@arcgis/toolkit 5.2.0-next.1 → 5.2.0-next.10
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/intl/index.js +1 -1
- package/package.json +13 -61
- package/dist/array/index.cjs +0 -13
- package/dist/array/index.d.cts +0 -12
- package/dist/dom/index.cjs +0 -227
- package/dist/dom/index.d.cts +0 -117
- package/dist/dom/reference-element.d.cts +0 -6
- package/dist/dom/slots.d.cts +0 -93
- package/dist/error/index.cjs +0 -36
- package/dist/error/index.d.cts +0 -32
- package/dist/function/index.cjs +0 -16
- package/dist/function/index.d.cts +0 -19
- package/dist/intl/index.cjs +0 -110
- package/dist/intl/index.d.cts +0 -124
- package/dist/log/index.cjs +0 -81
- package/dist/log/index.d.cts +0 -128
- package/dist/number/index.cjs +0 -10
- package/dist/number/index.d.cts +0 -19
- package/dist/predicate/index.cjs +0 -8
- package/dist/predicate/index.d.cts +0 -24
- package/dist/promise/index.cjs +0 -45
- package/dist/promise/index.d.cts +0 -60
- package/dist/string/index.cjs +0 -117
- package/dist/string/index.d.cts +0 -130
- package/dist/tests/utils.d.cts +0 -1
- package/dist/type/index.cjs +0 -4
- package/dist/type/index.d.cts +0 -29
- package/dist/url/index.cjs +0 -26
- package/dist/url/index.d.cts +0 -18
package/dist/intl/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const localeEquivalencies = {
|
|
|
26
26
|
const fetchT9nStringsBundle = async (locale, assetsPath, prefix = "") => {
|
|
27
27
|
const path = `${assetsPath}/${prefix}`;
|
|
28
28
|
const filePath = `${path}${locale}.json`;
|
|
29
|
-
t9nStringsCache[filePath]
|
|
29
|
+
t9nStringsCache[filePath] ??= fetchBundle(locale, path);
|
|
30
30
|
return await t9nStringsCache[filePath];
|
|
31
31
|
};
|
|
32
32
|
const t9nStringsCache = {};
|
package/package.json
CHANGED
|
@@ -1,71 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/toolkit",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.10",
|
|
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":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"./
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"./
|
|
20
|
-
|
|
21
|
-
"import": "./dist/error/index.js",
|
|
22
|
-
"require": "./dist/error/index.cjs"
|
|
23
|
-
},
|
|
24
|
-
"./function": {
|
|
25
|
-
"types": "./dist/function/index.d.ts",
|
|
26
|
-
"import": "./dist/function/index.js",
|
|
27
|
-
"require": "./dist/function/index.cjs"
|
|
28
|
-
},
|
|
29
|
-
"./intl": {
|
|
30
|
-
"types": "./dist/intl/index.d.ts",
|
|
31
|
-
"import": "./dist/intl/index.js",
|
|
32
|
-
"require": "./dist/intl/index.cjs"
|
|
33
|
-
},
|
|
34
|
-
"./log": {
|
|
35
|
-
"types": "./dist/log/index.d.ts",
|
|
36
|
-
"import": "./dist/log/index.js",
|
|
37
|
-
"require": "./dist/log/index.cjs"
|
|
38
|
-
},
|
|
39
|
-
"./number": {
|
|
40
|
-
"types": "./dist/number/index.d.ts",
|
|
41
|
-
"import": "./dist/number/index.js",
|
|
42
|
-
"require": "./dist/number/index.cjs"
|
|
43
|
-
},
|
|
44
|
-
"./predicate": {
|
|
45
|
-
"types": "./dist/predicate/index.d.ts",
|
|
46
|
-
"import": "./dist/predicate/index.js",
|
|
47
|
-
"require": "./dist/predicate/index.cjs"
|
|
48
|
-
},
|
|
49
|
-
"./promise": {
|
|
50
|
-
"types": "./dist/promise/index.d.ts",
|
|
51
|
-
"import": "./dist/promise/index.js",
|
|
52
|
-
"require": "./dist/promise/index.cjs"
|
|
53
|
-
},
|
|
54
|
-
"./string": {
|
|
55
|
-
"types": "./dist/string/index.d.ts",
|
|
56
|
-
"import": "./dist/string/index.js",
|
|
57
|
-
"require": "./dist/string/index.cjs"
|
|
58
|
-
},
|
|
59
|
-
"./type": {
|
|
60
|
-
"types": "./dist/type/index.d.ts",
|
|
61
|
-
"import": "./dist/type/index.js",
|
|
62
|
-
"require": "./dist/type/index.cjs"
|
|
63
|
-
},
|
|
64
|
-
"./url": {
|
|
65
|
-
"types": "./dist/url/index.d.ts",
|
|
66
|
-
"import": "./dist/url/index.js",
|
|
67
|
-
"require": "./dist/url/index.cjs"
|
|
68
|
-
},
|
|
9
|
+
"./array": "./dist/array/index.js",
|
|
10
|
+
"./dom": "./dist/dom/index.js",
|
|
11
|
+
"./error": "./dist/error/index.js",
|
|
12
|
+
"./function": "./dist/function/index.js",
|
|
13
|
+
"./intl": "./dist/intl/index.js",
|
|
14
|
+
"./log": "./dist/log/index.js",
|
|
15
|
+
"./number": "./dist/number/index.js",
|
|
16
|
+
"./predicate": "./dist/predicate/index.js",
|
|
17
|
+
"./promise": "./dist/promise/index.js",
|
|
18
|
+
"./string": "./dist/string/index.js",
|
|
19
|
+
"./type": "./dist/type/index.js",
|
|
20
|
+
"./url": "./dist/url/index.js",
|
|
69
21
|
"./package.json": "./package.json"
|
|
70
22
|
},
|
|
71
23
|
"files": [
|
package/dist/array/index.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const mappedFind = (array, callback) => {
|
|
4
|
-
const length = array.length;
|
|
5
|
-
for (let i = 0; i < length; ++i) {
|
|
6
|
-
const value = callback(array[i], i);
|
|
7
|
-
if (value != null) {
|
|
8
|
-
return value ?? void 0;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return;
|
|
12
|
-
};
|
|
13
|
-
exports.mappedFind = mappedFind;
|
package/dist/array/index.d.cts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { nil } from '../type/index.ts';
|
|
2
|
-
/**
|
|
3
|
-
* A combination of map and find.
|
|
4
|
-
* Find a value in an array, and return its mapped variant.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* // Given array of url strings, return the first valid URL object.
|
|
9
|
-
* const url = mappedFind(urlsStrings, (url) => URL.parse(url));
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare const mappedFind: <Item, ReturnType>(array: readonly Item[], callback: (item: Item, index: number) => nil | ReturnType) => ReturnType | undefined;
|
package/dist/dom/index.cjs
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const log_index = require("../log/index.cjs");
|
|
4
|
-
function slotChangeHasContent(event) {
|
|
5
|
-
return slotChangeHasAssignedElement(event) || slotChangeHasTextContent(event);
|
|
6
|
-
}
|
|
7
|
-
function slotChangeGetTextContent(event) {
|
|
8
|
-
return slotChangeGetAssignedNodes(event).filter((node) => node.nodeType === Node.TEXT_NODE).map((node) => node.textContent).join("").trim();
|
|
9
|
-
}
|
|
10
|
-
function slotChangeHasTextContent(event) {
|
|
11
|
-
return slotChangeGetTextContent(event).length > 0;
|
|
12
|
-
}
|
|
13
|
-
function slotChangeHasAssignedNode(event) {
|
|
14
|
-
return slotChangeGetAssignedNodes(event).length > 0;
|
|
15
|
-
}
|
|
16
|
-
function slotChangeGetAssignedNodes(event) {
|
|
17
|
-
return event.currentTarget.assignedNodes({
|
|
18
|
-
flatten: true
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function slotChangeHasAssignedElement(event) {
|
|
22
|
-
return slotChangeGetAssignedElements(event).length > 0;
|
|
23
|
-
}
|
|
24
|
-
function slotChangeGetAssignedElements(event, selector) {
|
|
25
|
-
return getSlotAssignedElements(event.target, selector);
|
|
26
|
-
}
|
|
27
|
-
function getSlotAssignedElements(slot, selector) {
|
|
28
|
-
const assignedElements = slot.assignedElements({
|
|
29
|
-
flatten: true
|
|
30
|
-
});
|
|
31
|
-
return selector ? assignedElements.filter((element) => element.matches(selector)) : assignedElements;
|
|
32
|
-
}
|
|
33
|
-
const allowedTags = ["arcgis-map", "arcgis-scene", "arcgis-link-chart"];
|
|
34
|
-
function resolveReferenceElement(component, referenceElementString) {
|
|
35
|
-
const referenceElement = referenceElementString ?? component.referenceElement;
|
|
36
|
-
if (typeof referenceElement !== "string") {
|
|
37
|
-
return referenceElement ?? void 0;
|
|
38
|
-
}
|
|
39
|
-
const isComplexSelector = referenceElement.includes("#") || referenceElement.includes(".") || referenceElement.includes("[");
|
|
40
|
-
const rootNode = component.el.getRootNode();
|
|
41
|
-
const resolved = (isComplexSelector ? void 0 : rootNode.querySelector(`#${referenceElement}`)) ?? rootNode.querySelector(referenceElement) ?? (isComplexSelector ? void 0 : getClosestElement(component.el, `#${referenceElement}`)) ?? getClosestElement(component.el, referenceElement);
|
|
42
|
-
if (resolved == null) {
|
|
43
|
-
log_index.log(
|
|
44
|
-
"error",
|
|
45
|
-
component,
|
|
46
|
-
`Expected property \`referenceElement\` to resolve to an <arcgis-map>, <arcgis-scene>, or <arcgis-link-chart> element, but no element matched \`${referenceElement}\`.`
|
|
47
|
-
);
|
|
48
|
-
return void 0;
|
|
49
|
-
}
|
|
50
|
-
if (!allowedTags.includes(resolved.localName)) {
|
|
51
|
-
log_index.log(
|
|
52
|
-
"error",
|
|
53
|
-
component,
|
|
54
|
-
`Expected property \`referenceElement\` to point to an <arcgis-map>, <arcgis-scene>, or <arcgis-link-chart> element, but instead found <${resolved?.localName}>.`,
|
|
55
|
-
{ detail: { referenceElement, resolved } }
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
return resolved ?? void 0;
|
|
59
|
-
}
|
|
60
|
-
const classes = (...classes2) => {
|
|
61
|
-
const effectiveClasses = [];
|
|
62
|
-
for (let i = 0; i < classes2.length; ++i) {
|
|
63
|
-
const arg = classes2[i];
|
|
64
|
-
if (typeof arg === "string") {
|
|
65
|
-
effectiveClasses.push(arg);
|
|
66
|
-
} else if (Array.isArray(arg)) {
|
|
67
|
-
effectiveClasses.push.apply(effectiveClasses, arg);
|
|
68
|
-
} else if (typeof arg === "object") {
|
|
69
|
-
for (const prop in arg) {
|
|
70
|
-
if (arg[prop]) {
|
|
71
|
-
effectiveClasses.push(prop);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
const className = effectiveClasses.join(" ");
|
|
77
|
-
effectiveClasses.length = 0;
|
|
78
|
-
return className;
|
|
79
|
-
};
|
|
80
|
-
const inTargetElement = (element, targetElement) => {
|
|
81
|
-
let currentElement = element;
|
|
82
|
-
while (currentElement) {
|
|
83
|
-
if (currentElement === targetElement) {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
if (!currentElement.parentNode) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
if (currentElement.parentNode instanceof ShadowRoot) {
|
|
90
|
-
currentElement = currentElement.parentNode.host;
|
|
91
|
-
} else {
|
|
92
|
-
currentElement = currentElement.parentNode;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
};
|
|
97
|
-
const observeAncestorsMutation = (element, attributeFilter, callback) => {
|
|
98
|
-
const subscribe = observe(attributeFilter).subscribe;
|
|
99
|
-
return subscribe((mutations) => {
|
|
100
|
-
const matched = mutations.some((mutation) => inTargetElement(element, mutation.target));
|
|
101
|
-
if (matched) {
|
|
102
|
-
callback();
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
const observers = {};
|
|
107
|
-
const observe = (attributeFilter) => {
|
|
108
|
-
const attributes = attributeFilter.join(",");
|
|
109
|
-
const previousObserver = observers[attributes];
|
|
110
|
-
if (previousObserver !== void 0) {
|
|
111
|
-
return previousObserver;
|
|
112
|
-
}
|
|
113
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
114
|
-
const mutationObserver = new MutationObserver((mutations) => subscribers.forEach((callback) => callback(mutations)));
|
|
115
|
-
if (globalThis.document) {
|
|
116
|
-
mutationObserver.observe(document.documentElement, {
|
|
117
|
-
attributes: true,
|
|
118
|
-
attributeFilter,
|
|
119
|
-
subtree: true
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
const observer = {
|
|
123
|
-
subscribe: (callback) => {
|
|
124
|
-
subscribers.add(callback);
|
|
125
|
-
return () => {
|
|
126
|
-
subscribers.delete(callback);
|
|
127
|
-
if (subscribers.size === 0) {
|
|
128
|
-
mutationObserver.disconnect();
|
|
129
|
-
observers[attributes] = void 0;
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
observers[attributes] = observer;
|
|
135
|
-
return observer;
|
|
136
|
-
};
|
|
137
|
-
const getClosestElement = (base, selector) => {
|
|
138
|
-
let currentElement = base;
|
|
139
|
-
while (currentElement) {
|
|
140
|
-
const element = currentElement.closest?.(selector);
|
|
141
|
-
if (element) {
|
|
142
|
-
return element;
|
|
143
|
-
}
|
|
144
|
-
const rootElement = currentElement.getRootNode?.();
|
|
145
|
-
if (rootElement === globalThis.document) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
currentElement = rootElement?.host;
|
|
149
|
-
}
|
|
150
|
-
return;
|
|
151
|
-
};
|
|
152
|
-
function unsafeGetCalciteModeName(el) {
|
|
153
|
-
const closestElWithMode = getClosestElement(el, `.calcite-mode-dark, .calcite-mode-light, .calcite-mode-auto`);
|
|
154
|
-
return closestElWithMode?.classList.contains("calcite-mode-dark") || closestElWithMode?.classList.contains("calcite-mode-auto") && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
155
|
-
}
|
|
156
|
-
const unsafeGetElementDirection = (el) => (
|
|
157
|
-
//#endregion unsafeGetElementDirection
|
|
158
|
-
getElementAttribute(el, "dir", "ltr")
|
|
159
|
-
);
|
|
160
|
-
const getElementAttribute = (el, attributeName, fallbackValue) => {
|
|
161
|
-
const closest = getClosestElement(el, `[${attributeName}]`);
|
|
162
|
-
return closest?.getAttribute(attributeName) ?? fallbackValue;
|
|
163
|
-
};
|
|
164
|
-
const focusElement = async (el) => {
|
|
165
|
-
if (el == null) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (hasSetFocus(el)) {
|
|
169
|
-
await el.setFocus();
|
|
170
|
-
} else {
|
|
171
|
-
el.focus();
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
const hasSetFocus = (ref) => typeof ref.setFocus === "function";
|
|
175
|
-
const setFocusOnElement = (ref, selector) => {
|
|
176
|
-
if (!ref?.shadowRoot) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
if (ref.hasAttribute("hydrated") || ref.hasAttribute("calcite-hydrated")) {
|
|
180
|
-
setFocus(ref, selector);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
void Promise.resolve(ref.componentOnReady?.()).then(() => setFocus(ref, selector));
|
|
184
|
-
};
|
|
185
|
-
const isElement = (ref) => ref.nodeType === Node.ELEMENT_NODE;
|
|
186
|
-
const setFocus = (ref, selector = "") => {
|
|
187
|
-
if (!isElement(ref)) {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
if (ref.matches(selector)) {
|
|
191
|
-
if (hasSetFocus(ref)) {
|
|
192
|
-
setTimeout(() => void ref.setFocus(), 0);
|
|
193
|
-
}
|
|
194
|
-
return true;
|
|
195
|
-
}
|
|
196
|
-
for (const child of ref.children) {
|
|
197
|
-
if (setFocus(child, selector)) {
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
const shadowRoot = ref.shadowRoot;
|
|
202
|
-
if (shadowRoot) {
|
|
203
|
-
for (const child of shadowRoot.children) {
|
|
204
|
-
if (setFocus(child, selector)) {
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return false;
|
|
210
|
-
};
|
|
211
|
-
exports.classes = classes;
|
|
212
|
-
exports.focusElement = focusElement;
|
|
213
|
-
exports.getClosestElement = getClosestElement;
|
|
214
|
-
exports.getElementAttribute = getElementAttribute;
|
|
215
|
-
exports.getSlotAssignedElements = getSlotAssignedElements;
|
|
216
|
-
exports.observeAncestorsMutation = observeAncestorsMutation;
|
|
217
|
-
exports.resolveReferenceElement = resolveReferenceElement;
|
|
218
|
-
exports.setFocusOnElement = setFocusOnElement;
|
|
219
|
-
exports.slotChangeGetAssignedElements = slotChangeGetAssignedElements;
|
|
220
|
-
exports.slotChangeGetAssignedNodes = slotChangeGetAssignedNodes;
|
|
221
|
-
exports.slotChangeGetTextContent = slotChangeGetTextContent;
|
|
222
|
-
exports.slotChangeHasAssignedElement = slotChangeHasAssignedElement;
|
|
223
|
-
exports.slotChangeHasAssignedNode = slotChangeHasAssignedNode;
|
|
224
|
-
exports.slotChangeHasContent = slotChangeHasContent;
|
|
225
|
-
exports.slotChangeHasTextContent = slotChangeHasTextContent;
|
|
226
|
-
exports.unsafeGetCalciteModeName = unsafeGetCalciteModeName;
|
|
227
|
-
exports.unsafeGetElementDirection = unsafeGetElementDirection;
|
package/dist/dom/index.d.cts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { nil } from '../type/index.ts';
|
|
2
|
-
export * from './slots.ts';
|
|
3
|
-
export * from './reference-element.ts';
|
|
4
|
-
/**
|
|
5
|
-
* Combine multiple class names into a single string.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* This function is less necessary in Lumina packages as the `class` JSX prop
|
|
9
|
-
* accepts `Record<string, boolean>` objects.
|
|
10
|
-
*/
|
|
11
|
-
export declare const classes: (...classes: (nil | Record<string, boolean> | string[] | string | false)[]) => string;
|
|
12
|
-
/**
|
|
13
|
-
* Observe the element and its ancestors for attribute mutations.
|
|
14
|
-
* If the attributes have been changed in the ancestor tree then the callback
|
|
15
|
-
* will be invoked.
|
|
16
|
-
*
|
|
17
|
-
* @param element The element on which to observe the attribute mutations.
|
|
18
|
-
* @param attributeFilter The list of attributes to observe.
|
|
19
|
-
* @param callback The callback to invoke when the attributes have been changed.
|
|
20
|
-
* @returns A callback to unsubscribe from the observer.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* observeAncestorsMutation(
|
|
25
|
-
* element,
|
|
26
|
-
* ["dir", "lang"],
|
|
27
|
-
* () => console.log(getElementAttribute(element, "dir", "ltr"))
|
|
28
|
-
* );
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export declare const observeAncestorsMutation: (element: Node, attributeFilter: string[], callback: () => void) => (() => void);
|
|
32
|
-
/**
|
|
33
|
-
* Find the closest element that matches the selector.
|
|
34
|
-
* It will traverse the element's ancestors to find the target element.
|
|
35
|
-
* Shadow DOM boundaries are also taken into account.
|
|
36
|
-
* @param base The element to start the search from.
|
|
37
|
-
* @param selector The selector to match.
|
|
38
|
-
* @returns The closest element that matches the selector or null if not found.
|
|
39
|
-
*
|
|
40
|
-
* @remarks
|
|
41
|
-
* This is similar to [Element.closest()](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest),
|
|
42
|
-
* but the DOM's utility only looks up until the first shadow boundary.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* const hostElement = getClosestElement(element, "arcgis-map, arcgis-scene");
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare const getClosestElement: <T = Element>(base: Element, selector: string) => T | undefined;
|
|
50
|
-
/**
|
|
51
|
-
* Use the closest Calcite mode class name to determine the
|
|
52
|
-
* theme of the element. It will traverse the element's
|
|
53
|
-
* ancestors to find the theme. Shadow DOM boundaries are also
|
|
54
|
-
* taken into account.
|
|
55
|
-
*
|
|
56
|
-
* @param base The element to start the search from.
|
|
57
|
-
* @returns The theme of the element ("light" or "dark"). "light" is the default.
|
|
58
|
-
*
|
|
59
|
-
* @remarks
|
|
60
|
-
* It is advised to consider alternative solutions before using this utility:
|
|
61
|
-
* - Calcite CSS variables. Benefits: makes styles more consistent,
|
|
62
|
-
* and variables are updated automatically to match dark/light theme.
|
|
63
|
-
* - Detect dark mode using CSS selectors and apply styles in CSS.
|
|
64
|
-
* Benefit: styles update automatically when the theme changes.
|
|
65
|
-
*/
|
|
66
|
-
export declare function unsafeGetCalciteModeName(el: HTMLElement): "dark" | "light";
|
|
67
|
-
/**
|
|
68
|
-
* Get direction property of the closest element.
|
|
69
|
-
*
|
|
70
|
-
* @param el The element to start the search from.
|
|
71
|
-
* @returns The direction of the element ("ltr" | "rtl"). "ltr" is the default.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* Do not set the `dir` property on the element itself. Do not set the `dir`
|
|
75
|
-
* attribute on the components you are rendering. The `dir` attribute is only
|
|
76
|
-
* meant to be set by the consumers of your component. Your component is
|
|
77
|
-
* expected to respect what was set by the consumer.
|
|
78
|
-
*
|
|
79
|
-
* @remarks
|
|
80
|
-
* Prefer [useDirection()](https://webgis.esri.com/references/lumina/controllers/useDirection)
|
|
81
|
-
* to ensure your component is responsive to direction changes.
|
|
82
|
-
*/
|
|
83
|
-
export declare const unsafeGetElementDirection: (el: HTMLElement) => "ltr" | "rtl";
|
|
84
|
-
/**
|
|
85
|
-
* Get the attribute value from the element or closest ancestor.
|
|
86
|
-
* Shadow DOM boundaries are also taken into account.
|
|
87
|
-
* If the attribute is not found then the fallback value is returned.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```ts
|
|
91
|
-
* const dir = getElementAttribute(element, "dir", "ltr");
|
|
92
|
-
* ```
|
|
93
|
-
*/
|
|
94
|
-
export declare const getElementAttribute: (el: Element, attributeName: string, fallbackValue: string) => string;
|
|
95
|
-
/**
|
|
96
|
-
* Focus the element if it is focusable.
|
|
97
|
-
* @returns A promise that resolves once the focus is set.
|
|
98
|
-
*/
|
|
99
|
-
export declare const focusElement: (el: FocusableElement | undefined) => Promise<void>;
|
|
100
|
-
export interface FocusableElement extends HTMLElement {
|
|
101
|
-
setFocus?: () => Promise<void>;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Set the focus on the element that matches the selector.
|
|
105
|
-
* It will traverse the element's ancestors to find the target element.
|
|
106
|
-
* Shadow DOM boundaries are also taken into account.
|
|
107
|
-
* If the element is not found then the focus is not set.
|
|
108
|
-
* Example: `setFocusOnElement(element, "[role='menuitem']");`
|
|
109
|
-
* @param ref The element to start the search from.
|
|
110
|
-
* @param selector The selector to match.
|
|
111
|
-
* @returns Returns true if the focus is set on the element.
|
|
112
|
-
*
|
|
113
|
-
* @deprecated This function is doing too much. Import from `focusElement(getClosestElement())` from `@arcgis/toolkit/dom` instead.
|
|
114
|
-
*/
|
|
115
|
-
export declare const setFocusOnElement: (ref: (Element & {
|
|
116
|
-
componentOnReady?: () => Promise<void>;
|
|
117
|
-
}) | null | undefined, selector: string) => void;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
type ArcgisComponentBase<T> = {
|
|
2
|
-
el: HTMLElement;
|
|
3
|
-
referenceElement?: T | string | null | undefined;
|
|
4
|
-
};
|
|
5
|
-
export declare function resolveReferenceElement<T extends Element>(component: ArcgisComponentBase<T>, referenceElementString?: ArcgisComponentBase<T>["referenceElement"] | string): T | undefined;
|
|
6
|
-
export {};
|
package/dist/dom/slots.d.cts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has any content (text or elements).
|
|
3
|
-
*
|
|
4
|
-
* @param event The event.
|
|
5
|
-
* @returns Whether the slot has any content.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* <slot onSlotchange={(event) => this.mySlotHasContent = slotChangeHasContent(event)} />}
|
|
10
|
-
* ```
|
|
11
|
-
*/
|
|
12
|
-
export declare function slotChangeHasContent(event: Event): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Returns a string of textContent if the target `slot` element from the `onSlotchange` event has any text content.
|
|
15
|
-
*
|
|
16
|
-
* @param event The event.
|
|
17
|
-
* @returns The slots text.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* <slot onSlotchange={(event) => this.mySlotText = slotChangeGetTextContent(event)} />}
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function slotChangeGetTextContent(event: Event): string;
|
|
25
|
-
/**
|
|
26
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has any text content.
|
|
27
|
-
*
|
|
28
|
-
* @param event The event.
|
|
29
|
-
* @returns Whether the slot has any text content.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```tsx
|
|
33
|
-
* <slot onSlotchange={(event) => this.mySlotHasTextContent = slotChangeHasTextContent(event)} />}
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function slotChangeHasTextContent(event: Event): boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has an assigned node.
|
|
39
|
-
*
|
|
40
|
-
* @param event The event.
|
|
41
|
-
* @returns Whether the slot has any assigned nodes.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* <slot onSlotchange={(event) => this.mySlotHasNode = slotChangeHasAssignedNode(event)} />}
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export declare function slotChangeHasAssignedNode(event: Event): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Returns the assigned nodes on a `slot` element from the `onSlotchange` event.
|
|
51
|
-
*
|
|
52
|
-
* @param event The event.
|
|
53
|
-
* @returns Whether the slot has any assigned nodes.
|
|
54
|
-
*
|
|
55
|
-
* @example
|
|
56
|
-
* ```tsx
|
|
57
|
-
* <slot onSlotchange={(event) => this.mySlotNodes = slotChangeGetAssignedNodes(event)} />}
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function slotChangeGetAssignedNodes(event: Event): Node[];
|
|
61
|
-
/**
|
|
62
|
-
* Returns `true` if the target `slot` element from the `onSlotchange` event has an assigned element.
|
|
63
|
-
*
|
|
64
|
-
* @param event The event.
|
|
65
|
-
* @returns Whether the slot has any assigned elements.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* ```tsx
|
|
69
|
-
* <slot onSlotchange={(event) => this.mySlotHasElement = slotChangeHasAssignedElement(event)} />}
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
export declare function slotChangeHasAssignedElement(event: Event): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Returns the assigned elements on a `slot` element from the `onSlotchange` event.
|
|
75
|
-
*
|
|
76
|
-
* @param event The event.
|
|
77
|
-
* @param selector The CSS selector string to filter the returned elements by.
|
|
78
|
-
* @returns An array of elements.
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```tsx
|
|
82
|
-
* <slot onSlotchange={(event) => this.mySlotElements = slotChangeGetAssignedElements(event)} />}
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
|
-
export declare function slotChangeGetAssignedElements<T extends Element>(event: Event, selector?: string): T[];
|
|
86
|
-
/**
|
|
87
|
-
* Returns the assigned elements on a `slot` element, filtered by an optional css selector.
|
|
88
|
-
*
|
|
89
|
-
* @param slot The slot element.
|
|
90
|
-
* @param selector CSS selector string to filter the returned elements by.
|
|
91
|
-
* @returns An array of elements.
|
|
92
|
-
*/
|
|
93
|
-
export declare function getSlotAssignedElements<T extends Element>(slot: HTMLSlotElement, selector?: string): T[];
|
package/dist/error/index.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const isEsriInternalEnv = () => (
|
|
4
|
-
//#endregion isEsriInternalEnv
|
|
5
|
-
/*
|
|
6
|
-
* `globalThis.` is important here. Some bundlers remove the `typeof process`
|
|
7
|
-
* checks, but don't remove the usages of undefined variables - this can cause
|
|
8
|
-
* runtime error. By adding `globalThis.`, we avoid having `typeof process`
|
|
9
|
-
* check removed by the bundler.
|
|
10
|
-
* This does meant tree-shaking won't happen for the isEsriInternalEnv()
|
|
11
|
-
* check, but this is ok since this check is meant to always be behind the
|
|
12
|
-
* development/test guard.
|
|
13
|
-
* See https://devtopia.esri.com/WebGIS/arcgis-web-components/pull/2087#issuecomment-5152454
|
|
14
|
-
*/
|
|
15
|
-
typeof globalThis.process === "object" && !!process.env.ESRI_INTERNAL
|
|
16
|
-
);
|
|
17
|
-
const safeCall = (callback, thisContext, ...rest) => {
|
|
18
|
-
try {
|
|
19
|
-
return callback?.call(thisContext, ...rest);
|
|
20
|
-
} catch (error) {
|
|
21
|
-
console.error(error, callback);
|
|
22
|
-
}
|
|
23
|
-
return void 0;
|
|
24
|
-
};
|
|
25
|
-
const safeAsyncCall = async (callback, thisContext, ...rest) => {
|
|
26
|
-
try {
|
|
27
|
-
const result = callback?.call(thisContext, ...rest);
|
|
28
|
-
return await result;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error(error, callback);
|
|
31
|
-
}
|
|
32
|
-
return void 0;
|
|
33
|
-
};
|
|
34
|
-
exports.isEsriInternalEnv = isEsriInternalEnv;
|
|
35
|
-
exports.safeAsyncCall = safeAsyncCall;
|
|
36
|
-
exports.safeCall = safeCall;
|
package/dist/error/index.d.cts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check whether the code is executing in an Esri internal environment (for
|
|
3
|
-
* example, Lumina dev server). When true, your code can enable extra validation
|
|
4
|
-
* to detect incorrect usages or do runtime bug detection.
|
|
5
|
-
*
|
|
6
|
-
* The call to isEsriInternalEnv() MUST always appear behind one of the
|
|
7
|
-
* following guards to ensure it is correctly eliminated in production bundles:
|
|
8
|
-
*
|
|
9
|
-
* - `process.env.NODE_ENV !== "production"`
|
|
10
|
-
* - `process.env.NODE_ENV === "development"`
|
|
11
|
-
* - `process.env.NODE_ENV === "test"`
|
|
12
|
-
*
|
|
13
|
-
* [Documentation](https://webgis.esri.com/references/lumina/publishing#internal-esri-environment)
|
|
14
|
-
*
|
|
15
|
-
* @remarks
|
|
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
|
-
*/
|
|
20
|
-
export declare const isEsriInternalEnv: () => boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Calls a sync method and catch any errors. Returns undefined if error occurred.
|
|
23
|
-
*
|
|
24
|
-
* Can also provide a thisContext and rest arguments
|
|
25
|
-
*/
|
|
26
|
-
export declare const safeCall: <Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>) => ReturnType<Callback> | void;
|
|
27
|
-
/**
|
|
28
|
-
* Calls an async method and catch any errors. Returns undefined if error occurred.
|
|
29
|
-
*
|
|
30
|
-
* Can also provide a thisContext and rest arguments
|
|
31
|
-
*/
|
|
32
|
-
export declare const safeAsyncCall: <Callback extends (...args: never[]) => unknown>(callback?: Callback, thisContext?: ThisParameterType<Callback>, ...rest: Parameters<Callback>) => Promise<Awaited<ReturnType<Callback>> | void>;
|
package/dist/function/index.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const identity = (value) => value;
|
|
4
|
-
const debounce = (func, waitFor = 100) => {
|
|
5
|
-
let timeout;
|
|
6
|
-
return (...args) => {
|
|
7
|
-
const later = () => {
|
|
8
|
-
clearTimeout(timeout);
|
|
9
|
-
func(...args);
|
|
10
|
-
};
|
|
11
|
-
clearTimeout(timeout);
|
|
12
|
-
timeout = setTimeout(later, waitFor);
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
exports.debounce = debounce;
|
|
16
|
-
exports.identity = identity;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identity function - returns back the first parameter
|
|
3
|
-
*
|
|
4
|
-
* Useful when providing a "mapping function" is required, but you have no need
|
|
5
|
-
* to change the value
|
|
6
|
-
*
|
|
7
|
-
* @privateRemarks
|
|
8
|
-
* This is a trivial function, but it helps workaround a TypeScript bug:
|
|
9
|
-
* https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/2047
|
|
10
|
-
*/
|
|
11
|
-
export declare const identity: <T>(value: T) => T;
|
|
12
|
-
/**
|
|
13
|
-
* Allows to debounce a function.
|
|
14
|
-
*
|
|
15
|
-
* @param func Function to be debounced
|
|
16
|
-
* @param waitFor Debounce time in milliseconds
|
|
17
|
-
* @returns Returns a function that can be called to debounce the original function
|
|
18
|
-
*/
|
|
19
|
-
export declare const debounce: <F extends (...args: Parameters<F>) => ReturnType<F>>(func: F, waitFor?: number) => ((...args: Parameters<F>) => void);
|