@bigbinary/neeto-themes-frontend 2.1.1 → 2.1.2
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.
- package/README.md +74 -36
- package/app/javascript/src/translations/en.json +5 -1
- package/dist/NeetoThemesBuilder.js +1894 -0
- package/dist/NeetoThemesBuilder.js.map +1 -0
- package/dist/{index.cjs.js → cjs/NeetoThemesBuilder.js} +407 -507
- package/dist/cjs/NeetoThemesBuilder.js.map +1 -0
- package/dist/cjs/hooks.js +22 -0
- package/dist/cjs/hooks.js.map +1 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/utils.js +17 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/hooks.js +14 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index-09d44807.js +174 -0
- package/dist/index-09d44807.js.map +1 -0
- package/dist/index-383fae09.js +159 -0
- package/dist/index-383fae09.js.map +1 -0
- package/dist/index.js +45 -1990
- package/dist/index.js.map +1 -1
- package/dist/useThemeUtils-148b9f27.js +111 -0
- package/dist/useThemeUtils-148b9f27.js.map +1 -0
- package/dist/useThemeUtils-3875c1d1.js +102 -0
- package/dist/useThemeUtils-3875c1d1.js.map +1 -0
- package/dist/utils.js +6 -0
- package/dist/utils.js.map +1 -0
- package/package.json +22 -9
- package/dist/index.cjs.js.map +0 -1
|
@@ -0,0 +1,1894 @@
|
|
|
1
|
+
import { shallow } from 'zustand/shallow';
|
|
2
|
+
import { createElement, useEffect, useState, useRef, memo, useCallback } from 'react';
|
|
3
|
+
import { t as t$1 } from 'i18next';
|
|
4
|
+
import { hyphenate, findBy, findIndexBy, isPresent, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
|
|
5
|
+
import { useMutationWithInvalidation, withT, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
6
|
+
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
7
|
+
import { useQuery } from '@tanstack/react-query';
|
|
8
|
+
import axios from 'axios';
|
|
9
|
+
import { B as BASE_URL, a as scrollElementIntoView, b as setCustomCSS, g as getDominantColorFromUrl, i as isFunction } from './index-383fae09.js';
|
|
10
|
+
import { Q as QUERY_KEYS, a as useConfigStore, b as useThemeStore, u as useThemeUtils } from './useThemeUtils-3875c1d1.js';
|
|
11
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
12
|
+
import classNames from 'classnames';
|
|
13
|
+
import Alert from '@bigbinary/neetoui/Alert';
|
|
14
|
+
import { useTranslation, Trans } from 'react-i18next';
|
|
15
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
16
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
17
|
+
import Close from '@bigbinary/neeto-icons/Close';
|
|
18
|
+
import Button from '@bigbinary/neetoui/Button';
|
|
19
|
+
import Popover from '@bigbinary/neetoui/Popover';
|
|
20
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
21
|
+
import Form from '@bigbinary/neetoui/formik/Form';
|
|
22
|
+
import * as yup from 'yup';
|
|
23
|
+
import Editor from '@monaco-editor/react';
|
|
24
|
+
import { useFormikContext, Field } from 'formik';
|
|
25
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
26
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
27
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
28
|
+
import { ImageUploader } from '@bigbinary/neeto-image-uploader-frontend';
|
|
29
|
+
import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
|
|
30
|
+
import Toastr from '@bigbinary/neetoui/Toastr';
|
|
31
|
+
import { isEmpty, negate } from 'ramda';
|
|
32
|
+
import Select from '@bigbinary/neetoui/Select';
|
|
33
|
+
import CenterAlign from '@bigbinary/neeto-icons/CenterAlign';
|
|
34
|
+
import LeftAlign from '@bigbinary/neeto-icons/LeftAlign';
|
|
35
|
+
import ColorPicker from '@bigbinary/neetoui/ColorPicker';
|
|
36
|
+
import { Slider } from 'antd';
|
|
37
|
+
import HelpPopover from '@bigbinary/neeto-molecules/HelpPopover';
|
|
38
|
+
import Switch from '@bigbinary/neetoui/Switch';
|
|
39
|
+
import Input from '@bigbinary/neetoui/formik/Input';
|
|
40
|
+
import Search from '@bigbinary/neeto-molecules/Search';
|
|
41
|
+
import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
42
|
+
import LeftArrow from '@bigbinary/neeto-icons/LeftArrow';
|
|
43
|
+
import Plus from '@bigbinary/neeto-icons/Plus';
|
|
44
|
+
import 'zustand';
|
|
45
|
+
|
|
46
|
+
var show$1 = function show(entityId) {
|
|
47
|
+
return axios.get("".concat(BASE_URL, "/api/v1/entities/").concat(entityId));
|
|
48
|
+
};
|
|
49
|
+
var entitiesApi = {
|
|
50
|
+
show: show$1
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var useShowThemeEntity = function useShowThemeEntity(entityId) {
|
|
54
|
+
return useQuery({
|
|
55
|
+
queryKey: [QUERY_KEYS.THEME_ENTITY_DETAILS, entityId],
|
|
56
|
+
queryFn: function queryFn() {
|
|
57
|
+
return entitiesApi.show(entityId);
|
|
58
|
+
},
|
|
59
|
+
enabled: !!entityId
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
64
|
+
|
|
65
|
+
var css = ".neeto-themes__wrapper{display:flex;width:100%}.neeto-themes__wrapper .neeto-themes-sidebar{background-color:rgb(var(--neeto-ui-white));height:calc(100vh - 64px);width:280px}@media (min-width:1024px){.neeto-themes__wrapper .neeto-themes-sidebar{width:320px}}@media (min-width:1280px){.neeto-themes__wrapper .neeto-themes-sidebar{width:340px}.neeto-themes__wrapper .neeto-themes-sidebar--expanded{max-width:50%;width:520px}}.neeto-themes__wrapper .neeto-themes-sidebar .neeto-themes-sidebar__header{padding-bottom:8px;padding-top:16px}.neeto-themes__wrapper .neeto-themes-sidebar .neeto-themes-sidebar__scroll{display:flex;flex-direction:column;height:calc(100vh - 120px);overflow-y:auto}.neeto-themes__wrapper .neeto-themes-sidebar .neeto-themes-sidebar__scroll .neeto-ui-colorpicker__target .neeto-ui-colorpicker-target__code{display:none}.neeto-themes__wrapper .neeto-themes-sidebar .neeto-ui-colorpicker__target-size--medium{--neeto-ui-colorpicker-target-padding:6px}.neeto-themes__wrapper .neeto-themes-sidebar .neeto-ui-colorpicker__target-size--medium .neeto-ui-colorpicker-target__color{border-radius:0!important;height:20px;width:20px}.neeto-themes__wrapper .css-editor-height__expanded{height:calc(100vh - 300px)}.neeto-themes__wrapper .css-editor-height__regular{height:384px}.neeto-themes__wrapper .neeto-themes-preview__wrapper{flex-grow:1;height:calc(100vh - 64px);position:relative}.neeto-themes-theme-thumbnail--preview-active{border-color:rgb(var(--neeto-ui-gray-600))!important;outline:1px solid rgb(var(--neeto-ui-gray-600))!important}.neeto-themes-theme-thumbnail--active{border-color:rgb(var(--neeto-ui-primary-500))!important;outline:2px solid rgb(var(--neeto-ui-primary-500))!important}.neeto-themes-theme-thumbnail--highlight-active{border-color:rgb(var(--neeto-ui-gray-400))!important;outline:2px solid rgb(var(--neeto-ui-gray-400))!important}.neeto-themes-theme-thumbnail__apply-btn{--neeto-ui-btn-padding-x:12px;--neeto-ui-btn-border-radius:100px}.neeto-themes-theme-thumbnail__apply-btn:disabled,.neeto-themes-theme-thumbnail__apply-btn[disabled]{opacity:1!important}.neeto-themes-sidebar__custom-css-editor-header{background-color:#1e1e1e;border-top-left-radius:var(--neeto-ui-rounded-lg);border-top-right-radius:var(--neeto-ui-rounded-lg)}.neeto-themes-sidebar .monaco-editor,.neeto-themes-sidebar .overflow-guard{border-bottom-left-radius:var(--neeto-ui-rounded-lg);border-bottom-right-radius:var(--neeto-ui-rounded-lg)}.neeto-themes-sidebar__custom-css-wrapper .neeto-themes-nano-section{border-bottom:0!important}\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFwcC9qYXZhc2NyaXB0L3N0eWxlc2hlZXRzL2NvbXBvbmVudHMvdGhlbWVzLnNjc3MiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsdUJBRUUsWUFBQSxDQURBLFVBQUYsQ0FHRSw2Q0FHRSwyQ0FBQSxDQURBLHlCQUFBLENBREEsV0FDSixDQUdJLDBCQUxGLDZDQU1JLFdBQUosQ0FDRixDQUNJLDBCQVJGLDZDQVNJLFdBRUosQ0FBSSx1REFFRSxhQUFBLENBREEsV0FHTixDQUNGLENBQ0ksMkVBRUUsa0JBQUEsQ0FEQSxnQkFFTixDQUVJLDJFQUdFLFlBQUEsQ0FDQSxxQkFBQSxDQUhBLDBCQUFBLENBQ0EsZUFFTixDQUdRLDRJQUNFLFlBRFYsQ0FLSSx3RkFDRSx5Q0FITixDQUlNLDRIQUdFLHlCQUFBLENBRkEsV0FBQSxDQUNBLFVBRFIsQ0FPRSxvREFDRSwwQkFMSixDQVFFLG1EQUNFLFlBTkosQ0FTRSxzREFHRSxXQUFBLENBREEseUJBQUEsQ0FEQSxpQkFMSixDQVdBLDhDQUNFLG9EQUFBLENBQ0EseURBUkYsQ0FXQSxzQ0FDRSx1REFBQSxDQUNBLDREQVJGLENBV0EsZ0RBQ0Usb0RBQUEsQ0FDQSx5REFSRixDQVdBLHlDQUNFLDZCQUFBLENBQ0Esa0NBUkYsQ0FTRSxxR0FFRSxtQkFSSixDQVlBLGdEQUNFLHdCQUFBLENBQ0EsaURBQUEsQ0FDQSxrREFURixDQWFFLDJFQUVFLG9EQUFBLENBQ0EscURBVkosQ0FlRSxxRUFDRSx5QkFaSiIsInNvdXJjZXNDb250ZW50IjpbIkBpbXBvcnQgXCIuLi9hYnN0cmFjdHMvdmFyaWFibGVzXCI7XG5cbi5uZWV0by10aGVtZXNfX3dyYXBwZXIge1xuICB3aWR0aDogMTAwJTtcbiAgZGlzcGxheTogZmxleDtcblxuICAubmVldG8tdGhlbWVzLXNpZGViYXIge1xuICAgIHdpZHRoOiAkdGhlbWVzLXNpZGViYXItd2lkdGgtc207XG4gICAgaGVpZ2h0OiBjYWxjKDEwMHZoIC0gI3skYnVpbGRlci1oZWFkZXItaGVpZ2h0fSk7XG4gICAgYmFja2dyb3VuZC1jb2xvcjogcmdiKHZhcigtLW5lZXRvLXVpLXdoaXRlKSk7XG5cbiAgICBAc2NyZWVuIGxnIHtcbiAgICAgIHdpZHRoOiAkdGhlbWVzLXNpZGViYXItd2lkdGgtbGc7XG4gICAgfVxuICAgIEBzY3JlZW4geGwge1xuICAgICAgd2lkdGg6ICR0aGVtZXMtc2lkZWJhci13aWR0aC14bDtcblxuICAgICAgJi0tZXhwYW5kZWQge1xuICAgICAgICB3aWR0aDogJHRoZW1lcy1zaWRlYmFyLWV4cGFuZGVkO1xuICAgICAgICBtYXgtd2lkdGg6IDUwJTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICAubmVldG8tdGhlbWVzLXNpZGViYXJfX2hlYWRlciB7XG4gICAgICBwYWRkaW5nLXRvcDogMTZweDtcbiAgICAgIHBhZGRpbmctYm90dG9tOiA4cHg7XG4gICAgfVxuXG4gICAgLm5lZXRvLXRoZW1lcy1zaWRlYmFyX19zY3JvbGwge1xuICAgICAgaGVpZ2h0OiBjYWxjKDEwMHZoIC0gMTIwcHgpO1xuICAgICAgb3ZlcmZsb3cteTogYXV0bztcbiAgICAgIGRpc3BsYXk6IGZsZXg7XG4gICAgICBmbGV4LWRpcmVjdGlvbjogY29sdW1uO1xuXG4gICAgICAubmVldG8tdWktY29sb3JwaWNrZXJfX3RhcmdldCB7XG4gICAgICAgIC5uZWV0by11aS1jb2xvcnBpY2tlci10YXJnZXRfX2NvZGUge1xuICAgICAgICAgIGRpc3BsYXk6IG5vbmU7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG4gICAgLm5lZXRvLXVpLWNvbG9ycGlja2VyX190YXJnZXQtc2l6ZS0tbWVkaXVtIHtcbiAgICAgIC0tbmVldG8tdWktY29sb3JwaWNrZXItdGFyZ2V0LXBhZGRpbmc6IDZweDtcbiAgICAgIC5uZWV0by11aS1jb2xvcnBpY2tlci10YXJnZXRfX2NvbG9yIHtcbiAgICAgICAgaGVpZ2h0OiAyMHB4O1xuICAgICAgICB3aWR0aDogMjBweDtcbiAgICAgICAgYm9yZGVyLXJhZGl1czogMCAhaW1wb3J0YW50O1xuICAgICAgfVxuICAgIH1cbiAgfVxuXG4gIC5jc3MtZWRpdG9yLWhlaWdodF9fZXhwYW5kZWQge1xuICAgIGhlaWdodDogY2FsYygxMDB2aCAtIDMwMHB4KTtcbiAgfVxuXG4gIC5jc3MtZWRpdG9yLWhlaWdodF9fcmVndWxhciB7XG4gICAgaGVpZ2h0OiAzODRweDtcbiAgfVxuXG4gIC5uZWV0by10aGVtZXMtcHJldmlld19fd3JhcHBlciB7XG4gICAgcG9zaXRpb246IHJlbGF0aXZlO1xuICAgIGhlaWdodDogY2FsYygxMDB2aCAtICN7JGJ1aWxkZXItaGVhZGVyLWhlaWdodH0pO1xuICAgIGZsZXgtZ3JvdzogMTtcbiAgfVxufVxuXG4ubmVldG8tdGhlbWVzLXRoZW1lLXRodW1ibmFpbC0tcHJldmlldy1hY3RpdmUge1xuICBib3JkZXItY29sb3I6IHJnYih2YXIoLS1uZWV0by11aS1ncmF5LTYwMCkpICFpbXBvcnRhbnQ7XG4gIG91dGxpbmU6IDFweCBzb2xpZCByZ2IodmFyKC0tbmVldG8tdWktZ3JheS02MDApKSAhaW1wb3J0YW50O1xufVxuXG4ubmVldG8tdGhlbWVzLXRoZW1lLXRodW1ibmFpbC0tYWN0aXZlIHtcbiAgYm9yZGVyLWNvbG9yOiByZ2IodmFyKC0tbmVldG8tdWktcHJpbWFyeS01MDApKSAhaW1wb3J0YW50O1xuICBvdXRsaW5lOiAycHggc29saWQgcmdiKHZhcigtLW5lZXRvLXVpLXByaW1hcnktNTAwKSkgIWltcG9ydGFudDtcbn1cblxuLm5lZXRvLXRoZW1lcy10aGVtZS10aHVtYm5haWwtLWhpZ2hsaWdodC1hY3RpdmUge1xuICBib3JkZXItY29sb3I6IHJnYih2YXIoLS1uZWV0by11aS1ncmF5LTQwMCkpICFpbXBvcnRhbnQ7XG4gIG91dGxpbmU6IDJweCBzb2xpZCByZ2IodmFyKC0tbmVldG8tdWktZ3JheS00MDApKSAhaW1wb3J0YW50O1xufVxuXG4ubmVldG8tdGhlbWVzLXRoZW1lLXRodW1ibmFpbF9fYXBwbHktYnRuIHtcbiAgLS1uZWV0by11aS1idG4tcGFkZGluZy14OiAxMnB4O1xuICAtLW5lZXRvLXVpLWJ0bi1ib3JkZXItcmFkaXVzOiAxMDBweDtcbiAgJjpkaXNhYmxlZCxcbiAgJltkaXNhYmxlZF0ge1xuICAgIG9wYWNpdHk6IDEgIWltcG9ydGFudDtcbiAgfVxufVxuXG4ubmVldG8tdGhlbWVzLXNpZGViYXJfX2N1c3RvbS1jc3MtZWRpdG9yLWhlYWRlciB7XG4gIGJhY2tncm91bmQtY29sb3I6ICMxZTFlMWU7XG4gIGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IHZhcigtLW5lZXRvLXVpLXJvdW5kZWQtbGcpO1xuICBib3JkZXItdG9wLXJpZ2h0LXJhZGl1czogdmFyKC0tbmVldG8tdWktcm91bmRlZC1sZyk7XG59XG5cbi5uZWV0by10aGVtZXMtc2lkZWJhciB7XG4gIC5vdmVyZmxvdy1ndWFyZCxcbiAgLm1vbmFjby1lZGl0b3Ige1xuICAgIGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IHZhcigtLW5lZXRvLXVpLXJvdW5kZWQtbGcpO1xuICAgIGJvcmRlci1ib3R0b20tcmlnaHQtcmFkaXVzOiB2YXIoLS1uZWV0by11aS1yb3VuZGVkLWxnKTtcbiAgfVxufVxuXG4ubmVldG8tdGhlbWVzLXNpZGViYXJfX2N1c3RvbS1jc3Mtd3JhcHBlciB7XG4gIC5uZWV0by10aGVtZXMtbmFuby1zZWN0aW9uIHtcbiAgICBib3JkZXItYm90dG9tOiAwICFpbXBvcnRhbnQ7XG4gIH1cbn1cbiJdfQ== */";
|
|
66
|
+
n(css,{});
|
|
67
|
+
|
|
68
|
+
var _excluded$1 = ["themeId"];
|
|
69
|
+
var list = function list(entityId) {
|
|
70
|
+
return axios.get("".concat(BASE_URL, "/api/v1/themes"), {
|
|
71
|
+
params: {
|
|
72
|
+
entity_id: entityId
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
var show = function show(id) {
|
|
77
|
+
return axios.get("".concat(BASE_URL, "/api/v1/themes/").concat(id));
|
|
78
|
+
};
|
|
79
|
+
var create = function create(payload) {
|
|
80
|
+
return axios.post("".concat(BASE_URL, "/api/v1/themes"), {
|
|
81
|
+
theme: payload
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
var update = function update(_ref) {
|
|
85
|
+
var id = _ref.id,
|
|
86
|
+
payload = _ref.payload;
|
|
87
|
+
return axios.put("".concat(BASE_URL, "/api/v1/themes/").concat(id), {
|
|
88
|
+
theme: payload
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
var destroy = function destroy(id) {
|
|
92
|
+
return axios["delete"]("".concat(BASE_URL, "/api/v1/themes/").concat(id));
|
|
93
|
+
};
|
|
94
|
+
var clone = function clone(id) {
|
|
95
|
+
return axios.post("".concat(BASE_URL, "/api/v1/themes/").concat(id, "/clone"));
|
|
96
|
+
};
|
|
97
|
+
var apply = function apply(_ref2) {
|
|
98
|
+
var themeId = _ref2.themeId,
|
|
99
|
+
payload = _objectWithoutProperties(_ref2, _excluded$1);
|
|
100
|
+
return axios.post("".concat(BASE_URL, "/api/v1/themes/").concat(themeId, "/apply"), {
|
|
101
|
+
entity: payload
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
var themesApi = {
|
|
105
|
+
list: list,
|
|
106
|
+
show: show,
|
|
107
|
+
create: create,
|
|
108
|
+
update: update,
|
|
109
|
+
destroy: destroy,
|
|
110
|
+
clone: clone,
|
|
111
|
+
apply: apply
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
var useListThemes = function useListThemes(entityId) {
|
|
115
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
116
|
+
return {
|
|
117
|
+
isTemplateThemesEnabled: store["isTemplateThemesEnabled"]
|
|
118
|
+
};
|
|
119
|
+
}, shallow),
|
|
120
|
+
isTemplateThemesEnabled = _useConfigStore.isTemplateThemesEnabled;
|
|
121
|
+
var queryKey = isTemplateThemesEnabled ? [QUERY_KEYS.THEMES_LIST, entityId] : [QUERY_KEYS.THEMES_LIST];
|
|
122
|
+
return useQuery({
|
|
123
|
+
queryKey: queryKey,
|
|
124
|
+
queryFn: function queryFn() {
|
|
125
|
+
return themesApi.list(entityId);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
var useCreateTheme = function useCreateTheme() {
|
|
130
|
+
return useMutationWithInvalidation(themesApi.create, {
|
|
131
|
+
keysToInvalidate: [QUERY_KEYS.THEMES_LIST]
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
var useUpdateTheme = function useUpdateTheme(themeId) {
|
|
135
|
+
return useMutationWithInvalidation(function (payload) {
|
|
136
|
+
return themesApi.update({
|
|
137
|
+
id: themeId,
|
|
138
|
+
payload: payload
|
|
139
|
+
});
|
|
140
|
+
}, {
|
|
141
|
+
keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.THEME_DETAILS, themeId]]
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
var useDeleteTheme = function useDeleteTheme() {
|
|
145
|
+
return useMutationWithInvalidation(themesApi.destroy, {
|
|
146
|
+
keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS]]
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
var useCloneTheme = function useCloneTheme() {
|
|
150
|
+
return useMutationWithInvalidation(themesApi.clone, {
|
|
151
|
+
keysToInvalidate: [QUERY_KEYS.THEMES_LIST]
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
var useApplyTheme = function useApplyTheme(_ref) {
|
|
155
|
+
var onSuccess = _ref.onSuccess;
|
|
156
|
+
return useMutationWithInvalidation(themesApi.apply, {
|
|
157
|
+
keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS]],
|
|
158
|
+
onSuccess: onSuccess
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
var POSITION_OPTIONS = [{
|
|
163
|
+
label: "Left",
|
|
164
|
+
value: "left"
|
|
165
|
+
}, {
|
|
166
|
+
label: "Right",
|
|
167
|
+
value: "right"
|
|
168
|
+
}];
|
|
169
|
+
var FONT_OPTIONS = [{
|
|
170
|
+
label: "System UI",
|
|
171
|
+
value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
|
|
172
|
+
}, {
|
|
173
|
+
label: "Cedarville Cursive",
|
|
174
|
+
value: "'Cedarville Cursive', cursive"
|
|
175
|
+
}, {
|
|
176
|
+
label: "Poppins",
|
|
177
|
+
value: "Poppins, sans-serif"
|
|
178
|
+
}, {
|
|
179
|
+
label: "Roboto",
|
|
180
|
+
value: "Roboto, sans-serif"
|
|
181
|
+
}, {
|
|
182
|
+
label: "Open Sans",
|
|
183
|
+
value: "Open Sans, sans-serif"
|
|
184
|
+
}, {
|
|
185
|
+
label: "Montserrat",
|
|
186
|
+
value: "Montserrat, sans-serif"
|
|
187
|
+
}, {
|
|
188
|
+
label: "Raleway",
|
|
189
|
+
value: "Raleway, sans-serif"
|
|
190
|
+
}, {
|
|
191
|
+
label: "Quicksand",
|
|
192
|
+
value: "Quicksand, sans-serif"
|
|
193
|
+
}, {
|
|
194
|
+
label: "Inter",
|
|
195
|
+
value: "Inter, sans-serif"
|
|
196
|
+
}, {
|
|
197
|
+
label: "Satoshi",
|
|
198
|
+
value: "Satoshi, sans-serif"
|
|
199
|
+
}, {
|
|
200
|
+
label: "Chillax",
|
|
201
|
+
value: "Chillax, sans-serif"
|
|
202
|
+
}, {
|
|
203
|
+
label: "Clash Display",
|
|
204
|
+
value: "Clash Display, sans-serif"
|
|
205
|
+
}, {
|
|
206
|
+
label: "General Sans",
|
|
207
|
+
value: "General Sans, sans-serif"
|
|
208
|
+
}, {
|
|
209
|
+
label: "Cabinet Grotesk",
|
|
210
|
+
value: "Cabinet Grotesk, sans-serif"
|
|
211
|
+
}, {
|
|
212
|
+
label: "Lora",
|
|
213
|
+
value: "Lora, serif"
|
|
214
|
+
}, {
|
|
215
|
+
label: "Merriweather",
|
|
216
|
+
value: "Merriweather, serif"
|
|
217
|
+
}, {
|
|
218
|
+
label: "Boska",
|
|
219
|
+
value: "Boska, serif"
|
|
220
|
+
}, {
|
|
221
|
+
label: "Playfair Display",
|
|
222
|
+
value: "Playfair Display, serif"
|
|
223
|
+
}, {
|
|
224
|
+
label: "Roboto Slab",
|
|
225
|
+
value: "Roboto Slab, serif"
|
|
226
|
+
}, {
|
|
227
|
+
label: "Dancing Script",
|
|
228
|
+
value: "Dancing Script, cursive"
|
|
229
|
+
}];
|
|
230
|
+
var THEME_VALIDATION_SCHEMA = yup.object().shape({
|
|
231
|
+
name: yup.string().required("Name is required")
|
|
232
|
+
});
|
|
233
|
+
var OVERLAY_OPACITY_SLIDER_MARKS = {
|
|
234
|
+
0: " "
|
|
235
|
+
};
|
|
236
|
+
var HUNDRED = 100;
|
|
237
|
+
|
|
238
|
+
var DESIGN_SCREENS = {
|
|
239
|
+
THEMES: "Themes",
|
|
240
|
+
Customize: "Customize",
|
|
241
|
+
CustomCSS: "CustomCSS"
|
|
242
|
+
};
|
|
243
|
+
var ONE_MEGABYTE = 1;
|
|
244
|
+
|
|
245
|
+
var Card$2 = function Card(_ref) {
|
|
246
|
+
var _ref$title = _ref.title,
|
|
247
|
+
title = _ref$title === void 0 ? "" : _ref$title,
|
|
248
|
+
children = _ref.children;
|
|
249
|
+
return /*#__PURE__*/jsxs("div", {
|
|
250
|
+
className: "neeto-themes-nano-section neeto-ui-border-gray-200 mb-4 space-y-3 border-b pb-4",
|
|
251
|
+
"data-cy": "theme-".concat(hyphenate(title), "-properties"),
|
|
252
|
+
children: [title && /*#__PURE__*/jsx("div", {
|
|
253
|
+
className: "neeto-themes-nano-section__title flex items-center justify-between",
|
|
254
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
255
|
+
className: "min-w-0 flex-grow",
|
|
256
|
+
"data-cy": "theme-properties",
|
|
257
|
+
lineHeight: "normal",
|
|
258
|
+
style: "h4",
|
|
259
|
+
weight: "semibold",
|
|
260
|
+
children: title
|
|
261
|
+
})
|
|
262
|
+
}), children && /*#__PURE__*/jsx("div", {
|
|
263
|
+
className: "neeto-themes-nano-section__content w-full",
|
|
264
|
+
children: children
|
|
265
|
+
})]
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
var isScreenCustomCSS = function isScreenCustomCSS(screen) {
|
|
270
|
+
return screen === DESIGN_SCREENS.CustomCSS;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
var CustomCSS = function CustomCSS(_ref) {
|
|
274
|
+
var onEditCSSClick = _ref.onEditCSSClick,
|
|
275
|
+
currentScreen = _ref.currentScreen;
|
|
276
|
+
var _useTranslation = useTranslation(),
|
|
277
|
+
t = _useTranslation.t;
|
|
278
|
+
var _useFormikContext = useFormikContext(),
|
|
279
|
+
values = _useFormikContext.values,
|
|
280
|
+
setFieldValue = _useFormikContext.setFieldValue;
|
|
281
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
282
|
+
return {
|
|
283
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
284
|
+
};
|
|
285
|
+
}, shallow),
|
|
286
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
287
|
+
var customCSS = findBy({
|
|
288
|
+
kind: "custom_css"
|
|
289
|
+
}, values.properties);
|
|
290
|
+
if (!customCSS) return null;
|
|
291
|
+
var parentElementClass = findBy({
|
|
292
|
+
kind: "custom_css"
|
|
293
|
+
}, themePropertiesSchema).parentClass;
|
|
294
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
295
|
+
var handleEditorToggle = function handleEditorToggle() {
|
|
296
|
+
if (!isCustomCssScreen) return onEditCSSClick(DESIGN_SCREENS.CustomCSS);
|
|
297
|
+
onEditCSSClick(DESIGN_SCREENS.Customize);
|
|
298
|
+
return setTimeout(function () {
|
|
299
|
+
scrollElementIntoView("css-editor");
|
|
300
|
+
}, 400);
|
|
301
|
+
};
|
|
302
|
+
var handleChange = function handleChange(value) {
|
|
303
|
+
var index = findIndexBy({
|
|
304
|
+
key: customCSS.key
|
|
305
|
+
}, values.properties);
|
|
306
|
+
if (index !== -1 && values.properties[index].value !== value) {
|
|
307
|
+
setFieldValue("properties[".concat(index, "].value"), value);
|
|
308
|
+
setCustomCSS({
|
|
309
|
+
css: value,
|
|
310
|
+
elementId: customCSS.key,
|
|
311
|
+
parentElementClass: parentElementClass
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
return /*#__PURE__*/jsx("div", {
|
|
316
|
+
className: "neeto-themes-sidebar__custom-css-wrapper",
|
|
317
|
+
id: "css-editor",
|
|
318
|
+
children: /*#__PURE__*/jsxs(Card$2, {
|
|
319
|
+
title: isCustomCssScreen ? "" : t("neetoThemes.build.leftSideBar.themes.customCSS"),
|
|
320
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
321
|
+
className: "neeto-themes-sidebar__custom-css-editor-header flex w-full justify-end gap-1 rounded-b-none p-2",
|
|
322
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
323
|
+
size: "small",
|
|
324
|
+
style: "secondary",
|
|
325
|
+
label: isCustomCssScreen ? t("neetoThemes.buttons.minimizeEditor") : t("neetoThemes.buttons.expandEditor"),
|
|
326
|
+
onClick: handleEditorToggle
|
|
327
|
+
})
|
|
328
|
+
}), /*#__PURE__*/jsx(Editor, {
|
|
329
|
+
language: "css",
|
|
330
|
+
options: {
|
|
331
|
+
scrollBeyondLastLine: false,
|
|
332
|
+
minimap: {
|
|
333
|
+
enabled: false
|
|
334
|
+
}
|
|
335
|
+
},
|
|
336
|
+
theme: "vs-dark",
|
|
337
|
+
value: customCSS.value,
|
|
338
|
+
className: classNames({
|
|
339
|
+
rounded: true,
|
|
340
|
+
"css-editor-height__expanded": isCustomCssScreen,
|
|
341
|
+
"css-editor-height__regular": !isCustomCssScreen
|
|
342
|
+
}),
|
|
343
|
+
onChange: handleChange
|
|
344
|
+
})]
|
|
345
|
+
})
|
|
346
|
+
});
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
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; }
|
|
350
|
+
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), !0).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; }
|
|
351
|
+
var buildInitialValues = function buildInitialValues(theme, themePropertiesSchema) {
|
|
352
|
+
if (isPresent(theme)) return theme;
|
|
353
|
+
return {
|
|
354
|
+
name: t$1("neetoThemes.build.leftSideBar.themes.createTheme.newThemeName"),
|
|
355
|
+
properties: themePropertiesSchema.map(function (_ref) {
|
|
356
|
+
var key = _ref.key,
|
|
357
|
+
kind = _ref.kind,
|
|
358
|
+
defaultValue = _ref.defaultValue,
|
|
359
|
+
_ref$order = _ref.order,
|
|
360
|
+
order = _ref$order === void 0 ? null : _ref$order;
|
|
361
|
+
switch (kind) {
|
|
362
|
+
case "color":
|
|
363
|
+
return _objectSpread$4({
|
|
364
|
+
value: defaultValue,
|
|
365
|
+
kind: "color",
|
|
366
|
+
key: key
|
|
367
|
+
}, order !== null && {
|
|
368
|
+
order: order
|
|
369
|
+
});
|
|
370
|
+
case "font_family":
|
|
371
|
+
return _objectSpread$4({
|
|
372
|
+
value: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
|
|
373
|
+
kind: "font_family",
|
|
374
|
+
key: key
|
|
375
|
+
}, order !== null && {
|
|
376
|
+
order: order
|
|
377
|
+
});
|
|
378
|
+
case "overlay_opacity":
|
|
379
|
+
return _objectSpread$4({
|
|
380
|
+
value: 0,
|
|
381
|
+
kind: "overlay_opacity",
|
|
382
|
+
key: key
|
|
383
|
+
}, order !== null && {
|
|
384
|
+
order: order
|
|
385
|
+
});
|
|
386
|
+
case "slider":
|
|
387
|
+
return _objectSpread$4({
|
|
388
|
+
value: 0,
|
|
389
|
+
kind: "slider",
|
|
390
|
+
key: key
|
|
391
|
+
}, order !== null && {
|
|
392
|
+
order: order
|
|
393
|
+
});
|
|
394
|
+
case "radius":
|
|
395
|
+
return _objectSpread$4({
|
|
396
|
+
value: defaultValue,
|
|
397
|
+
kind: "radius",
|
|
398
|
+
key: key
|
|
399
|
+
}, order !== null && {
|
|
400
|
+
order: order
|
|
401
|
+
});
|
|
402
|
+
case "boolean":
|
|
403
|
+
return _objectSpread$4({
|
|
404
|
+
value: String(defaultValue),
|
|
405
|
+
kind: "boolean",
|
|
406
|
+
key: key
|
|
407
|
+
}, order !== null && {
|
|
408
|
+
order: order
|
|
409
|
+
});
|
|
410
|
+
case "order_selector":
|
|
411
|
+
return _objectSpread$4({
|
|
412
|
+
value: defaultValue,
|
|
413
|
+
kind: "order_selector",
|
|
414
|
+
key: key
|
|
415
|
+
}, order !== null && {
|
|
416
|
+
order: order
|
|
417
|
+
});
|
|
418
|
+
case "alignment_block":
|
|
419
|
+
return _objectSpread$4({
|
|
420
|
+
value: defaultValue,
|
|
421
|
+
kind: "alignment_block",
|
|
422
|
+
key: key
|
|
423
|
+
}, order !== null && {
|
|
424
|
+
order: order
|
|
425
|
+
});
|
|
426
|
+
case "custom_css":
|
|
427
|
+
return _objectSpread$4({
|
|
428
|
+
value: defaultValue,
|
|
429
|
+
kind: "custom_css",
|
|
430
|
+
key: key
|
|
431
|
+
}, order !== null && {
|
|
432
|
+
order: order
|
|
433
|
+
});
|
|
434
|
+
default:
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
}).filter(isNot(null))
|
|
438
|
+
};
|
|
439
|
+
};
|
|
440
|
+
var buildImageData = function buildImageData(values, themePropertiesSchema) {
|
|
441
|
+
return filterBy({
|
|
442
|
+
kind: "image"
|
|
443
|
+
}, themePropertiesSchema).reduce(function (acc, item) {
|
|
444
|
+
var _values$snakeToCamelC;
|
|
445
|
+
var signedId = (_values$snakeToCamelC = values[snakeToCamelCase(item.key)]) === null || _values$snakeToCamelC === void 0 ? void 0 : _values$snakeToCamelC.signedId;
|
|
446
|
+
acc[item.key] = signedId;
|
|
447
|
+
return acc;
|
|
448
|
+
}, {});
|
|
449
|
+
};
|
|
450
|
+
var isPropertyVisible = function isPropertyVisible(key, formikValues, themePropertiesSchema) {
|
|
451
|
+
var property = findBy({
|
|
452
|
+
key: key
|
|
453
|
+
}, themePropertiesSchema);
|
|
454
|
+
if (isNotPresent(property)) return false;
|
|
455
|
+
if (property !== null && property !== void 0 && property.hidden) return false;
|
|
456
|
+
var conditionalKey = property === null || property === void 0 ? void 0 : property.dependsOn;
|
|
457
|
+
if (isNotPresent(conditionalKey)) return true;
|
|
458
|
+
var dependentPropertySchema = findBy({
|
|
459
|
+
key: conditionalKey
|
|
460
|
+
}, themePropertiesSchema);
|
|
461
|
+
var dependentProperty = findBy({
|
|
462
|
+
key: conditionalKey
|
|
463
|
+
}, formikValues.properties);
|
|
464
|
+
if (dependentPropertySchema.kind === "image") {
|
|
465
|
+
var _formikValues$snakeTo;
|
|
466
|
+
return isPresent((_formikValues$snakeTo = formikValues[snakeToCamelCase(conditionalKey)]) === null || _formikValues$snakeTo === void 0 ? void 0 : _formikValues$snakeTo.url);
|
|
467
|
+
} else if (dependentPropertySchema.kind === "boolean") {
|
|
468
|
+
return (dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value) !== "false";
|
|
469
|
+
}
|
|
470
|
+
return isPresent(dependentProperty === null || dependentProperty === void 0 ? void 0 : dependentProperty.value);
|
|
471
|
+
};
|
|
472
|
+
var buildLabel = function buildLabel(key, kind) {
|
|
473
|
+
return t$1("neetoThemes.properties.".concat(snakeToCamelCase(kind), ".").concat(snakeToCamelCase(key)));
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
var SelectBlock = function SelectBlock(_ref) {
|
|
477
|
+
var label = _ref.label,
|
|
478
|
+
_ref$placeholder = _ref.placeholder,
|
|
479
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
480
|
+
value = _ref.value,
|
|
481
|
+
options = _ref.options,
|
|
482
|
+
onChange = _ref.onChange;
|
|
483
|
+
return /*#__PURE__*/jsxs("div", {
|
|
484
|
+
className: "flex items-center justify-between py-2 first:pt-0 last:pb-0",
|
|
485
|
+
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
486
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
487
|
+
"data-cy": "logo-field-labels",
|
|
488
|
+
style: "body2",
|
|
489
|
+
children: label
|
|
490
|
+
}), /*#__PURE__*/jsx("div", {
|
|
491
|
+
className: "w-40",
|
|
492
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
493
|
+
onChange: onChange,
|
|
494
|
+
options: options,
|
|
495
|
+
placeholder: placeholder,
|
|
496
|
+
value: value
|
|
497
|
+
})
|
|
498
|
+
})]
|
|
499
|
+
});
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
var ImageBlock = function ImageBlock(_ref) {
|
|
503
|
+
var _findBy;
|
|
504
|
+
var label = _ref.label,
|
|
505
|
+
name = _ref.name,
|
|
506
|
+
_ref$imageData = _ref.imageData,
|
|
507
|
+
imageData = _ref$imageData === void 0 ? {} : _ref$imageData,
|
|
508
|
+
_ref$uploadConfig = _ref.uploadConfig,
|
|
509
|
+
uploadConfig = _ref$uploadConfig === void 0 ? {
|
|
510
|
+
maxImageSize: ONE_MEGABYTE
|
|
511
|
+
} : _ref$uploadConfig,
|
|
512
|
+
attribute = _ref.attribute;
|
|
513
|
+
var _useTranslation = useTranslation(),
|
|
514
|
+
t = _useTranslation.t;
|
|
515
|
+
var _useFormikContext = useFormikContext(),
|
|
516
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
517
|
+
values = _useFormikContext.values;
|
|
518
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
519
|
+
return {
|
|
520
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
521
|
+
};
|
|
522
|
+
}, shallow),
|
|
523
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
524
|
+
var propertySchema = findBy({
|
|
525
|
+
key: attribute
|
|
526
|
+
}, themePropertiesSchema);
|
|
527
|
+
var enablePositionChanger = (propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.enablePositionChanger) || false;
|
|
528
|
+
var options = propertySchema === null || propertySchema === void 0 ? void 0 : propertySchema.options;
|
|
529
|
+
var positionKeyInSchema = findBy({
|
|
530
|
+
key: "".concat(name, "_position")
|
|
531
|
+
}, themePropertiesSchema);
|
|
532
|
+
var isPositionChangerVisible = enablePositionChanger && (imageData === null || imageData === void 0 ? void 0 : imageData.url) && isPresent(positionKeyInSchema);
|
|
533
|
+
var positionKeyIndex = findIndexBy({
|
|
534
|
+
key: "".concat(name, "_position")
|
|
535
|
+
}, values.properties);
|
|
536
|
+
var handleImageChange = /*#__PURE__*/function () {
|
|
537
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(image) {
|
|
538
|
+
var dominantColor;
|
|
539
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
540
|
+
while (1) switch (_context.prev = _context.next) {
|
|
541
|
+
case 0:
|
|
542
|
+
_context.prev = 0;
|
|
543
|
+
if (!(isEmpty(image.signedId) || isEmpty(image.url))) {
|
|
544
|
+
_context.next = 4;
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
setFieldValue(name, {
|
|
548
|
+
signedId: null,
|
|
549
|
+
url: image.url
|
|
550
|
+
});
|
|
551
|
+
return _context.abrupt("return");
|
|
552
|
+
case 4:
|
|
553
|
+
_context.next = 6;
|
|
554
|
+
return getDominantColorFromUrl(image.url);
|
|
555
|
+
case 6:
|
|
556
|
+
dominantColor = _context.sent;
|
|
557
|
+
setFieldValue(name, {
|
|
558
|
+
signedId: image.signedId,
|
|
559
|
+
url: image.url,
|
|
560
|
+
dominantColor: dominantColor
|
|
561
|
+
});
|
|
562
|
+
_context.next = 13;
|
|
563
|
+
break;
|
|
564
|
+
case 10:
|
|
565
|
+
_context.prev = 10;
|
|
566
|
+
_context.t0 = _context["catch"](0);
|
|
567
|
+
Toastr.error(_context.t0);
|
|
568
|
+
case 13:
|
|
569
|
+
case "end":
|
|
570
|
+
return _context.stop();
|
|
571
|
+
}
|
|
572
|
+
}, _callee, null, [[0, 10]]);
|
|
573
|
+
}));
|
|
574
|
+
return function handleImageChange(_x) {
|
|
575
|
+
return _ref2.apply(this, arguments);
|
|
576
|
+
};
|
|
577
|
+
}();
|
|
578
|
+
return /*#__PURE__*/jsxs("div", {
|
|
579
|
+
className: "space-y-3 py-3 first:pt-0 last:pb-0",
|
|
580
|
+
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
581
|
+
children: [label && /*#__PURE__*/jsx("div", {
|
|
582
|
+
className: "flex items-center justify-between",
|
|
583
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
584
|
+
"data-cy": "style-fields-labels",
|
|
585
|
+
style: "body2",
|
|
586
|
+
children: label
|
|
587
|
+
})
|
|
588
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
589
|
+
className: "space-y-3",
|
|
590
|
+
children: [/*#__PURE__*/createElement(ImageUploader, {
|
|
591
|
+
uploadConfig: uploadConfig,
|
|
592
|
+
className: "h-40 w-full",
|
|
593
|
+
key: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
594
|
+
src: imageData === null || imageData === void 0 ? void 0 : imageData.url,
|
|
595
|
+
onUploadComplete: handleImageChange
|
|
596
|
+
}), isPositionChangerVisible && /*#__PURE__*/jsx(SelectBlock, {
|
|
597
|
+
label: buildLabel("".concat(name, "Position"), "image"),
|
|
598
|
+
options: options || POSITION_OPTIONS,
|
|
599
|
+
placeholder: t("neetoThemes.common.left"),
|
|
600
|
+
value: toLabelAndValue(((_findBy = findBy({
|
|
601
|
+
key: "".concat(name, "_position")
|
|
602
|
+
}, values.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value) || (positionKeyInSchema === null || positionKeyInSchema === void 0 ? void 0 : positionKeyInSchema.defaultValue)),
|
|
603
|
+
onChange: function onChange(option) {
|
|
604
|
+
return setFieldValue("properties[".concat(positionKeyIndex, "].value"), option.value);
|
|
605
|
+
}
|
|
606
|
+
})]
|
|
607
|
+
})]
|
|
608
|
+
});
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
var Images = function Images(_ref) {
|
|
612
|
+
var attribute = _ref.attribute;
|
|
613
|
+
var _useFormikContext = useFormikContext(),
|
|
614
|
+
values = _useFormikContext.values;
|
|
615
|
+
var key = snakeToCamelCase(attribute);
|
|
616
|
+
var title = buildLabel(key, "image");
|
|
617
|
+
var imageData = values[key];
|
|
618
|
+
return /*#__PURE__*/jsx(Card$2, {
|
|
619
|
+
title: title,
|
|
620
|
+
children: /*#__PURE__*/jsx(ImageBlock, {
|
|
621
|
+
attribute: attribute,
|
|
622
|
+
imageData: imageData,
|
|
623
|
+
name: key
|
|
624
|
+
})
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
|
|
628
|
+
var AlignmentBlock = function AlignmentBlock(_ref) {
|
|
629
|
+
var label = _ref.label,
|
|
630
|
+
name = _ref.name;
|
|
631
|
+
return /*#__PURE__*/jsxs("div", {
|
|
632
|
+
className: "flex items-center justify-between gap-2 py-3 first:pt-0 last:pb-0",
|
|
633
|
+
"data-cy": joinHyphenCase(label),
|
|
634
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
635
|
+
"data-cy": "style-fields-labels",
|
|
636
|
+
style: "body2",
|
|
637
|
+
children: label
|
|
638
|
+
}), /*#__PURE__*/jsx(Field, {
|
|
639
|
+
name: name,
|
|
640
|
+
children: function children(_ref2) {
|
|
641
|
+
var value = _ref2.field.value,
|
|
642
|
+
setFieldValue = _ref2.form.setFieldValue;
|
|
643
|
+
return /*#__PURE__*/jsxs("div", {
|
|
644
|
+
className: "flex items-center gap-3",
|
|
645
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
646
|
+
"data-cy": "alignment-left",
|
|
647
|
+
icon: LeftAlign,
|
|
648
|
+
size: "large",
|
|
649
|
+
style: value === "left" ? "primary" : "text",
|
|
650
|
+
tooltipProps: {
|
|
651
|
+
content: "Left align",
|
|
652
|
+
position: "bottom"
|
|
653
|
+
},
|
|
654
|
+
onClick: function onClick() {
|
|
655
|
+
return setFieldValue(name, "left");
|
|
656
|
+
}
|
|
657
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
658
|
+
"data-cy": "alignment-center",
|
|
659
|
+
icon: CenterAlign,
|
|
660
|
+
size: "large",
|
|
661
|
+
style: value === "center" ? "primary" : "text",
|
|
662
|
+
tooltipProps: {
|
|
663
|
+
content: "Center align",
|
|
664
|
+
position: "bottom"
|
|
665
|
+
},
|
|
666
|
+
onClick: function onClick() {
|
|
667
|
+
return setFieldValue(name, "center");
|
|
668
|
+
}
|
|
669
|
+
})]
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
})]
|
|
673
|
+
});
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
var ColorBlock = function ColorBlock(_ref) {
|
|
677
|
+
var label = _ref.label,
|
|
678
|
+
_ref$color = _ref.color,
|
|
679
|
+
color = _ref$color === void 0 ? "#FFFFFF" : _ref$color,
|
|
680
|
+
onChange = _ref.onChange,
|
|
681
|
+
showTransparencyControl = _ref.showTransparencyControl;
|
|
682
|
+
return /*#__PURE__*/jsxs("div", {
|
|
683
|
+
className: "flex items-center justify-between py-2 first:pt-0 last:pb-0",
|
|
684
|
+
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
685
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
686
|
+
"data-cy": "style-fields-labels",
|
|
687
|
+
style: "body2",
|
|
688
|
+
children: label
|
|
689
|
+
}), /*#__PURE__*/jsx(ColorPicker, {
|
|
690
|
+
color: color,
|
|
691
|
+
onChange: onChange,
|
|
692
|
+
showTransparencyControl: showTransparencyControl,
|
|
693
|
+
showEyeDropper: true,
|
|
694
|
+
size: "large"
|
|
695
|
+
})]
|
|
696
|
+
});
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
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; }
|
|
700
|
+
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), !0).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; }
|
|
701
|
+
var FontPickerBlock = function FontPickerBlock(_ref) {
|
|
702
|
+
var label = _ref.label,
|
|
703
|
+
_ref$placeholder = _ref.placeholder,
|
|
704
|
+
placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
|
|
705
|
+
value = _ref.value,
|
|
706
|
+
options = _ref.options,
|
|
707
|
+
onChange = _ref.onChange;
|
|
708
|
+
return /*#__PURE__*/jsxs("div", {
|
|
709
|
+
className: "flex items-center justify-between py-2 first:pt-0 last:pb-0",
|
|
710
|
+
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
711
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
712
|
+
"data-cy": "style-fields-labels",
|
|
713
|
+
style: "body2",
|
|
714
|
+
children: label
|
|
715
|
+
}), /*#__PURE__*/jsx("div", {
|
|
716
|
+
className: "w-40",
|
|
717
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
718
|
+
onChange: onChange,
|
|
719
|
+
options: options,
|
|
720
|
+
placeholder: placeholder,
|
|
721
|
+
value: value,
|
|
722
|
+
menuPosition: "fixed",
|
|
723
|
+
styles: {
|
|
724
|
+
option: function option(styles, _ref2) {
|
|
725
|
+
var data = _ref2.data;
|
|
726
|
+
return _objectSpread$3(_objectSpread$3({}, styles), {}, {
|
|
727
|
+
fontFamily: data.value
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
})
|
|
732
|
+
})]
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
var SliderBlock = function SliderBlock(_ref) {
|
|
737
|
+
var label = _ref.label,
|
|
738
|
+
onChange = _ref.onChange,
|
|
739
|
+
value = _ref.value,
|
|
740
|
+
min = _ref.min,
|
|
741
|
+
max = _ref.max,
|
|
742
|
+
marks = _ref.marks;
|
|
743
|
+
return /*#__PURE__*/jsxs("div", {
|
|
744
|
+
className: "flex items-center justify-between gap-3 py-3 first:pt-0 last:pb-0",
|
|
745
|
+
"data-cy": "theme-style-".concat(joinHyphenCase(label)),
|
|
746
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
747
|
+
"data-cy": "style-fields-labels",
|
|
748
|
+
style: "body2",
|
|
749
|
+
children: label
|
|
750
|
+
}), /*#__PURE__*/jsx(Slider, {
|
|
751
|
+
marks: marks,
|
|
752
|
+
max: max,
|
|
753
|
+
min: min,
|
|
754
|
+
onChange: onChange,
|
|
755
|
+
value: value,
|
|
756
|
+
className: "my-2 w-20",
|
|
757
|
+
tooltip: {
|
|
758
|
+
formatter: null
|
|
759
|
+
}
|
|
760
|
+
})]
|
|
761
|
+
});
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
var _excluded = ["label", "name"];
|
|
765
|
+
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; }
|
|
766
|
+
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), !0).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; }
|
|
767
|
+
var SwitchBlock = function SwitchBlock(_ref) {
|
|
768
|
+
var label = _ref.label,
|
|
769
|
+
name = _ref.name,
|
|
770
|
+
switchProps = _objectWithoutProperties(_ref, _excluded);
|
|
771
|
+
var _useTranslation = useTranslation(),
|
|
772
|
+
t = _useTranslation.t,
|
|
773
|
+
i18n = _useTranslation.i18n;
|
|
774
|
+
var translationKey = "neetoThemes.properties.boolean.".concat(name, "HelpText");
|
|
775
|
+
var doesHelpTextExist = i18n.exists(translationKey);
|
|
776
|
+
return /*#__PURE__*/jsxs("div", {
|
|
777
|
+
className: "flex items-center justify-between py-2 first:pt-0 last:pb-0",
|
|
778
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
779
|
+
className: "inline-flex items-center gap-4",
|
|
780
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
781
|
+
"data-cy": "style-fields-labels",
|
|
782
|
+
style: "body2",
|
|
783
|
+
className: classNames({
|
|
784
|
+
"w-32": doesHelpTextExist,
|
|
785
|
+
"w-auto": !doesHelpTextExist
|
|
786
|
+
}),
|
|
787
|
+
children: label
|
|
788
|
+
}), doesHelpTextExist && /*#__PURE__*/jsx(HelpPopover, {
|
|
789
|
+
className: "flex-shrink-0",
|
|
790
|
+
description: t(translationKey)
|
|
791
|
+
})]
|
|
792
|
+
}), /*#__PURE__*/jsx(Switch, _objectSpread$2(_objectSpread$2({}, _objectSpread$2({
|
|
793
|
+
name: name
|
|
794
|
+
}, switchProps)), {}, {
|
|
795
|
+
"data-cy": "enable-background-color-toggle"
|
|
796
|
+
}))]
|
|
797
|
+
});
|
|
798
|
+
};
|
|
799
|
+
|
|
800
|
+
var Properties = function Properties(_ref) {
|
|
801
|
+
var onPropertiesChange = _ref.onPropertiesChange;
|
|
802
|
+
var _useTranslation = useTranslation(),
|
|
803
|
+
t = _useTranslation.t;
|
|
804
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
805
|
+
return {
|
|
806
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
807
|
+
};
|
|
808
|
+
}, shallow),
|
|
809
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema;
|
|
810
|
+
var _useThemeStore = useThemeStore(function (store) {
|
|
811
|
+
return {
|
|
812
|
+
setThemeState: store["setThemeState"]
|
|
813
|
+
};
|
|
814
|
+
}, shallow),
|
|
815
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
816
|
+
var _useFormikContext = useFormikContext(),
|
|
817
|
+
setFieldValue = _useFormikContext.setFieldValue,
|
|
818
|
+
values = _useFormikContext.values;
|
|
819
|
+
var _useThemeUtils = useThemeUtils(),
|
|
820
|
+
setVariable = _useThemeUtils.setVariable,
|
|
821
|
+
setTheme = _useThemeUtils.setTheme;
|
|
822
|
+
var handleColorChange = function handleColorChange(name) {
|
|
823
|
+
return function (_ref2) {
|
|
824
|
+
var hex = _ref2.hex,
|
|
825
|
+
rgb = _ref2.rgb;
|
|
826
|
+
handleChange(name, hex, "".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a));
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
var handleChange = function handleChange(name, value, variableValue) {
|
|
830
|
+
var index = findIndexBy({
|
|
831
|
+
key: name
|
|
832
|
+
}, values.properties);
|
|
833
|
+
if (index !== -1 && values.properties[index].value !== value) {
|
|
834
|
+
setFieldValue("properties[".concat(index, "].value"), value);
|
|
835
|
+
}
|
|
836
|
+
setVariable(snakeToCamelCase(name), variableValue !== null && variableValue !== void 0 ? variableValue : value);
|
|
837
|
+
};
|
|
838
|
+
var handleOverlayChange = function handleOverlayChange(key, value) {
|
|
839
|
+
var index = findIndexBy({
|
|
840
|
+
key: key
|
|
841
|
+
}, values.properties);
|
|
842
|
+
var overlayColorVariable = "".concat(key, "_overlay_color");
|
|
843
|
+
setFieldValue("properties[".concat(index, "].value"), value);
|
|
844
|
+
setVariable("".concat(key, "_overlay_opacity"), Math.abs(value / 100));
|
|
845
|
+
if (value < 0) {
|
|
846
|
+
handleChange(overlayColorVariable, "#000000", "0, 0, 0");
|
|
847
|
+
} else {
|
|
848
|
+
handleChange(overlayColorVariable, "#ffffff", "255, 255, 255");
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
useEffect(function () {
|
|
852
|
+
onPropertiesChange === null || onPropertiesChange === void 0 || onPropertiesChange(values, handleChange, handleColorChange);
|
|
853
|
+
setTheme(values);
|
|
854
|
+
setThemeState({
|
|
855
|
+
previewingTheme: values
|
|
856
|
+
});
|
|
857
|
+
}, [values]);
|
|
858
|
+
return /*#__PURE__*/jsx(Card$2, {
|
|
859
|
+
title: t("neetoThemes.common.style"),
|
|
860
|
+
children: values.properties.sort(function (a, b) {
|
|
861
|
+
var _a$order, _b$order;
|
|
862
|
+
return ((_a$order = a.order) !== null && _a$order !== void 0 ? _a$order : Infinity) - ((_b$order = b.order) !== null && _b$order !== void 0 ? _b$order : Infinity);
|
|
863
|
+
}).map(function (_ref3) {
|
|
864
|
+
var _findBy;
|
|
865
|
+
var key = _ref3.key,
|
|
866
|
+
value = _ref3.value,
|
|
867
|
+
kind = _ref3.kind;
|
|
868
|
+
var isCurrentPropertyVisible = isPropertyVisible(key, values, themePropertiesSchema);
|
|
869
|
+
if (!isCurrentPropertyVisible) return null;
|
|
870
|
+
switch (kind) {
|
|
871
|
+
case "font_family":
|
|
872
|
+
return /*#__PURE__*/jsx(FontPickerBlock, {
|
|
873
|
+
label: buildLabel(key, kind),
|
|
874
|
+
options: FONT_OPTIONS,
|
|
875
|
+
value: findBy({
|
|
876
|
+
value: value || null
|
|
877
|
+
}, FONT_OPTIONS),
|
|
878
|
+
onChange: function onChange(_ref4) {
|
|
879
|
+
var value = _ref4.value;
|
|
880
|
+
return handleChange(key, value);
|
|
881
|
+
}
|
|
882
|
+
}, key);
|
|
883
|
+
case "color":
|
|
884
|
+
return /*#__PURE__*/jsx(ColorBlock, {
|
|
885
|
+
color: value,
|
|
886
|
+
label: buildLabel(key, kind),
|
|
887
|
+
showTransparencyControl: ((_findBy = findBy({
|
|
888
|
+
key: key
|
|
889
|
+
}, themePropertiesSchema)) === null || _findBy === void 0 ? void 0 : _findBy.showTransparencyControl) || false,
|
|
890
|
+
onChange: handleColorChange(key)
|
|
891
|
+
}, key);
|
|
892
|
+
case "radius":
|
|
893
|
+
return /*#__PURE__*/jsx(SliderBlock, {
|
|
894
|
+
label: buildLabel(key, kind),
|
|
895
|
+
max: 50,
|
|
896
|
+
min: 0,
|
|
897
|
+
value: Number(value) || 0,
|
|
898
|
+
onChange: function onChange(radius) {
|
|
899
|
+
return handleChange(key, radius, "".concat(radius, "px"));
|
|
900
|
+
}
|
|
901
|
+
}, key);
|
|
902
|
+
case "overlay_opacity":
|
|
903
|
+
return /*#__PURE__*/jsx(SliderBlock, {
|
|
904
|
+
label: buildLabel(key, kind),
|
|
905
|
+
marks: OVERLAY_OPACITY_SLIDER_MARKS,
|
|
906
|
+
max: HUNDRED,
|
|
907
|
+
min: negate(HUNDRED),
|
|
908
|
+
value: Number(value) || 0,
|
|
909
|
+
onChange: function onChange(opacity) {
|
|
910
|
+
return handleOverlayChange(key, opacity);
|
|
911
|
+
}
|
|
912
|
+
}, key);
|
|
913
|
+
case "position_selector":
|
|
914
|
+
{
|
|
915
|
+
var _findBy2;
|
|
916
|
+
var index = findIndexBy({
|
|
917
|
+
key: key
|
|
918
|
+
}, values.properties);
|
|
919
|
+
var options = (_findBy2 = findBy({
|
|
920
|
+
key: key
|
|
921
|
+
}, themePropertiesSchema)) === null || _findBy2 === void 0 || (_findBy2 = _findBy2.options) === null || _findBy2 === void 0 ? void 0 : _findBy2.map(toLabelAndValue);
|
|
922
|
+
return /*#__PURE__*/jsx(SelectBlock, {
|
|
923
|
+
label: buildLabel(key, kind),
|
|
924
|
+
options: options || POSITION_OPTIONS,
|
|
925
|
+
placeholder: "left",
|
|
926
|
+
value: toLabelAndValue(value),
|
|
927
|
+
onChange: function onChange(option) {
|
|
928
|
+
return setFieldValue("properties[".concat(index, "].value"), option.value);
|
|
929
|
+
}
|
|
930
|
+
}, key);
|
|
931
|
+
}
|
|
932
|
+
case "boolean":
|
|
933
|
+
{
|
|
934
|
+
var _index = findIndexBy({
|
|
935
|
+
key: key
|
|
936
|
+
}, values.properties);
|
|
937
|
+
return /*#__PURE__*/jsx(SwitchBlock, {
|
|
938
|
+
checked: value !== "false",
|
|
939
|
+
label: buildLabel(key, kind),
|
|
940
|
+
name: snakeToCamelCase(key),
|
|
941
|
+
onChange: function onChange(e) {
|
|
942
|
+
return setFieldValue("properties[".concat(_index, "].value"), String(e.target.checked));
|
|
943
|
+
}
|
|
944
|
+
}, key);
|
|
945
|
+
}
|
|
946
|
+
case "alignment_block":
|
|
947
|
+
{
|
|
948
|
+
var _index2 = findIndexBy({
|
|
949
|
+
key: key
|
|
950
|
+
}, values.properties);
|
|
951
|
+
return /*#__PURE__*/jsx(AlignmentBlock, {
|
|
952
|
+
label: buildLabel(key, kind),
|
|
953
|
+
name: "properties[".concat(_index2, "].value")
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
default:
|
|
957
|
+
return null;
|
|
958
|
+
}
|
|
959
|
+
})
|
|
960
|
+
});
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
var ThemeMeta = withT(function (_ref) {
|
|
964
|
+
var t = _ref.t;
|
|
965
|
+
return /*#__PURE__*/jsx(Card$2, {
|
|
966
|
+
title: t("neetoThemes.common.name"),
|
|
967
|
+
children: /*#__PURE__*/jsx(Input, {
|
|
968
|
+
autoFocus: true,
|
|
969
|
+
"data-cy": "theme-name-property",
|
|
970
|
+
name: "name"
|
|
971
|
+
})
|
|
972
|
+
});
|
|
973
|
+
});
|
|
974
|
+
|
|
975
|
+
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; }
|
|
976
|
+
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), !0).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; }
|
|
977
|
+
var Customize = function Customize(_ref) {
|
|
978
|
+
var themeId = _ref.themeId,
|
|
979
|
+
theme = _ref.theme,
|
|
980
|
+
onCreateTheme = _ref.onCreateTheme,
|
|
981
|
+
onApplyTheme = _ref.onApplyTheme,
|
|
982
|
+
isApplyingTheme = _ref.isApplyingTheme,
|
|
983
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
984
|
+
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess,
|
|
985
|
+
onEditCSSClick = _ref.onEditCSSClick,
|
|
986
|
+
currentScreen = _ref.currentScreen;
|
|
987
|
+
var _useTranslation = useTranslation(),
|
|
988
|
+
t = _useTranslation.t;
|
|
989
|
+
var _useState = useState({}),
|
|
990
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
991
|
+
popoverInstance = _useState2[0],
|
|
992
|
+
setPopoverInstance = _useState2[1];
|
|
993
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
994
|
+
return {
|
|
995
|
+
themePropertiesSchema: store["themePropertiesSchema"],
|
|
996
|
+
entityType: store["entityType"]
|
|
997
|
+
};
|
|
998
|
+
}, shallow),
|
|
999
|
+
themePropertiesSchema = _useConfigStore.themePropertiesSchema,
|
|
1000
|
+
entityType = _useConfigStore.entityType;
|
|
1001
|
+
var _useThemeUtils = useThemeUtils(),
|
|
1002
|
+
currentTheme = _useThemeUtils.currentTheme;
|
|
1003
|
+
var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
|
|
1004
|
+
var submitBtnRef = useRef(null);
|
|
1005
|
+
var _useCreateTheme = useCreateTheme(),
|
|
1006
|
+
createTheme = _useCreateTheme.mutate,
|
|
1007
|
+
isCreating = _useCreateTheme.isPending;
|
|
1008
|
+
var _useUpdateTheme = useUpdateTheme(themeId),
|
|
1009
|
+
updateTheme = _useUpdateTheme.mutate,
|
|
1010
|
+
isUpdating = _useUpdateTheme.isPending;
|
|
1011
|
+
var isSubmitting = isCreating || isUpdating;
|
|
1012
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
1013
|
+
var onSubmit = function onSubmit(values, _ref2) {
|
|
1014
|
+
var resetForm = _ref2.resetForm;
|
|
1015
|
+
var imageData = buildImageData(values, themePropertiesSchema);
|
|
1016
|
+
var themeToSave = _objectSpread$1({
|
|
1017
|
+
propertiesAttributes: values.properties,
|
|
1018
|
+
name: values.name
|
|
1019
|
+
}, imageData);
|
|
1020
|
+
if (!themeId) {
|
|
1021
|
+
return createTheme(themeToSave, {
|
|
1022
|
+
onSuccess: function onSuccess(_ref3) {
|
|
1023
|
+
var theme = _ref3.theme;
|
|
1024
|
+
resetForm({
|
|
1025
|
+
values: theme
|
|
1026
|
+
});
|
|
1027
|
+
onCreateTheme(theme);
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return updateTheme(themeToSave, {
|
|
1032
|
+
onSuccess: function onSuccess() {
|
|
1033
|
+
resetForm({
|
|
1034
|
+
values: values
|
|
1035
|
+
});
|
|
1036
|
+
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 || onUpdateThemeSuccess(values);
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
return /*#__PURE__*/jsx(Form, {
|
|
1041
|
+
formikProps: {
|
|
1042
|
+
initialValues: buildInitialValues(theme, themePropertiesSchema),
|
|
1043
|
+
validationSchema: THEME_VALIDATION_SCHEMA,
|
|
1044
|
+
onSubmit: onSubmit
|
|
1045
|
+
},
|
|
1046
|
+
children: function children(_ref4) {
|
|
1047
|
+
var dirty = _ref4.dirty;
|
|
1048
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1049
|
+
className: "neeto-themes-sidebar__scroll",
|
|
1050
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1051
|
+
className: "neeto-themes-sidebar__scroll-content flex flex-grow flex-col px-4 py-2 lg:px-5 xl:px-6",
|
|
1052
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1053
|
+
className: classNames({
|
|
1054
|
+
hidden: isCustomCssScreen
|
|
1055
|
+
}),
|
|
1056
|
+
children: /*#__PURE__*/jsx(ThemeMeta, {})
|
|
1057
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1058
|
+
className: classNames({
|
|
1059
|
+
hidden: isCustomCssScreen
|
|
1060
|
+
}),
|
|
1061
|
+
children: /*#__PURE__*/jsx(Properties, {
|
|
1062
|
+
onPropertiesChange: onPropertiesChange
|
|
1063
|
+
})
|
|
1064
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1065
|
+
className: classNames("flex flex-col gap-6", {
|
|
1066
|
+
hidden: isCustomCssScreen
|
|
1067
|
+
}),
|
|
1068
|
+
children: filterBy({
|
|
1069
|
+
kind: "image"
|
|
1070
|
+
}, themePropertiesSchema).map(function (_ref5) {
|
|
1071
|
+
var key = _ref5.key;
|
|
1072
|
+
return /*#__PURE__*/jsx(Images, {
|
|
1073
|
+
attribute: key
|
|
1074
|
+
}, key);
|
|
1075
|
+
})
|
|
1076
|
+
}), /*#__PURE__*/jsx(CustomCSS, {
|
|
1077
|
+
currentScreen: currentScreen,
|
|
1078
|
+
onEditCSSClick: onEditCSSClick
|
|
1079
|
+
})]
|
|
1080
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1081
|
+
className: "neeto-ui-bg-white neeto-ui-shadow-s sticky bottom-0 left-0 right-0 flex justify-end gap-x-2 px-4 py-6",
|
|
1082
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1083
|
+
"data-cy": "reset-button",
|
|
1084
|
+
disabled: !dirty || isSubmitting,
|
|
1085
|
+
label: t("neetoThemes.buttons.reset"),
|
|
1086
|
+
style: "text",
|
|
1087
|
+
type: "reset"
|
|
1088
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
1089
|
+
"data-cy": "save-changes-button",
|
|
1090
|
+
disabled: !dirty && (theme === null || theme === void 0 ? void 0 : theme.id) || isSubmitting,
|
|
1091
|
+
label: t("neetoThemes.buttons.save"),
|
|
1092
|
+
loading: isSubmitting,
|
|
1093
|
+
ref: submitBtnRef,
|
|
1094
|
+
type: "submit"
|
|
1095
|
+
})]
|
|
1096
|
+
}), /*#__PURE__*/jsx(Popover, {
|
|
1097
|
+
appendTo: function appendTo() {
|
|
1098
|
+
return document.body;
|
|
1099
|
+
},
|
|
1100
|
+
disabled: isEditingCurrentlyAppliedTheme,
|
|
1101
|
+
position: "top",
|
|
1102
|
+
reference: submitBtnRef,
|
|
1103
|
+
trigger: "click",
|
|
1104
|
+
content: /*#__PURE__*/jsxs("div", {
|
|
1105
|
+
className: "flex flex-col items-start gap-2",
|
|
1106
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1107
|
+
className: "absolute right-1 top-1 z-0",
|
|
1108
|
+
icon: Close,
|
|
1109
|
+
size: "small",
|
|
1110
|
+
style: "text",
|
|
1111
|
+
onClick: function onClick() {
|
|
1112
|
+
var _popoverInstance$hide;
|
|
1113
|
+
return popoverInstance === null || popoverInstance === void 0 || (_popoverInstance$hide = popoverInstance.hide) === null || _popoverInstance$hide === void 0 ? void 0 : _popoverInstance$hide.call(popoverInstance);
|
|
1114
|
+
}
|
|
1115
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1116
|
+
className: "w-72 pr-5",
|
|
1117
|
+
style: "body2",
|
|
1118
|
+
weight: "normal",
|
|
1119
|
+
children: /*#__PURE__*/jsx(Trans, {
|
|
1120
|
+
components: {
|
|
1121
|
+
bold: /*#__PURE__*/jsx("strong", {})
|
|
1122
|
+
},
|
|
1123
|
+
i18nKey: "neetoThemes.build.leftSideBar.themes.notAppliedYet",
|
|
1124
|
+
values: {
|
|
1125
|
+
entityType: entityType
|
|
1126
|
+
}
|
|
1127
|
+
})
|
|
1128
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
1129
|
+
disabled: isApplyingTheme,
|
|
1130
|
+
label: t("neetoThemes.buttons.applyThisTheme"),
|
|
1131
|
+
loading: isApplyingTheme,
|
|
1132
|
+
onClick: function onClick() {
|
|
1133
|
+
return onApplyTheme(theme);
|
|
1134
|
+
}
|
|
1135
|
+
})]
|
|
1136
|
+
}),
|
|
1137
|
+
onMount: setPopoverInstance
|
|
1138
|
+
})]
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1142
|
+
};
|
|
1143
|
+
|
|
1144
|
+
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; }
|
|
1145
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).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; }
|
|
1146
|
+
var Check = function Check(props) {
|
|
1147
|
+
return /*#__PURE__*/jsxs("svg", _objectSpread(_objectSpread({
|
|
1148
|
+
fill: "none",
|
|
1149
|
+
height: "24",
|
|
1150
|
+
viewBox: "0 0 24 24",
|
|
1151
|
+
width: "24",
|
|
1152
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1153
|
+
}, props), {}, {
|
|
1154
|
+
children: [/*#__PURE__*/jsxs("g", {
|
|
1155
|
+
filter: "url(#filter0_d_9519_161)",
|
|
1156
|
+
children: [/*#__PURE__*/jsx("rect", {
|
|
1157
|
+
fill: "#008068",
|
|
1158
|
+
height: "20",
|
|
1159
|
+
rx: "10",
|
|
1160
|
+
width: "20",
|
|
1161
|
+
x: "2",
|
|
1162
|
+
y: "2"
|
|
1163
|
+
}), /*#__PURE__*/jsx("rect", {
|
|
1164
|
+
height: "20",
|
|
1165
|
+
rx: "10",
|
|
1166
|
+
stroke: "#fff",
|
|
1167
|
+
strokeWidth: "1.5",
|
|
1168
|
+
width: "20",
|
|
1169
|
+
x: "2",
|
|
1170
|
+
y: "2"
|
|
1171
|
+
}), /*#__PURE__*/jsx("path", {
|
|
1172
|
+
d: "M16.375 9.5l-5.95 6.25-2.8-2.941",
|
|
1173
|
+
stroke: "#fff",
|
|
1174
|
+
strokeLinecap: "round",
|
|
1175
|
+
strokeLinejoin: "round",
|
|
1176
|
+
strokeWidth: "1.25"
|
|
1177
|
+
})]
|
|
1178
|
+
}), /*#__PURE__*/jsx("defs", {
|
|
1179
|
+
children: /*#__PURE__*/jsxs("filter", {
|
|
1180
|
+
colorInterpolationFilters: "sRGB",
|
|
1181
|
+
filterUnits: "userSpaceOnUse",
|
|
1182
|
+
height: "23.5",
|
|
1183
|
+
id: "filter0_d_9519_161",
|
|
1184
|
+
width: "23.5",
|
|
1185
|
+
x: "0.25",
|
|
1186
|
+
y: "0.25",
|
|
1187
|
+
children: [/*#__PURE__*/jsx("feFlood", {
|
|
1188
|
+
floodOpacity: "0",
|
|
1189
|
+
result: "BackgroundImageFix"
|
|
1190
|
+
}), /*#__PURE__*/jsx("feColorMatrix", {
|
|
1191
|
+
"in": "SourceAlpha",
|
|
1192
|
+
result: "hardAlpha",
|
|
1193
|
+
values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"
|
|
1194
|
+
}), /*#__PURE__*/jsx("feOffset", {}), /*#__PURE__*/jsx("feGaussianBlur", {
|
|
1195
|
+
stdDeviation: "0.5"
|
|
1196
|
+
}), /*#__PURE__*/jsx("feComposite", {
|
|
1197
|
+
in2: "hardAlpha",
|
|
1198
|
+
operator: "out"
|
|
1199
|
+
}), /*#__PURE__*/jsx("feColorMatrix", {
|
|
1200
|
+
values: "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.09 0"
|
|
1201
|
+
}), /*#__PURE__*/jsx("feBlend", {
|
|
1202
|
+
in2: "BackgroundImageFix",
|
|
1203
|
+
result: "effect1_dropShadow_9519_161"
|
|
1204
|
+
}), /*#__PURE__*/jsx("feBlend", {
|
|
1205
|
+
"in": "SourceGraphic",
|
|
1206
|
+
in2: "effect1_dropShadow_9519_161",
|
|
1207
|
+
result: "shape"
|
|
1208
|
+
})]
|
|
1209
|
+
})
|
|
1210
|
+
})]
|
|
1211
|
+
}));
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
var Thumbnail = function Thumbnail(_ref) {
|
|
1215
|
+
var _theme$snakeToCamelCa, _findBy, _findBy2;
|
|
1216
|
+
var active = _ref.active,
|
|
1217
|
+
isPreviewing = _ref.isPreviewing,
|
|
1218
|
+
isHighLightedTheme = _ref.isHighLightedTheme,
|
|
1219
|
+
theme = _ref.theme;
|
|
1220
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
1221
|
+
return {
|
|
1222
|
+
themePropertiesSchema: store["themePropertiesSchema"]
|
|
1223
|
+
};
|
|
1224
|
+
}, shallow),
|
|
1225
|
+
_useConfigStore$theme = _useConfigStore.themePropertiesSchema,
|
|
1226
|
+
themePropertiesSchema = _useConfigStore$theme === void 0 ? [] : _useConfigStore$theme;
|
|
1227
|
+
var _themePropertiesSchem = _slicedToArray(themePropertiesSchema, 2),
|
|
1228
|
+
colorObject1 = _themePropertiesSchem[0],
|
|
1229
|
+
colorObject2 = _themePropertiesSchem[1];
|
|
1230
|
+
var primaryLabel = humanize(colorObject1 === null || colorObject1 === void 0 ? void 0 : colorObject1.key);
|
|
1231
|
+
var secondaryLabel = humanize(colorObject2 === null || colorObject2 === void 0 ? void 0 : colorObject2.key);
|
|
1232
|
+
var primaryColor = findBy({
|
|
1233
|
+
key: colorObject1.key
|
|
1234
|
+
}, theme.properties).value;
|
|
1235
|
+
var secondaryColor = findBy({
|
|
1236
|
+
key: colorObject2.key
|
|
1237
|
+
}, theme.properties).value;
|
|
1238
|
+
var backgroundImageUrl = (_theme$snakeToCamelCa = theme[snakeToCamelCase(findBy({
|
|
1239
|
+
useAsCardBackground: true
|
|
1240
|
+
}, themePropertiesSchema).key)]) === null || _theme$snakeToCamelCa === void 0 ? void 0 : _theme$snakeToCamelCa.url;
|
|
1241
|
+
var buttonBackgroundColor = (_findBy = findBy({
|
|
1242
|
+
key: (_findBy2 = findBy({
|
|
1243
|
+
useAsCardButtonBackground: true
|
|
1244
|
+
}, themePropertiesSchema)) === null || _findBy2 === void 0 ? void 0 : _findBy2.key
|
|
1245
|
+
}, theme.properties)) === null || _findBy === void 0 ? void 0 : _findBy.value;
|
|
1246
|
+
return /*#__PURE__*/jsx("div", {
|
|
1247
|
+
className: classNames("neeto-themes-theme-thumbnail neeto-ui-rounded-lg border transition-all duration-300 ease-in-out", {
|
|
1248
|
+
"neeto-ui-border-gray-400": !active,
|
|
1249
|
+
"neeto-ui-border-gray-800 neeto-themes-theme-thumbnail--active": active,
|
|
1250
|
+
"neeto-themes-theme-thumbnail--preview-active": isPreviewing,
|
|
1251
|
+
"neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
|
|
1252
|
+
}),
|
|
1253
|
+
style: {
|
|
1254
|
+
backgroundImage: backgroundImageUrl ? "url(".concat(backgroundImageUrl, ")") : "initial",
|
|
1255
|
+
backgroundSize: "cover"
|
|
1256
|
+
},
|
|
1257
|
+
children: /*#__PURE__*/jsx("div", {
|
|
1258
|
+
className: "neeto-ui-rounded-lg cursor-pointer p-3 transition-all duration-300 ease-in-out group-hover:opacity-85",
|
|
1259
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1260
|
+
className: "neeto-ui-rounded-lg p-3",
|
|
1261
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1262
|
+
className: "mb-3",
|
|
1263
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1264
|
+
style: "h3",
|
|
1265
|
+
weight: "semibold",
|
|
1266
|
+
children: /*#__PURE__*/jsx("span", {
|
|
1267
|
+
style: {
|
|
1268
|
+
color: primaryColor
|
|
1269
|
+
},
|
|
1270
|
+
children: primaryLabel
|
|
1271
|
+
})
|
|
1272
|
+
}), /*#__PURE__*/jsx(Typography, {
|
|
1273
|
+
className: "neeto-ui-text-gray-600",
|
|
1274
|
+
style: "body2",
|
|
1275
|
+
children: /*#__PURE__*/jsx("span", {
|
|
1276
|
+
style: {
|
|
1277
|
+
color: secondaryColor
|
|
1278
|
+
},
|
|
1279
|
+
children: secondaryLabel
|
|
1280
|
+
})
|
|
1281
|
+
})]
|
|
1282
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1283
|
+
className: "neeto-ui-rounded-lg h-5 w-12",
|
|
1284
|
+
style: {
|
|
1285
|
+
backgroundColor: buttonBackgroundColor
|
|
1286
|
+
}
|
|
1287
|
+
})]
|
|
1288
|
+
})
|
|
1289
|
+
})
|
|
1290
|
+
});
|
|
1291
|
+
};
|
|
1292
|
+
|
|
1293
|
+
var Card = function Card(_ref) {
|
|
1294
|
+
var _ref$active = _ref.active,
|
|
1295
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
1296
|
+
isPreviewing = _ref.isPreviewing,
|
|
1297
|
+
onSetPreviewTheme = _ref.onSetPreviewTheme,
|
|
1298
|
+
onDeleteTheme = _ref.onDeleteTheme,
|
|
1299
|
+
onEditTheme = _ref.onEditTheme,
|
|
1300
|
+
theme = _ref.theme,
|
|
1301
|
+
isApplyingTheme = _ref.isApplyingTheme,
|
|
1302
|
+
onCloneTheme = _ref.onCloneTheme,
|
|
1303
|
+
isHighLightedTheme = _ref.isHighLightedTheme,
|
|
1304
|
+
onApplyTheme = _ref.onApplyTheme,
|
|
1305
|
+
Thumbnail$1 = _ref.thumbnail;
|
|
1306
|
+
var _useTranslation = useTranslation(),
|
|
1307
|
+
t = _useTranslation.t;
|
|
1308
|
+
var id = theme.id,
|
|
1309
|
+
name = theme.name,
|
|
1310
|
+
appliedCount = theme.appliedCount;
|
|
1311
|
+
var handleCloneTheme = function handleCloneTheme() {
|
|
1312
|
+
return onCloneTheme(theme);
|
|
1313
|
+
};
|
|
1314
|
+
var handleEditTheme = function handleEditTheme() {
|
|
1315
|
+
return onEditTheme(theme);
|
|
1316
|
+
};
|
|
1317
|
+
var handleDeleteTheme = function handleDeleteTheme() {
|
|
1318
|
+
return onDeleteTheme(id, name, appliedCount);
|
|
1319
|
+
};
|
|
1320
|
+
return /*#__PURE__*/jsx("div", {
|
|
1321
|
+
className: "group space-y-2 pt-0.5",
|
|
1322
|
+
"data-cy": active ? "active-theme-card" : "theme-card",
|
|
1323
|
+
id: theme.id,
|
|
1324
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1325
|
+
className: classNames("neeto-themes-theme-thumbnail neeto-ui-rounded-lg cursor-pointer border transition-all duration-300 ease-in-out", {
|
|
1326
|
+
"neeto-ui-border-gray-200": !active,
|
|
1327
|
+
"neeto-themes-theme-thumbnail--active": active,
|
|
1328
|
+
"neeto-themes-theme-thumbnail--preview-active": isPreviewing,
|
|
1329
|
+
"neeto-themes-theme-thumbnail--highlight-active": isHighLightedTheme
|
|
1330
|
+
}),
|
|
1331
|
+
onClick: function onClick() {
|
|
1332
|
+
return onSetPreviewTheme(theme);
|
|
1333
|
+
},
|
|
1334
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1335
|
+
className: "neeto-ui-rounded-lg relative overflow-hidden rounded-bl-none rounded-br-none transition-all duration-300 ease-in-out group-hover:opacity-85",
|
|
1336
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
1337
|
+
className: "absolute right-0 top-0 p-3",
|
|
1338
|
+
children: active ? /*#__PURE__*/jsx(Check, {
|
|
1339
|
+
className: "flex-shrink-0",
|
|
1340
|
+
"data-cy": "active-theme-label"
|
|
1341
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
1342
|
+
className: classNames({
|
|
1343
|
+
hidden: !isPreviewing,
|
|
1344
|
+
"group-hover:block": true
|
|
1345
|
+
}),
|
|
1346
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
1347
|
+
className: "neeto-themes-theme-thumbnail__apply-btn flex-shrink-0",
|
|
1348
|
+
"data-cy": "apply-theme-button",
|
|
1349
|
+
disabled: isApplyingTheme,
|
|
1350
|
+
label: t("neetoThemes.common.apply"),
|
|
1351
|
+
loading: isApplyingTheme,
|
|
1352
|
+
size: "small",
|
|
1353
|
+
style: "tertiary",
|
|
1354
|
+
onClick: function onClick() {
|
|
1355
|
+
return onApplyTheme(theme);
|
|
1356
|
+
}
|
|
1357
|
+
})
|
|
1358
|
+
})
|
|
1359
|
+
}), Thumbnail$1 ? /*#__PURE__*/jsx(Thumbnail$1, {
|
|
1360
|
+
active: active,
|
|
1361
|
+
isHighLightedTheme: isHighLightedTheme,
|
|
1362
|
+
isPreviewing: isPreviewing,
|
|
1363
|
+
theme: theme
|
|
1364
|
+
}) : /*#__PURE__*/jsx(Thumbnail, {
|
|
1365
|
+
active: active,
|
|
1366
|
+
isHighLightedTheme: isHighLightedTheme,
|
|
1367
|
+
isPreviewing: isPreviewing,
|
|
1368
|
+
theme: theme
|
|
1369
|
+
})]
|
|
1370
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
1371
|
+
className: "neeto-ui-border-gray-100 flex items-start justify-between gap-1 border-t p-2",
|
|
1372
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1373
|
+
className: "line-clamp-2 min-w-0 flex-grow break-words pt-1",
|
|
1374
|
+
"data-cy": "theme-name",
|
|
1375
|
+
lineHeight: "snug",
|
|
1376
|
+
style: "body2",
|
|
1377
|
+
children: name
|
|
1378
|
+
}), /*#__PURE__*/jsx(MoreDropdown, {
|
|
1379
|
+
dropdownButtonProps: {
|
|
1380
|
+
size: "small"
|
|
1381
|
+
},
|
|
1382
|
+
dropdownProps: {
|
|
1383
|
+
strategy: "fixed",
|
|
1384
|
+
onClick: function onClick(e) {
|
|
1385
|
+
return e.stopPropagation();
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
menuItems: [{
|
|
1389
|
+
key: "edit",
|
|
1390
|
+
"data-cy": "edit-theme-menu-item",
|
|
1391
|
+
label: t("neetoThemes.common.edit"),
|
|
1392
|
+
isVisible: isPresent(onEditTheme),
|
|
1393
|
+
onClick: handleEditTheme
|
|
1394
|
+
}, {
|
|
1395
|
+
key: "clone",
|
|
1396
|
+
"data-cy": "clone-theme-menu-item",
|
|
1397
|
+
label: t("neetoThemes.build.leftSideBar.themes.themeOptions.clone"),
|
|
1398
|
+
onClick: handleCloneTheme
|
|
1399
|
+
}, {
|
|
1400
|
+
key: "divider",
|
|
1401
|
+
type: "divider",
|
|
1402
|
+
isVisible: isFunction(onDeleteTheme)
|
|
1403
|
+
}, {
|
|
1404
|
+
key: "delete",
|
|
1405
|
+
"data-cy": "delete-theme-menu-item",
|
|
1406
|
+
label: t("neetoThemes.build.leftSideBar.themes.themeOptions.delete"),
|
|
1407
|
+
isVisible: isFunction(onDeleteTheme),
|
|
1408
|
+
onClick: function onClick(e) {
|
|
1409
|
+
e.stopPropagation();
|
|
1410
|
+
handleDeleteTheme();
|
|
1411
|
+
}
|
|
1412
|
+
}]
|
|
1413
|
+
})]
|
|
1414
|
+
})]
|
|
1415
|
+
})
|
|
1416
|
+
});
|
|
1417
|
+
};
|
|
1418
|
+
var Card$1 = /*#__PURE__*/memo(Card);
|
|
1419
|
+
|
|
1420
|
+
var Themes = function Themes(_ref) {
|
|
1421
|
+
var onEditTheme = _ref.onEditTheme,
|
|
1422
|
+
_ref$themes = _ref.themes,
|
|
1423
|
+
themes = _ref$themes === void 0 ? [] : _ref$themes,
|
|
1424
|
+
_ref$defaultThemes = _ref.defaultThemes,
|
|
1425
|
+
defaultThemes = _ref$defaultThemes === void 0 ? [] : _ref$defaultThemes,
|
|
1426
|
+
onDeleteTheme = _ref.onDeleteTheme,
|
|
1427
|
+
themeToHighlight = _ref.themeToHighlight,
|
|
1428
|
+
didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
|
|
1429
|
+
isLoading = _ref.isLoading,
|
|
1430
|
+
currentTheme = _ref.currentTheme,
|
|
1431
|
+
isCurrentThemeLoading = _ref.isCurrentThemeLoading,
|
|
1432
|
+
thumbnail = _ref.thumbnail,
|
|
1433
|
+
themeBeingApplied = _ref.themeBeingApplied,
|
|
1434
|
+
onApplyTheme = _ref.onApplyTheme,
|
|
1435
|
+
isApplyingTheme = _ref.isApplyingTheme;
|
|
1436
|
+
var _useTranslation = useTranslation(),
|
|
1437
|
+
t = _useTranslation.t;
|
|
1438
|
+
var _useThemeUtils = useThemeUtils(),
|
|
1439
|
+
setTheme = _useThemeUtils.setTheme;
|
|
1440
|
+
var _useThemeStore = useThemeStore(function (store) {
|
|
1441
|
+
return {
|
|
1442
|
+
setThemeState: store["setThemeState"],
|
|
1443
|
+
previewingTheme: store["previewingTheme"]
|
|
1444
|
+
};
|
|
1445
|
+
}, shallow),
|
|
1446
|
+
setThemeState = _useThemeStore.setThemeState,
|
|
1447
|
+
previewingTheme = _useThemeStore.previewingTheme;
|
|
1448
|
+
var _useState = useState(""),
|
|
1449
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1450
|
+
searchQuery = _useState2[0],
|
|
1451
|
+
setSearchQuery = _useState2[1];
|
|
1452
|
+
var _useCloneTheme = useCloneTheme(),
|
|
1453
|
+
cloneTheme = _useCloneTheme.mutate;
|
|
1454
|
+
useEffect(function () {
|
|
1455
|
+
if (didScrollActiveThemeIntoView.current || !(currentTheme !== null && currentTheme !== void 0 && currentTheme.id)) return;
|
|
1456
|
+
didScrollActiveThemeIntoView.current = true;
|
|
1457
|
+
setTimeout(function () {
|
|
1458
|
+
scrollElementIntoView(currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
|
|
1459
|
+
}, 100);
|
|
1460
|
+
}, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
|
|
1461
|
+
var setPreviewTheme = function setPreviewTheme(theme) {
|
|
1462
|
+
setThemeState({
|
|
1463
|
+
previewingTheme: theme
|
|
1464
|
+
});
|
|
1465
|
+
setTheme(theme);
|
|
1466
|
+
};
|
|
1467
|
+
var filteredDefaultThemes = defaultThemes.filter(function (theme) {
|
|
1468
|
+
return theme.name.toLowerCase().includes(searchQuery.toLowerCase());
|
|
1469
|
+
});
|
|
1470
|
+
var filteredThemes = themes.filter(function (theme) {
|
|
1471
|
+
return theme.name.toLowerCase().includes(searchQuery.toLowerCase());
|
|
1472
|
+
});
|
|
1473
|
+
var isSearchFieldVisible = (themes === null || themes === void 0 ? void 0 : themes.length) + (defaultThemes === null || defaultThemes === void 0 ? void 0 : defaultThemes.length) > 10;
|
|
1474
|
+
var handleCloneTheme = function handleCloneTheme(data) {
|
|
1475
|
+
cloneTheme(data.id, {
|
|
1476
|
+
onSuccess: function onSuccess(_ref2) {
|
|
1477
|
+
var clonedTheme = _ref2.theme;
|
|
1478
|
+
onEditTheme(clonedTheme);
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
};
|
|
1482
|
+
if (isLoading || isCurrentThemeLoading) {
|
|
1483
|
+
return /*#__PURE__*/jsx("div", {
|
|
1484
|
+
className: "flex h-full w-full items-center justify-center",
|
|
1485
|
+
children: /*#__PURE__*/jsx(Spinner, {})
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1489
|
+
className: "neeto-themes-sidebar__scroll",
|
|
1490
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1491
|
+
className: "mb-6 space-y-3",
|
|
1492
|
+
children: [isSearchFieldVisible && /*#__PURE__*/jsx(Search, {
|
|
1493
|
+
autoFocus: true,
|
|
1494
|
+
autoComplete: "off",
|
|
1495
|
+
className: "mb-4 mt-1 px-6",
|
|
1496
|
+
placeholder: t("neetoThemes.common.searchThemes"),
|
|
1497
|
+
onSearch: setSearchQuery
|
|
1498
|
+
}), isEmpty(filteredThemes) && isEmpty(filteredDefaultThemes) && /*#__PURE__*/jsx(Typography, {
|
|
1499
|
+
className: "text-center",
|
|
1500
|
+
style: "body2",
|
|
1501
|
+
children: t("neetoThemes.common.noResultsFound")
|
|
1502
|
+
}), isNotEmpty(filteredDefaultThemes) && /*#__PURE__*/jsxs(Fragment, {
|
|
1503
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1504
|
+
className: "my-4 px-4 uppercase lg:px-5 xl:px-6",
|
|
1505
|
+
"data-cy": "system-themes-header",
|
|
1506
|
+
style: "h6",
|
|
1507
|
+
weight: "semibold",
|
|
1508
|
+
children: t("neetoThemes.build.leftSideBar.themes.systemThemes")
|
|
1509
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1510
|
+
className: "flex flex-col gap-4 px-4 pb-10 lg:px-5 xl:px-6",
|
|
1511
|
+
"data-cy": "system-themes",
|
|
1512
|
+
children: filteredDefaultThemes.map(function (theme) {
|
|
1513
|
+
return /*#__PURE__*/createElement(Card$1, {
|
|
1514
|
+
onApplyTheme: onApplyTheme,
|
|
1515
|
+
theme: theme,
|
|
1516
|
+
thumbnail: thumbnail,
|
|
1517
|
+
active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
|
|
1518
|
+
isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
|
|
1519
|
+
key: theme.id,
|
|
1520
|
+
isApplyingTheme: isApplyingTheme && (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
|
|
1521
|
+
onCloneTheme: handleCloneTheme,
|
|
1522
|
+
onSetPreviewTheme: setPreviewTheme
|
|
1523
|
+
});
|
|
1524
|
+
})
|
|
1525
|
+
})]
|
|
1526
|
+
})]
|
|
1527
|
+
}), isNotEmpty(filteredThemes) && /*#__PURE__*/jsxs("div", {
|
|
1528
|
+
className: "mb-6 space-y-3",
|
|
1529
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1530
|
+
className: "my-4 px-6 uppercase",
|
|
1531
|
+
"data-cy": "custom-themes-header",
|
|
1532
|
+
style: "h6",
|
|
1533
|
+
weight: "semibold",
|
|
1534
|
+
children: t("neetoThemes.build.leftSideBar.themes.customThemes")
|
|
1535
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1536
|
+
className: "flex flex-col gap-4 px-6",
|
|
1537
|
+
"data-cy": "custom-themes",
|
|
1538
|
+
children: filteredThemes.map(function (theme) {
|
|
1539
|
+
var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
|
|
1540
|
+
var isPreviewing = (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id;
|
|
1541
|
+
return /*#__PURE__*/createElement(Card$1, {
|
|
1542
|
+
isPreviewing: isPreviewing,
|
|
1543
|
+
onApplyTheme: onApplyTheme,
|
|
1544
|
+
onEditTheme: onEditTheme,
|
|
1545
|
+
theme: theme,
|
|
1546
|
+
thumbnail: thumbnail,
|
|
1547
|
+
active: isActive,
|
|
1548
|
+
isHighLightedTheme: theme.id === themeToHighlight,
|
|
1549
|
+
key: theme.id,
|
|
1550
|
+
isApplyingTheme: isApplyingTheme && (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
|
|
1551
|
+
onCloneTheme: handleCloneTheme,
|
|
1552
|
+
onDeleteTheme: !isActive && onDeleteTheme,
|
|
1553
|
+
onSetPreviewTheme: setPreviewTheme
|
|
1554
|
+
});
|
|
1555
|
+
})
|
|
1556
|
+
})]
|
|
1557
|
+
})]
|
|
1558
|
+
});
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
var TitleBar = function TitleBar(_ref) {
|
|
1562
|
+
var currentScreen = _ref.currentScreen,
|
|
1563
|
+
handleBackPress = _ref.handleBackPress,
|
|
1564
|
+
handleCreateNewTheme = _ref.handleCreateNewTheme,
|
|
1565
|
+
isNewTheme = _ref.isNewTheme,
|
|
1566
|
+
themeToEdit = _ref.themeToEdit;
|
|
1567
|
+
var _useTranslation = useTranslation(),
|
|
1568
|
+
t = _useTranslation.t;
|
|
1569
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
1570
|
+
if (currentScreen === DESIGN_SCREENS.THEMES) {
|
|
1571
|
+
return /*#__PURE__*/jsx("div", {
|
|
1572
|
+
className: "neeto-themes-sidebar__header px-4 lg:px-5 xl:px-6",
|
|
1573
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1574
|
+
className: "flex items-center justify-between space-x-2",
|
|
1575
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1576
|
+
"data-cy": "themes-header",
|
|
1577
|
+
lineHeight: "normal",
|
|
1578
|
+
style: "h3",
|
|
1579
|
+
weight: "semibold",
|
|
1580
|
+
children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
|
|
1581
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1582
|
+
className: "self-end",
|
|
1583
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
1584
|
+
"data-cy": "customize-themes-add-theme-button",
|
|
1585
|
+
icon: Plus,
|
|
1586
|
+
iconPosition: "left",
|
|
1587
|
+
style: "text",
|
|
1588
|
+
tooltipProps: {
|
|
1589
|
+
content: t("neetoThemes.buttons.addNewTheme"),
|
|
1590
|
+
position: "top"
|
|
1591
|
+
},
|
|
1592
|
+
onClick: handleCreateNewTheme
|
|
1593
|
+
})
|
|
1594
|
+
})]
|
|
1595
|
+
})
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
return /*#__PURE__*/jsx("div", {
|
|
1599
|
+
className: "neeto-themes-sidebar__header px-4",
|
|
1600
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
1601
|
+
className: "flex items-center justify-start space-x-2",
|
|
1602
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1603
|
+
"data-cy": "customize-themes-back-button",
|
|
1604
|
+
icon: LeftArrow,
|
|
1605
|
+
iconPosition: "left",
|
|
1606
|
+
style: "text",
|
|
1607
|
+
tooltipProps: {
|
|
1608
|
+
content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
|
|
1609
|
+
position: "top"
|
|
1610
|
+
},
|
|
1611
|
+
onClick: function onClick() {
|
|
1612
|
+
return handleBackPress(themeToEdit);
|
|
1613
|
+
}
|
|
1614
|
+
}), /*#__PURE__*/jsxs(Typography, {
|
|
1615
|
+
"data-cy": "themes-header",
|
|
1616
|
+
lineHeight: "normal",
|
|
1617
|
+
style: "h3",
|
|
1618
|
+
weight: "semibold",
|
|
1619
|
+
children: [currentScreen === DESIGN_SCREENS.Customize && (isNewTheme ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
|
|
1620
|
+
})]
|
|
1621
|
+
})
|
|
1622
|
+
});
|
|
1623
|
+
};
|
|
1624
|
+
|
|
1625
|
+
var MemoizedAlert = /*#__PURE__*/memo(Alert);
|
|
1626
|
+
var Sidebar = function Sidebar(_ref) {
|
|
1627
|
+
var _themeToEdit$current, _themeToEdit$current2, _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
|
|
1628
|
+
var thumbnail = _ref.thumbnail,
|
|
1629
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
1630
|
+
onApplyThemeSuccess = _ref.onApplyThemeSuccess,
|
|
1631
|
+
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess;
|
|
1632
|
+
var _useState = useState(DESIGN_SCREENS.THEMES),
|
|
1633
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1634
|
+
currentScreen = _useState2[0],
|
|
1635
|
+
setCurrentScreen = _useState2[1];
|
|
1636
|
+
var _useState3 = useState(false),
|
|
1637
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
1638
|
+
isDeleteAlertOpen = _useState4[0],
|
|
1639
|
+
setIsDeleteAlertOpen = _useState4[1];
|
|
1640
|
+
var _useState5 = useState(null),
|
|
1641
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
1642
|
+
themeToHighlight = _useState6[0],
|
|
1643
|
+
setThemeToHighlight = _useState6[1];
|
|
1644
|
+
var _useState7 = useState({}),
|
|
1645
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
1646
|
+
themeBeingApplied = _useState8[0],
|
|
1647
|
+
setThemeBeingApplied = _useState8[1];
|
|
1648
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
1649
|
+
return {
|
|
1650
|
+
entityType: store["entityType"],
|
|
1651
|
+
entityId: store["entityId"],
|
|
1652
|
+
isFetchingSchema: store["isFetchingSchema"],
|
|
1653
|
+
defaultThemeName: store["defaultThemeName"]
|
|
1654
|
+
};
|
|
1655
|
+
}, shallow),
|
|
1656
|
+
entityType = _useConfigStore.entityType,
|
|
1657
|
+
entityId = _useConfigStore.entityId,
|
|
1658
|
+
isFetchingSchema = _useConfigStore.isFetchingSchema,
|
|
1659
|
+
defaultThemeName = _useConfigStore.defaultThemeName;
|
|
1660
|
+
var _useThemeStore = useThemeStore(function (store) {
|
|
1661
|
+
return {
|
|
1662
|
+
setThemeState: store["setThemeState"]
|
|
1663
|
+
};
|
|
1664
|
+
}, shallow),
|
|
1665
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
1666
|
+
var didScrollActiveThemeIntoView = useRef(null);
|
|
1667
|
+
var _useTranslation = useTranslation(),
|
|
1668
|
+
t = _useTranslation.t;
|
|
1669
|
+
var _useThemeUtils = useThemeUtils(),
|
|
1670
|
+
setTheme = _useThemeUtils.setTheme;
|
|
1671
|
+
var _useListThemes = useListThemes(entityId),
|
|
1672
|
+
_useListThemes$data = _useListThemes.data,
|
|
1673
|
+
_useListThemes$data2 = _useListThemes$data === void 0 ? {} : _useListThemes$data,
|
|
1674
|
+
_useListThemes$data2$ = _useListThemes$data2.themes,
|
|
1675
|
+
themes = _useListThemes$data2$ === void 0 ? [] : _useListThemes$data2$,
|
|
1676
|
+
_useListThemes$data2$2 = _useListThemes$data2.defaultThemes,
|
|
1677
|
+
defaultThemes = _useListThemes$data2$2 === void 0 ? [] : _useListThemes$data2$2,
|
|
1678
|
+
isLoading = _useListThemes.isLoading;
|
|
1679
|
+
var _useShowThemeEntity = useShowThemeEntity(entityId),
|
|
1680
|
+
_useShowThemeEntity$d = _useShowThemeEntity.data,
|
|
1681
|
+
_useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
|
|
1682
|
+
_useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
|
|
1683
|
+
currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
|
|
1684
|
+
isCurrentThemeLoading = _useShowThemeEntity.isLoading;
|
|
1685
|
+
var _useDeleteTheme = useDeleteTheme(),
|
|
1686
|
+
deleteTheme = _useDeleteTheme.mutate,
|
|
1687
|
+
isDeleting = _useDeleteTheme.isPending;
|
|
1688
|
+
var _useApplyTheme = useApplyTheme({
|
|
1689
|
+
onSuccess: function onSuccess(_ref2) {
|
|
1690
|
+
var theme = _ref2.theme;
|
|
1691
|
+
setTheme(theme);
|
|
1692
|
+
highlightTheme(theme);
|
|
1693
|
+
setThemeState({
|
|
1694
|
+
previewingTheme: theme
|
|
1695
|
+
});
|
|
1696
|
+
setThemeBeingApplied({});
|
|
1697
|
+
setCurrentScreen(DESIGN_SCREENS.THEMES);
|
|
1698
|
+
onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(theme);
|
|
1699
|
+
}
|
|
1700
|
+
}),
|
|
1701
|
+
applyTheme = _useApplyTheme.mutate,
|
|
1702
|
+
isApplyingTheme = _useApplyTheme.isPending;
|
|
1703
|
+
var themeToDelete = useRef(null);
|
|
1704
|
+
var themeToEdit = useRef(null);
|
|
1705
|
+
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
1706
|
+
var handleEditTheme = function handleEditTheme(theme) {
|
|
1707
|
+
themeToEdit.current = theme;
|
|
1708
|
+
setCurrentScreen(DESIGN_SCREENS.Customize);
|
|
1709
|
+
};
|
|
1710
|
+
var onApplyTheme = function onApplyTheme(theme) {
|
|
1711
|
+
if (isApplyingTheme) return;
|
|
1712
|
+
setThemeBeingApplied(theme);
|
|
1713
|
+
applyTheme({
|
|
1714
|
+
themeId: theme.id,
|
|
1715
|
+
entityId: entityId,
|
|
1716
|
+
entityType: entityType
|
|
1717
|
+
});
|
|
1718
|
+
};
|
|
1719
|
+
var handleBackPress = function handleBackPress(theme) {
|
|
1720
|
+
setTheme(currentTheme);
|
|
1721
|
+
highlightTheme(isPresent(theme) ? theme : currentTheme);
|
|
1722
|
+
setThemeState({
|
|
1723
|
+
previewingTheme: currentTheme
|
|
1724
|
+
});
|
|
1725
|
+
setCurrentScreen(isCustomCssScreen ? DESIGN_SCREENS.Customize : DESIGN_SCREENS.THEMES);
|
|
1726
|
+
themeToEdit.current = null;
|
|
1727
|
+
};
|
|
1728
|
+
var highlightTheme = function highlightTheme(themeToHighlight) {
|
|
1729
|
+
setTimeout(function () {
|
|
1730
|
+
scrollElementIntoView(themeToHighlight.id);
|
|
1731
|
+
}, 1500);
|
|
1732
|
+
setTimeout(function () {
|
|
1733
|
+
setThemeToHighlight(null);
|
|
1734
|
+
}, 4000);
|
|
1735
|
+
setThemeToHighlight(themeToHighlight.id);
|
|
1736
|
+
};
|
|
1737
|
+
var onCreateTheme = function onCreateTheme(createdTheme) {
|
|
1738
|
+
themeToEdit.current = createdTheme;
|
|
1739
|
+
setTheme(createdTheme);
|
|
1740
|
+
setThemeState({
|
|
1741
|
+
previewingTheme: createdTheme
|
|
1742
|
+
});
|
|
1743
|
+
};
|
|
1744
|
+
var handleDelete = function handleDelete(themeId, name, appliedCount) {
|
|
1745
|
+
setIsDeleteAlertOpen(true);
|
|
1746
|
+
themeToDelete.current = {
|
|
1747
|
+
id: themeId,
|
|
1748
|
+
name: name,
|
|
1749
|
+
appliedCount: appliedCount
|
|
1750
|
+
};
|
|
1751
|
+
};
|
|
1752
|
+
var handleCloseDeleteAlert = useCallback(function () {
|
|
1753
|
+
setIsDeleteAlertOpen(false);
|
|
1754
|
+
themeToDelete.current = null;
|
|
1755
|
+
}, [themeToDelete]);
|
|
1756
|
+
var handleDeleteTheme = useCallback(function () {
|
|
1757
|
+
var _themeToDelete$curren;
|
|
1758
|
+
deleteTheme((_themeToDelete$curren = themeToDelete.current) === null || _themeToDelete$curren === void 0 ? void 0 : _themeToDelete$curren.id, {
|
|
1759
|
+
onSuccess: function onSuccess() {
|
|
1760
|
+
setIsDeleteAlertOpen(false);
|
|
1761
|
+
themeToDelete.current = null;
|
|
1762
|
+
}
|
|
1763
|
+
});
|
|
1764
|
+
}, [deleteTheme, themeToDelete]);
|
|
1765
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1766
|
+
className: classNames("neeto-themes-sidebar neeto-ui-border-gray-200 flex-shrink-0 border-r transition-all duration-300", {
|
|
1767
|
+
"neeto-themes-sidebar--expanded": isCustomCssScreen
|
|
1768
|
+
}),
|
|
1769
|
+
children: [/*#__PURE__*/jsx(TitleBar, {
|
|
1770
|
+
currentScreen: currentScreen,
|
|
1771
|
+
handleBackPress: handleBackPress,
|
|
1772
|
+
handleCreateNewTheme: function handleCreateNewTheme() {
|
|
1773
|
+
return handleEditTheme({});
|
|
1774
|
+
},
|
|
1775
|
+
isNewTheme: !((_themeToEdit$current = themeToEdit.current) !== null && _themeToEdit$current !== void 0 && _themeToEdit$current.id),
|
|
1776
|
+
themeToEdit: themeToEdit.current
|
|
1777
|
+
}), currentScreen === DESIGN_SCREENS.THEMES ? /*#__PURE__*/jsx(Themes, {
|
|
1778
|
+
currentTheme: currentTheme,
|
|
1779
|
+
defaultThemes: defaultThemes,
|
|
1780
|
+
didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
|
|
1781
|
+
highlightTheme: highlightTheme,
|
|
1782
|
+
isApplyingTheme: isApplyingTheme,
|
|
1783
|
+
isCurrentThemeLoading: isCurrentThemeLoading,
|
|
1784
|
+
onApplyTheme: onApplyTheme,
|
|
1785
|
+
themeBeingApplied: themeBeingApplied,
|
|
1786
|
+
themeToHighlight: themeToHighlight,
|
|
1787
|
+
themes: themes,
|
|
1788
|
+
thumbnail: thumbnail,
|
|
1789
|
+
isLoading: isLoading || isFetchingSchema,
|
|
1790
|
+
onDeleteTheme: handleDelete,
|
|
1791
|
+
onEditTheme: handleEditTheme
|
|
1792
|
+
}) : /*#__PURE__*/jsx(Customize, {
|
|
1793
|
+
currentScreen: currentScreen,
|
|
1794
|
+
isApplyingTheme: isApplyingTheme,
|
|
1795
|
+
onApplyTheme: onApplyTheme,
|
|
1796
|
+
onCreateTheme: onCreateTheme,
|
|
1797
|
+
onPropertiesChange: onPropertiesChange,
|
|
1798
|
+
onUpdateThemeSuccess: onUpdateThemeSuccess,
|
|
1799
|
+
theme: themeToEdit.current,
|
|
1800
|
+
themeId: (_themeToEdit$current2 = themeToEdit.current) === null || _themeToEdit$current2 === void 0 ? void 0 : _themeToEdit$current2.id,
|
|
1801
|
+
onEditCSSClick: setCurrentScreen
|
|
1802
|
+
}), /*#__PURE__*/jsx(MemoizedAlert, {
|
|
1803
|
+
isOpen: isDeleteAlertOpen,
|
|
1804
|
+
isSubmitting: isDeleting,
|
|
1805
|
+
title: t("neetoThemes.alerts.title.deleteTheme"),
|
|
1806
|
+
message: t("neetoThemes.alerts.message.deleteTheme", {
|
|
1807
|
+
name: (_themeToDelete$curren2 = themeToDelete.current) === null || _themeToDelete$curren2 === void 0 ? void 0 : _themeToDelete$curren2.name,
|
|
1808
|
+
count: (_themeToDelete$curren3 = themeToDelete.current) === null || _themeToDelete$curren3 === void 0 ? void 0 : _themeToDelete$curren3.appliedCount,
|
|
1809
|
+
defaultThemeName: defaultThemeName,
|
|
1810
|
+
entityType: t("neetoThemes.entityType.".concat(entityType.toLowerCase()), {
|
|
1811
|
+
count: (_themeToDelete$curren4 = themeToDelete.current) === null || _themeToDelete$curren4 === void 0 ? void 0 : _themeToDelete$curren4.appliedCount
|
|
1812
|
+
})
|
|
1813
|
+
}),
|
|
1814
|
+
onClose: handleCloseDeleteAlert,
|
|
1815
|
+
onSubmit: handleDeleteTheme
|
|
1816
|
+
})]
|
|
1817
|
+
});
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
1821
|
+
var children = _ref.children,
|
|
1822
|
+
entityType = _ref.entityType,
|
|
1823
|
+
entityId = _ref.entityId,
|
|
1824
|
+
thumbnail = _ref.thumbnail,
|
|
1825
|
+
onPropertiesChange = _ref.onPropertiesChange,
|
|
1826
|
+
_ref$isTemplateThemes = _ref.isTemplateThemesEnabled,
|
|
1827
|
+
isTemplateThemesEnabled = _ref$isTemplateThemes === void 0 ? false : _ref$isTemplateThemes,
|
|
1828
|
+
_ref$onApplyThemeSucc = _ref.onApplyThemeSuccess,
|
|
1829
|
+
onApplyThemeSuccess = _ref$onApplyThemeSucc === void 0 ? noop : _ref$onApplyThemeSucc,
|
|
1830
|
+
_ref$onUpdateThemeSuc = _ref.onUpdateThemeSuccess,
|
|
1831
|
+
onUpdateThemeSuccess = _ref$onUpdateThemeSuc === void 0 ? noop : _ref$onUpdateThemeSuc;
|
|
1832
|
+
var _useThemeStore = useThemeStore(function (store) {
|
|
1833
|
+
return {
|
|
1834
|
+
setThemeState: store["setThemeState"]
|
|
1835
|
+
};
|
|
1836
|
+
}, shallow),
|
|
1837
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
1838
|
+
var _useThemeUtils = useThemeUtils(),
|
|
1839
|
+
setTheme = _useThemeUtils.setTheme;
|
|
1840
|
+
var _useConfigStore = useConfigStore(function (store) {
|
|
1841
|
+
return {
|
|
1842
|
+
setConfigState: store["setConfigState"]
|
|
1843
|
+
};
|
|
1844
|
+
}, shallow),
|
|
1845
|
+
setConfigState = _useConfigStore.setConfigState;
|
|
1846
|
+
var _useShowThemeEntity = useShowThemeEntity(entityId),
|
|
1847
|
+
_useShowThemeEntity$d = _useShowThemeEntity.data,
|
|
1848
|
+
_useShowThemeEntity$d2 = _useShowThemeEntity$d === void 0 ? {} : _useShowThemeEntity$d,
|
|
1849
|
+
_useShowThemeEntity$d3 = _useShowThemeEntity$d2.theme,
|
|
1850
|
+
currentTheme = _useShowThemeEntity$d3 === void 0 ? {} : _useShowThemeEntity$d3,
|
|
1851
|
+
isLoading = _useShowThemeEntity.isLoading,
|
|
1852
|
+
isFetchingCurrentTheme = _useShowThemeEntity.isFetching;
|
|
1853
|
+
var isCurrentThemeLoading = isLoading || isFetchingCurrentTheme;
|
|
1854
|
+
useEffect(function () {
|
|
1855
|
+
setConfigState({
|
|
1856
|
+
entityType: entityType,
|
|
1857
|
+
entityId: entityId,
|
|
1858
|
+
isTemplateThemesEnabled: isTemplateThemesEnabled
|
|
1859
|
+
});
|
|
1860
|
+
}, []);
|
|
1861
|
+
useEffect(function () {
|
|
1862
|
+
if (isNotPresent(currentTheme)) return;
|
|
1863
|
+
setThemeState({
|
|
1864
|
+
previewingTheme: currentTheme
|
|
1865
|
+
});
|
|
1866
|
+
setTheme(currentTheme);
|
|
1867
|
+
}, [isLoading, entityId]);
|
|
1868
|
+
useEffect(function () {
|
|
1869
|
+
if (isNotPresent(currentTheme)) return;
|
|
1870
|
+
setThemeState({
|
|
1871
|
+
currentTheme: currentTheme,
|
|
1872
|
+
isCurrentThemeLoading: isCurrentThemeLoading
|
|
1873
|
+
});
|
|
1874
|
+
}, [currentTheme, isCurrentThemeLoading]);
|
|
1875
|
+
return /*#__PURE__*/jsxs("div", {
|
|
1876
|
+
className: "neeto-themes__wrapper",
|
|
1877
|
+
children: [/*#__PURE__*/jsx(Sidebar, {
|
|
1878
|
+
onApplyThemeSuccess: onApplyThemeSuccess,
|
|
1879
|
+
onPropertiesChange: onPropertiesChange,
|
|
1880
|
+
onUpdateThemeSuccess: onUpdateThemeSuccess,
|
|
1881
|
+
thumbnail: thumbnail
|
|
1882
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1883
|
+
className: "neeto-themes-preview__wrapper",
|
|
1884
|
+
children: isCurrentThemeLoading ? /*#__PURE__*/jsx("div", {
|
|
1885
|
+
className: "m-auto flex h-full w-full items-center justify-center",
|
|
1886
|
+
children: /*#__PURE__*/jsx(Spinner, {})
|
|
1887
|
+
}) : children
|
|
1888
|
+
})]
|
|
1889
|
+
});
|
|
1890
|
+
};
|
|
1891
|
+
var index = withTitle(NeetoThemesBuilder, t$1("neetoThemes.common.design"));
|
|
1892
|
+
|
|
1893
|
+
export { index as default };
|
|
1894
|
+
//# sourceMappingURL=NeetoThemesBuilder.js.map
|