@bigbinary/neeto-themes-frontend 4.0.24 → 4.0.26
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/ar.json +9 -1
- package/app/javascript/src/translations/bg.json +9 -1
- package/app/javascript/src/translations/ca.json +9 -1
- package/app/javascript/src/translations/cs.json +9 -1
- package/app/javascript/src/translations/da.json +9 -1
- package/app/javascript/src/translations/de.json +9 -1
- package/app/javascript/src/translations/es-MX.json +9 -1
- package/app/javascript/src/translations/es.json +9 -1
- package/app/javascript/src/translations/et.json +9 -1
- package/app/javascript/src/translations/fi.json +9 -1
- package/app/javascript/src/translations/fil.json +9 -1
- package/app/javascript/src/translations/fr.json +9 -1
- package/app/javascript/src/translations/he.json +9 -1
- package/app/javascript/src/translations/hi.json +9 -1
- package/app/javascript/src/translations/hr.json +9 -1
- package/app/javascript/src/translations/hu.json +9 -1
- package/app/javascript/src/translations/id.json +9 -1
- package/app/javascript/src/translations/it.json +9 -1
- package/app/javascript/src/translations/ja.json +9 -1
- package/app/javascript/src/translations/ko.json +9 -1
- package/app/javascript/src/translations/nl.json +9 -1
- package/app/javascript/src/translations/pl.json +9 -1
- package/app/javascript/src/translations/pt-BR.json +9 -1
- package/app/javascript/src/translations/pt.json +9 -1
- package/app/javascript/src/translations/ro.json +9 -1
- package/app/javascript/src/translations/ru.json +9 -1
- package/app/javascript/src/translations/sk.json +9 -1
- package/app/javascript/src/translations/sl.json +9 -1
- package/app/javascript/src/translations/sv.json +9 -1
- package/app/javascript/src/translations/th.json +9 -1
- package/app/javascript/src/translations/tr.json +9 -1
- package/app/javascript/src/translations/uk.json +9 -1
- package/app/javascript/src/translations/vi.json +9 -1
- package/app/javascript/src/translations/zh-CN.json +9 -1
- package/app/javascript/src/translations/zh-TW.json +9 -1
- package/dist/.ready +1 -1
- package/dist/NeetoThemesBuilder.js +2553 -57
- package/dist/NeetoThemesBuilder.js.map +1 -1
- package/dist/cjs/NeetoThemesBuilder.js +2550 -58
- package/dist/cjs/NeetoThemesBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +3 -3
- package/dist/cjs/index.js +11 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils.js +2 -2
- package/dist/cjs/v2/NeetoThemesBuilder.js +2620 -0
- package/dist/cjs/v2/NeetoThemesBuilder.js.map +1 -0
- package/dist/cjs/v2/hooks.js +24 -0
- package/dist/cjs/v2/hooks.js.map +1 -0
- package/dist/cjs/v2/index.js +57 -0
- package/dist/cjs/v2/index.js.map +1 -0
- package/dist/cjs/v2/utils.js +15 -0
- package/dist/cjs/v2/utils.js.map +1 -0
- package/dist/hooks.js +3 -3
- package/dist/{index-BUeeI0XI.js → index-B-4HZASx.js} +3 -3
- package/dist/index-B-4HZASx.js.map +1 -0
- package/dist/{index-BZB12oJt.js → index-D2TnRRl0.js} +2 -2
- package/dist/index-D2TnRRl0.js.map +1 -0
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/{useExpandedSection-GpzbAxmE.js → useExpandedSection-B6NCIYzj.js} +2 -2
- package/dist/{useExpandedSection-GpzbAxmE.js.map → useExpandedSection-B6NCIYzj.js.map} +1 -1
- package/dist/{useExpandedSection-CelNLEKQ.js → useExpandedSection-CgRGFCFP.js} +2 -2
- package/dist/{useExpandedSection-CelNLEKQ.js.map → useExpandedSection-CgRGFCFP.js.map} +1 -1
- package/dist/{index-Brp-lmHk.js → useGlobalThemesApi-D-kXqRpG.js} +327 -2588
- package/dist/useGlobalThemesApi-D-kXqRpG.js.map +1 -0
- package/dist/{index-BEXUMCg4.js → useGlobalThemesApi-v6clqKxy.js} +335 -2587
- package/dist/useGlobalThemesApi-v6clqKxy.js.map +1 -0
- package/dist/utils.js +2 -2
- package/dist/v2/NeetoThemesBuilder.js +2599 -0
- package/dist/v2/NeetoThemesBuilder.js.map +1 -0
- package/dist/v2/hooks.js +17 -0
- package/dist/v2/hooks.js.map +1 -0
- package/dist/v2/index.js +48 -0
- package/dist/v2/index.js.map +1 -0
- package/dist/v2/utils.js +6 -0
- package/dist/v2/utils.js.map +1 -0
- package/package.json +20 -8
- package/dist/index-BEXUMCg4.js.map +0 -1
- package/dist/index-BUeeI0XI.js.map +0 -1
- package/dist/index-BZB12oJt.js.map +0 -1
- package/dist/index-Brp-lmHk.js.map +0 -1
|
@@ -1,68 +1,2560 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('zustand/shallow');
|
|
4
|
-
require('react');
|
|
5
|
-
require('@bigbinary/neeto-cist');
|
|
6
|
-
require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
7
|
-
require('@bigbinary/neetoui/Spinner');
|
|
8
|
-
require('react-i18next');
|
|
9
|
-
require('../index-
|
|
10
|
-
var
|
|
11
|
-
require('../useExpandedSection-
|
|
12
|
-
require('
|
|
13
|
-
require('
|
|
14
|
-
require('@
|
|
15
|
-
require('@bigbinary/
|
|
3
|
+
var shallow = require('zustand/shallow');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var neetoCist = require('@bigbinary/neeto-cist');
|
|
6
|
+
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
7
|
+
var Spinner = require('@bigbinary/neetoui/Spinner');
|
|
8
|
+
var reactI18next = require('react-i18next');
|
|
9
|
+
var utils = require('../index-B-4HZASx.js');
|
|
10
|
+
var useGlobalThemesApi = require('../useGlobalThemesApi-v6clqKxy.js');
|
|
11
|
+
var useExpandedSection = require('../useExpandedSection-B6NCIYzj.js');
|
|
12
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
13
|
+
var classnames = require('classnames');
|
|
14
|
+
var utils$1 = require('@bigbinary/neeto-commons-frontend/utils');
|
|
15
|
+
var Collapse = require('@bigbinary/neeto-icons/Collapse');
|
|
16
|
+
var Alert = require('@bigbinary/neetoui/Alert');
|
|
17
|
+
var Button = require('@bigbinary/neetoui/Button');
|
|
18
|
+
var reactRouterDom = require('react-router-dom');
|
|
19
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
20
|
+
var Close = require('@bigbinary/neeto-icons/Close');
|
|
21
|
+
var ramda = require('ramda');
|
|
22
|
+
var Popover = require('@bigbinary/neetoui/Popover');
|
|
23
|
+
var Typography = require('@bigbinary/neetoui/Typography');
|
|
24
|
+
var Switch = require('@bigbinary/neetoui/Switch');
|
|
25
|
+
var Tooltip = require('@bigbinary/neetoui/Tooltip');
|
|
26
|
+
var Form = require('@bigbinary/neetoui/formik/Form');
|
|
27
|
+
var BlockNavigation = require('@bigbinary/neetoui/formik/BlockNavigation');
|
|
28
|
+
var formik = require('formik');
|
|
29
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
30
|
+
var i18n = require('i18next');
|
|
31
|
+
var Right = require('@bigbinary/neeto-icons/Right');
|
|
32
|
+
var Left = require('@bigbinary/neeto-icons/Left');
|
|
33
|
+
var HelpPopover = require('@bigbinary/neeto-molecules/HelpPopover');
|
|
34
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
|
35
|
+
var reactDom = require('react-dom');
|
|
36
|
+
var Radio = require('@bigbinary/neetoui/formik/Radio');
|
|
37
|
+
var CenterAlign = require('@bigbinary/neeto-icons/CenterAlign');
|
|
38
|
+
var LeftAlign = require('@bigbinary/neeto-icons/LeftAlign');
|
|
39
|
+
var ColorPicker = require('@bigbinary/neetoui/ColorPicker');
|
|
40
|
+
var Select = require('@bigbinary/neetoui/Select');
|
|
41
|
+
var antd = require('antd');
|
|
42
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
43
|
+
var Help = require('@bigbinary/neeto-icons/Help');
|
|
44
|
+
var Checkbox = require('@bigbinary/neetoui/Checkbox');
|
|
45
|
+
var Modal = require('@bigbinary/neetoui/Modal');
|
|
46
|
+
var Input = require('@bigbinary/neetoui/Input');
|
|
47
|
+
var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
|
|
48
|
+
var _regeneratorRuntime = require('@babel/runtime/regenerator');
|
|
49
|
+
var ImageUploader = require('@bigbinary/neeto-image-uploader-frontend/ImageUploader');
|
|
50
|
+
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
51
|
+
var Input$1 = require('@bigbinary/neetoui/formik/Input');
|
|
52
|
+
var Search = require('@bigbinary/neeto-molecules/Search');
|
|
53
|
+
var AddImage = require('@bigbinary/neeto-icons/AddImage');
|
|
54
|
+
var CodeBlock = require('@bigbinary/neeto-icons/CodeBlock');
|
|
55
|
+
var ColorPicker$1 = require('@bigbinary/neeto-icons/ColorPicker');
|
|
56
|
+
var MoreDropdown = require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
57
|
+
var LeftArrow = require('@bigbinary/neeto-icons/LeftArrow');
|
|
58
|
+
var RightArrow = require('@bigbinary/neeto-icons/RightArrow');
|
|
59
|
+
var Search$1 = require('@bigbinary/neeto-icons/Search');
|
|
60
|
+
require('@bigbinary/neeto-atoms');
|
|
16
61
|
require('@tanstack/react-query');
|
|
17
62
|
require('axios');
|
|
18
|
-
require('@babel/runtime/helpers/slicedToArray');
|
|
19
|
-
require('i18next');
|
|
20
|
-
require('classnames');
|
|
21
|
-
require('@bigbinary/neeto-commons-frontend/utils');
|
|
22
|
-
require('@bigbinary/neeto-icons/Collapse');
|
|
23
|
-
require('@bigbinary/neetoui/Alert');
|
|
24
|
-
require('@bigbinary/neetoui/Button');
|
|
25
|
-
require('react-router-dom');
|
|
26
|
-
require('@babel/runtime/helpers/defineProperty');
|
|
27
|
-
require('@babel/runtime/helpers/objectWithoutProperties');
|
|
28
|
-
require('@bigbinary/neeto-icons/Close');
|
|
29
|
-
require('ramda');
|
|
30
|
-
require('@bigbinary/neetoui/Popover');
|
|
31
|
-
require('@bigbinary/neetoui/Typography');
|
|
32
|
-
require('@bigbinary/neetoui/Switch');
|
|
33
|
-
require('@bigbinary/neetoui/Tooltip');
|
|
34
|
-
require('@bigbinary/neetoui/formik/Form');
|
|
35
|
-
require('@bigbinary/neetoui/formik/BlockNavigation');
|
|
36
|
-
require('formik');
|
|
37
|
-
require('@bigbinary/neeto-icons/Right');
|
|
38
|
-
require('@bigbinary/neeto-icons/Left');
|
|
39
|
-
require('@bigbinary/neeto-molecules/HelpPopover');
|
|
40
|
-
require('@babel/runtime/helpers/toConsumableArray');
|
|
41
|
-
require('react-dom');
|
|
42
|
-
require('@bigbinary/neetoui/formik/Radio');
|
|
43
|
-
require('@bigbinary/neeto-icons/CenterAlign');
|
|
44
|
-
require('@bigbinary/neeto-icons/LeftAlign');
|
|
45
|
-
require('@bigbinary/neetoui/ColorPicker');
|
|
46
|
-
require('@bigbinary/neetoui/Select');
|
|
47
|
-
require('antd');
|
|
48
|
-
require('@bigbinary/neeto-icons/Help');
|
|
49
|
-
require('@bigbinary/neetoui/Checkbox');
|
|
50
|
-
require('@bigbinary/neetoui/Modal');
|
|
51
|
-
require('@bigbinary/neetoui/Input');
|
|
52
|
-
require('@bigbinary/neeto-image-uploader-frontend/ImageUploader');
|
|
53
|
-
require('@bigbinary/neetoui/formik/Input');
|
|
54
|
-
require('@bigbinary/neeto-molecules/Search');
|
|
55
|
-
require('@bigbinary/neeto-icons/AddImage');
|
|
56
|
-
require('@bigbinary/neeto-icons/CodeBlock');
|
|
57
|
-
require('@bigbinary/neeto-icons/ColorPicker');
|
|
58
|
-
require('@bigbinary/neeto-molecules/MoreDropdown');
|
|
59
|
-
require('@bigbinary/neeto-icons/LeftArrow');
|
|
60
|
-
require('@bigbinary/neeto-icons/RightArrow');
|
|
61
|
-
require('@bigbinary/neeto-icons/Search');
|
|
62
63
|
require('zustand');
|
|
63
64
|
require('yup');
|
|
64
65
|
|
|
66
|
+
var DESIGN_SCREENS = {
|
|
67
|
+
THEMES: "Themes",
|
|
68
|
+
Customize: "Customize",
|
|
69
|
+
CustomCSS: "CustomCSS"
|
|
70
|
+
};
|
|
71
|
+
var ONE_MEGABYTE = 1;
|
|
65
72
|
|
|
73
|
+
var MonacoEditor = /*#__PURE__*/react.lazy(function () {
|
|
74
|
+
return import('@monaco-editor/react');
|
|
75
|
+
});
|
|
76
|
+
var Editor = function Editor(_ref) {
|
|
77
|
+
var value = _ref.value,
|
|
78
|
+
isCustomCssScreen = _ref.isCustomCssScreen,
|
|
79
|
+
onChange = _ref.onChange;
|
|
80
|
+
return /*#__PURE__*/jsxRuntime.jsx(react.Suspense, {
|
|
81
|
+
fallback: /*#__PURE__*/jsxRuntime.jsx(Spinner, {}),
|
|
82
|
+
children: /*#__PURE__*/jsxRuntime.jsx(MonacoEditor, {
|
|
83
|
+
onChange: onChange,
|
|
84
|
+
value: value,
|
|
85
|
+
language: "css",
|
|
86
|
+
theme: "vs-dark",
|
|
87
|
+
className: classnames({
|
|
88
|
+
rounded: true,
|
|
89
|
+
"css-editor-height__expanded": isCustomCssScreen,
|
|
90
|
+
"css-editor-height__regular": !isCustomCssScreen
|
|
91
|
+
}),
|
|
92
|
+
options: {
|
|
93
|
+
scrollBeyondLastLine: false,
|
|
94
|
+
minimap: {
|
|
95
|
+
enabled: false
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
};
|
|
66
101
|
|
|
67
|
-
|
|
102
|
+
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
103
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
104
|
+
var Card$2 = function Card(_ref) {
|
|
105
|
+
var _ref$title = _ref.title,
|
|
106
|
+
title = _ref$title === void 0 ? "" : _ref$title,
|
|
107
|
+
children = _ref.children,
|
|
108
|
+
name = _ref.name,
|
|
109
|
+
className = _ref.className,
|
|
110
|
+
helpPopoverProps = _ref.helpPopoverProps,
|
|
111
|
+
required = _ref.required;
|
|
112
|
+
var _useExpandedSection = useExpandedSection.useExpandedSection(),
|
|
113
|
+
expandedSection = _useExpandedSection.expandedSection,
|
|
114
|
+
setExpandedSection = _useExpandedSection.setExpandedSection;
|
|
115
|
+
var isOpen = expandedSection === name;
|
|
116
|
+
var isRTL = i18n.dir() === "rtl";
|
|
117
|
+
var ToggleIcon = isRTL ? Left : Right;
|
|
118
|
+
var handleToggle = function handleToggle() {
|
|
119
|
+
return setExpandedSection(isOpen ? "" : name);
|
|
120
|
+
};
|
|
121
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
122
|
+
"data-testid": "theme-".concat(neetoCist.hyphenate(title), "-properties"),
|
|
123
|
+
className: classnames("neeto-themes-nano-section neeto-ui-border-gray-200 border-b pt-2 transition-all duration-300 last:border-none", className, {
|
|
124
|
+
"pb-2": !isOpen,
|
|
125
|
+
"pb-3": isOpen
|
|
126
|
+
}),
|
|
127
|
+
children: [title && /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
128
|
+
className: "neeto-themes-nano-section__title flex w-full cursor-pointer items-center justify-between px-1 py-2 focus:outline-none",
|
|
129
|
+
type: "button",
|
|
130
|
+
onClick: handleToggle,
|
|
131
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(Typography, {
|
|
132
|
+
className: "flex min-w-0 grow items-center gap-2 text-start",
|
|
133
|
+
component: "span",
|
|
134
|
+
"data-testid": "theme-properties",
|
|
135
|
+
lineHeight: "normal",
|
|
136
|
+
style: "h4",
|
|
137
|
+
weight: "semibold",
|
|
138
|
+
children: [title, required && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
139
|
+
"aria-hidden": true,
|
|
140
|
+
className: "-ms-1",
|
|
141
|
+
children: "*"
|
|
142
|
+
}), neetoCist.isPresent(helpPopoverProps) && /*#__PURE__*/jsxRuntime.jsx(HelpPopover, _objectSpread$4({}, helpPopoverProps))]
|
|
143
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ToggleIcon, {
|
|
144
|
+
size: 20,
|
|
145
|
+
className: classnames("transition-all duration-300", {
|
|
146
|
+
"rotate-90 rtl:-rotate-90": isOpen
|
|
147
|
+
})
|
|
148
|
+
})]
|
|
149
|
+
}), children && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
150
|
+
className: classnames("neeto-themes-nano-section__content w-full space-y-3 overflow-hidden px-1 transition-all duration-300", {
|
|
151
|
+
"neeto-themes-nano-section__content--closed": !isOpen,
|
|
152
|
+
"neeto-themes-nano-section__content--open pb-1": isOpen
|
|
153
|
+
}),
|
|
154
|
+
children: children
|
|
155
|
+
})]
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: true } : { done: false, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = true, u = false; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = true, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
160
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
161
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
162
|
+
var isScreenCustomCSS = function isScreenCustomCSS(screen) {
|
|
163
|
+
return screen === DESIGN_SCREENS.CustomCSS;
|
|
164
|
+
};
|
|
165
|
+
var buildPathname = function buildPathname(route) {
|
|
166
|
+
var pathname = "";
|
|
167
|
+
var _iterator = _createForOfIteratorHelper(location.pathname.split("/")),
|
|
168
|
+
_step;
|
|
169
|
+
try {
|
|
170
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
171
|
+
var segment = _step.value;
|
|
172
|
+
if (ramda.isEmpty(segment)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (segment === "themes") {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
pathname += "/".concat(segment);
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
_iterator.e(err);
|
|
182
|
+
} finally {
|
|
183
|
+
_iterator.f();
|
|
184
|
+
}
|
|
185
|
+
return "".concat(pathname).concat(route);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// FLIP: measure each theme card's position, apply the React update, then
|
|
189
|
+
// transform every card back to its old spot and let a CSS transition glide
|
|
190
|
+
// it to the new one. The animation itself is CSS (.neeto-themes-flip-animating).
|
|
191
|
+
var animateThemeReorder = function animateThemeReorder(updateFn) {
|
|
192
|
+
var prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
193
|
+
var cards = _toConsumableArray(document.querySelectorAll("[data-flip-id]"));
|
|
194
|
+
var scrollContainer = document.querySelector(".neeto-themes-sidebar__scroll");
|
|
195
|
+
if (prefersReducedMotion || cards.length === 0) {
|
|
196
|
+
updateFn();
|
|
197
|
+
if (scrollContainer) scrollContainer.scrollTop = 0;
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
var oldRects = new Map(cards.map(function (card) {
|
|
201
|
+
return [card.dataset.flipId, card.getBoundingClientRect()];
|
|
202
|
+
}));
|
|
203
|
+
reactDom.flushSync(updateFn);
|
|
204
|
+
|
|
205
|
+
// Move the viewport to the top — the applied theme is now the first card.
|
|
206
|
+
// The FLIP deltas below are measured after this, so the scroll is folded
|
|
207
|
+
// into the glide instead of showing as an instant jump.
|
|
208
|
+
if (scrollContainer) scrollContainer.scrollTop = 0;
|
|
209
|
+
var flips = _toConsumableArray(document.querySelectorAll("[data-flip-id]")).map(function (card) {
|
|
210
|
+
var oldRect = oldRects.get(card.dataset.flipId);
|
|
211
|
+
if (!oldRect) return null;
|
|
212
|
+
var newRect = card.getBoundingClientRect();
|
|
213
|
+
var dx = oldRect.left - newRect.left;
|
|
214
|
+
var dy = oldRect.top - newRect.top;
|
|
215
|
+
return dx || dy ? {
|
|
216
|
+
card: card,
|
|
217
|
+
dx: dx,
|
|
218
|
+
dy: dy
|
|
219
|
+
} : null;
|
|
220
|
+
}).filter(Boolean);
|
|
221
|
+
if (flips.length === 0) return;
|
|
222
|
+
flips.forEach(function (_ref) {
|
|
223
|
+
var card = _ref.card,
|
|
224
|
+
dx = _ref.dx,
|
|
225
|
+
dy = _ref.dy;
|
|
226
|
+
card.style.transform = "translate(".concat(dx, "px, ").concat(dy, "px)");
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Force a reflow so the starting transform is committed before animating.
|
|
230
|
+
document.body.offsetHeight;
|
|
231
|
+
flips.forEach(function (_ref2) {
|
|
232
|
+
var card = _ref2.card;
|
|
233
|
+
card.classList.add("neeto-themes-flip-animating");
|
|
234
|
+
card.style.transform = "";
|
|
235
|
+
card.addEventListener("transitionend", function () {
|
|
236
|
+
card.classList.remove("neeto-themes-flip-animating");
|
|
237
|
+
}, {
|
|
238
|
+
once: true
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
var CustomCSS = function CustomCSS(_ref) {
|
|
244
|
+
var onEditCSSClick = _ref.onEditCSSClick,
|
|
245
|
+
currentScreen = _ref.currentScreen,
|
|
246
|
+
isEnabled = _ref.isEnabled,
|
|
247
|
+
isProFeature = _ref.isProFeature;
|
|
248
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
249
|
+
t = _useTranslation.t;
|
|
250
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
251
|
+
values = _useFormikContext.values,
|
|
252
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
253
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
254
|
+
return {
|
|
255
|
+
themePropertiesSchema: store["themePropertiesSchema"],
|
|
256
|
+
helpPopoverProps: store["helpPopoverProps"]
|
|
257
|
+
};
|
|
258
|
+
}, shallow.shallow),
|
|
259
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema,
|
|
260
|
+
helpPopoverProps = _useConfigStore.helpPopoverProps;
|
|
261
|
+
var _helpPopoverProps$cus = helpPopoverProps.customCss,
|
|
262
|
+
customCssHelpPopoverProps = _helpPopoverProps$cus === void 0 ? {} : _helpPopoverProps$cus;
|
|
263
|
+
var _useExpandedSection = useExpandedSection.useExpandedSection(),
|
|
264
|
+
expandedSection = _useExpandedSection.expandedSection;
|
|
265
|
+
var isExpanded = expandedSection === "customcss";
|
|
266
|
+
var customCSS = neetoCist.findBy({
|
|
267
|
+
kind: "custom_css"
|
|
268
|
+
}, values.properties);
|
|
269
|
+
if (!customCSS || !isEnabled && !isProFeature) return null;
|
|
270
|
+
var parentElementClass = neetoCist.findBy({
|
|
271
|
+
kind: "custom_css"
|
|
272
|
+
}, themePropertiesSchema).parentClass;
|
|
273
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
274
|
+
var handleEditorToggle = function handleEditorToggle() {
|
|
275
|
+
if (!isCustomCssScreen) return onEditCSSClick(DESIGN_SCREENS.CustomCSS);
|
|
276
|
+
onEditCSSClick(DESIGN_SCREENS.Customize);
|
|
277
|
+
return setTimeout(function () {
|
|
278
|
+
utils.scrollElementIntoView("css-editor");
|
|
279
|
+
}, 400);
|
|
280
|
+
};
|
|
281
|
+
var handleChange = function handleChange(value) {
|
|
282
|
+
var index = neetoCist.findIndexBy({
|
|
283
|
+
key: customCSS.key
|
|
284
|
+
}, values.properties);
|
|
285
|
+
if (index !== -1 && values.properties[index].value !== value) {
|
|
286
|
+
setFieldValue("properties[".concat(index, "].value"), value);
|
|
287
|
+
utils.setCustomCSS({
|
|
288
|
+
css: value,
|
|
289
|
+
elementId: customCSS.key,
|
|
290
|
+
parentElementClass: parentElementClass
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
295
|
+
className: "neeto-themes-sidebar__custom-css-wrapper",
|
|
296
|
+
id: "css-editor",
|
|
297
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Card$2, {
|
|
298
|
+
name: "customcss",
|
|
299
|
+
helpPopoverProps: isEnabled ? customCssHelpPopoverProps : {
|
|
300
|
+
title: t("neetoThemes.common.proFeature.customCSS.title"),
|
|
301
|
+
description: t("neetoThemes.common.proFeature.customCSS.description")
|
|
302
|
+
},
|
|
303
|
+
title: isCustomCssScreen ? "" : t("neetoThemes.build.leftSideBar.themes.customCSS"),
|
|
304
|
+
children: isEnabled ? /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
305
|
+
className: "w-full",
|
|
306
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
307
|
+
className: "neeto-themes-sidebar__custom-css-editor-header w-full justify-end gap-1 rounded-b-none p-2",
|
|
308
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
309
|
+
size: "small",
|
|
310
|
+
style: "secondary",
|
|
311
|
+
label: isCustomCssScreen ? t("neetoThemes.buttons.minimizeEditor") : t("neetoThemes.buttons.expandEditor"),
|
|
312
|
+
onClick: handleEditorToggle
|
|
313
|
+
})
|
|
314
|
+
}), isExpanded && /*#__PURE__*/jsxRuntime.jsx(Editor, {
|
|
315
|
+
isCustomCssScreen: isCustomCssScreen,
|
|
316
|
+
value: customCSS.value,
|
|
317
|
+
onChange: handleChange
|
|
318
|
+
})]
|
|
319
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
320
|
+
className: "px-1 py-2",
|
|
321
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
322
|
+
lineHeight: "normal",
|
|
323
|
+
style: "body2",
|
|
324
|
+
children: t("neetoThemes.common.proFeature.customCSS.description")
|
|
325
|
+
})
|
|
326
|
+
})
|
|
327
|
+
})
|
|
328
|
+
});
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
var LogoPosition = function LogoPosition() {
|
|
332
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
333
|
+
t = _useTranslation.t;
|
|
334
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
335
|
+
values = _useFormikContext.values;
|
|
336
|
+
var index = neetoCist.findIndexBy({
|
|
337
|
+
key: "logo_position"
|
|
338
|
+
}, values.properties);
|
|
339
|
+
// Do not show this field if the logo_position property is not present.
|
|
340
|
+
if (index === -1) return null;
|
|
341
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Radio, {
|
|
342
|
+
stacked: true,
|
|
343
|
+
name: "properties[".concat(index, "].value"),
|
|
344
|
+
label: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
345
|
+
className: "my-3",
|
|
346
|
+
component: "span",
|
|
347
|
+
style: "body2",
|
|
348
|
+
weight: "semibold",
|
|
349
|
+
children: t("neetoThemes.build.leftSideBar.themes.logoPosition.title")
|
|
350
|
+
}),
|
|
351
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Radio.Item, {
|
|
352
|
+
value: "over_left",
|
|
353
|
+
label: /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
354
|
+
className: "flex flex-col gap-1",
|
|
355
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
356
|
+
component: "span",
|
|
357
|
+
style: "body2",
|
|
358
|
+
weight: "semibold",
|
|
359
|
+
children: t("neetoThemes.build.leftSideBar.themes.logoPosition.overLeft")
|
|
360
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
361
|
+
component: "span",
|
|
362
|
+
style: "body3",
|
|
363
|
+
weight: "normal",
|
|
364
|
+
children: t("neetoThemes.build.leftSideBar.themes.logoPosition.overLeftDescription")
|
|
365
|
+
})]
|
|
366
|
+
})
|
|
367
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Radio.Item, {
|
|
368
|
+
value: "below_left",
|
|
369
|
+
label: /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
370
|
+
className: "flex flex-col gap-1",
|
|
371
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
372
|
+
component: "span",
|
|
373
|
+
style: "body2",
|
|
374
|
+
weight: "semibold",
|
|
375
|
+
children: t("neetoThemes.build.leftSideBar.themes.logoPosition.belowLeft")
|
|
376
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
377
|
+
component: "span",
|
|
378
|
+
style: "body3",
|
|
379
|
+
weight: "normal",
|
|
380
|
+
children: t("neetoThemes.build.leftSideBar.themes.logoPosition.belowLeftDescription")
|
|
381
|
+
})]
|
|
382
|
+
})
|
|
383
|
+
})]
|
|
384
|
+
});
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
388
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
389
|
+
|
|
390
|
+
// Capitalizes the first letter of the displayed label while keeping the
|
|
391
|
+
// underlying value untouched (position values like "top left" are used
|
|
392
|
+
// verbatim as CSS background-position, so they must stay lowercase).
|
|
393
|
+
var toCapitalizedOption = function toCapitalizedOption(value) {
|
|
394
|
+
var _toLabelAndValue = neetoCist.toLabelAndValue(value),
|
|
395
|
+
label = _toLabelAndValue.label,
|
|
396
|
+
optionValue = _toLabelAndValue.value;
|
|
397
|
+
return {
|
|
398
|
+
label: label ? neetoCist.capitalize(label) : label,
|
|
399
|
+
value: optionValue
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
|
|
403
|
+
if (neetoCist.isPresent(theme)) return theme;
|
|
404
|
+
return {
|
|
405
|
+
name: i18n.t("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
|
|
406
|
+
properties: themePropertiesSchema.map(function (_ref) {
|
|
407
|
+
var key = _ref.key,
|
|
408
|
+
kind = _ref.kind,
|
|
409
|
+
defaultValue = _ref.defaultValue,
|
|
410
|
+
_ref$order = _ref.order,
|
|
411
|
+
order = _ref$order === void 0 ? null : _ref$order,
|
|
412
|
+
dependsOn = _ref.dependsOn;
|
|
413
|
+
switch (kind) {
|
|
414
|
+
case "text_input":
|
|
415
|
+
return _objectSpread$3({
|
|
416
|
+
value: defaultValue || "",
|
|
417
|
+
kind: "text_input",
|
|
418
|
+
key: key,
|
|
419
|
+
dependsOn: dependsOn
|
|
420
|
+
}, order !== null && {
|
|
421
|
+
order: order
|
|
422
|
+
});
|
|
423
|
+
case "color":
|
|
424
|
+
return _objectSpread$3({
|
|
425
|
+
value: defaultValue,
|
|
426
|
+
kind: "color",
|
|
427
|
+
key: key,
|
|
428
|
+
dependsOn: dependsOn
|
|
429
|
+
}, order !== null && {
|
|
430
|
+
order: order
|
|
431
|
+
});
|
|
432
|
+
case "font_family":
|
|
433
|
+
return _objectSpread$3({
|
|
434
|
+
value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
|
|
435
|
+
kind: "font_family",
|
|
436
|
+
key: key,
|
|
437
|
+
dependsOn: dependsOn
|
|
438
|
+
}, order !== null && {
|
|
439
|
+
order: order
|
|
440
|
+
});
|
|
441
|
+
case "overlay_opacity":
|
|
442
|
+
return _objectSpread$3({
|
|
443
|
+
value: 0,
|
|
444
|
+
kind: "overlay_opacity",
|
|
445
|
+
key: key,
|
|
446
|
+
dependsOn: dependsOn
|
|
447
|
+
}, order !== null && {
|
|
448
|
+
order: order
|
|
449
|
+
});
|
|
450
|
+
case "slider":
|
|
451
|
+
return _objectSpread$3({
|
|
452
|
+
value: 0,
|
|
453
|
+
kind: "slider",
|
|
454
|
+
key: key,
|
|
455
|
+
dependsOn: dependsOn
|
|
456
|
+
}, order !== null && {
|
|
457
|
+
order: order
|
|
458
|
+
});
|
|
459
|
+
case "radius":
|
|
460
|
+
return _objectSpread$3({
|
|
461
|
+
value: defaultValue,
|
|
462
|
+
kind: "radius",
|
|
463
|
+
key: key,
|
|
464
|
+
dependsOn: dependsOn
|
|
465
|
+
}, order !== null && {
|
|
466
|
+
order: order
|
|
467
|
+
});
|
|
468
|
+
case "boolean":
|
|
469
|
+
return _objectSpread$3({
|
|
470
|
+
value: String(defaultValue),
|
|
471
|
+
kind: "boolean",
|
|
472
|
+
key: key,
|
|
473
|
+
dependsOn: dependsOn
|
|
474
|
+
}, order !== null && {
|
|
475
|
+
order: order
|
|
476
|
+
});
|
|
477
|
+
case "order_selector":
|
|
478
|
+
return _objectSpread$3({
|
|
479
|
+
value: defaultValue,
|
|
480
|
+
kind: "order_selector",
|
|
481
|
+
key: key,
|
|
482
|
+
dependsOn: dependsOn
|
|
483
|
+
}, order !== null && {
|
|
484
|
+
order: order
|
|
485
|
+
});
|
|
486
|
+
case "alignment_block":
|
|
487
|
+
return _objectSpread$3({
|
|
488
|
+
value: defaultValue,
|
|
489
|
+
kind: "alignment_block",
|
|
490
|
+
key: key,
|
|
491
|
+
dependsOn: dependsOn
|
|
492
|
+
}, order !== null && {
|
|
493
|
+
order: order
|
|
494
|
+
});
|
|
495
|
+
case "custom_css":
|
|
496
|
+
return _objectSpread$3({
|
|
497
|
+
value: defaultValue,
|
|
498
|
+
kind: "custom_css",
|
|
499
|
+
key: key,
|
|
500
|
+
dependsOn: dependsOn
|
|
501
|
+
}, order !== null && {
|
|
502
|
+
order: order
|
|
503
|
+
});
|
|
504
|
+
case "logo_position":
|
|
505
|
+
return _objectSpread$3({
|
|
506
|
+
value: defaultValue,
|
|
507
|
+
kind: "logo_position",
|
|
508
|
+
key: key,
|
|
509
|
+
dependsOn: dependsOn
|
|
510
|
+
}, order !== null && {
|
|
511
|
+
order: order
|
|
512
|
+
});
|
|
513
|
+
default:
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
}).filter(neetoCist.isNot(null))
|
|
517
|
+
};
|
|
518
|
+
};
|
|
519
|
+
var buildImageData = function buildImageData(values, themePropertiesSchema) {
|
|
520
|
+
return neetoCist.filterBy({
|
|
521
|
+
kind: "image"
|
|
522
|
+
}, themePropertiesSchema).reduce(function (acc, item) {
|
|
523
|
+
var _values$snakeToCamelC;
|
|
524
|
+
var signedId = (_values$snakeToCamelC = values[neetoCist.snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
|
|
525
|
+
acc[item.key] = signedId;
|
|
526
|
+
return acc;
|
|
527
|
+
}, {});
|
|
528
|
+
};
|
|
529
|
+
var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
|
|
530
|
+
var property = neetoCist.findBy({
|
|
531
|
+
key: key
|
|
532
|
+
}, themePropertiesSchema);
|
|
533
|
+
if (neetoCist.isNotPresent(property)) return false;
|
|
534
|
+
if (property !== null && property !== void 0 && property.hidden) return false;
|
|
535
|
+
var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
|
|
536
|
+
if (neetoCist.isNotPresent(conditionalKey)) return true;
|
|
537
|
+
var dependentPropertySchema = neetoCist.findBy({
|
|
538
|
+
key: conditionalKey
|
|
539
|
+
}, themePropertiesSchema);
|
|
540
|
+
var dependentProperty = neetoCist.findBy({
|
|
541
|
+
key: conditionalKey
|
|
542
|
+
}, formikValues.properties);
|
|
543
|
+
if (dependentPropertySchema.kind === "image") {
|
|
544
|
+
var _formikValues$snakeTo;
|
|
545
|
+
return neetoCist.isPresent((_formikValues$snakeTo = formikValues[neetoCist.snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
|
|
546
|
+
} else if (dependentPropertySchema.kind === "boolean") {
|
|
547
|
+
return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
|
|
548
|
+
}
|
|
549
|
+
return neetoCist.isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
|
|
550
|
+
};
|
|
551
|
+
var buildLabel = function buildLabel(key, kind) {
|
|
552
|
+
return i18n.t("neetoThemes.properties.".concat(neetoCist.snakeToCamelCase(kind), ".").concat(neetoCist.snakeToCamelCase(key)));
|
|
553
|
+
};
|
|
554
|
+
var buildProperties = function buildProperties(values, condition, themePropertiesSchema) {
|
|
555
|
+
values.forEach(function (value) {
|
|
556
|
+
themePropertiesSchema.forEach(function (theme) {
|
|
557
|
+
if (!(value.key === theme.key)) return;
|
|
558
|
+
value.dependsOn = theme.dependsOn;
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
if (condition) {
|
|
562
|
+
return neetoCist.filterBy({
|
|
563
|
+
dependsOn: condition
|
|
564
|
+
}, values);
|
|
565
|
+
}
|
|
566
|
+
var imageKeys = new Set();
|
|
567
|
+
neetoCist.filterBy({
|
|
568
|
+
kind: "image"
|
|
569
|
+
}, themePropertiesSchema).forEach(function (ele) {
|
|
570
|
+
return imageKeys.add(ele.key);
|
|
571
|
+
});
|
|
572
|
+
return values === null || values === void 0 ? void 0 : values.filter(function (_ref2) {
|
|
573
|
+
var dependsOn = _ref2.dependsOn;
|
|
574
|
+
return !imageKeys.has(dependsOn);
|
|
575
|
+
});
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
var AlignmentBlock = function AlignmentBlock(_ref) {
|
|
579
|
+
var label = _ref.label,
|
|
580
|
+
name = _ref.name;
|
|
581
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
582
|
+
className: "flex items-center justify-between gap-2",
|
|
583
|
+
"data-testid": utils$1.joinHyphenCase(label),
|
|
584
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
585
|
+
"data-testid": "style-fields-labels",
|
|
586
|
+
style: "body2",
|
|
587
|
+
children: label
|
|
588
|
+
}), /*#__PURE__*/jsxRuntime.jsx(formik.Field, {
|
|
589
|
+
name: name,
|
|
590
|
+
children: function children(_ref2) {
|
|
591
|
+
var value = _ref2.field.value,
|
|
592
|
+
setFieldValue = _ref2.form.setFieldValue;
|
|
593
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
594
|
+
className: "neeto-ui-border-gray-300 neeto-themes-nano-alignment-block flex items-center border",
|
|
595
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
596
|
+
className: "neeto-themes-nano-alignment-button neeto-themes-nano-alignment-button__alignment-left",
|
|
597
|
+
"data-testid": "alignment-left",
|
|
598
|
+
size: "medium",
|
|
599
|
+
style: value === "left" ? "primary" : "text",
|
|
600
|
+
icon: function icon() {
|
|
601
|
+
return /*#__PURE__*/jsxRuntime.jsx(LeftAlign, {
|
|
602
|
+
size: 20,
|
|
603
|
+
className: classnames({
|
|
604
|
+
rounded: true,
|
|
605
|
+
"neeto-ui-text-primary-800": value === "left",
|
|
606
|
+
"neeto-ui-text-gray-600": value !== "left"
|
|
607
|
+
})
|
|
608
|
+
});
|
|
609
|
+
},
|
|
610
|
+
tooltipProps: {
|
|
611
|
+
content: "Left align",
|
|
612
|
+
position: "bottom"
|
|
613
|
+
},
|
|
614
|
+
onClick: function onClick() {
|
|
615
|
+
return setFieldValue(name, "left");
|
|
616
|
+
}
|
|
617
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
618
|
+
className: "neeto-themes-nano-alignment-divider"
|
|
619
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
620
|
+
className: "neeto-themes-nano-alignment-button neeto-themes-nano-alignment-button__alignment-center",
|
|
621
|
+
"data-testid": "alignment-center",
|
|
622
|
+
size: "medium",
|
|
623
|
+
style: value === "center" ? "primary" : "text",
|
|
624
|
+
icon: function icon() {
|
|
625
|
+
return /*#__PURE__*/jsxRuntime.jsx(CenterAlign, {
|
|
626
|
+
size: 20,
|
|
627
|
+
className: classnames({
|
|
628
|
+
rounded: true,
|
|
629
|
+
"neeto-ui-text-primary-800": value === "center",
|
|
630
|
+
"neeto-ui-text-gray-600": value !== "center"
|
|
631
|
+
})
|
|
632
|
+
});
|
|
633
|
+
},
|
|
634
|
+
tooltipProps: {
|
|
635
|
+
content: "Center align",
|
|
636
|
+
position: "bottom"
|
|
637
|
+
},
|
|
638
|
+
onClick: function onClick() {
|
|
639
|
+
return setFieldValue(name, "center");
|
|
640
|
+
}
|
|
641
|
+
})]
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
})]
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
var ColorBlock = function ColorBlock(_ref) {
|
|
649
|
+
var label = _ref.label,
|
|
650
|
+
_ref$color = _ref.color,
|
|
651
|
+
color = _ref$color === void 0 ? "#FFFFFF" : _ref$color,
|
|
652
|
+
onChange = _ref.onChange,
|
|
653
|
+
showTransparencyControl = _ref.showTransparencyControl;
|
|
654
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
655
|
+
className: "flex items-center justify-between",
|
|
656
|
+
"data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
|
|
657
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
658
|
+
"data-testid": "style-fields-labels",
|
|
659
|
+
style: "body2",
|
|
660
|
+
children: label
|
|
661
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ColorPicker, {
|
|
662
|
+
color: color,
|
|
663
|
+
onChange: onChange,
|
|
664
|
+
showTransparencyControl: showTransparencyControl,
|
|
665
|
+
showEyeDropper: true,
|
|
666
|
+
size: "medium"
|
|
667
|
+
})]
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
672
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
673
|
+
var FontPickerBlock = function FontPickerBlock(_ref) {
|
|
674
|
+
var label = _ref.label,
|
|
675
|
+
_ref$placeholder = _ref.placeholder,
|
|
676
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
677
|
+
value = _ref.value,
|
|
678
|
+
options = _ref.options,
|
|
679
|
+
onChange = _ref.onChange;
|
|
680
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
681
|
+
className: "flex items-center justify-between",
|
|
682
|
+
"data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
|
|
683
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
684
|
+
"data-testid": "style-fields-labels",
|
|
685
|
+
style: "body2",
|
|
686
|
+
children: label
|
|
687
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
688
|
+
className: "w-40",
|
|
689
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
690
|
+
onChange: onChange,
|
|
691
|
+
options: options,
|
|
692
|
+
placeholder: placeholder,
|
|
693
|
+
value: value,
|
|
694
|
+
menuPosition: "fixed",
|
|
695
|
+
styles: {
|
|
696
|
+
option: function option(styles, _ref2) {
|
|
697
|
+
var data = _ref2.data;
|
|
698
|
+
return _objectSpread$2(_objectSpread$2({}, styles), {}, {
|
|
699
|
+
fontFamily: data.value
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
})
|
|
704
|
+
})]
|
|
705
|
+
});
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
var SelectBlock = function SelectBlock(_ref) {
|
|
709
|
+
var label = _ref.label,
|
|
710
|
+
_ref$placeholder = _ref.placeholder,
|
|
711
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
712
|
+
value = _ref.value,
|
|
713
|
+
options = _ref.options,
|
|
714
|
+
onChange = _ref.onChange;
|
|
715
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
716
|
+
className: "neeto-ui-border-gray-200 flex flex-col gap-2 border-t pt-3",
|
|
717
|
+
"data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
|
|
718
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
719
|
+
"data-testid": "logo-field-labels",
|
|
720
|
+
style: "body2",
|
|
721
|
+
children: label
|
|
722
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Select, {
|
|
723
|
+
onChange: onChange,
|
|
724
|
+
options: options,
|
|
725
|
+
placeholder: placeholder,
|
|
726
|
+
value: value
|
|
727
|
+
})]
|
|
728
|
+
});
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
var SliderBlock = function SliderBlock(_ref) {
|
|
732
|
+
var label = _ref.label,
|
|
733
|
+
onChange = _ref.onChange,
|
|
734
|
+
value = _ref.value,
|
|
735
|
+
min = _ref.min,
|
|
736
|
+
max = _ref.max,
|
|
737
|
+
marks = _ref.marks;
|
|
738
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
739
|
+
className: "flex items-center justify-between gap-3",
|
|
740
|
+
"data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
|
|
741
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
742
|
+
"data-testid": "style-fields-labels",
|
|
743
|
+
style: "body2",
|
|
744
|
+
children: label
|
|
745
|
+
}), /*#__PURE__*/jsxRuntime.jsx(antd.Slider, {
|
|
746
|
+
marks: marks,
|
|
747
|
+
max: max,
|
|
748
|
+
min: min,
|
|
749
|
+
onChange: onChange,
|
|
750
|
+
value: value,
|
|
751
|
+
className: "my-2 w-20",
|
|
752
|
+
tooltip: {
|
|
753
|
+
formatter: null
|
|
754
|
+
}
|
|
755
|
+
})]
|
|
756
|
+
});
|
|
757
|
+
};
|
|
758
|
+
|
|
759
|
+
var CONTENT_BACKGROUND_PROPERTY_NAME = "isContentBackgroundEnabled";
|
|
760
|
+
var CONTENT_BACKGROUND_HELP_TRANSLATION_BASE_KEY = "neetoThemes.properties.boolean.contentBackgroundHelp";
|
|
761
|
+
|
|
762
|
+
var ContentBackgroundHelpModal = function ContentBackgroundHelpModal(_ref) {
|
|
763
|
+
var isOpen = _ref.isOpen,
|
|
764
|
+
onClose = _ref.onClose,
|
|
765
|
+
t = _ref.t;
|
|
766
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Modal, {
|
|
767
|
+
isOpen: isOpen,
|
|
768
|
+
onClose: onClose,
|
|
769
|
+
size: "large",
|
|
770
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Modal.Header, {
|
|
771
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
772
|
+
style: "h2",
|
|
773
|
+
children: t("".concat(CONTENT_BACKGROUND_HELP_TRANSLATION_BASE_KEY, ".title"))
|
|
774
|
+
})
|
|
775
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Modal.Body, {
|
|
776
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
777
|
+
className: "neeto-themes-content-background-help-modal",
|
|
778
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
779
|
+
lineHeight: "normal",
|
|
780
|
+
style: "body2",
|
|
781
|
+
children: t("".concat(CONTENT_BACKGROUND_HELP_TRANSLATION_BASE_KEY, ".description"))
|
|
782
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("ol", {
|
|
783
|
+
className: "neeto-themes-content-background-help-modal__list",
|
|
784
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("li", {
|
|
785
|
+
className: "neeto-themes-content-background-help-modal__section",
|
|
786
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
787
|
+
style: "h4",
|
|
788
|
+
children: t("".concat(CONTENT_BACKGROUND_HELP_TRANSLATION_BASE_KEY, ".notEnabledTitle"))
|
|
789
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
790
|
+
className: "neeto-themes-content-background-help-modal__image neeto-themes-content-background-help-modal__image--disabled",
|
|
791
|
+
role: "img",
|
|
792
|
+
"aria-label": t("".concat(CONTENT_BACKGROUND_HELP_TRANSLATION_BASE_KEY, ".notEnabledImageAlt"))
|
|
793
|
+
})]
|
|
794
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("li", {
|
|
795
|
+
className: "neeto-themes-content-background-help-modal__section",
|
|
796
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
797
|
+
style: "h4",
|
|
798
|
+
children: t("".concat(CONTENT_BACKGROUND_HELP_TRANSLATION_BASE_KEY, ".enabledTitle"))
|
|
799
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
800
|
+
className: "neeto-themes-content-background-help-modal__image neeto-themes-content-background-help-modal__image--enabled",
|
|
801
|
+
role: "img",
|
|
802
|
+
"aria-label": t("".concat(CONTENT_BACKGROUND_HELP_TRANSLATION_BASE_KEY, ".enabledImageAlt"))
|
|
803
|
+
})]
|
|
804
|
+
})]
|
|
805
|
+
})]
|
|
806
|
+
})
|
|
807
|
+
})]
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
var ContentBackgroundHelpModal$1 = reactUtils.withT(ContentBackgroundHelpModal);
|
|
811
|
+
|
|
812
|
+
var _excluded = ["label", "name", "asCheckbox"];
|
|
813
|
+
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
814
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
815
|
+
var SwitchBlock = function SwitchBlock(_ref) {
|
|
816
|
+
var label = _ref.label,
|
|
817
|
+
name = _ref.name,
|
|
818
|
+
_ref$asCheckbox = _ref.asCheckbox,
|
|
819
|
+
asCheckbox = _ref$asCheckbox === void 0 ? false : _ref$asCheckbox,
|
|
820
|
+
inputProps = _objectWithoutProperties(_ref, _excluded);
|
|
821
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
822
|
+
t = _useTranslation.t,
|
|
823
|
+
i18n = _useTranslation.i18n;
|
|
824
|
+
var _useState = react.useState(false),
|
|
825
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
826
|
+
isContentBackgroundHelpOpen = _useState2[0],
|
|
827
|
+
setIsContentBackgroundHelpOpen = _useState2[1];
|
|
828
|
+
var translationKey = "neetoThemes.properties.boolean.".concat(name, "HelpText");
|
|
829
|
+
var doesHelpTextExist = i18n.exists(translationKey);
|
|
830
|
+
var shouldShowContentBackgroundHelp = name === CONTENT_BACKGROUND_PROPERTY_NAME;
|
|
831
|
+
var shouldShowHelpPopover = doesHelpTextExist && !shouldShowContentBackgroundHelp;
|
|
832
|
+
var shouldRenderAsCheckbox = asCheckbox || shouldShowContentBackgroundHelp;
|
|
833
|
+
var renderHelpIcon = function renderHelpIcon() {
|
|
834
|
+
if (shouldShowContentBackgroundHelp) {
|
|
835
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
836
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
837
|
+
className: "neeto-themes-content-background-help-modal__trigger shrink-0",
|
|
838
|
+
"data-testid": "content-background-help-button",
|
|
839
|
+
icon: Help,
|
|
840
|
+
size: "small",
|
|
841
|
+
style: "text",
|
|
842
|
+
"aria-label": t("neetoThemes.properties.boolean.contentBackgroundHelp.title"),
|
|
843
|
+
onClick: function onClick() {
|
|
844
|
+
return setIsContentBackgroundHelpOpen(true);
|
|
845
|
+
}
|
|
846
|
+
}), /*#__PURE__*/jsxRuntime.jsx(ContentBackgroundHelpModal$1, {
|
|
847
|
+
isOpen: isContentBackgroundHelpOpen,
|
|
848
|
+
onClose: function onClose() {
|
|
849
|
+
return setIsContentBackgroundHelpOpen(false);
|
|
850
|
+
}
|
|
851
|
+
})]
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
if (shouldShowHelpPopover) {
|
|
855
|
+
return /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
|
|
856
|
+
className: "shrink-0",
|
|
857
|
+
description: t(translationKey)
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
return null;
|
|
861
|
+
};
|
|
862
|
+
if (shouldRenderAsCheckbox) {
|
|
863
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
864
|
+
"data-testid": "theme-style-content-background",
|
|
865
|
+
className: classnames("flex items-center gap-2", {
|
|
866
|
+
"neeto-themes-content-background-checkbox-row": shouldShowContentBackgroundHelp
|
|
867
|
+
}),
|
|
868
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Checkbox, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
|
|
869
|
+
label: label,
|
|
870
|
+
name: name
|
|
871
|
+
}, inputProps)), {}, {
|
|
872
|
+
"data-testid": "enable-background-color-toggle"
|
|
873
|
+
})), renderHelpIcon()]
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
877
|
+
className: "flex items-center justify-between",
|
|
878
|
+
"data-testid": "theme-style-content-background",
|
|
879
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
880
|
+
className: "inline-flex items-center gap-4",
|
|
881
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
882
|
+
"data-testid": "style-fields-labels",
|
|
883
|
+
style: "body2",
|
|
884
|
+
className: classnames({
|
|
885
|
+
"w-32": doesHelpTextExist || shouldShowContentBackgroundHelp,
|
|
886
|
+
"w-auto": !doesHelpTextExist && !shouldShowContentBackgroundHelp
|
|
887
|
+
}),
|
|
888
|
+
children: label
|
|
889
|
+
}), renderHelpIcon()]
|
|
890
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Switch, _objectSpread$1(_objectSpread$1({}, _objectSpread$1({
|
|
891
|
+
name: name
|
|
892
|
+
}, inputProps)), {}, {
|
|
893
|
+
"data-testid": "enable-background-color-toggle"
|
|
894
|
+
}))]
|
|
895
|
+
});
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
var TextBlock = function TextBlock(_ref) {
|
|
899
|
+
var label = _ref.label,
|
|
900
|
+
name = _ref.name,
|
|
901
|
+
_ref$type = _ref.type,
|
|
902
|
+
type = _ref$type === void 0 ? "text" : _ref$type,
|
|
903
|
+
value = _ref.value,
|
|
904
|
+
onChange = _ref.onChange,
|
|
905
|
+
placeholder = _ref.placeholder,
|
|
906
|
+
error = _ref.error;
|
|
907
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
908
|
+
className: "flex items-center justify-between",
|
|
909
|
+
"data-testid": "theme-style-".concat(utils$1.joinHyphenCase(label)),
|
|
910
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
911
|
+
"data-testid": "style-fields-labels",
|
|
912
|
+
style: "body2",
|
|
913
|
+
children: label
|
|
914
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
915
|
+
className: "w-40",
|
|
916
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
917
|
+
error: error,
|
|
918
|
+
name: name,
|
|
919
|
+
onChange: onChange,
|
|
920
|
+
placeholder: placeholder,
|
|
921
|
+
type: type,
|
|
922
|
+
value: value
|
|
923
|
+
})
|
|
924
|
+
})]
|
|
925
|
+
});
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
var DependentPropertyConnector = function DependentPropertyConnector() {
|
|
929
|
+
return /*#__PURE__*/jsxRuntime.jsx("svg", {
|
|
930
|
+
className: "neeto-themes-dependent-property__connector",
|
|
931
|
+
fill: "none",
|
|
932
|
+
height: "32",
|
|
933
|
+
viewBox: "0 0 36 32",
|
|
934
|
+
width: "36",
|
|
935
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
936
|
+
children: /*#__PURE__*/jsxRuntime.jsx("path", {
|
|
937
|
+
d: "M4 1V22C4 25.5 7 28 13 28H34",
|
|
938
|
+
stroke: "rgb(var(--neeto-ui-gray-300))",
|
|
939
|
+
strokeLinecap: "round",
|
|
940
|
+
strokeWidth: "1.5"
|
|
941
|
+
})
|
|
942
|
+
});
|
|
943
|
+
};
|
|
944
|
+
var Properties = function Properties(_ref) {
|
|
945
|
+
var onPropertiesChange = _ref.onPropertiesChange,
|
|
946
|
+
condition = _ref.condition,
|
|
947
|
+
themeId = _ref.themeId;
|
|
948
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
949
|
+
return {
|
|
950
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
951
|
+
};
|
|
952
|
+
}, shallow.shallow),
|
|
953
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
954
|
+
var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
|
|
955
|
+
return {
|
|
956
|
+
setThemeState: store["setThemeState"]
|
|
957
|
+
};
|
|
958
|
+
}, shallow.shallow),
|
|
959
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
960
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
961
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
962
|
+
values = _useFormikContext.values,
|
|
963
|
+
errors = _useFormikContext.errors;
|
|
964
|
+
var _useThemeUtils = useExpandedSection.useThemeUtils(),
|
|
965
|
+
setVariable = _useThemeUtils.setVariable,
|
|
966
|
+
setTheme = _useThemeUtils.setTheme;
|
|
967
|
+
var handleColorChange = function handleColorChange(name) {
|
|
968
|
+
return function (_ref2) {
|
|
969
|
+
var hex = _ref2.hex,
|
|
970
|
+
rgb = _ref2.rgb;
|
|
971
|
+
if (name === "background_color") {
|
|
972
|
+
var _findBy, _values$backgroundIma;
|
|
973
|
+
var isDominantBackgroundColorEnabled = ((_findBy = neetoCist.findBy({
|
|
974
|
+
key: "is_dominant_background_color_enabled"
|
|
975
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) === "true";
|
|
976
|
+
var hasImageWithDominantColor = values === null || values === void 0 || (_values$backgroundIma = values.backgroundImage) === null || _values$backgroundIma === void 0 ? void 0 : _values$backgroundIma.dominantColor;
|
|
977
|
+
if (isDominantBackgroundColorEnabled && hasImageWithDominantColor) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
handleChange(name, hex, "".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a));
|
|
982
|
+
};
|
|
983
|
+
};
|
|
984
|
+
var handleChange = function handleChange(name, value, variableValue) {
|
|
985
|
+
var index = neetoCist.findIndexBy({
|
|
986
|
+
key: name
|
|
987
|
+
}, values.properties);
|
|
988
|
+
if (index !== -1 && values.properties[index].value !== value) {
|
|
989
|
+
setFieldValue("properties[".concat(index, "].value"), value);
|
|
990
|
+
}
|
|
991
|
+
setVariable(neetoCist.snakeToCamelCase(name), variableValue !== null && variableValue !== void 0 ? variableValue : value);
|
|
992
|
+
};
|
|
993
|
+
var handleOverlayChange = function handleOverlayChange(key, value) {
|
|
994
|
+
var index = neetoCist.findIndexBy({
|
|
995
|
+
key: key
|
|
996
|
+
}, values.properties);
|
|
997
|
+
var overlayColorVariable = "".concat(key, "_overlay_color");
|
|
998
|
+
setFieldValue("properties[".concat(index, "].value"), value);
|
|
999
|
+
setVariable("".concat(key, "_overlay_opacity"), Math.abs(value / 100));
|
|
1000
|
+
if (value < 0) {
|
|
1001
|
+
handleChange(overlayColorVariable, "#000000", "0, 0, 0");
|
|
1002
|
+
} else {
|
|
1003
|
+
handleChange(overlayColorVariable, "#ffffff", "255, 255, 255");
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
react.useEffect(function () {
|
|
1007
|
+
if (!((values === null || values === void 0 ? void 0 : values.id) === themeId)) return;
|
|
1008
|
+
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values, handleChange, handleColorChange);
|
|
1009
|
+
setTheme(values);
|
|
1010
|
+
setThemeState({
|
|
1011
|
+
previewingTheme: values
|
|
1012
|
+
});
|
|
1013
|
+
}, [values]);
|
|
1014
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
1015
|
+
children: buildProperties(values === null || values === void 0 ? void 0 : values.properties, condition, themePropertiesSchema).sort(function (a, b) {
|
|
1016
|
+
var order = function order(key) {
|
|
1017
|
+
var _findBy2;
|
|
1018
|
+
return ((_findBy2 = neetoCist.findBy({
|
|
1019
|
+
key: key
|
|
1020
|
+
}, themePropertiesSchema)) === null || _findBy2 === void 0 ? void 0 : _findBy2.order) || Infinity;
|
|
1021
|
+
};
|
|
1022
|
+
return order(a.key) - order(b.key);
|
|
1023
|
+
}).map(function (_ref3) {
|
|
1024
|
+
var key = _ref3.key,
|
|
1025
|
+
value = _ref3.value,
|
|
1026
|
+
kind = _ref3.kind;
|
|
1027
|
+
var propertySchema = neetoCist.findBy({
|
|
1028
|
+
key: key
|
|
1029
|
+
}, themePropertiesSchema);
|
|
1030
|
+
var isDependentProperty = Boolean(propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.dependsOn);
|
|
1031
|
+
var wrapProperty = function wrapProperty(property) {
|
|
1032
|
+
if (!isDependentProperty) return property;
|
|
1033
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1034
|
+
className: "neeto-themes-dependent-property",
|
|
1035
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(DependentPropertyConnector, {}), property]
|
|
1036
|
+
}, key);
|
|
1037
|
+
};
|
|
1038
|
+
var isCurrentPropertyVisible = isPropertyVisible(key, values, themePropertiesSchema);
|
|
1039
|
+
if (!isCurrentPropertyVisible) return null;
|
|
1040
|
+
switch (kind) {
|
|
1041
|
+
case "text_input":
|
|
1042
|
+
{
|
|
1043
|
+
var _errors$properties;
|
|
1044
|
+
var index = neetoCist.findIndexBy({
|
|
1045
|
+
key: key
|
|
1046
|
+
}, values.properties);
|
|
1047
|
+
var error = errors === null || errors === void 0 || (_errors$properties = errors.properties) === null || _errors$properties === void 0 || (_errors$properties = _errors$properties[index]) === null || _errors$properties === void 0 ? void 0 : _errors$properties.value;
|
|
1048
|
+
return wrapProperty(/*#__PURE__*/react.createElement(TextBlock, {
|
|
1049
|
+
error: error,
|
|
1050
|
+
key: key,
|
|
1051
|
+
label: buildLabel(key, kind),
|
|
1052
|
+
name: "properties[".concat(index, "].value"),
|
|
1053
|
+
value: value || "",
|
|
1054
|
+
onChange: function onChange(e) {
|
|
1055
|
+
return setFieldValue("properties[".concat(index, "].value"), e.target.value);
|
|
1056
|
+
}
|
|
1057
|
+
}));
|
|
1058
|
+
}
|
|
1059
|
+
case "font_family":
|
|
1060
|
+
return wrapProperty(/*#__PURE__*/jsxRuntime.jsx(FontPickerBlock, {
|
|
1061
|
+
label: buildLabel(key, kind),
|
|
1062
|
+
options: useExpandedSection.FONT_OPTIONS,
|
|
1063
|
+
value: neetoCist.findBy({
|
|
1064
|
+
value: value || null
|
|
1065
|
+
}, useExpandedSection.FONT_OPTIONS),
|
|
1066
|
+
onChange: function onChange(_ref4) {
|
|
1067
|
+
var value = _ref4.value;
|
|
1068
|
+
return handleChange(key, value);
|
|
1069
|
+
}
|
|
1070
|
+
}, key));
|
|
1071
|
+
case "color":
|
|
1072
|
+
return wrapProperty(/*#__PURE__*/jsxRuntime.jsx(ColorBlock, {
|
|
1073
|
+
color: value,
|
|
1074
|
+
label: buildLabel(key, kind),
|
|
1075
|
+
showTransparencyControl: (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.showTransparencyControl) || false,
|
|
1076
|
+
onChange: handleColorChange(key)
|
|
1077
|
+
}, key));
|
|
1078
|
+
case "radius":
|
|
1079
|
+
return wrapProperty(/*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
|
|
1080
|
+
label: buildLabel(key, kind),
|
|
1081
|
+
max: 50,
|
|
1082
|
+
min: 0,
|
|
1083
|
+
value: Number(value) || 0,
|
|
1084
|
+
onChange: function onChange(radius) {
|
|
1085
|
+
return handleChange(key, radius, "".concat(radius, "px"));
|
|
1086
|
+
}
|
|
1087
|
+
}, key));
|
|
1088
|
+
case "overlay_opacity":
|
|
1089
|
+
return wrapProperty(/*#__PURE__*/jsxRuntime.jsx(SliderBlock, {
|
|
1090
|
+
label: buildLabel(key, kind),
|
|
1091
|
+
marks: useExpandedSection.OVERLAY_OPACITY_SLIDER_MARKS,
|
|
1092
|
+
max: useExpandedSection.HUNDRED,
|
|
1093
|
+
min: ramda.negate(useExpandedSection.HUNDRED),
|
|
1094
|
+
value: Number(value) || 0,
|
|
1095
|
+
onChange: function onChange(opacity) {
|
|
1096
|
+
return handleOverlayChange(key, opacity);
|
|
1097
|
+
}
|
|
1098
|
+
}, key));
|
|
1099
|
+
case "position_selector":
|
|
1100
|
+
{
|
|
1101
|
+
var _findBy3;
|
|
1102
|
+
var _index = neetoCist.findIndexBy({
|
|
1103
|
+
key: key
|
|
1104
|
+
}, values.properties);
|
|
1105
|
+
var options = (_findBy3 = neetoCist.findBy({
|
|
1106
|
+
key: key
|
|
1107
|
+
}, themePropertiesSchema)) === null || _findBy3 === void 0 || (_findBy3 = _findBy3.options) === null || _findBy3 === void 0 ? void 0 : _findBy3.map(toCapitalizedOption);
|
|
1108
|
+
return wrapProperty(/*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
|
|
1109
|
+
label: buildLabel(key, kind),
|
|
1110
|
+
options: options || useExpandedSection.POSITION_OPTIONS,
|
|
1111
|
+
placeholder: "left",
|
|
1112
|
+
value: toCapitalizedOption(value),
|
|
1113
|
+
onChange: function onChange(option) {
|
|
1114
|
+
return setFieldValue("properties[".concat(_index, "].value"), option.value);
|
|
1115
|
+
}
|
|
1116
|
+
}, key));
|
|
1117
|
+
}
|
|
1118
|
+
case "boolean":
|
|
1119
|
+
{
|
|
1120
|
+
var _index2 = neetoCist.findIndexBy({
|
|
1121
|
+
key: key
|
|
1122
|
+
}, values.properties);
|
|
1123
|
+
var renderAsCheckbox = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.renderAsCheckbox) || false;
|
|
1124
|
+
return wrapProperty(/*#__PURE__*/jsxRuntime.jsx(SwitchBlock, {
|
|
1125
|
+
asCheckbox: renderAsCheckbox,
|
|
1126
|
+
checked: value !== "false",
|
|
1127
|
+
label: buildLabel(key, kind),
|
|
1128
|
+
name: neetoCist.snakeToCamelCase(key),
|
|
1129
|
+
onChange: function onChange(e) {
|
|
1130
|
+
return setFieldValue("properties[".concat(_index2, "].value"), String(e.target.checked));
|
|
1131
|
+
}
|
|
1132
|
+
}, key));
|
|
1133
|
+
}
|
|
1134
|
+
case "alignment_block":
|
|
1135
|
+
{
|
|
1136
|
+
var _index3 = neetoCist.findIndexBy({
|
|
1137
|
+
key: key
|
|
1138
|
+
}, values.properties);
|
|
1139
|
+
return wrapProperty(/*#__PURE__*/jsxRuntime.jsx(AlignmentBlock, {
|
|
1140
|
+
label: buildLabel(key, kind),
|
|
1141
|
+
name: "properties[".concat(_index3, "].value")
|
|
1142
|
+
}, key));
|
|
1143
|
+
}
|
|
1144
|
+
default:
|
|
1145
|
+
return null;
|
|
1146
|
+
}
|
|
1147
|
+
})
|
|
1148
|
+
});
|
|
1149
|
+
};
|
|
1150
|
+
|
|
1151
|
+
var ImageBlock = function ImageBlock(_ref) {
|
|
1152
|
+
var _findBy;
|
|
1153
|
+
var label = _ref.label,
|
|
1154
|
+
name = _ref.name,
|
|
1155
|
+
_ref$imageData = _ref.imageData,
|
|
1156
|
+
imageData = _ref$imageData === void 0 ? {} : _ref$imageData,
|
|
1157
|
+
_ref$uploadConfig = _ref.uploadConfig,
|
|
1158
|
+
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
1159
|
+
maxImageSize: ONE_MEGABYTE
|
|
1160
|
+
} : _ref$uploadConfig,
|
|
1161
|
+
attribute = _ref.attribute,
|
|
1162
|
+
defaultImageSize = _ref.defaultImageSize,
|
|
1163
|
+
useDefaultImageSize = _ref.useDefaultImageSize,
|
|
1164
|
+
fixedAspectRatio = _ref.fixedAspectRatio;
|
|
1165
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1166
|
+
t = _useTranslation.t;
|
|
1167
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
1168
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
1169
|
+
values = _useFormikContext.values;
|
|
1170
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
1171
|
+
return {
|
|
1172
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
1173
|
+
};
|
|
1174
|
+
}, shallow.shallow),
|
|
1175
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
1176
|
+
var propertySchema = neetoCist.findBy({
|
|
1177
|
+
key: attribute
|
|
1178
|
+
}, themePropertiesSchema);
|
|
1179
|
+
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
1180
|
+
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
1181
|
+
var positionKeyInSchema = neetoCist.findBy({
|
|
1182
|
+
key: "".concat(name, "_position")
|
|
1183
|
+
}, themePropertiesSchema);
|
|
1184
|
+
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && neetoCist.isPresent(positionKeyInSchema);
|
|
1185
|
+
var positionKeyIndex = neetoCist.findIndexBy({
|
|
1186
|
+
key: "".concat(name, "_position")
|
|
1187
|
+
}, values.properties);
|
|
1188
|
+
var handleImageChange = /*#__PURE__*/function () {
|
|
1189
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
1190
|
+
var dominantColor;
|
|
1191
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
1192
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1193
|
+
case 0:
|
|
1194
|
+
_context.prev = 0;
|
|
1195
|
+
if (!(ramda.isEmpty(image.signedId) || ramda.isEmpty(image.url))) {
|
|
1196
|
+
_context.next = 4;
|
|
1197
|
+
break;
|
|
1198
|
+
}
|
|
1199
|
+
setFieldValue(name, {
|
|
1200
|
+
signedId: null,
|
|
1201
|
+
url: image.url
|
|
1202
|
+
});
|
|
1203
|
+
return _context.abrupt("return");
|
|
1204
|
+
case 4:
|
|
1205
|
+
_context.next = 6;
|
|
1206
|
+
return utils.getDominantColorFromUrl(image.url);
|
|
1207
|
+
case 6:
|
|
1208
|
+
dominantColor = _context.sent;
|
|
1209
|
+
setFieldValue(name, {
|
|
1210
|
+
signedId: image.signedId,
|
|
1211
|
+
url: image.url,
|
|
1212
|
+
dominantColor: dominantColor
|
|
1213
|
+
});
|
|
1214
|
+
_context.next = 13;
|
|
1215
|
+
break;
|
|
1216
|
+
case 10:
|
|
1217
|
+
_context.prev = 10;
|
|
1218
|
+
_context.t0 = _context["catch"](0);
|
|
1219
|
+
Toastr.error(_context.t0);
|
|
1220
|
+
case 13:
|
|
1221
|
+
case "end":
|
|
1222
|
+
return _context.stop();
|
|
1223
|
+
}
|
|
1224
|
+
}, _callee, null, [[0, 10]]);
|
|
1225
|
+
}));
|
|
1226
|
+
return function handleImageChange(_x) {
|
|
1227
|
+
return _ref2.apply(this, arguments);
|
|
1228
|
+
};
|
|
1229
|
+
}();
|
|
1230
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1231
|
+
className: "space-y-3",
|
|
1232
|
+
"data-testid": "theme-style-".concat(label ? utils$1.joinHyphenCase(label) : "image-block"),
|
|
1233
|
+
children: [label && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1234
|
+
className: "flex items-center justify-between",
|
|
1235
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1236
|
+
"data-testid": "style-fields-labels",
|
|
1237
|
+
style: "body2",
|
|
1238
|
+
children: label
|
|
1239
|
+
})
|
|
1240
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1241
|
+
className: "space-y-3",
|
|
1242
|
+
children: [/*#__PURE__*/react.createElement(ImageUploader, {
|
|
1243
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
1244
|
+
uploadConfig: uploadConfig,
|
|
1245
|
+
className: "h-40 w-full",
|
|
1246
|
+
defaultImageSize: useDefaultImageSize ? defaultImageSize : {},
|
|
1247
|
+
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
1248
|
+
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
1249
|
+
onUploadComplete: handleImageChange
|
|
1250
|
+
}), isPositionChangerVisible && /*#__PURE__*/jsxRuntime.jsx(SelectBlock, {
|
|
1251
|
+
label: buildLabel("".concat(name, "Position"), "image"),
|
|
1252
|
+
options: (options === null || options === void 0 ? void 0 : options.map(toCapitalizedOption)) || useExpandedSection.POSITION_OPTIONS,
|
|
1253
|
+
placeholder: t("neetoThemes.common.left"),
|
|
1254
|
+
value: toCapitalizedOption(((_findBy = neetoCist.findBy({
|
|
1255
|
+
key: "".concat(name, "_position")
|
|
1256
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
|
|
1257
|
+
onChange: function onChange(option) {
|
|
1258
|
+
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
1259
|
+
}
|
|
1260
|
+
})]
|
|
1261
|
+
})]
|
|
1262
|
+
});
|
|
1263
|
+
};
|
|
1264
|
+
|
|
1265
|
+
var Images = function Images(_ref) {
|
|
1266
|
+
var _values$coverImage;
|
|
1267
|
+
var attribute = _ref.attribute,
|
|
1268
|
+
className = _ref.className,
|
|
1269
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
1270
|
+
defaultImageSize = _ref.defaultImageSize,
|
|
1271
|
+
useDefaultImageSize = _ref.useDefaultImageSize,
|
|
1272
|
+
fixedAspectRatio = _ref.fixedAspectRatio;
|
|
1273
|
+
var _useFormikContext = formik.useFormikContext(),
|
|
1274
|
+
values = _useFormikContext.values;
|
|
1275
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
1276
|
+
return {
|
|
1277
|
+
helpPopoverProps: store["helpPopoverProps"]
|
|
1278
|
+
};
|
|
1279
|
+
}, shallow.shallow),
|
|
1280
|
+
helpPopoverProps = _useConfigStore.helpPopoverProps;
|
|
1281
|
+
var key = neetoCist.snakeToCamelCase(attribute);
|
|
1282
|
+
var title = buildLabel(key, "image");
|
|
1283
|
+
var imageData = values[key];
|
|
1284
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Card$2, {
|
|
1285
|
+
className: className,
|
|
1286
|
+
title: title,
|
|
1287
|
+
helpPopoverProps: helpPopoverProps[key],
|
|
1288
|
+
name: key,
|
|
1289
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(ImageBlock, {
|
|
1290
|
+
attribute: attribute,
|
|
1291
|
+
defaultImageSize: defaultImageSize,
|
|
1292
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
1293
|
+
imageData: imageData,
|
|
1294
|
+
useDefaultImageSize: useDefaultImageSize,
|
|
1295
|
+
name: key
|
|
1296
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Properties, {
|
|
1297
|
+
onPropertiesChange: onPropertiesChange,
|
|
1298
|
+
condition: attribute
|
|
1299
|
+
}), key === "logo" && ((_values$coverImage = values.coverImage) === null || _values$coverImage === void 0 ? void 0 : _values$coverImage.url) && /*#__PURE__*/jsxRuntime.jsx(LogoPosition, {})]
|
|
1300
|
+
});
|
|
1301
|
+
};
|
|
1302
|
+
|
|
1303
|
+
var ThemeMeta = function ThemeMeta(_ref) {
|
|
1304
|
+
var className = _ref.className;
|
|
1305
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1306
|
+
t = _useTranslation.t;
|
|
1307
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
1308
|
+
return {
|
|
1309
|
+
helpPopoverProps: store["helpPopoverProps"]
|
|
1310
|
+
};
|
|
1311
|
+
}, shallow.shallow),
|
|
1312
|
+
helpPopoverProps = _useConfigStore.helpPopoverProps;
|
|
1313
|
+
var _helpPopoverProps$nam = helpPopoverProps.name,
|
|
1314
|
+
nameHelpPopoverProps = _helpPopoverProps$nam === void 0 ? {} : _helpPopoverProps$nam;
|
|
1315
|
+
return /*#__PURE__*/jsxRuntime.jsx(Card$2, {
|
|
1316
|
+
className: className,
|
|
1317
|
+
required: true,
|
|
1318
|
+
helpPopoverProps: nameHelpPopoverProps,
|
|
1319
|
+
name: "name",
|
|
1320
|
+
title: t("neetoThemes.common.name"),
|
|
1321
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Input$1, {
|
|
1322
|
+
autoFocus: true,
|
|
1323
|
+
"data-testid": "theme-name-property",
|
|
1324
|
+
name: "name"
|
|
1325
|
+
})
|
|
1326
|
+
});
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
1330
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1331
|
+
var Customize = function Customize(_ref) {
|
|
1332
|
+
var theme = _ref.theme,
|
|
1333
|
+
onCreateTheme = _ref.onCreateTheme,
|
|
1334
|
+
onApplyTheme = _ref.onApplyTheme,
|
|
1335
|
+
onUpdateTheme = _ref.onUpdateTheme,
|
|
1336
|
+
isApplyingTheme = _ref.isApplyingTheme,
|
|
1337
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
1338
|
+
defaultImageSize = _ref.defaultImageSize,
|
|
1339
|
+
fixedAspectRatio = _ref.fixedAspectRatio,
|
|
1340
|
+
onEditCSSClick = _ref.onEditCSSClick,
|
|
1341
|
+
currentScreen = _ref.currentScreen;
|
|
1342
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1343
|
+
t = _useTranslation.t;
|
|
1344
|
+
useExpandedSection.useSyncExpandedSectionFromUrl();
|
|
1345
|
+
var history = reactRouterDom.useHistory();
|
|
1346
|
+
var _useState = react.useState({}),
|
|
1347
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1348
|
+
popoverInstance = _useState2[0],
|
|
1349
|
+
setPopoverInstance = _useState2[1];
|
|
1350
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
1351
|
+
return {
|
|
1352
|
+
themePropertiesSchema: store["themePropertiesSchema"],
|
|
1353
|
+
entityType: store["entityType"],
|
|
1354
|
+
isFetchingSchema: store["isFetchingSchema"],
|
|
1355
|
+
helpPopoverProps: store["helpPopoverProps"],
|
|
1356
|
+
enabledFeatures: store["enabledFeatures"],
|
|
1357
|
+
proFeatures: store["proFeatures"]
|
|
1358
|
+
};
|
|
1359
|
+
}, shallow.shallow),
|
|
1360
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema,
|
|
1361
|
+
entityType = _useConfigStore.entityType,
|
|
1362
|
+
isFetchingSchema = _useConfigStore.isFetchingSchema,
|
|
1363
|
+
helpPopoverProps = _useConfigStore.helpPopoverProps,
|
|
1364
|
+
enabledFeatures = _useConfigStore.enabledFeatures,
|
|
1365
|
+
proFeatures = _useConfigStore.proFeatures;
|
|
1366
|
+
var _useParams = reactRouterDom.useParams(),
|
|
1367
|
+
themeId = _useParams.themeId;
|
|
1368
|
+
var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
|
|
1369
|
+
return {
|
|
1370
|
+
currentTheme: store["currentTheme"],
|
|
1371
|
+
setThemeState: store["setThemeState"]
|
|
1372
|
+
};
|
|
1373
|
+
}, shallow.shallow),
|
|
1374
|
+
currentTheme = _useThemeStore.currentTheme,
|
|
1375
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
1376
|
+
var _useShowGlobalTheme = useGlobalThemesApi.useShowGlobalTheme(entityType),
|
|
1377
|
+
_useShowGlobalTheme$d = _useShowGlobalTheme.data,
|
|
1378
|
+
_useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
|
|
1379
|
+
_useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
|
|
1380
|
+
globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
|
|
1381
|
+
var _useFetchTheme = useGlobalThemesApi.useFetchTheme(themeId, {
|
|
1382
|
+
enabled: utils.isEditThemeRoute() && ramda.isNotNil(themeId),
|
|
1383
|
+
initialData: theme !== null && theme !== void 0 ? theme : undefined
|
|
1384
|
+
}),
|
|
1385
|
+
_useFetchTheme$data = _useFetchTheme.data,
|
|
1386
|
+
themeData = _useFetchTheme$data === void 0 ? {} : _useFetchTheme$data,
|
|
1387
|
+
isLoadingTheme = _useFetchTheme.isLoadingTheme;
|
|
1388
|
+
var isLoading = isFetchingSchema || isLoadingTheme;
|
|
1389
|
+
var isThemeGlobalTheme = themeId && (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
|
|
1390
|
+
var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
|
|
1391
|
+
var _helpPopoverProps$sty = helpPopoverProps.style,
|
|
1392
|
+
styleHelpPopoverProps = _helpPopoverProps$sty === void 0 ? {} : _helpPopoverProps$sty;
|
|
1393
|
+
var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
|
|
1394
|
+
var submitBtnRef = react.useRef(null);
|
|
1395
|
+
var _useCreateTheme = useGlobalThemesApi.useCreateTheme(),
|
|
1396
|
+
createTheme = _useCreateTheme.mutate,
|
|
1397
|
+
isCreating = _useCreateTheme.isPending;
|
|
1398
|
+
var _useUpdateTheme = useGlobalThemesApi.useUpdateTheme(themeId),
|
|
1399
|
+
updateTheme = _useUpdateTheme.mutate,
|
|
1400
|
+
isUpdating = _useUpdateTheme.isPending;
|
|
1401
|
+
var isSubmitting = isCreating || isUpdating;
|
|
1402
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
1403
|
+
var handleGlobalThemeSwitchChange = function handleGlobalThemeSwitchChange(e, setFieldValue) {
|
|
1404
|
+
setFieldValue("shouldSetAsGlobalTheme", e.target.checked);
|
|
1405
|
+
};
|
|
1406
|
+
var onSubmit = function onSubmit(values, _ref2) {
|
|
1407
|
+
var resetForm = _ref2.resetForm;
|
|
1408
|
+
var imageData = buildImageData(values, themePropertiesSchema);
|
|
1409
|
+
var themeToSave = _objectSpread({
|
|
1410
|
+
propertiesAttributes: values.properties,
|
|
1411
|
+
name: values.name,
|
|
1412
|
+
shouldSetAsGlobalTheme: values.shouldSetAsGlobalTheme,
|
|
1413
|
+
entityType: values.entityType
|
|
1414
|
+
}, imageData);
|
|
1415
|
+
if (!themeId) {
|
|
1416
|
+
return createTheme(themeToSave, {
|
|
1417
|
+
onSuccess: function onSuccess(_ref3) {
|
|
1418
|
+
var theme = _ref3.theme;
|
|
1419
|
+
resetForm({
|
|
1420
|
+
values: theme
|
|
1421
|
+
});
|
|
1422
|
+
onCreateTheme(theme);
|
|
1423
|
+
history.replace(utils$1.buildUrl(buildPathname(useGlobalThemesApi.routes.themes.edit), {
|
|
1424
|
+
themeId: theme.id
|
|
1425
|
+
}));
|
|
1426
|
+
}
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
return updateTheme(themeToSave, {
|
|
1430
|
+
onSuccess: function onSuccess(_ref4) {
|
|
1431
|
+
var theme = _ref4.theme;
|
|
1432
|
+
onUpdateTheme(theme);
|
|
1433
|
+
resetForm({
|
|
1434
|
+
values: theme
|
|
1435
|
+
});
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
};
|
|
1439
|
+
react.useEffect(function () {
|
|
1440
|
+
if (ramda.isNotNil(themeId) && !isLoadingTheme) {
|
|
1441
|
+
setThemeState({
|
|
1442
|
+
previewingTheme: themeData
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
}, [isLoadingTheme]);
|
|
1446
|
+
if (isLoading) {
|
|
1447
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1448
|
+
className: "flex h-full w-full items-center justify-center",
|
|
1449
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
return /*#__PURE__*/jsxRuntime.jsx(Form, {
|
|
1453
|
+
formikProps: {
|
|
1454
|
+
initialValues: _objectSpread(_objectSpread({}, buildInitialValues(themeData, themePropertiesSchema)), {}, {
|
|
1455
|
+
shouldSetAsGlobalTheme: isThemeGlobalTheme,
|
|
1456
|
+
entityType: entityType
|
|
1457
|
+
}),
|
|
1458
|
+
validationSchema: useExpandedSection.THEME_VALIDATION_SCHEMA,
|
|
1459
|
+
enableReinitialize: true,
|
|
1460
|
+
onSubmit: onSubmit
|
|
1461
|
+
},
|
|
1462
|
+
children: function children(_ref5) {
|
|
1463
|
+
var dirty = _ref5.dirty,
|
|
1464
|
+
isValid = _ref5.isValid,
|
|
1465
|
+
values = _ref5.values,
|
|
1466
|
+
setFieldValue = _ref5.setFieldValue;
|
|
1467
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1468
|
+
className: "neeto-themes-sidebar__scroll",
|
|
1469
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1470
|
+
className: "neeto-themes-sidebar__scroll-content flex grow flex-col px-4 pb-4 lg:px-5",
|
|
1471
|
+
children: [!isSubmitting && /*#__PURE__*/jsxRuntime.jsx(BlockNavigation, {}), /*#__PURE__*/jsxRuntime.jsx(ThemeMeta, {
|
|
1472
|
+
className: classnames({
|
|
1473
|
+
hidden: isCustomCssScreen
|
|
1474
|
+
})
|
|
1475
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Card$2, {
|
|
1476
|
+
className: classnames({
|
|
1477
|
+
hidden: isCustomCssScreen
|
|
1478
|
+
}),
|
|
1479
|
+
helpPopoverProps: styleHelpPopoverProps,
|
|
1480
|
+
name: "style",
|
|
1481
|
+
title: t("neetoThemes.common.style"),
|
|
1482
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Properties, {
|
|
1483
|
+
onPropertiesChange: onPropertiesChange,
|
|
1484
|
+
themeId: themeId
|
|
1485
|
+
})
|
|
1486
|
+
}), neetoCist.filterBy({
|
|
1487
|
+
kind: "image"
|
|
1488
|
+
}, themePropertiesSchema).map(function (_ref6) {
|
|
1489
|
+
var key = _ref6.key,
|
|
1490
|
+
useDefaultImageSize = _ref6.useDefaultImageSize,
|
|
1491
|
+
propertyDefaultSize = _ref6.defaultImageSize,
|
|
1492
|
+
propertyFixedAspectRatio = _ref6.fixedAspectRatio;
|
|
1493
|
+
return /*#__PURE__*/react.createElement(Images, _defineProperty({
|
|
1494
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
1495
|
+
onPropertiesChange: onPropertiesChange,
|
|
1496
|
+
useDefaultImageSize: useDefaultImageSize,
|
|
1497
|
+
attribute: key,
|
|
1498
|
+
className: classnames({
|
|
1499
|
+
hidden: isCustomCssScreen
|
|
1500
|
+
}),
|
|
1501
|
+
defaultImageSize: propertyDefaultSize || defaultImageSize,
|
|
1502
|
+
key: key
|
|
1503
|
+
}, "fixedAspectRatio", propertyFixedAspectRatio || fixedAspectRatio));
|
|
1504
|
+
}), /*#__PURE__*/jsxRuntime.jsx(CustomCSS, {
|
|
1505
|
+
currentScreen: currentScreen,
|
|
1506
|
+
onEditCSSClick: onEditCSSClick,
|
|
1507
|
+
isEnabled: enabledFeatures.customCSS,
|
|
1508
|
+
isProFeature: proFeatures.customCSS
|
|
1509
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1510
|
+
className: "neeto-ui-bg-gray-50 neeto-ui-border-gray-200 mt-2 flex flex-col space-y-2 border p-2",
|
|
1511
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Tooltip, {
|
|
1512
|
+
disabled: !isThemeGlobalTheme,
|
|
1513
|
+
content: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.tooltipContent"),
|
|
1514
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Switch, {
|
|
1515
|
+
checked: values.shouldSetAsGlobalTheme,
|
|
1516
|
+
disabled: isThemeGlobalTheme,
|
|
1517
|
+
name: "shouldSetAsGlobalTheme",
|
|
1518
|
+
label: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.label"),
|
|
1519
|
+
onChange: function onChange(e) {
|
|
1520
|
+
return handleGlobalThemeSwitchChange(e, setFieldValue);
|
|
1521
|
+
}
|
|
1522
|
+
})
|
|
1523
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1524
|
+
className: "text-sm",
|
|
1525
|
+
style: "body2",
|
|
1526
|
+
children: t("neetoThemes.build.leftSideBar.themes.themeOptions.setAsGlobalTheme.helpText", {
|
|
1527
|
+
entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()), {
|
|
1528
|
+
count: 2
|
|
1529
|
+
})
|
|
1530
|
+
})
|
|
1531
|
+
})]
|
|
1532
|
+
})]
|
|
1533
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1534
|
+
className: "neeto-ui-bg-white neeto-ui-shadow-s sticky bottom-0 start-0 end-0 flex justify-end gap-x-2 px-4 py-6 lg:px-5 xl:px-6",
|
|
1535
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1536
|
+
"data-testid": "reset-button",
|
|
1537
|
+
disabled: !dirty || isSubmitting,
|
|
1538
|
+
label: t("neetoThemes.buttons.reset"),
|
|
1539
|
+
style: "text",
|
|
1540
|
+
type: "reset"
|
|
1541
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1542
|
+
"data-testid": "save-changes-button",
|
|
1543
|
+
disabled: !dirty && (themeData === null || themeData === void 0 ? void 0 : themeData.id) || isSubmitting || !isValid,
|
|
1544
|
+
label: t("neetoThemes.buttons.save"),
|
|
1545
|
+
loading: isSubmitting,
|
|
1546
|
+
ref: submitBtnRef,
|
|
1547
|
+
type: "submit"
|
|
1548
|
+
})]
|
|
1549
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Popover, {
|
|
1550
|
+
appendTo: function appendTo() {
|
|
1551
|
+
return document.body;
|
|
1552
|
+
},
|
|
1553
|
+
position: "top",
|
|
1554
|
+
reference: submitBtnRef,
|
|
1555
|
+
trigger: "click",
|
|
1556
|
+
content: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1557
|
+
className: "flex flex-col items-start gap-2",
|
|
1558
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1559
|
+
className: "absolute end-1 top-1 z-0",
|
|
1560
|
+
icon: Close,
|
|
1561
|
+
size: "small",
|
|
1562
|
+
style: "text",
|
|
1563
|
+
onClick: function onClick() {
|
|
1564
|
+
var _popoverInstance$hide;
|
|
1565
|
+
return popoverInstance === null || popoverInstance === void 0 || (_popoverInstance$hide = popoverInstance.hide) === null || _popoverInstance$hide === void 0 ? void 0 : _popoverInstance$hide.call(popoverInstance);
|
|
1566
|
+
}
|
|
1567
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1568
|
+
className: "w-72 pe-5",
|
|
1569
|
+
style: "body2",
|
|
1570
|
+
weight: "normal",
|
|
1571
|
+
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
1572
|
+
components: {
|
|
1573
|
+
bold: /*#__PURE__*/jsxRuntime.jsx("strong", {})
|
|
1574
|
+
},
|
|
1575
|
+
i18nKey: "neetoThemes.build.leftSideBar.themes.notAppliedYet",
|
|
1576
|
+
values: {
|
|
1577
|
+
entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
|
|
1578
|
+
}
|
|
1579
|
+
})
|
|
1580
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1581
|
+
disabled: isApplyingTheme,
|
|
1582
|
+
label: t("neetoThemes.buttons.applyThisTheme"),
|
|
1583
|
+
loading: isApplyingTheme,
|
|
1584
|
+
onClick: function onClick() {
|
|
1585
|
+
return onApplyTheme(themeData);
|
|
1586
|
+
}
|
|
1587
|
+
})]
|
|
1588
|
+
}),
|
|
1589
|
+
disabled: isEditingCurrentlyAppliedTheme || isCurrentThemeAndGlobalThemeSame && values.shouldSetAsGlobalTheme,
|
|
1590
|
+
onMount: setPopoverInstance
|
|
1591
|
+
})]
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1597
|
+
var QuickActionRow = function QuickActionRow(_ref) {
|
|
1598
|
+
var Icon = _ref.icon,
|
|
1599
|
+
label = _ref.label,
|
|
1600
|
+
onClick = _ref.onClick,
|
|
1601
|
+
testId = _ref.testId;
|
|
1602
|
+
return /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
1603
|
+
onClick: onClick,
|
|
1604
|
+
className: "neeto-ui-border-gray-100 hover:neeto-ui-bg-gray-100 flex w-full cursor-pointer items-center gap-3 border-t px-3 py-2 text-start transition-colors",
|
|
1605
|
+
"data-testid": testId,
|
|
1606
|
+
type: "button",
|
|
1607
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
1608
|
+
size: 16
|
|
1609
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1610
|
+
lineHeight: "normal",
|
|
1611
|
+
style: "body2",
|
|
1612
|
+
children: label
|
|
1613
|
+
})]
|
|
1614
|
+
});
|
|
1615
|
+
};
|
|
1616
|
+
|
|
1617
|
+
var Thumbnail = function Thumbnail(_ref) {
|
|
1618
|
+
var _theme$snakeToCamelCa, _findBy, _findBy2;
|
|
1619
|
+
var active = _ref.active,
|
|
1620
|
+
isPreviewing = _ref.isPreviewing,
|
|
1621
|
+
isHighLightedTheme = _ref.isHighLightedTheme,
|
|
1622
|
+
theme = _ref.theme;
|
|
1623
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
1624
|
+
return {
|
|
1625
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
1626
|
+
};
|
|
1627
|
+
}, shallow.shallow),
|
|
1628
|
+
_useConfigStore$theme = _useConfigStore.themePropertiesSchema,
|
|
1629
|
+
themePropertiesSchema = _useConfigStore$theme === void 0 ? [] : _useConfigStore$theme;
|
|
1630
|
+
var _themePropertiesSchem = _slicedToArray(themePropertiesSchema, 2),
|
|
1631
|
+
colorObject1 = _themePropertiesSchem[0],
|
|
1632
|
+
colorObject2 = _themePropertiesSchem[1];
|
|
1633
|
+
var primaryLabel = neetoCist.humanize(colorObject1 === null || colorObject1 === void 0 ? void 0 : colorObject1.key);
|
|
1634
|
+
var secondaryLabel = neetoCist.humanize(colorObject2 === null || colorObject2 === void 0 ? void 0 : colorObject2.key);
|
|
1635
|
+
var primaryColor = neetoCist.findBy({
|
|
1636
|
+
key: colorObject1.key
|
|
1637
|
+
}, theme.properties).value;
|
|
1638
|
+
var secondaryColor = neetoCist.findBy({
|
|
1639
|
+
key: colorObject2.key
|
|
1640
|
+
}, theme.properties).value;
|
|
1641
|
+
var backgroundImageUrl = (_theme$snakeToCamelCa = theme[neetoCist.snakeToCamelCase(neetoCist.findBy({
|
|
1642
|
+
useAsCardBackground: true
|
|
1643
|
+
}, themePropertiesSchema).key)]) === null || _theme$snakeToCamelCa === void 0 ? void 0 : _theme$snakeToCamelCa.url;
|
|
1644
|
+
var buttonBackgroundColor = (_findBy = neetoCist.findBy({
|
|
1645
|
+
key: (_findBy2 = neetoCist.findBy({
|
|
1646
|
+
useAsCardButtonBackground: true
|
|
1647
|
+
}, themePropertiesSchema)) === null || _findBy2 === void 0 ? void 0 : _findBy2.key
|
|
1648
|
+
}, theme.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value;
|
|
1649
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1650
|
+
className: classnames("neeto-themes-theme-thumbnail neeto-ui-rounded-lg border transition-all duration-300 ease-in-out", {
|
|
1651
|
+
"neeto-ui-border-gray-400": !active,
|
|
1652
|
+
"neeto-ui-border-gray-800 neeto-themes-theme-thumbnail--active": active,
|
|
1653
|
+
"neeto-themes-theme-thumbnail--preview-active": isPreviewing,
|
|
1654
|
+
"neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
|
|
1655
|
+
}),
|
|
1656
|
+
style: {
|
|
1657
|
+
backgroundImage: backgroundImageUrl ? "url(".concat(backgroundImageUrl, ")") : "initial",
|
|
1658
|
+
backgroundSize: "cover"
|
|
1659
|
+
},
|
|
1660
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1661
|
+
className: "neeto-ui-rounded-lg cursor-pointer p-3 transition-all duration-300 ease-in-out group-hover:opacity-85",
|
|
1662
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1663
|
+
className: "neeto-ui-rounded-lg p-3",
|
|
1664
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1665
|
+
className: "mb-3",
|
|
1666
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1667
|
+
style: "h3",
|
|
1668
|
+
weight: "semibold",
|
|
1669
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1670
|
+
style: {
|
|
1671
|
+
color: primaryColor
|
|
1672
|
+
},
|
|
1673
|
+
children: primaryLabel
|
|
1674
|
+
})
|
|
1675
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1676
|
+
className: "neeto-ui-text-gray-600",
|
|
1677
|
+
style: "body2",
|
|
1678
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1679
|
+
style: {
|
|
1680
|
+
color: secondaryColor
|
|
1681
|
+
},
|
|
1682
|
+
children: secondaryLabel
|
|
1683
|
+
})
|
|
1684
|
+
})]
|
|
1685
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1686
|
+
className: "neeto-ui-rounded-lg h-5 w-12",
|
|
1687
|
+
style: {
|
|
1688
|
+
backgroundColor: buttonBackgroundColor
|
|
1689
|
+
}
|
|
1690
|
+
})]
|
|
1691
|
+
})
|
|
1692
|
+
})
|
|
1693
|
+
});
|
|
1694
|
+
};
|
|
1695
|
+
|
|
1696
|
+
var Card = function Card(_ref) {
|
|
1697
|
+
var _ref$active = _ref.active,
|
|
1698
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
1699
|
+
isPreviewing = _ref.isPreviewing,
|
|
1700
|
+
onSetPreviewTheme = _ref.onSetPreviewTheme,
|
|
1701
|
+
onDeleteTheme = _ref.onDeleteTheme,
|
|
1702
|
+
onEditTheme = _ref.onEditTheme,
|
|
1703
|
+
theme = _ref.theme,
|
|
1704
|
+
isApplyingTheme = _ref.isApplyingTheme,
|
|
1705
|
+
onCloneTheme = _ref.onCloneTheme,
|
|
1706
|
+
isHighLightedTheme = _ref.isHighLightedTheme,
|
|
1707
|
+
isGlobalTheme = _ref.isGlobalTheme,
|
|
1708
|
+
onApplyTheme = _ref.onApplyTheme,
|
|
1709
|
+
Thumbnail$1 = _ref.thumbnail;
|
|
1710
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1711
|
+
t = _useTranslation.t;
|
|
1712
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
1713
|
+
return {
|
|
1714
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
1715
|
+
};
|
|
1716
|
+
}, shallow.shallow),
|
|
1717
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
1718
|
+
var id = theme.id,
|
|
1719
|
+
name = theme.name;
|
|
1720
|
+
var imageProperties = neetoCist.filterBy({
|
|
1721
|
+
kind: "image"
|
|
1722
|
+
}, themePropertiesSchema);
|
|
1723
|
+
var handleDeleteTheme = function handleDeleteTheme() {
|
|
1724
|
+
return onDeleteTheme(id, name);
|
|
1725
|
+
};
|
|
1726
|
+
var handleQuickEdit = function handleQuickEdit(section) {
|
|
1727
|
+
return function (e) {
|
|
1728
|
+
e.stopPropagation();
|
|
1729
|
+
if (neetoCist.isPresent(onEditTheme)) onEditTheme(theme, section);else onCloneTheme(theme, section);
|
|
1730
|
+
};
|
|
1731
|
+
};
|
|
1732
|
+
var showMoreDropdown = utils.isFunction(onDeleteTheme);
|
|
1733
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1734
|
+
className: "group space-y-2 pt-0.5",
|
|
1735
|
+
"data-flip-id": theme.id,
|
|
1736
|
+
"data-testid": active ? "active-theme-card" : "theme-card",
|
|
1737
|
+
id: theme.id,
|
|
1738
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1739
|
+
className: classnames("neeto-themes-theme-thumbnail neeto-ui-rounded-lg relative cursor-pointer border-2 transition-all duration-300 ease-in-out", {
|
|
1740
|
+
"neeto-ui-border-gray-400": !active,
|
|
1741
|
+
"neeto-themes-theme-thumbnail--active": active,
|
|
1742
|
+
"neeto-themes-theme-thumbnail--preview-active": isPreviewing,
|
|
1743
|
+
"neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
|
|
1744
|
+
}),
|
|
1745
|
+
onClick: function onClick() {
|
|
1746
|
+
return onSetPreviewTheme(theme);
|
|
1747
|
+
},
|
|
1748
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1749
|
+
className: "neeto-ui-rounded-lg relative overflow-hidden rounded-bl-none rounded-br-none transition-all duration-300 ease-in-out",
|
|
1750
|
+
children: [active ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1751
|
+
className: "neeto-themes-theme-thumbnail__active-banner absolute start-0 top-0 z-10 w-full py-1 text-center text-xs font-semibold uppercase tracking-wide",
|
|
1752
|
+
"data-testid": "active-theme-label",
|
|
1753
|
+
children: t("neetoThemes.common.activeTheme")
|
|
1754
|
+
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1755
|
+
className: "absolute start-0 top-0 z-10 flex h-full w-full items-center justify-center px-3 pb-3 pt-3",
|
|
1756
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1757
|
+
className: classnames("-translate-y-9 flex w-full items-center justify-between gap-2", {
|
|
1758
|
+
hidden: !isPreviewing,
|
|
1759
|
+
"group-hover:flex": true
|
|
1760
|
+
}),
|
|
1761
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1762
|
+
"data-testid": "preview-theme-button",
|
|
1763
|
+
disabled: isPreviewing,
|
|
1764
|
+
label: t("neetoThemes.common.previewTheme"),
|
|
1765
|
+
size: "medium",
|
|
1766
|
+
style: "tertiary",
|
|
1767
|
+
className: classnames({
|
|
1768
|
+
"neeto-themes-theme-thumbnail__preview-btn--disabled opacity-100": isPreviewing,
|
|
1769
|
+
"neeto-themes-theme-thumbnail__preview-btn shrink-0 justify-center": true
|
|
1770
|
+
}),
|
|
1771
|
+
onClick: function onClick() {
|
|
1772
|
+
return onSetPreviewTheme(theme);
|
|
1773
|
+
}
|
|
1774
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1775
|
+
className: "neeto-themes-theme-thumbnail__apply-btn shrink-0 justify-center",
|
|
1776
|
+
"data-testid": "apply-theme-button",
|
|
1777
|
+
disabled: isApplyingTheme,
|
|
1778
|
+
label: t("neetoThemes.common.useTheme"),
|
|
1779
|
+
loading: isApplyingTheme,
|
|
1780
|
+
size: "medium",
|
|
1781
|
+
style: "primary",
|
|
1782
|
+
onClick: function onClick() {
|
|
1783
|
+
return onApplyTheme(theme);
|
|
1784
|
+
}
|
|
1785
|
+
})]
|
|
1786
|
+
})
|
|
1787
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1788
|
+
className: "neeto-themes-theme-thumbnail__overlay w-full transition-all duration-300 ease-in-out",
|
|
1789
|
+
children: Thumbnail$1 ? /*#__PURE__*/jsxRuntime.jsx(Thumbnail$1, {
|
|
1790
|
+
active: active,
|
|
1791
|
+
isHighLightedTheme: isHighLightedTheme,
|
|
1792
|
+
isPreviewing: isPreviewing,
|
|
1793
|
+
theme: theme
|
|
1794
|
+
}) : /*#__PURE__*/jsxRuntime.jsx(Thumbnail, {
|
|
1795
|
+
active: active,
|
|
1796
|
+
isHighLightedTheme: isHighLightedTheme,
|
|
1797
|
+
isPreviewing: isPreviewing,
|
|
1798
|
+
theme: theme
|
|
1799
|
+
})
|
|
1800
|
+
})]
|
|
1801
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1802
|
+
className: "neeto-ui-border-gray-100 flex items-start justify-between gap-1 border-t p-2",
|
|
1803
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1804
|
+
className: "flex items-center space-x-2",
|
|
1805
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1806
|
+
className: "neeto-ui-text-gray-500 line-clamp-2 min-w-0 grow wrap-anywhere pt-1 italic",
|
|
1807
|
+
"data-testid": "theme-name",
|
|
1808
|
+
lineHeight: "snug",
|
|
1809
|
+
style: "body2",
|
|
1810
|
+
children: name
|
|
1811
|
+
}), isGlobalTheme && /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
1812
|
+
className: "neeto-ui-text-gray-500 shrink-0 pt-1 italic",
|
|
1813
|
+
"data-testid": "default-theme-label",
|
|
1814
|
+
lineHeight: "snug",
|
|
1815
|
+
style: "body2",
|
|
1816
|
+
children: t("neetoThemes.common.defaultTheme")
|
|
1817
|
+
})]
|
|
1818
|
+
}), showMoreDropdown && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown, {
|
|
1819
|
+
dropdownButtonProps: {
|
|
1820
|
+
size: "small"
|
|
1821
|
+
},
|
|
1822
|
+
dropdownProps: {
|
|
1823
|
+
strategy: "fixed",
|
|
1824
|
+
onClick: function onClick(e) {
|
|
1825
|
+
return e.stopPropagation();
|
|
1826
|
+
}
|
|
1827
|
+
},
|
|
1828
|
+
menuItems: [{
|
|
1829
|
+
key: "delete",
|
|
1830
|
+
"data-testid": "delete-theme-menu-item",
|
|
1831
|
+
label: t("neetoThemes.build.leftSideBar.themes.themeOptions.delete"),
|
|
1832
|
+
isDisabled: isApplyingTheme,
|
|
1833
|
+
onClick: function onClick(e) {
|
|
1834
|
+
e.stopPropagation();
|
|
1835
|
+
handleDeleteTheme();
|
|
1836
|
+
}
|
|
1837
|
+
}]
|
|
1838
|
+
})]
|
|
1839
|
+
}), active && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1840
|
+
className: "flex flex-col",
|
|
1841
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(QuickActionRow, {
|
|
1842
|
+
icon: ColorPicker$1,
|
|
1843
|
+
label: t("neetoThemes.common.customizeStyle"),
|
|
1844
|
+
testId: "quick-customize-style",
|
|
1845
|
+
onClick: handleQuickEdit("style")
|
|
1846
|
+
}), imageProperties.map(function (_ref2) {
|
|
1847
|
+
var _theme$camelKey;
|
|
1848
|
+
var key = _ref2.key;
|
|
1849
|
+
var camelKey = neetoCist.snakeToCamelCase(key);
|
|
1850
|
+
var hasImage = neetoCist.isPresent((_theme$camelKey = theme[camelKey]) === null || _theme$camelKey === void 0 ? void 0 : _theme$camelKey.url);
|
|
1851
|
+
var action = hasImage ? "change" : "add";
|
|
1852
|
+
var specificKey = "neetoThemes.common.".concat(action).concat(neetoCist.capitalize(camelKey));
|
|
1853
|
+
return /*#__PURE__*/jsxRuntime.jsx(QuickActionRow, {
|
|
1854
|
+
icon: AddImage,
|
|
1855
|
+
label: t([specificKey, "neetoThemes.common.addImage"]),
|
|
1856
|
+
testId: "quick-add-".concat(neetoCist.hyphenate(key)),
|
|
1857
|
+
onClick: handleQuickEdit(camelKey)
|
|
1858
|
+
}, key);
|
|
1859
|
+
}), /*#__PURE__*/jsxRuntime.jsx(QuickActionRow, {
|
|
1860
|
+
icon: CodeBlock,
|
|
1861
|
+
label: t("neetoThemes.build.leftSideBar.themes.customCSS"),
|
|
1862
|
+
testId: "quick-custom-css",
|
|
1863
|
+
onClick: handleQuickEdit("customcss")
|
|
1864
|
+
})]
|
|
1865
|
+
})]
|
|
1866
|
+
})
|
|
1867
|
+
});
|
|
1868
|
+
};
|
|
1869
|
+
var Card$1 = /*#__PURE__*/react.memo(Card);
|
|
1870
|
+
|
|
1871
|
+
var Themes = function Themes(_ref) {
|
|
1872
|
+
var onEditTheme = _ref.onEditTheme,
|
|
1873
|
+
_ref$themes = _ref.themes,
|
|
1874
|
+
themes = _ref$themes === void 0 ? [] : _ref$themes,
|
|
1875
|
+
_ref$defaultThemes = _ref.defaultThemes,
|
|
1876
|
+
defaultThemes = _ref$defaultThemes === void 0 ? [] : _ref$defaultThemes,
|
|
1877
|
+
onDeleteTheme = _ref.onDeleteTheme,
|
|
1878
|
+
themeToHighlight = _ref.themeToHighlight,
|
|
1879
|
+
didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
|
|
1880
|
+
isLoading = _ref.isLoading,
|
|
1881
|
+
currentTheme = _ref.currentTheme,
|
|
1882
|
+
isCurrentThemeLoading = _ref.isCurrentThemeLoading,
|
|
1883
|
+
thumbnail = _ref.thumbnail,
|
|
1884
|
+
themeBeingApplied = _ref.themeBeingApplied,
|
|
1885
|
+
onApplyTheme = _ref.onApplyTheme,
|
|
1886
|
+
onApplyThemeSuccess = _ref.onApplyThemeSuccess,
|
|
1887
|
+
_ref$isSearchVisible = _ref.isSearchVisible,
|
|
1888
|
+
isSearchVisible = _ref$isSearchVisible === void 0 ? false : _ref$isSearchVisible;
|
|
1889
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
1890
|
+
t = _useTranslation.t;
|
|
1891
|
+
var _useThemeUtils = useExpandedSection.useThemeUtils(),
|
|
1892
|
+
setTheme = _useThemeUtils.setTheme;
|
|
1893
|
+
var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
|
|
1894
|
+
return {
|
|
1895
|
+
setThemeState: store["setThemeState"],
|
|
1896
|
+
previewingTheme: store["previewingTheme"]
|
|
1897
|
+
};
|
|
1898
|
+
}, shallow.shallow),
|
|
1899
|
+
setThemeState = _useThemeStore.setThemeState,
|
|
1900
|
+
previewingTheme = _useThemeStore.previewingTheme;
|
|
1901
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
1902
|
+
return {
|
|
1903
|
+
entityType: store["entityType"],
|
|
1904
|
+
entityId: store["entityId"]
|
|
1905
|
+
};
|
|
1906
|
+
}, shallow.shallow),
|
|
1907
|
+
entityType = _useConfigStore.entityType,
|
|
1908
|
+
entityId = _useConfigStore.entityId;
|
|
1909
|
+
var _useQueryParams = reactUtils.useQueryParams(),
|
|
1910
|
+
_useQueryParams$searc = _useQueryParams.searchTerm,
|
|
1911
|
+
searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
|
|
1912
|
+
var _useCloneTheme = useGlobalThemesApi.useCloneTheme(),
|
|
1913
|
+
cloneTheme = _useCloneTheme.mutate;
|
|
1914
|
+
var _useApplyTheme = useGlobalThemesApi.useApplyTheme({}),
|
|
1915
|
+
applyClonedTheme = _useApplyTheme.mutate;
|
|
1916
|
+
var _useShowGlobalTheme = useGlobalThemesApi.useShowGlobalTheme(entityType),
|
|
1917
|
+
_useShowGlobalTheme$d = _useShowGlobalTheme.data,
|
|
1918
|
+
_useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
|
|
1919
|
+
_useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
|
|
1920
|
+
globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3,
|
|
1921
|
+
isLoadingGlobalTheme = _useShowGlobalTheme.isLoading;
|
|
1922
|
+
react.useEffect(function () {
|
|
1923
|
+
if (didScrollActiveThemeIntoView.current || !(currentTheme !== null && currentTheme !== void 0 && currentTheme.id)) return;
|
|
1924
|
+
didScrollActiveThemeIntoView.current = true;
|
|
1925
|
+
setTimeout(function () {
|
|
1926
|
+
utils.scrollElementIntoView(currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
|
|
1927
|
+
}, 100);
|
|
1928
|
+
}, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
|
|
1929
|
+
var setPreviewTheme = function setPreviewTheme(theme) {
|
|
1930
|
+
setThemeState({
|
|
1931
|
+
previewingTheme: theme
|
|
1932
|
+
});
|
|
1933
|
+
setTheme(theme);
|
|
1934
|
+
};
|
|
1935
|
+
var activeThemeId = currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id;
|
|
1936
|
+
var lowerSearchTerm = searchTerm.toLowerCase();
|
|
1937
|
+
var matchesSearch = function matchesSearch(theme) {
|
|
1938
|
+
return theme.name.toLowerCase().includes(lowerSearchTerm);
|
|
1939
|
+
};
|
|
1940
|
+
var activeTheme = activeThemeId ? [].concat(_toConsumableArray(defaultThemes), _toConsumableArray(themes)).find(function (theme) {
|
|
1941
|
+
return theme.id === activeThemeId;
|
|
1942
|
+
}) : null;
|
|
1943
|
+
var isActiveThemeCustom = themes.some(function (theme) {
|
|
1944
|
+
return theme.id === activeThemeId;
|
|
1945
|
+
});
|
|
1946
|
+
var filteredDefaultThemes = defaultThemes.filter(function (theme) {
|
|
1947
|
+
return theme.id !== activeThemeId && matchesSearch(theme);
|
|
1948
|
+
});
|
|
1949
|
+
var filteredThemes = themes.filter(function (theme) {
|
|
1950
|
+
return theme.id !== activeThemeId && matchesSearch(theme);
|
|
1951
|
+
});
|
|
1952
|
+
var showActiveThemeSection = activeTheme && matchesSearch(activeTheme);
|
|
1953
|
+
var handleCloneTheme = function handleCloneTheme(data, section) {
|
|
1954
|
+
cloneTheme(data.id, {
|
|
1955
|
+
onSuccess: function onSuccess(_ref2) {
|
|
1956
|
+
var clonedTheme = _ref2.theme;
|
|
1957
|
+
// A system theme is cloned when the user customizes it. Apply the
|
|
1958
|
+
// clone right away so it becomes the active theme — the editor then
|
|
1959
|
+
// won't prompt "apply this theme?" on save.
|
|
1960
|
+
applyClonedTheme({
|
|
1961
|
+
themeId: clonedTheme.id,
|
|
1962
|
+
entityId: entityId,
|
|
1963
|
+
entityType: entityType
|
|
1964
|
+
}, {
|
|
1965
|
+
onSuccess: function onSuccess() {
|
|
1966
|
+
onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(clonedTheme);
|
|
1967
|
+
onEditTheme(clonedTheme, section);
|
|
1968
|
+
}
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1972
|
+
};
|
|
1973
|
+
if (isLoading || isCurrentThemeLoading || isLoadingGlobalTheme) {
|
|
1974
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1975
|
+
className: "flex h-full w-full items-center justify-center",
|
|
1976
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
var activeThemeSection = showActiveThemeSection && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1980
|
+
className: "neeto-ui-border-gray-200 mb-6 border-b px-6 pb-6 lg:px-5 xl:px-6",
|
|
1981
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Card$1, {
|
|
1982
|
+
onApplyTheme: onApplyTheme,
|
|
1983
|
+
thumbnail: thumbnail,
|
|
1984
|
+
active: true,
|
|
1985
|
+
isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === activeTheme.id,
|
|
1986
|
+
isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === activeTheme.id,
|
|
1987
|
+
isHighLightedTheme: activeTheme.id === themeToHighlight,
|
|
1988
|
+
isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === activeTheme.id,
|
|
1989
|
+
theme: activeTheme,
|
|
1990
|
+
onCloneTheme: handleCloneTheme,
|
|
1991
|
+
onEditTheme: isActiveThemeCustom ? onEditTheme : undefined,
|
|
1992
|
+
onSetPreviewTheme: setPreviewTheme
|
|
1993
|
+
})
|
|
1994
|
+
});
|
|
1995
|
+
var systemThemesSection = neetoCist.isNotEmpty(filteredDefaultThemes) && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1996
|
+
className: "mb-6 space-y-3",
|
|
1997
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1998
|
+
className: "flex flex-col gap-4 px-6 pb-10 lg:px-5 xl:px-6",
|
|
1999
|
+
"data-testid": "system-themes",
|
|
2000
|
+
children: filteredDefaultThemes.map(function (theme) {
|
|
2001
|
+
return /*#__PURE__*/react.createElement(Card$1, {
|
|
2002
|
+
onApplyTheme: onApplyTheme,
|
|
2003
|
+
theme: theme,
|
|
2004
|
+
thumbnail: thumbnail,
|
|
2005
|
+
active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
|
|
2006
|
+
isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
|
|
2007
|
+
isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
|
|
2008
|
+
isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
|
|
2009
|
+
key: theme.id,
|
|
2010
|
+
onCloneTheme: handleCloneTheme,
|
|
2011
|
+
onSetPreviewTheme: setPreviewTheme
|
|
2012
|
+
});
|
|
2013
|
+
})
|
|
2014
|
+
})
|
|
2015
|
+
});
|
|
2016
|
+
var customThemesSection = neetoCist.isNotEmpty(filteredThemes) && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2017
|
+
className: "mb-6 space-y-3",
|
|
2018
|
+
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2019
|
+
className: "flex flex-col gap-4 px-6",
|
|
2020
|
+
"data-testid": "custom-themes",
|
|
2021
|
+
children: filteredThemes.map(function (theme) {
|
|
2022
|
+
var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
|
|
2023
|
+
var isPreviewing = (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id;
|
|
2024
|
+
return /*#__PURE__*/react.createElement(Card$1, {
|
|
2025
|
+
isPreviewing: isPreviewing,
|
|
2026
|
+
onApplyTheme: onApplyTheme,
|
|
2027
|
+
onEditTheme: onEditTheme,
|
|
2028
|
+
theme: theme,
|
|
2029
|
+
thumbnail: thumbnail,
|
|
2030
|
+
active: isActive,
|
|
2031
|
+
isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
|
|
2032
|
+
isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
|
|
2033
|
+
isHighLightedTheme: theme.id === themeToHighlight,
|
|
2034
|
+
key: theme.id,
|
|
2035
|
+
onCloneTheme: handleCloneTheme,
|
|
2036
|
+
onDeleteTheme: !isActive && onDeleteTheme,
|
|
2037
|
+
onSetPreviewTheme: setPreviewTheme
|
|
2038
|
+
});
|
|
2039
|
+
})
|
|
2040
|
+
})
|
|
2041
|
+
});
|
|
2042
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2043
|
+
className: "neeto-themes-sidebar__scroll",
|
|
2044
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2045
|
+
className: "mb-6 space-y-3",
|
|
2046
|
+
children: [isSearchVisible && /*#__PURE__*/jsxRuntime.jsx(Search, {
|
|
2047
|
+
autoFocus: true,
|
|
2048
|
+
enableUrlSync: true,
|
|
2049
|
+
autoComplete: "off",
|
|
2050
|
+
className: "mb-4 mt-1 px-6",
|
|
2051
|
+
placeholder: t("neetoThemes.common.searchThemes")
|
|
2052
|
+
}), ramda.isEmpty(filteredThemes) && ramda.isEmpty(filteredDefaultThemes) && /*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
2053
|
+
className: "text-center",
|
|
2054
|
+
"data-testid": "no-data-title",
|
|
2055
|
+
style: "body2",
|
|
2056
|
+
children: t("neetoThemes.common.noResultsFound")
|
|
2057
|
+
})]
|
|
2058
|
+
}), activeThemeSection, systemThemesSection, customThemesSection]
|
|
2059
|
+
});
|
|
2060
|
+
};
|
|
2061
|
+
|
|
2062
|
+
var TitleBar = function TitleBar(_ref) {
|
|
2063
|
+
var currentScreen = _ref.currentScreen,
|
|
2064
|
+
handleBackPress = _ref.handleBackPress,
|
|
2065
|
+
handleToggleSearch = _ref.handleToggleSearch;
|
|
2066
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
2067
|
+
t = _useTranslation.t;
|
|
2068
|
+
var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
|
|
2069
|
+
return {
|
|
2070
|
+
previewingTheme: store["previewingTheme"]
|
|
2071
|
+
};
|
|
2072
|
+
}, shallow.shallow),
|
|
2073
|
+
previewingTheme = _useThemeStore.previewingTheme;
|
|
2074
|
+
var themeId = previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id;
|
|
2075
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
2076
|
+
return {
|
|
2077
|
+
entityType: store["entityType"],
|
|
2078
|
+
helpDocUrl: store["helpDocUrl"]
|
|
2079
|
+
};
|
|
2080
|
+
}, shallow.shallow),
|
|
2081
|
+
entityType = _useConfigStore.entityType,
|
|
2082
|
+
helpDocUrl = _useConfigStore.helpDocUrl;
|
|
2083
|
+
var isCustomizeScreen = utils.isEditThemeRoute() || utils.isNewThemeRoute();
|
|
2084
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
2085
|
+
var isRTL = i18n.dir() === "rtl";
|
|
2086
|
+
var BackButtonIcon = isRTL ? RightArrow : LeftArrow;
|
|
2087
|
+
if (isCustomizeScreen) {
|
|
2088
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2089
|
+
className: "neeto-themes-sidebar__header px-4",
|
|
2090
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2091
|
+
className: "flex items-center justify-start space-x-2",
|
|
2092
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
2093
|
+
"data-testid": "customize-themes-back-button",
|
|
2094
|
+
icon: BackButtonIcon,
|
|
2095
|
+
iconPosition: "left",
|
|
2096
|
+
style: "text",
|
|
2097
|
+
tooltipProps: {
|
|
2098
|
+
content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
|
|
2099
|
+
position: "top"
|
|
2100
|
+
},
|
|
2101
|
+
onClick: function onClick() {
|
|
2102
|
+
return handleBackPress(themeId);
|
|
2103
|
+
}
|
|
2104
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(Typography, {
|
|
2105
|
+
"data-testid": "themes-header",
|
|
2106
|
+
lineHeight: "normal",
|
|
2107
|
+
style: "h3",
|
|
2108
|
+
weight: "semibold",
|
|
2109
|
+
children: [isCustomizeScreen && !isCustomCssScreen && (utils.isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
|
|
2110
|
+
})]
|
|
2111
|
+
})
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2115
|
+
className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
|
|
2116
|
+
children: /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2117
|
+
className: "flex items-center justify-between space-x-2",
|
|
2118
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2119
|
+
className: "flex space-x-2",
|
|
2120
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Typography, {
|
|
2121
|
+
"data-testid": "themes-header",
|
|
2122
|
+
lineHeight: "normal",
|
|
2123
|
+
style: "h3",
|
|
2124
|
+
weight: "semibold",
|
|
2125
|
+
children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
|
|
2126
|
+
}), /*#__PURE__*/jsxRuntime.jsx(HelpPopover, {
|
|
2127
|
+
helpLinkProps: helpDocUrl && {
|
|
2128
|
+
href: helpDocUrl
|
|
2129
|
+
},
|
|
2130
|
+
title: t("neetoThemes.build.leftSideBar.helpPopover.title"),
|
|
2131
|
+
description: t("neetoThemes.build.leftSideBar.helpPopover.description", {
|
|
2132
|
+
entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
|
|
2133
|
+
})
|
|
2134
|
+
})]
|
|
2135
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2136
|
+
className: "self-end",
|
|
2137
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
2138
|
+
"data-testid": "themes-search-toggle-button",
|
|
2139
|
+
icon: Search$1,
|
|
2140
|
+
iconPosition: "left",
|
|
2141
|
+
style: "text",
|
|
2142
|
+
tooltipProps: {
|
|
2143
|
+
content: t("neetoThemes.common.searchThemes"),
|
|
2144
|
+
position: "top"
|
|
2145
|
+
},
|
|
2146
|
+
onClick: handleToggleSearch
|
|
2147
|
+
})
|
|
2148
|
+
})]
|
|
2149
|
+
})
|
|
2150
|
+
});
|
|
2151
|
+
};
|
|
2152
|
+
|
|
2153
|
+
var MemoizedAlert = /*#__PURE__*/react.memo(Alert);
|
|
2154
|
+
var Sidebar = function Sidebar(_ref) {
|
|
2155
|
+
var _themeToDelete$curren2;
|
|
2156
|
+
var thumbnail = _ref.thumbnail,
|
|
2157
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
2158
|
+
defaultImageSize = _ref.defaultImageSize,
|
|
2159
|
+
fixedAspectRatio = _ref.fixedAspectRatio,
|
|
2160
|
+
onApplyThemeSuccess = _ref.onApplyThemeSuccess,
|
|
2161
|
+
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
|
|
2162
|
+
var _useState = react.useState(DESIGN_SCREENS.THEMES),
|
|
2163
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2164
|
+
currentScreen = _useState2[0],
|
|
2165
|
+
setCurrentScreen = _useState2[1];
|
|
2166
|
+
var _useState3 = react.useState(false),
|
|
2167
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2168
|
+
isDeleteAlertOpen = _useState4[0],
|
|
2169
|
+
setIsDeleteAlertOpen = _useState4[1];
|
|
2170
|
+
var _useState5 = react.useState(null),
|
|
2171
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2172
|
+
themeToHighlight = _useState6[0],
|
|
2173
|
+
setThemeToHighlight = _useState6[1];
|
|
2174
|
+
var _useState7 = react.useState({}),
|
|
2175
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
2176
|
+
themeBeingApplied = _useState8[0],
|
|
2177
|
+
setThemeBeingApplied = _useState8[1];
|
|
2178
|
+
var _useBreakpoints = reactUtils.useBreakpoints(),
|
|
2179
|
+
isSize = _useBreakpoints.isSize;
|
|
2180
|
+
var isLargerScreen = !isSize("mobile");
|
|
2181
|
+
var _useState9 = react.useState(!isLargerScreen),
|
|
2182
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
2183
|
+
isThemesSidebarCollapsed = _useState10[0],
|
|
2184
|
+
setIsThemesSidebarCollapsed = _useState10[1];
|
|
2185
|
+
var history = reactRouterDom.useHistory();
|
|
2186
|
+
react.useEffect(function () {
|
|
2187
|
+
setIsThemesSidebarCollapsed(!isLargerScreen);
|
|
2188
|
+
}, [isLargerScreen]);
|
|
2189
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
2190
|
+
return {
|
|
2191
|
+
entityType: store["entityType"],
|
|
2192
|
+
entityId: store["entityId"],
|
|
2193
|
+
isFetchingSchema: store["isFetchingSchema"],
|
|
2194
|
+
defaultThemeName: store["defaultThemeName"]
|
|
2195
|
+
};
|
|
2196
|
+
}, shallow.shallow),
|
|
2197
|
+
entityType = _useConfigStore.entityType,
|
|
2198
|
+
entityId = _useConfigStore.entityId,
|
|
2199
|
+
isFetchingSchema = _useConfigStore.isFetchingSchema,
|
|
2200
|
+
defaultThemeName = _useConfigStore.defaultThemeName;
|
|
2201
|
+
var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
|
|
2202
|
+
return {
|
|
2203
|
+
setThemeState: store["setThemeState"]
|
|
2204
|
+
};
|
|
2205
|
+
}, shallow.shallow),
|
|
2206
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
2207
|
+
var didScrollActiveThemeIntoView = react.useRef(null);
|
|
2208
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
2209
|
+
t = _useTranslation.t;
|
|
2210
|
+
var _useThemeUtils = useExpandedSection.useThemeUtils(),
|
|
2211
|
+
setTheme = _useThemeUtils.setTheme;
|
|
2212
|
+
var _useListThemes = useGlobalThemesApi.useListThemes(entityId),
|
|
2213
|
+
_useListThemes$data = _useListThemes.data,
|
|
2214
|
+
_useListThemes$data2 = _useListThemes$data === void 0 ? {} : _useListThemes$data,
|
|
2215
|
+
_useListThemes$data2$ = _useListThemes$data2.themes,
|
|
2216
|
+
themes = _useListThemes$data2$ === void 0 ? [] : _useListThemes$data2$,
|
|
2217
|
+
_useListThemes$data2$2 = _useListThemes$data2.defaultThemes,
|
|
2218
|
+
defaultThemes = _useListThemes$data2$2 === void 0 ? [] : _useListThemes$data2$2,
|
|
2219
|
+
isLoading = _useListThemes.isLoading;
|
|
2220
|
+
var _useShowThemeEntity = useGlobalThemesApi.useShowThemeEntity(entityId),
|
|
2221
|
+
_useShowThemeEntity$d = _useShowThemeEntity.data,
|
|
2222
|
+
_useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
|
|
2223
|
+
_useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
|
|
2224
|
+
currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
|
|
2225
|
+
isCurrentThemeLoading = _useShowThemeEntity.isLoading;
|
|
2226
|
+
var _useDeleteTheme = useGlobalThemesApi.useDeleteTheme(),
|
|
2227
|
+
deleteTheme = _useDeleteTheme.mutate,
|
|
2228
|
+
isDeleting = _useDeleteTheme.isPending;
|
|
2229
|
+
var _useApplyTheme = useGlobalThemesApi.useApplyTheme({
|
|
2230
|
+
onSuccess: function onSuccess(_ref2) {
|
|
2231
|
+
var theme = _ref2.theme;
|
|
2232
|
+
var applyUpdates = function applyUpdates() {
|
|
2233
|
+
setTheme(theme);
|
|
2234
|
+
highlightTheme(theme);
|
|
2235
|
+
setThemeState({
|
|
2236
|
+
previewingTheme: theme
|
|
2237
|
+
});
|
|
2238
|
+
setThemeBeingApplied({});
|
|
2239
|
+
setCurrentScreen(DESIGN_SCREENS.THEMES);
|
|
2240
|
+
onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(theme);
|
|
2241
|
+
};
|
|
2242
|
+
|
|
2243
|
+
// Keep the spinner visible a bit longer so the apply feels deliberate,
|
|
2244
|
+
// then glide the card into the pinned active section.
|
|
2245
|
+
setTimeout(function () {
|
|
2246
|
+
return animateThemeReorder(applyUpdates);
|
|
2247
|
+
}, useExpandedSection.APPLY_SPINNER_DELAY);
|
|
2248
|
+
}
|
|
2249
|
+
}),
|
|
2250
|
+
applyTheme = _useApplyTheme.mutate,
|
|
2251
|
+
isApplyingTheme = _useApplyTheme.isPending;
|
|
2252
|
+
var themeToDelete = react.useRef(null);
|
|
2253
|
+
var themeToEdit = react.useRef(null);
|
|
2254
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
2255
|
+
var _useState11 = react.useState(false),
|
|
2256
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
2257
|
+
isSearchVisible = _useState12[0],
|
|
2258
|
+
setIsSearchVisible = _useState12[1];
|
|
2259
|
+
var handleToggleSearch = function handleToggleSearch() {
|
|
2260
|
+
setIsSearchVisible(function (prev) {
|
|
2261
|
+
var next = !prev;
|
|
2262
|
+
if (!next) {
|
|
2263
|
+
var params = new URLSearchParams(history.location.search);
|
|
2264
|
+
params["delete"]("searchTerm");
|
|
2265
|
+
history.replace({
|
|
2266
|
+
search: params.toString()
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
return next;
|
|
2270
|
+
});
|
|
2271
|
+
};
|
|
2272
|
+
var handleEditTheme = function handleEditTheme(theme, section) {
|
|
2273
|
+
themeToEdit.current = theme;
|
|
2274
|
+
var pathname = utils$1.buildUrl(buildPathname(useGlobalThemesApi.routes.themes.edit), {
|
|
2275
|
+
themeId: theme.id
|
|
2276
|
+
});
|
|
2277
|
+
history.push({
|
|
2278
|
+
pathname: pathname,
|
|
2279
|
+
search: section ? "?section=".concat(section) : ""
|
|
2280
|
+
});
|
|
2281
|
+
};
|
|
2282
|
+
var onApplyTheme = function onApplyTheme(theme) {
|
|
2283
|
+
if (themeBeingApplied !== null && themeBeingApplied !== void 0 && themeBeingApplied.id) return;
|
|
2284
|
+
setThemeBeingApplied(theme);
|
|
2285
|
+
applyTheme({
|
|
2286
|
+
themeId: theme.id,
|
|
2287
|
+
entityId: entityId,
|
|
2288
|
+
entityType: entityType
|
|
2289
|
+
}, {
|
|
2290
|
+
onError: function onError() {
|
|
2291
|
+
return setThemeBeingApplied({});
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
};
|
|
2295
|
+
var navigateToThemesScreen = function navigateToThemesScreen(themeId) {
|
|
2296
|
+
highlightTheme(neetoCist.isPresent(themeId) ? themeId : currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
|
|
2297
|
+
history.push(buildPathname(useGlobalThemesApi.routes.themes.index));
|
|
2298
|
+
themeToEdit.current = null;
|
|
2299
|
+
};
|
|
2300
|
+
var handleBackPress = function handleBackPress(themeId) {
|
|
2301
|
+
if (isCustomCssScreen) {
|
|
2302
|
+
setCurrentScreen(DESIGN_SCREENS.Customize);
|
|
2303
|
+
return;
|
|
2304
|
+
}
|
|
2305
|
+
navigateToThemesScreen(themeId);
|
|
2306
|
+
};
|
|
2307
|
+
var highlightTheme = function highlightTheme(themeIdToHighlight) {
|
|
2308
|
+
setTimeout(function () {
|
|
2309
|
+
utils.scrollElementIntoView(themeIdToHighlight);
|
|
2310
|
+
}, 1500);
|
|
2311
|
+
setTimeout(function () {
|
|
2312
|
+
setThemeToHighlight(null);
|
|
2313
|
+
}, 4000);
|
|
2314
|
+
setThemeToHighlight(themeIdToHighlight);
|
|
2315
|
+
};
|
|
2316
|
+
var onCreateTheme = function onCreateTheme(createdTheme) {
|
|
2317
|
+
themeToEdit.current = createdTheme;
|
|
2318
|
+
setTheme(createdTheme);
|
|
2319
|
+
setThemeState({
|
|
2320
|
+
previewingTheme: createdTheme
|
|
2321
|
+
});
|
|
2322
|
+
};
|
|
2323
|
+
var onUpdateTheme = function onUpdateTheme(updatedTheme) {
|
|
2324
|
+
themeToEdit.current = updatedTheme;
|
|
2325
|
+
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 || onUpdateThemeSuccess(updatedTheme);
|
|
2326
|
+
};
|
|
2327
|
+
var handleDelete = function handleDelete(themeId, name) {
|
|
2328
|
+
setIsDeleteAlertOpen(true);
|
|
2329
|
+
themeToDelete.current = {
|
|
2330
|
+
id: themeId,
|
|
2331
|
+
name: name
|
|
2332
|
+
};
|
|
2333
|
+
};
|
|
2334
|
+
var handleCloseDeleteAlert = react.useCallback(function () {
|
|
2335
|
+
setIsDeleteAlertOpen(false);
|
|
2336
|
+
themeToDelete.current = null;
|
|
2337
|
+
}, [themeToDelete]);
|
|
2338
|
+
var handleDeleteTheme = react.useCallback(function () {
|
|
2339
|
+
var _themeToDelete$curren;
|
|
2340
|
+
deleteTheme((_themeToDelete$curren = themeToDelete.current) === null || _themeToDelete$curren === void 0 ? void 0 : _themeToDelete$curren.id, {
|
|
2341
|
+
onSuccess: function onSuccess() {
|
|
2342
|
+
setIsDeleteAlertOpen(false);
|
|
2343
|
+
themeToDelete.current = null;
|
|
2344
|
+
}
|
|
2345
|
+
});
|
|
2346
|
+
}, [deleteTheme, themeToDelete]);
|
|
2347
|
+
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
2348
|
+
children: [!isThemesSidebarCollapsed && /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2349
|
+
className: "neeto-themes-sidebar__backdrop",
|
|
2350
|
+
onClick: function onClick() {
|
|
2351
|
+
setIsThemesSidebarCollapsed(!isThemesSidebarCollapsed);
|
|
2352
|
+
}
|
|
2353
|
+
}), /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2354
|
+
className: classnames("neeto-themes-sidebar neeto-ui-border-gray-200 shrink-0 border-e transition-all duration-300", {
|
|
2355
|
+
"neeto-themes-sidebar--expanded": isCustomCssScreen
|
|
2356
|
+
}, {
|
|
2357
|
+
"neeto-themes-sidebar--collapsed": isThemesSidebarCollapsed
|
|
2358
|
+
}),
|
|
2359
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(TitleBar, {
|
|
2360
|
+
currentScreen: currentScreen,
|
|
2361
|
+
handleBackPress: handleBackPress,
|
|
2362
|
+
handleToggleSearch: handleToggleSearch
|
|
2363
|
+
}), /*#__PURE__*/jsxRuntime.jsxs(reactRouterDom.Switch, {
|
|
2364
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
|
|
2365
|
+
exact: true,
|
|
2366
|
+
path: buildPathname(useGlobalThemesApi.routes.themes.index),
|
|
2367
|
+
render: function render() {
|
|
2368
|
+
return /*#__PURE__*/jsxRuntime.jsx(Themes, {
|
|
2369
|
+
currentTheme: currentTheme,
|
|
2370
|
+
defaultThemes: defaultThemes,
|
|
2371
|
+
didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
|
|
2372
|
+
highlightTheme: highlightTheme,
|
|
2373
|
+
isCurrentThemeLoading: isCurrentThemeLoading,
|
|
2374
|
+
isSearchVisible: isSearchVisible,
|
|
2375
|
+
onApplyTheme: onApplyTheme,
|
|
2376
|
+
onApplyThemeSuccess: onApplyThemeSuccess,
|
|
2377
|
+
themeBeingApplied: themeBeingApplied,
|
|
2378
|
+
themeToHighlight: themeToHighlight,
|
|
2379
|
+
themes: themes,
|
|
2380
|
+
thumbnail: thumbnail,
|
|
2381
|
+
isLoading: isLoading || isFetchingSchema,
|
|
2382
|
+
onDeleteTheme: handleDelete,
|
|
2383
|
+
onEditTheme: handleEditTheme
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
|
|
2387
|
+
path: buildPathname(useGlobalThemesApi.routes.themes["new"]),
|
|
2388
|
+
render: function render() {
|
|
2389
|
+
return /*#__PURE__*/jsxRuntime.jsx(Customize, {
|
|
2390
|
+
currentScreen: currentScreen,
|
|
2391
|
+
defaultImageSize: defaultImageSize,
|
|
2392
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
2393
|
+
isApplyingTheme: isApplyingTheme,
|
|
2394
|
+
onApplyTheme: onApplyTheme,
|
|
2395
|
+
onCreateTheme: onCreateTheme,
|
|
2396
|
+
onPropertiesChange: onPropertiesChange,
|
|
2397
|
+
onUpdateTheme: onUpdateTheme,
|
|
2398
|
+
theme: themeToEdit.current,
|
|
2399
|
+
onEditCSSClick: setCurrentScreen
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2402
|
+
}), /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, {
|
|
2403
|
+
path: buildPathname(useGlobalThemesApi.routes.themes.edit),
|
|
2404
|
+
render: function render() {
|
|
2405
|
+
return /*#__PURE__*/jsxRuntime.jsx(Customize, {
|
|
2406
|
+
currentScreen: currentScreen,
|
|
2407
|
+
defaultImageSize: defaultImageSize,
|
|
2408
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
2409
|
+
isApplyingTheme: isApplyingTheme,
|
|
2410
|
+
onApplyTheme: onApplyTheme,
|
|
2411
|
+
onCreateTheme: onCreateTheme,
|
|
2412
|
+
onPropertiesChange: onPropertiesChange,
|
|
2413
|
+
onUpdateTheme: onUpdateTheme,
|
|
2414
|
+
theme: themeToEdit.current,
|
|
2415
|
+
onEditCSSClick: setCurrentScreen
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
})]
|
|
2419
|
+
}), /*#__PURE__*/jsxRuntime.jsx(MemoizedAlert, {
|
|
2420
|
+
isOpen: isDeleteAlertOpen,
|
|
2421
|
+
isSubmitting: isDeleting,
|
|
2422
|
+
title: t("neetoThemes.alerts.title.deleteTheme"),
|
|
2423
|
+
message: t("neetoThemes.alerts.message.deleteTheme", {
|
|
2424
|
+
name: (_themeToDelete$curren2 = themeToDelete.current) === null || _themeToDelete$curren2 === void 0 ? void 0 : _themeToDelete$curren2.name,
|
|
2425
|
+
defaultThemeName: defaultThemeName,
|
|
2426
|
+
entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()))
|
|
2427
|
+
}),
|
|
2428
|
+
onClose: handleCloseDeleteAlert,
|
|
2429
|
+
onSubmit: handleDeleteTheme
|
|
2430
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
2431
|
+
className: "neeto-themes-sidebar__toggler",
|
|
2432
|
+
icon: Collapse,
|
|
2433
|
+
style: "secondary",
|
|
2434
|
+
onClick: function onClick() {
|
|
2435
|
+
setIsThemesSidebarCollapsed(!isThemesSidebarCollapsed);
|
|
2436
|
+
}
|
|
2437
|
+
})]
|
|
2438
|
+
})]
|
|
2439
|
+
});
|
|
2440
|
+
};
|
|
2441
|
+
|
|
2442
|
+
var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
2443
|
+
var children = _ref.children,
|
|
2444
|
+
entityType = _ref.entityType,
|
|
2445
|
+
entityId = _ref.entityId,
|
|
2446
|
+
thumbnail = _ref.thumbnail,
|
|
2447
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
2448
|
+
_ref$defaultImageSize = _ref.defaultImageSize,
|
|
2449
|
+
defaultImageSize = _ref$defaultImageSize === void 0 ? {} : _ref$defaultImageSize,
|
|
2450
|
+
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
2451
|
+
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio,
|
|
2452
|
+
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
2453
|
+
helpDocUrl = _ref$helpDocUrl === void 0 ? null : _ref$helpDocUrl,
|
|
2454
|
+
_ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
|
|
2455
|
+
isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes,
|
|
2456
|
+
_ref$pageTitle = _ref.pageTitle,
|
|
2457
|
+
pageTitle = _ref$pageTitle === void 0 ? null : _ref$pageTitle,
|
|
2458
|
+
_ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
|
|
2459
|
+
onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? neetoCist.noop : _ref$onApplyThemeSucc,
|
|
2460
|
+
_ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
|
|
2461
|
+
onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? neetoCist.noop : _ref$onUpdateThemeSuc,
|
|
2462
|
+
_ref$helpPopoverProps = _ref.helpPopoverProps,
|
|
2463
|
+
helpPopoverProps = _ref$helpPopoverProps === void 0 ? {} : _ref$helpPopoverProps,
|
|
2464
|
+
_ref$enabledFeatures = _ref.enabledFeatures,
|
|
2465
|
+
enabledFeatures = _ref$enabledFeatures === void 0 ? {
|
|
2466
|
+
customCSS: true
|
|
2467
|
+
} : _ref$enabledFeatures,
|
|
2468
|
+
_ref$proFeatures = _ref.proFeatures,
|
|
2469
|
+
proFeatures = _ref$proFeatures === void 0 ? {} : _ref$proFeatures;
|
|
2470
|
+
react.useMemo(useGlobalThemesApi.registerNeetoThemesTranslations, []);
|
|
2471
|
+
var _useThemeStore = useExpandedSection.useThemeStore(function (store) {
|
|
2472
|
+
return {
|
|
2473
|
+
setThemeState: store["setThemeState"]
|
|
2474
|
+
};
|
|
2475
|
+
}, shallow.shallow),
|
|
2476
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
2477
|
+
var _useThemeUtils = useExpandedSection.useThemeUtils(),
|
|
2478
|
+
setTheme = _useThemeUtils.setTheme;
|
|
2479
|
+
var _useConfigStore = useExpandedSection.useConfigStore(function (store) {
|
|
2480
|
+
return {
|
|
2481
|
+
setConfigState: store["setConfigState"]
|
|
2482
|
+
};
|
|
2483
|
+
}, shallow.shallow),
|
|
2484
|
+
setConfigState = _useConfigStore.setConfigState;
|
|
2485
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
2486
|
+
t = _useTranslation.t;
|
|
2487
|
+
var _useShowThemeEntity = useGlobalThemesApi.useShowThemeEntity(entityId),
|
|
2488
|
+
_useShowThemeEntity$d = _useShowThemeEntity.data,
|
|
2489
|
+
_useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
|
|
2490
|
+
_useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
|
|
2491
|
+
currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
|
|
2492
|
+
isLoading = _useShowThemeEntity.isLoading,
|
|
2493
|
+
isFetchingCurrentTheme = _useShowThemeEntity.isFetching;
|
|
2494
|
+
var isCurrentThemeLoading = isLoading || isFetchingCurrentTheme;
|
|
2495
|
+
react.useEffect(function () {
|
|
2496
|
+
setConfigState({
|
|
2497
|
+
entityType: entityType,
|
|
2498
|
+
entityId: entityId,
|
|
2499
|
+
isTemplateThemesEnabled: isTemplateThemesEnabled,
|
|
2500
|
+
helpDocUrl: helpDocUrl,
|
|
2501
|
+
helpPopoverProps: helpPopoverProps,
|
|
2502
|
+
enabledFeatures: enabledFeatures,
|
|
2503
|
+
proFeatures: proFeatures
|
|
2504
|
+
});
|
|
2505
|
+
}, []);
|
|
2506
|
+
react.useEffect(function () {
|
|
2507
|
+
if (neetoCist.isNotPresent(currentTheme) || utils.isEditThemeRoute()) {
|
|
2508
|
+
return;
|
|
2509
|
+
}
|
|
2510
|
+
setThemeState({
|
|
2511
|
+
previewingTheme: currentTheme
|
|
2512
|
+
});
|
|
2513
|
+
setTheme(currentTheme);
|
|
2514
|
+
}, [isLoading, entityId, currentTheme]);
|
|
2515
|
+
react.useEffect(function () {
|
|
2516
|
+
if (neetoCist.isNotPresent(currentTheme)) return;
|
|
2517
|
+
setThemeState({
|
|
2518
|
+
currentTheme: currentTheme,
|
|
2519
|
+
isCurrentThemeLoading: isCurrentThemeLoading
|
|
2520
|
+
});
|
|
2521
|
+
}, [currentTheme, isCurrentThemeLoading]);
|
|
2522
|
+
react.useEffect(function () {
|
|
2523
|
+
var setViewportHeight = function setViewportHeight() {
|
|
2524
|
+
document.documentElement.style.setProperty("--viewport-height", "".concat(window.innerHeight, "px"));
|
|
2525
|
+
};
|
|
2526
|
+
setViewportHeight();
|
|
2527
|
+
window.addEventListener("load", setViewportHeight);
|
|
2528
|
+
window.addEventListener("resize", setViewportHeight);
|
|
2529
|
+
window.addEventListener("orientationchange", setViewportHeight);
|
|
2530
|
+
window.addEventListener("scroll", setViewportHeight);
|
|
2531
|
+
return function () {
|
|
2532
|
+
window.removeEventListener("load", setViewportHeight);
|
|
2533
|
+
window.removeEventListener("resize", setViewportHeight);
|
|
2534
|
+
window.removeEventListener("orientationchange", setViewportHeight);
|
|
2535
|
+
window.removeEventListener("scroll", setViewportHeight);
|
|
2536
|
+
};
|
|
2537
|
+
}, []);
|
|
2538
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
2539
|
+
className: "neeto-themes__wrapper",
|
|
2540
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(reactUtils.PageTitle, {
|
|
2541
|
+
title: pageTitle || t("neetoThemes.common.theme")
|
|
2542
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Sidebar, {
|
|
2543
|
+
defaultImageSize: defaultImageSize,
|
|
2544
|
+
fixedAspectRatio: fixedAspectRatio,
|
|
2545
|
+
onApplyThemeSuccess: onApplyThemeSuccess,
|
|
2546
|
+
onPropertiesChange: onPropertiesChange,
|
|
2547
|
+
onUpdateThemeSuccess: onUpdateThemeSuccess,
|
|
2548
|
+
thumbnail: thumbnail
|
|
2549
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2550
|
+
className: "neeto-themes-preview__wrapper",
|
|
2551
|
+
children: isCurrentThemeLoading ? /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2552
|
+
className: "m-auto flex h-full w-full items-center justify-center",
|
|
2553
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Spinner, {})
|
|
2554
|
+
}) : children
|
|
2555
|
+
})]
|
|
2556
|
+
});
|
|
2557
|
+
};
|
|
2558
|
+
|
|
2559
|
+
module.exports = NeetoThemesBuilder;
|
|
68
2560
|
//# sourceMappingURL=NeetoThemesBuilder.js.map
|