@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,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CodeBlockProps extends React.HTMLAttributes<HTMLPreElement> {
|
|
3
|
+
/** 要展示 / 高亮的源代码 */
|
|
4
|
+
code: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 只读代码块:暗色表面 + 轻量语法高亮。
|
|
8
|
+
* 可用 Tab 聚焦、方向键滚动(`tabIndex=0` 的可滚动区域);默认可及名「代码块」,可用 `aria-label` 覆盖。
|
|
9
|
+
*/
|
|
10
|
+
export declare const CodeBlock: React.FC<CodeBlockProps>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import e from "./codeblock.module.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import t from "clsx";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region packages/react/src/components/CodeBlock/CodeBlock.tsx
|
|
6
|
+
var r = {
|
|
7
|
+
comment: e["tok-comment"],
|
|
8
|
+
string: e["tok-string"],
|
|
9
|
+
keyword: e["tok-keyword"],
|
|
10
|
+
react: e["tok-react"],
|
|
11
|
+
component: e["tok-component"],
|
|
12
|
+
func: e["tok-func"],
|
|
13
|
+
prop: e["tok-prop"],
|
|
14
|
+
jsx: e["tok-jsx"],
|
|
15
|
+
operator: e["tok-operator"],
|
|
16
|
+
number: e["tok-number"],
|
|
17
|
+
default: e["tok-default"]
|
|
18
|
+
}, i = (e) => {
|
|
19
|
+
let t = [], i = (n, r) => {
|
|
20
|
+
let i, a = new RegExp(n.source, n.flags.includes("g") ? n.flags : n.flags + "g");
|
|
21
|
+
for (; (i = a.exec(e)) !== null;) t.push({
|
|
22
|
+
start: i.index,
|
|
23
|
+
end: i.index + i[0].length,
|
|
24
|
+
type: r
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
i(/\/\*[\s\S]*?\*\//g, "comment"), i(/\/\/.*$/gm, "comment"), i(/`[^`]*`/g, "string"), i(/"[^"]*"/g, "string"), i(/'[^']*'/g, "string"), i(/<\/?[A-Z][\w.$]*/g, "jsx"), i(/<\/?[a-z][\w-]*/g, "jsx"), i(/\/?>/g, "jsx"), i(/\b(React|useState|useEffect|useCallback|useMemo|useRef|useContext|useReducer|useLayoutEffect|useImperativeHandle|useDebugValue|createContext|createElement|cloneElement|Fragment|Suspense|lazy|memo|forwardRef|useId|FC|ReactNode|ReactElement|CSSProperties)\b/g, "react"), i(/\b(true|false)\b/g, "keyword"), i(/\b(null|undefined|void|NaN|Infinity)\b/gi, "keyword"), i(/\b\d+\.?\d*\b/g, "number"), i(/\b(import|from|as|export|default|const|let|var|function|return|if|else|for|while|switch|case|break|continue|try|catch|throw|finally|new|typeof|instanceof|async|await|type|interface)\b/gi, "keyword"), i(/\b[A-Z][a-zA-Z0-9_$]*\b/g, "component"), i(/\b[a-z][a-zA-Z0-9_$]*\s*(?=\()/g, "func"), i(/\b[a-zA-Z_$][\w$]*\s*(?==)/g, "prop"), i(/>|===|!==|==|!=|<=|>=|&&|\|\||[+\-*/%=<>!&|^~?:]/g, "operator"), i(/[{}[\]();,]/g, "operator"), t.sort((e, t) => e.start - t.start);
|
|
28
|
+
let a = [], o = 0;
|
|
29
|
+
for (let i of t) i.start < o || (i.start > o && a.push(/* @__PURE__ */ n("span", {
|
|
30
|
+
className: r.default,
|
|
31
|
+
children: e.slice(o, i.start)
|
|
32
|
+
}, `t${o}`)), a.push(/* @__PURE__ */ n("span", {
|
|
33
|
+
className: r[i.type],
|
|
34
|
+
children: e.slice(i.start, i.end)
|
|
35
|
+
}, `s${i.start}`)), o = i.end);
|
|
36
|
+
return o < e.length && a.push(/* @__PURE__ */ n("span", {
|
|
37
|
+
className: r.default,
|
|
38
|
+
children: e.slice(o)
|
|
39
|
+
}, `e${o}`)), a;
|
|
40
|
+
}, a = ({ code: r, className: a, ...o }) => /* @__PURE__ */ n("pre", {
|
|
41
|
+
role: "group",
|
|
42
|
+
"aria-label": "代码块",
|
|
43
|
+
tabIndex: 0,
|
|
44
|
+
className: t(e.codeBlock, a),
|
|
45
|
+
...o,
|
|
46
|
+
children: i(r)
|
|
47
|
+
});
|
|
48
|
+
a.displayName = "CodeBlock";
|
|
49
|
+
//#endregion
|
|
50
|
+
export { a as CodeBlock };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region packages/react/src/components/CodeBlock/codeblock.module.less
|
|
2
|
+
var e = "_codeBlock_zsyzk_1", t = {
|
|
3
|
+
codeBlock: e,
|
|
4
|
+
"tok-default": "_tok-default_zsyzk_19",
|
|
5
|
+
"tok-comment": "_tok-comment_zsyzk_22",
|
|
6
|
+
"tok-operator": "_tok-operator_zsyzk_25",
|
|
7
|
+
"tok-keyword": "_tok-keyword_zsyzk_28",
|
|
8
|
+
"tok-react": "_tok-react_zsyzk_31",
|
|
9
|
+
"tok-string": "_tok-string_zsyzk_34",
|
|
10
|
+
"tok-number": "_tok-number_zsyzk_37",
|
|
11
|
+
"tok-component": "_tok-component_zsyzk_40",
|
|
12
|
+
"tok-func": "_tok-func_zsyzk_43",
|
|
13
|
+
"tok-prop": "_tok-prop_zsyzk_46",
|
|
14
|
+
"tok-jsx": "_tok-jsx_zsyzk_49"
|
|
15
|
+
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as codeBlock, t as default };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 单项披露件(Ant v5 `Collapse.Panel` 语义,非多面板 accordion):`header`(触发标题)+
|
|
4
|
+
* `children`(面板内容)+ 受控/非受控 `open` / `defaultOpen` / `onOpenChange` + `disabled`。
|
|
5
|
+
*
|
|
6
|
+
* 跨-prop 注意事项:
|
|
7
|
+
* - **受控/非受控双模式**:给 `open` 由父管(配 `onOpenChange`),只给 `defaultOpen` 组件自管
|
|
8
|
+
* (非靠 remount 换 `defaultOpen` 的伪受控)。`extends HTMLAttributes<HTMLDivElement>`、
|
|
9
|
+
* `...rest` 透传(`className` / `style` / `data-*` / `aria-*`)。
|
|
10
|
+
* - **展开指示走 `<Icon name="chevron-down">`**(跟随 `currentColor`、展开旋转 180°),非
|
|
11
|
+
* Unicode `+`/`−` 字符、非裸 `<svg>`;用中立 chevron 而非填充强调圆,避免与「一屏最多一个填充
|
|
12
|
+
* 强调」的克制冲突。头部/内容经 `aria-controls` / `aria-labelledby` 关联,`disabled` 时不可展开。
|
|
13
|
+
* - **容器表面**:`--stitch-bg-elevated` + `--stitch-border`(发丝)+ `--stitch-radius-card`,
|
|
14
|
+
* 无阴影(边框即结构);圆角随主题变。
|
|
15
|
+
*/
|
|
16
|
+
export interface CollapseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
17
|
+
/** 触发区标题(可点击的问句 / 标签) */
|
|
18
|
+
header: React.ReactNode;
|
|
19
|
+
/** 展开后显示的面板内容 */
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* 受控展开状态(给了即受控;配 `onOpenChange` 用)
|
|
23
|
+
*/
|
|
24
|
+
open?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 非受控初始展开状态
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
defaultOpen?: boolean;
|
|
30
|
+
/** 展开状态变化回调(受控/非受控都会触发) */
|
|
31
|
+
onOpenChange?: (open: boolean) => void;
|
|
32
|
+
/**
|
|
33
|
+
* 是否禁用(禁用后不可切换、按钮 disabled)
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
disabled?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare const Collapse: React.FC<CollapseProps>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
+
import t from "./collapse.module.js";
|
|
3
|
+
import { useCallback as n, useId as r, useState as i } from "react";
|
|
4
|
+
import a from "clsx";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/react/src/components/Collapse/Collapse.tsx
|
|
7
|
+
var c = ({ header: c, children: l, open: u, defaultOpen: d = !1, onOpenChange: f, disabled: p = !1, className: m, ...h }) => {
|
|
8
|
+
let [g, _] = i(d), v = u !== void 0, y = v ? u : g, b = `stitch-collapse-${r().replace(/:/g, "")}`, x = `${b}-header`, S = `${b}-panel`, C = n(() => {
|
|
9
|
+
if (p) return;
|
|
10
|
+
let e = !y;
|
|
11
|
+
v || _(e), f?.(e);
|
|
12
|
+
}, [
|
|
13
|
+
p,
|
|
14
|
+
y,
|
|
15
|
+
v,
|
|
16
|
+
f
|
|
17
|
+
]), w = a(t.collapse, y && t.expanded, p && t.disabled, m);
|
|
18
|
+
return /* @__PURE__ */ s("div", {
|
|
19
|
+
className: w,
|
|
20
|
+
...h,
|
|
21
|
+
children: [/* @__PURE__ */ s("button", {
|
|
22
|
+
type: "button",
|
|
23
|
+
id: x,
|
|
24
|
+
className: t.header,
|
|
25
|
+
onClick: C,
|
|
26
|
+
disabled: p,
|
|
27
|
+
"aria-expanded": y,
|
|
28
|
+
"aria-controls": S,
|
|
29
|
+
children: [/* @__PURE__ */ o("span", {
|
|
30
|
+
className: t.indicator,
|
|
31
|
+
children: /* @__PURE__ */ o(e, { name: "chevron-down" })
|
|
32
|
+
}), /* @__PURE__ */ o("span", {
|
|
33
|
+
className: t.text,
|
|
34
|
+
children: c
|
|
35
|
+
})]
|
|
36
|
+
}), /* @__PURE__ */ o("div", {
|
|
37
|
+
className: t.panel,
|
|
38
|
+
id: S,
|
|
39
|
+
role: "region",
|
|
40
|
+
"aria-labelledby": x,
|
|
41
|
+
children: /* @__PURE__ */ o("div", {
|
|
42
|
+
className: t.content,
|
|
43
|
+
children: l
|
|
44
|
+
})
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
c.displayName = "Collapse";
|
|
49
|
+
//#endregion
|
|
50
|
+
export { c as Collapse };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region packages/react/src/components/Collapse/collapse.module.less
|
|
2
|
+
var e = "_collapse_xqb89_1", t = "_disabled_xqb89_11", n = "_header_xqb89_14", r = "_indicator_xqb89_34", i = "_expanded_xqb89_40", a = "_text_xqb89_43", o = "_panel_xqb89_50", s = "_content_xqb89_58", c = {
|
|
3
|
+
collapse: e,
|
|
4
|
+
disabled: t,
|
|
5
|
+
header: n,
|
|
6
|
+
indicator: r,
|
|
7
|
+
expanded: i,
|
|
8
|
+
text: a,
|
|
9
|
+
panel: o,
|
|
10
|
+
content: s
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as collapse, s as content, c as default, t as disabled, i as expanded, n as header, r as indicator, o as panel, a as text };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type IconName } from '../Icon';
|
|
3
|
+
/**
|
|
4
|
+
* 右键菜单里的一项。结构与 `DropdownMenuItem` 完全一致(同族,同一心智)。
|
|
5
|
+
*/
|
|
6
|
+
export interface ContextMenuItem {
|
|
7
|
+
/** 菜单项文字 */
|
|
8
|
+
label: React.ReactNode;
|
|
9
|
+
/** 选中该项时触发(底层 `onSelect` → 我们的 `onClick`);有 `children` 的父项忽略此项 */
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
/** 危险操作(如删除):文字走 `--stitch-danger`、高亮态软底 `--stitch-danger-bg` */
|
|
12
|
+
danger?: boolean;
|
|
13
|
+
/** 禁用该项(不可选、灰显;键盘导航跳过——由底层保证) */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** 项前图标(必须是 `<Icon>` 支持的名,图标经 `<Icon>` 渲染、不接受裸 svg) */
|
|
16
|
+
icon?: IconName;
|
|
17
|
+
/** 子菜单项:非空 → 该项渲染为可展开的子菜单入口(底层 `Sub/SubTrigger/SubContent`) */
|
|
18
|
+
children?: ContextMenuItem[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 右键菜单(在目标区域右键弹出的一列动作):`children` 是右键目标区、`items` 是动作项数组,
|
|
22
|
+
* 点项**触发动作、无选中态**。`onOpenChange` 观察开合。
|
|
23
|
+
*
|
|
24
|
+
* 跨-prop 注意事项:
|
|
25
|
+
* - **vs DropdownMenu**:二者**同构**——同一列动作、同 `items` 项结构(`{ label, onClick?, danger?,
|
|
26
|
+
* disabled?, icon?, children? }`)、同 `menu/menuitem` 语义、同浮起面皮;**唯一区别是触发方式**:
|
|
27
|
+
* DropdownMenu 由按钮 click 触发(有 `trigger` prop、锚在按钮上),ContextMenu 由**右键 `children`
|
|
28
|
+
* 目标区**触发(无 `trigger`、锚在光标处)。当作同一心智,别学两套。
|
|
29
|
+
* - **items 数组 API**(跟库里 Select / Tabs / Accordion / DropdownMenu 一致):底层 `onSelect` 归一成
|
|
30
|
+
* `onClick`;`icon` 走 `<Icon>`(禁裸 svg);某项 `children` 非空即渲染成可展开的子菜单。
|
|
31
|
+
* - **面 = 浮起层**:菜单面走 `--stitch-bg-elevated` + `--stitch-text-primary`,边 `--stitch-border`、
|
|
32
|
+
* 圆角 `--stitch-radius-card`、阴影 `--stitch-shadow-base`;开合态 / 高亮态 / 禁用态由底层挂的
|
|
33
|
+
* `data-state` / `data-highlighted` / `data-disabled` 描,组件不自持显隐 state。
|
|
34
|
+
* - **键盘 / 焦点 / ARIA**(右键 / 长按开、方向键走项、Enter 选中、Esc 关、焦点归还、`role="menu"`)
|
|
35
|
+
* 由底层保证,组件不重复实现。
|
|
36
|
+
*/
|
|
37
|
+
export interface ContextMenuProps {
|
|
38
|
+
/** 右键目标区:在这块区域内右键(触屏长按)弹出菜单 */
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
/** 动作项数组(Ant v5 `items` 风格,与 DropdownMenu 同结构) */
|
|
41
|
+
items: ContextMenuItem[];
|
|
42
|
+
/** 显隐变化回调 */
|
|
43
|
+
onOpenChange?: (open: boolean) => void;
|
|
44
|
+
/** 自定义类名(挂到菜单面上) */
|
|
45
|
+
className?: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const ContextMenu: React.FC<ContextMenuProps>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
+
import t from "./context-menu.module.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import n from "clsx";
|
|
5
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { ContextMenu as o } from "radix-ui";
|
|
7
|
+
//#region packages/react/src/components/ContextMenu/ContextMenu.tsx
|
|
8
|
+
function s(c, l = "") {
|
|
9
|
+
return c.map((c, u) => {
|
|
10
|
+
let d = `${l}${u}`, f = /* @__PURE__ */ a(r, { children: [c.icon && /* @__PURE__ */ i(e, {
|
|
11
|
+
name: c.icon,
|
|
12
|
+
size: "1em",
|
|
13
|
+
className: t.itemIcon
|
|
14
|
+
}), /* @__PURE__ */ i("span", {
|
|
15
|
+
className: t.itemLabel,
|
|
16
|
+
children: c.label
|
|
17
|
+
})] });
|
|
18
|
+
return c.children && c.children.length > 0 ? /* @__PURE__ */ a(o.Sub, { children: [/* @__PURE__ */ a(o.SubTrigger, {
|
|
19
|
+
className: n(t.item, c.danger && t.danger),
|
|
20
|
+
disabled: c.disabled,
|
|
21
|
+
children: [f, /* @__PURE__ */ i(e, {
|
|
22
|
+
name: "chevron-right",
|
|
23
|
+
size: "1em",
|
|
24
|
+
className: t.subArrow
|
|
25
|
+
})]
|
|
26
|
+
}), /* @__PURE__ */ i(o.Portal, { children: /* @__PURE__ */ i(o.SubContent, {
|
|
27
|
+
className: t.content,
|
|
28
|
+
sideOffset: 8,
|
|
29
|
+
children: s(c.children, `${d}-`)
|
|
30
|
+
}) })] }, d) : /* @__PURE__ */ i(o.Item, {
|
|
31
|
+
className: n(t.item, c.danger && t.danger),
|
|
32
|
+
disabled: c.disabled,
|
|
33
|
+
onSelect: c.onClick,
|
|
34
|
+
children: f
|
|
35
|
+
}, d);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
var c = ({ children: e, items: r, onOpenChange: c, className: l }) => /* @__PURE__ */ a(o.Root, {
|
|
39
|
+
onOpenChange: c,
|
|
40
|
+
children: [/* @__PURE__ */ i(o.Trigger, {
|
|
41
|
+
asChild: !0,
|
|
42
|
+
children: e
|
|
43
|
+
}), /* @__PURE__ */ i(o.Portal, { children: /* @__PURE__ */ i(o.Content, {
|
|
44
|
+
className: n(t.content, l),
|
|
45
|
+
children: s(r)
|
|
46
|
+
}) })]
|
|
47
|
+
});
|
|
48
|
+
c.displayName = "ContextMenu";
|
|
49
|
+
//#endregion
|
|
50
|
+
export { c as ContextMenu };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region packages/react/src/components/ContextMenu/context-menu.module.less
|
|
2
|
+
var e = "_content_1or0o_1", t = "_item_1or0o_21", n = "_danger_1or0o_41", r = "_itemIcon_1or0o_48", i = "_itemLabel_1or0o_52", a = "_subArrow_1or0o_55", o = {
|
|
3
|
+
content: e,
|
|
4
|
+
"stitch-context-menu-in": "_stitch-context-menu-in_1or0o_1",
|
|
5
|
+
"stitch-context-menu-out": "_stitch-context-menu-out_1or0o_1",
|
|
6
|
+
item: t,
|
|
7
|
+
danger: n,
|
|
8
|
+
itemIcon: r,
|
|
9
|
+
itemLabel: i,
|
|
10
|
+
subArrow: a
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { e as content, n as danger, o as default, t as item, r as itemIcon, i as itemLabel, a as subArrow };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** 方向:水平(默认)/ 垂直(内联细线) */
|
|
3
|
+
export type DividerType = 'horizontal' | 'vertical';
|
|
4
|
+
/** 线型:实线 / 虚线(只留可 CSS 表达的两档) */
|
|
5
|
+
export type DividerVariant = 'solid' | 'dashed';
|
|
6
|
+
/** 带文字时文字位置(仅水平生效) */
|
|
7
|
+
export type DividerOrientation = 'left' | 'center' | 'right';
|
|
8
|
+
/**
|
|
9
|
+
* 分隔线(Ant `Divider` 语义):`type`(水平/垂直)+ `variant`(实线/虚线)+ `children` 文字
|
|
10
|
+
* 分隔线(`orientation` 左/中/右 + `plain` 常规字重)。非交互件,`role="separator"`。
|
|
11
|
+
*
|
|
12
|
+
* 跨-prop 注意事项:
|
|
13
|
+
* - **线色统一走 `--stitch-border`**:主题里 border 即「主结构分隔手段」,正是分隔线该用的角色;
|
|
14
|
+
* 线宽 `--stitch-border-width`,虚线由 `border-style: dashed` 表达(颜色仍是 border 角色)。
|
|
15
|
+
* - **文字分隔线(仅水平)**:`::before`/`::after` 两段 `border-top` 画线、文字居中夹在中间;
|
|
16
|
+
* `orientation=left/right` 调两段 width 占比。文字色 `--stitch-text-primary`、字重
|
|
17
|
+
* `--stitch-font-weight-medium`(`plain` → `-normal` + 小一档字号)。**垂直分隔线忽略
|
|
18
|
+
* `children`**(与 Ant 一致)。
|
|
19
|
+
* - **a11y**:根 `role="separator"`;垂直显式 `aria-orientation="vertical"`(水平用 ARIA 默认
|
|
20
|
+
* 方向,不标注);文字分隔线的文字即其可访问名。
|
|
21
|
+
*/
|
|
22
|
+
export interface DividerProps {
|
|
23
|
+
/**
|
|
24
|
+
* 方向:水平 / 垂直
|
|
25
|
+
* @default 'horizontal'
|
|
26
|
+
*/
|
|
27
|
+
type?: DividerType;
|
|
28
|
+
/**
|
|
29
|
+
* 线型:实线 / 虚线
|
|
30
|
+
* @default 'solid'
|
|
31
|
+
*/
|
|
32
|
+
variant?: DividerVariant;
|
|
33
|
+
/**
|
|
34
|
+
* 文字位置(仅水平且带文字时生效)
|
|
35
|
+
* @default 'center'
|
|
36
|
+
*/
|
|
37
|
+
orientation?: DividerOrientation;
|
|
38
|
+
/**
|
|
39
|
+
* 文字用常规字重(非加粗强调)
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
plain?: boolean;
|
|
43
|
+
/** 分隔线中间的文字内容(仅水平生效;垂直分隔线忽略) */
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
/** 自定义类名 */
|
|
46
|
+
className?: string;
|
|
47
|
+
/** 自定义样式 */
|
|
48
|
+
style?: React.CSSProperties;
|
|
49
|
+
}
|
|
50
|
+
export declare const Divider: React.FC<DividerProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import e from "./divider.module.js";
|
|
2
|
+
import { useId as t } from "react";
|
|
3
|
+
import n from "clsx";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
//#region packages/react/src/components/Divider/Divider.tsx
|
|
6
|
+
var i = ({ type: i = "horizontal", variant: a = "solid", orientation: o = "center", plain: s = !1, children: c, className: l, style: u }) => {
|
|
7
|
+
let d = i === "horizontal" && c != null && c !== !1, f = t(), p = n(e.divider, i === "vertical" ? e["divider-vertical"] : e["divider-horizontal"], a === "dashed" && e["divider-dashed"], d && e["divider-with-text"], d && e[`divider-${o}`], d && s && e["divider-plain"], l);
|
|
8
|
+
return /* @__PURE__ */ r("div", {
|
|
9
|
+
className: p,
|
|
10
|
+
style: u,
|
|
11
|
+
role: "separator",
|
|
12
|
+
"aria-orientation": i === "vertical" ? "vertical" : void 0,
|
|
13
|
+
"aria-labelledby": d ? f : void 0,
|
|
14
|
+
children: d && /* @__PURE__ */ r("span", {
|
|
15
|
+
id: f,
|
|
16
|
+
className: e["divider-text"],
|
|
17
|
+
children: c
|
|
18
|
+
})
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
i.displayName = "Divider";
|
|
22
|
+
//#endregion
|
|
23
|
+
export { i as Divider };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region packages/react/src/components/Divider/divider.module.less
|
|
2
|
+
var e = "_divider_13eyd_1", t = {
|
|
3
|
+
divider: e,
|
|
4
|
+
"divider-dashed": "_divider-dashed_13eyd_6",
|
|
5
|
+
"divider-horizontal": "_divider-horizontal_13eyd_9",
|
|
6
|
+
"divider-vertical": "_divider-vertical_13eyd_17",
|
|
7
|
+
"divider-with-text": "_divider-with-text_13eyd_24",
|
|
8
|
+
"divider-text": "_divider-text_13eyd_48",
|
|
9
|
+
"divider-left": "_divider-left_13eyd_52",
|
|
10
|
+
"divider-right": "_divider-right_13eyd_58",
|
|
11
|
+
"divider-plain": "_divider-plain_13eyd_64"
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { t as default, e as divider };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type DrawerPlacement = 'left' | 'right' | 'top' | 'bottom';
|
|
3
|
+
export interface DrawerProps {
|
|
4
|
+
/** 是否可见 */
|
|
5
|
+
open: boolean;
|
|
6
|
+
/** 标题 */
|
|
7
|
+
title?: React.ReactNode;
|
|
8
|
+
/** 弹出位置 @default 'right' */
|
|
9
|
+
placement?: DrawerPlacement;
|
|
10
|
+
/** 宽度(left / right 时生效) @default 378 */
|
|
11
|
+
width?: number | string;
|
|
12
|
+
/** 高度(top / bottom 时生效) @default 300 */
|
|
13
|
+
height?: number | string;
|
|
14
|
+
/**
|
|
15
|
+
* 点击遮罩是否关闭
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
maskClosable?: boolean;
|
|
19
|
+
/** 底部区域;不传则不渲染 */
|
|
20
|
+
footer?: React.ReactNode;
|
|
21
|
+
/** 关闭回调(遮罩 / Esc / 关闭按钮触发;Ant v5 Drawer 约定名 `onClose`) */
|
|
22
|
+
onClose?: () => void;
|
|
23
|
+
/** 抽屉内容 */
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
/** 自定义类名(挂到面板) */
|
|
26
|
+
className?: string;
|
|
27
|
+
/** 遮罩层自定义样式 */
|
|
28
|
+
maskStyle?: React.CSSProperties;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 抽屉浮层:Portal 挂到 body,遮罩 + 贴边滑入面板。
|
|
32
|
+
* 打开时把焦点送进抽屉并做 Tab 焦点陷阱,Esc / 点遮罩关闭,关闭时焦点归还触发元素(共享自 `useOverlay`)。
|
|
33
|
+
* `role="dialog"` + `aria-modal` + `aria-labelledby` 关联标题。
|
|
34
|
+
* 标准贴边浮层:几何随 `placement`、圆角/阴影/字体随站点。
|
|
35
|
+
*/
|
|
36
|
+
export declare const Drawer: React.FC<DrawerProps>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Icon as e } from "../Icon/Icon.js";
|
|
2
|
+
import { useOverlay as t } from "../_internal/useOverlay.js";
|
|
3
|
+
import n from "./drawer.module.js";
|
|
4
|
+
import { useCallback as r, useId as i, useRef as a } from "react";
|
|
5
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
6
|
+
import { createPortal as c } from "react-dom";
|
|
7
|
+
//#region packages/react/src/components/Drawer/Drawer.tsx
|
|
8
|
+
var l = {
|
|
9
|
+
left: n.panelLeft,
|
|
10
|
+
right: n.panelRight,
|
|
11
|
+
top: n.panelTop,
|
|
12
|
+
bottom: n.panelBottom
|
|
13
|
+
}, u = ({ open: u, title: d, placement: f = "right", width: p = 378, height: m = 300, maskClosable: h = !0, footer: g, onClose: _, children: v, className: y, maskStyle: b }) => {
|
|
14
|
+
let x = a(null);
|
|
15
|
+
t({
|
|
16
|
+
open: u,
|
|
17
|
+
containerRef: x,
|
|
18
|
+
onEscape: _
|
|
19
|
+
});
|
|
20
|
+
let S = r(() => {
|
|
21
|
+
h && _?.();
|
|
22
|
+
}, [h, _]), C = r((e) => {
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
}, []), w = `${`stitch-drawer-${i().replace(/:/g, "")}`}-title`;
|
|
25
|
+
if (!u) return null;
|
|
26
|
+
let T = f === "left" || f === "right" ? { width: p } : { height: m }, E = /* @__PURE__ */ o("div", {
|
|
27
|
+
className: n.mask,
|
|
28
|
+
style: b,
|
|
29
|
+
onClick: S,
|
|
30
|
+
children: /* @__PURE__ */ s("div", {
|
|
31
|
+
ref: x,
|
|
32
|
+
className: [
|
|
33
|
+
n.panel,
|
|
34
|
+
l[f],
|
|
35
|
+
y
|
|
36
|
+
].filter(Boolean).join(" "),
|
|
37
|
+
style: T,
|
|
38
|
+
onClick: C,
|
|
39
|
+
role: "dialog",
|
|
40
|
+
"aria-modal": "true",
|
|
41
|
+
"aria-labelledby": d ? w : void 0,
|
|
42
|
+
tabIndex: -1,
|
|
43
|
+
children: [
|
|
44
|
+
d && /* @__PURE__ */ s("div", {
|
|
45
|
+
className: n.header,
|
|
46
|
+
children: [/* @__PURE__ */ o("div", {
|
|
47
|
+
className: n.title,
|
|
48
|
+
id: w,
|
|
49
|
+
children: d
|
|
50
|
+
}), /* @__PURE__ */ o("button", {
|
|
51
|
+
type: "button",
|
|
52
|
+
className: n.close,
|
|
53
|
+
onClick: _,
|
|
54
|
+
"aria-label": "关闭",
|
|
55
|
+
children: /* @__PURE__ */ o(e, {
|
|
56
|
+
name: "close",
|
|
57
|
+
size: "1em"
|
|
58
|
+
})
|
|
59
|
+
})]
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ o("div", {
|
|
62
|
+
className: n.body,
|
|
63
|
+
children: v
|
|
64
|
+
}),
|
|
65
|
+
g && /* @__PURE__ */ o("div", {
|
|
66
|
+
className: n.footer,
|
|
67
|
+
children: g
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
return c(E, document.body);
|
|
73
|
+
};
|
|
74
|
+
u.displayName = "Drawer";
|
|
75
|
+
//#endregion
|
|
76
|
+
export { u as Drawer };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region packages/react/src/components/Drawer/drawer.module.less
|
|
2
|
+
var e = "_mask_16an3_1", t = "_panel_16an3_8", n = "_panelRight_16an3_25", r = "_panelLeft_16an3_33", i = "_panelTop_16an3_41", a = "_panelBottom_16an3_49", o = "_header_16an3_57", s = "_title_16an3_65", c = "_close_16an3_72", l = "_body_16an3_97", u = "_footer_16an3_105", d = {
|
|
3
|
+
mask: e,
|
|
4
|
+
"stitch-drawer-fade-in": "_stitch-drawer-fade-in_16an3_1",
|
|
5
|
+
panel: t,
|
|
6
|
+
panelRight: n,
|
|
7
|
+
"stitch-drawer-slide-right": "_stitch-drawer-slide-right_16an3_1",
|
|
8
|
+
panelLeft: r,
|
|
9
|
+
"stitch-drawer-slide-left": "_stitch-drawer-slide-left_16an3_1",
|
|
10
|
+
panelTop: i,
|
|
11
|
+
"stitch-drawer-slide-top": "_stitch-drawer-slide-top_16an3_1",
|
|
12
|
+
panelBottom: a,
|
|
13
|
+
"stitch-drawer-slide-bottom": "_stitch-drawer-slide-bottom_16an3_1",
|
|
14
|
+
header: o,
|
|
15
|
+
title: s,
|
|
16
|
+
close: c,
|
|
17
|
+
body: l,
|
|
18
|
+
footer: u
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { l as body, c as close, d as default, u as footer, o as header, e as mask, t as panel, a as panelBottom, r as panelLeft, n as panelRight, i as panelTop, s as title };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type IconName } from '../Icon';
|
|
3
|
+
/**
|
|
4
|
+
* 动作菜单里的一项。
|
|
5
|
+
*/
|
|
6
|
+
export interface DropdownMenuItem {
|
|
7
|
+
/** 菜单项文字 */
|
|
8
|
+
label: React.ReactNode;
|
|
9
|
+
/** 选中该项时触发(底层 `onSelect` → 我们的 `onClick`);有 `children` 的父项忽略此项 */
|
|
10
|
+
onClick?: () => void;
|
|
11
|
+
/** 危险操作(如删除):文字走 `--stitch-danger`、高亮态软底 `--stitch-danger-bg` */
|
|
12
|
+
danger?: boolean;
|
|
13
|
+
/** 禁用该项(不可选、灰显;键盘导航跳过——由底层保证) */
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
/** 项前图标(必须是 `<Icon>` 支持的名,图标经 `<Icon>` 渲染、不接受裸 svg) */
|
|
16
|
+
icon?: IconName;
|
|
17
|
+
/** 子菜单项:非空 → 该项渲染为可展开的子菜单入口(底层 `Sub/SubTrigger/SubContent`) */
|
|
18
|
+
children?: DropdownMenuItem[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 动作菜单(点按钮弹出的一列动作):`trigger` 触发按钮 + `items` 动作项数组,点项**触发动作、
|
|
22
|
+
* 无选中态**。受控 `open` / 非受控 `defaultOpen` / `onOpenChange`。内部把 `items` map 成底层
|
|
23
|
+
* 菜单项;某项 `children` 非空即渲染成可展开的子菜单。
|
|
24
|
+
*
|
|
25
|
+
* 跨-prop 注意事项:
|
|
26
|
+
* - **vs Select**:Select 是**选值**(`role="combobox/listbox"`、有受控 `value`、有选中态);
|
|
27
|
+
* DropdownMenu 是**触发动作**(`role="menu/menuitem"`、无 `value`、无选中态),点项调 `item.onClick`。
|
|
28
|
+
* - **vs ContextMenu**:同为一列动作,差在触发方式——DropdownMenu 由按钮 click 触发,ContextMenu 由右键触发。
|
|
29
|
+
* - **items 数组 API**(跟库里 Select / Tabs / Accordion 一致):`{ label, onClick?, danger?, disabled?,
|
|
30
|
+
* icon?, children? }`。底层 `onSelect` 归一成 `onClick`;`icon` 走 `<Icon>`(禁裸 svg)。
|
|
31
|
+
* - **面 = 浮起层**:菜单面走 `--stitch-bg-elevated` + `--stitch-text-primary`,边 `--stitch-border`、
|
|
32
|
+
* 圆角 `--stitch-radius-card`、阴影 `--stitch-shadow-base`;开合态 / 高亮态 / 禁用态由底层挂的
|
|
33
|
+
* `data-state` / `data-highlighted` / `data-disabled` 描,组件不自持显隐 state。
|
|
34
|
+
* - **键盘 / 焦点 / ARIA**(方向键走项、Enter 选中、Esc 关、焦点归还、`role="menu"`)由底层保证,
|
|
35
|
+
* 组件不重复实现;无可见标题时用 `aria-label` 给触发的可及名。
|
|
36
|
+
*/
|
|
37
|
+
export interface DropdownMenuProps {
|
|
38
|
+
/** 触发器:任意可承载 click 与焦点的元素(如 `<Button>`),菜单锚定其上 */
|
|
39
|
+
trigger: React.ReactNode;
|
|
40
|
+
/** 动作项数组(Ant v5 `items` 风格) */
|
|
41
|
+
items: DropdownMenuItem[];
|
|
42
|
+
/** 受控显隐 */
|
|
43
|
+
open?: boolean;
|
|
44
|
+
/** 非受控初始显隐 @default false */
|
|
45
|
+
defaultOpen?: boolean;
|
|
46
|
+
/** 显隐变化回调 */
|
|
47
|
+
onOpenChange?: (open: boolean) => void;
|
|
48
|
+
/** 触发器与菜单的间距(px) @default 8 */
|
|
49
|
+
sideOffset?: number;
|
|
50
|
+
/** 自定义类名(挂到菜单面上) */
|
|
51
|
+
className?: string;
|
|
52
|
+
/** 无可见标题时给触发器的无障碍标签 */
|
|
53
|
+
'aria-label'?: string;
|
|
54
|
+
}
|
|
55
|
+
export declare const DropdownMenu: React.FC<DropdownMenuProps>;
|