@arcgis/components-utils 4.32.0-next.99 → 4.33.0-next.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/LICENSE.md +1 -1
- package/README.md +1 -1
- package/dist/index.cjs +8 -10
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +8 -10
- package/package.json +1 -1
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ It is not intended to be used directly, but rather used as a dependency by other
|
|
|
8
8
|
|
|
9
9
|
## License
|
|
10
10
|
|
|
11
|
-
COPYRIGHT ©
|
|
11
|
+
COPYRIGHT © 2025 Esri
|
|
12
12
|
|
|
13
13
|
All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
|
|
14
14
|
|
package/dist/index.cjs
CHANGED
|
@@ -164,13 +164,11 @@ function observe(attributeFilter) {
|
|
|
164
164
|
const observer = {
|
|
165
165
|
subscribe(callback) {
|
|
166
166
|
subscribers.add(callback);
|
|
167
|
-
return {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
observers[attributes] = void 0;
|
|
173
|
-
}
|
|
167
|
+
return () => {
|
|
168
|
+
subscribers.delete(callback);
|
|
169
|
+
if (subscribers.size === 0) {
|
|
170
|
+
mutationObserver.disconnect();
|
|
171
|
+
observers[attributes] = void 0;
|
|
174
172
|
}
|
|
175
173
|
};
|
|
176
174
|
}
|
|
@@ -396,15 +394,15 @@ function normalizeLocale(locale) {
|
|
|
396
394
|
}
|
|
397
395
|
return defaultLocale;
|
|
398
396
|
}
|
|
399
|
-
function startLocaleObserver(element,
|
|
397
|
+
function startLocaleObserver(element, getAssetsPath, onUpdated, assetName) {
|
|
400
398
|
let result = void 0;
|
|
401
|
-
const callback = () => void updateComponentLocaleState(element,
|
|
399
|
+
const callback = () => void updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
402
400
|
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
403
401
|
onUpdated(newResult);
|
|
404
402
|
}
|
|
405
403
|
result = newResult;
|
|
406
404
|
}).catch(console.error);
|
|
407
|
-
callback
|
|
405
|
+
queueMicrotask(callback);
|
|
408
406
|
return observeAncestorsMutation(element, ["lang"], callback);
|
|
409
407
|
}
|
|
410
408
|
async function updateComponentLocaleState(element, assetsPath, assetName = element.tagName.toLowerCase().split("-").slice(1).join("-")) {
|
package/dist/index.d.cts
CHANGED
|
@@ -89,7 +89,7 @@ declare class Deferred<T> {
|
|
|
89
89
|
* @param callback The callback to invoke when the attributes have been changed.
|
|
90
90
|
* @returns The mutation observer
|
|
91
91
|
*/
|
|
92
|
-
declare function observeAncestorsMutation(element: Node, attributeFilter: string[], callback: () => void):
|
|
92
|
+
declare function observeAncestorsMutation(element: Node, attributeFilter: string[], callback: () => void): () => void;
|
|
93
93
|
/**
|
|
94
94
|
* Find the closest element that matches the selector.
|
|
95
95
|
* It will traverse the element's ancestors to find the target element.
|
|
@@ -252,8 +252,16 @@ type LocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings> = {
|
|
|
252
252
|
declare function startLocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings>(
|
|
253
253
|
/** The Web component HTML element that is doing the fetching */
|
|
254
254
|
element: HTMLElement,
|
|
255
|
-
/**
|
|
256
|
-
|
|
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,
|
|
257
265
|
/** The callback to call when the locale changes */
|
|
258
266
|
onUpdated: (payload: LocaleObserver<Strings>) => void,
|
|
259
267
|
/**
|
|
@@ -264,7 +272,7 @@ onUpdated: (payload: LocaleObserver<Strings>) => void,
|
|
|
264
272
|
* Set to null if the component has no localization strings, but you still
|
|
265
273
|
* wish to use `startLocaleObserver` to get the locale information.
|
|
266
274
|
*/
|
|
267
|
-
assetName?: string | null):
|
|
275
|
+
assetName?: string | null): () => void;
|
|
268
276
|
|
|
269
277
|
declare const extractMinorVersion: (version: string) => string;
|
|
270
278
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ declare class Deferred<T> {
|
|
|
89
89
|
* @param callback The callback to invoke when the attributes have been changed.
|
|
90
90
|
* @returns The mutation observer
|
|
91
91
|
*/
|
|
92
|
-
declare function observeAncestorsMutation(element: Node, attributeFilter: string[], callback: () => void):
|
|
92
|
+
declare function observeAncestorsMutation(element: Node, attributeFilter: string[], callback: () => void): () => void;
|
|
93
93
|
/**
|
|
94
94
|
* Find the closest element that matches the selector.
|
|
95
95
|
* It will traverse the element's ancestors to find the target element.
|
|
@@ -252,8 +252,16 @@ type LocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings> = {
|
|
|
252
252
|
declare function startLocaleObserver<Strings extends GenericT9nStrings = GenericT9nStrings>(
|
|
253
253
|
/** The Web component HTML element that is doing the fetching */
|
|
254
254
|
element: HTMLElement,
|
|
255
|
-
/**
|
|
256
|
-
|
|
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,
|
|
257
265
|
/** The callback to call when the locale changes */
|
|
258
266
|
onUpdated: (payload: LocaleObserver<Strings>) => void,
|
|
259
267
|
/**
|
|
@@ -264,7 +272,7 @@ onUpdated: (payload: LocaleObserver<Strings>) => void,
|
|
|
264
272
|
* Set to null if the component has no localization strings, but you still
|
|
265
273
|
* wish to use `startLocaleObserver` to get the locale information.
|
|
266
274
|
*/
|
|
267
|
-
assetName?: string | null):
|
|
275
|
+
assetName?: string | null): () => void;
|
|
268
276
|
|
|
269
277
|
declare const extractMinorVersion: (version: string) => string;
|
|
270
278
|
/**
|
package/dist/index.js
CHANGED
|
@@ -101,13 +101,11 @@ function observe(attributeFilter) {
|
|
|
101
101
|
const observer = {
|
|
102
102
|
subscribe(callback) {
|
|
103
103
|
subscribers.add(callback);
|
|
104
|
-
return {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
observers[attributes] = void 0;
|
|
110
|
-
}
|
|
104
|
+
return () => {
|
|
105
|
+
subscribers.delete(callback);
|
|
106
|
+
if (subscribers.size === 0) {
|
|
107
|
+
mutationObserver.disconnect();
|
|
108
|
+
observers[attributes] = void 0;
|
|
111
109
|
}
|
|
112
110
|
};
|
|
113
111
|
}
|
|
@@ -333,15 +331,15 @@ function normalizeLocale(locale) {
|
|
|
333
331
|
}
|
|
334
332
|
return defaultLocale;
|
|
335
333
|
}
|
|
336
|
-
function startLocaleObserver(element,
|
|
334
|
+
function startLocaleObserver(element, getAssetsPath, onUpdated, assetName) {
|
|
337
335
|
let result = void 0;
|
|
338
|
-
const callback = () => void updateComponentLocaleState(element,
|
|
336
|
+
const callback = () => void updateComponentLocaleState(element, getAssetsPath(), assetName).then((newResult) => {
|
|
339
337
|
if (result?.lang !== newResult.lang || result.t9nLocale !== newResult.t9nLocale || result.t9nStrings !== newResult.t9nStrings) {
|
|
340
338
|
onUpdated(newResult);
|
|
341
339
|
}
|
|
342
340
|
result = newResult;
|
|
343
341
|
}).catch(console.error);
|
|
344
|
-
callback
|
|
342
|
+
queueMicrotask(callback);
|
|
345
343
|
return observeAncestorsMutation(element, ["lang"], callback);
|
|
346
344
|
}
|
|
347
345
|
async function updateComponentLocaleState(element, assetsPath, assetName = element.tagName.toLowerCase().split("-").slice(1).join("-")) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/components-utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.33.0-next.1",
|
|
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,
|