@bigbinary/neeto-themes-frontend 4.0.24 → 4.0.26

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