@rovula/ui 0.1.27 → 0.1.29

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 (77) hide show
  1. package/dist/cjs/bundle.css +513 -67
  2. package/dist/cjs/bundle.js +589 -589
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/Avatar/Avatar.d.ts +1 -1
  5. package/dist/cjs/types/components/Avatar/Avatar.stories.d.ts +1 -1
  6. package/dist/cjs/types/components/Avatar/Avatar.styles.d.ts +1 -0
  7. package/dist/cjs/types/components/DataTable/DataTable.d.ts +195 -4
  8. package/dist/cjs/types/components/DataTable/DataTable.editing.d.ts +20 -0
  9. package/dist/cjs/types/components/DataTable/DataTable.editing.types.d.ts +145 -0
  10. package/dist/cjs/types/components/DataTable/DataTable.stories.d.ts +268 -6
  11. package/dist/cjs/types/components/Dropdown/Dropdown.d.ts +22 -0
  12. package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +4 -0
  13. package/dist/cjs/types/components/ScrollArea/ScrollArea.d.ts +3 -3
  14. package/dist/cjs/types/components/ScrollArea/ScrollArea.stories.d.ts +4 -0
  15. package/dist/cjs/types/components/Table/Table.d.ts +33 -3
  16. package/dist/cjs/types/components/Table/Table.stories.d.ts +86 -4
  17. package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +8 -0
  18. package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +1 -0
  19. package/dist/components/Avatar/Avatar.js +2 -1
  20. package/dist/components/Avatar/Avatar.styles.js +3 -0
  21. package/dist/components/Avatar/AvatarBase.js +1 -1
  22. package/dist/components/DataTable/DataTable.editing.js +385 -0
  23. package/dist/components/DataTable/DataTable.editing.types.js +1 -0
  24. package/dist/components/DataTable/DataTable.js +983 -50
  25. package/dist/components/DataTable/DataTable.stories.js +1077 -25
  26. package/dist/components/Dropdown/Dropdown.js +8 -6
  27. package/dist/components/ScrollArea/ScrollArea.js +2 -2
  28. package/dist/components/ScrollArea/ScrollArea.stories.js +68 -2
  29. package/dist/components/Table/Table.js +103 -13
  30. package/dist/components/Table/Table.stories.js +226 -9
  31. package/dist/components/TextInput/TextInput.js +6 -4
  32. package/dist/components/TextInput/TextInput.stories.js +8 -0
  33. package/dist/components/TextInput/TextInput.styles.js +7 -1
  34. package/dist/esm/bundle.css +513 -67
  35. package/dist/esm/bundle.js +1545 -1545
  36. package/dist/esm/bundle.js.map +1 -1
  37. package/dist/esm/types/components/Avatar/Avatar.d.ts +1 -1
  38. package/dist/esm/types/components/Avatar/Avatar.stories.d.ts +1 -1
  39. package/dist/esm/types/components/Avatar/Avatar.styles.d.ts +1 -0
  40. package/dist/esm/types/components/DataTable/DataTable.d.ts +195 -4
  41. package/dist/esm/types/components/DataTable/DataTable.editing.d.ts +20 -0
  42. package/dist/esm/types/components/DataTable/DataTable.editing.types.d.ts +145 -0
  43. package/dist/esm/types/components/DataTable/DataTable.stories.d.ts +268 -6
  44. package/dist/esm/types/components/Dropdown/Dropdown.d.ts +22 -0
  45. package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +4 -0
  46. package/dist/esm/types/components/ScrollArea/ScrollArea.d.ts +3 -3
  47. package/dist/esm/types/components/ScrollArea/ScrollArea.stories.d.ts +4 -0
  48. package/dist/esm/types/components/Table/Table.d.ts +33 -3
  49. package/dist/esm/types/components/Table/Table.stories.d.ts +86 -4
  50. package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +8 -0
  51. package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +1 -0
  52. package/dist/index.d.ts +493 -122
  53. package/dist/src/theme/global.css +762 -96
  54. package/package.json +14 -2
  55. package/src/components/Avatar/Avatar.styles.ts +4 -1
  56. package/src/components/Avatar/Avatar.tsx +3 -2
  57. package/src/components/Avatar/AvatarBase.tsx +3 -3
  58. package/src/components/DataTable/DataTable.editing.tsx +861 -0
  59. package/src/components/DataTable/DataTable.editing.types.ts +192 -0
  60. package/src/components/DataTable/DataTable.stories.tsx +2169 -31
  61. package/src/components/DataTable/DataTable.test.tsx +696 -0
  62. package/src/components/DataTable/DataTable.tsx +2260 -94
  63. package/src/components/Dropdown/Dropdown.tsx +22 -6
  64. package/src/components/ScrollArea/ScrollArea.stories.tsx +146 -3
  65. package/src/components/ScrollArea/ScrollArea.tsx +6 -6
  66. package/src/components/Table/Table.stories.tsx +789 -44
  67. package/src/components/Table/Table.tsx +294 -28
  68. package/src/components/TextInput/TextInput.stories.tsx +80 -0
  69. package/src/components/TextInput/TextInput.styles.ts +7 -1
  70. package/src/components/TextInput/TextInput.tsx +21 -14
  71. package/src/test/setup.ts +50 -0
  72. package/src/theme/global.css +81 -42
  73. package/src/theme/presets/colors.js +12 -0
  74. package/src/theme/themes/variable.css +27 -28
  75. package/src/theme/tokens/baseline.css +2 -1
  76. package/src/theme/tokens/components/scrollbar.css +9 -4
  77. package/src/theme/tokens/components/table.css +63 -0
@@ -0,0 +1,385 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
3
+ import TextInput from "@/components/TextInput/TextInput";
4
+ import NumberInput from "@/components/NumberInput";
5
+ import { Checkbox } from "@/components/Checkbox/Checkbox";
6
+ import Dropdown from "@/components/Dropdown/Dropdown";
7
+ import { customInputVariant } from "@/components/Dropdown/Dropdown.styles";
8
+ import { cn } from "@/utils/cn";
9
+ // ---------------------------------------------------------------------------
10
+ // EditContext — shared between engine and DataTable render layer
11
+ // ---------------------------------------------------------------------------
12
+ export const EditContext = React.createContext(null);
13
+ // ---------------------------------------------------------------------------
14
+ // useDataTableEditing — manages edit state (row / cell)
15
+ // ---------------------------------------------------------------------------
16
+ export function useDataTableEditing(opts) {
17
+ const { enabled, editDisplayMode, editTrigger, editableColumnIds } = opts;
18
+ const [editingRowId, setEditingRowId] = useState(null);
19
+ const [editingCell, setEditingCell] = useState(null);
20
+ const tabMovingRef = React.useRef(false);
21
+ const requestRowEdit = useCallback((rowId) => {
22
+ setEditingRowId(rowId);
23
+ setEditingCell(null);
24
+ }, []);
25
+ const requestCellEdit = useCallback((rowId, columnId) => {
26
+ setEditingCell({ rowId, columnId });
27
+ setEditingRowId(null);
28
+ }, []);
29
+ const clearEdit = useCallback(() => {
30
+ setEditingRowId(null);
31
+ setEditingCell(null);
32
+ }, []);
33
+ const onFieldBlur = useCallback((_rowId, _columnId) => {
34
+ if (tabMovingRef.current)
35
+ return;
36
+ if (editDisplayMode === "cell") {
37
+ setEditingCell(null);
38
+ }
39
+ }, [editDisplayMode]);
40
+ const moveCellEdit = useCallback((rowId, fromColumnId, delta) => {
41
+ const idx = editableColumnIds.indexOf(fromColumnId);
42
+ if (idx < 0) {
43
+ setEditingCell(null);
44
+ return "exited";
45
+ }
46
+ const next = idx + delta;
47
+ if (next < 0 || next >= editableColumnIds.length) {
48
+ setEditingCell(null);
49
+ return "exited";
50
+ }
51
+ tabMovingRef.current = true;
52
+ setEditingCell({ rowId, columnId: editableColumnIds[next] });
53
+ requestAnimationFrame(() => {
54
+ tabMovingRef.current = false;
55
+ });
56
+ return "moved";
57
+ }, [editableColumnIds]);
58
+ // Esc exits row edit
59
+ useEffect(() => {
60
+ if (!enabled || editDisplayMode !== "row" || !editingRowId)
61
+ return;
62
+ const onKey = (e) => {
63
+ if (e.key === "Escape")
64
+ setEditingRowId(null);
65
+ };
66
+ document.addEventListener("keydown", onKey);
67
+ return () => document.removeEventListener("keydown", onKey);
68
+ }, [enabled, editDisplayMode, editingRowId]);
69
+ return useMemo(() => ({
70
+ editingRowId,
71
+ editingCell,
72
+ editDisplayMode,
73
+ editTrigger,
74
+ requestRowEdit,
75
+ requestCellEdit,
76
+ clearEdit,
77
+ onFieldBlur,
78
+ moveCellEdit,
79
+ }), [
80
+ editingRowId,
81
+ editingCell,
82
+ editDisplayMode,
83
+ editTrigger,
84
+ requestRowEdit,
85
+ requestCellEdit,
86
+ clearEdit,
87
+ onFieldBlur,
88
+ moveCellEdit,
89
+ ]);
90
+ }
91
+ // ---------------------------------------------------------------------------
92
+ // resolveEditableColumns — wraps EditableColumnDef[] → ColumnDef[]
93
+ // ---------------------------------------------------------------------------
94
+ const EDIT_SELECT_PH_PREFIX = "__edit_ph__";
95
+ function editPlaceholderOption(label) {
96
+ return { value: `${EDIT_SELECT_PH_PREFIX}:${label}`, label };
97
+ }
98
+ function isPlaceholderOption(opt) {
99
+ var _a;
100
+ return (_a = opt === null || opt === void 0 ? void 0 : opt.value.startsWith(`${EDIT_SELECT_PH_PREFIX}:`)) !== null && _a !== void 0 ? _a : false;
101
+ }
102
+ function isEditingCell(editing, row, columnId) {
103
+ var _a;
104
+ const rowId = typeof row.original.id === "string"
105
+ ? row.original.id
106
+ : row.id;
107
+ if (editing.editDisplayMode === "row")
108
+ return editing.editingRowId === rowId;
109
+ return (((_a = editing.editingCell) === null || _a === void 0 ? void 0 : _a.rowId) === rowId &&
110
+ editing.editingCell.columnId === columnId);
111
+ }
112
+ function getRowId(row) {
113
+ const orig = row.original;
114
+ return typeof orig.id === "string" ? orig.id : row.id;
115
+ }
116
+ function coerceValue(variant, rawValue) {
117
+ if (variant === "number") {
118
+ const n = Number(rawValue);
119
+ return Number.isNaN(n) ? 0 : n;
120
+ }
121
+ if (variant === "checkbox") {
122
+ return rawValue === "true";
123
+ }
124
+ return rawValue;
125
+ }
126
+ function buildPatch(col, row, rawValue, columnId) {
127
+ if (col.onCommit) {
128
+ return col.onCommit(row, rawValue);
129
+ }
130
+ return { [columnId]: coerceValue(col.editVariant, rawValue) };
131
+ }
132
+ export function resolveEditableColumns(columns, opts) {
133
+ const { editing, onCellCommit, alwaysEditing, enableCellTabTraversal, editableColumnIds, } = opts;
134
+ return columns.map((col) => {
135
+ var _a, _b;
136
+ const colEditing = col.enableEditing;
137
+ if (colEditing == null && col.editVariant == null) {
138
+ return col;
139
+ }
140
+ const columnId = (_b = (_a = col.accessorKey) !== null && _a !== void 0 ? _a : col.id) !== null && _b !== void 0 ? _b : "";
141
+ const originalCell = col.cell;
142
+ const wrappedCol = Object.assign(Object.assign({}, col), { cell: (cellProps) => {
143
+ var _a, _b, _c, _d, _e, _f, _g, _h;
144
+ const { row } = cellProps;
145
+ const rowId = getRowId(row);
146
+ const canEdit = typeof colEditing === "function"
147
+ ? colEditing(row)
148
+ : colEditing !== false;
149
+ if (!canEdit) {
150
+ const always = (_a = alwaysEditing === null || alwaysEditing === void 0 ? void 0 : alwaysEditing(row)) !== null && _a !== void 0 ? _a : false;
151
+ const isRowActive = always ||
152
+ editing.editingRowId === rowId ||
153
+ ((_b = editing.editingCell) === null || _b === void 0 ? void 0 : _b.rowId) === rowId;
154
+ const showDisabledField = always || (col.editShowDisabledField && isRowActive);
155
+ if (showDisabledField && (col.editVariant || colEditing != null)) {
156
+ return _jsx(DisabledEditCell, { row: row, col: col, columnId: columnId });
157
+ }
158
+ if (col.displayCell) {
159
+ return col.displayCell(row);
160
+ }
161
+ if (originalCell) {
162
+ return typeof originalCell === "function"
163
+ ? originalCell(cellProps)
164
+ : originalCell;
165
+ }
166
+ const value = row.original[columnId];
167
+ return _jsx(_Fragment, { children: String(value !== null && value !== void 0 ? value : "") });
168
+ }
169
+ const always = (_c = alwaysEditing === null || alwaysEditing === void 0 ? void 0 : alwaysEditing(row)) !== null && _c !== void 0 ? _c : false;
170
+ const active = always || isEditingCell(editing, row, columnId);
171
+ if (!active) {
172
+ const previewContent = col.displayCell
173
+ ? col.displayCell(row)
174
+ : String((_d = row.original[columnId]) !== null && _d !== void 0 ? _d : "");
175
+ const activate = () => {
176
+ if (editing.editDisplayMode === "row")
177
+ editing.requestRowEdit(rowId);
178
+ else
179
+ editing.requestCellEdit(rowId, columnId);
180
+ };
181
+ const handler = editing.editTrigger === "click"
182
+ ? { onClick: activate }
183
+ : { onDoubleClick: activate };
184
+ return (_jsx("div", Object.assign({ className: cn("-mx-1 flex min-h-[32px] w-full min-w-0 cursor-pointer items-center rounded-sm px-1", "hover:bg-table-c-hover/35") }, handler, { children: previewContent })));
185
+ }
186
+ // ── Edit mode ──
187
+ const variant = (_e = col.editVariant) !== null && _e !== void 0 ? _e : "text";
188
+ const autoFocus = !always && editing.editDisplayMode === "cell";
189
+ const errorMsg = (_f = col.editError) === null || _f === void 0 ? void 0 : _f.call(col, row);
190
+ const commitAndBlur = (value) => {
191
+ const patch = buildPatch(col, row, value, columnId);
192
+ onCellCommit === null || onCellCommit === void 0 ? void 0 : onCellCommit(rowId, columnId, patch);
193
+ if (!always)
194
+ editing.onFieldBlur(rowId, columnId);
195
+ };
196
+ const handleTab = enableCellTabTraversal
197
+ ? (e, commitFn) => {
198
+ if (e.key !== "Tab")
199
+ return;
200
+ if (editing.editDisplayMode === "row") {
201
+ const idx = editableColumnIds.indexOf(columnId);
202
+ if (idx < 0)
203
+ return;
204
+ const nextIdx = idx + (e.shiftKey ? -1 : 1);
205
+ if (nextIdx < 0 || nextIdx >= editableColumnIds.length)
206
+ return;
207
+ const nextColId = editableColumnIds[nextIdx];
208
+ commitFn();
209
+ e.preventDefault();
210
+ requestAnimationFrame(() => {
211
+ const el = document.querySelector(`[data-edit-cell="${rowId}:${nextColId}"] input, [data-edit-cell="${rowId}:${nextColId}"] button`);
212
+ el === null || el === void 0 ? void 0 : el.focus();
213
+ });
214
+ return;
215
+ }
216
+ commitFn();
217
+ if (editing.moveCellEdit(rowId, columnId, e.shiftKey ? -1 : 1) ===
218
+ "moved") {
219
+ e.preventDefault();
220
+ }
221
+ }
222
+ : undefined;
223
+ if (variant === "select") {
224
+ return (_jsx("div", { "data-edit-cell": `${rowId}:${columnId}`, children: _jsx(EditCellSelect, { row: row, columnId: columnId, col: col, autoFocus: autoFocus, keepOpenAfterSelect: editing.editDisplayMode === "row" || always, onCommit: (label) => {
225
+ var _a;
226
+ const currentValue = String((_a = row.original[columnId]) !== null && _a !== void 0 ? _a : "");
227
+ if (label.trim() === currentValue.trim())
228
+ return;
229
+ const patch = buildPatch(col, row, label, columnId);
230
+ onCellCommit === null || onCellCommit === void 0 ? void 0 : onCellCommit(rowId, columnId, patch);
231
+ }, onBlurField: editing.editDisplayMode === "row"
232
+ ? undefined
233
+ : () => {
234
+ if (!always)
235
+ editing.onFieldBlur(rowId, columnId);
236
+ }, onKeyDown: handleTab
237
+ ? (e) => handleTab(e, () => { })
238
+ : undefined, errorMessage: errorMsg }) }));
239
+ }
240
+ if (variant === "number") {
241
+ return (_jsx("div", { "data-edit-cell": `${rowId}:${columnId}`, children: _jsx(EditCellNumber, { columnId: columnId, row: row, col: col, autoFocus: autoFocus, errorMessage: errorMsg, onBlur: (val) => commitAndBlur(val), onKeyDown: handleTab
242
+ ? (e) => handleTab(e, () => {
243
+ const v = e.target.value.trim();
244
+ const patch = buildPatch(col, row, v, columnId);
245
+ onCellCommit === null || onCellCommit === void 0 ? void 0 : onCellCommit(rowId, columnId, patch);
246
+ })
247
+ : undefined }) }));
248
+ }
249
+ if (variant === "checkbox") {
250
+ return (_jsx("div", { "data-edit-cell": `${rowId}:${columnId}`, children: _jsx(EditCellCheckbox, { columnId: columnId, row: row, col: col, errorMessage: errorMsg, onCommit: (checked) => {
251
+ const patch = buildPatch(col, row, String(checked), columnId);
252
+ onCellCommit === null || onCellCommit === void 0 ? void 0 : onCellCommit(rowId, columnId, patch);
253
+ }, onKeyDown: handleTab
254
+ ? (e) => handleTab(e, () => { })
255
+ : undefined }) }));
256
+ }
257
+ if (variant === "custom" && col.editCustomCell) {
258
+ const blur = () => {
259
+ if (!always)
260
+ editing.onFieldBlur(rowId, columnId);
261
+ };
262
+ return (_jsx("div", { "data-edit-cell": `${rowId}:${columnId}`, children: col.editCustomCell(row, {
263
+ commit: (rawValue) => {
264
+ const patch = buildPatch(col, row, rawValue, columnId);
265
+ onCellCommit === null || onCellCommit === void 0 ? void 0 : onCellCommit(rowId, columnId, patch);
266
+ },
267
+ blur,
268
+ columnId,
269
+ autoFocus,
270
+ errorMessage: errorMsg,
271
+ onKeyDown: handleTab
272
+ ? (e) => handleTab(e, () => { })
273
+ : undefined,
274
+ }) }));
275
+ }
276
+ // variant === "text"
277
+ return (_jsx("div", { "data-edit-cell": `${rowId}:${columnId}`, children: _jsx(EditCellText, { columnId: columnId, row: row, placeholder: (_h = (_g = col.editTextProps) === null || _g === void 0 ? void 0 : _g.placeholder) !== null && _h !== void 0 ? _h : "", autoFocus: autoFocus, errorMessage: errorMsg, onBlur: (e) => commitAndBlur(e.currentTarget.value.trim()), onKeyDown: handleTab
278
+ ? (e) => handleTab(e, () => {
279
+ const v = e.target.value.trim();
280
+ const patch = buildPatch(col, row, v, columnId);
281
+ onCellCommit === null || onCellCommit === void 0 ? void 0 : onCellCommit(rowId, columnId, patch);
282
+ })
283
+ : undefined }) }));
284
+ } });
285
+ return wrappedCol;
286
+ });
287
+ }
288
+ // ---------------------------------------------------------------------------
289
+ // Built-in cell editors
290
+ // ---------------------------------------------------------------------------
291
+ function EditCellText({ columnId, row, placeholder, autoFocus, errorMessage, onBlur, onKeyDown, }) {
292
+ var _a;
293
+ const value = String((_a = row.original[columnId]) !== null && _a !== void 0 ? _a : "");
294
+ return (_jsx(TextInput, { size: "sm", variant: "outline", rounded: "normal", fullwidth: true, isFloatingLabel: false, label: "", required: false, hasClearIcon: false, keepFooterSpace: false, defaultValue: value, placeholder: placeholder, "aria-label": placeholder || columnId, autoFocus: autoFocus, error: !!errorMessage, errorMessage: errorMessage, onBlur: onBlur, onKeyDown: onKeyDown, className: "rounded-md px-2 py-2 typography-small2" }));
295
+ }
296
+ function EditCellSelect({ row, columnId, col, autoFocus, onCommit, onBlurField, onKeyDown, keepOpenAfterSelect, errorMessage, }) {
297
+ var _a, _b, _c, _d, _e;
298
+ const displayValue = String((_a = row.original[columnId]) !== null && _a !== void 0 ? _a : "");
299
+ const rawOptions = typeof ((_b = col.editSelectProps) === null || _b === void 0 ? void 0 : _b.options) === "function"
300
+ ? col.editSelectProps.options(row)
301
+ : (_d = (_c = col.editSelectProps) === null || _c === void 0 ? void 0 : _c.options) !== null && _d !== void 0 ? _d : [];
302
+ const options = useMemo(() => {
303
+ var _a, _b;
304
+ const ph = (_b = (_a = col.editSelectProps) === null || _a === void 0 ? void 0 : _a.placeholder) !== null && _b !== void 0 ? _b : columnId;
305
+ return [editPlaceholderOption(ph), ...rawOptions];
306
+ }, [rawOptions, (_e = col.editSelectProps) === null || _e === void 0 ? void 0 : _e.placeholder, columnId]);
307
+ const selected = useMemo(() => {
308
+ var _a;
309
+ const cur = displayValue.trim();
310
+ if (!cur)
311
+ return options[0];
312
+ return (_a = options.find((o) => o.label === cur)) !== null && _a !== void 0 ? _a : options[0];
313
+ }, [displayValue, options]);
314
+ return (_jsx("div", { children: _jsx(Dropdown, { id: `edit-dd-${columnId}-${row.id}`, options: options, value: selected, onSelect: (opt) => {
315
+ if (isPlaceholderOption(opt))
316
+ return;
317
+ onCommit(opt.label);
318
+ }, size: "sm", variant: "outline", rounded: "normal", fullwidth: true, required: false, isFloatingLabel: false, label: "", keepFooterSpace: false, segmentedInput: true, autoFocus: autoFocus, onBlur: onBlurField, onKeyDown: onKeyDown, keepOpenAfterSelect: keepOpenAfterSelect, portal: true, error: !!errorMessage, errorMessage: errorMessage, className: cn("rounded-md", customInputVariant({ size: "sm" }), displayValue.trim().length > 0 && "font-medium") }) }));
319
+ }
320
+ // ---------------------------------------------------------------------------
321
+ // EditCellNumber — inline number editor
322
+ // ---------------------------------------------------------------------------
323
+ function EditCellNumber({ columnId, row, col, autoFocus, errorMessage, onBlur, onKeyDown, }) {
324
+ var _a;
325
+ const rawValue = row.original[columnId];
326
+ const numericValue = rawValue === "" || rawValue == null ? undefined : Number(rawValue);
327
+ const np = col.editNumberProps;
328
+ return (_jsx(NumberInput, { size: "sm", variant: "outline", rounded: "normal", fullwidth: true, isFloatingLabel: false, label: "", required: false, hasClearIcon: false, keepFooterSpace: false, defaultValue: numericValue, placeholder: (_a = np === null || np === void 0 ? void 0 : np.placeholder) !== null && _a !== void 0 ? _a : columnId, "aria-label": (np === null || np === void 0 ? void 0 : np.placeholder) || columnId, autoFocus: autoFocus, min: np === null || np === void 0 ? void 0 : np.min, max: np === null || np === void 0 ? void 0 : np.max, step: np === null || np === void 0 ? void 0 : np.step, precision: np === null || np === void 0 ? void 0 : np.precision, allowDecimal: np === null || np === void 0 ? void 0 : np.allowDecimal, allowNegative: np === null || np === void 0 ? void 0 : np.allowNegative, hideControls: true, error: !!errorMessage, errorMessage: errorMessage, onBlur: (e) => onBlur(e.currentTarget.value.trim()), onKeyDown: onKeyDown, className: "rounded-md px-2 py-2 typography-small2" }));
329
+ }
330
+ // ---------------------------------------------------------------------------
331
+ // EditCellCheckbox — inline checkbox editor
332
+ // ---------------------------------------------------------------------------
333
+ function EditCellCheckbox({ columnId, row, col, errorMessage, onCommit, onKeyDown, }) {
334
+ var _a;
335
+ const rawValue = row.original[columnId];
336
+ const checked = rawValue === true || rawValue === "true";
337
+ const label = (_a = col.editCheckboxProps) === null || _a === void 0 ? void 0 : _a.label;
338
+ return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [_jsxs("div", { className: "flex items-center gap-2 min-h-[32px]", children: [_jsx(Checkbox, { checked: checked, onCheckedChange: (val) => {
339
+ onCommit(val === true);
340
+ }, onKeyDown: onKeyDown
341
+ ? (e) => onKeyDown(e)
342
+ : undefined, "aria-label": label || columnId }), label && (_jsx("span", { className: "typography-small2 text-text-contrast-high select-none", children: label }))] }), errorMessage && (_jsx("span", { className: "typography-small3 text-error-500", children: errorMessage }))] }));
343
+ }
344
+ // ---------------------------------------------------------------------------
345
+ // Disabled cell editor — shown in alwaysEditing rows when canEdit is false
346
+ // ---------------------------------------------------------------------------
347
+ function DisabledEditCell({ row, col, columnId, }) {
348
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
349
+ const variant = (_a = col.editVariant) !== null && _a !== void 0 ? _a : "text";
350
+ if (variant === "select") {
351
+ const rawOptions = typeof ((_b = col.editSelectProps) === null || _b === void 0 ? void 0 : _b.options) === "function"
352
+ ? col.editSelectProps.options(row)
353
+ : (_d = (_c = col.editSelectProps) === null || _c === void 0 ? void 0 : _c.options) !== null && _d !== void 0 ? _d : [];
354
+ const ph = (_f = (_e = col.editSelectProps) === null || _e === void 0 ? void 0 : _e.placeholder) !== null && _f !== void 0 ? _f : columnId;
355
+ const options = [editPlaceholderOption(ph), ...rawOptions];
356
+ const displayValue = String((_g = row.original[columnId]) !== null && _g !== void 0 ? _g : "");
357
+ const selected = (_h = options.find((o) => o.label === displayValue.trim())) !== null && _h !== void 0 ? _h : options[0];
358
+ return (_jsx(Dropdown, { id: `edit-dd-disabled-${columnId}-${row.id}`, options: options, value: selected, onSelect: () => { }, size: "sm", variant: "outline", rounded: "normal", fullwidth: true, required: false, isFloatingLabel: false, label: "", keepFooterSpace: false, segmentedInput: true, disabled: true, className: cn("rounded-md", customInputVariant({ size: "sm" })) }));
359
+ }
360
+ if (variant === "number") {
361
+ const rawValue = row.original[columnId];
362
+ const numericValue = rawValue === "" || rawValue == null ? undefined : Number(rawValue);
363
+ return (_jsx(NumberInput, { size: "sm", variant: "outline", rounded: "normal", fullwidth: true, isFloatingLabel: false, label: "", required: false, hasClearIcon: false, keepFooterSpace: false, defaultValue: numericValue, disabled: true, hideControls: true, className: "rounded-md px-2 py-2 typography-small2" }));
364
+ }
365
+ if (variant === "checkbox") {
366
+ const rawValue = row.original[columnId];
367
+ const checked = rawValue === true || rawValue === "true";
368
+ return (_jsxs("div", { className: "flex items-center gap-2 min-h-[32px]", children: [_jsx(Checkbox, { checked: checked, disabled: true }), ((_j = col.editCheckboxProps) === null || _j === void 0 ? void 0 : _j.label) && (_jsx("span", { className: "typography-small2 text-text-g-contrast-medium select-none", children: col.editCheckboxProps.label }))] }));
369
+ }
370
+ const value = String((_k = row.original[columnId]) !== null && _k !== void 0 ? _k : "");
371
+ const placeholder = (_m = (_l = col.editTextProps) === null || _l === void 0 ? void 0 : _l.placeholder) !== null && _m !== void 0 ? _m : "";
372
+ return (_jsx(TextInput, { size: "sm", variant: "outline", rounded: "normal", fullwidth: true, isFloatingLabel: false, label: "", required: false, hasClearIcon: false, keepFooterSpace: false, defaultValue: value, placeholder: placeholder, "aria-label": placeholder || columnId, disabled: true, className: "rounded-md px-2 py-2 typography-small2" }));
373
+ }
374
+ // ---------------------------------------------------------------------------
375
+ // Utility: detect editable column ids from column defs
376
+ // ---------------------------------------------------------------------------
377
+ export function detectEditableColumnIds(columns) {
378
+ return columns
379
+ .filter((col) => col.enableEditing != null || col.editVariant != null)
380
+ .map((col) => {
381
+ var _a, _b;
382
+ return (_b = (_a = col.accessorKey) !== null && _a !== void 0 ? _a : col.id) !== null && _b !== void 0 ? _b : "";
383
+ })
384
+ .filter(Boolean);
385
+ }