@gem-sdk/components 2.4.11 → 2.4.13

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.
@@ -71,10 +71,17 @@ const AccordionItem = ({ accordions, index, rawChildren, builderProps, title, pa
71
71
  return '';
72
72
  };
73
73
  const composeColorIconStyle = ()=>{
74
- return `.${parentUid}.gp-accordion-item-${parentUid}-${index}:hover .gp-collapsible-icon, .${parentUid}.gp-accordion-item-${parentUid}-${index}:hover .gp-icon {
75
- color: ${isShow ? color?.active : color?.hover}
76
- } {
77
- }`;
74
+ return `.gp-accordion-item-${parentUid}-${index}:hover
75
+ {
76
+ .gp-collapsible-icon {
77
+ color: ${isShow ? color?.active : color?.hover}
78
+ }
79
+
80
+ .gp-icon {
81
+ color: ${isShow ? iconColor?.active : iconColor?.hover}
82
+ }
83
+ }
84
+ `;
78
85
  };
79
86
  const getTemplateRow = ()=>{
80
87
  return {
@@ -82,16 +89,6 @@ const AccordionItem = ({ accordions, index, rawChildren, builderProps, title, pa
82
89
  };
83
90
  };
84
91
  return core.template`
85
- <style title="gp-accordion-item-style">
86
- .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-collapsible-icon.gp-accordion-item-hover, .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-icon.gp-accordion-item-hover
87
- {
88
- color: ${color?.hover} !important
89
- }
90
- .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-collapsible-icon.gp-accordion-item-active, .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-icon.gp-accordion-item-active
91
- {
92
- color: ${color?.active} !important
93
- }
94
- </style>
95
92
  <div class="gp-overflow-clip" style="${{
96
93
  ...widthStyle,
97
94
  '--height-iconCollapseSize': `${iconCollapseSize || 16}px`,
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var core = require('@gem-sdk/core');
6
6
  var helpers = require('../../helpers.js');
7
7
 
8
- const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId })=>{
8
+ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isUseTranslatedValue = false })=>{
9
9
  const { align, size, backgroundColor, textColor, roundedBtn, iconSpacing, globalSize } = styles;
10
10
  const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
11
11
  const [wrapStyle, restStyle] = core.splitStyle([
@@ -70,7 +70,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
70
70
  color: ${core.getSingleColorVariable(styles?.textColor?.hover)};
71
71
  }
72
72
  `;
73
- const labelValDisplay = helpers.getDynamicSourceLocales({
73
+ const labelValDisplay = !isUseTranslatedValue ? label : helpers.getDynamicSourceLocales({
74
74
  val: label,
75
75
  uid: builderProps?.uidTranslate ?? builderProps?.uid,
76
76
  settingId: translate ?? 'label',
@@ -161,7 +161,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
161
161
  >${iconSvg}</span>`)}
162
162
  <span
163
163
  data-gp-text
164
- class="${`group-hover/button:!gp-text-inherit gp-button-text-only gp-break-words group-data-[state=loading]/button:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
164
+ class="${`gp-content-product-button group-hover/button:!gp-text-inherit gp-button-text-only gp-break-words group-data-[state=loading]/button:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
165
165
  ${styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : ''}`}"
166
166
  style="${{
167
167
  ...nodePrice && appendTypoStyle,
@@ -260,6 +260,21 @@ const config = {
260
260
  }
261
261
  }
262
262
  },
263
+ {
264
+ id: 'columnGap',
265
+ type: 'range',
266
+ min: 0,
267
+ max: 100,
268
+ step: 1,
269
+ units: [
270
+ '%'
271
+ ],
272
+ devices: {
273
+ desktop: {
274
+ default: '0%'
275
+ }
276
+ }
277
+ },
263
278
  {
264
279
  id: 'background',
265
280
  type: 'background',
@@ -296,14 +311,29 @@ const config = {
296
311
  ],
297
312
  ui: [
298
313
  {
299
- type: 'control',
314
+ type: 'group',
300
315
  label: {
301
316
  en: 'Layout'
302
317
  },
303
- setting: {
304
- id: 'layout'
305
- },
306
- layout: 'vertical'
318
+ controls: [
319
+ {
320
+ type: 'control',
321
+ setting: {
322
+ id: 'layout'
323
+ },
324
+ layout: 'vertical'
325
+ },
326
+ {
327
+ type: 'control',
328
+ label: {
329
+ en: 'Column gap'
330
+ },
331
+ setting: {
332
+ id: 'columnGap'
333
+ },
334
+ condition: `!!layout.cols && layout.cols.length > 1 && pageType == "POST_PURCHASE"`
335
+ }
336
+ ]
307
337
  },
308
338
  {
309
339
  type: 'group',
@@ -340,7 +370,7 @@ const config = {
340
370
  setting: {
341
371
  id: 'verticalGutter'
342
372
  },
343
- condition: `!!layout.cols && layout.cols.length > 1`
373
+ condition: `!!layout.cols && layout.cols.length > 1 && pageType != "POST_PURCHASE"`
344
374
  }
345
375
  ]
346
376
  },
@@ -349,7 +379,7 @@ const config = {
349
379
  label: {
350
380
  en: 'Align'
351
381
  },
352
- condition: `layout.display !== 'fill' || (layout.display === 'fill' && !!layout.cols && layout.cols.length > 1)`,
382
+ condition: `(layout.display !== 'fill' || (layout.display === 'fill' && !!layout.cols && layout.cols.length > 1)) && pageType != "POST_PURCHASE"`,
353
383
  controls: [
354
384
  {
355
385
  type: 'control',
@@ -218,7 +218,7 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
218
218
  ]);
219
219
  const isInStock = core.useCurrentVariantInStock();
220
220
  const isDisable = !isInStock || createCartLoading || addToCartLoading;
221
- const label = !isInStock ? setting?.outOfStockLabel : setting?.label;
221
+ const label = !isInStock ? !currentVariant ? 'Unavailable' : setting?.outOfStockLabel : setting?.label;
222
222
  if (!isInStock && isCustomOutOfStock) {
223
223
  buttonStyles.backgroundColor = {
224
224
  normal: oosBackground
@@ -188,6 +188,22 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
188
188
  pageContext,
189
189
  translate: setting?.translate
190
190
  });
191
+ const labelUnavailableTranslate = helpers.getDynamicSourceLocales({
192
+ val: 'Unavailable',
193
+ uid: builderProps?.uid,
194
+ settingId: 'unavailableLabel',
195
+ isLiquid: true,
196
+ pageContext,
197
+ translate: setting?.translate ? 'unavailableLabel' : undefined
198
+ });
199
+ const labelOutOfStockTranslate = helpers.getDynamicSourceLocales({
200
+ val: setting?.outOfStockLabel,
201
+ uid: builderProps?.uid,
202
+ settingId: 'outOfStockLabel',
203
+ isLiquid: true,
204
+ pageContext,
205
+ translate: setting?.translate ? 'outOfStockLabel' : undefined
206
+ });
191
207
  return core.template /* liquid */ `
192
208
  {%- liquid
193
209
  assign inventory_quantity = variant.inventory_quantity | default: 0
@@ -195,6 +211,8 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
195
211
  <gp-product-button
196
212
  class="gp-product-button"
197
213
  gp-data-wrapper="true"
214
+ gp-label-out-of-stock="${pageContext?.isPreviewing ? labelOutOfStockTranslate : `{{${labelOutOfStockTranslate}}}`}"
215
+ gp-label-unavailable="${pageContext?.isPreviewing ? labelUnavailableTranslate : `{{${labelUnavailableTranslate}}}`}"
198
216
  gp-data='${JSON.stringify({
199
217
  setting: {
200
218
  actionEffect: setting?.actionEffect,
@@ -272,8 +290,7 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
272
290
  'gp-data-hidden': `{% if variant.available %}true{% endif %}`
273
291
  },
274
292
  setting: {
275
- label: setting?.outOfStockLabel,
276
- translate: setting?.translate ? 'outOfStockLabel' : undefined,
293
+ label: `${pageContext?.isPreviewing ? labelOutOfStockTranslate : `{{${labelOutOfStockTranslate}}}`}`,
277
294
  htmlType: 'button',
278
295
  iconAlign: iconAlign,
279
296
  iconSvg: iconSvg,
@@ -292,7 +309,8 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
292
309
  }
293
310
  },
294
311
  pageContext,
295
- nodePrice: composeNodePrice()
312
+ nodePrice: composeNodePrice(),
313
+ isUseTranslatedValue: true
296
314
  })}
297
315
  </gp-product-button>
298
316
  ${core.RenderIf(core.isLocalEnv, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-button.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-product-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
@@ -67,10 +67,17 @@ const AccordionItem = ({ accordions, index, rawChildren, builderProps, title, pa
67
67
  return '';
68
68
  };
69
69
  const composeColorIconStyle = ()=>{
70
- return `.${parentUid}.gp-accordion-item-${parentUid}-${index}:hover .gp-collapsible-icon, .${parentUid}.gp-accordion-item-${parentUid}-${index}:hover .gp-icon {
71
- color: ${isShow ? color?.active : color?.hover}
72
- } {
73
- }`;
70
+ return `.gp-accordion-item-${parentUid}-${index}:hover
71
+ {
72
+ .gp-collapsible-icon {
73
+ color: ${isShow ? color?.active : color?.hover}
74
+ }
75
+
76
+ .gp-icon {
77
+ color: ${isShow ? iconColor?.active : iconColor?.hover}
78
+ }
79
+ }
80
+ `;
74
81
  };
75
82
  const getTemplateRow = ()=>{
76
83
  return {
@@ -78,16 +85,6 @@ const AccordionItem = ({ accordions, index, rawChildren, builderProps, title, pa
78
85
  };
79
86
  };
80
87
  return template`
81
- <style title="gp-accordion-item-style">
82
- .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-collapsible-icon.gp-accordion-item-hover, .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-icon.gp-accordion-item-hover
83
- {
84
- color: ${color?.hover} !important
85
- }
86
- .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-collapsible-icon.gp-accordion-item-active, .gp-accordion-item .gp-accordion-item-${parentUid}-${index}:hover .gp-icon.gp-accordion-item-active
87
- {
88
- color: ${color?.active} !important
89
- }
90
- </style>
91
88
  <div class="gp-overflow-clip" style="${{
92
89
  ...widthStyle,
93
90
  '--height-iconCollapseSize': `${iconCollapseSize || 16}px`,
@@ -1,7 +1,7 @@
1
1
  import { splitStyle, makeStyleResponsive, makeGlobalSize, composeTypographyClassName, composeTypographyStyle, composeBorderCss, composeCornerCss, getSingleColorVariable, template, cls, getGlobalColorStateClass, getGlobalColorStateStyle, composeRadius, getStyleShadowState, composeSize, getGradientBgrStyleForButton, RenderIf } from '@gem-sdk/core';
2
2
  import { getInsertLinkData, getDynamicSourceLocales } from '../../helpers.js';
3
3
 
4
- const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId })=>{
4
+ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isUseTranslatedValue = false })=>{
5
5
  const { align, size, backgroundColor, textColor, roundedBtn, iconSpacing, globalSize } = styles;
6
6
  const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
7
7
  const [wrapStyle, restStyle] = splitStyle([
@@ -66,7 +66,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
66
66
  color: ${getSingleColorVariable(styles?.textColor?.hover)};
67
67
  }
68
68
  `;
69
- const labelValDisplay = getDynamicSourceLocales({
69
+ const labelValDisplay = !isUseTranslatedValue ? label : getDynamicSourceLocales({
70
70
  val: label,
71
71
  uid: builderProps?.uidTranslate ?? builderProps?.uid,
72
72
  settingId: translate ?? 'label',
@@ -157,7 +157,7 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
157
157
  >${iconSvg}</span>`)}
158
158
  <span
159
159
  data-gp-text
160
- class="${`group-hover/button:!gp-text-inherit gp-button-text-only gp-break-words group-data-[state=loading]/button:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
160
+ class="${`gp-content-product-button group-hover/button:!gp-text-inherit gp-button-text-only gp-break-words group-data-[state=loading]/button:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
161
161
  ${styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : ''}`}"
162
162
  style="${{
163
163
  ...nodePrice && appendTypoStyle,
@@ -256,6 +256,21 @@ const config = {
256
256
  }
257
257
  }
258
258
  },
259
+ {
260
+ id: 'columnGap',
261
+ type: 'range',
262
+ min: 0,
263
+ max: 100,
264
+ step: 1,
265
+ units: [
266
+ '%'
267
+ ],
268
+ devices: {
269
+ desktop: {
270
+ default: '0%'
271
+ }
272
+ }
273
+ },
259
274
  {
260
275
  id: 'background',
261
276
  type: 'background',
@@ -292,14 +307,29 @@ const config = {
292
307
  ],
293
308
  ui: [
294
309
  {
295
- type: 'control',
310
+ type: 'group',
296
311
  label: {
297
312
  en: 'Layout'
298
313
  },
299
- setting: {
300
- id: 'layout'
301
- },
302
- layout: 'vertical'
314
+ controls: [
315
+ {
316
+ type: 'control',
317
+ setting: {
318
+ id: 'layout'
319
+ },
320
+ layout: 'vertical'
321
+ },
322
+ {
323
+ type: 'control',
324
+ label: {
325
+ en: 'Column gap'
326
+ },
327
+ setting: {
328
+ id: 'columnGap'
329
+ },
330
+ condition: `!!layout.cols && layout.cols.length > 1 && pageType == "POST_PURCHASE"`
331
+ }
332
+ ]
303
333
  },
304
334
  {
305
335
  type: 'group',
@@ -336,7 +366,7 @@ const config = {
336
366
  setting: {
337
367
  id: 'verticalGutter'
338
368
  },
339
- condition: `!!layout.cols && layout.cols.length > 1`
369
+ condition: `!!layout.cols && layout.cols.length > 1 && pageType != "POST_PURCHASE"`
340
370
  }
341
371
  ]
342
372
  },
@@ -345,7 +375,7 @@ const config = {
345
375
  label: {
346
376
  en: 'Align'
347
377
  },
348
- condition: `layout.display !== 'fill' || (layout.display === 'fill' && !!layout.cols && layout.cols.length > 1)`,
378
+ condition: `(layout.display !== 'fill' || (layout.display === 'fill' && !!layout.cols && layout.cols.length > 1)) && pageType != "POST_PURCHASE"`,
349
379
  controls: [
350
380
  {
351
381
  type: 'control',
@@ -214,7 +214,7 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
214
214
  ]);
215
215
  const isInStock = useCurrentVariantInStock();
216
216
  const isDisable = !isInStock || createCartLoading || addToCartLoading;
217
- const label = !isInStock ? setting?.outOfStockLabel : setting?.label;
217
+ const label = !isInStock ? !currentVariant ? 'Unavailable' : setting?.outOfStockLabel : setting?.label;
218
218
  if (!isInStock && isCustomOutOfStock) {
219
219
  buttonStyles.backgroundColor = {
220
220
  normal: oosBackground
@@ -184,6 +184,22 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
184
184
  pageContext,
185
185
  translate: setting?.translate
186
186
  });
187
+ const labelUnavailableTranslate = getDynamicSourceLocales({
188
+ val: 'Unavailable',
189
+ uid: builderProps?.uid,
190
+ settingId: 'unavailableLabel',
191
+ isLiquid: true,
192
+ pageContext,
193
+ translate: setting?.translate ? 'unavailableLabel' : undefined
194
+ });
195
+ const labelOutOfStockTranslate = getDynamicSourceLocales({
196
+ val: setting?.outOfStockLabel,
197
+ uid: builderProps?.uid,
198
+ settingId: 'outOfStockLabel',
199
+ isLiquid: true,
200
+ pageContext,
201
+ translate: setting?.translate ? 'outOfStockLabel' : undefined
202
+ });
187
203
  return template /* liquid */ `
188
204
  {%- liquid
189
205
  assign inventory_quantity = variant.inventory_quantity | default: 0
@@ -191,6 +207,8 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
191
207
  <gp-product-button
192
208
  class="gp-product-button"
193
209
  gp-data-wrapper="true"
210
+ gp-label-out-of-stock="${pageContext?.isPreviewing ? labelOutOfStockTranslate : `{{${labelOutOfStockTranslate}}}`}"
211
+ gp-label-unavailable="${pageContext?.isPreviewing ? labelUnavailableTranslate : `{{${labelUnavailableTranslate}}}`}"
194
212
  gp-data='${JSON.stringify({
195
213
  setting: {
196
214
  actionEffect: setting?.actionEffect,
@@ -268,8 +286,7 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
268
286
  'gp-data-hidden': `{% if variant.available %}true{% endif %}`
269
287
  },
270
288
  setting: {
271
- label: setting?.outOfStockLabel,
272
- translate: setting?.translate ? 'outOfStockLabel' : undefined,
289
+ label: `${pageContext?.isPreviewing ? labelOutOfStockTranslate : `{{${labelOutOfStockTranslate}}}`}`,
273
290
  htmlType: 'button',
274
291
  iconAlign: iconAlign,
275
292
  iconSvg: iconSvg,
@@ -288,7 +305,8 @@ const ProductButton = ({ setting, builderProps, builderAttrs, style, styles, adv
288
305
  }
289
306
  },
290
307
  pageContext,
291
- nodePrice: composeNodePrice()
308
+ nodePrice: composeNodePrice(),
309
+ isUseTranslatedValue: true
292
310
  })}
293
311
  </gp-product-button>
294
312
  ${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-button.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-product-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
@@ -1577,6 +1577,8 @@ type ProductButtonProps = BasePropsWrap<{
1577
1577
  translate?: string;
1578
1578
  outOfStockLabel?: string;
1579
1579
  unavailableLabel?: string;
1580
+ labelUnavailableTranslate?: string;
1581
+ labelOutOfStockTranslate?: string;
1580
1582
  actionEffect?: 'open-cart-drawer' | 'buy-now' | 'continue-shopping' | 'go-to-url';
1581
1583
  customURL?: {
1582
1584
  link?: string;
@@ -5433,10 +5435,11 @@ type ButtonLiquidProps = MixedProps & ButtonProps & {
5433
5435
  advanced?: any;
5434
5436
  pageContext?: PageContext;
5435
5437
  nodePrice?: string | null;
5438
+ isUseTranslatedValue?: boolean;
5436
5439
  } & {
5437
5440
  dataId?: string;
5438
5441
  };
5439
- declare const Button: ({ className, builderProps, customAttrs, pageContext, setting, styles, style, wrapClassName, advanced, nodePrice, dataId, }: ButtonLiquidProps) => string;
5442
+ declare const Button: ({ className, builderProps, customAttrs, pageContext, setting, styles, style, wrapClassName, advanced, nodePrice, dataId, isUseTranslatedValue, }: ButtonLiquidProps) => string;
5440
5443
 
5441
5444
  declare const Coupon: ({ setting, builderProps, builderAttrs, style, styles, advanced, pageContext, }: _gem_sdk_core.BaseProps<{
5442
5445
  copyContent?: string | undefined;
@@ -5688,6 +5691,8 @@ declare const ProductButton: ({ setting, builderProps, builderAttrs, style, styl
5688
5691
  translate?: string | undefined;
5689
5692
  outOfStockLabel?: string | undefined;
5690
5693
  unavailableLabel?: string | undefined;
5694
+ labelUnavailableTranslate?: string | undefined;
5695
+ labelOutOfStockTranslate?: string | undefined;
5691
5696
  actionEffect?: "buy-now" | "open-cart-drawer" | "continue-shopping" | "go-to-url" | undefined;
5692
5697
  customURL?: {
5693
5698
  link?: string | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.4.11",
3
+ "version": "2.4.13",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",