@bigbinary/neeto-themes-frontend 4.0.25 → 4.0.27

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