@tanstack/table-core 8.10.4 → 8.10.6
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/core/row.js +1 -1
- package/build/lib/core/row.js.map +1 -1
- package/build/lib/index.esm.js +11 -1
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +11 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/sortingFns.js +10 -0
- package/build/lib/sortingFns.js.map +1 -1
- package/build/umd/index.development.js +11 -1
- 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/row.ts +1 -1
- package/src/sortingFns.ts +10 -0
package/build/lib/core/row.js
CHANGED
|
@@ -56,7 +56,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
56
56
|
},
|
|
57
57
|
subRows: subRows != null ? subRows : [],
|
|
58
58
|
getLeafRows: () => utils.flattenBy(row.subRows, d => d.subRows),
|
|
59
|
-
getParentRow: () => row.parentId ? table.getRow(row.parentId) : undefined,
|
|
59
|
+
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
|
|
60
60
|
getParentRows: () => {
|
|
61
61
|
let parentRows = [];
|
|
62
62
|
let currentRow = row;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.js","sources":["../../../src/core/row.ts"],"sourcesContent":["import { RowData, Cell, Row, Table } from '../types'\nimport { flattenBy, memo } from '../utils'\nimport { createCell } from './cell'\n\nexport interface CoreRow<TData extends RowData> {\n _getAllCellsByColumnId: () => Record<string, Cell<TData, unknown>>\n _uniqueValuesCache: Record<string, unknown>\n _valuesCache: Record<string, unknown>\n /**\n * The depth of the row (if nested or grouped) relative to the root row array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n depth: number\n /**\n * Returns all of the cells for the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getallcells)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getAllCells: () => Cell<TData, unknown>[]\n /**\n * Returns the leaf rows for the row, not including any parent rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getleafrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getLeafRows: () => Row<TData>[]\n /**\n * Returns the parent row for the row, if it exists.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrow)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRow: () => Row<TData> | undefined\n /**\n * Returns the parent rows for the row, all the way up to a root row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRows: () => Row<TData>[]\n /**\n * Returns a unique array of values from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getuniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getUniqueValues: <TValue>(columnId: string) => TValue[]\n /**\n * Returns the value from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getValue: <TValue>(columnId: string) => TValue\n /**\n * The resolved unique identifier for the row resolved via the `options.getRowId` option. Defaults to the row's index (or relative index if it is a subRow).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n id: string\n /**\n * The index of the row within its parent array (or the root data array).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#index)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n index: number\n /**\n * The original row object provided to the table. If the row is a grouped row, the original row object will be the first original in the group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#original)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n original: TData\n /**\n * An array of the original subRows as returned by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#originalsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n originalSubRows?: TData[]\n /**\n * If nested, this row's parent row id.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#parentid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n parentId?: string\n /**\n * Renders the value for the row in a given columnId the same as `getValue`, but will return the `renderFallbackValue` if no value is found.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#rendervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n renderValue: <TValue>(columnId: string) => TValue\n /**\n * An array of subRows for the row as returned and created by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#subrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n subRows: Row<TData>[]\n}\n\nexport const createRow = <TData extends RowData>(\n table: Table<TData>,\n id: string,\n original: TData,\n rowIndex: number,\n depth: number,\n subRows?: Row<TData>[],\n parentId?: string\n): Row<TData> => {\n let row: CoreRow<TData> = {\n id,\n index: rowIndex,\n original,\n depth,\n parentId,\n _valuesCache: {},\n _uniqueValuesCache: {},\n getValue: columnId => {\n if (row._valuesCache.hasOwnProperty(columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(\n row.original as TData,\n rowIndex\n )\n\n return row._valuesCache[columnId] as any\n },\n getUniqueValues: columnId => {\n if (row._uniqueValuesCache.hasOwnProperty(columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original as TData,\n rowIndex\n )\n\n return row._uniqueValuesCache[columnId] as any\n },\n renderValue: columnId =>\n row.getValue(columnId) ?? table.options.renderFallbackValue,\n subRows: subRows ?? [],\n getLeafRows: () => flattenBy(row.subRows, d => d.subRows),\n getParentRow: () => (row.parentId ? table.getRow(row.parentId) : undefined),\n getParentRows: () => {\n let parentRows: Row<TData>[] = []\n let currentRow = row\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n },\n getAllCells: memo(\n () => [table.getAllLeafColumns()],\n leafColumns => {\n return leafColumns.map(column => {\n return createCell(table, row as Row<TData>, column, column.id)\n })\n },\n {\n key: process.env.NODE_ENV === 'development' && 'row.getAllCells',\n debug: () => table.options.debugAll ?? table.options.debugRows,\n }\n ),\n\n _getAllCellsByColumnId: memo(\n () => [row.getAllCells()],\n allCells => {\n return allCells.reduce(\n (acc, cell) => {\n acc[cell.column.id] = cell\n return acc\n },\n {} as Record<string, Cell<TData, unknown>>\n )\n },\n {\n key:\n process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',\n debug: () => table.options.debugAll ?? table.options.debugRows,\n }\n ),\n }\n\n for (let i = 0; i < table._features.length; i++) {\n const feature = table._features[i]\n feature?.createRow?.(row, table)\n }\n\n return row as Row<TData>\n}\n"],"names":["createRow","table","id","original","rowIndex","depth","subRows","parentId","row","index","_valuesCache","_uniqueValuesCache","getValue","columnId","hasOwnProperty","column","getColumn","accessorFn","undefined","getUniqueValues","columnDef","renderValue","_row$getValue","options","renderFallbackValue","getLeafRows","flattenBy","d","getParentRow","getRow","getParentRows","parentRows","currentRow","parentRow","push","reverse","getAllCells","memo","getAllLeafColumns","leafColumns","map","createCell","key","process","env","NODE_ENV","debug","_table$options$debugA","debugAll","debugRows","_getAllCellsByColumnId","allCells","reduce","acc","cell","_table$options$debugA2","i","_features","length","feature"],"mappings":";;;;;;;;;;;;;;;;;MA8FaA,SAAS,GAAGA,CACvBC,KAAmB,EACnBC,EAAU,EACVC,QAAe,EACfC,QAAgB,EAChBC,KAAa,EACbC,OAAsB,EACtBC,QAAiB,KACF;AACf,EAAA,IAAIC,GAAmB,GAAG;IACxBN,EAAE;AACFO,IAAAA,KAAK,EAAEL,QAAQ;IACfD,QAAQ;IACRE,KAAK;IACLE,QAAQ;IACRG,YAAY,EAAE,EAAE;IAChBC,kBAAkB,EAAE,EAAE;IACtBC,QAAQ,EAAEC,QAAQ,IAAI;MACpB,IAAIL,GAAG,CAACE,YAAY,CAACI,cAAc,CAACD,QAAQ,CAAC,EAAE;AAC7C,QAAA,OAAOL,GAAG,CAACE,YAAY,CAACG,QAAQ,CAAC,CAAA;AACnC,OAAA;AAEA,MAAA,MAAME,MAAM,GAAGd,KAAK,CAACe,SAAS,CAACH,QAAQ,CAAC,CAAA;AAExC,MAAA,IAAI,EAACE,MAAM,IAAA,IAAA,IAANA,MAAM,CAAEE,UAAU,CAAE,EAAA;AACvB,QAAA,OAAOC,SAAS,CAAA;AAClB,OAAA;AAEAV,MAAAA,GAAG,CAACE,YAAY,CAACG,QAAQ,CAAC,GAAGE,MAAM,CAACE,UAAU,CAC5CT,GAAG,CAACL,QAAQ,EACZC,QACF,CAAC,CAAA;AAED,MAAA,OAAOI,GAAG,CAACE,YAAY,CAACG,QAAQ,CAAC,CAAA;KAClC;IACDM,eAAe,EAAEN,QAAQ,IAAI;MAC3B,IAAIL,GAAG,CAACG,kBAAkB,CAACG,cAAc,CAACD,QAAQ,CAAC,EAAE;AACnD,QAAA,OAAOL,GAAG,CAACG,kBAAkB,CAACE,QAAQ,CAAC,CAAA;AACzC,OAAA;AAEA,MAAA,MAAME,MAAM,GAAGd,KAAK,CAACe,SAAS,CAACH,QAAQ,CAAC,CAAA;AAExC,MAAA,IAAI,EAACE,MAAM,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ACD;MACEX,GAAG,EACDC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,2BAA2B;AACtEC,MAAAA,KAAK,EAAEA,MAAA;AAAA,QAAA,IAAAS,sBAAA,CAAA;AAAA,QAAA,OAAA,CAAAA,sBAAA,GAAMtD,KAAK,CAACsB,OAAO,CAACyB,QAAQ,KAAAO,IAAAA,GAAAA,sBAAA,GAAItD,KAAK,CAACsB,OAAO,CAAC0B,SAAS,CAAA;AAAA,OAAA;KAElE,CAAA;GACD,CAAA;AAED,EAAA,KAAK,IAAIO,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGvD,KAAK,CAACwD,SAAS,CAACC,MAAM,EAAEF,CAAC,EAAE,EAAE;AAC/C,IAAA,MAAMG,OAAO,GAAG1D,KAAK,CAACwD,SAAS,CAACD,CAAC,CAAC,CAAA;AAClCG,IAAAA,OAAO,IAAPA,IAAAA,IAAAA,OAAO,CAAE3D,SAAS,IAAlB2D,IAAAA,IAAAA,OAAO,CAAE3D,SAAS,CAAGQ,GAAG,EAAEP,KAAK,CAAC,CAAA;AAClC,GAAA;AAEA,EAAA,OAAOO,GAAG,CAAA;AACZ;;;;"}
|
|
1
|
+
{"version":3,"file":"row.js","sources":["../../../src/core/row.ts"],"sourcesContent":["import { RowData, Cell, Row, Table } from '../types'\nimport { flattenBy, memo } from '../utils'\nimport { createCell } from './cell'\n\nexport interface CoreRow<TData extends RowData> {\n _getAllCellsByColumnId: () => Record<string, Cell<TData, unknown>>\n _uniqueValuesCache: Record<string, unknown>\n _valuesCache: Record<string, unknown>\n /**\n * The depth of the row (if nested or grouped) relative to the root row array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n depth: number\n /**\n * Returns all of the cells for the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getallcells)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getAllCells: () => Cell<TData, unknown>[]\n /**\n * Returns the leaf rows for the row, not including any parent rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getleafrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getLeafRows: () => Row<TData>[]\n /**\n * Returns the parent row for the row, if it exists.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrow)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRow: () => Row<TData> | undefined\n /**\n * Returns the parent rows for the row, all the way up to a root row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRows: () => Row<TData>[]\n /**\n * Returns a unique array of values from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getuniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getUniqueValues: <TValue>(columnId: string) => TValue[]\n /**\n * Returns the value from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getValue: <TValue>(columnId: string) => TValue\n /**\n * The resolved unique identifier for the row resolved via the `options.getRowId` option. Defaults to the row's index (or relative index if it is a subRow).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n id: string\n /**\n * The index of the row within its parent array (or the root data array).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#index)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n index: number\n /**\n * The original row object provided to the table. If the row is a grouped row, the original row object will be the first original in the group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#original)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n original: TData\n /**\n * An array of the original subRows as returned by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#originalsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n originalSubRows?: TData[]\n /**\n * If nested, this row's parent row id.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#parentid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n parentId?: string\n /**\n * Renders the value for the row in a given columnId the same as `getValue`, but will return the `renderFallbackValue` if no value is found.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#rendervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n renderValue: <TValue>(columnId: string) => TValue\n /**\n * An array of subRows for the row as returned and created by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#subrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n subRows: Row<TData>[]\n}\n\nexport const createRow = <TData extends RowData>(\n table: Table<TData>,\n id: string,\n original: TData,\n rowIndex: number,\n depth: number,\n subRows?: Row<TData>[],\n parentId?: string\n): Row<TData> => {\n let row: CoreRow<TData> = {\n id,\n index: rowIndex,\n original,\n depth,\n parentId,\n _valuesCache: {},\n _uniqueValuesCache: {},\n getValue: columnId => {\n if (row._valuesCache.hasOwnProperty(columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(\n row.original as TData,\n rowIndex\n )\n\n return row._valuesCache[columnId] as any\n },\n getUniqueValues: columnId => {\n if (row._uniqueValuesCache.hasOwnProperty(columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original as TData,\n rowIndex\n )\n\n return row._uniqueValuesCache[columnId] as any\n },\n renderValue: columnId =>\n row.getValue(columnId) ?? table.options.renderFallbackValue,\n subRows: subRows ?? [],\n getLeafRows: () => flattenBy(row.subRows, d => d.subRows),\n getParentRow: () => (row.parentId ? table.getRow(row.parentId, true) : undefined),\n getParentRows: () => {\n let parentRows: Row<TData>[] = []\n let currentRow = row\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n },\n getAllCells: memo(\n () => [table.getAllLeafColumns()],\n leafColumns => {\n return leafColumns.map(column => {\n return createCell(table, row as Row<TData>, column, column.id)\n })\n },\n {\n key: process.env.NODE_ENV === 'development' && 'row.getAllCells',\n debug: () => table.options.debugAll ?? table.options.debugRows,\n }\n ),\n\n _getAllCellsByColumnId: memo(\n () => [row.getAllCells()],\n allCells => {\n return allCells.reduce(\n (acc, cell) => {\n acc[cell.column.id] = cell\n return acc\n },\n {} as Record<string, Cell<TData, unknown>>\n )\n },\n {\n key:\n process.env.NODE_ENV === 'production' && 'row.getAllCellsByColumnId',\n debug: () => table.options.debugAll ?? table.options.debugRows,\n }\n ),\n }\n\n for (let i = 0; i < table._features.length; i++) {\n const feature = table._features[i]\n feature?.createRow?.(row, table)\n }\n\n return row as Row<TData>\n}\n"],"names":["createRow","table","id","original","rowIndex","depth","subRows","parentId","row","index","_valuesCache","_uniqueValuesCache","getValue","columnId","hasOwnProperty","column","getColumn","accessorFn","undefined","getUniqueValues","columnDef","renderValue","_row$getValue","options","renderFallbackValue","getLeafRows","flattenBy","d","getParentRow","getRow","getParentRows","parentRows","currentRow","parentRow","push","reverse","getAllCells","memo","getAllLeafColumns","leafColumns","map","createCell","key","process","env","NODE_ENV","debug","_table$options$debugA","debugAll","debugRows","_getAllCellsByColumnId","allCells","reduce","acc","cell","_table$options$debugA2","i","_features","length","feature"],"mappings":";;;;;;;;;;;;;;;;;MA8FaA,SAAS,GAAGA,CACvBC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AEA,MAAA;AAAA,QAAA,IAAAS,sBAAA,CAAA;AAAA,QAAA,OAAA,CAAAA,sBAAA,GAAMtD,KAAK,CAACsB,OAAO,CAACyB,QAAQ,KAAAO,IAAAA,GAAAA,sBAAA,GAAItD,KAAK,CAACsB,OAAO,CAAC0B,SAAS,CAAA;AAAA,OAAA;KAElE,CAAA;GACD,CAAA;AAED,EAAA,KAAK,IAAIO,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGvD,KAAK,CAACwD,SAAS,CAACC,MAAM,EAAEF,CAAC,EAAE,EAAE;AAC/C,IAAA,MAAMG,OAAO,GAAG1D,KAAK,CAACwD,SAAS,CAACD,CAAC,CAAC,CAAA;AAClCG,IAAAA,OAAO,IAAPA,IAAAA,IAAAA,OAAO,CAAE3D,SAAS,IAAlB2D,IAAAA,IAAAA,OAAO,CAAE3D,SAAS,CAAGQ,GAAG,EAAEP,KAAK,CAAC,CAAA;AAClC,GAAA;AAEA,EAAA,OAAOO,GAAG,CAAA;AACZ;;;;"}
|
package/build/lib/index.esm.js
CHANGED
|
@@ -2337,6 +2337,9 @@ function compareBasic(a, b) {
|
|
|
2337
2337
|
return a === b ? 0 : a > b ? 1 : -1;
|
|
2338
2338
|
}
|
|
2339
2339
|
function toString(a) {
|
|
2340
|
+
if (typeof a === 'boolean') {
|
|
2341
|
+
return String(a);
|
|
2342
|
+
}
|
|
2340
2343
|
if (typeof a === 'number') {
|
|
2341
2344
|
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2342
2345
|
return '';
|
|
@@ -2353,6 +2356,13 @@ function toString(a) {
|
|
|
2353
2356
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2354
2357
|
// null, undefined, and Infinity
|
|
2355
2358
|
function compareAlphanumeric(aStr, bStr) {
|
|
2359
|
+
// Check if the string contains only a number
|
|
2360
|
+
const aFloat = parseFloat(aStr);
|
|
2361
|
+
const bFloat = parseFloat(bStr);
|
|
2362
|
+
if (!isNaN(aFloat) && !isNaN(bFloat)) {
|
|
2363
|
+
return compareBasic(aFloat, bFloat);
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2356
2366
|
// Split on number groups, but keep the delimiter
|
|
2357
2367
|
// Then remove falsey split values
|
|
2358
2368
|
const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
@@ -2978,7 +2988,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
2978
2988
|
},
|
|
2979
2989
|
subRows: subRows != null ? subRows : [],
|
|
2980
2990
|
getLeafRows: () => flattenBy(row.subRows, d => d.subRows),
|
|
2981
|
-
getParentRow: () => row.parentId ? table.getRow(row.parentId) : undefined,
|
|
2991
|
+
getParentRow: () => row.parentId ? table.getRow(row.parentId, true) : undefined,
|
|
2982
2992
|
getParentRows: () => {
|
|
2983
2993
|
let parentRows = [];
|
|
2984
2994
|
let currentRow = row;
|