@gem-sdk/components 2.0.0-dev.707 → 2.0.0-dev.709

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.
@@ -75,7 +75,7 @@ const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNot
75
75
  const bg = core.getValueByDevice(background, device);
76
76
  result = {
77
77
  ...result,
78
- [device]: bg.type === 'color' ? 'url()' : `url('${!enableLazyImage ? getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
78
+ [device]: bg?.type === 'color' ? 'url()' : `url('${!enableLazyImage ? getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
79
79
  };
80
80
  });
81
81
  return core.makeStyleResponsive('bgi', result);
@@ -457,8 +457,8 @@ const showVideoType = (background)=>{
457
457
  ];
458
458
  return DEVICES.some((item)=>{
459
459
  const bg = core.getValueByDevice(background, item);
460
- if (bg.type === 'color' || bg.type === 'image') return false;
461
- if (bg) return bg.videoType === 'html5' && bg.videoHtml5 || bg.videoType === 'youtube' && bg.video;
460
+ if (bg?.type === 'color' || bg?.type === 'image') return false;
461
+ if (bg) return bg?.videoType === 'html5' && bg?.videoHtml5 || bg?.videoType === 'youtube' && bg?.video;
462
462
  return false;
463
463
  });
464
464
  };
@@ -11,7 +11,7 @@ const checkHasBackgroundVideo = (background)=>{
11
11
  ];
12
12
  return DEVICES.some((item)=>{
13
13
  const bg = core.getValueByDevice(background, item);
14
- if (bg) return bg.videoType === 'html5' && bg.videoHtml5 || bg.videoType === 'youtube' && bg.video;
14
+ if (bg) return bg?.videoType === 'html5' && bg?.videoHtml5 || bg?.videoType === 'youtube' && bg?.video;
15
15
  return false;
16
16
  });
17
17
  };
@@ -5,31 +5,21 @@ var helpers = require('../../../../helpers.js');
5
5
  const getButtonDynamicSourceLocales = ({ setting, builderProps, pageContext })=>{
6
6
  const baseProps = {
7
7
  pageContext,
8
- isLiquid: true,
9
8
  uid: builderProps?.uid
10
9
  };
11
- const variantSelectionRequiredMessage = helpers.getDynamicSourceLocales({
12
- ...baseProps,
13
- translate: setting?.translate,
14
- settingId: 'variantSelectionRequiredMessage',
15
- val: setting?.variantSelectionRequiredMessage
16
- });
17
- const unavailableButtonLabel = helpers.getDynamicSourceLocales({
18
- ...baseProps,
19
- val: 'Unavailable',
20
- settingId: 'unavailableLabel',
21
- translate: setting?.translate ? 'unavailableLabel' : undefined
22
- });
23
- const outOfStockButtonLabel = helpers.getDynamicSourceLocales({
24
- ...baseProps,
25
- settingId: 'outOfStockLabel',
26
- val: setting?.outOfStockLabel,
27
- translate: setting?.translate ? 'outOfStockLabel' : undefined
28
- });
10
+ const getLocale = (settingId, val, translate)=>{
11
+ const locale = helpers.getDynamicSourceLocales({
12
+ ...baseProps,
13
+ translate: setting?.translate ? translate : undefined,
14
+ settingId,
15
+ val: val ?? ''
16
+ });
17
+ return locale;
18
+ };
29
19
  return {
30
- outOfStockButtonLabel: pageContext?.isPreviewing ? outOfStockButtonLabel : `{{${outOfStockButtonLabel}}}`,
31
- unavailableButtonLabel: pageContext?.isPreviewing ? unavailableButtonLabel : `{{${unavailableButtonLabel}}}`,
32
- variantSelectionRequiredMessage: pageContext?.isPreviewing ? variantSelectionRequiredMessage : `{{${variantSelectionRequiredMessage}}}`
20
+ outOfStockButtonLabel: getLocale('outOfStockLabel', setting?.outOfStockLabel, 'outOfStockLabel'),
21
+ unavailableButtonLabel: getLocale('unavailableLabel', 'Unavailable', 'unavailableLabel'),
22
+ variantSelectionRequiredMessage: getLocale('variantSelectionRequiredMessage', setting?.variantSelectionRequiredMessage, 'variantSelectionRequiredMessage')
33
23
  };
34
24
  };
35
25
 
@@ -73,7 +73,7 @@ const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNot
73
73
  const bg = getValueByDevice(background, device);
74
74
  result = {
75
75
  ...result,
76
- [device]: bg.type === 'color' ? 'url()' : `url('${!enableLazyImage ? getImageSrc(getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
76
+ [device]: bg?.type === 'color' ? 'url()' : `url('${!enableLazyImage ? getImageSrc(getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
77
77
  };
78
78
  });
79
79
  return makeStyleResponsive('bgi', result);
@@ -455,8 +455,8 @@ const showVideoType = (background)=>{
455
455
  ];
456
456
  return DEVICES.some((item)=>{
457
457
  const bg = getValueByDevice(background, item);
458
- if (bg.type === 'color' || bg.type === 'image') return false;
459
- if (bg) return bg.videoType === 'html5' && bg.videoHtml5 || bg.videoType === 'youtube' && bg.video;
458
+ if (bg?.type === 'color' || bg?.type === 'image') return false;
459
+ if (bg) return bg?.videoType === 'html5' && bg?.videoHtml5 || bg?.videoType === 'youtube' && bg?.video;
460
460
  return false;
461
461
  });
462
462
  };
@@ -9,7 +9,7 @@ const checkHasBackgroundVideo = (background)=>{
9
9
  ];
10
10
  return DEVICES.some((item)=>{
11
11
  const bg = getValueByDevice(background, item);
12
- if (bg) return bg.videoType === 'html5' && bg.videoHtml5 || bg.videoType === 'youtube' && bg.video;
12
+ if (bg) return bg?.videoType === 'html5' && bg?.videoHtml5 || bg?.videoType === 'youtube' && bg?.video;
13
13
  return false;
14
14
  });
15
15
  };
@@ -3,31 +3,21 @@ import { getDynamicSourceLocales } from '../../../../helpers.js';
3
3
  const getButtonDynamicSourceLocales = ({ setting, builderProps, pageContext })=>{
4
4
  const baseProps = {
5
5
  pageContext,
6
- isLiquid: true,
7
6
  uid: builderProps?.uid
8
7
  };
9
- const variantSelectionRequiredMessage = getDynamicSourceLocales({
10
- ...baseProps,
11
- translate: setting?.translate,
12
- settingId: 'variantSelectionRequiredMessage',
13
- val: setting?.variantSelectionRequiredMessage
14
- });
15
- const unavailableButtonLabel = getDynamicSourceLocales({
16
- ...baseProps,
17
- val: 'Unavailable',
18
- settingId: 'unavailableLabel',
19
- translate: setting?.translate ? 'unavailableLabel' : undefined
20
- });
21
- const outOfStockButtonLabel = getDynamicSourceLocales({
22
- ...baseProps,
23
- settingId: 'outOfStockLabel',
24
- val: setting?.outOfStockLabel,
25
- translate: setting?.translate ? 'outOfStockLabel' : undefined
26
- });
8
+ const getLocale = (settingId, val, translate)=>{
9
+ const locale = getDynamicSourceLocales({
10
+ ...baseProps,
11
+ translate: setting?.translate ? translate : undefined,
12
+ settingId,
13
+ val: val ?? ''
14
+ });
15
+ return locale;
16
+ };
27
17
  return {
28
- outOfStockButtonLabel: pageContext?.isPreviewing ? outOfStockButtonLabel : `{{${outOfStockButtonLabel}}}`,
29
- unavailableButtonLabel: pageContext?.isPreviewing ? unavailableButtonLabel : `{{${unavailableButtonLabel}}}`,
30
- variantSelectionRequiredMessage: pageContext?.isPreviewing ? variantSelectionRequiredMessage : `{{${variantSelectionRequiredMessage}}}`
18
+ outOfStockButtonLabel: getLocale('outOfStockLabel', setting?.outOfStockLabel, 'outOfStockLabel'),
19
+ unavailableButtonLabel: getLocale('unavailableLabel', 'Unavailable', 'unavailableLabel'),
20
+ variantSelectionRequiredMessage: getLocale('variantSelectionRequiredMessage', setting?.variantSelectionRequiredMessage, 'variantSelectionRequiredMessage')
31
21
  };
32
22
  };
33
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.707",
3
+ "version": "2.0.0-dev.709",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",