@gem-sdk/core 1.23.0 → 1.23.1

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 (50) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +443 -0
  2. package/dist/cjs/components/ComponentWrapper.js +25 -8
  3. package/dist/cjs/components/ComponentWrapperPreview.js +37 -4
  4. package/dist/cjs/components/Render.liquid.js +8 -0
  5. package/dist/cjs/components/RenderCustomCode.js +2 -0
  6. package/dist/cjs/components/resize/Resize.js +16 -0
  7. package/dist/cjs/components/resize/Spacing.js +132 -0
  8. package/dist/cjs/components/src/product/helpers/variant-presets.js +56 -0
  9. package/dist/cjs/components/theme-section/CreateThemeSection.js +117 -0
  10. package/dist/cjs/components/theme-section/ThemeSectionStatus.js +36 -0
  11. package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +102 -0
  12. package/dist/cjs/components/toolbar/Tooltip.js +22 -0
  13. package/dist/cjs/contexts/BuilderPreviewContext.js +36 -4
  14. package/dist/cjs/contexts/ShopContext.js +10 -0
  15. package/dist/cjs/graphql/queries/product-value-label.generated.js +11 -0
  16. package/dist/cjs/helpers/background.js +64 -5
  17. package/dist/cjs/helpers/filter-toolbar-preview.js +14 -0
  18. package/dist/cjs/helpers/is-empty-children.js +4 -1
  19. package/dist/cjs/helpers/make-style.js +8 -0
  20. package/dist/cjs/helpers/size.js +54 -0
  21. package/dist/cjs/helpers/typography.js +10 -9
  22. package/dist/cjs/hooks/useInitialSwatchesOptions.js +113 -0
  23. package/dist/cjs/hooks/useProduct.js +10 -3
  24. package/dist/cjs/index.js +10 -0
  25. package/dist/esm/components/ComponentToolbarPreview.js +441 -0
  26. package/dist/esm/components/ComponentWrapper.js +26 -9
  27. package/dist/esm/components/ComponentWrapperPreview.js +38 -5
  28. package/dist/esm/components/Render.liquid.js +8 -0
  29. package/dist/esm/components/RenderCustomCode.js +2 -0
  30. package/dist/esm/components/resize/Resize.js +12 -0
  31. package/dist/esm/components/resize/Spacing.js +128 -0
  32. package/dist/esm/components/src/product/helpers/variant-presets.js +54 -0
  33. package/dist/esm/components/theme-section/CreateThemeSection.js +115 -0
  34. package/dist/esm/components/theme-section/ThemeSectionStatus.js +34 -0
  35. package/dist/esm/components/theme-section/ThemeSectionTooltip.js +100 -0
  36. package/dist/esm/components/toolbar/Tooltip.js +18 -0
  37. package/dist/esm/contexts/BuilderPreviewContext.js +36 -4
  38. package/dist/esm/contexts/ShopContext.js +10 -0
  39. package/dist/esm/graphql/queries/product-value-label.generated.js +9 -0
  40. package/dist/esm/helpers/background.js +64 -6
  41. package/dist/esm/helpers/filter-toolbar-preview.js +9 -0
  42. package/dist/esm/helpers/is-empty-children.js +4 -1
  43. package/dist/esm/helpers/make-style.js +8 -1
  44. package/dist/esm/helpers/size.js +51 -1
  45. package/dist/esm/helpers/typography.js +10 -9
  46. package/dist/esm/hooks/useInitialSwatchesOptions.js +109 -0
  47. package/dist/esm/hooks/useProduct.js +10 -3
  48. package/dist/esm/index.js +5 -3
  49. package/dist/types/index.d.ts +96 -10
  50. package/package.json +2 -2
@@ -0,0 +1,128 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { useRef } from 'react';
3
+ import 'zustand';
4
+ import { useBuilderPreviewStore } from '../../contexts/BuilderPreviewContext.js';
5
+ import 'swr';
6
+ import '@gem-sdk/adapter-shopify';
7
+ import 'swr/mutation';
8
+ import 'vanilla-lazyload';
9
+ import '../../hooks/useCartUI.js';
10
+ import 'react-transition-group';
11
+ import '@gem-sdk/core';
12
+ import '../../helpers/convert.js';
13
+
14
+ function Spacing(props) {
15
+ const isThemeSectionEditor = useBuilderPreviewStore((s)=>s.isThemeSectionEditor);
16
+ const $bottomDrag = useRef(null);
17
+ const $bottomBg = useRef(null);
18
+ const delayMouseMove = useRef(null);
19
+ const isDragging = useRef(false);
20
+ const startY = useRef(0);
21
+ const marginBottom = useRef(0);
22
+ const getNewValueMargin = (event)=>{
23
+ const top = event.clientY;
24
+ const diffY = Math.ceil(top - startY.current);
25
+ const currentValue = marginBottom.current || 0;
26
+ const newValue = currentValue + diffY >= 0 ? `${currentValue + diffY}px` : `0px`;
27
+ return {
28
+ newValue
29
+ };
30
+ };
31
+ const onMouseMoveDocument = (event)=>{
32
+ if ($bottomDrag.current && $bottomBg.current) {
33
+ // $bottomDrag.current.
34
+ const { newValue } = getNewValueMargin(event);
35
+ $bottomBg.current.style.height = newValue;
36
+ $bottomDrag.current.style.top = newValue;
37
+ const $component = $bottomDrag.current.closest('[data-toolbar-wrap]');
38
+ if ($component) {
39
+ $component.style.marginBottom = newValue;
40
+ }
41
+ }
42
+ };
43
+ const onMouseUpDocument = ()=>{
44
+ endDrag();
45
+ };
46
+ const startDrag = ()=>{
47
+ if (delayMouseMove.current) clearTimeout(delayMouseMove.current);
48
+ delayMouseMove.current = setTimeout(()=>{
49
+ isDragging.current = true;
50
+ const event = new CustomEvent('editor:toolbar:resize-spacing', {
51
+ bubbles: true,
52
+ detail: {
53
+ value: true
54
+ }
55
+ });
56
+ window.dispatchEvent(event);
57
+ document.addEventListener('mousemove', onMouseMoveDocument);
58
+ document.addEventListener('mouseup', onMouseUpDocument);
59
+ }, 100);
60
+ };
61
+ const endDrag = ()=>{
62
+ if (delayMouseMove.current) clearTimeout(delayMouseMove.current);
63
+ isDragging.current = false;
64
+ const event = new CustomEvent('editor:toolbar:resize-spacing', {
65
+ bubbles: true,
66
+ detail: {
67
+ value: false
68
+ }
69
+ });
70
+ window.dispatchEvent(event);
71
+ if ($bottomDrag.current) {
72
+ const style = getComputedStyle($bottomDrag.current);
73
+ const marginBottom = style.top;
74
+ const event = new CustomEvent('editor:toolbar:change-margin-bottom', {
75
+ bubbles: true,
76
+ detail: {
77
+ componentUid: props.uid,
78
+ marginBottom
79
+ }
80
+ });
81
+ window.dispatchEvent(event);
82
+ }
83
+ const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
84
+ if ($component) {
85
+ $component.style.marginBottom = '';
86
+ }
87
+ document.removeEventListener('mousemove', onMouseMoveDocument);
88
+ document.removeEventListener('mouseup', onMouseUpDocument);
89
+ };
90
+ const onMouseDown = (event)=>{
91
+ if ($bottomDrag.current) {
92
+ const style = getComputedStyle($bottomDrag.current);
93
+ startY.current = event.clientY;
94
+ marginBottom.current = parseFloat(style.top);
95
+ startDrag();
96
+ }
97
+ };
98
+ const onMouseUp = ()=>{
99
+ endDrag();
100
+ };
101
+ return /*#__PURE__*/ jsx(Fragment, {
102
+ children: props.tag !== 'Section' && /*#__PURE__*/ jsx("div", {
103
+ "data-spacing": true,
104
+ "data-spacing-theme-section": isThemeSectionEditor,
105
+ children: /*#__PURE__*/ jsxs("div", {
106
+ "data-spacing-margin-bottom": true,
107
+ children: [
108
+ /*#__PURE__*/ jsx("div", {
109
+ "data-spacing-margin-bottom-bg": true,
110
+ ref: $bottomBg,
111
+ children: /*#__PURE__*/ jsx("div", {
112
+ "data-spacing-margin-bottom-value": true
113
+ })
114
+ }),
115
+ /*#__PURE__*/ jsx("div", {
116
+ ref: $bottomDrag,
117
+ "data-spacing-margin-bottom-drag": true,
118
+ onMouseDown: onMouseDown,
119
+ onMouseUp: onMouseUp,
120
+ role: "presentation"
121
+ })
122
+ ]
123
+ })
124
+ })
125
+ });
126
+ }
127
+
128
+ export { Spacing as default };
@@ -0,0 +1,54 @@
1
+ const colorPreset = {
2
+ black: '#000000',
3
+ white: '#FFFFFF',
4
+ gray: '#808080',
5
+ red: '#FF0000',
6
+ blue: '#0000FF',
7
+ green: '#008000',
8
+ yellow: '#FFFF00',
9
+ orange: '#FFA500',
10
+ pink: '#FFC0CB',
11
+ purple: '#800080',
12
+ brown: '#A52A2A',
13
+ cyan: '#00FFFF',
14
+ magenta: '#FF00FF',
15
+ teal: '#008080',
16
+ navy: '#000080',
17
+ maroon: '#800000',
18
+ gold: '#FFD700',
19
+ silver: '#C0C0C0',
20
+ beige: '#F5F5DC',
21
+ ivory: '#FFFFF0',
22
+ lavender: '#E6E6FA',
23
+ indigo: '#4B0082',
24
+ coral: '#FF7F50',
25
+ mint: '#98FF98',
26
+ 'sky blue': '#87CEEB',
27
+ salmon: '#FA8072',
28
+ olive: '#808000',
29
+ lilac: '#C8A2C8',
30
+ peach: '#FFDAB9',
31
+ turquoise: '#40E0D0',
32
+ ruby: '#E0115F',
33
+ bronze: '#CD7F32',
34
+ slate: '#708090',
35
+ charcoal: '#36454F',
36
+ sand: '#C2B280',
37
+ mauve: '#E0B0FF',
38
+ tangerine: '#FF4500',
39
+ 'mint green': '#00FF99',
40
+ 'forest green': '#228B22',
41
+ 'ruby red': '#9B111E',
42
+ marigold: '#FFB928',
43
+ eggplant: '#990066',
44
+ 'coral pink': '#F88379',
45
+ mustard: '#FFDB58',
46
+ 'sky gray': '#B0C4DE',
47
+ 'dusty rose': '#FF9BAE',
48
+ 'olive green': '#556B2F',
49
+ coffee: '#6F4E37',
50
+ 'lilac gray': '#C8A2C8',
51
+ 'steel blue': '#4682B4'
52
+ };
53
+
54
+ export { colorPreset };
@@ -0,0 +1,115 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { useRef, useState } from 'react';
3
+ import { ThemeSectionTooltip } from './ThemeSectionTooltip.js';
4
+ import 'zustand';
5
+ import { useShopStore } from '../../contexts/ShopContext.js';
6
+ import '@gem-sdk/adapter-shopify';
7
+ import 'swr';
8
+ import 'swr/mutation';
9
+ import 'vanilla-lazyload';
10
+ import '../../hooks/useCartUI.js';
11
+ import '../../helpers/convert.js';
12
+
13
+ const SHOW_TOOLTIP_TIMEOUT = 600;
14
+ const NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP = 1;
15
+ const LIMIT_PLANS = [
16
+ 'starter',
17
+ 'trial',
18
+ 'trial2022'
19
+ ];
20
+ const CreateThemeSection = ({ ...props })=>{
21
+ const shopPlan = useShopStore((s)=>s.plan);
22
+ const createThemeSectionCount = useShopStore((s)=>s.createThemeSectionCount);
23
+ const isLimit = LIMIT_PLANS.includes(shopPlan ?? '');
24
+ const isRenderTooltip = isLimit || createThemeSectionCount === undefined || createThemeSectionCount < NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP;
25
+ const timeoutRef = useRef();
26
+ const [isShowTooltip, setIsShowTooltip] = useState(false);
27
+ const showTooltip = ()=>{
28
+ if (!isRenderTooltip) return;
29
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
30
+ timeoutRef.current = setTimeout(()=>{
31
+ setIsShowTooltip(true);
32
+ }, SHOW_TOOLTIP_TIMEOUT);
33
+ };
34
+ const hideTooltip = ()=>{
35
+ if (!isRenderTooltip) return;
36
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
37
+ setIsShowTooltip(false);
38
+ };
39
+ const onActions = (e, options)=>{
40
+ e.preventDefault();
41
+ e.stopPropagation();
42
+ if (options?.disabled) return;
43
+ isLimit ? onUpgrade() : onCreate();
44
+ if (timeoutRef.current) clearTimeout(timeoutRef.current);
45
+ setIsShowTooltip(false);
46
+ };
47
+ const onUpgrade = ()=>{
48
+ const eventUpgrade = new CustomEvent('editor:toolbar:upgrade', {
49
+ bubbles: true
50
+ });
51
+ window.dispatchEvent(eventUpgrade);
52
+ };
53
+ const onCreate = ()=>{
54
+ const eventCreate = new CustomEvent('editor:toolbar:create-theme-section', {
55
+ bubbles: true,
56
+ detail: {
57
+ componentUid: props.uid
58
+ }
59
+ });
60
+ window.dispatchEvent(eventCreate);
61
+ };
62
+ return /*#__PURE__*/ jsx(Fragment, {
63
+ children: /*#__PURE__*/ jsxs(ThemeSectionTooltip, {
64
+ isLimit: isLimit,
65
+ isShow: isShowTooltip,
66
+ isRender: isRenderTooltip,
67
+ onActions: onActions,
68
+ onMouseEnter: showTooltip,
69
+ onMouseLeave: hideTooltip,
70
+ children: [
71
+ isRenderTooltip && /*#__PURE__*/ jsx("div", {
72
+ "data-toolbar-create-theme-section": true,
73
+ children: "You can create reusable sections"
74
+ }),
75
+ /*#__PURE__*/ jsx("div", {
76
+ "data-toolbar-active-create-theme-section-wrapper": true,
77
+ children: /*#__PURE__*/ jsxs("div", {
78
+ "data-toolbar-active-create-theme-section": true,
79
+ onClick: (e)=>onActions(e, {
80
+ disabled: isLimit
81
+ }),
82
+ "aria-hidden": "true",
83
+ children: [
84
+ /*#__PURE__*/ jsxs("svg", {
85
+ width: "16",
86
+ height: "16",
87
+ viewBox: "0 0 16 16",
88
+ fill: "none",
89
+ children: [
90
+ /*#__PURE__*/ jsx("path", {
91
+ d: "M1 2C1 1.44772 1.44772 1 2 1H6C6.55228 1 7 1.44772 7 2V6C7 6.55228 6.55228 7 6 7H2C1.44772 7 1 6.55228 1 6V2Z",
92
+ fill: "#F9F9F9"
93
+ }),
94
+ /*#__PURE__*/ jsx("path", {
95
+ d: "M9 10C9 9.44772 9.44772 9 10 9H14C14.5523 9 15 9.44772 15 10V14C15 14.5523 14.5523 15 14 15H10C9.44772 15 9 14.5523 9 14V10Z",
96
+ fill: "#F9F9F9"
97
+ }),
98
+ /*#__PURE__*/ jsx("path", {
99
+ d: "M2 9C1.44772 9 1 9.44772 1 10V14C1 14.5523 1.44772 15 2 15H6C6.55228 15 7 14.5523 7 14V10C7 9.44772 6.55228 9 6 9H2Z",
100
+ fill: "#F9F9F9"
101
+ })
102
+ ]
103
+ }),
104
+ /*#__PURE__*/ jsx("p", {
105
+ children: "Create Theme Section"
106
+ })
107
+ ]
108
+ })
109
+ })
110
+ ]
111
+ })
112
+ });
113
+ };
114
+
115
+ export { CreateThemeSection };
@@ -0,0 +1,34 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+
3
+ const ThemeSectionStatus = ({ ...props })=>{
4
+ const isRenderThemeSectionStatus = props.tag === 'Section' && props?.isThemeSection && props?.needPublishing;
5
+ return /*#__PURE__*/ jsx(Fragment, {
6
+ children: isRenderThemeSectionStatus && /*#__PURE__*/ jsxs("div", {
7
+ "data-theme-section-status": true,
8
+ children: [
9
+ /*#__PURE__*/ jsx("div", {
10
+ "data-theme-section-status-icon": true,
11
+ children: /*#__PURE__*/ jsx("svg", {
12
+ xmlns: "http://www.w3.org/2000/svg",
13
+ width: "16",
14
+ height: "16",
15
+ viewBox: "0 0 16 16",
16
+ fill: "none",
17
+ children: /*#__PURE__*/ jsx("path", {
18
+ fillRule: "evenodd",
19
+ clipRule: "evenodd",
20
+ d: "M15 8C15 11.866 11.866 15 8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8ZM8.4668 4.61597C8.4668 4.89211 8.24294 5.11597 7.9668 5.11597C7.69065 5.11597 7.4668 4.89211 7.4668 4.61597C7.4668 4.33982 7.69065 4.11597 7.9668 4.11597C8.24294 4.11597 8.4668 4.33982 8.4668 4.61597ZM6.91309 5.48633C6.63694 5.48633 6.41309 5.71019 6.41309 5.98633C6.41309 6.26247 6.63694 6.48633 6.91309 6.48633H7.56006V10.3839C7.56006 10.9362 8.00777 11.3839 8.56006 11.3839H9.57144C9.84758 11.3839 10.0714 11.1601 10.0714 10.8839C10.0714 10.6078 9.84758 10.3839 9.57144 10.3839H8.56006V6.48633C8.56006 5.93404 8.11234 5.48633 7.56006 5.48633H6.91309Z",
21
+ fill: "#9144DA"
22
+ })
23
+ })
24
+ }),
25
+ /*#__PURE__*/ jsx("span", {
26
+ "data-theme-section-status-text": true,
27
+ children: "Need to republish. Go to global edit and publish this section"
28
+ })
29
+ ]
30
+ })
31
+ });
32
+ };
33
+
34
+ export { ThemeSectionStatus };
@@ -0,0 +1,100 @@
1
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
+ import { useRef } from 'react';
3
+ import { Transition } from 'react-transition-group';
4
+ import { cls } from '@gem-sdk/core';
5
+
6
+ const TRANSITION_DURATION = 350;
7
+ const defaultStyles = {
8
+ transition: `opacity ${TRANSITION_DURATION}ms ease-out`,
9
+ opacity: 0
10
+ };
11
+ const transitions = {
12
+ entering: {
13
+ opacity: 1
14
+ },
15
+ entered: {
16
+ opacity: 1
17
+ },
18
+ exiting: {
19
+ opacity: 0
20
+ },
21
+ exited: {
22
+ opacity: 0
23
+ },
24
+ unmounted: {
25
+ opacity: 0
26
+ }
27
+ };
28
+ const ThemeSectionTooltip = ({ isShow, isLimit, isRender, children, onMouseEnter, onMouseLeave, onActions })=>{
29
+ const nodeRef = useRef(null);
30
+ const actionBtnLabel = isLimit ? 'Upgrade to create Theme Section' : 'Create Theme Section';
31
+ const openHelpCenter = ()=>{
32
+ const url = 'https://help.gempages.net/articles/theme-section';
33
+ window.open(url, '_blank');
34
+ };
35
+ return /*#__PURE__*/ jsx(Fragment, {
36
+ children: /*#__PURE__*/ jsxs("div", {
37
+ className: "theme-section-tooltip-wrapper",
38
+ onMouseEnter: onMouseEnter,
39
+ onMouseLeave: onMouseLeave,
40
+ children: [
41
+ children,
42
+ isRender && /*#__PURE__*/ jsx(Transition, {
43
+ in: isShow,
44
+ timeout: TRANSITION_DURATION,
45
+ nodeRef: nodeRef,
46
+ unmountOnExit: true,
47
+ children: (state)=>/*#__PURE__*/ jsxs("div", {
48
+ className: "theme-section-tooltip",
49
+ ref: nodeRef,
50
+ style: {
51
+ ...defaultStyles,
52
+ ...transitions[state]
53
+ },
54
+ children: [
55
+ /*#__PURE__*/ jsx("div", {
56
+ className: "theme-section-tooltip__image",
57
+ children: /*#__PURE__*/ jsx("img", {
58
+ src: "https://ucarecdn.com/6a9f408a-aa8c-434a-890b-81067a14aceb/-/format/auto/-/preview/1920x1920/-/quality/lighter/theme-section-illustration.png",
59
+ alt: ""
60
+ })
61
+ }),
62
+ /*#__PURE__*/ jsxs("div", {
63
+ className: "theme-section-tooltip__body",
64
+ children: [
65
+ /*#__PURE__*/ jsx("div", {
66
+ className: "theme-section-tooltip__body-title",
67
+ children: "Create once, use everywhere with Theme Section"
68
+ }),
69
+ /*#__PURE__*/ jsx("div", {
70
+ className: "theme-section-tooltip__body-desc",
71
+ children: "A global section that can be used on all your GemPages & Shopify pages."
72
+ })
73
+ ]
74
+ }),
75
+ /*#__PURE__*/ jsxs("div", {
76
+ className: cls('theme-section-tooltip__action', {
77
+ 'theme-section-tooltip__action-limit': isLimit
78
+ }),
79
+ children: [
80
+ /*#__PURE__*/ jsx("button", {
81
+ onClick: (e)=>onActions(e),
82
+ children: actionBtnLabel
83
+ }),
84
+ isLimit && /*#__PURE__*/ jsx("div", {
85
+ onClick: openHelpCenter,
86
+ "aria-hidden": true,
87
+ className: "theme-section-tooltip__action-learn-more",
88
+ children: "Learn more about Theme Section"
89
+ })
90
+ ]
91
+ })
92
+ ]
93
+ })
94
+ })
95
+ ]
96
+ })
97
+ });
98
+ };
99
+
100
+ export { ThemeSectionTooltip };
@@ -0,0 +1,18 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
+
3
+ function Tooltip({ children, enable, text = 'Tooltip Text', position = 'right', ...props }) {
4
+ return /*#__PURE__*/ jsxs("div", {
5
+ ...props,
6
+ "data-toolbar-tooltip-trigger": true,
7
+ children: [
8
+ children,
9
+ enable && /*#__PURE__*/ jsx("div", {
10
+ "data-toolbar-tooltip": true,
11
+ "data-toolbar-tooltip-position": position,
12
+ children: text
13
+ })
14
+ ]
15
+ });
16
+ }
17
+
18
+ export { Tooltip as default };
@@ -26,9 +26,12 @@ const root = {
26
26
  label: 'Root',
27
27
  childrens: []
28
28
  };
29
- const createBuilderPreviewProvider = (args)=>createStore((set, get)=>({
29
+ const createBuilderPreviewProvider = (args, isThemeSectionEditor)=>createStore((set, get)=>({
30
30
  state: args,
31
31
  loaded: false,
32
+ isThemeSectionEditor: !!isThemeSectionEditor,
33
+ dynamicProduct: null,
34
+ dynamicCollection: null,
32
35
  addItem: (args)=>{
33
36
  const { position, data } = args;
34
37
  const state = get().state;
@@ -388,14 +391,43 @@ const createBuilderPreviewProvider = (args)=>createStore((set, get)=>({
388
391
  ROOT: cloneDeep(ROOT)
389
392
  }
390
393
  });
394
+ },
395
+ getParents: (id, limit)=>{
396
+ const state = get().state;
397
+ const parents = [];
398
+ let index = 0;
399
+ let currentId = id;
400
+ // eslint-disable-next-line no-constant-condition
401
+ while(true){
402
+ if (limit && index >= limit) break;
403
+ const parent = Object.entries(state).find(([, value])=>value.type !== 'section' && value.childrens?.includes(currentId));
404
+ if (!parent) break;
405
+ const [, parentItem] = parent;
406
+ if (!parentItem) break;
407
+ parents.push(parentItem);
408
+ currentId = parentItem.uid;
409
+ index++;
410
+ }
411
+ return parents;
412
+ },
413
+ setDynamicProduct: (data)=>{
414
+ set({
415
+ dynamicProduct: data
416
+ });
417
+ },
418
+ setDynamicCollection: (data)=>{
419
+ set({
420
+ dynamicCollection: data
421
+ });
391
422
  }
392
423
  }));
393
- const BuilderPreviewProvider = ({ children, state, lazy, ...passProps })=>{
424
+ const BuilderPreviewProvider = ({ children, state, isThemeSectionEditor, lazy, ...passProps })=>{
394
425
  const Component = lazy ? Suspense : Fragment;
395
426
  const value = useMemo(()=>{
396
- return createBuilderPreviewProvider(state);
427
+ return createBuilderPreviewProvider(state, isThemeSectionEditor);
397
428
  }, [
398
- state
429
+ state,
430
+ isThemeSectionEditor
399
431
  ]);
400
432
  return /*#__PURE__*/ jsx(Component, {
401
433
  children: /*#__PURE__*/ jsx(BuilderPreviewContext.Provider, {
@@ -35,6 +35,16 @@ const createShopStoreProvider = (data)=>createStore((set)=>({
35
35
  storefrontUrl: url,
36
36
  storefrontToken: token
37
37
  });
38
+ },
39
+ changeCreateThemeSectionCount: (count)=>{
40
+ set({
41
+ createThemeSectionCount: count
42
+ });
43
+ },
44
+ changeShopPlan: (plan)=>{
45
+ set({
46
+ plan
47
+ });
38
48
  }
39
49
  }));
40
50
  const ShopProvider = ({ children, addons, storeOption, queryOption, ...passProps })=>{
@@ -0,0 +1,9 @@
1
+ const ProductOptionNameDocument = `
2
+ query productOptionName($limit: Int, $offset: Int) {
3
+ productOptionName(
4
+ limit: $limit,
5
+ offset: $offset
6
+ )
7
+ }`;
8
+
9
+ export { ProductOptionNameDocument };
@@ -11,7 +11,7 @@ const getStyleBackgroundByDevice = (background, options)=>{
11
11
  ...getStyleBgPosition(background),
12
12
  ...getStyleBgSize(background),
13
13
  ...getStyleBgRepeat(background),
14
- ...getStyleBgAttachment(background)
14
+ ...!options?.ignoreBgAttachment ? getStyleBgAttachment(background) : {}
15
15
  };
16
16
  };
17
17
  const getStyleBgColor = (background)=>{
@@ -36,10 +36,6 @@ const getColor = (color)=>{
36
36
  };
37
37
  const getStyleBgImage = (background, options)=>{
38
38
  const bgImage = {
39
- // desktop:
40
- // background.desktop?.type === 'color' ? 'none' : getBgImageByDevice(background, 'desktop'),
41
- // tablet: background.tablet?.type === 'color' ? 'none' : getBgImageByDevice(background, 'tablet'),
42
- // mobile: background.mobile?.type === 'color' ? 'none' : getBgImageByDevice(background, 'mobile'),
43
39
  desktop: getBgImageByDevice(background, 'desktop', options),
44
40
  tablet: getBgImageByDevice(background, 'tablet', options),
45
41
  mobile: getBgImageByDevice(background, 'mobile', options)
@@ -102,5 +98,67 @@ const getBgAttachmentByDevice = (background, device)=>{
102
98
  const composeBackgroundCss = (backgroundColor)=>{
103
99
  return `${backgroundColor ? `background-color: ${getSingleColorVariable(backgroundColor)} !important;` : undefined}`;
104
100
  };
101
+ const makeFixedBgAttachment = (background)=>{
102
+ if (!background) return;
103
+ background.tablet = background.tablet ? background.tablet : background.desktop;
104
+ background.mobile = background.mobile ? background.mobile : background.tablet;
105
+ const bgAttachment = {
106
+ desktop: getBgAttachmentByDevice(background, 'desktop'),
107
+ tablet: getBgAttachmentByDevice(background, 'tablet'),
108
+ mobile: getBgAttachmentByDevice(background, 'mobile')
109
+ };
110
+ const composeFixed = {
111
+ desktop: {
112
+ ...makeFixedBgAttachmentByDevice('desktop', bgAttachment.desktop)
113
+ },
114
+ tablet: {
115
+ ...makeFixedBgAttachmentByDevice('tablet', bgAttachment.tablet)
116
+ },
117
+ mobile: {
118
+ ...makeFixedBgAttachmentByDevice('mobile', bgAttachment.mobile)
119
+ }
120
+ };
121
+ return {
122
+ wrapper: {
123
+ ...composeFixed.desktop?.wrapper,
124
+ ...composeFixed.tablet?.wrapper,
125
+ ...composeFixed.mobile?.wrapper
126
+ },
127
+ content: {
128
+ ...composeFixed.desktop?.content,
129
+ ...composeFixed.tablet?.content,
130
+ ...composeFixed.mobile?.content
131
+ }
132
+ };
133
+ };
134
+ const makeFixedBgAttachmentByDevice = (device, bgAttachment)=>{
135
+ const subfix = device === 'desktop' ? '' : `-${device}`;
136
+ if (bgAttachment === 'fixed') {
137
+ return {
138
+ wrapper: {
139
+ [`--pos${subfix}`]: 'absolute',
140
+ [`--top${subfix}`]: '0',
141
+ [`--left${subfix}`]: '0',
142
+ [`--w${subfix}`]: '100%',
143
+ [`--h${subfix}`]: '100%'
144
+ },
145
+ content: {
146
+ [`--pos${subfix}`]: 'fixed',
147
+ [`--w${subfix}`]: '100vw',
148
+ [`--h${subfix}`]: '100vh',
149
+ [`--bga${subfix}`]: 'unset'
150
+ }
151
+ };
152
+ }
153
+ return {
154
+ wrapper: {
155
+ [`--pos${subfix}`]: 'absolute'
156
+ },
157
+ content: {
158
+ [`--pos${subfix}`]: 'absolute',
159
+ [`--bga${subfix}`]: bgAttachment
160
+ }
161
+ };
162
+ };
105
163
 
106
- export { composeBackgroundCss, getStyleBackgroundByDevice };
164
+ export { composeBackgroundCss, getStyleBackgroundByDevice, makeFixedBgAttachment };
@@ -0,0 +1,9 @@
1
+ import { Children } from 'react';
2
+ import { ComponentToolbarPreview } from '../components/ComponentToolbarPreview.js';
3
+
4
+ const filterToolbarPreview = (children, keep = false)=>{
5
+ const arrChild = Children.toArray(children);
6
+ return arrChild.filter((child)=>!keep ? child?.type != ComponentToolbarPreview : child?.type == ComponentToolbarPreview);
7
+ };
8
+
9
+ export { filterToolbarPreview as default, filterToolbarPreview };
@@ -1,7 +1,10 @@
1
1
  import { Children } from 'react';
2
+ import { ComponentToolbarPreview } from '../components/ComponentToolbarPreview.js';
2
3
 
3
4
  const isEmptyChildren = (children)=>{
4
- return Children.count(children) < 1 || !children;
5
+ let arrChild = Children.toArray(children);
6
+ arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview);
7
+ return Children.count(arrChild) < 1 || !children;
5
8
  };
6
9
 
7
10
  export { isEmptyChildren as default, isEmptyChildren };
@@ -73,6 +73,13 @@ const makeWidth = (widthValue, fullWidthValue)=>{
73
73
  mobile: getVal('mobile', widthValue, fullWidthValue)
74
74
  };
75
75
  };
76
+ const makeGlobalSizeWidthResponsive = (globalSize)=>{
77
+ return {
78
+ '--w': globalSize?.desktop?.width,
79
+ '--w-tablet': globalSize?.tablet?.width,
80
+ '--w-mobile': globalSize?.mobile?.width
81
+ };
82
+ };
76
83
  const makeHeight = (heighValue, autoHeight)=>{
77
84
  const getVal = (deviceValue, heighValue, autoHeight)=>{
78
85
  const heightVal = heighValue?.[deviceValue];
@@ -125,4 +132,4 @@ const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
125
132
  };
126
133
  };
127
134
 
128
- export { makeAspectRatio, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined };
135
+ export { makeAspectRatio, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined };