@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shallow } from 'zustand/shallow';
|
|
2
|
-
import { useState,
|
|
2
|
+
import { useState, useEffect, createElement, useRef, memo, useCallback } from 'react';
|
|
3
3
|
import { t as t$1 } from 'i18next';
|
|
4
4
|
import { hyphenate, findBy, findIndexBy, isPresent, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
|
|
5
5
|
import { useMutationWithInvalidation, withT, useBreakpoints, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
@@ -27,18 +27,18 @@ import Editor from '@monaco-editor/react';
|
|
|
27
27
|
import { useFormikContext, Field } from 'formik';
|
|
28
28
|
import Down from '@bigbinary/neeto-icons/Down';
|
|
29
29
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
30
|
-
import
|
|
31
|
-
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
32
|
-
import ImageUploader from '@bigbinary/neeto-image-uploader-frontend/ImageUploader';
|
|
30
|
+
import { negate, isEmpty } from 'ramda';
|
|
33
31
|
import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
|
|
34
|
-
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
35
|
-
import { isEmpty, negate } from 'ramda';
|
|
36
|
-
import Select from '@bigbinary/neetoui/Select';
|
|
37
32
|
import CenterAlign from '@bigbinary/neeto-icons/CenterAlign';
|
|
38
33
|
import LeftAlign from '@bigbinary/neeto-icons/LeftAlign';
|
|
39
34
|
import ColorPicker from '@bigbinary/neetoui/ColorPicker';
|
|
35
|
+
import Select from '@bigbinary/neetoui/Select';
|
|
40
36
|
import { Slider } from 'antd';
|
|
41
37
|
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
38
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
39
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
40
|
+
import ImageUploader from '@bigbinary/neeto-image-uploader-frontend/ImageUploader';
|
|
41
|
+
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
42
42
|
import Input from '@bigbinary/neetoui/formik/Input';
|
|
43
43
|
import Search from '@bigbinary/neeto-molecules/Search';
|
|
44
44
|
import Rating from '@bigbinary/neeto-icons/Rating';
|
|
@@ -435,13 +435,15 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
435
435
|
kind = _ref.kind,
|
|
436
436
|
defaultValue = _ref.defaultValue,
|
|
437
437
|
_ref$order = _ref.order,
|
|
438
|
-
order = _ref$order === void 0 ? null : _ref$order
|
|
438
|
+
order = _ref$order === void 0 ? null : _ref$order,
|
|
439
|
+
dependsOn = _ref.dependsOn;
|
|
439
440
|
switch (kind) {
|
|
440
441
|
case "color":
|
|
441
442
|
return _objectSpread$4({
|
|
442
443
|
value: defaultValue,
|
|
443
444
|
kind: "color",
|
|
444
|
-
key: key
|
|
445
|
+
key: key,
|
|
446
|
+
dependsOn: dependsOn
|
|
445
447
|
}, order !== null && {
|
|
446
448
|
order: order
|
|
447
449
|
});
|
|
@@ -449,7 +451,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
449
451
|
return _objectSpread$4({
|
|
450
452
|
value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
|
|
451
453
|
kind: "font_family",
|
|
452
|
-
key: key
|
|
454
|
+
key: key,
|
|
455
|
+
dependsOn: dependsOn
|
|
453
456
|
}, order !== null && {
|
|
454
457
|
order: order
|
|
455
458
|
});
|
|
@@ -457,7 +460,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
457
460
|
return _objectSpread$4({
|
|
458
461
|
value: 0,
|
|
459
462
|
kind: "overlay_opacity",
|
|
460
|
-
key: key
|
|
463
|
+
key: key,
|
|
464
|
+
dependsOn: dependsOn
|
|
461
465
|
}, order !== null && {
|
|
462
466
|
order: order
|
|
463
467
|
});
|
|
@@ -465,7 +469,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
465
469
|
return _objectSpread$4({
|
|
466
470
|
value: 0,
|
|
467
471
|
kind: "slider",
|
|
468
|
-
key: key
|
|
472
|
+
key: key,
|
|
473
|
+
dependsOn: dependsOn
|
|
469
474
|
}, order !== null && {
|
|
470
475
|
order: order
|
|
471
476
|
});
|
|
@@ -473,7 +478,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
473
478
|
return _objectSpread$4({
|
|
474
479
|
value: defaultValue,
|
|
475
480
|
kind: "radius",
|
|
476
|
-
key: key
|
|
481
|
+
key: key,
|
|
482
|
+
dependsOn: dependsOn
|
|
477
483
|
}, order !== null && {
|
|
478
484
|
order: order
|
|
479
485
|
});
|
|
@@ -481,7 +487,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
481
487
|
return _objectSpread$4({
|
|
482
488
|
value: String(defaultValue),
|
|
483
489
|
kind: "boolean",
|
|
484
|
-
key: key
|
|
490
|
+
key: key,
|
|
491
|
+
dependsOn: dependsOn
|
|
485
492
|
}, order !== null && {
|
|
486
493
|
order: order
|
|
487
494
|
});
|
|
@@ -489,7 +496,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
489
496
|
return _objectSpread$4({
|
|
490
497
|
value: defaultValue,
|
|
491
498
|
kind: "order_selector",
|
|
492
|
-
key: key
|
|
499
|
+
key: key,
|
|
500
|
+
dependsOn: dependsOn
|
|
493
501
|
}, order !== null && {
|
|
494
502
|
order: order
|
|
495
503
|
});
|
|
@@ -497,7 +505,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
497
505
|
return _objectSpread$4({
|
|
498
506
|
value: defaultValue,
|
|
499
507
|
kind: "alignment_block",
|
|
500
|
-
key: key
|
|
508
|
+
key: key,
|
|
509
|
+
dependsOn: dependsOn
|
|
501
510
|
}, order !== null && {
|
|
502
511
|
order: order
|
|
503
512
|
});
|
|
@@ -505,7 +514,8 @@ var buildInitialValues = function buildInitialValues(theme, themePropertiesSchem
|
|
|
505
514
|
return _objectSpread$4({
|
|
506
515
|
value: defaultValue,
|
|
507
516
|
kind: "custom_css",
|
|
508
|
-
key: key
|
|
517
|
+
key: key,
|
|
518
|
+
dependsOn: dependsOn
|
|
509
519
|
}, order !== null && {
|
|
510
520
|
order: order
|
|
511
521
|
});
|
|
@@ -550,159 +560,27 @@ var isPropertyVisible = function isPropertyVisible(key, formikValues, themePrope
|
|
|
550
560
|
var buildLabel = function buildLabel(key, kind) {
|
|
551
561
|
return t$1("neetoThemes.properties.".concat(snakeToCamelCase(kind), ".").concat(snakeToCamelCase(key)));
|
|
552
562
|
};
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
options = _ref.options,
|
|
560
|
-
onChange = _ref.onChange;
|
|
561
|
-
return /*#__PURE__*/jsxs("div", {
|
|
562
|
-
className: "flex items-center justify-between",
|
|
563
|
-
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
564
|
-
children: [/*#__PURE__*/jsx(Typography, {
|
|
565
|
-
"data-cy": "logo-field-labels",
|
|
566
|
-
style: "body2",
|
|
567
|
-
children: label
|
|
568
|
-
}), /*#__PURE__*/jsx("div", {
|
|
569
|
-
className: "w-40",
|
|
570
|
-
children: /*#__PURE__*/jsx(Select, {
|
|
571
|
-
onChange: onChange,
|
|
572
|
-
options: options,
|
|
573
|
-
placeholder: placeholder,
|
|
574
|
-
value: value
|
|
575
|
-
})
|
|
576
|
-
})]
|
|
563
|
+
var buildProperties = function buildProperties(values, condition, themePropertiesSchema) {
|
|
564
|
+
values.forEach(function (value) {
|
|
565
|
+
themePropertiesSchema.forEach(function (theme) {
|
|
566
|
+
if (!(value.key === theme.key)) return;
|
|
567
|
+
value.dependsOn = theme.dependsOn;
|
|
568
|
+
});
|
|
577
569
|
});
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
maxImageSize: ONE_MEGABYTE
|
|
589
|
-
} : _ref$uploadConfig,
|
|
590
|
-
attribute = _ref.attribute;
|
|
591
|
-
var _useTranslation = useTranslation(),
|
|
592
|
-
t = _useTranslation.t;
|
|
593
|
-
var _useFormikContext = useFormikContext(),
|
|
594
|
-
setFieldValue = _useFormikContext.setFieldValue,
|
|
595
|
-
values = _useFormikContext.values;
|
|
596
|
-
var _useConfigStore = useConfigStore(function (store) {
|
|
597
|
-
return {
|
|
598
|
-
themePropertiesSchema: store["themePropertiesSchema"]
|
|
599
|
-
};
|
|
600
|
-
}, shallow),
|
|
601
|
-
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
602
|
-
var propertySchema = findBy({
|
|
603
|
-
key: attribute
|
|
604
|
-
}, themePropertiesSchema);
|
|
605
|
-
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
606
|
-
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
607
|
-
var positionKeyInSchema = findBy({
|
|
608
|
-
key: "".concat(name, "_position")
|
|
609
|
-
}, themePropertiesSchema);
|
|
610
|
-
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && isPresent(positionKeyInSchema);
|
|
611
|
-
var positionKeyIndex = findIndexBy({
|
|
612
|
-
key: "".concat(name, "_position")
|
|
613
|
-
}, values.properties);
|
|
614
|
-
var handleImageChange = /*#__PURE__*/function () {
|
|
615
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
616
|
-
var dominantColor;
|
|
617
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
618
|
-
while (1) switch (_context.prev = _context.next) {
|
|
619
|
-
case 0:
|
|
620
|
-
_context.prev = 0;
|
|
621
|
-
if (!(isEmpty(image.signedId) || isEmpty(image.url))) {
|
|
622
|
-
_context.next = 4;
|
|
623
|
-
break;
|
|
624
|
-
}
|
|
625
|
-
setFieldValue(name, {
|
|
626
|
-
signedId: null,
|
|
627
|
-
url: image.url
|
|
628
|
-
});
|
|
629
|
-
return _context.abrupt("return");
|
|
630
|
-
case 4:
|
|
631
|
-
_context.next = 6;
|
|
632
|
-
return getDominantColorFromUrl(image.url);
|
|
633
|
-
case 6:
|
|
634
|
-
dominantColor = _context.sent;
|
|
635
|
-
setFieldValue(name, {
|
|
636
|
-
signedId: image.signedId,
|
|
637
|
-
url: image.url,
|
|
638
|
-
dominantColor: dominantColor
|
|
639
|
-
});
|
|
640
|
-
_context.next = 13;
|
|
641
|
-
break;
|
|
642
|
-
case 10:
|
|
643
|
-
_context.prev = 10;
|
|
644
|
-
_context.t0 = _context["catch"](0);
|
|
645
|
-
Toastr.error(_context.t0);
|
|
646
|
-
case 13:
|
|
647
|
-
case "end":
|
|
648
|
-
return _context.stop();
|
|
649
|
-
}
|
|
650
|
-
}, _callee, null, [[0, 10]]);
|
|
651
|
-
}));
|
|
652
|
-
return function handleImageChange(_x) {
|
|
653
|
-
return _ref2.apply(this, arguments);
|
|
654
|
-
};
|
|
655
|
-
}();
|
|
656
|
-
return /*#__PURE__*/jsxs("div", {
|
|
657
|
-
className: "space-y-3",
|
|
658
|
-
"data-cy": "theme-style-".concat(label ? joinHyphenCase(label) : "image-block"),
|
|
659
|
-
children: [label && /*#__PURE__*/jsx("div", {
|
|
660
|
-
className: "flex items-center justify-between",
|
|
661
|
-
children: /*#__PURE__*/jsx(Typography, {
|
|
662
|
-
"data-cy": "style-fields-labels",
|
|
663
|
-
style: "body2",
|
|
664
|
-
children: label
|
|
665
|
-
})
|
|
666
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
667
|
-
className: "space-y-3",
|
|
668
|
-
children: [/*#__PURE__*/createElement(ImageUploader, {
|
|
669
|
-
uploadConfig: uploadConfig,
|
|
670
|
-
className: "h-40 w-full",
|
|
671
|
-
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
672
|
-
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
673
|
-
onUploadComplete: handleImageChange
|
|
674
|
-
}), isPositionChangerVisible && /*#__PURE__*/jsx(SelectBlock, {
|
|
675
|
-
label: buildLabel("".concat(name, "Position"), "image"),
|
|
676
|
-
options: options || POSITION_OPTIONS,
|
|
677
|
-
placeholder: t("neetoThemes.common.left"),
|
|
678
|
-
value: toLabelAndValue(((_findBy = findBy({
|
|
679
|
-
key: "".concat(name, "_position")
|
|
680
|
-
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
|
|
681
|
-
onChange: function onChange(option) {
|
|
682
|
-
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
683
|
-
}
|
|
684
|
-
})]
|
|
685
|
-
})]
|
|
570
|
+
if (condition) {
|
|
571
|
+
return filterBy({
|
|
572
|
+
dependsOn: condition
|
|
573
|
+
}, values);
|
|
574
|
+
}
|
|
575
|
+
var imageKeys = new Set();
|
|
576
|
+
filterBy({
|
|
577
|
+
kind: "image"
|
|
578
|
+
}, themePropertiesSchema).forEach(function (ele) {
|
|
579
|
+
return imageKeys.add(ele.key);
|
|
686
580
|
});
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
var attribute = _ref.attribute,
|
|
691
|
-
className = _ref.className;
|
|
692
|
-
var _useFormikContext = useFormikContext(),
|
|
693
|
-
values = _useFormikContext.values;
|
|
694
|
-
var key = snakeToCamelCase(attribute);
|
|
695
|
-
var title = buildLabel(key, "image");
|
|
696
|
-
var imageData = values[key];
|
|
697
|
-
return /*#__PURE__*/jsx(Card$2, {
|
|
698
|
-
className: className,
|
|
699
|
-
title: title,
|
|
700
|
-
name: "images",
|
|
701
|
-
children: /*#__PURE__*/jsx(ImageBlock, {
|
|
702
|
-
attribute: attribute,
|
|
703
|
-
imageData: imageData,
|
|
704
|
-
name: key
|
|
705
|
-
})
|
|
581
|
+
return values === null || values === void 0 ? void 0 : values.filter(function (_ref2) {
|
|
582
|
+
var dependsOn = _ref2.dependsOn;
|
|
583
|
+
return !imageKeys.has(dependsOn);
|
|
706
584
|
});
|
|
707
585
|
};
|
|
708
586
|
|
|
@@ -836,6 +714,32 @@ var FontPickerBlock = function FontPickerBlock(_ref) {
|
|
|
836
714
|
});
|
|
837
715
|
};
|
|
838
716
|
|
|
717
|
+
var SelectBlock = function SelectBlock(_ref) {
|
|
718
|
+
var label = _ref.label,
|
|
719
|
+
_ref$placeholder = _ref.placeholder,
|
|
720
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
721
|
+
value = _ref.value,
|
|
722
|
+
options = _ref.options,
|
|
723
|
+
onChange = _ref.onChange;
|
|
724
|
+
return /*#__PURE__*/jsxs("div", {
|
|
725
|
+
className: "flex items-center justify-between",
|
|
726
|
+
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
727
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
728
|
+
"data-cy": "logo-field-labels",
|
|
729
|
+
style: "body2",
|
|
730
|
+
children: label
|
|
731
|
+
}), /*#__PURE__*/jsx("div", {
|
|
732
|
+
className: "w-40",
|
|
733
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
734
|
+
onChange: onChange,
|
|
735
|
+
options: options,
|
|
736
|
+
placeholder: placeholder,
|
|
737
|
+
value: value
|
|
738
|
+
})
|
|
739
|
+
})]
|
|
740
|
+
});
|
|
741
|
+
};
|
|
742
|
+
|
|
839
743
|
var SliderBlock = function SliderBlock(_ref) {
|
|
840
744
|
var label = _ref.label,
|
|
841
745
|
onChange = _ref.onChange,
|
|
@@ -878,6 +782,7 @@ var SwitchBlock = function SwitchBlock(_ref) {
|
|
|
878
782
|
var doesHelpTextExist = i18n.exists(translationKey);
|
|
879
783
|
return /*#__PURE__*/jsxs("div", {
|
|
880
784
|
className: "flex items-center justify-between",
|
|
785
|
+
"data-cy": "theme-style-content-background",
|
|
881
786
|
children: [/*#__PURE__*/jsxs("div", {
|
|
882
787
|
className: "inline-flex items-center gap-4",
|
|
883
788
|
children: [/*#__PURE__*/jsx(Typography, {
|
|
@@ -902,9 +807,7 @@ var SwitchBlock = function SwitchBlock(_ref) {
|
|
|
902
807
|
|
|
903
808
|
var Properties = function Properties(_ref) {
|
|
904
809
|
var onPropertiesChange = _ref.onPropertiesChange,
|
|
905
|
-
|
|
906
|
-
var _useTranslation = useTranslation(),
|
|
907
|
-
t = _useTranslation.t;
|
|
810
|
+
condition = _ref.condition;
|
|
908
811
|
var _useConfigStore = useConfigStore(function (store) {
|
|
909
812
|
return {
|
|
910
813
|
themePropertiesSchema: store["themePropertiesSchema"]
|
|
@@ -959,11 +862,8 @@ var Properties = function Properties(_ref) {
|
|
|
959
862
|
previewingTheme: values
|
|
960
863
|
});
|
|
961
864
|
}, [values]);
|
|
962
|
-
return /*#__PURE__*/jsx(
|
|
963
|
-
|
|
964
|
-
name: "style",
|
|
965
|
-
title: t("neetoThemes.common.style"),
|
|
966
|
-
children: values.properties.sort(function (a, b) {
|
|
865
|
+
return /*#__PURE__*/jsx(Fragment, {
|
|
866
|
+
children: buildProperties(values === null || values === void 0 ? void 0 : values.properties, condition, themePropertiesSchema).sort(function (a, b) {
|
|
967
867
|
var order = function order(key) {
|
|
968
868
|
var _findBy;
|
|
969
869
|
return ((_findBy = findBy({
|
|
@@ -1071,6 +971,139 @@ var Properties = function Properties(_ref) {
|
|
|
1071
971
|
});
|
|
1072
972
|
};
|
|
1073
973
|
|
|
974
|
+
var ImageBlock = function ImageBlock(_ref) {
|
|
975
|
+
var _findBy;
|
|
976
|
+
var label = _ref.label,
|
|
977
|
+
name = _ref.name,
|
|
978
|
+
_ref$imageData = _ref.imageData,
|
|
979
|
+
imageData = _ref$imageData === void 0 ? {} : _ref$imageData,
|
|
980
|
+
_ref$uploadConfig = _ref.uploadConfig,
|
|
981
|
+
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
982
|
+
maxImageSize: ONE_MEGABYTE
|
|
983
|
+
} : _ref$uploadConfig,
|
|
984
|
+
attribute = _ref.attribute;
|
|
985
|
+
var _useTranslation = useTranslation(),
|
|
986
|
+
t = _useTranslation.t;
|
|
987
|
+
var _useFormikContext = useFormikContext(),
|
|
988
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
989
|
+
values = _useFormikContext.values;
|
|
990
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
991
|
+
return {
|
|
992
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
993
|
+
};
|
|
994
|
+
}, shallow),
|
|
995
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
996
|
+
var propertySchema = findBy({
|
|
997
|
+
key: attribute
|
|
998
|
+
}, themePropertiesSchema);
|
|
999
|
+
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
1000
|
+
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
1001
|
+
var positionKeyInSchema = findBy({
|
|
1002
|
+
key: "".concat(name, "_position")
|
|
1003
|
+
}, themePropertiesSchema);
|
|
1004
|
+
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && isPresent(positionKeyInSchema);
|
|
1005
|
+
var positionKeyIndex = findIndexBy({
|
|
1006
|
+
key: "".concat(name, "_position")
|
|
1007
|
+
}, values.properties);
|
|
1008
|
+
var handleImageChange = /*#__PURE__*/function () {
|
|
1009
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
1010
|
+
var dominantColor;
|
|
1011
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1012
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1013
|
+
case 0:
|
|
1014
|
+
_context.prev = 0;
|
|
1015
|
+
if (!(isEmpty(image.signedId) || isEmpty(image.url))) {
|
|
1016
|
+
_context.next = 4;
|
|
1017
|
+
break;
|
|
1018
|
+
}
|
|
1019
|
+
setFieldValue(name, {
|
|
1020
|
+
signedId: null,
|
|
1021
|
+
url: image.url
|
|
1022
|
+
});
|
|
1023
|
+
return _context.abrupt("return");
|
|
1024
|
+
case 4:
|
|
1025
|
+
_context.next = 6;
|
|
1026
|
+
return getDominantColorFromUrl(image.url);
|
|
1027
|
+
case 6:
|
|
1028
|
+
dominantColor = _context.sent;
|
|
1029
|
+
setFieldValue(name, {
|
|
1030
|
+
signedId: image.signedId,
|
|
1031
|
+
url: image.url,
|
|
1032
|
+
dominantColor: dominantColor
|
|
1033
|
+
});
|
|
1034
|
+
_context.next = 13;
|
|
1035
|
+
break;
|
|
1036
|
+
case 10:
|
|
1037
|
+
_context.prev = 10;
|
|
1038
|
+
_context.t0 = _context["catch"](0);
|
|
1039
|
+
Toastr.error(_context.t0);
|
|
1040
|
+
case 13:
|
|
1041
|
+
case "end":
|
|
1042
|
+
return _context.stop();
|
|
1043
|
+
}
|
|
1044
|
+
}, _callee, null, [[0, 10]]);
|
|
1045
|
+
}));
|
|
1046
|
+
return function handleImageChange(_x) {
|
|
1047
|
+
return _ref2.apply(this, arguments);
|
|
1048
|
+
};
|
|
1049
|
+
}();
|
|
1050
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1051
|
+
className: "space-y-3",
|
|
1052
|
+
"data-cy": "theme-style-".concat(label ? joinHyphenCase(label) : "image-block"),
|
|
1053
|
+
children: [label && /*#__PURE__*/jsx("div", {
|
|
1054
|
+
className: "flex items-center justify-between",
|
|
1055
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
1056
|
+
"data-cy": "style-fields-labels",
|
|
1057
|
+
style: "body2",
|
|
1058
|
+
children: label
|
|
1059
|
+
})
|
|
1060
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1061
|
+
className: "space-y-3",
|
|
1062
|
+
children: [/*#__PURE__*/createElement(ImageUploader, {
|
|
1063
|
+
uploadConfig: uploadConfig,
|
|
1064
|
+
className: "h-40 w-full",
|
|
1065
|
+
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
1066
|
+
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
1067
|
+
onUploadComplete: handleImageChange
|
|
1068
|
+
}), isPositionChangerVisible && /*#__PURE__*/jsx(SelectBlock, {
|
|
1069
|
+
label: buildLabel("".concat(name, "Position"), "image"),
|
|
1070
|
+
options: options || POSITION_OPTIONS,
|
|
1071
|
+
placeholder: t("neetoThemes.common.left"),
|
|
1072
|
+
value: toLabelAndValue(((_findBy = findBy({
|
|
1073
|
+
key: "".concat(name, "_position")
|
|
1074
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
|
|
1075
|
+
onChange: function onChange(option) {
|
|
1076
|
+
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
1077
|
+
}
|
|
1078
|
+
})]
|
|
1079
|
+
})]
|
|
1080
|
+
});
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
var Images = function Images(_ref) {
|
|
1084
|
+
var attribute = _ref.attribute,
|
|
1085
|
+
className = _ref.className,
|
|
1086
|
+
onPropertiesChange = _ref.onPropertiesChange;
|
|
1087
|
+
var _useFormikContext = useFormikContext(),
|
|
1088
|
+
values = _useFormikContext.values;
|
|
1089
|
+
var key = snakeToCamelCase(attribute);
|
|
1090
|
+
var title = buildLabel(key, "image");
|
|
1091
|
+
var imageData = values[key];
|
|
1092
|
+
return /*#__PURE__*/jsxs(Card$2, {
|
|
1093
|
+
className: className,
|
|
1094
|
+
title: title,
|
|
1095
|
+
name: "images",
|
|
1096
|
+
children: [/*#__PURE__*/jsx(ImageBlock, {
|
|
1097
|
+
attribute: attribute,
|
|
1098
|
+
imageData: imageData,
|
|
1099
|
+
name: key
|
|
1100
|
+
}), /*#__PURE__*/jsx(Properties, {
|
|
1101
|
+
onPropertiesChange: onPropertiesChange,
|
|
1102
|
+
condition: attribute
|
|
1103
|
+
})]
|
|
1104
|
+
});
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1074
1107
|
var ThemeMeta = withT(function (_ref) {
|
|
1075
1108
|
var t = _ref.t,
|
|
1076
1109
|
className = _ref.className;
|
|
@@ -1113,7 +1146,8 @@ var Customize = function Customize(_ref) {
|
|
|
1113
1146
|
themePropertiesSchema = _useConfigStore.themePropertiesSchema,
|
|
1114
1147
|
entityType = _useConfigStore.entityType;
|
|
1115
1148
|
var _useThemeUtils = useThemeUtils(),
|
|
1116
|
-
currentTheme = _useThemeUtils.currentTheme
|
|
1149
|
+
currentTheme = _useThemeUtils.currentTheme,
|
|
1150
|
+
setThemeState = _useThemeUtils.setThemeState;
|
|
1117
1151
|
var _useShowGlobalTheme = useShowGlobalTheme(entityType),
|
|
1118
1152
|
_useShowGlobalTheme$d = _useShowGlobalTheme.data,
|
|
1119
1153
|
_useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
|
|
@@ -1154,11 +1188,15 @@ var Customize = function Customize(_ref) {
|
|
|
1154
1188
|
});
|
|
1155
1189
|
}
|
|
1156
1190
|
return updateTheme(themeToSave, {
|
|
1157
|
-
onSuccess: function onSuccess() {
|
|
1191
|
+
onSuccess: function onSuccess(_ref4) {
|
|
1192
|
+
var theme = _ref4.theme;
|
|
1193
|
+
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(theme);
|
|
1194
|
+
setThemeState({
|
|
1195
|
+
previewingTheme: theme
|
|
1196
|
+
});
|
|
1158
1197
|
resetForm({
|
|
1159
|
-
values:
|
|
1198
|
+
values: theme
|
|
1160
1199
|
});
|
|
1161
|
-
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(values);
|
|
1162
1200
|
}
|
|
1163
1201
|
});
|
|
1164
1202
|
};
|
|
@@ -1172,10 +1210,10 @@ var Customize = function Customize(_ref) {
|
|
|
1172
1210
|
enableReinitialize: true,
|
|
1173
1211
|
onSubmit: onSubmit
|
|
1174
1212
|
},
|
|
1175
|
-
children: function children(
|
|
1176
|
-
var dirty =
|
|
1177
|
-
values =
|
|
1178
|
-
setFieldValue =
|
|
1213
|
+
children: function children(_ref5) {
|
|
1214
|
+
var dirty = _ref5.dirty,
|
|
1215
|
+
values = _ref5.values,
|
|
1216
|
+
setFieldValue = _ref5.setFieldValue;
|
|
1179
1217
|
return /*#__PURE__*/jsxs("div", {
|
|
1180
1218
|
className: "neeto-themes-sidebar__scroll",
|
|
1181
1219
|
children: [/*#__PURE__*/jsxs("div", {
|
|
@@ -1184,21 +1222,27 @@ var Customize = function Customize(_ref) {
|
|
|
1184
1222
|
className: classnames({
|
|
1185
1223
|
hidden: isCustomCssScreen
|
|
1186
1224
|
})
|
|
1187
|
-
}), /*#__PURE__*/jsx(
|
|
1188
|
-
onPropertiesChange: onPropertiesChange,
|
|
1225
|
+
}), /*#__PURE__*/jsx(Card$2, {
|
|
1189
1226
|
className: classnames({
|
|
1190
1227
|
hidden: isCustomCssScreen
|
|
1228
|
+
}),
|
|
1229
|
+
name: "style",
|
|
1230
|
+
title: t("neetoThemes.common.style"),
|
|
1231
|
+
children: /*#__PURE__*/jsx(Properties, {
|
|
1232
|
+
onPropertiesChange: onPropertiesChange
|
|
1191
1233
|
})
|
|
1192
1234
|
}), filterBy({
|
|
1193
1235
|
kind: "image"
|
|
1194
|
-
}, themePropertiesSchema).map(function (
|
|
1195
|
-
var key =
|
|
1196
|
-
return /*#__PURE__*/
|
|
1236
|
+
}, themePropertiesSchema).map(function (_ref6) {
|
|
1237
|
+
var key = _ref6.key;
|
|
1238
|
+
return /*#__PURE__*/createElement(Images, {
|
|
1239
|
+
onPropertiesChange: onPropertiesChange,
|
|
1197
1240
|
attribute: key,
|
|
1198
1241
|
className: classnames({
|
|
1199
1242
|
hidden: isCustomCssScreen
|
|
1200
|
-
})
|
|
1201
|
-
|
|
1243
|
+
}),
|
|
1244
|
+
key: key
|
|
1245
|
+
});
|
|
1202
1246
|
}), /*#__PURE__*/jsx(CustomCSS, {
|
|
1203
1247
|
currentScreen: currentScreen,
|
|
1204
1248
|
onEditCSSClick: onEditCSSClick
|