@gem-sdk/components 2.4.11 → 2.4.12

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.
@@ -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,
@@ -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>`)}
@@ -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,
@@ -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.12",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",