@panneau/lists 5.0.0-alpha.11 → 5.0.0-alpha.13
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 +13 -11
- package/dist/ItemDetails.css +16 -0
- package/dist/ItemDetails.d.ts +12 -3
- package/dist/ItemDetails.d.ts.map +1 -1
- package/dist/ItemDetails.js +89 -59
- package/dist/ItemDetails.js.map +1 -1
- package/dist/ItemDetails.module.js +6 -2
- package/dist/ItemDetails.module.js.map +1 -1
- package/dist/List.d.ts +1 -1
- package/dist/List.d.ts.map +1 -1
- package/dist/List.js +29 -50
- package/dist/List.js.map +1 -1
- package/dist/ListView.d.ts +34 -5
- package/dist/ListView.d.ts.map +1 -1
- package/dist/ListView.js +416 -359
- package/dist/ListView.js.map +1 -1
- package/dist/columns.d.ts +10 -0
- package/dist/columns.d.ts.map +1 -0
- package/dist/columns.js +25 -0
- package/dist/columns.js.map +1 -0
- package/dist/displays/Displays.css +12 -0
- package/dist/displays/Displays.module.js +6 -2
- package/dist/displays/Displays.module.js.map +1 -1
- package/dist/displays/displays.d.ts +11 -1
- package/dist/displays/displays.d.ts.map +1 -1
- package/dist/displays/displays.js +185 -22
- package/dist/displays/displays.js.map +1 -1
- package/dist/images.d.ts +6 -0
- package/dist/images.d.ts.map +1 -0
- package/dist/images.js +18 -0
- package/dist/images.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/inline/Inline.css +58 -0
- package/dist/inline/Inline.module.js +20 -0
- package/dist/inline/Inline.module.js.map +1 -0
- package/dist/inline/InlineCell.d.ts +27 -0
- package/dist/inline/InlineCell.d.ts.map +1 -0
- package/dist/inline/InlineCell.js +471 -0
- package/dist/inline/InlineCell.js.map +1 -0
- package/dist/inline/editable.d.ts +12 -0
- package/dist/inline/editable.d.ts.map +1 -0
- package/dist/inline/editable.js +29 -0
- package/dist/inline/editable.js.map +1 -0
- package/dist/layouts/CalendarLayout.css +153 -0
- package/dist/layouts/CalendarLayout.d.ts +9 -0
- package/dist/layouts/CalendarLayout.d.ts.map +1 -0
- package/dist/layouts/CalendarLayout.js +298 -0
- package/dist/layouts/CalendarLayout.js.map +1 -0
- package/dist/layouts/CalendarLayout.module.js +28 -0
- package/dist/layouts/CalendarLayout.module.js.map +1 -0
- package/dist/layouts/CardsLayout.js +1 -1
- package/dist/layouts/GalleryLayout.css +80 -0
- package/dist/layouts/GalleryLayout.d.ts +8 -0
- package/dist/layouts/GalleryLayout.d.ts.map +1 -0
- package/dist/layouts/GalleryLayout.js +129 -0
- package/dist/layouts/GalleryLayout.js.map +1 -0
- package/dist/layouts/GalleryLayout.module.js +26 -0
- package/dist/layouts/GalleryLayout.module.js.map +1 -0
- package/dist/layouts/TableLayout.d.ts +1 -1
- package/dist/layouts/TableLayout.d.ts.map +1 -1
- package/dist/layouts/TableLayout.js +44 -39
- package/dist/layouts/TableLayout.js.map +1 -1
- package/dist/layouts/builtIn.d.ts +1 -1
- package/dist/layouts/builtIn.d.ts.map +1 -1
- package/dist/layouts/builtIn.js +6 -2
- package/dist/layouts/builtIn.js.map +1 -1
- package/dist/toolbar/ColumnMenu.d.ts +17 -0
- package/dist/toolbar/ColumnMenu.d.ts.map +1 -0
- package/dist/toolbar/ColumnMenu.js +193 -0
- package/dist/toolbar/ColumnMenu.js.map +1 -0
- package/dist/toolbar/LayoutSwitch.d.ts.map +1 -1
- package/dist/toolbar/LayoutSwitch.js +73 -55
- package/dist/toolbar/LayoutSwitch.js.map +1 -1
- package/dist/toolbar/Toolbar.css +36 -0
- package/dist/toolbar/Toolbar.module.js +12 -2
- package/dist/toolbar/Toolbar.module.js.map +1 -1
- package/dist/types.d.ts +42 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/values.d.ts +1 -0
- package/dist/values.d.ts.map +1 -1
- package/dist/values.js +1 -1
- package/dist/values.js.map +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -77,17 +77,19 @@ const { data, isFetching, error } = useResourceList('pages', query); // @panneau
|
|
|
77
77
|
|
|
78
78
|
## What a list does
|
|
79
79
|
|
|
80
|
-
| Feature | How
|
|
81
|
-
| ---------- |
|
|
82
|
-
| Columns | `item[id]` shown with a display: the column's `display`, else text. Localized values in the UI's locale. `render` for a cell of its own
|
|
83
|
-
| Displays | `text`, `textarea`, `slug`, `richtext`, `number`, `boolean`, `date`, `datetime`, `time`, `select`, `relation`, `url`, `email`, `color`, `media`
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
80
|
+
| Feature | How |
|
|
81
|
+
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
82
|
+
| Columns | `item[id]` shown with a display: the column's `display`, else text. Localized values in the UI's locale. `render` for a cell of its own |
|
|
83
|
+
| Displays | `text`, `textarea`, `slug`, `richtext`, `number`, `boolean`, `date`, `datetime`, `time`, `select`, `relation`, `url`, `email`, `color`, `media` |
|
|
84
|
+
| Columns | A "Columns" menu shows, hides and orders them: `hidden` columns are shown when the user picks them, and `hideable: false` ones always are. In the view of the list state |
|
|
85
|
+
| Layouts | `table`, `cards`, `gallery` (on `itemImage`) and `calendar` (with `calendar`), the first of `layouts` being the default, in the view of the list state. On narrow lists, table rows stack and show the label of each value, and the calendar lists its days with items ([0044](../../docs/decisions/0044-gallery-and-calendar.md)) |
|
|
86
|
+
| Sorting | Sortable column headers (`aria-sort`), and a select for cards and phones |
|
|
87
|
+
| Filters | `text`, `select`, `toggle`, `date`, `date-range` (sent as bounds: `filter[id][from]`, `filter[id][to]`), `relation`, with chips for the active filters and the search |
|
|
88
|
+
| Pagination | With `total`: the range, previous and next pages, and the page size (`perPageOptions`) |
|
|
89
|
+
| Selection | Checkboxes, the page, then "select all N items", which selects every item matching the query, with exceptions |
|
|
90
|
+
| Actions | `row` (buttons), `menu` (the row's menu), `toolbar` (selection and resource actions), with `confirm`, hidden by abilities ([0011](../../docs/decisions/0011-permissions.md)) |
|
|
91
|
+
| Editing | Columns of `inlineEdit` edit their field in place in the table (`text`, `number`, `select`, `boolean`, `date`), on items that can be updated: `onInlineEdit` saves the one field ([0043](../../docs/decisions/0043-inline-editing.md)) |
|
|
92
|
+
| 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
93
|
|
|
92
94
|
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
95
|
|
package/dist/ItemDetails.css
CHANGED
|
@@ -24,6 +24,17 @@
|
|
|
24
24
|
overflow-wrap: anywhere;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/* A group: its label over its values, which are indented. */
|
|
28
|
+
.panneau-item-details-group > .panneau-item-details-label {
|
|
29
|
+
color: var(--panneau-color-text);
|
|
30
|
+
font-weight: var(--panneau-font-weight-medium);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.panneau-item-details-nested {
|
|
34
|
+
padding-inline-start: var(--panneau-space-3);
|
|
35
|
+
border-inline-start: var(--panneau-border-width) solid var(--panneau-color-border);
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
/* Wide enough: the label and its value side by side. */
|
|
28
39
|
@container panneau-item-details (min-width: 30rem) {
|
|
29
40
|
.panneau-item-details-entry {
|
|
@@ -31,4 +42,9 @@
|
|
|
31
42
|
grid-template-columns: minmax(8rem, 30%) minmax(0, 1fr);
|
|
32
43
|
gap: var(--panneau-space-3);
|
|
33
44
|
}
|
|
45
|
+
|
|
46
|
+
.panneau-item-details-group {
|
|
47
|
+
display: flex;
|
|
48
|
+
gap: var(--panneau-space-2);
|
|
49
|
+
}
|
|
34
50
|
}
|
package/dist/ItemDetails.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { DisplayEntry, ListColumn, ListItem } from './types.js';
|
|
2
|
+
/** A value of the details, or a group of values under its label. */
|
|
3
|
+
export interface ItemDetailsColumn extends ListColumn {
|
|
4
|
+
/**
|
|
5
|
+
* The values of a group (a `group` field): read in the value of the column, an object, and
|
|
6
|
+
* listed under its label.
|
|
7
|
+
*/
|
|
8
|
+
columns?: readonly ItemDetailsColumn[];
|
|
9
|
+
}
|
|
2
10
|
export interface ItemDetailsProps {
|
|
3
11
|
/** The item. `undefined` while it loads: the labels, with a skeleton of each value. */
|
|
4
12
|
item: ListItem | undefined;
|
|
5
13
|
/** The values to show, with their label and display, in order. */
|
|
6
|
-
columns: readonly
|
|
14
|
+
columns: readonly ItemDetailsColumn[];
|
|
7
15
|
/** Displays by name, over the built-in ones and those of the plugins. */
|
|
8
16
|
displays?: Readonly<Record<string, DisplayEntry>>;
|
|
9
17
|
'aria-label'?: string;
|
|
@@ -11,8 +19,9 @@ export interface ItemDetailsProps {
|
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
21
|
* 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.
|
|
15
|
-
*
|
|
22
|
+
* details of an item next to its list, or anywhere a read-only view of it is needed. A column with
|
|
23
|
+
* `columns` is a group, whose values are listed under its label. While the item loads, it draws
|
|
24
|
+
* the labels with a skeleton of each value (decision 0034).
|
|
16
25
|
*/
|
|
17
26
|
export declare function ItemDetails({ item, columns, displays, 'aria-label': ariaLabel, className, }: ItemDetailsProps): import("react").JSX.Element;
|
|
18
27
|
//# sourceMappingURL=ItemDetails.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAOlE,oEAAoE;AACpE,MAAM,WAAW,iBAAkB,SAAQ,UAAU;IACjD;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,gBAAgB;IAC7B,uFAAuF;IACvF,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,kEAAkE;IAClE,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,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;AAMD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EACxB,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,YAAY,EAAE,SAAS,EACvB,SAAS,GACZ,EAAE,gBAAgB,+BA0DlB"}
|
package/dist/ItemDetails.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { messages } from "./messages.js";
|
|
2
|
+
import { getColumnValue } from "./values.js";
|
|
2
3
|
import { cx } from "./cx.js";
|
|
3
4
|
import ItemDetails_module_default from "./ItemDetails.module.js";
|
|
4
5
|
import { useRenderValue } from "./useRenderValue.js";
|
|
@@ -14,87 +15,116 @@ var WIDTHS = [
|
|
|
14
15
|
"30%",
|
|
15
16
|
"65%"
|
|
16
17
|
];
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
20
|
+
}
|
|
17
21
|
/**
|
|
18
22
|
* 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.
|
|
20
|
-
*
|
|
23
|
+
* details of an item next to its list, or anywhere a read-only view of it is needed. A column with
|
|
24
|
+
* `columns` is a group, whose values are listed under its label. While the item loads, it draws
|
|
25
|
+
* the labels with a skeleton of each value (decision 0034).
|
|
21
26
|
*/
|
|
22
27
|
function ItemDetails(t0) {
|
|
23
|
-
const $ = c(
|
|
28
|
+
const $ = c(22);
|
|
24
29
|
const { item, columns, displays, "aria-label": ariaLabel, className } = t0;
|
|
25
30
|
const intl = usePanneauIntl();
|
|
26
31
|
const renderValue = useRenderValue(displays);
|
|
27
32
|
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
33
|
let t2;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
let t3;
|
|
35
|
+
if ($[0] !== ariaLabel || $[1] !== className || $[2] !== columns || $[3] !== intl || $[4] !== item || $[5] !== renderValue) {
|
|
36
|
+
const renderEntries = (entryItem, entryColumns) => entryColumns.map((column, index) => {
|
|
37
|
+
const label = /* @__PURE__ */ jsx("dt", {
|
|
38
|
+
className: ItemDetails_module_default.label,
|
|
39
|
+
children: column.label ?? column.id
|
|
40
|
+
});
|
|
41
|
+
if (column.columns !== void 0) {
|
|
42
|
+
const value = entryItem !== void 0 ? getColumnValue(entryItem, column, intl.locale) : void 0;
|
|
43
|
+
const groupItem = entryItem !== void 0 ? {
|
|
44
|
+
...isRecord(value) ? value : {},
|
|
45
|
+
id: entryItem.id
|
|
46
|
+
} : void 0;
|
|
47
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
className: cx(ItemDetails_module_default.entry, ItemDetails_module_default.group),
|
|
49
|
+
children: [label, /* @__PURE__ */ jsx("dd", {
|
|
50
|
+
className: ItemDetails_module_default.value,
|
|
51
|
+
children: /* @__PURE__ */ jsx("dl", {
|
|
52
|
+
className: cx(ItemDetails_module_default.details, ItemDetails_module_default.nested),
|
|
53
|
+
children: renderEntries(groupItem, column.columns)
|
|
54
|
+
})
|
|
55
|
+
})]
|
|
56
|
+
}, column.id);
|
|
57
|
+
}
|
|
58
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
38
59
|
className: ItemDetails_module_default.entry,
|
|
39
|
-
children: [/* @__PURE__ */ jsx("
|
|
40
|
-
className: ItemDetails_module_default.label,
|
|
41
|
-
children: column.label ?? column.id
|
|
42
|
-
}), /* @__PURE__ */ jsx("dd", {
|
|
60
|
+
children: [label, /* @__PURE__ */ jsx("dd", {
|
|
43
61
|
className: ItemDetails_module_default.value,
|
|
44
|
-
children:
|
|
62
|
+
children: entryItem !== void 0 ? renderValue(entryItem, column) : /* @__PURE__ */ jsx(Skeleton, { width: WIDTHS[index % WIDTHS.length] })
|
|
45
63
|
})]
|
|
46
64
|
}, column.id);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
65
|
+
});
|
|
66
|
+
t1 = ariaLabel;
|
|
67
|
+
if ($[9] !== className) {
|
|
68
|
+
t2 = cx(ItemDetails_module_default.details, className);
|
|
69
|
+
$[9] = className;
|
|
70
|
+
$[10] = t2;
|
|
71
|
+
} else t2 = $[10];
|
|
72
|
+
t3 = renderEntries(item, columns);
|
|
73
|
+
$[0] = ariaLabel;
|
|
74
|
+
$[1] = className;
|
|
52
75
|
$[2] = columns;
|
|
53
|
-
$[3] =
|
|
54
|
-
$[4] =
|
|
55
|
-
$[5] =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
76
|
+
$[3] = intl;
|
|
77
|
+
$[4] = item;
|
|
78
|
+
$[5] = renderValue;
|
|
79
|
+
$[6] = t1;
|
|
80
|
+
$[7] = t2;
|
|
81
|
+
$[8] = t3;
|
|
82
|
+
} else {
|
|
83
|
+
t1 = $[6];
|
|
84
|
+
t2 = $[7];
|
|
85
|
+
t3 = $[8];
|
|
86
|
+
}
|
|
87
|
+
let t4;
|
|
88
|
+
if ($[11] !== t1 || $[12] !== t2 || $[13] !== t3) {
|
|
89
|
+
t4 = /* @__PURE__ */ jsx("dl", {
|
|
90
|
+
"aria-label": t1,
|
|
91
|
+
className: t2,
|
|
92
|
+
children: t3
|
|
63
93
|
});
|
|
64
|
-
$[
|
|
65
|
-
$[
|
|
66
|
-
$[
|
|
67
|
-
$[
|
|
68
|
-
} else
|
|
69
|
-
const details =
|
|
94
|
+
$[11] = t1;
|
|
95
|
+
$[12] = t2;
|
|
96
|
+
$[13] = t3;
|
|
97
|
+
$[14] = t4;
|
|
98
|
+
} else t4 = $[14];
|
|
99
|
+
const details = t4;
|
|
70
100
|
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
101
|
let t5;
|
|
78
|
-
if ($[15] !==
|
|
79
|
-
t5 =
|
|
102
|
+
if ($[15] !== intl) {
|
|
103
|
+
t5 = intl.formatMessage(messages.loadingItem);
|
|
104
|
+
$[15] = intl;
|
|
105
|
+
$[16] = t5;
|
|
106
|
+
} else t5 = $[16];
|
|
107
|
+
let t6;
|
|
108
|
+
if ($[17] !== details) {
|
|
109
|
+
t6 = /* @__PURE__ */ jsx("div", {
|
|
80
110
|
inert: true,
|
|
81
111
|
"aria-hidden": "true",
|
|
82
112
|
children: details
|
|
83
113
|
});
|
|
84
|
-
$[
|
|
85
|
-
$[
|
|
86
|
-
} else
|
|
87
|
-
let
|
|
88
|
-
if ($[
|
|
89
|
-
|
|
90
|
-
label:
|
|
91
|
-
children:
|
|
114
|
+
$[17] = details;
|
|
115
|
+
$[18] = t6;
|
|
116
|
+
} else t6 = $[18];
|
|
117
|
+
let t7;
|
|
118
|
+
if ($[19] !== t5 || $[20] !== t6) {
|
|
119
|
+
t7 = /* @__PURE__ */ jsx(LoadingRegion, {
|
|
120
|
+
label: t5,
|
|
121
|
+
children: t6
|
|
92
122
|
});
|
|
93
|
-
$[
|
|
94
|
-
$[
|
|
95
|
-
$[
|
|
96
|
-
} else
|
|
97
|
-
return
|
|
123
|
+
$[19] = t5;
|
|
124
|
+
$[20] = t6;
|
|
125
|
+
$[21] = t7;
|
|
126
|
+
} else t7 = $[21];
|
|
127
|
+
return t7;
|
|
98
128
|
}
|
|
99
129
|
return details;
|
|
100
130
|
}
|
package/dist/ItemDetails.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemDetails.js","names":["LoadingRegion","Skeleton","usePanneauIntl","styles","cx","messages","DisplayEntry","ListColumn","ListItem","useRenderValue","
|
|
1
|
+
{"version":3,"file":"ItemDetails.js","names":["LoadingRegion","Skeleton","usePanneauIntl","styles","cx","messages","DisplayEntry","ListColumn","ListItem","useRenderValue","getColumnValue","WIDTHS","ItemDetailsColumn","columns","ItemDetailsProps","item","displays","Readonly","Record","className","isRecord","value","Array","isArray","ItemDetails","t0","$","_c","ariaLabel","intl","renderValue","t1","t2","t3","renderEntries","entryItem","entryColumns","map","column","index","label","id","undefined","locale","groupItem","entry","group","details","nested","length","t4","t5","formatMessage","loadingItem","t6","t7","_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';\nimport { getColumnValue } from './values';\n\n/** Widths of the values of a skeleton, varied so they read as text. */\nconst WIDTHS = ['70%', '40%', '55%', '30%', '65%'];\n\n/** A value of the details, or a group of values under its label. */\nexport interface ItemDetailsColumn extends ListColumn {\n /**\n * The values of a group (a `group` field): read in the value of the column, an object, and\n * listed under its label.\n */\n columns?: readonly ItemDetailsColumn[];\n}\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 ItemDetailsColumn[];\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\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\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. A column with\n * `columns` is a group, whose values are listed under its label. While the item loads, it draws\n * 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 renderEntries = (\n entryItem: ListItem | undefined,\n entryColumns: readonly ItemDetailsColumn[],\n ) =>\n entryColumns.map((column, index) => {\n const label = <dt className={styles.label}>{column.label ?? column.id}</dt>;\n if (column.columns !== undefined) {\n // The values of a group are those of an item made of the value of the column.\n const value =\n entryItem !== undefined\n ? getColumnValue(entryItem, column, intl.locale)\n : undefined;\n const groupItem =\n entryItem !== undefined\n ? { ...(isRecord(value) ? value : {}), id: entryItem.id }\n : undefined;\n return (\n <div key={column.id} className={cx(styles.entry, styles.group)}>\n {label}\n <dd className={styles.value}>\n <dl className={cx(styles.details, styles.nested)}>\n {renderEntries(groupItem, column.columns)}\n </dl>\n </dd>\n </div>\n );\n }\n return (\n <div key={column.id} className={styles.entry}>\n {label}\n <dd className={styles.value}>\n {entryItem !== undefined ? (\n renderValue(entryItem, column)\n ) : (\n <Skeleton width={WIDTHS[index % WIDTHS.length]} />\n )}\n </dd>\n </div>\n );\n });\n const details = (\n <dl aria-label={ariaLabel} className={cx(styles.details, className)}>\n {renderEntries(item, columns)}\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":";;;;;;;;;;AAUA,IAAMW,SAAS;CAAC;CAAO;CAAO;CAAO;CAAO;AAAK;AAsBjD,SAASS,SAASC,OAAkD;CAChE,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,CAACC,MAAMC,QAAQF,KAAK;AAC9E;;;;;;;AAQA,SAAOG,YAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAqB,MAAA,EAAAZ,MAAAF,SAAAG,UAAA,cAAAY,WAAAT,cAAAM;CAOxB,MAAAI,OAAa3B,eAAe;CAC5B,MAAA4B,cAAoBrB,eAAeO,QAAQ;CAAE,IAAAe;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAP,EAAA,OAAAE,aAAAF,EAAA,OAAAP,aAAAO,EAAA,OAAAb,WAAAa,EAAA,OAAAG,QAAAH,EAAA,OAAAX,QAAAW,EAAA,OAAAI,aAAA;EAC7C,MAAAI,iBAAsBC,WAAAC,iBAIlBA,aAAYC,KAAKC,QAAAC,UAAA;GACb,MAAAC,QAAc,oBAAA,MAAA;IAAe,WAAArC,2BAAMqC;IAASF,UAAAA,OAAME,SAAUF,OAAMG;GAAS,CAAA;GAC3E,IAAIH,OAAMzB,YAAa6B,KAAAA,GAAS;IAE5B,MAAArB,QACIc,cAAcO,KAAAA,IACRhC,eAAeyB,WAAWG,QAAQT,KAAIc,MAC9B,IAFdD,KAAAA;IAGJ,MAAAE,YACIT,cAAcO,KAAAA,IAAd;KAAA,GACYtB,SAASC,KAAkB,IAA3BA,QAAA,CAA2B;KAACoB,IAAON,UAASM;IAC1C,IAFdC,KAAAA;I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B,WAAAI;GACjCC,UAAAA;EACA,CAAA;EAAAP,EAAA,MAAAK;EAAAL,EAAA,MAAAM;EAAAN,EAAA,MAAAO;EAAAP,EAAA,MAAAwB;CAAA,OAAAA,KAAAxB,EAAA;CAHT,MAAAqB,UACIG;CAIJ,IAAInC,SAAS2B,KAAAA,GAAS;EAAA,IAAAS;EAAA,IAAAzB,EAAA,QAAAG,MAAA;GAEQsB,KAAAtB,KAAIuB,cAAe/C,SAAQgD,WAAY;GAAC3B,EAAA,MAAAG;GAAAH,EAAA,MAAAyB;EAAA,OAAAA,KAAAzB,EAAA;EAAA,IAAA4B;EAAA,IAAA5B,EAAA,QAAAqB,SAAA;GAC1DO,KAAA,oBAAA,OAAA;IAAK,OAAA;IAAkB,eAAA;IAClBP,UAAAA;GACC,CAAA;GAAArB,EAAA,MAAAqB;GAAArB,EAAA,MAAA4B;EAAA,OAAAA,KAAA5B,EAAA;EAAA,IAAA6B;EAAA,IAAA7B,EAAA,QAAAyB,MAAAzB,EAAA,QAAA4B,IAAA;GAHVC,KAAA,oBAAC,eAAD;IAAsB,OAAAJ;IAClBG,UAAAA;GADU,CAAA;GAIE5B,EAAA,MAAAyB;GAAAzB,EAAA,MAAA4B;GAAA5B,EAAA,MAAA6B;EAAA,OAAAA,KAAA7B,EAAA;EAAA,OAJhB6B;CAIgB;CAEvB,OACMR;AAAO"}
|
|
@@ -4,13 +4,17 @@ var details = "panneau-item-details-details";
|
|
|
4
4
|
var entry = "panneau-item-details-entry";
|
|
5
5
|
var label = "panneau-item-details-label";
|
|
6
6
|
var value = "panneau-item-details-value";
|
|
7
|
+
var group = "panneau-item-details-group";
|
|
8
|
+
var nested = "panneau-item-details-nested";
|
|
7
9
|
var ItemDetails_module_default = {
|
|
8
10
|
details,
|
|
9
11
|
entry,
|
|
10
12
|
label,
|
|
11
|
-
value
|
|
13
|
+
value,
|
|
14
|
+
group,
|
|
15
|
+
nested
|
|
12
16
|
};
|
|
13
17
|
//#endregion
|
|
14
|
-
export { ItemDetails_module_default as default, details, entry, label, value };
|
|
18
|
+
export { ItemDetails_module_default as default, details, entry, group, label, nested, value };
|
|
15
19
|
|
|
16
20
|
//# sourceMappingURL=ItemDetails.module.js.map
|
|
@@ -1 +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":""}
|
|
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/* A group: its label over its values, which are indented. */\n.group > .label {\n color: var(--panneau-color-text);\n font-weight: var(--panneau-font-weight-medium);\n}\n\n.nested {\n padding-inline-start: var(--panneau-space-3);\n border-inline-start: var(--panneau-border-width) solid var(--panneau-color-border);\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 .group {\n display: flex;\n gap: var(--panneau-space-2);\n }\n}\n"],"mappings":""}
|
package/dist/List.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface ListProps extends Omit<ListViewProps, 'list' | 'total' | 'items
|
|
|
20
20
|
* For items fetched page by page, create the state with `useList()`, fetch its `query`, and render
|
|
21
21
|
* `ListView`.
|
|
22
22
|
*
|
|
23
|
-
* The page size
|
|
23
|
+
* The page size, the default sort, the first layout and the calendar are read once.
|
|
24
24
|
*/
|
|
25
25
|
export declare function List({ items, perPage, defaultSort, router, ...props }: ListProps): import("react").JSX.Element;
|
|
26
26
|
//# sourceMappingURL=List.d.ts.map
|
package/dist/List.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../src/List.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../src/List.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,WAAW,EAAW,MAAM,eAAe,CAAC;AAGrF,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;IAC9E,kFAAkF;IAClF,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,CAAC;IACvC,sCAAsC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,EAAE,KAAK,EAAE,OAAY,EAAE,WAAgB,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,+BAkB1F"}
|
package/dist/List.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ListView } from "./ListView.js";
|
|
2
2
|
import { applyListQuery } from "./query.js";
|
|
3
|
-
import { useList } from "@panneau/core";
|
|
3
|
+
import { DEFAULT_CALENDAR_PER_PAGE, useList } from "@panneau/core";
|
|
4
4
|
import { c } from "react/compiler-runtime";
|
|
5
5
|
import { usePanneauIntl } from "@panneau/ui";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -11,68 +11,47 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
* For items fetched page by page, create the state with `useList()`, fetch its `query`, and render
|
|
12
12
|
* `ListView`.
|
|
13
13
|
*
|
|
14
|
-
* The page size
|
|
14
|
+
* The page size, the default sort, the first layout and the calendar are read once.
|
|
15
15
|
*/
|
|
16
16
|
function List(t0) {
|
|
17
|
-
const $ = c(
|
|
17
|
+
const $ = c(5);
|
|
18
18
|
const { items, perPage: t1, defaultSort: t2, router, ...props } = t0;
|
|
19
19
|
const perPage = t1 === void 0 ? 20 : t1;
|
|
20
|
-
|
|
21
|
-
if ($[0] !== t2) {
|
|
22
|
-
t3 = t2 === void 0 ? [] : t2;
|
|
23
|
-
$[0] = t2;
|
|
24
|
-
$[1] = t3;
|
|
25
|
-
} else t3 = $[1];
|
|
26
|
-
const defaultSort = t3;
|
|
20
|
+
const defaultSort = t2 === void 0 ? [] : t2;
|
|
27
21
|
const intl = usePanneauIntl();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
t4 = {
|
|
22
|
+
const { query, list } = useList({
|
|
23
|
+
defaults: {
|
|
31
24
|
perPage,
|
|
32
|
-
sort: defaultSort
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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);
|
|
25
|
+
sort: defaultSort,
|
|
26
|
+
...props.layouts?.[0] !== void 0 ? { layout: props.layouts[0] } : {},
|
|
27
|
+
...props.calendar !== null && props.calendar !== void 0 ? { calendar: {
|
|
28
|
+
...props.calendar,
|
|
29
|
+
perPage: DEFAULT_CALENDAR_PER_PAGE
|
|
30
|
+
} } : {}
|
|
31
|
+
},
|
|
32
|
+
...router !== void 0 ? { router } : {}
|
|
33
|
+
});
|
|
55
34
|
const result = items !== void 0 ? applyListQuery(items, query, {
|
|
56
35
|
columns: props.columns,
|
|
57
36
|
locale: intl.locale
|
|
58
37
|
}) : void 0;
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
let
|
|
62
|
-
if ($[
|
|
63
|
-
|
|
38
|
+
const t3 = result?.items;
|
|
39
|
+
const t4 = result?.total;
|
|
40
|
+
let t5;
|
|
41
|
+
if ($[0] !== list || $[1] !== props || $[2] !== t3 || $[3] !== t4) {
|
|
42
|
+
t5 = /* @__PURE__ */ jsx(ListView, {
|
|
64
43
|
...props,
|
|
65
44
|
list,
|
|
66
|
-
items:
|
|
67
|
-
total:
|
|
45
|
+
items: t3,
|
|
46
|
+
total: t4
|
|
68
47
|
});
|
|
69
|
-
$[
|
|
70
|
-
$[
|
|
71
|
-
$[
|
|
72
|
-
$[
|
|
73
|
-
$[
|
|
74
|
-
} else
|
|
75
|
-
return
|
|
48
|
+
$[0] = list;
|
|
49
|
+
$[1] = props;
|
|
50
|
+
$[2] = t3;
|
|
51
|
+
$[3] = t4;
|
|
52
|
+
$[4] = t5;
|
|
53
|
+
} else t5 = $[4];
|
|
54
|
+
return t5;
|
|
76
55
|
}
|
|
77
56
|
//#endregion
|
|
78
57
|
export { List };
|
package/dist/List.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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","
|
|
1
|
+
{"version":3,"file":"List.js","names":["DEFAULT_CALENDAR_PER_PAGE","ListOptions","useList","usePanneauIntl","ListView","ListViewProps","applyListQuery","ListItem","ListProps","Omit","items","perPage","defaultSort","router","List","t0","$","_c","t1","t2","props","undefined","intl","query","list","defaults","sort","layouts","layout","calendar","result","columns","locale","t3","t4","total","t5","_c"],"sources":["../src/List.tsx"],"sourcesContent":["import { DEFAULT_CALENDAR_PER_PAGE, 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, the default sort, the first layout and the calendar 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: {\n perPage,\n sort: defaultSort,\n ...(props.layouts?.[0] !== undefined ? { layout: props.layouts[0] } : {}),\n ...(props.calendar !== null && props.calendar !== undefined\n ? { calendar: { ...props.calendar, perPage: DEFAULT_CALENDAR_PER_PAGE } }\n : {}),\n },\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,SAAOc,KAAAC,IAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAc,MAAA,EAAAP,OAAAC,SAAAO,IAAAN,aAAAO,IAAAN,QAAA,GAAAO,UAAAL;CAAS,MAAAJ,UAAAO,OAAAG,KAAAA,IAAA,KAAAH;CAAc,MAAAN,cAAAO,OAAAE,KAAAA,IAAA,CAAA,IAAAF;CACxC,MAAAG,OAAanB,eAAe;CAC5B,MAAA,EAAAoB,OAAAC,SAAwBtB,QAAQ;EAAAuB,UAClB;GAAAd;GAAAe,MAEAd;GAAW,GACbQ,MAAKO,UAAa,OAAKN,KAAAA,IAAvB,EAAAO,QAA6CR,MAAKO,QAAQ,GAAS,IAAnE,CAAmE;GAAC,GACpEP,MAAKS,aAAc,QAAQT,MAAKS,aAAcR,KAAAA,IAA9C,EAAAQ,UACc;IAAA,GAAKT,MAAKS;IAASlB,SAAWX;GAA0B,EACnE,IAFH,CAEG;EACX;EAAC,GACGa,WAAWQ,KAAAA,IAAX,EAAAR,OAAqC,IAArC,CAAqC;CAC7C,CAAC;CACD,MAAAiB,SACIpB,UAAUW,KAAAA,IACJf,eAAeI,OAAOa,OAAO;EAAAQ,SAAWX,MAAKW;EAAQC,QAAUV,KAAIU;CAAQ,CACnE,IAFdX,KAAAA;CAG2C,MAAAY,KAAAH,QAAMpB;CAAgB,MAAAwB,KAAAJ,QAAMK;CAAO,IAAAC;CAAA,IAAApB,EAAA,OAAAQ,QAAAR,EAAA,OAAAI,SAAAJ,EAAA,OAAAiB,MAAAjB,EAAA,OAAAkB,IAAA;EAA3EE,KAAA,oBAAC,UAAD;GAAS,GAAKhB;GAAaI;GAAa,OAAAS;GAAsB,OAAAC;EAAa,CAAA;EAAIlB,EAAA,KAAAQ;EAAAR,EAAA,KAAAI;EAAAJ,EAAA,KAAAiB;EAAAjB,EAAA,KAAAkB;EAAAlB,EAAA,KAAAoB;CAAA,OAAAA,KAAApB,EAAA;CAAA,OAA/EoB;AAA+E"}
|
package/dist/ListView.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import type { List } from '@panneau/core';
|
|
3
|
-
import type { Action, Field, Filter } from '@panneau/protocol';
|
|
2
|
+
import type { List, ResolvedCalendar } from '@panneau/core';
|
|
3
|
+
import type { Action, Field, Filter, RuleFailure } from '@panneau/protocol';
|
|
4
4
|
import { type ListActions } from './actions/actions.js';
|
|
5
5
|
import type { ActionIcons } from './actions/icons.js';
|
|
6
|
-
import type { DisplayEntry, FilterEntry, ListActionHandler, ListActionPreviewer, ListColumn, ListItem, ListLayoutEntry } from './types.js';
|
|
6
|
+
import type { DisplayEntry, FilterEntry, ListActionHandler, ListActionPreviewer, ListColumn, ListInlineEditHandler, 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;
|
|
@@ -12,7 +12,13 @@ export interface ListViewProps {
|
|
|
12
12
|
* draws a skeleton of its rows, from its columns and its page size.
|
|
13
13
|
*/
|
|
14
14
|
items: readonly ListItem[] | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Every column of the list. Those with `hidden` are shown when the user chooses them, from
|
|
17
|
+
* the "Columns" menu, and the view of the list state says which ones are shown (decision 0042).
|
|
18
|
+
*/
|
|
15
19
|
columns: readonly ListColumn[];
|
|
20
|
+
/** Offers the user to show, hide and order the columns. Defaults to `true`. */
|
|
21
|
+
columnChoice?: boolean;
|
|
16
22
|
/**
|
|
17
23
|
* How many items match the query, on every page (`meta.total`). With it, the list shows
|
|
18
24
|
* pagination and offers to select every matching item. Without it, `items` is the whole list.
|
|
@@ -40,7 +46,7 @@ export interface ListViewProps {
|
|
|
40
46
|
search?: boolean;
|
|
41
47
|
/** Layouts to choose from, the first one being the default. Defaults to `['table']`. */
|
|
42
48
|
layouts?: readonly string[];
|
|
43
|
-
/** The layout, controlled. */
|
|
49
|
+
/** The layout, controlled. Without it, the layout is the view of the list state. */
|
|
44
50
|
layout?: string;
|
|
45
51
|
onLayoutChange?: (layout: string) => void;
|
|
46
52
|
/** Page sizes to choose from. */
|
|
@@ -67,6 +73,16 @@ export interface ListViewProps {
|
|
|
67
73
|
actionIcons?: ActionIcons;
|
|
68
74
|
/** The field that titles items, for their label (`itemTitle` of the resource). */
|
|
69
75
|
itemTitle?: string;
|
|
76
|
+
/**
|
|
77
|
+
* The field shown as the image of items (`itemImage` of the resource): a media reference, a
|
|
78
|
+
* file or a URL. The `gallery` layout needs it (decision 0044).
|
|
79
|
+
*/
|
|
80
|
+
itemImage?: string | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The calendar of the list (`calendar` of `resolveList()`), for its `calendar` layout. The list
|
|
83
|
+
* state asks for its month when it is given the same calendar.
|
|
84
|
+
*/
|
|
85
|
+
calendar?: Pick<ResolvedCalendar, 'field' | 'filter'> | null | undefined;
|
|
70
86
|
/** The label of an item, for checkboxes and actions. Defaults to its title, then its id. */
|
|
71
87
|
getItemLabel?: (item: ListItem) => string;
|
|
72
88
|
/** A link to an item, on its title. */
|
|
@@ -88,6 +104,19 @@ export interface ListViewProps {
|
|
|
88
104
|
layoutComponents?: Readonly<Record<string, ListLayoutEntry>>;
|
|
89
105
|
/** Filter controls by filter type, over the built-in ones. */
|
|
90
106
|
filterControls?: Readonly<Record<string, FilterEntry>>;
|
|
107
|
+
/**
|
|
108
|
+
* The fields that columns edit in place (`inlineEdit` of the list), on the items that can be
|
|
109
|
+
* updated, in the table (decision 0043). Needs `onInlineEdit`.
|
|
110
|
+
*/
|
|
111
|
+
inlineEdit?: readonly string[];
|
|
112
|
+
/** Saves a field edited in place, and resolves with the updated item. */
|
|
113
|
+
onInlineEdit?: ListInlineEditHandler;
|
|
114
|
+
/**
|
|
115
|
+
* The message of a portable rule that a value edited in place fails. Defaults to
|
|
116
|
+
* `formatRuleFailure()` of `@panneau/core`, in English; `useFormatRuleFailure()` of
|
|
117
|
+
* `@panneau/forms` translates them.
|
|
118
|
+
*/
|
|
119
|
+
formatError?: (failure: RuleFailure, path: string) => string;
|
|
91
120
|
/** Content at the end of the toolbar, such as a button to create an item. */
|
|
92
121
|
toolbar?: ReactNode;
|
|
93
122
|
/** Shown when the list has no items, without filters or search. */
|
|
@@ -101,5 +130,5 @@ export interface ListViewProps {
|
|
|
101
130
|
* cards), with sorting, search, filters and their chips, pagination, selection and actions. It
|
|
102
131
|
* fetches nothing: the caller gives the items of the list's query and their total.
|
|
103
132
|
*/
|
|
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;
|
|
133
|
+
export declare function ListView({ list, items, columns: allColumns, columnChoice, total, cursors, isLoading, error, onRetry, filters: filtersProp, fields, search, layouts: layoutsProp, layout: controlledLayout, onLayoutChange, perPageOptions, selectable: selectableProp, actions: actionsProp, onAction, previewAction, actionIcons, itemTitle, itemImage, calendar, getItemLabel: getItemLabelProp, getItemHref, getLinkHref, currentItemId, displays, layoutComponents, filterControls, inlineEdit, onInlineEdit, formatError, toolbar, emptyMessage, 'aria-label': ariaLabel, className, }: ListViewProps): import("react").JSX.Element;
|
|
105
134
|
//# sourceMappingURL=ListView.d.ts.map
|
package/dist/ListView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../src/ListView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ListView.d.ts","sourceRoot":"","sources":["../src/ListView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAQ5E,OAAO,EACH,KAAK,WAAW,EAKnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAenD,OAAO,KAAK,EACR,YAAY,EACZ,WAAW,EAEX,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,eAAe,EAClB,MAAM,SAAS,CAAC;AAKjB,MAAM,WAAW,aAAa;IAC1B,4EAA4E;IAC5E,IAAI,EAAE,IAAI,CAAC;IACX;;;OAGG;IACH,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,+EAA+E;IAC/E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,CA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