@gem-sdk/core 1.41.3 → 1.42.0-dev.61

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.
Files changed (78) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +54 -6
  2. package/dist/cjs/components/ComponentWrapperPreview.js +44 -1
  3. package/dist/cjs/components/Render.liquid.js +2 -0
  4. package/dist/cjs/components/RenderCustomCode.js +2 -0
  5. package/dist/cjs/components/ai-generator/AIContentGenerator.js +205 -0
  6. package/dist/cjs/components/ai-generator/AIGenContentLoading.js +85 -0
  7. package/dist/cjs/components/ai-generator/components/PickProduct.js +218 -0
  8. package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +77 -0
  9. package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +47 -0
  10. package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +110 -0
  11. package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +37 -0
  12. package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +63 -0
  13. package/dist/cjs/components/ai-generator/icons/AIIcon.js +67 -0
  14. package/dist/cjs/components/ai-generator/icons/CloseIcon.js +19 -0
  15. package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +37 -0
  16. package/dist/cjs/components/ai-generator/icons/SearchIcon.js +21 -0
  17. package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +21 -0
  18. package/dist/cjs/components/constant.js +19 -2
  19. package/dist/cjs/components/resize/Spacing.js +2 -0
  20. package/dist/cjs/components/theme-section/CreateThemeSection.js +2 -0
  21. package/dist/cjs/contexts/ArticleContext.js +39 -0
  22. package/dist/cjs/contexts/ArticleListContext.js +32 -0
  23. package/dist/cjs/contexts/BuilderPreviewContext.js +11 -6
  24. package/dist/cjs/contexts/SectionContext.js +1 -0
  25. package/dist/cjs/graphql/fragments/product-little.generated.js +9 -0
  26. package/dist/cjs/graphql/fragments/product.generated.js +9 -0
  27. package/dist/cjs/graphql/queries/products.generated.js +9 -0
  28. package/dist/cjs/helpers/align.js +19 -0
  29. package/dist/cjs/helpers/carousel.js +7 -10
  30. package/dist/cjs/helpers/colors.js +1 -1
  31. package/dist/cjs/helpers/queries/get-products.js +47 -0
  32. package/dist/cjs/helpers/typography.js +4 -4
  33. package/dist/cjs/hooks/articles/useArticlesQuery.js +152 -0
  34. package/dist/cjs/hooks/shop/use-products-query.js +39 -0
  35. package/dist/cjs/hooks/useAnimations.js +2 -0
  36. package/dist/cjs/hooks/useInitialSwatchesOptions.js +2 -0
  37. package/dist/cjs/hooks/useProduct.js +2 -0
  38. package/dist/cjs/index.js +12 -0
  39. package/dist/esm/components/ComponentToolbarPreview.js +54 -6
  40. package/dist/esm/components/ComponentWrapperPreview.js +44 -1
  41. package/dist/esm/components/Render.liquid.js +2 -0
  42. package/dist/esm/components/RenderCustomCode.js +2 -0
  43. package/dist/esm/components/ai-generator/AIContentGenerator.js +203 -0
  44. package/dist/esm/components/ai-generator/AIGenContentLoading.js +83 -0
  45. package/dist/esm/components/ai-generator/components/PickProduct.js +216 -0
  46. package/dist/esm/components/ai-generator/components/ToneAndVoice.js +75 -0
  47. package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +45 -0
  48. package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +108 -0
  49. package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +35 -0
  50. package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +61 -0
  51. package/dist/esm/components/ai-generator/icons/AIIcon.js +65 -0
  52. package/dist/esm/components/ai-generator/icons/CloseIcon.js +17 -0
  53. package/dist/esm/components/ai-generator/icons/DropdownIcon.js +34 -0
  54. package/dist/esm/components/ai-generator/icons/SearchIcon.js +19 -0
  55. package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +19 -0
  56. package/dist/esm/components/constant.js +19 -3
  57. package/dist/esm/components/resize/Spacing.js +2 -0
  58. package/dist/esm/components/theme-section/CreateThemeSection.js +2 -0
  59. package/dist/esm/contexts/ArticleContext.js +36 -0
  60. package/dist/esm/contexts/ArticleListContext.js +28 -0
  61. package/dist/esm/contexts/BuilderPreviewContext.js +11 -6
  62. package/dist/esm/contexts/SectionContext.js +1 -0
  63. package/dist/esm/graphql/fragments/product-little.generated.js +9 -0
  64. package/dist/esm/graphql/fragments/product.generated.js +9 -0
  65. package/dist/esm/graphql/queries/products.generated.js +9 -0
  66. package/dist/esm/helpers/align.js +17 -0
  67. package/dist/esm/helpers/carousel.js +7 -10
  68. package/dist/esm/helpers/colors.js +1 -1
  69. package/dist/esm/helpers/queries/get-products.js +46 -1
  70. package/dist/esm/helpers/typography.js +4 -4
  71. package/dist/esm/hooks/articles/useArticlesQuery.js +149 -0
  72. package/dist/esm/hooks/shop/use-products-query.js +39 -2
  73. package/dist/esm/hooks/useAnimations.js +2 -0
  74. package/dist/esm/hooks/useInitialSwatchesOptions.js +2 -0
  75. package/dist/esm/hooks/useProduct.js +2 -0
  76. package/dist/esm/index.js +5 -1
  77. package/dist/types/index.d.ts +178 -21
  78. package/package.json +5 -3
@@ -13,10 +13,12 @@ require('react/jsx-runtime');
13
13
  require('zustand');
14
14
  require('@gem-sdk/adapter-shopify');
15
15
  require('swr/mutation');
16
+ require('swr/infinite');
16
17
  require('vanilla-lazyload');
17
18
  require('./useCartUI.js');
18
19
  require('react-transition-group');
19
20
  require('@gem-sdk/core');
21
+ require('classnames');
20
22
  var isBrowser = require('../helpers/is-browser.js');
21
23
  require('../helpers/convert.js');
22
24
 
@@ -8,11 +8,13 @@ require('swr');
8
8
  var PageContext = require('../contexts/PageContext.js');
9
9
  require('@gem-sdk/adapter-shopify');
10
10
  require('swr/mutation');
11
+ require('swr/infinite');
11
12
  require('vanilla-lazyload');
12
13
  require('./useCartUI.js');
13
14
  var variant = require('../helpers/variant.js');
14
15
  require('react-transition-group');
15
16
  require('@gem-sdk/core');
17
+ require('classnames');
16
18
  var flattenConnection = require('../helpers/flatten-connection.js');
17
19
  require('../helpers/convert.js');
18
20
  var product = require('../helpers/product.js');
package/dist/cjs/index.js CHANGED
@@ -16,6 +16,8 @@ var ShopContext = require('./contexts/ShopContext.js');
16
16
  var PageContext = require('./contexts/PageContext.js');
17
17
  var CollectionContext = require('./contexts/CollectionContext.js');
18
18
  var ModalContext = require('./contexts/ModalContext.js');
19
+ var ArticleListContext = require('./contexts/ArticleListContext.js');
20
+ var ArticleContext = require('./contexts/ArticleContext.js');
19
21
  var pageViewUp_generated = require('./graphql/mutations/page-view-up.generated.js');
20
22
  var collectionDetailFilter_generated = require('./graphql/queries/collection-detail-filter.generated.js');
21
23
  var collection_generated = require('./graphql/queries/collection.generated.js');
@@ -51,6 +53,7 @@ var iconList = require('./helpers/icon-list.js');
51
53
  var isDefined = require('./helpers/is-defined.js');
52
54
  var layout = require('./helpers/layout.js');
53
55
  var makeStyle = require('./helpers/make-style.js');
56
+ var align = require('./helpers/align.js');
54
57
  var product = require('./helpers/product.js');
55
58
  var query = require('./helpers/query.js');
56
59
  var radius = require('./helpers/radius.js');
@@ -89,6 +92,7 @@ var useIsomorphicLayoutEffect = require('./hooks/useIsomorphicLayoutEffect.js');
89
92
  var useLoadScript = require('./hooks/useLoadScript.js');
90
93
  var useMoney = require('./hooks/useMoney.js');
91
94
  var usePrevious = require('./hooks/usePrevious.js');
95
+ var useArticlesQuery = require('./hooks/articles/useArticlesQuery.js');
92
96
  var useProduct = require('./hooks/useProduct.js');
93
97
  var useProductList = require('./hooks/useProductList.js');
94
98
  var useSuspenseFetch = require('./hooks/useSuspenseFetch.js');
@@ -136,6 +140,10 @@ exports.CollectionProvider = CollectionContext.CollectionProvider;
136
140
  exports.useCollectionStore = CollectionContext.useCollectionStore;
137
141
  exports.ModalProvider = ModalContext.ModalProvider;
138
142
  exports.useModalStore = ModalContext.useModalStore;
143
+ exports.ArticleListProvider = ArticleListContext.ArticleListProvider;
144
+ exports.useArticleListStore = ArticleListContext.useArticleListStore;
145
+ exports.ArticleProvider = ArticleContext.ArticleProvider;
146
+ exports.useArticleStore = ArticleContext.useArticleStore;
139
147
  exports.PageViewUpDocument = pageViewUp_generated.PageViewUpDocument;
140
148
  exports.CollectionDetailFilterDocument = collectionDetailFilter_generated.CollectionDetailFilterDocument;
141
149
  exports.CollectionDocument = collection_generated.CollectionDocument;
@@ -224,6 +232,7 @@ exports.makeStyleResponsiveState = makeStyle.makeStyleResponsiveState;
224
232
  exports.makeStyleState = makeStyle.makeStyleState;
225
233
  exports.makeWidth = makeStyle.makeWidth;
226
234
  exports.removeNullUndefined = makeStyle.removeNullUndefined;
235
+ exports.convertTextAlignToJustify = align.convertTextAlignToJustify;
227
236
  exports.checkAvailableVariantInStock = product.checkAvailableVariantInStock;
228
237
  exports.getSelectedVariant = product.getSelectedVariant;
229
238
  exports.parseSelectedOption = product.parseSelectedOption;
@@ -302,6 +311,7 @@ exports.useCollectionQuery = useCollectionQuery.useCollectionQuery;
302
311
  exports.useCollectionsQuery = useCollectionsQuery.useCollectionsQuery;
303
312
  exports.useProductQuery = useProductQuery.useProductQuery;
304
313
  exports.useProductsQuery = useProductsQuery.useProductsQuery;
314
+ exports.useProductsQueryAll = useProductsQuery.useProductsQueryAll;
305
315
  exports.useCurrentDevice = useCurrentDevice.useCurrentDevice;
306
316
  exports.shopifyPriceRounding = useFormatMoney.shopifyPriceRounding;
307
317
  exports.useFormatMoney = useFormatMoney.useFormatMoney;
@@ -318,6 +328,8 @@ exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect.default;
318
328
  exports.useLoadScript = useLoadScript.default;
319
329
  exports.useMoney = useMoney.default;
320
330
  exports.usePrevious = usePrevious.usePrevious;
331
+ exports.useArticlesQuery = useArticlesQuery.useArticlesQuery;
332
+ exports.useBlogsQuery = useArticlesQuery.useBlogsQuery;
321
333
  exports.useCheckAvailableVariantInStock = useProduct.useCheckAvailableVariantInStock;
322
334
  exports.useCurrentVariant = useProduct.useCurrentVariant;
323
335
  exports.useCurrentVariantInStock = useProduct.useCurrentVariantInStock;
@@ -6,6 +6,7 @@ import { useShopStore } from '../contexts/ShopContext.js';
6
6
  import '@gem-sdk/adapter-shopify';
7
7
  import 'swr';
8
8
  import 'swr/mutation';
9
+ import 'swr/infinite';
9
10
  import 'vanilla-lazyload';
10
11
  import '../hooks/useCartUI.js';
11
12
  import { CreateThemeSection } from './theme-section/CreateThemeSection.js';
@@ -13,6 +14,9 @@ import Tooltip from './toolbar/Tooltip.js';
13
14
  import { ThemeSectionStatus } from './theme-section/ThemeSectionStatus.js';
14
15
  import Resize from './resize/Resize.js';
15
16
  import { usePostPurchase } from '../hooks/useToolbarPostPurchase.js';
17
+ import { ableGenerateContentElements } from './constant.js';
18
+ import { AIContentGenerator } from './ai-generator/AIContentGenerator.js';
19
+ import { AIGenContentLoading } from './ai-generator/AIGenContentLoading.js';
16
20
  import '../helpers/convert.js';
17
21
 
18
22
  const SECTION_LIMIT = 25;
@@ -26,6 +30,7 @@ const isSection = (el)=>{
26
30
  };
27
31
  const ComponentToolbarPreview = (props)=>{
28
32
  const isThemeSection = props.isThemeSection;
33
+ const isShopifySection = props.isShopifySection;
29
34
  const editingPageType = useShopStore((s)=>s.pageType);
30
35
  const getParents = useBuilderPreviewStore((s)=>s.getParents);
31
36
  const root = useBuilderPreviewStore((s)=>s.getItem('ROOT'));
@@ -171,7 +176,8 @@ const ComponentToolbarPreview = (props)=>{
171
176
  bubbles: true,
172
177
  detail: {
173
178
  componentUid: props.uid,
174
- isThemeSection: isThemeSection
179
+ isThemeSection,
180
+ isShopifySection
175
181
  }
176
182
  });
177
183
  window.dispatchEvent(event);
@@ -187,7 +193,8 @@ const ComponentToolbarPreview = (props)=>{
187
193
  bubbles: true,
188
194
  detail: {
189
195
  componentUid: props.uid,
190
- isThemeSection: isThemeSection
196
+ isThemeSection,
197
+ isShopifySection
191
198
  }
192
199
  });
193
200
  window.dispatchEvent(event);
@@ -236,6 +243,9 @@ const ComponentToolbarPreview = (props)=>{
236
243
  return false;
237
244
  };
238
245
  const getSectionName = ()=>{
246
+ if (isShopifySection) {
247
+ return `Shopify section: ${props.name}`;
248
+ }
239
249
  const checkRenamedSection = props.name && props.name === `Section ${props.uid}`;
240
250
  if (getSectionNumber() >= SECTION_LIMIT - 5) {
241
251
  return `${checkRenamedSection ? 'Section' : props?.name} ${getIndexSection() + 1}/${SECTION_LIMIT}`;
@@ -252,6 +262,7 @@ const ComponentToolbarPreview = (props)=>{
252
262
  "data-toolbar": true,
253
263
  "data-toolbar-section": props.tag == 'Section',
254
264
  "data-toolbar-theme-section": props.tag == 'Section' && !!isThemeSection || isThemeSectionEditor,
265
+ "data-toolbar-shopify-section": props.tag == 'Section' && !!isShopifySection,
255
266
  "data-toolbar-limit": getIndexSection() >= SECTION_LIMIT,
256
267
  children: [
257
268
  /*#__PURE__*/ jsxs("div", {
@@ -294,9 +305,39 @@ const ComponentToolbarPreview = (props)=>{
294
305
  ]
295
306
  })
296
307
  }),
297
- props.tag == 'Section' ? /*#__PURE__*/ jsx("div", {
308
+ props.tag == 'Section' ? /*#__PURE__*/ jsxs("div", {
298
309
  "data-toolbar-name": true,
299
- children: getSectionName()
310
+ children: [
311
+ getSectionName(),
312
+ props.isShopifySection && !props.isShopifyVisibility && /*#__PURE__*/ jsxs("svg", {
313
+ "data-toolbar-visibility": true,
314
+ width: "20",
315
+ height: "20",
316
+ viewBox: "0 0 20 20",
317
+ fill: "none",
318
+ xmlns: "http://www.w3.org/2000/svg",
319
+ children: [
320
+ /*#__PURE__*/ jsx("path", {
321
+ fillRule: "evenodd",
322
+ clipRule: "evenodd",
323
+ 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",
324
+ fill: "#F9F9F9"
325
+ }),
326
+ /*#__PURE__*/ jsx("path", {
327
+ fillRule: "evenodd",
328
+ clipRule: "evenodd",
329
+ 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",
330
+ fill: "#F9F9F9"
331
+ }),
332
+ /*#__PURE__*/ jsx("path", {
333
+ fillRule: "evenodd",
334
+ clipRule: "evenodd",
335
+ 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",
336
+ fill: "#F9F9F9"
337
+ })
338
+ ]
339
+ })
340
+ ]
300
341
  }) : /*#__PURE__*/ jsx("div", {
301
342
  "data-toolbar-name": true,
302
343
  children: toolbarName()
@@ -376,7 +417,10 @@ const ComponentToolbarPreview = (props)=>{
376
417
  ]
377
418
  }, parent.uid);
378
419
  }),
379
- props.tag === 'Section' && !props.isThemeSection && isEnableCreateThemeSection() && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsx(CreateThemeSection, {
420
+ props.tag === 'Section' && !props.isThemeSection && isEnableCreateThemeSection() && !props.isShopifySection && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsx(CreateThemeSection, {
421
+ ...props
422
+ }),
423
+ !props.isShopifySection && ableGenerateContentElements.includes(props.tag) && /*#__PURE__*/ jsx(AIContentGenerator, {
380
424
  ...props
381
425
  }),
382
426
  props.tag == 'Sticky' && /*#__PURE__*/ jsx("div", {
@@ -450,6 +494,7 @@ const ComponentToolbarPreview = (props)=>{
450
494
  "data-outline": true,
451
495
  "data-outline-section": props.tag == 'Section',
452
496
  "data-outline-theme-section": props.tag == 'Section' && !!isThemeSection || isThemeSectionEditor,
497
+ "data-outline-shopify-section": props.tag == 'Section' && !!isShopifySection,
453
498
  "data-outline-limit": getIndexSection() >= SECTION_LIMIT
454
499
  }, 'outline-' + props.uid),
455
500
  props.tag == 'Section' && !isThemeSectionEditor && /*#__PURE__*/ jsxs(Fragment, {
@@ -496,12 +541,15 @@ const ComponentToolbarPreview = (props)=>{
496
541
  })
497
542
  ]
498
543
  }),
544
+ ableGenerateContentElements.includes(props.tag) && /*#__PURE__*/ jsx(AIGenContentLoading, {
545
+ ...props
546
+ }),
499
547
  /*#__PURE__*/ jsx(Resize, {
500
548
  ...props
501
549
  })
502
550
  ]
503
551
  });
504
552
  };
505
- var ComponentToolbarPreview$1 = /*#__PURE__*/ memo(ComponentToolbarPreview);
553
+ var ComponentToolbarPreview$1 = /*#__PURE__*/ memo(ComponentToolbarPreview); /* gem-lint/disallow-import-from-package-path */
506
554
 
507
555
  export { ComponentToolbarPreview$1 as default };
@@ -10,8 +10,10 @@ import 'swr';
10
10
  import '@gem-sdk/adapter-shopify';
11
11
  import 'swr/mutation';
12
12
  import { usePageType } from '../hooks/shop.js';
13
+ import 'swr/infinite';
13
14
  import 'vanilla-lazyload';
14
15
  import '../hooks/useCartUI.js';
16
+ import { cls } from '../helpers/cls.js';
15
17
  import '../helpers/convert.js';
16
18
 
17
19
  const ComponentWrapperPreview = ({ children, ...props })=>{
@@ -37,6 +39,10 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
37
39
  if (props.tag === 'Section' && props.isThemeSection) {
38
40
  customProps['data-theme-section'] = true;
39
41
  }
42
+ if (props.tag === 'Section' && props.isShopifySection) {
43
+ customProps['data-shopify-section'] = true;
44
+ customProps['data-toolbar-wrap'] = true;
45
+ }
40
46
  // Build editor configs
41
47
  if (props.editorConfigs) {
42
48
  const editorConfigs = props.editorConfigs;
@@ -91,6 +97,40 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
91
97
  'data-component-label': props.label,
92
98
  'data-not-droppable': isNotDroppable(props.tag)
93
99
  };
100
+ const ShopifySection = ({ name, visibility })=>{
101
+ return /*#__PURE__*/ jsxs("div", {
102
+ className: cls('gp-flex gp-items-center gp-justify-center gp-gap-[8px] gp-bg-[#F4F4F4] gp-p-[16px] gp-border gp-border-[#D6D6D6]', {
103
+ 'gp-opacity-60': !visibility
104
+ }),
105
+ children: [
106
+ /*#__PURE__*/ jsxs("svg", {
107
+ width: "24",
108
+ height: "24",
109
+ viewBox: "0 0 24 24",
110
+ fill: "none",
111
+ xmlns: "http://www.w3.org/2000/svg",
112
+ children: [
113
+ /*#__PURE__*/ jsx("path", {
114
+ 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",
115
+ fill: "#95BF47"
116
+ }),
117
+ /*#__PURE__*/ jsx("path", {
118
+ 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",
119
+ fill: "#5E8E3E"
120
+ }),
121
+ /*#__PURE__*/ jsx("path", {
122
+ 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",
123
+ fill: "white"
124
+ })
125
+ ]
126
+ }),
127
+ /*#__PURE__*/ jsx("span", {
128
+ className: "gp-text-[#212121] gp-text-[14px] gp-leading-[24px] gp-font-medium",
129
+ children: name
130
+ })
131
+ ]
132
+ });
133
+ };
94
134
  if (disableWrap.includes(props.tag) && /*#__PURE__*/ isValidElement(children)) {
95
135
  return /*#__PURE__*/ jsxs(Fragment, {
96
136
  children: [
@@ -105,7 +145,10 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
105
145
  builderAttrs,
106
146
  advanced,
107
147
  children: [
108
- children.props['children'],
148
+ props.isShopifySection ? /*#__PURE__*/ jsx(ShopifySection, {
149
+ name: props.name ?? '',
150
+ visibility: !!props.isShopifyVisibility
151
+ }) : children.props['children'],
109
152
  /*#__PURE__*/ jsx(ComponentToolbarPreview, {
110
153
  ...props
111
154
  })
@@ -5,11 +5,13 @@ import 'zustand';
5
5
  import 'swr';
6
6
  import '@gem-sdk/adapter-shopify';
7
7
  import 'swr/mutation';
8
+ import 'swr/infinite';
8
9
  import 'vanilla-lazyload';
9
10
  import '../hooks/useCartUI.js';
10
11
  import 'react-transition-group';
11
12
  import '@gem-sdk/core';
12
13
  import { disableWrap, customRenderChildren } from './constant.js';
14
+ import 'classnames';
13
15
  import { composeAdvanceStyle } from '../helpers/compose-advance-style.js';
14
16
  import { baseAssetURL, isLocalEnv } from '../helpers/convert.js';
15
17
  import { RenderIf, template } from '../helpers/render.js';
@@ -7,10 +7,12 @@ import 'swr';
7
7
  import '@gem-sdk/adapter-shopify';
8
8
  import 'swr/mutation';
9
9
  import { useEditorMode } from '../hooks/shop.js';
10
+ import 'swr/infinite';
10
11
  import 'vanilla-lazyload';
11
12
  import '../hooks/useCartUI.js';
12
13
  import 'react-transition-group';
13
14
  import '@gem-sdk/core';
15
+ import 'classnames';
14
16
  import '../helpers/convert.js';
15
17
 
16
18
  const RenderCustomCode = ({ uid, advanced })=>{
@@ -0,0 +1,203 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState, useRef, useCallback, useEffect } from 'react';
3
+ import { AIIcon } from './icons/AIIcon.js';
4
+ import { CloseIcon } from './icons/CloseIcon.js';
5
+ import { ShowMoreIcon } from './icons/ShowMoreIcon.js';
6
+ import { PickProduct } from './components/PickProduct.js';
7
+ import { ToneAndVoice } from './components/ToneAndVoice.js';
8
+ import classNames from 'classnames';
9
+ import { useListenEventGenerate } from './hooks/useListenEventGenerate.js';
10
+ import { useGettingGenerateRequest } from './hooks/useGettingGenerateRequest.js';
11
+ import { useFlipPopup } from './hooks/useFlipPopup.js';
12
+ import { useCheckingProductInside } from './hooks/useCheckingProductInside.js';
13
+
14
+ const AIContentGenerator = ({ ...props })=>{
15
+ const [isShowPopup, setIsShowPopup] = useState(false);
16
+ const [isShowMore, setIsShowMore] = useState(false);
17
+ const genTool = useRef(null);
18
+ const genPopup = useRef(null);
19
+ const genPopupHeader = useRef(null);
20
+ const genButtonWrapper = useRef(null);
21
+ const { popupPositionX, popupPositionY, isValidating: isValidatingFlipPopup, bodyMaxHeight: popupBodyMaxHeight } = useFlipPopup(isShowPopup, {
22
+ genTool,
23
+ genPopup,
24
+ genPopupHeader,
25
+ genButtonWrapper
26
+ });
27
+ const { isGenerating, onGenerate, onOpenProductElementSettings } = useListenEventGenerate({
28
+ uid: props.uid,
29
+ tag: String(props.tag)
30
+ });
31
+ const { getRequestBody, prompt, changeProductName, changePrompt, changeTone } = useGettingGenerateRequest();
32
+ const { productElement, checkSectionHasProduct } = useCheckingProductInside(genTool);
33
+ const togglePopup = ()=>{
34
+ setIsShowPopup(!isShowPopup);
35
+ };
36
+ const hidePopup = ()=>{
37
+ setIsShowPopup(false);
38
+ };
39
+ const onChangePrompt = (e)=>{
40
+ changePrompt(e.target.value);
41
+ };
42
+ const onActiveComponent = useCallback((e)=>{
43
+ const detail = e.detail;
44
+ if (detail?.componentUid !== props.uid) {
45
+ hidePopup();
46
+ return;
47
+ }
48
+ checkSectionHasProduct();
49
+ }, [
50
+ props.uid,
51
+ checkSectionHasProduct
52
+ ]);
53
+ const toggleShowMore = ()=>{
54
+ setIsShowMore(!isShowMore);
55
+ };
56
+ const handleGenerateContent = ()=>{
57
+ const body = getRequestBody();
58
+ onGenerate(body);
59
+ hidePopup();
60
+ };
61
+ const handleOpenProductSetting = ()=>{
62
+ onOpenProductElementSettings(productElement.uid ?? '');
63
+ };
64
+ useEffect(()=>{
65
+ if (!isGenerating) {
66
+ hidePopup();
67
+ }
68
+ }, [
69
+ isGenerating
70
+ ]);
71
+ useEffect(()=>{
72
+ if (productElement.productId) {
73
+ setIsShowMore(false);
74
+ return;
75
+ }
76
+ setIsShowMore(true);
77
+ }, [
78
+ productElement
79
+ ]);
80
+ useEffect(()=>{
81
+ window.addEventListener('editor:active-component', onActiveComponent);
82
+ return ()=>{
83
+ window.removeEventListener('editor:active-component', onActiveComponent);
84
+ };
85
+ }, [
86
+ onActiveComponent
87
+ ]);
88
+ return /*#__PURE__*/ jsxs("div", {
89
+ className: "gp-relative",
90
+ ref: genTool,
91
+ children: [
92
+ /*#__PURE__*/ jsx("div", {
93
+ className: "gp-gen-content-toolbar gp-border-r-[#6a6a6a] gp-border-r gp-pr-1 gp-mr-1",
94
+ children: /*#__PURE__*/ jsxs("button", {
95
+ className: classNames({
96
+ 'gp-bg-[#3B3B3B]': isShowPopup
97
+ }, 'gp-p-1 gp-text-xs gp-flex gp-gap-1 gp-items-center gp-rounded-md hover:gp-bg-[#3B3B3B] gp-font-medium'),
98
+ onClick: togglePopup,
99
+ children: [
100
+ /*#__PURE__*/ jsx(AIIcon, {}),
101
+ "AI Content"
102
+ ]
103
+ })
104
+ }),
105
+ /*#__PURE__*/ jsxs("div", {
106
+ className: classNames({
107
+ 'gp-hidden': !isShowPopup,
108
+ 'gp-right-0': props.tag === 'Section' || popupPositionX === 'right',
109
+ 'gp-left-0': popupPositionX === 'left' && props.tag !== 'Section',
110
+ 'gp-top-8': popupPositionY === 'top',
111
+ 'gp-bottom-8': popupPositionY === 'bottom',
112
+ '!gp-visible': !isValidatingFlipPopup
113
+ }, 'gp-absolute gp-invisible gp-rounded-lg gp-bg-[#151515] gp-w-[312px] !gp-max-w-[312px] !gp-cursor-default'),
114
+ ref: genPopup,
115
+ children: [
116
+ /*#__PURE__*/ jsxs("div", {
117
+ className: "gp-flex gp-items-center gp-justify-between gp-px-4 gp-py-[10px]",
118
+ ref: genPopupHeader,
119
+ children: [
120
+ /*#__PURE__*/ jsx("span", {
121
+ className: "gp-font-medium gp-text-sm",
122
+ children: "Write with GemAI"
123
+ }),
124
+ /*#__PURE__*/ jsx("button", {
125
+ className: "gp-p-2 gp-cursor-pointer hover:gp-bg-[#3B3B3B] gp-rounded-md",
126
+ onClick: hidePopup,
127
+ children: /*#__PURE__*/ jsx(CloseIcon, {})
128
+ })
129
+ ]
130
+ }),
131
+ /*#__PURE__*/ jsxs("div", {
132
+ className: classNames({
133
+ 'gp-overflow-auto': popupBodyMaxHeight !== null
134
+ }, 'gp-pt-2 gp-text-left gp-px-4 scrollbar:gp-w-1 scrollbar-thumb:gp-bg-[#999] scrollbar-thumb:gp-rounded-xl'),
135
+ style: {
136
+ maxHeight: popupBodyMaxHeight !== null ? `${popupBodyMaxHeight}px` : 'auto'
137
+ },
138
+ children: [
139
+ /*#__PURE__*/ jsx("div", {
140
+ className: "gp-mb-4",
141
+ children: /*#__PURE__*/ jsx("span", {
142
+ className: "gp-text-xs",
143
+ children: "What would you like to describe here?"
144
+ })
145
+ }),
146
+ /*#__PURE__*/ jsx("div", {
147
+ className: "gp-mb-4 gp-flex",
148
+ children: /*#__PURE__*/ jsx("textarea", {
149
+ 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",
150
+ placeholder: "e.g: generate feature benefits",
151
+ rows: 4,
152
+ value: prompt,
153
+ onChange: onChangePrompt
154
+ })
155
+ }),
156
+ /*#__PURE__*/ jsxs("div", {
157
+ className: classNames({
158
+ 'gp-hidden': !isShowMore
159
+ }, 'gp-mb-4 gp-gap-4 gp-flex gp-flex-col'),
160
+ children: [
161
+ /*#__PURE__*/ jsx(ToneAndVoice, {
162
+ changeToneAndVoice: changeTone
163
+ }),
164
+ /*#__PURE__*/ jsx(PickProduct, {
165
+ changeProductName: changeProductName,
166
+ openProductSetting: handleOpenProductSetting,
167
+ productId: productElement.productId
168
+ })
169
+ ]
170
+ }),
171
+ /*#__PURE__*/ jsx("div", {
172
+ children: /*#__PURE__*/ jsxs("button", {
173
+ 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",
174
+ onClick: toggleShowMore,
175
+ children: [
176
+ "Show more",
177
+ /*#__PURE__*/ jsx("span", {
178
+ className: classNames({
179
+ 'gp-rotate-180': isShowMore
180
+ }),
181
+ children: /*#__PURE__*/ jsx(ShowMoreIcon, {})
182
+ })
183
+ ]
184
+ })
185
+ })
186
+ ]
187
+ }),
188
+ /*#__PURE__*/ jsx("div", {
189
+ className: "gp-p-4",
190
+ ref: genButtonWrapper,
191
+ children: /*#__PURE__*/ jsx("button", {
192
+ 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",
193
+ onClick: handleGenerateContent,
194
+ children: isGenerating ? 'Generating...' : 'Generate'
195
+ })
196
+ })
197
+ ]
198
+ })
199
+ ]
200
+ });
201
+ };
202
+
203
+ export { AIContentGenerator };
@@ -0,0 +1,83 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+ import { useState, useRef, useCallback, useEffect } from 'react';
3
+ import { AIIcon } from './icons/AIIcon.js';
4
+
5
+ function getRandomArbitrary(min, max) {
6
+ const randomNum = Math.random();
7
+ return randomNum * (max - min) + min;
8
+ }
9
+ const AIGenContentLoading = ({ ...props })=>{
10
+ const [isGenerating, setIsGenerating] = useState(false);
11
+ const [time, setTime] = useState(0);
12
+ const interval = useRef(null);
13
+ const onGenerateContentStatus = useCallback((e)=>{
14
+ const detail = e.detail;
15
+ if (detail?.generatingUid !== props.uid) {
16
+ return;
17
+ }
18
+ if (detail.status === 'loading') {
19
+ setIsGenerating(true);
20
+ return;
21
+ }
22
+ if (detail.status === 'success') {
23
+ setIsGenerating(false);
24
+ return;
25
+ }
26
+ }, [
27
+ props.uid
28
+ ]);
29
+ useEffect(()=>{
30
+ if (isGenerating) {
31
+ handleFakeLoading();
32
+ } else {
33
+ setTime(0);
34
+ }
35
+ return ()=>{
36
+ interval.current && clearInterval(interval.current);
37
+ };
38
+ }, [
39
+ isGenerating
40
+ ]);
41
+ const handleFakeLoading = ()=>{
42
+ setTime(0);
43
+ interval.current = setInterval(()=>{
44
+ setTime((time)=>{
45
+ const randomNum = getRandomArbitrary(0, 6);
46
+ return time >= 580 ? time : time + randomNum;
47
+ });
48
+ }, 50);
49
+ };
50
+ useEffect(()=>{
51
+ window.addEventListener('editor:ai-generate-content-status', onGenerateContentStatus);
52
+ return ()=>{
53
+ window.removeEventListener('editor:ai-generate-content-status', onGenerateContentStatus);
54
+ };
55
+ }, [
56
+ onGenerateContentStatus
57
+ ]);
58
+ return isGenerating ? /*#__PURE__*/ jsxs("div", {
59
+ 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",
60
+ children: [
61
+ /*#__PURE__*/ jsx("div", {
62
+ className: "gp-absolute gp-left-0 gp-top-0 gp-z-2 gp-flex gp-h-full gp-w-full",
63
+ children: /*#__PURE__*/ jsxs("div", {
64
+ className: `gp-relative gp-h-[2px] gp-w-full gp-overflow-hidden gp-rounded-md`,
65
+ children: [
66
+ /*#__PURE__*/ jsx("div", {
67
+ className: "gp-absolute gp-h-full gp-w-full gp-rounded-md gp-bg-[#F4F4F4]"
68
+ }),
69
+ /*#__PURE__*/ jsx("div", {
70
+ className: "gps-image-to-layout-progress-bar gp-absolute gp-h-full gp-rounded-md gp-transition-all",
71
+ style: {
72
+ width: `${time / 600 * 100}%`
73
+ }
74
+ })
75
+ ]
76
+ })
77
+ }),
78
+ /*#__PURE__*/ jsx(AIIcon, {})
79
+ ]
80
+ }) : null;
81
+ };
82
+
83
+ export { AIGenContentLoading };