@alaarab/ogrid-react 2.4.0 → 2.4.2

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/dist/esm/index.js CHANGED
@@ -1200,7 +1200,8 @@ function computeCellDescriptor(item, col, rowIndex, colIdx, input) {
1200
1200
  globalColIndex,
1201
1201
  rowId,
1202
1202
  rowIndex,
1203
- displayValue: formulaDisplay !== void 0 ? formulaDisplay : cellValue
1203
+ displayValue: formulaDisplay !== void 0 ? formulaDisplay : cellValue,
1204
+ columnType: col.type
1204
1205
  };
1205
1206
  }
1206
1207
  function resolveCellDisplayContent(col, item, displayValue) {
@@ -1314,6 +1315,8 @@ var CHECKBOX_COLUMN_WIDTH = 48;
1314
1315
  var ROW_NUMBER_COLUMN_WIDTH = 50;
1315
1316
  var DEFAULT_MIN_COLUMN_WIDTH = 80;
1316
1317
  var CELL_PADDING = 16;
1318
+ var ROW_NUMBER_COLUMN_MIN_WIDTH = 30;
1319
+ var ROW_NUMBER_COLUMN_ID = "__row_number__";
1317
1320
  var GRID_BORDER_RADIUS = 6;
1318
1321
  var AUTOSIZE_EXTRA_PX = 16;
1319
1322
  var AUTOSIZE_MAX_PX = 520;
@@ -8803,6 +8806,7 @@ function useKeyboardNavigation(params) {
8803
8806
  case "ArrowUp":
8804
8807
  case "ArrowRight":
8805
8808
  case "ArrowLeft": {
8809
+ if (editingCell != null) break;
8806
8810
  e.preventDefault();
8807
8811
  const { newRowIndex, newColumnIndex, newRange } = computeArrowNavigation({
8808
8812
  direction: e.key,
@@ -10792,9 +10796,10 @@ function useColumnResize({
10792
10796
  [columnId]: { widthPx: latestWidth }
10793
10797
  }));
10794
10798
  };
10799
+ const effectiveMinWidth = columnId === ROW_NUMBER_COLUMN_ID ? ROW_NUMBER_COLUMN_MIN_WIDTH : minWidth;
10795
10800
  const onMove = (moveEvent) => {
10796
10801
  const deltaX = moveEvent.clientX - startX;
10797
- latestWidth = Math.max(minWidth, startWidth + deltaX);
10802
+ latestWidth = Math.max(effectiveMinWidth, startWidth + deltaX);
10798
10803
  if (!rafRef.current) {
10799
10804
  rafRef.current = requestAnimationFrame(() => {
10800
10805
  rafRef.current = 0;
@@ -10855,9 +10860,14 @@ function getSelectDisplayText(value, formatValue) {
10855
10860
  return value != null ? String(value) : "";
10856
10861
  }
10857
10862
  function useRichSelectState(params) {
10858
- const { values, formatValue, onCommit, onCancel } = params;
10863
+ const { values, formatValue, initialValue, onCommit, onCancel } = params;
10859
10864
  const [searchText, setSearchText] = useState("");
10860
- const [highlightedIndex, setHighlightedIndex] = useState(0);
10865
+ const initialIndex = values.findIndex((v) => String(v) === String(initialValue));
10866
+ const [highlightedIndex, setHighlightedIndex] = useState(Math.max(initialIndex, 0));
10867
+ useEffect(() => {
10868
+ const idx = values.findIndex((v) => String(v) === String(initialValue));
10869
+ setHighlightedIndex(Math.max(idx, 0));
10870
+ }, [initialValue, values]);
10861
10871
  const getDisplayText = useCallback(
10862
10872
  (value) => getSelectDisplayText(value, formatValue),
10863
10873
  [formatValue]
@@ -10919,6 +10929,10 @@ function useSelectState(params) {
10919
10929
  );
10920
10930
  const initialIndex = values.findIndex((v) => String(v) === String(initialValue));
10921
10931
  const [highlightedIndex, setHighlightedIndex] = useState(Math.max(initialIndex, 0));
10932
+ useEffect(() => {
10933
+ const idx = values.findIndex((v) => String(v) === String(initialValue));
10934
+ setHighlightedIndex(Math.max(idx, 0));
10935
+ }, [initialValue, values]);
10922
10936
  useEffect(() => {
10923
10937
  const dropdown = dropdownRef.current;
10924
10938
  if (!dropdown) return;
@@ -12990,12 +13004,15 @@ var selectChevronStyle = {
12990
13004
  function BaseInlineCellEditor(props) {
12991
13005
  const { value, column, editorType, onCommit, onCancel, renderCheckbox } = props;
12992
13006
  const wrapperRef = React5.useRef(null);
13007
+ const onCancelRef = React5.useRef(onCancel);
13008
+ onCancelRef.current = onCancel;
12993
13009
  const { localValue, setLocalValue, handleKeyDown, handleBlur, commit, cancel } = useInlineCellEditorState({ value, editorType, onCommit, onCancel });
12994
13010
  const editorValues = column.cellEditorParams?.values ?? [];
12995
13011
  const editorFormatValue = column.cellEditorParams?.formatValue;
12996
13012
  const richSelect = useRichSelectState({
12997
13013
  values: editorValues,
12998
13014
  formatValue: editorFormatValue,
13015
+ initialValue: value,
12999
13016
  onCommit,
13000
13017
  onCancel
13001
13018
  });
@@ -13028,6 +13045,16 @@ function BaseInlineCellEditor(props) {
13028
13045
  boxShadow: "var(--ogrid-shadow, 0 4px 16px rgba(0,0,0,0.2))",
13029
13046
  textAlign: "left"
13030
13047
  });
13048
+ const scrollParent = wrapper.closest(".ogrid-table-wrapper") ?? wrapper.closest('[style*="overflow"]');
13049
+ const handleScroll = () => onCancelRef.current();
13050
+ if (scrollParent) {
13051
+ scrollParent.addEventListener("scroll", handleScroll, { passive: true });
13052
+ }
13053
+ window.addEventListener("scroll", handleScroll, { passive: true });
13054
+ return () => {
13055
+ if (scrollParent) scrollParent.removeEventListener("scroll", handleScroll);
13056
+ window.removeEventListener("scroll", handleScroll);
13057
+ };
13031
13058
  }, [editorType]);
13032
13059
  const computedDropdownStyle = fixedDropdownStyle ?? richSelectDropdownStyle;
13033
13060
  React5.useEffect(() => {
@@ -13893,4 +13920,4 @@ function createBaseFilterRenderers(components, dateClassNames) {
13893
13920
  };
13894
13921
  }
13895
13922
 
13896
- export { BaseColumnHeaderMenu, BaseDropIndicator, BaseEmptyState, BaseInlineCellEditor, BaseLoadingOverlay, CELL_PADDING, CHECKBOX_COLUMN_WIDTH, COLUMN_HEADER_MENU_ITEMS, CURSOR_CELL_STYLE, CellDescriptorCache, CellErrorBoundary, ColumnChooserContent, DEFAULT_MIN_COLUMN_WIDTH, DateFilterContent, EmptyState, FormulaBar, FormulaRefOverlay, GRID_BORDER_RADIUS, GRID_CONTEXT_MENU_ITEMS, GRID_ROOT_STYLE, GridContextMenu, MAX_PAGE_BUTTONS, MarchingAntsOverlay, NOOP3 as NOOP, OGridLayout, PAGE_SIZE_OPTIONS, POPOVER_ANCHOR_STYLE, PREVENT_DEFAULT, PaginationControlsBase, ROW_NUMBER_COLUMN_WIDTH, STOP_PROPAGATION, SheetTabs, SideBar, StatusBar, UndoRedoStack, areGridRowPropsEqual, booleanParser, buildCsvHeader, buildCsvRows, buildHeaderRows, buildInlineEditorProps2 as buildInlineEditorProps, buildPopoverEditorProps2 as buildPopoverEditorProps, clampSelectionToBounds, computeAggregations, computeAutoScrollSpeed, computeTabNavigation, createBaseFilterRenderers, createOGrid, currencyParser, dateParser, deriveFilterOptionsFromData, editorInputStyle, editorWrapperStyle, emailParser, escapeCsvValue, exportToCsv, findCtrlArrowTarget, flattenColumns, formatCellReference, formatCellValueForTsv, formatSelectionAsTsv, formatShortcut, getCellInteractionProps, getCellRenderDescriptor, getCellValue, getColumnHeaderFilterStateParams, getColumnHeaderMenuItems, getColumnHeaderMenuProps, getContextMenuHandlers, getDataGridStatusBarConfig, getDateFilterContentProps, getFilterField, getHeaderFilterConfig, getMultiSelectFilterFields, getPaginationViewModel, getStatusBarParts, indexToColumnLetter, isInSelectionRange, isRowInRange, mergeFilter, normalizeSelectionRange, numberParser, parseTsvClipboard, parseValue, partitionColumnsForVirtualization, processClientSideData, rangesEqual, renderFilterContent, resolveCellDisplayContent2 as resolveCellDisplayContent, resolveCellStyle2 as resolveCellStyle, richSelectDropdownStyle, richSelectNoMatchesStyle, richSelectOptionHighlightedStyle, richSelectOptionStyle, richSelectWrapperStyle, selectChevronStyle, selectDisplayStyle, selectEditorStyle, toUserLike, triggerCsvDownload, useActiveCell, useCellEditing, useCellSelection, useClipboard, useColumnChooserState, useColumnHeaderFilterState, useColumnMeta, useColumnReorder, useColumnResize, useContextMenu, useDataGridState, useDataGridTableOrchestration, useDateFilterState, useDebounce, useFillHandle, useFilterOptions, useFormulaBar, useFormulaEngine, useInlineCellEditorState, useKeyboardNavigation, useLatestRef, useListVirtualizer, useMultiSelectFilterState, useOGrid, usePaginationControls, usePeopleFilterState, useRichSelectState, useRowSelection, useSelectState, useSideBarState, useTableLayout, useTextFilterState, useUndoRedo, useVirtualScroll };
13923
+ export { BaseColumnHeaderMenu, BaseDropIndicator, BaseEmptyState, BaseInlineCellEditor, BaseLoadingOverlay, CELL_PADDING, CHECKBOX_COLUMN_WIDTH, COLUMN_HEADER_MENU_ITEMS, CURSOR_CELL_STYLE, CellDescriptorCache, CellErrorBoundary, ColumnChooserContent, DEFAULT_MIN_COLUMN_WIDTH, DateFilterContent, EmptyState, FormulaBar, FormulaRefOverlay, GRID_BORDER_RADIUS, GRID_CONTEXT_MENU_ITEMS, GRID_ROOT_STYLE, GridContextMenu, MAX_PAGE_BUTTONS, MarchingAntsOverlay, NOOP3 as NOOP, OGridLayout, PAGE_SIZE_OPTIONS, POPOVER_ANCHOR_STYLE, PREVENT_DEFAULT, PaginationControlsBase, ROW_NUMBER_COLUMN_ID, ROW_NUMBER_COLUMN_MIN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, STOP_PROPAGATION, SheetTabs, SideBar, StatusBar, UndoRedoStack, areGridRowPropsEqual, booleanParser, buildCsvHeader, buildCsvRows, buildHeaderRows, buildInlineEditorProps2 as buildInlineEditorProps, buildPopoverEditorProps2 as buildPopoverEditorProps, clampSelectionToBounds, computeAggregations, computeAutoScrollSpeed, computeTabNavigation, createBaseFilterRenderers, createOGrid, currencyParser, dateParser, deriveFilterOptionsFromData, editorInputStyle, editorWrapperStyle, emailParser, escapeCsvValue, exportToCsv, findCtrlArrowTarget, flattenColumns, formatCellReference, formatCellValueForTsv, formatSelectionAsTsv, formatShortcut, getCellInteractionProps, getCellRenderDescriptor, getCellValue, getColumnHeaderFilterStateParams, getColumnHeaderMenuItems, getColumnHeaderMenuProps, getContextMenuHandlers, getDataGridStatusBarConfig, getDateFilterContentProps, getFilterField, getHeaderFilterConfig, getMultiSelectFilterFields, getPaginationViewModel, getStatusBarParts, indexToColumnLetter, isInSelectionRange, isRowInRange, mergeFilter, normalizeSelectionRange, numberParser, parseTsvClipboard, parseValue, partitionColumnsForVirtualization, processClientSideData, rangesEqual, renderFilterContent, resolveCellDisplayContent2 as resolveCellDisplayContent, resolveCellStyle2 as resolveCellStyle, richSelectDropdownStyle, richSelectNoMatchesStyle, richSelectOptionHighlightedStyle, richSelectOptionStyle, richSelectWrapperStyle, selectChevronStyle, selectDisplayStyle, selectEditorStyle, toUserLike, triggerCsvDownload, useActiveCell, useCellEditing, useCellSelection, useClipboard, useColumnChooserState, useColumnHeaderFilterState, useColumnMeta, useColumnReorder, useColumnResize, useContextMenu, useDataGridState, useDataGridTableOrchestration, useDateFilterState, useDebounce, useFillHandle, useFilterOptions, useFormulaBar, useFormulaEngine, useInlineCellEditorState, useKeyboardNavigation, useLatestRef, useListVirtualizer, useMultiSelectFilterState, useOGrid, usePaginationControls, usePeopleFilterState, useRichSelectState, useRowSelection, useSelectState, useSideBarState, useTableLayout, useTextFilterState, useUndoRedo, useVirtualScroll };
@@ -1,4 +1,4 @@
1
- export { CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, CELL_PADDING, GRID_BORDER_RADIUS, } from '@alaarab/ogrid-core';
1
+ export { CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, ROW_NUMBER_COLUMN_MIN_WIDTH, ROW_NUMBER_COLUMN_ID, DEFAULT_MIN_COLUMN_WIDTH, CELL_PADDING, GRID_BORDER_RADIUS, } from '@alaarab/ogrid-core';
2
2
  export type { ColumnFilterType, IColumnFilterDef, IColumnMeta, IColumnDef, IColumnGroupDef, IColumnDefinition, ICellValueChangedEvent, ICellEditorProps, CellEditorParams, IValueParserParams, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, IOGridApi, IOGridProps, IOGridDataGridProps, RowSelectionMode, RowId, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, HeaderCell, HeaderRow, SideBarPanelId, ISideBarDef, IDateFilterValue, IVirtualScrollConfig, IColumnReorderConfig, ISheetDef, } from './types';
3
3
  export { toUserLike, isInSelectionRange, normalizeSelectionRange } from './types';
4
4
  export { useFilterOptions, useOGrid, useActiveCell, useCellEditing, useContextMenu, useCellSelection, useClipboard, useRowSelection, useKeyboardNavigation, useUndoRedo, useDebounce, useFillHandle, useDataGridState, useColumnHeaderFilterState, useTextFilterState, useMultiSelectFilterState, usePeopleFilterState, useDateFilterState, useColumnChooserState, useInlineCellEditorState, useColumnResize, useRichSelectState, useSelectState, useSideBarState, useTableLayout, useColumnReorder, useVirtualScroll, useListVirtualizer, useLatestRef, usePaginationControls, useDataGridTableOrchestration, useColumnMeta, useFormulaEngine, useFormulaBar, getColumnHeaderMenuProps, } from './hooks';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-react",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "OGrid React – React hooks, headless components, and utilities for OGrid data grids.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -39,7 +39,7 @@
39
39
  "node": ">=18"
40
40
  },
41
41
  "dependencies": {
42
- "@alaarab/ogrid-core": "2.4.0",
42
+ "@alaarab/ogrid-core": "2.4.2",
43
43
  "@tanstack/react-virtual": "^3.0.0"
44
44
  },
45
45
  "peerDependencies": {