dishui 0.0.78 → 0.0.80
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/Avatar/index.d.ts +6 -4
- package/dist/components/Avatar/index.js +39 -28
- package/dist/components/Avatar/index.js.map +1 -1
- package/dist/components/Card/index.d.ts +16 -8
- package/dist/components/Card/index.js +81 -99
- package/dist/components/Card/index.js.map +1 -1
- package/dist/components/DateTimeInput/index.js +3 -2
- package/dist/components/DateTimeInput/index.js.map +1 -1
- package/dist/components/GroupedTable/index.d.ts +2 -1
- package/dist/components/GroupedTable/index.js +96 -37
- package/dist/components/GroupedTable/index.js.map +1 -1
- package/dist/components/Input/index.d.ts +2 -2
- package/dist/components/Input/index.js +129 -111
- package/dist/components/Input/index.js.map +1 -1
- package/dist/components/Label/index.js +1 -1
- package/dist/components/Label/index.js.map +1 -1
- package/dist/components/NavigationList/index.js +55 -24
- package/dist/components/NavigationList/index.js.map +1 -1
- package/dist/components/Resizable/index.d.ts +28 -0
- package/dist/components/Resizable/index.js +128 -0
- package/dist/components/Resizable/index.js.map +1 -0
- package/dist/components/Resizable/useResize.d.ts +21 -0
- package/dist/components/Resizable/useResize.js +60 -0
- package/dist/components/Resizable/useResize.js.map +1 -0
- package/dist/components/SidebarToggleButton/index.js +51 -43
- package/dist/components/SidebarToggleButton/index.js.map +1 -1
- package/dist/components/Slider/index.d.ts +17 -3
- package/dist/components/Slider/index.js +131 -28
- package/dist/components/Slider/index.js.map +1 -1
- package/dist/components/pro/RichTextEditor/RichTextEditor.js +62 -62
- package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
- package/dist/components/pro/RichTextEditor/extensions/ResizableImage.d.ts +2 -0
- package/dist/components/pro/RichTextEditor/extensions/ResizableImage.js +94 -0
- package/dist/components/pro/RichTextEditor/extensions/ResizableImage.js.map +1 -0
- package/dist/components/pro/RichTextEditor/index.d.ts +1 -0
- package/dist/dishui.css +1 -1
- package/dist/index-nostyled.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +123 -121
- package/dist/layouts/Sidebar.js +34 -45
- package/dist/layouts/Sidebar.js.map +1 -1
- package/dist/lite.d.ts +2 -0
- package/dist/lite.js +20 -18
- package/dist/utils/i18n.js +145 -75
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/menu.js +85 -8
- package/dist/utils/menu.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export { useResize } from './useResize';
|
|
3
|
+
export type { UseResizeOptions } from './useResize';
|
|
4
|
+
export interface ResizablePanelProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
minSize?: number;
|
|
6
|
+
maxSize?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ResizableHandleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
variant?: 'line' | 'pill';
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
step?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface ResizableProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
orientation?: 'horizontal' | 'vertical';
|
|
15
|
+
sizes?: number[];
|
|
16
|
+
defaultSizes?: number[];
|
|
17
|
+
onSizesChange?: (sizes: number[]) => void;
|
|
18
|
+
onSizesCommit?: (sizes: number[]) => void;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function ResizablePanel({ minSize: _min, maxSize: _max, className, style, ...props }: ResizablePanelProps): React.JSX.Element;
|
|
22
|
+
export declare function ResizableHandle({ variant, disabled, step, className, onPointerDown, onKeyDown, onClickCapture, children, ...props }: ResizableHandleProps): React.JSX.Element;
|
|
23
|
+
declare function ResizableRoot({ orientation, sizes: controlled, defaultSizes, onSizesChange, onSizesCommit, disabled, children, className, style, ...props }: ResizableProps): React.JSX.Element;
|
|
24
|
+
export declare const Resizable: typeof ResizableRoot & {
|
|
25
|
+
Panel: typeof ResizablePanel;
|
|
26
|
+
Handle: typeof ResizableHandle;
|
|
27
|
+
};
|
|
28
|
+
export default Resizable;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { useResize as e } from "./useResize.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import { Children as t, createContext as n, isValidElement as r, useContext as i, useId as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
|
|
4
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Resizable/index.tsx
|
|
6
|
+
var u = n(null), d = n(0);
|
|
7
|
+
function f({ minSize: e, maxSize: t, className: n = "", style: r, ...a }) {
|
|
8
|
+
let o = i(u), s = i(d);
|
|
9
|
+
if (!o) throw Error("Resizable.Panel must be inside Resizable");
|
|
10
|
+
return /* @__PURE__ */ l("div", {
|
|
11
|
+
...a,
|
|
12
|
+
id: o.ids[s],
|
|
13
|
+
className: `dishui-resizable-panel ${n}`,
|
|
14
|
+
style: {
|
|
15
|
+
...r,
|
|
16
|
+
flex: `${o.sizes[s]} 1 0px`
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function p({ variant: t = "line", disabled: n = !1, step: r = 1, className: a = "", onPointerDown: o, onKeyDown: s, onClickCapture: c, children: f, ...p }) {
|
|
21
|
+
let m = i(u), h = i(d);
|
|
22
|
+
if (!m) throw Error("Resizable.Handle must be inside Resizable");
|
|
23
|
+
let g = m.sizes[h] + m.sizes[h + 1], _ = Math.max(m.bounds[h].min, g - m.bounds[h + 1].max), v = Math.min(m.bounds[h].max, g - m.bounds[h + 1].min), y = n || m.disabled || _ >= v, b = e({
|
|
24
|
+
orientation: m.orientation,
|
|
25
|
+
value: m.sizes[h],
|
|
26
|
+
min: _,
|
|
27
|
+
max: v,
|
|
28
|
+
disabled: y,
|
|
29
|
+
step: r,
|
|
30
|
+
getScale: () => {
|
|
31
|
+
let e = m.root.current;
|
|
32
|
+
if (!e) return 0;
|
|
33
|
+
let t = m.orientation === "horizontal" ? "width" : "height", n = Array.from(e.children).filter((e) => e.classList.contains("dishui-resizable-panel")).reduce((e, n) => e + n.getBoundingClientRect()[t], 0), r = m.orientation === "horizontal" && getComputedStyle(e).direction === "rtl";
|
|
34
|
+
return n > 0 ? (r ? -100 : 100) / n : 0;
|
|
35
|
+
},
|
|
36
|
+
onChange: (e) => m.change(h, e),
|
|
37
|
+
onCommit: (e) => m.change(h, e, !0)
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ l("div", {
|
|
40
|
+
...p,
|
|
41
|
+
role: "separator",
|
|
42
|
+
tabIndex: y ? -1 : 0,
|
|
43
|
+
"aria-label": p["aria-label"] ?? "Resize panels",
|
|
44
|
+
"aria-orientation": m.orientation === "horizontal" ? "vertical" : "horizontal",
|
|
45
|
+
"aria-controls": m.ids[h],
|
|
46
|
+
"aria-valuemin": _,
|
|
47
|
+
"aria-valuemax": v,
|
|
48
|
+
"aria-valuenow": m.sizes[h],
|
|
49
|
+
"aria-valuetext": `${Number(m.sizes[h].toFixed(2))}%`,
|
|
50
|
+
"aria-disabled": y,
|
|
51
|
+
"data-orientation": m.orientation,
|
|
52
|
+
"data-variant": t,
|
|
53
|
+
"data-dragging": b.dragging || void 0,
|
|
54
|
+
className: `dishui-resizable-handle ${a}`,
|
|
55
|
+
onPointerDown: (e) => {
|
|
56
|
+
o?.(e), e.defaultPrevented || b.onPointerDown(e);
|
|
57
|
+
},
|
|
58
|
+
onKeyDown: (e) => {
|
|
59
|
+
s?.(e), e.defaultPrevented || b.onKeyDown(e);
|
|
60
|
+
},
|
|
61
|
+
onClickCapture: (e) => {
|
|
62
|
+
b.onClickCapture(e), e.defaultPrevented || c?.(e);
|
|
63
|
+
},
|
|
64
|
+
children: f ?? (t === "pill" ? /* @__PURE__ */ l("span", {
|
|
65
|
+
className: "dishui-resizable-grip",
|
|
66
|
+
"aria-hidden": "true"
|
|
67
|
+
}) : null)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function m({ orientation: e = "horizontal", sizes: n, defaultSizes: i, onSizesChange: m, onSizesCommit: h, disabled: g = !1, children: _, className: v = "", style: y, ...b }) {
|
|
71
|
+
let x = s(null), S = a(), C = t.toArray(_);
|
|
72
|
+
if (!C.length || C.some((e, t) => !r(e) || e.type !== (t % 2 == 0 ? f : p)) || C.length % 2 == 0) throw Error("Resizable requires alternating Panel / Handle children, starting and ending with Panel. Nest groups inside a Panel.");
|
|
73
|
+
let w = C.filter((e, t) => t % 2 == 0), T = w.map((e) => ({
|
|
74
|
+
min: e.props.minSize ?? 0,
|
|
75
|
+
max: e.props.maxSize ?? 100
|
|
76
|
+
}));
|
|
77
|
+
if (T.some((e) => !Number.isFinite(e.min) || !Number.isFinite(e.max) || e.min < 0 || e.max > 100 || e.min > e.max) || T.reduce((e, t) => e + t.min, 0) > 100 || T.reduce((e, t) => e + t.max, 0) < 100) throw Error("Resizable panel constraints must be feasible percentages between 0 and 100");
|
|
78
|
+
let E = (e) => {
|
|
79
|
+
if (e && (e.length !== w.length || e.some((e) => !Number.isFinite(e) || e < 0) || Math.abs(e.reduce((e, t) => e + t, 0) - 100) > .001)) throw Error("Resizable sizes must match the panel count and sum to 100");
|
|
80
|
+
let t = T.map((t, n) => Math.max(t.min, Math.min(t.max, e?.[n] ?? 100 / w.length))), n = 100 - t.reduce((e, t) => e + t, 0);
|
|
81
|
+
for (let e = 0; e < t.length && Math.abs(n) > 1e-8; e++) {
|
|
82
|
+
let r = Math.max(T[e].min - t[e], Math.min(T[e].max - t[e], n));
|
|
83
|
+
t[e] += r, n -= r;
|
|
84
|
+
}
|
|
85
|
+
return t;
|
|
86
|
+
}, [D, O] = c(() => E(i)), k = E(n ?? (D.length === w.length ? D : void 0)), A = s(k);
|
|
87
|
+
o(() => {
|
|
88
|
+
A.current = k;
|
|
89
|
+
});
|
|
90
|
+
let j = (e, t, r = !1) => {
|
|
91
|
+
let i = [...A.current], a = i[e] + i[e + 1];
|
|
92
|
+
if (i[e] = t, i[e + 1] = a - t, r) {
|
|
93
|
+
h?.(i);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
n || (A.current = i, O(i)), m?.(i);
|
|
97
|
+
}, M = w.map((e, t) => e.props.id ?? `${S}-panel-${t}`);
|
|
98
|
+
return /* @__PURE__ */ l(u.Provider, {
|
|
99
|
+
value: {
|
|
100
|
+
orientation: e,
|
|
101
|
+
disabled: g,
|
|
102
|
+
sizes: k,
|
|
103
|
+
bounds: T,
|
|
104
|
+
ids: M,
|
|
105
|
+
root: x,
|
|
106
|
+
change: j
|
|
107
|
+
},
|
|
108
|
+
children: /* @__PURE__ */ l("div", {
|
|
109
|
+
...b,
|
|
110
|
+
ref: x,
|
|
111
|
+
className: `dishui-resizable ${v}`,
|
|
112
|
+
"data-orientation": e,
|
|
113
|
+
style: y,
|
|
114
|
+
children: C.map((e, t) => /* @__PURE__ */ l(d.Provider, {
|
|
115
|
+
value: Math.floor(t / 2),
|
|
116
|
+
children: e
|
|
117
|
+
}, e.key ?? t))
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
var h = Object.assign(m, {
|
|
122
|
+
Panel: f,
|
|
123
|
+
Handle: p
|
|
124
|
+
});
|
|
125
|
+
//#endregion
|
|
126
|
+
export { h as Resizable, h as default, p as ResizableHandle, f as ResizablePanel, e as useResize };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/Resizable/index.tsx"],"sourcesContent":["import React, { Children, createContext, isValidElement, useContext, useId, useLayoutEffect, useRef, useState } from 'react';\nimport { useResize } from './useResize';\nimport './Resizable.css';\nexport { useResize } from './useResize';\nexport type { UseResizeOptions } from './useResize';\n\nexport interface ResizablePanelProps extends React.HTMLAttributes<HTMLDivElement> {\n minSize?: number;\n maxSize?: number;\n}\nexport interface ResizableHandleProps extends React.HTMLAttributes<HTMLDivElement> {\n variant?: 'line' | 'pill';\n disabled?: boolean;\n step?: number;\n}\nexport interface ResizableProps extends React.HTMLAttributes<HTMLDivElement> {\n orientation?: 'horizontal' | 'vertical';\n sizes?: number[];\n defaultSizes?: number[];\n onSizesChange?: (sizes: number[]) => void;\n onSizesCommit?: (sizes: number[]) => void;\n disabled?: boolean;\n}\ninterface GroupContext {\n orientation: 'horizontal' | 'vertical';\n disabled: boolean;\n sizes: number[];\n bounds: { min: number; max: number }[];\n ids: string[];\n root: React.RefObject<HTMLDivElement | null>;\n change: (index: number, value: number, commit?: boolean) => void;\n}\nconst Group = createContext<GroupContext | null>(null);\nconst Position = createContext(0);\n\nexport function ResizablePanel({ minSize: _min, maxSize: _max, className = '', style, ...props }: ResizablePanelProps) {\n const group = useContext(Group);\n const index = useContext(Position);\n if (!group) throw new Error('Resizable.Panel must be inside Resizable');\n return <div {...props} id={group.ids[index]} className={`dishui-resizable-panel ${className}`} style={{ ...style, flex: `${group.sizes[index]} 1 0px` }} />;\n}\n\nexport function ResizableHandle({ variant = 'line', disabled = false, step = 1, className = '', onPointerDown, onKeyDown, onClickCapture, children, ...props }: ResizableHandleProps) {\n const group = useContext(Group);\n const index = useContext(Position);\n if (!group) throw new Error('Resizable.Handle must be inside Resizable');\n const total = group.sizes[index] + group.sizes[index + 1];\n const min = Math.max(group.bounds[index].min, total - group.bounds[index + 1].max);\n const max = Math.min(group.bounds[index].max, total - group.bounds[index + 1].min);\n const locked = disabled || group.disabled || min >= max;\n const resize = useResize({\n orientation: group.orientation, value: group.sizes[index], min, max, disabled: locked, step,\n getScale: () => {\n const root = group.root.current;\n if (!root) return 0;\n const dimension = group.orientation === 'horizontal' ? 'width' : 'height';\n const available = Array.from(root.children).filter(el => el.classList.contains('dishui-resizable-panel')).reduce((sum, el) => sum + el.getBoundingClientRect()[dimension], 0);\n const rtl = group.orientation === 'horizontal' && getComputedStyle(root).direction === 'rtl';\n return available > 0 ? (rtl ? -100 : 100) / available : 0;\n },\n onChange: value => group.change(index, value),\n onCommit: value => group.change(index, value, true),\n });\n return <div {...props} role=\"separator\" tabIndex={locked ? -1 : 0}\n aria-label={props['aria-label'] ?? 'Resize panels'} aria-orientation={group.orientation === 'horizontal' ? 'vertical' : 'horizontal'}\n aria-controls={group.ids[index]} aria-valuemin={min} aria-valuemax={max} aria-valuenow={group.sizes[index]} aria-valuetext={`${Number(group.sizes[index].toFixed(2))}%`} aria-disabled={locked}\n data-orientation={group.orientation} data-variant={variant} data-dragging={resize.dragging || undefined}\n className={`dishui-resizable-handle ${className}`}\n onPointerDown={event => { onPointerDown?.(event); if (!event.defaultPrevented) resize.onPointerDown(event); }}\n onKeyDown={event => { onKeyDown?.(event); if (!event.defaultPrevented) resize.onKeyDown(event); }}\n onClickCapture={event => { resize.onClickCapture(event); if (!event.defaultPrevented) onClickCapture?.(event); }}>\n {children ?? (variant === 'pill' ? <span className=\"dishui-resizable-grip\" aria-hidden=\"true\" /> : null)}\n </div>;\n}\n\nfunction ResizableRoot({ orientation = 'horizontal', sizes: controlled, defaultSizes, onSizesChange, onSizesCommit, disabled = false, children, className = '', style, ...props }: ResizableProps) {\n const root = useRef<HTMLDivElement>(null);\n const id = useId();\n const nodes = Children.toArray(children);\n if (!nodes.length || nodes.some((node, i) => !isValidElement(node) || node.type !== (i % 2 === 0 ? ResizablePanel : ResizableHandle)) || nodes.length % 2 === 0) {\n throw new Error('Resizable requires alternating Panel / Handle children, starting and ending with Panel. Nest groups inside a Panel.');\n }\n const panels = nodes.filter((_, i) => i % 2 === 0) as React.ReactElement<ResizablePanelProps>[];\n const bounds = panels.map(panel => ({ min: panel.props.minSize ?? 0, max: panel.props.maxSize ?? 100 }));\n if (bounds.some(b => !Number.isFinite(b.min) || !Number.isFinite(b.max) || b.min < 0 || b.max > 100 || b.min > b.max) || bounds.reduce((s, b) => s + b.min, 0) > 100 || bounds.reduce((s, b) => s + b.max, 0) < 100) throw new Error('Resizable panel constraints must be feasible percentages between 0 and 100');\n const normalize = (input?: number[]) => {\n if (input && (input.length !== panels.length || input.some(v => !Number.isFinite(v) || v < 0) || Math.abs(input.reduce((s, v) => s + v, 0) - 100) > 0.001)) throw new Error('Resizable sizes must match the panel count and sum to 100');\n const values = bounds.map((b, i) => Math.max(b.min, Math.min(b.max, input?.[i] ?? 100 / panels.length)));\n let remaining = 100 - values.reduce((s, v) => s + v, 0);\n for (let i = 0; i < values.length && Math.abs(remaining) > 1e-8; i++) {\n const delta = Math.max(bounds[i].min - values[i], Math.min(bounds[i].max - values[i], remaining));\n values[i] += delta;\n remaining -= delta;\n }\n return values;\n };\n const [internal, setInternal] = useState(() => normalize(defaultSizes));\n const sizes = normalize(controlled ?? (internal.length === panels.length ? internal : undefined));\n const current = useRef(sizes);\n useLayoutEffect(() => { current.current = sizes; });\n const change = (index: number, value: number, commit = false) => {\n const next = [...current.current];\n const total = next[index] + next[index + 1];\n next[index] = value;\n next[index + 1] = total - value;\n if (commit) { onSizesCommit?.(next); return; }\n if (!controlled) { current.current = next; setInternal(next); }\n onSizesChange?.(next);\n };\n const ids = panels.map((panel, i) => panel.props.id ?? `${id}-panel-${i}`);\n return <Group.Provider value={{ orientation, disabled, sizes, bounds, ids, root, change }}>\n <div {...props} ref={root} className={`dishui-resizable ${className}`} data-orientation={orientation} style={style}>\n {nodes.map((node, i) => <Position.Provider key={(node as React.ReactElement).key ?? i} value={Math.floor(i / 2)}>{node}</Position.Provider>)}\n </div>\n </Group.Provider>;\n}\n\nexport const Resizable = Object.assign(ResizableRoot, { Panel: ResizablePanel, Handle: ResizableHandle });\nexport default Resizable;\n"],"mappings":";;;;;AAgCA,IAAM,IAAQ,EAAmC,IAAI,GAC/C,IAAW,EAAc,CAAC;AAEhC,SAAgB,EAAe,EAAE,SAAS,GAAM,SAAS,GAAM,eAAY,IAAI,UAAO,GAAG,KAA8B;CACrH,IAAM,IAAQ,EAAW,CAAK,GACxB,IAAQ,EAAW,CAAQ;CACjC,IAAI,CAAC,GAAO,MAAU,MAAM,0CAA0C;CACtE,OAAO,kBAAC,OAAD;EA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AA,EAAU,GAC1F,IAAU,EAAO,CAAK;CAC5B,QAAsB;EAAE,EAAQ,UAAU;CAAO,CAAC;CAClD,IAAM,KAAU,GAAe,GAAe,IAAS,OAAU;EAC/D,IAAM,IAAO,CAAC,GAAG,EAAQ,OAAO,GAC1B,IAAQ,EAAK,KAAS,EAAK,IAAQ;EAGzC,IAFA,EAAK,KAAS,GACd,EAAK,IAAQ,KAAK,IAAQ,GACtB,GAAQ;GAAE,IAAgB,CAAI;GAAG;EAAQ;EAE7C,AADK,MAAc,EAAQ,UAAU,GAAM,EAAY,CAAI,IAC3D,IAAgB,CAAI;CACtB,GACM,IAAM,EAAO,KAAK,GAAO,MAAM,EAAM,MAAM,MAAM,GAAG,EAAG,SAAS,GAAG;CACzE,OAAO,kBAAC,EAAM,UAAP;EAAgB,OAAO;GAAE;GAAa;GAAU;GAAO;GAAQ;GAAK;GAAM;EAAO;EACtF,UAAA,kBAAC,OAAD;GAAK,GAAI;GAAO,KAAK;GAAM,WAAW,oBAAoB;GAAa,oBAAkB;GAAoB;GAC1G,UAAA,EAAM,KAAK,GAAM,MAAM,kBAAC,EAAS,UAAV;IAA+D,OAAO,KAAK,MAAM,IAAI,CAAC;IAAI,UAAA;GAAwB,GAAzF,EAA4B,OAAO,CAAsD,CAAC;EACxI,CAAA;CACS,CAAA;AAClB;AAEA,IAAa,IAAY,OAAO,OAAO,GAAe;CAAE,OAAO;CAAgB,QAAQ;AAAgB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface UseResizeOptions {
|
|
3
|
+
orientation?: 'horizontal' | 'vertical';
|
|
4
|
+
value: number;
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
step?: number;
|
|
9
|
+
/** Value units per CSS pixel; evaluated at pointer down. */
|
|
10
|
+
getScale?: () => number;
|
|
11
|
+
threshold?: number;
|
|
12
|
+
onChange: (value: number) => void;
|
|
13
|
+
onCommit?: (value: number) => void;
|
|
14
|
+
}
|
|
15
|
+
/** Shared pointer/keyboard engine. Does not mutate document/body styles. */
|
|
16
|
+
export declare function useResize(options: UseResizeOptions): {
|
|
17
|
+
dragging: boolean;
|
|
18
|
+
onPointerDown: (event: React.PointerEvent<HTMLElement>) => void;
|
|
19
|
+
onKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
20
|
+
onClickCapture: (event: React.MouseEvent<HTMLElement>) => void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useEffect as e, useLayoutEffect as t, useRef as n, useState as r } from "react";
|
|
2
|
+
//#region src/components/Resizable/useResize.ts
|
|
3
|
+
function i(i) {
|
|
4
|
+
let a = n(i);
|
|
5
|
+
t(() => {
|
|
6
|
+
a.current = i;
|
|
7
|
+
});
|
|
8
|
+
let o = n(null), s = n(!1), [c, l] = r(!1);
|
|
9
|
+
e(() => () => o.current?.(), []), e(() => {
|
|
10
|
+
i.disabled && o.current?.();
|
|
11
|
+
}, [i.disabled]);
|
|
12
|
+
let u = (e) => Math.max(a.current.min ?? 0, Math.min(a.current.max ?? 100, e));
|
|
13
|
+
return {
|
|
14
|
+
dragging: c,
|
|
15
|
+
onPointerDown: (e) => {
|
|
16
|
+
if (a.current.disabled || e.button !== 0 || !e.isPrimary || o.current) return;
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
let t = e.currentTarget;
|
|
19
|
+
t.focus();
|
|
20
|
+
let n = e.pointerId, { orientation: r = "horizontal", value: i, getScale: c, threshold: d = 3 } = a.current, f = r === "horizontal" ? e.clientX : e.clientY, p = c?.() ?? 1;
|
|
21
|
+
if (!Number.isFinite(p) || p === 0) return;
|
|
22
|
+
let m = !1, h = i;
|
|
23
|
+
s.current = !1;
|
|
24
|
+
let g = (e = !1) => {
|
|
25
|
+
t.removeEventListener("pointermove", _), t.removeEventListener("pointerup", v), t.removeEventListener("pointercancel", y), t.removeEventListener("lostpointercapture", y), t.ownerDocument.defaultView?.removeEventListener("blur", y), o.current = null, t.hasPointerCapture(n) && t.releasePointerCapture(n), l(!1), e && m && a.current.onCommit?.(h);
|
|
26
|
+
}, _ = (e) => {
|
|
27
|
+
if (e.pointerId !== n) return;
|
|
28
|
+
let t = (r === "horizontal" ? e.clientX : e.clientY) - f;
|
|
29
|
+
!m && Math.abs(t) <= d || (m = !0, s.current = !0, l(!0), e.preventDefault(), h = u(i + t * p), a.current.onChange(h));
|
|
30
|
+
}, v = (e) => {
|
|
31
|
+
e.pointerId === n && g(!0);
|
|
32
|
+
}, y = (e) => {
|
|
33
|
+
e && "pointerId" in e && e.pointerId !== n || (s.current = !0, g());
|
|
34
|
+
};
|
|
35
|
+
try {
|
|
36
|
+
t.setPointerCapture(n);
|
|
37
|
+
} catch {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
t.addEventListener("pointermove", _), t.addEventListener("pointerup", v), t.addEventListener("pointercancel", y), t.addEventListener("lostpointercapture", y), t.ownerDocument.defaultView?.addEventListener("blur", y), o.current = y;
|
|
41
|
+
},
|
|
42
|
+
onKeyDown: (e) => {
|
|
43
|
+
let { disabled: t, orientation: n = "horizontal", value: r, min: i = 0, max: o = 100, step: s = 1 } = a.current;
|
|
44
|
+
if (t) return;
|
|
45
|
+
let c = n === "horizontal" ? "ArrowLeft" : "ArrowUp", l = n === "horizontal" ? "ArrowRight" : "ArrowDown", d;
|
|
46
|
+
if (e.key === "Home") d = i;
|
|
47
|
+
else if (e.key === "End") d = o;
|
|
48
|
+
else if (e.key === c || e.key === l) d = r + (e.key === c ? -1 : 1) * s * (e.shiftKey ? 10 : 1);
|
|
49
|
+
else return;
|
|
50
|
+
e.preventDefault(), e.stopPropagation(), d = u(d), a.current.onChange(d), a.current.onCommit?.(d);
|
|
51
|
+
},
|
|
52
|
+
onClickCapture: (e) => {
|
|
53
|
+
s.current && e.detail !== 0 && (e.preventDefault(), e.stopPropagation(), s.current = !1);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { i as useResize };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=useResize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResize.js","names":[],"sources":["../../../src/components/Resizable/useResize.ts"],"sourcesContent":["import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\n\nexport interface UseResizeOptions {\n orientation?: 'horizontal' | 'vertical';\n value: number;\n min?: number;\n max?: number;\n disabled?: boolean;\n step?: number;\n /** Value units per CSS pixel; evaluated at pointer down. */\n getScale?: () => number;\n threshold?: number;\n onChange: (value: number) => void;\n onCommit?: (value: number) => void;\n}\n\n/** Shared pointer/keyboard engine. Does not mutate document/body styles. */\nexport function useResize(options: UseResizeOptions) {\n const latest = useRef(options);\n useLayoutEffect(() => { latest.current = options; });\n const cleanup = useRef<(() => void) | null>(null);\n const suppressClick = useRef(false);\n const [dragging, setDragging] = useState(false);\n useEffect(() => () => cleanup.current?.(), []);\n useEffect(() => { if (options.disabled) cleanup.current?.(); }, [options.disabled]);\n const clamp = (v: number) => Math.max(latest.current.min ?? 0, Math.min(latest.current.max ?? 100, v));\n const onPointerDown = (event: React.PointerEvent<HTMLElement>) => {\n if (latest.current.disabled || event.button !== 0 || !event.isPrimary || cleanup.current) return;\n event.stopPropagation();\n const el = event.currentTarget;\n el.focus();\n const id = event.pointerId;\n const { orientation = 'horizontal', value, getScale, threshold = 3 } = latest.current;\n const start = orientation === 'horizontal' ? event.clientX : event.clientY;\n const scale = getScale?.() ?? 1;\n if (!Number.isFinite(scale) || scale === 0) return;\n let moved = false;\n let last = value;\n suppressClick.current = false;\n const finish = (commit = false) => {\n el.removeEventListener('pointermove', move);\n el.removeEventListener('pointerup', up);\n el.removeEventListener('pointercancel', cancel);\n el.removeEventListener('lostpointercapture', cancel);\n el.ownerDocument.defaultView?.removeEventListener('blur', cancel);\n cleanup.current = null;\n if (el.hasPointerCapture(id)) el.releasePointerCapture(id);\n setDragging(false);\n if (commit && moved) latest.current.onCommit?.(last);\n };\n const move = (e: PointerEvent) => {\n if (e.pointerId !== id) return;\n const delta = (orientation === 'horizontal' ? e.clientX : e.clientY) - start;\n if (!moved && Math.abs(delta) <= threshold) return;\n moved = true;\n suppressClick.current = true;\n setDragging(true);\n e.preventDefault();\n last = clamp(value + delta * scale);\n latest.current.onChange(last);\n };\n const up = (e: PointerEvent) => { if (e.pointerId === id) finish(true); };\n const cancel = (cancelEvent?: Event) => {\n if (cancelEvent && 'pointerId' in cancelEvent && (cancelEvent as PointerEvent).pointerId !== id) return;\n suppressClick.current = true;\n finish();\n };\n try { el.setPointerCapture(id); } catch { return; }\n el.addEventListener('pointermove', move);\n el.addEventListener('pointerup', up);\n el.addEventListener('pointercancel', cancel);\n el.addEventListener('lostpointercapture', cancel);\n el.ownerDocument.defaultView?.addEventListener('blur', cancel);\n cleanup.current = cancel;\n };\n const onKeyDown = (event: React.KeyboardEvent<HTMLElement>) => {\n const { disabled, orientation = 'horizontal', value, min = 0, max = 100, step = 1 } = latest.current;\n if (disabled) return;\n const negative = orientation === 'horizontal' ? 'ArrowLeft' : 'ArrowUp';\n const positive = orientation === 'horizontal' ? 'ArrowRight' : 'ArrowDown';\n let next: number;\n if (event.key === 'Home') next = min;\n else if (event.key === 'End') next = max;\n else if (event.key === negative || event.key === positive) next = value + (event.key === negative ? -1 : 1) * step * (event.shiftKey ? 10 : 1);\n else return;\n event.preventDefault();\n event.stopPropagation();\n next = clamp(next);\n latest.current.onChange(next);\n latest.current.onCommit?.(next);\n };\n const onClickCapture = (event: React.MouseEvent<HTMLElement>) => {\n if (suppressClick.current && event.detail !== 0) {\n event.preventDefault();\n event.stopPropagation();\n suppressClick.current = false;\n }\n };\n return { dragging, onPointerDown, onKeyDown, onClickCapture };\n}\n"],"mappings":";;AAiBA,SAAgB,EAAU,GAA2B;CACnD,IAAM,IAAS,EAAO,CAAO;CAC7B,QAAsB;EAAE,EAAO,UAAU;CAA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AAW,EAAM,WAAW,MAC5C,EAAM,eAAe,GACrB,EAAM,gBAAgB,GACtB,EAAc,UAAU;EAE5B;CAC4D;AAC9D"}
|
|
@@ -1,37 +1,45 @@
|
|
|
1
|
+
import { useResize as e } from "../Resizable/useResize.js";
|
|
2
|
+
/* empty css */
|
|
1
3
|
import "react";
|
|
2
|
-
import { Fragment as
|
|
4
|
+
import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
5
|
//#region src/components/SidebarToggleButton/index.tsx
|
|
4
|
-
var
|
|
5
|
-
let
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
var i = ({ isCollapsed: t, onToggle: i, sidebarWidth: a, onWidthChange: o, minWidth: s = 160, maxWidth: c = 400 }) => {
|
|
7
|
+
let l = typeof o == "function", u = e({
|
|
8
|
+
value: a,
|
|
9
|
+
min: s,
|
|
10
|
+
max: c,
|
|
11
|
+
step: 10,
|
|
12
|
+
disabled: !l || t,
|
|
13
|
+
threshold: 4,
|
|
14
|
+
onChange: (e) => o?.(e)
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ r("div", {
|
|
17
|
+
className: "dishui-sidebar-resize absolute inset-y-0 right-0 z-40 hidden w-3 translate-x-1/2 md:block lg:block",
|
|
18
|
+
style: {
|
|
19
|
+
cursor: l && !t ? "ew-resize" : "pointer",
|
|
20
|
+
touchAction: "none",
|
|
21
|
+
userSelect: "none"
|
|
22
|
+
},
|
|
23
|
+
onPointerDown: (e) => {
|
|
24
|
+
(e.target === e.currentTarget || !e.target.closest("button")) && u.onPointerDown(e);
|
|
25
|
+
},
|
|
26
|
+
onClickCapture: u.onClickCapture,
|
|
27
|
+
onClick: i,
|
|
28
|
+
children: [/* @__PURE__ */ n("div", {
|
|
23
29
|
className: "pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-base-300",
|
|
24
30
|
"aria-hidden": "true"
|
|
25
|
-
}), /* @__PURE__ */
|
|
31
|
+
}), /* @__PURE__ */ n("button", {
|
|
26
32
|
type: "button",
|
|
27
33
|
tabIndex: 0,
|
|
28
|
-
|
|
34
|
+
onPointerDown: u.onPointerDown,
|
|
35
|
+
onKeyDown: u.onKeyDown,
|
|
29
36
|
className: "group absolute top-1/2 left-1/2 flex h-10 w-4 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-base-300 bg-base-100 text-base-content/40 shadow-md transition-[width,color] duration-200 ease-in-out hover:w-5 hover:text-base-content focus:outline-none focus:ring-2 focus:ring-primary/40",
|
|
30
|
-
style: { cursor:
|
|
31
|
-
"aria-label":
|
|
32
|
-
"aria-expanded": !
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
style: { cursor: l ? "ew-resize" : "pointer" },
|
|
38
|
+
"aria-label": t ? "展开侧边栏" : l ? "拖拽调整侧边栏宽度,点击收起" : "收起侧边栏",
|
|
39
|
+
"aria-expanded": !t,
|
|
40
|
+
"aria-description": l && !t ? `宽度 ${Math.round(a)}px;左右方向键调整,Home/End 到达最小/最大宽度,Enter/空格折叠` : void 0,
|
|
41
|
+
title: l && !t ? "拖拽调节宽度 · 点击折叠" : void 0,
|
|
42
|
+
children: t ? /* @__PURE__ */ n("svg", {
|
|
35
43
|
xmlns: "http://www.w3.org/2000/svg",
|
|
36
44
|
width: "10",
|
|
37
45
|
height: "10",
|
|
@@ -39,13 +47,13 @@ var r = 4, i = ({ isCollapsed: e, onToggle: i, collapsedWidth: a = 64, onWidthCh
|
|
|
39
47
|
viewBox: "0 0 24 24",
|
|
40
48
|
stroke: "currentColor",
|
|
41
49
|
className: "pointer-events-none",
|
|
42
|
-
children: /* @__PURE__ */
|
|
50
|
+
children: /* @__PURE__ */ n("path", {
|
|
43
51
|
strokeLinecap: "round",
|
|
44
52
|
strokeLinejoin: "round",
|
|
45
53
|
strokeWidth: "2.5",
|
|
46
54
|
d: "M9 5l7 7-7 7"
|
|
47
55
|
})
|
|
48
|
-
}) : /* @__PURE__ */
|
|
56
|
+
}) : /* @__PURE__ */ r("svg", {
|
|
49
57
|
width: "6",
|
|
50
58
|
height: "18",
|
|
51
59
|
viewBox: "0 0 6 18",
|
|
@@ -53,32 +61,32 @@ var r = 4, i = ({ isCollapsed: e, onToggle: i, collapsedWidth: a = 64, onWidthCh
|
|
|
53
61
|
"aria-hidden": "true",
|
|
54
62
|
className: "pointer-events-none",
|
|
55
63
|
children: [
|
|
56
|
-
/* @__PURE__ */
|
|
64
|
+
/* @__PURE__ */ n("circle", {
|
|
57
65
|
cx: "1.5",
|
|
58
66
|
cy: "3",
|
|
59
67
|
r: "1"
|
|
60
68
|
}),
|
|
61
|
-
/* @__PURE__ */
|
|
69
|
+
/* @__PURE__ */ n("circle", {
|
|
62
70
|
cx: "4.5",
|
|
63
71
|
cy: "3",
|
|
64
72
|
r: "1"
|
|
65
73
|
}),
|
|
66
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ n("circle", {
|
|
67
75
|
cx: "1.5",
|
|
68
76
|
cy: "9",
|
|
69
77
|
r: "1"
|
|
70
78
|
}),
|
|
71
|
-
/* @__PURE__ */
|
|
79
|
+
/* @__PURE__ */ n("circle", {
|
|
72
80
|
cx: "4.5",
|
|
73
81
|
cy: "9",
|
|
74
82
|
r: "1"
|
|
75
83
|
}),
|
|
76
|
-
/* @__PURE__ */
|
|
84
|
+
/* @__PURE__ */ n("circle", {
|
|
77
85
|
cx: "1.5",
|
|
78
86
|
cy: "15",
|
|
79
87
|
r: "1"
|
|
80
88
|
}),
|
|
81
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ n("circle", {
|
|
82
90
|
cx: "4.5",
|
|
83
91
|
cy: "15",
|
|
84
92
|
r: "1"
|
|
@@ -87,32 +95,32 @@ var r = 4, i = ({ isCollapsed: e, onToggle: i, collapsedWidth: a = 64, onWidthCh
|
|
|
87
95
|
})
|
|
88
96
|
})]
|
|
89
97
|
});
|
|
90
|
-
}, a = ({ isCollapsed: e, onToggle:
|
|
91
|
-
onClick:
|
|
98
|
+
}, a = ({ isCollapsed: e, onToggle: t }) => /* @__PURE__ */ n("button", {
|
|
99
|
+
onClick: t,
|
|
92
100
|
className: "fixed bottom-6 right-6 z-50 bg-primary bg-opacity-30 hover:bg-opacity-50 text-primary-content rounded-full p-3 shadow-lg transition-all duration-300 ease-in-out backdrop-blur-sm hover:scale-105 md:hidden",
|
|
93
101
|
style: { boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)" },
|
|
94
102
|
"aria-label": e ? "展开侧边栏" : "收起侧边栏",
|
|
95
|
-
children: /* @__PURE__ */
|
|
103
|
+
children: /* @__PURE__ */ n("svg", {
|
|
96
104
|
xmlns: "http://www.w3.org/2000/svg",
|
|
97
105
|
fill: "none",
|
|
98
106
|
viewBox: "0 0 24 24",
|
|
99
107
|
stroke: "currentColor",
|
|
100
108
|
className: "w-5 h-5",
|
|
101
|
-
children: e ? /* @__PURE__ */
|
|
109
|
+
children: e ? /* @__PURE__ */ n("path", {
|
|
102
110
|
strokeLinecap: "round",
|
|
103
111
|
strokeLinejoin: "round",
|
|
104
112
|
strokeWidth: "2",
|
|
105
113
|
d: "M4 6h16M4 12h16M4 18h16"
|
|
106
|
-
}) : /* @__PURE__ */
|
|
114
|
+
}) : /* @__PURE__ */ n("path", {
|
|
107
115
|
strokeLinecap: "round",
|
|
108
116
|
strokeLinejoin: "round",
|
|
109
117
|
strokeWidth: "2",
|
|
110
118
|
d: "M6 18L18 6M6 6l12 12"
|
|
111
119
|
})
|
|
112
120
|
})
|
|
113
|
-
}), o = (
|
|
114
|
-
isCollapsed:
|
|
115
|
-
onToggle:
|
|
121
|
+
}), o = (e) => /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ n(i, { ...e }), /* @__PURE__ */ n(a, {
|
|
122
|
+
isCollapsed: e.isCollapsed,
|
|
123
|
+
onToggle: e.onToggle
|
|
116
124
|
})] });
|
|
117
125
|
//#endregion
|
|
118
126
|
export { i as DesktopSidebarToggleButton, a as MobileSidebarToggleButton, o as SidebarToggleButtons, o as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/SidebarToggleButton/index.tsx"],"sourcesContent":["import React from 'react';\n\ninterface SidebarToggleButtonProps {\n /** 侧边栏是否折叠 */\n isCollapsed: boolean;\n /** 切换侧边栏的回调 */\n onToggle: () => void;\n /** 当前侧边栏宽度 */\n sidebarWidth: number;\n /** 折叠时的宽度 */\n collapsedWidth?: number;\n /** 拖拽调节宽度的回调(传入时支持拖拽缩放) */\n onWidthChange?: (width: number) => void;\n /** 拖拽时的最小宽度(px) */\n minWidth?: number;\n /** 拖拽时的最大宽度(px) */\n maxWidth?: number;\n /**\n * 侧边栏容器元素的引用(用于拖拽时获取左边缘,使宽度计算与内嵌位置无关)。\n */\n anchorRef?: React.RefObject<HTMLElement | null>;\n}\n\n
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/SidebarToggleButton/index.tsx"],"sourcesContent":["import React from 'react';\nimport { useResize } from '../Resizable/useResize';\nimport '../Resizable/Resizable.css';\n\ninterface SidebarToggleButtonProps {\n /** 侧边栏是否折叠 */\n isCollapsed: boolean;\n /** 切换侧边栏的回调 */\n onToggle: () => void;\n /** 当前侧边栏宽度 */\n sidebarWidth: number;\n /** 折叠时的宽度 */\n collapsedWidth?: number;\n /** 拖拽调节宽度的回调(传入时支持拖拽缩放) */\n onWidthChange?: (width: number) => void;\n /** 拖拽时的最小宽度(px) */\n minWidth?: number;\n /** 拖拽时的最大宽度(px) */\n maxWidth?: number;\n /**\n * 侧边栏容器元素的引用(用于拖拽时获取左边缘,使宽度计算与内嵌位置无关)。\n */\n anchorRef?: React.RefObject<HTMLElement | null>;\n}\n\n\n\n/**\n * 桌面端侧边栏切换控件(与右侧纵向边界线一体)\n * - 点击:折叠 / 展开侧边栏\n * - 拖拽:任意调节侧边栏宽度(需传入 onWidthChange)\n *\n * 采用 `absolute` 定位内嵌在侧边栏(relative 容器)右边缘,随侧边栏布局自然移动——\n * 无需测量/追赶,无延迟,也不受其它可变宽度组件影响。\n */\nexport const DesktopSidebarToggleButton: React.FC<SidebarToggleButtonProps> = ({\n isCollapsed,\n onToggle,\n sidebarWidth,\n onWidthChange,\n minWidth = 160,\n maxWidth = 400,\n}) => {\n const draggable = typeof onWidthChange === 'function';\n\n const resize = useResize({\n value: sidebarWidth, min: minWidth, max: maxWidth, step: 10,\n disabled: !draggable || isCollapsed, threshold: 4,\n onChange: width => onWidthChange?.(width),\n });\n\n return (\n // 与右侧边界线一体:定位在侧边栏右边缘(right:0)的全高约束区,\n // 内嵌纵向边界线 + 坐落在线上的 pill。w-3 作为拖拽热区。\n <div\n className=\"dishui-sidebar-resize absolute inset-y-0 right-0 z-40 hidden w-3 translate-x-1/2 md:block lg:block\"\n style={{ cursor: draggable && !isCollapsed ? 'ew-resize' : 'pointer', touchAction: 'none', userSelect: 'none' }}\n onPointerDown={event => { if (event.target === event.currentTarget || !(event.target as HTMLElement).closest('button')) resize.onPointerDown(event); }}\n onClickCapture={resize.onClickCapture}\n onClick={onToggle}\n >\n {/* 纵向边界线(居中于热区 = 侧边栏右边缘) */}\n <div className=\"pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-base-300\" aria-hidden=\"true\" />\n {/* pill 手柄(坐落在线上,与之一体) */}\n <button\n type=\"button\"\n tabIndex={0}\n onPointerDown={resize.onPointerDown}\n onKeyDown={resize.onKeyDown}\n className=\"group absolute top-1/2 left-1/2 flex h-10 w-4 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-base-300 bg-base-100 text-base-content/40 shadow-md transition-[width,color] duration-200 ease-in-out hover:w-5 hover:text-base-content focus:outline-none focus:ring-2 focus:ring-primary/40\"\n style={{ cursor: draggable ? 'ew-resize' : 'pointer' }}\n aria-label={isCollapsed ? '展开侧边栏' : (draggable ? '拖拽调整侧边栏宽度,点击收起' : '收起侧边栏')}\n aria-expanded={!isCollapsed}\n aria-description={draggable && !isCollapsed ? `宽度 ${Math.round(sidebarWidth)}px;左右方向键调整,Home/End 到达最小/最大宽度,Enter/空格折叠` : undefined}\n title={draggable && !isCollapsed ? '拖拽调节宽度 · 点击折叠' : undefined}\n >\n {isCollapsed ? (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"10\" height=\"10\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" className=\"pointer-events-none\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2.5\" d=\"M9 5l7 7-7 7\" />\n </svg>\n ) : (\n <svg width=\"6\" height=\"18\" viewBox=\"0 0 6 18\" fill=\"currentColor\" aria-hidden=\"true\" className=\"pointer-events-none\">\n <circle cx=\"1.5\" cy=\"3\" r=\"1\" /><circle cx=\"4.5\" cy=\"3\" r=\"1\" />\n <circle cx=\"1.5\" cy=\"9\" r=\"1\" /><circle cx=\"4.5\" cy=\"9\" r=\"1\" />\n <circle cx=\"1.5\" cy=\"15\" r=\"1\" /><circle cx=\"4.5\" cy=\"15\" r=\"1\" />\n </svg>\n )}\n </button>\n </div>\n );\n};\n\n/**\n * 移动端悬浮侧边栏切换按钮\n */\nexport const MobileSidebarToggleButton: React.FC<Pick<SidebarToggleButtonProps, 'isCollapsed' | 'onToggle'>> = ({\n isCollapsed,\n onToggle,\n}) => {\n return (\n <button\n onClick={onToggle}\n className=\"fixed bottom-6 right-6 z-50 bg-primary bg-opacity-30 hover:bg-opacity-50 text-primary-content rounded-full p-3 shadow-lg transition-all duration-300 ease-in-out backdrop-blur-sm hover:scale-105 md:hidden\"\n style={{\n boxShadow: '0 4px 20px rgba(0, 0, 0, 0.15)',\n }}\n aria-label={isCollapsed ? '展开侧边栏' : '收起侧边栏'}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n className=\"w-5 h-5\"\n >\n {isCollapsed ? (\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M4 6h16M4 12h16M4 18h16\" />\n ) : (\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2\" d=\"M6 18L18 6M6 6l12 12\" />\n )}\n </svg>\n </button>\n );\n};\n\n/**\n * 组合的侧边栏切换按钮(包含桌面端和移动端)\n */\nexport const SidebarToggleButtons: React.FC<SidebarToggleButtonProps> = (props) => {\n return (\n <>\n <DesktopSidebarToggleButton {...props} />\n <MobileSidebarToggleButton isCollapsed={props.isCollapsed} onToggle={props.onToggle} />\n </>\n );\n};\n\nexport default SidebarToggleButtons;\n"],"mappings":";;;;;AAmCA,IAAa,KAAkE,EAC7E,gBACA,aACA,iBACA,kBACA,cAAW,KACX,cAAW,UACP;CACJ,IAAM,IAAY,OAAO,KAAkB,YAErC,IAAS,EAAU;EACvB,OAAO;EAAc,KAAK;EAAU,KAAK;EAAU,MAAM;EACzD,UAAU,CAAC,KAAa;EAAa,WAAW;EAChD,WAAU,MAAS,IAAgB,CAAK;CAC1C,CAAC;CAED,OAGE,kBAAC,OAAD;EACE,WAAU;EACV,OAAO;GAAE,QAAQ,KAAa,CAAC,IAAc,cAAc;GAAW,aAAa;GAAQ,YAAY;EAAO;EAC9G,gBAAe,MAAS;GAAE,CAAI,EAAM,WAAW,EAAM,iBAAiB,CAAE,EAAM,OAAuB,QAAQ,QAAQ,MAAG,EAAO,cAAc,CAAK;EAAG;EACrJ,gBAAgB,EAAO;EACvB,SAAS;EALX,UAAA,CAQE,kBAAC,OAAD;GAAK,WAAU;GAAoF,eAAY;EAAQ,CAAA,GAEvH,kBAAC,UAAD;GACE,MAAK;GACL,UAAU;GACV,eAAe,EAAO;GACd,WAAW,EAAO;GAC1B,WAAU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;GAAQ,gBAAe;GAAQ,aAAY;GAAI,GAAE;EAA2B,CAAA,IAEhG,kBAAC,QAAD;GAAM,eAAc;GAAQ,gBAAe;GAAQ,aAAY;GAAI,GAAE;EAAwB,CAAA;CAE5F,CAAA;AACC,CAAA,GAOC,KAA4D,MAErE,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD,EAA4B,GAAI,EAAQ,CAAA,GACxC,kBAAC,GAAD;CAA2B,aAAa,EAAM;CAAa,UAAU,EAAM;AAAW,CAAA,CACtF,EAAA,CAAA"}
|
|
@@ -2,6 +2,20 @@ import React from 'react';
|
|
|
2
2
|
export type SliderVariant = 'default' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
3
3
|
export type SliderSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
4
4
|
export type SliderProps = {
|
|
5
|
+
/** Linear remains the default. Circular starts at 12 o'clock, clockwise. */
|
|
6
|
+
mode?: 'linear' | 'circular' | 'discrete';
|
|
7
|
+
/** Applies to linear and discrete sliders. */
|
|
8
|
+
orientation?: 'horizontal' | 'vertical';
|
|
9
|
+
/** Discrete item shape and quantity (positive integer, defaults to 5). */
|
|
10
|
+
shape?: 'square' | 'star' | 'heart';
|
|
11
|
+
count?: number;
|
|
12
|
+
/** Discrete increments: half an item instead of a whole item. */
|
|
13
|
+
allowHalf?: boolean;
|
|
14
|
+
id?: string;
|
|
15
|
+
'aria-label'?: string;
|
|
16
|
+
'aria-labelledby'?: string;
|
|
17
|
+
'aria-describedby'?: string;
|
|
18
|
+
'aria-valuetext'?: string;
|
|
5
19
|
/** Controlled value. */
|
|
6
20
|
value?: number;
|
|
7
21
|
/** Uncontrolled initial value. */
|
|
@@ -10,7 +24,7 @@ export type SliderProps = {
|
|
|
10
24
|
min?: number;
|
|
11
25
|
/** Maximum value. */
|
|
12
26
|
max?: number;
|
|
13
|
-
/** Step increment. */
|
|
27
|
+
/** Step increment for linear/circular modes; discrete derives it from count and allowHalf. */
|
|
14
28
|
step?: number;
|
|
15
29
|
/** Change handler with the numeric value. */
|
|
16
30
|
onChange?: (value: number, e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -32,8 +46,8 @@ export type SliderProps = {
|
|
|
32
46
|
style?: React.CSSProperties;
|
|
33
47
|
};
|
|
34
48
|
/**
|
|
35
|
-
* Slider ——
|
|
36
|
-
*
|
|
49
|
+
* Slider —— Native range semantics with linear, circular and discrete presentations.
|
|
50
|
+
* Supports controlled/uncontrolled values, keyboard input and semantic colors.
|
|
37
51
|
*/
|
|
38
52
|
declare const Slider: React.FC<SliderProps>;
|
|
39
53
|
export default Slider;
|