@tker-react/layout 0.2.1 → 0.2.2
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 +89 -66
- package/dist/layout.css +5 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./layout.css";
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
3
|
import { createContext, useContext, useRef, useCallback, useState, useMemo, useEffect } from 'react';
|
|
3
4
|
|
|
4
5
|
function findMenuItemByPath(menuData, path) {
|
|
@@ -192,7 +193,7 @@ function LayoutProvider({ children }) {
|
|
|
192
193
|
setMaxTabs
|
|
193
194
|
]
|
|
194
195
|
);
|
|
195
|
-
return /* @__PURE__ */
|
|
196
|
+
return /* @__PURE__ */ jsx(LayoutContext.Provider, { value, children });
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
function LayoutAside() {
|
|
@@ -220,36 +221,39 @@ function LayoutAside() {
|
|
|
220
221
|
const MenuAdapter = adapters.menu;
|
|
221
222
|
if (!MenuAdapter) return null;
|
|
222
223
|
const asideWidth = collapsed ? collapsedWidth : expandedWidth;
|
|
223
|
-
return /* @__PURE__ */
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
menuData,
|
|
227
|
-
activePath,
|
|
228
|
-
collapsed,
|
|
229
|
-
mode: menuMode,
|
|
230
|
-
width: asideWidth,
|
|
231
|
-
onSelect: handleMenuSelect
|
|
232
|
-
}
|
|
233
|
-
), /* @__PURE__ */ React.createElement(
|
|
234
|
-
"div",
|
|
235
|
-
{
|
|
236
|
-
className: "tker-layout-aside__toggle-btn",
|
|
237
|
-
onClick: toggleCollapse
|
|
238
|
-
},
|
|
239
|
-
collapsed ? /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 16 16", fill: "none", width: "16", height: "16" }, /* @__PURE__ */ React.createElement(
|
|
240
|
-
"path",
|
|
224
|
+
return /* @__PURE__ */ jsxs("aside", { className: "tker-layout-aside", style: { width: asideWidth }, children: [
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
226
|
+
MenuAdapter,
|
|
241
227
|
{
|
|
242
|
-
|
|
243
|
-
|
|
228
|
+
menuData,
|
|
229
|
+
activePath,
|
|
230
|
+
collapsed,
|
|
231
|
+
mode: menuMode,
|
|
232
|
+
width: asideWidth,
|
|
233
|
+
onSelect: handleMenuSelect
|
|
244
234
|
}
|
|
245
|
-
)
|
|
246
|
-
|
|
235
|
+
),
|
|
236
|
+
/* @__PURE__ */ jsx(
|
|
237
|
+
"div",
|
|
247
238
|
{
|
|
248
|
-
|
|
249
|
-
|
|
239
|
+
className: "tker-layout-aside__toggle-btn",
|
|
240
|
+
onClick: toggleCollapse,
|
|
241
|
+
children: collapsed ? /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", width: "16", height: "16", children: /* @__PURE__ */ jsx(
|
|
242
|
+
"path",
|
|
243
|
+
{
|
|
244
|
+
d: "M5.64645 3.14645C5.45118 3.34171 5.45118 3.65829 5.64645 3.85355L9.79289 8L5.64645 12.1464C5.45118 12.3417 5.45118 12.6583 5.64645 12.8536C5.84171 13.0488 6.15829 13.0488 6.35355 12.8536L10.8536 8.35355C11.0488 8.15829 11.0488 7.84171 10.8536 7.64645L6.35355 3.14645C6.15829 2.95118 5.84171 2.95118 5.64645 3.14645Z",
|
|
245
|
+
fill: "currentColor"
|
|
246
|
+
}
|
|
247
|
+
) }) : /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", width: "16", height: "16", children: /* @__PURE__ */ jsx(
|
|
248
|
+
"path",
|
|
249
|
+
{
|
|
250
|
+
d: "M10.3536 3.14645C10.5488 3.34171 10.5488 3.65829 10.3536 3.85355L6.20711 8L10.3536 12.1464C10.5488 12.3417 10.5488 12.6583 10.3536 12.8536C10.1583 13.0488 9.84171 13.0488 9.64645 12.8536L5.14645 8.35355C4.95118 8.15829 4.95118 7.84171 5.14645 7.64645L9.64645 3.14645C9.84171 2.95118 10.1583 2.95118 10.3536 3.14645Z",
|
|
251
|
+
fill: "currentColor"
|
|
252
|
+
}
|
|
253
|
+
) })
|
|
250
254
|
}
|
|
251
|
-
)
|
|
252
|
-
)
|
|
255
|
+
)
|
|
256
|
+
] });
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
function LayoutContent({ children }) {
|
|
@@ -354,19 +358,22 @@ function LayoutContent({ children }) {
|
|
|
354
358
|
setRefreshKey((k) => k + 1);
|
|
355
359
|
}, []);
|
|
356
360
|
const TabAdapter = adapters.tab;
|
|
357
|
-
return /* @__PURE__ */
|
|
358
|
-
TabAdapter
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
361
|
+
return /* @__PURE__ */ jsxs("main", { className: "tker-layout-content", children: [
|
|
362
|
+
!isTopMenu && TabAdapter && /* @__PURE__ */ jsx(
|
|
363
|
+
TabAdapter,
|
|
364
|
+
{
|
|
365
|
+
tabData,
|
|
366
|
+
activeTab,
|
|
367
|
+
onSelect: handleTabSelect,
|
|
368
|
+
onClose: handleTabClose,
|
|
369
|
+
onCloseOther: handleCloseOtherTabs,
|
|
370
|
+
onCloseAll: handleCloseAllTabs,
|
|
371
|
+
onRefresh: handleRefresh,
|
|
372
|
+
onSetFixed: handleSetFixed
|
|
373
|
+
}
|
|
374
|
+
),
|
|
375
|
+
/* @__PURE__ */ jsx("div", { className: "tker-layout-content__body", children }, refreshKey)
|
|
376
|
+
] });
|
|
370
377
|
}
|
|
371
378
|
function openTabInData(tabData, path, config) {
|
|
372
379
|
const { homePath, maxTabs, menuData } = config;
|
|
@@ -454,39 +461,55 @@ function LayoutHeader() {
|
|
|
454
461
|
const BreadcrumbAdapter = adapters.breadcrumb;
|
|
455
462
|
const ToolbarAdapter = adapters.toolbar;
|
|
456
463
|
const UserAvatarAdapter = adapters.userAvatar;
|
|
457
|
-
return /* @__PURE__ */
|
|
458
|
-
"div",
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
464
|
+
return /* @__PURE__ */ jsxs("header", { className: "tker-layout-header", children: [
|
|
465
|
+
/* @__PURE__ */ jsxs("div", { className: "tker-layout-header__left", children: [
|
|
466
|
+
LogoAdapter && leftContent.includes("logo") && /* @__PURE__ */ jsx(
|
|
467
|
+
"div",
|
|
468
|
+
{
|
|
469
|
+
className: "tker-layout-header__left-logo",
|
|
470
|
+
style: { width: logoWidth },
|
|
471
|
+
children: /* @__PURE__ */ jsx(LogoAdapter, { collapsed, width: logoWidth })
|
|
472
|
+
}
|
|
473
|
+
),
|
|
474
|
+
MenuAdapter && isTopMenu && /* @__PURE__ */ jsx(
|
|
475
|
+
MenuAdapter,
|
|
476
|
+
{
|
|
477
|
+
menuData,
|
|
478
|
+
activePath,
|
|
479
|
+
collapsed: false,
|
|
480
|
+
mode: "top",
|
|
481
|
+
width: logoWidth,
|
|
482
|
+
onSelect: handleMenuSelect
|
|
483
|
+
}
|
|
484
|
+
),
|
|
485
|
+
BreadcrumbAdapter && isSideMenu && /* @__PURE__ */ jsx(
|
|
486
|
+
BreadcrumbAdapter,
|
|
487
|
+
{
|
|
488
|
+
breadcrumbData,
|
|
489
|
+
onSelect: handleBreadcrumbSelect
|
|
490
|
+
}
|
|
491
|
+
)
|
|
492
|
+
] }),
|
|
493
|
+
/* @__PURE__ */ jsxs("div", { className: "tker-layout-header__right", children: [
|
|
494
|
+
ToolbarAdapter && /* @__PURE__ */ jsx(ToolbarAdapter, {}),
|
|
495
|
+
UserAvatarAdapter && /* @__PURE__ */ jsx(UserAvatarAdapter, {})
|
|
496
|
+
] })
|
|
497
|
+
] });
|
|
481
498
|
}
|
|
482
499
|
|
|
483
500
|
function LayoutInner({ children }) {
|
|
484
501
|
const { layoutMode } = useLayoutContext();
|
|
485
502
|
const isSideMenu = layoutMode === "side-menu";
|
|
486
|
-
return /* @__PURE__ */
|
|
503
|
+
return /* @__PURE__ */ jsxs("div", { className: "tker-layout", children: [
|
|
504
|
+
/* @__PURE__ */ jsx(LayoutHeader, {}),
|
|
505
|
+
/* @__PURE__ */ jsxs("div", { className: "tker-layout__body", children: [
|
|
506
|
+
isSideMenu && /* @__PURE__ */ jsx(LayoutAside, {}),
|
|
507
|
+
/* @__PURE__ */ jsx(LayoutContent, { children })
|
|
508
|
+
] })
|
|
509
|
+
] });
|
|
487
510
|
}
|
|
488
511
|
function Layout({ children }) {
|
|
489
|
-
return /* @__PURE__ */
|
|
512
|
+
return /* @__PURE__ */ jsx(LayoutProvider, { children: /* @__PURE__ */ jsx(LayoutInner, { children }) });
|
|
490
513
|
}
|
|
491
514
|
|
|
492
515
|
export { Layout, LayoutProvider, useLayoutContext as useLayout, useLayoutContext };
|
package/dist/layout.css
CHANGED
|
@@ -32,9 +32,14 @@
|
|
|
32
32
|
gap: 12px;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
.tker-layout-header__left{
|
|
36
|
+
height: 100%;
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
.tker-layout-header__left-logo {
|
|
36
40
|
height: 100%;
|
|
37
41
|
border-right: 1px solid #e8e8e8;
|
|
42
|
+
transition: width 0.3s;
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
/* === Aside === */
|
|
@@ -48,7 +53,6 @@
|
|
|
48
53
|
position: relative;
|
|
49
54
|
display: flex;
|
|
50
55
|
flex-direction: column;
|
|
51
|
-
overflow: hidden;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
.tker-layout-aside__toggle-btn {
|