@bigbinary/neeto-themes-frontend 1.2.2 → 1.2.4
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/app/javascript/src/translations/en.json +1 -1
- package/dist/index.cjs.js +305 -94
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +303 -95
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"primary": "Primary",
|
|
54
54
|
"secondary": "Secondary"
|
|
55
55
|
},
|
|
56
|
-
"notAppliedYet": "This theme is <bold>not yet applied</bold> to this {{entityType
|
|
56
|
+
"notAppliedYet": "This theme is <bold>not yet applied</bold> to this {{entityType}}.",
|
|
57
57
|
"editTheme": {
|
|
58
58
|
"title": "Edit theme",
|
|
59
59
|
"imageUpload": "Drag and drop or <span>Browse</span> a file"
|
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);
|
|
@@ -100,6 +103,52 @@ var useThemeStore = zustand.create(reactUtils.withImmutableActions(function (set
|
|
|
100
103
|
};
|
|
101
104
|
}));
|
|
102
105
|
|
|
106
|
+
var getImageFromUrl = function getImageFromUrl(source) {
|
|
107
|
+
var image = new Image();
|
|
108
|
+
image.crossOrigin = "anonymous";
|
|
109
|
+
image.src = source;
|
|
110
|
+
return new Promise(function (resolve) {
|
|
111
|
+
image.onload = function () {
|
|
112
|
+
resolve(image);
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
var getDominantColorFromUrl = /*#__PURE__*/function () {
|
|
117
|
+
var _ref = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(imageUrl) {
|
|
118
|
+
var image, context, c;
|
|
119
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
120
|
+
while (1) switch (_context.prev = _context.next) {
|
|
121
|
+
case 0:
|
|
122
|
+
_context.prev = 0;
|
|
123
|
+
_context.next = 3;
|
|
124
|
+
return getImageFromUrl(imageUrl);
|
|
125
|
+
case 3:
|
|
126
|
+
image = _context.sent;
|
|
127
|
+
context = document.createElement("canvas").getContext("2d");
|
|
128
|
+
context === null || context === void 0 || context.drawImage(image, 0, 0, 1, 1);
|
|
129
|
+
c = context === null || context === void 0 ? void 0 : context.getImageData(0, 0, 1, 1).data;
|
|
130
|
+
if (!c) {
|
|
131
|
+
_context.next = 9;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
return _context.abrupt("return", "#".concat(((1 << 24) + (c[0] << 16) + (c[1] << 8) + c[2]).toString(16).slice(1)));
|
|
135
|
+
case 9:
|
|
136
|
+
return _context.abrupt("return", null);
|
|
137
|
+
case 12:
|
|
138
|
+
_context.prev = 12;
|
|
139
|
+
_context.t0 = _context["catch"](0);
|
|
140
|
+
Toastr__default["default"].error(_context.t0);
|
|
141
|
+
return _context.abrupt("return", null);
|
|
142
|
+
case 16:
|
|
143
|
+
case "end":
|
|
144
|
+
return _context.stop();
|
|
145
|
+
}
|
|
146
|
+
}, _callee, null, [[0, 12]]);
|
|
147
|
+
}));
|
|
148
|
+
return function getDominantColorFromUrl(_x) {
|
|
149
|
+
return _ref.apply(this, arguments);
|
|
150
|
+
};
|
|
151
|
+
}();
|
|
103
152
|
var scrollElementIntoView = function scrollElementIntoView(elementId) {
|
|
104
153
|
var elementToScroll = document.getElementById(elementId);
|
|
105
154
|
elementToScroll === null || elementToScroll === void 0 || elementToScroll.scrollIntoView({
|
|
@@ -238,6 +287,8 @@ var setTheme = function setTheme(theme, variableNamesMap, themeConfig) {
|
|
|
238
287
|
var overlayOpacity = Number(property.value);
|
|
239
288
|
setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_opacity")), Math.abs(overlayOpacity / 100), variableNamesMap);
|
|
240
289
|
setVariable(neetoCist.snakeToCamelCase("".concat(property.key, "_overlay_color")), overlayOpacity < 0 ? BLACK : WHITE, variableNamesMap);
|
|
290
|
+
} else if (property.kind === "radius") {
|
|
291
|
+
setVariable(attribute, "".concat(property.value, "px"), variableNamesMap);
|
|
241
292
|
} else {
|
|
242
293
|
setVariable(attribute, property.value, variableNamesMap);
|
|
243
294
|
}
|
|
@@ -424,6 +475,12 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
424
475
|
kind: "slider",
|
|
425
476
|
key: key
|
|
426
477
|
};
|
|
478
|
+
case "radius":
|
|
479
|
+
return {
|
|
480
|
+
value: defaultValue,
|
|
481
|
+
kind: "radius",
|
|
482
|
+
key: key
|
|
483
|
+
};
|
|
427
484
|
case "boolean":
|
|
428
485
|
return {
|
|
429
486
|
value: String(defaultValue),
|
|
@@ -436,6 +493,12 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
436
493
|
kind: "position_selector",
|
|
437
494
|
key: key
|
|
438
495
|
};
|
|
496
|
+
case "alignment_block":
|
|
497
|
+
return {
|
|
498
|
+
value: defaultValue,
|
|
499
|
+
kind: "alignment_block",
|
|
500
|
+
key: key
|
|
501
|
+
};
|
|
439
502
|
default:
|
|
440
503
|
return null;
|
|
441
504
|
}
|
|
@@ -453,23 +516,26 @@ var buildImageData = function buildImageData(values, themePropertiesSchema) {
|
|
|
453
516
|
}, {});
|
|
454
517
|
};
|
|
455
518
|
var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
|
|
456
|
-
var _findBy;
|
|
457
519
|
var property = neetoCist.findBy({
|
|
458
520
|
key: key
|
|
459
521
|
}, themePropertiesSchema);
|
|
460
522
|
if (neetoCist.isNotPresent(property)) return false;
|
|
523
|
+
if (property !== null && property !== void 0 && property.hidden) return false;
|
|
461
524
|
var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
|
|
462
525
|
if (neetoCist.isNotPresent(conditionalKey)) return true;
|
|
463
|
-
var
|
|
526
|
+
var dependentPropertySchema = neetoCist.findBy({
|
|
464
527
|
key: conditionalKey
|
|
465
528
|
}, themePropertiesSchema);
|
|
466
|
-
|
|
529
|
+
var dependentProperty = neetoCist.findBy({
|
|
530
|
+
key: conditionalKey
|
|
531
|
+
}, formikValues.properties);
|
|
532
|
+
if (dependentPropertySchema.kind === "image") {
|
|
467
533
|
var _formikValues$snakeTo;
|
|
468
534
|
return neetoCist.isPresent((_formikValues$snakeTo = formikValues[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
|
|
535
|
+
} else if (dependentPropertySchema.kind === "boolean") {
|
|
536
|
+
return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
|
|
469
537
|
}
|
|
470
|
-
return neetoCist.isPresent(
|
|
471
|
-
key: conditionalKey
|
|
472
|
-
}, formikValues.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value);
|
|
538
|
+
return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
|
|
473
539
|
};
|
|
474
540
|
var buildLabel = function buildLabel(key, kind) {
|
|
475
541
|
return i18next.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
|
|
@@ -497,6 +563,32 @@ var Card$2 = function Card(_ref) {
|
|
|
497
563
|
});
|
|
498
564
|
};
|
|
499
565
|
|
|
566
|
+
var SelectBlock = function SelectBlock(_ref) {
|
|
567
|
+
var label = _ref.label,
|
|
568
|
+
_ref$placeholder = _ref.placeholder,
|
|
569
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
570
|
+
value = _ref.value,
|
|
571
|
+
options = _ref.options,
|
|
572
|
+
onChange = _ref.onChange;
|
|
573
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
574
|
+
className: "flex items-center justify-between py-3 first:pt-0 last:pb-0",
|
|
575
|
+
"data-cy": "theme-style-".concat(utils.joinHyphenCase(label)),
|
|
576
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
577
|
+
"data-cy": "logo-field-labels",
|
|
578
|
+
style: "body2",
|
|
579
|
+
children: label
|
|
580
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
581
|
+
className: "w-40",
|
|
582
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Select__default["default"], {
|
|
583
|
+
onChange: onChange,
|
|
584
|
+
options: options,
|
|
585
|
+
placeholder: placeholder,
|
|
586
|
+
value: value
|
|
587
|
+
})
|
|
588
|
+
})]
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
|
|
500
592
|
var DESIGN_SCREENS = {
|
|
501
593
|
THEMES: "Themes",
|
|
502
594
|
Customize: "Customize"
|
|
@@ -504,6 +596,7 @@ var DESIGN_SCREENS = {
|
|
|
504
596
|
var ONE_MEGABYTE = 1;
|
|
505
597
|
|
|
506
598
|
var ImageBlock = function ImageBlock(_ref) {
|
|
599
|
+
var _findBy;
|
|
507
600
|
var label = _ref.label,
|
|
508
601
|
name = _ref.name,
|
|
509
602
|
_ref$imageData = _ref.imageData,
|
|
@@ -511,22 +604,73 @@ var ImageBlock = function ImageBlock(_ref) {
|
|
|
511
604
|
_ref$uploadConfig = _ref.uploadConfig,
|
|
512
605
|
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
513
606
|
maxImageSize: ONE_MEGABYTE
|
|
514
|
-
} : _ref$uploadConfig
|
|
607
|
+
} : _ref$uploadConfig,
|
|
608
|
+
attribute = _ref.attribute;
|
|
609
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
610
|
+
t = _useTranslation.t;
|
|
515
611
|
var _useFormikContext = formik.useFormikContext(),
|
|
516
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
612
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
613
|
+
values = _useFormikContext.values;
|
|
614
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
615
|
+
return {
|
|
616
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
617
|
+
};
|
|
618
|
+
}, shallow.shallow),
|
|
619
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
620
|
+
var propertySchema = neetoCist.findBy({
|
|
621
|
+
key: attribute
|
|
622
|
+
}, themePropertiesSchema);
|
|
623
|
+
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
624
|
+
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
625
|
+
var positionKeyInSchema = neetoCist.findBy({
|
|
626
|
+
key: "".concat(name, "_position")
|
|
627
|
+
}, themePropertiesSchema);
|
|
628
|
+
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && neetoCist.isPresent(positionKeyInSchema);
|
|
629
|
+
var positionKeyIndex = neetoCist.findIndexBy({
|
|
630
|
+
key: "".concat(name, "_position")
|
|
631
|
+
}, values.properties);
|
|
632
|
+
var handleImageChange = /*#__PURE__*/function () {
|
|
633
|
+
var _ref2 = _asyncToGenerator__default["default"]( /*#__PURE__*/_regeneratorRuntime__default["default"].mark(function _callee(image) {
|
|
634
|
+
var dominantColor;
|
|
635
|
+
return _regeneratorRuntime__default["default"].wrap(function _callee$(_context) {
|
|
636
|
+
while (1) switch (_context.prev = _context.next) {
|
|
637
|
+
case 0:
|
|
638
|
+
_context.prev = 0;
|
|
639
|
+
if (!(ramda.isEmpty(image.signedId) || ramda.isEmpty(image.url))) {
|
|
640
|
+
_context.next = 4;
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
setFieldValue(name, {
|
|
644
|
+
signedId: null,
|
|
645
|
+
url: image.url
|
|
646
|
+
});
|
|
647
|
+
return _context.abrupt("return");
|
|
648
|
+
case 4:
|
|
649
|
+
_context.next = 6;
|
|
650
|
+
return getDominantColorFromUrl(image.url);
|
|
651
|
+
case 6:
|
|
652
|
+
dominantColor = _context.sent;
|
|
653
|
+
setFieldValue(name, {
|
|
654
|
+
signedId: image.signedId,
|
|
655
|
+
url: image.url,
|
|
656
|
+
dominantColor: dominantColor
|
|
657
|
+
});
|
|
658
|
+
_context.next = 13;
|
|
659
|
+
break;
|
|
660
|
+
case 10:
|
|
661
|
+
_context.prev = 10;
|
|
662
|
+
_context.t0 = _context["catch"](0);
|
|
663
|
+
Toastr__default["default"].error(_context.t0);
|
|
664
|
+
case 13:
|
|
665
|
+
case "end":
|
|
666
|
+
return _context.stop();
|
|
667
|
+
}
|
|
668
|
+
}, _callee, null, [[0, 10]]);
|
|
669
|
+
}));
|
|
670
|
+
return function handleImageChange(_x) {
|
|
671
|
+
return _ref2.apply(this, arguments);
|
|
672
|
+
};
|
|
673
|
+
}();
|
|
530
674
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
531
675
|
className: "space-y-3 py-3 first:pt-0 last:pb-0",
|
|
532
676
|
"data-cy": "theme-style-".concat(utils.joinHyphenCase(label)),
|
|
@@ -537,12 +681,25 @@ var ImageBlock = function ImageBlock(_ref) {
|
|
|
537
681
|
style: "body2",
|
|
538
682
|
children: label
|
|
539
683
|
})
|
|
540
|
-
}), /*#__PURE__*/
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
684
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
685
|
+
className: "space-y-3 divide-y divide-gray-200",
|
|
686
|
+
children: [/*#__PURE__*/react.createElement(neetoImageUploaderFrontend.ImageUploader, {
|
|
687
|
+
uploadConfig: uploadConfig,
|
|
688
|
+
className: "h-40 w-full",
|
|
689
|
+
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
690
|
+
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
691
|
+
onUploadComplete: handleImageChange
|
|
692
|
+
}), isPositionChangerVisible && /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
|
|
693
|
+
label: buildLabel("".concat(name, "Position"), "image"),
|
|
694
|
+
options: options || POSITION_OPTIONS,
|
|
695
|
+
placeholder: t("neetoThemes.common.left"),
|
|
696
|
+
value: neetoCist.toLabelAndValue((_findBy = neetoCist.findBy({
|
|
697
|
+
key: "".concat(name, "_position")
|
|
698
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value),
|
|
699
|
+
onChange: function onChange(option) {
|
|
700
|
+
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
701
|
+
}
|
|
702
|
+
})]
|
|
546
703
|
})]
|
|
547
704
|
});
|
|
548
705
|
};
|
|
@@ -559,6 +716,7 @@ var Images = function Images(_ref) {
|
|
|
559
716
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
560
717
|
className: "divide-y divide-gray-200",
|
|
561
718
|
children: /*#__PURE__*/jsxRuntime.jsx(ImageBlock, {
|
|
719
|
+
attribute: attribute,
|
|
562
720
|
imageData: imageData,
|
|
563
721
|
name: key
|
|
564
722
|
})
|
|
@@ -566,6 +724,54 @@ var Images = function Images(_ref) {
|
|
|
566
724
|
});
|
|
567
725
|
};
|
|
568
726
|
|
|
727
|
+
var AlignmentBlock = function AlignmentBlock(_ref) {
|
|
728
|
+
var label = _ref.label,
|
|
729
|
+
name = _ref.name;
|
|
730
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
731
|
+
className: "flex items-center justify-between gap-2 py-3 first:pt-0 last:pb-0",
|
|
732
|
+
"data-cy": utils.joinHyphenCase(label),
|
|
733
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
|
|
734
|
+
"data-cy": "style-fields-labels",
|
|
735
|
+
style: "body2",
|
|
736
|
+
children: label
|
|
737
|
+
}), /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
|
|
738
|
+
name: name,
|
|
739
|
+
children: function children(_ref2) {
|
|
740
|
+
var value = _ref2.field.value,
|
|
741
|
+
setFieldValue = _ref2.form.setFieldValue;
|
|
742
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
743
|
+
className: "flex items-center gap-3",
|
|
744
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
745
|
+
"data-cy": "alignment-left",
|
|
746
|
+
icon: neetoIcons.LeftAlign,
|
|
747
|
+
size: "large",
|
|
748
|
+
style: value === "left" ? "primary" : "text",
|
|
749
|
+
tooltipProps: {
|
|
750
|
+
content: "Left align",
|
|
751
|
+
position: "bottom"
|
|
752
|
+
},
|
|
753
|
+
onClick: function onClick() {
|
|
754
|
+
return setFieldValue(name, "left");
|
|
755
|
+
}
|
|
756
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
757
|
+
"data-cy": "alignment-center",
|
|
758
|
+
icon: neetoIcons.CenterAlign,
|
|
759
|
+
size: "large",
|
|
760
|
+
style: value === "center" ? "primary" : "text",
|
|
761
|
+
tooltipProps: {
|
|
762
|
+
content: "Center align",
|
|
763
|
+
position: "bottom"
|
|
764
|
+
},
|
|
765
|
+
onClick: function onClick() {
|
|
766
|
+
return setFieldValue(name, "center");
|
|
767
|
+
}
|
|
768
|
+
})]
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
})]
|
|
772
|
+
});
|
|
773
|
+
};
|
|
774
|
+
|
|
569
775
|
var ColorBlock = function ColorBlock(_ref) {
|
|
570
776
|
var label = _ref.label,
|
|
571
777
|
_ref$color = _ref.color,
|
|
@@ -625,32 +831,6 @@ var FontPickerBlock = function FontPickerBlock(_ref) {
|
|
|
625
831
|
});
|
|
626
832
|
};
|
|
627
833
|
|
|
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
834
|
var SliderBlock = function SliderBlock(_ref) {
|
|
655
835
|
var label = _ref.label,
|
|
656
836
|
onChange = _ref.onChange,
|
|
@@ -697,17 +877,16 @@ var SwitchBlock = function SwitchBlock(_ref) {
|
|
|
697
877
|
});
|
|
698
878
|
};
|
|
699
879
|
|
|
700
|
-
var Properties = function Properties() {
|
|
880
|
+
var Properties = function Properties(_ref) {
|
|
881
|
+
var onPropertiesChange = _ref.onPropertiesChange;
|
|
701
882
|
var _useTranslation = reactI18next.useTranslation(),
|
|
702
883
|
t = _useTranslation.t;
|
|
703
884
|
var _useConfigStore = useConfigStore(function (store) {
|
|
704
885
|
return {
|
|
705
|
-
themePropertiesSchema: store["themePropertiesSchema"]
|
|
706
|
-
onPropertiesChange: store["onPropertiesChange"]
|
|
886
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
707
887
|
};
|
|
708
888
|
}, shallow.shallow),
|
|
709
|
-
themePropertiesSchema = _useConfigStore.themePropertiesSchema
|
|
710
|
-
onPropertiesChange = _useConfigStore.onPropertiesChange;
|
|
889
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
711
890
|
var _useThemeStore = useThemeStore(function (store) {
|
|
712
891
|
return {
|
|
713
892
|
setThemeState: store["setThemeState"]
|
|
@@ -721,9 +900,9 @@ var Properties = function Properties() {
|
|
|
721
900
|
setVariable = _useThemeUtils.setVariable,
|
|
722
901
|
setTheme = _useThemeUtils.setTheme;
|
|
723
902
|
var handleColorChange = function handleColorChange(name) {
|
|
724
|
-
return function (
|
|
725
|
-
var hex =
|
|
726
|
-
rgb =
|
|
903
|
+
return function (_ref2) {
|
|
904
|
+
var hex = _ref2.hex,
|
|
905
|
+
rgb = _ref2.rgb;
|
|
727
906
|
handleChange(name, hex, "".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a));
|
|
728
907
|
};
|
|
729
908
|
};
|
|
@@ -748,7 +927,7 @@ var Properties = function Properties() {
|
|
|
748
927
|
}
|
|
749
928
|
};
|
|
750
929
|
react.useEffect(function () {
|
|
751
|
-
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values,
|
|
930
|
+
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values, handleChange, handleColorChange);
|
|
752
931
|
setTheme(values);
|
|
753
932
|
setThemeState({
|
|
754
933
|
previewingTheme: values
|
|
@@ -760,38 +939,53 @@ var Properties = function Properties() {
|
|
|
760
939
|
className: "divide-y divide-gray-200",
|
|
761
940
|
children: [neetoCist.filterBy({
|
|
762
941
|
kind: "font_family"
|
|
763
|
-
}, values.properties).map(function (
|
|
764
|
-
var key =
|
|
765
|
-
value =
|
|
766
|
-
kind =
|
|
942
|
+
}, values.properties).map(function (_ref3) {
|
|
943
|
+
var key = _ref3.key,
|
|
944
|
+
value = _ref3.value,
|
|
945
|
+
kind = _ref3.kind;
|
|
767
946
|
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(FontPickerBlock, {
|
|
768
947
|
label: buildLabel(key, kind),
|
|
769
948
|
options: FONT_OPTIONS,
|
|
770
949
|
value: neetoCist.findBy({
|
|
771
950
|
value: value || null
|
|
772
951
|
}, FONT_OPTIONS),
|
|
773
|
-
onChange: function onChange(
|
|
774
|
-
var value =
|
|
952
|
+
onChange: function onChange(_ref4) {
|
|
953
|
+
var value = _ref4.value;
|
|
775
954
|
handleChange(key, value);
|
|
776
955
|
}
|
|
777
956
|
}, key);
|
|
778
957
|
}), neetoCist.filterBy({
|
|
779
958
|
kind: "color"
|
|
780
|
-
}, values.properties).map(function (
|
|
781
|
-
var key =
|
|
782
|
-
value =
|
|
783
|
-
kind =
|
|
959
|
+
}, values.properties).map(function (_ref5) {
|
|
960
|
+
var key = _ref5.key,
|
|
961
|
+
value = _ref5.value,
|
|
962
|
+
kind = _ref5.kind;
|
|
784
963
|
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(ColorBlock, {
|
|
785
964
|
color: value,
|
|
786
965
|
label: buildLabel(key, kind),
|
|
787
966
|
onChange: handleColorChange(key)
|
|
788
967
|
}, key);
|
|
968
|
+
}), neetoCist.filterBy({
|
|
969
|
+
kind: "radius"
|
|
970
|
+
}, values.properties).map(function (_ref6) {
|
|
971
|
+
var key = _ref6.key,
|
|
972
|
+
value = _ref6.value,
|
|
973
|
+
kind = _ref6.kind;
|
|
974
|
+
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
|
|
975
|
+
label: buildLabel(key, kind),
|
|
976
|
+
max: 50,
|
|
977
|
+
min: 0,
|
|
978
|
+
value: Number(value) || 0,
|
|
979
|
+
onChange: function onChange(radius) {
|
|
980
|
+
return handleChange(key, radius, "".concat(radius, "px"));
|
|
981
|
+
}
|
|
982
|
+
}, key);
|
|
789
983
|
}), neetoCist.filterBy({
|
|
790
984
|
kind: "overlay_opacity"
|
|
791
|
-
}, values.properties).map(function (
|
|
792
|
-
var key =
|
|
793
|
-
value =
|
|
794
|
-
kind =
|
|
985
|
+
}, values.properties).map(function (_ref7) {
|
|
986
|
+
var key = _ref7.key,
|
|
987
|
+
value = _ref7.value,
|
|
988
|
+
kind = _ref7.kind;
|
|
795
989
|
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
|
|
796
990
|
label: buildLabel(key, kind),
|
|
797
991
|
marks: OVERLAY_OPACITY_SLIDER_MARKS,
|
|
@@ -804,11 +998,11 @@ var Properties = function Properties() {
|
|
|
804
998
|
}, key);
|
|
805
999
|
}), neetoCist.filterBy({
|
|
806
1000
|
kind: "position_selector"
|
|
807
|
-
}, values.properties).map(function (
|
|
1001
|
+
}, values.properties).map(function (_ref8) {
|
|
808
1002
|
var _findBy;
|
|
809
|
-
var key =
|
|
810
|
-
kind =
|
|
811
|
-
value =
|
|
1003
|
+
var key = _ref8.key,
|
|
1004
|
+
kind = _ref8.kind,
|
|
1005
|
+
value = _ref8.value;
|
|
812
1006
|
var index = neetoCist.findIndexBy({
|
|
813
1007
|
key: key
|
|
814
1008
|
}, values.properties);
|
|
@@ -826,10 +1020,10 @@ var Properties = function Properties() {
|
|
|
826
1020
|
}, key);
|
|
827
1021
|
}), neetoCist.filterBy({
|
|
828
1022
|
kind: "boolean"
|
|
829
|
-
}, values.properties).map(function (
|
|
830
|
-
var key =
|
|
831
|
-
kind =
|
|
832
|
-
value =
|
|
1023
|
+
}, values.properties).map(function (_ref9) {
|
|
1024
|
+
var key = _ref9.key,
|
|
1025
|
+
kind = _ref9.kind,
|
|
1026
|
+
value = _ref9.value;
|
|
833
1027
|
var index = neetoCist.findIndexBy({
|
|
834
1028
|
key: key
|
|
835
1029
|
}, values.properties);
|
|
@@ -840,6 +1034,18 @@ var Properties = function Properties() {
|
|
|
840
1034
|
return setFieldValue("properties[".concat(index, "].value"), String(e.target.checked));
|
|
841
1035
|
}
|
|
842
1036
|
}, key);
|
|
1037
|
+
}), neetoCist.filterBy({
|
|
1038
|
+
kind: "alignment_block"
|
|
1039
|
+
}, values.properties).map(function (_ref10) {
|
|
1040
|
+
var key = _ref10.key,
|
|
1041
|
+
kind = _ref10.kind;
|
|
1042
|
+
var index = neetoCist.findIndexBy({
|
|
1043
|
+
key: key
|
|
1044
|
+
}, values.properties);
|
|
1045
|
+
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsxRuntime.jsx(AlignmentBlock, {
|
|
1046
|
+
label: buildLabel(key, kind),
|
|
1047
|
+
name: "properties[".concat(index, "].value")
|
|
1048
|
+
});
|
|
843
1049
|
})]
|
|
844
1050
|
})
|
|
845
1051
|
});
|
|
@@ -864,7 +1070,8 @@ var Customize = function Customize(_ref) {
|
|
|
864
1070
|
theme = _ref.theme,
|
|
865
1071
|
onCreateTheme = _ref.onCreateTheme,
|
|
866
1072
|
onApplyTheme = _ref.onApplyTheme,
|
|
867
|
-
isApplyingTheme = _ref.isApplyingTheme
|
|
1073
|
+
isApplyingTheme = _ref.isApplyingTheme,
|
|
1074
|
+
onPropertiesChange = _ref.onPropertiesChange;
|
|
868
1075
|
var _useTranslation = reactI18next.useTranslation(),
|
|
869
1076
|
t = _useTranslation.t;
|
|
870
1077
|
var _useState = react.useState({}),
|
|
@@ -928,7 +1135,9 @@ var Customize = function Customize(_ref) {
|
|
|
928
1135
|
className: "neeto-themes-sidebar__scroll",
|
|
929
1136
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
930
1137
|
className: "flex flex-col gap-6 p-4",
|
|
931
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(ThemeMeta, {}), /*#__PURE__*/jsxRuntime.jsx(Properties, {
|
|
1138
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ThemeMeta, {}), /*#__PURE__*/jsxRuntime.jsx(Properties, {
|
|
1139
|
+
onPropertiesChange: onPropertiesChange
|
|
1140
|
+
}), neetoCist.filterBy({
|
|
932
1141
|
kind: "image"
|
|
933
1142
|
}, themePropertiesSchema).map(function (_ref5) {
|
|
934
1143
|
var key = _ref5.key;
|
|
@@ -1473,7 +1682,8 @@ var TitleBar = function TitleBar(_ref) {
|
|
|
1473
1682
|
var MemoizedAlert = /*#__PURE__*/react.memo(Alert__default["default"]);
|
|
1474
1683
|
var Sidebar = function Sidebar(_ref) {
|
|
1475
1684
|
var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3;
|
|
1476
|
-
var thumbnail = _ref.thumbnail
|
|
1685
|
+
var thumbnail = _ref.thumbnail,
|
|
1686
|
+
onPropertiesChange = _ref.onPropertiesChange;
|
|
1477
1687
|
var _useState = react.useState(DESIGN_SCREENS.THEMES),
|
|
1478
1688
|
_useState2 = _slicedToArray__default["default"](_useState, 2),
|
|
1479
1689
|
currentScreen = _useState2[0],
|
|
@@ -1641,6 +1851,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1641
1851
|
isApplyingTheme: isApplyingTheme,
|
|
1642
1852
|
onApplyTheme: onApplyTheme,
|
|
1643
1853
|
onCreateTheme: onCreateTheme,
|
|
1854
|
+
onPropertiesChange: onPropertiesChange,
|
|
1644
1855
|
theme: themeToEdit.current,
|
|
1645
1856
|
themeId: (_themeToEdit$current2 = themeToEdit.current) === null || _themeToEdit$current2 === void 0 ? void 0 : _themeToEdit$current2.id
|
|
1646
1857
|
}), /*#__PURE__*/jsxRuntime.jsx(MemoizedAlert, {
|
|
@@ -1679,13 +1890,13 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1679
1890
|
react.useEffect(function () {
|
|
1680
1891
|
setConfigState({
|
|
1681
1892
|
entityType: entityType,
|
|
1682
|
-
entityId: entityId
|
|
1683
|
-
onPropertiesChange: onPropertiesChange
|
|
1893
|
+
entityId: entityId
|
|
1684
1894
|
});
|
|
1685
1895
|
}, []);
|
|
1686
1896
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1687
1897
|
className: "neeto-themes__wrapper",
|
|
1688
1898
|
children: [/*#__PURE__*/jsxRuntime.jsx(Sidebar, {
|
|
1899
|
+
onPropertiesChange: onPropertiesChange,
|
|
1689
1900
|
thumbnail: thumbnail
|
|
1690
1901
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1691
1902
|
className: "neeto-themes-preview__wrapper",
|