@tker-react/layout 0.2.7 → 0.2.8
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.mjs +16 -5
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -52,6 +52,14 @@ function useLayoutInteractionContext() {
|
|
|
52
52
|
}
|
|
53
53
|
return ctx;
|
|
54
54
|
}
|
|
55
|
+
const LayoutOpenKeysContext = createContext(null);
|
|
56
|
+
function useLayoutOpenKeysContext() {
|
|
57
|
+
const ctx = useContext(LayoutOpenKeysContext);
|
|
58
|
+
if (!ctx) {
|
|
59
|
+
throw new Error("useLayoutOpenKeysContext \u5FC5\u987B\u5728 <Layout> \u5185\u90E8\u4F7F\u7528");
|
|
60
|
+
}
|
|
61
|
+
return ctx;
|
|
62
|
+
}
|
|
55
63
|
function useLayoutContext() {
|
|
56
64
|
const ctx = useContext(LayoutContext);
|
|
57
65
|
if (!ctx) {
|
|
@@ -209,11 +217,13 @@ function LayoutProvider({ children }) {
|
|
|
209
217
|
collapsed,
|
|
210
218
|
toggleCollapse,
|
|
211
219
|
setCollapsed,
|
|
212
|
-
openKeys,
|
|
213
|
-
toggleMenuOpen,
|
|
214
220
|
menuItemClick
|
|
215
221
|
}),
|
|
216
|
-
[collapsed, toggleCollapse, setCollapsed,
|
|
222
|
+
[collapsed, toggleCollapse, setCollapsed, menuItemClick]
|
|
223
|
+
);
|
|
224
|
+
const openKeysValue = useMemo(
|
|
225
|
+
() => ({ openKeys, toggleMenuOpen }),
|
|
226
|
+
[openKeys, toggleMenuOpen]
|
|
217
227
|
);
|
|
218
228
|
const value = useMemo(
|
|
219
229
|
() => ({
|
|
@@ -268,7 +278,7 @@ function LayoutProvider({ children }) {
|
|
|
268
278
|
setMaxTabs
|
|
269
279
|
]
|
|
270
280
|
);
|
|
271
|
-
return /* @__PURE__ */ jsx(LayoutContext.Provider, { value, children: /* @__PURE__ */ jsx(LayoutInteractionContext.Provider, { value: interactionValue, children }) });
|
|
281
|
+
return /* @__PURE__ */ jsx(LayoutContext.Provider, { value, children: /* @__PURE__ */ jsx(LayoutInteractionContext.Provider, { value: interactionValue, children: /* @__PURE__ */ jsx(LayoutOpenKeysContext.Provider, { value: openKeysValue, children }) }) });
|
|
272
282
|
}
|
|
273
283
|
|
|
274
284
|
function LayoutAside() {
|
|
@@ -282,7 +292,8 @@ function LayoutAside() {
|
|
|
282
292
|
getFullPath,
|
|
283
293
|
navigate
|
|
284
294
|
} = useLayoutContext();
|
|
285
|
-
const { collapsed, toggleCollapse,
|
|
295
|
+
const { collapsed, toggleCollapse, menuItemClick } = useLayoutInteractionContext();
|
|
296
|
+
const { openKeys } = useLayoutOpenKeysContext();
|
|
286
297
|
const menuMode = layoutMode === "top-menu" ? "top" : "side";
|
|
287
298
|
const handleMenuSelect = useCallback(
|
|
288
299
|
(path) => {
|