@viewkitjs/views 0.3.0 → 0.5.0

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 (288) hide show
  1. package/CHANGELOG.md +641 -0
  2. package/README.md +3 -3
  3. package/dist/atoms/CommandMenu.d.ts +1 -1
  4. package/dist/atoms/CommandMenu.js +7 -3
  5. package/dist/atoms/DrillRows.d.ts +3 -0
  6. package/dist/atoms/DrillRows.js +25 -0
  7. package/dist/atoms/PanelRows.d.ts +5 -0
  8. package/dist/atoms/PanelRows.js +40 -0
  9. package/dist/atoms/PanelSearch.d.ts +2 -0
  10. package/dist/atoms/PanelSearch.js +21 -0
  11. package/dist/atoms/RelationRoles.d.ts +2 -0
  12. package/dist/atoms/RelationRoles.js +6 -0
  13. package/dist/atoms/Row.js +2 -1
  14. package/dist/atoms/RowMenu.js +2 -1
  15. package/dist/atoms/SelectionSheet.d.ts +3 -0
  16. package/dist/atoms/SelectionSheet.js +30 -0
  17. package/dist/atoms/StatusMarker.js +3 -1
  18. package/dist/atoms/Tag.js +2 -1
  19. package/dist/atoms/defaults.js +14 -0
  20. package/dist/atoms/types.d.ts +146 -8
  21. package/dist/cells/cell-values.js +4 -2
  22. package/dist/cells/relation-wrap.js +3 -1
  23. package/dist/contract.d.ts +212 -17
  24. package/dist/contract.js +208 -6
  25. package/dist/display/boolean.js +3 -1
  26. package/dist/display/date.d.ts +1 -1
  27. package/dist/display/date.js +4 -2
  28. package/dist/display/format.js +20 -4
  29. package/dist/display/link.js +4 -3
  30. package/dist/display/multi-value.js +2 -1
  31. package/dist/display/percent.js +2 -1
  32. package/dist/display/phone.js +2 -1
  33. package/dist/display/range.js +3 -13
  34. package/dist/display/relation.js +23 -8
  35. package/dist/display/rich-text.js +2 -1
  36. package/dist/editors/ChipsEditor.d.ts +5 -1
  37. package/dist/editors/ChipsEditor.js +15 -2
  38. package/dist/editors/DateEditor.d.ts +2 -0
  39. package/dist/editors/DateEditor.js +76 -10
  40. package/dist/editors/EditorPanel.d.ts +14 -4
  41. package/dist/editors/EditorPanel.js +21 -4
  42. package/dist/editors/LocationEditor.js +35 -3
  43. package/dist/editors/NumberEditor.js +3 -2
  44. package/dist/editors/RangeEditor.d.ts +8 -0
  45. package/dist/editors/RangeEditor.js +3 -2
  46. package/dist/editors/RelationEditor.d.ts +2 -0
  47. package/dist/editors/RelationEditor.js +16 -2
  48. package/dist/editors/RelationSetEditor.d.ts +4 -2
  49. package/dist/editors/RelationSetEditor.js +36 -2
  50. package/dist/editors/SelectEditor.d.ts +5 -2
  51. package/dist/editors/SelectEditor.js +31 -4
  52. package/dist/editors/TextEditor.js +3 -1
  53. package/dist/editors/ValueListEditor.d.ts +3 -0
  54. package/dist/editors/ValueListEditor.js +10 -4
  55. package/dist/editors/edit-session.d.ts +14 -2
  56. package/dist/editors/edit-session.js +13 -5
  57. package/dist/editors/escape-rule.d.ts +12 -0
  58. package/dist/editors/escape-rule.js +8 -0
  59. package/dist/editors/open-value.js +2 -1
  60. package/dist/editors/picker-slot.d.ts +25 -0
  61. package/dist/editors/picker-slot.js +37 -0
  62. package/dist/editors/relation-picker.d.ts +44 -0
  63. package/dist/editors/relation-picker.js +49 -0
  64. package/dist/editors/relation-source.d.ts +1 -0
  65. package/dist/editors/relation-source.js +7 -1
  66. package/dist/field-row/FieldNoteLine.js +2 -1
  67. package/dist/field-row/FieldRow.js +41 -6
  68. package/dist/field-row/FieldRowLane.js +3 -1
  69. package/dist/field-row/editors/RowChipsEditor.js +1 -1
  70. package/dist/field-row/editors/RowDateEditor.js +1 -1
  71. package/dist/field-row/editors/RowEditor.js +2 -1
  72. package/dist/field-row/editors/RowRangeEditor.js +2 -1
  73. package/dist/field-row/editors/RowRelationEditor.js +2 -2
  74. package/dist/field-row/editors/RowSelectEditor.d.ts +1 -1
  75. package/dist/field-row/editors/RowSelectEditor.js +2 -2
  76. package/dist/field-row/editors/RowValueListEditor.js +1 -1
  77. package/dist/field-row/editors/host.d.ts +3 -0
  78. package/dist/field-row/editors/row-session.js +4 -1
  79. package/dist/fields/menus.d.ts +2 -0
  80. package/dist/fields/range-unit.d.ts +7 -0
  81. package/dist/fields/range-unit.js +13 -0
  82. package/dist/figures.d.ts +5 -48
  83. package/dist/figures.js +1 -63
  84. package/dist/grid/chrome/GridAddColumn.d.ts +8 -0
  85. package/dist/grid/chrome/GridAddColumn.js +66 -9
  86. package/dist/grid/chrome/GridAggregateMenu.d.ts +5 -2
  87. package/dist/grid/chrome/GridAggregateMenu.js +33 -4
  88. package/dist/grid/chrome/GridCellEditors.d.ts +9 -2
  89. package/dist/grid/chrome/GridCellEditors.js +24 -5
  90. package/dist/grid/chrome/GridCellOutline.d.ts +3 -2
  91. package/dist/grid/chrome/GridCellOutline.js +11 -1
  92. package/dist/grid/chrome/GridChipsEditor.js +1 -1
  93. package/dist/grid/chrome/GridColumnColorSection.d.ts +2 -0
  94. package/dist/grid/chrome/GridColumnColorSection.js +2 -2
  95. package/dist/grid/chrome/GridColumnDateSection.d.ts +4 -0
  96. package/dist/grid/chrome/GridColumnDateSection.js +2 -2
  97. package/dist/grid/chrome/GridColumnDurationSection.d.ts +4 -0
  98. package/dist/grid/chrome/GridColumnDurationSection.js +2 -2
  99. package/dist/grid/chrome/GridColumnMenu.d.ts +10 -6
  100. package/dist/grid/chrome/GridColumnMenu.js +62 -24
  101. package/dist/grid/chrome/GridColumnNumberSection.d.ts +4 -0
  102. package/dist/grid/chrome/GridColumnNumberSection.js +2 -2
  103. package/dist/grid/chrome/GridColumnPercentSection.d.ts +1 -0
  104. package/dist/grid/chrome/GridColumnPercentSection.js +1 -1
  105. package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
  106. package/dist/grid/chrome/GridDateEditor.js +1 -1
  107. package/dist/grid/chrome/GridFooter.js +7 -48
  108. package/dist/grid/chrome/GridGroupMenu.d.ts +11 -5
  109. package/dist/grid/chrome/GridGroupMenu.js +28 -13
  110. package/dist/grid/chrome/GridHeader.d.ts +3 -1
  111. package/dist/grid/chrome/GridHeader.js +8 -8
  112. package/dist/grid/chrome/GridNumberEditor.js +3 -24
  113. package/dist/grid/chrome/GridRangeEditor.js +3 -2
  114. package/dist/grid/chrome/GridRelationEditor.js +2 -2
  115. package/dist/grid/chrome/GridRow.d.ts +2 -1
  116. package/dist/grid/chrome/GridRow.js +13 -37
  117. package/dist/grid/chrome/GridRowActions.js +2 -1
  118. package/dist/grid/chrome/GridRowCells.js +9 -4
  119. package/dist/grid/chrome/GridSelectEditor.js +30 -20
  120. package/dist/grid/chrome/GridStructure.d.ts +11 -4
  121. package/dist/grid/chrome/GridStructure.js +19 -7
  122. package/dist/grid/chrome/GridTable.js +138 -16
  123. package/dist/grid/chrome/GridTableSurface.d.ts +25 -12
  124. package/dist/grid/chrome/GridTableSurface.js +13 -6
  125. package/dist/grid/chrome/GridTextEditor.js +3 -1
  126. package/dist/grid/chrome/GridValueListEditor.js +1 -1
  127. package/dist/grid/chrome/cell-clipboard.d.ts +1 -1
  128. package/dist/grid/chrome/cell-clipboard.js +1 -1
  129. package/dist/grid/chrome/checks.d.ts +10 -2
  130. package/dist/grid/chrome/checks.js +17 -11
  131. package/dist/grid/chrome/column-glyph.d.ts +2 -2
  132. package/dist/grid/chrome/column-glyph.js +4 -0
  133. package/dist/grid/chrome/grid-add-column-items.d.ts +13 -0
  134. package/dist/grid/chrome/grid-add-column-items.js +40 -0
  135. package/dist/grid/chrome/grid-cell-classes.d.ts +2 -0
  136. package/dist/grid/chrome/grid-cell-classes.js +10 -4
  137. package/dist/grid/chrome/grid-column-menu-items.d.ts +75 -0
  138. package/dist/grid/chrome/grid-column-menu-items.js +263 -0
  139. package/dist/grid/chrome/grid-edit-escape.d.ts +4 -0
  140. package/dist/grid/chrome/grid-edit-escape.js +12 -0
  141. package/dist/grid/chrome/grid-edit-session.d.ts +2 -1
  142. package/dist/grid/chrome/grid-edit-session.js +14 -1
  143. package/dist/grid/chrome/grid-figure-value.d.ts +25 -0
  144. package/dist/grid/chrome/grid-figure-value.js +40 -0
  145. package/dist/grid/chrome/grid-fitted-box.d.ts +15 -0
  146. package/dist/grid/chrome/grid-fitted-box.js +26 -0
  147. package/dist/grid/chrome/grid-group-menu-items.d.ts +31 -0
  148. package/dist/grid/chrome/grid-group-menu-items.js +75 -0
  149. package/dist/grid/chrome/grid-group-menu-parts.d.ts +27 -0
  150. package/dist/grid/chrome/grid-group-menu-parts.js +19 -0
  151. package/dist/grid/chrome/grid-hover.d.ts +1 -0
  152. package/dist/grid/chrome/grid-hover.js +13 -1
  153. package/dist/grid/chrome/grid-lab.d.ts +7 -0
  154. package/dist/grid/chrome/grid-lab.js +7 -0
  155. package/dist/grid/chrome/grid-menu-focus.d.ts +12 -0
  156. package/dist/grid/chrome/grid-menu-focus.js +13 -0
  157. package/dist/grid/chrome/{useGridRowContextMenu.d.ts → grid-row-menu-items.d.ts} +15 -4
  158. package/dist/grid/chrome/{useGridRowContextMenu.js → grid-row-menu-items.js} +15 -18
  159. package/dist/grid/chrome/grid-row-props.d.ts +3 -1
  160. package/dist/grid/chrome/grid-row-window.d.ts +15 -5
  161. package/dist/grid/chrome/grid-row-window.js +44 -10
  162. package/dist/grid/chrome/grid-rows-menu.d.ts +38 -0
  163. package/dist/grid/chrome/grid-rows-menu.js +83 -0
  164. package/dist/grid/chrome/grid-table-props.d.ts +53 -8
  165. package/dist/grid/chrome/useGridBandFigures.d.ts +26 -0
  166. package/dist/grid/chrome/useGridBandFigures.js +50 -0
  167. package/dist/grid/chrome/useGridBoxes.d.ts +22 -0
  168. package/dist/grid/chrome/useGridBoxes.js +22 -0
  169. package/dist/grid/chrome/useGridColumnLayout.js +29 -4
  170. package/dist/grid/chrome/useGridKeyboard.js +7 -2
  171. package/dist/grid/chrome/useGridPartColumns.d.ts +5 -0
  172. package/dist/grid/chrome/useGridPartColumns.js +9 -0
  173. package/dist/grid/chrome/useGridRangeGestures.js +2 -1
  174. package/dist/grid/chrome/useGridRecorder.d.ts +16 -0
  175. package/dist/grid/chrome/useGridRecorder.js +144 -0
  176. package/dist/grid/chrome/useGridRowOpener.d.ts +41 -0
  177. package/dist/grid/chrome/useGridRowOpener.js +83 -0
  178. package/dist/grid/chrome/useGridScrollArea.d.ts +38 -12
  179. package/dist/grid/chrome/useGridScrollArea.js +70 -17
  180. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
  181. package/dist/grid/chrome/useGridTableInteractionModel.js +67 -9
  182. package/dist/grid/core/clipboard-model.d.ts +11 -3
  183. package/dist/grid/core/clipboard-model.js +9 -4
  184. package/dist/grid/core/commit-model.d.ts +7 -0
  185. package/dist/grid/core/editing-controller.d.ts +31 -1
  186. package/dist/grid/core/editing-controller.js +65 -0
  187. package/dist/grid/core/grid-recorder.d.ts +111 -0
  188. package/dist/grid/core/grid-recorder.js +223 -0
  189. package/dist/grid/core/part-edits.d.ts +18 -0
  190. package/dist/grid/core/part-edits.js +48 -0
  191. package/dist/grid/core/pending-reconciliation.js +12 -3
  192. package/dist/grid/core/refusal-sentence.d.ts +3 -0
  193. package/dist/grid/core/refusal-sentence.js +15 -0
  194. package/dist/grid/core/row-opened-from.d.ts +21 -0
  195. package/dist/grid/core/row-opened-from.js +11 -0
  196. package/dist/grid/core/useGridEditing.d.ts +16 -2
  197. package/dist/grid/core/useGridEditing.js +10 -4
  198. package/dist/grid/core/value-equality.d.ts +19 -1
  199. package/dist/grid/core/value-equality.js +24 -0
  200. package/dist/grid/index.d.ts +4 -1
  201. package/dist/grid/index.js +1 -0
  202. package/dist/grid/useGridTablePrefs.d.ts +1 -1
  203. package/dist/grid-lab.d.ts +18 -0
  204. package/dist/grid-lab.js +16 -0
  205. package/dist/grouping/sort-groups.d.ts +6 -7
  206. package/dist/index.d.ts +1 -0
  207. package/dist/index.js +1 -0
  208. package/dist/internal/reset.d.ts +9 -0
  209. package/dist/internal/reset.js +1 -0
  210. package/dist/model/aggregates.d.ts +3 -3
  211. package/dist/model/aggregates.js +17 -71
  212. package/dist/model/column-capabilities.d.ts +29 -2
  213. package/dist/model/column-capabilities.js +27 -3
  214. package/dist/model/column-filters.js +24 -4
  215. package/dist/model/column-inspect.d.ts +2 -1
  216. package/dist/model/column-order.d.ts +2 -2
  217. package/dist/model/column-schema.d.ts +18 -7
  218. package/dist/model/column-state.d.ts +9 -20
  219. package/dist/model/column-state.js +1 -4
  220. package/dist/model/column-types.d.ts +1 -15
  221. package/dist/model/column-types.js +1 -1
  222. package/dist/model/part-columns.d.ts +17 -0
  223. package/dist/model/part-columns.js +67 -0
  224. package/dist/model/part-rows.d.ts +3 -10
  225. package/dist/model/part-rows.js +6 -11
  226. package/dist/model/part-write.d.ts +11 -0
  227. package/dist/model/part-write.js +52 -0
  228. package/dist/model/preferences.d.ts +3 -23
  229. package/dist/model/preferences.js +1 -17
  230. package/dist/model/prefs-buckets.d.ts +0 -27
  231. package/dist/model/prefs-buckets.js +1 -1
  232. package/dist/model/relation-filters.d.ts +0 -1
  233. package/dist/model/relation-filters.js +1 -1
  234. package/dist/model/row-icon.d.ts +5 -9
  235. package/dist/model/view-rules.d.ts +32 -6
  236. package/dist/model/view-rules.js +101 -21
  237. package/dist/provider/ViewsProvider.d.ts +22 -2
  238. package/dist/provider/ViewsProvider.js +21 -2
  239. package/dist/provider/components.d.ts +197 -9
  240. package/dist/provider/context.d.ts +12 -1
  241. package/dist/provider/desktop.d.ts +3 -0
  242. package/dist/provider/desktop.js +7 -4
  243. package/dist/provider/menu-groups.d.ts +3 -2
  244. package/dist/provider/menu-groups.js +13 -7
  245. package/dist/provider/missing-slot.d.ts +10 -0
  246. package/dist/provider/missing-slot.js +15 -0
  247. package/dist/provider/plain-input.d.ts +3 -2
  248. package/dist/provider/plain-input.js +3 -1
  249. package/dist/react.d.ts +3 -2
  250. package/dist/selection/SelectionBar.d.ts +18 -0
  251. package/dist/selection/SelectionBar.js +92 -0
  252. package/dist/selection/SelectionBarPhone.d.ts +3 -0
  253. package/dist/selection/SelectionBarPhone.js +14 -0
  254. package/dist/selection/bar-overflow.d.ts +12 -0
  255. package/dist/selection/bar-overflow.js +42 -0
  256. package/dist/selection/bar-parts.d.ts +15 -0
  257. package/dist/selection/bar-parts.js +17 -0
  258. package/dist/selection/index.d.ts +2 -0
  259. package/dist/selection/index.js +1 -0
  260. package/dist/selection/types.d.ts +3 -2
  261. package/dist/selection/verbs.d.ts +34 -0
  262. package/dist/selection/verbs.js +1 -0
  263. package/docs/contract.md +142 -39
  264. package/docs/getting-started.md +1 -1
  265. package/docs/guides/atoms.md +32 -4
  266. package/docs/guides/columns.md +1 -1
  267. package/docs/guides/display.md +1 -1
  268. package/docs/guides/editors.md +3 -3
  269. package/docs/guides/ports.md +1 -1
  270. package/docs/guides/selection.md +32 -20
  271. package/docs/guides/the-grid.md +43 -21
  272. package/docs/guides/the-provider.md +14 -4
  273. package/docs/index.md +2 -0
  274. package/docs/install.md +8 -1
  275. package/docs/reference/editors-date.md +2 -0
  276. package/docs/reference/editors-panel.md +4 -4
  277. package/docs/reference/editors-range.md +1 -1
  278. package/docs/reference/editors-relation.md +3 -3
  279. package/docs/reference/editors-select.md +1 -1
  280. package/docs/reference/editors-session.md +3 -2
  281. package/docs/reference/editors-value-list.md +1 -1
  282. package/docs/reference/field-row.md +2 -2
  283. package/docs/reference/grid.md +25 -6
  284. package/docs/reference/react.md +30 -8
  285. package/docs/reference/selection.md +10 -2
  286. package/docs/reference/views.md +42 -36
  287. package/package.json +22 -3
  288. package/skills/views/SKILL.md +3 -3
@@ -6,16 +6,25 @@ export function fieldKeyOf(col) {
6
6
  return col.field?.key ?? col.id;
7
7
  }
8
8
  export function fromListFilterRule(fieldKey, type, rule, part) {
9
- const whole = wholeFromListFilterRule(fieldKey, type, rule);
9
+ const read = wholeFromListFilterRule(fieldKey, type, rule);
10
+ const whole = read && VALUELESS.has(read.operator) ? { ...read, value: null } : read;
10
11
  return whole && part !== undefined ? { ...whole, part } : whole;
11
12
  }
13
+ const VALUELESS = new Set(["is_empty", "is_not_empty"]);
14
+ function numberEnds(value) {
15
+ return {
16
+ value: value[0] == null ? null : Number(value[0]),
17
+ value2: value[1] == null ? null : Number(value[1]),
18
+ };
19
+ }
12
20
  function wholeFromListFilterRule(fieldKey, type, rule) {
13
21
  switch (rule.editor) {
14
22
  case "text":
15
23
  return { fieldKey, operator: rule.operator, value: rule.query };
16
24
  case "number":
17
25
  return rule.operator === "between"
18
- ? { fieldKey, operator: "between", value: [rule.value ?? 0, rule.value2 ?? 0] }
26
+ ?
27
+ { fieldKey, operator: "between", value: [rule.value ?? null, rule.value2 ?? null] }
19
28
  : { fieldKey, operator: rule.operator, value: rule.value };
20
29
  case "date":
21
30
  if (rule.operator === "is_relative")
@@ -59,12 +68,7 @@ export function toListFilterRule(type, rule, opts) {
59
68
  case "percent":
60
69
  case "currency":
61
70
  if (Array.isArray(rule.value))
62
- return {
63
- editor: "number",
64
- operator: "between",
65
- value: Number(rule.value[0]),
66
- value2: Number(rule.value[1]),
67
- };
71
+ return { editor: "number", operator: "between", ...numberEnds(rule.value) };
68
72
  return {
69
73
  editor: "number",
70
74
  operator: rule.operator,
@@ -129,6 +133,14 @@ function partListFilterRule(type, rule, part) {
129
133
  const ops = operatorsFor(type, part);
130
134
  if (!ops.includes(rule.operator))
131
135
  return null;
136
+ if (type === "range")
137
+ return Array.isArray(rule.value)
138
+ ? { editor: "number", operator: "between", ...numberEnds(rule.value) }
139
+ : {
140
+ editor: "number",
141
+ operator: rule.operator,
142
+ value: typeof rule.value === "number" ? rule.value : null,
143
+ };
132
144
  if (ops[0] === "is_any_of")
133
145
  return rule.operator === "is_any_of" && Array.isArray(rule.value)
134
146
  ? { editor: "options", values: [...rule.value] }
@@ -142,7 +154,7 @@ function partListFilterRule(type, rule, part) {
142
154
  export function rootRulesByColumn(tree, columns, opts) {
143
155
  const out = {};
144
156
  for (const item of tree.items) {
145
- if (isFilterGroup(item) || isRelationRule(item))
157
+ if (isFilterGroup(item) || isRelationRule(item) || item.setAside)
146
158
  continue;
147
159
  const col = columns.find((c) => fieldKeyOf(c) === item.fieldKey);
148
160
  if (!col?.field)
@@ -153,31 +165,98 @@ export function rootRulesByColumn(tree, columns, opts) {
153
165
  }
154
166
  return out;
155
167
  }
156
- export function withRootRuleState(tree, columns, state, opts) {
157
- const named = rootRulesByColumn(tree, columns, opts);
158
- let next = tree;
168
+ function columnRows(columns, opts) {
169
+ const rows = [];
159
170
  for (const col of columns) {
160
171
  if (!col.field)
161
172
  continue;
162
- const parts = opts?.parts ? (FILTER_PART_ROWS[valueTypeOf(col.field)] ?? []) : [];
163
- for (const part of [undefined, ...parts]) {
164
- const key = part === undefined ? col.id : partKey(col.id, part);
165
- const rule = state[key] ?? null;
166
- if (rule || key in named)
167
- next = withRootRule(next, col, rule, part);
173
+ const type = valueTypeOf(col.field);
174
+ const fieldKey = fieldKeyOf(col);
175
+ rows.push({ key: col.id, fieldKey, type });
176
+ if (opts?.parts)
177
+ for (const part of FILTER_PART_ROWS[type] ?? [])
178
+ rows.push({ key: partKey(col.id, part), fieldKey, type, part });
179
+ }
180
+ return rows;
181
+ }
182
+ const quickRows = (fields) => fields.map((f) => ({ key: f.key, fieldKey: f.key, type: f.type }));
183
+ function sameValue(a, b) {
184
+ if (a === b)
185
+ return true;
186
+ if (Array.isArray(a) || Array.isArray(b))
187
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((x, i) => sameValue(x, b[i]));
188
+ if (a && b && typeof a === "object" && typeof b === "object") {
189
+ const keys = Object.keys(a);
190
+ return (keys.length === Object.keys(b).length &&
191
+ keys.every((k) => sameValue(a[k], b[k])));
192
+ }
193
+ return false;
194
+ }
195
+ function sameRule(a, b) {
196
+ if (a.fieldKey !== b.fieldKey || a.part !== b.part || a.operator !== b.operator)
197
+ return false;
198
+ return VALUELESS.has(a.operator) || sameValue(a.value, b.value);
199
+ }
200
+ function readRows(tree, rows) {
201
+ const rules = {};
202
+ const rest = [];
203
+ for (const item of tree.items) {
204
+ if (isFilterGroup(item) || isRelationRule(item) || item.setAside) {
205
+ rest.push(item);
206
+ continue;
168
207
  }
208
+ const row = rows.find((r) => !(r.key in rules) && r.fieldKey === item.fieldKey && r.part === item.part);
209
+ const rule = row ? toListFilterRule(row.type, item, { parts: true }) : null;
210
+ const back = row && rule ? fromListFilterRule(row.fieldKey, row.type, rule, row.part) : null;
211
+ if (row && rule && back && sameRule(back, item))
212
+ rules[row.key] = rule;
213
+ else
214
+ rest.push(item);
215
+ }
216
+ return { rules, rest };
217
+ }
218
+ function writeRows(op, rows, rules, rest) {
219
+ const items = [];
220
+ for (const row of rows) {
221
+ const rule = rules[row.key];
222
+ const next = rule ? fromListFilterRule(row.fieldKey, row.type, rule, row.part) : null;
223
+ if (next)
224
+ items.push(next);
225
+ }
226
+ return { op, items: [...items, ...rest] };
227
+ }
228
+ export function filterPanelFromTree(tree, columns, opts) {
229
+ return { op: tree.op, ...readRows(tree, columnRows(columns, opts)) };
230
+ }
231
+ export function treeFromFilterPanel(panel, columns, opts) {
232
+ return writeRows(panel.op, columnRows(columns, opts), panel.rules, panel.rest);
233
+ }
234
+ export function quickValuesFromTree(tree, fields) {
235
+ const out = {};
236
+ for (const [key, rule] of Object.entries(readRows(tree, quickRows(fields)).rules))
237
+ if (rule.editor === "options")
238
+ out[key] = rule.values;
239
+ return out;
240
+ }
241
+ export function withQuickValues(tree, fields, values) {
242
+ const rows = quickRows(fields);
243
+ const rules = {};
244
+ for (const f of fields) {
245
+ const picked = values[f.key];
246
+ if (picked?.length)
247
+ rules[f.key] = { editor: "options", values: [...picked] };
169
248
  }
170
- return next;
249
+ return writeRows(tree.op, rows, rules, readRows(tree, rows).rest);
171
250
  }
172
251
  export function rootRelationRules(tree) {
173
252
  const out = {};
174
253
  for (const item of tree.items)
175
- if (isRelationRule(item))
254
+ if (isRelationRule(item) && !item.setAside)
176
255
  out[item.fieldKey] = item;
177
256
  return out;
178
257
  }
179
258
  export function withRootRelationRules(tree, rules) {
180
- const kept = tree.items.filter((item) => !isRelationRule(item));
259
+ const kept = tree.items.filter((item) => !isRelationRule(item) || item.setAside);
181
260
  return { op: tree.op, items: [...kept, ...Object.values(rules)] };
182
261
  }
183
262
  export function withRootRule(tree, col, rule, part) {
@@ -185,6 +264,7 @@ export function withRootRule(tree, col, rule, part) {
185
264
  const type = col.field ? valueTypeOf(col.field) : undefined;
186
265
  const kept = tree.items.filter((item) => isFilterGroup(item) ||
187
266
  isRelationRule(item) ||
267
+ item.setAside ||
188
268
  item.fieldKey !== key ||
189
269
  item.part !== part ||
190
270
  (part !== undefined && (!type || !toListFilterRule(type, item, { parts: true }))));
@@ -3,8 +3,9 @@ import type { FieldConventions } from "@viewkitjs/fields";
3
3
  import { type ViewsMessageResolver } from "../contract.js";
4
4
  import type { ViewsAtoms } from "../atoms/types.js";
5
5
  import type { FieldPresentation } from "../display/options.js";
6
- import type { ViewsComponents } from "./components.js";
6
+ import type { ViewsComponents, ViewsMenuRoute, ViewsSelectionBarSettings, ViewsSheetActionsPlace } from "./components.js";
7
7
  import type { ViewsIcons } from "./icons.js";
8
+ import type { ViewsEscapeRules } from "../editors/escape-rule.js";
8
9
  import { type ViewsPorts } from "./ports.js";
9
10
  export { useViews, type ViewsContextValue } from "./context.js";
10
11
  export type ViewsProviderProps = {
@@ -25,6 +26,25 @@ export type ViewsProviderProps = {
25
26
  * elsewhere. Hand in the one your own shell switches on. Default `DEFAULT_DESKTOP_QUERY`,
26
27
  * `(min-width: 1024px)`. */
27
28
  desktopQuery?: string;
29
+ /** Where the editor panel's ✕ and ✓ stand on a phone. `bar` (the default): the panel draws its own
30
+ * bar inside your `Sheet`. `head`: your `Sheet` is handed them as `actions`, for its own head, and
31
+ * the panel draws no bar. */
32
+ sheetActions?: ViewsSheetActionsPlace;
33
+ /** What Escape does in an editor of each field type: `keep` keeps what was typed and closes, as a press
34
+ * outside does; a type left out throws the edit away. Desktop only: on a phone every way out of the
35
+ * sheet throws it away. Pass a module-level object. */
36
+ escape?: ViewsEscapeRules;
37
+ /** The grid says, through the toast port's `error`, why your app refused an edit it sent. Default false:
38
+ * your app says it. */
39
+ sayRefusals?: boolean;
40
+ /** How the grid opens its own menus. `popover` (the default): ViewKit's rows in your `Popover`. `menu`:
41
+ * your `Menu`, handed its rows as data, with the three hints a row may carry (`beside`, `keepOpen`,
42
+ * `detail`). */
43
+ menus?: ViewsMenuRoute;
44
+ /** Where the selection bar sits: its bottom, its layer and its classes on the desktop and on the phone,
45
+ * and the media query that makes it the phone's pill. Pass a module-level object. Default: 1rem above
46
+ * the screen's foot, layer 50, the pill wherever `desktopQuery` does not match. */
47
+ selectionBar?: ViewsSelectionBarSettings;
28
48
  children: ReactNode;
29
49
  };
30
- export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
50
+ export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, sheetActions, escape, sayRefusals, menus, selectionBar, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -5,18 +5,37 @@ import { resolveViewsMessage } from "../contract.js";
5
5
  import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
6
6
  import { ViewsContext } from "./context.js";
7
7
  import { PlainInput } from "./plain-input.js";
8
+ import { missingComponent, missingParts } from "./missing-slot.js";
8
9
  import { withSettledGroups } from "./menu-groups.js";
9
10
  import { DEFAULT_DESKTOP_QUERY } from "./desktop.js";
10
11
  import { browserConfirm } from "./ports.js";
11
12
  export { useViews } from "./context.js";
12
- export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, }) {
13
+ const MISSING_COMMAND_PARTS = missingParts("Command");
14
+ const MISSING_CALENDAR_COMPONENT = missingComponent("Calendar");
15
+ export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, sayRefusals = false, menus = "popover", selectionBar, }) {
13
16
  const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
14
17
  const settled = useMemo(() => ({
15
18
  ...components,
16
19
  Menu: withSettledGroups(components.Menu),
17
20
  Input: components.Input ?? PlainInput,
21
+ Command: components.Command ?? MISSING_COMMAND_PARTS,
22
+ Calendar: components.Calendar ?? MISSING_CALENDAR_COMPONENT,
18
23
  }), [components]);
19
24
  const resolved = useMemo(() => (ports.confirm ? ports : { ...ports, confirm: browserConfirm }), [ports]);
20
- const value = useMemo(() => ({ components: settled, atoms: merged, conventions, icons, ports: resolved, messages, presentation, desktopQuery }), [settled, merged, conventions, icons, resolved, messages, presentation, desktopQuery]);
25
+ const value = useMemo(() => ({
26
+ components: settled,
27
+ atoms: merged,
28
+ conventions,
29
+ icons,
30
+ ports: resolved,
31
+ messages,
32
+ presentation,
33
+ desktopQuery,
34
+ sheetActions,
35
+ escape,
36
+ sayRefusals,
37
+ menus,
38
+ selectionBar,
39
+ }), [settled, merged, conventions, icons, resolved, messages, presentation, desktopQuery, sheetActions, escape, sayRefusals, menus, selectionBar]);
21
40
  return _jsx(ViewsContext.Provider, { value: value, children: children });
22
41
  }
@@ -1,4 +1,6 @@
1
1
  import type { ComponentPropsWithRef, ComponentType, CSSProperties, KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent, ReactElement, ReactNode, Ref, RefObject } from "react";
2
+ import type { CategoryColor } from "@viewkitjs/fields/design/category-colors";
3
+ import type { StatusSlot } from "@viewkitjs/fields/design/status-slots";
2
4
  /** Where a floating part attaches: an element, a ref to one, or a point (a context menu). */
3
5
  export type ViewsAnchor = HTMLElement | RefObject<HTMLElement | null> | {
4
6
  x: number;
@@ -87,25 +89,42 @@ export type ViewsCheckboxProps = {
87
89
  /** A menu is data: the app draws it with its own primitive. */
88
90
  export type ViewsMenuItem = {
89
91
  key: string;
90
- label: ReactNode;
92
+ /** The row's words: always text, so a menu that writes its rows' names takes it as it is. */
93
+ label: string;
91
94
  icon?: ReactNode;
92
95
  onSelect?: () => void;
93
96
  disabled?: boolean;
97
+ /** Why a disabled row can't be used, in words: the app shows it (a tooltip, a second line). A row
98
+ * under a disabled group that gives none carries the group's. */
99
+ disabledReason?: string;
94
100
  destructive?: boolean;
95
- /** A checkable row: the app draws its tick. A checkable row closes the menu like any row. */
101
+ /** A checkable row: the app draws its tick. A checkable row closes the menu like any row, unless it
102
+ * asks to `keepOpen`. */
96
103
  checked?: boolean;
97
- /** A group: its rows drawn in place under this row's label, never a flyout. A group row is a
98
- * label, not a target: its own `onSelect`, `href` and `checked` are ignored. A disabled group
104
+ /** A group: its rows drawn in place under this row's label, unless it asks to open `beside`. A group
105
+ * row is a label, not a target: its own `onSelect`, `href` and `checked` are ignored. A disabled group
99
106
  * disables every row under it: the provider hands the app's `Menu` those rows already `disabled`. */
100
107
  children?: ViewsMenuItem[];
108
+ /** A group (`children`) that opens its rows beside the menu, one level in, rather than in place: its row
109
+ * shows its label and `detail` and opens on a hover, a press or →. A hint: an adapter with no flyouts
110
+ * draws the group in place under its label, as every group is drawn. Ignored on a row with no `children`. */
111
+ beside?: boolean;
112
+ /** A checkable row (`checked` set) that leaves the menu open when picked, so several can be ticked in
113
+ * turn. A hint: an adapter that ignores it closes the menu, as any row does. Ignored on a row that isn't
114
+ * checkable. */
115
+ keepOpen?: boolean;
116
+ /** The row's current value in words, drawn at its end ("2", "Short"): on a group that opens beside, the
117
+ * choice made in it. Optional for an adapter to draw: one that ignores it draws the label alone, and a
118
+ * group's choice still shows by its ticked row. */
119
+ detail?: string;
101
120
  separatorBefore?: boolean;
102
121
  /** A keyboard hint drawn at the row's end, never bound by the menu. */
103
122
  shortcut?: string;
104
123
  /** A link item: the row is an anchor and `onSelect` still fires. */
105
124
  href?: string;
106
125
  };
107
- /** Opens at `anchor`, with no trigger child and no flyouts: on Base UI, the menu's root,
108
- * positioner and popup, the anchor handed to the positioner. */
126
+ /** Opens at `anchor`, with no trigger child; a group opens beside it only where it asks to and the
127
+ * adapter can. On Base UI, the menu's root, positioner and popup, the anchor handed to the positioner. */
109
128
  export type ViewsMenuProps = {
110
129
  open: boolean;
111
130
  onOpenChange: ViewsOpenChange;
@@ -113,6 +132,9 @@ export type ViewsMenuProps = {
113
132
  items: ViewsMenuItem[];
114
133
  side?: ViewsSide;
115
134
  align?: ViewsAlign;
135
+ /** The menu's name, which a screen reader announces as it opens: the menu's `aria-label`. Every
136
+ * menu the package opens hands one. */
137
+ label?: string;
116
138
  className?: string;
117
139
  };
118
140
  /** The command list's parts, the shape both cmdk-based shadcn copies already have. */
@@ -169,6 +191,87 @@ export type ViewsCommandParts = {
169
191
  className?: string;
170
192
  }>;
171
193
  };
194
+ /** One row of an app's picker body, as data: the value it stands for, its words, and how they are dressed. */
195
+ export type ViewsPickerItem = {
196
+ value: string;
197
+ label: string;
198
+ /** A status's step: draw your status badge in this slot. */
199
+ slot?: StatusSlot;
200
+ /** A category's colour: draw your option chip or tag in it. */
201
+ color?: CategoryColor;
202
+ /** Your own glyph's name, as `AppIcon` draws it, before the words. */
203
+ icon?: string;
204
+ /** A quieter second line. */
205
+ line?: string;
206
+ /** The heading it stands under. */
207
+ group?: string;
208
+ disabled?: boolean;
209
+ /** A word at the row's end telling kinds apart in a list of several ("Person"). */
210
+ badge?: string;
211
+ /** The record's own glyph, drawn before its words, unsized; wins over `icon`. */
212
+ glyph?: ReactNode;
213
+ /** The record's picture, for an avatar. */
214
+ avatarUrl?: string | null;
215
+ /** The record's kind, as the app names it (for the avatar's shape): not the `badge` word. */
216
+ kind?: string;
217
+ };
218
+ /** A row that does something rather than pick (create a record with what was typed): picking it closes the
219
+ * editor, then runs it. */
220
+ export type ViewsPickerAction = {
221
+ key: string;
222
+ label: string;
223
+ icon?: ReactNode;
224
+ onSelect: () => void;
225
+ };
226
+ /** A whole pick list your app draws: its search, its rows, its empty row and its create row. The editor
227
+ * around it keeps the draft, Tab, Escape, the save and the phone's ✕ and ✓. */
228
+ export type ViewsPickerProps = {
229
+ /** The field's name: the list's accessible name. */
230
+ label: string;
231
+ items: ViewsPickerItem[];
232
+ /** Several values may be held. Default false. */
233
+ multiple?: boolean;
234
+ /** What is held: one value, or null when none; several, a list. */
235
+ value: string | string[] | null;
236
+ /** One: the pick, null for the empty row. Several: the whole new list, on every change. Nothing is
237
+ * saved until the editor closes. */
238
+ onValueChange: (value: string | string[] | null) => void;
239
+ /** A pick of one is made: the editor closes and saves it. */
240
+ onDone: () => void;
241
+ /** The empty row's words; absent, a value of one can't be emptied. */
242
+ empty?: string;
243
+ /** The search's words before anything is typed. */
244
+ search?: string;
245
+ /** Takes new values: handed what was typed, it returns the value made, which you then pick (one) or
246
+ * add (several). Absent, nothing typed is added. */
247
+ onCreate?: (typed: string) => string;
248
+ /** What was typed on what opened it: the list opens filtered by it, the search holding it. */
249
+ typed?: string;
250
+ /** Put the focus inside as it opens, without scrolling the page. */
251
+ autoFocus?: boolean;
252
+ /** `phone`: draw no ✕, ✓ or Cancel of your own (the editor's panel holds them), and hand every change
253
+ * through `onValueChange` as it is made. */
254
+ form: "computer" | "phone";
255
+ /** The editor filters or fetches: hand it every typed query, and draw `items` as they come, in order, never
256
+ * filtered again. */
257
+ onSearch?: (query: string) => void;
258
+ /** What the list is doing besides showing its rows: a first page in flight, or the last ask failed. */
259
+ doing?: "searching" | "failed";
260
+ /** Ask again after `doing: "failed"`. */
261
+ onRetry?: () => void;
262
+ /** More rows are to come: call it each time the list's end comes into view. */
263
+ onMore?: () => void;
264
+ /** Rows that do something rather than pick, drawn after the rows. */
265
+ actions?: ViewsPickerAction[];
266
+ /** Several held, one of them leading: which, a way to make another lead, and the words for both. A body
267
+ * that draws none of it leaves the first held value leading. */
268
+ lead?: {
269
+ value: string | null;
270
+ onLead: (value: string) => void;
271
+ label: string;
272
+ makeLabel: string;
273
+ };
274
+ };
172
275
  /** A calendar over ISO days (`YYYY-MM-DD`) and months (`YYYY-MM`); the app's date library stays its own. */
173
276
  export type ViewsCalendarProps = {
174
277
  value: string | null;
@@ -188,6 +291,37 @@ export type ViewsCalendarProps = {
188
291
  locale: string;
189
292
  className?: string;
190
293
  };
294
+ /** A quick pick a date body offers: a day the editor names, or `none`, which empties the field. */
295
+ export type ViewsDatePick = "today" | "tomorrow" | "next-monday" | "none";
296
+ /** A whole date body your app draws: its typed line, its days, its quick picks and its time. The editor
297
+ * around it keeps the draft, Tab, Escape, the save and the phone's ✕ and ✓. */
298
+ export type ViewsDateBodyProps = {
299
+ /** The field's name: the days' accessible name. */
300
+ label: string;
301
+ /** What is held, on the local calendar: a day ("2026-11-12"), a day and time ("2026-11-12T14:30"), or null. */
302
+ value: string | null;
303
+ /** Every change as it is made, in `value`'s shape: a day picked, a day typed once it reads as one, a time
304
+ * set, or null for the empty pick. Nothing is saved until the editor closes. */
305
+ onValueChange: (value: string | null) => void;
306
+ /** A pick that finishes the edit is made (a day on a field with no time, the empty pick): the editor
307
+ * closes and saves it. */
308
+ onDone: () => void;
309
+ /** It holds a time too. */
310
+ time: boolean;
311
+ /** It may be emptied: offer the `none` pick. */
312
+ empty: boolean;
313
+ /** The quick picks, in order: `next-monday` is the Monday after today (a week on when today is one). */
314
+ picks: ViewsDatePick[];
315
+ /** Today, on the local calendar ("YYYY-MM-DD"). */
316
+ today: string;
317
+ /** What was typed on what opened it: the line starts with it. */
318
+ typed?: string;
319
+ /** Put the focus inside as it opens, without scrolling the page. */
320
+ autoFocus: boolean;
321
+ /** `phone`: draw no ✕, ✓ or Cancel of your own (the editor's panel holds them), and hand every change
322
+ * through `onValueChange` as it is made. */
323
+ form: "computer" | "phone";
324
+ };
191
325
  export type ViewsCollapseProps = {
192
326
  open: boolean;
193
327
  children: ReactNode;
@@ -196,12 +330,53 @@ export type ViewsCollapseProps = {
196
330
  clipClassName?: string;
197
331
  durationMs?: number;
198
332
  };
333
+ /** One of the editor panel's buttons, handed to a Sheet that draws them in its own head: its
334
+ * accessible name and what a press does. The glyph is the app's (✕, ✓). */
335
+ export type ViewsSheetAction = {
336
+ label: string;
337
+ onPress: () => void;
338
+ };
339
+ /** The editor panel's ✕ and ✓. `close` throws the edit away, as a swipe does; `done` closes it as
340
+ * done, and is absent where the body saves on its pick (a pick of one), which needs no ✓. */
341
+ export type ViewsSheetActions = {
342
+ close: ViewsSheetAction;
343
+ done?: ViewsSheetAction;
344
+ };
345
+ /** Where the editor panel's ✕ and ✓ stand on a phone: `bar`, the panel's own bar inside the Sheet;
346
+ * `head`, handed to the Sheet as `actions` for its own head, with no bar. */
347
+ export type ViewsSheetActionsPlace = "bar" | "head";
348
+ /** How the grid opens its own menus (a column's, a footer's figure picker, a group's ⋯, Add column):
349
+ * `popover`, ViewKit's rows in your `Popover`; `menu`, your `Menu`, handed rows as data. The row menu and
350
+ * a command cell's menu always go through your `Menu`. */
351
+ export type ViewsMenuRoute = "popover" | "menu";
352
+ /** Where the selection bar's fixed box sits on one form. `bottom` is a CSS length (default
353
+ * `calc(1rem + env(safe-area-inset-bottom))`), `zIndex` its layer (default 50), and `className` the app's
354
+ * own classes on the box (a hook its CSS reads, a rule that hides the bar). */
355
+ export type ViewsBarPlacement = {
356
+ bottom?: string;
357
+ zIndex?: number;
358
+ className?: string;
359
+ };
360
+ /** The selection bar, as the app places it: on the desktop an island, on the phone a pill whose Actions
361
+ * open a sheet. `phoneQuery`, when handed, is the media query under which the bar is the phone's pill;
362
+ * without it the bar is the pill wherever the provider's `desktopQuery` does not match. */
363
+ export type ViewsSelectionBarSettings = {
364
+ phoneQuery?: string;
365
+ desktop?: ViewsBarPlacement;
366
+ phone?: ViewsBarPlacement;
367
+ };
199
368
  /** A phone sheet. `snap` is a hint: an app whose sheet has no snap points ignores it. */
200
369
  export type ViewsSheetProps = {
201
370
  open: boolean;
202
371
  onOpenChange: ViewsOpenChange;
203
372
  title?: ReactNode;
373
+ /** The title in words, whenever the title is words: the sheet's accessible name, and the title of
374
+ * a head that takes only text. Absent for a title that is something else (a header with a glyph). */
375
+ label?: string;
204
376
  description?: string;
377
+ /** The editor panel's ✕ and ✓, handed only when the provider's `sheetActions` is `head`: draw both
378
+ * in the sheet's head (no `done`, no ✓). With `bar`, the default, the panel draws them itself. */
379
+ actions?: ViewsSheetActions;
205
380
  snap?: "full" | "half" | "peek" | "auto";
206
381
  className?: string;
207
382
  children: ReactNode;
@@ -219,8 +394,12 @@ export type ViewsComponents = {
219
394
  Tooltip: ComponentType<ViewsTooltipProps>;
220
395
  Checkbox: ComponentType<ViewsCheckboxProps>;
221
396
  Menu: ComponentType<ViewsMenuProps>;
222
- Command: ViewsCommandParts;
223
- Calendar: ComponentType<ViewsCalendarProps>;
397
+ /** Optional: the editors' lists and the popover route's menus draw through it. An app that hands `Picker`
398
+ * and sets `menus: "menu"` needs none. Reached without one, it throws an error naming it. */
399
+ Command?: ViewsCommandParts;
400
+ /** Optional: the date editor draws its month through it. Handed `DateBody`, it is never reached.
401
+ * Reached without one, it throws an error naming it. */
402
+ Calendar?: ComponentType<ViewsCalendarProps>;
224
403
  Collapse: ComponentType<ViewsCollapseProps>;
225
404
  Sheet: ComponentType<ViewsSheetProps>;
226
405
  /** The app's own icon component by the app's own names, for glyphs a host
@@ -241,8 +420,17 @@ export type ViewsComponents = {
241
420
  /** Optional: every editor's single-line box draws through it. Left out, the provider draws a
242
421
  * plain `<input>`. */
243
422
  Input?: ComponentType<ViewsInputProps>;
423
+ /** Optional: a whole pick list your app draws. Handed one, the select, several-values, place and relation
424
+ * editors open it, handed their rows as data; left out, they draw from `Command`. */
425
+ Picker?: ComponentType<ViewsPickerProps>;
426
+ /** Optional: a whole date body your app draws. Handed one, the date editor opens it; left out, it draws
427
+ * its own line, quick days and time around `Calendar`. */
428
+ DateBody?: ComponentType<ViewsDateBodyProps>;
244
429
  };
245
- /** The map as the views read it: the optional slots filled, the app's or the package's default. */
430
+ /** The map as the views read it: `Input`, `Command` and `Calendar` always filled, the app's or the
431
+ * package's own; `Picker` and `DateBody` as the app handed them. */
246
432
  export type ViewsResolvedComponents = ViewsComponents & {
247
433
  Input: ComponentType<ViewsInputProps>;
434
+ Command: ViewsCommandParts;
435
+ Calendar: ComponentType<ViewsCalendarProps>;
248
436
  };
@@ -2,9 +2,10 @@ import type { FieldConventions } from "@viewkitjs/fields";
2
2
  import type { ViewsMessageResolver } from "../contract.js";
3
3
  import type { ViewsAtoms } from "../atoms/types.js";
4
4
  import type { FieldPresentation } from "../display/options.js";
5
- import type { ViewsResolvedComponents } from "./components.js";
5
+ import type { ViewsMenuRoute, ViewsResolvedComponents, ViewsSelectionBarSettings, ViewsSheetActionsPlace } from "./components.js";
6
6
  import type { ViewsIcons } from "./icons.js";
7
7
  import type { ViewsResolvedPorts } from "./ports.js";
8
+ import type { ViewsEscapeRules } from "../editors/escape-rule.js";
8
9
  export type ViewsContextValue = {
9
10
  /** The app's components, with the optional ones filled: the app's own, or the package's plain default. */
10
11
  components: ViewsResolvedComponents;
@@ -18,6 +19,16 @@ export type ViewsContextValue = {
18
19
  presentation?: (defaults: FieldPresentation) => FieldPresentation;
19
20
  /** The media query that means a desktop: the app's own, or `DEFAULT_DESKTOP_QUERY`. */
20
21
  desktopQuery: string;
22
+ /** Where the editor panel's ✕ and ✓ stand on a phone. Absent means `bar`. */
23
+ sheetActions?: ViewsSheetActionsPlace;
24
+ /** What Escape does per field type (`ViewsProvider`'s `escape`); absent, every type throws the edit away. */
25
+ escape?: ViewsEscapeRules;
26
+ /** The grid says why the app refused an edit it sent (`ViewsProvider`'s `sayRefusals`); absent, it says nothing. */
27
+ sayRefusals?: boolean;
28
+ /** How the grid opens its own menus (`ViewsProvider`'s `menus`). Absent means `popover`. */
29
+ menus?: ViewsMenuRoute;
30
+ /** Where the selection bar sits (`ViewsProvider`'s `selectionBar`); absent, the package's defaults. */
31
+ selectionBar?: ViewsSelectionBarSettings;
21
32
  };
22
33
  export declare const ViewsContext: import("react").Context<ViewsContextValue | null>;
23
34
  export declare function useViews(): ViewsContextValue;
@@ -7,3 +7,6 @@ export declare function isDesktopNow(query: string): boolean;
7
7
  /** Whether the screen is a desktop, by the provider's `desktopQuery`: true where there is no
8
8
  * `matchMedia`. It follows the query's changes. The package's own: no entry point exports it. */
9
9
  export declare function useDesktop(): boolean;
10
+ /** Whether `query` matches the screen, following its changes. `fallback` is the answer where the screen
11
+ * can't be asked (a server render, no `matchMedia`). The package's own: no entry point exports it. */
12
+ export declare function useMediaQuery(query: string, fallback: boolean): boolean;
@@ -10,13 +10,16 @@ export function isDesktopNow(query) {
10
10
  }
11
11
  export function useDesktop() {
12
12
  const { desktopQuery } = useViews();
13
+ return useMediaQuery(desktopQuery, true);
14
+ }
15
+ export function useMediaQuery(query, fallback) {
13
16
  const subscribe = useCallback((onChange) => {
14
17
  if (!canAsk())
15
18
  return () => { };
16
- const list = window.matchMedia(desktopQuery);
19
+ const list = window.matchMedia(query);
17
20
  list.addEventListener("change", onChange);
18
21
  return () => list.removeEventListener("change", onChange);
19
- }, [desktopQuery]);
20
- const read = () => isDesktopNow(desktopQuery);
21
- return useSyncExternalStore(subscribe, read, () => true);
22
+ }, [query]);
23
+ const read = () => (canAsk() ? window.matchMedia(query).matches : fallback);
24
+ return useSyncExternalStore(subscribe, read, () => fallback);
22
25
  }
@@ -1,7 +1,8 @@
1
1
  import { type ComponentType } from "react";
2
2
  import type { ViewsMenuItem, ViewsMenuProps } from "./components.js";
3
- /** The items with every row under a disabled group marked `disabled`, at every depth. Only the
4
- * path to a disabled group is copied; with none, the same array comes back. */
3
+ /** The items with every row under a disabled group marked `disabled`, at every depth, each row that
4
+ * gives no reason carrying the group's. Only the path to a disabled group is copied; with none, the
5
+ * same array comes back. */
5
6
  export declare function settleMenuGroups(items: ViewsMenuItem[]): ViewsMenuItem[];
6
7
  /** The app's Menu, handed its items settled. One wrapper per app Menu, so an open menu never
7
8
  * remounts; a wrapper handed in again (a nested provider) comes back as it is. */
@@ -1,17 +1,23 @@
1
1
  import { createElement, useMemo } from "react";
2
- function disableAll(items) {
3
- return items.map((item) => ({
4
- ...item,
5
- disabled: true,
6
- ...(item.children && { children: disableAll(item.children) }),
7
- }));
2
+ function disableAll(items, reason) {
3
+ return items.map((item) => {
4
+ const own = item.disabledReason ?? reason;
5
+ return {
6
+ ...item,
7
+ disabled: true,
8
+ ...(own !== undefined && { disabledReason: own }),
9
+ ...(item.children && { children: disableAll(item.children, own) }),
10
+ };
11
+ });
8
12
  }
9
13
  export function settleMenuGroups(items) {
10
14
  let changed = false;
11
15
  const settled = items.map((item) => {
12
16
  if (!item.children || item.children.length === 0)
13
17
  return item;
14
- const children = item.disabled ? disableAll(item.children) : settleMenuGroups(item.children);
18
+ const children = item.disabled
19
+ ? disableAll(item.children, item.disabledReason)
20
+ : settleMenuGroups(item.children);
15
21
  if (children === item.children)
16
22
  return item;
17
23
  changed = true;
@@ -0,0 +1,10 @@
1
+ import type { ComponentType } from "react";
2
+ import type { ViewsCalendarProps, ViewsCommandParts } from "./components.js";
3
+ /** What a list says when it reaches the components map's `Command` and the app handed none. */
4
+ export declare const MISSING_COMMAND = "ViewKit drew a list through the components map's `Command`, and the app handed none. Hand `Command`, or hand `Picker` for the editors' lists and set the provider's `menus` to \"menu\" for the grid's menus.";
5
+ /** What the date editor says when it reaches the components map's `Calendar` and the app handed none. */
6
+ export declare const MISSING_CALENDAR = "ViewKit drew the date editor's month through the components map's `Calendar`, and the app handed none. Hand `Calendar`, or hand `DateBody`, your whole date body, which the date editor then opens instead.";
7
+ /** Parts standing in for a `Command` the app left out: each throws the error naming the slot. */
8
+ export declare function missingParts(name: "Command"): ViewsCommandParts;
9
+ /** A component standing in for a slot the app left out: it throws the error naming the slot. */
10
+ export declare function missingComponent(name: "Calendar"): ComponentType<ViewsCalendarProps>;