@gem-sdk/core 1.23.0-staging.268 → 1.23.0-staging.271
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/components/resize/Spacing.js +17 -6
- package/dist/cjs/helpers/variant.js +4 -4
- package/dist/cjs/hooks/useProduct.js +2 -1
- package/dist/esm/components/resize/Spacing.js +17 -6
- package/dist/esm/helpers/variant.js +4 -4
- package/dist/esm/hooks/useProduct.js +2 -1
- package/package.json +1 -1
|
@@ -116,6 +116,10 @@ function Spacing(props) {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
+
const isLayoutElement = (el)=>{
|
|
120
|
+
const tag = el.getAttribute('data-component-tag');
|
|
121
|
+
return tag === 'Row' || tag === 'Product';
|
|
122
|
+
};
|
|
119
123
|
const updateSpacing = react.useCallback(()=>{
|
|
120
124
|
const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
|
|
121
125
|
if (!$component) return;
|
|
@@ -128,15 +132,22 @@ function Spacing(props) {
|
|
|
128
132
|
const $marginBottom = ($spacing?.querySelector('[data-spacing-margin-bottom]')) || null;
|
|
129
133
|
if ($marginBottom) {
|
|
130
134
|
if ($bottomBg.current && $bottomDrag.current) {
|
|
131
|
-
|
|
135
|
+
let value = style.marginBottom;
|
|
136
|
+
if (parseFloat(value) < 0) {
|
|
137
|
+
value = '0';
|
|
138
|
+
}
|
|
132
139
|
$bottomBg.current.style.height = value;
|
|
133
140
|
$bottomDrag.current.style.top = value;
|
|
134
141
|
$marginBottom.setAttribute('data-spacing-margin-bottom-active', 'true');
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
if (isLayoutElement($component)) {
|
|
143
|
+
$bottomBg.current.style.left = '0';
|
|
144
|
+
} else {
|
|
145
|
+
const paddingLeft = style.paddingLeft;
|
|
146
|
+
const leftValue = `-${paddingLeft}`;
|
|
147
|
+
const translateCss = `translate(${leftValue}, -100%)`;
|
|
148
|
+
$bottomBg.current.style.left = leftValue;
|
|
149
|
+
$bottomDrag.current.style.transform = translateCss;
|
|
150
|
+
}
|
|
140
151
|
}
|
|
141
152
|
}
|
|
142
153
|
}, []);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function checkInStock(variant) {
|
|
3
|
+
function checkInStock(variant, product) {
|
|
4
4
|
if (!variant) return false;
|
|
5
|
-
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !isDefaultVariant(variant) || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
5
|
+
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !isDefaultVariant(variant, product) || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
6
6
|
}
|
|
7
|
-
function isDefaultVariant(variant) {
|
|
8
|
-
return variant?.title === 'Default Title';
|
|
7
|
+
function isDefaultVariant(variant, product) {
|
|
8
|
+
return Boolean(variant?.title === 'Default Title' && product?.options?.some((option)=>option.values.length > 1));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
exports.checkInStock = checkInStock;
|
|
@@ -149,7 +149,8 @@ const useCurrentVariant = ()=>{
|
|
|
149
149
|
};
|
|
150
150
|
const useCurrentVariantInStock = ()=>{
|
|
151
151
|
const currentVariant = useCurrentVariant();
|
|
152
|
-
|
|
152
|
+
const currentProduct = useProduct();
|
|
153
|
+
return variant.checkInStock(currentVariant, currentProduct);
|
|
153
154
|
};
|
|
154
155
|
const useVariantOutStock = (optionId, optionValue, options)=>{
|
|
155
156
|
const { selectedOptions } = useSelectedOption();
|
|
@@ -112,6 +112,10 @@ function Spacing(props) {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
+
const isLayoutElement = (el)=>{
|
|
116
|
+
const tag = el.getAttribute('data-component-tag');
|
|
117
|
+
return tag === 'Row' || tag === 'Product';
|
|
118
|
+
};
|
|
115
119
|
const updateSpacing = useCallback(()=>{
|
|
116
120
|
const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
|
|
117
121
|
if (!$component) return;
|
|
@@ -124,15 +128,22 @@ function Spacing(props) {
|
|
|
124
128
|
const $marginBottom = ($spacing?.querySelector('[data-spacing-margin-bottom]')) || null;
|
|
125
129
|
if ($marginBottom) {
|
|
126
130
|
if ($bottomBg.current && $bottomDrag.current) {
|
|
127
|
-
|
|
131
|
+
let value = style.marginBottom;
|
|
132
|
+
if (parseFloat(value) < 0) {
|
|
133
|
+
value = '0';
|
|
134
|
+
}
|
|
128
135
|
$bottomBg.current.style.height = value;
|
|
129
136
|
$bottomDrag.current.style.top = value;
|
|
130
137
|
$marginBottom.setAttribute('data-spacing-margin-bottom-active', 'true');
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
138
|
+
if (isLayoutElement($component)) {
|
|
139
|
+
$bottomBg.current.style.left = '0';
|
|
140
|
+
} else {
|
|
141
|
+
const paddingLeft = style.paddingLeft;
|
|
142
|
+
const leftValue = `-${paddingLeft}`;
|
|
143
|
+
const translateCss = `translate(${leftValue}, -100%)`;
|
|
144
|
+
$bottomBg.current.style.left = leftValue;
|
|
145
|
+
$bottomDrag.current.style.transform = translateCss;
|
|
146
|
+
}
|
|
136
147
|
}
|
|
137
148
|
}
|
|
138
149
|
}, []);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
function checkInStock(variant) {
|
|
1
|
+
function checkInStock(variant, product) {
|
|
2
2
|
if (!variant) return false;
|
|
3
|
-
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !isDefaultVariant(variant) || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
3
|
+
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !isDefaultVariant(variant, product) || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
4
4
|
}
|
|
5
|
-
function isDefaultVariant(variant) {
|
|
6
|
-
return variant?.title === 'Default Title';
|
|
5
|
+
function isDefaultVariant(variant, product) {
|
|
6
|
+
return Boolean(variant?.title === 'Default Title' && product?.options?.some((option)=>option.values.length > 1));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export { checkInStock };
|
|
@@ -147,7 +147,8 @@ const useCurrentVariant = ()=>{
|
|
|
147
147
|
};
|
|
148
148
|
const useCurrentVariantInStock = ()=>{
|
|
149
149
|
const currentVariant = useCurrentVariant();
|
|
150
|
-
|
|
150
|
+
const currentProduct = useProduct();
|
|
151
|
+
return checkInStock(currentVariant, currentProduct);
|
|
151
152
|
};
|
|
152
153
|
const useVariantOutStock = (optionId, optionValue, options)=>{
|
|
153
154
|
const { selectedOptions } = useSelectedOption();
|