@tanstack/table-core 8.5.9 → 8.5.12
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/cjs/core/cell.js +6 -1
- package/build/cjs/core/cell.js.map +1 -1
- package/build/cjs/utils/getExpandedRowModel.js +0 -1
- package/build/cjs/utils/getExpandedRowModel.js.map +1 -1
- package/build/cjs/utils/getPaginationRowModel.js +0 -1
- package/build/cjs/utils/getPaginationRowModel.js.map +1 -1
- package/build/esm/index.js +4 -3
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +17 -17
- package/build/stats-react.json +323 -316
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +4 -3
- 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/core/cell.ts +16 -9
- package/src/types.ts +1 -1
- package/src/utils/getExpandedRowModel.ts +0 -1
- package/src/utils/getPaginationRowModel.ts +0 -2
package/build/cjs/core/cell.js
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
14
|
|
|
15
|
+
var utils = require('../utils.js');
|
|
16
|
+
|
|
15
17
|
function createCell(table, row, column, columnId) {
|
|
16
18
|
const getRenderValue = () => {
|
|
17
19
|
var _cell$getValue;
|
|
@@ -25,13 +27,16 @@ function createCell(table, row, column, columnId) {
|
|
|
25
27
|
column,
|
|
26
28
|
getValue: () => row.getValue(columnId),
|
|
27
29
|
renderValue: getRenderValue,
|
|
28
|
-
getContext: () => ({
|
|
30
|
+
getContext: utils.memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
29
31
|
table,
|
|
30
32
|
column,
|
|
31
33
|
row,
|
|
32
34
|
cell: cell,
|
|
33
35
|
getValue: cell.getValue,
|
|
34
36
|
renderValue: cell.renderValue
|
|
37
|
+
}), {
|
|
38
|
+
key: process.env.NODE_ENV === 'development' && 'cell.getContext',
|
|
39
|
+
debug: () => table.options.debugAll
|
|
35
40
|
})
|
|
36
41
|
};
|
|
37
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell.js","sources":["../../../src/core/cell.ts"],"sourcesContent":["import { RowData, Cell, Column, Row, Table } from '../types'\nimport { Getter } from '../utils'\n\nexport type CellContext<TData extends RowData, TValue> = {\n table: Table<TData>\n column: Column<TData, TValue>\n row: Row<TData>\n cell: Cell<TData, TValue>\n getValue: Getter<TValue>\n renderValue: Getter<TValue | null>\n}\n\nexport type CoreCell<TData extends RowData, TValue> = {\n id: string\n getValue: CellContext<TData, TValue>['getValue']\n renderValue: CellContext<TData, TValue>['renderValue']\n row: Row<TData>\n column: Column<TData, TValue>\n getContext: () => CellContext<TData, TValue>\n}\n\nexport function createCell<TData extends RowData, TValue>(\n table: Table<TData>,\n row: Row<TData>,\n column: Column<TData, TValue>,\n columnId: string\n) {\n const getRenderValue = () =>\n cell.getValue() ?? table.options.renderFallbackValue\n\n const cell: CoreCell<TData, TValue> = {\n id: `${row.id}_${column.id}`,\n row,\n column,\n getValue: () => row.getValue(columnId),\n renderValue: getRenderValue,\n getContext: () => ({\n
|
|
1
|
+
{"version":3,"file":"cell.js","sources":["../../../src/core/cell.ts"],"sourcesContent":["import { RowData, Cell, Column, Row, Table } from '../types'\nimport { Getter, memo } from '../utils'\n\nexport type CellContext<TData extends RowData, TValue> = {\n table: Table<TData>\n column: Column<TData, TValue>\n row: Row<TData>\n cell: Cell<TData, TValue>\n getValue: Getter<TValue>\n renderValue: Getter<TValue | null>\n}\n\nexport type CoreCell<TData extends RowData, TValue> = {\n id: string\n getValue: CellContext<TData, TValue>['getValue']\n renderValue: CellContext<TData, TValue>['renderValue']\n row: Row<TData>\n column: Column<TData, TValue>\n getContext: () => CellContext<TData, TValue>\n}\n\nexport function createCell<TData extends RowData, TValue>(\n table: Table<TData>,\n row: Row<TData>,\n column: Column<TData, TValue>,\n columnId: string\n) {\n const getRenderValue = () =>\n cell.getValue() ?? table.options.renderFallbackValue\n\n const cell: CoreCell<TData, TValue> = {\n id: `${row.id}_${column.id}`,\n row,\n column,\n getValue: () => row.getValue(columnId),\n renderValue: getRenderValue,\n getContext: memo(\n () => [table, column, row, cell],\n (table, column, row, cell) => ({\n table,\n column,\n row,\n cell: cell as Cell<TData, TValue>,\n getValue: cell.getValue,\n renderValue: cell.renderValue,\n }),\n {\n key: process.env.NODE_ENV === 'development' && 'cell.getContext',\n debug: () => table.options.debugAll,\n }\n ),\n }\n\n table._features.forEach(feature => {\n Object.assign(\n cell,\n feature.createCell?.(\n cell as Cell<TData, TValue>,\n column,\n row as Row<TData>,\n table\n )\n )\n }, {})\n\n return cell as Cell<TData, TValue>\n}\n"],"names":["createCell","table","row","column","columnId","getRenderValue","cell","getValue","options","renderFallbackValue","id","renderValue","getContext","memo","key","process","env","NODE_ENV","debug","debugAll","_features","forEach","feature","Object","assign"],"mappings":";;;;;;;;;;;;;;;;AAqBO,SAASA,UAAT,CACLC,KADK,EAELC,GAFK,EAGLC,MAHK,EAILC,QAJK,EAKL;AACA,EAAA,MAAMC,cAAc,GAAG,MAAA;AAAA,IAAA,IAAA,cAAA,CAAA;;IAAA,OACrBC,CAAAA,cAAAA,GAAAA,IAAI,CAACC,QAAL,EADqB,6BACFN,KAAK,CAACO,OAAN,CAAcC,mBADZ,CAAA;GAAvB,CAAA;;AAGA,EAAA,MAAMH,IAA6B,GAAG;AACpCI,IAAAA,EAAE,EAAKR,GAAG,CAACQ,EAAT,GAAeP,GAAAA,GAAAA,MAAM,CAACO,EADY;IAEpCR,GAFoC;IAGpCC,MAHoC;AAIpCI,IAAAA,QAAQ,EAAE,MAAML,GAAG,CAACK,QAAJ,CAAaH,QAAb,CAJoB;AAKpCO,IAAAA,WAAW,EAAEN,cALuB;IAMpCO,UAAU,EAAEC,UAAI,CACd,MAAM,CAACZ,KAAD,EAAQE,MAAR,EAAgBD,GAAhB,EAAqBI,IAArB,CADQ,EAEd,CAACL,KAAD,EAAQE,MAAR,EAAgBD,GAAhB,EAAqBI,IAArB,MAA+B;MAC7BL,KAD6B;MAE7BE,MAF6B;MAG7BD,GAH6B;AAI7BI,MAAAA,IAAI,EAAEA,IAJuB;MAK7BC,QAAQ,EAAED,IAAI,CAACC,QALc;MAM7BI,WAAW,EAAEL,IAAI,CAACK,WAAAA;AANW,KAA/B,CAFc,EAUd;MACEG,GAAG,EAAEC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,aAAzB,IAA0C,iBADjD;AAEEC,MAAAA,KAAK,EAAE,MAAMjB,KAAK,CAACO,OAAN,CAAcW,QAAAA;KAZf,CAAA;GANlB,CAAA;;AAuBAlB,EAAAA,KAAK,CAACmB,SAAN,CAAgBC,OAAhB,CAAwBC,OAAO,IAAI;IACjCC,MAAM,CAACC,MAAP,CACElB,IADF,EAEEgB,OAAO,CAACtB,UAFV,IAEEsB,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACtB,UAAR,CACEM,IADF,EAEEH,MAFF,EAGED,GAHF,EAIED,KAJF,CAFF,CAAA,CAAA;AASD,GAVD,EAUG,EAVH,CAAA,CAAA;;AAYA,EAAA,OAAOK,IAAP,CAAA;AACD;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExpandedRowModel.js","sources":["../../../src/utils/getExpandedRowModel.ts"],"sourcesContent":["import { Table, Row, RowModel, RowData } from '../types'\nimport { memo } from '../utils'\n\nexport function getExpandedRowModel<TData extends RowData>(): (\n table: Table<TData>\n) => () => RowModel<TData> {\n return table =>\n memo(\n () => [\n table.getState().expanded,\n table.getPreExpandedRowModel(),\n table.options.paginateExpandedRows,\n ],\n (expanded, rowModel, paginateExpandedRows) => {\n if (\n !rowModel.rows.length ||\n (expanded !== true && !Object.keys(expanded ?? {}).length)\n ) {\n return rowModel\n }\n\n if (!paginateExpandedRows) {\n // Only expand rows at this point if they are being paginated\n
|
|
1
|
+
{"version":3,"file":"getExpandedRowModel.js","sources":["../../../src/utils/getExpandedRowModel.ts"],"sourcesContent":["import { Table, Row, RowModel, RowData } from '../types'\nimport { memo } from '../utils'\n\nexport function getExpandedRowModel<TData extends RowData>(): (\n table: Table<TData>\n) => () => RowModel<TData> {\n return table =>\n memo(\n () => [\n table.getState().expanded,\n table.getPreExpandedRowModel(),\n table.options.paginateExpandedRows,\n ],\n (expanded, rowModel, paginateExpandedRows) => {\n if (\n !rowModel.rows.length ||\n (expanded !== true && !Object.keys(expanded ?? {}).length)\n ) {\n return rowModel\n }\n\n if (!paginateExpandedRows) {\n // Only expand rows at this point if they are being paginated\n return rowModel\n }\n\n return expandRows(rowModel)\n },\n {\n key: process.env.NODE_ENV === 'development' && 'getExpandedRowModel',\n debug: () => table.options.debugAll ?? table.options.debugTable,\n }\n )\n}\n\nexport function expandRows<TData extends RowData>(rowModel: RowModel<TData>) {\n const expandedRows: Row<TData>[] = []\n\n const handleRow = (row: Row<TData>) => {\n expandedRows.push(row)\n\n if (row.subRows?.length && row.getIsExpanded()) {\n row.subRows.forEach(handleRow)\n }\n }\n\n rowModel.rows.forEach(handleRow)\n\n return {\n rows: expandedRows,\n flatRows: rowModel.flatRows,\n rowsById: rowModel.rowsById,\n }\n}\n"],"names":["getExpandedRowModel","table","memo","getState","expanded","getPreExpandedRowModel","options","paginateExpandedRows","rowModel","rows","length","Object","keys","expandRows","key","process","env","NODE_ENV","debug","debugAll","debugTable","expandedRows","handleRow","row","push","subRows","getIsExpanded","forEach","flatRows","rowsById"],"mappings":";;;;;;;;;;;;;;;;AAGO,SAASA,mBAAT,GAEoB;AACzB,EAAA,OAAOC,KAAK,IACVC,UAAI,CACF,MAAM,CACJD,KAAK,CAACE,QAAN,EAAA,CAAiBC,QADb,EAEJH,KAAK,CAACI,sBAAN,EAFI,EAGJJ,KAAK,CAACK,OAAN,CAAcC,oBAHV,CADJ,EAMF,CAACH,QAAD,EAAWI,QAAX,EAAqBD,oBAArB,KAA8C;IAC5C,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AELO,QAAQ,EAAEpB,QAAQ,CAACoB,QAFd;IAGLC,QAAQ,EAAErB,QAAQ,CAACqB,QAAAA;GAHrB,CAAA;AAKD;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPaginationRowModel.js","sources":["../../../src/utils/getPaginationRowModel.ts"],"sourcesContent":["import { Table, RowModel, Row, RowData } from '../types'\nimport { memo } from '../utils'\nimport { expandRows } from './getExpandedRowModel'\n\nexport function getPaginationRowModel<TData extends RowData>(opts?: {\n initialSync: boolean\n}): (table: Table<TData>) => () => RowModel<TData> {\n return table =>\n memo(\n () => [\n table.getState().pagination,\n table.getPrePaginationRowModel(),\n table.options.paginateExpandedRows\n ? undefined\n : table.getState().expanded,\n ],\n (pagination, rowModel) => {\n if (!rowModel.rows.length) {\n return rowModel\n }\n\n const { pageSize, pageIndex } = pagination\n let { rows, flatRows, rowsById } = rowModel\n const pageStart = pageSize * pageIndex\n const pageEnd = pageStart + pageSize\n\n rows = rows.slice(pageStart, pageEnd)\n\n let paginatedRowModel: RowModel<TData>\n\n if (!table.options.paginateExpandedRows) {\n paginatedRowModel = expandRows({\n rows,\n flatRows,\n rowsById,\n })\n } else {\n paginatedRowModel = {\n rows,\n flatRows,\n rowsById,\n }\n }\n\n
|
|
1
|
+
{"version":3,"file":"getPaginationRowModel.js","sources":["../../../src/utils/getPaginationRowModel.ts"],"sourcesContent":["import { Table, RowModel, Row, RowData } from '../types'\nimport { memo } from '../utils'\nimport { expandRows } from './getExpandedRowModel'\n\nexport function getPaginationRowModel<TData extends RowData>(opts?: {\n initialSync: boolean\n}): (table: Table<TData>) => () => RowModel<TData> {\n return table =>\n memo(\n () => [\n table.getState().pagination,\n table.getPrePaginationRowModel(),\n table.options.paginateExpandedRows\n ? undefined\n : table.getState().expanded,\n ],\n (pagination, rowModel) => {\n if (!rowModel.rows.length) {\n return rowModel\n }\n\n const { pageSize, pageIndex } = pagination\n let { rows, flatRows, rowsById } = rowModel\n const pageStart = pageSize * pageIndex\n const pageEnd = pageStart + pageSize\n\n rows = rows.slice(pageStart, pageEnd)\n\n let paginatedRowModel: RowModel<TData>\n\n if (!table.options.paginateExpandedRows) {\n paginatedRowModel = expandRows({\n rows,\n flatRows,\n rowsById,\n })\n } else {\n paginatedRowModel = {\n rows,\n flatRows,\n rowsById,\n }\n }\n\n paginatedRowModel.flatRows = []\n\n const handleRow = (row: Row<TData>) => {\n paginatedRowModel.flatRows.push(row)\n if (row.subRows.length) {\n row.subRows.forEach(handleRow)\n }\n }\n\n paginatedRowModel.rows.forEach(handleRow)\n\n return paginatedRowModel\n },\n {\n key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',\n debug: () => table.options.debugAll ?? table.options.debugTable,\n }\n )\n}\n"],"names":["getPaginationRowModel","opts","table","memo","getState","pagination","getPrePaginationRowModel","options","paginateExpandedRows","undefined","expanded","rowModel","rows","length","pageSize","pageIndex","flatRows","rowsById","pageStart","pageEnd","slice","paginatedRowModel","expandRows","handleRow","row","push","subRows","forEach","key","process","env","NODE_ENV","debug","debugAll","debugTable"],"mappings":";;;;;;;;;;;;;;;;;AAIO,SAASA,qBAAT,CAAsDC,IAAtD,EAE4C;AACjD,EAAA,OAAOC,KAAK,IACVC,UAAI,CACF,MAAM,CACJD,KAAK,CAACE,QAAN,EAAA,CAAiBC,UADb,EAEJH,KAAK,CAACI,wBAAN,EAFI,EAGJJ,KAAK,CAACK,OAAN,CAAcC,oBAAd,GACIC,SADJ,GAEIP,KAAK,CAACE,QAAN,EAAiBM,CAAAA,QALjB,CADJ,EAQF,CAACL,UAAD,EAAaM,QAAb,KAA0B;AACxB,IAAA,IAAI,CAACA,QAAQ,CAACC,IAAT,CAAcC,MAAnB,EAA2B;AACzB,MAAA,OAAOF,QAAP,CAAA;AACD,KAAA;;IAED,MAAM;MAAEG,QAAF;AAAYC,MAAAA,SAAAA;AAAZ,KAAA,GAA0BV,UAAhC,CAAA;IACA,IAAI;MAAEO,IAAF;MAAQI,QAAR;AAA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AAA,KAAK,CAACK,OAAN,CAAc0B,QAApB,oCAAgC/B,KAAK,CAACK,OAAN,CAAc2B,UAA9C,CAAA;AAAA,KAAA;AAFT,GAjDE,CADN,CAAA;AAuDD;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -3051,13 +3051,16 @@ function createCell(table, row, column, columnId) {
|
|
|
3051
3051
|
column,
|
|
3052
3052
|
getValue: () => row.getValue(columnId),
|
|
3053
3053
|
renderValue: getRenderValue,
|
|
3054
|
-
getContext: () => ({
|
|
3054
|
+
getContext: memo(() => [table, column, row, cell], (table, column, row, cell) => ({
|
|
3055
3055
|
table,
|
|
3056
3056
|
column,
|
|
3057
3057
|
row,
|
|
3058
3058
|
cell: cell,
|
|
3059
3059
|
getValue: cell.getValue,
|
|
3060
3060
|
renderValue: cell.renderValue
|
|
3061
|
+
}), {
|
|
3062
|
+
key: process.env.NODE_ENV === 'development' && 'cell.getContext',
|
|
3063
|
+
debug: () => table.options.debugAll
|
|
3061
3064
|
})
|
|
3062
3065
|
};
|
|
3063
3066
|
|
|
@@ -3789,7 +3792,6 @@ function getExpandedRowModel() {
|
|
|
3789
3792
|
|
|
3790
3793
|
if (!paginateExpandedRows) {
|
|
3791
3794
|
// Only expand rows at this point if they are being paginated
|
|
3792
|
-
console.log(rowModel.rows);
|
|
3793
3795
|
return rowModel;
|
|
3794
3796
|
}
|
|
3795
3797
|
|
|
@@ -3858,7 +3860,6 @@ function getPaginationRowModel(opts) {
|
|
|
3858
3860
|
};
|
|
3859
3861
|
}
|
|
3860
3862
|
|
|
3861
|
-
console.log(paginatedRowModel.rows);
|
|
3862
3863
|
paginatedRowModel.flatRows = [];
|
|
3863
3864
|
|
|
3864
3865
|
const handleRow = row => {
|