@bigbinary/neeto-themes-frontend 2.0.7 → 2.0.8

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.
package/dist/index.cjs.js CHANGED
@@ -143,105 +143,6 @@ var useThemeStore = zustand.create(reactUtils.withImmutableActions(function (set
143
143
  };
144
144
  }));
145
145
 
146
- var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
147
- if (neetoCist.isPresent(theme)) return theme;
148
- return {
149
- name: i18next.t("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
150
- properties: themePropertiesSchema.map(function (_ref) {
151
- var key = _ref.key,
152
- kind = _ref.kind,
153
- defaultValue = _ref.defaultValue;
154
- switch (kind) {
155
- case "color":
156
- return {
157
- value: defaultValue,
158
- kind: "color",
159
- key: key
160
- };
161
- case "font_family":
162
- return {
163
- value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
164
- kind: "font_family",
165
- key: key
166
- };
167
- case "overlay_opacity":
168
- return {
169
- value: 0,
170
- kind: "overlay_opacity",
171
- key: key
172
- };
173
- case "slider":
174
- return {
175
- value: 0,
176
- kind: "slider",
177
- key: key
178
- };
179
- case "radius":
180
- return {
181
- value: defaultValue,
182
- kind: "radius",
183
- key: key
184
- };
185
- case "boolean":
186
- return {
187
- value: String(defaultValue),
188
- kind: "boolean",
189
- key: key
190
- };
191
- case "position_selector":
192
- return {
193
- value: defaultValue,
194
- kind: "position_selector",
195
- key: key
196
- };
197
- case "alignment_block":
198
- return {
199
- value: defaultValue,
200
- kind: "alignment_block",
201
- key: key
202
- };
203
- default:
204
- return null;
205
- }
206
- }).filter(neetoCist.isNot(null))
207
- };
208
- };
209
- var buildImageData = function buildImageData(values, themePropertiesSchema) {
210
- return neetoCist.filterBy({
211
- kind: "image"
212
- }, themePropertiesSchema).reduce(function (acc, item) {
213
- var _values$snakeToCamelC;
214
- var signedId = (_values$snakeToCamelC = values[neetoCist.snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
215
- acc[item.key] = signedId;
216
- return acc;
217
- }, {});
218
- };
219
- var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
220
- var property = neetoCist.findBy({
221
- key: key
222
- }, themePropertiesSchema);
223
- if (neetoCist.isNotPresent(property)) return false;
224
- if (property !== null && property !== void 0 && property.hidden) return false;
225
- var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
226
- if (neetoCist.isNotPresent(conditionalKey)) return true;
227
- var dependentPropertySchema = neetoCist.findBy({
228
- key: conditionalKey
229
- }, themePropertiesSchema);
230
- var dependentProperty = neetoCist.findBy({
231
- key: conditionalKey
232
- }, formikValues.properties);
233
- if (dependentPropertySchema.kind === "image") {
234
- var _formikValues$snakeTo;
235
- return neetoCist.isPresent((_formikValues$snakeTo = formikValues[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
236
- } else if (dependentPropertySchema.kind === "boolean") {
237
- return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
238
- }
239
- return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
240
- };
241
- var buildLabel = function buildLabel(key, kind) {
242
- return i18next.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
243
- };
244
-
245
146
  var getImageFromUrl = function getImageFromUrl(source) {
246
147
  var image = new Image();
247
148
  image.crossOrigin = "anonymous";
@@ -313,11 +214,32 @@ var setVariable = function setVariable(name, value, variableNamesMap) {
313
214
  if (!variableName) return;
314
215
  root.style.setProperty(variableName, value);
315
216
  };
217
+ var isPropertyIndependent = function isPropertyIndependent(key, theme, schema) {
218
+ var property = neetoCist.findBy({
219
+ key: key
220
+ }, schema);
221
+ if (neetoCist.isNotPresent(property)) return false;
222
+ var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
223
+ if (neetoCist.isNotPresent(conditionalKey)) return true;
224
+ var dependentPropertySchema = neetoCist.findBy({
225
+ key: conditionalKey
226
+ }, schema);
227
+ var dependentProperty = neetoCist.findBy({
228
+ key: conditionalKey
229
+ }, theme.properties);
230
+ if (dependentPropertySchema.kind === "image") {
231
+ var _theme$snakeToCamelCa;
232
+ return neetoCist.isPresent((_theme$snakeToCamelCa = theme[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _theme$snakeToCamelCa === void 0 ? void 0 : _theme$snakeToCamelCa.url);
233
+ } else if (dependentPropertySchema.kind === "boolean") {
234
+ return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
235
+ }
236
+ return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
237
+ };
316
238
  var setTheme = function setTheme(theme, variableNamesMap, themeConfig) {
317
239
  if (neetoCist.isNotPresent(theme === null || theme === void 0 ? void 0 : theme.properties)) return;
318
240
  theme.properties.forEach(function (property) {
319
241
  var attribute = neetoCist.snakeToCamelCase(property.key);
320
- if (!isPropertyVisible(property.key, theme, themeConfig)) {
242
+ if (!isPropertyIndependent(property.key, theme, themeConfig)) {
321
243
  setVariable(attribute, "", variableNamesMap);
322
244
  return;
323
245
  }
@@ -574,6 +496,105 @@ var OVERLAY_OPACITY_SLIDER_MARKS = {
574
496
  };
575
497
  var HUNDRED = 100;
576
498
 
499
+ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
500
+ if (neetoCist.isPresent(theme)) return theme;
501
+ return {
502
+ name: i18next.t("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
503
+ properties: themePropertiesSchema.map(function (_ref) {
504
+ var key = _ref.key,
505
+ kind = _ref.kind,
506
+ defaultValue = _ref.defaultValue;
507
+ switch (kind) {
508
+ case "color":
509
+ return {
510
+ value: defaultValue,
511
+ kind: "color",
512
+ key: key
513
+ };
514
+ case "font_family":
515
+ return {
516
+ value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
517
+ kind: "font_family",
518
+ key: key
519
+ };
520
+ case "overlay_opacity":
521
+ return {
522
+ value: 0,
523
+ kind: "overlay_opacity",
524
+ key: key
525
+ };
526
+ case "slider":
527
+ return {
528
+ value: 0,
529
+ kind: "slider",
530
+ key: key
531
+ };
532
+ case "radius":
533
+ return {
534
+ value: defaultValue,
535
+ kind: "radius",
536
+ key: key
537
+ };
538
+ case "boolean":
539
+ return {
540
+ value: String(defaultValue),
541
+ kind: "boolean",
542
+ key: key
543
+ };
544
+ case "position_selector":
545
+ return {
546
+ value: defaultValue,
547
+ kind: "position_selector",
548
+ key: key
549
+ };
550
+ case "alignment_block":
551
+ return {
552
+ value: defaultValue,
553
+ kind: "alignment_block",
554
+ key: key
555
+ };
556
+ default:
557
+ return null;
558
+ }
559
+ }).filter(neetoCist.isNot(null))
560
+ };
561
+ };
562
+ var buildImageData = function buildImageData(values, themePropertiesSchema) {
563
+ return neetoCist.filterBy({
564
+ kind: "image"
565
+ }, themePropertiesSchema).reduce(function (acc, item) {
566
+ var _values$snakeToCamelC;
567
+ var signedId = (_values$snakeToCamelC = values[neetoCist.snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
568
+ acc[item.key] = signedId;
569
+ return acc;
570
+ }, {});
571
+ };
572
+ var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
573
+ var property = neetoCist.findBy({
574
+ key: key
575
+ }, themePropertiesSchema);
576
+ if (neetoCist.isNotPresent(property)) return false;
577
+ if (property !== null && property !== void 0 && property.hidden) return false;
578
+ var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
579
+ if (neetoCist.isNotPresent(conditionalKey)) return true;
580
+ var dependentPropertySchema = neetoCist.findBy({
581
+ key: conditionalKey
582
+ }, themePropertiesSchema);
583
+ var dependentProperty = neetoCist.findBy({
584
+ key: conditionalKey
585
+ }, formikValues.properties);
586
+ if (dependentPropertySchema.kind === "image") {
587
+ var _formikValues$snakeTo;
588
+ return neetoCist.isPresent((_formikValues$snakeTo = formikValues[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
589
+ } else if (dependentPropertySchema.kind === "boolean") {
590
+ return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
591
+ }
592
+ return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
593
+ };
594
+ var buildLabel = function buildLabel(key, kind) {
595
+ return i18next.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
596
+ };
597
+
577
598
  var Card$2 = function Card(_ref) {
578
599
  var _ref$title = _ref.title,
579
600
  title = _ref$title === void 0 ? "" : _ref$title,