@arcgis/toolkit 5.2.0-next.9 → 5.2.0-next.91

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.
Files changed (66) hide show
  1. package/LICENSE.md +4 -2
  2. package/README.md +2 -2
  3. package/dist/{array/index.d.cts → array.d.ts} +4 -1
  4. package/dist/dom/referenceElement.d.ts +17 -0
  5. package/dist/dom/referenceElement.js +5 -0
  6. package/dist/dom/slots.d.ts +8 -0
  7. package/dist/dom/slots.js +39 -0
  8. package/dist/{dom/index.js → dom-Bnc7oSYx.js} +30 -48
  9. package/dist/dom.d.ts +177 -0
  10. package/dist/dom.js +21 -0
  11. package/dist/{error/index.d.cts → error.d.ts} +15 -4
  12. package/dist/{error/index.js → error.js} +1 -1
  13. package/dist/{function/index.d.cts → function.d.ts} +4 -1
  14. package/dist/intl/dom.d.ts +74 -0
  15. package/dist/intl/{index.js → dom.js} +41 -37
  16. package/dist/intl.d.ts +89 -0
  17. package/dist/intl.js +10 -0
  18. package/dist/{log/index.d.ts → log.d.ts} +38 -6
  19. package/dist/{number/index.d.cts → number.d.ts} +2 -1
  20. package/dist/predicate.d.ts +27 -0
  21. package/dist/predicate.js +8 -0
  22. package/dist/{promise/index.d.ts → promise.d.ts} +17 -2
  23. package/dist/{promise/index.js → promise.js} +2 -0
  24. package/dist/{string/index.d.ts → string.d.ts} +40 -3
  25. package/dist/{type/index.d.cts → type.d.ts} +11 -1
  26. package/dist/{url/index.d.cts → url.d.ts} +4 -3
  27. package/package.json +16 -61
  28. package/dist/array/index.cjs +0 -13
  29. package/dist/array/index.d.ts +0 -12
  30. package/dist/dom/index.cjs +0 -227
  31. package/dist/dom/index.d.cts +0 -117
  32. package/dist/dom/index.d.ts +0 -117
  33. package/dist/dom/reference-element.d.cts +0 -6
  34. package/dist/dom/reference-element.d.ts +0 -6
  35. package/dist/dom/slots.d.cts +0 -93
  36. package/dist/error/index.cjs +0 -36
  37. package/dist/error/index.d.ts +0 -32
  38. package/dist/function/index.cjs +0 -16
  39. package/dist/function/index.d.ts +0 -19
  40. package/dist/intl/index.cjs +0 -110
  41. package/dist/intl/index.d.cts +0 -124
  42. package/dist/intl/index.d.ts +0 -124
  43. package/dist/log/index.cjs +0 -81
  44. package/dist/log/index.d.cts +0 -128
  45. package/dist/number/index.cjs +0 -10
  46. package/dist/number/index.d.ts +0 -19
  47. package/dist/predicate/index.cjs +0 -8
  48. package/dist/predicate/index.d.cts +0 -24
  49. package/dist/predicate/index.d.ts +0 -24
  50. package/dist/predicate/index.js +0 -8
  51. package/dist/promise/index.cjs +0 -45
  52. package/dist/promise/index.d.cts +0 -60
  53. package/dist/string/index.cjs +0 -117
  54. package/dist/string/index.d.cts +0 -130
  55. package/dist/tests/utils.d.cts +0 -1
  56. package/dist/type/index.cjs +0 -4
  57. package/dist/type/index.d.ts +0 -29
  58. package/dist/url/index.cjs +0 -26
  59. package/dist/url/index.d.ts +0 -18
  60. /package/dist/{array/index.js → array.js} +0 -0
  61. /package/dist/{function/index.js → function.js} +0 -0
  62. /package/dist/{log/index.js → log.js} +0 -0
  63. /package/dist/{number/index.js → number.js} +0 -0
  64. /package/dist/{string/index.js → string.js} +0 -0
  65. /package/dist/{type/index.js → type.js} +0 -0
  66. /package/dist/{url/index.js → url.js} +0 -0
package/package.json CHANGED
@@ -1,71 +1,26 @@
1
1
  {
2
2
  "name": "@arcgis/toolkit",
3
- "version": "5.2.0-next.9",
3
+ "version": "5.2.0-next.91",
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
- "types": "./dist/array/index.d.ts",
11
- "import": "./dist/array/index.js",
12
- "require": "./dist/array/index.cjs"
13
- },
14
- "./dom": {
15
- "types": "./dist/dom/index.d.ts",
16
- "import": "./dist/dom/index.js",
17
- "require": "./dist/dom/index.cjs"
18
- },
19
- "./error": {
20
- "types": "./dist/error/index.d.ts",
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.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",
69
24
  "./package.json": "./package.json"
70
25
  },
71
26
  "files": [
@@ -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;
@@ -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;
@@ -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;
@@ -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,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 {};
@@ -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 {};