@dropins/tools 1.6.0-alpha999 → 1.6.0-beta2

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 (48) hide show
  1. package/chunks/Image.js +1 -1
  2. package/chunks/Image.js.map +1 -1
  3. package/chunks/get-price-formatter.js +4 -0
  4. package/chunks/get-price-formatter.js.map +1 -0
  5. package/chunks/icons/Add.js +1 -1
  6. package/chunks/icons/Business.js +4 -0
  7. package/chunks/icons/Business.js.map +1 -0
  8. package/chunks/icons/List.js +4 -0
  9. package/chunks/icons/List.js.map +1 -0
  10. package/chunks/icons/Quote.js +4 -0
  11. package/chunks/icons/Quote.js.map +1 -0
  12. package/chunks/icons/Structure.js +4 -0
  13. package/chunks/icons/Structure.js.map +1 -0
  14. package/chunks/icons/Team.js +4 -0
  15. package/chunks/icons/Team.js.map +1 -0
  16. package/chunks/initializer.js +2 -2
  17. package/components.js +1 -1
  18. package/components.js.map +1 -1
  19. package/fetch-graphql.js +1 -1
  20. package/fetch-graphql.js.map +1 -1
  21. package/initializer.js +2 -2
  22. package/lib/aem/assets.js +1 -1
  23. package/lib/aem/configs.js +1 -1
  24. package/lib/aem/configs.js.map +1 -1
  25. package/lib.js +1 -1
  26. package/lib.js.map +1 -1
  27. package/package.json +1 -1
  28. package/preact-compat.js +1 -1
  29. package/types/elsie/src/components/Button/Button.d.ts +2 -0
  30. package/types/elsie/src/components/Incrementer/Incrementer.d.ts +1 -0
  31. package/types/elsie/src/components/MultiSelect/MultiSelect.d.ts +29 -0
  32. package/types/elsie/src/components/MultiSelect/index.d.ts +11 -0
  33. package/types/elsie/src/components/Pagination/Pagination.d.ts +2 -1
  34. package/types/elsie/src/components/Pagination/PaginationButton.d.ts +11 -0
  35. package/types/elsie/src/components/Table/Table.d.ts +32 -0
  36. package/types/elsie/src/components/Table/index.d.ts +11 -0
  37. package/types/elsie/src/components/ToggleButton/ToggleButton.d.ts +1 -0
  38. package/types/elsie/src/components/index.d.ts +2 -0
  39. package/types/elsie/src/i18n/en_US.json.d.ts +38 -0
  40. package/types/elsie/src/i18n/index.d.ts +114 -0
  41. package/types/elsie/src/icons/index.d.ts +29 -24
  42. package/types/elsie/src/lib/aem/configs.d.ts +9 -2
  43. package/types/elsie/src/lib/get-price-formatter.d.ts +34 -0
  44. package/types/elsie/src/lib/index.d.ts +1 -0
  45. package/types/elsie/src/lib/slot.d.ts +3 -1
  46. package/types/fetch-graphql/src/index.d.ts +83 -5
  47. package/chunks/deviceUtils.js +0 -4
  48. package/chunks/deviceUtils.js.map +0 -1
@@ -0,0 +1,34 @@
1
+ /********************************************************************
2
+ * Copyright 2025 Adobe
3
+ * All Rights Reserved.
4
+ *
5
+ * NOTICE: Adobe permits you to use, modify, and distribute this
6
+ * file in accordance with the terms of the Adobe license agreement
7
+ * accompanying it.
8
+ *******************************************************************/
9
+ export interface PriceFormatterOptions {
10
+ currency?: string | null;
11
+ locale?: string;
12
+ formatOptions?: Intl.NumberFormatOptions;
13
+ }
14
+ /**
15
+ * Determines the effective locale to use for price formatting
16
+ * Priority: prop locale > global locale > browser locale > default 'en-US'
17
+ */
18
+ export declare function getEffectiveLocale(locale?: string): string;
19
+ /**
20
+ * Gets an Intl.NumberFormat instance for price formatting
21
+ * Uses getEffectiveLocale internally to determine the best locale
22
+ *
23
+ * @example
24
+ * // Single price formatting
25
+ * const formatter = getPriceFormatter({ currency: 'USD', locale: 'en-US' });
26
+ * const price = formatter.format(10.99); // "$10.99"
27
+ *
28
+ * @example
29
+ * // Bulk price formatting (more efficient)
30
+ * const formatter = getPriceFormatter({ currency: 'EUR', locale: 'fr-FR' });
31
+ * const prices = [10.99, 25.50, 99.99].map(amount => formatter.format(amount));
32
+ */
33
+ export declare function getPriceFormatter(options?: PriceFormatterOptions): Intl.NumberFormat;
34
+ //# sourceMappingURL=get-price-formatter.d.ts.map
@@ -24,4 +24,5 @@ export * from './is-number';
24
24
  export * from './deviceUtils';
25
25
  export * from './get-path-value';
26
26
  export * from './get-cookie';
27
+ export * from './get-price-formatter';
27
28
  //# sourceMappingURL=index.d.ts.map
@@ -13,6 +13,7 @@ interface SlotElement {
13
13
  prependChild: MutateElement;
14
14
  appendSibling: MutateElement;
15
15
  prependSibling: MutateElement;
16
+ remove: () => void;
16
17
  }
17
18
  interface PrivateContext<T> {
18
19
  _setProps: (s: StateUpdater<{}>) => void;
@@ -27,13 +28,14 @@ interface DefaultSlotContext<T> extends PrivateContext<T> {
27
28
  prependChild: MutateElement;
28
29
  appendSibling: MutateElement;
29
30
  prependSibling: MutateElement;
31
+ remove: () => void;
30
32
  onRender: (cb: (next: T & DefaultSlotContext<T>) => void) => void;
31
33
  onChange: (cb: (next: T & DefaultSlotContext<T>) => void) => void;
32
34
  }
33
35
  type Context<T> = T & ThisType<DefaultSlotContext<T>>;
34
36
  export type SlotProps<T = any> = (ctx: T & DefaultSlotContext<T>, element: HTMLDivElement | null) => Promise<void> | void;
35
37
  export type SlotMethod<P = any> = (callback: (next: unknown, state: State) => P) => void;
36
- export declare function useSlot<K, V extends HTMLElement>(name: string, context?: Context<K>, callback?: SlotProps<K>, children?: ComponentChildren, render?: Function, contentTag?: keyof HTMLElementTagNameMap): [RefObject<V>, Record<string, any>];
38
+ export declare function useSlot<K, V extends HTMLElement>(name: string, context?: Context<K>, callback?: SlotProps<K>, children?: ComponentChildren, render?: Function, contentTag?: keyof HTMLElementTagNameMap): [RefObject<V>, Record<string, any>, 'loading' | 'pending' | 'ready'];
37
39
  interface SlotPropsComponent<T> extends Omit<HTMLAttributes<HTMLElement>, 'slot'> {
38
40
  name: string;
39
41
  lazy?: boolean;
@@ -32,15 +32,20 @@ export type AfterHook<T = any> = (requestInit: RequestInit, response: {
32
32
  data: T;
33
33
  };
34
34
  declare class FetchGraphQLMesh {
35
- _endpoint?: string;
36
- get endpoint(): string | undefined;
37
- get fetchGraphQlHeaders(): Header;
35
+ protected _endpoint?: string;
38
36
  _fetchGraphQlHeaders: Header;
39
37
  _beforeHooks: BeforeHook[];
40
38
  _afterHooks: AfterHook[];
39
+ get endpoint(): string | undefined;
40
+ get fetchGraphQlHeaders(): Header;
41
41
  /**
42
42
  * Sets the GraphQL endpoint.
43
- * @param endpoint - The GraphQL endpoint.
43
+ * @param endpoint - The GraphQL endpoint URL string.
44
+ * @example
45
+ * ```js
46
+ * // Set endpoint as string
47
+ * instance.setEndpoint('https://api.example.com/graphql');
48
+ * ```
44
49
  */
45
50
  setEndpoint(endpoint: string): void;
46
51
  /**
@@ -106,6 +111,16 @@ declare class FetchGraphQLMesh {
106
111
  * ```
107
112
  */
108
113
  addAfterHook(hook: AfterHook): void;
114
+ /**
115
+ * Collects all before hooks. Can be overridden by subclasses for inheritance.
116
+ * @protected
117
+ */
118
+ protected _collectBeforeHooks(): BeforeHook[];
119
+ /**
120
+ * Collects all after hooks. Can be overridden by subclasses for inheritance.
121
+ * @protected
122
+ */
123
+ protected _collectAfterHooks(): AfterHook[];
109
124
  /**
110
125
  * Fetches GraphQL data.
111
126
  * @param query - The GraphQL query.
@@ -143,14 +158,75 @@ declare class FetchGraphQLMesh {
143
158
  }
144
159
  /**
145
160
  * `FetchGraphQL` is a class that extends `FetchGraphQLMesh`.
146
- * It provides methods to get the GraphQL endpoint and headers.
161
+ * It provides methods to get the GraphQL endpoint and headers with support for inheritance.
147
162
  *
148
163
  * @class
149
164
  *
150
165
  */
151
166
  export declare class FetchGraphQL extends FetchGraphQLMesh {
167
+ private _mode;
168
+ private _source?;
152
169
  get endpoint(): string | undefined;
153
170
  get fetchGraphQlHeaders(): Header;
171
+ /**
172
+ * Sets the GraphQL endpoint or links to another FetchGraphQL instance.
173
+ * @param endpoint - The GraphQL endpoint URL string, or a FetchGraphQL instance to link to.
174
+ * @example
175
+ * ```js
176
+ * // Set endpoint as string
177
+ * instance.setEndpoint('https://api.example.com/graphql');
178
+ *
179
+ * // Link to another instance
180
+ * const parent = new FetchGraphQL();
181
+ * parent.setEndpoint('https://api.example.com/graphql');
182
+ *
183
+ * const child = new FetchGraphQL();
184
+ * child.setEndpoint(parent); // Links to parent, shares endpoint, headers, and hooks
185
+ * ```
186
+ */
187
+ setEndpoint(endpoint: string | FetchGraphQL): void;
188
+ /**
189
+ * Sets a GraphQL header. When linked to another instance, this sets the header on the linked instance.
190
+ * @param key - The key of the header.
191
+ * @param value - The value of the header.
192
+ */
193
+ setFetchGraphQlHeader(key: string, value: string | null): void;
194
+ /**
195
+ * Sets the GraphQL headers. When linked to another instance, this sets the headers on the linked instance.
196
+ * @param header - The header object or a function that returns a header object.
197
+ */
198
+ setFetchGraphQlHeaders(header: Header | ((prev: Header) => Header)): void;
199
+ /**
200
+ * Removes a specific GraphQL header. When linked to another instance, this removes the header from the linked instance.
201
+ * @param key - The key of the header.
202
+ */
203
+ removeFetchGraphQlHeader(key: string): void;
204
+ /**
205
+ * Gets the value of a specific GraphQL header. When linked to another instance, this gets the header from the linked instance.
206
+ * @param key - The key of the header.
207
+ * @returns The value of the header, or undefined if not found.
208
+ */
209
+ getFetchGraphQlHeader(key: string): string | null | undefined;
210
+ /**
211
+ * Adds a before hook. When linked to another instance, this adds the hook to the linked instance.
212
+ * @param hook - The hook function.
213
+ */
214
+ addBeforeHook(hook: BeforeHook): void;
215
+ /**
216
+ * Adds an after hook. When linked to another instance, this adds the hook to the linked instance.
217
+ * @param hook - The hook function.
218
+ */
219
+ addAfterHook(hook: AfterHook): void;
220
+ /**
221
+ * Collects all before hooks. When linked, delegates to the linked instance.
222
+ * @protected
223
+ */
224
+ protected _collectBeforeHooks(): BeforeHook[];
225
+ /**
226
+ * Collects all after hooks. When linked, delegates to the linked instance.
227
+ * @protected
228
+ */
229
+ protected _collectAfterHooks(): AfterHook[];
154
230
  }
155
231
  /**
156
232
  * Exports several methods from the `mesh` object.
@@ -162,6 +238,8 @@ export declare class FetchGraphQL extends FetchGraphQLMesh {
162
238
  * @property {Function} removeFetchGraphQlHeader - Removes a specific GraphQL header.
163
239
  * @property {Function} fetchGraphQl - Fetches GraphQL data.
164
240
  * @property {Function} getConfig - Gets the configuration.
241
+ * @property {Function} addBeforeHook - Adds a hook executed before the GraphQL call.
242
+ * @property {Function} addAfterHook - Adds a hook executed after the GraphQL call.
165
243
  */
166
244
  export declare const setEndpoint: (endpoint: string) => void, setFetchGraphQlHeaders: (header: Header | ((prev: Header) => Header)) => void, setFetchGraphQlHeader: (key: string, value: string | null) => void, getFetchGraphQlHeader: (key: string) => string | null | undefined, removeFetchGraphQlHeader: (key: string) => void, fetchGraphQl: <T = any>(query: string, options?: FetchOptions) => Promise<{
167
245
  errors?: FetchQueryError | undefined;
@@ -1,4 +0,0 @@
1
- /*! Copyright 2025 Adobe
2
- All Rights Reserved. */
3
- const s=(e,o)=>{let t;return function(...n){clearTimeout(t),t=setTimeout(()=>e.apply(this,n),o)}},i=e=>typeof e=="number",c=()=>{const e=navigator.userAgent.toLowerCase(),o=/ipad|iphone|ipod/.test(e),t=e.includes("mac")&&"ontouchend"in document;return o||t};export{c as a,s as d,i};
4
- //# sourceMappingURL=deviceUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deviceUtils.js","sources":["/@dropins/tools/src/lib/debounce.ts","/@dropins/tools/src/lib/is-number.ts","/@dropins/tools/src/lib/deviceUtils.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const debounce = (fn: Function, ms: number) => {\n let timeoutId: ReturnType<typeof setTimeout>;\n return function (this: any, ...args: any[]) {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => fn.apply(this, args), ms);\n };\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const isNumber = (value: number | string): value is number => {\n return typeof value === 'number';\n};\n","/********************************************************************\n * Copyright 2024 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nexport const isIOSMobileDevice = () => {\n const userAgent = navigator.userAgent.toLowerCase();\n const isIOS = /ipad|iphone|ipod/.test(userAgent);\n const isMacWithTouch = userAgent.includes('mac') && 'ontouchend' in document;\n\n return isIOS || isMacWithTouch;\n};\n"],"names":["debounce","fn","ms","timeoutId","args","isNumber","value","isIOSMobileDevice","userAgent","isIOS","isMacWithTouch"],"mappings":"AASa,MAAAA,EAAW,CAACC,EAAcC,IAAe,CAChD,IAAAC,EACJ,OAAO,YAAwBC,EAAa,CAC1C,aAAaD,CAAS,EACtBA,EAAY,WAAW,IAAMF,EAAG,MAAM,KAAMG,CAAI,EAAGF,CAAE,CACvD,CACF,ECNaG,EAAYC,GAChB,OAAOA,GAAU,SCDbC,EAAoB,IAAM,CAC/B,MAAAC,EAAY,UAAU,UAAU,YAAY,EAC5CC,EAAQ,mBAAmB,KAAKD,CAAS,EACzCE,EAAiBF,EAAU,SAAS,KAAK,GAAK,eAAgB,SAEpE,OAAOC,GAASC,CAClB"}