@bigbinary/neeto-themes-frontend 2.0.6 → 2.0.7
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 +110 -104
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +111 -105
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.cjs.js
CHANGED
|
@@ -143,6 +143,105 @@ 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
|
+
|
|
146
245
|
var getImageFromUrl = function getImageFromUrl(source) {
|
|
147
246
|
var image = new Image();
|
|
148
247
|
image.crossOrigin = "anonymous";
|
|
@@ -218,6 +317,10 @@ var setTheme = function setTheme(theme, variableNamesMap, themeConfig) {
|
|
|
218
317
|
if (neetoCist.isNotPresent(theme === null || theme === void 0 ? void 0 : theme.properties)) return;
|
|
219
318
|
theme.properties.forEach(function (property) {
|
|
220
319
|
var attribute = neetoCist.snakeToCamelCase(property.key);
|
|
320
|
+
if (!isPropertyVisible(property.key, theme, themeConfig)) {
|
|
321
|
+
setVariable(attribute, "", variableNamesMap);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
221
324
|
if (property.kind === "color") {
|
|
222
325
|
setVariable(attribute, hexToRgba(property.value), variableNamesMap);
|
|
223
326
|
} else if (property.kind === "overlay_opacity") {
|
|
@@ -471,105 +574,6 @@ var OVERLAY_OPACITY_SLIDER_MARKS = {
|
|
|
471
574
|
};
|
|
472
575
|
var HUNDRED = 100;
|
|
473
576
|
|
|
474
|
-
var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
|
|
475
|
-
if (neetoCist.isPresent(theme)) return theme;
|
|
476
|
-
return {
|
|
477
|
-
name: i18next.t("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
|
|
478
|
-
properties: themePropertiesSchema.map(function (_ref) {
|
|
479
|
-
var key = _ref.key,
|
|
480
|
-
kind = _ref.kind,
|
|
481
|
-
defaultValue = _ref.defaultValue;
|
|
482
|
-
switch (kind) {
|
|
483
|
-
case "color":
|
|
484
|
-
return {
|
|
485
|
-
value: defaultValue,
|
|
486
|
-
kind: "color",
|
|
487
|
-
key: key
|
|
488
|
-
};
|
|
489
|
-
case "font_family":
|
|
490
|
-
return {
|
|
491
|
-
value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
|
|
492
|
-
kind: "font_family",
|
|
493
|
-
key: key
|
|
494
|
-
};
|
|
495
|
-
case "overlay_opacity":
|
|
496
|
-
return {
|
|
497
|
-
value: 0,
|
|
498
|
-
kind: "overlay_opacity",
|
|
499
|
-
key: key
|
|
500
|
-
};
|
|
501
|
-
case "slider":
|
|
502
|
-
return {
|
|
503
|
-
value: 0,
|
|
504
|
-
kind: "slider",
|
|
505
|
-
key: key
|
|
506
|
-
};
|
|
507
|
-
case "radius":
|
|
508
|
-
return {
|
|
509
|
-
value: defaultValue,
|
|
510
|
-
kind: "radius",
|
|
511
|
-
key: key
|
|
512
|
-
};
|
|
513
|
-
case "boolean":
|
|
514
|
-
return {
|
|
515
|
-
value: String(defaultValue),
|
|
516
|
-
kind: "boolean",
|
|
517
|
-
key: key
|
|
518
|
-
};
|
|
519
|
-
case "position_selector":
|
|
520
|
-
return {
|
|
521
|
-
value: defaultValue,
|
|
522
|
-
kind: "position_selector",
|
|
523
|
-
key: key
|
|
524
|
-
};
|
|
525
|
-
case "alignment_block":
|
|
526
|
-
return {
|
|
527
|
-
value: defaultValue,
|
|
528
|
-
kind: "alignment_block",
|
|
529
|
-
key: key
|
|
530
|
-
};
|
|
531
|
-
default:
|
|
532
|
-
return null;
|
|
533
|
-
}
|
|
534
|
-
}).filter(neetoCist.isNot(null))
|
|
535
|
-
};
|
|
536
|
-
};
|
|
537
|
-
var buildImageData = function buildImageData(values, themePropertiesSchema) {
|
|
538
|
-
return neetoCist.filterBy({
|
|
539
|
-
kind: "image"
|
|
540
|
-
}, themePropertiesSchema).reduce(function (acc, item) {
|
|
541
|
-
var _values$snakeToCamelC;
|
|
542
|
-
var signedId = (_values$snakeToCamelC = values[neetoCist.snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
|
|
543
|
-
acc[item.key] = signedId;
|
|
544
|
-
return acc;
|
|
545
|
-
}, {});
|
|
546
|
-
};
|
|
547
|
-
var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
|
|
548
|
-
var property = neetoCist.findBy({
|
|
549
|
-
key: key
|
|
550
|
-
}, themePropertiesSchema);
|
|
551
|
-
if (neetoCist.isNotPresent(property)) return false;
|
|
552
|
-
if (property !== null && property !== void 0 && property.hidden) return false;
|
|
553
|
-
var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
|
|
554
|
-
if (neetoCist.isNotPresent(conditionalKey)) return true;
|
|
555
|
-
var dependentPropertySchema = neetoCist.findBy({
|
|
556
|
-
key: conditionalKey
|
|
557
|
-
}, themePropertiesSchema);
|
|
558
|
-
var dependentProperty = neetoCist.findBy({
|
|
559
|
-
key: conditionalKey
|
|
560
|
-
}, formikValues.properties);
|
|
561
|
-
if (dependentPropertySchema.kind === "image") {
|
|
562
|
-
var _formikValues$snakeTo;
|
|
563
|
-
return neetoCist.isPresent((_formikValues$snakeTo = formikValues[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
|
|
564
|
-
} else if (dependentPropertySchema.kind === "boolean") {
|
|
565
|
-
return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
|
|
566
|
-
}
|
|
567
|
-
return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
|
|
568
|
-
};
|
|
569
|
-
var buildLabel = function buildLabel(key, kind) {
|
|
570
|
-
return i18next.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
|
|
571
|
-
};
|
|
572
|
-
|
|
573
577
|
var Card$2 = function Card(_ref) {
|
|
574
578
|
var _ref$title = _ref.title,
|
|
575
579
|
title = _ref$title === void 0 ? "" : _ref$title,
|
|
@@ -1967,15 +1971,17 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1967
1971
|
react.useEffect(function () {
|
|
1968
1972
|
if (neetoCist.isNotPresent(currentTheme)) return;
|
|
1969
1973
|
setThemeState({
|
|
1970
|
-
currentTheme: currentTheme,
|
|
1971
|
-
isCurrentThemeLoading: isCurrentThemeLoading,
|
|
1972
1974
|
previewingTheme: currentTheme
|
|
1973
1975
|
});
|
|
1974
|
-
|
|
1976
|
+
setTheme(currentTheme);
|
|
1977
|
+
}, [isLoading, entityId]);
|
|
1975
1978
|
react.useEffect(function () {
|
|
1976
1979
|
if (neetoCist.isNotPresent(currentTheme)) return;
|
|
1977
|
-
|
|
1978
|
-
|
|
1980
|
+
setThemeState({
|
|
1981
|
+
currentTheme: currentTheme,
|
|
1982
|
+
isCurrentThemeLoading: isCurrentThemeLoading
|
|
1983
|
+
});
|
|
1984
|
+
}, [currentTheme, isCurrentThemeLoading]);
|
|
1979
1985
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1980
1986
|
className: "neeto-themes__wrapper",
|
|
1981
1987
|
children: [/*#__PURE__*/jsxRuntime.jsx(Sidebar, {
|