@gem-sdk/components 2.0.0-dev.551 → 2.0.0-dev.552

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.
@@ -1,5 +1,3 @@
1
- import { dataStringify } from '@gem-sdk/core';
2
-
3
1
  const getImageAttr = ({ setting })=>{
4
2
  return {
5
3
  src: setting?.image?.src,
@@ -8,27 +6,12 @@ const getImageAttr = ({ setting })=>{
8
6
  };
9
7
  };
10
8
  const getContainerAttrs = (props)=>{
11
- const { builderAttrs, builderProps, setting } = props;
12
- const isTextBadge = setting?.contentType === 'text';
9
+ const { builderAttrs, builderProps } = props;
13
10
  return {
14
11
  ...builderAttrs,
15
12
  'data-id': builderProps?.uid || '',
16
13
  id: `g-product-badge-${builderProps?.uid}`,
17
- 'gp-data-hidden': 'false',
18
- 'gp-data': `${dataStringify({
19
- displayContent: setting?.displayContent,
20
- minPrice: '{{ minPriceValue }}',
21
- variantIDs: '{{ product.variants | map: "id" | json | escape }}',
22
- variantInventoryQuantities: '{{ product.variants | map: "inventory_quantity" | json | escape }}',
23
- amountDiscount: '{{amountDiscountValue}}',
24
- percentDiscount: '{{percentDiscountValue}}',
25
- price: '{{price}}',
26
- displayTrigger: setting?.displayTrigger,
27
- uid: builderProps?.uid,
28
- productCreatedAt: '{{product.created_at | date: "%Y-%m-%d" }}',
29
- productTags: '{{ product.tags | join: "," }}',
30
- isTextBadge
31
- })}`
14
+ 'gp-data-hidden': 'false'
32
15
  };
33
16
  };
34
17
  const getEditTooltipAttrs = (props)=>{
@@ -1,9 +1,9 @@
1
- import { template, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
1
+ import { template, dataStringify, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
2
  import { getSettingPreloadData } from '../../../helpers.js';
3
3
  import { checkDiscountContentProductBadge } from './utils/common.js';
4
4
  import { generateBadgeContent } from './utils/generateLiquidContent.js';
5
5
  import { renderBadgeInFirstTime } from './utils/renderBadgeLiquid.js';
6
- import { createStyle, createClass, createAttr } from '@gem-sdk/system';
6
+ import { createStyle, createClass, createAttr, createStateOrContext } from '@gem-sdk/system';
7
7
  import { getWrapperClasses, getSubWrapperClass, getTextContainerClasses, getTextWrapperClasses, getTextContentClasses, getImageContainerClasses, getImageClasses } from './common/getClasses.js';
8
8
  import { getContainerStyle, getSubWrapperStyle, getContentStyleInternal, getTextBadgeWrapperStyles, getTextContentStyle, getImageContainerStyles } from './common/getStyles.js';
9
9
  import { getSubWrapperAttrs, getContainerAttrs, getTextContentAttrs, getImageAttr } from './common/getAttrs.js';
@@ -73,6 +73,20 @@ const ProductBadge = (props)=>{
73
73
  setting
74
74
  })
75
75
  });
76
+ const createDataState = createStateOrContext({
77
+ displayContent: setting?.displayContent,
78
+ minPrice: '{{ minPriceValue }}',
79
+ variantIDs: '{{ product.variants | map: "id" | json | escape }}',
80
+ variantInventoryQuantities: '{{ product.variants | map: "inventory_quantity" | json | escape }}',
81
+ amountDiscount: '{{amountDiscountValue}}',
82
+ percentDiscount: '{{percentDiscountValue}}',
83
+ price: '{{price}}',
84
+ displayTrigger: setting?.displayTrigger,
85
+ uid: props.builderProps?.uid,
86
+ productCreatedAt: '{{product.created_at | date: "%Y-%m-%d" }}',
87
+ productTags: '{{ product.tags | join: "," }}',
88
+ isTextBadge
89
+ });
76
90
  return template`
77
91
  {% if product %}
78
92
  ${generateBadgeContent(setting?.displayContent)}
@@ -81,6 +95,7 @@ const ProductBadge = (props)=>{
81
95
  ${{
82
96
  ...containerAttrs
83
97
  }}
98
+ gp-data='${dataStringify(createDataState)}'
84
99
  class="containerClass"
85
100
  style="${containerStyle}"
86
101
  >