@vuu-ui/vuu-table 0.8.23-debug → 0.8.24-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js CHANGED
@@ -459,10 +459,10 @@ var HeaderCell = ({
459
459
  // src/Table.tsx
460
460
  var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
461
461
  var import_vuu_ui_controls5 = require("@vuu-ui/vuu-ui-controls");
462
- var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
462
+ var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
463
463
  var import_core2 = require("@salt-ds/core");
464
464
  var import_clsx9 = __toESM(require("clsx"));
465
- var import_react25 = require("react");
465
+ var import_react27 = require("react");
466
466
 
467
467
  // src/Row.tsx
468
468
  var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
@@ -571,9 +571,23 @@ var TableGroupCell = ({
571
571
  var import_jsx_runtime10 = require("react/jsx-runtime");
572
572
  var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils5.metadataKeys;
573
573
  var classBase6 = "vuuTableRow";
574
+ var RowProxy = (0, import_react11.forwardRef)(
575
+ function RowProxy2({ height }, forwardedRef) {
576
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
577
+ "div",
578
+ {
579
+ "aria-hidden": true,
580
+ className: (0, import_clsx7.default)(classBase6, `${classBase6}-proxy`),
581
+ ref: forwardedRef,
582
+ style: { height }
583
+ }
584
+ );
585
+ }
586
+ );
574
587
  var Row = (0, import_react11.memo)(
575
588
  ({
576
589
  className: classNameProp,
590
+ classNameGenerator,
577
591
  columnMap,
578
592
  columns,
579
593
  highlighted,
@@ -600,14 +614,19 @@ var Row = (0, import_react11.memo)(
600
614
  [onClick, row]
601
615
  );
602
616
  const { True, First, Last } = import_vuu_utils5.RowSelected;
603
- const className = (0, import_clsx7.default)(classBase6, classNameProp, {
604
- [`${classBase6}-even`]: zebraStripes && rowIndex % 2 === 0,
605
- [`${classBase6}-expanded`]: isExpanded,
606
- [`${classBase6}-highlighted`]: highlighted,
607
- [`${classBase6}-selected`]: selectionStatus & True,
608
- [`${classBase6}-selectedStart`]: selectionStatus & First,
609
- [`${classBase6}-selectedEnd`]: selectionStatus & Last
610
- });
617
+ const className = (0, import_clsx7.default)(
618
+ classBase6,
619
+ classNameProp,
620
+ classNameGenerator == null ? void 0 : classNameGenerator(row, columnMap),
621
+ {
622
+ [`${classBase6}-even`]: zebraStripes && rowIndex % 2 === 0,
623
+ [`${classBase6}-expanded`]: isExpanded,
624
+ [`${classBase6}-highlighted`]: highlighted,
625
+ [`${classBase6}-selected`]: selectionStatus & True,
626
+ [`${classBase6}-selectedStart`]: selectionStatus & First,
627
+ [`${classBase6}-selectedEnd`]: selectionStatus & Last
628
+ }
629
+ );
611
630
  const style = { transform: `translate3d(0px, ${offset}px, 0px)` };
612
631
  const handleGroupCellClick = (0, import_react11.useCallback)(
613
632
  (evt, column) => {
@@ -807,8 +826,8 @@ TableHeader.displayName = "TableHeader";
807
826
 
808
827
  // src/useTable.ts
809
828
  var import_vuu_ui_controls4 = require("@vuu-ui/vuu-ui-controls");
810
- var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
811
- var import_react24 = require("react");
829
+ var import_vuu_utils22 = require("@vuu-ui/vuu-utils");
830
+ var import_react25 = require("react");
812
831
 
813
832
  // src/context-menu/buildContextMenuDescriptors.ts
814
833
  var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
@@ -1338,7 +1357,6 @@ var useDataSource = ({
1338
1357
  if (isMounted.current) {
1339
1358
  forceUpdate({});
1340
1359
  } else {
1341
- console.log(`ignore update as we're not mounted`);
1342
1360
  }
1343
1361
  },
1344
1362
  [dataWindow]
@@ -1869,11 +1887,11 @@ var columnReducer = (state, action) => {
1869
1887
  }
1870
1888
  };
1871
1889
  var useTableModel = (tableConfigProp, dataSource) => {
1872
- const [state, dispatchColumnAction] = (0, import_react20.useReducer)(columnReducer, { tableConfig: tableConfigProp, dataSource }, init);
1890
+ const [state, dispatchTableModelAction] = (0, import_react20.useReducer)(columnReducer, { tableConfig: tableConfigProp, dataSource }, init);
1873
1891
  const { columns, headings, tableConfig, ...tableAttributes } = state;
1874
1892
  return {
1875
1893
  columns,
1876
- dispatchColumnAction,
1894
+ dispatchTableModelAction,
1877
1895
  headings,
1878
1896
  tableAttributes,
1879
1897
  tableConfig
@@ -2183,11 +2201,13 @@ var useTableScroll = ({
2183
2201
  onHorizontalScroll,
2184
2202
  onVerticalScroll,
2185
2203
  onVerticalScrollInSitu,
2204
+ rowHeight,
2186
2205
  scrollingApiRef,
2187
2206
  setRange,
2188
2207
  viewportMeasurements
2189
2208
  }) => {
2190
2209
  const firstRowRef = (0, import_react21.useRef)(0);
2210
+ const rowHeightRef = (0, import_react21.useRef)(rowHeight);
2191
2211
  const contentContainerScrolledRef = (0, import_react21.useRef)(false);
2192
2212
  const contentContainerPosRef = (0, import_react21.useRef)({
2193
2213
  scrollTop: 0,
@@ -2469,10 +2489,19 @@ var useTableScroll = ({
2469
2489
  [scrollHandles]
2470
2490
  );
2471
2491
  (0, import_react21.useEffect)(() => {
2472
- const { current: from } = firstRowRef;
2473
- const rowRange = { from, to: from + viewportRowCount };
2474
- setRange(rowRange);
2475
- }, [setRange, viewportRowCount]);
2492
+ if (rowHeight !== rowHeightRef.current) {
2493
+ rowHeightRef.current = rowHeight;
2494
+ if (contentContainerPosRef.current.scrollTop > 0) {
2495
+ if (contentContainerRef.current) {
2496
+ contentContainerRef.current.scrollTop = 0;
2497
+ }
2498
+ }
2499
+ } else {
2500
+ const { current: from } = firstRowRef;
2501
+ const rowRange = { from, to: from + viewportRowCount };
2502
+ setRange(rowRange);
2503
+ }
2504
+ }, [rowHeight, setRange, viewportRowCount]);
2476
2505
  return {
2477
2506
  columnsWithinViewport: columnsWithinViewportRef.current,
2478
2507
  /** Ref to be assigned to ScrollbarContainer */
@@ -2730,11 +2759,41 @@ var useTableAndColumnSettings = ({
2730
2759
  };
2731
2760
  };
2732
2761
 
2762
+ // src/useRowClassNameGenerators.ts
2763
+ var import_vuu_utils21 = require("@vuu-ui/vuu-utils");
2764
+ var import_react24 = require("react");
2765
+ var createClassNameGenerator = (ids) => {
2766
+ const functions = [];
2767
+ ids == null ? void 0 : ids.forEach((id) => {
2768
+ const fn = (0, import_vuu_utils21.getRowClassNameGenerator)(id);
2769
+ if (fn) {
2770
+ functions.push(fn.fn);
2771
+ }
2772
+ });
2773
+ return (row, columnMap) => {
2774
+ const classNames = [];
2775
+ functions == null ? void 0 : functions.forEach((fn) => {
2776
+ const className = fn(row, columnMap);
2777
+ if (className) {
2778
+ classNames.push(className);
2779
+ }
2780
+ });
2781
+ return classNames.join(" ");
2782
+ };
2783
+ };
2784
+ var useRowClassNameGenerators = ({
2785
+ rowClassNameGenerators
2786
+ }) => {
2787
+ return (0, import_react24.useMemo)(() => {
2788
+ return createClassNameGenerator(rowClassNameGenerators);
2789
+ }, [rowClassNameGenerators]);
2790
+ };
2791
+
2733
2792
  // src/useTable.ts
2734
2793
  var stripInternalProperties = (tableConfig) => {
2735
2794
  return tableConfig;
2736
2795
  };
2737
- var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils21.metadataKeys;
2796
+ var { KEY, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils22.metadataKeys;
2738
2797
  var NULL_DRAG_DROP = {
2739
2798
  draggable: void 0,
2740
2799
  onMouseDown: void 0
@@ -2770,51 +2829,52 @@ var useTable = ({
2770
2829
  selectionModel,
2771
2830
  size
2772
2831
  }) => {
2773
- const [rowCount, setRowCount] = (0, import_react24.useState)(dataSource.size);
2832
+ const [rowCount, setRowCount] = (0, import_react25.useState)(dataSource.size);
2774
2833
  if (dataSource === void 0) {
2775
2834
  throw Error("no data source provided to Vuu Table");
2776
2835
  }
2836
+ const rowClassNameGenerator = useRowClassNameGenerators(config);
2777
2837
  const useRowDragDrop = allowDragDrop ? import_vuu_ui_controls4.useDragDrop : useNullDragDrop;
2778
- const menuBuilder = (0, import_react24.useMemo)(
2838
+ const menuBuilder = (0, import_react25.useMemo)(
2779
2839
  () => buildContextMenuDescriptors(dataSource),
2780
2840
  [dataSource]
2781
2841
  );
2782
- const onDataRowcountChange = (0, import_react24.useCallback)((size2) => {
2842
+ const onDataRowcountChange = (0, import_react25.useCallback)((size2) => {
2783
2843
  setRowCount(size2);
2784
2844
  }, []);
2785
2845
  const {
2786
2846
  columns,
2787
- dispatchColumnAction,
2847
+ dispatchTableModelAction,
2788
2848
  headings,
2789
2849
  tableAttributes,
2790
2850
  tableConfig
2791
2851
  } = useTableModel(config, dataSource);
2792
- (0, import_vuu_utils21.useLayoutEffectSkipFirst)(() => {
2793
- dispatchColumnAction({
2852
+ (0, import_vuu_utils22.useLayoutEffectSkipFirst)(() => {
2853
+ dispatchTableModelAction({
2794
2854
  type: "init",
2795
2855
  tableConfig: config,
2796
2856
  dataSource
2797
2857
  });
2798
- }, [config, dataSource, dispatchColumnAction]);
2799
- const applyTableConfigChange = (0, import_react24.useCallback)(
2858
+ }, [config, dataSource, dispatchTableModelAction]);
2859
+ const applyTableConfigChange = (0, import_react25.useCallback)(
2800
2860
  (config2) => {
2801
- dispatchColumnAction({
2861
+ dispatchTableModelAction({
2802
2862
  type: "init",
2803
2863
  tableConfig: config2,
2804
2864
  dataSource
2805
2865
  });
2806
2866
  onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(config2));
2807
2867
  },
2808
- [dataSource, dispatchColumnAction, onConfigChange]
2868
+ [dataSource, dispatchTableModelAction, onConfigChange]
2809
2869
  );
2810
- const columnMap = (0, import_react24.useMemo)(
2811
- () => (0, import_vuu_utils21.buildColumnMap)(dataSource.columns),
2870
+ const columnMap = (0, import_react25.useMemo)(
2871
+ () => (0, import_vuu_utils22.buildColumnMap)(dataSource.columns),
2812
2872
  [dataSource.columns]
2813
2873
  );
2814
- const onSubscribed = (0, import_react24.useCallback)(
2874
+ const onSubscribed = (0, import_react25.useCallback)(
2815
2875
  ({ tableSchema }) => {
2816
2876
  if (tableSchema) {
2817
- dispatchColumnAction({
2877
+ dispatchTableModelAction({
2818
2878
  type: "setTableSchema",
2819
2879
  tableSchema
2820
2880
  });
@@ -2822,7 +2882,7 @@ var useTable = ({
2822
2882
  console.log("subscription message with no schema");
2823
2883
  }
2824
2884
  },
2825
- [dispatchColumnAction]
2885
+ [dispatchTableModelAction]
2826
2886
  );
2827
2887
  const {
2828
2888
  getRowAtPosition,
@@ -2861,18 +2921,18 @@ var useTable = ({
2861
2921
  onVerticalScrollInSitu: viewportHookSetInSituRowOffset,
2862
2922
  viewportMeasurements
2863
2923
  });
2864
- const handleConfigEditedInSettingsPanel = (0, import_react24.useCallback)(
2924
+ const handleConfigEditedInSettingsPanel = (0, import_react25.useCallback)(
2865
2925
  (tableConfig2) => {
2866
- dispatchColumnAction({
2926
+ dispatchTableModelAction({
2867
2927
  type: "init",
2868
2928
  tableConfig: tableConfig2,
2869
2929
  dataSource
2870
2930
  });
2871
2931
  onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(tableConfig2));
2872
2932
  },
2873
- [dataSource, dispatchColumnAction, onConfigChange]
2933
+ [dataSource, dispatchTableModelAction, onConfigChange]
2874
2934
  );
2875
- const handleDataSourceConfigChanged = (0, import_react24.useCallback)(
2935
+ const handleDataSourceConfigChanged = (0, import_react25.useCallback)(
2876
2936
  (dataSourceConfig) => {
2877
2937
  dataSource.config = {
2878
2938
  ...dataSource.config,
@@ -2881,23 +2941,30 @@ var useTable = ({
2881
2941
  },
2882
2942
  [dataSource]
2883
2943
  );
2884
- (0, import_react24.useEffect)(() => {
2885
- dataSource.on("config", (config2, confirmed) => {
2886
- dispatchColumnAction({
2944
+ (0, import_react25.useEffect)(() => {
2945
+ dataSource.on("config", (config2, confirmed, changes) => {
2946
+ const scrollSensitiveChanges = (changes == null ? void 0 : changes.filterChanged) || (changes == null ? void 0 : changes.groupByChanged);
2947
+ if (scrollSensitiveChanges && dataSource.range.from > 0) {
2948
+ requestScroll({
2949
+ type: "scroll-end",
2950
+ direction: "home"
2951
+ });
2952
+ }
2953
+ dispatchTableModelAction({
2887
2954
  type: "tableConfig",
2888
2955
  ...config2,
2889
2956
  confirmed
2890
2957
  });
2891
2958
  });
2892
- }, [dataSource, dispatchColumnAction]);
2893
- const handleCreateCalculatedColumn = (0, import_react24.useCallback)(
2959
+ }, [dataSource, dispatchTableModelAction, requestScroll]);
2960
+ const handleCreateCalculatedColumn = (0, import_react25.useCallback)(
2894
2961
  (column) => {
2895
2962
  dataSource.columns = dataSource.columns.concat(column.name);
2896
2963
  applyTableConfigChange(addColumn(tableConfig, column));
2897
2964
  },
2898
2965
  [dataSource, tableConfig, applyTableConfigChange]
2899
2966
  );
2900
- const hideColumns2 = (0, import_react24.useCallback)(
2967
+ const hideColumns2 = (0, import_react25.useCallback)(
2901
2968
  (action) => {
2902
2969
  const { columns: columns2 } = action;
2903
2970
  const hiddenColumns = columns2.map((c) => c.name);
@@ -2911,11 +2978,11 @@ var useTable = ({
2911
2978
  },
2912
2979
  [tableConfig, applyTableConfigChange]
2913
2980
  );
2914
- const pinColumn3 = (0, import_react24.useCallback)(
2981
+ const pinColumn3 = (0, import_react25.useCallback)(
2915
2982
  (action) => {
2916
2983
  applyTableConfigChange({
2917
2984
  ...tableConfig,
2918
- columns: (0, import_vuu_utils21.updateColumn)(tableConfig.columns, {
2985
+ columns: (0, import_vuu_utils22.updateColumn)(tableConfig.columns, {
2919
2986
  ...action.column,
2920
2987
  pin: action.pin
2921
2988
  })
@@ -2934,7 +3001,7 @@ var useTable = ({
2934
3001
  onDataSourceConfigChange: handleDataSourceConfigChanged,
2935
3002
  tableConfig
2936
3003
  });
2937
- const onPersistentColumnOperation = (0, import_react24.useCallback)(
3004
+ const onPersistentColumnOperation = (0, import_react25.useCallback)(
2938
3005
  (action) => {
2939
3006
  if (isShowColumnSettings(action)) {
2940
3007
  showColumnSettingsPanel(action);
@@ -2947,12 +3014,12 @@ var useTable = ({
2947
3014
  case "pinColumn":
2948
3015
  return pinColumn3(action);
2949
3016
  default:
2950
- dispatchColumnAction(action);
3017
+ dispatchTableModelAction(action);
2951
3018
  }
2952
3019
  }
2953
3020
  },
2954
3021
  [
2955
- dispatchColumnAction,
3022
+ dispatchTableModelAction,
2956
3023
  hideColumns2,
2957
3024
  pinColumn3,
2958
3025
  showColumnSettingsPanel,
@@ -2963,10 +3030,10 @@ var useTable = ({
2963
3030
  dataSource,
2964
3031
  onPersistentColumnOperation
2965
3032
  });
2966
- const handleSort = (0, import_react24.useCallback)(
3033
+ const handleSort = (0, import_react25.useCallback)(
2967
3034
  (column, extendSort = false, sortType) => {
2968
3035
  if (dataSource) {
2969
- dataSource.sort = (0, import_vuu_utils21.applySort)(
3036
+ dataSource.sort = (0, import_vuu_utils22.applySort)(
2970
3037
  dataSource.sort,
2971
3038
  column,
2972
3039
  extendSort,
@@ -2976,8 +3043,8 @@ var useTable = ({
2976
3043
  },
2977
3044
  [dataSource]
2978
3045
  );
2979
- const resizeCells = (0, import_react24.useRef)();
2980
- const onResizeColumn = (0, import_react24.useCallback)(
3046
+ const resizeCells = (0, import_react25.useRef)();
3047
+ const onResizeColumn = (0, import_react25.useCallback)(
2981
3048
  (phase, columnName, width) => {
2982
3049
  var _a, _b, _c;
2983
3050
  const column = columns.find((column2) => column2.name === columnName);
@@ -2988,8 +3055,8 @@ var useTable = ({
2988
3055
  });
2989
3056
  } else if (phase === "end") {
2990
3057
  resizeCells.current = void 0;
2991
- if ((0, import_vuu_utils21.isValidNumber)(width)) {
2992
- dispatchColumnAction({
3058
+ if ((0, import_vuu_utils22.isValidNumber)(width)) {
3059
+ dispatchTableModelAction({
2993
3060
  type: "resizeColumn",
2994
3061
  phase,
2995
3062
  column,
@@ -3012,7 +3079,7 @@ var useTable = ({
3012
3079
  `.vuuTableCell${byColIndex},.vuuTableHeaderCell${byColIndex}`
3013
3080
  )) != null ? _c : []
3014
3081
  );
3015
- dispatchColumnAction({
3082
+ dispatchTableModelAction({
3016
3083
  type: "resizeColumn",
3017
3084
  phase,
3018
3085
  column,
@@ -3025,12 +3092,18 @@ var useTable = ({
3025
3092
  );
3026
3093
  }
3027
3094
  },
3028
- [columns, dispatchColumnAction, onConfigChange, tableConfig, containerRef]
3095
+ [
3096
+ columns,
3097
+ dispatchTableModelAction,
3098
+ onConfigChange,
3099
+ tableConfig,
3100
+ containerRef
3101
+ ]
3029
3102
  );
3030
- const onToggleGroup = (0, import_react24.useCallback)(
3103
+ const onToggleGroup = (0, import_react25.useCallback)(
3031
3104
  (row, column) => {
3032
3105
  var _a, _b;
3033
- const isJson = (0, import_vuu_utils21.isJsonGroup)(column, row, columnMap);
3106
+ const isJson = (0, import_vuu_utils22.isJsonGroup)(column, row, columnMap);
3034
3107
  const key = row[KEY];
3035
3108
  if (row[IS_EXPANDED2]) {
3036
3109
  dataSource.closeTreeNode(key, true);
@@ -3038,7 +3111,7 @@ var useTable = ({
3038
3111
  const idx = columns.indexOf(column);
3039
3112
  const rows = (_a = dataSource.getRowsAtDepth) == null ? void 0 : _a.call(dataSource, idx + 1);
3040
3113
  if (rows && !rows.some((row2) => row2[IS_EXPANDED2] || row2[IS_LEAF2])) {
3041
- dispatchColumnAction({
3114
+ dispatchTableModelAction({
3042
3115
  type: "hideColumns",
3043
3116
  columns: columns.slice(idx + 2)
3044
3117
  });
@@ -3054,7 +3127,7 @@ var useTable = ({
3054
3127
  columnsToShow.push(columns[idx + 1]);
3055
3128
  }
3056
3129
  if (columnsToShow.some((col) => col.hidden)) {
3057
- dispatchColumnAction({
3130
+ dispatchTableModelAction({
3058
3131
  type: "showColumns",
3059
3132
  columns: columnsToShow
3060
3133
  });
@@ -3062,7 +3135,7 @@ var useTable = ({
3062
3135
  }
3063
3136
  }
3064
3137
  },
3065
- [columnMap, columns, dataSource, dispatchColumnAction]
3138
+ [columnMap, columns, dataSource, dispatchTableModelAction]
3066
3139
  );
3067
3140
  const {
3068
3141
  highlightedIndexRef,
@@ -3090,7 +3163,7 @@ var useTable = ({
3090
3163
  } = useCellEditing({
3091
3164
  navigate
3092
3165
  });
3093
- const handleFocus = (0, import_react24.useCallback)(
3166
+ const handleFocus = (0, import_react25.useCallback)(
3094
3167
  (e) => {
3095
3168
  navigationFocus();
3096
3169
  if (!e.defaultPrevented) {
@@ -3105,15 +3178,15 @@ var useTable = ({
3105
3178
  dataSource,
3106
3179
  getSelectedRows
3107
3180
  });
3108
- const onMoveGroupColumn = (0, import_react24.useCallback)(
3181
+ const onMoveGroupColumn = (0, import_react25.useCallback)(
3109
3182
  (columns2) => {
3110
3183
  dataSource.groupBy = columns2.map((col) => col.name);
3111
3184
  },
3112
3185
  [dataSource]
3113
3186
  );
3114
- const onRemoveGroupColumn = (0, import_react24.useCallback)(
3187
+ const onRemoveGroupColumn = (0, import_react25.useCallback)(
3115
3188
  (column) => {
3116
- if ((0, import_vuu_utils21.isGroupColumn)(column)) {
3189
+ if ((0, import_vuu_utils22.isGroupColumn)(column)) {
3117
3190
  dataSource.groupBy = [];
3118
3191
  } else {
3119
3192
  if (dataSource && dataSource.groupBy.includes(column.name)) {
@@ -3125,7 +3198,7 @@ var useTable = ({
3125
3198
  },
3126
3199
  [dataSource]
3127
3200
  );
3128
- const handleSelectionChange = (0, import_react24.useCallback)(
3201
+ const handleSelectionChange = (0, import_react25.useCallback)(
3129
3202
  (selected) => {
3130
3203
  dataSource.select(selected);
3131
3204
  onSelectionChange == null ? void 0 : onSelectionChange(selected);
@@ -3141,7 +3214,7 @@ var useTable = ({
3141
3214
  onSelectionChange: handleSelectionChange,
3142
3215
  selectionModel
3143
3216
  });
3144
- const handleKeyDown = (0, import_react24.useCallback)(
3217
+ const handleKeyDown = (0, import_react25.useCallback)(
3145
3218
  (e) => {
3146
3219
  navigationKeyDown(e);
3147
3220
  if (!e.defaultPrevented) {
@@ -3153,42 +3226,42 @@ var useTable = ({
3153
3226
  },
3154
3227
  [navigationKeyDown, editingKeyDown, selectionHookKeyDown]
3155
3228
  );
3156
- const handleRowClick = (0, import_react24.useCallback)(
3229
+ const handleRowClick = (0, import_react25.useCallback)(
3157
3230
  (row, rangeSelect, keepExistingSelection) => {
3158
3231
  selectionHookOnRowClick(row, rangeSelect, keepExistingSelection);
3159
3232
  onRowClickProp == null ? void 0 : onRowClickProp(row);
3160
3233
  },
3161
3234
  [onRowClickProp, selectionHookOnRowClick]
3162
3235
  );
3163
- const onMoveColumn = (0, import_react24.useCallback)(
3236
+ const onMoveColumn = (0, import_react25.useCallback)(
3164
3237
  (columns2) => {
3165
3238
  const newTableConfig = {
3166
3239
  ...tableConfig,
3167
3240
  columns: columns2
3168
3241
  };
3169
- dispatchColumnAction({
3242
+ dispatchTableModelAction({
3170
3243
  type: "init",
3171
3244
  tableConfig: newTableConfig,
3172
3245
  dataSource
3173
3246
  });
3174
3247
  onConfigChange == null ? void 0 : onConfigChange(stripInternalProperties(newTableConfig));
3175
3248
  },
3176
- [dataSource, dispatchColumnAction, onConfigChange, tableConfig]
3249
+ [dataSource, dispatchTableModelAction, onConfigChange, tableConfig]
3177
3250
  );
3178
- const handleDropRow = (0, import_react24.useCallback)(
3251
+ const handleDropRow = (0, import_react25.useCallback)(
3179
3252
  (dragDropState) => {
3180
3253
  onDrop == null ? void 0 : onDrop(dragDropState);
3181
3254
  },
3182
3255
  [onDrop]
3183
3256
  );
3184
- const handleDataEdited = (0, import_react24.useCallback)(
3257
+ const handleDataEdited = (0, import_react25.useCallback)(
3185
3258
  async (row, columnName, value) => dataSource.applyEdit(row, columnName, value),
3186
3259
  [dataSource]
3187
3260
  );
3188
- const handleDragStartRow = (0, import_react24.useCallback)(
3261
+ const handleDragStartRow = (0, import_react25.useCallback)(
3189
3262
  (dragDropState) => {
3190
3263
  const { initialDragElement } = dragDropState;
3191
- const rowIndex = (0, import_vuu_utils21.getIndexFromRowElement)(initialDragElement);
3264
+ const rowIndex = (0, import_vuu_utils22.getIndexFromRowElement)(initialDragElement);
3192
3265
  const row = dataRef.current.find((row2) => row2[0] === rowIndex);
3193
3266
  if (row) {
3194
3267
  dragDropState.setPayload(row);
@@ -3211,6 +3284,7 @@ var useTable = ({
3211
3284
  return {
3212
3285
  ...containerProps,
3213
3286
  "aria-rowcount": dataSource.size,
3287
+ rowClassNameGenerator,
3214
3288
  draggableRow,
3215
3289
  onBlur: editingBlur,
3216
3290
  onDoubleClick: editingDoubleClick,
@@ -3242,10 +3316,48 @@ var useTable = ({
3242
3316
  };
3243
3317
  };
3244
3318
 
3319
+ // src/useRowHeight.ts
3320
+ var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
3321
+ var import_react26 = require("react");
3322
+ var useRowHeight = ({
3323
+ rowHeight: rowHeightProp = 0
3324
+ }) => {
3325
+ const [rowHeight, setRowHeight] = (0, import_react26.useState)(rowHeightProp);
3326
+ const heightRef = (0, import_react26.useRef)(rowHeight);
3327
+ const resizeObserver = (0, import_react26.useMemo)(() => {
3328
+ return new ResizeObserver((entries) => {
3329
+ for (const entry of entries) {
3330
+ const { height: measuredHeight } = entry.contentRect;
3331
+ const newHeight = Math.round(measuredHeight);
3332
+ if ((0, import_vuu_utils23.isValidNumber)(newHeight) && heightRef.current !== newHeight) {
3333
+ heightRef.current = newHeight;
3334
+ setRowHeight(newHeight);
3335
+ }
3336
+ }
3337
+ });
3338
+ }, []);
3339
+ const rowRef = (0, import_react26.useCallback)(
3340
+ (el) => {
3341
+ if (el) {
3342
+ if (rowHeightProp === 0) {
3343
+ const { height } = el.getBoundingClientRect();
3344
+ console.log(`measured rowHeight = ${height}`);
3345
+ resizeObserver.observe(el);
3346
+ setRowHeight(height);
3347
+ }
3348
+ } else {
3349
+ resizeObserver.disconnect();
3350
+ }
3351
+ },
3352
+ [resizeObserver, rowHeightProp]
3353
+ );
3354
+ return { rowHeight, rowRef };
3355
+ };
3356
+
3245
3357
  // src/Table.tsx
3246
3358
  var import_jsx_runtime12 = require("react/jsx-runtime");
3247
3359
  var classBase7 = "vuuTable";
3248
- var { IDX: IDX3, RENDER_IDX } = import_vuu_utils22.metadataKeys;
3360
+ var { IDX: IDX3, RENDER_IDX } = import_vuu_utils24.metadataKeys;
3249
3361
  var TableCore = ({
3250
3362
  Row: Row2 = Row,
3251
3363
  allowDragDrop,
@@ -3267,14 +3379,14 @@ var TableCore = ({
3267
3379
  onSelect,
3268
3380
  onSelectionChange,
3269
3381
  renderBufferSize = 5,
3270
- rowHeight = 20,
3382
+ rowHeight,
3271
3383
  scrollingApiRef,
3272
3384
  selectionModel = "extended",
3273
3385
  showColumnHeaders = true,
3274
- headerHeight = showColumnHeaders ? 25 : 0,
3386
+ headerHeight = showColumnHeaders ? rowHeight * 1.25 : 0,
3275
3387
  size
3276
3388
  }) => {
3277
- const id = (0, import_vuu_utils22.useId)(idProp);
3389
+ const id = (0, import_vuu_utils24.useId)(idProp);
3278
3390
  const {
3279
3391
  columnMap,
3280
3392
  columns,
@@ -3284,6 +3396,7 @@ var TableCore = ({
3284
3396
  handleContextMenuAction,
3285
3397
  headings,
3286
3398
  highlightedIndex,
3399
+ menuBuilder,
3287
3400
  onDataEdited,
3288
3401
  onMoveColumn,
3289
3402
  onMoveGroupColumn,
@@ -3292,7 +3405,7 @@ var TableCore = ({
3292
3405
  onRowClick,
3293
3406
  onSortColumn,
3294
3407
  onToggleGroup,
3295
- menuBuilder,
3408
+ rowClassNameGenerator,
3296
3409
  scrollProps,
3297
3410
  tableAttributes,
3298
3411
  tableConfig,
@@ -3336,7 +3449,7 @@ var TableCore = ({
3336
3449
  "--pinned-width-left": `${viewportMeasurements.pinnedWidthLeft}px`,
3337
3450
  "--pinned-width-right": `${viewportMeasurements.pinnedWidthRight}px`,
3338
3451
  "--header-height": `${headerHeight}px`,
3339
- "--row-height": `${rowHeight}px`,
3452
+ "--row-height-prop": `${rowHeight}px`,
3340
3453
  "--total-header-height": `${viewportMeasurements.totalHeaderHeight}px`,
3341
3454
  "--vertical-scrollbar-width": `${viewportMeasurements.verticalScrollbarWidth}px`,
3342
3455
  "--viewport-body-height": `${viewportMeasurements.viewportBodyHeight}px`
@@ -3389,6 +3502,7 @@ var TableCore = ({
3389
3502
  Row2,
3390
3503
  {
3391
3504
  "aria-rowindex": data2[0] + 1,
3505
+ classNameGenerator: rowClassNameGenerator,
3392
3506
  columnMap,
3393
3507
  columns: scrollProps.columnsWithinViewport,
3394
3508
  highlighted: highlightedIndex === data2[IDX3],
@@ -3412,7 +3526,7 @@ var TableCore = ({
3412
3526
  }
3413
3527
  );
3414
3528
  };
3415
- var Table = (0, import_react25.forwardRef)(function TableNext({
3529
+ var Table = (0, import_react27.forwardRef)(function TableNext({
3416
3530
  Row: Row2,
3417
3531
  allowDragDrop,
3418
3532
  availableColumns,
@@ -3433,7 +3547,7 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
3433
3547
  onSelect,
3434
3548
  onSelectionChange,
3435
3549
  renderBufferSize,
3436
- rowHeight,
3550
+ rowHeight: rowHeightProp,
3437
3551
  scrollingApiRef,
3438
3552
  selectionModel,
3439
3553
  showColumnHeaders,
@@ -3441,8 +3555,9 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
3441
3555
  style: styleProp,
3442
3556
  ...htmlAttributes
3443
3557
  }, forwardedRef) {
3444
- const containerRef = (0, import_react25.useRef)(null);
3445
- const [size, setSize] = (0, import_react25.useState)();
3558
+ const containerRef = (0, import_react27.useRef)(null);
3559
+ const [size, setSize] = (0, import_react27.useState)();
3560
+ const { rowHeight, rowRef } = useRowHeight({ rowHeight: rowHeightProp });
3446
3561
  if (config === void 0) {
3447
3562
  throw Error(
3448
3563
  "vuu Table requires config prop. Minimum config is list of Column Descriptors"
@@ -3451,7 +3566,7 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
3451
3566
  if (dataSource === void 0) {
3452
3567
  throw Error("vuu Table requires dataSource prop");
3453
3568
  }
3454
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3569
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
3455
3570
  import_vuu_ui_controls5.MeasuredContainer,
3456
3571
  {
3457
3572
  ...htmlAttributes,
@@ -3459,56 +3574,59 @@ var Table = (0, import_react25.forwardRef)(function TableNext({
3459
3574
  id,
3460
3575
  onResize: setSize,
3461
3576
  ref: (0, import_core2.useForkRef)(containerRef, forwardedRef),
3462
- children: size ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3463
- TableCore,
3464
- {
3465
- Row: Row2,
3466
- allowDragDrop,
3467
- availableColumns,
3468
- config,
3469
- containerRef,
3470
- dataSource,
3471
- disableFocus,
3472
- headerHeight,
3473
- highlightedIndex,
3474
- id,
3475
- navigationStyle,
3476
- onAvailableColumnsChange,
3477
- onConfigChange,
3478
- onDragStart,
3479
- onDrop,
3480
- onFeatureInvocation,
3481
- onHighlight,
3482
- onRowClick,
3483
- onSelect,
3484
- onSelectionChange,
3485
- renderBufferSize,
3486
- rowHeight,
3487
- scrollingApiRef,
3488
- selectionModel,
3489
- showColumnHeaders,
3490
- size
3491
- }
3492
- ) : null
3577
+ children: [
3578
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RowProxy, { ref: rowRef, height: rowHeightProp }),
3579
+ size && rowHeight ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
3580
+ TableCore,
3581
+ {
3582
+ Row: Row2,
3583
+ allowDragDrop,
3584
+ availableColumns,
3585
+ config,
3586
+ containerRef,
3587
+ dataSource,
3588
+ disableFocus,
3589
+ headerHeight,
3590
+ highlightedIndex,
3591
+ id,
3592
+ navigationStyle,
3593
+ onAvailableColumnsChange,
3594
+ onConfigChange,
3595
+ onDragStart,
3596
+ onDrop,
3597
+ onFeatureInvocation,
3598
+ onHighlight,
3599
+ onRowClick,
3600
+ onSelect,
3601
+ onSelectionChange,
3602
+ renderBufferSize,
3603
+ rowHeight,
3604
+ scrollingApiRef,
3605
+ selectionModel,
3606
+ showColumnHeaders,
3607
+ size
3608
+ }
3609
+ ) : null
3610
+ ]
3493
3611
  }
3494
3612
  );
3495
3613
  });
3496
3614
 
3497
3615
  // src/cell-renderers/checkbox-cell/CheckboxCell.tsx
3498
- var import_react26 = require("react");
3616
+ var import_react28 = require("react");
3499
3617
  var import_vuu_ui_controls6 = require("@vuu-ui/vuu-ui-controls");
3500
3618
  var import_core3 = require("@salt-ds/core");
3501
- var import_vuu_utils23 = require("@vuu-ui/vuu-utils");
3619
+ var import_vuu_utils25 = require("@vuu-ui/vuu-utils");
3502
3620
  var import_jsx_runtime13 = require("react/jsx-runtime");
3503
- var CheckboxCell = (0, import_react26.memo)(
3621
+ var CheckboxCell = (0, import_react28.memo)(
3504
3622
  ({ column, columnMap, onCommit = import_vuu_ui_controls6.WarnCommit, row }) => {
3505
3623
  const dataIdx = columnMap[column.name];
3506
- const isChecked = row[dataIdx];
3507
- const handleCommit = (0, import_react26.useCallback)(
3624
+ const isChecked = !!row[dataIdx];
3625
+ const handleCommit = (0, import_react28.useCallback)(
3508
3626
  (value) => async (evt) => {
3509
3627
  const res = await onCommit(value);
3510
3628
  if (res === true) {
3511
- (0, import_vuu_utils23.dispatchCustomEvent)(evt.target, "vuu-commit");
3629
+ (0, import_vuu_utils25.dispatchCustomEvent)(evt.target, "vuu-commit");
3512
3630
  }
3513
3631
  return res;
3514
3632
  },
@@ -3516,15 +3634,15 @@ var CheckboxCell = (0, import_react26.memo)(
3516
3634
  );
3517
3635
  return column.editable ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_core3.Checkbox, { checked: isChecked, onClick: handleCommit(!isChecked) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_vuu_ui_controls6.CheckboxIcon, { checked: isChecked, disabled: true });
3518
3636
  },
3519
- import_vuu_utils23.dataAndColumnUnchanged
3637
+ import_vuu_utils25.dataColumnAndKeyUnchanged
3520
3638
  );
3521
3639
  CheckboxCell.displayName = "CheckboxCell";
3522
- (0, import_vuu_utils23.registerComponent)("checkbox-cell", CheckboxCell, "cell-renderer", {
3640
+ (0, import_vuu_utils25.registerComponent)("checkbox-cell", CheckboxCell, "cell-renderer", {
3523
3641
  serverDataType: "boolean"
3524
3642
  });
3525
3643
 
3526
3644
  // src/cell-renderers/input-cell/InputCell.tsx
3527
- var import_vuu_utils24 = require("@vuu-ui/vuu-utils");
3645
+ var import_vuu_utils26 = require("@vuu-ui/vuu-utils");
3528
3646
  var import_core4 = require("@salt-ds/core");
3529
3647
  var import_vuu_ui_controls7 = require("@vuu-ui/vuu-ui-controls");
3530
3648
  var import_clsx10 = __toESM(require("clsx"));
@@ -3543,9 +3661,10 @@ var InputCell = ({
3543
3661
  row
3544
3662
  }) => {
3545
3663
  const dataIdx = columnMap[column.name];
3664
+ const dataValue = row[dataIdx];
3546
3665
  const { align = "left", clientSideEditValidationCheck } = column;
3547
3666
  const { warningMessage, ...editProps } = (0, import_vuu_ui_controls7.useEditableText)({
3548
- initialValue: row[dataIdx],
3667
+ initialValue: dataValue,
3549
3668
  onCommit,
3550
3669
  clientSideEditValidationCheck
3551
3670
  });
@@ -3563,18 +3682,20 @@ var InputCell = ({
3563
3682
  }
3564
3683
  );
3565
3684
  };
3566
- (0, import_vuu_utils24.registerComponent)("input-cell", InputCell, "cell-renderer", {});
3685
+ (0, import_vuu_utils26.registerComponent)("input-cell", InputCell, "cell-renderer", {
3686
+ userCanAssign: false
3687
+ });
3567
3688
 
3568
3689
  // src/cell-renderers/toggle-cell/ToggleCell.tsx
3569
3690
  var import_vuu_ui_controls8 = require("@vuu-ui/vuu-ui-controls");
3570
- var import_vuu_utils25 = require("@vuu-ui/vuu-utils");
3691
+ var import_vuu_utils27 = require("@vuu-ui/vuu-utils");
3571
3692
  var import_clsx11 = __toESM(require("clsx"));
3572
- var import_react27 = require("react");
3693
+ var import_react29 = require("react");
3573
3694
  var import_vuu_ui_controls9 = require("@vuu-ui/vuu-ui-controls");
3574
3695
  var import_jsx_runtime15 = require("react/jsx-runtime");
3575
3696
  var classBase9 = "vuuTableToggleCell";
3576
3697
  var getValueList = ({ name, type }) => {
3577
- if ((0, import_vuu_utils25.isTypeDescriptor)(type) && (0, import_vuu_utils25.isValueListRenderer)(type.renderer)) {
3698
+ if ((0, import_vuu_utils27.isTypeDescriptor)(type) && (0, import_vuu_utils27.isValueListRenderer)(type.renderer)) {
3578
3699
  return type.renderer.values;
3579
3700
  } else {
3580
3701
  throw Error(
@@ -3582,7 +3703,7 @@ var getValueList = ({ name, type }) => {
3582
3703
  );
3583
3704
  }
3584
3705
  };
3585
- var ToggleCell = (0, import_react27.memo)(
3706
+ var ToggleCell = (0, import_react29.memo)(
3586
3707
  function ToggleCell2({
3587
3708
  column,
3588
3709
  columnMap,
@@ -3592,11 +3713,11 @@ var ToggleCell = (0, import_react27.memo)(
3592
3713
  const values = getValueList(column);
3593
3714
  const dataIdx = columnMap[column.name];
3594
3715
  const value = row[dataIdx];
3595
- const handleCommit = (0, import_react27.useCallback)(
3716
+ const handleCommit = (0, import_react29.useCallback)(
3596
3717
  (evt, value2) => {
3597
3718
  return onCommit(value2).then((response) => {
3598
3719
  if (response === true) {
3599
- (0, import_vuu_utils25.dispatchCustomEvent)(evt.target, "vuu-commit");
3720
+ (0, import_vuu_utils27.dispatchCustomEvent)(evt.target, "vuu-commit");
3600
3721
  }
3601
3722
  return response;
3602
3723
  });
@@ -3615,18 +3736,20 @@ var ToggleCell = (0, import_react27.memo)(
3615
3736
  }
3616
3737
  );
3617
3738
  },
3618
- import_vuu_utils25.dataAndColumnUnchanged
3739
+ import_vuu_utils27.dataColumnAndKeyUnchanged
3619
3740
  );
3620
- (0, import_vuu_utils25.registerComponent)("toggle-cell", ToggleCell, "cell-renderer", {});
3741
+ (0, import_vuu_utils27.registerComponent)("toggle-cell", ToggleCell, "cell-renderer", {
3742
+ userCanAssign: false
3743
+ });
3621
3744
 
3622
3745
  // src/useControlledTableNavigation.ts
3623
3746
  var import_vuu_ui_controls10 = require("@vuu-ui/vuu-ui-controls");
3624
- var import_vuu_utils26 = require("@vuu-ui/vuu-utils");
3625
- var import_react28 = require("react");
3747
+ var import_vuu_utils28 = require("@vuu-ui/vuu-utils");
3748
+ var import_react30 = require("react");
3626
3749
  var useControlledTableNavigation = (initialValue, rowCount) => {
3627
- const tableRef = (0, import_react28.useRef)(null);
3750
+ const tableRef = (0, import_react30.useRef)(null);
3628
3751
  const [highlightedIndexRef, setHighlightedIndex] = (0, import_vuu_ui_controls10.useStateRef)(initialValue);
3629
- const handleKeyDown = (0, import_react28.useCallback)(
3752
+ const handleKeyDown = (0, import_react30.useCallback)(
3630
3753
  (e) => {
3631
3754
  var _a;
3632
3755
  if (e.key === "ArrowDown") {
@@ -3639,13 +3762,13 @@ var useControlledTableNavigation = (initialValue, rowCount) => {
3639
3762
  `[aria-rowindex="${rowIdx}"]`
3640
3763
  );
3641
3764
  if (rowEl) {
3642
- (0, import_vuu_utils26.dispatchMouseEvent)(rowEl, "click");
3765
+ (0, import_vuu_utils28.dispatchMouseEvent)(rowEl, "click");
3643
3766
  }
3644
3767
  }
3645
3768
  },
3646
3769
  [highlightedIndexRef, rowCount, setHighlightedIndex]
3647
3770
  );
3648
- const handleHighlight = (0, import_react28.useCallback)(
3771
+ const handleHighlight = (0, import_react30.useCallback)(
3649
3772
  (idx) => {
3650
3773
  setHighlightedIndex(idx);
3651
3774
  },