@gem-sdk/core 1.10.14 → 1.10.16

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.
@@ -340,10 +340,15 @@ const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
340
340
  }));
341
341
  const BuilderPreviewProvider = ({ children , state , lazy , ...passProps })=>{
342
342
  const Component = lazy ? react.Suspense : react.Fragment;
343
+ const value = react.useMemo(()=>{
344
+ return createBuilderPreviewProvider(state);
345
+ }, [
346
+ state
347
+ ]);
343
348
  return /*#__PURE__*/ jsxRuntime.jsx(Component, {
344
349
  children: /*#__PURE__*/ jsxRuntime.jsx(BuilderPreviewContext.Provider, {
345
350
  ...passProps,
346
- value: createBuilderPreviewProvider(state),
351
+ value: value,
347
352
  children: children
348
353
  })
349
354
  });
@@ -103,8 +103,9 @@ const ProductProvider = ({ children , product , initialVariantId , quantity =1
103
103
  let featuredImageGlobal = undefined;
104
104
  if (product) {
105
105
  const variants = flattenConnection.flattenConnection(product.variants);
106
- const firstVariant = flattenConnection.flattenConnection(product.variants).find((item)=>useProduct.checkInStock(item));
107
- const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariant;
106
+ const firstVariant = variants[0];
107
+ const firstVariantInStock = variants.find((item)=>useProduct.checkInStock(item));
108
+ const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariantInStock ?? firstVariant;
108
109
  selectedOptions = initialVariant?.selectedOptions.reduce((acc, option)=>{
109
110
  if (option.name) {
110
111
  return {
@@ -167,10 +167,7 @@ const handleConvertClassColorDynamicBtn = (value)=>{
167
167
  };
168
168
  const composeBorderCss = (borderV)=>{
169
169
  if (!borderV) return '';
170
- const { border , width , color , isCustom } = borderV;
171
- if (!isCustom) {
172
- return '';
173
- }
170
+ const { border , width , color } = borderV;
174
171
  return `${border ? `border-style: ${border};` : ''}
175
172
  ${width ? `border-width: ${width};` : ''}
176
173
  ${color ? `border-color: ${colors.getSingleColorVariable(color)};` : ''}
@@ -78,8 +78,8 @@ const loopFetchProducts = async (fetcher, { ids , isSample , isStorefront })=>{
78
78
  firstMedia: 1,
79
79
  firstVariant: 1,
80
80
  orderBy: {
81
- field: 'TITLE',
82
- direction: 'ASC'
81
+ field: 'PLATFORM_CREATED_AT',
82
+ direction: 'DESC'
83
83
  },
84
84
  orderByMedia: {
85
85
  field: 'POSITION',
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { useContext, createContext, Suspense, Fragment } from 'react';
2
+ import { useMemo, useContext, createContext, Suspense, Fragment } from 'react';
3
3
  import { useStore, createStore } from 'zustand';
4
4
  import { cloneDeep } from '../helpers/clone-deep.js';
5
5
  import { normalizeBuilderData } from '../helpers/normalize-builder-data.js';
@@ -338,10 +338,15 @@ const createBuilderPreviewProvider = (args)=>createStore((set, get)=>({
338
338
  }));
339
339
  const BuilderPreviewProvider = ({ children , state , lazy , ...passProps })=>{
340
340
  const Component = lazy ? Suspense : Fragment;
341
+ const value = useMemo(()=>{
342
+ return createBuilderPreviewProvider(state);
343
+ }, [
344
+ state
345
+ ]);
341
346
  return /*#__PURE__*/ jsx(Component, {
342
347
  children: /*#__PURE__*/ jsx(BuilderPreviewContext.Provider, {
343
348
  ...passProps,
344
- value: createBuilderPreviewProvider(state),
349
+ value: value,
345
350
  children: children
346
351
  })
347
352
  });
@@ -101,8 +101,9 @@ const ProductProvider = ({ children , product , initialVariantId , quantity =1
101
101
  let featuredImageGlobal = undefined;
102
102
  if (product) {
103
103
  const variants = flattenConnection(product.variants);
104
- const firstVariant = flattenConnection(product.variants).find((item)=>checkInStock(item));
105
- const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariant;
104
+ const firstVariant = variants[0];
105
+ const firstVariantInStock = variants.find((item)=>checkInStock(item));
106
+ const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariantInStock ?? firstVariant;
106
107
  selectedOptions = initialVariant?.selectedOptions.reduce((acc, option)=>{
107
108
  if (option.name) {
108
109
  return {
@@ -165,10 +165,7 @@ const handleConvertClassColorDynamicBtn = (value)=>{
165
165
  };
166
166
  const composeBorderCss = (borderV)=>{
167
167
  if (!borderV) return '';
168
- const { border , width , color , isCustom } = borderV;
169
- if (!isCustom) {
170
- return '';
171
- }
168
+ const { border , width , color } = borderV;
172
169
  return `${border ? `border-style: ${border};` : ''}
173
170
  ${width ? `border-width: ${width};` : ''}
174
171
  ${color ? `border-color: ${getSingleColorVariable(color)};` : ''}
@@ -76,8 +76,8 @@ const loopFetchProducts = async (fetcher, { ids , isSample , isStorefront })=>{
76
76
  firstMedia: 1,
77
77
  firstVariant: 1,
78
78
  orderBy: {
79
- field: 'TITLE',
80
- direction: 'ASC'
79
+ field: 'PLATFORM_CREATED_AT',
80
+ direction: 'DESC'
81
81
  },
82
82
  orderByMedia: {
83
83
  field: 'POSITION',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.10.14",
3
+ "version": "1.10.16",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",