@arcgis/components-utils 4.33.0-next.16 → 4.33.0-next.160
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/array-utils.d.cts +5 -0
- package/dist/array-utils.d.ts +5 -0
- package/dist/css-utils.d.cts +15 -0
- package/dist/css-utils.d.ts +15 -0
- package/dist/deferred.d.cts +35 -0
- package/dist/deferred.d.ts +35 -0
- package/dist/dom.d.cts +65 -0
- package/dist/dom.d.ts +65 -0
- package/dist/errors.d.cts +30 -0
- package/dist/errors.d.ts +30 -0
- package/dist/guid.d.cts +5 -0
- package/dist/guid.d.ts +5 -0
- package/dist/index.cjs +148 -294
- package/dist/index.d.cts +15 -378
- package/dist/index.d.ts +15 -378
- package/dist/index.js +109 -191
- package/dist/intl.d.cts +91 -0
- package/dist/intl.d.ts +91 -0
- package/dist/preamble.d.cts +17 -0
- package/dist/preamble.d.ts +17 -0
- package/dist/strings.d.cts +29 -0
- package/dist/strings.d.ts +29 -0
- package/dist/tests/utils.d.cts +1 -0
- package/dist/tests/utils.d.ts +1 -0
- package/dist/text.d.cts +7 -0
- package/dist/text.d.ts +7 -0
- package/dist/timeouts.d.cts +7 -0
- package/dist/timeouts.d.ts +7 -0
- package/dist/type-guards.d.cts +12 -0
- package/dist/type-guards.d.ts +12 -0
- package/dist/types.d.cts +30 -0
- package/dist/types.d.ts +30 -0
- package/dist/ui.d.cts +8 -0
- package/dist/ui.d.ts +8 -0
- package/dist/url.d.cts +14 -0
- package/dist/url.d.ts +14 -0
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,68 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/index.ts
|
|
21
|
-
var src_exports = {};
|
|
22
|
-
__export(src_exports, {
|
|
23
|
-
Deferred: () => Deferred,
|
|
24
|
-
addLTRMark: () => addLTRMark,
|
|
25
|
-
camelToHuman: () => camelToHuman,
|
|
26
|
-
camelToKebab: () => camelToKebab,
|
|
27
|
-
capitalize: () => capitalize,
|
|
28
|
-
classes: () => classes,
|
|
29
|
-
closestElement: () => closestElement,
|
|
30
|
-
createFilterExpression: () => createFilterExpression,
|
|
31
|
-
debounce: () => debounce,
|
|
32
|
-
defaultLocale: () => defaultLocale,
|
|
33
|
-
devToolsAwareTimeout: () => devToolsAwareTimeout,
|
|
34
|
-
extractMinorVersion: () => extractMinorVersion,
|
|
35
|
-
fetchT9nStringsBundle: () => fetchT9nStringsBundle,
|
|
36
|
-
focusElement: () => focusElement,
|
|
37
|
-
generateGuid: () => generateGuid,
|
|
38
|
-
getElementAttribute: () => getElementAttribute,
|
|
39
|
-
getElementDir: () => getElementDir,
|
|
40
|
-
getElementLocales: () => getElementLocales,
|
|
41
|
-
getElementTheme: () => getElementTheme,
|
|
42
|
-
getPreamble: () => getPreamble,
|
|
43
|
-
hasSameOrigin: () => hasSameOrigin,
|
|
44
|
-
identity: () => identity,
|
|
45
|
-
isEsriInternalEnv: () => isEsriInternalEnv,
|
|
46
|
-
isNotNull: () => isNotNull,
|
|
47
|
-
isNotUndefined: () => isNotUndefined,
|
|
48
|
-
isURL: () => isURL,
|
|
49
|
-
kebabToPascal: () => kebabToPascal,
|
|
50
|
-
mappedFind: () => mappedFind,
|
|
51
|
-
normalizeLocale: () => normalizeLocale,
|
|
52
|
-
observeAncestorsMutation: () => observeAncestorsMutation,
|
|
53
|
-
quoteString: () => quoteString,
|
|
54
|
-
safeAsyncCall: () => safeAsyncCall,
|
|
55
|
-
safeCall: () => safeCall,
|
|
56
|
-
setFocusOnElement: () => setFocusOnElement,
|
|
57
|
-
setValuesInString: () => setValuesInString,
|
|
58
|
-
startLocaleObserver: () => startLocaleObserver,
|
|
59
|
-
supportedLocales: () => supportedLocales,
|
|
60
|
-
uncapitalize: () => uncapitalize
|
|
61
|
-
});
|
|
62
|
-
module.exports = __toCommonJS(src_exports);
|
|
63
|
-
|
|
64
|
-
// src/array-utils.ts
|
|
65
|
-
function mappedFind(array, callback) {
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const mappedFind = (array, callback) => {
|
|
66
4
|
for (let i = 0; i < array.length; i++) {
|
|
67
5
|
const value = callback(array[i], i);
|
|
68
6
|
if (value != null) {
|
|
@@ -70,10 +8,8 @@ function mappedFind(array, callback) {
|
|
|
70
8
|
}
|
|
71
9
|
}
|
|
72
10
|
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/css-utils.ts
|
|
76
|
-
function classes(...classes2) {
|
|
11
|
+
};
|
|
12
|
+
const classes = (...classes2) => {
|
|
77
13
|
const effectiveClasses = [];
|
|
78
14
|
for (let i = 0; i < classes2.length; i++) {
|
|
79
15
|
const arg = classes2[i];
|
|
@@ -92,21 +28,8 @@ function classes(...classes2) {
|
|
|
92
28
|
const className = effectiveClasses.join(" ");
|
|
93
29
|
effectiveClasses.length = 0;
|
|
94
30
|
return className;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// src/deferred.ts
|
|
98
|
-
var Deferred = class {
|
|
99
|
-
/**
|
|
100
|
-
* Resolves the promise.
|
|
101
|
-
* @param value The value to resolve the promise with.
|
|
102
|
-
*/
|
|
103
|
-
resolve(_value) {
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Rejects the promise.
|
|
107
|
-
*/
|
|
108
|
-
reject(_error) {
|
|
109
|
-
}
|
|
31
|
+
};
|
|
32
|
+
class Deferred {
|
|
110
33
|
/**
|
|
111
34
|
* Creates a new deferred promise.
|
|
112
35
|
*/
|
|
@@ -116,10 +39,8 @@ var Deferred = class {
|
|
|
116
39
|
this.reject = reject;
|
|
117
40
|
});
|
|
118
41
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// src/dom.ts
|
|
122
|
-
function inTargetElement(element, targetElement) {
|
|
42
|
+
}
|
|
43
|
+
const inTargetElement = (element, targetElement) => {
|
|
123
44
|
let currentElement = element;
|
|
124
45
|
while (currentElement) {
|
|
125
46
|
if (currentElement === targetElement) {
|
|
@@ -135,18 +56,18 @@ function inTargetElement(element, targetElement) {
|
|
|
135
56
|
}
|
|
136
57
|
}
|
|
137
58
|
return false;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const
|
|
59
|
+
};
|
|
60
|
+
const observeAncestorsMutation = (element, attributeFilter, callback) => {
|
|
61
|
+
const subscribe = observe(attributeFilter).subscribe;
|
|
141
62
|
return subscribe((mutations) => {
|
|
142
63
|
const matched = mutations.some((mutation) => inTargetElement(element, mutation.target));
|
|
143
64
|
if (matched) {
|
|
144
65
|
callback();
|
|
145
66
|
}
|
|
146
67
|
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
68
|
+
};
|
|
69
|
+
const observers = {};
|
|
70
|
+
const observe = (attributeFilter) => {
|
|
150
71
|
const attributes = attributeFilter.join(",");
|
|
151
72
|
const previousObserver = observers[attributes];
|
|
152
73
|
if (previousObserver !== void 0) {
|
|
@@ -162,7 +83,7 @@ function observe(attributeFilter) {
|
|
|
162
83
|
});
|
|
163
84
|
}
|
|
164
85
|
const observer = {
|
|
165
|
-
subscribe(callback) {
|
|
86
|
+
subscribe: (callback) => {
|
|
166
87
|
subscribers.add(callback);
|
|
167
88
|
return () => {
|
|
168
89
|
subscribers.delete(callback);
|
|
@@ -175,8 +96,8 @@ function observe(attributeFilter) {
|
|
|
175
96
|
};
|
|
176
97
|
observers[attributes] = observer;
|
|
177
98
|
return observer;
|
|
178
|
-
}
|
|
179
|
-
|
|
99
|
+
};
|
|
100
|
+
const closestElement = (base, selector) => {
|
|
180
101
|
let currentElement = base;
|
|
181
102
|
while (currentElement) {
|
|
182
103
|
const element = currentElement.closest?.(selector);
|
|
@@ -190,25 +111,19 @@ function closestElement(base, selector) {
|
|
|
190
111
|
currentElement = rootElement.host;
|
|
191
112
|
}
|
|
192
113
|
return null;
|
|
193
|
-
}
|
|
194
|
-
|
|
114
|
+
};
|
|
115
|
+
const getElementTheme = (base) => {
|
|
195
116
|
const themeElement = closestElement(base, ":is(.calcite-mode-light, .calcite-mode-dark)");
|
|
196
117
|
return themeElement?.classList.contains("calcite-mode-dark") ? "dark" : "light";
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
}
|
|
201
|
-
function getElementAttribute(el, prop, fallbackValue) {
|
|
118
|
+
};
|
|
119
|
+
const getElementDir = (el) => getElementAttribute(el, "dir", "ltr");
|
|
120
|
+
const getElementAttribute = (el, prop, fallbackValue) => {
|
|
202
121
|
const closest = closestElement(el, `[${prop}]`);
|
|
203
122
|
return closest?.getAttribute(prop) ?? fallbackValue;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
function hasSetFocus(ref) {
|
|
209
|
-
return typeof ref.setFocus === "function";
|
|
210
|
-
}
|
|
211
|
-
function setFocus(ref, selector = "") {
|
|
123
|
+
};
|
|
124
|
+
const isElement = (ref) => ref.nodeType === Node.ELEMENT_NODE;
|
|
125
|
+
const hasSetFocus = (ref) => typeof ref.setFocus === "function";
|
|
126
|
+
const setFocus = (ref, selector = "") => {
|
|
212
127
|
if (!isElement(ref)) {
|
|
213
128
|
return false;
|
|
214
129
|
}
|
|
@@ -232,8 +147,8 @@ function setFocus(ref, selector = "") {
|
|
|
232
147
|
}
|
|
233
148
|
}
|
|
234
149
|
return false;
|
|
235
|
-
}
|
|
236
|
-
async
|
|
150
|
+
};
|
|
151
|
+
const focusElement = async (el) => {
|
|
237
152
|
if (el == null) {
|
|
238
153
|
return;
|
|
239
154
|
}
|
|
@@ -242,8 +157,8 @@ async function focusElement(el) {
|
|
|
242
157
|
} else {
|
|
243
158
|
el.focus();
|
|
244
159
|
}
|
|
245
|
-
}
|
|
246
|
-
|
|
160
|
+
};
|
|
161
|
+
const setFocusOnElement = (ref, selector) => {
|
|
247
162
|
if (!ref?.shadowRoot) {
|
|
248
163
|
return;
|
|
249
164
|
}
|
|
@@ -252,104 +167,69 @@ function setFocusOnElement(ref, selector) {
|
|
|
252
167
|
return;
|
|
253
168
|
}
|
|
254
169
|
void Promise.resolve(ref.componentOnReady?.()).then(() => setFocus(ref, selector));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
170
|
+
};
|
|
171
|
+
const isEsriInternalEnv = () => (
|
|
172
|
+
/*
|
|
173
|
+
* `globalThis.` is important here. Some bundlers remove the `typeof process`
|
|
174
|
+
* checks, but don't remove the usages of undefined variables - this can cause
|
|
175
|
+
* runtime error. By adding `globalThis.`, we avoid having `typeof process`
|
|
176
|
+
* check removed by the bundler.
|
|
177
|
+
* This does meant tree-shaking won't happen for the isEsriInternalEnv()
|
|
178
|
+
* check, but this is ok since this check is meant to always be behind the
|
|
179
|
+
* development/test guard.
|
|
180
|
+
* See https://devtopia.esri.com/WebGIS/arcgis-web-components/pull/2087#issuecomment-5152454
|
|
181
|
+
*/
|
|
182
|
+
typeof globalThis.process === "object" && !!process.env.ESRI_INTERNAL
|
|
183
|
+
);
|
|
184
|
+
const safeCall = (callback, thisContext, ...rest) => {
|
|
262
185
|
try {
|
|
263
186
|
return callback?.call(thisContext, ...rest);
|
|
264
187
|
} catch (error) {
|
|
265
188
|
console.error(error, callback);
|
|
266
189
|
}
|
|
267
190
|
return void 0;
|
|
268
|
-
}
|
|
269
|
-
async
|
|
191
|
+
};
|
|
192
|
+
const safeAsyncCall = async (callback, thisContext, ...rest) => {
|
|
270
193
|
try {
|
|
271
194
|
const result = callback?.call(thisContext, ...rest);
|
|
272
|
-
return
|
|
195
|
+
return await result;
|
|
273
196
|
} catch (error) {
|
|
274
197
|
console.error(error, callback);
|
|
275
198
|
}
|
|
276
199
|
return void 0;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// src/guid.ts
|
|
280
|
-
function gen(count) {
|
|
200
|
+
};
|
|
201
|
+
const gen = (count) => {
|
|
281
202
|
let out = "";
|
|
282
203
|
for (let i = 0; i < count; i++) {
|
|
283
204
|
out += ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
284
205
|
}
|
|
285
206
|
return out;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
"bg",
|
|
295
|
-
"bs",
|
|
296
|
-
"ca",
|
|
297
|
-
"cs",
|
|
298
|
-
"da",
|
|
299
|
-
"de",
|
|
300
|
-
"el",
|
|
301
|
-
"en",
|
|
302
|
-
"es",
|
|
303
|
-
"et",
|
|
304
|
-
"fi",
|
|
305
|
-
"fr",
|
|
306
|
-
"he",
|
|
307
|
-
"hr",
|
|
308
|
-
"hu",
|
|
309
|
-
"id",
|
|
310
|
-
"it",
|
|
311
|
-
"ja",
|
|
312
|
-
"ko",
|
|
313
|
-
"lt",
|
|
314
|
-
"lv",
|
|
315
|
-
"nl",
|
|
316
|
-
"nb",
|
|
317
|
-
"no",
|
|
318
|
-
"pl",
|
|
319
|
-
"pt-BR",
|
|
320
|
-
"pt-PT",
|
|
321
|
-
"ro",
|
|
322
|
-
"ru",
|
|
323
|
-
"sk",
|
|
324
|
-
"sl",
|
|
325
|
-
"sr",
|
|
326
|
-
"sv",
|
|
327
|
-
"th",
|
|
328
|
-
"tr",
|
|
329
|
-
"uk",
|
|
330
|
-
"vi",
|
|
331
|
-
"zh-CN",
|
|
332
|
-
"zh-HK",
|
|
333
|
-
"zh-TW"
|
|
334
|
-
];
|
|
335
|
-
var supportedLocales = /* @__PURE__ */ new Set(supportedLocalesArray);
|
|
336
|
-
var defaultLocale = "en";
|
|
337
|
-
var localeEquivalencies = {
|
|
207
|
+
};
|
|
208
|
+
const generateGuid = () => [gen(2), gen(1), gen(1), gen(1), gen(3)].join("-");
|
|
209
|
+
const supportedLocalesArray = "ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(
|
|
210
|
+
","
|
|
211
|
+
);
|
|
212
|
+
const supportedLocales = /* @__PURE__ */ new Set(supportedLocalesArray);
|
|
213
|
+
const defaultLocale = "en";
|
|
214
|
+
const localeEquivalencies = {
|
|
338
215
|
// We use `pt-PT` as it will have the same translations as `pt`, which has no corresponding bundle
|
|
339
216
|
pt: "pt-PT",
|
|
340
217
|
// We support both 'nb' and 'no' (BCP 47) for Norwegian but only `no` has corresponding bundle
|
|
341
218
|
nb: "no",
|
|
219
|
+
// We support both 'nn' and 'no' (BCP 47) for Norwegian but only `no` has corresponding bundle
|
|
220
|
+
// See https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/4667
|
|
221
|
+
nn: "no",
|
|
342
222
|
// We use `zh-CN` as base translation for chinese locales which has no corresponding bundle.
|
|
343
223
|
zh: "zh-CN"
|
|
344
224
|
};
|
|
345
|
-
async
|
|
225
|
+
const fetchT9nStringsBundle = async (locale, assetsPath, prefix = "") => {
|
|
346
226
|
const path = `${assetsPath}/${prefix}`;
|
|
347
227
|
const filePath = `${path}${locale}.json`;
|
|
348
228
|
t9nStringsCache[filePath] ?? (t9nStringsCache[filePath] = fetchBundle(locale, path));
|
|
349
229
|
return await t9nStringsCache[filePath];
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
async
|
|
230
|
+
};
|
|
231
|
+
const t9nStringsCache = {};
|
|
232
|
+
const fetchBundle = async (locale, path) => {
|
|
353
233
|
const filePath = `${path}${locale}.json`;
|
|
354
234
|
try {
|
|
355
235
|
const response = await fetch(filePath);
|
|
@@ -373,12 +253,12 @@ async function fetchBundle(locale, path) {
|
|
|
373
253
|
return {};
|
|
374
254
|
}
|
|
375
255
|
return await fetchBundle(defaultLocale, path);
|
|
376
|
-
}
|
|
377
|
-
|
|
256
|
+
};
|
|
257
|
+
const getElementLocales = (element) => {
|
|
378
258
|
const lang = getElementAttribute(element, "lang", globalThis.navigator?.language || defaultLocale);
|
|
379
259
|
return { lang, t9nLocale: normalizeLocale(lang) };
|
|
380
|
-
}
|
|
381
|
-
|
|
260
|
+
};
|
|
261
|
+
const normalizeLocale = (locale) => {
|
|
382
262
|
const [rawLanguageCode, regionCode] = locale.split("-");
|
|
383
263
|
const languageCode = rawLanguageCode.toLowerCase();
|
|
384
264
|
let normalizedLocale = languageCode;
|
|
@@ -393,10 +273,10 @@ function normalizeLocale(locale) {
|
|
|
393
273
|
return normalizeLocale(languageCode);
|
|
394
274
|
}
|
|
395
275
|
return defaultLocale;
|
|
396
|
-
}
|
|
397
|
-
|
|
276
|
+
};
|
|
277
|
+
const startLocaleObserver = (element, getAssetsPath, onUpdated, assetName) => {
|
|
398
278
|
let result = void 0;
|
|
399
|
-
const callback = () =>
|
|
279
|
+
const callback = () => updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
400
280
|
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
401
281
|
onUpdated(newResult);
|
|
402
282
|
}
|
|
@@ -404,8 +284,8 @@ function startLocaleObserver(element, getAssetsPath, onUpdated, assetName) {
|
|
|
404
284
|
}).catch(console.error);
|
|
405
285
|
queueMicrotask(callback);
|
|
406
286
|
return observeAncestorsMutation(element, ["lang"], callback);
|
|
407
|
-
}
|
|
408
|
-
async
|
|
287
|
+
};
|
|
288
|
+
const updateComponentLocaleState = async (element, assetsPath, assetName = element.localName.split("-").slice(1).join("-")) => {
|
|
409
289
|
const { lang, t9nLocale } = getElementLocales(element);
|
|
410
290
|
const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
|
|
411
291
|
const prefix = `messages.`;
|
|
@@ -414,23 +294,17 @@ async function updateComponentLocaleState(element, assetsPath, assetName = eleme
|
|
|
414
294
|
assetName === null ? {} : await fetchT9nStringsBundle(t9nLocale, t9nAssetsPath, prefix)
|
|
415
295
|
);
|
|
416
296
|
return { lang, t9nLocale, t9nStrings };
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
var blurb = "All material copyright Esri, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/{minorVersion}/esri/copyright.txt for details.\nv{version}";
|
|
421
|
-
var extractMinorVersion = (version) => {
|
|
297
|
+
};
|
|
298
|
+
const blurb = "All material copyright Esri, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/{minorVersion}/esri/copyright.txt for details.\nv{version}";
|
|
299
|
+
const extractMinorVersion = (version) => {
|
|
422
300
|
const [major, minor] = version.split(".");
|
|
423
301
|
return `${major}.${minor}`;
|
|
424
302
|
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
function repeatString(value, n) {
|
|
431
|
-
return new Array(n + 1).join(value);
|
|
432
|
-
}
|
|
433
|
-
function quoteString(value) {
|
|
303
|
+
const getPreamble = (version) => blurb.replace("{minorVersion}", extractMinorVersion(version)).replace("{version}", version);
|
|
304
|
+
const doubleQuote = '"';
|
|
305
|
+
const singleQuote = "'";
|
|
306
|
+
const repeatString = (value, n) => new Array(n + 1).join(value);
|
|
307
|
+
const quoteString = (value) => {
|
|
434
308
|
let quote = doubleQuote;
|
|
435
309
|
let alternateQuote = singleQuote;
|
|
436
310
|
const avoidEscape = value.includes(quote) && !value.includes(alternateQuote);
|
|
@@ -452,28 +326,23 @@ function quoteString(value) {
|
|
|
452
326
|
(_, boundaryChar, leadingEscapedSlashes, quoteChars) => boundaryChar + leadingEscapedSlashes + repeatString(`\\${quote}`, quoteChars.length)
|
|
453
327
|
);
|
|
454
328
|
return quote + value + quote;
|
|
455
|
-
}
|
|
456
|
-
|
|
329
|
+
};
|
|
330
|
+
const createFilterExpression = (filterWord) => {
|
|
457
331
|
const sanitizedWord = filterWord ? filterWord.replaceAll(/[-[\]/{}()*+?.\\^$|]/gu, "\\$&") : "^.*$";
|
|
458
332
|
return new RegExp(sanitizedWord, "i");
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
var uncapitalize = (string) => string.charAt(0).toLowerCase() + string.slice(1);
|
|
473
|
-
var camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
|
|
474
|
-
|
|
475
|
-
// src/timeouts.ts
|
|
476
|
-
function devToolsAwareTimeout(callback, timeout) {
|
|
333
|
+
};
|
|
334
|
+
const setValuesInString = (message, values = {}) => (message ?? "").replace(/\{(?<valueName>.*?)\}/gu, (match, valueName) => values[valueName] ?? match);
|
|
335
|
+
const addLTRMark = (value) => (
|
|
336
|
+
// Make sure the string value is LTR. This prevent issues with RTL language used in LTR containers.
|
|
337
|
+
`${value ?? ""}`
|
|
338
|
+
);
|
|
339
|
+
const kebabToPascal = (string) => string.split("-").map(capitalize).join("");
|
|
340
|
+
const camelToKebab = (string) => string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`);
|
|
341
|
+
const upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
|
|
342
|
+
const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
|
|
343
|
+
const uncapitalize = (string) => string.charAt(0).toLowerCase() + string.slice(1);
|
|
344
|
+
const camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
|
|
345
|
+
const devToolsAwareTimeout = (callback, timeout) => {
|
|
477
346
|
const interval = timeout > longTimeoutThreshold ? longTimeoutInterval : timeout / shortTimeoutIntervals;
|
|
478
347
|
let elapsed = 0;
|
|
479
348
|
const reference = setInterval(() => {
|
|
@@ -484,24 +353,14 @@ function devToolsAwareTimeout(callback, timeout) {
|
|
|
484
353
|
}
|
|
485
354
|
}, interval);
|
|
486
355
|
return reference;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
function isNotUndefined(item) {
|
|
497
|
-
return item !== void 0;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
// src/types.ts
|
|
501
|
-
var identity = (value) => value;
|
|
502
|
-
|
|
503
|
-
// src/ui.ts
|
|
504
|
-
function debounce(func, waitFor = 100) {
|
|
356
|
+
};
|
|
357
|
+
const longTimeoutThreshold = 4e3;
|
|
358
|
+
const longTimeoutInterval = 2e3;
|
|
359
|
+
const shortTimeoutIntervals = 4;
|
|
360
|
+
const isNotNull = (item) => item !== null;
|
|
361
|
+
const isNotUndefined = (item) => item !== void 0;
|
|
362
|
+
const identity = (value) => value;
|
|
363
|
+
const debounce = (func, waitFor = 100) => {
|
|
505
364
|
let timeout;
|
|
506
365
|
return (...args) => {
|
|
507
366
|
const later = () => {
|
|
@@ -511,10 +370,8 @@ function debounce(func, waitFor = 100) {
|
|
|
511
370
|
clearTimeout(timeout);
|
|
512
371
|
timeout = setTimeout(later, waitFor);
|
|
513
372
|
};
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
// src/url.ts
|
|
517
|
-
function hasSameOrigin(url1, url2, ignoreProtocol = false) {
|
|
373
|
+
};
|
|
374
|
+
const hasSameOrigin = (url1, url2, ignoreProtocol = false) => {
|
|
518
375
|
if (!url1 || !url2) {
|
|
519
376
|
return false;
|
|
520
377
|
}
|
|
@@ -527,53 +384,50 @@ function hasSameOrigin(url1, url2, ignoreProtocol = false) {
|
|
|
527
384
|
return false;
|
|
528
385
|
}
|
|
529
386
|
return url1Obj.host.toLowerCase() === url2Obj.host.toLowerCase() && url1Obj.port === url2Obj.port;
|
|
530
|
-
}
|
|
531
|
-
|
|
387
|
+
};
|
|
388
|
+
const isURL = (url) => {
|
|
532
389
|
try {
|
|
533
390
|
new URL(url);
|
|
534
391
|
return true;
|
|
535
392
|
} catch (e) {
|
|
536
393
|
return false;
|
|
537
394
|
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
supportedLocales,
|
|
578
|
-
uncapitalize
|
|
579
|
-
});
|
|
395
|
+
};
|
|
396
|
+
exports.Deferred = Deferred;
|
|
397
|
+
exports.addLTRMark = addLTRMark;
|
|
398
|
+
exports.camelToHuman = camelToHuman;
|
|
399
|
+
exports.camelToKebab = camelToKebab;
|
|
400
|
+
exports.capitalize = capitalize;
|
|
401
|
+
exports.classes = classes;
|
|
402
|
+
exports.closestElement = closestElement;
|
|
403
|
+
exports.createFilterExpression = createFilterExpression;
|
|
404
|
+
exports.debounce = debounce;
|
|
405
|
+
exports.defaultLocale = defaultLocale;
|
|
406
|
+
exports.devToolsAwareTimeout = devToolsAwareTimeout;
|
|
407
|
+
exports.extractMinorVersion = extractMinorVersion;
|
|
408
|
+
exports.fetchT9nStringsBundle = fetchT9nStringsBundle;
|
|
409
|
+
exports.focusElement = focusElement;
|
|
410
|
+
exports.generateGuid = generateGuid;
|
|
411
|
+
exports.getElementAttribute = getElementAttribute;
|
|
412
|
+
exports.getElementDir = getElementDir;
|
|
413
|
+
exports.getElementLocales = getElementLocales;
|
|
414
|
+
exports.getElementTheme = getElementTheme;
|
|
415
|
+
exports.getPreamble = getPreamble;
|
|
416
|
+
exports.hasSameOrigin = hasSameOrigin;
|
|
417
|
+
exports.identity = identity;
|
|
418
|
+
exports.isEsriInternalEnv = isEsriInternalEnv;
|
|
419
|
+
exports.isNotNull = isNotNull;
|
|
420
|
+
exports.isNotUndefined = isNotUndefined;
|
|
421
|
+
exports.isURL = isURL;
|
|
422
|
+
exports.kebabToPascal = kebabToPascal;
|
|
423
|
+
exports.mappedFind = mappedFind;
|
|
424
|
+
exports.normalizeLocale = normalizeLocale;
|
|
425
|
+
exports.observeAncestorsMutation = observeAncestorsMutation;
|
|
426
|
+
exports.quoteString = quoteString;
|
|
427
|
+
exports.safeAsyncCall = safeAsyncCall;
|
|
428
|
+
exports.safeCall = safeCall;
|
|
429
|
+
exports.setFocusOnElement = setFocusOnElement;
|
|
430
|
+
exports.setValuesInString = setValuesInString;
|
|
431
|
+
exports.startLocaleObserver = startLocaleObserver;
|
|
432
|
+
exports.supportedLocales = supportedLocales;
|
|
433
|
+
exports.uncapitalize = uncapitalize;
|