@bigbinary/neeto-themes-frontend 3.0.0 → 3.0.2
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/NeetoThemesBuilder.js +235 -191
- package/dist/NeetoThemesBuilder.js.map +1 -1
- package/dist/cjs/NeetoThemesBuilder.js +234 -190
- package/dist/cjs/NeetoThemesBuilder.js.map +1 -1
- package/dist/cjs/index.js +6 -6
- package/dist/index.js +6 -6
- package/package.json +9 -9
|
@@ -29,18 +29,18 @@ var Editor = require('@monaco-editor/react');
|
|
|
29
29
|
var formik = require('formik');
|
|
30
30
|
var Down = require('@bigbinary/neeto-icons/Down');
|
|
31
31
|
var jsxRuntime = require('react/jsx-runtime');
|
|
32
|
-
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
33
|
-
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
34
|
-
var ImageUploader = require('@bigbinary/neeto-image-uploader-frontend/ImageUploader');
|
|
35
|
-
var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
|
|
36
|
-
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
37
32
|
var ramda = require('ramda');
|
|
38
|
-
var
|
|
33
|
+
var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
|
|
39
34
|
var CenterAlign = require('@bigbinary/neeto-icons/CenterAlign');
|
|
40
35
|
var LeftAlign = require('@bigbinary/neeto-icons/LeftAlign');
|
|
41
36
|
var ColorPicker = require('@bigbinary/neetoui/ColorPicker');
|
|
37
|
+
var Select = require('@bigbinary/neetoui/Select');
|
|
42
38
|
var antd = require('antd');
|
|
43
39
|
var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
|
|
40
|
+
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
41
|
+
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
42
|
+
var ImageUploader = require('@bigbinary/neeto-image-uploader-frontend/ImageUploader');
|
|
43
|
+
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
44
44
|
var Input = require('@bigbinary/neetoui/formik/Input');
|
|
45
45
|
var Search = require('@bigbinary/neeto-molecules/Search');
|
|
46
46
|
var Rating = require('@bigbinary/neeto-icons/Rating');
|
|
@@ -456,13 +456,15 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
456
456
|
kind = _ref.kind,
|
|
457
457
|
defaultValue = _ref.defaultValue,
|
|
458
458
|
_ref$order = _ref.order,
|
|
459
|
-
order = _ref$order === void 0 ? null : _ref$order
|
|
459
|
+
order = _ref$order === void 0 ? null : _ref$order,
|
|
460
|
+
dependsOn = _ref.dependsOn;
|
|
460
461
|
switch (kind) {
|
|
461
462
|
case "color":
|
|
462
463
|
return _objectSpread$4({
|
|
463
464
|
value: defaultValue,
|
|
464
465
|
kind: "color",
|
|
465
|
-
key: key
|
|
466
|
+
key: key,
|
|
467
|
+
dependsOn: dependsOn
|
|
466
468
|
}, order !== null && {
|
|
467
469
|
order: order
|
|
468
470
|
});
|
|
@@ -470,7 +472,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
470
472
|
return _objectSpread$4({
|
|
471
473
|
value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
|
|
472
474
|
kind: "font_family",
|
|
473
|
-
key: key
|
|
475
|
+
key: key,
|
|
476
|
+
dependsOn: dependsOn
|
|
474
477
|
}, order !== null && {
|
|
475
478
|
order: order
|
|
476
479
|
});
|
|
@@ -478,7 +481,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
478
481
|
return _objectSpread$4({
|
|
479
482
|
value: 0,
|
|
480
483
|
kind: "overlay_opacity",
|
|
481
|
-
key: key
|
|
484
|
+
key: key,
|
|
485
|
+
dependsOn: dependsOn
|
|
482
486
|
}, order !== null && {
|
|
483
487
|
order: order
|
|
484
488
|
});
|
|
@@ -486,7 +490,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
486
490
|
return _objectSpread$4({
|
|
487
491
|
value: 0,
|
|
488
492
|
kind: "slider",
|
|
489
|
-
key: key
|
|
493
|
+
key: key,
|
|
494
|
+
dependsOn: dependsOn
|
|
490
495
|
}, order !== null && {
|
|
491
496
|
order: order
|
|
492
497
|
});
|
|
@@ -494,7 +499,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
494
499
|
return _objectSpread$4({
|
|
495
500
|
value: defaultValue,
|
|
496
501
|
kind: "radius",
|
|
497
|
-
key: key
|
|
502
|
+
key: key,
|
|
503
|
+
dependsOn: dependsOn
|
|
498
504
|
}, order !== null && {
|
|
499
505
|
order: order
|
|
500
506
|
});
|
|
@@ -502,7 +508,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
502
508
|
return _objectSpread$4({
|
|
503
509
|
value: String(defaultValue),
|
|
504
510
|
kind: "boolean",
|
|
505
|
-
key: key
|
|
511
|
+
key: key,
|
|
512
|
+
dependsOn: dependsOn
|
|
506
513
|
}, order !== null && {
|
|
507
514
|
order: order
|
|
508
515
|
});
|
|
@@ -510,7 +517,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
510
517
|
return _objectSpread$4({
|
|
511
518
|
value: defaultValue,
|
|
512
519
|
kind: "order_selector",
|
|
513
|
-
key: key
|
|
520
|
+
key: key,
|
|
521
|
+
dependsOn: dependsOn
|
|
514
522
|
}, order !== null && {
|
|
515
523
|
order: order
|
|
516
524
|
});
|
|
@@ -518,7 +526,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
518
526
|
return _objectSpread$4({
|
|
519
527
|
value: defaultValue,
|
|
520
528
|
kind: "alignment_block",
|
|
521
|
-
key: key
|
|
529
|
+
key: key,
|
|
530
|
+
dependsOn: dependsOn
|
|
522
531
|
}, order !== null && {
|
|
523
532
|
order: order
|
|
524
533
|
});
|
|
@@ -526,7 +535,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
526
535
|
return _objectSpread$4({
|
|
527
536
|
value: defaultValue,
|
|
528
537
|
kind: "custom_css",
|
|
529
|
-
key: key
|
|
538
|
+
key: key,
|
|
539
|
+
dependsOn: dependsOn
|
|
530
540
|
}, order !== null && {
|
|
531
541
|
order: order
|
|
532
542
|
});
|
|
@@ -571,159 +581,27 @@ var isPropertyVisible = function isPropertyVisible(key, formikValues, themePrope
|
|
|
571
581
|
var buildLabel = function buildLabel(key, kind) {
|
|
572
582
|
return i18next.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
|
|
573
583
|
};
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
options = _ref.options,
|
|
581
|
-
onChange = _ref.onChange;
|
|
582
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
583
|
-
className: "flex items-center justify-between",
|
|
584
|
-
"data-cy": "theme-style-".concat(utils$1.joinHyphenCase(label)),
|
|
585
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
586
|
-
"data-cy": "logo-field-labels",
|
|
587
|
-
style: "body2",
|
|
588
|
-
children: label
|
|
589
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
590
|
-
className: "w-40",
|
|
591
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
592
|
-
onChange: onChange,
|
|
593
|
-
options: options,
|
|
594
|
-
placeholder: placeholder,
|
|
595
|
-
value: value
|
|
596
|
-
})
|
|
597
|
-
})]
|
|
584
|
+
var buildProperties = function buildProperties(values, condition, themePropertiesSchema) {
|
|
585
|
+
values.forEach(function (value) {
|
|
586
|
+
themePropertiesSchema.forEach(function (theme) {
|
|
587
|
+
if (!(value.key === theme.key)) return;
|
|
588
|
+
value.dependsOn = theme.dependsOn;
|
|
589
|
+
});
|
|
598
590
|
});
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
maxImageSize: ONE_MEGABYTE
|
|
610
|
-
} : _ref$uploadConfig,
|
|
611
|
-
attribute = _ref.attribute;
|
|
612
|
-
var _useTranslation = reactI18next.useTranslation(),
|
|
613
|
-
t = _useTranslation.t;
|
|
614
|
-
var _useFormikContext = formik.useFormikContext(),
|
|
615
|
-
setFieldValue = _useFormikContext.setFieldValue,
|
|
616
|
-
values = _useFormikContext.values;
|
|
617
|
-
var _useConfigStore = useThemeUtils.useConfigStore(function (store) {
|
|
618
|
-
return {
|
|
619
|
-
themePropertiesSchema: store["themePropertiesSchema"]
|
|
620
|
-
};
|
|
621
|
-
}, shallow.shallow),
|
|
622
|
-
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
623
|
-
var propertySchema = neetoCist.findBy({
|
|
624
|
-
key: attribute
|
|
625
|
-
}, themePropertiesSchema);
|
|
626
|
-
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
627
|
-
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
628
|
-
var positionKeyInSchema = neetoCist.findBy({
|
|
629
|
-
key: "".concat(name, "_position")
|
|
630
|
-
}, themePropertiesSchema);
|
|
631
|
-
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && neetoCist.isPresent(positionKeyInSchema);
|
|
632
|
-
var positionKeyIndex = neetoCist.findIndexBy({
|
|
633
|
-
key: "".concat(name, "_position")
|
|
634
|
-
}, values.properties);
|
|
635
|
-
var handleImageChange = /*#__PURE__*/function () {
|
|
636
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
637
|
-
var dominantColor;
|
|
638
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
639
|
-
while (1) switch (_context.prev = _context.next) {
|
|
640
|
-
case 0:
|
|
641
|
-
_context.prev = 0;
|
|
642
|
-
if (!(ramda.isEmpty(image.signedId) || ramda.isEmpty(image.url))) {
|
|
643
|
-
_context.next = 4;
|
|
644
|
-
break;
|
|
645
|
-
}
|
|
646
|
-
setFieldValue(name, {
|
|
647
|
-
signedId: null,
|
|
648
|
-
url: image.url
|
|
649
|
-
});
|
|
650
|
-
return _context.abrupt("return");
|
|
651
|
-
case 4:
|
|
652
|
-
_context.next = 6;
|
|
653
|
-
return utils.getDominantColorFromUrl(image.url);
|
|
654
|
-
case 6:
|
|
655
|
-
dominantColor = _context.sent;
|
|
656
|
-
setFieldValue(name, {
|
|
657
|
-
signedId: image.signedId,
|
|
658
|
-
url: image.url,
|
|
659
|
-
dominantColor: dominantColor
|
|
660
|
-
});
|
|
661
|
-
_context.next = 13;
|
|
662
|
-
break;
|
|
663
|
-
case 10:
|
|
664
|
-
_context.prev = 10;
|
|
665
|
-
_context.t0 = _context["catch"](0);
|
|
666
|
-
Toastr.error(_context.t0);
|
|
667
|
-
case 13:
|
|
668
|
-
case "end":
|
|
669
|
-
return _context.stop();
|
|
670
|
-
}
|
|
671
|
-
}, _callee, null, [[0, 10]]);
|
|
672
|
-
}));
|
|
673
|
-
return function handleImageChange(_x) {
|
|
674
|
-
return _ref2.apply(this, arguments);
|
|
675
|
-
};
|
|
676
|
-
}();
|
|
677
|
-
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
678
|
-
className: "space-y-3",
|
|
679
|
-
"data-cy": "theme-style-".concat(label ? utils$1.joinHyphenCase(label) : "image-block"),
|
|
680
|
-
children: [label && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
681
|
-
className: "flex items-center justify-between",
|
|
682
|
-
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
683
|
-
"data-cy": "style-fields-labels",
|
|
684
|
-
style: "body2",
|
|
685
|
-
children: label
|
|
686
|
-
})
|
|
687
|
-
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
688
|
-
className: "space-y-3",
|
|
689
|
-
children: [/*#__PURE__*/react.createElement(ImageUploader, {
|
|
690
|
-
uploadConfig: uploadConfig,
|
|
691
|
-
className: "h-40 w-full",
|
|
692
|
-
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
693
|
-
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
694
|
-
onUploadComplete: handleImageChange
|
|
695
|
-
}), isPositionChangerVisible && /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
|
|
696
|
-
label: buildLabel("".concat(name, "Position"), "image"),
|
|
697
|
-
options: options || POSITION_OPTIONS,
|
|
698
|
-
placeholder: t("neetoThemes.common.left"),
|
|
699
|
-
value: neetoCist.toLabelAndValue(((_findBy = neetoCist.findBy({
|
|
700
|
-
key: "".concat(name, "_position")
|
|
701
|
-
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
|
|
702
|
-
onChange: function onChange(option) {
|
|
703
|
-
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
704
|
-
}
|
|
705
|
-
})]
|
|
706
|
-
})]
|
|
591
|
+
if (condition) {
|
|
592
|
+
return neetoCist.filterBy({
|
|
593
|
+
dependsOn: condition
|
|
594
|
+
}, values);
|
|
595
|
+
}
|
|
596
|
+
var imageKeys = new Set();
|
|
597
|
+
neetoCist.filterBy({
|
|
598
|
+
kind: "image"
|
|
599
|
+
}, themePropertiesSchema).forEach(function (ele) {
|
|
600
|
+
return imageKeys.add(ele.key);
|
|
707
601
|
});
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
var attribute = _ref.attribute,
|
|
712
|
-
className = _ref.className;
|
|
713
|
-
var _useFormikContext = formik.useFormikContext(),
|
|
714
|
-
values = _useFormikContext.values;
|
|
715
|
-
var key = neetoCist.snakeToCamelCase(attribute);
|
|
716
|
-
var title = buildLabel(key, "image");
|
|
717
|
-
var imageData = values[key];
|
|
718
|
-
return /*#__PURE__*/jsxRuntime.jsx(Card$2, {
|
|
719
|
-
className: className,
|
|
720
|
-
title: title,
|
|
721
|
-
name: "images",
|
|
722
|
-
children: /*#__PURE__*/jsxRuntime.jsx(ImageBlock, {
|
|
723
|
-
attribute: attribute,
|
|
724
|
-
imageData: imageData,
|
|
725
|
-
name: key
|
|
726
|
-
})
|
|
602
|
+
return values === null || values === void 0 ? void 0 : values.filter(function (_ref2) {
|
|
603
|
+
var dependsOn = _ref2.dependsOn;
|
|
604
|
+
return !imageKeys.has(dependsOn);
|
|
727
605
|
});
|
|
728
606
|
};
|
|
729
607
|
|
|
@@ -857,6 +735,32 @@ var FontPickerBlock = function FontPickerBlock(_ref) {
|
|
|
857
735
|
});
|
|
858
736
|
};
|
|
859
737
|
|
|
738
|
+
var SelectBlock = function SelectBlock(_ref) {
|
|
739
|
+
var label = _ref.label,
|
|
740
|
+
_ref$placeholder = _ref.placeholder,
|
|
741
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
742
|
+
value = _ref.value,
|
|
743
|
+
options = _ref.options,
|
|
744
|
+
onChange = _ref.onChange;
|
|
745
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
746
|
+
className: "flex items-center justify-between",
|
|
747
|
+
"data-cy": "theme-style-".concat(utils$1.joinHyphenCase(label)),
|
|
748
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
749
|
+
"data-cy": "logo-field-labels",
|
|
750
|
+
style: "body2",
|
|
751
|
+
children: label
|
|
752
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
753
|
+
className: "w-40",
|
|
754
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
755
|
+
onChange: onChange,
|
|
756
|
+
options: options,
|
|
757
|
+
placeholder: placeholder,
|
|
758
|
+
value: value
|
|
759
|
+
})
|
|
760
|
+
})]
|
|
761
|
+
});
|
|
762
|
+
};
|
|
763
|
+
|
|
860
764
|
var SliderBlock = function SliderBlock(_ref) {
|
|
861
765
|
var label = _ref.label,
|
|
862
766
|
onChange = _ref.onChange,
|
|
@@ -899,6 +803,7 @@ var SwitchBlock = function SwitchBlock(_ref) {
|
|
|
899
803
|
var doesHelpTextExist = i18n.exists(translationKey);
|
|
900
804
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
901
805
|
className: "flex items-center justify-between",
|
|
806
|
+
"data-cy": "theme-style-content-background",
|
|
902
807
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
903
808
|
className: "inline-flex items-center gap-4",
|
|
904
809
|
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
@@ -923,9 +828,7 @@ var SwitchBlock = function SwitchBlock(_ref) {
|
|
|
923
828
|
|
|
924
829
|
var Properties = function Properties(_ref) {
|
|
925
830
|
var onPropertiesChange = _ref.onPropertiesChange,
|
|
926
|
-
|
|
927
|
-
var _useTranslation = reactI18next.useTranslation(),
|
|
928
|
-
t = _useTranslation.t;
|
|
831
|
+
condition = _ref.condition;
|
|
929
832
|
var _useConfigStore = useThemeUtils.useConfigStore(function (store) {
|
|
930
833
|
return {
|
|
931
834
|
themePropertiesSchema: store["themePropertiesSchema"]
|
|
@@ -980,11 +883,8 @@ var Properties = function Properties(_ref) {
|
|
|
980
883
|
previewingTheme: values
|
|
981
884
|
});
|
|
982
885
|
}, [values]);
|
|
983
|
-
return /*#__PURE__*/jsxRuntime.jsx(
|
|
984
|
-
|
|
985
|
-
name: "style",
|
|
986
|
-
title: t("neetoThemes.common.style"),
|
|
987
|
-
children: values.properties.sort(function (a, b) {
|
|
886
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
887
|
+
children: buildProperties(values === null || values === void 0 ? void 0 : values.properties, condition, themePropertiesSchema).sort(function (a, b) {
|
|
988
888
|
var order = function order(key) {
|
|
989
889
|
var _findBy;
|
|
990
890
|
return ((_findBy = neetoCist.findBy({
|
|
@@ -1092,6 +992,139 @@ var Properties = function Properties(_ref) {
|
|
|
1092
992
|
});
|
|
1093
993
|
};
|
|
1094
994
|
|
|
995
|
+
var ImageBlock = function ImageBlock(_ref) {
|
|
996
|
+
var _findBy;
|
|
997
|
+
var label = _ref.label,
|
|
998
|
+
name = _ref.name,
|
|
999
|
+
_ref$imageData = _ref.imageData,
|
|
1000
|
+
imageData = _ref$imageData === void 0 ? {} : _ref$imageData,
|
|
1001
|
+
_ref$uploadConfig = _ref.uploadConfig,
|
|
1002
|
+
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
1003
|
+
maxImageSize: ONE_MEGABYTE
|
|
1004
|
+
} : _ref$uploadConfig,
|
|
1005
|
+
attribute = _ref.attribute;
|
|
1006
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1007
|
+
t = _useTranslation.t;
|
|
1008
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
1009
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
1010
|
+
values = _useFormikContext.values;
|
|
1011
|
+
var _useConfigStore = useThemeUtils.useConfigStore(function (store) {
|
|
1012
|
+
return {
|
|
1013
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
1014
|
+
};
|
|
1015
|
+
}, shallow.shallow),
|
|
1016
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
1017
|
+
var propertySchema = neetoCist.findBy({
|
|
1018
|
+
key: attribute
|
|
1019
|
+
}, themePropertiesSchema);
|
|
1020
|
+
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
1021
|
+
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
1022
|
+
var positionKeyInSchema = neetoCist.findBy({
|
|
1023
|
+
key: "".concat(name, "_position")
|
|
1024
|
+
}, themePropertiesSchema);
|
|
1025
|
+
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && neetoCist.isPresent(positionKeyInSchema);
|
|
1026
|
+
var positionKeyIndex = neetoCist.findIndexBy({
|
|
1027
|
+
key: "".concat(name, "_position")
|
|
1028
|
+
}, values.properties);
|
|
1029
|
+
var handleImageChange = /*#__PURE__*/function () {
|
|
1030
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
1031
|
+
var dominantColor;
|
|
1032
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1033
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1034
|
+
case 0:
|
|
1035
|
+
_context.prev = 0;
|
|
1036
|
+
if (!(ramda.isEmpty(image.signedId) || ramda.isEmpty(image.url))) {
|
|
1037
|
+
_context.next = 4;
|
|
1038
|
+
break;
|
|
1039
|
+
}
|
|
1040
|
+
setFieldValue(name, {
|
|
1041
|
+
signedId: null,
|
|
1042
|
+
url: image.url
|
|
1043
|
+
});
|
|
1044
|
+
return _context.abrupt("return");
|
|
1045
|
+
case 4:
|
|
1046
|
+
_context.next = 6;
|
|
1047
|
+
return utils.getDominantColorFromUrl(image.url);
|
|
1048
|
+
case 6:
|
|
1049
|
+
dominantColor = _context.sent;
|
|
1050
|
+
setFieldValue(name, {
|
|
1051
|
+
signedId: image.signedId,
|
|
1052
|
+
url: image.url,
|
|
1053
|
+
dominantColor: dominantColor
|
|
1054
|
+
});
|
|
1055
|
+
_context.next = 13;
|
|
1056
|
+
break;
|
|
1057
|
+
case 10:
|
|
1058
|
+
_context.prev = 10;
|
|
1059
|
+
_context.t0 = _context["catch"](0);
|
|
1060
|
+
Toastr.error(_context.t0);
|
|
1061
|
+
case 13:
|
|
1062
|
+
case "end":
|
|
1063
|
+
return _context.stop();
|
|
1064
|
+
}
|
|
1065
|
+
}, _callee, null, [[0, 10]]);
|
|
1066
|
+
}));
|
|
1067
|
+
return function handleImageChange(_x) {
|
|
1068
|
+
return _ref2.apply(this, arguments);
|
|
1069
|
+
};
|
|
1070
|
+
}();
|
|
1071
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1072
|
+
className: "space-y-3",
|
|
1073
|
+
"data-cy": "theme-style-".concat(label ? utils$1.joinHyphenCase(label) : "image-block"),
|
|
1074
|
+
children: [label && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1075
|
+
className: "flex items-center justify-between",
|
|
1076
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1077
|
+
"data-cy": "style-fields-labels",
|
|
1078
|
+
style: "body2",
|
|
1079
|
+
children: label
|
|
1080
|
+
})
|
|
1081
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1082
|
+
className: "space-y-3",
|
|
1083
|
+
children: [/*#__PURE__*/react.createElement(ImageUploader, {
|
|
1084
|
+
uploadConfig: uploadConfig,
|
|
1085
|
+
className: "h-40 w-full",
|
|
1086
|
+
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
1087
|
+
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
1088
|
+
onUploadComplete: handleImageChange
|
|
1089
|
+
}), isPositionChangerVisible && /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
|
|
1090
|
+
label: buildLabel("".concat(name, "Position"), "image"),
|
|
1091
|
+
options: options || POSITION_OPTIONS,
|
|
1092
|
+
placeholder: t("neetoThemes.common.left"),
|
|
1093
|
+
value: neetoCist.toLabelAndValue(((_findBy = neetoCist.findBy({
|
|
1094
|
+
key: "".concat(name, "_position")
|
|
1095
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
|
|
1096
|
+
onChange: function onChange(option) {
|
|
1097
|
+
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
1098
|
+
}
|
|
1099
|
+
})]
|
|
1100
|
+
})]
|
|
1101
|
+
});
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
var Images = function Images(_ref) {
|
|
1105
|
+
var attribute = _ref.attribute,
|
|
1106
|
+
className = _ref.className,
|
|
1107
|
+
onPropertiesChange = _ref.onPropertiesChange;
|
|
1108
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
1109
|
+
values = _useFormikContext.values;
|
|
1110
|
+
var key = neetoCist.snakeToCamelCase(attribute);
|
|
1111
|
+
var title = buildLabel(key, "image");
|
|
1112
|
+
var imageData = values[key];
|
|
1113
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Card$2, {
|
|
1114
|
+
className: className,
|
|
1115
|
+
title: title,
|
|
1116
|
+
name: "images",
|
|
1117
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ImageBlock, {
|
|
1118
|
+
attribute: attribute,
|
|
1119
|
+
imageData: imageData,
|
|
1120
|
+
name: key
|
|
1121
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Properties, {
|
|
1122
|
+
onPropertiesChange: onPropertiesChange,
|
|
1123
|
+
condition: attribute
|
|
1124
|
+
})]
|
|
1125
|
+
});
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1095
1128
|
var ThemeMeta = reactUtils.withT(function (_ref) {
|
|
1096
1129
|
var t = _ref.t,
|
|
1097
1130
|
className = _ref.className;
|
|
@@ -1134,7 +1167,8 @@ var Customize = function Customize(_ref) {
|
|
|
1134
1167
|
themePropertiesSchema = _useConfigStore.themePropertiesSchema,
|
|
1135
1168
|
entityType = _useConfigStore.entityType;
|
|
1136
1169
|
var _useThemeUtils = useThemeUtils.useThemeUtils(),
|
|
1137
|
-
currentTheme = _useThemeUtils.currentTheme
|
|
1170
|
+
currentTheme = _useThemeUtils.currentTheme,
|
|
1171
|
+
setThemeState = _useThemeUtils.setThemeState;
|
|
1138
1172
|
var _useShowGlobalTheme = useShowGlobalTheme(entityType),
|
|
1139
1173
|
_useShowGlobalTheme$d = _useShowGlobalTheme.data,
|
|
1140
1174
|
_useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
|
|
@@ -1175,11 +1209,15 @@ var Customize = function Customize(_ref) {
|
|
|
1175
1209
|
});
|
|
1176
1210
|
}
|
|
1177
1211
|
return updateTheme(themeToSave, {
|
|
1178
|
-
onSuccess: function onSuccess() {
|
|
1212
|
+
onSuccess: function onSuccess(_ref4) {
|
|
1213
|
+
var theme = _ref4.theme;
|
|
1214
|
+
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(theme);
|
|
1215
|
+
setThemeState({
|
|
1216
|
+
previewingTheme: theme
|
|
1217
|
+
});
|
|
1179
1218
|
resetForm({
|
|
1180
|
-
values:
|
|
1219
|
+
values: theme
|
|
1181
1220
|
});
|
|
1182
|
-
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(values);
|
|
1183
1221
|
}
|
|
1184
1222
|
});
|
|
1185
1223
|
};
|
|
@@ -1193,10 +1231,10 @@ var Customize = function Customize(_ref) {
|
|
|
1193
1231
|
enableReinitialize: true,
|
|
1194
1232
|
onSubmit: onSubmit
|
|
1195
1233
|
},
|
|
1196
|
-
children: function children(
|
|
1197
|
-
var dirty =
|
|
1198
|
-
values =
|
|
1199
|
-
setFieldValue =
|
|
1234
|
+
children: function children(_ref5) {
|
|
1235
|
+
var dirty = _ref5.dirty,
|
|
1236
|
+
values = _ref5.values,
|
|
1237
|
+
setFieldValue = _ref5.setFieldValue;
|
|
1200
1238
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1201
1239
|
className: "neeto-themes-sidebar__scroll",
|
|
1202
1240
|
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
@@ -1205,21 +1243,27 @@ var Customize = function Customize(_ref) {
|
|
|
1205
1243
|
className: classnames({
|
|
1206
1244
|
hidden: isCustomCssScreen
|
|
1207
1245
|
})
|
|
1208
|
-
}), /*#__PURE__*/jsxRuntime.jsx(
|
|
1209
|
-
onPropertiesChange: onPropertiesChange,
|
|
1246
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Card$2, {
|
|
1210
1247
|
className: classnames({
|
|
1211
1248
|
hidden: isCustomCssScreen
|
|
1249
|
+
}),
|
|
1250
|
+
name: "style",
|
|
1251
|
+
title: t("neetoThemes.common.style"),
|
|
1252
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Properties, {
|
|
1253
|
+
onPropertiesChange: onPropertiesChange
|
|
1212
1254
|
})
|
|
1213
1255
|
}), neetoCist.filterBy({
|
|
1214
1256
|
kind: "image"
|
|
1215
|
-
}, themePropertiesSchema).map(function (
|
|
1216
|
-
var key =
|
|
1217
|
-
return /*#__PURE__*/
|
|
1257
|
+
}, themePropertiesSchema).map(function (_ref6) {
|
|
1258
|
+
var key = _ref6.key;
|
|
1259
|
+
return /*#__PURE__*/react.createElement(Images, {
|
|
1260
|
+
onPropertiesChange: onPropertiesChange,
|
|
1218
1261
|
attribute: key,
|
|
1219
1262
|
className: classnames({
|
|
1220
1263
|
hidden: isCustomCssScreen
|
|
1221
|
-
})
|
|
1222
|
-
|
|
1264
|
+
}),
|
|
1265
|
+
key: key
|
|
1266
|
+
});
|
|
1223
1267
|
}), /*#__PURE__*/jsxRuntime.jsx(CustomCSS, {
|
|
1224
1268
|
currentScreen: currentScreen,
|
|
1225
1269
|
onEditCSSClick: onEditCSSClick
|