@mirror-physics/fractal-ui 0.2.0-next.66 → 0.2.0-next.67

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.cts CHANGED
@@ -298,6 +298,8 @@ interface SortableTableProps<T> {
298
298
  selection?: SortableTableSelection<T>;
299
299
  /** Disabled rows remain visible but cannot be selected or activated. */
300
300
  isRowDisabled?: (row: T) => boolean;
301
+ /** Disables only a row's selection control while preserving row activation. */
302
+ isRowSelectionDisabled?: (row: T) => boolean;
301
303
  /** Invoked when a row is selected. Enables pointer and keyboard row activation. */
302
304
  onRowClick?: (row: T, index: number) => void;
303
305
  /** Invoked when a row is double-clicked. */
@@ -305,7 +307,7 @@ interface SortableTableProps<T> {
305
307
  /** Directional affordance displayed over the right edge of an interactive row. */
306
308
  rowAction?: SortableTableRowAction<T>;
307
309
  }
308
- declare function SortableTable<T>({ columns, data, 'aria-label': ariaLabel, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, selection, isRowDisabled, onRowClick, onRowDoubleClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
310
+ declare function SortableTable<T>({ columns, data, 'aria-label': ariaLabel, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, selection, isRowDisabled, isRowSelectionDisabled, onRowClick, onRowDoubleClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
309
311
 
310
312
  interface TabItem {
311
313
  id: string;
package/dist/index.d.ts CHANGED
@@ -298,6 +298,8 @@ interface SortableTableProps<T> {
298
298
  selection?: SortableTableSelection<T>;
299
299
  /** Disabled rows remain visible but cannot be selected or activated. */
300
300
  isRowDisabled?: (row: T) => boolean;
301
+ /** Disables only a row's selection control while preserving row activation. */
302
+ isRowSelectionDisabled?: (row: T) => boolean;
301
303
  /** Invoked when a row is selected. Enables pointer and keyboard row activation. */
302
304
  onRowClick?: (row: T, index: number) => void;
303
305
  /** Invoked when a row is double-clicked. */
@@ -305,7 +307,7 @@ interface SortableTableProps<T> {
305
307
  /** Directional affordance displayed over the right edge of an interactive row. */
306
308
  rowAction?: SortableTableRowAction<T>;
307
309
  }
308
- declare function SortableTable<T>({ columns, data, 'aria-label': ariaLabel, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, selection, isRowDisabled, onRowClick, onRowDoubleClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
310
+ declare function SortableTable<T>({ columns, data, 'aria-label': ariaLabel, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, selection, isRowDisabled, isRowSelectionDisabled, onRowClick, onRowDoubleClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
309
311
 
310
312
  interface TabItem {
311
313
  id: string;
package/dist/index.js CHANGED
@@ -1372,6 +1372,7 @@ function SortableTable({
1372
1372
  highlightRow,
1373
1373
  selection,
1374
1374
  isRowDisabled,
1375
+ isRowSelectionDisabled,
1375
1376
  onRowClick,
1376
1377
  onRowDoubleClick,
1377
1378
  rowAction
@@ -1419,7 +1420,7 @@ function SortableTable({
1419
1420
  const startIndex = (page - 1) * pageSize;
1420
1421
  return sorted.slice(startIndex, startIndex + pageSize);
1421
1422
  }, [pagination, sorted]);
1422
- const selectableRows = selection ? data.filter((row) => !isRowDisabled?.(row)) : [];
1423
+ const selectableRows = selection ? data.filter((row) => !isRowDisabled?.(row) && !isRowSelectionDisabled?.(row)) : [];
1423
1424
  const selectedRowCount = selection ? selectableRows.filter(selection.isSelected).length : 0;
1424
1425
  const allRowsSelected = selectableRows.length > 0 && selectedRowCount === selectableRows.length;
1425
1426
  const someRowsSelected = selectedRowCount > 0 && !allRowsSelected;
@@ -1516,6 +1517,7 @@ function SortableTable({
1516
1517
  /* @__PURE__ */ jsx19("tbody", { children: visibleRows.map((row, rowIndex) => {
1517
1518
  const highlighted = highlightRow?.(row, rowIndex) ?? false;
1518
1519
  const disabled = isRowDisabled?.(row) ?? false;
1520
+ const selectionDisabled = disabled || (isRowSelectionDisabled?.(row) ?? false);
1519
1521
  const interactive = !disabled && Boolean(onRowClick || onRowDoubleClick);
1520
1522
  const action = !disabled && rowAction ? {
1521
1523
  label: rowAction.label(row, rowIndex),
@@ -1549,11 +1551,11 @@ function SortableTable({
1549
1551
  Checkbox,
1550
1552
  {
1551
1553
  "aria-label": selection.getRowLabel(row),
1552
- checked: !disabled && selection.isSelected(row),
1553
- disabled,
1554
+ checked: !selectionDisabled && selection.isSelected(row),
1555
+ disabled: selectionDisabled,
1554
1556
  onClick: (event) => event.stopPropagation(),
1555
1557
  onCheckedChange: (checked) => {
1556
- if (!disabled) selection.onSelectedChange(row, checked);
1558
+ if (!selectionDisabled) selection.onSelectedChange(row, checked);
1557
1559
  }
1558
1560
  }
1559
1561
  ) }),