@tanstack/table-core 8.13.1 → 8.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/aggregationFns.d.ts +1 -1
- package/build/lib/aggregationFns.js.map +1 -1
- package/build/lib/core/column.js +1 -1
- package/build/lib/core/column.js.map +1 -1
- package/build/lib/core/headers.d.ts +1 -2
- package/build/lib/core/headers.js.map +1 -1
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/core/table.d.ts +7 -11
- package/build/lib/core/table.js +21 -13
- package/build/lib/core/table.js.map +1 -1
- package/build/lib/features/ColumnFaceting.d.ts +34 -0
- package/build/lib/features/ColumnFaceting.js +42 -0
- package/build/lib/features/ColumnFaceting.js.map +1 -0
- package/build/lib/features/{Filters.d.ts → ColumnFiltering.d.ts} +29 -132
- package/build/lib/features/{Filters.js → ColumnFiltering.js} +8 -83
- package/build/lib/features/ColumnFiltering.js.map +1 -0
- package/build/lib/features/{Grouping.d.ts → ColumnGrouping.d.ts} +2 -3
- package/build/lib/features/{Grouping.js → ColumnGrouping.js} +3 -3
- package/build/lib/features/ColumnGrouping.js.map +1 -0
- package/build/lib/features/{Ordering.d.ts → ColumnOrdering.d.ts} +2 -3
- package/build/lib/features/{Ordering.js → ColumnOrdering.js} +9 -9
- package/build/lib/features/ColumnOrdering.js.map +1 -0
- package/build/lib/features/ColumnPinning.d.ts +126 -0
- package/build/lib/features/{Pinning.js → ColumnPinning.js} +4 -115
- package/build/lib/features/ColumnPinning.js.map +1 -0
- package/build/lib/features/ColumnSizing.d.ts +2 -3
- package/build/lib/features/ColumnSizing.js +3 -3
- package/build/lib/features/ColumnSizing.js.map +1 -1
- package/build/lib/features/{Visibility.d.ts → ColumnVisibility.d.ts} +2 -3
- package/build/lib/features/{Visibility.js → ColumnVisibility.js} +3 -3
- package/build/lib/features/ColumnVisibility.js.map +1 -0
- package/build/lib/features/GlobalFiltering.d.ts +100 -0
- package/build/lib/features/GlobalFiltering.js +85 -0
- package/build/lib/features/GlobalFiltering.js.map +1 -0
- package/build/lib/features/{Expanding.d.ts → RowExpanding.d.ts} +2 -3
- package/build/lib/features/{Expanding.js → RowExpanding.js} +3 -3
- package/build/lib/features/RowExpanding.js.map +1 -0
- package/build/lib/features/{Pagination.d.ts → RowPagination.d.ts} +2 -3
- package/build/lib/features/{Pagination.js → RowPagination.js} +3 -3
- package/build/lib/features/RowPagination.js.map +1 -0
- package/build/lib/features/RowPinning.d.ts +98 -0
- package/build/lib/features/RowPinning.js +145 -0
- package/build/lib/features/RowPinning.js.map +1 -0
- package/build/lib/features/RowSelection.d.ts +1 -2
- package/build/lib/features/RowSelection.js.map +1 -1
- package/build/lib/features/{Sorting.d.ts → RowSorting.d.ts} +5 -3
- package/build/lib/features/{Sorting.js → RowSorting.js} +3 -3
- package/build/lib/features/RowSorting.js.map +1 -0
- package/build/lib/filterFns.d.ts +1 -1
- package/build/lib/filterFns.js.map +1 -1
- package/build/lib/index.d.ts +21 -18
- package/build/lib/index.esm.js +1490 -1446
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +47 -41
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +1490 -1446
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/sortingFns.d.ts +1 -1
- package/build/lib/sortingFns.js.map +1 -1
- package/build/lib/types.d.ts +30 -16
- package/build/lib/utils/getFilteredRowModel.js.map +1 -1
- package/build/lib/utils/getSortedRowModel.js.map +1 -1
- package/build/lib/utils.d.ts +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +1500 -1453
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/aggregationFns.ts +1 -1
- package/src/core/column.ts +2 -2
- package/src/core/headers.ts +9 -3
- package/src/core/row.ts +1 -1
- package/src/core/table.ts +40 -32
- package/src/features/ColumnFaceting.ts +84 -0
- package/src/features/{Filters.ts → ColumnFiltering.ts} +44 -279
- package/src/features/{Grouping.ts → ColumnGrouping.ts} +6 -6
- package/src/features/{Ordering.ts → ColumnOrdering.ts} +11 -5
- package/src/features/ColumnPinning.ts +336 -0
- package/src/features/ColumnSizing.ts +10 -3
- package/src/features/{Visibility.ts → ColumnVisibility.ts} +2 -2
- package/src/features/GlobalFiltering.ts +218 -0
- package/src/features/{Expanding.ts → RowExpanding.ts} +9 -3
- package/src/features/{Pagination.ts → RowPagination.ts} +9 -3
- package/src/features/RowPinning.ts +273 -0
- package/src/features/RowSelection.ts +9 -2
- package/src/features/{Sorting.ts → RowSorting.ts} +5 -2
- package/src/filterFns.ts +1 -1
- package/src/index.ts +30 -18
- package/src/sortingFns.ts +1 -1
- package/src/types.ts +60 -23
- package/src/utils/getFilteredRowModel.ts +1 -1
- package/src/utils/getSortedRowModel.ts +1 -1
- package/src/utils.ts +9 -11
- package/build/lib/features/Expanding.js.map +0 -1
- package/build/lib/features/Filters.js.map +0 -1
- package/build/lib/features/Grouping.js.map +0 -1
- package/build/lib/features/Ordering.js.map +0 -1
- package/build/lib/features/Pagination.js.map +0 -1
- package/build/lib/features/Pinning.d.ts +0 -222
- package/build/lib/features/Pinning.js.map +0 -1
- package/build/lib/features/Sorting.js.map +0 -1
- package/build/lib/features/Visibility.js.map +0 -1
- package/src/features/Pinning.ts +0 -573
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowSelection.js","sources":["../../../src/features/RowSelection.ts"],"sourcesContent":["import { TableFeature } from '../core/table'\nimport { OnChangeFn, Table, Row, RowModel, Updater, RowData } from '../types'\nimport { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nexport type RowSelectionState = Record<string, boolean>\n\nexport interface RowSelectionTableState {\n rowSelection: RowSelectionState\n}\n\nexport interface RowSelectionOptions<TData extends RowData> {\n /**\n * - Enables/disables multiple row selection for all rows in the table OR\n * - A function that given a row, returns whether to enable/disable multiple row selection for that row's children/grandchildren\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablemultirowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * - Enables/disables row selection for all rows in the table OR\n * - A function that given a row, returns whether to enable/disable row selection for that row\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablerowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * Enables/disables automatic sub-row selection when a parent row is selected, or a function that enables/disables automatic sub-row selection for each row.\n * (Use in combination with expanding or grouping features)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablesubrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * If provided, this function will be called with an `updaterFn` when `state.rowSelection` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#onrowselectionchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n onRowSelectionChange?: OnChangeFn<RowSelectionState>\n // enableGroupingRowSelection?:\n // | boolean\n // | ((\n // row: Row<TData>\n // ) => boolean)\n // isAdditiveSelectEvent?: (e: unknown) => boolean\n // isInclusiveSelectEvent?: (e: unknown) => boolean\n // selectRowsFn?: (\n // table: Table<TData>,\n // rowModel: RowModel<TData>\n // ) => RowModel<TData>\n}\n\nexport interface RowSelectionRow {\n /**\n * Returns whether or not the row can multi-select.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanmultiselect)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanMultiSelect: () => boolean\n /**\n * Returns whether or not the row can be selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselect)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanSelect: () => boolean\n /**\n * Returns whether or not the row can select sub rows automatically when the parent row is selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselectsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanSelectSubRows: () => boolean\n /**\n * Returns whether or not all of the row's sub rows are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallsubrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllSubRowsSelected: () => boolean\n /**\n * Returns whether or not the row is selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSelected: () => boolean\n /**\n * Returns whether or not some of the row's sub rows are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomeselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomeSelected: () => boolean\n /**\n * Returns a handler that can be used to toggle the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleSelectedHandler: () => (event: unknown) => void\n /**\n * Selects/deselects the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleSelected: (value?: boolean, opts?: { selectChildren?: boolean }) => void\n}\n\nexport interface RowSelectionInstance<TData extends RowData> {\n /**\n * Returns the row model of all rows that are selected after filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getfilteredselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getFilteredSelectedRowModel: () => RowModel<TData>\n /**\n * Returns the row model of all rows that are selected after grouping has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getgroupedselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getGroupedSelectedRowModel: () => RowModel<TData>\n /**\n * Returns whether or not all rows on the current page are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallpagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllPageRowsSelected: () => boolean\n /**\n * Returns whether or not all rows in the table are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllRowsSelected: () => boolean\n /**\n * Returns whether or not any rows on the current page are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomepagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomePageRowsSelected: () => boolean\n /**\n * Returns whether or not any rows in the table are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomeRowsSelected: () => boolean\n /**\n * Returns the core row model of all rows before row selection has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getpreselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getPreSelectedRowModel: () => RowModel<TData>\n /**\n * Returns the row model of all rows that are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getSelectedRowModel: () => RowModel<TData>\n /**\n * Returns a handler that can be used to toggle all rows on the current page.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallpagerowsselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void\n /**\n * Returns a handler that can be used to toggle all rows in the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallrowsselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleAllRowsSelectedHandler: () => (event: unknown) => void\n /**\n * Resets the **rowSelection** state to the `initialState.rowSelection`, or `true` can be passed to force a default blank state reset to `{}`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#resetrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n resetRowSelection: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.rowSelection` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#setrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n setRowSelection: (updater: Updater<RowSelectionState>) => void\n /**\n * Selects/deselects all rows on the current page.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallpagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleAllPageRowsSelected: (value?: boolean) => void\n /**\n * Selects/deselects all rows in the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleAllRowsSelected: (value?: boolean) => void\n}\n\n//\n\nexport const RowSelection: TableFeature = {\n getInitialState: (state): RowSelectionTableState => {\n return {\n rowSelection: {},\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): RowSelectionOptions<TData> => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n // enableGroupingRowSelection: false,\n // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,\n // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setRowSelection = updater =>\n table.options.onRowSelectionChange?.(updater)\n table.resetRowSelection = defaultState =>\n table.setRowSelection(\n defaultState ? {} : table.initialState.rowSelection ?? {}\n )\n table.toggleAllRowsSelected = value => {\n table.setRowSelection(old => {\n value =\n typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected()\n\n const rowSelection = { ...old }\n\n const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows\n\n // We don't use `mutateRowIsSelected` here for performance reasons.\n // All of the rows are flat already, so it wouldn't be worth it\n if (value) {\n preGroupedFlatRows.forEach(row => {\n if (!row.getCanSelect()) {\n return\n }\n rowSelection[row.id] = true\n })\n } else {\n preGroupedFlatRows.forEach(row => {\n delete rowSelection[row.id]\n })\n }\n\n return rowSelection\n })\n }\n table.toggleAllPageRowsSelected = value =>\n table.setRowSelection(old => {\n const resolvedValue =\n typeof value !== 'undefined'\n ? value\n : !table.getIsAllPageRowsSelected()\n\n const rowSelection: RowSelectionState = { ...old }\n\n table.getRowModel().rows.forEach(row => {\n mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table)\n })\n\n return rowSelection\n })\n\n // addRowSelectionRange: rowId => {\n // const {\n // rows,\n // rowsById,\n // options: { selectGroupingRows, selectSubRows },\n // } = table\n\n // const findSelectedRow = (rows: Row[]) => {\n // let found\n // rows.find(d => {\n // if (d.getIsSelected()) {\n // found = d\n // return true\n // }\n // const subFound = findSelectedRow(d.subRows || [])\n // if (subFound) {\n // found = subFound\n // return true\n // }\n // return false\n // })\n // return found\n // }\n\n // const firstRow = findSelectedRow(rows) || rows[0]\n // const lastRow = rowsById[rowId]\n\n // let include = false\n // const selectedRowIds = {}\n\n // const addRow = (row: Row) => {\n // mutateRowIsSelected(selectedRowIds, row.id, true, {\n // rowsById,\n // selectGroupingRows: selectGroupingRows!,\n // selectSubRows: selectSubRows!,\n // })\n // }\n\n // table.rows.forEach(row => {\n // const isFirstRow = row.id === firstRow.id\n // const isLastRow = row.id === lastRow.id\n\n // if (isFirstRow || isLastRow) {\n // if (!include) {\n // include = true\n // } else if (include) {\n // addRow(row)\n // include = false\n // }\n // }\n\n // if (include) {\n // addRow(row)\n // }\n // })\n\n // table.setRowSelection(selectedRowIds)\n // },\n table.getPreSelectedRowModel = () => table.getCoreRowModel()\n table.getSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getCoreRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel')\n )\n\n table.getFilteredSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getFilteredRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel')\n )\n\n table.getGroupedSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getSortedRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel')\n )\n\n ///\n\n // getGroupingRowCanSelect: rowId => {\n // const row = table.getRow(rowId)\n\n // if (!row) {\n // throw new Error()\n // }\n\n // if (typeof table.options.enableGroupingRowSelection === 'function') {\n // return table.options.enableGroupingRowSelection(row)\n // }\n\n // return table.options.enableGroupingRowSelection ?? false\n // },\n\n table.getIsAllRowsSelected = () => {\n const preGroupedFlatRows = table.getFilteredRowModel().flatRows\n const { rowSelection } = table.getState()\n\n let isAllRowsSelected = Boolean(\n preGroupedFlatRows.length && Object.keys(rowSelection).length\n )\n\n if (isAllRowsSelected) {\n if (\n preGroupedFlatRows.some(\n row => row.getCanSelect() && !rowSelection[row.id]\n )\n ) {\n isAllRowsSelected = false\n }\n }\n\n return isAllRowsSelected\n }\n\n table.getIsAllPageRowsSelected = () => {\n const paginationFlatRows = table\n .getPaginationRowModel()\n .flatRows.filter(row => row.getCanSelect())\n const { rowSelection } = table.getState()\n\n let isAllPageRowsSelected = !!paginationFlatRows.length\n\n if (\n isAllPageRowsSelected &&\n paginationFlatRows.some(row => !rowSelection[row.id])\n ) {\n isAllPageRowsSelected = false\n }\n\n return isAllPageRowsSelected\n }\n\n table.getIsSomeRowsSelected = () => {\n const totalSelected = Object.keys(\n table.getState().rowSelection ?? {}\n ).length\n return (\n totalSelected > 0 &&\n totalSelected < table.getFilteredRowModel().flatRows.length\n )\n }\n\n table.getIsSomePageRowsSelected = () => {\n const paginationFlatRows = table.getPaginationRowModel().flatRows\n return table.getIsAllPageRowsSelected()\n ? false\n : paginationFlatRows\n .filter(row => row.getCanSelect())\n .some(d => d.getIsSelected() || d.getIsSomeSelected())\n }\n\n table.getToggleAllRowsSelectedHandler = () => {\n return (e: unknown) => {\n table.toggleAllRowsSelected(\n ((e as MouseEvent).target as HTMLInputElement).checked\n )\n }\n }\n\n table.getToggleAllPageRowsSelectedHandler = () => {\n return (e: unknown) => {\n table.toggleAllPageRowsSelected(\n ((e as MouseEvent).target as HTMLInputElement).checked\n )\n }\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.toggleSelected = (value, opts) => {\n const isSelected = row.getIsSelected()\n\n table.setRowSelection(old => {\n value = typeof value !== 'undefined' ? value : !isSelected\n\n if (row.getCanSelect() && isSelected === value) {\n return old\n }\n\n const selectedRowIds = { ...old }\n\n mutateRowIsSelected(\n selectedRowIds,\n row.id,\n value,\n opts?.selectChildren ?? true,\n table\n )\n\n return selectedRowIds\n })\n }\n row.getIsSelected = () => {\n const { rowSelection } = table.getState()\n return isRowSelected(row, rowSelection)\n }\n\n row.getIsSomeSelected = () => {\n const { rowSelection } = table.getState()\n return isSubRowSelected(row, rowSelection, table) === 'some'\n }\n\n row.getIsAllSubRowsSelected = () => {\n const { rowSelection } = table.getState()\n return isSubRowSelected(row, rowSelection, table) === 'all'\n }\n\n row.getCanSelect = () => {\n if (typeof table.options.enableRowSelection === 'function') {\n return table.options.enableRowSelection(row)\n }\n\n return table.options.enableRowSelection ?? true\n }\n\n row.getCanSelectSubRows = () => {\n if (typeof table.options.enableSubRowSelection === 'function') {\n return table.options.enableSubRowSelection(row)\n }\n\n return table.options.enableSubRowSelection ?? true\n }\n\n row.getCanMultiSelect = () => {\n if (typeof table.options.enableMultiRowSelection === 'function') {\n return table.options.enableMultiRowSelection(row)\n }\n\n return table.options.enableMultiRowSelection ?? true\n }\n row.getToggleSelectedHandler = () => {\n const canSelect = row.getCanSelect()\n\n return (e: unknown) => {\n if (!canSelect) return\n row.toggleSelected(\n ((e as MouseEvent).target as HTMLInputElement)?.checked\n )\n }\n }\n },\n}\n\nconst mutateRowIsSelected = <TData extends RowData>(\n selectedRowIds: Record<string, boolean>,\n id: string,\n value: boolean,\n includeChildren: boolean,\n table: Table<TData>\n) => {\n const row = table.getRow(id, true)\n\n // const isGrouped = row.getIsGrouped()\n\n // if ( // TODO: enforce grouping row selection rules\n // !isGrouped ||\n // (isGrouped && table.options.enableGroupingRowSelection)\n // ) {\n if (value) {\n if (!row.getCanMultiSelect()) {\n Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key])\n }\n if (row.getCanSelect()) {\n selectedRowIds[id] = true\n }\n } else {\n delete selectedRowIds[id]\n }\n // }\n\n if (includeChildren && row.subRows?.length && row.getCanSelectSubRows()) {\n row.subRows.forEach(row =>\n mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table)\n )\n }\n}\n\nexport function selectRowsFn<TData extends RowData>(\n table: Table<TData>,\n rowModel: RowModel<TData>\n): RowModel<TData> {\n const rowSelection = table.getState().rowSelection\n\n const newSelectedFlatRows: Row<TData>[] = []\n const newSelectedRowsById: Record<string, Row<TData>> = {}\n\n // Filters top level and nested rows\n const recurseRows = (rows: Row<TData>[], depth = 0): Row<TData>[] => {\n return rows\n .map(row => {\n const isSelected = isRowSelected(row, rowSelection)\n\n if (isSelected) {\n newSelectedFlatRows.push(row)\n newSelectedRowsById[row.id] = row\n }\n\n if (row.subRows?.length) {\n row = {\n ...row,\n subRows: recurseRows(row.subRows, depth + 1),\n }\n }\n\n if (isSelected) {\n return row\n }\n })\n .filter(Boolean) as Row<TData>[]\n }\n\n return {\n rows: recurseRows(rowModel.rows),\n flatRows: newSelectedFlatRows,\n rowsById: newSelectedRowsById,\n }\n}\n\nexport function isRowSelected<TData extends RowData>(\n row: Row<TData>,\n selection: Record<string, boolean>\n): boolean {\n return selection[row.id] ?? false\n}\n\nexport function isSubRowSelected<TData extends RowData>(\n row: Row<TData>,\n selection: Record<string, boolean>,\n table: Table<TData>\n): boolean | 'some' | 'all' {\n if (!row.subRows?.length) return false\n\n let allChildrenSelected = true\n let someSelected = false\n\n row.subRows.forEach(subRow => {\n // Bail out early if we know both of these\n if (someSelected && !allChildrenSelected) {\n return\n }\n\n if (subRow.getCanSelect()) {\n if (isRowSelected(subRow, selection)) {\n someSelected = true\n } else {\n allChildrenSelected = false\n }\n }\n\n // Check row selection of nested subrows\n if (subRow.subRows && subRow.subRows.length) {\n const subRowChildrenSelected = isSubRowSelected(subRow, selection, table)\n if (subRowChildrenSelected === 'all') {\n someSelected = true\n } else if (subRowChildrenSelected === 'some') {\n someSelected = true\n allChildrenSelected = false\n } else {\n allChildrenSelected = false\n }\n }\n })\n\n return allChildrenSelected ? 'all' : someSelected ? 'some' : false\n}\n"],"names":["RowSelection","getInitialState","state","rowSelection","getDefaultOptions","table","onRowSelectionChange","makeStateUpdater","enableRowSelection","enableMultiRowSelection","enableSubRowSelection","createTable","setRowSelection","updater","options","resetRowSelection","defaultState","_table$initialState$r","initialState","toggleAllRowsSelected","value","old","getIsAllRowsSelected","preGroupedFlatRows","getPreGroupedRowModel","flatRows","forEach","row","getCanSelect","id","toggleAllPageRowsSelected","resolvedValue","getIsAllPageRowsSelected","getRowModel","rows","mutateRowIsSelected","getPreSelectedRowModel","getCoreRowModel","getSelectedRowModel","memo","getState","rowModel","Object","keys","length","rowsById","selectRowsFn","getMemoOptions","getFilteredSelectedRowModel","getFilteredRowModel","getGroupedSelectedRowModel","getSortedRowModel","isAllRowsSelected","Boolean","some","paginationFlatRows","getPaginationRowModel","filter","isAllPageRowsSelected","getIsSomeRowsSelected","_table$getState$rowSe","totalSelected","getIsSomePageRowsSelected","d","getIsSelected","getIsSomeSelected","getToggleAllRowsSelectedHandler","e","target","checked","getToggleAllPageRowsSelectedHandler","createRow","toggleSelected","opts","isSelected","_opts$selectChildren","selectedRowIds","selectChildren","isRowSelected","isSubRowSelected","getIsAllSubRowsSelected","_table$options$enable","getCanSelectSubRows","_table$options$enable2","getCanMultiSelect","_table$options$enable3","getToggleSelectedHandler","canSelect","_target","includeChildren","_row$subRows","getRow","key","subRows","newSelectedFlatRows","newSelectedRowsById","recurseRows","depth","map","_row$subRows2","push","selection","_selection$row$id","_row$subRows3","allChildrenSelected","someSelected","subRow","subRowChildrenSelected"],"mappings":";;;;;;;;;;;;;;AA6LA;;AAEO,MAAMA,YAA0B,GAAG;EACxCC,eAAe,EAAGC,KAAK,IAA6B;IAClD,OAAO;MACLC,YAAY,EAAE,EAAE;MAChB,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,iBAAiB,EACfC,KAAmB,IACY;IAC/B,OAAO;AACLC,MAAAA,oBAAoB,EAAEC,sBAAgB,CAAC,cAAc,EAAEF,KAAK,CAAC;AAC7DG,MAAAA,kBAAkB,EAAE,IAAI;AACxBC,MAAAA,uBAAuB,EAAE,IAAI;AAC7BC,MAAAA,qBAAqB,EAAE,IAAA;AACvB;AACA;AACA;KACD,CAAA;GACF;EAEDC,WAAW,EAA0BN,KAAmB,IAAW;AACjEA,IAAAA,KAAK,CAACO,eAAe,GAAGC,OAAO,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CAAA;AACrB,OAAC,MAAM;AACLD,QAAAA,mBAAmB,GAAG,KAAK,CAAA;AAC7B,OAAA;AACF,KAAA;;AAEA;IACA,IAAIE,MAAM,CAACb,OAAO,IAAIa,MAAM,CAACb,OAAO,CAACjD,MAAM,EAAE;MAC3C,MAAM+D,sBAAsB,GAAG5B,gBAAgB,CAAC2B,MAAM,EAAEL,SAAgB,CAAC,CAAA;MACzE,IAAIM,sBAAsB,KAAK,KAAK,EAAE;AACpCF,QAAAA,YAAY,GAAG,IAAI,CAAA;AACrB,OAAC,MAAM,IAAIE,sBAAsB,KAAK,MAAM,EAAE;AAC5CF,QAAAA,YAAY,GAAG,IAAI,CAAA;AACnBD,QAAAA,mBAAmB,GAAG,KAAK,CAAA;AAC7B,OAAC,MAAM;AACLA,QAAAA,mBAAmB,GAAG,KAAK,CAAA;AAC7B,OAAA;AACF,KAAA;AACF,GAAC,CAAC,CAAA;EAEF,OAAOA,mBAAmB,GAAG,KAAK,GAAGC,YAAY,GAAG,MAAM,GAAG,KAAK,CAAA;AACpE;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"RowSelection.js","sources":["../../../src/features/RowSelection.ts"],"sourcesContent":["import {\n OnChangeFn,\n Table,\n Row,\n RowModel,\n Updater,\n RowData,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nexport type RowSelectionState = Record<string, boolean>\n\nexport interface RowSelectionTableState {\n rowSelection: RowSelectionState\n}\n\nexport interface RowSelectionOptions<TData extends RowData> {\n /**\n * - Enables/disables multiple row selection for all rows in the table OR\n * - A function that given a row, returns whether to enable/disable multiple row selection for that row's children/grandchildren\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablemultirowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * - Enables/disables row selection for all rows in the table OR\n * - A function that given a row, returns whether to enable/disable row selection for that row\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablerowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * Enables/disables automatic sub-row selection when a parent row is selected, or a function that enables/disables automatic sub-row selection for each row.\n * (Use in combination with expanding or grouping features)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablesubrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * If provided, this function will be called with an `updaterFn` when `state.rowSelection` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#onrowselectionchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n onRowSelectionChange?: OnChangeFn<RowSelectionState>\n // enableGroupingRowSelection?:\n // | boolean\n // | ((\n // row: Row<TData>\n // ) => boolean)\n // isAdditiveSelectEvent?: (e: unknown) => boolean\n // isInclusiveSelectEvent?: (e: unknown) => boolean\n // selectRowsFn?: (\n // table: Table<TData>,\n // rowModel: RowModel<TData>\n // ) => RowModel<TData>\n}\n\nexport interface RowSelectionRow {\n /**\n * Returns whether or not the row can multi-select.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanmultiselect)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanMultiSelect: () => boolean\n /**\n * Returns whether or not the row can be selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselect)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanSelect: () => boolean\n /**\n * Returns whether or not the row can select sub rows automatically when the parent row is selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselectsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanSelectSubRows: () => boolean\n /**\n * Returns whether or not all of the row's sub rows are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallsubrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllSubRowsSelected: () => boolean\n /**\n * Returns whether or not the row is selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSelected: () => boolean\n /**\n * Returns whether or not some of the row's sub rows are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomeselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomeSelected: () => boolean\n /**\n * Returns a handler that can be used to toggle the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleSelectedHandler: () => (event: unknown) => void\n /**\n * Selects/deselects the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleSelected: (value?: boolean, opts?: { selectChildren?: boolean }) => void\n}\n\nexport interface RowSelectionInstance<TData extends RowData> {\n /**\n * Returns the row model of all rows that are selected after filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getfilteredselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getFilteredSelectedRowModel: () => RowModel<TData>\n /**\n * Returns the row model of all rows that are selected after grouping has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getgroupedselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getGroupedSelectedRowModel: () => RowModel<TData>\n /**\n * Returns whether or not all rows on the current page are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallpagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllPageRowsSelected: () => boolean\n /**\n * Returns whether or not all rows in the table are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllRowsSelected: () => boolean\n /**\n * Returns whether or not any rows on the current page are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomepagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomePageRowsSelected: () => boolean\n /**\n * Returns whether or not any rows in the table are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomeRowsSelected: () => boolean\n /**\n * Returns the core row model of all rows before row selection has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getpreselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getPreSelectedRowModel: () => RowModel<TData>\n /**\n * Returns the row model of all rows that are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getSelectedRowModel: () => RowModel<TData>\n /**\n * Returns a handler that can be used to toggle all rows on the current page.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallpagerowsselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void\n /**\n * Returns a handler that can be used to toggle all rows in the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallrowsselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleAllRowsSelectedHandler: () => (event: unknown) => void\n /**\n * Resets the **rowSelection** state to the `initialState.rowSelection`, or `true` can be passed to force a default blank state reset to `{}`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#resetrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n resetRowSelection: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.rowSelection` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#setrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n setRowSelection: (updater: Updater<RowSelectionState>) => void\n /**\n * Selects/deselects all rows on the current page.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallpagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleAllPageRowsSelected: (value?: boolean) => void\n /**\n * Selects/deselects all rows in the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleAllRowsSelected: (value?: boolean) => void\n}\n\n//\n\nexport const RowSelection: TableFeature = {\n getInitialState: (state): RowSelectionTableState => {\n return {\n rowSelection: {},\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): RowSelectionOptions<TData> => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n // enableGroupingRowSelection: false,\n // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,\n // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setRowSelection = updater =>\n table.options.onRowSelectionChange?.(updater)\n table.resetRowSelection = defaultState =>\n table.setRowSelection(\n defaultState ? {} : table.initialState.rowSelection ?? {}\n )\n table.toggleAllRowsSelected = value => {\n table.setRowSelection(old => {\n value =\n typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected()\n\n const rowSelection = { ...old }\n\n const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows\n\n // We don't use `mutateRowIsSelected` here for performance reasons.\n // All of the rows are flat already, so it wouldn't be worth it\n if (value) {\n preGroupedFlatRows.forEach(row => {\n if (!row.getCanSelect()) {\n return\n }\n rowSelection[row.id] = true\n })\n } else {\n preGroupedFlatRows.forEach(row => {\n delete rowSelection[row.id]\n })\n }\n\n return rowSelection\n })\n }\n table.toggleAllPageRowsSelected = value =>\n table.setRowSelection(old => {\n const resolvedValue =\n typeof value !== 'undefined'\n ? value\n : !table.getIsAllPageRowsSelected()\n\n const rowSelection: RowSelectionState = { ...old }\n\n table.getRowModel().rows.forEach(row => {\n mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table)\n })\n\n return rowSelection\n })\n\n // addRowSelectionRange: rowId => {\n // const {\n // rows,\n // rowsById,\n // options: { selectGroupingRows, selectSubRows },\n // } = table\n\n // const findSelectedRow = (rows: Row[]) => {\n // let found\n // rows.find(d => {\n // if (d.getIsSelected()) {\n // found = d\n // return true\n // }\n // const subFound = findSelectedRow(d.subRows || [])\n // if (subFound) {\n // found = subFound\n // return true\n // }\n // return false\n // })\n // return found\n // }\n\n // const firstRow = findSelectedRow(rows) || rows[0]\n // const lastRow = rowsById[rowId]\n\n // let include = false\n // const selectedRowIds = {}\n\n // const addRow = (row: Row) => {\n // mutateRowIsSelected(selectedRowIds, row.id, true, {\n // rowsById,\n // selectGroupingRows: selectGroupingRows!,\n // selectSubRows: selectSubRows!,\n // })\n // }\n\n // table.rows.forEach(row => {\n // const isFirstRow = row.id === firstRow.id\n // const isLastRow = row.id === lastRow.id\n\n // if (isFirstRow || isLastRow) {\n // if (!include) {\n // include = true\n // } else if (include) {\n // addRow(row)\n // include = false\n // }\n // }\n\n // if (include) {\n // addRow(row)\n // }\n // })\n\n // table.setRowSelection(selectedRowIds)\n // },\n table.getPreSelectedRowModel = () => table.getCoreRowModel()\n table.getSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getCoreRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel')\n )\n\n table.getFilteredSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getFilteredRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel')\n )\n\n table.getGroupedSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getSortedRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel')\n )\n\n ///\n\n // getGroupingRowCanSelect: rowId => {\n // const row = table.getRow(rowId)\n\n // if (!row) {\n // throw new Error()\n // }\n\n // if (typeof table.options.enableGroupingRowSelection === 'function') {\n // return table.options.enableGroupingRowSelection(row)\n // }\n\n // return table.options.enableGroupingRowSelection ?? false\n // },\n\n table.getIsAllRowsSelected = () => {\n const preGroupedFlatRows = table.getFilteredRowModel().flatRows\n const { rowSelection } = table.getState()\n\n let isAllRowsSelected = Boolean(\n preGroupedFlatRows.length && Object.keys(rowSelection).length\n )\n\n if (isAllRowsSelected) {\n if (\n preGroupedFlatRows.some(\n row => row.getCanSelect() && !rowSelection[row.id]\n )\n ) {\n isAllRowsSelected = false\n }\n }\n\n return isAllRowsSelected\n }\n\n table.getIsAllPageRowsSelected = () => {\n const paginationFlatRows = table\n .getPaginationRowModel()\n .flatRows.filter(row => row.getCanSelect())\n const { rowSelection } = table.getState()\n\n let isAllPageRowsSelected = !!paginationFlatRows.length\n\n if (\n isAllPageRowsSelected &&\n paginationFlatRows.some(row => !rowSelection[row.id])\n ) {\n isAllPageRowsSelected = false\n }\n\n return isAllPageRowsSelected\n }\n\n table.getIsSomeRowsSelected = () => {\n const totalSelected = Object.keys(\n table.getState().rowSelection ?? {}\n ).length\n return (\n totalSelected > 0 &&\n totalSelected < table.getFilteredRowModel().flatRows.length\n )\n }\n\n table.getIsSomePageRowsSelected = () => {\n const paginationFlatRows = table.getPaginationRowModel().flatRows\n return table.getIsAllPageRowsSelected()\n ? false\n : paginationFlatRows\n .filter(row => row.getCanSelect())\n .some(d => d.getIsSelected() || d.getIsSomeSelected())\n }\n\n table.getToggleAllRowsSelectedHandler = () => {\n return (e: unknown) => {\n table.toggleAllRowsSelected(\n ((e as MouseEvent).target as HTMLInputElement).checked\n )\n }\n }\n\n table.getToggleAllPageRowsSelectedHandler = () => {\n return (e: unknown) => {\n table.toggleAllPageRowsSelected(\n ((e as MouseEvent).target as HTMLInputElement).checked\n )\n }\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.toggleSelected = (value, opts) => {\n const isSelected = row.getIsSelected()\n\n table.setRowSelection(old => {\n value = typeof value !== 'undefined' ? value : !isSelected\n\n if (row.getCanSelect() && isSelected === value) {\n return old\n }\n\n const selectedRowIds = { ...old }\n\n mutateRowIsSelected(\n selectedRowIds,\n row.id,\n value,\n opts?.selectChildren ?? true,\n table\n )\n\n return selectedRowIds\n })\n }\n row.getIsSelected = () => {\n const { rowSelection } = table.getState()\n return isRowSelected(row, rowSelection)\n }\n\n row.getIsSomeSelected = () => {\n const { rowSelection } = table.getState()\n return isSubRowSelected(row, rowSelection, table) === 'some'\n }\n\n row.getIsAllSubRowsSelected = () => {\n const { rowSelection } = table.getState()\n return isSubRowSelected(row, rowSelection, table) === 'all'\n }\n\n row.getCanSelect = () => {\n if (typeof table.options.enableRowSelection === 'function') {\n return table.options.enableRowSelection(row)\n }\n\n return table.options.enableRowSelection ?? true\n }\n\n row.getCanSelectSubRows = () => {\n if (typeof table.options.enableSubRowSelection === 'function') {\n return table.options.enableSubRowSelection(row)\n }\n\n return table.options.enableSubRowSelection ?? true\n }\n\n row.getCanMultiSelect = () => {\n if (typeof table.options.enableMultiRowSelection === 'function') {\n return table.options.enableMultiRowSelection(row)\n }\n\n return table.options.enableMultiRowSelection ?? true\n }\n row.getToggleSelectedHandler = () => {\n const canSelect = row.getCanSelect()\n\n return (e: unknown) => {\n if (!canSelect) return\n row.toggleSelected(\n ((e as MouseEvent).target as HTMLInputElement)?.checked\n )\n }\n }\n },\n}\n\nconst mutateRowIsSelected = <TData extends RowData>(\n selectedRowIds: Record<string, boolean>,\n id: string,\n value: boolean,\n includeChildren: boolean,\n table: Table<TData>\n) => {\n const row = table.getRow(id, true)\n\n // const isGrouped = row.getIsGrouped()\n\n // if ( // TODO: enforce grouping row selection rules\n // !isGrouped ||\n // (isGrouped && table.options.enableGroupingRowSelection)\n // ) {\n if (value) {\n if (!row.getCanMultiSelect()) {\n Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key])\n }\n if (row.getCanSelect()) {\n selectedRowIds[id] = true\n }\n } else {\n delete selectedRowIds[id]\n }\n // }\n\n if (includeChildren && row.subRows?.length && row.getCanSelectSubRows()) {\n row.subRows.forEach(row =>\n mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table)\n )\n }\n}\n\nexport function selectRowsFn<TData extends RowData>(\n table: Table<TData>,\n rowModel: RowModel<TData>\n): RowModel<TData> {\n const rowSelection = table.getState().rowSelection\n\n const newSelectedFlatRows: Row<TData>[] = []\n const newSelectedRowsById: Record<string, Row<TData>> = {}\n\n // Filters top level and nested rows\n const recurseRows = (rows: Row<TData>[], depth = 0): Row<TData>[] => {\n return rows\n .map(row => {\n const isSelected = isRowSelected(row, rowSelection)\n\n if (isSelected) {\n newSelectedFlatRows.push(row)\n newSelectedRowsById[row.id] = row\n }\n\n if (row.subRows?.length) {\n row = {\n ...row,\n subRows: recurseRows(row.subRows, depth + 1),\n }\n }\n\n if (isSelected) {\n return row\n }\n })\n .filter(Boolean) as Row<TData>[]\n }\n\n return {\n rows: recurseRows(rowModel.rows),\n flatRows: newSelectedFlatRows,\n rowsById: newSelectedRowsById,\n }\n}\n\nexport function isRowSelected<TData extends RowData>(\n row: Row<TData>,\n selection: Record<string, boolean>\n): boolean {\n return selection[row.id] ?? false\n}\n\nexport function isSubRowSelected<TData extends RowData>(\n row: Row<TData>,\n selection: Record<string, boolean>,\n table: Table<TData>\n): boolean | 'some' | 'all' {\n if (!row.subRows?.length) return false\n\n let allChildrenSelected = true\n let someSelected = false\n\n row.subRows.forEach(subRow => {\n // Bail out early if we know both of these\n if (someSelected && !allChildrenSelected) {\n return\n }\n\n if (subRow.getCanSelect()) {\n if (isRowSelected(subRow, selection)) {\n someSelected = true\n } else {\n allChildrenSelected = false\n }\n }\n\n // Check row selection of nested subrows\n if (subRow.subRows && subRow.subRows.length) {\n const subRowChildrenSelected = isSubRowSelected(subRow, selection, table)\n if (subRowChildrenSelected === 'all') {\n someSelected = true\n } else if (subRowChildrenSelected === 'some') {\n someSelected = true\n allChildrenSelected = false\n } else {\n allChildrenSelected = false\n }\n }\n })\n\n return allChildrenSelected ? 'all' : someSelected ? 'some' : false\n}\n"],"names":["RowSelection","getInitialState","state","rowSelection","getDefaultOptions","table","onRowSelectionChange","makeStateUpdater","enableRowSelection","enableMultiRowSelection","enableSubRowSelection","createTable","setRowSelection","updater","options","resetRowSelection","defaultState","_table$initialState$r","initialState","toggleAllRowsSelected","value","old","getIsAllRowsSelected","preGroupedFlatRows","getPreGroupedRowModel","flatRows","forEach","row","getCanSelect","id","toggleAllPageRowsSelected","resolvedValue","getIsAllPageRowsSelected","getRowModel","rows","mutateRowIsSelected","getPreSelectedRowModel","getCoreRowModel","getSelectedRowModel","memo","getState","rowModel","Object","keys","length","rowsById","selectRowsFn","getMemoOptions","getFilteredSelectedRowModel","getFilteredRowModel","getGroupedSelectedRowModel","getSortedRowModel","isAllRowsSelected","Boolean","some","paginationFlatRows","getPaginationRowModel","filter","isAllPageRowsSelected","getIsSomeRowsSelected","_table$getState$rowSe","totalSelected","getIsSomePageRowsSelected","d","getIsSelected","getIsSomeSelected","getToggleAllRowsSelectedHandler","e","target","checked","getToggleAllPageRowsSelectedHandler","createRow","toggleSelected","opts","isSelected","_opts$selectChildren","selectedRowIds","selectChildren","isRowSelected","isSubRowSelected","getIsAllSubRowsSelected","_table$options$enable","getCanSelectSubRows","_table$options$enable2","getCanMultiSelect","_table$options$enable3","getToggleSelectedHandler","canSelect","_target","includeChildren","_row$subRows","getRow","key","subRows","newSelectedFlatRows","newSelectedRowsById","recurseRows","depth","map","_row$subRows2","push","selection","_selection$row$id","_row$subRows3","allChildrenSelected","someSelected","subRow","subRowChildrenSelected"],"mappings":";;;;;;;;;;;;;;AAoMA;;AAEO,MAAMA,YAA0B,GAAG;EACxCC,eAAe,EAAGC,KAAK,IAA6B;IAClD,OAAO;MACLC,YAAY,EAAE,EAAE;MAChB,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,iBAAiB,EACfC,KAAmB,IACY;IAC/B,OAAO;AACLC,MAAAA,oBAAoB,EAAEC,sBAAgB,CAAC,cAAc,EAAEF,KAAK,CAAC;AAC7DG,MAAAA,kBAAkB,EAAE,IAAI;AACxBC,MAAAA,uBAAuB,EAAE,IAAI;AAC7BC,MAAAA,qBAAqB,EAAE,IAAA;AACvB;AACA;AACA;KACD,CAAA;GACF;EAEDC,WAAW,EAA0BN,KAAmB,IAAW;AACjEA,IAAAA,KAAK,CAACO,eAAe,GAAGC,OAAO,IAC7BR,KAAK,CAACS,OAAO,CAACR,oBAAoB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAlCD,KAAK,CAACS,OAAO,CAACR,oBAAoB,CAAGO,OAAO,CAAC,CAAA;IAC/CR,KAAK,CAACU,iBAAiB,GAAGC,YAAY,IAAA;AAA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AsB,GAAG5B,gBAAgB,CAAC2B,MAAM,EAAEL,SAAgB,CAAC,CAAA;MACzE,IAAIM,sBAAsB,KAAK,KAAK,EAAE;AACpCF,QAAAA,YAAY,GAAG,IAAI,CAAA;AACrB,OAAC,MAAM,IAAIE,sBAAsB,KAAK,MAAM,EAAE;AAC5CF,QAAAA,YAAY,GAAG,IAAI,CAAA;AACnBD,QAAAA,mBAAmB,GAAG,KAAK,CAAA;AAC7B,OAAC,MAAM;AACLA,QAAAA,mBAAmB,GAAG,KAAK,CAAA;AAC7B,OAAA;AACF,KAAA;AACF,GAAC,CAAC,CAAA;EAEF,OAAOA,mBAAmB,GAAG,KAAK,GAAGC,YAAY,GAAG,MAAM,GAAG,KAAK,CAAA;AACpE;;;;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RowModel } from '..';
|
|
2
|
-
import { TableFeature } from '../core/table';
|
|
3
2
|
import { BuiltInSortingFn } from '../sortingFns';
|
|
4
|
-
import { OnChangeFn, Table, Row, Updater, RowData, SortingFns } from '../types';
|
|
3
|
+
import { OnChangeFn, Table, Row, Updater, RowData, SortingFns, TableFeature } from '../types';
|
|
5
4
|
export type SortDirection = 'asc' | 'desc';
|
|
6
5
|
export interface ColumnSort {
|
|
7
6
|
desc: boolean;
|
|
@@ -50,12 +49,15 @@ export interface SortingColumnDef<TData extends RowData> {
|
|
|
50
49
|
*/
|
|
51
50
|
sortingFn?: SortingFnOption<TData>;
|
|
52
51
|
/**
|
|
52
|
+
* The priority of undefined values when sorting this column.
|
|
53
53
|
* - `false`
|
|
54
54
|
* - Undefined values will be considered tied and need to be sorted by the next column filter or original index (whichever applies)
|
|
55
55
|
* - `-1`
|
|
56
56
|
* - Undefined values will be sorted with higher priority (ascending) (if ascending, undefined will appear on the beginning of the list)
|
|
57
57
|
* - `1`
|
|
58
58
|
* - Undefined values will be sorted with lower priority (descending) (if ascending, undefined will appear on the end of the list)
|
|
59
|
+
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortundefined)
|
|
60
|
+
* @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
|
|
59
61
|
*/
|
|
60
62
|
sortUndefined?: false | -1 | 1;
|
|
61
63
|
}
|
|
@@ -231,5 +233,5 @@ export interface SortingInstance<TData extends RowData> {
|
|
|
231
233
|
*/
|
|
232
234
|
setSorting: (updater: Updater<SortingState>) => void;
|
|
233
235
|
}
|
|
234
|
-
export declare const
|
|
236
|
+
export declare const RowSorting: TableFeature;
|
|
235
237
|
export {};
|
|
@@ -15,7 +15,7 @@ var utils = require('../utils.js');
|
|
|
15
15
|
|
|
16
16
|
//
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const RowSorting = {
|
|
19
19
|
getInitialState: state => {
|
|
20
20
|
return {
|
|
21
21
|
sorting: [],
|
|
@@ -222,5 +222,5 @@ const Sorting = {
|
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
-
exports.
|
|
226
|
-
//# sourceMappingURL=
|
|
225
|
+
exports.RowSorting = RowSorting;
|
|
226
|
+
//# sourceMappingURL=RowSorting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowSorting.js","sources":["../../../src/features/RowSorting.ts"],"sourcesContent":["import { RowModel } from '..'\nimport {\n BuiltInSortingFn,\n reSplitAlphaNumeric,\n sortingFns,\n} from '../sortingFns'\n\nimport {\n Column,\n OnChangeFn,\n Table,\n Row,\n Updater,\n RowData,\n SortingFns,\n TableFeature,\n} from '../types'\n\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport type SortDirection = 'asc' | 'desc'\n\nexport interface ColumnSort {\n desc: boolean\n id: string\n}\n\nexport type SortingState = ColumnSort[]\n\nexport interface SortingTableState {\n sorting: SortingState\n}\n\nexport interface SortingFn<TData extends RowData> {\n (rowA: Row<TData>, rowB: Row<TData>, columnId: string): number\n}\n\nexport type CustomSortingFns<TData extends RowData> = Record<\n string,\n SortingFn<TData>\n>\n\nexport type SortingFnOption<TData extends RowData> =\n | 'auto'\n | keyof SortingFns\n | BuiltInSortingFn\n | SortingFn<TData>\n\nexport interface SortingColumnDef<TData extends RowData> {\n /**\n * Enables/Disables multi-sorting for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiSort?: boolean\n /**\n * Enables/Disables sorting for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSorting?: boolean\n /**\n * Inverts the order of the sorting for this column. This is useful for values that have an inverted best/worst scale where lower numbers are better, eg. a ranking (1st, 2nd, 3rd) or golf-like scoring\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#invertsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n invertSorting?: boolean\n /**\n * Set to `true` for sorting toggles on this column to start in the descending direction.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortdescfirst)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortDescFirst?: boolean\n /**\n * The sorting function to use with this column.\n * - A `string` referencing a built-in sorting function\n * - A custom sorting function\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortingFn?: SortingFnOption<TData>\n /**\n * The priority of undefined values when sorting this column.\n * - `false`\n * - Undefined values will be considered tied and need to be sorted by the next column filter or original index (whichever applies)\n * - `-1`\n * - Undefined values will be sorted with higher priority (ascending) (if ascending, undefined will appear on the beginning of the list)\n * - `1`\n * - Undefined values will be sorted with lower priority (descending) (if ascending, undefined will appear on the end of the list)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortundefined)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortUndefined?: false | -1 | 1\n}\n\nexport interface SortingColumn<TData extends RowData> {\n /**\n * Removes this column from the table's sorting state\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#clearsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n clearSorting: () => void\n /**\n * Returns a sort direction automatically inferred based on the columns values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getautosortdir)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getAutoSortDir: () => SortDirection\n /**\n * Returns a sorting function automatically inferred based on the columns values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getautosortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getAutoSortingFn: () => SortingFn<TData>\n /**\n * Returns whether this column can be multi-sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getcanmultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getCanMultiSort: () => boolean\n /**\n * Returns whether this column can be sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getcansort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getCanSort: () => boolean\n /**\n * Returns the first direction that should be used when sorting this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getfirstsortdir)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getFirstSortDir: () => SortDirection\n /**\n * Returns the current sort direction of this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getissorted)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getIsSorted: () => false | SortDirection\n /**\n * Returns the next sorting order.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getnextsortingorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getNextSortingOrder: () => SortDirection | false\n /**\n * Returns the index position of this column's sorting within the sorting state\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortIndex: () => number\n /**\n * Returns the resolved sorting function to be used for this column\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortingFn: () => SortingFn<TData>\n /**\n * Returns a function that can be used to toggle this column's sorting state. This is useful for attaching a click handler to the column header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#gettogglesortinghandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getToggleSortingHandler: () => undefined | ((event: unknown) => void)\n /**\n * Toggles this columns sorting state. If `desc` is provided, it will force the sort direction to that value. If `isMulti` is provided, it will additivity multi-sort the column (or toggle it if it is already sorted).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#togglesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n toggleSorting: (desc?: boolean, isMulti?: boolean) => void\n}\n\ninterface SortingOptionsBase {\n /**\n * Enables/disables the ability to remove multi-sorts\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultiremove)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiRemove?: boolean\n /**\n * Enables/Disables multi-sorting for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiSort?: boolean\n /**\n * Enables/Disables sorting for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSorting?: boolean\n /**\n * Enables/Disables the ability to remove sorting for the table.\n * - If `true` then changing sort order will circle like: 'none' -> 'desc' -> 'asc' -> 'none' -> ...\n * - If `false` then changing sort order will circle like: 'none' -> 'desc' -> 'asc' -> 'desc' -> 'asc' -> ...\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesortingremoval)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSortingRemoval?: boolean\n /**\n * This function is used to retrieve the sorted row model. If using server-side sorting, this function is not required. To use client-side sorting, pass the exported `getSortedRowModel()` from your adapter to your table or implement your own.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortedRowModel?: (table: Table<any>) => () => RowModel<any>\n /**\n * Pass a custom function that will be used to determine if a multi-sort event should be triggered. It is passed the event from the sort toggle handler and should return `true` if the event should trigger a multi-sort.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#ismultisortevent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n isMultiSortEvent?: (e: unknown) => boolean\n /**\n * Enables manual sorting for the table. If this is `true`, you will be expected to sort your data before it is passed to the table. This is useful if you are doing server-side sorting.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#manualsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n manualSorting?: boolean\n /**\n * Set a maximum number of columns that can be multi-sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#maxmultisortcolcount)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n maxMultiSortColCount?: number\n /**\n * If provided, this function will be called with an `updaterFn` when `state.sorting` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#onsortingchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n onSortingChange?: OnChangeFn<SortingState>\n /**\n * If `true`, all sorts will default to descending as their first toggle state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortdescfirst)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortDescFirst?: boolean\n}\n\ntype ResolvedSortingFns = keyof SortingFns extends never\n ? {\n sortingFns?: Record<string, SortingFn<any>>\n }\n : {\n sortingFns: Record<keyof SortingFns, SortingFn<any>>\n }\n\nexport interface SortingOptions<TData extends RowData>\n extends SortingOptionsBase,\n ResolvedSortingFns {}\n\nexport interface SortingInstance<TData extends RowData> {\n _getSortedRowModel?: () => RowModel<TData>\n /**\n * Returns the row model for the table before any sorting has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getpresortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getPreSortedRowModel: () => RowModel<TData>\n /**\n * Returns the row model for the table after sorting has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortedRowModel: () => RowModel<TData>\n /**\n * Resets the **sorting** state to `initialState.sorting`, or `true` can be passed to force a default blank state reset to `[]`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#resetsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n resetSorting: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.sorting` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#setsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n setSorting: (updater: Updater<SortingState>) => void\n}\n\n//\n\nexport const RowSorting: TableFeature = {\n getInitialState: (state): SortingTableState => {\n return {\n sorting: [],\n ...state,\n }\n },\n\n getDefaultColumnDef: <TData extends RowData>(): SortingColumnDef<TData> => {\n return {\n sortingFn: 'auto',\n sortUndefined: 1,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): SortingOptions<TData> => {\n return {\n onSortingChange: makeStateUpdater('sorting', table),\n isMultiSortEvent: (e: unknown) => {\n return (e as MouseEvent).shiftKey\n },\n }\n },\n\n createColumn: <TData extends RowData, TValue>(\n column: Column<TData, TValue>,\n table: Table<TData>\n ): void => {\n column.getAutoSortingFn = () => {\n const firstRows = table.getFilteredRowModel().flatRows.slice(10)\n\n let isString = false\n\n for (const row of firstRows) {\n const value = row?.getValue(column.id)\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return sortingFns.datetime\n }\n\n if (typeof value === 'string') {\n isString = true\n\n if (value.split(reSplitAlphaNumeric).length > 1) {\n return sortingFns.alphanumeric\n }\n }\n }\n\n if (isString) {\n return sortingFns.text\n }\n\n return sortingFns.basic\n }\n column.getAutoSortDir = () => {\n const firstRow = table.getFilteredRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'string') {\n return 'asc'\n }\n\n return 'desc'\n }\n column.getSortingFn = () => {\n if (!column) {\n throw new Error()\n }\n\n return isFunction(column.columnDef.sortingFn)\n ? column.columnDef.sortingFn\n : column.columnDef.sortingFn === 'auto'\n ? column.getAutoSortingFn()\n : table.options.sortingFns?.[column.columnDef.sortingFn as string] ??\n sortingFns[column.columnDef.sortingFn as BuiltInSortingFn]\n }\n column.toggleSorting = (desc, multi) => {\n // if (column.columns.length) {\n // column.columns.forEach((c, i) => {\n // if (c.id) {\n // table.toggleColumnSorting(c.id, undefined, multi || !!i)\n // }\n // })\n // return\n // }\n\n // this needs to be outside of table.setSorting to be in sync with rerender\n const nextSortingOrder = column.getNextSortingOrder()\n const hasManualValue = typeof desc !== 'undefined' && desc !== null\n\n table.setSorting(old => {\n // Find any existing sorting for this column\n const existingSorting = old?.find(d => d.id === column.id)\n const existingIndex = old?.findIndex(d => d.id === column.id)\n\n let newSorting: SortingState = []\n\n // What should we do with this sort action?\n let sortAction: 'add' | 'remove' | 'toggle' | 'replace'\n let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'\n\n // Multi-mode\n if (old?.length && column.getCanMultiSort() && multi) {\n if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'add'\n }\n } else {\n // Normal mode\n if (old?.length && existingIndex !== old.length - 1) {\n sortAction = 'replace'\n } else if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'replace'\n }\n }\n\n // Handle toggle states that will remove the sorting\n if (sortAction === 'toggle') {\n // If we are \"actually\" toggling (not a manual set value), should we remove the sorting?\n if (!hasManualValue) {\n // Is our intention to remove?\n if (!nextSortingOrder) {\n sortAction = 'remove'\n }\n }\n }\n\n if (sortAction === 'add') {\n newSorting = [\n ...old,\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n // Take latest n columns\n newSorting.splice(\n 0,\n newSorting.length -\n (table.options.maxMultiSortColCount ?? Number.MAX_SAFE_INTEGER)\n )\n } else if (sortAction === 'toggle') {\n // This flips (or sets) the\n newSorting = old.map(d => {\n if (d.id === column.id) {\n return {\n ...d,\n desc: nextDesc,\n }\n }\n return d\n })\n } else if (sortAction === 'remove') {\n newSorting = old.filter(d => d.id !== column.id)\n } else {\n newSorting = [\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n }\n\n return newSorting\n })\n }\n\n column.getFirstSortDir = () => {\n const sortDescFirst =\n column.columnDef.sortDescFirst ??\n table.options.sortDescFirst ??\n column.getAutoSortDir() === 'desc'\n return sortDescFirst ? 'desc' : 'asc'\n }\n\n column.getNextSortingOrder = (multi?: boolean) => {\n const firstSortDirection = column.getFirstSortDir()\n const isSorted = column.getIsSorted()\n\n if (!isSorted) {\n return firstSortDirection\n }\n\n if (\n isSorted !== firstSortDirection &&\n (table.options.enableSortingRemoval ?? true) && // If enableSortRemove, enable in general\n (multi ? table.options.enableMultiRemove ?? true : true) // If multi, don't allow if enableMultiRemove))\n ) {\n return false\n }\n return isSorted === 'desc' ? 'asc' : 'desc'\n }\n\n column.getCanSort = () => {\n return (\n (column.columnDef.enableSorting ?? true) &&\n (table.options.enableSorting ?? true) &&\n !!column.accessorFn\n )\n }\n\n column.getCanMultiSort = () => {\n return (\n column.columnDef.enableMultiSort ??\n table.options.enableMultiSort ??\n !!column.accessorFn\n )\n }\n\n column.getIsSorted = () => {\n const columnSort = table.getState().sorting?.find(d => d.id === column.id)\n\n return !columnSort ? false : columnSort.desc ? 'desc' : 'asc'\n }\n\n column.getSortIndex = () =>\n table.getState().sorting?.findIndex(d => d.id === column.id) ?? -1\n\n column.clearSorting = () => {\n //clear sorting for just 1 column\n table.setSorting(old =>\n old?.length ? old.filter(d => d.id !== column.id) : []\n )\n }\n\n column.getToggleSortingHandler = () => {\n const canSort = column.getCanSort()\n\n return (e: unknown) => {\n if (!canSort) return\n ;(e as any).persist?.()\n column.toggleSorting?.(\n undefined,\n column.getCanMultiSort() ? table.options.isMultiSortEvent?.(e) : false\n )\n }\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setSorting = updater => table.options.onSortingChange?.(updater)\n table.resetSorting = defaultState => {\n table.setSorting(defaultState ? [] : table.initialState?.sorting ?? [])\n }\n table.getPreSortedRowModel = () => table.getGroupedRowModel()\n table.getSortedRowModel = () => {\n if (!table._getSortedRowModel && table.options.getSortedRowModel) {\n table._getSortedRowModel = table.options.getSortedRowModel(table)\n }\n\n if (table.options.manualSorting || !table._getSortedRowModel) {\n return table.getPreSortedRowModel()\n }\n\n return table._getSortedRowModel()\n }\n },\n}\n"],"names":["RowSorting","getInitialState","state","sorting","getDefaultColumnDef","sortingFn","sortUndefined","getDefaultOptions","table","onSortingChange","makeStateUpdater","isMultiSortEvent","e","shiftKey","createColumn","column","getAutoSortingFn","firstRows","getFilteredRowModel","flatRows","slice","isString","row","value","getValue","id","Object","prototype","toString","call","sortingFns","datetime","split","reSplitAlphaNumeric","length","alphanumeric","text","basic","getAutoSortDir","firstRow","getSortingFn","_table$options$sortin","_table$options$sortin2","Error","isFunction","columnDef","options","toggleSorting","desc","multi","nextSortingOrder","getNextSortingOrder","hasManualValue","setSorting","old","existingSorting","find","d","existingIndex","findIndex","newSorting","sortAction","nextDesc","getCanMultiSort","_table$options$maxMul","splice","maxMultiSortColCount","Number","MAX_SAFE_INTEGER","map","filter","getFirstSortDir","_ref","_column$columnDef$sor","sortDescFirst","_table$options$enable","_table$options$enable2","firstSortDirection","isSorted","getIsSorted","enableSortingRemoval","enableMultiRemove","getCanSort","_column$columnDef$ena","_table$options$enable3","enableSorting","accessorFn","_ref2","_column$columnDef$ena2","enableMultiSort","_table$getState$sorti","columnSort","getState","getSortIndex","_table$getState$sorti2","_table$getState$sorti3","clearSorting","getToggleSortingHandler","canSort","persist","undefined","createTable","updater","resetSorting","defaultState","_table$initialState$s","_table$initialState","initialState","getPreSortedRowModel","getGroupedRowModel","getSortedRowModel","_getSortedRowModel","manualSorting"],"mappings":";;;;;;;;;;;;;;;AAmRA;;AAEO,MAAMA,UAAwB,GAAG;EACtCC,eAAe,EAAGC,KAAK,IAAwB;IAC7C,OAAO;AACLC,MAAAA,OAAO,EAAE,EAAE;MACX,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,mBAAmB,EAAEA,MAAsD;IACzE,OAAO;AACLC,MAAAA,SAAS,EAAE,MAAM;AACjBC,MAAAA,aAAa,EAAE,CAAA;KAChB,CAAA;GACF;EAEDC,iBAAiB,EACfC,KAAmB,IACO;IAC1B,OAAO;AACLC,MAAAA,eAAe,EAAEC,sBAAgB,CAAC,SAAS,EAAEF,KAAK,CAAC;MACnDG,gBAAgB,EAAGC,CAAU,IAAK;QAChC,OAAQA,CAAC,CAAgBC,QAAQ,CAAA;AACnC,OAAA;KACD,CAAA;GACF;AAEDC,EAAAA,YAAY,EAAEA,CACZC,MAA6B,EAC7BP,KAAmB,KACV;IACTO,MAAM,CAACC,gBAAgB,GAAG,MAAM;AAC9B,MAAA,MAAMC,SAAS,GAAGT,KAAK,CAACU,mBAAmB,EAAE,CAACC,QAAQ,CAACC,KAAK,CAAC,EAAE,CAAC,CAAA;MAEhE,IAAIC,QAAQ,GAAG,KAAK,CAAA;AAEpB,MAAA,KAAK,MAAMC,GAAG,IAAIL,SAAS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MAC9B,IAAI,CAACtG,KAAK,CAACuG,kBAAkB,IAAIvG,KAAK,CAACsC,OAAO,CAACgE,iBAAiB,EAAE;QAChEtG,KAAK,CAACuG,kBAAkB,GAAGvG,KAAK,CAACsC,OAAO,CAACgE,iBAAiB,CAACtG,KAAK,CAAC,CAAA;AACnE,OAAA;MAEA,IAAIA,KAAK,CAACsC,OAAO,CAACkE,aAAa,IAAI,CAACxG,KAAK,CAACuG,kBAAkB,EAAE;AAC5D,QAAA,OAAOvG,KAAK,CAACoG,oBAAoB,EAAE,CAAA;AACrC,OAAA;AAEA,MAAA,OAAOpG,KAAK,CAACuG,kBAAkB,EAAE,CAAA;KAClC,CAAA;AACH,GAAA;AACF;;;;"}
|
package/build/lib/filterFns.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filterFns.js","sources":["../../src/filterFns.ts"],"sourcesContent":["import { FilterFn } from './features/
|
|
1
|
+
{"version":3,"file":"filterFns.js","sources":["../../src/filterFns.ts"],"sourcesContent":["import { FilterFn } from './features/ColumnFiltering'\n\nconst includesString: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: string\n) => {\n const search = filterValue.toLowerCase()\n return Boolean(\n row\n .getValue<string | null>(columnId)\n ?.toString()\n ?.toLowerCase()\n ?.includes(search)\n )\n}\n\nincludesString.autoRemove = (val: any) => testFalsey(val)\n\nconst includesStringSensitive: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: string\n) => {\n return Boolean(\n row.getValue<string | null>(columnId)?.toString()?.includes(filterValue)\n )\n}\n\nincludesStringSensitive.autoRemove = (val: any) => testFalsey(val)\n\nconst equalsString: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: string\n) => {\n return (\n row.getValue<string | null>(columnId)?.toString()?.toLowerCase() ===\n filterValue?.toLowerCase()\n )\n}\n\nequalsString.autoRemove = (val: any) => testFalsey(val)\n\nconst arrIncludes: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: unknown\n) => {\n return row.getValue<unknown[]>(columnId)?.includes(filterValue)\n}\n\narrIncludes.autoRemove = (val: any) => testFalsey(val) || !val?.length\n\nconst arrIncludesAll: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: unknown[]\n) => {\n return !filterValue.some(\n val => !row.getValue<unknown[]>(columnId)?.includes(val)\n )\n}\n\narrIncludesAll.autoRemove = (val: any) => testFalsey(val) || !val?.length\n\nconst arrIncludesSome: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: unknown[]\n) => {\n return filterValue.some(\n val => row.getValue<unknown[]>(columnId)?.includes(val)\n )\n}\n\narrIncludesSome.autoRemove = (val: any) => testFalsey(val) || !val?.length\n\nconst equals: FilterFn<any> = (row, columnId: string, filterValue: unknown) => {\n return row.getValue(columnId) === filterValue\n}\n\nequals.autoRemove = (val: any) => testFalsey(val)\n\nconst weakEquals: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: unknown\n) => {\n return row.getValue(columnId) == filterValue\n}\n\nweakEquals.autoRemove = (val: any) => testFalsey(val)\n\nconst inNumberRange: FilterFn<any> = (\n row,\n columnId: string,\n filterValue: [number, number]\n) => {\n let [min, max] = filterValue\n\n const rowValue = row.getValue<number>(columnId)\n return rowValue >= min && rowValue <= max\n}\n\ninNumberRange.resolveFilterValue = (val: [any, any]) => {\n let [unsafeMin, unsafeMax] = val\n\n let parsedMin =\n typeof unsafeMin !== 'number' ? parseFloat(unsafeMin as string) : unsafeMin\n let parsedMax =\n typeof unsafeMax !== 'number' ? parseFloat(unsafeMax as string) : unsafeMax\n\n let min =\n unsafeMin === null || Number.isNaN(parsedMin) ? -Infinity : parsedMin\n let max = unsafeMax === null || Number.isNaN(parsedMax) ? Infinity : parsedMax\n\n if (min > max) {\n const temp = min\n min = max\n max = temp\n }\n\n return [min, max] as const\n}\n\ninNumberRange.autoRemove = (val: any) =>\n testFalsey(val) || (testFalsey(val[0]) && testFalsey(val[1]))\n\n// Export\n\nexport const filterFns = {\n includesString,\n includesStringSensitive,\n equalsString,\n arrIncludes,\n arrIncludesAll,\n arrIncludesSome,\n equals,\n weakEquals,\n inNumberRange,\n}\n\nexport type BuiltInFilterFn = keyof typeof filterFns\n\n// Utils\n\nfunction testFalsey(val: any) {\n return val === undefined || val === null || val === ''\n}\n"],"names":["includesString","row","columnId","filterValue","_row$getValue","search","toLowerCase","Boolean","getValue","toString","includes","autoRemove","val","testFalsey","includesStringSensitive","_row$getValue2","equalsString","_row$getValue3","arrIncludes","_row$getValue4","length","arrIncludesAll","some","_row$getValue5","arrIncludesSome","_row$getValue6","equals","weakEquals","inNumberRange","min","max","rowValue","resolveFilterValue","unsafeMin","unsafeMax","parsedMin","parseFloat","parsedMax","Number","isNaN","Infinity","temp","filterFns","undefined"],"mappings":";;;;;;;;;;;;AAEA,MAAMA,cAA6B,GAAGA,CACpCC,GAAG,EACHC,QAAgB,EAChBC,WAAmB,KAChB;AAAA,EAAA,IAAAC,aAAA,CAAA;AACH,EAAA,MAAMC,MAAM,GAAGF,WAAW,CAACG,WAAW,EAAE,CAAA;AACxC,EAAA,OAAOC,OAAO,CAAA,CAAAH,aAAA,GACZH,GAAG,CACAO,QAAQ,CAAgBN,QAAQ,CAAC,KAAA,IAAA,IAAA,CAAAE,aAAA,GADpCA,aAAA,CAEIK,QAAQ,EAAE,KAAAL,IAAAA,IAAAA,CAAAA,aAAA,GAFdA,aAAA,CAGIE,WAAW,EAAE,KAAA,IAAA,GAAA,KAAA,CAAA,GAHjBF,aAAA,CAIIM,QAAQ,CAACL,MAAM,CACrB,CAAC,CAAA;AACH,CAAC,CAAA;AAEDL,cAAc,CAACW,UAAU,GAAIC,GAAQ,IAAKC,UAAU,CAACD,GAAG,CAAC,CAAA;AAEzD,MAAME,uBAAsC,GAAGA,CAC7Cb,GAAG,EACHC,QAAgB,EAChBC,WAAmB,KAChB;AAAA,EAAA,IAAAY,cAAA,CAAA;EACH,OAAOR,OAAO,CAAAQ,CAAAA,cAAA,GACZd,GAAG,CAACO,QAAQ,CAAgBN,QAAQ,CAA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ACb,MAAMW,IAAI,GAAGZ,GAAG,CAAA;AAChBA,IAAAA,GAAG,GAAGC,GAAG,CAAA;AACTA,IAAAA,GAAG,GAAGW,IAAI,CAAA;AACZ,GAAA;AAEA,EAAA,OAAO,CAACZ,GAAG,EAAEC,GAAG,CAAC,CAAA;AACnB,CAAC,CAAA;AAEDF,aAAa,CAACjB,UAAU,GAAIC,GAAQ,IAClCC,UAAU,CAACD,GAAG,CAAC,IAAKC,UAAU,CAACD,GAAG,CAAC,CAAC,CAAC,CAAC,IAAIC,UAAU,CAACD,GAAG,CAAC,CAAC,CAAC,CAAE,CAAA;;AAE/D;;AAEO,MAAM8B,SAAS,GAAG;EACvB1C,cAAc;EACdc,uBAAuB;EACvBE,YAAY;EACZE,WAAW;EACXG,cAAc;EACdG,eAAe;EACfE,MAAM;EACNC,UAAU;AACVC,EAAAA,aAAAA;AACF,EAAC;AAID;;AAEA,SAASf,UAAUA,CAACD,GAAQ,EAAE;EAC5B,OAAOA,GAAG,KAAK+B,SAAS,IAAI/B,GAAG,KAAK,IAAI,IAAIA,GAAG,KAAK,EAAE,CAAA;AACxD;;;;"}
|
package/build/lib/index.d.ts
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './columnHelper';
|
|
2
2
|
export * from './types';
|
|
3
|
+
export * from './core/cell';
|
|
3
4
|
export * from './core/column';
|
|
4
5
|
export * from './core/headers';
|
|
5
6
|
export * from './core/row';
|
|
6
|
-
export * from './core/
|
|
7
|
+
export * from './core/table';
|
|
8
|
+
export * from './features/ColumnFaceting';
|
|
9
|
+
export * from './features/ColumnFiltering';
|
|
10
|
+
export * from './features/ColumnGrouping';
|
|
11
|
+
export * from './features/ColumnOrdering';
|
|
12
|
+
export * from './features/ColumnPinning';
|
|
7
13
|
export * from './features/ColumnSizing';
|
|
8
|
-
export * from './features/
|
|
9
|
-
export * from './features/
|
|
10
|
-
export * from './features/
|
|
11
|
-
export * from './features/
|
|
12
|
-
export * from './features/
|
|
13
|
-
export * from './features/Pinning';
|
|
14
|
+
export * from './features/ColumnVisibility';
|
|
15
|
+
export * from './features/GlobalFiltering';
|
|
16
|
+
export * from './features/RowExpanding';
|
|
17
|
+
export * from './features/RowPagination';
|
|
18
|
+
export * from './features/RowPinning';
|
|
14
19
|
export * from './features/RowSelection';
|
|
15
|
-
export * from './features/
|
|
16
|
-
export * from './features/Visibility';
|
|
17
|
-
export * from './filterFns';
|
|
18
|
-
export * from './sortingFns';
|
|
19
|
-
export * from './aggregationFns';
|
|
20
|
-
export * from './columnHelper';
|
|
20
|
+
export * from './features/RowSorting';
|
|
21
21
|
export * from './utils';
|
|
22
22
|
export * from './utils/getCoreRowModel';
|
|
23
|
-
export * from './utils/
|
|
23
|
+
export * from './utils/getExpandedRowModel';
|
|
24
|
+
export * from './utils/getFacetedMinMaxValues';
|
|
24
25
|
export * from './utils/getFacetedRowModel';
|
|
25
26
|
export * from './utils/getFacetedUniqueValues';
|
|
26
|
-
export * from './utils/
|
|
27
|
-
export * from './utils/getSortedRowModel';
|
|
27
|
+
export * from './utils/getFilteredRowModel';
|
|
28
28
|
export * from './utils/getGroupedRowModel';
|
|
29
|
-
export * from './utils/getExpandedRowModel';
|
|
30
29
|
export * from './utils/getPaginationRowModel';
|
|
30
|
+
export * from './utils/getSortedRowModel';
|
|
31
|
+
export * from './aggregationFns';
|
|
32
|
+
export * from './filterFns';
|
|
33
|
+
export * from './sortingFns';
|