@bigbinary/neeto-themes-frontend 4.0.25 → 4.0.26

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