@bigbinary/neeto-themes-frontend 2.0.7 → 2.0.9
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 +135 -105
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +136 -106
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/types.d.ts +2 -1
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 (!
|
|
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,
|
|
@@ -1127,7 +1148,8 @@ var Customize = function Customize(_ref) {
|
|
|
1127
1148
|
onCreateTheme = _ref.onCreateTheme,
|
|
1128
1149
|
onApplyTheme = _ref.onApplyTheme,
|
|
1129
1150
|
isApplyingTheme = _ref.isApplyingTheme,
|
|
1130
|
-
onPropertiesChange = _ref.onPropertiesChange
|
|
1151
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
1152
|
+
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
|
|
1131
1153
|
var _useTranslation = reactI18next.useTranslation(),
|
|
1132
1154
|
t = _useTranslation.t;
|
|
1133
1155
|
var _useState = react.useState({}),
|
|
@@ -1173,9 +1195,10 @@ var Customize = function Customize(_ref) {
|
|
|
1173
1195
|
}
|
|
1174
1196
|
return updateTheme(themeToSave, {
|
|
1175
1197
|
onSuccess: function onSuccess() {
|
|
1176
|
-
|
|
1198
|
+
resetForm({
|
|
1177
1199
|
values: values
|
|
1178
1200
|
});
|
|
1201
|
+
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 || onUpdateThemeSuccess(values);
|
|
1179
1202
|
}
|
|
1180
1203
|
});
|
|
1181
1204
|
};
|
|
@@ -1511,11 +1534,13 @@ var Card = function Card(_ref) {
|
|
|
1511
1534
|
},
|
|
1512
1535
|
menuItems: [{
|
|
1513
1536
|
key: "edit",
|
|
1537
|
+
"data-cy": "edit-theme-menu-item",
|
|
1514
1538
|
label: t("neetoThemes.common.edit"),
|
|
1515
1539
|
isVisible: neetoCist.isPresent(onEditTheme),
|
|
1516
1540
|
onClick: handleEditTheme
|
|
1517
1541
|
}, {
|
|
1518
1542
|
key: "clone",
|
|
1543
|
+
"data-cy": "clone-theme-menu-item",
|
|
1519
1544
|
label: t("neetoThemes.build.leftSideBar.themes.themeOptions.clone"),
|
|
1520
1545
|
onClick: handleCloneTheme
|
|
1521
1546
|
}, {
|
|
@@ -1746,7 +1771,8 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1746
1771
|
var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
|
|
1747
1772
|
var thumbnail = _ref.thumbnail,
|
|
1748
1773
|
onPropertiesChange = _ref.onPropertiesChange,
|
|
1749
|
-
onApplyThemeSuccess = _ref.onApplyThemeSuccess
|
|
1774
|
+
onApplyThemeSuccess = _ref.onApplyThemeSuccess,
|
|
1775
|
+
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
|
|
1750
1776
|
var _useState = react.useState(DESIGN_SCREENS.THEMES),
|
|
1751
1777
|
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1752
1778
|
currentScreen = _useState2[0],
|
|
@@ -1813,7 +1839,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1813
1839
|
});
|
|
1814
1840
|
setThemeBeingApplied({});
|
|
1815
1841
|
setCurrentScreen(DESIGN_SCREENS.THEMES);
|
|
1816
|
-
onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess();
|
|
1842
|
+
onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(theme);
|
|
1817
1843
|
}
|
|
1818
1844
|
}),
|
|
1819
1845
|
applyTheme = _useApplyTheme.mutate,
|
|
@@ -1909,6 +1935,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1909
1935
|
onApplyTheme: onApplyTheme,
|
|
1910
1936
|
onCreateTheme: onCreateTheme,
|
|
1911
1937
|
onPropertiesChange: onPropertiesChange,
|
|
1938
|
+
onUpdateThemeSuccess: onUpdateThemeSuccess,
|
|
1912
1939
|
theme: themeToEdit.current,
|
|
1913
1940
|
themeId: (_themeToEdit$current2 = themeToEdit.current) === null || _themeToEdit$current2 === void 0 ? void 0 : _themeToEdit$current2.id
|
|
1914
1941
|
}), /*#__PURE__*/jsxRuntime.jsx(MemoizedAlert, {
|
|
@@ -1938,7 +1965,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1938
1965
|
_ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
|
|
1939
1966
|
isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes,
|
|
1940
1967
|
_ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
|
|
1941
|
-
onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? neetoCist.noop : _ref$onApplyThemeSucc
|
|
1968
|
+
onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? neetoCist.noop : _ref$onApplyThemeSucc,
|
|
1969
|
+
_ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
|
|
1970
|
+
onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? neetoCist.noop : _ref$onUpdateThemeSuc;
|
|
1942
1971
|
var _useThemeStore = useThemeStore(function (store) {
|
|
1943
1972
|
return {
|
|
1944
1973
|
setThemeState: store["setThemeState"]
|
|
@@ -1987,6 +2016,7 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1987
2016
|
children: [/*#__PURE__*/jsxRuntime.jsx(Sidebar, {
|
|
1988
2017
|
onApplyThemeSuccess: onApplyThemeSuccess,
|
|
1989
2018
|
onPropertiesChange: onPropertiesChange,
|
|
2019
|
+
onUpdateThemeSuccess: onUpdateThemeSuccess,
|
|
1990
2020
|
thumbnail: thumbnail
|
|
1991
2021
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1992
2022
|
className: "neeto-themes-preview__wrapper",
|