@vuu-ui/vuu-table-extras 0.8.10-debug → 0.8.11-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 +2394 -72
- package/cjs/index.js.map +4 -4
- package/esm/index.js +2378 -56
- package/esm/index.js.map +4 -4
- package/index.css +0 -8
- package/index.css.map +2 -2
- package/package.json +11 -11
- package/types/column-expression-panel/useColumnExpression.d.ts +1 -1
- package/types/column-formatting-settings/ColumnFormattingPanel.d.ts +3 -3
- package/types/column-formatting-settings/NumericFormattingSettings.d.ts +1 -1
- package/types/column-list/ColumnList.d.ts +1 -1
- package/types/column-settings/useColumnSettings.d.ts +3 -3
package/cjs/index.js
CHANGED
|
@@ -2740,7 +2740,7 @@ var DataSourceStats = ({
|
|
|
2740
2740
|
};
|
|
2741
2741
|
|
|
2742
2742
|
// src/table-settings/TableSettingsPanel.tsx
|
|
2743
|
-
var
|
|
2743
|
+
var import_core9 = require("@salt-ds/core");
|
|
2744
2744
|
|
|
2745
2745
|
// src/table-settings/useTableSettings.ts
|
|
2746
2746
|
var import_vuu_layout4 = require("@vuu-ui/vuu-layout");
|
|
@@ -2751,11 +2751,312 @@ var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
|
2751
2751
|
|
|
2752
2752
|
// ../vuu-table/src/table/context-menu/buildContextMenuDescriptors.ts
|
|
2753
2753
|
var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
|
|
2754
|
+
var buildContextMenuDescriptors = (dataSource) => (location, options) => {
|
|
2755
|
+
const descriptors = [];
|
|
2756
|
+
if (dataSource === void 0) {
|
|
2757
|
+
return descriptors;
|
|
2758
|
+
}
|
|
2759
|
+
if (location === "header" || location === "column-menu") {
|
|
2760
|
+
descriptors.push(
|
|
2761
|
+
...buildSortMenuItems(options, dataSource)
|
|
2762
|
+
);
|
|
2763
|
+
descriptors.push(
|
|
2764
|
+
...buildGroupMenuItems(options, dataSource)
|
|
2765
|
+
);
|
|
2766
|
+
descriptors.push(
|
|
2767
|
+
...buildAggregationMenuItems(options, dataSource)
|
|
2768
|
+
);
|
|
2769
|
+
descriptors.push(...buildColumnDisplayMenuItems(options));
|
|
2770
|
+
descriptors.push({
|
|
2771
|
+
action: "column-settings",
|
|
2772
|
+
icon: "cog",
|
|
2773
|
+
label: `Column Settings`,
|
|
2774
|
+
options
|
|
2775
|
+
});
|
|
2776
|
+
descriptors.push({
|
|
2777
|
+
action: "table-settings",
|
|
2778
|
+
icon: "cog",
|
|
2779
|
+
label: `DataGrid Settings`,
|
|
2780
|
+
options
|
|
2781
|
+
});
|
|
2782
|
+
} else if (location === "filter") {
|
|
2783
|
+
const { column, filter } = options;
|
|
2784
|
+
const colIsOnlyFilter = (filter == null ? void 0 : filter.column) === (column == null ? void 0 : column.name);
|
|
2785
|
+
descriptors.push({
|
|
2786
|
+
label: "Edit filter",
|
|
2787
|
+
action: "filter-edit",
|
|
2788
|
+
options
|
|
2789
|
+
});
|
|
2790
|
+
descriptors.push({
|
|
2791
|
+
label: "Remove filter",
|
|
2792
|
+
action: "filter-remove-column",
|
|
2793
|
+
options
|
|
2794
|
+
});
|
|
2795
|
+
if (column && !colIsOnlyFilter) {
|
|
2796
|
+
descriptors.push({
|
|
2797
|
+
label: `Remove all filters`,
|
|
2798
|
+
action: "remove-filters",
|
|
2799
|
+
options
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
return descriptors;
|
|
2804
|
+
};
|
|
2805
|
+
function buildSortMenuItems(options, { sort: { sortDefs } }) {
|
|
2806
|
+
const { column } = options;
|
|
2807
|
+
const menuItems = [];
|
|
2808
|
+
if (column === void 0) {
|
|
2809
|
+
return menuItems;
|
|
2810
|
+
}
|
|
2811
|
+
const hasSort = sortDefs.length > 0;
|
|
2812
|
+
if (column.sorted === "A") {
|
|
2813
|
+
menuItems.push({
|
|
2814
|
+
label: "Reverse Sort (DSC)",
|
|
2815
|
+
action: "sort-dsc",
|
|
2816
|
+
options
|
|
2817
|
+
});
|
|
2818
|
+
} else if (column.sorted === "D") {
|
|
2819
|
+
menuItems.push({
|
|
2820
|
+
label: "Reverse Sort (ASC)",
|
|
2821
|
+
action: "sort-asc",
|
|
2822
|
+
options
|
|
2823
|
+
});
|
|
2824
|
+
} else if (typeof column.sorted === "number") {
|
|
2825
|
+
if (column.sorted > 0) {
|
|
2826
|
+
menuItems.push({
|
|
2827
|
+
label: "Reverse Sort (DSC)",
|
|
2828
|
+
action: "sort-add-dsc",
|
|
2829
|
+
options
|
|
2830
|
+
});
|
|
2831
|
+
} else {
|
|
2832
|
+
menuItems.push({
|
|
2833
|
+
label: "Reverse Sort (ASC)",
|
|
2834
|
+
action: "sort-add-asc",
|
|
2835
|
+
options
|
|
2836
|
+
});
|
|
2837
|
+
}
|
|
2838
|
+
if (hasSort && Math.abs(column.sorted) < sortDefs.length) {
|
|
2839
|
+
menuItems.push({
|
|
2840
|
+
label: "Remove from sort",
|
|
2841
|
+
action: "sort-remove",
|
|
2842
|
+
options
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
menuItems.push({
|
|
2846
|
+
label: "New Sort",
|
|
2847
|
+
children: [
|
|
2848
|
+
{ label: "Ascending", action: "sort-asc", options },
|
|
2849
|
+
{ label: "Descending", action: "sort-dsc", options }
|
|
2850
|
+
]
|
|
2851
|
+
});
|
|
2852
|
+
} else if (hasSort) {
|
|
2853
|
+
menuItems.push({
|
|
2854
|
+
label: "Add to sort",
|
|
2855
|
+
children: [
|
|
2856
|
+
{ label: "Ascending", action: "sort-add-asc", options },
|
|
2857
|
+
{ label: "Descending", action: "sort-add-dsc", options }
|
|
2858
|
+
]
|
|
2859
|
+
});
|
|
2860
|
+
menuItems.push({
|
|
2861
|
+
label: "New Sort",
|
|
2862
|
+
children: [
|
|
2863
|
+
{ label: "Ascending", action: "sort-asc", options },
|
|
2864
|
+
{ label: "Descending", action: "sort-dsc", options }
|
|
2865
|
+
]
|
|
2866
|
+
});
|
|
2867
|
+
} else {
|
|
2868
|
+
menuItems.push({
|
|
2869
|
+
label: "Sort",
|
|
2870
|
+
children: [
|
|
2871
|
+
{ label: "Ascending", action: "sort-asc", options },
|
|
2872
|
+
{ label: "Descending", action: "sort-dsc", options }
|
|
2873
|
+
]
|
|
2874
|
+
});
|
|
2875
|
+
}
|
|
2876
|
+
return menuItems;
|
|
2877
|
+
}
|
|
2878
|
+
function buildAggregationMenuItems(options, dataSource) {
|
|
2879
|
+
const { column } = options;
|
|
2880
|
+
if (column === void 0 || dataSource.groupBy.length === 0) {
|
|
2881
|
+
return [];
|
|
2882
|
+
}
|
|
2883
|
+
const { name: name2, label = name2 } = column;
|
|
2884
|
+
return [
|
|
2885
|
+
{
|
|
2886
|
+
label: `Aggregate ${label}`,
|
|
2887
|
+
children: [
|
|
2888
|
+
{ label: "Count", action: "agg-count", options },
|
|
2889
|
+
{ label: "Distinct", action: "agg-distinct", options }
|
|
2890
|
+
].concat(
|
|
2891
|
+
(0, import_vuu_utils16.isNumericColumn)(column) ? [
|
|
2892
|
+
{ label: "Sum", action: "agg-sum", options },
|
|
2893
|
+
{ label: "Avg", action: "agg-avg", options },
|
|
2894
|
+
{ label: "High", action: "agg-high", options },
|
|
2895
|
+
{ label: "Low", action: "agg-low", options }
|
|
2896
|
+
] : []
|
|
2897
|
+
)
|
|
2898
|
+
}
|
|
2899
|
+
];
|
|
2900
|
+
}
|
|
2901
|
+
var pinColumn = (options, pinLocation) => ({
|
|
2902
|
+
label: `Pin ${pinLocation}`,
|
|
2903
|
+
action: `column-pin-${pinLocation}`,
|
|
2904
|
+
options
|
|
2905
|
+
});
|
|
2906
|
+
var pinLeft = (options) => pinColumn(options, "left");
|
|
2907
|
+
var pinFloating = (options) => pinColumn(options, "floating");
|
|
2908
|
+
var pinRight = (options) => pinColumn(options, "right");
|
|
2909
|
+
function buildColumnDisplayMenuItems(options) {
|
|
2910
|
+
const { column } = options;
|
|
2911
|
+
if (column === void 0) {
|
|
2912
|
+
return [];
|
|
2913
|
+
}
|
|
2914
|
+
const { pin } = column;
|
|
2915
|
+
const menuItems = [
|
|
2916
|
+
{
|
|
2917
|
+
label: `Hide column`,
|
|
2918
|
+
action: "column-hide",
|
|
2919
|
+
options
|
|
2920
|
+
},
|
|
2921
|
+
{
|
|
2922
|
+
label: `Remove column`,
|
|
2923
|
+
action: "column-remove",
|
|
2924
|
+
options
|
|
2925
|
+
}
|
|
2926
|
+
];
|
|
2927
|
+
if (pin === void 0) {
|
|
2928
|
+
menuItems.push({
|
|
2929
|
+
label: `Pin column`,
|
|
2930
|
+
children: [pinLeft(options), pinFloating(options), pinRight(options)]
|
|
2931
|
+
});
|
|
2932
|
+
} else if (pin === "left") {
|
|
2933
|
+
menuItems.push(
|
|
2934
|
+
{ label: "Unpin column", action: "column-unpin", options },
|
|
2935
|
+
{
|
|
2936
|
+
label: `Pin column`,
|
|
2937
|
+
children: [pinFloating(options), pinRight(options)]
|
|
2938
|
+
}
|
|
2939
|
+
);
|
|
2940
|
+
} else if (pin === "right") {
|
|
2941
|
+
menuItems.push(
|
|
2942
|
+
{ label: "Unpin column", action: "column-unpin", options },
|
|
2943
|
+
{
|
|
2944
|
+
label: `Pin column`,
|
|
2945
|
+
children: [pinLeft(options), pinFloating(options)]
|
|
2946
|
+
}
|
|
2947
|
+
);
|
|
2948
|
+
} else if (pin === "floating") {
|
|
2949
|
+
menuItems.push(
|
|
2950
|
+
{ label: "Unpin column", action: "column-unpin", options },
|
|
2951
|
+
{
|
|
2952
|
+
label: `Pin column`,
|
|
2953
|
+
children: [pinLeft(options), pinRight(options)]
|
|
2954
|
+
}
|
|
2955
|
+
);
|
|
2956
|
+
}
|
|
2957
|
+
return menuItems;
|
|
2958
|
+
}
|
|
2959
|
+
function buildGroupMenuItems(options, { groupBy }) {
|
|
2960
|
+
const { column } = options;
|
|
2961
|
+
const menuItems = [];
|
|
2962
|
+
if (column === void 0) {
|
|
2963
|
+
return menuItems;
|
|
2964
|
+
}
|
|
2965
|
+
const { name: name2, label = name2 } = column;
|
|
2966
|
+
if (groupBy.length === 0) {
|
|
2967
|
+
menuItems.push({
|
|
2968
|
+
label: `Group by ${label}`,
|
|
2969
|
+
action: "group",
|
|
2970
|
+
options
|
|
2971
|
+
});
|
|
2972
|
+
} else {
|
|
2973
|
+
menuItems.push({
|
|
2974
|
+
label: `Add ${label} to group by`,
|
|
2975
|
+
action: "group-add",
|
|
2976
|
+
options
|
|
2977
|
+
});
|
|
2978
|
+
}
|
|
2979
|
+
return menuItems;
|
|
2980
|
+
}
|
|
2754
2981
|
|
|
2755
2982
|
// ../vuu-table/src/table/context-menu/useTableContextMenu.ts
|
|
2756
2983
|
var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
|
|
2757
2984
|
var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
|
|
2985
|
+
var removeFilterColumn = (dataSourceFilter, column) => {
|
|
2986
|
+
if (dataSourceFilter.filterStruct && column) {
|
|
2987
|
+
const [filterStruct, filter] = (0, import_vuu_utils17.removeColumnFromFilter)(
|
|
2988
|
+
column,
|
|
2989
|
+
dataSourceFilter.filterStruct
|
|
2990
|
+
);
|
|
2991
|
+
return {
|
|
2992
|
+
filter,
|
|
2993
|
+
filterStruct
|
|
2994
|
+
};
|
|
2995
|
+
} else {
|
|
2996
|
+
return dataSourceFilter;
|
|
2997
|
+
}
|
|
2998
|
+
};
|
|
2758
2999
|
var { Average, Count, Distinct, High, Low, Sum } = import_vuu_utils18.AggregationType;
|
|
3000
|
+
var useTableContextMenu = ({
|
|
3001
|
+
dataSource,
|
|
3002
|
+
onPersistentColumnOperation
|
|
3003
|
+
}) => {
|
|
3004
|
+
const handleContextMenuAction = (action) => {
|
|
3005
|
+
const gridOptions = action.options;
|
|
3006
|
+
if (gridOptions.column && dataSource) {
|
|
3007
|
+
const { column } = gridOptions;
|
|
3008
|
+
switch (action.menuId) {
|
|
3009
|
+
case "sort-asc":
|
|
3010
|
+
return dataSource.sort = (0, import_vuu_utils18.setSortColumn)(dataSource.sort, column, "A"), true;
|
|
3011
|
+
case "sort-dsc":
|
|
3012
|
+
return dataSource.sort = (0, import_vuu_utils18.setSortColumn)(dataSource.sort, column, "D"), true;
|
|
3013
|
+
case "sort-add-asc":
|
|
3014
|
+
return dataSource.sort = (0, import_vuu_utils18.addSortColumn)(dataSource.sort, column, "A"), true;
|
|
3015
|
+
case "sort-add-dsc":
|
|
3016
|
+
return dataSource.sort = (0, import_vuu_utils18.addSortColumn)(dataSource.sort, column, "D"), true;
|
|
3017
|
+
case "group":
|
|
3018
|
+
return dataSource.groupBy = (0, import_vuu_utils18.addGroupColumn)(dataSource.groupBy, column), true;
|
|
3019
|
+
case "group-add":
|
|
3020
|
+
return dataSource.groupBy = (0, import_vuu_utils18.addGroupColumn)(dataSource.groupBy, column), true;
|
|
3021
|
+
case "column-hide":
|
|
3022
|
+
return onPersistentColumnOperation({ type: "hideColumns", columns: [column] }), true;
|
|
3023
|
+
case "column-remove":
|
|
3024
|
+
return dataSource.columns = dataSource.columns.filter((name2) => name2 !== column.name), true;
|
|
3025
|
+
case "filter-remove-column":
|
|
3026
|
+
return dataSource.filter = removeFilterColumn(dataSource.filter, column), true;
|
|
3027
|
+
case "remove-filters":
|
|
3028
|
+
return dataSource.filter = { filter: "" }, true;
|
|
3029
|
+
case "agg-avg":
|
|
3030
|
+
return dataSource.aggregations = (0, import_vuu_utils18.setAggregations)(dataSource.aggregations, column, Average), true;
|
|
3031
|
+
case "agg-high":
|
|
3032
|
+
return dataSource.aggregations = (0, import_vuu_utils18.setAggregations)(dataSource.aggregations, column, High), true;
|
|
3033
|
+
case "agg-low":
|
|
3034
|
+
return dataSource.aggregations = (0, import_vuu_utils18.setAggregations)(dataSource.aggregations, column, Low), true;
|
|
3035
|
+
case "agg-count":
|
|
3036
|
+
return dataSource.aggregations = (0, import_vuu_utils18.setAggregations)(dataSource.aggregations, column, Count), true;
|
|
3037
|
+
case "agg-distinct":
|
|
3038
|
+
return dataSource.aggregations = (0, import_vuu_utils18.setAggregations)(dataSource.aggregations, column, Distinct), true;
|
|
3039
|
+
case "agg-sum":
|
|
3040
|
+
return dataSource.aggregations = (0, import_vuu_utils18.setAggregations)(dataSource.aggregations, column, Sum), true;
|
|
3041
|
+
case "column-pin-floating":
|
|
3042
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "floating" }), true;
|
|
3043
|
+
case "column-pin-left":
|
|
3044
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "left" }), true;
|
|
3045
|
+
case "column-pin-right":
|
|
3046
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: "right" }), true;
|
|
3047
|
+
case "column-unpin":
|
|
3048
|
+
return onPersistentColumnOperation({ type: "pinColumn", column, pin: void 0 }), true;
|
|
3049
|
+
case "column-settings":
|
|
3050
|
+
return onPersistentColumnOperation({ type: "columnSettings", column }), true;
|
|
3051
|
+
case "table-settings":
|
|
3052
|
+
return onPersistentColumnOperation({ type: "tableSettings" }), true;
|
|
3053
|
+
default:
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
return false;
|
|
3057
|
+
};
|
|
3058
|
+
return handleContextMenuAction;
|
|
3059
|
+
};
|
|
2759
3060
|
|
|
2760
3061
|
// ../vuu-table/src/table/Table.tsx
|
|
2761
3062
|
var import_vuu_popups4 = require("@vuu-ui/vuu-popups");
|
|
@@ -3153,6 +3454,38 @@ var resizeObserver = new ResizeObserver((entries) => {
|
|
|
3153
3454
|
var import_vuu_utils26 = require("@vuu-ui/vuu-utils");
|
|
3154
3455
|
var import_react27 = require("react");
|
|
3155
3456
|
var { IDX: IDX2 } = import_vuu_utils26.metadataKeys;
|
|
3457
|
+
var NO_SELECTION = [];
|
|
3458
|
+
var useSelection = ({
|
|
3459
|
+
selectionModel,
|
|
3460
|
+
onSelect,
|
|
3461
|
+
onSelectionChange
|
|
3462
|
+
}) => {
|
|
3463
|
+
selectionModel === "extended" || selectionModel === "checkbox";
|
|
3464
|
+
const lastActiveRef = (0, import_react27.useRef)(-1);
|
|
3465
|
+
const selectedRef = (0, import_react27.useRef)(NO_SELECTION);
|
|
3466
|
+
const handleSelectionChange = (0, import_react27.useCallback)(
|
|
3467
|
+
(row, rangeSelect, keepExistingSelection) => {
|
|
3468
|
+
const { [IDX2]: idx } = row;
|
|
3469
|
+
const { current: active } = lastActiveRef;
|
|
3470
|
+
const { current: selected } = selectedRef;
|
|
3471
|
+
const selectOperation = (0, import_vuu_utils26.isRowSelected)(row) ? import_vuu_utils26.deselectItem : import_vuu_utils26.selectItem;
|
|
3472
|
+
const newSelected = selectOperation(
|
|
3473
|
+
selectionModel,
|
|
3474
|
+
selected,
|
|
3475
|
+
idx,
|
|
3476
|
+
rangeSelect,
|
|
3477
|
+
keepExistingSelection,
|
|
3478
|
+
active
|
|
3479
|
+
);
|
|
3480
|
+
selectedRef.current = newSelected;
|
|
3481
|
+
lastActiveRef.current = idx;
|
|
3482
|
+
onSelect == null ? void 0 : onSelect(row);
|
|
3483
|
+
onSelectionChange == null ? void 0 : onSelectionChange(newSelected);
|
|
3484
|
+
},
|
|
3485
|
+
[onSelect, onSelectionChange, selectionModel]
|
|
3486
|
+
);
|
|
3487
|
+
return handleSelectionChange;
|
|
3488
|
+
};
|
|
3156
3489
|
|
|
3157
3490
|
// ../vuu-table/src/table/useTableModel.ts
|
|
3158
3491
|
var import_vuu_utils27 = require("@vuu-ui/vuu-utils");
|
|
@@ -3165,6 +3498,126 @@ var import_react29 = require("react");
|
|
|
3165
3498
|
// ../vuu-table/src/table-next/useTableViewport.ts
|
|
3166
3499
|
var import_react30 = require("react");
|
|
3167
3500
|
var import_vuu_utils28 = require("@vuu-ui/vuu-utils");
|
|
3501
|
+
var MAX_RAW_ROWS = 15e5;
|
|
3502
|
+
var UNMEASURED_VIEWPORT = {
|
|
3503
|
+
contentHeight: 0,
|
|
3504
|
+
contentWidth: 0,
|
|
3505
|
+
getRowAtPosition: () => -1,
|
|
3506
|
+
getRowOffset: () => -1,
|
|
3507
|
+
horizontalScrollbarHeight: 0,
|
|
3508
|
+
maxScrollContainerScrollHorizontal: 0,
|
|
3509
|
+
maxScrollContainerScrollVertical: 0,
|
|
3510
|
+
pinnedWidthLeft: 0,
|
|
3511
|
+
pinnedWidthRight: 0,
|
|
3512
|
+
rowCount: 0,
|
|
3513
|
+
setPctScrollTop: () => void 0,
|
|
3514
|
+
totalHeaderHeight: 0,
|
|
3515
|
+
verticalScrollbarWidth: 0,
|
|
3516
|
+
viewportBodyHeight: 0
|
|
3517
|
+
};
|
|
3518
|
+
var measurePinnedColumns = (columns) => {
|
|
3519
|
+
let pinnedWidthLeft = 0;
|
|
3520
|
+
let pinnedWidthRight = 0;
|
|
3521
|
+
let unpinnedWidth = 0;
|
|
3522
|
+
for (const column of columns) {
|
|
3523
|
+
const { hidden, pin, width } = column;
|
|
3524
|
+
const visibleWidth = hidden ? 0 : width;
|
|
3525
|
+
if (pin === "left") {
|
|
3526
|
+
pinnedWidthLeft += visibleWidth;
|
|
3527
|
+
} else if (pin === "right") {
|
|
3528
|
+
pinnedWidthRight += visibleWidth;
|
|
3529
|
+
} else {
|
|
3530
|
+
unpinnedWidth += visibleWidth;
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
return {
|
|
3534
|
+
pinnedWidthLeft: pinnedWidthLeft + 4,
|
|
3535
|
+
pinnedWidthRight: pinnedWidthRight + 4,
|
|
3536
|
+
unpinnedWidth
|
|
3537
|
+
};
|
|
3538
|
+
};
|
|
3539
|
+
var useTableViewport = ({
|
|
3540
|
+
columns,
|
|
3541
|
+
headerHeight,
|
|
3542
|
+
headings,
|
|
3543
|
+
rowCount,
|
|
3544
|
+
rowHeight,
|
|
3545
|
+
size
|
|
3546
|
+
}) => {
|
|
3547
|
+
const pctScrollTopRef = (0, import_react30.useRef)(0);
|
|
3548
|
+
const appliedRowCount = Math.min(rowCount, MAX_RAW_ROWS);
|
|
3549
|
+
const appliedContentHeight = appliedRowCount * rowHeight;
|
|
3550
|
+
const virtualContentHeight = rowCount * rowHeight;
|
|
3551
|
+
const virtualisedExtent = virtualContentHeight - appliedContentHeight;
|
|
3552
|
+
const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0, import_react30.useMemo)(
|
|
3553
|
+
() => measurePinnedColumns(columns),
|
|
3554
|
+
[columns]
|
|
3555
|
+
);
|
|
3556
|
+
const [actualRowOffset, actualRowAtPosition] = (0, import_react30.useMemo)(
|
|
3557
|
+
() => (0, import_vuu_utils28.actualRowPositioning)(rowHeight),
|
|
3558
|
+
[rowHeight]
|
|
3559
|
+
);
|
|
3560
|
+
const [getRowOffset, getRowAtPosition] = (0, import_react30.useMemo)(() => {
|
|
3561
|
+
if (virtualisedExtent) {
|
|
3562
|
+
return (0, import_vuu_utils28.virtualRowPositioning)(
|
|
3563
|
+
rowHeight,
|
|
3564
|
+
virtualisedExtent,
|
|
3565
|
+
pctScrollTopRef
|
|
3566
|
+
);
|
|
3567
|
+
} else {
|
|
3568
|
+
return [actualRowOffset, actualRowAtPosition];
|
|
3569
|
+
}
|
|
3570
|
+
}, [actualRowAtPosition, actualRowOffset, virtualisedExtent, rowHeight]);
|
|
3571
|
+
const setPctScrollTop = (0, import_react30.useCallback)((scrollPct) => {
|
|
3572
|
+
pctScrollTopRef.current = scrollPct;
|
|
3573
|
+
}, []);
|
|
3574
|
+
return (0, import_react30.useMemo)(() => {
|
|
3575
|
+
var _a;
|
|
3576
|
+
if (size) {
|
|
3577
|
+
const headingsDepth = headings.length;
|
|
3578
|
+
const scrollbarSize = 15;
|
|
3579
|
+
const contentWidth = pinnedWidthLeft + unpinnedWidth + pinnedWidthRight;
|
|
3580
|
+
const horizontalScrollbarHeight = contentWidth > size.width ? scrollbarSize : 0;
|
|
3581
|
+
const totalHeaderHeight = headerHeight * (1 + headingsDepth);
|
|
3582
|
+
const maxScrollContainerScrollVertical = appliedContentHeight - (((_a = size == null ? void 0 : size.height) != null ? _a : 0) - horizontalScrollbarHeight) + totalHeaderHeight;
|
|
3583
|
+
const maxScrollContainerScrollHorizontal = contentWidth - size.width + pinnedWidthLeft;
|
|
3584
|
+
const visibleRows = (size.height - headerHeight) / rowHeight;
|
|
3585
|
+
const count = Number.isInteger(visibleRows) ? visibleRows + 1 : Math.ceil(visibleRows);
|
|
3586
|
+
const viewportBodyHeight = size.height - totalHeaderHeight;
|
|
3587
|
+
const verticalScrollbarWidth = appliedContentHeight > viewportBodyHeight ? scrollbarSize : 0;
|
|
3588
|
+
return {
|
|
3589
|
+
contentHeight: appliedContentHeight,
|
|
3590
|
+
getRowAtPosition,
|
|
3591
|
+
getRowOffset,
|
|
3592
|
+
horizontalScrollbarHeight,
|
|
3593
|
+
maxScrollContainerScrollHorizontal,
|
|
3594
|
+
maxScrollContainerScrollVertical,
|
|
3595
|
+
pinnedWidthLeft,
|
|
3596
|
+
pinnedWidthRight,
|
|
3597
|
+
rowCount: count,
|
|
3598
|
+
contentWidth,
|
|
3599
|
+
setPctScrollTop,
|
|
3600
|
+
totalHeaderHeight,
|
|
3601
|
+
verticalScrollbarWidth,
|
|
3602
|
+
viewportBodyHeight
|
|
3603
|
+
};
|
|
3604
|
+
} else {
|
|
3605
|
+
return UNMEASURED_VIEWPORT;
|
|
3606
|
+
}
|
|
3607
|
+
}, [
|
|
3608
|
+
size,
|
|
3609
|
+
headings.length,
|
|
3610
|
+
pinnedWidthLeft,
|
|
3611
|
+
unpinnedWidth,
|
|
3612
|
+
pinnedWidthRight,
|
|
3613
|
+
appliedContentHeight,
|
|
3614
|
+
headerHeight,
|
|
3615
|
+
rowHeight,
|
|
3616
|
+
getRowAtPosition,
|
|
3617
|
+
getRowOffset,
|
|
3618
|
+
setPctScrollTop
|
|
3619
|
+
]);
|
|
3620
|
+
};
|
|
3168
3621
|
|
|
3169
3622
|
// ../vuu-table/src/table/useVirtualViewport.ts
|
|
3170
3623
|
var import_vuu_utils29 = require("@vuu-ui/vuu-utils");
|
|
@@ -3221,6 +3674,7 @@ var JsonCell = ({ column, row }) => {
|
|
|
3221
3674
|
return null;
|
|
3222
3675
|
}
|
|
3223
3676
|
};
|
|
3677
|
+
console.log("register JsonCell");
|
|
3224
3678
|
(0, import_vuu_utils32.registerComponent)("json", JsonCell, "cell-renderer", {
|
|
3225
3679
|
description: "JSON formatter",
|
|
3226
3680
|
label: "JSON formatter",
|
|
@@ -3234,44 +3688,199 @@ var import_react37 = require("react");
|
|
|
3234
3688
|
// ../vuu-table/src/table-next/column-resizing/ColumnResizer.tsx
|
|
3235
3689
|
var import_react33 = require("react");
|
|
3236
3690
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3691
|
+
var NOOP = () => void 0;
|
|
3692
|
+
var baseClass = "vuuColumnResizerNext";
|
|
3693
|
+
var ColumnResizer2 = ({
|
|
3694
|
+
onDrag,
|
|
3695
|
+
onDragEnd = NOOP,
|
|
3696
|
+
onDragStart = NOOP
|
|
3697
|
+
}) => {
|
|
3698
|
+
const position = (0, import_react33.useRef)(0);
|
|
3699
|
+
const onMouseMove = (0, import_react33.useCallback)(
|
|
3700
|
+
(e) => {
|
|
3701
|
+
if (e.stopPropagation) {
|
|
3702
|
+
e.stopPropagation();
|
|
3703
|
+
}
|
|
3704
|
+
if (e.preventDefault) {
|
|
3705
|
+
e.preventDefault();
|
|
3706
|
+
}
|
|
3707
|
+
const x = Math.round(e.clientX);
|
|
3708
|
+
const moveBy = x - position.current;
|
|
3709
|
+
position.current = x;
|
|
3710
|
+
if (moveBy !== 0) {
|
|
3711
|
+
onDrag(e, moveBy);
|
|
3712
|
+
}
|
|
3713
|
+
},
|
|
3714
|
+
[onDrag]
|
|
3715
|
+
);
|
|
3716
|
+
const onMouseUp = (0, import_react33.useCallback)(
|
|
3717
|
+
(e) => {
|
|
3718
|
+
window.removeEventListener("mouseup", onMouseUp);
|
|
3719
|
+
window.removeEventListener("mousemove", onMouseMove);
|
|
3720
|
+
onDragEnd(e);
|
|
3721
|
+
},
|
|
3722
|
+
[onDragEnd, onMouseMove]
|
|
3723
|
+
);
|
|
3724
|
+
const handleMouseDown = (0, import_react33.useCallback)(
|
|
3725
|
+
(e) => {
|
|
3726
|
+
onDragStart(e);
|
|
3727
|
+
position.current = Math.round(e.clientX);
|
|
3728
|
+
window.addEventListener("mouseup", onMouseUp);
|
|
3729
|
+
window.addEventListener("mousemove", onMouseMove);
|
|
3730
|
+
if (e.stopPropagation) {
|
|
3731
|
+
e.stopPropagation();
|
|
3732
|
+
}
|
|
3733
|
+
if (e.preventDefault) {
|
|
3734
|
+
e.preventDefault();
|
|
3735
|
+
}
|
|
3736
|
+
},
|
|
3737
|
+
[onDragStart, onMouseMove, onMouseUp]
|
|
3738
|
+
);
|
|
3739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: baseClass, onMouseDown: handleMouseDown });
|
|
3740
|
+
};
|
|
3237
3741
|
|
|
3238
3742
|
// ../vuu-table/src/table-next/column-resizing/useTableColumnResize.tsx
|
|
3239
3743
|
var import_react34 = require("react");
|
|
3744
|
+
var useTableColumnResize2 = ({
|
|
3745
|
+
column,
|
|
3746
|
+
onResize,
|
|
3747
|
+
rootRef
|
|
3748
|
+
}) => {
|
|
3749
|
+
const widthRef = (0, import_react34.useRef)(0);
|
|
3750
|
+
const [isResizing, setResizing] = (0, import_react34.useState)(false);
|
|
3751
|
+
const { name: name2 } = column;
|
|
3752
|
+
const handleResizeStart = (0, import_react34.useCallback)(() => {
|
|
3753
|
+
console.log("onResizeStart");
|
|
3754
|
+
if (onResize && rootRef.current) {
|
|
3755
|
+
console.log("handleResizeStart");
|
|
3756
|
+
const { width } = rootRef.current.getBoundingClientRect();
|
|
3757
|
+
widthRef.current = Math.round(width);
|
|
3758
|
+
setResizing(true);
|
|
3759
|
+
onResize == null ? void 0 : onResize("begin", name2);
|
|
3760
|
+
}
|
|
3761
|
+
}, [name2, onResize, rootRef]);
|
|
3762
|
+
const handleResize = (0, import_react34.useCallback)(
|
|
3763
|
+
(_evt, moveBy) => {
|
|
3764
|
+
if (rootRef.current) {
|
|
3765
|
+
if (onResize) {
|
|
3766
|
+
const { width } = rootRef.current.getBoundingClientRect();
|
|
3767
|
+
const newWidth = Math.round(width) + moveBy;
|
|
3768
|
+
if (newWidth !== widthRef.current && newWidth > 0) {
|
|
3769
|
+
onResize("resize", name2, newWidth);
|
|
3770
|
+
widthRef.current = newWidth;
|
|
3771
|
+
}
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
},
|
|
3775
|
+
[name2, onResize, rootRef]
|
|
3776
|
+
);
|
|
3777
|
+
const handleResizeEnd = (0, import_react34.useCallback)(() => {
|
|
3778
|
+
if (onResize) {
|
|
3779
|
+
onResize("end", name2, widthRef.current);
|
|
3780
|
+
setTimeout(() => {
|
|
3781
|
+
setResizing(false);
|
|
3782
|
+
}, 80);
|
|
3783
|
+
}
|
|
3784
|
+
}, [name2, onResize]);
|
|
3785
|
+
return {
|
|
3786
|
+
isResizing,
|
|
3787
|
+
onDrag: handleResize,
|
|
3788
|
+
onDragStart: handleResizeStart,
|
|
3789
|
+
onDragEnd: handleResizeEnd
|
|
3790
|
+
};
|
|
3791
|
+
};
|
|
3240
3792
|
|
|
3241
3793
|
// ../vuu-table/src/table-next/useCell.ts
|
|
3242
3794
|
var import_vuu_utils33 = require("@vuu-ui/vuu-utils");
|
|
3243
3795
|
var import_classnames15 = __toESM(require("classnames"));
|
|
3244
3796
|
var import_react35 = require("react");
|
|
3245
|
-
var useCell = (column,
|
|
3797
|
+
var useCell = (column, classBase23, isHeader) => (
|
|
3246
3798
|
// TODO measure perf without the memo, might not be worth the cost
|
|
3247
3799
|
(0, import_react35.useMemo)(() => {
|
|
3248
|
-
const className = (0, import_classnames15.default)(
|
|
3800
|
+
const className = (0, import_classnames15.default)(classBase23, {
|
|
3249
3801
|
vuuPinFloating: column.pin === "floating",
|
|
3250
3802
|
vuuPinLeft: column.pin === "left",
|
|
3251
3803
|
vuuPinRight: column.pin === "right",
|
|
3252
3804
|
vuuEndPin: isHeader && column.endPin,
|
|
3253
3805
|
// [`${classBase}-resizing`]: column.resizing,
|
|
3254
|
-
[`${
|
|
3255
|
-
[`${
|
|
3806
|
+
[`${classBase23}-editable`]: column.editable,
|
|
3807
|
+
[`${classBase23}-right`]: column.align === "right"
|
|
3256
3808
|
});
|
|
3257
3809
|
const style = (0, import_vuu_utils33.getColumnStyle)(column);
|
|
3258
3810
|
return {
|
|
3259
3811
|
className,
|
|
3260
3812
|
style
|
|
3261
3813
|
};
|
|
3262
|
-
}, [column,
|
|
3814
|
+
}, [column, classBase23, isHeader])
|
|
3263
3815
|
);
|
|
3264
3816
|
|
|
3265
3817
|
// ../vuu-table/src/table-next/column-header-pill/ColumnHeaderPill.tsx
|
|
3266
3818
|
var import_classnames16 = __toESM(require("classnames"));
|
|
3267
3819
|
var import_react36 = require("react");
|
|
3268
3820
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3821
|
+
var classBase13 = "vuuColumnHeaderPill";
|
|
3822
|
+
var ColumnHeaderPill = ({
|
|
3823
|
+
children,
|
|
3824
|
+
className,
|
|
3825
|
+
column,
|
|
3826
|
+
onRemove,
|
|
3827
|
+
removable,
|
|
3828
|
+
...htmlAttributes
|
|
3829
|
+
}) => {
|
|
3830
|
+
if (removable && typeof onRemove !== "function") {
|
|
3831
|
+
throw Error(
|
|
3832
|
+
"ColumnHeaderPill onRemove prop must be provided if Pill is removable"
|
|
3833
|
+
);
|
|
3834
|
+
}
|
|
3835
|
+
const handleClickRemove = (0, import_react36.useCallback)(
|
|
3836
|
+
(evt) => {
|
|
3837
|
+
evt.preventDefault();
|
|
3838
|
+
evt.stopPropagation();
|
|
3839
|
+
onRemove == null ? void 0 : onRemove(column);
|
|
3840
|
+
},
|
|
3841
|
+
[column, onRemove]
|
|
3842
|
+
);
|
|
3843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { ...htmlAttributes, className: (0, import_classnames16.default)(classBase13, className), children: [
|
|
3844
|
+
children,
|
|
3845
|
+
removable ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
3846
|
+
"span",
|
|
3847
|
+
{
|
|
3848
|
+
className: `${classBase13}-removeButton`,
|
|
3849
|
+
role: "button",
|
|
3850
|
+
"data-icon": "cross",
|
|
3851
|
+
onClick: handleClickRemove
|
|
3852
|
+
}
|
|
3853
|
+
) : null
|
|
3854
|
+
] });
|
|
3855
|
+
};
|
|
3269
3856
|
|
|
3270
3857
|
// ../vuu-table/src/table-next/column-header-pill/GroupColumnPill.tsx
|
|
3271
3858
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3859
|
+
var GroupColumnPill = ({
|
|
3860
|
+
column,
|
|
3861
|
+
...columnHeaderProps
|
|
3862
|
+
}) => {
|
|
3863
|
+
const { name: name2, sorted } = column;
|
|
3864
|
+
const icon = typeof sorted === "number" ? sorted < 0 ? "arrow-down" : "arrow-up" : sorted === "A" ? "arrow-up" : sorted === "D" ? "arrow-down" : void 0;
|
|
3865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(ColumnHeaderPill, { ...columnHeaderProps, column, children: [
|
|
3866
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "vuuGroupColumnPill-label", children: name2 }),
|
|
3867
|
+
icon !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { "data-icon": icon }) : null,
|
|
3868
|
+
typeof sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { className: "vuuSortPosition", children: Math.abs(sorted) }) : null
|
|
3869
|
+
] });
|
|
3870
|
+
};
|
|
3272
3871
|
|
|
3273
3872
|
// ../vuu-table/src/table-next/column-header-pill/SortIndicator.tsx
|
|
3274
3873
|
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
3874
|
+
var SortIndicator2 = ({ column }) => {
|
|
3875
|
+
if (!column.sorted) {
|
|
3876
|
+
return null;
|
|
3877
|
+
}
|
|
3878
|
+
const icon = typeof column.sorted === "number" ? column.sorted < 0 ? "arrow-down" : "arrow-up" : column.sorted === "A" ? "arrow-up" : "arrow-down";
|
|
3879
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(ColumnHeaderPill, { column, children: [
|
|
3880
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { "data-icon": icon }),
|
|
3881
|
+
typeof column.sorted === "number" ? /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "vuuSortPosition", children: Math.abs(column.sorted) }) : null
|
|
3882
|
+
] });
|
|
3883
|
+
};
|
|
3275
3884
|
|
|
3276
3885
|
// ../vuu-table/src/table-next/header-cell/GroupHeaderCell.tsx
|
|
3277
3886
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
@@ -3283,6 +3892,92 @@ var import_react39 = require("react");
|
|
|
3283
3892
|
var import_vuu_layout = require("@vuu-ui/vuu-layout");
|
|
3284
3893
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
3285
3894
|
var import_react40 = require("react");
|
|
3895
|
+
var classBase14 = "vuuTableNextGroupHeaderCell";
|
|
3896
|
+
var switchIfChanged = (columns, newColumns) => {
|
|
3897
|
+
if (columns === newColumns) {
|
|
3898
|
+
return columns;
|
|
3899
|
+
} else {
|
|
3900
|
+
return newColumns;
|
|
3901
|
+
}
|
|
3902
|
+
};
|
|
3903
|
+
var GroupHeaderCellNext = ({
|
|
3904
|
+
column: groupColumn,
|
|
3905
|
+
className: classNameProp,
|
|
3906
|
+
onRemoveColumn,
|
|
3907
|
+
onResize,
|
|
3908
|
+
...htmlAttributes
|
|
3909
|
+
}) => {
|
|
3910
|
+
const rootRef = (0, import_react39.useRef)(null);
|
|
3911
|
+
const { isResizing, ...resizeProps } = useTableColumnResize2({
|
|
3912
|
+
column: groupColumn,
|
|
3913
|
+
onResize,
|
|
3914
|
+
rootRef
|
|
3915
|
+
});
|
|
3916
|
+
const [columns, setColumns] = (0, import_react39.useState)(groupColumn.columns);
|
|
3917
|
+
const { className, style } = useCell(groupColumn, classBase14, true);
|
|
3918
|
+
const columnPillProps = columns.length > 1 ? {
|
|
3919
|
+
removable: true,
|
|
3920
|
+
onRemove: onRemoveColumn
|
|
3921
|
+
} : void 0;
|
|
3922
|
+
const handleMoveItem = (0, import_react39.useCallback)((fromIndex, toIndex) => {
|
|
3923
|
+
setColumns((cols) => {
|
|
3924
|
+
const newCols = cols.slice();
|
|
3925
|
+
const [tab] = newCols.splice(fromIndex, 1);
|
|
3926
|
+
if (toIndex === -1) {
|
|
3927
|
+
return newCols.concat(tab);
|
|
3928
|
+
} else {
|
|
3929
|
+
newCols.splice(toIndex, 0, tab);
|
|
3930
|
+
return newCols;
|
|
3931
|
+
}
|
|
3932
|
+
});
|
|
3933
|
+
}, []);
|
|
3934
|
+
(0, import_vuu_layout.useLayoutEffectSkipFirst)(() => {
|
|
3935
|
+
setColumns((cols) => switchIfChanged(cols, groupColumn.columns));
|
|
3936
|
+
}, [groupColumn.columns]);
|
|
3937
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
3938
|
+
"div",
|
|
3939
|
+
{
|
|
3940
|
+
...htmlAttributes,
|
|
3941
|
+
className: (0, import_classnames18.default)(className, "vuuTableNextHeaderCell", classNameProp, {
|
|
3942
|
+
[`${classBase14}-pending`]: groupColumn.groupConfirmed === false
|
|
3943
|
+
}),
|
|
3944
|
+
ref: rootRef,
|
|
3945
|
+
role: "columnheader",
|
|
3946
|
+
style,
|
|
3947
|
+
children: [
|
|
3948
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3949
|
+
import_vuu_layout.OverflowContainer,
|
|
3950
|
+
{
|
|
3951
|
+
allowDragDrop: true,
|
|
3952
|
+
className: `${classBase14}-inner`,
|
|
3953
|
+
height: 24,
|
|
3954
|
+
onMoveItem: handleMoveItem,
|
|
3955
|
+
overflowPosition: "start",
|
|
3956
|
+
children: columns.map((column) => {
|
|
3957
|
+
return /* @__PURE__ */ (0, import_react40.createElement)(
|
|
3958
|
+
GroupColumnPill,
|
|
3959
|
+
{
|
|
3960
|
+
...columnPillProps,
|
|
3961
|
+
column,
|
|
3962
|
+
key: column.key
|
|
3963
|
+
}
|
|
3964
|
+
);
|
|
3965
|
+
})
|
|
3966
|
+
}
|
|
3967
|
+
),
|
|
3968
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
3969
|
+
ColumnHeaderPill,
|
|
3970
|
+
{
|
|
3971
|
+
column: groupColumn,
|
|
3972
|
+
removable: true,
|
|
3973
|
+
onRemove: onRemoveColumn
|
|
3974
|
+
}
|
|
3975
|
+
),
|
|
3976
|
+
groupColumn.resizeable !== false ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ColumnResizer2, { ...resizeProps }) : null
|
|
3977
|
+
]
|
|
3978
|
+
}
|
|
3979
|
+
);
|
|
3980
|
+
};
|
|
3286
3981
|
|
|
3287
3982
|
// ../vuu-table/src/table-next/header-cell/HeaderCell.tsx
|
|
3288
3983
|
var import_react42 = require("react");
|
|
@@ -3292,10 +3987,98 @@ var import_vuu_popups5 = require("@vuu-ui/vuu-popups");
|
|
|
3292
3987
|
var import_classnames19 = __toESM(require("classnames"));
|
|
3293
3988
|
var import_react41 = require("react");
|
|
3294
3989
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
3990
|
+
var getPosition = (element) => {
|
|
3991
|
+
if (element) {
|
|
3992
|
+
const { bottom, left } = element.getBoundingClientRect();
|
|
3993
|
+
return { x: left, y: bottom + 6 };
|
|
3994
|
+
}
|
|
3995
|
+
};
|
|
3996
|
+
var ColumnMenu = ({
|
|
3997
|
+
className,
|
|
3998
|
+
column,
|
|
3999
|
+
...props
|
|
4000
|
+
}) => {
|
|
4001
|
+
const rootRef = (0, import_react41.useRef)(null);
|
|
4002
|
+
const [menuOpen, setMenuOpen] = (0, import_react41.useState)(false);
|
|
4003
|
+
const [showContextMenu] = (0, import_vuu_popups5.useContextMenu)();
|
|
4004
|
+
const handleMenuClose = (0, import_react41.useCallback)(() => {
|
|
4005
|
+
setMenuOpen(false);
|
|
4006
|
+
}, []);
|
|
4007
|
+
const showColumnMenu = (0, import_react41.useCallback)(
|
|
4008
|
+
(e) => {
|
|
4009
|
+
setMenuOpen(true);
|
|
4010
|
+
showContextMenu(e, "column-menu", {
|
|
4011
|
+
column,
|
|
4012
|
+
ContextMenuProps: {
|
|
4013
|
+
onClose: handleMenuClose,
|
|
4014
|
+
position: getPosition(rootRef.current)
|
|
4015
|
+
}
|
|
4016
|
+
});
|
|
4017
|
+
},
|
|
4018
|
+
[column, handleMenuClose, showContextMenu]
|
|
4019
|
+
);
|
|
4020
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4021
|
+
"span",
|
|
4022
|
+
{
|
|
4023
|
+
...props,
|
|
4024
|
+
className: (0, import_classnames19.default)("vuuTable-columnMenu", className, {
|
|
4025
|
+
"vuuTable-columnMenu-open": menuOpen
|
|
4026
|
+
}),
|
|
4027
|
+
"data-icon": "more-vert",
|
|
4028
|
+
onClick: showColumnMenu,
|
|
4029
|
+
ref: rootRef
|
|
4030
|
+
}
|
|
4031
|
+
);
|
|
4032
|
+
};
|
|
3295
4033
|
|
|
3296
4034
|
// ../vuu-table/src/table-next/header-cell/HeaderCell.tsx
|
|
3297
4035
|
var import_classnames20 = __toESM(require("classnames"));
|
|
3298
4036
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
4037
|
+
var classBase15 = "vuuTableNextHeaderCell";
|
|
4038
|
+
var HeaderCell = ({
|
|
4039
|
+
className: classNameProp,
|
|
4040
|
+
column,
|
|
4041
|
+
onClick,
|
|
4042
|
+
onResize,
|
|
4043
|
+
...htmlAttributes
|
|
4044
|
+
}) => {
|
|
4045
|
+
var _a;
|
|
4046
|
+
const rootRef = (0, import_react42.useRef)(null);
|
|
4047
|
+
const { isResizing, ...resizeProps } = useTableColumnResize2({
|
|
4048
|
+
column,
|
|
4049
|
+
onResize,
|
|
4050
|
+
rootRef
|
|
4051
|
+
});
|
|
4052
|
+
const handleClick = (0, import_react42.useCallback)(
|
|
4053
|
+
(evt) => {
|
|
4054
|
+
console.log(`click isResizing ${isResizing}`);
|
|
4055
|
+
!isResizing && (onClick == null ? void 0 : onClick(evt));
|
|
4056
|
+
},
|
|
4057
|
+
[isResizing, onClick]
|
|
4058
|
+
);
|
|
4059
|
+
const { className, style } = useCell(column, classBase15, true);
|
|
4060
|
+
const columnMenu = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ColumnMenu, { column });
|
|
4061
|
+
const columnLabel = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: `${classBase15}-label`, children: (_a = column.label) != null ? _a : column.name });
|
|
4062
|
+
const sortIndicator = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(SortIndicator2, { column });
|
|
4063
|
+
const headerItems = column.align === "right" ? [sortIndicator, columnLabel, columnMenu] : [columnMenu, columnLabel, sortIndicator];
|
|
4064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
|
|
4065
|
+
"div",
|
|
4066
|
+
{
|
|
4067
|
+
...htmlAttributes,
|
|
4068
|
+
className: (0, import_classnames20.default)(className, classNameProp, {
|
|
4069
|
+
[`${classBase15}-resizing`]: isResizing
|
|
4070
|
+
}),
|
|
4071
|
+
onClick: handleClick,
|
|
4072
|
+
ref: rootRef,
|
|
4073
|
+
role: "columnheader",
|
|
4074
|
+
style,
|
|
4075
|
+
children: [
|
|
4076
|
+
...headerItems,
|
|
4077
|
+
column.resizeable !== false ? /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(ColumnResizer2, { ...resizeProps }) : null
|
|
4078
|
+
]
|
|
4079
|
+
}
|
|
4080
|
+
);
|
|
4081
|
+
};
|
|
3299
4082
|
|
|
3300
4083
|
// ../vuu-table/src/table-next/TableNext.tsx
|
|
3301
4084
|
var import_vuu_popups7 = require("@vuu-ui/vuu-popups");
|
|
@@ -3313,14 +4096,15 @@ var import_vuu_utils34 = require("@vuu-ui/vuu-utils");
|
|
|
3313
4096
|
var import_react43 = require("react");
|
|
3314
4097
|
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
3315
4098
|
var { IDX: IDX3 } = import_vuu_utils34.metadataKeys;
|
|
3316
|
-
var
|
|
4099
|
+
var classBase16 = "vuuTableNextCell";
|
|
3317
4100
|
var TableCell2 = ({
|
|
3318
4101
|
column,
|
|
3319
4102
|
columnMap,
|
|
4103
|
+
onClick,
|
|
3320
4104
|
onDataEdited,
|
|
3321
4105
|
row
|
|
3322
4106
|
}) => {
|
|
3323
|
-
const { className, style } = useCell(column,
|
|
4107
|
+
const { className, style } = useCell(column, classBase16);
|
|
3324
4108
|
const { CellRenderer, name: name2, valueFormatter } = column;
|
|
3325
4109
|
const dataIdx = columnMap[name2];
|
|
3326
4110
|
const handleDataItemEdited = (0, import_react43.useCallback)(
|
|
@@ -3330,15 +4114,30 @@ var TableCell2 = ({
|
|
|
3330
4114
|
},
|
|
3331
4115
|
[name2, onDataEdited, row]
|
|
3332
4116
|
);
|
|
3333
|
-
|
|
3334
|
-
|
|
4117
|
+
const handleClick = (0, import_react43.useCallback)(
|
|
4118
|
+
(evt) => {
|
|
4119
|
+
onClick == null ? void 0 : onClick(evt, column);
|
|
4120
|
+
},
|
|
4121
|
+
[column, onClick]
|
|
4122
|
+
);
|
|
4123
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4124
|
+
"div",
|
|
3335
4125
|
{
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
4126
|
+
className,
|
|
4127
|
+
onClick: onClick ? handleClick : void 0,
|
|
4128
|
+
role: "cell",
|
|
4129
|
+
style,
|
|
4130
|
+
children: CellRenderer ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4131
|
+
CellRenderer,
|
|
4132
|
+
{
|
|
4133
|
+
column,
|
|
4134
|
+
columnMap,
|
|
4135
|
+
onCommit: handleDataItemEdited,
|
|
4136
|
+
row
|
|
4137
|
+
}
|
|
4138
|
+
) : valueFormatter(row[dataIdx])
|
|
3340
4139
|
}
|
|
3341
|
-
)
|
|
4140
|
+
);
|
|
3342
4141
|
};
|
|
3343
4142
|
|
|
3344
4143
|
// ../vuu-table/src/table-next/table-cell/TableGroupCell.tsx
|
|
@@ -3347,11 +4146,11 @@ var import_react44 = require("react");
|
|
|
3347
4146
|
var import_classnames21 = __toESM(require("classnames"));
|
|
3348
4147
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3349
4148
|
var { IS_LEAF: IS_LEAF3 } = import_vuu_utils35.metadataKeys;
|
|
3350
|
-
var
|
|
4149
|
+
var classBase17 = "vuuTableNextGroupCell";
|
|
3351
4150
|
var TableGroupCell2 = ({ column, onClick, row }) => {
|
|
3352
4151
|
const { columns } = column;
|
|
3353
4152
|
const [value, offset] = (0, import_vuu_utils35.getGroupValueAndOffset)(columns, row);
|
|
3354
|
-
const { className, style } = useCell(column,
|
|
4153
|
+
const { className, style } = useCell(column, classBase17);
|
|
3355
4154
|
const handleClick = (0, import_react44.useCallback)(
|
|
3356
4155
|
(evt) => {
|
|
3357
4156
|
onClick == null ? void 0 : onClick(evt, column);
|
|
@@ -3359,7 +4158,7 @@ var TableGroupCell2 = ({ column, onClick, row }) => {
|
|
|
3359
4158
|
[column, onClick]
|
|
3360
4159
|
);
|
|
3361
4160
|
const isLeaf = row[IS_LEAF3];
|
|
3362
|
-
const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: `${
|
|
4161
|
+
const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: `${classBase17}-spacer` }, i));
|
|
3363
4162
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
|
|
3364
4163
|
"div",
|
|
3365
4164
|
{
|
|
@@ -3369,7 +4168,7 @@ var TableGroupCell2 = ({ column, onClick, row }) => {
|
|
|
3369
4168
|
onClick: isLeaf ? void 0 : handleClick,
|
|
3370
4169
|
children: [
|
|
3371
4170
|
spacers,
|
|
3372
|
-
isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: `${
|
|
4171
|
+
isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: `${classBase17}-toggle`, "data-icon": "triangle-right" }),
|
|
3373
4172
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { children: value })
|
|
3374
4173
|
]
|
|
3375
4174
|
}
|
|
@@ -3380,7 +4179,7 @@ var TableGroupCell2 = ({ column, onClick, row }) => {
|
|
|
3380
4179
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3381
4180
|
var import_react46 = require("react");
|
|
3382
4181
|
var { IDX: IDX4, IS_EXPANDED: IS_EXPANDED4, SELECTED: SELECTED3 } = import_vuu_utils36.metadataKeys;
|
|
3383
|
-
var
|
|
4182
|
+
var classBase18 = "vuuTableNextRow";
|
|
3384
4183
|
var Row2 = (0, import_react45.memo)(
|
|
3385
4184
|
({
|
|
3386
4185
|
className: classNameProp,
|
|
@@ -3408,12 +4207,12 @@ var Row2 = (0, import_react45.memo)(
|
|
|
3408
4207
|
[onClick, row]
|
|
3409
4208
|
);
|
|
3410
4209
|
const { True: True2, First: First2, Last: Last2 } = import_vuu_utils36.RowSelected;
|
|
3411
|
-
const className = (0, import_classnames22.default)(
|
|
3412
|
-
[`${
|
|
3413
|
-
[`${
|
|
3414
|
-
[`${
|
|
3415
|
-
[`${
|
|
3416
|
-
[`${
|
|
4210
|
+
const className = (0, import_classnames22.default)(classBase18, classNameProp, {
|
|
4211
|
+
[`${classBase18}-even`]: zebraStripes && rowIndex % 2 === 0,
|
|
4212
|
+
[`${classBase18}-expanded`]: isExpanded,
|
|
4213
|
+
[`${classBase18}-selected`]: selectionStatus & True2,
|
|
4214
|
+
[`${classBase18}-selectedStart`]: selectionStatus & First2,
|
|
4215
|
+
[`${classBase18}-selectedEnd`]: selectionStatus & Last2
|
|
3417
4216
|
});
|
|
3418
4217
|
const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
|
|
3419
4218
|
const handleGroupCellClick = (0, import_react45.useCallback)(
|
|
@@ -3436,7 +4235,7 @@ var Row2 = (0, import_react45.memo)(
|
|
|
3436
4235
|
onClick: handleRowClick,
|
|
3437
4236
|
style
|
|
3438
4237
|
},
|
|
3439
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: `${
|
|
4238
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: `${classBase18}-selectionDecorator vuuStickyLeft` }),
|
|
3440
4239
|
columns.filter(import_vuu_utils36.notHidden).map((column) => {
|
|
3441
4240
|
const isGroup = (0, import_vuu_utils36.isGroupColumn)(column);
|
|
3442
4241
|
const isJsonCell = (0, import_vuu_utils36.isJsonColumn)(column);
|
|
@@ -3453,7 +4252,7 @@ var Row2 = (0, import_react45.memo)(
|
|
|
3453
4252
|
column.key
|
|
3454
4253
|
);
|
|
3455
4254
|
}),
|
|
3456
|
-
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: `${
|
|
4255
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: `${classBase18}-selectionDecorator vuuStickyRight` })
|
|
3457
4256
|
);
|
|
3458
4257
|
}
|
|
3459
4258
|
);
|
|
@@ -3466,23 +4265,277 @@ var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
|
|
|
3466
4265
|
// ../vuu-table/src/table-next/useKeyboardNavigation.ts
|
|
3467
4266
|
var import_react47 = require("react");
|
|
3468
4267
|
|
|
3469
|
-
// ../vuu-table/src/table-next/
|
|
3470
|
-
var
|
|
3471
|
-
var
|
|
4268
|
+
// ../vuu-table/src/table-next/table-dom-utils.ts
|
|
4269
|
+
var headerCellQuery = (colIdx) => `.vuuTableNext-col-headers .vuuTableNextHeaderCell:nth-child(${colIdx})`;
|
|
4270
|
+
var dataCellQuery = (rowIdx, colIdx) => `.vuuTableNext-body > [aria-rowindex='${rowIdx}'] > [role='cell']:nth-child(${colIdx + 1})`;
|
|
4271
|
+
var getTableCell = (containerRef, [rowIdx, colIdx]) => {
|
|
4272
|
+
var _a;
|
|
4273
|
+
const cssQuery = rowIdx === -1 ? headerCellQuery(colIdx) : dataCellQuery(rowIdx, colIdx);
|
|
4274
|
+
const cell = (_a = containerRef.current) == null ? void 0 : _a.querySelector(
|
|
4275
|
+
cssQuery
|
|
4276
|
+
);
|
|
4277
|
+
if (cellIsEditable(cell)) {
|
|
4278
|
+
const focusableContent = cell.querySelector("button");
|
|
4279
|
+
return focusableContent || cell;
|
|
4280
|
+
} else {
|
|
4281
|
+
return cell;
|
|
4282
|
+
}
|
|
4283
|
+
};
|
|
4284
|
+
var cellIsEditable = (cell) => cell.classList.contains("vuuTableNextCell-editable");
|
|
4285
|
+
var cellIsTextInput = (cell) => cell.querySelector(".vuuTableInputCell") !== null;
|
|
3472
4286
|
|
|
3473
|
-
// ../vuu-table/src/table-next/
|
|
3474
|
-
var
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
4287
|
+
// ../vuu-table/src/table-next/useKeyboardNavigation.ts
|
|
4288
|
+
var navigationKeys2 = /* @__PURE__ */ new Set([
|
|
4289
|
+
"Home",
|
|
4290
|
+
"End",
|
|
4291
|
+
"PageUp",
|
|
4292
|
+
"PageDown",
|
|
4293
|
+
"ArrowDown",
|
|
4294
|
+
"ArrowLeft",
|
|
4295
|
+
"ArrowRight",
|
|
4296
|
+
"ArrowUp"
|
|
4297
|
+
]);
|
|
4298
|
+
var isNavigationKey2 = (key) => {
|
|
4299
|
+
return navigationKeys2.has(key);
|
|
4300
|
+
};
|
|
4301
|
+
var PageKeys = ["Home", "End", "PageUp", "PageDown"];
|
|
4302
|
+
var isPagingKey2 = (key) => PageKeys.includes(key);
|
|
4303
|
+
var NULL_CELL_POS = [-1, -1];
|
|
4304
|
+
var NO_SCROLL_NECESSARY = [void 0, void 0];
|
|
4305
|
+
var howFarIsCellOutsideViewport = (cellEl) => {
|
|
4306
|
+
var _a, _b;
|
|
4307
|
+
const scrollbarContainer = (_a = cellEl.closest(".vuuTableNext")) == null ? void 0 : _a.querySelector(".vuuTableNext-scrollbarContainer");
|
|
4308
|
+
if (scrollbarContainer) {
|
|
4309
|
+
const viewport = scrollbarContainer == null ? void 0 : scrollbarContainer.getBoundingClientRect();
|
|
4310
|
+
const cell = (_b = cellEl.closest(".vuuTableNextCell")) == null ? void 0 : _b.getBoundingClientRect();
|
|
4311
|
+
if (cell) {
|
|
4312
|
+
if (cell.bottom > viewport.bottom) {
|
|
4313
|
+
return ["down", cell.bottom - viewport.bottom];
|
|
4314
|
+
} else if (cell.top < viewport.top) {
|
|
4315
|
+
return ["up", cell.top - viewport.top];
|
|
4316
|
+
} else if (cell.right < viewport.right) {
|
|
4317
|
+
return ["right", cell.right - viewport.right];
|
|
4318
|
+
} else if (cell.left < viewport.left) {
|
|
4319
|
+
return ["left", cell.left - viewport.left];
|
|
4320
|
+
} else {
|
|
4321
|
+
return NO_SCROLL_NECESSARY;
|
|
4322
|
+
}
|
|
4323
|
+
} else {
|
|
4324
|
+
throw Error("Whats going on, cell not found");
|
|
4325
|
+
}
|
|
4326
|
+
} else {
|
|
4327
|
+
throw Error("Whats going on, scrollbar container not found");
|
|
4328
|
+
}
|
|
4329
|
+
};
|
|
4330
|
+
function nextCellPos(key, [rowIdx, colIdx], columnCount, rowCount) {
|
|
4331
|
+
if (key === "ArrowUp") {
|
|
4332
|
+
if (rowIdx > -1) {
|
|
4333
|
+
return [rowIdx - 1, colIdx];
|
|
4334
|
+
} else {
|
|
4335
|
+
return [rowIdx, colIdx];
|
|
4336
|
+
}
|
|
4337
|
+
} else if (key === "ArrowDown") {
|
|
4338
|
+
if (rowIdx === -1) {
|
|
4339
|
+
return [0, colIdx];
|
|
4340
|
+
} else if (rowIdx === rowCount - 1) {
|
|
4341
|
+
return [rowIdx, colIdx];
|
|
4342
|
+
} else {
|
|
4343
|
+
return [rowIdx + 1, colIdx];
|
|
4344
|
+
}
|
|
4345
|
+
} else if (key === "ArrowRight") {
|
|
4346
|
+
if (colIdx < columnCount - 1) {
|
|
4347
|
+
return [rowIdx, colIdx + 1];
|
|
4348
|
+
} else {
|
|
4349
|
+
return [rowIdx, colIdx];
|
|
4350
|
+
}
|
|
4351
|
+
} else if (key === "ArrowLeft") {
|
|
4352
|
+
if (colIdx > 1) {
|
|
4353
|
+
return [rowIdx, colIdx - 1];
|
|
4354
|
+
} else {
|
|
4355
|
+
return [rowIdx, colIdx];
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
return [rowIdx, colIdx];
|
|
4359
|
+
}
|
|
4360
|
+
var useKeyboardNavigation2 = ({
|
|
4361
|
+
columnCount = 0,
|
|
4362
|
+
containerRef,
|
|
4363
|
+
disableHighlightOnFocus,
|
|
4364
|
+
requestScroll,
|
|
4365
|
+
rowCount = 0,
|
|
4366
|
+
viewportRowCount
|
|
4367
|
+
}) => {
|
|
4368
|
+
var _a;
|
|
4369
|
+
const focusedCellPos = (0, import_react47.useRef)([-1, -1]);
|
|
4370
|
+
const focusableCell = (0, import_react47.useRef)();
|
|
4371
|
+
const activeCellPos = (0, import_react47.useRef)([-1, 0]);
|
|
4372
|
+
const getFocusedCell = (element) => element == null ? void 0 : element.closest(
|
|
4373
|
+
"[role='columnHeader'],[role='cell']"
|
|
4374
|
+
);
|
|
4375
|
+
const getTableCellPos = (tableCell) => {
|
|
4376
|
+
var _a2, _b;
|
|
4377
|
+
if (tableCell.role === "columnHeader") {
|
|
4378
|
+
const colIdx = parseInt((_a2 = tableCell.dataset.idx) != null ? _a2 : "-1", 10);
|
|
4379
|
+
return [-1, colIdx];
|
|
4380
|
+
} else {
|
|
4381
|
+
const focusedRow = tableCell.closest("[role='row']");
|
|
4382
|
+
if (focusedRow) {
|
|
4383
|
+
const rowIdx = parseInt((_b = focusedRow.ariaRowIndex) != null ? _b : "-1", 10);
|
|
4384
|
+
const colIdx = Array.from(focusedRow.childNodes).indexOf(tableCell);
|
|
4385
|
+
return [rowIdx, colIdx];
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
return NULL_CELL_POS;
|
|
4389
|
+
};
|
|
4390
|
+
const focusCell = (0, import_react47.useCallback)(
|
|
4391
|
+
(cellPos) => {
|
|
4392
|
+
var _a2;
|
|
4393
|
+
if (containerRef.current) {
|
|
4394
|
+
const activeCell = getTableCell(containerRef, cellPos);
|
|
4395
|
+
if (activeCell) {
|
|
4396
|
+
if (activeCell !== focusableCell.current) {
|
|
4397
|
+
(_a2 = focusableCell.current) == null ? void 0 : _a2.removeAttribute("tabindex");
|
|
4398
|
+
focusableCell.current = activeCell;
|
|
4399
|
+
activeCell.setAttribute("tabindex", "0");
|
|
4400
|
+
}
|
|
4401
|
+
const [direction, distance] = howFarIsCellOutsideViewport(activeCell);
|
|
4402
|
+
if (direction && distance) {
|
|
4403
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-distance", distance, direction });
|
|
4404
|
+
}
|
|
4405
|
+
activeCell.focus();
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
},
|
|
4409
|
+
// TODO we recreate this function whenever viewportRange changes, which will
|
|
4410
|
+
// be often whilst scrolling - store range in a a ref ?
|
|
4411
|
+
[containerRef, requestScroll]
|
|
4412
|
+
);
|
|
4413
|
+
const setActiveCell = (0, import_react47.useCallback)(
|
|
4414
|
+
(rowIdx, colIdx, fromKeyboard = false) => {
|
|
4415
|
+
const pos = [rowIdx, colIdx];
|
|
4416
|
+
activeCellPos.current = pos;
|
|
4417
|
+
focusCell(pos);
|
|
4418
|
+
if (fromKeyboard) {
|
|
4419
|
+
focusedCellPos.current = pos;
|
|
4420
|
+
}
|
|
4421
|
+
},
|
|
4422
|
+
[focusCell]
|
|
4423
|
+
);
|
|
4424
|
+
const nextPageItemIdx = (0, import_react47.useCallback)(
|
|
4425
|
+
(key, [rowIdx, colIdx]) => new Promise((resolve) => {
|
|
4426
|
+
let newRowIdx = rowIdx;
|
|
4427
|
+
switch (key) {
|
|
4428
|
+
case "PageDown":
|
|
4429
|
+
newRowIdx = Math.min(rowCount - 1, rowIdx + viewportRowCount);
|
|
4430
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "down" });
|
|
4431
|
+
break;
|
|
4432
|
+
case "PageUp":
|
|
4433
|
+
newRowIdx = Math.max(0, rowIdx - viewportRowCount);
|
|
4434
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "up" });
|
|
4435
|
+
break;
|
|
4436
|
+
case "Home":
|
|
4437
|
+
newRowIdx = 0;
|
|
4438
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "home" });
|
|
4439
|
+
break;
|
|
4440
|
+
case "End":
|
|
4441
|
+
newRowIdx = rowCount - 1;
|
|
4442
|
+
requestScroll == null ? void 0 : requestScroll({ type: "scroll-end", direction: "end" });
|
|
4443
|
+
break;
|
|
4444
|
+
}
|
|
4445
|
+
setTimeout(() => {
|
|
4446
|
+
resolve([newRowIdx, colIdx]);
|
|
4447
|
+
}, 90);
|
|
4448
|
+
}),
|
|
4449
|
+
[requestScroll, rowCount, viewportRowCount]
|
|
4450
|
+
);
|
|
4451
|
+
const handleFocus = (0, import_react47.useCallback)(() => {
|
|
4452
|
+
var _a2;
|
|
4453
|
+
if (disableHighlightOnFocus !== true) {
|
|
4454
|
+
if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(document.activeElement)) {
|
|
4455
|
+
const focusedCell = getFocusedCell(document.activeElement);
|
|
4456
|
+
if (focusedCell) {
|
|
4457
|
+
console.log({ focusedCell });
|
|
4458
|
+
focusedCellPos.current = getTableCellPos(focusedCell);
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
}
|
|
4462
|
+
}, [disableHighlightOnFocus, containerRef]);
|
|
4463
|
+
const navigateChildItems = (0, import_react47.useCallback)(
|
|
4464
|
+
async (key) => {
|
|
4465
|
+
console.log(`navigate child items ${key}`);
|
|
4466
|
+
const [nextRowIdx, nextColIdx] = isPagingKey2(key) ? await nextPageItemIdx(key, activeCellPos.current) : nextCellPos(key, activeCellPos.current, columnCount, rowCount);
|
|
4467
|
+
console.log(`nextRowIdx ${nextRowIdx} nextColIdx ${nextColIdx}`);
|
|
4468
|
+
const [rowIdx, colIdx] = activeCellPos.current;
|
|
4469
|
+
if (nextRowIdx !== rowIdx || nextColIdx !== colIdx) {
|
|
4470
|
+
setActiveCell(nextRowIdx, nextColIdx, true);
|
|
4471
|
+
}
|
|
4472
|
+
},
|
|
4473
|
+
[columnCount, nextPageItemIdx, rowCount, setActiveCell]
|
|
4474
|
+
);
|
|
4475
|
+
const handleKeyDown = (0, import_react47.useCallback)(
|
|
4476
|
+
(e) => {
|
|
4477
|
+
if (rowCount > 0 && isNavigationKey2(e.key)) {
|
|
4478
|
+
e.preventDefault();
|
|
4479
|
+
e.stopPropagation();
|
|
4480
|
+
void navigateChildItems(e.key);
|
|
4481
|
+
}
|
|
4482
|
+
},
|
|
4483
|
+
[rowCount, navigateChildItems]
|
|
4484
|
+
);
|
|
4485
|
+
const handleClick = (0, import_react47.useCallback)(
|
|
4486
|
+
// Might not be a cell e.g the Settings button
|
|
4487
|
+
(evt) => {
|
|
4488
|
+
const target = evt.target;
|
|
4489
|
+
const focusedCell = getFocusedCell(target);
|
|
4490
|
+
if (focusedCell) {
|
|
4491
|
+
const [rowIdx, colIdx] = getTableCellPos(focusedCell);
|
|
4492
|
+
setActiveCell(rowIdx, colIdx);
|
|
4493
|
+
}
|
|
4494
|
+
},
|
|
4495
|
+
[setActiveCell]
|
|
4496
|
+
);
|
|
4497
|
+
const navigate = (0, import_react47.useCallback)(() => {
|
|
4498
|
+
navigateChildItems("ArrowDown");
|
|
4499
|
+
}, [navigateChildItems]);
|
|
4500
|
+
const containerProps = (0, import_react47.useMemo)(() => {
|
|
4501
|
+
return {
|
|
4502
|
+
navigate,
|
|
4503
|
+
onClick: handleClick,
|
|
4504
|
+
onFocus: handleFocus,
|
|
4505
|
+
onKeyDown: handleKeyDown
|
|
4506
|
+
};
|
|
4507
|
+
}, [handleClick, handleFocus, handleKeyDown, navigate]);
|
|
4508
|
+
const fullyRendered = ((_a = containerRef.current) == null ? void 0 : _a.firstChild) != null;
|
|
4509
|
+
(0, import_react47.useEffect)(() => {
|
|
4510
|
+
if (fullyRendered && focusableCell.current === void 0) {
|
|
4511
|
+
const { current: container } = containerRef;
|
|
4512
|
+
const cell = (container == null ? void 0 : container.querySelector(headerCellQuery(0))) || (container == null ? void 0 : container.querySelector(dataCellQuery(0, 0)));
|
|
4513
|
+
if (cell) {
|
|
4514
|
+
cell.setAttribute("tabindex", "0");
|
|
4515
|
+
focusableCell.current = cell;
|
|
4516
|
+
}
|
|
4517
|
+
}
|
|
4518
|
+
}, [containerRef, fullyRendered]);
|
|
4519
|
+
return containerProps;
|
|
4520
|
+
};
|
|
4521
|
+
|
|
4522
|
+
// ../vuu-table/src/table-next/useTableNext.ts
|
|
4523
|
+
var import_vuu_utils42 = require("@vuu-ui/vuu-utils");
|
|
4524
|
+
var import_react55 = require("react");
|
|
4525
|
+
|
|
4526
|
+
// ../vuu-table/src/table-next/table-config.ts
|
|
4527
|
+
var updateTableConfig = (config, action) => {
|
|
4528
|
+
switch (action.type) {
|
|
4529
|
+
case "col-size":
|
|
4530
|
+
return {
|
|
4531
|
+
...config,
|
|
4532
|
+
columns: config.columns.map(
|
|
4533
|
+
(col) => col.name === action.column.name ? { ...col, width: action.width } : col
|
|
4534
|
+
)
|
|
4535
|
+
};
|
|
4536
|
+
case "column-prop":
|
|
4537
|
+
return {
|
|
4538
|
+
...config,
|
|
3486
4539
|
columns: config.columns.map(
|
|
3487
4540
|
(col) => col.name === action.column.name ? { ...col, [action.property]: action.value } : col
|
|
3488
4541
|
)
|
|
@@ -3500,47 +4553,1316 @@ var import_react48 = require("react");
|
|
|
3500
4553
|
// ../vuu-table/src/table-next/moving-window.ts
|
|
3501
4554
|
var import_vuu_utils37 = require("@vuu-ui/vuu-utils");
|
|
3502
4555
|
var { SELECTED: SELECTED4 } = import_vuu_utils37.metadataKeys;
|
|
4556
|
+
var MovingWindow = class {
|
|
4557
|
+
constructor({ from, to }) {
|
|
4558
|
+
this.rowCount = 0;
|
|
4559
|
+
this.setRowCount = (rowCount) => {
|
|
4560
|
+
if (rowCount < this.data.length) {
|
|
4561
|
+
this.data.length = rowCount;
|
|
4562
|
+
}
|
|
4563
|
+
this.rowCount = rowCount;
|
|
4564
|
+
};
|
|
4565
|
+
this.range = new import_vuu_utils37.WindowRange(from, to);
|
|
4566
|
+
this.data = new Array(to - from);
|
|
4567
|
+
this.rowCount = 0;
|
|
4568
|
+
}
|
|
4569
|
+
add(data) {
|
|
4570
|
+
const [index] = data;
|
|
4571
|
+
if (this.isWithinRange(index)) {
|
|
4572
|
+
const internalIndex = index - this.range.from;
|
|
4573
|
+
this.data[internalIndex] = data;
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
getAtIndex(index) {
|
|
4577
|
+
return this.range.isWithin(index) && this.data[index - this.range.from] != null ? this.data[index - this.range.from] : void 0;
|
|
4578
|
+
}
|
|
4579
|
+
isWithinRange(index) {
|
|
4580
|
+
return this.range.isWithin(index);
|
|
4581
|
+
}
|
|
4582
|
+
setRange({ from, to }) {
|
|
4583
|
+
if (from !== this.range.from || to !== this.range.to) {
|
|
4584
|
+
const [overlapFrom, overlapTo] = this.range.overlap(from, to);
|
|
4585
|
+
const newData = new Array(Math.max(0, to - from));
|
|
4586
|
+
for (let i = overlapFrom; i < overlapTo; i++) {
|
|
4587
|
+
const data = this.getAtIndex(i);
|
|
4588
|
+
if (data) {
|
|
4589
|
+
const index = i - from;
|
|
4590
|
+
newData[index] = data;
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
this.data = newData;
|
|
4594
|
+
this.range.from = from;
|
|
4595
|
+
this.range.to = to;
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
getSelectedRows() {
|
|
4599
|
+
return this.data.filter((row) => row[SELECTED4] !== 0);
|
|
4600
|
+
}
|
|
4601
|
+
};
|
|
4602
|
+
|
|
4603
|
+
// ../vuu-table/src/table-next/useDataSource.ts
|
|
4604
|
+
var useDataSource2 = ({
|
|
4605
|
+
dataSource,
|
|
4606
|
+
onFeatureEnabled,
|
|
4607
|
+
onFeatureInvocation,
|
|
4608
|
+
onSizeChange,
|
|
4609
|
+
onSubscribed,
|
|
4610
|
+
range = import_vuu_utils38.NULL_RANGE,
|
|
4611
|
+
renderBufferSize = 0
|
|
4612
|
+
}) => {
|
|
4613
|
+
const [, forceUpdate] = (0, import_react48.useState)(null);
|
|
4614
|
+
const data = (0, import_react48.useRef)([]);
|
|
4615
|
+
const isMounted = (0, import_react48.useRef)(true);
|
|
4616
|
+
const hasUpdated = (0, import_react48.useRef)(false);
|
|
4617
|
+
const rangeRef = (0, import_react48.useRef)(import_vuu_utils38.NULL_RANGE);
|
|
4618
|
+
const dataWindow = (0, import_react48.useMemo)(
|
|
4619
|
+
() => new MovingWindow((0, import_vuu_utils38.getFullRange)(range, renderBufferSize)),
|
|
4620
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4621
|
+
[]
|
|
4622
|
+
);
|
|
4623
|
+
const setData = (0, import_react48.useCallback)(
|
|
4624
|
+
(updates) => {
|
|
4625
|
+
for (const row of updates) {
|
|
4626
|
+
dataWindow.add(row);
|
|
4627
|
+
}
|
|
4628
|
+
data.current = dataWindow.data;
|
|
4629
|
+
if (isMounted.current) {
|
|
4630
|
+
forceUpdate({});
|
|
4631
|
+
}
|
|
4632
|
+
},
|
|
4633
|
+
[dataWindow]
|
|
4634
|
+
);
|
|
4635
|
+
const datasourceMessageHandler = (0, import_react48.useCallback)(
|
|
4636
|
+
(message) => {
|
|
4637
|
+
if (message.type === "subscribed") {
|
|
4638
|
+
onSubscribed == null ? void 0 : onSubscribed(message);
|
|
4639
|
+
} else if (message.type === "viewport-update") {
|
|
4640
|
+
if (typeof message.size === "number") {
|
|
4641
|
+
onSizeChange == null ? void 0 : onSizeChange(message.size);
|
|
4642
|
+
dataWindow.setRowCount(message.size);
|
|
4643
|
+
}
|
|
4644
|
+
if (message.rows) {
|
|
4645
|
+
setData(message.rows);
|
|
4646
|
+
} else if (typeof message.size === "number") {
|
|
4647
|
+
data.current = dataWindow.data;
|
|
4648
|
+
hasUpdated.current = true;
|
|
4649
|
+
}
|
|
4650
|
+
} else if ((0, import_src.isVuuFeatureAction)(message)) {
|
|
4651
|
+
onFeatureEnabled == null ? void 0 : onFeatureEnabled(message);
|
|
4652
|
+
} else if ((0, import_src.isVuuFeatureInvocation)(message)) {
|
|
4653
|
+
onFeatureInvocation == null ? void 0 : onFeatureInvocation(message);
|
|
4654
|
+
} else {
|
|
4655
|
+
console.log(`useDataSource unexpected message ${message.type}`);
|
|
4656
|
+
}
|
|
4657
|
+
},
|
|
4658
|
+
[
|
|
4659
|
+
dataWindow,
|
|
4660
|
+
onFeatureEnabled,
|
|
4661
|
+
onFeatureInvocation,
|
|
4662
|
+
onSizeChange,
|
|
4663
|
+
onSubscribed,
|
|
4664
|
+
setData
|
|
4665
|
+
]
|
|
4666
|
+
);
|
|
4667
|
+
(0, import_react48.useEffect)(
|
|
4668
|
+
() => () => {
|
|
4669
|
+
isMounted.current = true;
|
|
4670
|
+
isMounted.current = false;
|
|
4671
|
+
},
|
|
4672
|
+
[]
|
|
4673
|
+
);
|
|
4674
|
+
(0, import_react48.useEffect)(() => {
|
|
4675
|
+
dataSource == null ? void 0 : dataSource.subscribe(
|
|
4676
|
+
{ range: (0, import_vuu_utils38.getFullRange)(range, renderBufferSize) },
|
|
4677
|
+
datasourceMessageHandler
|
|
4678
|
+
);
|
|
4679
|
+
}, [dataSource, datasourceMessageHandler, range, renderBufferSize]);
|
|
4680
|
+
const setRange = (0, import_react48.useCallback)(
|
|
4681
|
+
(range2) => {
|
|
4682
|
+
const fullRange = (0, import_vuu_utils38.getFullRange)(range2, renderBufferSize);
|
|
4683
|
+
dataWindow.setRange(fullRange);
|
|
4684
|
+
dataSource.range = rangeRef.current = fullRange;
|
|
4685
|
+
dataSource.emit("range", range2);
|
|
4686
|
+
},
|
|
4687
|
+
[dataSource, dataWindow, renderBufferSize]
|
|
4688
|
+
);
|
|
4689
|
+
return {
|
|
4690
|
+
data: data.current,
|
|
4691
|
+
range: rangeRef.current,
|
|
4692
|
+
setRange
|
|
4693
|
+
};
|
|
4694
|
+
};
|
|
3503
4695
|
|
|
3504
4696
|
// ../vuu-table/src/table-next/useInitialValue.ts
|
|
3505
4697
|
var import_react49 = require("react");
|
|
4698
|
+
var useInitialValue = (value) => {
|
|
4699
|
+
const ref = (0, import_react49.useRef)(value);
|
|
4700
|
+
return (0, import_react49.useMemo)(() => ref.current, []);
|
|
4701
|
+
};
|
|
3506
4702
|
|
|
3507
4703
|
// ../vuu-table/src/table-next/useTableContextMenu.ts
|
|
3508
4704
|
var import_vuu_utils39 = require("@vuu-ui/vuu-utils");
|
|
3509
4705
|
var import_react50 = require("react");
|
|
3510
4706
|
var import_vuu_popups6 = require("@vuu-ui/vuu-popups");
|
|
4707
|
+
var useTableContextMenu2 = ({
|
|
4708
|
+
columns,
|
|
4709
|
+
data
|
|
4710
|
+
}) => {
|
|
4711
|
+
const [showContextMenu] = (0, import_vuu_popups6.useContextMenu)();
|
|
4712
|
+
const onContextMenu = (0, import_react50.useCallback)(
|
|
4713
|
+
(evt) => {
|
|
4714
|
+
var _a;
|
|
4715
|
+
const target = evt.target;
|
|
4716
|
+
const cellEl = target == null ? void 0 : target.closest("div[role='cell']");
|
|
4717
|
+
const rowEl = target == null ? void 0 : target.closest("div[role='row']");
|
|
4718
|
+
if (cellEl && rowEl) {
|
|
4719
|
+
const columnMap = (0, import_vuu_utils39.buildColumnMap)(columns);
|
|
4720
|
+
const rowIndex = parseInt((_a = rowEl.ariaRowIndex) != null ? _a : "-1");
|
|
4721
|
+
const cellIndex = Array.from(rowEl.childNodes).indexOf(cellEl);
|
|
4722
|
+
const row = data.find(([idx]) => idx === rowIndex);
|
|
4723
|
+
const columnName = columns[cellIndex];
|
|
4724
|
+
showContextMenu(evt, "grid", {
|
|
4725
|
+
columnMap,
|
|
4726
|
+
columnName,
|
|
4727
|
+
row
|
|
4728
|
+
// selectedRows: selectedRowsCount === 0 ? NO_ROWS : getSelectedRows(),
|
|
4729
|
+
// viewport: dataSource?.viewport,
|
|
4730
|
+
});
|
|
4731
|
+
}
|
|
4732
|
+
},
|
|
4733
|
+
[columns, data, showContextMenu]
|
|
4734
|
+
);
|
|
4735
|
+
return onContextMenu;
|
|
4736
|
+
};
|
|
3511
4737
|
|
|
3512
4738
|
// ../vuu-table/src/table-next/useCellEditing.ts
|
|
3513
4739
|
var import_vuu_utils40 = require("@vuu-ui/vuu-utils");
|
|
3514
4740
|
var import_react51 = require("react");
|
|
4741
|
+
var useCellEditing = ({ navigate }) => {
|
|
4742
|
+
const commitHandler = (0, import_react51.useCallback)(() => {
|
|
4743
|
+
navigate();
|
|
4744
|
+
}, [navigate]);
|
|
4745
|
+
const editInput = (0, import_react51.useCallback)(
|
|
4746
|
+
(evt) => {
|
|
4747
|
+
const cellEl = evt.target;
|
|
4748
|
+
const input = cellEl.querySelector("input");
|
|
4749
|
+
if (input) {
|
|
4750
|
+
input.focus();
|
|
4751
|
+
input.select();
|
|
4752
|
+
}
|
|
4753
|
+
cellEl.addEventListener("vuu-commit", commitHandler, true);
|
|
4754
|
+
},
|
|
4755
|
+
[commitHandler]
|
|
4756
|
+
);
|
|
4757
|
+
const focusInput = (0, import_react51.useCallback)(
|
|
4758
|
+
(evt) => {
|
|
4759
|
+
const cellEl = evt.target;
|
|
4760
|
+
const input = cellEl.querySelector("input");
|
|
4761
|
+
if (input) {
|
|
4762
|
+
input.focus();
|
|
4763
|
+
input.select();
|
|
4764
|
+
}
|
|
4765
|
+
cellEl.addEventListener("vuu-commit", commitHandler, true);
|
|
4766
|
+
},
|
|
4767
|
+
[commitHandler]
|
|
4768
|
+
);
|
|
4769
|
+
const handleKeyDown = (0, import_react51.useCallback)(
|
|
4770
|
+
(e) => {
|
|
4771
|
+
if (cellIsTextInput(e.target)) {
|
|
4772
|
+
if ((0, import_vuu_utils40.isCharacterKey)(e.key)) {
|
|
4773
|
+
editInput(e);
|
|
4774
|
+
} else if (e.key === "Enter") {
|
|
4775
|
+
focusInput(e);
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4778
|
+
},
|
|
4779
|
+
[editInput, focusInput]
|
|
4780
|
+
);
|
|
4781
|
+
return {
|
|
4782
|
+
onKeyDown: handleKeyDown
|
|
4783
|
+
};
|
|
4784
|
+
};
|
|
3515
4785
|
|
|
3516
4786
|
// ../vuu-table/src/table-next/useTableModel.ts
|
|
3517
4787
|
var import_vuu_utils41 = require("@vuu-ui/vuu-utils");
|
|
3518
4788
|
var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
|
|
3519
4789
|
var import_react52 = require("react");
|
|
3520
4790
|
var { info } = (0, import_vuu_utils41.logger)("useTableModel");
|
|
4791
|
+
var DEFAULT_COLUMN_WIDTH = 100;
|
|
3521
4792
|
var KEY_OFFSET2 = import_vuu_utils41.metadataKeys.count;
|
|
4793
|
+
var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
|
|
4794
|
+
var getCellRendererForColumn = (column) => {
|
|
4795
|
+
var _a;
|
|
4796
|
+
if ((0, import_vuu_utils41.isTypeDescriptor)(column.type)) {
|
|
4797
|
+
return (0, import_vuu_utils41.getCellRenderer)((_a = column.type) == null ? void 0 : _a.renderer);
|
|
4798
|
+
}
|
|
4799
|
+
};
|
|
4800
|
+
var getDataType = (column, tableSchema) => {
|
|
4801
|
+
var _a;
|
|
4802
|
+
const schemaColumn = tableSchema.columns.find(
|
|
4803
|
+
({ name: name2 }) => name2 === column.name
|
|
4804
|
+
);
|
|
4805
|
+
if (schemaColumn) {
|
|
4806
|
+
return schemaColumn.serverDataType;
|
|
4807
|
+
} else {
|
|
4808
|
+
return (_a = column.serverDataType) != null ? _a : "string";
|
|
4809
|
+
}
|
|
4810
|
+
};
|
|
4811
|
+
var numericTypes = ["int", "long", "double"];
|
|
4812
|
+
var getDefaultAlignment3 = (serverDataType) => serverDataType === void 0 ? void 0 : numericTypes.includes(serverDataType) ? "right" : "left";
|
|
4813
|
+
var isShowColumnSettings = (action) => action.type === "columnSettings";
|
|
4814
|
+
var isShowTableSettings = (action) => action.type === "tableSettings";
|
|
4815
|
+
var columnReducer = (state, action) => {
|
|
4816
|
+
info == null ? void 0 : info(`TableModelReducer ${action.type}`);
|
|
4817
|
+
console.log(`TableModelReducer ${action.type}`);
|
|
4818
|
+
switch (action.type) {
|
|
4819
|
+
case "init":
|
|
4820
|
+
console.log({ init: action });
|
|
4821
|
+
return init(action);
|
|
4822
|
+
case "moveColumn":
|
|
4823
|
+
return moveColumn(state, action);
|
|
4824
|
+
case "resizeColumn":
|
|
4825
|
+
return resizeColumn(state, action);
|
|
4826
|
+
case "setTableSchema":
|
|
4827
|
+
return setTableSchema(state, action);
|
|
4828
|
+
case "hideColumns":
|
|
4829
|
+
return hideColumns(state, action);
|
|
4830
|
+
case "showColumns":
|
|
4831
|
+
return showColumns(state, action);
|
|
4832
|
+
case "pinColumn":
|
|
4833
|
+
return pinColumn2(state, action);
|
|
4834
|
+
case "updateColumnProp":
|
|
4835
|
+
return updateColumnProp(state, action);
|
|
4836
|
+
case "tableConfig":
|
|
4837
|
+
return updateTableConfig2(state, action);
|
|
4838
|
+
default:
|
|
4839
|
+
console.log(`unhandled action ${action.type}`);
|
|
4840
|
+
return state;
|
|
4841
|
+
}
|
|
4842
|
+
};
|
|
4843
|
+
var useTableModel2 = (tableConfigProp, dataSourceConfig) => {
|
|
4844
|
+
const [state, dispatchColumnAction] = (0, import_react52.useReducer)(columnReducer, { tableConfig: tableConfigProp, dataSourceConfig }, init);
|
|
4845
|
+
const { columns, headings, tableConfig, ...tableAttributes } = state;
|
|
4846
|
+
return {
|
|
4847
|
+
columns,
|
|
4848
|
+
dispatchColumnAction,
|
|
4849
|
+
headings,
|
|
4850
|
+
tableAttributes,
|
|
4851
|
+
tableConfig
|
|
4852
|
+
};
|
|
4853
|
+
};
|
|
4854
|
+
function init({
|
|
4855
|
+
dataSourceConfig,
|
|
4856
|
+
tableConfig
|
|
4857
|
+
}) {
|
|
4858
|
+
const { columns, ...tableAttributes } = tableConfig;
|
|
4859
|
+
const keyedColumns = columns.filter((0, import_vuu_utils41.subscribedOnly)(dataSourceConfig == null ? void 0 : dataSourceConfig.columns)).map(columnDescriptorToKeyedColumDescriptor(tableAttributes));
|
|
4860
|
+
const maybePinnedColumns = keyedColumns.some(import_vuu_utils41.isPinned) ? (0, import_vuu_utils41.sortPinnedColumns)(keyedColumns) : keyedColumns;
|
|
4861
|
+
let state = {
|
|
4862
|
+
columns: maybePinnedColumns,
|
|
4863
|
+
headings: (0, import_vuu_utils41.getTableHeadings)(maybePinnedColumns),
|
|
4864
|
+
tableConfig,
|
|
4865
|
+
...tableAttributes
|
|
4866
|
+
};
|
|
4867
|
+
if (dataSourceConfig) {
|
|
4868
|
+
const { columns: _, ...rest } = dataSourceConfig;
|
|
4869
|
+
state = updateTableConfig2(state, {
|
|
4870
|
+
type: "tableConfig",
|
|
4871
|
+
...rest
|
|
4872
|
+
});
|
|
4873
|
+
}
|
|
4874
|
+
return state;
|
|
4875
|
+
}
|
|
4876
|
+
var getLabel = (label, columnFormatHeader) => {
|
|
4877
|
+
if (columnFormatHeader === "uppercase") {
|
|
4878
|
+
return label.toUpperCase();
|
|
4879
|
+
} else if (columnFormatHeader === "capitalize") {
|
|
4880
|
+
return label[0].toUpperCase() + label.slice(1).toLowerCase();
|
|
4881
|
+
}
|
|
4882
|
+
return label;
|
|
4883
|
+
};
|
|
4884
|
+
var columnDescriptorToKeyedColumDescriptor = (tableAttributes) => (column, index) => {
|
|
4885
|
+
const { columnDefaultWidth = DEFAULT_COLUMN_WIDTH, columnFormatHeader } = tableAttributes;
|
|
4886
|
+
const {
|
|
4887
|
+
align = getDefaultAlignment3(column.serverDataType),
|
|
4888
|
+
key,
|
|
4889
|
+
name: name2,
|
|
4890
|
+
label = name2,
|
|
4891
|
+
width = columnDefaultWidth,
|
|
4892
|
+
...rest
|
|
4893
|
+
} = column;
|
|
4894
|
+
const keyedColumnWithDefaults = {
|
|
4895
|
+
...rest,
|
|
4896
|
+
align,
|
|
4897
|
+
CellRenderer: getCellRendererForColumn(column),
|
|
4898
|
+
clientSideEditValidationCheck: (0, import_vuu_utils41.hasValidationRules)(column.type) ? (0, import_vuu_ui_controls7.buildValidationChecker)(column.type.renderer.rules) : void 0,
|
|
4899
|
+
label: getLabel(label, columnFormatHeader),
|
|
4900
|
+
key: key != null ? key : index + KEY_OFFSET2,
|
|
4901
|
+
name: name2,
|
|
4902
|
+
originalIdx: index,
|
|
4903
|
+
valueFormatter: (0, import_vuu_utils41.getValueFormatter)(column),
|
|
4904
|
+
width
|
|
4905
|
+
};
|
|
4906
|
+
if ((0, import_vuu_utils41.isGroupColumn)(keyedColumnWithDefaults)) {
|
|
4907
|
+
keyedColumnWithDefaults.columns = keyedColumnWithDefaults.columns.map(
|
|
4908
|
+
(col) => columnDescriptorToKeyedColumDescriptor(tableAttributes)(col, col.key)
|
|
4909
|
+
);
|
|
4910
|
+
}
|
|
4911
|
+
return keyedColumnWithDefaults;
|
|
4912
|
+
};
|
|
4913
|
+
function moveColumn(state, { column, moveBy, moveTo }) {
|
|
4914
|
+
const { columns } = state;
|
|
4915
|
+
if (typeof moveBy === "number") {
|
|
4916
|
+
const idx = columns.indexOf(column);
|
|
4917
|
+
const newColumns = columns.slice();
|
|
4918
|
+
const [movedColumns] = newColumns.splice(idx, 1);
|
|
4919
|
+
newColumns.splice(idx + moveBy, 0, movedColumns);
|
|
4920
|
+
return {
|
|
4921
|
+
...state,
|
|
4922
|
+
columns: newColumns
|
|
4923
|
+
};
|
|
4924
|
+
} else if (typeof moveTo === "number") {
|
|
4925
|
+
const index = columns.indexOf(column);
|
|
4926
|
+
return {
|
|
4927
|
+
...state,
|
|
4928
|
+
columns: (0, import_vuu_utils41.moveItem)(columns, index, moveTo)
|
|
4929
|
+
};
|
|
4930
|
+
}
|
|
4931
|
+
return state;
|
|
4932
|
+
}
|
|
4933
|
+
function hideColumns(state, { columns }) {
|
|
4934
|
+
if (columns.some((col) => col.hidden !== true)) {
|
|
4935
|
+
return columns.reduce((s, c) => {
|
|
4936
|
+
if (c.hidden !== true) {
|
|
4937
|
+
return updateColumnProp(s, {
|
|
4938
|
+
type: "updateColumnProp",
|
|
4939
|
+
column: c,
|
|
4940
|
+
hidden: true
|
|
4941
|
+
});
|
|
4942
|
+
} else {
|
|
4943
|
+
return s;
|
|
4944
|
+
}
|
|
4945
|
+
}, state);
|
|
4946
|
+
} else {
|
|
4947
|
+
return state;
|
|
4948
|
+
}
|
|
4949
|
+
}
|
|
4950
|
+
function showColumns(state, { columns }) {
|
|
4951
|
+
if (columns.some((col) => col.hidden)) {
|
|
4952
|
+
return columns.reduce((s, c) => {
|
|
4953
|
+
if (c.hidden) {
|
|
4954
|
+
return updateColumnProp(s, {
|
|
4955
|
+
type: "updateColumnProp",
|
|
4956
|
+
column: c,
|
|
4957
|
+
hidden: false
|
|
4958
|
+
});
|
|
4959
|
+
} else {
|
|
4960
|
+
return s;
|
|
4961
|
+
}
|
|
4962
|
+
}, state);
|
|
4963
|
+
} else {
|
|
4964
|
+
return state;
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
function resizeColumn(state, { column, phase, width }) {
|
|
4968
|
+
const type = "updateColumnProp";
|
|
4969
|
+
const resizing = phase !== "end";
|
|
4970
|
+
switch (phase) {
|
|
4971
|
+
case "begin":
|
|
4972
|
+
return updateColumnProp(state, { type, column, resizing });
|
|
4973
|
+
case "end":
|
|
4974
|
+
return updateColumnProp(state, { type, column, resizing, width });
|
|
4975
|
+
case "resize":
|
|
4976
|
+
return updateColumnProp(state, { type, column, width });
|
|
4977
|
+
default:
|
|
4978
|
+
throw Error(`useTableModel.resizeColumn, invalid resizePhase ${phase}`);
|
|
4979
|
+
}
|
|
4980
|
+
}
|
|
4981
|
+
function setTableSchema(state, { tableSchema }) {
|
|
4982
|
+
const { columns } = state;
|
|
4983
|
+
if (columns.some(columnWithoutDataType)) {
|
|
4984
|
+
const cols = columns.map((column) => {
|
|
4985
|
+
var _a;
|
|
4986
|
+
const serverDataType = getDataType(column, tableSchema);
|
|
4987
|
+
return {
|
|
4988
|
+
...column,
|
|
4989
|
+
align: (_a = column.align) != null ? _a : getDefaultAlignment3(serverDataType),
|
|
4990
|
+
serverDataType
|
|
4991
|
+
};
|
|
4992
|
+
});
|
|
4993
|
+
return {
|
|
4994
|
+
...state,
|
|
4995
|
+
columns: cols
|
|
4996
|
+
};
|
|
4997
|
+
} else {
|
|
4998
|
+
return state;
|
|
4999
|
+
}
|
|
5000
|
+
}
|
|
5001
|
+
function pinColumn2(state, action) {
|
|
5002
|
+
let { columns } = state;
|
|
5003
|
+
const { column, pin } = action;
|
|
5004
|
+
const targetColumn = columns.find((col) => col.name === column.name);
|
|
5005
|
+
if (targetColumn) {
|
|
5006
|
+
columns = replaceColumn2(columns, { ...targetColumn, pin });
|
|
5007
|
+
columns = (0, import_vuu_utils41.sortPinnedColumns)(columns);
|
|
5008
|
+
return {
|
|
5009
|
+
...state,
|
|
5010
|
+
columns
|
|
5011
|
+
};
|
|
5012
|
+
} else {
|
|
5013
|
+
return state;
|
|
5014
|
+
}
|
|
5015
|
+
}
|
|
5016
|
+
function updateColumnProp(state, action) {
|
|
5017
|
+
let { columns } = state;
|
|
5018
|
+
const { align, column, hidden, label, resizing, width } = action;
|
|
5019
|
+
const targetColumn = columns.find((col) => col.name === column.name);
|
|
5020
|
+
if (targetColumn) {
|
|
5021
|
+
if (align === "left" || align === "right") {
|
|
5022
|
+
columns = replaceColumn2(columns, { ...targetColumn, align });
|
|
5023
|
+
}
|
|
5024
|
+
if (typeof label === "string") {
|
|
5025
|
+
columns = replaceColumn2(columns, { ...targetColumn, label });
|
|
5026
|
+
}
|
|
5027
|
+
if (typeof resizing === "boolean") {
|
|
5028
|
+
columns = replaceColumn2(columns, { ...targetColumn, resizing });
|
|
5029
|
+
}
|
|
5030
|
+
if (typeof hidden === "boolean") {
|
|
5031
|
+
columns = replaceColumn2(columns, { ...targetColumn, hidden });
|
|
5032
|
+
}
|
|
5033
|
+
if (typeof width === "number") {
|
|
5034
|
+
columns = replaceColumn2(columns, { ...targetColumn, width });
|
|
5035
|
+
}
|
|
5036
|
+
}
|
|
5037
|
+
return {
|
|
5038
|
+
...state,
|
|
5039
|
+
columns
|
|
5040
|
+
};
|
|
5041
|
+
}
|
|
5042
|
+
function updateTableConfig2(state, { confirmed, filter, groupBy, sort }) {
|
|
5043
|
+
const hasGroupBy = groupBy !== void 0;
|
|
5044
|
+
const hasFilter = typeof (filter == null ? void 0 : filter.filter) === "string";
|
|
5045
|
+
const hasSort = sort && sort.sortDefs.length > 0;
|
|
5046
|
+
let result = state;
|
|
5047
|
+
if (hasGroupBy) {
|
|
5048
|
+
result = {
|
|
5049
|
+
...state,
|
|
5050
|
+
columns: (0, import_vuu_utils41.applyGroupByToColumns)(result.columns, groupBy, confirmed)
|
|
5051
|
+
};
|
|
5052
|
+
}
|
|
5053
|
+
if (hasSort) {
|
|
5054
|
+
result = {
|
|
5055
|
+
...state,
|
|
5056
|
+
columns: (0, import_vuu_utils41.applySortToColumns)(result.columns, sort)
|
|
5057
|
+
};
|
|
5058
|
+
}
|
|
5059
|
+
if (hasFilter) {
|
|
5060
|
+
result = {
|
|
5061
|
+
...state,
|
|
5062
|
+
columns: (0, import_vuu_utils41.applyFilterToColumns)(result.columns, filter)
|
|
5063
|
+
};
|
|
5064
|
+
} else if (result.columns.some(import_vuu_utils41.isFilteredColumn)) {
|
|
5065
|
+
result = {
|
|
5066
|
+
...state,
|
|
5067
|
+
columns: (0, import_vuu_utils41.stripFilterFromColumns)(result.columns)
|
|
5068
|
+
};
|
|
5069
|
+
}
|
|
5070
|
+
return result;
|
|
5071
|
+
}
|
|
5072
|
+
function replaceColumn2(state, column) {
|
|
5073
|
+
return state.map((col) => col.name === column.name ? column : col);
|
|
5074
|
+
}
|
|
3522
5075
|
|
|
3523
5076
|
// ../vuu-table/src/table-next/useTableScroll.ts
|
|
3524
5077
|
var import_react53 = require("react");
|
|
5078
|
+
var getPctScroll = (container) => {
|
|
5079
|
+
const { scrollLeft, scrollTop } = container;
|
|
5080
|
+
const { clientHeight, clientWidth, scrollHeight, scrollWidth } = container;
|
|
5081
|
+
const pctScrollLeft = scrollLeft / (scrollWidth - clientWidth);
|
|
5082
|
+
const pctScrollTop = scrollTop / (scrollHeight - clientHeight);
|
|
5083
|
+
return [pctScrollLeft, pctScrollTop];
|
|
5084
|
+
};
|
|
5085
|
+
var useCallbackRef = ({
|
|
5086
|
+
onAttach,
|
|
5087
|
+
onDetach
|
|
5088
|
+
}) => {
|
|
5089
|
+
const ref = (0, import_react53.useRef)(null);
|
|
5090
|
+
const callbackRef = (0, import_react53.useCallback)(
|
|
5091
|
+
(el) => {
|
|
5092
|
+
if (el) {
|
|
5093
|
+
ref.current = el;
|
|
5094
|
+
onAttach == null ? void 0 : onAttach(el);
|
|
5095
|
+
} else if (ref.current) {
|
|
5096
|
+
const { current: originalRef } = ref;
|
|
5097
|
+
ref.current = el;
|
|
5098
|
+
onDetach == null ? void 0 : onDetach(originalRef);
|
|
5099
|
+
}
|
|
5100
|
+
},
|
|
5101
|
+
[onAttach, onDetach]
|
|
5102
|
+
);
|
|
5103
|
+
return callbackRef;
|
|
5104
|
+
};
|
|
5105
|
+
var useTableScroll2 = ({
|
|
5106
|
+
maxScrollLeft,
|
|
5107
|
+
maxScrollTop,
|
|
5108
|
+
onHorizontalScroll,
|
|
5109
|
+
onVerticalScroll,
|
|
5110
|
+
rowHeight,
|
|
5111
|
+
viewportRowCount
|
|
5112
|
+
}) => {
|
|
5113
|
+
const contentContainerScrolledRef = (0, import_react53.useRef)(false);
|
|
5114
|
+
const scrollPosRef = (0, import_react53.useRef)({ scrollTop: 0, scrollLeft: 0 });
|
|
5115
|
+
const scrollbarContainerRef = (0, import_react53.useRef)(null);
|
|
5116
|
+
const contentContainerRef = (0, import_react53.useRef)(null);
|
|
5117
|
+
const handleScrollbarContainerScroll = (0, import_react53.useCallback)(() => {
|
|
5118
|
+
const { current: contentContainer } = contentContainerRef;
|
|
5119
|
+
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
5120
|
+
const { current: contentContainerScrolled } = contentContainerScrolledRef;
|
|
5121
|
+
if (contentContainerScrolled) {
|
|
5122
|
+
contentContainerScrolledRef.current = false;
|
|
5123
|
+
} else if (contentContainer && scrollbarContainer) {
|
|
5124
|
+
const [pctScrollLeft, pctScrollTop] = getPctScroll(scrollbarContainer);
|
|
5125
|
+
const rootScrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
5126
|
+
const rootScrollTop = Math.round(pctScrollTop * maxScrollTop);
|
|
5127
|
+
contentContainer.scrollTo({
|
|
5128
|
+
left: rootScrollLeft,
|
|
5129
|
+
top: rootScrollTop,
|
|
5130
|
+
behavior: "auto"
|
|
5131
|
+
});
|
|
5132
|
+
}
|
|
5133
|
+
}, [maxScrollLeft, maxScrollTop]);
|
|
5134
|
+
const handleContentContainerScroll = (0, import_react53.useCallback)(() => {
|
|
5135
|
+
const { current: contentContainer } = contentContainerRef;
|
|
5136
|
+
const { current: scrollbarContainer } = scrollbarContainerRef;
|
|
5137
|
+
const { current: scrollPos } = scrollPosRef;
|
|
5138
|
+
if (contentContainer && scrollbarContainer) {
|
|
5139
|
+
const { scrollLeft, scrollTop } = contentContainer;
|
|
5140
|
+
const [pctScrollLeft, pctScrollTop] = getPctScroll(contentContainer);
|
|
5141
|
+
contentContainerScrolledRef.current = true;
|
|
5142
|
+
scrollbarContainer.scrollLeft = Math.round(pctScrollLeft * maxScrollLeft);
|
|
5143
|
+
scrollbarContainer.scrollTop = Math.round(pctScrollTop * maxScrollTop);
|
|
5144
|
+
if (scrollPos.scrollTop !== scrollTop) {
|
|
5145
|
+
scrollPos.scrollTop = scrollTop;
|
|
5146
|
+
onVerticalScroll == null ? void 0 : onVerticalScroll(scrollTop, pctScrollTop);
|
|
5147
|
+
}
|
|
5148
|
+
if (scrollPos.scrollLeft !== scrollLeft) {
|
|
5149
|
+
scrollPos.scrollLeft = scrollLeft;
|
|
5150
|
+
onHorizontalScroll == null ? void 0 : onHorizontalScroll(scrollLeft);
|
|
5151
|
+
}
|
|
5152
|
+
}
|
|
5153
|
+
}, [maxScrollLeft, maxScrollTop, onHorizontalScroll, onVerticalScroll]);
|
|
5154
|
+
const handleAttachScrollbarContainer = (0, import_react53.useCallback)(
|
|
5155
|
+
(el) => {
|
|
5156
|
+
scrollbarContainerRef.current = el;
|
|
5157
|
+
el.addEventListener("scroll", handleScrollbarContainerScroll, {
|
|
5158
|
+
passive: true
|
|
5159
|
+
});
|
|
5160
|
+
},
|
|
5161
|
+
[handleScrollbarContainerScroll]
|
|
5162
|
+
);
|
|
5163
|
+
const handleDetachScrollbarContainer = (0, import_react53.useCallback)(
|
|
5164
|
+
(el) => {
|
|
5165
|
+
scrollbarContainerRef.current = null;
|
|
5166
|
+
el.removeEventListener("scroll", handleScrollbarContainerScroll);
|
|
5167
|
+
},
|
|
5168
|
+
[handleScrollbarContainerScroll]
|
|
5169
|
+
);
|
|
5170
|
+
const handleAttachContentContainer = (0, import_react53.useCallback)(
|
|
5171
|
+
(el) => {
|
|
5172
|
+
contentContainerRef.current = el;
|
|
5173
|
+
el.addEventListener("scroll", handleContentContainerScroll, {
|
|
5174
|
+
passive: true
|
|
5175
|
+
});
|
|
5176
|
+
},
|
|
5177
|
+
[handleContentContainerScroll]
|
|
5178
|
+
);
|
|
5179
|
+
const handleDetachContentContainer = (0, import_react53.useCallback)(
|
|
5180
|
+
(el) => {
|
|
5181
|
+
contentContainerRef.current = null;
|
|
5182
|
+
el.removeEventListener("scroll", handleContentContainerScroll);
|
|
5183
|
+
},
|
|
5184
|
+
[handleContentContainerScroll]
|
|
5185
|
+
);
|
|
5186
|
+
const contentContainerCallbackRef = useCallbackRef({
|
|
5187
|
+
onAttach: handleAttachContentContainer,
|
|
5188
|
+
onDetach: handleDetachContentContainer
|
|
5189
|
+
});
|
|
5190
|
+
const scrollbarContainerCallbackRef = useCallbackRef({
|
|
5191
|
+
onAttach: handleAttachScrollbarContainer,
|
|
5192
|
+
onDetach: handleDetachScrollbarContainer
|
|
5193
|
+
});
|
|
5194
|
+
const requestScroll = (0, import_react53.useCallback)(
|
|
5195
|
+
(scrollRequest) => {
|
|
5196
|
+
const { current: scrollbarContainer } = contentContainerRef;
|
|
5197
|
+
if (scrollbarContainer) {
|
|
5198
|
+
const { scrollLeft, scrollTop } = scrollbarContainer;
|
|
5199
|
+
contentContainerScrolledRef.current = false;
|
|
5200
|
+
if (scrollRequest.type === "scroll-distance") {
|
|
5201
|
+
let newScrollLeft = scrollLeft;
|
|
5202
|
+
let newScrollTop = scrollTop;
|
|
5203
|
+
if (scrollRequest.direction === "up" || scrollRequest.direction === "down") {
|
|
5204
|
+
newScrollTop = Math.min(
|
|
5205
|
+
Math.max(0, scrollTop + scrollRequest.distance),
|
|
5206
|
+
maxScrollTop
|
|
5207
|
+
);
|
|
5208
|
+
} else {
|
|
5209
|
+
newScrollLeft = Math.min(
|
|
5210
|
+
Math.max(0, scrollLeft + scrollRequest.distance),
|
|
5211
|
+
maxScrollLeft
|
|
5212
|
+
);
|
|
5213
|
+
}
|
|
5214
|
+
scrollbarContainer.scrollTo({
|
|
5215
|
+
top: newScrollTop,
|
|
5216
|
+
left: newScrollLeft,
|
|
5217
|
+
behavior: "auto"
|
|
5218
|
+
});
|
|
5219
|
+
} else if (scrollRequest.type === "scroll-page") {
|
|
5220
|
+
const { direction } = scrollRequest;
|
|
5221
|
+
const scrollBy = viewportRowCount * (direction === "down" ? rowHeight : -rowHeight);
|
|
5222
|
+
const newScrollTop = Math.min(
|
|
5223
|
+
Math.max(0, scrollTop + scrollBy),
|
|
5224
|
+
maxScrollTop
|
|
5225
|
+
);
|
|
5226
|
+
scrollbarContainer.scrollTo({
|
|
5227
|
+
top: newScrollTop,
|
|
5228
|
+
left: scrollLeft,
|
|
5229
|
+
behavior: "auto"
|
|
5230
|
+
});
|
|
5231
|
+
} else if (scrollRequest.type === "scroll-end") {
|
|
5232
|
+
const { direction } = scrollRequest;
|
|
5233
|
+
const scrollTo = direction === "end" ? maxScrollTop : 0;
|
|
5234
|
+
scrollbarContainer.scrollTo({
|
|
5235
|
+
top: scrollTo,
|
|
5236
|
+
left: scrollbarContainer.scrollLeft,
|
|
5237
|
+
behavior: "auto"
|
|
5238
|
+
});
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
},
|
|
5242
|
+
[maxScrollLeft, maxScrollTop, rowHeight, viewportRowCount]
|
|
5243
|
+
);
|
|
5244
|
+
return {
|
|
5245
|
+
/** Ref to be assigned to ScrollbarContainer */
|
|
5246
|
+
scrollbarContainerRef: scrollbarContainerCallbackRef,
|
|
5247
|
+
/** Ref to be assigned to ContentContainer */
|
|
5248
|
+
contentContainerRef: contentContainerCallbackRef,
|
|
5249
|
+
/** Scroll the table */
|
|
5250
|
+
requestScroll
|
|
5251
|
+
};
|
|
5252
|
+
};
|
|
3525
5253
|
|
|
3526
5254
|
// ../vuu-table/src/table-next/useVirtualViewport.ts
|
|
3527
5255
|
var import_react54 = require("react");
|
|
5256
|
+
var useVirtualViewport2 = ({
|
|
5257
|
+
columns,
|
|
5258
|
+
getRowAtPosition,
|
|
5259
|
+
setRange,
|
|
5260
|
+
viewportMeasurements
|
|
5261
|
+
}) => {
|
|
5262
|
+
const firstRowRef = (0, import_react54.useRef)(0);
|
|
5263
|
+
const { contentWidth, rowCount: viewportRowCount } = viewportMeasurements;
|
|
5264
|
+
const handleVerticalScroll = (0, import_react54.useCallback)(
|
|
5265
|
+
(scrollTop) => {
|
|
5266
|
+
const firstRow = getRowAtPosition(scrollTop);
|
|
5267
|
+
if (firstRow !== firstRowRef.current) {
|
|
5268
|
+
firstRowRef.current = firstRow;
|
|
5269
|
+
setRange({ from: firstRow, to: firstRow + viewportRowCount });
|
|
5270
|
+
}
|
|
5271
|
+
},
|
|
5272
|
+
[getRowAtPosition, setRange, viewportRowCount]
|
|
5273
|
+
);
|
|
5274
|
+
(0, import_react54.useEffect)(() => {
|
|
5275
|
+
const { current: from } = firstRowRef;
|
|
5276
|
+
const rowRange = { from, to: from + viewportRowCount };
|
|
5277
|
+
setRange(rowRange);
|
|
5278
|
+
}, [setRange, viewportRowCount]);
|
|
5279
|
+
return {
|
|
5280
|
+
onVerticalScroll: handleVerticalScroll
|
|
5281
|
+
};
|
|
5282
|
+
};
|
|
3528
5283
|
|
|
3529
5284
|
// ../vuu-table/src/table-next/useTableNext.ts
|
|
3530
5285
|
var { KEY: KEY6, IS_EXPANDED: IS_EXPANDED5, IS_LEAF: IS_LEAF4 } = import_vuu_utils42.metadataKeys;
|
|
5286
|
+
var addColumn = (tableConfig, column) => ({
|
|
5287
|
+
...tableConfig,
|
|
5288
|
+
columns: tableConfig.columns.concat(column)
|
|
5289
|
+
});
|
|
5290
|
+
var useTable2 = ({
|
|
5291
|
+
availableColumns,
|
|
5292
|
+
config,
|
|
5293
|
+
containerRef,
|
|
5294
|
+
dataSource,
|
|
5295
|
+
headerHeight = 25,
|
|
5296
|
+
onAvailableColumnsChange,
|
|
5297
|
+
onConfigChange,
|
|
5298
|
+
onFeatureEnabled,
|
|
5299
|
+
onFeatureInvocation,
|
|
5300
|
+
onRowClick: onRowClickProp,
|
|
5301
|
+
onSelect,
|
|
5302
|
+
onSelectionChange,
|
|
5303
|
+
renderBufferSize = 0,
|
|
5304
|
+
rowHeight = 20,
|
|
5305
|
+
selectionModel
|
|
5306
|
+
}) => {
|
|
5307
|
+
const [rowCount, setRowCount] = (0, import_react55.useState)(dataSource.size);
|
|
5308
|
+
if (dataSource === void 0) {
|
|
5309
|
+
throw Error("no data source provided to Vuu Table");
|
|
5310
|
+
}
|
|
5311
|
+
const [size, setSize] = (0, import_react55.useState)();
|
|
5312
|
+
const handleResize = (0, import_react55.useCallback)((size2) => {
|
|
5313
|
+
setSize(size2);
|
|
5314
|
+
}, []);
|
|
5315
|
+
const menuBuilder = (0, import_react55.useMemo)(
|
|
5316
|
+
() => buildContextMenuDescriptors(dataSource),
|
|
5317
|
+
[dataSource]
|
|
5318
|
+
);
|
|
5319
|
+
const onDataRowcountChange = (0, import_react55.useCallback)((size2) => {
|
|
5320
|
+
setRowCount(size2);
|
|
5321
|
+
}, []);
|
|
5322
|
+
const {
|
|
5323
|
+
columns: modelColumns,
|
|
5324
|
+
dispatchColumnAction,
|
|
5325
|
+
headings,
|
|
5326
|
+
tableAttributes,
|
|
5327
|
+
tableConfig
|
|
5328
|
+
} = useTableModel2(config, dataSource.config);
|
|
5329
|
+
(0, import_vuu_layout2.useLayoutEffectSkipFirst)(() => {
|
|
5330
|
+
dispatchColumnAction({
|
|
5331
|
+
type: "init",
|
|
5332
|
+
dataSourceConfig: dataSource.config,
|
|
5333
|
+
tableConfig
|
|
5334
|
+
});
|
|
5335
|
+
}, [tableConfig, dataSource.config, dispatchColumnAction]);
|
|
5336
|
+
const [stateColumns, setStateColumns] = (0, import_react55.useState)();
|
|
5337
|
+
const [columns, setColumnSize] = (0, import_react55.useMemo)(() => {
|
|
5338
|
+
const setSize2 = (columnName, width) => {
|
|
5339
|
+
const cols = (0, import_vuu_utils42.updateColumn)(modelColumns, columnName, { width });
|
|
5340
|
+
setStateColumns(cols);
|
|
5341
|
+
};
|
|
5342
|
+
return [stateColumns != null ? stateColumns : modelColumns, setSize2];
|
|
5343
|
+
}, [modelColumns, stateColumns]);
|
|
5344
|
+
const columnMap = (0, import_react55.useMemo)(
|
|
5345
|
+
() => (0, import_vuu_utils42.buildColumnMap)(dataSource.columns),
|
|
5346
|
+
[dataSource.columns]
|
|
5347
|
+
);
|
|
5348
|
+
const {
|
|
5349
|
+
getRowAtPosition,
|
|
5350
|
+
getRowOffset,
|
|
5351
|
+
setPctScrollTop,
|
|
5352
|
+
...viewportMeasurements
|
|
5353
|
+
} = useTableViewport({
|
|
5354
|
+
columns,
|
|
5355
|
+
headerHeight,
|
|
5356
|
+
headings,
|
|
5357
|
+
rowCount,
|
|
5358
|
+
rowHeight,
|
|
5359
|
+
size
|
|
5360
|
+
});
|
|
5361
|
+
const initialRange = useInitialValue({
|
|
5362
|
+
from: 0,
|
|
5363
|
+
to: viewportMeasurements.rowCount
|
|
5364
|
+
});
|
|
5365
|
+
const onSubscribed = (0, import_react55.useCallback)(
|
|
5366
|
+
({ tableSchema }) => {
|
|
5367
|
+
if (tableSchema) {
|
|
5368
|
+
} else {
|
|
5369
|
+
console.log("usbscription message with no schema");
|
|
5370
|
+
}
|
|
5371
|
+
},
|
|
5372
|
+
[]
|
|
5373
|
+
);
|
|
5374
|
+
const { data, range, setRange } = useDataSource2({
|
|
5375
|
+
dataSource,
|
|
5376
|
+
onFeatureEnabled,
|
|
5377
|
+
onFeatureInvocation,
|
|
5378
|
+
renderBufferSize,
|
|
5379
|
+
onSizeChange: onDataRowcountChange,
|
|
5380
|
+
onSubscribed,
|
|
5381
|
+
range: initialRange
|
|
5382
|
+
});
|
|
5383
|
+
const handleConfigChanged = (0, import_react55.useCallback)(
|
|
5384
|
+
(tableConfig2) => {
|
|
5385
|
+
dispatchColumnAction({
|
|
5386
|
+
type: "init",
|
|
5387
|
+
tableConfig: tableConfig2,
|
|
5388
|
+
dataSourceConfig: dataSource.config
|
|
5389
|
+
});
|
|
5390
|
+
onConfigChange == null ? void 0 : onConfigChange(tableConfig2);
|
|
5391
|
+
},
|
|
5392
|
+
[dataSource.config, dispatchColumnAction, onConfigChange]
|
|
5393
|
+
);
|
|
5394
|
+
const handleDataSourceConfigChanged = (0, import_react55.useCallback)(
|
|
5395
|
+
(dataSourceConfig) => {
|
|
5396
|
+
dataSource.config = {
|
|
5397
|
+
...dataSource.config,
|
|
5398
|
+
...dataSourceConfig
|
|
5399
|
+
};
|
|
5400
|
+
},
|
|
5401
|
+
[dataSource]
|
|
5402
|
+
);
|
|
5403
|
+
const handleCreateCalculatedColumn = (0, import_react55.useCallback)(
|
|
5404
|
+
(column) => {
|
|
5405
|
+
dataSource.columns = dataSource.columns.concat(column.name);
|
|
5406
|
+
const newTableConfig = addColumn(tableConfig, column);
|
|
5407
|
+
dispatchColumnAction({
|
|
5408
|
+
type: "init",
|
|
5409
|
+
tableConfig: newTableConfig,
|
|
5410
|
+
dataSourceConfig: dataSource.config
|
|
5411
|
+
});
|
|
5412
|
+
onConfigChange == null ? void 0 : onConfigChange(newTableConfig);
|
|
5413
|
+
},
|
|
5414
|
+
[dataSource, dispatchColumnAction, onConfigChange, tableConfig]
|
|
5415
|
+
);
|
|
5416
|
+
(0, import_react55.useEffect)(() => {
|
|
5417
|
+
dataSource.on("config", (config2, confirmed) => {
|
|
5418
|
+
dispatchColumnAction({
|
|
5419
|
+
type: "tableConfig",
|
|
5420
|
+
...config2,
|
|
5421
|
+
confirmed
|
|
5422
|
+
});
|
|
5423
|
+
});
|
|
5424
|
+
}, [dataSource, dispatchColumnAction]);
|
|
5425
|
+
const { showColumnSettingsPanel, showTableSettingsPanel } = useTableAndColumnSettings({
|
|
5426
|
+
availableColumns: availableColumns != null ? availableColumns : tableConfig.columns.map(({ name: name2, serverDataType = "string" }) => ({
|
|
5427
|
+
name: name2,
|
|
5428
|
+
serverDataType
|
|
5429
|
+
})),
|
|
5430
|
+
onAvailableColumnsChange,
|
|
5431
|
+
onConfigChange: handleConfigChanged,
|
|
5432
|
+
onCreateCalculatedColumn: handleCreateCalculatedColumn,
|
|
5433
|
+
onDataSourceConfigChange: handleDataSourceConfigChanged,
|
|
5434
|
+
tableConfig
|
|
5435
|
+
});
|
|
5436
|
+
const onPersistentColumnOperation = (0, import_react55.useCallback)(
|
|
5437
|
+
(action) => {
|
|
5438
|
+
if (isShowColumnSettings(action)) {
|
|
5439
|
+
showColumnSettingsPanel(action);
|
|
5440
|
+
} else if (isShowTableSettings(action)) {
|
|
5441
|
+
showTableSettingsPanel();
|
|
5442
|
+
} else {
|
|
5443
|
+
dispatchColumnAction(action);
|
|
5444
|
+
}
|
|
5445
|
+
},
|
|
5446
|
+
[dispatchColumnAction, showColumnSettingsPanel, showTableSettingsPanel]
|
|
5447
|
+
);
|
|
5448
|
+
const handleContextMenuAction = useTableContextMenu({
|
|
5449
|
+
dataSource,
|
|
5450
|
+
onPersistentColumnOperation
|
|
5451
|
+
});
|
|
5452
|
+
const handleSort = (0, import_react55.useCallback)(
|
|
5453
|
+
(column, extendSort = false, sortType) => {
|
|
5454
|
+
if (dataSource) {
|
|
5455
|
+
dataSource.sort = (0, import_vuu_utils42.applySort)(
|
|
5456
|
+
dataSource.sort,
|
|
5457
|
+
column,
|
|
5458
|
+
extendSort,
|
|
5459
|
+
sortType
|
|
5460
|
+
);
|
|
5461
|
+
}
|
|
5462
|
+
},
|
|
5463
|
+
[dataSource]
|
|
5464
|
+
);
|
|
5465
|
+
const onHeaderResize = (0, import_react55.useCallback)(
|
|
5466
|
+
(phase, columnName, width) => {
|
|
5467
|
+
const column = columns.find((column2) => column2.name === columnName);
|
|
5468
|
+
if (column) {
|
|
5469
|
+
if (phase === "resize") {
|
|
5470
|
+
if ((0, import_vuu_utils42.isValidNumber)(width)) {
|
|
5471
|
+
setColumnSize(columnName, width);
|
|
5472
|
+
}
|
|
5473
|
+
} else if (phase === "end") {
|
|
5474
|
+
if ((0, import_vuu_utils42.isValidNumber)(width)) {
|
|
5475
|
+
dispatchColumnAction({
|
|
5476
|
+
type: "resizeColumn",
|
|
5477
|
+
phase,
|
|
5478
|
+
column,
|
|
5479
|
+
width
|
|
5480
|
+
});
|
|
5481
|
+
onConfigChange == null ? void 0 : onConfigChange(
|
|
5482
|
+
updateTableConfig(tableConfig, {
|
|
5483
|
+
type: "col-size",
|
|
5484
|
+
column,
|
|
5485
|
+
width
|
|
5486
|
+
})
|
|
5487
|
+
);
|
|
5488
|
+
}
|
|
5489
|
+
} else {
|
|
5490
|
+
setStateColumns(void 0);
|
|
5491
|
+
dispatchColumnAction({
|
|
5492
|
+
type: "resizeColumn",
|
|
5493
|
+
phase,
|
|
5494
|
+
column,
|
|
5495
|
+
width
|
|
5496
|
+
});
|
|
5497
|
+
}
|
|
5498
|
+
} else {
|
|
5499
|
+
throw Error(
|
|
5500
|
+
`useDataTable.handleColumnResize, column ${columnName} not found`
|
|
5501
|
+
);
|
|
5502
|
+
}
|
|
5503
|
+
},
|
|
5504
|
+
[columns, tableConfig, dispatchColumnAction, onConfigChange, setColumnSize]
|
|
5505
|
+
);
|
|
5506
|
+
const onToggleGroup = (0, import_react55.useCallback)(
|
|
5507
|
+
(row, column) => {
|
|
5508
|
+
const isJson = (0, import_vuu_utils42.isJsonGroup)(column, row);
|
|
5509
|
+
const key = row[KEY6];
|
|
5510
|
+
if (row[IS_EXPANDED5]) {
|
|
5511
|
+
dataSource.closeTreeNode(key, true);
|
|
5512
|
+
if (isJson) {
|
|
5513
|
+
const idx = columns.indexOf(column);
|
|
5514
|
+
const rows = dataSource.getRowsAtDepth(idx + 1);
|
|
5515
|
+
if (!rows.some((row2) => row2[IS_EXPANDED5] || row2[IS_LEAF4])) {
|
|
5516
|
+
dispatchColumnAction({
|
|
5517
|
+
type: "hideColumns",
|
|
5518
|
+
columns: columns.slice(idx + 2)
|
|
5519
|
+
});
|
|
5520
|
+
}
|
|
5521
|
+
}
|
|
5522
|
+
} else {
|
|
5523
|
+
dataSource.openTreeNode(key);
|
|
5524
|
+
if (isJson) {
|
|
5525
|
+
const childRows = dataSource.getChildRows(key);
|
|
5526
|
+
const idx = columns.indexOf(column) + 1;
|
|
5527
|
+
const columnsToShow = [columns[idx]];
|
|
5528
|
+
if (childRows.some((row2) => row2[IS_LEAF4])) {
|
|
5529
|
+
columnsToShow.push(columns[idx + 1]);
|
|
5530
|
+
}
|
|
5531
|
+
if (columnsToShow.some((col) => col.hidden)) {
|
|
5532
|
+
dispatchColumnAction({
|
|
5533
|
+
type: "showColumns",
|
|
5534
|
+
columns: columnsToShow
|
|
5535
|
+
});
|
|
5536
|
+
}
|
|
5537
|
+
}
|
|
5538
|
+
}
|
|
5539
|
+
},
|
|
5540
|
+
[columns, dataSource, dispatchColumnAction]
|
|
5541
|
+
);
|
|
5542
|
+
const { onVerticalScroll } = useVirtualViewport2({
|
|
5543
|
+
columns,
|
|
5544
|
+
getRowAtPosition,
|
|
5545
|
+
setRange,
|
|
5546
|
+
viewportMeasurements
|
|
5547
|
+
});
|
|
5548
|
+
const handleVerticalScroll = (0, import_react55.useCallback)(
|
|
5549
|
+
(scrollTop) => {
|
|
5550
|
+
onVerticalScroll(scrollTop);
|
|
5551
|
+
},
|
|
5552
|
+
[onVerticalScroll]
|
|
5553
|
+
);
|
|
5554
|
+
const { requestScroll, ...scrollProps } = useTableScroll2({
|
|
5555
|
+
maxScrollLeft: viewportMeasurements.maxScrollContainerScrollHorizontal,
|
|
5556
|
+
maxScrollTop: viewportMeasurements.maxScrollContainerScrollVertical,
|
|
5557
|
+
rowHeight,
|
|
5558
|
+
onVerticalScroll: handleVerticalScroll,
|
|
5559
|
+
viewportRowCount: viewportMeasurements.rowCount
|
|
5560
|
+
});
|
|
5561
|
+
const {
|
|
5562
|
+
navigate,
|
|
5563
|
+
onKeyDown: navigationKeyDown,
|
|
5564
|
+
...containerProps
|
|
5565
|
+
} = useKeyboardNavigation2({
|
|
5566
|
+
columnCount: columns.filter((c) => c.hidden !== true).length,
|
|
5567
|
+
containerRef,
|
|
5568
|
+
requestScroll,
|
|
5569
|
+
rowCount: dataSource == null ? void 0 : dataSource.size,
|
|
5570
|
+
viewportRange: range,
|
|
5571
|
+
viewportRowCount: viewportMeasurements.rowCount
|
|
5572
|
+
});
|
|
5573
|
+
const { onKeyDown: editingKeyDown } = useCellEditing({ navigate });
|
|
5574
|
+
const handleKeyDown = (0, import_react55.useCallback)(
|
|
5575
|
+
(e) => {
|
|
5576
|
+
navigationKeyDown(e);
|
|
5577
|
+
if (!e.defaultPrevented) {
|
|
5578
|
+
editingKeyDown(e);
|
|
5579
|
+
}
|
|
5580
|
+
},
|
|
5581
|
+
[navigationKeyDown, editingKeyDown]
|
|
5582
|
+
);
|
|
5583
|
+
const onContextMenu = useTableContextMenu2({ columns, data });
|
|
5584
|
+
const onHeaderClick = (0, import_react55.useCallback)(
|
|
5585
|
+
(evt) => {
|
|
5586
|
+
var _a;
|
|
5587
|
+
const targetElement = evt.target;
|
|
5588
|
+
const headerCell = targetElement.closest(
|
|
5589
|
+
".vuuTableNextHeaderCell"
|
|
5590
|
+
);
|
|
5591
|
+
const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.index) != null ? _a : "-1");
|
|
5592
|
+
const column = (0, import_vuu_utils42.visibleColumnAtIndex)(columns, colIdx);
|
|
5593
|
+
const isAdditive = evt.shiftKey;
|
|
5594
|
+
column && handleSort(column, isAdditive);
|
|
5595
|
+
},
|
|
5596
|
+
[columns, handleSort]
|
|
5597
|
+
);
|
|
5598
|
+
const onRemoveGroupColumn = (0, import_react55.useCallback)(
|
|
5599
|
+
(column) => {
|
|
5600
|
+
if ((0, import_vuu_utils42.isGroupColumn)(column)) {
|
|
5601
|
+
dataSource.groupBy = [];
|
|
5602
|
+
} else {
|
|
5603
|
+
if (dataSource && dataSource.groupBy.includes(column.name)) {
|
|
5604
|
+
dataSource.groupBy = dataSource.groupBy.filter(
|
|
5605
|
+
(columnName) => columnName !== column.name
|
|
5606
|
+
);
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5609
|
+
},
|
|
5610
|
+
[dataSource]
|
|
5611
|
+
);
|
|
5612
|
+
const handleSelectionChange = (0, import_react55.useCallback)(
|
|
5613
|
+
(selected) => {
|
|
5614
|
+
dataSource.select(selected);
|
|
5615
|
+
onSelectionChange == null ? void 0 : onSelectionChange(selected);
|
|
5616
|
+
},
|
|
5617
|
+
[dataSource, onSelectionChange]
|
|
5618
|
+
);
|
|
5619
|
+
const selectionHookOnRowClick = useSelection({
|
|
5620
|
+
onSelect,
|
|
5621
|
+
onSelectionChange: handleSelectionChange,
|
|
5622
|
+
selectionModel
|
|
5623
|
+
});
|
|
5624
|
+
const handleRowClick = (0, import_react55.useCallback)(
|
|
5625
|
+
(row, rangeSelect, keepExistingSelection) => {
|
|
5626
|
+
selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
|
|
5627
|
+
onRowClickProp == null ? void 0 : onRowClickProp(row);
|
|
5628
|
+
},
|
|
5629
|
+
[onRowClickProp, selectionHookOnRowClick]
|
|
5630
|
+
);
|
|
5631
|
+
(0, import_react55.useEffect)(() => {
|
|
5632
|
+
dataSource.on("config", (config2, confirmed) => {
|
|
5633
|
+
dispatchColumnAction({
|
|
5634
|
+
type: "tableConfig",
|
|
5635
|
+
...config2,
|
|
5636
|
+
confirmed
|
|
5637
|
+
});
|
|
5638
|
+
});
|
|
5639
|
+
}, [dataSource, dispatchColumnAction]);
|
|
5640
|
+
const handleDrop = (0, import_react55.useCallback)(
|
|
5641
|
+
(moveFrom, moveTo) => {
|
|
5642
|
+
const column = columns[moveFrom];
|
|
5643
|
+
dispatchColumnAction({
|
|
5644
|
+
type: "moveColumn",
|
|
5645
|
+
column,
|
|
5646
|
+
moveTo
|
|
5647
|
+
});
|
|
5648
|
+
},
|
|
5649
|
+
[columns, dispatchColumnAction]
|
|
5650
|
+
);
|
|
5651
|
+
const handleDataEdited = (0, import_react55.useCallback)(
|
|
5652
|
+
(rowIndex, columnName, value) => {
|
|
5653
|
+
return dataSource.applyEdit(rowIndex, columnName, value);
|
|
5654
|
+
},
|
|
5655
|
+
[dataSource]
|
|
5656
|
+
);
|
|
5657
|
+
const { onMouseDown: dragDropHookHandleMouseDown, ...dragDropHook } = (0, import_vuu_ui_controls8.useDragDropNext)({
|
|
5658
|
+
allowDragDrop: true,
|
|
5659
|
+
containerRef,
|
|
5660
|
+
// this is for useDragDropNext
|
|
5661
|
+
draggableClassName: `vuuTableNext`,
|
|
5662
|
+
// extendedDropZone: overflowedItems.length > 0,
|
|
5663
|
+
onDrop: handleDrop,
|
|
5664
|
+
orientation: "horizontal",
|
|
5665
|
+
itemQuery: ".vuuTableNextHeaderCell"
|
|
5666
|
+
});
|
|
5667
|
+
const headerProps = {
|
|
5668
|
+
onClick: onHeaderClick,
|
|
5669
|
+
onMouseDown: dragDropHookHandleMouseDown,
|
|
5670
|
+
onResize: onHeaderResize
|
|
5671
|
+
};
|
|
5672
|
+
return {
|
|
5673
|
+
...containerProps,
|
|
5674
|
+
onKeyDown: handleKeyDown,
|
|
5675
|
+
columnMap,
|
|
5676
|
+
columns,
|
|
5677
|
+
data,
|
|
5678
|
+
handleContextMenuAction,
|
|
5679
|
+
headerProps,
|
|
5680
|
+
menuBuilder,
|
|
5681
|
+
onContextMenu,
|
|
5682
|
+
onDataEdited: handleDataEdited,
|
|
5683
|
+
onRemoveGroupColumn,
|
|
5684
|
+
onResize: handleResize,
|
|
5685
|
+
onRowClick: handleRowClick,
|
|
5686
|
+
onToggleGroup,
|
|
5687
|
+
scrollProps,
|
|
5688
|
+
tableAttributes,
|
|
5689
|
+
viewportMeasurements,
|
|
5690
|
+
dragDropHook
|
|
5691
|
+
};
|
|
5692
|
+
};
|
|
3531
5693
|
|
|
3532
5694
|
// ../vuu-table/src/table-next/TableNext.tsx
|
|
3533
5695
|
var import_vuu_layout3 = require("@vuu-ui/vuu-layout");
|
|
5696
|
+
var import_core7 = require("@salt-ds/core");
|
|
3534
5697
|
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3535
5698
|
var import_react57 = require("react");
|
|
5699
|
+
var classBase19 = "vuuTableNext";
|
|
3536
5700
|
var { IDX: IDX5, RENDER_IDX: RENDER_IDX2 } = import_vuu_utils43.metadataKeys;
|
|
5701
|
+
var TableNext = (0, import_react56.forwardRef)(function TableNext2({
|
|
5702
|
+
Row: Row3 = Row2,
|
|
5703
|
+
availableColumns,
|
|
5704
|
+
className: classNameProp,
|
|
5705
|
+
config,
|
|
5706
|
+
dataSource,
|
|
5707
|
+
id: idProp,
|
|
5708
|
+
onAvailableColumnsChange,
|
|
5709
|
+
onConfigChange,
|
|
5710
|
+
onFeatureEnabled,
|
|
5711
|
+
onFeatureInvocation,
|
|
5712
|
+
onRowClick: onRowClickProp,
|
|
5713
|
+
onSelect,
|
|
5714
|
+
onSelectionChange,
|
|
5715
|
+
onShowConfigEditor: onShowSettings,
|
|
5716
|
+
renderBufferSize = 0,
|
|
5717
|
+
rowHeight = 20,
|
|
5718
|
+
selectionModel = "extended",
|
|
5719
|
+
showColumnHeaders = true,
|
|
5720
|
+
headerHeight = showColumnHeaders ? 25 : 0,
|
|
5721
|
+
style: styleProp,
|
|
5722
|
+
...htmlAttributes
|
|
5723
|
+
}, forwardedRef) {
|
|
5724
|
+
const id = (0, import_vuu_layout3.useId)(idProp);
|
|
5725
|
+
const containerRef = (0, import_react56.useRef)(null);
|
|
5726
|
+
const {
|
|
5727
|
+
columnMap,
|
|
5728
|
+
columns,
|
|
5729
|
+
data,
|
|
5730
|
+
dragDropHook,
|
|
5731
|
+
handleContextMenuAction,
|
|
5732
|
+
headerProps,
|
|
5733
|
+
onDataEdited,
|
|
5734
|
+
onRemoveGroupColumn,
|
|
5735
|
+
onResize,
|
|
5736
|
+
onRowClick,
|
|
5737
|
+
onToggleGroup,
|
|
5738
|
+
menuBuilder,
|
|
5739
|
+
scrollProps,
|
|
5740
|
+
tableAttributes,
|
|
5741
|
+
viewportMeasurements,
|
|
5742
|
+
...tableProps
|
|
5743
|
+
} = useTable2({
|
|
5744
|
+
availableColumns,
|
|
5745
|
+
config,
|
|
5746
|
+
containerRef,
|
|
5747
|
+
dataSource,
|
|
5748
|
+
headerHeight,
|
|
5749
|
+
onAvailableColumnsChange,
|
|
5750
|
+
onConfigChange,
|
|
5751
|
+
onFeatureEnabled,
|
|
5752
|
+
onFeatureInvocation,
|
|
5753
|
+
onRowClick: onRowClickProp,
|
|
5754
|
+
onSelect,
|
|
5755
|
+
onSelectionChange,
|
|
5756
|
+
renderBufferSize,
|
|
5757
|
+
rowHeight,
|
|
5758
|
+
selectionModel
|
|
5759
|
+
});
|
|
5760
|
+
const getStyle = () => {
|
|
5761
|
+
return {
|
|
5762
|
+
...styleProp,
|
|
5763
|
+
"--content-height": `${viewportMeasurements.contentHeight}px`,
|
|
5764
|
+
"--horizontal-scrollbar-height": `${viewportMeasurements.horizontalScrollbarHeight}px`,
|
|
5765
|
+
"--content-width": `${viewportMeasurements.contentWidth}px`,
|
|
5766
|
+
"--pinned-width-left": `${viewportMeasurements.pinnedWidthLeft}px`,
|
|
5767
|
+
"--pinned-width-right": `${viewportMeasurements.pinnedWidthRight}px`,
|
|
5768
|
+
"--header-height": `${headerHeight}px`,
|
|
5769
|
+
"--row-height": `${rowHeight}px`,
|
|
5770
|
+
"--total-header-height": `${viewportMeasurements.totalHeaderHeight}px`,
|
|
5771
|
+
"--vertical-scrollbar-width": `${viewportMeasurements.verticalScrollbarWidth}px`,
|
|
5772
|
+
"--viewport-body-height": `${viewportMeasurements.viewportBodyHeight}px`
|
|
5773
|
+
};
|
|
5774
|
+
};
|
|
5775
|
+
const className = (0, import_classnames23.default)(classBase19, classNameProp, {
|
|
5776
|
+
[`${classBase19}-colLines`]: tableAttributes.columnSeparators,
|
|
5777
|
+
[`${classBase19}-rowLines`]: tableAttributes.rowSeparators,
|
|
5778
|
+
[`${classBase19}-zebra`]: tableAttributes.zebraStripes
|
|
5779
|
+
// [`${classBase}-loading`]: isDataLoading(tableProps.columns),
|
|
5780
|
+
});
|
|
5781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
5782
|
+
import_vuu_popups7.ContextMenuProvider,
|
|
5783
|
+
{
|
|
5784
|
+
menuActionHandler: handleContextMenuAction,
|
|
5785
|
+
menuBuilder,
|
|
5786
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
|
|
5787
|
+
import_vuu_layout3.MeasuredContainer,
|
|
5788
|
+
{
|
|
5789
|
+
...htmlAttributes,
|
|
5790
|
+
className,
|
|
5791
|
+
onResize,
|
|
5792
|
+
ref: (0, import_core7.useForkRef)(containerRef, forwardedRef),
|
|
5793
|
+
style: getStyle(),
|
|
5794
|
+
children: [
|
|
5795
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
5796
|
+
"div",
|
|
5797
|
+
{
|
|
5798
|
+
className: `${classBase19}-scrollbarContainer`,
|
|
5799
|
+
ref: scrollProps.scrollbarContainerRef,
|
|
5800
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `${classBase19}-scrollbarContent` })
|
|
5801
|
+
}
|
|
5802
|
+
),
|
|
5803
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
5804
|
+
"div",
|
|
5805
|
+
{
|
|
5806
|
+
className: `${classBase19}-contentContainer`,
|
|
5807
|
+
ref: scrollProps.contentContainerRef,
|
|
5808
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { ...tableProps, className: `${classBase19}-table`, tabIndex: -1, children: [
|
|
5809
|
+
showColumnHeaders ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `${classBase19}-col-headings`, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: `${classBase19}-col-headers`, role: "row", children: [
|
|
5810
|
+
columns.filter(import_vuu_utils43.notHidden).map(
|
|
5811
|
+
(col, i) => (0, import_vuu_utils43.isGroupColumn)(col) ? /* @__PURE__ */ (0, import_react57.createElement)(
|
|
5812
|
+
GroupHeaderCellNext,
|
|
5813
|
+
{
|
|
5814
|
+
...headerProps,
|
|
5815
|
+
column: col,
|
|
5816
|
+
"data-index": i,
|
|
5817
|
+
key: col.name,
|
|
5818
|
+
onRemoveColumn: onRemoveGroupColumn
|
|
5819
|
+
}
|
|
5820
|
+
) : /* @__PURE__ */ (0, import_react57.createElement)(
|
|
5821
|
+
HeaderCell,
|
|
5822
|
+
{
|
|
5823
|
+
...headerProps,
|
|
5824
|
+
className: (0, import_classnames23.default)({
|
|
5825
|
+
"vuuDraggable-dragAway": i === dragDropHook.draggedItemIndex
|
|
5826
|
+
}),
|
|
5827
|
+
column: col,
|
|
5828
|
+
"data-index": i,
|
|
5829
|
+
id: `${id}-col-${i}`,
|
|
5830
|
+
key: col.name
|
|
5831
|
+
}
|
|
5832
|
+
)
|
|
5833
|
+
),
|
|
5834
|
+
dragDropHook.draggable
|
|
5835
|
+
] }) }) : null,
|
|
5836
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `${classBase19}-body`, children: data.map((data2) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
5837
|
+
Row3,
|
|
5838
|
+
{
|
|
5839
|
+
columnMap,
|
|
5840
|
+
columns,
|
|
5841
|
+
onClick: onRowClick,
|
|
5842
|
+
onDataEdited,
|
|
5843
|
+
row: data2,
|
|
5844
|
+
offset: rowHeight * data2[IDX5] + headerHeight,
|
|
5845
|
+
onToggleGroup,
|
|
5846
|
+
zebraStripes: tableAttributes.zebraStripes
|
|
5847
|
+
},
|
|
5848
|
+
data2[RENDER_IDX2]
|
|
5849
|
+
)) })
|
|
5850
|
+
] })
|
|
5851
|
+
}
|
|
5852
|
+
)
|
|
5853
|
+
]
|
|
5854
|
+
}
|
|
5855
|
+
)
|
|
5856
|
+
}
|
|
5857
|
+
);
|
|
5858
|
+
});
|
|
3537
5859
|
|
|
3538
5860
|
// ../vuu-table/src/table-next/cell-renderers/dropdown-cell/DropdownCell.tsx
|
|
3539
5861
|
var import_vuu_ui_controls9 = require("@vuu-ui/vuu-ui-controls");
|
|
3540
5862
|
var import_vuu_utils44 = require("@vuu-ui/vuu-utils");
|
|
3541
5863
|
var import_react58 = require("react");
|
|
3542
5864
|
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3543
|
-
var
|
|
5865
|
+
var classBase20 = "vuuTableDropdownCell";
|
|
3544
5866
|
var openKeys = ["Enter", " "];
|
|
3545
5867
|
var DropdownCell = ({ column, columnMap, row }) => {
|
|
3546
5868
|
var _a, _b, _c;
|
|
@@ -3558,7 +5880,7 @@ var DropdownCell = ({ column, columnMap, row }) => {
|
|
|
3558
5880
|
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3559
5881
|
import_vuu_ui_controls9.Dropdown,
|
|
3560
5882
|
{
|
|
3561
|
-
className:
|
|
5883
|
+
className: classBase20,
|
|
3562
5884
|
onSelectionChange: handleSelectionChange,
|
|
3563
5885
|
openKeys,
|
|
3564
5886
|
selected: value,
|
|
@@ -3571,11 +5893,11 @@ var DropdownCell = ({ column, columnMap, row }) => {
|
|
|
3571
5893
|
|
|
3572
5894
|
// ../vuu-table/src/table-next/cell-renderers/input-cell/InputCell.tsx
|
|
3573
5895
|
var import_vuu_utils45 = require("@vuu-ui/vuu-utils");
|
|
3574
|
-
var
|
|
5896
|
+
var import_core8 = require("@salt-ds/core");
|
|
3575
5897
|
var import_vuu_ui_controls10 = require("@vuu-ui/vuu-ui-controls");
|
|
3576
5898
|
var import_classnames24 = __toESM(require("classnames"));
|
|
3577
5899
|
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3578
|
-
var
|
|
5900
|
+
var classBase21 = "vuuTableInputCell";
|
|
3579
5901
|
var WarnCommit = () => {
|
|
3580
5902
|
console.warn(
|
|
3581
5903
|
"onCommit handler has not been provided to InputCell cell renderer"
|
|
@@ -3599,14 +5921,14 @@ var InputCell = ({
|
|
|
3599
5921
|
onCommit,
|
|
3600
5922
|
clientSideEditValidationCheck
|
|
3601
5923
|
});
|
|
3602
|
-
const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: `${
|
|
3603
|
-
const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: `${
|
|
5924
|
+
const endAdornment = warningMessage && align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: `${classBase21}-icon`, "data-icon": "error" }) : void 0;
|
|
5925
|
+
const startAdornment = warningMessage && align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("span", { className: `${classBase21}-icon`, "data-icon": "error" }) : void 0;
|
|
3604
5926
|
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3605
|
-
|
|
5927
|
+
import_core8.Input,
|
|
3606
5928
|
{
|
|
3607
5929
|
...editProps,
|
|
3608
|
-
className: (0, import_classnames24.default)(
|
|
3609
|
-
[`${
|
|
5930
|
+
className: (0, import_classnames24.default)(classBase21, {
|
|
5931
|
+
[`${classBase21}-error`]: warningMessage !== void 0
|
|
3610
5932
|
}),
|
|
3611
5933
|
endAdornment,
|
|
3612
5934
|
startAdornment
|
|
@@ -3773,7 +6095,7 @@ var useTableSettings = ({
|
|
|
3773
6095
|
|
|
3774
6096
|
// src/table-settings/TableSettingsPanel.tsx
|
|
3775
6097
|
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3776
|
-
var
|
|
6098
|
+
var classBase22 = "vuuTableSettingsPanel";
|
|
3777
6099
|
var TableSettingsPanel = ({
|
|
3778
6100
|
availableColumns,
|
|
3779
6101
|
onAddCalculatedColumn,
|
|
@@ -3796,18 +6118,18 @@ var TableSettingsPanel = ({
|
|
|
3796
6118
|
onDataSourceConfigChange,
|
|
3797
6119
|
tableConfig: tableConfigProp
|
|
3798
6120
|
});
|
|
3799
|
-
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ...htmlAttributes, className:
|
|
3800
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3801
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
6121
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { ...htmlAttributes, className: classBase22, children: [
|
|
6122
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_core9.FormField, { children: [
|
|
6123
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_core9.FormFieldLabel, { children: "Column Labels" }),
|
|
3802
6124
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3803
|
-
|
|
6125
|
+
import_core9.ToggleButtonGroup,
|
|
3804
6126
|
{
|
|
3805
6127
|
className: "vuuToggleButtonGroup",
|
|
3806
6128
|
onChange: onChangeColumnLabels,
|
|
3807
6129
|
value: columnLabelsValue,
|
|
3808
6130
|
children: [
|
|
3809
6131
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3810
|
-
|
|
6132
|
+
import_core9.ToggleButton,
|
|
3811
6133
|
{
|
|
3812
6134
|
className: "vuuIconToggleButton",
|
|
3813
6135
|
"data-icon": "text-strikethrough",
|
|
@@ -3815,7 +6137,7 @@ var TableSettingsPanel = ({
|
|
|
3815
6137
|
}
|
|
3816
6138
|
),
|
|
3817
6139
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3818
|
-
|
|
6140
|
+
import_core9.ToggleButton,
|
|
3819
6141
|
{
|
|
3820
6142
|
className: "vuuIconToggleButton",
|
|
3821
6143
|
"data-icon": "text-Tt",
|
|
@@ -3823,7 +6145,7 @@ var TableSettingsPanel = ({
|
|
|
3823
6145
|
}
|
|
3824
6146
|
),
|
|
3825
6147
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3826
|
-
|
|
6148
|
+
import_core9.ToggleButton,
|
|
3827
6149
|
{
|
|
3828
6150
|
className: "vuuIconToggleButton",
|
|
3829
6151
|
"data-icon": "text-T",
|
|
@@ -3834,11 +6156,11 @@ var TableSettingsPanel = ({
|
|
|
3834
6156
|
}
|
|
3835
6157
|
)
|
|
3836
6158
|
] }),
|
|
3837
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3838
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
6159
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_core9.FormField, { children: [
|
|
6160
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_core9.FormFieldLabel, { children: "Grid separators" }),
|
|
3839
6161
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "saltToggleButtonGroup vuuToggleButtonGroup saltToggleButtonGroup-horizontal vuuGridSeparators", children: [
|
|
3840
6162
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3841
|
-
|
|
6163
|
+
import_core9.ToggleButton,
|
|
3842
6164
|
{
|
|
3843
6165
|
className: "vuuIconToggleButton",
|
|
3844
6166
|
"data-icon": "row-striping",
|
|
@@ -3848,7 +6170,7 @@ var TableSettingsPanel = ({
|
|
|
3848
6170
|
}
|
|
3849
6171
|
),
|
|
3850
6172
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3851
|
-
|
|
6173
|
+
import_core9.ToggleButton,
|
|
3852
6174
|
{
|
|
3853
6175
|
className: "vuuIconToggleButton",
|
|
3854
6176
|
"data-icon": "row-lines",
|
|
@@ -3858,7 +6180,7 @@ var TableSettingsPanel = ({
|
|
|
3858
6180
|
}
|
|
3859
6181
|
),
|
|
3860
6182
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3861
|
-
|
|
6183
|
+
import_core9.ToggleButton,
|
|
3862
6184
|
{
|
|
3863
6185
|
className: "vuuIconToggleButton",
|
|
3864
6186
|
"data-icon": "col-lines",
|
|
@@ -3869,9 +6191,9 @@ var TableSettingsPanel = ({
|
|
|
3869
6191
|
)
|
|
3870
6192
|
] })
|
|
3871
6193
|
] }),
|
|
3872
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
|
|
3873
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3874
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
6194
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_core9.FormField, { children: [
|
|
6195
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_core9.FormFieldLabel, { children: "Default Column Width" }),
|
|
6196
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_core9.Input, { className: "vuuInput" })
|
|
3875
6197
|
] }),
|
|
3876
6198
|
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3877
6199
|
ColumnList,
|
|
@@ -3881,9 +6203,9 @@ var TableSettingsPanel = ({
|
|
|
3881
6203
|
onMoveListItem
|
|
3882
6204
|
}
|
|
3883
6205
|
),
|
|
3884
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `${
|
|
3885
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3886
|
-
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: `${
|
|
6206
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: `${classBase22}-calculatedButtonbar`, children: [
|
|
6207
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_core9.Button, { "data-icon": "plus", onClick: onAddCalculatedColumn }),
|
|
6208
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: `${classBase22}-calculatedLabel`, children: "Add calculated column" })
|
|
3887
6209
|
] })
|
|
3888
6210
|
] });
|
|
3889
6211
|
};
|