@etsoo/toolpad 1.0.37 → 1.0.38

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.
@@ -27,7 +27,7 @@ export type PageData = {
27
27
  breadcrumbs?: Breadcrumb[];
28
28
  pageHeader?: React.ReactNode;
29
29
  };
30
- type PageDataAction = PageData;
30
+ type PageDataAction = PageData | true;
31
31
  export declare const PageDataContext: React.Context<{
32
32
  state: PageData;
33
33
  dispatch: React.Dispatch<PageDataAction>;
@@ -63,6 +63,10 @@ function jsonSerialize(obj) {
63
63
  }
64
64
  exports.PageDataContext = React.createContext({ state: {}, dispatch: (value) => value });
65
65
  function reducer(state, action) {
66
+ // Check if the action is 'reset'
67
+ if (action === true) {
68
+ return {};
69
+ }
66
70
  // Check if the action is the same as the current state
67
71
  if (jsonSerialize(state) === jsonSerialize(action)) {
68
72
  return state;
@@ -96,7 +100,6 @@ function PageContainerBar(props) {
96
100
  const breadcrumbs = [...(state.breadcrumbs ?? activePage?.breadcrumbs ?? [])];
97
101
  const title = state.title ?? activePage?.title ?? "";
98
102
  const pageHeader = state.pageHeader ?? activePage?.pageHeader ?? null;
99
- console.log("PageContainerBar", activePage?.sourcePath, title, state);
100
103
  // No page header
101
104
  if (pageHeader === false)
102
105
  return undefined;
@@ -27,7 +27,7 @@ export type PageData = {
27
27
  breadcrumbs?: Breadcrumb[];
28
28
  pageHeader?: React.ReactNode;
29
29
  };
30
- type PageDataAction = PageData;
30
+ type PageDataAction = PageData | true;
31
31
  export declare const PageDataContext: React.Context<{
32
32
  state: PageData;
33
33
  dispatch: React.Dispatch<PageDataAction>;
@@ -22,6 +22,10 @@ function jsonSerialize(obj) {
22
22
  }
23
23
  export const PageDataContext = React.createContext({ state: {}, dispatch: (value) => value });
24
24
  function reducer(state, action) {
25
+ // Check if the action is 'reset'
26
+ if (action === true) {
27
+ return {};
28
+ }
25
29
  // Check if the action is the same as the current state
26
30
  if (jsonSerialize(state) === jsonSerialize(action)) {
27
31
  return state;
@@ -55,7 +59,6 @@ function PageContainerBar(props) {
55
59
  const breadcrumbs = [...(state.breadcrumbs ?? activePage?.breadcrumbs ?? [])];
56
60
  const title = state.title ?? activePage?.title ?? "";
57
61
  const pageHeader = state.pageHeader ?? activePage?.pageHeader ?? null;
58
- console.log("PageContainerBar", activePage?.sourcePath, title, state);
59
62
  // No page header
60
63
  if (pageHeader === false)
61
64
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/toolpad",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "author": "ETSOO",
5
5
  "description": "Dashboard framework extention based on Toolpad Core",
6
6
  "main": "build/cjs/index.js",
@@ -51,7 +51,7 @@ export type PageData = {
51
51
  pageHeader?: React.ReactNode;
52
52
  };
53
53
 
54
- type PageDataAction = PageData;
54
+ type PageDataAction = PageData | true;
55
55
 
56
56
  function jsonSerialize(obj: unknown) {
57
57
  return JSON.stringify(obj, (_key, value) =>
@@ -65,6 +65,11 @@ export const PageDataContext = React.createContext<{
65
65
  }>({ state: {}, dispatch: (value) => value });
66
66
 
67
67
  function reducer(state: PageData, action: PageDataAction) {
68
+ // Check if the action is 'reset'
69
+ if (action === true) {
70
+ return {};
71
+ }
72
+
68
73
  // Check if the action is the same as the current state
69
74
  if (jsonSerialize(state) === jsonSerialize(action)) {
70
75
  return state;
@@ -127,8 +132,6 @@ function PageContainerBar(props: PageContainerBarProps) {
127
132
  const title = state.title ?? activePage?.title ?? "";
128
133
  const pageHeader = state.pageHeader ?? activePage?.pageHeader ?? null;
129
134
 
130
- console.log("PageContainerBar", activePage?.sourcePath, title, state);
131
-
132
135
  // No page header
133
136
  if (pageHeader === false) return undefined;
134
137