@arcgis/toolkit 5.2.0-next.37 → 5.2.0-next.39
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/index.d.ts → array.d.ts} +1 -1
- package/dist/dom/{reference-element.d.ts → referenceElement.d.ts} +4 -0
- package/dist/dom/referenceElement.js +5 -0
- package/dist/dom/slots.js +39 -0
- package/dist/{dom/index.js → dom-Bnc7oSYx.js} +30 -48
- package/dist/{dom/index.d.ts → dom.d.ts} +21 -3
- package/dist/dom.js +21 -0
- package/dist/intl/dom.d.ts +63 -0
- package/dist/intl/{index.js → dom.js} +39 -35
- package/dist/{intl/index.d.ts → intl.d.ts} +10 -62
- package/dist/intl.js +10 -0
- package/dist/{predicate/index.d.ts → predicate.d.ts} +1 -1
- package/package.json +16 -13
- /package/dist/{array/index.js → array.js} +0 -0
- /package/dist/{error/index.d.ts → error.d.ts} +0 -0
- /package/dist/{error/index.js → error.js} +0 -0
- /package/dist/{function/index.d.ts → function.d.ts} +0 -0
- /package/dist/{function/index.js → function.js} +0 -0
- /package/dist/{log/index.d.ts → log.d.ts} +0 -0
- /package/dist/{log/index.js → log.js} +0 -0
- /package/dist/{number/index.d.ts → number.d.ts} +0 -0
- /package/dist/{number/index.js → number.js} +0 -0
- /package/dist/{predicate/index.js → predicate.js} +0 -0
- /package/dist/{promise/index.d.ts → promise.d.ts} +0 -0
- /package/dist/{promise/index.js → promise.js} +0 -0
- /package/dist/{string/index.d.ts → string.d.ts} +0 -0
- /package/dist/{string/index.js → string.js} +0 -0
- /package/dist/{type/index.d.ts → type.d.ts} +0 -0
- /package/dist/{type/index.js → type.js} +0 -0
- /package/dist/{url/index.d.ts → url.d.ts} +0 -0
- /package/dist/{url/index.js → url.js} +0 -0
|
@@ -2,5 +2,9 @@ type ArcgisComponentBase<T> = {
|
|
|
2
2
|
el: HTMLElement;
|
|
3
3
|
referenceElement?: T | string | null | undefined;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a reference element (arcgis-map, arcgis-scene, arcgis-link-chart)
|
|
7
|
+
* from a component's `referenceElement` property or attribute.
|
|
8
|
+
*/
|
|
5
9
|
export declare function resolveReferenceElement<T extends Element>(component: ArcgisComponentBase<T>, referenceElementString?: ArcgisComponentBase<T>["referenceElement"] | string): T | undefined;
|
|
6
10
|
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
function slotChangeHasContent(event) {
|
|
2
|
+
return slotChangeHasAssignedElement(event) || slotChangeHasTextContent(event);
|
|
3
|
+
}
|
|
4
|
+
function slotChangeGetTextContent(event) {
|
|
5
|
+
return slotChangeGetAssignedNodes(event).filter((node) => node.nodeType === Node.TEXT_NODE).map((node) => node.textContent).join("").trim();
|
|
6
|
+
}
|
|
7
|
+
function slotChangeHasTextContent(event) {
|
|
8
|
+
return slotChangeGetTextContent(event).length > 0;
|
|
9
|
+
}
|
|
10
|
+
function slotChangeHasAssignedNode(event) {
|
|
11
|
+
return slotChangeGetAssignedNodes(event).length > 0;
|
|
12
|
+
}
|
|
13
|
+
function slotChangeGetAssignedNodes(event) {
|
|
14
|
+
return event.currentTarget.assignedNodes({
|
|
15
|
+
flatten: true
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function slotChangeHasAssignedElement(event) {
|
|
19
|
+
return slotChangeGetAssignedElements(event).length > 0;
|
|
20
|
+
}
|
|
21
|
+
function slotChangeGetAssignedElements(event, selector) {
|
|
22
|
+
return getSlotAssignedElements(event.target, selector);
|
|
23
|
+
}
|
|
24
|
+
function getSlotAssignedElements(slot, selector) {
|
|
25
|
+
const assignedElements = slot.assignedElements({
|
|
26
|
+
flatten: true
|
|
27
|
+
});
|
|
28
|
+
return selector ? assignedElements.filter((element) => element.matches(selector)) : assignedElements;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
getSlotAssignedElements,
|
|
32
|
+
slotChangeGetAssignedElements,
|
|
33
|
+
slotChangeGetAssignedNodes,
|
|
34
|
+
slotChangeGetTextContent,
|
|
35
|
+
slotChangeHasAssignedElement,
|
|
36
|
+
slotChangeHasAssignedNode,
|
|
37
|
+
slotChangeHasContent,
|
|
38
|
+
slotChangeHasTextContent
|
|
39
|
+
};
|
|
@@ -1,35 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
return slotChangeHasAssignedElement(event) || slotChangeHasTextContent(event);
|
|
4
|
-
}
|
|
5
|
-
function slotChangeGetTextContent(event) {
|
|
6
|
-
return slotChangeGetAssignedNodes(event).filter((node) => node.nodeType === Node.TEXT_NODE).map((node) => node.textContent).join("").trim();
|
|
7
|
-
}
|
|
8
|
-
function slotChangeHasTextContent(event) {
|
|
9
|
-
return slotChangeGetTextContent(event).length > 0;
|
|
10
|
-
}
|
|
11
|
-
function slotChangeHasAssignedNode(event) {
|
|
12
|
-
return slotChangeGetAssignedNodes(event).length > 0;
|
|
13
|
-
}
|
|
14
|
-
function slotChangeGetAssignedNodes(event) {
|
|
15
|
-
return event.currentTarget.assignedNodes({
|
|
16
|
-
flatten: true
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function slotChangeHasAssignedElement(event) {
|
|
20
|
-
return slotChangeGetAssignedElements(event).length > 0;
|
|
21
|
-
}
|
|
22
|
-
function slotChangeGetAssignedElements(event, selector) {
|
|
23
|
-
return getSlotAssignedElements(event.target, selector);
|
|
24
|
-
}
|
|
25
|
-
function getSlotAssignedElements(slot, selector) {
|
|
26
|
-
const assignedElements = slot.assignedElements({
|
|
27
|
-
flatten: true
|
|
28
|
-
});
|
|
29
|
-
return selector ? assignedElements.filter((element) => element.matches(selector)) : assignedElements;
|
|
30
|
-
}
|
|
1
|
+
import { getSlotAssignedElements as getSlotAssignedElements$1, slotChangeGetAssignedElements as slotChangeGetAssignedElements$1, slotChangeGetAssignedNodes as slotChangeGetAssignedNodes$1, slotChangeGetTextContent as slotChangeGetTextContent$1, slotChangeHasAssignedElement as slotChangeHasAssignedElement$1, slotChangeHasAssignedNode as slotChangeHasAssignedNode$1, slotChangeHasContent as slotChangeHasContent$1, slotChangeHasTextContent as slotChangeHasTextContent$1 } from "./dom/slots.js";
|
|
2
|
+
import { log } from "./log.js";
|
|
31
3
|
const allowedTags = ["arcgis-map", "arcgis-scene", "arcgis-link-chart"];
|
|
32
|
-
function resolveReferenceElement(component, referenceElementString) {
|
|
4
|
+
function resolveReferenceElement$1(component, referenceElementString) {
|
|
33
5
|
const referenceElement = referenceElementString ?? component.referenceElement;
|
|
34
6
|
if (typeof referenceElement !== "string") {
|
|
35
7
|
return referenceElement ?? void 0;
|
|
@@ -55,6 +27,15 @@ function resolveReferenceElement(component, referenceElementString) {
|
|
|
55
27
|
}
|
|
56
28
|
return resolved ?? void 0;
|
|
57
29
|
}
|
|
30
|
+
const slotChangeHasContent = slotChangeHasContent$1;
|
|
31
|
+
const slotChangeGetTextContent = slotChangeGetTextContent$1;
|
|
32
|
+
const slotChangeHasTextContent = slotChangeHasTextContent$1;
|
|
33
|
+
const slotChangeHasAssignedNode = slotChangeHasAssignedNode$1;
|
|
34
|
+
const slotChangeGetAssignedNodes = slotChangeGetAssignedNodes$1;
|
|
35
|
+
const slotChangeHasAssignedElement = slotChangeHasAssignedElement$1;
|
|
36
|
+
const slotChangeGetAssignedElements = slotChangeGetAssignedElements$1;
|
|
37
|
+
const getSlotAssignedElements = getSlotAssignedElements$1;
|
|
38
|
+
const resolveReferenceElement = resolveReferenceElement$1;
|
|
58
39
|
const classes = (...classes2) => {
|
|
59
40
|
const effectiveClasses = [];
|
|
60
41
|
for (let i = 0; i < classes2.length; ++i) {
|
|
@@ -207,21 +188,22 @@ const setFocus = (ref, selector = "") => {
|
|
|
207
188
|
return false;
|
|
208
189
|
};
|
|
209
190
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
191
|
+
getClosestElement as a,
|
|
192
|
+
getSlotAssignedElements as b,
|
|
193
|
+
classes as c,
|
|
194
|
+
resolveReferenceElement as d,
|
|
195
|
+
slotChangeGetAssignedElements as e,
|
|
196
|
+
focusElement as f,
|
|
197
|
+
getElementAttribute as g,
|
|
198
|
+
slotChangeGetAssignedNodes as h,
|
|
199
|
+
slotChangeGetTextContent as i,
|
|
200
|
+
slotChangeHasAssignedElement as j,
|
|
201
|
+
slotChangeHasAssignedNode as k,
|
|
202
|
+
slotChangeHasContent as l,
|
|
203
|
+
slotChangeHasTextContent as m,
|
|
204
|
+
unsafeGetElementDirection as n,
|
|
205
|
+
observeAncestorsMutation as o,
|
|
206
|
+
resolveReferenceElement$1 as r,
|
|
207
|
+
setFocusOnElement as s,
|
|
208
|
+
unsafeGetCalciteModeName as u
|
|
227
209
|
};
|
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import { nil } from '
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { nil } from './type.ts';
|
|
2
|
+
import { slotChangeHasContent as slotChangeHasContentAlias, slotChangeGetTextContent as slotChangeGetTextContentAlias, slotChangeHasTextContent as slotChangeHasTextContentAlias, slotChangeHasAssignedNode as slotChangeHasAssignedNodeAlias, slotChangeGetAssignedNodes as slotChangeGetAssignedNodesAlias, slotChangeHasAssignedElement as slotChangeHasAssignedElementAlias, slotChangeGetAssignedElements as slotChangeGetAssignedElementsAlias, getSlotAssignedElements as getSlotAssignedElementsAlias } from './dom/slots.ts';
|
|
3
|
+
import { resolveReferenceElement as resolveReferenceElementAlias } from './dom/referenceElement.ts';
|
|
4
|
+
/** @deprecated import { slotChangeHasContent } from "@arcgis/toolkit/dom/slots"; instead */
|
|
5
|
+
export declare const slotChangeHasContent: typeof slotChangeHasContentAlias;
|
|
6
|
+
/** @deprecated import { slotChangeGetTextContent } from "@arcgis/toolkit/dom/slots"; instead */
|
|
7
|
+
export declare const slotChangeGetTextContent: typeof slotChangeGetTextContentAlias;
|
|
8
|
+
/** @deprecated import { slotChangeHasTextContent } from "@arcgis/toolkit/dom/slots"; instead */
|
|
9
|
+
export declare const slotChangeHasTextContent: typeof slotChangeHasTextContentAlias;
|
|
10
|
+
/** @deprecated import { slotChangeHasAssignedNode } from "@arcgis/toolkit/dom/slots"; instead */
|
|
11
|
+
export declare const slotChangeHasAssignedNode: typeof slotChangeHasAssignedNodeAlias;
|
|
12
|
+
/** @deprecated import { slotChangeGetAssignedNodes } from "@arcgis/toolkit/dom/slots"; instead */
|
|
13
|
+
export declare const slotChangeGetAssignedNodes: typeof slotChangeGetAssignedNodesAlias;
|
|
14
|
+
/** @deprecated import { slotChangeHasAssignedElement } from "@arcgis/toolkit/dom/slots"; instead */
|
|
15
|
+
export declare const slotChangeHasAssignedElement: typeof slotChangeHasAssignedElementAlias;
|
|
16
|
+
/** @deprecated import { slotChangeGetAssignedElements } from "@arcgis/toolkit/dom/slots"; instead */
|
|
17
|
+
export declare const slotChangeGetAssignedElements: typeof slotChangeGetAssignedElementsAlias;
|
|
18
|
+
/** @deprecated import { getSlotAssignedElements } from "@arcgis/toolkit/dom/slots"; instead */
|
|
19
|
+
export declare const getSlotAssignedElements: typeof getSlotAssignedElementsAlias;
|
|
20
|
+
/** @deprecated import { resolveReferenceElement } from "@arcgis/toolkit/dom/reference-element"; instead */
|
|
21
|
+
export declare const resolveReferenceElement: typeof resolveReferenceElementAlias;
|
|
4
22
|
/**
|
|
5
23
|
* Combine multiple class names into a single string.
|
|
6
24
|
*
|
package/dist/dom.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./dom/slots.js";
|
|
2
|
+
import { c, f, a, g, b, o, d, s, e, h, i, j, k, l, m, u, n } from "./dom-Bnc7oSYx.js";
|
|
3
|
+
export {
|
|
4
|
+
c as classes,
|
|
5
|
+
f as focusElement,
|
|
6
|
+
a as getClosestElement,
|
|
7
|
+
g as getElementAttribute,
|
|
8
|
+
b as getSlotAssignedElements,
|
|
9
|
+
o as observeAncestorsMutation,
|
|
10
|
+
d as resolveReferenceElement,
|
|
11
|
+
s as setFocusOnElement,
|
|
12
|
+
e as slotChangeGetAssignedElements,
|
|
13
|
+
h as slotChangeGetAssignedNodes,
|
|
14
|
+
i as slotChangeGetTextContent,
|
|
15
|
+
j as slotChangeHasAssignedElement,
|
|
16
|
+
k as slotChangeHasAssignedNode,
|
|
17
|
+
l as slotChangeHasContent,
|
|
18
|
+
m as slotChangeHasTextContent,
|
|
19
|
+
u as unsafeGetCalciteModeName,
|
|
20
|
+
n as unsafeGetElementDirection
|
|
21
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { GenericT9nStrings, SupportedLocale } from '../intl.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Get the locale of the given element.
|
|
4
|
+
* It will look for the lang attribute on the element and its ancestors.
|
|
5
|
+
* If not lang is found, it will default to 'en'.
|
|
6
|
+
*
|
|
7
|
+
* @returns an object with the `lang` and `t9nLocale` properties.
|
|
8
|
+
*
|
|
9
|
+
* @see [lang vs t9nLocale](https://webgis.esri.com/references/lumina/controllers/useT9n#difference-between-lang-and-t9nlocale).
|
|
10
|
+
*/
|
|
11
|
+
export declare const getElementLocale: (element: HTMLElement) => {
|
|
12
|
+
readonly lang: string;
|
|
13
|
+
readonly t9nLocale: SupportedLocale;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Start the locale observer for the given component.
|
|
17
|
+
* The callback will be called when the locale changes for the component.
|
|
18
|
+
* It will observe the lang attribute on the component and its ancestors.
|
|
19
|
+
* The callback is called once at the beginning.
|
|
20
|
+
*
|
|
21
|
+
* @param element The HTML element that is doing the fetching
|
|
22
|
+
* This is used to determine the locale to fetch, observe the `lang` attribute
|
|
23
|
+
* changes, and is used as the default value for the `assetName` parameter.
|
|
24
|
+
* @param getAssetsPath The callback to get path to the assets folder where the
|
|
25
|
+
* T9N strings are located.
|
|
26
|
+
* @param onUpdated The callback to call when the locale changes.
|
|
27
|
+
* @param assetName Optionally override the asset file name.
|
|
28
|
+
* Default file name is the element tag name without the part before the
|
|
29
|
+
* first dash (e.g. `arcgis-map` becomes `map`).
|
|
30
|
+
*
|
|
31
|
+
* Set to null if the component has no localization strings, but you still
|
|
32
|
+
* wish to use `startLocaleObserver` to get the locale information.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* Rather than using this function directly, prefer the
|
|
36
|
+
* [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
|
|
37
|
+
* controller.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const observer = startLocaleObserver(
|
|
42
|
+
* element,
|
|
43
|
+
* () => getAssetPath("./assets"),
|
|
44
|
+
* ({ strings, lang, t9nLocale }) => console.log({ strings, lang, t9nLocale }),
|
|
45
|
+
* );
|
|
46
|
+
* // Later: cleanup
|
|
47
|
+
* observer();
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const startLocaleObserver: <Strings extends GenericT9nStrings = GenericT9nStrings>(element: HTMLElement, getAssetsPath: () => string, onUpdated: (payload: LocaleObserverResult<Strings>) => void, assetName?: string | null) => (() => void);
|
|
51
|
+
export interface LocaleObserverResult<Strings extends GenericT9nStrings = GenericT9nStrings> {
|
|
52
|
+
/** The T9N strings of the component */
|
|
53
|
+
t9nStrings: Strings;
|
|
54
|
+
/**
|
|
55
|
+
* The locale of the component set by the `lang` attribute on the component host element or one of its ancestors.
|
|
56
|
+
*/
|
|
57
|
+
lang: string;
|
|
58
|
+
/**
|
|
59
|
+
* The locale used by the component to load the T9N strings.
|
|
60
|
+
* It may be different than the locale of the component host element that was set by the `lang` attribute.
|
|
61
|
+
*/
|
|
62
|
+
t9nLocale: SupportedLocale;
|
|
63
|
+
}
|
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { log } from "../log.js";
|
|
2
|
+
import { g as getElementAttribute, o as observeAncestorsMutation } from "../dom-Bnc7oSYx.js";
|
|
3
|
+
const getElementLocale$1 = (element) => {
|
|
4
|
+
const lang = getElementAttribute(element, "lang", globalThis.navigator?.language || defaultLocale);
|
|
5
|
+
return { lang, t9nLocale: normalizeLocale(lang) };
|
|
6
|
+
};
|
|
7
|
+
const startLocaleObserver$1 = (element, getAssetsPath, onUpdated, assetName) => {
|
|
8
|
+
let result = void 0;
|
|
9
|
+
const callback = () => updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
10
|
+
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
11
|
+
onUpdated(newResult);
|
|
12
|
+
}
|
|
13
|
+
result = newResult;
|
|
14
|
+
}).catch((error) => {
|
|
15
|
+
log("error", "intl", "Error updating component locale state", { detail: { error } });
|
|
16
|
+
});
|
|
17
|
+
queueMicrotask(callback);
|
|
18
|
+
return observeAncestorsMutation(element, ["lang"], callback);
|
|
19
|
+
};
|
|
20
|
+
const updateComponentLocaleState = async (element, assetsPath, assetName = element.localName.split("-").slice(1).join("-")) => {
|
|
21
|
+
const { lang, t9nLocale } = getElementLocale$1(element);
|
|
22
|
+
const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
|
|
23
|
+
const prefix = `messages.`;
|
|
24
|
+
const t9nStrings = (
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
26
|
+
assetName === null ? {} : await fetchT9nStringsBundle(t9nLocale, t9nAssetsPath, prefix)
|
|
27
|
+
);
|
|
28
|
+
return { lang, t9nLocale, t9nStrings };
|
|
29
|
+
};
|
|
30
|
+
const getElementLocale = getElementLocale$1;
|
|
31
|
+
const startLocaleObserver = startLocaleObserver$1;
|
|
3
32
|
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(
|
|
4
33
|
","
|
|
5
34
|
);
|
|
@@ -57,10 +86,6 @@ const fetchBundle = async (locale, path) => {
|
|
|
57
86
|
}
|
|
58
87
|
return await fetchBundle(defaultLocale, path);
|
|
59
88
|
};
|
|
60
|
-
const getElementLocale = (element) => {
|
|
61
|
-
const lang = getElementAttribute(element, "lang", globalThis.navigator?.language || defaultLocale);
|
|
62
|
-
return { lang, t9nLocale: normalizeLocale(lang) };
|
|
63
|
-
};
|
|
64
89
|
const normalizeLocale = (lang) => {
|
|
65
90
|
const [rawLanguageCode, regionCode] = lang.split("-");
|
|
66
91
|
const languageCode = rawLanguageCode.toLowerCase();
|
|
@@ -77,34 +102,13 @@ const normalizeLocale = (lang) => {
|
|
|
77
102
|
}
|
|
78
103
|
return defaultLocale;
|
|
79
104
|
};
|
|
80
|
-
const startLocaleObserver = (element, getAssetsPath, onUpdated, assetName) => {
|
|
81
|
-
let result = void 0;
|
|
82
|
-
const callback = () => updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
83
|
-
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
84
|
-
onUpdated(newResult);
|
|
85
|
-
}
|
|
86
|
-
result = newResult;
|
|
87
|
-
}).catch((error) => {
|
|
88
|
-
log("error", "intl", "Error updating component locale state", { detail: { error } });
|
|
89
|
-
});
|
|
90
|
-
queueMicrotask(callback);
|
|
91
|
-
return observeAncestorsMutation(element, ["lang"], callback);
|
|
92
|
-
};
|
|
93
|
-
const updateComponentLocaleState = async (element, assetsPath, assetName = element.localName.split("-").slice(1).join("-")) => {
|
|
94
|
-
const { lang, t9nLocale } = getElementLocale(element);
|
|
95
|
-
const t9nAssetsPath = `${assetsPath}/${assetName}/t9n`;
|
|
96
|
-
const prefix = `messages.`;
|
|
97
|
-
const t9nStrings = (
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
99
|
-
assetName === null ? {} : await fetchT9nStringsBundle(t9nLocale, t9nAssetsPath, prefix)
|
|
100
|
-
);
|
|
101
|
-
return { lang, t9nLocale, t9nStrings };
|
|
102
|
-
};
|
|
103
105
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
supportedLocales as a,
|
|
107
|
+
defaultLocale as d,
|
|
108
|
+
fetchT9nStringsBundle as f,
|
|
109
|
+
getElementLocale as g,
|
|
110
|
+
getElementLocale$1 as getElementLocale,
|
|
111
|
+
normalizeLocale as n,
|
|
112
|
+
startLocaleObserver as s,
|
|
113
|
+
startLocaleObserver$1 as startLocaleObserver
|
|
110
114
|
};
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import { LocaleObserverResult as LocaleObserverResultAlias } from './intl/dom.ts';
|
|
2
|
+
/** @deprecated import { getElementLocale } from "./intl/dom.ts" instead */
|
|
3
|
+
export declare const getElementLocale: (element: HTMLElement) => {
|
|
4
|
+
readonly lang: string;
|
|
5
|
+
readonly t9nLocale: SupportedLocale;
|
|
6
|
+
};
|
|
7
|
+
/** @deprecated import { startLocaleObserver } from "./intl/dom.ts" instead */
|
|
8
|
+
export declare const startLocaleObserver: <Strings extends GenericT9nStrings = GenericT9nStrings>(element: HTMLElement, getAssetsPath: () => string, onUpdated: (payload: LocaleObserverResultAlias<Strings>) => void, assetName?: string | null) => (() => void);
|
|
9
|
+
/** @deprecated import type { LocaleObserverResult } from "./intl/dom.ts" instead */
|
|
10
|
+
export type LocaleObserverResult = LocaleObserverResultAlias;
|
|
1
11
|
declare 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"];
|
|
2
12
|
/**
|
|
3
13
|
* The list of supported locales for ArcGIS Maps SDK for JavaScript components.
|
|
@@ -48,19 +58,6 @@ export declare const fetchT9nStringsBundle: <Strings extends GenericT9nStrings>(
|
|
|
48
58
|
export interface GenericT9nStrings {
|
|
49
59
|
[key: string]: GenericT9nStrings | string;
|
|
50
60
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Get the locale of the given element.
|
|
53
|
-
* It will look for the lang attribute on the element and its ancestors.
|
|
54
|
-
* If not lang is found, it will default to 'en'.
|
|
55
|
-
*
|
|
56
|
-
* @returns an object with the `lang` and `t9nLocale` properties.
|
|
57
|
-
*
|
|
58
|
-
* @see [lang vs t9nLocale](https://webgis.esri.com/references/lumina/controllers/useT9n#difference-between-lang-and-t9nlocale).
|
|
59
|
-
*/
|
|
60
|
-
export declare const getElementLocale: (element: HTMLElement) => {
|
|
61
|
-
readonly lang: string;
|
|
62
|
-
readonly t9nLocale: SupportedLocale;
|
|
63
|
-
};
|
|
64
61
|
/**
|
|
65
62
|
* Try to parse any language string into one of the locales supported by WebGIS SDK.
|
|
66
63
|
*
|
|
@@ -72,53 +69,4 @@ export declare const getElementLocale: (element: HTMLElement) => {
|
|
|
72
69
|
* language is normalized to the language code only.
|
|
73
70
|
*/
|
|
74
71
|
export declare const normalizeLocale: (lang: string) => SupportedLocale;
|
|
75
|
-
export interface LocaleObserverResult<Strings extends GenericT9nStrings = GenericT9nStrings> {
|
|
76
|
-
/** The T9N strings of the component */
|
|
77
|
-
t9nStrings: Strings;
|
|
78
|
-
/**
|
|
79
|
-
* The locale of the component set by the `lang` attribute on the component host element or one of its ancestors.
|
|
80
|
-
*/
|
|
81
|
-
lang: string;
|
|
82
|
-
/**
|
|
83
|
-
* The locale used by the component to load the T9N strings.
|
|
84
|
-
* It may be different than the locale of the component host element that was set by the `lang` attribute.
|
|
85
|
-
*/
|
|
86
|
-
t9nLocale: SupportedLocale;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Start the locale observer for the given component.
|
|
90
|
-
* The callback will be called when the locale changes for the component.
|
|
91
|
-
* It will observe the lang attribute on the component and its ancestors.
|
|
92
|
-
* The callback is called once at the beginning.
|
|
93
|
-
*
|
|
94
|
-
* @param element The HTML element that is doing the fetching
|
|
95
|
-
* This is used to determine the locale to fetch, observe the `lang` attribute
|
|
96
|
-
* changes, and is used as the default value for the `assetName` parameter.
|
|
97
|
-
* @param getAssetsPath The callback to get path to the assets folder where the
|
|
98
|
-
* T9N strings are located.
|
|
99
|
-
* @param onUpdated The callback to call when the locale changes.
|
|
100
|
-
* @param assetName Optionally override the asset file name.
|
|
101
|
-
* Default file name is the element tag name without the part before the
|
|
102
|
-
* first dash (e.g. `arcgis-map` becomes `map`).
|
|
103
|
-
*
|
|
104
|
-
* Set to null if the component has no localization strings, but you still
|
|
105
|
-
* wish to use `startLocaleObserver` to get the locale information.
|
|
106
|
-
*
|
|
107
|
-
* @remarks
|
|
108
|
-
* Rather than using this function directly, prefer the
|
|
109
|
-
* [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
|
|
110
|
-
* controller.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```ts
|
|
114
|
-
* const observer = startLocaleObserver(
|
|
115
|
-
* element,
|
|
116
|
-
* () => getAssetPath("./assets"),
|
|
117
|
-
* ({ strings, lang, t9nLocale }) => console.log({ strings, lang, t9nLocale }),
|
|
118
|
-
* );
|
|
119
|
-
* // Later: cleanup
|
|
120
|
-
* observer();
|
|
121
|
-
* ```
|
|
122
|
-
*/
|
|
123
|
-
export declare const startLocaleObserver: <Strings extends GenericT9nStrings = GenericT9nStrings>(element: HTMLElement, getAssetsPath: () => string, onUpdated: (payload: LocaleObserverResult<Strings>) => void, assetName?: string | null) => (() => void);
|
|
124
72
|
export {};
|
package/dist/intl.js
ADDED
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/toolkit",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.39",
|
|
4
4
|
"description": "Collection of common internal patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
|
|
5
5
|
"homepage": "https://developers.arcgis.com/javascript/latest/",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
|
-
"./array": "./dist/array
|
|
10
|
-
"./dom": "./dist/dom
|
|
11
|
-
"./
|
|
12
|
-
"./
|
|
13
|
-
"./
|
|
14
|
-
"./
|
|
15
|
-
"./
|
|
16
|
-
"./
|
|
17
|
-
"./
|
|
18
|
-
"./
|
|
19
|
-
"./
|
|
20
|
-
"./
|
|
9
|
+
"./array": "./dist/array.js",
|
|
10
|
+
"./dom": "./dist/dom.js",
|
|
11
|
+
"./dom/slots": "./dist/dom/slots.js",
|
|
12
|
+
"./dom/referenceElement": "./dist/dom/referenceElement.js",
|
|
13
|
+
"./error": "./dist/error.js",
|
|
14
|
+
"./function": "./dist/function.js",
|
|
15
|
+
"./intl": "./dist/intl.js",
|
|
16
|
+
"./intl/dom": "./dist/intl/dom.js",
|
|
17
|
+
"./log": "./dist/log.js",
|
|
18
|
+
"./number": "./dist/number.js",
|
|
19
|
+
"./predicate": "./dist/predicate.js",
|
|
20
|
+
"./promise": "./dist/promise.js",
|
|
21
|
+
"./string": "./dist/string.js",
|
|
22
|
+
"./type": "./dist/type.js",
|
|
23
|
+
"./url": "./dist/url.js",
|
|
21
24
|
"./package.json": "./package.json"
|
|
22
25
|
},
|
|
23
26
|
"files": [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|