@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.
Files changed (132) hide show
  1. package/dist/Breadcrumbs/BreadcrumbItem.d.ts +1 -1
  2. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  3. package/dist/Breadcrumbs/BreadcrumbItem.js +4 -1
  4. package/dist/Button/Button.d.ts.map +1 -1
  5. package/dist/Button/Button.js +2 -4
  6. package/dist/Calendar/Calendar.d.ts.map +1 -1
  7. package/dist/Calendar/Calendar.js +33 -14
  8. package/dist/Calendar/hooks/index.d.ts +0 -2
  9. package/dist/Calendar/hooks/index.d.ts.map +1 -1
  10. package/dist/Calendar/hooks/index.js +1 -2
  11. package/dist/Calendar/index.d.ts +2 -2
  12. package/dist/Calendar/index.d.ts.map +1 -1
  13. package/dist/Calendar/index.js +1 -1
  14. package/dist/CheckboxList/CheckboxList.js +3 -3
  15. package/dist/Citation/Citation.d.ts.map +1 -1
  16. package/dist/Citation/Citation.js +3 -3
  17. package/dist/ContextMenu/ContextMenu.d.ts +1 -7
  18. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  19. package/dist/ContextMenu/ContextMenu.js +7 -13
  20. package/dist/DropdownMenu/DropdownMenu.d.ts +1 -8
  21. package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  22. package/dist/DropdownMenu/DropdownMenu.js +4 -9
  23. package/dist/Field/Field.d.ts +4 -4
  24. package/dist/Field/Field.d.ts.map +1 -1
  25. package/dist/Field/Field.js +2 -2
  26. package/dist/Field/FieldLabel.d.ts +4 -4
  27. package/dist/Field/FieldLabel.d.ts.map +1 -1
  28. package/dist/Field/FieldLabel.js +2 -2
  29. package/dist/InputGroup/InputGroup.js +3 -3
  30. package/dist/Link/Link.d.ts.map +1 -1
  31. package/dist/Link/Link.js +2 -4
  32. package/dist/MoreMenu/MoreMenu.d.ts +1 -7
  33. package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
  34. package/dist/MoreMenu/MoreMenu.js +0 -2
  35. package/dist/MultiSelector/MultiSelector.d.ts +25 -2
  36. package/dist/MultiSelector/MultiSelector.d.ts.map +1 -1
  37. package/dist/MultiSelector/MultiSelector.js +31 -6
  38. package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
  39. package/dist/ProgressBar/ProgressBar.js +2 -4
  40. package/dist/RadioList/RadioList.js +3 -3
  41. package/dist/SegmentedControl/SegmentedControl.d.ts +1 -1
  42. package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
  43. package/dist/SegmentedControl/SegmentedControl.js +51 -61
  44. package/dist/Selector/Selector.d.ts +22 -1
  45. package/dist/Selector/Selector.d.ts.map +1 -1
  46. package/dist/Selector/Selector.js +31 -6
  47. package/dist/Switch/Switch.d.ts.map +1 -1
  48. package/dist/Switch/Switch.js +2 -4
  49. package/dist/TabList/TabList.d.ts +3 -2
  50. package/dist/TabList/TabList.d.ts.map +1 -1
  51. package/dist/TabList/TabList.js +55 -33
  52. package/dist/Table/tableContextMenu.d.ts.map +1 -1
  53. package/dist/Table/tableContextMenu.js +0 -3
  54. package/dist/TextArea/TextArea.d.ts.map +1 -1
  55. package/dist/TextArea/TextArea.js +2 -4
  56. package/dist/Toolbar/Toolbar.d.ts +3 -3
  57. package/dist/Toolbar/Toolbar.d.ts.map +1 -1
  58. package/dist/Toolbar/Toolbar.js +46 -6
  59. package/dist/TreeList/TreeList.d.ts.map +1 -1
  60. package/dist/TreeList/TreeList.js +16 -22
  61. package/dist/TreeList/TreeListItem.d.ts +3 -2
  62. package/dist/TreeList/TreeListItem.d.ts.map +1 -1
  63. package/dist/astryx.css +3 -0
  64. package/dist/astryx.umd.js +47 -47
  65. package/dist/astryx.umd.js.map +4 -4
  66. package/dist/hooks/index.d.ts +4 -2
  67. package/dist/hooks/index.d.ts.map +1 -1
  68. package/dist/hooks/index.js +1 -0
  69. package/dist/hooks/useGridFocus.d.ts +56 -0
  70. package/dist/hooks/useGridFocus.d.ts.map +1 -1
  71. package/dist/hooks/useGridFocus.js +138 -24
  72. package/dist/hooks/useKeyboardHint.d.ts +82 -0
  73. package/dist/hooks/useKeyboardHint.d.ts.map +1 -0
  74. package/dist/hooks/useKeyboardHint.js +220 -0
  75. package/dist/hooks/useTreeFocus.d.ts +27 -3
  76. package/dist/hooks/useTreeFocus.d.ts.map +1 -1
  77. package/dist/hooks/useTreeFocus.js +69 -6
  78. package/package.json +1 -1
  79. package/src/Breadcrumbs/BreadcrumbItem.tsx +5 -2
  80. package/src/Button/Button.tsx +3 -16
  81. package/src/Calendar/Calendar.tsx +52 -22
  82. package/src/Calendar/hooks/index.ts +0 -6
  83. package/src/Calendar/index.ts +0 -3
  84. package/src/CheckboxList/CheckboxList.tsx +3 -3
  85. package/src/Citation/Citation.doc.mjs +10 -0
  86. package/src/Citation/Citation.test.tsx +117 -0
  87. package/src/Citation/Citation.tsx +9 -1
  88. package/src/ContextMenu/ContextMenu.doc.mjs +0 -6
  89. package/src/ContextMenu/ContextMenu.test.tsx +4 -6
  90. package/src/ContextMenu/ContextMenu.tsx +7 -19
  91. package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -8
  92. package/src/DropdownMenu/DropdownMenu.test.tsx +0 -23
  93. package/src/DropdownMenu/DropdownMenu.tsx +4 -16
  94. package/src/Field/Field.test.tsx +2 -2
  95. package/src/Field/Field.tsx +5 -5
  96. package/src/Field/FieldLabel.tsx +5 -5
  97. package/src/InputGroup/InputGroup.tsx +3 -3
  98. package/src/Link/Link.tsx +2 -13
  99. package/src/MoreMenu/MoreMenu.doc.mjs +2 -17
  100. package/src/MoreMenu/MoreMenu.tsx +0 -9
  101. package/src/MultiSelector/MultiSelector.doc.mjs +25 -0
  102. package/src/MultiSelector/MultiSelector.test.tsx +150 -1
  103. package/src/MultiSelector/MultiSelector.tsx +55 -3
  104. package/src/ProgressBar/ProgressBar.tsx +2 -3
  105. package/src/RadioList/RadioList.tsx +3 -3
  106. package/src/SegmentedControl/SegmentedControl.tsx +51 -77
  107. package/src/Selector/Selector.doc.mjs +21 -0
  108. package/src/Selector/Selector.test.tsx +123 -1
  109. package/src/Selector/Selector.tsx +53 -3
  110. package/src/Switch/Switch.tsx +2 -16
  111. package/src/TabList/TabList.test.tsx +41 -0
  112. package/src/TabList/TabList.tsx +66 -39
  113. package/src/Table/tableContextMenu.tsx +1 -5
  114. package/src/TextArea/TextArea.tsx +3 -13
  115. package/src/Toolbar/Toolbar.test.tsx +64 -6
  116. package/src/Toolbar/Toolbar.tsx +55 -4
  117. package/src/TreeList/TreeList.tsx +17 -28
  118. package/src/TreeList/TreeListItem.tsx +3 -2
  119. package/src/VisuallyHidden/VisuallyHidden.doc.mjs +7 -7
  120. package/src/hooks/index.ts +12 -5
  121. package/src/hooks/useGridFocus.doc.mjs +40 -2
  122. package/src/hooks/useGridFocus.test.tsx +132 -0
  123. package/src/hooks/useGridFocus.ts +179 -23
  124. package/src/hooks/useKeyboardHint.doc.mjs +101 -0
  125. package/src/hooks/useKeyboardHint.test.tsx +70 -0
  126. package/src/hooks/useKeyboardHint.tsx +332 -0
  127. package/src/hooks/useTreeFocus.doc.mjs +15 -1
  128. package/src/hooks/useTreeFocus.ts +101 -6
  129. package/dist/Calendar/hooks/useCalendarRovingTabindex.d.ts +0 -57
  130. package/dist/Calendar/hooks/useCalendarRovingTabindex.d.ts.map +0 -1
  131. package/dist/Calendar/hooks/useCalendarRovingTabindex.js +0 -96
  132. 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
- }