@vuu-ui/vuu-table 0.8.23-debug → 0.8.24-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 +267 -144
- package/cjs/index.js.map +4 -4
- package/esm/index.js +229 -100
- package/esm/index.js.map +4 -4
- package/index.css +31 -14
- package/index.css.map +2 -2
- package/package.json +9 -9
- package/types/Row.d.ts +6 -2
- package/types/Table.d.ts +9 -0
- package/types/useRowClassNameGenerators.d.ts +3 -0
- package/types/useRowHeight.d.ts +8 -0
- package/types/useTable.d.ts +1 -0
- package/types/useTableModel.d.ts +1 -1
- package/types/useTableScroll.d.ts +1 -1
package/esm/index.js
CHANGED
|
@@ -418,9 +418,9 @@ import { metadataKeys as metadataKeys6, useId } from "@vuu-ui/vuu-utils";
|
|
|
418
418
|
import { useForkRef } from "@salt-ds/core";
|
|
419
419
|
import cx9 from "clsx";
|
|
420
420
|
import {
|
|
421
|
-
forwardRef,
|
|
422
|
-
useRef as
|
|
423
|
-
useState as
|
|
421
|
+
forwardRef as forwardRef2,
|
|
422
|
+
useRef as useRef16,
|
|
423
|
+
useState as useState9
|
|
424
424
|
} from "react";
|
|
425
425
|
|
|
426
426
|
// src/Row.tsx
|
|
@@ -433,7 +433,11 @@ import {
|
|
|
433
433
|
RowSelected
|
|
434
434
|
} from "@vuu-ui/vuu-utils";
|
|
435
435
|
import cx7 from "clsx";
|
|
436
|
-
import {
|
|
436
|
+
import {
|
|
437
|
+
forwardRef,
|
|
438
|
+
memo,
|
|
439
|
+
useCallback as useCallback9
|
|
440
|
+
} from "react";
|
|
437
441
|
|
|
438
442
|
// src/table-cell/TableCell.tsx
|
|
439
443
|
import { isNumericColumn } from "@vuu-ui/vuu-utils";
|
|
@@ -537,9 +541,23 @@ var TableGroupCell = ({
|
|
|
537
541
|
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
538
542
|
var { IDX, IS_EXPANDED, SELECTED } = metadataKeys2;
|
|
539
543
|
var classBase6 = "vuuTableRow";
|
|
544
|
+
var RowProxy = forwardRef(
|
|
545
|
+
function RowProxy2({ height }, forwardedRef) {
|
|
546
|
+
return /* @__PURE__ */ jsx10(
|
|
547
|
+
"div",
|
|
548
|
+
{
|
|
549
|
+
"aria-hidden": true,
|
|
550
|
+
className: cx7(classBase6, `${classBase6}-proxy`),
|
|
551
|
+
ref: forwardedRef,
|
|
552
|
+
style: { height }
|
|
553
|
+
}
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
);
|
|
540
557
|
var Row = memo(
|
|
541
558
|
({
|
|
542
559
|
className: classNameProp,
|
|
560
|
+
classNameGenerator,
|
|
543
561
|
columnMap,
|
|
544
562
|
columns,
|
|
545
563
|
highlighted,
|
|
@@ -566,14 +584,19 @@ var Row = memo(
|
|
|
566
584
|
[onClick, row]
|
|
567
585
|
);
|
|
568
586
|
const { True, First, Last } = RowSelected;
|
|
569
|
-
const className = cx7(
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
587
|
+
const className = cx7(
|
|
588
|
+
classBase6,
|
|
589
|
+
classNameProp,
|
|
590
|
+
classNameGenerator == null ? void 0 : classNameGenerator(row, columnMap),
|
|
591
|
+
{
|
|
592
|
+
[`${classBase6}-even`]: zebraStripes && rowIndex % 2 === 0,
|
|
593
|
+
[`${classBase6}-expanded`]: isExpanded,
|
|
594
|
+
[`${classBase6}-highlighted`]: highlighted,
|
|
595
|
+
[`${classBase6}-selected`]: selectionStatus & True,
|
|
596
|
+
[`${classBase6}-selectedStart`]: selectionStatus & First,
|
|
597
|
+
[`${classBase6}-selectedEnd`]: selectionStatus & Last
|
|
598
|
+
}
|
|
599
|
+
);
|
|
577
600
|
const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
|
|
578
601
|
const handleGroupCellClick = useCallback9(
|
|
579
602
|
(evt, column) => {
|
|
@@ -791,7 +814,7 @@ import {
|
|
|
791
814
|
import {
|
|
792
815
|
useCallback as useCallback19,
|
|
793
816
|
useEffect as useEffect4,
|
|
794
|
-
useMemo as
|
|
817
|
+
useMemo as useMemo7,
|
|
795
818
|
useRef as useRef14,
|
|
796
819
|
useState as useState7
|
|
797
820
|
} from "react";
|
|
@@ -1336,7 +1359,6 @@ var useDataSource = ({
|
|
|
1336
1359
|
if (isMounted.current) {
|
|
1337
1360
|
forceUpdate({});
|
|
1338
1361
|
} else {
|
|
1339
|
-
console.log(`ignore update as we're not mounted`);
|
|
1340
1362
|
}
|
|
1341
1363
|
},
|
|
1342
1364
|
[dataWindow]
|
|
@@ -1899,11 +1921,11 @@ var columnReducer = (state, action) => {
|
|
|
1899
1921
|
}
|
|
1900
1922
|
};
|
|
1901
1923
|
var useTableModel = (tableConfigProp, dataSource) => {
|
|
1902
|
-
const [state,
|
|
1924
|
+
const [state, dispatchTableModelAction] = useReducer(columnReducer, { tableConfig: tableConfigProp, dataSource }, init);
|
|
1903
1925
|
const { columns, headings, tableConfig, ...tableAttributes } = state;
|
|
1904
1926
|
return {
|
|
1905
1927
|
columns,
|
|
1906
|
-
|
|
1928
|
+
dispatchTableModelAction,
|
|
1907
1929
|
headings,
|
|
1908
1930
|
tableAttributes,
|
|
1909
1931
|
tableConfig
|
|
@@ -2224,11 +2246,13 @@ var useTableScroll = ({
|
|
|
2224
2246
|
onHorizontalScroll,
|
|
2225
2247
|
onVerticalScroll,
|
|
2226
2248
|
onVerticalScrollInSitu,
|
|
2249
|
+
rowHeight,
|
|
2227
2250
|
scrollingApiRef,
|
|
2228
2251
|
setRange,
|
|
2229
2252
|
viewportMeasurements
|
|
2230
2253
|
}) => {
|
|
2231
2254
|
const firstRowRef = useRef11(0);
|
|
2255
|
+
const rowHeightRef = useRef11(rowHeight);
|
|
2232
2256
|
const contentContainerScrolledRef = useRef11(false);
|
|
2233
2257
|
const contentContainerPosRef = useRef11({
|
|
2234
2258
|
scrollTop: 0,
|
|
@@ -2510,10 +2534,19 @@ var useTableScroll = ({
|
|
|
2510
2534
|
[scrollHandles]
|
|
2511
2535
|
);
|
|
2512
2536
|
useEffect3(() => {
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2537
|
+
if (rowHeight !== rowHeightRef.current) {
|
|
2538
|
+
rowHeightRef.current = rowHeight;
|
|
2539
|
+
if (contentContainerPosRef.current.scrollTop > 0) {
|
|
2540
|
+
if (contentContainerRef.current) {
|
|
2541
|
+
contentContainerRef.current.scrollTop = 0;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
} else {
|
|
2545
|
+
const { current: from } = firstRowRef;
|
|
2546
|
+
const rowRange = { from, to: from + viewportRowCount };
|
|
2547
|
+
setRange(rowRange);
|
|
2548
|
+
}
|
|
2549
|
+
}, [rowHeight, setRange, viewportRowCount]);
|
|
2517
2550
|
return {
|
|
2518
2551
|
columnsWithinViewport: columnsWithinViewportRef.current,
|
|
2519
2552
|
/** Ref to be assigned to ScrollbarContainer */
|
|
@@ -2775,6 +2808,38 @@ var useTableAndColumnSettings = ({
|
|
|
2775
2808
|
};
|
|
2776
2809
|
};
|
|
2777
2810
|
|
|
2811
|
+
// src/useRowClassNameGenerators.ts
|
|
2812
|
+
import {
|
|
2813
|
+
getRowClassNameGenerator
|
|
2814
|
+
} from "@vuu-ui/vuu-utils";
|
|
2815
|
+
import { useMemo as useMemo6 } from "react";
|
|
2816
|
+
var createClassNameGenerator = (ids) => {
|
|
2817
|
+
const functions = [];
|
|
2818
|
+
ids == null ? void 0 : ids.forEach((id) => {
|
|
2819
|
+
const fn = getRowClassNameGenerator(id);
|
|
2820
|
+
if (fn) {
|
|
2821
|
+
functions.push(fn.fn);
|
|
2822
|
+
}
|
|
2823
|
+
});
|
|
2824
|
+
return (row, columnMap) => {
|
|
2825
|
+
const classNames = [];
|
|
2826
|
+
functions == null ? void 0 : functions.forEach((fn) => {
|
|
2827
|
+
const className = fn(row, columnMap);
|
|
2828
|
+
if (className) {
|
|
2829
|
+
classNames.push(className);
|
|
2830
|
+
}
|
|
2831
|
+
});
|
|
2832
|
+
return classNames.join(" ");
|
|
2833
|
+
};
|
|
2834
|
+
};
|
|
2835
|
+
var useRowClassNameGenerators = ({
|
|
2836
|
+
rowClassNameGenerators
|
|
2837
|
+
}) => {
|
|
2838
|
+
return useMemo6(() => {
|
|
2839
|
+
return createClassNameGenerator(rowClassNameGenerators);
|
|
2840
|
+
}, [rowClassNameGenerators]);
|
|
2841
|
+
};
|
|
2842
|
+
|
|
2778
2843
|
// src/useTable.ts
|
|
2779
2844
|
var stripInternalProperties = (tableConfig) => {
|
|
2780
2845
|
return tableConfig;
|
|
@@ -2819,8 +2884,9 @@ var useTable = ({
|
|
|
2819
2884
|
if (dataSource === void 0) {
|
|
2820
2885
|
throw Error("no data source provided to Vuu Table");
|
|
2821
2886
|
}
|
|
2887
|
+
const rowClassNameGenerator = useRowClassNameGenerators(config);
|
|
2822
2888
|
const useRowDragDrop = allowDragDrop ? useDragDrop2 : useNullDragDrop;
|
|
2823
|
-
const menuBuilder =
|
|
2889
|
+
const menuBuilder = useMemo7(
|
|
2824
2890
|
() => buildContextMenuDescriptors(dataSource),
|
|
2825
2891
|
[dataSource]
|
|
2826
2892
|
);
|
|
@@ -2829,37 +2895,37 @@ var useTable = ({
|
|
|
2829
2895
|
}, []);
|
|
2830
2896
|
const {
|
|
2831
2897
|
columns,
|
|
2832
|
-
|
|
2898
|
+
dispatchTableModelAction,
|
|
2833
2899
|
headings,
|
|
2834
2900
|
tableAttributes,
|
|
2835
2901
|
tableConfig
|
|
2836
2902
|
} = useTableModel(config, dataSource);
|
|
2837
2903
|
useLayoutEffectSkipFirst2(() => {
|
|
2838
|
-
|
|
2904
|
+
dispatchTableModelAction({
|
|
2839
2905
|
type: "init",
|
|
2840
2906
|
tableConfig: config,
|
|
2841
2907
|
dataSource
|
|
2842
2908
|
});
|
|
2843
|
-
}, [config, dataSource,
|
|
2909
|
+
}, [config, dataSource, dispatchTableModelAction]);
|
|
2844
2910
|
const applyTableConfigChange = useCallback19(
|
|
2845
2911
|
(config2) => {
|
|
2846
|
-
|
|
2912
|
+
dispatchTableModelAction({
|
|
2847
2913
|
type: "init",
|
|
2848
2914
|
tableConfig: config2,
|
|
2849
2915
|
dataSource
|
|
2850
2916
|
});
|
|
2851
2917
|
onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(config2));
|
|
2852
2918
|
},
|
|
2853
|
-
[dataSource,
|
|
2919
|
+
[dataSource, dispatchTableModelAction, onConfigChange]
|
|
2854
2920
|
);
|
|
2855
|
-
const columnMap =
|
|
2921
|
+
const columnMap = useMemo7(
|
|
2856
2922
|
() => buildColumnMap2(dataSource.columns),
|
|
2857
2923
|
[dataSource.columns]
|
|
2858
2924
|
);
|
|
2859
2925
|
const onSubscribed = useCallback19(
|
|
2860
2926
|
({ tableSchema }) => {
|
|
2861
2927
|
if (tableSchema) {
|
|
2862
|
-
|
|
2928
|
+
dispatchTableModelAction({
|
|
2863
2929
|
type: "setTableSchema",
|
|
2864
2930
|
tableSchema
|
|
2865
2931
|
});
|
|
@@ -2867,7 +2933,7 @@ var useTable = ({
|
|
|
2867
2933
|
console.log("subscription message with no schema");
|
|
2868
2934
|
}
|
|
2869
2935
|
},
|
|
2870
|
-
[
|
|
2936
|
+
[dispatchTableModelAction]
|
|
2871
2937
|
);
|
|
2872
2938
|
const {
|
|
2873
2939
|
getRowAtPosition,
|
|
@@ -2908,14 +2974,14 @@ var useTable = ({
|
|
|
2908
2974
|
});
|
|
2909
2975
|
const handleConfigEditedInSettingsPanel = useCallback19(
|
|
2910
2976
|
(tableConfig2) => {
|
|
2911
|
-
|
|
2977
|
+
dispatchTableModelAction({
|
|
2912
2978
|
type: "init",
|
|
2913
2979
|
tableConfig: tableConfig2,
|
|
2914
2980
|
dataSource
|
|
2915
2981
|
});
|
|
2916
2982
|
onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(tableConfig2));
|
|
2917
2983
|
},
|
|
2918
|
-
[dataSource,
|
|
2984
|
+
[dataSource, dispatchTableModelAction, onConfigChange]
|
|
2919
2985
|
);
|
|
2920
2986
|
const handleDataSourceConfigChanged = useCallback19(
|
|
2921
2987
|
(dataSourceConfig) => {
|
|
@@ -2927,14 +2993,21 @@ var useTable = ({
|
|
|
2927
2993
|
[dataSource]
|
|
2928
2994
|
);
|
|
2929
2995
|
useEffect4(() => {
|
|
2930
|
-
dataSource.on("config", (config2, confirmed) => {
|
|
2931
|
-
|
|
2996
|
+
dataSource.on("config", (config2, confirmed, changes) => {
|
|
2997
|
+
const scrollSensitiveChanges = (changes == null ? void 0 : changes.filterChanged) || (changes == null ? void 0 : changes.groupByChanged);
|
|
2998
|
+
if (scrollSensitiveChanges && dataSource.range.from > 0) {
|
|
2999
|
+
requestScroll({
|
|
3000
|
+
type: "scroll-end",
|
|
3001
|
+
direction: "home"
|
|
3002
|
+
});
|
|
3003
|
+
}
|
|
3004
|
+
dispatchTableModelAction({
|
|
2932
3005
|
type: "tableConfig",
|
|
2933
3006
|
...config2,
|
|
2934
3007
|
confirmed
|
|
2935
3008
|
});
|
|
2936
3009
|
});
|
|
2937
|
-
}, [dataSource,
|
|
3010
|
+
}, [dataSource, dispatchTableModelAction, requestScroll]);
|
|
2938
3011
|
const handleCreateCalculatedColumn = useCallback19(
|
|
2939
3012
|
(column) => {
|
|
2940
3013
|
dataSource.columns = dataSource.columns.concat(column.name);
|
|
@@ -2992,12 +3065,12 @@ var useTable = ({
|
|
|
2992
3065
|
case "pinColumn":
|
|
2993
3066
|
return pinColumn3(action);
|
|
2994
3067
|
default:
|
|
2995
|
-
|
|
3068
|
+
dispatchTableModelAction(action);
|
|
2996
3069
|
}
|
|
2997
3070
|
}
|
|
2998
3071
|
},
|
|
2999
3072
|
[
|
|
3000
|
-
|
|
3073
|
+
dispatchTableModelAction,
|
|
3001
3074
|
hideColumns2,
|
|
3002
3075
|
pinColumn3,
|
|
3003
3076
|
showColumnSettingsPanel,
|
|
@@ -3034,7 +3107,7 @@ var useTable = ({
|
|
|
3034
3107
|
} else if (phase === "end") {
|
|
3035
3108
|
resizeCells.current = void 0;
|
|
3036
3109
|
if (isValidNumber(width)) {
|
|
3037
|
-
|
|
3110
|
+
dispatchTableModelAction({
|
|
3038
3111
|
type: "resizeColumn",
|
|
3039
3112
|
phase,
|
|
3040
3113
|
column,
|
|
@@ -3057,7 +3130,7 @@ var useTable = ({
|
|
|
3057
3130
|
`.vuuTableCell${byColIndex},.vuuTableHeaderCell${byColIndex}`
|
|
3058
3131
|
)) != null ? _c : []
|
|
3059
3132
|
);
|
|
3060
|
-
|
|
3133
|
+
dispatchTableModelAction({
|
|
3061
3134
|
type: "resizeColumn",
|
|
3062
3135
|
phase,
|
|
3063
3136
|
column,
|
|
@@ -3070,7 +3143,13 @@ var useTable = ({
|
|
|
3070
3143
|
);
|
|
3071
3144
|
}
|
|
3072
3145
|
},
|
|
3073
|
-
[
|
|
3146
|
+
[
|
|
3147
|
+
columns,
|
|
3148
|
+
dispatchTableModelAction,
|
|
3149
|
+
onConfigChange,
|
|
3150
|
+
tableConfig,
|
|
3151
|
+
containerRef
|
|
3152
|
+
]
|
|
3074
3153
|
);
|
|
3075
3154
|
const onToggleGroup = useCallback19(
|
|
3076
3155
|
(row, column) => {
|
|
@@ -3083,7 +3162,7 @@ var useTable = ({
|
|
|
3083
3162
|
const idx = columns.indexOf(column);
|
|
3084
3163
|
const rows = (_a = dataSource.getRowsAtDepth) == null ? void 0 : _a.call(dataSource, idx + 1);
|
|
3085
3164
|
if (rows && !rows.some((row2) => row2[IS_EXPANDED2] || row2[IS_LEAF2])) {
|
|
3086
|
-
|
|
3165
|
+
dispatchTableModelAction({
|
|
3087
3166
|
type: "hideColumns",
|
|
3088
3167
|
columns: columns.slice(idx + 2)
|
|
3089
3168
|
});
|
|
@@ -3099,7 +3178,7 @@ var useTable = ({
|
|
|
3099
3178
|
columnsToShow.push(columns[idx + 1]);
|
|
3100
3179
|
}
|
|
3101
3180
|
if (columnsToShow.some((col) => col.hidden)) {
|
|
3102
|
-
|
|
3181
|
+
dispatchTableModelAction({
|
|
3103
3182
|
type: "showColumns",
|
|
3104
3183
|
columns: columnsToShow
|
|
3105
3184
|
});
|
|
@@ -3107,7 +3186,7 @@ var useTable = ({
|
|
|
3107
3186
|
}
|
|
3108
3187
|
}
|
|
3109
3188
|
},
|
|
3110
|
-
[columnMap, columns, dataSource,
|
|
3189
|
+
[columnMap, columns, dataSource, dispatchTableModelAction]
|
|
3111
3190
|
);
|
|
3112
3191
|
const {
|
|
3113
3192
|
highlightedIndexRef,
|
|
@@ -3211,14 +3290,14 @@ var useTable = ({
|
|
|
3211
3290
|
...tableConfig,
|
|
3212
3291
|
columns: columns2
|
|
3213
3292
|
};
|
|
3214
|
-
|
|
3293
|
+
dispatchTableModelAction({
|
|
3215
3294
|
type: "init",
|
|
3216
3295
|
tableConfig: newTableConfig,
|
|
3217
3296
|
dataSource
|
|
3218
3297
|
});
|
|
3219
3298
|
onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(newTableConfig));
|
|
3220
3299
|
},
|
|
3221
|
-
[dataSource,
|
|
3300
|
+
[dataSource, dispatchTableModelAction, onConfigChange, tableConfig]
|
|
3222
3301
|
);
|
|
3223
3302
|
const handleDropRow = useCallback19(
|
|
3224
3303
|
(dragDropState) => {
|
|
@@ -3256,6 +3335,7 @@ var useTable = ({
|
|
|
3256
3335
|
return {
|
|
3257
3336
|
...containerProps,
|
|
3258
3337
|
"aria-rowcount": dataSource.size,
|
|
3338
|
+
rowClassNameGenerator,
|
|
3259
3339
|
draggableRow,
|
|
3260
3340
|
onBlur: editingBlur,
|
|
3261
3341
|
onDoubleClick: editingDoubleClick,
|
|
@@ -3287,6 +3367,44 @@ var useTable = ({
|
|
|
3287
3367
|
};
|
|
3288
3368
|
};
|
|
3289
3369
|
|
|
3370
|
+
// src/useRowHeight.ts
|
|
3371
|
+
import { isValidNumber as isValidNumber2 } from "@vuu-ui/vuu-utils";
|
|
3372
|
+
import { useCallback as useCallback20, useMemo as useMemo8, useRef as useRef15, useState as useState8 } from "react";
|
|
3373
|
+
var useRowHeight = ({
|
|
3374
|
+
rowHeight: rowHeightProp = 0
|
|
3375
|
+
}) => {
|
|
3376
|
+
const [rowHeight, setRowHeight] = useState8(rowHeightProp);
|
|
3377
|
+
const heightRef = useRef15(rowHeight);
|
|
3378
|
+
const resizeObserver = useMemo8(() => {
|
|
3379
|
+
return new ResizeObserver((entries) => {
|
|
3380
|
+
for (const entry of entries) {
|
|
3381
|
+
const { height: measuredHeight } = entry.contentRect;
|
|
3382
|
+
const newHeight = Math.round(measuredHeight);
|
|
3383
|
+
if (isValidNumber2(newHeight) && heightRef.current !== newHeight) {
|
|
3384
|
+
heightRef.current = newHeight;
|
|
3385
|
+
setRowHeight(newHeight);
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
});
|
|
3389
|
+
}, []);
|
|
3390
|
+
const rowRef = useCallback20(
|
|
3391
|
+
(el) => {
|
|
3392
|
+
if (el) {
|
|
3393
|
+
if (rowHeightProp === 0) {
|
|
3394
|
+
const { height } = el.getBoundingClientRect();
|
|
3395
|
+
console.log(`measured rowHeight = ${height}`);
|
|
3396
|
+
resizeObserver.observe(el);
|
|
3397
|
+
setRowHeight(height);
|
|
3398
|
+
}
|
|
3399
|
+
} else {
|
|
3400
|
+
resizeObserver.disconnect();
|
|
3401
|
+
}
|
|
3402
|
+
},
|
|
3403
|
+
[resizeObserver, rowHeightProp]
|
|
3404
|
+
);
|
|
3405
|
+
return { rowHeight, rowRef };
|
|
3406
|
+
};
|
|
3407
|
+
|
|
3290
3408
|
// src/Table.tsx
|
|
3291
3409
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3292
3410
|
var classBase7 = "vuuTable";
|
|
@@ -3312,11 +3430,11 @@ var TableCore = ({
|
|
|
3312
3430
|
onSelect,
|
|
3313
3431
|
onSelectionChange,
|
|
3314
3432
|
renderBufferSize = 5,
|
|
3315
|
-
rowHeight
|
|
3433
|
+
rowHeight,
|
|
3316
3434
|
scrollingApiRef,
|
|
3317
3435
|
selectionModel = "extended",
|
|
3318
3436
|
showColumnHeaders = true,
|
|
3319
|
-
headerHeight = showColumnHeaders ? 25 : 0,
|
|
3437
|
+
headerHeight = showColumnHeaders ? rowHeight * 1.25 : 0,
|
|
3320
3438
|
size
|
|
3321
3439
|
}) => {
|
|
3322
3440
|
const id = useId(idProp);
|
|
@@ -3329,6 +3447,7 @@ var TableCore = ({
|
|
|
3329
3447
|
handleContextMenuAction,
|
|
3330
3448
|
headings,
|
|
3331
3449
|
highlightedIndex,
|
|
3450
|
+
menuBuilder,
|
|
3332
3451
|
onDataEdited,
|
|
3333
3452
|
onMoveColumn,
|
|
3334
3453
|
onMoveGroupColumn,
|
|
@@ -3337,7 +3456,7 @@ var TableCore = ({
|
|
|
3337
3456
|
onRowClick,
|
|
3338
3457
|
onSortColumn,
|
|
3339
3458
|
onToggleGroup,
|
|
3340
|
-
|
|
3459
|
+
rowClassNameGenerator,
|
|
3341
3460
|
scrollProps,
|
|
3342
3461
|
tableAttributes,
|
|
3343
3462
|
tableConfig,
|
|
@@ -3381,7 +3500,7 @@ var TableCore = ({
|
|
|
3381
3500
|
"--pinned-width-left": `${viewportMeasurements.pinnedWidthLeft}px`,
|
|
3382
3501
|
"--pinned-width-right": `${viewportMeasurements.pinnedWidthRight}px`,
|
|
3383
3502
|
"--header-height": `${headerHeight}px`,
|
|
3384
|
-
"--row-height": `${rowHeight}px`,
|
|
3503
|
+
"--row-height-prop": `${rowHeight}px`,
|
|
3385
3504
|
"--total-header-height": `${viewportMeasurements.totalHeaderHeight}px`,
|
|
3386
3505
|
"--vertical-scrollbar-width": `${viewportMeasurements.verticalScrollbarWidth}px`,
|
|
3387
3506
|
"--viewport-body-height": `${viewportMeasurements.viewportBodyHeight}px`
|
|
@@ -3434,6 +3553,7 @@ var TableCore = ({
|
|
|
3434
3553
|
Row2,
|
|
3435
3554
|
{
|
|
3436
3555
|
"aria-rowindex": data2[0] + 1,
|
|
3556
|
+
classNameGenerator: rowClassNameGenerator,
|
|
3437
3557
|
columnMap,
|
|
3438
3558
|
columns: scrollProps.columnsWithinViewport,
|
|
3439
3559
|
highlighted: highlightedIndex === data2[IDX3],
|
|
@@ -3457,7 +3577,7 @@ var TableCore = ({
|
|
|
3457
3577
|
}
|
|
3458
3578
|
);
|
|
3459
3579
|
};
|
|
3460
|
-
var Table =
|
|
3580
|
+
var Table = forwardRef2(function TableNext({
|
|
3461
3581
|
Row: Row2,
|
|
3462
3582
|
allowDragDrop,
|
|
3463
3583
|
availableColumns,
|
|
@@ -3478,7 +3598,7 @@ var Table = forwardRef(function TableNext({
|
|
|
3478
3598
|
onSelect,
|
|
3479
3599
|
onSelectionChange,
|
|
3480
3600
|
renderBufferSize,
|
|
3481
|
-
rowHeight,
|
|
3601
|
+
rowHeight: rowHeightProp,
|
|
3482
3602
|
scrollingApiRef,
|
|
3483
3603
|
selectionModel,
|
|
3484
3604
|
showColumnHeaders,
|
|
@@ -3486,8 +3606,9 @@ var Table = forwardRef(function TableNext({
|
|
|
3486
3606
|
style: styleProp,
|
|
3487
3607
|
...htmlAttributes
|
|
3488
3608
|
}, forwardedRef) {
|
|
3489
|
-
const containerRef =
|
|
3490
|
-
const [size, setSize] =
|
|
3609
|
+
const containerRef = useRef16(null);
|
|
3610
|
+
const [size, setSize] = useState9();
|
|
3611
|
+
const { rowHeight, rowRef } = useRowHeight({ rowHeight: rowHeightProp });
|
|
3491
3612
|
if (config === void 0) {
|
|
3492
3613
|
throw Error(
|
|
3493
3614
|
"vuu Table requires config prop. Minimum config is list of Column Descriptors"
|
|
@@ -3496,7 +3617,7 @@ var Table = forwardRef(function TableNext({
|
|
|
3496
3617
|
if (dataSource === void 0) {
|
|
3497
3618
|
throw Error("vuu Table requires dataSource prop");
|
|
3498
3619
|
}
|
|
3499
|
-
return /* @__PURE__ */
|
|
3620
|
+
return /* @__PURE__ */ jsxs9(
|
|
3500
3621
|
MeasuredContainer,
|
|
3501
3622
|
{
|
|
3502
3623
|
...htmlAttributes,
|
|
@@ -3504,47 +3625,50 @@ var Table = forwardRef(function TableNext({
|
|
|
3504
3625
|
id,
|
|
3505
3626
|
onResize: setSize,
|
|
3506
3627
|
ref: useForkRef(containerRef, forwardedRef),
|
|
3507
|
-
children:
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3628
|
+
children: [
|
|
3629
|
+
/* @__PURE__ */ jsx12(RowProxy, { ref: rowRef, height: rowHeightProp }),
|
|
3630
|
+
size && rowHeight ? /* @__PURE__ */ jsx12(
|
|
3631
|
+
TableCore,
|
|
3632
|
+
{
|
|
3633
|
+
Row: Row2,
|
|
3634
|
+
allowDragDrop,
|
|
3635
|
+
availableColumns,
|
|
3636
|
+
config,
|
|
3637
|
+
containerRef,
|
|
3638
|
+
dataSource,
|
|
3639
|
+
disableFocus,
|
|
3640
|
+
headerHeight,
|
|
3641
|
+
highlightedIndex,
|
|
3642
|
+
id,
|
|
3643
|
+
navigationStyle,
|
|
3644
|
+
onAvailableColumnsChange,
|
|
3645
|
+
onConfigChange,
|
|
3646
|
+
onDragStart,
|
|
3647
|
+
onDrop,
|
|
3648
|
+
onFeatureInvocation,
|
|
3649
|
+
onHighlight,
|
|
3650
|
+
onRowClick,
|
|
3651
|
+
onSelect,
|
|
3652
|
+
onSelectionChange,
|
|
3653
|
+
renderBufferSize,
|
|
3654
|
+
rowHeight,
|
|
3655
|
+
scrollingApiRef,
|
|
3656
|
+
selectionModel,
|
|
3657
|
+
showColumnHeaders,
|
|
3658
|
+
size
|
|
3659
|
+
}
|
|
3660
|
+
) : null
|
|
3661
|
+
]
|
|
3538
3662
|
}
|
|
3539
3663
|
);
|
|
3540
3664
|
});
|
|
3541
3665
|
|
|
3542
3666
|
// src/cell-renderers/checkbox-cell/CheckboxCell.tsx
|
|
3543
|
-
import { memo as memo3, useCallback as
|
|
3667
|
+
import { memo as memo3, useCallback as useCallback21 } from "react";
|
|
3544
3668
|
import { CheckboxIcon, WarnCommit } from "@vuu-ui/vuu-ui-controls";
|
|
3545
3669
|
import { Checkbox } from "@salt-ds/core";
|
|
3546
3670
|
import {
|
|
3547
|
-
|
|
3671
|
+
dataColumnAndKeyUnchanged,
|
|
3548
3672
|
dispatchCustomEvent,
|
|
3549
3673
|
registerComponent
|
|
3550
3674
|
} from "@vuu-ui/vuu-utils";
|
|
@@ -3552,8 +3676,8 @@ import { jsx as jsx13 } from "react/jsx-runtime";
|
|
|
3552
3676
|
var CheckboxCell = memo3(
|
|
3553
3677
|
({ column, columnMap, onCommit = WarnCommit, row }) => {
|
|
3554
3678
|
const dataIdx = columnMap[column.name];
|
|
3555
|
-
const isChecked = row[dataIdx];
|
|
3556
|
-
const handleCommit =
|
|
3679
|
+
const isChecked = !!row[dataIdx];
|
|
3680
|
+
const handleCommit = useCallback21(
|
|
3557
3681
|
(value) => async (evt) => {
|
|
3558
3682
|
const res = await onCommit(value);
|
|
3559
3683
|
if (res === true) {
|
|
@@ -3565,7 +3689,7 @@ var CheckboxCell = memo3(
|
|
|
3565
3689
|
);
|
|
3566
3690
|
return column.editable ? /* @__PURE__ */ jsx13(Checkbox, { checked: isChecked, onClick: handleCommit(!isChecked) }) : /* @__PURE__ */ jsx13(CheckboxIcon, { checked: isChecked, disabled: true });
|
|
3567
3691
|
},
|
|
3568
|
-
|
|
3692
|
+
dataColumnAndKeyUnchanged
|
|
3569
3693
|
);
|
|
3570
3694
|
CheckboxCell.displayName = "CheckboxCell";
|
|
3571
3695
|
registerComponent("checkbox-cell", CheckboxCell, "cell-renderer", {
|
|
@@ -3592,9 +3716,10 @@ var InputCell = ({
|
|
|
3592
3716
|
row
|
|
3593
3717
|
}) => {
|
|
3594
3718
|
const dataIdx = columnMap[column.name];
|
|
3719
|
+
const dataValue = row[dataIdx];
|
|
3595
3720
|
const { align = "left", clientSideEditValidationCheck } = column;
|
|
3596
3721
|
const { warningMessage, ...editProps } = useEditableText({
|
|
3597
|
-
initialValue:
|
|
3722
|
+
initialValue: dataValue,
|
|
3598
3723
|
onCommit,
|
|
3599
3724
|
clientSideEditValidationCheck
|
|
3600
3725
|
});
|
|
@@ -3612,19 +3737,21 @@ var InputCell = ({
|
|
|
3612
3737
|
}
|
|
3613
3738
|
);
|
|
3614
3739
|
};
|
|
3615
|
-
registerComponent2("input-cell", InputCell, "cell-renderer", {
|
|
3740
|
+
registerComponent2("input-cell", InputCell, "cell-renderer", {
|
|
3741
|
+
userCanAssign: false
|
|
3742
|
+
});
|
|
3616
3743
|
|
|
3617
3744
|
// src/cell-renderers/toggle-cell/ToggleCell.tsx
|
|
3618
3745
|
import { WarnCommit as WarnCommit3 } from "@vuu-ui/vuu-ui-controls";
|
|
3619
3746
|
import {
|
|
3620
|
-
|
|
3747
|
+
dataColumnAndKeyUnchanged as dataColumnAndKeyUnchanged2,
|
|
3621
3748
|
dispatchCustomEvent as dispatchCustomEvent2,
|
|
3622
3749
|
isTypeDescriptor,
|
|
3623
3750
|
isValueListRenderer,
|
|
3624
3751
|
registerComponent as registerComponent3
|
|
3625
3752
|
} from "@vuu-ui/vuu-utils";
|
|
3626
3753
|
import cx11 from "clsx";
|
|
3627
|
-
import { memo as memo4, useCallback as
|
|
3754
|
+
import { memo as memo4, useCallback as useCallback22 } from "react";
|
|
3628
3755
|
import { CycleStateButton } from "@vuu-ui/vuu-ui-controls";
|
|
3629
3756
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
3630
3757
|
var classBase9 = "vuuTableToggleCell";
|
|
@@ -3647,7 +3774,7 @@ var ToggleCell = memo4(
|
|
|
3647
3774
|
const values = getValueList(column);
|
|
3648
3775
|
const dataIdx = columnMap[column.name];
|
|
3649
3776
|
const value = row[dataIdx];
|
|
3650
|
-
const handleCommit =
|
|
3777
|
+
const handleCommit = useCallback22(
|
|
3651
3778
|
(evt, value2) => {
|
|
3652
3779
|
return onCommit(value2).then((response) => {
|
|
3653
3780
|
if (response === true) {
|
|
@@ -3670,18 +3797,20 @@ var ToggleCell = memo4(
|
|
|
3670
3797
|
}
|
|
3671
3798
|
);
|
|
3672
3799
|
},
|
|
3673
|
-
|
|
3800
|
+
dataColumnAndKeyUnchanged2
|
|
3674
3801
|
);
|
|
3675
|
-
registerComponent3("toggle-cell", ToggleCell, "cell-renderer", {
|
|
3802
|
+
registerComponent3("toggle-cell", ToggleCell, "cell-renderer", {
|
|
3803
|
+
userCanAssign: false
|
|
3804
|
+
});
|
|
3676
3805
|
|
|
3677
3806
|
// src/useControlledTableNavigation.ts
|
|
3678
3807
|
import { useStateRef } from "@vuu-ui/vuu-ui-controls";
|
|
3679
3808
|
import { dispatchMouseEvent as dispatchMouseEvent2 } from "@vuu-ui/vuu-utils";
|
|
3680
|
-
import { useCallback as
|
|
3809
|
+
import { useCallback as useCallback23, useRef as useRef17 } from "react";
|
|
3681
3810
|
var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
3682
|
-
const tableRef =
|
|
3811
|
+
const tableRef = useRef17(null);
|
|
3683
3812
|
const [highlightedIndexRef, setHighlightedIndex] = useStateRef(initialValue);
|
|
3684
|
-
const handleKeyDown =
|
|
3813
|
+
const handleKeyDown = useCallback23(
|
|
3685
3814
|
(e) => {
|
|
3686
3815
|
var _a;
|
|
3687
3816
|
if (e.key === "ArrowDown") {
|
|
@@ -3700,7 +3829,7 @@ var useControlledTableNavigation = (initialValue, rowCount) => {
|
|
|
3700
3829
|
},
|
|
3701
3830
|
[highlightedIndexRef, rowCount, setHighlightedIndex]
|
|
3702
3831
|
);
|
|
3703
|
-
const handleHighlight =
|
|
3832
|
+
const handleHighlight = useCallback23(
|
|
3704
3833
|
(idx) => {
|
|
3705
3834
|
setHighlightedIndex(idx);
|
|
3706
3835
|
},
|