@webority/ui-react 0.17.2 → 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;
@@ -15,14 +15,33 @@
15
15
  * @param {(row: object) => import('react').ReactNode} [props.rowActions]
16
16
  * @param {string} [props.rowActionsLabel]
17
17
  * @param {object} [props.pagination] The footer's state, usually straight from usePagination:
18
- * `{ page, totalPages, pageSize, total, firstRow, lastRow, setPage, setPageSize }`, plus the
19
- * optional `pageSizes` and `mode` that AppTablePagination takes. The footer shows once `total`
20
- * is above 0 and stays in place while `loading`, so the table does not jump between pages.
18
+ * `{ page, totalPages, pageSize, total, setPage, setPageSize }`, plus the optional `pageSizes`
19
+ * and `mode` that AppTablePagination takes. The footer shows once `total` is above 0 and stays
20
+ * in place while `loading`, so the table does not jump between pages.
21
21
  * @param {string} [props.ariaLabel]
22
22
  * @param {string} [props.className] Extra classes on the <table> (column/table styling).
23
23
  * @param {string} [props.wrapperClassName] Extra classes on the `.table-wrap` outer div — the
24
24
  * padding hook. Manage the table's inset from here (e.g. a class that sets `--wui-table-pad`);
25
25
  * the Razor counterpart is a plain `class` on `<app-data-table>`.
26
+ * @param {'comfortable'|'cozy'|'compact'} [props.density='comfortable'] Row height: 54 / 48 / 40px.
27
+ * compact is one line per row (the identity subline is hidden). An avatar with no size of its own
28
+ * follows the density (32 / 28 / 24px).
29
+ * @param {boolean} [props.striped=false] Alternate-row shading in place of divider lines.
30
+ * @param {string|number} [props.maxHeight] Caps the table's height; the body scrolls inside it with
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.
36
+ * @param {boolean} [props.stickyFirstColumn=false] Pins the first column (and the select/expand
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.
43
+ * @param {(row: object) => 'success'|'warning'|'danger'|'info'|undefined} [props.rowStatus] A coloured
44
+ * bar on the row's leading edge, e.g. danger for an overdue invoice. Undefined draws none.
26
45
  * @param {boolean} [props.selectable=false] Render a leading checkbox column.
27
46
  * @param {Set<string|number>} [props.selectedIds] Currently selected row keys.
28
47
  * @param {(id: string|number) => void} [props.onToggleRow]
@@ -30,7 +49,7 @@
30
49
  * @param {(row: object) => import('react').ReactNode} [props.renderExpanded] When given, each row
31
50
  * gets a leading expand toggle; the returned content renders in a full-width row beneath it.
32
51
  */
33
- 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, ...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 }: {
34
53
  columns: object[];
35
54
  rows: object[];
36
55
  rowKey?: (row: object, index: number) => string | number;
@@ -50,6 +69,15 @@ export default function AppDataTable({ columns, rows, rowKey, sort, onSort, load
50
69
  ariaLabel?: string;
51
70
  className?: string;
52
71
  wrapperClassName?: string;
72
+ density?: 'comfortable' | 'cozy' | 'compact';
73
+ striped?: boolean;
74
+ maxHeight?: string | number;
75
+ hiddenColumns?: string[];
76
+ stackOnMobile?: boolean;
77
+ stickyFirstColumn?: boolean;
78
+ rowHref?: (row: object) => string;
79
+ onRowClick?: (row: object) => void;
80
+ rowStatus?: (row: object) => 'success' | 'warning' | 'danger' | 'info' | undefined;
53
81
  selectable?: boolean;
54
82
  selectedIds?: Set<string | number>;
55
83
  onToggleRow?: (id: string | number) => void;
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Pagination footer under a .table. Pair with usePagination.
3
3
  *
4
+ * A page-size menu ("10 per page") beside the page buttons. It shows no row range and no total:
5
+ * the page buttons already say where you are.
6
+ *
4
7
  * `page` is ONE-BASED, matching `<app-table-pagination page="…">` (the shared 1-based pagination contract). It used to be zero-based here while
5
8
  * Razor's was one-based — the same prop name meaning different things on the two surfaces,
6
9
  * which no name-level check can see. `pageCount` is likewise now `totalPages`, the name
@@ -10,30 +13,24 @@
10
13
  * @param {number} props.page 1-based.
11
14
  * @param {number} props.totalPages
12
15
  * @param {number} props.pageSize
13
- * @param {number} props.total
14
- * @param {number} props.firstRow
15
- * @param {number} props.lastRow
16
16
  * @param {(page: number) => void} props.onPageChange
17
17
  * @param {(size: number) => void} props.onPageSizeChange
18
18
  * @param {number[]} [props.pageSizes]
19
- * @param {'prev-next'|'numbered'} [props.mode='prev-next'] prev-next (default) is the arrows-
20
- * only nav above. numbered inserts windowed page buttons — first/last plus an ellipsis over
21
- * any run of hidden pages — between the arrows.
22
- * @param {boolean} [props.showPageSize=true] Show the "Rows per page" selector. Set false for a
23
- * compact pager that pages but doesn't expose page size (e.g. a dense numbered table).
19
+ * @param {'numbered'|'prev-next'} [props.mode='numbered'] numbered (default) puts windowed page
20
+ * buttons (first/last plus an ellipsis over any run of hidden pages) between the arrows.
21
+ * prev-next is the arrows with a "Page N of M" readout.
22
+ * @param {boolean} [props.showPageSize=true] Show the page-size menu. Set false for a pager that
23
+ * pages but doesn't expose page size.
24
24
  * @param {string} [props.className] Merged with the component's own table-pagination class.
25
25
  */
26
- export default function AppTablePagination({ page, totalPages, pageSize, total, firstRow, lastRow, onPageChange, onPageSizeChange, pageSizes, mode, showPageSize, className, ...rest }: {
26
+ export default function AppTablePagination({ page, totalPages, pageSize, onPageChange, onPageSizeChange, pageSizes, mode, showPageSize, className, ...rest }: {
27
27
  page: number;
28
28
  totalPages: number;
29
29
  pageSize: number;
30
- total: number;
31
- firstRow: number;
32
- lastRow: number;
33
30
  onPageChange: (page: number) => void;
34
31
  onPageSizeChange: (size: number) => void;
35
32
  pageSizes?: number[];
36
- mode?: 'prev-next' | 'numbered';
33
+ mode?: 'numbered' | 'prev-next';
37
34
  showPageSize?: boolean;
38
35
  className?: string;
39
36
  }): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The toolbar above a table: filters on the left, search and actions on the right. While rows are
3
+ * selected the same strip becomes a bulk bar ("3 selected", the bulk actions, Clear), so the two
4
+ * never compete for space. Place it directly above `AppDataTable`; Razor counterpart:
5
+ * `<app-table-toolbar for="…">`.
6
+ *
7
+ * Both rows are always rendered and one is `hidden`, so the markup is identical on both surfaces
8
+ * and the swap never shifts what comes after.
9
+ *
10
+ * @param {object} props
11
+ * @param {import('react').ReactNode} [props.filters] Left side: status segments, chips, a filter menu.
12
+ * @param {import('react').ReactNode} [props.actions] Right side: search, export, a columns menu.
13
+ * @param {number} [props.selectedCount=0] Selected rows. Above 0, the bulk bar replaces the toolbar.
14
+ * @param {import('react').ReactNode} [props.bulkActions] Buttons shown in the bulk bar.
15
+ * @param {() => void} [props.onClearSelection] Shows a Clear button in the bulk bar that calls this.
16
+ * @param {string} [props.className]
17
+ */
18
+ export default function AppTableToolbar({ filters, actions, selectedCount, bulkActions, onClearSelection, className, ...rest }: {
19
+ filters?: import('react').ReactNode;
20
+ actions?: import('react').ReactNode;
21
+ selectedCount?: number;
22
+ bulkActions?: import('react').ReactNode;
23
+ onClearSelection?: () => void;
24
+ className?: string;
25
+ }): import("react").JSX.Element;
@@ -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";
@@ -72,6 +73,7 @@ export { default as AppStepper } from "./components/AppStepper.jsx";
72
73
  export { default as AppSwitch } from "./components/AppSwitch.jsx";
73
74
  export { default as AppTableEmptyState } from "./components/AppTableEmptyState.jsx";
74
75
  export { default as AppTablePagination } from "./components/AppTablePagination.jsx";
76
+ export { default as AppTableToolbar } from "./components/AppTableToolbar.jsx";
75
77
  export { default as AppTabs } from "./components/AppTabs.jsx";
76
78
  export { default as AppTagInput } from "./components/AppTagInput.jsx";
77
79
  export { default as AppTextarea } from "./components/AppTextarea.jsx";
@@ -86,3 +88,4 @@ export { MODAL_ICONS } from "./components/ModalIcons.jsx";
86
88
  export { dismissAll, errorToast, toast } from "./components/toast.js";
87
89
  export { useCommandPaletteShortcut } from "./lib/useCommandPaletteShortcut.js";
88
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
+ };