pb-sxp-ui 1.20.17 → 1.20.19
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/index.cjs +732 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +291 -0
- package/dist/index.js +732 -32
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +44 -5
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +44 -5
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +732 -32
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +44 -5
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/index.d.ts +2 -0
- package/es/core/context/SxpDataSourceProvider.d.ts +1 -1
- package/es/materials/sxp/popup/AddToCart/index.d.ts +33 -0
- package/es/materials/sxp/popup/AddToCart/index.js +279 -0
- package/es/materials/sxp/popup/AddToCart/interactionRender.d.ts +3 -0
- package/es/materials/sxp/popup/AddToCart/interactionRender.js +11 -0
- package/es/materials/sxp/popup/AddToCart/material.d.ts +2 -0
- package/es/materials/sxp/popup/AddToCart/material.js +75 -0
- package/es/materials/sxp/popup/AddToCart/settingRender.d.ts +160 -0
- package/es/materials/sxp/popup/AddToCart/settingRender.js +277 -0
- package/es/materials/sxp/popup/CommodityDetail/index.d.ts +2 -0
- package/es/materials/sxp/popup/CommodityDetail/index.js +24 -6
- package/es/materials/sxp/popup/CommodityDetail/settingRender.d.ts +13 -0
- package/es/materials/sxp/popup/CommodityDetail/settingRender.js +16 -0
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -2
- package/es/materials/sxp/popup/index.d.ts +1 -0
- package/es/materials/sxp/popup/index.js +1 -0
- package/lib/core/components/SxpPageRender/index.d.ts +2 -0
- package/lib/core/context/SxpDataSourceProvider.d.ts +1 -1
- package/lib/materials/sxp/popup/AddToCart/index.d.ts +33 -0
- package/lib/materials/sxp/popup/AddToCart/index.js +281 -0
- package/lib/materials/sxp/popup/AddToCart/interactionRender.d.ts +3 -0
- package/lib/materials/sxp/popup/AddToCart/interactionRender.js +14 -0
- package/lib/materials/sxp/popup/AddToCart/material.d.ts +2 -0
- package/lib/materials/sxp/popup/AddToCart/material.js +79 -0
- package/lib/materials/sxp/popup/AddToCart/settingRender.d.ts +160 -0
- package/lib/materials/sxp/popup/AddToCart/settingRender.js +279 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.d.ts +2 -0
- package/lib/materials/sxp/popup/CommodityDetail/index.js +24 -6
- package/lib/materials/sxp/popup/CommodityDetail/settingRender.d.ts +13 -0
- package/lib/materials/sxp/popup/CommodityDetail/settingRender.js +16 -0
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +2 -2
- package/lib/materials/sxp/popup/index.d.ts +1 -0
- package/lib/materials/sxp/popup/index.js +1 -0
- package/package.json +1 -1
|
@@ -12,7 +12,7 @@ export interface IEventTimeType {
|
|
|
12
12
|
time: Date;
|
|
13
13
|
target: EventTarget;
|
|
14
14
|
}
|
|
15
|
-
export type ICapiEventNameType = 'PageView' | 'ProductView' | 'ViewContent' | 'ClickCTA' | 'ContentSwipe' | 'Engagement' | 'ExitFeed';
|
|
15
|
+
export type ICapiEventNameType = 'PageView' | 'ProductView' | 'ViewContent' | 'ClickCTA' | 'ContentSwipe' | 'Engagement' | 'ExitFeed' | 'AddToCart';
|
|
16
16
|
export interface ISxpDataSourceContext {
|
|
17
17
|
rtcList: RecItemType[];
|
|
18
18
|
setRtcList?: React.Dispatch<React.SetStateAction<RecItemType[]>>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FC, CSSProperties } from 'react';
|
|
2
|
+
import './index.less';
|
|
3
|
+
export interface IAddToCartPopupProps {
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
isActive?: boolean;
|
|
6
|
+
index?: number;
|
|
7
|
+
shopifyDomain?: string;
|
|
8
|
+
storefrontAccessToken?: string;
|
|
9
|
+
variantStyles?: {
|
|
10
|
+
title?: CSSProperties;
|
|
11
|
+
price?: CSSProperties;
|
|
12
|
+
option?: CSSProperties;
|
|
13
|
+
selectedOption?: CSSProperties;
|
|
14
|
+
};
|
|
15
|
+
buttonStyle?: CSSProperties;
|
|
16
|
+
quantityStyle?: CSSProperties;
|
|
17
|
+
texts?: {
|
|
18
|
+
addToCart?: string;
|
|
19
|
+
selectOptions?: string;
|
|
20
|
+
loading?: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
color?: string;
|
|
23
|
+
size?: string;
|
|
24
|
+
material?: string;
|
|
25
|
+
style?: string;
|
|
26
|
+
};
|
|
27
|
+
popupBg?: {
|
|
28
|
+
horizontalMargin?: number;
|
|
29
|
+
bottomMargin?: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
declare const AddToCartPopup: FC<IAddToCartPopupProps>;
|
|
33
|
+
export default AddToCartPopup;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
|
+
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
3
|
+
import { useSxpDataSource } from '../../../../core/hooks';
|
|
4
|
+
import { useEventReport } from '../../../../core/hooks/useEventReport';
|
|
5
|
+
import { setFontForText } from '../../../../core/utils/tool';
|
|
6
|
+
import './index.less';
|
|
7
|
+
const AddToCartPopup = (_a) => {
|
|
8
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
9
|
+
var { style, isActive = true, index, shopifyDomain = '', storefrontAccessToken = '', variantStyles = {}, buttonStyle = {}, quantityStyle = {}, texts = {}, popupBg = {} } = _a, props = __rest(_a, ["style", "isActive", "index", "shopifyDomain", "storefrontAccessToken", "variantStyles", "buttonStyle", "quantityStyle", "texts", "popupBg"]);
|
|
10
|
+
const { sxpParameter, popupDetailData, isPreview, bffFbReport, globalConfig } = useSxpDataSource();
|
|
11
|
+
const { jumpToWeb } = useEventReport();
|
|
12
|
+
const curTimeRef = useRef(null);
|
|
13
|
+
const [productData, setProductData] = useState(null);
|
|
14
|
+
const [selectedOptions, setSelectedOptions] = useState({});
|
|
15
|
+
const [selectedVariant, setSelectedVariant] = useState(null);
|
|
16
|
+
const [quantity, setQuantity] = useState(1);
|
|
17
|
+
const [loading, setLoading] = useState(true);
|
|
18
|
+
const [error, setError] = useState(null);
|
|
19
|
+
const data = popupDetailData;
|
|
20
|
+
const product = (_c = (_b = data === null || data === void 0 ? void 0 : data.video) === null || _b === void 0 ? void 0 : _b.bindProduct) !== null && _c !== void 0 ? _c : (_e = (_d = data === null || data === void 0 ? void 0 : data.video) === null || _d === void 0 ? void 0 : _d.bindProducts) === null || _e === void 0 ? void 0 : _e[0];
|
|
21
|
+
const cta = product === null || product === void 0 ? void 0 : product.bindCta;
|
|
22
|
+
const position = (_g = (_f = popupDetailData === null || popupDetailData === void 0 ? void 0 : popupDetailData.index) !== null && _f !== void 0 ? _f : index) !== null && _g !== void 0 ? _g : 0;
|
|
23
|
+
const finalShopifyDomain = shopifyDomain || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.shopifyDomain) || 'dev-store-749237498237498636.myshopify.com';
|
|
24
|
+
const finalStorefrontToken = storefrontAccessToken || (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.storefrontAccessToken) || '77d894c490f79430ce7bd0a7efdff6b7';
|
|
25
|
+
const productId = (product === null || product === void 0 ? void 0 : product.itemId) || '';
|
|
26
|
+
const finalTexts = {
|
|
27
|
+
addToCart: texts.addToCart || 'Add to Cart',
|
|
28
|
+
selectOptions: texts.selectOptions || 'Please select options',
|
|
29
|
+
loading: texts.loading || 'Loading...',
|
|
30
|
+
error: texts.error || 'Failed to load product',
|
|
31
|
+
color: texts.color || 'Color',
|
|
32
|
+
size: texts.size || 'Size',
|
|
33
|
+
material: texts.material || 'Material',
|
|
34
|
+
style: texts.style || 'Style'
|
|
35
|
+
};
|
|
36
|
+
const fetchProductData = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
var _m;
|
|
38
|
+
if (!productId || !finalShopifyDomain || !finalStorefrontToken) {
|
|
39
|
+
console.log('[AddToCartPopup] 缺少必要配置:', {
|
|
40
|
+
productId,
|
|
41
|
+
shopifyDomain: finalShopifyDomain,
|
|
42
|
+
hasToken: !!finalStorefrontToken
|
|
43
|
+
});
|
|
44
|
+
setLoading(false);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
console.log('[AddToCartPopup] 开始加载商品数据:', {
|
|
48
|
+
productId,
|
|
49
|
+
shopifyDomain: finalShopifyDomain
|
|
50
|
+
});
|
|
51
|
+
setLoading(true);
|
|
52
|
+
setError(null);
|
|
53
|
+
try {
|
|
54
|
+
const query = `
|
|
55
|
+
query getProduct($id: ID!) {
|
|
56
|
+
product(id: $id) {
|
|
57
|
+
id
|
|
58
|
+
title
|
|
59
|
+
images(first: 10) {
|
|
60
|
+
edges {
|
|
61
|
+
node {
|
|
62
|
+
url
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
options {
|
|
67
|
+
name
|
|
68
|
+
values
|
|
69
|
+
}
|
|
70
|
+
variants(first: 100) {
|
|
71
|
+
edges {
|
|
72
|
+
node {
|
|
73
|
+
id
|
|
74
|
+
title
|
|
75
|
+
availableForSale
|
|
76
|
+
quantityAvailable
|
|
77
|
+
price {
|
|
78
|
+
amount
|
|
79
|
+
currencyCode
|
|
80
|
+
}
|
|
81
|
+
image {
|
|
82
|
+
url
|
|
83
|
+
}
|
|
84
|
+
selectedOptions {
|
|
85
|
+
name
|
|
86
|
+
value
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
const formattedProductId = productId.startsWith('gid://')
|
|
95
|
+
? productId
|
|
96
|
+
: `gid://shopify/Product/${productId}`;
|
|
97
|
+
console.log('[AddToCartPopup] 使用的 Product ID:', formattedProductId);
|
|
98
|
+
const response = yield fetch(`https://${finalShopifyDomain}/api/2024-01/graphql.json`, {
|
|
99
|
+
method: 'POST',
|
|
100
|
+
headers: {
|
|
101
|
+
'Content-Type': 'application/json',
|
|
102
|
+
'X-Shopify-Storefront-Access-Token': finalStorefrontToken
|
|
103
|
+
},
|
|
104
|
+
body: JSON.stringify({
|
|
105
|
+
query,
|
|
106
|
+
variables: { id: formattedProductId }
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
throw new Error(`HTTP ${response.status}`);
|
|
111
|
+
}
|
|
112
|
+
const result = yield response.json();
|
|
113
|
+
if (result.errors) {
|
|
114
|
+
console.error('[AddToCartPopup] GraphQL 错误:', result.errors);
|
|
115
|
+
throw new Error(result.errors[0].message);
|
|
116
|
+
}
|
|
117
|
+
if (!((_m = result.data) === null || _m === void 0 ? void 0 : _m.product)) {
|
|
118
|
+
console.error('[AddToCartPopup] 未找到商品');
|
|
119
|
+
throw new Error('Product not found');
|
|
120
|
+
}
|
|
121
|
+
console.log('[AddToCartPopup] 商品数据加载成功:', result.data.product.title);
|
|
122
|
+
setProductData(result.data.product);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
const errorMessage = err instanceof Error ? err.message : finalTexts.error;
|
|
126
|
+
setError(errorMessage);
|
|
127
|
+
console.error('[AddToCartPopup] 加载失败:', err);
|
|
128
|
+
}
|
|
129
|
+
finally {
|
|
130
|
+
setLoading(false);
|
|
131
|
+
}
|
|
132
|
+
}), [productId, finalShopifyDomain, finalStorefrontToken, finalTexts.error]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (isActive) {
|
|
135
|
+
fetchProductData();
|
|
136
|
+
}
|
|
137
|
+
}, [isActive, fetchProductData]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!productData)
|
|
140
|
+
return;
|
|
141
|
+
const variants = productData.variants.edges.map(edge => edge.node);
|
|
142
|
+
const optionsCount = productData.options.length;
|
|
143
|
+
const selectedCount = Object.keys(selectedOptions).length;
|
|
144
|
+
if (selectedCount === 0 || selectedCount < optionsCount) {
|
|
145
|
+
setSelectedVariant(null);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const matchedVariant = variants.find(variant => {
|
|
149
|
+
return variant.selectedOptions.every(option => selectedOptions[option.name] === option.value);
|
|
150
|
+
});
|
|
151
|
+
setSelectedVariant(matchedVariant || null);
|
|
152
|
+
setQuantity(1);
|
|
153
|
+
}, [selectedOptions, productData]);
|
|
154
|
+
const handleOptionSelect = useCallback((optionName, value) => {
|
|
155
|
+
setSelectedOptions(prev => {
|
|
156
|
+
const newOptions = Object.assign({}, prev);
|
|
157
|
+
if (newOptions[optionName] === value) {
|
|
158
|
+
delete newOptions[optionName];
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
newOptions[optionName] = value;
|
|
162
|
+
}
|
|
163
|
+
return newOptions;
|
|
164
|
+
});
|
|
165
|
+
}, []);
|
|
166
|
+
const handleQuantityChange = useCallback((delta) => {
|
|
167
|
+
setQuantity(prev => {
|
|
168
|
+
var _a;
|
|
169
|
+
const newQuantity = prev + delta;
|
|
170
|
+
const maxQuantity = (_a = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.quantityAvailable) !== null && _a !== void 0 ? _a : 999;
|
|
171
|
+
return Math.max(1, Math.min(newQuantity, maxQuantity));
|
|
172
|
+
});
|
|
173
|
+
}, [selectedVariant]);
|
|
174
|
+
const isOptionValueAvailable = useCallback((optionName, value) => {
|
|
175
|
+
if (!productData)
|
|
176
|
+
return false;
|
|
177
|
+
const variants = productData.variants.edges.map(edge => edge.node);
|
|
178
|
+
const tempOptions = Object.assign(Object.assign({}, selectedOptions), { [optionName]: value });
|
|
179
|
+
return variants.some(variant => {
|
|
180
|
+
const matches = variant.selectedOptions.every(option => !tempOptions[option.name] || tempOptions[option.name] === option.value);
|
|
181
|
+
const hasStock = variant.quantityAvailable === null || variant.quantityAvailable > 0;
|
|
182
|
+
return matches && variant.availableForSale && hasStock;
|
|
183
|
+
});
|
|
184
|
+
}, [productData, selectedOptions]);
|
|
185
|
+
const handleAddToCart = useCallback(() => {
|
|
186
|
+
var _a;
|
|
187
|
+
if (!selectedVariant || quantity === 0)
|
|
188
|
+
return;
|
|
189
|
+
const variantId = selectedVariant.id.split('/').pop();
|
|
190
|
+
const cartUrl = `https://${finalShopifyDomain}/cart/add?id=${variantId}&quantity=${quantity}`;
|
|
191
|
+
console.log('[AddToCartPopup] 加购:', {
|
|
192
|
+
variantId,
|
|
193
|
+
quantity,
|
|
194
|
+
cartUrl
|
|
195
|
+
});
|
|
196
|
+
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
|
197
|
+
eventName: 'AddToCart',
|
|
198
|
+
product: product ? [product] : undefined,
|
|
199
|
+
contentType: 'product',
|
|
200
|
+
data,
|
|
201
|
+
position,
|
|
202
|
+
content_id: (_a = product === null || product === void 0 ? void 0 : product.itemId) !== null && _a !== void 0 ? _a : '',
|
|
203
|
+
value: parseFloat(selectedVariant.price.amount) * quantity,
|
|
204
|
+
currency: selectedVariant.price.currencyCode,
|
|
205
|
+
contents: [{
|
|
206
|
+
id: variantId,
|
|
207
|
+
quantity
|
|
208
|
+
}]
|
|
209
|
+
});
|
|
210
|
+
window.location.href = cartUrl;
|
|
211
|
+
}, [selectedVariant, quantity, finalShopifyDomain, bffFbReport, product, data, position]);
|
|
212
|
+
const totalPrice = useMemo(() => {
|
|
213
|
+
if (!selectedVariant)
|
|
214
|
+
return null;
|
|
215
|
+
const price = parseFloat(selectedVariant.price.amount);
|
|
216
|
+
const total = price * quantity;
|
|
217
|
+
return total.toFixed(2);
|
|
218
|
+
}, [selectedVariant, quantity]);
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
const initTime = () => {
|
|
221
|
+
curTimeRef.current = new Date();
|
|
222
|
+
};
|
|
223
|
+
initTime();
|
|
224
|
+
window.addEventListener('pageshow', initTime);
|
|
225
|
+
return () => {
|
|
226
|
+
window.removeEventListener('pageshow', initTime);
|
|
227
|
+
};
|
|
228
|
+
}, []);
|
|
229
|
+
if (loading) {
|
|
230
|
+
return (React.createElement("div", { className: "add-to-cart-popup-loading", style: style },
|
|
231
|
+
React.createElement("div", null, finalTexts.loading)));
|
|
232
|
+
}
|
|
233
|
+
if (error || !productData) {
|
|
234
|
+
return (React.createElement("div", { className: "add-to-cart-popup-error", style: style },
|
|
235
|
+
React.createElement("div", null,
|
|
236
|
+
finalTexts.error,
|
|
237
|
+
": ",
|
|
238
|
+
error || 'Product not found')));
|
|
239
|
+
}
|
|
240
|
+
const mainImage = ((_h = selectedVariant === null || selectedVariant === void 0 ? void 0 : selectedVariant.image) === null || _h === void 0 ? void 0 : _h.url) || ((_j = productData.images.edges[0]) === null || _j === void 0 ? void 0 : _j.node.url) || ((_k = product === null || product === void 0 ? void 0 : product.homePage) === null || _k === void 0 ? void 0 : _k[0]) || '';
|
|
241
|
+
const hasAllOptionsSelected = productData.options.length === Object.keys(selectedOptions).length;
|
|
242
|
+
const isAddToCartDisabled = !selectedVariant || quantity === 0;
|
|
243
|
+
return (React.createElement("div", Object.assign({ className: "add-to-cart-popup-container", style: style }, props),
|
|
244
|
+
React.createElement("div", { className: "variant-detail-section" },
|
|
245
|
+
React.createElement("div", { className: "variant-image-wrapper" },
|
|
246
|
+
React.createElement("img", { src: mainImage, alt: productData.title, className: "variant-image" })),
|
|
247
|
+
React.createElement("div", { className: "variant-info-wrapper" },
|
|
248
|
+
React.createElement("h2", { className: "product-title-text", style: variantStyles.title, dangerouslySetInnerHTML: {
|
|
249
|
+
__html: setFontForText(productData.title, variantStyles.title)
|
|
250
|
+
} }),
|
|
251
|
+
selectedVariant && (React.createElement(React.Fragment, null,
|
|
252
|
+
React.createElement("div", { className: "selected-options-tags" }, selectedVariant.selectedOptions.map(option => (React.createElement("span", { key: option.name, className: "option-tag", style: variantStyles.selectedOption },
|
|
253
|
+
option.name,
|
|
254
|
+
": ",
|
|
255
|
+
option.value)))),
|
|
256
|
+
React.createElement("div", { className: "price-display" },
|
|
257
|
+
React.createElement("span", { className: "price-value", style: variantStyles.price, dangerouslySetInnerHTML: {
|
|
258
|
+
__html: setFontForText(`${selectedVariant.price.currencyCode} $${totalPrice}`, variantStyles.price)
|
|
259
|
+
} })),
|
|
260
|
+
React.createElement("div", { className: "quantity-selector-wrapper", style: quantityStyle },
|
|
261
|
+
React.createElement("button", { className: "quantity-btn quantity-decrease", onClick: () => handleQuantityChange(-1), disabled: quantity <= 1, "aria-label": "Decrease quantity" }, "-"),
|
|
262
|
+
React.createElement("input", { type: "number", value: quantity, readOnly: true, className: "quantity-input-field", "aria-label": "Quantity" }),
|
|
263
|
+
React.createElement("button", { className: "quantity-btn quantity-increase", onClick: () => handleQuantityChange(1), disabled: quantity >= ((_l = selectedVariant.quantityAvailable) !== null && _l !== void 0 ? _l : 999), "aria-label": "Increase quantity" }, "+")))),
|
|
264
|
+
!hasAllOptionsSelected && (React.createElement("div", { className: "no-selection-hint", style: variantStyles.option }, finalTexts.selectOptions)))),
|
|
265
|
+
React.createElement("div", { className: "variant-options-section" }, productData.options.map(option => (React.createElement("div", { key: option.name, className: "option-group-wrapper" },
|
|
266
|
+
React.createElement("h3", { className: "option-group-name", style: variantStyles.option, dangerouslySetInnerHTML: {
|
|
267
|
+
__html: setFontForText(option.name, variantStyles.option)
|
|
268
|
+
} }),
|
|
269
|
+
React.createElement("div", { className: "option-values-grid" }, option.values.map(value => {
|
|
270
|
+
const isSelected = selectedOptions[option.name] === value;
|
|
271
|
+
const isAvailable = isOptionValueAvailable(option.name, value);
|
|
272
|
+
return (React.createElement("button", { key: value, className: `option-value-button ${isSelected ? 'selected' : ''} ${!isAvailable ? 'disabled' : ''}`, onClick: () => isAvailable && handleOptionSelect(option.name, value), disabled: !isAvailable, "aria-label": `${option.name}: ${value}`, "aria-pressed": isSelected }, value));
|
|
273
|
+
})))))),
|
|
274
|
+
React.createElement("button", { className: `add-to-cart-button ${isAddToCartDisabled ? 'disabled' : ''}`, style: buttonStyle, onClick: handleAddToCart, disabled: isAddToCartDisabled, "aria-label": finalTexts.addToCart },
|
|
275
|
+
React.createElement("span", { dangerouslySetInnerHTML: {
|
|
276
|
+
__html: setFontForText(finalTexts.addToCart, buttonStyle)
|
|
277
|
+
} }))));
|
|
278
|
+
};
|
|
279
|
+
export default AddToCartPopup;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export default () => {
|
|
3
|
+
return (React.createElement("div", { style: { padding: '20px', color: '#666' } },
|
|
4
|
+
React.createElement("p", null, "\u52A0\u8D2D\u5546\u54C1\u5F39\u7A97\u4EA4\u4E92\u8BF4\u660E\uFF1A"),
|
|
5
|
+
React.createElement("ul", { style: { paddingLeft: '20px', lineHeight: '1.8' } },
|
|
6
|
+
React.createElement("li", null, "\u70B9\u51FB\u5546\u54C1\u8BE6\u60C5\u5F39\u7A97\u7684\"Shop Now\"\u6309\u94AE\u540E\u81EA\u52A8\u5C55\u793A"),
|
|
7
|
+
React.createElement("li", null, "\u901A\u8FC7Shopify Storefront API\u83B7\u53D6\u5546\u54C1\u89C4\u683C\u548C\u5E93\u5B58\u4FE1\u606F"),
|
|
8
|
+
React.createElement("li", null, "\u7528\u6237\u9009\u62E9\u89C4\u683C\u540E\u5B9E\u65F6\u663E\u793A\u5BF9\u5E94SKU\u7684\u4EF7\u683C\u548C\u5E93\u5B58"),
|
|
9
|
+
React.createElement("li", null, "\u70B9\u51FB\"Add to Cart\"\u6309\u94AE\u540E\u8DF3\u8F6C\u81F3Shopify\u8D2D\u7269\u8F66\u9875\u9762"),
|
|
10
|
+
React.createElement("li", null, "\u65E0\u5E93\u5B58\u6216\u4E0D\u53EF\u552E\u5356\u7684\u89C4\u683C\u81EA\u52A8\u7F6E\u7070\u4E0D\u53EF\u9009"))));
|
|
11
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import settingRender from './settingRender';
|
|
2
|
+
import interactionRender from './interactionRender';
|
|
3
|
+
import AddToCartPopupComponent from '.';
|
|
4
|
+
import { createMaterial } from '../../../../core/create';
|
|
5
|
+
const AddToCartPopup = createMaterial(AddToCartPopupComponent, {
|
|
6
|
+
displayName: '加购商品',
|
|
7
|
+
icon: '',
|
|
8
|
+
category: 'popup',
|
|
9
|
+
type: 'AddToCartPopup',
|
|
10
|
+
related: {
|
|
11
|
+
settingRender,
|
|
12
|
+
interactionRender
|
|
13
|
+
},
|
|
14
|
+
defaulSetting: {
|
|
15
|
+
props: {
|
|
16
|
+
shopifyDomain: '',
|
|
17
|
+
storefrontAccessToken: '',
|
|
18
|
+
variantStyles: {
|
|
19
|
+
title: {
|
|
20
|
+
color: '#000',
|
|
21
|
+
fontSize: 20,
|
|
22
|
+
fontWeight: 600,
|
|
23
|
+
marginBottom: 12
|
|
24
|
+
},
|
|
25
|
+
price: {
|
|
26
|
+
color: '#000',
|
|
27
|
+
fontSize: 24,
|
|
28
|
+
fontWeight: 700,
|
|
29
|
+
marginBottom: 16
|
|
30
|
+
},
|
|
31
|
+
option: {
|
|
32
|
+
color: '#111',
|
|
33
|
+
fontSize: 16,
|
|
34
|
+
fontWeight: 600,
|
|
35
|
+
marginBottom: 12
|
|
36
|
+
},
|
|
37
|
+
selectedOption: {
|
|
38
|
+
fontSize: 14,
|
|
39
|
+
color: '#374151'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
buttonStyle: {
|
|
43
|
+
backgroundColor: '#000',
|
|
44
|
+
color: '#fff',
|
|
45
|
+
fontSize: 16,
|
|
46
|
+
height: 52,
|
|
47
|
+
fontWeight: 600,
|
|
48
|
+
textAlign: 'center',
|
|
49
|
+
textTransform: 'uppercase'
|
|
50
|
+
},
|
|
51
|
+
quantityStyle: {
|
|
52
|
+
gap: 12
|
|
53
|
+
},
|
|
54
|
+
texts: {
|
|
55
|
+
addToCart: 'Add to Cart',
|
|
56
|
+
selectOptions: 'Please select options',
|
|
57
|
+
loading: 'Loading...',
|
|
58
|
+
error: 'Failed to load product',
|
|
59
|
+
color: 'Color',
|
|
60
|
+
size: 'Size',
|
|
61
|
+
material: 'Material',
|
|
62
|
+
style: 'Style'
|
|
63
|
+
},
|
|
64
|
+
popupBg: {
|
|
65
|
+
horizontalMargin: 0,
|
|
66
|
+
bottomMargin: 0
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
style: {}
|
|
70
|
+
},
|
|
71
|
+
w: 100,
|
|
72
|
+
h: 40,
|
|
73
|
+
sort: 7
|
|
74
|
+
});
|
|
75
|
+
export { AddToCartPopup };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
declare const _default: ({
|
|
2
|
+
title: string;
|
|
3
|
+
child: {
|
|
4
|
+
type: string;
|
|
5
|
+
label: string;
|
|
6
|
+
name: string[];
|
|
7
|
+
placeholder: string;
|
|
8
|
+
}[];
|
|
9
|
+
} | {
|
|
10
|
+
title: string;
|
|
11
|
+
child: {
|
|
12
|
+
name: string[];
|
|
13
|
+
type: string;
|
|
14
|
+
child: ({
|
|
15
|
+
label: string;
|
|
16
|
+
type: string;
|
|
17
|
+
options: {
|
|
18
|
+
label: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
21
|
+
name: string[];
|
|
22
|
+
initialValue: string;
|
|
23
|
+
child?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
type: string;
|
|
26
|
+
child: {
|
|
27
|
+
label: string;
|
|
28
|
+
type: string;
|
|
29
|
+
addonAfter: string;
|
|
30
|
+
name: string[];
|
|
31
|
+
}[];
|
|
32
|
+
label?: undefined;
|
|
33
|
+
options?: undefined;
|
|
34
|
+
name?: undefined;
|
|
35
|
+
initialValue?: undefined;
|
|
36
|
+
} | {
|
|
37
|
+
type: string;
|
|
38
|
+
label: string;
|
|
39
|
+
child: {
|
|
40
|
+
type: string;
|
|
41
|
+
name: string[];
|
|
42
|
+
bottomText: string;
|
|
43
|
+
}[];
|
|
44
|
+
options?: undefined;
|
|
45
|
+
name?: undefined;
|
|
46
|
+
initialValue?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
type: string;
|
|
49
|
+
label: string;
|
|
50
|
+
child: ({
|
|
51
|
+
type: string;
|
|
52
|
+
name: string[];
|
|
53
|
+
addonAfter?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
type: string;
|
|
56
|
+
addonAfter: string;
|
|
57
|
+
name: string[];
|
|
58
|
+
})[];
|
|
59
|
+
options?: undefined;
|
|
60
|
+
name?: undefined;
|
|
61
|
+
initialValue?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
label: string;
|
|
64
|
+
type: string;
|
|
65
|
+
options?: undefined;
|
|
66
|
+
name?: undefined;
|
|
67
|
+
initialValue?: undefined;
|
|
68
|
+
child?: undefined;
|
|
69
|
+
})[];
|
|
70
|
+
}[];
|
|
71
|
+
} | {
|
|
72
|
+
title: string;
|
|
73
|
+
child: ({
|
|
74
|
+
label: string;
|
|
75
|
+
type: string;
|
|
76
|
+
name: string[];
|
|
77
|
+
options: {
|
|
78
|
+
label: string;
|
|
79
|
+
value: string;
|
|
80
|
+
}[];
|
|
81
|
+
initialValue?: undefined;
|
|
82
|
+
child?: undefined;
|
|
83
|
+
} | {
|
|
84
|
+
type: string;
|
|
85
|
+
label: string;
|
|
86
|
+
name: string[];
|
|
87
|
+
initialValue: string;
|
|
88
|
+
options?: undefined;
|
|
89
|
+
child?: undefined;
|
|
90
|
+
} | {
|
|
91
|
+
type: string;
|
|
92
|
+
label: string;
|
|
93
|
+
child: ({
|
|
94
|
+
type: string;
|
|
95
|
+
name: string[];
|
|
96
|
+
max: number;
|
|
97
|
+
addonAfter?: undefined;
|
|
98
|
+
} | {
|
|
99
|
+
type: string;
|
|
100
|
+
name: string[];
|
|
101
|
+
addonAfter: string;
|
|
102
|
+
max: number;
|
|
103
|
+
})[];
|
|
104
|
+
name?: undefined;
|
|
105
|
+
options?: undefined;
|
|
106
|
+
initialValue?: undefined;
|
|
107
|
+
} | {
|
|
108
|
+
type: string;
|
|
109
|
+
name: string[];
|
|
110
|
+
label?: undefined;
|
|
111
|
+
options?: undefined;
|
|
112
|
+
initialValue?: undefined;
|
|
113
|
+
child?: undefined;
|
|
114
|
+
} | {
|
|
115
|
+
type: string;
|
|
116
|
+
label: string;
|
|
117
|
+
child: {
|
|
118
|
+
type: string;
|
|
119
|
+
name: string[];
|
|
120
|
+
bottomText: string;
|
|
121
|
+
}[];
|
|
122
|
+
name?: undefined;
|
|
123
|
+
options?: undefined;
|
|
124
|
+
initialValue?: undefined;
|
|
125
|
+
} | {
|
|
126
|
+
type: string;
|
|
127
|
+
label: string;
|
|
128
|
+
child: ({
|
|
129
|
+
type: string;
|
|
130
|
+
name: string[];
|
|
131
|
+
initialValue: string;
|
|
132
|
+
addonAfter?: undefined;
|
|
133
|
+
} | {
|
|
134
|
+
type: string;
|
|
135
|
+
name: string[];
|
|
136
|
+
addonAfter: string;
|
|
137
|
+
initialValue?: undefined;
|
|
138
|
+
})[];
|
|
139
|
+
name?: undefined;
|
|
140
|
+
options?: undefined;
|
|
141
|
+
initialValue?: undefined;
|
|
142
|
+
} | {
|
|
143
|
+
label: string;
|
|
144
|
+
type: string;
|
|
145
|
+
name: string[];
|
|
146
|
+
options?: undefined;
|
|
147
|
+
initialValue?: undefined;
|
|
148
|
+
child?: undefined;
|
|
149
|
+
})[];
|
|
150
|
+
} | {
|
|
151
|
+
title: string;
|
|
152
|
+
child: {
|
|
153
|
+
type: string;
|
|
154
|
+
label: string;
|
|
155
|
+
name: string[];
|
|
156
|
+
addonAfter: string;
|
|
157
|
+
initialValue: number;
|
|
158
|
+
}[];
|
|
159
|
+
})[];
|
|
160
|
+
export default _default;
|