@gem-sdk/components 2.1.13-staging.42 → 2.1.13-staging.43

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.
@@ -34,7 +34,7 @@ const isHexTransparent = (hex)=>{
34
34
  return Boolean(a);
35
35
  };
36
36
  const youtubeShortsRegex = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([^"&?/\s]{11})$/i;
37
- const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin })=>{
37
+ const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin, isReplaceInventoryQuantity })=>{
38
38
  const hasLiquidInValue = new RegExp(/\{\{.*?\}\}|\{%.*?%\}/).test(val?.toString() ?? '');
39
39
  const translateLimit = pageContext?.isTranslateWithLocale ? 1000 : 5000;
40
40
  if (!translate || !val?.toString().trim() || val.toString().length > translateLimit || hasLiquidInValue || pageContext?.isPreviewing) return val ?? defaultVal;
@@ -46,6 +46,9 @@ const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, i
46
46
  if (isReplaceLocationOrigin) {
47
47
  locale += ` | replace: '$locationOrigin', locationOrigin`;
48
48
  }
49
+ if (isReplaceInventoryQuantity) {
50
+ locale += ` | replace: '$quantity$', {{ inventory_quantity }}`;
51
+ }
49
52
  if (isCapitalize) {
50
53
  locale = `${locale} | downcase`;
51
54
  }
@@ -37,28 +37,29 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps, pageCont
37
37
  const appendTypoClass = core.composeTypographyClassName(styles?.typo, styles?.typography);
38
38
  const appendTypoStyle = core.composeTypographyStyle(styles?.typo, styles?.typography);
39
39
  const templateStringDisplay = helpers$1.getDynamicSourceLocales({
40
- val: templateString,
40
+ val: helpers.transformHighlighTag(helpers.transformNumberTag(templateString || '', mainColor, ''), mainColor),
41
41
  uid: builderProps?.uid,
42
42
  settingId: 'template',
43
43
  pageContext,
44
- translate
44
+ translate,
45
+ isReplaceInventoryQuantity: true
45
46
  });
46
47
  const outOfStockMessageDisplay = helpers$1.getDynamicSourceLocales({
47
- val: outOfStockMessage,
48
+ val: helpers.transformHighlighTag(outOfStockMessage || '', mainColor),
48
49
  uid: builderProps?.uid,
49
50
  settingId: 'outOfStockMessage',
50
51
  pageContext,
51
52
  translate
52
53
  });
53
54
  const continueSellingDisplay = helpers$1.getDynamicSourceLocales({
54
- val: continueSelling,
55
+ val: helpers.transformHighlighTag(continueSelling || '', mainColor),
55
56
  uid: builderProps?.uid,
56
57
  settingId: 'continueSelling',
57
58
  pageContext,
58
59
  translate
59
60
  });
60
61
  const unlimitedQuantityMessageDisplay = helpers$1.getDynamicSourceLocales({
61
- val: unlimitedQuantityMessage,
62
+ val: helpers.transformHighlighTag(unlimitedQuantityMessage ?? helpers$1.getStaticLocale('StockCounter', 'let_buy_now'), mainColor),
62
63
  uid: builderProps?.uid,
63
64
  settingId: 'unlimitedQuantityMessage',
64
65
  pageContext,
@@ -153,13 +154,13 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps, pageCont
153
154
  style="${appendTypoStyle}"
154
155
  >
155
156
  {% if inventory_management == null and inventory_quantity <= 0 %}
156
- ${helpers.transformHighlighTag(unlimitedQuantityMessageDisplay ?? helpers$1.getStaticLocale('StockCounter', 'let_buy_now'), mainColor)}
157
+ ${unlimitedQuantityMessageDisplay}
157
158
  {% elsif available == false %}
158
- ${helpers.transformHighlighTag(outOfStockMessageDisplay || '', mainColor)}
159
+ ${outOfStockMessageDisplay}
159
160
  {% elsif available and inventory_policy == '${_const.CONTINUE_SELLING_WHEN_OUT_OF_STOCK.toLowerCase()}' and inventory_quantity <= 0 %}
160
- ${helpers.transformHighlighTag(continueSellingDisplay || '', mainColor)}
161
+ ${continueSellingDisplay}
161
162
  {% else %}
162
- ${helpers.transformHighlighTag(helpers.transformNumberTag(templateStringDisplay || '', mainColor, `{{ inventory_quantity }}`), mainColor)}
163
+ ${templateStringDisplay}
163
164
  {% endif %}
164
165
  </p>
165
166
  </div>
@@ -6,7 +6,7 @@ const transformHighlighTag = (template, stringColor)=>{
6
6
  if (!template.includes(`<${_const.DEFAULT_HIGHLIGHT_TAG}>`)) {
7
7
  return template;
8
8
  }
9
- const defaultClass = 'gp-text-white gp-py-1 gp-px-2 gp-mr-1 gp-inline-block gp-my-[1px] gp-bg-g-text-1';
9
+ const defaultClass = 'gp-text-white gp-py-1 gp-px-2 gp-mr-1 gp-inline-block gp-my-[1px]';
10
10
  let markTag = `<${_const.DEFAULT_HIGHLIGHT_TAG}>`;
11
11
  // Is hex color
12
12
  if (stringColor.includes('#')) {
@@ -32,7 +32,7 @@ const isHexTransparent = (hex)=>{
32
32
  return Boolean(a);
33
33
  };
34
34
  const youtubeShortsRegex = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([^"&?/\s]{11})$/i;
35
- const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin })=>{
35
+ const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal = '', translate, isReplaceLocationOrigin, isReplaceInventoryQuantity })=>{
36
36
  const hasLiquidInValue = new RegExp(/\{\{.*?\}\}|\{%.*?%\}/).test(val?.toString() ?? '');
37
37
  const translateLimit = pageContext?.isTranslateWithLocale ? 1000 : 5000;
38
38
  if (!translate || !val?.toString().trim() || val.toString().length > translateLimit || hasLiquidInValue || pageContext?.isPreviewing) return val ?? defaultVal;
@@ -44,6 +44,9 @@ const getDynamicSourceLocales = ({ val, uid, settingId, isLiquid, pageContext, i
44
44
  if (isReplaceLocationOrigin) {
45
45
  locale += ` | replace: '$locationOrigin', locationOrigin`;
46
46
  }
47
+ if (isReplaceInventoryQuantity) {
48
+ locale += ` | replace: '$quantity$', {{ inventory_quantity }}`;
49
+ }
47
50
  if (isCapitalize) {
48
51
  locale = `${locale} | downcase`;
49
52
  }
@@ -33,28 +33,29 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps, pageCont
33
33
  const appendTypoClass = composeTypographyClassName(styles?.typo, styles?.typography);
34
34
  const appendTypoStyle = composeTypographyStyle(styles?.typo, styles?.typography);
35
35
  const templateStringDisplay = getDynamicSourceLocales({
36
- val: templateString,
36
+ val: transformHighlighTag(transformNumberTag(templateString || '', mainColor, ''), mainColor),
37
37
  uid: builderProps?.uid,
38
38
  settingId: 'template',
39
39
  pageContext,
40
- translate
40
+ translate,
41
+ isReplaceInventoryQuantity: true
41
42
  });
42
43
  const outOfStockMessageDisplay = getDynamicSourceLocales({
43
- val: outOfStockMessage,
44
+ val: transformHighlighTag(outOfStockMessage || '', mainColor),
44
45
  uid: builderProps?.uid,
45
46
  settingId: 'outOfStockMessage',
46
47
  pageContext,
47
48
  translate
48
49
  });
49
50
  const continueSellingDisplay = getDynamicSourceLocales({
50
- val: continueSelling,
51
+ val: transformHighlighTag(continueSelling || '', mainColor),
51
52
  uid: builderProps?.uid,
52
53
  settingId: 'continueSelling',
53
54
  pageContext,
54
55
  translate
55
56
  });
56
57
  const unlimitedQuantityMessageDisplay = getDynamicSourceLocales({
57
- val: unlimitedQuantityMessage,
58
+ val: transformHighlighTag(unlimitedQuantityMessage ?? getStaticLocale('StockCounter', 'let_buy_now'), mainColor),
58
59
  uid: builderProps?.uid,
59
60
  settingId: 'unlimitedQuantityMessage',
60
61
  pageContext,
@@ -149,13 +150,13 @@ const StockCounter = ({ setting, styles, style, advanced, builderProps, pageCont
149
150
  style="${appendTypoStyle}"
150
151
  >
151
152
  {% if inventory_management == null and inventory_quantity <= 0 %}
152
- ${transformHighlighTag(unlimitedQuantityMessageDisplay ?? getStaticLocale('StockCounter', 'let_buy_now'), mainColor)}
153
+ ${unlimitedQuantityMessageDisplay}
153
154
  {% elsif available == false %}
154
- ${transformHighlighTag(outOfStockMessageDisplay || '', mainColor)}
155
+ ${outOfStockMessageDisplay}
155
156
  {% elsif available and inventory_policy == '${CONTINUE_SELLING_WHEN_OUT_OF_STOCK.toLowerCase()}' and inventory_quantity <= 0 %}
156
- ${transformHighlighTag(continueSellingDisplay || '', mainColor)}
157
+ ${continueSellingDisplay}
157
158
  {% else %}
158
- ${transformHighlighTag(transformNumberTag(templateStringDisplay || '', mainColor, `{{ inventory_quantity }}`), mainColor)}
159
+ ${templateStringDisplay}
159
160
  {% endif %}
160
161
  </p>
161
162
  </div>
@@ -4,7 +4,7 @@ const transformHighlighTag = (template, stringColor)=>{
4
4
  if (!template.includes(`<${DEFAULT_HIGHLIGHT_TAG}>`)) {
5
5
  return template;
6
6
  }
7
- const defaultClass = 'gp-text-white gp-py-1 gp-px-2 gp-mr-1 gp-inline-block gp-my-[1px] gp-bg-g-text-1';
7
+ const defaultClass = 'gp-text-white gp-py-1 gp-px-2 gp-mr-1 gp-inline-block gp-my-[1px]';
8
8
  let markTag = `<${DEFAULT_HIGHLIGHT_TAG}>`;
9
9
  // Is hex color
10
10
  if (stringColor.includes('#')) {
@@ -7796,12 +7796,13 @@ type DynamicSource = {
7796
7796
  defaultVal?: string;
7797
7797
  translate?: string;
7798
7798
  isReplaceLocationOrigin?: boolean;
7799
+ isReplaceInventoryQuantity?: boolean;
7799
7800
  };
7800
7801
  declare const isTransparentColor: (str?: string) => boolean;
7801
7802
  declare const isTransparentRGBA: (rgbStr: string) => boolean;
7802
7803
  declare const isHexTransparent: (hex: string) => boolean;
7803
7804
  declare const youtubeShortsRegex: RegExp;
7804
- declare const getDynamicSourceLocales: ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal, translate, isReplaceLocationOrigin, }: DynamicSource) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>;
7805
+ declare const getDynamicSourceLocales: ({ val, uid, settingId, isLiquid, pageContext, isCapitalize, defaultVal, translate, isReplaceLocationOrigin, isReplaceInventoryQuantity, }: DynamicSource) => string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode>;
7805
7806
  declare const getStaticLocale: (tag: string, key: string) => string;
7806
7807
  declare const getSettingPreloadData: (disabledValue: string, enabledValue?: string) => string;
7807
7808
  declare const getInsertLinkData: (defaultWrap: string, setting?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.1.13-staging.42",
3
+ "version": "2.1.13-staging.43",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@gem-sdk/core": "2.1.13-staging.28",
25
- "@gem-sdk/styles": "2.1.13-staging.41",
25
+ "@gem-sdk/styles": "2.1.13-staging.43",
26
26
  "@types/react-transition-group": "^4.4.5"
27
27
  },
28
28
  "dependencies": {