@gem-sdk/core 1.14.0-dev.314 → 1.14.0-dev.319

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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var useSWR=require("swr"),productValueLabel_generated=require("../graphql/queries/product-value-label.generated.js"),variantPresets=require("../components/src/product/helpers/variant-presets.js"),shop=require("./shop.js"),useFetchHandle=require("./useFetchHandle.js"),ShopContext=require("../contexts/ShopContext.js");let swatchChange=!1,colorChange=!1;const useInitialSwatchesOptions=e=>{let t=useFetchHandle.useFetchHandle(),a=ShopContext.useShopStore(e=>e.changeSwatches),{swatches:o}=shop.useSwatches(),{data:s}=useSWR(["/query/productOptionName",{}],async()=>fetchProductValueLabel(t),{revalidateOnMount:!0}),r=[];if(o?.forEach(e=>{r.push(e.optionTitle)}),s?.productOptionName?.forEach(e=>{r.includes(e)||(swatchChange=!0,o?.push({optionTitle:e,optionType:"rectangle_list",optionValues:[]}))}),!e)return[];setDefaultSwatches(o,e),o?.length&&(swatchChange||colorChange)&&(window?.parent?.postMessage?.(JSON.stringify({type:"update-swatches",swatches:o}),"*"),a(o))},getColorDefault=(e,t)=>{let a=e?variantPresets.colorPreset[e.toLocaleLowerCase()]:void 0,o=a?[a]:[],s=t?.[0];return!s&&o.length&&(colorChange=!0),s?[s]:o},getProductOptionsLabelByName=(e,t)=>{let a=[],o=e.find(e=>e.name===t);return o?.values.forEach(e=>{a.push(e.label??"")}),a},getSwatchesOptionsLabel=e=>{let t=[];return e.forEach(e=>{t.push(e.label??"")}),t},setDefaultSwatches=(e,t)=>(e&&e?.map(e=>{let a=getProductOptionsLabelByName(t,e.optionTitle),o=getSwatchesOptionsLabel(e.optionValues);a.forEach(t=>{o.includes(t)||e.optionValues.push({label:t,colors:getColorDefault(t),imageUrl:""})}),e.optionValues.map(e=>({...e,colors:getColorDefault(e.label,e.colors)}))}),e),fetchProductValueLabel=async e=>{let t={},a=async t=>{let a=await e([productValueLabel_generated.ProductOptionNameDocument,t]);return a};return a(t)};exports.default=useInitialSwatchesOptions;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var useSWR=require("swr"),productValueLabel_generated=require("../graphql/queries/product-value-label.generated.js"),variantPresets=require("../components/src/product/helpers/variant-presets.js"),shop=require("./shop.js"),useFetchHandle=require("./useFetchHandle.js"),ShopContext=require("../contexts/ShopContext.js");let swatchChange=!1,colorChange=!1;const useInitialSwatchesOptions=e=>{let t=useFetchHandle.useFetchHandle(),a=ShopContext.useShopStore(e=>e.changeSwatches),{swatches:o}=shop.useSwatches(),{data:s}=useSWR(["/query/productOptionName",{}],async()=>fetchProductValueLabel(t),{revalidateOnMount:!0}),r=[];if(o?.forEach(e=>{r.push(e.optionTitle)}),s?.productOptionName?.forEach(e=>{r.includes(e)||(swatchChange=!0,o?.push({optionTitle:e,optionType:"rectangle_list",optionValues:[]}))}),!e)return[];setDefaultSwatches(o,e),o?.length&&(swatchChange||colorChange)&&(window?.parent?.postMessage?.(JSON.stringify({type:"update-swatches",swatches:o}),"*"),a(o))},getColorDefault=(e,t)=>{let a=e?variantPresets.colorPreset[e.toLocaleLowerCase()]:void 0,o=a?[a]:[],s=t?.[0];return!s&&o.length&&(colorChange=!0),s?[s]:o},getProductOptionsLabelByName=(e,t)=>{let a=[],o=e.find(e=>e.name===t);return o?.values.forEach(e=>{a.push(e.label??"")}),a},getSwatchesOptionsLabel=e=>{let t=[];return e.forEach(e=>{t.push(e.label??"")}),t},setDefaultSwatches=(e,t)=>(e&&e?.map(e=>{let a=getProductOptionsLabelByName(t,e.optionTitle),o=getSwatchesOptionsLabel(e.optionValues);a.forEach(t=>{o.includes(t)||e.optionValues.push({label:t,colors:getColorDefault(t),imageUrl:""})}),e.optionValues=e.optionValues.map(e=>(void 0===e.imageUrl&&(swatchChange=!0),{label:e.label??"",colors:getColorDefault(e.label,e.colors),imageUrl:e.imageUrl??""}))}),e),fetchProductValueLabel=async e=>{let t={},a=async t=>{let a=await e([productValueLabel_generated.ProductOptionNameDocument,t]);return a};return a(t)};exports.default=useInitialSwatchesOptions;
@@ -1 +1 @@
1
- import e from"swr";import{ProductOptionNameDocument as t}from"../graphql/queries/product-value-label.generated.js";import{colorPreset as o}from"../components/src/product/helpers/variant-presets.js";import{useSwatches as a}from"./shop.js";import{useFetchHandle as l}from"./useFetchHandle.js";import{useShopStore as r}from"../contexts/ShopContext.js";let swatchChange=!1,colorChange=!1,useInitialSwatchesOptions=t=>{let o=l(),s=r(e=>e.changeSwatches),{swatches:n}=a(),{data:p}=e(["/query/productOptionName",{}],async()=>fetchProductValueLabel(o),{revalidateOnMount:!0}),c=[];if(n?.forEach(e=>{c.push(e.optionTitle)}),p?.productOptionName?.forEach(e=>{c.includes(e)||(swatchChange=!0,n?.push({optionTitle:e,optionType:"rectangle_list",optionValues:[]}))}),!t)return[];setDefaultSwatches(n,t),n?.length&&(swatchChange||colorChange)&&(window?.parent?.postMessage?.(JSON.stringify({type:"update-swatches",swatches:n}),"*"),s(n))},getColorDefault=(e,t)=>{let a=e?o[e.toLocaleLowerCase()]:void 0,l=a?[a]:[],r=t?.[0];return!r&&l.length&&(colorChange=!0),r?[r]:l},getProductOptionsLabelByName=(e,t)=>{let o=[],a=e.find(e=>e.name===t);return a?.values.forEach(e=>{o.push(e.label??"")}),o},getSwatchesOptionsLabel=e=>{let t=[];return e.forEach(e=>{t.push(e.label??"")}),t},setDefaultSwatches=(e,t)=>(e&&e?.map(e=>{let o=getProductOptionsLabelByName(t,e.optionTitle),a=getSwatchesOptionsLabel(e.optionValues);o.forEach(t=>{a.includes(t)||e.optionValues.push({label:t,colors:getColorDefault(t),imageUrl:""})}),e.optionValues.map(e=>({...e,colors:getColorDefault(e.label,e.colors)}))}),e),fetchProductValueLabel=async e=>{let o={},a=async o=>{let a=await e([t,o]);return a};return a(o)};export{useInitialSwatchesOptions as default};
1
+ import e from"swr";import{ProductOptionNameDocument as t}from"../graphql/queries/product-value-label.generated.js";import{colorPreset as a}from"../components/src/product/helpers/variant-presets.js";import{useSwatches as o}from"./shop.js";import{useFetchHandle as l}from"./useFetchHandle.js";import{useShopStore as r}from"../contexts/ShopContext.js";let swatchChange=!1,colorChange=!1,useInitialSwatchesOptions=t=>{let a=l(),s=r(e=>e.changeSwatches),{swatches:n}=o(),{data:i}=e(["/query/productOptionName",{}],async()=>fetchProductValueLabel(a),{revalidateOnMount:!0}),p=[];if(n?.forEach(e=>{p.push(e.optionTitle)}),i?.productOptionName?.forEach(e=>{p.includes(e)||(swatchChange=!0,n?.push({optionTitle:e,optionType:"rectangle_list",optionValues:[]}))}),!t)return[];setDefaultSwatches(n,t),n?.length&&(swatchChange||colorChange)&&(window?.parent?.postMessage?.(JSON.stringify({type:"update-swatches",swatches:n}),"*"),s(n))},getColorDefault=(e,t)=>{let o=e?a[e.toLocaleLowerCase()]:void 0,l=o?[o]:[],r=t?.[0];return!r&&l.length&&(colorChange=!0),r?[r]:l},getProductOptionsLabelByName=(e,t)=>{let a=[],o=e.find(e=>e.name===t);return o?.values.forEach(e=>{a.push(e.label??"")}),a},getSwatchesOptionsLabel=e=>{let t=[];return e.forEach(e=>{t.push(e.label??"")}),t},setDefaultSwatches=(e,t)=>(e&&e?.map(e=>{let a=getProductOptionsLabelByName(t,e.optionTitle),o=getSwatchesOptionsLabel(e.optionValues);a.forEach(t=>{o.includes(t)||e.optionValues.push({label:t,colors:getColorDefault(t),imageUrl:""})}),e.optionValues=e.optionValues.map(e=>(void 0===e.imageUrl&&(swatchChange=!0),{label:e.label??"",colors:getColorDefault(e.label,e.colors),imageUrl:e.imageUrl??""}))}),e),fetchProductValueLabel=async e=>{let a={},o=async a=>{let o=await e([t,a]);return o};return o(a)};export{useInitialSwatchesOptions as default};
@@ -555,6 +555,7 @@ type TypographyControlType<T> = SharedControlType<T> & {
555
555
  type PickLinkControlType<T> = SharedControlType<T> & {
556
556
  type: 'pick-link';
557
557
  pickLinkLabel?: string;
558
+ pickLinkPlaceholder?: string;
558
559
  };
559
560
 
560
561
  type BehaviorStateControlType<T> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.14.0-dev.314",
3
+ "version": "1.14.0-dev.319",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",