@fluentui/react-list 9.6.19 → 9.7.0

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 (46) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/dist/index.d.cts +119 -15
  3. package/dist/index.d.ts +119 -15
  4. package/lib/List.js +1 -1
  5. package/lib/List.js.map +1 -1
  6. package/lib/ListItem.js +1 -1
  7. package/lib/ListItem.js.map +1 -1
  8. package/lib/components/List/index.js +3 -1
  9. package/lib/components/List/index.js.map +1 -1
  10. package/lib/components/List/useList.js +51 -12
  11. package/lib/components/List/useList.js.map +1 -1
  12. package/lib/components/ListItem/ListItem.types.js +1 -1
  13. package/lib/components/ListItem/ListItem.types.js.map +1 -1
  14. package/lib/components/ListItem/index.js +1 -1
  15. package/lib/components/ListItem/index.js.map +1 -1
  16. package/lib/components/ListItem/useListItem.js +108 -50
  17. package/lib/components/ListItem/useListItem.js.map +1 -1
  18. package/lib/events/ListItemActionEvent.js.map +1 -1
  19. package/lib/index.js +3 -2
  20. package/lib/index.js.map +1 -1
  21. package/lib/utils/index.js +1 -0
  22. package/lib/utils/index.js.map +1 -1
  23. package/lib/utils/validateListItemElement.js +17 -0
  24. package/lib/utils/validateListItemElement.js.map +1 -0
  25. package/lib-commonjs/List.cjs +12 -0
  26. package/lib-commonjs/List.cjs.map +1 -1
  27. package/lib-commonjs/ListItem.cjs +3 -0
  28. package/lib-commonjs/ListItem.cjs.map +1 -1
  29. package/lib-commonjs/components/List/index.cjs +14 -0
  30. package/lib-commonjs/components/List/index.cjs.map +1 -1
  31. package/lib-commonjs/components/List/useList.cjs +53 -14
  32. package/lib-commonjs/components/List/useList.cjs.map +1 -1
  33. package/lib-commonjs/components/ListItem/ListItem.types.cjs +1 -1
  34. package/lib-commonjs/components/ListItem/ListItem.types.cjs.map +1 -1
  35. package/lib-commonjs/components/ListItem/index.cjs +3 -0
  36. package/lib-commonjs/components/ListItem/index.cjs.map +1 -1
  37. package/lib-commonjs/components/ListItem/useListItem.cjs +109 -52
  38. package/lib-commonjs/components/ListItem/useListItem.cjs.map +1 -1
  39. package/lib-commonjs/events/ListItemActionEvent.cjs.map +1 -1
  40. package/lib-commonjs/index.cjs +34 -0
  41. package/lib-commonjs/index.cjs.map +1 -1
  42. package/lib-commonjs/utils/index.cjs +4 -0
  43. package/lib-commonjs/utils/index.cjs.map +1 -1
  44. package/lib-commonjs/utils/validateListItemElement.cjs +22 -0
  45. package/lib-commonjs/utils/validateListItemElement.cjs.map +1 -0
  46. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,12 +1,25 @@
1
1
  # Change Log - @fluentui/react-list
2
2
 
3
- <!-- This log was last generated on Mon, 21 Sep 2026 16:12:51 GMT and should not be manually modified. -->
3
+ <!-- This log was last generated on Mon, 19 Oct 2026 14:49:10 GMT and should not be manually modified. -->
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.7.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-list_v9.7.0)
8
+
9
+ Mon, 19 Oct 2026 14:49:10 GMT
10
+
11
+ ### Minor changes
12
+
13
+ - feat: expose design-free List base hooks and context APIs with complete public types, editable-child validation, inferred roles, and explicit root support ([PR #36590](https://github.com/microsoft/fluentui/pull/36590) by dmytrokirpa@microsoft.com)
14
+ - Bump @fluentui/react-checkbox to v9.6.6 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
15
+ - Bump @fluentui/react-context-selector to v9.2.21 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
16
+ - Bump @fluentui/react-jsx-runtime to v9.4.7 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
17
+ - Bump @fluentui/react-tabster to v9.26.19 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
18
+ - Bump @fluentui/react-utilities to v9.27.0 ([commit](https://github.com/microsoft/fluentui/commit/undefined) by beachball)
19
+
7
20
  ## [9.6.19](https://github.com/microsoft/fluentui/tree/@fluentui/react-list_v9.6.19)
8
21
 
9
- Mon, 21 Sep 2026 16:12:51 GMT
22
+ Tue, 22 Sep 2026 11:25:40 GMT
10
23
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-list_v9.6.18..@fluentui/react-list_v9.6.19)
11
24
 
12
25
  ### Patches
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Checkbox } from '@fluentui/react-checkbox';
2
2
  import type { ComponentProps } from '@fluentui/react-utilities';
3
3
  import type { ComponentState } from '@fluentui/react-utilities';
4
+ import type { ContextSelector } from '@fluentui/react-context-selector';
4
5
  import type { EventData } from '@fluentui/react-utilities';
5
6
  import type { EventHandler } from '@fluentui/react-utilities';
6
7
  import type { ForwardRefComponent } from '@fluentui/react-utilities';
@@ -11,33 +12,62 @@ import type { SelectionMode as SelectionMode_2 } from '@fluentui/react-utilities
11
12
  import type { Slot } from '@fluentui/react-utilities';
12
13
  import type { SlotClassNames } from '@fluentui/react-utilities';
13
14
 
15
+ /**
16
+ * Calculate the role for the list item based on the list role.
17
+ * @param listRole - the role of the list
18
+ * @returns proper role for the list item
19
+ */
20
+ export declare const calculateListItemRoleForListRole: (listRole: string) => string;
21
+
22
+ /**
23
+ * Calculate the role for the list based on the navigation mode and selectable state
24
+ * @param navigationMode - the navigation mode of the list
25
+ * @param selectable - whether the list is selectable
26
+ * @returns 'grid' if navigationMode is 'composite', otherwise 'listbox' if selectable or 'list' if not
27
+ */
28
+ export declare const calculateListRole: (navigationMode: ListNavigationMode | undefined, selectable: boolean) => "grid" | "listbox" | "list";
29
+
14
30
  export declare const List: ForwardRefComponent<ListProps>;
15
31
 
16
32
  export declare const listClassNames: SlotClassNames<ListSlots>;
17
33
 
18
- declare type ListContextValue = {
34
+ export declare const ListContextProvider: React_2.Provider<ListContextValue | undefined> & React_2.FC<React_2.ProviderProps<ListContextValue | undefined>>;
35
+
36
+ export declare type ListContextValue = {
19
37
  selection?: ListSelectionState;
20
38
  validateListItem: (listItemElement: HTMLElement) => void;
21
39
  };
22
40
 
23
- declare type ListContextValues = {
41
+ export declare type ListContextValues = {
24
42
  listContext: ListContextValue;
25
43
  synchronousContext: ListSynchronousContextValue;
26
44
  };
27
45
 
28
46
  export declare const ListItem: ForwardRefComponent<ListItemProps>;
29
47
 
30
- declare type ListItemActionEvent = CustomEvent<ListItemActionEventDetail>;
31
-
32
- declare type ListItemActionEventData = EventData<typeof ListItemActionEventName, ListItemActionEvent> & {
48
+ export declare type ListItemActionEventData = EventData<'ListItemAction', CustomEvent<{
49
+ originalEvent: React_2.MouseEvent | React_2.KeyboardEvent;
50
+ }>> & {
33
51
  value: ListItemValue;
34
52
  };
35
53
 
36
- declare interface ListItemActionEventDetail {
37
- originalEvent: React_2.MouseEvent | React_2.KeyboardEvent;
38
- }
54
+ /**
55
+ * ListItem props accepted by `useListItemBase_unstable`.
56
+ */
57
+ export declare type ListItemBaseProps = ComponentProps<ListItemBaseSlots> & Pick<ListItemProps, 'value' | 'onAction' | 'disabledSelection'>;
39
58
 
40
- declare const ListItemActionEventName = "ListItemAction";
59
+ /**
60
+ * ListItem slots without any design dependency, used by `useListItemBase_unstable`.
61
+ */
62
+ export declare type ListItemBaseSlots = {
63
+ root: NonNullable<Slot<'li', 'div'>>;
64
+ checkmark?: Slot<'input'>;
65
+ };
66
+
67
+ /**
68
+ * State returned by `useListItemBase_unstable`.
69
+ */
70
+ export declare type ListItemBaseState = ComponentState<ListItemBaseSlots> & Pick<ListItemState, 'selectable' | 'navigable' | 'disabled'>;
41
71
 
42
72
  export declare const listItemClassNames: SlotClassNames<ListItemSlots>;
43
73
 
@@ -64,9 +94,9 @@ export declare type ListItemState = ComponentState<ListItemSlots> & {
64
94
  disabled?: boolean;
65
95
  };
66
96
 
67
- declare type ListItemValue = string | number;
97
+ export declare type ListItemValue = string | number;
68
98
 
69
- declare type ListNavigationMode = 'items' | 'composite';
99
+ export declare type ListNavigationMode = 'items' | 'composite';
70
100
 
71
101
  /**
72
102
  * List Props
@@ -79,7 +109,7 @@ export declare type ListProps = ComponentProps<ListSlots> & {
79
109
  onSelectionChange?: EventHandler<OnListSelectionChangeData>;
80
110
  };
81
111
 
82
- declare type ListSelectionState = {
112
+ export declare type ListSelectionState = {
83
113
  isSelected: (item: string | number) => boolean;
84
114
  toggleItem: (e: React_2.SyntheticEvent, id: string | number) => void;
85
115
  deselectItem: (e: React_2.SyntheticEvent, id: string | number) => void;
@@ -99,12 +129,12 @@ export declare type ListSlots = {
99
129
  */
100
130
  export declare type ListState = ComponentState<ListSlots> & ListContextValue & ListSynchronousContextValue;
101
131
 
102
- declare type ListSynchronousContextValue = {
132
+ export declare type ListSynchronousContextValue = {
103
133
  navigationMode: ListNavigationMode | undefined;
104
134
  listItemRole: string;
105
135
  };
106
136
 
107
- declare type OnListSelectionChangeData = EventData<'change', React_2.SyntheticEvent> & {
137
+ export declare type OnListSelectionChangeData = EventData<'change', React_2.SyntheticEvent> & {
108
138
  selectedItems: SelectionItemId[];
109
139
  };
110
140
 
@@ -129,6 +159,21 @@ export declare const renderListItem_unstable: (state: ListItemState) => JSXEleme
129
159
  */
130
160
  export declare const useList_unstable: (props: ListProps, ref: React_2.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>) => ListState;
131
161
 
162
+ /**
163
+ * Base state hook for List, free of any focus or keyboard navigation runtime.
164
+ *
165
+ * Arrow key navigation is layered on by the wrapping `useList_unstable` hook, so consumers of this
166
+ * hook are expected to bring their own focus management.
167
+ *
168
+ * @param props - props from this instance of List
169
+ * @param ref - reference to root HTMLElement of List
170
+ */
171
+ export declare const useListBase_unstable: (props: ListProps, ref: React_2.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>) => ListState;
172
+
173
+ export declare const useListContext_unstable: <T>(selector: ContextSelector<ListContextValue, T>) => T;
174
+
175
+ export declare function useListContextValues_unstable(state: ListState): ListContextValues;
176
+
132
177
  /**
133
178
  * Create the state required to render ListItem.
134
179
  *
@@ -136,10 +181,22 @@ export declare const useList_unstable: (props: ListProps, ref: React_2.Ref<HTMLD
136
181
  * before being passed to renderListItem_unstable.
137
182
  *
138
183
  * @param props - props from this instance of ListItem
139
- * @param ref - reference to root HTMLLIElement | HTMLDivElementof ListItem
184
+ * @param ref - reference to root HTMLLIElement | HTMLDivElement of ListItem
140
185
  */
141
186
  export declare const useListItem_unstable: (props: ListItemProps, ref: React_2.Ref<HTMLLIElement | HTMLDivElement>) => ListItemState;
142
187
 
188
+ /**
189
+ * Base state hook for ListItem, free of any focus or keyboard navigation runtime and of the
190
+ * Fluent `Checkbox` used for the selection indicator.
191
+ *
192
+ * The checkmark slot is rendered as a native `input[type="checkbox"]`, and the Tabster driven
193
+ * arrow key handling is layered on by the wrapping `useListItem_unstable` hook.
194
+ *
195
+ * @param props - props from this instance of ListItem
196
+ * @param ref - reference to root HTMLLIElement | HTMLDivElement of ListItem
197
+ */
198
+ export declare const useListItemBase_unstable: (props: ListItemBaseProps, ref: React_2.Ref<HTMLLIElement | HTMLDivElement>) => ListItemBaseState;
199
+
143
200
  /**
144
201
  * Apply styling to the ListItem slots based on the state
145
202
  */
@@ -150,4 +207,51 @@ export declare const useListItemStyles_unstable: (state: ListItemState) => ListI
150
207
  */
151
208
  export declare const useListStyles_unstable: (state: ListState) => ListState;
152
209
 
210
+ /**
211
+ * Validates that grid cells are present in a grid list item. This is necessary for proper screen reader support.
212
+ * If grid cells are not present and we're not running in production mode, a warning will be logged to the console.
213
+ * @param listRole - The role of the list
214
+ * @param listItemEl - The list item element
215
+ * @returns
216
+ */
217
+ export declare const validateGridCellsArePresent: (listRole: string, listItemEl: HTMLElement) => void;
218
+
219
+ /**
220
+ * Runs the development time validations for a single list item element.
221
+ *
222
+ * The focusable children detection is passed in so that callers can choose between a Tabster
223
+ * aware implementation and a plain DOM one.
224
+ */
225
+ export declare const validateListItemElement: (listItemEl: HTMLElement, { listRenderedAs, listRole, hasSelection, hasFocusableChildren }: ValidateListItemElementOptions) => void;
226
+
227
+ export declare type ValidateListItemElementOptions = {
228
+ /** The element type the parent List renders as. */
229
+ listRenderedAs: string;
230
+ /** The resolved role of the parent List. */
231
+ listRole: string;
232
+ /** Whether the parent List has selection enabled. */
233
+ hasSelection: boolean;
234
+ /** Whether the list item contains focusable children. */
235
+ hasFocusableChildren: boolean;
236
+ };
237
+
238
+ /**
239
+ * Validates that the List and ListItem elements are compatible
240
+ * @param listRenderedAs - the type of the parent element
241
+ * @param listItemRenderedAs - the type of the child element
242
+ */
243
+ export declare function validateProperElementTypes(listRenderedAs?: string, listItemRenderedAs?: string): void;
244
+
245
+ /**
246
+ * Validate that the proper roles are used for the given combination of roles and states.
247
+ * If the roles are invalid and we're not running in production mode, an warning will be logged to the console.
248
+ *
249
+ * @param role - the role of the list
250
+ * @param listItemRole - the role of the list item
251
+ * @param hasSelection - whether the list has selection enabled
252
+ * @param hasFocusableChildren - whether the list has focusable children
253
+ * @returns
254
+ */
255
+ export declare const validateProperRolesAreUsed: (role: string, listItemRole: string, hasSelection: boolean, hasFocusableChildren: boolean) => void;
256
+
153
257
  export { }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { Checkbox } from '@fluentui/react-checkbox';
2
2
  import type { ComponentProps } from '@fluentui/react-utilities';
3
3
  import type { ComponentState } from '@fluentui/react-utilities';
4
+ import type { ContextSelector } from '@fluentui/react-context-selector';
4
5
  import type { EventData } from '@fluentui/react-utilities';
5
6
  import type { EventHandler } from '@fluentui/react-utilities';
6
7
  import type { ForwardRefComponent } from '@fluentui/react-utilities';
@@ -11,33 +12,62 @@ import type { SelectionMode as SelectionMode_2 } from '@fluentui/react-utilities
11
12
  import type { Slot } from '@fluentui/react-utilities';
12
13
  import type { SlotClassNames } from '@fluentui/react-utilities';
13
14
 
15
+ /**
16
+ * Calculate the role for the list item based on the list role.
17
+ * @param listRole - the role of the list
18
+ * @returns proper role for the list item
19
+ */
20
+ export declare const calculateListItemRoleForListRole: (listRole: string) => string;
21
+
22
+ /**
23
+ * Calculate the role for the list based on the navigation mode and selectable state
24
+ * @param navigationMode - the navigation mode of the list
25
+ * @param selectable - whether the list is selectable
26
+ * @returns 'grid' if navigationMode is 'composite', otherwise 'listbox' if selectable or 'list' if not
27
+ */
28
+ export declare const calculateListRole: (navigationMode: ListNavigationMode | undefined, selectable: boolean) => "grid" | "listbox" | "list";
29
+
14
30
  export declare const List: ForwardRefComponent<ListProps>;
15
31
 
16
32
  export declare const listClassNames: SlotClassNames<ListSlots>;
17
33
 
18
- declare type ListContextValue = {
34
+ export declare const ListContextProvider: React_2.Provider<ListContextValue | undefined> & React_2.FC<React_2.ProviderProps<ListContextValue | undefined>>;
35
+
36
+ export declare type ListContextValue = {
19
37
  selection?: ListSelectionState;
20
38
  validateListItem: (listItemElement: HTMLElement) => void;
21
39
  };
22
40
 
23
- declare type ListContextValues = {
41
+ export declare type ListContextValues = {
24
42
  listContext: ListContextValue;
25
43
  synchronousContext: ListSynchronousContextValue;
26
44
  };
27
45
 
28
46
  export declare const ListItem: ForwardRefComponent<ListItemProps>;
29
47
 
30
- declare type ListItemActionEvent = CustomEvent<ListItemActionEventDetail>;
31
-
32
- declare type ListItemActionEventData = EventData<typeof ListItemActionEventName, ListItemActionEvent> & {
48
+ export declare type ListItemActionEventData = EventData<'ListItemAction', CustomEvent<{
49
+ originalEvent: React_2.MouseEvent | React_2.KeyboardEvent;
50
+ }>> & {
33
51
  value: ListItemValue;
34
52
  };
35
53
 
36
- declare interface ListItemActionEventDetail {
37
- originalEvent: React_2.MouseEvent | React_2.KeyboardEvent;
38
- }
54
+ /**
55
+ * ListItem props accepted by `useListItemBase_unstable`.
56
+ */
57
+ export declare type ListItemBaseProps = ComponentProps<ListItemBaseSlots> & Pick<ListItemProps, 'value' | 'onAction' | 'disabledSelection'>;
39
58
 
40
- declare const ListItemActionEventName = "ListItemAction";
59
+ /**
60
+ * ListItem slots without any design dependency, used by `useListItemBase_unstable`.
61
+ */
62
+ export declare type ListItemBaseSlots = {
63
+ root: NonNullable<Slot<'li', 'div'>>;
64
+ checkmark?: Slot<'input'>;
65
+ };
66
+
67
+ /**
68
+ * State returned by `useListItemBase_unstable`.
69
+ */
70
+ export declare type ListItemBaseState = ComponentState<ListItemBaseSlots> & Pick<ListItemState, 'selectable' | 'navigable' | 'disabled'>;
41
71
 
42
72
  export declare const listItemClassNames: SlotClassNames<ListItemSlots>;
43
73
 
@@ -64,9 +94,9 @@ export declare type ListItemState = ComponentState<ListItemSlots> & {
64
94
  disabled?: boolean;
65
95
  };
66
96
 
67
- declare type ListItemValue = string | number;
97
+ export declare type ListItemValue = string | number;
68
98
 
69
- declare type ListNavigationMode = 'items' | 'composite';
99
+ export declare type ListNavigationMode = 'items' | 'composite';
70
100
 
71
101
  /**
72
102
  * List Props
@@ -79,7 +109,7 @@ export declare type ListProps = ComponentProps<ListSlots> & {
79
109
  onSelectionChange?: EventHandler<OnListSelectionChangeData>;
80
110
  };
81
111
 
82
- declare type ListSelectionState = {
112
+ export declare type ListSelectionState = {
83
113
  isSelected: (item: string | number) => boolean;
84
114
  toggleItem: (e: React_2.SyntheticEvent, id: string | number) => void;
85
115
  deselectItem: (e: React_2.SyntheticEvent, id: string | number) => void;
@@ -99,12 +129,12 @@ export declare type ListSlots = {
99
129
  */
100
130
  export declare type ListState = ComponentState<ListSlots> & ListContextValue & ListSynchronousContextValue;
101
131
 
102
- declare type ListSynchronousContextValue = {
132
+ export declare type ListSynchronousContextValue = {
103
133
  navigationMode: ListNavigationMode | undefined;
104
134
  listItemRole: string;
105
135
  };
106
136
 
107
- declare type OnListSelectionChangeData = EventData<'change', React_2.SyntheticEvent> & {
137
+ export declare type OnListSelectionChangeData = EventData<'change', React_2.SyntheticEvent> & {
108
138
  selectedItems: SelectionItemId[];
109
139
  };
110
140
 
@@ -129,6 +159,21 @@ export declare const renderListItem_unstable: (state: ListItemState) => JSXEleme
129
159
  */
130
160
  export declare const useList_unstable: (props: ListProps, ref: React_2.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>) => ListState;
131
161
 
162
+ /**
163
+ * Base state hook for List, free of any focus or keyboard navigation runtime.
164
+ *
165
+ * Arrow key navigation is layered on by the wrapping `useList_unstable` hook, so consumers of this
166
+ * hook are expected to bring their own focus management.
167
+ *
168
+ * @param props - props from this instance of List
169
+ * @param ref - reference to root HTMLElement of List
170
+ */
171
+ export declare const useListBase_unstable: (props: ListProps, ref: React_2.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>) => ListState;
172
+
173
+ export declare const useListContext_unstable: <T>(selector: ContextSelector<ListContextValue, T>) => T;
174
+
175
+ export declare function useListContextValues_unstable(state: ListState): ListContextValues;
176
+
132
177
  /**
133
178
  * Create the state required to render ListItem.
134
179
  *
@@ -136,10 +181,22 @@ export declare const useList_unstable: (props: ListProps, ref: React_2.Ref<HTMLD
136
181
  * before being passed to renderListItem_unstable.
137
182
  *
138
183
  * @param props - props from this instance of ListItem
139
- * @param ref - reference to root HTMLLIElement | HTMLDivElementof ListItem
184
+ * @param ref - reference to root HTMLLIElement | HTMLDivElement of ListItem
140
185
  */
141
186
  export declare const useListItem_unstable: (props: ListItemProps, ref: React_2.Ref<HTMLLIElement | HTMLDivElement>) => ListItemState;
142
187
 
188
+ /**
189
+ * Base state hook for ListItem, free of any focus or keyboard navigation runtime and of the
190
+ * Fluent `Checkbox` used for the selection indicator.
191
+ *
192
+ * The checkmark slot is rendered as a native `input[type="checkbox"]`, and the Tabster driven
193
+ * arrow key handling is layered on by the wrapping `useListItem_unstable` hook.
194
+ *
195
+ * @param props - props from this instance of ListItem
196
+ * @param ref - reference to root HTMLLIElement | HTMLDivElement of ListItem
197
+ */
198
+ export declare const useListItemBase_unstable: (props: ListItemBaseProps, ref: React_2.Ref<HTMLLIElement | HTMLDivElement>) => ListItemBaseState;
199
+
143
200
  /**
144
201
  * Apply styling to the ListItem slots based on the state
145
202
  */
@@ -150,4 +207,51 @@ export declare const useListItemStyles_unstable: (state: ListItemState) => ListI
150
207
  */
151
208
  export declare const useListStyles_unstable: (state: ListState) => ListState;
152
209
 
210
+ /**
211
+ * Validates that grid cells are present in a grid list item. This is necessary for proper screen reader support.
212
+ * If grid cells are not present and we're not running in production mode, a warning will be logged to the console.
213
+ * @param listRole - The role of the list
214
+ * @param listItemEl - The list item element
215
+ * @returns
216
+ */
217
+ export declare const validateGridCellsArePresent: (listRole: string, listItemEl: HTMLElement) => void;
218
+
219
+ /**
220
+ * Runs the development time validations for a single list item element.
221
+ *
222
+ * The focusable children detection is passed in so that callers can choose between a Tabster
223
+ * aware implementation and a plain DOM one.
224
+ */
225
+ export declare const validateListItemElement: (listItemEl: HTMLElement, { listRenderedAs, listRole, hasSelection, hasFocusableChildren }: ValidateListItemElementOptions) => void;
226
+
227
+ export declare type ValidateListItemElementOptions = {
228
+ /** The element type the parent List renders as. */
229
+ listRenderedAs: string;
230
+ /** The resolved role of the parent List. */
231
+ listRole: string;
232
+ /** Whether the parent List has selection enabled. */
233
+ hasSelection: boolean;
234
+ /** Whether the list item contains focusable children. */
235
+ hasFocusableChildren: boolean;
236
+ };
237
+
238
+ /**
239
+ * Validates that the List and ListItem elements are compatible
240
+ * @param listRenderedAs - the type of the parent element
241
+ * @param listItemRenderedAs - the type of the child element
242
+ */
243
+ export declare function validateProperElementTypes(listRenderedAs?: string, listItemRenderedAs?: string): void;
244
+
245
+ /**
246
+ * Validate that the proper roles are used for the given combination of roles and states.
247
+ * If the roles are invalid and we're not running in production mode, an warning will be logged to the console.
248
+ *
249
+ * @param role - the role of the list
250
+ * @param listItemRole - the role of the list item
251
+ * @param hasSelection - whether the list has selection enabled
252
+ * @param hasFocusableChildren - whether the list has focusable children
253
+ * @returns
254
+ */
255
+ export declare const validateProperRolesAreUsed: (role: string, listItemRole: string, hasSelection: boolean, hasFocusableChildren: boolean) => void;
256
+
153
257
  export { }
package/lib/List.js CHANGED
@@ -1 +1 @@
1
- export { List, listClassNames, renderList_unstable, useListStyles_unstable, useList_unstable } from "./components/List/index.js";
1
+ export { List, ListContextProvider, listClassNames, renderList_unstable, useListBase_unstable, useListContextValues_unstable, useListContext_unstable, useListStyles_unstable, useList_unstable } from "./components/List/index.js";
package/lib/List.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/List.ts"],"sourcesContent":["export type {\n ListContextValue,\n ListContextValues,\n ListNavigationMode,\n ListProps,\n ListSlots,\n ListState,\n OnListSelectionChangeData,\n} from './components/List/index';\nexport {\n List,\n listClassNames,\n renderList_unstable,\n useListStyles_unstable,\n useList_unstable,\n} from './components/List/index';\n"],"names":["List","listClassNames","renderList_unstable","useListStyles_unstable","useList_unstable"],"mappings":"AASA,SACEA,IAAI,EACJC,cAAc,EACdC,mBAAmB,EACnBC,sBAAsB,EACtBC,gBAAgB,QACX,6BAA0B"}
1
+ {"version":3,"sources":["../src/List.ts"],"sourcesContent":["export type {\n ListContextValue,\n ListContextValues,\n ListNavigationMode,\n ListProps,\n ListSlots,\n ListState,\n ListSynchronousContextValue,\n OnListSelectionChangeData,\n} from './components/List/index';\nexport {\n List,\n ListContextProvider,\n listClassNames,\n renderList_unstable,\n useListBase_unstable,\n useListContextValues_unstable,\n useListContext_unstable,\n useListStyles_unstable,\n useList_unstable,\n} from './components/List/index';\n"],"names":["List","ListContextProvider","listClassNames","renderList_unstable","useListBase_unstable","useListContextValues_unstable","useListContext_unstable","useListStyles_unstable","useList_unstable"],"mappings":"AAUA,SACEA,IAAI,EACJC,mBAAmB,EACnBC,cAAc,EACdC,mBAAmB,EACnBC,oBAAoB,EACpBC,6BAA6B,EAC7BC,uBAAuB,EACvBC,sBAAsB,EACtBC,gBAAgB,QACX,6BAA0B"}
package/lib/ListItem.js CHANGED
@@ -1 +1 @@
1
- export { ListItem, listItemClassNames, renderListItem_unstable, useListItemStyles_unstable, useListItem_unstable } from "./components/ListItem/index.js";
1
+ export { ListItem, listItemClassNames, renderListItem_unstable, useListItemBase_unstable, useListItemStyles_unstable, useListItem_unstable } from "./components/ListItem/index.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ListItem.ts"],"sourcesContent":["export type {\n ListItemActionEventData,\n ListItemProps,\n ListItemSlots,\n ListItemState,\n ListItemValue,\n} from './components/ListItem/index';\nexport {\n ListItem,\n listItemClassNames,\n renderListItem_unstable,\n useListItemStyles_unstable,\n useListItem_unstable,\n} from './components/ListItem/index';\n"],"names":["ListItem","listItemClassNames","renderListItem_unstable","useListItemStyles_unstable","useListItem_unstable"],"mappings":"AAOA,SACEA,QAAQ,EACRC,kBAAkB,EAClBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,oBAAoB,QACf,iCAA8B"}
1
+ {"version":3,"sources":["../src/ListItem.ts"],"sourcesContent":["export type {\n ListItemActionEventData,\n ListItemBaseProps,\n ListItemBaseSlots,\n ListItemBaseState,\n ListItemProps,\n ListItemSlots,\n ListItemState,\n ListItemValue,\n} from './components/ListItem/index';\nexport {\n ListItem,\n listItemClassNames,\n renderListItem_unstable,\n useListItemBase_unstable,\n useListItemStyles_unstable,\n useListItem_unstable,\n} from './components/ListItem/index';\n"],"names":["ListItem","listItemClassNames","renderListItem_unstable","useListItemBase_unstable","useListItemStyles_unstable","useListItem_unstable"],"mappings":"AAUA,SACEA,QAAQ,EACRC,kBAAkB,EAClBC,uBAAuB,EACvBC,wBAAwB,EACxBC,0BAA0B,EAC1BC,oBAAoB,QACf,iCAA8B"}
@@ -1,4 +1,6 @@
1
1
  export { List } from "./List.js";
2
2
  export { renderList_unstable } from "./renderList.js";
3
- export { useList_unstable } from "./useList.js";
3
+ export { useList_unstable, useListBase_unstable } from "./useList.js";
4
+ export { useListContextValues_unstable } from "./useListContextValues.js";
5
+ export { ListContextProvider, useListContext_unstable } from "./listContext.js";
4
6
  export { listClassNames, useListStyles_unstable } from "./useListStyles.styles.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/List/index.ts"],"sourcesContent":["export { List } from './List';\nexport type {\n ListContextValue,\n ListContextValues,\n ListNavigationMode,\n ListProps,\n ListSlots,\n ListState,\n OnListSelectionChangeData,\n} from './List.types';\nexport { renderList_unstable } from './renderList';\nexport { useList_unstable } from './useList';\nexport { listClassNames, useListStyles_unstable } from './useListStyles.styles';\n"],"names":["List","renderList_unstable","useList_unstable","listClassNames","useListStyles_unstable"],"mappings":"AAAA,SAASA,IAAI,QAAQ,YAAS;AAU9B,SAASC,mBAAmB,QAAQ,kBAAe;AACnD,SAASC,gBAAgB,QAAQ,eAAY;AAC7C,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,4BAAyB"}
1
+ {"version":3,"sources":["../src/components/List/index.ts"],"sourcesContent":["export { List } from './List';\nexport type {\n ListContextValue,\n ListContextValues,\n ListNavigationMode,\n ListProps,\n ListSlots,\n ListState,\n OnListSelectionChangeData,\n} from './List.types';\nexport { renderList_unstable } from './renderList';\nexport { useList_unstable, useListBase_unstable } from './useList';\nexport { useListContextValues_unstable } from './useListContextValues';\nexport { ListContextProvider, useListContext_unstable } from './listContext';\nexport { listClassNames, useListStyles_unstable } from './useListStyles.styles';\nexport type { ListSynchronousContextValue } from './List.types';\n"],"names":["List","renderList_unstable","useList_unstable","useListBase_unstable","useListContextValues_unstable","ListContextProvider","useListContext_unstable","listClassNames","useListStyles_unstable"],"mappings":"AAAA,SAASA,IAAI,QAAQ,YAAS;AAU9B,SAASC,mBAAmB,QAAQ,kBAAe;AACnD,SAASC,gBAAgB,EAAEC,oBAAoB,QAAQ,eAAY;AACnE,SAASC,6BAA6B,QAAQ,4BAAyB;AACvE,SAASC,mBAAmB,EAAEC,uBAAuB,QAAQ,mBAAgB;AAC7E,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,4BAAyB"}
@@ -2,8 +2,13 @@
2
2
  import { getIntrinsicElementProps, slot, useControllableState, useEventCallback } from "@fluentui/react-utilities";
3
3
  import { useArrowNavigationGroup, useFocusFinders } from "@fluentui/react-tabster";
4
4
  import { useListSelection } from "../../hooks/useListSelection.js";
5
- import { calculateListItemRoleForListRole, calculateListRole, validateGridCellsArePresent, validateProperElementTypes, validateProperRolesAreUsed } from "../../utils/index.js";
5
+ import { calculateListItemRoleForListRole, calculateListRole, validateListItemElement } from "../../utils/index.js";
6
6
  const DEFAULT_ROOT_EL_TYPE = 'ul';
7
+ /**
8
+ * Plain DOM approximation of Tabster's focus finders, used by the base hook which must stay free of
9
+ * any Tabster runtime.
10
+ */ const FOCUSABLE_SELECTOR = 'a[href], area[href], button, input, select, textarea, iframe, ' + '[contenteditable=""], [contenteditable="true" i], [contenteditable="plaintext-only" i], [tabindex]';
11
+ const NON_FOCUSABLE_SELECTOR = ':disabled, [hidden], input[type="hidden"], [tabindex^="-"]';
7
12
  /**
8
13
  * Create the state required to render List.
9
14
  *
@@ -13,12 +18,47 @@ const DEFAULT_ROOT_EL_TYPE = 'ul';
13
18
  * @param props - props from this instance of List
14
19
  * @param ref - reference to root HTMLElement of List
15
20
  */ export const useList_unstable = (props, ref)=>{
16
- const { navigationMode, selectionMode, selectedItems, defaultSelectedItems, onSelectionChange } = props;
17
- const as = props.as || navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE;
21
+ const state = useListBase_unstable(props, ref);
22
+ const { navigationMode, selectionMode } = props;
23
+ const as = props.as || (navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE);
24
+ const listRole = props.role || calculateListRole(navigationMode, !!selectionMode);
18
25
  const arrowNavigationAttributes = useArrowNavigationGroup({
19
26
  axis: 'vertical',
20
27
  memorizeCurrent: true
21
28
  });
29
+ const { findAllFocusable } = useFocusFinders();
30
+ const validateListItem = useEventCallback((listItemEl)=>{
31
+ if (process.env.NODE_ENV === 'production') {
32
+ return;
33
+ }
34
+ validateListItemElement(listItemEl, {
35
+ listRenderedAs: as,
36
+ listRole,
37
+ hasSelection: !!selectionMode,
38
+ hasFocusableChildren: findAllFocusable(listItemEl).length > 0
39
+ });
40
+ });
41
+ return {
42
+ ...state,
43
+ validateListItem,
44
+ // Consumer props keep winning over the navigation attributes, matching the base slot ordering.
45
+ root: {
46
+ ...arrowNavigationAttributes,
47
+ ...state.root
48
+ }
49
+ };
50
+ };
51
+ /**
52
+ * Base state hook for List, free of any focus or keyboard navigation runtime.
53
+ *
54
+ * Arrow key navigation is layered on by the wrapping `useList_unstable` hook, so consumers of this
55
+ * hook are expected to bring their own focus management.
56
+ *
57
+ * @param props - props from this instance of List
58
+ * @param ref - reference to root HTMLElement of List
59
+ */ export const useListBase_unstable = (props, ref)=>{
60
+ const { navigationMode, selectionMode, selectedItems, defaultSelectedItems, onSelectionChange } = props;
61
+ const as = props.as || (navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE);
22
62
  const [selectionState, setSelectionState] = useControllableState({
23
63
  state: selectedItems,
24
64
  defaultState: defaultSelectedItems,
@@ -40,16 +80,16 @@ const DEFAULT_ROOT_EL_TYPE = 'ul';
40
80
  });
41
81
  const listRole = props.role || calculateListRole(navigationMode, !!selectionMode);
42
82
  const listItemRole = calculateListItemRoleForListRole(listRole);
43
- const { findAllFocusable } = useFocusFinders();
44
83
  const validateListItem = useEventCallback((listItemEl)=>{
45
84
  if (process.env.NODE_ENV === 'production') {
46
85
  return;
47
86
  }
48
- const itemRole = listItemEl.getAttribute('role') || '';
49
- const focusable = findAllFocusable(listItemEl);
50
- validateProperElementTypes(as, listItemEl.tagName.toLocaleLowerCase());
51
- validateProperRolesAreUsed(listRole, itemRole, !!selectionMode, focusable.length > 0);
52
- validateGridCellsArePresent(listRole, listItemEl);
87
+ validateListItemElement(listItemEl, {
88
+ listRenderedAs: as,
89
+ listRole,
90
+ hasSelection: !!selectionMode,
91
+ hasFocusableChildren: Array.from(listItemEl.querySelectorAll(FOCUSABLE_SELECTOR)).some((element)=>!element.matches(NON_FOCUSABLE_SELECTOR))
92
+ });
53
93
  });
54
94
  return {
55
95
  components: {
@@ -57,12 +97,11 @@ const DEFAULT_ROOT_EL_TYPE = 'ul';
57
97
  },
58
98
  root: slot.always(getIntrinsicElementProps(as, {
59
99
  ref,
60
- role: listRole,
61
100
  ...selectionMode && {
62
101
  'aria-multiselectable': selectionMode === 'multiselect' ? true : undefined
63
102
  },
64
- ...arrowNavigationAttributes,
65
- ...props
103
+ ...props,
104
+ role: listRole
66
105
  }), {
67
106
  elementType: as
68
107
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/List/useList.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport type { OnSelectionChangeData } from '@fluentui/react-utilities';\nimport { getIntrinsicElementProps, slot, useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport type { ListProps, ListState } from './List.types';\nimport { useListSelection } from '../../hooks/useListSelection';\nimport {\n calculateListItemRoleForListRole,\n calculateListRole,\n validateGridCellsArePresent,\n validateProperElementTypes,\n validateProperRolesAreUsed,\n} from '../../utils';\n\nconst DEFAULT_ROOT_EL_TYPE = 'ul';\n\n/**\n * Create the state required to render List.\n *\n * The returned state can be modified with hooks such as useListStyles_unstable,\n * before being passed to renderList_unstable.\n *\n * @param props - props from this instance of List\n * @param ref - reference to root HTMLElement of List\n */\nexport const useList_unstable = (\n props: ListProps,\n ref: React.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>,\n): ListState => {\n const { navigationMode, selectionMode, selectedItems, defaultSelectedItems, onSelectionChange } = props;\n\n const as = props.as || navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE;\n\n const arrowNavigationAttributes = useArrowNavigationGroup({\n axis: 'vertical',\n memorizeCurrent: true,\n });\n\n const [selectionState, setSelectionState] = useControllableState({\n state: selectedItems,\n defaultState: defaultSelectedItems,\n initialState: [],\n });\n\n const onChange = useEventCallback((e: React.SyntheticEvent, data: OnSelectionChangeData) => {\n const selectedItemsAsArray = Array.from(data.selectedItems);\n setSelectionState(selectedItemsAsArray);\n onSelectionChange?.(e, { event: e, type: 'change', selectedItems: selectedItemsAsArray });\n });\n\n const selection = useListSelection({\n onSelectionChange: onChange,\n selectionMode: selectionMode || 'multiselect',\n selectedItems: selectionState,\n });\n\n const listRole = props.role || calculateListRole(navigationMode, !!selectionMode);\n const listItemRole = calculateListItemRoleForListRole(listRole);\n\n const { findAllFocusable } = useFocusFinders();\n\n const validateListItem = useEventCallback((listItemEl: HTMLElement) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n const itemRole = listItemEl.getAttribute('role') || '';\n const focusable = findAllFocusable(listItemEl);\n validateProperElementTypes(as, listItemEl.tagName.toLocaleLowerCase());\n validateProperRolesAreUsed(listRole, itemRole, !!selectionMode, focusable.length > 0);\n validateGridCellsArePresent(listRole, listItemEl);\n });\n\n return {\n components: {\n root: as,\n },\n root: slot.always(\n getIntrinsicElementProps(as, {\n ref,\n role: listRole,\n ...(selectionMode && {\n 'aria-multiselectable': selectionMode === 'multiselect' ? true : undefined,\n }),\n ...arrowNavigationAttributes,\n ...props,\n }),\n { elementType: as },\n ),\n listItemRole,\n validateListItem,\n navigationMode,\n // only pass down selection state if its handled internally, otherwise just report the events\n selection: selectionMode ? selection : undefined,\n };\n};\n"],"names":["getIntrinsicElementProps","slot","useControllableState","useEventCallback","useArrowNavigationGroup","useFocusFinders","useListSelection","calculateListItemRoleForListRole","calculateListRole","validateGridCellsArePresent","validateProperElementTypes","validateProperRolesAreUsed","DEFAULT_ROOT_EL_TYPE","useList_unstable","props","ref","navigationMode","selectionMode","selectedItems","defaultSelectedItems","onSelectionChange","as","arrowNavigationAttributes","axis","memorizeCurrent","selectionState","setSelectionState","state","defaultState","initialState","onChange","e","data","selectedItemsAsArray","Array","from","event","type","selection","listRole","role","listItemRole","findAllFocusable","validateListItem","listItemEl","process","env","NODE_ENV","itemRole","getAttribute","focusable","tagName","toLocaleLowerCase","length","components","root","always","undefined","elementType"],"mappings":"AAAA;AAIA,SAASA,wBAAwB,EAAEC,IAAI,EAAEC,oBAAoB,EAAEC,gBAAgB,QAAQ,4BAA4B;AACnH,SAASC,uBAAuB,EAAEC,eAAe,QAAQ,0BAA0B;AAEnF,SAASC,gBAAgB,QAAQ,kCAA+B;AAChE,SACEC,gCAAgC,EAChCC,iBAAiB,EACjBC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,0BAA0B,QACrB,uBAAc;AAErB,MAAMC,uBAAuB;AAE7B;;;;;;;;CAQC,GACD,OAAO,MAAMC,mBAAmB,CAC9BC,OACAC;IAEA,MAAM,EAAEC,cAAc,EAAEC,aAAa,EAAEC,aAAa,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAE,GAAGN;IAElG,MAAMO,KAAKP,MAAMO,EAAE,IAAIL,mBAAmB,cAAc,QAAQJ;IAEhE,MAAMU,4BAA4BlB,wBAAwB;QACxDmB,MAAM;QACNC,iBAAiB;IACnB;IAEA,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGxB,qBAAqB;QAC/DyB,OAAOT;QACPU,cAAcT;QACdU,cAAc,EAAE;IAClB;IAEA,MAAMC,WAAW3B,iBAAiB,CAAC4B,GAAyBC;QAC1D,MAAMC,uBAAuBC,MAAMC,IAAI,CAACH,KAAKd,aAAa;QAC1DQ,kBAAkBO;QAClBb,8BAAAA,wCAAAA,kBAAoBW,GAAG;YAAEK,OAAOL;YAAGM,MAAM;YAAUnB,eAAee;QAAqB;IACzF;IAEA,MAAMK,YAAYhC,iBAAiB;QACjCc,mBAAmBU;QACnBb,eAAeA,iBAAiB;QAChCC,eAAeO;IACjB;IAEA,MAAMc,WAAWzB,MAAM0B,IAAI,IAAIhC,kBAAkBQ,gBAAgB,CAAC,CAACC;IACnE,MAAMwB,eAAelC,iCAAiCgC;IAEtD,MAAM,EAAEG,gBAAgB,EAAE,GAAGrC;IAE7B,MAAMsC,mBAAmBxC,iBAAiB,CAACyC;QACzC,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;YACzC;QACF;QACA,MAAMC,WAAWJ,WAAWK,YAAY,CAAC,WAAW;QACpD,MAAMC,YAAYR,iBAAiBE;QACnClC,2BAA2BW,IAAIuB,WAAWO,OAAO,CAACC,iBAAiB;QACnEzC,2BAA2B4B,UAAUS,UAAU,CAAC,CAAC/B,eAAeiC,UAAUG,MAAM,GAAG;QACnF5C,4BAA4B8B,UAAUK;IACxC;IAEA,OAAO;QACLU,YAAY;YACVC,MAAMlC;QACR;QACAkC,MAAMtD,KAAKuD,MAAM,CACfxD,yBAAyBqB,IAAI;YAC3BN;YACAyB,MAAMD;YACN,GAAItB,iBAAiB;gBACnB,wBAAwBA,kBAAkB,gBAAgB,OAAOwC;YACnE,CAAC;YACD,GAAGnC,yBAAyB;YAC5B,GAAGR,KAAK;QACV,IACA;YAAE4C,aAAarC;QAAG;QAEpBoB;QACAE;QACA3B;QACA,6FAA6F;QAC7FsB,WAAWrB,gBAAgBqB,YAAYmB;IACzC;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/List/useList.ts"],"sourcesContent":["'use client';\n\nimport type * as React from 'react';\nimport type { OnSelectionChangeData } from '@fluentui/react-utilities';\nimport { getIntrinsicElementProps, slot, useControllableState, useEventCallback } from '@fluentui/react-utilities';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport type { ListProps, ListState } from './List.types';\nimport { useListSelection } from '../../hooks/useListSelection';\nimport { calculateListItemRoleForListRole, calculateListRole, validateListItemElement } from '../../utils';\n\nconst DEFAULT_ROOT_EL_TYPE = 'ul';\n\n/**\n * Plain DOM approximation of Tabster's focus finders, used by the base hook which must stay free of\n * any Tabster runtime.\n */\nconst FOCUSABLE_SELECTOR =\n 'a[href], area[href], button, input, select, textarea, iframe, ' +\n '[contenteditable=\"\"], [contenteditable=\"true\" i], [contenteditable=\"plaintext-only\" i], [tabindex]';\nconst NON_FOCUSABLE_SELECTOR = ':disabled, [hidden], input[type=\"hidden\"], [tabindex^=\"-\"]';\n\n/**\n * Create the state required to render List.\n *\n * The returned state can be modified with hooks such as useListStyles_unstable,\n * before being passed to renderList_unstable.\n *\n * @param props - props from this instance of List\n * @param ref - reference to root HTMLElement of List\n */\nexport const useList_unstable = (\n props: ListProps,\n ref: React.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>,\n): ListState => {\n const state = useListBase_unstable(props, ref);\n\n const { navigationMode, selectionMode } = props;\n const as = props.as || (navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE);\n const listRole = props.role || calculateListRole(navigationMode, !!selectionMode);\n\n const arrowNavigationAttributes = useArrowNavigationGroup({\n axis: 'vertical',\n memorizeCurrent: true,\n });\n\n const { findAllFocusable } = useFocusFinders();\n\n const validateListItem = useEventCallback((listItemEl: HTMLElement) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n validateListItemElement(listItemEl, {\n listRenderedAs: as,\n listRole,\n hasSelection: !!selectionMode,\n hasFocusableChildren: findAllFocusable(listItemEl).length > 0,\n });\n });\n\n return {\n ...state,\n validateListItem,\n // Consumer props keep winning over the navigation attributes, matching the base slot ordering.\n root: { ...arrowNavigationAttributes, ...state.root },\n };\n};\n\n/**\n * Base state hook for List, free of any focus or keyboard navigation runtime.\n *\n * Arrow key navigation is layered on by the wrapping `useList_unstable` hook, so consumers of this\n * hook are expected to bring their own focus management.\n *\n * @param props - props from this instance of List\n * @param ref - reference to root HTMLElement of List\n */\nexport const useListBase_unstable = (\n props: ListProps,\n ref: React.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>,\n): ListState => {\n const { navigationMode, selectionMode, selectedItems, defaultSelectedItems, onSelectionChange } = props;\n\n const as = props.as || (navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE);\n\n const [selectionState, setSelectionState] = useControllableState({\n state: selectedItems,\n defaultState: defaultSelectedItems,\n initialState: [],\n });\n\n const onChange = useEventCallback((e: React.SyntheticEvent, data: OnSelectionChangeData) => {\n const selectedItemsAsArray = Array.from(data.selectedItems);\n setSelectionState(selectedItemsAsArray);\n onSelectionChange?.(e, { event: e, type: 'change', selectedItems: selectedItemsAsArray });\n });\n\n const selection = useListSelection({\n onSelectionChange: onChange,\n selectionMode: selectionMode || 'multiselect',\n selectedItems: selectionState,\n });\n\n const listRole = props.role || calculateListRole(navigationMode, !!selectionMode);\n const listItemRole = calculateListItemRoleForListRole(listRole);\n\n const validateListItem = useEventCallback((listItemEl: HTMLElement) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n\n validateListItemElement(listItemEl, {\n listRenderedAs: as,\n listRole,\n hasSelection: !!selectionMode,\n hasFocusableChildren: Array.from(listItemEl.querySelectorAll(FOCUSABLE_SELECTOR)).some(\n element => !element.matches(NON_FOCUSABLE_SELECTOR),\n ),\n });\n });\n\n return {\n components: {\n root: as,\n },\n root: slot.always(\n getIntrinsicElementProps(as, {\n ref,\n ...(selectionMode && {\n 'aria-multiselectable': selectionMode === 'multiselect' ? true : undefined,\n }),\n ...props,\n role: listRole,\n }),\n { elementType: as },\n ),\n listItemRole,\n validateListItem,\n navigationMode,\n // only pass down selection state if its handled internally, otherwise just report the events\n selection: selectionMode ? selection : undefined,\n };\n};\n"],"names":["getIntrinsicElementProps","slot","useControllableState","useEventCallback","useArrowNavigationGroup","useFocusFinders","useListSelection","calculateListItemRoleForListRole","calculateListRole","validateListItemElement","DEFAULT_ROOT_EL_TYPE","FOCUSABLE_SELECTOR","NON_FOCUSABLE_SELECTOR","useList_unstable","props","ref","state","useListBase_unstable","navigationMode","selectionMode","as","listRole","role","arrowNavigationAttributes","axis","memorizeCurrent","findAllFocusable","validateListItem","listItemEl","process","env","NODE_ENV","listRenderedAs","hasSelection","hasFocusableChildren","length","root","selectedItems","defaultSelectedItems","onSelectionChange","selectionState","setSelectionState","defaultState","initialState","onChange","e","data","selectedItemsAsArray","Array","from","event","type","selection","listItemRole","querySelectorAll","some","element","matches","components","always","undefined","elementType"],"mappings":"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"}
@@ -1,3 +1,3 @@
1
1
  /**
2
- * State used in rendering ListItem
2
+ * State returned by `useListItemBase_unstable`.
3
3
  */ export { };