@astryxdesign/core 0.1.2-canary.bfcbf64 → 0.1.2-canary.c395fca
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/Breadcrumbs/BreadcrumbItem.d.ts +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +4 -1
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +2 -4
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +33 -14
- package/dist/Calendar/hooks/index.d.ts +0 -2
- package/dist/Calendar/hooks/index.d.ts.map +1 -1
- package/dist/Calendar/hooks/index.js +1 -2
- package/dist/Calendar/index.d.ts +2 -2
- package/dist/Calendar/index.d.ts.map +1 -1
- package/dist/Calendar/index.js +1 -1
- package/dist/CheckboxList/CheckboxList.js +3 -3
- package/dist/Citation/Citation.d.ts.map +1 -1
- package/dist/Citation/Citation.js +3 -3
- package/dist/ContextMenu/ContextMenu.d.ts +1 -7
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +7 -13
- package/dist/DropdownMenu/DropdownMenu.d.ts +1 -8
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +4 -9
- package/dist/Field/Field.d.ts +4 -4
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +2 -2
- package/dist/Field/FieldLabel.d.ts +4 -4
- package/dist/Field/FieldLabel.d.ts.map +1 -1
- package/dist/Field/FieldLabel.js +2 -2
- package/dist/InputGroup/InputGroup.js +3 -3
- package/dist/Link/Link.d.ts.map +1 -1
- package/dist/Link/Link.js +2 -4
- package/dist/MoreMenu/MoreMenu.d.ts +1 -7
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +0 -2
- package/dist/MultiSelector/MultiSelector.d.ts +25 -2
- package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
- package/dist/MultiSelector/MultiSelector.js +31 -6
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +2 -4
- package/dist/RadioList/RadioList.js +3 -3
- package/dist/SegmentedControl/SegmentedControl.d.ts +1 -1
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +51 -61
- package/dist/Selector/Selector.d.ts +22 -1
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +31 -6
- package/dist/Switch/Switch.d.ts.map +1 -1
- package/dist/Switch/Switch.js +2 -4
- package/dist/TabList/TabList.d.ts +3 -2
- package/dist/TabList/TabList.d.ts.map +1 -1
- package/dist/TabList/TabList.js +55 -33
- package/dist/Table/tableContextMenu.d.ts.map +1 -1
- package/dist/Table/tableContextMenu.js +0 -3
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +2 -4
- package/dist/Toolbar/Toolbar.d.ts +3 -3
- package/dist/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/Toolbar/Toolbar.js +46 -6
- package/dist/TreeList/TreeList.d.ts.map +1 -1
- package/dist/TreeList/TreeList.js +16 -22
- package/dist/TreeList/TreeListItem.d.ts +3 -2
- package/dist/TreeList/TreeListItem.d.ts.map +1 -1
- package/dist/astryx.css +3 -0
- package/dist/astryx.umd.js +47 -47
- package/dist/astryx.umd.js.map +4 -4
- package/dist/hooks/index.d.ts +4 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/useGridFocus.d.ts +56 -0
- package/dist/hooks/useGridFocus.d.ts.map +1 -1
- package/dist/hooks/useGridFocus.js +138 -24
- package/dist/hooks/useKeyboardHint.d.ts +82 -0
- package/dist/hooks/useKeyboardHint.d.ts.map +1 -0
- package/dist/hooks/useKeyboardHint.js +220 -0
- package/dist/hooks/useTreeFocus.d.ts +27 -3
- package/dist/hooks/useTreeFocus.d.ts.map +1 -1
- package/dist/hooks/useTreeFocus.js +69 -6
- package/package.json +1 -1
- package/src/Breadcrumbs/BreadcrumbItem.tsx +5 -2
- package/src/Button/Button.tsx +3 -16
- package/src/Calendar/Calendar.tsx +52 -22
- package/src/Calendar/hooks/index.ts +0 -6
- package/src/Calendar/index.ts +0 -3
- package/src/CheckboxList/CheckboxList.tsx +3 -3
- package/src/Citation/Citation.doc.mjs +10 -0
- package/src/Citation/Citation.test.tsx +117 -0
- package/src/Citation/Citation.tsx +9 -1
- package/src/ContextMenu/ContextMenu.doc.mjs +0 -6
- package/src/ContextMenu/ContextMenu.test.tsx +4 -6
- package/src/ContextMenu/ContextMenu.tsx +7 -19
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -8
- package/src/DropdownMenu/DropdownMenu.test.tsx +0 -23
- package/src/DropdownMenu/DropdownMenu.tsx +4 -16
- package/src/Field/Field.test.tsx +2 -2
- package/src/Field/Field.tsx +5 -5
- package/src/Field/FieldLabel.tsx +5 -5
- package/src/InputGroup/InputGroup.tsx +3 -3
- package/src/Link/Link.tsx +2 -13
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -17
- package/src/MoreMenu/MoreMenu.tsx +0 -9
- package/src/MultiSelector/MultiSelector.doc.mjs +25 -0
- package/src/MultiSelector/MultiSelector.test.tsx +150 -1
- package/src/MultiSelector/MultiSelector.tsx +55 -3
- package/src/ProgressBar/ProgressBar.tsx +2 -3
- package/src/RadioList/RadioList.tsx +3 -3
- package/src/SegmentedControl/SegmentedControl.tsx +51 -77
- package/src/Selector/Selector.doc.mjs +21 -0
- package/src/Selector/Selector.test.tsx +123 -1
- package/src/Selector/Selector.tsx +53 -3
- package/src/Switch/Switch.tsx +2 -16
- package/src/TabList/TabList.test.tsx +41 -0
- package/src/TabList/TabList.tsx +66 -39
- package/src/Table/tableContextMenu.tsx +1 -5
- package/src/TextArea/TextArea.tsx +3 -13
- package/src/Toolbar/Toolbar.test.tsx +64 -6
- package/src/Toolbar/Toolbar.tsx +55 -4
- package/src/TreeList/TreeList.tsx +17 -28
- package/src/TreeList/TreeListItem.tsx +3 -2
- package/src/VisuallyHidden/VisuallyHidden.doc.mjs +7 -7
- package/src/hooks/index.ts +12 -5
- package/src/hooks/useGridFocus.doc.mjs +40 -2
- package/src/hooks/useGridFocus.test.tsx +132 -0
- package/src/hooks/useGridFocus.ts +179 -23
- package/src/hooks/useKeyboardHint.doc.mjs +101 -0
- package/src/hooks/useKeyboardHint.test.tsx +70 -0
- package/src/hooks/useKeyboardHint.tsx +332 -0
- package/src/hooks/useTreeFocus.doc.mjs +15 -1
- package/src/hooks/useTreeFocus.ts +101 -6
- package/dist/Calendar/hooks/useCalendarRovingTabindex.d.ts +0 -57
- package/dist/Calendar/hooks/useCalendarRovingTabindex.d.ts.map +0 -1
- package/dist/Calendar/hooks/useCalendarRovingTabindex.js +0 -96
- package/src/Calendar/hooks/useCalendarRovingTabindex.ts +0 -118
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @file useCalendarRovingTabindex.ts
|
|
7
|
-
* @input Uses React useMemo, PlainDate utilities
|
|
8
|
-
* @output Exports useCalendarRovingTabindex hook for accessible grid navigation
|
|
9
|
-
* @position Calendar-specific hook; used by Calendar
|
|
10
|
-
*
|
|
11
|
-
* SYNC: When modified, update:
|
|
12
|
-
* - /packages/core/src/Calendar/hooks/index.ts
|
|
13
|
-
*/
|
|
14
|
-
import { useMemo } from 'react';
|
|
15
|
-
import { plainDateToISO } from "../../utils/plainDate.js";
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Configuration for calendar roving tabindex
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Return type for useCalendarRovingTabindex hook
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Hook for managing roving tabindex in calendar grids.
|
|
27
|
-
*
|
|
28
|
-
* Implements the WAI-ARIA roving tabindex pattern where only one element
|
|
29
|
-
* in a group has tabindex="0" while others have tabindex="-1".
|
|
30
|
-
*
|
|
31
|
-
* Priority for tabbable element:
|
|
32
|
-
* 1. Today if visible in the current month and enabled
|
|
33
|
-
* 2. First enabled day in the month
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```
|
|
37
|
-
* const {tabbableDate, isTabbable} = useCalendarRovingTabindex({
|
|
38
|
-
* days,
|
|
39
|
-
* today: {year: 2026, month: 1, day: 20},
|
|
40
|
-
* year: 2026,
|
|
41
|
-
* month: 1, // January (1-based)
|
|
42
|
-
* isDateDisabled,
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* // In day rendering:
|
|
46
|
-
* <button tabIndex={isTabbable(day.iso) ? 0 : -1}>
|
|
47
|
-
* {day.dayNumber}
|
|
48
|
-
* </button>
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
export function useCalendarRovingTabindex(options) {
|
|
52
|
-
const {
|
|
53
|
-
days,
|
|
54
|
-
today,
|
|
55
|
-
year,
|
|
56
|
-
month,
|
|
57
|
-
isDateDisabled,
|
|
58
|
-
selectedDate
|
|
59
|
-
} = options;
|
|
60
|
-
|
|
61
|
-
// Determine which day should be tabbable
|
|
62
|
-
const tabbableDate = useMemo(() => {
|
|
63
|
-
// Priority 1: Selected date if visible in this month and enabled
|
|
64
|
-
if (selectedDate) {
|
|
65
|
-
const isSelectedInMonth = selectedDate.year === year && selectedDate.month === month;
|
|
66
|
-
if (isSelectedInMonth && !isDateDisabled(selectedDate)) {
|
|
67
|
-
return plainDateToISO(selectedDate);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Priority 2: Today if visible in this month and enabled
|
|
72
|
-
const isTodayInMonth = today.year === year && today.month === month;
|
|
73
|
-
if (isTodayInMonth && !isDateDisabled(today)) {
|
|
74
|
-
return plainDateToISO(today);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Priority 3: First enabled day in this month
|
|
78
|
-
for (const day of days) {
|
|
79
|
-
if (!day.isOutside && !isDateDisabled(day.date)) {
|
|
80
|
-
return day.iso;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}, [days, today, year, month, isDateDisabled, selectedDate]);
|
|
85
|
-
|
|
86
|
-
// Check if a specific date is tabbable
|
|
87
|
-
const isTabbable = useMemo(() => {
|
|
88
|
-
return iso => {
|
|
89
|
-
return tabbableDate !== null && iso === tabbableDate;
|
|
90
|
-
};
|
|
91
|
-
}, [tabbableDate]);
|
|
92
|
-
return {
|
|
93
|
-
tabbableDate,
|
|
94
|
-
isTabbable
|
|
95
|
-
};
|
|
96
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @file useCalendarRovingTabindex.ts
|
|
7
|
-
* @input Uses React useMemo, PlainDate utilities
|
|
8
|
-
* @output Exports useCalendarRovingTabindex hook for accessible grid navigation
|
|
9
|
-
* @position Calendar-specific hook; used by Calendar
|
|
10
|
-
*
|
|
11
|
-
* SYNC: When modified, update:
|
|
12
|
-
* - /packages/core/src/Calendar/hooks/index.ts
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import {useMemo} from 'react';
|
|
16
|
-
import type {ISODateString} from '../../utils/dateTypes';
|
|
17
|
-
import {type PlainDate, plainDateToISO} from '../../utils/plainDate';
|
|
18
|
-
import type {CalendarDay} from './useCalendarDays';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Configuration for calendar roving tabindex
|
|
22
|
-
*/
|
|
23
|
-
export interface UseCalendarRovingTabindexOptions {
|
|
24
|
-
/** All days in the grid */
|
|
25
|
-
days: CalendarDay[];
|
|
26
|
-
/** Today's date as a PlainDate */
|
|
27
|
-
today: PlainDate;
|
|
28
|
-
/** The year being displayed */
|
|
29
|
-
year: number;
|
|
30
|
-
/** The month being displayed (1-based: 1 = January, 12 = December) */
|
|
31
|
-
month: number;
|
|
32
|
-
/** Function to check if a date is disabled */
|
|
33
|
-
isDateDisabled: (date: PlainDate) => boolean;
|
|
34
|
-
/** Currently selected date (if any) */
|
|
35
|
-
selectedDate?: PlainDate | null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Return type for useCalendarRovingTabindex hook
|
|
40
|
-
*/
|
|
41
|
-
export interface UseCalendarRovingTabindexReturn {
|
|
42
|
-
/** The ISO date string of the tabbable element, or null */
|
|
43
|
-
tabbableDate: ISODateString | null;
|
|
44
|
-
/** Check if a specific date is the tabbable one */
|
|
45
|
-
isTabbable: (iso: ISODateString) => boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Hook for managing roving tabindex in calendar grids.
|
|
50
|
-
*
|
|
51
|
-
* Implements the WAI-ARIA roving tabindex pattern where only one element
|
|
52
|
-
* in a group has tabindex="0" while others have tabindex="-1".
|
|
53
|
-
*
|
|
54
|
-
* Priority for tabbable element:
|
|
55
|
-
* 1. Today if visible in the current month and enabled
|
|
56
|
-
* 2. First enabled day in the month
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```
|
|
60
|
-
* const {tabbableDate, isTabbable} = useCalendarRovingTabindex({
|
|
61
|
-
* days,
|
|
62
|
-
* today: {year: 2026, month: 1, day: 20},
|
|
63
|
-
* year: 2026,
|
|
64
|
-
* month: 1, // January (1-based)
|
|
65
|
-
* isDateDisabled,
|
|
66
|
-
* });
|
|
67
|
-
*
|
|
68
|
-
* // In day rendering:
|
|
69
|
-
* <button tabIndex={isTabbable(day.iso) ? 0 : -1}>
|
|
70
|
-
* {day.dayNumber}
|
|
71
|
-
* </button>
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export function useCalendarRovingTabindex(
|
|
75
|
-
options: UseCalendarRovingTabindexOptions,
|
|
76
|
-
): UseCalendarRovingTabindexReturn {
|
|
77
|
-
const {days, today, year, month, isDateDisabled, selectedDate} = options;
|
|
78
|
-
|
|
79
|
-
// Determine which day should be tabbable
|
|
80
|
-
const tabbableDate = useMemo(() => {
|
|
81
|
-
// Priority 1: Selected date if visible in this month and enabled
|
|
82
|
-
if (selectedDate) {
|
|
83
|
-
const isSelectedInMonth =
|
|
84
|
-
selectedDate.year === year && selectedDate.month === month;
|
|
85
|
-
if (isSelectedInMonth && !isDateDisabled(selectedDate)) {
|
|
86
|
-
return plainDateToISO(selectedDate);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Priority 2: Today if visible in this month and enabled
|
|
91
|
-
const isTodayInMonth = today.year === year && today.month === month;
|
|
92
|
-
|
|
93
|
-
if (isTodayInMonth && !isDateDisabled(today)) {
|
|
94
|
-
return plainDateToISO(today);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Priority 3: First enabled day in this month
|
|
98
|
-
for (const day of days) {
|
|
99
|
-
if (!day.isOutside && !isDateDisabled(day.date)) {
|
|
100
|
-
return day.iso;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return null;
|
|
105
|
-
}, [days, today, year, month, isDateDisabled, selectedDate]);
|
|
106
|
-
|
|
107
|
-
// Check if a specific date is tabbable
|
|
108
|
-
const isTabbable = useMemo(() => {
|
|
109
|
-
return (iso: ISODateString): boolean => {
|
|
110
|
-
return tabbableDate !== null && iso === tabbableDate;
|
|
111
|
-
};
|
|
112
|
-
}, [tabbableDate]);
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
tabbableDate,
|
|
116
|
-
isTabbable,
|
|
117
|
-
};
|
|
118
|
-
}
|