@camstack/ui-library 1.2.254 → 1.2.256
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/composites/confirm-dialog.d.ts +6 -0
- package/dist/composites/data-table-filter-bar.d.ts +14 -1
- package/dist/composites/data-table-filter.d.ts +23 -0
- package/dist/composites/data-table-pager.d.ts +8 -0
- package/dist/composites/data-table-pagination.d.ts +31 -0
- package/dist/composites/data-table-selection.d.ts +15 -0
- package/dist/composites/data-table.d.ts +31 -2
- package/dist/composites/index.d.ts +9 -4
- package/dist/composites/use-data-table-filter.d.ts +9 -0
- package/dist/index.cjs +275 -32
- package/dist/index.js +271 -33
- package/dist/lib/tailwind-variants.d.ts +1 -1
- package/package.json +1 -1
|
@@ -37,6 +37,12 @@ export interface PromptOptions {
|
|
|
37
37
|
* a refusal never needs a second `alert`.
|
|
38
38
|
*/
|
|
39
39
|
readonly validate?: (value: string) => string | null;
|
|
40
|
+
/**
|
|
41
|
+
* `danger` paints the affirmative button as destructive — a typed
|
|
42
|
+
* confirmation ("type 17 to revoke 17 links") is a prompt whose OK destroys.
|
|
43
|
+
* Focus still opens on the field. Default: `default`.
|
|
44
|
+
*/
|
|
45
|
+
readonly variant?: DialogVariant;
|
|
40
46
|
}
|
|
41
47
|
export interface DialogContextValue {
|
|
42
48
|
readonly confirm: (options: ConfirmOptions) => Promise<boolean>;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { DataTableFacet, DataTableFilterState } from './data-table-filter';
|
|
2
|
+
/** One facet group as the bar draws it. */
|
|
3
|
+
export interface DataTableFilterBarGroup {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
/** Visible caption AND the chip group's accessible name ("Status"). */
|
|
6
|
+
readonly label: string;
|
|
7
|
+
readonly facets: readonly DataTableFacet[];
|
|
8
|
+
readonly selected: readonly string[];
|
|
9
|
+
/** Render a chip's caption. Default: the raw value. */
|
|
10
|
+
readonly facetLabel?: (value: string) => string;
|
|
11
|
+
}
|
|
2
12
|
export interface DataTableFilterBarLabels {
|
|
3
13
|
/** Placeholder of the search box. */
|
|
4
14
|
readonly searchPlaceholder: string;
|
|
@@ -19,5 +29,8 @@ export interface DataTableFilterBarProps {
|
|
|
19
29
|
readonly onClear: () => void;
|
|
20
30
|
/** Render a chip's caption. Default: the raw value. */
|
|
21
31
|
readonly facetLabel?: (value: string) => string;
|
|
32
|
+
/** Further chip rows (status, owner, kind…), each its own group. */
|
|
33
|
+
readonly groups?: readonly DataTableFilterBarGroup[];
|
|
34
|
+
readonly onToggleGroupFacet?: (groupId: string, value: string) => void;
|
|
22
35
|
}
|
|
23
|
-
export declare function DataTableFilterBar({ state, facets, labels, onSearch, onToggleFacet, onClear, facetLabel, }: DataTableFilterBarProps): import("react").JSX.Element;
|
|
36
|
+
export declare function DataTableFilterBar({ state, facets, labels, onSearch, onToggleFacet, onClear, facetLabel, groups, onToggleGroupFacet, }: DataTableFilterBarProps): import("react").JSX.Element;
|
|
@@ -3,8 +3,25 @@ export interface DataTableFilterState {
|
|
|
3
3
|
readonly search: string;
|
|
4
4
|
/** Selected facet values. Empty = every row. */
|
|
5
5
|
readonly facets: readonly string[];
|
|
6
|
+
/**
|
|
7
|
+
* Selected chips per facet GROUP (`facetGroups[].id` → values). OR inside a
|
|
8
|
+
* group, AND across groups. Absent or empty = the group does not filter.
|
|
9
|
+
*/
|
|
10
|
+
readonly groups?: Readonly<Record<string, readonly string[]>>;
|
|
6
11
|
}
|
|
7
12
|
export declare const EMPTY_DATA_TABLE_FILTER: DataTableFilterState;
|
|
13
|
+
/** One independent chip row — status, owner, kind… */
|
|
14
|
+
export interface DataTableFacetGroupConfig<T> {
|
|
15
|
+
/** Stable id; the key of `DataTableFilterState.groups`. */
|
|
16
|
+
readonly id: string;
|
|
17
|
+
/** The value this row contributes to THIS group's chips. */
|
|
18
|
+
readonly value: (row: T) => string;
|
|
19
|
+
}
|
|
20
|
+
/** A group's chips, derived from the rows. */
|
|
21
|
+
export interface DataTableFacetGroup {
|
|
22
|
+
readonly id: string;
|
|
23
|
+
readonly facets: readonly DataTableFacet[];
|
|
24
|
+
}
|
|
8
25
|
/** One facet chip, with how many of the rows carry it. */
|
|
9
26
|
export interface DataTableFacet {
|
|
10
27
|
readonly value: string;
|
|
@@ -18,13 +35,19 @@ export interface DataTableFilterConfig<T> {
|
|
|
18
35
|
/** The value this row contributes to the facet chips. Omit for a table
|
|
19
36
|
* with a search box only. */
|
|
20
37
|
readonly facetValue?: (row: T) => string;
|
|
38
|
+
/** Further chip rows, each filtering on its own dimension. */
|
|
39
|
+
readonly facetGroups?: readonly DataTableFacetGroupConfig<T>[];
|
|
21
40
|
}
|
|
22
41
|
/**
|
|
23
42
|
* The facet chips for these rows: one per distinct value, most common first,
|
|
24
43
|
* ties by value.
|
|
25
44
|
*/
|
|
26
45
|
export declare function dataTableFacets<T>(rows: readonly T[], facetValue: ((row: T) => string) | undefined): readonly DataTableFacet[];
|
|
46
|
+
/** One chip row per configured group, each derived like {@link dataTableFacets}. */
|
|
47
|
+
export declare function dataTableFacetGroups<T>(rows: readonly T[], groups: readonly DataTableFacetGroupConfig<T>[] | undefined): readonly DataTableFacetGroup[];
|
|
27
48
|
export declare function isDataTableFilterActive(state: DataTableFilterState): boolean;
|
|
49
|
+
/** A new state with `value` added to, or removed from, group `groupId`. */
|
|
50
|
+
export declare function toggleDataTableGroupFacet(state: DataTableFilterState, groupId: string, value: string): DataTableFilterState;
|
|
28
51
|
/** A new state with `value` added to, or removed from, the selected facets. */
|
|
29
52
|
export declare function toggleDataTableFacet(state: DataTableFilterState, value: string): DataTableFilterState;
|
|
30
53
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DataTablePage, DataTablePaginationLabels } from './data-table-pagination';
|
|
3
|
+
export interface DataTablePagerProps {
|
|
4
|
+
readonly page: DataTablePage<unknown>;
|
|
5
|
+
readonly labels: DataTablePaginationLabels;
|
|
6
|
+
readonly onPageChange: (page: number) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function DataTablePager({ page, labels, onPageChange }: DataTablePagerProps): ReactNode;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side pagination for {@link DataTable} — pure, no React.
|
|
3
|
+
*
|
|
4
|
+
* The table sorts first and pages second, so page 1 always holds the first
|
|
5
|
+
* rows of the CURRENT order. A page past the end (the rows shrank under it:
|
|
6
|
+
* a filter narrowed, a revoke removed rows) clamps to the last page instead
|
|
7
|
+
* of rendering an empty table with a pager that says "page 4 of 2".
|
|
8
|
+
*/
|
|
9
|
+
export interface DataTablePage<T> {
|
|
10
|
+
readonly pageRows: readonly T[];
|
|
11
|
+
/** 0-based page actually shown (after clamping). */
|
|
12
|
+
readonly page: number;
|
|
13
|
+
/** At least 1 — an empty table is one empty page. */
|
|
14
|
+
readonly pageCount: number;
|
|
15
|
+
/** 1-based index of the first row shown; 0 when there are none. */
|
|
16
|
+
readonly from: number;
|
|
17
|
+
/** 1-based index of the last row shown; 0 when there are none. */
|
|
18
|
+
readonly to: number;
|
|
19
|
+
readonly total: number;
|
|
20
|
+
}
|
|
21
|
+
export declare function paginateRows<T>(rows: readonly T[], page: number, pageSize: number): DataTablePage<T>;
|
|
22
|
+
/** Every visible string of the pager — this library carries no translations. */
|
|
23
|
+
export interface DataTablePaginationLabels {
|
|
24
|
+
/** Accessible name of the pager's `<nav>` — say WHICH table. */
|
|
25
|
+
readonly navLabel: string;
|
|
26
|
+
readonly previous: string;
|
|
27
|
+
readonly next: string;
|
|
28
|
+
/** "1–25 of 167". Arguments are 1-based; `from`/`to` are 0 for no rows. */
|
|
29
|
+
readonly range: (from: number, to: number, total: number) => string;
|
|
30
|
+
}
|
|
31
|
+
export declare const DEFAULT_PAGINATION_LABELS: DataTablePaginationLabels;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataColumn } from './data-table';
|
|
2
|
+
export interface DataTableSelection<T> {
|
|
3
|
+
/** Selected row keys (`rowKey(row)`, stringified). Owned by the caller. */
|
|
4
|
+
readonly selected: ReadonlySet<string>;
|
|
5
|
+
readonly onChange: (next: ReadonlySet<string>) => void;
|
|
6
|
+
/** False = no checkbox for this row (e.g. the caller's own session). */
|
|
7
|
+
readonly isSelectable?: (row: T) => boolean;
|
|
8
|
+
/** Accessible name of a row's checkbox — name the row, not "select". */
|
|
9
|
+
readonly rowLabel: (row: T) => string;
|
|
10
|
+
/** Accessible name of the header checkbox. */
|
|
11
|
+
readonly pageLabel: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const SELECTION_COLUMN_KEY = "__select";
|
|
14
|
+
/** The selection column for the rows currently on screen. */
|
|
15
|
+
export declare function selectionColumn<T>(selection: DataTableSelection<T>, pageRows: readonly T[], keyOf: (row: T) => string): DataColumn<T>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { TableMobileMode } from './data-table-layout';
|
|
3
|
+
import { DataTablePaginationLabels } from './data-table-pagination';
|
|
4
|
+
import { DataTableSelection } from './data-table-selection';
|
|
3
5
|
import { TableSortState, TableSortValue } from './table-sort';
|
|
4
6
|
export interface DataColumn<T> {
|
|
5
7
|
/** Stable key for React reconciliation + tests. */
|
|
@@ -80,9 +82,36 @@ export interface DataTableProps<T> {
|
|
|
80
82
|
*
|
|
81
83
|
* The state is owned INSIDE the table from here on — a header click moves it
|
|
82
84
|
* none → asc → desc → none. Pass this only to choose the opening order, not
|
|
83
|
-
* to drive the table from outside.
|
|
85
|
+
* to drive the table from outside — that is {@link DataTableProps.sort}.
|
|
84
86
|
*/
|
|
85
87
|
readonly defaultSort?: TableSortState;
|
|
88
|
+
/**
|
|
89
|
+
* CONTROLLED sort. Present (even `null`) = the owner holds the state: the
|
|
90
|
+
* table renders exactly this order and reports header clicks through
|
|
91
|
+
* `onSortChange` without moving on its own. Use it when the order must
|
|
92
|
+
* survive a remount or live in the URL. Absent = uncontrolled
|
|
93
|
+
* (`defaultSort`).
|
|
94
|
+
*/
|
|
95
|
+
readonly sort?: TableSortState | null;
|
|
96
|
+
/** Every header click, with the next state (none → asc → desc → none). */
|
|
97
|
+
readonly onSortChange?: (next: TableSortState | null) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Client-side pagination: show this many rows per page with a pager under
|
|
100
|
+
* the table. Sorting happens first, so page 1 holds the first rows of the
|
|
101
|
+
* current order. Absent = every row, no pager. The pager is drawn only when
|
|
102
|
+
* the rows do not fit on one page.
|
|
103
|
+
*/
|
|
104
|
+
readonly pageSize?: number;
|
|
105
|
+
/** CONTROLLED 0-based page (with `onPageChange`). Absent = the table owns it. */
|
|
106
|
+
readonly page?: number;
|
|
107
|
+
readonly onPageChange?: (page: number) => void;
|
|
108
|
+
/** The pager's strings. Default: English. */
|
|
109
|
+
readonly paginationLabels?: DataTablePaginationLabels;
|
|
110
|
+
/**
|
|
111
|
+
* Row selection — a leading checkbox column (see `data-table-selection`).
|
|
112
|
+
* Needs `rowKey`: keys are what the caller's bulk action acts on.
|
|
113
|
+
*/
|
|
114
|
+
readonly selection?: DataTableSelection<T>;
|
|
86
115
|
}
|
|
87
116
|
/**
|
|
88
117
|
* The default cap for an internally-scrolling table.
|
|
@@ -92,4 +121,4 @@ export interface DataTableProps<T> {
|
|
|
92
121
|
* does not need a breakpoint of its own.
|
|
93
122
|
*/
|
|
94
123
|
export declare const TABLE_SCROLL_MAX_H: "max-h-[60vh]";
|
|
95
|
-
export declare function DataTable<T>({ columns, rows, rowKey, onRowClick, minWidthPx, emptyMessage, className, bordered, rowClassName, mobileMode, maxBodyHeight, defaultSort, }: DataTableProps<T>): import("react").JSX.Element | null;
|
|
124
|
+
export declare function DataTable<T>({ columns, rows, rowKey, onRowClick, minWidthPx, emptyMessage, className, bordered, rowClassName, mobileMode, maxBodyHeight, defaultSort, sort: sortProp, onSortChange, pageSize, page: pageProp, onPageChange, paginationLabels, selection, }: DataTableProps<T>): import("react").JSX.Element | null;
|
|
@@ -66,11 +66,16 @@ export { CopyButton } from './copy-button';
|
|
|
66
66
|
export type { DataColumn, DataTableProps } from './data-table';
|
|
67
67
|
export * from './data-table';
|
|
68
68
|
export { DataTable } from './data-table';
|
|
69
|
-
export type {
|
|
70
|
-
export {
|
|
71
|
-
export type {
|
|
69
|
+
export type { DataTablePage, DataTablePaginationLabels } from './data-table-pagination';
|
|
70
|
+
export { DEFAULT_PAGINATION_LABELS, paginateRows } from './data-table-pagination';
|
|
71
|
+
export type { DataTablePagerProps } from './data-table-pager';
|
|
72
|
+
export { DataTablePager } from './data-table-pager';
|
|
73
|
+
export type { DataTableSelection } from './data-table-selection';
|
|
74
|
+
export type { DataTableFacet, DataTableFacetGroup, DataTableFacetGroupConfig, DataTableFilterConfig, DataTableFilterState, } from './data-table-filter';
|
|
75
|
+
export { dataTableFacetGroups, toggleDataTableGroupFacet, dataTableFacets, EMPTY_DATA_TABLE_FILTER, filterDataTableRows, isDataTableFilterActive, toggleDataTableFacet, } from './data-table-filter';
|
|
76
|
+
export type { DataTableFilterBarGroup, DataTableFilterBarLabels, DataTableFilterBarProps, } from './data-table-filter-bar';
|
|
72
77
|
export { DataTableFilterBar } from './data-table-filter-bar';
|
|
73
|
-
export type { DataTableFilter } from './use-data-table-filter';
|
|
78
|
+
export type { DataTableFilter, DataTableFilterGroupView } from './use-data-table-filter';
|
|
74
79
|
export { useDataTableFilter } from './use-data-table-filter';
|
|
75
80
|
export type { TableLayoutKind, TableMobileMode } from './data-table-layout';
|
|
76
81
|
export { CARD_MODE_MIN_COLUMNS, resolveTableLayout } from './data-table-layout';
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { DataTableFacet, DataTableFilterConfig, DataTableFilterState } from './data-table-filter';
|
|
2
|
+
/** A facet group as the bar renders it: its chips and what is selected. */
|
|
3
|
+
export interface DataTableFilterGroupView {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly facets: readonly DataTableFacet[];
|
|
6
|
+
readonly selected: readonly string[];
|
|
7
|
+
}
|
|
2
8
|
export interface DataTableFilter<T> {
|
|
3
9
|
readonly state: DataTableFilterState;
|
|
4
10
|
readonly setSearch: (search: string) => void;
|
|
5
11
|
readonly toggleFacet: (value: string) => void;
|
|
12
|
+
readonly toggleGroupFacet: (groupId: string, value: string) => void;
|
|
13
|
+
/** One entry per `facetGroups` config, chips derived from the UNFILTERED rows. */
|
|
14
|
+
readonly groups: readonly DataTableFilterGroupView[];
|
|
6
15
|
readonly clear: () => void;
|
|
7
16
|
/** Chips derived from the UNFILTERED rows — a chip never disappears because
|
|
8
17
|
* it was the one just pressed. */
|