dishui 0.0.82 → 0.0.84
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/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/ButtonMenu/index.d.ts +28 -0
- package/dist/components/ButtonMenu/index.js +197 -0
- package/dist/components/ButtonMenu/index.js.map +1 -0
- package/dist/components/Demo/index.d.ts +5 -0
- package/dist/components/Demo/index.js +131 -56
- package/dist/components/Demo/index.js.map +1 -1
- package/dist/components/Demo/source.d.ts +9 -0
- package/dist/components/Demo/source.js +32 -0
- package/dist/components/Demo/source.js.map +1 -0
- package/dist/components/Field/index.d.ts +8 -0
- package/dist/components/Field/index.js +43 -0
- package/dist/components/Field/index.js.map +1 -0
- package/dist/components/LayoutSuite/DashboardSuite.d.ts +35 -0
- package/dist/components/LayoutSuite/DashboardSuite.js +61 -0
- package/dist/components/LayoutSuite/DashboardSuite.js.map +1 -0
- package/dist/components/LayoutSuite/index.d.ts +56 -0
- package/dist/components/LayoutSuite/index.js +101 -0
- package/dist/components/LayoutSuite/index.js.map +1 -0
- package/dist/components/Modal/focusScope.d.ts +1 -0
- package/dist/components/Modal/focusScope.js +81 -0
- package/dist/components/Modal/focusScope.js.map +1 -0
- package/dist/components/Modal/index.d.ts +4 -1
- package/dist/components/Modal/index.js +48 -43
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Page/Float.d.ts +14 -0
- package/dist/components/Page/Float2.js +154 -0
- package/dist/components/Page/Float2.js.map +1 -0
- package/dist/components/Page/index.d.ts +34 -7
- package/dist/components/Page/index.js +117 -36
- package/dist/components/Page/index.js.map +1 -1
- package/dist/components/Page/resize.d.ts +28 -0
- package/dist/components/Page/resize2.js +95 -0
- package/dist/components/Page/resize2.js.map +1 -0
- package/dist/components/PageHeader/index.d.ts +10 -3
- package/dist/components/PageHeader/index.js +46 -25
- package/dist/components/PageHeader/index.js.map +1 -1
- package/dist/components/PagePanel/index.d.ts +29 -0
- package/dist/components/PagePanel/index.js +99 -0
- package/dist/components/PagePanel/index.js.map +1 -0
- package/dist/components/Resizable/ResizeGrip.d.ts +5 -0
- package/dist/components/Resizable/ResizeGrip.js +14 -0
- package/dist/components/Resizable/ResizeGrip.js.map +1 -0
- package/dist/components/Resizable/index.js +57 -59
- package/dist/components/Resizable/index.js.map +1 -1
- package/dist/components/Resizable/useResize.d.ts +6 -0
- package/dist/components/Resizable/useResize.js +29 -28
- package/dist/components/Resizable/useResize.js.map +1 -1
- package/dist/components/SidebarToggleButton/index.d.ts +5 -3
- package/dist/components/SidebarToggleButton/index.js +24 -21
- package/dist/components/SidebarToggleButton/index.js.map +1 -1
- package/dist/components/Table/index.d.ts +10 -12
- package/dist/components/Table/index.js +25 -20
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Text/index.d.ts +2 -2
- package/dist/components/Text/index.js +13 -12
- package/dist/components/Text/index.js.map +1 -1
- package/dist/components/Textarea/index.d.ts +14 -0
- package/dist/components/Textarea/index.js +44 -0
- package/dist/components/Textarea/index.js.map +1 -0
- package/dist/components/Tree/Tree.d.ts +2 -0
- package/dist/components/Tree/Tree.js +49 -40
- package/dist/components/Tree/Tree.js.map +1 -1
- package/dist/dishui.css +1 -1
- package/dist/index-nostyled.d.ts +9 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +119 -113
- package/dist/layouts/Sidebar.d.ts +14 -1
- package/dist/layouts/Sidebar.js +170 -137
- package/dist/layouts/Sidebar.js.map +1 -1
- package/dist/lite.d.ts +10 -2
- package/dist/lite.js +17 -12
- package/dist/utils/i18n.js +1 -1
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js +14 -16
- package/dist/utils/menu.js.map +1 -1
- package/package.json +3 -1
|
@@ -1,65 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { mountFocusScope as e } from "./focusScope.js";
|
|
2
|
+
import { useId as t, useLayoutEffect as n, useRef as r } from "react";
|
|
3
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as o } from "react-dom";
|
|
3
5
|
//#region src/components/Modal/index.tsx
|
|
4
|
-
var
|
|
6
|
+
var s = {
|
|
5
7
|
sm: "max-w-sm",
|
|
6
8
|
md: "max-w-lg",
|
|
7
9
|
lg: "max-w-2xl",
|
|
8
10
|
xl: "max-w-5xl",
|
|
9
11
|
full: "max-w-[95vw]"
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}, [a, o]), !a) return null;
|
|
22
|
-
let _ = f !== void 0, v = {
|
|
23
|
-
width: _ ? i(f) : void 0,
|
|
24
|
-
maxWidth: _ ? "95vw" : void 0,
|
|
25
|
-
height: i(p),
|
|
12
|
+
}, c = (e) => typeof e == "number" ? `${e}px` : e, l = ({ open: l, onClose: u, title: d, description: f, children: p, footer: m, size: h = "md", width: g, height: _, closeOnOverlay: v = !0, showClose: y = !0, className: b = "", "aria-label": x, "aria-labelledby": S, "aria-describedby": C }) => {
|
|
13
|
+
let w = t(), T = t(), E = r(null), D = r(null), O = r(null), k = r(!1), A = r(u);
|
|
14
|
+
if (l && !k.current && typeof document < "u" && (O.current = document.activeElement), k.current = l, n(() => {
|
|
15
|
+
A.current = u;
|
|
16
|
+
}), n(() => {
|
|
17
|
+
if (l && E.current && D.current) return e(E.current, D.current, O.current, () => A.current());
|
|
18
|
+
}, [l]), !l || typeof document > "u") return null;
|
|
19
|
+
let j = g !== void 0, M = {
|
|
20
|
+
width: j ? c(g) : void 0,
|
|
21
|
+
maxWidth: j ? "95vw" : void 0,
|
|
22
|
+
height: c(_),
|
|
26
23
|
maxHeight: "92vh"
|
|
27
|
-
},
|
|
28
|
-
return /* @__PURE__ */
|
|
24
|
+
}, N = j ? "" : s[h], P = _ === void 0 ? "max-h-[70vh] overflow-y-auto px-5 py-4" : "min-h-0 flex-1 overflow-y-auto px-5 py-4";
|
|
25
|
+
return o(/* @__PURE__ */ a("div", {
|
|
26
|
+
ref: D,
|
|
29
27
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
|
|
30
|
-
children: [/* @__PURE__ */
|
|
28
|
+
children: [/* @__PURE__ */ i("div", {
|
|
31
29
|
className: "absolute inset-0",
|
|
32
|
-
onClick:
|
|
30
|
+
onClick: v ? u : void 0,
|
|
33
31
|
"aria-hidden": !0
|
|
34
|
-
}), /* @__PURE__ */
|
|
32
|
+
}), /* @__PURE__ */ a("div", {
|
|
33
|
+
ref: E,
|
|
35
34
|
role: "dialog",
|
|
35
|
+
tabIndex: -1,
|
|
36
36
|
"aria-modal": "true",
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
"aria-label": x,
|
|
38
|
+
"aria-labelledby": S ?? (d && !x ? w : void 0),
|
|
39
|
+
"aria-describedby": C ?? (f ? T : void 0),
|
|
40
|
+
className: `dishui-modal card relative flex w-full min-w-0 flex-col rounded-xl border border-base-300 bg-base-100 text-body leading-5 text-base-content shadow-md ${N} ${b}`.trim(),
|
|
41
|
+
style: M,
|
|
39
42
|
children: [
|
|
40
|
-
(
|
|
43
|
+
(d || f || y) && /* @__PURE__ */ a("div", {
|
|
41
44
|
className: "flex shrink-0 items-start justify-between gap-3 border-b border-base-300 px-5 py-3",
|
|
42
|
-
children: [/* @__PURE__ */
|
|
45
|
+
children: [/* @__PURE__ */ a("div", {
|
|
43
46
|
className: "min-w-0",
|
|
44
|
-
children: [
|
|
47
|
+
children: [d && /* @__PURE__ */ i("h3", {
|
|
48
|
+
id: w,
|
|
45
49
|
className: "break-words text-body font-semibold text-base-content",
|
|
46
|
-
children:
|
|
47
|
-
}),
|
|
50
|
+
children: d
|
|
51
|
+
}), f && /* @__PURE__ */ i("p", {
|
|
52
|
+
id: T,
|
|
48
53
|
className: "mt-1 text-body-sm leading-5 text-base-content/70",
|
|
49
|
-
children:
|
|
54
|
+
children: f
|
|
50
55
|
})]
|
|
51
|
-
}),
|
|
56
|
+
}), y && /* @__PURE__ */ i("button", {
|
|
52
57
|
type: "button",
|
|
53
|
-
onClick:
|
|
58
|
+
onClick: u,
|
|
54
59
|
"aria-label": "Close",
|
|
55
60
|
className: "shrink-0 rounded-md p-1 text-base-content/70 transition-colors duration-150 motion-reduce:transition-none hover:bg-base-200 hover:text-base-content focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current",
|
|
56
|
-
children: /* @__PURE__ */
|
|
61
|
+
children: /* @__PURE__ */ i("svg", {
|
|
57
62
|
className: "h-4 w-4",
|
|
58
63
|
fill: "none",
|
|
59
64
|
viewBox: "0 0 24 24",
|
|
60
65
|
stroke: "currentColor",
|
|
61
66
|
strokeWidth: 2,
|
|
62
|
-
children: /* @__PURE__ */
|
|
67
|
+
children: /* @__PURE__ */ i("path", {
|
|
63
68
|
strokeLinecap: "round",
|
|
64
69
|
strokeLinejoin: "round",
|
|
65
70
|
d: "M6 18L18 6M6 6l12 12"
|
|
@@ -67,19 +72,19 @@ var r = {
|
|
|
67
72
|
})
|
|
68
73
|
})]
|
|
69
74
|
}),
|
|
70
|
-
/* @__PURE__ */
|
|
71
|
-
className:
|
|
72
|
-
children:
|
|
75
|
+
/* @__PURE__ */ i("div", {
|
|
76
|
+
className: P,
|
|
77
|
+
children: p
|
|
73
78
|
}),
|
|
74
|
-
|
|
79
|
+
m && /* @__PURE__ */ i("div", {
|
|
75
80
|
className: "flex shrink-0 flex-wrap justify-end gap-2 border-t border-base-300 px-5 py-3",
|
|
76
|
-
children:
|
|
81
|
+
children: m
|
|
77
82
|
})
|
|
78
83
|
]
|
|
79
84
|
})]
|
|
80
|
-
});
|
|
85
|
+
}), document.body);
|
|
81
86
|
};
|
|
82
87
|
//#endregion
|
|
83
|
-
export {
|
|
88
|
+
export { l as default };
|
|
84
89
|
|
|
85
90
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Modal/index.tsx"],"sourcesContent":["import React, { useId, useLayoutEffect, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { mountFocusScope } from './focusScope';\n\nexport type ModalProps = {\n /** 是否打开 */\n open: boolean;\n /** 关闭回调(遮罩点击 / Esc / 关闭按钮触发) */\n onClose: () => void;\n /** 标题 */\n title?: React.ReactNode;\n /** 标题下的说明文字 */\n description?: React.ReactNode;\n /** 正文内容 */\n children?: React.ReactNode;\n /** 底部操作区(默认右对齐) */\n footer?: React.ReactNode;\n /** 尺寸(预设):sm / md / lg / xl / full */\n size?: 'sm' | 'md' | 'lg' | 'xl' | 'full';\n /** 自定义宽度:支持百分比/像素等 CSS 长度(如 \"80%\"、640)。优先于 size。 */\n width?: number | string;\n /** 自定义高度:支持百分比/像素等 CSS 长度(如 \"80%\"、480)。 */\n height?: number | string;\n /** 点击遮罩是否关闭(默认 true) */\n closeOnOverlay?: boolean;\n /** 是否显示右上角关闭按钮(默认 true) */\n showClose?: boolean;\n className?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n};\n\nconst SIZE_CLASS: Record<NonNullable<ModalProps['size']>, string> = {\n sm: 'max-w-sm',\n md: 'max-w-lg',\n lg: 'max-w-2xl',\n xl: 'max-w-5xl',\n full: 'max-w-[95vw]',\n};\n\nconst toCssSize = (value: number | string | undefined): string | undefined =>\n typeof value === 'number' ? `${value}px` : value;\n\n/**\n * 轻量模态框:遮罩 + 居中面板,支持 Esc 关闭、遮罩点击关闭与滚动锁定。\n */\nconst Modal = ({\n open,\n onClose,\n title,\n description,\n children,\n footer,\n size = 'md',\n width,\n height,\n closeOnOverlay = true,\n showClose = true,\n className = '',\n 'aria-label': ariaLabel,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': describedBy,\n}: ModalProps) => {\n const titleId = useId();\n const descriptionId = useId();\n const panel = useRef<HTMLDivElement>(null);\n const overlay = useRef<HTMLDivElement>(null);\n const trigger = useRef<HTMLElement | null>(null);\n const wasOpen = useRef(false);\n const close = useRef(onClose);\n // Capture before React commits autoFocus inside the newly opened portal.\n if (open && !wasOpen.current && typeof document !== 'undefined') trigger.current = document.activeElement as HTMLElement | null;\n wasOpen.current = open;\n useLayoutEffect(() => { close.current = onClose; });\n useLayoutEffect(() => {\n if (!open || !panel.current || !overlay.current) return;\n return mountFocusScope(panel.current, overlay.current, trigger.current, () => close.current());\n }, [open]);\n\n if (!open || typeof document === 'undefined') return null;\n\n // 自定义宽高:传入时优先于 size 预设;支持百分比。\n const hasCustomWidth = width !== undefined;\n const panelStyle: React.CSSProperties = {\n width: hasCustomWidth ? toCssSize(width) : undefined,\n maxWidth: hasCustomWidth ? '95vw' : undefined,\n height: toCssSize(height),\n maxHeight: '92vh',\n };\n // 面板尺寸类:未自定义宽度时才应用 max-w-* 预设。\n const sizeClass = hasCustomWidth ? '' : SIZE_CLASS[size];\n // 正文区:固定高度时自适应充满并内部滚动;否则限制最大高度。\n const bodyClass = height !== undefined\n ? 'min-h-0 flex-1 overflow-y-auto px-5 py-4'\n : 'max-h-[70vh] overflow-y-auto px-5 py-4';\n\n return createPortal(\n <div ref={overlay} className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4\">\n <div\n className=\"absolute inset-0\"\n onClick={closeOnOverlay ? onClose : undefined}\n aria-hidden\n />\n <div\n ref={panel}\n role=\"dialog\"\n tabIndex={-1}\n aria-modal=\"true\"\n aria-label={ariaLabel}\n aria-labelledby={labelledBy ?? (title && !ariaLabel ? titleId : undefined)}\n aria-describedby={describedBy ?? (description ? descriptionId : undefined)}\n className={`dishui-modal card relative flex w-full min-w-0 flex-col rounded-xl border border-base-300 bg-base-100 text-body leading-5 text-base-content shadow-md ${sizeClass} ${className}`.trim()}\n style={panelStyle}\n >\n {(title || description || showClose) && (\n <div className=\"flex shrink-0 items-start justify-between gap-3 border-b border-base-300 px-5 py-3\">\n <div className=\"min-w-0\">\n {title && (\n <h3 id={titleId} className=\"break-words text-body font-semibold text-base-content\">\n {title}\n </h3>\n )}\n {description && (\n <p id={descriptionId} className=\"mt-1 text-body-sm leading-5 text-base-content/70\">{description}</p>\n )}\n </div>\n {showClose && (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label=\"Close\"\n className=\"shrink-0 rounded-md p-1 text-base-content/70 transition-colors duration-150 motion-reduce:transition-none hover:bg-base-200 hover:text-base-content focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current\"\n >\n <svg\n className=\"h-4 w-4\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n strokeWidth={2}\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </button>\n )}\n </div>\n )}\n <div className={bodyClass}>{children}</div>\n {footer && (\n <div className=\"flex shrink-0 flex-wrap justify-end gap-2 border-t border-base-300 px-5 py-3\">\n {footer}\n </div>\n )}\n </div>\n </div>,\n document.body,\n );\n};\n\nexport default Modal;\n"],"mappings":";;;;;AAiCA,IAAM,IAA8D;CAChE,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,MAAM;AACV,GAEM,KAAa,MACf,OAAO,KAAU,WAAW,GAAG,EAAM,MAAM,GAKzC,KAAS,EACX,SACA,YACA,UACA,gBACA,aACA,WACA,UAAO,MACP,UACA,WACA,oBAAiB,IACjB,eAAY,IACZ,eAAY,IACZ,cAAc,GACd,mBAAmB,GACnB,oBAAoB,QACN;CACd,IAAM,IAAU,EAAM,GAChB,IAAgB,EAAM,GACtB,IAAQ,EAAuB,IAAI,GACnC,IAAU,EAAuB,IAAI,GACrC,IAAU,EAA2B,IAAI,GACzC,IAAU,EAAO,EAAK,GACtB,IAAQ,EAAO,CAAO;CAU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AAC,UAAD;MACI,MAAK;MACL,SAAS;MACT,cAAW;MACX,WAAU;MAEV,UAAA,kBAAC,OAAD;OACI,WAAU;OACV,MAAK;OACL,SAAQ;OACR,QAAO;OACP,aAAa;OAEb,UAAA,kBAAC,QAAD;QACI,eAAc;QACd,gBAAe;QACf,GAAE;OACL,CAAA;MACA,CAAA;KACD,CAAA,CAEX;;IAET,kBAAC,OAAD;KAAK,WAAW;KAAY;IAAc,CAAA;IACzC,KACG,kBAAC,OAAD;KAAK,WAAU;KACV,UAAA;IACA,CAAA;GAER;EACJ,CAAA,CAAA;CACL,CAAA,GAAA,SAAS,IACb;AACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type PageFloatProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
title?: string;
|
|
4
|
+
collapsed?: boolean;
|
|
5
|
+
defaultCollapsed?: boolean;
|
|
6
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
7
|
+
defaultPosition?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
draggable?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** Coordinates are relative to the containing Page; dragging is confined to it. */
|
|
14
|
+
export default function PageFloat({ title, collapsed, defaultCollapsed, onCollapsedChange, defaultPosition, draggable, className, style, children, ...rest }: PageFloatProps): React.JSX.Element;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { cn as e } from "../../utils/cn.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
|
|
4
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Page/Float.tsx
|
|
6
|
+
function c({ title: c = "Float", collapsed: l, defaultCollapsed: u = !1, onCollapsedChange: d, defaultPosition: f = {
|
|
7
|
+
x: 16,
|
|
8
|
+
y: 16
|
|
9
|
+
}, draggable: p = !0, className: m, style: h, children: g, ..._ }) {
|
|
10
|
+
let [v, y] = i(u), b = l ?? v, [x, S] = i(f), C = r(null), w = r(null), T = r(null), E = r(!1), D = t((e) => {
|
|
11
|
+
let t = C.current, n = t?.offsetParent;
|
|
12
|
+
return !t || !n ? e : {
|
|
13
|
+
x: Math.max(0, Math.min(e.x, n.clientWidth - t.offsetWidth)),
|
|
14
|
+
y: Math.max(0, Math.min(e.y, n.clientHeight - t.offsetHeight))
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
n(() => {
|
|
18
|
+
let e = () => S((e) => {
|
|
19
|
+
let t = D(e);
|
|
20
|
+
return t.x === e.x && t.y === e.y ? e : t;
|
|
21
|
+
});
|
|
22
|
+
e();
|
|
23
|
+
let t = new ResizeObserver(e);
|
|
24
|
+
return C.current && t.observe(C.current), C.current?.offsetParent && t.observe(C.current.offsetParent), () => t.disconnect();
|
|
25
|
+
}, [D, b]);
|
|
26
|
+
let O = () => {
|
|
27
|
+
y(!b), d?.(!b), w.current?.focus();
|
|
28
|
+
}, k = {
|
|
29
|
+
onPointerDown: (e) => {
|
|
30
|
+
E.current = !1, p && e.button === 0 && (T.current = {
|
|
31
|
+
id: e.pointerId,
|
|
32
|
+
x: e.clientX,
|
|
33
|
+
y: e.clientY,
|
|
34
|
+
origin: x,
|
|
35
|
+
moved: !1
|
|
36
|
+
}, e.currentTarget.setPointerCapture(e.pointerId));
|
|
37
|
+
},
|
|
38
|
+
onPointerMove: (e) => {
|
|
39
|
+
let t = T.current;
|
|
40
|
+
if (!t || t.id !== e.pointerId) return;
|
|
41
|
+
let n = e.clientX - t.x, r = e.clientY - t.y;
|
|
42
|
+
Math.abs(n) + Math.abs(r) > 4 && (t.moved = !0), t.moved && S(D({
|
|
43
|
+
x: t.origin.x + n,
|
|
44
|
+
y: t.origin.y + r
|
|
45
|
+
}));
|
|
46
|
+
},
|
|
47
|
+
onPointerUp: (e) => {
|
|
48
|
+
E.current = T.current?.moved ?? !1, T.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId);
|
|
49
|
+
},
|
|
50
|
+
onPointerCancel: () => {
|
|
51
|
+
T.current = null;
|
|
52
|
+
},
|
|
53
|
+
onLostPointerCapture: () => {
|
|
54
|
+
T.current = null;
|
|
55
|
+
},
|
|
56
|
+
onKeyDown: (e) => {
|
|
57
|
+
if (!p) return;
|
|
58
|
+
let t = e.shiftKey ? 32 : 8, n = {
|
|
59
|
+
ArrowLeft: [-t, 0],
|
|
60
|
+
ArrowRight: [t, 0],
|
|
61
|
+
ArrowUp: [0, -t],
|
|
62
|
+
ArrowDown: [0, t]
|
|
63
|
+
}[e.key];
|
|
64
|
+
n && (e.preventDefault(), S((e) => D({
|
|
65
|
+
x: e.x + n[0],
|
|
66
|
+
y: e.y + n[1]
|
|
67
|
+
})));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return /* @__PURE__ */ s("div", {
|
|
71
|
+
..._,
|
|
72
|
+
ref: C,
|
|
73
|
+
className: e("dishui-page-float absolute z-30 overflow-hidden border border-base-300 bg-base-100 text-base-content shadow-sm", b ? "rounded-full" : "rounded-lg", m),
|
|
74
|
+
"data-collapsed": b,
|
|
75
|
+
style: {
|
|
76
|
+
width: 288,
|
|
77
|
+
maxWidth: "100%",
|
|
78
|
+
maxHeight: "100%",
|
|
79
|
+
...h,
|
|
80
|
+
...b ? {
|
|
81
|
+
boxSizing: "border-box",
|
|
82
|
+
width: 48,
|
|
83
|
+
height: 48,
|
|
84
|
+
minWidth: 48,
|
|
85
|
+
minHeight: 48,
|
|
86
|
+
maxWidth: 48,
|
|
87
|
+
maxHeight: 48,
|
|
88
|
+
padding: 0,
|
|
89
|
+
borderRadius: "50%"
|
|
90
|
+
} : {},
|
|
91
|
+
left: x.x,
|
|
92
|
+
top: x.y
|
|
93
|
+
},
|
|
94
|
+
children: [/* @__PURE__ */ s("div", {
|
|
95
|
+
className: e("flex items-center border-base-300", b && "h-full w-full"),
|
|
96
|
+
children: [!b && /* @__PURE__ */ o("button", {
|
|
97
|
+
type: "button",
|
|
98
|
+
...k,
|
|
99
|
+
onClick: () => {
|
|
100
|
+
E.current = !1;
|
|
101
|
+
},
|
|
102
|
+
"aria-label": `${c}: move with arrow keys`,
|
|
103
|
+
className: "min-w-0 flex-1 truncate px-3 py-2 text-left text-sm font-medium focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",
|
|
104
|
+
style: {
|
|
105
|
+
touchAction: p ? "none" : void 0,
|
|
106
|
+
cursor: p ? "grab" : void 0
|
|
107
|
+
},
|
|
108
|
+
children: c
|
|
109
|
+
}), /* @__PURE__ */ o("button", {
|
|
110
|
+
ref: w,
|
|
111
|
+
type: "button",
|
|
112
|
+
...b ? k : {},
|
|
113
|
+
"aria-label": `${b ? "Expand" : "Collapse"} ${c}`,
|
|
114
|
+
"aria-expanded": !b,
|
|
115
|
+
title: `${b ? "Expand" : "Collapse"} ${c}`,
|
|
116
|
+
className: e("dishui-page-float-toggle flex shrink-0 items-center justify-center focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary", b ? "h-full w-full rounded-full" : "h-9 w-9 rounded-md"),
|
|
117
|
+
style: {
|
|
118
|
+
touchAction: b && p ? "none" : void 0,
|
|
119
|
+
cursor: b && p ? "grab" : "pointer"
|
|
120
|
+
},
|
|
121
|
+
onClick: () => {
|
|
122
|
+
E.current || O(), E.current = !1;
|
|
123
|
+
},
|
|
124
|
+
children: /* @__PURE__ */ o("svg", {
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
width: "20",
|
|
127
|
+
height: "20",
|
|
128
|
+
viewBox: "0 0 24 24",
|
|
129
|
+
fill: "none",
|
|
130
|
+
stroke: "currentColor",
|
|
131
|
+
strokeWidth: "1.75",
|
|
132
|
+
strokeLinecap: "round",
|
|
133
|
+
strokeLinejoin: "round",
|
|
134
|
+
children: b ? /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("rect", {
|
|
135
|
+
x: "4",
|
|
136
|
+
y: "4",
|
|
137
|
+
width: "16",
|
|
138
|
+
height: "16",
|
|
139
|
+
rx: "3"
|
|
140
|
+
}), /* @__PURE__ */ o("path", { d: "M4 10h16M9 4v6" })] }) : /* @__PURE__ */ o("path", { d: "M6 12h12" })
|
|
141
|
+
})
|
|
142
|
+
})]
|
|
143
|
+
}), /* @__PURE__ */ o("div", {
|
|
144
|
+
hidden: b,
|
|
145
|
+
className: "overflow-auto border-t border-base-300 p-3 text-sm",
|
|
146
|
+
style: { maxHeight: "min(60vh, 360px)" },
|
|
147
|
+
children: g
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { c as default };
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=Float2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Float2.js","names":[],"sources":["../../../src/components/Page/Float.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { cn } from '../../utils/cn';\nimport './Float.css';\n\nexport type PageFloatProps = React.HTMLAttributes<HTMLDivElement> & {\n title?: string;\n collapsed?: boolean;\n defaultCollapsed?: boolean;\n onCollapsedChange?: (collapsed: boolean) => void;\n defaultPosition?: { x: number; y: number };\n draggable?: boolean;\n};\n\n/** Coordinates are relative to the containing Page; dragging is confined to it. */\nexport default function PageFloat({\n title = 'Float', collapsed, defaultCollapsed = false, onCollapsedChange,\n defaultPosition = { x: 16, y: 16 }, draggable = true,\n className, style, children, ...rest\n}: PageFloatProps) {\n const [internalCollapsed, setInternalCollapsed] = useState(defaultCollapsed);\n const isCollapsed = collapsed ?? internalCollapsed;\n const [position, setPosition] = useState(defaultPosition);\n const root = useRef<HTMLDivElement>(null);\n const toggle = useRef<HTMLButtonElement>(null);\n const drag = useRef<{ id: number; x: number; y: number; origin: typeof position; moved: boolean } | null>(null);\n const suppressClick = useRef(false);\n const clamp = useCallback((next: typeof position) => {\n const element = root.current;\n const parent = element?.offsetParent as HTMLElement | null;\n if (!element || !parent) return next;\n return {\n x: Math.max(0, Math.min(next.x, parent.clientWidth - element.offsetWidth)),\n y: Math.max(0, Math.min(next.y, parent.clientHeight - element.offsetHeight)),\n };\n }, []);\n useEffect(() => {\n const update = () => setPosition(current => {\n const next = clamp(current);\n return next.x === current.x && next.y === current.y ? current : next;\n });\n update();\n const observer = new ResizeObserver(update);\n if (root.current) observer.observe(root.current);\n if (root.current?.offsetParent) observer.observe(root.current.offsetParent);\n return () => observer.disconnect();\n }, [clamp, isCollapsed]);\n const changeCollapsed = () => {\n setInternalCollapsed(!isCollapsed);\n onCollapsedChange?.(!isCollapsed);\n toggle.current?.focus();\n };\n const dragEvents = {\n onPointerDown: (event: React.PointerEvent<HTMLButtonElement>) => {\n suppressClick.current = false;\n if (!draggable || event.button !== 0) return;\n drag.current = { id: event.pointerId, x: event.clientX, y: event.clientY, origin: position, moved: false };\n event.currentTarget.setPointerCapture(event.pointerId);\n },\n onPointerMove: (event: React.PointerEvent<HTMLButtonElement>) => {\n const current = drag.current;\n if (!current || current.id !== event.pointerId) return;\n const dx = event.clientX - current.x;\n const dy = event.clientY - current.y;\n if (Math.abs(dx) + Math.abs(dy) > 4) current.moved = true;\n if (current.moved) setPosition(clamp({ x: current.origin.x + dx, y: current.origin.y + dy }));\n },\n onPointerUp: (event: React.PointerEvent<HTMLButtonElement>) => {\n suppressClick.current = drag.current?.moved ?? false;\n drag.current = null;\n if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);\n },\n onPointerCancel: () => { drag.current = null; },\n onLostPointerCapture: () => { drag.current = null; },\n onKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (!draggable) return;\n const delta = event.shiftKey ? 32 : 8;\n const offsets: Record<string, [number, number]> = { ArrowLeft: [-delta, 0], ArrowRight: [delta, 0], ArrowUp: [0, -delta], ArrowDown: [0, delta] };\n const offset = offsets[event.key];\n if (!offset) return;\n event.preventDefault();\n setPosition(current => clamp({ x: current.x + offset[0], y: current.y + offset[1] }));\n },\n };\n return (\n <div {...rest} ref={root} className={cn('dishui-page-float absolute z-30 overflow-hidden border border-base-300 bg-base-100 text-base-content shadow-sm', isCollapsed ? 'rounded-full' : 'rounded-lg', className)}\n data-collapsed={isCollapsed}\n style={{ width: 288, maxWidth: '100%', maxHeight: '100%', ...style,\n ...(isCollapsed ? { boxSizing: 'border-box', width: 48, height: 48, minWidth: 48, minHeight: 48, maxWidth: 48, maxHeight: 48, padding: 0, borderRadius: '50%' } as React.CSSProperties : {}),\n left: position.x, top: position.y }}>\n <div className={cn('flex items-center border-base-300', isCollapsed && 'h-full w-full')}>\n {!isCollapsed && <button type=\"button\" {...dragEvents} onClick={() => { suppressClick.current = false; }} aria-label={`${title}: move with arrow keys`} className=\"min-w-0 flex-1 truncate px-3 py-2 text-left text-sm font-medium focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary\" style={{ touchAction: draggable ? 'none' : undefined, cursor: draggable ? 'grab' : undefined }}>{title}</button>}\n <button ref={toggle} type=\"button\" {...(isCollapsed ? dragEvents : {})} aria-label={`${isCollapsed ? 'Expand' : 'Collapse'} ${title}`} aria-expanded={!isCollapsed}\n title={`${isCollapsed ? 'Expand' : 'Collapse'} ${title}`}\n className={cn('dishui-page-float-toggle flex shrink-0 items-center justify-center focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary', isCollapsed ? 'h-full w-full rounded-full' : 'h-9 w-9 rounded-md')}\n style={{ touchAction: isCollapsed && draggable ? 'none' : undefined, cursor: isCollapsed && draggable ? 'grab' : 'pointer' }}\n onClick={() => { if (!suppressClick.current) changeCollapsed(); suppressClick.current = false; }}>\n <svg aria-hidden=\"true\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.75\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n {isCollapsed ? <><rect x=\"4\" y=\"4\" width=\"16\" height=\"16\" rx=\"3\" /><path d=\"M4 10h16M9 4v6\" /></> : <path d=\"M6 12h12\" />}\n </svg>\n </button>\n </div>\n <div hidden={isCollapsed} className=\"overflow-auto border-t border-base-300 p-3 text-sm\" style={{ maxHeight: 'min(60vh, 360px)' }}>{children}</div>\n </div>\n );\n}\n"],"mappings":";;;;;AAcA,SAAwB,EAAU,EAC9B,WAAQ,SAAS,cAAW,sBAAmB,IAAO,sBACtD,qBAAkB;CAAE,GAAG;CAAI,GAAG;AAAG,GAAG,eAAY,IAChD,cAAW,UAAO,aAAU,GAAG,KAChB;CACf,IAAM,CAAC,GAAmB,KAAwB,EAAS,CAAgB,GACrE,IAAc,KAAa,GAC3B,CAAC,GAAU,KAAe,EAAS,CAAe,GAClD,IAAO,EAAuB,IAAI,GAClC,IAAS,EAA0B,IAAI,GACvC,IAAO,EAA6F,IAAI,GACxG,IAAgB,EAAO,EAAK,GAC5B,IAAQ,GAAa,MAA0B;EACjD,IAAM,IAAU,EAAK,SACf,IAAS,GAAS;EAExB,OADI,CAAC,KAAW,CAAC,IAAe,IACzB;GACH,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,EAAK,GAAG,EAAO,cAAc,EAAQ,WAAW,CAAC;GACzE,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,EAAK,GAAG,EAAO,eAAe,EAAQ,YAAY,CAAC;EAC/E;CACJ,GAAG,CAAC,CAAC;CACL,QAAgB;EACZ,IAAM,UAAe,GAAY,MAAW;GACxC,IAAM,IAAO,EAAM,CAAO;GAC1B,OAAO,EAAK,MAAM,EAAQ,KAAK,EAAK,MAAM,EAAQ,IAAI,IAAU;EACpE,CAAC;EACD,EAAO;EACP,IAAM,IAAW,IAAI,eAAe,CAAM;EAG1C,OAFI,EAAK,WAAS,EAAS,QAAQ,EAAK,OAAO,GAC3C,EAAK,SAAS,gBAAc,EAAS,QAAQ,EAAK,QAAQ,YAAY,SAC7D,EAAS,WAAW;CACrC,GAAG,CAAC,GAAO,CAAW,CAAC;CACvB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Q;KAAY,MAAK;KAAO,QAAO;KAAe,aAAY;KAAO,eAAc;KAAQ,gBAAe;KACpI,UAAA,IAAc,kBAAA,GAAA,EAAA,UAAA,CAAE,kBAAC,QAAD;MAAM,GAAE;MAAI,GAAE;MAAI,OAAM;MAAK,QAAO;MAAK,IAAG;KAAK,CAAA,GAAC,kBAAC,QAAD,EAAM,GAAE,iBAAkB,CAAA,CAAG,EAAA,CAAA,IAAI,kBAAC,QAAD,EAAM,GAAE,WAAY,CAAA;IACvH,CAAA;GACrB,CAAA,CACP;EACL,CAAA,GAAA,kBAAC,OAAD;GAAK,QAAQ;GAAa,WAAU;GAAqD,OAAO,EAAE,WAAW,mBAAmB;GAAI;EAAc,CAAA,CACjJ;;AAEb"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import PageFloat from './Float';
|
|
3
|
+
import { type PageResizeProps } from './resize';
|
|
4
|
+
export type { PageFloatProps } from './Float';
|
|
2
5
|
import { PageHeaderProps } from '../PageHeader';
|
|
6
|
+
import { type PagePanelProps, type PageAutoHideProps } from '../PagePanel';
|
|
7
|
+
export type { PagePanelProps } from '../PagePanel';
|
|
3
8
|
/**
|
|
4
9
|
* Page 布局脚手架
|
|
5
10
|
* ----------------------------------------------------------------------------
|
|
@@ -26,8 +31,22 @@ export type PageBodyProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
26
31
|
/** 是否让主体区在剩余空间内滚动(配合 Page fullHeight 使用) */
|
|
27
32
|
scroll?: boolean;
|
|
28
33
|
};
|
|
29
|
-
export type
|
|
30
|
-
|
|
34
|
+
export type PageHeaderLevel = PageHeaderProps & {
|
|
35
|
+
key: React.Key;
|
|
36
|
+
};
|
|
37
|
+
export type PageHeaderSlotProps = PageHeaderProps & {
|
|
38
|
+
/** 按顺序从上到下渲染;每级覆盖公共属性。空数组不渲染页头。 */
|
|
39
|
+
levels?: readonly PageHeaderLevel[];
|
|
40
|
+
};
|
|
41
|
+
export type PageAsideLevel = PageAsideProps & {
|
|
42
|
+
key: React.Key;
|
|
43
|
+
};
|
|
44
|
+
export type PageAsideSlotProps = PageAsideProps & {
|
|
45
|
+
/** 按 DOM 顺序从左到右渲染(小屏纵向堆叠);每级覆盖公共属性。 */
|
|
46
|
+
levels?: readonly PageAsideLevel[];
|
|
47
|
+
};
|
|
48
|
+
export type PageAsideProps = React.HTMLAttributes<HTMLDivElement> & PagePanelProps & PageResizeProps & {
|
|
49
|
+
/** 侧栏宽度,数字按 px 处理;Left 默认 260,Right 默认 320。外部变化会同步到拖动宽度。 */
|
|
31
50
|
width?: number | string;
|
|
32
51
|
/** 是否显示分隔边框 */
|
|
33
52
|
bordered?: boolean;
|
|
@@ -40,19 +59,27 @@ export type PageMainProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
40
59
|
/** 主内容区是否在剩余空间内纵向滚动 */
|
|
41
60
|
scroll?: boolean;
|
|
42
61
|
};
|
|
43
|
-
/**
|
|
44
|
-
declare const PageHeaderSlot: (props:
|
|
62
|
+
/** 不增加包装节点,保持 Page / Body 的布局、间距及面板开关语义。 */
|
|
63
|
+
declare const PageHeaderSlot: ({ levels, ...props }: PageHeaderSlotProps) => React.JSX.Element;
|
|
45
64
|
declare const PageBody: ({ gap, scroll, className, style, children, ...rest }: PageBodyProps) => React.JSX.Element;
|
|
46
|
-
declare const PageLeft: ({
|
|
47
|
-
declare const PageRight: ({
|
|
65
|
+
declare const PageLeft: ({ levels, ...props }: PageAsideSlotProps) => React.ReactElement;
|
|
66
|
+
declare const PageRight: ({ levels, ...props }: PageAsideSlotProps) => React.ReactElement;
|
|
67
|
+
export type PageFooterProps = React.HTMLAttributes<HTMLElement> & PagePanelProps & PageAutoHideProps & {
|
|
68
|
+
left?: React.ReactNode;
|
|
69
|
+
center?: React.ReactNode;
|
|
70
|
+
right?: React.ReactNode;
|
|
71
|
+
};
|
|
72
|
+
declare const PageFooter: ({ open, mode, animated, duration, autoHide, className, children, left, center, right, ...rest }: PageFooterProps) => React.JSX.Element;
|
|
48
73
|
declare const PageMain: ({ scroll, className, children, ...rest }: PageMainProps) => React.JSX.Element;
|
|
49
74
|
interface PageCompound extends React.FC<PageProps> {
|
|
50
75
|
Header: typeof PageHeaderSlot;
|
|
76
|
+
Footer: typeof PageFooter;
|
|
77
|
+
Float: typeof PageFloat;
|
|
51
78
|
Body: typeof PageBody;
|
|
52
79
|
Left: typeof PageLeft;
|
|
53
80
|
Right: typeof PageRight;
|
|
54
81
|
Main: typeof PageMain;
|
|
55
82
|
}
|
|
56
83
|
declare const PageWithCompounds: PageCompound;
|
|
57
|
-
export { PageBody, PageLeft, PageRight, PageMain };
|
|
84
|
+
export { PageBody, PageLeft, PageRight, PageMain, PageFooter, PageFloat };
|
|
58
85
|
export default PageWithCompounds;
|
|
@@ -1,43 +1,124 @@
|
|
|
1
1
|
import { cn as e } from "../../utils/cn.js";
|
|
2
|
-
import t from "../
|
|
3
|
-
import "
|
|
4
|
-
import
|
|
2
|
+
import t from "../PagePanel/index.js";
|
|
3
|
+
import n from "../PageHeader/index.js";
|
|
4
|
+
import r from "./Float2.js";
|
|
5
|
+
import i from "./resize2.js";
|
|
6
|
+
import { createElement as a } from "react";
|
|
7
|
+
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
5
8
|
//#region src/components/Page/index.tsx
|
|
6
|
-
var
|
|
7
|
-
className: e("dishui-page flex w-full min-w-0 flex-col text-body leading-5 text-base-content", t && "h-full min-h-0",
|
|
8
|
-
...
|
|
9
|
-
children:
|
|
10
|
-
}),
|
|
11
|
-
|
|
9
|
+
var l = (e) => typeof e == "number" ? `${e}px` : e, u = ({ fullHeight: t = !1, className: n = "", children: r, ...i }) => /* @__PURE__ */ s("div", {
|
|
10
|
+
className: e("dishui-page flex w-full min-w-0 flex-col text-body leading-5 text-base-content", t && "h-full min-h-0", n),
|
|
11
|
+
...i,
|
|
12
|
+
children: r
|
|
13
|
+
}), d = ({ levels: e, ...t }) => e === void 0 ? /* @__PURE__ */ s(n, { ...t }) : /* @__PURE__ */ s(o, { children: e.map(({ key: e, ...r }) => /* @__PURE__ */ a(n, {
|
|
14
|
+
...t,
|
|
15
|
+
...r,
|
|
16
|
+
key: e
|
|
17
|
+
})) }), f = ({ gap: t = 16, scroll: n = !1, className: r = "", style: i, children: a, ...o }) => /* @__PURE__ */ s("div", {
|
|
18
|
+
className: e("dishui-page-body flex w-full flex-col md:flex-row", n && "min-h-0 flex-1", r),
|
|
12
19
|
style: {
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
...i,
|
|
21
|
+
gap: 0,
|
|
22
|
+
"--dishui-page-gap": l(i?.gap ?? t)
|
|
15
23
|
},
|
|
16
|
-
...
|
|
17
|
-
children:
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
...o,
|
|
25
|
+
children: a
|
|
26
|
+
}), p = ({ levels: e, ...t }) => e === void 0 ? m(t) : /* @__PURE__ */ s(o, { children: e.map(({ key: e, ...n }) => /* @__PURE__ */ a(m, {
|
|
27
|
+
...t,
|
|
28
|
+
...n,
|
|
29
|
+
key: e
|
|
30
|
+
})) }), m = ({ resizeVariant: n = "pill", resizable: r = !1, minWidth: a = 160, maxWidth: o = 600, onWidthChange: c, open: u, mode: d, animated: f, duration: p, width: m = 260, bordered: h = !0, scroll: g = !0, hideOnMobile: _ = !1, className: v = "", style: y, children: b, ...x }) => {
|
|
31
|
+
let S = /* @__PURE__ */ s(t, {
|
|
32
|
+
edge: "left",
|
|
33
|
+
width: y?.width ?? m,
|
|
34
|
+
hideOnMobile: _,
|
|
35
|
+
open: u,
|
|
36
|
+
mode: d,
|
|
37
|
+
animated: f,
|
|
38
|
+
duration: p,
|
|
39
|
+
children: /* @__PURE__ */ s("aside", {
|
|
40
|
+
className: e("dishui-page-left w-full shrink-0 md:w-(--dishui-aside-w)", h && "md:border-r md:border-base-300 md:pr-4", g && "md:min-h-0 md:overflow-y-auto", _ && "hidden md:block", v),
|
|
41
|
+
style: {
|
|
42
|
+
"--dishui-aside-w": l(m),
|
|
43
|
+
...y
|
|
44
|
+
},
|
|
45
|
+
...x,
|
|
46
|
+
children: b
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
return r ? /* @__PURE__ */ s(i, {
|
|
50
|
+
panel: S,
|
|
51
|
+
resizeVariant: n,
|
|
52
|
+
minWidth: a,
|
|
53
|
+
maxWidth: o,
|
|
54
|
+
onWidthChange: c
|
|
55
|
+
}) : S;
|
|
56
|
+
}, h = ({ levels: e, ...t }) => e === void 0 ? g(t) : /* @__PURE__ */ s(o, { children: e.map(({ key: e, ...n }) => /* @__PURE__ */ a(g, {
|
|
57
|
+
...t,
|
|
58
|
+
...n,
|
|
59
|
+
key: e
|
|
60
|
+
})) }), g = ({ resizeVariant: n = "pill", resizable: r = !1, minWidth: a = 160, maxWidth: o = 600, onWidthChange: c, open: u, mode: d, animated: f, duration: p, width: m = 320, bordered: h = !0, scroll: g = !0, hideOnMobile: _ = !1, className: v = "", style: y, children: b, ...x }) => {
|
|
61
|
+
let S = /* @__PURE__ */ s(t, {
|
|
62
|
+
edge: "right",
|
|
63
|
+
width: y?.width ?? m,
|
|
64
|
+
hideOnMobile: _,
|
|
65
|
+
open: u,
|
|
66
|
+
mode: d,
|
|
67
|
+
animated: f,
|
|
68
|
+
duration: p,
|
|
69
|
+
children: /* @__PURE__ */ s("aside", {
|
|
70
|
+
className: e("dishui-page-right w-full shrink-0 md:w-(--dishui-aside-w)", h && "md:border-l md:border-base-300 md:pl-4", g && "md:min-h-0 md:overflow-y-auto", _ && "hidden md:block", v),
|
|
71
|
+
style: {
|
|
72
|
+
"--dishui-aside-w": l(m),
|
|
73
|
+
...y
|
|
74
|
+
},
|
|
75
|
+
...x,
|
|
76
|
+
children: b
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
return r ? /* @__PURE__ */ s(i, {
|
|
80
|
+
panel: S,
|
|
81
|
+
resizeVariant: n,
|
|
82
|
+
minWidth: a,
|
|
83
|
+
maxWidth: o,
|
|
84
|
+
onWidthChange: c
|
|
85
|
+
}) : S;
|
|
86
|
+
}, _ = ({ open: n, mode: r, animated: i, duration: a, autoHide: o, className: l, children: u, left: d, center: f, right: p, ...m }) => /* @__PURE__ */ s(t, {
|
|
87
|
+
edge: "footer",
|
|
88
|
+
autoHide: o,
|
|
89
|
+
open: n,
|
|
90
|
+
mode: r,
|
|
91
|
+
animated: i,
|
|
92
|
+
duration: a,
|
|
93
|
+
children: /* @__PURE__ */ s("footer", {
|
|
94
|
+
className: e("dishui-page-footer", l),
|
|
95
|
+
...m,
|
|
96
|
+
children: u === void 0 ? /* @__PURE__ */ c("div", {
|
|
97
|
+
className: "dishui-page-header-layout",
|
|
98
|
+
"data-centered": f != null && f !== !1 || void 0,
|
|
99
|
+
children: [
|
|
100
|
+
d != null && /* @__PURE__ */ s("div", {
|
|
101
|
+
className: "dishui-page-header-left",
|
|
102
|
+
children: d
|
|
103
|
+
}),
|
|
104
|
+
f != null && /* @__PURE__ */ s("div", {
|
|
105
|
+
className: "dishui-page-header-center",
|
|
106
|
+
children: f
|
|
107
|
+
}),
|
|
108
|
+
p != null && /* @__PURE__ */ s("div", {
|
|
109
|
+
className: "dishui-page-header-right",
|
|
110
|
+
children: p
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}) : u
|
|
114
|
+
})
|
|
115
|
+
}), v = ({ scroll: t = !1, className: n = "", children: r, ...i }) => /* @__PURE__ */ s("main", {
|
|
116
|
+
className: e("dishui-page-main min-w-0 flex-1", t && "min-h-0 overflow-y-auto", n),
|
|
117
|
+
...i,
|
|
118
|
+
children: r
|
|
119
|
+
}), y = u;
|
|
120
|
+
y.Header = d, y.Footer = _, y.Float = r, y.Body = f, y.Left = p, y.Right = h, y.Main = v;
|
|
40
121
|
//#endregion
|
|
41
|
-
export {
|
|
122
|
+
export { f as PageBody, r as PageFloat, _ as PageFooter, p as PageLeft, v as PageMain, h as PageRight, y as default };
|
|
42
123
|
|
|
43
124
|
//# sourceMappingURL=index.js.map
|