@dsh-workbench/shared 1.5.4-beta.2 → 1.5.5-beta.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/dist/api/workbench-client.d.ts +7 -0
- package/dist/components/card/Activity.d.ts +12 -12
- package/dist/components/card/Activity.js +0 -12
- package/dist/components/card/ApprovalDetail.d.ts +5 -5
- package/dist/components/card/ApprovalDetail.js +0 -5
- package/dist/components/card/ApprovalPlan.d.ts +4 -4
- package/dist/components/card/ApprovalPlan.js +0 -4
- package/dist/components/card/Card.d.ts +7 -6
- package/dist/components/card/Card.js +0 -6
- package/dist/components/card/CardAnchor.d.ts +2 -2
- package/dist/components/card/CardAnchor.js +0 -2
- package/dist/components/card/CardBoundary.d.ts +6 -6
- package/dist/components/card/CardBoundary.js +0 -6
- package/dist/components/card/CardHead.d.ts +11 -6
- package/dist/components/card/CardHead.js +0 -6
- package/dist/components/card/LongTaskRow.d.ts +20 -16
- package/dist/components/card/LongTaskRow.js +0 -16
- package/dist/components/card/board-module.d.ts +11 -2
- package/dist/components/feedback/EmptyIllustration.d.ts +1 -1
- package/dist/components/feedback/EmptyIllustration.js +0 -1
- package/dist/components/feedback/Note.d.ts +4 -4
- package/dist/components/feedback/Note.js +0 -4
- package/dist/components/feedback/ResourceStates.d.ts +22 -18
- package/dist/components/feedback/ResourceStates.js +0 -10
- package/dist/components/feedback/Spinner.d.ts +2 -2
- package/dist/components/feedback/Spinner.js +0 -2
- package/dist/components/feedback/StateBlock.d.ts +6 -6
- package/dist/components/feedback/StateBlock.js +0 -6
- package/dist/components/form/ChoiceGroup.d.ts +19 -10
- package/dist/components/form/ChoiceGroup.js +0 -8
- package/dist/components/form/ConfirmBar.d.ts +7 -7
- package/dist/components/form/ConfirmBar.js +0 -7
- package/dist/components/form/Field.d.ts +3 -3
- package/dist/components/form/Field.js +0 -3
- package/dist/components/form/Form.d.ts +0 -8
- package/dist/components/form/Form.js +0 -8
- package/dist/components/form/FormActions.d.ts +1 -1
- package/dist/components/form/FormActions.js +0 -1
- package/dist/components/form/FormRows.d.ts +7 -7
- package/dist/components/form/FormRows.js +0 -7
- package/dist/components/form/FormTypes.d.ts +8 -0
- package/dist/components/form/SaveBar.d.ts +5 -5
- package/dist/components/form/SaveBar.js +0 -5
- package/dist/components/form/SelectField.d.ts +42 -13
- package/dist/components/form/SelectField.js +0 -13
- package/dist/components/form/TextField.d.ts +1 -1
- package/dist/components/form/TextField.js +0 -1
- package/dist/components/layout/Link.d.ts +5 -5
- package/dist/components/layout/Link.js +0 -5
- package/dist/components/layout/Rows.d.ts +3 -3
- package/dist/components/layout/Rows.js +0 -3
- package/dist/components/layout/SettingsSection.d.ts +4 -4
- package/dist/components/layout/SettingsSection.js +0 -4
- package/dist/components/layout/SetupShell.d.ts +40 -5
- package/dist/components/layout/SetupShell.js +0 -5
- package/dist/components/layout/Stack.d.ts +1 -1
- package/dist/components/layout/Stack.js +0 -1
- package/dist/components/layout/icons.d.ts +1 -9
- package/dist/components/layout/icons.js +0 -9
- package/dist/contract/command.d.ts +2 -0
- package/dist/contract/data.d.ts +10 -0
- package/dist/contract/git.d.ts +4 -0
- package/dist/contract/lib.d.ts +2 -0
- package/dist/contract/module-context.d.ts +3 -0
- package/dist/contract/protocol/platform.d.ts +13 -0
- package/dist/host/adapters/toolbox-port.d.ts +0 -6
- package/dist/host/ai/port.d.ts +5 -0
- package/dist/host/ai/types.d.ts +12 -0
- package/dist/host/drafts/draft-store.d.ts +5 -0
- package/dist/host/runtime/workspace-store.d.ts +2 -0
- package/dist/host/seam/intent.d.ts +9 -0
- package/dist/host/seam/unit-seam.d.ts +2 -0
- package/dist/host/unit/host-kit.d.ts +8 -0
- package/dist/host/unit/long-task.d.ts +16 -0
- package/dist/host/unit/unit-face.d.ts +20 -0
- package/dist/host/unit/value-handoff.d.ts +3 -0
- package/package.json +1 -1
- package/src/api/workbench-client.ts +7 -0
- package/src/components/card/Activity.tsx +12 -12
- package/src/components/card/ApprovalDetail.tsx +5 -5
- package/src/components/card/ApprovalPlan.tsx +4 -4
- package/src/components/card/Card.tsx +7 -6
- package/src/components/card/CardAnchor.tsx +2 -2
- package/src/components/card/CardBoundary.tsx +6 -6
- package/src/components/card/CardHead.tsx +11 -6
- package/src/components/card/LongTaskRow.tsx +20 -16
- package/src/components/card/board-module.ts +11 -2
- package/src/components/feedback/EmptyIllustration.tsx +1 -1
- package/src/components/feedback/Note.tsx +4 -4
- package/src/components/feedback/ResourceStates.tsx +24 -16
- package/src/components/feedback/Spinner.tsx +2 -2
- package/src/components/feedback/StateBlock.tsx +6 -6
- package/src/components/form/ChoiceGroup.tsx +19 -9
- package/src/components/form/ConfirmBar.tsx +7 -7
- package/src/components/form/Field.tsx +3 -3
- package/src/components/form/Form.tsx +0 -8
- package/src/components/form/FormActions.tsx +1 -1
- package/src/components/form/FormRows.tsx +7 -7
- package/src/components/form/FormTypes.ts +8 -0
- package/src/components/form/SaveBar.tsx +5 -5
- package/src/components/form/SelectField.tsx +42 -13
- package/src/components/form/TextField.tsx +1 -1
- package/src/components/layout/Link.tsx +5 -5
- package/src/components/layout/Rows.tsx +3 -3
- package/src/components/layout/SettingsSection.tsx +4 -4
- package/src/components/layout/SetupShell.tsx +40 -5
- package/src/components/layout/Stack.tsx +1 -1
- package/src/components/layout/icons.tsx +1 -9
- package/src/contract/command.ts +2 -0
- package/src/contract/data.ts +10 -0
- package/src/contract/git.ts +4 -0
- package/src/contract/lib.ts +2 -0
- package/src/contract/module-context.ts +3 -0
- package/src/contract/protocol/platform.ts +13 -0
- package/src/host/adapters/toolbox-port.ts +0 -7
- package/src/host/ai/port.ts +5 -0
- package/src/host/ai/types.ts +12 -0
- package/src/host/drafts/draft-store.ts +5 -0
- package/src/host/runtime/workspace-store.ts +2 -0
- package/src/host/seam/intent.ts +9 -0
- package/src/host/seam/unit-seam.ts +2 -0
- package/src/host/unit/host-kit.ts +8 -0
- package/src/host/unit/long-task.ts +16 -0
- package/src/host/unit/unit-face.ts +20 -0
- package/src/host/unit/value-handoff.ts +3 -0
|
@@ -3,12 +3,17 @@ import { h } from '../../lib/react.js';
|
|
|
3
3
|
import { EmptyIllustration } from './EmptyIllustration.js';
|
|
4
4
|
import './ResourceStates.css';
|
|
5
5
|
|
|
6
|
+
/** 骨架屏的约定:只差行数。 */
|
|
7
|
+
export interface SkeletonRowsProps {
|
|
8
|
+
/** 画几行骨架(默认 4);整块 `aria-hidden`,不读给读屏。 */
|
|
9
|
+
readonly rows?: number | undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
/**
|
|
7
13
|
* 骨架屏:读数期间已经知道大概形状时用它(连形状都不知道就用 `CenteredState` 那句"正在读")。
|
|
8
|
-
* @param props.rows - 画几行骨架(默认 4);整块 `aria-hidden`,不读给读屏。
|
|
9
14
|
* @returns 一叠占位条。
|
|
10
15
|
*/
|
|
11
|
-
export function SkeletonRows({ rows = 4 }:
|
|
16
|
+
export function SkeletonRows({ rows = 4 }: SkeletonRowsProps) {
|
|
12
17
|
return (
|
|
13
18
|
<div className="wb-skeleton" aria-hidden="true">
|
|
14
19
|
{Array.from({ length: rows }, (_, index) => (
|
|
@@ -25,22 +30,22 @@ export function SkeletonRows({ rows = 4 }: { rows?: number }) {
|
|
|
25
30
|
* `CenteredState` 的契约:图标、标题、说明、明细与动作。
|
|
26
31
|
*/
|
|
27
32
|
export interface CenteredStateProps {
|
|
33
|
+
/** 标题上方那枚图标;给 `null` 就只留标题(加载与报错常见)。 */
|
|
28
34
|
icon: ReactNode;
|
|
35
|
+
/** 正中那行大字。 */
|
|
29
36
|
title: ReactNode;
|
|
37
|
+
/** 标题下的一行说明。 */
|
|
30
38
|
hint?: string;
|
|
39
|
+
/** 更细的一行(如原始错误码与那句话);"读不到"时把错误放这里,绝不显示 0。 */
|
|
31
40
|
detail?: string;
|
|
41
|
+
/** 底部动作(如"重试");不给不画。 */
|
|
32
42
|
action?: ReactNode;
|
|
43
|
+
/** 紧凑档(默认 false),卡里空间小的时候给 true。 */
|
|
33
44
|
compact?: boolean;
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
/**
|
|
37
48
|
* 居中一屏:要他先选一个 / 正在读 / 读不到时用它占住卡片版面。
|
|
38
|
-
* @param props.icon - 标题上方那枚图标;给 `null` 就只留标题(加载与报错常见)。
|
|
39
|
-
* @param props.title - 正中那行大字。
|
|
40
|
-
* @param props.hint - 标题下的一行说明。
|
|
41
|
-
* @param props.detail - 更细的一行(如原始错误码与那句话);"读不到"时把错误放这里,绝不显示 0。
|
|
42
|
-
* @param props.action - 底部动作(如"重试");不给不画。
|
|
43
|
-
* @param props.compact - 紧凑档(默认 false),卡里空间小的时候给 true。
|
|
44
49
|
* @returns 一个 `role="status"` 的居中块。
|
|
45
50
|
*/
|
|
46
51
|
export function CenteredState({ icon, title, hint, detail, action, compact = false }: CenteredStateProps) {
|
|
@@ -59,21 +64,24 @@ export function CenteredState({ icon, title, hint, detail, action, compact = fal
|
|
|
59
64
|
);
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
/** 空态的约定:一句话 + 图标 + 紧凑档。 */
|
|
68
|
+
export interface EmptyStateProps {
|
|
69
|
+
/** 空态那句话。 */
|
|
70
|
+
readonly text: string;
|
|
71
|
+
/** 标题上方的图标;不给就用空态插画,要纯文字给 `null`。 */
|
|
72
|
+
readonly icon?: ReactNode | undefined;
|
|
73
|
+
/** 紧凑档,默认 false。 */
|
|
74
|
+
readonly compact?: boolean | undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
62
77
|
/**
|
|
63
78
|
* 就绪但空:它只是 `CenteredState` 的简写,标题就是那句空态文案。
|
|
64
|
-
* @param props.text - 空态那句话。
|
|
65
|
-
* @param props.icon - 标题上方的图标;不给就用空态插画,要纯文字给 `null`。
|
|
66
|
-
* @param props.compact - 紧凑档,默认 false。
|
|
67
79
|
* @returns 一个居中块。
|
|
68
80
|
*/
|
|
69
81
|
export function EmptyState({
|
|
70
82
|
text,
|
|
71
83
|
icon = h(EmptyIllustration, { size: 72 }),
|
|
72
84
|
compact = false,
|
|
73
|
-
}: {
|
|
74
|
-
text: string;
|
|
75
|
-
icon?: ReactNode;
|
|
76
|
-
compact?: boolean;
|
|
77
|
-
}) {
|
|
85
|
+
}: EmptyStateProps) {
|
|
78
86
|
return <CenteredState icon={icon} title={text} compact={compact} />;
|
|
79
87
|
}
|
|
@@ -6,14 +6,14 @@ import './Spinner.css';
|
|
|
6
6
|
* `Spinner` 的契约:直径像素与可选的读屏标签。
|
|
7
7
|
*/
|
|
8
8
|
export interface SpinnerProps {
|
|
9
|
+
/** 直径像素(默认 14,与 dsh 紧凑控件同高)。 */
|
|
9
10
|
readonly size?: number;
|
|
11
|
+
/** 给了才读屏可见(`role="status"`);不给整颗 `aria-hidden`,此时旁边必须有文字。 */
|
|
10
12
|
readonly label?: string | undefined;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* 转圈:加载态一律用它(`FormActions` 与 `ChoiceGroup` 内部也是它),别自己写动画。
|
|
15
|
-
* @param props.size - 直径像素(默认 14,与 dsh 紧凑控件同高)。
|
|
16
|
-
* @param props.label - 给了才读屏可见(`role="status"`);不给整颗 `aria-hidden`,此时旁边必须有文字。
|
|
17
17
|
* @returns 一枚 `StateDot state="ongoing"`,自身不带文字。
|
|
18
18
|
*/
|
|
19
19
|
export function Spinner({ size = 14, label }: SpinnerProps) {
|
|
@@ -6,22 +6,22 @@ import './StateBlock.css';
|
|
|
6
6
|
* `StateBlock` 的契约:标题、状态点、提示、正文与行尾动作。
|
|
7
7
|
*/
|
|
8
8
|
export interface StateBlockProps {
|
|
9
|
+
/** 标题那行;它与 `dot` 都不给时整行不画。 */
|
|
9
10
|
readonly title?: ReactNode | undefined;
|
|
11
|
+
/** 标题前那枚状态点。 */
|
|
10
12
|
readonly dot?: ReactNode | undefined;
|
|
13
|
+
/** 标题下那行小字(如"3 条 · 刚刚");不给不画。 */
|
|
11
14
|
readonly hint?: ReactNode | undefined;
|
|
15
|
+
/** 底部动作区;给了才画那一条。 */
|
|
12
16
|
readonly actions?: ReactNode | undefined;
|
|
17
|
+
/** "正在读"那行,读数期间挂上去;不给不画。 */
|
|
13
18
|
readonly resolving?: ReactNode | undefined;
|
|
19
|
+
/** 正文。 */
|
|
14
20
|
readonly children?: ReactNode | undefined;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
/**
|
|
18
24
|
* 有内容那一段:一个标题 + 一行提示 + 正文,卡里已经读到东西时用它开头。
|
|
19
|
-
* @param props.title - 标题那行;它与 `dot` 都不给时整行不画。
|
|
20
|
-
* @param props.dot - 标题前那枚状态点。
|
|
21
|
-
* @param props.hint - 标题下那行小字(如"3 条 · 刚刚");不给不画。
|
|
22
|
-
* @param props.resolving - "正在读"那行,读数期间挂上去;不给不画。
|
|
23
|
-
* @param props.actions - 底部动作区;给了才画那一条。
|
|
24
|
-
* @param props.children - 正文。
|
|
25
25
|
* @returns 一个 div。
|
|
26
26
|
*/
|
|
27
27
|
export function StateBlock({ title, dot, hint, actions, resolving, children }: StateBlockProps) {
|
|
@@ -8,19 +8,31 @@ import './ChoiceGroup.css';
|
|
|
8
8
|
* 一个候选项:值、人看的标签,可带一行说明。
|
|
9
9
|
*/
|
|
10
10
|
export interface ChoiceGroupOption {
|
|
11
|
+
/** 给 `onChange` 的值。 */
|
|
11
12
|
readonly value: string;
|
|
13
|
+
/** 人看的标签。 */
|
|
12
14
|
readonly label: ReactNode;
|
|
15
|
+
/** 候选下面那行说明;不给不画。 */
|
|
13
16
|
readonly description?: ReactNode | undefined;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
/** 单选 / 多选共用的字段:组名、候选、禁用、样式、加载与空态。 */
|
|
20
|
+
export interface ChoiceGroupCommon {
|
|
21
|
+
/** 只给读屏的组名(`aria-label`)。 */
|
|
17
22
|
readonly label: string;
|
|
23
|
+
/** 这一组 `input` 的共用 name。 */
|
|
18
24
|
readonly name: string;
|
|
25
|
+
/** 候选项,按给的顺序排;空数组时画 `emptyText`(没给就什么都不画)。 */
|
|
19
26
|
readonly options: readonly ChoiceGroupOption[];
|
|
27
|
+
/** 禁掉整组(默认 false),不是单颗。 */
|
|
20
28
|
readonly disabled?: boolean | undefined;
|
|
29
|
+
/** `boxed`(默认,带边框的选项格)或 `ghost`(无边框,跟着父容器走)。 */
|
|
21
30
|
readonly variant?: 'boxed' | 'ghost' | undefined;
|
|
31
|
+
/** 正在读候选:整组换成转圈,文案取 `loadingText`;默认 false。 */
|
|
22
32
|
readonly loading?: boolean | undefined;
|
|
33
|
+
/** 转圈时那句文案;不给是 `…`。 */
|
|
23
34
|
readonly loadingText?: ReactNode | undefined;
|
|
35
|
+
/** 读到了但一个候选都没有时那句话;不给不画。 */
|
|
24
36
|
readonly emptyText?: ReactNode | undefined;
|
|
25
37
|
}
|
|
26
38
|
|
|
@@ -28,8 +40,11 @@ interface ChoiceGroupCommon {
|
|
|
28
40
|
* 单选那一支的契约:`value` + `onChange(next)`;`multi` 不给或给 false。
|
|
29
41
|
*/
|
|
30
42
|
export interface ChoiceGroupSingleProps extends ChoiceGroupCommon {
|
|
43
|
+
/** 单选这一支:不给或 false。 */
|
|
31
44
|
readonly multi?: false | undefined;
|
|
45
|
+
/** 当前选中的值。 */
|
|
32
46
|
readonly value: string;
|
|
47
|
+
/** 选了某一项:回它的 `value`。 */
|
|
33
48
|
readonly onChange: (next: string) => void;
|
|
34
49
|
}
|
|
35
50
|
|
|
@@ -37,8 +52,11 @@ export interface ChoiceGroupSingleProps extends ChoiceGroupCommon {
|
|
|
37
52
|
* 多选那一支的契约:`multi: true` + `values` + `onChange(next[])`。
|
|
38
53
|
*/
|
|
39
54
|
export interface ChoiceGroupMultiProps extends ChoiceGroupCommon {
|
|
55
|
+
/** true 走多选那支。 */
|
|
40
56
|
readonly multi: true;
|
|
57
|
+
/** 当前选中的一组 value。 */
|
|
41
58
|
readonly values: readonly string[];
|
|
59
|
+
/** 选了一组:回一组 value。 */
|
|
42
60
|
readonly onChange: (next: readonly string[]) => void;
|
|
43
61
|
}
|
|
44
62
|
|
|
@@ -124,14 +142,6 @@ function ChoiceMenu(input: {
|
|
|
124
142
|
|
|
125
143
|
/**
|
|
126
144
|
* 一组单选或多选:候选少、要一眼看全时用它;候选多或要搜索就用 `SelectField`。
|
|
127
|
-
* @param props.multi - true 走多选那支(`values` / `onChange(string[])`);默认单选(`value` / `onChange(string)`)。
|
|
128
|
-
* @param props.label - 只给读屏的组名(`aria-label`)。
|
|
129
|
-
* @param props.name - 这一组 `input` 的共用 name。
|
|
130
|
-
* @param props.options - 候选项,按给的顺序排;空数组时画 `emptyText`(没给就什么都不画)。
|
|
131
|
-
* @param props.disabled - 禁掉整组(默认 false),不是单颗。
|
|
132
|
-
* @param props.variant - `boxed`(默认,带边框的选项格)或 `ghost`(无边框,跟着父容器走)。
|
|
133
|
-
* @param props.loading - 正在读候选:整组换成转圈,文案取 `loadingText`(不给是 `…`);默认 false。
|
|
134
|
-
* @param props.emptyText - 读到了但一个候选都没有时那句话;不给不画。
|
|
135
145
|
* @returns 一组 `radio` / `checkbox` 选项。
|
|
136
146
|
*/
|
|
137
147
|
export function ChoiceGroup(props: ChoiceGroupProps) {
|
|
@@ -18,25 +18,25 @@ export interface ConfirmRow {
|
|
|
18
18
|
* `ConfirmBar` 的契约:标题、说明、键值、失败那句与动作。
|
|
19
19
|
*/
|
|
20
20
|
export interface ConfirmBarProps {
|
|
21
|
+
/** 那一句问话("发布到 prod?")。 */
|
|
21
22
|
readonly title: ReactNode;
|
|
23
|
+
/** 标题下面那句说明或正文;不给不占位。 */
|
|
22
24
|
readonly hint?: ReactNode | undefined;
|
|
25
|
+
/** 键值两格(键值列宽与分隔线归 `Rows` / `Row`);不给或空数组不渲染。值那一格可以放控件。 */
|
|
23
26
|
readonly rows?: readonly ConfirmRow[] | undefined;
|
|
27
|
+
/** 动作清单(归 `FormActions`:一个区一颗 `primary`、永远在右、窄了折行)。 */
|
|
24
28
|
readonly actions: readonly FormAction[];
|
|
29
|
+
/** 失败那句(走 `Note tone="problem"`,读屏是 `alert`);不给不占位。 */
|
|
25
30
|
readonly problem?: ReactNode | undefined;
|
|
31
|
+
/** 整条在忙(只喂 `aria-busy`;按钮自己的转圈与禁用归 `actions` 里那一颗)。 */
|
|
26
32
|
readonly busy?: boolean | undefined;
|
|
33
|
+
/** 读屏的组名;不给时 `title` 是字符串就拿它顶上,两者都没有就不设。 */
|
|
27
34
|
readonly label?: string | undefined;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
/**
|
|
31
38
|
* 「先问一句再动手」那一条:标题 + 说明 + 键值 + 失败那句 + 动作区,形状一次收口。
|
|
32
39
|
* **要不要问**归调用点,这一件只回答"问的时候长什么样"。
|
|
33
|
-
* @param props.title - 那一句问话("发布到 prod?")。
|
|
34
|
-
* @param props.hint - 标题下面那句说明或正文;不给不占位。
|
|
35
|
-
* @param props.rows - 键值两格(键值列宽与分隔线归 `Rows` / `Row`);不给或空数组不渲染。值那一格可以放控件。
|
|
36
|
-
* @param props.actions - 动作清单(归 `FormActions`:一个区一颗 `primary`、永远在右、窄了折行)。
|
|
37
|
-
* @param props.problem - 失败那句(走 `Note tone="problem"`,读屏是 `alert`);不给不占位。
|
|
38
|
-
* @param props.busy - 整条在忙(只喂 `aria-busy`;按钮自己的转圈与禁用归 `actions` 里那一颗)。
|
|
39
|
-
* @param props.label - 读屏的组名;不给时 `title` 是字符串就拿它顶上,两者都没有就不设。
|
|
40
40
|
* @returns 一个 `role="group"` 的条;`actions` 空数组时最后那一块不渲染。
|
|
41
41
|
*/
|
|
42
42
|
export function ConfirmBar({ title, hint, rows, actions, problem, busy, label }: ConfirmBarProps) {
|
|
@@ -6,16 +6,16 @@ import './Field.css';
|
|
|
6
6
|
* `Field` 的契约:一行"标签 + 控件 + 说明"的排布。
|
|
7
7
|
*/
|
|
8
8
|
export interface FieldProps {
|
|
9
|
+
/** 左侧标签,必给。 */
|
|
9
10
|
readonly label: ReactNode;
|
|
11
|
+
/** 控件下面那行说明;不给不画。 */
|
|
10
12
|
readonly hint?: ReactNode | undefined;
|
|
13
|
+
/** 控件本体,落在标签与说明之间。 */
|
|
11
14
|
readonly children?: ReactNode | undefined;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* 标签 + 控件的排布:没进 `FormRow` 时用它兜住一个字段的标签与说明。
|
|
16
|
-
* @param props.label - 左侧标签,必给。
|
|
17
|
-
* @param props.hint - 控件下面那行说明;不给不画。
|
|
18
|
-
* @param props.children - 控件本体,落在标签与说明之间。
|
|
19
19
|
* @returns 一个 `<label>`,点标签会聚焦里面的控件。
|
|
20
20
|
*/
|
|
21
21
|
export function Field({ label, hint, children }: FieldProps) {
|
|
@@ -23,14 +23,6 @@ import './Form.css';
|
|
|
23
23
|
* 提交那一拍永远先算一遍:有错就不调 `onSubmit`,并把第一个有错的 `FormRow` 带进视口、聚焦它里面的控件。
|
|
24
24
|
* 回车与点提交钮走的是同一条路:真 `<form>` 的隐式提交在**只有一个文本框**时也会 fire,所以 `busy` / `disabled` 时回车同样不提交。
|
|
25
25
|
* 调用点只管数据与语义:行怎么排、错误摆哪、什么时候校验、按钮在哪,这里没有口子。
|
|
26
|
-
* @param props.fields - 每格的键 / 标签 / 值 / 值怎么改(`onChange`)/ 校验 / 控件;`visible: false` 的那格当它不存在(不渲染、不校验、不进 `values`)。
|
|
27
|
-
* @param props.onSubmit - 校验全过的那一拍,回的是从 `fields` 现取的键值表(按 `visibleFieldsOf` 过滤过,不可见那格不在里面);被挡住时不会被调。
|
|
28
|
-
* @param props.submit - 提交钮文案;`busyLabel` 是提交中换的那句,不给就沿用 `label`。
|
|
29
|
-
* @param props.cancel - 取消钮;给了就排在提交钮左边,`busy` 时一起禁用。
|
|
30
|
-
* @param props.extra - 其余动作(default / danger),排在最左,`busy` 时一起禁用。
|
|
31
|
-
* @param props.busy - 提交中(默认 false):整表控件的绑定 `disabled` 为真,所有动作一起禁用,回车也不提交。
|
|
32
|
-
* @param props.disabled - 只再禁提交钮(如没改动可存),各格控件与其余动作不受影响,回车也不提交。
|
|
33
|
-
* @param props.problem - 整表级那句错(提交失败),落在行与操作区之间;不给就不画。
|
|
34
26
|
* @returns 一个 `<form>`(`noValidate`:报错形状归 `FormRow`,不走浏览器的气泡)。
|
|
35
27
|
*/
|
|
36
28
|
export function Form<Values extends object = FormValues>(props: FormProps<Values>) {
|
|
@@ -25,6 +25,7 @@ export interface FormAction {
|
|
|
25
25
|
* `FormActions` 的契约:一组动作。
|
|
26
26
|
*/
|
|
27
27
|
export interface FormActionsProps {
|
|
28
|
+
/** 动作清单;调用点给的顺序只在同语气内部生效,空数组时整块不渲染。 */
|
|
28
29
|
readonly actions: readonly FormAction[];
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -58,7 +59,6 @@ function variantOf(kind: FormActionKind): 'ghost' | 'outline' | 'primary' {
|
|
|
58
59
|
|
|
59
60
|
/**
|
|
60
61
|
* 操作区:把一组动作按"primary 永远在右、danger 紧挨它左侧"排好,窄了自动折行。
|
|
61
|
-
* @param props.actions - 动作清单;调用点给的顺序只在同语气内部生效,空数组时整块不渲染。
|
|
62
62
|
* @returns 一排按钮,或 `null`(没有动作时)。
|
|
63
63
|
*/
|
|
64
64
|
export function FormActions({ actions }: FormActionsProps) {
|
|
@@ -6,12 +6,12 @@ import './FormRows.css';
|
|
|
6
6
|
* `FormRows` 的契约:一列 `FormRow` 的容器。
|
|
7
7
|
*/
|
|
8
8
|
export interface FormRowsProps {
|
|
9
|
+
/** 一串 `FormRow`;非行的孩子(如分组标题)自动通栏。 */
|
|
9
10
|
readonly children?: ReactNode | undefined;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* 表单行的容器:同一份 `FormRows` 共用一个标签列(列宽由最长的标签定),行距也归它。
|
|
14
|
-
* @param props.children - 一串 `FormRow`;非行的孩子(如分组标题)自动通栏。
|
|
15
15
|
* @returns 竖排的 div。
|
|
16
16
|
*/
|
|
17
17
|
export function FormRows({ children }: FormRowsProps) {
|
|
@@ -22,22 +22,22 @@ export function FormRows({ children }: FormRowsProps) {
|
|
|
22
22
|
* `FormRow` 的契约:标签、提示、错误与控件的排布。
|
|
23
23
|
*/
|
|
24
24
|
export interface FormRowProps {
|
|
25
|
+
/** 这一行的标签;进了这一行,控件自己就别再给 `label`,否则会多一个标签。 */
|
|
25
26
|
readonly label: ReactNode;
|
|
27
|
+
/** 标签挂到哪个控件(同一个 `id`);不给就只是排布,点标签不聚焦 —— `Form` 会自己接好。 */
|
|
26
28
|
readonly htmlFor?: string | undefined;
|
|
29
|
+
/** 控件下的说明;给了 `problem` 就不画它 —— 同一格不叠两段话。 */
|
|
27
30
|
readonly hint?: ReactNode | undefined;
|
|
31
|
+
/** 校验失败那句话;给了就顶掉 `hint` 并给整行加上出错标记。 */
|
|
28
32
|
readonly problem?: ReactNode | undefined;
|
|
33
|
+
/** `stacked` 才是标签在上、控件在下(默认 `inline`:标签在左)。 */
|
|
29
34
|
readonly layout?: 'inline' | 'stacked' | undefined;
|
|
35
|
+
/** 控件本体。 */
|
|
30
36
|
readonly children?: ReactNode | undefined;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
39
|
/**
|
|
34
40
|
* 表单一行:左边标签、右边控件,提示与错误占控件下面那一格。
|
|
35
|
-
* @param props.label - 这一行的标签;进了这一行,控件自己就别再给 `label`,否则会多一个标签。
|
|
36
|
-
* @param props.htmlFor - 标签挂到哪个控件(同一个 `id`);不给就只是排布,点标签不聚焦 —— `Form` 会自己接好。
|
|
37
|
-
* @param props.hint - 控件下的说明;给了 `problem` 就不画它 —— 同一格不叠两段话。
|
|
38
|
-
* @param props.problem - 校验失败那句话;给了就顶掉 `hint` 并给整行加上出错标记。
|
|
39
|
-
* @param props.layout - `stacked` 才是标签在上、控件在下(默认 `inline`:标签在左)。
|
|
40
|
-
* @param props.children - 控件本体。
|
|
41
41
|
* @returns 一个 `<div>`:里面的 `<label>` 只包标签文字,不包控件、提示与整行的空白。
|
|
42
42
|
*/
|
|
43
43
|
export function FormRow({ label, htmlFor, hint, problem, layout = 'inline', children }: FormRowProps) {
|
|
@@ -85,12 +85,20 @@ export interface FormCancel {
|
|
|
85
85
|
* 可选键让"它可能不在表里"这件事在类型上也成立;永远可见的键照常必填。
|
|
86
86
|
*/
|
|
87
87
|
export interface FormProps<Values extends object = FormValues> {
|
|
88
|
+
/** 每格的键 / 标签 / 值 / 值怎么改(`onChange`)/ 校验 / 控件;`visible: false` 的那格当它不存在(不渲染、不校验、不进 `values`)。 */
|
|
88
89
|
readonly fields: readonly FormFieldOf<Values>[];
|
|
90
|
+
/** 校验全过的那一拍,回的是从 `fields` 现取的键值表(按 `visibleFieldsOf` 过滤过,不可见那格不在里面);被挡住时不会被调。 */
|
|
89
91
|
readonly onSubmit: (values: Readonly<Values>) => void;
|
|
92
|
+
/** 提交钮文案;`busyLabel` 是提交中换的那句,不给就沿用 `label`。 */
|
|
90
93
|
readonly submit: FormSubmit;
|
|
94
|
+
/** 取消钮;给了就排在提交钮左边,`busy` 时一起禁用。 */
|
|
91
95
|
readonly cancel?: FormCancel | undefined;
|
|
96
|
+
/** 其余动作(default / danger),排在最左,`busy` 时一起禁用。 */
|
|
92
97
|
readonly extra?: readonly FormAction[] | undefined;
|
|
98
|
+
/** 提交中(默认 false):整表控件的绑定 `disabled` 为真,所有动作一起禁用,回车也不提交。 */
|
|
93
99
|
readonly busy?: boolean | undefined;
|
|
100
|
+
/** 只再禁提交钮(如没改动可存),各格控件与其余动作不受影响,回车也不提交。 */
|
|
94
101
|
readonly disabled?: boolean | undefined;
|
|
102
|
+
/** 整表级那句错(提交失败),落在行与操作区之间;不给就不画。 */
|
|
95
103
|
readonly problem?: ReactNode | undefined;
|
|
96
104
|
}
|
|
@@ -6,24 +6,24 @@ import { FormActions } from './FormActions.js';
|
|
|
6
6
|
* `SaveBar` 的契约:忙碌态、三句文案与两个回调。
|
|
7
7
|
*/
|
|
8
8
|
export interface SaveBarProps {
|
|
9
|
+
/** 保存中:两颗钮一起禁用,保存那颗换成 `saving` 文案并带转圈。 */
|
|
9
10
|
readonly busy: boolean;
|
|
11
|
+
/** 再额外禁掉保存钮(如没改动可存);默认不禁,取消钮不受它管。 */
|
|
10
12
|
readonly disabled?: boolean | undefined;
|
|
13
|
+
/** 三句文案:`cancel` / `save` / `saving`。 */
|
|
11
14
|
readonly labels: {
|
|
12
15
|
readonly cancel: string;
|
|
13
16
|
readonly save: string;
|
|
14
17
|
readonly saving: string;
|
|
15
18
|
};
|
|
19
|
+
/** 点取消。 */
|
|
16
20
|
readonly onCancel: () => void;
|
|
21
|
+
/** 点保存。 */
|
|
17
22
|
readonly onSave: () => void;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
/**
|
|
21
26
|
* 设置面底下那条"取消 / 保存":就是 `FormActions` 的两颗固定动作,顺序与间距不归调用点。
|
|
22
|
-
* @param props.busy - 保存中:两颗钮一起禁用,保存那颗换成 `saving` 文案并带转圈。
|
|
23
|
-
* @param props.disabled - 再额外禁掉保存钮(如没改动可存);默认不禁,取消钮不受它管。
|
|
24
|
-
* @param props.labels - 三句文案:`cancel` / `save` / `saving`。
|
|
25
|
-
* @param props.onCancel - 点取消。
|
|
26
|
-
* @param props.onSave - 点保存。
|
|
27
27
|
* @returns 一组按钮。
|
|
28
28
|
*/
|
|
29
29
|
export function SaveBar({ busy, disabled, labels, onCancel, onSave }: SaveBarProps) {
|
|
@@ -10,11 +10,17 @@ import './SelectField.css';
|
|
|
10
10
|
|
|
11
11
|
/** 一个候选项:值、人看的标签,可带搜索词、图标、分组与禁用标记。 */
|
|
12
12
|
export interface SelectFieldOption {
|
|
13
|
+
/** 给 `onChange` 的值。 */
|
|
13
14
|
readonly value: string;
|
|
15
|
+
/** 人看的标签。 */
|
|
14
16
|
readonly label: ReactNode;
|
|
17
|
+
/** 搜它时用的文本(标签之外的可搜词);不给搜 `label`。 */
|
|
15
18
|
readonly searchText?: string | undefined;
|
|
19
|
+
/** 触发器左侧那枚图标。 */
|
|
16
20
|
readonly icon?: ReactNode | undefined;
|
|
21
|
+
/** 分组标题;同组连续排(怎么排归菜单)。 */
|
|
17
22
|
readonly group?: string | undefined;
|
|
23
|
+
/** 禁用整颗;默认 false。 */
|
|
18
24
|
readonly disabled?: boolean | undefined;
|
|
19
25
|
}
|
|
20
26
|
|
|
@@ -26,45 +32,81 @@ export interface SelectFieldFallback {
|
|
|
26
32
|
|
|
27
33
|
/** 列表底部固定那一条(如"添加工作区"):文案 + 可选图标。 */
|
|
28
34
|
export interface SelectFieldFooter {
|
|
35
|
+
/** 底部那一条的文案。 */
|
|
29
36
|
readonly label: ReactNode;
|
|
37
|
+
/** 底部那一条左侧的图标。 */
|
|
30
38
|
readonly icon?: ReactNode | undefined;
|
|
31
39
|
}
|
|
32
40
|
|
|
33
41
|
/** `SelectField` 的契约:值、候选、变更回调,外加搜索 / 分组 / 加载 / 空态 / 页脚那一整套开关。 */
|
|
34
42
|
export interface SelectFieldProps {
|
|
43
|
+
/** 当前值;在 `options` 里找不到就按"没选"画 `placeholder`。 */
|
|
35
44
|
readonly value: string;
|
|
45
|
+
/** 全量候选;空数组且给了 `fallback` 时改画手填输入框。 */
|
|
36
46
|
readonly options: readonly SelectFieldOption[];
|
|
47
|
+
/** 选中一项后的回调,回的是那一项的 `value`。 */
|
|
37
48
|
readonly onChange: (value: string) => void;
|
|
49
|
+
/** 没进 `FormRow` 时的标签回退;进了那一行就别再给它和 `hint`,否则会多一个标签。 */
|
|
38
50
|
readonly label?: ReactNode | undefined;
|
|
51
|
+
/** 控件下面那行说明;进了 `FormRow` 就别再给,否则会多一行。 */
|
|
39
52
|
readonly hint?: ReactNode | undefined;
|
|
53
|
+
/** 触发器左侧那枚图标。 */
|
|
40
54
|
readonly icon?: ReactNode | undefined;
|
|
55
|
+
/** 自己渲染触发器上那份当前值;不给就用候选项的 `label`。 */
|
|
41
56
|
readonly renderValue?: ((current: SelectFieldOption | undefined) => ReactNode) | undefined;
|
|
57
|
+
/** 没选中时那句话;不给是 `—`。 */
|
|
42
58
|
readonly placeholder?: ReactNode | undefined;
|
|
59
|
+
/** 是否可搜(默认 true);`false` 时不画搜索框、也不自动聚焦。 */
|
|
43
60
|
readonly search?: boolean | undefined;
|
|
61
|
+
/** 搜索框的读屏名;不给用默认。 */
|
|
44
62
|
readonly searchLabel?: string | undefined;
|
|
63
|
+
/** 搜索框的占位文案;不给用默认。 */
|
|
45
64
|
readonly searchPlaceholder?: string | undefined;
|
|
65
|
+
/** 自定义匹配;不给用 `defaultSelectFilter`(空白查询一律命中)。 */
|
|
46
66
|
readonly filter?: ((option: SelectFieldOption, query: string) => boolean) | undefined;
|
|
67
|
+
/** 无匹配时的文案,或按查询生成文案的函数(能说"没有匹配 X 的项")。 */
|
|
47
68
|
readonly emptyText?: string | ((query: string) => string) | undefined;
|
|
69
|
+
/** 受控打开状态;不给就内部自己管。 */
|
|
48
70
|
readonly open?: boolean | undefined;
|
|
71
|
+
/** 打开 / 关闭时通知;和 `open` 一起用才是受控。 */
|
|
49
72
|
readonly onOpenChange?: ((open: boolean) => void) | undefined;
|
|
73
|
+
/** 禁用整颗;默认 false。 */
|
|
50
74
|
readonly disabled?: boolean | undefined;
|
|
75
|
+
/** 置真标红并写 `aria-invalid`;默认 false。 */
|
|
51
76
|
readonly invalid?: boolean | undefined;
|
|
77
|
+
/** 正在读候选:触发器换成转圈;默认 false。 */
|
|
52
78
|
readonly loading?: boolean | undefined;
|
|
79
|
+
/** 正在读时那句文案;不给是 `…`。 */
|
|
53
80
|
readonly loadingText?: string | undefined;
|
|
81
|
+
/** 退路:`options` 为空时改成手填(`value` + `onChange`)。 */
|
|
54
82
|
readonly fallback?: SelectFieldFallback | undefined;
|
|
83
|
+
/** 菜单底部那一条(如「新建」);不给不画。 */
|
|
55
84
|
readonly footer?: SelectFieldFooter | undefined;
|
|
85
|
+
/** 点菜单底部那一条做什么。 */
|
|
56
86
|
readonly onFooter?: (() => void) | undefined;
|
|
87
|
+
/** 选中行标记:`fill`(整行底色,默认)或 `check`(行尾勾)。 */
|
|
57
88
|
readonly selection?: 'check' | 'fill' | undefined;
|
|
89
|
+
/** 游标还没动时默认高亮哪一项(不给就回退到当前值);回车也选它,方向键从它那行走。给 `null` 表示明确没有默认目标:不画默认高亮、回车不动作。 */
|
|
58
90
|
readonly initialSelectedId?: string | null | undefined;
|
|
91
|
+
/** 打开时把选中的那一项滚进列表可视区;默认开,给 `false` 关掉。 */
|
|
59
92
|
readonly scrollToSelected?: boolean | undefined;
|
|
93
|
+
/** `boxed`(默认,带边框)或 `ghost`(无边框)。 */
|
|
60
94
|
readonly variant?: 'ghost' | 'boxed' | undefined;
|
|
95
|
+
/** 只画图标、不画当前值;默认 false。 */
|
|
61
96
|
readonly iconOnly?: boolean | undefined;
|
|
97
|
+
/** 箭头留着位置但不画:调用方在那个位置叠自己的操作钮。 */
|
|
62
98
|
readonly chevronHidden?: boolean | undefined;
|
|
99
|
+
/** 没有可见 label 时的读屏名。 */
|
|
63
100
|
readonly ariaLabel?: string | undefined;
|
|
101
|
+
/** 触发器的 `title` 属性。 */
|
|
64
102
|
readonly title?: string | undefined;
|
|
103
|
+
/** 触发器 id;`FormRow` 的 `htmlFor` 用它。 */
|
|
65
104
|
readonly id?: string | undefined;
|
|
105
|
+
/** 隐藏 input 的 name;表单提交用。 */
|
|
66
106
|
readonly name?: string | undefined;
|
|
107
|
+
/** 触发器额外类名。 */
|
|
67
108
|
readonly className?: string | undefined;
|
|
109
|
+
/** 菜单额外类名。 */
|
|
68
110
|
readonly menuClassName?: string | undefined;
|
|
69
111
|
}
|
|
70
112
|
|
|
@@ -356,19 +398,6 @@ function selectStepFrom(
|
|
|
356
398
|
* 下拉选择:默认是跟 `TextField` 一套的常规下拉框(不是原生 `<select>`),无边框那种给 `variant: 'ghost'`。
|
|
357
399
|
* `open` 不给就内部自己管(两种接法下 `onOpenChange` 都会通知),`loading` 把触发器换成转圈 + `loadingText`(默认 `…`),
|
|
358
400
|
* `selection` 选选中行标记(`fill` 整行底色 / `check` 行尾勾),`footer` 是列表底部那一条(点它走 `onFooter`,不改当前值)。
|
|
359
|
-
* @param props.value - 当前值;在 `options` 里找不到就按"没选"画 `placeholder`。
|
|
360
|
-
* @param props.options - 全量候选;空数组且给了 `fallback` 时改画手填输入框。
|
|
361
|
-
* @param props.onChange - 选中一项后的回调,回的是那一项的 `value`。
|
|
362
|
-
* @param props.label - 没进 `FormRow` 时的标签兜底;进了那一行就别再给它和 `hint`,否则会多一个标签。
|
|
363
|
-
* @param props.renderValue - 自己渲染触发器上那份当前值;不给就用候选项的 `label`。
|
|
364
|
-
* @param props.placeholder - 没选中时那句话;不给是 `—`。
|
|
365
|
-
* @param props.chevronHidden - 箭头留着位置但不画:调用方在那个位置叠自己的操作钮。
|
|
366
|
-
* @param props.initialSelectedId - 游标还没动时默认高亮哪一项(不给就回退到当前值);回车也选它,方向键从它那行走。给 `null` 表示明确没有默认目标:不画默认高亮、回车不动作。
|
|
367
|
-
* @param props.scrollToSelected - 打开时把选中的那一项滚进列表可视区;默认开,给 `false` 关掉。
|
|
368
|
-
* @param props.search - 是否可搜(默认 true);`false` 时不画搜索框、也不自动聚焦。
|
|
369
|
-
* @param props.filter - 自定义匹配;不给用 `defaultSelectFilter`(空白查询一律命中)。
|
|
370
|
-
* @param props.emptyText - 无匹配时的文案,或按查询生成文案的函数(能说"没有匹配 X 的项")。
|
|
371
|
-
* @param props.fallback - 退路:`options` 为空时改成手填(`value` + `onChange`)。
|
|
372
401
|
* @returns 触发器,以及打开时的搜索框与列表。
|
|
373
402
|
*/
|
|
374
403
|
export function SelectField(props: SelectFieldProps) {
|
|
@@ -6,12 +6,12 @@ import { h } from '../../lib/react.js';
|
|
|
6
6
|
* `TextField` 的契约:原生 input 属性,外加一个标红开关。
|
|
7
7
|
*/
|
|
8
8
|
export interface TextFieldProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
9
|
+
/** 置真标红并写 `aria-invalid`(默认 false);错在哪一句归 `FormRow.problem`。 */
|
|
9
10
|
readonly invalid?: boolean;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* 单行文本输入:设置面与筛选框都用它,`invalid` 之外的属性全部透传给原生 `<input>`。
|
|
14
|
-
* @param props.invalid - 置真标红并写 `aria-invalid`(默认 false);错在哪一句归 `FormRow.problem`。
|
|
15
15
|
* @returns 输入框元素;`className` 是追加在基础类名之后,而不是替换它。
|
|
16
16
|
*/
|
|
17
17
|
export function TextField({ invalid = false, className, ...rest }: TextFieldProps) {
|
|
@@ -7,20 +7,20 @@ import './Link.css';
|
|
|
7
7
|
* `Link` 的契约:目标地址、文案与外链开关。
|
|
8
8
|
*/
|
|
9
9
|
export interface LinkProps {
|
|
10
|
+
/** 目标地址,必给。 */
|
|
10
11
|
readonly href: string;
|
|
12
|
+
/** 链接文字(别自己再带 `→`)。 */
|
|
11
13
|
readonly children?: ReactNode | undefined;
|
|
14
|
+
/** 原生 title 提示;不给就不写这个属性。 */
|
|
12
15
|
readonly title?: string | undefined;
|
|
16
|
+
/** 默认 true:新窗口打开并画那颗 ↗;站内跳转给 false,箭头也一起不画。 */
|
|
13
17
|
readonly external?: boolean | undefined;
|
|
18
|
+
/** 追加在基础类名之后,不是替换。 */
|
|
14
19
|
readonly className?: string | undefined;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* 唯一的外链写法:自带新窗口、`rel="noopener noreferrer"`、正文色与行尾那颗小箭头。
|
|
19
|
-
* @param props.href - 目标地址,必给。
|
|
20
|
-
* @param props.children - 链接文字(别自己再带 `→`)。
|
|
21
|
-
* @param props.title - 原生 title 提示;不给就不写这个属性。
|
|
22
|
-
* @param props.external - 默认 true:新窗口打开并画那颗 ↗;站内跳转给 false,箭头也一起不画。
|
|
23
|
-
* @param props.className - 追加在基础类名之后,不是替换。
|
|
24
24
|
* @returns 一个 `<a>`。
|
|
25
25
|
*/
|
|
26
26
|
export function Link({ href, children, title, external = true, className }: LinkProps) {
|
|
@@ -6,12 +6,12 @@ import './Rows.css';
|
|
|
6
6
|
* `Rows` 的契约:一组键值行的容器。
|
|
7
7
|
*/
|
|
8
8
|
export interface RowsProps {
|
|
9
|
+
/** 一串 `Row`。 */
|
|
9
10
|
readonly children?: ReactNode | undefined;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* 键值行的容器:分隔线、行距与两端对齐在它和 `Row` 里,别自己写 `ul` / `li` 拼。
|
|
14
|
-
* @param props.children - 一串 `Row`。
|
|
15
15
|
* @returns 竖排的 div。
|
|
16
16
|
*/
|
|
17
17
|
export function Rows({ children }: RowsProps) {
|
|
@@ -22,14 +22,14 @@ export function Rows({ children }: RowsProps) {
|
|
|
22
22
|
* `Row` 的契约:左边名字 + 右边值。
|
|
23
23
|
*/
|
|
24
24
|
export interface RowProps {
|
|
25
|
+
/** 左边那格(键)。 */
|
|
25
26
|
readonly label: ReactNode;
|
|
27
|
+
/** 右边那格(值),可以是数字、时间或一小段节点。 */
|
|
26
28
|
readonly value: ReactNode;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* 一行键值:左边名字、右边值;要成对说明一项数据就用它,别自己写两栏。
|
|
31
|
-
* @param props.label - 左边那格(键)。
|
|
32
|
-
* @param props.value - 右边那格(值),可以是数字、时间或一小段节点。
|
|
33
33
|
* @returns 一行两格。
|
|
34
34
|
*/
|
|
35
35
|
export function Row({ label, value }: RowProps) {
|
|
@@ -6,18 +6,18 @@ import './SettingsSection.css';
|
|
|
6
6
|
* `SettingsSection` 的契约:一节的读屏名、标题、右上动作与内容。
|
|
7
7
|
*/
|
|
8
8
|
export interface SettingsSectionProps {
|
|
9
|
+
/** 只给读屏的组名(`aria-label`),不是标题。 */
|
|
9
10
|
readonly label: string;
|
|
11
|
+
/** 人看的标题。 */
|
|
10
12
|
readonly title: ReactNode;
|
|
13
|
+
/** 标题右侧的动作(如"添加");不给不占位。 */
|
|
11
14
|
readonly action?: ReactNode | undefined;
|
|
15
|
+
/** 这一节的内容。 */
|
|
12
16
|
readonly children?: ReactNode | undefined;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
20
|
* 设置面里的一节:标题 + 右上那颗动作 + 一节内容,把一屏设置分组。
|
|
17
|
-
* @param props.label - 只给读屏的组名(`aria-label`),不是标题。
|
|
18
|
-
* @param props.title - 人看的标题。
|
|
19
|
-
* @param props.action - 标题右侧的动作(如"添加");不给不占位。
|
|
20
|
-
* @param props.children - 这一节的内容。
|
|
21
21
|
* @returns 一个 `role="group"` 的 section。
|
|
22
22
|
*/
|
|
23
23
|
export function SettingsSection({ label, title, action, children }: SettingsSectionProps) {
|