@vuu-ui/vuu-table 0.8.17-debug → 0.8.18-debug
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.
- package/cjs/index.js +444 -372
- package/cjs/index.js.map +4 -4
- package/esm/index.js +328 -264
- package/esm/index.js.map +4 -4
- package/index.css +32 -40
- package/index.css.map +3 -3
- package/package.json +12 -13
- package/types/{vuu-table/src/Table.d.ts → Table.d.ts} +8 -5
- package/types/{vuu-table/src/cell-renderers → cell-renderers}/cell-utils.d.ts +1 -1
- package/types/{vuu-table/src/cell-renderers → cell-renderers}/index.d.ts +1 -2
- package/types/{vuu-table/src/column-resizing → column-resizing}/useTableColumnResize.d.ts +1 -3
- package/types/{vuu-table/src/context-menu → context-menu}/buildContextMenuDescriptors.d.ts +1 -2
- package/types/{vuu-table/src/context-menu → context-menu}/useHandleTableContextMenu.d.ts +1 -2
- package/types/{vuu-table/src/header-cell → header-cell}/GroupHeaderCellNext.d.ts +1 -2
- package/types/header-cell/HeaderCell.d.ts +4 -0
- package/types/{vuu-table/src/index.d.ts → index.d.ts} +1 -0
- package/types/{vuu-table/src/table-header → table-header}/TableHeader.d.ts +2 -3
- package/types/{vuu-table/src/useDataSource.d.ts → useDataSource.d.ts} +3 -2
- package/types/{vuu-table/src/useSelection.d.ts → useSelection.d.ts} +2 -2
- package/types/{vuu-table/src/useTable.d.ts → useTable.d.ts} +1 -2
- package/types/useTableAndColumnSettings.d.ts +15 -0
- package/types/{vuu-table/src/useTableContextMenu.d.ts → useTableContextMenu.d.ts} +1 -2
- package/types/{vuu-table/src/useTableModel.d.ts → useTableModel.d.ts} +2 -4
- package/types/{vuu-table/src/useVirtualViewport.d.ts → useVirtualViewport.d.ts} +2 -2
- package/types/vuu-table/src/cell-renderers/dropdown-cell/DropdownCell.d.ts +0 -4
- package/types/vuu-table/src/cell-renderers/dropdown-cell/index.d.ts +0 -1
- package/types/vuu-table/src/cell-renderers/lookup-cell/LookupCell.d.ts +0 -3
- package/types/vuu-table/src/cell-renderers/lookup-cell/index.d.ts +0 -1
- package/types/vuu-table/src/header-cell/HeaderCell.d.ts +0 -10
- package/types/vuu-ui-controls/src/drag-drop/DragDropState.d.ts +0 -15
- package/types/vuu-ui-controls/src/drag-drop/dragDropTypesNext.d.ts +0 -91
- /package/types/{vuu-table/src/Row.d.ts → Row.d.ts} +0 -0
- /package/types/{vuu-table/src/cell-renderers → cell-renderers}/checkbox-cell/CheckboxCell.d.ts +0 -0
- /package/types/{vuu-table/src/cell-renderers → cell-renderers}/checkbox-cell/index.d.ts +0 -0
- /package/types/{vuu-table/src/cell-renderers → cell-renderers}/input-cell/InputCell.d.ts +0 -0
- /package/types/{vuu-table/src/cell-renderers → cell-renderers}/input-cell/index.d.ts +0 -0
- /package/types/{vuu-table/src/cell-renderers → cell-renderers}/toggle-cell/ToggleCell.d.ts +0 -0
- /package/types/{vuu-table/src/cell-renderers → cell-renderers}/toggle-cell/index.d.ts +0 -0
- /package/types/{vuu-table/src/column-header-pill → column-header-pill}/ColumnHeaderPill.d.ts +0 -0
- /package/types/{vuu-table/src/column-header-pill → column-header-pill}/GroupColumnPill.d.ts +0 -0
- /package/types/{vuu-table/src/column-header-pill → column-header-pill}/SortIndicator.d.ts +0 -0
- /package/types/{vuu-table/src/column-header-pill → column-header-pill}/index.d.ts +0 -0
- /package/types/{vuu-table/src/column-menu → column-menu}/ColumnMenu.d.ts +0 -0
- /package/types/{vuu-table/src/column-menu → column-menu}/index.d.ts +0 -0
- /package/types/{vuu-table/src/column-resizing → column-resizing}/ColumnResizer.d.ts +0 -0
- /package/types/{vuu-table/src/column-resizing → column-resizing}/index.d.ts +0 -0
- /package/types/{vuu-table/src/context-menu → context-menu}/index.d.ts +0 -0
- /package/types/{vuu-table/src/header-cell → header-cell}/index.d.ts +0 -0
- /package/types/{vuu-table/src/moving-window.d.ts → moving-window.d.ts} +0 -0
- /package/types/{vuu-table/src/table-cell → table-cell}/TableCell.d.ts +0 -0
- /package/types/{vuu-table/src/table-cell → table-cell}/TableGroupCell.d.ts +0 -0
- /package/types/{vuu-table/src/table-cell → table-cell}/index.d.ts +0 -0
- /package/types/{vuu-table/src/table-config.d.ts → table-config.d.ts} +0 -0
- /package/types/{vuu-table/src/table-dom-utils.d.ts → table-dom-utils.d.ts} +0 -0
- /package/types/{vuu-table/src/table-header → table-header}/useTableHeader.d.ts +0 -0
- /package/types/{vuu-table/src/useCell.d.ts → useCell.d.ts} +0 -0
- /package/types/{vuu-table/src/useCellEditing.d.ts → useCellEditing.d.ts} +0 -0
- /package/types/{vuu-table/src/useControlledTableNavigation.d.ts → useControlledTableNavigation.d.ts} +0 -0
- /package/types/{vuu-table/src/useInitialValue.d.ts → useInitialValue.d.ts} +0 -0
- /package/types/{vuu-table/src/useKeyboardNavigation.d.ts → useKeyboardNavigation.d.ts} +0 -0
- /package/types/{vuu-table/src/useResizeObserver.d.ts → useResizeObserver.d.ts} +0 -0
- /package/types/{vuu-table/src/useTableScroll.d.ts → useTableScroll.d.ts} +0 -0
- /package/types/{vuu-table/src/useTableViewport.d.ts → useTableViewport.d.ts} +0 -0
package/cjs/index.js
CHANGED
|
@@ -31,13 +31,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
CheckboxCell: () => CheckboxCell,
|
|
34
|
-
DropdownCell: () => DropdownCell,
|
|
35
34
|
GroupHeaderCellNext: () => GroupHeaderCellNext,
|
|
36
35
|
HeaderCell: () => HeaderCell,
|
|
37
36
|
InputCell: () => InputCell,
|
|
38
|
-
LookupCell: () => LookupCell,
|
|
39
37
|
Table: () => Table,
|
|
38
|
+
TableCell: () => TableCell,
|
|
39
|
+
TableGroupCell: () => TableGroupCell,
|
|
40
40
|
ToggleCell: () => ToggleCell,
|
|
41
|
+
dataAndColumnUnchanged: () => dataAndColumnUnchanged,
|
|
41
42
|
isShowColumnSettings: () => isShowColumnSettings,
|
|
42
43
|
isShowTableSettings: () => isShowTableSettings,
|
|
43
44
|
updateTableConfig: () => updateTableConfig,
|
|
@@ -48,12 +49,82 @@ __export(src_exports, {
|
|
|
48
49
|
module.exports = __toCommonJS(src_exports);
|
|
49
50
|
|
|
50
51
|
// src/header-cell/GroupHeaderCellNext.tsx
|
|
51
|
-
var
|
|
52
|
+
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
53
|
+
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
54
|
+
var import_clsx3 = __toESM(require("clsx"));
|
|
52
55
|
var import_react5 = require("react");
|
|
53
56
|
|
|
54
|
-
// src/column-
|
|
57
|
+
// src/column-header-pill/ColumnHeaderPill.tsx
|
|
58
|
+
var import_clsx = __toESM(require("clsx"));
|
|
55
59
|
var import_react = require("react");
|
|
56
60
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
61
|
+
var classBase = "vuuColumnHeaderPill";
|
|
62
|
+
var ColumnHeaderPill = ({
|
|
63
|
+
children,
|
|
64
|
+
className,
|
|
65
|
+
column,
|
|
66
|
+
onRemove,
|
|
67
|
+
removable,
|
|
68
|
+
...htmlAttributes
|
|
69
|
+
}) => {
|
|
70
|
+
if (removable && typeof onRemove !== "function") {
|
|
71
|
+
throw Error(
|
|
72
|
+
"ColumnHeaderPill onRemove prop must be provided if Pill is removable"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
const handleClickRemove = (0, import_react.useCallback)(
|
|
76
|
+
(evt) => {
|
|
77
|
+
evt.preventDefault();
|
|
78
|
+
evt.stopPropagation();
|
|
79
|
+
onRemove == null ? void 0 : onRemove(column);
|
|
80
|
+
},
|
|
81
|
+
[column, onRemove]
|
|
82
|
+
);
|
|
83
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...htmlAttributes, className: (0, import_clsx.default)(classBase, className), children: [
|
|
84
|
+
children,
|
|
85
|
+
removable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
|
+
"span",
|
|
87
|
+
{
|
|
88
|
+
className: `${classBase}-removeButton`,
|
|
89
|
+
role: "button",
|
|
90
|
+
"data-icon": "cross",
|
|
91
|
+
onClick: handleClickRemove
|
|
92
|
+
}
|
|
93
|
+
) : null
|
|
94
|
+
] });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/column-header-pill/GroupColumnPill.tsx
|
|
98
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
99
|
+
var GroupColumnPill = ({
|
|
100
|
+
column,
|
|
101
|
+
...columnHeaderProps
|
|
102
|
+
}) => {
|
|
103
|
+
const { name, sorted } = column;
|
|
104
|
+
const icon = typeof sorted === "number" ? sorted < 0 ? "arrow-down" : "arrow-up" : sorted === "A" ? "arrow-up" : sorted === "D" ? "arrow-down" : void 0;
|
|
105
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(ColumnHeaderPill, { ...columnHeaderProps, column, children: [
|
|
106
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "vuuGroupColumnPill-label", children: name }),
|
|
107
|
+
icon !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-icon": icon }) : null,
|
|
108
|
+
typeof sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "vuuSortPosition", children: Math.abs(sorted) }) : null
|
|
109
|
+
] });
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// src/column-header-pill/SortIndicator.tsx
|
|
113
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
114
|
+
var SortIndicator = ({ column }) => {
|
|
115
|
+
if (!column.sorted) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const icon = typeof column.sorted === "number" ? column.sorted < 0 ? "arrow-down" : "arrow-up" : column.sorted === "A" ? "arrow-up" : "arrow-down";
|
|
119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ColumnHeaderPill, { column, children: [
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-icon": icon }),
|
|
121
|
+
typeof column.sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "vuuSortPosition", children: Math.abs(column.sorted) }) : null
|
|
122
|
+
] });
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/column-resizing/ColumnResizer.tsx
|
|
126
|
+
var import_react2 = require("react");
|
|
127
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
57
128
|
var NOOP = () => void 0;
|
|
58
129
|
var baseClass = "vuuColumnResizerNext";
|
|
59
130
|
var ColumnResizer = ({
|
|
@@ -61,8 +132,8 @@ var ColumnResizer = ({
|
|
|
61
132
|
onDragEnd = NOOP,
|
|
62
133
|
onDragStart = NOOP
|
|
63
134
|
}) => {
|
|
64
|
-
const position = (0,
|
|
65
|
-
const onMouseMove = (0,
|
|
135
|
+
const position = (0, import_react2.useRef)(0);
|
|
136
|
+
const onMouseMove = (0, import_react2.useCallback)(
|
|
66
137
|
(e) => {
|
|
67
138
|
if (e.stopPropagation) {
|
|
68
139
|
e.stopPropagation();
|
|
@@ -79,7 +150,7 @@ var ColumnResizer = ({
|
|
|
79
150
|
},
|
|
80
151
|
[onDrag]
|
|
81
152
|
);
|
|
82
|
-
const onMouseUp = (0,
|
|
153
|
+
const onMouseUp = (0, import_react2.useCallback)(
|
|
83
154
|
(e) => {
|
|
84
155
|
window.removeEventListener("mouseup", onMouseUp);
|
|
85
156
|
window.removeEventListener("mousemove", onMouseMove);
|
|
@@ -87,7 +158,7 @@ var ColumnResizer = ({
|
|
|
87
158
|
},
|
|
88
159
|
[onDragEnd, onMouseMove]
|
|
89
160
|
);
|
|
90
|
-
const handleMouseDown = (0,
|
|
161
|
+
const handleMouseDown = (0, import_react2.useCallback)(
|
|
91
162
|
(e) => {
|
|
92
163
|
onDragStart(e);
|
|
93
164
|
position.current = Math.round(e.clientX);
|
|
@@ -102,20 +173,20 @@ var ColumnResizer = ({
|
|
|
102
173
|
},
|
|
103
174
|
[onDragStart, onMouseMove, onMouseUp]
|
|
104
175
|
);
|
|
105
|
-
return /* @__PURE__ */ (0,
|
|
176
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: baseClass, onMouseDown: handleMouseDown });
|
|
106
177
|
};
|
|
107
178
|
|
|
108
179
|
// src/column-resizing/useTableColumnResize.tsx
|
|
109
|
-
var
|
|
180
|
+
var import_react3 = require("react");
|
|
110
181
|
var useTableColumnResize = ({
|
|
111
182
|
column,
|
|
112
183
|
onResize,
|
|
113
184
|
rootRef
|
|
114
185
|
}) => {
|
|
115
|
-
const widthRef = (0,
|
|
116
|
-
const [isResizing, setResizing] = (0,
|
|
186
|
+
const widthRef = (0, import_react3.useRef)(0);
|
|
187
|
+
const [isResizing, setResizing] = (0, import_react3.useState)(false);
|
|
117
188
|
const { name } = column;
|
|
118
|
-
const handleResizeStart = (0,
|
|
189
|
+
const handleResizeStart = (0, import_react3.useCallback)(() => {
|
|
119
190
|
if (onResize && rootRef.current) {
|
|
120
191
|
const { width } = rootRef.current.getBoundingClientRect();
|
|
121
192
|
widthRef.current = Math.round(width);
|
|
@@ -123,7 +194,7 @@ var useTableColumnResize = ({
|
|
|
123
194
|
onResize == null ? void 0 : onResize("begin", name);
|
|
124
195
|
}
|
|
125
196
|
}, [name, onResize, rootRef]);
|
|
126
|
-
const handleResize = (0,
|
|
197
|
+
const handleResize = (0, import_react3.useCallback)(
|
|
127
198
|
(_evt, moveBy) => {
|
|
128
199
|
if (rootRef.current) {
|
|
129
200
|
if (onResize) {
|
|
@@ -138,7 +209,7 @@ var useTableColumnResize = ({
|
|
|
138
209
|
},
|
|
139
210
|
[name, onResize, rootRef]
|
|
140
211
|
);
|
|
141
|
-
const handleResizeEnd = (0,
|
|
212
|
+
const handleResizeEnd = (0, import_react3.useCallback)(() => {
|
|
142
213
|
if (onResize) {
|
|
143
214
|
onResize("end", name, widthRef.current);
|
|
144
215
|
setTimeout(() => {
|
|
@@ -156,98 +227,29 @@ var useTableColumnResize = ({
|
|
|
156
227
|
|
|
157
228
|
// src/useCell.ts
|
|
158
229
|
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
var useCell = (column,
|
|
230
|
+
var import_clsx2 = __toESM(require("clsx"));
|
|
231
|
+
var import_react4 = require("react");
|
|
232
|
+
var useCell = (column, classBase10, isHeader) => (
|
|
162
233
|
// TODO measure perf without the memo, might not be worth the cost
|
|
163
|
-
(0,
|
|
164
|
-
const className = (0,
|
|
234
|
+
(0, import_react4.useMemo)(() => {
|
|
235
|
+
const className = (0, import_clsx2.default)(classBase10, {
|
|
165
236
|
vuuPinFloating: column.pin === "floating",
|
|
166
237
|
vuuPinLeft: column.pin === "left",
|
|
167
238
|
vuuPinRight: column.pin === "right",
|
|
168
239
|
vuuEndPin: isHeader && column.endPin,
|
|
169
240
|
// [`${classBase}-resizing`]: column.resizing,
|
|
170
|
-
[`${
|
|
171
|
-
[`${
|
|
241
|
+
[`${classBase10}-editable`]: column.editable,
|
|
242
|
+
[`${classBase10}-right`]: column.align === "right"
|
|
172
243
|
});
|
|
173
244
|
const style = (0, import_vuu_utils.getColumnStyle)(column);
|
|
174
245
|
return {
|
|
175
246
|
className,
|
|
176
247
|
style
|
|
177
248
|
};
|
|
178
|
-
}, [column,
|
|
249
|
+
}, [column, classBase10, isHeader])
|
|
179
250
|
);
|
|
180
251
|
|
|
181
|
-
// src/column-header-pill/ColumnHeaderPill.tsx
|
|
182
|
-
var import_classnames2 = __toESM(require("classnames"));
|
|
183
|
-
var import_react4 = require("react");
|
|
184
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
185
|
-
var classBase = "vuuColumnHeaderPill";
|
|
186
|
-
var ColumnHeaderPill = ({
|
|
187
|
-
children,
|
|
188
|
-
className,
|
|
189
|
-
column,
|
|
190
|
-
onRemove,
|
|
191
|
-
removable,
|
|
192
|
-
...htmlAttributes
|
|
193
|
-
}) => {
|
|
194
|
-
if (removable && typeof onRemove !== "function") {
|
|
195
|
-
throw Error(
|
|
196
|
-
"ColumnHeaderPill onRemove prop must be provided if Pill is removable"
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
const handleClickRemove = (0, import_react4.useCallback)(
|
|
200
|
-
(evt) => {
|
|
201
|
-
evt.preventDefault();
|
|
202
|
-
evt.stopPropagation();
|
|
203
|
-
onRemove == null ? void 0 : onRemove(column);
|
|
204
|
-
},
|
|
205
|
-
[column, onRemove]
|
|
206
|
-
);
|
|
207
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ...htmlAttributes, className: (0, import_classnames2.default)(classBase, className), children: [
|
|
208
|
-
children,
|
|
209
|
-
removable ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
210
|
-
"span",
|
|
211
|
-
{
|
|
212
|
-
className: `${classBase}-removeButton`,
|
|
213
|
-
role: "button",
|
|
214
|
-
"data-icon": "cross",
|
|
215
|
-
onClick: handleClickRemove
|
|
216
|
-
}
|
|
217
|
-
) : null
|
|
218
|
-
] });
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// src/column-header-pill/GroupColumnPill.tsx
|
|
222
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
223
|
-
var GroupColumnPill = ({
|
|
224
|
-
column,
|
|
225
|
-
...columnHeaderProps
|
|
226
|
-
}) => {
|
|
227
|
-
const { name, sorted } = column;
|
|
228
|
-
const icon = typeof sorted === "number" ? sorted < 0 ? "arrow-down" : "arrow-up" : sorted === "A" ? "arrow-up" : sorted === "D" ? "arrow-down" : void 0;
|
|
229
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(ColumnHeaderPill, { ...columnHeaderProps, column, children: [
|
|
230
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "vuuGroupColumnPill-label", children: name }),
|
|
231
|
-
icon !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-icon": icon }) : null,
|
|
232
|
-
typeof sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "vuuSortPosition", children: Math.abs(sorted) }) : null
|
|
233
|
-
] });
|
|
234
|
-
};
|
|
235
|
-
|
|
236
|
-
// src/column-header-pill/SortIndicator.tsx
|
|
237
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
238
|
-
var SortIndicator = ({ column }) => {
|
|
239
|
-
if (!column.sorted) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
const icon = typeof column.sorted === "number" ? column.sorted < 0 ? "arrow-down" : "arrow-up" : column.sorted === "A" ? "arrow-up" : "arrow-down";
|
|
243
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ColumnHeaderPill, { column, children: [
|
|
244
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "data-icon": icon }),
|
|
245
|
-
typeof column.sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "vuuSortPosition", children: Math.abs(column.sorted) }) : null
|
|
246
|
-
] });
|
|
247
|
-
};
|
|
248
|
-
|
|
249
252
|
// src/header-cell/GroupHeaderCellNext.tsx
|
|
250
|
-
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
251
253
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
252
254
|
var import_react6 = require("react");
|
|
253
255
|
var classBase2 = "vuuTableGroupHeaderCell";
|
|
@@ -296,14 +298,14 @@ var GroupHeaderCellNext = ({
|
|
|
296
298
|
},
|
|
297
299
|
[onMoveColumn]
|
|
298
300
|
);
|
|
299
|
-
(0,
|
|
301
|
+
(0, import_vuu_utils2.useLayoutEffectSkipFirst)(() => {
|
|
300
302
|
setColumns((cols) => switchIfChanged(cols, groupColumn.columns));
|
|
301
303
|
}, [groupColumn.columns]);
|
|
302
304
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
303
305
|
"div",
|
|
304
306
|
{
|
|
305
307
|
...htmlAttributes,
|
|
306
|
-
className: (0,
|
|
308
|
+
className: (0, import_clsx3.default)(className, classNameProp, {
|
|
307
309
|
[`${classBase2}-pending`]: groupColumn.groupConfirmed === false
|
|
308
310
|
}),
|
|
309
311
|
ref: rootRef,
|
|
@@ -345,11 +347,12 @@ var GroupHeaderCellNext = ({
|
|
|
345
347
|
};
|
|
346
348
|
|
|
347
349
|
// src/header-cell/HeaderCell.tsx
|
|
350
|
+
var import_clsx5 = __toESM(require("clsx"));
|
|
348
351
|
var import_react8 = require("react");
|
|
349
352
|
|
|
350
353
|
// src/column-menu/ColumnMenu.tsx
|
|
351
354
|
var import_vuu_popups = require("@vuu-ui/vuu-popups");
|
|
352
|
-
var
|
|
355
|
+
var import_clsx4 = __toESM(require("clsx"));
|
|
353
356
|
var import_react7 = require("react");
|
|
354
357
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
355
358
|
var getPosition = (element) => {
|
|
@@ -386,7 +389,7 @@ var ColumnMenu = ({
|
|
|
386
389
|
"span",
|
|
387
390
|
{
|
|
388
391
|
...props,
|
|
389
|
-
className: (0,
|
|
392
|
+
className: (0, import_clsx4.default)("vuuTable-columnMenu", className, {
|
|
390
393
|
"vuuTable-columnMenu-open": menuOpen
|
|
391
394
|
}),
|
|
392
395
|
"data-icon": "more-vert",
|
|
@@ -397,7 +400,6 @@ var ColumnMenu = ({
|
|
|
397
400
|
};
|
|
398
401
|
|
|
399
402
|
// src/header-cell/HeaderCell.tsx
|
|
400
|
-
var import_classnames5 = __toESM(require("classnames"));
|
|
401
403
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
402
404
|
var classBase3 = "vuuTableHeaderCell";
|
|
403
405
|
var HeaderCell = ({
|
|
@@ -431,7 +433,7 @@ var HeaderCell = ({
|
|
|
431
433
|
"div",
|
|
432
434
|
{
|
|
433
435
|
...htmlAttributes,
|
|
434
|
-
className: (0,
|
|
436
|
+
className: (0, import_clsx5.default)(className, classNameProp, {
|
|
435
437
|
[`${classBase3}-resizing`]: isResizing
|
|
436
438
|
}),
|
|
437
439
|
onClick: handleClick,
|
|
@@ -449,18 +451,18 @@ var HeaderCell = ({
|
|
|
449
451
|
// src/Table.tsx
|
|
450
452
|
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
451
453
|
var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
|
|
452
|
-
var
|
|
454
|
+
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
453
455
|
var import_core2 = require("@salt-ds/core");
|
|
454
|
-
var
|
|
455
|
-
var
|
|
456
|
+
var import_clsx9 = __toESM(require("clsx"));
|
|
457
|
+
var import_react26 = require("react");
|
|
456
458
|
|
|
457
459
|
// src/Row.tsx
|
|
458
|
-
var
|
|
459
|
-
var
|
|
460
|
+
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
461
|
+
var import_clsx7 = __toESM(require("clsx"));
|
|
460
462
|
var import_react11 = require("react");
|
|
461
463
|
|
|
462
464
|
// src/table-cell/TableCell.tsx
|
|
463
|
-
var
|
|
465
|
+
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
464
466
|
var import_react9 = require("react");
|
|
465
467
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
466
468
|
var classBase4 = "vuuTableCell";
|
|
@@ -478,7 +480,7 @@ var TableCell = ({
|
|
|
478
480
|
(value) => {
|
|
479
481
|
if (onDataEdited) {
|
|
480
482
|
let typedValue = value;
|
|
481
|
-
if ((0,
|
|
483
|
+
if ((0, import_vuu_utils3.isNumericColumn)(column) && typeof value === "string") {
|
|
482
484
|
typedValue = column.serverDataType === "double" ? parseFloat(value) : parseInt(value);
|
|
483
485
|
}
|
|
484
486
|
return onDataEdited == null ? void 0 : onDataEdited(row, name, typedValue);
|
|
@@ -517,15 +519,15 @@ var TableCell = ({
|
|
|
517
519
|
};
|
|
518
520
|
|
|
519
521
|
// src/table-cell/TableGroupCell.tsx
|
|
520
|
-
var
|
|
522
|
+
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
521
523
|
var import_react10 = require("react");
|
|
522
|
-
var
|
|
524
|
+
var import_clsx6 = __toESM(require("clsx"));
|
|
523
525
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
524
|
-
var { IS_LEAF } =
|
|
526
|
+
var { IS_LEAF } = import_vuu_utils4.metadataKeys;
|
|
525
527
|
var classBase5 = "vuuTableGroupCell";
|
|
526
528
|
var TableGroupCell = ({ column, onClick, row }) => {
|
|
527
529
|
const { columns } = column;
|
|
528
|
-
const [value, offset] = (0,
|
|
530
|
+
const [value, offset] = (0, import_vuu_utils4.getGroupValueAndOffset)(columns, row);
|
|
529
531
|
const { className, style } = useCell(column, classBase5);
|
|
530
532
|
const handleClick = (0, import_react10.useCallback)(
|
|
531
533
|
(evt) => {
|
|
@@ -538,7 +540,7 @@ var TableGroupCell = ({ column, onClick, row }) => {
|
|
|
538
540
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
539
541
|
"div",
|
|
540
542
|
{
|
|
541
|
-
className: (0,
|
|
543
|
+
className: (0, import_clsx6.default)(className, "vuuTableCell"),
|
|
542
544
|
role: "cell",
|
|
543
545
|
style,
|
|
544
546
|
onClick: isLeaf ? void 0 : handleClick,
|
|
@@ -554,7 +556,7 @@ var TableGroupCell = ({ column, onClick, row }) => {
|
|
|
554
556
|
// src/Row.tsx
|
|
555
557
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
556
558
|
var import_react12 = require("react");
|
|
557
|
-
var { IDX, IS_EXPANDED, SELECTED } =
|
|
559
|
+
var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils5.metadataKeys;
|
|
558
560
|
var classBase6 = "vuuTableRow";
|
|
559
561
|
var Row = (0, import_react11.memo)(
|
|
560
562
|
({
|
|
@@ -583,8 +585,8 @@ var Row = (0, import_react11.memo)(
|
|
|
583
585
|
},
|
|
584
586
|
[onClick, row]
|
|
585
587
|
);
|
|
586
|
-
const { True, First, Last } =
|
|
587
|
-
const className = (0,
|
|
588
|
+
const { True, First, Last } = import_vuu_utils5.RowSelected;
|
|
589
|
+
const className = (0, import_clsx7.default)(classBase6, classNameProp, {
|
|
588
590
|
[`${classBase6}-even`]: zebraStripes && rowIndex % 2 === 0,
|
|
589
591
|
[`${classBase6}-expanded`]: isExpanded,
|
|
590
592
|
[`${classBase6}-highlighted`]: highlighted,
|
|
@@ -595,7 +597,7 @@ var Row = (0, import_react11.memo)(
|
|
|
595
597
|
const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
|
|
596
598
|
const handleGroupCellClick = (0, import_react11.useCallback)(
|
|
597
599
|
(evt, column) => {
|
|
598
|
-
if ((0,
|
|
600
|
+
if ((0, import_vuu_utils5.isGroupColumn)(column) || (0, import_vuu_utils5.isJsonGroup)(column, row)) {
|
|
599
601
|
evt.stopPropagation();
|
|
600
602
|
onToggleGroup == null ? void 0 : onToggleGroup(row, column);
|
|
601
603
|
}
|
|
@@ -606,7 +608,7 @@ var Row = (0, import_react11.memo)(
|
|
|
606
608
|
"div",
|
|
607
609
|
{
|
|
608
610
|
...htmlAttributes,
|
|
609
|
-
"aria-rowindex": row[0],
|
|
611
|
+
"aria-rowindex": row[0] + 1,
|
|
610
612
|
key: `row-${row[0]}`,
|
|
611
613
|
role: "row",
|
|
612
614
|
className,
|
|
@@ -614,9 +616,9 @@ var Row = (0, import_react11.memo)(
|
|
|
614
616
|
style
|
|
615
617
|
},
|
|
616
618
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase6}-selectionDecorator vuuStickyLeft` }),
|
|
617
|
-
columns.filter(
|
|
618
|
-
const isGroup = (0,
|
|
619
|
-
const isJsonCell = (0,
|
|
619
|
+
columns.filter(import_vuu_utils5.isNotHidden).map((column) => {
|
|
620
|
+
const isGroup = (0, import_vuu_utils5.isGroupColumn)(column);
|
|
621
|
+
const isJsonCell = (0, import_vuu_utils5.isJsonColumn)(column);
|
|
620
622
|
const Cell = isGroup ? TableGroupCell : TableCell;
|
|
621
623
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
622
624
|
Cell,
|
|
@@ -637,14 +639,12 @@ var Row = (0, import_react11.memo)(
|
|
|
637
639
|
Row.displayName = "Row";
|
|
638
640
|
|
|
639
641
|
// src/useTable.ts
|
|
640
|
-
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
641
|
-
var import_vuu_table_extras = require("@vuu-ui/vuu-table-extras");
|
|
642
642
|
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
643
|
-
var
|
|
644
|
-
var
|
|
643
|
+
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
644
|
+
var import_react24 = require("react");
|
|
645
645
|
|
|
646
646
|
// src/context-menu/buildContextMenuDescriptors.ts
|
|
647
|
-
var
|
|
647
|
+
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
648
648
|
var buildContextMenuDescriptors = (dataSource) => (location, options) => {
|
|
649
649
|
const descriptors = [];
|
|
650
650
|
if (dataSource === void 0) {
|
|
@@ -762,7 +762,7 @@ function buildAggregationMenuItems(options, dataSource) {
|
|
|
762
762
|
{ label: "Count", action: "agg-count", options },
|
|
763
763
|
{ label: "Distinct", action: "agg-distinct", options }
|
|
764
764
|
].concat(
|
|
765
|
-
(0,
|
|
765
|
+
(0, import_vuu_utils6.isNumericColumn)(column) ? [
|
|
766
766
|
{ label: "Sum", action: "agg-sum", options },
|
|
767
767
|
{ label: "Avg", action: "agg-avg", options },
|
|
768
768
|
{ label: "High", action: "agg-high", options },
|
|
@@ -854,11 +854,11 @@ function buildGroupMenuItems(options, { groupBy }) {
|
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
// src/context-menu/useHandleTableContextMenu.ts
|
|
857
|
-
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
858
857
|
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
858
|
+
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
859
859
|
var removeFilterColumn = (dataSourceFilter, column) => {
|
|
860
860
|
if (dataSourceFilter.filterStruct && column) {
|
|
861
|
-
const [filterStruct, filter] = (0,
|
|
861
|
+
const [filterStruct, filter] = (0, import_vuu_utils7.removeColumnFromFilter)(
|
|
862
862
|
column,
|
|
863
863
|
dataSourceFilter.filterStruct
|
|
864
864
|
);
|
|
@@ -870,7 +870,7 @@ var removeFilterColumn = (dataSourceFilter, column) => {
|
|
|
870
870
|
return dataSourceFilter;
|
|
871
871
|
}
|
|
872
872
|
};
|
|
873
|
-
var { Average, Count, Distinct, High, Low, Sum } =
|
|
873
|
+
var { Average, Count, Distinct, High, Low, Sum } = import_vuu_utils8.AggregationType;
|
|
874
874
|
var useHandleTableContextMenu = ({
|
|
875
875
|
dataSource,
|
|
876
876
|
onPersistentColumnOperation
|
|
@@ -881,17 +881,17 @@ var useHandleTableContextMenu = ({
|
|
|
881
881
|
const { column } = gridOptions;
|
|
882
882
|
switch (action.menuId) {
|
|
883
883
|
case "sort-asc":
|
|
884
|
-
return dataSource.sort = (0,
|
|
884
|
+
return dataSource.sort = (0, import_vuu_utils8.setSortColumn)(dataSource.sort, column, "A"), true;
|
|
885
885
|
case "sort-dsc":
|
|
886
|
-
return dataSource.sort = (0,
|
|
886
|
+
return dataSource.sort = (0, import_vuu_utils8.setSortColumn)(dataSource.sort, column, "D"), true;
|
|
887
887
|
case "sort-add-asc":
|
|
888
|
-
return dataSource.sort = (0,
|
|
888
|
+
return dataSource.sort = (0, import_vuu_utils8.addSortColumn)(dataSource.sort, column, "A"), true;
|
|
889
889
|
case "sort-add-dsc":
|
|
890
|
-
return dataSource.sort = (0,
|
|
890
|
+
return dataSource.sort = (0, import_vuu_utils8.addSortColumn)(dataSource.sort, column, "D"), true;
|
|
891
891
|
case "group":
|
|
892
|
-
return dataSource.groupBy = (0,
|
|
892
|
+
return dataSource.groupBy = (0, import_vuu_utils8.addGroupColumn)(dataSource.groupBy, column), true;
|
|
893
893
|
case "group-add":
|
|
894
|
-
return dataSource.groupBy = (0,
|
|
894
|
+
return dataSource.groupBy = (0, import_vuu_utils8.addGroupColumn)(dataSource.groupBy, column), true;
|
|
895
895
|
case "column-hide":
|
|
896
896
|
return onPersistentColumnOperation({ type: "hideColumns", columns: [column] }), true;
|
|
897
897
|
case "column-remove":
|
|
@@ -901,17 +901,17 @@ var useHandleTableContextMenu = ({
|
|
|
901
901
|
case "remove-filters":
|
|
902
902
|
return dataSource.filter = { filter: "" }, true;
|
|
903
903
|
case "agg-avg":
|
|
904
|
-
return dataSource.aggregations = (0,
|
|
904
|
+
return dataSource.aggregations = (0, import_vuu_utils8.setAggregations)(dataSource.aggregations, column, Average), true;
|
|
905
905
|
case "agg-high":
|
|
906
|
-
return dataSource.aggregations = (0,
|
|
906
|
+
return dataSource.aggregations = (0, import_vuu_utils8.setAggregations)(dataSource.aggregations, column, High), true;
|
|
907
907
|
case "agg-low":
|
|
908
|
-
return dataSource.aggregations = (0,
|
|
908
|
+
return dataSource.aggregations = (0, import_vuu_utils8.setAggregations)(dataSource.aggregations, column, Low), true;
|
|
909
909
|
case "agg-count":
|
|
910
|
-
return dataSource.aggregations = (0,
|
|
910
|
+
return dataSource.aggregations = (0, import_vuu_utils8.setAggregations)(dataSource.aggregations, column, Count), true;
|
|
911
911
|
case "agg-distinct":
|
|
912
|
-
return dataSource.aggregations = (0,
|
|
912
|
+
return dataSource.aggregations = (0, import_vuu_utils8.setAggregations)(dataSource.aggregations, column, Distinct), true;
|
|
913
913
|
case "agg-sum":
|
|
914
|
-
return dataSource.aggregations = (0,
|
|
914
|
+
return dataSource.aggregations = (0, import_vuu_utils8.setAggregations)(dataSource.aggregations, column, Sum), true;
|
|
915
915
|
case "column-pin-floating":
|
|
916
916
|
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "floating" }), true;
|
|
917
917
|
case "column-pin-left":
|
|
@@ -955,7 +955,7 @@ var updateTableConfig = (config, action) => {
|
|
|
955
955
|
};
|
|
956
956
|
|
|
957
957
|
// src/useCellEditing.ts
|
|
958
|
-
var
|
|
958
|
+
var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
|
|
959
959
|
var import_react13 = require("react");
|
|
960
960
|
|
|
961
961
|
// src/table-dom-utils.ts
|
|
@@ -980,7 +980,7 @@ function getRowIndex(rowEl) {
|
|
|
980
980
|
if (rowEl) {
|
|
981
981
|
const idx = rowEl.ariaRowIndex;
|
|
982
982
|
if (idx !== null) {
|
|
983
|
-
return parseInt(idx, 10);
|
|
983
|
+
return parseInt(idx, 10) - 1;
|
|
984
984
|
}
|
|
985
985
|
}
|
|
986
986
|
return -1;
|
|
@@ -1019,7 +1019,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1019
1019
|
(e) => {
|
|
1020
1020
|
const el = e.target;
|
|
1021
1021
|
if (cellIsTextInput(el)) {
|
|
1022
|
-
if ((0,
|
|
1022
|
+
if ((0, import_vuu_utils9.isCharacterKey)(e.key)) {
|
|
1023
1023
|
editInput(e);
|
|
1024
1024
|
} else if (e.key === "Enter") {
|
|
1025
1025
|
focusInput(e);
|
|
@@ -1061,13 +1061,12 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1061
1061
|
};
|
|
1062
1062
|
|
|
1063
1063
|
// src/useDataSource.ts
|
|
1064
|
-
var
|
|
1065
|
-
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
1064
|
+
var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
|
|
1066
1065
|
var import_react14 = require("react");
|
|
1067
1066
|
|
|
1068
1067
|
// src/moving-window.ts
|
|
1069
|
-
var
|
|
1070
|
-
var { SELECTED: SELECTED2 } =
|
|
1068
|
+
var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
|
|
1069
|
+
var { SELECTED: SELECTED2 } = import_vuu_utils10.metadataKeys;
|
|
1071
1070
|
var MovingWindow = class {
|
|
1072
1071
|
constructor({ from, to }) {
|
|
1073
1072
|
this.rowCount = 0;
|
|
@@ -1077,7 +1076,7 @@ var MovingWindow = class {
|
|
|
1077
1076
|
}
|
|
1078
1077
|
this.rowCount = rowCount;
|
|
1079
1078
|
};
|
|
1080
|
-
this.range = new
|
|
1079
|
+
this.range = new import_vuu_utils10.WindowRange(from, to);
|
|
1081
1080
|
this.data = new Array(Math.max(0, to - from));
|
|
1082
1081
|
this.rowCount = 0;
|
|
1083
1082
|
}
|
|
@@ -1088,7 +1087,7 @@ var MovingWindow = class {
|
|
|
1088
1087
|
this.data[internalIndex] = data;
|
|
1089
1088
|
if (data[SELECTED2]) {
|
|
1090
1089
|
const previousRow = this.data[internalIndex - 1];
|
|
1091
|
-
if ((0,
|
|
1090
|
+
if ((0, import_vuu_utils10.isRowSelectedLast)(previousRow)) {
|
|
1092
1091
|
this.data[internalIndex - 1] = previousRow.slice();
|
|
1093
1092
|
this.data[internalIndex - 1][SELECTED2] -= 4;
|
|
1094
1093
|
}
|
|
@@ -1123,21 +1122,22 @@ var MovingWindow = class {
|
|
|
1123
1122
|
};
|
|
1124
1123
|
|
|
1125
1124
|
// src/useDataSource.ts
|
|
1125
|
+
var isVuuFeatureInvocation = (action) => action.type === "vuu-link-created" || action.type === "vuu-link-removed";
|
|
1126
1126
|
var useDataSource = ({
|
|
1127
1127
|
dataSource,
|
|
1128
1128
|
onFeatureInvocation,
|
|
1129
1129
|
onSizeChange,
|
|
1130
1130
|
onSubscribed,
|
|
1131
|
-
range =
|
|
1131
|
+
range = import_vuu_utils11.NULL_RANGE,
|
|
1132
1132
|
renderBufferSize = 0
|
|
1133
1133
|
}) => {
|
|
1134
1134
|
const [, forceUpdate] = (0, import_react14.useState)(null);
|
|
1135
1135
|
const data = (0, import_react14.useRef)([]);
|
|
1136
1136
|
const isMounted = (0, import_react14.useRef)(true);
|
|
1137
1137
|
const hasUpdated = (0, import_react14.useRef)(false);
|
|
1138
|
-
const rangeRef = (0, import_react14.useRef)(
|
|
1138
|
+
const rangeRef = (0, import_react14.useRef)(import_vuu_utils11.NULL_RANGE);
|
|
1139
1139
|
const dataWindow = (0, import_react14.useMemo)(
|
|
1140
|
-
() => new MovingWindow((0,
|
|
1140
|
+
() => new MovingWindow((0, import_vuu_utils11.getFullRange)(range, renderBufferSize)),
|
|
1141
1141
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1142
1142
|
[]
|
|
1143
1143
|
);
|
|
@@ -1170,7 +1170,7 @@ var useDataSource = ({
|
|
|
1170
1170
|
data.current = dataWindow.data;
|
|
1171
1171
|
hasUpdated.current = true;
|
|
1172
1172
|
}
|
|
1173
|
-
} else if (
|
|
1173
|
+
} else if (isVuuFeatureInvocation(message)) {
|
|
1174
1174
|
onFeatureInvocation == null ? void 0 : onFeatureInvocation(message);
|
|
1175
1175
|
} else {
|
|
1176
1176
|
console.log(`useDataSource unexpected message ${message.type}`);
|
|
@@ -1197,14 +1197,14 @@ var useDataSource = ({
|
|
|
1197
1197
|
(_a = dataSource.enable) == null ? void 0 : _a.call(dataSource, datasourceMessageHandler);
|
|
1198
1198
|
} else {
|
|
1199
1199
|
dataSource == null ? void 0 : dataSource.subscribe(
|
|
1200
|
-
{ range: (0,
|
|
1200
|
+
{ range: (0, import_vuu_utils11.getFullRange)(range, renderBufferSize) },
|
|
1201
1201
|
datasourceMessageHandler
|
|
1202
1202
|
);
|
|
1203
1203
|
}
|
|
1204
1204
|
}, [dataSource, datasourceMessageHandler, range, renderBufferSize]);
|
|
1205
1205
|
const setRange = (0, import_react14.useCallback)(
|
|
1206
1206
|
(range2) => {
|
|
1207
|
-
const fullRange = (0,
|
|
1207
|
+
const fullRange = (0, import_vuu_utils11.getFullRange)(range2, renderBufferSize);
|
|
1208
1208
|
dataWindow.setRange(fullRange);
|
|
1209
1209
|
dataSource.range = rangeRef.current = fullRange;
|
|
1210
1210
|
dataSource.emit("range", range2);
|
|
@@ -1576,9 +1576,9 @@ var useKeyboardNavigation = ({
|
|
|
1576
1576
|
};
|
|
1577
1577
|
|
|
1578
1578
|
// src/useSelection.ts
|
|
1579
|
-
var
|
|
1579
|
+
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
1580
1580
|
var import_react17 = require("react");
|
|
1581
|
-
var { IDX: IDX2 } =
|
|
1581
|
+
var { IDX: IDX2 } = import_vuu_utils12.metadataKeys;
|
|
1582
1582
|
var NO_SELECTION = [];
|
|
1583
1583
|
var defaultSelectionKeys = ["Enter", " "];
|
|
1584
1584
|
var useSelection = ({
|
|
@@ -1600,7 +1600,7 @@ var useSelection = ({
|
|
|
1600
1600
|
const { [IDX2]: idx } = row;
|
|
1601
1601
|
const { current: active } = lastActiveRef;
|
|
1602
1602
|
const { current: selected } = selectedRef;
|
|
1603
|
-
const selectOperation = (0,
|
|
1603
|
+
const selectOperation = (0, import_vuu_utils12.isRowSelected)(row) ? import_vuu_utils12.deselectItem : import_vuu_utils12.selectItem;
|
|
1604
1604
|
const newSelected = selectOperation(
|
|
1605
1605
|
selectionModel,
|
|
1606
1606
|
selected,
|
|
@@ -1625,7 +1625,7 @@ var useSelection = ({
|
|
|
1625
1625
|
`[aria-rowindex="${rowIndex}"]`
|
|
1626
1626
|
);
|
|
1627
1627
|
if (rowEl) {
|
|
1628
|
-
(0,
|
|
1628
|
+
(0, import_vuu_utils12.dispatchMouseEvent)(rowEl, "click");
|
|
1629
1629
|
}
|
|
1630
1630
|
}
|
|
1631
1631
|
}
|
|
@@ -1640,7 +1640,7 @@ var useSelection = ({
|
|
|
1640
1640
|
|
|
1641
1641
|
// src/useTableContextMenu.ts
|
|
1642
1642
|
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
1643
|
-
var
|
|
1643
|
+
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
1644
1644
|
var import_react18 = require("react");
|
|
1645
1645
|
var NO_ROWS = [];
|
|
1646
1646
|
var useTableContextMenu = ({
|
|
@@ -1658,7 +1658,7 @@ var useTableContextMenu = ({
|
|
|
1658
1658
|
const rowEl = target == null ? void 0 : target.closest("div[role='row']");
|
|
1659
1659
|
if (cellEl && rowEl) {
|
|
1660
1660
|
const { selectedRowsCount } = dataSource;
|
|
1661
|
-
const columnMap = (0,
|
|
1661
|
+
const columnMap = (0, import_vuu_utils13.buildColumnMap)(columns);
|
|
1662
1662
|
const rowIndex = parseInt((_a = rowEl.ariaRowIndex) != null ? _a : "-1");
|
|
1663
1663
|
const cellIndex = Array.from(rowEl.childNodes).indexOf(cellEl);
|
|
1664
1664
|
const row = data.find(([idx]) => idx === rowIndex);
|
|
@@ -1678,12 +1678,12 @@ var useTableContextMenu = ({
|
|
|
1678
1678
|
};
|
|
1679
1679
|
|
|
1680
1680
|
// src/useTableModel.ts
|
|
1681
|
-
var
|
|
1681
|
+
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
1682
1682
|
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
1683
1683
|
var import_react19 = require("react");
|
|
1684
|
-
var { info } = (0,
|
|
1684
|
+
var { info } = (0, import_vuu_utils14.logger)("useTableModel");
|
|
1685
1685
|
var DEFAULT_COLUMN_WIDTH = 100;
|
|
1686
|
-
var KEY_OFFSET =
|
|
1686
|
+
var KEY_OFFSET = import_vuu_utils14.metadataKeys.count;
|
|
1687
1687
|
var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
|
|
1688
1688
|
var getDataType = (column, tableSchema) => {
|
|
1689
1689
|
const schemaColumn = tableSchema == null ? void 0 : tableSchema.columns.find(
|
|
@@ -1738,15 +1738,14 @@ var useTableModel = (tableConfigProp, dataSource) => {
|
|
|
1738
1738
|
};
|
|
1739
1739
|
function init({ dataSource, tableConfig }) {
|
|
1740
1740
|
const { columns, ...tableAttributes } = tableConfig;
|
|
1741
|
-
console.log(JSON.stringify(tableAttributes, null, 2));
|
|
1742
1741
|
const { config: dataSourceConfig, tableSchema } = dataSource;
|
|
1743
|
-
const runtimeColumns = columns.filter((0,
|
|
1742
|
+
const runtimeColumns = columns.filter((0, import_vuu_utils14.subscribedOnly)(dataSourceConfig == null ? void 0 : dataSourceConfig.columns)).map(
|
|
1744
1743
|
columnDescriptorToRuntimeColumDescriptor(tableAttributes, tableSchema)
|
|
1745
1744
|
);
|
|
1746
|
-
const maybePinnedColumns = runtimeColumns.some(
|
|
1745
|
+
const maybePinnedColumns = runtimeColumns.some(import_vuu_utils14.isPinned) ? (0, import_vuu_utils14.sortPinnedColumns)(runtimeColumns) : runtimeColumns;
|
|
1747
1746
|
let state = {
|
|
1748
1747
|
columns: maybePinnedColumns,
|
|
1749
|
-
headings: (0,
|
|
1748
|
+
headings: (0, import_vuu_utils14.getTableHeadings)(maybePinnedColumns),
|
|
1750
1749
|
tableConfig,
|
|
1751
1750
|
...tableAttributes
|
|
1752
1751
|
};
|
|
@@ -1774,26 +1773,26 @@ var columnDescriptorToRuntimeColumDescriptor = (tableAttributes, tableSchema) =>
|
|
|
1774
1773
|
align = getDefaultAlignment(serverDataType),
|
|
1775
1774
|
key,
|
|
1776
1775
|
name,
|
|
1777
|
-
label = (0,
|
|
1776
|
+
label = (0, import_vuu_utils14.getColumnLabel)(column),
|
|
1778
1777
|
width = columnDefaultWidth,
|
|
1779
1778
|
...rest
|
|
1780
1779
|
} = column;
|
|
1781
1780
|
const runtimeColumnWithDefaults = {
|
|
1782
1781
|
...rest,
|
|
1783
1782
|
align,
|
|
1784
|
-
CellRenderer: (0,
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
clientSideEditValidationCheck: (0,
|
|
1783
|
+
CellRenderer: (0, import_vuu_utils14.getCellRenderer)(column),
|
|
1784
|
+
HeaderCellContentRenderer: (0, import_vuu_utils14.getColumnHeaderContentRenderer)(column),
|
|
1785
|
+
HeaderCellLabelRenderer: (0, import_vuu_utils14.getColumnHeaderLabelRenderer)(column),
|
|
1786
|
+
clientSideEditValidationCheck: (0, import_vuu_utils14.hasValidationRules)(column.type) ? (0, import_vuu_ui_controls.buildValidationChecker)(column.type.renderer.rules) : void 0,
|
|
1788
1787
|
label: getLabel(label, columnFormatHeader),
|
|
1789
1788
|
key: key != null ? key : index + KEY_OFFSET,
|
|
1790
1789
|
name,
|
|
1791
1790
|
originalIdx: index,
|
|
1792
1791
|
serverDataType,
|
|
1793
|
-
valueFormatter: (0,
|
|
1792
|
+
valueFormatter: (0, import_vuu_utils14.getValueFormatter)(column, serverDataType),
|
|
1794
1793
|
width
|
|
1795
1794
|
};
|
|
1796
|
-
if ((0,
|
|
1795
|
+
if ((0, import_vuu_utils14.isGroupColumn)(runtimeColumnWithDefaults)) {
|
|
1797
1796
|
runtimeColumnWithDefaults.columns = runtimeColumnWithDefaults.columns.map(
|
|
1798
1797
|
(col) => columnDescriptorToRuntimeColumDescriptor(tableAttributes)(
|
|
1799
1798
|
col,
|
|
@@ -1890,8 +1889,8 @@ function pinColumn2(state, action) {
|
|
|
1890
1889
|
const { column, pin } = action;
|
|
1891
1890
|
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1892
1891
|
if (targetColumn) {
|
|
1893
|
-
columns = (0,
|
|
1894
|
-
columns = (0,
|
|
1892
|
+
columns = (0, import_vuu_utils14.replaceColumn)(columns, { ...targetColumn, pin });
|
|
1893
|
+
columns = (0, import_vuu_utils14.sortPinnedColumns)(columns);
|
|
1895
1894
|
return {
|
|
1896
1895
|
...state,
|
|
1897
1896
|
columns
|
|
@@ -1906,26 +1905,26 @@ function updateColumnProp(state, action) {
|
|
|
1906
1905
|
const targetColumn = columns.find((col) => col.name === column.name);
|
|
1907
1906
|
if (targetColumn) {
|
|
1908
1907
|
if (align === "left" || align === "right") {
|
|
1909
|
-
columns = (0,
|
|
1908
|
+
columns = (0, import_vuu_utils14.replaceColumn)(columns, { ...targetColumn, align });
|
|
1910
1909
|
}
|
|
1911
1910
|
if (typeof label === "string") {
|
|
1912
|
-
columns = (0,
|
|
1911
|
+
columns = (0, import_vuu_utils14.replaceColumn)(columns, { ...targetColumn, label });
|
|
1913
1912
|
}
|
|
1914
1913
|
if (typeof resizing === "boolean") {
|
|
1915
|
-
columns = (0,
|
|
1914
|
+
columns = (0, import_vuu_utils14.replaceColumn)(columns, { ...targetColumn, resizing });
|
|
1916
1915
|
}
|
|
1917
1916
|
if (typeof hidden === "boolean") {
|
|
1918
|
-
columns = (0,
|
|
1917
|
+
columns = (0, import_vuu_utils14.replaceColumn)(columns, { ...targetColumn, hidden });
|
|
1919
1918
|
}
|
|
1920
1919
|
if (typeof width === "number") {
|
|
1921
|
-
columns = (0,
|
|
1920
|
+
columns = (0, import_vuu_utils14.replaceColumn)(columns, { ...targetColumn, width });
|
|
1922
1921
|
const targetConfigColumn = tableConfig.columns.find(
|
|
1923
1922
|
(col) => col.name === column.name
|
|
1924
1923
|
);
|
|
1925
1924
|
if (targetConfigColumn) {
|
|
1926
1925
|
tableConfig = {
|
|
1927
1926
|
...tableConfig,
|
|
1928
|
-
columns: (0,
|
|
1927
|
+
columns: (0, import_vuu_utils14.replaceColumn)(tableConfig.columns, {
|
|
1929
1928
|
...targetConfigColumn,
|
|
1930
1929
|
width
|
|
1931
1930
|
})
|
|
@@ -1947,24 +1946,24 @@ function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
|
1947
1946
|
if (hasGroupBy) {
|
|
1948
1947
|
result = {
|
|
1949
1948
|
...state,
|
|
1950
|
-
columns: (0,
|
|
1949
|
+
columns: (0, import_vuu_utils14.applyGroupByToColumns)(result.columns, groupBy, confirmed)
|
|
1951
1950
|
};
|
|
1952
1951
|
}
|
|
1953
1952
|
if (hasSort) {
|
|
1954
1953
|
result = {
|
|
1955
1954
|
...state,
|
|
1956
|
-
columns: (0,
|
|
1955
|
+
columns: (0, import_vuu_utils14.applySortToColumns)(result.columns, sort)
|
|
1957
1956
|
};
|
|
1958
1957
|
}
|
|
1959
1958
|
if (hasFilter) {
|
|
1960
1959
|
result = {
|
|
1961
1960
|
...state,
|
|
1962
|
-
columns: (0,
|
|
1961
|
+
columns: (0, import_vuu_utils14.applyFilterToColumns)(result.columns, filter)
|
|
1963
1962
|
};
|
|
1964
|
-
} else if (result.columns.some(
|
|
1963
|
+
} else if (result.columns.some(import_vuu_utils14.isFilteredColumn)) {
|
|
1965
1964
|
result = {
|
|
1966
1965
|
...state,
|
|
1967
|
-
columns: (0,
|
|
1966
|
+
columns: (0, import_vuu_utils14.stripFilterFromColumns)(result.columns)
|
|
1968
1967
|
};
|
|
1969
1968
|
}
|
|
1970
1969
|
return result;
|
|
@@ -2150,7 +2149,7 @@ var useTableScroll = ({
|
|
|
2150
2149
|
|
|
2151
2150
|
// src/useTableViewport.ts
|
|
2152
2151
|
var import_react21 = require("react");
|
|
2153
|
-
var
|
|
2152
|
+
var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
|
|
2154
2153
|
var MAX_RAW_ROWS = 15e5;
|
|
2155
2154
|
var UNMEASURED_VIEWPORT = {
|
|
2156
2155
|
contentHeight: 0,
|
|
@@ -2207,12 +2206,12 @@ var useTableViewport = ({
|
|
|
2207
2206
|
[columns]
|
|
2208
2207
|
);
|
|
2209
2208
|
const [actualRowOffset, actualRowAtPosition] = (0, import_react21.useMemo)(
|
|
2210
|
-
() => (0,
|
|
2209
|
+
() => (0, import_vuu_utils15.actualRowPositioning)(rowHeight),
|
|
2211
2210
|
[rowHeight]
|
|
2212
2211
|
);
|
|
2213
2212
|
const [getRowOffset, getRowAtPosition] = (0, import_react21.useMemo)(() => {
|
|
2214
2213
|
if (virtualisedExtent) {
|
|
2215
|
-
return (0,
|
|
2214
|
+
return (0, import_vuu_utils15.virtualRowPositioning)(
|
|
2216
2215
|
rowHeight,
|
|
2217
2216
|
virtualisedExtent,
|
|
2218
2217
|
pctScrollTopRef
|
|
@@ -2275,13 +2274,12 @@ var useTableViewport = ({
|
|
|
2275
2274
|
// src/useVirtualViewport.ts
|
|
2276
2275
|
var import_react22 = require("react");
|
|
2277
2276
|
var useVirtualViewport = ({
|
|
2278
|
-
columns,
|
|
2279
2277
|
getRowAtPosition,
|
|
2280
2278
|
setRange,
|
|
2281
2279
|
viewportMeasurements
|
|
2282
2280
|
}) => {
|
|
2283
2281
|
const firstRowRef = (0, import_react22.useRef)(0);
|
|
2284
|
-
const {
|
|
2282
|
+
const { rowCount: viewportRowCount } = viewportMeasurements;
|
|
2285
2283
|
const handleVerticalScroll = (0, import_react22.useCallback)(
|
|
2286
2284
|
(scrollTop) => {
|
|
2287
2285
|
const firstRow = getRowAtPosition(scrollTop);
|
|
@@ -2302,11 +2300,137 @@ var useVirtualViewport = ({
|
|
|
2302
2300
|
};
|
|
2303
2301
|
};
|
|
2304
2302
|
|
|
2303
|
+
// src/useTableAndColumnSettings.ts
|
|
2304
|
+
var import_vuu_layout2 = require("@vuu-ui/vuu-layout");
|
|
2305
|
+
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
2306
|
+
var import_react23 = require("react");
|
|
2307
|
+
var useTableAndColumnSettings = ({
|
|
2308
|
+
availableColumns: availableColumnsProps,
|
|
2309
|
+
onAvailableColumnsChange,
|
|
2310
|
+
onConfigChange,
|
|
2311
|
+
onCreateCalculatedColumn,
|
|
2312
|
+
onDataSourceConfigChange,
|
|
2313
|
+
tableConfig
|
|
2314
|
+
}) => {
|
|
2315
|
+
const dispatchLayoutAction = (0, import_vuu_layout2.useLayoutProviderDispatch)();
|
|
2316
|
+
const showTableSettingsRef = (0, import_react23.useRef)();
|
|
2317
|
+
const [availableColumns, setAvailableColumns] = (0, import_react23.useState)(
|
|
2318
|
+
availableColumnsProps
|
|
2319
|
+
);
|
|
2320
|
+
const showContextPanel = (0, import_react23.useCallback)(
|
|
2321
|
+
(componentType, title, props) => {
|
|
2322
|
+
dispatchLayoutAction({
|
|
2323
|
+
type: "set-props",
|
|
2324
|
+
path: "#context-panel",
|
|
2325
|
+
props: {
|
|
2326
|
+
expanded: true,
|
|
2327
|
+
content: {
|
|
2328
|
+
type: componentType,
|
|
2329
|
+
props
|
|
2330
|
+
},
|
|
2331
|
+
title
|
|
2332
|
+
}
|
|
2333
|
+
});
|
|
2334
|
+
},
|
|
2335
|
+
[dispatchLayoutAction]
|
|
2336
|
+
);
|
|
2337
|
+
const handleCancelCreateColumn = (0, import_react23.useCallback)(() => {
|
|
2338
|
+
requestAnimationFrame(() => {
|
|
2339
|
+
var _a;
|
|
2340
|
+
(_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
|
|
2341
|
+
});
|
|
2342
|
+
}, []);
|
|
2343
|
+
const handleCreateCalculatedColumn = (0, import_react23.useCallback)(
|
|
2344
|
+
(column) => {
|
|
2345
|
+
const newAvailableColumns = availableColumns.concat({
|
|
2346
|
+
name: column.name,
|
|
2347
|
+
serverDataType: (0, import_vuu_utils16.getCalculatedColumnType)(column)
|
|
2348
|
+
});
|
|
2349
|
+
setAvailableColumns(newAvailableColumns);
|
|
2350
|
+
onAvailableColumnsChange == null ? void 0 : onAvailableColumnsChange(newAvailableColumns);
|
|
2351
|
+
requestAnimationFrame(() => {
|
|
2352
|
+
var _a;
|
|
2353
|
+
(_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
|
|
2354
|
+
});
|
|
2355
|
+
onCreateCalculatedColumn(column);
|
|
2356
|
+
},
|
|
2357
|
+
[availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
|
|
2358
|
+
);
|
|
2359
|
+
const showColumnSettingsPanel = (0, import_react23.useCallback)(
|
|
2360
|
+
(action) => {
|
|
2361
|
+
showContextPanel("ColumnSettings", "Column Settings", {
|
|
2362
|
+
column: action.column,
|
|
2363
|
+
onCancelCreateColumn: handleCancelCreateColumn,
|
|
2364
|
+
onConfigChange,
|
|
2365
|
+
onCreateCalculatedColumn: handleCreateCalculatedColumn,
|
|
2366
|
+
tableConfig,
|
|
2367
|
+
vuuTable: action.vuuTable
|
|
2368
|
+
});
|
|
2369
|
+
},
|
|
2370
|
+
[
|
|
2371
|
+
handleCancelCreateColumn,
|
|
2372
|
+
handleCreateCalculatedColumn,
|
|
2373
|
+
onConfigChange,
|
|
2374
|
+
showContextPanel,
|
|
2375
|
+
tableConfig
|
|
2376
|
+
]
|
|
2377
|
+
);
|
|
2378
|
+
const handleAddCalculatedColumn = (0, import_react23.useCallback)(() => {
|
|
2379
|
+
showColumnSettingsPanel({
|
|
2380
|
+
column: {
|
|
2381
|
+
name: "::",
|
|
2382
|
+
serverDataType: "string"
|
|
2383
|
+
},
|
|
2384
|
+
type: "columnSettings",
|
|
2385
|
+
vuuTable: { module: "SIMUL", table: "instruments" }
|
|
2386
|
+
});
|
|
2387
|
+
}, [showColumnSettingsPanel]);
|
|
2388
|
+
const handleNavigateToColumn = (0, import_react23.useCallback)(
|
|
2389
|
+
(columnName) => {
|
|
2390
|
+
const column = tableConfig.columns.find((c) => c.name === columnName);
|
|
2391
|
+
if (column) {
|
|
2392
|
+
showColumnSettingsPanel({
|
|
2393
|
+
type: "columnSettings",
|
|
2394
|
+
column,
|
|
2395
|
+
//TODO where do we get this from
|
|
2396
|
+
vuuTable: { module: "SIMUL", table: "instruments" }
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
},
|
|
2400
|
+
[showColumnSettingsPanel, tableConfig.columns]
|
|
2401
|
+
);
|
|
2402
|
+
showTableSettingsRef.current = (0, import_react23.useCallback)(() => {
|
|
2403
|
+
showContextPanel("TableSettings", "DataGrid Settings", {
|
|
2404
|
+
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType }) => ({
|
|
2405
|
+
name,
|
|
2406
|
+
serverDataType
|
|
2407
|
+
})),
|
|
2408
|
+
onAddCalculatedColumn: handleAddCalculatedColumn,
|
|
2409
|
+
onConfigChange,
|
|
2410
|
+
onDataSourceConfigChange,
|
|
2411
|
+
onNavigateToColumn: handleNavigateToColumn,
|
|
2412
|
+
tableConfig
|
|
2413
|
+
});
|
|
2414
|
+
}, [
|
|
2415
|
+
availableColumns,
|
|
2416
|
+
handleAddCalculatedColumn,
|
|
2417
|
+
handleNavigateToColumn,
|
|
2418
|
+
onConfigChange,
|
|
2419
|
+
onDataSourceConfigChange,
|
|
2420
|
+
showContextPanel,
|
|
2421
|
+
tableConfig
|
|
2422
|
+
]);
|
|
2423
|
+
return {
|
|
2424
|
+
showColumnSettingsPanel,
|
|
2425
|
+
showTableSettingsPanel: showTableSettingsRef.current
|
|
2426
|
+
};
|
|
2427
|
+
};
|
|
2428
|
+
|
|
2305
2429
|
// src/useTable.ts
|
|
2306
2430
|
var stripInternalProperties = (tableConfig) => {
|
|
2307
2431
|
return tableConfig;
|
|
2308
2432
|
};
|
|
2309
|
-
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } =
|
|
2433
|
+
var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils17.metadataKeys;
|
|
2310
2434
|
var NULL_DRAG_DROP = {
|
|
2311
2435
|
draggable: void 0,
|
|
2312
2436
|
onMouseDown: void 0
|
|
@@ -2341,16 +2465,16 @@ var useTable = ({
|
|
|
2341
2465
|
selectionModel,
|
|
2342
2466
|
size
|
|
2343
2467
|
}) => {
|
|
2344
|
-
const [rowCount, setRowCount] = (0,
|
|
2468
|
+
const [rowCount, setRowCount] = (0, import_react24.useState)(dataSource.size);
|
|
2345
2469
|
if (dataSource === void 0) {
|
|
2346
2470
|
throw Error("no data source provided to Vuu Table");
|
|
2347
2471
|
}
|
|
2348
2472
|
const useRowDragDrop = allowDragDrop ? import_vuu_ui_controls2.useDragDropNext : useNullDragDrop;
|
|
2349
|
-
const menuBuilder = (0,
|
|
2473
|
+
const menuBuilder = (0, import_react24.useMemo)(
|
|
2350
2474
|
() => buildContextMenuDescriptors(dataSource),
|
|
2351
2475
|
[dataSource]
|
|
2352
2476
|
);
|
|
2353
|
-
const onDataRowcountChange = (0,
|
|
2477
|
+
const onDataRowcountChange = (0, import_react24.useCallback)((size2) => {
|
|
2354
2478
|
setRowCount(size2);
|
|
2355
2479
|
}, []);
|
|
2356
2480
|
const {
|
|
@@ -2360,14 +2484,14 @@ var useTable = ({
|
|
|
2360
2484
|
tableAttributes,
|
|
2361
2485
|
tableConfig
|
|
2362
2486
|
} = useTableModel(config, dataSource);
|
|
2363
|
-
(0,
|
|
2487
|
+
(0, import_vuu_utils17.useLayoutEffectSkipFirst)(() => {
|
|
2364
2488
|
dispatchColumnAction({
|
|
2365
2489
|
type: "init",
|
|
2366
2490
|
dataSource,
|
|
2367
2491
|
tableConfig
|
|
2368
2492
|
});
|
|
2369
2493
|
}, [tableConfig, dataSource, dispatchColumnAction]);
|
|
2370
|
-
const applyTableConfigChange = (0,
|
|
2494
|
+
const applyTableConfigChange = (0, import_react24.useCallback)(
|
|
2371
2495
|
(config2) => {
|
|
2372
2496
|
dispatchColumnAction({
|
|
2373
2497
|
type: "init",
|
|
@@ -2378,16 +2502,16 @@ var useTable = ({
|
|
|
2378
2502
|
},
|
|
2379
2503
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2380
2504
|
);
|
|
2381
|
-
const [stateColumns, setStateColumns] = (0,
|
|
2382
|
-
const [columns, setColumnSize] = (0,
|
|
2505
|
+
const [stateColumns, setStateColumns] = (0, import_react24.useState)();
|
|
2506
|
+
const [columns, setColumnSize] = (0, import_react24.useMemo)(() => {
|
|
2383
2507
|
const setSize = (columnName, width) => {
|
|
2384
|
-
const cols = (0,
|
|
2508
|
+
const cols = (0, import_vuu_utils17.updateColumn)(runtimeColumns, columnName, { width });
|
|
2385
2509
|
setStateColumns(cols);
|
|
2386
2510
|
};
|
|
2387
2511
|
return [stateColumns != null ? stateColumns : runtimeColumns, setSize];
|
|
2388
2512
|
}, [runtimeColumns, stateColumns]);
|
|
2389
|
-
const columnMap = (0,
|
|
2390
|
-
() => (0,
|
|
2513
|
+
const columnMap = (0, import_react24.useMemo)(
|
|
2514
|
+
() => (0, import_vuu_utils17.buildColumnMap)(dataSource.columns),
|
|
2391
2515
|
[dataSource.columns]
|
|
2392
2516
|
);
|
|
2393
2517
|
const {
|
|
@@ -2407,7 +2531,7 @@ var useTable = ({
|
|
|
2407
2531
|
from: 0,
|
|
2408
2532
|
to: viewportMeasurements.rowCount
|
|
2409
2533
|
});
|
|
2410
|
-
const onSubscribed = (0,
|
|
2534
|
+
const onSubscribed = (0, import_react24.useCallback)(
|
|
2411
2535
|
({ tableSchema }) => {
|
|
2412
2536
|
if (tableSchema) {
|
|
2413
2537
|
dispatchColumnAction({
|
|
@@ -2422,13 +2546,14 @@ var useTable = ({
|
|
|
2422
2546
|
);
|
|
2423
2547
|
const { data, dataRef, getSelectedRows, range, setRange } = useDataSource({
|
|
2424
2548
|
dataSource,
|
|
2549
|
+
// We need to factor this out of Table
|
|
2425
2550
|
onFeatureInvocation,
|
|
2426
2551
|
renderBufferSize,
|
|
2427
2552
|
onSizeChange: onDataRowcountChange,
|
|
2428
2553
|
onSubscribed,
|
|
2429
2554
|
range: initialRange
|
|
2430
2555
|
});
|
|
2431
|
-
const handleConfigEditedInSettingsPanel = (0,
|
|
2556
|
+
const handleConfigEditedInSettingsPanel = (0, import_react24.useCallback)(
|
|
2432
2557
|
(tableConfig2) => {
|
|
2433
2558
|
console.log(`settings changed`);
|
|
2434
2559
|
dispatchColumnAction({
|
|
@@ -2440,7 +2565,7 @@ var useTable = ({
|
|
|
2440
2565
|
},
|
|
2441
2566
|
[dataSource, dispatchColumnAction, onConfigChange]
|
|
2442
2567
|
);
|
|
2443
|
-
const handleDataSourceConfigChanged = (0,
|
|
2568
|
+
const handleDataSourceConfigChanged = (0, import_react24.useCallback)(
|
|
2444
2569
|
(dataSourceConfig) => {
|
|
2445
2570
|
dataSource.config = {
|
|
2446
2571
|
...dataSource.config,
|
|
@@ -2449,7 +2574,7 @@ var useTable = ({
|
|
|
2449
2574
|
},
|
|
2450
2575
|
[dataSource]
|
|
2451
2576
|
);
|
|
2452
|
-
(0,
|
|
2577
|
+
(0, import_react24.useEffect)(() => {
|
|
2453
2578
|
dataSource.on("config", (config2, confirmed) => {
|
|
2454
2579
|
dispatchColumnAction({
|
|
2455
2580
|
type: "tableConfig",
|
|
@@ -2458,14 +2583,14 @@ var useTable = ({
|
|
|
2458
2583
|
});
|
|
2459
2584
|
});
|
|
2460
2585
|
}, [dataSource, dispatchColumnAction]);
|
|
2461
|
-
const handleCreateCalculatedColumn = (0,
|
|
2586
|
+
const handleCreateCalculatedColumn = (0, import_react24.useCallback)(
|
|
2462
2587
|
(column) => {
|
|
2463
2588
|
dataSource.columns = dataSource.columns.concat(column.name);
|
|
2464
2589
|
applyTableConfigChange(addColumn(tableConfig, column));
|
|
2465
2590
|
},
|
|
2466
2591
|
[dataSource, tableConfig, applyTableConfigChange]
|
|
2467
2592
|
);
|
|
2468
|
-
const hideColumns2 = (0,
|
|
2593
|
+
const hideColumns2 = (0, import_react24.useCallback)(
|
|
2469
2594
|
(action) => {
|
|
2470
2595
|
const { columns: columns2 } = action;
|
|
2471
2596
|
const hiddenColumns = columns2.map((c) => c.name);
|
|
@@ -2479,11 +2604,11 @@ var useTable = ({
|
|
|
2479
2604
|
},
|
|
2480
2605
|
[tableConfig, applyTableConfigChange]
|
|
2481
2606
|
);
|
|
2482
|
-
const pinColumn3 = (0,
|
|
2607
|
+
const pinColumn3 = (0, import_react24.useCallback)(
|
|
2483
2608
|
(action) => {
|
|
2484
2609
|
applyTableConfigChange({
|
|
2485
2610
|
...tableConfig,
|
|
2486
|
-
columns: (0,
|
|
2611
|
+
columns: (0, import_vuu_utils17.updateColumn)(tableConfig.columns, {
|
|
2487
2612
|
...action.column,
|
|
2488
2613
|
pin: action.pin
|
|
2489
2614
|
})
|
|
@@ -2491,7 +2616,7 @@ var useTable = ({
|
|
|
2491
2616
|
},
|
|
2492
2617
|
[tableConfig, applyTableConfigChange]
|
|
2493
2618
|
);
|
|
2494
|
-
const { showColumnSettingsPanel, showTableSettingsPanel } =
|
|
2619
|
+
const { showColumnSettingsPanel, showTableSettingsPanel } = useTableAndColumnSettings({
|
|
2495
2620
|
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType = "string" }) => ({
|
|
2496
2621
|
name,
|
|
2497
2622
|
serverDataType
|
|
@@ -2502,7 +2627,7 @@ var useTable = ({
|
|
|
2502
2627
|
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
2503
2628
|
tableConfig
|
|
2504
2629
|
});
|
|
2505
|
-
const onPersistentColumnOperation = (0,
|
|
2630
|
+
const onPersistentColumnOperation = (0, import_react24.useCallback)(
|
|
2506
2631
|
(action) => {
|
|
2507
2632
|
if (isShowColumnSettings(action)) {
|
|
2508
2633
|
showColumnSettingsPanel(action);
|
|
@@ -2531,10 +2656,10 @@ var useTable = ({
|
|
|
2531
2656
|
dataSource,
|
|
2532
2657
|
onPersistentColumnOperation
|
|
2533
2658
|
});
|
|
2534
|
-
const handleSort = (0,
|
|
2659
|
+
const handleSort = (0, import_react24.useCallback)(
|
|
2535
2660
|
(column, extendSort = false, sortType) => {
|
|
2536
2661
|
if (dataSource) {
|
|
2537
|
-
dataSource.sort = (0,
|
|
2662
|
+
dataSource.sort = (0, import_vuu_utils17.applySort)(
|
|
2538
2663
|
dataSource.sort,
|
|
2539
2664
|
column,
|
|
2540
2665
|
extendSort,
|
|
@@ -2544,16 +2669,16 @@ var useTable = ({
|
|
|
2544
2669
|
},
|
|
2545
2670
|
[dataSource]
|
|
2546
2671
|
);
|
|
2547
|
-
const onResizeColumn = (0,
|
|
2672
|
+
const onResizeColumn = (0, import_react24.useCallback)(
|
|
2548
2673
|
(phase, columnName, width) => {
|
|
2549
2674
|
const column = columns.find((column2) => column2.name === columnName);
|
|
2550
2675
|
if (column) {
|
|
2551
2676
|
if (phase === "resize") {
|
|
2552
|
-
if ((0,
|
|
2677
|
+
if ((0, import_vuu_utils17.isValidNumber)(width)) {
|
|
2553
2678
|
setColumnSize(columnName, width);
|
|
2554
2679
|
}
|
|
2555
2680
|
} else if (phase === "end") {
|
|
2556
|
-
if ((0,
|
|
2681
|
+
if ((0, import_vuu_utils17.isValidNumber)(width)) {
|
|
2557
2682
|
dispatchColumnAction({
|
|
2558
2683
|
type: "resizeColumn",
|
|
2559
2684
|
phase,
|
|
@@ -2588,16 +2713,17 @@ var useTable = ({
|
|
|
2588
2713
|
},
|
|
2589
2714
|
[columns, tableConfig, dispatchColumnAction, onConfigChange, setColumnSize]
|
|
2590
2715
|
);
|
|
2591
|
-
const onToggleGroup = (0,
|
|
2716
|
+
const onToggleGroup = (0, import_react24.useCallback)(
|
|
2592
2717
|
(row, column) => {
|
|
2593
|
-
|
|
2718
|
+
var _a, _b;
|
|
2719
|
+
const isJson = (0, import_vuu_utils17.isJsonGroup)(column, row);
|
|
2594
2720
|
const key = row[KEY];
|
|
2595
2721
|
if (row[IS_EXPANDED2]) {
|
|
2596
2722
|
dataSource.closeTreeNode(key, true);
|
|
2597
2723
|
if (isJson) {
|
|
2598
2724
|
const idx = columns.indexOf(column);
|
|
2599
|
-
const rows = dataSource.getRowsAtDepth(idx + 1);
|
|
2600
|
-
if (!rows.some((row2) => row2[IS_EXPANDED2] || row2[IS_LEAF2])) {
|
|
2725
|
+
const rows = (_a = dataSource.getRowsAtDepth) == null ? void 0 : _a.call(dataSource, idx + 1);
|
|
2726
|
+
if (rows && !rows.some((row2) => row2[IS_EXPANDED2] || row2[IS_LEAF2])) {
|
|
2601
2727
|
dispatchColumnAction({
|
|
2602
2728
|
type: "hideColumns",
|
|
2603
2729
|
columns: columns.slice(idx + 2)
|
|
@@ -2607,10 +2733,10 @@ var useTable = ({
|
|
|
2607
2733
|
} else {
|
|
2608
2734
|
dataSource.openTreeNode(key);
|
|
2609
2735
|
if (isJson) {
|
|
2610
|
-
const childRows = dataSource.getChildRows(key);
|
|
2736
|
+
const childRows = (_b = dataSource.getChildRows) == null ? void 0 : _b.call(dataSource, key);
|
|
2611
2737
|
const idx = columns.indexOf(column) + 1;
|
|
2612
2738
|
const columnsToShow = [columns[idx]];
|
|
2613
|
-
if (childRows.some((row2) => row2[IS_LEAF2])) {
|
|
2739
|
+
if (childRows && childRows.some((row2) => row2[IS_LEAF2])) {
|
|
2614
2740
|
columnsToShow.push(columns[idx + 1]);
|
|
2615
2741
|
}
|
|
2616
2742
|
if (columnsToShow.some((col) => col.hidden)) {
|
|
@@ -2630,7 +2756,7 @@ var useTable = ({
|
|
|
2630
2756
|
setRange,
|
|
2631
2757
|
viewportMeasurements
|
|
2632
2758
|
});
|
|
2633
|
-
const handleVerticalScroll = (0,
|
|
2759
|
+
const handleVerticalScroll = (0, import_react24.useCallback)(
|
|
2634
2760
|
(scrollTop) => {
|
|
2635
2761
|
onVerticalScroll(scrollTop);
|
|
2636
2762
|
},
|
|
@@ -2669,7 +2795,7 @@ var useTable = ({
|
|
|
2669
2795
|
} = useCellEditing({
|
|
2670
2796
|
navigate
|
|
2671
2797
|
});
|
|
2672
|
-
const handleFocus = (0,
|
|
2798
|
+
const handleFocus = (0, import_react24.useCallback)(
|
|
2673
2799
|
(e) => {
|
|
2674
2800
|
navigationFocus();
|
|
2675
2801
|
if (!e.defaultPrevented) {
|
|
@@ -2684,15 +2810,15 @@ var useTable = ({
|
|
|
2684
2810
|
dataSource,
|
|
2685
2811
|
getSelectedRows
|
|
2686
2812
|
});
|
|
2687
|
-
const onMoveGroupColumn = (0,
|
|
2813
|
+
const onMoveGroupColumn = (0, import_react24.useCallback)(
|
|
2688
2814
|
(columns2) => {
|
|
2689
2815
|
dataSource.groupBy = columns2.map((col) => col.name);
|
|
2690
2816
|
},
|
|
2691
2817
|
[dataSource]
|
|
2692
2818
|
);
|
|
2693
|
-
const onRemoveGroupColumn = (0,
|
|
2819
|
+
const onRemoveGroupColumn = (0, import_react24.useCallback)(
|
|
2694
2820
|
(column) => {
|
|
2695
|
-
if ((0,
|
|
2821
|
+
if ((0, import_vuu_utils17.isGroupColumn)(column)) {
|
|
2696
2822
|
dataSource.groupBy = [];
|
|
2697
2823
|
} else {
|
|
2698
2824
|
if (dataSource && dataSource.groupBy.includes(column.name)) {
|
|
@@ -2704,7 +2830,7 @@ var useTable = ({
|
|
|
2704
2830
|
},
|
|
2705
2831
|
[dataSource]
|
|
2706
2832
|
);
|
|
2707
|
-
const handleSelectionChange = (0,
|
|
2833
|
+
const handleSelectionChange = (0, import_react24.useCallback)(
|
|
2708
2834
|
(selected) => {
|
|
2709
2835
|
dataSource.select(selected);
|
|
2710
2836
|
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
@@ -2720,7 +2846,7 @@ var useTable = ({
|
|
|
2720
2846
|
onSelectionChange: handleSelectionChange,
|
|
2721
2847
|
selectionModel
|
|
2722
2848
|
});
|
|
2723
|
-
const handleKeyDown = (0,
|
|
2849
|
+
const handleKeyDown = (0, import_react24.useCallback)(
|
|
2724
2850
|
(e) => {
|
|
2725
2851
|
navigationKeyDown(e);
|
|
2726
2852
|
if (!e.defaultPrevented) {
|
|
@@ -2732,22 +2858,25 @@ var useTable = ({
|
|
|
2732
2858
|
},
|
|
2733
2859
|
[navigationKeyDown, editingKeyDown, selectionHookKeyDown]
|
|
2734
2860
|
);
|
|
2735
|
-
const handleRowClick = (0,
|
|
2861
|
+
const handleRowClick = (0, import_react24.useCallback)(
|
|
2736
2862
|
(row, rangeSelect, keepExistingSelection) => {
|
|
2737
2863
|
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
2738
2864
|
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
2739
2865
|
},
|
|
2740
2866
|
[onRowClickProp, selectionHookOnRowClick]
|
|
2741
2867
|
);
|
|
2742
|
-
(0,
|
|
2868
|
+
(0, import_vuu_utils17.useLayoutEffectSkipFirst)(() => {
|
|
2743
2869
|
dispatchColumnAction({
|
|
2744
2870
|
type: "init",
|
|
2745
2871
|
tableConfig: config,
|
|
2746
2872
|
dataSource
|
|
2747
2873
|
});
|
|
2748
2874
|
}, [config, dataSource, dispatchColumnAction]);
|
|
2749
|
-
const onMoveColumn = (0,
|
|
2875
|
+
const onMoveColumn = (0, import_react24.useCallback)(
|
|
2750
2876
|
(columns2) => {
|
|
2877
|
+
console.log(`useTable onMoveColumn`, {
|
|
2878
|
+
columns: columns2
|
|
2879
|
+
});
|
|
2751
2880
|
const newTableConfig = {
|
|
2752
2881
|
...tableConfig,
|
|
2753
2882
|
columns: columns2
|
|
@@ -2761,17 +2890,17 @@ var useTable = ({
|
|
|
2761
2890
|
},
|
|
2762
2891
|
[dataSource, dispatchColumnAction, onConfigChange, tableConfig]
|
|
2763
2892
|
);
|
|
2764
|
-
const handleDropRow = (0,
|
|
2893
|
+
const handleDropRow = (0, import_react24.useCallback)(
|
|
2765
2894
|
(dragDropState) => {
|
|
2766
2895
|
onDrop == null ? void 0 : onDrop(dragDropState);
|
|
2767
2896
|
},
|
|
2768
2897
|
[onDrop]
|
|
2769
2898
|
);
|
|
2770
|
-
const handleDataEdited = (0,
|
|
2899
|
+
const handleDataEdited = (0, import_react24.useCallback)(
|
|
2771
2900
|
async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
|
|
2772
2901
|
[dataSource]
|
|
2773
2902
|
);
|
|
2774
|
-
const handleDragStartRow = (0,
|
|
2903
|
+
const handleDragStartRow = (0, import_react24.useCallback)(
|
|
2775
2904
|
(dragDropState) => {
|
|
2776
2905
|
const { initialDragElement } = dragDropState;
|
|
2777
2906
|
const rowIndex = initialDragElement.ariaRowIndex;
|
|
@@ -2830,33 +2959,37 @@ var useTable = ({
|
|
|
2830
2959
|
};
|
|
2831
2960
|
|
|
2832
2961
|
// src/table-header/TableHeader.tsx
|
|
2833
|
-
var
|
|
2834
|
-
var
|
|
2962
|
+
var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
|
|
2963
|
+
var import_clsx8 = __toESM(require("clsx"));
|
|
2835
2964
|
|
|
2836
2965
|
// src/table-header/useTableHeader.ts
|
|
2837
2966
|
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
2838
|
-
var
|
|
2839
|
-
var
|
|
2967
|
+
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
2968
|
+
var import_react25 = require("react");
|
|
2840
2969
|
var useTableHeader = ({
|
|
2841
2970
|
columns,
|
|
2842
2971
|
onMoveColumn,
|
|
2843
2972
|
onSortColumn,
|
|
2844
2973
|
tableConfig
|
|
2845
2974
|
}) => {
|
|
2846
|
-
const containerRef = (0,
|
|
2847
|
-
const handleDropColumnHeader = (0,
|
|
2975
|
+
const containerRef = (0, import_react25.useRef)(null);
|
|
2976
|
+
const handleDropColumnHeader = (0, import_react25.useCallback)(
|
|
2848
2977
|
(moveFrom, moveTo) => {
|
|
2849
2978
|
const column = columns[moveFrom];
|
|
2850
|
-
const orderedColumns = (0,
|
|
2979
|
+
const orderedColumns = (0, import_vuu_utils18.moveColumnTo)(columns, column, moveTo);
|
|
2851
2980
|
const ofColumn = ({ name }) => (col) => col.name === name;
|
|
2852
2981
|
const targetIndex = orderedColumns.findIndex(ofColumn(column));
|
|
2853
2982
|
const nextColumn = orderedColumns[targetIndex + 1];
|
|
2854
2983
|
const insertPos = nextColumn ? tableConfig.columns.findIndex(ofColumn(nextColumn)) : -1;
|
|
2855
|
-
|
|
2984
|
+
if (moveTo > moveFrom && insertPos !== -1) {
|
|
2985
|
+
onMoveColumn((0, import_vuu_utils18.moveColumnTo)(tableConfig.columns, column, insertPos - 1));
|
|
2986
|
+
} else {
|
|
2987
|
+
onMoveColumn((0, import_vuu_utils18.moveColumnTo)(tableConfig.columns, column, insertPos));
|
|
2988
|
+
}
|
|
2856
2989
|
},
|
|
2857
2990
|
[columns, onMoveColumn, tableConfig.columns]
|
|
2858
2991
|
);
|
|
2859
|
-
const handleColumnHeaderClick = (0,
|
|
2992
|
+
const handleColumnHeaderClick = (0, import_react25.useCallback)(
|
|
2860
2993
|
(evt) => {
|
|
2861
2994
|
var _a;
|
|
2862
2995
|
const targetElement = evt.target;
|
|
@@ -2864,7 +2997,7 @@ var useTableHeader = ({
|
|
|
2864
2997
|
".vuuTableHeaderCell"
|
|
2865
2998
|
);
|
|
2866
2999
|
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
2867
|
-
const column = (0,
|
|
3000
|
+
const column = (0, import_vuu_utils18.visibleColumnAtIndex)(columns, colIdx);
|
|
2868
3001
|
const isAdditive = evt.shiftKey;
|
|
2869
3002
|
column && onSortColumn(column, isAdditive);
|
|
2870
3003
|
},
|
|
@@ -2894,7 +3027,7 @@ var useTableHeader = ({
|
|
|
2894
3027
|
// src/table-header/TableHeader.tsx
|
|
2895
3028
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
2896
3029
|
var TableHeader = ({
|
|
2897
|
-
classBase:
|
|
3030
|
+
classBase: classBase10 = "vuuTable",
|
|
2898
3031
|
columns,
|
|
2899
3032
|
headings,
|
|
2900
3033
|
onMoveColumn,
|
|
@@ -2917,11 +3050,11 @@ var TableHeader = ({
|
|
|
2917
3050
|
onSortColumn,
|
|
2918
3051
|
tableConfig
|
|
2919
3052
|
});
|
|
2920
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${
|
|
3053
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headings`, ref: containerRef, children: [
|
|
2921
3054
|
headings.map((colHeaders, i) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
|
|
2922
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${
|
|
2923
|
-
columns.filter(
|
|
2924
|
-
(col, i) => (0,
|
|
3055
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase10}-col-headers`, role: "row", children: [
|
|
3056
|
+
columns.filter(import_vuu_utils19.isNotHidden).map(
|
|
3057
|
+
(col, i) => (0, import_vuu_utils19.isGroupColumn)(col) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2925
3058
|
GroupHeaderCellNext,
|
|
2926
3059
|
{
|
|
2927
3060
|
column: col,
|
|
@@ -2934,7 +3067,7 @@ var TableHeader = ({
|
|
|
2934
3067
|
) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
2935
3068
|
HeaderCell,
|
|
2936
3069
|
{
|
|
2937
|
-
className: (0,
|
|
3070
|
+
className: (0, import_clsx8.default)({
|
|
2938
3071
|
"vuuDraggable-dragAway": i === draggedColumnIndex
|
|
2939
3072
|
}),
|
|
2940
3073
|
column: col,
|
|
@@ -2955,7 +3088,7 @@ var TableHeader = ({
|
|
|
2955
3088
|
// src/Table.tsx
|
|
2956
3089
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2957
3090
|
var classBase7 = "vuuTable";
|
|
2958
|
-
var { IDX: IDX3, RENDER_IDX } =
|
|
3091
|
+
var { IDX: IDX3, RENDER_IDX } = import_vuu_utils20.metadataKeys;
|
|
2959
3092
|
var TableCore = ({
|
|
2960
3093
|
Row: Row2 = Row,
|
|
2961
3094
|
allowDragDrop,
|
|
@@ -2983,7 +3116,7 @@ var TableCore = ({
|
|
|
2983
3116
|
headerHeight = showColumnHeaders ? 25 : 0,
|
|
2984
3117
|
size
|
|
2985
3118
|
}) => {
|
|
2986
|
-
const id = (0,
|
|
3119
|
+
const id = (0, import_vuu_utils20.useId)(idProp);
|
|
2987
3120
|
const {
|
|
2988
3121
|
columnMap,
|
|
2989
3122
|
columns,
|
|
@@ -3031,7 +3164,7 @@ var TableCore = ({
|
|
|
3031
3164
|
selectionModel,
|
|
3032
3165
|
size
|
|
3033
3166
|
});
|
|
3034
|
-
const className = (0,
|
|
3167
|
+
const className = (0, import_clsx9.default)(`${classBase7}-contentContainer`, {
|
|
3035
3168
|
[`${classBase7}-colLines`]: tableAttributes.columnSeparators,
|
|
3036
3169
|
[`${classBase7}-rowLines`]: tableAttributes.rowSeparators,
|
|
3037
3170
|
// [`${classBase}-highlight`]: tableAttributes.showHighlightedRow,
|
|
@@ -3076,6 +3209,7 @@ var TableCore = ({
|
|
|
3076
3209
|
{
|
|
3077
3210
|
...tableProps,
|
|
3078
3211
|
className: `${classBase7}-table`,
|
|
3212
|
+
role: "table",
|
|
3079
3213
|
tabIndex: disableFocus ? void 0 : -1,
|
|
3080
3214
|
children: [
|
|
3081
3215
|
showColumnHeaders ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -3117,7 +3251,7 @@ var TableCore = ({
|
|
|
3117
3251
|
}
|
|
3118
3252
|
);
|
|
3119
3253
|
};
|
|
3120
|
-
var Table = (0,
|
|
3254
|
+
var Table = (0, import_react26.forwardRef)(function TableNext({
|
|
3121
3255
|
Row: Row2,
|
|
3122
3256
|
allowDragDrop,
|
|
3123
3257
|
availableColumns,
|
|
@@ -3145,13 +3279,21 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
|
|
|
3145
3279
|
style: styleProp,
|
|
3146
3280
|
...htmlAttributes
|
|
3147
3281
|
}, forwardedRef) {
|
|
3148
|
-
const containerRef = (0,
|
|
3149
|
-
const [size, setSize] = (0,
|
|
3282
|
+
const containerRef = (0, import_react26.useRef)(null);
|
|
3283
|
+
const [size, setSize] = (0, import_react26.useState)();
|
|
3284
|
+
if (config === void 0) {
|
|
3285
|
+
throw Error(
|
|
3286
|
+
"vuu Table requires config prop. Minimum config is list of Column Descriptors"
|
|
3287
|
+
);
|
|
3288
|
+
}
|
|
3289
|
+
if (dataSource === void 0) {
|
|
3290
|
+
throw Error("vuu Table requires dataSource prop");
|
|
3291
|
+
}
|
|
3150
3292
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3151
3293
|
import_vuu_layout3.MeasuredContainer,
|
|
3152
3294
|
{
|
|
3153
3295
|
...htmlAttributes,
|
|
3154
|
-
className: (0,
|
|
3296
|
+
className: (0, import_clsx9.default)(classBase7, classNameProp),
|
|
3155
3297
|
id,
|
|
3156
3298
|
onResize: setSize,
|
|
3157
3299
|
ref: (0, import_core2.useForkRef)(containerRef, forwardedRef),
|
|
@@ -3190,94 +3332,47 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
|
|
|
3190
3332
|
});
|
|
3191
3333
|
|
|
3192
3334
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3193
|
-
var
|
|
3335
|
+
var import_react27 = require("react");
|
|
3194
3336
|
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
3195
3337
|
var import_core3 = require("@salt-ds/core");
|
|
3196
3338
|
|
|
3197
3339
|
// src/cell-renderers/cell-utils.ts
|
|
3198
|
-
var dataAndColumnUnchanged = (p, p1) => p.column === p1.column && p.row[p.columnMap[p.column.name]] === p1.row[p1.columnMap[p1.column.name]];
|
|
3340
|
+
var dataAndColumnUnchanged = (p, p1) => p.column === p1.column && p.column.valueFormatter(p.row[p.columnMap[p.column.name]]) === p1.column.valueFormatter(p1.row[p1.columnMap[p1.column.name]]);
|
|
3199
3341
|
|
|
3200
3342
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3201
|
-
var
|
|
3343
|
+
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
3202
3344
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3203
|
-
var CheckboxCell = (0,
|
|
3345
|
+
var CheckboxCell = (0, import_react27.memo)(
|
|
3204
3346
|
({ column, columnMap, onCommit = import_vuu_ui_controls4.WarnCommit, row }) => {
|
|
3205
3347
|
const dataIdx = columnMap[column.name];
|
|
3206
3348
|
const isChecked = row[dataIdx];
|
|
3207
|
-
const handleCommit = (0,
|
|
3349
|
+
const handleCommit = (0, import_react27.useCallback)(
|
|
3208
3350
|
(value) => async (evt) => {
|
|
3209
3351
|
const res = await onCommit(value);
|
|
3210
3352
|
if (res === true) {
|
|
3211
|
-
(0,
|
|
3353
|
+
(0, import_vuu_utils21.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
3212
3354
|
}
|
|
3213
3355
|
return res;
|
|
3214
3356
|
},
|
|
3215
3357
|
[onCommit]
|
|
3216
3358
|
);
|
|
3217
|
-
return
|
|
3359
|
+
return column.editable ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_core3.Checkbox, { checked: isChecked, onClick: handleCommit(!isChecked) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_vuu_ui_controls4.CheckboxIcon, { checked: isChecked, disabled: true });
|
|
3218
3360
|
},
|
|
3219
3361
|
dataAndColumnUnchanged
|
|
3220
3362
|
);
|
|
3221
3363
|
CheckboxCell.displayName = "CheckboxCell";
|
|
3222
|
-
(0,
|
|
3364
|
+
(0, import_vuu_utils21.registerComponent)("checkbox-cell", CheckboxCell, "cell-renderer", {
|
|
3223
3365
|
serverDataType: "boolean"
|
|
3224
3366
|
});
|
|
3225
3367
|
|
|
3226
|
-
// src/cell-renderers/dropdown-cell/DropdownCell.tsx
|
|
3227
|
-
var import_vuu_data_react = require("@vuu-ui/vuu-data-react");
|
|
3228
|
-
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
3229
|
-
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
3230
|
-
var import_react27 = require("react");
|
|
3231
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3232
|
-
var classBase8 = "vuuTableDropdownCell";
|
|
3233
|
-
var openKeys = ["Enter", " "];
|
|
3234
|
-
var DropdownCell = (0, import_react27.memo)(
|
|
3235
|
-
function DropdownCell2({
|
|
3236
|
-
column,
|
|
3237
|
-
columnMap,
|
|
3238
|
-
onCommit = import_vuu_ui_controls5.WarnCommit,
|
|
3239
|
-
row
|
|
3240
|
-
}) {
|
|
3241
|
-
const dataIdx = columnMap[column.name];
|
|
3242
|
-
const { initialValue, values } = (0, import_vuu_data_react.useLookupValues)(column, row[dataIdx]);
|
|
3243
|
-
const [value, setValue] = (0, import_react27.useState)(null);
|
|
3244
|
-
const handleSelectionChange = (0, import_react27.useCallback)(
|
|
3245
|
-
(evt, selectedOption) => {
|
|
3246
|
-
if (selectedOption) {
|
|
3247
|
-
setValue(selectedOption);
|
|
3248
|
-
onCommit(selectedOption.value).then((response) => {
|
|
3249
|
-
if (response === true && evt) {
|
|
3250
|
-
(0, import_vuu_utils20.dispatchCustomEvent)(evt.target, "vuu-commit");
|
|
3251
|
-
}
|
|
3252
|
-
});
|
|
3253
|
-
}
|
|
3254
|
-
},
|
|
3255
|
-
[onCommit]
|
|
3256
|
-
);
|
|
3257
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3258
|
-
import_vuu_ui_controls5.Dropdown,
|
|
3259
|
-
{
|
|
3260
|
-
className: classBase8,
|
|
3261
|
-
onSelectionChange: handleSelectionChange,
|
|
3262
|
-
openKeys,
|
|
3263
|
-
selected: value != null ? value : initialValue,
|
|
3264
|
-
source: values,
|
|
3265
|
-
width: column.width - 17
|
|
3266
|
-
}
|
|
3267
|
-
);
|
|
3268
|
-
},
|
|
3269
|
-
dataAndColumnUnchanged
|
|
3270
|
-
);
|
|
3271
|
-
(0, import_vuu_utils20.registerComponent)("dropdown-cell", DropdownCell, "cell-renderer", {});
|
|
3272
|
-
|
|
3273
3368
|
// src/cell-renderers/input-cell/InputCell.tsx
|
|
3274
|
-
var
|
|
3369
|
+
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
3275
3370
|
var import_core4 = require("@salt-ds/core");
|
|
3276
|
-
var
|
|
3277
|
-
var
|
|
3278
|
-
var
|
|
3279
|
-
var
|
|
3280
|
-
var
|
|
3371
|
+
var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
3372
|
+
var import_clsx10 = __toESM(require("clsx"));
|
|
3373
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3374
|
+
var classBase8 = "vuuTableInputCell";
|
|
3375
|
+
var WarnCommit2 = () => {
|
|
3281
3376
|
console.warn(
|
|
3282
3377
|
"onCommit handler has not been provided to InputCell cell renderer"
|
|
3283
3378
|
);
|
|
@@ -3286,63 +3381,40 @@ var WarnCommit3 = () => {
|
|
|
3286
3381
|
var InputCell = ({
|
|
3287
3382
|
column,
|
|
3288
3383
|
columnMap,
|
|
3289
|
-
onCommit =
|
|
3384
|
+
onCommit = WarnCommit2,
|
|
3290
3385
|
row
|
|
3291
3386
|
}) => {
|
|
3292
3387
|
const dataIdx = columnMap[column.name];
|
|
3293
|
-
const {
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
valueFormatter
|
|
3297
|
-
} = column;
|
|
3298
|
-
const { warningMessage, ...editProps } = (0, import_vuu_ui_controls6.useEditableText)({
|
|
3299
|
-
initialValue: valueFormatter(row[dataIdx]),
|
|
3388
|
+
const { align = "left", clientSideEditValidationCheck } = column;
|
|
3389
|
+
const { warningMessage, ...editProps } = (0, import_vuu_ui_controls5.useEditableText)({
|
|
3390
|
+
initialValue: row[dataIdx],
|
|
3300
3391
|
onCommit,
|
|
3301
3392
|
clientSideEditValidationCheck
|
|
3302
3393
|
});
|
|
3303
|
-
const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ (0,
|
|
3304
|
-
const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ (0,
|
|
3305
|
-
return /* @__PURE__ */ (0,
|
|
3394
|
+
const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `${classBase8}-icon`, "data-icon": "error" }) : void 0;
|
|
3395
|
+
const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `${classBase8}-icon`, "data-icon": "error" }) : void 0;
|
|
3396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3306
3397
|
import_core4.Input,
|
|
3307
3398
|
{
|
|
3308
3399
|
...editProps,
|
|
3309
|
-
className: (0,
|
|
3310
|
-
[`${
|
|
3400
|
+
className: (0, import_clsx10.default)(classBase8, {
|
|
3401
|
+
[`${classBase8}-error`]: warningMessage !== void 0
|
|
3311
3402
|
}),
|
|
3312
3403
|
endAdornment,
|
|
3313
3404
|
startAdornment
|
|
3314
3405
|
}
|
|
3315
3406
|
);
|
|
3316
3407
|
};
|
|
3317
|
-
(0,
|
|
3318
|
-
|
|
3319
|
-
// src/cell-renderers/lookup-cell/LookupCell.tsx
|
|
3320
|
-
var import_vuu_data_react2 = require("@vuu-ui/vuu-data-react");
|
|
3321
|
-
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
3322
|
-
var import_react28 = require("react");
|
|
3323
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3324
|
-
var LookupCell = (0, import_react28.memo)(
|
|
3325
|
-
function LookupCell2({
|
|
3326
|
-
column,
|
|
3327
|
-
columnMap,
|
|
3328
|
-
row
|
|
3329
|
-
}) {
|
|
3330
|
-
const dataIdx = columnMap[column.name];
|
|
3331
|
-
const { initialValue: value } = (0, import_vuu_data_react2.useLookupValues)(column, row[dataIdx]);
|
|
3332
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: value == null ? void 0 : value.label });
|
|
3333
|
-
},
|
|
3334
|
-
dataAndColumnUnchanged
|
|
3335
|
-
);
|
|
3336
|
-
(0, import_vuu_utils22.registerComponent)("lookup-cell", LookupCell, "cell-renderer", {});
|
|
3408
|
+
(0, import_vuu_utils22.registerComponent)("input-cell", InputCell, "cell-renderer", {});
|
|
3337
3409
|
|
|
3338
3410
|
// src/cell-renderers/toggle-cell/ToggleCell.tsx
|
|
3339
|
-
var
|
|
3411
|
+
var import_vuu_ui_controls6 = require("@vuu-ui/vuu-ui-controls");
|
|
3340
3412
|
var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
|
|
3341
|
-
var
|
|
3342
|
-
var
|
|
3343
|
-
var
|
|
3344
|
-
var
|
|
3345
|
-
var
|
|
3413
|
+
var import_clsx11 = __toESM(require("clsx"));
|
|
3414
|
+
var import_react28 = require("react");
|
|
3415
|
+
var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
|
|
3416
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3417
|
+
var classBase9 = "vuuTableToggleCell";
|
|
3346
3418
|
var getValueList = ({ name, type }) => {
|
|
3347
3419
|
if ((0, import_vuu_utils23.isTypeDescriptor)(type) && (0, import_vuu_utils23.isValueListRenderer)(type.renderer)) {
|
|
3348
3420
|
return type.renderer.values;
|
|
@@ -3352,17 +3424,17 @@ var getValueList = ({ name, type }) => {
|
|
|
3352
3424
|
);
|
|
3353
3425
|
}
|
|
3354
3426
|
};
|
|
3355
|
-
var ToggleCell = (0,
|
|
3427
|
+
var ToggleCell = (0, import_react28.memo)(
|
|
3356
3428
|
function ToggleCell2({
|
|
3357
3429
|
column,
|
|
3358
3430
|
columnMap,
|
|
3359
|
-
onCommit =
|
|
3431
|
+
onCommit = import_vuu_ui_controls6.WarnCommit,
|
|
3360
3432
|
row
|
|
3361
3433
|
}) {
|
|
3362
3434
|
const values = getValueList(column);
|
|
3363
3435
|
const dataIdx = columnMap[column.name];
|
|
3364
3436
|
const value = row[dataIdx];
|
|
3365
|
-
const handleCommit = (0,
|
|
3437
|
+
const handleCommit = (0, import_react28.useCallback)(
|
|
3366
3438
|
(evt, value2) => {
|
|
3367
3439
|
return onCommit(value2).then((response) => {
|
|
3368
3440
|
if (response === true) {
|
|
@@ -3373,10 +3445,10 @@ var ToggleCell = (0, import_react29.memo)(
|
|
|
3373
3445
|
},
|
|
3374
3446
|
[onCommit]
|
|
3375
3447
|
);
|
|
3376
|
-
return /* @__PURE__ */ (0,
|
|
3377
|
-
|
|
3448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3449
|
+
import_vuu_ui_controls7.CycleStateButton,
|
|
3378
3450
|
{
|
|
3379
|
-
className: (0,
|
|
3451
|
+
className: (0, import_clsx11.default)(classBase9, `${classBase9}-${column.name}`),
|
|
3380
3452
|
onCommit: handleCommit,
|
|
3381
3453
|
value,
|
|
3382
3454
|
values,
|
|
@@ -3390,13 +3462,13 @@ var ToggleCell = (0, import_react29.memo)(
|
|
|
3390
3462
|
(0, import_vuu_utils23.registerComponent)("toggle-cell", ToggleCell, "cell-renderer", {});
|
|
3391
3463
|
|
|
3392
3464
|
// src/useControlledTableNavigation.ts
|
|
3393
|
-
var
|
|
3465
|
+
var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
|
|
3394
3466
|
var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
|
|
3395
|
-
var
|
|
3467
|
+
var import_react29 = require("react");
|
|
3396
3468
|
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3397
|
-
const tableRef = (0,
|
|
3398
|
-
const [highlightedIndexRef, setHighlightedIndex] = (0,
|
|
3399
|
-
const handleKeyDown = (0,
|
|
3469
|
+
const tableRef = (0, import_react29.useRef)(null);
|
|
3470
|
+
const [highlightedIndexRef, setHighlightedIndex] = (0, import_vuu_ui_controls8.useStateRef)(initialValue);
|
|
3471
|
+
const handleKeyDown = (0, import_react29.useCallback)(
|
|
3400
3472
|
(e) => {
|
|
3401
3473
|
var _a;
|
|
3402
3474
|
if (e.key === "ArrowDown") {
|
|
@@ -3415,7 +3487,7 @@ var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
|
3415
3487
|
},
|
|
3416
3488
|
[highlightedIndexRef, rowCount, setHighlightedIndex]
|
|
3417
3489
|
);
|
|
3418
|
-
const handleHighlight = (0,
|
|
3490
|
+
const handleHighlight = (0, import_react29.useCallback)(
|
|
3419
3491
|
(idx) => {
|
|
3420
3492
|
setHighlightedIndex(idx);
|
|
3421
3493
|
},
|