@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.
Files changed (113) hide show
  1. package/README.md +3 -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 +35 -6
  18. package/dist/ListView.d.ts.map +1 -1
  19. package/dist/ListView.js +544 -211
  20. package/dist/ListView.js.map +1 -1
  21. package/dist/ListView.module.js +10 -10
  22. package/dist/actions/ActionButton.d.ts +1 -1
  23. package/dist/actions/ActionButton.d.ts.map +1 -1
  24. package/dist/actions/ActionButton.js +90 -22
  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 +6 -7
  33. package/dist/actions/RowActions.d.ts.map +1 -1
  34. package/dist/actions/RowActions.js +59 -53
  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.js.map +1 -1
  41. package/dist/cx.js.map +1 -1
  42. package/dist/displays/Displays.css +25 -13
  43. package/dist/displays/Displays.module.js +18 -14
  44. package/dist/displays/Displays.module.js.map +1 -1
  45. package/dist/displays/displays.d.ts +18 -3
  46. package/dist/displays/displays.d.ts.map +1 -1
  47. package/dist/displays/displays.js +355 -12
  48. package/dist/displays/displays.js.map +1 -1
  49. package/dist/filters/Filters.css +34 -20
  50. package/dist/filters/Filters.d.ts +1 -1
  51. package/dist/filters/Filters.js.map +1 -1
  52. package/dist/filters/Filters.module.js +13 -9
  53. package/dist/filters/Filters.module.js.map +1 -1
  54. package/dist/filters/controls.d.ts +1 -1
  55. package/dist/filters/controls.d.ts.map +1 -1
  56. package/dist/filters/controls.js +57 -35
  57. package/dist/filters/controls.js.map +1 -1
  58. package/dist/filters/format.d.ts +1 -1
  59. package/dist/filters/format.js.map +1 -1
  60. package/dist/index.d.ts +19 -18
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +4 -3
  63. package/dist/layouts/CardsLayout.css +22 -11
  64. package/dist/layouts/CardsLayout.d.ts +2 -2
  65. package/dist/layouts/CardsLayout.d.ts.map +1 -1
  66. package/dist/layouts/CardsLayout.js +39 -35
  67. package/dist/layouts/CardsLayout.js.map +1 -1
  68. package/dist/layouts/CardsLayout.module.js +8 -8
  69. package/dist/layouts/CardsLayout.module.js.map +1 -1
  70. package/dist/layouts/ItemTitle.d.ts +3 -1
  71. package/dist/layouts/ItemTitle.d.ts.map +1 -1
  72. package/dist/layouts/ItemTitle.js +12 -8
  73. package/dist/layouts/ItemTitle.js.map +1 -1
  74. package/dist/layouts/TableLayout.css +51 -35
  75. package/dist/layouts/TableLayout.d.ts +2 -2
  76. package/dist/layouts/TableLayout.d.ts.map +1 -1
  77. package/dist/layouts/TableLayout.js +38 -33
  78. package/dist/layouts/TableLayout.js.map +1 -1
  79. package/dist/layouts/TableLayout.module.js +14 -14
  80. package/dist/layouts/TableLayout.module.js.map +1 -1
  81. package/dist/layouts/builtIn.d.ts +1 -1
  82. package/dist/layouts/builtIn.js.map +1 -1
  83. package/dist/layouts/link.css +3 -3
  84. package/dist/layouts/link.module.js +1 -1
  85. package/dist/plugin.d.ts +1 -1
  86. package/dist/plugin.js.map +1 -1
  87. package/dist/query.d.ts +1 -1
  88. package/dist/query.js.map +1 -1
  89. package/dist/selection.d.ts +1 -1
  90. package/dist/selection.js.map +1 -1
  91. package/dist/toolbar/LayoutSwitch.js.map +1 -1
  92. package/dist/toolbar/Pagination.d.ts +33 -0
  93. package/dist/toolbar/Pagination.d.ts.map +1 -1
  94. package/dist/toolbar/Pagination.js +282 -42
  95. package/dist/toolbar/Pagination.js.map +1 -1
  96. package/dist/toolbar/SearchField.js.map +1 -1
  97. package/dist/toolbar/SortSelect.d.ts +1 -1
  98. package/dist/toolbar/SortSelect.js.map +1 -1
  99. package/dist/toolbar/Toolbar.css +12 -12
  100. package/dist/toolbar/Toolbar.module.js +7 -7
  101. package/dist/types.d.ts +16 -1
  102. package/dist/types.d.ts.map +1 -1
  103. package/dist/useDraft.js.map +1 -1
  104. package/dist/useListState.js.map +1 -1
  105. package/dist/useRenderValue.d.ts +8 -0
  106. package/dist/useRenderValue.d.ts.map +1 -0
  107. package/dist/useRenderValue.js +64 -0
  108. package/dist/useRenderValue.js.map +1 -0
  109. package/dist/values.d.ts +3 -1
  110. package/dist/values.d.ts.map +1 -1
  111. package/dist/values.js +6 -2
  112. package/dist/values.js.map +1 -1
  113. package/package.json +9 -9
@@ -1,25 +1,25 @@
1
- .panneau-scroller-dntHlH {
1
+ .panneau-table-layout-scroller {
2
2
  overflow-x: auto;
3
3
  border: var(--panneau-border-width) solid var(--panneau-color-border);
4
4
  border-radius: var(--panneau-radius-lg);
5
5
  background-color: var(--panneau-color-surface);
6
6
  }
7
7
 
8
- .panneau-table-adJh-G {
8
+ .panneau-table-layout-table {
9
9
  width: 100%;
10
10
  border-collapse: collapse;
11
11
  font-size: var(--panneau-font-size-md);
12
12
  }
13
13
 
14
- .panneau-table-adJh-G th,
15
- .panneau-table-adJh-G td {
16
- padding: var(--panneau-space-2) var(--panneau-space-3);
14
+ .panneau-table-layout-table th,
15
+ .panneau-table-layout-table td {
16
+ padding: var(--panneau-row-padding-y) var(--panneau-space-3);
17
17
  text-align: start;
18
18
  vertical-align: middle;
19
19
  border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);
20
20
  }
21
21
 
22
- .panneau-table-adJh-G th {
22
+ .panneau-table-layout-table th {
23
23
  font-size: var(--panneau-font-size-sm);
24
24
  font-weight: var(--panneau-font-weight-medium);
25
25
  color: var(--panneau-color-text-muted);
@@ -27,33 +27,48 @@
27
27
  background-color: var(--panneau-color-surface-sunken);
28
28
  }
29
29
 
30
- .panneau-table-adJh-G tbody tr:last-child td {
30
+ /* The title stays readable in a narrow list, such as next to an item's details: the table
31
+ * scrolls instead. */
32
+ .panneau-table-layout-table td.panneau-table-layout-title {
33
+ min-width: 12rem;
34
+ }
35
+
36
+ .panneau-table-layout-table tbody tr:last-child td {
31
37
  border-bottom: 0;
32
38
  }
33
39
 
34
- .panneau-table-adJh-G tbody tr[data-selected] {
40
+ .panneau-table-layout-table tbody tr[data-selected] {
35
41
  background-color: var(--panneau-color-accent-subtle);
36
42
  }
37
43
 
38
- .panneau-center-Fx-12L {
44
+ /* The item shown next to the list: a bar on its first cell. */
45
+ .panneau-table-layout-table tbody tr[data-current] td:first-child {
46
+ box-shadow: inset 3px 0 0 var(--panneau-color-accent);
47
+ }
48
+
49
+ .panneau-table-layout-table tbody tr[data-current] {
50
+ background-color: var(--panneau-color-hover);
51
+ }
52
+
53
+ .panneau-table-layout-center {
39
54
  text-align: center !important;
40
55
  }
41
56
 
42
- .panneau-end-Jr3hRc {
57
+ .panneau-table-layout-end {
43
58
  text-align: end !important;
44
59
  }
45
60
 
46
- .panneau-check-E5-IqZ {
61
+ .panneau-table-layout-check {
47
62
  width: 1px;
48
63
  }
49
64
 
50
- .panneau-actionsCell-dzoCuU {
65
+ .panneau-table-layout-actions-cell {
51
66
  width: 1px;
52
67
  text-align: end !important;
53
68
  white-space: nowrap;
54
69
  }
55
70
 
56
- .panneau-sort-t4x1tD {
71
+ .panneau-table-layout-sort {
57
72
  display: inline-flex;
58
73
  align-items: center;
59
74
  gap: var(--panneau-space-1);
@@ -67,29 +82,29 @@
67
82
  cursor: pointer;
68
83
  }
69
84
 
70
- .panneau-sort-t4x1tD:hover {
85
+ .panneau-table-layout-sort:hover {
71
86
  color: var(--panneau-color-text);
72
87
  background-color: var(--panneau-color-hover);
73
88
  }
74
89
 
75
- .panneau-sort-t4x1tD:focus-visible {
90
+ .panneau-table-layout-sort:focus-visible {
76
91
  outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
77
92
  outline-offset: 1px;
78
93
  }
79
94
 
80
- .panneau-sortIcon-5pp-ve {
95
+ .panneau-table-layout-sort-icon {
81
96
  opacity: 0.5;
82
97
  }
83
98
 
84
- .panneau-sorted-a6Fwul .panneau-sortIcon-5pp-ve {
99
+ .panneau-table-layout-sorted .panneau-table-layout-sort-icon {
85
100
  opacity: 1;
86
101
  }
87
102
 
88
- .panneau-cellLabel-tiliX5 {
103
+ .panneau-table-layout-cell-label {
89
104
  display: none;
90
105
  }
91
106
 
92
- .panneau-visuallyHidden--8qvnp {
107
+ .panneau-table-layout-visually-hidden {
93
108
  position: absolute;
94
109
  width: 1px;
95
110
  height: 1px;
@@ -100,30 +115,30 @@
100
115
 
101
116
  /* Narrow lists (phones): each row is a block, with the label of each value next to it. */
102
117
  @container panneau-list (max-width: 40rem) {
103
- .panneau-scroller-dntHlH {
118
+ .panneau-table-layout-scroller {
104
119
  overflow: visible;
105
120
  background: none;
106
121
  border: 0;
107
122
  }
108
123
 
109
124
  /* The labels of the cells replace the headers, and the list's sort select their buttons. */
110
- .panneau-table-adJh-G thead {
125
+ .panneau-table-layout-table thead {
111
126
  display: none;
112
127
  }
113
128
 
114
- .panneau-table-adJh-G,
115
- .panneau-table-adJh-G tbody,
116
- .panneau-table-adJh-G tr,
117
- .panneau-table-adJh-G td {
129
+ .panneau-table-layout-table,
130
+ .panneau-table-layout-table tbody,
131
+ .panneau-table-layout-table tr,
132
+ .panneau-table-layout-table td {
118
133
  display: block;
119
134
  }
120
135
 
121
- .panneau-table-adJh-G tbody {
136
+ .panneau-table-layout-table tbody {
122
137
  display: grid;
123
138
  gap: var(--panneau-space-2);
124
139
  }
125
140
 
126
- .panneau-table-adJh-G tr {
141
+ .panneau-table-layout-table tr {
127
142
  position: relative;
128
143
  padding: var(--panneau-space-2) 0;
129
144
  background-color: var(--panneau-color-surface);
@@ -131,7 +146,7 @@
131
146
  border-radius: var(--panneau-radius-lg);
132
147
  }
133
148
 
134
- .panneau-table-adJh-G td {
149
+ .panneau-table-layout-table td {
135
150
  display: grid;
136
151
  grid-template-columns: minmax(5rem, 35%) 1fr;
137
152
  gap: var(--panneau-space-2);
@@ -140,36 +155,37 @@
140
155
  border: 0;
141
156
  }
142
157
 
143
- .panneau-table-adJh-G td.panneau-check-E5-IqZ,
144
- .panneau-table-adJh-G td.panneau-actionsCell-dzoCuU {
158
+ .panneau-table-layout-table td.panneau-table-layout-check,
159
+ .panneau-table-layout-table td.panneau-table-layout-actions-cell {
145
160
  display: flex;
146
161
  width: auto;
147
162
  }
148
163
 
149
- .panneau-table-adJh-G td.panneau-check-E5-IqZ {
164
+ .panneau-table-layout-table td.panneau-table-layout-check {
150
165
  position: absolute;
151
166
  top: var(--panneau-space-2);
152
167
  inset-inline-end: var(--panneau-space-2);
153
168
  padding: 0;
154
169
  }
155
170
 
156
- .panneau-table-adJh-G td.panneau-actionsCell-dzoCuU {
171
+ .panneau-table-layout-table td.panneau-table-layout-actions-cell {
157
172
  justify-content: flex-start;
158
173
  flex-wrap: wrap;
159
174
  padding-top: var(--panneau-space-2);
160
175
  }
161
176
 
162
- .panneau-table-adJh-G td.panneau-title-KEAnyJ {
177
+ .panneau-table-layout-table td.panneau-table-layout-title {
163
178
  display: block;
179
+ min-width: 0;
164
180
  padding-inline-end: var(--panneau-space-10);
165
181
  font-weight: var(--panneau-font-weight-medium);
166
182
  }
167
183
 
168
- .panneau-table-adJh-G td.panneau-title-KEAnyJ .panneau-cellLabel-tiliX5 {
184
+ .panneau-table-layout-table td.panneau-table-layout-title .panneau-table-layout-cell-label {
169
185
  display: none;
170
186
  }
171
187
 
172
- .panneau-cellLabel-tiliX5 {
188
+ .panneau-table-layout-cell-label {
173
189
  display: block;
174
190
  font-size: var(--panneau-font-size-sm);
175
191
  color: var(--panneau-color-text-muted);
@@ -1,9 +1,9 @@
1
- import type { ListColumn, ListLayoutProps } from '../types';
1
+ import type { ListColumn, ListLayoutProps } from '../types.js';
2
2
  /** The sort direction of a column, from the first `sort` value. */
3
3
  export declare function getSortDirection(sort: readonly string[], column: ListColumn): 'ascending' | 'descending' | null;
4
4
  /**
5
5
  * Items as a table, with sortable column headers. On narrow lists (phones), each row turns into a
6
6
  * block that shows the label of each value.
7
7
  */
8
- export declare function TableLayout({ items, columns, renderValue, getItemLabel, getItemHref, selectable, isSelected, onToggle, renderActions, sort, onSort, label, pageSelection, }: ListLayoutProps): import("react").JSX.Element;
8
+ export declare function TableLayout({ items, columns, renderValue, getItemLabel, getItemHref, isCurrent, selectable, isSelected, onToggle, renderActions, sort, onSort, label, pageSelection, }: ListLayoutProps): import("react").JSX.Element;
9
9
  //# sourceMappingURL=TableLayout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableLayout.d.ts","sourceRoot":"","sources":["../../src/layouts/TableLayout.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI5D,mEAAmE;AACnE,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,MAAM,EAAE,UAAU,GACnB,WAAW,GAAG,YAAY,GAAG,IAAI,CAMnC;AASD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,UAAU,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,MAAM,EACN,KAAK,EACL,aAAa,GAChB,EAAE,eAAe,+BAiHjB"}
1
+ {"version":3,"file":"TableLayout.d.ts","sourceRoot":"","sources":["../../src/layouts/TableLayout.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAI5D,mEAAmE;AACnE,wBAAgB,gBAAgB,CAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,MAAM,EAAE,UAAU,GACnB,WAAW,GAAG,YAAY,GAAG,IAAI,CAMnC;AASD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,MAAM,EACN,KAAK,EACL,aAAa,GAChB,EAAE,eAAe,+BAsHjB"}
@@ -22,8 +22,8 @@ function alignClass(column) {
22
22
  * block that shows the label of each value.
23
23
  */
24
24
  function TableLayout(t0) {
25
- const $ = c(52);
26
- const { items, columns, renderValue, getItemLabel, getItemHref, selectable, isSelected, onToggle, renderActions, sort, onSort, label, pageSelection } = t0;
25
+ const $ = c(54);
26
+ const { items, columns, renderValue, getItemLabel, getItemHref, isCurrent, selectable, isSelected, onToggle, renderActions, sort, onSort, label, pageSelection } = t0;
27
27
  const intl = usePanneauIntl();
28
28
  let actions;
29
29
  let t1;
@@ -116,14 +116,16 @@ function TableLayout(t0) {
116
116
  $[22] = t5;
117
117
  } else t5 = $[22];
118
118
  let t6;
119
- if ($[23] !== actions || $[24] !== columns || $[25] !== getItemHref || $[26] !== getItemLabel || $[27] !== hasActions || $[28] !== intl || $[29] !== isSelected || $[30] !== items || $[31] !== onToggle || $[32] !== renderValue || $[33] !== selectable) {
119
+ if ($[23] !== actions || $[24] !== columns || $[25] !== getItemHref || $[26] !== getItemLabel || $[27] !== hasActions || $[28] !== intl || $[29] !== isCurrent || $[30] !== isSelected || $[31] !== items || $[32] !== onToggle || $[33] !== renderValue || $[34] !== selectable) {
120
120
  let t7;
121
- if ($[35] !== actions || $[36] !== columns || $[37] !== getItemHref || $[38] !== getItemLabel || $[39] !== hasActions || $[40] !== intl || $[41] !== isSelected || $[42] !== onToggle || $[43] !== renderValue || $[44] !== selectable) {
121
+ if ($[36] !== actions || $[37] !== columns || $[38] !== getItemHref || $[39] !== getItemLabel || $[40] !== hasActions || $[41] !== intl || $[42] !== isCurrent || $[43] !== isSelected || $[44] !== onToggle || $[45] !== renderValue || $[46] !== selectable) {
122
122
  t7 = (item_0, row) => {
123
123
  const selected = selectable && isSelected(item_0);
124
124
  const href = getItemHref?.(item_0) ?? null;
125
+ const current = isCurrent?.(item_0) ?? false;
125
126
  return /* @__PURE__ */ jsxs("tr", {
126
127
  "data-selected": selected || void 0,
128
+ "data-current": current || void 0,
127
129
  children: [
128
130
  selectable ? /* @__PURE__ */ jsx("td", {
129
131
  className: TableLayout_module_default.check,
@@ -140,6 +142,7 @@ function TableLayout(t0) {
140
142
  children: column_0.label ?? column_0.id
141
143
  }), /* @__PURE__ */ jsx("span", { children: index === 0 ? /* @__PURE__ */ jsx(ItemTitle, {
142
144
  href,
145
+ current,
143
146
  children: renderValue(item_0, column_0)
144
147
  }) : renderValue(item_0, column_0) })]
145
148
  }, column_0.id)),
@@ -150,18 +153,19 @@ function TableLayout(t0) {
150
153
  ]
151
154
  }, item_0.id);
152
155
  };
153
- $[35] = actions;
154
- $[36] = columns;
155
- $[37] = getItemHref;
156
- $[38] = getItemLabel;
157
- $[39] = hasActions;
158
- $[40] = intl;
159
- $[41] = isSelected;
160
- $[42] = onToggle;
161
- $[43] = renderValue;
162
- $[44] = selectable;
163
- $[45] = t7;
164
- } else t7 = $[45];
156
+ $[36] = actions;
157
+ $[37] = columns;
158
+ $[38] = getItemHref;
159
+ $[39] = getItemLabel;
160
+ $[40] = hasActions;
161
+ $[41] = intl;
162
+ $[42] = isCurrent;
163
+ $[43] = isSelected;
164
+ $[44] = onToggle;
165
+ $[45] = renderValue;
166
+ $[46] = selectable;
167
+ $[47] = t7;
168
+ } else t7 = $[47];
165
169
  t6 = items.map(t7);
166
170
  $[23] = actions;
167
171
  $[24] = columns;
@@ -169,21 +173,22 @@ function TableLayout(t0) {
169
173
  $[26] = getItemLabel;
170
174
  $[27] = hasActions;
171
175
  $[28] = intl;
172
- $[29] = isSelected;
173
- $[30] = items;
174
- $[31] = onToggle;
175
- $[32] = renderValue;
176
- $[33] = selectable;
177
- $[34] = t6;
178
- } else t6 = $[34];
176
+ $[29] = isCurrent;
177
+ $[30] = isSelected;
178
+ $[31] = items;
179
+ $[32] = onToggle;
180
+ $[33] = renderValue;
181
+ $[34] = selectable;
182
+ $[35] = t6;
183
+ } else t6 = $[35];
179
184
  let t7;
180
- if ($[46] !== t6) {
185
+ if ($[48] !== t6) {
181
186
  t7 = /* @__PURE__ */ jsx("tbody", { children: t6 });
182
- $[46] = t6;
183
- $[47] = t7;
184
- } else t7 = $[47];
187
+ $[48] = t6;
188
+ $[49] = t7;
189
+ } else t7 = $[49];
185
190
  let t8;
186
- if ($[48] !== label || $[49] !== t5 || $[50] !== t7) {
191
+ if ($[50] !== label || $[51] !== t5 || $[52] !== t7) {
187
192
  t8 = /* @__PURE__ */ jsx("div", {
188
193
  className: TableLayout_module_default.scroller,
189
194
  children: /* @__PURE__ */ jsxs("table", {
@@ -192,11 +197,11 @@ function TableLayout(t0) {
192
197
  children: [t5, t7]
193
198
  })
194
199
  });
195
- $[48] = label;
196
- $[49] = t5;
197
- $[50] = t7;
198
- $[51] = t8;
199
- } else t8 = $[51];
200
+ $[50] = label;
201
+ $[51] = t5;
202
+ $[52] = t7;
203
+ $[53] = t8;
204
+ } else t8 = $[53];
200
205
  return t8;
201
206
  }
202
207
  function _temp(node) {
@@ -1 +1 @@
1
- {"version":3,"file":"TableLayout.js","names":["pageSelection","item","selected","column","href","label","styles","_c"],"sources":["../../src/layouts/TableLayout.tsx"],"sourcesContent":["import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react';\n\nimport { Checkbox, Icon, usePanneauIntl } from '@panneau/ui';\n\nimport { cx } from '../cx';\nimport { messages } from '../messages';\nimport type { ListColumn, ListLayoutProps } from '../types';\nimport { ItemTitle } from './ItemTitle';\nimport styles from './TableLayout.module.css';\n\n/** The sort direction of a column, from the first `sort` value. */\nexport function getSortDirection(\n sort: readonly string[],\n column: ListColumn,\n): 'ascending' | 'descending' | null {\n const first = sort[0];\n if (first === column.id) {\n return 'ascending';\n }\n return first === `-${column.id}` ? 'descending' : null;\n}\n\nfunction alignClass(column: ListColumn): string | undefined {\n if (column.align === 'center') {\n return styles.center;\n }\n return column.align === 'end' ? styles.end : undefined;\n}\n\n/**\n * Items as a table, with sortable column headers. On narrow lists (phones), each row turns into a\n * block that shows the label of each value.\n */\nexport function TableLayout({\n items,\n columns,\n renderValue,\n getItemLabel,\n getItemHref,\n selectable,\n isSelected,\n onToggle,\n renderActions,\n sort,\n onSort,\n label,\n pageSelection,\n}: ListLayoutProps) {\n const intl = usePanneauIntl();\n const actions = items.map((item) => renderActions(item));\n const hasActions = actions.some((node) => node !== null);\n return (\n <div className={styles.scroller}>\n <table className={styles.table} aria-label={label}>\n <thead>\n <tr>\n {selectable ? <th className={styles.check}>{pageSelection}</th> : null}\n {columns.map((column) => {\n const direction = getSortDirection(sort, column);\n return (\n <th\n key={column.id}\n scope=\"col\"\n className={alignClass(column)}\n style={\n column.width !== undefined\n ? { width: column.width }\n : undefined\n }\n aria-sort={\n column.sortable === true ? (direction ?? 'none') : undefined\n }\n >\n {column.sortable === true ? (\n <button\n type=\"button\"\n className={cx(\n styles.sort,\n direction !== null && styles.sorted,\n )}\n onClick={() => onSort(column)}\n >\n {column.label ?? column.id}\n <span className={styles.sortIcon}>\n <Icon\n icon={\n direction === 'ascending'\n ? ArrowUp\n : direction === 'descending'\n ? ArrowDown\n : ArrowUpDown\n }\n size=\"sm\"\n />\n </span>\n </button>\n ) : (\n (column.label ?? column.id)\n )}\n </th>\n );\n })}\n {hasActions ? (\n <th className={styles.actionsCell}>\n <span className={styles.visuallyHidden}>\n {intl.formatMessage(messages.actions)}\n </span>\n </th>\n ) : null}\n </tr>\n </thead>\n <tbody>\n {items.map((item, row) => {\n const selected = selectable && isSelected(item);\n const href = getItemHref?.(item) ?? null;\n return (\n <tr key={item.id} data-selected={selected || undefined}>\n {selectable ? (\n <td className={styles.check}>\n <Checkbox\n aria-label={intl.formatMessage(messages.selectItem, {\n item: getItemLabel(item),\n })}\n isSelected={selected}\n onChange={() => onToggle(item)}\n />\n </td>\n ) : null}\n {columns.map((column, index) => (\n <td\n key={column.id}\n className={cx(\n alignClass(column),\n index === 0 && styles.title,\n )}\n >\n <span className={styles.cellLabel}>\n {column.label ?? column.id}\n </span>\n <span>\n {index === 0 ? (\n <ItemTitle href={href}>\n {renderValue(item, column)}\n </ItemTitle>\n ) : (\n renderValue(item, column)\n )}\n </span>\n </td>\n ))}\n {hasActions ? (\n <td className={styles.actionsCell}>{actions[row]}</td>\n ) : null}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgB,iBACZ,MACA,QACiC;CACjC,MAAM,QAAQ,KAAK;CACnB,IAAI,UAAU,OAAO,IACjB,OAAO;CAEX,OAAO,UAAU,IAAI,OAAO,OAAO,eAAe;AACtD;AAEA,SAAS,WAAW,QAAwC;CACxD,IAAI,OAAO,UAAU,UACjB,OAAOM,2BAAO;CAElB,OAAO,OAAO,UAAU,QAAQA,2BAAO,MAAM,KAAA;AACjD;;;;;AAMA,SAAO,YAAA,IAAA;CAAA,MAAA,IAAAC,EAAA,EAAA;CAAqB,MAAA,EAAA,OAAA,SAAA,aAAA,cAAA,aAAA,YA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AA;GAAA,EAAA,MAAA;GAAA,EAAA,MAAA;GAAA,EAAA,MAAA;GAAA,EAAA,MAAA;GAAA,EAAA,MAAA;EAAA,OAAA,KAAA,EAAA;EA3CA,KAAA,MAAK,IAAK,EA2CV;EAAC,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,IAAA;EA5CN,KAAA,oBAAA,SAAA,EAAA,UACK,GA4CG,CAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,QAAA,SAAA,EAAA,QAAA,MAAA,EAAA,QAAA,IAAA;EAxGhB,KAAA,oBAAA,OAAA;GAAgB,WAAAK,2BAAM;GAClB,UAAA,qBAAA,SAAA;IAAkB,WAAAA,2BAAM;IAAoBD,cAAA;IAA5C,UAAA,CACI,IAyDA,EA8CI;;EACN,CAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;EAAA,EAAA,MAAA;CAAA,OAAA,KAAA,EAAA;CAAA,OA1GN;AA0GM;AA7HP,SAAA,MAAA,MAAA;CAAA,OAiBuC,SAAS;AAAI"}
1
+ {"version":3,"file":"TableLayout.js","names":["ArrowDown","ArrowUp","ArrowUpDown","Checkbox","Icon","usePanneauIntl","cx","messages","ListColumn","ListLayoutProps","ItemTitle","styles","getSortDirection","sort","column","first","id","alignClass","align","center","end","undefined","TableLayout","t0","$","_c","items","columns","renderValue","getItemLabel","getItemHref","isCurrent","selectable","isSelected","onToggle","renderActions","onSort","label","pageSelection","intl","actions","t1","t2","item","map","some","_temp","hasActions","check","t3","t4","direction","width","sortable","sorted","sortIcon","actionsCell","visuallyHidden","formatMessage","t5","t6","t7","item_0","row","selected","href","current","selectItem","column_0","index","title","cellLabel","t8","scroller","table","node","styles","_c"],"sources":["../../src/layouts/TableLayout.tsx"],"sourcesContent":["import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react';\n\nimport { Checkbox, Icon, usePanneauIntl } from '@panneau/ui';\n\nimport { cx } from '../cx';\nimport { messages } from '../messages';\nimport type { ListColumn, ListLayoutProps } from '../types';\nimport { ItemTitle } from './ItemTitle';\nimport styles from './TableLayout.module.css';\n\n/** The sort direction of a column, from the first `sort` value. */\nexport function getSortDirection(\n sort: readonly string[],\n column: ListColumn,\n): 'ascending' | 'descending' | null {\n const first = sort[0];\n if (first === column.id) {\n return 'ascending';\n }\n return first === `-${column.id}` ? 'descending' : null;\n}\n\nfunction alignClass(column: ListColumn): string | undefined {\n if (column.align === 'center') {\n return styles.center;\n }\n return column.align === 'end' ? styles.end : undefined;\n}\n\n/**\n * Items as a table, with sortable column headers. On narrow lists (phones), each row turns into a\n * block that shows the label of each value.\n */\nexport function TableLayout({\n items,\n columns,\n renderValue,\n getItemLabel,\n getItemHref,\n isCurrent,\n selectable,\n isSelected,\n onToggle,\n renderActions,\n sort,\n onSort,\n label,\n pageSelection,\n}: ListLayoutProps) {\n const intl = usePanneauIntl();\n const actions = items.map((item) => renderActions(item));\n const hasActions = actions.some((node) => node !== null);\n return (\n <div className={styles.scroller}>\n <table className={styles.table} aria-label={label}>\n <thead>\n <tr>\n {selectable ? <th className={styles.check}>{pageSelection}</th> : null}\n {columns.map((column) => {\n const direction = getSortDirection(sort, column);\n return (\n <th\n key={column.id}\n scope=\"col\"\n className={alignClass(column)}\n style={\n column.width !== undefined\n ? { width: column.width }\n : undefined\n }\n aria-sort={\n column.sortable === true ? (direction ?? 'none') : undefined\n }\n >\n {column.sortable === true ? (\n <button\n type=\"button\"\n className={cx(\n styles.sort,\n direction !== null && styles.sorted,\n )}\n onClick={() => onSort(column)}\n >\n {column.label ?? column.id}\n <span className={styles.sortIcon}>\n <Icon\n icon={\n direction === 'ascending'\n ? ArrowUp\n : direction === 'descending'\n ? ArrowDown\n : ArrowUpDown\n }\n size=\"sm\"\n />\n </span>\n </button>\n ) : (\n (column.label ?? column.id)\n )}\n </th>\n );\n })}\n {hasActions ? (\n <th className={styles.actionsCell}>\n <span className={styles.visuallyHidden}>\n {intl.formatMessage(messages.actions)}\n </span>\n </th>\n ) : null}\n </tr>\n </thead>\n <tbody>\n {items.map((item, row) => {\n const selected = selectable && isSelected(item);\n const href = getItemHref?.(item) ?? null;\n const current = isCurrent?.(item) ?? false;\n return (\n <tr\n key={item.id}\n data-selected={selected || undefined}\n data-current={current || undefined}\n >\n {selectable ? (\n <td className={styles.check}>\n <Checkbox\n aria-label={intl.formatMessage(messages.selectItem, {\n item: getItemLabel(item),\n })}\n isSelected={selected}\n onChange={() => onToggle(item)}\n />\n </td>\n ) : null}\n {columns.map((column, index) => (\n <td\n key={column.id}\n className={cx(\n alignClass(column),\n index === 0 && styles.title,\n )}\n >\n <span className={styles.cellLabel}>\n {column.label ?? column.id}\n </span>\n <span>\n {index === 0 ? (\n <ItemTitle href={href} current={current}>\n {renderValue(item, column)}\n </ItemTitle>\n ) : (\n renderValue(item, column)\n )}\n </span>\n </td>\n ))}\n {hasActions ? (\n <td className={styles.actionsCell}>{actions[row]}</td>\n ) : null}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAWA,SAAgBY,iBACZC,MACAC,QACiC;CACjC,MAAMC,QAAQF,KAAK;CACnB,IAAIE,UAAUD,OAAOE,IACjB,OAAO;CAEX,OAAOD,UAAU,IAAID,OAAOE,OAAO,eAAe;AACtD;AAEA,SAASC,WAAWH,QAAwC;CACxD,IAAIA,OAAOI,UAAU,UACjB,OAAOP,2BAAOQ;CAElB,OAAOL,OAAOI,UAAU,QAAQP,2BAAOS,MAAMC,KAAAA;AACjD;;;;;AA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AA,MAAAoC;CAAA,OAAAA,KAAApC,EAAA;CAAA,IAAAqC;CAAA,IAAArC,EAAA,QAAAoC,IAAA;EAjDNC,KAAA,oBAAA,SAAA,EAAA,UACKD,GAiDG,CAAA;EAAApC,EAAA,MAAAoC;EAAApC,EAAA,MAAAqC;CAAA,OAAAA,KAAArC,EAAA;CAAA,IAAAgD;CAAA,IAAAhD,EAAA,QAAAa,SAAAb,EAAA,QAAAmC,MAAAnC,EAAA,QAAAqC,IAAA;EA7GhBW,KAAA,oBAAA,OAAA;GAAgB,WAAA7D,2BAAM8D;GAClB,UAAA,qBAAA,SAAA;IAAkB,WAAA9D,2BAAM+D;IAAoBrC,cAAAA;IAA5C,UAAA,CACIsB,IAyDAE,EAmDI;;EACN,CAAA;EAAArC,EAAA,MAAAa;EAAAb,EAAA,MAAAmC;EAAAnC,EAAA,MAAAqC;EAAArC,EAAA,MAAAgD;CAAA,OAAAA,KAAAhD,EAAA;CAAA,OA/GNgD;AA+GM;AAnIP,SAAA1B,MAAA6B,MAAA;CAAA,OAkBuCA,SAAS;AAAI"}
@@ -1,20 +1,21 @@
1
1
  import "./TableLayout.css";
2
2
  //#region src/layouts/TableLayout.module.css
3
- var scroller = "panneau-scroller-dntHlH";
4
- var table = "panneau-table-adJh-G";
5
- var center = "panneau-center-Fx-12L";
6
- var end = "panneau-end-Jr3hRc";
7
- var check = "panneau-check-E5-IqZ";
8
- var actionsCell = "panneau-actionsCell-dzoCuU";
9
- var sort = "panneau-sort-t4x1tD";
10
- var sortIcon = "panneau-sortIcon-5pp-ve";
11
- var sorted = "panneau-sorted-a6Fwul";
12
- var cellLabel = "panneau-cellLabel-tiliX5";
13
- var visuallyHidden = "panneau-visuallyHidden--8qvnp";
14
- var title = "panneau-title-KEAnyJ";
3
+ var scroller = "panneau-table-layout-scroller";
4
+ var table = "panneau-table-layout-table";
5
+ var title = "panneau-table-layout-title";
6
+ var center = "panneau-table-layout-center";
7
+ var end = "panneau-table-layout-end";
8
+ var check = "panneau-table-layout-check";
9
+ var actionsCell = "panneau-table-layout-actions-cell";
10
+ var sort = "panneau-table-layout-sort";
11
+ var sortIcon = "panneau-table-layout-sort-icon";
12
+ var sorted = "panneau-table-layout-sorted";
13
+ var cellLabel = "panneau-table-layout-cell-label";
14
+ var visuallyHidden = "panneau-table-layout-visually-hidden";
15
15
  var TableLayout_module_default = {
16
16
  scroller,
17
17
  table,
18
+ title,
18
19
  center,
19
20
  end,
20
21
  check,
@@ -23,8 +24,7 @@ var TableLayout_module_default = {
23
24
  sortIcon,
24
25
  sorted,
25
26
  cellLabel,
26
- visuallyHidden,
27
- title
27
+ visuallyHidden
28
28
  };
29
29
  //#endregion
30
30
  export { actionsCell, cellLabel, center, check, TableLayout_module_default as default, end, scroller, sort, sortIcon, sorted, table, title, visuallyHidden };
@@ -1 +1 @@
1
- {"version":3,"file":"TableLayout.module.js","names":[],"sources":["../../src/layouts/TableLayout.module.css"],"sourcesContent":[".scroller {\n overflow-x: auto;\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n background-color: var(--panneau-color-surface);\n}\n\n.table {\n width: 100%;\n border-collapse: collapse;\n font-size: var(--panneau-font-size-md);\n}\n\n.table th,\n.table td {\n padding: var(--panneau-space-2) var(--panneau-space-3);\n text-align: start;\n vertical-align: middle;\n border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.table th {\n font-size: var(--panneau-font-size-sm);\n font-weight: var(--panneau-font-weight-medium);\n color: var(--panneau-color-text-muted);\n white-space: nowrap;\n background-color: var(--panneau-color-surface-sunken);\n}\n\n.table tbody tr:last-child td {\n border-bottom: 0;\n}\n\n.table tbody tr[data-selected] {\n background-color: var(--panneau-color-accent-subtle);\n}\n\n.center {\n text-align: center !important;\n}\n\n.end {\n text-align: end !important;\n}\n\n.check {\n width: 1px;\n}\n\n.actionsCell {\n width: 1px;\n text-align: end !important;\n white-space: nowrap;\n}\n\n.sort {\n display: inline-flex;\n align-items: center;\n gap: var(--panneau-space-1);\n margin: calc(-1 * var(--panneau-space-1)) calc(-1 * var(--panneau-space-2));\n padding: var(--panneau-space-1) var(--panneau-space-2);\n font: inherit;\n color: inherit;\n background: none;\n border: 0;\n border-radius: var(--panneau-radius-sm);\n cursor: pointer;\n}\n\n.sort:hover {\n color: var(--panneau-color-text);\n background-color: var(--panneau-color-hover);\n}\n\n.sort:focus-visible {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 1px;\n}\n\n.sortIcon {\n opacity: 0.5;\n}\n\n.sorted .sortIcon {\n opacity: 1;\n}\n\n.cellLabel {\n display: none;\n}\n\n.visuallyHidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n}\n\n/* Narrow lists (phones): each row is a block, with the label of each value next to it. */\n@container panneau-list (max-width: 40rem) {\n .scroller {\n overflow: visible;\n background: none;\n border: 0;\n }\n\n /* The labels of the cells replace the headers, and the list's sort select their buttons. */\n .table thead {\n display: none;\n }\n\n .table,\n .table tbody,\n .table tr,\n .table td {\n display: block;\n }\n\n .table tbody {\n display: grid;\n gap: var(--panneau-space-2);\n }\n\n .table tr {\n position: relative;\n padding: var(--panneau-space-2) 0;\n background-color: var(--panneau-color-surface);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n }\n\n .table td {\n display: grid;\n grid-template-columns: minmax(5rem, 35%) 1fr;\n gap: var(--panneau-space-2);\n padding: var(--panneau-space-1) var(--panneau-space-3);\n text-align: start !important;\n border: 0;\n }\n\n .table td.check,\n .table td.actionsCell {\n display: flex;\n width: auto;\n }\n\n .table td.check {\n position: absolute;\n top: var(--panneau-space-2);\n inset-inline-end: var(--panneau-space-2);\n padding: 0;\n }\n\n .table td.actionsCell {\n justify-content: flex-start;\n flex-wrap: wrap;\n padding-top: var(--panneau-space-2);\n }\n\n .table td.title {\n display: block;\n padding-inline-end: var(--panneau-space-10);\n font-weight: var(--panneau-font-weight-medium);\n }\n\n .table td.title .cellLabel {\n display: none;\n }\n\n .cellLabel {\n display: block;\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n }\n}\n"],"mappings":""}
1
+ {"version":3,"file":"TableLayout.module.js","names":[],"sources":["../../src/layouts/TableLayout.module.css"],"sourcesContent":[".scroller {\n overflow-x: auto;\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n background-color: var(--panneau-color-surface);\n}\n\n.table {\n width: 100%;\n border-collapse: collapse;\n font-size: var(--panneau-font-size-md);\n}\n\n.table th,\n.table td {\n padding: var(--panneau-row-padding-y) var(--panneau-space-3);\n text-align: start;\n vertical-align: middle;\n border-bottom: var(--panneau-border-width) solid var(--panneau-color-border);\n}\n\n.table th {\n font-size: var(--panneau-font-size-sm);\n font-weight: var(--panneau-font-weight-medium);\n color: var(--panneau-color-text-muted);\n white-space: nowrap;\n background-color: var(--panneau-color-surface-sunken);\n}\n\n/* The title stays readable in a narrow list, such as next to an item's details: the table\n * scrolls instead. */\n.table td.title {\n min-width: 12rem;\n}\n\n.table tbody tr:last-child td {\n border-bottom: 0;\n}\n\n.table tbody tr[data-selected] {\n background-color: var(--panneau-color-accent-subtle);\n}\n\n/* The item shown next to the list: a bar on its first cell. */\n.table tbody tr[data-current] td:first-child {\n box-shadow: inset 3px 0 0 var(--panneau-color-accent);\n}\n\n.table tbody tr[data-current] {\n background-color: var(--panneau-color-hover);\n}\n\n.center {\n text-align: center !important;\n}\n\n.end {\n text-align: end !important;\n}\n\n.check {\n width: 1px;\n}\n\n.actionsCell {\n width: 1px;\n text-align: end !important;\n white-space: nowrap;\n}\n\n.sort {\n display: inline-flex;\n align-items: center;\n gap: var(--panneau-space-1);\n margin: calc(-1 * var(--panneau-space-1)) calc(-1 * var(--panneau-space-2));\n padding: var(--panneau-space-1) var(--panneau-space-2);\n font: inherit;\n color: inherit;\n background: none;\n border: 0;\n border-radius: var(--panneau-radius-sm);\n cursor: pointer;\n}\n\n.sort:hover {\n color: var(--panneau-color-text);\n background-color: var(--panneau-color-hover);\n}\n\n.sort:focus-visible {\n outline: var(--panneau-focus-width) solid var(--panneau-color-focus);\n outline-offset: 1px;\n}\n\n.sortIcon {\n opacity: 0.5;\n}\n\n.sorted .sortIcon {\n opacity: 1;\n}\n\n.cellLabel {\n display: none;\n}\n\n.visuallyHidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n}\n\n/* Narrow lists (phones): each row is a block, with the label of each value next to it. */\n@container panneau-list (max-width: 40rem) {\n .scroller {\n overflow: visible;\n background: none;\n border: 0;\n }\n\n /* The labels of the cells replace the headers, and the list's sort select their buttons. */\n .table thead {\n display: none;\n }\n\n .table,\n .table tbody,\n .table tr,\n .table td {\n display: block;\n }\n\n .table tbody {\n display: grid;\n gap: var(--panneau-space-2);\n }\n\n .table tr {\n position: relative;\n padding: var(--panneau-space-2) 0;\n background-color: var(--panneau-color-surface);\n border: var(--panneau-border-width) solid var(--panneau-color-border);\n border-radius: var(--panneau-radius-lg);\n }\n\n .table td {\n display: grid;\n grid-template-columns: minmax(5rem, 35%) 1fr;\n gap: var(--panneau-space-2);\n padding: var(--panneau-space-1) var(--panneau-space-3);\n text-align: start !important;\n border: 0;\n }\n\n .table td.check,\n .table td.actionsCell {\n display: flex;\n width: auto;\n }\n\n .table td.check {\n position: absolute;\n top: var(--panneau-space-2);\n inset-inline-end: var(--panneau-space-2);\n padding: 0;\n }\n\n .table td.actionsCell {\n justify-content: flex-start;\n flex-wrap: wrap;\n padding-top: var(--panneau-space-2);\n }\n\n .table td.title {\n display: block;\n min-width: 0;\n padding-inline-end: var(--panneau-space-10);\n font-weight: var(--panneau-font-weight-medium);\n }\n\n .table td.title .cellLabel {\n display: none;\n }\n\n .cellLabel {\n display: block;\n font-size: var(--panneau-font-size-sm);\n color: var(--panneau-color-text-muted);\n }\n}\n"],"mappings":""}
@@ -1,4 +1,4 @@
1
- import type { ListLayoutEntry } from '../types';
1
+ import type { ListLayoutEntry } from '../types.js';
2
2
  /** The built-in list layouts, by id. `gallery` and `calendar` come later. */
3
3
  export declare const builtInLayouts: Readonly<Record<string, ListLayoutEntry>> & {
4
4
  table: ListLayoutEntry;
@@ -1 +1 @@
1
- {"version":3,"file":"builtIn.js","names":[],"sources":["../../src/layouts/builtIn.ts"],"sourcesContent":["import type { ListLayoutEntry } from '../types';\nimport { CardsLayout } from './CardsLayout';\nimport { TableLayout } from './TableLayout';\n\n/** The built-in list layouts, by id. `gallery` and `calendar` come later. */\nexport const builtInLayouts: Readonly<Record<string, ListLayoutEntry>> & {\n table: ListLayoutEntry;\n} = {\n table: TableLayout,\n cards: CardsLayout,\n};\n"],"mappings":";;;;AAKA,IAAa,iBAET;CACA,OAAO;CACP,OAAO;AACX"}
1
+ {"version":3,"file":"builtIn.js","names":["ListLayoutEntry","CardsLayout","TableLayout","builtInLayouts","Readonly","Record","table","cards"],"sources":["../../src/layouts/builtIn.ts"],"sourcesContent":["import type { ListLayoutEntry } from '../types';\nimport { CardsLayout } from './CardsLayout';\nimport { TableLayout } from './TableLayout';\n\n/** The built-in list layouts, by id. `gallery` and `calendar` come later. */\nexport const builtInLayouts: Readonly<Record<string, ListLayoutEntry>> & {\n table: ListLayoutEntry;\n} = {\n table: TableLayout,\n cards: CardsLayout,\n};\n"],"mappings":";;;;AAKA,IAAaG,iBAET;CACAG,OAAOJ;CACPK,OAAON;AACX"}
@@ -1,4 +1,4 @@
1
- .panneau-link-1crRKJ {
1
+ .panneau-link {
2
2
  color: inherit;
3
3
  font-weight: var(--panneau-font-weight-medium);
4
4
  text-decoration: none;
@@ -6,11 +6,11 @@
6
6
  cursor: pointer;
7
7
  }
8
8
 
9
- .panneau-link-1crRKJ:hover {
9
+ .panneau-link:hover {
10
10
  text-decoration: underline;
11
11
  }
12
12
 
13
- .panneau-link-1crRKJ[data-focus-visible] {
13
+ .panneau-link[data-focus-visible] {
14
14
  outline: var(--panneau-focus-width) solid var(--panneau-color-focus);
15
15
  outline-offset: 2px;
16
16
  }
@@ -1,6 +1,6 @@
1
1
  import "./link.css";
2
2
  //#region src/layouts/link.module.css
3
- var link = "panneau-link-1crRKJ";
3
+ var link = "panneau-link";
4
4
  var link_module_default = { link };
5
5
  //#endregion
6
6
  export { link_module_default as default, link };
package/dist/plugin.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { DisplayEntry, ListLayoutEntry } from './types';
1
+ import type { DisplayEntry, ListLayoutEntry } from './types.js';
2
2
  /**
3
3
  * The built-in displays and layouts as a `@panneau/core` plugin, with the French messages of every
4
4
  * Panneau package (from `@panneau/intl`). Lists use the built-in displays and layouts without it:
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { builtInDisplays } from './displays/displays';\nimport { builtInLayouts } from './layouts/builtIn';\nimport type { DisplayEntry, ListLayoutEntry } from './types';\n\n/**\n * The built-in displays and layouts as a `@panneau/core` plugin, with the French messages of every\n * Panneau package (from `@panneau/intl`). Lists use the built-in displays and layouts without it:\n * pass it for the messages, before the plugins that replace a display.\n */\nexport const listsPlugin: {\n id: string;\n displays: Readonly<Record<string, DisplayEntry>>;\n listLayouts: Readonly<Record<string, ListLayoutEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-lists',\n displays: builtInDisplays,\n listLayouts: builtInLayouts,\n locales: { fr },\n};\n"],"mappings":";;;;;;;;;AAWA,IAAa,cAKT;CACA,IAAI;CACJ,UAAU;CACV,aAAa;CACb,SAAS,EAAE,GAAG;AAClB"}
1
+ {"version":3,"file":"plugin.js","names":["fr","builtInDisplays","builtInLayouts","DisplayEntry","ListLayoutEntry","listsPlugin","id","displays","Readonly","Record","listLayouts","locales"],"sources":["../src/plugin.ts"],"sourcesContent":["import { fr } from '@panneau/intl';\n\nimport { builtInDisplays } from './displays/displays';\nimport { builtInLayouts } from './layouts/builtIn';\nimport type { DisplayEntry, ListLayoutEntry } from './types';\n\n/**\n * The built-in displays and layouts as a `@panneau/core` plugin, with the French messages of every\n * Panneau package (from `@panneau/intl`). Lists use the built-in displays and layouts without it:\n * pass it for the messages, before the plugins that replace a display.\n */\nexport const listsPlugin: {\n id: string;\n displays: Readonly<Record<string, DisplayEntry>>;\n listLayouts: Readonly<Record<string, ListLayoutEntry>>;\n locales: Readonly<Record<string, Record<string, string>>>;\n} = {\n id: 'panneau-lists',\n displays: builtInDisplays,\n listLayouts: builtInLayouts,\n locales: { fr },\n};\n"],"mappings":";;;;;;;;;AAWA,IAAaK,cAKT;CACAC,IAAI;CACJC,UAAUN;CACVS,aAAaR;CACbS,SAAS,EAAEX,GAAG;AAClB"}
package/dist/query.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ListQuery } from '@panneau/protocol';
2
- import type { ListColumn, ListItem } from './types';
2
+ import type { ListColumn, ListItem } from './types.js';
3
3
  export interface LocalQueryOptions {
4
4
  /** The columns: values of localized fields are compared in `locale`. */
5
5
  columns?: readonly ListColumn[];
package/dist/query.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"query.js","names":[],"sources":["../src/query.ts"],"sourcesContent":["import type { ListQuery } from '@panneau/protocol';\nimport { isFilterRange, matchesFilterRange } from '@panneau/protocol/runtime';\n\nimport type { ListColumn, ListItem } from './types';\nimport { getColumnValue, toText } from './values';\n\nexport interface LocalQueryOptions {\n /** The columns: values of localized fields are compared in `locale`. */\n columns?: readonly ListColumn[];\n /** Locale of localized values and of the text comparison. Defaults to `en`. */\n locale?: string;\n}\n\nexport interface LocalQueryResult<T extends ListItem> {\n /** The items of the page. */\n items: T[];\n /** How many items match the filters and the search, on every page. */\n total: number;\n}\n\nfunction valueOf(item: ListItem, key: string, options: LocalQueryOptions): unknown {\n const column = options.columns?.find((candidate) => candidate.id === key);\n return column !== undefined ? getColumnValue(item, column, options.locale ?? 'en') : item[key];\n}\n\n/**\n * Applies a list query to items in memory, as a backend would: filters (the value, or one of the\n * values, matches as a string; a range matches the values within its bounds), search in every text\n * value, sort, then the page. For a product that has every item at hand.\n */\nexport function applyListQuery<T extends ListItem>(\n items: readonly T[],\n query: ListQuery,\n options: LocalQueryOptions = {},\n): LocalQueryResult<T> {\n const locale = options.locale ?? 'en';\n let result = [...items];\n Object.entries(query.filter ?? {}).forEach(([key, expected]) => {\n if (isFilterRange(expected)) {\n result = result.filter((item) =>\n matchesFilterRange(valueOf(item, key, options), expected),\n );\n return;\n }\n const accepted = (Array.isArray(expected) ? expected : [expected]).map(String);\n result = result.filter((item) => {\n const value = valueOf(item, key, options);\n const values: unknown[] = Array.isArray(value) ? value : [value];\n return values.some((candidate) => {\n const id =\n candidate !== null && typeof candidate === 'object' && 'id' in candidate\n ? candidate.id\n : candidate;\n return accepted.includes(String(id));\n });\n });\n });\n const q = query.q?.trim().toLocaleLowerCase(locale) ?? '';\n if (q !== '') {\n result = result.filter((item) =>\n Object.entries(item)\n .filter(([key]) => key !== 'id' && key !== 'abilities' && key !== 'version')\n .some(([key]) =>\n toText(valueOf(item, key, options), locale)\n .toLocaleLowerCase(locale)\n .includes(q),\n ),\n );\n }\n const sort = query.sort ?? [];\n if (sort.length > 0) {\n const collator = new Intl.Collator(locale, { numeric: true, sensitivity: 'base' });\n result.sort((a, b) => {\n for (const part of sort) {\n const descending = part.startsWith('-');\n const key = descending ? part.slice(1) : part;\n const left = valueOf(a, key, options);\n const right = valueOf(b, key, options);\n const order =\n typeof left === 'number' && typeof right === 'number'\n ? left - right\n : compareText(toText(left, locale), toText(right, locale), collator);\n if (order !== 0) {\n return descending ? -order : order;\n }\n }\n return 0;\n });\n }\n const total = result.length;\n if (query.perPage !== undefined) {\n const page = query.page ?? 1;\n result = result.slice((page - 1) * query.perPage, page * query.perPage);\n }\n return { items: result, total };\n}\n\n/** Compares texts, empty ones last. */\nfunction compareText(left: string, right: string, collator: Intl.Collator): number {\n if (left === right) {\n return 0;\n }\n if (left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Q,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC,CACtC,kBAAkB,MAAM,CAAC,CACzB,SAAS,CAAC,CACnB,CACR;CAEJ,MAAM,OAAO,MAAM,QAAQ,CAAA;CAC3B,IAAI,KAAK,SAAS,GAAG;EACjB,MAAM,WAAW,IAAI,KAAK,SAAS,QAAQ;GAAE,SAAS;GAAM,aAAa;EAAO,CAAC;EACjF,OAAO,MAAM,GAAG,MAAM;GAClB,KAAK,MAAM,QAAQ,MAAM;IACrB,MAAM,aAAa,KAAK,WAAW,GAAG;IACtC,MAAM,MAAM,aAAa,KAAK,MAAM,CAAC,IAAI;IACzC,MAAM,OAAO,QAAQ,GAAG,KAAK,OAAO;IACpC,MAAM,QAAQ,QAAQ,GAAG,KAAK,OAAO;IACrC,MAAM,QACF,OAAO,SAAS,YAAY,OAAO,UAAU,WACvC,OAAO,QACP,YAAY,OAAO,MAAM,MAAM,GAAG,OAAO,OAAO,MAAM,GAAG,QAAQ;IAC3E,IAAI,UAAU,GACV,OAAO,aAAa,CAAC,QAAQ;GAErC;GACA,OAAO;EACX,CAAC;CACL;CACA,MAAM,QAAQ,OAAO;CACrB,IAAI,MAAM,YAAY,KAAA,GAAW;EAC7B,MAAM,OAAO,MAAM,QAAQ;EAC3B,SAAS,OAAO,OAAO,OAAO,KAAK,MAAM,SAAS,OAAO,MAAM,OAAO;CAC1E;CACA,OAAO;EAAE,OAAO;EAAQ;CAAM;AAClC;;AAGA,SAAS,YAAY,MAAc,OAAe,UAAiC;CAC/E,IAAI,SAAS,OACT,OAAO;CAEX,IAAI,SAAS,IACT,OAAO;CAEX,IAAI,UAAU,IACV,OAAO;CAEX,OAAO,SAAS,QAAQ,MAAM,KAAK;AACvC"}
1
+ {"version":3,"file":"query.js","names":["ListQuery","isFilterRange","matchesFilterRange","ListColumn","ListItem","getColumnValue","toText","LocalQueryOptions","columns","locale","LocalQueryResult","items","T","total","valueOf","item","key","options","column","find","candidate","id","undefined","applyListQuery","query","result","Object","entries","filter","forEach","expected","accepted","Array","isArray","map","String","value","values","some","includes","q","trim","toLocaleLowerCase","sort","length","collator","Intl","Collator","numeric","sensitivity","a","b","part","descending","startsWith","slice","left","right","order","compareText","perPage","page","compare"],"sources":["../src/query.ts"],"sourcesContent":["import type { ListQuery } from '@panneau/protocol';\nimport { isFilterRange, matchesFilterRange } from '@panneau/protocol/runtime';\n\nimport type { ListColumn, ListItem } from './types';\nimport { getColumnValue, toText } from './values';\n\nexport interface LocalQueryOptions {\n /** The columns: values of localized fields are compared in `locale`. */\n columns?: readonly ListColumn[];\n /** Locale of localized values and of the text comparison. Defaults to `en`. */\n locale?: string;\n}\n\nexport interface LocalQueryResult<T extends ListItem> {\n /** The items of the page. */\n items: T[];\n /** How many items match the filters and the search, on every page. */\n total: number;\n}\n\nfunction valueOf(item: ListItem, key: string, options: LocalQueryOptions): unknown {\n const column = options.columns?.find((candidate) => candidate.id === key);\n return column !== undefined ? getColumnValue(item, column, options.locale ?? 'en') : item[key];\n}\n\n/**\n * Applies a list query to items in memory, as a backend would: filters (the value, or one of the\n * values, matches as a string; a range matches the values within its bounds), search in every text\n * value, sort, then the page. For a product that has every item at hand.\n */\nexport function applyListQuery<T extends ListItem>(\n items: readonly T[],\n query: ListQuery,\n options: LocalQueryOptions = {},\n): LocalQueryResult<T> {\n const locale = options.locale ?? 'en';\n let result = [...items];\n Object.entries(query.filter ?? {}).forEach(([key, expected]) => {\n if (isFilterRange(expected)) {\n result = result.filter((item) =>\n matchesFilterRange(valueOf(item, key, options), expected),\n );\n return;\n }\n const accepted = (Array.isArray(expected) ? expected : [expected]).map(String);\n result = result.filter((item) => {\n const value = valueOf(item, key, options);\n const values: unknown[] = Array.isArray(value) ? value : [value];\n return values.some((candidate) => {\n const id =\n candidate !== null && typeof candidate === 'object' && 'id' in candidate\n ? candidate.id\n : candidate;\n return accepted.includes(String(id));\n });\n });\n });\n const q = query.q?.trim().toLocaleLowerCase(locale) ?? '';\n if (q !== '') {\n result = result.filter((item) =>\n Object.entries(item)\n .filter(([key]) => key !== 'id' && key !== 'abilities' && key !== 'version')\n .some(([key]) =>\n toText(valueOf(item, key, options), locale)\n .toLocaleLowerCase(locale)\n .includes(q),\n ),\n );\n }\n const sort = query.sort ?? [];\n if (sort.length > 0) {\n const collator = new Intl.Collator(locale, { numeric: true, sensitivity: 'base' });\n result.sort((a, b) => {\n for (const part of sort) {\n const descending = part.startsWith('-');\n const key = descending ? part.slice(1) : part;\n const left = valueOf(a, key, options);\n const right = valueOf(b, key, options);\n const order =\n typeof left === 'number' && typeof right === 'number'\n ? left - right\n : compareText(toText(left, locale), toText(right, locale), collator);\n if (order !== 0) {\n return descending ? -order : order;\n }\n }\n return 0;\n });\n }\n const total = result.length;\n if (query.perPage !== undefined) {\n const page = query.page ?? 1;\n result = result.slice((page - 1) * query.perPage, page * query.perPage);\n }\n return { items: result, total };\n}\n\n/** Compares texts, empty ones last. */\nfunction compareText(left: string, right: string, collator: Intl.Collator): number {\n if (left === right) {\n return 0;\n }\n if (left === '') {\n return 1;\n }\n if (right === '') {\n return -1;\n }\n return collator.compare(left, right);\n}\n"],"mappings":";;;AAoBA,SAASc,QAAQC,MAAgBC,KAAaC,SAAqC;CAC/E,MAAMC,SAASD,QAAQT,SAASW,MAAMC,cAAcA,UAAUC,OAAOL,GAAG;CACxE,OAAOE,WAAWI,KAAAA,IAAYjB,eAAeU,MAAMG,QAAQD,QAAQR,UAAU,IAAI,IAAIM,KAAKC;AAC9F;;;;;;AAOA,SAAgBO,eACZZ,OACAa,OACAP,UAA6B,CAAC,GACX;CACnB,MAAMR,SAASQ,QAAQR,UAAU;CACjC,IAAIgB,SAAS,CAAC,GAAGd,KAAK;CACtBe,OAAOC,QAAQH,MAAMI,UAAU,CAAC,CAAC,CAAC,CAACC,SAAS,CAACb,KAAKc,cAAc;EAC5D,IAAI7B,cAAc6B,QAAQ,GAAG;GACzBL,SAASA,OAAOG,QAAQb,SACpBb,mBAAmBY,QAAQC,MAAMC,KAAKC,OAAO,G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MAAMwC,QAAQ3C,QAAQqC,GAAGnC,KAAKC,OAAO;IACrC,MAAMyC,QACF,OAAOF,SAAS,YAAY,OAAOC,UAAU,WACvCD,OAAOC,QACPE,YAAYrD,OAAOkD,MAAM/C,MAAM,GAAGH,OAAOmD,OAAOhD,MAAM,GAAGoC,QAAQ;IAC3E,IAAIa,UAAU,GACV,OAAOL,aAAa,CAACK,QAAQA;GAErC;GACA,OAAO;EACX,CAAC;CACL;CACA,MAAM7C,QAAQY,OAAOmB;CACrB,IAAIpB,MAAMoC,YAAYtC,KAAAA,GAAW;EAC7B,MAAMuC,OAAOrC,MAAMqC,QAAQ;EAC3BpC,SAASA,OAAO8B,OAAOM,OAAO,KAAKrC,MAAMoC,SAASC,OAAOrC,MAAMoC,OAAO;CAC1E;CACA,OAAO;EAAEjD,OAAOc;EAAQZ;CAAM;AAClC;;AAGA,SAAS8C,YAAYH,MAAcC,OAAeZ,UAAiC;CAC/E,IAAIW,SAASC,OACT,OAAO;CAEX,IAAID,SAAS,IACT,OAAO;CAEX,IAAIC,UAAU,IACV,OAAO;CAEX,OAAOZ,SAASiB,QAAQN,MAAMC,KAAK;AACvC"}
@@ -1,5 +1,5 @@
1
1
  import type { ListSelection } from '@panneau/core';
2
- import type { ListItem } from './types';
2
+ import type { ListItem } from './types.js';
3
3
  /** Whether an item is selected. */
4
4
  export declare function isItemSelected(selection: ListSelection, id: string): boolean;
5
5
  /** How many items are selected, given the total of the list (or the count of items without it). */
@@ -1 +1 @@
1
- {"version":3,"file":"selection.js","names":[],"sources":["../src/selection.ts"],"sourcesContent":["import type { ListSelection } from '@panneau/core';\n\nimport type { ListItem } from './types';\n\n// The selection is read from the subscribed state, not through the methods of the list\n// (`list.isSelected()`): under the React Compiler, a component that calls a method of an object\n// that doesn't change would keep its first result.\n\n/** Whether an item is selected. */\nexport function isItemSelected(selection: ListSelection, id: string): boolean {\n return selection.mode === 'all' ? !selection.except.includes(id) : selection.ids.includes(id);\n}\n\n/** How many items are selected, given the total of the list (or the count of items without it). */\nexport function countSelected(selection: ListSelection, total: number): number {\n return selection.mode === 'all'\n ? Math.max(0, total - selection.except.length)\n : selection.ids.length;\n}\n\n/** Whether every, some or none of the items of a page are selected. */\nexport function getPageSelection(\n selection: ListSelection,\n items: readonly ListItem[],\n): 'all' | 'some' | 'none' {\n const selected = items.filter((item) => isItemSelected(selection, item.id)).length;\n if (selected === 0 || items.length === 0) {\n return 'none';\n }\n return selected === items.length ? 'all' : 'some';\n}\n"],"mappings":";;AASA,SAAgB,eAAe,WAA0B,IAAqB;CAC1E,OAAO,UAAU,SAAS,QAAQ,CAAC,UAAU,OAAO,SAAS,EAAE,IAAI,UAAU,IAAI,SAAS,EAAE;AAChG;;AAGA,SAAgB,cAAc,WAA0B,OAAuB;CAC3E,OAAO,UAAU,SAAS,QACpB,KAAK,IAAI,GAAG,QAAQ,UAAU,OAAO,MAAM,IAC3C,UAAU,IAAI;AACxB;;AAGA,SAAgB,iBACZ,WACA,OACuB;CACvB,MAAM,WAAW,MAAM,QAAQ,SAAS,eAAe,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC;CAC5E,IAAI,aAAa,KAAK,MAAM,WAAW,GACnC,OAAO;CAEX,OAAO,aAAa,MAAM,SAAS,QAAQ;AAC/C"}
1
+ {"version":3,"file":"selection.js","names":["ListSelection","ListItem","isItemSelected","selection","id","mode","except","includes","ids","countSelected","total","Math","max","length","getPageSelection","items","selected","filter","item"],"sources":["../src/selection.ts"],"sourcesContent":["import type { ListSelection } from '@panneau/core';\n\nimport type { ListItem } from './types';\n\n// The selection is read from the subscribed state, not through the methods of the list\n// (`list.isSelected()`): under the React Compiler, a component that calls a method of an object\n// that doesn't change would keep its first result.\n\n/** Whether an item is selected. */\nexport function isItemSelected(selection: ListSelection, id: string): boolean {\n return selection.mode === 'all' ? !selection.except.includes(id) : selection.ids.includes(id);\n}\n\n/** How many items are selected, given the total of the list (or the count of items without it). */\nexport function countSelected(selection: ListSelection, total: number): number {\n return selection.mode === 'all'\n ? Math.max(0, total - selection.except.length)\n : selection.ids.length;\n}\n\n/** Whether every, some or none of the items of a page are selected. */\nexport function getPageSelection(\n selection: ListSelection,\n items: readonly ListItem[],\n): 'all' | 'some' | 'none' {\n const selected = items.filter((item) => isItemSelected(selection, item.id)).length;\n if (selected === 0 || items.length === 0) {\n return 'none';\n }\n return selected === items.length ? 'all' : 'some';\n}\n"],"mappings":";;AASA,SAAgBE,eAAeC,WAA0BC,IAAqB;CAC1E,OAAOD,UAAUE,SAAS,QAAQ,CAACF,UAAUG,OAAOC,SAASH,EAAE,IAAID,UAAUK,IAAID,SAASH,EAAE;AAChG;;AAGA,SAAgBK,cAAcN,WAA0BO,OAAuB;CAC3E,OAAOP,UAAUE,SAAS,QACpBM,KAAKC,IAAI,GAAGF,QAAQP,UAAUG,OAAOO,MAAM,IAC3CV,UAAUK,IAAIK;AACxB;;AAGA,SAAgBC,iBACZX,WACAY,OACuB;CACvB,MAAMC,WAAWD,MAAME,QAAQC,SAAShB,eAAeC,WAAWe,KAAKd,EAAE,CAAC,CAAC,CAACS;CAC5E,IAAIG,aAAa,KAAKD,MAAMF,WAAW,GACnC,OAAO;CAEX,OAAOG,aAAaD,MAAMF,SAAS,QAAQ;AAC/C"}