@panneau/lists 5.0.0-alpha.12 → 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.
Files changed (78) hide show
  1. package/README.md +13 -11
  2. package/dist/List.d.ts +1 -1
  3. package/dist/List.d.ts.map +1 -1
  4. package/dist/List.js +29 -50
  5. package/dist/List.js.map +1 -1
  6. package/dist/ListView.d.ts +34 -5
  7. package/dist/ListView.d.ts.map +1 -1
  8. package/dist/ListView.js +416 -359
  9. package/dist/ListView.js.map +1 -1
  10. package/dist/columns.d.ts +10 -0
  11. package/dist/columns.d.ts.map +1 -0
  12. package/dist/columns.js +25 -0
  13. package/dist/columns.js.map +1 -0
  14. package/dist/displays/Displays.css +12 -0
  15. package/dist/displays/Displays.module.js +6 -2
  16. package/dist/displays/Displays.module.js.map +1 -1
  17. package/dist/displays/displays.d.ts +11 -1
  18. package/dist/displays/displays.d.ts.map +1 -1
  19. package/dist/displays/displays.js +185 -22
  20. package/dist/displays/displays.js.map +1 -1
  21. package/dist/images.d.ts +6 -0
  22. package/dist/images.d.ts.map +1 -0
  23. package/dist/images.js +18 -0
  24. package/dist/images.js.map +1 -0
  25. package/dist/index.d.ts +5 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -2
  28. package/dist/inline/Inline.css +58 -0
  29. package/dist/inline/Inline.module.js +20 -0
  30. package/dist/inline/Inline.module.js.map +1 -0
  31. package/dist/inline/InlineCell.d.ts +27 -0
  32. package/dist/inline/InlineCell.d.ts.map +1 -0
  33. package/dist/inline/InlineCell.js +471 -0
  34. package/dist/inline/InlineCell.js.map +1 -0
  35. package/dist/inline/editable.d.ts +12 -0
  36. package/dist/inline/editable.d.ts.map +1 -0
  37. package/dist/inline/editable.js +29 -0
  38. package/dist/inline/editable.js.map +1 -0
  39. package/dist/layouts/CalendarLayout.css +153 -0
  40. package/dist/layouts/CalendarLayout.d.ts +9 -0
  41. package/dist/layouts/CalendarLayout.d.ts.map +1 -0
  42. package/dist/layouts/CalendarLayout.js +298 -0
  43. package/dist/layouts/CalendarLayout.js.map +1 -0
  44. package/dist/layouts/CalendarLayout.module.js +28 -0
  45. package/dist/layouts/CalendarLayout.module.js.map +1 -0
  46. package/dist/layouts/CardsLayout.js +1 -1
  47. package/dist/layouts/GalleryLayout.css +80 -0
  48. package/dist/layouts/GalleryLayout.d.ts +8 -0
  49. package/dist/layouts/GalleryLayout.d.ts.map +1 -0
  50. package/dist/layouts/GalleryLayout.js +129 -0
  51. package/dist/layouts/GalleryLayout.js.map +1 -0
  52. package/dist/layouts/GalleryLayout.module.js +26 -0
  53. package/dist/layouts/GalleryLayout.module.js.map +1 -0
  54. package/dist/layouts/TableLayout.d.ts +1 -1
  55. package/dist/layouts/TableLayout.d.ts.map +1 -1
  56. package/dist/layouts/TableLayout.js +44 -39
  57. package/dist/layouts/TableLayout.js.map +1 -1
  58. package/dist/layouts/builtIn.d.ts +1 -1
  59. package/dist/layouts/builtIn.d.ts.map +1 -1
  60. package/dist/layouts/builtIn.js +6 -2
  61. package/dist/layouts/builtIn.js.map +1 -1
  62. package/dist/toolbar/ColumnMenu.d.ts +17 -0
  63. package/dist/toolbar/ColumnMenu.d.ts.map +1 -0
  64. package/dist/toolbar/ColumnMenu.js +193 -0
  65. package/dist/toolbar/ColumnMenu.js.map +1 -0
  66. package/dist/toolbar/LayoutSwitch.d.ts.map +1 -1
  67. package/dist/toolbar/LayoutSwitch.js +73 -55
  68. package/dist/toolbar/LayoutSwitch.js.map +1 -1
  69. package/dist/toolbar/Toolbar.css +36 -0
  70. package/dist/toolbar/Toolbar.module.js +12 -2
  71. package/dist/toolbar/Toolbar.module.js.map +1 -1
  72. package/dist/types.d.ts +42 -0
  73. package/dist/types.d.ts.map +1 -1
  74. package/dist/values.d.ts +1 -0
  75. package/dist/values.d.ts.map +1 -1
  76. package/dist/values.js +1 -1
  77. package/dist/values.js.map +1 -1
  78. 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
- | Layouts | `table` and `cards` (`layouts`, the first is the default). On narrow lists, table rows stack and show the label of each value |
85
- | Sorting | Sortable column headers (`aria-sort`), and a select for cards and phones |
86
- | 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 |
87
- | Pagination | With `total`: the range, previous and next pages, and the page size (`perPageOptions`) |
88
- | Selection | Checkboxes, the page, then "select all N items", which selects every item matching the query, with exceptions |
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 | 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 |
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/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 and the default sort are read once.
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
@@ -1 +1 @@
1
- {"version":3,"file":"List.d.ts","sourceRoot":"","sources":["../src/List.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAW,MAAM,eAAe,CAAC;AAG1D,OAAO,EAAY,KAAK,aAAa,E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,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 and the default sort are read once.
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(15);
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
- 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;
20
+ const defaultSort = t2 === void 0 ? [] : t2;
27
21
  const intl = usePanneauIntl();
28
- let t4;
29
- if ($[2] !== defaultSort || $[3] !== perPage) {
30
- t4 = {
22
+ const { query, list } = useList({
23
+ defaults: {
31
24
  perPage,
32
- sort: defaultSort
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);
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 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, {
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: t7,
67
- total: t8
45
+ items: t3,
46
+ total: t4
68
47
  });
69
- $[10] = list;
70
- $[11] = props;
71
- $[12] = t7;
72
- $[13] = t8;
73
- $[14] = t9;
74
- } else t9 = $[14];
75
- return t9;
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","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,MAAAC,OAAapB,eAAe;CAAE,IAAAqB;CAAA,IAAAR,EAAA,OAAAJ,eAAAI,EAAA,OAAAL,SAAA;EAEhBa,KAAA;GAAAb;GAAAc,MAAiBb;EAAY;EAACI,EAAA,KAAAJ;EAAAI,EAAA,KAAAL;EAAAK,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAU;CAAA,IAAAV,EAAA,OAAAH,QAAA;EACpCa,KAAAb,WAAWQ,KAAAA,IAAX,EAAAR,OAAqC,IAArC,CAAqC;EAACG,EAAA,KAAAH;EAAAG,EAAA,KAAAU;CAAA,OAAAA,KAAAV,EAAA;CAAA,IAAAW;CAAA,IAAAX,EAAA,OAAAQ,MAAAR,EAAA,OAAAU,IAAA;EAFdC,KAAA;GAAAC,UAClBJ;GAA8B,GACpCE;EACR;EAACV,EAAA,KAAAQ;EAAAR,EAAA,KAAAU;EAAAV,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CAHD,MAAA,EAAAa,OAAAC,SAAwB5B,QAAQyB,EAG/B;CACD,MAAAI,SACIrB,UAAUW,KAAAA,IACJf,eAAeI,OAAOmB,OAAO;EAAAG,SAAWZ,MAAKY;EAAQC,QAAUV,KAAIU;CAAQ,CACnE,IAFdZ,KAAAA;CAG2C,MAAAa,KAAAH,QAAMrB;CAAgB,MAAAyB,KAAAJ,QAAMK;CAAO,IAAAC;CAAA,IAAArB,EAAA,QAAAc,QAAAd,EAAA,QAAAI,SAAAJ,EAAA,QAAAkB,MAAAlB,EAAA,QAAAmB,IAAA;EAA3EE,KAAA,oBAAC,UAAD;GAAS,GAAKjB;GAAaU;GAAa,OAAAI;GAAsB,OAAAC;EAAa,CAAA;EAAInB,EAAA,MAAAc;EAAAd,EAAA,MAAAI;EAAAJ,EAAA,MAAAkB;EAAAlB,EAAA,MAAAmB;EAAAnB,EAAA,MAAAqB;CAAA,OAAAA,KAAArB,EAAA;CAAA,OAA/EqB;AAA+E"}
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"}
@@ -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
@@ -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;AAG1C,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAQ/D,OAAO,EACH,KAAK,WAAW,EAKnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAUnD,OAAO,KAAK,EACR,YAAY,EACZ,WAAW,EAEX,iBAAiB,EACjB,mBAAmB,EACnB,UAAU,EACV,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,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B;;;;OAIG;IACH,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;KAAE,GAAG,SAAS,CAAC;IACpF,sEAAsE;IACtE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,wEAAwE;IACxE,KAA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