@astryxdesign/core 0.7.1 → 0.7.2-canary.151434a
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/AspectRatio/AspectRatio.d.ts +6 -8
- package/dist/AspectRatio/AspectRatio.d.ts.map +1 -1
- package/dist/AspectRatio/AspectRatio.js +44 -3
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +38 -14
- package/dist/CheckboxInput/CheckboxInput.d.ts +1 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +3 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts +9 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +4 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +20 -8
- package/dist/Drawer/Drawer.d.ts +191 -0
- package/dist/Drawer/Drawer.d.ts.map +1 -0
- package/dist/Drawer/Drawer.js +382 -0
- package/dist/Drawer/DrawerHeader.d.ts +85 -0
- package/dist/Drawer/DrawerHeader.d.ts.map +1 -0
- package/dist/Drawer/DrawerHeader.js +134 -0
- package/dist/Drawer/index.d.ts +11 -0
- package/dist/Drawer/index.d.ts.map +1 -0
- package/dist/Drawer/index.js +11 -0
- package/dist/Drawer/useDrawerDialogPresence.d.ts +42 -0
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -0
- package/dist/Drawer/useDrawerDialogPresence.js +236 -0
- package/dist/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/DropdownMenu/DropdownMenuDivider.d.ts +5 -3
- package/dist/DropdownMenu/DropdownMenuDivider.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenuDivider.js +7 -3
- package/dist/DropdownMenu/DropdownMenuSubMenu.js +4 -4
- package/dist/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/EmptyState/EmptyState.js +4 -10
- package/dist/Field/Field.d.ts +1 -1
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +8 -4
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +10 -2
- package/dist/Item/Item.d.ts +6 -2
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +19 -4
- package/dist/Layer/layerViewportInset.stylex.d.ts +6 -2
- package/dist/Layer/layerViewportInset.stylex.d.ts.map +1 -1
- package/dist/Layer/layerViewportInset.stylex.js +6 -2
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +13 -7
- package/dist/Layer/useLayerDismissal.d.ts +1 -1
- package/dist/Layer/useLayerDismissal.js +1 -1
- package/dist/Layout/container.stylex.d.ts +5 -5
- package/dist/Layout/container.stylex.js +4 -4
- package/dist/List/List.d.ts +46 -19
- package/dist/List/List.d.ts.map +1 -1
- package/dist/List/List.js +28 -10
- package/dist/List/ListContext.d.ts +8 -3
- package/dist/List/ListContext.d.ts.map +1 -1
- package/dist/List/ListContext.js +7 -2
- package/dist/List/ListItem.d.ts +13 -5
- package/dist/List/ListItem.d.ts.map +1 -1
- package/dist/List/ListItem.js +21 -8
- package/dist/List/index.d.ts +1 -1
- package/dist/List/index.d.ts.map +1 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +8 -1
- package/dist/Markdown/plugins/frontmatter.d.ts.map +1 -1
- package/dist/Markdown/plugins/frontmatter.js +7 -3
- package/dist/MetadataList/MetadataList.d.ts.map +1 -1
- package/dist/MetadataList/MetadataList.js +5 -1
- package/dist/MetadataList/MetadataListContext.d.ts +1 -1
- package/dist/MetadataList/MetadataListContext.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +22 -8
- package/dist/MultiSelector/OptionActions.a11y.chromium.spec.js +100 -2
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +3 -1
- package/dist/Pagination/Pagination.d.ts +8 -5
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +21 -8
- package/dist/Popover/Popover.js +2 -2
- package/dist/PowerSearch/PowerSearch.js +1 -1
- package/dist/RadioList/RadioListItem.d.ts +9 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +2 -0
- package/dist/Selector/hooks.d.ts.map +1 -1
- package/dist/Selector/hooks.js +6 -2
- package/dist/Switch/Switch.d.ts +1 -1
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +13 -1
- package/dist/TabList/TabMenu.d.ts +2 -2
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +6 -3
- package/dist/Text/useTruncation.d.ts +7 -5
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +16 -5
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +11 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +26 -0
- package/dist/astryx.css +35 -12
- package/dist/hooks/useEntryAnimation.d.ts +2 -1
- package/dist/hooks/useEntryAnimation.d.ts.map +1 -1
- package/dist/hooks/useEntryAnimation.js +14 -12
- package/dist/hooks/useIsHydrating.d.ts +6 -0
- package/dist/hooks/useIsHydrating.d.ts.map +1 -0
- package/dist/hooks/useIsHydrating.js +30 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +112 -1
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +112 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/theme/derivedVarRegistry.d.ts.map +1 -1
- package/dist/theme/derivedVarRegistry.js +0 -3
- package/dist/utils/focusOutline.stylex.d.ts +4 -0
- package/dist/utils/focusOutline.stylex.d.ts.map +1 -1
- package/dist/utils/focusOutline.stylex.js +4 -0
- package/dist/utils/plainDate.d.ts.map +1 -1
- package/dist/utils/plainDate.js +15 -9
- package/dist/utils/sharedMutationObserver.d.ts +21 -0
- package/dist/utils/sharedMutationObserver.d.ts.map +1 -0
- package/dist/utils/sharedMutationObserver.js +69 -0
- package/locales/en.json +444 -0
- package/locales/pseudo.json +333 -0
- package/package.json +9 -4
- package/src/AspectRatio/AspectRatio.test.tsx +44 -43
- package/src/AspectRatio/AspectRatio.tsx +38 -18
- package/src/AspectRatio/__tests__/AspectRatioFitLayers.a11y.browser.spec.ts +157 -0
- package/src/Button/Button.doc.mjs +2 -2
- package/src/Button/Button.test.tsx +155 -9
- package/src/Button/Button.tsx +39 -16
- package/src/Button/__tests__/Button.a11y.known-failures.ts +1 -62
- package/src/Button/__tests__/Button.a11y.states.ts +0 -10
- package/src/CheckboxInput/CheckboxInput.test.tsx +34 -0
- package/src/CheckboxInput/CheckboxInput.tsx +3 -1
- package/src/CheckboxList/CheckboxList.test.tsx +22 -0
- package/src/CheckboxList/CheckboxListItem.doc.mjs +16 -0
- package/src/CheckboxList/CheckboxListItem.tsx +10 -0
- package/src/Dialog/Dialog.test.tsx +46 -0
- package/src/Dialog/Dialog.tsx +20 -7
- package/src/Dialog/__tests__/Dialog.a11y.known-failures.ts +0 -14
- package/src/Drawer/Drawer.doc.mjs +472 -0
- package/src/Drawer/Drawer.spec.md +357 -0
- package/src/Drawer/Drawer.test.tsx +1300 -0
- package/src/Drawer/Drawer.tsx +613 -0
- package/src/Drawer/DrawerDirection.test.tsx +127 -0
- package/src/Drawer/DrawerHeader.doc.mjs +293 -0
- package/src/Drawer/DrawerHeader.test.tsx +102 -0
- package/src/Drawer/DrawerHeader.tsx +235 -0
- package/src/Drawer/__tests__/DrawerAudit.a11y.chromium.spec.ts +401 -0
- package/src/Drawer/__tests__/DrawerHeaderAudit.a11y.chromium.spec.ts +297 -0
- package/src/Drawer/index.ts +13 -0
- package/src/Drawer/useDrawerDialogPresence.ts +284 -0
- package/src/DropdownMenu/DropdownMenu.test.tsx +21 -12
- package/src/DropdownMenu/DropdownMenu.tsx +2 -2
- package/src/DropdownMenu/DropdownMenuDivider.doc.mjs +2 -2
- package/src/DropdownMenu/DropdownMenuDivider.tsx +9 -5
- package/src/DropdownMenu/DropdownMenuSubMenu.tsx +2 -2
- package/src/DropdownMenu/__tests__/Menu.a11y.chromium.spec.ts +145 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.known-failures.ts +26 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.renders.tsx +65 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.states.ts +138 -0
- package/src/DropdownMenu/__tests__/Menu.a11y.test.tsx +136 -0
- package/src/EmptyState/EmptyState.doc.mjs +3 -2
- package/src/EmptyState/EmptyState.spec.md +189 -0
- package/src/EmptyState/EmptyState.test.tsx +74 -3
- package/src/EmptyState/EmptyState.tsx +4 -8
- package/src/Field/Field.doc.mjs +14 -8
- package/src/Field/Field.spec.md +217 -0
- package/src/Field/Field.test.tsx +60 -2
- package/src/Field/Field.tsx +17 -8
- package/src/HoverCard/HoverCard.test.tsx +58 -0
- package/src/HoverCard/useHoverCard.tsx +10 -2
- package/src/IconButton/IconButton.doc.mjs +2 -2
- package/src/IconButton/IconButton.test.tsx +3 -1
- package/src/Item/Item.doc.mjs +12 -8
- package/src/Item/Item.spec.md +226 -0
- package/src/Item/Item.test.tsx +61 -0
- package/src/Item/Item.tsx +40 -4
- package/src/Layer/layerViewportInset.source-build.test.mjs +90 -0
- package/src/Layer/layerViewportInset.stylex.ts +6 -2
- package/src/Layer/layerViewportInset.test.ts +1 -0
- package/src/Layer/useLayer.tsx +24 -13
- package/src/Layer/useLayerDismissal.ts +1 -1
- package/src/Layout/container.stylex.ts +6 -6
- package/src/List/List.doc.mjs +14 -1
- package/src/List/List.spec.md +129 -77
- package/src/List/List.test.tsx +163 -94
- package/src/List/List.tsx +74 -18
- package/src/List/ListContext.tsx +9 -3
- package/src/List/ListItem.doc.mjs +24 -5
- package/src/List/ListItem.tsx +56 -27
- package/src/List/index.ts +1 -1
- package/src/Markdown/Markdown.tsx +14 -1
- package/src/Markdown/plugins/frontmatter.test.tsx +25 -0
- package/src/Markdown/plugins/frontmatter.ts +7 -3
- package/src/MetadataList/MetadataList.doc.mjs +2 -2
- package/src/MetadataList/MetadataList.test.tsx +38 -0
- package/src/MetadataList/MetadataList.tsx +8 -1
- package/src/MetadataList/MetadataListContext.tsx +1 -1
- package/src/MultiSelector/MultiSelector.test.tsx +159 -0
- package/src/MultiSelector/MultiSelector.tsx +40 -7
- package/src/MultiSelector/OptionActions.a11y.chromium.spec.ts +112 -2
- package/src/MultiSelector/hooks.ts +3 -1
- package/src/MultiSelector/useMultiCombobox.doc.mjs +267 -0
- package/src/Pagination/Pagination.doc.mjs +7 -7
- package/src/Pagination/Pagination.spec.md +9 -9
- package/src/Pagination/Pagination.test.tsx +242 -0
- package/src/Pagination/Pagination.tsx +27 -11
- package/src/Popover/Popover.test.tsx +2 -2
- package/src/Popover/Popover.tsx +4 -4
- package/src/PowerSearch/PowerSearch.test.tsx +85 -0
- package/src/PowerSearch/PowerSearch.tsx +2 -2
- package/src/RadioList/RadioList.test.tsx +22 -0
- package/src/RadioList/RadioListItem.doc.mjs +16 -0
- package/src/RadioList/RadioListItem.tsx +10 -1
- package/src/Selector/hooks.ts +6 -2
- package/src/Selector/useCombobox.doc.mjs +237 -0
- package/src/Switch/Switch.test.tsx +49 -0
- package/src/Switch/Switch.tsx +11 -0
- package/src/TabList/TabList.spec.md +57 -44
- package/src/TabList/TabList.test.tsx +67 -0
- package/src/TabList/TabMenu.doc.mjs +4 -3
- package/src/TabList/TabMenu.tsx +7 -4
- package/src/Text/useTruncation.test.tsx +69 -0
- package/src/Text/useTruncation.ts +16 -5
- package/src/Tokenizer/Tokenizer.test.tsx +54 -1
- package/src/Tooltip/Tooltip.test.tsx +31 -0
- package/src/Tooltip/useTooltip.test.tsx +13 -0
- package/src/Tooltip/useTooltip.tsx +11 -0
- package/src/TreeList/TreeList.spec.md +29 -17
- package/src/Typeahead/BaseTypeahead.tsx +26 -0
- package/src/Typeahead/Typeahead.test.tsx +260 -2
- package/src/hooks/useEntryAnimation.doc.mjs +4 -4
- package/src/hooks/useEntryAnimation.ssr.test.tsx +143 -0
- package/src/hooks/useEntryAnimation.ts +15 -16
- package/src/hooks/useIsHydrating.test.tsx +70 -0
- package/src/hooks/useIsHydrating.ts +31 -0
- package/src/i18n/InternationalizationProvider.doc.mjs +8 -0
- package/src/i18n/InternationalizationProvider.spec.md +252 -0
- package/src/i18n/__tests__/InternationalizationProvider.test.tsx +128 -0
- package/src/i18n/generated-locales/en.generated.ts +121 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +121 -0
- package/src/i18n/useTranslator.test.tsx +37 -0
- package/src/index.ts +1 -0
- package/src/reset.css +0 -29
- package/src/theme/derivedVarRegistry.test.ts +3 -3
- package/src/theme/derivedVarRegistry.ts +0 -3
- package/src/utils/focusOutline.stylex.ts +4 -0
- package/src/utils/plainDate.test.ts +37 -1
- package/src/utils/plainDate.ts +15 -5
- package/src/utils/sharedMutationObserver.test.ts +53 -0
- package/src/utils/sharedMutationObserver.ts +78 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/** @type {import('@astryxdesign/cli/authoring').HookDoc} */
|
|
4
|
+
export const docs = {
|
|
5
|
+
name: 'useCombobox',
|
|
6
|
+
displayName: 'useCombobox',
|
|
7
|
+
group: 'Selector',
|
|
8
|
+
keywords: [
|
|
9
|
+
'combobox',
|
|
10
|
+
'listbox',
|
|
11
|
+
'select',
|
|
12
|
+
'dropdown',
|
|
13
|
+
'highlight',
|
|
14
|
+
'active option',
|
|
15
|
+
'aria-activedescendant',
|
|
16
|
+
'keyboard',
|
|
17
|
+
'arrow keys',
|
|
18
|
+
'headless',
|
|
19
|
+
'apg',
|
|
20
|
+
'accessibility',
|
|
21
|
+
'a11y',
|
|
22
|
+
],
|
|
23
|
+
params: [
|
|
24
|
+
{
|
|
25
|
+
name: 'options',
|
|
26
|
+
type: 'UseComboboxOptions',
|
|
27
|
+
description: 'Configuration object.',
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'options.selectableItems',
|
|
32
|
+
type: 'SelectorOptionData[]',
|
|
33
|
+
description:
|
|
34
|
+
'The options in the same order as they render. Options with `disabled` cannot be picked and are skipped while moving through the open list; ArrowDown or ArrowUp that opens the list still lands on the first or last option.',
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'options.isOpen',
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
description: 'Whether the list is shown. The caller owns this state.',
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'options.onOpen',
|
|
45
|
+
type: '() => unknown',
|
|
46
|
+
description:
|
|
47
|
+
'Called to show the list. Return `false` to refuse; the hook then leaves the highlight alone.',
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'options.onClose',
|
|
52
|
+
type: '() => void',
|
|
53
|
+
description:
|
|
54
|
+
'Called when the hook hides the list; the hook resets the highlight first. When the caller closes the list itself (an outside press, say), it should also call `setHighlightedIndex(-1)`.',
|
|
55
|
+
required: true,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'options.listboxId',
|
|
59
|
+
type: 'string',
|
|
60
|
+
description:
|
|
61
|
+
"The listbox element's id. Option ids are derived from it through `getItemId`.",
|
|
62
|
+
required: true,
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'options.value',
|
|
66
|
+
type: 'string',
|
|
67
|
+
description:
|
|
68
|
+
'The selected value. Without search, opening by a press, Enter or Space highlights it, or the first option when nothing is selected; ArrowDown and ArrowUp open on the first and last option.',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'options.onSelect',
|
|
72
|
+
type: '(value: string) => void',
|
|
73
|
+
description:
|
|
74
|
+
'Called with the picked value. Picking also closes the list.',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'options.onClear',
|
|
78
|
+
type: '() => void',
|
|
79
|
+
description:
|
|
80
|
+
'Clears the value. When provided, Delete or Backspace on the closed control clears it, so clearing is not pointer-only. Ignored while the list is open or with `hasSearch`.',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'options.hasSearch',
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
description:
|
|
86
|
+
'Whether the list has its own search field. Space then types instead of picking, opening by a press or Enter does not pre-highlight (ArrowDown and ArrowUp still open on the first and last option), and printable keys on the closed control go to `onSearchSeed`.',
|
|
87
|
+
default: 'false',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'options.onSearchSeed',
|
|
91
|
+
type: '(char: string) => void',
|
|
92
|
+
description:
|
|
93
|
+
'With `hasSearch`, receives each printable character except Space typed while the control has focus, opening the list first when it is closed, so type-to-find needs no separate open step.',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'options.isDisabled',
|
|
97
|
+
type: 'boolean',
|
|
98
|
+
description: 'Whether the control ignores clicks and keys.',
|
|
99
|
+
default: 'false',
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
returns: [
|
|
103
|
+
{
|
|
104
|
+
name: 'highlightedIndex',
|
|
105
|
+
type: 'number',
|
|
106
|
+
description:
|
|
107
|
+
'Index of the active option, or -1 when none is active. With `hasSearch`, opening by a press or Enter does not set one, so it stays -1 after the hook itself closes the list; ArrowDown and ArrowUp still open on the first or last option. Render it as the active option and name it in `aria-activedescendant` only while it points at a rendered option.',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'setHighlightedIndex',
|
|
111
|
+
type: '(index: number) => void',
|
|
112
|
+
description:
|
|
113
|
+
'Sets the active option, for example from a filter that changes the options.',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'getItemId',
|
|
117
|
+
type: '(index: number) => string',
|
|
118
|
+
description:
|
|
119
|
+
"The id to render on the option at `index`. Set the control's `aria-activedescendant` to `isOpen && highlightedIndex >= 0 && highlightedIndex < selectableItems.length ? getItemId(highlightedIndex) : undefined`, so it never names an option that does not exist, including in an empty list.",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'onTriggerClick',
|
|
123
|
+
type: '() => void',
|
|
124
|
+
description: 'Toggles the list from a press on the control.',
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'onKeyDown',
|
|
128
|
+
type: '(e: React.KeyboardEvent) => void',
|
|
129
|
+
description:
|
|
130
|
+
'Key handler for the control that keeps focus. ArrowDown and ArrowUp open the list or move the active option; Enter (and Space without search) picks it or opens the list; Escape and Tab close it; Home, End, PageUp and PageDown jump to the first or last option. An editable control that keeps Home and End for the caret does not pass them to this handler, as CommandPalette does.',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'onItemSelect',
|
|
134
|
+
type: '(item: SelectorOptionData) => void',
|
|
135
|
+
description: 'Picks an option from a press on it, then closes the list.',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'onItemMouseEnter',
|
|
139
|
+
type: '(item: SelectorOptionData, index: number) => void',
|
|
140
|
+
description:
|
|
141
|
+
'Makes the hovered option active without scrolling the list or moving focus.',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
usage: {
|
|
145
|
+
description:
|
|
146
|
+
'Tracks the active option of a single-select combobox and handles its keys, while DOM focus stays on the control. It powers Selector and CommandPalette; use it to build a combobox those components do not cover. It renders nothing and sets no attributes: the caller renders the control, the listbox and the options, and wires `role`, `aria-expanded`, `aria-controls` and `aria-activedescendant` from what it returns.',
|
|
147
|
+
bestPractices: [
|
|
148
|
+
{
|
|
149
|
+
guidance: true,
|
|
150
|
+
description:
|
|
151
|
+
"Render each option with `id={getItemId(index)}` and set the control's `aria-activedescendant` only while `isOpen` and `highlightedIndex` points at a rendered option, as CommandPalette does.",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
guidance: true,
|
|
155
|
+
description:
|
|
156
|
+
"For type-to-select without a search field, run useTypeahead's handler first and fall through to this `onKeyDown` when it returns false, as Selector does.",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
guidance: true,
|
|
160
|
+
description:
|
|
161
|
+
'Announce the number of results through useAnnounce when the options change for a new query.',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
guidance: false,
|
|
165
|
+
description:
|
|
166
|
+
'Move DOM focus onto the options; the active option is announced through `aria-activedescendant` while focus stays on the control.',
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
},
|
|
170
|
+
relatedComponents: ['Selector', 'CommandPalette'],
|
|
171
|
+
relatedHooks: ['useMultiCombobox', 'useTypeahead', 'useAnnounce'],
|
|
172
|
+
importPath: '@astryxdesign/core/Selector',
|
|
173
|
+
category: 'focus',
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
/** @type {import('@astryxdesign/cli/authoring').HookTranslationDoc} */
|
|
177
|
+
export const docsDense = {
|
|
178
|
+
description:
|
|
179
|
+
'Single-select combobox state + keys; focus stays on control. Powers Selector / CommandPalette. Renders nothing, sets no attrs: caller renders control / listbox / options and wires role, aria-expanded, aria-controls, aria-activedescendant.',
|
|
180
|
+
paramDescriptions: {
|
|
181
|
+
options: 'config.',
|
|
182
|
+
'options.selectableItems':
|
|
183
|
+
'options in render order; disabled ones not pickable, skipped while moving in open list (ArrowDown/Up opening still lands first / last).',
|
|
184
|
+
'options.isOpen': 'list shown; caller owns state.',
|
|
185
|
+
'options.onOpen':
|
|
186
|
+
'show list; return false to refuse (highlight untouched).',
|
|
187
|
+
'options.onClose':
|
|
188
|
+
'hook hides list; resets highlight first. caller closing itself (outside press): also setHighlightedIndex(-1).',
|
|
189
|
+
'options.listboxId': 'listbox id; option ids derive from it (getItemId).',
|
|
190
|
+
'options.value':
|
|
191
|
+
'selected value; w/o search, press / Enter / Space opening highlights it (else first); ArrowDown/Up open on first / last.',
|
|
192
|
+
'options.onSelect': 'called w/ picked value; picking closes.',
|
|
193
|
+
'options.onClear':
|
|
194
|
+
'clears value; Delete / Backspace on closed control. ignored when open or hasSearch.',
|
|
195
|
+
'options.hasSearch':
|
|
196
|
+
'list has own search field: Space types, press / Enter opening does not pre-highlight (ArrowDown/Up still first / last), printable keys on closed control -> onSearchSeed.',
|
|
197
|
+
'options.onSearchSeed':
|
|
198
|
+
'w/ hasSearch, each printable char except Space typed while control focused (opens first if closed).',
|
|
199
|
+
'options.isDisabled': 'ignore clicks + keys.',
|
|
200
|
+
},
|
|
201
|
+
returnDescriptions: {
|
|
202
|
+
highlightedIndex:
|
|
203
|
+
'active option index, -1 = none. hasSearch: press / Enter opening sets none (stays -1 after hook closes); ArrowDown/Up still first / last. name in aria-activedescendant only when it points at a rendered option.',
|
|
204
|
+
setHighlightedIndex: 'set active option (e.g. after filtering).',
|
|
205
|
+
getItemId:
|
|
206
|
+
'id for option at index; aria-activedescendant = isOpen && highlightedIndex >= 0 && highlightedIndex < selectableItems.length ? getItemId(highlightedIndex) : undefined (empty list safe).',
|
|
207
|
+
onTriggerClick: 'toggle list from a press on control.',
|
|
208
|
+
onKeyDown:
|
|
209
|
+
'control keydown: ArrowDown/Up open or move; Enter (Space w/o search) picks or opens; Escape / Tab close; Home / End / PageUp / PageDown jump. editable control keeping Home / End for caret: do not pass them.',
|
|
210
|
+
onItemSelect: 'pick from a press, then close.',
|
|
211
|
+
onItemMouseEnter: 'hover makes option active; no scroll, no focus move.',
|
|
212
|
+
},
|
|
213
|
+
usage: {
|
|
214
|
+
description:
|
|
215
|
+
'Headless single-select combobox: active option + keys, focus stays on control. Caller renders + wires ARIA.',
|
|
216
|
+
bestPractices: [
|
|
217
|
+
{
|
|
218
|
+
guidance: true,
|
|
219
|
+
description:
|
|
220
|
+
'Option id = getItemId(index); aria-activedescendant only while open and highlightedIndex points at a rendered option.',
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
guidance: true,
|
|
224
|
+
description:
|
|
225
|
+
'Type-to-select w/o search: run useTypeahead first, fall through when it returns false.',
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
guidance: true,
|
|
229
|
+
description: 'Announce result count via useAnnounce on new query.',
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
guidance: false,
|
|
233
|
+
description: 'Move DOM focus onto options; use aria-activedescendant.',
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
};
|
|
@@ -834,6 +834,55 @@ describe('Switch', () => {
|
|
|
834
834
|
expect(root).toHaveAttribute('id', 'switch-1');
|
|
835
835
|
expect(root).toHaveAttribute('aria-label', 'Toggle notifications');
|
|
836
836
|
});
|
|
837
|
+
|
|
838
|
+
it('composes a caller aria-describedby onto the switch control', () => {
|
|
839
|
+
const {container} = render(
|
|
840
|
+
<>
|
|
841
|
+
<p id="external-hint">Applies to every repository</p>
|
|
842
|
+
<Switch
|
|
843
|
+
label="Notifications"
|
|
844
|
+
description="Sends a daily digest"
|
|
845
|
+
value={false}
|
|
846
|
+
onChange={() => {}}
|
|
847
|
+
data-testid="my-switch"
|
|
848
|
+
aria-describedby="external-hint"
|
|
849
|
+
/>
|
|
850
|
+
</>,
|
|
851
|
+
);
|
|
852
|
+
const control = screen.getByRole('switch');
|
|
853
|
+
const description = screen.getByText('Sends a daily digest');
|
|
854
|
+
expect(control.getAttribute('aria-describedby')?.split(' ')).toEqual([
|
|
855
|
+
'external-hint',
|
|
856
|
+
description.id,
|
|
857
|
+
]);
|
|
858
|
+
expect(control).toHaveAccessibleDescription(
|
|
859
|
+
'Applies to every repository Sends a daily digest',
|
|
860
|
+
);
|
|
861
|
+
// The id reference lives on the control only, not on the field wrapper.
|
|
862
|
+
const root = container.querySelector('[data-testid="my-switch"]');
|
|
863
|
+
expect(root).not.toHaveAttribute('aria-describedby');
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
it('names the switch control from a caller aria-labelledby', () => {
|
|
867
|
+
const {container} = render(
|
|
868
|
+
<>
|
|
869
|
+
<span id="row-title">Release notes</span>
|
|
870
|
+
<Switch
|
|
871
|
+
label="Pin Release notes"
|
|
872
|
+
isLabelHidden
|
|
873
|
+
value={false}
|
|
874
|
+
onChange={() => {}}
|
|
875
|
+
data-testid="my-switch"
|
|
876
|
+
aria-labelledby="row-title"
|
|
877
|
+
/>
|
|
878
|
+
</>,
|
|
879
|
+
);
|
|
880
|
+
const control = screen.getByRole('switch', {name: 'Release notes'});
|
|
881
|
+
expect(control).toHaveAttribute('aria-labelledby', 'row-title');
|
|
882
|
+
// The id reference lives on the control only, not on the field wrapper.
|
|
883
|
+
const root = container.querySelector('[data-testid="my-switch"]');
|
|
884
|
+
expect(root).not.toHaveAttribute('aria-labelledby');
|
|
885
|
+
});
|
|
837
886
|
});
|
|
838
887
|
|
|
839
888
|
describe('pressed state', () => {
|
package/src/Switch/Switch.tsx
CHANGED
|
@@ -566,6 +566,8 @@ export function Switch({
|
|
|
566
566
|
className,
|
|
567
567
|
style,
|
|
568
568
|
ref,
|
|
569
|
+
'aria-describedby': ariaDescribedByProp,
|
|
570
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
569
571
|
...rest
|
|
570
572
|
}: SwitchProps) {
|
|
571
573
|
const t = useTranslator();
|
|
@@ -610,7 +612,12 @@ export function Switch({
|
|
|
610
612
|
// Only include descriptionID when the element actually renders.
|
|
611
613
|
// FieldLabel renders the description (with descriptionID) even when the
|
|
612
614
|
// label is visually hidden — it's sr-only, so keep it linked.
|
|
615
|
+
// A consumer's own `aria-describedby` describes the control, so it comes
|
|
616
|
+
// first here rather than landing on the field wrapper via `...rest`.
|
|
613
617
|
const describedByParts: string[] = [];
|
|
618
|
+
if (ariaDescribedByProp) {
|
|
619
|
+
describedByParts.push(ariaDescribedByProp);
|
|
620
|
+
}
|
|
614
621
|
if (description) {
|
|
615
622
|
describedByParts.push(descriptionID);
|
|
616
623
|
}
|
|
@@ -658,6 +665,10 @@ export function Switch({
|
|
|
658
665
|
}}
|
|
659
666
|
onFocus={onFocus}
|
|
660
667
|
onBlur={onBlur}
|
|
668
|
+
// A caller's `aria-labelledby` names the control (a visible title
|
|
669
|
+
// elsewhere in the row, for example), so it reaches the input rather
|
|
670
|
+
// than the field wrapper via `...rest`.
|
|
671
|
+
aria-labelledby={ariaLabelledByProp}
|
|
661
672
|
aria-describedby={ariaDescribedBy}
|
|
662
673
|
aria-invalid={status?.type === 'error' ? true : undefined}
|
|
663
674
|
aria-busy={isBusy || undefined}
|
|
@@ -31,10 +31,10 @@ system_specs: [spec:AST-002/DEC-1, spec:AST-002/DEC-2, spec:AST-017/DEC-1]
|
|
|
31
31
|
|
|
32
32
|
| Area | Contract |
|
|
33
33
|
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
34
|
-
| Public contract | Canonicalize the existing
|
|
34
|
+
| Public contract | Canonicalize the existing mode as `edge?: 'padded' \| 'bleed'` (default `'padded'`) from the shared `edge` vocabulary; deprecate `isFullBleed` as an alias of `edge="bleed"` and remove it in the next minor release. |
|
|
35
35
|
| Behavior | Move first and last visible tab content toward the host content line, reaching it when the host inset is at least the edge-tab padding, while preserving tab interaction padding, focus-ring room, overflow controls, selection-indicator geometry, and the optional divider rail. |
|
|
36
36
|
| End-user impact | Edge tabs lose unnecessary extra inset where host geometry permits and remain fully interactive without clipped focus, selection, overflow, or divider treatment. |
|
|
37
|
-
| Builder impact | Existing `isFullBleed` callsites keep working during the deprecation window and migrate mechanically to `
|
|
37
|
+
| Builder impact | Existing `isFullBleed` callsites keep working during the deprecation window and migrate mechanically to `edge="bleed"`. |
|
|
38
38
|
| Compatibility/readiness | Current behavior is shipped; the canonical alias is additive, while removing the released legacy prop is a separately implemented breaking change in the next minor release. |
|
|
39
39
|
| Review checks | Reject a behavior change disguised as a rename, directional values without overflow/indicator proof, or early removal of the legacy prop. |
|
|
40
40
|
| Governing rules | `architecture:container-padding/INV9–INV11`; `spec:AST-002/DEC-1–DEC-2`; `spec:AST-017/DEC-1`. |
|
|
@@ -43,12 +43,13 @@ This table is a review projection; the body below is authoritative.
|
|
|
43
43
|
|
|
44
44
|
## Intent
|
|
45
45
|
|
|
46
|
-
TabList's current opt-in is edge
|
|
47
|
-
host inset, moves visible edge-tab content toward the surrounding content line,
|
|
46
|
+
TabList's current opt-in is the shared `bleed` edge treatment: it consumes the
|
|
47
|
+
full inherited host inset, moves visible edge-tab content toward the surrounding content line,
|
|
48
48
|
and retains Tab-owned interaction padding plus TabList-owned divider, overflow,
|
|
49
49
|
and indicator geometry. Content reaches the host line only when that inset is at
|
|
50
50
|
least the edge tab's own padding. The public `isFullBleed` name is misleading
|
|
51
|
-
because the strip
|
|
51
|
+
because the strip keeps a content line: it restores uncovered content inset
|
|
52
|
+
after the outer box expands, which `architecture:container-padding` names `bleed`.
|
|
52
53
|
|
|
53
54
|
## Compatibility and migration
|
|
54
55
|
|
|
@@ -61,21 +62,21 @@ because the strip restores uncovered content inset after the outer box expands.
|
|
|
61
62
|
|
|
62
63
|
During the compatibility window:
|
|
63
64
|
|
|
64
|
-
- `
|
|
65
|
-
- omitted `
|
|
65
|
+
- `edge="bleed"` is the canonical spelling, and omitted `edge` means `padded`;
|
|
66
|
+
- omitted `edge` plus `isFullBleed={true}` selects `bleed`;
|
|
66
67
|
- `isFullBleed` is deprecated and maintained examples use the canonical prop;
|
|
67
|
-
- if both props are supplied, explicit `
|
|
68
|
-
|
|
68
|
+
- if both props are supplied, explicit `edge` is canonical and the legacy
|
|
69
|
+
boolean cannot override it.
|
|
69
70
|
|
|
70
71
|
The removal release MUST include a `[breaking]` Changeset for
|
|
71
72
|
`@astryxdesign/core`, consumer release notes, and an `astryx upgrade` codemod that rewrites
|
|
72
|
-
`isFullBleed` to `
|
|
73
|
+
`isFullBleed` to `edge="bleed"`.
|
|
73
74
|
|
|
74
75
|
## Ownership boundary
|
|
75
76
|
|
|
76
77
|
**Owns**
|
|
77
78
|
|
|
78
|
-
- The TabList-wide edge
|
|
79
|
+
- The TabList-wide `bleed` edge treatment and its compatibility alias.
|
|
79
80
|
- The relationship between the outer TabList box, inner strip padding, edge tabs,
|
|
80
81
|
focus-ring room, overflow controls, and selection indicator.
|
|
81
82
|
- Which logical edges are supported by the public mode.
|
|
@@ -84,33 +85,34 @@ The removal release MUST include a `[breaking]` Changeset for
|
|
|
84
85
|
|
|
85
86
|
- Host padding publication, nesting, or overlay resets — owned by
|
|
86
87
|
`architecture:container-padding`.
|
|
87
|
-
- Button or List edge
|
|
88
|
-
-
|
|
88
|
+
- Button or List edge projections.
|
|
89
|
+
- The `flush` or `outset` values, or per-edge application, without separate
|
|
90
|
+
proof and owner approval.
|
|
89
91
|
- A change to navigation/tab semantics, selection state, keyboard behavior, or
|
|
90
92
|
overflow ownership.
|
|
91
93
|
|
|
92
94
|
## Public concepts
|
|
93
95
|
|
|
94
|
-
| Concept
|
|
95
|
-
|
|
|
96
|
-
| Edge
|
|
97
|
-
| Legacy alias
|
|
96
|
+
| Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
|
|
97
|
+
| -------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ | ------------------ | ------------------- | ------------------------------- | -------------------------------------------- |
|
|
98
|
+
| Edge treatment | omitted, `padded`, `bleed` | `bleed`: consume both inherited inline host insets and move edge-tab content toward the host lines while retaining local interaction and strip-owned geometry; `padded`: current default geometry | Navigation and tabs patterns across current layout/overflow states | omitted (`padded`) | `component:TabList` | accepted; canonical API pending | Other values are rejected by the public type |
|
|
99
|
+
| Legacy alias | omitted, `false`, `true` | Compatibility spelling for `padded` or `bleed` | Until the next minor release | omitted/`false` | `component:TabList` | deprecated | `true` maps to `bleed`; explicit `edge` wins |
|
|
98
100
|
|
|
99
101
|
## Behavioral and layout contract
|
|
100
102
|
|
|
101
|
-
| ID | Invariant
|
|
102
|
-
| --- |
|
|
103
|
-
| FR1 | The current opt-in MUST remain
|
|
104
|
-
| FR2 | Compensation MUST preserve Tab interaction padding, focus-ring room, overflow detection and controls, scroll access, selection-indicator geometry, and the optional divider rail's expanded inline span.
|
|
105
|
-
| FR3 | `
|
|
106
|
-
| FR4 | During the deprecation window, omitted `
|
|
107
|
-
| FR5 | `isFullBleed` MUST be removed in the next minor release only after maintained docs/examples use `
|
|
108
|
-
| FR6 | `
|
|
103
|
+
| ID | Invariant | Basis | Status |
|
|
104
|
+
| --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | -------------------------------------------------------- |
|
|
105
|
+
| FR1 | The current opt-in MUST remain the `bleed` treatment: the outer TabList box consumes the full inherited inline host inset and any `hasDivider` rail spans that expanded width; the inner strip restores `max(host inset - edge-tab padding, 0)` at each logical edge. Visible edge-tab content reaches the host line only when the host inset is at least the tab padding; otherwise it moves toward that line without crossing the host boundary. | Current source and `component:TabList/DEC-1` | Shipped behavior |
|
|
106
|
+
| FR2 | Compensation MUST preserve Tab interaction padding, focus-ring room, overflow detection and controls, scroll access, selection-indicator geometry, and the optional divider rail's expanded inline span. | Current source plus owner direction | Shipped behavior; expanded evidence required with rename |
|
|
107
|
+
| FR3 | `edge?: 'padded' \| 'bleed'` MUST become the canonical API, with `bleed` selecting FR1–FR2 geometry and `padded` the omitted default, without changing either. | `architecture:container-padding/INV10`; `component:TabList/DEC-1` | Accepted contract; implementation pending |
|
|
108
|
+
| FR4 | During the deprecation window, omitted `edge` plus `isFullBleed={true}` MUST produce the canonical `bleed` behavior. Explicit `edge` MUST remain authoritative when both props are supplied. | Compatibility decision | Accepted contract; implementation pending |
|
|
109
|
+
| FR5 | `isFullBleed` MUST be removed in the next minor release only after maintained docs/examples use `edge`, both paths have compatibility evidence, and the removal includes a `[breaking]` Changeset plus an `astryx upgrade` codemod for mechanical consumer migration. | `component:TabList/DEC-1`; `spec:AST-017/DEC-1` | Accepted contract; implementation pending |
|
|
110
|
+
| FR6 | `flush`, `outset`, and per-edge application MUST remain rejected until overflow, clipping, scroll-control, focus-ring, indicator, direction, and theme-padding evidence receives owner approval. | Shared edge vocabulary and TabList boundary | Accepted boundary |
|
|
109
111
|
|
|
110
112
|
### Allowed variation
|
|
111
113
|
|
|
112
114
|
- Layout, size, role, selected value, labels, tab content, and overflow mode may
|
|
113
|
-
vary while the same
|
|
115
|
+
vary while the same `bleed` meaning is preserved.
|
|
114
116
|
- The implementation may retain the current outer-box/inner-strip technique or
|
|
115
117
|
replace it with equivalent geometry that satisfies FR1–FR2.
|
|
116
118
|
- A host may be painted or bounded only where TabList's component-specific
|
|
@@ -118,20 +120,20 @@ The removal release MUST include a `[breaking]` Changeset for
|
|
|
118
120
|
|
|
119
121
|
### Representative states
|
|
120
122
|
|
|
121
|
-
| State
|
|
122
|
-
|
|
|
123
|
-
| Default/omitted
|
|
124
|
-
| Canonical
|
|
125
|
-
| Divider
|
|
126
|
-
| Legacy alias
|
|
127
|
-
| Overflowing strip
|
|
128
|
-
| Focused edge tab
|
|
123
|
+
| State | Required invariant | Allowed variation |
|
|
124
|
+
| ----------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- |
|
|
125
|
+
| Default/omitted | Current TabList box, strip, and tab geometry are unchanged. | Any current layout, role, or overflow mode. |
|
|
126
|
+
| Canonical `bleed` | Outer box consumes each host inset; edge content reaches the host line only when that inset is at least the tab padding. | Host inset smaller than, equal to, or larger than edge-tab padding; asymmetric insets; LTR/RTL. |
|
|
127
|
+
| Divider | `hasDivider` rail spans the expanded outer inline width. | Fitting or overflowing strips. |
|
|
128
|
+
| Legacy alias | `isFullBleed={true}` matches canonical `bleed` geometry during the compatibility window. | The canonical prop may also be present. |
|
|
129
|
+
| Overflowing strip | Scroll access, edge fades, controls, and selected-tab reveal remain correct. | Start/end overflow independently. |
|
|
130
|
+
| Focused edge tab | The focus ring remains visible and local to the tab. | Keyboard or pointer focus. |
|
|
129
131
|
|
|
130
132
|
### Transformation and precedence order
|
|
131
133
|
|
|
132
|
-
- **ORD1 — Public input.** Resolve explicit `
|
|
133
|
-
`isFullBleed={true}` to `
|
|
134
|
-
|
|
134
|
+
- **ORD1 — Public input.** Resolve explicit `edge`; otherwise map
|
|
135
|
+
`isFullBleed={true}` to `bleed` during the compatibility window; otherwise use
|
|
136
|
+
`padded`.
|
|
135
137
|
- **ORD2 — Host geometry.** Read the matching inherited logical host insets, with
|
|
136
138
|
missing values falling back to zero.
|
|
137
139
|
- **ORD3 — Component geometry.** Resolve edge-tab padding and focus/indicator
|
|
@@ -145,10 +147,10 @@ The removal release MUST include a `[breaking]` Changeset for
|
|
|
145
147
|
|
|
146
148
|
## Accessibility contract
|
|
147
149
|
|
|
148
|
-
- **AR1 — Interaction remains stable.**
|
|
150
|
+
- **AR1 — Interaction remains stable.** The `bleed` treatment MUST NOT change the
|
|
149
151
|
tab/nav pattern, accessible names, selected state, keyboard movement, tab stop,
|
|
150
152
|
focus target, or controlled value behavior.
|
|
151
|
-
- **AR2 — Overflow remains reachable.**
|
|
153
|
+
- **AR2 — Overflow remains reachable.** `bleed` geometry MUST NOT clip or
|
|
152
154
|
hide a focus ring, selected indicator, visible tab content, or an overflow
|
|
153
155
|
control required to reach offscreen tabs.
|
|
154
156
|
|
|
@@ -162,8 +164,8 @@ The removal release MUST include a `[breaking]` Changeset for
|
|
|
162
164
|
|
|
163
165
|
## Family and system relationships
|
|
164
166
|
|
|
165
|
-
- `architecture:container-padding` owns host publication, the shared
|
|
166
|
-
|
|
167
|
+
- `architecture:container-padding` owns host publication, the shared `edge`
|
|
168
|
+
vocabulary, logical-edge semantics, and overlay reset.
|
|
167
169
|
- `architecture:public-component-api` and `spec:AST-002` own public API
|
|
168
170
|
admission; `spec:AST-017/DEC-1` owns the breaking classification and migration
|
|
169
171
|
evidence required when the released alias is removed.
|
|
@@ -189,9 +191,20 @@ TabList's current mode consumes the full inherited inline host inset, keeps an
|
|
|
189
191
|
optional divider across that expanded width, and restores only the portion of
|
|
190
192
|
content inset not already supplied by edge-tab padding. The user-facing intent is
|
|
191
193
|
therefore edge compensation, not a promise that tab content itself reaches an
|
|
192
|
-
outer edge.
|
|
193
|
-
|
|
194
|
-
|
|
194
|
+
outer edge. DEC-2 sets the canonical spelling; `isFullBleed` remains a
|
|
195
|
+
compatibility alias until its `[breaking]` next-minor removal, with the required
|
|
196
|
+
codemod and release evidence.
|
|
197
|
+
|
|
198
|
+
### DEC-2 — TabList spells its mode with the shared edge vocabulary
|
|
199
|
+
|
|
200
|
+
**Reference:** `component:TabList/DEC-2`
|
|
201
|
+
|
|
202
|
+
**Decider:** cixzhang, 2026-10-16
|
|
203
|
+
|
|
204
|
+
`architecture:container-padding` names TabList's geometry `bleed`: paint reaches
|
|
205
|
+
the host's padding edge and content stays on the host content line, or at the
|
|
206
|
+
edge tab's own padding when the host inset is smaller. `edge="bleed"` is the
|
|
207
|
+
canonical spelling, so TabList and List share one prop name and one value set.
|
|
195
208
|
|
|
196
209
|
## Open questions
|
|
197
210
|
|
|
@@ -783,6 +783,73 @@ describe('TabMenu', () => {
|
|
|
783
783
|
});
|
|
784
784
|
});
|
|
785
785
|
|
|
786
|
+
describe('TabMenu host attributes', () => {
|
|
787
|
+
const menuOptions = [
|
|
788
|
+
{value: 'analytics', label: 'Analytics'},
|
|
789
|
+
{value: 'reports', label: 'Reports'},
|
|
790
|
+
];
|
|
791
|
+
|
|
792
|
+
it('forwards host attributes to the trigger, not the popup', () => {
|
|
793
|
+
render(
|
|
794
|
+
<TabList value="home" onChange={() => {}}>
|
|
795
|
+
<Tab value="home" label="Home" />
|
|
796
|
+
<TabMenu
|
|
797
|
+
label="More"
|
|
798
|
+
options={menuOptions}
|
|
799
|
+
id="more-tabs"
|
|
800
|
+
aria-label="More views"
|
|
801
|
+
data-view="overflow"
|
|
802
|
+
/>
|
|
803
|
+
</TabList>,
|
|
804
|
+
);
|
|
805
|
+
|
|
806
|
+
const trigger = screen.getByRole('button', {name: 'More views'});
|
|
807
|
+
expect(trigger).toHaveAttribute('id', 'more-tabs');
|
|
808
|
+
expect(trigger).toHaveAttribute('data-view', 'overflow');
|
|
809
|
+
const menu = screen.getByRole('menu', {name: 'More', hidden: true});
|
|
810
|
+
expect(trigger).toHaveAttribute('aria-controls', menu.id);
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
it('runs drag-and-drop handlers on the trigger', () => {
|
|
814
|
+
const onDragOver = vi.fn();
|
|
815
|
+
const onDrop = vi.fn();
|
|
816
|
+
render(
|
|
817
|
+
<TabList value="home" onChange={() => {}}>
|
|
818
|
+
<Tab value="home" label="Home" />
|
|
819
|
+
<TabMenu
|
|
820
|
+
label="More"
|
|
821
|
+
options={menuOptions}
|
|
822
|
+
onDragOver={onDragOver}
|
|
823
|
+
onDrop={onDrop}
|
|
824
|
+
/>
|
|
825
|
+
</TabList>,
|
|
826
|
+
);
|
|
827
|
+
const trigger = screen.getByRole('button', {name: 'More'});
|
|
828
|
+
fireEvent.dragOver(trigger);
|
|
829
|
+
fireEvent.drop(trigger);
|
|
830
|
+
expect(onDragOver).toHaveBeenCalledTimes(1);
|
|
831
|
+
expect(onDrop).toHaveBeenCalledTimes(1);
|
|
832
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
it('onClick preserves the toggle', async () => {
|
|
836
|
+
const user = userEvent.setup();
|
|
837
|
+
const onClick = vi.fn((event: React.MouseEvent<HTMLButtonElement>) => {
|
|
838
|
+
event.preventDefault();
|
|
839
|
+
});
|
|
840
|
+
render(
|
|
841
|
+
<TabList value="home" onChange={() => {}}>
|
|
842
|
+
<Tab value="home" label="Home" />
|
|
843
|
+
<TabMenu label="More" options={menuOptions} onClick={onClick} />
|
|
844
|
+
</TabList>,
|
|
845
|
+
);
|
|
846
|
+
const trigger = screen.getByRole('button', {name: 'More'});
|
|
847
|
+
await user.click(trigger);
|
|
848
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
849
|
+
expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
850
|
+
});
|
|
851
|
+
});
|
|
852
|
+
|
|
786
853
|
describe('TabMenu keyboard navigation (roving tabindex)', () => {
|
|
787
854
|
const menuOptions = [
|
|
788
855
|
{value: 'analytics', label: 'Analytics'},
|
|
@@ -7,7 +7,7 @@ export const docs = {
|
|
|
7
7
|
subComponentOf: 'TabList',
|
|
8
8
|
displayName: 'Tab Menu',
|
|
9
9
|
isHiddenFromOverview: true,
|
|
10
|
-
description: "Overflow menu trigger that opens a dropdown of additional tab options, showing the selected option's label as the trigger text.",
|
|
10
|
+
description: "Overflow menu trigger that opens a dropdown of additional tab options, showing the selected option's label as the trigger text. Host attributes and DOM event handlers (id, aria-*, data-*, drag and drop) reach the trigger button, not the popup or its options. The button keeps its role, tab stop, and menu disclosure attributes.",
|
|
11
11
|
// TabMenu requires TabList context; wrap it so the preview doesn't throw.
|
|
12
12
|
// The wrapper value matches none of the options, so the trigger shows its
|
|
13
13
|
// own label (the idle overflow state).
|
|
@@ -42,7 +42,7 @@ export const docsZh = {
|
|
|
42
42
|
name: 'TabMenu',
|
|
43
43
|
isHiddenFromOverview: true,
|
|
44
44
|
displayName: 'Tab Menu',
|
|
45
|
-
description: '
|
|
45
|
+
description: '溢出菜单触发器,打开包含额外标签选项的下拉菜单,将选中选项的标签显示为触发器文本。宿主属性和 DOM 事件处理器(id、aria-*、data-*、拖放)传递给触发按钮,而不是弹出菜单或选项。按钮保留自己的角色、Tab 停靠点及菜单展开属性。',
|
|
46
46
|
props: [
|
|
47
47
|
{
|
|
48
48
|
name: 'label',
|
|
@@ -63,7 +63,8 @@ export const docsDense = {
|
|
|
63
63
|
name: 'TabMenu',
|
|
64
64
|
isHiddenFromOverview: true,
|
|
65
65
|
displayName: 'Tab Menu',
|
|
66
|
-
description:
|
|
66
|
+
description:
|
|
67
|
+
"Overflow menu trigger; shows selected option's label. Host attributes/DOM handlers reach the trigger button, not the popup/options; role, tab stop and disclosure attributes stay owned.",
|
|
67
68
|
propDescriptions: {
|
|
68
69
|
label: 'Trigger text (when no option selected) + dropdown heading.',
|
|
69
70
|
options: 'Menu options array rendered in dropdown.',
|