@octohirono/stitch-design-system 0.1.0
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/README.md +7 -0
- package/dist/components/Accordion/Accordion.d.ts +45 -0
- package/dist/components/Accordion/Accordion.js +26 -0
- package/dist/components/Accordion/accordion.module.js +4 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts +45 -0
- package/dist/components/AlertDialog/AlertDialog.js +32 -0
- package/dist/components/AlertDialog/alert-dialog.module.js +4 -0
- package/dist/components/AlertDialog/index.d.ts +2 -0
- package/dist/components/AspectRatio/AspectRatio.d.ts +29 -0
- package/dist/components/AspectRatio/AspectRatio.js +15 -0
- package/dist/components/AspectRatio/aspect-ratio.module.js +4 -0
- package/dist/components/AspectRatio/index.d.ts +2 -0
- package/dist/components/Avatar/Avatar.d.ts +42 -0
- package/dist/components/Avatar/Avatar.js +21 -0
- package/dist/components/Avatar/avatar.module.js +13 -0
- package/dist/components/Avatar/index.d.ts +2 -0
- package/dist/components/Button/Button.d.ts +60 -0
- package/dist/components/Button/Button.js +22 -0
- package/dist/components/Button/button.module.js +19 -0
- package/dist/components/Button/index.d.ts +2 -0
- package/dist/components/Card/Card.d.ts +50 -0
- package/dist/components/Card/Card.js +21 -0
- package/dist/components/Card/card.module.js +22 -0
- package/dist/components/Card/index.d.ts +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +45 -0
- package/dist/components/Checkbox/Checkbox.js +56 -0
- package/dist/components/Checkbox/checkbox.module.js +17 -0
- package/dist/components/Checkbox/index.d.ts +2 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +10 -0
- package/dist/components/CodeBlock/CodeBlock.js +50 -0
- package/dist/components/CodeBlock/codeblock.module.js +17 -0
- package/dist/components/CodeBlock/index.d.ts +2 -0
- package/dist/components/Collapse/Collapse.d.ts +38 -0
- package/dist/components/Collapse/Collapse.js +50 -0
- package/dist/components/Collapse/collapse.module.js +13 -0
- package/dist/components/Collapse/index.d.ts +2 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +47 -0
- package/dist/components/ContextMenu/ContextMenu.js +50 -0
- package/dist/components/ContextMenu/context-menu.module.js +13 -0
- package/dist/components/ContextMenu/index.d.ts +2 -0
- package/dist/components/Divider/Divider.d.ts +50 -0
- package/dist/components/Divider/Divider.js +23 -0
- package/dist/components/Divider/divider.module.js +14 -0
- package/dist/components/Divider/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.d.ts +36 -0
- package/dist/components/Drawer/Drawer.js +76 -0
- package/dist/components/Drawer/drawer.module.js +21 -0
- package/dist/components/Drawer/index.d.ts +2 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +55 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +54 -0
- package/dist/components/DropdownMenu/dropdown-menu.module.js +13 -0
- package/dist/components/DropdownMenu/index.d.ts +2 -0
- package/dist/components/Form/Form.d.ts +20 -0
- package/dist/components/Form/Form.js +105 -0
- package/dist/components/Form/FormItem.d.ts +3 -0
- package/dist/components/Form/FormItem.js +96 -0
- package/dist/components/Form/context.d.ts +22 -0
- package/dist/components/Form/context.js +5 -0
- package/dist/components/Form/form.module.js +25 -0
- package/dist/components/Form/index.d.ts +7 -0
- package/dist/components/Form/types.d.ts +164 -0
- package/dist/components/Form/types.js +6 -0
- package/dist/components/Form/useForm.d.ts +15 -0
- package/dist/components/Form/useForm.js +188 -0
- package/dist/components/Form/validators.d.ts +3 -0
- package/dist/components/Form/validators.js +73 -0
- package/dist/components/HoverCard/HoverCard.d.ts +47 -0
- package/dist/components/HoverCard/HoverCard.js +26 -0
- package/dist/components/HoverCard/hover-card.module.js +9 -0
- package/dist/components/HoverCard/index.d.ts +2 -0
- package/dist/components/Icon/Icon.d.ts +100 -0
- package/dist/components/Icon/Icon.js +150 -0
- package/dist/components/Icon/icon.module.js +7 -0
- package/dist/components/Icon/index.d.ts +2 -0
- package/dist/components/Image/Image.d.ts +50 -0
- package/dist/components/Image/Image.js +95 -0
- package/dist/components/Image/image.module.js +27 -0
- package/dist/components/Image/index.d.ts +2 -0
- package/dist/components/Input/Input.d.ts +41 -0
- package/dist/components/Input/Input.js +62 -0
- package/dist/components/Input/index.d.ts +2 -0
- package/dist/components/Input/input.module.js +17 -0
- package/dist/components/Label/Label.d.ts +28 -0
- package/dist/components/Label/Label.js +15 -0
- package/dist/components/Label/index.d.ts +2 -0
- package/dist/components/Label/label.module.js +4 -0
- package/dist/components/Loading/Loading.d.ts +22 -0
- package/dist/components/Loading/Loading.js +32 -0
- package/dist/components/Loading/index.d.ts +2 -0
- package/dist/components/Loading/loading.module.js +14 -0
- package/dist/components/Menubar/Menubar.d.ts +64 -0
- package/dist/components/Menubar/Menubar.js +70 -0
- package/dist/components/Menubar/index.d.ts +2 -0
- package/dist/components/Menubar/menubar.module.js +15 -0
- package/dist/components/Modal/Modal.d.ts +38 -0
- package/dist/components/Modal/Modal.js +68 -0
- package/dist/components/Modal/index.d.ts +2 -0
- package/dist/components/Modal/modal.module.js +13 -0
- package/dist/components/NavigationMenu/NavigationMenu.d.ts +47 -0
- package/dist/components/NavigationMenu/NavigationMenu.js +47 -0
- package/dist/components/NavigationMenu/index.d.ts +2 -0
- package/dist/components/NavigationMenu/navigation-menu.module.js +16 -0
- package/dist/components/Notification/Notification.d.ts +14 -0
- package/dist/components/Notification/Notification.js +87 -0
- package/dist/components/Notification/NotificationPortal.d.ts +29 -0
- package/dist/components/Notification/NotificationPortal.js +90 -0
- package/dist/components/Notification/index.d.ts +4 -0
- package/dist/components/Notification/notification.module.js +31 -0
- package/dist/components/Notification/types.d.ts +44 -0
- package/dist/components/OtpField/OtpField.d.ts +40 -0
- package/dist/components/OtpField/OtpField.js +20 -0
- package/dist/components/OtpField/index.d.ts +2 -0
- package/dist/components/OtpField/otp-field.module.js +7 -0
- package/dist/components/PasswordInput/PasswordInput.d.ts +36 -0
- package/dist/components/PasswordInput/PasswordInput.js +28 -0
- package/dist/components/PasswordInput/index.d.ts +2 -0
- package/dist/components/PasswordInput/password-input.module.js +4 -0
- package/dist/components/Popover/Popover.d.ts +42 -0
- package/dist/components/Popover/Popover.js +24 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/popover.module.js +9 -0
- package/dist/components/Progress/Progress.d.ts +44 -0
- package/dist/components/Progress/Progress.js +55 -0
- package/dist/components/Progress/index.d.ts +2 -0
- package/dist/components/Progress/progress.module.js +21 -0
- package/dist/components/Radio/Radio.d.ts +47 -0
- package/dist/components/Radio/Radio.js +102 -0
- package/dist/components/Radio/index.d.ts +2 -0
- package/dist/components/Radio/radio.module.js +17 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +34 -0
- package/dist/components/ScrollArea/ScrollArea.js +34 -0
- package/dist/components/ScrollArea/index.d.ts +2 -0
- package/dist/components/ScrollArea/scroll-area.module.js +10 -0
- package/dist/components/Select/Select.d.ts +54 -0
- package/dist/components/Select/Select.js +118 -0
- package/dist/components/Select/index.d.ts +2 -0
- package/dist/components/Select/select.module.js +24 -0
- package/dist/components/Skeleton/Skeleton.d.ts +71 -0
- package/dist/components/Skeleton/Skeleton.js +147 -0
- package/dist/components/Skeleton/index.d.ts +2 -0
- package/dist/components/Skeleton/skeleton.module.js +16 -0
- package/dist/components/Slider/Slider.d.ts +58 -0
- package/dist/components/Slider/Slider.js +33 -0
- package/dist/components/Slider/index.d.ts +2 -0
- package/dist/components/Slider/slider.module.js +9 -0
- package/dist/components/Switch/Switch.d.ts +50 -0
- package/dist/components/Switch/Switch.js +43 -0
- package/dist/components/Switch/index.d.ts +2 -0
- package/dist/components/Switch/switch.module.js +15 -0
- package/dist/components/Table/Table.d.ts +65 -0
- package/dist/components/Table/Table.js +75 -0
- package/dist/components/Table/index.d.ts +2 -0
- package/dist/components/Table/table.module.js +21 -0
- package/dist/components/Tabs/Tabs.d.ts +37 -0
- package/dist/components/Tabs/Tabs.js +68 -0
- package/dist/components/Tabs/index.d.ts +2 -0
- package/dist/components/Tabs/tabs.module.js +13 -0
- package/dist/components/Tag/Tag.d.ts +67 -0
- package/dist/components/Tag/Tag.js +54 -0
- package/dist/components/Tag/index.d.ts +2 -0
- package/dist/components/Tag/tag.module.js +28 -0
- package/dist/components/Toggle/Toggle.d.ts +39 -0
- package/dist/components/Toggle/Toggle.js +29 -0
- package/dist/components/Toggle/index.d.ts +2 -0
- package/dist/components/Toggle/toggle.module.js +7 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +88 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +42 -0
- package/dist/components/ToggleGroup/index.d.ts +2 -0
- package/dist/components/ToggleGroup/toggle-group.module.js +8 -0
- package/dist/components/Toolbar/Toolbar.d.ts +116 -0
- package/dist/components/Toolbar/Toolbar.js +72 -0
- package/dist/components/Toolbar/index.d.ts +2 -0
- package/dist/components/Toolbar/toolbar.module.js +14 -0
- package/dist/components/Tooltip/Tooltip.d.ts +41 -0
- package/dist/components/Tooltip/Tooltip.js +38 -0
- package/dist/components/Tooltip/index.d.ts +2 -0
- package/dist/components/Tooltip/tooltip.module.js +21 -0
- package/dist/components/_internal/useOverlay.d.ts +15 -0
- package/dist/components/_internal/useOverlay.js +55 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +43 -0
- package/dist/style.css +3693 -0
- package/package.json +36 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SkeletonVariant = 'text' | 'circle' | 'rect' | 'paragraph';
|
|
3
|
+
export interface SkeletonProps {
|
|
4
|
+
/**
|
|
5
|
+
* 是否显示骨架占位:`true` 渲染骨架,`false` 直接渲染 `children`
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 骨架变体
|
|
11
|
+
* @default 'text'
|
|
12
|
+
*/
|
|
13
|
+
variant?: SkeletonVariant;
|
|
14
|
+
/**
|
|
15
|
+
* 是否启用扫光动画(对齐 Ant v5 `Skeleton.active`)
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
active?: boolean;
|
|
19
|
+
/** 行数(`paragraph` 变体有效) */
|
|
20
|
+
rows?: number;
|
|
21
|
+
/** 每行宽度(`paragraph` 变体有效,可传数组对不同行指定不同宽度) */
|
|
22
|
+
rowWidths?: (number | string)[];
|
|
23
|
+
/** 宽度(text/circle/rect 变体有效) */
|
|
24
|
+
width?: number | string;
|
|
25
|
+
/** 高度(circle/rect 变体有效) */
|
|
26
|
+
height?: number | string;
|
|
27
|
+
/** 透传到根元素 */
|
|
28
|
+
className?: string;
|
|
29
|
+
/** 透传到根元素 */
|
|
30
|
+
style?: React.CSSProperties;
|
|
31
|
+
/** 无障碍名(默认「加载中」) */
|
|
32
|
+
'aria-label'?: string;
|
|
33
|
+
/** 子元素(`loading=false` 时渲染) */
|
|
34
|
+
children?: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
interface SkeletonComponent extends React.FC<SkeletonProps> {
|
|
37
|
+
Button: React.FC<SkeletonButtonProps>;
|
|
38
|
+
Input: React.FC<SkeletonInputProps>;
|
|
39
|
+
Avatar: React.FC<SkeletonAvatarProps>;
|
|
40
|
+
}
|
|
41
|
+
export interface SkeletonButtonProps {
|
|
42
|
+
/** @default 'middle' */
|
|
43
|
+
size?: 'small' | 'middle' | 'large';
|
|
44
|
+
/** @default true */
|
|
45
|
+
active?: boolean;
|
|
46
|
+
className?: string;
|
|
47
|
+
style?: React.CSSProperties;
|
|
48
|
+
'aria-label'?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface SkeletonInputProps {
|
|
51
|
+
/** @default 'middle' */
|
|
52
|
+
size?: 'small' | 'middle' | 'large';
|
|
53
|
+
/** @default true */
|
|
54
|
+
active?: boolean;
|
|
55
|
+
className?: string;
|
|
56
|
+
style?: React.CSSProperties;
|
|
57
|
+
'aria-label'?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface SkeletonAvatarProps {
|
|
60
|
+
/** @default 'middle' */
|
|
61
|
+
size?: 'small' | 'middle' | 'large';
|
|
62
|
+
/** @default 'circle' */
|
|
63
|
+
shape?: 'circle' | 'square';
|
|
64
|
+
/** @default true */
|
|
65
|
+
active?: boolean;
|
|
66
|
+
className?: string;
|
|
67
|
+
style?: React.CSSProperties;
|
|
68
|
+
'aria-label'?: string;
|
|
69
|
+
}
|
|
70
|
+
export declare const Skeleton: SkeletonComponent;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import e from "./skeleton.module.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import t from "clsx";
|
|
4
|
+
import { Fragment as n, jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region packages/react/src/components/Skeleton/Skeleton.tsx
|
|
6
|
+
var i = {
|
|
7
|
+
text: e["vt-text"],
|
|
8
|
+
circle: e["vt-circle"],
|
|
9
|
+
rect: e["vt-rect"],
|
|
10
|
+
paragraph: e["vt-paragraph"]
|
|
11
|
+
}, a = [
|
|
12
|
+
"100%",
|
|
13
|
+
"92%",
|
|
14
|
+
"84%",
|
|
15
|
+
"76%",
|
|
16
|
+
"60%"
|
|
17
|
+
], o = ({ loading: o = !0, variant: s = "text", active: c = !0, rows: l = 3, rowWidths: u, width: d, height: f, className: p, style: m, "aria-label": h = "加载中", children: g }) => {
|
|
18
|
+
if (!o && g) return /* @__PURE__ */ r(n, { children: g });
|
|
19
|
+
let _ = t(e.skeleton, c && e.active, i[s], p), v = {
|
|
20
|
+
role: "status",
|
|
21
|
+
"aria-busy": !0,
|
|
22
|
+
"aria-label": h
|
|
23
|
+
};
|
|
24
|
+
if (s === "paragraph") {
|
|
25
|
+
let n = Array.isArray(u) ? u : a, i = Math.max(1, l);
|
|
26
|
+
return /* @__PURE__ */ r("div", {
|
|
27
|
+
className: _,
|
|
28
|
+
style: m,
|
|
29
|
+
...v,
|
|
30
|
+
children: Array.from({ length: i }, (i, a) => {
|
|
31
|
+
let o = n[a] ?? n[n.length - 1] ?? "100%";
|
|
32
|
+
return /* @__PURE__ */ r("div", {
|
|
33
|
+
className: t(e.line, c && e.active),
|
|
34
|
+
style: { width: o },
|
|
35
|
+
"aria-hidden": !0
|
|
36
|
+
}, a);
|
|
37
|
+
})
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (s === "circle") {
|
|
41
|
+
let e = d ?? f ?? 44;
|
|
42
|
+
return /* @__PURE__ */ r("div", {
|
|
43
|
+
className: _,
|
|
44
|
+
style: {
|
|
45
|
+
width: e,
|
|
46
|
+
height: e,
|
|
47
|
+
...m
|
|
48
|
+
},
|
|
49
|
+
...v
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return s === "rect" ? /* @__PURE__ */ r("div", {
|
|
53
|
+
className: _,
|
|
54
|
+
style: {
|
|
55
|
+
width: d ?? "100%",
|
|
56
|
+
height: f ?? 120,
|
|
57
|
+
...m
|
|
58
|
+
},
|
|
59
|
+
...v
|
|
60
|
+
}) : /* @__PURE__ */ r("div", {
|
|
61
|
+
className: _,
|
|
62
|
+
style: {
|
|
63
|
+
width: d ?? "100%",
|
|
64
|
+
height: f ?? 16,
|
|
65
|
+
...m
|
|
66
|
+
},
|
|
67
|
+
...v
|
|
68
|
+
});
|
|
69
|
+
}, s = {
|
|
70
|
+
small: {
|
|
71
|
+
width: 80,
|
|
72
|
+
height: 32
|
|
73
|
+
},
|
|
74
|
+
middle: {
|
|
75
|
+
width: 100,
|
|
76
|
+
height: 40
|
|
77
|
+
},
|
|
78
|
+
large: {
|
|
79
|
+
width: 130,
|
|
80
|
+
height: 48
|
|
81
|
+
}
|
|
82
|
+
}, c = ({ size: n = "middle", active: i = !0, className: a, style: o, "aria-label": c = "加载中" }) => {
|
|
83
|
+
let l = s[n];
|
|
84
|
+
return /* @__PURE__ */ r("div", {
|
|
85
|
+
className: t(e.skeleton, e["skeleton-btn"], i && e.active, a),
|
|
86
|
+
style: {
|
|
87
|
+
width: l.width,
|
|
88
|
+
height: l.height,
|
|
89
|
+
...o
|
|
90
|
+
},
|
|
91
|
+
role: "status",
|
|
92
|
+
"aria-busy": !0,
|
|
93
|
+
"aria-label": c
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
c.displayName = "Skeleton.Button";
|
|
97
|
+
var l = {
|
|
98
|
+
small: {
|
|
99
|
+
width: 160,
|
|
100
|
+
height: 32
|
|
101
|
+
},
|
|
102
|
+
middle: {
|
|
103
|
+
width: 200,
|
|
104
|
+
height: 40
|
|
105
|
+
},
|
|
106
|
+
large: {
|
|
107
|
+
width: 240,
|
|
108
|
+
height: 48
|
|
109
|
+
}
|
|
110
|
+
}, u = ({ size: n = "middle", active: i = !0, className: a, style: o, "aria-label": s = "加载中" }) => {
|
|
111
|
+
let c = l[n];
|
|
112
|
+
return /* @__PURE__ */ r("div", {
|
|
113
|
+
className: t(e.skeleton, e["skeleton-input"], i && e.active, a),
|
|
114
|
+
style: {
|
|
115
|
+
width: c.width,
|
|
116
|
+
height: c.height,
|
|
117
|
+
...o
|
|
118
|
+
},
|
|
119
|
+
role: "status",
|
|
120
|
+
"aria-busy": !0,
|
|
121
|
+
"aria-label": s
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
u.displayName = "Skeleton.Input";
|
|
125
|
+
var d = {
|
|
126
|
+
small: 32,
|
|
127
|
+
middle: 44,
|
|
128
|
+
large: 56
|
|
129
|
+
}, f = ({ size: n = "middle", shape: i = "circle", active: a = !0, className: o, style: s, "aria-label": c = "加载中" }) => {
|
|
130
|
+
let l = d[n];
|
|
131
|
+
return /* @__PURE__ */ r("div", {
|
|
132
|
+
className: t(e.skeleton, i === "circle" ? e["vt-circle"] : e["skeleton-avatar-square"], a && e.active, o),
|
|
133
|
+
style: {
|
|
134
|
+
width: l,
|
|
135
|
+
height: l,
|
|
136
|
+
...s
|
|
137
|
+
},
|
|
138
|
+
role: "status",
|
|
139
|
+
"aria-busy": !0,
|
|
140
|
+
"aria-label": c
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
f.displayName = "Skeleton.Avatar";
|
|
144
|
+
var p = o;
|
|
145
|
+
p.Button = c, p.Input = u, p.Avatar = f, p.displayName = "Skeleton";
|
|
146
|
+
//#endregion
|
|
147
|
+
export { p as Skeleton };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region packages/react/src/components/Skeleton/skeleton.module.less
|
|
2
|
+
var e = "_skeleton_p760x_1", t = "_active_p760x_11", n = "_line_p760x_44", r = {
|
|
3
|
+
skeleton: e,
|
|
4
|
+
active: t,
|
|
5
|
+
"stitch-skeleton-shimmer": "_stitch-skeleton-shimmer_p760x_1",
|
|
6
|
+
"vt-text": "_vt-text_p760x_26",
|
|
7
|
+
"vt-circle": "_vt-circle_p760x_31",
|
|
8
|
+
"vt-rect": "_vt-rect_p760x_34",
|
|
9
|
+
"vt-paragraph": "_vt-paragraph_p760x_37",
|
|
10
|
+
line: n,
|
|
11
|
+
"skeleton-btn": "_skeleton-btn_p760x_49",
|
|
12
|
+
"skeleton-input": "_skeleton-input_p760x_52",
|
|
13
|
+
"skeleton-avatar-square": "_skeleton-avatar-square_p760x_55"
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { t as active, r as default, n as line, e as skeleton };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SliderOrientation = 'horizontal' | 'vertical';
|
|
3
|
+
/**
|
|
4
|
+
* 拖动条(Ant `Slider` 语义):拖 thumb 在 `min`–`max` 间按 `step` 取连续/离散值。
|
|
5
|
+
* 单值给标量(一个 thumb)、区间给数组(两个 thumb);`value`/`defaultValue`/`onChange`
|
|
6
|
+
* + `min`/`max`/`step` + `disabled` + `orientation`。
|
|
7
|
+
*
|
|
8
|
+
* 跨-prop 注意事项:
|
|
9
|
+
* - **标量↔数组归一**:底层 `value` 恒为数组(支持多 thumb);对外单值时接受标量、内部包成
|
|
10
|
+
* `[v]`,`onValueChange(arr)` → 单值取 `arr[0]`、区间原样传数组。是否区间由 `value ??
|
|
11
|
+
* defaultValue` 是否为数组判定(数组 = 区间,渲两个 thumb)。
|
|
12
|
+
* - **vs Progress**:Progress 只读展示进度、无 thumb 不可拖;Slider **可拖取值**。
|
|
13
|
+
* vs Switch:Switch 是布尔两态,Slider 是连续/离散取值。
|
|
14
|
+
* - **受控/非受控双模式**:给 `value` 由父管(配 `onChange`),只给 `defaultValue` 组件自管;
|
|
15
|
+
* 两者内部包成数组后透传底层。
|
|
16
|
+
* - **Less 皮**:`track` 走 `--stitch-border` 底槽、`range` 走 `--stitch-accent`、`thumb`
|
|
17
|
+
* 圆点 + focus 环 `--stitch-focus-ring`;禁用态由底层挂的 `data-disabled` 描,组件不自持 state。
|
|
18
|
+
* - **键盘 / 焦点 / ARIA**(←→ 调值、Home/End、`aria-valuenow`)由底层保证,组件不重复实现;
|
|
19
|
+
* thumb 是 `role="slider"`,**须有可及名**——用 `aria-label` 或 `aria-labelledby` 指定
|
|
20
|
+
* (内容相关,由使用者给)。
|
|
21
|
+
*/
|
|
22
|
+
export interface SliderProps {
|
|
23
|
+
/** 受控值:标量 = 单值(一个 thumb),数组 = 区间(多个 thumb) */
|
|
24
|
+
value?: number | number[];
|
|
25
|
+
/** 非受控初始值:标量 = 单值,数组 = 区间 */
|
|
26
|
+
defaultValue?: number | number[];
|
|
27
|
+
/** 值变化回调;单值回标量、区间回数组(与传入形状一致) */
|
|
28
|
+
onChange?: (value: number | number[]) => void;
|
|
29
|
+
/**
|
|
30
|
+
* 最小值
|
|
31
|
+
* @default 0
|
|
32
|
+
*/
|
|
33
|
+
min?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 最大值
|
|
36
|
+
* @default 100
|
|
37
|
+
*/
|
|
38
|
+
max?: number;
|
|
39
|
+
/**
|
|
40
|
+
* 步长
|
|
41
|
+
* @default 1
|
|
42
|
+
*/
|
|
43
|
+
step?: number;
|
|
44
|
+
/** 禁用 */
|
|
45
|
+
disabled?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 朝向
|
|
48
|
+
* @default 'horizontal'
|
|
49
|
+
*/
|
|
50
|
+
orientation?: SliderOrientation;
|
|
51
|
+
/** 自定义类名(挂到根轨道容器) */
|
|
52
|
+
className?: string;
|
|
53
|
+
/** 无障碍标签(无可见 label 时给 thumb 一个可及名) */
|
|
54
|
+
'aria-label'?: string;
|
|
55
|
+
/** 关联外部可见 label 的 id */
|
|
56
|
+
'aria-labelledby'?: string;
|
|
57
|
+
}
|
|
58
|
+
export declare const Slider: React.FC<SliderProps>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import e from "./slider.module.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import t from "clsx";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
import { Slider as i } from "radix-ui";
|
|
6
|
+
//#region packages/react/src/components/Slider/Slider.tsx
|
|
7
|
+
var a = (e) => Array.isArray(e) ? e : [e], o = ({ value: o, defaultValue: s, onChange: c, min: l = 0, max: u = 100, step: d = 1, disabled: f = !1, orientation: p = "horizontal", className: m, "aria-label": h, "aria-labelledby": g }) => {
|
|
8
|
+
let _ = Array.isArray(o ?? s), v = o === void 0 ? void 0 : a(o), y = s === void 0 ? void 0 : a(s), b = (v ?? y)?.length ?? 1;
|
|
9
|
+
return /* @__PURE__ */ r(i.Root, {
|
|
10
|
+
className: t(e.root, m),
|
|
11
|
+
value: v,
|
|
12
|
+
defaultValue: y,
|
|
13
|
+
onValueChange: c ? (e) => {
|
|
14
|
+
c?.(_ ? e : e[0]);
|
|
15
|
+
} : void 0,
|
|
16
|
+
min: l,
|
|
17
|
+
max: u,
|
|
18
|
+
step: d,
|
|
19
|
+
disabled: f,
|
|
20
|
+
orientation: p,
|
|
21
|
+
children: [/* @__PURE__ */ n(i.Track, {
|
|
22
|
+
className: e.track,
|
|
23
|
+
children: /* @__PURE__ */ n(i.Range, { className: e.range })
|
|
24
|
+
}), Array.from({ length: b }, (t, r) => /* @__PURE__ */ n(i.Thumb, {
|
|
25
|
+
className: e.thumb,
|
|
26
|
+
"aria-label": h,
|
|
27
|
+
"aria-labelledby": g
|
|
28
|
+
}, r))]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
o.displayName = "Slider";
|
|
32
|
+
//#endregion
|
|
33
|
+
export { o as Slider };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region packages/react/src/components/Slider/slider.module.less
|
|
2
|
+
var e = "_root_1i2nk_1", t = "_track_1i2nk_23", n = "_range_1i2nk_36", r = "_thumb_1i2nk_47", i = {
|
|
3
|
+
root: e,
|
|
4
|
+
track: t,
|
|
5
|
+
range: n,
|
|
6
|
+
thumb: r
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { i as default, n as range, e as root, r as thumb, t as track };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type SwitchSize = 'small' | 'middle' | 'large';
|
|
3
|
+
/**
|
|
4
|
+
* 开关(Ant `Switch` 语义):`checked` / `defaultChecked` / `onChange(boolean)`,
|
|
5
|
+
* `<button role="switch" aria-checked>` + Space/Enter 键切换。结构 = 轨(button 本体)+
|
|
6
|
+
* `.handle`(滑块)+ `.inner`(轨内小文案,滑块对侧显示 `checkedChildren`/`unCheckedChildren`)。
|
|
7
|
+
*
|
|
8
|
+
* 跨-prop 注意事项:
|
|
9
|
+
* - **受控/非受控双模式**:给 `checked` 由父管,只给 `defaultChecked` 组件自管;原生 button
|
|
10
|
+
* 焦点 + 手动键处理,`aria-label` / `aria-labelledby` 透传。
|
|
11
|
+
* - **形状走 `--stitch-radius-button`(轨 + 滑块同用),非 `--stitch-radius-input`**:开关是
|
|
12
|
+
* 「按钮型动作」而非「取值盒」,取按钮圆角档以保住滑动隐喻(与 Checkbox/Radio 的取值盒不同源)。
|
|
13
|
+
* ON 态填 `--stitch-accent` + 边 `--stitch-accent-active`(与 Checkbox/Radio 选中同源);
|
|
14
|
+
* OFF 轨走中性 `--stitch-border-strong`,滑块填 `--stitch-bg-elevated` + 1px `--stitch-border`。
|
|
15
|
+
* - **轨内文案竖向居中的实现 gotcha**:文案套一层 inline-block `.innerText` 承载
|
|
16
|
+
* `text-box: trim-both cap alphabetic`(渐进增强)——**`text-box` 只对直接生成行盒的块/行内块
|
|
17
|
+
* 生效,放在 flex 的 `.inner` 上会被静默忽略**(computed 报 trim 但盒高不变、不居中)。裁到真实
|
|
18
|
+
* cap/基线后按墨迹居中,解决 Latin 全大写(ON/OFF)无降部显偏低、与 CJK 墨位不一致的问题;
|
|
19
|
+
* fallback(不支持的浏览器)走 `line-height:normal`。带降部的文案(小写 g/y)降部挂在裁剪盒外
|
|
20
|
+
* 略偏高,轨内标签惯常无降部、可接受。
|
|
21
|
+
* - **尺寸 `small`/`middle`/`large`**(默认 `middle`):控件几何(轨高/宽、滑块直径)为物理像素、
|
|
22
|
+
* 非主题值;圆角/颜色/字体全走 token。`loading` 为**非交互 + `aria-busy` + 变暗**,无内建动画。
|
|
23
|
+
*/
|
|
24
|
+
export interface SwitchProps {
|
|
25
|
+
/** 是否选中(受控) */
|
|
26
|
+
checked?: boolean;
|
|
27
|
+
/** 默认是否选中(非受控) */
|
|
28
|
+
defaultChecked?: boolean;
|
|
29
|
+
/** 尺寸 */
|
|
30
|
+
size?: SwitchSize;
|
|
31
|
+
/** 禁用 */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** 加载状态:非交互 + `aria-busy`(无内建 spinner 动画,见 notes) */
|
|
34
|
+
loading?: boolean;
|
|
35
|
+
/** 选中时轨内文案 */
|
|
36
|
+
checkedChildren?: React.ReactNode;
|
|
37
|
+
/** 未选中时轨内文案 */
|
|
38
|
+
unCheckedChildren?: React.ReactNode;
|
|
39
|
+
/** 变化回调 */
|
|
40
|
+
onChange?: (checked: boolean) => void;
|
|
41
|
+
/** 自定义类名 */
|
|
42
|
+
className?: string;
|
|
43
|
+
/** 自定义样式 */
|
|
44
|
+
style?: React.CSSProperties;
|
|
45
|
+
/** 无障碍标签(无可见 label 时使用) */
|
|
46
|
+
'aria-label'?: string;
|
|
47
|
+
/** 关联外部可见 label 的 id */
|
|
48
|
+
'aria-labelledby'?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const Switch: React.FC<SwitchProps>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import e from "./switch.module.js";
|
|
2
|
+
import { useCallback as t, useState as n } from "react";
|
|
3
|
+
import r from "clsx";
|
|
4
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
|
+
//#region packages/react/src/components/Switch/Switch.tsx
|
|
6
|
+
var o = ({ checked: o, defaultChecked: s = !1, size: c = "middle", disabled: l = !1, loading: u = !1, checkedChildren: d, unCheckedChildren: f, onChange: p, className: m, style: h, "aria-label": g, "aria-labelledby": _ }) => {
|
|
7
|
+
let [v, y] = n(s), b = o !== void 0, x = b ? o : v, S = t(() => {
|
|
8
|
+
if (l || u) return;
|
|
9
|
+
let e = !x;
|
|
10
|
+
b || y(e), p?.(e);
|
|
11
|
+
}, [
|
|
12
|
+
l,
|
|
13
|
+
u,
|
|
14
|
+
x,
|
|
15
|
+
b,
|
|
16
|
+
p
|
|
17
|
+
]), C = t((e) => {
|
|
18
|
+
(e.key === " " || e.key === "Enter") && (e.preventDefault(), S());
|
|
19
|
+
}, [S]);
|
|
20
|
+
return /* @__PURE__ */ a("button", {
|
|
21
|
+
type: "button",
|
|
22
|
+
role: "switch",
|
|
23
|
+
"aria-checked": x,
|
|
24
|
+
"aria-label": g,
|
|
25
|
+
"aria-labelledby": _,
|
|
26
|
+
"aria-busy": u || void 0,
|
|
27
|
+
className: r(e.switch, e[c], x && e.checked, l && e.disabled, u && e.loading, m),
|
|
28
|
+
style: h,
|
|
29
|
+
onClick: S,
|
|
30
|
+
onKeyDown: C,
|
|
31
|
+
disabled: l,
|
|
32
|
+
children: [/* @__PURE__ */ i("span", { className: e.handle }), /* @__PURE__ */ i("span", {
|
|
33
|
+
className: e.inner,
|
|
34
|
+
children: /* @__PURE__ */ i("span", {
|
|
35
|
+
className: e.innerText,
|
|
36
|
+
children: x ? d : f
|
|
37
|
+
})
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
o.displayName = "Switch";
|
|
42
|
+
//#endregion
|
|
43
|
+
export { o as Switch };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region packages/react/src/components/Switch/switch.module.less
|
|
2
|
+
var e = "_disabled_19mtb_18", t = "_checked_19mtb_18", n = "_handle_19mtb_37", r = "_inner_19mtb_54", i = "_innerText_19mtb_71", a = "_loading_19mtb_81", o = "_small_19mtb_85", s = "_middle_19mtb_92", c = "_large_19mtb_99", l = {
|
|
3
|
+
switch: "_switch_19mtb_1",
|
|
4
|
+
disabled: e,
|
|
5
|
+
checked: t,
|
|
6
|
+
handle: n,
|
|
7
|
+
inner: r,
|
|
8
|
+
innerText: i,
|
|
9
|
+
loading: a,
|
|
10
|
+
small: o,
|
|
11
|
+
middle: s,
|
|
12
|
+
large: c
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { t as checked, l as default, e as disabled, n as handle, r as inner, i as innerText, c as large, a as loading, s as middle, o as small };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
export interface TableColumn<T = Record<string, unknown>> {
|
|
3
|
+
/** 列头(表头单元格内容,也是该列的可访问名来源) */
|
|
4
|
+
title: React.ReactNode;
|
|
5
|
+
/** 取值字段名;缺省时靠 `render` 自定义单元格 */
|
|
6
|
+
dataIndex?: keyof T;
|
|
7
|
+
/** 自定义单元格渲染,优先于 `dataIndex` 取值 */
|
|
8
|
+
render?: (value: unknown, record: T, index: number) => React.ReactNode;
|
|
9
|
+
/** 列宽(数字按 px,字符串原样) */
|
|
10
|
+
width?: string | number;
|
|
11
|
+
/** 单元格水平对齐 */
|
|
12
|
+
align?: 'left' | 'center' | 'right';
|
|
13
|
+
/** 额外内联样式,合并到该列每个单元格 */
|
|
14
|
+
style?: React.CSSProperties;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 数据表(Ant v5 `Table` 语义):`columns` + `dataSource` + `rowKey`(字段名或函数)+
|
|
18
|
+
* `striped` / `showHeader` / `rowClassName` / `onRow` / `loading` / `emptyText` / `scroll`。
|
|
19
|
+
*
|
|
20
|
+
* 跨-prop 注意事项:
|
|
21
|
+
* - **纯展示件,无内部 state,未提供排序 / 选择**:源为纯展示语义,源码为权威、不臆造 API。
|
|
22
|
+
* `extends HTMLAttributes<HTMLDivElement>`(`Omit<'onChange'>`),`...rest` 透传到卡面容器
|
|
23
|
+
* (`className` / `style` / `data-*` / `aria-*`)。
|
|
24
|
+
* - **键盘维度**:表格本体无交互键盘行为;`scroll` 给定时容器成**可聚焦滚动区**(`tabIndex=0`,
|
|
25
|
+
* WCAG 2.1.1 可滚动内容须键盘可达),有 `aria-label` 时才挂 `role="region"`(无名 region 是
|
|
26
|
+
* a11y 噪声)。
|
|
27
|
+
* - **图标走 `<Icon>` 非裸 `<svg>`**:空态 `<Icon name="info">`(装饰 `aria-hidden`);加载态为纯
|
|
28
|
+
* CSS 环(中性描边 + `--stitch-accent` 高亮弧),loading overlay 挂 `role="status"` +
|
|
29
|
+
* `aria-label`。
|
|
30
|
+
*/
|
|
31
|
+
export interface TableProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
32
|
+
/** 列定义(Ant v5 `columns` 语义) */
|
|
33
|
+
columns?: TableColumn[];
|
|
34
|
+
/** 数据源(Ant v5 `dataSource` 语义) */
|
|
35
|
+
dataSource?: Record<string, unknown>[];
|
|
36
|
+
/** 行 key:字段名或从记录派生的函数(缺省取 `key` 字段,再退化为下标) */
|
|
37
|
+
rowKey?: string | ((record: Record<string, unknown>) => string);
|
|
38
|
+
/**
|
|
39
|
+
* 斑马纹(偶数行加浅底)
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
striped?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* 是否显示表头
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
showHeader?: boolean;
|
|
48
|
+
/** 自定义行类名:静态字符串或从记录派生的函数 */
|
|
49
|
+
rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
50
|
+
/** 逐行透传原生属性(如 onClick),Ant v5 `onRow` 语义 */
|
|
51
|
+
onRow?: (record: Record<string, unknown>, index: number) => HTMLAttributes<HTMLTableRowElement>;
|
|
52
|
+
/**
|
|
53
|
+
* 加载态(叠加半透明遮罩 + spinner,屏蔽指针)
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
loading?: boolean;
|
|
57
|
+
/** 空数据提示 */
|
|
58
|
+
emptyText?: React.ReactNode;
|
|
59
|
+
/** 溢出滚动(给定即让容器成为可键盘聚焦的滚动区,Ant v5 `scroll` 语义) */
|
|
60
|
+
scroll?: {
|
|
61
|
+
x?: number | string;
|
|
62
|
+
y?: number | string;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export declare const Table: React.FC<TableProps>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
+
import t from "./table.module.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import n from "clsx";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/react/src/components/Table/Table.tsx
|
|
7
|
+
var a = ({ columns: a = [], dataSource: o = [], rowKey: s = "key", striped: c = !0, showHeader: l = !0, rowClassName: u, onRow: d, loading: f = !1, emptyText: p = "暂无数据", scroll: m, className: h, style: g, "aria-label": _, ...v }) => {
|
|
8
|
+
let y = (e, t) => typeof s == "function" ? s(e) : e[s] || String(t), b = (e, r) => {
|
|
9
|
+
let i = typeof u == "function" ? u(e, r) : u;
|
|
10
|
+
return n(t.row, c && r % 2 == 1 && t.striped, i);
|
|
11
|
+
}, x = (e, t, n) => {
|
|
12
|
+
let r = e.dataIndex ? t[e.dataIndex] : void 0;
|
|
13
|
+
return e.render ? e.render(r, t, n) : r;
|
|
14
|
+
}, S = m != null, C = S && _ != null ? "region" : void 0;
|
|
15
|
+
return /* @__PURE__ */ i("div", {
|
|
16
|
+
className: n(t.wrapper, S && t.scrollable, h),
|
|
17
|
+
style: g,
|
|
18
|
+
tabIndex: S ? 0 : void 0,
|
|
19
|
+
role: C,
|
|
20
|
+
"aria-label": _,
|
|
21
|
+
...v,
|
|
22
|
+
children: [/* @__PURE__ */ i("table", {
|
|
23
|
+
className: n(t.table, f && t.loading),
|
|
24
|
+
children: [l && /* @__PURE__ */ r("thead", {
|
|
25
|
+
className: t.thead,
|
|
26
|
+
children: /* @__PURE__ */ r("tr", {
|
|
27
|
+
className: t.headerRow,
|
|
28
|
+
children: a.map((e, n) => /* @__PURE__ */ r("th", {
|
|
29
|
+
scope: "col",
|
|
30
|
+
className: t.headerCell,
|
|
31
|
+
style: {
|
|
32
|
+
width: e.width,
|
|
33
|
+
textAlign: e.align || "left",
|
|
34
|
+
...e.style
|
|
35
|
+
},
|
|
36
|
+
children: e.title
|
|
37
|
+
}, n))
|
|
38
|
+
})
|
|
39
|
+
}), /* @__PURE__ */ r("tbody", {
|
|
40
|
+
className: t.tbody,
|
|
41
|
+
children: o.length === 0 ? /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r("td", {
|
|
42
|
+
colSpan: a.length || 1,
|
|
43
|
+
className: t.emptyCell,
|
|
44
|
+
children: /* @__PURE__ */ i("div", {
|
|
45
|
+
className: t.emptyContent,
|
|
46
|
+
children: [/* @__PURE__ */ r(e, {
|
|
47
|
+
name: "info",
|
|
48
|
+
size: 40,
|
|
49
|
+
className: t.emptyIcon
|
|
50
|
+
}), /* @__PURE__ */ r("span", { children: p })]
|
|
51
|
+
})
|
|
52
|
+
}) }) : o.map((e, n) => /* @__PURE__ */ r("tr", {
|
|
53
|
+
className: b(e, n),
|
|
54
|
+
...d?.(e, n),
|
|
55
|
+
children: a.map((i, a) => /* @__PURE__ */ r("td", {
|
|
56
|
+
className: t.cell,
|
|
57
|
+
style: {
|
|
58
|
+
textAlign: i.align || "left",
|
|
59
|
+
...i.style
|
|
60
|
+
},
|
|
61
|
+
children: x(i, e, n)
|
|
62
|
+
}, a))
|
|
63
|
+
}, y(e, n)))
|
|
64
|
+
})]
|
|
65
|
+
}), f && /* @__PURE__ */ r("div", {
|
|
66
|
+
className: t.loadingOverlay,
|
|
67
|
+
role: "status",
|
|
68
|
+
"aria-label": "加载中",
|
|
69
|
+
children: /* @__PURE__ */ r("span", { className: t.loadingSpinner })
|
|
70
|
+
})]
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
a.displayName = "Table";
|
|
74
|
+
//#endregion
|
|
75
|
+
export { a as Table };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region packages/react/src/components/Table/table.module.less
|
|
2
|
+
var e = "_wrapper_gfk3g_1", t = "_scrollable_gfk3g_11", n = "_table_gfk3g_18", r = "_thead_gfk3g_23", i = "_headerCell_gfk3g_26", a = "_tbody_gfk3g_36", o = "_row_gfk3g_39", s = "_striped_gfk3g_45", c = "_cell_gfk3g_51", l = "_emptyCell_gfk3g_63", u = "_emptyContent_gfk3g_67", d = "_emptyIcon_gfk3g_75", f = "_loading_gfk3g_79", p = "_loadingOverlay_gfk3g_83", m = "_loadingSpinner_gfk3g_93", h = "_spin_gfk3g_1", g = {
|
|
3
|
+
wrapper: e,
|
|
4
|
+
scrollable: t,
|
|
5
|
+
table: n,
|
|
6
|
+
thead: r,
|
|
7
|
+
headerCell: i,
|
|
8
|
+
tbody: a,
|
|
9
|
+
row: o,
|
|
10
|
+
striped: s,
|
|
11
|
+
cell: c,
|
|
12
|
+
emptyCell: l,
|
|
13
|
+
emptyContent: u,
|
|
14
|
+
emptyIcon: d,
|
|
15
|
+
loading: f,
|
|
16
|
+
loadingOverlay: p,
|
|
17
|
+
loadingSpinner: m,
|
|
18
|
+
spin: h
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { c as cell, g as default, l as emptyCell, u as emptyContent, d as emptyIcon, i as headerCell, f as loading, p as loadingOverlay, m as loadingSpinner, o as row, t as scrollable, h as spin, s as striped, n as table, a as tbody, r as thead, e as wrapper };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface TabItem {
|
|
3
|
+
/** 唯一标识,切换 / 受控回写都用它 */
|
|
4
|
+
key: string;
|
|
5
|
+
/** 标签文本(tab 的可访问名来源) */
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
/** 该 tab 激活时显示的面板内容 */
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 药丸标签组(Ant v5 `Tabs` `items` 语义):`items` 面板列表 + 受控 `activeKey` /
|
|
12
|
+
* 非受控 `defaultActiveKey` + `onChange`。
|
|
13
|
+
*
|
|
14
|
+
* 跨-prop 注意事项:
|
|
15
|
+
* - **受控/非受控双模式**:给 `activeKey` 即受控(配 `onChange` 用),只给
|
|
16
|
+
* `defaultActiveKey` 组件自管(缺省取首项)。`extends HTMLAttributes<HTMLDivElement>`
|
|
17
|
+
* 但 `Omit<'onChange'>`——原生 form 的 `onChange` 与本组件 `(key)=>void` 签名冲突;
|
|
18
|
+
* `...rest` 透传到根 `<div>`(`className` / `style` / `data-*`)。
|
|
19
|
+
* - **`aria-label` 路由到 tablist**:显式解构后挂到 `role="tablist"` 而非根 `...rest`——
|
|
20
|
+
* tablist 才是需要可访问名的元素。每个 tab 与其面板经 `aria-controls` / `aria-labelledby`
|
|
21
|
+
* 双向关联。
|
|
22
|
+
* - **激活指示双通道**:激活 tab 由「反色暗面填充(`--stitch-bg-inverted` +
|
|
23
|
+
* `--stitch-text-on-dark`)+ `aria-selected`」两通道同时表达,无需额外状态图标;未激活为
|
|
24
|
+
* 透明底 + `--stitch-text-primary` + `--stitch-border` 发丝药丸边。切换时面板内容随
|
|
25
|
+
* `activeKey` 重挂载令淡入每次都重放(`--stitch-motion-*`),而非仅首次挂载放一次。
|
|
26
|
+
*/
|
|
27
|
+
export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
28
|
+
/** 标签项列表(Ant v5 `items` 语义) */
|
|
29
|
+
items: TabItem[];
|
|
30
|
+
/** 非受控初始激活项 key(缺省取首项) */
|
|
31
|
+
defaultActiveKey?: string;
|
|
32
|
+
/** 受控激活项 key(给了即受控;配 `onChange` 用) */
|
|
33
|
+
activeKey?: string;
|
|
34
|
+
/** 激活项变化回调(受控/非受控都会触发) */
|
|
35
|
+
onChange?: (key: string) => void;
|
|
36
|
+
}
|
|
37
|
+
export declare const Tabs: React.FC<TabsProps>;
|