@tker-react/layout 0.2.1 → 0.2.3
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/LICENSE +21 -0
- package/dist/index.mjs +89 -66
- package/dist/layout.css +5 -1
- package/package.json +34 -41
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joey
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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 {
|
package/package.json
CHANGED
|
@@ -1,43 +1,36 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
".": {
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"development": "./src/index.ts",
|
|
20
|
-
"default": "./dist/index.mjs"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"publishConfig": {
|
|
24
|
-
"access": "public",
|
|
25
|
-
"exports": {
|
|
26
|
-
".": {
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
28
|
-
"default": "./dist/index.mjs"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"react": ">=18",
|
|
34
|
-
"react-dom": ">=18"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@tker-react/tsconfig": "workspace:*",
|
|
38
|
-
"@types/react": "catalog:",
|
|
39
|
-
"@types/react-dom": "catalog:",
|
|
40
|
-
"react": "catalog:",
|
|
41
|
-
"react-dom": "catalog:"
|
|
2
|
+
"name": "@tker-react/layout",
|
|
3
|
+
"version": "0.2.3",
|
|
4
|
+
"private": false,
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"**/*.css"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.mjs"
|
|
42
17
|
}
|
|
43
|
-
}
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"react": ">=18",
|
|
24
|
+
"react-dom": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/react": "^19.2.14",
|
|
28
|
+
"@types/react-dom": "^19.2.3",
|
|
29
|
+
"react": "^19.2.6",
|
|
30
|
+
"react-dom": "^19.2.6",
|
|
31
|
+
"@tker-react/tsconfig": "0.0.1"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "pnpm unbuild"
|
|
35
|
+
}
|
|
36
|
+
}
|