@webiny/app-admin-ui 0.0.0-unstable.6f45466a1d → 0.0.0-unstable.81ae05e56b
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.
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
import React, { useMemo } from "react";
|
|
2
2
|
import { SidebarProvider as AdminUiSidebar } from "@webiny/admin-ui";
|
|
3
3
|
import { useLocalStorage, useLocalStorageValue } from "@webiny/app";
|
|
4
|
-
const
|
|
4
|
+
const SIDEBAR_STATE_KEY = "navigation/state";
|
|
5
5
|
export const SidebarProvider = Component => {
|
|
6
6
|
return function SidebarProvider(props) {
|
|
7
|
-
const
|
|
7
|
+
const rawState = useLocalStorageValue(SIDEBAR_STATE_KEY);
|
|
8
8
|
const {
|
|
9
9
|
set
|
|
10
10
|
} = useLocalStorage();
|
|
11
|
-
const
|
|
11
|
+
const state = useMemo(() => {
|
|
12
12
|
try {
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
13
|
+
if (typeof rawState === "object" && rawState !== null) {
|
|
14
|
+
return rawState;
|
|
15
15
|
}
|
|
16
|
-
if (typeof
|
|
17
|
-
|
|
18
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
16
|
+
if (typeof rawState === "string") {
|
|
17
|
+
return JSON.parse(rawState);
|
|
19
18
|
}
|
|
20
19
|
} catch {
|
|
21
20
|
// Ignore parse errors
|
|
22
21
|
}
|
|
23
|
-
return
|
|
24
|
-
}, [
|
|
25
|
-
const
|
|
26
|
-
set(
|
|
22
|
+
return undefined;
|
|
23
|
+
}, [rawState]);
|
|
24
|
+
const onChangeState = newState => {
|
|
25
|
+
set(SIDEBAR_STATE_KEY, JSON.stringify(newState));
|
|
27
26
|
};
|
|
28
27
|
return /*#__PURE__*/React.createElement(AdminUiSidebar, {
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
state: state,
|
|
29
|
+
onChangeState: onChangeState
|
|
31
30
|
}, /*#__PURE__*/React.createElement(Component, props));
|
|
32
31
|
};
|
|
33
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","SidebarProvider","AdminUiSidebar","useLocalStorage","useLocalStorageValue","
|
|
1
|
+
{"version":3,"names":["React","useMemo","SidebarProvider","AdminUiSidebar","useLocalStorage","useLocalStorageValue","SIDEBAR_STATE_KEY","Component","props","rawState","set","state","JSON","parse","undefined","onChangeState","newState","stringify","createElement"],"sources":["SidebarProvider.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { SidebarProvider as AdminUiSidebar } from \"@webiny/admin-ui\";\nimport { useLocalStorage, useLocalStorageValue } from \"@webiny/app\";\n\ninterface NavigationProviderProps {\n children?: React.ReactNode;\n}\n\nconst SIDEBAR_STATE_KEY = \"navigation/state\";\n\ntype SidebarState = {\n pinned: boolean;\n expandedSections: string[];\n pinnedItems: string[];\n};\n\nexport const SidebarProvider = (Component: React.ComponentType<NavigationProviderProps>) => {\n return function SidebarProvider(props: NavigationProviderProps) {\n const rawState = useLocalStorageValue(SIDEBAR_STATE_KEY);\n const { set } = useLocalStorage();\n\n const state = useMemo(() => {\n try {\n if (typeof rawState === \"object\" && rawState !== null) {\n return rawState as SidebarState;\n }\n if (typeof rawState === \"string\") {\n return JSON.parse(rawState) as SidebarState;\n }\n } catch {\n // Ignore parse errors\n }\n return undefined;\n }, [rawState]);\n\n const onChangeState = (newState: SidebarState) => {\n set(SIDEBAR_STATE_KEY, JSON.stringify(newState));\n };\n\n return (\n <AdminUiSidebar state={state} onChangeState={onChangeState}>\n <Component {...props} />\n </AdminUiSidebar>\n );\n };\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,eAAe,IAAIC,cAAc,QAAQ,kBAAkB;AACpE,SAASC,eAAe,EAAEC,oBAAoB,QAAQ,aAAa;AAMnE,MAAMC,iBAAiB,GAAG,kBAAkB;AAQ5C,OAAO,MAAMJ,eAAe,GAAIK,SAAuD,IAAK;EACxF,OAAO,SAASL,eAAeA,CAACM,KAA8B,EAAE;IAC5D,MAAMC,QAAQ,GAAGJ,oBAAoB,CAACC,iBAAiB,CAAC;IACxD,MAAM;MAAEI;IAAI,CAAC,GAAGN,eAAe,CAAC,CAAC;IAEjC,MAAMO,KAAK,GAAGV,OAAO,CAAC,MAAM;MACxB,IAAI;QACA,IAAI,OAAOQ,QAAQ,KAAK,QAAQ,IAAIA,QAAQ,KAAK,IAAI,EAAE;UACnD,OAAOA,QAAQ;QACnB;QACA,IAAI,OAAOA,QAAQ,KAAK,QAAQ,EAAE;UAC9B,OAAOG,IAAI,CAACC,KAAK,CAACJ,QAAQ,CAAC;QAC/B;MACJ,CAAC,CAAC,MAAM;QACJ;MAAA;MAEJ,OAAOK,SAAS;IACpB,CAAC,EAAE,CAACL,QAAQ,CAAC,CAAC;IAEd,MAAMM,aAAa,GAAIC,QAAsB,IAAK;MAC9CN,GAAG,CAACJ,iBAAiB,EAAEM,IAAI,CAACK,SAAS,CAACD,QAAQ,CAAC,CAAC;IACpD,CAAC;IAED,oBACIhB,KAAA,CAAAkB,aAAA,CAACf,cAAc;MAACQ,KAAK,EAAEA,KAAM;MAACI,aAAa,EAAEA;IAAc,gBACvDf,KAAA,CAAAkB,aAAA,CAACX,SAAS,EAAKC,KAAQ,CACX,CAAC;EAEzB,CAAC;AACL,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-admin-ui",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.81ae05e56b",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -10,21 +10,20 @@
|
|
|
10
10
|
"author": "Webiny Ltd.",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@types/react": "18.
|
|
14
|
-
"@webiny/admin-ui": "0.0.0-unstable.
|
|
15
|
-
"@webiny/app": "0.0.0-unstable.
|
|
16
|
-
"@webiny/app-admin": "0.0.0-unstable.
|
|
17
|
-
"@webiny/icons": "0.0.0-unstable.
|
|
18
|
-
"react": "18.
|
|
19
|
-
"react-dom": "18.
|
|
13
|
+
"@types/react": "18.3.28",
|
|
14
|
+
"@webiny/admin-ui": "0.0.0-unstable.81ae05e56b",
|
|
15
|
+
"@webiny/app": "0.0.0-unstable.81ae05e56b",
|
|
16
|
+
"@webiny/app-admin": "0.0.0-unstable.81ae05e56b",
|
|
17
|
+
"@webiny/icons": "0.0.0-unstable.81ae05e56b",
|
|
18
|
+
"react": "18.3.1",
|
|
19
|
+
"react-dom": "18.3.1",
|
|
20
20
|
"react-helmet": "6.1.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@emotion/babel-plugin": "11.13.5",
|
|
24
24
|
"@types/react-helmet": "6.1.11",
|
|
25
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
26
|
-
"
|
|
27
|
-
"rimraf": "6.1.2",
|
|
25
|
+
"@webiny/build-tools": "0.0.0-unstable.81ae05e56b",
|
|
26
|
+
"rimraf": "6.1.3",
|
|
28
27
|
"typescript": "5.9.3"
|
|
29
28
|
},
|
|
30
29
|
"publishConfig": {
|
|
@@ -36,5 +35,5 @@
|
|
|
36
35
|
"removeViewBox": false
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "81ae05e56bcc774d1e077ca615a0005e736aa5a6"
|
|
40
39
|
}
|