@gem-sdk/core 1.24.4 → 1.25.0

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 (40) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +443 -0
  2. package/dist/cjs/components/ComponentWrapperPreview.js +37 -4
  3. package/dist/cjs/components/Render.liquid.js +8 -0
  4. package/dist/cjs/components/RenderCustomCode.js +2 -0
  5. package/dist/cjs/components/resize/Resize.js +16 -0
  6. package/dist/cjs/components/resize/Spacing.js +132 -0
  7. package/dist/cjs/components/theme-section/CreateThemeSection.js +117 -0
  8. package/dist/cjs/components/theme-section/ThemeSectionStatus.js +36 -0
  9. package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +102 -0
  10. package/dist/cjs/components/toolbar/Tooltip.js +22 -0
  11. package/dist/cjs/contexts/BuilderPreviewContext.js +36 -4
  12. package/dist/cjs/contexts/ShopContext.js +10 -0
  13. package/dist/cjs/helpers/filter-toolbar-preview.js +14 -0
  14. package/dist/cjs/helpers/is-empty-children.js +4 -1
  15. package/dist/cjs/helpers/make-style.js +8 -0
  16. package/dist/cjs/helpers/size.js +54 -0
  17. package/dist/cjs/helpers/typography.js +10 -9
  18. package/dist/cjs/hooks/useProduct.js +9 -1
  19. package/dist/cjs/index.js +7 -0
  20. package/dist/esm/components/ComponentToolbarPreview.js +441 -0
  21. package/dist/esm/components/ComponentWrapperPreview.js +38 -5
  22. package/dist/esm/components/Render.liquid.js +8 -0
  23. package/dist/esm/components/RenderCustomCode.js +2 -0
  24. package/dist/esm/components/resize/Resize.js +12 -0
  25. package/dist/esm/components/resize/Spacing.js +128 -0
  26. package/dist/esm/components/theme-section/CreateThemeSection.js +115 -0
  27. package/dist/esm/components/theme-section/ThemeSectionStatus.js +34 -0
  28. package/dist/esm/components/theme-section/ThemeSectionTooltip.js +100 -0
  29. package/dist/esm/components/toolbar/Tooltip.js +18 -0
  30. package/dist/esm/contexts/BuilderPreviewContext.js +36 -4
  31. package/dist/esm/contexts/ShopContext.js +10 -0
  32. package/dist/esm/helpers/filter-toolbar-preview.js +9 -0
  33. package/dist/esm/helpers/is-empty-children.js +4 -1
  34. package/dist/esm/helpers/make-style.js +8 -1
  35. package/dist/esm/helpers/size.js +51 -1
  36. package/dist/esm/helpers/typography.js +10 -9
  37. package/dist/esm/hooks/useProduct.js +9 -1
  38. package/dist/esm/index.js +3 -2
  39. package/dist/types/index.d.ts +81 -9
  40. package/package.json +3 -3
@@ -0,0 +1,443 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var react = require('react');
5
+ require('zustand');
6
+ var BuilderPreviewContext = require('../contexts/BuilderPreviewContext.js');
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
+ var CreateThemeSection = require('./theme-section/CreateThemeSection.js');
14
+ var Tooltip = require('./toolbar/Tooltip.js');
15
+ var ThemeSectionStatus = require('./theme-section/ThemeSectionStatus.js');
16
+ var Resize = require('./resize/Resize.js');
17
+ require('../helpers/convert.js');
18
+
19
+ const SECTION_LIMIT = 25;
20
+ const notVisible = (el)=>{
21
+ const overflow = getComputedStyle(el).overflow;
22
+ return overflow !== 'visible';
23
+ };
24
+ const isSection = (el)=>{
25
+ const tag = el.getAttribute('data-component-tag');
26
+ return tag === 'Section';
27
+ };
28
+ const isOverToolbarPosition = (el, parent)=>{
29
+ const rect = el.getBoundingClientRect();
30
+ const rectP = parent.getBoundingClientRect();
31
+ // 32px = toolbar active height
32
+ return rect.top - rectP.top < 32 + 1;
33
+ };
34
+ const findOverflowParent = (element, initEl)=>{
35
+ const thisEl = element;
36
+ const origEl = initEl || thisEl;
37
+ if (!thisEl) return;
38
+ if (isSection(thisEl)) return;
39
+ if (notVisible(thisEl) && isOverToolbarPosition(initEl, thisEl)) return thisEl;
40
+ if (thisEl.parentElement) {
41
+ return findOverflowParent(thisEl.parentElement, origEl);
42
+ } else {
43
+ return;
44
+ }
45
+ };
46
+ const ComponentToolbarPreview = ({ ...props })=>{
47
+ const isThemeSection = props.isThemeSection;
48
+ const editingPageType = ShopContext.useShopStore((s)=>s.pageType);
49
+ const getParents = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getParents);
50
+ const root = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getItem('ROOT'));
51
+ const isThemeSectionEditor = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.isThemeSectionEditor);
52
+ const [activeAddSection, setActiveAddSection] = react.useState(null);
53
+ const [isShowParent, setIsShowParent] = react.useState(false);
54
+ const [isShowParentRevert, setIsShowParentRevert] = react.useState(false);
55
+ const [parents, setParents] = react.useState([]);
56
+ // Get parents
57
+ const onActiveComponent = react.useCallback((e)=>{
58
+ const detail = e.detail;
59
+ if (detail?.componentUid == props.uid) {
60
+ const currentParents = getParents(props.uid).filter((parent)=>{
61
+ if (parent.uid === 'ROOT') return false;
62
+ if (parent.tag === 'Section') return false;
63
+ if (parent.editorConfigs?.toolbar?.hide) return false;
64
+ if (parent.editorConfigs?.component?.noSetting) return false;
65
+ return true;
66
+ }).slice(0, 3);
67
+ setParents(currentParents);
68
+ } else {
69
+ setParents([]);
70
+ setIsShowParent(false);
71
+ }
72
+ }, [
73
+ setParents,
74
+ getParents,
75
+ props.uid
76
+ ]);
77
+ react.useEffect(()=>{
78
+ window.addEventListener('editor:active-component', onActiveComponent);
79
+ return ()=>{
80
+ window.removeEventListener('editor:active-component', onActiveComponent);
81
+ };
82
+ }, [
83
+ onActiveComponent
84
+ ]);
85
+ // End get parents
86
+ if (props.type === 'section') {
87
+ return null;
88
+ }
89
+ if (props.editorConfigs?.toolbar?.hide) {
90
+ return null;
91
+ }
92
+ const getSectionNumber = ()=>{
93
+ return root?.childrens?.length || 0;
94
+ };
95
+ const getIndexSection = ()=>{
96
+ if (props.tag !== 'Section') {
97
+ return -1;
98
+ }
99
+ if (root?.childrens?.length) {
100
+ return root.childrens.findIndex((sectionUid)=>sectionUid == props.uid);
101
+ }
102
+ return -1;
103
+ };
104
+ const onShowParent = (e)=>{
105
+ if (!parents.length) return;
106
+ const $target = (e?.target) || null;
107
+ const $toolbar = $target.closest('[data-toolbar-active]');
108
+ if (!$target || !$toolbar) return;
109
+ if (isShowParent) {
110
+ setIsShowParentRevert(false);
111
+ setIsShowParent(false);
112
+ } else {
113
+ const $parentOverflow = findOverflowParent($toolbar, $toolbar);
114
+ if ($parentOverflow) {
115
+ setIsShowParentRevert(true);
116
+ } else {
117
+ const rect = $toolbar.getBoundingClientRect();
118
+ if (rect.top < parents.length * 24) {
119
+ setIsShowParentRevert(true);
120
+ } else {
121
+ setIsShowParentRevert(false);
122
+ }
123
+ }
124
+ setIsShowParent(true);
125
+ }
126
+ const event = new CustomEvent('editor:toolbar:show-parents', {
127
+ bubbles: true,
128
+ detail: {
129
+ value: !isShowParent
130
+ }
131
+ });
132
+ window.dispatchEvent(event);
133
+ };
134
+ const onDelete = (e)=>{
135
+ e.preventDefault();
136
+ e.stopPropagation();
137
+ const event = new CustomEvent('editor:toolbar:delete-component', {
138
+ bubbles: true,
139
+ detail: {
140
+ componentUid: props.uid,
141
+ isThemeSection: isThemeSection
142
+ }
143
+ });
144
+ window.dispatchEvent(event);
145
+ return false;
146
+ };
147
+ const onDuplicate = (e)=>{
148
+ e.preventDefault();
149
+ e.stopPropagation();
150
+ if (getSectionNumber() >= SECTION_LIMIT && props.tag == 'Section') {
151
+ return false;
152
+ }
153
+ const event = new CustomEvent('editor:toolbar:duplicate-component', {
154
+ bubbles: true,
155
+ detail: {
156
+ componentUid: props.uid,
157
+ isThemeSection: isThemeSection
158
+ }
159
+ });
160
+ window.dispatchEvent(event);
161
+ return false;
162
+ };
163
+ const onZoomOut = (e)=>{
164
+ e.preventDefault();
165
+ e.stopPropagation();
166
+ const event = new CustomEvent('editor:toolbar:zoom-out-component', {
167
+ bubbles: true,
168
+ detail: {
169
+ componentUid: props.uid
170
+ }
171
+ });
172
+ window.dispatchEvent(event);
173
+ return false;
174
+ };
175
+ const closeAddSection = ()=>{
176
+ setActiveAddSection(null);
177
+ window.removeEventListener('editor:close-add-section-popup', closeAddSection);
178
+ };
179
+ const onAddSection = (e, position)=>{
180
+ e.preventDefault();
181
+ e.stopPropagation();
182
+ if (getSectionNumber() >= SECTION_LIMIT) {
183
+ return false;
184
+ }
185
+ const $target = e.target;
186
+ if ($target) {
187
+ setActiveAddSection(position);
188
+ const rect = $target.getBoundingClientRect();
189
+ const event = new CustomEvent('editor:toolbar:add-section', {
190
+ bubbles: true,
191
+ detail: {
192
+ componentUid: props.uid,
193
+ position,
194
+ top: rect.top + rect.height / 2
195
+ }
196
+ });
197
+ window.dispatchEvent(event);
198
+ window.addEventListener('editor:close-add-section-popup', closeAddSection);
199
+ }
200
+ return false;
201
+ };
202
+ return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
203
+ children: [
204
+ !(props.tag == 'Section' && isThemeSectionEditor) && /*#__PURE__*/ jsxRuntime.jsxs("div", {
205
+ "data-toolbar": true,
206
+ "data-toolbar-section": props.tag == 'Section',
207
+ "data-toolbar-theme-section": props.tag == 'Section' && !!isThemeSection || isThemeSectionEditor,
208
+ "data-toolbar-limit": getIndexSection() >= SECTION_LIMIT,
209
+ children: [
210
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
211
+ "data-toolbar-show-parent": true,
212
+ onClick: (e)=>onShowParent(e),
213
+ "aria-hidden": "true",
214
+ children: [
215
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
216
+ "data-toolbar-icon-drag": true,
217
+ children: /*#__PURE__*/ jsxRuntime.jsxs("svg", {
218
+ width: "16",
219
+ height: "16",
220
+ viewBox: "0 0 16 16",
221
+ fill: "none",
222
+ children: [
223
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
224
+ d: "M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",
225
+ fill: "currentColor"
226
+ }),
227
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
228
+ d: "M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",
229
+ fill: "currentColor"
230
+ }),
231
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
232
+ d: "M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",
233
+ fill: "currentColor"
234
+ }),
235
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
236
+ d: "M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",
237
+ fill: "currentColor"
238
+ }),
239
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
240
+ d: "M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",
241
+ fill: "currentColor"
242
+ }),
243
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
244
+ d: "M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",
245
+ fill: "currentColor"
246
+ })
247
+ ]
248
+ })
249
+ }),
250
+ props.tag == 'Section' ? /*#__PURE__*/ jsxRuntime.jsx("div", {
251
+ "data-toolbar-name": true,
252
+ children: isThemeSection ? props.name : `Section ${getIndexSection() + 1}${getSectionNumber() >= SECTION_LIMIT - 5 ? `/${SECTION_LIMIT}` : ''}`
253
+ }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
254
+ "data-toolbar-name": true,
255
+ children: props.customLabel || props.label
256
+ }),
257
+ props.tag !== 'Section' && parents.length > 0 && /*#__PURE__*/ jsxRuntime.jsx("div", {
258
+ "data-toolbar-icon-parent": true,
259
+ "data-toolbar-icon-parent-open": isShowParent,
260
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
261
+ width: "16",
262
+ height: "16",
263
+ viewBox: "0 0 16 16",
264
+ fill: "none",
265
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
266
+ d: "M5.65522 10C5.07265 10 4.7809 9.22865 5.19284 8.77753L7.53762 6.20974C7.79298 5.93009 8.20702 5.93009 8.46238 6.20974L10.8072 8.77754C11.2191 9.22866 10.9274 10 10.3448 10H5.65522Z",
267
+ fill: "currentColor"
268
+ })
269
+ })
270
+ })
271
+ ]
272
+ }),
273
+ isShowParent && parents.map((parent, index)=>/*#__PURE__*/ jsxRuntime.jsxs("div", {
274
+ "data-toolbar-parent": true,
275
+ "data-parent-uid": parent.uid,
276
+ "data-toolbar-theme-section": isThemeSectionEditor,
277
+ style: {
278
+ top: !isShowParentRevert ? `${-24 * (index + 1) + index}px` : `${31 + 24 * index - index}px`
279
+ },
280
+ children: [
281
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
282
+ "data-toolbar-icon-drag": true,
283
+ children: /*#__PURE__*/ jsxRuntime.jsxs("svg", {
284
+ width: "16",
285
+ height: "16",
286
+ viewBox: "0 0 16 16",
287
+ fill: "none",
288
+ children: [
289
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
290
+ d: "M5.5 4.5C6.32843 4.5 7 3.82843 7 3C7 2.17157 6.32843 1.5 5.5 1.5C4.67157 1.5 4 2.17157 4 3C4 3.82843 4.67157 4.5 5.5 4.5Z",
291
+ fill: "currentColor"
292
+ }),
293
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
294
+ d: "M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z",
295
+ fill: "currentColor"
296
+ }),
297
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
298
+ d: "M7 13C7 13.8284 6.32843 14.5 5.5 14.5C4.67157 14.5 4 13.8284 4 13C4 12.1716 4.67157 11.5 5.5 11.5C6.32843 11.5 7 12.1716 7 13Z",
299
+ fill: "currentColor"
300
+ }),
301
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
302
+ d: "M10.5 4.5C11.3284 4.5 12 3.82843 12 3C12 2.17157 11.3284 1.5 10.5 1.5C9.67157 1.5 9 2.17157 9 3C9 3.82843 9.67157 4.5 10.5 4.5Z",
303
+ fill: "currentColor"
304
+ }),
305
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
306
+ d: "M12 8C12 8.82843 11.3284 9.5 10.5 9.5C9.67157 9.5 9 8.82843 9 8C9 7.17157 9.67157 6.5 10.5 6.5C11.3284 6.5 12 7.17157 12 8Z",
307
+ fill: "currentColor"
308
+ }),
309
+ /*#__PURE__*/ jsxRuntime.jsx("path", {
310
+ d: "M10.5 14.5C11.3284 14.5 12 13.8284 12 13C12 12.1716 11.3284 11.5 10.5 11.5C9.67157 11.5 9 12.1716 9 13C9 13.8284 9.67157 14.5 10.5 14.5Z",
311
+ fill: "currentColor"
312
+ })
313
+ ]
314
+ })
315
+ }),
316
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
317
+ "data-toolbar-name": true,
318
+ children: parent.label
319
+ })
320
+ ]
321
+ }, parent.uid)),
322
+ props.tag === 'Section' && !props.isThemeSection && editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
323
+ ...props
324
+ }),
325
+ props.tag == 'Sticky' && /*#__PURE__*/ jsxRuntime.jsx("div", {
326
+ "data-toolbar-zoom-out": true,
327
+ onClick: (e)=>onZoomOut(e),
328
+ "aria-hidden": "true",
329
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
330
+ width: "16",
331
+ height: "16",
332
+ viewBox: "0 0 16 16",
333
+ fill: "none",
334
+ xmlns: "http://www.w3.org/2000/svg",
335
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
336
+ fillRule: "evenodd",
337
+ clipRule: "evenodd",
338
+ d: "M14.5 7C14.7761 7 15 6.77614 15 6.5C15 6.22386 14.7761 6 14.5 6L10.7072 6L14.8536 1.85355C15.0489 1.65829 15.0489 1.34171 14.8536 1.14645C14.6584 0.951186 14.3418 0.951185 14.1465 1.14645L10 5.29297L10 1.5C10 1.22386 9.77614 1 9.5 1C9.22386 1 9 1.22386 9 1.5L9 6.5C9 6.77614 9.22386 7 9.5 7L14.5 7ZM6 10.7073L6 14.5C6 14.7761 6.22386 15 6.5 15C6.77614 15 7 14.7761 7 14.5L7 9.5C7 9.22386 6.77614 9 6.5 9H1.5C1.22386 9 1 9.22386 1 9.5C1 9.77614 1.22386 10 1.5 10H5.29306L1.14662 14.1464C0.951353 14.3417 0.951353 14.6583 1.14662 14.8536C1.34188 15.0488 1.65846 15.0488 1.85372 14.8536L6 10.7073Z",
339
+ fill: "currentColor"
340
+ })
341
+ })
342
+ }),
343
+ /*#__PURE__*/ jsxRuntime.jsx(Tooltip.default, {
344
+ enable: props.tag == 'Section' && getSectionNumber() >= SECTION_LIMIT,
345
+ text: "Page has reached Shopify’s 25 section-limit",
346
+ position: "bottom",
347
+ "data-toolbar-duplicate": true,
348
+ "data-toolbar-disable": props.tag == 'Section' && getSectionNumber() >= SECTION_LIMIT,
349
+ onClick: (e)=>onDuplicate(e),
350
+ "aria-hidden": "true",
351
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
352
+ width: "16",
353
+ height: "16",
354
+ viewBox: "0 0 16 16",
355
+ fill: "none",
356
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
357
+ fillRule: "evenodd",
358
+ clipRule: "evenodd",
359
+ d: "M6.08423 1.21289C5.53194 1.21289 5.08423 1.66061 5.08423 2.21289V3.78711H4.26172C3.43329 3.78711 2.76172 4.45868 2.76172 5.28711V13.2871C2.76172 14.1155 3.43329 14.7871 4.26172 14.7871H10.2617C11.0901 14.7871 11.7617 14.1155 11.7617 13.2871V12.4629H13.0842C13.6365 12.4629 14.0842 12.0152 14.0842 11.4629V2.21289C14.0842 1.66061 13.6365 1.21289 13.0842 1.21289H6.08423ZM10.7617 12.4629H6.08423C5.53194 12.4629 5.08423 12.0152 5.08423 11.4629V4.78711H4.26172C3.98558 4.78711 3.76172 5.01097 3.76172 5.28711V13.2871C3.76172 13.5633 3.98558 13.7871 4.26172 13.7871H10.2617C10.5379 13.7871 10.7617 13.5633 10.7617 13.2871V12.4629Z",
360
+ fill: "currentColor"
361
+ })
362
+ })
363
+ }),
364
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
365
+ "data-toolbar-delete": true,
366
+ onClick: (e)=>onDelete(e),
367
+ "aria-hidden": "true",
368
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
369
+ width: "16",
370
+ height: "16",
371
+ viewBox: "0 0 16 16",
372
+ fill: "none",
373
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
374
+ fillRule: "evenodd",
375
+ clipRule: "evenodd",
376
+ d: "M11 2.88965V2.38965C11 1.56122 10.3284 0.889648 9.5 0.889648H6.5C5.67157 0.889648 5 1.56122 5 2.38965V2.88965H2C1.72386 2.88965 1.5 3.11351 1.5 3.38965C1.5 3.66579 1.72386 3.88965 2 3.88965H3.21997V13.1099C3.21997 14.2144 4.1154 15.1099 5.21997 15.1099H11.22C12.3245 15.1099 13.22 14.2144 13.22 13.1099V3.88965H14C14.2761 3.88965 14.5 3.66579 14.5 3.38965C14.5 3.11351 14.2761 2.88965 14 2.88965H11ZM6 2.88965H10V2.38965C10 2.11351 9.77614 1.88965 9.5 1.88965H6.5C6.22386 1.88965 6 2.11351 6 2.38965V2.88965ZM6.24976 6.13965C6.66397 6.13965 6.99976 6.47543 6.99976 6.88965V11.3896C6.99976 11.8039 6.66397 12.1396 6.24976 12.1396C5.83554 12.1396 5.49976 11.8039 5.49976 11.3896V6.88965C5.49976 6.47543 5.83554 6.13965 6.24976 6.13965ZM10.4998 6.88965C10.4998 6.47543 10.164 6.13965 9.74976 6.13965C9.33554 6.13965 8.99976 6.47543 8.99976 6.88965V11.3896C8.99976 11.8039 9.33554 12.1396 9.74976 12.1396C10.164 12.1396 10.4998 11.8039 10.4998 11.3896V6.88965Z",
377
+ fill: "currentColor"
378
+ })
379
+ })
380
+ })
381
+ ]
382
+ }),
383
+ editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(ThemeSectionStatus.ThemeSectionStatus, {
384
+ ...props
385
+ }),
386
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
387
+ "data-outline": true,
388
+ "data-outline-section": props.tag == 'Section',
389
+ "data-outline-theme-section": props.tag == 'Section' && !!isThemeSection || isThemeSectionEditor,
390
+ "data-outline-limit": getIndexSection() >= SECTION_LIMIT
391
+ }),
392
+ props.tag == 'Section' && !isThemeSectionEditor && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
393
+ children: [
394
+ /*#__PURE__*/ jsxRuntime.jsx(Tooltip.default, {
395
+ enable: getSectionNumber() >= SECTION_LIMIT,
396
+ text: "Page has reached Shopify’s 25 section-limit",
397
+ position: "top",
398
+ "data-toolbar-add-top": true,
399
+ "data-toolbar-disable": getSectionNumber() >= SECTION_LIMIT,
400
+ "data-toolbar-add-open": activeAddSection == 'above',
401
+ onClick: (e)=>onAddSection(e, 'above'),
402
+ "aria-hidden": "true",
403
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
404
+ width: "16",
405
+ height: "16",
406
+ viewBox: "0 0 16 16",
407
+ fill: "none",
408
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
409
+ d: "M8.5 1.5C8.5 1.22386 8.27614 1 8 1C7.72386 1 7.5 1.22386 7.5 1.5V7.5H1.5C1.22386 7.5 1 7.72386 1 8C1 8.27614 1.22386 8.5 1.5 8.5H7.5V14.5C7.5 14.7761 7.72386 15 8 15C8.27614 15 8.5 14.7761 8.5 14.5V8.5H14.5C14.7761 8.5 15 8.27614 15 8C15 7.72386 14.7761 7.5 14.5 7.5H8.5V1.5Z",
410
+ fill: "currentColor"
411
+ })
412
+ })
413
+ }),
414
+ /*#__PURE__*/ jsxRuntime.jsx(Tooltip.default, {
415
+ enable: getSectionNumber() >= SECTION_LIMIT,
416
+ text: "Page has reached Shopify’s 25 section-limit",
417
+ position: "top",
418
+ "data-toolbar-add-bottom": true,
419
+ "data-toolbar-disable": getSectionNumber() >= SECTION_LIMIT,
420
+ "data-toolbar-add-open": activeAddSection == 'below',
421
+ onClick: (e)=>onAddSection(e, 'below'),
422
+ "aria-hidden": "true",
423
+ children: /*#__PURE__*/ jsxRuntime.jsx("svg", {
424
+ width: "16",
425
+ height: "16",
426
+ viewBox: "0 0 16 16",
427
+ fill: "none",
428
+ children: /*#__PURE__*/ jsxRuntime.jsx("path", {
429
+ d: "M8.5 1.5C8.5 1.22386 8.27614 1 8 1C7.72386 1 7.5 1.22386 7.5 1.5V7.5H1.5C1.22386 7.5 1 7.72386 1 8C1 8.27614 1.22386 8.5 1.5 8.5H7.5V14.5C7.5 14.7761 7.72386 15 8 15C8.27614 15 8.5 14.7761 8.5 14.5V8.5H14.5C14.7761 8.5 15 8.27614 15 8C15 7.72386 14.7761 7.5 14.5 7.5H8.5V1.5Z",
430
+ fill: "currentColor"
431
+ })
432
+ })
433
+ })
434
+ ]
435
+ }),
436
+ /*#__PURE__*/ jsxRuntime.jsx(Resize.default, {
437
+ ...props
438
+ })
439
+ ]
440
+ });
441
+ };
442
+
443
+ exports.ComponentToolbarPreview = ComponentToolbarPreview;
@@ -7,12 +7,27 @@ var react = require('react');
7
7
  var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
8
8
  var constant = require('./constant.js');
9
9
  var RenderCustomCode = require('./RenderCustomCode.js');
10
+ var ComponentToolbarPreview = require('./ComponentToolbarPreview.js');
10
11
 
11
12
  const ComponentWrapperPreview = ({ children, ...props })=>{
13
+ react.useEffect(()=>{
14
+ const event = new CustomEvent('editor:component:render', {
15
+ bubbles: true,
16
+ detail: {
17
+ componentUid: props.uid
18
+ }
19
+ });
20
+ window.dispatchEvent(event);
21
+ }, [
22
+ props.uid
23
+ ]);
12
24
  if (props.type === 'section') {
13
25
  return null;
14
26
  }
15
27
  const customProps = {};
28
+ if (props.tag === 'Section' && props.isThemeSection) {
29
+ customProps['data-theme-section'] = true;
30
+ }
16
31
  // Build editor configs
17
32
  if (props.editorConfigs) {
18
33
  const editorConfigs = props.editorConfigs;
@@ -43,6 +58,13 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
43
58
  if (editorConfigs.slots?.children) {
44
59
  customProps['data-slots-children'] = true;
45
60
  }
61
+ if (!editorConfigs.toolbar?.hide) {
62
+ customProps['data-toolbar-wrap'] = true;
63
+ }
64
+ }
65
+ // Show toolbar wrapper
66
+ if (!props?.editorConfigs?.toolbar?.hide) {
67
+ customProps['data-toolbar-wrap'] = true;
46
68
  }
47
69
  const style = composeAdvanceStyle.composeAdvanceStyle(props.advanced, props.tag);
48
70
  const advanced = props.advanced;
@@ -60,12 +82,18 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
60
82
  uid: props.uid,
61
83
  advanced: advanced
62
84
  }),
63
- /*#__PURE__*/ jsxRuntime.jsx(children.type, {
85
+ /*#__PURE__*/ jsxRuntime.jsxs(children.type, {
64
86
  className: advanced?.cssClass,
65
87
  ...children.props,
66
88
  style,
67
89
  builderAttrs,
68
- advanced
90
+ advanced,
91
+ children: [
92
+ children.props['children'],
93
+ /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview, {
94
+ ...props
95
+ })
96
+ ]
69
97
  })
70
98
  ]
71
99
  });
@@ -77,11 +105,16 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
77
105
  uid: props.uid,
78
106
  advanced: advanced
79
107
  }),
80
- /*#__PURE__*/ jsxRuntime.jsx("div", {
108
+ /*#__PURE__*/ jsxRuntime.jsxs("div", {
81
109
  style: style,
82
110
  className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
83
111
  ...builderAttrs,
84
- children: children
112
+ children: [
113
+ children,
114
+ /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview, {
115
+ ...props
116
+ })
117
+ ]
85
118
  })
86
119
  ]
87
120
  });
@@ -3,7 +3,15 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('react');
6
+ require('react/jsx-runtime');
7
+ require('zustand');
6
8
  require('swr');
9
+ require('@gem-sdk/adapter-shopify');
10
+ require('swr/mutation');
11
+ require('vanilla-lazyload');
12
+ require('../hooks/useCartUI.js');
13
+ require('react-transition-group');
14
+ require('@gem-sdk/core');
7
15
  var render = require('../helpers/render.js');
8
16
  require('../helpers/convert.js');
9
17
  var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
@@ -13,6 +13,8 @@ require('swr/mutation');
13
13
  var shop = require('../hooks/shop.js');
14
14
  require('vanilla-lazyload');
15
15
  require('../hooks/useCartUI.js');
16
+ require('react-transition-group');
17
+ require('@gem-sdk/core');
16
18
  require('../helpers/convert.js');
17
19
 
18
20
  const RenderCustomCode = ({ uid, advanced })=>{
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var Spacing = require('./Spacing.js');
7
+
8
+ function Resize(props) {
9
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
10
+ children: /*#__PURE__*/ jsxRuntime.jsx(Spacing.default, {
11
+ ...props
12
+ })
13
+ });
14
+ }
15
+
16
+ exports.default = Resize;