@vuu-ui/vuu-table 0.8.24-debug → 0.8.25-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 +255 -276
- package/cjs/index.js.map +4 -4
- package/esm/index.js +235 -259
- package/esm/index.js.map +4 -4
- package/index.css +44 -78
- package/index.css.map +3 -3
- package/package.json +8 -8
- package/types/Row.d.ts +2 -2
- package/types/Table.d.ts +2 -3
- package/types/cell-renderers/checkbox-cell/CheckboxCell.d.ts +1 -0
- package/types/column-menu/ColumnMenu.d.ts +1 -1
- package/types/header-cell/{GroupHeaderCellNext.d.ts → GroupHeaderCell.d.ts} +2 -2
- package/types/header-cell/index.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/types/useSelection.d.ts +4 -4
- package/types/useTable.d.ts +2 -2
package/cjs/index.js
CHANGED
|
@@ -31,7 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
CheckboxCell: () => CheckboxCell,
|
|
34
|
-
|
|
34
|
+
GroupHeaderCell: () => GroupHeaderCell,
|
|
35
|
+
GroupHeaderCellNext: () => GroupHeaderCell,
|
|
35
36
|
HeaderCell: () => HeaderCell,
|
|
36
37
|
InputCell: () => InputCell,
|
|
37
38
|
Table: () => Table,
|
|
@@ -49,7 +50,7 @@ __export(src_exports, {
|
|
|
49
50
|
});
|
|
50
51
|
module.exports = __toCommonJS(src_exports);
|
|
51
52
|
|
|
52
|
-
// src/header-cell/
|
|
53
|
+
// src/header-cell/GroupHeaderCell.tsx
|
|
53
54
|
var import_vuu_ui_controls = require("@vuu-ui/vuu-ui-controls");
|
|
54
55
|
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
55
56
|
var import_clsx3 = __toESM(require("clsx"));
|
|
@@ -237,27 +238,27 @@ var useTableColumnResize = ({
|
|
|
237
238
|
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
238
239
|
var import_clsx2 = __toESM(require("clsx"));
|
|
239
240
|
var import_react4 = require("react");
|
|
240
|
-
var useCell = (column,
|
|
241
|
+
var useCell = (column, classBase11, isHeader) => (
|
|
241
242
|
// TODO measure perf without the memo, might not be worth the cost
|
|
242
243
|
(0, import_react4.useMemo)(() => {
|
|
243
|
-
const className = (0, import_clsx2.default)(
|
|
244
|
+
const className = (0, import_clsx2.default)(classBase11, {
|
|
244
245
|
vuuPinFloating: column.pin === "floating",
|
|
245
246
|
vuuPinLeft: column.pin === "left",
|
|
246
247
|
vuuPinRight: column.pin === "right",
|
|
247
248
|
vuuEndPin: isHeader && column.endPin,
|
|
248
249
|
// [`${classBase}-resizing`]: column.resizing,
|
|
249
|
-
[`${
|
|
250
|
-
[`${
|
|
250
|
+
[`${classBase11}-editable`]: column.editable,
|
|
251
|
+
[`${classBase11}-right`]: column.align === "right"
|
|
251
252
|
});
|
|
252
253
|
const style = (0, import_vuu_utils.getColumnStyle)(column);
|
|
253
254
|
return {
|
|
254
255
|
className,
|
|
255
256
|
style
|
|
256
257
|
};
|
|
257
|
-
}, [column,
|
|
258
|
+
}, [column, classBase11, isHeader])
|
|
258
259
|
);
|
|
259
260
|
|
|
260
|
-
// src/header-cell/
|
|
261
|
+
// src/header-cell/GroupHeaderCell.tsx
|
|
261
262
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
262
263
|
var import_react6 = require("react");
|
|
263
264
|
var classBase2 = "vuuTableGroupHeaderCell";
|
|
@@ -268,7 +269,7 @@ var switchIfChanged = (columns, newColumns) => {
|
|
|
268
269
|
return newColumns;
|
|
269
270
|
}
|
|
270
271
|
};
|
|
271
|
-
var
|
|
272
|
+
var GroupHeaderCell = ({
|
|
272
273
|
column: groupColumn,
|
|
273
274
|
className: classNameProp,
|
|
274
275
|
onMoveColumn,
|
|
@@ -325,7 +326,6 @@ var GroupHeaderCellNext = ({
|
|
|
325
326
|
{
|
|
326
327
|
allowDragDrop: true,
|
|
327
328
|
className: `${classBase2}-inner`,
|
|
328
|
-
height: 24,
|
|
329
329
|
onMoveItem: handleMoveItem,
|
|
330
330
|
overflowPosition: "start",
|
|
331
331
|
children: columns.map((column) => {
|
|
@@ -356,60 +356,28 @@ var GroupHeaderCellNext = ({
|
|
|
356
356
|
|
|
357
357
|
// src/header-cell/HeaderCell.tsx
|
|
358
358
|
var import_clsx5 = __toESM(require("clsx"));
|
|
359
|
-
var
|
|
359
|
+
var import_react7 = require("react");
|
|
360
360
|
|
|
361
361
|
// src/column-menu/ColumnMenu.tsx
|
|
362
362
|
var import_vuu_popups = require("@vuu-ui/vuu-popups");
|
|
363
363
|
var import_clsx4 = __toESM(require("clsx"));
|
|
364
|
-
var import_react7 = require("react");
|
|
365
364
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
366
|
-
var
|
|
367
|
-
|
|
368
|
-
const { bottom, left } = element.getBoundingClientRect();
|
|
369
|
-
return { x: left, y: bottom + 6 };
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
var ColumnMenu = ({
|
|
373
|
-
className,
|
|
374
|
-
column,
|
|
375
|
-
...props
|
|
376
|
-
}) => {
|
|
377
|
-
const rootRef = (0, import_react7.useRef)(null);
|
|
378
|
-
const [menuOpen, setMenuOpen] = (0, import_react7.useState)(false);
|
|
379
|
-
const [showContextMenu] = (0, import_vuu_popups.useContextMenu)();
|
|
380
|
-
const handleMenuClose = (0, import_react7.useCallback)(() => {
|
|
381
|
-
setMenuOpen(false);
|
|
382
|
-
}, []);
|
|
383
|
-
const showColumnMenu = (0, import_react7.useCallback)(
|
|
384
|
-
(e) => {
|
|
385
|
-
setMenuOpen(true);
|
|
386
|
-
showContextMenu(e, "column-menu", {
|
|
387
|
-
column,
|
|
388
|
-
ContextMenuProps: {
|
|
389
|
-
onClose: handleMenuClose,
|
|
390
|
-
position: getPosition(rootRef.current)
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
},
|
|
394
|
-
[column, handleMenuClose, showContextMenu]
|
|
395
|
-
);
|
|
365
|
+
var classBase3 = "vuuColumnMenu";
|
|
366
|
+
var ColumnMenu = ({ className, column }) => {
|
|
396
367
|
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
397
|
-
|
|
368
|
+
import_vuu_popups.PopupMenu,
|
|
398
369
|
{
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
403
|
-
"data-icon": "more-vert",
|
|
404
|
-
onClick: showColumnMenu,
|
|
405
|
-
ref: rootRef
|
|
370
|
+
className: (0, import_clsx4.default)(classBase3, className),
|
|
371
|
+
"data-embedded": true,
|
|
372
|
+
menuLocation: "column-menu",
|
|
373
|
+
menuOptions: { column }
|
|
406
374
|
}
|
|
407
375
|
);
|
|
408
376
|
};
|
|
409
377
|
|
|
410
378
|
// src/header-cell/HeaderCell.tsx
|
|
411
379
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
412
|
-
var
|
|
380
|
+
var classBase4 = "vuuTableHeaderCell";
|
|
413
381
|
var HeaderCell = ({
|
|
414
382
|
className: classNameProp,
|
|
415
383
|
column,
|
|
@@ -419,21 +387,21 @@ var HeaderCell = ({
|
|
|
419
387
|
}) => {
|
|
420
388
|
var _a;
|
|
421
389
|
const { HeaderCellContentRenderer, HeaderCellLabelRenderer } = column;
|
|
422
|
-
const rootRef = (0,
|
|
390
|
+
const rootRef = (0, import_react7.useRef)(null);
|
|
423
391
|
const { isResizing, ...resizeProps } = useTableColumnResize({
|
|
424
392
|
column,
|
|
425
393
|
onResize,
|
|
426
394
|
rootRef
|
|
427
395
|
});
|
|
428
|
-
const handleClick = (0,
|
|
396
|
+
const handleClick = (0, import_react7.useCallback)(
|
|
429
397
|
(evt) => {
|
|
430
398
|
!isResizing && (onClick == null ? void 0 : onClick(evt));
|
|
431
399
|
},
|
|
432
400
|
[isResizing, onClick]
|
|
433
401
|
);
|
|
434
|
-
const { className, style } = useCell(column,
|
|
402
|
+
const { className, style } = useCell(column, classBase4, true);
|
|
435
403
|
const columnMenu = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ColumnMenu, { column });
|
|
436
|
-
const columnLabel = HeaderCellLabelRenderer ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderCellLabelRenderer, { className: `${
|
|
404
|
+
const columnLabel = HeaderCellLabelRenderer ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderCellLabelRenderer, { className: `${classBase4}-label`, column }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `${classBase4}-label`, children: (_a = column.label) != null ? _a : column.name });
|
|
437
405
|
const columnContent = HeaderCellContentRenderer ? [/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(HeaderCellContentRenderer, { column }, "content")] : [];
|
|
438
406
|
const sortIndicator = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SortIndicator, { column });
|
|
439
407
|
const headerItems = column.align === "right" ? [sortIndicator, columnLabel].concat(columnContent).concat(columnMenu) : [columnMenu, columnLabel, sortIndicator].concat(columnContent);
|
|
@@ -442,7 +410,7 @@ var HeaderCell = ({
|
|
|
442
410
|
{
|
|
443
411
|
...htmlAttributes,
|
|
444
412
|
className: (0, import_clsx5.default)(className, classNameProp, {
|
|
445
|
-
[`${
|
|
413
|
+
[`${classBase4}-resizing`]: isResizing
|
|
446
414
|
}),
|
|
447
415
|
onClick: handleClick,
|
|
448
416
|
ref: rootRef,
|
|
@@ -462,18 +430,18 @@ var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
|
|
|
462
430
|
var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
|
|
463
431
|
var import_core2 = require("@salt-ds/core");
|
|
464
432
|
var import_clsx9 = __toESM(require("clsx"));
|
|
465
|
-
var
|
|
433
|
+
var import_react26 = require("react");
|
|
466
434
|
|
|
467
435
|
// src/Row.tsx
|
|
468
436
|
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
469
437
|
var import_clsx7 = __toESM(require("clsx"));
|
|
470
|
-
var
|
|
438
|
+
var import_react10 = require("react");
|
|
471
439
|
|
|
472
440
|
// src/table-cell/TableCell.tsx
|
|
473
441
|
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
474
|
-
var
|
|
442
|
+
var import_react8 = require("react");
|
|
475
443
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
476
|
-
var
|
|
444
|
+
var classBase5 = "vuuTableCell";
|
|
477
445
|
var TableCell = ({
|
|
478
446
|
column,
|
|
479
447
|
columnMap,
|
|
@@ -481,10 +449,10 @@ var TableCell = ({
|
|
|
481
449
|
onDataEdited,
|
|
482
450
|
row
|
|
483
451
|
}) => {
|
|
484
|
-
const { className, style } = useCell(column,
|
|
452
|
+
const { className, style } = useCell(column, classBase5);
|
|
485
453
|
const { CellRenderer, index, name, valueFormatter } = column;
|
|
486
454
|
const dataIdx = columnMap[name];
|
|
487
|
-
const handleDataItemEdited = (0,
|
|
455
|
+
const handleDataItemEdited = (0, import_react8.useCallback)(
|
|
488
456
|
(value) => {
|
|
489
457
|
if (onDataEdited) {
|
|
490
458
|
let typedValue = value;
|
|
@@ -500,7 +468,7 @@ var TableCell = ({
|
|
|
500
468
|
},
|
|
501
469
|
[column, name, onDataEdited, row]
|
|
502
470
|
);
|
|
503
|
-
const handleClick = (0,
|
|
471
|
+
const handleClick = (0, import_react8.useCallback)(
|
|
504
472
|
(evt) => {
|
|
505
473
|
onClick == null ? void 0 : onClick(evt, column);
|
|
506
474
|
},
|
|
@@ -529,11 +497,11 @@ var TableCell = ({
|
|
|
529
497
|
|
|
530
498
|
// src/table-cell/TableGroupCell.tsx
|
|
531
499
|
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
532
|
-
var
|
|
500
|
+
var import_react9 = require("react");
|
|
533
501
|
var import_clsx6 = __toESM(require("clsx"));
|
|
534
502
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
535
503
|
var { IS_LEAF } = import_vuu_utils4.metadataKeys;
|
|
536
|
-
var
|
|
504
|
+
var classBase6 = "vuuTableGroupCell";
|
|
537
505
|
var TableGroupCell = ({
|
|
538
506
|
column,
|
|
539
507
|
columnMap,
|
|
@@ -542,15 +510,15 @@ var TableGroupCell = ({
|
|
|
542
510
|
}) => {
|
|
543
511
|
const { columns } = column;
|
|
544
512
|
const [value, offset] = (0, import_vuu_utils4.getGroupValueAndOffset)(columns, row, columnMap);
|
|
545
|
-
const { className, style } = useCell(column,
|
|
546
|
-
const handleClick = (0,
|
|
513
|
+
const { className, style } = useCell(column, classBase6);
|
|
514
|
+
const handleClick = (0, import_react9.useCallback)(
|
|
547
515
|
(evt) => {
|
|
548
516
|
onClick == null ? void 0 : onClick(evt, column);
|
|
549
517
|
},
|
|
550
518
|
[column, onClick]
|
|
551
519
|
);
|
|
552
520
|
const isLeaf = row[IS_LEAF];
|
|
553
|
-
const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `${
|
|
521
|
+
const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `${classBase6}-spacer` }, i));
|
|
554
522
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
555
523
|
"div",
|
|
556
524
|
{
|
|
@@ -560,7 +528,7 @@ var TableGroupCell = ({
|
|
|
560
528
|
onClick: isLeaf ? void 0 : handleClick,
|
|
561
529
|
children: [
|
|
562
530
|
spacers,
|
|
563
|
-
isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `${
|
|
531
|
+
isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `${classBase6}-toggle`, "data-icon": "triangle-right" }),
|
|
564
532
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: value })
|
|
565
533
|
]
|
|
566
534
|
}
|
|
@@ -570,21 +538,21 @@ var TableGroupCell = ({
|
|
|
570
538
|
// src/Row.tsx
|
|
571
539
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
572
540
|
var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils5.metadataKeys;
|
|
573
|
-
var
|
|
574
|
-
var RowProxy = (0,
|
|
541
|
+
var classBase7 = "vuuTableRow";
|
|
542
|
+
var RowProxy = (0, import_react10.forwardRef)(
|
|
575
543
|
function RowProxy2({ height }, forwardedRef) {
|
|
576
544
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
577
545
|
"div",
|
|
578
546
|
{
|
|
579
547
|
"aria-hidden": true,
|
|
580
|
-
className: (0, import_clsx7.default)(
|
|
548
|
+
className: (0, import_clsx7.default)(classBase7, `${classBase7}-proxy`),
|
|
581
549
|
ref: forwardedRef,
|
|
582
550
|
style: { height }
|
|
583
551
|
}
|
|
584
552
|
);
|
|
585
553
|
}
|
|
586
554
|
);
|
|
587
|
-
var Row = (0,
|
|
555
|
+
var Row = (0, import_react10.memo)(
|
|
588
556
|
({
|
|
589
557
|
className: classNameProp,
|
|
590
558
|
classNameGenerator,
|
|
@@ -605,30 +573,30 @@ var Row = (0, import_react11.memo)(
|
|
|
605
573
|
[IS_EXPANDED]: isExpanded,
|
|
606
574
|
[SELECTED]: selectionStatus
|
|
607
575
|
} = row;
|
|
608
|
-
const handleRowClick = (0,
|
|
576
|
+
const handleRowClick = (0, import_react10.useCallback)(
|
|
609
577
|
(evt) => {
|
|
610
578
|
const rangeSelect = evt.shiftKey;
|
|
611
579
|
const keepExistingSelection = evt.ctrlKey || evt.metaKey;
|
|
612
|
-
onClick == null ? void 0 : onClick(row, rangeSelect, keepExistingSelection);
|
|
580
|
+
onClick == null ? void 0 : onClick(evt, row, rangeSelect, keepExistingSelection);
|
|
613
581
|
},
|
|
614
582
|
[onClick, row]
|
|
615
583
|
);
|
|
616
584
|
const { True, First, Last } = import_vuu_utils5.RowSelected;
|
|
617
585
|
const className = (0, import_clsx7.default)(
|
|
618
|
-
|
|
586
|
+
classBase7,
|
|
619
587
|
classNameProp,
|
|
620
588
|
classNameGenerator == null ? void 0 : classNameGenerator(row, columnMap),
|
|
621
589
|
{
|
|
622
|
-
[`${
|
|
623
|
-
[`${
|
|
624
|
-
[`${
|
|
625
|
-
[`${
|
|
626
|
-
[`${
|
|
627
|
-
[`${
|
|
590
|
+
[`${classBase7}-even`]: zebraStripes && rowIndex % 2 === 0,
|
|
591
|
+
[`${classBase7}-expanded`]: isExpanded,
|
|
592
|
+
[`${classBase7}-highlighted`]: highlighted,
|
|
593
|
+
[`${classBase7}-selected`]: selectionStatus & True,
|
|
594
|
+
[`${classBase7}-selectedStart`]: selectionStatus & First,
|
|
595
|
+
[`${classBase7}-selectedEnd`]: selectionStatus & Last
|
|
628
596
|
}
|
|
629
597
|
);
|
|
630
598
|
const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
|
|
631
|
-
const handleGroupCellClick = (0,
|
|
599
|
+
const handleGroupCellClick = (0, import_react10.useCallback)(
|
|
632
600
|
(evt, column) => {
|
|
633
601
|
if ((0, import_vuu_utils5.isGroupColumn)(column) || (0, import_vuu_utils5.isJsonGroup)(column, row, columnMap)) {
|
|
634
602
|
evt.stopPropagation();
|
|
@@ -646,7 +614,7 @@ var Row = (0, import_react11.memo)(
|
|
|
646
614
|
onClick: handleRowClick,
|
|
647
615
|
style,
|
|
648
616
|
children: [
|
|
649
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${
|
|
617
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase7}-selectionDecorator vuuStickyLeft` }),
|
|
650
618
|
virtualColSpan > 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "vuuTableCell", style: { width: virtualColSpan } }) : null,
|
|
651
619
|
columns.filter(import_vuu_utils5.isNotHidden).map((column) => {
|
|
652
620
|
const isGroup = (0, import_vuu_utils5.isGroupColumn)(column);
|
|
@@ -664,7 +632,7 @@ var Row = (0, import_react11.memo)(
|
|
|
664
632
|
column.name
|
|
665
633
|
);
|
|
666
634
|
}),
|
|
667
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${
|
|
635
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: `${classBase7}-selectionDecorator vuuStickyRight` })
|
|
668
636
|
]
|
|
669
637
|
}
|
|
670
638
|
);
|
|
@@ -675,21 +643,21 @@ Row.displayName = "Row";
|
|
|
675
643
|
// src/table-header/TableHeader.tsx
|
|
676
644
|
var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
|
|
677
645
|
var import_clsx8 = __toESM(require("clsx"));
|
|
678
|
-
var
|
|
646
|
+
var import_react12 = require("react");
|
|
679
647
|
|
|
680
648
|
// src/table-header/useTableHeader.ts
|
|
681
649
|
var import_vuu_ui_controls2 = require("@vuu-ui/vuu-ui-controls");
|
|
682
650
|
var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
|
|
683
|
-
var
|
|
651
|
+
var import_react11 = require("react");
|
|
684
652
|
var useTableHeader = ({
|
|
685
653
|
columns,
|
|
686
654
|
onMoveColumn,
|
|
687
655
|
onSortColumn,
|
|
688
656
|
tableConfig
|
|
689
657
|
}) => {
|
|
690
|
-
const containerRef = (0,
|
|
691
|
-
const scrollingContainerRef = (0,
|
|
692
|
-
const setContainerRef = (0,
|
|
658
|
+
const containerRef = (0, import_react11.useRef)(null);
|
|
659
|
+
const scrollingContainerRef = (0, import_react11.useRef)(null);
|
|
660
|
+
const setContainerRef = (0, import_react11.useCallback)((el) => {
|
|
693
661
|
containerRef.current = el;
|
|
694
662
|
if (el) {
|
|
695
663
|
scrollingContainerRef.current = el.closest(".vuuTable-contentContainer");
|
|
@@ -697,7 +665,7 @@ var useTableHeader = ({
|
|
|
697
665
|
scrollingContainerRef.current = null;
|
|
698
666
|
}
|
|
699
667
|
}, []);
|
|
700
|
-
const handleDropColumnHeader = (0,
|
|
668
|
+
const handleDropColumnHeader = (0, import_react11.useCallback)(
|
|
701
669
|
({ fromIndex: moveFrom, toIndex: moveTo }) => {
|
|
702
670
|
const column = columns[moveFrom];
|
|
703
671
|
const orderedColumns = (0, import_vuu_utils6.moveColumnTo)(columns, column, moveTo);
|
|
@@ -713,7 +681,7 @@ var useTableHeader = ({
|
|
|
713
681
|
},
|
|
714
682
|
[columns, onMoveColumn, tableConfig.columns]
|
|
715
683
|
);
|
|
716
|
-
const handleColumnHeaderClick = (0,
|
|
684
|
+
const handleColumnHeaderClick = (0, import_react11.useCallback)(
|
|
717
685
|
(evt) => {
|
|
718
686
|
var _a;
|
|
719
687
|
const targetElement = evt.target;
|
|
@@ -751,9 +719,9 @@ var useTableHeader = ({
|
|
|
751
719
|
|
|
752
720
|
// src/table-header/TableHeader.tsx
|
|
753
721
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
754
|
-
var TableHeader = (0,
|
|
722
|
+
var TableHeader = (0, import_react12.memo)(
|
|
755
723
|
({
|
|
756
|
-
classBase:
|
|
724
|
+
classBase: classBase11 = "vuuTable",
|
|
757
725
|
columns,
|
|
758
726
|
headings,
|
|
759
727
|
onMoveColumn,
|
|
@@ -777,9 +745,9 @@ var TableHeader = (0, import_react13.memo)(
|
|
|
777
745
|
onSortColumn,
|
|
778
746
|
tableConfig
|
|
779
747
|
});
|
|
780
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${
|
|
748
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase11}-col-headings`, ref: setContainerRef, children: [
|
|
781
749
|
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)),
|
|
782
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${
|
|
750
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: `${classBase11}-col-headers`, role: "row", children: [
|
|
783
751
|
virtualColSpan > 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
784
752
|
"div",
|
|
785
753
|
{
|
|
@@ -790,7 +758,7 @@ var TableHeader = (0, import_react13.memo)(
|
|
|
790
758
|
) : null,
|
|
791
759
|
columns.filter(import_vuu_utils7.isNotHidden).map(
|
|
792
760
|
(col, i) => (0, import_vuu_utils7.isGroupColumn)(col) ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
793
|
-
|
|
761
|
+
GroupHeaderCell,
|
|
794
762
|
{
|
|
795
763
|
"aria-colindex": col.index,
|
|
796
764
|
column: col,
|
|
@@ -827,7 +795,7 @@ TableHeader.displayName = "TableHeader";
|
|
|
827
795
|
// src/useTable.ts
|
|
828
796
|
var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
|
|
829
797
|
var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
|
|
830
|
-
var
|
|
798
|
+
var import_react24 = require("react");
|
|
831
799
|
|
|
832
800
|
// src/context-menu/buildContextMenuDescriptors.ts
|
|
833
801
|
var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
|
|
@@ -1142,7 +1110,7 @@ var updateTableConfig = (config, action) => {
|
|
|
1142
1110
|
|
|
1143
1111
|
// src/useCellEditing.ts
|
|
1144
1112
|
var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
|
|
1145
|
-
var
|
|
1113
|
+
var import_react13 = require("react");
|
|
1146
1114
|
|
|
1147
1115
|
// src/table-dom-utils.ts
|
|
1148
1116
|
var headerCellQuery = (colIdx) => `.vuuTable-col-headers .vuuTableHeaderCell:nth-child(${colIdx})`;
|
|
@@ -1197,10 +1165,10 @@ var howFarIsRowOutsideViewport = (rowEl, totalHeaderHeight, contentContainer = r
|
|
|
1197
1165
|
|
|
1198
1166
|
// src/useCellEditing.ts
|
|
1199
1167
|
var useCellEditing = ({ navigate }) => {
|
|
1200
|
-
const commitHandler = (0,
|
|
1168
|
+
const commitHandler = (0, import_react13.useCallback)(() => {
|
|
1201
1169
|
navigate();
|
|
1202
1170
|
}, [navigate]);
|
|
1203
|
-
const editInput = (0,
|
|
1171
|
+
const editInput = (0, import_react13.useCallback)(
|
|
1204
1172
|
(evt) => {
|
|
1205
1173
|
const cellEl = evt.target;
|
|
1206
1174
|
const input = cellEl.matches("input") ? cellEl : cellEl.querySelector("input");
|
|
@@ -1211,7 +1179,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1211
1179
|
},
|
|
1212
1180
|
[]
|
|
1213
1181
|
);
|
|
1214
|
-
const focusInput = (0,
|
|
1182
|
+
const focusInput = (0, import_react13.useCallback)(
|
|
1215
1183
|
(evt) => {
|
|
1216
1184
|
const cellEl = evt.target;
|
|
1217
1185
|
const input = cellEl.querySelector("input");
|
|
@@ -1222,7 +1190,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1222
1190
|
},
|
|
1223
1191
|
[]
|
|
1224
1192
|
);
|
|
1225
|
-
const handleKeyDown = (0,
|
|
1193
|
+
const handleKeyDown = (0, import_react13.useCallback)(
|
|
1226
1194
|
(e) => {
|
|
1227
1195
|
const el = e.target;
|
|
1228
1196
|
if (cellIsTextInput(el)) {
|
|
@@ -1235,7 +1203,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1235
1203
|
},
|
|
1236
1204
|
[editInput, focusInput]
|
|
1237
1205
|
);
|
|
1238
|
-
const handleDoubleClick = (0,
|
|
1206
|
+
const handleDoubleClick = (0, import_react13.useCallback)(
|
|
1239
1207
|
(e) => {
|
|
1240
1208
|
const el = e.target;
|
|
1241
1209
|
if (el.matches("input") || el.querySelector("input")) {
|
|
@@ -1245,14 +1213,14 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1245
1213
|
},
|
|
1246
1214
|
[editInput]
|
|
1247
1215
|
);
|
|
1248
|
-
const handleBlur = (0,
|
|
1216
|
+
const handleBlur = (0, import_react13.useCallback)(
|
|
1249
1217
|
(e) => {
|
|
1250
1218
|
const el = e.target;
|
|
1251
1219
|
el.removeEventListener("vuu-commit", commitHandler, true);
|
|
1252
1220
|
},
|
|
1253
1221
|
[commitHandler]
|
|
1254
1222
|
);
|
|
1255
|
-
const handleFocus = (0,
|
|
1223
|
+
const handleFocus = (0, import_react13.useCallback)(
|
|
1256
1224
|
(e) => {
|
|
1257
1225
|
const el = e.target;
|
|
1258
1226
|
el.addEventListener("vuu-commit", commitHandler, true);
|
|
@@ -1269,7 +1237,7 @@ var useCellEditing = ({ navigate }) => {
|
|
|
1269
1237
|
|
|
1270
1238
|
// src/useDataSource.ts
|
|
1271
1239
|
var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
|
|
1272
|
-
var
|
|
1240
|
+
var import_react14 = require("react");
|
|
1273
1241
|
|
|
1274
1242
|
// src/moving-window.ts
|
|
1275
1243
|
var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
|
|
@@ -1338,17 +1306,17 @@ var useDataSource = ({
|
|
|
1338
1306
|
range = import_vuu_utils13.NULL_RANGE,
|
|
1339
1307
|
renderBufferSize = 0
|
|
1340
1308
|
}) => {
|
|
1341
|
-
const [, forceUpdate] = (0,
|
|
1342
|
-
const data = (0,
|
|
1343
|
-
const isMounted = (0,
|
|
1344
|
-
const hasUpdated = (0,
|
|
1345
|
-
const rangeRef = (0,
|
|
1346
|
-
const dataWindow = (0,
|
|
1309
|
+
const [, forceUpdate] = (0, import_react14.useState)(null);
|
|
1310
|
+
const data = (0, import_react14.useRef)([]);
|
|
1311
|
+
const isMounted = (0, import_react14.useRef)(true);
|
|
1312
|
+
const hasUpdated = (0, import_react14.useRef)(false);
|
|
1313
|
+
const rangeRef = (0, import_react14.useRef)(range);
|
|
1314
|
+
const dataWindow = (0, import_react14.useMemo)(
|
|
1347
1315
|
() => new MovingWindow((0, import_vuu_utils13.getFullRange)(range, renderBufferSize)),
|
|
1348
1316
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1349
1317
|
[]
|
|
1350
1318
|
);
|
|
1351
|
-
const setData = (0,
|
|
1319
|
+
const setData = (0, import_react14.useCallback)(
|
|
1352
1320
|
(updates) => {
|
|
1353
1321
|
for (const row of updates) {
|
|
1354
1322
|
dataWindow.add(row);
|
|
@@ -1361,7 +1329,7 @@ var useDataSource = ({
|
|
|
1361
1329
|
},
|
|
1362
1330
|
[dataWindow]
|
|
1363
1331
|
);
|
|
1364
|
-
const datasourceMessageHandler = (0,
|
|
1332
|
+
const datasourceMessageHandler = (0, import_react14.useCallback)(
|
|
1365
1333
|
(message) => {
|
|
1366
1334
|
if (message.type === "subscribed") {
|
|
1367
1335
|
onSubscribed == null ? void 0 : onSubscribed(message);
|
|
@@ -1384,10 +1352,10 @@ var useDataSource = ({
|
|
|
1384
1352
|
},
|
|
1385
1353
|
[dataWindow, onFeatureInvocation, onSizeChange, onSubscribed, setData]
|
|
1386
1354
|
);
|
|
1387
|
-
const getSelectedRows = (0,
|
|
1355
|
+
const getSelectedRows = (0, import_react14.useCallback)(() => {
|
|
1388
1356
|
return dataWindow.getSelectedRows();
|
|
1389
1357
|
}, [dataWindow]);
|
|
1390
|
-
(0,
|
|
1358
|
+
(0, import_react14.useEffect)(() => {
|
|
1391
1359
|
var _a;
|
|
1392
1360
|
isMounted.current = true;
|
|
1393
1361
|
(_a = dataSource.resume) == null ? void 0 : _a.call(dataSource);
|
|
@@ -1397,7 +1365,7 @@ var useDataSource = ({
|
|
|
1397
1365
|
(_a2 = dataSource.suspend) == null ? void 0 : _a2.call(dataSource);
|
|
1398
1366
|
};
|
|
1399
1367
|
}, [dataSource]);
|
|
1400
|
-
(0,
|
|
1368
|
+
(0, import_react14.useEffect)(() => {
|
|
1401
1369
|
var _a;
|
|
1402
1370
|
if (dataSource.status === "disabled") {
|
|
1403
1371
|
(_a = dataSource.enable) == null ? void 0 : _a.call(dataSource, datasourceMessageHandler);
|
|
@@ -1408,7 +1376,7 @@ var useDataSource = ({
|
|
|
1408
1376
|
);
|
|
1409
1377
|
}
|
|
1410
1378
|
}, [dataSource, datasourceMessageHandler, range, renderBufferSize]);
|
|
1411
|
-
const setRange = (0,
|
|
1379
|
+
const setRange = (0, import_react14.useCallback)(
|
|
1412
1380
|
(range2) => {
|
|
1413
1381
|
if (!(0, import_vuu_utils13.rangesAreSame)(range2, rangeRef.current)) {
|
|
1414
1382
|
const fullRange = (0, import_vuu_utils13.getFullRange)(range2, renderBufferSize);
|
|
@@ -1429,16 +1397,16 @@ var useDataSource = ({
|
|
|
1429
1397
|
};
|
|
1430
1398
|
|
|
1431
1399
|
// src/useInitialValue.ts
|
|
1432
|
-
var
|
|
1400
|
+
var import_react15 = require("react");
|
|
1433
1401
|
var useInitialValue = (value) => {
|
|
1434
|
-
const ref = (0,
|
|
1435
|
-
return (0,
|
|
1402
|
+
const ref = (0, import_react15.useRef)(value);
|
|
1403
|
+
return (0, import_react15.useMemo)(() => ref.current, []);
|
|
1436
1404
|
};
|
|
1437
1405
|
|
|
1438
1406
|
// src/useKeyboardNavigation.ts
|
|
1439
1407
|
var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
|
|
1440
1408
|
var import_core = require("@salt-ds/core");
|
|
1441
|
-
var
|
|
1409
|
+
var import_react16 = require("react");
|
|
1442
1410
|
var rowNavigationKeys = /* @__PURE__ */ new Set([
|
|
1443
1411
|
"Home",
|
|
1444
1412
|
"End",
|
|
@@ -1507,17 +1475,17 @@ var useKeyboardNavigation = ({
|
|
|
1507
1475
|
viewportRowCount
|
|
1508
1476
|
}) => {
|
|
1509
1477
|
var _a;
|
|
1510
|
-
const focusedCellPos = (0,
|
|
1511
|
-
const focusableCell = (0,
|
|
1512
|
-
const activeCellPos = (0,
|
|
1513
|
-
const highlightedIndexRef = (0,
|
|
1478
|
+
const focusedCellPos = (0, import_react16.useRef)([-1, -1]);
|
|
1479
|
+
const focusableCell = (0, import_react16.useRef)();
|
|
1480
|
+
const activeCellPos = (0, import_react16.useRef)([-1, 0]);
|
|
1481
|
+
const highlightedIndexRef = (0, import_react16.useRef)();
|
|
1514
1482
|
const [highlightedIndex, setHighlightedIdx] = (0, import_core.useControlled)({
|
|
1515
1483
|
controlled: highlightedIndexProp,
|
|
1516
1484
|
default: defaultHighlightedIndex,
|
|
1517
1485
|
name: "UseKeyboardNavigation"
|
|
1518
1486
|
});
|
|
1519
1487
|
highlightedIndexRef.current = highlightedIndex;
|
|
1520
|
-
const setHighlightedIndex = (0,
|
|
1488
|
+
const setHighlightedIndex = (0, import_react16.useCallback)(
|
|
1521
1489
|
(idx, fromKeyboard = false) => {
|
|
1522
1490
|
onHighlight == null ? void 0 : onHighlight(idx);
|
|
1523
1491
|
setHighlightedIdx(idx);
|
|
@@ -1544,7 +1512,7 @@ var useKeyboardNavigation = ({
|
|
|
1544
1512
|
}
|
|
1545
1513
|
return NULL_CELL_POS;
|
|
1546
1514
|
};
|
|
1547
|
-
const focusCell = (0,
|
|
1515
|
+
const focusCell = (0, import_react16.useCallback)(
|
|
1548
1516
|
(cellPos) => {
|
|
1549
1517
|
var _a2;
|
|
1550
1518
|
if (containerRef.current) {
|
|
@@ -1564,7 +1532,7 @@ var useKeyboardNavigation = ({
|
|
|
1564
1532
|
// be often whilst scrolling - store range in a a ref ?
|
|
1565
1533
|
[containerRef, requestScroll]
|
|
1566
1534
|
);
|
|
1567
|
-
const setActiveCell = (0,
|
|
1535
|
+
const setActiveCell = (0, import_react16.useCallback)(
|
|
1568
1536
|
(rowIdx, colIdx, fromKeyboard = false) => {
|
|
1569
1537
|
const pos = [rowIdx, colIdx];
|
|
1570
1538
|
activeCellPos.current = pos;
|
|
@@ -1579,7 +1547,7 @@ var useKeyboardNavigation = ({
|
|
|
1579
1547
|
},
|
|
1580
1548
|
[focusCell, navigationStyle, setHighlightedIdx]
|
|
1581
1549
|
);
|
|
1582
|
-
const nextPageItemIdx = (0,
|
|
1550
|
+
const nextPageItemIdx = (0, import_react16.useCallback)(
|
|
1583
1551
|
(key, [rowIdx, colIdx]) => new Promise((resolve) => {
|
|
1584
1552
|
let newRowIdx = rowIdx;
|
|
1585
1553
|
switch (key) {
|
|
@@ -1618,7 +1586,7 @@ var useKeyboardNavigation = ({
|
|
|
1618
1586
|
}),
|
|
1619
1587
|
[requestScroll, rowCount, viewportRowCount]
|
|
1620
1588
|
);
|
|
1621
|
-
const handleFocus = (0,
|
|
1589
|
+
const handleFocus = (0, import_react16.useCallback)(() => {
|
|
1622
1590
|
var _a2;
|
|
1623
1591
|
if (disableHighlightOnFocus !== true) {
|
|
1624
1592
|
if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(document.activeElement)) {
|
|
@@ -1637,7 +1605,7 @@ var useKeyboardNavigation = ({
|
|
|
1637
1605
|
navigationStyle,
|
|
1638
1606
|
setHighlightedIdx
|
|
1639
1607
|
]);
|
|
1640
|
-
const navigateChildItems = (0,
|
|
1608
|
+
const navigateChildItems = (0, import_react16.useCallback)(
|
|
1641
1609
|
async (key) => {
|
|
1642
1610
|
const [nextRowIdx, nextColIdx] = isPagingKey(key) ? await nextPageItemIdx(key, activeCellPos.current) : nextCellPos(key, activeCellPos.current, columnCount, rowCount);
|
|
1643
1611
|
const [rowIdx, colIdx] = activeCellPos.current;
|
|
@@ -1647,13 +1615,13 @@ var useKeyboardNavigation = ({
|
|
|
1647
1615
|
},
|
|
1648
1616
|
[columnCount, nextPageItemIdx, rowCount, setActiveCell]
|
|
1649
1617
|
);
|
|
1650
|
-
const scrollRowIntoViewIfNecessary = (0,
|
|
1618
|
+
const scrollRowIntoViewIfNecessary = (0, import_react16.useCallback)(
|
|
1651
1619
|
(rowIndex) => {
|
|
1652
1620
|
requestScroll == null ? void 0 : requestScroll({ type: "scroll-row", rowIndex });
|
|
1653
1621
|
},
|
|
1654
1622
|
[requestScroll]
|
|
1655
1623
|
);
|
|
1656
|
-
const moveHighlightedRow = (0,
|
|
1624
|
+
const moveHighlightedRow = (0, import_react16.useCallback)(
|
|
1657
1625
|
async (key) => {
|
|
1658
1626
|
const { current: highlighted } = highlightedIndexRef;
|
|
1659
1627
|
const [nextRowIdx] = isPagingKey(key) ? await nextPageItemIdx(key, [highlighted != null ? highlighted : -1, 0]) : nextCellPos(key, [highlighted != null ? highlighted : -1, 0], columnCount, rowCount);
|
|
@@ -1670,12 +1638,12 @@ var useKeyboardNavigation = ({
|
|
|
1670
1638
|
setHighlightedIndex
|
|
1671
1639
|
]
|
|
1672
1640
|
);
|
|
1673
|
-
(0,
|
|
1641
|
+
(0, import_react16.useEffect)(() => {
|
|
1674
1642
|
if (highlightedIndexProp !== void 0 && highlightedIndexProp !== -1) {
|
|
1675
1643
|
scrollRowIntoViewIfNecessary(highlightedIndexProp);
|
|
1676
1644
|
}
|
|
1677
1645
|
}, [highlightedIndexProp, scrollRowIntoViewIfNecessary]);
|
|
1678
|
-
const handleKeyDown = (0,
|
|
1646
|
+
const handleKeyDown = (0, import_react16.useCallback)(
|
|
1679
1647
|
(e) => {
|
|
1680
1648
|
if (rowCount > 0 && isNavigationKey(e.key, navigationStyle)) {
|
|
1681
1649
|
e.preventDefault();
|
|
@@ -1689,7 +1657,7 @@ var useKeyboardNavigation = ({
|
|
|
1689
1657
|
},
|
|
1690
1658
|
[rowCount, navigationStyle, moveHighlightedRow, navigateChildItems]
|
|
1691
1659
|
);
|
|
1692
|
-
const handleClick = (0,
|
|
1660
|
+
const handleClick = (0, import_react16.useCallback)(
|
|
1693
1661
|
// Might not be a cell e.g the Settings button
|
|
1694
1662
|
(evt) => {
|
|
1695
1663
|
const target = evt.target;
|
|
@@ -1701,10 +1669,10 @@ var useKeyboardNavigation = ({
|
|
|
1701
1669
|
},
|
|
1702
1670
|
[setActiveCell]
|
|
1703
1671
|
);
|
|
1704
|
-
const handleMouseLeave = (0,
|
|
1672
|
+
const handleMouseLeave = (0, import_react16.useCallback)(() => {
|
|
1705
1673
|
setHighlightedIndex(-1);
|
|
1706
1674
|
}, [setHighlightedIndex]);
|
|
1707
|
-
const handleMouseMove = (0,
|
|
1675
|
+
const handleMouseMove = (0, import_react16.useCallback)(
|
|
1708
1676
|
(evt) => {
|
|
1709
1677
|
const idx = closestRowIndex(evt.target);
|
|
1710
1678
|
if (idx !== -1 && idx !== highlightedIndexRef.current) {
|
|
@@ -1713,11 +1681,11 @@ var useKeyboardNavigation = ({
|
|
|
1713
1681
|
},
|
|
1714
1682
|
[setHighlightedIndex]
|
|
1715
1683
|
);
|
|
1716
|
-
const navigate = (0,
|
|
1684
|
+
const navigate = (0, import_react16.useCallback)(() => {
|
|
1717
1685
|
navigateChildItems("ArrowDown");
|
|
1718
1686
|
}, [navigateChildItems]);
|
|
1719
1687
|
const fullyRendered = ((_a = containerRef.current) == null ? void 0 : _a.firstChild) != null;
|
|
1720
|
-
(0,
|
|
1688
|
+
(0, import_react16.useEffect)(() => {
|
|
1721
1689
|
if (fullyRendered && focusableCell.current === void 0 && !disableFocus) {
|
|
1722
1690
|
const { current: container } = containerRef;
|
|
1723
1691
|
const cell = (container == null ? void 0 : container.querySelector(headerCellQuery(0))) || (container == null ? void 0 : container.querySelector(dataCellQuery(0, 0)));
|
|
@@ -1740,7 +1708,7 @@ var useKeyboardNavigation = ({
|
|
|
1740
1708
|
|
|
1741
1709
|
// src/useSelection.ts
|
|
1742
1710
|
var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
|
|
1743
|
-
var
|
|
1711
|
+
var import_react17 = require("react");
|
|
1744
1712
|
var { IDX: IDX2 } = import_vuu_utils15.metadataKeys;
|
|
1745
1713
|
var NO_SELECTION = [];
|
|
1746
1714
|
var defaultSelectionKeys = ["Enter", " "];
|
|
@@ -1752,14 +1720,14 @@ var useSelection = ({
|
|
|
1752
1720
|
onSelectionChange
|
|
1753
1721
|
}) => {
|
|
1754
1722
|
selectionModel === "extended" || selectionModel === "checkbox";
|
|
1755
|
-
const lastActiveRef = (0,
|
|
1756
|
-
const selectedRef = (0,
|
|
1757
|
-
const isSelectionEvent = (0,
|
|
1723
|
+
const lastActiveRef = (0, import_react17.useRef)(-1);
|
|
1724
|
+
const selectedRef = (0, import_react17.useRef)(NO_SELECTION);
|
|
1725
|
+
const isSelectionEvent = (0, import_react17.useCallback)(
|
|
1758
1726
|
(evt) => selectionKeys.includes(evt.key),
|
|
1759
1727
|
[selectionKeys]
|
|
1760
1728
|
);
|
|
1761
|
-
const handleRowClick = (0,
|
|
1762
|
-
(row, rangeSelect, keepExistingSelection) => {
|
|
1729
|
+
const handleRowClick = (0, import_react17.useCallback)(
|
|
1730
|
+
(evt, row, rangeSelect, keepExistingSelection) => {
|
|
1763
1731
|
const { [IDX2]: idx } = row;
|
|
1764
1732
|
const { current: active } = lastActiveRef;
|
|
1765
1733
|
const { current: selected } = selectedRef;
|
|
@@ -1779,7 +1747,7 @@ var useSelection = ({
|
|
|
1779
1747
|
},
|
|
1780
1748
|
[onSelect, onSelectionChange, selectionModel]
|
|
1781
1749
|
);
|
|
1782
|
-
const handleKeyDown = (0,
|
|
1750
|
+
const handleKeyDown = (0, import_react17.useCallback)(
|
|
1783
1751
|
(e) => {
|
|
1784
1752
|
if (isSelectionEvent(e)) {
|
|
1785
1753
|
const { current: rowIndex } = highlightedIndexRef;
|
|
@@ -1804,7 +1772,7 @@ var useSelection = ({
|
|
|
1804
1772
|
// src/useTableContextMenu.ts
|
|
1805
1773
|
var import_vuu_popups2 = require("@vuu-ui/vuu-popups");
|
|
1806
1774
|
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
1807
|
-
var
|
|
1775
|
+
var import_react18 = require("react");
|
|
1808
1776
|
var NO_ROWS = [];
|
|
1809
1777
|
var useTableContextMenu = ({
|
|
1810
1778
|
columns,
|
|
@@ -1813,7 +1781,7 @@ var useTableContextMenu = ({
|
|
|
1813
1781
|
getSelectedRows
|
|
1814
1782
|
}) => {
|
|
1815
1783
|
const [showContextMenu] = (0, import_vuu_popups2.useContextMenu)();
|
|
1816
|
-
const onContextMenu = (0,
|
|
1784
|
+
const onContextMenu = (0, import_react18.useCallback)(
|
|
1817
1785
|
(evt) => {
|
|
1818
1786
|
const target = evt.target;
|
|
1819
1787
|
const cellEl = target == null ? void 0 : target.closest("div[role='cell']");
|
|
@@ -1842,7 +1810,7 @@ var useTableContextMenu = ({
|
|
|
1842
1810
|
// src/useTableModel.ts
|
|
1843
1811
|
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
1844
1812
|
var import_vuu_ui_controls3 = require("@vuu-ui/vuu-ui-controls");
|
|
1845
|
-
var
|
|
1813
|
+
var import_react19 = require("react");
|
|
1846
1814
|
var { info } = (0, import_vuu_utils17.logger)("useTableModel");
|
|
1847
1815
|
var DEFAULT_COLUMN_WIDTH = 100;
|
|
1848
1816
|
var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
|
|
@@ -1887,7 +1855,7 @@ var columnReducer = (state, action) => {
|
|
|
1887
1855
|
}
|
|
1888
1856
|
};
|
|
1889
1857
|
var useTableModel = (tableConfigProp, dataSource) => {
|
|
1890
|
-
const [state, dispatchTableModelAction] = (0,
|
|
1858
|
+
const [state, dispatchTableModelAction] = (0, import_react19.useReducer)(columnReducer, { tableConfig: tableConfigProp, dataSource }, init);
|
|
1891
1859
|
const { columns, headings, tableConfig, ...tableAttributes } = state;
|
|
1892
1860
|
return {
|
|
1893
1861
|
columns,
|
|
@@ -2128,7 +2096,7 @@ function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
|
2128
2096
|
|
|
2129
2097
|
// src/useTableScroll.ts
|
|
2130
2098
|
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
2131
|
-
var
|
|
2099
|
+
var import_react20 = require("react");
|
|
2132
2100
|
var SCROLL_MOVE_CHECK_THRESHOLD = 100;
|
|
2133
2101
|
var HORIZONTAL_SCROLL_BUFFER = 200;
|
|
2134
2102
|
var getMaxScroll = (container) => {
|
|
@@ -2179,8 +2147,8 @@ var useCallbackRef = ({
|
|
|
2179
2147
|
onAttach,
|
|
2180
2148
|
onDetach
|
|
2181
2149
|
}) => {
|
|
2182
|
-
const ref = (0,
|
|
2183
|
-
const callbackRef = (0,
|
|
2150
|
+
const ref = (0, import_react20.useRef)(null);
|
|
2151
|
+
const callbackRef = (0, import_react20.useCallback)(
|
|
2184
2152
|
(el) => {
|
|
2185
2153
|
if (el) {
|
|
2186
2154
|
ref.current = el;
|
|
@@ -2206,21 +2174,21 @@ var useTableScroll = ({
|
|
|
2206
2174
|
setRange,
|
|
2207
2175
|
viewportMeasurements
|
|
2208
2176
|
}) => {
|
|
2209
|
-
const firstRowRef = (0,
|
|
2210
|
-
const rowHeightRef = (0,
|
|
2211
|
-
const contentContainerScrolledRef = (0,
|
|
2212
|
-
const contentContainerPosRef = (0,
|
|
2177
|
+
const firstRowRef = (0, import_react20.useRef)(0);
|
|
2178
|
+
const rowHeightRef = (0, import_react20.useRef)(rowHeight);
|
|
2179
|
+
const contentContainerScrolledRef = (0, import_react20.useRef)(false);
|
|
2180
|
+
const contentContainerPosRef = (0, import_react20.useRef)({
|
|
2213
2181
|
scrollTop: 0,
|
|
2214
2182
|
scrollLeft: 0
|
|
2215
2183
|
});
|
|
2216
|
-
const scrollbarContainerScrolledRef = (0,
|
|
2217
|
-
const scrollbarContainerPosRef = (0,
|
|
2184
|
+
const scrollbarContainerScrolledRef = (0, import_react20.useRef)(false);
|
|
2185
|
+
const scrollbarContainerPosRef = (0, import_react20.useRef)({
|
|
2218
2186
|
scrollTop: 0,
|
|
2219
2187
|
scrollLeft: 0
|
|
2220
2188
|
});
|
|
2221
|
-
const scrollbarContainerRef = (0,
|
|
2222
|
-
const contentContainerRef = (0,
|
|
2223
|
-
const lastHorizontalScrollCheckPoint = (0,
|
|
2189
|
+
const scrollbarContainerRef = (0, import_react20.useRef)(null);
|
|
2190
|
+
const contentContainerRef = (0, import_react20.useRef)(null);
|
|
2191
|
+
const lastHorizontalScrollCheckPoint = (0, import_react20.useRef)(0);
|
|
2224
2192
|
const {
|
|
2225
2193
|
appliedPageSize,
|
|
2226
2194
|
isVirtualScroll,
|
|
@@ -2228,10 +2196,10 @@ var useTableScroll = ({
|
|
|
2228
2196
|
totalHeaderHeight,
|
|
2229
2197
|
viewportWidth
|
|
2230
2198
|
} = viewportMeasurements;
|
|
2231
|
-
const columnsWithinViewportRef = (0,
|
|
2232
|
-
const [, forceRefresh] = (0,
|
|
2233
|
-
const preSpanRef = (0,
|
|
2234
|
-
(0,
|
|
2199
|
+
const columnsWithinViewportRef = (0, import_react20.useRef)([]);
|
|
2200
|
+
const [, forceRefresh] = (0, import_react20.useState)({});
|
|
2201
|
+
const preSpanRef = (0, import_react20.useRef)(0);
|
|
2202
|
+
(0, import_react20.useMemo)(() => {
|
|
2235
2203
|
const [visibleColumns, offset] = (0, import_vuu_utils18.getColumnsInViewport)(
|
|
2236
2204
|
columns,
|
|
2237
2205
|
contentContainerPosRef.current.scrollLeft,
|
|
@@ -2240,7 +2208,7 @@ var useTableScroll = ({
|
|
|
2240
2208
|
preSpanRef.current = offset;
|
|
2241
2209
|
columnsWithinViewportRef.current = visibleColumns;
|
|
2242
2210
|
}, [viewportWidth, columns]);
|
|
2243
|
-
const handleHorizontalScroll = (0,
|
|
2211
|
+
const handleHorizontalScroll = (0, import_react20.useCallback)(
|
|
2244
2212
|
(scrollLeft) => {
|
|
2245
2213
|
contentContainerPosRef.current.scrollLeft = scrollLeft;
|
|
2246
2214
|
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
@@ -2260,7 +2228,7 @@ var useTableScroll = ({
|
|
|
2260
2228
|
},
|
|
2261
2229
|
[columns, onHorizontalScroll, viewportWidth]
|
|
2262
2230
|
);
|
|
2263
|
-
const handleVerticalScroll = (0,
|
|
2231
|
+
const handleVerticalScroll = (0, import_react20.useCallback)(
|
|
2264
2232
|
(scrollTop, pctScrollTop) => {
|
|
2265
2233
|
contentContainerPosRef.current.scrollTop = scrollTop;
|
|
2266
2234
|
onVerticalScroll == null ? void 0 : onVerticalScroll(scrollTop, pctScrollTop);
|
|
@@ -2279,7 +2247,7 @@ var useTableScroll = ({
|
|
|
2279
2247
|
viewportRowCount
|
|
2280
2248
|
]
|
|
2281
2249
|
);
|
|
2282
|
-
const handleScrollbarContainerScroll = (0,
|
|
2250
|
+
const handleScrollbarContainerScroll = (0, import_react20.useCallback)(() => {
|
|
2283
2251
|
const { current: contentContainer } = contentContainerRef;
|
|
2284
2252
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
2285
2253
|
const { current: contentContainerScrolled } = contentContainerScrolledRef;
|
|
@@ -2302,7 +2270,7 @@ var useTableScroll = ({
|
|
|
2302
2270
|
}
|
|
2303
2271
|
onVerticalScrollInSitu == null ? void 0 : onVerticalScrollInSitu(0);
|
|
2304
2272
|
}, [onVerticalScrollInSitu]);
|
|
2305
|
-
const handleContentContainerScroll = (0,
|
|
2273
|
+
const handleContentContainerScroll = (0, import_react20.useCallback)(() => {
|
|
2306
2274
|
const { current: scrollbarContainerScrolled } = scrollbarContainerScrolledRef;
|
|
2307
2275
|
const { current: contentContainer } = contentContainerRef;
|
|
2308
2276
|
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
@@ -2333,7 +2301,7 @@ var useTableScroll = ({
|
|
|
2333
2301
|
}
|
|
2334
2302
|
}
|
|
2335
2303
|
}, [handleVerticalScroll, handleHorizontalScroll]);
|
|
2336
|
-
const handleAttachScrollbarContainer = (0,
|
|
2304
|
+
const handleAttachScrollbarContainer = (0, import_react20.useCallback)(
|
|
2337
2305
|
(el) => {
|
|
2338
2306
|
scrollbarContainerRef.current = el;
|
|
2339
2307
|
el.addEventListener("scroll", handleScrollbarContainerScroll, {
|
|
@@ -2342,14 +2310,14 @@ var useTableScroll = ({
|
|
|
2342
2310
|
},
|
|
2343
2311
|
[handleScrollbarContainerScroll]
|
|
2344
2312
|
);
|
|
2345
|
-
const handleDetachScrollbarContainer = (0,
|
|
2313
|
+
const handleDetachScrollbarContainer = (0, import_react20.useCallback)(
|
|
2346
2314
|
(el) => {
|
|
2347
2315
|
scrollbarContainerRef.current = null;
|
|
2348
2316
|
el.removeEventListener("scroll", handleScrollbarContainerScroll);
|
|
2349
2317
|
},
|
|
2350
2318
|
[handleScrollbarContainerScroll]
|
|
2351
2319
|
);
|
|
2352
|
-
const handleAttachContentContainer = (0,
|
|
2320
|
+
const handleAttachContentContainer = (0, import_react20.useCallback)(
|
|
2353
2321
|
(el) => {
|
|
2354
2322
|
contentContainerRef.current = el;
|
|
2355
2323
|
el.addEventListener("scroll", handleContentContainerScroll, {
|
|
@@ -2358,7 +2326,7 @@ var useTableScroll = ({
|
|
|
2358
2326
|
},
|
|
2359
2327
|
[handleContentContainerScroll]
|
|
2360
2328
|
);
|
|
2361
|
-
const handleDetachContentContainer = (0,
|
|
2329
|
+
const handleDetachContentContainer = (0, import_react20.useCallback)(
|
|
2362
2330
|
(el) => {
|
|
2363
2331
|
contentContainerRef.current = null;
|
|
2364
2332
|
el.removeEventListener("scroll", handleContentContainerScroll);
|
|
@@ -2373,7 +2341,7 @@ var useTableScroll = ({
|
|
|
2373
2341
|
onAttach: handleAttachScrollbarContainer,
|
|
2374
2342
|
onDetach: handleDetachScrollbarContainer
|
|
2375
2343
|
});
|
|
2376
|
-
const requestScroll = (0,
|
|
2344
|
+
const requestScroll = (0, import_react20.useCallback)(
|
|
2377
2345
|
(scrollRequest) => {
|
|
2378
2346
|
const { current: contentContainer } = contentContainerRef;
|
|
2379
2347
|
if (contentContainer) {
|
|
@@ -2390,6 +2358,7 @@ var useTableScroll = ({
|
|
|
2390
2358
|
activeRow,
|
|
2391
2359
|
totalHeaderHeight
|
|
2392
2360
|
);
|
|
2361
|
+
console.log(`outside viewport ? ${direction} ${distance}`);
|
|
2393
2362
|
if (direction && distance) {
|
|
2394
2363
|
if (isVirtualScroll) {
|
|
2395
2364
|
const offset = direction === "down" ? 1 : -1;
|
|
@@ -2462,7 +2431,7 @@ var useTableScroll = ({
|
|
|
2462
2431
|
viewportRowCount
|
|
2463
2432
|
]
|
|
2464
2433
|
);
|
|
2465
|
-
const scrollHandles = (0,
|
|
2434
|
+
const scrollHandles = (0, import_react20.useMemo)(
|
|
2466
2435
|
// TODO not complete yet
|
|
2467
2436
|
() => ({
|
|
2468
2437
|
scrollToIndex: (rowIndex) => {
|
|
@@ -2477,7 +2446,7 @@ var useTableScroll = ({
|
|
|
2477
2446
|
}),
|
|
2478
2447
|
[]
|
|
2479
2448
|
);
|
|
2480
|
-
(0,
|
|
2449
|
+
(0, import_react20.useImperativeHandle)(
|
|
2481
2450
|
scrollingApiRef,
|
|
2482
2451
|
() => {
|
|
2483
2452
|
if (scrollbarContainerRef.current) {
|
|
@@ -2488,7 +2457,7 @@ var useTableScroll = ({
|
|
|
2488
2457
|
},
|
|
2489
2458
|
[scrollHandles]
|
|
2490
2459
|
);
|
|
2491
|
-
(0,
|
|
2460
|
+
(0, import_react20.useEffect)(() => {
|
|
2492
2461
|
if (rowHeight !== rowHeightRef.current) {
|
|
2493
2462
|
rowHeightRef.current = rowHeight;
|
|
2494
2463
|
if (contentContainerPosRef.current.scrollTop > 0) {
|
|
@@ -2517,7 +2486,7 @@ var useTableScroll = ({
|
|
|
2517
2486
|
|
|
2518
2487
|
// src/useTableViewport.ts
|
|
2519
2488
|
var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
|
|
2520
|
-
var
|
|
2489
|
+
var import_react21 = require("react");
|
|
2521
2490
|
var MAX_PIXEL_HEIGHT = 1e7;
|
|
2522
2491
|
var UNMEASURED_VIEWPORT = {
|
|
2523
2492
|
appliedPageSize: 0,
|
|
@@ -2546,20 +2515,20 @@ var useTableViewport = ({
|
|
|
2546
2515
|
selectionEndSize = 4,
|
|
2547
2516
|
size
|
|
2548
2517
|
}) => {
|
|
2549
|
-
const inSituRowOffsetRef = (0,
|
|
2550
|
-
const pctScrollTopRef = (0,
|
|
2518
|
+
const inSituRowOffsetRef = (0, import_react21.useRef)(0);
|
|
2519
|
+
const pctScrollTopRef = (0, import_react21.useRef)(0);
|
|
2551
2520
|
const pixelContentHeight = Math.min(rowHeight * rowCount, MAX_PIXEL_HEIGHT);
|
|
2552
2521
|
const virtualContentHeight = rowCount * rowHeight;
|
|
2553
2522
|
const virtualisedExtent = virtualContentHeight - pixelContentHeight;
|
|
2554
|
-
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0,
|
|
2523
|
+
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0, import_react21.useMemo)(
|
|
2555
2524
|
() => (0, import_vuu_utils19.measurePinnedColumns)(columns, selectionEndSize),
|
|
2556
2525
|
[columns, selectionEndSize]
|
|
2557
2526
|
);
|
|
2558
|
-
const totalHeaderHeightRef = (0,
|
|
2559
|
-
(0,
|
|
2527
|
+
const totalHeaderHeightRef = (0, import_react21.useRef)(headerHeight);
|
|
2528
|
+
(0, import_react21.useMemo)(() => {
|
|
2560
2529
|
totalHeaderHeightRef.current = headerHeight * (1 + headings.length);
|
|
2561
2530
|
}, [headerHeight, headings.length]);
|
|
2562
|
-
const [getRowOffset, getRowAtPosition, isVirtualScroll] = (0,
|
|
2531
|
+
const [getRowOffset, getRowAtPosition, isVirtualScroll] = (0, import_react21.useMemo)(() => {
|
|
2563
2532
|
if (virtualisedExtent) {
|
|
2564
2533
|
const [_getRowOffset, getRowAtPosition2, _isVirtual] = (0, import_vuu_utils19.virtualRowPositioning)(rowHeight, virtualisedExtent, pctScrollTopRef);
|
|
2565
2534
|
const getOffset = (row) => {
|
|
@@ -2570,10 +2539,10 @@ var useTableViewport = ({
|
|
|
2570
2539
|
return (0, import_vuu_utils19.actualRowPositioning)(rowHeight);
|
|
2571
2540
|
}
|
|
2572
2541
|
}, [virtualisedExtent, rowHeight]);
|
|
2573
|
-
const setScrollTop = (0,
|
|
2542
|
+
const setScrollTop = (0, import_react21.useCallback)((_, scrollPct) => {
|
|
2574
2543
|
pctScrollTopRef.current = scrollPct;
|
|
2575
2544
|
}, []);
|
|
2576
|
-
const setInSituRowOffset = (0,
|
|
2545
|
+
const setInSituRowOffset = (0, import_react21.useCallback)((rowIndexOffset) => {
|
|
2577
2546
|
if (rowIndexOffset === 0) {
|
|
2578
2547
|
inSituRowOffsetRef.current = 0;
|
|
2579
2548
|
} else {
|
|
@@ -2583,7 +2552,7 @@ var useTableViewport = ({
|
|
|
2583
2552
|
);
|
|
2584
2553
|
}
|
|
2585
2554
|
}, []);
|
|
2586
|
-
return (0,
|
|
2555
|
+
return (0, import_react21.useMemo)(() => {
|
|
2587
2556
|
if (size) {
|
|
2588
2557
|
const { current: totalHeaderHeight } = totalHeaderHeightRef;
|
|
2589
2558
|
const scrollbarSize = 15;
|
|
@@ -2636,7 +2605,7 @@ var useTableViewport = ({
|
|
|
2636
2605
|
// src/useTableAndColumnSettings.ts
|
|
2637
2606
|
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
2638
2607
|
var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
|
|
2639
|
-
var
|
|
2608
|
+
var import_react22 = require("react");
|
|
2640
2609
|
var useTableAndColumnSettings = ({
|
|
2641
2610
|
availableColumns: availableColumnsProps,
|
|
2642
2611
|
onAvailableColumnsChange,
|
|
@@ -2646,11 +2615,11 @@ var useTableAndColumnSettings = ({
|
|
|
2646
2615
|
tableConfig
|
|
2647
2616
|
}) => {
|
|
2648
2617
|
const dispatchLayoutAction = (0, import_vuu_layout.useLayoutProviderDispatch)();
|
|
2649
|
-
const showTableSettingsRef = (0,
|
|
2650
|
-
const [availableColumns, setAvailableColumns] = (0,
|
|
2618
|
+
const showTableSettingsRef = (0, import_react22.useRef)();
|
|
2619
|
+
const [availableColumns, setAvailableColumns] = (0, import_react22.useState)(
|
|
2651
2620
|
availableColumnsProps
|
|
2652
2621
|
);
|
|
2653
|
-
const showContextPanel = (0,
|
|
2622
|
+
const showContextPanel = (0, import_react22.useCallback)(
|
|
2654
2623
|
(componentType, title, props) => {
|
|
2655
2624
|
dispatchLayoutAction({
|
|
2656
2625
|
type: "set-props",
|
|
@@ -2667,13 +2636,13 @@ var useTableAndColumnSettings = ({
|
|
|
2667
2636
|
},
|
|
2668
2637
|
[dispatchLayoutAction]
|
|
2669
2638
|
);
|
|
2670
|
-
const handleCancelCreateColumn = (0,
|
|
2639
|
+
const handleCancelCreateColumn = (0, import_react22.useCallback)(() => {
|
|
2671
2640
|
requestAnimationFrame(() => {
|
|
2672
2641
|
var _a;
|
|
2673
2642
|
(_a = showTableSettingsRef.current) == null ? void 0 : _a.call(showTableSettingsRef);
|
|
2674
2643
|
});
|
|
2675
2644
|
}, []);
|
|
2676
|
-
const handleCreateCalculatedColumn = (0,
|
|
2645
|
+
const handleCreateCalculatedColumn = (0, import_react22.useCallback)(
|
|
2677
2646
|
(column) => {
|
|
2678
2647
|
const newAvailableColumns = availableColumns.concat({
|
|
2679
2648
|
name: column.name,
|
|
@@ -2689,7 +2658,7 @@ var useTableAndColumnSettings = ({
|
|
|
2689
2658
|
},
|
|
2690
2659
|
[availableColumns, onAvailableColumnsChange, onCreateCalculatedColumn]
|
|
2691
2660
|
);
|
|
2692
|
-
const showColumnSettingsPanel = (0,
|
|
2661
|
+
const showColumnSettingsPanel = (0, import_react22.useCallback)(
|
|
2693
2662
|
(action) => {
|
|
2694
2663
|
showContextPanel("ColumnSettings", "Column Settings", {
|
|
2695
2664
|
column: action.column,
|
|
@@ -2708,7 +2677,7 @@ var useTableAndColumnSettings = ({
|
|
|
2708
2677
|
tableConfig
|
|
2709
2678
|
]
|
|
2710
2679
|
);
|
|
2711
|
-
const handleAddCalculatedColumn = (0,
|
|
2680
|
+
const handleAddCalculatedColumn = (0, import_react22.useCallback)(() => {
|
|
2712
2681
|
showColumnSettingsPanel({
|
|
2713
2682
|
column: {
|
|
2714
2683
|
name: "::",
|
|
@@ -2718,7 +2687,7 @@ var useTableAndColumnSettings = ({
|
|
|
2718
2687
|
vuuTable: { module: "SIMUL", table: "instruments" }
|
|
2719
2688
|
});
|
|
2720
2689
|
}, [showColumnSettingsPanel]);
|
|
2721
|
-
const handleNavigateToColumn = (0,
|
|
2690
|
+
const handleNavigateToColumn = (0, import_react22.useCallback)(
|
|
2722
2691
|
(columnName) => {
|
|
2723
2692
|
const column = tableConfig.columns.find((c) => c.name === columnName);
|
|
2724
2693
|
if (column) {
|
|
@@ -2732,7 +2701,7 @@ var useTableAndColumnSettings = ({
|
|
|
2732
2701
|
},
|
|
2733
2702
|
[showColumnSettingsPanel, tableConfig.columns]
|
|
2734
2703
|
);
|
|
2735
|
-
showTableSettingsRef.current = (0,
|
|
2704
|
+
showTableSettingsRef.current = (0, import_react22.useCallback)(() => {
|
|
2736
2705
|
showContextPanel("TableSettings", "DataGrid Settings", {
|
|
2737
2706
|
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name, serverDataType }) => ({
|
|
2738
2707
|
name,
|
|
@@ -2761,7 +2730,7 @@ var useTableAndColumnSettings = ({
|
|
|
2761
2730
|
|
|
2762
2731
|
// src/useRowClassNameGenerators.ts
|
|
2763
2732
|
var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
|
|
2764
|
-
var
|
|
2733
|
+
var import_react23 = require("react");
|
|
2765
2734
|
var createClassNameGenerator = (ids) => {
|
|
2766
2735
|
const functions = [];
|
|
2767
2736
|
ids == null ? void 0 : ids.forEach((id) => {
|
|
@@ -2784,7 +2753,7 @@ var createClassNameGenerator = (ids) => {
|
|
|
2784
2753
|
var useRowClassNameGenerators = ({
|
|
2785
2754
|
rowClassNameGenerators
|
|
2786
2755
|
}) => {
|
|
2787
|
-
return (0,
|
|
2756
|
+
return (0, import_react23.useMemo)(() => {
|
|
2788
2757
|
return createClassNameGenerator(rowClassNameGenerators);
|
|
2789
2758
|
}, [rowClassNameGenerators]);
|
|
2790
2759
|
};
|
|
@@ -2829,17 +2798,17 @@ var useTable = ({
|
|
|
2829
2798
|
selectionModel,
|
|
2830
2799
|
size
|
|
2831
2800
|
}) => {
|
|
2832
|
-
const [rowCount, setRowCount] = (0,
|
|
2801
|
+
const [rowCount, setRowCount] = (0, import_react24.useState)(dataSource.size);
|
|
2833
2802
|
if (dataSource === void 0) {
|
|
2834
2803
|
throw Error("no data source provided to Vuu Table");
|
|
2835
2804
|
}
|
|
2836
2805
|
const rowClassNameGenerator = useRowClassNameGenerators(config);
|
|
2837
2806
|
const useRowDragDrop = allowDragDrop ? import_vuu_ui_controls4.useDragDrop : useNullDragDrop;
|
|
2838
|
-
const menuBuilder = (0,
|
|
2807
|
+
const menuBuilder = (0, import_react24.useMemo)(
|
|
2839
2808
|
() => buildContextMenuDescriptors(dataSource),
|
|
2840
2809
|
[dataSource]
|
|
2841
2810
|
);
|
|
2842
|
-
const onDataRowcountChange = (0,
|
|
2811
|
+
const onDataRowcountChange = (0, import_react24.useCallback)((size2) => {
|
|
2843
2812
|
setRowCount(size2);
|
|
2844
2813
|
}, []);
|
|
2845
2814
|
const {
|
|
@@ -2856,7 +2825,7 @@ var useTable = ({
|
|
|
2856
2825
|
dataSource
|
|
2857
2826
|
});
|
|
2858
2827
|
}, [config, dataSource, dispatchTableModelAction]);
|
|
2859
|
-
const applyTableConfigChange = (0,
|
|
2828
|
+
const applyTableConfigChange = (0, import_react24.useCallback)(
|
|
2860
2829
|
(config2) => {
|
|
2861
2830
|
dispatchTableModelAction({
|
|
2862
2831
|
type: "init",
|
|
@@ -2867,11 +2836,11 @@ var useTable = ({
|
|
|
2867
2836
|
},
|
|
2868
2837
|
[dataSource, dispatchTableModelAction, onConfigChange]
|
|
2869
2838
|
);
|
|
2870
|
-
const columnMap = (0,
|
|
2839
|
+
const columnMap = (0, import_react24.useMemo)(
|
|
2871
2840
|
() => (0, import_vuu_utils22.buildColumnMap)(dataSource.columns),
|
|
2872
2841
|
[dataSource.columns]
|
|
2873
2842
|
);
|
|
2874
|
-
const onSubscribed = (0,
|
|
2843
|
+
const onSubscribed = (0, import_react24.useCallback)(
|
|
2875
2844
|
({ tableSchema }) => {
|
|
2876
2845
|
if (tableSchema) {
|
|
2877
2846
|
dispatchTableModelAction({
|
|
@@ -2921,7 +2890,7 @@ var useTable = ({
|
|
|
2921
2890
|
onVerticalScrollInSitu: viewportHookSetInSituRowOffset,
|
|
2922
2891
|
viewportMeasurements
|
|
2923
2892
|
});
|
|
2924
|
-
const handleConfigEditedInSettingsPanel = (0,
|
|
2893
|
+
const handleConfigEditedInSettingsPanel = (0, import_react24.useCallback)(
|
|
2925
2894
|
(tableConfig2) => {
|
|
2926
2895
|
dispatchTableModelAction({
|
|
2927
2896
|
type: "init",
|
|
@@ -2932,7 +2901,7 @@ var useTable = ({
|
|
|
2932
2901
|
},
|
|
2933
2902
|
[dataSource, dispatchTableModelAction, onConfigChange]
|
|
2934
2903
|
);
|
|
2935
|
-
const handleDataSourceConfigChanged = (0,
|
|
2904
|
+
const handleDataSourceConfigChanged = (0, import_react24.useCallback)(
|
|
2936
2905
|
(dataSourceConfig) => {
|
|
2937
2906
|
dataSource.config = {
|
|
2938
2907
|
...dataSource.config,
|
|
@@ -2941,7 +2910,7 @@ var useTable = ({
|
|
|
2941
2910
|
},
|
|
2942
2911
|
[dataSource]
|
|
2943
2912
|
);
|
|
2944
|
-
(0,
|
|
2913
|
+
(0, import_react24.useEffect)(() => {
|
|
2945
2914
|
dataSource.on("config", (config2, confirmed, changes) => {
|
|
2946
2915
|
const scrollSensitiveChanges = (changes == null ? void 0 : changes.filterChanged) || (changes == null ? void 0 : changes.groupByChanged);
|
|
2947
2916
|
if (scrollSensitiveChanges && dataSource.range.from > 0) {
|
|
@@ -2957,14 +2926,14 @@ var useTable = ({
|
|
|
2957
2926
|
});
|
|
2958
2927
|
});
|
|
2959
2928
|
}, [dataSource, dispatchTableModelAction, requestScroll]);
|
|
2960
|
-
const handleCreateCalculatedColumn = (0,
|
|
2929
|
+
const handleCreateCalculatedColumn = (0, import_react24.useCallback)(
|
|
2961
2930
|
(column) => {
|
|
2962
2931
|
dataSource.columns = dataSource.columns.concat(column.name);
|
|
2963
2932
|
applyTableConfigChange(addColumn(tableConfig, column));
|
|
2964
2933
|
},
|
|
2965
2934
|
[dataSource, tableConfig, applyTableConfigChange]
|
|
2966
2935
|
);
|
|
2967
|
-
const hideColumns2 = (0,
|
|
2936
|
+
const hideColumns2 = (0, import_react24.useCallback)(
|
|
2968
2937
|
(action) => {
|
|
2969
2938
|
const { columns: columns2 } = action;
|
|
2970
2939
|
const hiddenColumns = columns2.map((c) => c.name);
|
|
@@ -2978,7 +2947,7 @@ var useTable = ({
|
|
|
2978
2947
|
},
|
|
2979
2948
|
[tableConfig, applyTableConfigChange]
|
|
2980
2949
|
);
|
|
2981
|
-
const pinColumn3 = (0,
|
|
2950
|
+
const pinColumn3 = (0, import_react24.useCallback)(
|
|
2982
2951
|
(action) => {
|
|
2983
2952
|
applyTableConfigChange({
|
|
2984
2953
|
...tableConfig,
|
|
@@ -3001,7 +2970,7 @@ var useTable = ({
|
|
|
3001
2970
|
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
3002
2971
|
tableConfig
|
|
3003
2972
|
});
|
|
3004
|
-
const onPersistentColumnOperation = (0,
|
|
2973
|
+
const onPersistentColumnOperation = (0, import_react24.useCallback)(
|
|
3005
2974
|
(action) => {
|
|
3006
2975
|
if (isShowColumnSettings(action)) {
|
|
3007
2976
|
showColumnSettingsPanel(action);
|
|
@@ -3030,7 +2999,7 @@ var useTable = ({
|
|
|
3030
2999
|
dataSource,
|
|
3031
3000
|
onPersistentColumnOperation
|
|
3032
3001
|
});
|
|
3033
|
-
const handleSort = (0,
|
|
3002
|
+
const handleSort = (0, import_react24.useCallback)(
|
|
3034
3003
|
(column, extendSort = false, sortType) => {
|
|
3035
3004
|
if (dataSource) {
|
|
3036
3005
|
dataSource.sort = (0, import_vuu_utils22.applySort)(
|
|
@@ -3043,8 +3012,8 @@ var useTable = ({
|
|
|
3043
3012
|
},
|
|
3044
3013
|
[dataSource]
|
|
3045
3014
|
);
|
|
3046
|
-
const resizeCells = (0,
|
|
3047
|
-
const onResizeColumn = (0,
|
|
3015
|
+
const resizeCells = (0, import_react24.useRef)();
|
|
3016
|
+
const onResizeColumn = (0, import_react24.useCallback)(
|
|
3048
3017
|
(phase, columnName, width) => {
|
|
3049
3018
|
var _a, _b, _c;
|
|
3050
3019
|
const column = columns.find((column2) => column2.name === columnName);
|
|
@@ -3100,7 +3069,7 @@ var useTable = ({
|
|
|
3100
3069
|
containerRef
|
|
3101
3070
|
]
|
|
3102
3071
|
);
|
|
3103
|
-
const onToggleGroup = (0,
|
|
3072
|
+
const onToggleGroup = (0, import_react24.useCallback)(
|
|
3104
3073
|
(row, column) => {
|
|
3105
3074
|
var _a, _b;
|
|
3106
3075
|
const isJson = (0, import_vuu_utils22.isJsonGroup)(column, row, columnMap);
|
|
@@ -3163,7 +3132,7 @@ var useTable = ({
|
|
|
3163
3132
|
} = useCellEditing({
|
|
3164
3133
|
navigate
|
|
3165
3134
|
});
|
|
3166
|
-
const handleFocus = (0,
|
|
3135
|
+
const handleFocus = (0, import_react24.useCallback)(
|
|
3167
3136
|
(e) => {
|
|
3168
3137
|
navigationFocus();
|
|
3169
3138
|
if (!e.defaultPrevented) {
|
|
@@ -3178,13 +3147,13 @@ var useTable = ({
|
|
|
3178
3147
|
dataSource,
|
|
3179
3148
|
getSelectedRows
|
|
3180
3149
|
});
|
|
3181
|
-
const onMoveGroupColumn = (0,
|
|
3150
|
+
const onMoveGroupColumn = (0, import_react24.useCallback)(
|
|
3182
3151
|
(columns2) => {
|
|
3183
3152
|
dataSource.groupBy = columns2.map((col) => col.name);
|
|
3184
3153
|
},
|
|
3185
3154
|
[dataSource]
|
|
3186
3155
|
);
|
|
3187
|
-
const onRemoveGroupColumn = (0,
|
|
3156
|
+
const onRemoveGroupColumn = (0, import_react24.useCallback)(
|
|
3188
3157
|
(column) => {
|
|
3189
3158
|
if ((0, import_vuu_utils22.isGroupColumn)(column)) {
|
|
3190
3159
|
dataSource.groupBy = [];
|
|
@@ -3198,23 +3167,38 @@ var useTable = ({
|
|
|
3198
3167
|
},
|
|
3199
3168
|
[dataSource]
|
|
3200
3169
|
);
|
|
3201
|
-
const handleSelectionChange = (0,
|
|
3170
|
+
const handleSelectionChange = (0, import_react24.useCallback)(
|
|
3202
3171
|
(selected) => {
|
|
3203
3172
|
dataSource.select(selected);
|
|
3204
3173
|
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
3205
3174
|
},
|
|
3206
3175
|
[dataSource, onSelectionChange]
|
|
3207
3176
|
);
|
|
3177
|
+
const handleSelect = (0, import_react24.useCallback)(
|
|
3178
|
+
(row) => {
|
|
3179
|
+
if (onSelect) {
|
|
3180
|
+
onSelect(row === null ? null : (0, import_vuu_utils22.asDataSourceRowObject)(row, columnMap));
|
|
3181
|
+
}
|
|
3182
|
+
},
|
|
3183
|
+
[columnMap, onSelect]
|
|
3184
|
+
);
|
|
3208
3185
|
const {
|
|
3209
3186
|
onKeyDown: selectionHookKeyDown,
|
|
3210
3187
|
onRowClick: selectionHookOnRowClick
|
|
3211
3188
|
} = useSelection({
|
|
3212
3189
|
highlightedIndexRef,
|
|
3213
|
-
onSelect,
|
|
3190
|
+
onSelect: handleSelect,
|
|
3214
3191
|
onSelectionChange: handleSelectionChange,
|
|
3215
3192
|
selectionModel
|
|
3216
3193
|
});
|
|
3217
|
-
const
|
|
3194
|
+
const handleRowClick = (0, import_react24.useCallback)(
|
|
3195
|
+
(evt, row, rangeSelect, keepExistingSelection) => {
|
|
3196
|
+
selectionHookOnRowClick(evt, row, rangeSelect, keepExistingSelection);
|
|
3197
|
+
onRowClickProp == null ? void 0 : onRowClickProp(evt, (0, import_vuu_utils22.asDataSourceRowObject)(row, columnMap));
|
|
3198
|
+
},
|
|
3199
|
+
[columnMap, onRowClickProp, selectionHookOnRowClick]
|
|
3200
|
+
);
|
|
3201
|
+
const handleKeyDown = (0, import_react24.useCallback)(
|
|
3218
3202
|
(e) => {
|
|
3219
3203
|
navigationKeyDown(e);
|
|
3220
3204
|
if (!e.defaultPrevented) {
|
|
@@ -3226,14 +3210,7 @@ var useTable = ({
|
|
|
3226
3210
|
},
|
|
3227
3211
|
[navigationKeyDown, editingKeyDown, selectionHookKeyDown]
|
|
3228
3212
|
);
|
|
3229
|
-
const
|
|
3230
|
-
(row, rangeSelect, keepExistingSelection) => {
|
|
3231
|
-
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
3232
|
-
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
3233
|
-
},
|
|
3234
|
-
[onRowClickProp, selectionHookOnRowClick]
|
|
3235
|
-
);
|
|
3236
|
-
const onMoveColumn = (0, import_react25.useCallback)(
|
|
3213
|
+
const onMoveColumn = (0, import_react24.useCallback)(
|
|
3237
3214
|
(columns2) => {
|
|
3238
3215
|
const newTableConfig = {
|
|
3239
3216
|
...tableConfig,
|
|
@@ -3248,17 +3225,17 @@ var useTable = ({
|
|
|
3248
3225
|
},
|
|
3249
3226
|
[dataSource, dispatchTableModelAction, onConfigChange, tableConfig]
|
|
3250
3227
|
);
|
|
3251
|
-
const handleDropRow = (0,
|
|
3228
|
+
const handleDropRow = (0, import_react24.useCallback)(
|
|
3252
3229
|
(dragDropState) => {
|
|
3253
3230
|
onDrop == null ? void 0 : onDrop(dragDropState);
|
|
3254
3231
|
},
|
|
3255
3232
|
[onDrop]
|
|
3256
3233
|
);
|
|
3257
|
-
const handleDataEdited = (0,
|
|
3234
|
+
const handleDataEdited = (0, import_react24.useCallback)(
|
|
3258
3235
|
async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
|
|
3259
3236
|
[dataSource]
|
|
3260
3237
|
);
|
|
3261
|
-
const handleDragStartRow = (0,
|
|
3238
|
+
const handleDragStartRow = (0, import_react24.useCallback)(
|
|
3262
3239
|
(dragDropState) => {
|
|
3263
3240
|
const { initialDragElement } = dragDropState;
|
|
3264
3241
|
const rowIndex = (0, import_vuu_utils22.getIndexFromRowElement)(initialDragElement);
|
|
@@ -3318,17 +3295,17 @@ var useTable = ({
|
|
|
3318
3295
|
|
|
3319
3296
|
// src/useRowHeight.ts
|
|
3320
3297
|
var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
|
|
3321
|
-
var
|
|
3298
|
+
var import_react25 = require("react");
|
|
3322
3299
|
var useRowHeight = ({
|
|
3323
3300
|
rowHeight: rowHeightProp = 0
|
|
3324
3301
|
}) => {
|
|
3325
|
-
const [rowHeight, setRowHeight] = (0,
|
|
3326
|
-
const heightRef = (0,
|
|
3327
|
-
const resizeObserver = (0,
|
|
3302
|
+
const [rowHeight, setRowHeight] = (0, import_react25.useState)(rowHeightProp);
|
|
3303
|
+
const heightRef = (0, import_react25.useRef)(rowHeight);
|
|
3304
|
+
const resizeObserver = (0, import_react25.useMemo)(() => {
|
|
3328
3305
|
return new ResizeObserver((entries) => {
|
|
3329
3306
|
for (const entry of entries) {
|
|
3330
|
-
const {
|
|
3331
|
-
const newHeight = Math.round(
|
|
3307
|
+
const [{ blockSize: measuredSize }] = entry.borderBoxSize;
|
|
3308
|
+
const newHeight = Math.round(measuredSize);
|
|
3332
3309
|
if ((0, import_vuu_utils23.isValidNumber)(newHeight) && heightRef.current !== newHeight) {
|
|
3333
3310
|
heightRef.current = newHeight;
|
|
3334
3311
|
setRowHeight(newHeight);
|
|
@@ -3336,12 +3313,13 @@ var useRowHeight = ({
|
|
|
3336
3313
|
}
|
|
3337
3314
|
});
|
|
3338
3315
|
}, []);
|
|
3339
|
-
const rowRef = (0,
|
|
3316
|
+
const rowRef = (0, import_react25.useCallback)(
|
|
3340
3317
|
(el) => {
|
|
3341
3318
|
if (el) {
|
|
3342
3319
|
if (rowHeightProp === 0) {
|
|
3343
3320
|
const { height } = el.getBoundingClientRect();
|
|
3344
|
-
console.log(
|
|
3321
|
+
console.log({ boundingClientHeight: height });
|
|
3322
|
+
console.log(`measured rowHeight = ${height} (${rowHeightProp})`);
|
|
3345
3323
|
resizeObserver.observe(el);
|
|
3346
3324
|
setRowHeight(height);
|
|
3347
3325
|
}
|
|
@@ -3356,7 +3334,7 @@ var useRowHeight = ({
|
|
|
3356
3334
|
|
|
3357
3335
|
// src/Table.tsx
|
|
3358
3336
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3359
|
-
var
|
|
3337
|
+
var classBase8 = "vuuTable";
|
|
3360
3338
|
var { IDX: IDX3, RENDER_IDX } = import_vuu_utils24.metadataKeys;
|
|
3361
3339
|
var TableCore = ({
|
|
3362
3340
|
Row: Row2 = Row,
|
|
@@ -3431,16 +3409,16 @@ var TableCore = ({
|
|
|
3431
3409
|
onRowClick: onRowClickProp,
|
|
3432
3410
|
onSelect,
|
|
3433
3411
|
onSelectionChange,
|
|
3434
|
-
renderBufferSize,
|
|
3412
|
+
renderBufferSize: Math.max(5, renderBufferSize),
|
|
3435
3413
|
rowHeight,
|
|
3436
3414
|
scrollingApiRef,
|
|
3437
3415
|
selectionModel,
|
|
3438
3416
|
size
|
|
3439
3417
|
});
|
|
3440
|
-
const contentContainerClassName = (0, import_clsx9.default)(`${
|
|
3441
|
-
[`${
|
|
3442
|
-
[`${
|
|
3443
|
-
[`${
|
|
3418
|
+
const contentContainerClassName = (0, import_clsx9.default)(`${classBase8}-contentContainer`, {
|
|
3419
|
+
[`${classBase8}-colLines`]: tableAttributes.columnSeparators,
|
|
3420
|
+
[`${classBase8}-rowLines`]: tableAttributes.rowSeparators,
|
|
3421
|
+
[`${classBase8}-zebra`]: tableAttributes.zebraStripes
|
|
3444
3422
|
});
|
|
3445
3423
|
const cssVariables = {
|
|
3446
3424
|
"--content-height": `${viewportMeasurements.contentHeight}px`,
|
|
@@ -3463,10 +3441,10 @@ var TableCore = ({
|
|
|
3463
3441
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3464
3442
|
"div",
|
|
3465
3443
|
{
|
|
3466
|
-
className: `${
|
|
3444
|
+
className: `${classBase8}-scrollbarContainer`,
|
|
3467
3445
|
ref: scrollProps.scrollbarContainerRef,
|
|
3468
3446
|
style: cssVariables,
|
|
3469
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${
|
|
3447
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase8}-scrollbarContent` })
|
|
3470
3448
|
}
|
|
3471
3449
|
),
|
|
3472
3450
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -3479,7 +3457,7 @@ var TableCore = ({
|
|
|
3479
3457
|
"div",
|
|
3480
3458
|
{
|
|
3481
3459
|
...tableProps,
|
|
3482
|
-
className: `${
|
|
3460
|
+
className: `${classBase8}-table`,
|
|
3483
3461
|
role: "table",
|
|
3484
3462
|
tabIndex: disableFocus ? void 0 : -1,
|
|
3485
3463
|
children: [
|
|
@@ -3498,7 +3476,7 @@ var TableCore = ({
|
|
|
3498
3476
|
virtualColSpan: scrollProps.virtualColSpan
|
|
3499
3477
|
}
|
|
3500
3478
|
) : null,
|
|
3501
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${
|
|
3479
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: `${classBase8}-body`, children: data.map((data2) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3502
3480
|
Row2,
|
|
3503
3481
|
{
|
|
3504
3482
|
"aria-rowindex": data2[0] + 1,
|
|
@@ -3526,7 +3504,7 @@ var TableCore = ({
|
|
|
3526
3504
|
}
|
|
3527
3505
|
);
|
|
3528
3506
|
};
|
|
3529
|
-
var Table = (0,
|
|
3507
|
+
var Table = (0, import_react26.forwardRef)(function TableNext({
|
|
3530
3508
|
Row: Row2,
|
|
3531
3509
|
allowDragDrop,
|
|
3532
3510
|
availableColumns,
|
|
@@ -3555,8 +3533,8 @@ var Table = (0, import_react27.forwardRef)(function TableNext({
|
|
|
3555
3533
|
style: styleProp,
|
|
3556
3534
|
...htmlAttributes
|
|
3557
3535
|
}, forwardedRef) {
|
|
3558
|
-
const containerRef = (0,
|
|
3559
|
-
const [size, setSize] = (0,
|
|
3536
|
+
const containerRef = (0, import_react26.useRef)(null);
|
|
3537
|
+
const [size, setSize] = (0, import_react26.useState)();
|
|
3560
3538
|
const { rowHeight, rowRef } = useRowHeight({ rowHeight: rowHeightProp });
|
|
3561
3539
|
if (config === void 0) {
|
|
3562
3540
|
throw Error(
|
|
@@ -3566,11 +3544,12 @@ var Table = (0, import_react27.forwardRef)(function TableNext({
|
|
|
3566
3544
|
if (dataSource === void 0) {
|
|
3567
3545
|
throw Error("vuu Table requires dataSource prop");
|
|
3568
3546
|
}
|
|
3547
|
+
console.log({ rowHeight });
|
|
3569
3548
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
3570
3549
|
import_vuu_ui_controls5.MeasuredContainer,
|
|
3571
3550
|
{
|
|
3572
3551
|
...htmlAttributes,
|
|
3573
|
-
className: (0, import_clsx9.default)(
|
|
3552
|
+
className: (0, import_clsx9.default)(classBase8, classNameProp),
|
|
3574
3553
|
id,
|
|
3575
3554
|
onResize: setSize,
|
|
3576
3555
|
ref: (0, import_core2.useForkRef)(containerRef, forwardedRef),
|
|
@@ -3613,16 +3592,16 @@ var Table = (0, import_react27.forwardRef)(function TableNext({
|
|
|
3613
3592
|
});
|
|
3614
3593
|
|
|
3615
3594
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3616
|
-
var
|
|
3595
|
+
var import_react27 = require("react");
|
|
3617
3596
|
var import_vuu_ui_controls6 = require("@vuu-ui/vuu-ui-controls");
|
|
3618
3597
|
var import_core3 = require("@salt-ds/core");
|
|
3619
3598
|
var import_vuu_utils25 = require("@vuu-ui/vuu-utils");
|
|
3620
3599
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3621
|
-
var CheckboxCell = (0,
|
|
3600
|
+
var CheckboxCell = (0, import_react27.memo)(
|
|
3622
3601
|
({ column, columnMap, onCommit = import_vuu_ui_controls6.WarnCommit, row }) => {
|
|
3623
3602
|
const dataIdx = columnMap[column.name];
|
|
3624
3603
|
const isChecked = !!row[dataIdx];
|
|
3625
|
-
const handleCommit = (0,
|
|
3604
|
+
const handleCommit = (0, import_react27.useCallback)(
|
|
3626
3605
|
(value) => async (evt) => {
|
|
3627
3606
|
const res = await onCommit(value);
|
|
3628
3607
|
if (res === true) {
|
|
@@ -3647,7 +3626,7 @@ var import_core4 = require("@salt-ds/core");
|
|
|
3647
3626
|
var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
|
|
3648
3627
|
var import_clsx10 = __toESM(require("clsx"));
|
|
3649
3628
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3650
|
-
var
|
|
3629
|
+
var classBase9 = "vuuTableInputCell";
|
|
3651
3630
|
var WarnCommit2 = () => {
|
|
3652
3631
|
console.warn(
|
|
3653
3632
|
"onCommit handler has not been provided to InputCell cell renderer"
|
|
@@ -3668,14 +3647,14 @@ var InputCell = ({
|
|
|
3668
3647
|
onCommit,
|
|
3669
3648
|
clientSideEditValidationCheck
|
|
3670
3649
|
});
|
|
3671
|
-
const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `${
|
|
3672
|
-
const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `${
|
|
3650
|
+
const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `${classBase9}-icon`, "data-icon": "error" }) : void 0;
|
|
3651
|
+
const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: `${classBase9}-icon`, "data-icon": "error" }) : void 0;
|
|
3673
3652
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
3674
3653
|
import_core4.Input,
|
|
3675
3654
|
{
|
|
3676
3655
|
...editProps,
|
|
3677
|
-
className: (0, import_clsx10.default)(
|
|
3678
|
-
[`${
|
|
3656
|
+
className: (0, import_clsx10.default)(classBase9, {
|
|
3657
|
+
[`${classBase9}-error`]: warningMessage !== void 0
|
|
3679
3658
|
}),
|
|
3680
3659
|
endAdornment,
|
|
3681
3660
|
startAdornment
|
|
@@ -3690,10 +3669,10 @@ var InputCell = ({
|
|
|
3690
3669
|
var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
|
|
3691
3670
|
var import_vuu_utils27 = require("@vuu-ui/vuu-utils");
|
|
3692
3671
|
var import_clsx11 = __toESM(require("clsx"));
|
|
3693
|
-
var
|
|
3672
|
+
var import_react28 = require("react");
|
|
3694
3673
|
var import_vuu_ui_controls9 = require("@vuu-ui/vuu-ui-controls");
|
|
3695
3674
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3696
|
-
var
|
|
3675
|
+
var classBase10 = "vuuTableToggleCell";
|
|
3697
3676
|
var getValueList = ({ name, type }) => {
|
|
3698
3677
|
if ((0, import_vuu_utils27.isTypeDescriptor)(type) && (0, import_vuu_utils27.isValueListRenderer)(type.renderer)) {
|
|
3699
3678
|
return type.renderer.values;
|
|
@@ -3703,7 +3682,7 @@ var getValueList = ({ name, type }) => {
|
|
|
3703
3682
|
);
|
|
3704
3683
|
}
|
|
3705
3684
|
};
|
|
3706
|
-
var ToggleCell = (0,
|
|
3685
|
+
var ToggleCell = (0, import_react28.memo)(
|
|
3707
3686
|
function ToggleCell2({
|
|
3708
3687
|
column,
|
|
3709
3688
|
columnMap,
|
|
@@ -3713,7 +3692,7 @@ var ToggleCell = (0, import_react29.memo)(
|
|
|
3713
3692
|
const values = getValueList(column);
|
|
3714
3693
|
const dataIdx = columnMap[column.name];
|
|
3715
3694
|
const value = row[dataIdx];
|
|
3716
|
-
const handleCommit = (0,
|
|
3695
|
+
const handleCommit = (0, import_react28.useCallback)(
|
|
3717
3696
|
(evt, value2) => {
|
|
3718
3697
|
return onCommit(value2).then((response) => {
|
|
3719
3698
|
if (response === true) {
|
|
@@ -3727,7 +3706,7 @@ var ToggleCell = (0, import_react29.memo)(
|
|
|
3727
3706
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3728
3707
|
import_vuu_ui_controls9.CycleStateButton,
|
|
3729
3708
|
{
|
|
3730
|
-
className: (0, import_clsx11.default)(
|
|
3709
|
+
className: (0, import_clsx11.default)(classBase10, `${classBase10}-${column.name}`),
|
|
3731
3710
|
onCommit: handleCommit,
|
|
3732
3711
|
value,
|
|
3733
3712
|
values,
|
|
@@ -3745,11 +3724,11 @@ var ToggleCell = (0, import_react29.memo)(
|
|
|
3745
3724
|
// src/useControlledTableNavigation.ts
|
|
3746
3725
|
var import_vuu_ui_controls10 = require("@vuu-ui/vuu-ui-controls");
|
|
3747
3726
|
var import_vuu_utils28 = require("@vuu-ui/vuu-utils");
|
|
3748
|
-
var
|
|
3727
|
+
var import_react29 = require("react");
|
|
3749
3728
|
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3750
|
-
const tableRef = (0,
|
|
3729
|
+
const tableRef = (0, import_react29.useRef)(null);
|
|
3751
3730
|
const [highlightedIndexRef, setHighlightedIndex] = (0, import_vuu_ui_controls10.useStateRef)(initialValue);
|
|
3752
|
-
const handleKeyDown = (0,
|
|
3731
|
+
const handleKeyDown = (0, import_react29.useCallback)(
|
|
3753
3732
|
(e) => {
|
|
3754
3733
|
var _a;
|
|
3755
3734
|
if (e.key === "ArrowDown") {
|
|
@@ -3768,7 +3747,7 @@ var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
|
3768
3747
|
},
|
|
3769
3748
|
[highlightedIndexRef, rowCount, setHighlightedIndex]
|
|
3770
3749
|
);
|
|
3771
|
-
const handleHighlight = (0,
|
|
3750
|
+
const handleHighlight = (0, import_react29.useCallback)(
|
|
3772
3751
|
(idx) => {
|
|
3773
3752
|
setHighlightedIndex(idx);
|
|
3774
3753
|
},
|