@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.
- package/.elsie.js +3 -3
- package/CHANGELOG.md +385 -112
- package/LICENSE.md +257 -157
- package/README.md +4 -2
- package/__mocks__/svg.js +3 -3
- package/bin/builders/build/index.js +2 -1
- package/bin/builders/changeset/index.js +1 -1
- package/bin/builders/concurrently/index.js +1 -1
- package/bin/builders/generate/api/index.js +7 -7
- package/bin/builders/generate/component/index.js +8 -8
- package/bin/builders/generate/config/index.js +5 -5
- package/bin/builders/generate/config/templates/elsie.js +1 -1
- package/bin/builders/generate/container/index.js +7 -7
- package/bin/builders/generate/index.js +36 -36
- package/bin/builders/gql/index.js +28 -28
- package/bin/builders/gql/validate.js +116 -105
- package/bin/builders/lint/index.js +1 -1
- package/bin/builders/serve/index.js +1 -1
- package/bin/builders/storybook/index.js +9 -1
- package/bin/builders/types/index.js +1 -2
- package/bin/builders/types/validate-tsconfig.js +5 -5
- package/bin/index.js +12 -6
- package/bin/lib/cli.js +9 -8
- package/bin/lib/resolve-bin.js +9 -0
- package/bin/lib/validate-typeof.js +3 -3
- package/bin/lib/write-file.js +3 -3
- package/bin/lib/write-parent-index.js +4 -4
- package/config/eslint.mjs +2 -1
- package/config/jest.mjs +7 -2
- package/config/plugins/dts-normalize-relative-replacer.cjs +1 -1
- package/config/plugins/dts.mjs +4 -3
- package/config/prettier.json +25 -3
- package/config/setEnvVars.mjs +2 -2
- package/config/storybook/addon.js +5 -5
- package/config/storybook/components/FileTree/FileTree.jsx +4 -4
- package/config/storybook/components/FileTree/index.js +4 -4
- package/config/storybook/components/Flex/Flex.jsx +3 -3
- package/config/storybook/components/Flex/index.js +3 -3
- package/config/storybook/components/OptionsTable/OptionsTable.jsx +3 -3
- package/config/storybook/components/OptionsTable/index.js +4 -4
- package/config/storybook/components/Panel/Panel.tsx +7 -7
- package/config/storybook/components/Panel/index.ts +3 -3
- package/config/storybook/components/Screenshot/Screenshot.jsx +3 -3
- package/config/storybook/components/Screenshot/index.js +4 -4
- package/config/storybook/components/Steps/Steps.jsx +3 -3
- package/config/storybook/components/Steps/index.js +4 -4
- package/config/storybook/components/StoryWrapper/StoryWrapper.jsx +3 -3
- package/config/storybook/components/StoryWrapper/index.js +3 -3
- package/config/storybook/components/Summary/Summary.jsx +3 -3
- package/config/storybook/components/Summary/index.js +3 -3
- package/config/storybook/components/Variants/Variants.jsx +11 -7
- package/config/storybook/components/Variants/index.js +3 -3
- package/config/storybook/manager.js +3 -3
- package/config/storybook/preview.jsx +3 -3
- package/config/storybook/theming/fonts.css +12 -4
- package/config/storybook/theming/preview.css +3 -1
- package/config/storybook/theming/theme.js +3 -3
- package/config/vite.mjs +53 -26
- package/package.json +36 -34
- package/src/components/Accordion/Accordion.css +1 -1
- package/src/components/Accordion/Accordion.stories.tsx +18 -18
- package/src/components/Accordion/Accordion.tsx +12 -8
- package/src/components/Accordion/index.ts +3 -3
- package/src/components/ActionButton/ActionButton.stories.tsx +8 -8
- package/src/components/ActionButton/ActionButton.tsx +7 -5
- package/src/components/ActionButton/index.ts +3 -3
- package/src/components/ActionButtonGroup/ActionButtonGroup.stories.tsx +3 -3
- package/src/components/ActionButtonGroup/ActionButtonGroup.tsx +2 -2
- package/src/components/ActionButtonGroup/index.ts +3 -3
- package/src/components/AlertBanner/AlertBanner.stories.tsx +6 -6
- package/src/components/AlertBanner/AlertBanner.tsx +12 -10
- package/src/components/AlertBanner/index.ts +3 -3
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +14 -14
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +3 -3
- package/src/components/Breadcrumbs/index.ts +3 -3
- package/src/components/Button/Button.mdx +24 -11
- package/src/components/Button/Button.stories.tsx +6 -6
- package/src/components/Button/Button.tsx +7 -8
- package/src/components/Button/index.ts +3 -3
- package/src/components/Card/Card.stories.tsx +6 -6
- package/src/components/Card/Card.tsx +3 -3
- package/src/components/Card/index.ts +3 -3
- package/src/components/CartItem/CartItem.stories.tsx +12 -12
- package/src/components/CartItem/CartItem.tsx +4 -2
- package/src/components/CartItem/CartItemSkeleton.tsx +3 -3
- package/src/components/CartItem/index.ts +3 -3
- package/src/components/CartList/CartList.tsx +3 -3
- package/src/components/CartList/index.ts +3 -3
- package/src/components/Checkbox/Checkbox.stories.tsx +17 -14
- package/src/components/Checkbox/Checkbox.tsx +8 -6
- package/src/components/Checkbox/index.ts +3 -3
- package/src/components/ColorSwatch/ColorSwatch.css +8 -4
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +6 -6
- package/src/components/ColorSwatch/ColorSwatch.tsx +8 -6
- package/src/components/ColorSwatch/index.ts +3 -3
- package/src/components/ContentGrid/ContentGrid.css +15 -15
- package/src/components/ContentGrid/ContentGrid.stories.tsx +4 -4
- package/src/components/ContentGrid/ContentGrid.tsx +3 -3
- package/src/components/ContentGrid/index.ts +3 -3
- package/src/components/Divider/Divider.stories.tsx +7 -4
- package/src/components/Divider/Divider.tsx +3 -3
- package/src/components/Divider/index.ts +4 -4
- package/src/components/Field/Field.stories.tsx +7 -7
- package/src/components/Field/Field.tsx +4 -2
- package/src/components/Field/index.ts +3 -3
- package/src/components/Header/Header.stories.tsx +9 -10
- package/src/components/Header/Header.tsx +11 -7
- package/src/components/Header/index.ts +3 -3
- package/src/components/Icon/Icon.stories.helpers.jsx +4 -4
- package/src/components/Icon/Icon.stories.tsx +74 -60
- package/src/components/Icon/Icon.tsx +77 -44
- package/src/components/Icon/index.ts +3 -3
- package/src/components/IllustratedMessage/IllustratedMessage.stories.tsx +8 -8
- package/src/components/IllustratedMessage/IllustratedMessage.tsx +7 -5
- package/src/components/IllustratedMessage/index.ts +3 -3
- package/src/components/Image/Image.stories.tsx +3 -3
- package/src/components/Image/Image.tsx +4 -4
- package/src/components/Image/index.ts +3 -3
- package/src/components/ImageSwatch/ImageSwatch.css +8 -4
- package/src/components/ImageSwatch/ImageSwatch.stories.tsx +10 -10
- package/src/components/ImageSwatch/ImageSwatch.tsx +25 -23
- package/src/components/ImageSwatch/index.ts +3 -3
- package/src/components/InLineAlert/InLineAlert.stories.tsx +12 -7
- package/src/components/InLineAlert/InLineAlert.tsx +4 -2
- package/src/components/InLineAlert/index.ts +3 -3
- package/src/components/Incrementer/Incrementer.stories.tsx +9 -9
- package/src/components/Incrementer/Incrementer.tsx +75 -37
- package/src/components/Incrementer/index.ts +3 -3
- package/src/components/Input/Input.css +4 -1
- package/src/components/Input/Input.stories.tsx +5 -5
- package/src/components/Input/Input.tsx +5 -3
- package/src/components/Input/index.ts +3 -3
- package/src/components/InputDate/InputDate.tsx +3 -3
- package/src/components/InputDate/index.ts +3 -3
- package/src/components/InputFile/InputFile.css +16 -16
- package/src/components/InputFile/InputFile.stories.tsx +21 -16
- package/src/components/InputFile/InputFile.tsx +8 -6
- package/src/components/InputFile/index.ts +5 -5
- package/src/components/InputPassword/InputPassword.stories.tsx +4 -4
- package/src/components/InputPassword/InputPassword.tsx +5 -4
- package/src/components/InputPassword/PasswordStatusIndicator/PasswordStatusIndicator.tsx +1 -1
- package/src/components/InputPassword/PasswordStatusIndicator/index.ts +3 -3
- package/src/components/InputPassword/index.ts +3 -3
- package/src/components/Modal/Modal.stories.tsx +27 -16
- package/src/components/Modal/Modal.tsx +10 -11
- package/src/components/Modal/index.ts +3 -3
- package/src/components/MultiSelect/MultiSelect.stories.tsx +15 -15
- package/src/components/MultiSelect/MultiSelect.tsx +15 -15
- package/src/components/Pagination/Pagination.css +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +0 -1
- package/src/components/Pagination/Pagination.tsx +17 -12
- package/src/components/Pagination/PaginationButton.tsx +2 -3
- package/src/components/Pagination/index.ts +3 -3
- package/src/components/Picker/Picker.css +3 -1
- package/src/components/Picker/Picker.stories.tsx +1 -1
- package/src/components/Picker/Picker.tsx +8 -6
- package/src/components/Picker/index.ts +3 -3
- package/src/components/Portal/Portal.stories.tsx +50 -44
- package/src/components/Portal/Portal.tsx +4 -4
- package/src/components/Price/Price.stories.tsx +3 -3
- package/src/components/Price/Price.tsx +4 -2
- package/src/components/Price/index.ts +3 -3
- package/src/components/PriceRange/PriceRange.stories.tsx +3 -3
- package/src/components/PriceRange/PriceRange.tsx +8 -6
- package/src/components/PriceRange/index.ts +3 -3
- package/src/components/ProductItemCard/ProductItemCard.tsx +4 -2
- package/src/components/ProductItemCard/ProductItemCardSkeleton.tsx +16 -16
- package/src/components/ProductItemCard/index.ts +4 -4
- package/src/components/ProgressSpinner/ProgressSpinner.stories.tsx +8 -8
- package/src/components/ProgressSpinner/ProgressSpinner.tsx +7 -5
- package/src/components/ProgressSpinner/index.ts +3 -3
- package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
- package/src/components/RadioButton/RadioButton.tsx +4 -2
- package/src/components/Skeleton/Skeleton.stories.tsx +4 -4
- package/src/components/Skeleton/Skeleton.tsx +11 -7
- package/src/components/Skeleton/index.ts +3 -3
- package/src/components/Table/Table.css +106 -99
- package/src/components/Table/Table.stories.tsx +404 -227
- package/src/components/Table/Table.tsx +11 -7
- package/src/components/Table/index.ts +4 -4
- package/src/components/Tag/Tag.stories.tsx +6 -6
- package/src/components/Tag/Tag.tsx +7 -5
- package/src/components/Tag/index.ts +3 -3
- package/src/components/TextArea/TextArea.css +3 -1
- package/src/components/TextArea/TextArea.stories.tsx +9 -6
- package/src/components/TextArea/TextArea.tsx +3 -3
- package/src/components/TextArea/index.ts +3 -3
- package/src/components/TextSwatch/TextSwatch.css +4 -2
- package/src/components/TextSwatch/TextSwatch.stories.tsx +8 -8
- package/src/components/TextSwatch/TextSwatch.tsx +12 -7
- package/src/components/TextSwatch/index.ts +3 -3
- package/src/components/ToggleButton/ToggleButton.css +6 -2
- package/src/components/ToggleButton/ToggleButton.stories.tsx +10 -6
- package/src/components/ToggleButton/ToggleButton.tsx +8 -3
- package/src/components/ToggleButton/index.ts +3 -3
- package/src/components/UIProvider/UIProvider.css +3 -2
- package/src/components/UIProvider/UIProvider.tsx +11 -7
- package/src/components/UIProvider/debugger.css +5 -6
- package/src/components/UIProvider/index.ts +3 -3
- package/src/docs/API/event-bus.mdx +64 -37
- package/src/docs/API/graphql.mdx +69 -36
- package/src/docs/API/initializer.mdx +58 -35
- package/src/docs/API/render.mdx +45 -32
- package/src/docs/Design/colors.mdx +10 -12
- package/src/docs/Design/grid.mdx +41 -14
- package/src/docs/Design/overview.mdx +20 -4
- package/src/docs/Design/shapes.mdx +8 -7
- package/src/docs/Design/spacing.mdx +3 -1
- package/src/docs/Design/typography.mdx +3 -2
- package/src/docs/Utilities/VComponent.mdx +27 -10
- package/src/docs/Utilities/classList.mdx +7 -5
- package/src/docs/Utilities/debounce.mdx +6 -7
- package/src/docs/Utilities/getCookie.mdx +1 -2
- package/src/docs/Utilities/getFormErrors.mdx +1 -2
- package/src/docs/Utilities/getFormValues.mdx +1 -2
- package/src/docs/Utilities/getPathValue.mdx +2 -4
- package/src/docs/Utilities/links.mdx +16 -7
- package/src/docs/cli-usage.mdx +8 -3
- package/src/docs/components/overview.mdx +14 -4
- package/src/docs/quick-start.mdx +69 -22
- package/src/docs/slots.mdx +74 -37
- package/src/docs/welcome.mdx +13 -4
- package/src/i18n/index.ts +3 -3
- package/src/lib/aem/assets.ts +9 -9
- package/src/lib/aem/configs.ts +16 -8
- package/src/lib/classes.ts +4 -4
- package/src/lib/config.ts +3 -3
- package/src/lib/debounce.ts +3 -3
- package/src/lib/deepmerge.ts +6 -13
- package/src/lib/deviceUtils.ts +3 -3
- package/src/lib/form-values.ts +3 -3
- package/src/lib/get-price-formatter.ts +8 -3
- package/src/lib/i18n.ts +3 -3
- package/src/lib/image-params-keymap.ts +4 -5
- package/src/lib/initializer.ts +11 -12
- package/src/lib/is-number.ts +3 -3
- package/src/lib/locale-config.ts +4 -4
- package/src/lib/render.tsx +14 -8
- package/src/lib/resolve-image.ts +19 -16
- package/src/lib/signals.ts +4 -4
- package/src/lib/slot.tsx +34 -27
- package/src/lib/tests.tsx +6 -8
- package/src/lib/types.ts +3 -3
- package/src/lib/vcomponent.tsx +3 -3
- package/src/shims/importmap.js +3107 -20
- package/static/assets/images/index.ts +3 -3
- package/storybook-stories.js +3 -3
- package/tests/__mocks__/browserMocks.ts +3 -3
- package/tests/__mocks__/fileMocks.ts +3 -3
package/src/lib/aem/assets.ts
CHANGED
|
@@ -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
|
|
package/src/lib/aem/configs.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
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(
|
|
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);
|
package/src/lib/classes.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
|
// @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> {
|
package/src/lib/debounce.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 const debounce = (fn: Function, ms: number) => {
|
package/src/lib/deepmerge.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
|
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
|
}
|
package/src/lib/deviceUtils.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 const isIOSMobileDevice = () => {
|
package/src/lib/form-values.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 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'
|
|
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(
|
|
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
|
-
|
|
13
|
-
| undefined;
|
|
12
|
+
{ [key: string]: string | ((data: any) => [string, string]) } | undefined;
|
|
14
13
|
|
|
15
14
|
get map() {
|
|
16
15
|
return this._map;
|
package/src/lib/initializer.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
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
await initializer.init?.({
|
|
105
|
+
imageParamsKeyMap: initializers._imageParamsKeyMap,
|
|
106
|
+
globalLocale: initializers._globalLocale,
|
|
107
|
+
...options,
|
|
108
|
+
});
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
/**
|
package/src/lib/is-number.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 const isNumber = (value: number | string): value is number => {
|
package/src/lib/locale-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
|
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();
|
package/src/lib/render.tsx
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
|
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(
|
|
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(
|
|
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
|
+
);
|
package/src/lib/resolve-image.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
|
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(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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({
|
package/src/lib/signals.ts
CHANGED
|
@@ -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';
|