@astryxdesign/core 0.7.6-canary.eecd9c1 → 0.7.6-canary.f73623d
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/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +28 -19
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +27 -0
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +10 -3
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +5 -2
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +36 -10
- package/dist/Table/plugins/sortable/useTableSortable.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortable.js +46 -58
- package/dist/ToggleButton/ToggleButtonGroup.d.ts +7 -1
- package/dist/ToggleButton/ToggleButtonGroup.d.ts.map +1 -1
- package/dist/ToggleButton/ToggleButtonGroup.js +16 -2
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +37 -5
- package/dist/Token/TokenLink.d.ts.map +1 -1
- package/dist/Token/TokenLink.js +14 -2
- package/dist/i18n/generated-locales/af-ZA.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/af-ZA.generated.js +0 -5
- package/dist/i18n/generated-locales/ar-SA.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/ar-SA.generated.js +0 -5
- package/dist/i18n/generated-locales/ca-ES.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/ca-ES.generated.js +0 -5
- package/dist/i18n/generated-locales/cs-CZ.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/cs-CZ.generated.js +0 -5
- package/dist/i18n/generated-locales/da-DK.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/da-DK.generated.js +0 -5
- package/dist/i18n/generated-locales/de-DE.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/de-DE.generated.js +0 -5
- package/dist/i18n/generated-locales/el-GR.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/el-GR.generated.js +0 -5
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +1 -5
- package/dist/i18n/generated-locales/es-ES.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/es-ES.generated.js +0 -5
- package/dist/i18n/generated-locales/fi-FI.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/fi-FI.generated.js +0 -5
- package/dist/i18n/generated-locales/fr-FR.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/fr-FR.generated.js +0 -5
- package/dist/i18n/generated-locales/he-IL.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/he-IL.generated.js +0 -5
- package/dist/i18n/generated-locales/hu-HU.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/hu-HU.generated.js +0 -5
- package/dist/i18n/generated-locales/it-IT.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/it-IT.generated.js +0 -5
- package/dist/i18n/generated-locales/ja-JP.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/ja-JP.generated.js +0 -5
- package/dist/i18n/generated-locales/ko-KR.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/ko-KR.generated.js +0 -5
- package/dist/i18n/generated-locales/nl-NL.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/nl-NL.generated.js +0 -5
- package/dist/i18n/generated-locales/no-NO.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/no-NO.generated.js +0 -5
- package/dist/i18n/generated-locales/pl-PL.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pl-PL.generated.js +0 -5
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +1 -5
- package/dist/i18n/generated-locales/pt-BR.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pt-BR.generated.js +0 -5
- package/dist/i18n/generated-locales/pt-PT.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pt-PT.generated.js +0 -5
- package/dist/i18n/generated-locales/ro-RO.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/ro-RO.generated.js +0 -5
- package/dist/i18n/generated-locales/ru-RU.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/ru-RU.generated.js +0 -5
- package/dist/i18n/generated-locales/sr-SP.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/sr-SP.generated.js +0 -5
- package/dist/i18n/generated-locales/sv-SE.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/sv-SE.generated.js +0 -5
- package/dist/i18n/generated-locales/tr-TR.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/tr-TR.generated.js +0 -5
- package/dist/i18n/generated-locales/uk-UA.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/uk-UA.generated.js +0 -5
- package/dist/i18n/generated-locales/vi-VN.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/vi-VN.generated.js +0 -5
- package/dist/i18n/generated-locales/zh-CN.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/zh-CN.generated.js +0 -5
- package/dist/i18n/generated-locales/zh-TW.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/zh-TW.generated.js +0 -5
- package/locales/af-ZA.json +0 -21
- package/locales/ar-SA.json +0 -21
- package/locales/ca-ES.json +0 -21
- package/locales/cs-CZ.json +0 -21
- package/locales/da-DK.json +0 -21
- package/locales/de-DE.json +0 -21
- package/locales/el-GR.json +0 -21
- package/locales/en.json +3 -19
- package/locales/es-ES.json +0 -21
- package/locales/fi-FI.json +0 -21
- package/locales/fr-FR.json +0 -21
- package/locales/he-IL.json +0 -21
- package/locales/hu-HU.json +0 -21
- package/locales/it-IT.json +0 -21
- package/locales/ja-JP.json +0 -21
- package/locales/ko-KR.json +0 -21
- package/locales/nl-NL.json +0 -21
- package/locales/no-NO.json +0 -21
- package/locales/pl-PL.json +0 -21
- package/locales/pseudo.json +2 -14
- package/locales/pt-BR.json +0 -21
- package/locales/pt-PT.json +0 -21
- package/locales/ro-RO.json +0 -21
- package/locales/ru-RU.json +0 -21
- package/locales/sr-SP.json +0 -21
- package/locales/sv-SE.json +0 -21
- package/locales/tr-TR.json +0 -21
- package/locales/uk-UA.json +0 -21
- package/locales/vi-VN.json +0 -21
- package/locales/zh-CN.json +0 -21
- package/locales/zh-TW.json +0 -21
- package/package.json +4 -4
- package/src/Chat/ChatLayout.spec.md +41 -36
- package/src/Chat/ChatLayoutScrollButton.spec.md +87 -103
- package/src/Chat/ChatSendButton.spec.md +78 -67
- package/src/ContextMenu/ContextMenu.spec.md +84 -56
- package/src/ContextMenu/ContextMenuItem.spec.md +132 -0
- package/src/DropdownMenu/DropdownMenu.spec.md +198 -218
- package/src/DropdownMenu/DropdownMenu.test.tsx +117 -0
- package/src/DropdownMenu/DropdownMenu.tsx +33 -18
- package/src/DropdownMenu/DropdownMenuCheckboxItem.spec.md +192 -0
- package/src/DropdownMenu/DropdownMenuDivider.spec.md +25 -31
- package/src/DropdownMenu/DropdownMenuGroup.spec.md +145 -0
- package/src/DropdownMenu/DropdownMenuItem.spec.md +48 -42
- package/src/DropdownMenu/DropdownMenuRadioGroup.spec.md +34 -37
- package/src/DropdownMenu/DropdownMenuRadioItem.spec.md +54 -53
- package/src/DropdownMenu/DropdownMenuSubMenu.spec.md +47 -41
- package/src/EmptyState/EmptyState.spec.md +35 -29
- package/src/Outline/Outline.spec.md +165 -69
- package/src/Outline/Outline.test.tsx +67 -2
- package/src/Outline/Outline.tsx +23 -0
- package/src/Outline/modules/parseOutlineFromMarkdown.spec.md +3 -4
- package/src/Popover/Popover.test.tsx +44 -0
- package/src/Popover/usePopover.tsx +10 -3
- package/src/RadioList/RadioList.test.tsx +56 -0
- package/src/RadioList/RadioListItem.tsx +5 -2
- package/src/Table/Table.spec.md +1 -1
- package/src/Table/Table.test.tsx +32 -0
- package/src/Table/Table.tsx +43 -11
- package/src/Table/__tests__/Table.a11y.states.ts +1 -5
- package/src/Table/plugins/sortable/useTableSortable.test.tsx +73 -144
- package/src/Table/plugins/sortable/useTableSortable.tsx +44 -73
- package/src/Table/plugins/sortable/useTableSortableState.test.tsx +9 -21
- package/src/ToggleButton/ToggleButton.test.tsx +27 -0
- package/src/ToggleButton/ToggleButtonGroup.tsx +20 -1
- package/src/Token/Token.doc.mjs +2 -2
- package/src/Token/Token.spec.md +41 -51
- package/src/Token/Token.test.tsx +67 -0
- package/src/Token/Token.tsx +60 -5
- package/src/Token/TokenLink.tsx +21 -7
- package/src/i18n/generated-locales/af-ZA.generated.ts +0 -7
- package/src/i18n/generated-locales/ar-SA.generated.ts +0 -6
- package/src/i18n/generated-locales/ca-ES.generated.ts +0 -7
- package/src/i18n/generated-locales/cs-CZ.generated.ts +0 -6
- package/src/i18n/generated-locales/da-DK.generated.ts +0 -6
- package/src/i18n/generated-locales/de-DE.generated.ts +0 -6
- package/src/i18n/generated-locales/el-GR.generated.ts +0 -7
- package/src/i18n/generated-locales/en.generated.ts +1 -6
- package/src/i18n/generated-locales/es-ES.generated.ts +0 -7
- package/src/i18n/generated-locales/fi-FI.generated.ts +0 -6
- package/src/i18n/generated-locales/fr-FR.generated.ts +0 -7
- package/src/i18n/generated-locales/he-IL.generated.ts +0 -6
- package/src/i18n/generated-locales/hu-HU.generated.ts +0 -6
- package/src/i18n/generated-locales/it-IT.generated.ts +0 -7
- package/src/i18n/generated-locales/ja-JP.generated.ts +0 -6
- package/src/i18n/generated-locales/ko-KR.generated.ts +0 -6
- package/src/i18n/generated-locales/nl-NL.generated.ts +0 -6
- package/src/i18n/generated-locales/no-NO.generated.ts +0 -6
- package/src/i18n/generated-locales/pl-PL.generated.ts +0 -7
- package/src/i18n/generated-locales/pseudo.generated.ts +1 -6
- package/src/i18n/generated-locales/pt-BR.generated.ts +0 -7
- package/src/i18n/generated-locales/pt-PT.generated.ts +0 -7
- package/src/i18n/generated-locales/ro-RO.generated.ts +0 -6
- package/src/i18n/generated-locales/ru-RU.generated.ts +0 -7
- package/src/i18n/generated-locales/sr-SP.generated.ts +0 -6
- package/src/i18n/generated-locales/sv-SE.generated.ts +0 -6
- package/src/i18n/generated-locales/tr-TR.generated.ts +0 -7
- package/src/i18n/generated-locales/uk-UA.generated.ts +0 -7
- package/src/i18n/generated-locales/vi-VN.generated.ts +0 -6
- package/src/i18n/generated-locales/zh-CN.generated.ts +0 -6
- package/src/i18n/generated-locales/zh-TW.generated.ts +0 -6
|
@@ -499,6 +499,62 @@ describe('RadioList', () => {
|
|
|
499
499
|
fireEvent.click(pro);
|
|
500
500
|
expect(onChange).not.toHaveBeenCalled();
|
|
501
501
|
});
|
|
502
|
+
|
|
503
|
+
it('does not run a caller onClick while focusable-disabled', () => {
|
|
504
|
+
const onClick = vi.fn();
|
|
505
|
+
render(
|
|
506
|
+
<RadioList
|
|
507
|
+
label="Plan"
|
|
508
|
+
value="free"
|
|
509
|
+
onChange={() => {}}
|
|
510
|
+
isDisabled
|
|
511
|
+
disabledMessage="Upgrade your account to change plans">
|
|
512
|
+
<RadioListItem label="Free" value="free" onClick={onClick} />
|
|
513
|
+
<RadioListItem label="Pro" value="pro" onClick={onClick} />
|
|
514
|
+
</RadioList>,
|
|
515
|
+
);
|
|
516
|
+
fireEvent.click(screen.getByRole('radio', {name: 'Pro', hidden: true}));
|
|
517
|
+
fireEvent.click(screen.getByRole('radio', {name: 'Free', hidden: true}));
|
|
518
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
it('does not run a caller onClick from the keyboard while focusable-disabled', async () => {
|
|
522
|
+
const user = userEvent.setup();
|
|
523
|
+
const onClick = vi.fn();
|
|
524
|
+
render(
|
|
525
|
+
<RadioList
|
|
526
|
+
label="Plan"
|
|
527
|
+
value="free"
|
|
528
|
+
onChange={() => {}}
|
|
529
|
+
isDisabled
|
|
530
|
+
disabledMessage="Upgrade your account to change plans">
|
|
531
|
+
<RadioListItem label="Free" value="free" onClick={onClick} />
|
|
532
|
+
<RadioListItem label="Pro" value="pro" onClick={onClick} />
|
|
533
|
+
</RadioList>,
|
|
534
|
+
);
|
|
535
|
+
await user.tab();
|
|
536
|
+
expect(
|
|
537
|
+
screen.getByRole('radio', {name: 'Free', hidden: true}),
|
|
538
|
+
).toHaveFocus();
|
|
539
|
+
// Space activates the focused radio.
|
|
540
|
+
await user.keyboard(' ');
|
|
541
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
542
|
+
// An arrow key moves onto the next radio, and the browser clicks it.
|
|
543
|
+
await user.keyboard('{ArrowDown}');
|
|
544
|
+
expect(onClick).not.toHaveBeenCalled();
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
it('still runs a caller onClick on an enabled radio', () => {
|
|
548
|
+
const onClick = vi.fn();
|
|
549
|
+
render(
|
|
550
|
+
<RadioList label="Plan" value="free" onChange={() => {}}>
|
|
551
|
+
<RadioListItem label="Free" value="free" />
|
|
552
|
+
<RadioListItem label="Pro" value="pro" onClick={onClick} />
|
|
553
|
+
</RadioList>,
|
|
554
|
+
);
|
|
555
|
+
fireEvent.click(screen.getByRole('radio', {name: 'Pro'}));
|
|
556
|
+
expect(onClick).toHaveBeenCalledTimes(1);
|
|
557
|
+
});
|
|
502
558
|
});
|
|
503
559
|
describe('form participation', () => {
|
|
504
560
|
it('submits the selected value under htmlName', () => {
|
|
@@ -340,8 +340,11 @@ export function RadioListItem({
|
|
|
340
340
|
}}
|
|
341
341
|
// A consumer onClick rides on the radio input itself, so it fires for
|
|
342
342
|
// both direct control clicks and row-surface clicks the row delegates
|
|
343
|
-
// to the input — the same routing CheckboxListItem uses.
|
|
344
|
-
|
|
343
|
+
// to the input — the same routing CheckboxListItem uses. A disabled
|
|
344
|
+
// radio that stays focusable (`aria-disabled`, not native `disabled`)
|
|
345
|
+
// is not silenced by the browser, so drop the handler here
|
|
346
|
+
// (`spec:AST-085` FR2), as CheckboxInput does.
|
|
347
|
+
onClick={isDisabled ? undefined : onClick}
|
|
345
348
|
// The radio names itself from the visible label element, which works
|
|
346
349
|
// for a rich label as well as a plain string. `aria-label` replaces
|
|
347
350
|
// that name rather than adding to it, so the two are mutually
|
package/src/Table/Table.spec.md
CHANGED
|
@@ -127,7 +127,7 @@ documented in `Table.doc.mjs` and the member and module docs.
|
|
|
127
127
|
|
|
128
128
|
| ID | Invariant | Basis | Evidence state |
|
|
129
129
|
| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
130
|
-
| FR1 | By default, Styled Table renders one named Scroll region around one observed content box and one semantic Table. The Scroll region enters the keyboard order and contains inline overscroll only while inline content effectively overflows; fitting content passes scroll gestures to its ancestor. Explicit scroll-wrapper plugin HTML attributes remain authoritative.
|
|
130
|
+
| FR1 | By default, Styled Table renders one named Scroll region around one observed content box and one semantic Table. The Scroll region takes the Table's own name (its `aria-labelledby`, else its `aria-label`), and a generic table name only when the Table has none. The Scroll region enters the keyboard order and contains inline overscroll only while inline content effectively overflows; fitting content passes scroll gestures to its ancestor. Explicit scroll-wrapper plugin HTML attributes remain authoritative. | `spec:AST-025` FR12, FR14, FR19, FR21; current source, docs, and tests | Verified fitting and inline-overflow transitions through the shared `useScrollableArea` behavior core |
|
|
131
131
|
| FR2 | Data-driven mode renders a Body section and a Header section with Column header cells when columns are present. Each data item renders a standard Row and Cells; an empty data array instead renders the configured empty-state row when enabled. It never creates a Footer section. | Current source, docs, and tests | Verified current behavior; no new behavior decided |
|
|
132
132
|
| FR3 | Children mode passes caller composition through to the Table. TableHeader, TableBody, and TableFooter provide the respective sections, and TableRow, TableHeaderCell, and TableCell provide standard rows and cells. | Current source, docs, and tests | Verified current composition; no new API or DOM rule |
|
|
133
133
|
| FR4 | `Table.doc.mjs` is the canonical aggregate consumer owner for the eight current targets: `table`, `table-scroll-wrapper`, `table-header`, `table-body`, `table-footer`, `table-row`, `table-cell`, and `table-header-cell`. Member docs retain direct lookup metadata through `subComponentOf: 'Table'`. | Current docs and CLI target tests | Verified parent ownership; focused placement coverage is partial |
|
package/src/Table/Table.test.tsx
CHANGED
|
@@ -961,6 +961,38 @@ describe('Table', () => {
|
|
|
961
961
|
expect(wrapper.style.overscrollBehaviorX).toBe('auto');
|
|
962
962
|
});
|
|
963
963
|
|
|
964
|
+
it('names the scroll region after its table, not a generic "Table" (AST-025)', () => {
|
|
965
|
+
render(
|
|
966
|
+
<>
|
|
967
|
+
<Table aria-label="Orders" data={users} columns={columns} />
|
|
968
|
+
<h2 id="refunds-title">Refunds</h2>
|
|
969
|
+
<Table aria-labelledby="refunds-title" data={users} columns={columns} />
|
|
970
|
+
<h2 id="returns-title">Returns</h2>
|
|
971
|
+
<Table
|
|
972
|
+
aria-label="Ignored label"
|
|
973
|
+
aria-labelledby="returns-title"
|
|
974
|
+
data={users}
|
|
975
|
+
columns={columns}
|
|
976
|
+
/>
|
|
977
|
+
<Table data={users} columns={columns} />
|
|
978
|
+
</>,
|
|
979
|
+
);
|
|
980
|
+
expect(screen.getByRole('group', {name: 'Orders'})).toBeInTheDocument();
|
|
981
|
+
expect(screen.getByRole('group', {name: 'Refunds'})).toHaveAttribute(
|
|
982
|
+
'aria-labelledby',
|
|
983
|
+
'refunds-title',
|
|
984
|
+
);
|
|
985
|
+
// With both, the region is named as the table is: by aria-labelledby.
|
|
986
|
+
expect(screen.getByRole('table', {name: 'Returns'})).toBeInTheDocument();
|
|
987
|
+
const returns = screen.getByRole('group', {name: 'Returns'});
|
|
988
|
+
expect(returns).not.toHaveAttribute('aria-label');
|
|
989
|
+
expect(
|
|
990
|
+
screen.queryByRole('group', {name: 'Ignored label'}),
|
|
991
|
+
).not.toBeInTheDocument();
|
|
992
|
+
// An unnamed table keeps the generic fallback.
|
|
993
|
+
expect(screen.getAllByRole('group', {name: 'Table'})).toHaveLength(1);
|
|
994
|
+
});
|
|
995
|
+
|
|
964
996
|
it('preserves scroll-wrapper HTML attributes from plugins', () => {
|
|
965
997
|
const plugin: TablePlugin<User> = {
|
|
966
998
|
transformScrollWrapper: props => ({
|
package/src/Table/Table.tsx
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* - /packages/cli/assets/templates/blocks/components/Table/ (showcase blocks)
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import {useMemo, type ReactElement, type Ref} from 'react';
|
|
20
|
+
import {createContext, use, useMemo, type ReactElement, type Ref} from 'react';
|
|
21
21
|
import * as stylex from '@stylexjs/stylex';
|
|
22
22
|
import {colorVars} from '../theme/tokens.stylex';
|
|
23
23
|
import {BaseTable} from './BaseTable';
|
|
@@ -135,6 +135,17 @@ const scrollWrapperStyles = stylex.create({
|
|
|
135
135
|
},
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* The Table's own name, for the scroll region that names itself after it.
|
|
140
|
+
* Internal to Table: the scroll wrapper is not given it as a prop, so it adds
|
|
141
|
+
* nothing to the public table types.
|
|
142
|
+
*/
|
|
143
|
+
const TableNameContext = createContext<{
|
|
144
|
+
label?: string;
|
|
145
|
+
labelledBy?: string;
|
|
146
|
+
} | null>(null);
|
|
147
|
+
TableNameContext.displayName = 'TableNameContext';
|
|
148
|
+
|
|
138
149
|
function TableScrollWrapper({
|
|
139
150
|
children,
|
|
140
151
|
htmlProps,
|
|
@@ -151,7 +162,17 @@ function TableScrollWrapper({
|
|
|
151
162
|
afterTable?: React.ReactNode;
|
|
152
163
|
}) {
|
|
153
164
|
const t = useTranslator();
|
|
154
|
-
const
|
|
165
|
+
const tableName = use(TableNameContext);
|
|
166
|
+
// The focusable scroll region takes the table's own name (spec:AST-025
|
|
167
|
+
// FR12), so two tables are not two groups both named "Table". It is named
|
|
168
|
+
// the way the table is: `aria-labelledby` wins over `aria-label`, as it does
|
|
169
|
+
// in accessible-name computation; the generic name is the fallback for an
|
|
170
|
+
// unnamed table.
|
|
171
|
+
const labelledBy = tableName?.labelledBy;
|
|
172
|
+
const label =
|
|
173
|
+
labelledBy != null
|
|
174
|
+
? undefined
|
|
175
|
+
: (tableName?.label ?? t('@astryx.table.label'));
|
|
155
176
|
const {getViewportProps, getContentProps, state} = useScrollableArea({
|
|
156
177
|
axis: 'inline',
|
|
157
178
|
keyboardAccess: {owner: 'content'},
|
|
@@ -161,6 +182,9 @@ function TableScrollWrapper({
|
|
|
161
182
|
const viewportProps = getViewportProps<HTMLDivElement>({
|
|
162
183
|
role: 'group',
|
|
163
184
|
'aria-label': label,
|
|
185
|
+
// A plugin's explicit name stays authoritative (Table FR1).
|
|
186
|
+
'aria-labelledby':
|
|
187
|
+
restHtmlProps['aria-label'] == null ? labelledBy : undefined,
|
|
164
188
|
...(state.inline.isScrollable ? {tabIndex: 0} : {}),
|
|
165
189
|
...restHtmlProps,
|
|
166
190
|
ref,
|
|
@@ -240,18 +264,26 @@ function TableInner<T extends Record<string, unknown>>({
|
|
|
240
264
|
}),
|
|
241
265
|
[density, dividers, isStriped, hasHover, verticalAlign, textOverflow],
|
|
242
266
|
);
|
|
267
|
+
const tableLabel = rest['aria-label'];
|
|
268
|
+
const tableLabelledBy = rest['aria-labelledby'];
|
|
269
|
+
const tableName = useMemo(
|
|
270
|
+
() => ({label: tableLabel, labelledBy: tableLabelledBy}),
|
|
271
|
+
[tableLabel, tableLabelledBy],
|
|
272
|
+
);
|
|
243
273
|
|
|
244
274
|
return (
|
|
245
275
|
<TableContext value={contextValue}>
|
|
246
|
-
<
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
276
|
+
<TableNameContext value={tableName}>
|
|
277
|
+
<BaseTable<T>
|
|
278
|
+
ref={ref}
|
|
279
|
+
data={data}
|
|
280
|
+
columns={columns}
|
|
281
|
+
plugins={mergedPlugins}
|
|
282
|
+
textOverflow={textOverflow}
|
|
283
|
+
scrollWrapper={TableScrollWrapper}
|
|
284
|
+
{...rest}
|
|
285
|
+
/>
|
|
286
|
+
</TableNameContext>
|
|
255
287
|
</TableContext>
|
|
256
288
|
);
|
|
257
289
|
}
|
|
@@ -51,11 +51,7 @@ export const TABLE_A11Y_STATES = [
|
|
|
51
51
|
modules: ['sort'],
|
|
52
52
|
facts: {
|
|
53
53
|
label: 'Team members',
|
|
54
|
-
columnHeaders: [
|
|
55
|
-
'Sort by Name, sorted descending',
|
|
56
|
-
'Sort by Role',
|
|
57
|
-
'Sort by Location',
|
|
58
|
-
],
|
|
54
|
+
columnHeaders: ['Name', 'Role', 'Location'],
|
|
59
55
|
rows: 3,
|
|
60
56
|
rowHeaders: [],
|
|
61
57
|
cells: 3,
|