@webority/ui-react 0.17.3 → 0.17.4
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.
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A "Columns" menu that hides and shows a table's columns: one checkbox per column marked
|
|
3
|
+
* `hideable`. Put it in the table toolbar's actions and feed it from `useTableView`, which also
|
|
4
|
+
* hands the same `hiddenColumns` to `AppDataTable`. Razor counterpart: `<app-column-menu for="…" view-key="…">`.
|
|
5
|
+
*
|
|
6
|
+
* @param {object} props
|
|
7
|
+
* @param {{ key: string, label: import('react').ReactNode, hideable?: boolean }[]} props.columns The table's columns.
|
|
8
|
+
* @param {string[]} [props.hiddenColumns] Keys of the columns currently hidden.
|
|
9
|
+
* @param {(key: string) => void} props.onToggle Called with a column's key when its box changes.
|
|
10
|
+
* @param {string} [props.label="Columns"] Accessible name and tooltip of the button, and the menu heading.
|
|
11
|
+
* @param {string} [props.className] Extra classes on the menu panel.
|
|
12
|
+
*/
|
|
13
|
+
export default function AppColumnMenu({ columns, hiddenColumns, onToggle, label, className, ...rest }: {
|
|
14
|
+
columns: {
|
|
15
|
+
key: string;
|
|
16
|
+
label: import('react').ReactNode;
|
|
17
|
+
hideable?: boolean;
|
|
18
|
+
}[];
|
|
19
|
+
hiddenColumns?: string[];
|
|
20
|
+
onToggle: (key: string) => void;
|
|
21
|
+
label?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
@@ -29,8 +29,17 @@
|
|
|
29
29
|
* @param {boolean} [props.striped=false] Alternate-row shading in place of divider lines.
|
|
30
30
|
* @param {string|number} [props.maxHeight] Caps the table's height; the body scrolls inside it with
|
|
31
31
|
* the header pinned. Without it there is no scroll box for the header to stick to.
|
|
32
|
+
* @param {string[]} [props.hiddenColumns] Keys of `hideable` columns to leave out (from useTableView).
|
|
33
|
+
* A column that is not hideable always shows.
|
|
34
|
+
* @param {boolean} [props.stackOnMobile=false] Below 576px, shows each row as a card: the first
|
|
35
|
+
* column on top, then "label: value" lines from the column labels, actions at the bottom.
|
|
32
36
|
* @param {boolean} [props.stickyFirstColumn=false] Pins the first column (and the select/expand
|
|
33
37
|
* column before it) while a wide table scrolls sideways.
|
|
38
|
+
* @param {(row: object) => string} [props.rowHref] Makes the whole row open this URL on click or Enter
|
|
39
|
+
* (Ctrl/Cmd or middle click opens a new tab). Checkboxes, buttons, links and menus in the row keep
|
|
40
|
+
* their own behaviour. Razor: `data-href` on the <tr>.
|
|
41
|
+
* @param {(row: object) => void} [props.onRowClick] Called when the row is clicked or Enter is pressed
|
|
42
|
+
* on it, for in-page actions (open a drawer). Same nested-control rule as rowHref.
|
|
34
43
|
* @param {(row: object) => 'success'|'warning'|'danger'|'info'|undefined} [props.rowStatus] A coloured
|
|
35
44
|
* bar on the row's leading edge, e.g. danger for an overdue invoice. Undefined draws none.
|
|
36
45
|
* @param {boolean} [props.selectable=false] Render a leading checkbox column.
|
|
@@ -40,7 +49,7 @@
|
|
|
40
49
|
* @param {(row: object) => import('react').ReactNode} [props.renderExpanded] When given, each row
|
|
41
50
|
* gets a leading expand toggle; the returned content renders in a full-width row beneath it.
|
|
42
51
|
*/
|
|
43
|
-
export default function AppDataTable({ columns, rows, rowKey, sort, onSort, loading, skeletonRows, empty, emptyFiltered, sourceCount, rowActions, rowActionsLabel, pagination, ariaLabel, className, wrapperClassName, selectable, selectedIds, onToggleRow, onToggleAll, renderExpanded, density, striped, maxHeight, stickyFirstColumn, rowStatus, ...rest }: {
|
|
52
|
+
export default function AppDataTable({ columns, rows, rowKey, sort, onSort, loading, skeletonRows, empty, emptyFiltered, sourceCount, rowActions, rowActionsLabel, pagination, ariaLabel, className, wrapperClassName, selectable, selectedIds, onToggleRow, onToggleAll, renderExpanded, density, striped, maxHeight, stickyFirstColumn, stackOnMobile, hiddenColumns, rowStatus, rowHref, onRowClick, ...rest }: {
|
|
44
53
|
columns: object[];
|
|
45
54
|
rows: object[];
|
|
46
55
|
rowKey?: (row: object, index: number) => string | number;
|
|
@@ -63,7 +72,11 @@ export default function AppDataTable({ columns, rows, rowKey, sort, onSort, load
|
|
|
63
72
|
density?: 'comfortable' | 'cozy' | 'compact';
|
|
64
73
|
striped?: boolean;
|
|
65
74
|
maxHeight?: string | number;
|
|
75
|
+
hiddenColumns?: string[];
|
|
76
|
+
stackOnMobile?: boolean;
|
|
66
77
|
stickyFirstColumn?: boolean;
|
|
78
|
+
rowHref?: (row: object) => string;
|
|
79
|
+
onRowClick?: (row: object) => void;
|
|
67
80
|
rowStatus?: (row: object) => 'success' | 'warning' | 'danger' | 'info' | undefined;
|
|
68
81
|
selectable?: boolean;
|
|
69
82
|
selectedIds?: Set<string | number>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export { default as AppChip } from "./components/AppChip.jsx";
|
|
|
15
15
|
export { default as AppChoiceCard } from "./components/AppChoiceCard.jsx";
|
|
16
16
|
export { default as AppChoiceChip } from "./components/AppChoiceChip.jsx";
|
|
17
17
|
export { default as AppColorField } from "./components/AppColorField.jsx";
|
|
18
|
+
export { default as AppColumnMenu } from "./components/AppColumnMenu.jsx";
|
|
18
19
|
export { default as AppCommandPalette } from "./components/AppCommandPalette.jsx";
|
|
19
20
|
export { default as AppCompareTable } from "./components/AppCompareTable.jsx";
|
|
20
21
|
export { default as AppConfirmDialog } from "./components/AppConfirmDialog.jsx";
|
|
@@ -87,3 +88,4 @@ export { MODAL_ICONS } from "./components/ModalIcons.jsx";
|
|
|
87
88
|
export { dismissAll, errorToast, toast } from "./components/toast.js";
|
|
88
89
|
export { useCommandPaletteShortcut } from "./lib/useCommandPaletteShortcut.js";
|
|
89
90
|
export { usePagination } from "./lib/usePagination.js";
|
|
91
|
+
export { useTableView } from "./lib/useTableView.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hidden columns and sort for one table, remembered per browser.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} viewKey Names the view, e.g. "invoices". Two tables sharing a key share a view.
|
|
5
|
+
* @param {{ sort?: { key: string, dir: "asc"|"desc" } }} [options] The sort to start from.
|
|
6
|
+
* @returns {{ hiddenColumns: string[], toggleColumn: (key: string) => void,
|
|
7
|
+
* sort: { key: string, dir: "asc"|"desc" }|undefined, setSort: (next: object|((prev: object) => object)) => void }}
|
|
8
|
+
*/
|
|
9
|
+
export declare function useTableView(viewKey: string, { sort: initialSort }?: {
|
|
10
|
+
sort?: {
|
|
11
|
+
key: string;
|
|
12
|
+
dir: "asc" | "desc";
|
|
13
|
+
};
|
|
14
|
+
}): {
|
|
15
|
+
hiddenColumns: string[];
|
|
16
|
+
toggleColumn: (key: string) => void;
|
|
17
|
+
sort: {
|
|
18
|
+
key: string;
|
|
19
|
+
dir: "asc" | "desc";
|
|
20
|
+
} | undefined;
|
|
21
|
+
setSort: (next: object | ((prev: object) => object)) => void;
|
|
22
|
+
};
|