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