@panneau/lists 5.0.0-alpha.0 → 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.
Files changed (120) hide show
  1. package/README.md +7 -3
  2. package/dist/ItemDetails.css +34 -0
  3. package/dist/ItemDetails.d.ts +18 -0
  4. package/dist/ItemDetails.d.ts.map +1 -0
  5. package/dist/ItemDetails.js +104 -0
  6. package/dist/ItemDetails.js.map +1 -0
  7. package/dist/ItemDetails.module.js +16 -0
  8. package/dist/ItemDetails.module.js.map +1 -0
  9. package/dist/List.d.ts +2 -2
  10. package/dist/List.js +54 -12
  11. package/dist/List.js.map +1 -1
  12. package/dist/ListSkeleton.d.ts +17 -0
  13. package/dist/ListSkeleton.d.ts.map +1 -0
  14. package/dist/ListSkeleton.js +111 -0
  15. package/dist/ListSkeleton.js.map +1 -0
  16. package/dist/ListView.css +16 -16
  17. package/dist/ListView.d.ts +40 -5
  18. package/dist/ListView.d.ts.map +1 -1
  19. package/dist/ListView.js +547 -211
  20. package/dist/ListView.js.map +1 -1
  21. package/dist/ListView.module.js +10 -10
  22. package/dist/actions/ActionButton.d.ts +4 -1
  23. package/dist/actions/ActionButton.d.ts.map +1 -1
  24. package/dist/actions/ActionButton.js +91 -23
  25. package/dist/actions/ActionButton.js.map +1 -1
  26. package/dist/actions/Actions.css +9 -9
  27. package/dist/actions/Actions.module.js +6 -6
  28. package/dist/actions/ConfirmDialog.d.ts +15 -3
  29. package/dist/actions/ConfirmDialog.d.ts.map +1 -1
  30. package/dist/actions/ConfirmDialog.js +103 -89
  31. package/dist/actions/ConfirmDialog.js.map +1 -1
  32. package/dist/actions/RowActions.d.ts +8 -6
  33. package/dist/actions/RowActions.d.ts.map +1 -1
  34. package/dist/actions/RowActions.js +40 -30
  35. package/dist/actions/RowActions.js.map +1 -1
  36. package/dist/actions/actions.d.ts +5 -4
  37. package/dist/actions/actions.d.ts.map +1 -1
  38. package/dist/actions/actions.js +7 -14
  39. package/dist/actions/actions.js.map +1 -1
  40. package/dist/actions/icons.d.ts +8 -3
  41. package/dist/actions/icons.d.ts.map +1 -1
  42. package/dist/actions/icons.js +11 -7
  43. package/dist/actions/icons.js.map +1 -1
  44. package/dist/cx.js.map +1 -1
  45. package/dist/displays/Displays.css +25 -13
  46. package/dist/displays/Displays.module.js +18 -14
  47. package/dist/displays/Displays.module.js.map +1 -1
  48. package/dist/displays/displays.d.ts +18 -3
  49. package/dist/displays/displays.d.ts.map +1 -1
  50. package/dist/displays/displays.js +355 -12
  51. package/dist/displays/displays.js.map +1 -1
  52. package/dist/filters/Filters.css +34 -20
  53. package/dist/filters/Filters.d.ts +1 -1
  54. package/dist/filters/Filters.js.map +1 -1
  55. package/dist/filters/Filters.module.js +13 -9
  56. package/dist/filters/Filters.module.js.map +1 -1
  57. package/dist/filters/controls.d.ts +3 -3
  58. package/dist/filters/controls.d.ts.map +1 -1
  59. package/dist/filters/controls.js +171 -123
  60. package/dist/filters/controls.js.map +1 -1
  61. package/dist/filters/format.d.ts +1 -1
  62. package/dist/filters/format.d.ts.map +1 -1
  63. package/dist/filters/format.js +4 -1
  64. package/dist/filters/format.js.map +1 -1
  65. package/dist/index.d.ts +19 -17
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +5 -3
  68. package/dist/layouts/CardsLayout.css +22 -11
  69. package/dist/layouts/CardsLayout.d.ts +2 -2
  70. package/dist/layouts/CardsLayout.d.ts.map +1 -1
  71. package/dist/layouts/CardsLayout.js +39 -35
  72. package/dist/layouts/CardsLayout.js.map +1 -1
  73. package/dist/layouts/CardsLayout.module.js +8 -8
  74. package/dist/layouts/CardsLayout.module.js.map +1 -1
  75. package/dist/layouts/ItemTitle.d.ts +4 -2
  76. package/dist/layouts/ItemTitle.d.ts.map +1 -1
  77. package/dist/layouts/ItemTitle.js +12 -8
  78. package/dist/layouts/ItemTitle.js.map +1 -1
  79. package/dist/layouts/TableLayout.css +51 -35
  80. package/dist/layouts/TableLayout.d.ts +2 -2
  81. package/dist/layouts/TableLayout.d.ts.map +1 -1
  82. package/dist/layouts/TableLayout.js +38 -33
  83. package/dist/layouts/TableLayout.js.map +1 -1
  84. package/dist/layouts/TableLayout.module.js +14 -14
  85. package/dist/layouts/TableLayout.module.js.map +1 -1
  86. package/dist/layouts/builtIn.d.ts +1 -1
  87. package/dist/layouts/builtIn.js.map +1 -1
  88. package/dist/layouts/link.css +3 -3
  89. package/dist/layouts/link.module.js +1 -1
  90. package/dist/plugin.d.ts +1 -1
  91. package/dist/plugin.js.map +1 -1
  92. package/dist/query.d.ts +3 -3
  93. package/dist/query.d.ts.map +1 -1
  94. package/dist/query.js +7 -2
  95. package/dist/query.js.map +1 -1
  96. package/dist/selection.d.ts +1 -1
  97. package/dist/selection.js.map +1 -1
  98. package/dist/toolbar/LayoutSwitch.js.map +1 -1
  99. package/dist/toolbar/Pagination.d.ts +33 -0
  100. package/dist/toolbar/Pagination.d.ts.map +1 -1
  101. package/dist/toolbar/Pagination.js +282 -42
  102. package/dist/toolbar/Pagination.js.map +1 -1
  103. package/dist/toolbar/SearchField.js.map +1 -1
  104. package/dist/toolbar/SortSelect.d.ts +1 -1
  105. package/dist/toolbar/SortSelect.js.map +1 -1
  106. package/dist/toolbar/Toolbar.css +12 -12
  107. package/dist/toolbar/Toolbar.module.js +7 -7
  108. package/dist/types.d.ts +18 -2
  109. package/dist/types.d.ts.map +1 -1
  110. package/dist/useDraft.js.map +1 -1
  111. package/dist/useListState.js.map +1 -1
  112. package/dist/useRenderValue.d.ts +8 -0
  113. package/dist/useRenderValue.d.ts.map +1 -0
  114. package/dist/useRenderValue.js +64 -0
  115. package/dist/useRenderValue.js.map +1 -0
  116. package/dist/values.d.ts +3 -1
  117. package/dist/values.d.ts.map +1 -1
  118. package/dist/values.js +6 -2
  119. package/dist/values.js.map +1 -1
  120. package/package.json +9 -9
@@ -1,12 +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 { 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';
6
7
  export interface ListViewProps {
7
8
  /** The list state of `@panneau/core` (`useList()`): query and selection. */
8
9
  list: List;
9
- /** The items of the current page. `undefined` while they load for the first time. */
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
+ */
10
14
  items: readonly ListItem[] | undefined;
11
15
  columns: readonly ListColumn[];
12
16
  /**
@@ -14,6 +18,15 @@ export interface ListViewProps {
14
18
  * pagination and offers to select every matching item. Without it, `items` is the whole list.
15
19
  */
16
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;
17
30
  /** Shows that items are loading. Items already shown stay, dimmed. */
18
31
  isLoading?: boolean;
19
32
  /** An error while loading: an alert with a retry replaces the items. */
@@ -41,12 +54,34 @@ export interface ListViewProps {
41
54
  actions?: ListActions;
42
55
  /** Runs an action, after its confirmation. */
43
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;
63
+ /**
64
+ * Icons of actions by action id (`{ archive: Archive }`), for actions written in code. They
65
+ * win over the Lucide icon an action names (`"icon": "archive"`).
66
+ */
67
+ actionIcons?: ActionIcons;
44
68
  /** The field that titles items, for their label (`itemTitle` of the resource). */
45
69
  itemTitle?: string;
46
70
  /** The label of an item, for checkboxes and actions. Defaults to its title, then its id. */
47
71
  getItemLabel?: (item: ListItem) => string;
48
72
  /** A link to an item, on its title. */
49
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;
50
85
  /** Displays by name, over the built-in ones and those of the plugins. */
51
86
  displays?: Readonly<Record<string, DisplayEntry>>;
52
87
  /** Layouts by id, over the built-in ones and those of the plugins. */
@@ -66,5 +101,5 @@ export interface ListViewProps {
66
101
  * cards), with sorting, search, filters and their chips, pagination, selection and actions. It
67
102
  * fetches nothing: the caller gives the items of the list's query and their total.
68
103
  */
69
- 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, 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;
70
105
  //# source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