@bigbinary/neeto-themes-frontend 1.2.3 → 1.2.5
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 +299 -75
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +297 -76
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/types.d.ts +1 -0
package/dist/index.cjs.js
CHANGED
|
@@ -12,9 +12,9 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
|
12
12
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
13
13
|
var Alert = require('@bigbinary/neetoui/Alert');
|
|
14
14
|
var reactI18next = require('react-i18next');
|
|
15
|
-
require('@babel/runtime/helpers/asyncToGenerator');
|
|
16
|
-
require('@babel/runtime/regenerator');
|
|
17
|
-
require('@bigbinary/neetoui/Toastr');
|
|
15
|
+
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
16
|
+
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
17
|
+
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
18
18
|
var reactQuery = require('react-query');
|
|
19
19
|
var axios = require('axios');
|
|
20
20
|
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
@@ -30,8 +30,8 @@ var formik = require('formik');
|
|
|
30
30
|
var jsxRuntime = require('react/jsx-runtime');
|
|
31
31
|
var neetoImageUploaderFrontend = require('@bigbinary/neeto-image-uploader-frontend');
|
|
32
32
|
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
33
|
-
var ColorPicker = require('@bigbinary/neetoui/ColorPicker');
|
|
34
33
|
var Select = require('@bigbinary/neetoui/Select');
|
|
34
|
+
var ColorPicker = require('@bigbinary/neetoui/ColorPicker');
|
|
35
35
|
var antd = require('antd');
|
|
36
36
|
var Switch = require('@bigbinary/neetoui/Switch');
|
|
37
37
|
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
@@ -62,6 +62,9 @@ function _interopNamespace(e) {
|
|
|
62
62
|
var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner);
|
|
63
63
|
var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
|
|
64
64
|
var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
|
|
65
|
+
var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
|
|
66
|
+
var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
|
|
67
|
+
var Toastr__default = /*#__PURE__*/_interopDefaultLegacy(Toastr);
|
|
65
68
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
66
69
|
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_objectWithoutProperties);
|
|
67
70
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
@@ -70,8 +73,8 @@ var Popover__default = /*#__PURE__*/_interopDefaultLegacy(Popover);
|
|
|
70
73
|
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
|
|
71
74
|
var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form);
|
|
72
75
|
var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
|
|
73
|
-
var ColorPicker__default = /*#__PURE__*/_interopDefaultLegacy(ColorPicker);
|
|
74
76
|
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
|
77
|
+
var ColorPicker__default = /*#__PURE__*/_interopDefaultLegacy(ColorPicker);
|
|
75
78
|
var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
|
|
76
79
|
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
77
80
|
var Search__default = /*#__PURE__*/_interopDefaultLegacy(Search);
|
|
@@ -86,6 +89,7 @@ var useConfigStore = zustand.create(reactUtils.withImmutableActions(function (se
|
|
|
86
89
|
entityId: "",
|
|
87
90
|
variableNamesMap: {},
|
|
88
91
|
isFetchingSchema: true,
|
|
92
|
+
isTemplateThemesEnabled: false,
|
|
89
93
|
setConfigState: set
|
|
90
94
|
};
|
|
91
95
|
}));
|
|
@@ -100,6 +104,52 @@ var useThemeStore = zustand.create(reactUtils.withImmutableActions(function (set
|
|
|
100
104
|
};
|
|
101
105
|
}));
|
|
102
106
|
|
|
107
|
+
var getImageFromUrl = function getImageFromUrl(source) {
|
|
108
|
+
var image = new Image();
|
|
109
|
+
image.crossOrigin = "anonymous";
|
|
110
|
+
image.src = source;
|
|
111
|
+
return new Promise(function (resolve) {
|
|
112
|
+
image.onload = function () {
|
|
113
|
+
resolve(image);
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
var getDominantColorFromUrl = /*#__PURE__*/function () {
|
|
118
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(imageUrl) {
|
|
119
|
+
var image, context, c;
|
|
120
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
121
|
+
while (1) switch (_context.prev = _context.next) {
|
|
122
|
+
case 0:
|
|
123
|
+
_context.prev = 0;
|
|
124
|
+
_context.next = 3;
|
|
125
|
+
return getImageFromUrl(imageUrl);
|
|
126
|
+
case 3:
|
|
127
|
+
image = _context.sent;
|
|
128
|
+
context = document.createElement("canvas").getContext("2d");
|
|
129
|
+
context === null || context === void 0 || context.drawImage(image, 0, 0, 1, 1);
|
|
130
|
+
c = context === null || context === void 0 ? void 0 : context.getImageData(0, 0, 1, 1).data;
|
|
131
|
+
if (!c) {
|
|
132
|
+
_context.next = 9;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
return _context.abrupt("return", "#".concat(((1 << 24) + (c[0] << 16) + (c[1] << 8) + c[2]).toString(16).slice(1)));
|
|
136
|
+
case 9:
|
|
137
|
+
return _context.abrupt("return", null);
|
|
138
|
+
case 12:
|
|
139
|
+
_context.prev = 12;
|
|
140
|
+
_context.t0 = _context["catch"](0);
|
|
141
|
+
Toastr__default["default"].error(_context.t0);
|
|
142
|
+
return _context.abrupt("return", null);
|
|
143
|
+
case 16:
|
|
144
|
+
case "end":
|
|
145
|
+
return _context.stop();
|
|
146
|
+
}
|
|
147
|
+
}, _callee, null, [[0, 12]]);
|
|
148
|
+
}));
|
|
149
|
+
return function getDominantColorFromUrl(_x) {
|
|
150
|
+
return _ref.apply(this, arguments);
|
|
151
|
+
};
|
|
152
|
+
}();
|
|
103
153
|
var scrollElementIntoView = function scrollElementIntoView(elementId) {
|
|
104
154
|
var elementToScroll = document.getElementById(elementId);
|
|
105
155
|
elementToScroll === null || elementToScroll === void 0 || elementToScroll.scrollIntoView({
|
|
@@ -145,8 +195,12 @@ var useShowThemeEntity = function useShowThemeEntity(entityId) {
|
|
|
145
195
|
};
|
|
146
196
|
|
|
147
197
|
var _excluded$1 = ["themeId"];
|
|
148
|
-
var list$1 = function list() {
|
|
149
|
-
return axios__default["default"].get("".concat(BASE_URL, "/api/v1/themes")
|
|
198
|
+
var list$1 = function list(entityId) {
|
|
199
|
+
return axios__default["default"].get("".concat(BASE_URL, "/api/v1/themes"), {
|
|
200
|
+
params: {
|
|
201
|
+
entity_id: entityId
|
|
202
|
+
}
|
|
203
|
+
});
|
|
150
204
|
};
|
|
151
205
|
var show = function show(id) {
|
|
152
206
|
return axios__default["default"].get("".concat(BASE_URL, "/api/v1/themes/").concat(id));
|
|
@@ -186,8 +240,17 @@ var themesApi = {
|
|
|
186
240
|
apply: apply
|
|
187
241
|
};
|
|
188
242
|
|
|
189
|
-
var useListThemes = function useListThemes() {
|
|
190
|
-
|
|
243
|
+
var useListThemes = function useListThemes(entityId) {
|
|
244
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
245
|
+
return {
|
|
246
|
+
isTemplateThemesEnabled: store["isTemplateThemesEnabled"]
|
|
247
|
+
};
|
|
248
|
+
}, shallow.shallow),
|
|
249
|
+
isTemplateThemesEnabled = _useConfigStore.isTemplateThemesEnabled;
|
|
250
|
+
var queryKey = isTemplateThemesEnabled ? [QUERY_KEYS.THEMES_LIST, entityId] : [QUERY_KEYS.THEMES_LIST];
|
|
251
|
+
return reactQuery.useQuery(queryKey, function () {
|
|
252
|
+
return themesApi.list(entityId);
|
|
253
|
+
});
|
|
191
254
|
};
|
|
192
255
|
var useCreateTheme = function useCreateTheme() {
|
|
193
256
|
return reactUtils.useMutationWithInvalidation(themesApi.create, {
|
|
@@ -238,6 +301,8 @@ var setTheme = function setTheme(theme, variableNamesMap, themeConfig) {
|
|
|
238
301
|
var overlayOpacity = Number(property.value);
|
|
239
302
|
setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_opacity")), Math.abs(overlayOpacity / 100), variableNamesMap);
|
|
240
303
|
setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_color")), overlayOpacity < 0 ? BLACK : WHITE, variableNamesMap);
|
|
304
|
+
} else if (property.kind === "radius") {
|
|
305
|
+
setVariable(attribute, "".concat(property.value, "px"), variableNamesMap);
|
|
241
306
|
} else {
|
|
242
307
|
setVariable(attribute, property.value, variableNamesMap);
|
|
243
308
|
}
|
|
@@ -424,6 +489,12 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
424
489
|
kind: "slider",
|
|
425
490
|
key: key
|
|
426
491
|
};
|
|
492
|
+
case "radius":
|
|
493
|
+
return {
|
|
494
|
+
value: defaultValue,
|
|
495
|
+
kind: "radius",
|
|
496
|
+
key: key
|
|
497
|
+
};
|
|
427
498
|
case "boolean":
|
|
428
499
|
return {
|
|
429
500
|
value: String(defaultValue),
|
|
@@ -436,6 +507,12 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
436
507
|
kind: "position_selector",
|
|
437
508
|
key: key
|
|
438
509
|
};
|
|
510
|
+
case "alignment_block":
|
|
511
|
+
return {
|
|
512
|
+
value: defaultValue,
|
|
513
|
+
kind: "alignment_block",
|
|
514
|
+
key: key
|
|
515
|
+
};
|
|
439
516
|
default:
|
|
440
517
|
return null;
|
|
441
518
|
}
|
|
@@ -453,23 +530,26 @@ var buildImageData = function buildImageData(values, themePropertiesSchema) {
|
|
|
453
530
|
}, {});
|
|
454
531
|
};
|
|
455
532
|
var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
|
|
456
|
-
var _findBy;
|
|
457
533
|
var property = neetoCist.findBy({
|
|
458
534
|
key: key
|
|
459
535
|
}, themePropertiesSchema);
|
|
460
536
|
if (neetoCist.isNotPresent(property)) return false;
|
|
537
|
+
if (property !== null && property !== void 0 && property.hidden) return false;
|
|
461
538
|
var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
|
|
462
539
|
if (neetoCist.isNotPresent(conditionalKey)) return true;
|
|
463
|
-
var
|
|
540
|
+
var dependentPropertySchema = neetoCist.findBy({
|
|
464
541
|
key: conditionalKey
|
|
465
542
|
}, themePropertiesSchema);
|
|
466
|
-
|
|
543
|
+
var dependentProperty = neetoCist.findBy({
|
|
544
|
+
key: conditionalKey
|
|
545
|
+
}, formikValues.properties);
|
|
546
|
+
if (dependentPropertySchema.kind === "image") {
|
|
467
547
|
var _formikValues$snakeTo;
|
|
468
548
|
return neetoCist.isPresent((_formikValues$snakeTo = formikValues[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
|
|
549
|
+
} else if (dependentPropertySchema.kind === "boolean") {
|
|
550
|
+
return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
|
|
469
551
|
}
|
|
470
|
-
return neetoCist.isPresent(
|
|
471
|
-
key: conditionalKey
|
|
472
|
-
}, formikValues.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value);
|
|
552
|
+
return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
|
|
473
553
|
};
|
|
474
554
|
var buildLabel = function buildLabel(key, kind) {
|
|
475
555
|
return i18next.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
|
|
@@ -497,6 +577,32 @@ var Card$2 = function Card(_ref) {
|
|
|
497
577
|
});
|
|
498
578
|
};
|
|
499
579
|
|
|
580
|
+
var SelectBlock = function SelectBlock(_ref) {
|
|
581
|
+
var label = _ref.label,
|
|
582
|
+
_ref$placeholder = _ref.placeholder,
|
|
583
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
584
|
+
value = _ref.value,
|
|
585
|
+
options = _ref.options,
|
|
586
|
+
onChange = _ref.onChange;
|
|
587
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
588
|
+
className: "flex items-center justify-between py-3 first:pt-0 last:pb-0",
|
|
589
|
+
"data-cy": "theme-style-".concat(utils.joinHyphenCase(label)),
|
|
590
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
591
|
+
"data-cy": "logo-field-labels",
|
|
592
|
+
style: "body2",
|
|
593
|
+
children: label
|
|
594
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
595
|
+
className: "w-40",
|
|
596
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Select__default["default"], {
|
|
597
|
+
onChange: onChange,
|
|
598
|
+
options: options,
|
|
599
|
+
placeholder: placeholder,
|
|
600
|
+
value: value
|
|
601
|
+
})
|
|
602
|
+
})]
|
|
603
|
+
});
|
|
604
|
+
};
|
|
605
|
+
|
|
500
606
|
var DESIGN_SCREENS = {
|
|
501
607
|
THEMES: "Themes",
|
|
502
608
|
Customize: "Customize"
|
|
@@ -504,6 +610,7 @@ var DESIGN_SCREENS = {
|
|
|
504
610
|
var ONE_MEGABYTE = 1;
|
|
505
611
|
|
|
506
612
|
var ImageBlock = function ImageBlock(_ref) {
|
|
613
|
+
var _findBy;
|
|
507
614
|
var label = _ref.label,
|
|
508
615
|
name = _ref.name,
|
|
509
616
|
_ref$imageData = _ref.imageData,
|
|
@@ -511,22 +618,73 @@ var ImageBlock = function ImageBlock(_ref) {
|
|
|
511
618
|
_ref$uploadConfig = _ref.uploadConfig,
|
|
512
619
|
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
513
620
|
maxImageSize: ONE_MEGABYTE
|
|
514
|
-
} : _ref$uploadConfig
|
|
621
|
+
} : _ref$uploadConfig,
|
|
622
|
+
attribute = _ref.attribute;
|
|
623
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
624
|
+
t = _useTranslation.t;
|
|
515
625
|
var _useFormikContext = formik.useFormikContext(),
|
|
516
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
626
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
627
|
+
values = _useFormikContext.values;
|
|
628
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
629
|
+
return {
|
|
630
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
631
|
+
};
|
|
632
|
+
}, shallow.shallow),
|
|
633
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
634
|
+
var propertySchema = neetoCist.findBy({
|
|
635
|
+
key: attribute
|
|
636
|
+
}, themePropertiesSchema);
|
|
637
|
+
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
638
|
+
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
639
|
+
var positionKeyInSchema = neetoCist.findBy({
|
|
640
|
+
key: "".concat(name, "_position")
|
|
641
|
+
}, themePropertiesSchema);
|
|
642
|
+
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && neetoCist.isPresent(positionKeyInSchema);
|
|
643
|
+
var positionKeyIndex = neetoCist.findIndexBy({
|
|
644
|
+
key: "".concat(name, "_position")
|
|
645
|
+
}, values.properties);
|
|
646
|
+
var handleImageChange = /*#__PURE__*/function () {
|
|
647
|
+
var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(image) {
|
|
648
|
+
var dominantColor;
|
|
649
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
650
|
+
while (1) switch (_context.prev = _context.next) {
|
|
651
|
+
case 0:
|
|
652
|
+
_context.prev = 0;
|
|
653
|
+
if (!(ramda.isEmpty(image.signedId) || ramda.isEmpty(image.url))) {
|
|
654
|
+
_context.next = 4;
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
setFieldValue(name, {
|
|
658
|
+
signedId: null,
|
|
659
|
+
url: image.url
|
|
660
|
+
});
|
|
661
|
+
return _context.abrupt("return");
|
|
662
|
+
case 4:
|
|
663
|
+
_context.next = 6;
|
|
664
|
+
return getDominantColorFromUrl(image.url);
|
|
665
|
+
case 6:
|
|
666
|
+
dominantColor = _context.sent;
|
|
667
|
+
setFieldValue(name, {
|
|
668
|
+
signedId: image.signedId,
|
|
669
|
+
url: image.url,
|
|
670
|
+
dominantColor: dominantColor
|
|
671
|
+
});
|
|
672
|
+
_context.next = 13;
|
|
673
|
+
break;
|
|
674
|
+
case 10:
|
|
675
|
+
_context.prev = 10;
|
|
676
|
+
_context.t0 = _context["catch"](0);
|
|
677
|
+
Toastr__default["default"].error(_context.t0);
|
|
678
|
+
case 13:
|
|
679
|
+
case "end":
|
|
680
|
+
return _context.stop();
|
|
681
|
+
}
|
|
682
|
+
}, _callee, null, [[0, 10]]);
|
|
683
|
+
}));
|
|
684
|
+
return function handleImageChange(_x) {
|
|
685
|
+
return _ref2.apply(this, arguments);
|
|
686
|
+
};
|
|
687
|
+
}();
|
|
530
688
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
531
689
|
className: "space-y-3 py-3 first:pt-0 last:pb-0",
|
|
532
690
|
"data-cy": "theme-style-".concat(utils.joinHyphenCase(label)),
|
|
@@ -537,12 +695,25 @@ var ImageBlock = function ImageBlock(_ref) {
|
|
|
537
695
|
style: "body2",
|
|
538
696
|
children: label
|
|
539
697
|
})
|
|
540
|
-
}), /*#__PURE__*/
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
698
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
699
|
+
className: "space-y-3 divide-y divide-gray-200",
|
|
700
|
+
children: [/*#__PURE__*/react.createElement(neetoImageUploaderFrontend.ImageUploader, {
|
|
701
|
+
uploadConfig: uploadConfig,
|
|
702
|
+
className: "h-40 w-full",
|
|
703
|
+
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
704
|
+
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
705
|
+
onUploadComplete: handleImageChange
|
|
706
|
+
}), isPositionChangerVisible && /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
|
|
707
|
+
label: buildLabel("".concat(name, "Position"), "image"),
|
|
708
|
+
options: options || POSITION_OPTIONS,
|
|
709
|
+
placeholder: t("neetoThemes.common.left"),
|
|
710
|
+
value: neetoCist.toLabelAndValue((_findBy = neetoCist.findBy({
|
|
711
|
+
key: "".concat(name, "_position")
|
|
712
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value),
|
|
713
|
+
onChange: function onChange(option) {
|
|
714
|
+
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
715
|
+
}
|
|
716
|
+
})]
|
|
546
717
|
})]
|
|
547
718
|
});
|
|
548
719
|
};
|
|
@@ -559,6 +730,7 @@ var Images = function Images(_ref) {
|
|
|
559
730
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
560
731
|
className: "divide-y divide-gray-200",
|
|
561
732
|
children: /*#__PURE__*/jsxRuntime.jsx(ImageBlock, {
|
|
733
|
+
attribute: attribute,
|
|
562
734
|
imageData: imageData,
|
|
563
735
|
name: key
|
|
564
736
|
})
|
|
@@ -566,6 +738,54 @@ var Images = function Images(_ref) {
|
|
|
566
738
|
});
|
|
567
739
|
};
|
|
568
740
|
|
|
741
|
+
var AlignmentBlock = function AlignmentBlock(_ref) {
|
|
742
|
+
var label = _ref.label,
|
|
743
|
+
name = _ref.name;
|
|
744
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
745
|
+
className: "flex items-center justify-between gap-2 py-3 first:pt-0 last:pb-0",
|
|
746
|
+
"data-cy": utils.joinHyphenCase(label),
|
|
747
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
748
|
+
"data-cy": "style-fields-labels",
|
|
749
|
+
style: "body2",
|
|
750
|
+
children: label
|
|
751
|
+
}), /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
|
|
752
|
+
name: name,
|
|
753
|
+
children: function children(_ref2) {
|
|
754
|
+
var value = _ref2.field.value,
|
|
755
|
+
setFieldValue = _ref2.form.setFieldValue;
|
|
756
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
757
|
+
className: "flex items-center gap-3",
|
|
758
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
759
|
+
"data-cy": "alignment-left",
|
|
760
|
+
icon: neetoIcons.LeftAlign,
|
|
761
|
+
size: "large",
|
|
762
|
+
style: value === "left" ? "primary" : "text",
|
|
763
|
+
tooltipProps: {
|
|
764
|
+
content: "Left align",
|
|
765
|
+
position: "bottom"
|
|
766
|
+
},
|
|
767
|
+
onClick: function onClick() {
|
|
768
|
+
return setFieldValue(name, "left");
|
|
769
|
+
}
|
|
770
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
771
|
+
"data-cy": "alignment-center",
|
|
772
|
+
icon: neetoIcons.CenterAlign,
|
|
773
|
+
size: "large",
|
|
774
|
+
style: value === "center" ? "primary" : "text",
|
|
775
|
+
tooltipProps: {
|
|
776
|
+
content: "Center align",
|
|
777
|
+
position: "bottom"
|
|
778
|
+
},
|
|
779
|
+
onClick: function onClick() {
|
|
780
|
+
return setFieldValue(name, "center");
|
|
781
|
+
}
|
|
782
|
+
})]
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
})]
|
|
786
|
+
});
|
|
787
|
+
};
|
|
788
|
+
|
|
569
789
|
var ColorBlock = function ColorBlock(_ref) {
|
|
570
790
|
var label = _ref.label,
|
|
571
791
|
_ref$color = _ref.color,
|
|
@@ -625,32 +845,6 @@ var FontPickerBlock = function FontPickerBlock(_ref) {
|
|
|
625
845
|
});
|
|
626
846
|
};
|
|
627
847
|
|
|
628
|
-
var SelectBlock = function SelectBlock(_ref) {
|
|
629
|
-
var label = _ref.label,
|
|
630
|
-
_ref$placeholder = _ref.placeholder,
|
|
631
|
-
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
632
|
-
value = _ref.value,
|
|
633
|
-
options = _ref.options,
|
|
634
|
-
onChange = _ref.onChange;
|
|
635
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
636
|
-
className: "flex items-center justify-between py-3 first:pt-0 last:pb-0",
|
|
637
|
-
"data-cy": "theme-style-".concat(utils.joinHyphenCase(label)),
|
|
638
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
639
|
-
"data-cy": "logo-field-labels",
|
|
640
|
-
style: "body2",
|
|
641
|
-
children: label
|
|
642
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
643
|
-
className: "w-40",
|
|
644
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Select__default["default"], {
|
|
645
|
-
onChange: onChange,
|
|
646
|
-
options: options,
|
|
647
|
-
placeholder: placeholder,
|
|
648
|
-
value: value
|
|
649
|
-
})
|
|
650
|
-
})]
|
|
651
|
-
});
|
|
652
|
-
};
|
|
653
|
-
|
|
654
848
|
var SliderBlock = function SliderBlock(_ref) {
|
|
655
849
|
var label = _ref.label,
|
|
656
850
|
onChange = _ref.onChange,
|
|
@@ -747,7 +941,7 @@ var Properties = function Properties(_ref) {
|
|
|
747
941
|
}
|
|
748
942
|
};
|
|
749
943
|
react.useEffect(function () {
|
|
750
|
-
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values,
|
|
944
|
+
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values, handleChange, handleColorChange);
|
|
751
945
|
setTheme(values);
|
|
752
946
|
setThemeState({
|
|
753
947
|
previewingTheme: values
|
|
@@ -786,11 +980,26 @@ var Properties = function Properties(_ref) {
|
|
|
786
980
|
onChange: handleColorChange(key)
|
|
787
981
|
}, key);
|
|
788
982
|
}), neetoCist.filterBy({
|
|
789
|
-
kind: "
|
|
983
|
+
kind: "radius"
|
|
790
984
|
}, values.properties).map(function (_ref6) {
|
|
791
985
|
var key = _ref6.key,
|
|
792
986
|
value = _ref6.value,
|
|
793
987
|
kind = _ref6.kind;
|
|
988
|
+
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
|
|
989
|
+
label: buildLabel(key, kind),
|
|
990
|
+
max: 50,
|
|
991
|
+
min: 0,
|
|
992
|
+
value: Number(value) || 0,
|
|
993
|
+
onChange: function onChange(radius) {
|
|
994
|
+
return handleChange(key, radius, "".concat(radius, "px"));
|
|
995
|
+
}
|
|
996
|
+
}, key);
|
|
997
|
+
}), neetoCist.filterBy({
|
|
998
|
+
kind: "overlay_opacity"
|
|
999
|
+
}, values.properties).map(function (_ref7) {
|
|
1000
|
+
var key = _ref7.key,
|
|
1001
|
+
value = _ref7.value,
|
|
1002
|
+
kind = _ref7.kind;
|
|
794
1003
|
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
|
|
795
1004
|
label: buildLabel(key, kind),
|
|
796
1005
|
marks: OVERLAY_OPACITY_SLIDER_MARKS,
|
|
@@ -803,11 +1012,11 @@ var Properties = function Properties(_ref) {
|
|
|
803
1012
|
}, key);
|
|
804
1013
|
}), neetoCist.filterBy({
|
|
805
1014
|
kind: "position_selector"
|
|
806
|
-
}, values.properties).map(function (
|
|
1015
|
+
}, values.properties).map(function (_ref8) {
|
|
807
1016
|
var _findBy;
|
|
808
|
-
var key =
|
|
809
|
-
kind =
|
|
810
|
-
value =
|
|
1017
|
+
var key = _ref8.key,
|
|
1018
|
+
kind = _ref8.kind,
|
|
1019
|
+
value = _ref8.value;
|
|
811
1020
|
var index = neetoCist.findIndexBy({
|
|
812
1021
|
key: key
|
|
813
1022
|
}, values.properties);
|
|
@@ -825,10 +1034,10 @@ var Properties = function Properties(_ref) {
|
|
|
825
1034
|
}, key);
|
|
826
1035
|
}), neetoCist.filterBy({
|
|
827
1036
|
kind: "boolean"
|
|
828
|
-
}, values.properties).map(function (
|
|
829
|
-
var key =
|
|
830
|
-
kind =
|
|
831
|
-
value =
|
|
1037
|
+
}, values.properties).map(function (_ref9) {
|
|
1038
|
+
var key = _ref9.key,
|
|
1039
|
+
kind = _ref9.kind,
|
|
1040
|
+
value = _ref9.value;
|
|
832
1041
|
var index = neetoCist.findIndexBy({
|
|
833
1042
|
key: key
|
|
834
1043
|
}, values.properties);
|
|
@@ -839,6 +1048,18 @@ var Properties = function Properties(_ref) {
|
|
|
839
1048
|
return setFieldValue("properties[".concat(index, "].value"), String(e.target.checked));
|
|
840
1049
|
}
|
|
841
1050
|
}, key);
|
|
1051
|
+
}), neetoCist.filterBy({
|
|
1052
|
+
kind: "alignment_block"
|
|
1053
|
+
}, values.properties).map(function (_ref10) {
|
|
1054
|
+
var key = _ref10.key,
|
|
1055
|
+
kind = _ref10.kind;
|
|
1056
|
+
var index = neetoCist.findIndexBy({
|
|
1057
|
+
key: key
|
|
1058
|
+
}, values.properties);
|
|
1059
|
+
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(AlignmentBlock, {
|
|
1060
|
+
label: buildLabel(key, kind),
|
|
1061
|
+
name: "properties[".concat(index, "].value")
|
|
1062
|
+
});
|
|
842
1063
|
})]
|
|
843
1064
|
})
|
|
844
1065
|
});
|
|
@@ -1514,7 +1735,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1514
1735
|
t = _useTranslation.t;
|
|
1515
1736
|
var _useThemeUtils = useThemeUtils(),
|
|
1516
1737
|
setTheme = _useThemeUtils.setTheme;
|
|
1517
|
-
var _useListThemes = useListThemes(),
|
|
1738
|
+
var _useListThemes = useListThemes(entityId),
|
|
1518
1739
|
_useListThemes$data = _useListThemes.data,
|
|
1519
1740
|
_useListThemes$data2 = _useListThemes$data === void 0 ? {} : _useListThemes$data,
|
|
1520
1741
|
_useListThemes$data2$ = _useListThemes$data2.themes,
|
|
@@ -1667,7 +1888,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1667
1888
|
entityType = _ref.entityType,
|
|
1668
1889
|
entityId = _ref.entityId,
|
|
1669
1890
|
thumbnail = _ref.thumbnail,
|
|
1670
|
-
onPropertiesChange = _ref.onPropertiesChange
|
|
1891
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
1892
|
+
_ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
|
|
1893
|
+
isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes;
|
|
1671
1894
|
var _useThemeStore = useThemeStore(function (store) {
|
|
1672
1895
|
return {
|
|
1673
1896
|
isCurrentThemeLoading: store["isCurrentThemeLoading"]
|
|
@@ -1683,7 +1906,8 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1683
1906
|
react.useEffect(function () {
|
|
1684
1907
|
setConfigState({
|
|
1685
1908
|
entityType: entityType,
|
|
1686
|
-
entityId: entityId
|
|
1909
|
+
entityId: entityId,
|
|
1910
|
+
isTemplateThemesEnabled: isTemplateThemesEnabled
|
|
1687
1911
|
});
|
|
1688
1912
|
}, []);
|
|
1689
1913
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|