@gem-sdk/components 2.0.0-dev.401 → 2.0.0-dev.402

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.
@@ -7,11 +7,17 @@ var jsxRuntime = require('react/jsx-runtime');
7
7
  var system = require('@gem-sdk/system');
8
8
  var composeStyles = require('./common/composeStyles.js');
9
9
  var composeClasses = require('./common/composeClasses.js');
10
+ var index = require('./hooks/index.js');
10
11
 
11
- const FormDropdown = ({ builderProps, builderAttrs, setting, advanced, children })=>{
12
+ const FormDropdown = ({ builderProps, builderAttrs, setting, advanced, children, styles })=>{
12
13
  const { name, childItem, required } = setting ?? {};
14
+ const { handleOnChange, getTextColor } = index.useGetColorContent(setting);
13
15
  const composedContainerStyles = system.createStyle(composeStyles.composeContainerStyles(advanced, setting));
14
- const composedFormDropdownStyles = system.createStyle(composeStyles.composeFormDropdownStyles(advanced, setting));
16
+ const composedFormDropdownStyles = system.createStyle({
17
+ ...composeStyles.composeFormDropdownStyles(advanced, setting, styles),
18
+ ...getTextColor
19
+ });
20
+ const composedOptionStyles = system.createStyle(composeStyles.getStyleOption(setting));
15
21
  const composedContainerClasses = system.createClass(composeClasses.composeContainerClasses(advanced, builderProps));
16
22
  const composedFormDropdownClasses = system.createClass(composeClasses.composeFormDropdownClasses(setting));
17
23
  return /*#__PURE__*/ jsxRuntime.jsxs("div", {
@@ -20,15 +26,29 @@ const FormDropdown = ({ builderProps, builderAttrs, setting, advanced, children
20
26
  className: composedContainerClasses,
21
27
  style: composedContainerStyles,
22
28
  children: [
23
- /*#__PURE__*/ jsxRuntime.jsx("select", {
29
+ /*#__PURE__*/ jsxRuntime.jsxs("select", {
24
30
  className: composedFormDropdownClasses,
25
31
  style: composedFormDropdownStyles,
26
32
  required: required,
27
33
  name: name,
28
- children: childItem?.map((item, index)=>/*#__PURE__*/ jsxRuntime.jsx("option", {
29
- value: item,
30
- children: item
31
- }, index))
34
+ onChange: handleOnChange,
35
+ children: [
36
+ system.If(!Number(setting?.defaultOption), /*#__PURE__*/ jsxRuntime.jsx("option", {
37
+ className: "gp-hidden",
38
+ value: "",
39
+ disabled: true,
40
+ selected: true,
41
+ children: setting?.placeholder
42
+ })),
43
+ childItem?.map((item, index)=>/*#__PURE__*/ jsxRuntime.jsx("option", {
44
+ value: item,
45
+ style: composedOptionStyles,
46
+ ...!!Number(setting?.defaultOption) && {
47
+ selected: item === childItem[Number(setting?.defaultOption) - 1]
48
+ },
49
+ children: item
50
+ }, index))
51
+ ]
32
52
  }),
33
53
  children
34
54
  ]
@@ -8,7 +8,7 @@ var system = require('@gem-sdk/system');
8
8
  var composeStyles = require('./common/composeStyles.js');
9
9
  var composeClasses = require('./common/composeClasses.js');
10
10
 
11
- const FormDropdown = ({ builderProps, setting, advanced, pageContext })=>{
11
+ const FormDropdown = ({ builderProps, setting, advanced, pageContext, styles })=>{
12
12
  const { name, childItem, required, translate } = setting ?? {};
13
13
  const childItemVal = childItem?.map((item, index)=>helpers.getDynamicSourceLocales({
14
14
  val: item,
@@ -18,7 +18,11 @@ const FormDropdown = ({ builderProps, setting, advanced, pageContext })=>{
18
18
  translate
19
19
  }));
20
20
  const composedContainerStyles = system.createStyle(composeStyles.composeContainerStyles(advanced, setting));
21
- const composedFormDropdownStyles = system.createStyle(composeStyles.composeFormDropdownStyles(advanced, setting));
21
+ const composedFormDropdownStyles = system.createStyle({
22
+ ...composeStyles.composeFormDropdownStyles(advanced, setting, styles),
23
+ ...composeStyles.getAppendTypoStyleFirstTime(setting)
24
+ });
25
+ const composedOptionStyles = system.createStyle(composeStyles.getStyleOption(setting));
22
26
  const composedContainerClasses = system.createClass(composeClasses.composeContainerClasses(advanced, builderProps));
23
27
  const composedFormDropdownClasses = system.createClass(composeClasses.composeFormDropdownClasses(setting));
24
28
  return core.template`
@@ -33,10 +37,16 @@ const FormDropdown = ({ builderProps, setting, advanced, pageContext })=>{
33
37
  style="${composedFormDropdownStyles}"
34
38
  ${system.If(required, 'required')}
35
39
  name="${name}"
40
+ gp-data='${JSON.stringify(setting).replaceAll("'", ''')}'
36
41
  >
42
+ ${system.If(!Number(setting?.defaultOption), `<option class="gp-hidden" value="" disabled selected>
43
+ ${setting?.placeholder}
44
+ </option>`)}
37
45
  ${childItemVal?.map((item)=>core.template /* liquid */ `
38
46
  <option
39
47
  value="${item}"
48
+ style="${composedOptionStyles}"
49
+ ${system.If(!!Number(setting?.defaultOption), `selected: ${item === childItemVal[Number(setting?.defaultOption) - 1]}`)}
40
50
  >
41
51
  ${item}
42
52
  </option>`).join('')}
@@ -16,7 +16,7 @@ const composeFormDropdownClasses = (setting)=>{
16
16
  return composeClasses({
17
17
  [appendTypoClass]: !!appendTypoClass,
18
18
  [`${core.genSizeClass(setting?.size?.type)}`]: !!setting?.size?.type,
19
- 'gp-form-item !gp-outline-none !gp-h-auto focus:!gp-shadow-none hover:!gp-shadow-none': true
19
+ 'gp-form-item !gp-outline-none focus:!gp-shadow-none hover:!gp-shadow-none': true
20
20
  });
21
21
  };
22
22
 
@@ -25,29 +25,90 @@ const composeContainerStyles = (advanced, setting)=>{
25
25
  ...core.makeStyleResponsive('ta', setting?.align)
26
26
  });
27
27
  };
28
- const composeFormDropdownStyles = (advanced, setting)=>{
29
- const { size } = setting ?? {};
28
+ const composeFormDropdownStyles = (advanced, setting, styles)=>{
30
29
  const { border, rounded, hasBoxShadow, boxShadow } = advanced ?? {};
31
- const { typography, width } = setting ?? {};
32
- const appendTypoStyle = core.composeTypographyStyle(setting?.typo, typography);
30
+ const { background, size } = setting ?? {};
31
+ const { globalSize, borderActive, boxShadowActive, roundedActive, backgroundColorV2Active } = styles ?? {};
33
32
  const inputStyle = core.composeAdvanceStyle({
34
33
  border,
35
34
  rounded,
36
35
  hasBoxShadow,
37
36
  boxShadow
38
37
  });
39
- const inputWidth = core.makeStyleResponsive('w', core.makeWidth(width));
38
+ const composeGlobalSize = core.makeGlobalSize(globalSize);
40
39
  return composeStyles({
41
- ...inputWidth,
40
+ ...composeGlobalSize?.width?.['--w'] ? composeGlobalSize.width : {
41
+ '--w': '100%'
42
+ },
43
+ ...composeGlobalSize?.height?.['--h'] ? composeGlobalSize.height : {
44
+ '--h': 'auto'
45
+ },
46
+ ...composeGlobalSize.padding,
42
47
  ...inputStyle,
43
48
  ...!size?.type ? core.composeSize(size?.custom) : {},
44
- ...appendTypoStyle,
45
49
  appearance: 'none',
46
- 'background-image': 'url(https://cdn.shopify.com/s/files/1/1827/4239/t/1/assets/ico-select.svg?v=155563818344741998551488860031)',
50
+ ...core.getStyleBackgroundByDevice(background),
51
+ ...generateStylesTarget({
52
+ state: 'focus',
53
+ borderStyle: borderActive?.active,
54
+ background: backgroundColorV2Active?.active,
55
+ radius: roundedActive?.active
56
+ }),
57
+ ...core.getStyleShadow({
58
+ value: boxShadowActive?.active,
59
+ state: 'focus',
60
+ styleAppliedFor: 'box-shadow',
61
+ isEnableShadow: true
62
+ }),
63
+ '--bgi': getBgImageUrl(background?.desktop?.color),
47
64
  'background-repeat': 'no-repeat',
48
- 'background-position': 'right 10px center'
65
+ 'background-position': 'right 10px center, 0 0',
66
+ '--focus-bgi': getBgImageUrl(backgroundColorV2Active?.active)
67
+ });
68
+ };
69
+ const getBgImageUrl = (color)=>{
70
+ const iconDropDown = 'url(https://cdn.shopify.com/s/files/1/1827/4239/t/1/assets/ico-select.svg?v=155563818344741998551488860031)';
71
+ return `${iconDropDown} ${color?.includes('linear-gradient') ? ',' + color : ''}`;
72
+ };
73
+ const generateStylesTarget = ({ state, borderStyle, background, radius })=>{
74
+ const { border, width, color } = borderStyle ?? {};
75
+ const getState = {
76
+ hover: 'hvr',
77
+ focus: 'focus'
78
+ };
79
+ const currentState = getState[state];
80
+ return {
81
+ ...width && {
82
+ [`--${currentState}-bw`]: `${width}`
83
+ },
84
+ ...border && {
85
+ [`--${currentState}-b`]: `${border} ${core.getSingleColorVariable(color)}`
86
+ },
87
+ ...background && {
88
+ [`--${currentState}-bgc`]: `${core.getSingleColorVariable(background)}`
89
+ },
90
+ ...core.getCustomRadius(state, radius)
91
+ };
92
+ };
93
+ const getAppendTypoStyleFirstTime = (setting)=>{
94
+ const appendTypoStyle = core.composeTypographyStyle(setting?.typo, setting?.typography);
95
+ return composeStyles({
96
+ ...appendTypoStyle,
97
+ ...!Number(setting?.defaultOption) && {
98
+ '--c': setting?.placeholderColor
99
+ }
100
+ });
101
+ };
102
+ const getStyleOption = (setting)=>{
103
+ const { typography, typo } = setting ?? {};
104
+ const appendTypoStyle = core.composeTypographyStyle(typo, typography);
105
+ return composeStyles({
106
+ ...appendTypoStyle
49
107
  });
50
108
  };
51
109
 
52
110
  exports.composeContainerStyles = composeContainerStyles;
53
111
  exports.composeFormDropdownStyles = composeFormDropdownStyles;
112
+ exports.generateStylesTarget = generateStylesTarget;
113
+ exports.getAppendTypoStyleFirstTime = getAppendTypoStyleFirstTime;
114
+ exports.getStyleOption = getStyleOption;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var core = require('@gem-sdk/core');
5
+
6
+ const useGetColorContent = (setting)=>{
7
+ const [showPlaceholder, setShowPlaceholder] = React.useState(true);
8
+ const { typography, placeholderColor } = setting ?? {};
9
+ const appendTypoStyle = core.composeTypographyStyle(setting?.typo, typography);
10
+ const handleOnChange = ()=>{
11
+ if (showPlaceholder) {
12
+ setShowPlaceholder(false);
13
+ }
14
+ };
15
+ return {
16
+ handleOnChange,
17
+ getTextColor: {
18
+ ...appendTypoStyle,
19
+ ...showPlaceholder && {
20
+ '--c': placeholderColor
21
+ }
22
+ }
23
+ };
24
+ };
25
+
26
+ exports.useGetColorContent = useGetColorContent;
@@ -6,6 +6,24 @@ const FormDropdownSettings = [
6
6
  {
7
7
  id: 'setting',
8
8
  controls: [
9
+ {
10
+ id: 'placeholder',
11
+ type: 'input',
12
+ label: 'Placeholder',
13
+ default: 'Choose your option'
14
+ },
15
+ {
16
+ id: 'placeholderColor',
17
+ type: 'color-picker-v2',
18
+ label: 'Color',
19
+ default: '#A3A3A3'
20
+ },
21
+ {
22
+ id: 'defaultOption',
23
+ type: 'input',
24
+ label: 'Default option',
25
+ default: '1'
26
+ },
9
27
  {
10
28
  id: 'name',
11
29
  type: 'input',
@@ -20,8 +38,7 @@ const FormDropdownSettings = [
20
38
  'Option 1',
21
39
  'Option 2',
22
40
  'Option 3'
23
- ],
24
- expandItem: true
41
+ ]
25
42
  },
26
43
  {
27
44
  id: 'translate',
@@ -32,7 +49,7 @@ const FormDropdownSettings = [
32
49
  id: 'required',
33
50
  type: 'toggle',
34
51
  label: 'Placeholder',
35
- default: true
52
+ default: false
36
53
  },
37
54
  {
38
55
  id: 'typo',
@@ -81,22 +98,6 @@ const FormDropdownSettings = [
81
98
  }
82
99
  }
83
100
  },
84
- {
85
- id: 'width',
86
- type: 'input:unit',
87
- label: 'Width',
88
- min: 0,
89
- units: [
90
- 'px',
91
- '%'
92
- ],
93
- hide: true,
94
- devices: {
95
- desktop: {
96
- default: '358px'
97
- }
98
- }
99
- },
100
101
  {
101
102
  id: 'align',
102
103
  label: 'Alignment',
@@ -134,23 +135,12 @@ const FormDropdownSettings = [
134
135
  id: 'background',
135
136
  type: 'background-media',
136
137
  ignoreReRender: true,
138
+ hideImage: true,
137
139
  devices: {
138
140
  desktop: {
139
141
  default: {
140
142
  type: 'color',
141
- color: 'transparent',
142
- image: {
143
- src: '',
144
- width: 0,
145
- height: 0
146
- },
147
- size: 'cover',
148
- position: {
149
- x: 50,
150
- y: 50
151
- },
152
- repeat: 'no-repeat',
153
- attachment: 'scroll'
143
+ color: 'transparent'
154
144
  }
155
145
  }
156
146
  },
@@ -158,20 +148,7 @@ const FormDropdownSettings = [
158
148
  desktop: {
159
149
  default: {
160
150
  type: 'color',
161
- color: '#DDDDDD',
162
- image: {
163
- src: 'https://ucarecdn.com/5e27d43d-eb1e-4e71-b7e1-4158f3071bb6/-/format/auto/',
164
- width: 1200,
165
- height: 480
166
- },
167
- size: 'cover',
168
- position: {
169
- x: 50,
170
- y: 50
171
- },
172
- repeat: 'no-repeat',
173
- attachment: 'scroll',
174
- preload: false
151
+ color: '#DDDDDD'
175
152
  }
176
153
  }
177
154
  }
@@ -187,14 +164,14 @@ const FormDropdownSettings = [
187
164
  devices: {
188
165
  desktop: {
189
166
  default: {
190
- width: 'Auto',
167
+ width: '100%',
191
168
  height: 'Auto',
192
169
  padding: {
193
170
  type: 'medium',
194
171
  top: '12px',
195
172
  bottom: '12px',
196
- left: '24px',
197
- right: '24px'
173
+ left: '12px',
174
+ right: '12px'
198
175
  }
199
176
  }
200
177
  }
@@ -276,6 +253,52 @@ const FormDropdownSettings = [
276
253
  }
277
254
  }
278
255
  }
256
+ },
257
+ {
258
+ id: 'backgroundColorV2Active',
259
+ type: 'color-picker-v2',
260
+ enableGradient: true
261
+ },
262
+ {
263
+ id: 'borderActive',
264
+ type: 'border',
265
+ emptyOnClear: true,
266
+ state: {
267
+ active: true
268
+ }
269
+ },
270
+ {
271
+ id: 'roundedActive',
272
+ type: 'radius-preset',
273
+ default: {
274
+ active: {
275
+ radiusType: 'small'
276
+ }
277
+ },
278
+ state: {
279
+ active: true
280
+ }
281
+ },
282
+ {
283
+ id: 'boxShadowActive',
284
+ type: 'shadow-v2',
285
+ label: 'Button Shadow',
286
+ hideOnState: {
287
+ active: true
288
+ },
289
+ default: {
290
+ active: {
291
+ type: 'shadow-1',
292
+ distance: '4px',
293
+ blur: '12px',
294
+ spread: '0px',
295
+ color: 'rgba(0, 0, 0, 0.20)',
296
+ angle: 90
297
+ }
298
+ },
299
+ state: {
300
+ active: true
301
+ }
279
302
  }
280
303
  ]
281
304
  }
@@ -6,6 +6,33 @@ const SettingUIV2 = [
6
6
  en: 'Item management'
7
7
  },
8
8
  controls: [
9
+ {
10
+ type: 'combo',
11
+ label: {
12
+ en: 'Placeholder'
13
+ },
14
+ iconName: 'polaris-text-block',
15
+ getValueFromSettingID: 'placeholder',
16
+ isHideClear: true,
17
+ controls: [
18
+ {
19
+ label: {
20
+ en: 'Content'
21
+ },
22
+ setting: {
23
+ id: 'placeholder'
24
+ }
25
+ },
26
+ {
27
+ setting: {
28
+ id: 'placeholderColor'
29
+ },
30
+ label: {
31
+ en: 'Color'
32
+ }
33
+ }
34
+ ]
35
+ },
9
36
  {
10
37
  label: {
11
38
  en: 'Options'
@@ -13,6 +40,14 @@ const SettingUIV2 = [
13
40
  setting: {
14
41
  id: 'childItem'
15
42
  }
43
+ },
44
+ {
45
+ label: {
46
+ en: 'Default option'
47
+ },
48
+ setting: {
49
+ id: 'defaultOption'
50
+ }
16
51
  }
17
52
  ]
18
53
  },
@@ -99,7 +134,7 @@ const SettingUIV2 = [
99
134
  ],
100
135
  hideUnit: false,
101
136
  linkWithSetting: {
102
- name: 'globalSizeBtn',
137
+ name: 'globalSize',
103
138
  field: 'height'
104
139
  },
105
140
  displayOptions: [
@@ -170,48 +205,114 @@ const SettingUIV2 = [
170
205
  label: {
171
206
  en: 'Border'
172
207
  },
173
- controlConfig: {
208
+ setting: {
174
209
  id: 'border',
175
- type: 'border-v2',
176
- linkWithSetting: {
177
- name: 'wrapperBorder'
178
- },
179
- compoDefaultValue: {
180
- desktop: {
181
- default: {
182
- normal: {
183
- border: 'solid',
184
- color: '#121212',
185
- width: '1px',
186
- borderWidth: '1px'
187
- }
210
+ state: 'normal'
211
+ }
212
+ },
213
+ {
214
+ label: {
215
+ en: 'Corner'
216
+ },
217
+ setting: {
218
+ id: 'rounded',
219
+ state: 'normal'
220
+ }
221
+ },
222
+ {
223
+ label: {
224
+ en: 'Shadow'
225
+ },
226
+ setting: {
227
+ id: 'boxShadow',
228
+ state: 'normal'
229
+ },
230
+ options: {
231
+ updateFields: [
232
+ {
233
+ field: 'enable',
234
+ settingId: 'hasBoxShadow',
235
+ state: 'normal'
236
+ }
237
+ ]
238
+ },
239
+ controlChangeTrigger: {
240
+ settings: [
241
+ {
242
+ condition: `boxShadow.normal.enable === true`,
243
+ source: [
244
+ 'boxShadow',
245
+ 'hasBoxShadow'
246
+ ],
247
+ action: {
248
+ controlId: 'hasBoxShadow',
249
+ groupType: 'advanced',
250
+ controlType: 'advanced',
251
+ state: 'normal',
252
+ newValue: true
253
+ }
254
+ },
255
+ {
256
+ condition: `boxShadow.normal.enable === false`,
257
+ source: [
258
+ 'boxShadow',
259
+ 'hasBoxShadow'
260
+ ],
261
+ action: {
262
+ controlId: 'hasBoxShadow',
263
+ groupType: 'advanced',
264
+ controlType: 'advanced',
265
+ state: 'normal',
266
+ newValue: false
188
267
  }
189
268
  }
269
+ ],
270
+ options: {
271
+ noRecordHistory: true
190
272
  }
191
273
  }
274
+ }
275
+ ]
276
+ },
277
+ {
278
+ label: {
279
+ en: 'Active state'
280
+ },
281
+ controls: [
282
+ {
283
+ label: {
284
+ en: 'Background'
285
+ },
286
+ setting: {
287
+ id: 'backgroundColorV2Active',
288
+ state: 'active'
289
+ }
290
+ },
291
+ {
292
+ label: {
293
+ en: 'Border'
294
+ },
295
+ setting: {
296
+ id: 'borderActive',
297
+ state: 'active'
298
+ }
192
299
  },
193
300
  {
194
301
  label: {
195
302
  en: 'Corner'
196
303
  },
197
- controlConfig: {
198
- id: 'corner',
199
- type: 'corner-v2',
200
- linkWithSetting: {
201
- name: 'borderRadius'
202
- }
304
+ setting: {
305
+ id: 'roundedActive',
306
+ state: 'active'
203
307
  }
204
308
  },
205
309
  {
206
310
  label: {
207
311
  en: 'Shadow'
208
312
  },
209
- controlConfig: {
210
- id: 'shadow',
211
- type: 'shadow-v2',
212
- linkWithSetting: {
213
- name: 'shadow'
214
- }
313
+ setting: {
314
+ id: 'boxShadowActive',
315
+ state: 'active'
215
316
  }
216
317
  }
217
318
  ]
@@ -235,6 +336,9 @@ const SettingUIV2 = [
235
336
  },
236
337
  setting: {
237
338
  id: 'name'
339
+ },
340
+ help: {
341
+ content: 'Identify the information submitted via this element.'
238
342
  }
239
343
  }
240
344
  ]
@@ -245,7 +349,7 @@ const SettingUIV2 = [
245
349
  label: {
246
350
  en: 'Align'
247
351
  },
248
- conditionEnable: '!(parseInt(width) >= 100 && width?.includes("%"))',
352
+ conditionEnable: '!(parseInt(globalSize.width) >= 100 && globalSize.width?.includes("%"))',
249
353
  setting: {
250
354
  id: 'align'
251
355
  },