@arcgis/toolkit 5.2.0-next.14 → 5.2.0-next.141
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 +4 -2
- package/README.md +2 -2
- package/dist/{array/index.d.ts → array.d.ts} +4 -1
- package/dist/{dom/index.js → chunks/dom.js} +34 -48
- package/dist/dom/color.d.ts +56 -0
- package/dist/dom/color.js +37 -0
- package/dist/dom/referenceElement.d.ts +17 -0
- package/dist/dom/referenceElement.js +5 -0
- package/dist/dom/slots.d.ts +8 -0
- package/dist/dom/slots.js +39 -0
- package/dist/dom.d.ts +186 -0
- package/dist/dom.js +22 -0
- package/dist/{error/index.d.ts → error.d.ts} +15 -4
- package/dist/{error/index.js → error.js} +1 -1
- package/dist/{function/index.d.ts → function.d.ts} +4 -1
- package/dist/intl/dom.d.ts +80 -0
- package/dist/intl/{index.js → dom.js} +40 -36
- package/dist/intl.d.ts +89 -0
- package/dist/intl.js +10 -0
- package/dist/{log/index.d.ts → log.d.ts} +38 -6
- package/dist/{number/index.d.ts → number.d.ts} +2 -1
- package/dist/predicate.d.ts +27 -0
- package/dist/predicate.js +8 -0
- package/dist/{promise/index.d.ts → promise.d.ts} +28 -1
- package/dist/{promise/index.js → promise.js} +24 -1
- package/dist/{string/index.d.ts → string.d.ts} +40 -3
- package/dist/{type/index.d.ts → type.d.ts} +11 -1
- package/dist/{url/index.d.ts → url.d.ts} +4 -3
- package/package.json +17 -13
- package/dist/dom/index.d.ts +0 -117
- package/dist/dom/reference-element.d.ts +0 -6
- package/dist/intl/index.d.ts +0 -124
- package/dist/predicate/index.d.ts +0 -24
- package/dist/predicate/index.js +0 -8
- /package/dist/{array/index.js → array.js} +0 -0
- /package/dist/{function/index.js → function.js} +0 -0
- /package/dist/{log/index.js → log.js} +0 -0
- /package/dist/{number/index.js → number.js} +0 -0
- /package/dist/{string/index.js → string.js} +0 -0
- /package/dist/{type/index.js → type.js} +0 -0
- /package/dist/{url/index.js → url.js} +0 -0
package/LICENSE.md
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# Licensing
|
|
2
2
|
|
|
3
|
-
COPYRIGHT
|
|
3
|
+
COPYRIGHT Esri
|
|
4
4
|
|
|
5
5
|
All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
|
|
6
6
|
|
|
7
|
-
This material is licensed for use under the
|
|
7
|
+
This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement.
|
|
8
8
|
You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
|
|
9
9
|
|
|
10
|
+
See use restrictions at https://www.esri.com/content/dam/esrisites/en-us/media/legal/ma-full/ma-full.pdf.
|
|
11
|
+
|
|
10
12
|
For additional information, contact:
|
|
11
13
|
Environmental Systems Research Institute, Inc.
|
|
12
14
|
Attn: Contracts and Legal Services Department
|
package/README.md
CHANGED
|
@@ -8,5 +8,5 @@ It is not intended to be used directly, but rather used as a dependency by other
|
|
|
8
8
|
|
|
9
9
|
## License
|
|
10
10
|
|
|
11
|
-
This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package, and at https://js.arcgis.com/5.
|
|
12
|
-
For third party notices, see https://js.arcgis.com/5.
|
|
11
|
+
This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package, and at https://js.arcgis.com/5.2/LICENSE.txt.
|
|
12
|
+
For third party notices, see https://js.arcgis.com/5.2/third-party-notices.txt.
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { nil } from
|
|
1
|
+
import type { nil } from "./type.ts";
|
|
2
2
|
/**
|
|
3
3
|
* A combination of map and find.
|
|
4
4
|
* Find a value in an array, and return its mapped variant.
|
|
5
5
|
*
|
|
6
|
+
* @public
|
|
7
|
+
* @param array
|
|
8
|
+
* @param callback
|
|
6
9
|
* @example
|
|
7
10
|
* ```ts
|
|
8
11
|
* // Given array of url strings, return the first valid URL object.
|
|
@@ -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) {
|
|
@@ -206,22 +187,27 @@ const setFocus = (ref, selector = "") => {
|
|
|
206
187
|
}
|
|
207
188
|
return false;
|
|
208
189
|
};
|
|
190
|
+
function getElementWindow(element) {
|
|
191
|
+
return element.ownerDocument.defaultView || window;
|
|
192
|
+
}
|
|
209
193
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
194
|
+
getElementAttribute as a,
|
|
195
|
+
getClosestElement as b,
|
|
196
|
+
classes as c,
|
|
197
|
+
getSlotAssignedElements as d,
|
|
198
|
+
resolveReferenceElement as e,
|
|
199
|
+
focusElement as f,
|
|
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,
|
|
208
|
+
observeAncestorsMutation as o,
|
|
209
|
+
unsafeGetElementDirection as p,
|
|
210
|
+
resolveReferenceElement$1 as r,
|
|
211
|
+
setFocusOnElement as s,
|
|
212
|
+
unsafeGetCalciteModeName as u
|
|
227
213
|
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** @public */
|
|
2
|
+
interface ArcgisComponentBase<T> {
|
|
3
|
+
/** @public */
|
|
4
|
+
el: HTMLElement;
|
|
5
|
+
/** @public */
|
|
6
|
+
referenceElement?: T | string | null | undefined;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves a reference element (arcgis-map, arcgis-scene, arcgis-link-chart)
|
|
10
|
+
* from a component's `referenceElement` property or attribute.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
* @param component
|
|
14
|
+
* @param referenceElementString
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveReferenceElement<T extends Element>(component: ArcgisComponentBase<T>, referenceElementString?: ArcgisComponentBase<T>["referenceElement"] | string): T | undefined;
|
|
17
|
+
export {};
|
package/dist/dom/slots.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns `true` if the target `slot` element from the `onSlotchange` event has any content (text or elements).
|
|
3
3
|
*
|
|
4
|
+
* @public
|
|
4
5
|
* @param event The event.
|
|
5
6
|
* @returns Whether the slot has any content.
|
|
6
7
|
*
|
|
@@ -13,6 +14,7 @@ export declare function slotChangeHasContent(event: Event): boolean;
|
|
|
13
14
|
/**
|
|
14
15
|
* Returns a string of textContent if the target `slot` element from the `onSlotchange` event has any text content.
|
|
15
16
|
*
|
|
17
|
+
* @public
|
|
16
18
|
* @param event The event.
|
|
17
19
|
* @returns The slots text.
|
|
18
20
|
*
|
|
@@ -25,6 +27,7 @@ export declare function slotChangeGetTextContent(event: Event): string;
|
|
|
25
27
|
/**
|
|
26
28
|
* Returns `true` if the target `slot` element from the `onSlotchange` event has any text content.
|
|
27
29
|
*
|
|
30
|
+
* @public
|
|
28
31
|
* @param event The event.
|
|
29
32
|
* @returns Whether the slot has any text content.
|
|
30
33
|
*
|
|
@@ -37,6 +40,7 @@ export declare function slotChangeHasTextContent(event: Event): boolean;
|
|
|
37
40
|
/**
|
|
38
41
|
* Returns `true` if the target `slot` element from the `onSlotchange` event has an assigned node.
|
|
39
42
|
*
|
|
43
|
+
* @public
|
|
40
44
|
* @param event The event.
|
|
41
45
|
* @returns Whether the slot has any assigned nodes.
|
|
42
46
|
*
|
|
@@ -49,6 +53,7 @@ export declare function slotChangeHasAssignedNode(event: Event): boolean;
|
|
|
49
53
|
/**
|
|
50
54
|
* Returns the assigned nodes on a `slot` element from the `onSlotchange` event.
|
|
51
55
|
*
|
|
56
|
+
* @public
|
|
52
57
|
* @param event The event.
|
|
53
58
|
* @returns Whether the slot has any assigned nodes.
|
|
54
59
|
*
|
|
@@ -61,6 +66,7 @@ export declare function slotChangeGetAssignedNodes(event: Event): Node[];
|
|
|
61
66
|
/**
|
|
62
67
|
* Returns `true` if the target `slot` element from the `onSlotchange` event has an assigned element.
|
|
63
68
|
*
|
|
69
|
+
* @public
|
|
64
70
|
* @param event The event.
|
|
65
71
|
* @returns Whether the slot has any assigned elements.
|
|
66
72
|
*
|
|
@@ -73,6 +79,7 @@ export declare function slotChangeHasAssignedElement(event: Event): boolean;
|
|
|
73
79
|
/**
|
|
74
80
|
* Returns the assigned elements on a `slot` element from the `onSlotchange` event.
|
|
75
81
|
*
|
|
82
|
+
* @public
|
|
76
83
|
* @param event The event.
|
|
77
84
|
* @param selector The CSS selector string to filter the returned elements by.
|
|
78
85
|
* @returns An array of elements.
|
|
@@ -86,6 +93,7 @@ export declare function slotChangeGetAssignedElements<T extends Element>(event:
|
|
|
86
93
|
/**
|
|
87
94
|
* Returns the assigned elements on a `slot` element, filtered by an optional css selector.
|
|
88
95
|
*
|
|
96
|
+
* @public
|
|
89
97
|
* @param slot The slot element.
|
|
90
98
|
* @param selector CSS selector string to filter the returned elements by.
|
|
91
99
|
* @returns An array of elements.
|
|
@@ -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
|
+
};
|
package/dist/dom.d.ts
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { 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
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* @deprecated import { slotChangeHasContent } from "@arcgis/toolkit/dom/slots"; instead
|
|
6
|
+
* */
|
|
7
|
+
export declare const slotChangeHasContent: typeof slotChangeHasContentAlias;
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
* @deprecated import { slotChangeGetTextContent } from "@arcgis/toolkit/dom/slots"; instead
|
|
11
|
+
*/
|
|
12
|
+
export declare const slotChangeGetTextContent: typeof slotChangeGetTextContentAlias;
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
* @deprecated import { slotChangeHasTextContent } from "@arcgis/toolkit/dom/slots"; instead
|
|
16
|
+
*/
|
|
17
|
+
export declare const slotChangeHasTextContent: typeof slotChangeHasTextContentAlias;
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
* @deprecated import { slotChangeHasAssignedNode } from "@arcgis/toolkit/dom/slots"; instead
|
|
21
|
+
*/
|
|
22
|
+
export declare const slotChangeHasAssignedNode: typeof slotChangeHasAssignedNodeAlias;
|
|
23
|
+
/**
|
|
24
|
+
* @public
|
|
25
|
+
* @deprecated import { slotChangeGetAssignedNodes } from "@arcgis/toolkit/dom/slots"; instead
|
|
26
|
+
*/
|
|
27
|
+
export declare const slotChangeGetAssignedNodes: typeof slotChangeGetAssignedNodesAlias;
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
* @deprecated import { slotChangeHasAssignedElement } from "@arcgis/toolkit/dom/slots"; instead
|
|
31
|
+
*/
|
|
32
|
+
export declare const slotChangeHasAssignedElement: typeof slotChangeHasAssignedElementAlias;
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
* @deprecated import { slotChangeGetAssignedElements } from "@arcgis/toolkit/dom/slots"; instead
|
|
36
|
+
*/
|
|
37
|
+
export declare const slotChangeGetAssignedElements: typeof slotChangeGetAssignedElementsAlias;
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
* @deprecated import { getSlotAssignedElements } from "@arcgis/toolkit/dom/slots"; instead
|
|
41
|
+
*/
|
|
42
|
+
export declare const getSlotAssignedElements: typeof getSlotAssignedElementsAlias;
|
|
43
|
+
import { resolveReferenceElement as resolveReferenceElementAlias } from "./dom/referenceElement.ts";
|
|
44
|
+
/**
|
|
45
|
+
* @public
|
|
46
|
+
* @deprecated import { resolveReferenceElement } from "@arcgis/toolkit/dom/reference-element"; instead
|
|
47
|
+
*/
|
|
48
|
+
export declare const resolveReferenceElement: typeof resolveReferenceElementAlias;
|
|
49
|
+
/**
|
|
50
|
+
* Combine multiple class names into a single string.
|
|
51
|
+
*
|
|
52
|
+
* > This function is less necessary in Lumina packages as the `class` JSX prop
|
|
53
|
+
* > accepts `Record<string, boolean>` objects.
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
* @param classes
|
|
57
|
+
*/
|
|
58
|
+
export declare const classes: (...classes: (nil | Record<string, boolean> | string[] | string | false)[]) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Observe the element and its ancestors for attribute mutations.
|
|
61
|
+
* If the attributes have been changed in the ancestor tree then the callback
|
|
62
|
+
* will be invoked.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @param element The element on which to observe the attribute mutations.
|
|
66
|
+
* @param attributeFilter The list of attributes to observe.
|
|
67
|
+
* @param callback The callback to invoke when the attributes have been changed.
|
|
68
|
+
* @returns A callback to unsubscribe from the observer.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* observeAncestorsMutation(
|
|
73
|
+
* element,
|
|
74
|
+
* ["dir", "lang"],
|
|
75
|
+
* () => console.log(getElementAttribute(element, "dir", "ltr"))
|
|
76
|
+
* );
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export declare const observeAncestorsMutation: (element: Node, attributeFilter: string[], callback: () => void) => (() => void);
|
|
80
|
+
/**
|
|
81
|
+
* Find the closest element that matches the selector.
|
|
82
|
+
* It will traverse the element's ancestors to find the target element.
|
|
83
|
+
* Shadow DOM boundaries are also taken into account.
|
|
84
|
+
*
|
|
85
|
+
* > This is similar to [Element.closest()](https://developer.mozilla.org/docs/Web/API/Element/closest),
|
|
86
|
+
* > but the DOM's utility only looks up until the first shadow boundary.
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
* @param base The element to start the search from.
|
|
90
|
+
* @param selector The selector to match.
|
|
91
|
+
* @returns The closest element that matches the selector or null if not found.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* const hostElement = getClosestElement(element, "arcgis-map, arcgis-scene");
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare const getClosestElement: <T = Element>(base: Element, selector: string) => T | undefined;
|
|
99
|
+
/**
|
|
100
|
+
* Use the closest Calcite mode class name to determine the
|
|
101
|
+
* theme of the element. It will traverse the element's
|
|
102
|
+
* ancestors to find the theme. Shadow DOM boundaries are also
|
|
103
|
+
* taken into account.
|
|
104
|
+
*
|
|
105
|
+
* > It is advised to consider alternative solutions before using this utility:
|
|
106
|
+
* > - Calcite CSS variables. Benefits: makes styles more consistent,
|
|
107
|
+
* > and variables are updated automatically to match dark/light theme.
|
|
108
|
+
* > - Detect dark mode using CSS selectors and apply styles in CSS.
|
|
109
|
+
* > Benefit: styles update automatically when the theme changes.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
* @param el The element to start the search from.
|
|
113
|
+
* @returns The theme of the element ("light" or "dark"). "light" is the default.
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
export declare function unsafeGetCalciteModeName(el: HTMLElement): "dark" | "light";
|
|
117
|
+
/**
|
|
118
|
+
* Get direction property of the closest element.
|
|
119
|
+
*
|
|
120
|
+
* > Do not set the `dir` property on the element itself. Do not set the `dir`
|
|
121
|
+
* > attribute on the components you are rendering. The `dir` attribute is only
|
|
122
|
+
* > meant to be set by the consumers of your component. Your component is
|
|
123
|
+
* > expected to respect what was set by the consumer.
|
|
124
|
+
*
|
|
125
|
+
* > Prefer [useDirection()](https://webgis.esri.com/references/lumina/controllers/useDirection)
|
|
126
|
+
* > to ensure your component is responsive to direction changes.
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @param el The element to start the search from.
|
|
130
|
+
* @returns The direction of the element ("ltr" | "rtl"). "ltr" is the default.
|
|
131
|
+
*/
|
|
132
|
+
export declare const unsafeGetElementDirection: (el: HTMLElement) => "ltr" | "rtl";
|
|
133
|
+
/**
|
|
134
|
+
* Get the attribute value from the element or closest ancestor.
|
|
135
|
+
* Shadow DOM boundaries are also taken into account.
|
|
136
|
+
* If the attribute is not found then the fallback value is returned.
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
* @param el
|
|
140
|
+
* @param attributeName
|
|
141
|
+
* @param fallbackValue
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const dir = getElementAttribute(element, "dir", "ltr");
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
export declare const getElementAttribute: (el: Element, attributeName: string, fallbackValue: string) => string;
|
|
148
|
+
/**
|
|
149
|
+
* Focus the element if it is focusable.
|
|
150
|
+
*
|
|
151
|
+
* @public
|
|
152
|
+
* @param el
|
|
153
|
+
* @returns A promise that resolves once the focus is set.
|
|
154
|
+
*/
|
|
155
|
+
export declare const focusElement: (el: FocusableElement | undefined) => Promise<void>;
|
|
156
|
+
/** @public */
|
|
157
|
+
export interface FocusableElement extends HTMLElement {
|
|
158
|
+
/** @public */
|
|
159
|
+
setFocus?: () => Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Set the focus on the element that matches the selector.
|
|
163
|
+
* It will traverse the element's ancestors to find the target element.
|
|
164
|
+
* Shadow DOM boundaries are also taken into account.
|
|
165
|
+
* If the element is not found then the focus is not set.
|
|
166
|
+
* Example: `setFocusOnElement(element, "[role='menuitem']");`
|
|
167
|
+
*
|
|
168
|
+
* @public
|
|
169
|
+
* @param ref The element to start the search from.
|
|
170
|
+
* @param selector The selector to match.
|
|
171
|
+
* @returns Returns true if the focus is set on the element.
|
|
172
|
+
*
|
|
173
|
+
* @deprecated This function is doing too much. Import from `focusElement(getClosestElement())` from `@arcgis/toolkit/dom` instead.
|
|
174
|
+
*/
|
|
175
|
+
export declare const setFocusOnElement: (ref: (Element & {
|
|
176
|
+
componentOnReady?: () => Promise<void>;
|
|
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
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "./dom/slots.js";
|
|
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
|
+
export {
|
|
4
|
+
c as classes,
|
|
5
|
+
f as focusElement,
|
|
6
|
+
b as getClosestElement,
|
|
7
|
+
a as getElementAttribute,
|
|
8
|
+
g as getElementWindow,
|
|
9
|
+
d as getSlotAssignedElements,
|
|
10
|
+
o as observeAncestorsMutation,
|
|
11
|
+
e as resolveReferenceElement,
|
|
12
|
+
s as setFocusOnElement,
|
|
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,
|
|
20
|
+
u as unsafeGetCalciteModeName,
|
|
21
|
+
p as unsafeGetElementDirection
|
|
22
|
+
};
|
|
@@ -10,23 +10,34 @@
|
|
|
10
10
|
* - `process.env.NODE_ENV === "development"`
|
|
11
11
|
* - `process.env.NODE_ENV === "test"`
|
|
12
12
|
*
|
|
13
|
+
* > This function is primary for usage in support packages. In Lumina component
|
|
14
|
+
* > packages, simpler alternatives are provided:
|
|
15
|
+
* > https://webgis.esri.com/references/lumina/publishing#bundling-code-conditionally
|
|
16
|
+
*
|
|
13
17
|
* [Documentation](https://webgis.esri.com/references/lumina/publishing#internal-esri-environment)
|
|
14
18
|
*
|
|
15
|
-
* @
|
|
16
|
-
* This function is primary for usage in support packages. In Lumina component
|
|
17
|
-
* packages, simpler alternatives are provided:
|
|
18
|
-
* https://webgis.esri.com/references/lumina/publishing#bundling-code-conditionally
|
|
19
|
+
* @public
|
|
19
20
|
*/
|
|
20
21
|
export declare const isEsriInternalEnv: () => boolean;
|
|
21
22
|
/**
|
|
22
23
|
* Calls a sync method and catch any errors. Returns undefined if error occurred.
|
|
23
24
|
*
|
|
24
25
|
* Can also provide a thisContext and rest arguments
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @param callback
|
|
29
|
+
* @param thisContext
|
|
30
|
+
* @param rest
|
|
25
31
|
*/
|
|
26
32
|
export declare const safeCall: <Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>) => ReturnType<Callback> | void;
|
|
27
33
|
/**
|
|
28
34
|
* Calls an async method and catch any errors. Returns undefined if error occurred.
|
|
29
35
|
*
|
|
30
36
|
* Can also provide a thisContext and rest arguments
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @param callback
|
|
40
|
+
* @param thisContext
|
|
41
|
+
* @param rest
|
|
31
42
|
*/
|
|
32
43
|
export declare const safeAsyncCall: <Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>) => Promise<Awaited<ReturnType<Callback>> | void>;
|
|
@@ -8,7 +8,7 @@ const isEsriInternalEnv = () => (
|
|
|
8
8
|
* This does meant tree-shaking won't happen for the isEsriInternalEnv()
|
|
9
9
|
* check, but this is ok since this check is meant to always be behind the
|
|
10
10
|
* development/test guard.
|
|
11
|
-
* See https://devtopia.esri.com/WebGIS/
|
|
11
|
+
* See https://devtopia.esri.com/WebGIS/webgis-sdk/pull/2087#issuecomment-5152454
|
|
12
12
|
*/
|
|
13
13
|
typeof globalThis.process === "object" && !!process.env.ESRI_INTERNAL
|
|
14
14
|
);
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
* Useful when providing a "mapping function" is required, but you have no need
|
|
5
5
|
* to change the value
|
|
6
6
|
*
|
|
7
|
+
* @public
|
|
8
|
+
* @param value
|
|
7
9
|
* @privateRemarks
|
|
8
10
|
* This is a trivial function, but it helps workaround a TypeScript bug:
|
|
9
|
-
* https://devtopia.esri.com/WebGIS/
|
|
11
|
+
* https://devtopia.esri.com/WebGIS/webgis-sdk/issues/2047
|
|
10
12
|
*/
|
|
11
13
|
export declare const identity: <T>(value: T) => T;
|
|
12
14
|
/**
|
|
13
15
|
* Allows to debounce a function.
|
|
14
16
|
*
|
|
17
|
+
* @public
|
|
15
18
|
* @param func Function to be debounced
|
|
16
19
|
* @param waitFor Debounce time in milliseconds
|
|
17
20
|
* @returns Returns a function that can be called to debounce the original function
|