@react-aria/i18n 3.6.1 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/real-main.js +167 -85
- package/dist/real-main.js.map +1 -1
- package/dist/real-module.js +167 -85
- package/dist/real-module.js.map +1 -1
- package/package.json +10 -10
package/dist/real-main.js
CHANGED
|
@@ -21,6 +21,26 @@ $parcel$export(module.exports, "useNumberFormatter", () => $fea93c5b7c90d9f4$exp
|
|
|
21
21
|
$parcel$export(module.exports, "useCollator", () => $27a5ce66022270ad$export$a16aca283550c30d);
|
|
22
22
|
$parcel$export(module.exports, "useFilter", () => $832d079b867c7223$export$3274cf84b703fff);
|
|
23
23
|
/*
|
|
24
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
25
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
26
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
27
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
30
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
31
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
32
|
+
* governing permissions and limitations under the License.
|
|
33
|
+
*/ /*
|
|
34
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
35
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
36
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
37
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
38
|
+
*
|
|
39
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
40
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
41
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
42
|
+
* governing permissions and limitations under the License.
|
|
43
|
+
*/ /*
|
|
24
44
|
* Copyright 2020 Adobe. All rights reserved.
|
|
25
45
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
26
46
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -32,37 +52,37 @@ $parcel$export(module.exports, "useFilter", () => $832d079b867c7223$export$3274c
|
|
|
32
52
|
* governing permissions and limitations under the License.
|
|
33
53
|
*/ // https://en.wikipedia.org/wiki/Right-to-left
|
|
34
54
|
const $4d65847630a056a8$var$RTL_SCRIPTS = new Set([
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
"Arab",
|
|
56
|
+
"Syrc",
|
|
57
|
+
"Samr",
|
|
58
|
+
"Mand",
|
|
59
|
+
"Thaa",
|
|
60
|
+
"Mend",
|
|
61
|
+
"Nkoo",
|
|
62
|
+
"Adlm",
|
|
63
|
+
"Rohg",
|
|
64
|
+
"Hebr"
|
|
45
65
|
]);
|
|
46
66
|
const $4d65847630a056a8$var$RTL_LANGS = new Set([
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
"ae",
|
|
68
|
+
"ar",
|
|
69
|
+
"arc",
|
|
70
|
+
"bcc",
|
|
71
|
+
"bqi",
|
|
72
|
+
"ckb",
|
|
73
|
+
"dv",
|
|
74
|
+
"fa",
|
|
75
|
+
"glk",
|
|
76
|
+
"he",
|
|
77
|
+
"ku",
|
|
78
|
+
"mzn",
|
|
79
|
+
"nqo",
|
|
80
|
+
"pnb",
|
|
81
|
+
"ps",
|
|
82
|
+
"sd",
|
|
83
|
+
"ug",
|
|
84
|
+
"ur",
|
|
85
|
+
"yi"
|
|
66
86
|
]);
|
|
67
87
|
function $4d65847630a056a8$export$702d680b21cbd764(locale) {
|
|
68
88
|
// If the Intl.Locale API is available, use it to get the script for the locale.
|
|
@@ -74,28 +94,38 @@ function $4d65847630a056a8$export$702d680b21cbd764(locale) {
|
|
|
74
94
|
return $4d65847630a056a8$var$RTL_SCRIPTS.has(script);
|
|
75
95
|
}
|
|
76
96
|
// If not, just guess by the language (first part of the locale)
|
|
77
|
-
let lang = locale.split(
|
|
97
|
+
let lang = locale.split("-")[0];
|
|
78
98
|
return $4d65847630a056a8$var$RTL_LANGS.has(lang);
|
|
79
99
|
}
|
|
80
100
|
|
|
81
101
|
|
|
82
|
-
|
|
102
|
+
/*
|
|
103
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
104
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
105
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
106
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
107
|
+
*
|
|
108
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
109
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
110
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
111
|
+
* governing permissions and limitations under the License.
|
|
112
|
+
*/
|
|
83
113
|
|
|
84
114
|
|
|
85
115
|
function $2919bdec75484e64$export$f09106e7c6677ec5() {
|
|
86
116
|
// @ts-ignore
|
|
87
|
-
let locale = typeof navigator !==
|
|
117
|
+
let locale = typeof navigator !== "undefined" && (navigator.language || navigator.userLanguage) || "en-US";
|
|
88
118
|
try {
|
|
89
119
|
// @ts-ignore
|
|
90
120
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
91
121
|
locale
|
|
92
122
|
]);
|
|
93
123
|
} catch (_err) {
|
|
94
|
-
locale =
|
|
124
|
+
locale = "en-US";
|
|
95
125
|
}
|
|
96
126
|
return {
|
|
97
127
|
locale: locale,
|
|
98
|
-
direction: $4d65847630a056a8$export$702d680b21cbd764(locale) ?
|
|
128
|
+
direction: (0, $4d65847630a056a8$export$702d680b21cbd764)(locale) ? "rtl" : "ltr"
|
|
99
129
|
};
|
|
100
130
|
}
|
|
101
131
|
let $2919bdec75484e64$var$currentLocale = $2919bdec75484e64$export$f09106e7c6677ec5();
|
|
@@ -105,42 +135,42 @@ function $2919bdec75484e64$var$updateLocale() {
|
|
|
105
135
|
for (let listener of $2919bdec75484e64$var$listeners)listener($2919bdec75484e64$var$currentLocale);
|
|
106
136
|
}
|
|
107
137
|
function $2919bdec75484e64$export$188ec29ebc2bdc3a() {
|
|
108
|
-
let isSSR = $87SwK$reactariassr.useIsSSR();
|
|
109
|
-
let [defaultLocale, setDefaultLocale] = $87SwK$react.useState($2919bdec75484e64$var$currentLocale);
|
|
110
|
-
$87SwK$react.useEffect(()=>{
|
|
111
|
-
if ($2919bdec75484e64$var$listeners.size === 0) window.addEventListener(
|
|
138
|
+
let isSSR = (0, $87SwK$reactariassr.useIsSSR)();
|
|
139
|
+
let [defaultLocale, setDefaultLocale] = (0, $87SwK$react.useState)($2919bdec75484e64$var$currentLocale);
|
|
140
|
+
(0, $87SwK$react.useEffect)(()=>{
|
|
141
|
+
if ($2919bdec75484e64$var$listeners.size === 0) window.addEventListener("languagechange", $2919bdec75484e64$var$updateLocale);
|
|
112
142
|
$2919bdec75484e64$var$listeners.add(setDefaultLocale);
|
|
113
143
|
return ()=>{
|
|
114
144
|
$2919bdec75484e64$var$listeners.delete(setDefaultLocale);
|
|
115
|
-
if ($2919bdec75484e64$var$listeners.size === 0) window.removeEventListener(
|
|
145
|
+
if ($2919bdec75484e64$var$listeners.size === 0) window.removeEventListener("languagechange", $2919bdec75484e64$var$updateLocale);
|
|
116
146
|
};
|
|
117
147
|
}, []);
|
|
118
148
|
// We cannot determine the browser's language on the server, so default to
|
|
119
149
|
// en-US. This will be updated after hydration on the client to the correct value.
|
|
120
150
|
if (isSSR) return {
|
|
121
|
-
locale:
|
|
122
|
-
direction:
|
|
151
|
+
locale: "en-US",
|
|
152
|
+
direction: "ltr"
|
|
123
153
|
};
|
|
124
154
|
return defaultLocale;
|
|
125
155
|
}
|
|
126
156
|
|
|
127
157
|
|
|
128
158
|
|
|
129
|
-
const $47fa5ec5ff482271$var$I18nContext = /*#__PURE__*/ ($parcel$interopDefault($87SwK$react)).createContext(null);
|
|
159
|
+
const $47fa5ec5ff482271$var$I18nContext = /*#__PURE__*/ (0, ($parcel$interopDefault($87SwK$react))).createContext(null);
|
|
130
160
|
function $47fa5ec5ff482271$export$a54013f0d02a8f82(props) {
|
|
131
161
|
let { locale: locale , children: children } = props;
|
|
132
|
-
let defaultLocale = $2919bdec75484e64$export$188ec29ebc2bdc3a();
|
|
162
|
+
let defaultLocale = (0, $2919bdec75484e64$export$188ec29ebc2bdc3a)();
|
|
133
163
|
let value = locale ? {
|
|
134
164
|
locale: locale,
|
|
135
|
-
direction: $4d65847630a056a8$export$702d680b21cbd764(locale) ?
|
|
165
|
+
direction: (0, $4d65847630a056a8$export$702d680b21cbd764)(locale) ? "rtl" : "ltr"
|
|
136
166
|
} : defaultLocale;
|
|
137
|
-
return
|
|
167
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($87SwK$react))).createElement($47fa5ec5ff482271$var$I18nContext.Provider, {
|
|
138
168
|
value: value
|
|
139
|
-
}, children)
|
|
169
|
+
}, children);
|
|
140
170
|
}
|
|
141
171
|
function $47fa5ec5ff482271$export$43bb16f9c6d9e3f7() {
|
|
142
|
-
let defaultLocale = $2919bdec75484e64$export$188ec29ebc2bdc3a();
|
|
143
|
-
let context = $87SwK$react.useContext($47fa5ec5ff482271$var$I18nContext);
|
|
172
|
+
let defaultLocale = (0, $2919bdec75484e64$export$188ec29ebc2bdc3a)();
|
|
173
|
+
let context = (0, $87SwK$react.useContext)($47fa5ec5ff482271$var$I18nContext);
|
|
144
174
|
return context || defaultLocale;
|
|
145
175
|
}
|
|
146
176
|
|
|
@@ -149,57 +179,82 @@ var $227f31f0c647c5fc$exports = {};
|
|
|
149
179
|
"use strict";
|
|
150
180
|
|
|
151
181
|
|
|
152
|
-
|
|
182
|
+
/*
|
|
183
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
184
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
185
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
186
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
187
|
+
*
|
|
188
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
189
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
190
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
191
|
+
* governing permissions and limitations under the License.
|
|
192
|
+
*/
|
|
153
193
|
|
|
154
194
|
|
|
155
195
|
const $fc53663969a3d00a$var$cache = new WeakMap();
|
|
156
196
|
function $fc53663969a3d00a$var$getCachedDictionary(strings) {
|
|
157
197
|
let dictionary = $fc53663969a3d00a$var$cache.get(strings);
|
|
158
198
|
if (!dictionary) {
|
|
159
|
-
dictionary = new $87SwK$internationalizedstring.LocalizedStringDictionary(strings);
|
|
199
|
+
dictionary = new (0, $87SwK$internationalizedstring.LocalizedStringDictionary)(strings);
|
|
160
200
|
$fc53663969a3d00a$var$cache.set(strings, dictionary);
|
|
161
201
|
}
|
|
162
202
|
return dictionary;
|
|
163
203
|
}
|
|
164
204
|
function $fc53663969a3d00a$export$f12b703ca79dfbb1(strings) {
|
|
165
|
-
let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
|
|
166
|
-
let dictionary = $87SwK$react.useMemo(()=>$fc53663969a3d00a$var$getCachedDictionary(strings)
|
|
167
|
-
, [
|
|
205
|
+
let { locale: locale } = (0, $47fa5ec5ff482271$export$43bb16f9c6d9e3f7)();
|
|
206
|
+
let dictionary = (0, $87SwK$react.useMemo)(()=>$fc53663969a3d00a$var$getCachedDictionary(strings), [
|
|
168
207
|
strings
|
|
169
208
|
]);
|
|
170
|
-
return $87SwK$react.useMemo(()=>new $87SwK$internationalizedstring.LocalizedStringFormatter(locale, dictionary)
|
|
171
|
-
, [
|
|
209
|
+
return (0, $87SwK$react.useMemo)(()=>new (0, $87SwK$internationalizedstring.LocalizedStringFormatter)(locale, dictionary), [
|
|
172
210
|
locale,
|
|
173
211
|
dictionary
|
|
174
212
|
]);
|
|
175
213
|
}
|
|
176
214
|
|
|
177
215
|
|
|
216
|
+
/*
|
|
217
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
218
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
219
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
220
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
221
|
+
*
|
|
222
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
223
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
224
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
225
|
+
* governing permissions and limitations under the License.
|
|
226
|
+
*/
|
|
178
227
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}) {
|
|
182
|
-
let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
|
|
228
|
+
function $cb6a3e7d490e97a4$export$a2f47a3d2973640(options = {}) {
|
|
229
|
+
let { locale: locale } = (0, $47fa5ec5ff482271$export$43bb16f9c6d9e3f7)();
|
|
183
230
|
// @ts-ignore
|
|
184
|
-
return $87SwK$react.useMemo(()=>new Intl.ListFormat(locale, options)
|
|
185
|
-
, [
|
|
231
|
+
return (0, $87SwK$react.useMemo)(()=>new Intl.ListFormat(locale, options), [
|
|
186
232
|
locale,
|
|
187
233
|
options
|
|
188
234
|
]);
|
|
189
235
|
}
|
|
190
236
|
|
|
191
237
|
|
|
192
|
-
|
|
238
|
+
/*
|
|
239
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
240
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
241
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
242
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
243
|
+
*
|
|
244
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
245
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
246
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
247
|
+
* governing permissions and limitations under the License.
|
|
248
|
+
*/
|
|
193
249
|
|
|
194
250
|
|
|
195
251
|
function $b80c530ff2e20243$export$85fd5fdf27bacc79(options) {
|
|
196
252
|
// Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
|
|
197
|
-
let lastOptions = $87SwK$react.useRef(null);
|
|
253
|
+
let lastOptions = (0, $87SwK$react.useRef)(null);
|
|
198
254
|
if (options && lastOptions.current && $b80c530ff2e20243$var$isEqual(options, lastOptions.current)) options = lastOptions.current;
|
|
199
255
|
lastOptions.current = options;
|
|
200
|
-
let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
|
|
201
|
-
return $87SwK$react.useMemo(()=>new $87SwK$internationalizeddate.DateFormatter(locale, options)
|
|
202
|
-
, [
|
|
256
|
+
let { locale: locale } = (0, $47fa5ec5ff482271$export$43bb16f9c6d9e3f7)();
|
|
257
|
+
return (0, $87SwK$react.useMemo)(()=>new (0, $87SwK$internationalizeddate.DateFormatter)(locale, options), [
|
|
203
258
|
locale,
|
|
204
259
|
options
|
|
205
260
|
]);
|
|
@@ -216,26 +271,43 @@ function $b80c530ff2e20243$var$isEqual(a, b) {
|
|
|
216
271
|
}
|
|
217
272
|
|
|
218
273
|
|
|
274
|
+
/*
|
|
275
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
276
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
277
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
278
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
279
|
+
*
|
|
280
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
281
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
282
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
283
|
+
* governing permissions and limitations under the License.
|
|
284
|
+
*/
|
|
219
285
|
|
|
220
286
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
|
|
225
|
-
return $87SwK$react.useMemo(()=>new $87SwK$internationalizednumber.NumberFormatter(locale, options)
|
|
226
|
-
, [
|
|
287
|
+
function $fea93c5b7c90d9f4$export$b7a616150fdb9f44(options = {}) {
|
|
288
|
+
let { locale: locale } = (0, $47fa5ec5ff482271$export$43bb16f9c6d9e3f7)();
|
|
289
|
+
return (0, $87SwK$react.useMemo)(()=>new (0, $87SwK$internationalizednumber.NumberFormatter)(locale, options), [
|
|
227
290
|
locale,
|
|
228
291
|
options
|
|
229
292
|
]);
|
|
230
293
|
}
|
|
231
294
|
|
|
232
295
|
|
|
233
|
-
|
|
296
|
+
/*
|
|
297
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
298
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
299
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
300
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
301
|
+
*
|
|
302
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
303
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
304
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
305
|
+
* governing permissions and limitations under the License.
|
|
306
|
+
*/
|
|
234
307
|
let $27a5ce66022270ad$var$cache = new Map();
|
|
235
308
|
function $27a5ce66022270ad$export$a16aca283550c30d(options) {
|
|
236
|
-
let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
|
|
237
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
238
|
-
).join() : '');
|
|
309
|
+
let { locale: locale } = (0, $47fa5ec5ff482271$export$43bb16f9c6d9e3f7)();
|
|
310
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
|
|
239
311
|
if ($27a5ce66022270ad$var$cache.has(cacheKey)) return $27a5ce66022270ad$var$cache.get(cacheKey);
|
|
240
312
|
let formatter = new Intl.Collator(locale, options);
|
|
241
313
|
$27a5ce66022270ad$var$cache.set(cacheKey, formatter);
|
|
@@ -243,10 +315,20 @@ function $27a5ce66022270ad$export$a16aca283550c30d(options) {
|
|
|
243
315
|
}
|
|
244
316
|
|
|
245
317
|
|
|
246
|
-
|
|
318
|
+
/*
|
|
319
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
320
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
321
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
322
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
323
|
+
*
|
|
324
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
325
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
326
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
327
|
+
* governing permissions and limitations under the License.
|
|
328
|
+
*/
|
|
247
329
|
function $832d079b867c7223$export$3274cf84b703fff(options) {
|
|
248
|
-
let collator = $27a5ce66022270ad$export$a16aca283550c30d({
|
|
249
|
-
usage:
|
|
330
|
+
let collator = (0, $27a5ce66022270ad$export$a16aca283550c30d)({
|
|
331
|
+
usage: "search",
|
|
250
332
|
...options
|
|
251
333
|
});
|
|
252
334
|
// TODO(later): these methods don't currently support the ignorePunctuation option.
|
|
@@ -255,20 +337,20 @@ function $832d079b867c7223$export$3274cf84b703fff(options) {
|
|
|
255
337
|
if (substring.length === 0) return true;
|
|
256
338
|
// Normalize both strings so we can slice safely
|
|
257
339
|
// TODO: take into account the ignorePunctuation option as well...
|
|
258
|
-
string = string.normalize(
|
|
259
|
-
substring = substring.normalize(
|
|
340
|
+
string = string.normalize("NFC");
|
|
341
|
+
substring = substring.normalize("NFC");
|
|
260
342
|
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
261
343
|
},
|
|
262
344
|
endsWith (string, substring) {
|
|
263
345
|
if (substring.length === 0) return true;
|
|
264
|
-
string = string.normalize(
|
|
265
|
-
substring = substring.normalize(
|
|
346
|
+
string = string.normalize("NFC");
|
|
347
|
+
substring = substring.normalize("NFC");
|
|
266
348
|
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
267
349
|
},
|
|
268
350
|
contains (string, substring) {
|
|
269
351
|
if (substring.length === 0) return true;
|
|
270
|
-
string = string.normalize(
|
|
271
|
-
substring = substring.normalize(
|
|
352
|
+
string = string.normalize("NFC");
|
|
353
|
+
substring = substring.normalize("NFC");
|
|
272
354
|
let scan = 0;
|
|
273
355
|
let sliceLen = substring.length;
|
|
274
356
|
for(; scan + sliceLen <= string.length; scan++){
|
package/dist/real-main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AEAA,EAUG,AAVH;;;;;;;;;;CAUG,AAVH,EAUG,CAEH,EAA8C,AAA9C,4CAA8C;AAC9C,KAAK,CAAC,iCAAW,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAAA,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;AAAA,CAAC;AAC5G,KAAK,CAAC,+BAAS,GAAG,GAAG,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18n/src/index.ts","packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/useDefaultLocale.ts","node_modules/@parcel/node-resolver-core/lib/_empty.js","packages/@react-aria/i18n/src/useLocalizedStringFormatter.ts","packages/@react-aria/i18n/src/useListFormatter.tsx","packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react-aria/i18n/src/useCollator.ts","packages/@react-aria/i18n/src/useFilter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {I18nProvider, useLocale} from './context';\nexport {useMessageFormatter} from './useMessageFormatter';\nexport {useLocalizedStringFormatter} from './useLocalizedStringFormatter';\nexport {useListFormatter} from './useListFormatter';\nexport {useDateFormatter} from './useDateFormatter';\nexport {useNumberFormatter} from './useNumberFormatter';\nexport {useCollator} from './useCollator';\nexport {useFilter} from './useFilter';\n\nexport type {FormatMessage} from './useMessageFormatter';\nexport type {I18nProviderProps} from './context';\nexport type {Locale} from './useDefaultLocale';\nexport type {LocalizedStrings} from '@internationalized/message';\nexport type {DateFormatterOptions} from './useDateFormatter';\nexport type {DateFormatter} from '@internationalized/date';\nexport type {Filter} from './useFilter';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\nexport interface I18nProviderProps {\n /** Contents that should have the locale applied. */\n children: ReactNode,\n /** The locale to apply to the children. */\n locale?: string\n}\n\nconst I18nContext = React.createContext<Locale>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps) {\n let {locale, children} = props;\n let defaultLocale = useDefaultLocale();\n\n let value: Locale = locale ? {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n } : defaultLocale;\n\n return (\n <I18nContext.Provider value={value}>\n {children}\n </I18nContext.Provider>\n );\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n let defaultLocale = useDefaultLocale();\n let context = useContext(I18nContext);\n return context || defaultLocale;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(locale: string) {\n // If the Intl.Locale API is available, use it to get the script for the locale.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n // @ts-ignore\n if (Intl.Locale) {\n // @ts-ignore\n let script = new Intl.Locale(locale).maximize().script;\n return RTL_SCRIPTS.has(script);\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = locale.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string,\n /** The writing direction for the locale. */\n direction: Direction\n}\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n // @ts-ignore\n let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n try {\n // @ts-ignore\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch (_err) {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr'\n };\n }\n\n return defaultLocale;\n}\n","\"use strict\";","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {LocalizedString, LocalizedStringDictionary, LocalizedStringFormatter, LocalizedStrings} from '@internationalized/string';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\nconst cache = new WeakMap();\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(strings: LocalizedStrings<K, T>): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Provides localized string formatting for the current locale. Supports interpolating variables,\n * selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.\n * @param strings - A mapping of languages to localized strings by key.\n */\nexport function useLocalizedStringFormatter<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>): LocalizedStringFormatter<K, T> {\n let {locale} = useLocale();\n let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized list formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the list formatter for performance.\n * @param options - Formatting options.\n */\n\n// Typescript version 4.7 supports Intl.ListFormat - TODO upgrade\n// @ts-ignore\nexport function useListFormatter(options: Intl.ListFormatOptions = {}): Intl.ListFormat {\n let {locale} = useLocale();\n // @ts-ignore\n return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DateFormatter} from '@internationalized/date';\nimport {useLocale} from './context';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateFormatterOptions extends Intl.DateTimeFormatOptions {\n calendar?: string\n}\n\n/**\n * Provides localized date formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the date formatter for performance.\n * @param options - Formatting options.\n */\nexport function useDateFormatter(options?: DateFormatterOptions): DateFormatter {\n // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.\n let lastOptions = useRef(null);\n if (options && lastOptions.current && isEqual(options, lastOptions.current)) {\n options = lastOptions.current;\n }\n\n lastOptions.current = options;\n\n let {locale} = useLocale();\n return useMemo(() => new DateFormatter(locale, options), [locale, options]);\n}\n\nfunction isEqual(a: DateFormatterOptions, b: DateFormatterOptions) {\n if (a === b) {\n return true;\n }\n\n let aKeys = Object.keys(a);\n let bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let key of aKeys) {\n if (b[key] !== a[key]) {\n return false;\n }\n }\n\n return true;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {NumberFormatOptions, NumberFormatter} from '@internationalized/number';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {locale} = useLocale();\n return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\n\nlet cache = new Map<string, Intl.Collator>();\n\n/**\n * Provides localized string collation for the current locale. Automatically updates when the locale changes,\n * and handles caching of the collator for performance.\n * @param options - Collator options.\n */\nexport function useCollator(options?: Intl.CollatorOptions): Intl.Collator {\n let {locale} = useLocale();\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n\n let formatter = new Intl.Collator(locale, options);\n cache.set(cacheKey, formatter);\n return formatter;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCollator} from './useCollator';\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean,\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean,\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n let collator = useCollator({\n usage: 'search',\n ...options\n });\n\n // TODO(later): these methods don't currently support the ignorePunctuation option.\n\n return {\n startsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings so we can slice safely\n // TODO: take into account the ignorePunctuation option as well...\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(0, substring.length), substring) === 0;\n },\n endsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(-substring.length), substring) === 0;\n },\n contains(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n\n let scan = 0;\n let sliceLen = substring.length;\n for (; scan + sliceLen <= string.length; scan++) {\n let slice = string.slice(scan, scan + sliceLen);\n if (collator.compare(substring, slice) === 0) {\n return true;\n }\n }\n\n return false;\n }\n };\n}\n"],"names":[],"version":3,"file":"real-main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,8CAA8C;AAC9C,MAAM,oCAAc,IAAI,IAAI;IAAC;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;CAAO;AAC5G,MAAM,kCAAY,IAAI,IAAI;IAAC;IAAM;IAAM;IAAO;IAAO;IAAO;IAAO;IAAM;IAAM;IAAO;IAAM;IAAM;IAAO;IAAO;IAAO;IAAM;IAAM;IAAM;IAAM;CAAK;AAK7I,SAAS,0CAAM,MAAc,EAAE;IACpC,gFAAgF;IAChF,uGAAuG;IACvG,aAAa;IACb,IAAI,KAAK,MAAM,EAAE;QACf,aAAa;QACb,IAAI,SAAS,IAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ,GAAG,MAAM;QACtD,OAAO,kCAAY,GAAG,CAAC;IACzB,CAAC;IAED,gEAAgE;IAChE,IAAI,OAAO,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;IAC/B,OAAO,gCAAU,GAAG,CAAC;AACvB;;CDtBC,GAED;AEZA;;;;;;;;;;CAUC,GAED;;;AAeO,SAAS,4CAA2B;IACzC,aAAa;IACb,IAAI,SAAS,AAAC,OAAO,cAAc,eAAgB,CAAA,UAAU,QAAQ,IAAI,UAAU,YAAY,AAAD,KAAO;IACrG,IAAI;QACF,aAAa;QACb,KAAK,cAAc,CAAC,kBAAkB,CAAC;YAAC;SAAO;IACjD,EAAE,OAAO,MAAM;QACb,SAAS;IACX;IACA,OAAO;gBACL;QACA,WAAW,CAA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GAAG,OAAO;IACZ;IAEA,mFAAmF;IAEnF,OAAO;QACL,YAAW,MAAM,EAAE,SAAS,EAAE;YAC5B,IAAI,UAAU,MAAM,KAAK,GACvB,OAAO,IAAI;YAGb,gDAAgD;YAChD,kEAAkE;YAClE,SAAS,OAAO,SAAS,CAAC;YAC1B,YAAY,UAAU,SAAS,CAAC;YAChC,OAAO,SAAS,OAAO,CAAC,OAAO,KAAK,CAAC,GAAG,UAAU,MAAM,GAAG,eAAe;QAC5E;QACA,UAAS,MAAM,EAAE,SAAS,EAAE;YAC1B,IAAI,UAAU,MAAM,KAAK,GACvB,OAAO,IAAI;YAGb,SAAS,OAAO,SAAS,CAAC;YAC1B,YAAY,UAAU,SAAS,CAAC;YAChC,OAAO,SAAS,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,UAAU,MAAM,GAAG,eAAe;QAC1E;QACA,UAAS,MAAM,EAAE,SAAS,EAAE;YAC1B,IAAI,UAAU,MAAM,KAAK,GACvB,OAAO,IAAI;YAGb,SAAS,OAAO,SAAS,CAAC;YAC1B,YAAY,UAAU,SAAS,CAAC;YAEhC,IAAI,OAAO;YACX,IAAI,WAAW,UAAU,MAAM;YAC/B,MAAO,OAAO,YAAY,OAAO,MAAM,EAAE,OAAQ;gBAC/C,IAAI,QAAQ,OAAO,KAAK,CAAC,MAAM,OAAO;gBACtC,IAAI,SAAS,OAAO,CAAC,WAAW,WAAW,GACzC,OAAO,IAAI;YAEf;YAEA,OAAO,KAAK;QACd;IACF;AACF;","sources":["packages/@react-aria/i18n/src/index.ts","packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/useDefaultLocale.ts","node_modules/@parcel/node-resolver-core/lib/_empty.js","packages/@react-aria/i18n/src/useLocalizedStringFormatter.ts","packages/@react-aria/i18n/src/useListFormatter.tsx","packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react-aria/i18n/src/useCollator.ts","packages/@react-aria/i18n/src/useFilter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {I18nProvider, useLocale} from './context';\nexport {useMessageFormatter} from './useMessageFormatter';\nexport {useLocalizedStringFormatter} from './useLocalizedStringFormatter';\nexport {useListFormatter} from './useListFormatter';\nexport {useDateFormatter} from './useDateFormatter';\nexport {useNumberFormatter} from './useNumberFormatter';\nexport {useCollator} from './useCollator';\nexport {useFilter} from './useFilter';\n\nexport type {FormatMessage} from './useMessageFormatter';\nexport type {I18nProviderProps} from './context';\nexport type {Locale} from './useDefaultLocale';\nexport type {LocalizedStrings} from '@internationalized/message';\nexport type {DateFormatterOptions} from './useDateFormatter';\nexport type {DateFormatter} from '@internationalized/date';\nexport type {Filter} from './useFilter';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\nexport interface I18nProviderProps {\n /** Contents that should have the locale applied. */\n children: ReactNode,\n /** The locale to apply to the children. */\n locale?: string\n}\n\nconst I18nContext = React.createContext<Locale>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps) {\n let {locale, children} = props;\n let defaultLocale = useDefaultLocale();\n\n let value: Locale = locale ? {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n } : defaultLocale;\n\n return (\n <I18nContext.Provider value={value}>\n {children}\n </I18nContext.Provider>\n );\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n let defaultLocale = useDefaultLocale();\n let context = useContext(I18nContext);\n return context || defaultLocale;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(locale: string) {\n // If the Intl.Locale API is available, use it to get the script for the locale.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n // @ts-ignore\n if (Intl.Locale) {\n // @ts-ignore\n let script = new Intl.Locale(locale).maximize().script;\n return RTL_SCRIPTS.has(script);\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = locale.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string,\n /** The writing direction for the locale. */\n direction: Direction\n}\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n // @ts-ignore\n let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n try {\n // @ts-ignore\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch (_err) {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr'\n };\n }\n\n return defaultLocale;\n}\n","\"use strict\";","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {LocalizedString, LocalizedStringDictionary, LocalizedStringFormatter, LocalizedStrings} from '@internationalized/string';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\nconst cache = new WeakMap();\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(strings: LocalizedStrings<K, T>): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Provides localized string formatting for the current locale. Supports interpolating variables,\n * selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.\n * @param strings - A mapping of languages to localized strings by key.\n */\nexport function useLocalizedStringFormatter<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>): LocalizedStringFormatter<K, T> {\n let {locale} = useLocale();\n let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized list formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the list formatter for performance.\n * @param options - Formatting options.\n */\n\n// Typescript version 4.7 supports Intl.ListFormat - TODO upgrade\n// @ts-ignore\nexport function useListFormatter(options: Intl.ListFormatOptions = {}): Intl.ListFormat {\n let {locale} = useLocale();\n // @ts-ignore\n return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DateFormatter} from '@internationalized/date';\nimport {useLocale} from './context';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateFormatterOptions extends Intl.DateTimeFormatOptions {\n calendar?: string\n}\n\n/**\n * Provides localized date formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the date formatter for performance.\n * @param options - Formatting options.\n */\nexport function useDateFormatter(options?: DateFormatterOptions): DateFormatter {\n // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.\n let lastOptions = useRef(null);\n if (options && lastOptions.current && isEqual(options, lastOptions.current)) {\n options = lastOptions.current;\n }\n\n lastOptions.current = options;\n\n let {locale} = useLocale();\n return useMemo(() => new DateFormatter(locale, options), [locale, options]);\n}\n\nfunction isEqual(a: DateFormatterOptions, b: DateFormatterOptions) {\n if (a === b) {\n return true;\n }\n\n let aKeys = Object.keys(a);\n let bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let key of aKeys) {\n if (b[key] !== a[key]) {\n return false;\n }\n }\n\n return true;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {NumberFormatOptions, NumberFormatter} from '@internationalized/number';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {locale} = useLocale();\n return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\n\nlet cache = new Map<string, Intl.Collator>();\n\n/**\n * Provides localized string collation for the current locale. Automatically updates when the locale changes,\n * and handles caching of the collator for performance.\n * @param options - Collator options.\n */\nexport function useCollator(options?: Intl.CollatorOptions): Intl.Collator {\n let {locale} = useLocale();\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n\n let formatter = new Intl.Collator(locale, options);\n cache.set(cacheKey, formatter);\n return formatter;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCollator} from './useCollator';\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean,\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean,\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n let collator = useCollator({\n usage: 'search',\n ...options\n });\n\n // TODO(later): these methods don't currently support the ignorePunctuation option.\n\n return {\n startsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings so we can slice safely\n // TODO: take into account the ignorePunctuation option as well...\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(0, substring.length), substring) === 0;\n },\n endsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(-substring.length), substring) === 0;\n },\n contains(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n\n let scan = 0;\n let sliceLen = substring.length;\n for (; scan + sliceLen <= string.length; scan++) {\n let slice = string.slice(scan, scan + sliceLen);\n if (collator.compare(substring, slice) === 0) {\n return true;\n }\n }\n\n return false;\n }\n };\n}\n"],"names":[],"version":3,"file":"real-main.js.map"}
|
package/dist/real-module.js
CHANGED
|
@@ -5,6 +5,26 @@ import {DateFormatter as $iFADg$DateFormatter} from "@internationalized/date";
|
|
|
5
5
|
import {NumberFormatter as $iFADg$NumberFormatter} from "@internationalized/number";
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/ /*
|
|
18
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
19
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
21
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
24
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
25
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
26
|
+
* governing permissions and limitations under the License.
|
|
27
|
+
*/ /*
|
|
8
28
|
* Copyright 2020 Adobe. All rights reserved.
|
|
9
29
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
30
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -16,37 +36,37 @@ import {NumberFormatter as $iFADg$NumberFormatter} from "@internationalized/numb
|
|
|
16
36
|
* governing permissions and limitations under the License.
|
|
17
37
|
*/ // https://en.wikipedia.org/wiki/Right-to-left
|
|
18
38
|
const $148a7a147e38ea7f$var$RTL_SCRIPTS = new Set([
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
"Arab",
|
|
40
|
+
"Syrc",
|
|
41
|
+
"Samr",
|
|
42
|
+
"Mand",
|
|
43
|
+
"Thaa",
|
|
44
|
+
"Mend",
|
|
45
|
+
"Nkoo",
|
|
46
|
+
"Adlm",
|
|
47
|
+
"Rohg",
|
|
48
|
+
"Hebr"
|
|
29
49
|
]);
|
|
30
50
|
const $148a7a147e38ea7f$var$RTL_LANGS = new Set([
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
"ae",
|
|
52
|
+
"ar",
|
|
53
|
+
"arc",
|
|
54
|
+
"bcc",
|
|
55
|
+
"bqi",
|
|
56
|
+
"ckb",
|
|
57
|
+
"dv",
|
|
58
|
+
"fa",
|
|
59
|
+
"glk",
|
|
60
|
+
"he",
|
|
61
|
+
"ku",
|
|
62
|
+
"mzn",
|
|
63
|
+
"nqo",
|
|
64
|
+
"pnb",
|
|
65
|
+
"ps",
|
|
66
|
+
"sd",
|
|
67
|
+
"ug",
|
|
68
|
+
"ur",
|
|
69
|
+
"yi"
|
|
50
70
|
]);
|
|
51
71
|
function $148a7a147e38ea7f$export$702d680b21cbd764(locale) {
|
|
52
72
|
// If the Intl.Locale API is available, use it to get the script for the locale.
|
|
@@ -58,28 +78,38 @@ function $148a7a147e38ea7f$export$702d680b21cbd764(locale) {
|
|
|
58
78
|
return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(script);
|
|
59
79
|
}
|
|
60
80
|
// If not, just guess by the language (first part of the locale)
|
|
61
|
-
let lang = locale.split(
|
|
81
|
+
let lang = locale.split("-")[0];
|
|
62
82
|
return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
|
|
66
|
-
|
|
86
|
+
/*
|
|
87
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
88
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
89
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
90
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
91
|
+
*
|
|
92
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
93
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
94
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
95
|
+
* governing permissions and limitations under the License.
|
|
96
|
+
*/
|
|
67
97
|
|
|
68
98
|
|
|
69
99
|
function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
|
|
70
100
|
// @ts-ignore
|
|
71
|
-
let locale = typeof navigator !==
|
|
101
|
+
let locale = typeof navigator !== "undefined" && (navigator.language || navigator.userLanguage) || "en-US";
|
|
72
102
|
try {
|
|
73
103
|
// @ts-ignore
|
|
74
104
|
Intl.DateTimeFormat.supportedLocalesOf([
|
|
75
105
|
locale
|
|
76
106
|
]);
|
|
77
107
|
} catch (_err) {
|
|
78
|
-
locale =
|
|
108
|
+
locale = "en-US";
|
|
79
109
|
}
|
|
80
110
|
return {
|
|
81
111
|
locale: locale,
|
|
82
|
-
direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ?
|
|
112
|
+
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? "rtl" : "ltr"
|
|
83
113
|
};
|
|
84
114
|
}
|
|
85
115
|
let $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
|
|
@@ -89,42 +119,42 @@ function $1e5a04cdaf7d1af8$var$updateLocale() {
|
|
|
89
119
|
for (let listener of $1e5a04cdaf7d1af8$var$listeners)listener($1e5a04cdaf7d1af8$var$currentLocale);
|
|
90
120
|
}
|
|
91
121
|
function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
|
|
92
|
-
let isSSR = $iFADg$useIsSSR();
|
|
93
|
-
let [defaultLocale, setDefaultLocale] = $iFADg$useState($1e5a04cdaf7d1af8$var$currentLocale);
|
|
94
|
-
$iFADg$useEffect(()=>{
|
|
95
|
-
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener(
|
|
122
|
+
let isSSR = (0, $iFADg$useIsSSR)();
|
|
123
|
+
let [defaultLocale, setDefaultLocale] = (0, $iFADg$useState)($1e5a04cdaf7d1af8$var$currentLocale);
|
|
124
|
+
(0, $iFADg$useEffect)(()=>{
|
|
125
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
|
|
96
126
|
$1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale);
|
|
97
127
|
return ()=>{
|
|
98
128
|
$1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale);
|
|
99
|
-
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener(
|
|
129
|
+
if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener("languagechange", $1e5a04cdaf7d1af8$var$updateLocale);
|
|
100
130
|
};
|
|
101
131
|
}, []);
|
|
102
132
|
// We cannot determine the browser's language on the server, so default to
|
|
103
133
|
// en-US. This will be updated after hydration on the client to the correct value.
|
|
104
134
|
if (isSSR) return {
|
|
105
|
-
locale:
|
|
106
|
-
direction:
|
|
135
|
+
locale: "en-US",
|
|
136
|
+
direction: "ltr"
|
|
107
137
|
};
|
|
108
138
|
return defaultLocale;
|
|
109
139
|
}
|
|
110
140
|
|
|
111
141
|
|
|
112
142
|
|
|
113
|
-
const $18f2051aff69b9bf$var$I18nContext = /*#__PURE__*/ $iFADg$react.createContext(null);
|
|
143
|
+
const $18f2051aff69b9bf$var$I18nContext = /*#__PURE__*/ (0, $iFADg$react).createContext(null);
|
|
114
144
|
function $18f2051aff69b9bf$export$a54013f0d02a8f82(props) {
|
|
115
145
|
let { locale: locale , children: children } = props;
|
|
116
|
-
let defaultLocale = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
|
|
146
|
+
let defaultLocale = (0, $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a)();
|
|
117
147
|
let value = locale ? {
|
|
118
148
|
locale: locale,
|
|
119
|
-
direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ?
|
|
149
|
+
direction: (0, $148a7a147e38ea7f$export$702d680b21cbd764)(locale) ? "rtl" : "ltr"
|
|
120
150
|
} : defaultLocale;
|
|
121
|
-
return
|
|
151
|
+
return /*#__PURE__*/ (0, $iFADg$react).createElement($18f2051aff69b9bf$var$I18nContext.Provider, {
|
|
122
152
|
value: value
|
|
123
|
-
}, children)
|
|
153
|
+
}, children);
|
|
124
154
|
}
|
|
125
155
|
function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
|
|
126
|
-
let defaultLocale = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
|
|
127
|
-
let context = $iFADg$useContext($18f2051aff69b9bf$var$I18nContext);
|
|
156
|
+
let defaultLocale = (0, $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a)();
|
|
157
|
+
let context = (0, $iFADg$useContext)($18f2051aff69b9bf$var$I18nContext);
|
|
128
158
|
return context || defaultLocale;
|
|
129
159
|
}
|
|
130
160
|
|
|
@@ -133,57 +163,82 @@ var $2aa2084a6c2b6b4f$exports = {};
|
|
|
133
163
|
"use strict";
|
|
134
164
|
|
|
135
165
|
|
|
136
|
-
|
|
166
|
+
/*
|
|
167
|
+
* Copyright 2022 Adobe. All rights reserved.
|
|
168
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
169
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
170
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
171
|
+
*
|
|
172
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
173
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
174
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
175
|
+
* governing permissions and limitations under the License.
|
|
176
|
+
*/
|
|
137
177
|
|
|
138
178
|
|
|
139
179
|
const $fca6afa0e843324b$var$cache = new WeakMap();
|
|
140
180
|
function $fca6afa0e843324b$var$getCachedDictionary(strings) {
|
|
141
181
|
let dictionary = $fca6afa0e843324b$var$cache.get(strings);
|
|
142
182
|
if (!dictionary) {
|
|
143
|
-
dictionary = new $iFADg$LocalizedStringDictionary(strings);
|
|
183
|
+
dictionary = new (0, $iFADg$LocalizedStringDictionary)(strings);
|
|
144
184
|
$fca6afa0e843324b$var$cache.set(strings, dictionary);
|
|
145
185
|
}
|
|
146
186
|
return dictionary;
|
|
147
187
|
}
|
|
148
188
|
function $fca6afa0e843324b$export$f12b703ca79dfbb1(strings) {
|
|
149
|
-
let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
150
|
-
let dictionary = $iFADg$useMemo(()=>$fca6afa0e843324b$var$getCachedDictionary(strings)
|
|
151
|
-
, [
|
|
189
|
+
let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
|
|
190
|
+
let dictionary = (0, $iFADg$useMemo)(()=>$fca6afa0e843324b$var$getCachedDictionary(strings), [
|
|
152
191
|
strings
|
|
153
192
|
]);
|
|
154
|
-
return $iFADg$useMemo(()=>new $iFADg$LocalizedStringFormatter(locale, dictionary)
|
|
155
|
-
, [
|
|
193
|
+
return (0, $iFADg$useMemo)(()=>new (0, $iFADg$LocalizedStringFormatter)(locale, dictionary), [
|
|
156
194
|
locale,
|
|
157
195
|
dictionary
|
|
158
196
|
]);
|
|
159
197
|
}
|
|
160
198
|
|
|
161
199
|
|
|
200
|
+
/*
|
|
201
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
202
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
203
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
204
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
205
|
+
*
|
|
206
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
207
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
208
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
209
|
+
* governing permissions and limitations under the License.
|
|
210
|
+
*/
|
|
162
211
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}) {
|
|
166
|
-
let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
212
|
+
function $33bf17300c498528$export$a2f47a3d2973640(options = {}) {
|
|
213
|
+
let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
|
|
167
214
|
// @ts-ignore
|
|
168
|
-
return $iFADg$useMemo(()=>new Intl.ListFormat(locale, options)
|
|
169
|
-
, [
|
|
215
|
+
return (0, $iFADg$useMemo)(()=>new Intl.ListFormat(locale, options), [
|
|
170
216
|
locale,
|
|
171
217
|
options
|
|
172
218
|
]);
|
|
173
219
|
}
|
|
174
220
|
|
|
175
221
|
|
|
176
|
-
|
|
222
|
+
/*
|
|
223
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
224
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
225
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
226
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
227
|
+
*
|
|
228
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
229
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
230
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
231
|
+
* governing permissions and limitations under the License.
|
|
232
|
+
*/
|
|
177
233
|
|
|
178
234
|
|
|
179
235
|
function $896ba0a80a8f4d36$export$85fd5fdf27bacc79(options) {
|
|
180
236
|
// Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
|
|
181
|
-
let lastOptions = $iFADg$useRef(null);
|
|
237
|
+
let lastOptions = (0, $iFADg$useRef)(null);
|
|
182
238
|
if (options && lastOptions.current && $896ba0a80a8f4d36$var$isEqual(options, lastOptions.current)) options = lastOptions.current;
|
|
183
239
|
lastOptions.current = options;
|
|
184
|
-
let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
185
|
-
return $iFADg$useMemo(()=>new $iFADg$DateFormatter(locale, options)
|
|
186
|
-
, [
|
|
240
|
+
let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
|
|
241
|
+
return (0, $iFADg$useMemo)(()=>new (0, $iFADg$DateFormatter)(locale, options), [
|
|
187
242
|
locale,
|
|
188
243
|
options
|
|
189
244
|
]);
|
|
@@ -200,26 +255,43 @@ function $896ba0a80a8f4d36$var$isEqual(a, b) {
|
|
|
200
255
|
}
|
|
201
256
|
|
|
202
257
|
|
|
258
|
+
/*
|
|
259
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
260
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
261
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
262
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
263
|
+
*
|
|
264
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
265
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
266
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
267
|
+
* governing permissions and limitations under the License.
|
|
268
|
+
*/
|
|
203
269
|
|
|
204
270
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
209
|
-
return $iFADg$useMemo(()=>new $iFADg$NumberFormatter(locale, options)
|
|
210
|
-
, [
|
|
271
|
+
function $a916eb452884faea$export$b7a616150fdb9f44(options = {}) {
|
|
272
|
+
let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
|
|
273
|
+
return (0, $iFADg$useMemo)(()=>new (0, $iFADg$NumberFormatter)(locale, options), [
|
|
211
274
|
locale,
|
|
212
275
|
options
|
|
213
276
|
]);
|
|
214
277
|
}
|
|
215
278
|
|
|
216
279
|
|
|
217
|
-
|
|
280
|
+
/*
|
|
281
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
282
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
283
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
284
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
285
|
+
*
|
|
286
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
287
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
288
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
289
|
+
* governing permissions and limitations under the License.
|
|
290
|
+
*/
|
|
218
291
|
let $325a3faab7a68acd$var$cache = new Map();
|
|
219
292
|
function $325a3faab7a68acd$export$a16aca283550c30d(options) {
|
|
220
|
-
let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
|
|
221
|
-
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
|
|
222
|
-
).join() : '');
|
|
293
|
+
let { locale: locale } = (0, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7)();
|
|
294
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1).join() : "");
|
|
223
295
|
if ($325a3faab7a68acd$var$cache.has(cacheKey)) return $325a3faab7a68acd$var$cache.get(cacheKey);
|
|
224
296
|
let formatter = new Intl.Collator(locale, options);
|
|
225
297
|
$325a3faab7a68acd$var$cache.set(cacheKey, formatter);
|
|
@@ -227,10 +299,20 @@ function $325a3faab7a68acd$export$a16aca283550c30d(options) {
|
|
|
227
299
|
}
|
|
228
300
|
|
|
229
301
|
|
|
230
|
-
|
|
302
|
+
/*
|
|
303
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
304
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
305
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
306
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
307
|
+
*
|
|
308
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
309
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
310
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
311
|
+
* governing permissions and limitations under the License.
|
|
312
|
+
*/
|
|
231
313
|
function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
232
|
-
let collator = $325a3faab7a68acd$export$a16aca283550c30d({
|
|
233
|
-
usage:
|
|
314
|
+
let collator = (0, $325a3faab7a68acd$export$a16aca283550c30d)({
|
|
315
|
+
usage: "search",
|
|
234
316
|
...options
|
|
235
317
|
});
|
|
236
318
|
// TODO(later): these methods don't currently support the ignorePunctuation option.
|
|
@@ -239,20 +321,20 @@ function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
|
|
|
239
321
|
if (substring.length === 0) return true;
|
|
240
322
|
// Normalize both strings so we can slice safely
|
|
241
323
|
// TODO: take into account the ignorePunctuation option as well...
|
|
242
|
-
string = string.normalize(
|
|
243
|
-
substring = substring.normalize(
|
|
324
|
+
string = string.normalize("NFC");
|
|
325
|
+
substring = substring.normalize("NFC");
|
|
244
326
|
return collator.compare(string.slice(0, substring.length), substring) === 0;
|
|
245
327
|
},
|
|
246
328
|
endsWith (string, substring) {
|
|
247
329
|
if (substring.length === 0) return true;
|
|
248
|
-
string = string.normalize(
|
|
249
|
-
substring = substring.normalize(
|
|
330
|
+
string = string.normalize("NFC");
|
|
331
|
+
substring = substring.normalize("NFC");
|
|
250
332
|
return collator.compare(string.slice(-substring.length), substring) === 0;
|
|
251
333
|
},
|
|
252
334
|
contains (string, substring) {
|
|
253
335
|
if (substring.length === 0) return true;
|
|
254
|
-
string = string.normalize(
|
|
255
|
-
substring = substring.normalize(
|
|
336
|
+
string = string.normalize("NFC");
|
|
337
|
+
substring = substring.normalize("NFC");
|
|
256
338
|
let scan = 0;
|
|
257
339
|
let sliceLen = substring.length;
|
|
258
340
|
for(; scan + sliceLen <= string.length; scan++){
|
package/dist/real-module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AEAA,EAUG,AAVH;;;;;;;;;;CAUG,AAVH,EAUG,CAEH,EAA8C,AAA9C,4CAA8C;AAC9C,KAAK,CAAC,iCAAW,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAAA,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;IAAE,CAAM;AAAA,CAAC;AAC5G,KAAK,CAAC,+BAAS,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAAA,CAAI;IAAE,CAAI;IAAE,CAAK;IAAE,CAAK;IAAE,CAAK;IAAE,CAAK;IAAE,CAAI;IAAE,CAAI;IAAE,CAAK;IAAE,CAAI;IAAE,CAAI;IAAE,CAAK;IAAE,CAAK;IAAE,CAAK;IAAE,CAAI;IAAE,CAAI;IAAE,CAAI;IAAE,CAAI;IAAE,CAAI;AAAA,CAAC;SAKpI,yCAAK,CAAC,MAAc,EAAE,CAAC;IACrC,EAAgF,AAAhF,8EAAgF;IAChF,EAAuG,AAAvG,qGAAuG;IACvG,EAAa,AAAb,WAAa;IACb,EAAE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S,GAAG,SAAS,CAAC,SAAS,CAAC,CAAK;YACrC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,MAAM,CAAC;QAC3E,CAAC;QACD,QAAQ,EAAC,MAAM,EAAE,SAAS,EAAE,CAAC;YAC3B,EAAE,EAAE,SAAS,CAAC,MAAM,KAAK,CAAC,EACxB,MAAM,CAAC,IAAI;YAGb,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,CAAK;YAC/B,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC,CAAK;YAErC,GAAG,CAAC,IAAI,GAAG,CAAC;YACZ,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,MAAM;YAC/B,GAAG,GAAI,IAAI,GAAG,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,GAAI,CAAC;gBAChD,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ;gBAC9C,EAAE,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,MAAM,CAAC,EAC1C,MAAM,CAAC,IAAI;YAEf,CAAC;YAED,MAAM,CAAC,KAAK;QACd,CAAC;IACH,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/i18n/src/index.ts","packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/useDefaultLocale.ts","node_modules/@parcel/node-resolver-core/lib/_empty.js","packages/@react-aria/i18n/src/useLocalizedStringFormatter.ts","packages/@react-aria/i18n/src/useListFormatter.tsx","packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react-aria/i18n/src/useCollator.ts","packages/@react-aria/i18n/src/useFilter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {I18nProvider, useLocale} from './context';\nexport {useMessageFormatter} from './useMessageFormatter';\nexport {useLocalizedStringFormatter} from './useLocalizedStringFormatter';\nexport {useListFormatter} from './useListFormatter';\nexport {useDateFormatter} from './useDateFormatter';\nexport {useNumberFormatter} from './useNumberFormatter';\nexport {useCollator} from './useCollator';\nexport {useFilter} from './useFilter';\n\nexport type {FormatMessage} from './useMessageFormatter';\nexport type {I18nProviderProps} from './context';\nexport type {Locale} from './useDefaultLocale';\nexport type {LocalizedStrings} from '@internationalized/message';\nexport type {DateFormatterOptions} from './useDateFormatter';\nexport type {DateFormatter} from '@internationalized/date';\nexport type {Filter} from './useFilter';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\nexport interface I18nProviderProps {\n /** Contents that should have the locale applied. */\n children: ReactNode,\n /** The locale to apply to the children. */\n locale?: string\n}\n\nconst I18nContext = React.createContext<Locale>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps) {\n let {locale, children} = props;\n let defaultLocale = useDefaultLocale();\n\n let value: Locale = locale ? {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n } : defaultLocale;\n\n return (\n <I18nContext.Provider value={value}>\n {children}\n </I18nContext.Provider>\n );\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n let defaultLocale = useDefaultLocale();\n let context = useContext(I18nContext);\n return context || defaultLocale;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(locale: string) {\n // If the Intl.Locale API is available, use it to get the script for the locale.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n // @ts-ignore\n if (Intl.Locale) {\n // @ts-ignore\n let script = new Intl.Locale(locale).maximize().script;\n return RTL_SCRIPTS.has(script);\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = locale.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string,\n /** The writing direction for the locale. */\n direction: Direction\n}\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n // @ts-ignore\n let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n try {\n // @ts-ignore\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch (_err) {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr'\n };\n }\n\n return defaultLocale;\n}\n","\"use strict\";","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {LocalizedString, LocalizedStringDictionary, LocalizedStringFormatter, LocalizedStrings} from '@internationalized/string';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\nconst cache = new WeakMap();\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(strings: LocalizedStrings<K, T>): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Provides localized string formatting for the current locale. Supports interpolating variables,\n * selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.\n * @param strings - A mapping of languages to localized strings by key.\n */\nexport function useLocalizedStringFormatter<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>): LocalizedStringFormatter<K, T> {\n let {locale} = useLocale();\n let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized list formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the list formatter for performance.\n * @param options - Formatting options.\n */\n\n// Typescript version 4.7 supports Intl.ListFormat - TODO upgrade\n// @ts-ignore\nexport function useListFormatter(options: Intl.ListFormatOptions = {}): Intl.ListFormat {\n let {locale} = useLocale();\n // @ts-ignore\n return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DateFormatter} from '@internationalized/date';\nimport {useLocale} from './context';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateFormatterOptions extends Intl.DateTimeFormatOptions {\n calendar?: string\n}\n\n/**\n * Provides localized date formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the date formatter for performance.\n * @param options - Formatting options.\n */\nexport function useDateFormatter(options?: DateFormatterOptions): DateFormatter {\n // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.\n let lastOptions = useRef(null);\n if (options && lastOptions.current && isEqual(options, lastOptions.current)) {\n options = lastOptions.current;\n }\n\n lastOptions.current = options;\n\n let {locale} = useLocale();\n return useMemo(() => new DateFormatter(locale, options), [locale, options]);\n}\n\nfunction isEqual(a: DateFormatterOptions, b: DateFormatterOptions) {\n if (a === b) {\n return true;\n }\n\n let aKeys = Object.keys(a);\n let bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let key of aKeys) {\n if (b[key] !== a[key]) {\n return false;\n }\n }\n\n return true;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {NumberFormatOptions, NumberFormatter} from '@internationalized/number';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {locale} = useLocale();\n return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\n\nlet cache = new Map<string, Intl.Collator>();\n\n/**\n * Provides localized string collation for the current locale. Automatically updates when the locale changes,\n * and handles caching of the collator for performance.\n * @param options - Collator options.\n */\nexport function useCollator(options?: Intl.CollatorOptions): Intl.Collator {\n let {locale} = useLocale();\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n\n let formatter = new Intl.Collator(locale, options);\n cache.set(cacheKey, formatter);\n return formatter;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCollator} from './useCollator';\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean,\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean,\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n let collator = useCollator({\n usage: 'search',\n ...options\n });\n\n // TODO(later): these methods don't currently support the ignorePunctuation option.\n\n return {\n startsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings so we can slice safely\n // TODO: take into account the ignorePunctuation option as well...\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(0, substring.length), substring) === 0;\n },\n endsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(-substring.length), substring) === 0;\n },\n contains(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n\n let scan = 0;\n let sliceLen = substring.length;\n for (; scan + sliceLen <= string.length; scan++) {\n let slice = string.slice(scan, scan + sliceLen);\n if (collator.compare(substring, slice) === 0) {\n return true;\n }\n }\n\n return false;\n }\n };\n}\n"],"names":[],"version":3,"file":"real-module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,8CAA8C;AAC9C,MAAM,oCAAc,IAAI,IAAI;IAAC;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ;IAAQ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AU,SAAS,CAAC;YAChC,OAAO,SAAS,OAAO,CAAC,OAAO,KAAK,CAAC,CAAC,UAAU,MAAM,GAAG,eAAe;QAC1E;QACA,UAAS,MAAM,EAAE,SAAS,EAAE;YAC1B,IAAI,UAAU,MAAM,KAAK,GACvB,OAAO,IAAI;YAGb,SAAS,OAAO,SAAS,CAAC;YAC1B,YAAY,UAAU,SAAS,CAAC;YAEhC,IAAI,OAAO;YACX,IAAI,WAAW,UAAU,MAAM;YAC/B,MAAO,OAAO,YAAY,OAAO,MAAM,EAAE,OAAQ;gBAC/C,IAAI,QAAQ,OAAO,KAAK,CAAC,MAAM,OAAO;gBACtC,IAAI,SAAS,OAAO,CAAC,WAAW,WAAW,GACzC,OAAO,IAAI;YAEf;YAEA,OAAO,KAAK;QACd;IACF;AACF;","sources":["packages/@react-aria/i18n/src/index.ts","packages/@react-aria/i18n/src/context.tsx","packages/@react-aria/i18n/src/utils.ts","packages/@react-aria/i18n/src/useDefaultLocale.ts","node_modules/@parcel/node-resolver-core/lib/_empty.js","packages/@react-aria/i18n/src/useLocalizedStringFormatter.ts","packages/@react-aria/i18n/src/useListFormatter.tsx","packages/@react-aria/i18n/src/useDateFormatter.ts","packages/@react-aria/i18n/src/useNumberFormatter.ts","packages/@react-aria/i18n/src/useCollator.ts","packages/@react-aria/i18n/src/useFilter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport {I18nProvider, useLocale} from './context';\nexport {useMessageFormatter} from './useMessageFormatter';\nexport {useLocalizedStringFormatter} from './useLocalizedStringFormatter';\nexport {useListFormatter} from './useListFormatter';\nexport {useDateFormatter} from './useDateFormatter';\nexport {useNumberFormatter} from './useNumberFormatter';\nexport {useCollator} from './useCollator';\nexport {useFilter} from './useFilter';\n\nexport type {FormatMessage} from './useMessageFormatter';\nexport type {I18nProviderProps} from './context';\nexport type {Locale} from './useDefaultLocale';\nexport type {LocalizedStrings} from '@internationalized/message';\nexport type {DateFormatterOptions} from './useDateFormatter';\nexport type {DateFormatter} from '@internationalized/date';\nexport type {Filter} from './useFilter';\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {isRTL} from './utils';\nimport {Locale, useDefaultLocale} from './useDefaultLocale';\nimport React, {ReactNode, useContext} from 'react';\n\nexport interface I18nProviderProps {\n /** Contents that should have the locale applied. */\n children: ReactNode,\n /** The locale to apply to the children. */\n locale?: string\n}\n\nconst I18nContext = React.createContext<Locale>(null);\n\n/**\n * Provides the locale for the application to all child components.\n */\nexport function I18nProvider(props: I18nProviderProps) {\n let {locale, children} = props;\n let defaultLocale = useDefaultLocale();\n\n let value: Locale = locale ? {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n } : defaultLocale;\n\n return (\n <I18nContext.Provider value={value}>\n {children}\n </I18nContext.Provider>\n );\n}\n\n/**\n * Returns the current locale and layout direction.\n */\nexport function useLocale(): Locale {\n let defaultLocale = useDefaultLocale();\n let context = useContext(I18nContext);\n return context || defaultLocale;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// https://en.wikipedia.org/wiki/Right-to-left\nconst RTL_SCRIPTS = new Set(['Arab', 'Syrc', 'Samr', 'Mand', 'Thaa', 'Mend', 'Nkoo', 'Adlm', 'Rohg', 'Hebr']);\nconst RTL_LANGS = new Set(['ae', 'ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'glk', 'he', 'ku', 'mzn', 'nqo', 'pnb', 'ps', 'sd', 'ug', 'ur', 'yi']);\n\n/**\n * Determines if a locale is read right to left using [Intl.Locale]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale}.\n */\nexport function isRTL(locale: string) {\n // If the Intl.Locale API is available, use it to get the script for the locale.\n // This is more accurate than guessing by language, since languages can be written in multiple scripts.\n // @ts-ignore\n if (Intl.Locale) {\n // @ts-ignore\n let script = new Intl.Locale(locale).maximize().script;\n return RTL_SCRIPTS.has(script);\n }\n\n // If not, just guess by the language (first part of the locale)\n let lang = locale.split('-')[0];\n return RTL_LANGS.has(lang);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {isRTL} from './utils';\nimport {useEffect, useState} from 'react';\nimport {useIsSSR} from '@react-aria/ssr';\n\nexport interface Locale {\n /** The [BCP47](https://www.ietf.org/rfc/bcp/bcp47.txt) language code for the locale. */\n locale: string,\n /** The writing direction for the locale. */\n direction: Direction\n}\n\n/**\n * Gets the locale setting of the browser.\n */\nexport function getDefaultLocale(): Locale {\n // @ts-ignore\n let locale = (typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage)) || 'en-US';\n try {\n // @ts-ignore\n Intl.DateTimeFormat.supportedLocalesOf([locale]);\n } catch (_err) {\n locale = 'en-US';\n }\n return {\n locale,\n direction: isRTL(locale) ? 'rtl' : 'ltr'\n };\n}\n\nlet currentLocale = getDefaultLocale();\nlet listeners = new Set<(locale: Locale) => void>();\n\nfunction updateLocale() {\n currentLocale = getDefaultLocale();\n for (let listener of listeners) {\n listener(currentLocale);\n }\n}\n\n/**\n * Returns the current browser/system language, and updates when it changes.\n */\nexport function useDefaultLocale(): Locale {\n let isSSR = useIsSSR();\n let [defaultLocale, setDefaultLocale] = useState(currentLocale);\n\n useEffect(() => {\n if (listeners.size === 0) {\n window.addEventListener('languagechange', updateLocale);\n }\n\n listeners.add(setDefaultLocale);\n\n return () => {\n listeners.delete(setDefaultLocale);\n if (listeners.size === 0) {\n window.removeEventListener('languagechange', updateLocale);\n }\n };\n }, []);\n\n // We cannot determine the browser's language on the server, so default to\n // en-US. This will be updated after hydration on the client to the correct value.\n if (isSSR) {\n return {\n locale: 'en-US',\n direction: 'ltr'\n };\n }\n\n return defaultLocale;\n}\n","\"use strict\";","/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {LocalizedString, LocalizedStringDictionary, LocalizedStringFormatter, LocalizedStrings} from '@internationalized/string';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\nconst cache = new WeakMap();\nfunction getCachedDictionary<K extends string, T extends LocalizedString>(strings: LocalizedStrings<K, T>): LocalizedStringDictionary<K, T> {\n let dictionary = cache.get(strings);\n if (!dictionary) {\n dictionary = new LocalizedStringDictionary(strings);\n cache.set(strings, dictionary);\n }\n\n return dictionary;\n}\n\n/**\n * Provides localized string formatting for the current locale. Supports interpolating variables,\n * selecting the correct pluralization, and formatting numbers. Automatically updates when the locale changes.\n * @param strings - A mapping of languages to localized strings by key.\n */\nexport function useLocalizedStringFormatter<K extends string = string, T extends LocalizedString = string>(strings: LocalizedStrings<K, T>): LocalizedStringFormatter<K, T> {\n let {locale} = useLocale();\n let dictionary = useMemo(() => getCachedDictionary(strings), [strings]);\n return useMemo(() => new LocalizedStringFormatter(locale, dictionary), [locale, dictionary]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized list formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the list formatter for performance.\n * @param options - Formatting options.\n */\n\n// Typescript version 4.7 supports Intl.ListFormat - TODO upgrade\n// @ts-ignore\nexport function useListFormatter(options: Intl.ListFormatOptions = {}): Intl.ListFormat {\n let {locale} = useLocale();\n // @ts-ignore\n return useMemo(() => new Intl.ListFormat(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DateFormatter} from '@internationalized/date';\nimport {useLocale} from './context';\nimport {useMemo, useRef} from 'react';\n\nexport interface DateFormatterOptions extends Intl.DateTimeFormatOptions {\n calendar?: string\n}\n\n/**\n * Provides localized date formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the date formatter for performance.\n * @param options - Formatting options.\n */\nexport function useDateFormatter(options?: DateFormatterOptions): DateFormatter {\n // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.\n let lastOptions = useRef(null);\n if (options && lastOptions.current && isEqual(options, lastOptions.current)) {\n options = lastOptions.current;\n }\n\n lastOptions.current = options;\n\n let {locale} = useLocale();\n return useMemo(() => new DateFormatter(locale, options), [locale, options]);\n}\n\nfunction isEqual(a: DateFormatterOptions, b: DateFormatterOptions) {\n if (a === b) {\n return true;\n }\n\n let aKeys = Object.keys(a);\n let bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n for (let key of aKeys) {\n if (b[key] !== a[key]) {\n return false;\n }\n }\n\n return true;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {NumberFormatOptions, NumberFormatter} from '@internationalized/number';\nimport {useLocale} from './context';\nimport {useMemo} from 'react';\n\n/**\n * Provides localized number formatting for the current locale. Automatically updates when the locale changes,\n * and handles caching of the number formatter for performance.\n * @param options - Formatting options.\n */\nexport function useNumberFormatter(options: NumberFormatOptions = {}): Intl.NumberFormat {\n let {locale} = useLocale();\n return useMemo(() => new NumberFormatter(locale, options), [locale, options]);\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useLocale} from './context';\n\nlet cache = new Map<string, Intl.Collator>();\n\n/**\n * Provides localized string collation for the current locale. Automatically updates when the locale changes,\n * and handles caching of the collator for performance.\n * @param options - Collator options.\n */\nexport function useCollator(options?: Intl.CollatorOptions): Intl.Collator {\n let {locale} = useLocale();\n\n let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : '');\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n\n let formatter = new Intl.Collator(locale, options);\n cache.set(cacheKey, formatter);\n return formatter;\n}\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {useCollator} from './useCollator';\n\nexport interface Filter {\n /** Returns whether a string starts with a given substring. */\n startsWith(string: string, substring: string): boolean,\n /** Returns whether a string ends with a given substring. */\n endsWith(string: string, substring: string): boolean,\n /** Returns whether a string contains a given substring. */\n contains(string: string, substring: string): boolean\n}\n\n/**\n * Provides localized string search functionality that is useful for filtering or matching items\n * in a list. Options can be provided to adjust the sensitivity to case, diacritics, and other parameters.\n */\nexport function useFilter(options?: Intl.CollatorOptions): Filter {\n let collator = useCollator({\n usage: 'search',\n ...options\n });\n\n // TODO(later): these methods don't currently support the ignorePunctuation option.\n\n return {\n startsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n // Normalize both strings so we can slice safely\n // TODO: take into account the ignorePunctuation option as well...\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(0, substring.length), substring) === 0;\n },\n endsWith(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n return collator.compare(string.slice(-substring.length), substring) === 0;\n },\n contains(string, substring) {\n if (substring.length === 0) {\n return true;\n }\n\n string = string.normalize('NFC');\n substring = substring.normalize('NFC');\n\n let scan = 0;\n let sliceLen = substring.length;\n for (; scan + sliceLen <= string.length; scan++) {\n let slice = string.slice(scan, scan + sliceLen);\n if (collator.compare(substring, slice) === 0) {\n return true;\n }\n }\n\n return false;\n }\n };\n}\n"],"names":[],"version":3,"file":"real-module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/i18n",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.3",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"url": "https://github.com/adobe/react-spectrum"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@internationalized/
|
|
46
|
-
"@internationalized/
|
|
47
|
-
"@internationalized/
|
|
48
|
-
"@
|
|
49
|
-
"@react-aria/
|
|
50
|
-
"@react-
|
|
51
|
-
"@
|
|
44
|
+
"@internationalized/date": "^3.0.2",
|
|
45
|
+
"@internationalized/message": "^3.0.10",
|
|
46
|
+
"@internationalized/number": "^3.1.2",
|
|
47
|
+
"@internationalized/string": "^3.0.1",
|
|
48
|
+
"@react-aria/ssr": "^3.4.1",
|
|
49
|
+
"@react-aria/utils": "^3.14.2",
|
|
50
|
+
"@react-types/shared": "^3.16.0",
|
|
51
|
+
"@swc/helpers": "^0.4.14"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
|
|
60
60
|
}
|