@astryxdesign/core 0.7.3-canary.f94e962 → 0.7.3
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/CHANGELOG.md +88 -0
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +8 -4
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.js +7 -0
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +15 -2
- package/dist/Calendar/Calendar.js +3 -2
- package/dist/Chat/ChatComposer.d.ts.map +1 -1
- package/dist/Chat/ChatComposer.js +25 -2
- package/dist/Chat/ChatSystemMessage.d.ts +4 -0
- package/dist/Chat/ChatSystemMessage.d.ts.map +1 -1
- package/dist/Chat/ChatSystemMessage.js +4 -2
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +11 -1
- package/dist/DateRangeInput/DateRangeInput.d.ts +5 -5
- package/dist/DateRangeInput/DateRangeInput.d.ts.map +1 -1
- package/dist/DateRangeInput/DateRangeInput.js +27 -18
- package/dist/DateTimeInput/DateTimeInput.d.ts +5 -5
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +25 -27
- package/dist/DateTimeInput/NativeDateSegment.d.ts +3 -2
- package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeDateSegment.js +5 -5
- package/dist/DateTimeInput/NativeTimeSegment.d.ts +3 -2
- package/dist/DateTimeInput/NativeTimeSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeTimeSegment.js +5 -5
- package/dist/DateTimeInput/TouchDateTimeField.d.ts.map +1 -1
- package/dist/DateTimeInput/TouchDateTimeField.js +12 -9
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +9 -4
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts +9 -5
- package/dist/DropdownMenu/DropdownMenuRadioGroup.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuRadioGroup.js +2 -0
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +48 -15
- package/dist/MultiSelector/MultiSelector.d.ts +4 -4
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.d.ts +2 -0
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.js +48 -0
- package/dist/MultiSelector/MultiSelector.js +25 -18
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +5 -2
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +13 -3
- package/dist/TimeInput/TimeInput.d.ts +5 -5
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +37 -20
- package/dist/TimeInput/TouchTimeField.d.ts.map +1 -1
- package/dist/TimeInput/TouchTimeField.js +17 -6
- package/dist/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/Timestamp/Timestamp.js +41 -8
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/TreeList/TreeListItem.js +8 -3
- package/dist/hooks/useGridFocus.d.ts.map +1 -1
- package/dist/hooks/useGridFocus.js +10 -1
- package/package.json +4 -4
- package/scripts/agent-doc-state.mjs +24 -2
- package/src/BottomSheet/BottomSheet.spec.md +26 -53
- package/src/BottomSheet/BottomSheet.test.tsx +29 -0
- package/src/BottomSheet/BottomSheet.tsx +8 -4
- package/src/BottomSheet/BottomSheetSwitcher.spec.md +45 -48
- package/src/BottomSheet/BottomSheetSwitcher.test.tsx +26 -0
- package/src/BottomSheet/BottomSheetSwitcher.tsx +6 -0
- package/src/Button/Button.test.tsx +13 -2
- package/src/Button/Button.tsx +23 -2
- package/src/Button/__tests__/Button.a11y.states.ts +4 -3
- package/src/Calendar/Calendar.test.tsx +68 -24
- package/src/Calendar/Calendar.tsx +2 -1
- package/src/Carousel/Carousel.spec.md +146 -0
- package/src/Chat/ChatComposer.spec.md +26 -26
- package/src/Chat/ChatComposer.test.tsx +58 -2
- package/src/Chat/ChatComposer.tsx +25 -1
- package/src/Chat/ChatSystemMessage.doc.mjs +1 -1
- package/src/Chat/ChatSystemMessage.test.tsx +25 -3
- package/src/Chat/ChatSystemMessage.tsx +6 -4
- package/src/Chat/__tests__/ChatSystemMessage.a11y.chromium.spec.ts +8 -9
- package/src/CheckboxList/__tests__/CheckboxList.a11y.chromium.spec.ts +7 -6
- package/src/CodeBlock/CodeBlock.highlightStyles.test.tsx +87 -0
- package/src/CodeBlock/CodeBlock.tsx +11 -1
- package/src/DateRangeInput/DateRangeInput.doc.mjs +6 -5
- package/src/DateRangeInput/DateRangeInput.test.tsx +82 -16
- package/src/DateRangeInput/DateRangeInput.tsx +40 -20
- package/src/DateTimeInput/DateTimeInput.doc.mjs +9 -8
- package/src/DateTimeInput/DateTimeInput.test.tsx +126 -11
- package/src/DateTimeInput/DateTimeInput.tsx +42 -26
- package/src/DateTimeInput/DateTimeInputTouch.test.tsx +24 -0
- package/src/DateTimeInput/NativeDateSegment.tsx +9 -6
- package/src/DateTimeInput/NativePickerSegments.test.tsx +31 -0
- package/src/DateTimeInput/NativeTimeSegment.tsx +9 -6
- package/src/DateTimeInput/TouchDateTimeField.tsx +22 -7
- package/src/Dialog/Dialog.test.tsx +39 -0
- package/src/Dialog/Dialog.tsx +9 -4
- package/src/DropdownMenu/DropdownMenuItem.doc.mjs +66 -7
- package/src/DropdownMenu/DropdownMenuItem.spec.md +209 -0
- package/src/DropdownMenu/DropdownMenuRadioGroup.doc.mjs +62 -7
- package/src/DropdownMenu/DropdownMenuRadioGroup.spec.md +190 -0
- package/src/DropdownMenu/DropdownMenuRadioGroup.tsx +10 -4
- package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +93 -0
- package/src/DropdownMenu/__tests__/DropdownMenuItemAudit.a11y.chromium.spec.ts +366 -0
- package/src/DropdownMenu/__tests__/DropdownMenuRadioGroupAudit.a11y.chromium.spec.ts +327 -0
- package/src/FieldStatus/FieldStatus.spec.md +4 -4
- package/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx +0 -18
- package/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts +3 -18
- package/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx +1 -2
- package/src/Markdown/Markdown.helpers.perf.test.ts +25 -19
- package/src/Markdown/Markdown.rerender.test.tsx +143 -0
- package/src/Markdown/Markdown.tsx +89 -35
- package/src/MultiSelector/MultiSelector.disabledFocus.a11y.chromium.spec.ts +71 -0
- package/src/MultiSelector/MultiSelector.doc.mjs +5 -5
- package/src/MultiSelector/MultiSelector.focusableDisabled.test.tsx +121 -0
- package/src/MultiSelector/MultiSelector.test.tsx +49 -7
- package/src/MultiSelector/MultiSelector.tsx +53 -29
- package/src/Pagination/Pagination.test.tsx +5 -1
- package/src/Pagination/Pagination.tsx +3 -1
- package/src/Switch/Switch.test.tsx +56 -0
- package/src/Switch/Switch.tsx +13 -2
- package/src/Table/plugins/columnResize/useTableColumnResize.spec.md +11 -11
- package/src/Table/plugins/rowStatus/useTableRowStatus.spec.md +4 -3
- package/src/TimeInput/NativeTimeInput.test.tsx +25 -1
- package/src/TimeInput/Presentation.test.tsx +23 -0
- package/src/TimeInput/TimeInput.doc.mjs +8 -7
- package/src/TimeInput/TimeInput.test.tsx +119 -7
- package/src/TimeInput/TimeInput.tsx +51 -23
- package/src/TimeInput/TouchTimeField.tsx +27 -5
- package/src/Timestamp/Timestamp.doc.mjs +1 -1
- package/src/Timestamp/Timestamp.test.tsx +168 -0
- package/src/Timestamp/Timestamp.tsx +62 -11
- package/src/TreeList/TreeList.test.tsx +28 -0
- package/src/TreeList/TreeListItem.tsx +6 -2
- package/src/__tests__/DisabledTriggerFocus.a11y.chromium.spec.ts +86 -0
- package/src/hooks/useGridFocus.ts +16 -1
|
@@ -8,7 +8,52 @@ export const docs = {
|
|
|
8
8
|
displayName: 'Dropdown Menu Radio Group',
|
|
9
9
|
isHiddenFromOverview: true,
|
|
10
10
|
description:
|
|
11
|
-
'A single-select group of
|
|
11
|
+
'A controlled, named single-select group of DropdownMenuRadioItem children (role="group" of menuitemradio). Owns value propagation, close policy, root composition, and the menu inter-item gap; the parent DropdownMenu owns keyboard navigation.',
|
|
12
|
+
usage: {
|
|
13
|
+
description:
|
|
14
|
+
'Use DropdownMenuRadioGroup inside compound-mode DropdownMenu when several commands represent one mutually exclusive choice. Keep value in caller state, provide a concise accessible label, and render each choice as DropdownMenuRadioItem.',
|
|
15
|
+
bestPractices: [
|
|
16
|
+
{
|
|
17
|
+
guidance: true,
|
|
18
|
+
description:
|
|
19
|
+
'Keep value controlled and update it from onChange so checked state follows caller data.',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
guidance: true,
|
|
23
|
+
description:
|
|
24
|
+
'Provide a concise label even when aria-labelledby points to visible text; label remains required and supplies the aria-label fallback.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
guidance: true,
|
|
28
|
+
description:
|
|
29
|
+
'Set hasCloseOnSelect=false only when the menu must stay open to show another selection or an in-place result.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
guidance: false,
|
|
33
|
+
description:
|
|
34
|
+
'Place buttons, links, checkboxes, or arbitrary menu rows inside the radio group.',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
guidance: false,
|
|
38
|
+
description:
|
|
39
|
+
'Add a second key handler or roving-focus model; DropdownMenu owns keyboard navigation.',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
anatomy: [
|
|
43
|
+
{
|
|
44
|
+
name: 'Group',
|
|
45
|
+
required: true,
|
|
46
|
+
description:
|
|
47
|
+
'The role="group" root that owns the accessible name, controlled-selection context, close policy, root inputs, and inter-item gap.',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'Radio items',
|
|
51
|
+
required: true,
|
|
52
|
+
description:
|
|
53
|
+
'DropdownMenuRadioItem children; each child owns its menuitemradio role, checked state, content, and indicator paint.',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
12
57
|
playground: {
|
|
13
58
|
wrapper: {
|
|
14
59
|
component: 'DropdownMenu',
|
|
@@ -42,17 +87,20 @@ export const docs = {
|
|
|
42
87
|
type: 'string | undefined',
|
|
43
88
|
description:
|
|
44
89
|
'The currently selected value in the group. Pass undefined when nothing is selected yet.',
|
|
90
|
+
required: true,
|
|
45
91
|
},
|
|
46
92
|
{
|
|
47
93
|
name: 'onChange',
|
|
48
94
|
type: '(value: string) => void',
|
|
49
95
|
description: 'Callback fired when the selected value changes.',
|
|
96
|
+
required: true,
|
|
50
97
|
},
|
|
51
98
|
{
|
|
52
99
|
name: 'label',
|
|
53
100
|
type: 'string',
|
|
54
101
|
description:
|
|
55
|
-
'Accessible name for the group, applied as aria-label so screen readers announce the radios as a named set, e.g. "Sort by". Required
|
|
102
|
+
'Accessible name for the group, applied as aria-label so screen readers announce the radios as a named set, e.g. "Sort by". Required even when aria-labelledby (via base props) points to visible text; that visible reference becomes the computed name while label remains the fallback.',
|
|
103
|
+
required: true,
|
|
56
104
|
},
|
|
57
105
|
{
|
|
58
106
|
name: 'hasCloseOnSelect',
|
|
@@ -61,40 +109,47 @@ export const docs = {
|
|
|
61
109
|
description:
|
|
62
110
|
'Whether selecting a value closes the menu. Radio items default to closing on selection (a single-choice commit).',
|
|
63
111
|
},
|
|
112
|
+
{
|
|
113
|
+
name: 'ref',
|
|
114
|
+
type: 'React.Ref<HTMLDivElement>',
|
|
115
|
+
description: 'Ref forwarded to the role="group" root.',
|
|
116
|
+
},
|
|
64
117
|
{
|
|
65
118
|
name: 'children',
|
|
66
119
|
type: 'ReactNode',
|
|
67
120
|
description: 'The DropdownMenuRadioItems that make up the group.',
|
|
121
|
+
required: true,
|
|
68
122
|
},
|
|
69
123
|
],
|
|
70
124
|
};
|
|
71
125
|
|
|
72
126
|
export const docsZh = {
|
|
73
127
|
name: 'DropdownMenuRadioGroup',
|
|
74
|
-
isHiddenFromOverview: true,
|
|
75
128
|
displayName: 'Dropdown Menu Radio Group',
|
|
76
129
|
description:
|
|
77
|
-
'
|
|
130
|
+
'DropdownMenu 中由调用方控制且有名称的单选组(menuitemradio 的 role="group")。该组负责值传递、关闭策略、根元素组合和菜单项间距;父 DropdownMenu 负责键盘导航。',
|
|
78
131
|
propDescriptions: {
|
|
79
132
|
value: '组中当前选中的值。尚无选中项时传 undefined。',
|
|
80
133
|
onChange: '所选值变化时触发的回调。',
|
|
81
134
|
label:
|
|
82
|
-
'组的无障碍名称,作为 aria-label
|
|
135
|
+
'组的无障碍名称,作为 aria-label 应用。即使 aria-labelledby(通过基础属性)指向可见文本,label 仍然必需并作为后备名称。',
|
|
83
136
|
hasCloseOnSelect: '选择某值是否关闭菜单。默认关闭。',
|
|
137
|
+
ref: '转发到 role="group" 根元素的 ref。',
|
|
84
138
|
children: '组成该组的 DropdownMenuRadioItem。',
|
|
85
139
|
},
|
|
86
140
|
};
|
|
87
141
|
|
|
88
142
|
export const docsDense = {
|
|
89
143
|
name: 'DropdownMenuRadioGroup',
|
|
90
|
-
isHiddenFromOverview: true,
|
|
91
144
|
displayName: 'Dropdown Menu Radio Group',
|
|
92
|
-
description:
|
|
145
|
+
description:
|
|
146
|
+
'controlled named menuitemradio group; owns value propagation, close policy, root inputs, and item gap',
|
|
93
147
|
propDescriptions: {
|
|
94
148
|
value: 'selected value (undefined = none)',
|
|
95
149
|
onChange: 'fired when selected value changes',
|
|
96
150
|
label: 'accessible group name (applied as aria-label); required',
|
|
97
151
|
hasCloseOnSelect: 'close menu on select (default true)',
|
|
152
|
+
ref: 'forwarded to the role="group" root',
|
|
98
153
|
children: 'the DropdownMenuRadioItems',
|
|
99
154
|
},
|
|
100
155
|
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
---
|
|
2
|
+
schema_version: 3
|
|
3
|
+
template_version: 7
|
|
4
|
+
kind: component
|
|
5
|
+
id: component:DropdownMenuRadioGroup
|
|
6
|
+
authority: draft
|
|
7
|
+
archive_reason: null
|
|
8
|
+
superseded_by: null
|
|
9
|
+
approved_by: null
|
|
10
|
+
approved_at: null
|
|
11
|
+
owners: [cixzhang]
|
|
12
|
+
review_triggers: [public-api, behavior, accessibility, theming, testing]
|
|
13
|
+
verified_by:
|
|
14
|
+
[
|
|
15
|
+
packages/core/src/DropdownMenu/DropdownMenuSelectable.test.tsx,
|
|
16
|
+
packages/core/src/DropdownMenu/DropdownMenu.test.tsx,
|
|
17
|
+
packages/core/src/DropdownMenu/__tests__/Menu.a11y.test.tsx,
|
|
18
|
+
apps/storybook/stories/DropdownMenuRadioGroup.stories.tsx,
|
|
19
|
+
apps/storybook/rtl-audit/verified-not-applicable.json,
|
|
20
|
+
scripts/check-knowledge.mjs,
|
|
21
|
+
]
|
|
22
|
+
modules: []
|
|
23
|
+
families: []
|
|
24
|
+
design_specs: []
|
|
25
|
+
architecture:
|
|
26
|
+
[
|
|
27
|
+
architecture:public-component-api,
|
|
28
|
+
architecture:component-test-sufficiency,
|
|
29
|
+
architecture:interaction-modality,
|
|
30
|
+
]
|
|
31
|
+
contributing: []
|
|
32
|
+
system_specs: [spec:AST-020, spec:AST-029]
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
# DropdownMenuRadioGroup component contract
|
|
36
|
+
|
|
37
|
+
## Contract at a glance
|
|
38
|
+
|
|
39
|
+
| Area | Contract |
|
|
40
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| Public contract | One controlled, named single-selection group of `DropdownMenuRadioItem` children with value, change callback, close policy, root inputs, and an explicit React 19 ref. |
|
|
42
|
+
| Behavior | The group supplies selection and close-policy context; radio items emit values; the parent DropdownMenu owns keyboard navigation and menu lifecycle. |
|
|
43
|
+
| End-user impact | Assistive technology encounters one named group with exactly one current choice when a value matches, while pointer and keyboard selection stay aligned. |
|
|
44
|
+
| Builder impact | Keep the value controlled, provide a stable accessible label, and place only DropdownMenuRadioItem options inside the group. |
|
|
45
|
+
| Compatibility/readiness | Patch-compatible additive `ref` prop on the existing group root. Existing runtime behavior, exports, defaults, and theme surfaces remain unchanged; authority stays `draft` until owner approval. |
|
|
46
|
+
| Review checks | Reject unnamed groups, local selection state, dropped root inputs, a second keyboard owner, or a close policy that bypasses the controlled callback. |
|
|
47
|
+
| Governing rules | WAI-ARIA menu pattern; `architecture:public-component-api/INV5–INV9`; `architecture:component-test-sufficiency/INV1–INV7`; `spec:AST-020/FR1,FR2,FR6`. |
|
|
48
|
+
|
|
49
|
+
This table is a review projection; the body below is authoritative.
|
|
50
|
+
|
|
51
|
+
## Intent
|
|
52
|
+
|
|
53
|
+
DropdownMenuRadioGroup renders one named `role="group"` wrapper inside the
|
|
54
|
+
pointer presentation of DropdownMenu. It owns controlled selection context,
|
|
55
|
+
close policy, root composition, and the tokenized gap between children.
|
|
56
|
+
DropdownMenuRadioItem owns each `menuitemradio` row and its checked state;
|
|
57
|
+
DropdownMenu owns focus movement, typeahead, keyboard activation, presentation,
|
|
58
|
+
and menu open/close lifecycle.
|
|
59
|
+
|
|
60
|
+
## Compatibility and migration
|
|
61
|
+
|
|
62
|
+
- Released default preserved: yes (`hasCloseOnSelect=true`).
|
|
63
|
+
- Compatibility class: additive patch; declares and forwards the React 19 `ref`
|
|
64
|
+
prop to the existing group root without changing existing behavior.
|
|
65
|
+
- Controlled behavior: `value` is caller-owned and `onChange` is the only commit path.
|
|
66
|
+
- Migration decision: none.
|
|
67
|
+
|
|
68
|
+
Consumer migration instructions belong in consumer docs and release notes.
|
|
69
|
+
|
|
70
|
+
## Ownership boundary
|
|
71
|
+
|
|
72
|
+
**Owns**
|
|
73
|
+
|
|
74
|
+
- One `role="group"` root with an `aria-label` from the required `label` prop.
|
|
75
|
+
- Controlled `value`, `onChange`, and `hasCloseOnSelect` context for radio items.
|
|
76
|
+
- Composition of `children`, supported host inputs, ref, `className`, `style`, and
|
|
77
|
+
`xstyle` on the group root.
|
|
78
|
+
- Column layout and the semantic menu inter-item gap.
|
|
79
|
+
|
|
80
|
+
**Does not own / non-goals**
|
|
81
|
+
|
|
82
|
+
- The `menuitemradio` role, `aria-checked`, disabled behavior, indicator paint,
|
|
83
|
+
label, description, icon, or end content — owned by DropdownMenuRadioItem.
|
|
84
|
+
- Focus entry, arrow-key navigation, typeahead, Enter/Space synthesis, and menu
|
|
85
|
+
close implementation — owned by DropdownMenu and shared menu hooks.
|
|
86
|
+
- Touch and bottom-sheet selectable-row rendering — owned by the parent presentation.
|
|
87
|
+
- Uncontrolled selection state or child-value registration.
|
|
88
|
+
|
|
89
|
+
## Public concepts
|
|
90
|
+
|
|
91
|
+
| Concept | Closed values or states | Meaning | Default | Owner | Stability | Invalid-value behavior |
|
|
92
|
+
| --------------- | --------------------------------------------- | -------------------------------------------------------------------- | -------- | ------------------------ | --------- | ----------------------------------------------------- |
|
|
93
|
+
| Selection | matching value; no matching value | Controls which child reports checked. | none | caller and radio item | stable | No match leaves every child unchecked. |
|
|
94
|
+
| Commit | child value | Emits the selected child value through `onChange`. | required | group context | stable | Children outside the group throw from the item owner. |
|
|
95
|
+
| Close policy | close; remain open | Controls whether an item asks DropdownMenu to close after selection. | close | group context and parent | stable | Omission closes. |
|
|
96
|
+
| Accessible name | required label; optional labelledby | Names the group; `aria-labelledby` may point at visible text. | label | group root | stable | `label` remains required by the public type. |
|
|
97
|
+
| Root surface | ref; DOM/data/ARIA; class/style/xstyle/events | Extends the group root while preserving its role and name. | omitted | public component API | stable | Accepted inputs compose; owned role and label win. |
|
|
98
|
+
|
|
99
|
+
## Behavioral and layout contract
|
|
100
|
+
|
|
101
|
+
Draft requirements identify their basis so observed code is not mistaken for an
|
|
102
|
+
intentional decision.
|
|
103
|
+
|
|
104
|
+
| ID | Candidate invariant | Basis | Draft review state |
|
|
105
|
+
| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- | ------------------ |
|
|
106
|
+
| FR1 | The root MUST expose `role="group"` and a non-empty accessible name. The required `label` supplies `aria-label`; caller `aria-labelledby` MAY reference visible text. | WAI-ARIA menu pattern; released source/docs | verify |
|
|
107
|
+
| FR2 | The group MUST remain controlled. It MUST compare each radio item's value with caller `value` and MUST emit a selected child value only through caller `onChange`. | Released public API and focused tests | verify |
|
|
108
|
+
| FR3 | `hasCloseOnSelect` MUST default to true. When false, successful selection MUST update through `onChange` while the parent menu remains open. | Released behavior and focused tests | verify |
|
|
109
|
+
| FR4 | DropdownMenu MUST remain the only keyboard owner. The group adds no tab stop, key handler, typeahead, or click synthesis; it only provides context to child rows. | `architecture:interaction-modality`; parent tests | verify |
|
|
110
|
+
| FR5 | Ref, supported host attributes and handlers, `className`, `style`, and `xstyle` MUST reach or compose on the group root without replacing the owned role or `aria-label`. | `architecture:public-component-api/INV5–INV9`; source/tests | verify |
|
|
111
|
+
| FR6 | The wrapper MUST remain a logical column whose tokenized gap matches the surrounding menu's item rhythm; it MUST NOT add component-specific directional paint or navigation. | Current source; token and bidirectionality rules | verify |
|
|
112
|
+
|
|
113
|
+
### Allowed variation
|
|
114
|
+
|
|
115
|
+
- **AV1 — Children.** The number, labels, descriptions, icons, and supporting
|
|
116
|
+
content of DropdownMenuRadioItem children may vary.
|
|
117
|
+
- **AV2 — Selection.** Any string value, including no matching value, may be
|
|
118
|
+
caller-controlled without adding local group state.
|
|
119
|
+
- **AV3 — Root styling.** Caller style inputs may extend the wrapper while the
|
|
120
|
+
role, accessible label, column flow, and child semantics remain intact.
|
|
121
|
+
|
|
122
|
+
### Representative states
|
|
123
|
+
|
|
124
|
+
| State | Required invariant | Allowed variation |
|
|
125
|
+
| ----------------- | -------------------------------------------------------------------------- | ------------------------------------ |
|
|
126
|
+
| Matching value | Exactly the matching child reports `aria-checked=true`. | Child content and menu size. |
|
|
127
|
+
| No matching value | Every child reports `aria-checked=false`. | Empty or unmatched caller value. |
|
|
128
|
+
| Default close | Selection emits the value and closes through the parent. | Pointer or synthesized keyboard act. |
|
|
129
|
+
| Retained open | Selection emits the value, updates controlled state, and leaves menu open. | Result copy and selected child. |
|
|
130
|
+
| RTL / narrow | Column order and tokenized gap hold with no horizontal overflow. | Parent menu placement. |
|
|
131
|
+
|
|
132
|
+
### Transformation and precedence order
|
|
133
|
+
|
|
134
|
+
- **ORD1 — Selection.** Child activation → disabled guard in the item owner →
|
|
135
|
+
group `onChange(value)` → optional parent close.
|
|
136
|
+
- **ORD2 — Root composition.** Base column/gap → caller `xstyle`; supported host
|
|
137
|
+
inputs and class/style compose while owned role and label remain fixed.
|
|
138
|
+
|
|
139
|
+
### Performance and resources
|
|
140
|
+
|
|
141
|
+
- **PR1 — Context only.** The group memoizes a small context value and owns no
|
|
142
|
+
Effect, listener, observer, timer, request, DOM read, or resource lifecycle.
|
|
143
|
+
|
|
144
|
+
## Accessibility contract
|
|
145
|
+
|
|
146
|
+
- **AR1 — Named group.** The wrapper is one named `group` inside the parent menu.
|
|
147
|
+
- **AR2 — Radio rows.** Child items own `menuitemradio` and `aria-checked`; the
|
|
148
|
+
group does not add nested native inputs or duplicate row semantics.
|
|
149
|
+
- **AR3 — Keyboard ownership.** DropdownMenu owns focus collection and activation;
|
|
150
|
+
the group itself never enters the tab or arrow-key sequence.
|
|
151
|
+
|
|
152
|
+
## Design relationships
|
|
153
|
+
|
|
154
|
+
| Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
|
|
155
|
+
| ---------------- | ---------------------------------------------------------------- | ---------------------------------- | -------------- | ------------------ |
|
|
156
|
+
| Group wrapper | Logical column with the menu's semantic inter-item gap. | Current source and spacing tokens | structural | FR1, FR5, FR6 |
|
|
157
|
+
| Selected child | One child reflects caller value through `aria-checked`. | DropdownMenuRadioItem | prominent | FR2, AR2 |
|
|
158
|
+
| Direction/narrow | Child order and gap hold without physical-direction assumptions. | Bidirectionality and parent layout | structural | FR6 |
|
|
159
|
+
|
|
160
|
+
No new component-local visual decision is settled by this draft.
|
|
161
|
+
|
|
162
|
+
## Family and system relationships
|
|
163
|
+
|
|
164
|
+
- `architecture:public-component-api` owns root input composition and released compatibility.
|
|
165
|
+
- `architecture:component-test-sufficiency` owns proportionate observable evidence.
|
|
166
|
+
- `architecture:interaction-modality` and DropdownMenu own keyboard behavior.
|
|
167
|
+
- `spec:AST-020` supplies WCAG/APG adoption and evidence-layer boundaries.
|
|
168
|
+
- `spec:AST-029` keeps this observational draft separate from the audit receipt.
|
|
169
|
+
|
|
170
|
+
## Verification map
|
|
171
|
+
|
|
172
|
+
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
|
|
173
|
+
| -------------- | ------------------------------------------------------------------------------ | ------------------------------------ | ----------------------------------------------------------------------------------------- | ------------------------------------------- |
|
|
174
|
+
| FR1–FR4, AR1–3 | `DropdownMenuSelectable.test.tsx`; reusable Menu contracts; scoped axe | matching, none, close, retained-open | An unnamed group, wrong checked row, skipped callback, unwanted close, or key owner fails | `audit:DropdownMenuRadioGroup/§1,§4,§6` |
|
|
175
|
+
| FR5 | root/ref/handler tests; lint and typecheck | ref, host attributes, class/style | An accepted input is dropped or overrides the owned role/name | `audit:DropdownMenuRadioGroup/§3` |
|
|
176
|
+
| FR6 | source-hashed RTL N/A receipt plus exact-head Neutral/Butter/RTL/narrow frames | LTR, RTL, 320px, light/dark | Physical direction, lost tokenized gap, collapsed geometry, or horizontal overflow fails | `audit:DropdownMenuRadioGroup/§2,§5,§9,§10` |
|
|
177
|
+
|
|
178
|
+
## Decision log
|
|
179
|
+
|
|
180
|
+
None. This draft records current facts and introduces no product decision.
|
|
181
|
+
|
|
182
|
+
## Open questions
|
|
183
|
+
|
|
184
|
+
None.
|
|
185
|
+
|
|
186
|
+
## Content boundary
|
|
187
|
+
|
|
188
|
+
This file does not duplicate consumer prop tables/examples, current audit scores,
|
|
189
|
+
screenshot matrices, implementation steps, or parent/item contracts. The audit
|
|
190
|
+
pull request owns the closed run evidence required by `spec:AST-029/FR5`.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* menuitemradio rows.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {useMemo, type ReactNode} from 'react';
|
|
17
|
+
import {useMemo, type ReactNode, type Ref} from 'react';
|
|
18
18
|
import * as stylex from '@stylexjs/stylex';
|
|
19
19
|
import {spacingVars} from '../theme/tokens.stylex';
|
|
20
20
|
import {mergeProps} from '../utils';
|
|
@@ -51,9 +51,9 @@ export interface DropdownMenuRadioGroupProps extends Omit<
|
|
|
51
51
|
/**
|
|
52
52
|
* Accessible name for the group, announced by screen readers so the radios
|
|
53
53
|
* read as a named set (e.g. "Sort by"). Applied as the group's `aria-label`.
|
|
54
|
-
* Required
|
|
55
|
-
*
|
|
56
|
-
*
|
|
54
|
+
* Required even when `aria-labelledby` (via base props) points to visible
|
|
55
|
+
* text; that visible reference becomes the computed name while `label`
|
|
56
|
+
* remains the fallback.
|
|
57
57
|
*/
|
|
58
58
|
label: string;
|
|
59
59
|
/**
|
|
@@ -63,6 +63,10 @@ export interface DropdownMenuRadioGroupProps extends Omit<
|
|
|
63
63
|
* @default true
|
|
64
64
|
*/
|
|
65
65
|
hasCloseOnSelect?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Ref forwarded to the role="group" root.
|
|
68
|
+
*/
|
|
69
|
+
ref?: Ref<HTMLDivElement>;
|
|
66
70
|
/**
|
|
67
71
|
* The `DropdownMenuRadioItem`s that make up the group.
|
|
68
72
|
*/
|
|
@@ -92,6 +96,7 @@ export function DropdownMenuRadioGroup({
|
|
|
92
96
|
label,
|
|
93
97
|
hasCloseOnSelect = true,
|
|
94
98
|
children,
|
|
99
|
+
ref,
|
|
95
100
|
xstyle,
|
|
96
101
|
className,
|
|
97
102
|
style,
|
|
@@ -105,6 +110,7 @@ export function DropdownMenuRadioGroup({
|
|
|
105
110
|
return (
|
|
106
111
|
<div
|
|
107
112
|
{...rest}
|
|
113
|
+
ref={ref}
|
|
108
114
|
role="group"
|
|
109
115
|
aria-label={label}
|
|
110
116
|
{...mergeProps(stylex.props(styles.group, xstyle), {className, style})}>
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* outcomes live in their reusable contracts; Menu retains navigation.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
+
import {useState} from 'react';
|
|
12
13
|
import {describe, it, expect, vi, beforeEach} from 'vitest';
|
|
13
14
|
import {render, screen, fireEvent, waitFor} from '@testing-library/react';
|
|
14
15
|
import userEvent from '@testing-library/user-event';
|
|
@@ -328,6 +329,98 @@ describe('DropdownMenuRadioGroup / RadioItem', () => {
|
|
|
328
329
|
screen.getByRole('menuitemradio', {name: 'Oldest', hidden: true}),
|
|
329
330
|
);
|
|
330
331
|
expect(onChange).toHaveBeenCalledWith('oldest');
|
|
332
|
+
expect(
|
|
333
|
+
screen.getByRole('menuitemradio', {name: 'Newest', hidden: true}),
|
|
334
|
+
).toHaveAttribute('aria-checked', 'true');
|
|
335
|
+
expect(
|
|
336
|
+
screen.getByRole('menuitemradio', {name: 'Oldest', hidden: true}),
|
|
337
|
+
).toHaveAttribute('aria-checked', 'false');
|
|
338
|
+
expect(HTMLElement.prototype.hidePopover).toHaveBeenCalledTimes(1);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it('keeps the menu open while controlled selection updates when requested', async () => {
|
|
342
|
+
const user = userEvent.setup();
|
|
343
|
+
const onChange = vi.fn();
|
|
344
|
+
|
|
345
|
+
function ControlledGroup() {
|
|
346
|
+
const [value, setValue] = useState('newest');
|
|
347
|
+
return (
|
|
348
|
+
<DropdownMenu button={{label: 'Sort'}}>
|
|
349
|
+
<DropdownMenuRadioGroup
|
|
350
|
+
value={value}
|
|
351
|
+
onChange={nextValue => {
|
|
352
|
+
onChange(nextValue);
|
|
353
|
+
setValue(nextValue);
|
|
354
|
+
}}
|
|
355
|
+
label="Sort by"
|
|
356
|
+
hasCloseOnSelect={false}>
|
|
357
|
+
<DropdownMenuRadioItem value="newest" label="Newest" />
|
|
358
|
+
<DropdownMenuRadioItem value="oldest" label="Oldest" />
|
|
359
|
+
</DropdownMenuRadioGroup>
|
|
360
|
+
</DropdownMenu>
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
render(<ControlledGroup />);
|
|
365
|
+
await user.click(screen.getByRole('button', {name: /Sort/}));
|
|
366
|
+
const oldest = screen.getByRole('menuitemradio', {
|
|
367
|
+
name: 'Oldest',
|
|
368
|
+
hidden: true,
|
|
369
|
+
});
|
|
370
|
+
await user.click(oldest);
|
|
371
|
+
|
|
372
|
+
expect(onChange).toHaveBeenCalledWith('oldest');
|
|
373
|
+
expect(oldest).toHaveAttribute('aria-checked', 'true');
|
|
374
|
+
expect(HTMLElement.prototype.hidePopover).not.toHaveBeenCalled();
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
it('names and composes the group root when no value matches', async () => {
|
|
378
|
+
const user = userEvent.setup();
|
|
379
|
+
const ref = vi.fn();
|
|
380
|
+
const onClick = vi.fn();
|
|
381
|
+
render(
|
|
382
|
+
<>
|
|
383
|
+
<span id="sort-label">Visible sort label</span>
|
|
384
|
+
<DropdownMenu button={{label: 'Sort'}}>
|
|
385
|
+
<DropdownMenuRadioGroup
|
|
386
|
+
ref={ref}
|
|
387
|
+
role="tree"
|
|
388
|
+
aria-label="Consumer label"
|
|
389
|
+
aria-labelledby="sort-label"
|
|
390
|
+
data-owner="consumer"
|
|
391
|
+
className="consumer-group"
|
|
392
|
+
style={{inlineSize: 240}}
|
|
393
|
+
onClick={onClick}
|
|
394
|
+
value={undefined}
|
|
395
|
+
onChange={() => {}}
|
|
396
|
+
label="Sort fallback">
|
|
397
|
+
<DropdownMenuRadioItem value="newest" label="Newest" />
|
|
398
|
+
<DropdownMenuRadioItem value="oldest" label="Oldest" />
|
|
399
|
+
</DropdownMenuRadioGroup>
|
|
400
|
+
</DropdownMenu>
|
|
401
|
+
</>,
|
|
402
|
+
);
|
|
403
|
+
await user.click(screen.getByRole('button', {name: /Sort/}));
|
|
404
|
+
|
|
405
|
+
const group = screen.getByRole('group', {
|
|
406
|
+
name: 'Visible sort label',
|
|
407
|
+
hidden: true,
|
|
408
|
+
});
|
|
409
|
+
expect(group).toHaveAttribute('role', 'group');
|
|
410
|
+
expect(group).toHaveAttribute('aria-label', 'Sort fallback');
|
|
411
|
+
expect(group).toHaveAttribute('aria-labelledby', 'sort-label');
|
|
412
|
+
expect(group).toHaveAttribute('data-owner', 'consumer');
|
|
413
|
+
expect(group).toHaveClass('consumer-group');
|
|
414
|
+
expect(group).toHaveStyle({inlineSize: '240px'});
|
|
415
|
+
expect(ref).toHaveBeenCalledWith(group);
|
|
416
|
+
expect(
|
|
417
|
+
screen
|
|
418
|
+
.getAllByRole('menuitemradio', {hidden: true})
|
|
419
|
+
.every(item => item.getAttribute('aria-checked') === 'false'),
|
|
420
|
+
).toBe(true);
|
|
421
|
+
|
|
422
|
+
fireEvent.click(group);
|
|
423
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
331
424
|
});
|
|
332
425
|
|
|
333
426
|
it('throws when a radio item is used outside a group', () => {
|