Skip to content

Commit d705916

Browse files
authored
Internationalization support for Calendar (adobe#1804)
Also fixes a bug in ListLayout: When an item moved from one section to another, cached nodes and layout infos were not updated properly.
1 parent 74040b7 commit d705916

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3034
-128
lines changed

NOTICE.txt

+87
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,90 @@ This codebase contains a portion of code that vuejs adapted from jest-dom which
127127
* https://github.com/testing-library/jest-dom/blob/main/LICENSE
128128

129129
------------------------------------------------------------------------------
130+
This codebase contains a modified portion of code from ICU which can be obtained at:
131+
* SOURCE:
132+
* https://github.com/unicode-org/icu
133+
134+
* LICENSE:
135+
COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later)
136+
137+
Copyright © 1991-2020 Unicode, Inc. All rights reserved.
138+
Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
139+
140+
Permission is hereby granted, free of charge, to any person obtaining
141+
a copy of the Unicode data files and any associated documentation
142+
(the "Data Files") or Unicode software and any associated documentation
143+
(the "Software") to deal in the Data Files or Software
144+
without restriction, including without limitation the rights to use,
145+
copy, modify, merge, publish, distribute, and/or sell copies of
146+
the Data Files or Software, and to permit persons to whom the Data Files
147+
or Software are furnished to do so, provided that either
148+
(a) this copyright and permission notice appear with all copies
149+
of the Data Files or Software, or
150+
(b) this copyright and permission notice appear in associated
151+
Documentation.
152+
153+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
154+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
155+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
156+
NONINFRINGEMENT OF THIRD PARTY RIGHTS.
157+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
158+
NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
159+
DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
160+
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
161+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
162+
PERFORMANCE OF THE DATA FILES OR SOFTWARE.
163+
164+
Except as contained in this notice, the name of a copyright holder
165+
shall not be used in advertising or otherwise to promote the sale,
166+
use or other dealings in these Data Files or Software without prior
167+
written authorization of the copyright holder.
168+
169+
-------------------------------------------------------------------------------
170+
This codebase contains a modified portion of code from the TC39 Temporal proposal which can be obtained at:
171+
* SOURCE:
172+
* https://github.com/tc39/proposal-temporal
173+
174+
* LICENSE:
175+
Copyright (c) 2017, 2018, 2019, 2020
176+
Ecma International. All rights reserved.
177+
178+
All Software contained in this document ("Software") is protected by copyright
179+
and is being made available under the "BSD License", included below.
180+
181+
This Software may be subject to third party rights (rights from parties other
182+
than Ecma International), including patent rights, and no licenses under such
183+
third party rights are granted under this license even if the third party
184+
concerned is a member of Ecma International.
185+
186+
SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT
187+
https://ecma-international.org/memento/codeofconduct.htm
188+
FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO
189+
IMPLEMENT ECMA INTERNATIONAL STANDARDS.
190+
191+
192+
Redistribution and use in source and binary forms, with or without
193+
modification, are permitted provided that the following conditions are met:
194+
195+
1. Redistributions of source code must retain the above copyright notice, this
196+
list of conditions and the following disclaimer.
197+
198+
2. Redistributions in binary form must reproduce the above copyright notice,
199+
this list of conditions and the following disclaimer in the documentation
200+
and/or other materials provided with the distribution.
201+
202+
3. Neither the name of the authors nor Ecma International may be used to
203+
endorse or promote products derived from this software without specific prior
204+
written permission.
205+
206+
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND
207+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
208+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
209+
ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE
210+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
211+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
212+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
213+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
214+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
215+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
216+
SUCH DAMAGE.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# @internationalized/date
2+
3+
This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright 2020 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
export * from './src';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "@internationalized/date",
3+
"version": "3.0.0-alpha.1",
4+
"description": "Internationalized calendar and date manipulation utilities",
5+
"license": "Apache-2.0",
6+
"private": true,
7+
"main": "dist/main.js",
8+
"module": "dist/module.js",
9+
"types": "dist/types.d.ts",
10+
"source": "src/index.ts",
11+
"files": ["dist"],
12+
"sideEffects": false,
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/adobe/react-spectrum"
16+
},
17+
"dependencies": {
18+
"@babel/runtime": "^7.6.2"
19+
},
20+
"publishConfig": {
21+
"access": "public"
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/*
2+
* Copyright 2020 Adobe. All rights reserved.
3+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License. You may obtain a copy
5+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
*
7+
* Unless required by applicable law or agreed to in writing, software distributed under
8+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
* OF ANY KIND, either express or implied. See the License for the specific language
10+
* governing permissions and limitations under the License.
11+
*/
12+
13+
// Copied from ICU's IslamicCalendar.java
14+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
15+
16+
const UMALQURA_MONTHLENGTH = [
17+
//* 1300 -1302 */
18+
// "1010 1010 1010", "1101 0101 0100", "1110 1100 1001",
19+
0x0AAA, 0x0D54, 0x0EC9,
20+
//* 1303 -1307 */
21+
// "0110 1101 0100", "0110 1110 1010", "0011 0110 1100", "1010 1010 1101", "0101 0101 0101",
22+
0x06D4, 0x06EA, 0x036C, 0x0AAD, 0x0555,
23+
//* 1308 -1312 */
24+
// "0110 1010 1001", "0111 1001 0010", "1011 1010 1001", "0101 1101 0100", "1010 1101 1010",
25+
0x06A9, 0x0792, 0x0BA9, 0x05D4, 0x0ADA,
26+
//* 1313 -1317 */
27+
// "0101 0101 1100", "1101 0010 1101", "0110 1001 0101", "0111 0100 1010", "1011 0101 0100",
28+
0x055C, 0x0D2D, 0x0695, 0x074A, 0x0B54,
29+
//* 1318 -1322 */
30+
// "1011 0110 1010", "0101 1010 1101", "0100 1010 1110", "1010 0100 1111", "0101 0001 0111",
31+
0x0B6A, 0x05AD, 0x04AE, 0x0A4F, 0x0517,
32+
//* 1323 -1327 */
33+
// "0110 1000 1011", "0110 1010 0101", "1010 1101 0101", "0010 1101 0110", "1001 0101 1011",
34+
0x068B, 0x06A5, 0x0AD5, 0x02D6, 0x095B,
35+
//* 1328 -1332 */
36+
// "0100 1001 1101", "1010 0100 1101", "1101 0010 0110", "1101 1001 0101", "0101 1010 1100",
37+
0x049D, 0x0A4D, 0x0D26, 0x0D95, 0x05AC,
38+
//* 1333 -1337 */
39+
// "1001 1011 0110", "0010 1011 1010", "1010 0101 1011", "0101 0010 1011", "1010 1001 0101",
40+
0x09B6, 0x02BA, 0x0A5B, 0x052B, 0x0A95,
41+
//* 1338 -1342 */
42+
// "0110 1100 1010", "1010 1110 1001", "0010 1111 0100", "1001 0111 0110", "0010 1011 0110",
43+
0x06CA, 0x0AE9, 0x02F4, 0x0976, 0x02B6,
44+
//* 1343 -1347 */
45+
// "1001 0101 0110", "1010 1100 1010", "1011 1010 0100", "1011 1101 0010", "0101 1101 1001",
46+
0x0956, 0x0ACA, 0x0BA4, 0x0BD2, 0x05D9,
47+
//* 1348 -1352 */
48+
// "0010 1101 1100", "1001 0110 1101", "0101 0100 1101", "1010 1010 0101", "1011 0101 0010",
49+
0x02DC, 0x096D, 0x054D, 0x0AA5, 0x0B52,
50+
//* 1353 -1357 */
51+
// "1011 1010 0101", "0101 1011 0100", "1001 1011 0110", "0101 0101 0111", "0010 1001 0111",
52+
0x0BA5, 0x05B4, 0x09B6, 0x0557, 0x0297,
53+
//* 1358 -1362 */
54+
// "0101 0100 1011", "0110 1010 0011", "0111 0101 0010", "1011 0110 0101", "0101 0110 1010",
55+
0x054B, 0x06A3, 0x0752, 0x0B65, 0x056A,
56+
//* 1363 -1367 */
57+
// "1010 1010 1011", "0101 0010 1011", "1100 1001 0101", "1101 0100 1010", "1101 1010 0101",
58+
0x0AAB, 0x052B, 0x0C95, 0x0D4A, 0x0DA5,
59+
//* 1368 -1372 */
60+
// "0101 1100 1010", "1010 1101 0110", "1001 0101 0111", "0100 1010 1011", "1001 0100 1011",
61+
0x05CA, 0x0AD6, 0x0957, 0x04AB, 0x094B,
62+
//* 1373 -1377 */
63+
// "1010 1010 0101", "1011 0101 0010", "1011 0110 1010", "0101 0111 0101", "0010 0111 0110",
64+
0x0AA5, 0x0B52, 0x0B6A, 0x0575, 0x0276,
65+
//* 1378 -1382 */
66+
// "1000 1011 0111", "0100 0101 1011", "0101 0101 0101", "0101 1010 1001", "0101 1011 0100",
67+
0x08B7, 0x045B, 0x0555, 0x05A9, 0x05B4,
68+
//* 1383 -1387 */
69+
// "1001 1101 1010", "0100 1101 1101", "0010 0110 1110", "1001 0011 0110", "1010 1010 1010",
70+
0x09DA, 0x04DD, 0x026E, 0x0936, 0x0AAA,
71+
//* 1388 -1392 */
72+
// "1101 0101 0100", "1101 1011 0010", "0101 1101 0101", "0010 1101 1010", "1001 0101 1011",
73+
0x0D54, 0x0DB2, 0x05D5, 0x02DA, 0x095B,
74+
//* 1393 -1397 */
75+
// "0100 1010 1011", "1010 0101 0101", "1011 0100 1001", "1011 0110 0100", "1011 0111 0001",
76+
0x04AB, 0x0A55, 0x0B49, 0x0B64, 0x0B71,
77+
//* 1398 -1402 */
78+
// "0101 1011 0100", "1010 1011 0101", "1010 0101 0101", "1101 0010 0101", "1110 1001 0010",
79+
0x05B4, 0x0AB5, 0x0A55, 0x0D25, 0x0E92,
80+
//* 1403 -1407 */
81+
// "1110 1100 1001", "0110 1101 0100", "1010 1110 1001", "1001 0110 1011", "0100 1010 1011",
82+
0x0EC9, 0x06D4, 0x0AE9, 0x096B, 0x04AB,
83+
//* 1408 -1412 */
84+
// "1010 1001 0011", "1101 0100 1001", "1101 1010 0100", "1101 1011 0010", "1010 1011 1001",
85+
0x0A93, 0x0D49, 0x0DA4, 0x0DB2, 0x0AB9,
86+
//* 1413 -1417 */
87+
// "0100 1011 1010", "1010 0101 1011", "0101 0010 1011", "1010 1001 0101", "1011 0010 1010",
88+
0x04BA, 0x0A5B, 0x052B, 0x0A95, 0x0B2A,
89+
//* 1418 -1422 */
90+
// "1011 0101 0101", "0101 0101 1100", "0100 1011 1101", "0010 0011 1101", "1001 0001 1101",
91+
0x0B55, 0x055C, 0x04BD, 0x023D, 0x091D,
92+
//* 1423 -1427 */
93+
// "1010 1001 0101", "1011 0100 1010", "1011 0101 1010", "0101 0110 1101", "0010 1011 0110",
94+
0x0A95, 0x0B4A, 0x0B5A, 0x056D, 0x02B6,
95+
//* 1428 -1432 */
96+
// "1001 0011 1011", "0100 1001 1011", "0110 0101 0101", "0110 1010 1001", "0111 0101 0100",
97+
0x093B, 0x049B, 0x0655, 0x06A9, 0x0754,
98+
//* 1433 -1437 */
99+
// "1011 0110 1010", "0101 0110 1100", "1010 1010 1101", "0101 0101 0101", "1011 0010 1001",
100+
0x0B6A, 0x056C, 0x0AAD, 0x0555, 0x0B29,
101+
//* 1438 -1442 */
102+
// "1011 1001 0010", "1011 1010 1001", "0101 1101 0100", "1010 1101 1010", "0101 0101 1010",
103+
0x0B92, 0x0BA9, 0x05D4, 0x0ADA, 0x055A,
104+
//* 1443 -1447 */
105+
// "1010 1010 1011", "0101 1001 0101", "0111 0100 1001", "0111 0110 0100", "1011 1010 1010",
106+
0x0AAB, 0x0595, 0x0749, 0x0764, 0x0BAA,
107+
//* 1448 -1452 */
108+
// "0101 1011 0101", "0010 1011 0110", "1010 0101 0110", "1110 0100 1101", "1011 0010 0101",
109+
0x05B5, 0x02B6, 0x0A56, 0x0E4D, 0x0B25,
110+
//* 1453 -1457 */
111+
// "1011 0101 0010", "1011 0110 1010", "0101 1010 1101", "0010 1010 1110", "1001 0010 1111",
112+
0x0B52, 0x0B6A, 0x05AD, 0x02AE, 0x092F,
113+
//* 1458 -1462 */
114+
// "0100 1001 0111", "0110 0100 1011", "0110 1010 0101", "0110 1010 1100", "1010 1101 0110",
115+
0x0497, 0x064B, 0x06A5, 0x06AC, 0x0AD6,
116+
//* 1463 -1467 */
117+
// "0101 0101 1101", "0100 1001 1101", "1010 0100 1101", "1101 0001 0110", "1101 1001 0101",
118+
0x055D, 0x049D, 0x0A4D, 0x0D16, 0x0D95,
119+
//* 1468 -1472 */
120+
// "0101 1010 1010", "0101 1011 0101", "0010 1101 1010", "1001 0101 1011", "0100 1010 1101",
121+
0x05AA, 0x05B5, 0x02DA, 0x095B, 0x04AD,
122+
//* 1473 -1477 */
123+
// "0101 1001 0101", "0110 1100 1010", "0110 1110 0100", "1010 1110 1010", "0100 1111 0101",
124+
0x0595, 0x06CA, 0x06E4, 0x0AEA, 0x04F5,
125+
//* 1478 -1482 */
126+
// "0010 1011 0110", "1001 0101 0110", "1010 1010 1010", "1011 0101 0100", "1011 1101 0010",
127+
0x02B6, 0x0956, 0x0AAA, 0x0B54, 0x0BD2,
128+
//* 1483 -1487 */
129+
// "0101 1101 1001", "0010 1110 1010", "1001 0110 1101", "0100 1010 1101", "1010 1001 0101",
130+
0x05D9, 0x02EA, 0x096D, 0x04AD, 0x0A95,
131+
//* 1488 -1492 */
132+
// "1011 0100 1010", "1011 1010 0101", "0101 1011 0010", "1001 1011 0101", "0100 1101 0110",
133+
0x0B4A, 0x0BA5, 0x05B2, 0x09B5, 0x04D6,
134+
//* 1493 -1497 */
135+
// "1010 1001 0111", "0101 0100 0111", "0110 1001 0011", "0111 0100 1001", "1011 0101 0101",
136+
0x0A97, 0x0547, 0x0693, 0x0749, 0x0B55,
137+
//* 1498 -1508 */
138+
// "0101 0110 1010", "1010 0110 1011", "0101 0010 1011", "1010 1000 1011", "1101 0100 0110", "1101 1010 0011", "0101 1100 1010", "1010 1101 0110", "0100 1101 1011", "0010 0110 1011", "1001 0100 1011",
139+
0x056A, 0x0A6B, 0x052B, 0x0A8B, 0x0D46, 0x0DA3, 0x05CA, 0x0AD6, 0x04DB, 0x026B, 0x094B,
140+
//* 1509 -1519 */
141+
// "1010 1010 0101", "1011 0101 0010", "1011 0110 1001", "0101 0111 0101", "0001 0111 0110", "1000 1011 0111", "0010 0101 1011", "0101 0010 1011", "0101 0110 0101", "0101 1011 0100", "1001 1101 1010",
142+
0x0AA5, 0x0B52, 0x0B69, 0x0575, 0x0176, 0x08B7, 0x025B, 0x052B, 0x0565, 0x05B4, 0x09DA,
143+
//* 1520 -1530 */
144+
// "0100 1110 1101", "0001 0110 1101", "1000 1011 0110", "1010 1010 0110", "1101 0101 0010", "1101 1010 1001", "0101 1101 0100", "1010 1101 1010", "1001 0101 1011", "0100 1010 1011", "0110 0101 0011",
145+
0x04ED, 0x016D, 0x08B6, 0x0AA6, 0x0D52, 0x0DA9, 0x05D4, 0x0ADA, 0x095B, 0x04AB, 0x0653,
146+
//* 1531 -1541 */
147+
// "0111 0010 1001", "0111 0110 0010", "1011 1010 1001", "0101 1011 0010", "1010 1011 0101", "0101 0101 0101", "1011 0010 0101", "1101 1001 0010", "1110 1100 1001", "0110 1101 0010", "1010 1110 1001",
148+
0x0729, 0x0762, 0x0BA9, 0x05B2, 0x0AB5, 0x0555, 0x0B25, 0x0D92, 0x0EC9, 0x06D2, 0x0AE9,
149+
//* 1542 -1552 */
150+
// "0101 0110 1011", "0100 1010 1011", "1010 0101 0101", "1101 0010 1001", "1101 0101 0100", "1101 1010 1010", "1001 1011 0101", "0100 1011 1010", "1010 0011 1011", "0100 1001 1011", "1010 0100 1101",
151+
0x056B, 0x04AB, 0x0A55, 0x0D29, 0x0D54, 0x0DAA, 0x09B5, 0x04BA, 0x0A3B, 0x049B, 0x0A4D,
152+
//* 1553 -1563 */
153+
// "1010 1010 1010", "1010 1101 0101", "0010 1101 1010", "1001 0101 1101", "0100 0101 1110", "1010 0010 1110", "1100 1001 1010", "1101 0101 0101", "0110 1011 0010", "0110 1011 1001", "0100 1011 1010",
154+
0x0AAA, 0x0AD5, 0x02DA, 0x095D, 0x045E, 0x0A2E, 0x0C9A, 0x0D55, 0x06B2, 0x06B9, 0x04BA,
155+
//* 1564 -1574 */
156+
// "1010 0101 1101", "0101 0010 1101", "1010 1001 0101", "1011 0101 0010", "1011 1010 1000", "1011 1011 0100", "0101 1011 1001", "0010 1101 1010", "1001 0101 1010", "1011 0100 1010", "1101 1010 0100",
157+
0x0A5D, 0x052D, 0x0A95, 0x0B52, 0x0BA8, 0x0BB4, 0x05B9, 0x02DA, 0x095A, 0x0B4A, 0x0DA4,
158+
//* 1575 -1585 */
159+
// "1110 1101 0001", "0110 1110 1000", "1011 0110 1010", "0101 0110 1101", "0101 0011 0101", "0110 1001 0101", "1101 0100 1010", "1101 1010 1000", "1101 1101 0100", "0110 1101 1010", "0101 0101 1011",
160+
0x0ED1, 0x06E8, 0x0B6A, 0x056D, 0x0535, 0x0695, 0x0D4A, 0x0DA8, 0x0DD4, 0x06DA, 0x055B,
161+
//* 1586 -1596 */
162+
// "0010 1001 1101", "0110 0010 1011", "1011 0001 0101", "1011 0100 1010", "1011 1001 0101", "0101 1010 1010", "1010 1010 1110", "1001 0010 1110", "1100 1000 1111", "0101 0010 0111", "0110 1001 0101",
163+
0x029D, 0x062B, 0x0B15, 0x0B4A, 0x0B95, 0x05AA, 0x0AAE, 0x092E, 0x0C8F, 0x0527, 0x0695,
164+
//* 1597 -1600 */
165+
// "0110 1010 1010", "1010 1101 0110", "0101 0101 1101", "0010 1001 1101", };
166+
0x06AA, 0x0AD6, 0x055D, 0x029D
167+
];
168+
169+
console.log(Buffer.from(new Uint16Array(UMALQURA_MONTHLENGTH).buffer).toString('base64'));

0 commit comments

Comments
 (0)