@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,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var core = require('@gem-sdk/core');
4
-
5
3
  const getImageAttr = ({ setting })=>{
6
4
  return {
7
5
  src: setting?.image?.src,
@@ -10,27 +8,12 @@ const getImageAttr = ({ setting })=>{
10
8
  };
11
9
  };
12
10
  const getContainerAttrs = (props)=>{
13
- const { builderAttrs, builderProps, setting } = props;
14
- const isTextBadge = setting?.contentType === 'text';
11
+ const { builderAttrs, builderProps } = props;
15
12
  return {
16
13
  ...builderAttrs,
17
14
  'data-id': builderProps?.uid || '',
18
15
  id: `g-product-badge-${builderProps?.uid}`,
19
- 'gp-data-hidden': 'false',
20
- 'gp-data': `${core.dataStringify({
21
- displayContent: setting?.displayContent,
22
- minPrice: '{{ minPriceValue }}',
23
- variantIDs: '{{ product.variants | map: "id" | json | escape }}',
24
- variantInventoryQuantities: '{{ product.variants | map: "inventory_quantity" | json | escape }}',
25
- amountDiscount: '{{amountDiscountValue}}',
26
- percentDiscount: '{{percentDiscountValue}}',
27
- price: '{{price}}',
28
- displayTrigger: setting?.displayTrigger,
29
- uid: builderProps?.uid,
30
- productCreatedAt: '{{product.created_at | date: "%Y-%m-%d" }}',
31
- productTags: '{{ product.tags | join: "," }}',
32
- isTextBadge
33
- })}`
16
+ 'gp-data-hidden': 'false'
34
17
  };
35
18
  };
36
19
  const getEditTooltipAttrs = (props)=>{
@@ -77,6 +77,20 @@ const ProductBadge = (props)=>{
77
77
  setting
78
78
  })
79
79
  });
80
+ const createDataState = system.createStateOrContext({
81
+ displayContent: setting?.displayContent,
82
+ minPrice: '{{ minPriceValue }}',
83
+ variantIDs: '{{ product.variants | map: "id" | json | escape }}',
84
+ variantInventoryQuantities: '{{ product.variants | map: "inventory_quantity" | json | escape }}',
85
+ amountDiscount: '{{amountDiscountValue}}',
86
+ percentDiscount: '{{percentDiscountValue}}',
87
+ price: '{{price}}',
88
+ displayTrigger: setting?.displayTrigger,
89
+ uid: props.builderProps?.uid,
90
+ productCreatedAt: '{{product.created_at | date: "%Y-%m-%d" }}',
91
+ productTags: '{{ product.tags | join: "," }}',
92
+ isTextBadge
93
+ });
80
94
  return core.template`
81
95
  {% if product %}
82
96
  ${generateLiquidContent.generateBadgeContent(setting?.displayContent)}
@@ -85,6 +99,7 @@ const ProductBadge = (props)=>{
85
99
  ${{
86
100
  ...containerAttrs
87
101
  }}
102
+ gp-data='${core.dataStringify(createDataState)}'
88
103
  class="containerClass"
89
104
  style="${containerStyle}"
90
105
  >