@economic/taco 2.15.0 → 2.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/dist/components/Drawer/Drawer.d.ts +5 -1
  2. package/dist/components/Provider/Localization.d.ts +19 -0
  3. package/dist/components/SearchInput2/SearchInput2.d.ts +1 -0
  4. package/dist/components/Table3/components/alert/ErrorAlert.d.ts +10 -0
  5. package/dist/components/Table3/components/columns/cell/DisplayCell.d.ts +5 -2
  6. package/dist/components/Table3/components/columns/cell/EditingCell.d.ts +3 -0
  7. package/dist/components/Table3/components/columns/cell/Highlight.d.ts +2 -0
  8. package/dist/components/Table3/components/columns/internal/EditingActions.d.ts +1 -1
  9. package/dist/components/Table3/components/rows/Row.d.ts +2 -0
  10. package/dist/components/Table3/components/rows/RowContext.d.ts +1 -0
  11. package/dist/components/Table3/hooks/features/useEditing.d.ts +12 -11
  12. package/dist/components/Table3/hooks/features/usePauseShortcuts.d.ts +5 -0
  13. package/dist/components/Table3/hooks/features/useSearch.d.ts +2 -0
  14. package/dist/components/Table3/hooks/features/useValidation.d.ts +13 -0
  15. package/dist/components/Table3/hooks/useTable.d.ts +4 -0
  16. package/dist/components/Table3/types.d.ts +26 -1
  17. package/dist/components/Table3/util/editing.d.ts +6 -0
  18. package/dist/esm/index.css +108 -33
  19. package/dist/esm/packages/taco/src/components/Drawer/Drawer.js +7 -2
  20. package/dist/esm/packages/taco/src/components/Drawer/Drawer.js.map +1 -1
  21. package/dist/esm/packages/taco/src/components/Provider/Localization.js +19 -0
  22. package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
  23. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +4 -0
  24. package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
  25. package/dist/esm/packages/taco/src/components/Table3/Table3.js +7 -1
  26. package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
  27. package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js +154 -0
  28. package/dist/esm/packages/taco/src/components/Table3/components/alert/ErrorAlert.js.map +1 -0
  29. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js +51 -6
  30. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Cell.js.map +1 -1
  31. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +7 -55
  32. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
  33. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +69 -37
  34. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
  35. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js +17 -17
  36. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingControl.js.map +1 -1
  37. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Highlight.js +41 -0
  38. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/Highlight.js.map +1 -0
  39. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js +21 -12
  40. package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/controls/TextareaControl.js.map +1 -1
  41. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js +1 -1
  42. package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js.map +1 -1
  43. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js +57 -17
  44. package/dist/esm/packages/taco/src/components/Table3/components/columns/internal/EditingActions.js.map +1 -1
  45. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js +39 -31
  46. package/dist/esm/packages/taco/src/components/Table3/components/rows/Row.js.map +1 -1
  47. package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js +2 -1
  48. package/dist/esm/packages/taco/src/components/Table3/components/rows/RowContext.js.map +1 -1
  49. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js +8 -1
  50. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Filter/filters/Filters.js.map +1 -1
  51. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js +48 -1
  52. package/dist/esm/packages/taco/src/components/Table3/components/toolbar/Search.js.map +1 -1
  53. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js +185 -101
  54. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useEditing.js.map +1 -1
  55. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseShortcuts.js +12 -0
  56. package/dist/esm/packages/taco/src/components/Table3/hooks/features/usePauseShortcuts.js.map +1 -0
  57. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js +4 -1
  58. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useSearch.js.map +1 -1
  59. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useValidation.js +178 -0
  60. package/dist/esm/packages/taco/src/components/Table3/hooks/features/useValidation.js.map +1 -0
  61. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js +1 -1
  62. package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
  63. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js +8 -2
  64. package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
  65. package/dist/esm/packages/taco/src/components/Table3/strategies/virtualised.js +1 -1
  66. package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
  67. package/dist/esm/packages/taco/src/components/Table3/util/editing.js +21 -1
  68. package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
  69. package/dist/index.css +108 -33
  70. package/dist/taco.cjs.development.js +2605 -1970
  71. package/dist/taco.cjs.development.js.map +1 -1
  72. package/dist/taco.cjs.production.min.js +1 -1
  73. package/dist/taco.cjs.production.min.js.map +1 -1
  74. package/package.json +2 -2
  75. package/types.json +10973 -7880
@@ -0,0 +1,154 @@
1
+ import React__default from 'react';
2
+ import { Alert } from '../../../Alert/Alert.js';
3
+ import { useLocalization } from '../../../Provider/Localization.js';
4
+ import { Button } from '../../../Button/Button.js';
5
+ import { Dialog } from '../../../Dialog/Dialog.js';
6
+ import { Group } from '../../../Group/Group.js';
7
+ import { focusableSelector } from '../../util/editing.js';
8
+ import { lastCellIndex } from '../rows/Row.js';
9
+
10
+ function ErrorAlert(props) {
11
+ var _column$columnDef$met;
12
+ const {
13
+ table,
14
+ tableRef,
15
+ scrollToIndex,
16
+ rowIdentifier
17
+ } = props;
18
+ const tableMeta = table.options.meta;
19
+ const errors = tableMeta.validation.errors;
20
+ const errorsRowIds = errors ? Object.keys(errors) : [];
21
+ const rows = table.getRowModel().rows;
22
+ const coreRows = table.getCoreRowModel().rows;
23
+ const {
24
+ texts
25
+ } = useLocalization();
26
+ const [resetFiltersConfirmationOpen, setResetFiltersConfirmationOpen] = React__default.useState(false);
27
+ const [internalRowId, setInternalRowId] = React__default.useState(null);
28
+ const [internalRowIndex, setInternalRowIndex] = React__default.useState(null);
29
+ const [isFiltersReset, setIsFiltersReset] = React__default.useState(false);
30
+ const columns = table.getAllFlatColumns();
31
+ const column = columns.find(column => column.id === rowIdentifier);
32
+ const rowIdentifierHeader = column === null || column === void 0 ? void 0 : (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.header;
33
+ // Find and focus first invalid cell
34
+ const navigateToFirstInvalidCell = () => {
35
+ var _tableRef$current;
36
+ const firstInvalidCell = (_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.querySelector('[role="row"][data-current="true"] [role="cell"][data-invalid="true"]');
37
+ const firstInvalidElement = firstInvalidCell === null || firstInvalidCell === void 0 ? void 0 : firstInvalidCell.querySelector(focusableSelector);
38
+ if (firstInvalidElement) {
39
+ firstInvalidElement === null || firstInvalidElement === void 0 ? void 0 : firstInvalidElement.focus();
40
+ lastCellIndex.value = firstInvalidCell === null || firstInvalidCell === void 0 ? void 0 : firstInvalidCell.getAttribute('data-column-index');
41
+ }
42
+ };
43
+ // Navigate to row and focus first invalid cell
44
+ const navigateToRow = rowIndex => {
45
+ tableMeta.currentRow.setCurrentRowIndex(rowIndex);
46
+ scrollToIndex(rowIndex, {
47
+ align: 'center'
48
+ });
49
+ lastCellIndex.value = undefined;
50
+ // Need to request animation frame here, because newly selected row is not rendered yet.
51
+ requestAnimationFrame(() => {
52
+ navigateToFirstInvalidCell();
53
+ });
54
+ };
55
+ // When internal row index is changed after click on row link, we should navigate to the row.
56
+ React__default.useEffect(() => {
57
+ if (internalRowIndex !== null && internalRowIndex >= 0) {
58
+ navigateToRow(internalRowIndex);
59
+ }
60
+ }, [internalRowIndex]);
61
+ // When filters are reset, we're able to get the real row index by rowId
62
+ React__default.useEffect(() => {
63
+ if (isFiltersReset) {
64
+ const rowIndex = rows.findIndex(row => row.id === internalRowId);
65
+ if (rowIndex === -1) {
66
+ return;
67
+ }
68
+ setInternalRowIndex(rowIndex);
69
+ }
70
+ }, [isFiltersReset]);
71
+ const onRowNumberClick = React__default.useCallback(rowId => {
72
+ // When row is hidden due filtering it will not be present in rows (but it still will be present in coreRows)
73
+ const foundIndex = rows.findIndex(row => row.id === rowId);
74
+ if (foundIndex === -1) {
75
+ setIsFiltersReset(false);
76
+ setResetFiltersConfirmationOpen(true);
77
+ // Since row indexes changed due filtering, we need to save row id, so that we can find it when filters will be reset
78
+ setInternalRowId(rowId);
79
+ return;
80
+ }
81
+ // In cases when user clicked on a row link multiple times we still need to navigate to the row, and focus the cell,
82
+ // because row/cell will loose focus on next click, but row index will not change.
83
+ if (foundIndex === internalRowIndex) {
84
+ navigateToRow(foundIndex);
85
+ } else {
86
+ setInternalRowIndex(foundIndex);
87
+ }
88
+ }, [rows, internalRowIndex]);
89
+ const onResetFiltersConfirm = () => {
90
+ setIsFiltersReset(true);
91
+ };
92
+ // Getting the row from core rows (ignoring search and filtering)
93
+ const getCoreRow = React__default.useCallback(rowId => coreRows.find(coreRow => coreRow.id === rowId), [coreRows]);
94
+ return /*#__PURE__*/React__default.createElement("div", {
95
+ className: "mb-4"
96
+ }, errorsRowIds.length ? /*#__PURE__*/React__default.createElement(Alert, {
97
+ state: "error",
98
+ className: "mb-1"
99
+ }, /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("b", null, errorsRowIds.length, " ", texts.table3.validation.alert.unsavedEntries(errorsRowIds.length)), ' '), rowIdentifierHeader || texts.table3.validation.index, ' ', errorsRowIds.map((rowId, index) => {
100
+ const coreRow = getCoreRow(rowId);
101
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
102
+ key: rowId,
103
+ className: "!min-h-[theme(spacing.2)] !min-w-[theme(spacing.2)] !px-1",
104
+ appearance: "discrete",
105
+ onClick: () => {
106
+ onRowNumberClick(rowId);
107
+ }
108
+ }, rowIdentifier ? coreRow === null || coreRow === void 0 ? void 0 : coreRow.original[rowIdentifier] : coreRow === null || coreRow === void 0 ? void 0 : coreRow.index), /*#__PURE__*/React__default.createElement("span", {
109
+ key: `${rowId}_comma`
110
+ }, index < errorsRowIds.length - 1 ? ',' : ''));
111
+ }), texts.table3.validation.alert.incompleteAndHavntBeenSaved(errorsRowIds.length)) : null, /*#__PURE__*/React__default.createElement(FilterResetDialog, {
112
+ open: resetFiltersConfirmationOpen,
113
+ onClose: () => {
114
+ setResetFiltersConfirmationOpen(false);
115
+ },
116
+ onConfirm: onResetFiltersConfirm,
117
+ table: table
118
+ }));
119
+ }
120
+ function FilterResetDialog(props) {
121
+ const {
122
+ open,
123
+ onClose,
124
+ onConfirm,
125
+ table
126
+ } = props;
127
+ const tableMeta = table.options.meta;
128
+ const {
129
+ texts
130
+ } = useLocalization();
131
+ const resetFilters = React__default.useCallback(() => {
132
+ tableMeta.search.setQuery('');
133
+ table.resetGlobalFilter();
134
+ table.resetColumnFilters();
135
+ }, [table, tableMeta.search]);
136
+ const handleConfirmClick = () => {
137
+ resetFilters();
138
+ onConfirm();
139
+ onClose();
140
+ };
141
+ return /*#__PURE__*/React__default.createElement(Dialog, {
142
+ open: open,
143
+ onClose: onClose,
144
+ size: "xs"
145
+ }, /*#__PURE__*/React__default.createElement(Dialog.Content, {
146
+ "aria-label": "Create a new account"
147
+ }, /*#__PURE__*/React__default.createElement(Dialog.Title, null, texts.table3.validation.resetFiltersDialog.title), /*#__PURE__*/React__default.createElement("p", null, texts.table3.validation.resetFiltersDialog.description), /*#__PURE__*/React__default.createElement(Dialog.Footer, null, /*#__PURE__*/React__default.createElement(Group, null, /*#__PURE__*/React__default.createElement(Dialog.Close, null, /*#__PURE__*/React__default.createElement(Button, null, texts.table3.validation.resetFiltersDialog.cancel)), /*#__PURE__*/React__default.createElement(Button, {
148
+ appearance: "primary",
149
+ onClick: handleConfirmClick
150
+ }, texts.table3.validation.resetFiltersDialog.confirm)))));
151
+ }
152
+
153
+ export { ErrorAlert };
154
+ //# sourceMappingURL=ErrorAlert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorAlert.js","sources":["../../../../../../../../../src/components/Table3/components/alert/ErrorAlert.tsx"],"sourcesContent":["import { Table as RTable, TableMeta } from '@tanstack/react-table';\nimport { TableStrategy } from '../../types';\nimport React from 'react';\nimport { Alert } from '../../../Alert/Alert';\nimport { Button } from '../../../Button/Button';\nimport { useLocalization } from '../../../Provider/Localization';\nimport { focusableSelector } from '../../util/editing';\nimport { lastCellIndex } from '../rows/Row';\nimport { Dialog } from '../../../Dialog/Dialog';\nimport { Group } from '../../../Group/Group';\n\nexport type ErrorAlertProps<TType = unknown> = {\n table: RTable<TType>;\n tableRef: React.RefObject<HTMLDivElement>;\n scrollToIndex: TableStrategy['scrollToIndex'];\n rowIdentifier?: string;\n};\n\nexport function ErrorAlert<TType = unknown>(props: ErrorAlertProps<TType>) {\n const { table, tableRef, scrollToIndex, rowIdentifier } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const errors = tableMeta.validation.errors;\n const errorsRowIds = errors ? Object.keys(errors) : [];\n const rows = table.getRowModel().rows;\n const coreRows = table.getCoreRowModel().rows;\n const { texts } = useLocalization();\n const [resetFiltersConfirmationOpen, setResetFiltersConfirmationOpen] = React.useState(false);\n const [internalRowId, setInternalRowId] = React.useState<string | null>(null);\n const [internalRowIndex, setInternalRowIndex] = React.useState<number | null>(null);\n const [isFiltersReset, setIsFiltersReset] = React.useState(false);\n const columns = table.getAllFlatColumns();\n const column = columns.find(column => column.id === rowIdentifier);\n const rowIdentifierHeader = column?.columnDef.meta?.header;\n\n // Find and focus first invalid cell\n const navigateToFirstInvalidCell = () => {\n const firstInvalidCell = tableRef.current?.querySelector(\n '[role=\"row\"][data-current=\"true\"] [role=\"cell\"][data-invalid=\"true\"]'\n );\n const firstInvalidElement = firstInvalidCell?.querySelector(focusableSelector);\n\n if (firstInvalidElement) {\n (firstInvalidElement as HTMLElement)?.focus();\n lastCellIndex.value = firstInvalidCell?.getAttribute('data-column-index');\n }\n };\n\n // Navigate to row and focus first invalid cell\n const navigateToRow = rowIndex => {\n tableMeta.currentRow.setCurrentRowIndex(rowIndex);\n scrollToIndex(rowIndex, { align: 'center' });\n lastCellIndex.value = undefined;\n\n // Need to request animation frame here, because newly selected row is not rendered yet.\n requestAnimationFrame(() => {\n navigateToFirstInvalidCell();\n });\n };\n\n // When internal row index is changed after click on row link, we should navigate to the row.\n React.useEffect(() => {\n if (internalRowIndex !== null && internalRowIndex >= 0) {\n navigateToRow(internalRowIndex);\n }\n }, [internalRowIndex]);\n\n // When filters are reset, we're able to get the real row index by rowId\n React.useEffect(() => {\n if (isFiltersReset) {\n const rowIndex = rows.findIndex(row => row.id === internalRowId);\n if (rowIndex === -1) {\n return;\n }\n setInternalRowIndex(rowIndex);\n }\n }, [isFiltersReset]);\n\n const onRowNumberClick = React.useCallback(\n (rowId: string) => {\n // When row is hidden due filtering it will not be present in rows (but it still will be present in coreRows)\n const foundIndex = rows.findIndex(row => row.id === rowId);\n if (foundIndex === -1) {\n setIsFiltersReset(false);\n setResetFiltersConfirmationOpen(true);\n\n // Since row indexes changed due filtering, we need to save row id, so that we can find it when filters will be reset\n setInternalRowId(rowId);\n return;\n }\n\n // In cases when user clicked on a row link multiple times we still need to navigate to the row, and focus the cell,\n // because row/cell will loose focus on next click, but row index will not change.\n if (foundIndex === internalRowIndex) {\n navigateToRow(foundIndex);\n } else {\n setInternalRowIndex(foundIndex);\n }\n },\n [rows, internalRowIndex]\n );\n\n const onResetFiltersConfirm = () => {\n setIsFiltersReset(true);\n };\n\n // Getting the row from core rows (ignoring search and filtering)\n const getCoreRow = React.useCallback((rowId: string) => coreRows.find(coreRow => coreRow.id === rowId), [coreRows]);\n\n return (\n <div className=\"mb-4\">\n {errorsRowIds.length ? (\n <Alert state=\"error\" className=\"mb-1\">\n <>\n <b>\n {errorsRowIds.length} {texts.table3.validation.alert.unsavedEntries(errorsRowIds.length)}\n </b>{' '}\n </>\n {rowIdentifierHeader || texts.table3.validation.index}{' '}\n {errorsRowIds.map((rowId: string, index) => {\n const coreRow = getCoreRow(rowId);\n return (\n <>\n <Button\n key={rowId}\n className=\"!min-h-[theme(spacing.2)] !min-w-[theme(spacing.2)] !px-1\"\n appearance=\"discrete\"\n onClick={() => {\n onRowNumberClick(rowId);\n }}>\n {/* Getting row from core rows, because 'table.getRow' will fail if row is hidden due filtering */}\n {rowIdentifier ? coreRow?.original[rowIdentifier] : coreRow?.index}\n </Button>\n <span key={`${rowId}_comma`}>{index < errorsRowIds.length - 1 ? ',' : ''}</span>\n </>\n );\n })}\n {texts.table3.validation.alert.incompleteAndHavntBeenSaved(errorsRowIds.length)}\n </Alert>\n ) : null}\n <FilterResetDialog\n open={resetFiltersConfirmationOpen}\n onClose={() => {\n setResetFiltersConfirmationOpen(false);\n }}\n onConfirm={onResetFiltersConfirm}\n table={table}\n />\n </div>\n );\n}\n\ntype FilterResetDialogProps<TType = unknown> = {\n open: boolean;\n onClose: () => void;\n onConfirm: () => void;\n table: RTable<TType>;\n};\nfunction FilterResetDialog<TType = unknown>(props: FilterResetDialogProps<TType>) {\n const { open, onClose, onConfirm, table } = props;\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { texts } = useLocalization();\n\n const resetFilters = React.useCallback(() => {\n tableMeta.search.setQuery('');\n table.resetGlobalFilter();\n table.resetColumnFilters();\n }, [table, tableMeta.search]);\n\n const handleConfirmClick = () => {\n resetFilters();\n onConfirm();\n onClose();\n };\n\n return (\n <Dialog open={open} onClose={onClose} size=\"xs\">\n <Dialog.Content aria-label=\"Create a new account\">\n <Dialog.Title>{texts.table3.validation.resetFiltersDialog.title}</Dialog.Title>\n\n <p>{texts.table3.validation.resetFiltersDialog.description}</p>\n\n <Dialog.Footer>\n <Group>\n <Dialog.Close>\n <Button>{texts.table3.validation.resetFiltersDialog.cancel}</Button>\n </Dialog.Close>\n <Button appearance=\"primary\" onClick={handleConfirmClick}>\n {texts.table3.validation.resetFiltersDialog.confirm}\n </Button>\n </Group>\n </Dialog.Footer>\n </Dialog.Content>\n </Dialog>\n );\n}\n"],"names":["ErrorAlert","props","table","tableRef","scrollToIndex","rowIdentifier","tableMeta","options","meta","errors","validation","errorsRowIds","Object","keys","rows","getRowModel","coreRows","getCoreRowModel","texts","useLocalization","resetFiltersConfirmationOpen","setResetFiltersConfirmationOpen","React","useState","internalRowId","setInternalRowId","internalRowIndex","setInternalRowIndex","isFiltersReset","setIsFiltersReset","columns","getAllFlatColumns","column","find","id","rowIdentifierHeader","_column$columnDef$met","columnDef","header","navigateToFirstInvalidCell","firstInvalidCell","_tableRef$current","current","querySelector","firstInvalidElement","focusableSelector","focus","lastCellIndex","value","getAttribute","navigateToRow","rowIndex","currentRow","setCurrentRowIndex","align","undefined","requestAnimationFrame","useEffect","findIndex","row","onRowNumberClick","useCallback","rowId","foundIndex","onResetFiltersConfirm","getCoreRow","coreRow","className","length","Alert","state","table3","alert","unsavedEntries","index","map","Button","key","appearance","onClick","original","incompleteAndHavntBeenSaved","FilterResetDialog","open","onClose","onConfirm","resetFilters","search","setQuery","resetGlobalFilter","resetColumnFilters","handleConfirmClick","Dialog","size","Content","Title","resetFiltersDialog","title","description","Footer","Group","Close","cancel","confirm"],"mappings":";;;;;;;;;SAkBgBA,UAAUA,CAAkBC,KAA6B;;EACrE,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,aAAa;IAAEC;GAAe,GAAGJ,KAAK;EAC/D,MAAMK,SAAS,GAAGJ,KAAK,CAACK,OAAO,CAACC,IAAwB;EACxD,MAAMC,MAAM,GAAGH,SAAS,CAACI,UAAU,CAACD,MAAM;EAC1C,MAAME,YAAY,GAAGF,MAAM,GAAGG,MAAM,CAACC,IAAI,CAACJ,MAAM,CAAC,GAAG,EAAE;EACtD,MAAMK,IAAI,GAAGZ,KAAK,CAACa,WAAW,EAAE,CAACD,IAAI;EACrC,MAAME,QAAQ,GAAGd,KAAK,CAACe,eAAe,EAAE,CAACH,IAAI;EAC7C,MAAM;IAAEI;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAM,CAACC,4BAA4B,EAAEC,+BAA+B,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EAC7F,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAgB,IAAI,CAAC;EAC7E,MAAM,CAACG,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGL,cAAK,CAACC,QAAQ,CAAgB,IAAI,CAAC;EACnF,MAAM,CAACK,cAAc,EAAEC,iBAAiB,CAAC,GAAGP,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACjE,MAAMO,OAAO,GAAG5B,KAAK,CAAC6B,iBAAiB,EAAE;EACzC,MAAMC,MAAM,GAAGF,OAAO,CAACG,IAAI,CAACD,MAAM,IAAIA,MAAM,CAACE,EAAE,KAAK7B,aAAa,CAAC;EAClE,MAAM8B,mBAAmB,GAAGH,MAAM,aAANA,MAAM,wBAAAI,qBAAA,GAANJ,MAAM,CAAEK,SAAS,CAAC7B,IAAI,cA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ACwF,kBAAkB,EAAE;GAC7B,EAAE,CAACxF,KAAK,EAAEI,SAAS,CAACiF,MAAM,CAAC,CAAC;EAE7B,MAAMI,kBAAkB,GAAGA;IACvBL,YAAY,EAAE;IACdD,SAAS,EAAE;IACXD,OAAO,EAAE;GACZ;EAED,oBACI9D,6BAACsE,MAAM;IAACT,IAAI,EAAEA,IAAI;IAAEC,OAAO,EAAEA,OAAO;IAAES,IAAI,EAAC;kBACvCvE,6BAACsE,MAAM,CAACE,OAAO;kBAAY;kBACvBxE,6BAACsE,MAAM,CAACG,KAAK,QAAE7E,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACC,KAAK,CAAgB,eAE/E3E,wCAAIJ,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACE,WAAW,CAAK,eAE/D5E,6BAACsE,MAAM,CAACO,MAAM,qBACV7E,6BAAC8E,KAAK,qBACF9E,6BAACsE,MAAM,CAACS,KAAK,qBACT/E,6BAACsD,MAAM,QAAE1D,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACM,MAAM,CAAU,CACzD,eACfhF,6BAACsD,MAAM;IAACE,UAAU,EAAC,SAAS;IAACC,OAAO,EAAEY;KACjCzE,KAAK,CAACqD,MAAM,CAAC7D,UAAU,CAACsF,kBAAkB,CAACO,OAAO,CAC9C,CACL,CACI,CACH,CACZ;AAEjB;;;;"}
@@ -1,6 +1,7 @@
1
1
  import React__default from 'react';
2
- import { useRowContext } from '../../rows/RowContext.js';
2
+ import { useRowContext, RowContext } from '../../rows/RowContext.js';
3
3
  import { DisplayCell } from './DisplayCell.js';
4
+ import { isCellHighlighted } from '../../../util/columns.js';
4
5
  import { EditingCell } from './EditingCell.js';
5
6
 
6
7
  function Cell(props) {
@@ -8,20 +9,64 @@ function Cell(props) {
8
9
  const {
9
10
  column,
10
11
  row,
11
- table
12
+ table,
13
+ index,
14
+ getValue,
15
+ cell
12
16
  } = props;
13
17
  const {
14
- isHovered: isHoveredRow
18
+ isHovered: isHoveredRow,
19
+ hasError
15
20
  } = useRowContext();
16
21
  const rows = table.getRowModel().rows;
17
22
  const tableMeta = table.options.meta;
18
23
  const columnMeta = column.columnDef.meta;
24
+ const rowErrors = tableMeta.validation.errors ? tableMeta.validation.errors[row.id] : null;
25
+ const isColumnError = hasError && rowErrors && !!rowErrors[column.id];
19
26
  const currentRowIndex = tableMeta.currentRow.currentRowIndex;
20
27
  const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
21
- if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || isHoveredRow && !tableMeta.hoverState.isPaused)) {
22
- return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props));
28
+ let value = getValue();
29
+ // When row has changes we always need to show the editing state value, end revert it to original value only when row got saved successfully.
30
+ // Otherwise it might confuse user because it will look like display value is getting reverted everytime user leaves the row.
31
+ if (tableMeta.editing.isEditing) {
32
+ const editingValue = tableMeta.editing.getCellValue(cell);
33
+ value = editingValue !== null && editingValue !== void 0 ? editingValue : value;
23
34
  }
24
- return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props));
35
+ const {
36
+ rowIndex
37
+ } = React__default.useContext(RowContext);
38
+ const memoedHighlight = React__default.useMemo(() => {
39
+ var _tableMeta$search$que;
40
+ if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {
41
+ return false;
42
+ }
43
+ if ((_tableMeta$search$que = tableMeta.search.query) !== null && _tableMeta$search$que !== void 0 && _tableMeta$search$que.length) {
44
+ return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);
45
+ }
46
+ return false;
47
+ }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);
48
+ const memoedHighlightCurrent = React__default.useMemo(() => {
49
+ if (!tableMeta.search.isHighlightingEnabled || !memoedHighlight || tableMeta.search.currentHighlightColumnIndex === undefined) {
50
+ return false;
51
+ }
52
+ const [currentRowIndex, currentColumnIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];
53
+ if (currentRowIndex === rowIndex && currentColumnIndex === index) {
54
+ return true;
55
+ }
56
+ return false;
57
+ }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);
58
+ const highlightProps = {
59
+ highlighted: memoedHighlight,
60
+ highlightedAsCurrent: memoedHighlightCurrent
61
+ };
62
+ if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || isHoveredRow && !tableMeta.hoverState.isPaused ||
63
+ // When cell has error, we renderimg it in edit mode (UX reqirement)
64
+ isColumnError)) {
65
+ return /*#__PURE__*/React__default.createElement(EditingCell, Object.assign({}, props, highlightProps));
66
+ }
67
+ return /*#__PURE__*/React__default.createElement(DisplayCell, Object.assign({}, props, highlightProps, {
68
+ value: value
69
+ }));
25
70
  }
26
71
 
27
72
  export { Cell };
@@ -1 +1 @@
1
- {"version":3,"file":"Cell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { DisplayCell } from './DisplayCell';\nimport { EditingCell } from './EditingCell';\nimport { useRowContext } from '../../rows/RowContext';\n\nexport type CellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n};\n\nexport function Cell<TType = unknown>(props: CellProps<TType>) {\n const { column, row, table } = props;\n const { isHovered: isHoveredRow } = useRowContext();\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<unknown>;\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n\n const currentRowIndex = tableMeta.currentRow.currentRowIndex;\n const isCurrentRow =\n currentRowIndex !== undefined && rows[currentRowIndex]?.id === row.id;\n\n if (tableMeta.editing.isEditing && columnMeta.control && (isCurrentRow || (isHoveredRow && !tableMeta.hoverState.isPaused))) {\n return <EditingCell {...props} />;\n }\n\n return <DisplayCell {...props} />;\n}\n"],"names":["Cell","props","column","row","table","isHovered","isHoveredRow","useRowContext","rows","getRowModel","tableMeta","options","meta","columnMeta","columnDef","currentRowIndex","currentRow","isCurrentRow","undefined","_rows$currentRowIndex","id","editing","isEditing","control","hoverState","isPaused","React","EditingCell","DisplayCell"],"mappings":";;;;;SAUgBA,IAAIA,CAAkBC,KAAuB;;EACzD,MAAM;IAAEC,MAAM;IAAEC,GAAG;IAAEC;GAAO,GAAGH,KAAK;EACpC,MAAM;IAAEI,SAAS,EAAEC;GAAc,GAAGC,aAAa,EAAE;EACnD,MAAMC,IAAI,GAAGJ,KAAK,CAACK,WAAW,EAAE,CAACD,IAAI;EACrC,MAAME,SAAS,GAAGN,KAAK,CAACO,OAAO,CAACC,IAA0B;EAC1D,MAAMC,UAAU,GAAGX,MAAM,CAACY,SAAS,CAACF,IAAkC;EAEtE,MAAMG,eAAe,GAAGL,SAAS,CAACM,UAAU,CAACD,eAAe;EAC5D,MAAME,YAAY,GACdF,eAAe,KAAKG,SAAS,IAAI,EAAAC,qBAAA,GAAAX,IAAI,CAACO,eAAe,CAAC,cAAAI,qBAAA,uBAArBA,qBAAA,CAAuBC,EAAE,MAAKjB,GAAG,CAACiB,EAAE;EAEzE,IAAIV,SAAS,CAACW,OAAO,CAACC,SAAS,IAAIT,UAAU,CAACU,OAAO,KAAKN,YAAY,IAAKX,YAAY,IAAI,CAACI,SAAS,CAACc,UAAU,CAACC,QAAS,CAAC,EAAE;IACzH,oBAAOC,6BAACC,WAAW,oBAAK1B,KAAK,EAAI;;EAGrC,oBAAOyB,6BAACE,WAAW,oBAAK3B,KAAK,EAAI;AACrC;;;;"}
1
+ {"version":3,"file":"Cell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport { CellContext, ColumnMeta, TableMeta } from '@tanstack/react-table';\nimport { DisplayCell } from './DisplayCell';\nimport { EditingCell } from './EditingCell';\nimport { RowContext, useRowContext } from '../../rows/RowContext';\nimport { isCellHighlighted } from '../../../util/columns';\n\nexport type CellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n};\n\nexport function Cell<TType = unknown>(props: CellProps<TType>) {\n const { column, row, table, index, getValue, cell } = props;\n const { isHovered: isHoveredRow, hasError } = useRowContext();\n const rows = table.getRowModel().rows;\n const tableMeta = table.options.meta as TableMeta<unknown>;\n const columnMeta = column.columnDef.meta as ColumnMeta<TType, unknown>;\n const rowErrors = tableMeta.validation.errors ? tableMeta.validation.errors[row.id] : null;\n const isColumnError = hasError && rowErrors && !!rowErrors[column.id];\n\n const currentRowIndex = tableMeta.currentRow.currentRowIndex;\n const isCurrentRow =\n currentRowIndex !== undefined && rows[currentRowIndex]?.id === row.id;\n let value = getValue();\n\n // When row has changes we always need to show the editing state value, end revert it to original value only when row got saved successfully.\n // Otherwise it might confuse user because it will look like display value is getting reverted everytime user leaves the row.\n if (tableMeta.editing.isEditing) {\n const editingValue = tableMeta.editing.getCellValue(cell);\n value = editingValue ?? value;\n }\n\n const { rowIndex } = React.useContext(RowContext);\n\n const memoedHighlight = React.useMemo(() => {\n if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {\n return false;\n }\n\n if (tableMeta.search.query?.length) {\n return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);\n }\n\n return false;\n }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);\n\n const memoedHighlightCurrent = React.useMemo(() => {\n if (\n !tableMeta.search.isHighlightingEnabled ||\n !memoedHighlight ||\n tableMeta.search.currentHighlightColumnIndex === undefined\n ) {\n return false;\n }\n\n const [currentRowIndex, currentColumnIndex] =\n tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (currentRowIndex === rowIndex && currentColumnIndex === index) {\n return true;\n }\n\n return false;\n }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);\n\n const highlightProps = {\n highlighted: memoedHighlight,\n highlightedAsCurrent: memoedHighlightCurrent,\n };\n\n if (\n tableMeta.editing.isEditing &&\n columnMeta.control &&\n (isCurrentRow ||\n (isHoveredRow && !tableMeta.hoverState.isPaused) ||\n // When cell has error, we renderimg it in edit mode (UX reqirement)\n isColumnError)\n ) {\n return <EditingCell {...props} {...highlightProps} />;\n }\n\n return <DisplayCell {...props} {...highlightProps} value={value} />;\n}\n"],"names":["Cell","props","column","row","table","index","getValue","cell","isHovered","isHoveredRow","hasError","useRowContext","rows","getRowModel","tableMeta","options","meta","columnMeta","columnDef","rowErrors","validation","errors","id","isColumnError","currentRowIndex","currentRow","isCurrentRow","undefined","_rows$currentRowIndex","value","editing","isEditing","editingValue","getCellValue","rowIndex","React","useContext","RowContext","memoedHighlight","useMemo","search","isHighlightingEnabled","enableSearch","_tableMeta$search$que","query","length","isCellHighlighted","dataType","excludeUnmatchedResults","memoedHighlightCurrent","currentHighlightColumnIndex","currentColumnIndex","highlightedColumnIndexes","highlightProps","highlighted","highlightedAsCurrent","control","hoverState","isPaused","EditingCell","DisplayCell"],"mappings":";;;;;;SAWgBA,IAAIA,CAAkBC,KAAuB;;EACzD,MAAM;IAAEC,MAAM;IAAEC,GAAG;IAAEC,KAAK;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;GAAM,GAAGN,KAAK;EAC3D,MAAM;IAAEO,SAAS,EAAEC,YAAY;IAAEC;GAAU,GAAGC,aAAa,EAAE;EAC7D,MAAMC,IAAI,GAAGR,KAAK,CAACS,WAAW,EAAE,CAACD,IAAI;EACrC,MAAME,SAAS,GAAGV,KAAK,CAACW,OAAO,CAACC,IAA0B;EAC1D,MAAMC,UAAU,GAAGf,MAAM,CAACgB,SAAS,CAACF,IAAkC;EACtE,MAAMG,SAAS,GAAGL,SAAS,CAACM,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,CAAC0B,MAAM,CAACQ,uBAAuB,EAAElC,SAAS,CAAC0B,MAAM,CAACI,KAAK,CAAC,CAAC;EAErH,MAAMK,sBAAsB,GAAGd,cAAK,CAACI,OAAO,CAAC;IACzC,IACI,CAACzB,SAAS,CAAC0B,MAAM,CAACC,qBAAqB,IACvC,CAACH,eAAe,IAChBxB,SAAS,CAAC0B,MAAM,CAACU,2BAA2B,KAAKvB,SAAS,EAC5D;MACE,OAAO,KAAK;;IAGhB,MAAM,CAACH,eAAe,EAAE2B,kBAAkB,CAAC,GACvCrC,SAAS,CAAC0B,MAAM,CAACY,wBAAwB,CAACtC,SAAS,CAAC0B,MAAM,CAACU,2BAA2B,CAAC;IAE3F,IAAI1B,eAAe,KAAKU,QAAQ,IAAIiB,kBAAkB,KAAK9C,KAAK,EAAE;MAC9D,OAAO,IAAI;;IAGf,OAAO,KAAK;GACf,EAAE,CAACiC,eAAe,EAAExB,SAAS,CAAC0B,MAAM,CAACY,wBAAwB,CAACP,MAAM,EAAE/B,SAAS,CAAC0B,MAAM,CAACU,2BAA2B,CAAC,CAAC;EAErH,MAAMG,cAAc,GAAG;IACnBC,WAAW,EAAEhB,eAAe;IAC5BiB,oBAAoB,EAAEN;GACzB;EAED,IACInC,SAAS,CAACgB,OAAO,CAACC,SAAS,IAC3Bd,UAAU,CAACuC,OAAO,KACjB9B,YAAY,IACRjB,YAAY,IAAI,CAACK,SAAS,CAAC2C,UAAU,CAACC,QAAS;;EAEhDnC,aAAa,CAAC,EACpB;IACE,oBAAOY,6BAACwB,WAAW,oBAAK1D,KAAK,EAAMoD,cAAc,EAAI;;EAGzD,oBAAOlB,6BAACyB,WAAW,oBAAK3D,KAAK,EAAMoD,cAAc;IAAExB,KAAK,EAAEA;KAAS;AACvE;;;;"}
@@ -1,25 +1,22 @@
1
1
  import React__default from 'react';
2
2
  import cn from 'classnames';
3
- import { RowContext } from '../../rows/RowContext.js';
4
- import { isCellHighlighted, scrollColumnIntoView } from '../../../util/columns.js';
3
+ import { Highlight } from './Highlight.js';
5
4
 
6
5
  function DisplayCell(props) {
7
6
  const {
8
7
  cell,
9
8
  className,
10
9
  column,
11
- getValue,
10
+ value,
12
11
  index,
13
12
  row,
14
13
  table,
15
- tableRef
14
+ tableRef,
15
+ highlighted,
16
+ highlightedAsCurrent
16
17
  } = props;
17
18
  const columnMeta = React__default.useMemo(() => column.columnDef.meta, []);
18
19
  const tableMeta = table.options.meta;
19
- const {
20
- rowIndex
21
- } = React__default.useContext(RowContext);
22
- const value = getValue();
23
20
  // cells are heavily memoized because performance in our table is critical
24
21
  // be careful and selective about props that you pass to the cell
25
22
  const memoedProps = React__default.useMemo(() => {
@@ -37,29 +34,9 @@ function DisplayCell(props) {
37
34
  tableRef
38
35
  };
39
36
  }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);
40
- const memoedHighlight = React__default.useMemo(() => {
41
- var _tableMeta$search$que;
42
- if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {
43
- return false;
44
- }
45
- if ((_tableMeta$search$que = tableMeta.search.query) !== null && _tableMeta$search$que !== void 0 && _tableMeta$search$que.length) {
46
- return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);
47
- }
48
- return false;
49
- }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);
50
- const memoedHighlightCurrent = React__default.useMemo(() => {
51
- if (!tableMeta.search.isHighlightingEnabled || !memoedHighlight || tableMeta.search.currentHighlightColumnIndex === undefined) {
52
- return false;
53
- }
54
- const [currentRowIndex, currentColumnIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];
55
- if (currentRowIndex === rowIndex && currentColumnIndex === index) {
56
- return true;
57
- }
58
- return false;
59
- }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);
60
37
  return /*#__PURE__*/React__default.createElement(MemoedDisplayCell, Object.assign({}, memoedProps, {
61
- highlighted: memoedHighlight,
62
- highlightedAsCurrent: memoedHighlightCurrent
38
+ highlighted: highlighted,
39
+ highlightedAsCurrent: highlightedAsCurrent
63
40
  }));
64
41
  }
65
42
  const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDisplayCell(props) {
@@ -100,31 +77,6 @@ const MemoedDisplayCell = /*#__PURE__*/React__default.memo(function MemoedDispla
100
77
  tableRef: tableRef
101
78
  }, content) : content);
102
79
  });
103
- const Highlight = props => {
104
- const {
105
- current,
106
- frozenColumnIndex,
107
- index,
108
- tableRef,
109
- ...attributes
110
- } = props;
111
- const ref = React__default.useRef(null);
112
- const className = cn('h-full flex [justify-content:inherit] [text-align:inherit]', props.className, {
113
- // normal row
114
- 'bg-blue-200/25': !current,
115
- // current row
116
- 'bg-blue-200/75': current
117
- });
118
- React__default.useEffect(() => {
119
- if (ref.current && current) {
120
- scrollColumnIntoView(index, frozenColumnIndex, ref.current, tableRef.current);
121
- }
122
- }, [current]);
123
- return /*#__PURE__*/React__default.createElement("div", Object.assign({}, attributes, {
124
- className: className,
125
- ref: ref
126
- }));
127
- };
128
80
 
129
81
  export { DisplayCell };
130
82
  //# sourceMappingURL=DisplayCell.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { RowContext } from '../../rows/RowContext';\nimport { isCellHighlighted, scrollColumnIntoView } from '../../../util/columns';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n children?: string | JSX.Element;\n className?: string;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, getValue, index, row, table, tableRef } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n const { rowIndex } = React.useContext(RowContext);\n\n const value = getValue();\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);\n\n const memoedHighlight = React.useMemo(() => {\n if (!tableMeta.search.isHighlightingEnabled || !columnMeta.enableSearch) {\n return false;\n }\n\n if (tableMeta.search.query?.length) {\n return isCellHighlighted(tableMeta.search.query, value, columnMeta.dataType);\n }\n\n return false;\n }, [value, tableMeta.search.isHighlightingEnabled, tableMeta.search.excludeUnmatchedResults, tableMeta.search.query]);\n\n const memoedHighlightCurrent = React.useMemo(() => {\n if (\n !tableMeta.search.isHighlightingEnabled ||\n !memoedHighlight ||\n tableMeta.search.currentHighlightColumnIndex === undefined\n ) {\n return false;\n }\n\n const [currentRowIndex, currentColumnIndex] =\n tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (currentRowIndex === rowIndex && currentColumnIndex === index) {\n return true;\n }\n\n return false;\n }, [memoedHighlight, tableMeta.search.highlightedColumnIndexes.length, tableMeta.search.currentHighlightColumnIndex]);\n\n return (\n <MemoedDisplayCell<TType> {...memoedProps} highlighted={memoedHighlight} highlightedAsCurrent={memoedHighlightCurrent} />\n );\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted: boolean;\n highlightedAsCurrent: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n\nconst Highlight = props => {\n const { current, frozenColumnIndex, index, tableRef, ...attributes } = props;\n const ref = React.useRef<HTMLDivElement | null>(null);\n const className = cn('h-full flex [justify-content:inherit] [text-align:inherit]', props.className, {\n // normal row\n 'bg-blue-200/25': !current,\n // current row\n 'bg-blue-200/75': current,\n });\n\n React.useEffect(() => {\n if (ref.current && current) {\n scrollColumnIntoView(index, frozenColumnIndex, ref.current, tableRef.current);\n }\n }, [current]);\n\n return <div {...attributes} className={className} ref={ref} />;\n};\n"],"names":["DisplayCell","props","cell","className","column","getValue","index","row","table","tableRef","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","rowIndex","useContext","RowContext","value","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","memoedHighlight","search","isHighlightingEnabled","enableSearch","_tableMeta$search$que","query","length","isCellHighlighted","dataType","excludeUnmatchedResults","memoedHighlightCurrent","currentHighlightColumnIndex","undefined","currentRowIndex","currentColumnIndex","highlightedColumnIndexes","MemoedDisplayCell","highlighted","highlightedAsCurrent","memo","customClassName","layoutClassName","content","console","log","role","tabIndex","Highlight","current","attributes","ref","useRef","useEffect","scrollColumnIntoView"],"mappings":";;;;;SAYgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,GAAG;IAAEC,KAAK;IAAEC;GAAU,GAAGR,KAAK;EAChF,MAAMS,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMR,MAAM,CAACS,SAAS,CAACC,IAAkC,EAAE,EAAE,CAAC;EAC/F,MAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACF,IAAwB;EACxD,MAAM;IAAEG;GAAU,GAAGN,cAAK,CAACO,UAAU,CAACC,UAAU,CAAC;EAEjD,MAAMC,KAAK,GAAGf,QAAQ,EAAE;;;EAIxB,MAAMgB,WAAW,GAAGV,cAAK,CAACC,OAAO,CAAC;;IAC9B,OAAO;MACHU,KAAK,EAAEZ,UAAU,CAACY,KAAK;MACvBC,QAAQ,GAAAC,IAAA,IAAAC,KAAA,IAAAC,eAAA,GAAGzB,KAAK,CAACsB,QAAQ,cAAAG,eAAA,cAAAA,eAAA,IAAAC,oBAAA,GAAIjB,UAAU,CAACkB,QAAQ,cAAAD,oBAAA,uBAAnBA,oBAAA,CAAAE,IAAA,CAAAnB,UAAU,EAAYU,KAAK,EAAEb,GAAG,CAACuB,QAAQ,CAAC,cAAAL,KAAA,cAAAA,KAAA,GAAIL,KAAK,cAAAI,IAAA,cAAAA,IAAA,GAAI,IAG1E;MACV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ACIR,SAAS,EAAEA,SAAS;kBACRmB,KAAK;yBACEhB,KAAK;wBACNkD,WAAW;IAC7BQ,IAAI,EAAC,MAAM;;IAEXC,QAAQ,EAAE,CAAC;KACVT,WAAW,gBACR7C,6BAACuD,SAAS;IACN/D,SAAS,EAAEyD,eAAe;IAC1BO,OAAO,EAAEV,oBAAoB;IAC7BrB,iBAAiB,EAAEA,iBAAiB;IACpC9B,KAAK,EAAEA,KAAK;IACZG,QAAQ,EAAEA;KACToD,OAAO,CACA,GAEZA,OACH,CACC;AAEd,CAAC,CAA2E;AAE5E,MAAMK,SAAS,GAAGjE,KAAK;EACnB,MAAM;IAAEkE,OAAO;IAAE/B,iBAAiB;IAAE9B,KAAK;IAAEG,QAAQ;IAAE,GAAG2D;GAAY,GAAGnE,KAAK;EAC5E,MAAMoE,GAAG,GAAG1D,cAAK,CAAC2D,MAAM,CAAwB,IAAI,CAAC;EACrD,MAAMnE,SAAS,GAAG4B,EAAE,CAAC,4DAA4D,EAAE9B,KAAK,CAACE,SAAS,EAAE;;IAEhG,gBAAgB,EAAE,CAACgE,OAAO;;IAE1B,gBAAgB,EAAEA;GACrB,CAAC;EAEFxD,cAAK,CAAC4D,SAAS,CAAC;IACZ,IAAIF,GAAG,CAACF,OAAO,IAAIA,OAAO,EAAE;MACxBK,oBAAoB,CAAClE,KAAK,EAAE8B,iBAAiB,EAAEiC,GAAG,CAACF,OAAO,EAAE1D,QAAQ,CAAC0D,OAAO,CAAC;;GAEpF,EAAE,CAACA,OAAO,CAAC,CAAC;EAEb,oBAAOxD,sDAASyD,UAAU;IAAEjE,SAAS,EAAEA,SAAS;IAAEkE,GAAG,EAAEA;KAAO;AAClE,CAAC;;;;"}
1
+ {"version":3,"file":"DisplayCell.js","sources":["../../../../../../../../../../src/components/Table3/components/columns/cell/DisplayCell.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\nimport { ColumnMeta, CellContext, TableMeta } from '@tanstack/react-table';\nimport { Table3ColumnAlignment } from '../../../types';\nimport { Highlight } from './Highlight';\n\nexport type DisplayCellProps<TType = unknown> = CellContext<TType, unknown> & {\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n children?: string | JSX.Element;\n className?: string;\n value?: any;\n};\n\nexport function DisplayCell<TType = unknown>(props: DisplayCellProps<TType>) {\n const { cell, className, column, value, index, row, table, tableRef, highlighted, highlightedAsCurrent } = props;\n const columnMeta = React.useMemo(() => column.columnDef.meta as ColumnMeta<TType, unknown>, []);\n const tableMeta = table.options.meta as TableMeta<TType>;\n\n // cells are heavily memoized because performance in our table is critical\n // be careful and selective about props that you pass to the cell\n const memoedProps = React.useMemo(() => {\n return {\n align: columnMeta.align,\n children: (props.children ?? columnMeta.renderer?.(value, row.original) ?? value ?? null) as\n | JSX.Element\n | string\n | null,\n className: cn(\n className,\n typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className\n ),\n data: row.original,\n debug: table.options.debugAll,\n enableTruncate: columnMeta.enableTruncate,\n frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,\n id: cell.id,\n index,\n tableRef,\n };\n }, [row.original, props.children, value, tableMeta.columnFreezing.frozenColumnIndex]);\n\n return <MemoedDisplayCell<TType> {...memoedProps} highlighted={highlighted} highlightedAsCurrent={highlightedAsCurrent} />;\n}\n\n// Memoization\nexport type MemoedDisplayCellProps<TType = unknown> = {\n align?: Table3ColumnAlignment;\n children: JSX.Element | string | null;\n className?: string;\n data: TType;\n debug?: boolean;\n enableTruncate?: boolean;\n frozenColumnIndex?: number;\n highlighted?: boolean;\n highlightedAsCurrent?: boolean;\n id: string;\n index: number;\n tableRef: React.RefObject<HTMLDivElement>;\n};\n\nconst MemoedDisplayCell = React.memo(function MemoedDisplayCell<TType = unknown>(props: MemoedDisplayCellProps<TType>) {\n const {\n align = 'left',\n children,\n className: customClassName,\n debug,\n enableTruncate,\n frozenColumnIndex,\n highlighted,\n highlightedAsCurrent = false,\n id,\n index,\n tableRef,\n } = props;\n\n const layoutClassName = cn(\n 'py-[var(--table3-cell-padding-y)] px-[var(--table3-cell-padding-x)] focus:outline-none break-word hyphens-auto',\n customClassName\n );\n\n const className = highlighted ? undefined : layoutClassName;\n const content = enableTruncate ? <span className=\"truncate\">{children}</span> : children;\n\n if (debug) {\n console.log('cell render', id);\n }\n\n return (\n <div\n className={className}\n data-align={align}\n data-column-index={index}\n data-highlighted={highlighted}\n role=\"cell\"\n // cells must be focusable (but not included in tabbing - hence -1)\n tabIndex={-1}>\n {highlighted ? (\n <Highlight\n className={layoutClassName}\n current={highlightedAsCurrent}\n frozenColumnIndex={frozenColumnIndex}\n index={index}\n tableRef={tableRef}>\n {content}\n </Highlight>\n ) : (\n content\n )}\n </div>\n );\n}) as <TType = unknown>(props: MemoedDisplayCellProps<TType>) => JSX.Element;\n"],"names":["DisplayCell","props","cell","className","column","value","index","row","table","tableRef","highlighted","highlightedAsCurrent","columnMeta","React","useMemo","columnDef","meta","tableMeta","options","memoedProps","align","children","_ref","_ref2","_props$children","_columnMeta$renderer","renderer","call","original","cn","data","debug","debugAll","enableTruncate","frozenColumnIndex","columnFreezing","id","MemoedDisplayCell","memo","customClassName","layoutClassName","undefined","content","console","log","role","tabIndex","Highlight","current"],"mappings":";;;;SAcgBA,WAAWA,CAAkBC,KAA8B;EACvE,MAAM;IAAEC,IAAI;IAAEC,SAAS;IAAEC,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,GAAG;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;GAAsB,GAAGV,KAAK;EAChH,MAAMW,UAAU,GAAGC,cAAK,CAACC,OAAO,CAAC,MAAMV,MAAM,CAACW,SAAS,CAACC,IAAkC,EAAE,EAAE,CAAC;EAC/F,MAAMC,SAAS,GAAGT,KAAK,CAACU,OAAO,CAACF,IAAwB;;;EAIxD,MAAMG,WAAW,GAAGN,cAAK,CAACC,OAAO,CAAC;;IAC9B,OAAO;MACHM,KAAK,EAAER,UAAU,CAACQ,KAAK;MACvBC,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IACXC,oBAAoB,GAAG,KAAK;IAC5ByB,EAAE;IACF9B,KAAK;IACLG;GACH,GAAGR,KAAK;EAET,MAAMuC,eAAe,GAAGX,EAAE,CACtB,gHAAgH,EAChHU,eAAe,CAClB;EAED,MAAMpC,SAAS,GAAGO,WAAW,GAAG+B,SAAS,GAAGD,eAAe;EAC3D,MAAME,OAAO,GAAGT,cAAc,gBAAGpB;IAAMV,SAAS,EAAC;KAAYkB,QAAQ,CAAQ,GAAGA,QAAQ;EAExF,IAAIU,KAAK,EAAE;IACPY,OAAO,CAACC,GAAG,CAAC,aAAa,EAAER,EAAE,CAAC;;EAGlC,oBACIvB;IACIV,SAAS,EAAEA,SAAS;kBACRiB,KAAK;yBACEd,KAAK;wBACNI,WAAW;IAC7BmC,IAAI,EAAC,MAAM;;IAEXC,QAAQ,EAAE,CAAC;KACVpC,WAAW,gBACRG,6BAACkC,SAAS;IACN5C,SAAS,EAAEqC,eAAe;IAC1BQ,OAAO,EAAErC,oBAAoB;IAC7BuB,iBAAiB,EAAEA,iBAAiB;IACpC5B,KAAK,EAAEA,KAAK;IACZG,QAAQ,EAAEA;KACTiC,OAAO,CACA,GAEZA,OACH,CACC;AAEd,CAAC,CAA2E;;;;"}
@@ -1,20 +1,28 @@
1
1
  import React__default from 'react';
2
2
  import cn from 'classnames';
3
+ import { Field } from '../../../../Field/Field.js';
3
4
  import { useRowContext } from '../../rows/RowContext.js';
5
+ import { Highlight } from './Highlight.js';
4
6
  import { getCurrentRowCellElement } from '../../../util/columns.js';
5
7
  import { globalFilterFn, columnFilterFn } from '../../../util/filtering.js';
8
+ import { hasChanged, willRowMoveAfterSorting } from '../../../util/editing.js';
6
9
  import { EDITING_ACTIONS_WIDTH } from '../internal/EditingActions.js';
7
10
  import { Indicator, IndicatorReason } from './Indicator.js';
8
- import { hasChanged, willRowMoveAfterSorting } from '../../../util/editing.js';
9
11
  import { EditingControl } from './EditingControl.js';
10
12
 
11
13
  function EditingCell(props) {
14
+ const {
15
+ cell,
16
+ table
17
+ } = props;
12
18
  const {
13
19
  isHovered
14
20
  } = useRowContext();
15
21
  // Need to explicitly pass tableMeta, because just passing the table object will not trigger editing change since table object is not mutatable.
16
- const tableMeta = props.table.options.meta;
22
+ const tableMeta = table.options.meta;
23
+ const error = tableMeta.validation.getCellError(cell);
17
24
  return /*#__PURE__*/React__default.createElement(MemoedEditingCell, Object.assign({}, props, {
25
+ error: error,
18
26
  isHovered: isHovered,
19
27
  tableMeta: tableMeta
20
28
  }));
@@ -29,8 +37,10 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
29
37
  table,
30
38
  tableRef,
31
39
  row,
32
- isHovered,
33
- tableMeta
40
+ tableMeta,
41
+ error,
42
+ highlighted,
43
+ highlightedAsCurrent
34
44
  } = props;
35
45
  const columnMeta = column.columnDef.meta;
36
46
  const cellRef = React__default.useRef(null);
@@ -67,31 +77,38 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
67
77
  }
68
78
  };
69
79
  const handleBlur = () => {
80
+ var _tableMeta$editing$ch;
70
81
  tableMeta.editing.setDetailModeEditing(false);
82
+ if ((_tableMeta$editing$ch = tableMeta.editing.changes) !== null && _tableMeta$editing$ch !== void 0 && _tableMeta$editing$ch[cell.row.id]) {
83
+ tableMeta.validation.validate(cell.row.id, tableMeta.editing.changes[cell.row.id], cell.column.id);
84
+ }
71
85
  };
72
86
  // row move indicator
73
- const moveReason = (_tableMeta$editing$ro = tableMeta.editing.rowMoveReason[cell.column.id]) !== null && _tableMeta$editing$ro !== void 0 ? _tableMeta$editing$ro : null;
87
+ const moveReason = ((_tableMeta$editing$ro = tableMeta.editing.rowMoveReason) === null || _tableMeta$editing$ro === void 0 ? void 0 : _tableMeta$editing$ro[cell.column.id]) || null;
74
88
  const rows = table.getRowModel().rows;
75
89
  const currentRowIndex = tableMeta.currentRow.currentRowIndex;
76
90
  const isCurrentRow = currentRowIndex !== undefined && ((_rows$currentRowIndex = rows[currentRowIndex]) === null || _rows$currentRowIndex === void 0 ? void 0 : _rows$currentRowIndex.id) === row.id;
77
91
  const mountNode = React__default.useMemo(() => {
78
- if (moveReason) {
92
+ if (moveReason !== null && isCurrentRow && !error) {
79
93
  var _cellRef$current2, _cellRef$current2$par;
80
94
  return (_cellRef$current2 = cellRef.current) === null || _cellRef$current2 === void 0 ? void 0 : (_cellRef$current2$par = _cellRef$current2.parentElement) === null || _cellRef$current2$par === void 0 ? void 0 : _cellRef$current2$par.firstChild;
81
95
  }
82
96
  return null;
83
- }, [moveReason, cellRef]);
97
+ }, [moveReason, isCurrentRow, error, cellRef]);
84
98
  const removeMoveReason = () => {
85
- tableMeta.editing.removeRowMoveReason(cell.column.id);
99
+ tableMeta.editing.removeRowMoveReason();
86
100
  };
87
101
  React__default.useEffect(() => {
88
102
  // To avoid reseting move reason on another row hover,
89
103
  // we need to check for changes only if value got changed in the current row.
90
- if (!isCurrentRow) {
104
+ if (!isCurrentRow || error) {
105
+ if (tableMeta.editing.rowMoveReason) {
106
+ removeMoveReason();
107
+ }
91
108
  return;
92
109
  }
93
110
  if (hasChanged(getValue(), value)) {
94
- const moveReason = getRowMoveReason(table, row.index, row.original, cell, value);
111
+ const moveReason = getRowMoveReason(table, row.index, row.original, cell, value, tableMeta.search.excludeUnmatchedResults);
95
112
  tableMeta.editing.setRowMoveReason({
96
113
  [cell.column.id]: moveReason
97
114
  });
@@ -99,28 +116,19 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
99
116
  removeMoveReason();
100
117
  }
101
118
  return removeMoveReason;
102
- }, [value]);
119
+ }, [value, tableMeta.currentRow.currentRowIndex, tableMeta.search.excludeUnmatchedResults, error]);
103
120
  const controlRenderer = (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.control;
104
121
  const className = cn('py-[calc(var(--table3-cell-padding-y)_-_0.06rem)]', {
105
- relative: (isCurrentRow || isHovered) && controlRenderer === 'textarea',
106
- // Need to set higher z-index, so that the current row textarea (in expanded state, when positioned absolute) overlaps rows below,
107
- // but at the same time it should not overlap the table headers which has z-10.
108
- 'z-[9]': isCurrentRow && controlRenderer === 'textarea'
109
- },
110
- // component overrides - grayscale for editing hover
111
- '[[role="row"][data-current="false"]:hover_&>*]:!grayscale [[role="row"][data-current="false"]:hover_&_.bg-white]:!bg-grey-100', typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
112
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && /*#__PURE__*/React__default.createElement(Indicator, {
113
- reason: moveReason,
114
- columnName: String(cell.column.columnDef.header),
115
- mountNode: mountNode,
116
- validationErrors: []
117
- }), /*#__PURE__*/React__default.createElement("div", {
118
- className: className,
119
- "data-align": columnMeta.align,
120
- "data-column-index": index,
121
- "data-editable": true,
122
- role: "cell",
123
- ref: cellRef
122
+ // Textarea control is positioned absolute, when column is in enableTruncate mode, so the cell need to be positioned relative
123
+ relative: controlRenderer === 'textarea' && columnMeta.enableTruncate
124
+ }, typeof columnMeta.className === 'function' ? columnMeta.className(row.original) : columnMeta.className);
125
+ const fieldClassName = cn('!min-h-0 w-full !pb-0', {
126
+ '!pb-3': !!error
127
+ });
128
+ const content = /*#__PURE__*/React__default.createElement(Field, {
129
+ message: error,
130
+ invalid: !!error,
131
+ className: fieldClassName
124
132
  }, /*#__PURE__*/React__default.createElement(EditingControl, {
125
133
  align: columnMeta.align,
126
134
  column: cell.column,
@@ -134,22 +142,46 @@ const MemoedEditingCell = /*#__PURE__*/React__default.memo(function MemoedEditin
134
142
  tableRef: tableRef,
135
143
  value: value,
136
144
  cell: cell,
145
+ error: error,
146
+ tabIndex: isCurrentRow ? 0 : -1,
137
147
  isCurrentRow: isCurrentRow
138
- })));
148
+ }));
149
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, moveReason !== null && mountNode && !error ? /*#__PURE__*/React__default.createElement(Indicator, {
150
+ reason: moveReason,
151
+ columnName: String(cell.column.columnDef.header),
152
+ mountNode: mountNode,
153
+ validationErrors: []
154
+ }) : null, /*#__PURE__*/React__default.createElement("div", {
155
+ className: !highlighted ? className : undefined,
156
+ "data-align": columnMeta.align,
157
+ "data-column-index": index,
158
+ role: "cell",
159
+ "data-editable": true,
160
+ ref: cellRef,
161
+ "data-invalid": !!error,
162
+ "data-highlighted": highlighted
163
+ }, highlighted ? /*#__PURE__*/React__default.createElement(Highlight, {
164
+ current: highlightedAsCurrent,
165
+ className: className,
166
+ frozenColumnIndex: tableMeta.columnFreezing.frozenColumnIndex,
167
+ index: index,
168
+ tableRef: tableRef
169
+ }, content) : content));
139
170
  });
140
- function getRowMoveReason(table, rowIndex, rowValues, cell, newValue) {
171
+ function getRowMoveReason(table, rowIndex, rowValues, cell, newValue, excludeUnmatchedResults) {
141
172
  var _table$getState$sorti;
142
173
  let rowMoveReason = null;
143
174
  const {
144
175
  globalFilter
145
176
  } = table.getState();
146
- const isFilteredByGlobalFilter = Object.values({
177
+ const isFilteredByGlobalFilter = excludeUnmatchedResults ? Object.values({
147
178
  ...rowValues,
148
179
  [cell.id]: newValue
149
- }).some(cellValue =>
150
- // Global filter can be undefined when there is no text being searched so we pass an empty string to
151
- // globalFilterFn as query in that case.
152
- globalFilterFn(String(cellValue), globalFilter ? String(globalFilter) : ''));
180
+ }).some(() => {
181
+ // Global filter can be undefined when there is no text being searched so we pass an empty string to
182
+ // globalFilterFn as query in that case.
183
+ return globalFilterFn(String(newValue), globalFilter ? String(globalFilter) : '');
184
+ }) : true;
153
185
  if (!isFilteredByGlobalFilter) {
154
186
  rowMoveReason = IndicatorReason.SEARCH;
155
187
  } else if (cell.column.getIsFiltered() && !columnFilterFn(newValue, cell.column.getFilterValue())) {