@economic/taco 2.0.0-alpha.173 → 2.0.0-alpha.6
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Provider/Localization.d.ts +114 -1
- package/dist/components/Table2/Table2.d.ts +130 -0
- package/dist/components/Table2/components/BatchActionsMenu.d.ts +10 -0
- package/dist/components/Table2/components/ColumnSettingsButton.d.ts +6 -0
- package/dist/components/Table2/components/EditModeButton.d.ts +8 -0
- package/dist/components/Table2/components/RowDensityButton.d.ts +7 -0
- package/dist/components/Table2/components/Search.d.ts +3 -0
- package/dist/components/Table2/components/ShortcutsGuideButton.d.ts +7 -0
- package/dist/components/Table2/components/column/Base.d.ts +14 -0
- package/dist/components/Table2/components/column/Cell.d.ts +15 -0
- package/dist/components/Table2/components/column/Footer.d.ts +9 -0
- package/dist/components/Table2/components/column/Header.d.ts +11 -0
- package/dist/components/Table2/components/column/Indicator.d.ts +17 -0
- package/dist/components/Table2/components/column/ValidationError.d.ts +5 -0
- package/dist/components/Table2/components/column/utils.d.ts +3 -0
- package/dist/components/Table2/components/filters/FiltersButton.d.ts +7 -0
- package/dist/components/Table2/components/filters/components/Column.d.ts +11 -0
- package/dist/components/Table2/components/filters/components/ColumnFilter.d.ts +10 -0
- package/dist/components/Table2/components/filters/components/Comparator.d.ts +11 -0
- package/dist/components/Table2/components/filters/components/EmptyFilter.d.ts +13 -0
- package/dist/components/Table2/components/filters/components/InferredControl.d.ts +10 -0
- package/dist/components/Table2/components/row/Context.d.ts +24 -0
- package/dist/components/Table2/components/row/ExpandedRow.d.ts +6 -0
- package/dist/components/Table2/components/row/Row.d.ts +2 -0
- package/dist/components/Table2/hooks/listeners/useActiveCellStateListener.d.ts +3 -0
- package/dist/components/Table2/hooks/listeners/useActiveRowStateListener.d.ts +3 -0
- package/dist/components/Table2/hooks/listeners/useColumnOffsetStateListener.d.ts +3 -0
- package/dist/components/Table2/hooks/listeners/useFilterStateListener.d.ts +3 -0
- package/dist/components/Table2/hooks/listeners/useRowSelectionListener.d.ts +3 -0
- package/dist/components/Table2/hooks/listeners/useSettingsStateListener.d.ts +3 -0
- package/dist/components/Table2/hooks/useActiveCell.d.ts +26 -0
- package/dist/components/Table2/hooks/useActiveRow.d.ts +10 -0
- package/dist/components/Table2/hooks/useColumnDefinitions.d.ts +37 -0
- package/dist/components/Table2/hooks/useEditMode.d.ts +28 -0
- package/dist/components/Table2/hooks/useGridTemplate.d.ts +2 -0
- package/dist/components/Table2/hooks/useTable.d.ts +46 -0
- package/dist/components/Table2/hooks/useTableShortcuts.d.ts +2 -0
- package/dist/components/Table2/hooks/useVirtualiser.d.ts +23 -0
- package/dist/components/Table2/types.d.ts +148 -0
- package/dist/components/Table2/utilities/cell.d.ts +14 -0
- package/dist/components/Table2/utilities/columns.d.ts +16 -0
- package/dist/components/Table2/utilities/filterFn.d.ts +3 -0
- package/dist/components/Table3/Table3.d.ts +3 -2
- package/dist/components/Table3/components/columns/cell/DisplayCell.d.ts +2 -2
- package/dist/components/Table3/components/columns/footer/Footer.d.ts +2 -2
- package/dist/components/Table3/components/columns/header/Header.d.ts +3 -3
- package/dist/components/Table3/components/columns/header/SortIndicator.d.ts +3 -3
- package/dist/components/Table3/components/columns/styles.d.ts +2 -2
- package/dist/components/Table3/hooks/useTable.d.ts +3 -3
- package/dist/components/Table3/hooks/useTableDataLoader.d.ts +23 -0
- package/dist/components/Table3/types.d.ts +18 -19
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +110 -0
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table2/Table2.js +422 -0
- package/dist/esm/packages/taco/src/components/Table2/Table2.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js +83 -0
- package/dist/esm/packages/taco/src/components/Table2/components/BatchActionsMenu.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js +116 -0
- package/dist/esm/packages/taco/src/components/Table2/components/ColumnSettingsButton.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js +81 -0
- package/dist/esm/packages/taco/src/components/Table2/components/EditModeButton.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js +47 -0
- package/dist/esm/packages/taco/src/components/Table2/components/RowDensityButton.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js +62 -0
- package/dist/esm/packages/taco/src/components/Table2/components/Search.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js +32 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Base.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js +600 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Cell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js +32 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Footer.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js +243 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Header.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js +73 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/Indicator.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js +30 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/ValidationError.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js +39 -0
- package/dist/esm/packages/taco/src/components/Table2/components/column/utils.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js +155 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/FiltersButton.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js +31 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Column.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js +129 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/ColumnFilter.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js +68 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/Comparator.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js +63 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/EmptyFilter.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js +99 -0
- package/dist/esm/packages/taco/src/components/Table2/components/filters/components/InferredControl.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js +58 -0
- package/dist/esm/packages/taco/src/components/Table2/components/row/Context.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js +36 -0
- package/dist/esm/packages/taco/src/components/Table2/components/row/ExpandedRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js +43 -0
- package/dist/esm/packages/taco/src/components/Table2/components/row/Row.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js +19 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useActiveRowStateListener.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js +28 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useColumnOffsetStateListener.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js +12 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useFilterStateListener.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js +18 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useRowSelectionListener.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js +25 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/listeners/useSettingsStateListener.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js +33 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useActiveRow.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js +122 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useColumnDefinitions.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js +112 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useEditMode.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js +34 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useGridTemplate.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js +222 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTable.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js +46 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useTableShortcuts.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js +48 -0
- package/dist/esm/packages/taco/src/components/Table2/hooks/useVirtualiser.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/types.js +18 -0
- package/dist/esm/packages/taco/src/components/Table2/types.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js +41 -0
- package/dist/esm/packages/taco/src/components/Table2/utilities/cell.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js +387 -0
- package/dist/esm/packages/taco/src/components/Table2/utilities/columns.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js +100 -0
- package/dist/esm/packages/taco/src/components/Table2/utilities/filterFn.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/Table3.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/Table3.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js +4 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/DisplayCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js +4 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/cell/EditingCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/footer/Footer.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/Header.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/header/SortIndicator.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/columns/styles.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/ColumnSettings.js +2 -2
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js +4 -3
- package/dist/esm/packages/taco/src/components/Table3/components/toolbar/PrintButton/PrintIFrame.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useConvertChildrenToColumns.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/hooks/{useTableData.js → useTableDataLoader.js} +3 -3
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTableDataLoader.js.map +1 -0
- package/dist/esm/packages/taco/src/components/Table3/types.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js +32 -0
- package/dist/esm/packages/taco/src/components/Truncate/Truncate.js.map +1 -0
- package/dist/esm/packages/taco/src/index.js +3 -2
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/dom.js +2 -1
- package/dist/esm/packages/taco/src/utils/dom.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js +20 -0
- package/dist/esm/packages/taco/src/utils/hooks/useTruncated.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/taco.cjs.development.js +4023 -362
- package/dist/taco.cjs.development.js.map +1 -1
- package/dist/taco.cjs.production.min.js +1 -1
- package/dist/taco.cjs.production.min.js.map +1 -1
- package/package.json +2 -3
- package/types.json +2220 -377
- package/dist/components/Table3/hooks/useTableData.d.ts +0 -23
- package/dist/esm/packages/taco/src/components/Table3/hooks/useTableData.js.map +0 -1
@@ -0,0 +1,600 @@
|
|
1
|
+
import React__default from 'react';
|
2
|
+
import cn from 'classnames';
|
3
|
+
import { useMergedRef } from '../../../../hooks/useMergedRef.js';
|
4
|
+
import { Input } from '../../../Input/Input.js';
|
5
|
+
import { Datepicker } from '../../../Datepicker/Datepicker.js';
|
6
|
+
import { _catch } from '../../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
7
|
+
import { Switch } from '../../../Switch/Switch.js';
|
8
|
+
import { flexRender } from '@tanstack/react-table';
|
9
|
+
import { useRowContext } from '../row/Context.js';
|
10
|
+
import { isInternalColumn } from '../../utilities/columns.js';
|
11
|
+
import { getCellSizingClasses, isKeyboardFocusableElement, getCellAlignmentClasses } from '../../utilities/cell.js';
|
12
|
+
import { ColumnBase } from './Base.js';
|
13
|
+
import { globalFilterFn, columnFilterFn } from '../../utilities/filterFn.js';
|
14
|
+
import { MOVE_DIR } from '../../hooks/useEditMode.js';
|
15
|
+
import { IndicatorReason, Indicator } from './Indicator.js';
|
16
|
+
import { ValidationError } from './ValidationError.js';
|
17
|
+
import { clickableNodeNames, hasChanged, willRowMoveAfterSorting } from './utils.js';
|
18
|
+
|
19
|
+
const Cell = function Cell(props) {
|
20
|
+
var _cell$column$columnDe, _cell$column$columnDe2, _table$options$meta;
|
21
|
+
const {
|
22
|
+
cell,
|
23
|
+
index,
|
24
|
+
isLastRow,
|
25
|
+
rowIndex,
|
26
|
+
rows,
|
27
|
+
scrollToIndex,
|
28
|
+
scrollToOffset,
|
29
|
+
table,
|
30
|
+
tableRef,
|
31
|
+
...columnProps
|
32
|
+
} = props;
|
33
|
+
const meta = table.options.meta;
|
34
|
+
const {
|
35
|
+
addFocussableColumnIndex,
|
36
|
+
focussableColumnIndexes: allFocussableColumnIndexes
|
37
|
+
} = meta;
|
38
|
+
const {
|
39
|
+
editMode: {
|
40
|
+
validationErrors,
|
41
|
+
rowMoveReason
|
42
|
+
},
|
43
|
+
isHovered: isHoveredRow
|
44
|
+
} = useRowContext();
|
45
|
+
const hasValidationErrorsInRow = !!validationErrors;
|
46
|
+
const internalRef = React__default.useRef(null);
|
47
|
+
const controlRef = React__default.useRef(null);
|
48
|
+
const cellClassName = (_cell$column$columnDe = cell.column.columnDef.meta) === null || _cell$column$columnDe === void 0 ? void 0 : _cell$column$columnDe.className;
|
49
|
+
const isActiveRow = meta.activeRowIndex === rowIndex;
|
50
|
+
const isFrozen = !!cell.column.getIsPinned();
|
51
|
+
const isDragging = meta.dragging[cell.row.id];
|
52
|
+
const isSelected = cell.row.getIsSelected();
|
53
|
+
const isDataColumn = !isInternalColumn(cell.column.id);
|
54
|
+
const hasCellControl = !!((_cell$column$columnDe2 = cell.column.columnDef.meta) !== null && _cell$column$columnDe2 !== void 0 && _cell$column$columnDe2.control);
|
55
|
+
const allVisibleColumns = table.getVisibleLeafColumns();
|
56
|
+
const lastColumnIndex = allVisibleColumns.length > 0 ? allVisibleColumns.length - 1 : 0;
|
57
|
+
// editing
|
58
|
+
const isEditingThisRow = meta.editMode.isEditing && isActiveRow;
|
59
|
+
const canEditThisCell = isEditingThisRow && isDataColumn;
|
60
|
+
const isEditingThisCell = canEditThisCell && meta.editMode.columnIndex === index;
|
61
|
+
const isHoveringThisRowWhileEditing = meta.editMode.isEditing && isHoveredRow && !meta.shouldPauseHoverState;
|
62
|
+
const isIndicatorVisible = Object.keys(rowMoveReason).length > 0;
|
63
|
+
React__default.useEffect(() => {
|
64
|
+
// Adds padding to the table so that indicator doesn't get cropped
|
65
|
+
if (isIndicatorVisible && isLastRow) {
|
66
|
+
var _tableRef$current;
|
67
|
+
(_tableRef$current = tableRef.current) === null || _tableRef$current === void 0 ? void 0 : _tableRef$current.classList.add('pb-4');
|
68
|
+
}
|
69
|
+
return () => {
|
70
|
+
var _tableRef$current2;
|
71
|
+
return (_tableRef$current2 = tableRef.current) === null || _tableRef$current2 === void 0 ? void 0 : _tableRef$current2.classList.remove('pb-4');
|
72
|
+
};
|
73
|
+
}, [isIndicatorVisible, isLastRow]);
|
74
|
+
const className = cn('[&>[data-taco="tag"]]:-my-0.5', {
|
75
|
+
'border-b': !isLastRow,
|
76
|
+
'sticky z-[1]': isFrozen,
|
77
|
+
// use isHoveredRow rather than css group-hover/row because we want to hide hover state when keyboard navigating
|
78
|
+
'bg-white': !isActiveRow && !isSelected,
|
79
|
+
'group-hover/row:bg-grey-100': !isActiveRow && !isSelected && !meta.shouldPauseHoverState,
|
80
|
+
'bg-grey-200 group-hover/row:bg-grey-200': isActiveRow && !isSelected,
|
81
|
+
'bg-blue-100': isSelected,
|
82
|
+
'!wcag-blue-500': isDragging,
|
83
|
+
'[&>*]:!grayscale [&_.bg-white]:!bg-grey-100': !isEditingThisRow && isHoveringThisRowWhileEditing,
|
84
|
+
'!bg-red-100': hasValidationErrorsInRow,
|
85
|
+
'z-[1]': isFrozen && isActiveRow,
|
86
|
+
// First column should have higher z-index so that row indicator always show on top of the cell
|
87
|
+
// control components. A z-index of 3, will show the indicator when columns are pinned.
|
88
|
+
'z-[3]': isFrozen && isActiveRow && index === 0,
|
89
|
+
'border-blue !border-y-2 border-x-0': isIndicatorVisible,
|
90
|
+
'border-l-2 rounded-l': isIndicatorVisible && index === 0,
|
91
|
+
'border-r-2 rounded-r': isIndicatorVisible && index === lastColumnIndex
|
92
|
+
}, getCellSizingClasses((_table$options$meta = table.options.meta) === null || _table$options$meta === void 0 ? void 0 : _table$options$meta.rowDensity, (isEditingThisRow || isHoveringThisRowWhileEditing) && hasCellControl), typeof cellClassName === 'function' ? cellClassName(cell.row, table) : cellClassName);
|
93
|
+
const handleMouseDown = event => {
|
94
|
+
// only detect left clicks
|
95
|
+
if (event.button === 0) {
|
96
|
+
const activeElement = document.activeElement;
|
97
|
+
const isActiveElementControl = activeElement === null || activeElement === void 0 ? void 0 : activeElement.closest('[role="cell"]');
|
98
|
+
const hasActiveRowChanged = meta.activeRowIndex !== rowIndex;
|
99
|
+
// When user clicks on a cell that is not in the active row, for some reason blur event is not called on the cell
|
100
|
+
// previous cell control element so we need to manually call it in order to save the changes in that cell
|
101
|
+
if (isActiveElementControl && hasActiveRowChanged) {
|
102
|
+
activeElement.blur();
|
103
|
+
}
|
104
|
+
meta.setActiveRowIndex(rowIndex);
|
105
|
+
if (meta.editMode.isEditing) {
|
106
|
+
if (allFocussableColumnIndexes.includes(index)) {
|
107
|
+
meta.editMode.setColumn(index);
|
108
|
+
} else {
|
109
|
+
meta.editMode.setColumn(allFocussableColumnIndexes[0]);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
};
|
114
|
+
const attributes = {
|
115
|
+
...columnProps,
|
116
|
+
// base props,
|
117
|
+
column: cell.column,
|
118
|
+
table,
|
119
|
+
// dom attributes
|
120
|
+
className,
|
121
|
+
'data-column-index': index,
|
122
|
+
'data-row-index': rowIndex,
|
123
|
+
onMouseDown: handleMouseDown,
|
124
|
+
ref: internalRef,
|
125
|
+
role: 'cell'
|
126
|
+
};
|
127
|
+
const [detailModeEditing, setDetailModeEditing] = React__default.useState(false);
|
128
|
+
// reset the editing state when we move column
|
129
|
+
React__default.useEffect(() => {
|
130
|
+
if (meta.editMode.columnIndex !== index) {
|
131
|
+
setDetailModeEditing(false);
|
132
|
+
}
|
133
|
+
}, [meta.editMode.columnIndex]);
|
134
|
+
React__default.useEffect(() => {
|
135
|
+
if (isEditingThisRow && controlRef.current && isKeyboardFocusableElement(controlRef.current)) {
|
136
|
+
addFocussableColumnIndex(index);
|
137
|
+
}
|
138
|
+
}, [isEditingThisRow, allFocussableColumnIndexes, addFocussableColumnIndex, index]);
|
139
|
+
const moveRow = moveDirection => {
|
140
|
+
if (moveDirection === MOVE_DIR.PREV) {
|
141
|
+
meta.moveToPreviousRow(rows, nextIndex => scrollToIndex(nextIndex - 1));
|
142
|
+
} else if (moveDirection === MOVE_DIR.NEXT) {
|
143
|
+
meta.moveToNextRow(rows, nextIndex => scrollToIndex(nextIndex + 2));
|
144
|
+
}
|
145
|
+
};
|
146
|
+
if (meta.editMode.onSave && hasCellControl && (canEditThisCell || isHoveringThisRowWhileEditing && isDataColumn)) {
|
147
|
+
attributes.onMouseDown = event => {
|
148
|
+
handleMouseDown(event);
|
149
|
+
const target = event.target;
|
150
|
+
const isTargetInput = target !== null && target.nodeName === 'INPUT';
|
151
|
+
// event.target?.select is only truthy for input elements
|
152
|
+
// if event.target is active element, then that means we should select the text
|
153
|
+
if (isTargetInput && target !== document.activeElement) {
|
154
|
+
event.preventDefault();
|
155
|
+
setTimeout(() => {
|
156
|
+
target.select();
|
157
|
+
}, 1);
|
158
|
+
} else if (isTargetInput && target === document.activeElement) {
|
159
|
+
// if user left clicks on the input then we are into edit mode
|
160
|
+
// only detect left clicks
|
161
|
+
if (event.button === 0) {
|
162
|
+
setDetailModeEditing(true);
|
163
|
+
}
|
164
|
+
}
|
165
|
+
};
|
166
|
+
attributes.onBlur = () => {
|
167
|
+
setDetailModeEditing(false);
|
168
|
+
};
|
169
|
+
if (canEditThisCell) {
|
170
|
+
var _allFocussableColumnI, _allFocussableColumnI2;
|
171
|
+
const firstDataColumnIndex = (_allFocussableColumnI = allFocussableColumnIndexes.at(0)) !== null && _allFocussableColumnI !== void 0 ? _allFocussableColumnI : 0;
|
172
|
+
const lastDataColumnIndex = (_allFocussableColumnI2 = allFocussableColumnIndexes.at(-1)) !== null && _allFocussableColumnI2 !== void 0 ? _allFocussableColumnI2 : 0;
|
173
|
+
attributes.onKeyDown = event => {
|
174
|
+
const control = event.target;
|
175
|
+
const isControlInput = control.nodeName === 'INPUT' && (control === null || control === void 0 ? void 0 : control.getAttribute('data-inline-editing-component')) === 'true';
|
176
|
+
// For some reason, Taco Input keyboard event always return true when "event.isDefaultPrevented()" is
|
177
|
+
// called. So we need to check if the control is input or not so that we don't return early.
|
178
|
+
if (!isControlInput && (event.isDefaultPrevented() || event.isPropagationStopped())) {
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
if (control.tagName === 'INPUT') {
|
182
|
+
if (event.key === 'Enter') {
|
183
|
+
event.preventDefault();
|
184
|
+
const input = control;
|
185
|
+
if (!detailModeEditing) {
|
186
|
+
var _input$setSelectionRa, _input$value, _input$value2;
|
187
|
+
(_input$setSelectionRa = input.setSelectionRange) === null || _input$setSelectionRa === void 0 ? void 0 : _input$setSelectionRa.call(input, (_input$value = input.value) === null || _input$value === void 0 ? void 0 : _input$value.length, (_input$value2 = input.value) === null || _input$value2 === void 0 ? void 0 : _input$value2.length);
|
188
|
+
} else {
|
189
|
+
var _input$select;
|
190
|
+
input === null || input === void 0 ? void 0 : (_input$select = input.select) === null || _input$select === void 0 ? void 0 : _input$select.call(input);
|
191
|
+
}
|
192
|
+
setDetailModeEditing(!detailModeEditing);
|
193
|
+
return;
|
194
|
+
}
|
195
|
+
// Datepicker doesn't have keydown event handler its value doesn't change when user types inside
|
196
|
+
// datepicker input, so we need to explicitly enable detail editing mode on typing any alphanumeric
|
197
|
+
// character
|
198
|
+
if (control !== null && control !== void 0 && control.closest('[data-taco="datepicker"]') && /^[a-z0-9]$/i.test(event.key)) {
|
199
|
+
setDetailModeEditing(true);
|
200
|
+
}
|
201
|
+
}
|
202
|
+
// Don't exit edit mode if the target of the escape isn't a child of the cell (e.g. if its a popover).
|
203
|
+
if (event.key === 'Escape' && event.currentTarget.contains(control)) {
|
204
|
+
event.preventDefault();
|
205
|
+
if (detailModeEditing) {
|
206
|
+
setDetailModeEditing(false);
|
207
|
+
} else {
|
208
|
+
var _tableRef$current3;
|
209
|
+
meta.editMode.toggleEditing(false);
|
210
|
+
(_tableRef$current3 = tableRef.current) === null || _tableRef$current3 === void 0 ? void 0 : _tableRef$current3.focus();
|
211
|
+
}
|
212
|
+
return;
|
213
|
+
}
|
214
|
+
if (!detailModeEditing && event.key === 'ArrowLeft' || event.key === 'Tab' && event.shiftKey) {
|
215
|
+
event.preventDefault();
|
216
|
+
const isFirstRow = rowIndex === 0;
|
217
|
+
const isFirstColumn = index === firstDataColumnIndex;
|
218
|
+
if (event.ctrlKey || event.metaKey) {
|
219
|
+
// If the current active column is the first column then we don't do any thing so that focus
|
220
|
+
// remains on the first column.
|
221
|
+
if (!isFirstColumn) {
|
222
|
+
control.blur();
|
223
|
+
meta.editMode.moveToFirstColumn(allFocussableColumnIndexes);
|
224
|
+
}
|
225
|
+
} else {
|
226
|
+
// If it is first row and first column, then don't move column.
|
227
|
+
if (!isFirstRow || !isFirstColumn) {
|
228
|
+
control.blur();
|
229
|
+
meta.editMode.moveToPreviousColumn(allFocussableColumnIndexes, moveRow);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
return;
|
233
|
+
}
|
234
|
+
if (!detailModeEditing && event.key === 'ArrowRight' || event.key === 'Tab' && !event.shiftKey) {
|
235
|
+
event.preventDefault();
|
236
|
+
const isLastColumn = index === lastDataColumnIndex;
|
237
|
+
if (event.ctrlKey || event.metaKey) {
|
238
|
+
// If the current active column is the last column then we don't do any thing so that focus
|
239
|
+
// remains on the last column.
|
240
|
+
if (!isLastColumn) {
|
241
|
+
control.blur();
|
242
|
+
meta.editMode.moveToLastColumn(allFocussableColumnIndexes);
|
243
|
+
}
|
244
|
+
} else {
|
245
|
+
// If it is last row and last column, then don't move column.
|
246
|
+
if (!isLastRow || !isLastColumn) {
|
247
|
+
control.blur();
|
248
|
+
meta.editMode.moveToNextColumn(allFocussableColumnIndexes, moveRow);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
return;
|
252
|
+
}
|
253
|
+
if (!detailModeEditing && event.key === 'ArrowUp') {
|
254
|
+
event.preventDefault();
|
255
|
+
// if it is the first row then return early, so that focus on the cell is not lost
|
256
|
+
if (rowIndex === 0) {
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
control.blur();
|
260
|
+
if (event.ctrlKey || event.metaKey) {
|
261
|
+
meta.setActiveRowIndex(0);
|
262
|
+
scrollToOffset(0);
|
263
|
+
} else {
|
264
|
+
moveRow(MOVE_DIR.PREV);
|
265
|
+
}
|
266
|
+
meta.setShouldPauseHoverState(true);
|
267
|
+
return;
|
268
|
+
}
|
269
|
+
if (!detailModeEditing && event.key === 'ArrowDown') {
|
270
|
+
event.preventDefault();
|
271
|
+
// if it is the last row then return early, so that focus on the cell is not lost
|
272
|
+
if (rowIndex === rows.length - 1) {
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
control.blur();
|
276
|
+
if (event.ctrlKey || event.metaKey) {
|
277
|
+
meta.setActiveRowIndex(rows.length - 1);
|
278
|
+
scrollToIndex(rows.length + 20);
|
279
|
+
} else {
|
280
|
+
moveRow(MOVE_DIR.NEXT);
|
281
|
+
}
|
282
|
+
meta.setShouldPauseHoverState(true);
|
283
|
+
return;
|
284
|
+
}
|
285
|
+
};
|
286
|
+
}
|
287
|
+
return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, attributes), /*#__PURE__*/React__default.createElement(EditingCell, {
|
288
|
+
detailModeEditing: detailModeEditing,
|
289
|
+
cell: cell,
|
290
|
+
cellRef: internalRef,
|
291
|
+
columnIndex: index,
|
292
|
+
isEditingThisCell: isEditingThisCell,
|
293
|
+
onSave: meta.editMode.onSave,
|
294
|
+
rowIndex: rowIndex,
|
295
|
+
table: table,
|
296
|
+
tableRef: tableRef,
|
297
|
+
ref: controlRef,
|
298
|
+
rowValues: rows[rowIndex].original,
|
299
|
+
rowsLength: rows.length,
|
300
|
+
enableDetailModeEditing: () => {
|
301
|
+
if (!detailModeEditing) {
|
302
|
+
setDetailModeEditing(true);
|
303
|
+
}
|
304
|
+
}
|
305
|
+
}));
|
306
|
+
} else {
|
307
|
+
if (meta.onRowClick) {
|
308
|
+
attributes.onClick = event => {
|
309
|
+
const {
|
310
|
+
target
|
311
|
+
} = event;
|
312
|
+
// This check prevents triggering row click, when a click is performed in the dropdown (e.g. Select option or DayPicker date selection)
|
313
|
+
if (internalRef.current && target instanceof HTMLElement && internalRef.current.contains(target)) {
|
314
|
+
var _meta$onRowClick;
|
315
|
+
// Checking that target is clickable element or it is a child of clickable element
|
316
|
+
if (clickableNodeNames.includes(target.tagName) || target.closest(clickableNodeNames.map(tag => `[role=row] ${tag}`).join(','))) {
|
317
|
+
return;
|
318
|
+
}
|
319
|
+
(_meta$onRowClick = meta.onRowClick) === null || _meta$onRowClick === void 0 ? void 0 : _meta$onRowClick.call(meta, cell.row.original);
|
320
|
+
}
|
321
|
+
};
|
322
|
+
}
|
323
|
+
}
|
324
|
+
return /*#__PURE__*/React__default.createElement(ColumnBase, Object.assign({}, attributes), flexRender(cell.column.columnDef.cell, cell.getContext()));
|
325
|
+
};
|
326
|
+
const EditingCell = /*#__PURE__*/React__default.memo( /*#__PURE__*/React__default.forwardRef((props, ref) => {
|
327
|
+
var _cell$column$columnDe3, _cell$column$columnDe4, _cellRef$current2, _cellRef$current2$par, _rowMoveReason$cellId;
|
328
|
+
const {
|
329
|
+
cell,
|
330
|
+
cellRef,
|
331
|
+
columnIndex,
|
332
|
+
detailModeEditing,
|
333
|
+
isEditingThisCell = false,
|
334
|
+
onSave: handleSave,
|
335
|
+
rowIndex,
|
336
|
+
rowValues,
|
337
|
+
table,
|
338
|
+
tableRef,
|
339
|
+
enableDetailModeEditing
|
340
|
+
} = props;
|
341
|
+
const {
|
342
|
+
editMode: {
|
343
|
+
validationErrors,
|
344
|
+
setValidationErrors,
|
345
|
+
rowMoveReason,
|
346
|
+
setRowMoveReason
|
347
|
+
},
|
348
|
+
isHovered
|
349
|
+
} = useRowContext();
|
350
|
+
const controlRef = useMergedRef(ref);
|
351
|
+
const cellId = cell.column.id;
|
352
|
+
const cellValidationError = validationErrors === null || validationErrors === void 0 ? void 0 : validationErrors[cellId];
|
353
|
+
const value = cell.getValue();
|
354
|
+
const ariaLabel = cell.column.columnDef.header;
|
355
|
+
const meta = table.options.meta;
|
356
|
+
const {
|
357
|
+
globalFilter
|
358
|
+
} = table.getState();
|
359
|
+
const [state, setState] = React__default.useState(value);
|
360
|
+
const isHoveringAnotherRowWhileEditing = meta.editMode.isEditing && meta.activeRowIndex !== rowIndex && isHovered;
|
361
|
+
const hasValidationError = !isHoveringAnotherRowWhileEditing && !!cellValidationError;
|
362
|
+
// On each save, the initialValue will be set to the new value of the cell
|
363
|
+
const initialValue = React__default.useRef(value);
|
364
|
+
const stateReset = React__default.useRef(false);
|
365
|
+
// It is important that we let consumers pass a newValue as an argument because when setState is called before
|
366
|
+
// onBlur then saveIfChanged method gets the stale state value. This happens because the rerender hasn't happened
|
367
|
+
// before the saveIfChanged method is called.
|
368
|
+
const saveIfChanged = function (eventOrNewValue) {
|
369
|
+
try {
|
370
|
+
let newValue = state;
|
371
|
+
// if eventOrNewValue is not an event object
|
372
|
+
if (!(eventOrNewValue !== null && eventOrNewValue !== void 0 && eventOrNewValue.target)) {
|
373
|
+
newValue = eventOrNewValue;
|
374
|
+
}
|
375
|
+
const _temp2 = function () {
|
376
|
+
if (hasChanged(value, newValue)) {
|
377
|
+
const _temp = _catch(function () {
|
378
|
+
const updatedRow = {
|
379
|
+
...cell.row.original,
|
380
|
+
[cellId]: newValue
|
381
|
+
};
|
382
|
+
return Promise.resolve(handleSave(updatedRow, cellId)).then(function () {
|
383
|
+
// If sorting is paused then update the last sorted or filtered rows to store the newly updated row
|
384
|
+
if (meta.shouldPauseSortingAndFiltering) {
|
385
|
+
meta.lastSortedOrFilteredRows.current = meta.lastSortedOrFilteredRows.current.map(row => {
|
386
|
+
if (row.id === cell.row.id) {
|
387
|
+
row.original = updatedRow;
|
388
|
+
}
|
389
|
+
return row;
|
390
|
+
});
|
391
|
+
}
|
392
|
+
// Reset error if save was successful
|
393
|
+
setValidationErrors(null);
|
394
|
+
});
|
395
|
+
}, function (error) {
|
396
|
+
setValidationErrors({
|
397
|
+
...validationErrors,
|
398
|
+
...error
|
399
|
+
});
|
400
|
+
});
|
401
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
402
|
+
}
|
403
|
+
}();
|
404
|
+
return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
|
405
|
+
} catch (e) {
|
406
|
+
return Promise.reject(e);
|
407
|
+
}
|
408
|
+
};
|
409
|
+
// Ensures we "auto focus" the field if the cell is being edited.
|
410
|
+
React__default.useEffect(() => {
|
411
|
+
var _meta$tableRef$curren;
|
412
|
+
const isFocusInsideTable = (_meta$tableRef$curren = meta.tableRef.current) === null || _meta$tableRef$curren === void 0 ? void 0 : _meta$tableRef$curren.contains(document.activeElement);
|
413
|
+
// When control is blurred then body gets the focus that's why we have to make sure if activeElement
|
414
|
+
// is body then we focus the cell if it is being edited.
|
415
|
+
const isBodyFocussed = document.body === document.activeElement;
|
416
|
+
// Don't focus cell if any table popup(filter popup, column settings popup) is open.
|
417
|
+
if (isEditingThisCell && (isFocusInsideTable || isBodyFocussed)) {
|
418
|
+
var _controlRef$current, _controlRef$current$f;
|
419
|
+
(_controlRef$current = controlRef.current) === null || _controlRef$current === void 0 ? void 0 : (_controlRef$current$f = _controlRef$current.focus) === null || _controlRef$current$f === void 0 ? void 0 : _controlRef$current$f.call(_controlRef$current);
|
420
|
+
}
|
421
|
+
}, [isEditingThisCell, controlRef.current]);
|
422
|
+
const pinnedColumnsWidth = React__default.useMemo(() => {
|
423
|
+
const pinnedColumns = table.getState().columnPinning.left;
|
424
|
+
if (Array.isArray(pinnedColumns) && pinnedColumns.length > 0) {
|
425
|
+
const lastFrozenColumn = pinnedColumns[pinnedColumns.length - 1];
|
426
|
+
const lastFrozenColumnOffset = meta.columnOffsets[lastFrozenColumn];
|
427
|
+
if (lastFrozenColumnOffset !== undefined) {
|
428
|
+
var _table$getState$colum;
|
429
|
+
return lastFrozenColumnOffset + ((_table$getState$colum = table.getState().columnSizing[lastFrozenColumn]) !== null && _table$getState$colum !== void 0 ? _table$getState$colum : 0);
|
430
|
+
}
|
431
|
+
}
|
432
|
+
return 0;
|
433
|
+
}, [meta.columnOffsets, table.getState().columnSizing]);
|
434
|
+
React__default.useEffect(() => {
|
435
|
+
if (hasChanged(initialValue.current, state)) {
|
436
|
+
var _controlRef$current2;
|
437
|
+
// For an input we want to make sure that if the value is changed then we go into detail mode, so that
|
438
|
+
// arrow keys doesn't trigger the quick mode shortcuts.
|
439
|
+
if (((_controlRef$current2 = controlRef.current) === null || _controlRef$current2 === void 0 ? void 0 : _controlRef$current2.nodeName) === 'INPUT') {
|
440
|
+
enableDetailModeEditing();
|
441
|
+
}
|
442
|
+
showIndicator();
|
443
|
+
} else {
|
444
|
+
hideIndicator();
|
445
|
+
}
|
446
|
+
return hideIndicator;
|
447
|
+
}, [state]);
|
448
|
+
// This effect makes sure we select the input control value when escape key is pressed
|
449
|
+
React__default.useEffect(() => {
|
450
|
+
var _controlRef$current3, _controlRef$current4;
|
451
|
+
const isControlInput = ((_controlRef$current3 = controlRef.current) === null || _controlRef$current3 === void 0 ? void 0 : _controlRef$current3.nodeName) === 'INPUT' && ((_controlRef$current4 = controlRef.current) === null || _controlRef$current4 === void 0 ? void 0 : _controlRef$current4.getAttribute('data-inline-editing-component')) === 'true';
|
452
|
+
if (stateReset.current && isControlInput) {
|
453
|
+
var _controlRef$current5;
|
454
|
+
(_controlRef$current5 = controlRef.current) === null || _controlRef$current5 === void 0 ? void 0 : _controlRef$current5.select();
|
455
|
+
}
|
456
|
+
stateReset.current = false;
|
457
|
+
}, [stateReset.current]);
|
458
|
+
const handleFocus = event => {
|
459
|
+
var _event$target, _cellRef$current;
|
460
|
+
meta.editMode.setColumn(columnIndex);
|
461
|
+
if ((_event$target = event.target) !== null && _event$target !== void 0 && _event$target.select) {
|
462
|
+
var _event$target2;
|
463
|
+
(_event$target2 = event.target) === null || _event$target2 === void 0 ? void 0 : _event$target2.select();
|
464
|
+
}
|
465
|
+
// ensure the field is always visible (e.g. not hidden behind the pinned columns)
|
466
|
+
const rect = (_cellRef$current = cellRef.current) === null || _cellRef$current === void 0 ? void 0 : _cellRef$current.getBoundingClientRect();
|
467
|
+
const leftOffset = meta.columnOffsets[cellId];
|
468
|
+
if (rect && leftOffset && rect.left < pinnedColumnsWidth) {
|
469
|
+
var _tableRef$current4;
|
470
|
+
(_tableRef$current4 = tableRef.current) === null || _tableRef$current4 === void 0 ? void 0 : _tableRef$current4.scrollTo(leftOffset - pinnedColumnsWidth, tableRef.current.scrollTop);
|
471
|
+
}
|
472
|
+
};
|
473
|
+
// In order to reset the value of an input when escape key is pressed this keydown handler is required.
|
474
|
+
// Instead of adding this event handler in parent component, this handler is added here because we have access
|
475
|
+
// to the state handler of the control component.
|
476
|
+
const handleKeyDown = event => {
|
477
|
+
const control = event.target;
|
478
|
+
const isControlInput = control.nodeName === 'INPUT' && (control === null || control === void 0 ? void 0 : control.getAttribute('data-inline-editing-component')) === 'true';
|
479
|
+
if (isControlInput && event.key === 'Escape') {
|
480
|
+
setState(initialValue.current);
|
481
|
+
stateReset.current = true;
|
482
|
+
}
|
483
|
+
};
|
484
|
+
const showIndicator = () => {
|
485
|
+
var _table$getState$sorti;
|
486
|
+
let willRowMoveReason = null;
|
487
|
+
const isFilteredByGlobalFilter = Object.values({
|
488
|
+
...rowValues,
|
489
|
+
[cellId]: state
|
490
|
+
}).some(cellValue =>
|
491
|
+
// Global filter can be undefined when there is no text being searched so we pass an empty string to
|
492
|
+
// globalFilterFn as query in that case.
|
493
|
+
globalFilterFn(String(cellValue), globalFilter ? String(globalFilter) : ''));
|
494
|
+
if (!isFilteredByGlobalFilter) {
|
495
|
+
willRowMoveReason = IndicatorReason.SEARCH;
|
496
|
+
} else if (cell.column.getIsFiltered() && !columnFilterFn(state, cell.column.getFilterValue())) {
|
497
|
+
willRowMoveReason = IndicatorReason.FILTER;
|
498
|
+
} else if (!willRowMoveReason && cell.column.getIsSorted() && willRowMoveAfterSorting(state, cell, rowIndex, table.getRowModel().rows, !!((_table$getState$sorti = table.getState().sorting.find(s => s.id === cell.column.id)) !== null && _table$getState$sorti !== void 0 && _table$getState$sorti.desc))) {
|
499
|
+
willRowMoveReason = IndicatorReason.SORTING;
|
500
|
+
}
|
501
|
+
if (willRowMoveReason !== null) {
|
502
|
+
meta.setShouldPauseSortingAndFiltering(true);
|
503
|
+
setRowMoveReason({
|
504
|
+
[cellId]: willRowMoveReason
|
505
|
+
});
|
506
|
+
}
|
507
|
+
};
|
508
|
+
const hideIndicator = () => {
|
509
|
+
setRowMoveReason(prevState => {
|
510
|
+
const newState = {
|
511
|
+
...prevState
|
512
|
+
};
|
513
|
+
delete newState[cellId];
|
514
|
+
return newState;
|
515
|
+
});
|
516
|
+
};
|
517
|
+
const cellControl = (_cell$column$columnDe3 = cell.column.columnDef.meta) === null || _cell$column$columnDe3 === void 0 ? void 0 : _cell$column$columnDe3.control;
|
518
|
+
const attributes = {
|
519
|
+
'aria-label': ariaLabel,
|
520
|
+
onBlur: saveIfChanged,
|
521
|
+
onFocus: handleFocus,
|
522
|
+
ref,
|
523
|
+
// This is a temporary fix to enable up/down arrow key shortcuts on input in quick mode. For some reason,
|
524
|
+
// the preventDefault is true on Taco Input, so the keyboard shortcuts doesn't work. By adding this
|
525
|
+
// data attribute we make sure the event is coming from a control component, and then we can make sure
|
526
|
+
// keyboard shortcut works as expected.
|
527
|
+
'data-inline-editing-component': 'true'
|
528
|
+
};
|
529
|
+
const className = cn(getCellAlignmentClasses((_cell$column$columnDe4 = cell.column.columnDef.meta) === null || _cell$column$columnDe4 === void 0 ? void 0 : _cell$column$columnDe4.align));
|
530
|
+
const indicatorMountNode = (_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.querySelector(':first-child');
|
531
|
+
let controlComponent;
|
532
|
+
const detailModeClassName = cn({
|
533
|
+
'!yt-focus-dark': detailModeEditing
|
534
|
+
});
|
535
|
+
if (cellControl) {
|
536
|
+
if (typeof cellControl === 'function') {
|
537
|
+
controlComponent = cellControl({
|
538
|
+
invalid: hasValidationError,
|
539
|
+
onBlur: saveIfChanged,
|
540
|
+
onFocus: handleFocus,
|
541
|
+
ref: controlRef,
|
542
|
+
setValue: setState,
|
543
|
+
value: state,
|
544
|
+
'data-inline-editing-component': 'true'
|
545
|
+
}, cell.row.original);
|
546
|
+
} else {
|
547
|
+
switch (cellControl) {
|
548
|
+
case 'datepicker':
|
549
|
+
controlComponent = /*#__PURE__*/React__default.createElement(Datepicker, Object.assign({}, attributes, {
|
550
|
+
className: cn({
|
551
|
+
'[&_input]:!shadow-[0_0_0_4px_rgba(0,99,255,0.25)]': detailModeEditing
|
552
|
+
}),
|
553
|
+
invalid: hasValidationError,
|
554
|
+
onBlur: event => {
|
555
|
+
const newDate = event.detail;
|
556
|
+
saveIfChanged(newDate);
|
557
|
+
},
|
558
|
+
onChange: event => {
|
559
|
+
setState(event.detail);
|
560
|
+
},
|
561
|
+
ref: controlRef,
|
562
|
+
value: state
|
563
|
+
}));
|
564
|
+
break;
|
565
|
+
case 'switch':
|
566
|
+
controlComponent = /*#__PURE__*/React__default.createElement(Switch, Object.assign({}, attributes, {
|
567
|
+
className: cn('mx-2 mt-1.5', detailModeClassName),
|
568
|
+
checked: Boolean(state),
|
569
|
+
onChange: setState,
|
570
|
+
ref: controlRef
|
571
|
+
}));
|
572
|
+
break;
|
573
|
+
default:
|
574
|
+
controlComponent = /*#__PURE__*/React__default.createElement(Input, Object.assign({}, attributes, {
|
575
|
+
className: cn(className, detailModeClassName),
|
576
|
+
invalid: hasValidationError,
|
577
|
+
onChange: event => {
|
578
|
+
setState(event.target.value);
|
579
|
+
},
|
580
|
+
ref: controlRef,
|
581
|
+
value: String(state !== null && state !== void 0 ? state : ''),
|
582
|
+
onKeyDown: handleKeyDown
|
583
|
+
}));
|
584
|
+
break;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
}
|
588
|
+
const indicatorReason = (_rowMoveReason$cellId = rowMoveReason[cellId]) !== null && _rowMoveReason$cellId !== void 0 ? _rowMoveReason$cellId : null;
|
589
|
+
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, indicatorReason !== null && /*#__PURE__*/React__default.createElement(Indicator, {
|
590
|
+
reason: indicatorReason,
|
591
|
+
columnName: String(cell.column.columnDef.header),
|
592
|
+
mountNode: indicatorMountNode,
|
593
|
+
validationErrors: validationErrors
|
594
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
595
|
+
className: "relative flex-grow"
|
596
|
+
}, controlComponent, hasValidationError && /*#__PURE__*/React__default.createElement(ValidationError, null, String(cellValidationError))));
|
597
|
+
}));
|
598
|
+
|
599
|
+
export { Cell };
|
600
|
+
//# sourceMappingURL=Cell.js.map
|