MCPcopy Create free account
hub / github.com/adobe/react-spectrum / TableSelectAllCell

Function TableSelectAllCell

packages/react-aria/stories/table/example.tsx:225–252  ·  view source on GitHub ↗
({column, state}: {column: any; state: any})

Source from the content-addressed store, hash-verified

223}
224
225export function TableSelectAllCell({column, state}: {column: any; state: any}): JSX.Element {
226 let ref = useRef<HTMLTableCellElement | null>(null);
227 let isSingleSelectionMode = state.selectionManager.selectionMode === 'single';
228 let {columnHeaderProps} = useTableColumnHeader({node: column}, state, ref);
229
230 let {checkboxProps} = useTableSelectAllCheckbox(state);
231 let inputRef = useRef(null);
232 let {inputProps} = useCheckbox(checkboxProps, useToggleState(checkboxProps), inputRef);
233
234 return (
235 <th {...columnHeaderProps} ref={ref}>
236 {
237 /*
238 In single selection mode, the checkbox will be hidden.
239 So to avoid leaving a column header with no accessible content,
240 use a VisuallyHidden component to include the aria-label from the checkbox,
241 which for single selection will be "Select."
242 */
243 isSingleSelectionMode && <VisuallyHidden>{inputProps['aria-label']}</VisuallyHidden>
244 }
245 <input
246 {...inputProps}
247 ref={inputRef}
248 style={isSingleSelectionMode ? {visibility: 'hidden'} : undefined}
249 />
250 </th>
251 );
252}

Callers

nothing calls this directly

Calls 4

useTableColumnHeaderFunction · 0.90
useCheckboxFunction · 0.90
useToggleStateFunction · 0.90

Tested by

no test coverage detected