@vuu-ui/vuu-table 2.1.19-beta.1 → 2.1.19-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/package.json +12 -13
  2. package/src/CellFocusState.mjs +25 -0
  3. package/src/Row.mjs +83 -0
  4. package/src/Table.css.js +441 -0
  5. package/src/Table.mjs +297 -0
  6. package/src/VirtualColSpan.mjs +12 -0
  7. package/src/applyHighlighting.mjs +28 -0
  8. package/src/bulk-edit/BulkEditPanel.css.js +27 -0
  9. package/src/bulk-edit/BulkEditPanel.mjs +77 -0
  10. package/src/bulk-edit/ColumnCascadingUpdateEditor.css.js +86 -0
  11. package/src/bulk-edit/ColumnCascadingUpdateEditor.mjs +59 -0
  12. package/src/bulk-edit/InsertNewRowEditor.css.js +86 -0
  13. package/src/bulk-edit/InsertNewRowEditor.mjs +59 -0
  14. package/src/bulk-edit/useBulkEditPanel.mjs +61 -0
  15. package/src/bulk-edit/useColumnCascadingEditor.mjs +124 -0
  16. package/src/cell-block/CellBlock.css.js +95 -0
  17. package/src/cell-block/CellBlock.mjs +32 -0
  18. package/src/cell-block/cellblock-utils.mjs +114 -0
  19. package/src/cell-block/useCellBlockSelection.mjs +245 -0
  20. package/src/cell-renderers/checkbox-cell/CheckboxCell.css.js +16 -0
  21. package/src/cell-renderers/checkbox-cell/CheckboxCell.mjs +56 -0
  22. package/src/cell-renderers/checkbox-cell/index.mjs +1 -0
  23. package/src/cell-renderers/checkbox-row-selector/CheckboxRowSelectorCell.css.js +19 -0
  24. package/src/cell-renderers/checkbox-row-selector/CheckboxRowSelectorCell.mjs +34 -0
  25. package/src/cell-renderers/checkbox-row-selector/index.mjs +1 -0
  26. package/src/cell-renderers/index.mjs +4 -0
  27. package/src/cell-renderers/input-cell/InputCell.css.js +81 -0
  28. package/src/cell-renderers/input-cell/InputCell.mjs +73 -0
  29. package/src/cell-renderers/input-cell/index.mjs +1 -0
  30. package/src/cell-renderers/input-cell/useInputCell.mjs +199 -0
  31. package/src/cell-renderers/toggle-cell/ToggleCell.css.js +31 -0
  32. package/src/cell-renderers/toggle-cell/ToggleCell.mjs +47 -0
  33. package/src/cell-renderers/toggle-cell/index.mjs +1 -0
  34. package/src/column-header-pill/ColumnHeaderPill.css.js +34 -0
  35. package/src/column-header-pill/ColumnHeaderPill.mjs +39 -0
  36. package/src/column-header-pill/GroupColumnPill.css.js +10 -0
  37. package/src/column-header-pill/GroupColumnPill.mjs +33 -0
  38. package/src/column-header-pill/SortIndicator.css.js +15 -0
  39. package/src/column-header-pill/SortIndicator.mjs +29 -0
  40. package/src/column-header-pill/index.mjs +3 -0
  41. package/src/column-resizing/ColumnResizer.css.js +32 -0
  42. package/src/column-resizing/ColumnResizer.mjs +69 -0
  43. package/src/column-resizing/index.mjs +2 -0
  44. package/src/column-resizing/useTableColumnResize.mjs +57 -0
  45. package/src/data-row/DataRow.mjs +298 -0
  46. package/src/header-cell/GroupHeaderCell.css.js +91 -0
  47. package/src/header-cell/GroupHeaderCell.mjs +98 -0
  48. package/src/header-cell/HeaderCell.css.js +182 -0
  49. package/src/header-cell/HeaderCell.mjs +126 -0
  50. package/src/header-cell/index.mjs +2 -0
  51. package/src/index.mjs +20 -0
  52. package/src/pagination/PaginationControl.css.js +18 -0
  53. package/src/pagination/PaginationControl.mjs +34 -0
  54. package/src/pagination/index.mjs +1 -0
  55. package/src/pagination/usePagination.mjs +29 -0
  56. package/src/table-cell/TableCell.css.js +67 -0
  57. package/src/table-cell/TableCell.mjs +54 -0
  58. package/src/table-cell/TableGroupCell.css.js +91 -0
  59. package/src/table-cell/TableGroupCell.mjs +61 -0
  60. package/src/table-cell/index.mjs +2 -0
  61. package/src/table-config/useTableConfig.mjs +49 -0
  62. package/src/table-config.mjs +38 -0
  63. package/src/table-data-source/DataRowMovingWindow.mjs +66 -0
  64. package/src/table-data-source/useDataSource.mjs +177 -0
  65. package/src/table-dom-utils.mjs +162 -0
  66. package/src/table-header/HeaderProvider.mjs +14 -0
  67. package/src/table-header/TableHeader.mjs +182 -0
  68. package/src/table-header/index.mjs +2 -0
  69. package/src/table-header/useTableHeader.mjs +69 -0
  70. package/src/useCell.mjs +22 -0
  71. package/src/useCellEditing.mjs +58 -0
  72. package/src/useCellFocus.mjs +112 -0
  73. package/src/useControlledTableNavigation.mjs +34 -0
  74. package/src/useEditableCell.mjs +18 -0
  75. package/src/useInitialValue.mjs +6 -0
  76. package/src/useKeyboardNavigation.mjs +275 -0
  77. package/src/useMeasuredHeight.mjs +44 -0
  78. package/src/useResizeObserver.mjs +118 -0
  79. package/src/useRowClassNameGenerators.mjs +21 -0
  80. package/src/useSelection.mjs +101 -0
  81. package/src/useTable.mjs +588 -0
  82. package/src/useTableContextMenu.mjs +54 -0
  83. package/src/useTableModel.mjs +344 -0
  84. package/src/useTableScroll.mjs +382 -0
  85. package/src/useTableViewport.mjs +120 -0
@@ -0,0 +1,245 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { isArrowKey, queryClosest } from "@vuu-ui/vuu-utils";
3
+ import { useCallback, useRef, useState } from "react";
4
+ import { getAriaCellPos, getNextCellPos, getTableCell } from "../table-dom-utils.mjs";
5
+ import { CellBlock } from "./CellBlock.mjs";
6
+ import { getTableCellBlock, getTextFromCells, isNullCellBox, outsideBox, refState, setElementBox, updateCellBlockClassName } from "./cellblock-utils.mjs";
7
+ const clone = (posTuple)=>posTuple.slice();
8
+ const NullHandler = ()=>console.error("no handler installed");
9
+ const mouseHandlers = {
10
+ mouseMove: NullHandler,
11
+ mouseMovePreDrag: NullHandler,
12
+ mouseUp: NullHandler,
13
+ mouseUpPreDrag: NullHandler
14
+ };
15
+ const mouseType = (name)=>name.startsWith("mouseMove") ? "mousemove" : "mouseup";
16
+ const DRAG_THRESHOLD = 5;
17
+ const useCellBlockSelection = ({ allowCellBlockSelection, columnCount = 0, containerRef, onSelectCellBlock, rowCount = 0 })=>{
18
+ const [cellBlock, setCellBlock] = useState(null);
19
+ const stateRef = useRef(refState);
20
+ const handlersRef = useRef(mouseHandlers);
21
+ const handleCopy = useCallback(async ()=>{
22
+ const { startCell, endCell } = stateRef.current;
23
+ if (startCell && endCell) {
24
+ const tsvText = getTextFromCells(startCell, endCell);
25
+ const type = "text/plain";
26
+ const blob = new Blob([
27
+ tsvText
28
+ ], {
29
+ type
30
+ });
31
+ const data = [
32
+ new ClipboardItem({
33
+ [type]: blob
34
+ })
35
+ ];
36
+ await navigator.clipboard.write(data);
37
+ }
38
+ }, []);
39
+ const cellBlockRef = useCallback((el)=>{
40
+ stateRef.current.cellBlock = el;
41
+ }, []);
42
+ const createCellBlock = useCallback((method = "mouse")=>{
43
+ const { startBox, startCell } = stateRef.current;
44
+ if (startCell) {
45
+ const table = queryClosest(startCell, ".vuuTable");
46
+ if (table) table.classList.add(`vuu-cellblock-select-in-progress-${method}`);
47
+ setElementBox(startCell, startBox);
48
+ startCell.classList.add("vuu-cellblock-start");
49
+ setCellBlock(/*#__PURE__*/ jsx(CellBlock, {
50
+ onCopy: handleCopy,
51
+ ref: cellBlockRef
52
+ }));
53
+ }
54
+ }, [
55
+ cellBlockRef,
56
+ handleCopy
57
+ ]);
58
+ const initializeStateRef = useCallback(()=>{
59
+ const { cellBlock, cellBlockClassName, startCell, endCell } = stateRef.current;
60
+ if (startCell) startCell.classList.remove("vuu-cellblock-start");
61
+ if (endCell) endCell.classList.remove("vuu-cellblock-end");
62
+ if (cellBlock?.classList.contains(cellBlockClassName)) cellBlock.classList.remove(cellBlockClassName);
63
+ const { endBox, startBox } = refState;
64
+ stateRef.current = {
65
+ ...refState,
66
+ cellBlock,
67
+ endBox: {
68
+ ...endBox
69
+ },
70
+ endPos: [
71
+ -1,
72
+ -1
73
+ ],
74
+ startBox: {
75
+ ...startBox
76
+ },
77
+ startPos: [
78
+ -1,
79
+ -1
80
+ ]
81
+ };
82
+ }, []);
83
+ const addMouseListener = useCallback((mouseOperation, handler)=>{
84
+ window.addEventListener(mouseType(mouseOperation), handler);
85
+ handlersRef.current[mouseOperation] = handler;
86
+ }, []);
87
+ const removeMouseListener = useCallback((name)=>{
88
+ window.removeEventListener(mouseType(name), handlersRef.current[name]);
89
+ }, []);
90
+ handlersRef.current.mouseMove = useCallback((evt)=>{
91
+ const { clientX: x, clientY: y } = evt;
92
+ const { endBox, startBox } = stateRef.current;
93
+ if (outsideBox(startBox, x, y) && outsideBox(endBox, x, y)) {
94
+ const cell = queryClosest(evt.target, ".vuuTableCell, .vuuCellBlock");
95
+ if (cell?.classList.contains("vuuTableCell")) {
96
+ setElementBox(cell, endBox);
97
+ stateRef.current.endCell = cell;
98
+ updateCellBlockClassName(stateRef.current);
99
+ }
100
+ }
101
+ }, []);
102
+ handlersRef.current.mouseUp = useCallback((evt)=>{
103
+ removeMouseListener("mouseMove");
104
+ removeMouseListener("mouseUp");
105
+ const { cellBlock, endCell, startCell } = stateRef.current;
106
+ const table = queryClosest(evt.target, ".vuuTable");
107
+ endCell?.classList.add("vuu-cellblock-end");
108
+ if (table) table.classList.remove("vuu-cellblock-select-in-progress-mouse");
109
+ if (startCell && endCell) {
110
+ const tableCellBlock = getTableCellBlock(startCell, endCell);
111
+ onSelectCellBlock?.(tableCellBlock);
112
+ }
113
+ if (cellBlock) cellBlock.focus();
114
+ }, [
115
+ onSelectCellBlock,
116
+ removeMouseListener
117
+ ]);
118
+ handlersRef.current.mouseMovePreDrag = useCallback((evt)=>{
119
+ const { current: state } = stateRef;
120
+ const { mouseStartX, mouseStartY } = state;
121
+ const x = state.mousePosX = evt.clientX;
122
+ const y = state.mousePosY = evt.clientY;
123
+ const distance = Math.max(Math.abs(x - mouseStartX), Math.abs(y - mouseStartY));
124
+ if (distance > DRAG_THRESHOLD) {
125
+ createCellBlock("mouse");
126
+ const { mouseMove, mouseUp } = handlersRef.current;
127
+ removeMouseListener("mouseMovePreDrag");
128
+ removeMouseListener("mouseUpPreDrag");
129
+ addMouseListener("mouseMove", mouseMove);
130
+ addMouseListener("mouseUp", mouseUp);
131
+ }
132
+ }, [
133
+ addMouseListener,
134
+ createCellBlock,
135
+ removeMouseListener
136
+ ]);
137
+ handlersRef.current.mouseUpPreDrag = useCallback(()=>{
138
+ removeMouseListener("mouseMovePreDrag");
139
+ removeMouseListener("mouseUpPreDrag");
140
+ }, [
141
+ removeMouseListener
142
+ ]);
143
+ const handleNativeMouseOver = useCallback((evt)=>{
144
+ const cell = queryClosest(evt.target, ".vuuTableCell");
145
+ if (cell) {
146
+ stateRef.current.endPos = getAriaCellPos(cell);
147
+ stateRef.current.endCell?.classList.remove("vuu-cellblock-end");
148
+ stateRef.current.endCell = cell;
149
+ setElementBox(cell, stateRef.current.endBox);
150
+ updateCellBlockClassName(stateRef.current);
151
+ cell?.classList.add("vuu-cellblock-end");
152
+ }
153
+ }, []);
154
+ const handleNativeMouseUp = useCallback(()=>{
155
+ window.removeEventListener("mouseover", handleNativeMouseOver);
156
+ }, [
157
+ handleNativeMouseOver
158
+ ]);
159
+ const handleMouseDown = useCallback((evt)=>{
160
+ if (0 === evt.button) {
161
+ initializeStateRef();
162
+ const { current: state } = stateRef;
163
+ const cell = queryClosest(evt.target, ".vuuTableCell");
164
+ if (cell) {
165
+ state.startCell = cell;
166
+ state.mouseStartX = evt.clientX;
167
+ state.mouseStartY = evt.clientY;
168
+ const { mouseMovePreDrag, mouseUpPreDrag } = handlersRef.current;
169
+ addMouseListener("mouseMovePreDrag", mouseMovePreDrag);
170
+ addMouseListener("mouseUpPreDrag", mouseUpPreDrag);
171
+ console.log("register mouse enter");
172
+ window.addEventListener("mouseover", handleNativeMouseOver);
173
+ window.addEventListener("mouseup", handleNativeMouseUp);
174
+ }
175
+ }
176
+ }, [
177
+ addMouseListener,
178
+ handleNativeMouseOver,
179
+ handleNativeMouseUp,
180
+ initializeStateRef
181
+ ]);
182
+ const nativeKeyDownHandlerRef = useRef(NullHandler);
183
+ const handleNativeKeyUp = useCallback((evt)=>{
184
+ if ("Shift" === evt.key) {
185
+ const { endCell } = stateRef.current;
186
+ const table = queryClosest(evt.target, ".vuuTable");
187
+ endCell?.classList.add("vuu-cellblock-end");
188
+ if (table) table.classList.remove("vuu-cellblock-select-in-progress-keyboard");
189
+ window.removeEventListener("keydown", nativeKeyDownHandlerRef.current, {
190
+ capture: true
191
+ });
192
+ window.removeEventListener("keyup", handleNativeKeyUp, {
193
+ capture: true
194
+ });
195
+ }
196
+ }, []);
197
+ const handleNativeKeyDown = nativeKeyDownHandlerRef.current = useCallback(({ key })=>{
198
+ if (isArrowKey(key)) {
199
+ const { endBox, endPos, startBox } = stateRef.current;
200
+ if (isNullCellBox(startBox)) createCellBlock("keyboard");
201
+ const nextCell = getNextCellPos(key, endPos, columnCount, rowCount);
202
+ stateRef.current.endPos = nextCell;
203
+ const cell = getTableCell(containerRef, nextCell);
204
+ stateRef.current.endCell = cell;
205
+ setElementBox(cell, endBox);
206
+ updateCellBlockClassName(stateRef.current);
207
+ }
208
+ }, [
209
+ columnCount,
210
+ containerRef,
211
+ createCellBlock,
212
+ rowCount
213
+ ]);
214
+ const handleKeyDown = useCallback((evt)=>{
215
+ console.log("[useCellBlockSelection] handleKeyDown (only interested in Shift key)");
216
+ if ("Shift" === evt.key) {
217
+ initializeStateRef();
218
+ const cell = queryClosest(evt.target, ".vuuTableCell");
219
+ if (cell) {
220
+ const startPos = getAriaCellPos(cell);
221
+ stateRef.current.startPos = startPos;
222
+ stateRef.current.endPos = clone(startPos);
223
+ const { current: state } = stateRef;
224
+ state.startCell = cell;
225
+ window.addEventListener("keydown", handleNativeKeyDown, {
226
+ capture: true
227
+ });
228
+ window.addEventListener("keyup", handleNativeKeyUp, {
229
+ capture: true
230
+ });
231
+ evt.preventDefault();
232
+ }
233
+ }
234
+ }, [
235
+ handleNativeKeyDown,
236
+ handleNativeKeyUp,
237
+ initializeStateRef
238
+ ]);
239
+ return {
240
+ cellBlock,
241
+ onKeyDown: allowCellBlockSelection ? handleKeyDown : void 0,
242
+ onMouseDown: allowCellBlockSelection ? handleMouseDown : void 0
243
+ };
244
+ };
245
+ export { useCellBlockSelection };
@@ -0,0 +1,16 @@
1
+ const css = `
2
+ .vuuCheckboxCell-checkbox {
3
+ border: 2px solid #0000;
4
+
5
+ & input:focus-visible + .saltCheckboxIcon {
6
+ outline: none;
7
+ }
8
+ }
9
+
10
+ .vuuTableCell-editable .vuuCheckboxCell-checkbox:focus-within {
11
+ border: solid 2px var(--salt-focused-outlineColor);
12
+ }
13
+
14
+
15
+ `;
16
+ export default css;
@@ -0,0 +1,56 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { memo, useCallback } from "react";
3
+ import { Checkbox } from "@salt-ds/core";
4
+ import { dataColumnAndKeyUnchanged, dispatchCustomEvent, isRpcSuccess, registerComponent } from "@vuu-ui/vuu-utils";
5
+ import { useComponentCssInjection } from "@salt-ds/styles";
6
+ import { useWindow } from "@salt-ds/window";
7
+ import CheckboxCell from "./CheckboxCell.css";
8
+ const classBase = "vuuCheckboxCell";
9
+ const CheckboxCell_CheckboxCell = /*#__PURE__*/ memo(({ column, dataRow, onEdit })=>{
10
+ const targetWindow = useWindow();
11
+ useComponentCssInjection({
12
+ testId: "vuu-checkbox-cell",
13
+ css: CheckboxCell,
14
+ window: targetWindow
15
+ });
16
+ const isChecked = !!dataRow[column.name];
17
+ const handleCommit = useCallback((value)=>async (evt)=>{
18
+ const res = await onEdit?.({
19
+ previousValue: isChecked,
20
+ value
21
+ }, "commit");
22
+ if (isRpcSuccess(res)) dispatchCustomEvent(evt.target, "vuu-commit");
23
+ return res;
24
+ }, [
25
+ isChecked,
26
+ onEdit
27
+ ]);
28
+ const handleKeyDown = useCallback(async (evt)=>{
29
+ if ("Enter" === evt.key) {
30
+ const res = await onEdit?.({
31
+ previousValue: isChecked,
32
+ value: !isChecked
33
+ }, "commit");
34
+ if (isRpcSuccess(res)) dispatchCustomEvent(evt.target, "vuu-commit");
35
+ }
36
+ }, [
37
+ isChecked,
38
+ onEdit
39
+ ]);
40
+ const className = `${classBase}-checkbox`;
41
+ return column.editable ? /*#__PURE__*/ jsx(Checkbox, {
42
+ checked: isChecked,
43
+ className: className,
44
+ onClick: handleCommit(!isChecked),
45
+ onKeyDown: handleKeyDown
46
+ }) : /*#__PURE__*/ jsx(Checkbox, {
47
+ checked: isChecked,
48
+ className: className,
49
+ disabled: true
50
+ });
51
+ }, dataColumnAndKeyUnchanged);
52
+ CheckboxCell_CheckboxCell.displayName = "CheckboxCell";
53
+ registerComponent("checkbox-cell", CheckboxCell_CheckboxCell, "cell-renderer", {
54
+ serverDataType: "boolean"
55
+ });
56
+ export { CheckboxCell_CheckboxCell as CheckboxCell };
@@ -0,0 +1 @@
1
+ export * from "./CheckboxCell.mjs";
@@ -0,0 +1,19 @@
1
+ const css = `
2
+ .vuuTableCell {
3
+ & .vuuCheckboxRowSelector {
4
+ align-items: center;
5
+ height: 100%;
6
+
7
+ & .saltCheckboxIcon {
8
+ margin-top: 0;
9
+ }
10
+ }
11
+
12
+ & .vuuCheckboxRowSelectorIcon {
13
+ margin-top: calc(var(--row-height) / 2 - 6px);
14
+ }
15
+ }
16
+
17
+
18
+ `;
19
+ export default css;
@@ -0,0 +1,34 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { registerComponent } from "@vuu-ui/vuu-utils";
3
+ import { Checkbox } from "@salt-ds/core";
4
+ import { useComponentCssInjection } from "@salt-ds/styles";
5
+ import { useWindow } from "@salt-ds/window";
6
+ import CheckboxRowSelectorCell from "./CheckboxRowSelectorCell.css";
7
+ import { useCallback } from "react";
8
+ const inputProps = {
9
+ "aria-label": "Press space to select row"
10
+ };
11
+ const CheckboxRowSelectorCell_CheckboxRowSelectorCell = ({ dataRow })=>{
12
+ const targetWindow = useWindow();
13
+ useComponentCssInjection({
14
+ testId: "vuu-checkbox-row-selector-cell",
15
+ css: CheckboxRowSelectorCell,
16
+ window: targetWindow
17
+ });
18
+ const isChecked = !!dataRow.isSelected;
19
+ const handleClick = useCallback((e)=>{
20
+ const target = e.target;
21
+ if ("INPUT" !== target.tagName) e.stopPropagation();
22
+ }, []);
23
+ return /*#__PURE__*/ jsx(Checkbox, {
24
+ checked: isChecked,
25
+ className: "vuuCheckboxRowSelector",
26
+ inputProps: inputProps,
27
+ onClick: handleClick
28
+ });
29
+ };
30
+ CheckboxRowSelectorCell_CheckboxRowSelectorCell.displayName = "CheckboxCell";
31
+ registerComponent("checkbox-row-selector-cell", CheckboxRowSelectorCell_CheckboxRowSelectorCell, "cell-renderer", {
32
+ serverDataType: "boolean"
33
+ });
34
+ export { CheckboxRowSelectorCell_CheckboxRowSelectorCell as CheckboxRowSelectorCell };
@@ -0,0 +1 @@
1
+ export * from "./CheckboxRowSelectorCell.mjs";
@@ -0,0 +1,4 @@
1
+ export * from "./checkbox-cell/index.mjs";
2
+ export * from "./checkbox-row-selector/index.mjs";
3
+ export * from "./input-cell/index.mjs";
4
+ export * from "./toggle-cell/index.mjs";
@@ -0,0 +1,81 @@
1
+ const css = `
2
+ .vuuTableCell.vuuTableCell-editable {
3
+ & .vuuTableInputCell.saltInput-primary {
4
+ --salt-focused-outlineStyle: none;
5
+ --saltInput-height: var(--vuu-table-embedded-control-height);
6
+ --saltInput-minHeight: var(--saltInput-height);
7
+ border-radius: 2px;
8
+ font-weight: 500;
9
+ }
10
+ }
11
+
12
+ .vuuTableInputCell {
13
+ --edit-indicator-color: var(--salt-editable-borderColor);
14
+ }
15
+
16
+ .vuuTableInputCell-icon {
17
+ --vuu-icon-height: 13px;
18
+ --vuu-icon-left: 0;
19
+ --vuu-icon-size: 15px;
20
+ --vuu-icon-width: 12px;
21
+ cursor: pointer;
22
+ border-radius: 10px;
23
+ }
24
+
25
+ .vuuTableInputCell-error.saltInput-bordered.saltInput {
26
+ border-color: var(--salt-status-error-foreground-informative);
27
+
28
+ & .saltInput-startAdornmentContainer {
29
+ & .vuuTableInputCell-icon {
30
+ --vuu-icon-color: var(--salt-status-error-bold-background);
31
+ }
32
+ }
33
+
34
+ & .saltInput-endAdornmentContainer {
35
+ & .vuuTableInputCell-icon {
36
+ --vuu-icon-color: var(--salt-status-error-bold-background);
37
+ }
38
+ }
39
+ }
40
+
41
+ .vuuTableInputCell-warning.saltInput-bordered.saltInput {
42
+ border-color: var(--salt-status-warning-foreground-informative);
43
+
44
+ & .saltInput-startAdornmentContainer {
45
+ & .vuuTableInputCell-icon {
46
+ --vuu-icon-color: var(--salt-status-warning-bold-background);
47
+ }
48
+ }
49
+
50
+ & .saltInput-endAdornmentContainer {
51
+ & .vuuTableInputCell-icon {
52
+ --vuu-icon-color: var(--salt-status-warning-bold-background);
53
+ }
54
+ }
55
+ }
56
+
57
+ .vuuTableCell-right {
58
+ & .saltInput-input {
59
+ text-align: right;
60
+ }
61
+ }
62
+
63
+ .vuuTableInputCell-edited {
64
+ border-left: solid var(--vuuTableInputCell-edited-color, var(--edit-indicator-color)) 4px !important;
65
+ }
66
+
67
+ .vuuTableInputCell-error {
68
+ --edit-indicator-color: var(--salt-status-error-foreground-informative);
69
+ outline: var(--vuuTableCell-outline, solid var(--salt-status-error-foreground-informative) 2px);
70
+ outline-offset: -2px;
71
+ }
72
+
73
+ .vuuTableInputCell-warning {
74
+ --edit-indicator-color: var(--salt-status-warning-foreground-informative);
75
+ outline: var(--vuuTableCell-outline, solid var(--salt-status-warning-foreground-informative) 2px);
76
+ outline-offset: -2px;
77
+ }
78
+
79
+
80
+ `;
81
+ export default css;
@@ -0,0 +1,73 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Input, Tooltip } from "@salt-ds/core";
3
+ import { useComponentCssInjection } from "@salt-ds/styles";
4
+ import { useWindow } from "@salt-ds/window";
5
+ import { Icon } from "@vuu-ui/vuu-ui-controls";
6
+ import { dataDescriptorTypeToVuuRowDataItemType, getVuuEditMessage, registerComponent } from "@vuu-ui/vuu-utils";
7
+ import clsx from "clsx";
8
+ import InputCell from "./InputCell.css";
9
+ import { useInputCell } from "./useInputCell.mjs";
10
+ const classBase = "vuuTableInputCell";
11
+ const InputCell_InputCell = ({ column, dataRow, editedDuringCurrentSession, onEdit })=>{
12
+ const targetWindow = useWindow();
13
+ useComponentCssInjection({
14
+ testId: "vuu-input-cell",
15
+ css: InputCell,
16
+ window: targetWindow
17
+ });
18
+ const dataValue = dataRow[column.name];
19
+ const { align = "left" } = column;
20
+ const { editing, warningMessage, previousValue = "", ...editProps } = useInputCell({
21
+ column,
22
+ onEdit,
23
+ type: dataDescriptorTypeToVuuRowDataItemType(column),
24
+ value: dataValue
25
+ });
26
+ const editRejected = getVuuEditMessage(dataRow, column, previousValue);
27
+ const endAdornment = editRejected && "left" === align ? /*#__PURE__*/ jsx(Tooltip, {
28
+ content: editRejected,
29
+ placement: "right",
30
+ children: /*#__PURE__*/ jsx(Icon, {
31
+ className: `${classBase}-icon`,
32
+ name: "error"
33
+ })
34
+ }) : warningMessage && "left" === align ? /*#__PURE__*/ jsx(Tooltip, {
35
+ content: warningMessage,
36
+ placement: "right",
37
+ children: /*#__PURE__*/ jsx(Icon, {
38
+ className: `${classBase}-icon`,
39
+ name: "error"
40
+ })
41
+ }) : void 0;
42
+ const startAdornment = editRejected && "right" === align ? /*#__PURE__*/ jsx(Tooltip, {
43
+ content: editRejected,
44
+ placement: "right",
45
+ children: /*#__PURE__*/ jsx(Icon, {
46
+ className: `${classBase}-icon`,
47
+ name: "error"
48
+ })
49
+ }) : warningMessage && "right" === align ? /*#__PURE__*/ jsx(Tooltip, {
50
+ content: warningMessage,
51
+ placement: "left",
52
+ children: /*#__PURE__*/ jsx(Icon, {
53
+ className: `${classBase}-icon`,
54
+ name: "error"
55
+ })
56
+ }) : void 0;
57
+ return /*#__PURE__*/ jsx(Input, {
58
+ ...editProps,
59
+ bordered: true,
60
+ className: clsx(classBase, {
61
+ [`${classBase}-edited`]: true === editedDuringCurrentSession,
62
+ [`${classBase}-error`]: void 0 !== warningMessage,
63
+ [`${classBase}-warning`]: void 0 !== editRejected,
64
+ vuuEditing: editing
65
+ }),
66
+ endAdornment: endAdornment,
67
+ startAdornment: startAdornment
68
+ });
69
+ };
70
+ registerComponent("input-cell", InputCell_InputCell, "cell-renderer", {
71
+ userCanAssign: false
72
+ });
73
+ export { InputCell_InputCell as InputCell };
@@ -0,0 +1 @@
1
+ export * from "./InputCell.mjs";