@arcgis/toolkit 4.34.0-next.100

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 (45) hide show
  1. package/LICENSE.md +13 -0
  2. package/README.md +25 -0
  3. package/dist/array/index.cjs +12 -0
  4. package/dist/array/index.d.cts +12 -0
  5. package/dist/array/index.d.ts +12 -0
  6. package/dist/array/index.js +12 -0
  7. package/dist/dom/index.cjs +198 -0
  8. package/dist/dom/index.d.cts +116 -0
  9. package/dist/dom/index.d.ts +116 -0
  10. package/dist/dom/index.js +198 -0
  11. package/dist/dom/slots.d.cts +93 -0
  12. package/dist/dom/slots.d.ts +93 -0
  13. package/dist/error/index.cjs +36 -0
  14. package/dist/error/index.d.cts +32 -0
  15. package/dist/error/index.d.ts +32 -0
  16. package/dist/error/index.js +36 -0
  17. package/dist/function/index.cjs +16 -0
  18. package/dist/function/index.d.cts +19 -0
  19. package/dist/function/index.d.ts +19 -0
  20. package/dist/function/index.js +16 -0
  21. package/dist/intl/index.cjs +103 -0
  22. package/dist/intl/index.d.cts +121 -0
  23. package/dist/intl/index.d.ts +121 -0
  24. package/dist/intl/index.js +103 -0
  25. package/dist/predicate/index.cjs +8 -0
  26. package/dist/predicate/index.d.cts +24 -0
  27. package/dist/predicate/index.d.ts +24 -0
  28. package/dist/predicate/index.js +8 -0
  29. package/dist/promise/index.cjs +30 -0
  30. package/dist/promise/index.d.cts +46 -0
  31. package/dist/promise/index.d.ts +46 -0
  32. package/dist/promise/index.js +30 -0
  33. package/dist/string/index.cjs +91 -0
  34. package/dist/string/index.d.cts +106 -0
  35. package/dist/string/index.d.ts +106 -0
  36. package/dist/string/index.js +91 -0
  37. package/dist/tests/utils.d.cts +1 -0
  38. package/dist/tests/utils.d.ts +1 -0
  39. package/dist/type/index.d.cts +15 -0
  40. package/dist/type/index.d.ts +15 -0
  41. package/dist/url/index.cjs +26 -0
  42. package/dist/url/index.d.cts +18 -0
  43. package/dist/url/index.d.ts +18 -0
  44. package/dist/url/index.js +26 -0
  45. package/package.json +66 -0
@@ -0,0 +1,198 @@
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
+ const classes = (...classes2) => {
31
+ const effectiveClasses = [];
32
+ for (let i = 0; i < classes2.length; i++) {
33
+ const arg = classes2[i];
34
+ if (typeof arg === "string") {
35
+ effectiveClasses.push(arg);
36
+ } else if (Array.isArray(arg)) {
37
+ effectiveClasses.push.apply(effectiveClasses, arg);
38
+ } else if (typeof arg === "object") {
39
+ for (const prop in arg) {
40
+ if (arg[prop]) {
41
+ effectiveClasses.push(prop);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ const className = effectiveClasses.join(" ");
47
+ effectiveClasses.length = 0;
48
+ return className;
49
+ };
50
+ const inTargetElement = (element, targetElement) => {
51
+ let currentElement = element;
52
+ while (currentElement) {
53
+ if (currentElement === targetElement) {
54
+ return true;
55
+ }
56
+ if (!currentElement.parentNode) {
57
+ return false;
58
+ }
59
+ if (currentElement.parentNode instanceof ShadowRoot) {
60
+ currentElement = currentElement.parentNode.host;
61
+ } else {
62
+ currentElement = currentElement.parentNode;
63
+ }
64
+ }
65
+ return false;
66
+ };
67
+ const observeAncestorsMutation = (element, attributeFilter, callback) => {
68
+ const subscribe = observe(attributeFilter).subscribe;
69
+ return subscribe((mutations) => {
70
+ const matched = mutations.some((mutation) => inTargetElement(element, mutation.target));
71
+ if (matched) {
72
+ callback();
73
+ }
74
+ });
75
+ };
76
+ const observers = {};
77
+ const observe = (attributeFilter) => {
78
+ const attributes = attributeFilter.join(",");
79
+ const previousObserver = observers[attributes];
80
+ if (previousObserver !== void 0) {
81
+ return previousObserver;
82
+ }
83
+ const subscribers = /* @__PURE__ */ new Set();
84
+ const mutationObserver = new MutationObserver((mutations) => subscribers.forEach((callback) => callback(mutations)));
85
+ if (globalThis.document) {
86
+ mutationObserver.observe(document.documentElement, {
87
+ attributes: true,
88
+ attributeFilter,
89
+ subtree: true
90
+ });
91
+ }
92
+ const observer = {
93
+ subscribe: (callback) => {
94
+ subscribers.add(callback);
95
+ return () => {
96
+ subscribers.delete(callback);
97
+ if (subscribers.size === 0) {
98
+ mutationObserver.disconnect();
99
+ observers[attributes] = void 0;
100
+ }
101
+ };
102
+ }
103
+ };
104
+ observers[attributes] = observer;
105
+ return observer;
106
+ };
107
+ const getClosestElement = (base, selector) => {
108
+ let currentElement = base;
109
+ while (currentElement) {
110
+ const element = currentElement.closest?.(selector);
111
+ if (element) {
112
+ return element;
113
+ }
114
+ const rootElement = currentElement.getRootNode?.();
115
+ if (rootElement === globalThis.document) {
116
+ return;
117
+ }
118
+ currentElement = rootElement.host;
119
+ }
120
+ return;
121
+ };
122
+ function unsafeGetCalciteModeName(el) {
123
+ const closestElWithMode = getClosestElement(el, `.calcite-mode-dark, .calcite-mode-light, .calcite-mode-auto`);
124
+ return closestElWithMode?.classList.contains("calcite-mode-dark") || closestElWithMode?.classList.contains("calcite-mode-auto") && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
125
+ }
126
+ const unsafeGetElementDirection = (el) => (
127
+ //#endregion unsafeGetElementDirection
128
+ getElementAttribute(el, "dir", "ltr")
129
+ );
130
+ const getElementAttribute = (el, attributeName, fallbackValue) => {
131
+ const closest = getClosestElement(el, `[${attributeName}]`);
132
+ return closest?.getAttribute(attributeName) ?? fallbackValue;
133
+ };
134
+ const focusElement = async (el) => {
135
+ if (el == null) {
136
+ return;
137
+ }
138
+ if (hasSetFocus(el)) {
139
+ await el.setFocus();
140
+ } else {
141
+ el.focus();
142
+ }
143
+ };
144
+ const hasSetFocus = (ref) => typeof ref.setFocus === "function";
145
+ const setFocusOnElement = (ref, selector) => {
146
+ if (!ref?.shadowRoot) {
147
+ return;
148
+ }
149
+ if (ref.hasAttribute("hydrated") || ref.hasAttribute("calcite-hydrated")) {
150
+ setFocus(ref, selector);
151
+ return;
152
+ }
153
+ void Promise.resolve(ref.componentOnReady?.()).then(() => setFocus(ref, selector));
154
+ };
155
+ const isElement = (ref) => ref.nodeType === Node.ELEMENT_NODE;
156
+ const setFocus = (ref, selector = "") => {
157
+ if (!isElement(ref)) {
158
+ return false;
159
+ }
160
+ if (ref.matches(selector)) {
161
+ if (hasSetFocus(ref)) {
162
+ setTimeout(() => void ref.setFocus(), 0);
163
+ }
164
+ return true;
165
+ }
166
+ for (const child of ref.children) {
167
+ if (setFocus(child, selector)) {
168
+ return true;
169
+ }
170
+ }
171
+ const shadowRoot = ref.shadowRoot;
172
+ if (shadowRoot) {
173
+ for (const child of shadowRoot.children) {
174
+ if (setFocus(child, selector)) {
175
+ return true;
176
+ }
177
+ }
178
+ }
179
+ return false;
180
+ };
181
+ export {
182
+ classes,
183
+ focusElement,
184
+ getClosestElement,
185
+ getElementAttribute,
186
+ getSlotAssignedElements,
187
+ observeAncestorsMutation,
188
+ setFocusOnElement,
189
+ slotChangeGetAssignedElements,
190
+ slotChangeGetAssignedNodes,
191
+ slotChangeGetTextContent,
192
+ slotChangeHasAssignedElement,
193
+ slotChangeHasAssignedNode,
194
+ slotChangeHasContent,
195
+ slotChangeHasTextContent,
196
+ unsafeGetCalciteModeName,
197
+ unsafeGetElementDirection
198
+ };
@@ -0,0 +1,93 @@
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 {string} 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} event The event.
77
+ * @param {string} selector The CSS selector string to filter the returned elements by.
78
+ * @returns {Element[]} 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 {HTMLSlotElement} slot The slot element.
90
+ * @param {string} selector CSS selector string to filter the returned elements by.
91
+ * @returns {Element[]} An array of elements.
92
+ */
93
+ export declare function getSlotAssignedElements<T extends Element>(slot: HTMLSlotElement, selector?: string): T[];
@@ -0,0 +1,93 @@
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 {string} 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} event The event.
77
+ * @param {string} selector The CSS selector string to filter the returned elements by.
78
+ * @returns {Element[]} 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 {HTMLSlotElement} slot The slot element.
90
+ * @param {string} selector CSS selector string to filter the returned elements by.
91
+ * @returns {Element[]} An array of elements.
92
+ */
93
+ export declare function getSlotAssignedElements<T extends Element>(slot: HTMLSlotElement, selector?: string): T[];
@@ -0,0 +1,36 @@
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;
@@ -0,0 +1,32 @@
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://qawebgis.esri.com/components/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://qawebgis.esri.com/components/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>;
@@ -0,0 +1,32 @@
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://qawebgis.esri.com/components/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://qawebgis.esri.com/components/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>;
@@ -0,0 +1,36 @@
1
+ const isEsriInternalEnv = () => (
2
+ //#endregion isEsriInternalEnv
3
+ /*
4
+ * `globalThis.` is important here. Some bundlers remove the `typeof process`
5
+ * checks, but don't remove the usages of undefined variables - this can cause
6
+ * runtime error. By adding `globalThis.`, we avoid having `typeof process`
7
+ * check removed by the bundler.
8
+ * This does meant tree-shaking won't happen for the isEsriInternalEnv()
9
+ * check, but this is ok since this check is meant to always be behind the
10
+ * development/test guard.
11
+ * See https://devtopia.esri.com/WebGIS/arcgis-web-components/pull/2087#issuecomment-5152454
12
+ */
13
+ typeof globalThis.process === "object" && !!process.env.ESRI_INTERNAL
14
+ );
15
+ const safeCall = (callback, thisContext, ...rest) => {
16
+ try {
17
+ return callback?.call(thisContext, ...rest);
18
+ } catch (error) {
19
+ console.error(error, callback);
20
+ }
21
+ return void 0;
22
+ };
23
+ const safeAsyncCall = async (callback, thisContext, ...rest) => {
24
+ try {
25
+ const result = callback?.call(thisContext, ...rest);
26
+ return await result;
27
+ } catch (error) {
28
+ console.error(error, callback);
29
+ }
30
+ return void 0;
31
+ };
32
+ export {
33
+ isEsriInternalEnv,
34
+ safeAsyncCall,
35
+ safeCall
36
+ };
@@ -0,0 +1,16 @@
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;
@@ -0,0 +1,19 @@
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);
@@ -0,0 +1,19 @@
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);
@@ -0,0 +1,16 @@
1
+ const identity = (value) => value;
2
+ const debounce = (func, waitFor = 100) => {
3
+ let timeout;
4
+ return (...args) => {
5
+ const later = () => {
6
+ clearTimeout(timeout);
7
+ func(...args);
8
+ };
9
+ clearTimeout(timeout);
10
+ timeout = setTimeout(later, waitFor);
11
+ };
12
+ };
13
+ export {
14
+ debounce,
15
+ identity
16
+ };