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