@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
package/dist/index.js
CHANGED
|
@@ -8,26 +8,26 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
|
8
8
|
import { isNotPresent, snakeToCamelCase, filterBy, isPresent, isNot, findBy, findIndexBy, toLabelAndValue, humanize, isNotEmpty } from '@bigbinary/neeto-cist';
|
|
9
9
|
import Alert from '@bigbinary/neetoui/Alert';
|
|
10
10
|
import { useTranslation, Trans } from 'react-i18next';
|
|
11
|
-
import '@babel/runtime/helpers/asyncToGenerator';
|
|
12
|
-
import '@babel/runtime/regenerator';
|
|
13
|
-
import '@bigbinary/neetoui/Toastr';
|
|
11
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
12
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
13
|
+
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
14
14
|
import { useQuery } from 'react-query';
|
|
15
15
|
import axios from 'axios';
|
|
16
16
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
17
17
|
import { prop, isEmpty, negate } from 'ramda';
|
|
18
18
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
19
|
-
import { Close, LeftArrow, Plus } from '@bigbinary/neeto-icons';
|
|
19
|
+
import { LeftAlign, CenterAlign, Close, LeftArrow, Plus } from '@bigbinary/neeto-icons';
|
|
20
20
|
import Button from '@bigbinary/neetoui/Button';
|
|
21
21
|
import Popover from '@bigbinary/neetoui/Popover';
|
|
22
22
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
23
23
|
import Form from '@bigbinary/neetoui/formik/Form';
|
|
24
24
|
import * as yup from 'yup';
|
|
25
|
-
import { useFormikContext } from 'formik';
|
|
25
|
+
import { useFormikContext, Field } from 'formik';
|
|
26
26
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
27
27
|
import { ImageUploader } from '@bigbinary/neeto-image-uploader-frontend';
|
|
28
28
|
import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
|
|
29
|
-
import ColorPicker from '@bigbinary/neetoui/ColorPicker';
|
|
30
29
|
import Select from '@bigbinary/neetoui/Select';
|
|
30
|
+
import ColorPicker from '@bigbinary/neetoui/ColorPicker';
|
|
31
31
|
import { Slider } from 'antd';
|
|
32
32
|
import Switch from '@bigbinary/neetoui/Switch';
|
|
33
33
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
@@ -57,6 +57,52 @@ var useThemeStore = create$1(withImmutableActions(function (set) {
|
|
|
57
57
|
};
|
|
58
58
|
}));
|
|
59
59
|
|
|
60
|
+
var getImageFromUrl = function getImageFromUrl(source) {
|
|
61
|
+
var image = new Image();
|
|
62
|
+
image.crossOrigin = "anonymous";
|
|
63
|
+
image.src = source;
|
|
64
|
+
return new Promise(function (resolve) {
|
|
65
|
+
image.onload = function () {
|
|
66
|
+
resolve(image);
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
var getDominantColorFromUrl = /*#__PURE__*/function () {
|
|
71
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(imageUrl) {
|
|
72
|
+
var image, context, c;
|
|
73
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
74
|
+
while (1) switch (_context.prev = _context.next) {
|
|
75
|
+
case 0:
|
|
76
|
+
_context.prev = 0;
|
|
77
|
+
_context.next = 3;
|
|
78
|
+
return getImageFromUrl(imageUrl);
|
|
79
|
+
case 3:
|
|
80
|
+
image = _context.sent;
|
|
81
|
+
context = document.createElement("canvas").getContext("2d");
|
|
82
|
+
context === null || context === void 0 || context.drawImage(image, 0, 0, 1, 1);
|
|
83
|
+
c = context === null || context === void 0 ? void 0 : context.getImageData(0, 0, 1, 1).data;
|
|
84
|
+
if (!c) {
|
|
85
|
+
_context.next = 9;
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
return _context.abrupt("return", "#".concat(((1 << 24) + (c[0] << 16) + (c[1] << 8) + c[2]).toString(16).slice(1)));
|
|
89
|
+
case 9:
|
|
90
|
+
return _context.abrupt("return", null);
|
|
91
|
+
case 12:
|
|
92
|
+
_context.prev = 12;
|
|
93
|
+
_context.t0 = _context["catch"](0);
|
|
94
|
+
Toastr.error(_context.t0);
|
|
95
|
+
return _context.abrupt("return", null);
|
|
96
|
+
case 16:
|
|
97
|
+
case "end":
|
|
98
|
+
return _context.stop();
|
|
99
|
+
}
|
|
100
|
+
}, _callee, null, [[0, 12]]);
|
|
101
|
+
}));
|
|
102
|
+
return function getDominantColorFromUrl(_x) {
|
|
103
|
+
return _ref.apply(this, arguments);
|
|
104
|
+
};
|
|
105
|
+
}();
|
|
60
106
|
var scrollElementIntoView = function scrollElementIntoView(elementId) {
|
|
61
107
|
var elementToScroll = document.getElementById(elementId);
|
|
62
108
|
elementToScroll === null || elementToScroll === void 0 || elementToScroll.scrollIntoView({
|
|
@@ -195,6 +241,8 @@ var setTheme = function setTheme(theme, variableNamesMap, themeConfig) {
|
|
|
195
241
|
var overlayOpacity = Number(property.value);
|
|
196
242
|
setVariable(snakeToCamelCase("".concat(property.key, "_overlay_opacity")), Math.abs(overlayOpacity / 100), variableNamesMap);
|
|
197
243
|
setVariable(snakeToCamelCase("".concat(property.key, "_overlay_color")), overlayOpacity < 0 ? BLACK : WHITE, variableNamesMap);
|
|
244
|
+
} else if (property.kind === "radius") {
|
|
245
|
+
setVariable(attribute, "".concat(property.value, "px"), variableNamesMap);
|
|
198
246
|
} else {
|
|
199
247
|
setVariable(attribute, property.value, variableNamesMap);
|
|
200
248
|
}
|
|
@@ -381,6 +429,12 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
381
429
|
kind: "slider",
|
|
382
430
|
key: key
|
|
383
431
|
};
|
|
432
|
+
case "radius":
|
|
433
|
+
return {
|
|
434
|
+
value: defaultValue,
|
|
435
|
+
kind: "radius",
|
|
436
|
+
key: key
|
|
437
|
+
};
|
|
384
438
|
case "boolean":
|
|
385
439
|
return {
|
|
386
440
|
value: String(defaultValue),
|
|
@@ -393,6 +447,12 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
393
447
|
kind: "position_selector",
|
|
394
448
|
key: key
|
|
395
449
|
};
|
|
450
|
+
case "alignment_block":
|
|
451
|
+
return {
|
|
452
|
+
value: defaultValue,
|
|
453
|
+
kind: "alignment_block",
|
|
454
|
+
key: key
|
|
455
|
+
};
|
|
396
456
|
default:
|
|
397
457
|
return null;
|
|
398
458
|
}
|
|
@@ -410,23 +470,26 @@ var buildImageData = function buildImageData(values, themePropertiesSchema) {
|
|
|
410
470
|
}, {});
|
|
411
471
|
};
|
|
412
472
|
var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
|
|
413
|
-
var _findBy;
|
|
414
473
|
var property = findBy({
|
|
415
474
|
key: key
|
|
416
475
|
}, themePropertiesSchema);
|
|
417
476
|
if (isNotPresent(property)) return false;
|
|
477
|
+
if (property !== null && property !== void 0 && property.hidden) return false;
|
|
418
478
|
var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
|
|
419
479
|
if (isNotPresent(conditionalKey)) return true;
|
|
420
|
-
var
|
|
480
|
+
var dependentPropertySchema = findBy({
|
|
421
481
|
key: conditionalKey
|
|
422
482
|
}, themePropertiesSchema);
|
|
423
|
-
|
|
483
|
+
var dependentProperty = findBy({
|
|
484
|
+
key: conditionalKey
|
|
485
|
+
}, formikValues.properties);
|
|
486
|
+
if (dependentPropertySchema.kind === "image") {
|
|
424
487
|
var _formikValues$snakeTo;
|
|
425
488
|
return isPresent((_formikValues$snakeTo = formikValues[snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
|
|
489
|
+
} else if (dependentPropertySchema.kind === "boolean") {
|
|
490
|
+
return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
|
|
426
491
|
}
|
|
427
|
-
return isPresent(
|
|
428
|
-
key: conditionalKey
|
|
429
|
-
}, formikValues.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value);
|
|
492
|
+
return isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
|
|
430
493
|
};
|
|
431
494
|
var buildLabel = function buildLabel(key, kind) {
|
|
432
495
|
return t$1("neetoThemes.properties.".concat(snakeToCamelCase(kind), ".").concat(snakeToCamelCase(key)));
|
|
@@ -454,6 +517,32 @@ var Card$2 = function Card(_ref) {
|
|
|
454
517
|
});
|
|
455
518
|
};
|
|
456
519
|
|
|
520
|
+
var SelectBlock = function SelectBlock(_ref) {
|
|
521
|
+
var label = _ref.label,
|
|
522
|
+
_ref$placeholder = _ref.placeholder,
|
|
523
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
524
|
+
value = _ref.value,
|
|
525
|
+
options = _ref.options,
|
|
526
|
+
onChange = _ref.onChange;
|
|
527
|
+
return /*#__PURE__*/jsxs("div", {
|
|
528
|
+
className: "flex items-center justify-between py-3 first:pt-0 last:pb-0",
|
|
529
|
+
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
530
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
531
|
+
"data-cy": "logo-field-labels",
|
|
532
|
+
style: "body2",
|
|
533
|
+
children: label
|
|
534
|
+
}), /*#__PURE__*/jsx("div", {
|
|
535
|
+
className: "w-40",
|
|
536
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
537
|
+
onChange: onChange,
|
|
538
|
+
options: options,
|
|
539
|
+
placeholder: placeholder,
|
|
540
|
+
value: value
|
|
541
|
+
})
|
|
542
|
+
})]
|
|
543
|
+
});
|
|
544
|
+
};
|
|
545
|
+
|
|
457
546
|
var DESIGN_SCREENS = {
|
|
458
547
|
THEMES: "Themes",
|
|
459
548
|
Customize: "Customize"
|
|
@@ -461,6 +550,7 @@ var DESIGN_SCREENS = {
|
|
|
461
550
|
var ONE_MEGABYTE = 1;
|
|
462
551
|
|
|
463
552
|
var ImageBlock = function ImageBlock(_ref) {
|
|
553
|
+
var _findBy;
|
|
464
554
|
var label = _ref.label,
|
|
465
555
|
name = _ref.name,
|
|
466
556
|
_ref$imageData = _ref.imageData,
|
|
@@ -468,22 +558,73 @@ var ImageBlock = function ImageBlock(_ref) {
|
|
|
468
558
|
_ref$uploadConfig = _ref.uploadConfig,
|
|
469
559
|
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
470
560
|
maxImageSize: ONE_MEGABYTE
|
|
471
|
-
} : _ref$uploadConfig
|
|
561
|
+
} : _ref$uploadConfig,
|
|
562
|
+
attribute = _ref.attribute;
|
|
563
|
+
var _useTranslation = useTranslation(),
|
|
564
|
+
t = _useTranslation.t;
|
|
472
565
|
var _useFormikContext = useFormikContext(),
|
|
473
|
-
setFieldValue = _useFormikContext.setFieldValue
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
566
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
567
|
+
values = _useFormikContext.values;
|
|
568
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
569
|
+
return {
|
|
570
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
571
|
+
};
|
|
572
|
+
}, shallow),
|
|
573
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
574
|
+
var propertySchema = findBy({
|
|
575
|
+
key: attribute
|
|
576
|
+
}, themePropertiesSchema);
|
|
577
|
+
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
578
|
+
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
579
|
+
var positionKeyInSchema = findBy({
|
|
580
|
+
key: "".concat(name, "_position")
|
|
581
|
+
}, themePropertiesSchema);
|
|
582
|
+
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && isPresent(positionKeyInSchema);
|
|
583
|
+
var positionKeyIndex = findIndexBy({
|
|
584
|
+
key: "".concat(name, "_position")
|
|
585
|
+
}, values.properties);
|
|
586
|
+
var handleImageChange = /*#__PURE__*/function () {
|
|
587
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
588
|
+
var dominantColor;
|
|
589
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
590
|
+
while (1) switch (_context.prev = _context.next) {
|
|
591
|
+
case 0:
|
|
592
|
+
_context.prev = 0;
|
|
593
|
+
if (!(isEmpty(image.signedId) || isEmpty(image.url))) {
|
|
594
|
+
_context.next = 4;
|
|
595
|
+
break;
|
|
596
|
+
}
|
|
597
|
+
setFieldValue(name, {
|
|
598
|
+
signedId: null,
|
|
599
|
+
url: image.url
|
|
600
|
+
});
|
|
601
|
+
return _context.abrupt("return");
|
|
602
|
+
case 4:
|
|
603
|
+
_context.next = 6;
|
|
604
|
+
return getDominantColorFromUrl(image.url);
|
|
605
|
+
case 6:
|
|
606
|
+
dominantColor = _context.sent;
|
|
607
|
+
setFieldValue(name, {
|
|
608
|
+
signedId: image.signedId,
|
|
609
|
+
url: image.url,
|
|
610
|
+
dominantColor: dominantColor
|
|
611
|
+
});
|
|
612
|
+
_context.next = 13;
|
|
613
|
+
break;
|
|
614
|
+
case 10:
|
|
615
|
+
_context.prev = 10;
|
|
616
|
+
_context.t0 = _context["catch"](0);
|
|
617
|
+
Toastr.error(_context.t0);
|
|
618
|
+
case 13:
|
|
619
|
+
case "end":
|
|
620
|
+
return _context.stop();
|
|
621
|
+
}
|
|
622
|
+
}, _callee, null, [[0, 10]]);
|
|
623
|
+
}));
|
|
624
|
+
return function handleImageChange(_x) {
|
|
625
|
+
return _ref2.apply(this, arguments);
|
|
626
|
+
};
|
|
627
|
+
}();
|
|
487
628
|
return /*#__PURE__*/jsxs("div", {
|
|
488
629
|
className: "space-y-3 py-3 first:pt-0 last:pb-0",
|
|
489
630
|
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
@@ -494,12 +635,25 @@ var ImageBlock = function ImageBlock(_ref) {
|
|
|
494
635
|
style: "body2",
|
|
495
636
|
children: label
|
|
496
637
|
})
|
|
497
|
-
}), /*#__PURE__*/
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
638
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
639
|
+
className: "space-y-3 divide-y divide-gray-200",
|
|
640
|
+
children: [/*#__PURE__*/createElement(ImageUploader, {
|
|
641
|
+
uploadConfig: uploadConfig,
|
|
642
|
+
className: "h-40 w-full",
|
|
643
|
+
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
644
|
+
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
645
|
+
onUploadComplete: handleImageChange
|
|
646
|
+
}), isPositionChangerVisible && /*#__PURE__*/jsx(SelectBlock, {
|
|
647
|
+
label: buildLabel("".concat(name, "Position"), "image"),
|
|
648
|
+
options: options || POSITION_OPTIONS,
|
|
649
|
+
placeholder: t("neetoThemes.common.left"),
|
|
650
|
+
value: toLabelAndValue((_findBy = findBy({
|
|
651
|
+
key: "".concat(name, "_position")
|
|
652
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value),
|
|
653
|
+
onChange: function onChange(option) {
|
|
654
|
+
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
655
|
+
}
|
|
656
|
+
})]
|
|
503
657
|
})]
|
|
504
658
|
});
|
|
505
659
|
};
|
|
@@ -516,6 +670,7 @@ var Images = function Images(_ref) {
|
|
|
516
670
|
children: /*#__PURE__*/jsx("div", {
|
|
517
671
|
className: "divide-y divide-gray-200",
|
|
518
672
|
children: /*#__PURE__*/jsx(ImageBlock, {
|
|
673
|
+
attribute: attribute,
|
|
519
674
|
imageData: imageData,
|
|
520
675
|
name: key
|
|
521
676
|
})
|
|
@@ -523,6 +678,54 @@ var Images = function Images(_ref) {
|
|
|
523
678
|
});
|
|
524
679
|
};
|
|
525
680
|
|
|
681
|
+
var AlignmentBlock = function AlignmentBlock(_ref) {
|
|
682
|
+
var label = _ref.label,
|
|
683
|
+
name = _ref.name;
|
|
684
|
+
return /*#__PURE__*/jsxs("div", {
|
|
685
|
+
className: "flex items-center justify-between gap-2 py-3 first:pt-0 last:pb-0",
|
|
686
|
+
"data-cy": joinHyphenCase(label),
|
|
687
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
688
|
+
"data-cy": "style-fields-labels",
|
|
689
|
+
style: "body2",
|
|
690
|
+
children: label
|
|
691
|
+
}), /*#__PURE__*/jsx(Field, {
|
|
692
|
+
name: name,
|
|
693
|
+
children: function children(_ref2) {
|
|
694
|
+
var value = _ref2.field.value,
|
|
695
|
+
setFieldValue = _ref2.form.setFieldValue;
|
|
696
|
+
return /*#__PURE__*/jsxs("div", {
|
|
697
|
+
className: "flex items-center gap-3",
|
|
698
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
699
|
+
"data-cy": "alignment-left",
|
|
700
|
+
icon: LeftAlign,
|
|
701
|
+
size: "large",
|
|
702
|
+
style: value === "left" ? "primary" : "text",
|
|
703
|
+
tooltipProps: {
|
|
704
|
+
content: "Left align",
|
|
705
|
+
position: "bottom"
|
|
706
|
+
},
|
|
707
|
+
onClick: function onClick() {
|
|
708
|
+
return setFieldValue(name, "left");
|
|
709
|
+
}
|
|
710
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
711
|
+
"data-cy": "alignment-center",
|
|
712
|
+
icon: CenterAlign,
|
|
713
|
+
size: "large",
|
|
714
|
+
style: value === "center" ? "primary" : "text",
|
|
715
|
+
tooltipProps: {
|
|
716
|
+
content: "Center align",
|
|
717
|
+
position: "bottom"
|
|
718
|
+
},
|
|
719
|
+
onClick: function onClick() {
|
|
720
|
+
return setFieldValue(name, "center");
|
|
721
|
+
}
|
|
722
|
+
})]
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
})]
|
|
726
|
+
});
|
|
727
|
+
};
|
|
728
|
+
|
|
526
729
|
var ColorBlock = function ColorBlock(_ref) {
|
|
527
730
|
var label = _ref.label,
|
|
528
731
|
_ref$color = _ref.color,
|
|
@@ -582,32 +785,6 @@ var FontPickerBlock = function FontPickerBlock(_ref) {
|
|
|
582
785
|
});
|
|
583
786
|
};
|
|
584
787
|
|
|
585
|
-
var SelectBlock = function SelectBlock(_ref) {
|
|
586
|
-
var label = _ref.label,
|
|
587
|
-
_ref$placeholder = _ref.placeholder,
|
|
588
|
-
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
589
|
-
value = _ref.value,
|
|
590
|
-
options = _ref.options,
|
|
591
|
-
onChange = _ref.onChange;
|
|
592
|
-
return /*#__PURE__*/jsxs("div", {
|
|
593
|
-
className: "flex items-center justify-between py-3 first:pt-0 last:pb-0",
|
|
594
|
-
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
595
|
-
children: [/*#__PURE__*/jsx(Typography, {
|
|
596
|
-
"data-cy": "logo-field-labels",
|
|
597
|
-
style: "body2",
|
|
598
|
-
children: label
|
|
599
|
-
}), /*#__PURE__*/jsx("div", {
|
|
600
|
-
className: "w-40",
|
|
601
|
-
children: /*#__PURE__*/jsx(Select, {
|
|
602
|
-
onChange: onChange,
|
|
603
|
-
options: options,
|
|
604
|
-
placeholder: placeholder,
|
|
605
|
-
value: value
|
|
606
|
-
})
|
|
607
|
-
})]
|
|
608
|
-
});
|
|
609
|
-
};
|
|
610
|
-
|
|
611
788
|
var SliderBlock = function SliderBlock(_ref) {
|
|
612
789
|
var label = _ref.label,
|
|
613
790
|
onChange = _ref.onChange,
|
|
@@ -654,17 +831,16 @@ var SwitchBlock = function SwitchBlock(_ref) {
|
|
|
654
831
|
});
|
|
655
832
|
};
|
|
656
833
|
|
|
657
|
-
var Properties = function Properties() {
|
|
834
|
+
var Properties = function Properties(_ref) {
|
|
835
|
+
var onPropertiesChange = _ref.onPropertiesChange;
|
|
658
836
|
var _useTranslation = useTranslation(),
|
|
659
837
|
t = _useTranslation.t;
|
|
660
838
|
var _useConfigStore = useConfigStore(function (store) {
|
|
661
839
|
return {
|
|
662
|
-
themePropertiesSchema: store["themePropertiesSchema"]
|
|
663
|
-
onPropertiesChange: store["onPropertiesChange"]
|
|
840
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
664
841
|
};
|
|
665
842
|
}, shallow),
|
|
666
|
-
themePropertiesSchema = _useConfigStore.themePropertiesSchema
|
|
667
|
-
onPropertiesChange = _useConfigStore.onPropertiesChange;
|
|
843
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
668
844
|
var _useThemeStore = useThemeStore(function (store) {
|
|
669
845
|
return {
|
|
670
846
|
setThemeState: store["setThemeState"]
|
|
@@ -678,9 +854,9 @@ var Properties = function Properties() {
|
|
|
678
854
|
setVariable = _useThemeUtils.setVariable,
|
|
679
855
|
setTheme = _useThemeUtils.setTheme;
|
|
680
856
|
var handleColorChange = function handleColorChange(name) {
|
|
681
|
-
return function (
|
|
682
|
-
var hex =
|
|
683
|
-
rgb =
|
|
857
|
+
return function (_ref2) {
|
|
858
|
+
var hex = _ref2.hex,
|
|
859
|
+
rgb = _ref2.rgb;
|
|
684
860
|
handleChange(name, hex, "".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a));
|
|
685
861
|
};
|
|
686
862
|
};
|
|
@@ -705,7 +881,7 @@ var Properties = function Properties() {
|
|
|
705
881
|
}
|
|
706
882
|
};
|
|
707
883
|
useEffect(function () {
|
|
708
|
-
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values,
|
|
884
|
+
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values, handleChange, handleColorChange);
|
|
709
885
|
setTheme(values);
|
|
710
886
|
setThemeState({
|
|
711
887
|
previewingTheme: values
|
|
@@ -717,38 +893,53 @@ var Properties = function Properties() {
|
|
|
717
893
|
className: "divide-y divide-gray-200",
|
|
718
894
|
children: [filterBy({
|
|
719
895
|
kind: "font_family"
|
|
720
|
-
}, values.properties).map(function (
|
|
721
|
-
var key =
|
|
722
|
-
value =
|
|
723
|
-
kind =
|
|
896
|
+
}, values.properties).map(function (_ref3) {
|
|
897
|
+
var key = _ref3.key,
|
|
898
|
+
value = _ref3.value,
|
|
899
|
+
kind = _ref3.kind;
|
|
724
900
|
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsx(FontPickerBlock, {
|
|
725
901
|
label: buildLabel(key, kind),
|
|
726
902
|
options: FONT_OPTIONS,
|
|
727
903
|
value: findBy({
|
|
728
904
|
value: value || null
|
|
729
905
|
}, FONT_OPTIONS),
|
|
730
|
-
onChange: function onChange(
|
|
731
|
-
var value =
|
|
906
|
+
onChange: function onChange(_ref4) {
|
|
907
|
+
var value = _ref4.value;
|
|
732
908
|
handleChange(key, value);
|
|
733
909
|
}
|
|
734
910
|
}, key);
|
|
735
911
|
}), filterBy({
|
|
736
912
|
kind: "color"
|
|
737
|
-
}, values.properties).map(function (
|
|
738
|
-
var key =
|
|
739
|
-
value =
|
|
740
|
-
kind =
|
|
913
|
+
}, values.properties).map(function (_ref5) {
|
|
914
|
+
var key = _ref5.key,
|
|
915
|
+
value = _ref5.value,
|
|
916
|
+
kind = _ref5.kind;
|
|
741
917
|
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsx(ColorBlock, {
|
|
742
918
|
color: value,
|
|
743
919
|
label: buildLabel(key, kind),
|
|
744
920
|
onChange: handleColorChange(key)
|
|
745
921
|
}, key);
|
|
922
|
+
}), filterBy({
|
|
923
|
+
kind: "radius"
|
|
924
|
+
}, values.properties).map(function (_ref6) {
|
|
925
|
+
var key = _ref6.key,
|
|
926
|
+
value = _ref6.value,
|
|
927
|
+
kind = _ref6.kind;
|
|
928
|
+
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsx(SliderBlock, {
|
|
929
|
+
label: buildLabel(key, kind),
|
|
930
|
+
max: 50,
|
|
931
|
+
min: 0,
|
|
932
|
+
value: Number(value) || 0,
|
|
933
|
+
onChange: function onChange(radius) {
|
|
934
|
+
return handleChange(key, radius, "".concat(radius, "px"));
|
|
935
|
+
}
|
|
936
|
+
}, key);
|
|
746
937
|
}), filterBy({
|
|
747
938
|
kind: "overlay_opacity"
|
|
748
|
-
}, values.properties).map(function (
|
|
749
|
-
var key =
|
|
750
|
-
value =
|
|
751
|
-
kind =
|
|
939
|
+
}, values.properties).map(function (_ref7) {
|
|
940
|
+
var key = _ref7.key,
|
|
941
|
+
value = _ref7.value,
|
|
942
|
+
kind = _ref7.kind;
|
|
752
943
|
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsx(SliderBlock, {
|
|
753
944
|
label: buildLabel(key, kind),
|
|
754
945
|
marks: OVERLAY_OPACITY_SLIDER_MARKS,
|
|
@@ -761,11 +952,11 @@ var Properties = function Properties() {
|
|
|
761
952
|
}, key);
|
|
762
953
|
}), filterBy({
|
|
763
954
|
kind: "position_selector"
|
|
764
|
-
}, values.properties).map(function (
|
|
955
|
+
}, values.properties).map(function (_ref8) {
|
|
765
956
|
var _findBy;
|
|
766
|
-
var key =
|
|
767
|
-
kind =
|
|
768
|
-
value =
|
|
957
|
+
var key = _ref8.key,
|
|
958
|
+
kind = _ref8.kind,
|
|
959
|
+
value = _ref8.value;
|
|
769
960
|
var index = findIndexBy({
|
|
770
961
|
key: key
|
|
771
962
|
}, values.properties);
|
|
@@ -783,10 +974,10 @@ var Properties = function Properties() {
|
|
|
783
974
|
}, key);
|
|
784
975
|
}), filterBy({
|
|
785
976
|
kind: "boolean"
|
|
786
|
-
}, values.properties).map(function (
|
|
787
|
-
var key =
|
|
788
|
-
kind =
|
|
789
|
-
value =
|
|
977
|
+
}, values.properties).map(function (_ref9) {
|
|
978
|
+
var key = _ref9.key,
|
|
979
|
+
kind = _ref9.kind,
|
|
980
|
+
value = _ref9.value;
|
|
790
981
|
var index = findIndexBy({
|
|
791
982
|
key: key
|
|
792
983
|
}, values.properties);
|
|
@@ -797,6 +988,18 @@ var Properties = function Properties() {
|
|
|
797
988
|
return setFieldValue("properties[".concat(index, "].value"), String(e.target.checked));
|
|
798
989
|
}
|
|
799
990
|
}, key);
|
|
991
|
+
}), filterBy({
|
|
992
|
+
kind: "alignment_block"
|
|
993
|
+
}, values.properties).map(function (_ref10) {
|
|
994
|
+
var key = _ref10.key,
|
|
995
|
+
kind = _ref10.kind;
|
|
996
|
+
var index = findIndexBy({
|
|
997
|
+
key: key
|
|
998
|
+
}, values.properties);
|
|
999
|
+
return isPropertyVisible(key, values, themePropertiesSchema) && /*#__PURE__*/jsx(AlignmentBlock, {
|
|
1000
|
+
label: buildLabel(key, kind),
|
|
1001
|
+
name: "properties[".concat(index, "].value")
|
|
1002
|
+
});
|
|
800
1003
|
})]
|
|
801
1004
|
})
|
|
802
1005
|
});
|
|
@@ -821,7 +1024,8 @@ var Customize = function Customize(_ref) {
|
|
|
821
1024
|
theme = _ref.theme,
|
|
822
1025
|
onCreateTheme = _ref.onCreateTheme,
|
|
823
1026
|
onApplyTheme = _ref.onApplyTheme,
|
|
824
|
-
isApplyingTheme = _ref.isApplyingTheme
|
|
1027
|
+
isApplyingTheme = _ref.isApplyingTheme,
|
|
1028
|
+
onPropertiesChange = _ref.onPropertiesChange;
|
|
825
1029
|
var _useTranslation = useTranslation(),
|
|
826
1030
|
t = _useTranslation.t;
|
|
827
1031
|
var _useState = useState({}),
|
|
@@ -885,7 +1089,9 @@ var Customize = function Customize(_ref) {
|
|
|
885
1089
|
className: "neeto-themes-sidebar__scroll",
|
|
886
1090
|
children: [/*#__PURE__*/jsxs("div", {
|
|
887
1091
|
className: "flex flex-col gap-6 p-4",
|
|
888
|
-
children: [/*#__PURE__*/jsx(ThemeMeta, {}), /*#__PURE__*/jsx(Properties, {
|
|
1092
|
+
children: [/*#__PURE__*/jsx(ThemeMeta, {}), /*#__PURE__*/jsx(Properties, {
|
|
1093
|
+
onPropertiesChange: onPropertiesChange
|
|
1094
|
+
}), filterBy({
|
|
889
1095
|
kind: "image"
|
|
890
1096
|
}, themePropertiesSchema).map(function (_ref5) {
|
|
891
1097
|
var key = _ref5.key;
|
|
@@ -1430,7 +1636,8 @@ var TitleBar = function TitleBar(_ref) {
|
|
|
1430
1636
|
var MemoizedAlert = /*#__PURE__*/memo(Alert);
|
|
1431
1637
|
var Sidebar = function Sidebar(_ref) {
|
|
1432
1638
|
var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3;
|
|
1433
|
-
var thumbnail = _ref.thumbnail
|
|
1639
|
+
var thumbnail = _ref.thumbnail,
|
|
1640
|
+
onPropertiesChange = _ref.onPropertiesChange;
|
|
1434
1641
|
var _useState = useState(DESIGN_SCREENS.THEMES),
|
|
1435
1642
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1436
1643
|
currentScreen = _useState2[0],
|
|
@@ -1598,6 +1805,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1598
1805
|
isApplyingTheme: isApplyingTheme,
|
|
1599
1806
|
onApplyTheme: onApplyTheme,
|
|
1600
1807
|
onCreateTheme: onCreateTheme,
|
|
1808
|
+
onPropertiesChange: onPropertiesChange,
|
|
1601
1809
|
theme: themeToEdit.current,
|
|
1602
1810
|
themeId: (_themeToEdit$current2 = themeToEdit.current) === null || _themeToEdit$current2 === void 0 ? void 0 : _themeToEdit$current2.id
|
|
1603
1811
|
}), /*#__PURE__*/jsx(MemoizedAlert, {
|
|
@@ -1636,13 +1844,13 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
1636
1844
|
useEffect(function () {
|
|
1637
1845
|
setConfigState({
|
|
1638
1846
|
entityType: entityType,
|
|
1639
|
-
entityId: entityId
|
|
1640
|
-
onPropertiesChange: onPropertiesChange
|
|
1847
|
+
entityId: entityId
|
|
1641
1848
|
});
|
|
1642
1849
|
}, []);
|
|
1643
1850
|
return /*#__PURE__*/jsxs("div", {
|
|
1644
1851
|
className: "neeto-themes__wrapper",
|
|
1645
1852
|
children: [/*#__PURE__*/jsx(Sidebar, {
|
|
1853
|
+
onPropertiesChange: onPropertiesChange,
|
|
1646
1854
|
thumbnail: thumbnail
|
|
1647
1855
|
}), /*#__PURE__*/jsx("div", {
|
|
1648
1856
|
className: "neeto-themes-preview__wrapper",
|