@panneau/lists 5.0.0-alpha.1 → 5.0.0-alpha.10
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/README.md +3 -3
- package/dist/ItemDetails.css +34 -0
- package/dist/ItemDetails.d.ts +18 -0
- package/dist/ItemDetails.d.ts.map +1 -0
- package/dist/ItemDetails.js +104 -0
- package/dist/ItemDetails.js.map +1 -0
- package/dist/ItemDetails.module.js +16 -0
- package/dist/ItemDetails.module.js.map +1 -0
- package/dist/List.d.ts +2 -2
- package/dist/List.js +54 -12
- package/dist/List.js.map +1 -1
- package/dist/ListSkeleton.d.ts +17 -0
- package/dist/ListSkeleton.d.ts.map +1 -0
- package/dist/ListSkeleton.js +111 -0
- package/dist/ListSkeleton.js.map +1 -0
- package/dist/ListView.css +16 -16
- package/dist/ListView.d.ts +35 -6
- package/dist/ListView.d.ts.map +1 -1
- package/dist/ListView.js +544 -211
- package/dist/ListView.js.map +1 -1
- package/dist/ListView.module.js +10 -10
- package/dist/actions/ActionButton.d.ts +1 -1
- package/dist/actions/ActionButton.d.ts.map +1 -1
- package/dist/actions/ActionButton.js +90 -22
- package/dist/actions/ActionButton.js.map +1 -1
- package/dist/actions/Actions.css +9 -9
- package/dist/actions/Actions.module.js +6 -6
- package/dist/actions/ConfirmDialog.d.ts +15 -3
- package/dist/actions/ConfirmDialog.d.ts.map +1 -1
- package/dist/actions/ConfirmDialog.js +103 -89
- package/dist/actions/ConfirmDialog.js.map +1 -1
- package/dist/actions/RowActions.d.ts +6 -7
- package/dist/actions/RowActions.d.ts.map +1 -1
- package/dist/actions/RowActions.js +59 -53
- package/dist/actions/RowActions.js.map +1 -1
- package/dist/actions/actions.d.ts +5 -4
- package/dist/actions/actions.d.ts.map +1 -1
- package/dist/actions/actions.js +7 -14
- package/dist/actions/actions.js.map +1 -1
- package/dist/actions/icons.js.map +1 -1
- package/dist/cx.js.map +1 -1
- package/dist/displays/Displays.css +25 -13
- package/dist/displays/Displays.module.js +18 -14
- package/dist/displays/Displays.module.js.map +1 -1
- package/dist/displays/displays.d.ts +18 -3
- package/dist/displays/displays.d.ts.map +1 -1
- package/dist/displays/displays.js +355 -12
- package/dist/displays/displays.js.map +1 -1
- package/dist/filters/Filters.css +34 -20
- package/dist/filters/Filters.d.ts +1 -1
- package/dist/filters/Filters.js.map +1 -1
- package/dist/filters/Filters.module.js +13 -9
- package/dist/filters/Filters.module.js.map +1 -1
- package/dist/filters/controls.d.ts +1 -1
- package/dist/filters/controls.d.ts.map +1 -1
- package/dist/filters/controls.js +57 -35
- package/dist/filters/controls.js.map +1 -1
- package/dist/filters/format.d.ts +1 -1
- package/dist/filters/format.js.map +1 -1
- package/dist/index.d.ts +19 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/layouts/CardsLayout.css +22 -11
- package/dist/layouts/CardsLayout.d.ts +2 -2
- package/dist/layouts/CardsLayout.d.ts.map +1 -1
- package/dist/layouts/CardsLayout.js +39 -35
- package/dist/layouts/CardsLayout.js.map +1 -1
- package/dist/layouts/CardsLayout.module.js +8 -8
- package/dist/layouts/CardsLayout.module.js.map +1 -1
- package/dist/layouts/ItemTitle.d.ts +3 -1
- package/dist/layouts/ItemTitle.d.ts.map +1 -1
- package/dist/layouts/ItemTitle.js +12 -8
- package/dist/layouts/ItemTitle.js.map +1 -1
- package/dist/layouts/TableLayout.css +51 -35
- package/dist/layouts/TableLayout.d.ts +2 -2
- package/dist/layouts/TableLayout.d.ts.map +1 -1
- package/dist/layouts/TableLayout.js +38 -33
- package/dist/layouts/TableLayout.js.map +1 -1
- package/dist/layouts/TableLayout.module.js +14 -14
- package/dist/layouts/TableLayout.module.js.map +1 -1
- package/dist/layouts/builtIn.d.ts +1 -1
- package/dist/layouts/builtIn.js.map +1 -1
- package/dist/layouts/link.css +3 -3
- package/dist/layouts/link.module.js +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/query.d.ts +1 -1
- package/dist/query.js.map +1 -1
- package/dist/selection.d.ts +1 -1
- package/dist/selection.js.map +1 -1
- package/dist/toolbar/LayoutSwitch.js.map +1 -1
- package/dist/toolbar/Pagination.d.ts +33 -0
- package/dist/toolbar/Pagination.d.ts.map +1 -1
- package/dist/toolbar/Pagination.js +282 -42
- package/dist/toolbar/Pagination.js.map +1 -1
- package/dist/toolbar/SearchField.js.map +1 -1
- package/dist/toolbar/SortSelect.d.ts +1 -1
- package/dist/toolbar/SortSelect.js.map +1 -1
- package/dist/toolbar/Toolbar.css +12 -12
- package/dist/toolbar/Toolbar.module.js +7 -7
- package/dist/types.d.ts +16 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/useDraft.js.map +1 -1
- package/dist/useListState.js.map +1 -1
- package/dist/useRenderValue.d.ts +8 -0
- package/dist/useRenderValue.d.ts.map +1 -0
- package/dist/useRenderValue.js +64 -0
- package/dist/useRenderValue.js.map +1 -0
- package/dist/values.d.ts +3 -1
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +6 -2
- package/dist/values.js.map +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -87,11 +87,11 @@ const { data, isFetching, error } = useResourceList('pages', query); // @panneau
|
|
|
87
87
|
| Pagination | With `total`: the range, previous and next pages, and the page size (`perPageOptions`) |
|
|
88
88
|
| Selection | Checkboxes, the page, then "select all N items", which selects every item matching the query, with exceptions |
|
|
89
89
|
| Actions | `row` (buttons), `menu` (the row's menu), `toolbar` (selection and resource actions), with `confirm`, hidden by abilities ([0011](../../docs/decisions/0011-permissions.md)) |
|
|
90
|
-
| States |
|
|
90
|
+
| States | Skeleton rows of the columns while `items` is `undefined`, an error with a retry, an empty message, and "no results" with a button that clears the filters |
|
|
91
91
|
|
|
92
|
-
An action shows the
|
|
92
|
+
An action shows the icon it names (`"icon": "send"`, through `getNamedIcon()` of `@panneau/ui`, which needs an `iconLoader` on `PanneauRoot`, such as `lucideIconLoader` of `@panneau/ui/named-icons`), or the icon of a built-in action (`edit`, `delete`…). Actions written in code can get icon components by id instead, which win over names: `actionIcons={{ archive: Archive }}`.
|
|
93
93
|
|
|
94
|
-
Lists confirm an action when it has `confirm` (its title and message are ICU messages with `{count}`), or when some selected items don't allow it,
|
|
94
|
+
Lists confirm an action when it has `confirm` (its title and message are ICU messages with `{count}`), or when some selected items don't allow it. For every item matching a query, they only know the current page: with `previewAction` (`useActionPreview()` of `@panneau/actions`), an action that declares `dryRun` asks the backend first, and the confirmation gives its count of skipped items. Then they call `onAction` with the action, its scope, the item or the `Selection` of the protocol, the count and the skipped items. A promise shows the action as pending; when it rejects, a toast says that it failed. After a selection action, the selection is cleared.
|
|
95
95
|
|
|
96
96
|
A `relation` filter keeps ids in the query (`filter[author]=7`). Its chip and picker show the labels of the items it picked, and those of ids from the URL once the relation source's `resolve()` gives them.
|
|
97
97
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.panneau-item-details-details {
|
|
2
|
+
container: panneau-item-details / inline-size;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--panneau-space-3);
|
|
6
|
+
margin: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.panneau-item-details-entry {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: var(--panneau-space-1);
|
|
13
|
+
min-width: 0;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.panneau-item-details-label {
|
|
17
|
+
color: var(--panneau-color-text-muted);
|
|
18
|
+
font-size: var(--panneau-font-size-sm);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.panneau-item-details-value {
|
|
22
|
+
min-width: 0;
|
|
23
|
+
margin: 0;
|
|
24
|
+
overflow-wrap: anywhere;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Wide enough: the label and its value side by side. */
|
|
28
|
+
@container panneau-item-details (min-width: 30rem) {
|
|
29
|
+
.panneau-item-details-entry {
|
|
30
|
+
display: grid;
|
|
31
|
+
grid-template-columns: minmax(8rem, 30%) minmax(0, 1fr);
|
|
32
|
+
gap: var(--panneau-space-3);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DisplayEntry, ListColumn, ListItem } from './types.js';
|
|
2
|
+
export interface ItemDetailsProps {
|
|
3
|
+
/** The item. `undefined` while it loads: the labels, with a skeleton of each value. */
|
|
4
|
+
item: ListItem | undefined;
|
|
5
|
+
/** The values to show, with their label and display, in order. */
|
|
6
|
+
columns: readonly ListColumn[];
|
|
7
|
+
/** Displays by name, over the built-in ones and those of the plugins. */
|
|
8
|
+
displays?: Readonly<Record<string, DisplayEntry>>;
|
|
9
|
+
'aria-label'?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The values of one item, each with its label, shown with the displays of the lists: for the
|
|
14
|
+
* details of an item next to its list, or anywhere a read-only view of it is needed. While the
|
|
15
|
+
* item loads, it draws the labels with a skeleton of each value (decision 0034).
|
|
16
|
+
*/
|
|
17
|
+
export declare function ItemDetails({ item, columns, displays, 'aria-label': ariaLabel, className, }: ItemDetailsProps): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=ItemDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemDetails.d.ts","sourceRoot":"","sources":["../src/ItemDetails.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAMlE,MAAM,WAAW,gBAAgB;IAC7B,uFAAuF;IACvF,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,kEAAkE;IAClE,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EACxB,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,SAAS,GACZ,EAAE,gBAAgB,+BA6BlB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { messages } from "./messages.js";
|
|
2
|
+
import { cx } from "./cx.js";
|
|
3
|
+
import ItemDetails_module_default from "./ItemDetails.module.js";
|
|
4
|
+
import { useRenderValue } from "./useRenderValue.js";
|
|
5
|
+
import { c } from "react/compiler-runtime";
|
|
6
|
+
import { LoadingRegion, Skeleton, usePanneauIntl } from "@panneau/ui";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/ItemDetails.tsx
|
|
9
|
+
/** Widths of the values of a skeleton, varied so they read as text. */
|
|
10
|
+
var WIDTHS = [
|
|
11
|
+
"70%",
|
|
12
|
+
"40%",
|
|
13
|
+
"55%",
|
|
14
|
+
"30%",
|
|
15
|
+
"65%"
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* The values of one item, each with its label, shown with the displays of the lists: for the
|
|
19
|
+
* details of an item next to its list, or anywhere a read-only view of it is needed. While the
|
|
20
|
+
* item loads, it draws the labels with a skeleton of each value (decision 0034).
|
|
21
|
+
*/
|
|
22
|
+
function ItemDetails(t0) {
|
|
23
|
+
const $ = c(20);
|
|
24
|
+
const { item, columns, displays, "aria-label": ariaLabel, className } = t0;
|
|
25
|
+
const intl = usePanneauIntl();
|
|
26
|
+
const renderValue = useRenderValue(displays);
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[0] !== className) {
|
|
29
|
+
t1 = cx(ItemDetails_module_default.details, className);
|
|
30
|
+
$[0] = className;
|
|
31
|
+
$[1] = t1;
|
|
32
|
+
} else t1 = $[1];
|
|
33
|
+
let t2;
|
|
34
|
+
if ($[2] !== columns || $[3] !== item || $[4] !== renderValue) {
|
|
35
|
+
let t3;
|
|
36
|
+
if ($[6] !== item || $[7] !== renderValue) {
|
|
37
|
+
t3 = (column, index) => /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: ItemDetails_module_default.entry,
|
|
39
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
40
|
+
className: ItemDetails_module_default.label,
|
|
41
|
+
children: column.label ?? column.id
|
|
42
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
43
|
+
className: ItemDetails_module_default.value,
|
|
44
|
+
children: item !== void 0 ? renderValue(item, column) : /* @__PURE__ */ jsx(Skeleton, { width: WIDTHS[index % WIDTHS.length] })
|
|
45
|
+
})]
|
|
46
|
+
}, column.id);
|
|
47
|
+
$[6] = item;
|
|
48
|
+
$[7] = renderValue;
|
|
49
|
+
$[8] = t3;
|
|
50
|
+
} else t3 = $[8];
|
|
51
|
+
t2 = columns.map(t3);
|
|
52
|
+
$[2] = columns;
|
|
53
|
+
$[3] = item;
|
|
54
|
+
$[4] = renderValue;
|
|
55
|
+
$[5] = t2;
|
|
56
|
+
} else t2 = $[5];
|
|
57
|
+
let t3;
|
|
58
|
+
if ($[9] !== ariaLabel || $[10] !== t1 || $[11] !== t2) {
|
|
59
|
+
t3 = /* @__PURE__ */ jsx("dl", {
|
|
60
|
+
"aria-label": ariaLabel,
|
|
61
|
+
className: t1,
|
|
62
|
+
children: t2
|
|
63
|
+
});
|
|
64
|
+
$[9] = ariaLabel;
|
|
65
|
+
$[10] = t1;
|
|
66
|
+
$[11] = t2;
|
|
67
|
+
$[12] = t3;
|
|
68
|
+
} else t3 = $[12];
|
|
69
|
+
const details = t3;
|
|
70
|
+
if (item === void 0) {
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[13] !== intl) {
|
|
73
|
+
t4 = intl.formatMessage(messages.loadingItem);
|
|
74
|
+
$[13] = intl;
|
|
75
|
+
$[14] = t4;
|
|
76
|
+
} else t4 = $[14];
|
|
77
|
+
let t5;
|
|
78
|
+
if ($[15] !== details) {
|
|
79
|
+
t5 = /* @__PURE__ */ jsx("div", {
|
|
80
|
+
inert: true,
|
|
81
|
+
"aria-hidden": "true",
|
|
82
|
+
children: details
|
|
83
|
+
});
|
|
84
|
+
$[15] = details;
|
|
85
|
+
$[16] = t5;
|
|
86
|
+
} else t5 = $[16];
|
|
87
|
+
let t6;
|
|
88
|
+
if ($[17] !== t4 || $[18] !== t5) {
|
|
89
|
+
t6 = /* @__PURE__ */ jsx(LoadingRegion, {
|
|
90
|
+
label: t4,
|
|
91
|
+
children: t5
|
|
92
|
+
});
|
|
93
|
+
$[17] = t4;
|
|
94
|
+
$[18] = t5;
|
|
95
|
+
$[19] = t6;
|
|
96
|
+
} else t6 = $[19];
|
|
97
|
+
return t6;
|
|
98
|
+
}
|
|
99
|
+
return details;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { ItemDetails };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=ItemDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemDetails.js","names":["LoadingRegion","Skeleton","usePanneauIntl","styles","cx","messages","DisplayEntry","ListColumn","ListItem","useRenderValue","WIDTHS","ItemDetailsProps","item","columns","displays","Readonly","Record","className","ItemDetails","t0","$","_c","ariaLabel","intl","renderValue","t1","details","t2","t3","column","index","id","entry","label","value","undefined","length","map","t4","formatMessage","loadingItem","t5","t6","_c","styles"],"sources":["../src/ItemDetails.tsx"],"sourcesContent":["import { LoadingRegion, Skeleton, usePanneauIntl } from '@panneau/ui';\n\nimport styles from './ItemDetails.module.css';\nimport { cx } from './cx';\nimport { messages } from './messages';\nimport type { DisplayEntry, ListColumn, ListItem } from './types';\nimport { useRenderValue } from './useRenderValue';\n\n/** Widths of the values of a skeleton, varied so they read as text. */\nconst WIDTHS = ['70%', '40%', '55%', '30%', '65%'];\n\nexport interface ItemDetailsProps {\n /** The item. `undefined` while it loads: the labels, with a skeleton of each value. */\n item: ListItem | undefined;\n /** The values to show, with their label and display, in order. */\n columns: readonly ListColumn[];\n /** Displays by name, over the built-in ones and those of the plugins. */\n displays?: Readonly<Record<string, DisplayEntry>>;\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * The values of one item, each with its label, shown with the displays of the lists: for the\n * details of an item next to its list, or anywhere a read-only view of it is needed. While the\n * item loads, it draws the labels with a skeleton of each value (decision 0034).\n */\nexport function ItemDetails({\n item,\n columns,\n displays,\n 'aria-label': ariaLabel,\n className,\n}: ItemDetailsProps) {\n const intl = usePanneauIntl();\n const renderValue = useRenderValue(displays);\n const details = (\n <dl aria-label={ariaLabel} className={cx(styles.details, className)}>\n {columns.map((column, index) => (\n <div key={column.id} className={styles.entry}>\n <dt className={styles.label}>{column.label ?? column.id}</dt>\n <dd className={styles.value}>\n {item !== undefined ? (\n renderValue(item, column)\n ) : (\n <Skeleton width={WIDTHS[index % WIDTHS.length]} />\n )}\n </dd>\n </div>\n ))}\n </dl>\n );\n if (item === undefined) {\n return (\n <LoadingRegion label={intl.formatMessage(messages.loadingItem)}>\n <div inert aria-hidden=\"true\">\n {details}\n </div>\n </LoadingRegion>\n );\n }\n return details;\n}\n"],"mappings":";;;;;;;;;AASA,IAAMU,SAAS;CAAC;CAAO;CAAO;CAAO;CAAO;AAAK;;;;;;AAkBjD,SAAOQ,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqB,MAAA,EAAAT,MAAAC,SAAAC,UAAA,cAAAQ,WAAAL,cAAAE;CAOxB,MAAAI,OAAarB,eAAe;CAC5B,MAAAsB,cAAoBf,eAAeK,QAAQ;CAAE,IAAAW;CAAA,IAAAL,EAAA,OAAAH,WAAA;EAEHQ,KAAArB,GAAGD,2BAAMuB,SAAUT,SAAS;EAACG,EAAA,KAAAH;EAAAG,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAP,WAAAO,EAAA,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AAqB;EAAA,IAAArB,EAAA,QAAAM,SAAA;GAC1De,KAAA,oBAAA,OAAA;IAAK,OAAA;IAAkB,eAAA;IAClBf,UAAAA;GACC,CAAA;GAAAN,EAAA,MAAAM;GAAAN,EAAA,MAAAqB;EAAA,OAAAA,KAAArB,EAAA;EAAA,IAAAsB;EAAA,IAAAtB,EAAA,QAAAkB,MAAAlB,EAAA,QAAAqB,IAAA;GAHVC,KAAA,oBAAC,eAAD;IAAsB,OAAAJ;IAClBG,UAAAA;GADU,CAAA;GAIErB,EAAA,MAAAkB;GAAAlB,EAAA,MAAAqB;GAAArB,EAAA,MAAAsB;EAAA,OAAAA,KAAAtB,EAAA;EAAA,OAJhBsB;CAIgB;CAEvB,OACMhB;AAAO"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./ItemDetails.css";
|
|
2
|
+
//#region src/ItemDetails.module.css
|
|
3
|
+
var details = "panneau-item-details-details";
|
|
4
|
+
var entry = "panneau-item-details-entry";
|
|
5
|
+
var label = "panneau-item-details-label";
|
|
6
|
+
var value = "panneau-item-details-value";
|
|
7
|
+
var ItemDetails_module_default = {
|
|
8
|
+
details,
|
|
9
|
+
entry,
|
|
10
|
+
label,
|
|
11
|
+
value
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ItemDetails_module_default as default, details, entry, label, value };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=ItemDetails.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemDetails.module.js","names":[],"sources":["../src/ItemDetails.module.css"],"sourcesContent":[".details {\n container: panneau-item-details / inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-3);\n margin: 0;\n}\n\n.entry {\n display: flex;\n flex-direction: column;\n gap: var(--panneau-space-1);\n min-width: 0;\n}\n\n.label {\n color: var(--panneau-color-text-muted);\n font-size: var(--panneau-font-size-sm);\n}\n\n.value {\n min-width: 0;\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n/* Wide enough: the label and its value side by side. */\n@container panneau-item-details (min-width: 30rem) {\n .entry {\n display: grid;\n grid-template-columns: minmax(8rem, 30%) minmax(0, 1fr);\n gap: var(--panneau-space-3);\n }\n}\n"],"mappings":""}
|
package/dist/List.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ListOptions } from '@panneau/core';
|
|
2
|
-
import { type ListViewProps } from './ListView';
|
|
3
|
-
import type { ListItem } from './types';
|
|
2
|
+
import { type ListViewProps } from './ListView.js';
|
|
3
|
+
import type { ListItem } from './types.js';
|
|
4
4
|
export interface ListProps extends Omit<ListViewProps, 'list' | 'total' | 'items'> {
|
|
5
5
|
/** Every item: the list searches, filters, sorts and paginates them in memory. */
|
|
6
6
|
items: readonly ListItem[] | undefined;
|
package/dist/List.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ListView } from "./ListView.js";
|
|
2
2
|
import { applyListQuery } from "./query.js";
|
|
3
3
|
import { useList } from "@panneau/core";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
4
5
|
import { usePanneauIntl } from "@panneau/ui";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
//#region src/List.tsx
|
|
@@ -12,25 +13,66 @@ import { jsx } from "react/jsx-runtime";
|
|
|
12
13
|
*
|
|
13
14
|
* The page size and the default sort are read once.
|
|
14
15
|
*/
|
|
15
|
-
function List(
|
|
16
|
+
function List(t0) {
|
|
17
|
+
const $ = c(15);
|
|
18
|
+
const { items, perPage: t1, defaultSort: t2, router, ...props } = t0;
|
|
19
|
+
const perPage = t1 === void 0 ? 20 : t1;
|
|
20
|
+
let t3;
|
|
21
|
+
if ($[0] !== t2) {
|
|
22
|
+
t3 = t2 === void 0 ? [] : t2;
|
|
23
|
+
$[0] = t2;
|
|
24
|
+
$[1] = t3;
|
|
25
|
+
} else t3 = $[1];
|
|
26
|
+
const defaultSort = t3;
|
|
16
27
|
const intl = usePanneauIntl();
|
|
17
|
-
|
|
18
|
-
|
|
28
|
+
let t4;
|
|
29
|
+
if ($[2] !== defaultSort || $[3] !== perPage) {
|
|
30
|
+
t4 = {
|
|
19
31
|
perPage,
|
|
20
32
|
sort: defaultSort
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
};
|
|
34
|
+
$[2] = defaultSort;
|
|
35
|
+
$[3] = perPage;
|
|
36
|
+
$[4] = t4;
|
|
37
|
+
} else t4 = $[4];
|
|
38
|
+
let t5;
|
|
39
|
+
if ($[5] !== router) {
|
|
40
|
+
t5 = router !== void 0 ? { router } : {};
|
|
41
|
+
$[5] = router;
|
|
42
|
+
$[6] = t5;
|
|
43
|
+
} else t5 = $[6];
|
|
44
|
+
let t6;
|
|
45
|
+
if ($[7] !== t4 || $[8] !== t5) {
|
|
46
|
+
t6 = {
|
|
47
|
+
defaults: t4,
|
|
48
|
+
...t5
|
|
49
|
+
};
|
|
50
|
+
$[7] = t4;
|
|
51
|
+
$[8] = t5;
|
|
52
|
+
$[9] = t6;
|
|
53
|
+
} else t6 = $[9];
|
|
54
|
+
const { query, list } = useList(t6);
|
|
24
55
|
const result = items !== void 0 ? applyListQuery(items, query, {
|
|
25
56
|
columns: props.columns,
|
|
26
57
|
locale: intl.locale
|
|
27
58
|
}) : void 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
59
|
+
const t7 = result?.items;
|
|
60
|
+
const t8 = result?.total;
|
|
61
|
+
let t9;
|
|
62
|
+
if ($[10] !== list || $[11] !== props || $[12] !== t7 || $[13] !== t8) {
|
|
63
|
+
t9 = /* @__PURE__ */ jsx(ListView, {
|
|
64
|
+
...props,
|
|
65
|
+
list,
|
|
66
|
+
items: t7,
|
|
67
|
+
total: t8
|
|
68
|
+
});
|
|
69
|
+
$[10] = list;
|
|
70
|
+
$[11] = props;
|
|
71
|
+
$[12] = t7;
|
|
72
|
+
$[13] = t8;
|
|
73
|
+
$[14] = t9;
|
|
74
|
+
} else t9 = $[14];
|
|
75
|
+
return t9;
|
|
34
76
|
}
|
|
35
77
|
//#endregion
|
|
36
78
|
export { List };
|
package/dist/List.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","names":[],"sources":["../src/List.tsx"],"sourcesContent":["import { type ListOptions, useList } from '@panneau/core';\nimport { usePanneauIntl } from '@panneau/ui';\n\nimport { ListView, type ListViewProps } from './ListView';\nimport { applyListQuery } from './query';\nimport type { ListItem } from './types';\n\nexport interface ListProps extends Omit<ListViewProps, 'list' | 'total' | 'items'> {\n /** Every item: the list searches, filters, sorts and paginates them in memory. */\n items: readonly ListItem[] | undefined;\n /** Items per page. Defaults to 20. */\n perPage?: number;\n /** Default sort, as `sort` query values (`['-published_at']`). */\n defaultSort?: string[];\n /**\n * Keeps the query in a router (`createHistoryRouter()`). Defaults to the router of the closest\n * `PanneauProvider`; `null` keeps it in memory.\n */\n router?: ListOptions['router'];\n}\n\n/**\n * A list of items held in memory, from columns and items, with or without a definition. It\n * creates its state with `useList()` of `@panneau/core`, and applies the query to `items` itself.\n * For items fetched page by page, create the state with `useList()`, fetch its `query`, and render\n * `ListView`.\n *\n * The page size and the default sort are read once.\n */\nexport function List({ items, perPage = 20, defaultSort = [], router, ...props }: ListProps) {\n const intl = usePanneauIntl();\n const { query, list } = useList({\n defaults: { perPage, sort: defaultSort },\n ...(router !== undefined ? { router } : {}),\n });\n const result =\n items !== undefined\n ? applyListQuery(items, query, { columns: props.columns, locale: intl.locale })\n : undefined;\n return <ListView {...props} list={list} items={result?.items} total={result?.total} />;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"List.js","names":["ListOptions","useList","usePanneauIntl","ListView","ListViewProps","applyListQuery","ListItem","ListProps","Omit","items","perPage","defaultSort","router","List","t0","$","_c","t1","t2","props","undefined","t3","intl","t4","sort","t5","t6","defaults","query","list","result","columns","locale","t7","t8","total","t9","_c"],"sources":["../src/List.tsx"],"sourcesContent":["import { type ListOptions, useList } from '@panneau/core';\nimport { usePanneauIntl } from '@panneau/ui';\n\nimport { ListView, type ListViewProps } from './ListView';\nimport { applyListQuery } from './query';\nimport type { ListItem } from './types';\n\nexport interface ListProps extends Omit<ListViewProps, 'list' | 'total' | 'items'> {\n /** Every item: the list searches, filters, sorts and paginates them in memory. */\n items: readonly ListItem[] | undefined;\n /** Items per page. Defaults to 20. */\n perPage?: number;\n /** Default sort, as `sort` query values (`['-published_at']`). */\n defaultSort?: string[];\n /**\n * Keeps the query in a router (`createHistoryRouter()`). Defaults to the router of the closest\n * `PanneauProvider`; `null` keeps it in memory.\n */\n router?: ListOptions['router'];\n}\n\n/**\n * A list of items held in memory, from columns and items, with or without a definition. It\n * creates its state with `useList()` of `@panneau/core`, and applies the query to `items` itself.\n * For items fetched page by page, create the state with `useList()`, fetch its `query`, and render\n * `ListView`.\n *\n * The page size and the default sort are read once.\n */\nexport function List({ items, perPage = 20, defaultSort = [], router, ...props }: ListProps) {\n const intl = usePanneauIntl();\n const { query, list } = useList({\n defaults: { perPage, sort: defaultSort },\n ...(router !== undefined ? { router } : {}),\n });\n const result =\n items !== undefined\n ? applyListQuery(items, query, { columns: props.columns, locale: intl.locale })\n : undefined;\n return <ListView {...props} list={list} items={result?.items} total={result?.total} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,SAAOa,KAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAc,MAAA,EAAAP,OAAAC,SAAAO,IAAAN,aAAAO,IAAAN,QAAA,GAAAO,UAAAL;CAAS,MAAAJ,UAAAO,OAAAG,KAAAA,IAAA,KAAAH;CAAY,IAAAI;CAAA,IAAAN,EAAA,OAAAG,IAAA;EAAEG,KAAAH,OAAAE,KAAAA,IAAA,CAAA,IAAAF;EAAgBH,EAAA,KAAAG;EAAAH,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAhB,MAAAJ,cAAAU;CACxC,MAAA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|
|
1
|
+
import type { ListColumn, ListLayoutEntry } from './types.js';
|
|
2
|
+
export interface ListSkeletonProps {
|
|
3
|
+
Layout: ListLayoutEntry;
|
|
4
|
+
columns: readonly ListColumn[];
|
|
5
|
+
/** The page size: as many rows, up to what fits. */
|
|
6
|
+
perPage: number | undefined;
|
|
7
|
+
sort: readonly string[];
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The first page of a list that loads (decision 0034): the list's own layout, with its columns
|
|
12
|
+
* and a skeleton for each value, as many rows as the page size, up to what fits. The layout is
|
|
13
|
+
* inert and hidden: its headers can't be used before the items are there, and the status message
|
|
14
|
+
* of the region says that the list loads.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ListSkeleton({ Layout, columns, perPage, sort, label }: ListSkeletonProps): import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=ListSkeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListSkeleton.d.ts","sourceRoot":"","sources":["../src/ListSkeleton.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAY,eAAe,EAAE,MAAM,SAAS,CAAC;AAUrE,MAAM,WAAW,iBAAiB;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,oDAAoD;IACpD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,iBAAiB,+BAgCxF"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { messages } from "./messages.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import { LoadingRegion, Skeleton, usePanneauIntl } from "@panneau/ui";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/ListSkeleton.tsx
|
|
6
|
+
/** The most rows a skeleton draws: about what fits in a window. */
|
|
7
|
+
var MAX_ROWS = 10;
|
|
8
|
+
/** Widths of the values, varied so the rows read as text. */
|
|
9
|
+
var WIDTHS = [
|
|
10
|
+
"72%",
|
|
11
|
+
"48%",
|
|
12
|
+
"64%",
|
|
13
|
+
"40%",
|
|
14
|
+
"56%",
|
|
15
|
+
"80%"
|
|
16
|
+
];
|
|
17
|
+
var none = () => null;
|
|
18
|
+
var nothing = () => void 0;
|
|
19
|
+
/**
|
|
20
|
+
* The first page of a list that loads (decision 0034): the list's own layout, with its columns
|
|
21
|
+
* and a skeleton for each value, as many rows as the page size, up to what fits. The layout is
|
|
22
|
+
* inert and hidden: its headers can't be used before the items are there, and the status message
|
|
23
|
+
* of the region says that the list loads.
|
|
24
|
+
*/
|
|
25
|
+
function ListSkeleton(t0) {
|
|
26
|
+
const $ = c(17);
|
|
27
|
+
const { Layout, columns, perPage, sort, label } = t0;
|
|
28
|
+
const intl = usePanneauIntl();
|
|
29
|
+
const rows = Math.max(1, Math.min(perPage ?? MAX_ROWS, MAX_ROWS));
|
|
30
|
+
let t1;
|
|
31
|
+
if ($[0] !== rows) {
|
|
32
|
+
t1 = Array.from({ length: rows }, _temp);
|
|
33
|
+
$[0] = rows;
|
|
34
|
+
$[1] = t1;
|
|
35
|
+
} else t1 = $[1];
|
|
36
|
+
const items = t1;
|
|
37
|
+
let t2;
|
|
38
|
+
if ($[2] !== columns || $[3] !== items) {
|
|
39
|
+
t2 = (item, column) => {
|
|
40
|
+
const offset = items.indexOf(item) + columns.indexOf(column);
|
|
41
|
+
return /* @__PURE__ */ jsx(Skeleton, { width: WIDTHS[offset % WIDTHS.length] });
|
|
42
|
+
};
|
|
43
|
+
$[2] = columns;
|
|
44
|
+
$[3] = items;
|
|
45
|
+
$[4] = t2;
|
|
46
|
+
} else t2 = $[4];
|
|
47
|
+
const renderValue = t2;
|
|
48
|
+
let t3;
|
|
49
|
+
if ($[5] !== intl) {
|
|
50
|
+
t3 = intl.formatMessage(messages.loading);
|
|
51
|
+
$[5] = intl;
|
|
52
|
+
$[6] = t3;
|
|
53
|
+
} else t3 = $[6];
|
|
54
|
+
let t4;
|
|
55
|
+
if ($[7] !== Layout || $[8] !== columns || $[9] !== items || $[10] !== label || $[11] !== renderValue || $[12] !== sort) {
|
|
56
|
+
t4 = /* @__PURE__ */ jsx("div", {
|
|
57
|
+
inert: true,
|
|
58
|
+
"aria-hidden": "true",
|
|
59
|
+
children: /* @__PURE__ */ jsx(Layout, {
|
|
60
|
+
items,
|
|
61
|
+
columns,
|
|
62
|
+
renderValue,
|
|
63
|
+
getItemLabel: _temp2,
|
|
64
|
+
getItemHref: none,
|
|
65
|
+
isCurrent: _temp3,
|
|
66
|
+
selectable: false,
|
|
67
|
+
isSelected: _temp4,
|
|
68
|
+
onToggle: nothing,
|
|
69
|
+
renderActions: none,
|
|
70
|
+
sort,
|
|
71
|
+
onSort: nothing,
|
|
72
|
+
label,
|
|
73
|
+
pageSelection: null
|
|
74
|
+
})
|
|
75
|
+
});
|
|
76
|
+
$[7] = Layout;
|
|
77
|
+
$[8] = columns;
|
|
78
|
+
$[9] = items;
|
|
79
|
+
$[10] = label;
|
|
80
|
+
$[11] = renderValue;
|
|
81
|
+
$[12] = sort;
|
|
82
|
+
$[13] = t4;
|
|
83
|
+
} else t4 = $[13];
|
|
84
|
+
let t5;
|
|
85
|
+
if ($[14] !== t3 || $[15] !== t4) {
|
|
86
|
+
t5 = /* @__PURE__ */ jsx(LoadingRegion, {
|
|
87
|
+
label: t3,
|
|
88
|
+
children: t4
|
|
89
|
+
});
|
|
90
|
+
$[14] = t3;
|
|
91
|
+
$[15] = t4;
|
|
92
|
+
$[16] = t5;
|
|
93
|
+
} else t5 = $[16];
|
|
94
|
+
return t5;
|
|
95
|
+
}
|
|
96
|
+
function _temp4() {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
function _temp3() {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
function _temp2(item_0) {
|
|
103
|
+
return item_0.id;
|
|
104
|
+
}
|
|
105
|
+
function _temp(_, index) {
|
|
106
|
+
return { id: `skeleton-${String(index)}` };
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { ListSkeleton };
|
|
110
|
+
|
|
111
|
+
//# sourceMappingURL=ListSkeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListSkeleton.js","names":["ReactNode","LoadingRegion","Skeleton","usePanneauIntl","messages","ListColumn","ListItem","ListLayoutEntry","MAX_ROWS","WIDTHS","none","nothing","undefined","ListSkeletonProps","Layout","columns","perPage","sort","label","ListSkeleton","t0","$","_c","intl","rows","Math","max","min","t1","Array","from","length","_temp","items","t2","item","column","offset","indexOf","renderValue","t3","formatMessage","loading","t4","_temp2","_temp3","_temp4","t5","item_0","id","_","index","String","_c"],"sources":["../src/ListSkeleton.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport { LoadingRegion, Skeleton, usePanneauIntl } from '@panneau/ui';\n\nimport { messages } from './messages';\nimport type { ListColumn, ListItem, ListLayoutEntry } from './types';\n\n/** The most rows a skeleton draws: about what fits in a window. */\nconst MAX_ROWS = 10;\n/** Widths of the values, varied so the rows read as text. */\nconst WIDTHS = ['72%', '48%', '64%', '40%', '56%', '80%'];\n\nconst none = () => null;\nconst nothing = () => undefined;\n\nexport interface ListSkeletonProps {\n Layout: ListLayoutEntry;\n columns: readonly ListColumn[];\n /** The page size: as many rows, up to what fits. */\n perPage: number | undefined;\n sort: readonly string[];\n label: string;\n}\n\n/**\n * The first page of a list that loads (decision 0034): the list's own layout, with its columns\n * and a skeleton for each value, as many rows as the page size, up to what fits. The layout is\n * inert and hidden: its headers can't be used before the items are there, and the status message\n * of the region says that the list loads.\n */\nexport function ListSkeleton({ Layout, columns, perPage, sort, label }: ListSkeletonProps) {\n const intl = usePanneauIntl();\n const rows = Math.max(1, Math.min(perPage ?? MAX_ROWS, MAX_ROWS));\n const items: ListItem[] = Array.from({ length: rows }, (_, index) => ({\n id: `skeleton-${String(index)}`,\n }));\n const renderValue = (item: ListItem, column: ListColumn): ReactNode => {\n const offset = items.indexOf(item) + columns.indexOf(column);\n return <Skeleton width={WIDTHS[offset % WIDTHS.length]} />;\n };\n return (\n <LoadingRegion label={intl.formatMessage(messages.loading)}>\n <div inert aria-hidden=\"true\">\n <Layout\n items={items}\n columns={columns}\n renderValue={renderValue}\n getItemLabel={(item) => item.id}\n getItemHref={none}\n isCurrent={() => false}\n selectable={false}\n isSelected={() => false}\n onToggle={nothing}\n renderActions={none}\n sort={sort}\n onSort={nothing}\n label={label}\n pageSelection={null}\n />\n </div>\n </LoadingRegion>\n );\n}\n"],"mappings":";;;;;;AAQA,IAAMQ,WAAW;;AAEjB,IAAMC,SAAS;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK;AAExD,IAAMC,aAAa;AACnB,IAAMC,gBAAgBC,KAAAA;;;;;;;AAiBtB,SAAOO,aAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAsB,MAAA,EAAAR,QAAAC,SAAAC,SAAAC,MAAAC,UAAAE;CACzB,MAAAG,OAAapB,eAAe;CAC5B,MAAAqB,OAAaC,KAAIC,IAAK,GAAGD,KAAIE,IAAKX,WAAAR,UAAqBA,QAAQ,CAAC;CAAE,IAAAoB;CAAA,IAAAP,EAAA,OAAAG,MAAA;EACxCI,KAAAC,MAAKC,KAAM,EAAAC,QAAUP,KAAK,GAAGQ,KAErD;EAACX,EAAA,KAAAG;EAAAH,EAAA,KAAAO;CAAA,OAAAA,KAAAP,EAAA;CAFH,MAAAY,QAA0BL;CAEtB,IAAAM;CAAA,IAAAb,EAAA,OAAAN,WAAAM,EAAA,OAAAY,OAAA;EACgBC,MAAAC,MAAAC,WAAA;GAChB,MAA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AA1B,EAAA;CAAA,OAnBhB0B;AAmBgB;AA9BjB,SAAAD,SAAA;CAAA,OAqB+B;AAAK;AArBpC,SAAAD,SAAA;CAAA,OAmB8B;AAAK;AAnBnC,SAAAD,OAAAI,QAAA;CAAA,OAiBqCb,OAAIc;AAAG;AAjB5C,SAAAjB,MAAAkB,GAAAC,OAAA;CAAA,OAGmE,EAAAF,IAC9D,YAAYG,OAAOD,KAAK,IAChC;AAAC"}
|
package/dist/ListView.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
.panneau-list-
|
|
1
|
+
.panneau-list-view-list {
|
|
2
2
|
container: panneau-list / inline-size;
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
min-width: 0;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.panneau-toolbar
|
|
9
|
+
.panneau-list-view-toolbar {
|
|
10
10
|
display: flex;
|
|
11
11
|
flex-wrap: wrap;
|
|
12
12
|
align-items: flex-end;
|
|
13
13
|
gap: var(--panneau-space-3);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.panneau-
|
|
16
|
+
.panneau-list-view-toolbar-start {
|
|
17
17
|
display: flex;
|
|
18
18
|
flex: 1 1 auto;
|
|
19
19
|
flex-wrap: wrap;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
min-width: 0;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
.panneau-
|
|
25
|
+
.panneau-list-view-toolbar-end {
|
|
26
26
|
display: flex;
|
|
27
27
|
flex-wrap: wrap;
|
|
28
28
|
align-items: flex-end;
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/* With the table layout, the column headers sort, until the list is too narrow to show them. */
|
|
34
|
-
.panneau-
|
|
34
|
+
.panneau-list-view-table-sort {
|
|
35
35
|
display: none;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.panneau-selection
|
|
38
|
+
.panneau-list-view-selection {
|
|
39
39
|
display: flex;
|
|
40
40
|
flex-wrap: wrap;
|
|
41
41
|
align-items: center;
|
|
@@ -47,23 +47,23 @@
|
|
|
47
47
|
border-radius: var(--panneau-radius-lg);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.panneau-
|
|
50
|
+
.panneau-list-view-selection-count {
|
|
51
51
|
font-weight: var(--panneau-font-weight-medium);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
.panneau-
|
|
54
|
+
.panneau-list-view-selection-actions {
|
|
55
55
|
display: flex;
|
|
56
56
|
flex-wrap: wrap;
|
|
57
57
|
gap: var(--panneau-space-2);
|
|
58
58
|
margin-inline-start: auto;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.panneau-body
|
|
61
|
+
.panneau-list-view-body[aria-busy='true'] {
|
|
62
62
|
opacity: 0.6;
|
|
63
63
|
transition: opacity var(--panneau-duration);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
.panneau-state
|
|
66
|
+
.panneau-list-view-state {
|
|
67
67
|
display: flex;
|
|
68
68
|
flex-direction: column;
|
|
69
69
|
align-items: center;
|
|
@@ -76,26 +76,26 @@
|
|
|
76
76
|
border-radius: var(--panneau-radius-lg);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
.panneau-state
|
|
79
|
+
.panneau-list-view-state p {
|
|
80
80
|
margin: 0;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
@container panneau-list (max-width: 40rem) {
|
|
84
|
-
.panneau-
|
|
85
|
-
.panneau-
|
|
84
|
+
.panneau-list-view-toolbar-start,
|
|
85
|
+
.panneau-list-view-toolbar-end {
|
|
86
86
|
flex-basis: 100%;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
.panneau-
|
|
89
|
+
.panneau-list-view-toolbar-end {
|
|
90
90
|
margin-inline-start: 0;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
.panneau-
|
|
93
|
+
.panneau-list-view-table-sort {
|
|
94
94
|
display: block;
|
|
95
95
|
width: 100%;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
.panneau-
|
|
98
|
+
.panneau-list-view-selection-actions {
|
|
99
99
|
margin-inline-start: 0;
|
|
100
100
|
}
|
|
101
101
|
}
|
package/dist/ListView.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { List } from '@panneau/core';
|
|
3
|
-
import type { Field, Filter } from '@panneau/protocol';
|
|
4
|
-
import { type ListActions } from './actions/actions';
|
|
5
|
-
import type { ActionIcons } from './actions/icons';
|
|
6
|
-
import type { DisplayEntry, FilterEntry, ListActionHandler, ListColumn, ListItem, ListLayoutEntry } from './types';
|
|
3
|
+
import type { Action, Field, Filter } from '@panneau/protocol';
|
|
4
|
+
import { type ListActions } from './actions/actions.js';
|
|
5
|
+
import type { ActionIcons } from './actions/icons.js';
|
|
6
|
+
import type { DisplayEntry, FilterEntry, ListActionHandler, ListActionPreviewer, ListColumn, ListItem, ListLayoutEntry } from './types.js';
|
|
7
7
|
export interface ListViewProps {
|
|
8
8
|
/** The list state of `@panneau/core` (`useList()`): query and selection. */
|
|
9
9
|
list: List;
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* The items of the current page. `undefined` while they load for the first time: the list
|
|
12
|
+
* draws a skeleton of its rows, from its columns and its page size.
|
|
13
|
+
*/
|
|
11
14
|
items: readonly ListItem[] | undefined;
|
|
12
15
|
columns: readonly ListColumn[];
|
|
13
16
|
/**
|
|
@@ -15,6 +18,15 @@ export interface ListViewProps {
|
|
|
15
18
|
* pagination and offers to select every matching item. Without it, `items` is the whole list.
|
|
16
19
|
*/
|
|
17
20
|
total?: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The cursors of the page, for a list paged with cursors (`nextCursor` and `previousCursor`
|
|
23
|
+
* of its `meta`): the list then has buttons to the previous and next pages, without page
|
|
24
|
+
* numbers or a total, and doesn't offer to select every matching item.
|
|
25
|
+
*/
|
|
26
|
+
cursors?: {
|
|
27
|
+
next: string | null;
|
|
28
|
+
previous?: string | null | undefined;
|
|
29
|
+
} | undefined;
|
|
18
30
|
/** Shows that items are loading. Items already shown stay, dimmed. */
|
|
19
31
|
isLoading?: boolean;
|
|
20
32
|
/** An error while loading: an alert with a retry replaces the items. */
|
|
@@ -42,6 +54,12 @@ export interface ListViewProps {
|
|
|
42
54
|
actions?: ListActions;
|
|
43
55
|
/** Runs an action, after its confirmation. */
|
|
44
56
|
onAction?: ListActionHandler;
|
|
57
|
+
/**
|
|
58
|
+
* Asks the backend how many items of a query selection ("Select all N items") an action will
|
|
59
|
+
* skip, before the confirmation: the list only knows the abilities of the current page. Only
|
|
60
|
+
* for actions with `dryRun`. `useActionPreview()` of `@panneau/actions` is one.
|
|
61
|
+
*/
|
|
62
|
+
previewAction?: ListActionPreviewer;
|
|
45
63
|
/**
|
|
46
64
|
* Icons of actions by action id (`{ archive: Archive }`), for actions written in code. They
|
|
47
65
|
* win over the Lucide icon an action names (`"icon": "archive"`).
|
|
@@ -53,6 +71,17 @@ export interface ListViewProps {
|
|
|
53
71
|
getItemLabel?: (item: ListItem) => string;
|
|
54
72
|
/** A link to an item, on its title. */
|
|
55
73
|
getItemHref?: (item: ListItem) => string | null;
|
|
74
|
+
/**
|
|
75
|
+
* The link of a built-in `show` or `edit` action without a `url` or a `route` (decision 0040),
|
|
76
|
+
* which the caller resolves to its own routes. Without it, or when it answers `null`, the list
|
|
77
|
+
* leaves those links out.
|
|
78
|
+
*/
|
|
79
|
+
getLinkHref?: (action: Action, item: ListItem) => string | null;
|
|
80
|
+
/**
|
|
81
|
+
* The item shown next to the list, such as in a panel of its details: its row is marked, and
|
|
82
|
+
* the link of its title is the current page.
|
|
83
|
+
*/
|
|
84
|
+
currentItemId?: string | null;
|
|
56
85
|
/** Displays by name, over the built-in ones and those of the plugins. */
|
|
57
86
|
displays?: Readonly<Record<string, DisplayEntry>>;
|
|
58
87
|
/** Layouts by id, over the built-in ones and those of the plugins. */
|
|
@@ -72,5 +101,5 @@ export interface ListViewProps {
|
|
|
72
101
|
* cards), with sorting, search, filters and their chips, pagination, selection and actions. It
|
|
73
102
|
* fetches nothing: the caller gives the items of the list's query and their total.
|
|
74
103
|
*/
|
|
75
|
-
export declare function ListView({ list, items, columns, total, isLoading, error, onRetry, filters, fields, search, layouts: layoutsProp, layout: controlledLayout, onLayoutChange, perPageOptions, selectable: selectableProp, actions: actionsProp, onAction, actionIcons, itemTitle, getItemLabel: getItemLabelProp, getItemHref, displays, layoutComponents, filterControls, toolbar, emptyMessage, 'aria-label': ariaLabel, className, }: ListViewProps): import("react").JSX.Element;
|
|
104
|
+
export declare function ListView({ list, items, columns, total, cursors, isLoading, error, onRetry, filters, fields, search, layouts: layoutsProp, layout: controlledLayout, onLayoutChange, perPageOptions, selectable: selectableProp, actions: actionsProp, onAction, previewAction, actionIcons, itemTitle, getItemLabel: getItemLabelProp, getItemHref, getLinkHref, currentItemId, displays, layoutComponents, filterControls, toolbar, emptyMessage, 'aria-label': ariaLabel, className, }: ListViewProps): import("react").JSX.Element;
|
|
76
105
|
//# sourceMappingURL=ListView.d.ts.map
|