@mirror-physics/fractal-ui 0.2.0-next.60 → 0.2.0-next.61

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
@@ -284,10 +284,12 @@ interface SortableTableProps<T> {
284
284
  highlightRow?: (row: T, index: number) => boolean;
285
285
  /** Invoked when a row is selected. Enables pointer and keyboard row activation. */
286
286
  onRowClick?: (row: T, index: number) => void;
287
+ /** Invoked when a row is double-clicked. */
288
+ onRowDoubleClick?: (row: T, index: number) => void;
287
289
  /** Directional affordance displayed over the right edge of an interactive row. */
288
290
  rowAction?: SortableTableRowAction<T>;
289
291
  }
290
- declare function SortableTable<T>({ columns, data, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, onRowClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
292
+ declare function SortableTable<T>({ columns, data, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, onRowClick, onRowDoubleClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
291
293
 
292
294
  interface TabItem {
293
295
  id: string;
package/dist/index.d.ts CHANGED
@@ -284,10 +284,12 @@ interface SortableTableProps<T> {
284
284
  highlightRow?: (row: T, index: number) => boolean;
285
285
  /** Invoked when a row is selected. Enables pointer and keyboard row activation. */
286
286
  onRowClick?: (row: T, index: number) => void;
287
+ /** Invoked when a row is double-clicked. */
288
+ onRowDoubleClick?: (row: T, index: number) => void;
287
289
  /** Directional affordance displayed over the right edge of an interactive row. */
288
290
  rowAction?: SortableTableRowAction<T>;
289
291
  }
290
- declare function SortableTable<T>({ columns, data, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, onRowClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
292
+ declare function SortableTable<T>({ columns, data, emptyMessage, header, size, embedded, className, defaultSort, defaultSortKey, defaultSortDirection, sortKey: controlledKey, sortDirection: controlledDirection, onSortChange, pagination, highlightRow, onRowClick, onRowDoubleClick, rowAction, }: SortableTableProps<T>): React.JSX.Element;
291
293
 
292
294
  interface TabItem {
293
295
  id: string;
package/dist/index.js CHANGED
@@ -1354,6 +1354,7 @@ function SortableTable({
1354
1354
  pagination,
1355
1355
  highlightRow,
1356
1356
  onRowClick,
1357
+ onRowDoubleClick,
1357
1358
  rowAction
1358
1359
  }) {
1359
1360
  const [internalKey, setInternalKey] = useState5(defaultSortKey ?? null);
@@ -1464,6 +1465,7 @@ function SortableTable({
1464
1465
  }) }) }),
1465
1466
  /* @__PURE__ */ jsx19("tbody", { children: visibleRows.map((row, rowIndex) => {
1466
1467
  const highlighted = highlightRow?.(row, rowIndex) ?? false;
1468
+ const interactive = Boolean(onRowClick || onRowDoubleClick);
1467
1469
  const action = rowAction ? {
1468
1470
  label: rowAction.label(row, rowIndex),
1469
1471
  icon: rowAction.icon(row, rowIndex)
@@ -1474,18 +1476,20 @@ function SortableTable({
1474
1476
  className: cn(
1475
1477
  "fractal-sortable-table-row",
1476
1478
  highlighted && "fractal-sortable-table-row--highlighted",
1477
- onRowClick && "fractal-sortable-table-row--interactive"
1479
+ interactive && "fractal-sortable-table-row--interactive"
1478
1480
  ),
1479
1481
  onClick: onRowClick ? () => onRowClick(row, rowIndex) : void 0,
1480
- onKeyDown: onRowClick ? (event) => {
1482
+ onDoubleClick: onRowDoubleClick ? () => onRowDoubleClick(row, rowIndex) : void 0,
1483
+ onKeyDown: interactive ? (event) => {
1481
1484
  if (event.key === "Enter" || event.key === " ") {
1482
1485
  event.preventDefault();
1483
- onRowClick(row, rowIndex);
1486
+ const activateRow = onRowClick ?? onRowDoubleClick;
1487
+ activateRow?.(row, rowIndex);
1484
1488
  }
1485
1489
  } : void 0,
1486
1490
  "aria-label": action?.label,
1487
- role: onRowClick ? "button" : void 0,
1488
- tabIndex: onRowClick ? 0 : void 0,
1491
+ role: interactive ? "button" : void 0,
1492
+ tabIndex: interactive ? 0 : void 0,
1489
1493
  children: columns.map((col, columnIndex) => /* @__PURE__ */ jsxs16(
1490
1494
  "td",
1491
1495
  {