@postxl/ui-components 1.3.8 → 1.3.10

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/index.d.ts CHANGED
@@ -1010,6 +1010,7 @@ declare function useDataGrid<TData>({
1010
1010
  //#region src/data-grid/data-grid.d.ts
1011
1011
  type DataGridProps<TData> = {
1012
1012
  height?: number;
1013
+ forceHeight?: boolean;
1013
1014
  } & ReturnType<typeof useDataGrid<TData>> & React$28.ComponentProps<'div'>;
1014
1015
  declare function DataGrid<TData>({
1015
1016
  dataGridRef,
@@ -1019,6 +1020,7 @@ declare function DataGrid<TData>({
1019
1020
  table,
1020
1021
  rowVirtualizer,
1021
1022
  height,
1023
+ forceHeight,
1022
1024
  searchState,
1023
1025
  columnSizeVars,
1024
1026
  onRowAdd,
package/dist/index.js CHANGED
@@ -4132,7 +4132,7 @@ function DataGridSearchImpl({ searchMatches, matchIndex, searchOpen, onSearchOpe
4132
4132
 
4133
4133
  //#endregion
4134
4134
  //#region src/data-grid/data-grid.tsx
4135
- function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirtualizer, height, searchState, columnSizeVars, onRowAdd, className,...props }) {
4135
+ function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirtualizer, height, forceHeight = false, searchState, columnSizeVars, onRowAdd, className,...props }) {
4136
4136
  const rows = table.getRowModel().rows;
4137
4137
  const columns = table.getAllColumns();
4138
4138
  const meta = table.options.meta;
@@ -4181,10 +4181,10 @@ function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirt
4181
4181
  "data-slot": "grid",
4182
4182
  tabIndex: 0,
4183
4183
  ref: dataGridRef,
4184
- className: "relative grid select-none overflow-auto rounded-md border border-border focus:outline-none",
4184
+ className: cn("relative grid select-none overflow-auto rounded-md border border-border focus:outline-none", forceHeight && "content-start"),
4185
4185
  style: {
4186
4186
  ...columnSizeVars,
4187
- height: `${Math.min(rowVirtualizer.getTotalSize() + headerHeight + footerHeight + scrollbarHeight + 3, height ?? Infinity)}px`
4187
+ height: `${forceHeight && height ? height : Math.min(rowVirtualizer.getTotalSize() + headerHeight + footerHeight + scrollbarHeight + 3, height ?? Infinity)}px`
4188
4188
  },
4189
4189
  onContextMenu: onGridContextMenu,
4190
4190
  children: [
@@ -4301,8 +4301,9 @@ function DataGrid({ dataGridRef, headerRef, rowMapRef, footerRef, table, rowVirt
4301
4301
  //#endregion
4302
4302
  //#region src/data-grid/cell-variants/checkbox-cell.tsx
4303
4303
  function CheckboxCell({ cell, table, rowIndex, columnId, isFocused, isSelected }) {
4304
- const initialValue = cell.getValue();
4305
- const [value, setValue] = React$24.useState(Boolean(initialValue));
4304
+ const cellValue = cell.getValue();
4305
+ const cellValueAsBoolean = Boolean(cellValue);
4306
+ const [value, setValue] = React$24.useState(cellValueAsBoolean);
4306
4307
  const containerRef = React$24.useRef(null);
4307
4308
  const meta = table.options.meta;
4308
4309
  const colMeta = cell.column.columnDef.meta;
@@ -4338,8 +4339,8 @@ function CheckboxCell({ cell, table, rowIndex, columnId, isFocused, isSelected }
4338
4339
  isEditable
4339
4340
  ]);
4340
4341
  React$24.useEffect(() => {
4341
- setValue(Boolean(initialValue));
4342
- }, [initialValue]);
4342
+ setValue(cellValueAsBoolean);
4343
+ }, [cellValueAsBoolean]);
4343
4344
  React$24.useEffect(() => {
4344
4345
  if (isFocused && !meta?.searchOpen && !meta?.isScrolling && containerRef.current) containerRef.current.focus();
4345
4346
  }, [
@@ -6680,6 +6681,13 @@ function useDataGrid({ columns, data, onDataChange, onRowAdd: onRowAddProp, onRo
6680
6681
  debouncedRowClick
6681
6682
  ]);
6682
6683
  const onCellEditingStart = React$13.useCallback((rowIndex, columnId) => {
6684
+ const col = tableRef.current?.getColumn(columnId);
6685
+ const editable = col?.columnDef?.meta?.editable;
6686
+ if (editable === false) return;
6687
+ if (typeof editable === "function") {
6688
+ const row = tableRef.current?.getRowModel().rows[rowIndex]?.original;
6689
+ if (row && !editable(row)) return;
6690
+ }
6683
6691
  store.batch(() => {
6684
6692
  store.setState("focusedCell", {
6685
6693
  rowIndex,