@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/LICENSE.md CHANGED
@@ -1,12 +1,14 @@
1
1
  # Licensing
2
2
 
3
- COPYRIGHT © Esri
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 [Esri Master License Agreement (MLA)](https://www.esri.com/content/dam/esrisites/en-us/media/legal/ma-full/ma-full.pdf), and is bound by the terms of that agreement.
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.1/LICENSE.txt.
12
- For third party notices, see https://js.arcgis.com/5.1/third-party-notices.txt.
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 '../type/index.ts';
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.
@@ -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 {};
@@ -0,0 +1,5 @@
1
+ import { r } from "../dom-Bnc7oSYx.js";
2
+ import "../log.js";
3
+ export {
4
+ r as resolveReferenceElement
5
+ };
@@ -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
+ };
@@ -1,35 +1,7 @@
1
- import { log } from "../log/index.js";
2
- function slotChangeHasContent(event) {
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) {
@@ -207,21 +188,22 @@ const setFocus = (ref, selector = "") => {
207
188
  return false;
208
189
  };
209
190
  export {
210
- classes,
211
- focusElement,
212
- getClosestElement,
213
- getElementAttribute,
214
- getSlotAssignedElements,
215
- observeAncestorsMutation,
216
- resolveReferenceElement,
217
- setFocusOnElement,
218
- slotChangeGetAssignedElements,
219
- slotChangeGetAssignedNodes,
220
- slotChangeGetTextContent,
221
- slotChangeHasAssignedElement,
222
- slotChangeHasAssignedNode,
223
- slotChangeHasContent,
224
- slotChangeHasTextContent,
225
- unsafeGetCalciteModeName,
226
- unsafeGetElementDirection
191
+ getClosestElement as a,
192
+ getSlotAssignedElements as b,
193
+ classes as c,
194
+ resolveReferenceElement as d,
195
+ slotChangeGetAssignedElements as e,
196
+ focusElement as f,
197
+ getElementAttribute as g,
198
+ slotChangeGetAssignedNodes as h,
199
+ slotChangeGetTextContent as i,
200
+ slotChangeHasAssignedElement as j,
201
+ slotChangeHasAssignedNode as k,
202
+ slotChangeHasContent as l,
203
+ slotChangeHasTextContent as m,
204
+ unsafeGetElementDirection as n,
205
+ observeAncestorsMutation as o,
206
+ resolveReferenceElement$1 as r,
207
+ setFocusOnElement as s,
208
+ unsafeGetCalciteModeName as u
227
209
  };
package/dist/dom.d.ts ADDED
@@ -0,0 +1,177 @@
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;
package/dist/dom.js ADDED
@@ -0,0 +1,21 @@
1
+ import "./dom/slots.js";
2
+ import { c, f, a, g, b, o, d, s, e, h, i, j, k, l, m, u, n } from "./dom-Bnc7oSYx.js";
3
+ export {
4
+ c as classes,
5
+ f as focusElement,
6
+ a as getClosestElement,
7
+ g as getElementAttribute,
8
+ b as getSlotAssignedElements,
9
+ o as observeAncestorsMutation,
10
+ d as resolveReferenceElement,
11
+ s as setFocusOnElement,
12
+ e as slotChangeGetAssignedElements,
13
+ h as slotChangeGetAssignedNodes,
14
+ i as slotChangeGetTextContent,
15
+ j as slotChangeHasAssignedElement,
16
+ k as slotChangeHasAssignedNode,
17
+ l as slotChangeHasContent,
18
+ m as slotChangeHasTextContent,
19
+ u as unsafeGetCalciteModeName,
20
+ n as unsafeGetElementDirection
21
+ };
@@ -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
- * @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
+ * @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/arcgis-web-components/pull/2087#issuecomment-5152454
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/arcgis-web-components/issues/2047
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
@@ -0,0 +1,74 @@
1
+ import { type GenericT9nStrings, type SupportedLocale } from "../intl.ts";
2
+ /**
3
+ * Get the locale of the given element.
4
+ * It will look for the lang attribute on the element and its ancestors.
5
+ * If not lang is found, it will default to 'en'.
6
+ *
7
+ * @public
8
+ * @param element
9
+ * @returns an object with the `lang` and `t9nLocale` properties.
10
+ *
11
+ * @see [lang vs t9nLocale](https://webgis.esri.com/references/lumina/controllers/useT9n#difference-between-lang-and-t9nlocale).
12
+ */
13
+ export declare const getElementLocale: (element: HTMLElement) => {
14
+ readonly lang: string;
15
+ readonly t9nLocale: SupportedLocale;
16
+ };
17
+ /**
18
+ * Start the locale observer for the given component.
19
+ * The callback will be called when the locale changes for the component.
20
+ * It will observe the lang attribute on the component and its ancestors.
21
+ * The callback is called once at the beginning.
22
+ *
23
+ * > Rather than using this function directly, prefer the
24
+ * > [useT9n()](https://webgis.esri.com/references/lumina/controllers/useT9n)
25
+ * > controller.
26
+ *
27
+ * @public
28
+ * @param element The HTML element that is doing the fetching
29
+ * This is used to determine the locale to fetch, observe the `lang` attribute
30
+ * changes, and is used as the default value for the `assetName` parameter.
31
+ * @param getAssetsPath The callback to get path to the assets folder where the
32
+ * T9N strings are located.
33
+ * @param onUpdated The callback to call when the locale changes.
34
+ * @param assetName Optionally override the asset file name.
35
+ * Default file name is the element tag name without the part before the
36
+ * first dash (e.g. `arcgis-map` becomes `map`).
37
+ *
38
+ * Set to null if the component has no localization strings, but you still
39
+ * wish to use `startLocaleObserver` to get the locale information.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const observer = startLocaleObserver(
44
+ * element,
45
+ * () => getAssetPath("./assets"),
46
+ * ({ strings, lang, t9nLocale }) => console.log({ strings, lang, t9nLocale }),
47
+ * );
48
+ * // Later: cleanup
49
+ * observer();
50
+ * ```
51
+ */
52
+ export declare const startLocaleObserver: <Strings extends GenericT9nStrings = GenericT9nStrings>(element: HTMLElement, getAssetsPath: () => string, onUpdated: (payload: LocaleObserverResult<Strings>) => void, assetName?: string | null) => (() => void);
53
+ /** @public */
54
+ export interface LocaleObserverResult<Strings extends GenericT9nStrings = GenericT9nStrings> {
55
+ /**
56
+ * The T9N strings of the component
57
+ *
58
+ * @public
59
+ */
60
+ t9nStrings: Strings;
61
+ /**
62
+ * The locale of the component set by the `lang` attribute on the component host element or one of its ancestors.
63
+ *
64
+ * @public
65
+ */
66
+ lang: string;
67
+ /**
68
+ * The locale used by the component to load the T9N strings.
69
+ * It may be different than the locale of the component host element that was set by the `lang` attribute.
70
+ *
71
+ * @public
72
+ */
73
+ t9nLocale: SupportedLocale;
74
+ }