@gem-sdk/core 1.10.1 → 1.10.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.
- package/dist/cjs/contexts/ProductContext.js +2 -1
- package/dist/cjs/helpers/borders.js +1 -1
- package/dist/cjs/helpers/make-style.js +1 -1
- package/dist/cjs/helpers/queries/get-product.js +1 -1
- package/dist/esm/contexts/ProductContext.js +2 -1
- package/dist/esm/helpers/borders.js +1 -1
- package/dist/esm/helpers/make-style.js +1 -1
- package/dist/esm/helpers/queries/get-product.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var zustand = require('zustand');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var flattenConnection = require('../helpers/flatten-connection.js');
|
|
7
|
+
var useProduct = require('../hooks/useProduct.js');
|
|
7
8
|
|
|
8
9
|
// const { Provider, useStore } = createContext<StoreApi<ProductContextProps>>();
|
|
9
10
|
const ProductContext = /*#__PURE__*/ react.createContext(null);
|
|
@@ -102,7 +103,7 @@ const ProductProvider = ({ children , product , initialVariantId , quantity =1
|
|
|
102
103
|
let featuredImageGlobal = undefined;
|
|
103
104
|
if (product) {
|
|
104
105
|
const variants = flattenConnection.flattenConnection(product.variants);
|
|
105
|
-
const firstVariant = flattenConnection.flattenConnection(product.variants)
|
|
106
|
+
const firstVariant = flattenConnection.flattenConnection(product.variants).find((item)=>useProduct.checkInStock(item));
|
|
106
107
|
const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariant;
|
|
107
108
|
selectedOptions = initialVariant?.selectedOptions.reduce((acc, option)=>{
|
|
108
109
|
if (option.name) {
|
|
@@ -168,7 +168,7 @@ const handleConvertClassColorDynamicBtn = (value)=>{
|
|
|
168
168
|
const composeBorderCss = (borderV)=>{
|
|
169
169
|
if (!borderV) return '';
|
|
170
170
|
const { border , width , color , isCustom } = borderV;
|
|
171
|
-
if (isCustom) {
|
|
171
|
+
if (!isCustom) {
|
|
172
172
|
return '';
|
|
173
173
|
}
|
|
174
174
|
return `${border ? `border-style: ${border};` : ''}
|
|
@@ -40,7 +40,7 @@ const makeStyleResponsive = (name, value)=>{
|
|
|
40
40
|
const makeWidth = (widthValue, fullWidthValue)=>{
|
|
41
41
|
const getVal = (deviceValue, widthValue, fullWidthValue)=>{
|
|
42
42
|
const widthVal = widthValue?.[deviceValue];
|
|
43
|
-
const fullWidthVal = fullWidthValue?.[deviceValue];
|
|
43
|
+
const fullWidthVal = fullWidthValue?.[deviceValue] === undefined ? fullWidthValue?.['desktop'] : fullWidthValue?.[deviceValue];
|
|
44
44
|
if (fullWidthVal) {
|
|
45
45
|
return '100%';
|
|
46
46
|
} else if (fullWidthVal === false) {
|
|
@@ -36,7 +36,7 @@ const getProduct = async (fetcher, { id , isSample , isStorefront })=>{
|
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
38
|
const orderBy = {
|
|
39
|
-
field: '
|
|
39
|
+
field: 'CREATED_AT',
|
|
40
40
|
direction: 'DESC'
|
|
41
41
|
};
|
|
42
42
|
const fetchProduct = async (fetcher, { id , isSample , isStorefront })=>{
|
|
@@ -2,6 +2,7 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useStore, createStore } from 'zustand';
|
|
3
3
|
import { useId, useMemo, useContext, createContext } from 'react';
|
|
4
4
|
import { flattenConnection } from '../helpers/flatten-connection.js';
|
|
5
|
+
import { checkInStock } from '../hooks/useProduct.js';
|
|
5
6
|
|
|
6
7
|
// const { Provider, useStore } = createContext<StoreApi<ProductContextProps>>();
|
|
7
8
|
const ProductContext = /*#__PURE__*/ createContext(null);
|
|
@@ -100,7 +101,7 @@ const ProductProvider = ({ children , product , initialVariantId , quantity =1
|
|
|
100
101
|
let featuredImageGlobal = undefined;
|
|
101
102
|
if (product) {
|
|
102
103
|
const variants = flattenConnection(product.variants);
|
|
103
|
-
const firstVariant = flattenConnection(product.variants)
|
|
104
|
+
const firstVariant = flattenConnection(product.variants).find((item)=>checkInStock(item));
|
|
104
105
|
const initialVariant = variants.find((v)=>v?.id === initialVariantId) ?? firstVariant;
|
|
105
106
|
selectedOptions = initialVariant?.selectedOptions.reduce((acc, option)=>{
|
|
106
107
|
if (option.name) {
|
|
@@ -166,7 +166,7 @@ const handleConvertClassColorDynamicBtn = (value)=>{
|
|
|
166
166
|
const composeBorderCss = (borderV)=>{
|
|
167
167
|
if (!borderV) return '';
|
|
168
168
|
const { border , width , color , isCustom } = borderV;
|
|
169
|
-
if (isCustom) {
|
|
169
|
+
if (!isCustom) {
|
|
170
170
|
return '';
|
|
171
171
|
}
|
|
172
172
|
return `${border ? `border-style: ${border};` : ''}
|
|
@@ -38,7 +38,7 @@ const makeStyleResponsive = (name, value)=>{
|
|
|
38
38
|
const makeWidth = (widthValue, fullWidthValue)=>{
|
|
39
39
|
const getVal = (deviceValue, widthValue, fullWidthValue)=>{
|
|
40
40
|
const widthVal = widthValue?.[deviceValue];
|
|
41
|
-
const fullWidthVal = fullWidthValue?.[deviceValue];
|
|
41
|
+
const fullWidthVal = fullWidthValue?.[deviceValue] === undefined ? fullWidthValue?.['desktop'] : fullWidthValue?.[deviceValue];
|
|
42
42
|
if (fullWidthVal) {
|
|
43
43
|
return '100%';
|
|
44
44
|
} else if (fullWidthVal === false) {
|
|
@@ -34,7 +34,7 @@ const getProduct = async (fetcher, { id , isSample , isStorefront })=>{
|
|
|
34
34
|
};
|
|
35
35
|
};
|
|
36
36
|
const orderBy = {
|
|
37
|
-
field: '
|
|
37
|
+
field: 'CREATED_AT',
|
|
38
38
|
direction: 'DESC'
|
|
39
39
|
};
|
|
40
40
|
const fetchProduct = async (fetcher, { id , isSample , isStorefront })=>{
|
package/dist/types/index.d.ts
CHANGED
|
@@ -614,6 +614,7 @@ type RadiusPresetControlType<T> = SharedControlType<T> & {
|
|
|
614
614
|
type SizeControlType<T> = SharedControlType<T> & {
|
|
615
615
|
type: 'size';
|
|
616
616
|
component?: 'tag' | string;
|
|
617
|
+
hasNoneValue?: boolean;
|
|
617
618
|
};
|
|
618
619
|
|
|
619
620
|
type ChildItemType<T> = SharedControlType<T> & {
|