@bigbinary/neeto-themes-frontend 3.0.4 → 3.1.1
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/dist/NeetoThemesBuilder.js +242 -124
- package/dist/NeetoThemesBuilder.js.map +1 -1
- package/dist/cjs/NeetoThemesBuilder.js +241 -123
- package/dist/cjs/NeetoThemesBuilder.js.map +1 -1
- package/dist/cjs/hooks.js +2 -2
- package/dist/cjs/index.js +8 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils.js +1 -1
- package/dist/hooks.js +2 -2
- package/dist/{index-D6l2IgrM.js → index-BvWiXoC1.js} +13 -5
- package/dist/index-BvWiXoC1.js.map +1 -0
- package/dist/{index-CvV1tFYS.js → index-BzuiCZa9.js} +12 -6
- package/dist/index-BzuiCZa9.js.map +1 -0
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/{useThemeUtils-BCO-i9ZG.js → useThemeUtils-3j-X4pSD.js} +2 -2
- package/dist/{useThemeUtils-BCO-i9ZG.js.map → useThemeUtils-3j-X4pSD.js.map} +1 -1
- package/dist/{useThemeUtils-P5tn1h2B.js → useThemeUtils-DrdkjWvi.js} +2 -2
- package/dist/{useThemeUtils-P5tn1h2B.js.map → useThemeUtils-DrdkjWvi.js.map} +1 -1
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/dist/index-CvV1tFYS.js.map +0 -1
- package/dist/index-D6l2IgrM.js.map +0 -1
|
@@ -4,31 +4,34 @@ import { t as t$1 } from 'i18next';
|
|
|
4
4
|
import { hyphenate, findBy, findIndexBy, isPresent, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
|
|
5
5
|
import { useMutationWithInvalidation, withT, useBreakpoints, withTitle } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
6
6
|
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
7
|
-
import {
|
|
7
|
+
import { B as BASE_URL, b as scrollElementIntoView, c as setCustomCSS, g as getDominantColorFromUrl, i as isEditThemeRoute, d as isFunction, e as isNewThemeRoute } from './index-BzuiCZa9.js';
|
|
8
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
8
9
|
import axios from 'axios';
|
|
9
|
-
import {
|
|
10
|
-
import { Q as QUERY_KEYS, a as useConfigStore, b as useThemeStore, u as useThemeUtils } from './useThemeUtils-BCO-i9ZG.js';
|
|
10
|
+
import { Q as QUERY_KEYS, a as useConfigStore, b as useThemeStore, u as useThemeUtils } from './useThemeUtils-3j-X4pSD.js';
|
|
11
11
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
12
12
|
import classnames from 'classnames';
|
|
13
|
+
import { joinHyphenCase, buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
|
|
13
14
|
import Collapse from '@bigbinary/neeto-icons/Collapse';
|
|
14
15
|
import Alert from '@bigbinary/neetoui/Alert';
|
|
15
16
|
import Button from '@bigbinary/neetoui/Button';
|
|
16
17
|
import { useTranslation, Trans } from 'react-i18next';
|
|
17
|
-
import
|
|
18
|
+
import { useHistory, useParams, Switch as Switch$1, Route } from 'react-router-dom';
|
|
18
19
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
20
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
19
21
|
import Close from '@bigbinary/neeto-icons/Close';
|
|
22
|
+
import PageLoader from '@bigbinary/neeto-molecules/PageLoader';
|
|
20
23
|
import Popover from '@bigbinary/neetoui/Popover';
|
|
21
24
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
22
25
|
import Switch from '@bigbinary/neetoui/Switch';
|
|
23
26
|
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
24
27
|
import Form from '@bigbinary/neetoui/formik/Form';
|
|
28
|
+
import BlockNavigation from '@bigbinary/neetoui/formik/BlockNavigation';
|
|
29
|
+
import { isEmpty, negate, isNotNil } from 'ramda';
|
|
25
30
|
import * as yup from 'yup';
|
|
26
31
|
import Editor from '@monaco-editor/react';
|
|
27
32
|
import { useFormikContext, Field } from 'formik';
|
|
28
33
|
import Down from '@bigbinary/neeto-icons/Down';
|
|
29
34
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
30
|
-
import { negate, isEmpty } from 'ramda';
|
|
31
|
-
import { joinHyphenCase } from '@bigbinary/neeto-commons-frontend/utils';
|
|
32
35
|
import CenterAlign from '@bigbinary/neeto-icons/CenterAlign';
|
|
33
36
|
import LeftAlign from '@bigbinary/neeto-icons/LeftAlign';
|
|
34
37
|
import ColorPicker from '@bigbinary/neetoui/ColorPicker';
|
|
@@ -123,6 +126,8 @@ var themesApi = {
|
|
|
123
126
|
applyGlobalTheme: applyGlobalTheme
|
|
124
127
|
};
|
|
125
128
|
|
|
129
|
+
function ownKeys$6(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; }
|
|
130
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
126
131
|
var useListThemes = function useListThemes(entityId) {
|
|
127
132
|
var _useConfigStore = useConfigStore(function (store) {
|
|
128
133
|
return {
|
|
@@ -138,19 +143,32 @@ var useListThemes = function useListThemes(entityId) {
|
|
|
138
143
|
}
|
|
139
144
|
});
|
|
140
145
|
};
|
|
146
|
+
var useFetchTheme = function useFetchTheme(themeId, options) {
|
|
147
|
+
return useQuery(_objectSpread$6({
|
|
148
|
+
queryKey: [QUERY_KEYS.THEME_DETAILS, themeId],
|
|
149
|
+
queryFn: function queryFn() {
|
|
150
|
+
return themesApi.show(themeId);
|
|
151
|
+
}
|
|
152
|
+
}, options));
|
|
153
|
+
};
|
|
141
154
|
var useCreateTheme = function useCreateTheme() {
|
|
142
155
|
return useMutationWithInvalidation(themesApi.create, {
|
|
143
156
|
keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.GLOBAL_THEME_DETAILS]]
|
|
144
157
|
});
|
|
145
158
|
};
|
|
146
159
|
var useUpdateTheme = function useUpdateTheme(themeId) {
|
|
160
|
+
var queryClient = useQueryClient();
|
|
147
161
|
return useMutationWithInvalidation(function (payload) {
|
|
148
162
|
return themesApi.update({
|
|
149
163
|
id: themeId,
|
|
150
164
|
payload: payload
|
|
151
165
|
});
|
|
152
166
|
}, {
|
|
153
|
-
keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.THEME_DETAILS, themeId], [QUERY_KEYS.GLOBAL_THEME_DETAILS]]
|
|
167
|
+
keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS], [QUERY_KEYS.THEME_DETAILS, themeId], [QUERY_KEYS.GLOBAL_THEME_DETAILS]],
|
|
168
|
+
onSuccess: function onSuccess(_ref) {
|
|
169
|
+
var theme = _ref.theme;
|
|
170
|
+
queryClient.setQueryData([QUERY_KEYS.THEME_DETAILS, themeId], theme);
|
|
171
|
+
}
|
|
154
172
|
});
|
|
155
173
|
};
|
|
156
174
|
var useDeleteTheme = function useDeleteTheme() {
|
|
@@ -163,8 +181,8 @@ var useCloneTheme = function useCloneTheme() {
|
|
|
163
181
|
keysToInvalidate: [QUERY_KEYS.THEMES_LIST]
|
|
164
182
|
});
|
|
165
183
|
};
|
|
166
|
-
var useApplyTheme = function useApplyTheme(
|
|
167
|
-
var onSuccess =
|
|
184
|
+
var useApplyTheme = function useApplyTheme(_ref2) {
|
|
185
|
+
var onSuccess = _ref2.onSuccess;
|
|
168
186
|
return useMutationWithInvalidation(themesApi.apply, {
|
|
169
187
|
keysToInvalidate: [[QUERY_KEYS.THEMES_LIST], [QUERY_KEYS.THEME_ENTITY_DETAILS]],
|
|
170
188
|
onSuccess: onSuccess
|
|
@@ -176,6 +194,14 @@ var useApplyGlobalTheme = function useApplyGlobalTheme() {
|
|
|
176
194
|
});
|
|
177
195
|
};
|
|
178
196
|
|
|
197
|
+
var routes = {
|
|
198
|
+
themes: {
|
|
199
|
+
index: "/themes",
|
|
200
|
+
edit: "/themes/:themeId/edit",
|
|
201
|
+
"new": "/themes/new"
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
179
205
|
var show = function show(entityType) {
|
|
180
206
|
return axios.get("".concat(BASE_URL, "/api/v1/global_theme"), {
|
|
181
207
|
params: {
|
|
@@ -340,9 +366,34 @@ var Card$2 = function Card(_ref) {
|
|
|
340
366
|
});
|
|
341
367
|
};
|
|
342
368
|
|
|
369
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
370
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
371
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
343
372
|
var isScreenCustomCSS = function isScreenCustomCSS(screen) {
|
|
344
373
|
return screen === DESIGN_SCREENS.CustomCSS;
|
|
345
374
|
};
|
|
375
|
+
var buildPathname = function buildPathname(route) {
|
|
376
|
+
var pathname = "";
|
|
377
|
+
var _iterator = _createForOfIteratorHelper(location.pathname.split("/")),
|
|
378
|
+
_step;
|
|
379
|
+
try {
|
|
380
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
381
|
+
var segment = _step.value;
|
|
382
|
+
if (isEmpty(segment)) {
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (segment === "themes") {
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
pathname += "/".concat(segment);
|
|
389
|
+
}
|
|
390
|
+
} catch (err) {
|
|
391
|
+
_iterator.e(err);
|
|
392
|
+
} finally {
|
|
393
|
+
_iterator.f();
|
|
394
|
+
}
|
|
395
|
+
return "".concat(pathname).concat(route);
|
|
396
|
+
};
|
|
346
397
|
|
|
347
398
|
var CustomCSS = function CustomCSS(_ref) {
|
|
348
399
|
var onEditCSSClick = _ref.onEditCSSClick,
|
|
@@ -1122,17 +1173,17 @@ var ThemeMeta = withT(function (_ref) {
|
|
|
1122
1173
|
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; }
|
|
1123
1174
|
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; }
|
|
1124
1175
|
var Customize = function Customize(_ref) {
|
|
1125
|
-
var
|
|
1126
|
-
theme = _ref.theme,
|
|
1176
|
+
var theme = _ref.theme,
|
|
1127
1177
|
onCreateTheme = _ref.onCreateTheme,
|
|
1128
1178
|
onApplyTheme = _ref.onApplyTheme,
|
|
1179
|
+
onUpdateTheme = _ref.onUpdateTheme,
|
|
1129
1180
|
isApplyingTheme = _ref.isApplyingTheme,
|
|
1130
1181
|
onPropertiesChange = _ref.onPropertiesChange,
|
|
1131
|
-
onUpdateThemeSuccess = _ref.onUpdateThemeSuccess,
|
|
1132
1182
|
onEditCSSClick = _ref.onEditCSSClick,
|
|
1133
1183
|
currentScreen = _ref.currentScreen;
|
|
1134
1184
|
var _useTranslation = useTranslation(),
|
|
1135
1185
|
t = _useTranslation.t;
|
|
1186
|
+
var history = useHistory();
|
|
1136
1187
|
var _useState = useState({}),
|
|
1137
1188
|
_useState2 = _slicedToArray(_useState, 2),
|
|
1138
1189
|
popoverInstance = _useState2[0],
|
|
@@ -1145,15 +1196,29 @@ var Customize = function Customize(_ref) {
|
|
|
1145
1196
|
}, shallow),
|
|
1146
1197
|
themePropertiesSchema = _useConfigStore.themePropertiesSchema,
|
|
1147
1198
|
entityType = _useConfigStore.entityType;
|
|
1148
|
-
var
|
|
1149
|
-
|
|
1150
|
-
|
|
1199
|
+
var _useParams = useParams(),
|
|
1200
|
+
themeId = _useParams.themeId;
|
|
1201
|
+
var _useThemeStore = useThemeStore(function (store) {
|
|
1202
|
+
return {
|
|
1203
|
+
currentTheme: store["currentTheme"],
|
|
1204
|
+
setThemeState: store["setThemeState"]
|
|
1205
|
+
};
|
|
1206
|
+
}, shallow),
|
|
1207
|
+
currentTheme = _useThemeStore.currentTheme,
|
|
1208
|
+
setThemeState = _useThemeStore.setThemeState;
|
|
1151
1209
|
var _useShowGlobalTheme = useShowGlobalTheme(entityType),
|
|
1152
1210
|
_useShowGlobalTheme$d = _useShowGlobalTheme.data,
|
|
1153
1211
|
_useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
|
|
1154
1212
|
_useShowGlobalTheme$d3 = _useShowGlobalTheme$d2.globalTheme,
|
|
1155
1213
|
globalTheme = _useShowGlobalTheme$d3 === void 0 ? {} : _useShowGlobalTheme$d3;
|
|
1156
|
-
var
|
|
1214
|
+
var _useFetchTheme = useFetchTheme(themeId, {
|
|
1215
|
+
enabled: isEditThemeRoute() && isNotNil(themeId),
|
|
1216
|
+
initialData: theme !== null && theme !== void 0 ? theme : undefined
|
|
1217
|
+
}),
|
|
1218
|
+
_useFetchTheme$data = _useFetchTheme.data,
|
|
1219
|
+
themeData = _useFetchTheme$data === void 0 ? {} : _useFetchTheme$data,
|
|
1220
|
+
isLoading = _useFetchTheme.isLoading;
|
|
1221
|
+
var isThemeGlobalTheme = themeId && (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
|
|
1157
1222
|
var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
|
|
1158
1223
|
var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
|
|
1159
1224
|
var submitBtnRef = useRef(null);
|
|
@@ -1185,25 +1250,35 @@ var Customize = function Customize(_ref) {
|
|
|
1185
1250
|
values: theme
|
|
1186
1251
|
});
|
|
1187
1252
|
onCreateTheme(theme);
|
|
1253
|
+
history.replace(buildUrl(buildPathname(routes.themes.edit), {
|
|
1254
|
+
themeId: theme.id
|
|
1255
|
+
}));
|
|
1188
1256
|
}
|
|
1189
1257
|
});
|
|
1190
1258
|
}
|
|
1191
1259
|
return updateTheme(themeToSave, {
|
|
1192
1260
|
onSuccess: function onSuccess(_ref4) {
|
|
1193
1261
|
var theme = _ref4.theme;
|
|
1194
|
-
|
|
1195
|
-
setThemeState({
|
|
1196
|
-
previewingTheme: theme
|
|
1197
|
-
});
|
|
1262
|
+
onUpdateTheme(theme);
|
|
1198
1263
|
resetForm({
|
|
1199
1264
|
values: theme
|
|
1200
1265
|
});
|
|
1201
1266
|
}
|
|
1202
1267
|
});
|
|
1203
1268
|
};
|
|
1269
|
+
useEffect(function () {
|
|
1270
|
+
if (isNotNil(themeId) && !isLoading) {
|
|
1271
|
+
setThemeState({
|
|
1272
|
+
previewingTheme: themeData
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
}, [themeData, isLoading]);
|
|
1276
|
+
if (isLoading) {
|
|
1277
|
+
return /*#__PURE__*/jsx(PageLoader, {});
|
|
1278
|
+
}
|
|
1204
1279
|
return /*#__PURE__*/jsx(Form, {
|
|
1205
1280
|
formikProps: {
|
|
1206
|
-
initialValues: _objectSpread$1(_objectSpread$1({}, buildInitialValues(
|
|
1281
|
+
initialValues: _objectSpread$1(_objectSpread$1({}, buildInitialValues(themeData, themePropertiesSchema)), {}, {
|
|
1207
1282
|
shouldSetAsGlobalTheme: isThemeGlobalTheme,
|
|
1208
1283
|
entityType: entityType
|
|
1209
1284
|
}),
|
|
@@ -1219,7 +1294,7 @@ var Customize = function Customize(_ref) {
|
|
|
1219
1294
|
className: "neeto-themes-sidebar__scroll",
|
|
1220
1295
|
children: [/*#__PURE__*/jsxs("div", {
|
|
1221
1296
|
className: "neeto-themes-sidebar__scroll-content flex flex-grow flex-col px-4 pb-4 lg:px-5",
|
|
1222
|
-
children: [/*#__PURE__*/jsx(ThemeMeta, {
|
|
1297
|
+
children: [!isSubmitting && /*#__PURE__*/jsx(BlockNavigation, {}), /*#__PURE__*/jsx(ThemeMeta, {
|
|
1223
1298
|
className: classnames({
|
|
1224
1299
|
hidden: isCustomCssScreen
|
|
1225
1300
|
})
|
|
@@ -1279,7 +1354,7 @@ var Customize = function Customize(_ref) {
|
|
|
1279
1354
|
type: "reset"
|
|
1280
1355
|
}), /*#__PURE__*/jsx(Button, {
|
|
1281
1356
|
"data-cy": "save-changes-button",
|
|
1282
|
-
disabled: !dirty && (
|
|
1357
|
+
disabled: !dirty && (themeData === null || themeData === void 0 ? void 0 : themeData.id) || isSubmitting,
|
|
1283
1358
|
label: t("neetoThemes.buttons.save"),
|
|
1284
1359
|
loading: isSubmitting,
|
|
1285
1360
|
ref: submitBtnRef,
|
|
@@ -1321,7 +1396,7 @@ var Customize = function Customize(_ref) {
|
|
|
1321
1396
|
label: t("neetoThemes.buttons.applyThisTheme"),
|
|
1322
1397
|
loading: isApplyingTheme,
|
|
1323
1398
|
onClick: function onClick() {
|
|
1324
|
-
return onApplyTheme(
|
|
1399
|
+
return onApplyTheme(themeData);
|
|
1325
1400
|
}
|
|
1326
1401
|
})]
|
|
1327
1402
|
}),
|
|
@@ -1802,11 +1877,16 @@ var Themes = function Themes(_ref) {
|
|
|
1802
1877
|
var TitleBar = function TitleBar(_ref) {
|
|
1803
1878
|
var currentScreen = _ref.currentScreen,
|
|
1804
1879
|
handleBackPress = _ref.handleBackPress,
|
|
1805
|
-
handleCreateNewTheme = _ref.handleCreateNewTheme
|
|
1806
|
-
isNewTheme = _ref.isNewTheme,
|
|
1807
|
-
themeToEdit = _ref.themeToEdit;
|
|
1880
|
+
handleCreateNewTheme = _ref.handleCreateNewTheme;
|
|
1808
1881
|
var _useTranslation = useTranslation(),
|
|
1809
1882
|
t = _useTranslation.t;
|
|
1883
|
+
var _useThemeStore = useThemeStore(function (store) {
|
|
1884
|
+
return {
|
|
1885
|
+
previewingTheme: store["previewingTheme"]
|
|
1886
|
+
};
|
|
1887
|
+
}, shallow),
|
|
1888
|
+
previewingTheme = _useThemeStore.previewingTheme;
|
|
1889
|
+
var themeId = previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id;
|
|
1810
1890
|
var _useConfigStore = useConfigStore(function (store) {
|
|
1811
1891
|
return {
|
|
1812
1892
|
entityType: store["entityType"],
|
|
@@ -1815,68 +1895,69 @@ var TitleBar = function TitleBar(_ref) {
|
|
|
1815
1895
|
}, shallow),
|
|
1816
1896
|
entityType = _useConfigStore.entityType,
|
|
1817
1897
|
helpDocUrl = _useConfigStore.helpDocUrl;
|
|
1898
|
+
var isCustomizeScreen = isEditThemeRoute() || isNewThemeRoute();
|
|
1818
1899
|
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
1819
|
-
if (
|
|
1900
|
+
if (isCustomizeScreen) {
|
|
1820
1901
|
return /*#__PURE__*/jsx("div", {
|
|
1821
|
-
className: "neeto-themes-sidebar__header px-
|
|
1902
|
+
className: "neeto-themes-sidebar__header px-4",
|
|
1822
1903
|
children: /*#__PURE__*/jsxs("div", {
|
|
1823
|
-
className: "flex items-center justify-
|
|
1824
|
-
children: [/*#__PURE__*/
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
}
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
className: "self-end",
|
|
1843
|
-
children: /*#__PURE__*/jsx(Button, {
|
|
1844
|
-
"data-cy": "customize-themes-add-theme-button",
|
|
1845
|
-
icon: Plus,
|
|
1846
|
-
iconPosition: "left",
|
|
1847
|
-
style: "text",
|
|
1848
|
-
tooltipProps: {
|
|
1849
|
-
content: t("neetoThemes.buttons.addNewTheme"),
|
|
1850
|
-
position: "top"
|
|
1851
|
-
},
|
|
1852
|
-
onClick: handleCreateNewTheme
|
|
1853
|
-
})
|
|
1904
|
+
className: "flex items-center justify-start space-x-2",
|
|
1905
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
1906
|
+
"data-cy": "customize-themes-back-button",
|
|
1907
|
+
icon: LeftArrow,
|
|
1908
|
+
iconPosition: "left",
|
|
1909
|
+
style: "text",
|
|
1910
|
+
tooltipProps: {
|
|
1911
|
+
content: isCustomCssScreen ? t("neetoThemes.buttons.backToEdit") : t("neetoThemes.buttons.backToThemes"),
|
|
1912
|
+
position: "top"
|
|
1913
|
+
},
|
|
1914
|
+
onClick: function onClick() {
|
|
1915
|
+
return handleBackPress(themeId);
|
|
1916
|
+
}
|
|
1917
|
+
}), /*#__PURE__*/jsxs(Typography, {
|
|
1918
|
+
"data-cy": "themes-header",
|
|
1919
|
+
lineHeight: "normal",
|
|
1920
|
+
style: "h3",
|
|
1921
|
+
weight: "semibold",
|
|
1922
|
+
children: [isCustomizeScreen && (isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
|
|
1854
1923
|
})]
|
|
1855
1924
|
})
|
|
1856
1925
|
});
|
|
1857
1926
|
}
|
|
1858
1927
|
return /*#__PURE__*/jsx("div", {
|
|
1859
|
-
className: "neeto-themes-sidebar__header px-
|
|
1928
|
+
className: "neeto-themes-sidebar__header px-6 lg:px-5 xl:px-6",
|
|
1860
1929
|
children: /*#__PURE__*/jsxs("div", {
|
|
1861
|
-
className: "flex items-center justify-
|
|
1862
|
-
children: [/*#__PURE__*/
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
},
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1930
|
+
className: "flex items-center justify-between space-x-2",
|
|
1931
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
1932
|
+
className: "flex space-x-2",
|
|
1933
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
1934
|
+
"data-cy": "themes-header",
|
|
1935
|
+
lineHeight: "normal",
|
|
1936
|
+
style: "h3",
|
|
1937
|
+
weight: "semibold",
|
|
1938
|
+
children: t("neetoThemes.build.leftSideBar.headerTabs.themes")
|
|
1939
|
+
}), /*#__PURE__*/jsx(HelpPopover, {
|
|
1940
|
+
helpLinkProps: helpDocUrl && {
|
|
1941
|
+
href: helpDocUrl
|
|
1942
|
+
},
|
|
1943
|
+
title: t("neetoThemes.build.leftSideBar.helpPopover.title"),
|
|
1944
|
+
description: t("neetoThemes.build.leftSideBar.helpPopover.description", {
|
|
1945
|
+
entityType: entityType
|
|
1946
|
+
})
|
|
1947
|
+
})]
|
|
1948
|
+
}), /*#__PURE__*/jsx("div", {
|
|
1949
|
+
className: "self-end",
|
|
1950
|
+
children: /*#__PURE__*/jsx(Button, {
|
|
1951
|
+
"data-cy": "customize-themes-add-theme-button",
|
|
1952
|
+
icon: Plus,
|
|
1953
|
+
iconPosition: "left",
|
|
1954
|
+
style: "text",
|
|
1955
|
+
tooltipProps: {
|
|
1956
|
+
content: t("neetoThemes.buttons.addNewTheme"),
|
|
1957
|
+
position: "top"
|
|
1958
|
+
},
|
|
1959
|
+
onClick: handleCreateNewTheme
|
|
1960
|
+
})
|
|
1880
1961
|
})]
|
|
1881
1962
|
})
|
|
1882
1963
|
});
|
|
@@ -1884,7 +1965,7 @@ var TitleBar = function TitleBar(_ref) {
|
|
|
1884
1965
|
|
|
1885
1966
|
var MemoizedAlert = /*#__PURE__*/memo(Alert);
|
|
1886
1967
|
var Sidebar = function Sidebar(_ref) {
|
|
1887
|
-
var
|
|
1968
|
+
var _themeToDelete$curren2, _themeToDelete$curren3, _themeToDelete$curren4;
|
|
1888
1969
|
var thumbnail = _ref.thumbnail,
|
|
1889
1970
|
onPropertiesChange = _ref.onPropertiesChange,
|
|
1890
1971
|
onApplyThemeSuccess = _ref.onApplyThemeSuccess,
|
|
@@ -1913,6 +1994,7 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1913
1994
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
1914
1995
|
isThemesSidebarCollapsed = _useState10[0],
|
|
1915
1996
|
setIsThemesSidebarCollapsed = _useState10[1];
|
|
1997
|
+
var history = useHistory();
|
|
1916
1998
|
useEffect(function () {
|
|
1917
1999
|
setIsThemesSidebarCollapsed(!isLargerScreen);
|
|
1918
2000
|
}, [isLargerScreen]);
|
|
@@ -1974,9 +2056,14 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1974
2056
|
var themeToDelete = useRef(null);
|
|
1975
2057
|
var themeToEdit = useRef(null);
|
|
1976
2058
|
var isCustomCssScreen = isScreenCustomCSS(currentScreen);
|
|
2059
|
+
var handleCreateNewTheme = function handleCreateNewTheme() {
|
|
2060
|
+
history.push(buildUrl(buildPathname(routes.themes["new"])));
|
|
2061
|
+
};
|
|
1977
2062
|
var handleEditTheme = function handleEditTheme(theme) {
|
|
1978
2063
|
themeToEdit.current = theme;
|
|
1979
|
-
|
|
2064
|
+
history.push(buildUrl(buildPathname(routes.themes.edit), {
|
|
2065
|
+
themeId: theme.id
|
|
2066
|
+
}));
|
|
1980
2067
|
};
|
|
1981
2068
|
var onApplyTheme = function onApplyTheme(theme) {
|
|
1982
2069
|
if (isApplyingTheme) return;
|
|
@@ -1987,23 +2074,26 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
1987
2074
|
entityType: entityType
|
|
1988
2075
|
});
|
|
1989
2076
|
};
|
|
1990
|
-
var
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
setThemeState({
|
|
1994
|
-
previewingTheme: currentTheme
|
|
1995
|
-
});
|
|
1996
|
-
setCurrentScreen(isCustomCssScreen ? DESIGN_SCREENS.Customize : DESIGN_SCREENS.THEMES);
|
|
2077
|
+
var navigateToThemesScreen = function navigateToThemesScreen(themeId) {
|
|
2078
|
+
highlightTheme(isPresent(themeId) ? themeId : currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
|
|
2079
|
+
history.push(buildUrl(buildPathname(routes.themes.index)));
|
|
1997
2080
|
themeToEdit.current = null;
|
|
1998
2081
|
};
|
|
1999
|
-
var
|
|
2082
|
+
var handleBackPress = function handleBackPress(themeId) {
|
|
2083
|
+
if (isCustomCssScreen) {
|
|
2084
|
+
setCurrentScreen(DESIGN_SCREENS.Customize);
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
navigateToThemesScreen(themeId);
|
|
2088
|
+
};
|
|
2089
|
+
var highlightTheme = function highlightTheme(themeIdToHighlight) {
|
|
2000
2090
|
setTimeout(function () {
|
|
2001
|
-
scrollElementIntoView(
|
|
2091
|
+
scrollElementIntoView(themeIdToHighlight);
|
|
2002
2092
|
}, 1500);
|
|
2003
2093
|
setTimeout(function () {
|
|
2004
2094
|
setThemeToHighlight(null);
|
|
2005
2095
|
}, 4000);
|
|
2006
|
-
setThemeToHighlight(
|
|
2096
|
+
setThemeToHighlight(themeIdToHighlight);
|
|
2007
2097
|
};
|
|
2008
2098
|
var onCreateTheme = function onCreateTheme(createdTheme) {
|
|
2009
2099
|
themeToEdit.current = createdTheme;
|
|
@@ -2012,6 +2102,10 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
2012
2102
|
previewingTheme: createdTheme
|
|
2013
2103
|
});
|
|
2014
2104
|
};
|
|
2105
|
+
var onUpdateTheme = function onUpdateTheme(updatedTheme) {
|
|
2106
|
+
themeToEdit.current = updatedTheme;
|
|
2107
|
+
onUpdateThemeSuccess === null || onUpdateThemeSuccess === void 0 ? void 0 : onUpdateThemeSuccess(updatedTheme);
|
|
2108
|
+
};
|
|
2015
2109
|
var handleDelete = function handleDelete(themeId, name, appliedCount) {
|
|
2016
2110
|
setIsDeleteAlertOpen(true);
|
|
2017
2111
|
themeToDelete.current = {
|
|
@@ -2048,37 +2142,59 @@ var Sidebar = function Sidebar(_ref) {
|
|
|
2048
2142
|
children: [/*#__PURE__*/jsx(TitleBar, {
|
|
2049
2143
|
currentScreen: currentScreen,
|
|
2050
2144
|
handleBackPress: handleBackPress,
|
|
2051
|
-
handleCreateNewTheme:
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2145
|
+
handleCreateNewTheme: handleCreateNewTheme
|
|
2146
|
+
}), /*#__PURE__*/jsxs(Switch$1, {
|
|
2147
|
+
children: [/*#__PURE__*/jsx(Route, {
|
|
2148
|
+
exact: true,
|
|
2149
|
+
path: buildPathname(routes.themes.index),
|
|
2150
|
+
render: function render() {
|
|
2151
|
+
return /*#__PURE__*/jsx(Themes, {
|
|
2152
|
+
currentTheme: currentTheme,
|
|
2153
|
+
defaultThemes: defaultThemes,
|
|
2154
|
+
didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
|
|
2155
|
+
highlightTheme: highlightTheme,
|
|
2156
|
+
isApplyingTheme: isApplyingTheme,
|
|
2157
|
+
isCurrentThemeLoading: isCurrentThemeLoading,
|
|
2158
|
+
onApplyGlobalThemeSuccess: onApplyGlobalThemeSuccess,
|
|
2159
|
+
onApplyTheme: onApplyTheme,
|
|
2160
|
+
themeBeingApplied: themeBeingApplied,
|
|
2161
|
+
themeToHighlight: themeToHighlight,
|
|
2162
|
+
themes: themes,
|
|
2163
|
+
thumbnail: thumbnail,
|
|
2164
|
+
isLoading: isLoading || isFetchingSchema,
|
|
2165
|
+
onDeleteTheme: handleDelete,
|
|
2166
|
+
onEditTheme: handleEditTheme
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
}), /*#__PURE__*/jsx(Route, {
|
|
2170
|
+
path: buildPathname(routes.themes["new"]),
|
|
2171
|
+
render: function render() {
|
|
2172
|
+
return /*#__PURE__*/jsx(Customize, {
|
|
2173
|
+
currentScreen: currentScreen,
|
|
2174
|
+
isApplyingTheme: isApplyingTheme,
|
|
2175
|
+
onApplyTheme: onApplyTheme,
|
|
2176
|
+
onCreateTheme: onCreateTheme,
|
|
2177
|
+
onPropertiesChange: onPropertiesChange,
|
|
2178
|
+
onUpdateTheme: onUpdateTheme,
|
|
2179
|
+
theme: themeToEdit.current,
|
|
2180
|
+
onEditCSSClick: setCurrentScreen
|
|
2181
|
+
});
|
|
2182
|
+
}
|
|
2183
|
+
}), /*#__PURE__*/jsx(Route, {
|
|
2184
|
+
path: buildPathname(routes.themes.edit),
|
|
2185
|
+
render: function render() {
|
|
2186
|
+
return /*#__PURE__*/jsx(Customize, {
|
|
2187
|
+
currentScreen: currentScreen,
|
|
2188
|
+
isApplyingTheme: isApplyingTheme,
|
|
2189
|
+
onApplyTheme: onApplyTheme,
|
|
2190
|
+
onCreateTheme: onCreateTheme,
|
|
2191
|
+
onPropertiesChange: onPropertiesChange,
|
|
2192
|
+
onUpdateTheme: onUpdateTheme,
|
|
2193
|
+
theme: themeToEdit.current,
|
|
2194
|
+
onEditCSSClick: setCurrentScreen
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
})]
|
|
2082
2198
|
}), /*#__PURE__*/jsx(MemoizedAlert, {
|
|
2083
2199
|
isOpen: isDeleteAlertOpen,
|
|
2084
2200
|
isSubmitting: isDeleting,
|
|
@@ -2152,7 +2268,9 @@ var NeetoThemesBuilder = function NeetoThemesBuilder(_ref) {
|
|
|
2152
2268
|
});
|
|
2153
2269
|
}, []);
|
|
2154
2270
|
useEffect(function () {
|
|
2155
|
-
if (isNotPresent(currentTheme))
|
|
2271
|
+
if (isNotPresent(currentTheme) || isEditThemeRoute()) {
|
|
2272
|
+
return;
|
|
2273
|
+
}
|
|
2156
2274
|
setThemeState({
|
|
2157
2275
|
previewingTheme: currentTheme
|
|
2158
2276
|
});
|