@tanstack/table-core 8.19.1 → 8.19.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/features/RowPinning.d.ts +1 -1
- package/build/lib/features/RowPinning.js +7 -7
- package/build/lib/features/RowPinning.js.map +1 -1
- package/build/lib/index.esm.js +15 -8
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +15 -8
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/utils/getGroupedRowModel.d.ts +1 -1
- package/build/lib/utils/getGroupedRowModel.js +8 -1
- package/build/lib/utils/getGroupedRowModel.js.map +1 -1
- package/build/umd/index.development.js +15 -8
- 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/features/RowPinning.ts +35 -31
- package/src/utils/getGroupedRowModel.ts +11 -2
|
@@ -57,7 +57,7 @@ export interface RowPinningRow {
|
|
|
57
57
|
pin: (position: RowPinningPosition, includeLeafRows?: boolean, includeParentRows?: boolean) => void;
|
|
58
58
|
}
|
|
59
59
|
export interface RowPinningInstance<TData extends RowData> {
|
|
60
|
-
_getPinnedRows: (position: 'top' | 'bottom') => Row<TData>[];
|
|
60
|
+
_getPinnedRows: (visiblePinnedRows: Array<Row<TData>>, pinnedRowIds: Array<string> | undefined, position: 'top' | 'bottom') => Row<TData>[];
|
|
61
61
|
/**
|
|
62
62
|
* Returns all bottom pinned rows.
|
|
63
63
|
* @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getbottomrows)
|
|
@@ -89,13 +89,13 @@ const RowPinning = {
|
|
|
89
89
|
return isTop ? 'top' : isBottom ? 'bottom' : false;
|
|
90
90
|
};
|
|
91
91
|
row.getPinnedIndex = () => {
|
|
92
|
-
var
|
|
92
|
+
var _ref4, _visiblePinnedRowIds$;
|
|
93
93
|
const position = row.getIsPinned();
|
|
94
94
|
if (!position) return -1;
|
|
95
|
-
const visiblePinnedRowIds = (
|
|
95
|
+
const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
|
|
96
96
|
let {
|
|
97
97
|
id
|
|
98
|
-
} =
|
|
98
|
+
} = _ref5;
|
|
99
99
|
return id;
|
|
100
100
|
});
|
|
101
101
|
return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
|
|
@@ -116,7 +116,7 @@ const RowPinning = {
|
|
|
116
116
|
}
|
|
117
117
|
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
118
118
|
};
|
|
119
|
-
table._getPinnedRows =
|
|
119
|
+
table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
|
|
120
120
|
var _table$options$keepPi;
|
|
121
121
|
const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
|
|
122
122
|
//get all rows that are pinned even if they would not be otherwise visible
|
|
@@ -131,9 +131,9 @@ const RowPinning = {
|
|
|
131
131
|
...d,
|
|
132
132
|
position
|
|
133
133
|
}));
|
|
134
|
-
}
|
|
135
|
-
table.getTopRows = () => table._getPinnedRows('top');
|
|
136
|
-
table.getBottomRows = () => table._getPinnedRows('bottom');
|
|
134
|
+
};
|
|
135
|
+
table.getTopRows = utils.memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), utils.getMemoOptions(table.options, 'debugRows', 'getTopRows'));
|
|
136
|
+
table.getBottomRows = utils.memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), utils.getMemoOptions(table.options, 'debugRows', 'getBottomRows'));
|
|
137
137
|
table.getCenterRows = utils.memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
|
|
138
138
|
const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
|
|
139
139
|
return allRows.filter(d => !topAndBottom.has(d.id));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowPinning.js","sources":["../../../src/features/RowPinning.ts"],"sourcesContent":["import {\n OnChangeFn,\n Updater,\n Table,\n Row,\n RowData,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nexport type RowPinningPosition = false | 'top' | 'bottom'\n\nexport interface RowPinningState {\n bottom?: string[]\n top?: string[]\n}\n\nexport interface RowPinningTableState {\n rowPinning: RowPinningState\n}\n\nexport interface RowPinningOptions<TData extends RowData> {\n /**\n * Enables/disables row pinning for the table. Defaults to `true`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#enablerowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n enableRowPinning?: boolean | ((row: Row<TData>) => boolean)\n /**\n * When `false`, pinned rows will not be visible if they are filtered or paginated out of the table. When `true`, pinned rows will always be visible regardless of filtering or pagination. Defaults to `true`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#keeppinnedrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n keepPinnedRows?: boolean\n /**\n * If provided, this function will be called with an `updaterFn` when `state.rowPinning` changes. This overrides the default internal state management, so you will also need to supply `state.rowPinning` from your own managed state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#onrowpinningchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/onrowpinningchange)\n */\n onRowPinningChange?: OnChangeFn<RowPinningState>\n}\n\nexport interface RowPinningDefaultOptions {\n onRowPinningChange: OnChangeFn<RowPinningState>\n}\n\nexport interface RowPinningRow {\n /**\n * Returns whether or not the row can be pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcanpin-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getCanPin: () => boolean\n /**\n * Returns the pinned position of the row. (`'top'`, `'bottom'` or `false`)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getispinned-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getIsPinned: () => RowPinningPosition\n /**\n * Returns the numeric pinned index of the row within a pinned row group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getpinnedindex-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getPinnedIndex: () => number\n /**\n * Pins a row to the `'top'` or `'bottom'`, or unpins the row to the center if `false` is passed.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#pin-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n pin: (\n position: RowPinningPosition,\n includeLeafRows?: boolean,\n includeParentRows?: boolean\n ) => void\n}\n\nexport interface RowPinningInstance<TData extends RowData> {\n _getPinnedRows: (position: 'top' | 'bottom') => Row<TData>[]\n /**\n * Returns all bottom pinned rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getbottomrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getBottomRows: () => Row<TData>[]\n /**\n * Returns all rows that are not pinned to the top or bottom.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcenterrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getCenterRows: () => Row<TData>[]\n /**\n * Returns whether or not any rows are pinned. Optionally specify to only check for pinned rows in either the `top` or `bottom` position.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getissomerowspinned)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean\n /**\n * Returns all top pinned rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#gettoprows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getTopRows: () => Row<TData>[]\n /**\n * Resets the **rowPinning** state to `initialState.rowPinning`, or `true` can be passed to force a default blank state reset to `{ top: [], bottom: [], }`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#resetrowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n resetRowPinning: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.rowPinning` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#setrowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n setRowPinning: (updater: Updater<RowPinningState>) => void\n}\n\n//\n\nconst getDefaultRowPinningState = (): RowPinningState => ({\n top: [],\n bottom: [],\n})\n\nexport const RowPinning: TableFeature = {\n getInitialState: (state): RowPinningTableState => {\n return {\n rowPinning: getDefaultRowPinningState(),\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): RowPinningDefaultOptions => {\n return {\n onRowPinningChange: makeStateUpdater('rowPinning', table),\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.pin = (position, includeLeafRows, includeParentRows) => {\n const leafRowIds = includeLeafRows\n ? row.getLeafRows().map(({ id }) => id)\n : []\n const parentRowIds = includeParentRows\n ? row.getParentRows().map(({ id }) => id)\n : []\n const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds])\n\n table.setRowPinning(old => {\n if (position === 'bottom') {\n return {\n top: (old?.top ?? []).filter(d => !rowIds?.has(d)),\n bottom: [\n ...(old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n ...Array.from(rowIds),\n ],\n }\n }\n\n if (position === 'top') {\n return {\n top: [\n ...(old?.top ?? []).filter(d => !rowIds?.has(d)),\n ...Array.from(rowIds),\n ],\n bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n }\n }\n\n return {\n top: (old?.top ?? []).filter(d => !rowIds?.has(d)),\n bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n }\n })\n }\n row.getCanPin = () => {\n const { enableRowPinning, enablePinning } = table.options\n if (typeof enableRowPinning === 'function') {\n return enableRowPinning(row)\n }\n return enableRowPinning ?? enablePinning ?? true\n }\n row.getIsPinned = () => {\n const rowIds = [row.id]\n\n const { top, bottom } = table.getState().rowPinning\n\n const isTop = rowIds.some(d => top?.includes(d))\n const isBottom = rowIds.some(d => bottom?.includes(d))\n\n return isTop ? 'top' : isBottom ? 'bottom' : false\n }\n row.getPinnedIndex = () => {\n const position = row.getIsPinned()\n if (!position) return -1\n\n const visiblePinnedRowIds = table\n ._getPinnedRows(position)\n ?.map(({ id }) => id)\n\n return visiblePinnedRowIds?.indexOf(row.id) ?? -1\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setRowPinning = updater => table.options.onRowPinningChange?.(updater)\n\n table.resetRowPinning = defaultState =>\n table.setRowPinning(\n defaultState\n ? getDefaultRowPinningState()\n : table.initialState?.rowPinning ?? getDefaultRowPinningState()\n )\n\n table.getIsSomeRowsPinned = position => {\n const pinningState = table.getState().rowPinning\n\n if (!position) {\n return Boolean(pinningState.top?.length || pinningState.bottom?.length)\n }\n return Boolean(pinningState[position]?.length)\n }\n\n table._getPinnedRows = memo(\n position => [\n table.getRowModel().rows,\n table.getState().rowPinning[position!],\n position,\n ],\n (visibleRows, pinnedRowIds, position) => {\n const rows =\n table.options.keepPinnedRows ?? true\n ? //get all rows that are pinned even if they would not be otherwise visible\n //account for expanded parent rows, but not pagination or filtering\n (pinnedRowIds ?? []).map(rowId => {\n const row = table.getRow(rowId, true)\n return row.getIsAllParentsExpanded() ? row : null\n })\n : //else get only visible rows that are pinned\n (pinnedRowIds ?? []).map(\n rowId => visibleRows.find(row => row.id === rowId)!\n )\n\n return rows\n .filter(Boolean)\n .map(d => ({ ...d, position })) as Row<TData>[]\n },\n getMemoOptions(table.options, 'debugRows', '_getPinnedRows')\n )\n\n table.getTopRows = () => table._getPinnedRows('top')\n\n table.getBottomRows = () => table._getPinnedRows('bottom')\n\n table.getCenterRows = memo(\n () => [\n table.getRowModel().rows,\n table.getState().rowPinning.top,\n table.getState().rowPinning.bottom,\n ],\n (allRows, top, bottom) => {\n const topAndBottom = new Set([...(top ?? []), ...(bottom ?? [])])\n return allRows.filter(d => !topAndBottom.has(d.id))\n },\n getMemoOptions(table.options, 'debugRows', 'getCenterRows')\n )\n },\n}\n"],"names":["getDefaultRowPinningState","top","bottom","RowPinning","getInitialState","state","rowPinning","getDefaultOptions","table","onRowPinningChange","makeStateUpdater","createRow","row","pin","position","includeLeafRows","includeParentRows","leafRowIds","getLeafRows","map","_ref","id","parentRowIds","getParentRows","_ref2","rowIds","Set","setRowPinning","old","_old$top3","_old$bottom3","_old$top","_old$bottom","filter","d","has","Array","from","_old$top2","_old$bottom2","getCanPin","_ref3","enableRowPinning","enablePinning","options","getIsPinned","getState","isTop","some","includes","isBottom","getPinnedIndex","_table$_getPinnedRows","_visiblePinnedRowIds$","visiblePinnedRowIds","_getPinnedRows","_ref4","indexOf","createTable","updater","resetRowPinning","defaultState","_table$initialState$r","_table$initialState","initialState","getIsSomeRowsPinned","_pinningState$positio","pinningState","_pinningState$top","_pinningState$bottom","Boolean","length","memo","getRowModel","rows","visibleRows","pinnedRowIds","_table$options$keepPi","keepPinnedRows","rowId","getRow","getIsAllParentsExpanded","find","getMemoOptions","getTopRows","getBottomRows","getCenterRows","allRows","topAndBottom"],"mappings":";;;;;;;;;;;;;;AAqHA;;AAEA,MAAMA,yBAAyB,GAAGA,OAAwB;AACxDC,EAAAA,GAAG,EAAE,EAAE;AACPC,EAAAA,MAAM,EAAE,EAAA;AACV,CAAC,CAAC,CAAA;AAEK,MAAMC,UAAwB,GAAG;EACtCC,eAAe,EAAGC,KAAK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AC,CAAA;IAEpD/C,KAAK,CAAC6E,aAAa,GAAG,MAAM7E,KAAK,CAAC+C,cAAc,CAAC,QAAQ,CAAC,CAAA;AAE1D/C,IAAAA,KAAK,CAAC8E,aAAa,GAAGd,UAAI,CACxB,MAAM,CACJhE,KAAK,CAACiE,WAAW,EAAE,CAACC,IAAI,EACxBlE,KAAK,CAACsC,QAAQ,EAAE,CAACxC,UAAU,CAACL,GAAG,EAC/BO,KAAK,CAACsC,QAAQ,EAAE,CAACxC,UAAU,CAACJ,MAAM,CACnC,EACD,CAACqF,OAAO,EAAEtF,GAAG,EAAEC,MAAM,KAAK;MACxB,MAAMsF,YAAY,GAAG,IAAI9D,GAAG,CAAC,CAAC,IAAIzB,GAAG,IAAA,IAAA,GAAHA,GAAG,GAAI,EAAE,GAAG,IAAIC,MAAM,IAAA,IAAA,GAANA,MAAM,GAAI,EAAE,EAAE,CAAC,CAAA;AACjE,MAAA,OAAOqF,OAAO,CAACtD,MAAM,CAACC,CAAC,IAAI,CAACsD,YAAY,CAACrD,GAAG,CAACD,CAAC,CAACb,EAAE,CAAC,CAAC,CAAA;KACpD,EACD8D,oBAAc,CAAC3E,KAAK,CAACoC,OAAO,EAAE,WAAW,EAAE,eAAe,CAC5D,CAAC,CAAA;AACH,GAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"RowPinning.js","sources":["../../../src/features/RowPinning.ts"],"sourcesContent":["import {\n OnChangeFn,\n Updater,\n Table,\n Row,\n RowData,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nexport type RowPinningPosition = false | 'top' | 'bottom'\n\nexport interface RowPinningState {\n bottom?: string[]\n top?: string[]\n}\n\nexport interface RowPinningTableState {\n rowPinning: RowPinningState\n}\n\nexport interface RowPinningOptions<TData extends RowData> {\n /**\n * Enables/disables row pinning for the table. Defaults to `true`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#enablerowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n enableRowPinning?: boolean | ((row: Row<TData>) => boolean)\n /**\n * When `false`, pinned rows will not be visible if they are filtered or paginated out of the table. When `true`, pinned rows will always be visible regardless of filtering or pagination. Defaults to `true`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#keeppinnedrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n keepPinnedRows?: boolean\n /**\n * If provided, this function will be called with an `updaterFn` when `state.rowPinning` changes. This overrides the default internal state management, so you will also need to supply `state.rowPinning` from your own managed state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#onrowpinningchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/onrowpinningchange)\n */\n onRowPinningChange?: OnChangeFn<RowPinningState>\n}\n\nexport interface RowPinningDefaultOptions {\n onRowPinningChange: OnChangeFn<RowPinningState>\n}\n\nexport interface RowPinningRow {\n /**\n * Returns whether or not the row can be pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcanpin-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getCanPin: () => boolean\n /**\n * Returns the pinned position of the row. (`'top'`, `'bottom'` or `false`)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getispinned-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getIsPinned: () => RowPinningPosition\n /**\n * Returns the numeric pinned index of the row within a pinned row group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getpinnedindex-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getPinnedIndex: () => number\n /**\n * Pins a row to the `'top'` or `'bottom'`, or unpins the row to the center if `false` is passed.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#pin-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n pin: (\n position: RowPinningPosition,\n includeLeafRows?: boolean,\n includeParentRows?: boolean\n ) => void\n}\n\nexport interface RowPinningInstance<TData extends RowData> {\n _getPinnedRows: (\n visiblePinnedRows: Array<Row<TData>>,\n pinnedRowIds: Array<string> | undefined,\n position: 'top' | 'bottom'\n ) => Row<TData>[]\n /**\n * Returns all bottom pinned rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getbottomrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getBottomRows: () => Row<TData>[]\n /**\n * Returns all rows that are not pinned to the top or bottom.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcenterrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getCenterRows: () => Row<TData>[]\n /**\n * Returns whether or not any rows are pinned. Optionally specify to only check for pinned rows in either the `top` or `bottom` position.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getissomerowspinned)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean\n /**\n * Returns all top pinned rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#gettoprows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getTopRows: () => Row<TData>[]\n /**\n * Resets the **rowPinning** state to `initialState.rowPinning`, or `true` can be passed to force a default blank state reset to `{ top: [], bottom: [], }`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#resetrowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n resetRowPinning: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.rowPinning` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#setrowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n setRowPinning: (updater: Updater<RowPinningState>) => void\n}\n\n//\n\nconst getDefaultRowPinningState = (): RowPinningState => ({\n top: [],\n bottom: [],\n})\n\nexport const RowPinning: TableFeature = {\n getInitialState: (state): RowPinningTableState => {\n return {\n rowPinning: getDefaultRowPinningState(),\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): RowPinningDefaultOptions => {\n return {\n onRowPinningChange: makeStateUpdater('rowPinning', table),\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.pin = (position, includeLeafRows, includeParentRows) => {\n const leafRowIds = includeLeafRows\n ? row.getLeafRows().map(({ id }) => id)\n : []\n const parentRowIds = includeParentRows\n ? row.getParentRows().map(({ id }) => id)\n : []\n const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds])\n\n table.setRowPinning(old => {\n if (position === 'bottom') {\n return {\n top: (old?.top ?? []).filter(d => !rowIds?.has(d)),\n bottom: [\n ...(old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n ...Array.from(rowIds),\n ],\n }\n }\n\n if (position === 'top') {\n return {\n top: [\n ...(old?.top ?? []).filter(d => !rowIds?.has(d)),\n ...Array.from(rowIds),\n ],\n bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n }\n }\n\n return {\n top: (old?.top ?? []).filter(d => !rowIds?.has(d)),\n bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n }\n })\n }\n row.getCanPin = () => {\n const { enableRowPinning, enablePinning } = table.options\n if (typeof enableRowPinning === 'function') {\n return enableRowPinning(row)\n }\n return enableRowPinning ?? enablePinning ?? true\n }\n row.getIsPinned = () => {\n const rowIds = [row.id]\n\n const { top, bottom } = table.getState().rowPinning\n\n const isTop = rowIds.some(d => top?.includes(d))\n const isBottom = rowIds.some(d => bottom?.includes(d))\n\n return isTop ? 'top' : isBottom ? 'bottom' : false\n }\n row.getPinnedIndex = () => {\n const position = row.getIsPinned()\n if (!position) return -1\n\n const visiblePinnedRowIds = (\n position === 'top' ? table.getTopRows() : table.getBottomRows()\n )?.map(({ id }) => id)\n\n return visiblePinnedRowIds?.indexOf(row.id) ?? -1\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setRowPinning = updater => table.options.onRowPinningChange?.(updater)\n\n table.resetRowPinning = defaultState =>\n table.setRowPinning(\n defaultState\n ? getDefaultRowPinningState()\n : table.initialState?.rowPinning ?? getDefaultRowPinningState()\n )\n\n table.getIsSomeRowsPinned = position => {\n const pinningState = table.getState().rowPinning\n\n if (!position) {\n return Boolean(pinningState.top?.length || pinningState.bottom?.length)\n }\n return Boolean(pinningState[position]?.length)\n }\n\n table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {\n const rows =\n table.options.keepPinnedRows ?? true\n ? //get all rows that are pinned even if they would not be otherwise visible\n //account for expanded parent rows, but not pagination or filtering\n (pinnedRowIds ?? []).map(rowId => {\n const row = table.getRow(rowId, true)\n return row.getIsAllParentsExpanded() ? row : null\n })\n : //else get only visible rows that are pinned\n (pinnedRowIds ?? []).map(\n rowId => visibleRows.find(row => row.id === rowId)!\n )\n\n return rows.filter(Boolean).map(d => ({ ...d, position })) as Row<TData>[]\n }\n\n table.getTopRows = memo(\n () => [table.getRowModel().rows, table.getState().rowPinning.top],\n (allRows, topPinnedRowIds) =>\n table._getPinnedRows(allRows, topPinnedRowIds, 'top'),\n getMemoOptions(table.options, 'debugRows', 'getTopRows')\n )\n\n table.getBottomRows = memo(\n () => [table.getRowModel().rows, table.getState().rowPinning.bottom],\n (allRows, bottomPinnedRowIds) =>\n table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'),\n getMemoOptions(table.options, 'debugRows', 'getBottomRows')\n )\n\n table.getCenterRows = memo(\n () => [\n table.getRowModel().rows,\n table.getState().rowPinning.top,\n table.getState().rowPinning.bottom,\n ],\n (allRows, top, bottom) => {\n const topAndBottom = new Set([...(top ?? []), ...(bottom ?? [])])\n return allRows.filter(d => !topAndBottom.has(d.id))\n },\n getMemoOptions(table.options, 'debugRows', 'getCenterRows')\n )\n },\n}\n"],"names":["getDefaultRowPinningState","top","bottom","RowPinning","getInitialState","state","rowPinning","getDefaultOptions","table","onRowPinningChange","makeStateUpdater","createRow","row","pin","position","includeLeafRows","includeParentRows","leafRowIds","getLeafRows","map","_ref","id","parentRowIds","getParentRows","_ref2","rowIds","Set","setRowPinning","old","_old$top3","_old$bottom3","_old$top","_old$bottom","filter","d","has","Array","from","_old$top2","_old$bottom2","getCanPin","_ref3","enableRowPinning","enablePinning","options","getIsPinned","getState","isTop","some","includes","isBottom","getPinnedIndex","_ref4","_visiblePinnedRowIds$","visiblePinnedRowIds","getTopRows","getBottomRows","_ref5","indexOf","createTable","updater","resetRowPinning","defaultState","_table$initialState$r","_table$initialState","initialState","getIsSomeRowsPinned","_pinningState$positio","pinningState","_pinningState$top","_pinningState$bottom","Boolean","length","_getPinnedRows","visibleRows","pinnedRowIds","_table$options$keepPi","rows","keepPinnedRows","rowId","getRow","getIsAllParentsExpanded","find","memo","getRowModel","allRows","topPinnedRowIds","getMemoOptions","bottomPinnedRowIds","getCenterRows","topAndBottom"],"mappings":";;;;;;;;;;;;;;AAyHA;;AAEA,MAAMA,yBAAyB,GAAGA,OAAwB;AACxDC,EAAAA,GAAG,EAAE,EAAE;AACPC,EAAAA,MAAM,EAAE,EAAA;AACV,CAAC,CAAC,CAAA;AAEK,MAAMC,UAAwB,GAAG;EACtCC,eAAe,EAAGC,KAAK,IAA2B;IAChD,OAAO;MACLC,UAAU,EAAEN,yBAAyB,EAAE;MACvC,GAAGK,KAAAA;KACJ,CAAA;GACF;EAEDE,iBAAiB,EACfC,KAAmB,IACU;IAC7B,OAAO;AACLC,MAAAA,kBAAkB,EAAEC,sBAAgB,CAAC,YAAY,EAAEF,KAAK,CAAA;KACzD,CAAA;GACF;AAEDG,EAAAA,SAAS,EAAEA,CACTC,GAAe,EACfJ,KAAmB,KACV;IACTI,GAAG,CAACC,GAAG,GAAG,CAACC,QAAQ,EAAEC,eAAe,EAAEC,iBAAiB,KAAK;AA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E,eAAe,CAC5D,CAAC,CAAA;AAEDpC,IAAAA,KAAK,CAACiF,aAAa,GAAGN,UAAI,CACxB,MAAM,CACJ3E,KAAK,CAAC4E,WAAW,EAAE,CAACP,IAAI,EACxBrE,KAAK,CAACsC,QAAQ,EAAE,CAACxC,UAAU,CAACL,GAAG,EAC/BO,KAAK,CAACsC,QAAQ,EAAE,CAACxC,UAAU,CAACJ,MAAM,CACnC,EACD,CAACmF,OAAO,EAAEpF,GAAG,EAAEC,MAAM,KAAK;MACxB,MAAMwF,YAAY,GAAG,IAAIhE,GAAG,CAAC,CAAC,IAAIzB,GAAG,IAAA,IAAA,GAAHA,GAAG,GAAI,EAAE,GAAG,IAAIC,MAAM,IAAA,IAAA,GAANA,MAAM,GAAI,EAAE,EAAE,CAAC,CAAA;AACjE,MAAA,OAAOmF,OAAO,CAACpD,MAAM,CAACC,CAAC,IAAI,CAACwD,YAAY,CAACvD,GAAG,CAACD,CAAC,CAACb,EAAE,CAAC,CAAC,CAAA;KACpD,EACDkE,oBAAc,CAAC/E,KAAK,CAACoC,OAAO,EAAE,WAAW,EAAE,eAAe,CAC5D,CAAC,CAAA;AACH,GAAA;AACF;;;;"}
|
package/build/lib/index.esm.js
CHANGED
|
@@ -2003,13 +2003,13 @@ const RowPinning = {
|
|
|
2003
2003
|
return isTop ? 'top' : isBottom ? 'bottom' : false;
|
|
2004
2004
|
};
|
|
2005
2005
|
row.getPinnedIndex = () => {
|
|
2006
|
-
var
|
|
2006
|
+
var _ref4, _visiblePinnedRowIds$;
|
|
2007
2007
|
const position = row.getIsPinned();
|
|
2008
2008
|
if (!position) return -1;
|
|
2009
|
-
const visiblePinnedRowIds = (
|
|
2009
|
+
const visiblePinnedRowIds = (_ref4 = position === 'top' ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _ref4.map(_ref5 => {
|
|
2010
2010
|
let {
|
|
2011
2011
|
id
|
|
2012
|
-
} =
|
|
2012
|
+
} = _ref5;
|
|
2013
2013
|
return id;
|
|
2014
2014
|
});
|
|
2015
2015
|
return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
|
|
@@ -2030,7 +2030,7 @@ const RowPinning = {
|
|
|
2030
2030
|
}
|
|
2031
2031
|
return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
|
|
2032
2032
|
};
|
|
2033
|
-
table._getPinnedRows =
|
|
2033
|
+
table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
|
|
2034
2034
|
var _table$options$keepPi;
|
|
2035
2035
|
const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
|
|
2036
2036
|
//get all rows that are pinned even if they would not be otherwise visible
|
|
@@ -2045,9 +2045,9 @@ const RowPinning = {
|
|
|
2045
2045
|
...d,
|
|
2046
2046
|
position
|
|
2047
2047
|
}));
|
|
2048
|
-
}
|
|
2049
|
-
table.getTopRows = () => table._getPinnedRows('top');
|
|
2050
|
-
table.getBottomRows = () => table._getPinnedRows('bottom');
|
|
2048
|
+
};
|
|
2049
|
+
table.getTopRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top], (allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, 'top'), getMemoOptions(table.options, 'debugRows', 'getTopRows'));
|
|
2050
|
+
table.getBottomRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.bottom], (allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'), getMemoOptions(table.options, 'debugRows', 'getBottomRows'));
|
|
2051
2051
|
table.getCenterRows = memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
|
|
2052
2052
|
const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
|
|
2053
2053
|
return allRows.filter(d => !topAndBottom.has(d.id));
|
|
@@ -3259,6 +3259,10 @@ function getFilteredRowModel() {
|
|
|
3259
3259
|
function getGroupedRowModel() {
|
|
3260
3260
|
return table => memo(() => [table.getState().grouping, table.getPreGroupedRowModel()], (grouping, rowModel) => {
|
|
3261
3261
|
if (!rowModel.rows.length || !grouping.length) {
|
|
3262
|
+
rowModel.rows.forEach(row => {
|
|
3263
|
+
row.depth = 0;
|
|
3264
|
+
row.parentId = undefined;
|
|
3265
|
+
});
|
|
3262
3266
|
return rowModel;
|
|
3263
3267
|
}
|
|
3264
3268
|
|
|
@@ -3294,7 +3298,7 @@ function getGroupedRowModel() {
|
|
|
3294
3298
|
// Group the rows together for this level
|
|
3295
3299
|
const rowGroupsMap = groupBy(rows, columnId);
|
|
3296
3300
|
|
|
3297
|
-
//
|
|
3301
|
+
// Perform aggregations for each group
|
|
3298
3302
|
const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map((_ref, index) => {
|
|
3299
3303
|
let [groupingValue, groupedRows] = _ref;
|
|
3300
3304
|
let id = `${columnId}:${groupingValue}`;
|
|
@@ -3302,6 +3306,9 @@ function getGroupedRowModel() {
|
|
|
3302
3306
|
|
|
3303
3307
|
// First, Recurse to group sub rows before aggregation
|
|
3304
3308
|
const subRows = groupUpRecursively(groupedRows, depth + 1, id);
|
|
3309
|
+
subRows.forEach(subRow => {
|
|
3310
|
+
subRow.parentId = id;
|
|
3311
|
+
});
|
|
3305
3312
|
|
|
3306
3313
|
// Flatten the leaf rows of the rows in this group
|
|
3307
3314
|
const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
|