@gem-sdk/core 1.42.3-dev.64 → 1.42.7

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 (72) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +6 -120
  2. package/dist/cjs/components/ComponentWrapperPreview.js +1 -44
  3. package/dist/cjs/components/Render.liquid.js +0 -2
  4. package/dist/cjs/components/RenderCustomCode.js +0 -2
  5. package/dist/cjs/components/constant.js +2 -19
  6. package/dist/cjs/components/resize/Spacing.js +0 -2
  7. package/dist/cjs/components/theme-section/CreateThemeSection.js +0 -2
  8. package/dist/cjs/contexts/BuilderPreviewContext.js +6 -11
  9. package/dist/cjs/contexts/SectionContext.js +0 -1
  10. package/dist/cjs/helpers/carousel.js +10 -7
  11. package/dist/cjs/helpers/colors.js +1 -1
  12. package/dist/cjs/helpers/queries/get-products.js +0 -23
  13. package/dist/cjs/helpers/typography.js +4 -4
  14. package/dist/cjs/hooks/shop/use-products-query.js +0 -29
  15. package/dist/cjs/hooks/useAnimations.js +0 -2
  16. package/dist/cjs/hooks/useInitialSwatchesOptions.js +0 -2
  17. package/dist/cjs/hooks/useProduct.js +0 -2
  18. package/dist/cjs/index.js +15 -26
  19. package/dist/esm/components/ComponentToolbarPreview.js +6 -120
  20. package/dist/esm/components/ComponentWrapperPreview.js +1 -44
  21. package/dist/esm/components/Render.liquid.js +0 -2
  22. package/dist/esm/components/RenderCustomCode.js +0 -2
  23. package/dist/esm/components/constant.js +3 -19
  24. package/dist/esm/components/resize/Spacing.js +0 -2
  25. package/dist/esm/components/theme-section/CreateThemeSection.js +0 -2
  26. package/dist/esm/contexts/BuilderPreviewContext.js +6 -11
  27. package/dist/esm/contexts/SectionContext.js +0 -1
  28. package/dist/esm/helpers/carousel.js +10 -7
  29. package/dist/esm/helpers/colors.js +1 -1
  30. package/dist/esm/helpers/queries/get-products.js +1 -23
  31. package/dist/esm/helpers/typography.js +4 -4
  32. package/dist/esm/hooks/shop/use-products-query.js +2 -30
  33. package/dist/esm/hooks/useAnimations.js +0 -2
  34. package/dist/esm/hooks/useInitialSwatchesOptions.js +0 -2
  35. package/dist/esm/hooks/useProduct.js +0 -2
  36. package/dist/esm/index.js +10 -14
  37. package/dist/types/index.d.ts +86 -227
  38. package/package.json +3 -5
  39. package/dist/cjs/components/ai-generator/AIContentGenerator.js +0 -205
  40. package/dist/cjs/components/ai-generator/AIGenContentLoading.js +0 -85
  41. package/dist/cjs/components/ai-generator/components/PickProduct.js +0 -218
  42. package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +0 -77
  43. package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +0 -47
  44. package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +0 -110
  45. package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +0 -37
  46. package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +0 -63
  47. package/dist/cjs/components/ai-generator/icons/AIIcon.js +0 -67
  48. package/dist/cjs/components/ai-generator/icons/CloseIcon.js +0 -19
  49. package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +0 -37
  50. package/dist/cjs/components/ai-generator/icons/SearchIcon.js +0 -21
  51. package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +0 -21
  52. package/dist/cjs/contexts/ArticleContext.js +0 -39
  53. package/dist/cjs/contexts/ArticleListContext.js +0 -32
  54. package/dist/cjs/helpers/align.js +0 -19
  55. package/dist/cjs/hooks/articles/useArticlesQuery.js +0 -152
  56. package/dist/esm/components/ai-generator/AIContentGenerator.js +0 -203
  57. package/dist/esm/components/ai-generator/AIGenContentLoading.js +0 -83
  58. package/dist/esm/components/ai-generator/components/PickProduct.js +0 -216
  59. package/dist/esm/components/ai-generator/components/ToneAndVoice.js +0 -75
  60. package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +0 -45
  61. package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +0 -108
  62. package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +0 -35
  63. package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +0 -61
  64. package/dist/esm/components/ai-generator/icons/AIIcon.js +0 -65
  65. package/dist/esm/components/ai-generator/icons/CloseIcon.js +0 -17
  66. package/dist/esm/components/ai-generator/icons/DropdownIcon.js +0 -34
  67. package/dist/esm/components/ai-generator/icons/SearchIcon.js +0 -19
  68. package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +0 -19
  69. package/dist/esm/contexts/ArticleContext.js +0 -36
  70. package/dist/esm/contexts/ArticleListContext.js +0 -28
  71. package/dist/esm/helpers/align.js +0 -17
  72. package/dist/esm/hooks/articles/useArticlesQuery.js +0 -149
@@ -1,203 +0,0 @@
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 };
@@ -1,83 +0,0 @@
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 };
@@ -1,216 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useState, useRef, useMemo, useEffect } from 'react';
3
- import { SearchIcon } from '../icons/SearchIcon.js';
4
- import { useListProductQuery } from '../../../hooks/shop/use-products-query.js';
5
- import classNames from 'classnames';
6
- import 'zustand';
7
- import 'swr';
8
- import '@gem-sdk/adapter-shopify';
9
- import 'swr/mutation';
10
- import { useProductQuery } from '../../../hooks/shop/use-product-query.js';
11
- import 'vanilla-lazyload';
12
- import '../../../hooks/useCartUI.js';
13
- import 'react-transition-group';
14
- import '@gem-sdk/core';
15
- import '../../../helpers/convert.js';
16
-
17
- const PickProduct = (props)=>{
18
- const LIMIT_PRODUCTS = 8;
19
- const [productVariables, setProductVariables] = useState(!props.productId ? {
20
- first: LIMIT_PRODUCTS
21
- } : undefined);
22
- const { data: productList, isLoading: isLoadingGetProducts, isValidating: isValidatingGetProducts, size: productsSize, setSize: setProductsSize } = useListProductQuery(productVariables, {
23
- revalidateFirstPage: false
24
- });
25
- const { data: sectionProduct } = useProductQuery(props.productId);
26
- const [activeProduct, setActiveProduct] = useState();
27
- const [isShowChooseProduct, setIsShowChooseProduct] = useState(false);
28
- const debounceSearch = useRef(null);
29
- const debounceScroll = useRef(null);
30
- const toggleChooseProduct = ()=>{
31
- if (props.productId) return;
32
- setIsShowChooseProduct(!isShowChooseProduct);
33
- };
34
- const chooseProduct = (product)=>{
35
- setActiveProduct(product);
36
- setIsShowChooseProduct(false);
37
- };
38
- const searchProduct = (e)=>{
39
- debounceSearch.current && clearTimeout(debounceSearch.current);
40
- debounceSearch.current = setTimeout(()=>{
41
- const searchValue = e.target.value ?? '';
42
- if (searchValue) {
43
- setProductVariables({
44
- first: LIMIT_PRODUCTS,
45
- where: {
46
- titleContainsFold: searchValue
47
- }
48
- });
49
- return;
50
- }
51
- setProductVariables({
52
- first: LIMIT_PRODUCTS
53
- });
54
- }, 200);
55
- };
56
- const handleOpenProductElementSettings = ()=>{
57
- props.openProductSetting();
58
- };
59
- const handleLoadMore = (e)=>{
60
- const target = e.target;
61
- if (target.scrollHeight - target.scrollTop === target.clientHeight) {
62
- debounceScroll.current && clearTimeout(debounceScroll.current);
63
- debounceScroll.current = setTimeout(()=>{
64
- setProductsSize(productsSize + 1);
65
- }, 50);
66
- }
67
- };
68
- const products = useMemo(()=>{
69
- return productList?.reduce((acc, curr)=>{
70
- return [
71
- ...acc,
72
- ...curr.products?.edges ?? []
73
- ];
74
- }, []) ?? [];
75
- }, [
76
- productList
77
- ]);
78
- useEffect(()=>{
79
- if (products.length && !activeProduct && !props.productId) {
80
- const firstProduct = products[0]?.node;
81
- if (!firstProduct) return;
82
- setActiveProduct({
83
- id: firstProduct?.id,
84
- name: firstProduct?.title,
85
- image: firstProduct.featuredImage?.src
86
- });
87
- }
88
- }, [
89
- products,
90
- activeProduct,
91
- props.productId
92
- ]);
93
- useEffect(()=>{
94
- if (activeProduct && activeProduct.name) {
95
- props.changeProductName(activeProduct.name);
96
- }
97
- }, [
98
- activeProduct,
99
- props
100
- ]);
101
- useEffect(()=>{
102
- if (sectionProduct) {
103
- setActiveProduct({
104
- id: sectionProduct.id,
105
- name: sectionProduct.title,
106
- image: sectionProduct.featuredImage?.src
107
- });
108
- }
109
- }, [
110
- sectionProduct
111
- ]);
112
- return /*#__PURE__*/ jsxs("div", {
113
- className: "gp-flex gp-flex-col gp-gap-2",
114
- children: [
115
- /*#__PURE__*/ jsx("p", {
116
- className: "gp-py-2 gp-text-xs",
117
- children: "Product"
118
- }),
119
- /*#__PURE__*/ jsxs("div", {
120
- className: "gp-relative",
121
- children: [
122
- !isLoadingGetProducts || activeProduct ? /*#__PURE__*/ jsxs("button", {
123
- className: classNames({
124
- 'gp-cursor-default': props.productId
125
- }, 'gp-flex gp-gap-2 gp-items-center gp-w-full gp-p-2 gp-rounded-lg gp-bg-[#333333] gp-text-xs'),
126
- onClick: toggleChooseProduct,
127
- children: [
128
- /*#__PURE__*/ jsx("img", {
129
- className: "gp-rounded-lg gp-w-10 gp-h-10",
130
- src: activeProduct?.image,
131
- alt: "product_image"
132
- }),
133
- /*#__PURE__*/ jsx("span", {
134
- className: "gp-truncate gp-max-w-[210px]",
135
- children: activeProduct?.name
136
- })
137
- ]
138
- }) : /*#__PURE__*/ jsx("div", {
139
- children: /*#__PURE__*/ jsx("span", {
140
- className: "gp-text-xs",
141
- children: "Getting products..."
142
- })
143
- }),
144
- props.productId && /*#__PURE__*/ jsx("div", {
145
- className: "gp-mt-2 gp-text-xs",
146
- children: /*#__PURE__*/ jsxs("p", {
147
- children: [
148
- "You can manage it in",
149
- ' ',
150
- /*#__PURE__*/ jsx("button", {
151
- className: "gp-text-[#8AA4FF] gp-cursor-pointer hover:gp-underline",
152
- onClick: handleOpenProductElementSettings,
153
- children: "Product element"
154
- })
155
- ]
156
- })
157
- }),
158
- isShowChooseProduct && /*#__PURE__*/ jsxs("div", {
159
- className: "gp-absolute gp-w-full gp-top-16 gp-left-0 gp-rounded-lg gp-bg-[#333333] gp-p-2 gp-flex gp-flex-col gp-gap-2 gp-z-10",
160
- children: [
161
- /*#__PURE__*/ jsxs("div", {
162
- className: "gp-flex gp-items-center gp-gap-2 gp-p-2",
163
- children: [
164
- /*#__PURE__*/ jsx(SearchIcon, {}),
165
- /*#__PURE__*/ jsx("input", {
166
- className: "gp-bg-transparent gp-w-full focus-visible:!gp-outline-none gp-text-xs",
167
- placeholder: "Search product...",
168
- onChange: searchProduct
169
- })
170
- ]
171
- }),
172
- /*#__PURE__*/ jsxs("div", {
173
- className: "gp-max-h-[168px] gp-overflow-auto scrollbar:gp-w-1 scrollbar-thumb:gp-bg-[#999] scrollbar-thumb:gp-rounded-xl",
174
- onScroll: handleLoadMore,
175
- children: [
176
- products?.map((item)=>{
177
- return /*#__PURE__*/ jsxs("button", {
178
- className: "gp-flex gp-p-2 hover:gp-bg-[#3B3B3B] gp-rounded-lg gp-cursor-pointer gp-gap-2 gp-items-center",
179
- onClick: ()=>{
180
- chooseProduct({
181
- id: item.node?.id,
182
- name: item.node?.title,
183
- image: item.node?.featuredImage?.src
184
- });
185
- },
186
- children: [
187
- /*#__PURE__*/ jsx("img", {
188
- className: "gp-rounded-lg gp-w-10 gp-h-10",
189
- src: item.node?.featuredImage?.src,
190
- alt: "product_image"
191
- }),
192
- /*#__PURE__*/ jsx("span", {
193
- className: "gp-truncate gp-max-w-[210px] gp-text-xs",
194
- children: item.node?.title
195
- })
196
- ]
197
- }, item.node?.id);
198
- }),
199
- isLoadingGetProducts || isValidatingGetProducts && /*#__PURE__*/ jsx("div", {
200
- className: "gp-p-2",
201
- children: /*#__PURE__*/ jsx("span", {
202
- className: "gp-text-xs",
203
- children: "Getting products..."
204
- })
205
- })
206
- ]
207
- })
208
- ]
209
- })
210
- ]
211
- })
212
- ]
213
- });
214
- };
215
-
216
- export { PickProduct };
@@ -1,75 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useState, useEffect } from 'react';
3
- import { DropdownIcon, TickIcon } from '../icons/DropdownIcon.js';
4
- import classNames from 'classnames';
5
-
6
- const ToneAndVoice = (props)=>{
7
- const listToneAndVoice = [
8
- 'Persuasive',
9
- 'Friendly',
10
- 'Professional',
11
- 'Casual'
12
- ];
13
- const [tone, setTone] = useState(listToneAndVoice[0]);
14
- const [isShow, setIsShow] = useState(false);
15
- const toggle = ()=>{
16
- setIsShow(!isShow);
17
- };
18
- const setValue = (value)=>{
19
- setTone(value);
20
- setIsShow(false);
21
- };
22
- useEffect(()=>{
23
- tone && props.changeToneAndVoice(tone);
24
- }, [
25
- tone,
26
- props
27
- ]);
28
- return /*#__PURE__*/ jsx("div", {
29
- children: /*#__PURE__*/ jsxs("div", {
30
- className: "gp-flex gp-flex-col gp-gap-2",
31
- children: [
32
- /*#__PURE__*/ jsx("p", {
33
- className: "gp-py-2 gp-text-xs",
34
- children: "Tone and Voice"
35
- }),
36
- /*#__PURE__*/ jsxs("div", {
37
- className: "gp-relative",
38
- children: [
39
- /*#__PURE__*/ jsxs("button", {
40
- className: "gp-flex gp-justify-between gp-items-center gp-w-full gp-p-2 gp-rounded-lg gp-bg-[#333333] gp-text-xs",
41
- onClick: toggle,
42
- children: [
43
- tone,
44
- /*#__PURE__*/ jsx(DropdownIcon, {})
45
- ]
46
- }),
47
- isShow ? /*#__PURE__*/ jsx("div", {
48
- className: "gp-absolute gp-w-full gp-top-10 gp-left-0 gp-rounded-lg gp-bg-[#333333] gp-p-2 gp-flex gp-flex-col gp-gap-2 gp-z-10",
49
- children: listToneAndVoice.map((item)=>{
50
- return /*#__PURE__*/ jsxs("button", {
51
- className: "gp-flex gp-p-2 hover:gp-bg-[#3B3B3B] gp-rounded-lg gp-cursor-pointer gp-gap-3 gp-items-center",
52
- onClick: ()=>setValue(item),
53
- children: [
54
- /*#__PURE__*/ jsx("div", {
55
- className: classNames({
56
- 'gp-invisible': tone !== item
57
- }),
58
- children: /*#__PURE__*/ jsx(TickIcon, {})
59
- }),
60
- /*#__PURE__*/ jsx("span", {
61
- className: "gp-text-xs",
62
- children: item
63
- })
64
- ]
65
- }, item);
66
- })
67
- }) : null
68
- ]
69
- })
70
- ]
71
- })
72
- });
73
- };
74
-
75
- export { ToneAndVoice };
@@ -1,45 +0,0 @@
1
- import { useState, useCallback, useEffect } from 'react';
2
-
3
- const useCheckingProductInside = (genTool, options)=>{
4
- const [productElement, setProductElement] = useState({});
5
- const checkSectionHasProduct = useCallback(()=>{
6
- if (!genTool.current) {
7
- setProductElement({
8
- productId: '',
9
- uid: ''
10
- });
11
- return;
12
- }
13
- const sectionEl = genTool.current?.closest('[data-component-tag="Section"]');
14
- const productEl = sectionEl?.querySelector('[data-product-id]:not([data-product-id=""])');
15
- const productId = productEl?.getAttribute('data-product-id');
16
- const productElUid = productEl?.getAttribute('data-uid');
17
- const productListOutSideProduct = productEl?.closest('[data-component-tag="ProductList"]');
18
- if (productListOutSideProduct || !productId) {
19
- setProductElement({
20
- productId: '',
21
- uid: ''
22
- });
23
- return;
24
- }
25
- setProductElement({
26
- productId: productId ? 'gid://shopify/Product/' + productId : '',
27
- uid: productElUid ?? ''
28
- });
29
- }, [
30
- genTool
31
- ]);
32
- useEffect(()=>{
33
- if (!options?.isEnabled) return;
34
- checkSectionHasProduct();
35
- }, [
36
- options?.isEnabled,
37
- checkSectionHasProduct
38
- ]);
39
- return {
40
- productElement,
41
- checkSectionHasProduct
42
- };
43
- };
44
-
45
- export { useCheckingProductInside };