@bigbinary/neeto-themes-frontend 4.0.25 → 4.0.27

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