@mirror-physics/fractal-ui 0.2.0-next.66 → 0.2.0-next.68
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.cjs +10 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -258,8 +258,13 @@ interface SortableTableRowAction<T> {
|
|
|
258
258
|
interface SortableTableSelection<T> {
|
|
259
259
|
/** Returns whether a row is selected. Selection is controlled by the consumer. */
|
|
260
260
|
isSelected: (row: T) => boolean;
|
|
261
|
-
/** Called when an individual row
|
|
261
|
+
/** Called when an individual row changes selection. */
|
|
262
262
|
onSelectedChange: (row: T, selected: boolean) => void;
|
|
263
|
+
/**
|
|
264
|
+
* Handles the complete selectable row set in one update when the header
|
|
265
|
+
* checkbox changes. Falls back to `onSelectedChange` for each row when omitted.
|
|
266
|
+
*/
|
|
267
|
+
onSelectAllChange?: (rows: T[], selected: boolean) => void;
|
|
263
268
|
/** Accessible name for an individual row's checkbox. */
|
|
264
269
|
getRowLabel: (row: T) => string;
|
|
265
270
|
/** Accessible name for the header checkbox. */
|
|
@@ -298,6 +303,8 @@ interface SortableTableProps<T> {
|
|
|
298
303
|
selection?: SortableTableSelection<T>;
|
|
299
304
|
/** Disabled rows remain visible but cannot be selected or activated. */
|
|
300
305
|
isRowDisabled?: (row: T) => boolean;
|
|
306
|
+
/** Disables only a row's selection control while preserving row activation. */
|
|
307
|
+
isRowSelectionDisabled?: (row: T) => boolean;
|
|
301
308
|
/** Invoked when a row is selected. Enables pointer and keyboard row activation. */
|
|
302
309
|
onRowClick?: (row: T, index: number) => void;
|
|
303
310
|
/** Invoked when a row is double-clicked. */
|
|
@@ -305,7 +312,7 @@ interface SortableTableProps<T> {
|
|
|
305
312
|
/** Directional affordance displayed over the right edge of an interactive row. */
|
|
306
313
|
rowAction?: SortableTableRowAction<T>;
|
|
307
314
|
}
|
|
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;
|
|
315
|
+
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
316
|
|
|
310
317
|
interface TabItem {
|
|
311
318
|
id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -258,8 +258,13 @@ interface SortableTableRowAction<T> {
|
|
|
258
258
|
interface SortableTableSelection<T> {
|
|
259
259
|
/** Returns whether a row is selected. Selection is controlled by the consumer. */
|
|
260
260
|
isSelected: (row: T) => boolean;
|
|
261
|
-
/** Called when an individual row
|
|
261
|
+
/** Called when an individual row changes selection. */
|
|
262
262
|
onSelectedChange: (row: T, selected: boolean) => void;
|
|
263
|
+
/**
|
|
264
|
+
* Handles the complete selectable row set in one update when the header
|
|
265
|
+
* checkbox changes. Falls back to `onSelectedChange` for each row when omitted.
|
|
266
|
+
*/
|
|
267
|
+
onSelectAllChange?: (rows: T[], selected: boolean) => void;
|
|
263
268
|
/** Accessible name for an individual row's checkbox. */
|
|
264
269
|
getRowLabel: (row: T) => string;
|
|
265
270
|
/** Accessible name for the header checkbox. */
|
|
@@ -298,6 +303,8 @@ interface SortableTableProps<T> {
|
|
|
298
303
|
selection?: SortableTableSelection<T>;
|
|
299
304
|
/** Disabled rows remain visible but cannot be selected or activated. */
|
|
300
305
|
isRowDisabled?: (row: T) => boolean;
|
|
306
|
+
/** Disables only a row's selection control while preserving row activation. */
|
|
307
|
+
isRowSelectionDisabled?: (row: T) => boolean;
|
|
301
308
|
/** Invoked when a row is selected. Enables pointer and keyboard row activation. */
|
|
302
309
|
onRowClick?: (row: T, index: number) => void;
|
|
303
310
|
/** Invoked when a row is double-clicked. */
|
|
@@ -305,7 +312,7 @@ interface SortableTableProps<T> {
|
|
|
305
312
|
/** Directional affordance displayed over the right edge of an interactive row. */
|
|
306
313
|
rowAction?: SortableTableRowAction<T>;
|
|
307
314
|
}
|
|
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;
|
|
315
|
+
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
316
|
|
|
310
317
|
interface TabItem {
|
|
311
318
|
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;
|
|
@@ -1462,6 +1463,10 @@ function SortableTable({
|
|
|
1462
1463
|
disabled: selectableRows.length === 0,
|
|
1463
1464
|
indeterminate: someRowsSelected,
|
|
1464
1465
|
onCheckedChange: (checked) => {
|
|
1466
|
+
if (selection.onSelectAllChange) {
|
|
1467
|
+
selection.onSelectAllChange(selectableRows, checked);
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1465
1470
|
selectableRows.forEach((row) => {
|
|
1466
1471
|
if (selection.isSelected(row) !== checked) {
|
|
1467
1472
|
selection.onSelectedChange(row, checked);
|
|
@@ -1516,6 +1521,7 @@ function SortableTable({
|
|
|
1516
1521
|
/* @__PURE__ */ jsx19("tbody", { children: visibleRows.map((row, rowIndex) => {
|
|
1517
1522
|
const highlighted = highlightRow?.(row, rowIndex) ?? false;
|
|
1518
1523
|
const disabled = isRowDisabled?.(row) ?? false;
|
|
1524
|
+
const selectionDisabled = disabled || (isRowSelectionDisabled?.(row) ?? false);
|
|
1519
1525
|
const interactive = !disabled && Boolean(onRowClick || onRowDoubleClick);
|
|
1520
1526
|
const action = !disabled && rowAction ? {
|
|
1521
1527
|
label: rowAction.label(row, rowIndex),
|
|
@@ -1549,11 +1555,11 @@ function SortableTable({
|
|
|
1549
1555
|
Checkbox,
|
|
1550
1556
|
{
|
|
1551
1557
|
"aria-label": selection.getRowLabel(row),
|
|
1552
|
-
checked: !
|
|
1553
|
-
disabled,
|
|
1558
|
+
checked: !selectionDisabled && selection.isSelected(row),
|
|
1559
|
+
disabled: selectionDisabled,
|
|
1554
1560
|
onClick: (event) => event.stopPropagation(),
|
|
1555
1561
|
onCheckedChange: (checked) => {
|
|
1556
|
-
if (!
|
|
1562
|
+
if (!selectionDisabled) selection.onSelectedChange(row, checked);
|
|
1557
1563
|
}
|
|
1558
1564
|
}
|
|
1559
1565
|
) }),
|