@gem-sdk/core 1.9.64 → 1.10.11

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.
@@ -33,6 +33,9 @@ const ComponentWrapperPreview = ({ children , ...props })=>{
33
33
  if (editorConfigs.component?.noSetting) {
34
34
  customProps['data-component-no-setting'] = true;
35
35
  }
36
+ if (editorConfigs.component?.isThirdParty) {
37
+ customProps['data-component-is-third-party'] = true;
38
+ }
36
39
  if (editorConfigs.toolbar?.hide) {
37
40
  customProps['data-toolbar-hide'] = true;
38
41
  }
@@ -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)[0];
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) {
@@ -29,6 +29,9 @@ const ComponentWrapperPreview = ({ children , ...props })=>{
29
29
  if (editorConfigs.component?.noSetting) {
30
30
  customProps['data-component-no-setting'] = true;
31
31
  }
32
+ if (editorConfigs.component?.isThirdParty) {
33
+ customProps['data-component-is-third-party'] = true;
34
+ }
32
35
  if (editorConfigs.toolbar?.hide) {
33
36
  customProps['data-toolbar-hide'] = true;
34
37
  }
@@ -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)[0];
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) {
@@ -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> & {
@@ -840,6 +841,7 @@ type ComponentSetting<P extends BaseProps> = {
840
841
  noDuplicate?: boolean;
841
842
  noDragDrop?: boolean;
842
843
  noSetting?: boolean;
844
+ isThirdParty?: boolean;
843
845
  };
844
846
  slots?: {
845
847
  children: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.9.64",
3
+ "version": "1.10.11",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",