@veeqo/ui 9.9.1 → 9.9.3

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 (50) hide show
  1. package/dist/components/DataGrid/DataGrid.cjs +40 -8
  2. package/dist/components/DataGrid/DataGrid.cjs.map +1 -1
  3. package/dist/components/DataGrid/DataGrid.d.ts +1 -1
  4. package/dist/components/DataGrid/DataGrid.js +40 -8
  5. package/dist/components/DataGrid/DataGrid.js.map +1 -1
  6. package/dist/components/DataGrid/columns/SelectionColumnDefinition.cjs +36 -0
  7. package/dist/components/DataGrid/columns/SelectionColumnDefinition.cjs.map +1 -0
  8. package/dist/components/DataGrid/columns/SelectionColumnDefinition.d.ts +2 -0
  9. package/dist/components/DataGrid/columns/SelectionColumnDefinition.js +30 -0
  10. package/dist/components/DataGrid/columns/SelectionColumnDefinition.js.map +1 -0
  11. package/dist/components/DataGrid/columns/index.d.ts +1 -0
  12. package/dist/components/DataGrid/constants.cjs +2 -0
  13. package/dist/components/DataGrid/constants.cjs.map +1 -1
  14. package/dist/components/DataGrid/constants.d.ts +1 -0
  15. package/dist/components/DataGrid/constants.js +2 -1
  16. package/dist/components/DataGrid/constants.js.map +1 -1
  17. package/dist/components/DataGrid/hooks/index.d.ts +1 -0
  18. package/dist/components/DataGrid/hooks/useKeyboardNavigation.cjs +112 -0
  19. package/dist/components/DataGrid/hooks/useKeyboardNavigation.cjs.map +1 -0
  20. package/dist/components/DataGrid/hooks/useKeyboardNavigation.d.ts +14 -0
  21. package/dist/components/DataGrid/hooks/useKeyboardNavigation.js +110 -0
  22. package/dist/components/DataGrid/hooks/useKeyboardNavigation.js.map +1 -0
  23. package/dist/components/DataGrid/hooks/useSelectionState.cjs +51 -0
  24. package/dist/components/DataGrid/hooks/useSelectionState.cjs.map +1 -0
  25. package/dist/components/DataGrid/hooks/useSelectionState.d.ts +18 -0
  26. package/dist/components/DataGrid/hooks/useSelectionState.js +49 -0
  27. package/dist/components/DataGrid/hooks/useSelectionState.js.map +1 -0
  28. package/dist/components/DataGrid/types/DataGridProps.d.ts +23 -1
  29. package/dist/components/DataGrid/types/enums.d.ts +1 -0
  30. package/dist/components/DataGrid/types/index.d.ts +1 -1
  31. package/dist/components/DataGrid/utils/getAriaRoles.cjs +9 -3
  32. package/dist/components/DataGrid/utils/getAriaRoles.cjs.map +1 -1
  33. package/dist/components/DataGrid/utils/getAriaRoles.d.ts +1 -1
  34. package/dist/components/DataGrid/utils/getAriaRoles.js +9 -3
  35. package/dist/components/DataGrid/utils/getAriaRoles.js.map +1 -1
  36. package/dist/components/Popover/hooks/useHandleFocus.cjs +4 -4
  37. package/dist/components/Popover/hooks/useHandleFocus.cjs.map +1 -1
  38. package/dist/components/Popover/hooks/useHandleFocus.js +1 -1
  39. package/dist/components/Popover/hooks/useHandleFocus.js.map +1 -1
  40. package/dist/components/Radio/Radio.cjs +2 -2
  41. package/dist/components/Radio/Radio.cjs.map +1 -1
  42. package/dist/components/Radio/Radio.d.ts +2 -2
  43. package/dist/components/Radio/Radio.js +2 -2
  44. package/dist/components/Radio/Radio.js.map +1 -1
  45. package/dist/utils/tabbableSelectors.cjs +6 -0
  46. package/dist/utils/tabbableSelectors.cjs.map +1 -0
  47. package/dist/utils/tabbableSelectors.d.ts +1 -0
  48. package/dist/utils/tabbableSelectors.js +4 -0
  49. package/dist/utils/tabbableSelectors.js.map +1 -0
  50. package/package.json +1 -1
@@ -0,0 +1,110 @@
1
+ import { useEffect } from 'react';
2
+ import { TABBABLE_SELECTORS } from '../../../utils/tabbableSelectors.js';
3
+
4
+ /**
5
+ * Finds a target element to be selected within a table cell element. If the table cell
6
+ * contains focusable children, the first child will be returned, otherwise we'll simply
7
+ * focus on the table cell.
8
+ */
9
+ const findTargetElement = (tableCell) => {
10
+ const validChildTarget = tableCell.querySelector(TABBABLE_SELECTORS);
11
+ return validChildTarget !== null && validChildTarget !== undefined ? validChildTarget : tableCell;
12
+ };
13
+ /**
14
+ * Finds the next available cell that can be focused by the user, within the next row.
15
+ */
16
+ const findNextCell = (nextRow, nextCellIndex) => {
17
+ if (nextCellIndex >= nextRow.cells.length ||
18
+ nextRow.cells[nextCellIndex].hasAttribute('aria-hidden')) {
19
+ // Ignore (skip) cells that are marked as hidden. Find the next available cell (if there is one) that is visible.
20
+ return [...nextRow.cells].reverse().find((cell) => !cell.hasAttribute('aria-hidden'));
21
+ }
22
+ return nextRow.cells[nextCellIndex];
23
+ };
24
+ /**
25
+ * Handles a `keydown` event from within the table. Navigates between cells using the arrow keys.
26
+ * @param table The table element.
27
+ * @param event The keyboard event.
28
+ */
29
+ const handleKeyDown = (table, event) => {
30
+ var _a;
31
+ const target = event.target;
32
+ if (!table)
33
+ return;
34
+ const currentCell = target.closest('td, th');
35
+ if (!currentCell)
36
+ return;
37
+ const currentRow = currentCell.parentElement;
38
+ if (!currentRow)
39
+ return;
40
+ const rowIndex = Array.from(table.querySelectorAll('tr')).indexOf(currentRow);
41
+ const cellIndex = Array.from(currentRow.children).indexOf(currentCell);
42
+ let nextRowIndex = rowIndex;
43
+ let nextCellIndex = cellIndex;
44
+ switch (event.key) {
45
+ case 'ArrowUp':
46
+ event.preventDefault();
47
+ nextRowIndex = Math.max(0, rowIndex - 1);
48
+ break;
49
+ case 'ArrowDown':
50
+ event.preventDefault();
51
+ nextRowIndex = Math.min(table.rows.length - 1, rowIndex + 1);
52
+ break;
53
+ case 'ArrowLeft':
54
+ event.preventDefault();
55
+ nextCellIndex = Math.max(0, cellIndex - 1);
56
+ break;
57
+ case 'ArrowRight':
58
+ event.preventDefault();
59
+ nextCellIndex = Math.min(currentRow.cells.length - 1, cellIndex + 1);
60
+ break;
61
+ default:
62
+ return;
63
+ }
64
+ const nextRow = table.rows[nextRowIndex];
65
+ const nextCell = findNextCell(nextRow, nextCellIndex);
66
+ if (nextCell) {
67
+ const nextTarget = findTargetElement(nextCell);
68
+ nextTarget.setAttribute('tabindex', '0');
69
+ (_a = nextTarget.scrollIntoView) === null || _a === undefined ? undefined : _a.call(nextTarget, { inline: 'nearest', block: 'nearest' });
70
+ nextTarget.focus();
71
+ // Clear the tabindex when the element loses focus
72
+ nextTarget.addEventListener('blur', () => {
73
+ if (nextTarget.attributes.getNamedItem('data-first')) {
74
+ return;
75
+ }
76
+ nextTarget.removeAttribute('tabindex');
77
+ }, { once: true });
78
+ }
79
+ };
80
+ /**
81
+ * Hook which sets up keyboard navigation within the `DataGrid` component using the arrow keys, can be disabled
82
+ * with the `enableKeyboardNavigation` prop.
83
+ *
84
+ * Supports navigating between cells and rows, with the focus directed either towards the cell element, or
85
+ * the first interactive child if one is present.
86
+ */
87
+ const useKeyboardNavigation = ({ enableKeyboardNavigation, tableRef, }) => {
88
+ useEffect(() => {
89
+ if (!tableRef.current || !enableKeyboardNavigation) {
90
+ return undefined;
91
+ }
92
+ const table = tableRef.current;
93
+ // Find the first column header in the table, and assign it a tabindex.
94
+ const firstElement = table.querySelector('th');
95
+ if (!firstElement)
96
+ return undefined;
97
+ const firstTarget = findTargetElement(firstElement);
98
+ firstTarget.setAttribute('tabindex', '0');
99
+ firstTarget.setAttribute('data-first', '');
100
+ const handler = (event) => handleKeyDown(table, event);
101
+ table.addEventListener('keydown', handler);
102
+ return () => {
103
+ table.removeEventListener('keydown', handler);
104
+ };
105
+ // eslint-disable-next-line react-hooks/exhaustive-deps
106
+ }, [tableRef, enableKeyboardNavigation]);
107
+ };
108
+
109
+ export { useKeyboardNavigation };
110
+ //# sourceMappingURL=useKeyboardNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardNavigation.js","sources":["../../../../src/components/DataGrid/hooks/useKeyboardNavigation.ts"],"sourcesContent":["import { RefObject, useEffect } from 'react';\n\nimport { TABBABLE_SELECTORS } from '../../../utils/tabbableSelectors';\nimport { DataGridProps } from '../types';\n\ntype UseKeyboardNavigationProps = Pick<DataGridProps, 'enableKeyboardNavigation'> & {\n tableRef: RefObject<HTMLTableElement>;\n};\n\n/**\n * Finds a target element to be selected within a table cell element. If the table cell\n * contains focusable children, the first child will be returned, otherwise we'll simply\n * focus on the table cell.\n */\nconst findTargetElement = (tableCell: HTMLElement): HTMLElement => {\n const validChildTarget: HTMLElement | null = tableCell.querySelector(TABBABLE_SELECTORS);\n return validChildTarget ?? tableCell;\n};\n\n/**\n * Finds the next available cell that can be focused by the user, within the next row.\n */\nconst findNextCell = (nextRow: HTMLTableRowElement, nextCellIndex: number) => {\n if (\n nextCellIndex >= nextRow.cells.length ||\n nextRow.cells[nextCellIndex].hasAttribute('aria-hidden')\n ) {\n // Ignore (skip) cells that are marked as hidden. Find the next available cell (if there is one) that is visible.\n return [...nextRow.cells].reverse().find((cell) => !cell.hasAttribute('aria-hidden'));\n }\n\n return nextRow.cells[nextCellIndex];\n};\n\n/**\n * Handles a `keydown` event from within the table. Navigates between cells using the arrow keys.\n * @param table The table element.\n * @param event The keyboard event.\n */\nconst handleKeyDown = (table: HTMLTableElement, event: KeyboardEvent) => {\n const target = event.target as HTMLElement;\n\n if (!table) return;\n\n const currentCell = target.closest('td, th') as HTMLElement;\n if (!currentCell) return;\n\n const currentRow = currentCell.parentElement as HTMLTableRowElement;\n if (!currentRow) return;\n\n const rowIndex = Array.from(table.querySelectorAll('tr')).indexOf(currentRow);\n const cellIndex = Array.from(currentRow.children).indexOf(currentCell);\n\n let nextRowIndex = rowIndex;\n let nextCellIndex = cellIndex;\n\n switch (event.key) {\n case 'ArrowUp':\n event.preventDefault();\n nextRowIndex = Math.max(0, rowIndex - 1);\n break;\n case 'ArrowDown':\n event.preventDefault();\n nextRowIndex = Math.min(table.rows.length - 1, rowIndex + 1);\n break;\n case 'ArrowLeft':\n event.preventDefault();\n nextCellIndex = Math.max(0, cellIndex - 1);\n break;\n case 'ArrowRight':\n event.preventDefault();\n nextCellIndex = Math.min(currentRow.cells.length - 1, cellIndex + 1);\n break;\n default:\n return;\n }\n\n const nextRow = table.rows[nextRowIndex];\n const nextCell = findNextCell(nextRow, nextCellIndex);\n\n if (nextCell) {\n const nextTarget = findTargetElement(nextCell);\n nextTarget.setAttribute('tabindex', '0');\n nextTarget.scrollIntoView?.({ inline: 'nearest', block: 'nearest' });\n nextTarget.focus();\n\n // Clear the tabindex when the element loses focus\n nextTarget.addEventListener(\n 'blur',\n () => {\n if (nextTarget.attributes.getNamedItem('data-first')) {\n return;\n }\n\n nextTarget.removeAttribute('tabindex');\n },\n { once: true },\n );\n }\n};\n\n/**\n * Hook which sets up keyboard navigation within the `DataGrid` component using the arrow keys, can be disabled\n * with the `enableKeyboardNavigation` prop.\n *\n * Supports navigating between cells and rows, with the focus directed either towards the cell element, or\n * the first interactive child if one is present.\n */\nexport const useKeyboardNavigation = ({\n enableKeyboardNavigation,\n tableRef,\n}: UseKeyboardNavigationProps) => {\n useEffect(() => {\n if (!tableRef.current || !enableKeyboardNavigation) {\n return undefined;\n }\n\n const table = tableRef.current;\n\n // Find the first column header in the table, and assign it a tabindex.\n const firstElement = table.querySelector('th') as HTMLElement;\n if (!firstElement) return undefined;\n const firstTarget = findTargetElement(firstElement);\n\n firstTarget.setAttribute('tabindex', '0');\n firstTarget.setAttribute('data-first', '');\n\n const handler = (event: KeyboardEvent) => handleKeyDown(table, event);\n table.addEventListener('keydown', handler);\n\n return () => {\n table.removeEventListener('keydown', handler);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tableRef, enableKeyboardNavigation]);\n};\n"],"names":[],"mappings":";;;AASA;;;;AAIG;AACH,MAAM,iBAAiB,GAAG,CAAC,SAAsB,KAAiB;IAChE,MAAM,gBAAgB,GAAuB,SAAS,CAAC,aAAa,CAAC,kBAAkB,CAAC;AACxF,IAAA,OAAO,gBAAgB,KAAhB,IAAA,IAAA,gBAAgB,iBAAhB,gBAAgB,GAAI,SAAS;AACtC,CAAC;AAED;;AAEG;AACH,MAAM,YAAY,GAAG,CAAC,OAA4B,EAAE,aAAqB,KAAI;AAC3E,IAAA,IACE,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM;QACrC,OAAO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AC/B,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,wBAAwB,EAAE;AAClD,YAAA,OAAO,SAAS;AACjB;AAED,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO;;QAG9B,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAgB;AAC7D,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,OAAO,SAAS;AACnC,QAAA,MAAM,WAAW,GAAG,iBAAiB,CAAC,YAAY,CAAC;AAEnD,QAAA,WAAW,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC;AACzC,QAAA,WAAW,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,CAAC;AAE1C,QAAA,MAAM,OAAO,GAAG,CAAC,KAAoB,KAAK,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC;AACrE,QAAA,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC;AAE1C,QAAA,OAAO,MAAK;AACV,YAAA,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC;AAC/C,SAAC;;AAEH,KAAC,EAAE,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;AAC1C;;;;"}
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ /**
6
+ * Hook which manages interop between selection props and the internal TanStack selection state.
7
+ */
8
+ const useSelectionState = ({ selectionMode, selectedRows, disabledRows, onSelectionChanged, }) => {
9
+ const internalSelectionState = React.useMemo(() => {
10
+ if (!selectedRows || !onSelectionChanged)
11
+ return {};
12
+ return selectedRows.reduce((acc, rowId) => ({
13
+ ...acc,
14
+ [rowId]: true,
15
+ }), {});
16
+ // eslint-disable-next-line react-hooks/exhaustive-deps
17
+ }, [selectedRows]);
18
+ const setInternalSelectionState = React.useCallback((onUpdate) => {
19
+ if (!onSelectionChanged)
20
+ return;
21
+ const newSelectionState = typeof onUpdate === 'function' ? onUpdate(internalSelectionState) : onUpdate;
22
+ const rowIds = Object.entries(newSelectionState)
23
+ .filter(([, selected]) => selected)
24
+ .map(([rowId]) => rowId);
25
+ onSelectionChanged(rowIds);
26
+ }, [onSelectionChanged, internalSelectionState]);
27
+ // Controls whether a given row can be selected or not. If selection is disabled, we tell the TanStack table
28
+ // to consider every row "un-selectable". Otherwise, we defer to whether or not a row is present within the
29
+ // array of disabled row ID's.
30
+ const enableRowSelection = React.useMemo(() => {
31
+ if (selectedRows === undefined || onSelectionChanged === undefined) {
32
+ return false;
33
+ }
34
+ return (row) => !(disabledRows === null || disabledRows === undefined ? undefined : disabledRows.includes(row.id));
35
+ }, [selectedRows, onSelectionChanged, disabledRows]);
36
+ const enableMultiRowSelection = React.useMemo(() => {
37
+ if (!enableRowSelection) {
38
+ return false;
39
+ }
40
+ return selectionMode === 'multiple';
41
+ }, [enableRowSelection, selectionMode]);
42
+ return {
43
+ enableRowSelection,
44
+ enableMultiRowSelection,
45
+ rowSelection: internalSelectionState,
46
+ onRowSelectionChange: setInternalSelectionState,
47
+ };
48
+ };
49
+
50
+ exports.useSelectionState = useSelectionState;
51
+ //# sourceMappingURL=useSelectionState.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSelectionState.cjs","sources":["../../../../src/components/DataGrid/hooks/useSelectionState.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\n\nimport { OnChangeFn, Row, RowSelectionState } from '@tanstack/react-table';\nimport { SelectionMode } from '../types/enums';\n\ntype UseSelectionProps = {\n selectionMode?: SelectionMode;\n selectedRows?: string[];\n disabledRows?: string[];\n onSelectionChanged?: (rowIds: string[]) => void;\n};\n\n/**\n * Hook which manages interop between selection props and the internal TanStack selection state.\n */\nexport const useSelectionState = ({\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n}: UseSelectionProps) => {\n const internalSelectionState: RowSelectionState = useMemo(() => {\n if (!selectedRows || !onSelectionChanged) return {};\n\n return selectedRows.reduce(\n (acc, rowId) => ({\n ...acc,\n [rowId]: true,\n }),\n {},\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedRows]);\n\n const setInternalSelectionState: OnChangeFn<RowSelectionState> = useCallback(\n (onUpdate) => {\n if (!onSelectionChanged) return;\n\n const newSelectionState =\n typeof onUpdate === 'function' ? onUpdate(internalSelectionState) : onUpdate;\n\n const rowIds = Object.entries(newSelectionState)\n .filter(([, selected]) => selected)\n .map(([rowId]) => rowId);\n\n onSelectionChanged(rowIds);\n },\n [onSelectionChanged, internalSelectionState],\n );\n\n // Controls whether a given row can be selected or not. If selection is disabled, we tell the TanStack table\n // to consider every row \"un-selectable\". Otherwise, we defer to whether or not a row is present within the\n // array of disabled row ID's.\n const enableRowSelection = useMemo(() => {\n if (selectedRows === undefined || onSelectionChanged === undefined) {\n return false;\n }\n\n return (row: Row<any>) => !disabledRows?.includes(row.id);\n }, [selectedRows, onSelectionChanged, disabledRows]);\n\n const enableMultiRowSelection = useMemo(() => {\n if (!enableRowSelection) {\n return false;\n }\n return selectionMode === 'multiple';\n }, [enableRowSelection, selectionMode]);\n\n return {\n enableRowSelection,\n enableMultiRowSelection,\n rowSelection: internalSelectionState,\n onRowSelectionChange: setInternalSelectionState,\n };\n};\n"],"names":["useMemo","useCallback"],"mappings":";;;;AAYA;;AAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,EAChC,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,kBAAkB,GACA,KAAI;AACtB,IAAA,MAAM,sBAAsB,GAAsBA,aAAO,CAAC,MAAK;AAC7D,QAAA,IAAI,CAAC,YAAY,IAAI,CAAC,kBAAkB;AAAE,YAAA,OAAO,EAAE;QAEnD,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,GAAG,EAAE,KAAK,MAAM;AACf,YAAA,GAAG,GAAG;YACN,CAAC,KAAK,GAAG,IAAI;SACd,CAAC,EACF,EAAE,CACH;;AAEH,KAAC,EAAE,CAAC,YAAY,CAA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';
2
+ import { SelectionMode } from '../types/enums';
3
+ type UseSelectionProps = {
4
+ selectionMode?: SelectionMode;
5
+ selectedRows?: string[];
6
+ disabledRows?: string[];
7
+ onSelectionChanged?: (rowIds: string[]) => void;
8
+ };
9
+ /**
10
+ * Hook which manages interop between selection props and the internal TanStack selection state.
11
+ */
12
+ export declare const useSelectionState: ({ selectionMode, selectedRows, disabledRows, onSelectionChanged, }: UseSelectionProps) => {
13
+ enableRowSelection: boolean | ((row: Row<any>) => boolean);
14
+ enableMultiRowSelection: boolean;
15
+ rowSelection: RowSelectionState;
16
+ onRowSelectionChange: OnChangeFn<RowSelectionState>;
17
+ };
18
+ export {};
@@ -0,0 +1,49 @@
1
+ import { useMemo, useCallback } from 'react';
2
+
3
+ /**
4
+ * Hook which manages interop between selection props and the internal TanStack selection state.
5
+ */
6
+ const useSelectionState = ({ selectionMode, selectedRows, disabledRows, onSelectionChanged, }) => {
7
+ const internalSelectionState = useMemo(() => {
8
+ if (!selectedRows || !onSelectionChanged)
9
+ return {};
10
+ return selectedRows.reduce((acc, rowId) => ({
11
+ ...acc,
12
+ [rowId]: true,
13
+ }), {});
14
+ // eslint-disable-next-line react-hooks/exhaustive-deps
15
+ }, [selectedRows]);
16
+ const setInternalSelectionState = useCallback((onUpdate) => {
17
+ if (!onSelectionChanged)
18
+ return;
19
+ const newSelectionState = typeof onUpdate === 'function' ? onUpdate(internalSelectionState) : onUpdate;
20
+ const rowIds = Object.entries(newSelectionState)
21
+ .filter(([, selected]) => selected)
22
+ .map(([rowId]) => rowId);
23
+ onSelectionChanged(rowIds);
24
+ }, [onSelectionChanged, internalSelectionState]);
25
+ // Controls whether a given row can be selected or not. If selection is disabled, we tell the TanStack table
26
+ // to consider every row "un-selectable". Otherwise, we defer to whether or not a row is present within the
27
+ // array of disabled row ID's.
28
+ const enableRowSelection = useMemo(() => {
29
+ if (selectedRows === undefined || onSelectionChanged === undefined) {
30
+ return false;
31
+ }
32
+ return (row) => !(disabledRows === null || disabledRows === undefined ? undefined : disabledRows.includes(row.id));
33
+ }, [selectedRows, onSelectionChanged, disabledRows]);
34
+ const enableMultiRowSelection = useMemo(() => {
35
+ if (!enableRowSelection) {
36
+ return false;
37
+ }
38
+ return selectionMode === 'multiple';
39
+ }, [enableRowSelection, selectionMode]);
40
+ return {
41
+ enableRowSelection,
42
+ enableMultiRowSelection,
43
+ rowSelection: internalSelectionState,
44
+ onRowSelectionChange: setInternalSelectionState,
45
+ };
46
+ };
47
+
48
+ export { useSelectionState };
49
+ //# sourceMappingURL=useSelectionState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSelectionState.js","sources":["../../../../src/components/DataGrid/hooks/useSelectionState.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\n\nimport { OnChangeFn, Row, RowSelectionState } from '@tanstack/react-table';\nimport { SelectionMode } from '../types/enums';\n\ntype UseSelectionProps = {\n selectionMode?: SelectionMode;\n selectedRows?: string[];\n disabledRows?: string[];\n onSelectionChanged?: (rowIds: string[]) => void;\n};\n\n/**\n * Hook which manages interop between selection props and the internal TanStack selection state.\n */\nexport const useSelectionState = ({\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n}: UseSelectionProps) => {\n const internalSelectionState: RowSelectionState = useMemo(() => {\n if (!selectedRows || !onSelectionChanged) return {};\n\n return selectedRows.reduce(\n (acc, rowId) => ({\n ...acc,\n [rowId]: true,\n }),\n {},\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [selectedRows]);\n\n const setInternalSelectionState: OnChangeFn<RowSelectionState> = useCallback(\n (onUpdate) => {\n if (!onSelectionChanged) return;\n\n const newSelectionState =\n typeof onUpdate === 'function' ? onUpdate(internalSelectionState) : onUpdate;\n\n const rowIds = Object.entries(newSelectionState)\n .filter(([, selected]) => selected)\n .map(([rowId]) => rowId);\n\n onSelectionChanged(rowIds);\n },\n [onSelectionChanged, internalSelectionState],\n );\n\n // Controls whether a given row can be selected or not. If selection is disabled, we tell the TanStack table\n // to consider every row \"un-selectable\". Otherwise, we defer to whether or not a row is present within the\n // array of disabled row ID's.\n const enableRowSelection = useMemo(() => {\n if (selectedRows === undefined || onSelectionChanged === undefined) {\n return false;\n }\n\n return (row: Row<any>) => !disabledRows?.includes(row.id);\n }, [selectedRows, onSelectionChanged, disabledRows]);\n\n const enableMultiRowSelection = useMemo(() => {\n if (!enableRowSelection) {\n return false;\n }\n return selectionMode === 'multiple';\n }, [enableRowSelection, selectionMode]);\n\n return {\n enableRowSelection,\n enableMultiRowSelection,\n rowSelection: internalSelectionState,\n onRowSelectionChange: setInternalSelectionState,\n };\n};\n"],"names":[],"mappings":";;AAYA;;AAEG;AACI,MAAM,iBAAiB,GAAG,CAAC,EAChC,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,kBAAkB,GACA,KAAI;AACtB,IAAA,MAAM,sBAAsB,GAAsB,OAAO,CAAC,MAAK;AAC7D,QAAA,IAAI,CAAC,YAAY,IAAI,CAAC,kBAAkB;AAAE,YAAA,OAAO,EAAE;QAEnD,OAAO,YAAY,CAAC,MAAM,CACxB,CAAC,GAAG,EAAE,KAAK,MAAM;AACf,YAAA,GAAG,GAAG;YACN,CAAC,KAAK,GAAG,IAAI;SACd,CAAC,EACF,EAAE,CACH;;AAEH,KAAC,EAAE,CAAC,YAAY,CAAC,CAAC;AAElB,IAAA,MAAM,yBAAyB,GAAkC,WAAW,CAC1E,CAAC,QAAQ,KAAI;AACX,QAAA,IAAI,CAAC,kBAAkB;YAAE;AAEzB,QAAA,MAAM,iBAAiB,GACrB,OAAO,QAAQ,KAAK,UAAU,GAAG,QAAQ,CAAC,sBAAsB,CAAC,GAAG,QAAQ;AAE9E,QAAA,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB;aAC5C,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,KAAK,QAAQ;aACjC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;QAE1B,kBAAkB,CAAC,MAAM,CAAC;AAC5B,KAAC,EACD,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAC7C;;;;AAKD,IAAA,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAK;AACtC,QAAA,IAAI,YAAY,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS,EAAE;AAClE,YAAA,OAAO,KAAK;AACb;QAED,OAAO,CAAC,GAAa,KAAK,EAAC,YAAY,KAAZ,IAAA,IAAA,YAAY,6BAAZ,YAAY,CAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;KAC1D,EAAE,CAAC,YAAY,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC;AAEpD,IAAA,MAAM,uBAAuB,GAAG,OAAO,CAAC,MAAK;QAC3C,IAAI,CAAC,kBAAkB,EAAE;AACvB,YAAA,OAAO,KAAK;AACb;QACD,OAAO,aAAa,KAAK,UAAU;AACrC,KAAC,EAAE,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAEvC,OAAO;QACL,kBAAkB;QAClB,uBAAuB;AACvB,QAAA,YAAY,EAAE,sBAAsB;AACpC,QAAA,oBAAoB,EAAE,yBAAyB;KAChD;AACH;;;;"}
@@ -1,6 +1,6 @@
1
1
  import React, { AriaAttributes, ReactElement } from 'react';
2
2
  import { SizeScale } from 'Theme/modules/sizes';
3
- import { BorderMode, ResizeMode } from './enums';
3
+ import { BorderMode, ResizeMode, SelectionMode } from './enums';
4
4
  import { ColumnDefinition } from './ColumnDefinition';
5
5
  import { SortState } from './SortState';
6
6
  import { PinnedColumnState } from './PinnedColumnState';
@@ -44,6 +44,11 @@ export type DataGridProps = Pick<AriaAttributes, 'aria-label'> & {
44
44
  * Additional styles to be applied to the grid container.
45
45
  */
46
46
  containerStyle?: React.CSSProperties;
47
+ /**
48
+ * Enable/disable keyboard navigation within the grid. Using the arrow keys will move users between cells and rows, selecting either the cell (if no interactive children are found),
49
+ * or the first interactive child within the cell (if one is present).
50
+ */
51
+ enableKeyboardNavigation?: boolean;
47
52
  /** Columns */
48
53
  /**
49
54
  * Column definitions. It is not recommended that you modify these once the table has been initialized, since internal state
@@ -82,4 +87,21 @@ export type DataGridProps = Pick<AriaAttributes, 'aria-label'> & {
82
87
  * Handler called when the sort state changes.
83
88
  */
84
89
  onSortChanged?: (sortState: SortState) => void;
90
+ /** Selection */
91
+ /**
92
+ * The selection mode, single or multiple.
93
+ */
94
+ selectionMode?: SelectionMode;
95
+ /**
96
+ * An array of row ID's that are selected in the grid.
97
+ */
98
+ selectedRows?: string[];
99
+ /**
100
+ * An array of row ID's that are disabled.
101
+ */
102
+ disabledRows?: string[];
103
+ /**
104
+ * Handler called when the row selection is changed.
105
+ */
106
+ onSelectionChanged?: (selectedRows: string[]) => void;
85
107
  };
@@ -1,3 +1,4 @@
1
1
  export type ResizeMode = 'onChange' | 'onEnd' | 'off';
2
2
  export type BorderMode = 'full' | 'vertical' | 'none';
3
3
  export type SortDirection = 'asc' | 'desc';
4
+ export type SelectionMode = 'single' | 'multiple';
@@ -1,4 +1,4 @@
1
- export { ResizeMode, BorderMode } from './enums';
1
+ export { ResizeMode, BorderMode, SelectionMode, SortDirection } from './enums';
2
2
  export { DataGridProps } from './DataGridProps';
3
3
  export { AriaRoles } from './AriaRoles';
4
4
  export { ColumnDefinition } from './ColumnDefinition';
@@ -1,9 +1,15 @@
1
1
  'use strict';
2
2
 
3
- const getAriaRoles = () => {
3
+ const getAriaRoles = (enableKeyboardNavigation) => {
4
+ if (!enableKeyboardNavigation) {
5
+ return {
6
+ table: 'table',
7
+ cell: 'cell',
8
+ };
9
+ }
4
10
  return {
5
- table: 'table',
6
- cell: 'cell',
11
+ table: 'grid',
12
+ cell: 'gridcell',
7
13
  };
8
14
  };
9
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"getAriaRoles.cjs","sources":["../../../../src/components/DataGrid/utils/getAriaRoles.ts"],"sourcesContent":["import { AriaRoles } from '../types/AriaRoles';\n\nexport const getAriaRoles = (): AriaRoles => {\n return {\n table: 'table',\n cell: 'cell',\n };\n};\n"],"names":[],"mappings":";;AAEO,MAAM,YAAY,GAAG,MAAgB;IAC1C,OAAO;AACL,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,IAAI,EAAE,MAAM;KACb;AACH;;;;"}
1
+ {"version":3,"file":"getAriaRoles.cjs","sources":["../../../../src/components/DataGrid/utils/getAriaRoles.ts"],"sourcesContent":["import { AriaRoles } from '../types/AriaRoles';\n\nexport const getAriaRoles = (enableKeyboardNavigation: boolean): AriaRoles => {\n if (!enableKeyboardNavigation) {\n return {\n table: 'table',\n cell: 'cell',\n };\n }\n\n return {\n table: 'grid',\n cell: 'gridcell',\n };\n};\n"],"names":[],"mappings":";;AAEa,MAAA,YAAY,GAAG,CAAC,wBAAiC,KAAe;IAC3E,IAAI,CAAC,wBAAwB,EAAE;QAC7B,OAAO;AACL,YAAA,KAAK,EAAE,OAAO;AACd,YAAA,IAAI,EAAE,MAAM;SACb;AACF;IAED,OAAO;AACL,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,IAAI,EAAE,UAAU;KACjB;AACH;;;;"}
@@ -1,2 +1,2 @@
1
1
  import { AriaRoles } from '../types/AriaRoles';
2
- export declare const getAriaRoles: () => AriaRoles;
2
+ export declare const getAriaRoles: (enableKeyboardNavigation: boolean) => AriaRoles;
@@ -1,7 +1,13 @@
1
- const getAriaRoles = () => {
1
+ const getAriaRoles = (enableKeyboardNavigation) => {
2
+ if (!enableKeyboardNavigation) {
3
+ return {
4
+ table: 'table',
5
+ cell: 'cell',
6
+ };
7
+ }
2
8
  return {
3
- table: 'table',
4
- cell: 'cell',
9
+ table: 'grid',
10
+ cell: 'gridcell',
5
11
  };
6
12
  };
7
13
 
@@ -1 +1 @@
1
- {"version":3,"file":"getAriaRoles.js","sources":["../../../../src/components/DataGrid/utils/getAriaRoles.ts"],"sourcesContent":["import { AriaRoles } from '../types/AriaRoles';\n\nexport const getAriaRoles = (): AriaRoles => {\n return {\n table: 'table',\n cell: 'cell',\n };\n};\n"],"names":[],"mappings":"AAEO,MAAM,YAAY,GAAG,MAAgB;IAC1C,OAAO;AACL,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,IAAI,EAAE,MAAM;KACb;AACH;;;;"}
1
+ {"version":3,"file":"getAriaRoles.js","sources":["../../../../src/components/DataGrid/utils/getAriaRoles.ts"],"sourcesContent":["import { AriaRoles } from '../types/AriaRoles';\n\nexport const getAriaRoles = (enableKeyboardNavigation: boolean): AriaRoles => {\n if (!enableKeyboardNavigation) {\n return {\n table: 'table',\n cell: 'cell',\n };\n }\n\n return {\n table: 'grid',\n cell: 'gridcell',\n };\n};\n"],"names":[],"mappings":"AAEa,MAAA,YAAY,GAAG,CAAC,wBAAiC,KAAe;IAC3E,IAAI,CAAC,wBAAwB,EAAE;QAC7B,OAAO;AACL,YAAA,KAAK,EAAE,OAAO;AACd,YAAA,IAAI,EAAE,MAAM;SACb;AACF;IAED,OAAO;AACL,QAAA,KAAK,EAAE,MAAM;AACb,QAAA,IAAI,EAAE,UAAU;KACjB;AACH;;;;"}
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var tabbableSelectors = require('../../../utils/tabbableSelectors.cjs');
4
5
 
5
- const TABBABLE_SELECTORS = 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])';
6
6
  const useHandleFocus = ({ popperElement, anchorElement, onClose, disableFocusLock = false, }) => {
7
7
  /**
8
8
  * Focuses first element, when this gets rendered for the first time.
@@ -10,7 +10,7 @@ const useHandleFocus = ({ popperElement, anchorElement, onClose, disableFocusLoc
10
10
  React.useEffect(() => {
11
11
  if (!popperElement || disableFocusLock)
12
12
  return;
13
- const focusableElements = popperElement.querySelectorAll(TABBABLE_SELECTORS);
13
+ const focusableElements = popperElement.querySelectorAll(tabbableSelectors.TABBABLE_SELECTORS);
14
14
  if (focusableElements.length < 1)
15
15
  return;
16
16
  setTimeout(() => {
@@ -28,7 +28,7 @@ const useHandleFocus = ({ popperElement, anchorElement, onClose, disableFocusLoc
28
28
  return;
29
29
  const focusWithinPopper = (event) => {
30
30
  if (event.key === 'Tab' && !event.shiftKey) {
31
- const focusableElements = popperElement.querySelectorAll(TABBABLE_SELECTORS);
31
+ const focusableElements = popperElement.querySelectorAll(tabbableSelectors.TABBABLE_SELECTORS);
32
32
  // When nothing is focusable within the popover, close popover and allow natural tab order.
33
33
  if (focusableElements.length < 1) {
34
34
  onClose();
@@ -49,7 +49,7 @@ const useHandleFocus = ({ popperElement, anchorElement, onClose, disableFocusLoc
49
49
  * popover, or forward past the last scrollable element within.
50
50
  */
51
51
  const handleFocusTrap = (event) => {
52
- const focusableElements = popperElement.querySelectorAll(TABBABLE_SELECTORS);
52
+ const focusableElements = popperElement.querySelectorAll(tabbableSelectors.TABBABLE_SELECTORS);
53
53
  const firstElement = focusableElements[0];
54
54
  const lastElement = focusableElements[focusableElements.length - 1];
55
55
  // If shift tabbing (BACK) and on the first element, loop to last element.
@@ -1 +1 @@
1
- {"version":3,"file":"useHandleFocus.cjs","sources":["../../../../src/components/Popover/hooks/useHandleFocus.ts"],"sourcesContent":["import { KeyboardEventHandler, useEffect } from 'react';\n\nconst TABBABLE_SELECTORS =\n 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])';\n\ntype UseHandleFocusArgs = {\n popperElement: HTMLDialogElement | HTMLDivElement | null;\n anchorElement: HTMLElement | null;\n onClose: () => void;\n disableFocusLock?: boolean;\n};\n\nexport const useHandleFocus = ({\n popperElement,\n anchorElement,\n onClose,\n disableFocusLock = false,\n}: UseHandleFocusArgs) => {\n /**\n * Focuses first element, when this gets rendered for the first time.\n */\n useEffect(() => {\n if (!popperElement || disableFocusLock) return;\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n\n if (focusableElements.length < 1) return;\n\n setTimeout(() => {\n (focusableElements[0] as HTMLElement).focus();\n }, 0);\n }, [popperElement, disableFocusLock]);\n\n /**\n * Sets up tabbing into the popover.\n *\n * When the popover is open (pre-requisite for this being ran), and the user clicks `TAB`\n * then the tab should move **into** the popover, instead of the natural tab order.\n */\n useEffect(() => {\n if (!popperElement || !popperElement) return;\n\n const focusWithinPopper = (event: KeyboardEvent) => {\n if (event.key === 'Tab' && !event.shiftKey) {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n // When nothing is focusable within the popover, close popover and allow natural tab order.\n if (focusableElements.length < 1) {\n onClose();\n return;\n }\n\n (focusableElements[0] as HTMLElement).focus();\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n // When tab occurs on ref focus, if focusable elements in popover focus first.\n anchorElement?.addEventListener('keydown', focusWithinPopper);\n\n // eslint-disable-next-line consistent-return\n return () => anchorElement?.removeEventListener('keydown', focusWithinPopper);\n }, [anchorElement, popperElement, onClose]);\n\n /**\n * Creates focus trap within the popover itself. Stopping users tabbing back to outside the\n * popover, or forward past the last scrollable element within.\n */\n const handleFocusTrap: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n // If shift tabbing (BACK) and on the first element, loop to last element.\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n (lastElement as HTMLElement).focus();\n\n // If tabbing (FORWARD) and on the last element, loop to first element.\n } else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n (firstElement as HTMLElement).focus();\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n if (!popperElement) return;\n\n // Handle escape\n if (event.key === 'Escape') {\n onClose();\n event.stopPropagation(); // Should only close THIS dialog.\n event.preventDefault(); // Shouldn't close any fullscreen dialogs (Modal) it's part of\n\n // Check we should enforce focus trap.\n } else if (!disableFocusLock && event.key === 'Tab') {\n handleFocusTrap(event);\n }\n };\n\n return {\n handleKeyDown,\n };\n};\n"],"names":["useEffect"],"mappings":";;;;AAEA,MAAM,kBAAkB,GACtB,oMAAoM;AASzL,MAAA,cAAc,GAAG,CAAC,EAC7B,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,GAAG,KAAK,GACL,KAAI;AACvB;;AAEG;IACHA,eAAS,CAAC,MAAK;QACb,IAAI,CAAC,aAAa,IAAI,gBAAgB;YAAE;QACxC,MAAM,iBAAiB,GAAG,aAAc,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;AAE7E,QAAA,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAAE;QAElC,UAAU,CAAC,MAAK;AACb,YAAA,iBAAiB,CAAC,CAAC,CAAiB,CAAC,KAAK,EAAE;SAC9C,EAAE,CAAC,CAAC;AACP,KAAC,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAErC;;;;;AAKG;IACHA,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa;YAAE;AAEtC,QAAA,MAAM,iBAAiB,GAAG,CAAC,KAAoB,KAAI;YACjD,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBAC1C,MAAM,iBAAiB,GAAG,aAAc,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;;AAE7E,gBAAA,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;AAChC,oBAAA,OAAO,EAAE;oBACT;AACD;AAEA,gBAAA,iBAAiB,CAAC,CAAC,CAAiB,CAAC,KAAK,EAAE;gBAC7C,KAAK,CAAC,eAAe,EAAE;gBACvB,KAAK,CAAC,cAAc,EAAE;AACvB;AACH,SAAC;;QAGD,aAAa,KAAA,IAAA,IAAb,aAAa,KAAA,SAAA,GAAA,SA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;;"}
1
+ {"version":3,"file":"useHandleFocus.cjs","sources":["../../../../src/components/Popover/hooks/useHandleFocus.ts"],"sourcesContent":["import { KeyboardEventHandler, useEffect } from 'react';\n\nimport { TABBABLE_SELECTORS } from '../../../utils/tabbableSelectors';\n\ntype UseHandleFocusArgs = {\n popperElement: HTMLDialogElement | HTMLDivElement | null;\n anchorElement: HTMLElement | null;\n onClose: () => void;\n disableFocusLock?: boolean;\n};\n\nexport const useHandleFocus = ({\n popperElement,\n anchorElement,\n onClose,\n disableFocusLock = false,\n}: UseHandleFocusArgs) => {\n /**\n * Focuses first element, when this gets rendered for the first time.\n */\n useEffect(() => {\n if (!popperElement || disableFocusLock) return;\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n\n if (focusableElements.length < 1) return;\n\n setTimeout(() => {\n (focusableElements[0] as HTMLElement).focus();\n }, 0);\n }, [popperElement, disableFocusLock]);\n\n /**\n * Sets up tabbing into the popover.\n *\n * When the popover is open (pre-requisite for this being ran), and the user clicks `TAB`\n * then the tab should move **into** the popover, instead of the natural tab order.\n */\n useEffect(() => {\n if (!popperElement || !popperElement) return;\n\n const focusWithinPopper = (event: KeyboardEvent) => {\n if (event.key === 'Tab' && !event.shiftKey) {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n // When nothing is focusable within the popover, close popover and allow natural tab order.\n if (focusableElements.length < 1) {\n onClose();\n return;\n }\n\n (focusableElements[0] as HTMLElement).focus();\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n // When tab occurs on ref focus, if focusable elements in popover focus first.\n anchorElement?.addEventListener('keydown', focusWithinPopper);\n\n // eslint-disable-next-line consistent-return\n return () => anchorElement?.removeEventListener('keydown', focusWithinPopper);\n }, [anchorElement, popperElement, onClose]);\n\n /**\n * Creates focus trap within the popover itself. Stopping users tabbing back to outside the\n * popover, or forward past the last scrollable element within.\n */\n const handleFocusTrap: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n // If shift tabbing (BACK) and on the first element, loop to last element.\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n (lastElement as HTMLElement).focus();\n\n // If tabbing (FORWARD) and on the last element, loop to first element.\n } else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n (firstElement as HTMLElement).focus();\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n if (!popperElement) return;\n\n // Handle escape\n if (event.key === 'Escape') {\n onClose();\n event.stopPropagation(); // Should only close THIS dialog.\n event.preventDefault(); // Shouldn't close any fullscreen dialogs (Modal) it's part of\n\n // Check we should enforce focus trap.\n } else if (!disableFocusLock && event.key === 'Tab') {\n handleFocusTrap(event);\n }\n };\n\n return {\n handleKeyDown,\n };\n};\n"],"names":["useEffect","TABBABLE_SELECTORS"],"mappings":";;;;;AAWa,MAAA,cAAc,GAAG,CAAC,EAC7B,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,GAAG,KAAK,GACL,KAAI;AACvB;;AAEG;IACHA,eAAS,CAAC,MAAK;QACb,IAAI,CAAC,aAAa,IAAI,gBAAgB;YAAE;QACxC,MAAM,iBAAiB,GAAG,aAAc,CAAC,gBAAgB,CAACC,oCAAkB,CAAC;AAE7E,QAAA,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAAE;QAElC,UAAU,CAAC,MAAK;AACb,YAAA,iBAAiB,CAAC,CAAC,CAAiB,CAAC,KAAK,EAAE;SAC9C,EAAE,CAAC,CAAC;AACP,KAAC,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAErC;;;;;AAKG;IACHD,eAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa;YAAE;AAEtC,QAAA,MAAM,iBAAiB,GAAG,CAAC,K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YACrB,YAA4B,CAAC,KAAK,EAAE;AACtC;AACH,KAAC;AAED,IAAA,MAAM,aAAa,GAA6D,CAAC,KAAK,KAAI;AACxF,QAAA,IAAI,CAAC,aAAa;YAAE;;AAGpB,QAAA,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;AAC1B,YAAA,OAAO,EAAE;AACT,YAAA,KAAK,CAAC,eAAe,EAAE,CAAC;AACxB,YAAA,KAAK,CAAC,cAAc,EAAE,CAAC;;AAGxB;aAAM,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,EAAE;YACnD,eAAe,CAAC,KAAK,CAAC;AACvB;AACH,KAAC;IAED,OAAO;QACL,aAAa;KACd;AACH;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { useEffect } from 'react';
2
+ import { TABBABLE_SELECTORS } from '../../../utils/tabbableSelectors.js';
2
3
 
3
- const TABBABLE_SELECTORS = 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])';
4
4
  const useHandleFocus = ({ popperElement, anchorElement, onClose, disableFocusLock = false, }) => {
5
5
  /**
6
6
  * Focuses first element, when this gets rendered for the first time.
@@ -1 +1 @@
1
- {"version":3,"file":"useHandleFocus.js","sources":["../../../../src/components/Popover/hooks/useHandleFocus.ts"],"sourcesContent":["import { KeyboardEventHandler, useEffect } from 'react';\n\nconst TABBABLE_SELECTORS =\n 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])';\n\ntype UseHandleFocusArgs = {\n popperElement: HTMLDialogElement | HTMLDivElement | null;\n anchorElement: HTMLElement | null;\n onClose: () => void;\n disableFocusLock?: boolean;\n};\n\nexport const useHandleFocus = ({\n popperElement,\n anchorElement,\n onClose,\n disableFocusLock = false,\n}: UseHandleFocusArgs) => {\n /**\n * Focuses first element, when this gets rendered for the first time.\n */\n useEffect(() => {\n if (!popperElement || disableFocusLock) return;\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n\n if (focusableElements.length < 1) return;\n\n setTimeout(() => {\n (focusableElements[0] as HTMLElement).focus();\n }, 0);\n }, [popperElement, disableFocusLock]);\n\n /**\n * Sets up tabbing into the popover.\n *\n * When the popover is open (pre-requisite for this being ran), and the user clicks `TAB`\n * then the tab should move **into** the popover, instead of the natural tab order.\n */\n useEffect(() => {\n if (!popperElement || !popperElement) return;\n\n const focusWithinPopper = (event: KeyboardEvent) => {\n if (event.key === 'Tab' && !event.shiftKey) {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n // When nothing is focusable within the popover, close popover and allow natural tab order.\n if (focusableElements.length < 1) {\n onClose();\n return;\n }\n\n (focusableElements[0] as HTMLElement).focus();\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n // When tab occurs on ref focus, if focusable elements in popover focus first.\n anchorElement?.addEventListener('keydown', focusWithinPopper);\n\n // eslint-disable-next-line consistent-return\n return () => anchorElement?.removeEventListener('keydown', focusWithinPopper);\n }, [anchorElement, popperElement, onClose]);\n\n /**\n * Creates focus trap within the popover itself. Stopping users tabbing back to outside the\n * popover, or forward past the last scrollable element within.\n */\n const handleFocusTrap: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n // If shift tabbing (BACK) and on the first element, loop to last element.\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n (lastElement as HTMLElement).focus();\n\n // If tabbing (FORWARD) and on the last element, loop to first element.\n } else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n (firstElement as HTMLElement).focus();\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n if (!popperElement) return;\n\n // Handle escape\n if (event.key === 'Escape') {\n onClose();\n event.stopPropagation(); // Should only close THIS dialog.\n event.preventDefault(); // Shouldn't close any fullscreen dialogs (Modal) it's part of\n\n // Check we should enforce focus trap.\n } else if (!disableFocusLock && event.key === 'Tab') {\n handleFocusTrap(event);\n }\n };\n\n return {\n handleKeyDown,\n };\n};\n"],"names":[],"mappings":";;AAEA,MAAM,kBAAkB,GACtB,oMAAoM;AASzL,MAAA,cAAc,GAAG,CAAC,EAC7B,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,GAAG,KAAK,GACL,KAAI;AACvB;;AAEG;IACH,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,aAAa,IAAI,gBAAgB;YAAE;QACxC,MAAM,iBAAiB,GAAG,aAAc,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;AAE7E,QAAA,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAAE;QAElC,UAAU,CAAC,MAAK;AACb,YAAA,iBAAiB,CAAC,CAAC,CAAiB,CAAC,KAAK,EAAE;SAC9C,EAAE,CAAC,CAAC;AACP,KAAC,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAErC;;;;;AAKG;IACH,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa;YAAE;AAEtC,QAAA,MAAM,iBAAiB,GAAG,CAAC,KAAoB,KAAI;YACjD,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBAC1C,MAAM,iBAAiB,GAAG,aAAc,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;;AAE7E,gBAAA,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;AAChC,oBAAA,OAAO,EAAE;oBACT;AACD;AAEA,gBAAA,iBAAiB,CAAC,CAAC,CAAiB,CAAC,KAAK,EAAE;gBAC7C,KAAK,CAAC,eAAe,EAAE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AC,GAAG,KAAK,KAAK,EAAE;YACnD,eAAe,CAAC,KAAK,CAAC;AACvB;AACH,KAAC;IAED,OAAO;QACL,aAAa;KACd;AACH;;;;"}
1
+ {"version":3,"file":"useHandleFocus.js","sources":["../../../../src/components/Popover/hooks/useHandleFocus.ts"],"sourcesContent":["import { KeyboardEventHandler, useEffect } from 'react';\n\nimport { TABBABLE_SELECTORS } from '../../../utils/tabbableSelectors';\n\ntype UseHandleFocusArgs = {\n popperElement: HTMLDialogElement | HTMLDivElement | null;\n anchorElement: HTMLElement | null;\n onClose: () => void;\n disableFocusLock?: boolean;\n};\n\nexport const useHandleFocus = ({\n popperElement,\n anchorElement,\n onClose,\n disableFocusLock = false,\n}: UseHandleFocusArgs) => {\n /**\n * Focuses first element, when this gets rendered for the first time.\n */\n useEffect(() => {\n if (!popperElement || disableFocusLock) return;\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n\n if (focusableElements.length < 1) return;\n\n setTimeout(() => {\n (focusableElements[0] as HTMLElement).focus();\n }, 0);\n }, [popperElement, disableFocusLock]);\n\n /**\n * Sets up tabbing into the popover.\n *\n * When the popover is open (pre-requisite for this being ran), and the user clicks `TAB`\n * then the tab should move **into** the popover, instead of the natural tab order.\n */\n useEffect(() => {\n if (!popperElement || !popperElement) return;\n\n const focusWithinPopper = (event: KeyboardEvent) => {\n if (event.key === 'Tab' && !event.shiftKey) {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n // When nothing is focusable within the popover, close popover and allow natural tab order.\n if (focusableElements.length < 1) {\n onClose();\n return;\n }\n\n (focusableElements[0] as HTMLElement).focus();\n event.stopPropagation();\n event.preventDefault();\n }\n };\n\n // When tab occurs on ref focus, if focusable elements in popover focus first.\n anchorElement?.addEventListener('keydown', focusWithinPopper);\n\n // eslint-disable-next-line consistent-return\n return () => anchorElement?.removeEventListener('keydown', focusWithinPopper);\n }, [anchorElement, popperElement, onClose]);\n\n /**\n * Creates focus trap within the popover itself. Stopping users tabbing back to outside the\n * popover, or forward past the last scrollable element within.\n */\n const handleFocusTrap: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n const focusableElements = popperElement!.querySelectorAll(TABBABLE_SELECTORS);\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n\n // If shift tabbing (BACK) and on the first element, loop to last element.\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n (lastElement as HTMLElement).focus();\n\n // If tabbing (FORWARD) and on the last element, loop to first element.\n } else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n (firstElement as HTMLElement).focus();\n }\n };\n\n const handleKeyDown: KeyboardEventHandler<HTMLDialogElement | HTMLDivElement> = (event) => {\n if (!popperElement) return;\n\n // Handle escape\n if (event.key === 'Escape') {\n onClose();\n event.stopPropagation(); // Should only close THIS dialog.\n event.preventDefault(); // Shouldn't close any fullscreen dialogs (Modal) it's part of\n\n // Check we should enforce focus trap.\n } else if (!disableFocusLock && event.key === 'Tab') {\n handleFocusTrap(event);\n }\n };\n\n return {\n handleKeyDown,\n };\n};\n"],"names":[],"mappings":";;;AAWa,MAAA,cAAc,GAAG,CAAC,EAC7B,aAAa,EACb,aAAa,EACb,OAAO,EACP,gBAAgB,GAAG,KAAK,GACL,KAAI;AACvB;;AAEG;IACH,SAAS,CAAC,MAAK;QACb,IAAI,CAAC,aAAa,IAAI,gBAAgB;YAAE;QACxC,MAAM,iBAAiB,GAAG,aAAc,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;AAE7E,QAAA,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC;YAAE;QAElC,UAAU,CAAC,MAAK;AACb,YAAA,iBAAiB,CAAC,CAAC,CAAiB,CAAC,KAAK,EAAE;SAC9C,EAAE,CAAC,CAAC;AACP,KAAC,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;AAErC;;;;;AAKG;IACH,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,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Q,IAAI,QAAQ,CAAC,aAAa,KAAK,WAAW,EAAE;YACpE,KAAK,CAAC,cAAc,EAAE;YACrB,YAA4B,CAAC,KAAK,EAAE;AACtC;AACH,KAAC;AAED,IAAA,MAAM,aAAa,GAA6D,CAAC,KAAK,KAAI;AACxF,QAAA,IAAI,CAAC,aAAa;YAAE;;AAGpB,QAAA,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;AAC1B,YAAA,OAAO,EAAE;AACT,YAAA,KAAK,CAAC,eAAe,EAAE,CAAC;AACxB,YAAA,KAAK,CAAC,cAAc,EAAE,CAAC;;AAGxB;aAAM,IAAI,CAAC,gBAAgB,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,EAAE;YACnD,eAAe,CAAC,KAAK,CAAC;AACvB;AACH,KAAC;IAED,OAAO;QACL,aAAa;KACd;AACH;;;;"}
@@ -9,13 +9,13 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
9
9
 
10
10
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
11
11
 
12
- const Radio = React.forwardRef(({ checked, value, name, disabled, onChange, id, children, ...otherProps }, ref) => {
12
+ const Radio = React.forwardRef(({ checked, value, name, disabled, onChange, id, children, 'aria-label': ariaLabel, ...otherProps }, ref) => {
13
13
  const handleChange = React.useCallback((e) => {
14
14
  onChange(e.currentTarget.checked, value);
15
15
  }, [onChange, value]);
16
16
  const componentId = id !== null && id !== undefined ? id : generateId.generateId('radio');
17
17
  return (React__default.default.createElement(Choice.Choice, { id: componentId, disabled: disabled, ...otherProps },
18
- React__default.default.createElement(styled.Input, { id: componentId, type: "radio", checked: checked, value: value, name: name, disabled: disabled, onChange: handleChange, ref: ref }),
18
+ React__default.default.createElement(styled.Input, { id: componentId, type: "radio", checked: checked, value: value, name: name, disabled: disabled, onChange: handleChange, ref: ref, "aria-label": ariaLabel }),
19
19
  children));
20
20
  });
21
21
 
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.cjs","sources":["../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { ReactNode, forwardRef, useCallback } from 'react';\nimport { Choice, ForwardedChoiceProps } from '../Choice';\nimport { Input } from './styled';\nimport { generateId } from '../../utils/generateId';\n\ntype RadioValue = string | number;\n\nexport interface RadioProps extends ForwardedChoiceProps {\n id?: string;\n className?: string;\n checked: boolean;\n value?: RadioValue;\n disabled?: boolean;\n name?: string;\n onChange: (checked: boolean, value?: RadioValue) => void;\n children?: ReactNode;\n}\n\nexport const Radio = forwardRef<HTMLInputElement, RadioProps>(\n ({ checked, value, name, disabled, onChange, id, children, ...otherProps }: RadioProps, ref) => {\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.currentTarget.checked, value);\n },\n [onChange, value],\n );\n\n const componentId = id ?? generateId('radio');\n\n return (\n <Choice id={componentId} disabled={disabled} {...otherProps}>\n <Input\n id={componentId}\n type=\"radio\"\n checked={checked}\n value={value}\n name={name}\n disabled={disabled}\n onChange={handleChange}\n ref={ref}\n />\n {children}\n </Choice>\n );\n },\n);\n"],"names":["forwardRef","useCallback","generateId","React","Choice","Input"],"mappings":";;;;;;;;;;;AAkBO,MAAM,KAAK,GAAGA,gBAAU,CAC7B,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAc,EAAE,GAAG,KAAI;AAC7F,IAAA,MAAM,YAAY,GAAGC,iBAAW,CAC9B,CAAC,CAAsC,KAAI;QACzC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;AAC1C,KAAC,EACD,CAAC,QAAQ,EAAE,KAAK,CAAC,CAClB;AAED,IAAA,MAAM,WAAW,GAAG,EAAE,KAAA,IAAA,IAAF,EAAE,KAAA,SAAA,GAAF,EAAE,GAAIC,qBAAU,CAAC,OAAO,CAAC;AAE7C,IAAA,QACEC,sBAAA,CAAA,aAAA,CAACC,aAAM,EAAA,EAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAA,GAAM,UAAU,EAAA;AACzD,QAAAD,sBAAA,CAAA,aAAA,CAACE,YAAK,EAAA,EACJ,EAAE,EAAE,WAAW,EACf,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,GAAG,EACR,CAAA;QACD,QAAQ,CACF;AAEb,CAAC;;;;"}
1
+ {"version":3,"file":"Radio.cjs","sources":["../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { AriaAttributes, ReactNode, forwardRef, useCallback } from 'react';\nimport { Choice, ForwardedChoiceProps } from '../Choice';\nimport { Input } from './styled';\nimport { generateId } from '../../utils/generateId';\n\ntype RadioValue = string | number;\n\nexport interface RadioProps extends ForwardedChoiceProps, Pick<AriaAttributes, 'aria-label'> {\n id?: string;\n className?: string;\n checked: boolean;\n value?: RadioValue;\n disabled?: boolean;\n name?: string;\n onChange: (checked: boolean, value?: RadioValue) => void;\n children?: ReactNode;\n}\n\nexport const Radio = forwardRef<HTMLInputElement, RadioProps>(\n (\n {\n checked,\n value,\n name,\n disabled,\n onChange,\n id,\n children,\n 'aria-label': ariaLabel,\n ...otherProps\n }: RadioProps,\n ref,\n ) => {\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.currentTarget.checked, value);\n },\n [onChange, value],\n );\n\n const componentId = id ?? generateId('radio');\n\n return (\n <Choice id={componentId} disabled={disabled} {...otherProps}>\n <Input\n id={componentId}\n type=\"radio\"\n checked={checked}\n value={value}\n name={name}\n disabled={disabled}\n onChange={handleChange}\n ref={ref}\n aria-label={ariaLabel}\n />\n {children}\n </Choice>\n );\n },\n);\n"],"names":["forwardRef","useCallback","generateId","React","Choice","Input"],"mappings":";;;;;;;;;;;AAkBO,MAAM,KAAK,GAAGA,gBAAU,CAC7B,CACE,EACE,OAAO,EACP,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,GAAG,UAAU,EACF,EACb,GAAG,KACD;AACF,IAAA,MAAM,YAAY,GAAGC,iBAAW,CAC9B,CAAC,CAAsC,KAAI;QACzC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;AAC1C,KAAC,EACD,CAAC,QAAQ,EAAE,KAAK,CAAC,CAClB;AAED,IAAA,MAAM,WAAW,GAAG,EAAE,KAAA,IAAA,IAAF,EAAE,KAAA,SAAA,GAAF,EAAE,GAAIC,qBAAU,CAAC,OAAO,CAAC;AAE7C,IAAA,QACEC,sBAAA,CAAA,aAAA,CAACC,aAAM,EAAA,EAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAA,GAAM,UAAU,EAAA;AACzD,QAAAD,sBAAA,CAAA,aAAA,CAACE,YAAK,EAAA,EACJ,EAAE,EAAE,WAAW,EACf,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,GAAG,EAAA,YAAA,EACI,SAAS,EACrB,CAAA;QACD,QAAQ,CACF;AAEb,CAAC;;;;"}
@@ -1,7 +1,7 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { AriaAttributes, ReactNode } from 'react';
2
2
  import { ForwardedChoiceProps } from '../Choice';
3
3
  type RadioValue = string | number;
4
- export interface RadioProps extends ForwardedChoiceProps {
4
+ export interface RadioProps extends ForwardedChoiceProps, Pick<AriaAttributes, 'aria-label'> {
5
5
  id?: string;
6
6
  className?: string;
7
7
  checked: boolean;
@@ -3,13 +3,13 @@ import { Choice } from '../Choice/Choice.js';
3
3
  import { Input } from './styled.js';
4
4
  import { generateId } from '../../utils/generateId.js';
5
5
 
6
- const Radio = forwardRef(({ checked, value, name, disabled, onChange, id, children, ...otherProps }, ref) => {
6
+ const Radio = forwardRef(({ checked, value, name, disabled, onChange, id, children, 'aria-label': ariaLabel, ...otherProps }, ref) => {
7
7
  const handleChange = useCallback((e) => {
8
8
  onChange(e.currentTarget.checked, value);
9
9
  }, [onChange, value]);
10
10
  const componentId = id !== null && id !== undefined ? id : generateId('radio');
11
11
  return (React__default.createElement(Choice, { id: componentId, disabled: disabled, ...otherProps },
12
- React__default.createElement(Input, { id: componentId, type: "radio", checked: checked, value: value, name: name, disabled: disabled, onChange: handleChange, ref: ref }),
12
+ React__default.createElement(Input, { id: componentId, type: "radio", checked: checked, value: value, name: name, disabled: disabled, onChange: handleChange, ref: ref, "aria-label": ariaLabel }),
13
13
  children));
14
14
  });
15
15
 
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","sources":["../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { ReactNode, forwardRef, useCallback } from 'react';\nimport { Choice, ForwardedChoiceProps } from '../Choice';\nimport { Input } from './styled';\nimport { generateId } from '../../utils/generateId';\n\ntype RadioValue = string | number;\n\nexport interface RadioProps extends ForwardedChoiceProps {\n id?: string;\n className?: string;\n checked: boolean;\n value?: RadioValue;\n disabled?: boolean;\n name?: string;\n onChange: (checked: boolean, value?: RadioValue) => void;\n children?: ReactNode;\n}\n\nexport const Radio = forwardRef<HTMLInputElement, RadioProps>(\n ({ checked, value, name, disabled, onChange, id, children, ...otherProps }: RadioProps, ref) => {\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.currentTarget.checked, value);\n },\n [onChange, value],\n );\n\n const componentId = id ?? generateId('radio');\n\n return (\n <Choice id={componentId} disabled={disabled} {...otherProps}>\n <Input\n id={componentId}\n type=\"radio\"\n checked={checked}\n value={value}\n name={name}\n disabled={disabled}\n onChange={handleChange}\n ref={ref}\n />\n {children}\n </Choice>\n );\n },\n);\n"],"names":["React"],"mappings":";;;;;AAkBO,MAAM,KAAK,GAAG,UAAU,CAC7B,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAc,EAAE,GAAG,KAAI;AAC7F,IAAA,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,CAAsC,KAAI;QACzC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;AAC1C,KAAC,EACD,CAAC,QAAQ,EAAE,KAAK,CAAC,CAClB;AAED,IAAA,MAAM,WAAW,GAAG,EAAE,KAAA,IAAA,IAAF,EAAE,KAAA,SAAA,GAAF,EAAE,GAAI,UAAU,CAAC,OAAO,CAAC;AAE7C,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAA,GAAM,UAAU,EAAA;AACzD,QAAAA,cAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EACJ,EAAE,EAAE,WAAW,EACf,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,GAAG,EACR,CAAA;QACD,QAAQ,CACF;AAEb,CAAC;;;;"}
1
+ {"version":3,"file":"Radio.js","sources":["../../../src/components/Radio/Radio.tsx"],"sourcesContent":["import React, { AriaAttributes, ReactNode, forwardRef, useCallback } from 'react';\nimport { Choice, ForwardedChoiceProps } from '../Choice';\nimport { Input } from './styled';\nimport { generateId } from '../../utils/generateId';\n\ntype RadioValue = string | number;\n\nexport interface RadioProps extends ForwardedChoiceProps, Pick<AriaAttributes, 'aria-label'> {\n id?: string;\n className?: string;\n checked: boolean;\n value?: RadioValue;\n disabled?: boolean;\n name?: string;\n onChange: (checked: boolean, value?: RadioValue) => void;\n children?: ReactNode;\n}\n\nexport const Radio = forwardRef<HTMLInputElement, RadioProps>(\n (\n {\n checked,\n value,\n name,\n disabled,\n onChange,\n id,\n children,\n 'aria-label': ariaLabel,\n ...otherProps\n }: RadioProps,\n ref,\n ) => {\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange(e.currentTarget.checked, value);\n },\n [onChange, value],\n );\n\n const componentId = id ?? generateId('radio');\n\n return (\n <Choice id={componentId} disabled={disabled} {...otherProps}>\n <Input\n id={componentId}\n type=\"radio\"\n checked={checked}\n value={value}\n name={name}\n disabled={disabled}\n onChange={handleChange}\n ref={ref}\n aria-label={ariaLabel}\n />\n {children}\n </Choice>\n );\n },\n);\n"],"names":["React"],"mappings":";;;;;AAkBO,MAAM,KAAK,GAAG,UAAU,CAC7B,CACE,EACE,OAAO,EACP,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,GAAG,UAAU,EACF,EACb,GAAG,KACD;AACF,IAAA,MAAM,YAAY,GAAG,WAAW,CAC9B,CAAC,CAAsC,KAAI;QACzC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC;AAC1C,KAAC,EACD,CAAC,QAAQ,EAAE,KAAK,CAAC,CAClB;AAED,IAAA,MAAM,WAAW,GAAG,EAAE,KAAA,IAAA,IAAF,EAAE,KAAA,SAAA,GAAF,EAAE,GAAI,UAAU,CAAC,OAAO,CAAC;AAE7C,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAA,GAAM,UAAU,EAAA;AACzD,QAAAA,cAAA,CAAA,aAAA,CAAC,KAAK,EAAA,EACJ,EAAE,EAAE,WAAW,EACf,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,GAAG,EAAE,GAAG,EAAA,YAAA,EACI,SAAS,EACrB,CAAA;QACD,QAAQ,CACF;AAEb,CAAC;;;;"}
@@ -0,0 +1,6 @@
1
+ 'use strict';
2
+
3
+ const TABBABLE_SELECTORS = 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])';
4
+
5
+ exports.TABBABLE_SELECTORS = TABBABLE_SELECTORS;
6
+ //# sourceMappingURL=tabbableSelectors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabbableSelectors.cjs","sources":["../../src/utils/tabbableSelectors.ts"],"sourcesContent":["export const TABBABLE_SELECTORS =\n 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])';\n"],"names":[],"mappings":";;AAAO,MAAM,kBAAkB,GAC7B;;;;"}
@@ -0,0 +1 @@
1
+ export declare const TABBABLE_SELECTORS = "input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])";
@@ -0,0 +1,4 @@
1
+ const TABBABLE_SELECTORS = 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled])';
2
+
3
+ export { TABBABLE_SELECTORS };
4
+ //# sourceMappingURL=tabbableSelectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabbableSelectors.js","sources":["../../src/utils/tabbableSelectors.ts"],"sourcesContent":["export const TABBABLE_SELECTORS =\n 'input:not([disabled]), summary:not([disabled]), a[href]:not([disabled]), button:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"]):not([disabled])';\n"],"names":[],"mappings":"AAAO,MAAM,kBAAkB,GAC7B;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veeqo/ui",
3
- "version": "9.9.1",
3
+ "version": "9.9.3",
4
4
  "description": "New optimised component library for Veeqo.",
5
5
  "author": "Robert Wealthall",
6
6
  "license": "ISC",