@adobe-commerce/elsie 2.0.0 → 2.0.1-alpha-20260728135101

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 (249) hide show
  1. package/.elsie.js +3 -3
  2. package/CHANGELOG.md +385 -112
  3. package/LICENSE.md +257 -157
  4. package/README.md +4 -2
  5. package/__mocks__/svg.js +3 -3
  6. package/bin/builders/build/index.js +2 -1
  7. package/bin/builders/changeset/index.js +1 -1
  8. package/bin/builders/concurrently/index.js +1 -1
  9. package/bin/builders/generate/api/index.js +7 -7
  10. package/bin/builders/generate/component/index.js +8 -8
  11. package/bin/builders/generate/config/index.js +5 -5
  12. package/bin/builders/generate/config/templates/elsie.js +1 -1
  13. package/bin/builders/generate/container/index.js +7 -7
  14. package/bin/builders/generate/index.js +36 -36
  15. package/bin/builders/gql/index.js +28 -28
  16. package/bin/builders/gql/validate.js +116 -105
  17. package/bin/builders/lint/index.js +1 -1
  18. package/bin/builders/serve/index.js +1 -1
  19. package/bin/builders/storybook/index.js +9 -1
  20. package/bin/builders/types/index.js +1 -2
  21. package/bin/builders/types/validate-tsconfig.js +5 -5
  22. package/bin/index.js +12 -6
  23. package/bin/lib/cli.js +9 -8
  24. package/bin/lib/resolve-bin.js +9 -0
  25. package/bin/lib/validate-typeof.js +3 -3
  26. package/bin/lib/write-file.js +3 -3
  27. package/bin/lib/write-parent-index.js +4 -4
  28. package/config/eslint.mjs +2 -1
  29. package/config/jest.mjs +7 -2
  30. package/config/plugins/dts-normalize-relative-replacer.cjs +1 -1
  31. package/config/plugins/dts.mjs +4 -3
  32. package/config/prettier.json +25 -3
  33. package/config/setEnvVars.mjs +2 -2
  34. package/config/storybook/addon.js +5 -5
  35. package/config/storybook/components/FileTree/FileTree.jsx +4 -4
  36. package/config/storybook/components/FileTree/index.js +4 -4
  37. package/config/storybook/components/Flex/Flex.jsx +3 -3
  38. package/config/storybook/components/Flex/index.js +3 -3
  39. package/config/storybook/components/OptionsTable/OptionsTable.jsx +3 -3
  40. package/config/storybook/components/OptionsTable/index.js +4 -4
  41. package/config/storybook/components/Panel/Panel.tsx +7 -7
  42. package/config/storybook/components/Panel/index.ts +3 -3
  43. package/config/storybook/components/Screenshot/Screenshot.jsx +3 -3
  44. package/config/storybook/components/Screenshot/index.js +4 -4
  45. package/config/storybook/components/Steps/Steps.jsx +3 -3
  46. package/config/storybook/components/Steps/index.js +4 -4
  47. package/config/storybook/components/StoryWrapper/StoryWrapper.jsx +3 -3
  48. package/config/storybook/components/StoryWrapper/index.js +3 -3
  49. package/config/storybook/components/Summary/Summary.jsx +3 -3
  50. package/config/storybook/components/Summary/index.js +3 -3
  51. package/config/storybook/components/Variants/Variants.jsx +11 -7
  52. package/config/storybook/components/Variants/index.js +3 -3
  53. package/config/storybook/manager.js +3 -3
  54. package/config/storybook/preview.jsx +3 -3
  55. package/config/storybook/theming/fonts.css +12 -4
  56. package/config/storybook/theming/preview.css +3 -1
  57. package/config/storybook/theming/theme.js +3 -3
  58. package/config/vite.mjs +53 -26
  59. package/package.json +36 -34
  60. package/src/components/Accordion/Accordion.css +1 -1
  61. package/src/components/Accordion/Accordion.stories.tsx +18 -18
  62. package/src/components/Accordion/Accordion.tsx +12 -8
  63. package/src/components/Accordion/index.ts +3 -3
  64. package/src/components/ActionButton/ActionButton.stories.tsx +8 -8
  65. package/src/components/ActionButton/ActionButton.tsx +7 -5
  66. package/src/components/ActionButton/index.ts +3 -3
  67. package/src/components/ActionButtonGroup/ActionButtonGroup.stories.tsx +3 -3
  68. package/src/components/ActionButtonGroup/ActionButtonGroup.tsx +2 -2
  69. package/src/components/ActionButtonGroup/index.ts +3 -3
  70. package/src/components/AlertBanner/AlertBanner.stories.tsx +6 -6
  71. package/src/components/AlertBanner/AlertBanner.tsx +12 -10
  72. package/src/components/AlertBanner/index.ts +3 -3
  73. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +14 -14
  74. package/src/components/Breadcrumbs/Breadcrumbs.tsx +3 -3
  75. package/src/components/Breadcrumbs/index.ts +3 -3
  76. package/src/components/Button/Button.mdx +24 -11
  77. package/src/components/Button/Button.stories.tsx +6 -6
  78. package/src/components/Button/Button.tsx +7 -8
  79. package/src/components/Button/index.ts +3 -3
  80. package/src/components/Card/Card.stories.tsx +6 -6
  81. package/src/components/Card/Card.tsx +3 -3
  82. package/src/components/Card/index.ts +3 -3
  83. package/src/components/CartItem/CartItem.stories.tsx +12 -12
  84. package/src/components/CartItem/CartItem.tsx +4 -2
  85. package/src/components/CartItem/CartItemSkeleton.tsx +3 -3
  86. package/src/components/CartItem/index.ts +3 -3
  87. package/src/components/CartList/CartList.tsx +3 -3
  88. package/src/components/CartList/index.ts +3 -3
  89. package/src/components/Checkbox/Checkbox.stories.tsx +17 -14
  90. package/src/components/Checkbox/Checkbox.tsx +8 -6
  91. package/src/components/Checkbox/index.ts +3 -3
  92. package/src/components/ColorSwatch/ColorSwatch.css +8 -4
  93. package/src/components/ColorSwatch/ColorSwatch.stories.tsx +6 -6
  94. package/src/components/ColorSwatch/ColorSwatch.tsx +8 -6
  95. package/src/components/ColorSwatch/index.ts +3 -3
  96. package/src/components/ContentGrid/ContentGrid.css +15 -15
  97. package/src/components/ContentGrid/ContentGrid.stories.tsx +4 -4
  98. package/src/components/ContentGrid/ContentGrid.tsx +3 -3
  99. package/src/components/ContentGrid/index.ts +3 -3
  100. package/src/components/Divider/Divider.stories.tsx +7 -4
  101. package/src/components/Divider/Divider.tsx +3 -3
  102. package/src/components/Divider/index.ts +4 -4
  103. package/src/components/Field/Field.stories.tsx +7 -7
  104. package/src/components/Field/Field.tsx +4 -2
  105. package/src/components/Field/index.ts +3 -3
  106. package/src/components/Header/Header.stories.tsx +9 -10
  107. package/src/components/Header/Header.tsx +11 -7
  108. package/src/components/Header/index.ts +3 -3
  109. package/src/components/Icon/Icon.stories.helpers.jsx +4 -4
  110. package/src/components/Icon/Icon.stories.tsx +74 -60
  111. package/src/components/Icon/Icon.tsx +77 -44
  112. package/src/components/Icon/index.ts +3 -3
  113. package/src/components/IllustratedMessage/IllustratedMessage.stories.tsx +8 -8
  114. package/src/components/IllustratedMessage/IllustratedMessage.tsx +7 -5
  115. package/src/components/IllustratedMessage/index.ts +3 -3
  116. package/src/components/Image/Image.stories.tsx +3 -3
  117. package/src/components/Image/Image.tsx +4 -4
  118. package/src/components/Image/index.ts +3 -3
  119. package/src/components/ImageSwatch/ImageSwatch.css +8 -4
  120. package/src/components/ImageSwatch/ImageSwatch.stories.tsx +10 -10
  121. package/src/components/ImageSwatch/ImageSwatch.tsx +25 -23
  122. package/src/components/ImageSwatch/index.ts +3 -3
  123. package/src/components/InLineAlert/InLineAlert.stories.tsx +12 -7
  124. package/src/components/InLineAlert/InLineAlert.tsx +4 -2
  125. package/src/components/InLineAlert/index.ts +3 -3
  126. package/src/components/Incrementer/Incrementer.stories.tsx +9 -9
  127. package/src/components/Incrementer/Incrementer.tsx +75 -37
  128. package/src/components/Incrementer/index.ts +3 -3
  129. package/src/components/Input/Input.css +4 -1
  130. package/src/components/Input/Input.stories.tsx +5 -5
  131. package/src/components/Input/Input.tsx +5 -3
  132. package/src/components/Input/index.ts +3 -3
  133. package/src/components/InputDate/InputDate.tsx +3 -3
  134. package/src/components/InputDate/index.ts +3 -3
  135. package/src/components/InputFile/InputFile.css +16 -16
  136. package/src/components/InputFile/InputFile.stories.tsx +21 -16
  137. package/src/components/InputFile/InputFile.tsx +8 -6
  138. package/src/components/InputFile/index.ts +5 -5
  139. package/src/components/InputPassword/InputPassword.stories.tsx +4 -4
  140. package/src/components/InputPassword/InputPassword.tsx +5 -4
  141. package/src/components/InputPassword/PasswordStatusIndicator/PasswordStatusIndicator.tsx +1 -1
  142. package/src/components/InputPassword/PasswordStatusIndicator/index.ts +3 -3
  143. package/src/components/InputPassword/index.ts +3 -3
  144. package/src/components/Modal/Modal.stories.tsx +27 -16
  145. package/src/components/Modal/Modal.tsx +10 -11
  146. package/src/components/Modal/index.ts +3 -3
  147. package/src/components/MultiSelect/MultiSelect.stories.tsx +15 -15
  148. package/src/components/MultiSelect/MultiSelect.tsx +15 -15
  149. package/src/components/Pagination/Pagination.css +1 -1
  150. package/src/components/Pagination/Pagination.stories.tsx +0 -1
  151. package/src/components/Pagination/Pagination.tsx +17 -12
  152. package/src/components/Pagination/PaginationButton.tsx +2 -3
  153. package/src/components/Pagination/index.ts +3 -3
  154. package/src/components/Picker/Picker.css +3 -1
  155. package/src/components/Picker/Picker.stories.tsx +1 -1
  156. package/src/components/Picker/Picker.tsx +8 -6
  157. package/src/components/Picker/index.ts +3 -3
  158. package/src/components/Portal/Portal.stories.tsx +50 -44
  159. package/src/components/Portal/Portal.tsx +4 -4
  160. package/src/components/Price/Price.stories.tsx +3 -3
  161. package/src/components/Price/Price.tsx +4 -2
  162. package/src/components/Price/index.ts +3 -3
  163. package/src/components/PriceRange/PriceRange.stories.tsx +3 -3
  164. package/src/components/PriceRange/PriceRange.tsx +8 -6
  165. package/src/components/PriceRange/index.ts +3 -3
  166. package/src/components/ProductItemCard/ProductItemCard.tsx +4 -2
  167. package/src/components/ProductItemCard/ProductItemCardSkeleton.tsx +16 -16
  168. package/src/components/ProductItemCard/index.ts +4 -4
  169. package/src/components/ProgressSpinner/ProgressSpinner.stories.tsx +8 -8
  170. package/src/components/ProgressSpinner/ProgressSpinner.tsx +7 -5
  171. package/src/components/ProgressSpinner/index.ts +3 -3
  172. package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
  173. package/src/components/RadioButton/RadioButton.tsx +4 -2
  174. package/src/components/Skeleton/Skeleton.stories.tsx +4 -4
  175. package/src/components/Skeleton/Skeleton.tsx +11 -7
  176. package/src/components/Skeleton/index.ts +3 -3
  177. package/src/components/Table/Table.css +106 -99
  178. package/src/components/Table/Table.stories.tsx +404 -227
  179. package/src/components/Table/Table.tsx +11 -7
  180. package/src/components/Table/index.ts +4 -4
  181. package/src/components/Tag/Tag.stories.tsx +6 -6
  182. package/src/components/Tag/Tag.tsx +7 -5
  183. package/src/components/Tag/index.ts +3 -3
  184. package/src/components/TextArea/TextArea.css +3 -1
  185. package/src/components/TextArea/TextArea.stories.tsx +9 -6
  186. package/src/components/TextArea/TextArea.tsx +3 -3
  187. package/src/components/TextArea/index.ts +3 -3
  188. package/src/components/TextSwatch/TextSwatch.css +4 -2
  189. package/src/components/TextSwatch/TextSwatch.stories.tsx +8 -8
  190. package/src/components/TextSwatch/TextSwatch.tsx +12 -7
  191. package/src/components/TextSwatch/index.ts +3 -3
  192. package/src/components/ToggleButton/ToggleButton.css +6 -2
  193. package/src/components/ToggleButton/ToggleButton.stories.tsx +10 -6
  194. package/src/components/ToggleButton/ToggleButton.tsx +8 -3
  195. package/src/components/ToggleButton/index.ts +3 -3
  196. package/src/components/UIProvider/UIProvider.css +3 -2
  197. package/src/components/UIProvider/UIProvider.tsx +11 -7
  198. package/src/components/UIProvider/debugger.css +5 -6
  199. package/src/components/UIProvider/index.ts +3 -3
  200. package/src/docs/API/event-bus.mdx +64 -37
  201. package/src/docs/API/graphql.mdx +69 -36
  202. package/src/docs/API/initializer.mdx +58 -35
  203. package/src/docs/API/render.mdx +45 -32
  204. package/src/docs/Design/colors.mdx +10 -12
  205. package/src/docs/Design/grid.mdx +41 -14
  206. package/src/docs/Design/overview.mdx +20 -4
  207. package/src/docs/Design/shapes.mdx +8 -7
  208. package/src/docs/Design/spacing.mdx +3 -1
  209. package/src/docs/Design/typography.mdx +3 -2
  210. package/src/docs/Utilities/VComponent.mdx +27 -10
  211. package/src/docs/Utilities/classList.mdx +7 -5
  212. package/src/docs/Utilities/debounce.mdx +6 -7
  213. package/src/docs/Utilities/getCookie.mdx +1 -2
  214. package/src/docs/Utilities/getFormErrors.mdx +1 -2
  215. package/src/docs/Utilities/getFormValues.mdx +1 -2
  216. package/src/docs/Utilities/getPathValue.mdx +2 -4
  217. package/src/docs/Utilities/links.mdx +16 -7
  218. package/src/docs/cli-usage.mdx +8 -3
  219. package/src/docs/components/overview.mdx +14 -4
  220. package/src/docs/quick-start.mdx +69 -22
  221. package/src/docs/slots.mdx +74 -37
  222. package/src/docs/welcome.mdx +13 -4
  223. package/src/i18n/index.ts +3 -3
  224. package/src/lib/aem/assets.ts +9 -9
  225. package/src/lib/aem/configs.ts +16 -8
  226. package/src/lib/classes.ts +4 -4
  227. package/src/lib/config.ts +3 -3
  228. package/src/lib/debounce.ts +3 -3
  229. package/src/lib/deepmerge.ts +6 -13
  230. package/src/lib/deviceUtils.ts +3 -3
  231. package/src/lib/form-values.ts +3 -3
  232. package/src/lib/get-price-formatter.ts +8 -3
  233. package/src/lib/i18n.ts +3 -3
  234. package/src/lib/image-params-keymap.ts +4 -5
  235. package/src/lib/initializer.ts +11 -12
  236. package/src/lib/is-number.ts +3 -3
  237. package/src/lib/locale-config.ts +4 -4
  238. package/src/lib/render.tsx +14 -8
  239. package/src/lib/resolve-image.ts +19 -16
  240. package/src/lib/signals.ts +4 -4
  241. package/src/lib/slot.tsx +34 -27
  242. package/src/lib/tests.tsx +6 -8
  243. package/src/lib/types.ts +3 -3
  244. package/src/lib/vcomponent.tsx +3 -3
  245. package/src/shims/importmap.js +3107 -20
  246. package/static/assets/images/index.ts +3 -3
  247. package/storybook-stories.js +3 -3
  248. package/tests/__mocks__/browserMocks.ts +3 -3
  249. package/tests/__mocks__/fileMocks.ts +3 -3
@@ -135,7 +135,7 @@ function isValidFormat(format: unknown): format is AemAssetsFormat {
135
135
  function assertUnionParameter(
136
136
  value: unknown,
137
137
  validator: (value: unknown) => boolean,
138
- errorMessage: string
138
+ errorMessage: string,
139
139
  ): void {
140
140
  if (value !== undefined && !validator(value)) {
141
141
  throw new Error(errorMessage);
@@ -177,7 +177,7 @@ export function isAemAssetsUrl(url: string | URL): boolean {
177
177
  export function generateAemAssetsOptimizedUrl(
178
178
  assetUrl: string,
179
179
  alias: string,
180
- params: Partial<AemAssetsParams> = {}
180
+ params: Partial<AemAssetsParams> = {},
181
181
  ): string {
182
182
  const defaultParams = getDefaultAemAssetsOptimizationParams();
183
183
  const mergedParams: AemAssetsParams = { ...defaultParams, ...params };
@@ -189,11 +189,11 @@ export function generateAemAssetsOptimizedUrl(
189
189
  assertUnionParameter(
190
190
  optimizedParams.rotate,
191
191
  isValidRotation,
192
- 'Invalid rotation'
192
+ 'Invalid rotation',
193
193
  );
194
194
 
195
195
  const stringifiedParams = Object.fromEntries(
196
- Object.entries(optimizedParams).map(([key, value]) => [key, String(value)])
196
+ Object.entries(optimizedParams).map(([key, value]) => [key, String(value)]),
197
197
  );
198
198
 
199
199
  const searchParams = new URLSearchParams(stringifiedParams);
@@ -216,7 +216,7 @@ export function generateAemAssetsOptimizedUrl(
216
216
  export function tryGenerateAemAssetsOptimizedUrl(
217
217
  assetUrl: string,
218
218
  alias: string,
219
- params: Partial<AemAssetsParams> = {}
219
+ params: Partial<AemAssetsParams> = {},
220
220
  ): string {
221
221
  const assetsEnabled = isAemAssetsEnabled();
222
222
 
@@ -243,7 +243,7 @@ export function makeAemAssetsImageSlot(config: AemAssetsImageSlotConfig) {
243
243
 
244
244
  if (!imageProps.src) {
245
245
  throw new Error(
246
- 'An image source is required. Please provide a `src` or `imageProps.src`.'
246
+ 'An image source is required. Please provide a `src` or `imageProps.src`.',
247
247
  );
248
248
  }
249
249
 
@@ -251,7 +251,7 @@ export function makeAemAssetsImageSlot(config: AemAssetsImageSlotConfig) {
251
251
  const imageSrc = generateAemAssetsOptimizedUrl(
252
252
  imageProps.src,
253
253
  alias,
254
- params
254
+ params,
255
255
  );
256
256
 
257
257
  const imageComponentParams: ResolveImageUrlOptions = {
@@ -281,7 +281,7 @@ export function makeAemAssetsImageSlot(config: AemAssetsImageSlotConfig) {
281
281
 
282
282
  export function tryRenderAemAssetsImage(
283
283
  ctx: RenderContext,
284
- config: AemAssetsImageSlotConfig
284
+ config: AemAssetsImageSlotConfig,
285
285
  ): void {
286
286
  // Renders an equivalent of the default image.
287
287
  function renderDefaultImage(): void {
@@ -307,7 +307,7 @@ export function tryRenderAemAssetsImage(
307
307
 
308
308
  if (!config.imageProps.src) {
309
309
  throw new Error(
310
- 'An image source is required. Please provide a `src` or `imageProps.src`.'
310
+ 'An image source is required. Please provide a `src` or `imageProps.src`.',
311
311
  );
312
312
  }
313
313
 
@@ -42,7 +42,10 @@ function resetConfig() {
42
42
  * @param {Object} [configObj=config] - The config object.
43
43
  * @returns {string} - The root path.
44
44
  */
45
- function getRootPath(configObj: Config | null = config, optionsObj: { match?: (key: string) => boolean } | null = options): string {
45
+ function getRootPath(
46
+ configObj: Config | null = config,
47
+ optionsObj: { match?: (key: string) => boolean } | null = options,
48
+ ): string {
46
49
  if (!configObj) {
47
50
  console.warn('No config found. Please call initializeConfig() first.');
48
51
  return '/';
@@ -58,7 +61,7 @@ function getRootPath(configObj: Config | null = config, optionsObj: { match?: (k
58
61
  .find(
59
62
  (key) =>
60
63
  window.location.pathname === key ||
61
- (optionsObj?.match?.(key) ?? window.location.pathname.startsWith(key))
64
+ (optionsObj?.match?.(key) ?? window.location.pathname.startsWith(key)),
62
65
  );
63
66
 
64
67
  return value ?? '/';
@@ -74,7 +77,9 @@ function getListOfRootPaths(): string[] {
74
77
  return [];
75
78
  }
76
79
 
77
- return Object.keys(config.public).filter((root) => root !== 'default' && root.startsWith('/'));
80
+ return Object.keys(config.public).filter(
81
+ (root) => root !== 'default' && root.startsWith('/'),
82
+ );
78
83
  }
79
84
 
80
85
  /**
@@ -94,7 +99,7 @@ function isMultistore(): boolean {
94
99
  function getHeaders(scope: string): Record<string, string> {
95
100
  if (!rootConfig) {
96
101
  throw new Error(
97
- 'Configuration not initialized. Call initializeConfig() first.'
102
+ 'Configuration not initialized. Call initializeConfig() first.',
98
103
  );
99
104
  }
100
105
  const headers = rootConfig.headers ?? {};
@@ -113,7 +118,7 @@ function getHeaders(scope: string): Record<string, string> {
113
118
  */
114
119
  function applyConfigOverrides(
115
120
  configObj: Config | null,
116
- root: string | null
121
+ root: string | null,
117
122
  ): ConfigRoot {
118
123
  const defaultConfig = configObj!.public?.default;
119
124
 
@@ -122,7 +127,7 @@ function applyConfigOverrides(
122
127
 
123
128
  return deepmerge(
124
129
  defaultConfig,
125
- configObj!.public[root as keyof ConfigPublic]
130
+ configObj!.public[root as keyof ConfigPublic],
126
131
  );
127
132
  }
128
133
 
@@ -133,7 +138,10 @@ function applyConfigOverrides(
133
138
  * @param {Function} [options.match] - The function to match the path to the config.
134
139
  * @returns {Object} The initialized root configuration
135
140
  */
136
- function initializeConfig(configObj: Config, optionsObj?: { match?: (key: string) => boolean }): ConfigRoot {
141
+ function initializeConfig(
142
+ configObj: Config,
143
+ optionsObj?: { match?: (key: string) => boolean },
144
+ ): ConfigRoot {
137
145
  config = configObj;
138
146
  options = optionsObj ?? null;
139
147
  rootPath = getRootPath(config, { match: optionsObj?.match });
@@ -150,7 +158,7 @@ function initializeConfig(configObj: Config, optionsObj?: { match?: (key: string
150
158
  function getConfigValue(configParam: string): any {
151
159
  if (!rootConfig) {
152
160
  throw new Error(
153
- 'Configuration not initialized. Call initializeConfig() first.'
161
+ 'Configuration not initialized. Call initializeConfig() first.',
154
162
  );
155
163
  }
156
164
  return getPathValue(rootConfig, configParam);
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  // @ts-ignore
@@ -13,7 +13,7 @@ import { JSXInternal } from 'preact/src/jsx';
13
13
  type ClassName = string | JSXInternal.SignalLike<string | undefined>;
14
14
 
15
15
  export const classes = (
16
- classes: Array<ClassName | [ClassName, boolean] | undefined>
16
+ classes: Array<ClassName | [ClassName, boolean] | undefined>,
17
17
  ) => {
18
18
  const result = classes.reduce((result, item) => {
19
19
  if (!item) return result;
package/src/lib/config.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  export class Config<T> {
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  export const debounce = (fn: Function, ms: number) => {
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  import deepmerge from 'deepmerge';
@@ -19,7 +19,7 @@ const mergeOptions = {
19
19
  if (typeof destination[index] === 'undefined') {
20
20
  destination[index] = options.cloneUnlessOtherwiseSpecified(
21
21
  item,
22
- options
22
+ options,
23
23
  );
24
24
  } else if (options.isMergeableObject(item)) {
25
25
  destination[index] = deepmerge(target[index], item, options);
@@ -31,15 +31,8 @@ const mergeOptions = {
31
31
  },
32
32
  };
33
33
 
34
- export function merge<T>(
35
- prev: T,
36
- next?: { [key: string]: any }
37
- ) {
34
+ export function merge<T>(prev: T, next?: { [key: string]: any }) {
38
35
  if (!next) return prev;
39
36
 
40
- return deepmerge<T, { [key: string]: any }>(
41
- prev,
42
- next,
43
- mergeOptions
44
- );
37
+ return deepmerge<T, { [key: string]: any }>(prev, next, mergeOptions);
45
38
  }
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  export const isIOSMobileDevice = () => {
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  export const getFormValues = (form: HTMLFormElement) => {
@@ -28,7 +28,9 @@ export function getEffectiveLocale(locale?: string): string {
28
28
  return globalLocale;
29
29
  }
30
30
  // Fallback to browser locale or default
31
- return process.env.LOCALE && process.env.LOCALE !== 'undefined' ? process.env.LOCALE : 'en-US';
31
+ return process.env.LOCALE && process.env.LOCALE !== 'undefined'
32
+ ? process.env.LOCALE
33
+ : 'en-US';
32
34
  }
33
35
 
34
36
  /**
@@ -46,7 +48,7 @@ export function getEffectiveLocale(locale?: string): string {
46
48
  * const prices = [10.99, 25.50, 99.99].map(amount => formatter.format(amount));
47
49
  */
48
50
  export function getPriceFormatter(
49
- options: PriceFormatterOptions = {}
51
+ options: PriceFormatterOptions = {},
50
52
  ): Intl.NumberFormat {
51
53
  const { currency, locale, formatOptions = {} } = options;
52
54
  const effectiveLocale = getEffectiveLocale(locale);
@@ -63,7 +65,10 @@ export function getPriceFormatter(
63
65
  try {
64
66
  return new Intl.NumberFormat(effectiveLocale, params);
65
67
  } catch (error) {
66
- console.error(`Error creating Intl.NumberFormat instance for locale ${effectiveLocale}. Falling back to en-US.`, error);
68
+ console.error(
69
+ `Error creating Intl.NumberFormat instance for locale ${effectiveLocale}. Falling back to en-US.`,
70
+ error,
71
+ );
67
72
  return new Intl.NumberFormat('en-US', params);
68
73
  }
69
74
  }
package/src/lib/i18n.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  /**
@@ -2,15 +2,14 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  class ImageParamsKeyMap {
11
11
  private _map:
12
- | { [key: string]: string | ((data: any) => [string, string]) }
13
- | undefined;
12
+ { [key: string]: string | ((data: any) => [string, string]) } | undefined;
14
13
 
15
14
  get map() {
16
15
  return this._map;
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  import {
@@ -52,8 +52,7 @@ export class Initializer<T> {
52
52
  };
53
53
 
54
54
  this.init = (options) => {
55
- const { imageParamsKeyMap, globalLocale, ...rest } =
56
- options as any;
55
+ const { imageParamsKeyMap, globalLocale, ...rest } = options as any;
57
56
  this.config.setConfig({ ...this.config.getConfig(), ...rest });
58
57
  setImageParamsKeyMap(imageParamsKeyMap);
59
58
  setGlobalLocale(globalLocale);
@@ -85,7 +84,7 @@ export class initializers {
85
84
  */
86
85
  static register(
87
86
  initializer: Initializer<any>,
88
- options?: { [key: string]: any }
87
+ options?: { [key: string]: any },
89
88
  ) {
90
89
  if (initializers._mounted) {
91
90
  initializer.listeners?.(options);
@@ -99,14 +98,14 @@ export class initializers {
99
98
  */
100
99
  static async mountImmediately(
101
100
  initializer: Initializer<any>,
102
- options?: { [key: string]: any }
101
+ options?: { [key: string]: any },
103
102
  ) {
104
103
  initializer.listeners?.(options);
105
- await initializer.init?.({
106
- imageParamsKeyMap: initializers._imageParamsKeyMap,
107
- globalLocale: initializers._globalLocale,
108
- ...options,
109
- });
104
+ await initializer.init?.({
105
+ imageParamsKeyMap: initializers._imageParamsKeyMap,
106
+ globalLocale: initializers._globalLocale,
107
+ ...options,
108
+ });
110
109
  }
111
110
 
112
111
  /**
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  export const isNumber = (value: number | string): value is number => {
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  class LocaleConfig {
@@ -31,4 +31,4 @@ class LocaleConfig {
31
31
  const localeConfig = new LocaleConfig();
32
32
 
33
33
  export const { setLocale: setGlobalLocale, getLocale: getGlobalLocale } =
34
- localeConfig.getMethods();
34
+ localeConfig.getMethods();
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  import { render, VNode, createContext } from 'preact';
@@ -77,7 +77,10 @@ export class Render {
77
77
  // apply base design tokens and global styles to the root element
78
78
  rootElement.classList.add('dropin-design');
79
79
  if (Component.displayName) {
80
- rootElement.setAttribute('data-dropin-container', Component.displayName);
80
+ rootElement.setAttribute(
81
+ 'data-dropin-container',
82
+ Component.displayName,
83
+ );
81
84
  }
82
85
 
83
86
  // store the virtual root element
@@ -149,7 +152,7 @@ export class Render {
149
152
  <Component {...props} initialData={initialData} />
150
153
  </VComponent>,
151
154
  {},
152
- { ...options }
155
+ { ...options },
153
156
  );
154
157
  }
155
158
  }
@@ -163,7 +166,10 @@ let _debuggerStyleEl: HTMLStyleElement | null = null;
163
166
 
164
167
  // @ts-ignore
165
168
  window.DROPINS.showOverlays = async (state: boolean) => {
166
- window.sessionStorage.setItem('dropin-debugger--show-overlays', state.toString());
169
+ window.sessionStorage.setItem(
170
+ 'dropin-debugger--show-overlays',
171
+ state.toString(),
172
+ );
167
173
 
168
174
  if (state && !_debuggerStyleEl) {
169
175
  _debuggerStyleEl = document.createElement('style');
@@ -182,5 +188,5 @@ window.DROPINS.showOverlays = async (state: boolean) => {
182
188
 
183
189
  // @ts-ignore
184
190
  window.DROPINS.showOverlays(
185
- window.sessionStorage.getItem('dropin-debugger--show-overlays') === 'true'
186
- );
191
+ window.sessionStorage.getItem('dropin-debugger--show-overlays') === 'true',
192
+ );
@@ -2,9 +2,9 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  import { getImageParamsKeyMap } from '@adobe-commerce/elsie/lib/';
@@ -36,17 +36,20 @@ const resolveImageUrl = (url: string, _opts?: ResolveImageUrlOptions) => {
36
36
  const unusedMapping = { ...keyMapping };
37
37
 
38
38
  if (keyMappingKeys?.length > 0 && _opts) {
39
- opts = Object.entries(_opts).reduce((acc, [key, value]) => {
40
- const newKey = keyMapping![key];
41
- if (typeof newKey === 'string') {
42
- acc[newKey] = value;
43
- } else if (typeof newKey === 'function') {
44
- const [newKeyString, newValue] = newKey(value);
45
- acc[newKeyString] = newValue;
46
- }
47
- delete unusedMapping![key];
48
- return acc;
49
- }, {} as { [key: string]: any });
39
+ opts = Object.entries(_opts).reduce(
40
+ (acc, [key, value]) => {
41
+ const newKey = keyMapping![key];
42
+ if (typeof newKey === 'string') {
43
+ acc[newKey] = value;
44
+ } else if (typeof newKey === 'function') {
45
+ const [newKeyString, newValue] = newKey(value);
46
+ acc[newKeyString] = newValue;
47
+ }
48
+ delete unusedMapping![key];
49
+ return acc;
50
+ },
51
+ {} as { [key: string]: any },
52
+ );
50
53
  } else {
51
54
  opts = {
52
55
  auto: 'webp',
@@ -77,7 +80,7 @@ const resolveImageUrl = (url: string, _opts?: ResolveImageUrlOptions) => {
77
80
 
78
81
  export const generateSrcset = (
79
82
  imageURL: string,
80
- options: ResolveImageUrlOptions
83
+ options: ResolveImageUrlOptions,
81
84
  ) => {
82
85
  if (!imageURL || !options?.width) return;
83
86
 
@@ -90,7 +93,7 @@ export const generateSrcset = (
90
93
  return Object.entries(BREAKPOINTS)
91
94
  .map(([, value]) => {
92
95
  const relativeWidth = Math.round(
93
- (options.width * value) / BREAKPOINTS.xxlarge
96
+ (options.width * value) / BREAKPOINTS.xxlarge,
94
97
  );
95
98
 
96
99
  return `${generateSrcsetUrl({
@@ -2,10 +2,10 @@
2
2
  * Copyright 2024 Adobe
3
3
  * All Rights Reserved.
4
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.
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
8
  *******************************************************************/
9
9
 
10
10
  // eslint-disable-next-line no-restricted-imports
11
- export * from '@preact/signals';
11
+ export * from '@preact/signals';