@arcgis/components-utils 4.33.0-next.8 → 4.33.0-next.80

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/index.d.ts CHANGED
@@ -1,378 +1,15 @@
1
- type Nil = null | undefined;
2
- type IHandle = {
3
- remove: () => void;
4
- };
5
- /**
6
- * Identity function - returns back the first parameter
7
- *
8
- * Useful when providing a "mapping function" is required, but you have no need
9
- * to change the value
10
- */
11
- declare const identity: <T>(value: T) => T;
12
- /**
13
- * Get back a type whose keys are all marked as mutable (no longer "readonly")
14
- *
15
- * It's a best practice to mark all keys as readonly by default in all the
16
- * interfaces and types you create. Benefits:
17
- * - Explicitly documents that a given key won't be modified/should not be
18
- * modified
19
- * - Favors more declarative and functional style programming
20
- * - Helps prevent bugs related to mutation unexpectedly affecting other places
21
- * that held a reference to the same object
22
- *
23
- * Your function could return a type like "ResolvedConfig", that has all keys
24
- * marked as readonly. But inside the function you may wish to modify some of
25
- * the keys while creating the object - casting the object to
26
- * `Writable<ResolvedConfig>` helps with that
27
- */
28
- type Writable<T> = {
29
- -readonly [k in keyof T]: T[k];
30
- };
31
-
32
- /**
33
- * Find a value in an array, and return it's mapped variant.
34
- */
35
- declare function mappedFind<Item, ReturnType>(array: readonly Item[], callback: (item: Item, index: number) => Nil | ReturnType): ReturnType | undefined;
36
-
37
- /**
38
- * This code contains imperative syntax (like for loops and mutation) as it is
39
- * in the hot path - performance optimizations are critical here.
40
- * See https://devtopia.esri.com/WebGIS/arcgis-js-api/commit/2565cedd87b
41
- *
42
- * Stencil has native support for passing-in class prop as an object or string,
43
- * but it does not support arrays or booleans, thus this utility is used
44
- * instead.
45
- *
46
- * @remarks
47
- * This function is not necessary in a Lit package as Lit's `classMap` directive
48
- * accepts an object
49
- */
50
- declare function classes(...classes: (Nil | Record<string, boolean> | string[] | string | false)[]): string;
51
-
52
- /**
53
- * A deferred promise.
54
- * Useful for when you want to return a promise but don't have the value yet.
55
- * Example:
56
- * ```
57
- * const deferred = new Deferred<string>();
58
- * setTimeout(() => deferred.resolve("Hello World"), 1000);
59
- * return deferred.promise;
60
- * ```
61
- * @template T The type of the promise.
62
- */
63
- declare class Deferred<T> {
64
- /**
65
- * The promise that can be awaited.
66
- */
67
- promise: Promise<T>;
68
- /**
69
- * Resolves the promise.
70
- * @param value The value to resolve the promise with.
71
- */
72
- resolve(_value: PromiseLike<T> | T): void;
73
- /**
74
- * Rejects the promise.
75
- */
76
- reject(_error: unknown): void;
77
- /**
78
- * Creates a new deferred promise.
79
- */
80
- constructor();
81
- }
82
-
83
- /**
84
- * Observe the element and its ancestors for attribute mutations.
85
- * If the attributes have been changed in the ancestor tree then the callback will be invoked.
86
- * Example: `observeAncestorsMutation(element, ["dir", "lang"], () => console.log("dir or lang changed"));`
87
- * @param element The element on which to observe the attribute mutations.
88
- * @param attributeFilter The list of attributes to observe.
89
- * @param callback The callback to invoke when the attributes have been changed.
90
- * @returns The mutation observer
91
- */
92
- declare function observeAncestorsMutation(element: Node, attributeFilter: string[], callback: () => void): () => void;
93
- /**
94
- * Find the closest element that matches the selector.
95
- * It will traverse the element's ancestors to find the target element.
96
- * Shadow DOM boundaries are also taken into account.
97
- * @param base The element to start the search from.
98
- * @param selector The selector to match.
99
- * @returns The closest element that matches the selector or null if not found.
100
- */
101
- declare function closestElement(base: Element, selector: string): Element | null;
102
- /**
103
- * Use the Calcite mode to determine the theme of the element.
104
- * It will traverse the element's ancestors to find the theme.
105
- * Shadow DOM boundaries are also taken into account.
106
- * @param base The element to start the search from.
107
- * @returns The theme of the element, either "light" or "dark", "light" is the default.
108
- */
109
- declare function getElementTheme(base: Element): "dark" | "light";
110
- /**
111
- * Get direction property of closest element.
112
- * @param el The element to start the search from.
113
- * @returns The direction of the element, either "ltr" | "rtl", "ltr" is the default.
114
- */
115
- declare function getElementDir(el: HTMLElement): "ltr" | "rtl";
116
- /**
117
- * Get the attribute value from the element.
118
- * It will traverse the element's ancestors to find the attribute.
119
- * Shadow DOM boundaries are also taken into account.
120
- * If the attribute is not found then the fallback value is returned.
121
- * Example: `getElementAttribute(element, "dir", "ltr");`
122
- * @param base The element to start the search from.
123
- * @param prop The attribute name.
124
- * @param fallbackValue The fallback value if the attribute is not found.
125
- * @returns The attribute value or the fallback value if the attribute is not found.
126
- */
127
- declare function getElementAttribute(el: Element, prop: string, fallbackValue: string): string;
128
- interface FocusableElement extends HTMLElement {
129
- setFocus?: () => Promise<void>;
130
- }
131
- declare function focusElement(el: FocusableElement | undefined): Promise<void>;
132
- /**
133
- * Set the focus on the element that matches the selector.
134
- * It will traverse the element's ancestors to find the target element.
135
- * Shadow DOM boundaries are also taken into account.
136
- * If the element is not found then the focus is not set.
137
- * Example: `setFocusOnElement(element, "[role='menuitem']");`
138
- * @param ref The element to start the search from.
139
- * @param selector The selector to match.
140
- * @returns Returns true if the focus is set on the element.
141
- *
142
- * REFACTOR: this is doing too much. break it into separate find element and focus
143
- * element utilities
144
- */
145
- declare function setFocusOnElement(ref: (Element & {
146
- componentOnReady?: () => Promise<void>;
147
- }) | null | undefined, selector: string): void;
148
-
149
- /**
150
- * Check whether the code is executing in an Esri internal environment (for
151
- * example, Lumina dev server). When true, your code can enable extra validation
152
- * to detect incorrect usages or do runtime bug detection.
153
- *
154
- * The call to isEsriInternalEnv() MUST always appear behind one of the
155
- * following guards to ensure it is correctly eliminated in production bundles:
156
- *
157
- * - `process.env.NODE_ENV !== "production"`
158
- * - `process.env.NODE_ENV === "development"`
159
- * - `process.env.NODE_ENV === "test"`
160
- *
161
- * @remarks
162
- * This function is primary for usage in support packages. In Lumina component
163
- * packages, simpler alternatives are provided:
164
- * https://qawebgis.esri.com/components/lumina/publishing#bundling-code-conditionally
165
- */
166
- declare function isEsriInternalEnv(): boolean;
167
- /**
168
- * Calls a sync method and catch any errors. Returns undefined if error occurred.
169
- *
170
- * Can also provide a thisContext and rest arguments
171
- */
172
- declare function safeCall<Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>): ReturnType<Callback> | void;
173
- /**
174
- * Calls an async method and catch any errors. Returns undefined if error occurred.
175
- *
176
- * Can also provide a thisContext and rest arguments
177
- */
178
- declare function safeAsyncCall<Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>): Promise<Awaited<ReturnType<Callback>> | void>;
179
-
180
- /**
181
- * Generates a GUID string.
182
- * @returns A GUID string with the pattern 00000000-0000-0000-0000-000000000000.
183
- */
184
- declare function generateGuid(): string;
185
-
186
- /**
187
- * The interface for translated strings.
188
- */
189
- interface GenericT9nStrings {
190
- [key: string]: GenericT9nStrings | string;
191
- }
192
- declare const supportedLocalesArray: readonly ["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"];
193
- /**
194
- * The list of supported locales for ArcGIS Maps SDK for JavaScript components.
195
- */
196
- declare const supportedLocales: Set<"hr" | "th" | "tr" | "ar" | "bg" | "bs" | "ca" | "cs" | "da" | "de" | "el" | "en" | "es" | "et" | "fi" | "fr" | "he" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "lv" | "nl" | "nb" | "no" | "pl" | "pt-BR" | "pt-PT" | "ro" | "ru" | "sk" | "sl" | "sr" | "sv" | "uk" | "vi" | "zh-CN" | "zh-HK" | "zh-TW">;
197
- type SupportedLocale = (typeof supportedLocalesArray)[number];
198
- declare const defaultLocale = "en";
199
- /**
200
- * Fetch the T9N strings bundle for the given locale, assets path and prefix.
201
- * The locale must be one of the supported locales.
202
- * If the locale is not supported, it will default to 'en'.
203
- * If the T9N strings bundle cannot be found, it will default to 'en'.
204
- *
205
- * @remarks
206
- * Rather than using this function directly, prefer the `useT9n()` controller.
207
- *
208
- * @example
209
- * ```ts
210
- * const t9nStrings = await fetchT9nStringsBundle("en", getAssetPath("./assets/coding-editor/t9n"), "messages.");
211
- * ```
212
- */
213
- declare function fetchT9nStringsBundle<Strings extends GenericT9nStrings>(
214
- /** The locale for which to fetch the T9N strings */
215
- locale: string,
216
- /** The path to the assets folder where the T9N strings are located */
217
- assetsPath: string,
218
- /** The prefix to use for the T9N strings file name. */
219
- prefix?: string): Promise<Strings>;
220
- /**
221
- * Get the locale of the given element.
222
- * It will look for the lang attribute on the element and its ancestors.
223
- * If not lang is found, it will default to 'en'.
224
- */
225
- declare function getElementLocales(element: HTMLElement): {
226
- readonly lang: string;
227
- readonly t9nLocale: SupportedLocale;
228
- };
229
- declare function normalizeLocale(locale: string): SupportedLocale;
230
- type LocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings> = {
231
- /** The T9N strings of the component */
232
- t9nStrings: Strings;
233
- /**
234
- * The locale of the component set by the `lang` attribute on the component host element or one of its ancestors.
235
- */
236
- lang: string;
237
- /**
238
- * The locale used by the component to load the T9N strings.
239
- * It may be different than the locale of the component host element that was set by the `lang` attribute.
240
- */
241
- t9nLocale: SupportedLocale;
242
- };
243
- /**
244
- * Start the locale observer for the given component.
245
- * The callback will be called when the locale changes for the component.
246
- * It will observe the lang attribute on the component and its ancestors.
247
- * The callback is called once at the beginning.
248
- *
249
- * @remarks
250
- * Rather than using this function directly, prefer the `useT9n()` controller.
251
- */
252
- declare function startLocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings>(
253
- /** The Web component HTML element that is doing the fetching */
254
- element: HTMLElement,
255
- /**
256
- * The callback to get path to the assets folder where the T9N strings are
257
- * located.
258
- *
259
- * @example
260
- * ```ts
261
- * () => getAssetPath("./assets")
262
- * ```
263
- */
264
- getAssetsPath: () => string,
265
- /** The callback to call when the locale changes */
266
- onUpdated: (payload: LocaleObserver<Strings>) => void,
267
- /**
268
- * Optionally override the asset file name.
269
- * Default file name is the component tag name without the part before the
270
- * first dash (e.g. `arcgis-map` becomes `map`).
271
- *
272
- * Set to null if the component has no localization strings, but you still
273
- * wish to use `startLocaleObserver` to get the locale information.
274
- */
275
- assetName?: string | null): () => void;
276
-
277
- declare const extractMinorVersion: (version: string) => string;
278
- /**
279
- * Creates preamble text from a version number. The preamble text is used in stencil.config.ts and inserts a comment at the top of the generated bundles.
280
- * The preamble text contains the version number and a link to the license.
281
- * The version number is typically extracted from the package.json file.
282
- * @example
283
- * ```ts
284
- * const preamble = getPreamble("4.18.2-beta.1");
285
- * console.log(preamble);
286
- * // All material copyright Esri, All Rights Reserved, unless otherwise specified.
287
- * // See https://js.arcgis.com/4.18/esri/copyright.txt for details.
288
- * // v4.18.2-beta.1
289
- * ```
290
- * @param version the version number, typically coming from package.json.
291
- * @returns a string containing the preamble text.
292
- */
293
- declare const getPreamble: (version: string) => string;
294
-
295
- /**
296
- * Add quotes to a string for display purposes.
297
- * If the string contains a double quote, then single quotes will be used.
298
- * If the string contains a single quote, then double quotes will be used.
299
- * If the string contains both, then double quotes will be used and the single quotes will be escaped.
300
- * @param value The string to quote
301
- * @returns The quoted string
302
- */
303
- declare function quoteString(value: string): string;
304
- /**
305
- * Create a filter expression from a filter word.
306
- * @param filterWord The filter word to create the expression from.
307
- * @returns The filter expression.
308
- */
309
- declare function createFilterExpression(filterWord: string): RegExp;
310
- /**
311
- * Replace values in a string using the format {valueName} with the value from the values object.
312
- * If the value is not found in the values object, then the value is not replaced.
313
- * @param message The string to replace values in.
314
- * @param values The values to replace in the string.
315
- * @returns The string with the values replaced.
316
- */
317
- declare function setValuesInString(message: string | null | undefined, values?: Record<string, string>): string;
318
- /**
319
- * Add LTR marks to a string to ensure it is displayed as LTR.
320
- * @param value The string to add LTR marks to.
321
- * @returns The string with LTR marks.
322
- */
323
- declare function addLTRMark(value: string | undefined): string;
324
-
325
- /** Convert kebab-case string to PascalCase */
326
- declare const kebabToPascal: (string: string) => string;
327
- /** Convert camelCase string to kebab-case */
328
- declare const camelToKebab: (string: string) => string;
329
- declare const capitalize: <T extends string>(string: T) => Capitalize<T>;
330
- declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
331
- declare const camelToHuman: (string: string) => string;
332
-
333
- /**
334
- * Like setTimeout(), but does not advance the clock if the program is
335
- * stopped on a debugger breakpoint.
336
- *
337
- * @see https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/60405
338
- */
339
- declare function devToolsAwareTimeout(callback: () => void, timeout: number): ReturnType<typeof setInterval>;
340
-
341
- /**
342
- * Safeguard to ensure that an item is not null.
343
- * @param item The item to check.
344
- * @returns Returns true if the item is not null.
345
- */
346
- declare function isNotNull<T>(item: T | null): item is T;
347
- /**
348
- * Safe guard to ensure that an item is not undefined.
349
- * @param item The item to check.
350
- * @returns Returns true if the item is not undefined.
351
- */
352
- declare function isNotUndefined<T>(item: T | undefined): item is T;
353
-
354
- /**
355
- * Allows to debounce a function.
356
- * @template F Function type that should extend a function with any parameters and a return type.
357
- * @param func Function to be debounced
358
- * @param waitFor Debounce time in milliseconds
359
- * @returns Returns a function that can be called to debounce the given function.
360
- */
361
- declare function debounce<F extends (...args: Parameters<F>) => ReturnType<F>>(func: F, waitFor?: number): (...args: Parameters<F>) => void;
362
-
363
- /**
364
- * Compares two url strings for their origin and returns true if they have the same origin.
365
- * @param url1 First url string
366
- * @param url2 Second url string
367
- * @param ignoreProtocol Indicates if protocol comparison should be ignored
368
- * @returns True if the two url strings have the same origin
369
- */
370
- declare function hasSameOrigin(url1: string | null | undefined, url2: string | null | undefined, ignoreProtocol?: boolean): boolean;
371
- /**
372
- * Tests if a url string is a URL or not.
373
- * @param url The url string to test
374
- * @returns True if the string is a URL.
375
- */
376
- declare function isURL(url: string): boolean;
377
-
378
- export { Deferred, type FocusableElement, type GenericT9nStrings, type IHandle, type LocaleObserver, type Nil, type SupportedLocale, type Writable, addLTRMark, camelToHuman, camelToKebab, capitalize, classes, closestElement, createFilterExpression, debounce, defaultLocale, devToolsAwareTimeout, extractMinorVersion, fetchT9nStringsBundle, focusElement, generateGuid, getElementAttribute, getElementDir, getElementLocales, getElementTheme, getPreamble, hasSameOrigin, identity, isEsriInternalEnv, isNotNull, isNotUndefined, isURL, kebabToPascal, mappedFind, normalizeLocale, observeAncestorsMutation, quoteString, safeAsyncCall, safeCall, setFocusOnElement, setValuesInString, startLocaleObserver, supportedLocales, uncapitalize };
1
+ export * from './array-utils';
2
+ export * from './css-utils';
3
+ export * from './deferred';
4
+ export * from './dom';
5
+ export * from './errors';
6
+ export * from './guid';
7
+ export * from './intl';
8
+ export * from './preamble';
9
+ export * from './strings';
10
+ export * from './text';
11
+ export * from './timeouts';
12
+ export * from './type-guards';
13
+ export * from './types';
14
+ export * from './ui';
15
+ export * from './url';
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- // src/array-utils.ts
2
1
  function mappedFind(array, callback) {
3
2
  for (let i = 0; i < array.length; i++) {
4
3
  const value = callback(array[i], i);
@@ -8,8 +7,6 @@ function mappedFind(array, callback) {
8
7
  }
9
8
  return;
10
9
  }
11
-
12
- // src/css-utils.ts
13
10
  function classes(...classes2) {
14
11
  const effectiveClasses = [];
15
12
  for (let i = 0; i < classes2.length; i++) {
@@ -30,9 +27,7 @@ function classes(...classes2) {
30
27
  effectiveClasses.length = 0;
31
28
  return className;
32
29
  }
33
-
34
- // src/deferred.ts
35
- var Deferred = class {
30
+ class Deferred {
36
31
  /**
37
32
  * Resolves the promise.
38
33
  * @param value The value to resolve the promise with.
@@ -53,9 +48,7 @@ var Deferred = class {
53
48
  this.reject = reject;
54
49
  });
55
50
  }
56
- };
57
-
58
- // src/dom.ts
51
+ }
59
52
  function inTargetElement(element, targetElement) {
60
53
  let currentElement = element;
61
54
  while (currentElement) {
@@ -82,7 +75,7 @@ function observeAncestorsMutation(element, attributeFilter, callback) {
82
75
  }
83
76
  });
84
77
  }
85
- var observers = {};
78
+ const observers = {};
86
79
  function observe(attributeFilter) {
87
80
  const attributes = attributeFilter.join(",");
88
81
  const previousObserver = observers[attributes];
@@ -190,8 +183,6 @@ function setFocusOnElement(ref, selector) {
190
183
  }
191
184
  void Promise.resolve(ref.componentOnReady?.()).then(() => setFocus(ref, selector));
192
185
  }
193
-
194
- // src/errors.ts
195
186
  function isEsriInternalEnv() {
196
187
  return typeof globalThis.process === "object" && !!process.env.ESRI_INTERNAL;
197
188
  }
@@ -212,8 +203,6 @@ async function safeAsyncCall(callback, thisContext, ...rest) {
212
203
  }
213
204
  return void 0;
214
205
  }
215
-
216
- // src/guid.ts
217
206
  function gen(count) {
218
207
  let out = "";
219
208
  for (let i = 0; i < count; i++) {
@@ -224,9 +213,7 @@ function gen(count) {
224
213
  function generateGuid() {
225
214
  return [gen(2), gen(1), gen(1), gen(1), gen(3)].join("-");
226
215
  }
227
-
228
- // src/intl.ts
229
- var supportedLocalesArray = [
216
+ const supportedLocalesArray = [
230
217
  "ar",
231
218
  "bg",
232
219
  "bs",
@@ -269,9 +256,9 @@ var supportedLocalesArray = [
269
256
  "zh-HK",
270
257
  "zh-TW"
271
258
  ];
272
- var supportedLocales = /* @__PURE__ */ new Set(supportedLocalesArray);
273
- var defaultLocale = "en";
274
- var localeEquivalencies = {
259
+ const supportedLocales = /* @__PURE__ */ new Set(supportedLocalesArray);
260
+ const defaultLocale = "en";
261
+ const localeEquivalencies = {
275
262
  // We use `pt-PT` as it will have the same translations as `pt`, which has no corresponding bundle
276
263
  pt: "pt-PT",
277
264
  // We support both 'nb' and 'no' (BCP 47) for Norwegian but only `no` has corresponding bundle
@@ -285,7 +272,7 @@ async function fetchT9nStringsBundle(locale, assetsPath, prefix = "") {
285
272
  t9nStringsCache[filePath] ?? (t9nStringsCache[filePath] = fetchBundle(locale, path));
286
273
  return await t9nStringsCache[filePath];
287
274
  }
288
- var t9nStringsCache = {};
275
+ const t9nStringsCache = {};
289
276
  async function fetchBundle(locale, path) {
290
277
  const filePath = `${path}${locale}.json`;
291
278
  try {
@@ -342,7 +329,7 @@ function startLocaleObserver(element, getAssetsPath, onUpdated, assetName) {
342
329
  queueMicrotask(callback);
343
330
  return observeAncestorsMutation(element, ["lang"], callback);
344
331
  }
345
- async function updateComponentLocaleState(element, assetsPath, assetName = element.tagName.toLowerCase().split("-").slice(1).join("-")) {
332
+ async function updateComponentLocaleState(element, assetsPath, assetName = element.localName.split("-").slice(1).join("-")) {
346
333
  const { lang, t9nLocale } = getElementLocales(element);
347
334
  const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
348
335
  const prefix = `messages.`;
@@ -352,18 +339,14 @@ async function updateComponentLocaleState(element, assetsPath, assetName = eleme
352
339
  );
353
340
  return { lang, t9nLocale, t9nStrings };
354
341
  }
355
-
356
- // src/preamble.ts
357
- 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}";
358
- var extractMinorVersion = (version) => {
342
+ 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}";
343
+ const extractMinorVersion = (version) => {
359
344
  const [major, minor] = version.split(".");
360
345
  return `${major}.${minor}`;
361
346
  };
362
- var getPreamble = (version) => blurb.replace("{minorVersion}", extractMinorVersion(version)).replace("{version}", version);
363
-
364
- // src/strings.ts
365
- var doubleQuote = '"';
366
- var singleQuote = "'";
347
+ const getPreamble = (version) => blurb.replace("{minorVersion}", extractMinorVersion(version)).replace("{version}", version);
348
+ const doubleQuote = '"';
349
+ const singleQuote = "'";
367
350
  function repeatString(value, n) {
368
351
  return new Array(n + 1).join(value);
369
352
  }
@@ -398,18 +381,14 @@ function setValuesInString(message, values = {}) {
398
381
  return (message ?? "").replace(/\{(?<valueName>.*?)\}/gu, (match, valueName) => values[valueName] ?? match);
399
382
  }
400
383
  function addLTRMark(value) {
401
- return `\u200E${value ?? ""}\u200E`;
402
- }
403
-
404
- // src/text.ts
405
- var kebabToPascal = (string) => string.split("-").map(capitalize).join("");
406
- var camelToKebab = (string) => string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`);
407
- var upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
408
- var capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
409
- var uncapitalize = (string) => string.charAt(0).toLowerCase() + string.slice(1);
410
- var camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
411
-
412
- // src/timeouts.ts
384
+ return `‎${value ?? ""}‎`;
385
+ }
386
+ const kebabToPascal = (string) => string.split("-").map(capitalize).join("");
387
+ const camelToKebab = (string) => string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : "-"}${upper.toLowerCase()}`);
388
+ const upperBeforeLower = /[A-Z]+(?![a-z])|[A-Z]/gu;
389
+ const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
390
+ const uncapitalize = (string) => string.charAt(0).toLowerCase() + string.slice(1);
391
+ const camelToHuman = (string) => capitalize(string.replace(upperBeforeLower, (upper, remainder) => `${remainder === 0 ? "" : " "}${upper}`));
413
392
  function devToolsAwareTimeout(callback, timeout) {
414
393
  const interval = timeout > longTimeoutThreshold ? longTimeoutInterval : timeout / shortTimeoutIntervals;
415
394
  let elapsed = 0;
@@ -422,22 +401,16 @@ function devToolsAwareTimeout(callback, timeout) {
422
401
  }, interval);
423
402
  return reference;
424
403
  }
425
- var longTimeoutThreshold = 4e3;
426
- var longTimeoutInterval = 2e3;
427
- var shortTimeoutIntervals = 4;
428
-
429
- // src/type-guards.ts
404
+ const longTimeoutThreshold = 4e3;
405
+ const longTimeoutInterval = 2e3;
406
+ const shortTimeoutIntervals = 4;
430
407
  function isNotNull(item) {
431
408
  return item !== null;
432
409
  }
433
410
  function isNotUndefined(item) {
434
411
  return item !== void 0;
435
412
  }
436
-
437
- // src/types.ts
438
- var identity = (value) => value;
439
-
440
- // src/ui.ts
413
+ const identity = (value) => value;
441
414
  function debounce(func, waitFor = 100) {
442
415
  let timeout;
443
416
  return (...args) => {
@@ -449,8 +422,6 @@ function debounce(func, waitFor = 100) {
449
422
  timeout = setTimeout(later, waitFor);
450
423
  };
451
424
  }
452
-
453
- // src/url.ts
454
425
  function hasSameOrigin(url1, url2, ignoreProtocol = false) {
455
426
  if (!url1 || !url2) {
456
427
  return false;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The interface for translated strings.
3
+ */
4
+ export interface GenericT9nStrings {
5
+ [key: string]: GenericT9nStrings | string;
6
+ }
7
+ declare const supportedLocalesArray: readonly ["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"];
8
+ /**
9
+ * The list of supported locales for ArcGIS Maps SDK for JavaScript components.
10
+ */
11
+ export declare const supportedLocales: Set<"hr" | "th" | "tr" | "ar" | "bg" | "bs" | "ca" | "cs" | "da" | "de" | "el" | "en" | "es" | "et" | "fi" | "fr" | "he" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "lv" | "nl" | "nb" | "no" | "pl" | "pt-BR" | "pt-PT" | "ro" | "ru" | "sk" | "sl" | "sr" | "sv" | "uk" | "vi" | "zh-CN" | "zh-HK" | "zh-TW">;
12
+ export type SupportedLocale = (typeof supportedLocalesArray)[number];
13
+ export declare const defaultLocale = "en";
14
+ /**
15
+ * Fetch the T9N strings bundle for the given locale, assets path and prefix.
16
+ * The locale must be one of the supported locales.
17
+ * If the locale is not supported, it will default to 'en'.
18
+ * If the T9N strings bundle cannot be found, it will default to 'en'.
19
+ *
20
+ * @remarks
21
+ * Rather than using this function directly, prefer the `useT9n()` controller.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const t9nStrings = await fetchT9nStringsBundle("en", getAssetPath("./assets/coding-editor/t9n"), "messages.");
26
+ * ```
27
+ */
28
+ export declare function fetchT9nStringsBundle<Strings extends GenericT9nStrings>(
29
+ /** The locale for which to fetch the T9N strings */
30
+ locale: string,
31
+ /** The path to the assets folder where the T9N strings are located */
32
+ assetsPath: string,
33
+ /** The prefix to use for the T9N strings file name. */
34
+ prefix?: string): Promise<Strings>;
35
+ /**
36
+ * Get the locale of the given element.
37
+ * It will look for the lang attribute on the element and its ancestors.
38
+ * If not lang is found, it will default to 'en'.
39
+ */
40
+ export declare function getElementLocales(element: HTMLElement): {
41
+ readonly lang: string;
42
+ readonly t9nLocale: SupportedLocale;
43
+ };
44
+ export declare function normalizeLocale(locale: string): SupportedLocale;
45
+ export type LocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings> = {
46
+ /** The T9N strings of the component */
47
+ t9nStrings: Strings;
48
+ /**
49
+ * The locale of the component set by the `lang` attribute on the component host element or one of its ancestors.
50
+ */
51
+ lang: string;
52
+ /**
53
+ * The locale used by the component to load the T9N strings.
54
+ * It may be different than the locale of the component host element that was set by the `lang` attribute.
55
+ */
56
+ t9nLocale: SupportedLocale;
57
+ };
58
+ /**
59
+ * Start the locale observer for the given component.
60
+ * The callback will be called when the locale changes for the component.
61
+ * It will observe the lang attribute on the component and its ancestors.
62
+ * The callback is called once at the beginning.
63
+ *
64
+ * @remarks
65
+ * Rather than using this function directly, prefer the `useT9n()` controller.
66
+ */
67
+ export declare function startLocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings>(
68
+ /** The Web component HTML element that is doing the fetching */
69
+ element: HTMLElement,
70
+ /**
71
+ * The callback to get path to the assets folder where the T9N strings are
72
+ * located.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * () => getAssetPath("./assets")
77
+ * ```
78
+ */
79
+ getAssetsPath: () => string,
80
+ /** The callback to call when the locale changes */
81
+ onUpdated: (payload: LocaleObserver<Strings>) => void,
82
+ /**
83
+ * Optionally override the asset file name.
84
+ * Default file name is the component tag name without the part before the
85
+ * first dash (e.g. `arcgis-map` becomes `map`).
86
+ *
87
+ * Set to null if the component has no localization strings, but you still
88
+ * wish to use `startLocaleObserver` to get the locale information.
89
+ */
90
+ assetName?: string | null): () => void;
91
+ export {};