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