@economic/taco 2.41.1 → 2.41.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,7 +13,7 @@ function CreateNewRowButton(props) {
13
13
  const {
14
14
  texts
15
15
  } = useLocalization();
16
- const rows = table.getCoreRowModel().rows;
16
+ const rows = table.getCoreRowModel().rows.filter(row => row.original !== undefined);
17
17
  const [rowCreated, setRowCreated] = React__default.useState({
18
18
  rowFinder: undefined
19
19
  });
@@ -60,7 +60,7 @@ function CreateNewRowButton(props) {
60
60
  return rowCreated === null || rowCreated === void 0 ? void 0 : (_rowCreated$rowFinder2 = rowCreated.rowFinder) === null || _rowCreated$rowFinder2 === void 0 ? void 0 : _rowCreated$rowFinder2.call(rowCreated, row.original);
61
61
  });
62
62
  if (createdRow) {
63
- const rowInTable = table.getRowModel().rows.find(row => {
63
+ const rowInTable = table.getRowModel().rows.filter(row => row.original !== undefined).find(row => {
64
64
  var _rowCreated$rowFinder3;
65
65
  return rowCreated === null || rowCreated === void 0 ? void 0 : (_rowCreated$rowFinder3 = rowCreated.rowFinder) === null || _rowCreated$rowFinder3 === void 0 ? void 0 : _rowCreated$rowFinder3.call(rowCreated, row.original);
66
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"CreateRowButton.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/CreateRowButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { ScrollToOptions } from '@tanstack/react-virtual';\nimport { Button } from '../../../../Button/Button';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { animateCreateRow } from '../../../util/editing';\n\ntype Props<TType = unknown> = {\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n onEditingCreate: (() => (row: Partial<TType>) => boolean) | undefined;\n scrollToIndex: (index: number, options?: ScrollToOptions) => void;\n};\n\nexport default function CreateNewRowButton<TType = unknown>(props: Props<TType>) {\n const { onEditingCreate, scrollToIndex, table, tableMeta } = props;\n const { texts } = useLocalization();\n const rows = table.getCoreRowModel().rows;\n const [rowCreated, setRowCreated] = React.useState<{ rowFinder: ((row: Partial<TType>) => boolean) | undefined }>({\n rowFinder: undefined,\n });\n\n const handleKeyDown = event => {\n if (!tableMeta.editing.hasChanges() && event.key === 'Tab') {\n !tableMeta.editing.saveChanges();\n }\n };\n\n const handleCreate = async () => {\n if (!onEditingCreate) {\n return;\n }\n const createdRow = rows.find(row => rowCreated?.rowFinder?.(row.original));\n\n if (createdRow) {\n await tableMeta.editing.saveChanges();\n\n if (!tableMeta.editing.hasRowErrors(createdRow.id)) {\n const rowFinder = onEditingCreate();\n\n setRowCreated({ rowFinder });\n }\n } else {\n const rowFinder = onEditingCreate();\n setRowCreated({ rowFinder });\n }\n };\n\n React.useEffect(() => {\n if (typeof rowCreated?.rowFinder === 'function') {\n const createdRow = rows.find(row => rowCreated?.rowFinder?.(row.original));\n\n if (createdRow) {\n const rowInTable = table.getRowModel().rows.find(row => rowCreated?.rowFinder?.(row.original));\n if (rowInTable) {\n tableMeta.editing.toggleEditing(true);\n tableMeta.rowActive.setRowActiveIndex(createdRow.index);\n scrollToIndex(createdRow.index);\n requestAnimationFrame(() => animateCreateRow(createdRow.id));\n }\n requestAnimationFrame(() => tableMeta.editing.addCreatedRowChangeset(createdRow));\n }\n }\n }, [rowCreated]);\n\n return (\n <tr\n onClick={handleCreate}\n className=\"border-grey-300 hover:bg-grey-100 group !sticky bottom-10 left-0 z-[21] !block cursor-pointer border-t print:!hidden\">\n <td className=\"!border-t-0 !bg-transparent\">\n <Button onKeyDown={handleKeyDown} className=\"group-hover:bg-grey-200 sticky left-0\" appearance=\"transparent\">\n + {texts.table3.editing.buttons.create.label}\n </Button>\n </td>\n </tr>\n );\n}\n"],"names":["CreateNewRowButton","props","onEditingCreate","scrollToIndex","table","tableMeta","texts","useLocalization","rows","getCoreRowModel","rowCreated","setRowCreated","React","useState","rowFinder","undefined","handleKeyDown","event","editing","hasChanges","key","saveChanges","handleCreate","Promise","resolve","createdRow","find","row","_rowCreated$rowFinder","call","original","_temp","then","hasRowErrors","id","e","reject","useEffect","_rowCreated$rowFinder2","rowInTable","getRowModel","_rowCreated$rowFinder3","toggleEditing","rowActive","setRowActiveIndex","index","requestAnimationFrame","animateCreateRow","addCreatedRowChangeset","onClick","className","Button","onKeyDown","appearance","table3","buttons","create","label"],"mappings":";;;;;SAcwBA,kBAAkBA,CAAkBC,KAAmB;EAC3E,MAAM;IAAEC,eAAe;IAAEC,aAAa;IAAEC,KAAK;IAAEC;GAAW,GAAGJ,KAAK;EAClE,MAAM;IAAEK;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,IAAI,GAAGJ,KAAK,CAACK,eAAe,EAAE,CAACD,IAAI;EACzC,MAAM,CAACE,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAgE;IAC9GC,SAAS,EAAEC;GACd,CAAC;EAEF,MAAMC,aAAa,GAAGC,KAAK;IACvB,IAAI,CAACZ,SAAS,CAACa,OAAO,CAACC,UAAU,EAAE,IAAIF,KAAK,CAACG,GAAG,KAAK,KAAK,EAAE;MACxD,CAACf,SAAS,CAACa,OAAO,CAACG,WAAW,EAAE;;GAEvC;EAED,MAAMC,YAAY;IAAA;MACd,IAAI,CAACpB,eAAe,EAAE;QAClB,OAAAqB,OAAA,CAAAC,OAAA;;MAEJ,MAAMC,UAAU,GAAGjB,IAAI,CAACkB,IAAI,CAACC,GAAG;QAAA,IAAAC,qBAAA;QAAA,OAAIlB,UAAU,aAAVA,UAAU,wBAAAkB,qBAAA,GAAVlB,UAAU,CAAEI,SAAS,cAAAc,qBAAA,uBAArBA,qBAAA,CAAAC,IAAA,CAAAnB,UAAU,EAAciB,GAAG,CAACG,QAAQ,CAAC;QAAC;MAAC,MAAAC,KAAA;QAAA,IAEvEN,UAAU;UAAA,OAAAF,OAAA,CAAAC,OAAA,CACJnB,SAAS,CAACa,OAAO,CAACG,WAAW,EAAE,EAAAW,IAAA;YAAA,IAEjC,CAA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AACoB,KAAK,CAAC;UACvD1C,aAAa,CAACsB,UAAU,CAACoB,KAAK,CAAC;UAC/BC,qBAAqB,CAAC,MAAMC,gBAAgB,CAACtB,UAAU,CAACS,EAAE,CAAC,CAAC;;QAEhEY,qBAAqB,CAAC,MAAMzC,SAAS,CAACa,OAAO,CAAC8B,sBAAsB,CAACvB,UAAU,CAAC,CAAC;;;GAG5F,EAAE,CAACf,UAAU,CAAC,CAAC;EAEhB,oBACIE;IACIqC,OAAO,EAAE3B,YAAY;IACrB4B,SAAS,EAAC;kBACVtC;IAAIsC,SAAS,EAAC;kBACVtC,6BAACuC,MAAM;IAACC,SAAS,EAAEpC,aAAa;IAAEkC,SAAS,EAAC,uCAAuC;IAACG,UAAU,EAAC;WACxF/C,KAAK,CAACgD,MAAM,CAACpC,OAAO,CAACqC,OAAO,CAACC,MAAM,CAACC,KAAK,CACvC,CACR,CACJ;AAEb;;;;"}
1
+ {"version":3,"file":"CreateRowButton.js","sources":["../../../../../../../../../../src/components/Table3/components/Row/Editing/CreateRowButton.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { ScrollToOptions } from '@tanstack/react-virtual';\nimport { Button } from '../../../../Button/Button';\nimport { useLocalization } from '../../../../Provider/Localization';\nimport { animateCreateRow } from '../../../util/editing';\n\ntype Props<TType = unknown> = {\n table: ReactTable<TType>;\n tableMeta: ReactTableMeta<TType>;\n onEditingCreate: (() => (row: Partial<TType>) => boolean) | undefined;\n scrollToIndex: (index: number, options?: ScrollToOptions) => void;\n};\n\nexport default function CreateNewRowButton<TType = unknown>(props: Props<TType>) {\n const { onEditingCreate, scrollToIndex, table, tableMeta } = props;\n const { texts } = useLocalization();\n const rows = table.getCoreRowModel().rows.filter(row => row.original !== undefined);\n\n const [rowCreated, setRowCreated] = React.useState<{ rowFinder: ((row: Partial<TType>) => boolean) | undefined }>({\n rowFinder: undefined,\n });\n\n const handleKeyDown = event => {\n if (!tableMeta.editing.hasChanges() && event.key === 'Tab') {\n !tableMeta.editing.saveChanges();\n }\n };\n\n const handleCreate = async () => {\n if (!onEditingCreate) {\n return;\n }\n const createdRow = rows.find(row => rowCreated?.rowFinder?.(row.original));\n\n if (createdRow) {\n await tableMeta.editing.saveChanges();\n\n if (!tableMeta.editing.hasRowErrors(createdRow.id)) {\n const rowFinder = onEditingCreate();\n\n setRowCreated({ rowFinder });\n }\n } else {\n const rowFinder = onEditingCreate();\n setRowCreated({ rowFinder });\n }\n };\n\n React.useEffect(() => {\n if (typeof rowCreated?.rowFinder === 'function') {\n const createdRow = rows.find(row => rowCreated?.rowFinder?.(row.original));\n\n if (createdRow) {\n const rowInTable = table\n .getRowModel()\n .rows.filter(row => row.original !== undefined)\n .find(row => rowCreated?.rowFinder?.(row.original));\n if (rowInTable) {\n tableMeta.editing.toggleEditing(true);\n tableMeta.rowActive.setRowActiveIndex(createdRow.index);\n scrollToIndex(createdRow.index);\n requestAnimationFrame(() => animateCreateRow(createdRow.id));\n }\n requestAnimationFrame(() => tableMeta.editing.addCreatedRowChangeset(createdRow));\n }\n }\n }, [rowCreated]);\n\n return (\n <tr\n onClick={handleCreate}\n className=\"border-grey-300 hover:bg-grey-100 group !sticky bottom-10 left-0 z-[21] !block cursor-pointer border-t print:!hidden\">\n <td className=\"!border-t-0 !bg-transparent\">\n <Button onKeyDown={handleKeyDown} className=\"group-hover:bg-grey-200 sticky left-0\" appearance=\"transparent\">\n + {texts.table3.editing.buttons.create.label}\n </Button>\n </td>\n </tr>\n );\n}\n"],"names":["CreateNewRowButton","props","onEditingCreate","scrollToIndex","table","tableMeta","texts","useLocalization","rows","getCoreRowModel","filter","row","original","undefined","rowCreated","setRowCreated","React","useState","rowFinder","handleKeyDown","event","editing","hasChanges","key","saveChanges","handleCreate","Promise","resolve","createdRow","find","_rowCreated$rowFinder","call","_temp","then","hasRowErrors","id","e","reject","useEffect","_rowCreated$rowFinder2","rowInTable","getRowModel","_rowCreated$rowFinder3","toggleEditing","rowActive","setRowActiveIndex","index","requestAnimationFrame","animateCreateRow","addCreatedRowChangeset","onClick","className","Button","onKeyDown","appearance","table3","buttons","create","label"],"mappings":";;;;;SAcwBA,kBAAkBA,CAAkBC,KAAmB;EAC3E,MAAM;IAAEC,eAAe;IAAEC,aAAa;IAAEC,KAAK;IAAEC;GAAW,GAAGJ,KAAK;EAClE,MAAM;IAAEK;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,IAAI,GAAGJ,KAAK,CAACK,eAAe,EAAE,CAACD,IAAI,CAACE,MAAM,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,KAAKC,SAAS,CAAC;EAEnF,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAgE;IAC9GC,SAAS,EAAEL;GACd,CAAC;EAEF,MAAMM,aAAa,GAAGC,KAAK;IACvB,IAAI,CAACf,SAAS,CAACgB,OAAO,CAACC,UAAU,EAAE,IAAIF,KAAK,CAACG,GAAG,KAAK,KAAK,EAAE;MACxD,CAAClB,SAAS,CAACgB,OAAO,CAACG,WAAW,EAAE;;GAEvC;EAED,MAAMC,YAAY;IAAA;MACd,IAAI,CAACvB,eAAe,EAAE;QAClB,OAAAwB,OAAA,CAAAC,OAAA;;MAEJ,MAAMC,UAAU,GAAGpB,IAAI,CAACqB,IAAI,CAAClB,GAAG;QAAA,IAAAmB,qBAAA;QAAA,OAAIhB,UAAU,aAAVA,UAAU,wBAAAgB,qBAAA,GAAVhB,UAAU,CAAEI,SAAS,cAAAY,qBAAA,uBAArBA,qBAAA,CAAAC,IAAA,CAAAjB,UAAU,EAAcH,GAAG,CAACC,QAAQ,CAAC;QAAC;MAAC,MAAAoB,KAAA;QAAA,IAEvEJ,UAAU;UAAA,OAAAF,OAAA,CAAAC,OAAA,CACJtB,SAAS,CAACgB,OAAO,CAACG,WAAW,EAAE,EAAAS,IAAA;YAAA,IAEjC,CAAC5B,SAAS,CAACgB,OAAO,CAACa,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C,SAAS,CAACuC,SAAS,CAACC,iBAAiB,CAACjB,UAAU,CAACkB,KAAK,CAAC;UACvD3C,aAAa,CAACyB,UAAU,CAACkB,KAAK,CAAC;UAC/BC,qBAAqB,CAAC,MAAMC,gBAAgB,CAACpB,UAAU,CAACO,EAAE,CAAC,CAAC;;QAEhEY,qBAAqB,CAAC,MAAM1C,SAAS,CAACgB,OAAO,CAAC4B,sBAAsB,CAACrB,UAAU,CAAC,CAAC;;;GAG5F,EAAE,CAACd,UAAU,CAAC,CAAC;EAEhB,oBACIE;IACIkC,OAAO,EAAEzB,YAAY;IACrB0B,SAAS,EAAC;kBACVnC;IAAImC,SAAS,EAAC;kBACVnC,6BAACoC,MAAM;IAACC,SAAS,EAAElC,aAAa;IAAEgC,SAAS,EAAC,uCAAuC;IAACG,UAAU,EAAC;WACxFhD,KAAK,CAACiD,MAAM,CAAClC,OAAO,CAACmC,OAAO,CAACC,MAAM,CAACC,KAAK,CACvC,CACR,CACJ;AAEb;;;;"}
@@ -19,7 +19,7 @@ function useTableRowSelectionListener(table, onRowSelect) {
19
19
  * we only need to know if selection was enabled or disabled, because enableRowSelection/enableMultiRowSelection functions
20
20
  * will be applied directly to particular rows.
21
21
  */
22
- }, [!!table.options.enableRowSelection, !!table.options.enableMultiRowSelection, rowSelection]);
22
+ }, [!!table.options.enableRowSelection, !!table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);
23
23
  }
24
24
 
25
25
  export { useTableRowSelectionListener };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\nimport React from 'react';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const rows = table.getSelectedRowModel().flatRows;\n const rowSelection = React.useMemo(() => rows.map(row => row.original), [rows]);\n\n useLazyEffect(() => {\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n if (table.options.enableMultiRowSelection) {\n onRowSelect(rowSelection);\n } else {\n onRowSelect([rowSelection[0]] ?? []);\n }\n }\n /**\n * Casting to a boolean, since enableRowSelection and enableMultiRowSelection can be a functions,\n * and setting a function as depoendency will lead to infinity loop. And in case of row selection useEffect,\n * we only need to know if selection was enabled or disabled, because enableRowSelection/enableMultiRowSelection functions\n * will be applied directly to particular rows.\n */\n }, [!!table.options.enableRowSelection, !!table.options.enableMultiRowSelection, rowSelection]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","rows","getSelectedRowModel","flatRows","rowSelection","React","useMemo","map","row","original","useLazyEffect","options","enableRowSelection","enableMultiRowSelection","_ref"],"mappings":";;;SAKgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;EAE1C,MAAMC,IAAI,GAAGF,KAAK,CAACG,mBAAmB,EAAE,CAACC,QAAQ;EACjD,MAAMC,YAAY,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAML,IAAI,CAACM,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,EAAE,CAACR,IAAI,CAAC,CAAC;EAE/ES,aAAa,CAAC;IACV,IAAIX,KAAK,CAACY,OAAO,CAACC,kBAAkB,IAAI,OAAOZ,WAAW,KAAK,UAAU,EAAE;MACvE,IAAID,KAAK,CAACY,OAAO,CAACE,uBAAuB,EAAE;QACvCb,WAAW,CAACI,YAAY,CAAC;OAC5B,MAAM;QAAA,IAAAU,IAAA;QACHd,WAAW,EAAAc,IAAA,GAAC,CAACV,YAAY,CAAC,CAAC,CAAC,CAAC,cAAAU,IAAA,cAAAA,IAAA,GAAI,EAAE,CAAC;;;;;;;;;GAS/C,EAAE,CAAC,CAAC,CAACf,KAAK,CAACY,OAAO,CAACC,kBAAkB,EAAE,CAAC,CAACb,KAAK,CAACY,OAAO,CAACE,uBAAuB,EAAET,YAAY,CAAC,CAAC;AACnG;;;;"}
1
+ {"version":3,"file":"useTableRowSelectionListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.ts"],"sourcesContent":["import { Table as ReactTable } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { TableRowSelectHandler } from '../../types';\nimport React from 'react';\n\nexport function useTableRowSelectionListener<TType = unknown>(\n table: ReactTable<TType>,\n onRowSelect?: TableRowSelectHandler<TType>\n) {\n const rows = table.getSelectedRowModel().flatRows;\n const rowSelection = React.useMemo(() => rows.map(row => row.original), [rows]);\n\n useLazyEffect(() => {\n if (table.options.enableRowSelection && typeof onRowSelect === 'function') {\n if (table.options.enableMultiRowSelection) {\n onRowSelect(rowSelection);\n } else {\n onRowSelect([rowSelection[0]] ?? []);\n }\n }\n /**\n * Casting to a boolean, since enableRowSelection and enableMultiRowSelection can be a functions,\n * and setting a function as depoendency will lead to infinity loop. And in case of row selection useEffect,\n * we only need to know if selection was enabled or disabled, because enableRowSelection/enableMultiRowSelection functions\n * will be applied directly to particular rows.\n */\n }, [!!table.options.enableRowSelection, !!table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);\n}\n"],"names":["useTableRowSelectionListener","table","onRowSelect","rows","getSelectedRowModel","flatRows","rowSelection","React","useMemo","map","row","original","useLazyEffect","options","enableRowSelection","enableMultiRowSelection","_ref","JSON","stringify"],"mappings":";;;SAKgBA,4BAA4BA,CACxCC,KAAwB,EACxBC,WAA0C;EAE1C,MAAMC,IAAI,GAAGF,KAAK,CAACG,mBAAmB,EAAE,CAACC,QAAQ;EACjD,MAAMC,YAAY,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAML,IAAI,CAACM,GAAG,CAACC,GAAG,IAAIA,GAAG,CAACC,QAAQ,CAAC,EAAE,CAACR,IAAI,CAAC,CAAC;EAE/ES,aAAa,CAAC;IACV,IAAIX,KAAK,CAACY,OAAO,CAACC,kBAAkB,IAAI,OAAOZ,WAAW,KAAK,UAAU,EAAE;MACvE,IAAID,KAAK,CAACY,OAAO,CAACE,uBAAuB,EAAE;QACvCb,WAAW,CAACI,YAAY,CAAC;OAC5B,MAAM;QAAA,IAAAU,IAAA;QACHd,WAAW,EAAAc,IAAA,GAAC,CAACV,YAAY,CAAC,CAAC,CAAC,CAAC,cAAAU,IAAA,cAAAA,IAAA,GAAI,EAAE,CAAC;;;;;;;;;GAS/C,EAAE,CAAC,CAAC,CAACf,KAAK,CAACY,OAAO,CAACC,kBAAkB,EAAE,CAAC,CAACb,KAAK,CAACY,OAAO,CAACE,uBAAuB,EAAEE,IAAI,CAACC,SAAS,CAACZ,YAAY,CAAC,CAAC,CAAC;AACnH;;;;"}
@@ -12,7 +12,7 @@ function useTableSearchListener(table, onChangeSearch) {
12
12
  onChangeSearch(query);
13
13
  }
14
14
  }
15
- }, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility), onChangeSearch]);
15
+ }, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility), onChangeSearch]);
16
16
  }
17
17
 
18
18
  export { useTableSearchListener };
@@ -1 +1 @@
1
- {"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\nimport { TableSearchHandler } from '../../types';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n\n // recalculates highlighted indexes whenever something important changes\n React.useEffect(() => {\n if (meta.search.isEnabled) {\n const query = table.getState().globalFilter;\n resetHighlightedColumnIndexes(query, table);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n onChangeSearch,\n ]);\n}\n"],"names":["useTableSearchListener","table","onChangeSearch","meta","options","React","useEffect","search","isEnabled","query","getState","globalFilter","resetHighlightedColumnIndexes","server","loadAllStatus","enableGlobalFilter","getRowModel","rows","JSON","stringify","sorting","columnVisibility"],"mappings":";;;SAKgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,cAAmC;EACjH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;;EAGxDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,MAAM,CAACC,SAAS,EAAE;MACvB,MAAMC,KAAK,GAAGR,KAAK,CAACS,QAAQ,EAAE,CAACC,YAAY;MAC3CC,6BAA6B,CAACH,KAAK,EAAER,KAAK,CAAC;MAE3C,IAAI,OAAOC,cAAc,KAAK,UAAU,EAAE;QACtCA,cAAc,CAACO,KAAK,CAAC;;;GAGhC,EAAE,CACCN,IAAI,CAACU,MAAM,CAACC,aAAa,EACzBX,IAAI,CAACI,MAAM,CAACC,SAAS,EACrBL,IAAI,CAACI,MAAM,CAACQ,kBAAkB,EAC9Bd,KAAK,CAACe,WAAW,EAAE,CAACC,IAAI,EACxBhB,KAAK,CAACS,QAAQ,EAAE,CAACC,YAAY,EAC7BO,IAAI,CAACC,SAAS,CAAClB,KAAK,CAACS,QAAQ,EAAE,CAACU,OAAO,CAAC,EACxCF,IAAI,CAACC,SAAS,CAAClB,KAAK,CAACS,QAAQ,EAAE,CAACW,gBAAgB,CAAC,EACjDnB,cAAc,CACjB,CAAC;AACN;;;;"}
1
+ {"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\nimport { TableSearchHandler } from '../../types';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n\n // recalculates highlighted indexes whenever something important changes\n React.useEffect(() => {\n if (meta.search.isEnabled) {\n const query = table.getState().globalFilter;\n resetHighlightedColumnIndexes(query, table);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n onChangeSearch,\n ]);\n}\n"],"names":["useTableSearchListener","table","onChangeSearch","meta","options","React","useEffect","search","isEnabled","query","getState","globalFilter","resetHighlightedColumnIndexes","server","loadAllStatus","enableGlobalFilter","getRowModel","rows","length","JSON","stringify","sorting","columnVisibility"],"mappings":";;;SAKgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,cAAmC;EACjH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;;EAGxDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,MAAM,CAACC,SAAS,EAAE;MACvB,MAAMC,KAAK,GAAGR,KAAK,CAACS,QAAQ,EAAE,CAACC,YAAY;MAC3CC,6BAA6B,CAACH,KAAK,EAAER,KAAK,CAAC;MAE3C,IAAI,OAAOC,cAAc,KAAK,UAAU,EAAE;QACtCA,cAAc,CAACO,KAAK,CAAC;;;GAGhC,EAAE,CACCN,IAAI,CAACU,MAAM,CAACC,aAAa,EACzBX,IAAI,CAACI,MAAM,CAACC,SAAS,EACrBL,IAAI,CAACI,MAAM,CAACQ,kBAAkB,EAC9Bd,KAAK,CAACe,WAAW,EAAE,CAACC,IAAI,CAACC,MAAM,EAC/BjB,KAAK,CAACS,QAAQ,EAAE,CAACC,YAAY,EAC7BQ,IAAI,CAACC,SAAS,CAACnB,KAAK,CAACS,QAAQ,EAAE,CAACW,OAAO,CAAC,EACxCF,IAAI,CAACC,SAAS,CAACnB,KAAK,CAACS,QAAQ,EAAE,CAACY,gBAAgB,CAAC,EACjDpB,cAAc,CACjB,CAAC;AACN;;;;"}
@@ -11391,7 +11391,7 @@ function useTableRowSelectionListener(table, onRowSelect) {
11391
11391
  * we only need to know if selection was enabled or disabled, because enableRowSelection/enableMultiRowSelection functions
11392
11392
  * will be applied directly to particular rows.
11393
11393
  */
11394
- }, [!!table.options.enableRowSelection, !!table.options.enableMultiRowSelection, rowSelection]);
11394
+ }, [!!table.options.enableRowSelection, !!table.options.enableMultiRowSelection, JSON.stringify(rowSelection)]);
11395
11395
  }
11396
11396
 
11397
11397
  function resetHighlightedColumnIndexes(value, table) {
@@ -11456,7 +11456,7 @@ function useTableSearchListener(table, onChangeSearch) {
11456
11456
  onChangeSearch(query);
11457
11457
  }
11458
11458
  }
11459
- }, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility), onChangeSearch]);
11459
+ }, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility), onChangeSearch]);
11460
11460
  }
11461
11461
 
11462
11462
  function useTableSettingsListener(table, onChangeSettings) {
@@ -19550,7 +19550,7 @@ function CreateNewRowButton(props) {
19550
19550
  const {
19551
19551
  texts
19552
19552
  } = useLocalization();
19553
- const rows = table.getCoreRowModel().rows;
19553
+ const rows = table.getCoreRowModel().rows.filter(row => row.original !== undefined);
19554
19554
  const [rowCreated, setRowCreated] = React__default.useState({
19555
19555
  rowFinder: undefined
19556
19556
  });
@@ -19597,7 +19597,7 @@ function CreateNewRowButton(props) {
19597
19597
  return rowCreated === null || rowCreated === void 0 ? void 0 : (_rowCreated$rowFinder2 = rowCreated.rowFinder) === null || _rowCreated$rowFinder2 === void 0 ? void 0 : _rowCreated$rowFinder2.call(rowCreated, row.original);
19598
19598
  });
19599
19599
  if (createdRow) {
19600
- const rowInTable = table.getRowModel().rows.find(row => {
19600
+ const rowInTable = table.getRowModel().rows.filter(row => row.original !== undefined).find(row => {
19601
19601
  var _rowCreated$rowFinder3;
19602
19602
  return rowCreated === null || rowCreated === void 0 ? void 0 : (_rowCreated$rowFinder3 = rowCreated.rowFinder) === null || _rowCreated$rowFinder3 === void 0 ? void 0 : _rowCreated$rowFinder3.call(rowCreated, row.original);
19603
19603
  });