@bigbinary/neeto-themes-frontend 4.2.2 → 4.2.4-beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/app/javascript/src/translations/ar.json +1 -1
  2. package/app/javascript/src/translations/bg.json +1 -1
  3. package/app/javascript/src/translations/ca.json +1 -1
  4. package/app/javascript/src/translations/cs.json +1 -1
  5. package/app/javascript/src/translations/da.json +1 -1
  6. package/app/javascript/src/translations/de.json +1 -1
  7. package/app/javascript/src/translations/en.json +2 -0
  8. package/app/javascript/src/translations/es-MX.json +1 -1
  9. package/app/javascript/src/translations/es.json +1 -1
  10. package/app/javascript/src/translations/et.json +1 -1
  11. package/app/javascript/src/translations/fi.json +1 -1
  12. package/app/javascript/src/translations/fil.json +1 -1
  13. package/app/javascript/src/translations/fr.json +1 -1
  14. package/app/javascript/src/translations/he.json +1 -1
  15. package/app/javascript/src/translations/hi.json +1 -1
  16. package/app/javascript/src/translations/hr.json +1 -1
  17. package/app/javascript/src/translations/hu.json +1 -1
  18. package/app/javascript/src/translations/id.json +1 -1
  19. package/app/javascript/src/translations/it.json +1 -1
  20. package/app/javascript/src/translations/ja.json +1 -1
  21. package/app/javascript/src/translations/ko.json +1 -1
  22. package/app/javascript/src/translations/lv.json +1 -1
  23. package/app/javascript/src/translations/nl.json +1 -1
  24. package/app/javascript/src/translations/pl.json +1 -1
  25. package/app/javascript/src/translations/pt-BR.json +1 -1
  26. package/app/javascript/src/translations/pt.json +1 -1
  27. package/app/javascript/src/translations/ro.json +1 -1
  28. package/app/javascript/src/translations/ru.json +1 -1
  29. package/app/javascript/src/translations/sk.json +1 -1
  30. package/app/javascript/src/translations/sl.json +1 -1
  31. package/app/javascript/src/translations/sv.json +1 -1
  32. package/app/javascript/src/translations/th.json +1 -1
  33. package/app/javascript/src/translations/tr.json +1 -1
  34. package/app/javascript/src/translations/uk.json +1 -1
  35. package/app/javascript/src/translations/vi.json +1 -1
  36. package/app/javascript/src/translations/zh-CN.json +1 -1
  37. package/app/javascript/src/translations/zh-TW.json +1 -1
  38. package/dist/.ready +1 -1
  39. package/dist/NeetoThemesBuilder.js +184 -86
  40. package/dist/NeetoThemesBuilder.js.map +1 -1
  41. package/dist/cjs/NeetoThemesBuilder.js +183 -85
  42. package/dist/cjs/NeetoThemesBuilder.js.map +1 -1
  43. package/dist/cjs/index.js +2 -1
  44. package/dist/cjs/index.js.map +1 -1
  45. package/dist/cjs/v2/NeetoThemesBuilder.js +182 -82
  46. package/dist/cjs/v2/NeetoThemesBuilder.js.map +1 -1
  47. package/dist/cjs/v2/index.js +1 -1
  48. package/dist/index.js +2 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/{useGlobalThemesApi-C-jx4UaU.js → useGlobalThemesApi-D04VWBoL.js} +39 -42
  51. package/dist/{useGlobalThemesApi-C-jx4UaU.js.map → useGlobalThemesApi-D04VWBoL.js.map} +1 -1
  52. package/dist/{useGlobalThemesApi-BUWGKtCL.js → useGlobalThemesApi-gt4U6XWZ.js} +38 -42
  53. package/dist/{useGlobalThemesApi-BUWGKtCL.js.map → useGlobalThemesApi-gt4U6XWZ.js.map} +1 -1
  54. package/dist/v2/NeetoThemesBuilder.js +184 -84
  55. package/dist/v2/NeetoThemesBuilder.js.map +1 -1
  56. package/dist/v2/index.js +1 -1
  57. package/package.json +13 -13
@@ -1,10 +1,10 @@
1
1
  import { shallow } from 'zustand/shallow';
2
2
  import { Suspense, lazy, useId, useEffect, createElement, useState, memo, useRef, useCallback, useMemo } from 'react';
3
- import { Toastr, Spinner, Typography, Button, Label, ColorPicker, Select, Slider, Checkbox, Switch, Input, Tooltip, Popover, Alert } from '@bigbinary/neeto-atoms';
3
+ import { Toastr, Spinner, Typography, Button, Label, ColorPicker, Select, Slider, Checkbox, Switch, Input, Tooltip, Popover, Badge, Alert } from '@bigbinary/neeto-atoms';
4
4
  import { hyphenate, isPresent, findBy, findIndexBy, isNot, filterBy, snakeToCamelCase, isNotPresent, toLabelAndValue, capitalize, humanize, isNotEmpty, noop } from '@bigbinary/neeto-cist';
5
5
  import { useQueryParams, useBreakpoints, PageTitle } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
6
6
  import { useTranslation, Trans } from 'react-i18next';
7
- import { n, u as useShowGlobalTheme, a as useFetchTheme, b as useCreateTheme, c as useUpdateTheme, d as routes, e as useCloneTheme, f as useApplyTheme, g as useListThemes, h as useShowThemeEntity, i as useDeleteTheme, r as registerNeetoThemesTranslations } from '../useGlobalThemesApi-C-jx4UaU.js';
7
+ import { n, u as useShowGlobalTheme, a as useFetchTheme, b as useListThemes, c as useCreateTheme, d as useUpdateTheme, e as useApplyTheme, f as routes, g as useShowThemeEntity, h as useDeleteTheme, r as registerNeetoThemesTranslations } from '../useGlobalThemesApi-D04VWBoL.js';
8
8
  import { a as useExpandedSection, b as useConfigStore, c as useThemeStore, u as useThemeUtils, d as useSyncExpandedSectionFromUrl } from '../useExpandedSection-MjgB7rh6.js';
9
9
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
10
10
  import _regeneratorRuntime from '@babel/runtime/regenerator';
@@ -15,7 +15,7 @@ import { joinHyphenCase, buildUrl } from '@bigbinary/neeto-commons-frontend/v2/u
15
15
  import { useHistory, useParams, Switch as Switch$1, Route } from 'react-router-dom';
16
16
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
17
17
  import { RadioGroup, Input as Input$1, Form, BlockNavigation } from '@bigbinary/neeto-atoms/formik';
18
- import { isEmpty, negate, isNotNil } from 'ramda';
18
+ import { isEmpty, omit, negate, isNotNil } from 'ramda';
19
19
  import i18n, { t } from 'i18next';
20
20
  import * as yup from 'yup';
21
21
  import { useFormikContext, Field } from 'formik';
@@ -741,6 +741,15 @@ var buildProperties = function buildProperties(values, condition, themePropertie
741
741
  return !imageKeys.has(dependsOn);
742
742
  });
743
743
  };
744
+ var buildSystemThemeCopy = function buildSystemThemeCopy(systemTheme) {
745
+ if (!systemTheme) return null;
746
+ return _objectSpread$2(_objectSpread$2({}, omit(["id"], systemTheme)), {}, {
747
+ name: t("neetoThemes.common.cloneName", {
748
+ name: systemTheme.name
749
+ }),
750
+ properties: systemTheme.properties.map(omit(["id", "themeId"]))
751
+ });
752
+ };
744
753
 
745
754
  var AlignmentBlock = withT(function (_ref) {
746
755
  var t = _ref.t,
@@ -1359,6 +1368,7 @@ var Customize = function Customize(_ref) {
1359
1368
  var theme = _ref.theme,
1360
1369
  onCreateTheme = _ref.onCreateTheme,
1361
1370
  onApplyTheme = _ref.onApplyTheme,
1371
+ onApplyThemeSuccess = _ref.onApplyThemeSuccess,
1362
1372
  onUpdateTheme = _ref.onUpdateTheme,
1363
1373
  isApplyingTheme = _ref.isApplyingTheme,
1364
1374
  onPropertiesChange = _ref.onPropertiesChange,
@@ -1377,6 +1387,7 @@ var Customize = function Customize(_ref) {
1377
1387
  var _useConfigStore = useConfigStore(function (store) {
1378
1388
  return {
1379
1389
  themePropertiesSchema: store["themePropertiesSchema"],
1390
+ entityId: store["entityId"],
1380
1391
  entityType: store["entityType"],
1381
1392
  isFetchingSchema: store["isFetchingSchema"],
1382
1393
  helpPopoverProps: store["helpPopoverProps"],
@@ -1385,6 +1396,7 @@ var Customize = function Customize(_ref) {
1385
1396
  };
1386
1397
  }, shallow),
1387
1398
  themePropertiesSchema = _useConfigStore.themePropertiesSchema,
1399
+ entityId = _useConfigStore.entityId,
1388
1400
  entityType = _useConfigStore.entityType,
1389
1401
  isFetchingSchema = _useConfigStore.isFetchingSchema,
1390
1402
  helpPopoverProps = _useConfigStore.helpPopoverProps,
@@ -1392,6 +1404,9 @@ var Customize = function Customize(_ref) {
1392
1404
  proFeatures = _useConfigStore.proFeatures;
1393
1405
  var _useParams = useParams(),
1394
1406
  themeId = _useParams.themeId;
1407
+ var _useQueryParams = useQueryParams(),
1408
+ sourceThemeId = _useQueryParams.source;
1409
+ var isCustomizingSystemTheme = !themeId && isPresent(sourceThemeId);
1395
1410
  var _useThemeStore = useThemeStore(function (store) {
1396
1411
  return {
1397
1412
  currentTheme: store["currentTheme"],
@@ -1412,22 +1427,75 @@ var Customize = function Customize(_ref) {
1412
1427
  _useFetchTheme$data = _useFetchTheme.data,
1413
1428
  themeData = _useFetchTheme$data === void 0 ? {} : _useFetchTheme$data,
1414
1429
  isLoadingTheme = _useFetchTheme.isLoadingTheme;
1415
- var isLoading = isFetchingSchema || isLoadingTheme;
1430
+ var _useListThemes = useListThemes(entityId),
1431
+ _useListThemes$data = _useListThemes.data,
1432
+ _useListThemes$data2 = _useListThemes$data === void 0 ? {} : _useListThemes$data,
1433
+ _useListThemes$data2$ = _useListThemes$data2.defaultThemes,
1434
+ defaultThemes = _useListThemes$data2$ === void 0 ? [] : _useListThemes$data2$,
1435
+ isLoadingSystemThemes = _useListThemes.isLoading;
1436
+ var themeToCustomize = isCustomizingSystemTheme ? buildSystemThemeCopy(findBy({
1437
+ id: sourceThemeId
1438
+ }, defaultThemes)) : themeData;
1439
+ var isLoading = isFetchingSchema || isLoadingTheme || isCustomizingSystemTheme && isLoadingSystemThemes;
1416
1440
  var isThemeGlobalTheme = themeId && (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === themeId;
1417
1441
  var isCurrentThemeAndGlobalThemeSame = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id);
1418
1442
  var _helpPopoverProps$sty = helpPopoverProps.style,
1419
1443
  styleHelpPopoverProps = _helpPopoverProps$sty === void 0 ? {} : _helpPopoverProps$sty;
1420
- var isEditingCurrentlyAppliedTheme = themeId === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1444
+ var isEditingCurrentlyAppliedTheme = (themeId !== null && themeId !== void 0 ? themeId : sourceThemeId) === (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id);
1421
1445
  var _useCreateTheme = useCreateTheme(),
1422
1446
  createTheme = _useCreateTheme.mutateAsync,
1423
1447
  isCreating = _useCreateTheme.isPending;
1424
1448
  var _useUpdateTheme = useUpdateTheme(themeId),
1425
1449
  updateTheme = _useUpdateTheme.mutateAsync,
1426
1450
  isUpdating = _useUpdateTheme.isPending;
1427
- var isSubmitting = isCreating || isUpdating;
1451
+ var _useApplyTheme = useApplyTheme({}),
1452
+ applyTheme = _useApplyTheme.mutateAsync,
1453
+ isApplyingCreatedTheme = _useApplyTheme.isPending;
1454
+ var isSubmitting = isCreating || isUpdating || isApplyingCreatedTheme;
1428
1455
  var isCustomCssScreen = isScreenCustomCSS(currentScreen);
1429
- var onSubmit = function onSubmit(values, _ref2) {
1430
- var resetForm = _ref2.resetForm;
1456
+ var createAndOpenTheme = /*#__PURE__*/function () {
1457
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeToSave, resetForm) {
1458
+ var _yield$createTheme, theme;
1459
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1460
+ while (1) switch (_context.prev = _context.next) {
1461
+ case 0:
1462
+ _context.next = 2;
1463
+ return createTheme(themeToSave);
1464
+ case 2:
1465
+ _yield$createTheme = _context.sent;
1466
+ theme = _yield$createTheme.theme;
1467
+ resetForm({
1468
+ values: theme
1469
+ });
1470
+ if (!isCustomizingSystemTheme) {
1471
+ _context.next = 9;
1472
+ break;
1473
+ }
1474
+ _context.next = 8;
1475
+ return applyTheme({
1476
+ themeId: theme.id,
1477
+ entityId: entityId,
1478
+ entityType: entityType
1479
+ });
1480
+ case 8:
1481
+ onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(theme);
1482
+ case 9:
1483
+ onCreateTheme(theme);
1484
+ history.replace(buildUrl(buildPathname(routes.themes.edit), {
1485
+ themeId: theme.id
1486
+ }));
1487
+ case 11:
1488
+ case "end":
1489
+ return _context.stop();
1490
+ }
1491
+ }, _callee);
1492
+ }));
1493
+ return function createAndOpenTheme(_x, _x2) {
1494
+ return _ref2.apply(this, arguments);
1495
+ };
1496
+ }();
1497
+ var onSubmit = function onSubmit(values, _ref3) {
1498
+ var resetForm = _ref3.resetForm;
1431
1499
  var imageData = buildImageData(values, themePropertiesSchema);
1432
1500
  var themeToSave = _objectSpread({
1433
1501
  propertiesAttributes: values.properties,
@@ -1435,20 +1503,7 @@ var Customize = function Customize(_ref) {
1435
1503
  shouldSetAsGlobalTheme: values.shouldSetAsGlobalTheme,
1436
1504
  entityType: values.entityType
1437
1505
  }, imageData);
1438
- if (!themeId) {
1439
- return createTheme(themeToSave, {
1440
- onSuccess: function onSuccess(_ref3) {
1441
- var theme = _ref3.theme;
1442
- resetForm({
1443
- values: theme
1444
- });
1445
- onCreateTheme(theme);
1446
- history.replace(buildUrl(buildPathname(routes.themes.edit), {
1447
- themeId: theme.id
1448
- }));
1449
- }
1450
- });
1451
- }
1506
+ if (!themeId) return createAndOpenTheme(themeToSave, resetForm);
1452
1507
  return updateTheme(themeToSave, {
1453
1508
  onSuccess: function onSuccess(_ref4) {
1454
1509
  var theme = _ref4.theme;
@@ -1474,7 +1529,7 @@ var Customize = function Customize(_ref) {
1474
1529
  }
1475
1530
  return /*#__PURE__*/jsx(Form, {
1476
1531
  formikProps: {
1477
- initialValues: _objectSpread(_objectSpread({}, buildInitialValues(themeData, themePropertiesSchema)), {}, {
1532
+ initialValues: _objectSpread(_objectSpread({}, buildInitialValues(themeToCustomize, themePropertiesSchema)), {}, {
1478
1533
  shouldSetAsGlobalTheme: isThemeGlobalTheme,
1479
1534
  entityType: entityType
1480
1535
  }),
@@ -1573,7 +1628,7 @@ var Customize = function Customize(_ref) {
1573
1628
  label: t("neetoThemes.buttons.save"),
1574
1629
  loading: isSubmitting,
1575
1630
  type: "submit",
1576
- disabled: !dirty && (themeData === null || themeData === void 0 ? void 0 : themeData.id) || isSubmitting || !isValid,
1631
+ disabled: !dirty && (themeToCustomize === null || themeToCustomize === void 0 ? void 0 : themeToCustomize.id) || isSubmitting || !isValid,
1577
1632
  onClick: function onClick() {
1578
1633
  if (isNotAppliedCondition) {
1579
1634
  setIsNotAppliedPopoverOpen(true);
@@ -1620,26 +1675,49 @@ var Customize = function Customize(_ref) {
1620
1675
  });
1621
1676
  };
1622
1677
 
1623
- var QuickActionRow = function QuickActionRow(_ref) {
1624
- var Icon = _ref.icon,
1678
+ var QuickActionRow = withT(function (_ref) {
1679
+ var t = _ref.t,
1680
+ Icon = _ref.icon,
1625
1681
  label = _ref.label,
1626
1682
  onClick = _ref.onClick,
1627
- testId = _ref.testId;
1628
- return /*#__PURE__*/jsxs("button", {
1629
- onClick: onClick,
1630
- className: "border-border hover:bg-muted flex w-full cursor-pointer items-center gap-2 border-t px-3 py-1.5 text-start transition-colors",
1631
- "data-testid": testId,
1632
- type: "button",
1633
- children: [/*#__PURE__*/jsx(Icon, {
1634
- className: "text-muted-foreground",
1635
- size: 16
1636
- }), /*#__PURE__*/jsx(Typography, {
1637
- className: "text-sm",
1638
- variant: "body2",
1639
- children: label
1640
- })]
1683
+ testId = _ref.testId,
1684
+ _ref$disabled = _ref.disabled,
1685
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
1686
+ disabledTooltip = _ref.disabledTooltip,
1687
+ _ref$isProFeature = _ref.isProFeature,
1688
+ isProFeature = _ref$isProFeature === void 0 ? false : _ref$isProFeature;
1689
+ return /*#__PURE__*/jsx(Tooltip, {
1690
+ content: disabledTooltip,
1691
+ disabled: !disabled || !disabledTooltip,
1692
+ position: "top",
1693
+ children: /*#__PURE__*/jsx("div", {
1694
+ className: "border-border border-t",
1695
+ children: /*#__PURE__*/jsxs("button", {
1696
+ disabled: disabled,
1697
+ onClick: onClick,
1698
+ "data-testid": testId,
1699
+ type: "button",
1700
+ className: classnames("flex w-full items-center gap-2 px-3 py-1.5 text-start transition-colors", {
1701
+ "hover:bg-muted cursor-pointer": !disabled,
1702
+ "cursor-not-allowed opacity-50": disabled
1703
+ }),
1704
+ children: [/*#__PURE__*/jsx(Icon, {
1705
+ className: "text-muted-foreground",
1706
+ size: 16
1707
+ }), /*#__PURE__*/jsx(Typography, {
1708
+ className: "text-sm",
1709
+ variant: "body2",
1710
+ children: label
1711
+ }), isProFeature && /*#__PURE__*/jsx(Badge, {
1712
+ "data-testid": "".concat(testId, "-pro-badge"),
1713
+ label: t("neetoThemes.common.pro"),
1714
+ size: "sm",
1715
+ variant: "purple-subtle"
1716
+ })]
1717
+ })
1718
+ })
1641
1719
  });
1642
- };
1720
+ });
1643
1721
 
1644
1722
  var Thumbnail = function Thumbnail(_ref) {
1645
1723
  var _theme$snakeToCamelCa, _findBy, _findBy2;
@@ -1728,7 +1806,7 @@ var Card$1 = function Card(_ref) {
1728
1806
  onEditTheme = _ref.onEditTheme,
1729
1807
  theme = _ref.theme,
1730
1808
  isApplyingTheme = _ref.isApplyingTheme,
1731
- onCloneTheme = _ref.onCloneTheme,
1809
+ onCustomizeSystemTheme = _ref.onCustomizeSystemTheme,
1732
1810
  isHighLightedTheme = _ref.isHighLightedTheme,
1733
1811
  isGlobalTheme = _ref.isGlobalTheme,
1734
1812
  onApplyTheme = _ref.onApplyTheme,
@@ -1737,22 +1815,32 @@ var Card$1 = function Card(_ref) {
1737
1815
  t = _useTranslation.t;
1738
1816
  var _useConfigStore = useConfigStore(function (store) {
1739
1817
  return {
1740
- themePropertiesSchema: store["themePropertiesSchema"]
1818
+ themePropertiesSchema: store["themePropertiesSchema"],
1819
+ enabledFeatures: store["enabledFeatures"],
1820
+ proFeatures: store["proFeatures"]
1741
1821
  };
1742
1822
  }, shallow),
1743
- themePropertiesSchema = _useConfigStore.themePropertiesSchema;
1823
+ themePropertiesSchema = _useConfigStore.themePropertiesSchema,
1824
+ enabledFeatures = _useConfigStore.enabledFeatures,
1825
+ proFeatures = _useConfigStore.proFeatures;
1744
1826
  var id = theme.id,
1745
1827
  name = theme.name;
1746
1828
  var imageProperties = filterBy({
1747
1829
  kind: "image"
1748
1830
  }, themePropertiesSchema);
1831
+ var isCustomCSSInSchema = isPresent(findBy({
1832
+ kind: "custom_css"
1833
+ }, themePropertiesSchema));
1834
+ var isCustomCSSEnabled = Boolean(enabledFeatures.customCSS);
1835
+ var isCustomCSSProFeature = Boolean(proFeatures.customCSS);
1836
+ var showCustomCSSAction = isCustomCSSInSchema && (isCustomCSSEnabled || isCustomCSSProFeature);
1749
1837
  var handleDeleteTheme = function handleDeleteTheme() {
1750
1838
  return onDeleteTheme(id, name);
1751
1839
  };
1752
1840
  var handleQuickEdit = function handleQuickEdit(section) {
1753
1841
  return function (e) {
1754
1842
  e.stopPropagation();
1755
- if (isPresent(onEditTheme)) onEditTheme(theme, section);else onCloneTheme(theme, section);
1843
+ if (isPresent(onEditTheme)) onEditTheme(theme, section);else onCustomizeSystemTheme(theme, section);
1756
1844
  };
1757
1845
  };
1758
1846
  var showMoreDropdown = isFunction(onDeleteTheme);
@@ -1885,10 +1973,13 @@ var Card$1 = function Card(_ref) {
1885
1973
  testId: "quick-add-".concat(hyphenate(key)),
1886
1974
  onClick: handleQuickEdit(camelKey)
1887
1975
  }, key);
1888
- }), /*#__PURE__*/jsx(QuickActionRow, {
1976
+ }), showCustomCSSAction && /*#__PURE__*/jsx(QuickActionRow, {
1977
+ disabled: !isCustomCSSEnabled,
1889
1978
  icon: Code,
1979
+ isProFeature: isCustomCSSProFeature,
1890
1980
  label: t("neetoThemes.build.leftSideBar.themes.customCSS"),
1891
1981
  testId: "quick-custom-css",
1982
+ disabledTooltip: t("neetoThemes.common.proFeature.customCSS.description"),
1892
1983
  onClick: handleQuickEdit("customcss")
1893
1984
  })]
1894
1985
  })]
@@ -1897,8 +1988,21 @@ var Card$1 = function Card(_ref) {
1897
1988
  };
1898
1989
  var Card = /*#__PURE__*/memo(Card$1);
1899
1990
 
1991
+ var SectionHeading = function SectionHeading(_ref) {
1992
+ var label = _ref.label,
1993
+ testId = _ref.testId;
1994
+ return /*#__PURE__*/jsx(Typography, {
1995
+ className: "px-6 text-xs font-semibold uppercase tracking-wide lg:px-5 xl:px-6",
1996
+ color: "muted",
1997
+ "data-testid": testId,
1998
+ variant: "body2",
1999
+ children: label
2000
+ });
2001
+ };
2002
+
1900
2003
  var Themes = function Themes(_ref) {
1901
2004
  var onEditTheme = _ref.onEditTheme,
2005
+ onCustomizeSystemTheme = _ref.onCustomizeSystemTheme,
1902
2006
  _ref$themes = _ref.themes,
1903
2007
  themes = _ref$themes === void 0 ? [] : _ref$themes,
1904
2008
  _ref$defaultThemes = _ref.defaultThemes,
@@ -1912,7 +2016,6 @@ var Themes = function Themes(_ref) {
1912
2016
  thumbnail = _ref.thumbnail,
1913
2017
  themeBeingApplied = _ref.themeBeingApplied,
1914
2018
  onApplyTheme = _ref.onApplyTheme,
1915
- onApplyThemeSuccess = _ref.onApplyThemeSuccess,
1916
2019
  _ref$isSearchVisible = _ref.isSearchVisible,
1917
2020
  isSearchVisible = _ref$isSearchVisible === void 0 ? false : _ref$isSearchVisible;
1918
2021
  var _useTranslation = useTranslation(),
@@ -1929,19 +2032,13 @@ var Themes = function Themes(_ref) {
1929
2032
  previewingTheme = _useThemeStore.previewingTheme;
1930
2033
  var _useConfigStore = useConfigStore(function (store) {
1931
2034
  return {
1932
- entityType: store["entityType"],
1933
- entityId: store["entityId"]
2035
+ entityType: store["entityType"]
1934
2036
  };
1935
2037
  }, shallow),
1936
- entityType = _useConfigStore.entityType,
1937
- entityId = _useConfigStore.entityId;
2038
+ entityType = _useConfigStore.entityType;
1938
2039
  var _useQueryParams = useQueryParams(),
1939
2040
  _useQueryParams$searc = _useQueryParams.searchTerm,
1940
2041
  searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
1941
- var _useCloneTheme = useCloneTheme(),
1942
- cloneTheme = _useCloneTheme.mutate;
1943
- var _useApplyTheme = useApplyTheme({}),
1944
- applyClonedTheme = _useApplyTheme.mutate;
1945
2042
  var _useShowGlobalTheme = useShowGlobalTheme(entityType),
1946
2043
  _useShowGlobalTheme$d = _useShowGlobalTheme.data,
1947
2044
  _useShowGlobalTheme$d2 = _useShowGlobalTheme$d === void 0 ? {} : _useShowGlobalTheme$d,
@@ -1979,23 +2076,7 @@ var Themes = function Themes(_ref) {
1979
2076
  return theme.id !== activeThemeId && matchesSearch(theme);
1980
2077
  });
1981
2078
  var showActiveThemeSection = activeTheme && matchesSearch(activeTheme);
1982
- var handleCloneTheme = function handleCloneTheme(data, section) {
1983
- cloneTheme(data.id, {
1984
- onSuccess: function onSuccess(_ref2) {
1985
- var clonedTheme = _ref2.theme;
1986
- applyClonedTheme({
1987
- themeId: clonedTheme.id,
1988
- entityId: entityId,
1989
- entityType: entityType
1990
- }, {
1991
- onSuccess: function onSuccess() {
1992
- onApplyThemeSuccess === null || onApplyThemeSuccess === void 0 || onApplyThemeSuccess(clonedTheme);
1993
- onEditTheme(clonedTheme, section);
1994
- }
1995
- });
1996
- }
1997
- });
1998
- };
2079
+ var hasNoMatchingThemes = !showActiveThemeSection && isEmpty(filteredThemes) && isEmpty(filteredDefaultThemes);
1999
2080
  if (isLoading || isCurrentThemeLoading || isLoadingGlobalTheme) {
2000
2081
  return /*#__PURE__*/jsx("div", {
2001
2082
  className: "flex h-full w-full items-center justify-center",
@@ -2006,6 +2087,7 @@ var Themes = function Themes(_ref) {
2006
2087
  className: "border-border mb-6 border-b px-6 pb-6 lg:px-5 xl:px-6",
2007
2088
  children: /*#__PURE__*/jsx(Card, {
2008
2089
  onApplyTheme: onApplyTheme,
2090
+ onCustomizeSystemTheme: onCustomizeSystemTheme,
2009
2091
  thumbnail: thumbnail,
2010
2092
  active: true,
2011
2093
  isApplyingTheme: (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === activeTheme.id,
@@ -2013,14 +2095,16 @@ var Themes = function Themes(_ref) {
2013
2095
  isHighLightedTheme: activeTheme.id === themeToHighlight,
2014
2096
  isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === activeTheme.id,
2015
2097
  theme: activeTheme,
2016
- onCloneTheme: handleCloneTheme,
2017
2098
  onEditTheme: isActiveThemeCustom ? onEditTheme : undefined,
2018
2099
  onSetPreviewTheme: setPreviewTheme
2019
2100
  })
2020
2101
  });
2021
- var systemThemesSection = isNotEmpty(filteredDefaultThemes) && /*#__PURE__*/jsx("div", {
2102
+ var systemThemesSection = isNotEmpty(filteredDefaultThemes) && /*#__PURE__*/jsxs("div", {
2022
2103
  className: "mb-6 space-y-3",
2023
- children: /*#__PURE__*/jsx("div", {
2104
+ children: [/*#__PURE__*/jsx(SectionHeading, {
2105
+ label: t("neetoThemes.build.leftSideBar.themes.systemThemes"),
2106
+ testId: "system-themes-heading"
2107
+ }), /*#__PURE__*/jsx("div", {
2024
2108
  className: "flex flex-col gap-4 px-6 pb-10 lg:px-5 xl:px-6",
2025
2109
  "data-testid": "system-themes",
2026
2110
  children: filteredDefaultThemes.map(function (theme) {
@@ -2033,15 +2117,17 @@ var Themes = function Themes(_ref) {
2033
2117
  isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
2034
2118
  isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
2035
2119
  key: theme.id,
2036
- onCloneTheme: handleCloneTheme,
2037
2120
  onSetPreviewTheme: setPreviewTheme
2038
2121
  });
2039
2122
  })
2040
- })
2123
+ })]
2041
2124
  });
2042
- var customThemesSection = isNotEmpty(filteredThemes) && /*#__PURE__*/jsx("div", {
2125
+ var customThemesSection = isNotEmpty(filteredThemes) && /*#__PURE__*/jsxs("div", {
2043
2126
  className: "mb-6 space-y-3",
2044
- children: /*#__PURE__*/jsx("div", {
2127
+ children: [/*#__PURE__*/jsx(SectionHeading, {
2128
+ label: t("neetoThemes.build.leftSideBar.themes.customThemes"),
2129
+ testId: "custom-themes-heading"
2130
+ }), /*#__PURE__*/jsx("div", {
2045
2131
  className: "flex flex-col gap-4 px-6",
2046
2132
  "data-testid": "custom-themes",
2047
2133
  children: filteredThemes.map(function (theme) {
@@ -2058,12 +2144,11 @@ var Themes = function Themes(_ref) {
2058
2144
  isGlobalTheme: (globalTheme === null || globalTheme === void 0 ? void 0 : globalTheme.id) === theme.id,
2059
2145
  isHighLightedTheme: theme.id === themeToHighlight,
2060
2146
  key: theme.id,
2061
- onCloneTheme: handleCloneTheme,
2062
2147
  onDeleteTheme: !isActive && onDeleteTheme,
2063
2148
  onSetPreviewTheme: setPreviewTheme
2064
2149
  });
2065
2150
  })
2066
- })
2151
+ })]
2067
2152
  });
2068
2153
  return /*#__PURE__*/jsxs("div", {
2069
2154
  className: "neeto-themes-sidebar__scroll",
@@ -2077,7 +2162,7 @@ var Themes = function Themes(_ref) {
2077
2162
  autoComplete: "off",
2078
2163
  placeholder: t("neetoThemes.common.searchThemes")
2079
2164
  })
2080
- }), isEmpty(filteredThemes) && isEmpty(filteredDefaultThemes) && /*#__PURE__*/jsx(Typography, {
2165
+ }), hasNoMatchingThemes && /*#__PURE__*/jsx(Typography, {
2081
2166
  className: "text-center",
2082
2167
  color: "muted",
2083
2168
  "data-testid": "no-data-title",
@@ -2109,6 +2194,8 @@ var TitleBar = function TitleBar(_ref) {
2109
2194
  }, shallow),
2110
2195
  entityType = _useConfigStore.entityType,
2111
2196
  helpDocUrl = _useConfigStore.helpDocUrl;
2197
+ var _useQueryParams = useQueryParams(),
2198
+ sourceThemeId = _useQueryParams.source;
2112
2199
  var isCustomizeScreen = isEditThemeRoute() || isNewThemeRoute();
2113
2200
  var isCustomCssScreen = isScreenCustomCSS(currentScreen);
2114
2201
  var isRTL = i18n.dir() === "rtl";
@@ -2133,7 +2220,7 @@ var TitleBar = function TitleBar(_ref) {
2133
2220
  }), /*#__PURE__*/jsxs(Typography, {
2134
2221
  "data-testid": "themes-header",
2135
2222
  variant: "h5",
2136
- children: [isCustomizeScreen && !isCustomCssScreen && (isNewThemeRoute() ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
2223
+ children: [isCustomizeScreen && !isCustomCssScreen && (isNewThemeRoute() && !isPresent(sourceThemeId) ? t("neetoThemes.build.leftSideBar.themes.createTheme.title") : t("neetoThemes.build.leftSideBar.themes.editTheme.title")), isCustomCssScreen && t("neetoThemes.build.leftSideBar.themes.customCSS")]
2137
2224
  })]
2138
2225
  })
2139
2226
  });
@@ -2306,6 +2393,17 @@ var Sidebar = function Sidebar(_ref) {
2306
2393
  search: section ? "?section=".concat(section) : ""
2307
2394
  });
2308
2395
  };
2396
+ var handleCustomizeSystemTheme = function handleCustomizeSystemTheme(theme, section) {
2397
+ themeToEdit.current = theme;
2398
+ var searchParams = new URLSearchParams({
2399
+ source: theme.id
2400
+ });
2401
+ if (section) searchParams.set("section", section);
2402
+ history.push({
2403
+ pathname: buildPathname(routes.themes["new"]),
2404
+ search: "?".concat(searchParams.toString())
2405
+ });
2406
+ };
2309
2407
  var onApplyTheme = function onApplyTheme(theme) {
2310
2408
  if (themeBeingApplied !== null && themeBeingApplied !== void 0 && themeBeingApplied.id) return;
2311
2409
  setThemeBeingApplied(theme);
@@ -2400,12 +2498,12 @@ var Sidebar = function Sidebar(_ref) {
2400
2498
  isCurrentThemeLoading: isCurrentThemeLoading,
2401
2499
  isSearchVisible: isSearchVisible,
2402
2500
  onApplyTheme: onApplyTheme,
2403
- onApplyThemeSuccess: onApplyThemeSuccess,
2404
2501
  themeBeingApplied: themeBeingApplied,
2405
2502
  themeToHighlight: themeToHighlight,
2406
2503
  themes: themes,
2407
2504
  thumbnail: thumbnail,
2408
2505
  isLoading: isLoading || isFetchingSchema,
2506
+ onCustomizeSystemTheme: handleCustomizeSystemTheme,
2409
2507
  onDeleteTheme: handleDelete,
2410
2508
  onEditTheme: handleEditTheme
2411
2509
  });
@@ -2419,6 +2517,7 @@ var Sidebar = function Sidebar(_ref) {
2419
2517
  fixedAspectRatio: fixedAspectRatio,
2420
2518
  isApplyingTheme: isApplyingTheme,
2421
2519
  onApplyTheme: onApplyTheme,
2520
+ onApplyThemeSuccess: onApplyThemeSuccess,
2422
2521
  onCreateTheme: onCreateTheme,
2423
2522
  onPropertiesChange: onPropertiesChange,
2424
2523
  onUpdateTheme: onUpdateTheme,
@@ -2435,6 +2534,7 @@ var Sidebar = function Sidebar(_ref) {
2435
2534
  fixedAspectRatio: fixedAspectRatio,
2436
2535
  isApplyingTheme: isApplyingTheme,
2437
2536
  onApplyTheme: onApplyTheme,
2537
+ onApplyThemeSuccess: onApplyThemeSuccess,
2438
2538
  onCreateTheme: onCreateTheme,
2439
2539
  onPropertiesChange: onPropertiesChange,
2440
2540
  onUpdateTheme: onUpdateTheme,