@gem-sdk/core 1.41.2-staging.0 → 1.42.0-dev.60
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/ComponentToolbarPreview.js +54 -6
- package/dist/cjs/components/ComponentWrapperPreview.js +44 -1
- package/dist/cjs/components/Render.liquid.js +2 -0
- package/dist/cjs/components/RenderCustomCode.js +2 -0
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +205 -0
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +85 -0
- package/dist/cjs/components/ai-generator/components/PickProduct.js +218 -0
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +77 -0
- package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +47 -0
- package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +110 -0
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +37 -0
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +63 -0
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +67 -0
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +19 -0
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +37 -0
- package/dist/cjs/components/ai-generator/icons/SearchIcon.js +21 -0
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +21 -0
- package/dist/cjs/components/constant.js +19 -2
- package/dist/cjs/components/resize/Spacing.js +2 -0
- package/dist/cjs/components/theme-section/CreateThemeSection.js +2 -0
- package/dist/cjs/contexts/ArticleContext.js +39 -0
- package/dist/cjs/contexts/ArticleListContext.js +32 -0
- package/dist/cjs/contexts/BuilderPreviewContext.js +11 -6
- package/dist/cjs/contexts/SectionContext.js +1 -0
- package/dist/cjs/graphql/fragments/product-little.generated.js +9 -0
- package/dist/cjs/graphql/fragments/product.generated.js +9 -0
- package/dist/cjs/graphql/queries/products.generated.js +9 -0
- package/dist/cjs/helpers/align.js +19 -0
- package/dist/cjs/helpers/carousel.js +7 -10
- package/dist/cjs/helpers/colors.js +1 -1
- package/dist/cjs/helpers/queries/get-products.js +48 -19
- package/dist/cjs/helpers/typography.js +4 -4
- package/dist/cjs/hooks/articles/useArticlesQuery.js +152 -0
- package/dist/cjs/hooks/shop/use-products-query.js +39 -0
- package/dist/cjs/hooks/useAnimations.js +2 -0
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +2 -0
- package/dist/cjs/hooks/useProduct.js +2 -0
- package/dist/cjs/index.js +12 -0
- package/dist/esm/components/ComponentToolbarPreview.js +54 -6
- package/dist/esm/components/ComponentWrapperPreview.js +44 -1
- package/dist/esm/components/Render.liquid.js +2 -0
- package/dist/esm/components/RenderCustomCode.js +2 -0
- package/dist/esm/components/ai-generator/AIContentGenerator.js +203 -0
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +83 -0
- package/dist/esm/components/ai-generator/components/PickProduct.js +216 -0
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +75 -0
- package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +45 -0
- package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +108 -0
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +35 -0
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +61 -0
- package/dist/esm/components/ai-generator/icons/AIIcon.js +65 -0
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +17 -0
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +34 -0
- package/dist/esm/components/ai-generator/icons/SearchIcon.js +19 -0
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +19 -0
- package/dist/esm/components/constant.js +19 -3
- package/dist/esm/components/resize/Spacing.js +2 -0
- package/dist/esm/components/theme-section/CreateThemeSection.js +2 -0
- package/dist/esm/contexts/ArticleContext.js +36 -0
- package/dist/esm/contexts/ArticleListContext.js +28 -0
- package/dist/esm/contexts/BuilderPreviewContext.js +11 -6
- package/dist/esm/contexts/SectionContext.js +1 -0
- package/dist/esm/graphql/fragments/product-little.generated.js +9 -0
- package/dist/esm/graphql/fragments/product.generated.js +9 -0
- package/dist/esm/graphql/queries/products.generated.js +9 -0
- package/dist/esm/helpers/align.js +17 -0
- package/dist/esm/helpers/carousel.js +7 -10
- package/dist/esm/helpers/colors.js +1 -1
- package/dist/esm/helpers/queries/get-products.js +47 -20
- package/dist/esm/helpers/typography.js +4 -4
- package/dist/esm/hooks/articles/useArticlesQuery.js +149 -0
- package/dist/esm/hooks/shop/use-products-query.js +39 -2
- package/dist/esm/hooks/useAnimations.js +2 -0
- package/dist/esm/hooks/useInitialSwatchesOptions.js +2 -0
- package/dist/esm/hooks/useProduct.js +2 -0
- package/dist/esm/index.js +5 -1
- package/dist/types/index.d.ts +176 -21
- package/package.json +5 -3
|
@@ -10,6 +10,7 @@ var ShopContext = require('../contexts/ShopContext.js');
|
|
|
10
10
|
require('@gem-sdk/adapter-shopify');
|
|
11
11
|
require('swr');
|
|
12
12
|
require('swr/mutation');
|
|
13
|
+
require('swr/infinite');
|
|
13
14
|
require('vanilla-lazyload');
|
|
14
15
|
require('../hooks/useCartUI.js');
|
|
15
16
|
var CreateThemeSection = require('./theme-section/CreateThemeSection.js');
|
|
@@ -17,6 +18,9 @@ var Tooltip = require('./toolbar/Tooltip.js');
|
|
|
17
18
|
var ThemeSectionStatus = require('./theme-section/ThemeSectionStatus.js');
|
|
18
19
|
var Resize = require('./resize/Resize.js');
|
|
19
20
|
var useToolbarPostPurchase = require('../hooks/useToolbarPostPurchase.js');
|
|
21
|
+
var constant = require('./constant.js');
|
|
22
|
+
var AIContentGenerator = require('./ai-generator/AIContentGenerator.js');
|
|
23
|
+
var AIGenContentLoading = require('./ai-generator/AIGenContentLoading.js');
|
|
20
24
|
require('../helpers/convert.js');
|
|
21
25
|
|
|
22
26
|
const SECTION_LIMIT = 25;
|
|
@@ -30,6 +34,7 @@ const isSection = (el)=>{
|
|
|
30
34
|
};
|
|
31
35
|
const ComponentToolbarPreview = (props)=>{
|
|
32
36
|
const isThemeSection = props.isThemeSection;
|
|
37
|
+
const isShopifySection = props.isShopifySection;
|
|
33
38
|
const editingPageType = ShopContext.useShopStore((s)=>s.pageType);
|
|
34
39
|
const getParents = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getParents);
|
|
35
40
|
const root = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getItem('ROOT'));
|
|
@@ -175,7 +180,8 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
175
180
|
bubbles: true,
|
|
176
181
|
detail: {
|
|
177
182
|
componentUid: props.uid,
|
|
178
|
-
isThemeSection
|
|
183
|
+
isThemeSection,
|
|
184
|
+
isShopifySection
|
|
179
185
|
}
|
|
180
186
|
});
|
|
181
187
|
window.dispatchEvent(event);
|
|
@@ -191,7 +197,8 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
191
197
|
bubbles: true,
|
|
192
198
|
detail: {
|
|
193
199
|
componentUid: props.uid,
|
|
194
|
-
isThemeSection
|
|
200
|
+
isThemeSection,
|
|
201
|
+
isShopifySection
|
|
195
202
|
}
|
|
196
203
|
});
|
|
197
204
|
window.dispatchEvent(event);
|
|
@@ -240,6 +247,9 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
240
247
|
return false;
|
|
241
248
|
};
|
|
242
249
|
const getSectionName = ()=>{
|
|
250
|
+
if (isShopifySection) {
|
|
251
|
+
return `Shopify section: ${props.name}`;
|
|
252
|
+
}
|
|
243
253
|
const checkRenamedSection = props.name && props.name === `Section ${props.uid}`;
|
|
244
254
|
if (getSectionNumber() >= SECTION_LIMIT - 5) {
|
|
245
255
|
return `${checkRenamedSection ? 'Section' : props?.name} ${getIndexSection() + 1}/${SECTION_LIMIT}`;
|
|
@@ -256,6 +266,7 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
256
266
|
"data-toolbar": true,
|
|
257
267
|
"data-toolbar-section": props.tag == 'Section',
|
|
258
268
|
"data-toolbar-theme-section": props.tag == 'Section' && !!isThemeSection || isThemeSectionEditor,
|
|
269
|
+
"data-toolbar-shopify-section": props.tag == 'Section' && !!isShopifySection,
|
|
259
270
|
"data-toolbar-limit": getIndexSection() >= SECTION_LIMIT,
|
|
260
271
|
children: [
|
|
261
272
|
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
@@ -298,9 +309,39 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
298
309
|
]
|
|
299
310
|
})
|
|
300
311
|
}),
|
|
301
|
-
props.tag == 'Section' ? /*#__PURE__*/ jsxRuntime.
|
|
312
|
+
props.tag == 'Section' ? /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
302
313
|
"data-toolbar-name": true,
|
|
303
|
-
children:
|
|
314
|
+
children: [
|
|
315
|
+
getSectionName(),
|
|
316
|
+
props.isShopifySection && !props.isShopifyVisibility && /*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
317
|
+
"data-toolbar-visibility": true,
|
|
318
|
+
width: "20",
|
|
319
|
+
height: "20",
|
|
320
|
+
viewBox: "0 0 20 20",
|
|
321
|
+
fill: "none",
|
|
322
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
323
|
+
children: [
|
|
324
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
325
|
+
fillRule: "evenodd",
|
|
326
|
+
clipRule: "evenodd",
|
|
327
|
+
d: "M13.1252 9.99773C13.1243 8.27226 11.7248 6.87423 9.99935 6.87506C8.27386 6.87561 6.87518 8.27455 6.87518 10.0001C6.87518 11.7259 8.27429 13.1251 10.0002 13.1251C11.7257 13.1251 13.125 11.727 13.1252 10.0011V9.99773ZM9.99985 8.12506C11.035 8.12451 11.8746 8.96322 11.8752 9.99839V10.0004C11.8752 11.0357 11.0359 11.8751 10.0002 11.8751C8.96465 11.8751 8.12518 11.0356 8.12518 10.0001C8.12518 8.96472 8.96451 8.12533 9.99985 8.12506Z",
|
|
328
|
+
fill: "#F9F9F9"
|
|
329
|
+
}),
|
|
330
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
331
|
+
fillRule: "evenodd",
|
|
332
|
+
clipRule: "evenodd",
|
|
333
|
+
d: "M9.99885 4.37593C5.66421 4.37604 2.80603 7.64523 1.79548 9.00983C1.35636 9.60279 1.35918 10.4 1.80012 10.9902C2.81706 12.3514 5.69374 15.6241 9.99886 15.6241C14.3806 15.6241 17.2194 12.3452 18.2168 10.9808C18.6473 10.392 18.6442 9.60472 18.211 9.01902C17.2056 7.65938 14.3429 4.37583 9.99885 4.37593ZM2.80002 9.75374C3.77049 8.44326 6.30207 5.62602 9.99888 5.62593C13.7041 5.62585 16.24 8.45598 17.206 9.76225C17.3146 9.9091 17.3149 10.0965 17.2077 10.2431C16.254 11.5477 13.7416 14.3741 9.99886 14.3741C6.33149 14.3741 3.78173 11.5541 2.80152 10.242C2.69021 10.0931 2.69001 9.90229 2.80002 9.75374Z",
|
|
334
|
+
fill: "#F9F9F9"
|
|
335
|
+
}),
|
|
336
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
337
|
+
fillRule: "evenodd",
|
|
338
|
+
clipRule: "evenodd",
|
|
339
|
+
d: "M18.0763 3.26988C18.3415 3.58809 18.2985 4.06101 17.9803 4.32619L2.98032 16.8262C2.66211 17.0914 2.18919 17.0484 1.92402 16.7302C1.65884 16.412 1.70184 15.939 2.02004 15.6739L17.02 3.17385C17.3383 2.90868 17.8112 2.95167 18.0763 3.26988Z",
|
|
340
|
+
fill: "#F9F9F9"
|
|
341
|
+
})
|
|
342
|
+
]
|
|
343
|
+
})
|
|
344
|
+
]
|
|
304
345
|
}) : /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
305
346
|
"data-toolbar-name": true,
|
|
306
347
|
children: toolbarName()
|
|
@@ -380,7 +421,10 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
380
421
|
]
|
|
381
422
|
}, parent.uid);
|
|
382
423
|
}),
|
|
383
|
-
props.tag === 'Section' && !props.isThemeSection && isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
|
|
424
|
+
props.tag === 'Section' && !props.isThemeSection && isEnableCreateThemeSection() && !props.isShopifySection && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
|
|
425
|
+
...props
|
|
426
|
+
}),
|
|
427
|
+
!props.isShopifySection && constant.ableGenerateContentElements.includes(props.tag) && /*#__PURE__*/ jsxRuntime.jsx(AIContentGenerator.AIContentGenerator, {
|
|
384
428
|
...props
|
|
385
429
|
}),
|
|
386
430
|
props.tag == 'Sticky' && /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
@@ -454,6 +498,7 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
454
498
|
"data-outline": true,
|
|
455
499
|
"data-outline-section": props.tag == 'Section',
|
|
456
500
|
"data-outline-theme-section": props.tag == 'Section' && !!isThemeSection || isThemeSectionEditor,
|
|
501
|
+
"data-outline-shopify-section": props.tag == 'Section' && !!isShopifySection,
|
|
457
502
|
"data-outline-limit": getIndexSection() >= SECTION_LIMIT
|
|
458
503
|
}, 'outline-' + props.uid),
|
|
459
504
|
props.tag == 'Section' && !isThemeSectionEditor && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
@@ -500,12 +545,15 @@ const ComponentToolbarPreview = (props)=>{
|
|
|
500
545
|
})
|
|
501
546
|
]
|
|
502
547
|
}),
|
|
548
|
+
constant.ableGenerateContentElements.includes(props.tag) && /*#__PURE__*/ jsxRuntime.jsx(AIGenContentLoading.AIGenContentLoading, {
|
|
549
|
+
...props
|
|
550
|
+
}),
|
|
503
551
|
/*#__PURE__*/ jsxRuntime.jsx(Resize.default, {
|
|
504
552
|
...props
|
|
505
553
|
})
|
|
506
554
|
]
|
|
507
555
|
});
|
|
508
556
|
};
|
|
509
|
-
var ComponentToolbarPreview$1 = /*#__PURE__*/ react.memo(ComponentToolbarPreview);
|
|
557
|
+
var ComponentToolbarPreview$1 = /*#__PURE__*/ react.memo(ComponentToolbarPreview); /* gem-lint/disallow-import-from-package-path */
|
|
510
558
|
|
|
511
559
|
exports.default = ComponentToolbarPreview$1;
|
|
@@ -14,8 +14,10 @@ require('swr');
|
|
|
14
14
|
require('@gem-sdk/adapter-shopify');
|
|
15
15
|
require('swr/mutation');
|
|
16
16
|
var shop = require('../hooks/shop.js');
|
|
17
|
+
require('swr/infinite');
|
|
17
18
|
require('vanilla-lazyload');
|
|
18
19
|
require('../hooks/useCartUI.js');
|
|
20
|
+
var cls = require('../helpers/cls.js');
|
|
19
21
|
require('../helpers/convert.js');
|
|
20
22
|
|
|
21
23
|
const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
@@ -41,6 +43,10 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
41
43
|
if (props.tag === 'Section' && props.isThemeSection) {
|
|
42
44
|
customProps['data-theme-section'] = true;
|
|
43
45
|
}
|
|
46
|
+
if (props.tag === 'Section' && props.isShopifySection) {
|
|
47
|
+
customProps['data-shopify-section'] = true;
|
|
48
|
+
customProps['data-toolbar-wrap'] = true;
|
|
49
|
+
}
|
|
44
50
|
// Build editor configs
|
|
45
51
|
if (props.editorConfigs) {
|
|
46
52
|
const editorConfigs = props.editorConfigs;
|
|
@@ -95,6 +101,40 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
95
101
|
'data-component-label': props.label,
|
|
96
102
|
'data-not-droppable': isNotDroppable(props.tag)
|
|
97
103
|
};
|
|
104
|
+
const ShopifySection = ({ name, visibility })=>{
|
|
105
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
106
|
+
className: cls.cls('gp-flex gp-items-center gp-justify-center gp-gap-[8px] gp-bg-[#F4F4F4] gp-p-[16px] gp-border gp-border-[#D6D6D6]', {
|
|
107
|
+
'gp-opacity-60': !visibility
|
|
108
|
+
}),
|
|
109
|
+
children: [
|
|
110
|
+
/*#__PURE__*/ jsxRuntime.jsxs("svg", {
|
|
111
|
+
width: "24",
|
|
112
|
+
height: "24",
|
|
113
|
+
viewBox: "0 0 24 24",
|
|
114
|
+
fill: "none",
|
|
115
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
118
|
+
d: "M19.1475 5.16194C19.1416 5.1148 19.1197 5.0713 19.0857 5.03911C19.0516 5.00692 19.0076 4.9881 18.9614 4.98597C18.8835 4.98597 17.3469 4.95397 17.3469 4.95397C17.3469 4.95397 16.0588 3.67419 15.9342 3.5311C15.8104 3.40312 15.5619 3.43512 15.4684 3.46711L14.8166 3.67508C14.7361 3.40491 14.6323 3.14259 14.5067 2.89121C14.0566 1.99536 13.3727 1.51544 12.5659 1.51544C12.5044 1.51544 12.4577 1.51544 12.3954 1.53144C12.3642 1.49945 12.3486 1.46745 12.3175 1.45145C11.9608 1.06752 11.5107 0.875552 10.967 0.891549C9.92824 0.923543 8.88772 1.70741 8.03419 3.08318C7.44467 4.05901 6.99453 5.27392 6.8543 6.21776C5.65969 6.6017 4.82087 6.87365 4.79057 6.87365C4.18461 7.06562 4.16903 7.08161 4.09199 7.67351C4.06082 8.12144 2.47754 20.7415 2.47754 20.7415L15.7636 23.1091L21.522 21.6374C21.5064 21.6374 19.1631 5.27392 19.1475 5.16194ZM14.1492 3.89904C13.8062 4.00572 13.4648 4.11772 13.1251 4.23498C13.1251 3.69108 13.0472 2.92321 12.8143 2.28331C13.6064 2.41129 13.9942 3.33914 14.1492 3.89904ZM12.4265 4.44206C11.7279 4.66602 10.9679 4.90598 10.207 5.14594C10.4243 4.29808 10.8277 3.46623 11.3245 2.90632C11.533 2.66965 11.7863 2.47913 12.069 2.34641C12.3806 2.9712 12.4421 3.85105 12.4265 4.44206ZM10.9982 1.61143C11.2466 1.61143 11.4483 1.65942 11.6197 1.7874C11.3127 1.95192 11.0387 2.17444 10.8121 2.44329C10.1455 3.17916 9.63305 4.31408 9.43135 5.4179C8.79423 5.62586 8.17356 5.81783 7.61521 5.9938C7.98744 4.25009 9.39933 1.65942 10.9982 1.61143Z",
|
|
119
|
+
fill: "#95BF47"
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
122
|
+
d: "M18.9647 4.94709C18.8851 4.94709 17.3155 4.91503 17.3155 4.91503C17.3155 4.91503 15.9981 3.63242 15.8716 3.48812C15.8261 3.43951 15.7635 3.41074 15.6973 3.40796V23.1094L21.5828 21.6344L19.1709 5.12345C19.1399 5.01122 19.0444 4.94709 18.9647 4.94709Z",
|
|
123
|
+
fill: "#5E8E3E"
|
|
124
|
+
}),
|
|
125
|
+
/*#__PURE__*/ jsxRuntime.jsx("path", {
|
|
126
|
+
d: "M13.0575 8.51577L12.3029 10.8908C12.3029 10.8908 11.4602 10.5663 10.4599 10.6253C8.98595 10.6991 8.98595 11.4809 8.98595 11.6727C9.07404 12.7348 12.39 12.9709 12.5828 15.4631C12.7238 17.4251 11.3545 18.7675 9.35396 18.8708C6.96778 18.9733 5.65137 17.7939 5.65137 17.7939L6.16032 15.9794C6.16032 15.9794 7.49435 16.8203 8.5465 16.7613C9.23162 16.7318 9.4949 16.245 9.45967 15.9204C9.35396 14.5337 6.65165 14.6223 6.47645 12.3365C6.33551 10.4188 7.82712 8.48626 11.1265 8.30924C12.4076 8.23548 13.0575 8.51577 13.0575 8.51577Z",
|
|
127
|
+
fill: "white"
|
|
128
|
+
})
|
|
129
|
+
]
|
|
130
|
+
}),
|
|
131
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
132
|
+
className: "gp-text-[#212121] gp-text-[14px] gp-leading-[24px] gp-font-medium",
|
|
133
|
+
children: name
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
};
|
|
98
138
|
if (constant.disableWrap.includes(props.tag) && /*#__PURE__*/ react.isValidElement(children)) {
|
|
99
139
|
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
100
140
|
children: [
|
|
@@ -109,7 +149,10 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
|
|
|
109
149
|
builderAttrs,
|
|
110
150
|
advanced,
|
|
111
151
|
children: [
|
|
112
|
-
|
|
152
|
+
props.isShopifySection ? /*#__PURE__*/ jsxRuntime.jsx(ShopifySection, {
|
|
153
|
+
name: props.name ?? '',
|
|
154
|
+
visibility: !!props.isShopifyVisibility
|
|
155
|
+
}) : children.props['children'],
|
|
113
156
|
/*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.default, {
|
|
114
157
|
...props
|
|
115
158
|
})
|
|
@@ -9,11 +9,13 @@ require('zustand');
|
|
|
9
9
|
require('swr');
|
|
10
10
|
require('@gem-sdk/adapter-shopify');
|
|
11
11
|
require('swr/mutation');
|
|
12
|
+
require('swr/infinite');
|
|
12
13
|
require('vanilla-lazyload');
|
|
13
14
|
require('../hooks/useCartUI.js');
|
|
14
15
|
require('react-transition-group');
|
|
15
16
|
require('@gem-sdk/core');
|
|
16
17
|
var constant = require('./constant.js');
|
|
18
|
+
require('classnames');
|
|
17
19
|
var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
|
|
18
20
|
var convert = require('../helpers/convert.js');
|
|
19
21
|
var render = require('../helpers/render.js');
|
|
@@ -11,10 +11,12 @@ require('swr');
|
|
|
11
11
|
require('@gem-sdk/adapter-shopify');
|
|
12
12
|
require('swr/mutation');
|
|
13
13
|
var shop = require('../hooks/shop.js');
|
|
14
|
+
require('swr/infinite');
|
|
14
15
|
require('vanilla-lazyload');
|
|
15
16
|
require('../hooks/useCartUI.js');
|
|
16
17
|
require('react-transition-group');
|
|
17
18
|
require('@gem-sdk/core');
|
|
19
|
+
require('classnames');
|
|
18
20
|
require('../helpers/convert.js');
|
|
19
21
|
|
|
20
22
|
const RenderCustomCode = ({ uid, advanced })=>{
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var AIIcon = require('./icons/AIIcon.js');
|
|
6
|
+
var CloseIcon = require('./icons/CloseIcon.js');
|
|
7
|
+
var ShowMoreIcon = require('./icons/ShowMoreIcon.js');
|
|
8
|
+
var PickProduct = require('./components/PickProduct.js');
|
|
9
|
+
var ToneAndVoice = require('./components/ToneAndVoice.js');
|
|
10
|
+
var classNames = require('classnames');
|
|
11
|
+
var useListenEventGenerate = require('./hooks/useListenEventGenerate.js');
|
|
12
|
+
var useGettingGenerateRequest = require('./hooks/useGettingGenerateRequest.js');
|
|
13
|
+
var useFlipPopup = require('./hooks/useFlipPopup.js');
|
|
14
|
+
var useCheckingProductInside = require('./hooks/useCheckingProductInside.js');
|
|
15
|
+
|
|
16
|
+
const AIContentGenerator = ({ ...props })=>{
|
|
17
|
+
const [isShowPopup, setIsShowPopup] = react.useState(false);
|
|
18
|
+
const [isShowMore, setIsShowMore] = react.useState(false);
|
|
19
|
+
const genTool = react.useRef(null);
|
|
20
|
+
const genPopup = react.useRef(null);
|
|
21
|
+
const genPopupHeader = react.useRef(null);
|
|
22
|
+
const genButtonWrapper = react.useRef(null);
|
|
23
|
+
const { popupPositionX, popupPositionY, isValidating: isValidatingFlipPopup, bodyMaxHeight: popupBodyMaxHeight } = useFlipPopup.useFlipPopup(isShowPopup, {
|
|
24
|
+
genTool,
|
|
25
|
+
genPopup,
|
|
26
|
+
genPopupHeader,
|
|
27
|
+
genButtonWrapper
|
|
28
|
+
});
|
|
29
|
+
const { isGenerating, onGenerate, onOpenProductElementSettings } = useListenEventGenerate.useListenEventGenerate({
|
|
30
|
+
uid: props.uid,
|
|
31
|
+
tag: String(props.tag)
|
|
32
|
+
});
|
|
33
|
+
const { getRequestBody, prompt, changeProductName, changePrompt, changeTone } = useGettingGenerateRequest.useGettingGenerateRequest();
|
|
34
|
+
const { productElement, checkSectionHasProduct } = useCheckingProductInside.useCheckingProductInside(genTool);
|
|
35
|
+
const togglePopup = ()=>{
|
|
36
|
+
setIsShowPopup(!isShowPopup);
|
|
37
|
+
};
|
|
38
|
+
const hidePopup = ()=>{
|
|
39
|
+
setIsShowPopup(false);
|
|
40
|
+
};
|
|
41
|
+
const onChangePrompt = (e)=>{
|
|
42
|
+
changePrompt(e.target.value);
|
|
43
|
+
};
|
|
44
|
+
const onActiveComponent = react.useCallback((e)=>{
|
|
45
|
+
const detail = e.detail;
|
|
46
|
+
if (detail?.componentUid !== props.uid) {
|
|
47
|
+
hidePopup();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
checkSectionHasProduct();
|
|
51
|
+
}, [
|
|
52
|
+
props.uid,
|
|
53
|
+
checkSectionHasProduct
|
|
54
|
+
]);
|
|
55
|
+
const toggleShowMore = ()=>{
|
|
56
|
+
setIsShowMore(!isShowMore);
|
|
57
|
+
};
|
|
58
|
+
const handleGenerateContent = ()=>{
|
|
59
|
+
const body = getRequestBody();
|
|
60
|
+
onGenerate(body);
|
|
61
|
+
hidePopup();
|
|
62
|
+
};
|
|
63
|
+
const handleOpenProductSetting = ()=>{
|
|
64
|
+
onOpenProductElementSettings(productElement.uid ?? '');
|
|
65
|
+
};
|
|
66
|
+
react.useEffect(()=>{
|
|
67
|
+
if (!isGenerating) {
|
|
68
|
+
hidePopup();
|
|
69
|
+
}
|
|
70
|
+
}, [
|
|
71
|
+
isGenerating
|
|
72
|
+
]);
|
|
73
|
+
react.useEffect(()=>{
|
|
74
|
+
if (productElement.productId) {
|
|
75
|
+
setIsShowMore(false);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
setIsShowMore(true);
|
|
79
|
+
}, [
|
|
80
|
+
productElement
|
|
81
|
+
]);
|
|
82
|
+
react.useEffect(()=>{
|
|
83
|
+
window.addEventListener('editor:active-component', onActiveComponent);
|
|
84
|
+
return ()=>{
|
|
85
|
+
window.removeEventListener('editor:active-component', onActiveComponent);
|
|
86
|
+
};
|
|
87
|
+
}, [
|
|
88
|
+
onActiveComponent
|
|
89
|
+
]);
|
|
90
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
91
|
+
className: "gp-relative",
|
|
92
|
+
ref: genTool,
|
|
93
|
+
children: [
|
|
94
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
95
|
+
className: "gp-gen-content-toolbar gp-border-r-[#6a6a6a] gp-border-r gp-pr-1 gp-mr-1",
|
|
96
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
97
|
+
className: classNames({
|
|
98
|
+
'gp-bg-[#3B3B3B]': isShowPopup
|
|
99
|
+
}, 'gp-p-1 gp-text-xs gp-flex gp-gap-1 gp-items-center gp-rounded-md hover:gp-bg-[#3B3B3B] gp-font-medium'),
|
|
100
|
+
onClick: togglePopup,
|
|
101
|
+
children: [
|
|
102
|
+
/*#__PURE__*/ jsxRuntime.jsx(AIIcon.AIIcon, {}),
|
|
103
|
+
"AI Content"
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
108
|
+
className: classNames({
|
|
109
|
+
'gp-hidden': !isShowPopup,
|
|
110
|
+
'gp-right-0': props.tag === 'Section' || popupPositionX === 'right',
|
|
111
|
+
'gp-left-0': popupPositionX === 'left' && props.tag !== 'Section',
|
|
112
|
+
'gp-top-8': popupPositionY === 'top',
|
|
113
|
+
'gp-bottom-8': popupPositionY === 'bottom',
|
|
114
|
+
'!gp-visible': !isValidatingFlipPopup
|
|
115
|
+
}, 'gp-absolute gp-invisible gp-rounded-lg gp-bg-[#151515] gp-w-[312px] !gp-max-w-[312px] !gp-cursor-default'),
|
|
116
|
+
ref: genPopup,
|
|
117
|
+
children: [
|
|
118
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
119
|
+
className: "gp-flex gp-items-center gp-justify-between gp-px-4 gp-py-[10px]",
|
|
120
|
+
ref: genPopupHeader,
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
123
|
+
className: "gp-font-medium gp-text-sm",
|
|
124
|
+
children: "Write with GemAI"
|
|
125
|
+
}),
|
|
126
|
+
/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
127
|
+
className: "gp-p-2 gp-cursor-pointer hover:gp-bg-[#3B3B3B] gp-rounded-md",
|
|
128
|
+
onClick: hidePopup,
|
|
129
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(CloseIcon.CloseIcon, {})
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
}),
|
|
133
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
134
|
+
className: classNames({
|
|
135
|
+
'gp-overflow-auto': popupBodyMaxHeight !== null
|
|
136
|
+
}, 'gp-pt-2 gp-text-left gp-px-4 scrollbar:gp-w-1 scrollbar-thumb:gp-bg-[#999] scrollbar-thumb:gp-rounded-xl'),
|
|
137
|
+
style: {
|
|
138
|
+
maxHeight: popupBodyMaxHeight !== null ? `${popupBodyMaxHeight}px` : 'auto'
|
|
139
|
+
},
|
|
140
|
+
children: [
|
|
141
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
142
|
+
className: "gp-mb-4",
|
|
143
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
144
|
+
className: "gp-text-xs",
|
|
145
|
+
children: "What would you like to describe here?"
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
149
|
+
className: "gp-mb-4 gp-flex",
|
|
150
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("textarea", {
|
|
151
|
+
className: "gp-p-2 gp-bg-[#333333] gp-rounded-lg gp-w-full gp-text-xs gp-text-white placeholder:gp-text-[#AAAAAA] gp-resize-none focus-visible:gp-outline-none",
|
|
152
|
+
placeholder: "e.g: generate feature benefits",
|
|
153
|
+
rows: 4,
|
|
154
|
+
value: prompt,
|
|
155
|
+
onChange: onChangePrompt
|
|
156
|
+
})
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
159
|
+
className: classNames({
|
|
160
|
+
'gp-hidden': !isShowMore
|
|
161
|
+
}, 'gp-mb-4 gp-gap-4 gp-flex gp-flex-col'),
|
|
162
|
+
children: [
|
|
163
|
+
/*#__PURE__*/ jsxRuntime.jsx(ToneAndVoice.ToneAndVoice, {
|
|
164
|
+
changeToneAndVoice: changeTone
|
|
165
|
+
}),
|
|
166
|
+
/*#__PURE__*/ jsxRuntime.jsx(PickProduct.PickProduct, {
|
|
167
|
+
changeProductName: changeProductName,
|
|
168
|
+
openProductSetting: handleOpenProductSetting,
|
|
169
|
+
productId: productElement.productId
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
}),
|
|
173
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
174
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("button", {
|
|
175
|
+
className: "gp-flex gp-justify-center gp-items-center gp-w-full gp-bg-[#333333] gp-py-2 gp-rounded-lg gp-gap-2 gp-text-xs gp-font-medium",
|
|
176
|
+
onClick: toggleShowMore,
|
|
177
|
+
children: [
|
|
178
|
+
"Show more",
|
|
179
|
+
/*#__PURE__*/ jsxRuntime.jsx("span", {
|
|
180
|
+
className: classNames({
|
|
181
|
+
'gp-rotate-180': isShowMore
|
|
182
|
+
}),
|
|
183
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(ShowMoreIcon.ShowMoreIcon, {})
|
|
184
|
+
})
|
|
185
|
+
]
|
|
186
|
+
})
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
}),
|
|
190
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
191
|
+
className: "gp-p-4",
|
|
192
|
+
ref: genButtonWrapper,
|
|
193
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
194
|
+
className: "gp-rounded-lg gp-w-full gp-text-xs gp-font-medium gp-bg-gradient-to-tl gp-from-[#3C38E1] gp-to-[#874CFD] gp-py-2",
|
|
195
|
+
onClick: handleGenerateContent,
|
|
196
|
+
children: isGenerating ? 'Generating...' : 'Generate'
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
exports.AIContentGenerator = AIContentGenerator;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var AIIcon = require('./icons/AIIcon.js');
|
|
6
|
+
|
|
7
|
+
function getRandomArbitrary(min, max) {
|
|
8
|
+
const randomNum = Math.random();
|
|
9
|
+
return randomNum * (max - min) + min;
|
|
10
|
+
}
|
|
11
|
+
const AIGenContentLoading = ({ ...props })=>{
|
|
12
|
+
const [isGenerating, setIsGenerating] = react.useState(false);
|
|
13
|
+
const [time, setTime] = react.useState(0);
|
|
14
|
+
const interval = react.useRef(null);
|
|
15
|
+
const onGenerateContentStatus = react.useCallback((e)=>{
|
|
16
|
+
const detail = e.detail;
|
|
17
|
+
if (detail?.generatingUid !== props.uid) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (detail.status === 'loading') {
|
|
21
|
+
setIsGenerating(true);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (detail.status === 'success') {
|
|
25
|
+
setIsGenerating(false);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
}, [
|
|
29
|
+
props.uid
|
|
30
|
+
]);
|
|
31
|
+
react.useEffect(()=>{
|
|
32
|
+
if (isGenerating) {
|
|
33
|
+
handleFakeLoading();
|
|
34
|
+
} else {
|
|
35
|
+
setTime(0);
|
|
36
|
+
}
|
|
37
|
+
return ()=>{
|
|
38
|
+
interval.current && clearInterval(interval.current);
|
|
39
|
+
};
|
|
40
|
+
}, [
|
|
41
|
+
isGenerating
|
|
42
|
+
]);
|
|
43
|
+
const handleFakeLoading = ()=>{
|
|
44
|
+
setTime(0);
|
|
45
|
+
interval.current = setInterval(()=>{
|
|
46
|
+
setTime((time)=>{
|
|
47
|
+
const randomNum = getRandomArbitrary(0, 6);
|
|
48
|
+
return time >= 580 ? time : time + randomNum;
|
|
49
|
+
});
|
|
50
|
+
}, 50);
|
|
51
|
+
};
|
|
52
|
+
react.useEffect(()=>{
|
|
53
|
+
window.addEventListener('editor:ai-generate-content-status', onGenerateContentStatus);
|
|
54
|
+
return ()=>{
|
|
55
|
+
window.removeEventListener('editor:ai-generate-content-status', onGenerateContentStatus);
|
|
56
|
+
};
|
|
57
|
+
}, [
|
|
58
|
+
onGenerateContentStatus
|
|
59
|
+
]);
|
|
60
|
+
return isGenerating ? /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
61
|
+
className: "gp-absolute gp-top-0 gp-left-0 gp-w-full gp-h-full gp-bg-white gp-bg-opacity-70 gp-flex gp-justify-center gp-items-center gp-z-100 gp-gap-2",
|
|
62
|
+
children: [
|
|
63
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
64
|
+
className: "gp-absolute gp-left-0 gp-top-0 gp-z-2 gp-flex gp-h-full gp-w-full",
|
|
65
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
66
|
+
className: `gp-relative gp-h-[2px] gp-w-full gp-overflow-hidden gp-rounded-md`,
|
|
67
|
+
children: [
|
|
68
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
69
|
+
className: "gp-absolute gp-h-full gp-w-full gp-rounded-md gp-bg-[#F4F4F4]"
|
|
70
|
+
}),
|
|
71
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
72
|
+
className: "gps-image-to-layout-progress-bar gp-absolute gp-h-full gp-rounded-md gp-transition-all",
|
|
73
|
+
style: {
|
|
74
|
+
width: `${time / 600 * 100}%`
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
})
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ jsxRuntime.jsx(AIIcon.AIIcon, {})
|
|
81
|
+
]
|
|
82
|
+
}) : null;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.AIGenContentLoading = AIGenContentLoading;
|