@gem-sdk/components 2.0.0-dev.358 → 2.0.0-dev.360

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 (45) hide show
  1. package/dist/cjs/builder.js +14 -14
  2. package/dist/cjs/grid/row/setting/configs/uiV2.js +44 -0
  3. package/dist/cjs/grid/section/setting/configs/uiV2.js +44 -0
  4. package/dist/cjs/heading/setting/configs/settings.js +5 -2
  5. package/dist/cjs/index.js +40 -40
  6. package/dist/cjs/post-purchase/product/settings/product-image/setting-v2.js +5 -1
  7. package/dist/cjs/product/components/ProductQuantity/common/common.js +17 -0
  8. package/dist/cjs/product/components/ProductQuantity/hooks/index.js +68 -0
  9. package/dist/cjs/product/components/ProductQuantity/index.js +168 -0
  10. package/dist/cjs/product/components/ProductQuickView/ProductQuickView.js +2 -2
  11. package/dist/cjs/product/components/ProductVariants/common/dropdown/styles.js +2 -6
  12. package/dist/cjs/product/components/ProductVariants/components/dropdown-swatches/Dropdown.js +3 -3
  13. package/dist/cjs/product/components/ProductVariants/components/dropdown-swatches/Dropdown.liquid.js +2 -2
  14. package/dist/cjs/product/index.js +6 -6
  15. package/dist/cjs/product/next.js +1 -1
  16. package/dist/cjs/product/setting/product-quantity/configs/settings.js +1 -0
  17. package/dist/cjs/product/setting/product-quantity/configs/uiV2.js +13 -6
  18. package/dist/cjs/product/setting/product-variant/configs/settings.js +6 -3
  19. package/dist/cjs/product/setting/product-variant/configs/uiV2.js +107 -1
  20. package/dist/cjs/text/components/common/getStyle.js +1 -2
  21. package/dist/cjs/text/setting/configs/settings.js +5 -2
  22. package/dist/esm/builder.js +1 -1
  23. package/dist/esm/grid/row/setting/configs/uiV2.js +44 -0
  24. package/dist/esm/grid/section/setting/configs/uiV2.js +44 -0
  25. package/dist/esm/heading/setting/configs/settings.js +5 -2
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/post-purchase/product/settings/product-image/setting-v2.js +5 -1
  28. package/dist/esm/product/components/ProductQuantity/common/common.js +17 -1
  29. package/dist/esm/product/components/ProductQuantity/hooks/index.js +66 -0
  30. package/dist/esm/product/components/ProductQuantity/index.js +164 -0
  31. package/dist/esm/product/components/ProductQuickView/ProductQuickView.js +1 -1
  32. package/dist/esm/product/components/ProductVariants/common/dropdown/styles.js +2 -6
  33. package/dist/esm/product/components/ProductVariants/components/dropdown-swatches/Dropdown.js +3 -3
  34. package/dist/esm/product/components/ProductVariants/components/dropdown-swatches/Dropdown.liquid.js +2 -2
  35. package/dist/esm/product/next.js +1 -1
  36. package/dist/esm/product/setting/product-quantity/configs/settings.js +1 -0
  37. package/dist/esm/product/setting/product-quantity/configs/uiV2.js +13 -6
  38. package/dist/esm/product/setting/product-variant/configs/settings.js +6 -3
  39. package/dist/esm/product/setting/product-variant/configs/uiV2.js +107 -1
  40. package/dist/esm/text/components/common/getStyle.js +2 -3
  41. package/dist/esm/text/setting/configs/settings.js +5 -2
  42. package/dist/types/index.d.ts +3 -27
  43. package/package.json +2 -2
  44. package/dist/cjs/product/components/ProductQuantity.js +0 -273
  45. package/dist/esm/product/components/ProductQuantity.js +0 -269
@@ -10,8 +10,7 @@ var attrs = require('../../common/dropdown/attrs.js');
10
10
  var index = require('../dropdown-option/render-liquid/index.js');
11
11
 
12
12
  const DropdownVariant = (props)=>{
13
- const { variantGroup, blankText, swatchAutoWidth, swatchHeight, optionTypography, optionBgColor, optionTextColor, optionRounded, optionShadow, // optionHasShadow,
14
- optionBorder, optionTransform, hasPreSelected, optionTypo, combineHeight, combineWidth, soldOutStyle, children } = props;
13
+ const { variantGroup, blankText, swatchAutoWidth, swatchHeight, optionTypography, optionBgColor, optionTextColor, optionRounded, optionShadow, optionHasShadow, optionBorder, optionTransform, hasPreSelected, optionTypo, combineHeight, combineWidth, soldOutStyle, children } = props;
15
14
  const isSoldOutMark = soldOutStyle === 'disable';
16
15
  const selectClass = system.createClass(classes.getSelectClass({
17
16
  optionTypo,
@@ -28,6 +27,7 @@ const DropdownVariant = (props)=>{
28
27
  optionBgColor,
29
28
  optionTextColor,
30
29
  optionRounded,
30
+ optionHasShadow,
31
31
  optionShadow,
32
32
  optionBorder,
33
33
  optionTransform
@@ -15,7 +15,7 @@ require('@gem-sdk/keen-slider/react');
15
15
  require('react-dom');
16
16
  require('../modal/components/confirm.js');
17
17
  require('../video/components/Video.js');
18
- var index$5 = require('./components/ProductQuickView/index.js');
18
+ var index$6 = require('./components/ProductQuickView/index.js');
19
19
  require('./components/constants/product-bundle.js');
20
20
  var ProductList = require('./components/ProductList/ProductList.js');
21
21
  require('./components/ProductBundle/common/styles.js');
@@ -24,7 +24,7 @@ require('./components/ProductBadge/constants.js');
24
24
  require('./components/ProductBadge/types.js');
25
25
  require('./components/ProductBadge/utils/shape.js');
26
26
  var Product$1 = require('./setting/Product.js');
27
- var ProductQuantity$1 = require('./setting/ProductQuantity.js');
27
+ var ProductQuantity = require('./setting/ProductQuantity.js');
28
28
  var ProductTitle = require('./setting/ProductTitle.js');
29
29
  var ProductButton$1 = require('./setting/ProductButton.js');
30
30
  var ProductPrice = require('./setting/ProductPrice.js');
@@ -42,11 +42,11 @@ var ProductBundleDiscount$1 = require('./components/ProductBundle/setting/Produc
42
42
  var ProductBundleDiscountItem$1 = require('./components/ProductBundle/setting/ProductBundleDiscountItem.js');
43
43
  var ProductViewMore$1 = require('./setting/ProductViewMore.js');
44
44
  var ProductBadge = require('./setting/ProductBadge.js');
45
- var index$7 = require('./components/FileUpload/components/setting/index.js');
45
+ var index$8 = require('./components/FileUpload/components/setting/index.js');
46
46
 
47
47
  const productSetting = {
48
48
  Product: Product$1.default,
49
- ProductQuantity: ProductQuantity$1.default,
49
+ ProductQuantity: ProductQuantity.default,
50
50
  ProductTitle: ProductTitle.default,
51
51
  ProductButton: ProductButton$1.default,
52
52
  ProductPrice: ProductPrice.default,
@@ -64,10 +64,10 @@ const productSetting = {
64
64
  ProductBundleDiscountItem: ProductBundleDiscountItem$1.default,
65
65
  ProductViewMore: ProductViewMore$1.default,
66
66
  ProductBadge: ProductBadge.default,
67
- FileUpload: index$7.default
67
+ FileUpload: index$8.default
68
68
  };
69
69
 
70
70
  exports.Product = Product.default;
71
- exports.ProductQuickView = index$5.default;
71
+ exports.ProductQuickView = index$6.default;
72
72
  exports.ProductList = ProductList.default;
73
73
  exports.productSetting = productSetting;
@@ -14,7 +14,7 @@ const Product = dynamic(()=>Promise.resolve().then(function () { return require(
14
14
  const ProductTitle = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductTitle/index.js'); }), {
15
15
  loading: Loading.default
16
16
  });
17
- const ProductQuantity = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductQuantity.js'); }), {
17
+ const ProductQuantity = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductQuantity/index.js'); }), {
18
18
  loading: Loading.default
19
19
  });
20
20
  const ProductDescription = dynamic(()=>Promise.resolve().then(function () { return require('./components/ProductDescription/index.js'); }), {
@@ -64,6 +64,7 @@ const ProductQuantitySettings = [
64
64
  id: 'quantityLayout',
65
65
  label: 'Style',
66
66
  type: 'layout-selector',
67
+ popoverLabel: 'Style',
67
68
  iconViewBox: '0 0 80 48',
68
69
  enableItemBackground: true,
69
70
  itemPerRow: 2,
@@ -191,7 +191,8 @@ const SettingUIV2 = [
191
191
  },
192
192
  setting: {
193
193
  id: 'buttonWidth'
194
- }
194
+ },
195
+ conditionDisplay: 'hasButton === true'
195
196
  },
196
197
  {
197
198
  label: {
@@ -200,7 +201,8 @@ const SettingUIV2 = [
200
201
  setting: {
201
202
  id: 'buttonBackgroundColor',
202
203
  state: 'normal'
203
- }
204
+ },
205
+ conditionDisplay: 'hasButton === true'
204
206
  },
205
207
  {
206
208
  label: {
@@ -208,7 +210,8 @@ const SettingUIV2 = [
208
210
  },
209
211
  setting: {
210
212
  id: 'plusIcon'
211
- }
213
+ },
214
+ conditionDisplay: 'hasButton === true'
212
215
  },
213
216
  {
214
217
  label: {
@@ -216,7 +219,8 @@ const SettingUIV2 = [
216
219
  },
217
220
  setting: {
218
221
  id: 'minusIcon'
219
- }
222
+ },
223
+ conditionDisplay: 'hasButton === true'
220
224
  },
221
225
  {
222
226
  label: {
@@ -225,7 +229,8 @@ const SettingUIV2 = [
225
229
  setting: {
226
230
  id: 'iconColor',
227
231
  state: 'normal'
228
- }
232
+ },
233
+ conditionDisplay: 'hasButton === true'
229
234
  }
230
235
  ],
231
236
  moreSettings: {
@@ -237,7 +242,8 @@ const SettingUIV2 = [
237
242
  },
238
243
  setting: {
239
244
  id: 'iconSizeCustom'
240
- }
245
+ },
246
+ conditionDisplay: 'hasButton === true'
241
247
  },
242
248
  {
243
249
  label: {
@@ -250,6 +256,7 @@ const SettingUIV2 = [
250
256
  popoverLabel: {
251
257
  en: 'Hover effect'
252
258
  },
259
+ conditionDisplay: 'hasButton === true',
253
260
  controls: [
254
261
  {
255
262
  label: {
@@ -618,7 +618,8 @@ const ProductVariantSettings = [
618
618
  blur: '12px',
619
619
  spread: '0px',
620
620
  color: 'rgba(0, 0, 0, 0.20)',
621
- angle: 90
621
+ angle: 90,
622
+ enable: false
622
623
  },
623
624
  hover: {
624
625
  type: 'shadow-1',
@@ -626,7 +627,8 @@ const ProductVariantSettings = [
626
627
  blur: '12px',
627
628
  spread: '0px',
628
629
  color: 'rgba(0, 0, 0, 0.20)',
629
- angle: 90
630
+ angle: 90,
631
+ enable: false
630
632
  },
631
633
  active: {
632
634
  type: 'shadow-1',
@@ -634,7 +636,8 @@ const ProductVariantSettings = [
634
636
  blur: '12px',
635
637
  spread: '0px',
636
638
  color: 'rgba(0, 0, 0, 0.20)',
637
- angle: 90
639
+ angle: 90,
640
+ enable: false
638
641
  }
639
642
  },
640
643
  state: {
@@ -188,13 +188,66 @@ const SettingUIV2 = [
188
188
  state: 'normal'
189
189
  }
190
190
  },
191
+ {
192
+ label: {
193
+ en: 'Has Shadow'
194
+ },
195
+ setting: {
196
+ id: 'optionHasShadow',
197
+ state: 'active'
198
+ }
199
+ },
191
200
  {
192
201
  label: {
193
202
  en: 'Shadow'
194
203
  },
195
204
  setting: {
196
205
  id: 'optionShadow',
197
- state: 'normal'
206
+ state: 'active'
207
+ },
208
+ options: {
209
+ updateFields: [
210
+ {
211
+ field: 'enable',
212
+ settingId: 'optionHasShadow',
213
+ state: 'active'
214
+ }
215
+ ]
216
+ },
217
+ controlChangeTrigger: {
218
+ settings: [
219
+ {
220
+ condition: `optionShadow.active.enable === true`,
221
+ source: [
222
+ 'optionShadow',
223
+ 'optionHasShadow'
224
+ ],
225
+ action: {
226
+ controlId: 'optionHasShadow',
227
+ groupType: 'setting',
228
+ controlType: 'setting',
229
+ state: 'active',
230
+ newValue: true
231
+ }
232
+ },
233
+ {
234
+ condition: `optionShadow.active.enable === false`,
235
+ source: [
236
+ 'optionShadow',
237
+ 'optionHasShadow'
238
+ ],
239
+ action: {
240
+ controlId: 'optionHasShadow',
241
+ groupType: 'setting',
242
+ controlType: 'setting',
243
+ state: 'active',
244
+ newValue: false
245
+ }
246
+ }
247
+ ],
248
+ options: {
249
+ noRecordHistory: true
250
+ }
198
251
  }
199
252
  }
200
253
  ]
@@ -241,6 +294,15 @@ const SettingUIV2 = [
241
294
  state: 'hover'
242
295
  }
243
296
  },
297
+ {
298
+ label: {
299
+ en: 'Has Shadow'
300
+ },
301
+ setting: {
302
+ id: 'optionHasShadow',
303
+ state: 'hover'
304
+ }
305
+ },
244
306
  {
245
307
  label: {
246
308
  en: 'Shadow'
@@ -248,6 +310,50 @@ const SettingUIV2 = [
248
310
  setting: {
249
311
  id: 'optionShadow',
250
312
  state: 'hover'
313
+ },
314
+ options: {
315
+ updateFields: [
316
+ {
317
+ field: 'enable',
318
+ settingId: 'optionHasShadow',
319
+ state: 'hover'
320
+ }
321
+ ]
322
+ },
323
+ controlChangeTrigger: {
324
+ settings: [
325
+ {
326
+ condition: `optionShadow.hover.enable === true`,
327
+ source: [
328
+ 'optionShadow',
329
+ 'optionHasShadow'
330
+ ],
331
+ action: {
332
+ controlId: 'optionHasShadow',
333
+ groupType: 'setting',
334
+ controlType: 'setting',
335
+ state: 'hover',
336
+ newValue: true
337
+ }
338
+ },
339
+ {
340
+ condition: `optionShadow.hover.enable === false`,
341
+ source: [
342
+ 'optionShadow',
343
+ 'optionHasShadow'
344
+ ],
345
+ action: {
346
+ controlId: 'optionHasShadow',
347
+ groupType: 'setting',
348
+ controlType: 'setting',
349
+ state: 'hover',
350
+ newValue: false
351
+ }
352
+ }
353
+ ],
354
+ options: {
355
+ noRecordHistory: true
356
+ }
251
357
  }
252
358
  }
253
359
  ]
@@ -39,11 +39,10 @@ const getTextStyle = (styles, setting)=>{
39
39
  ...core.composeBorderResponsive(styles?.shapeBorder),
40
40
  ...core.composeRadiusResponsive(styles?.shapeRounded),
41
41
  ...core.getResponsiveStyleShadowWithoutState(styles?.shapeBoxShadow, 'box-shadow', styles?.shapeBoxShadow),
42
- ...core.getStyleShadowState(styles?.textShadow, 'text-shadow', styles?.hasTextShadow),
43
42
  ...core.getStyleShadow({
44
43
  value: styles?.typo?.custom?.textShadow,
45
44
  styleAppliedFor: 'text-shadow',
46
- isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
45
+ isEnableShadow: styles?.typo?.custom?.hasShadowText
47
46
  }),
48
47
  ...core.makeStyleResponsive('ta', styles?.textAlign),
49
48
  ...core.makeStyleResponsive('line-clamp', core.makeLineClamp(styles?.lineClamp, styles?.hasLineClamp)),
@@ -344,7 +344,9 @@ const TextSettings = [
344
344
  type: 'shadow-v2',
345
345
  devices: {
346
346
  desktop: {
347
- default: {}
347
+ default: {
348
+ enable: false
349
+ }
348
350
  }
349
351
  },
350
352
  compoDefaultValue: {
@@ -355,7 +357,8 @@ const TextSettings = [
355
357
  blur: '12px',
356
358
  spread: '0px',
357
359
  color: 'rgba(18, 18, 18, 0.2)',
358
- angle: 45
360
+ angle: 45,
361
+ enable: true
359
362
  }
360
363
  }
361
364
  }
@@ -219,7 +219,7 @@ import HextomFreeShippingBar from './third-party/components/HextomFreeShippingBa
219
219
  import EcoboostifyShoppableReelUgc from './third-party/components/EcoboostifyShoppableReelUgc.js';
220
220
  import Product from './product/components/ProductWrap/Product.js';
221
221
  import ProductTitle from './product/components/ProductTitle/index.js';
222
- import ProductQuantity from './product/components/ProductQuantity.js';
222
+ import ProductQuantity from './product/components/ProductQuantity/index.js';
223
223
  import ProductDescription from './product/components/ProductDescription/index.js';
224
224
  import ProductPrice from './product/components/ProductPrice/index.js';
225
225
  import ProductButton from './product/components/ProductButton/ProductButton.js';
@@ -206,6 +206,50 @@ const SettingUIV2 = [
206
206
  setting: {
207
207
  id: 'boxShadow',
208
208
  state: 'normal'
209
+ },
210
+ options: {
211
+ updateFields: [
212
+ {
213
+ field: 'enable',
214
+ settingId: 'advanced.hasBoxShadow',
215
+ state: 'normal'
216
+ }
217
+ ]
218
+ },
219
+ controlChangeTrigger: {
220
+ settings: [
221
+ {
222
+ condition: `boxShadow.normal.enable === true`,
223
+ source: [
224
+ 'boxShadow',
225
+ 'hasBoxShadow'
226
+ ],
227
+ action: {
228
+ controlId: 'hasBoxShadow',
229
+ groupType: 'advanced',
230
+ controlType: 'advanced',
231
+ state: 'normal',
232
+ newValue: true
233
+ }
234
+ },
235
+ {
236
+ condition: `boxShadow.normal.enable === false`,
237
+ source: [
238
+ 'boxShadow',
239
+ 'hasBoxShadow'
240
+ ],
241
+ action: {
242
+ controlId: 'hasBoxShadow',
243
+ groupType: 'advanced',
244
+ controlType: 'advanced',
245
+ state: 'normal',
246
+ newValue: false
247
+ }
248
+ }
249
+ ],
250
+ options: {
251
+ noRecordHistory: true
252
+ }
209
253
  }
210
254
  }
211
255
  ]
@@ -210,6 +210,50 @@ const SettingUIV2 = [
210
210
  controlConfig: {
211
211
  id: 'boxShadow',
212
212
  type: 'shadow-v2'
213
+ },
214
+ options: {
215
+ updateFields: [
216
+ {
217
+ field: 'enable',
218
+ settingId: 'advanced.hasBoxShadow',
219
+ state: 'normal'
220
+ }
221
+ ]
222
+ },
223
+ controlChangeTrigger: {
224
+ settings: [
225
+ {
226
+ condition: `boxShadow.normal.enable === true`,
227
+ source: [
228
+ 'boxShadow',
229
+ 'hasBoxShadow'
230
+ ],
231
+ action: {
232
+ controlId: 'hasBoxShadow',
233
+ groupType: 'advanced',
234
+ controlType: 'advanced',
235
+ state: 'normal',
236
+ newValue: true
237
+ }
238
+ },
239
+ {
240
+ condition: `boxShadow.normal.enable === false`,
241
+ source: [
242
+ 'boxShadow',
243
+ 'hasBoxShadow'
244
+ ],
245
+ action: {
246
+ controlId: 'hasBoxShadow',
247
+ groupType: 'advanced',
248
+ controlType: 'advanced',
249
+ state: 'normal',
250
+ newValue: false
251
+ }
252
+ }
253
+ ],
254
+ options: {
255
+ noRecordHistory: true
256
+ }
213
257
  }
214
258
  }
215
259
  ]
@@ -316,7 +316,9 @@ const HeadingSettings = [
316
316
  type: 'shadow-v2',
317
317
  devices: {
318
318
  desktop: {
319
- default: {}
319
+ default: {
320
+ enable: false
321
+ }
320
322
  }
321
323
  },
322
324
  compoDefaultValue: {
@@ -327,7 +329,8 @@ const HeadingSettings = [
327
329
  blur: '12px',
328
330
  spread: '0px',
329
331
  color: 'rgba(18, 18, 18, 0.2)',
330
- angle: 45
332
+ angle: 45,
333
+ enable: true
331
334
  }
332
335
  }
333
336
  }
package/dist/esm/index.js CHANGED
@@ -169,7 +169,7 @@ export { postPurchaseProduct2Col } from './post-purchase/product/settings/preset
169
169
  export { postPurchaseProductDefault } from './post-purchase/product/settings/presets-config/product-presets/product-default.js';
170
170
  export { default as Product } from './product/components/ProductWrap/Product.js';
171
171
  export { default as ProductTitle } from './product/components/ProductTitle/index.js';
172
- export { default as ProductQuantity } from './product/components/ProductQuantity.js';
172
+ export { default as ProductQuantity } from './product/components/ProductQuantity/index.js';
173
173
  export { default as ProductPrice } from './product/components/ProductPrice/index.js';
174
174
  export { default as ProductButton } from './product/components/ProductButton/ProductButton.js';
175
175
  export { default as ProductDescription } from './product/components/ProductDescription/index.js';
@@ -76,7 +76,11 @@ const SettingV2 = [
76
76
  min: 0,
77
77
  max: 100,
78
78
  step: 1,
79
- default: '8'
79
+ units: [
80
+ '%'
81
+ ],
82
+ hide: true,
83
+ default: '1%'
80
84
  },
81
85
  {
82
86
  id: 'spacingVertical',
@@ -11,6 +11,22 @@ const getPlusIcon = (plusIcon)=>{
11
11
  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M18 12H6" />
12
12
  </svg>`;
13
13
  };
14
+ const getMinusIcon = (minusIcon)=>{
15
+ return minusIcon ?? `<svg
16
+ xmlns="http://www.w3.org/2000/svg"
17
+ fill="none"
18
+ viewBox="0 0 24 24"
19
+ stroke="currentColor"
20
+ >
21
+ <path
22
+ strokeLinecap="round"
23
+ strokeLinejoin="round"
24
+ strokeWidth={2}
25
+ d="M12 6v6m0 0v6m0-6h6m-6 0H6"
26
+ />
27
+ </svg>
28
+ `;
29
+ };
14
30
  const getIconWidth = (iconSizeCustom)=>{
15
31
  let check = true;
16
32
  Object.keys(iconSizeCustom ?? {}).forEach((key)=>{
@@ -25,4 +41,4 @@ const getIconWidth = (iconSizeCustom)=>{
25
41
  });
26
42
  };
27
43
 
28
- export { getIconWidth, getPlusIcon };
44
+ export { getIconWidth, getMinusIcon, getPlusIcon };
@@ -0,0 +1,66 @@
1
+ import { useQuantity, useCurrentVariantInStock, useProduct, useIsSyncProduct, useInteraction } from '@gem-sdk/core';
2
+ import { useRef, useEffect } from 'react';
3
+ import { useTransition } from '../../ProductVariants/common/common.js';
4
+
5
+ const useProductQuantity = (props)=>{
6
+ const { setting = {}, advanced } = props;
7
+ const { updatePrice } = setting;
8
+ const { quantity, setQuantity, setUpdatePrice } = useQuantity();
9
+ const isInStock = useCurrentVariantInStock();
10
+ const product = useProduct();
11
+ const isSyncProduct = useIsSyncProduct();
12
+ const { trigger } = useInteraction();
13
+ const ref = useRef(null);
14
+ const defaultQty = setting.defaultQtyValue || 1;
15
+ useEffect(()=>{
16
+ setQuantity(parseFloat(`${defaultQty}`));
17
+ }, [
18
+ setQuantity,
19
+ defaultQty
20
+ ]);
21
+ useEffect(()=>{
22
+ setUpdatePrice(updatePrice || false);
23
+ }, [
24
+ updatePrice,
25
+ setUpdatePrice
26
+ ]);
27
+ const onHandleQuantity = (e)=>{
28
+ const event = e;
29
+ const data = event.detail;
30
+ const currentProductId = product?.id;
31
+ if (isSyncProduct && data && currentProductId == data.productId && quantity != data.quantity) {
32
+ dispatchInteractionChangeQuantity(data.quantity);
33
+ setQuantity(data.quantity);
34
+ }
35
+ };
36
+ useEffect(()=>{
37
+ window.removeEventListener('set-product-quantity', onHandleQuantity);
38
+ window.addEventListener('set-product-quantity', onHandleQuantity);
39
+ });
40
+ useTransition((preQuantity)=>{
41
+ if (preQuantity !== quantity) {
42
+ dispatchInteractionChangeQuantity(quantity || 0);
43
+ }
44
+ }, [
45
+ quantity
46
+ ]);
47
+ const dispatchInteractionChangeQuantity = (quantity)=>{
48
+ trigger({
49
+ event: 'gp:rollback:quantity-change',
50
+ selector: `[data-id="${advanced?.uid}"]`,
51
+ element: ref.current
52
+ });
53
+ trigger({
54
+ event: 'gp:quantity-change',
55
+ selector: `[data-id="${advanced?.uid}"]`,
56
+ data: quantity,
57
+ element: ref.current
58
+ });
59
+ };
60
+ return {
61
+ isInStock,
62
+ ref
63
+ };
64
+ };
65
+
66
+ export { useProductQuantity };