@bigbinary/neeto-themes-frontend 1.1.11 → 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.js CHANGED
@@ -36,6 +36,7 @@ var useThemeStore = create$3(withImmutableActions(function (set) {
36
36
  return {
37
37
  currentTheme: {},
38
38
  isCurrentThemeLoading: true,
39
+ previewingTheme: {},
39
40
  setThemeState: set
40
41
  };
41
42
  }));
@@ -549,7 +550,7 @@ var useUpdateTheme = function useUpdateTheme(themeId) {
549
550
  };
550
551
  var useDeleteTheme = function useDeleteTheme() {
551
552
  return useMutationWithInvalidation(themesApi.destroy, {
552
- keysToInvalidate: [QUERY_KEYS$1.THEMES_LIST]
553
+ keysToInvalidate: [QUERY_KEYS$1.THEMES_LIST, QUERY_KEYS$1.THEME_ENTITY_DETAILS]
553
554
  });
554
555
  };
555
556
  var useCloneTheme = function useCloneTheme() {
@@ -574,6 +575,14 @@ var useListConfigs = function useListConfigs(_ref) {
574
575
 
575
576
  var useThemeUtils = function useThemeUtils() {
576
577
  var setConfigState = useConfigStore(prop("setConfigState"));
578
+ var _useThemeStore = useThemeStore(function (store) {
579
+ return {
580
+ previewingTheme: store["previewingTheme"],
581
+ currentTheme: store["currentTheme"]
582
+ };
583
+ }, shallow),
584
+ previewingTheme = _useThemeStore.previewingTheme,
585
+ currentTheme = _useThemeStore.currentTheme;
577
586
  var _useListConfigs = useListConfigs({
578
587
  onSuccess: function onSuccess(_ref) {
579
588
  var _ref$config = _ref.config,
@@ -614,7 +623,9 @@ var useThemeUtils = function useThemeUtils() {
614
623
  };
615
624
  return {
616
625
  setTheme: setTheme,
617
- setVariable: setVariable
626
+ setVariable: setVariable,
627
+ previewingTheme: previewingTheme,
628
+ currentTheme: currentTheme
618
629
  };
619
630
  };
620
631
 
@@ -6978,6 +6989,12 @@ var Properties = function Properties() {
6978
6989
  };
6979
6990
  }, shallow),
6980
6991
  variableNamesMap = _useConfigStore.variableNamesMap;
6992
+ var _useThemeStore = useThemeStore(function (store) {
6993
+ return {
6994
+ setThemeState: store["setThemeState"]
6995
+ };
6996
+ }, shallow),
6997
+ setThemeState = _useThemeStore.setThemeState;
6981
6998
  var _useFormikContext = useFormikContext(),
6982
6999
  setFieldValue = _useFormikContext.setFieldValue,
6983
7000
  values = _useFormikContext.values;
@@ -7000,6 +7017,9 @@ var Properties = function Properties() {
7000
7017
  };
7001
7018
  useEffect(function () {
7002
7019
  setTheme(values);
7020
+ setThemeState({
7021
+ previewingTheme: values
7022
+ });
7003
7023
  }, [values]);
7004
7024
  return /*#__PURE__*/React.createElement(Card$2, {
7005
7025
  title: t("neetoThemes.common.style")
@@ -7367,8 +7387,6 @@ var Themes = function Themes(_ref) {
7367
7387
  _ref$defaultThemes = _ref.defaultThemes,
7368
7388
  defaultThemes = _ref$defaultThemes === void 0 ? [] : _ref$defaultThemes,
7369
7389
  onDeleteTheme = _ref.onDeleteTheme,
7370
- previewingTheme = _ref.previewingTheme,
7371
- setPreviewingTheme = _ref.setPreviewingTheme,
7372
7390
  themeToHighlight = _ref.themeToHighlight,
7373
7391
  highlightTheme = _ref.highlightTheme,
7374
7392
  didScrollActiveThemeIntoView = _ref.didScrollActiveThemeIntoView,
@@ -7379,6 +7397,14 @@ var Themes = function Themes(_ref) {
7379
7397
  t = _useTranslation.t;
7380
7398
  var _useThemeUtils = useThemeUtils(),
7381
7399
  setTheme = _useThemeUtils.setTheme;
7400
+ var _useThemeStore = useThemeStore(function (store) {
7401
+ return {
7402
+ setThemeState: store["setThemeState"],
7403
+ previewingTheme: store["previewingTheme"]
7404
+ };
7405
+ }, shallow),
7406
+ setThemeState = _useThemeStore.setThemeState,
7407
+ previewingTheme = _useThemeStore.previewingTheme;
7382
7408
  var _useState = useState(""),
7383
7409
  _useState2 = _slicedToArray$3(_useState, 2),
7384
7410
  searchQuery = _useState2[0],
@@ -7393,6 +7419,9 @@ var Themes = function Themes(_ref) {
7393
7419
  onSuccess: function onSuccess(_ref2) {
7394
7420
  var theme = _ref2.theme;
7395
7421
  setTheme(theme);
7422
+ setThemeState({
7423
+ previewingTheme: theme
7424
+ });
7396
7425
  setThemeBeingApplied({});
7397
7426
  }
7398
7427
  }),
@@ -7406,8 +7435,9 @@ var Themes = function Themes(_ref) {
7406
7435
  }, 100);
7407
7436
  }, [didScrollActiveThemeIntoView, currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id]);
7408
7437
  var setPreviewTheme = function setPreviewTheme(theme) {
7409
- var id = theme.id;
7410
- setPreviewingTheme(id);
7438
+ setThemeState({
7439
+ previewingTheme: theme
7440
+ });
7411
7441
  setTheme(theme);
7412
7442
  };
7413
7443
  var filteredDefaultThemes = defaultThemes.filter(function (theme) {
@@ -7456,7 +7486,7 @@ var Themes = function Themes(_ref) {
7456
7486
  setThemeBeingApplied: setThemeBeingApplied,
7457
7487
  theme: theme,
7458
7488
  active: (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id,
7459
- isPreviewing: previewingTheme === theme.id,
7489
+ isPreviewing: (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id,
7460
7490
  key: theme.id,
7461
7491
  isApplyingTheme: isApplyingTheme && (themeBeingApplied === null || themeBeingApplied === void 0 ? void 0 : themeBeingApplied.id) === theme.id,
7462
7492
  onCloneTheme: handleCloneTheme,
@@ -7473,7 +7503,7 @@ var Themes = function Themes(_ref) {
7473
7503
  className: "flex flex-col gap-4 px-6"
7474
7504
  }, filteredThemes.map(function (theme) {
7475
7505
  var isActive = (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme.id) === theme.id;
7476
- var isPreviewing = previewingTheme === theme.id;
7506
+ var isPreviewing = (previewingTheme === null || previewingTheme === void 0 ? void 0 : previewingTheme.id) === theme.id;
7477
7507
  return /*#__PURE__*/React.createElement(Card$1, {
7478
7508
  isPreviewing: isPreviewing,
7479
7509
  onApplyTheme: onApplyTheme,
@@ -7557,12 +7587,8 @@ var Sidebar = function Sidebar() {
7557
7587
  setIsDeleteAlertOpen = _useState4[1];
7558
7588
  var _useState5 = useState(null),
7559
7589
  _useState6 = _slicedToArray$3(_useState5, 2),
7560
- previewingTheme = _useState6[0],
7561
- setPreviewingTheme = _useState6[1];
7562
- var _useState7 = useState(null),
7563
- _useState8 = _slicedToArray$3(_useState7, 2),
7564
- themeToHighlight = _useState8[0],
7565
- setThemeToHighlight = _useState8[1];
7590
+ themeToHighlight = _useState6[0],
7591
+ setThemeToHighlight = _useState6[1];
7566
7592
  var _useConfigStore = useConfigStore(function (store) {
7567
7593
  return {
7568
7594
  entityType: store["entityType"],
@@ -7609,6 +7635,9 @@ var Sidebar = function Sidebar() {
7609
7635
  };
7610
7636
  var handleBackPress = function handleBackPress() {
7611
7637
  setTheme(currentTheme);
7638
+ setThemeState({
7639
+ previewingTheme: currentTheme
7640
+ });
7612
7641
  setCurrentScreen(DESIGN_SCREENS.THEMES);
7613
7642
  themeToEdit.current = null;
7614
7643
  };
@@ -7624,7 +7653,9 @@ var Sidebar = function Sidebar() {
7624
7653
  var onCreateTheme = function onCreateTheme(createdTheme) {
7625
7654
  setCurrentScreen(DESIGN_SCREENS.THEMES);
7626
7655
  setTheme(createdTheme);
7627
- setPreviewingTheme(createdTheme.id);
7656
+ setThemeState({
7657
+ previewingTheme: createdTheme
7658
+ });
7628
7659
  highlightTheme(createdTheme);
7629
7660
  themeToEdit.current = null;
7630
7661
  };
@@ -7654,9 +7685,11 @@ var Sidebar = function Sidebar() {
7654
7685
  setTheme(currentTheme);
7655
7686
  }, [currentTheme, entityId]);
7656
7687
  useEffect(function () {
7688
+ if (isNotPresent(currentTheme)) return;
7657
7689
  setThemeState({
7658
7690
  currentTheme: currentTheme,
7659
- isCurrentThemeLoading: isCurrentThemeLoading
7691
+ isCurrentThemeLoading: isCurrentThemeLoading,
7692
+ previewingTheme: currentTheme
7660
7693
  });
7661
7694
  }, [currentTheme, isCurrentThemeLoading]);
7662
7695
  return /*#__PURE__*/React.createElement("div", {
@@ -7674,8 +7707,6 @@ var Sidebar = function Sidebar() {
7674
7707
  didScrollActiveThemeIntoView: didScrollActiveThemeIntoView,
7675
7708
  highlightTheme: highlightTheme,
7676
7709
  isCurrentThemeLoading: isCurrentThemeLoading,
7677
- previewingTheme: previewingTheme,
7678
- setPreviewingTheme: setPreviewingTheme,
7679
7710
  themeToHighlight: themeToHighlight,
7680
7711
  themes: themes,
7681
7712
  isLoading: isLoading || isFetchingConfig,