@gem-sdk/core 1.23.0-moon.60 → 1.23.0-moon.75

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.
@@ -160,13 +160,6 @@ const ComponentToolbarPreview = ({ ...props })=>{
160
160
  window.dispatchEvent(event);
161
161
  return false;
162
162
  };
163
- const toolbarName = ()=>{
164
- const name = props.customLabel || props.label;
165
- if (name?.toLowerCase() === 'item list' || name?.toLowerCase() === 'icon list') {
166
- return 'Advanced list';
167
- }
168
- return name;
169
- };
170
163
  const onZoomOut = (e)=>{
171
164
  e.preventDefault();
172
165
  e.stopPropagation();
@@ -259,7 +252,7 @@ const ComponentToolbarPreview = ({ ...props })=>{
259
252
  children: isThemeSection ? props.name : `Section ${getIndexSection() + 1}${getSectionNumber() >= SECTION_LIMIT - 5 ? `/${SECTION_LIMIT}` : ''}`
260
253
  }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
261
254
  "data-toolbar-name": true,
262
- children: toolbarName()
255
+ children: props.customLabel || props.label
263
256
  }),
264
257
  props.tag !== 'Section' && parents.length > 0 && /*#__PURE__*/ jsxRuntime.jsx("div", {
265
258
  "data-toolbar-icon-parent": true,
@@ -20,6 +20,7 @@ const ComponentWrapper = ({ children, ...props })=>{
20
20
  advanced: advanced
21
21
  }),
22
22
  /*#__PURE__*/ jsxRuntime.jsx(children.type, {
23
+ className: advanced?.cssClass,
23
24
  ...children.props,
24
25
  style,
25
26
  advanced
@@ -35,7 +36,7 @@ const ComponentWrapper = ({ children, ...props })=>{
35
36
  }),
36
37
  /*#__PURE__*/ jsxRuntime.jsx("div", {
37
38
  style: style,
38
- className: `${props.uid}`,
39
+ className: `${props.uid} ${advanced?.cssClass}`,
39
40
  children: children
40
41
  })
41
42
  ]
@@ -106,16 +106,11 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
106
106
  advanced: advanced
107
107
  }),
108
108
  /*#__PURE__*/ jsxRuntime.jsxs("div", {
109
- style: !props.editorConfigs?.component?.excludeApplyStyle ? style : {},
109
+ style: style,
110
110
  className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
111
111
  ...builderAttrs,
112
112
  children: [
113
- !props.editorConfigs?.component?.validate && children,
114
- /*#__PURE__*/ react.isValidElement(children) && props.editorConfigs?.component?.validate && /*#__PURE__*/ jsxRuntime.jsx(children.type, {
115
- ...children.props,
116
- style,
117
- advanced
118
- }),
113
+ children,
119
114
  /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview, {
120
115
  ...props
121
116
  })
@@ -24,9 +24,6 @@ const componentTexts = [
24
24
  'Text',
25
25
  'Heading'
26
26
  ];
27
- const componentIconList = [
28
- 'IconListV2'
29
- ];
30
27
  const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageContext, ...passProps })=>{
31
28
  const item = builder[uid];
32
29
  const Component = components[item?.tag];
@@ -107,7 +104,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
107
104
  });
108
105
  });
109
106
  } else {
110
- liquid = render.template`<div style="${!componentIconList.includes(item.tag) ? style : ''}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
107
+ liquid = render.template`<div style="${style}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
111
108
  ${render.RenderIf(item?.childrens?.length, ()=>{
112
109
  return Component({
113
110
  builderProps: {
@@ -156,7 +153,6 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
156
153
  },
157
154
  pageContext,
158
155
  isText: componentTexts.includes(item.tag) ? true : null,
159
- style: componentIconList.includes(item.tag) ? style : null,
160
156
  ...passProps
161
157
  });
162
158
  })}
@@ -3,19 +3,13 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
- var Column = require('./Column.js');
7
6
  var Spacing = require('./Spacing.js');
8
7
 
9
8
  function Resize(props) {
10
- return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
11
- children: [
12
- /*#__PURE__*/ jsxRuntime.jsx(Spacing.default, {
13
- ...props
14
- }),
15
- /*#__PURE__*/ jsxRuntime.jsx(Column.default, {
16
- ...props
17
- })
18
- ]
9
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
10
+ children: /*#__PURE__*/ jsxRuntime.jsx(Spacing.default, {
11
+ ...props
12
+ })
19
13
  });
20
14
  }
21
15
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  var makeStyle = require('./make-style.js');
4
4
  var constant = require('./constant.js');
5
+ var getResonsiveValue = require('./get-resonsive-value.js');
5
6
 
6
7
  function getCustomSizeCSSByDevice(size, device) {
7
8
  if (!size || !device) return {};
@@ -50,21 +51,100 @@ const makeStyleWithDefault = (name, value, defaultVal)=>{
50
51
  };
51
52
  const getWidthHeightGlobalSize = (type, globalSize)=>{
52
53
  if (!globalSize) return {};
53
- const data = {
54
- desktop: globalSize?.desktop?.[type],
55
- tablet: globalSize?.tablet?.[type],
56
- mobile: globalSize?.mobile?.[type]
57
- };
58
- if (data.desktop === undefined) {
59
- data.desktop = 'auto';
60
- }
61
- if (data.tablet === undefined) {
62
- data.tablet = data.desktop;
63
- }
64
- if (data.mobile === undefined) {
65
- data.mobile = data.tablet;
66
- }
67
- return data;
54
+ let result = {};
55
+ const DEVICES = [
56
+ 'desktop',
57
+ 'mobile',
58
+ 'tablet'
59
+ ];
60
+ DEVICES.forEach((device)=>{
61
+ result = {
62
+ ...result,
63
+ [device]: getResonsiveValue.getResponsiveValueByScreen(globalSize, device)?.[type]
64
+ };
65
+ });
66
+ return result;
67
+ };
68
+ const getHeightByShapeGlobalSize = (shapeByLayout)=>{
69
+ let result = {};
70
+ const DEVICES = [
71
+ 'desktop',
72
+ 'mobile',
73
+ 'tablet'
74
+ ];
75
+ DEVICES.forEach((device)=>{
76
+ const shapeByDevice = getResonsiveValue.getResponsiveValueByScreen(shapeByLayout, device);
77
+ const shapeValue = shapeByDevice?.shapeValue;
78
+ const height = shapeByDevice?.height;
79
+ result = {
80
+ ...result,
81
+ [device]: shapeValue ? 'auto' : height || 'auto'
82
+ };
83
+ });
84
+ return result;
85
+ };
86
+ const getWidthByShapeGlobalSize = (shapeByLayout)=>{
87
+ let result = {};
88
+ const DEVICES = [
89
+ 'desktop',
90
+ 'mobile',
91
+ 'tablet'
92
+ ];
93
+ DEVICES.forEach((device)=>{
94
+ const shapeByDevice = getResonsiveValue.getResponsiveValueByScreen(shapeByLayout, device);
95
+ const width = shapeByDevice?.width;
96
+ result = {
97
+ ...result,
98
+ [device]: width || 'auto'
99
+ };
100
+ });
101
+ return result;
102
+ };
103
+ const getAspectRatioGlobalSize = (shape)=>{
104
+ let result = {};
105
+ const DEVICES = [
106
+ 'desktop',
107
+ 'mobile',
108
+ 'tablet'
109
+ ];
110
+ DEVICES.forEach((device)=>{
111
+ const shapeValue = getResonsiveValue.getResponsiveValueByScreen(shape, device)?.shapeValue;
112
+ if (shapeValue) {
113
+ result = {
114
+ ...result,
115
+ [device]: shapeValue
116
+ };
117
+ } else {
118
+ const shapeConfig = getResonsiveValue.getResponsiveValueByScreen(shape, device)?.shape;
119
+ switch(shapeConfig){
120
+ case 'square':
121
+ result = {
122
+ ...result,
123
+ [device]: '1/1'
124
+ };
125
+ break;
126
+ case 'vertical':
127
+ result = {
128
+ ...result,
129
+ [device]: '3/4'
130
+ };
131
+ break;
132
+ case 'horizontal':
133
+ result = {
134
+ ...result,
135
+ [device]: '4/3'
136
+ };
137
+ break;
138
+ case 'original':
139
+ result = {
140
+ ...result,
141
+ [device]: 'auto'
142
+ };
143
+ break;
144
+ }
145
+ }
146
+ });
147
+ return result;
68
148
  };
69
149
  function getCustomPaddingSizeCSSByDevice(globalSize, device) {
70
150
  if (!globalSize || !device) return {};
@@ -83,7 +163,10 @@ const getPaddingGlobalSize = (globalSize)=>{
83
163
  exports.composeSize = composeSize;
84
164
  exports.composeSizeCss = composeSizeCss;
85
165
  exports.genSizeClass = genSizeClass;
166
+ exports.getAspectRatioGlobalSize = getAspectRatioGlobalSize;
167
+ exports.getHeightByShapeGlobalSize = getHeightByShapeGlobalSize;
86
168
  exports.getPaddingGlobalSize = getPaddingGlobalSize;
169
+ exports.getWidthByShapeGlobalSize = getWidthByShapeGlobalSize;
87
170
  exports.getWidthHeightGlobalSize = getWidthHeightGlobalSize;
88
171
  exports.makeGlobalSize = makeGlobalSize;
89
172
  exports.makeStyleWithDefault = makeStyleWithDefault;
package/dist/cjs/index.js CHANGED
@@ -221,7 +221,10 @@ exports.isLocalEnv = convert.isLocalEnv;
221
221
  exports.composeSize = size.composeSize;
222
222
  exports.composeSizeCss = size.composeSizeCss;
223
223
  exports.genSizeClass = size.genSizeClass;
224
+ exports.getAspectRatioGlobalSize = size.getAspectRatioGlobalSize;
225
+ exports.getHeightByShapeGlobalSize = size.getHeightByShapeGlobalSize;
224
226
  exports.getPaddingGlobalSize = size.getPaddingGlobalSize;
227
+ exports.getWidthByShapeGlobalSize = size.getWidthByShapeGlobalSize;
225
228
  exports.getWidthHeightGlobalSize = size.getWidthHeightGlobalSize;
226
229
  exports.makeGlobalSize = size.makeGlobalSize;
227
230
  exports.makeStyleWithDefault = size.makeStyleWithDefault;
@@ -158,13 +158,6 @@ const ComponentToolbarPreview = ({ ...props })=>{
158
158
  window.dispatchEvent(event);
159
159
  return false;
160
160
  };
161
- const toolbarName = ()=>{
162
- const name = props.customLabel || props.label;
163
- if (name?.toLowerCase() === 'item list' || name?.toLowerCase() === 'icon list') {
164
- return 'Advanced list';
165
- }
166
- return name;
167
- };
168
161
  const onZoomOut = (e)=>{
169
162
  e.preventDefault();
170
163
  e.stopPropagation();
@@ -257,7 +250,7 @@ const ComponentToolbarPreview = ({ ...props })=>{
257
250
  children: isThemeSection ? props.name : `Section ${getIndexSection() + 1}${getSectionNumber() >= SECTION_LIMIT - 5 ? `/${SECTION_LIMIT}` : ''}`
258
251
  }) : /*#__PURE__*/ jsx("div", {
259
252
  "data-toolbar-name": true,
260
- children: toolbarName()
253
+ children: props.customLabel || props.label
261
254
  }),
262
255
  props.tag !== 'Section' && parents.length > 0 && /*#__PURE__*/ jsx("div", {
263
256
  "data-toolbar-icon-parent": true,
@@ -16,6 +16,7 @@ const ComponentWrapper = ({ children, ...props })=>{
16
16
  advanced: advanced
17
17
  }),
18
18
  /*#__PURE__*/ jsx(children.type, {
19
+ className: advanced?.cssClass,
19
20
  ...children.props,
20
21
  style,
21
22
  advanced
@@ -31,7 +32,7 @@ const ComponentWrapper = ({ children, ...props })=>{
31
32
  }),
32
33
  /*#__PURE__*/ jsx("div", {
33
34
  style: style,
34
- className: `${props.uid}`,
35
+ className: `${props.uid} ${advanced?.cssClass}`,
35
36
  children: children
36
37
  })
37
38
  ]
@@ -102,16 +102,11 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
102
102
  advanced: advanced
103
103
  }),
104
104
  /*#__PURE__*/ jsxs("div", {
105
- style: !props.editorConfigs?.component?.excludeApplyStyle ? style : {},
105
+ style: style,
106
106
  className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
107
107
  ...builderAttrs,
108
108
  children: [
109
- !props.editorConfigs?.component?.validate && children,
110
- /*#__PURE__*/ isValidElement(children) && props.editorConfigs?.component?.validate && /*#__PURE__*/ jsx(children.type, {
111
- ...children.props,
112
- style,
113
- advanced
114
- }),
109
+ children,
115
110
  /*#__PURE__*/ jsx(ComponentToolbarPreview, {
116
111
  ...props
117
112
  })
@@ -20,9 +20,6 @@ const componentTexts = [
20
20
  'Text',
21
21
  'Heading'
22
22
  ];
23
- const componentIconList = [
24
- 'IconListV2'
25
- ];
26
23
  const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageContext, ...passProps })=>{
27
24
  const item = builder[uid];
28
25
  const Component = components[item?.tag];
@@ -103,7 +100,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
103
100
  });
104
101
  });
105
102
  } else {
106
- liquid = template`<div style="${!componentIconList.includes(item.tag) ? style : ''}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
103
+ liquid = template`<div style="${style}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
107
104
  ${RenderIf(item?.childrens?.length, ()=>{
108
105
  return Component({
109
106
  builderProps: {
@@ -152,7 +149,6 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
152
149
  },
153
150
  pageContext,
154
151
  isText: componentTexts.includes(item.tag) ? true : null,
155
- style: componentIconList.includes(item.tag) ? style : null,
156
152
  ...passProps
157
153
  });
158
154
  })}
@@ -1,17 +1,11 @@
1
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import Column from './Column.js';
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
3
2
  import Spacing from './Spacing.js';
4
3
 
5
4
  function Resize(props) {
6
- return /*#__PURE__*/ jsxs(Fragment, {
7
- children: [
8
- /*#__PURE__*/ jsx(Spacing, {
9
- ...props
10
- }),
11
- /*#__PURE__*/ jsx(Column, {
12
- ...props
13
- })
14
- ]
5
+ return /*#__PURE__*/ jsx(Fragment, {
6
+ children: /*#__PURE__*/ jsx(Spacing, {
7
+ ...props
8
+ })
15
9
  });
16
10
  }
17
11
 
@@ -1,5 +1,6 @@
1
1
  import { makeStyleResponsive } from './make-style.js';
2
2
  import { devicesMapping } from './constant.js';
3
+ import { getResponsiveValueByScreen } from './get-resonsive-value.js';
3
4
 
4
5
  function getCustomSizeCSSByDevice(size, device) {
5
6
  if (!size || !device) return {};
@@ -48,21 +49,100 @@ const makeStyleWithDefault = (name, value, defaultVal)=>{
48
49
  };
49
50
  const getWidthHeightGlobalSize = (type, globalSize)=>{
50
51
  if (!globalSize) return {};
51
- const data = {
52
- desktop: globalSize?.desktop?.[type],
53
- tablet: globalSize?.tablet?.[type],
54
- mobile: globalSize?.mobile?.[type]
55
- };
56
- if (data.desktop === undefined) {
57
- data.desktop = 'auto';
58
- }
59
- if (data.tablet === undefined) {
60
- data.tablet = data.desktop;
61
- }
62
- if (data.mobile === undefined) {
63
- data.mobile = data.tablet;
64
- }
65
- return data;
52
+ let result = {};
53
+ const DEVICES = [
54
+ 'desktop',
55
+ 'mobile',
56
+ 'tablet'
57
+ ];
58
+ DEVICES.forEach((device)=>{
59
+ result = {
60
+ ...result,
61
+ [device]: getResponsiveValueByScreen(globalSize, device)?.[type]
62
+ };
63
+ });
64
+ return result;
65
+ };
66
+ const getHeightByShapeGlobalSize = (shapeByLayout)=>{
67
+ let result = {};
68
+ const DEVICES = [
69
+ 'desktop',
70
+ 'mobile',
71
+ 'tablet'
72
+ ];
73
+ DEVICES.forEach((device)=>{
74
+ const shapeByDevice = getResponsiveValueByScreen(shapeByLayout, device);
75
+ const shapeValue = shapeByDevice?.shapeValue;
76
+ const height = shapeByDevice?.height;
77
+ result = {
78
+ ...result,
79
+ [device]: shapeValue ? 'auto' : height || 'auto'
80
+ };
81
+ });
82
+ return result;
83
+ };
84
+ const getWidthByShapeGlobalSize = (shapeByLayout)=>{
85
+ let result = {};
86
+ const DEVICES = [
87
+ 'desktop',
88
+ 'mobile',
89
+ 'tablet'
90
+ ];
91
+ DEVICES.forEach((device)=>{
92
+ const shapeByDevice = getResponsiveValueByScreen(shapeByLayout, device);
93
+ const width = shapeByDevice?.width;
94
+ result = {
95
+ ...result,
96
+ [device]: width || 'auto'
97
+ };
98
+ });
99
+ return result;
100
+ };
101
+ const getAspectRatioGlobalSize = (shape)=>{
102
+ let result = {};
103
+ const DEVICES = [
104
+ 'desktop',
105
+ 'mobile',
106
+ 'tablet'
107
+ ];
108
+ DEVICES.forEach((device)=>{
109
+ const shapeValue = getResponsiveValueByScreen(shape, device)?.shapeValue;
110
+ if (shapeValue) {
111
+ result = {
112
+ ...result,
113
+ [device]: shapeValue
114
+ };
115
+ } else {
116
+ const shapeConfig = getResponsiveValueByScreen(shape, device)?.shape;
117
+ switch(shapeConfig){
118
+ case 'square':
119
+ result = {
120
+ ...result,
121
+ [device]: '1/1'
122
+ };
123
+ break;
124
+ case 'vertical':
125
+ result = {
126
+ ...result,
127
+ [device]: '3/4'
128
+ };
129
+ break;
130
+ case 'horizontal':
131
+ result = {
132
+ ...result,
133
+ [device]: '4/3'
134
+ };
135
+ break;
136
+ case 'original':
137
+ result = {
138
+ ...result,
139
+ [device]: 'auto'
140
+ };
141
+ break;
142
+ }
143
+ }
144
+ });
145
+ return result;
66
146
  };
67
147
  function getCustomPaddingSizeCSSByDevice(globalSize, device) {
68
148
  if (!globalSize || !device) return {};
@@ -78,4 +158,4 @@ const getPaddingGlobalSize = (globalSize)=>{
78
158
  return Object.assign({}, getCustomPaddingSizeCSSByDevice(globalSize, 'desktop'), getCustomPaddingSizeCSSByDevice(globalSize, 'tablet'), getCustomPaddingSizeCSSByDevice(globalSize, 'mobile'));
79
159
  };
80
160
 
81
- export { composeSize, composeSizeCss, genSizeClass, getPaddingGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeStyleWithDefault };
161
+ export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getHeightByShapeGlobalSize, getPaddingGlobalSize, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeStyleWithDefault };
package/dist/esm/index.js CHANGED
@@ -53,7 +53,7 @@ import * as tiktokpixel from './helpers/tracking/tiktokpixel.js';
53
53
  export { tiktokpixel };
54
54
  export { RenderIf, composeMemo, dataStringify, props, styles, template } from './helpers/render.js';
55
55
  export { baseAssetURL, isLocalEnv } from './helpers/convert.js';
56
- export { composeSize, composeSizeCss, genSizeClass, getPaddingGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeStyleWithDefault } from './helpers/size.js';
56
+ export { composeSize, composeSizeCss, genSizeClass, getAspectRatioGlobalSize, getHeightByShapeGlobalSize, getPaddingGlobalSize, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, makeGlobalSize, makeStyleWithDefault } from './helpers/size.js';
57
57
  export { composeShadowCss, getStyleShadow, getStyleShadowState, parseValueWithUnit } from './helpers/shadow.js';
58
58
  export { composeBackgroundCss, getStyleBackgroundByDevice, makeFixedBgAttachment } from './helpers/background.js';
59
59
  export { generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey } from './helpers/query.js';
@@ -92,7 +92,9 @@ type ImageShape$1 = {
92
92
  height?: string;
93
93
  };
94
94
  type SizeSettingGlobal = {
95
- shape?: 'square' | 'vertical' | 'horizontal' | 'custom';
95
+ shape?: 'square' | 'vertical' | 'horizontal' | 'custom' | 'original';
96
+ shapeLinked?: boolean;
97
+ shapeValue?: string;
96
98
  padding?: {
97
99
  type?: 'small' | 'medium' | 'large' | 'custom';
98
100
  top?: string;
@@ -914,7 +916,7 @@ type GridArrange<T> = SharedControlType<T> & {
914
916
  };
915
917
 
916
918
  type SettingID = 'shape' | 'width' | 'height' | 'gap' | 'padding';
917
- type OptionKeyword = 'default' | 'auto' | 'full' | 'equal' | 'small' | 'medium' | 'large';
919
+ type OptionKeyword = 'default' | 'auto' | 'full' | 'equal' | 'small' | 'medium' | 'large' | 'original';
918
920
  type PaddingOptions = 'small' | 'medium' | 'large' | 'custom';
919
921
  type PaddingConfig = Partial<Record<PaddingOptions, {
920
922
  vertical: string;
@@ -931,15 +933,9 @@ type SizeSetting$1<T> = SharedControlType<T> & {
931
933
  readonly?: boolean;
932
934
  hiddenSettings?: SettingID[];
933
935
  settingConfig?: Partial<Record<SettingID, SettingConfig>>;
934
- hiddenShowMore?: boolean;
935
- };
936
-
937
- type ChildIconType<T> = SharedControlType<T> & {
938
- type: 'child-icon';
939
- [key: string]: any;
940
936
  };
941
937
 
942
- type ControlProp<T> = AngleControlType<T> | CheckboxControlType<T> | ColorPickerControlType<T> | GroupControlType<T> | IconControlType<T> | InputFixContentControlType<T> | InputNumberControlType<T> | InputUnitControlType<T> | InputUnitSpacingControlType<T> | InputUnitWidthControlType<T> | InputControlType<T> | MarginControlType<T> | PaddingControlType<T> | PositionControlType<T> | RadioGroupControlType | RangeControlType<T> | SegmentControlType<T> | SelectControlType<T> | TextareaControlType<T> | ToggleControlType<T> | ImageControlType<T> | ChildrensControlType | GridControlType<T> | FlexControlType<T> | TextEditorControlType<T> | ProductControlType<T> | TypographyControlType<T> | TypographyV2ControlType<T> | MenuControlType<T> | BehaviorStateControlType<T> | PickLinkControlType<T> | BoxShadowControlType<T> | TextShadowControlType<T> | BorderControlType<T> | BorderRadiusControlType<T> | RadiusPresetControlType<T> | SizeControlType<T> | ChildItemType<T> | PickMultiProductControlType<T> | CollectionControlType<T> | BackgroundControlType<T> | VisibilityControlType<T> | SelectVariantControlType | CountdownEvergreenType | Timezone<T> | CustomContentControlType<T> | DateTimePickerControlType | CountdownDailyType | KlaviyoCodes | YotpoLoyaltyCodes | InputWidthControlType<T> | LayoutSegmentControlType<T> | InputSpacing<T> | UniqueIdControlType<T> | PositionSquareControlType<T> | CustomCodeEditor | LayoutControlType<T> | SwatchesLinkControlType<T> | VariantSwatchesPresetControlType<T> | ProductListControlType<T> | CollectionBannerControlType<T> | Ratio<T> | StickyDisplayControlType<T> | SyncProductPropertiesControlType<T> | StepsGuide<T> | ImageShape<T> | GridArrange<T> | SizeSetting$1<T> | ChildIconType<T>;
938
+ type ControlProp<T> = AngleControlType<T> | CheckboxControlType<T> | ColorPickerControlType<T> | GroupControlType<T> | IconControlType<T> | InputFixContentControlType<T> | InputNumberControlType<T> | InputUnitControlType<T> | InputUnitSpacingControlType<T> | InputUnitWidthControlType<T> | InputControlType<T> | MarginControlType<T> | PaddingControlType<T> | PositionControlType<T> | RadioGroupControlType | RangeControlType<T> | SegmentControlType<T> | SelectControlType<T> | TextareaControlType<T> | ToggleControlType<T> | ImageControlType<T> | ChildrensControlType | GridControlType<T> | FlexControlType<T> | TextEditorControlType<T> | ProductControlType<T> | TypographyControlType<T> | TypographyV2ControlType<T> | MenuControlType<T> | BehaviorStateControlType<T> | PickLinkControlType<T> | BoxShadowControlType<T> | TextShadowControlType<T> | BorderControlType<T> | BorderRadiusControlType<T> | RadiusPresetControlType<T> | SizeControlType<T> | ChildItemType<T> | PickMultiProductControlType<T> | CollectionControlType<T> | BackgroundControlType<T> | VisibilityControlType<T> | SelectVariantControlType | CountdownEvergreenType | Timezone<T> | CustomContentControlType<T> | DateTimePickerControlType | CountdownDailyType | KlaviyoCodes | YotpoLoyaltyCodes | InputWidthControlType<T> | LayoutSegmentControlType<T> | InputSpacing<T> | UniqueIdControlType<T> | PositionSquareControlType<T> | CustomCodeEditor | LayoutControlType<T> | SwatchesLinkControlType<T> | VariantSwatchesPresetControlType<T> | ProductListControlType<T> | CollectionBannerControlType<T> | Ratio<T> | StickyDisplayControlType<T> | SyncProductPropertiesControlType<T> | StepsGuide<T> | ImageShape<T> | GridArrange<T> | SizeSetting$1<T>;
943
939
  type Setting<P extends BaseProps> = {
944
940
  id: 'setting';
945
941
  note?: string;
@@ -967,8 +963,6 @@ type ComponentSetting<P extends BaseProps> = {
967
963
  noWrap?: boolean;
968
964
  editorConfigs?: {
969
965
  component?: {
970
- validate?: boolean;
971
- excludeApplyStyle?: boolean;
972
966
  noDelete?: boolean;
973
967
  noDuplicate?: boolean;
974
968
  noDragDrop?: boolean;
@@ -9548,6 +9542,9 @@ declare const makeGlobalSize: (globalSize?: ObjectDevices<SizeSettingGlobal>) =>
9548
9542
  };
9549
9543
  declare const makeStyleWithDefault: <T extends ShortHandProperty, K>(name: T, value?: Partial<Record<NameDevices, K>> | undefined, defaultVal?: Partial<Record<NameDevices, K>> | undefined) => Record<ResponsiveKey<T>, K>;
9550
9544
  declare const getWidthHeightGlobalSize: (type: 'width' | 'height', globalSize?: ObjectDevices<SizeSettingGlobal>) => Partial<Record<NameDevices, string | number>>;
9545
+ declare const getHeightByShapeGlobalSize: (shapeByLayout?: ObjectDevices<SizeSettingGlobal>) => Partial<Record<NameDevices, string>>;
9546
+ declare const getWidthByShapeGlobalSize: (shapeByLayout?: ObjectDevices<SizeSettingGlobal>) => Partial<Record<NameDevices, string>>;
9547
+ declare const getAspectRatioGlobalSize: (shape?: ObjectDevices<SizeSettingGlobal>) => ObjectDevices<string>;
9551
9548
  declare const getPaddingGlobalSize: (globalSize?: ObjectDevices<SizeSettingGlobal>) => React.CSSProperties;
9552
9549
 
9553
9550
  declare const parseValueWithUnit: (valueWithUnit: string) => any;
@@ -9850,4 +9847,4 @@ type PublishedThemePageSelectFragment = Pick<PublishedThemePage, 'id' | 'name' |
9850
9847
 
9851
9848
  declare const getProductBySlug: (fetcher: FetchFunc, slug?: string) => Promise<ProductSelectFragment>;
9852
9849
 
9853
- export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, BoldSubscriptionsWidgetType, Border, BorderStyle, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, CollectionSelectFragment, CollectionsDocument, CollectionsQueryResponse, CollectionsQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentPreset, ComponentSetting, ContainerProp, ControlProp, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, DynamicCollection, DynamicProduct, ExtractState, FeraReviewsWidgetType, FetchCollectionArgs, FetchFunc, FetchProductParams, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, ImageShape$1 as ImageShape, InitComponentType, InstantJudgeMeReviewsWidgetType, InstantKlaviyoWidgetType, InstantLooxReviewsWidgetType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LaiProductReviewsWidgetType, LooxReviewsWidgetType, ModalProvider, ModalProviderProps, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, ObjectLayoutValue, OmnisendWidgetType, OptionNormalStyle, OptionSpecialStyle, PageContext, PageProvider, PageProviderProps, PageType, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PickyStoryWidgetType, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductReviewsWidgetType, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, Ratio$1 as Ratio, RenderMemo as Render, RenderChildren, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RivyoWidgetType, RoundedSize, RyviuWidgetType, SectionData, SectionEntity, SectionProvider, SectionProviderProps, ShadowProps, ShadowStyle, ShadowStyleApplied, ShadowType, ShopProvider, ShopProviderProps, shop as ShopType, SizeProps, SizeSetting, SizeSettingGlobal, SizeType, SpacingType, StampedWidgetType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TrustooWidgetType, TypographyProps, TypographySetting, TypographySettingV2, TypographyType, TypographyV2Attrs, TypographyV2Props, VariantSelectFragment, VitalsWidgetType, WiserWidgetType, WrapRenderChildren, baseAssetURL, calculateFirstProduct, checkAvailableVariantInStock, cls, composeAdvanceStyle, composeBackgroundCss, composeBorderCss, composeCornerCss, composeGridLayout, composeMemo, composeRadius, composeRadiusResponsive, composeShadowCss, composeSize, composeSizeCss, composeSpacing, composeTextColorCss, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, convertOldLayout, dataStringify, fetchMedias, fetchVariants, filterToolbarPreview, flattenConnection, fpixel, genSizeClass, genTypoClass, genVariable, generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey, getBorderStyle, getCollection, getCornerCSSFromGlobal, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateClassDynamicBtn, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveClassDynamicBtn, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getPaddingGlobalSize, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, getWidthHeightGlobalSize, globalEvent, gridToArrayRegex, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, handleConvertClassColorDynamicBtn, isBrowser, isColor, isColumnDirectionExist, isDefined, isEmptyChildren, isLocalEnv, isSafari, loadScript, makeAspectRatio, makeFixedBgAttachment, makeGlobalSize, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeStyleWithDefault, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, parseValueWithUnit, prefetchQueries, props, removeNullUndefined, splitStyle, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckAvailableVariantInStock, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useCollectionsQuery, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useInitialSwatchesOptions, useIsSampleProduct, useIsStorefrontProduct, useIsSyncProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useModalStore, useMoney, useMoneyFormat, usePageStore, usePageType, usePluginEnable, usePrevious, useProduct, useProductList, useProductListProducts, useProductListSettings, useProductListStore, useProductListStyles, useProductProperties, useProductQuery, useProductStore, useProductsQuery, useQuantity, useRemoveCartItem, useSection, useSectionStore, useSelectedOption, useShopStore, useStoreFront, useSuspenseFetch, useSwatches, useSwatchesOptions, useUniqProductID, useUpdateCartItem, useVariant, useVariantOutStock, useVariants, validateEmail };
9850
+ export { AddOn, AddonProvider, AddonProviderProps, AlignItemProp, AlignProp, Background, BaseProps, BasePropsWrap, BlockEntity, BoldSubscriptionsWidgetType, Border, BorderStyle, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, CollectionSelectFragment, CollectionsDocument, CollectionsQueryResponse, CollectionsQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentPreset, ComponentSetting, ContainerProp, ControlProp, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, DynamicCollection, DynamicProduct, ExtractState, FeraReviewsWidgetType, FetchCollectionArgs, FetchFunc, FetchProductParams, FlexDirectionProp, FontName, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, HSLAColorType, HSLColorType, HexColorType, ImageShape$1 as ImageShape, InitComponentType, InstantJudgeMeReviewsWidgetType, InstantKlaviyoWidgetType, InstantLooxReviewsWidgetType, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LaiProductReviewsWidgetType, LooxReviewsWidgetType, ModalProvider, ModalProviderProps, NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, ObjectLayoutValue, OmnisendWidgetType, OptionNormalStyle, OptionSpecialStyle, PageContext, PageProvider, PageProviderProps, PageType, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PickyStoryWidgetType, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductProvider, ProductProviderProps, ProductReviewsWidgetType, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, Ratio$1 as Ratio, RenderMemo as Render, RenderChildren, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveStateProp, RivyoWidgetType, RoundedSize, RyviuWidgetType, SectionData, SectionEntity, SectionProvider, SectionProviderProps, ShadowProps, ShadowStyle, ShadowStyleApplied, ShadowType, ShopProvider, ShopProviderProps, shop as ShopType, SizeProps, SizeSetting, SizeSettingGlobal, SizeType, SpacingType, StampedWidgetType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, TransformProp, TrustooWidgetType, TypographyProps, TypographySetting, TypographySettingV2, TypographyType, TypographyV2Attrs, TypographyV2Props, VariantSelectFragment, VitalsWidgetType, WiserWidgetType, WrapRenderChildren, baseAssetURL, calculateFirstProduct, checkAvailableVariantInStock, cls, composeAdvanceStyle, composeBackgroundCss, composeBorderCss, composeCornerCss, composeGridLayout, composeMemo, composeRadius, composeRadiusResponsive, composeShadowCss, composeSize, composeSizeCss, composeSpacing, composeTextColorCss, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, convertOldLayout, dataStringify, fetchMedias, fetchVariants, filterToolbarPreview, flattenConnection, fpixel, genSizeClass, genTypoClass, genVariable, generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey, getAspectRatioGlobalSize, getBorderStyle, getCollection, getCornerCSSFromGlobal, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateClassDynamicBtn, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveClassDynamicBtn, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getHeightByShapeGlobalSize, getPaddingGlobalSize, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleShadow, getStyleShadowState, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, globalEvent, gridToArrayRegex, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, handleConvertClassColorDynamicBtn, isBrowser, isColor, isColumnDirectionExist, isDefined, isEmptyChildren, isLocalEnv, isSafari, loadScript, makeAspectRatio, makeFixedBgAttachment, makeGlobalSize, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeStyleWithDefault, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, parseValueWithUnit, prefetchQueries, props, removeNullUndefined, splitStyle, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckAvailableVariantInStock, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useCollectionsQuery, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useInitialSwatchesOptions, useIsSampleProduct, useIsStorefrontProduct, useIsSyncProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useModalStore, useMoney, useMoneyFormat, usePageStore, usePageType, usePluginEnable, usePrevious, useProduct, useProductList, useProductListProducts, useProductListSettings, useProductListStore, useProductListStyles, useProductProperties, useProductQuery, useProductStore, useProductsQuery, useQuantity, useRemoveCartItem, useSection, useSectionStore, useSelectedOption, useShopStore, useStoreFront, useSuspenseFetch, useSwatches, useSwatchesOptions, useUniqProductID, useUpdateCartItem, useVariant, useVariantOutStock, useVariants, validateEmail };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.23.0-moon.60",
3
+ "version": "1.23.0-moon.75",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -24,8 +24,8 @@
24
24
  "type-check": "yarn tsc --noEmit"
25
25
  },
26
26
  "devDependencies": {
27
- "@gem-sdk/adapter-shopify": "1.23.0-moon.58",
28
- "@gem-sdk/styles": "1.23.0-moon.60"
27
+ "@gem-sdk/adapter-shopify": "1.23.0-moon.75",
28
+ "@gem-sdk/styles": "1.23.0-moon.75"
29
29
  },
30
30
  "dependencies": {
31
31
  "react-error-boundary": "4.0.10",
@@ -1,280 +0,0 @@
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
- var cls = require('../../helpers/cls.js');
15
- require('react-transition-group');
16
- require('@gem-sdk/core');
17
- require('../../helpers/convert.js');
18
-
19
- function Column(props) {
20
- const WIDTH_HAND = 16;
21
- const isThemeSectionEditor = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.isThemeSectionEditor);
22
- const [visualLayout, setVisualLayout] = react.useState(props.settings?.layout);
23
- const [currentLayout, setCurrentLayout] = react.useState(props.settings?.layout);
24
- const verticalGutter = props.styles?.verticalGutter;
25
- const dataDrag = react.useRef();
26
- const [isDragging, setIsDragging] = react.useState(false);
27
- const newValueCols = react.useRef([]);
28
- // Watch props change layout
29
- react.useEffect(()=>{
30
- setVisualLayout(props.settings?.layout);
31
- setCurrentLayout(props.settings?.layout);
32
- }, [
33
- props
34
- ]);
35
- // Validate resize column
36
- if (![
37
- 'Row',
38
- 'Product',
39
- 'HeroBanner'
40
- ].includes(props.tag)) return;
41
- const getTotalCol = (cols, i)=>{
42
- const cloneToIndex = cols.slice().splice(0, i + 1);
43
- return cloneToIndex.reduce((accumulator, currentValue)=>{
44
- return accumulator + currentValue;
45
- }, 0);
46
- };
47
- const getPositionLeft = ({ totalCol, len, gap, index })=>{
48
- const width = totalCol / 12;
49
- return `calc(100%*${width} - ${gap}*${0.5 - width} + ${gap}*${(12 / len * (index + 1) - totalCol) / (12 / len)} - ${WIDTH_HAND / 2}px)`;
50
- };
51
- const endDrag = ()=>{
52
- setIsDragging(false);
53
- document.body.style.cursor = '';
54
- if (!dataDrag.current) return;
55
- // Emit change value
56
- const device = dataDrag.current.device;
57
- const cols = currentLayout?.[device]?.cols || [];
58
- if (JSON.stringify(newValueCols.current) !== JSON.stringify(cols) && newValueCols.current.length) {
59
- window.dispatchEvent(new CustomEvent('editor:toolbar:change-column', {
60
- bubbles: true,
61
- detail: {
62
- componentUid: dataDrag.current.componentUid,
63
- cols: newValueCols.current
64
- }
65
- }));
66
- }
67
- window.dispatchEvent(new CustomEvent('editor:toolbar:resize-column', {
68
- bubbles: true,
69
- detail: {
70
- value: false
71
- }
72
- }));
73
- // Remove style inline
74
- setChangeVisualNewColumns(false, []);
75
- dataDrag.current = undefined;
76
- document.removeEventListener('mousemove', onMouseMoveDocument);
77
- document.removeEventListener('mouseup', onMouseUpDocument);
78
- };
79
- const setChangeVisualNewColumns = (value, newCols)=>{
80
- if (!dataDrag.current) return;
81
- const $components = document.querySelectorAll(`[data-uid="${dataDrag.current.componentUid}"]`);
82
- if ($components.length) {
83
- $components.forEach(($component)=>{
84
- let $row = $component;
85
- const tagRow = $row.getAttribute('data-component-tag');
86
- if (tagRow !== 'Row') {
87
- const $firstCol = $component.querySelector('[data-component-tag="Col"]');
88
- if ($firstCol && $firstCol.parentElement) {
89
- $row = $firstCol.parentElement;
90
- }
91
- }
92
- if ($row) {
93
- if (value) {
94
- $row.style.gridTemplateColumns = newCols.map((col)=>`minmax(0, ${col}fr)`).join(' ');
95
- } else {
96
- $row.style.gridTemplateColumns = '';
97
- }
98
- }
99
- });
100
- }
101
- };
102
- const onMouseMoveDocument = (event)=>{
103
- if (!dataDrag.current) return;
104
- const currentX = event.clientX;
105
- const diffX = currentX - (dataDrag.current.startX ?? 0);
106
- const diffXAbs = Math.abs(diffX);
107
- const index = dataDrag.current.index;
108
- const device = dataDrag.current.device ?? 'desktop';
109
- const itemWidth = dataDrag.current.itemWidth ?? 0;
110
- const cols = currentLayout?.[device]?.cols || [];
111
- const newCols = cols.slice();
112
- // Change value
113
- if (diffXAbs >= itemWidth) {
114
- const times = Math.round(diffXAbs / itemWidth);
115
- const action = diffX >= 0 ? 'plus' : 'minus';
116
- if (action == 'minus') {
117
- const currentCol = newCols[index] ?? 1;
118
- if (currentCol - times > 1) {
119
- newCols[index] = (newCols[index] ?? 0) - times;
120
- newCols[index + 1] = (newCols[index + 1] ?? 0) + times;
121
- } else {
122
- newCols[index + 1] = (newCols[index + 1] ?? 0) + (newCols[index] ?? 0) - 1;
123
- newCols[index] = 1;
124
- }
125
- } else {
126
- const nextCol = newCols[index + 1] ?? 1;
127
- if (nextCol - times > 1) {
128
- newCols[index + 1] = (newCols[index + 1] ?? 0) - times;
129
- newCols[index] = (newCols[index] ?? 0) + times;
130
- } else {
131
- newCols[index] = (newCols[index] ?? 0) + (newCols[index + 1] ?? 0) - 1;
132
- newCols[index + 1] = 1;
133
- }
134
- }
135
- }
136
- // Cancel when value not change
137
- if (JSON.stringify(newValueCols.current) === JSON.stringify(newCols)) {
138
- return;
139
- }
140
- // Update new value to ui
141
- if (JSON.stringify(newValueCols.current) !== JSON.stringify(newCols)) {
142
- newValueCols.current = newCols; // cache new value
143
- setVisualLayout({
144
- ...currentLayout,
145
- [device]: {
146
- ...currentLayout?.[device],
147
- cols: newCols
148
- }
149
- });
150
- setChangeVisualNewColumns(true, newCols);
151
- }
152
- };
153
- const onMouseUpDocument = ()=>{
154
- endDrag();
155
- };
156
- const onMouseDown = (event, { device, totalCol, index })=>{
157
- const target = event.target;
158
- if (target) {
159
- const $component = target.closest('[data-uid]');
160
- if ($component) {
161
- document.removeEventListener('mousemove', onMouseMoveDocument);
162
- document.removeEventListener('mouseup', onMouseUpDocument);
163
- document.addEventListener('mousemove', onMouseMoveDocument);
164
- document.addEventListener('mouseup', onMouseUpDocument);
165
- setIsDragging(true);
166
- const componentUid = $component.getAttribute('data-uid') || undefined;
167
- const handRect = target.getBoundingClientRect();
168
- const componentRect = $component.getBoundingClientRect();
169
- dataDrag.current = {
170
- componentUid,
171
- device,
172
- index,
173
- startX: event.clientX,
174
- itemWidth: (handRect.left - componentRect.left) / totalCol
175
- };
176
- document.body.style.cursor = 'grab';
177
- window.dispatchEvent(new CustomEvent('editor:toolbar:resize-column', {
178
- bubbles: true,
179
- detail: {
180
- value: true
181
- }
182
- }));
183
- }
184
- }
185
- };
186
- const onMouseUp = ()=>{
187
- endDrag();
188
- };
189
- const isActive = (device, index)=>{
190
- return dataDrag.current?.componentUid == props.uid && dataDrag.current.device == device && dataDrag.current.index == index;
191
- };
192
- const HandDragItems = ()=>{
193
- const items = [];
194
- const devices = [
195
- 'desktop',
196
- 'tablet',
197
- 'mobile'
198
- ];
199
- for (const device of devices){
200
- if (visualLayout?.[device]) {
201
- const cols = visualLayout?.[device]?.cols || visualLayout?.desktop?.cols || [];
202
- const colDisplay = visualLayout?.[device]?.display || visualLayout?.desktop?.display || 'fit';
203
- if (colDisplay == 'fill') {
204
- const len = cols.length;
205
- for(let i = 0; i < len - 1; i++){
206
- const col = cols[i];
207
- if (col) {
208
- const totalCol = getTotalCol(cols, i);
209
- const gap = verticalGutter?.[device] || verticalGutter?.desktop || '0px';
210
- const left = getPositionLeft({
211
- index: i,
212
- len,
213
- gap,
214
- totalCol
215
- });
216
- items.push(/*#__PURE__*/ jsxRuntime.jsxs("div", {
217
- role: "presentation",
218
- "data-column-hand-drag": true,
219
- "data-col": col,
220
- "data-gap": gap,
221
- "data-column-hand-drag-active": isActive(device, i),
222
- className: cls.cls('absolute h-full cursor-grab', {
223
- hidden: device !== 'desktop',
224
- flex: device === 'desktop',
225
- 'tablet:hidden': device !== 'tablet',
226
- 'tablet:flex': device === 'tablet',
227
- 'mobile:hidden': device !== 'mobile',
228
- 'mobile:flex': device === 'mobile'
229
- }),
230
- style: {
231
- width: `${WIDTH_HAND}px`,
232
- top: '0px',
233
- left: left
234
- },
235
- onMouseDown: (e)=>onMouseDown(e, {
236
- device,
237
- totalCol,
238
- index: i
239
- }),
240
- onMouseUp: onMouseUp,
241
- children: [
242
- /*#__PURE__*/ jsxRuntime.jsx("div", {
243
- "data-column-hand-visual": true
244
- }),
245
- /*#__PURE__*/ jsxRuntime.jsx("div", {
246
- "data-column-hand-visual-drag": true,
247
- children: /*#__PURE__*/ jsxRuntime.jsxs("svg", {
248
- viewBox: "0 0 20 20",
249
- children: [
250
- /*#__PURE__*/ jsxRuntime.jsx("path", {
251
- d: "M12.75 3.5a.75.75 0 0 0 0 1.5h1.19l-3.22 3.22a.75.75 0 0 0 1.06 1.06l3.22-3.22v1.19a.75.75 0 0 0 1.5 0v-3a.75.75 0 0 0-.75-.75h-3Z",
252
- fill: "currentColor"
253
- }),
254
- /*#__PURE__*/ jsxRuntime.jsx("path", {
255
- d: "M7.25 16.5a.75.75 0 0 0 0-1.5h-1.19l3.22-3.22a.75.75 0 1 0-1.06-1.06l-3.22 3.22v-1.19a.75.75 0 0 0-1.5 0v3c0 .414.336.75.75.75h3Z",
256
- fill: "currentColor"
257
- })
258
- ]
259
- })
260
- })
261
- ]
262
- }, `${device}-${i}`));
263
- }
264
- }
265
- }
266
- }
267
- }
268
- return items;
269
- };
270
- return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
271
- children: /*#__PURE__*/ jsxRuntime.jsx("div", {
272
- "data-column": true,
273
- "data-column-theme-section": isThemeSectionEditor,
274
- "data-column-is-drag-visible": isDragging,
275
- children: HandDragItems()
276
- })
277
- });
278
- }
279
-
280
- exports.default = Column;
@@ -1,276 +0,0 @@
1
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
- import { useState, useRef, useEffect } 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 { cls } from '../../helpers/cls.js';
11
- import 'react-transition-group';
12
- import '@gem-sdk/core';
13
- import '../../helpers/convert.js';
14
-
15
- function Column(props) {
16
- const WIDTH_HAND = 16;
17
- const isThemeSectionEditor = useBuilderPreviewStore((s)=>s.isThemeSectionEditor);
18
- const [visualLayout, setVisualLayout] = useState(props.settings?.layout);
19
- const [currentLayout, setCurrentLayout] = useState(props.settings?.layout);
20
- const verticalGutter = props.styles?.verticalGutter;
21
- const dataDrag = useRef();
22
- const [isDragging, setIsDragging] = useState(false);
23
- const newValueCols = useRef([]);
24
- // Watch props change layout
25
- useEffect(()=>{
26
- setVisualLayout(props.settings?.layout);
27
- setCurrentLayout(props.settings?.layout);
28
- }, [
29
- props
30
- ]);
31
- // Validate resize column
32
- if (![
33
- 'Row',
34
- 'Product',
35
- 'HeroBanner'
36
- ].includes(props.tag)) return;
37
- const getTotalCol = (cols, i)=>{
38
- const cloneToIndex = cols.slice().splice(0, i + 1);
39
- return cloneToIndex.reduce((accumulator, currentValue)=>{
40
- return accumulator + currentValue;
41
- }, 0);
42
- };
43
- const getPositionLeft = ({ totalCol, len, gap, index })=>{
44
- const width = totalCol / 12;
45
- return `calc(100%*${width} - ${gap}*${0.5 - width} + ${gap}*${(12 / len * (index + 1) - totalCol) / (12 / len)} - ${WIDTH_HAND / 2}px)`;
46
- };
47
- const endDrag = ()=>{
48
- setIsDragging(false);
49
- document.body.style.cursor = '';
50
- if (!dataDrag.current) return;
51
- // Emit change value
52
- const device = dataDrag.current.device;
53
- const cols = currentLayout?.[device]?.cols || [];
54
- if (JSON.stringify(newValueCols.current) !== JSON.stringify(cols) && newValueCols.current.length) {
55
- window.dispatchEvent(new CustomEvent('editor:toolbar:change-column', {
56
- bubbles: true,
57
- detail: {
58
- componentUid: dataDrag.current.componentUid,
59
- cols: newValueCols.current
60
- }
61
- }));
62
- }
63
- window.dispatchEvent(new CustomEvent('editor:toolbar:resize-column', {
64
- bubbles: true,
65
- detail: {
66
- value: false
67
- }
68
- }));
69
- // Remove style inline
70
- setChangeVisualNewColumns(false, []);
71
- dataDrag.current = undefined;
72
- document.removeEventListener('mousemove', onMouseMoveDocument);
73
- document.removeEventListener('mouseup', onMouseUpDocument);
74
- };
75
- const setChangeVisualNewColumns = (value, newCols)=>{
76
- if (!dataDrag.current) return;
77
- const $components = document.querySelectorAll(`[data-uid="${dataDrag.current.componentUid}"]`);
78
- if ($components.length) {
79
- $components.forEach(($component)=>{
80
- let $row = $component;
81
- const tagRow = $row.getAttribute('data-component-tag');
82
- if (tagRow !== 'Row') {
83
- const $firstCol = $component.querySelector('[data-component-tag="Col"]');
84
- if ($firstCol && $firstCol.parentElement) {
85
- $row = $firstCol.parentElement;
86
- }
87
- }
88
- if ($row) {
89
- if (value) {
90
- $row.style.gridTemplateColumns = newCols.map((col)=>`minmax(0, ${col}fr)`).join(' ');
91
- } else {
92
- $row.style.gridTemplateColumns = '';
93
- }
94
- }
95
- });
96
- }
97
- };
98
- const onMouseMoveDocument = (event)=>{
99
- if (!dataDrag.current) return;
100
- const currentX = event.clientX;
101
- const diffX = currentX - (dataDrag.current.startX ?? 0);
102
- const diffXAbs = Math.abs(diffX);
103
- const index = dataDrag.current.index;
104
- const device = dataDrag.current.device ?? 'desktop';
105
- const itemWidth = dataDrag.current.itemWidth ?? 0;
106
- const cols = currentLayout?.[device]?.cols || [];
107
- const newCols = cols.slice();
108
- // Change value
109
- if (diffXAbs >= itemWidth) {
110
- const times = Math.round(diffXAbs / itemWidth);
111
- const action = diffX >= 0 ? 'plus' : 'minus';
112
- if (action == 'minus') {
113
- const currentCol = newCols[index] ?? 1;
114
- if (currentCol - times > 1) {
115
- newCols[index] = (newCols[index] ?? 0) - times;
116
- newCols[index + 1] = (newCols[index + 1] ?? 0) + times;
117
- } else {
118
- newCols[index + 1] = (newCols[index + 1] ?? 0) + (newCols[index] ?? 0) - 1;
119
- newCols[index] = 1;
120
- }
121
- } else {
122
- const nextCol = newCols[index + 1] ?? 1;
123
- if (nextCol - times > 1) {
124
- newCols[index + 1] = (newCols[index + 1] ?? 0) - times;
125
- newCols[index] = (newCols[index] ?? 0) + times;
126
- } else {
127
- newCols[index] = (newCols[index] ?? 0) + (newCols[index + 1] ?? 0) - 1;
128
- newCols[index + 1] = 1;
129
- }
130
- }
131
- }
132
- // Cancel when value not change
133
- if (JSON.stringify(newValueCols.current) === JSON.stringify(newCols)) {
134
- return;
135
- }
136
- // Update new value to ui
137
- if (JSON.stringify(newValueCols.current) !== JSON.stringify(newCols)) {
138
- newValueCols.current = newCols; // cache new value
139
- setVisualLayout({
140
- ...currentLayout,
141
- [device]: {
142
- ...currentLayout?.[device],
143
- cols: newCols
144
- }
145
- });
146
- setChangeVisualNewColumns(true, newCols);
147
- }
148
- };
149
- const onMouseUpDocument = ()=>{
150
- endDrag();
151
- };
152
- const onMouseDown = (event, { device, totalCol, index })=>{
153
- const target = event.target;
154
- if (target) {
155
- const $component = target.closest('[data-uid]');
156
- if ($component) {
157
- document.removeEventListener('mousemove', onMouseMoveDocument);
158
- document.removeEventListener('mouseup', onMouseUpDocument);
159
- document.addEventListener('mousemove', onMouseMoveDocument);
160
- document.addEventListener('mouseup', onMouseUpDocument);
161
- setIsDragging(true);
162
- const componentUid = $component.getAttribute('data-uid') || undefined;
163
- const handRect = target.getBoundingClientRect();
164
- const componentRect = $component.getBoundingClientRect();
165
- dataDrag.current = {
166
- componentUid,
167
- device,
168
- index,
169
- startX: event.clientX,
170
- itemWidth: (handRect.left - componentRect.left) / totalCol
171
- };
172
- document.body.style.cursor = 'grab';
173
- window.dispatchEvent(new CustomEvent('editor:toolbar:resize-column', {
174
- bubbles: true,
175
- detail: {
176
- value: true
177
- }
178
- }));
179
- }
180
- }
181
- };
182
- const onMouseUp = ()=>{
183
- endDrag();
184
- };
185
- const isActive = (device, index)=>{
186
- return dataDrag.current?.componentUid == props.uid && dataDrag.current.device == device && dataDrag.current.index == index;
187
- };
188
- const HandDragItems = ()=>{
189
- const items = [];
190
- const devices = [
191
- 'desktop',
192
- 'tablet',
193
- 'mobile'
194
- ];
195
- for (const device of devices){
196
- if (visualLayout?.[device]) {
197
- const cols = visualLayout?.[device]?.cols || visualLayout?.desktop?.cols || [];
198
- const colDisplay = visualLayout?.[device]?.display || visualLayout?.desktop?.display || 'fit';
199
- if (colDisplay == 'fill') {
200
- const len = cols.length;
201
- for(let i = 0; i < len - 1; i++){
202
- const col = cols[i];
203
- if (col) {
204
- const totalCol = getTotalCol(cols, i);
205
- const gap = verticalGutter?.[device] || verticalGutter?.desktop || '0px';
206
- const left = getPositionLeft({
207
- index: i,
208
- len,
209
- gap,
210
- totalCol
211
- });
212
- items.push(/*#__PURE__*/ jsxs("div", {
213
- role: "presentation",
214
- "data-column-hand-drag": true,
215
- "data-col": col,
216
- "data-gap": gap,
217
- "data-column-hand-drag-active": isActive(device, i),
218
- className: cls('absolute h-full cursor-grab', {
219
- hidden: device !== 'desktop',
220
- flex: device === 'desktop',
221
- 'tablet:hidden': device !== 'tablet',
222
- 'tablet:flex': device === 'tablet',
223
- 'mobile:hidden': device !== 'mobile',
224
- 'mobile:flex': device === 'mobile'
225
- }),
226
- style: {
227
- width: `${WIDTH_HAND}px`,
228
- top: '0px',
229
- left: left
230
- },
231
- onMouseDown: (e)=>onMouseDown(e, {
232
- device,
233
- totalCol,
234
- index: i
235
- }),
236
- onMouseUp: onMouseUp,
237
- children: [
238
- /*#__PURE__*/ jsx("div", {
239
- "data-column-hand-visual": true
240
- }),
241
- /*#__PURE__*/ jsx("div", {
242
- "data-column-hand-visual-drag": true,
243
- children: /*#__PURE__*/ jsxs("svg", {
244
- viewBox: "0 0 20 20",
245
- children: [
246
- /*#__PURE__*/ jsx("path", {
247
- d: "M12.75 3.5a.75.75 0 0 0 0 1.5h1.19l-3.22 3.22a.75.75 0 0 0 1.06 1.06l3.22-3.22v1.19a.75.75 0 0 0 1.5 0v-3a.75.75 0 0 0-.75-.75h-3Z",
248
- fill: "currentColor"
249
- }),
250
- /*#__PURE__*/ jsx("path", {
251
- d: "M7.25 16.5a.75.75 0 0 0 0-1.5h-1.19l3.22-3.22a.75.75 0 1 0-1.06-1.06l-3.22 3.22v-1.19a.75.75 0 0 0-1.5 0v3c0 .414.336.75.75.75h3Z",
252
- fill: "currentColor"
253
- })
254
- ]
255
- })
256
- })
257
- ]
258
- }, `${device}-${i}`));
259
- }
260
- }
261
- }
262
- }
263
- }
264
- return items;
265
- };
266
- return /*#__PURE__*/ jsx(Fragment, {
267
- children: /*#__PURE__*/ jsx("div", {
268
- "data-column": true,
269
- "data-column-theme-section": isThemeSectionEditor,
270
- "data-column-is-drag-visible": isDragging,
271
- children: HandDragItems()
272
- })
273
- });
274
- }
275
-
276
- export { Column as default };