@react-aria/i18n 3.5.0 → 3.5.1

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/main.js CHANGED
@@ -1,298 +1,6 @@
1
- var $87SwK$react = require("react");
2
- var $87SwK$reactariassr = require("@react-aria/ssr");
3
- var $87SwK$internationalizedmessage = require("@internationalized/message");
4
- var $87SwK$internationalizedstring = require("@internationalized/string");
5
- var $87SwK$internationalizeddate = require("@internationalized/date");
6
- var $87SwK$internationalizednumber = require("@internationalized/number");
7
-
8
- function $parcel$export(e, n, v, s) {
9
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
- }
11
- function $parcel$interopDefault(a) {
12
- return a && a.__esModule ? a.default : a;
13
- }
14
-
15
- $parcel$export(module.exports, "I18nProvider", () => $47fa5ec5ff482271$export$a54013f0d02a8f82);
16
- $parcel$export(module.exports, "useLocale", () => $47fa5ec5ff482271$export$43bb16f9c6d9e3f7);
17
- $parcel$export(module.exports, "useMessageFormatter", () => $c376aa482226bf60$export$ec23bf898b1eed85);
18
- $parcel$export(module.exports, "useLocalizedStringFormatter", () => $fc53663969a3d00a$export$f12b703ca79dfbb1);
19
- $parcel$export(module.exports, "useDateFormatter", () => $b80c530ff2e20243$export$85fd5fdf27bacc79);
20
- $parcel$export(module.exports, "useNumberFormatter", () => $fea93c5b7c90d9f4$export$b7a616150fdb9f44);
21
- $parcel$export(module.exports, "useCollator", () => $27a5ce66022270ad$export$a16aca283550c30d);
22
- $parcel$export(module.exports, "useFilter", () => $832d079b867c7223$export$3274cf84b703fff);
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
- */ // https://en.wikipedia.org/wiki/Right-to-left
34
- const $4d65847630a056a8$var$RTL_SCRIPTS = new Set([
35
- 'Arab',
36
- 'Syrc',
37
- 'Samr',
38
- 'Mand',
39
- 'Thaa',
40
- 'Mend',
41
- 'Nkoo',
42
- 'Adlm',
43
- 'Rohg',
44
- 'Hebr'
45
- ]);
46
- const $4d65847630a056a8$var$RTL_LANGS = new Set([
47
- 'ae',
48
- 'ar',
49
- 'arc',
50
- 'bcc',
51
- 'bqi',
52
- 'ckb',
53
- 'dv',
54
- 'fa',
55
- 'glk',
56
- 'he',
57
- 'ku',
58
- 'mzn',
59
- 'nqo',
60
- 'pnb',
61
- 'ps',
62
- 'sd',
63
- 'ug',
64
- 'ur',
65
- 'yi'
66
- ]);
67
- function $4d65847630a056a8$export$702d680b21cbd764(locale) {
68
- // If the Intl.Locale API is available, use it to get the script for the locale.
69
- // This is more accurate than guessing by language, since languages can be written in multiple scripts.
70
- // @ts-ignore
71
- if (Intl.Locale) {
72
- // @ts-ignore
73
- let script = new Intl.Locale(locale).maximize().script;
74
- return $4d65847630a056a8$var$RTL_SCRIPTS.has(script);
75
- }
76
- // If not, just guess by the language (first part of the locale)
77
- let lang = locale.split('-')[0];
78
- return $4d65847630a056a8$var$RTL_LANGS.has(lang);
79
- }
80
-
81
-
82
-
83
-
84
-
85
- function $2919bdec75484e64$export$f09106e7c6677ec5() {
86
- // @ts-ignore
87
- let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
88
- try {
89
- // @ts-ignore
90
- Intl.DateTimeFormat.supportedLocalesOf([
91
- locale
92
- ]);
93
- } catch (_err) {
94
- locale = 'en-US';
95
- }
96
- return {
97
- locale: locale,
98
- direction: $4d65847630a056a8$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'
99
- };
100
- }
101
- let $2919bdec75484e64$var$currentLocale = $2919bdec75484e64$export$f09106e7c6677ec5();
102
- let $2919bdec75484e64$var$listeners = new Set();
103
- function $2919bdec75484e64$var$updateLocale() {
104
- $2919bdec75484e64$var$currentLocale = $2919bdec75484e64$export$f09106e7c6677ec5();
105
- for (let listener of $2919bdec75484e64$var$listeners)listener($2919bdec75484e64$var$currentLocale);
106
- }
107
- 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('languagechange', $2919bdec75484e64$var$updateLocale);
112
- $2919bdec75484e64$var$listeners.add(setDefaultLocale);
113
- return ()=>{
114
- $2919bdec75484e64$var$listeners.delete(setDefaultLocale);
115
- if ($2919bdec75484e64$var$listeners.size === 0) window.removeEventListener('languagechange', $2919bdec75484e64$var$updateLocale);
116
- };
117
- }, []);
118
- // We cannot determine the browser's language on the server, so default to
119
- // en-US. This will be updated after hydration on the client to the correct value.
120
- if (isSSR) return {
121
- locale: 'en-US',
122
- direction: 'ltr'
123
- };
124
- return defaultLocale;
125
- }
126
-
127
-
128
-
129
- const $47fa5ec5ff482271$var$I18nContext = /*#__PURE__*/ ($parcel$interopDefault($87SwK$react)).createContext(null);
130
- function $47fa5ec5ff482271$export$a54013f0d02a8f82(props) {
131
- let { locale: locale , children: children } = props;
132
- let defaultLocale = $2919bdec75484e64$export$188ec29ebc2bdc3a();
133
- let value = locale ? {
134
- locale: locale,
135
- direction: $4d65847630a056a8$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'
136
- } : defaultLocale;
137
- return(/*#__PURE__*/ ($parcel$interopDefault($87SwK$react)).createElement($47fa5ec5ff482271$var$I18nContext.Provider, {
138
- value: value
139
- }, children));
140
- }
141
- function $47fa5ec5ff482271$export$43bb16f9c6d9e3f7() {
142
- let defaultLocale = $2919bdec75484e64$export$188ec29ebc2bdc3a();
143
- let context = $87SwK$react.useContext($47fa5ec5ff482271$var$I18nContext);
144
- return context || defaultLocale;
145
- }
146
-
147
-
148
-
149
-
150
-
151
- const $c376aa482226bf60$var$cache = new WeakMap();
152
- function $c376aa482226bf60$var$getCachedDictionary(strings) {
153
- let dictionary = $c376aa482226bf60$var$cache.get(strings);
154
- if (!dictionary) {
155
- dictionary = new $87SwK$internationalizedmessage.MessageDictionary(strings);
156
- $c376aa482226bf60$var$cache.set(strings, dictionary);
157
- }
158
- return dictionary;
159
- }
160
- function $c376aa482226bf60$export$ec23bf898b1eed85(strings) {
161
- let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
162
- let dictionary = $87SwK$react.useMemo(()=>$c376aa482226bf60$var$getCachedDictionary(strings)
163
- , [
164
- strings
165
- ]);
166
- let formatter = $87SwK$react.useMemo(()=>new $87SwK$internationalizedmessage.MessageFormatter(locale, dictionary)
167
- , [
168
- locale,
169
- dictionary
170
- ]);
171
- return $87SwK$react.useCallback((key, variables)=>formatter.format(key, variables)
172
- , [
173
- formatter
174
- ]);
175
- }
176
-
177
-
178
-
179
-
180
-
181
- const $fc53663969a3d00a$var$cache = new WeakMap();
182
- function $fc53663969a3d00a$var$getCachedDictionary(strings) {
183
- let dictionary = $fc53663969a3d00a$var$cache.get(strings);
184
- if (!dictionary) {
185
- dictionary = new $87SwK$internationalizedstring.LocalizedStringDictionary(strings);
186
- $fc53663969a3d00a$var$cache.set(strings, dictionary);
187
- }
188
- return dictionary;
189
- }
190
- function $fc53663969a3d00a$export$f12b703ca79dfbb1(strings) {
191
- let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
192
- let dictionary = $87SwK$react.useMemo(()=>$fc53663969a3d00a$var$getCachedDictionary(strings)
193
- , [
194
- strings
195
- ]);
196
- return $87SwK$react.useMemo(()=>new $87SwK$internationalizedstring.LocalizedStringFormatter(locale, dictionary)
197
- , [
198
- locale,
199
- dictionary
200
- ]);
201
- }
202
-
203
-
204
-
205
-
206
-
207
- function $b80c530ff2e20243$export$85fd5fdf27bacc79(options) {
208
- // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
209
- let lastOptions = $87SwK$react.useRef(null);
210
- if (options && lastOptions.current && $b80c530ff2e20243$var$isEqual(options, lastOptions.current)) options = lastOptions.current;
211
- lastOptions.current = options;
212
- let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
213
- return $87SwK$react.useMemo(()=>new $87SwK$internationalizeddate.DateFormatter(locale, options)
214
- , [
215
- locale,
216
- options
217
- ]);
218
- }
219
- function $b80c530ff2e20243$var$isEqual(a, b) {
220
- if (a === b) return true;
221
- let aKeys = Object.keys(a);
222
- let bKeys = Object.keys(b);
223
- if (aKeys.length !== bKeys.length) return false;
224
- for (let key of aKeys){
225
- if (b[key] !== a[key]) return false;
226
- }
227
- return true;
228
- }
229
-
230
-
231
-
232
-
233
-
234
- function $fea93c5b7c90d9f4$export$b7a616150fdb9f44(options = {
235
- }) {
236
- let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
237
- return $87SwK$react.useMemo(()=>new $87SwK$internationalizednumber.NumberFormatter(locale, options)
238
- , [
239
- locale,
240
- options
241
- ]);
242
- }
243
-
244
-
245
-
246
- let $27a5ce66022270ad$var$cache = new Map();
247
- function $27a5ce66022270ad$export$a16aca283550c30d(options) {
248
- let { locale: locale } = $47fa5ec5ff482271$export$43bb16f9c6d9e3f7();
249
- let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
250
- ).join() : '');
251
- if ($27a5ce66022270ad$var$cache.has(cacheKey)) return $27a5ce66022270ad$var$cache.get(cacheKey);
252
- let formatter = new Intl.Collator(locale, options);
253
- $27a5ce66022270ad$var$cache.set(cacheKey, formatter);
254
- return formatter;
255
- }
256
-
257
-
258
-
259
- function $832d079b867c7223$export$3274cf84b703fff(options) {
260
- let collator = $27a5ce66022270ad$export$a16aca283550c30d({
261
- usage: 'search',
262
- ...options
263
- });
264
- // TODO(later): these methods don't currently support the ignorePunctuation option.
265
- return {
266
- startsWith (string, substring) {
267
- if (substring.length === 0) return true;
268
- // Normalize both strings so we can slice safely
269
- // TODO: take into account the ignorePunctuation option as well...
270
- string = string.normalize('NFC');
271
- substring = substring.normalize('NFC');
272
- return collator.compare(string.slice(0, substring.length), substring) === 0;
273
- },
274
- endsWith (string, substring) {
275
- if (substring.length === 0) return true;
276
- string = string.normalize('NFC');
277
- substring = substring.normalize('NFC');
278
- return collator.compare(string.slice(-substring.length), substring) === 0;
279
- },
280
- contains (string, substring) {
281
- if (substring.length === 0) return true;
282
- string = string.normalize('NFC');
283
- substring = substring.normalize('NFC');
284
- let scan = 0;
285
- let sliceLen = substring.length;
286
- for(; scan + sliceLen <= string.length; scan++){
287
- let slice = string.slice(scan, scan + sliceLen);
288
- if (collator.compare(substring, slice) === 0) return true;
289
- }
290
- return false;
291
- }
292
- };
293
- }
294
-
295
-
296
-
297
-
298
- //# sourceMappingURL=main.js.map
1
+ // useMessageFormatter is deprecated, but has a large dependency on intl-messageformat
2
+ // that we want to avoid. If it is built into the same file as the rest of the package,
3
+ // it deopts tree shaking in Parcel even when unused. Instead, it is split into a separate
4
+ // file and re-exported here, which allows tree shaking to work properly.
5
+ module.exports = require('./real-main.js');
6
+ Object.defineProperties(module.exports, Object.getOwnPropertyDescriptors(require('./useMessageFormatter.cjs.js')));
package/dist/module.js CHANGED
@@ -1,284 +1,6 @@
1
- import $iFADg$react, {useContext as $iFADg$useContext, useState as $iFADg$useState, useEffect as $iFADg$useEffect, useMemo as $iFADg$useMemo, useCallback as $iFADg$useCallback, useRef as $iFADg$useRef} from "react";
2
- import {useIsSSR as $iFADg$useIsSSR} from "@react-aria/ssr";
3
- import {MessageDictionary as $iFADg$MessageDictionary, MessageFormatter as $iFADg$MessageFormatter} from "@internationalized/message";
4
- import {LocalizedStringDictionary as $iFADg$LocalizedStringDictionary, LocalizedStringFormatter as $iFADg$LocalizedStringFormatter} from "@internationalized/string";
5
- import {DateFormatter as $iFADg$DateFormatter} from "@internationalized/date";
6
- import {NumberFormatter as $iFADg$NumberFormatter} from "@internationalized/number";
7
-
8
- /*
9
- * Copyright 2020 Adobe. All rights reserved.
10
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
11
- * you may not use this file except in compliance with the License. You may obtain a copy
12
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software distributed under
15
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
16
- * OF ANY KIND, either express or implied. See the License for the specific language
17
- * governing permissions and limitations under the License.
18
- */ // https://en.wikipedia.org/wiki/Right-to-left
19
- const $148a7a147e38ea7f$var$RTL_SCRIPTS = new Set([
20
- 'Arab',
21
- 'Syrc',
22
- 'Samr',
23
- 'Mand',
24
- 'Thaa',
25
- 'Mend',
26
- 'Nkoo',
27
- 'Adlm',
28
- 'Rohg',
29
- 'Hebr'
30
- ]);
31
- const $148a7a147e38ea7f$var$RTL_LANGS = new Set([
32
- 'ae',
33
- 'ar',
34
- 'arc',
35
- 'bcc',
36
- 'bqi',
37
- 'ckb',
38
- 'dv',
39
- 'fa',
40
- 'glk',
41
- 'he',
42
- 'ku',
43
- 'mzn',
44
- 'nqo',
45
- 'pnb',
46
- 'ps',
47
- 'sd',
48
- 'ug',
49
- 'ur',
50
- 'yi'
51
- ]);
52
- function $148a7a147e38ea7f$export$702d680b21cbd764(locale) {
53
- // If the Intl.Locale API is available, use it to get the script for the locale.
54
- // This is more accurate than guessing by language, since languages can be written in multiple scripts.
55
- // @ts-ignore
56
- if (Intl.Locale) {
57
- // @ts-ignore
58
- let script = new Intl.Locale(locale).maximize().script;
59
- return $148a7a147e38ea7f$var$RTL_SCRIPTS.has(script);
60
- }
61
- // If not, just guess by the language (first part of the locale)
62
- let lang = locale.split('-')[0];
63
- return $148a7a147e38ea7f$var$RTL_LANGS.has(lang);
64
- }
65
-
66
-
67
-
68
-
69
-
70
- function $1e5a04cdaf7d1af8$export$f09106e7c6677ec5() {
71
- // @ts-ignore
72
- let locale = typeof navigator !== 'undefined' && (navigator.language || navigator.userLanguage) || 'en-US';
73
- try {
74
- // @ts-ignore
75
- Intl.DateTimeFormat.supportedLocalesOf([
76
- locale
77
- ]);
78
- } catch (_err) {
79
- locale = 'en-US';
80
- }
81
- return {
82
- locale: locale,
83
- direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'
84
- };
85
- }
86
- let $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
87
- let $1e5a04cdaf7d1af8$var$listeners = new Set();
88
- function $1e5a04cdaf7d1af8$var$updateLocale() {
89
- $1e5a04cdaf7d1af8$var$currentLocale = $1e5a04cdaf7d1af8$export$f09106e7c6677ec5();
90
- for (let listener of $1e5a04cdaf7d1af8$var$listeners)listener($1e5a04cdaf7d1af8$var$currentLocale);
91
- }
92
- function $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a() {
93
- let isSSR = $iFADg$useIsSSR();
94
- let [defaultLocale, setDefaultLocale] = $iFADg$useState($1e5a04cdaf7d1af8$var$currentLocale);
95
- $iFADg$useEffect(()=>{
96
- if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.addEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
97
- $1e5a04cdaf7d1af8$var$listeners.add(setDefaultLocale);
98
- return ()=>{
99
- $1e5a04cdaf7d1af8$var$listeners.delete(setDefaultLocale);
100
- if ($1e5a04cdaf7d1af8$var$listeners.size === 0) window.removeEventListener('languagechange', $1e5a04cdaf7d1af8$var$updateLocale);
101
- };
102
- }, []);
103
- // We cannot determine the browser's language on the server, so default to
104
- // en-US. This will be updated after hydration on the client to the correct value.
105
- if (isSSR) return {
106
- locale: 'en-US',
107
- direction: 'ltr'
108
- };
109
- return defaultLocale;
110
- }
111
-
112
-
113
-
114
- const $18f2051aff69b9bf$var$I18nContext = /*#__PURE__*/ $iFADg$react.createContext(null);
115
- function $18f2051aff69b9bf$export$a54013f0d02a8f82(props) {
116
- let { locale: locale , children: children } = props;
117
- let defaultLocale = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
118
- let value = locale ? {
119
- locale: locale,
120
- direction: $148a7a147e38ea7f$export$702d680b21cbd764(locale) ? 'rtl' : 'ltr'
121
- } : defaultLocale;
122
- return(/*#__PURE__*/ $iFADg$react.createElement($18f2051aff69b9bf$var$I18nContext.Provider, {
123
- value: value
124
- }, children));
125
- }
126
- function $18f2051aff69b9bf$export$43bb16f9c6d9e3f7() {
127
- let defaultLocale = $1e5a04cdaf7d1af8$export$188ec29ebc2bdc3a();
128
- let context = $iFADg$useContext($18f2051aff69b9bf$var$I18nContext);
129
- return context || defaultLocale;
130
- }
131
-
132
-
133
-
134
-
135
-
136
- const $321bc95feeb923dd$var$cache = new WeakMap();
137
- function $321bc95feeb923dd$var$getCachedDictionary(strings) {
138
- let dictionary = $321bc95feeb923dd$var$cache.get(strings);
139
- if (!dictionary) {
140
- dictionary = new $iFADg$MessageDictionary(strings);
141
- $321bc95feeb923dd$var$cache.set(strings, dictionary);
142
- }
143
- return dictionary;
144
- }
145
- function $321bc95feeb923dd$export$ec23bf898b1eed85(strings) {
146
- let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
147
- let dictionary = $iFADg$useMemo(()=>$321bc95feeb923dd$var$getCachedDictionary(strings)
148
- , [
149
- strings
150
- ]);
151
- let formatter = $iFADg$useMemo(()=>new $iFADg$MessageFormatter(locale, dictionary)
152
- , [
153
- locale,
154
- dictionary
155
- ]);
156
- return $iFADg$useCallback((key, variables)=>formatter.format(key, variables)
157
- , [
158
- formatter
159
- ]);
160
- }
161
-
162
-
163
-
164
-
165
-
166
- const $fca6afa0e843324b$var$cache = new WeakMap();
167
- function $fca6afa0e843324b$var$getCachedDictionary(strings) {
168
- let dictionary = $fca6afa0e843324b$var$cache.get(strings);
169
- if (!dictionary) {
170
- dictionary = new $iFADg$LocalizedStringDictionary(strings);
171
- $fca6afa0e843324b$var$cache.set(strings, dictionary);
172
- }
173
- return dictionary;
174
- }
175
- function $fca6afa0e843324b$export$f12b703ca79dfbb1(strings) {
176
- let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
177
- let dictionary = $iFADg$useMemo(()=>$fca6afa0e843324b$var$getCachedDictionary(strings)
178
- , [
179
- strings
180
- ]);
181
- return $iFADg$useMemo(()=>new $iFADg$LocalizedStringFormatter(locale, dictionary)
182
- , [
183
- locale,
184
- dictionary
185
- ]);
186
- }
187
-
188
-
189
-
190
-
191
-
192
- function $896ba0a80a8f4d36$export$85fd5fdf27bacc79(options) {
193
- // Reuse last options object if it is shallowly equal, which allows the useMemo result to also be reused.
194
- let lastOptions = $iFADg$useRef(null);
195
- if (options && lastOptions.current && $896ba0a80a8f4d36$var$isEqual(options, lastOptions.current)) options = lastOptions.current;
196
- lastOptions.current = options;
197
- let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
198
- return $iFADg$useMemo(()=>new $iFADg$DateFormatter(locale, options)
199
- , [
200
- locale,
201
- options
202
- ]);
203
- }
204
- function $896ba0a80a8f4d36$var$isEqual(a, b) {
205
- if (a === b) return true;
206
- let aKeys = Object.keys(a);
207
- let bKeys = Object.keys(b);
208
- if (aKeys.length !== bKeys.length) return false;
209
- for (let key of aKeys){
210
- if (b[key] !== a[key]) return false;
211
- }
212
- return true;
213
- }
214
-
215
-
216
-
217
-
218
-
219
- function $a916eb452884faea$export$b7a616150fdb9f44(options = {
220
- }) {
221
- let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
222
- return $iFADg$useMemo(()=>new $iFADg$NumberFormatter(locale, options)
223
- , [
224
- locale,
225
- options
226
- ]);
227
- }
228
-
229
-
230
-
231
- let $325a3faab7a68acd$var$cache = new Map();
232
- function $325a3faab7a68acd$export$a16aca283550c30d(options) {
233
- let { locale: locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
234
- let cacheKey = locale + (options ? Object.entries(options).sort((a, b)=>a[0] < b[0] ? -1 : 1
235
- ).join() : '');
236
- if ($325a3faab7a68acd$var$cache.has(cacheKey)) return $325a3faab7a68acd$var$cache.get(cacheKey);
237
- let formatter = new Intl.Collator(locale, options);
238
- $325a3faab7a68acd$var$cache.set(cacheKey, formatter);
239
- return formatter;
240
- }
241
-
242
-
243
-
244
- function $bb77f239b46e8c72$export$3274cf84b703fff(options) {
245
- let collator = $325a3faab7a68acd$export$a16aca283550c30d({
246
- usage: 'search',
247
- ...options
248
- });
249
- // TODO(later): these methods don't currently support the ignorePunctuation option.
250
- return {
251
- startsWith (string, substring) {
252
- if (substring.length === 0) return true;
253
- // Normalize both strings so we can slice safely
254
- // TODO: take into account the ignorePunctuation option as well...
255
- string = string.normalize('NFC');
256
- substring = substring.normalize('NFC');
257
- return collator.compare(string.slice(0, substring.length), substring) === 0;
258
- },
259
- endsWith (string, substring) {
260
- if (substring.length === 0) return true;
261
- string = string.normalize('NFC');
262
- substring = substring.normalize('NFC');
263
- return collator.compare(string.slice(-substring.length), substring) === 0;
264
- },
265
- contains (string, substring) {
266
- if (substring.length === 0) return true;
267
- string = string.normalize('NFC');
268
- substring = substring.normalize('NFC');
269
- let scan = 0;
270
- let sliceLen = substring.length;
271
- for(; scan + sliceLen <= string.length; scan++){
272
- let slice = string.slice(scan, scan + sliceLen);
273
- if (collator.compare(substring, slice) === 0) return true;
274
- }
275
- return false;
276
- }
277
- };
278
- }
279
-
280
-
281
-
282
-
283
- export {$18f2051aff69b9bf$export$a54013f0d02a8f82 as I18nProvider, $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 as useLocale, $321bc95feeb923dd$export$ec23bf898b1eed85 as useMessageFormatter, $fca6afa0e843324b$export$f12b703ca79dfbb1 as useLocalizedStringFormatter, $896ba0a80a8f4d36$export$85fd5fdf27bacc79 as useDateFormatter, $a916eb452884faea$export$b7a616150fdb9f44 as useNumberFormatter, $325a3faab7a68acd$export$a16aca283550c30d as useCollator, $bb77f239b46e8c72$export$3274cf84b703fff as useFilter};
284
- //# sourceMappingURL=module.js.map
1
+ // useMessageFormatter is deprecated, but has a large dependency on intl-messageformat
2
+ // that we want to avoid. If it is built into the same file as the rest of the package,
3
+ // it deopts tree shaking in Parcel even when unused. Instead, it is split into a separate
4
+ // file and re-exported here, which allows tree shaking to work properly.
5
+ export * from './real-module.js';
6
+ export * from './useMessageFormatter.module.js';