@veeqo/ui 9.10.0 → 9.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Anchor/index.d.ts +1 -0
- package/dist/components/DataGrid/DataGrid.cjs +12 -3
- package/dist/components/DataGrid/DataGrid.cjs.map +1 -1
- package/dist/components/DataGrid/DataGrid.d.ts +1 -1
- package/dist/components/DataGrid/DataGrid.js +13 -4
- package/dist/components/DataGrid/DataGrid.js.map +1 -1
- package/dist/components/DataGrid/components/Body/Body.cjs +4 -1
- package/dist/components/DataGrid/components/Body/Body.cjs.map +1 -1
- package/dist/components/DataGrid/components/Body/Body.js +4 -1
- package/dist/components/DataGrid/components/Body/Body.js.map +1 -1
- package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.cjs +9 -2
- package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.cjs.map +1 -1
- package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.d.ts +9 -1
- package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.js +9 -2
- package/dist/components/DataGrid/components/Body/BodyCell/BodyCell.js.map +1 -1
- package/dist/components/DataGrid/components/Body/BodyCell/hooks/index.d.ts +1 -0
- package/dist/components/DataGrid/components/Body/BodyCell/hooks/useExpandableCell.cjs +34 -0
- package/dist/components/DataGrid/components/Body/BodyCell/hooks/useExpandableCell.cjs.map +1 -0
- package/dist/components/DataGrid/components/Body/BodyCell/hooks/useExpandableCell.d.ts +21 -0
- package/dist/components/DataGrid/components/Body/BodyCell/hooks/useExpandableCell.js +32 -0
- package/dist/components/DataGrid/components/Body/BodyCell/hooks/useExpandableCell.js.map +1 -0
- package/dist/components/DataGrid/components/Body/Row/Row.cjs +1 -1
- package/dist/components/DataGrid/components/Body/Row/Row.cjs.map +1 -1
- package/dist/components/DataGrid/components/Body/Row/Row.d.ts +5 -1
- package/dist/components/DataGrid/components/Body/Row/Row.js +1 -1
- package/dist/components/DataGrid/components/Body/Row/Row.js.map +1 -1
- package/dist/components/DataGrid/components/CellContent/CellContent.cjs +5 -2
- package/dist/components/DataGrid/components/CellContent/CellContent.cjs.map +1 -1
- package/dist/components/DataGrid/components/CellContent/CellContent.d.ts +7 -2
- package/dist/components/DataGrid/components/CellContent/CellContent.js +5 -2
- package/dist/components/DataGrid/components/CellContent/CellContent.js.map +1 -1
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.cjs +20 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.cjs.map +1 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.d.ts +9 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.js +14 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.js.map +1 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss.cjs +9 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss.cjs.map +1 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss.js +7 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss.js.map +1 -0
- package/dist/components/DataGrid/components/CellContent/ExpandButton/index.d.ts +2 -0
- package/dist/components/DataGrid/hooks/useExpandedState.cjs +34 -0
- package/dist/components/DataGrid/hooks/useExpandedState.cjs.map +1 -0
- package/dist/components/DataGrid/hooks/useExpandedState.d.ts +9 -0
- package/dist/components/DataGrid/hooks/useExpandedState.js +32 -0
- package/dist/components/DataGrid/hooks/useExpandedState.js.map +1 -0
- package/dist/components/DataGrid/types/DataGridProps.d.ts +6 -0
- package/dist/components/DataGrid/types/RowGroupingConfiguration.d.ts +22 -0
- package/dist/components/DataGrid/types/index.d.ts +1 -0
- package/dist/components/DataGrid/utils/getAriaRoles.cjs +12 -6
- package/dist/components/DataGrid/utils/getAriaRoles.cjs.map +1 -1
- package/dist/components/DataGrid/utils/getAriaRoles.d.ts +4 -1
- package/dist/components/DataGrid/utils/getAriaRoles.js +12 -6
- package/dist/components/DataGrid/utils/getAriaRoles.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ var useKeyboardNavigation = require('./hooks/useKeyboardNavigation.cjs');
|
|
|
19
19
|
var useSelectionState = require('./hooks/useSelectionState.cjs');
|
|
20
20
|
var constants = require('./constants.cjs');
|
|
21
21
|
var SelectionColumnDefinition = require('./columns/SelectionColumnDefinition.cjs');
|
|
22
|
+
var useExpandedState = require('./hooks/useExpandedState.cjs');
|
|
22
23
|
|
|
23
24
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
24
25
|
|
|
@@ -42,14 +43,14 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
42
43
|
*
|
|
43
44
|
* *Important: This component uses CSS modules, and therefore requires a `<ThemeInjector />` to be present on your page.*
|
|
44
45
|
*/
|
|
45
|
-
const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resizeMode = 'off', containerStyle, enableKeyboardNavigation = false, columns, hiddenColumns, columnOrdering, pinnedColumns, data, getRowId, sortState, onSortChanged, selectionMode, selectedRows, disabledRows, onSelectionChanged, 'aria-label': ariaLabel, }) => {
|
|
46
|
+
const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resizeMode = 'off', containerStyle, enableKeyboardNavigation = false, columns, hiddenColumns, columnOrdering, pinnedColumns, data, getRowId, sortState, onSortChanged, selectionMode, selectedRows, disabledRows, onSelectionChanged, rowGrouping, 'aria-label': ariaLabel, }) => {
|
|
46
47
|
const containerRef = React.useRef(null);
|
|
47
48
|
const tableRef = React.useRef(null);
|
|
48
49
|
const showFooter = React.useMemo(() => columns.some((column) => column.renderFooter), [columns]);
|
|
49
|
-
const ariaRoles = React.useMemo(() => getAriaRoles.getAriaRoles(enableKeyboardNavigation), [enableKeyboardNavigation]);
|
|
50
|
+
const ariaRoles = React.useMemo(() => getAriaRoles.getAriaRoles({ enableKeyboardNavigation, rowGrouping }), [enableKeyboardNavigation, rowGrouping]);
|
|
50
51
|
const enableColumnResizing = React.useMemo(() => resizeMode !== 'off', [resizeMode]);
|
|
51
52
|
/**
|
|
52
|
-
* Hooks to handle state for selection and
|
|
53
|
+
* Hooks to handle state for selection, sorting, and expanded/collapsed.
|
|
53
54
|
*/
|
|
54
55
|
const { enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange } = useSelectionState.useSelectionState({
|
|
55
56
|
selectionMode,
|
|
@@ -58,6 +59,7 @@ const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resiz
|
|
|
58
59
|
onSelectionChanged,
|
|
59
60
|
});
|
|
60
61
|
const { enableSorting, enableMultiRemove, enableSortingRemoval, manualSorting, sorting, onSortingChange, } = useSortingState.useSortingState({ columns, sortState, onSortChanged });
|
|
62
|
+
const { expanded, onExpandedChange, enableExpanding, getRowCanExpand, getSubRows } = useExpandedState.useExpandedState(rowGrouping);
|
|
61
63
|
/**
|
|
62
64
|
* Mapping of column definitions.
|
|
63
65
|
*/
|
|
@@ -132,6 +134,12 @@ const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resiz
|
|
|
132
134
|
enableRowSelection,
|
|
133
135
|
enableMultiRowSelection,
|
|
134
136
|
onRowSelectionChange,
|
|
137
|
+
// Row grouping
|
|
138
|
+
getSubRows,
|
|
139
|
+
getRowCanExpand,
|
|
140
|
+
onExpandedChange,
|
|
141
|
+
enableExpanding,
|
|
142
|
+
getExpandedRowModel: enableExpanding ? reactTable.getExpandedRowModel() : undefined,
|
|
135
143
|
// Inject external table state
|
|
136
144
|
state: {
|
|
137
145
|
columnOrder,
|
|
@@ -139,6 +147,7 @@ const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resiz
|
|
|
139
147
|
columnPinning,
|
|
140
148
|
sorting,
|
|
141
149
|
rowSelection,
|
|
150
|
+
expanded,
|
|
142
151
|
},
|
|
143
152
|
});
|
|
144
153
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGrid.cjs","sources":["../../../src/components/DataGrid/DataGrid.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { getCoreRowModel, useReactTable } from '@tanstack/react-table';\n\nimport { useDragToScroll } from '../../hooks';\n\nimport { DataGridProps } from './types';\nimport { ColumnMapper, getAriaRoles } from './utils';\nimport { GridContainer, Header, Body, Footer, Columns } from './components';\nimport { MemoizedBody } from './components/Body';\n\nimport { usePinnedColumnLayout, useSortingState, useKeyboardNavigation } from './hooks';\n\nimport { useSelectionState } from './hooks/useSelectionState';\nimport { SELECTION_COLUMN_ID } from './constants';\nimport { SelectionColumnDefinition } from './columns';\n\n/**\n * [WIP]\n *\n * A DataGrid component which renders data in a two-dimensional format, with columns and rows. Unlike the `DataTable`\n * component, the `DataGrid` supports both flat and hierarchical (tree) data.\n *\n * Under the hood, it uses [TanStack Table](http://tanstack.com/table/) for table management, and aims to replicate functionality\n * available in major third party grid components such as CloudScape's Table component, AgGrid, etc.\n *\n * Supported features include:\n * - Pinning, resizing (incl. smooth resizing), reordering, and hiding of columns\n * - Selection (single and multiple) and disabling of rows.\n * - Rendering of arbitrarily nested data, expanding/collapsing, and custom full-width 'group' rows.\n * - In-built keyboard navigation with arrow keys, and drag to scroll.\n * - Configurable density.\n *\n * *Important: This component uses CSS modules, and therefore requires a `<ThemeInjector />` to be present on your page.*\n */\nexport const DataGrid = ({\n density = 'base',\n striped = true,\n borderMode = 'full',\n resizeMode = 'off',\n containerStyle,\n enableKeyboardNavigation = false,\n\n columns,\n hiddenColumns,\n columnOrdering,\n pinnedColumns,\n\n data,\n getRowId,\n\n sortState,\n onSortChanged,\n\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n\n 'aria-label': ariaLabel,\n}: DataGridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const tableRef = useRef<HTMLTableElement>(null);\n\n const showFooter = useMemo(() => columns.some((column) => column.renderFooter), [columns]);\n const ariaRoles = useMemo(\n () => getAriaRoles(enableKeyboardNavigation),\n [enableKeyboardNavigation],\n );\n const enableColumnResizing = useMemo(() => resizeMode !== 'off', [resizeMode]);\n\n /**\n * Hooks to handle state for selection and sorting.\n */\n\n const { enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange } =\n useSelectionState({\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n });\n\n const {\n enableSorting,\n enableMultiRemove,\n enableSortingRemoval,\n manualSorting,\n sorting,\n onSortingChange,\n } = useSortingState({ columns, sortState, onSortChanged });\n\n /**\n * Mapping of column definitions.\n */\n const columnMapper = useRef(new ColumnMapper());\n const mappedColumnDefinitions = useMemo(() => {\n const mappedColumns = columns.map((column) => columnMapper.current.mapColumnDefinition(column));\n\n if (enableRowSelection) {\n mappedColumns.unshift(SelectionColumnDefinition);\n }\n\n return mappedColumns;\n }, [columns, enableRowSelection]);\n\n /**\n * Stable references for column states (visibility, order, pinning).\n */\n\n // Column render order - the order of the array indicates the order on screen.\n const columnOrder = useMemo(() => {\n if (!columnOrdering || columnOrdering.length === 0) {\n return undefined;\n }\n\n // If we have a custom column order, we need to make sure the selection column always appears first.\n if (enableRowSelection) {\n return ['selection', ...columnOrdering];\n }\n\n return columnOrdering;\n }, [columnOrdering, enableRowSelection]);\n\n // Column visibiilty - record of column ID's to visibility, where false/no value = hidden.\n const columnVisibility = useMemo(() => {\n // We can't have no columns visible - if the array is empty we show them all.\n if (!hiddenColumns || hiddenColumns.length === columns.length) {\n return undefined;\n }\n\n return columns.reduce(\n (acc, column) => ({\n ...acc,\n [column.id]: !hiddenColumns.includes(column.id),\n }),\n {},\n );\n }, [hiddenColumns, columns]);\n\n // Pinned columns\n const columnPinning = useMemo(() => {\n let left = pinnedColumns?.left ?? [];\n\n // If we have any left-pinned columns, we need to include the selection column as it should appear first.\n if (enableRowSelection && left.length > 0) {\n left = [SELECTION_COLUMN_ID, ...left];\n }\n\n return {\n left,\n right: pinnedColumns?.right ?? [],\n };\n }, [pinnedColumns, enableRowSelection]);\n\n /**\n * Setup the TanStack table, including mapped column definitions, row data, and any additional state such as\n * column visibility and ordering.\n */\n const table = useReactTable<any>({\n data,\n columns: mappedColumnDefinitions,\n\n // Column settings\n columnResizeMode: resizeMode === 'off' ? undefined : resizeMode,\n enableColumnResizing,\n\n // Row model\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n\n // Sorting\n enableSorting,\n enableSortingRemoval,\n enableMultiRemove,\n manualSorting,\n onSortingChange,\n\n // Pinning\n enableColumnPinning: columnPinning.left.length + columnPinning.right.length > 0,\n\n // Selection\n enableRowSelection,\n enableMultiRowSelection,\n onRowSelectionChange,\n\n // Inject external table state\n state: {\n columnOrder,\n columnVisibility,\n columnPinning,\n sorting,\n rowSelection,\n },\n });\n\n /**\n * Pinned column layout\n */\n const { pinnedColumnLayoutStyles } = usePinnedColumnLayout({ table });\n\n /**\n * Other hooks\n */\n useDragToScroll({ targetRef: containerRef, ignoreClassName: 'data-grid-column-resizer' });\n useKeyboardNavigation({ tableRef, enableKeyboardNavigation });\n\n return (\n <GridContainer\n containerRef={containerRef}\n tableRef={tableRef}\n borderMode={borderMode}\n containerStyles={{ ...containerStyle, ...pinnedColumnLayoutStyles }}\n ariaRoles={ariaRoles}\n enableResizeableColumns={enableColumnResizing}\n density={density}\n table={table}\n aria-label={ariaLabel}\n >\n {/* Columns */}\n {enableColumnResizing && <Columns table={table} />}\n\n {/* Header */}\n <Header table={table} />\n\n {/* Body */}\n {table.getState().columnSizingInfo.isResizingColumn ? (\n <MemoizedBody table={table} ariaRoles={ariaRoles} striped={striped} />\n ) : (\n <Body table={table} ariaRoles={ariaRoles} striped={striped} />\n )}\n\n {/* Footer */}\n {showFooter && <Footer table={table} ariaRoles={ariaRoles} />}\n </GridContainer>\n );\n};\n"],"names":["useRef","useMemo","getAriaRoles","useSelectionState","useSortingState","ColumnMapper","SelectionColumnDefinition","SELECTION_COLUMN_ID","useReactTable","getCoreRowModel","usePinnedColumnLayout","useDragToScroll","useKeyboardNavigation","React","GridContainer","Columns","Header","MemoizedBody","Body","Footer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;;;AAiBG;AACU,MAAA,QAAQ,GAAG,CAAC,EACvB,OAAO,GAAG,MAAM,EAChB,OAAO,GAAG,IAAI,EACd,UAAU,GAAG,MAAM,EACnB,UAAU,GAAG,KAAK,EAClB,cAAc,EACd,wBAAwB,GAAG,KAAK,EAEhC,OAAO,EACP,aAAa,EACb,cAAc,EACd,aAAa,EAEb,IAAI,EACJ,QAAQ,EAER,SAAS,EACT,aAAa,EAEb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAElB,YAAY,EAAE,SAAS,GACT,KAAI;AAClB,IAAA,MAAM,YAAY,GAAGA,YAAM,CAAiB,IAAI,CAAC;AACjD,IAAA,MAAM,QAAQ,GAAGA,YAAM,CAAmB,IAAI,CAAC;IAE/C,MAAM,UAAU,GAAGC,aAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAC1F,IAAA,MAAM,SAAS,GAAGA,aAAO,CACvB,MAAMC,yBAAY,CAAC,wBAAwB,CAAC,EAC5C,CAAC,wBAAwB,CAAC,CAC3B;AACD,IAAA,MAAM,oBAAoB,GAAGD,aAAO,CAAC,MAAM,UAAU,KAAK,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC;AAE9E;;AAEG;IAEH,MAAM,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,YAAY,EAAE,oBAAoB,EAAE,GACvFE,mCAAiB,CAAC;QAChB,aAAa;QACb,YAAY;QACZ,YAAY;QACZ,kBAAkB;AACnB,KAAA,CAAC;IAEJ,MAAM,EACJ,aAAa,E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/C;AAEpB;;;;"}
|
|
1
|
+
{"version":3,"file":"DataGrid.cjs","sources":["../../../src/components/DataGrid/DataGrid.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { getCoreRowModel, getExpandedRowModel, useReactTable } from '@tanstack/react-table';\n\nimport { useDragToScroll } from '../../hooks';\n\nimport { DataGridProps } from './types';\nimport { ColumnMapper, getAriaRoles } from './utils';\nimport { GridContainer, Header, Body, Footer, Columns } from './components';\nimport { MemoizedBody } from './components/Body';\n\nimport { usePinnedColumnLayout, useSortingState, useKeyboardNavigation } from './hooks';\n\nimport { useSelectionState } from './hooks/useSelectionState';\nimport { SELECTION_COLUMN_ID } from './constants';\nimport { SelectionColumnDefinition } from './columns';\nimport { useExpandedState } from './hooks/useExpandedState';\n\n/**\n * [WIP]\n *\n * A DataGrid component which renders data in a two-dimensional format, with columns and rows. Unlike the `DataTable`\n * component, the `DataGrid` supports both flat and hierarchical (tree) data.\n *\n * Under the hood, it uses [TanStack Table](http://tanstack.com/table/) for table management, and aims to replicate functionality\n * available in major third party grid components such as CloudScape's Table component, AgGrid, etc.\n *\n * Supported features include:\n * - Pinning, resizing (incl. smooth resizing), reordering, and hiding of columns\n * - Selection (single and multiple) and disabling of rows.\n * - Rendering of arbitrarily nested data, expanding/collapsing, and custom full-width 'group' rows.\n * - In-built keyboard navigation with arrow keys, and drag to scroll.\n * - Configurable density.\n *\n * *Important: This component uses CSS modules, and therefore requires a `<ThemeInjector />` to be present on your page.*\n */\nexport const DataGrid = ({\n density = 'base',\n striped = true,\n borderMode = 'full',\n resizeMode = 'off',\n containerStyle,\n enableKeyboardNavigation = false,\n\n columns,\n hiddenColumns,\n columnOrdering,\n pinnedColumns,\n\n data,\n getRowId,\n\n sortState,\n onSortChanged,\n\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n\n rowGrouping,\n\n 'aria-label': ariaLabel,\n}: DataGridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const tableRef = useRef<HTMLTableElement>(null);\n\n const showFooter = useMemo(() => columns.some((column) => column.renderFooter), [columns]);\n const ariaRoles = useMemo(\n () => getAriaRoles({ enableKeyboardNavigation, rowGrouping }),\n [enableKeyboardNavigation, rowGrouping],\n );\n const enableColumnResizing = useMemo(() => resizeMode !== 'off', [resizeMode]);\n\n /**\n * Hooks to handle state for selection, sorting, and expanded/collapsed.\n */\n\n const { enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange } =\n useSelectionState({\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n });\n\n const {\n enableSorting,\n enableMultiRemove,\n enableSortingRemoval,\n manualSorting,\n sorting,\n onSortingChange,\n } = useSortingState({ columns, sortState, onSortChanged });\n\n const { expanded, onExpandedChange, enableExpanding, getRowCanExpand, getSubRows } =\n useExpandedState(rowGrouping);\n\n /**\n * Mapping of column definitions.\n */\n const columnMapper = useRef(new ColumnMapper());\n const mappedColumnDefinitions = useMemo(() => {\n const mappedColumns = columns.map((column) => columnMapper.current.mapColumnDefinition(column));\n\n if (enableRowSelection) {\n mappedColumns.unshift(SelectionColumnDefinition);\n }\n\n return mappedColumns;\n }, [columns, enableRowSelection]);\n\n /**\n * Stable references for column states (visibility, order, pinning).\n */\n\n // Column render order - the order of the array indicates the order on screen.\n const columnOrder = useMemo(() => {\n if (!columnOrdering || columnOrdering.length === 0) {\n return undefined;\n }\n\n // If we have a custom column order, we need to make sure the selection column always appears first.\n if (enableRowSelection) {\n return ['selection', ...columnOrdering];\n }\n\n return columnOrdering;\n }, [columnOrdering, enableRowSelection]);\n\n // Column visibiilty - record of column ID's to visibility, where false/no value = hidden.\n const columnVisibility = useMemo(() => {\n // We can't have no columns visible - if the array is empty we show them all.\n if (!hiddenColumns || hiddenColumns.length === columns.length) {\n return undefined;\n }\n\n return columns.reduce(\n (acc, column) => ({\n ...acc,\n [column.id]: !hiddenColumns.includes(column.id),\n }),\n {},\n );\n }, [hiddenColumns, columns]);\n\n // Pinned columns\n const columnPinning = useMemo(() => {\n let left = pinnedColumns?.left ?? [];\n\n // If we have any left-pinned columns, we need to include the selection column as it should appear first.\n if (enableRowSelection && left.length > 0) {\n left = [SELECTION_COLUMN_ID, ...left];\n }\n\n return {\n left,\n right: pinnedColumns?.right ?? [],\n };\n }, [pinnedColumns, enableRowSelection]);\n\n /**\n * Setup the TanStack table, including mapped column definitions, row data, and any additional state such as\n * column visibility and ordering.\n */\n const table = useReactTable<any>({\n data,\n columns: mappedColumnDefinitions,\n\n // Column settings\n columnResizeMode: resizeMode === 'off' ? undefined : resizeMode,\n enableColumnResizing,\n\n // Row model\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n\n // Sorting\n enableSorting,\n enableSortingRemoval,\n enableMultiRemove,\n manualSorting,\n onSortingChange,\n\n // Pinning\n enableColumnPinning: columnPinning.left.length + columnPinning.right.length > 0,\n\n // Selection\n enableRowSelection,\n enableMultiRowSelection,\n onRowSelectionChange,\n\n // Row grouping\n getSubRows,\n getRowCanExpand,\n onExpandedChange,\n enableExpanding,\n getExpandedRowModel: enableExpanding ? getExpandedRowModel() : undefined,\n\n // Inject external table state\n state: {\n columnOrder,\n columnVisibility,\n columnPinning,\n sorting,\n rowSelection,\n expanded,\n },\n });\n\n /**\n * Pinned column layout\n */\n const { pinnedColumnLayoutStyles } = usePinnedColumnLayout({ table });\n\n /**\n * Other hooks\n */\n useDragToScroll({ targetRef: containerRef, ignoreClassName: 'data-grid-column-resizer' });\n useKeyboardNavigation({ tableRef, enableKeyboardNavigation });\n\n return (\n <GridContainer\n containerRef={containerRef}\n tableRef={tableRef}\n borderMode={borderMode}\n containerStyles={{ ...containerStyle, ...pinnedColumnLayoutStyles }}\n ariaRoles={ariaRoles}\n enableResizeableColumns={enableColumnResizing}\n density={density}\n table={table}\n aria-label={ariaLabel}\n >\n {/* Columns */}\n {enableColumnResizing && <Columns table={table} />}\n\n {/* Header */}\n <Header table={table} />\n\n {/* Body */}\n {table.getState().columnSizingInfo.isResizingColumn ? (\n <MemoizedBody table={table} ariaRoles={ariaRoles} striped={striped} />\n ) : (\n <Body table={table} ariaRoles={ariaRoles} striped={striped} />\n )}\n\n {/* Footer */}\n {showFooter && <Footer table={table} ariaRoles={ariaRoles} />}\n </GridContainer>\n );\n};\n"],"names":["useRef","useMemo","getAriaRoles","useSelectionState","useSortingState","useExpandedState","ColumnMapper","SelectionColumnDefinition","SELECTION_COLUMN_ID","useReactTable","getCoreRowModel","getExpandedRowModel","usePinnedColumnLayout","useDragToScroll","useKeyboardNavigation","React","GridContainer","Columns","Header","MemoizedBody","Body","Footer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;;;;;AAiBG;AACU,MAAA,QAAQ,GAAG,CAAC,EACvB,OAAO,GAAG,MAAM,EAChB,OAAO,GAAG,IAAI,EACd,UAAU,GAAG,MAAM,EACnB,UAAU,GAAG,KAAK,EAClB,cAAc,EACd,wBAAwB,GAAG,KAAK,EAEhC,OAAO,EACP,aAAa,EACb,cAAc,EACd,aAAa,EAEb,IAAI,EACJ,QAAQ,EAER,SAAS,EACT,aAAa,EAEb,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAElB,WAAW,EAEX,YAAY,EAAE,SAAS,GACT,KAAI;AAClB,IAAA,MAAM,YAAY,GAAGA,YAAM,CAAiB,IAAI,CAAC;AACjD,IAAA,MAAM,QAAQ,GAAGA,YAAM,CAAmB,IAAI,CAAC;IAE/C,MAAM,UAAU,GAAGC,aAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1F,MAAM,SAAS,GAAGA,aAAO,CACvB,MAAMC,yBAAY,CAAC,EAAE,wBAAwB,EAAE,WAAW,EAAE,CAAC,EAC7D,CAAC,wBAAwB,EAAE,WAAW,CAAC,CACxC;AACD,IAAA,MAAM,oBAAoB,GAAGD,aAAO,CAAC,MAAM,UAAU,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,EAAC,KAAK,EAAE,KAAK,EAAI,CAAA;QAGvB,KAAK,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,IACjDH,sBAAC,CAAA,aAAA,CAAAI,iBAAY,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI,KAEtEJ,sBAAA,CAAA,aAAA,CAACK,SAAI,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI,CAC/D;AAGA,QAAA,UAAU,IAAIL,sBAAA,CAAA,aAAA,CAACM,aAAM,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAI,CAAA,CAC/C;AAEpB;;;;"}
|
|
@@ -18,4 +18,4 @@ import { DataGridProps } from './types';
|
|
|
18
18
|
*
|
|
19
19
|
* *Important: This component uses CSS modules, and therefore requires a `<ThemeInjector />` to be present on your page.*
|
|
20
20
|
*/
|
|
21
|
-
export declare const DataGrid: ({ density, striped, borderMode, resizeMode, containerStyle, enableKeyboardNavigation, columns, hiddenColumns, columnOrdering, pinnedColumns, data, getRowId, sortState, onSortChanged, selectionMode, selectedRows, disabledRows, onSelectionChanged, "aria-label": ariaLabel, }: DataGridProps) => React.JSX.Element;
|
|
21
|
+
export declare const DataGrid: ({ density, striped, borderMode, resizeMode, containerStyle, enableKeyboardNavigation, columns, hiddenColumns, columnOrdering, pinnedColumns, data, getRowId, sortState, onSortChanged, selectionMode, selectedRows, disabledRows, onSelectionChanged, rowGrouping, "aria-label": ariaLabel, }: DataGridProps) => React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default, { useRef, useMemo } from 'react';
|
|
2
|
-
import { useReactTable, getCoreRowModel } from '@tanstack/react-table';
|
|
2
|
+
import { useReactTable, getCoreRowModel, getExpandedRowModel } from '@tanstack/react-table';
|
|
3
3
|
import '../../hooks/useFocusVisible.js';
|
|
4
4
|
import 'uid/secure';
|
|
5
5
|
import { useDragToScroll } from '../../hooks/useDragToScroll.js';
|
|
@@ -17,6 +17,7 @@ import { useKeyboardNavigation } from './hooks/useKeyboardNavigation.js';
|
|
|
17
17
|
import { useSelectionState } from './hooks/useSelectionState.js';
|
|
18
18
|
import { SELECTION_COLUMN_ID } from './constants.js';
|
|
19
19
|
import { SelectionColumnDefinition } from './columns/SelectionColumnDefinition.js';
|
|
20
|
+
import { useExpandedState } from './hooks/useExpandedState.js';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* [WIP]
|
|
@@ -36,14 +37,14 @@ import { SelectionColumnDefinition } from './columns/SelectionColumnDefinition.j
|
|
|
36
37
|
*
|
|
37
38
|
* *Important: This component uses CSS modules, and therefore requires a `<ThemeInjector />` to be present on your page.*
|
|
38
39
|
*/
|
|
39
|
-
const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resizeMode = 'off', containerStyle, enableKeyboardNavigation = false, columns, hiddenColumns, columnOrdering, pinnedColumns, data, getRowId, sortState, onSortChanged, selectionMode, selectedRows, disabledRows, onSelectionChanged, 'aria-label': ariaLabel, }) => {
|
|
40
|
+
const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resizeMode = 'off', containerStyle, enableKeyboardNavigation = false, columns, hiddenColumns, columnOrdering, pinnedColumns, data, getRowId, sortState, onSortChanged, selectionMode, selectedRows, disabledRows, onSelectionChanged, rowGrouping, 'aria-label': ariaLabel, }) => {
|
|
40
41
|
const containerRef = useRef(null);
|
|
41
42
|
const tableRef = useRef(null);
|
|
42
43
|
const showFooter = useMemo(() => columns.some((column) => column.renderFooter), [columns]);
|
|
43
|
-
const ariaRoles = useMemo(() => getAriaRoles(enableKeyboardNavigation), [enableKeyboardNavigation]);
|
|
44
|
+
const ariaRoles = useMemo(() => getAriaRoles({ enableKeyboardNavigation, rowGrouping }), [enableKeyboardNavigation, rowGrouping]);
|
|
44
45
|
const enableColumnResizing = useMemo(() => resizeMode !== 'off', [resizeMode]);
|
|
45
46
|
/**
|
|
46
|
-
* Hooks to handle state for selection and
|
|
47
|
+
* Hooks to handle state for selection, sorting, and expanded/collapsed.
|
|
47
48
|
*/
|
|
48
49
|
const { enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange } = useSelectionState({
|
|
49
50
|
selectionMode,
|
|
@@ -52,6 +53,7 @@ const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resiz
|
|
|
52
53
|
onSelectionChanged,
|
|
53
54
|
});
|
|
54
55
|
const { enableSorting, enableMultiRemove, enableSortingRemoval, manualSorting, sorting, onSortingChange, } = useSortingState({ columns, sortState, onSortChanged });
|
|
56
|
+
const { expanded, onExpandedChange, enableExpanding, getRowCanExpand, getSubRows } = useExpandedState(rowGrouping);
|
|
55
57
|
/**
|
|
56
58
|
* Mapping of column definitions.
|
|
57
59
|
*/
|
|
@@ -126,6 +128,12 @@ const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resiz
|
|
|
126
128
|
enableRowSelection,
|
|
127
129
|
enableMultiRowSelection,
|
|
128
130
|
onRowSelectionChange,
|
|
131
|
+
// Row grouping
|
|
132
|
+
getSubRows,
|
|
133
|
+
getRowCanExpand,
|
|
134
|
+
onExpandedChange,
|
|
135
|
+
enableExpanding,
|
|
136
|
+
getExpandedRowModel: enableExpanding ? getExpandedRowModel() : undefined,
|
|
129
137
|
// Inject external table state
|
|
130
138
|
state: {
|
|
131
139
|
columnOrder,
|
|
@@ -133,6 +141,7 @@ const DataGrid = ({ density = 'base', striped = true, borderMode = 'full', resiz
|
|
|
133
141
|
columnPinning,
|
|
134
142
|
sorting,
|
|
135
143
|
rowSelection,
|
|
144
|
+
expanded,
|
|
136
145
|
},
|
|
137
146
|
});
|
|
138
147
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGrid.js","sources":["../../../src/components/DataGrid/DataGrid.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { getCoreRowModel, useReactTable } from '@tanstack/react-table';\n\nimport { useDragToScroll } from '../../hooks';\n\nimport { DataGridProps } from './types';\nimport { ColumnMapper, getAriaRoles } from './utils';\nimport { GridContainer, Header, Body, Footer, Columns } from './components';\nimport { MemoizedBody } from './components/Body';\n\nimport { usePinnedColumnLayout, useSortingState, useKeyboardNavigation } from './hooks';\n\nimport { useSelectionState } from './hooks/useSelectionState';\nimport { SELECTION_COLUMN_ID } from './constants';\nimport { SelectionColumnDefinition } from './columns';\n\n/**\n * [WIP]\n *\n * A DataGrid component which renders data in a two-dimensional format, with columns and rows. Unlike the `DataTable`\n * component, the `DataGrid` supports both flat and hierarchical (tree) data.\n *\n * Under the hood, it uses [TanStack Table](http://tanstack.com/table/) for table management, and aims to replicate functionality\n * available in major third party grid components such as CloudScape's Table component, AgGrid, etc.\n *\n * Supported features include:\n * - Pinning, resizing (incl. smooth resizing), reordering, and hiding of columns\n * - Selection (single and multiple) and disabling of rows.\n * - Rendering of arbitrarily nested data, expanding/collapsing, and custom full-width 'group' rows.\n * - In-built keyboard navigation with arrow keys, and drag to scroll.\n * - Configurable density.\n *\n * *Important: This component uses CSS modules, and therefore requires a `<ThemeInjector />` to be present on your page.*\n */\nexport const DataGrid = ({\n density = 'base',\n striped = true,\n borderMode = 'full',\n resizeMode = 'off',\n containerStyle,\n enableKeyboardNavigation = false,\n\n columns,\n hiddenColumns,\n columnOrdering,\n pinnedColumns,\n\n data,\n getRowId,\n\n sortState,\n onSortChanged,\n\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n\n 'aria-label': ariaLabel,\n}: DataGridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const tableRef = useRef<HTMLTableElement>(null);\n\n const showFooter = useMemo(() => columns.some((column) => column.renderFooter), [columns]);\n const ariaRoles = useMemo(\n () => getAriaRoles(enableKeyboardNavigation),\n [enableKeyboardNavigation],\n );\n const enableColumnResizing = useMemo(() => resizeMode !== 'off', [resizeMode]);\n\n /**\n * Hooks to handle state for selection and sorting.\n */\n\n const { enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange } =\n useSelectionState({\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n });\n\n const {\n enableSorting,\n enableMultiRemove,\n enableSortingRemoval,\n manualSorting,\n sorting,\n onSortingChange,\n } = useSortingState({ columns, sortState, onSortChanged });\n\n /**\n * Mapping of column definitions.\n */\n const columnMapper = useRef(new ColumnMapper());\n const mappedColumnDefinitions = useMemo(() => {\n const mappedColumns = columns.map((column) => columnMapper.current.mapColumnDefinition(column));\n\n if (enableRowSelection) {\n mappedColumns.unshift(SelectionColumnDefinition);\n }\n\n return mappedColumns;\n }, [columns, enableRowSelection]);\n\n /**\n * Stable references for column states (visibility, order, pinning).\n */\n\n // Column render order - the order of the array indicates the order on screen.\n const columnOrder = useMemo(() => {\n if (!columnOrdering || columnOrdering.length === 0) {\n return undefined;\n }\n\n // If we have a custom column order, we need to make sure the selection column always appears first.\n if (enableRowSelection) {\n return ['selection', ...columnOrdering];\n }\n\n return columnOrdering;\n }, [columnOrdering, enableRowSelection]);\n\n // Column visibiilty - record of column ID's to visibility, where false/no value = hidden.\n const columnVisibility = useMemo(() => {\n // We can't have no columns visible - if the array is empty we show them all.\n if (!hiddenColumns || hiddenColumns.length === columns.length) {\n return undefined;\n }\n\n return columns.reduce(\n (acc, column) => ({\n ...acc,\n [column.id]: !hiddenColumns.includes(column.id),\n }),\n {},\n );\n }, [hiddenColumns, columns]);\n\n // Pinned columns\n const columnPinning = useMemo(() => {\n let left = pinnedColumns?.left ?? [];\n\n // If we have any left-pinned columns, we need to include the selection column as it should appear first.\n if (enableRowSelection && left.length > 0) {\n left = [SELECTION_COLUMN_ID, ...left];\n }\n\n return {\n left,\n right: pinnedColumns?.right ?? [],\n };\n }, [pinnedColumns, enableRowSelection]);\n\n /**\n * Setup the TanStack table, including mapped column definitions, row data, and any additional state such as\n * column visibility and ordering.\n */\n const table = useReactTable<any>({\n data,\n columns: mappedColumnDefinitions,\n\n // Column settings\n columnResizeMode: resizeMode === 'off' ? undefined : resizeMode,\n enableColumnResizing,\n\n // Row model\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n\n // Sorting\n enableSorting,\n enableSortingRemoval,\n enableMultiRemove,\n manualSorting,\n onSortingChange,\n\n // Pinning\n enableColumnPinning: columnPinning.left.length + columnPinning.right.length > 0,\n\n // Selection\n enableRowSelection,\n enableMultiRowSelection,\n onRowSelectionChange,\n\n // Inject external table state\n state: {\n columnOrder,\n columnVisibility,\n columnPinning,\n sorting,\n rowSelection,\n },\n });\n\n /**\n * Pinned column layout\n */\n const { pinnedColumnLayoutStyles } = usePinnedColumnLayout({ table });\n\n /**\n * Other hooks\n */\n useDragToScroll({ targetRef: containerRef, ignoreClassName: 'data-grid-column-resizer' });\n useKeyboardNavigation({ tableRef, enableKeyboardNavigation });\n\n return (\n <GridContainer\n containerRef={containerRef}\n tableRef={tableRef}\n borderMode={borderMode}\n containerStyles={{ ...containerStyle, ...pinnedColumnLayoutStyles }}\n ariaRoles={ariaRoles}\n enableResizeableColumns={enableColumnResizing}\n density={density}\n table={table}\n aria-label={ariaLabel}\n >\n {/* Columns */}\n {enableColumnResizing && <Columns table={table} />}\n\n {/* Header */}\n <Header table={table} />\n\n {/* Body */}\n {table.getState().columnSizingInfo.isResizingColumn ? (\n <MemoizedBody table={table} ariaRoles={ariaRoles} striped={striped} />\n ) : (\n <Body table={table} ariaRoles={ariaRoles} striped={striped} />\n )}\n\n {/* Footer */}\n {showFooter && <Footer table={table} ariaRoles={ariaRoles} />}\n </GridContainer>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;;;AAiBG;AACU,MAAA,QAAQ,GAAG,CAAC,EACvB,OAAO,GAAG,MAAM,EAChB,OAAO,GAAG,IAAI,EACd,UAAU,GAAG,MAAM,EACnB,UAAU,GAAG,KAAK,EAClB,cAAc,EACd,wBAAwB,GAAG,K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ACtB,eAAe,EAAE,EAAE,GAAG,cAAc,EAAE,GAAG,wBAAwB,EAAE,EACnE,SAAS,EAAE,SAAS,EACpB,uBAAuB,EAAE,oBAAoB,EAC7C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,gBACA,SAAS,EAAA;AAGpB,QAAA,oBAAoB,IAAIA,cAAC,CAAA,aAAA,CAAA,OAAO,IAAC,KAAK,EAAE,KAAK,EAAI,CAAA;AAGlD,QAAAA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,KAAK,EAAE,KAAK,EAAI,CAAA;QAGvB,KAAK,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,IACjDA,cAAC,CAAA,aAAA,CAAA,YAAY,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI,KAEtEA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI,CAC/D;AAGA,QAAA,UAAU,IAAIA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAI,CAAA,CAC/C;AAEpB;;;;"}
|
|
1
|
+
{"version":3,"file":"DataGrid.js","sources":["../../../src/components/DataGrid/DataGrid.tsx"],"sourcesContent":["import React, { useMemo, useRef } from 'react';\nimport { getCoreRowModel, getExpandedRowModel, useReactTable } from '@tanstack/react-table';\n\nimport { useDragToScroll } from '../../hooks';\n\nimport { DataGridProps } from './types';\nimport { ColumnMapper, getAriaRoles } from './utils';\nimport { GridContainer, Header, Body, Footer, Columns } from './components';\nimport { MemoizedBody } from './components/Body';\n\nimport { usePinnedColumnLayout, useSortingState, useKeyboardNavigation } from './hooks';\n\nimport { useSelectionState } from './hooks/useSelectionState';\nimport { SELECTION_COLUMN_ID } from './constants';\nimport { SelectionColumnDefinition } from './columns';\nimport { useExpandedState } from './hooks/useExpandedState';\n\n/**\n * [WIP]\n *\n * A DataGrid component which renders data in a two-dimensional format, with columns and rows. Unlike the `DataTable`\n * component, the `DataGrid` supports both flat and hierarchical (tree) data.\n *\n * Under the hood, it uses [TanStack Table](http://tanstack.com/table/) for table management, and aims to replicate functionality\n * available in major third party grid components such as CloudScape's Table component, AgGrid, etc.\n *\n * Supported features include:\n * - Pinning, resizing (incl. smooth resizing), reordering, and hiding of columns\n * - Selection (single and multiple) and disabling of rows.\n * - Rendering of arbitrarily nested data, expanding/collapsing, and custom full-width 'group' rows.\n * - In-built keyboard navigation with arrow keys, and drag to scroll.\n * - Configurable density.\n *\n * *Important: This component uses CSS modules, and therefore requires a `<ThemeInjector />` to be present on your page.*\n */\nexport const DataGrid = ({\n density = 'base',\n striped = true,\n borderMode = 'full',\n resizeMode = 'off',\n containerStyle,\n enableKeyboardNavigation = false,\n\n columns,\n hiddenColumns,\n columnOrdering,\n pinnedColumns,\n\n data,\n getRowId,\n\n sortState,\n onSortChanged,\n\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n\n rowGrouping,\n\n 'aria-label': ariaLabel,\n}: DataGridProps) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const tableRef = useRef<HTMLTableElement>(null);\n\n const showFooter = useMemo(() => columns.some((column) => column.renderFooter), [columns]);\n const ariaRoles = useMemo(\n () => getAriaRoles({ enableKeyboardNavigation, rowGrouping }),\n [enableKeyboardNavigation, rowGrouping],\n );\n const enableColumnResizing = useMemo(() => resizeMode !== 'off', [resizeMode]);\n\n /**\n * Hooks to handle state for selection, sorting, and expanded/collapsed.\n */\n\n const { enableRowSelection, enableMultiRowSelection, rowSelection, onRowSelectionChange } =\n useSelectionState({\n selectionMode,\n selectedRows,\n disabledRows,\n onSelectionChanged,\n });\n\n const {\n enableSorting,\n enableMultiRemove,\n enableSortingRemoval,\n manualSorting,\n sorting,\n onSortingChange,\n } = useSortingState({ columns, sortState, onSortChanged });\n\n const { expanded, onExpandedChange, enableExpanding, getRowCanExpand, getSubRows } =\n useExpandedState(rowGrouping);\n\n /**\n * Mapping of column definitions.\n */\n const columnMapper = useRef(new ColumnMapper());\n const mappedColumnDefinitions = useMemo(() => {\n const mappedColumns = columns.map((column) => columnMapper.current.mapColumnDefinition(column));\n\n if (enableRowSelection) {\n mappedColumns.unshift(SelectionColumnDefinition);\n }\n\n return mappedColumns;\n }, [columns, enableRowSelection]);\n\n /**\n * Stable references for column states (visibility, order, pinning).\n */\n\n // Column render order - the order of the array indicates the order on screen.\n const columnOrder = useMemo(() => {\n if (!columnOrdering || columnOrdering.length === 0) {\n return undefined;\n }\n\n // If we have a custom column order, we need to make sure the selection column always appears first.\n if (enableRowSelection) {\n return ['selection', ...columnOrdering];\n }\n\n return columnOrdering;\n }, [columnOrdering, enableRowSelection]);\n\n // Column visibiilty - record of column ID's to visibility, where false/no value = hidden.\n const columnVisibility = useMemo(() => {\n // We can't have no columns visible - if the array is empty we show them all.\n if (!hiddenColumns || hiddenColumns.length === columns.length) {\n return undefined;\n }\n\n return columns.reduce(\n (acc, column) => ({\n ...acc,\n [column.id]: !hiddenColumns.includes(column.id),\n }),\n {},\n );\n }, [hiddenColumns, columns]);\n\n // Pinned columns\n const columnPinning = useMemo(() => {\n let left = pinnedColumns?.left ?? [];\n\n // If we have any left-pinned columns, we need to include the selection column as it should appear first.\n if (enableRowSelection && left.length > 0) {\n left = [SELECTION_COLUMN_ID, ...left];\n }\n\n return {\n left,\n right: pinnedColumns?.right ?? [],\n };\n }, [pinnedColumns, enableRowSelection]);\n\n /**\n * Setup the TanStack table, including mapped column definitions, row data, and any additional state such as\n * column visibility and ordering.\n */\n const table = useReactTable<any>({\n data,\n columns: mappedColumnDefinitions,\n\n // Column settings\n columnResizeMode: resizeMode === 'off' ? undefined : resizeMode,\n enableColumnResizing,\n\n // Row model\n getRowId,\n getCoreRowModel: getCoreRowModel(),\n\n // Sorting\n enableSorting,\n enableSortingRemoval,\n enableMultiRemove,\n manualSorting,\n onSortingChange,\n\n // Pinning\n enableColumnPinning: columnPinning.left.length + columnPinning.right.length > 0,\n\n // Selection\n enableRowSelection,\n enableMultiRowSelection,\n onRowSelectionChange,\n\n // Row grouping\n getSubRows,\n getRowCanExpand,\n onExpandedChange,\n enableExpanding,\n getExpandedRowModel: enableExpanding ? getExpandedRowModel() : undefined,\n\n // Inject external table state\n state: {\n columnOrder,\n columnVisibility,\n columnPinning,\n sorting,\n rowSelection,\n expanded,\n },\n });\n\n /**\n * Pinned column layout\n */\n const { pinnedColumnLayoutStyles } = usePinnedColumnLayout({ table });\n\n /**\n * Other hooks\n */\n useDragToScroll({ targetRef: containerRef, ignoreClassName: 'data-grid-column-resizer' });\n useKeyboardNavigation({ tableRef, enableKeyboardNavigation });\n\n return (\n <GridContainer\n containerRef={containerRef}\n tableRef={tableRef}\n borderMode={borderMode}\n containerStyles={{ ...containerStyle, ...pinnedColumnLayoutStyles }}\n ariaRoles={ariaRoles}\n enableResizeableColumns={enableColumnResizing}\n density={density}\n table={table}\n aria-label={ariaLabel}\n >\n {/* Columns */}\n {enableColumnResizing && <Columns table={table} />}\n\n {/* Header */}\n <Header table={table} />\n\n {/* Body */}\n {table.getState().columnSizingInfo.isResizingColumn ? (\n <MemoizedBody table={table} ariaRoles={ariaRoles} striped={striped} />\n ) : (\n <Body table={table} ariaRoles={ariaRoles} striped={striped} />\n )}\n\n {/* Footer */}\n {showFooter && <Footer table={table} ariaRoles={ariaRoles} />}\n </GridContainer>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;;;;;AAiBG;AACU,MAAA,QAAQ,GAAG,CAAC,EACvB,OAAO,GAAG,MAAM,EAChB,OAAO,GAAG,IAAI,EACd,UAAU,GAAG,MAAM,EACnB,UAAU,GAAG,KAAK,EAClB,cAAc,EACd,wBAAwB,GAAG,KAAK,EAEhC,OAAO,EACP,aAAa,EACb,cAAc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S,EAAE,YAAY,EAAE,eAAe,EAAE,0BAA0B,EAAE,CAAC;AACzF,IAAA,qBAAqB,CAAC,EAAE,QAAQ,EAAE,wBAAwB,EAAE,CAAC;AAE7D,IAAA,QACEA,cAAC,CAAA,aAAA,CAAA,aAAa,IACZ,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,eAAe,EAAE,EAAE,GAAG,cAAc,EAAE,GAAG,wBAAwB,EAAE,EACnE,SAAS,EAAE,SAAS,EACpB,uBAAuB,EAAE,oBAAoB,EAC7C,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,gBACA,SAAS,EAAA;AAGpB,QAAA,oBAAoB,IAAIA,cAAC,CAAA,aAAA,CAAA,OAAO,IAAC,KAAK,EAAE,KAAK,EAAI,CAAA;AAGlD,QAAAA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,KAAK,EAAE,KAAK,EAAI,CAAA;QAGvB,KAAK,CAAC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,gBAAgB,IACjDA,cAAC,CAAA,aAAA,CAAA,YAAY,IAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI,KAEtEA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAC,EAAA,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAA,CAAI,CAC/D;AAGA,QAAA,UAAU,IAAIA,cAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAI,CAAA,CAC/C;AAEpB;;;;"}
|
|
@@ -9,7 +9,10 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
10
10
|
|
|
11
11
|
const Body = ({ table, striped, ariaRoles }) => {
|
|
12
|
-
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const enableExpanding = (_a = table.options.enableExpanding) !== null && _a !== undefined ? _a : false;
|
|
14
|
+
const enableRowSelection = (_b = table.options.enableRowSelection) !== null && _b !== undefined ? _b : false;
|
|
15
|
+
return (React__default.default.createElement("tbody", { className: "data-grid-body" }, table.getRowModel().rows.map((row) => (React__default.default.createElement(Row.Row, { key: row.id, row: row, striped: striped, enableExpanding: enableExpanding }, row.getVisibleCells().map((cell) => (React__default.default.createElement(BodyCell.BodyCell, { cell: cell, key: cell.id, ariaRoles: ariaRoles, enableExpanding: enableExpanding, enableRowSelection: !!enableRowSelection }))))))));
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
15
18
|
* Memoized table body, used to prevent rerenders when columns are being resized.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Body.cjs","sources":["../../../../../src/components/DataGrid/components/Body/Body.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@tanstack/react-table';\n\nimport { BodyCell } from './BodyCell';\nimport { Row } from './Row';\nimport { AriaRoles } from '../../types';\n\ntype BodyProps = {\n /**\n * TanStack table instance.\n */\n table: Table<any>;\n\n /**\n * Whether the rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * ARIA roles for the table.\n */\n ariaRoles: AriaRoles;\n};\n\nexport const Body = ({ table, striped, ariaRoles }: BodyProps) => {\n return (\n <tbody className=\"data-grid-body\">\n {table.getRowModel().rows.map((row) => (\n <Row key={row.id} row={row} striped={striped}>\n {row.getVisibleCells().map((cell) => (\n <BodyCell
|
|
1
|
+
{"version":3,"file":"Body.cjs","sources":["../../../../../src/components/DataGrid/components/Body/Body.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@tanstack/react-table';\n\nimport { BodyCell } from './BodyCell';\nimport { Row } from './Row';\nimport { AriaRoles } from '../../types';\n\ntype BodyProps = {\n /**\n * TanStack table instance.\n */\n table: Table<any>;\n\n /**\n * Whether the rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * ARIA roles for the table.\n */\n ariaRoles: AriaRoles;\n};\n\nexport const Body = ({ table, striped, ariaRoles }: BodyProps) => {\n const enableExpanding = table.options.enableExpanding ?? false;\n const enableRowSelection = table.options.enableRowSelection ?? false;\n\n return (\n <tbody className=\"data-grid-body\">\n {table.getRowModel().rows.map((row) => (\n <Row key={row.id} row={row} striped={striped} enableExpanding={enableExpanding}>\n {row.getVisibleCells().map((cell) => (\n <BodyCell\n cell={cell}\n key={cell.id}\n ariaRoles={ariaRoles}\n enableExpanding={enableExpanding}\n enableRowSelection={!!enableRowSelection}\n />\n ))}\n </Row>\n ))}\n </tbody>\n );\n};\n\n/**\n * Memoized table body, used to prevent rerenders when columns are being resized.\n */\nexport const MemoizedBody = React.memo(\n Body,\n (prev, next) => prev.table.options.data === next.table.options.data,\n);\n"],"names":["React","Row","BodyCell"],"mappings":";;;;;;;;;;AAwBO,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAa,KAAI;;IAC/D,MAAM,eAAe,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,OAAO,CAAC,eAAe,MAAI,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,EAAA,GAAA,KAAK;IAC9D,MAAM,kBAAkB,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,OAAO,CAAC,kBAAkB,MAAI,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,EAAA,GAAA,KAAK;AAEpE,IAAA,QACEA,sBAAO,CAAA,aAAA,CAAA,OAAA,EAAA,EAAA,SAAS,EAAC,gBAAgB,EAAA,EAC9B,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAChCA,sBAAC,CAAA,aAAA,CAAAC,OAAG,IAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,IAC3E,GAAG,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,MAC9BD,qCAACE,iBAAQ,EAAA,EACP,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,kBAAkB,EAAE,CAAC,CAAC,kBAAkB,EAAA,CACxC,CACH,CAAC,CACE,CACP,CAAC,CACI;AAEZ;AAEA;;AAEG;AACI,MAAM,YAAY,GAAGF,sBAAK,CAAC,IAAI,CACpC,IAAI,EACJ,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI;;;;;"}
|
|
@@ -3,7 +3,10 @@ import { BodyCell } from './BodyCell/BodyCell.js';
|
|
|
3
3
|
import { Row } from './Row/Row.js';
|
|
4
4
|
|
|
5
5
|
const Body = ({ table, striped, ariaRoles }) => {
|
|
6
|
-
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const enableExpanding = (_a = table.options.enableExpanding) !== null && _a !== undefined ? _a : false;
|
|
8
|
+
const enableRowSelection = (_b = table.options.enableRowSelection) !== null && _b !== undefined ? _b : false;
|
|
9
|
+
return (React__default.createElement("tbody", { className: "data-grid-body" }, table.getRowModel().rows.map((row) => (React__default.createElement(Row, { key: row.id, row: row, striped: striped, enableExpanding: enableExpanding }, row.getVisibleCells().map((cell) => (React__default.createElement(BodyCell, { cell: cell, key: cell.id, ariaRoles: ariaRoles, enableExpanding: enableExpanding, enableRowSelection: !!enableRowSelection }))))))));
|
|
7
10
|
};
|
|
8
11
|
/**
|
|
9
12
|
* Memoized table body, used to prevent rerenders when columns are being resized.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Body.js","sources":["../../../../../src/components/DataGrid/components/Body/Body.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@tanstack/react-table';\n\nimport { BodyCell } from './BodyCell';\nimport { Row } from './Row';\nimport { AriaRoles } from '../../types';\n\ntype BodyProps = {\n /**\n * TanStack table instance.\n */\n table: Table<any>;\n\n /**\n * Whether the rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * ARIA roles for the table.\n */\n ariaRoles: AriaRoles;\n};\n\nexport const Body = ({ table, striped, ariaRoles }: BodyProps) => {\n return (\n <tbody className=\"data-grid-body\">\n {table.getRowModel().rows.map((row) => (\n <Row key={row.id} row={row} striped={striped}>\n {row.getVisibleCells().map((cell) => (\n <BodyCell
|
|
1
|
+
{"version":3,"file":"Body.js","sources":["../../../../../src/components/DataGrid/components/Body/Body.tsx"],"sourcesContent":["import React from 'react';\nimport { Table } from '@tanstack/react-table';\n\nimport { BodyCell } from './BodyCell';\nimport { Row } from './Row';\nimport { AriaRoles } from '../../types';\n\ntype BodyProps = {\n /**\n * TanStack table instance.\n */\n table: Table<any>;\n\n /**\n * Whether the rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * ARIA roles for the table.\n */\n ariaRoles: AriaRoles;\n};\n\nexport const Body = ({ table, striped, ariaRoles }: BodyProps) => {\n const enableExpanding = table.options.enableExpanding ?? false;\n const enableRowSelection = table.options.enableRowSelection ?? false;\n\n return (\n <tbody className=\"data-grid-body\">\n {table.getRowModel().rows.map((row) => (\n <Row key={row.id} row={row} striped={striped} enableExpanding={enableExpanding}>\n {row.getVisibleCells().map((cell) => (\n <BodyCell\n cell={cell}\n key={cell.id}\n ariaRoles={ariaRoles}\n enableExpanding={enableExpanding}\n enableRowSelection={!!enableRowSelection}\n />\n ))}\n </Row>\n ))}\n </tbody>\n );\n};\n\n/**\n * Memoized table body, used to prevent rerenders when columns are being resized.\n */\nexport const MemoizedBody = React.memo(\n Body,\n (prev, next) => prev.table.options.data === next.table.options.data,\n);\n"],"names":["React"],"mappings":";;;;AAwBO,MAAM,IAAI,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAa,KAAI;;IAC/D,MAAM,eAAe,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,OAAO,CAAC,eAAe,MAAI,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,EAAA,GAAA,KAAK;IAC9D,MAAM,kBAAkB,GAAG,CAAA,EAAA,GAAA,KAAK,CAAC,OAAO,CAAC,kBAAkB,MAAI,IAAA,IAAA,EAAA,KAAA,SAAA,GAAA,EAAA,GAAA,KAAK;AAEpE,IAAA,QACEA,cAAO,CAAA,aAAA,CAAA,OAAA,EAAA,EAAA,SAAS,EAAC,gBAAgB,EAAA,EAC9B,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAChCA,cAAC,CAAA,aAAA,CAAA,GAAG,IAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,IAC3E,GAAG,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,MAC9BA,6BAAC,QAAQ,EAAA,EACP,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,IAAI,CAAC,EAAE,EACZ,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,eAAe,EAChC,kBAAkB,EAAE,CAAC,CAAC,kBAAkB,EAAA,CACxC,CACH,CAAC,CACE,CACP,CAAC,CACI;AAEZ;AAEA;;AAEG;AACI,MAAM,YAAY,GAAGA,cAAK,CAAC,IAAI,CACpC,IAAI,EACJ,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI;;;;"}
|
|
@@ -6,6 +6,7 @@ var buildClassnames = require('../../../../../utils/buildClassnames.cjs');
|
|
|
6
6
|
require('uid/secure');
|
|
7
7
|
var CellContent = require('../../CellContent/CellContent.cjs');
|
|
8
8
|
var usePinnedColumnStyles = require('../../../hooks/usePinnedColumnStyles.cjs');
|
|
9
|
+
var useExpandableCell = require('./hooks/useExpandableCell.cjs');
|
|
9
10
|
var BodyCell_module = require('./BodyCell.module.scss.cjs');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
@@ -15,10 +16,15 @@ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
|
15
16
|
/**
|
|
16
17
|
* Renders a cell element, and its content, for a given column and row, within the grid body.
|
|
17
18
|
*/
|
|
18
|
-
const BodyCell = ({ cell, ariaRoles }) => {
|
|
19
|
+
const BodyCell = ({ cell, ariaRoles, enableRowSelection, enableExpanding, }) => {
|
|
19
20
|
const { justifyContent, textAlign, rowHeader } = cell.column.columnDef.meta;
|
|
20
21
|
const CellElement = rowHeader ? 'th' : 'td';
|
|
21
22
|
const { pinnedCellClassName, pinnedCellStyles } = usePinnedColumnStyles.usePinnedColumnStyles({ column: cell.column });
|
|
23
|
+
const { expandButtonProps, contentMarginLeft } = useExpandableCell.useExpandableCell({
|
|
24
|
+
cell,
|
|
25
|
+
enableExpanding,
|
|
26
|
+
enableRowSelection,
|
|
27
|
+
});
|
|
22
28
|
const bodyCellClassname = buildClassnames.buildClassnames([
|
|
23
29
|
BodyCell_module.bodyCell,
|
|
24
30
|
pinnedCellClassName,
|
|
@@ -26,9 +32,10 @@ const BodyCell = ({ cell, ariaRoles }) => {
|
|
|
26
32
|
]);
|
|
27
33
|
return (React__default.default.createElement(CellElement, { className: bodyCellClassname, "aria-colindex": cell.column.getIndex() + 1, scope: rowHeader ? 'row' : undefined, role: rowHeader ? 'rowheader' : ariaRoles.cell, style: pinnedCellStyles },
|
|
28
34
|
React__default.default.createElement(CellContent.CellContent, { contentStyle: {
|
|
35
|
+
marginLeft: contentMarginLeft,
|
|
29
36
|
justifyContent,
|
|
30
37
|
textAlign,
|
|
31
|
-
} }, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
38
|
+
}, expandButtonProps: expandButtonProps }, reactTable.flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
32
39
|
};
|
|
33
40
|
|
|
34
41
|
exports.BodyCell = BodyCell;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BodyCell.cjs","sources":["../../../../../../src/components/DataGrid/components/Body/BodyCell/BodyCell.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Cell, flexRender } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\nimport { AriaRoles } from '../../../types';\nimport { CellContent } from '../../CellContent';\nimport { usePinnedColumnStyles } from '../../../hooks';\n\nimport styles from './BodyCell.module.scss';\n\ntype ColumnCellProps = {\n /**\n * Cell within the TanStack Table instance.\n */\n cell: Cell<any, any>;\n\n /**\n * ARIA roles for the grid.\n */\n ariaRoles: AriaRoles;\n};\n\n/**\n * Renders a cell element, and its content, for a given column and row, within the grid body.\n */\nexport const BodyCell = ({
|
|
1
|
+
{"version":3,"file":"BodyCell.cjs","sources":["../../../../../../src/components/DataGrid/components/Body/BodyCell/BodyCell.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Cell, flexRender } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\nimport { AriaRoles } from '../../../types';\nimport { CellContent } from '../../CellContent';\nimport { usePinnedColumnStyles } from '../../../hooks';\n\nimport { useExpandableCell } from './hooks';\nimport styles from './BodyCell.module.scss';\n\ntype ColumnCellProps = {\n /**\n * Cell within the TanStack Table instance.\n */\n cell: Cell<any, any>;\n\n /**\n * ARIA roles for the grid.\n */\n ariaRoles: AriaRoles;\n\n /**\n * Whether row selection is enabled.\n */\n enableRowSelection: boolean;\n\n /**\n * Whether row expanding is enabled for the grid.\n */\n enableExpanding: boolean;\n};\n\n/**\n * Renders a cell element, and its content, for a given column and row, within the grid body.\n */\nexport const BodyCell = ({\n cell,\n ariaRoles,\n enableRowSelection,\n enableExpanding,\n}: ColumnCellProps) => {\n const { justifyContent, textAlign, rowHeader } = cell.column.columnDef.meta!;\n const CellElement = rowHeader ? 'th' : 'td';\n\n const { pinnedCellClassName, pinnedCellStyles } = usePinnedColumnStyles({ column: cell.column });\n\n const { expandButtonProps, contentMarginLeft } = useExpandableCell({\n cell,\n enableExpanding,\n enableRowSelection,\n });\n\n const bodyCellClassname = buildClassnames([\n styles.bodyCell,\n pinnedCellClassName,\n 'data-grid-cell',\n ]);\n\n return (\n <CellElement\n className={bodyCellClassname}\n aria-colindex={cell.column.getIndex() + 1}\n scope={rowHeader ? 'row' : undefined}\n role={rowHeader ? 'rowheader' : ariaRoles.cell}\n style={pinnedCellStyles}\n >\n <CellContent\n contentStyle={\n {\n marginLeft: contentMarginLeft,\n justifyContent,\n textAlign,\n } as React.CSSProperties\n }\n expandButtonProps={expandButtonProps}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </CellContent>\n </CellElement>\n );\n};\n"],"names":["usePinnedColumnStyles","useExpandableCell","buildClassnames","styles","React","CellContent","flexRender"],"mappings":";;;;;;;;;;;;;;;AAmCA;;AAEG;AACI,MAAM,QAAQ,GAAG,CAAC,EACvB,IAAI,EACJ,SAAS,EACT,kBAAkB,EAClB,eAAe,GACC,KAAI;AACpB,IAAA,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAK;IAC5E,MAAM,WAAW,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI;AAE3C,IAAA,MAAM,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,GAAGA,2CAAqB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAEhG,IAAA,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,GAAGC,mCAAiB,CAAC;QACjE,IAAI;QACJ,eAAe;QACf,kBAAkB;AACnB,KAAA,CAAC;IAEF,MAAM,iBAAiB,GAAGC,+BAAe,CAAC;AACxC,QAAAC,eAAM,CAAC,QAAQ;QACf,mBAAmB;QACnB,gBAAgB;AACjB,KAAA,CAAC;IAEF,QACEC,qCAAC,WAAW,EAAA,EACV,SAAS,EAAE,iBAAiB,mBACb,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,EACzC,KAAK,EAAE,SAAS,GAAG,KAAK,GAAG,SAAS,EACpC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC,IAAI,EAC9C,KAAK,EAAE,gBAAgB,EAAA;QAEvBA,sBAAC,CAAA,aAAA,CAAAC,uBAAW,EACV,EAAA,YAAY,EACV;AACE,gBAAA,UAAU,EAAE,iBAAiB;gBAC7B,cAAc;gBACd,SAAS;aACa,EAE1B,iBAAiB,EAAE,iBAAiB,EAAA,EAEnCC,qBAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAC9C,CACF;AAElB;;;;"}
|
|
@@ -10,9 +10,17 @@ type ColumnCellProps = {
|
|
|
10
10
|
* ARIA roles for the grid.
|
|
11
11
|
*/
|
|
12
12
|
ariaRoles: AriaRoles;
|
|
13
|
+
/**
|
|
14
|
+
* Whether row selection is enabled.
|
|
15
|
+
*/
|
|
16
|
+
enableRowSelection: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether row expanding is enabled for the grid.
|
|
19
|
+
*/
|
|
20
|
+
enableExpanding: boolean;
|
|
13
21
|
};
|
|
14
22
|
/**
|
|
15
23
|
* Renders a cell element, and its content, for a given column and row, within the grid body.
|
|
16
24
|
*/
|
|
17
|
-
export declare const BodyCell: ({ cell, ariaRoles }: ColumnCellProps) => React.JSX.Element;
|
|
25
|
+
export declare const BodyCell: ({ cell, ariaRoles, enableRowSelection, enableExpanding, }: ColumnCellProps) => React.JSX.Element;
|
|
18
26
|
export {};
|
|
@@ -4,15 +4,21 @@ import { buildClassnames } from '../../../../../utils/buildClassnames.js';
|
|
|
4
4
|
import 'uid/secure';
|
|
5
5
|
import { CellContent } from '../../CellContent/CellContent.js';
|
|
6
6
|
import { usePinnedColumnStyles } from '../../../hooks/usePinnedColumnStyles.js';
|
|
7
|
+
import { useExpandableCell } from './hooks/useExpandableCell.js';
|
|
7
8
|
import styles from './BodyCell.module.scss.js';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Renders a cell element, and its content, for a given column and row, within the grid body.
|
|
11
12
|
*/
|
|
12
|
-
const BodyCell = ({ cell, ariaRoles }) => {
|
|
13
|
+
const BodyCell = ({ cell, ariaRoles, enableRowSelection, enableExpanding, }) => {
|
|
13
14
|
const { justifyContent, textAlign, rowHeader } = cell.column.columnDef.meta;
|
|
14
15
|
const CellElement = rowHeader ? 'th' : 'td';
|
|
15
16
|
const { pinnedCellClassName, pinnedCellStyles } = usePinnedColumnStyles({ column: cell.column });
|
|
17
|
+
const { expandButtonProps, contentMarginLeft } = useExpandableCell({
|
|
18
|
+
cell,
|
|
19
|
+
enableExpanding,
|
|
20
|
+
enableRowSelection,
|
|
21
|
+
});
|
|
16
22
|
const bodyCellClassname = buildClassnames([
|
|
17
23
|
styles.bodyCell,
|
|
18
24
|
pinnedCellClassName,
|
|
@@ -20,9 +26,10 @@ const BodyCell = ({ cell, ariaRoles }) => {
|
|
|
20
26
|
]);
|
|
21
27
|
return (React__default.createElement(CellElement, { className: bodyCellClassname, "aria-colindex": cell.column.getIndex() + 1, scope: rowHeader ? 'row' : undefined, role: rowHeader ? 'rowheader' : ariaRoles.cell, style: pinnedCellStyles },
|
|
22
28
|
React__default.createElement(CellContent, { contentStyle: {
|
|
29
|
+
marginLeft: contentMarginLeft,
|
|
23
30
|
justifyContent,
|
|
24
31
|
textAlign,
|
|
25
|
-
} }, flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
32
|
+
}, expandButtonProps: expandButtonProps }, flexRender(cell.column.columnDef.cell, cell.getContext()))));
|
|
26
33
|
};
|
|
27
34
|
|
|
28
35
|
export { BodyCell };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BodyCell.js","sources":["../../../../../../src/components/DataGrid/components/Body/BodyCell/BodyCell.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Cell, flexRender } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\nimport { AriaRoles } from '../../../types';\nimport { CellContent } from '../../CellContent';\nimport { usePinnedColumnStyles } from '../../../hooks';\n\nimport styles from './BodyCell.module.scss';\n\ntype ColumnCellProps = {\n /**\n * Cell within the TanStack Table instance.\n */\n cell: Cell<any, any>;\n\n /**\n * ARIA roles for the grid.\n */\n ariaRoles: AriaRoles;\n};\n\n/**\n * Renders a cell element, and its content, for a given column and row, within the grid body.\n */\nexport const BodyCell = ({
|
|
1
|
+
{"version":3,"file":"BodyCell.js","sources":["../../../../../../src/components/DataGrid/components/Body/BodyCell/BodyCell.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Cell, flexRender } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\nimport { AriaRoles } from '../../../types';\nimport { CellContent } from '../../CellContent';\nimport { usePinnedColumnStyles } from '../../../hooks';\n\nimport { useExpandableCell } from './hooks';\nimport styles from './BodyCell.module.scss';\n\ntype ColumnCellProps = {\n /**\n * Cell within the TanStack Table instance.\n */\n cell: Cell<any, any>;\n\n /**\n * ARIA roles for the grid.\n */\n ariaRoles: AriaRoles;\n\n /**\n * Whether row selection is enabled.\n */\n enableRowSelection: boolean;\n\n /**\n * Whether row expanding is enabled for the grid.\n */\n enableExpanding: boolean;\n};\n\n/**\n * Renders a cell element, and its content, for a given column and row, within the grid body.\n */\nexport const BodyCell = ({\n cell,\n ariaRoles,\n enableRowSelection,\n enableExpanding,\n}: ColumnCellProps) => {\n const { justifyContent, textAlign, rowHeader } = cell.column.columnDef.meta!;\n const CellElement = rowHeader ? 'th' : 'td';\n\n const { pinnedCellClassName, pinnedCellStyles } = usePinnedColumnStyles({ column: cell.column });\n\n const { expandButtonProps, contentMarginLeft } = useExpandableCell({\n cell,\n enableExpanding,\n enableRowSelection,\n });\n\n const bodyCellClassname = buildClassnames([\n styles.bodyCell,\n pinnedCellClassName,\n 'data-grid-cell',\n ]);\n\n return (\n <CellElement\n className={bodyCellClassname}\n aria-colindex={cell.column.getIndex() + 1}\n scope={rowHeader ? 'row' : undefined}\n role={rowHeader ? 'rowheader' : ariaRoles.cell}\n style={pinnedCellStyles}\n >\n <CellContent\n contentStyle={\n {\n marginLeft: contentMarginLeft,\n justifyContent,\n textAlign,\n } as React.CSSProperties\n }\n expandButtonProps={expandButtonProps}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </CellContent>\n </CellElement>\n );\n};\n"],"names":["React"],"mappings":";;;;;;;;;AAmCA;;AAEG;AACI,MAAM,QAAQ,GAAG,CAAC,EACvB,IAAI,EACJ,SAAS,EACT,kBAAkB,EAClB,eAAe,GACC,KAAI;AACpB,IAAA,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAK;IAC5E,MAAM,WAAW,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI;AAE3C,IAAA,MAAM,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,GAAG,qBAAqB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AAEhG,IAAA,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,GAAG,iBAAiB,CAAC;QACjE,IAAI;QACJ,eAAe;QACf,kBAAkB;AACnB,KAAA,CAAC;IAEF,MAAM,iBAAiB,GAAG,eAAe,CAAC;AACxC,QAAA,MAAM,CAAC,QAAQ;QACf,mBAAmB;QACnB,gBAAgB;AACjB,KAAA,CAAC;IAEF,QACEA,6BAAC,WAAW,EAAA,EACV,SAAS,EAAE,iBAAiB,mBACb,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC,EACzC,KAAK,EAAE,SAAS,GAAG,KAAK,GAAG,SAAS,EACpC,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAAC,IAAI,EAC9C,KAAK,EAAE,gBAAgB,EAAA;QAEvBA,cAAC,CAAA,aAAA,CAAA,WAAW,EACV,EAAA,YAAY,EACV;AACE,gBAAA,UAAU,EAAE,iBAAiB;gBAC7B,cAAc;gBACd,SAAS;aACa,EAE1B,iBAAiB,EAAE,iBAAiB,EAAA,EAEnC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAC9C,CACF;AAElB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useExpandableCell } from './useExpandableCell';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const useExpandableCell = ({ cell, enableRowSelection, enableExpanding, }) => {
|
|
6
|
+
/**
|
|
7
|
+
* If this cell is the first column, and the row can be expanded, then we need to show the expand button.
|
|
8
|
+
*/
|
|
9
|
+
const isFirstColumn = enableRowSelection
|
|
10
|
+
? cell.column.getIndex() === 1
|
|
11
|
+
: cell.column.getIndex() === 0;
|
|
12
|
+
const isExpanded = cell.row.getIsExpanded();
|
|
13
|
+
// Margin to use for the expand button, based on the row depth.
|
|
14
|
+
const expandMargin = `calc(var(--sizes-6) * ${cell.row.depth + 1})`;
|
|
15
|
+
// Props for the expand button within the cell content.
|
|
16
|
+
const expandButtonProps = React.useMemo(() => {
|
|
17
|
+
// If this cell is not the first column, or the row cannot be expanded, return undefined (don't show the button).
|
|
18
|
+
if (!enableExpanding || !isFirstColumn || !cell.row.getCanExpand()) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
isExpanded,
|
|
23
|
+
onToggle: cell.row.getToggleExpandedHandler(),
|
|
24
|
+
containerStyle: {
|
|
25
|
+
width: expandMargin,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}, [isFirstColumn, cell.row, enableExpanding, isExpanded, expandMargin]);
|
|
29
|
+
const contentMarginLeft = isFirstColumn && enableExpanding ? expandMargin : undefined;
|
|
30
|
+
return { expandButtonProps, contentMarginLeft };
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.useExpandableCell = useExpandableCell;
|
|
34
|
+
//# sourceMappingURL=useExpandableCell.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpandableCell.cjs","sources":["../../../../../../../src/components/DataGrid/components/Body/BodyCell/hooks/useExpandableCell.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { Cell } from '@tanstack/react-table';\n\nimport { ExpandButtonProps } from '../../../CellContent/ExpandButton';\n\ntype UseExpandableCellProps = {\n /**\n * Cell within the table.\n */\n cell: Cell<any, any>;\n\n /**\n * Whether row selection is enabled.\n */\n enableRowSelection: boolean;\n\n /**\n * Whether row expanding is enabled.\n */\n enableExpanding: boolean;\n};\n\nexport const useExpandableCell = ({\n cell,\n enableRowSelection,\n enableExpanding,\n}: UseExpandableCellProps) => {\n /**\n * If this cell is the first column, and the row can be expanded, then we need to show the expand button.\n */\n const isFirstColumn = enableRowSelection\n ? cell.column.getIndex() === 1\n : cell.column.getIndex() === 0;\n\n const isExpanded = cell.row.getIsExpanded();\n\n // Margin to use for the expand button, based on the row depth.\n const expandMargin = `calc(var(--sizes-6) * ${cell.row.depth + 1})`;\n\n // Props for the expand button within the cell content.\n const expandButtonProps: ExpandButtonProps | undefined = useMemo(() => {\n // If this cell is not the first column, or the row cannot be expanded, return undefined (don't show the button).\n if (!enableExpanding || !isFirstColumn || !cell.row.getCanExpand()) {\n return undefined;\n }\n\n return {\n isExpanded,\n onToggle: cell.row.getToggleExpandedHandler(),\n containerStyle: {\n width: expandMargin,\n },\n };\n }, [isFirstColumn, cell.row, enableExpanding, isExpanded, expandMargin]);\n\n const contentMarginLeft = isFirstColumn && enableExpanding ? expandMargin : undefined;\n\n return { expandButtonProps, contentMarginLeft };\n};\n"],"names":["useMemo"],"mappings":";;;;AAsBO,MAAM,iBAAiB,GAAG,CAAC,EAChC,IAAI,EACJ,kBAAkB,EAClB,eAAe,GACQ,KAAI;AAC3B;;AAEG;IACH,MAAM,aAAa,GAAG;UAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK;UAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC;IAEhC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE;;IAG3C,MAAM,YAAY,GAAG,CAAA,sBAAA,EAAyB,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAA,CAAA,CAAG;;AAGnE,IAAA,MAAM,iBAAiB,GAAkCA,aAAO,CAAC,MAAK;;AAEpE,QAAA,IAAI,CAAC,eAAe,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE;AAClE,YAAA,OAAO,SAAS;AACjB;QAED,OAAO;YACL,UAAU;AACV,YAAA,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE;AAC7C,YAAA,cAAc,EAAE;AACd,gBAAA,KAAK,EAAE,YAAY;AACpB,aAAA;SACF;AACH,KAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAExE,IAAA,MAAM,iBAAiB,GAAG,aAAa,IAAI,eAAe,GAAG,YAAY,GAAG,SAAS;AAErF,IAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE;AACjD;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Cell } from '@tanstack/react-table';
|
|
2
|
+
import { ExpandButtonProps } from '../../../CellContent/ExpandButton';
|
|
3
|
+
type UseExpandableCellProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Cell within the table.
|
|
6
|
+
*/
|
|
7
|
+
cell: Cell<any, any>;
|
|
8
|
+
/**
|
|
9
|
+
* Whether row selection is enabled.
|
|
10
|
+
*/
|
|
11
|
+
enableRowSelection: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether row expanding is enabled.
|
|
14
|
+
*/
|
|
15
|
+
enableExpanding: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const useExpandableCell: ({ cell, enableRowSelection, enableExpanding, }: UseExpandableCellProps) => {
|
|
18
|
+
expandButtonProps: ExpandButtonProps | undefined;
|
|
19
|
+
contentMarginLeft: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
const useExpandableCell = ({ cell, enableRowSelection, enableExpanding, }) => {
|
|
4
|
+
/**
|
|
5
|
+
* If this cell is the first column, and the row can be expanded, then we need to show the expand button.
|
|
6
|
+
*/
|
|
7
|
+
const isFirstColumn = enableRowSelection
|
|
8
|
+
? cell.column.getIndex() === 1
|
|
9
|
+
: cell.column.getIndex() === 0;
|
|
10
|
+
const isExpanded = cell.row.getIsExpanded();
|
|
11
|
+
// Margin to use for the expand button, based on the row depth.
|
|
12
|
+
const expandMargin = `calc(var(--sizes-6) * ${cell.row.depth + 1})`;
|
|
13
|
+
// Props for the expand button within the cell content.
|
|
14
|
+
const expandButtonProps = useMemo(() => {
|
|
15
|
+
// If this cell is not the first column, or the row cannot be expanded, return undefined (don't show the button).
|
|
16
|
+
if (!enableExpanding || !isFirstColumn || !cell.row.getCanExpand()) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
isExpanded,
|
|
21
|
+
onToggle: cell.row.getToggleExpandedHandler(),
|
|
22
|
+
containerStyle: {
|
|
23
|
+
width: expandMargin,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}, [isFirstColumn, cell.row, enableExpanding, isExpanded, expandMargin]);
|
|
27
|
+
const contentMarginLeft = isFirstColumn && enableExpanding ? expandMargin : undefined;
|
|
28
|
+
return { expandButtonProps, contentMarginLeft };
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { useExpandableCell };
|
|
32
|
+
//# sourceMappingURL=useExpandableCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpandableCell.js","sources":["../../../../../../../src/components/DataGrid/components/Body/BodyCell/hooks/useExpandableCell.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport { Cell } from '@tanstack/react-table';\n\nimport { ExpandButtonProps } from '../../../CellContent/ExpandButton';\n\ntype UseExpandableCellProps = {\n /**\n * Cell within the table.\n */\n cell: Cell<any, any>;\n\n /**\n * Whether row selection is enabled.\n */\n enableRowSelection: boolean;\n\n /**\n * Whether row expanding is enabled.\n */\n enableExpanding: boolean;\n};\n\nexport const useExpandableCell = ({\n cell,\n enableRowSelection,\n enableExpanding,\n}: UseExpandableCellProps) => {\n /**\n * If this cell is the first column, and the row can be expanded, then we need to show the expand button.\n */\n const isFirstColumn = enableRowSelection\n ? cell.column.getIndex() === 1\n : cell.column.getIndex() === 0;\n\n const isExpanded = cell.row.getIsExpanded();\n\n // Margin to use for the expand button, based on the row depth.\n const expandMargin = `calc(var(--sizes-6) * ${cell.row.depth + 1})`;\n\n // Props for the expand button within the cell content.\n const expandButtonProps: ExpandButtonProps | undefined = useMemo(() => {\n // If this cell is not the first column, or the row cannot be expanded, return undefined (don't show the button).\n if (!enableExpanding || !isFirstColumn || !cell.row.getCanExpand()) {\n return undefined;\n }\n\n return {\n isExpanded,\n onToggle: cell.row.getToggleExpandedHandler(),\n containerStyle: {\n width: expandMargin,\n },\n };\n }, [isFirstColumn, cell.row, enableExpanding, isExpanded, expandMargin]);\n\n const contentMarginLeft = isFirstColumn && enableExpanding ? expandMargin : undefined;\n\n return { expandButtonProps, contentMarginLeft };\n};\n"],"names":[],"mappings":";;AAsBO,MAAM,iBAAiB,GAAG,CAAC,EAChC,IAAI,EACJ,kBAAkB,EAClB,eAAe,GACQ,KAAI;AAC3B;;AAEG;IACH,MAAM,aAAa,GAAG;UAClB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK;UAC3B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC;IAEhC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE;;IAG3C,MAAM,YAAY,GAAG,CAAA,sBAAA,EAAyB,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAA,CAAA,CAAG;;AAGnE,IAAA,MAAM,iBAAiB,GAAkC,OAAO,CAAC,MAAK;;AAEpE,QAAA,IAAI,CAAC,eAAe,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE;AAClE,YAAA,OAAO,SAAS;AACjB;QAED,OAAO;YACL,UAAU;AACV,YAAA,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,wBAAwB,EAAE;AAC7C,YAAA,cAAc,EAAE;AACd,gBAAA,KAAK,EAAE,YAAY;AACpB,aAAA;SACF;AACH,KAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAExE,IAAA,MAAM,iBAAiB,GAAG,aAAa,IAAI,eAAe,GAAG,YAAY,GAAG,SAAS;AAErF,IAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE;AACjD;;;;"}
|
|
@@ -8,7 +8,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
10
10
|
|
|
11
|
-
const Row = ({ row, striped, children }) => (React__default.default.createElement("tr", { className: buildClassnames.buildClassnames(['data-grid-row', striped ? 'striped' : undefined]), key: row.id, "aria-rowindex": row.index + 2 }, children));
|
|
11
|
+
const Row = ({ row, striped, enableExpanding, children }) => (React__default.default.createElement("tr", { className: buildClassnames.buildClassnames(['data-grid-row', striped ? 'striped' : undefined]), key: row.id, "aria-rowindex": row.index + 2, "aria-level": enableExpanding ? row.depth + 1 : undefined }, children));
|
|
12
12
|
|
|
13
13
|
exports.Row = Row;
|
|
14
14
|
//# sourceMappingURL=Row.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.cjs","sources":["../../../../../../src/components/DataGrid/components/Body/Row/Row.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Row as RowItem } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\ntype RowProps = {\n /**\n * The row within the TanStack Table instance.\n */\n row: RowItem<any>;\n\n /**\n * Whether rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * Child elements (table cells).\n */\n children: React.ReactNode;\n};\n\nexport const Row = ({ row, striped, children }: RowProps) => (\n <tr\n className={buildClassnames(['data-grid-row', striped ? 'striped' : undefined])}\n key={row.id}\n // 0-based index + header row.\n aria-rowindex={row.index + 2}\n >\n {children}\n </tr>\n);\n"],"names":["React","buildClassnames"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Row.cjs","sources":["../../../../../../src/components/DataGrid/components/Body/Row/Row.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Row as RowItem } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\ntype RowProps = {\n /**\n * The row within the TanStack Table instance.\n */\n row: RowItem<any>;\n\n /**\n * Whether rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * Whether row expanding is enabled.\n */\n enableExpanding: boolean;\n\n /**\n * Child elements (table cells).\n */\n children: React.ReactNode;\n};\n\nexport const Row = ({ row, striped, enableExpanding, children }: RowProps) => (\n <tr\n className={buildClassnames(['data-grid-row', striped ? 'striped' : undefined])}\n key={row.id}\n // 0-based index + header row.\n aria-rowindex={row.index + 2}\n aria-level={enableExpanding ? row.depth + 1 : undefined}\n >\n {children}\n </tr>\n);\n"],"names":["React","buildClassnames"],"mappings":";;;;;;;;;;AA4BO,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAY,MACvEA,sBAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EACE,SAAS,EAAEC,+BAAe,CAAC,CAAC,eAAe,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC,EAC9E,GAAG,EAAE,GAAG,CAAC,EAAE,EAAA,eAAA,EAEI,GAAG,CAAC,KAAK,GAAG,CAAC,EAChB,YAAA,EAAA,eAAe,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,EAAA,EAEtD,QAAQ,CACN;;;;"}
|
|
@@ -9,10 +9,14 @@ type RowProps = {
|
|
|
9
9
|
* Whether rows should be striped or not.
|
|
10
10
|
*/
|
|
11
11
|
striped: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Whether row expanding is enabled.
|
|
14
|
+
*/
|
|
15
|
+
enableExpanding: boolean;
|
|
12
16
|
/**
|
|
13
17
|
* Child elements (table cells).
|
|
14
18
|
*/
|
|
15
19
|
children: React.ReactNode;
|
|
16
20
|
};
|
|
17
|
-
export declare const Row: ({ row, striped, children }: RowProps) => React.JSX.Element;
|
|
21
|
+
export declare const Row: ({ row, striped, enableExpanding, children }: RowProps) => React.JSX.Element;
|
|
18
22
|
export {};
|
|
@@ -2,7 +2,7 @@ import React__default from 'react';
|
|
|
2
2
|
import { buildClassnames } from '../../../../../utils/buildClassnames.js';
|
|
3
3
|
import 'uid/secure';
|
|
4
4
|
|
|
5
|
-
const Row = ({ row, striped, children }) => (React__default.createElement("tr", { className: buildClassnames(['data-grid-row', striped ? 'striped' : undefined]), key: row.id, "aria-rowindex": row.index + 2 }, children));
|
|
5
|
+
const Row = ({ row, striped, enableExpanding, children }) => (React__default.createElement("tr", { className: buildClassnames(['data-grid-row', striped ? 'striped' : undefined]), key: row.id, "aria-rowindex": row.index + 2, "aria-level": enableExpanding ? row.depth + 1 : undefined }, children));
|
|
6
6
|
|
|
7
7
|
export { Row };
|
|
8
8
|
//# sourceMappingURL=Row.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.js","sources":["../../../../../../src/components/DataGrid/components/Body/Row/Row.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Row as RowItem } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\ntype RowProps = {\n /**\n * The row within the TanStack Table instance.\n */\n row: RowItem<any>;\n\n /**\n * Whether rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * Child elements (table cells).\n */\n children: React.ReactNode;\n};\n\nexport const Row = ({ row, striped, children }: RowProps) => (\n <tr\n className={buildClassnames(['data-grid-row', striped ? 'striped' : undefined])}\n key={row.id}\n // 0-based index + header row.\n aria-rowindex={row.index + 2}\n >\n {children}\n </tr>\n);\n"],"names":["React"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"Row.js","sources":["../../../../../../src/components/DataGrid/components/Body/Row/Row.tsx"],"sourcesContent":["import React from 'react';\n\nimport { Row as RowItem } from '@tanstack/react-table';\n\nimport { buildClassnames } from '../../../../../utils';\n\ntype RowProps = {\n /**\n * The row within the TanStack Table instance.\n */\n row: RowItem<any>;\n\n /**\n * Whether rows should be striped or not.\n */\n striped: boolean;\n\n /**\n * Whether row expanding is enabled.\n */\n enableExpanding: boolean;\n\n /**\n * Child elements (table cells).\n */\n children: React.ReactNode;\n};\n\nexport const Row = ({ row, striped, enableExpanding, children }: RowProps) => (\n <tr\n className={buildClassnames(['data-grid-row', striped ? 'striped' : undefined])}\n key={row.id}\n // 0-based index + header row.\n aria-rowindex={row.index + 2}\n aria-level={enableExpanding ? row.depth + 1 : undefined}\n >\n {children}\n </tr>\n);\n"],"names":["React"],"mappings":";;;;AA4BO,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAY,MACvEA,cAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EACE,SAAS,EAAE,eAAe,CAAC,CAAC,eAAe,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC,CAAC,EAC9E,GAAG,EAAE,GAAG,CAAC,EAAE,EAAA,eAAA,EAEI,GAAG,CAAC,KAAK,GAAG,CAAC,EAChB,YAAA,EAAA,eAAe,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,GAAG,SAAS,EAAA,EAEtD,QAAQ,CACN;;;;"}
|
|
@@ -4,6 +4,7 @@ var React = require('react');
|
|
|
4
4
|
var buildClassnames = require('../../../../utils/buildClassnames.cjs');
|
|
5
5
|
require('uid/secure');
|
|
6
6
|
var CellContent_module = require('./CellContent.module.scss.cjs');
|
|
7
|
+
var ExpandButton = require('./ExpandButton/ExpandButton.cjs');
|
|
7
8
|
|
|
8
9
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
9
10
|
|
|
@@ -13,8 +14,10 @@ const cellContentClassname = buildClassnames.buildClassnames([CellContent_module
|
|
|
13
14
|
/**
|
|
14
15
|
* Wrapper for content displayed within a non-header cell in the grid.
|
|
15
16
|
*/
|
|
16
|
-
const CellContent = ({ contentStyle, children }) => {
|
|
17
|
-
return (React__default.default.createElement(
|
|
17
|
+
const CellContent = ({ contentStyle, children, expandButtonProps }) => {
|
|
18
|
+
return (React__default.default.createElement(React__default.default.Fragment, null,
|
|
19
|
+
expandButtonProps && React__default.default.createElement(ExpandButton.ExpandButton, { ...expandButtonProps }),
|
|
20
|
+
React__default.default.createElement("div", { "data-testid": "data-grid-cell-content", className: cellContentClassname, style: contentStyle }, children)));
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
exports.CellContent = CellContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellContent.cjs","sources":["../../../../../src/components/DataGrid/components/CellContent/CellContent.tsx"],"sourcesContent":["import React from 'react';\n\nimport { buildClassnames } from '../../../../utils';\n\nimport styles from './CellContent.module.scss';\n\nexport interface CellContentProps {\n /**\n * Styles to be applied to the cell content wrapper.\n */\n contentStyle: Pick
|
|
1
|
+
{"version":3,"file":"CellContent.cjs","sources":["../../../../../src/components/DataGrid/components/CellContent/CellContent.tsx"],"sourcesContent":["import React from 'react';\n\nimport { buildClassnames } from '../../../../utils';\n\nimport styles from './CellContent.module.scss';\nimport { ExpandButton, ExpandButtonProps } from './ExpandButton';\n\nexport interface CellContentProps {\n /**\n * Styles to be applied to the cell content wrapper.\n */\n contentStyle: Pick<\n React.CSSProperties,\n 'marginLeft' | 'justifyContent' | 'textAlign' | 'marginLeft'\n >;\n\n /**\n * Child elements.\n */\n children?: React.ReactNode;\n\n /**\n * Props for an expand/collapse button, if applicable.\n */\n expandButtonProps?: ExpandButtonProps;\n}\n\nconst cellContentClassname = buildClassnames([styles.cellContent, 'data-grid-cell-content']);\n\n/**\n * Wrapper for content displayed within a non-header cell in the grid.\n */\nexport const CellContent = ({ contentStyle, children, expandButtonProps }: CellContentProps) => {\n return (\n <>\n {expandButtonProps && <ExpandButton {...expandButtonProps} />}\n <div\n data-testid=\"data-grid-cell-content\"\n className={cellContentClassname}\n style={contentStyle}\n >\n {children}\n </div>\n </>\n );\n};\n"],"names":["buildClassnames","styles","React","ExpandButton"],"mappings":";;;;;;;;;;;;AA2BA,MAAM,oBAAoB,GAAGA,+BAAe,CAAC,CAACC,kBAAM,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;AAE5F;;AAEG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAoB,KAAI;AAC7F,IAAA,QACEC,sBAAA,CAAA,aAAA,CAAAA,sBAAA,CAAA,QAAA,EAAA,IAAA;AACG,QAAA,iBAAiB,IAAIA,sBAAA,CAAA,aAAA,CAACC,yBAAY,EAAA,EAAA,GAAK,iBAAiB,EAAI,CAAA;AAC7D,QAAAD,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,wBAAwB,EACpC,SAAS,EAAE,oBAAoB,EAC/B,KAAK,EAAE,YAAY,EAElB,EAAA,QAAQ,CACL,CACL;AAEP;;;;"}
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ExpandButtonProps } from './ExpandButton';
|
|
2
3
|
export interface CellContentProps {
|
|
3
4
|
/**
|
|
4
5
|
* Styles to be applied to the cell content wrapper.
|
|
5
6
|
*/
|
|
6
|
-
contentStyle: Pick<React.CSSProperties, 'marginLeft' | 'justifyContent' | 'textAlign'>;
|
|
7
|
+
contentStyle: Pick<React.CSSProperties, 'marginLeft' | 'justifyContent' | 'textAlign' | 'marginLeft'>;
|
|
7
8
|
/**
|
|
8
9
|
* Child elements.
|
|
9
10
|
*/
|
|
10
11
|
children?: React.ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Props for an expand/collapse button, if applicable.
|
|
14
|
+
*/
|
|
15
|
+
expandButtonProps?: ExpandButtonProps;
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* Wrapper for content displayed within a non-header cell in the grid.
|
|
14
19
|
*/
|
|
15
|
-
export declare const CellContent: ({ contentStyle, children }: CellContentProps) => React.JSX.Element;
|
|
20
|
+
export declare const CellContent: ({ contentStyle, children, expandButtonProps }: CellContentProps) => React.JSX.Element;
|
|
@@ -2,13 +2,16 @@ import React__default from 'react';
|
|
|
2
2
|
import { buildClassnames } from '../../../../utils/buildClassnames.js';
|
|
3
3
|
import 'uid/secure';
|
|
4
4
|
import styles from './CellContent.module.scss.js';
|
|
5
|
+
import { ExpandButton } from './ExpandButton/ExpandButton.js';
|
|
5
6
|
|
|
6
7
|
const cellContentClassname = buildClassnames([styles.cellContent, 'data-grid-cell-content']);
|
|
7
8
|
/**
|
|
8
9
|
* Wrapper for content displayed within a non-header cell in the grid.
|
|
9
10
|
*/
|
|
10
|
-
const CellContent = ({ contentStyle, children }) => {
|
|
11
|
-
return (React__default.createElement(
|
|
11
|
+
const CellContent = ({ contentStyle, children, expandButtonProps }) => {
|
|
12
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
13
|
+
expandButtonProps && React__default.createElement(ExpandButton, { ...expandButtonProps }),
|
|
14
|
+
React__default.createElement("div", { "data-testid": "data-grid-cell-content", className: cellContentClassname, style: contentStyle }, children)));
|
|
12
15
|
};
|
|
13
16
|
|
|
14
17
|
export { CellContent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CellContent.js","sources":["../../../../../src/components/DataGrid/components/CellContent/CellContent.tsx"],"sourcesContent":["import React from 'react';\n\nimport { buildClassnames } from '../../../../utils';\n\nimport styles from './CellContent.module.scss';\n\nexport interface CellContentProps {\n /**\n * Styles to be applied to the cell content wrapper.\n */\n contentStyle: Pick
|
|
1
|
+
{"version":3,"file":"CellContent.js","sources":["../../../../../src/components/DataGrid/components/CellContent/CellContent.tsx"],"sourcesContent":["import React from 'react';\n\nimport { buildClassnames } from '../../../../utils';\n\nimport styles from './CellContent.module.scss';\nimport { ExpandButton, ExpandButtonProps } from './ExpandButton';\n\nexport interface CellContentProps {\n /**\n * Styles to be applied to the cell content wrapper.\n */\n contentStyle: Pick<\n React.CSSProperties,\n 'marginLeft' | 'justifyContent' | 'textAlign' | 'marginLeft'\n >;\n\n /**\n * Child elements.\n */\n children?: React.ReactNode;\n\n /**\n * Props for an expand/collapse button, if applicable.\n */\n expandButtonProps?: ExpandButtonProps;\n}\n\nconst cellContentClassname = buildClassnames([styles.cellContent, 'data-grid-cell-content']);\n\n/**\n * Wrapper for content displayed within a non-header cell in the grid.\n */\nexport const CellContent = ({ contentStyle, children, expandButtonProps }: CellContentProps) => {\n return (\n <>\n {expandButtonProps && <ExpandButton {...expandButtonProps} />}\n <div\n data-testid=\"data-grid-cell-content\"\n className={cellContentClassname}\n style={contentStyle}\n >\n {children}\n </div>\n </>\n );\n};\n"],"names":["React"],"mappings":";;;;;;AA2BA,MAAM,oBAAoB,GAAG,eAAe,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;AAE5F;;AAEG;AACI,MAAM,WAAW,GAAG,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,iBAAiB,EAAoB,KAAI;AAC7F,IAAA,QACEA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA;AACG,QAAA,iBAAiB,IAAIA,cAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EAAA,GAAK,iBAAiB,EAAI,CAAA;AAC7D,QAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,wBAAwB,EACpC,SAAS,EAAE,oBAAoB,EAC/B,KAAK,EAAE,YAAY,EAElB,EAAA,QAAQ,CACL,CACL;AAEP;;;;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var DownArrowIcon = require('../../../../../tempIcons/DownArrowIcon.cjs');
|
|
5
|
+
var RightArrowIcon = require('../../../../../tempIcons/RightArrowIcon.cjs');
|
|
6
|
+
require('../../../../../theme/modules/sizes.cjs');
|
|
7
|
+
var Button = require('../../../../Button/Button.cjs');
|
|
8
|
+
var ExpandButton_module = require('./ExpandButton.module.scss.cjs');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
13
|
+
|
|
14
|
+
const ExpandButton = ({ isExpanded, onToggle, containerStyle }) => {
|
|
15
|
+
return (React__default.default.createElement("div", { className: ExpandButton_module.expandButtonContainer, style: containerStyle },
|
|
16
|
+
React__default.default.createElement(Button.Button, { size: "sm", variant: "flat", className: ExpandButton_module.expandButton, iconSlot: isExpanded ? React__default.default.createElement(DownArrowIcon.DownArrowIcon, null) : React__default.default.createElement(RightArrowIcon.RightArrowIcon, null), onClick: onToggle, "aria-label": isExpanded ? 'Collapse row' : 'Expand row', "aria-expanded": isExpanded })));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.ExpandButton = ExpandButton;
|
|
20
|
+
//# sourceMappingURL=ExpandButton.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandButton.cjs","sources":["../../../../../../src/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.tsx"],"sourcesContent":["import React from 'react';\n\nimport { DownArrowIcon, RightArrowIcon } from '../../../../../tempIcons';\nimport { Button } from '../../../../Button';\n\nimport styles from './ExpandButton.module.scss';\n\ntype ExpandButtonProps = {\n isExpanded: boolean;\n onToggle: () => void;\n containerStyle?: React.CSSProperties;\n};\n\nconst ExpandButton = ({ isExpanded, onToggle, containerStyle }: ExpandButtonProps) => {\n return (\n <div className={styles.expandButtonContainer} style={containerStyle}>\n <Button\n size=\"sm\"\n variant=\"flat\"\n className={styles.expandButton}\n iconSlot={isExpanded ? <DownArrowIcon /> : <RightArrowIcon />}\n onClick={onToggle}\n aria-label={isExpanded ? 'Collapse row' : 'Expand row'}\n aria-expanded={isExpanded}\n />\n </div>\n );\n};\n\nexport { ExpandButton };\nexport type { ExpandButtonProps };\n"],"names":["React","styles","Button","DownArrowIcon","RightArrowIcon"],"mappings":";;;;;;;;;;;;;AAaM,MAAA,YAAY,GAAG,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAqB,KAAI;IACnF,QACEA,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAEC,mBAAM,CAAC,qBAAqB,EAAE,KAAK,EAAE,cAAc,EAAA;QACjED,sBAAC,CAAA,aAAA,CAAAE,aAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,MAAM,EACd,SAAS,EAAED,mBAAM,CAAC,YAAY,EAC9B,QAAQ,EAAE,UAAU,GAAGD,sBAAA,CAAA,aAAA,CAACG,2BAAa,EAAA,IAAA,CAAG,GAAGH,qCAACI,6BAAc,EAAA,IAAA,CAAG,EAC7D,OAAO,EAAE,QAAQ,EAAA,YAAA,EACL,UAAU,GAAG,cAAc,GAAG,YAAY,mBACvC,UAAU,EAAA,CACzB,CACE;AAEV;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ExpandButtonProps = {
|
|
3
|
+
isExpanded: boolean;
|
|
4
|
+
onToggle: () => void;
|
|
5
|
+
containerStyle?: React.CSSProperties;
|
|
6
|
+
};
|
|
7
|
+
declare const ExpandButton: ({ isExpanded, onToggle, containerStyle }: ExpandButtonProps) => React.JSX.Element;
|
|
8
|
+
export { ExpandButton };
|
|
9
|
+
export type { ExpandButtonProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { DownArrowIcon } from '../../../../../tempIcons/DownArrowIcon.js';
|
|
3
|
+
import { RightArrowIcon } from '../../../../../tempIcons/RightArrowIcon.js';
|
|
4
|
+
import '../../../../../theme/modules/sizes.js';
|
|
5
|
+
import { Button } from '../../../../Button/Button.js';
|
|
6
|
+
import styles from './ExpandButton.module.scss.js';
|
|
7
|
+
|
|
8
|
+
const ExpandButton = ({ isExpanded, onToggle, containerStyle }) => {
|
|
9
|
+
return (React__default.createElement("div", { className: styles.expandButtonContainer, style: containerStyle },
|
|
10
|
+
React__default.createElement(Button, { size: "sm", variant: "flat", className: styles.expandButton, iconSlot: isExpanded ? React__default.createElement(DownArrowIcon, null) : React__default.createElement(RightArrowIcon, null), onClick: onToggle, "aria-label": isExpanded ? 'Collapse row' : 'Expand row', "aria-expanded": isExpanded })));
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { ExpandButton };
|
|
14
|
+
//# sourceMappingURL=ExpandButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandButton.js","sources":["../../../../../../src/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.tsx"],"sourcesContent":["import React from 'react';\n\nimport { DownArrowIcon, RightArrowIcon } from '../../../../../tempIcons';\nimport { Button } from '../../../../Button';\n\nimport styles from './ExpandButton.module.scss';\n\ntype ExpandButtonProps = {\n isExpanded: boolean;\n onToggle: () => void;\n containerStyle?: React.CSSProperties;\n};\n\nconst ExpandButton = ({ isExpanded, onToggle, containerStyle }: ExpandButtonProps) => {\n return (\n <div className={styles.expandButtonContainer} style={containerStyle}>\n <Button\n size=\"sm\"\n variant=\"flat\"\n className={styles.expandButton}\n iconSlot={isExpanded ? <DownArrowIcon /> : <RightArrowIcon />}\n onClick={onToggle}\n aria-label={isExpanded ? 'Collapse row' : 'Expand row'}\n aria-expanded={isExpanded}\n />\n </div>\n );\n};\n\nexport { ExpandButton };\nexport type { ExpandButtonProps };\n"],"names":["React"],"mappings":";;;;;;;AAaM,MAAA,YAAY,GAAG,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAqB,KAAI;IACnF,QACEA,cAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,MAAM,CAAC,qBAAqB,EAAE,KAAK,EAAE,cAAc,EAAA;QACjEA,cAAC,CAAA,aAAA,CAAA,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAC,MAAM,EACd,SAAS,EAAE,MAAM,CAAC,YAAY,EAC9B,QAAQ,EAAE,UAAU,GAAGA,cAAA,CAAA,aAAA,CAAC,aAAa,EAAA,IAAA,CAAG,GAAGA,6BAAC,cAAc,EAAA,IAAA,CAAG,EAC7D,OAAO,EAAE,QAAQ,EAAA,YAAA,EACL,UAAU,GAAG,cAAc,GAAG,YAAY,mBACvC,UAAU,EAAA,CACzB,CACE;AAEV;;;;"}
|
package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss.cjs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ___$insertStyle = require('../../../../../_virtual/____insertStyle.cjs');
|
|
4
|
+
|
|
5
|
+
___$insertStyle("._expandButton_153ka_1[aria-expanded] {\n padding: var(--sizes-none);\n width: var(--sizes-6);\n height: var(--sizes-6);\n}\n\n._expandButtonContainer_153ka_7 {\n display: flex;\n height: 100%;\n position: absolute;\n top: var(--sizes-none);\n align-items: center;\n justify-content: flex-end;\n}");
|
|
6
|
+
var styles = {"expandButton":"_expandButton_153ka_1","expandButtonContainer":"_expandButtonContainer_153ka_7"};
|
|
7
|
+
|
|
8
|
+
module.exports = styles;
|
|
9
|
+
//# sourceMappingURL=ExpandButton.module.scss.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandButton.module.scss.cjs","sources":["../../../../../../src/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss"],"sourcesContent":[".expandButton[aria-expanded] {\n padding: var(--sizes-none);\n width: var(--sizes-6);\n height: var(--sizes-6);\n}\n\n.expandButtonContainer {\n display: flex;\n height: 100%;\n\n position: absolute;\n top: var(--sizes-none);\n\n align-items: center;\n justify-content: flex-end;\n}\n"],"names":[],"mappings":";;;;AACE,eAAA,CAAA,mTAAA;AACA,aAAA,CAAA,cAAA,CAAA,uBAAA,CAAA,uBAAA,CAAA,gCAAA;;;;"}
|
package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import insertStyle from '../../../../../_virtual/____insertStyle.js';
|
|
2
|
+
|
|
3
|
+
insertStyle("._expandButton_153ka_1[aria-expanded] {\n padding: var(--sizes-none);\n width: var(--sizes-6);\n height: var(--sizes-6);\n}\n\n._expandButtonContainer_153ka_7 {\n display: flex;\n height: 100%;\n position: absolute;\n top: var(--sizes-none);\n align-items: center;\n justify-content: flex-end;\n}");
|
|
4
|
+
var styles = {"expandButton":"_expandButton_153ka_1","expandButtonContainer":"_expandButtonContainer_153ka_7"};
|
|
5
|
+
|
|
6
|
+
export { styles as default };
|
|
7
|
+
//# sourceMappingURL=ExpandButton.module.scss.js.map
|
package/dist/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpandButton.module.scss.js","sources":["../../../../../../src/components/DataGrid/components/CellContent/ExpandButton/ExpandButton.module.scss"],"sourcesContent":[".expandButton[aria-expanded] {\n padding: var(--sizes-none);\n width: var(--sizes-6);\n height: var(--sizes-6);\n}\n\n.expandButtonContainer {\n display: flex;\n height: 100%;\n\n position: absolute;\n top: var(--sizes-none);\n\n align-items: center;\n justify-content: flex-end;\n}\n"],"names":["___$insertStyle"],"mappings":";;AACEA,WAAA,CAAA,mTAAA;AACA,aAAA,CAAA,cAAA,CAAA,uBAAA,CAAA,uBAAA,CAAA,gCAAA;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
const useExpandedState = (rowGrouping) => {
|
|
6
|
+
const { getChildData, expandedRows, onRowExpanded } = rowGrouping || {};
|
|
7
|
+
const internalExpandedState = React.useMemo(() => {
|
|
8
|
+
if (!expandedRows || !onRowExpanded)
|
|
9
|
+
return {};
|
|
10
|
+
return expandedRows;
|
|
11
|
+
}, [expandedRows, onRowExpanded]);
|
|
12
|
+
const setInternalExpandedState = React.useCallback((onUpdate) => {
|
|
13
|
+
if (!onRowExpanded)
|
|
14
|
+
return;
|
|
15
|
+
const newExpandedState = typeof onUpdate === 'function' ? onUpdate(internalExpandedState) : onUpdate;
|
|
16
|
+
onRowExpanded(newExpandedState);
|
|
17
|
+
}, [onRowExpanded, internalExpandedState]);
|
|
18
|
+
const enableExpanding = !!getChildData;
|
|
19
|
+
const getRowCanExpand = React.useCallback((row) => {
|
|
20
|
+
if (!getChildData)
|
|
21
|
+
return false;
|
|
22
|
+
return getChildData(row.original) !== undefined;
|
|
23
|
+
}, [getChildData]);
|
|
24
|
+
return {
|
|
25
|
+
enableExpanding,
|
|
26
|
+
getSubRows: getChildData,
|
|
27
|
+
getRowCanExpand,
|
|
28
|
+
expanded: internalExpandedState,
|
|
29
|
+
onExpandedChange: setInternalExpandedState,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.useExpandedState = useExpandedState;
|
|
34
|
+
//# sourceMappingURL=useExpandedState.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpandedState.cjs","sources":["../../../../src/components/DataGrid/hooks/useExpandedState.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\n\nimport { ExpandedState, OnChangeFn } from '@tanstack/react-table';\nimport { RowGroupingConfiguration } from '../types';\n\nexport const useExpandedState = (rowGrouping?: RowGroupingConfiguration) => {\n const { getChildData, expandedRows, onRowExpanded } = rowGrouping || {};\n\n const internalExpandedState = useMemo(() => {\n if (!expandedRows || !onRowExpanded) return {};\n\n return expandedRows;\n }, [expandedRows, onRowExpanded]);\n\n const setInternalExpandedState: OnChangeFn<ExpandedState> = useCallback(\n (onUpdate) => {\n if (!onRowExpanded) return;\n\n const newExpandedState =\n typeof onUpdate === 'function' ? onUpdate(internalExpandedState) : onUpdate;\n\n onRowExpanded(newExpandedState);\n },\n [onRowExpanded, internalExpandedState],\n );\n\n const enableExpanding = !!getChildData;\n const getRowCanExpand = useCallback(\n (row: any) => {\n if (!getChildData) return false;\n\n return getChildData(row.original) !== undefined;\n },\n [getChildData],\n );\n\n return {\n enableExpanding,\n getSubRows: getChildData,\n getRowCanExpand,\n expanded: internalExpandedState,\n onExpandedChange: setInternalExpandedState,\n };\n};\n"],"names":["useMemo","useCallback"],"mappings":";;;;AAKa,MAAA,gBAAgB,GAAG,CAAC,WAAsC,KAAI;IACzE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,WAAW,IAAI,EAAE;AAEvE,IAAA,MAAM,qBAAqB,GAAGA,aAAO,CAAC,MAAK;AACzC,QAAA,IAAI,CAAC,YAAY,IAAI,CAAC,aAAa;AAAE,YAAA,OAAO,EAAE;AAE9C,QAAA,OAAO,YAAY;AACrB,KAAC,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAEjC,IAAA,MAAM,wBAAwB,GAA8BC,iBAAW,CACrE,CAAC,QAAQ,KAAI;AACX,QAAA,IAAI,CAAC,aAAa;YAAE;AAEpB,QAAA,MAAM,gBAAgB,GACpB,OAAO,QAAQ,KAAK,UAAU,GAAG,QAAQ,CAAC,qBAAqB,CAAC,GAAG,QAAQ;QAE7E,aAAa,CAAC,gBAAgB,CAAC;AACjC,KAAC,EACD,CAAC,aAAa,EAAE,qBAAqB,CAAC,CACvC;AAED,IAAA,MAAM,eAAe,GAAG,CAAC,CAAC,YAAY;AACtC,IAAA,MAAM,eAAe,GAAGA,iBAAW,CACjC,CAAC,GAAQ,KAAI;AACX,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,OAAO,KAAK;QAE/B,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,SAAS;AACjD,KAAC,EACD,CAAC,YAAY,CAAC,CACf;IAED,OAAO;QACL,eAAe;AACf,QAAA,UAAU,EAAE,YAAY;QACxB,eAAe;AACf,QAAA,QAAQ,EAAE,qBAAqB;AAC/B,QAAA,gBAAgB,EAAE,wBAAwB;KAC3C;AACH;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExpandedState, OnChangeFn } from '@tanstack/react-table';
|
|
2
|
+
import { RowGroupingConfiguration } from '../types';
|
|
3
|
+
export declare const useExpandedState: (rowGrouping?: RowGroupingConfiguration) => {
|
|
4
|
+
enableExpanding: boolean;
|
|
5
|
+
getSubRows: ((row: any) => any) | undefined;
|
|
6
|
+
getRowCanExpand: (row: any) => boolean;
|
|
7
|
+
expanded: import("../types").ExpandedRows;
|
|
8
|
+
onExpandedChange: OnChangeFn<ExpandedState>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useMemo, useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
const useExpandedState = (rowGrouping) => {
|
|
4
|
+
const { getChildData, expandedRows, onRowExpanded } = rowGrouping || {};
|
|
5
|
+
const internalExpandedState = useMemo(() => {
|
|
6
|
+
if (!expandedRows || !onRowExpanded)
|
|
7
|
+
return {};
|
|
8
|
+
return expandedRows;
|
|
9
|
+
}, [expandedRows, onRowExpanded]);
|
|
10
|
+
const setInternalExpandedState = useCallback((onUpdate) => {
|
|
11
|
+
if (!onRowExpanded)
|
|
12
|
+
return;
|
|
13
|
+
const newExpandedState = typeof onUpdate === 'function' ? onUpdate(internalExpandedState) : onUpdate;
|
|
14
|
+
onRowExpanded(newExpandedState);
|
|
15
|
+
}, [onRowExpanded, internalExpandedState]);
|
|
16
|
+
const enableExpanding = !!getChildData;
|
|
17
|
+
const getRowCanExpand = useCallback((row) => {
|
|
18
|
+
if (!getChildData)
|
|
19
|
+
return false;
|
|
20
|
+
return getChildData(row.original) !== undefined;
|
|
21
|
+
}, [getChildData]);
|
|
22
|
+
return {
|
|
23
|
+
enableExpanding,
|
|
24
|
+
getSubRows: getChildData,
|
|
25
|
+
getRowCanExpand,
|
|
26
|
+
expanded: internalExpandedState,
|
|
27
|
+
onExpandedChange: setInternalExpandedState,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { useExpandedState };
|
|
32
|
+
//# sourceMappingURL=useExpandedState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useExpandedState.js","sources":["../../../../src/components/DataGrid/hooks/useExpandedState.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\n\nimport { ExpandedState, OnChangeFn } from '@tanstack/react-table';\nimport { RowGroupingConfiguration } from '../types';\n\nexport const useExpandedState = (rowGrouping?: RowGroupingConfiguration) => {\n const { getChildData, expandedRows, onRowExpanded } = rowGrouping || {};\n\n const internalExpandedState = useMemo(() => {\n if (!expandedRows || !onRowExpanded) return {};\n\n return expandedRows;\n }, [expandedRows, onRowExpanded]);\n\n const setInternalExpandedState: OnChangeFn<ExpandedState> = useCallback(\n (onUpdate) => {\n if (!onRowExpanded) return;\n\n const newExpandedState =\n typeof onUpdate === 'function' ? onUpdate(internalExpandedState) : onUpdate;\n\n onRowExpanded(newExpandedState);\n },\n [onRowExpanded, internalExpandedState],\n );\n\n const enableExpanding = !!getChildData;\n const getRowCanExpand = useCallback(\n (row: any) => {\n if (!getChildData) return false;\n\n return getChildData(row.original) !== undefined;\n },\n [getChildData],\n );\n\n return {\n enableExpanding,\n getSubRows: getChildData,\n getRowCanExpand,\n expanded: internalExpandedState,\n onExpandedChange: setInternalExpandedState,\n };\n};\n"],"names":[],"mappings":";;AAKa,MAAA,gBAAgB,GAAG,CAAC,WAAsC,KAAI;IACzE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,WAAW,IAAI,EAAE;AAEvE,IAAA,MAAM,qBAAqB,GAAG,OAAO,CAAC,MAAK;AACzC,QAAA,IAAI,CAAC,YAAY,IAAI,CAAC,aAAa;AAAE,YAAA,OAAO,EAAE;AAE9C,QAAA,OAAO,YAAY;AACrB,KAAC,EAAE,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC;AAEjC,IAAA,MAAM,wBAAwB,GAA8B,WAAW,CACrE,CAAC,QAAQ,KAAI;AACX,QAAA,IAAI,CAAC,aAAa;YAAE;AAEpB,QAAA,MAAM,gBAAgB,GACpB,OAAO,QAAQ,KAAK,UAAU,GAAG,QAAQ,CAAC,qBAAqB,CAAC,GAAG,QAAQ;QAE7E,aAAa,CAAC,gBAAgB,CAAC;AACjC,KAAC,EACD,CAAC,aAAa,EAAE,qBAAqB,CAAC,CACvC;AAED,IAAA,MAAM,eAAe,GAAG,CAAC,CAAC,YAAY;AACtC,IAAA,MAAM,eAAe,GAAG,WAAW,CACjC,CAAC,GAAQ,KAAI;AACX,QAAA,IAAI,CAAC,YAAY;AAAE,YAAA,OAAO,KAAK;QAE/B,OAAO,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,SAAS;AACjD,KAAC,EACD,CAAC,YAAY,CAAC,CACf;IAED,OAAO;QACL,eAAe;AACf,QAAA,UAAU,EAAE,YAAY;QACxB,eAAe;AACf,QAAA,QAAQ,EAAE,qBAAqB;AAC/B,QAAA,gBAAgB,EAAE,wBAAwB;KAC3C;AACH;;;;"}
|
|
@@ -4,6 +4,7 @@ import { BorderMode, ResizeMode, SelectionMode } from './enums';
|
|
|
4
4
|
import { ColumnDefinition } from './ColumnDefinition';
|
|
5
5
|
import { SortState } from './SortState';
|
|
6
6
|
import { PinnedColumnState } from './PinnedColumnState';
|
|
7
|
+
import { RowGroupingConfiguration } from './RowGroupingConfiguration';
|
|
7
8
|
export type CustomState = {
|
|
8
9
|
iconSlot: ReactElement;
|
|
9
10
|
heading: string;
|
|
@@ -104,4 +105,9 @@ export type DataGridProps = Pick<AriaAttributes, 'aria-label'> & {
|
|
|
104
105
|
* Handler called when the row selection is changed.
|
|
105
106
|
*/
|
|
106
107
|
onSelectionChanged?: (selectedRows: string[]) => void;
|
|
108
|
+
/** Row grouping */
|
|
109
|
+
/**
|
|
110
|
+
* Row grouping configuration for rendering nested data in the grid.
|
|
111
|
+
*/
|
|
112
|
+
rowGrouping?: RowGroupingConfiguration;
|
|
107
113
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ExpandedRows = true | Record<string, boolean>;
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for row grouping within the `DataGrid` component.
|
|
4
|
+
*/
|
|
5
|
+
export type RowGroupingConfiguration<TRow = any> = {
|
|
6
|
+
/**
|
|
7
|
+
* Getter used to fetch children within the tree data structure.
|
|
8
|
+
* @param row The row data to fetch children for.
|
|
9
|
+
* @returns The children of the given row.
|
|
10
|
+
*/
|
|
11
|
+
getChildData: (row: TRow) => any;
|
|
12
|
+
/**
|
|
13
|
+
* Expanded row state. This can either be:
|
|
14
|
+
* - `true` - every row is expanded by default.
|
|
15
|
+
* - a record of row ID's to a boolean value indicating whether the row is expanded or not.
|
|
16
|
+
*/
|
|
17
|
+
expandedRows: ExpandedRows;
|
|
18
|
+
/**
|
|
19
|
+
* Setter called when a row is expanded within the table.
|
|
20
|
+
*/
|
|
21
|
+
onRowExpanded: (expandedRows: ExpandedRows) => void;
|
|
22
|
+
};
|
|
@@ -4,3 +4,4 @@ export { AriaRoles } from './AriaRoles';
|
|
|
4
4
|
export { ColumnDefinition } from './ColumnDefinition';
|
|
5
5
|
export { SortState } from './SortState';
|
|
6
6
|
export { PinnedColumnState } from './PinnedColumnState';
|
|
7
|
+
export { RowGroupingConfiguration, ExpandedRows } from './RowGroupingConfiguration';
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const getAriaRoles = (enableKeyboardNavigation) => {
|
|
4
|
-
if (
|
|
3
|
+
const getAriaRoles = ({ enableKeyboardNavigation, rowGrouping, }) => {
|
|
4
|
+
if (rowGrouping) {
|
|
5
5
|
return {
|
|
6
|
-
table: '
|
|
7
|
-
cell: '
|
|
6
|
+
table: 'treegrid',
|
|
7
|
+
cell: 'gridcell',
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
if (enableKeyboardNavigation) {
|
|
11
|
+
return {
|
|
12
|
+
table: 'grid',
|
|
13
|
+
cell: 'gridcell',
|
|
8
14
|
};
|
|
9
15
|
}
|
|
10
16
|
return {
|
|
11
|
-
table: '
|
|
12
|
-
cell: '
|
|
17
|
+
table: 'table',
|
|
18
|
+
cell: 'cell',
|
|
13
19
|
};
|
|
14
20
|
};
|
|
15
21
|
|
|
@@ -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 = (enableKeyboardNavigation:
|
|
1
|
+
{"version":3,"file":"getAriaRoles.cjs","sources":["../../../../src/components/DataGrid/utils/getAriaRoles.ts"],"sourcesContent":["import { DataGridProps } from '../types';\nimport { AriaRoles } from '../types/AriaRoles';\n\ntype GetAriaRolesProps = Pick<DataGridProps, 'enableKeyboardNavigation' | 'rowGrouping'>;\n\nexport const getAriaRoles = ({\n enableKeyboardNavigation,\n rowGrouping,\n}: GetAriaRolesProps): AriaRoles => {\n if (rowGrouping) {\n return {\n table: 'treegrid',\n cell: 'gridcell',\n };\n }\n\n if (enableKeyboardNavigation) {\n return {\n table: 'grid',\n cell: 'gridcell',\n };\n }\n\n return {\n table: 'table',\n cell: 'cell',\n };\n};\n"],"names":[],"mappings":";;AAKa,MAAA,YAAY,GAAG,CAAC,EAC3B,wBAAwB,EACxB,WAAW,GACO,KAAe;AACjC,IAAA,IAAI,WAAW,EAAE;QACf,OAAO;AACL,YAAA,KAAK,EAAE,UAAU;AACjB,YAAA,IAAI,EAAE,UAAU;SACjB;AACF;AAED,IAAA,IAAI,wBAAwB,EAAE;QAC5B,OAAO;AACL,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,IAAI,EAAE,UAAU;SACjB;AACF;IAED,OAAO;AACL,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,IAAI,EAAE,MAAM;KACb;AACH;;;;"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { DataGridProps } from '../types';
|
|
1
2
|
import { AriaRoles } from '../types/AriaRoles';
|
|
2
|
-
|
|
3
|
+
type GetAriaRolesProps = Pick<DataGridProps, 'enableKeyboardNavigation' | 'rowGrouping'>;
|
|
4
|
+
export declare const getAriaRoles: ({ enableKeyboardNavigation, rowGrouping, }: GetAriaRolesProps) => AriaRoles;
|
|
5
|
+
export {};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
const getAriaRoles = (enableKeyboardNavigation) => {
|
|
2
|
-
if (
|
|
1
|
+
const getAriaRoles = ({ enableKeyboardNavigation, rowGrouping, }) => {
|
|
2
|
+
if (rowGrouping) {
|
|
3
3
|
return {
|
|
4
|
-
table: '
|
|
5
|
-
cell: '
|
|
4
|
+
table: 'treegrid',
|
|
5
|
+
cell: 'gridcell',
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
if (enableKeyboardNavigation) {
|
|
9
|
+
return {
|
|
10
|
+
table: 'grid',
|
|
11
|
+
cell: 'gridcell',
|
|
6
12
|
};
|
|
7
13
|
}
|
|
8
14
|
return {
|
|
9
|
-
table: '
|
|
10
|
-
cell: '
|
|
15
|
+
table: 'table',
|
|
16
|
+
cell: 'cell',
|
|
11
17
|
};
|
|
12
18
|
};
|
|
13
19
|
|
|
@@ -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 = (enableKeyboardNavigation:
|
|
1
|
+
{"version":3,"file":"getAriaRoles.js","sources":["../../../../src/components/DataGrid/utils/getAriaRoles.ts"],"sourcesContent":["import { DataGridProps } from '../types';\nimport { AriaRoles } from '../types/AriaRoles';\n\ntype GetAriaRolesProps = Pick<DataGridProps, 'enableKeyboardNavigation' | 'rowGrouping'>;\n\nexport const getAriaRoles = ({\n enableKeyboardNavigation,\n rowGrouping,\n}: GetAriaRolesProps): AriaRoles => {\n if (rowGrouping) {\n return {\n table: 'treegrid',\n cell: 'gridcell',\n };\n }\n\n if (enableKeyboardNavigation) {\n return {\n table: 'grid',\n cell: 'gridcell',\n };\n }\n\n return {\n table: 'table',\n cell: 'cell',\n };\n};\n"],"names":[],"mappings":"AAKa,MAAA,YAAY,GAAG,CAAC,EAC3B,wBAAwB,EACxB,WAAW,GACO,KAAe;AACjC,IAAA,IAAI,WAAW,EAAE;QACf,OAAO;AACL,YAAA,KAAK,EAAE,UAAU;AACjB,YAAA,IAAI,EAAE,UAAU;SACjB;AACF;AAED,IAAA,IAAI,wBAAwB,EAAE;QAC5B,OAAO;AACL,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,IAAI,EAAE,UAAU;SACjB;AACF;IAED,OAAO;AACL,QAAA,KAAK,EAAE,OAAO;AACd,QAAA,IAAI,EAAE,MAAM;KACb;AACH;;;;"}
|
|
@@ -2,7 +2,7 @@ export { Accordion } from './Accordion';
|
|
|
2
2
|
export { ActionMenu } from './ActionMenu';
|
|
3
3
|
export { Alert } from './Alerts/Alert';
|
|
4
4
|
export { MiniAlert } from './Alerts/MiniAlert';
|
|
5
|
-
export { Anchor } from './Anchor';
|
|
5
|
+
export { Anchor, AnchorProps, isAnchorUrl, isRelativeUrl, createContextAwareUrl, addPrefixToUrl, shouldAddPrefix, } from './Anchor';
|
|
6
6
|
export { AnimatedDropdown } from './AnimatedDropdown';
|
|
7
7
|
export { Avatar } from './Avatar';
|
|
8
8
|
export { Badge } from './Badge';
|
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,7 @@ var ActionMenu = require('./components/ActionMenu/ActionMenu.cjs');
|
|
|
5
5
|
var Alert = require('./components/Alerts/Alert/Alert.cjs');
|
|
6
6
|
var MiniAlert = require('./components/Alerts/MiniAlert/MiniAlert.cjs');
|
|
7
7
|
var Anchor = require('./components/Anchor/Anchor.cjs');
|
|
8
|
+
var urlUtils = require('./components/Anchor/utils/urlUtils.cjs');
|
|
8
9
|
var AnimatedDropdown = require('./components/AnimatedDropdown/AnimatedDropdown.cjs');
|
|
9
10
|
var Avatar = require('./components/Avatar/Avatar.cjs');
|
|
10
11
|
var Badge = require('./components/Badge/Badge.cjs');
|
|
@@ -140,6 +141,11 @@ exports.ActionMenu = ActionMenu.ActionMenu;
|
|
|
140
141
|
exports.Alert = Alert.Alert;
|
|
141
142
|
exports.MiniAlert = MiniAlert.MiniAlert;
|
|
142
143
|
exports.Anchor = Anchor.Anchor;
|
|
144
|
+
exports.addPrefixToUrl = urlUtils.addPrefixToUrl;
|
|
145
|
+
exports.createContextAwareUrl = urlUtils.createContextAwareUrl;
|
|
146
|
+
exports.isAnchorUrl = urlUtils.isAnchorUrl;
|
|
147
|
+
exports.isRelativeUrl = urlUtils.isRelativeUrl;
|
|
148
|
+
exports.shouldAddPrefix = urlUtils.shouldAddPrefix;
|
|
143
149
|
exports.AnimatedDropdown = AnimatedDropdown.AnimatedDropdown;
|
|
144
150
|
exports.Avatar = Avatar.Avatar;
|
|
145
151
|
exports.Badge = Badge.Badge;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { ActionMenu } from './components/ActionMenu/ActionMenu.js';
|
|
|
3
3
|
export { Alert } from './components/Alerts/Alert/Alert.js';
|
|
4
4
|
export { MiniAlert } from './components/Alerts/MiniAlert/MiniAlert.js';
|
|
5
5
|
export { Anchor } from './components/Anchor/Anchor.js';
|
|
6
|
+
export { addPrefixToUrl, createContextAwareUrl, isAnchorUrl, isRelativeUrl, shouldAddPrefix } from './components/Anchor/utils/urlUtils.js';
|
|
6
7
|
export { AnimatedDropdown } from './components/AnimatedDropdown/AnimatedDropdown.js';
|
|
7
8
|
export { Avatar } from './components/Avatar/Avatar.js';
|
|
8
9
|
export { Badge } from './components/Badge/Badge.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|