@arcgis/toolkit 5.2.0-next.99 → 6.0.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/dist/{dom-Bnc7oSYx.js → chunks/dom.js} +18 -14
- package/dist/dom/color.d.ts +56 -0
- package/dist/dom/color.js +37 -0
- package/dist/dom/referenceElement.js +1 -1
- package/dist/dom.d.ts +9 -0
- package/dist/dom.js +14 -13
- package/dist/intl/dom.d.ts +10 -4
- package/dist/intl/dom.js +1 -1
- package/dist/promise.d.ts +12 -0
- package/dist/promise.js +22 -1
- package/package.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
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 "
|
|
2
|
-
import { log } from "
|
|
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";
|
|
3
3
|
const allowedTags = ["arcgis-map", "arcgis-scene", "arcgis-link-chart"];
|
|
4
4
|
function resolveReferenceElement$1(component, referenceElementString) {
|
|
5
5
|
const referenceElement = referenceElementString ?? component.referenceElement;
|
|
@@ -187,22 +187,26 @@ const setFocus = (ref, selector = "") => {
|
|
|
187
187
|
}
|
|
188
188
|
return false;
|
|
189
189
|
};
|
|
190
|
+
function getElementWindow(element) {
|
|
191
|
+
return element.ownerDocument.defaultView || window;
|
|
192
|
+
}
|
|
190
193
|
export {
|
|
191
|
-
|
|
192
|
-
|
|
194
|
+
getElementAttribute as a,
|
|
195
|
+
getClosestElement as b,
|
|
193
196
|
classes as c,
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
getSlotAssignedElements as d,
|
|
198
|
+
resolveReferenceElement as e,
|
|
196
199
|
focusElement as f,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
getElementWindow as g,
|
|
201
|
+
slotChangeGetAssignedElements as h,
|
|
202
|
+
slotChangeGetAssignedNodes as i,
|
|
203
|
+
slotChangeGetTextContent as j,
|
|
204
|
+
slotChangeHasAssignedElement as k,
|
|
205
|
+
slotChangeHasAssignedNode as l,
|
|
206
|
+
slotChangeHasContent as m,
|
|
207
|
+
slotChangeHasTextContent as n,
|
|
205
208
|
observeAncestorsMutation as o,
|
|
209
|
+
unsafeGetElementDirection as p,
|
|
206
210
|
resolveReferenceElement$1 as r,
|
|
207
211
|
setFocusOnElement as s,
|
|
208
212
|
unsafeGetCalciteModeName as u
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the resolved color from a CSS custom property on an element.
|
|
3
|
+
*
|
|
4
|
+
* Resolves `light-dark()` values using the element's inherited color scheme,
|
|
5
|
+
* including styles in its shadow root. Returns `undefined` if the property is
|
|
6
|
+
* missing. The returned value is a CSS color string, not a parsed color.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
* @param element The element on which to read the custom property.
|
|
10
|
+
* @param propertyName The CSS custom property containing a color.
|
|
11
|
+
* @returns The resolved CSS color, or `undefined` if the property is missing.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const textColor = getCssColor(element, "--app-text-color");
|
|
16
|
+
* const fallbackColor = getCssColor(element, "--optional-color") ?? "black";
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```css
|
|
21
|
+
* .panel {
|
|
22
|
+
* color-scheme: dark;
|
|
23
|
+
* --panel-color: light-dark(#ffffff, #202020);
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
* ```ts
|
|
27
|
+
* // Resolves to the dark color in the context of the panel.
|
|
28
|
+
* const panelColor = getCssColor(panel, "--panel-color");
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function getCssColor(element: Element, propertyName: string): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Get the effective light or dark color scheme for an element.
|
|
34
|
+
*
|
|
35
|
+
* A computed `color-scheme` containing only `light` or only `dark` takes
|
|
36
|
+
* precedence. If both or neither are allowed, the system color preference
|
|
37
|
+
* determines the result. This is a snapshot; call again after styles or the
|
|
38
|
+
* system preference change.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
* @param element The element whose computed color scheme is used.
|
|
42
|
+
* @returns The effective color scheme.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* // An element with `color-scheme: dark` returns "dark".
|
|
47
|
+
* const scheme = getEffectiveColorScheme(element);
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // With `color-scheme: light dark`, the preferred system scheme is returned.
|
|
53
|
+
* const preferredScheme = getEffectiveColorScheme(element);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function getEffectiveColorScheme(element: Element): "dark" | "light";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { g as getElementWindow } from "../chunks/dom.js";
|
|
2
|
+
function getCssColor(element, propertyName) {
|
|
3
|
+
const elWindow = getElementWindow(element);
|
|
4
|
+
const cssColor = elWindow.getComputedStyle(element).getPropertyValue(propertyName).trim();
|
|
5
|
+
if (!cssColor) {
|
|
6
|
+
return void 0;
|
|
7
|
+
}
|
|
8
|
+
if (!/light-dark\(/iu.test(cssColor)) {
|
|
9
|
+
return cssColor;
|
|
10
|
+
}
|
|
11
|
+
const sampleElement = element.ownerDocument.createElement("test");
|
|
12
|
+
Object.assign(sampleElement.style, {
|
|
13
|
+
color: cssColor,
|
|
14
|
+
display: "none"
|
|
15
|
+
});
|
|
16
|
+
if (!sampleElement.style.color) {
|
|
17
|
+
return cssColor;
|
|
18
|
+
}
|
|
19
|
+
(element.shadowRoot ?? element).append(sampleElement);
|
|
20
|
+
const color = elWindow.getComputedStyle(sampleElement).color || cssColor;
|
|
21
|
+
sampleElement.remove();
|
|
22
|
+
return color;
|
|
23
|
+
}
|
|
24
|
+
function getEffectiveColorScheme(element) {
|
|
25
|
+
const elWindow = getElementWindow(element);
|
|
26
|
+
const colorSchemes = elWindow.getComputedStyle(element).colorScheme.split(/\s+/u);
|
|
27
|
+
const hasDark = colorSchemes.includes("dark");
|
|
28
|
+
const hasLight = colorSchemes.includes("light");
|
|
29
|
+
if (hasDark !== hasLight) {
|
|
30
|
+
return hasDark ? "dark" : "light";
|
|
31
|
+
}
|
|
32
|
+
return elWindow.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
getCssColor,
|
|
36
|
+
getEffectiveColorScheme
|
|
37
|
+
};
|
package/dist/dom.d.ts
CHANGED
|
@@ -175,3 +175,12 @@ export interface FocusableElement extends HTMLElement {
|
|
|
175
175
|
export declare const setFocusOnElement: (ref: (Element & {
|
|
176
176
|
componentOnReady?: () => Promise<void>;
|
|
177
177
|
}) | null | undefined, selector: string) => void;
|
|
178
|
+
/**
|
|
179
|
+
* Get the window associated with an element's document.
|
|
180
|
+
* Falls back to the current global window if the document has no associated window.
|
|
181
|
+
*
|
|
182
|
+
* @public
|
|
183
|
+
* @param element The element whose document determines the window.
|
|
184
|
+
* @returns The element's document window, or the current global window as a fallback.
|
|
185
|
+
*/
|
|
186
|
+
export declare function getElementWindow(element: Element): Window;
|
package/dist/dom.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import "./dom/slots.js";
|
|
2
|
-
import { c, f, a, g,
|
|
2
|
+
import { c, f, b, a, g, d, o, e, s, h, i, j, k, l, m, n, u, p } from "./chunks/dom.js";
|
|
3
3
|
export {
|
|
4
4
|
c as classes,
|
|
5
5
|
f as focusElement,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
b as getClosestElement,
|
|
7
|
+
a as getElementAttribute,
|
|
8
|
+
g as getElementWindow,
|
|
9
|
+
d as getSlotAssignedElements,
|
|
9
10
|
o as observeAncestorsMutation,
|
|
10
|
-
|
|
11
|
+
e as resolveReferenceElement,
|
|
11
12
|
s as setFocusOnElement,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
h as slotChangeGetAssignedElements,
|
|
14
|
+
i as slotChangeGetAssignedNodes,
|
|
15
|
+
j as slotChangeGetTextContent,
|
|
16
|
+
k as slotChangeHasAssignedElement,
|
|
17
|
+
l as slotChangeHasAssignedNode,
|
|
18
|
+
m as slotChangeHasContent,
|
|
19
|
+
n as slotChangeHasTextContent,
|
|
19
20
|
u as unsafeGetCalciteModeName,
|
|
20
|
-
|
|
21
|
+
p as unsafeGetElementDirection
|
|
21
22
|
};
|
package/dist/intl/dom.d.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { type GenericT9nStrings, type SupportedLocale } from "../intl.ts";
|
|
2
2
|
/**
|
|
3
3
|
* Get the locale of the given element.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* The locale precedence order:
|
|
6
|
+
*
|
|
7
|
+
* 1. `lang` on the provided element
|
|
8
|
+
* 2. `lang` attribute on any parent DOM element (closest parent first)
|
|
9
|
+
* 3. Browser's default language (from [navigator.language](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language))
|
|
10
|
+
* 4. `en` as the default fallback
|
|
6
11
|
*
|
|
7
12
|
* @public
|
|
8
13
|
* @param element
|
|
9
14
|
* @returns an object with the `lang` and `t9nLocale` properties.
|
|
10
|
-
*
|
|
11
|
-
* @see [lang vs t9nLocale](https://webgis.esri.com/references/lumina/controllers/useT9n#difference-between-lang-and-t9nlocale).
|
|
15
|
+
* @see [lang vs t9nLocale](https://webgis.esri.com/references/lumina/controllers/useT9n#accessing-current-locale-information).
|
|
12
16
|
*/
|
|
13
17
|
export declare const getElementLocale: (element: HTMLElement) => {
|
|
14
18
|
readonly lang: string;
|
|
@@ -35,6 +39,8 @@ export declare const getElementLocale: (element: HTMLElement) => {
|
|
|
35
39
|
* Default file name is the element tag name without the part before the
|
|
36
40
|
* first dash (e.g. `arcgis-map` becomes `map`).
|
|
37
41
|
*
|
|
42
|
+
* Provide a custom asset name if `element` is not a web component.
|
|
43
|
+
*
|
|
38
44
|
* Set to null if the component has no localization strings, but you still
|
|
39
45
|
* wish to use `startLocaleObserver` to get the locale information.
|
|
40
46
|
*
|
package/dist/intl/dom.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { log } from "../log.js";
|
|
2
|
-
import {
|
|
2
|
+
import { a as getElementAttribute, o as observeAncestorsMutation } from "../chunks/dom.js";
|
|
3
3
|
const getElementLocale$1 = (element) => {
|
|
4
4
|
const lang = getElementAttribute(element, "lang", globalThis.navigator?.language || defaultLocale);
|
|
5
5
|
return { lang, t9nLocale: normalizeLocale(lang) };
|
package/dist/promise.d.ts
CHANGED
|
@@ -45,6 +45,14 @@ export interface Deferred<T> {
|
|
|
45
45
|
*/
|
|
46
46
|
reject(_error: unknown): void;
|
|
47
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Adds abort semantics to an existing promise. The input promise continues running after the signal aborts.
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
* @param promise The promise to race against the abort signal.
|
|
53
|
+
* @param signalOrOptions The signal that aborts the returned promise.
|
|
54
|
+
*/
|
|
55
|
+
export declare function whenOrAbort<T>(promise: Promise<T>, signalOrOptions: AbortOptions | AbortSignal | null | undefined): Promise<T>;
|
|
48
56
|
/**
|
|
49
57
|
* Execute async callbacks against a list with a fixed number of in-flight
|
|
50
58
|
* operations.
|
|
@@ -73,3 +81,7 @@ export declare function forEachWithConcurrency<T>(items: readonly T[], concurren
|
|
|
73
81
|
* @see https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/60405
|
|
74
82
|
*/
|
|
75
83
|
export declare const devToolsAwareTimeout: (callback: () => void, timeout: number) => ReturnType<typeof setInterval>;
|
|
84
|
+
interface AbortOptions {
|
|
85
|
+
signal?: AbortSignal | null | undefined;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
package/dist/promise.js
CHANGED
|
@@ -11,6 +11,23 @@ class Deferred {
|
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
async function whenOrAbort(promise, signalOrOptions) {
|
|
15
|
+
const signal = signalFromSignalOrOptions(signalOrOptions);
|
|
16
|
+
if (!signal) {
|
|
17
|
+
return await promise;
|
|
18
|
+
}
|
|
19
|
+
signal.throwIfAborted();
|
|
20
|
+
const abort = Promise.withResolvers();
|
|
21
|
+
const onAbort = () => {
|
|
22
|
+
try {
|
|
23
|
+
signal.throwIfAborted();
|
|
24
|
+
} catch (error) {
|
|
25
|
+
abort.reject(error);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
29
|
+
return await Promise.race([promise, abort.promise]).finally(() => signal.removeEventListener("abort", onAbort));
|
|
30
|
+
}
|
|
14
31
|
async function forEachWithConcurrency(items, concurrency, callback) {
|
|
15
32
|
if (items.length === 0) {
|
|
16
33
|
return;
|
|
@@ -40,8 +57,12 @@ const devToolsAwareTimeout = (callback, timeout) => {
|
|
|
40
57
|
const longTimeoutThreshold = 4e3;
|
|
41
58
|
const longTimeoutInterval = 2e3;
|
|
42
59
|
const shortTimeoutIntervals = 4;
|
|
60
|
+
function signalFromSignalOrOptions(params) {
|
|
61
|
+
return params instanceof AbortSignal ? params : params?.signal ?? void 0;
|
|
62
|
+
}
|
|
43
63
|
export {
|
|
44
64
|
Deferred,
|
|
45
65
|
devToolsAwareTimeout,
|
|
46
|
-
forEachWithConcurrency
|
|
66
|
+
forEachWithConcurrency,
|
|
67
|
+
whenOrAbort
|
|
47
68
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/toolkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.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,
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"exports": {
|
|
9
9
|
"./array": "./dist/array.js",
|
|
10
10
|
"./dom": "./dist/dom.js",
|
|
11
|
+
"./dom/color": "./dist/dom/color.js",
|
|
11
12
|
"./dom/slots": "./dist/dom/slots.js",
|
|
12
13
|
"./dom/referenceElement": "./dist/dom/referenceElement.js",
|
|
13
14
|
"./error": "./dist/error.js",
|