@aircall/ds 0.35.4 → 0.36.0
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/{data-table-C9eD8va8.d.ts → data-table-CKJNxqjI.d.ts} +15 -2
- package/dist/{data-table-C_8IrmFW.js → data-table-DhQHgJbc.js} +5 -4
- package/dist/data-table.d.ts +2 -2
- package/dist/data-table.js +1 -1
- package/dist/globals.css +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { ColumnDef, OnChangeFn, RowData, SortingState } from "@tanstack/react-table";
|
|
2
|
+
import { ColumnDef, OnChangeFn, RowData, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
3
3
|
//#region src/components/data-table.d.ts
|
|
4
4
|
declare module '@tanstack/react-table' {
|
|
5
5
|
interface ColumnMeta<TData extends RowData, TValue> {
|
|
@@ -23,6 +23,8 @@ type ColumnDef$1<TData extends RowData, TValue = unknown> = ColumnDef<TData, TVa
|
|
|
23
23
|
type SortingState$1 = SortingState;
|
|
24
24
|
/** Change handler used by `DataTable`'s controlled props (e.g. `onSortingChange`). Bound alias of TanStack Table's `OnChangeFn`. */
|
|
25
25
|
type OnChangeFn$1<TState> = OnChangeFn<TState>;
|
|
26
|
+
/** Column visibility state for `DataTable`'s `columnVisibility` prop. Bound alias of TanStack Table's `VisibilityState` — a record of column id to `boolean`, `false` hides it. */
|
|
27
|
+
type VisibilityState$1 = VisibilityState;
|
|
26
28
|
/** Async states a `DataTable` can be in (mirrors React Spectrum's `loadingState`). */
|
|
27
29
|
type DataTableLoadingState = 'idle' | 'loading' | 'sorting' | 'filtering' | 'loadingMore';
|
|
28
30
|
interface DataTableProps<TData> {
|
|
@@ -68,6 +70,17 @@ interface DataTableProps<TData> {
|
|
|
68
70
|
* column def to pin it (e.g. an actions column).
|
|
69
71
|
*/
|
|
70
72
|
enableColumnResizing?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Controlled column visibility state — a record of column id to `boolean`,
|
|
75
|
+
* `false` hides it (columns default to visible when absent). Intended to be
|
|
76
|
+
* driven by a column picker built outside `DataTable`, using the same
|
|
77
|
+
* column ids passed via `columns`.
|
|
78
|
+
*
|
|
79
|
+
* A column def's `enableHiding: false` (as set internally on the selection
|
|
80
|
+
* column) is only a signal for what a column picker should offer toggling
|
|
81
|
+
* for — `DataTable` does not itself enforce it against `columnVisibility`.
|
|
82
|
+
*/
|
|
83
|
+
columnVisibility?: VisibilityState$1;
|
|
71
84
|
/**
|
|
72
85
|
* The type of selection allowed (mirrors React Spectrum's `selectionMode`):
|
|
73
86
|
* - `'none'` — selection off; no checkbox column (default).
|
|
@@ -176,4 +189,4 @@ declare namespace DataTable {
|
|
|
176
189
|
type Props<TData> = DataTableProps<TData>;
|
|
177
190
|
}
|
|
178
191
|
//#endregion
|
|
179
|
-
export { SortingState$1 as a, OnChangeFn$1 as i, DataTable as n, DataTableLoadingState as r, ColumnDef$1 as t };
|
|
192
|
+
export { SortingState$1 as a, OnChangeFn$1 as i, DataTable as n, VisibilityState$1 as o, DataTableLoadingState as r, ColumnDef$1 as t };
|
|
@@ -838,7 +838,7 @@ const EMPTY_COLUMN_PINNING = {
|
|
|
838
838
|
* ```
|
|
839
839
|
*/
|
|
840
840
|
function DataTable(componentProps) {
|
|
841
|
-
const { columns, data, getRowId, loadingState = "idle", skeletonCount = DEFAULT_SKELETON_COUNT, emptyState, sorting, onSortingChange, selectionMode = "none", selectedKeys, defaultSelectedKeys, onSelectionChange, disabledKeys, disabledBehavior = "all", actionBar, onFetchMore, hasMore = false, enableColumnResizing = false, fillHeight = false, fixedLayout = false, onRowClick, className } = componentProps;
|
|
841
|
+
const { columns, data, getRowId, loadingState = "idle", skeletonCount = DEFAULT_SKELETON_COUNT, emptyState, sorting, onSortingChange, columnVisibility, selectionMode = "none", selectedKeys, defaultSelectedKeys, onSelectionChange, disabledKeys, disabledBehavior = "all", actionBar, onFetchMore, hasMore = false, enableColumnResizing = false, fillHeight = false, fixedLayout = false, onRowClick, className } = componentProps;
|
|
842
842
|
const sortingEnabled = !!onSortingChange;
|
|
843
843
|
const selectionEnabled = selectionMode !== "none";
|
|
844
844
|
const multiSelect = selectionMode === "multiple";
|
|
@@ -888,13 +888,14 @@ function DataTable(componentProps) {
|
|
|
888
888
|
state: {
|
|
889
889
|
...sorting !== void 0 && { sorting },
|
|
890
890
|
rowSelection,
|
|
891
|
-
...hasPinnedColumns && { columnPinning }
|
|
891
|
+
...hasPinnedColumns && { columnPinning },
|
|
892
|
+
...columnVisibility !== void 0 && { columnVisibility }
|
|
892
893
|
}
|
|
893
894
|
});
|
|
894
895
|
const rows = table.getRowModel().rows;
|
|
895
896
|
const selectedCount = table.getSelectedRowModel().rows.length;
|
|
896
897
|
const hasSelection = selectedCount > 0;
|
|
897
|
-
const hasFooter =
|
|
898
|
+
const hasFooter = table.getVisibleLeafColumns().some((col) => col.columnDef.footer != null);
|
|
898
899
|
const isInitialLoading = loadingState === "loading";
|
|
899
900
|
const isRefreshing = loadingState === "sorting" || loadingState === "filtering";
|
|
900
901
|
const isLoadingMore = loadingState === "loadingMore";
|
|
@@ -932,7 +933,7 @@ function DataTable(componentProps) {
|
|
|
932
933
|
const showActionBar = !!actionBar && hasSelection;
|
|
933
934
|
const reservedBottom = showActionBar ? 64 : void 0;
|
|
934
935
|
const sentinelRef = useFetchMoreSentinel(onFetchMore, (node) => fillHeight ? node.closest("[data-slot=\"table-container\"]") : null, data.length);
|
|
935
|
-
const leafColumnCount = table.getVisibleLeafColumns().length;
|
|
936
|
+
const leafColumnCount = Math.max(table.getVisibleLeafColumns().length, 1);
|
|
936
937
|
return /* @__PURE__ */ jsxs("div", {
|
|
937
938
|
className: cn("relative w-full", fillHeight && "flex min-h-0 flex-1 flex-col", className),
|
|
938
939
|
"aria-busy": isInitialLoading || isRefreshing || void 0,
|
package/dist/data-table.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SortingState, i as OnChangeFn, n as DataTable, r as DataTableLoadingState, t as ColumnDef } from "./data-table-
|
|
2
|
-
export { type ColumnDef, DataTable, type DataTableLoadingState, type OnChangeFn, type SortingState };
|
|
1
|
+
import { a as SortingState, i as OnChangeFn, n as DataTable, o as VisibilityState, r as DataTableLoadingState, t as ColumnDef } from "./data-table-CKJNxqjI.js";
|
|
2
|
+
export { type ColumnDef, DataTable, type DataTableLoadingState, type OnChangeFn, type SortingState, type VisibilityState };
|
package/dist/data-table.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as DataTable } from "./data-table-
|
|
1
|
+
import { t as DataTable } from "./data-table-DhQHgJbc.js";
|
|
2
2
|
export { DataTable };
|