@bigbinary/neeto-themes-frontend 1.1.12 → 1.1.13

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/index.cjs.js CHANGED
@@ -68,6 +68,7 @@ var useThemeStore = zustand.create(reactUtils.withImmutableActions(function (set
68
68
  return {
69
69
  currentTheme: {},
70
70
  isCurrentThemeLoading: true,
71
+ previewingTheme: {},
71
72
  setThemeState: set
72
73
  };
73
74
  }));
@@ -606,6 +607,14 @@ var useListConfigs = function useListConfigs(_ref) {
606
607
 
607
608
  var useThemeUtils = function useThemeUtils() {
608
609
  var setConfigState = useConfigStore(ramda.prop("setConfigState"));
610
+ var _useThemeStore = useThemeStore(function (store) {
611
+ return {
612
+ previewingTheme: store["previewingTheme"],
613
+ currentTheme: store["currentTheme"]
614
+ };
615
+ }, shallow.shallow),
616
+ previewingTheme = _useThemeStore.previewingTheme,
617
+ currentTheme = _useThemeStore.currentTheme;
609
618
  var _useListConfigs = useListConfigs({
610
619
  onSuccess: function onSuccess(_ref) {
611
620
  var _ref$config = _ref.config,
@@ -646,7 +655,9 @@ var useThemeUtils = function useThemeUtils() {
646
655
  };
647
656
  return {
648
657
  setTheme: setTheme,
649
- setVariable: setVariable
658
+ setVariable: setVariable,
659
+ previewingTheme: previewingTheme,
660
+ currentTheme: currentTheme
650
661
  };
651
662
  };
652
663
 
@@ -7010,6 +7021,12 @@ var Properties = function Properties() {
7010
7021
  };
7011
7022
  }, shallow.shallow),
7012
7023
  variableNamesMap = _useConfigStore.variableNamesMap;
7024
+ var _useThemeStore = useThemeStore(function (store) {
7025
+ return {
7026
+ setThemeState: store["setThemeState"]
7027
+ };
7028
+ }, shallow.shallow),
7029
+ setThemeState = _useThemeStore.setThemeState;
7013
7030
  var _useFormikContext = formik.useFormikContext(),
7014
7031
  setFieldValue = _useFormikContext.setFieldValue,
7015
7032
  values = _useFormikContext.values;
@@ -7032,6 +7049,9 @@ var Properties = function Properties() {
7032
7049
  };
7033
7050
  React.useEffect(function () {
7034
7051
  setTheme(values);
7052
+ setThemeState({
7053
+ previewingTheme: values
7054
+ });
7035
7055
  }, [values]);
7036
7056
  return /*#__PURE__*/React__default["default"].createElement(Card$2, {
7037
7057
  title: t("neetoThemes.common.style")
@@ -7399,8 +7419,6 @@ var Themes = function Themes(_ref) {
7399
7419
  _ref$defaultThemes = _ref.defaultThemes,
7400
7420
  defaultThemes = _ref$defaultThemes === void 0 ? [] : _ref$defaultThemes,
7401
7421
  onDeleteTheme = _ref.onDeleteTheme,
7402
- previewingTheme = _ref.previewingTheme,
7403
- setPreviewingTheme = _ref.setPreviewingTheme,
7404
7422
  themeToHighlight = _ref.themeToHighlight,
7405
7423
  highlightTheme = _ref.highlightTheme,
7406
7424
  didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
@@ -7411,6 +7429,14 @@ var Themes = function Themes(_ref) {
7411
7429
  t = _useTranslation.t;
7412
7430
  var _useThemeUtils = useThemeUtils(),
7413
7431
  setTheme = _useThemeUtils.setTheme;
7432
+ var _useThemeStore = useThemeStore(function (store) {
7433
+ return {
7434
+ setThemeState: store["setThemeState"],
7435
+ previewingTheme: store["previewingTheme"]
7436
+ };
7437
+ }, shallow.shallow),
7438
+ setThemeState = _useThemeStore.setThemeState,
7439
+ previewingTheme = _useThemeStore.previewingTheme;
7414
7440
  var _useState = React.useState(""),
7415
7441
  _useState2 = _slicedToArray$3(_useState, 2),
7416
7442
  searchQuery = _useState2[0],
@@ -7425,6 +7451,9 @@ var Themes = function Themes(_ref) {
7425
7451
  onSuccess: function onSuccess(_ref2) {
7426
7452
  var theme = _ref2.theme;
7427
7453
  setTheme(theme);
7454
+ setThemeState({
7455
+ previewingTheme: theme
7456
+ });
7428
7457
  setThemeBeingApplied({});
7429
7458
  }
7430
7459
  }),
@@ -7438,8 +7467,9 @@ var Themes = function Themes(_ref) {
7438
7467
  }, 100);
7439
7468
  }, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
7440
7469
  var setPreviewTheme = function setPreviewTheme(theme) {
7441
- var id = theme.id;
7442
- setPreviewingTheme(id);
7470
+ setThemeState({
7471
+ previewingTheme: theme
7472
+ });
7443
7473
  setTheme(theme);
7444
7474
  };
7445
7475
  var filteredDefaultThemes = defaultThemes.filter(function (theme) {
@@ -7488,7 +7518,7 @@ var Themes = function Themes(_ref) {
7488
7518
  setThemeBeingApplied: setThemeBeingApplied,
7489
7519
  theme: theme,
7490
7520
  active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
7491
- isPreviewing: previewingTheme === theme.id,
7521
+ isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
7492
7522
  key: theme.id,
7493
7523
  isApplyingTheme: isApplyingTheme && (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
7494
7524
  onCloneTheme: handleCloneTheme,
@@ -7505,7 +7535,7 @@ var Themes = function Themes(_ref) {
7505
7535
  className: "flex flex-col gap-4 px-6"
7506
7536
  }, filteredThemes.map(function (theme) {
7507
7537
  var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
7508
- var isPreviewing = previewingTheme === theme.id;
7538
+ var isPreviewing = (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id;
7509
7539
  return /*#__PURE__*/React__default["default"].createElement(Card$1, {
7510
7540
  isPreviewing: isPreviewing,
7511
7541
  onApplyTheme: onApplyTheme,
@@ -7589,12 +7619,8 @@ var Sidebar = function Sidebar() {
7589
7619
  setIsDeleteAlertOpen = _useState4[1];
7590
7620
  var _useState5 = React.useState(null),
7591
7621
  _useState6 = _slicedToArray$3(_useState5, 2),
7592
- previewingTheme = _useState6[0],
7593
- setPreviewingTheme = _useState6[1];
7594
- var _useState7 = React.useState(null),
7595
- _useState8 = _slicedToArray$3(_useState7, 2),
7596
- themeToHighlight = _useState8[0],
7597
- setThemeToHighlight = _useState8[1];
7622
+ themeToHighlight = _useState6[0],
7623
+ setThemeToHighlight = _useState6[1];
7598
7624
  var _useConfigStore = useConfigStore(function (store) {
7599
7625
  return {
7600
7626
  entityType: store["entityType"],
@@ -7641,6 +7667,9 @@ var Sidebar = function Sidebar() {
7641
7667
  };
7642
7668
  var handleBackPress = function handleBackPress() {
7643
7669
  setTheme(currentTheme);
7670
+ setThemeState({
7671
+ previewingTheme: currentTheme
7672
+ });
7644
7673
  setCurrentScreen(DESIGN_SCREENS.THEMES);
7645
7674
  themeToEdit.current = null;
7646
7675
  };
@@ -7656,7 +7685,9 @@ var Sidebar = function Sidebar() {
7656
7685
  var onCreateTheme = function onCreateTheme(createdTheme) {
7657
7686
  setCurrentScreen(DESIGN_SCREENS.THEMES);
7658
7687
  setTheme(createdTheme);
7659
- setPreviewingTheme(createdTheme.id);
7688
+ setThemeState({
7689
+ previewingTheme: createdTheme
7690
+ });
7660
7691
  highlightTheme(createdTheme);
7661
7692
  themeToEdit.current = null;
7662
7693
  };
@@ -7686,9 +7717,11 @@ var Sidebar = function Sidebar() {
7686
7717
  setTheme(currentTheme);
7687
7718
  }, [currentTheme, entityId]);
7688
7719
  React.useEffect(function () {
7720
+ if (neetoCist.isNotPresent(currentTheme)) return;
7689
7721
  setThemeState({
7690
7722
  currentTheme: currentTheme,
7691
- isCurrentThemeLoading: isCurrentThemeLoading
7723
+ isCurrentThemeLoading: isCurrentThemeLoading,
7724
+ previewingTheme: currentTheme
7692
7725
  });
7693
7726
  }, [currentTheme, isCurrentThemeLoading]);
7694
7727
  return /*#__PURE__*/React__default["default"].createElement("div", {
@@ -7706,8 +7739,6 @@ var Sidebar = function Sidebar() {
7706
7739
  didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
7707
7740
  highlightTheme: highlightTheme,
7708
7741
  isCurrentThemeLoading: isCurrentThemeLoading,
7709
- previewingTheme: previewingTheme,
7710
- setPreviewingTheme: setPreviewingTheme,
7711
7742
  themeToHighlight: themeToHighlight,
7712
7743
  themes: themes,
7713
7744
  isLoading: isLoading || isFetchingConfig,