viewkitjs 0.29.0 → 0.30.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 (287) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/MIGRATION.md +97 -8
  3. package/package.json +1 -1
  4. package/views/dist/cells/cell-format.d.ts +2 -2
  5. package/views/dist/cells/cell-values.js +0 -2
  6. package/views/dist/contract.d.ts +15 -18
  7. package/views/dist/contract.js +13 -27
  8. package/views/dist/controls/controls.d.ts +2 -4
  9. package/views/dist/controls/controls.js +2 -2
  10. package/views/dist/controls/customize/customize.d.ts +51 -0
  11. package/views/dist/controls/customize/customize.js +128 -23
  12. package/views/dist/controls/customize/map-customize-body.d.ts +0 -3
  13. package/views/dist/controls/customize/map-customize-body.js +46 -11
  14. package/views/dist/controls/customize/map-ranges.d.ts +23 -0
  15. package/views/dist/controls/customize/map-ranges.js +41 -0
  16. package/views/dist/controls/customize/rules.d.ts +17 -1
  17. package/views/dist/controls/customize/rules.js +2 -0
  18. package/views/dist/controls/customize/words.d.ts +7 -0
  19. package/views/dist/controls/customize/words.js +5 -0
  20. package/views/dist/controls/customize.css +3 -0
  21. package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
  22. package/views/dist/controls/filter-editor/filter-editor.js +1 -0
  23. package/views/dist/controls/filter-editor/rules.d.ts +1 -2
  24. package/views/dist/controls/index.d.ts +8 -8
  25. package/views/dist/controls/index.js +8 -8
  26. package/views/dist/controls/menu-list/menu-list.d.ts +16 -1
  27. package/views/dist/controls/menu-list/menu-list.js +26 -8
  28. package/views/dist/controls/menu-list.css +8 -0
  29. package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +1 -1
  30. package/views/dist/controls/quick-filters/map-quick-filters-body.js +6 -3
  31. package/views/dist/controls/sheet/map-sheet.js +1 -1
  32. package/views/dist/controls/text-editor/map-text-body.d.ts +1 -1
  33. package/views/dist/controls/text-editor/map-text-body.js +2 -2
  34. package/views/dist/controls/text-editor/text-editor.d.ts +3 -0
  35. package/views/dist/controls/text-editor/text-editor.js +16 -2
  36. package/views/dist/controls/text-editor.css +11 -0
  37. package/views/dist/controls/values-editor/values.js +6 -2
  38. package/views/dist/display/options.d.ts +1 -1
  39. package/views/dist/display/rich-text.js +0 -1
  40. package/views/dist/editors/ChipsEditor.d.ts +4 -5
  41. package/views/dist/editors/ChipsEditor.js +12 -78
  42. package/views/dist/editors/DateEditor.d.ts +12 -16
  43. package/views/dist/editors/DateEditor.js +40 -191
  44. package/views/dist/editors/EditorPanel.d.ts +2 -6
  45. package/views/dist/editors/EditorPanel.js +2 -2
  46. package/views/dist/editors/LocationEditor.d.ts +11 -19
  47. package/views/dist/editors/LocationEditor.js +19 -211
  48. package/views/dist/editors/NameEditor.d.ts +8 -16
  49. package/views/dist/editors/NameEditor.js +11 -100
  50. package/views/dist/editors/NumberEditor.d.ts +14 -21
  51. package/views/dist/editors/NumberEditor.js +22 -49
  52. package/views/dist/editors/RangeEditor.d.ts +9 -33
  53. package/views/dist/editors/RangeEditor.js +12 -97
  54. package/views/dist/editors/RelationEditor.d.ts +6 -9
  55. package/views/dist/editors/RelationEditor.js +11 -30
  56. package/views/dist/editors/RelationSetEditor.d.ts +13 -24
  57. package/views/dist/editors/RelationSetEditor.js +33 -101
  58. package/views/dist/editors/SelectEditor.d.ts +15 -17
  59. package/views/dist/editors/SelectEditor.js +15 -94
  60. package/views/dist/editors/TextEditor.d.ts +23 -26
  61. package/views/dist/editors/TextEditor.js +11 -48
  62. package/views/dist/editors/ValueListEditor.d.ts +14 -23
  63. package/views/dist/editors/ValueListEditor.js +16 -202
  64. package/views/dist/editors/body-panel.d.ts +13 -7
  65. package/views/dist/editors/body-panel.js +3 -7
  66. package/views/dist/editors/edit-cores.d.ts +15 -15
  67. package/views/dist/editors/edit-cores.js +14 -14
  68. package/views/dist/editors/number-body.d.ts +1 -1
  69. package/views/dist/editors/number-step.d.ts +0 -34
  70. package/views/dist/editors/number-step.js +0 -37
  71. package/views/dist/editors/option-add-flow.d.ts +1 -13
  72. package/views/dist/editors/option-add-flow.js +0 -22
  73. package/views/dist/editors/relation-links-body.d.ts +2 -3
  74. package/views/dist/editors/relation-picker.d.ts +13 -3
  75. package/views/dist/editors/relation-source.d.ts +0 -22
  76. package/views/dist/editors/relation-source.js +0 -21
  77. package/views/dist/field-row/FieldRow.js +5 -6
  78. package/views/dist/field-row/FieldRowLane.js +0 -1
  79. package/views/dist/field-row/editors/RowChipsEditor.js +2 -2
  80. package/views/dist/field-row/editors/RowDateEditor.d.ts +2 -2
  81. package/views/dist/field-row/editors/RowDateEditor.js +2 -2
  82. package/views/dist/field-row/editors/RowNameEditor.d.ts +2 -5
  83. package/views/dist/field-row/editors/RowNameEditor.js +7 -12
  84. package/views/dist/field-row/editors/RowNumberEditor.d.ts +1 -1
  85. package/views/dist/field-row/editors/RowNumberEditor.js +4 -4
  86. package/views/dist/field-row/editors/RowPlaceEditor.js +3 -3
  87. package/views/dist/field-row/editors/RowRangeEditor.d.ts +2 -5
  88. package/views/dist/field-row/editors/RowRangeEditor.js +7 -14
  89. package/views/dist/field-row/editors/RowRelationEditor.js +3 -3
  90. package/views/dist/field-row/editors/RowSelectEditor.js +2 -2
  91. package/views/dist/field-row/editors/RowTextEditor.d.ts +1 -1
  92. package/views/dist/field-row/editors/RowTextEditor.js +3 -4
  93. package/views/dist/field-row/editors/RowValueListEditor.js +5 -5
  94. package/views/dist/field-row/field-row-button.d.ts +6 -9
  95. package/views/dist/field-row/field-row-button.js +1 -6
  96. package/views/dist/field-row/field-row-checkbox.d.ts +1 -1
  97. package/views/dist/field-row/row-target.d.ts +0 -7
  98. package/views/dist/field-row/row-target.js +0 -2
  99. package/views/dist/grid/chrome/GridAddColumn.d.ts +2 -1
  100. package/views/dist/grid/chrome/GridAddColumn.js +8 -66
  101. package/views/dist/grid/chrome/GridAggregateMenu.d.ts +5 -7
  102. package/views/dist/grid/chrome/GridAggregateMenu.js +20 -39
  103. package/views/dist/grid/chrome/GridCellEditors.d.ts +2 -2
  104. package/views/dist/grid/chrome/GridCellEditors.js +12 -12
  105. package/views/dist/grid/chrome/GridChipsEditor.js +3 -3
  106. package/views/dist/grid/chrome/GridColumnMenu.d.ts +11 -12
  107. package/views/dist/grid/chrome/GridColumnMenu.js +32 -93
  108. package/views/dist/grid/chrome/GridDateEditor.d.ts +6 -6
  109. package/views/dist/grid/chrome/GridDateEditor.js +3 -3
  110. package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -6
  111. package/views/dist/grid/chrome/GridGroupMenu.js +21 -62
  112. package/views/dist/grid/chrome/GridHeader.d.ts +1 -2
  113. package/views/dist/grid/chrome/GridHeader.js +2 -2
  114. package/views/dist/grid/chrome/GridLongTextEditor.d.ts +17 -38
  115. package/views/dist/grid/chrome/GridLongTextEditor.js +6 -7
  116. package/views/dist/grid/chrome/GridNameEditor.js +4 -4
  117. package/views/dist/grid/chrome/GridNumberEditor.d.ts +4 -5
  118. package/views/dist/grid/chrome/GridNumberEditor.js +3 -4
  119. package/views/dist/grid/chrome/GridPlaceEditor.d.ts +2 -5
  120. package/views/dist/grid/chrome/GridPlaceEditor.js +5 -5
  121. package/views/dist/grid/chrome/GridRangeEditor.d.ts +6 -12
  122. package/views/dist/grid/chrome/GridRangeEditor.js +7 -15
  123. package/views/dist/grid/chrome/GridRelationEditor.js +5 -5
  124. package/views/dist/grid/chrome/GridRow.js +0 -3
  125. package/views/dist/grid/chrome/GridRowActions.d.ts +1 -1
  126. package/views/dist/grid/chrome/GridRowActions.js +0 -5
  127. package/views/dist/grid/chrome/GridRowCells.js +9 -6
  128. package/views/dist/grid/chrome/GridSelectEditor.js +3 -3
  129. package/views/dist/grid/chrome/GridStructure.js +0 -1
  130. package/views/dist/grid/chrome/GridTable.js +1 -1
  131. package/views/dist/grid/chrome/GridTextEditor.d.ts +5 -7
  132. package/views/dist/grid/chrome/GridTextEditor.js +4 -17
  133. package/views/dist/grid/chrome/GridValueListEditor.js +4 -4
  134. package/views/dist/grid/chrome/grid-body-place.d.ts +2 -3
  135. package/views/dist/grid/chrome/grid-body-place.js +4 -8
  136. package/views/dist/grid/chrome/grid-button.d.ts +7 -10
  137. package/views/dist/grid/chrome/grid-button.js +1 -6
  138. package/views/dist/grid/chrome/grid-cell-classes.js +1 -1
  139. package/views/dist/grid/chrome/grid-column-menu-items.d.ts +4 -4
  140. package/views/dist/grid/chrome/grid-column-menu-items.js +10 -6
  141. package/views/dist/grid/chrome/grid-group-menu-parts.d.ts +5 -9
  142. package/views/dist/grid/chrome/grid-group-menu-parts.js +1 -3
  143. package/views/dist/grid/chrome/grid-hover.js +0 -1
  144. package/views/dist/grid/chrome/grid-menu-focus.d.ts +7 -31
  145. package/views/dist/grid/chrome/grid-menu-focus.js +7 -47
  146. package/views/dist/grid/chrome/grid-styles.d.ts +0 -3
  147. package/views/dist/grid/chrome/grid-styles.js +0 -1
  148. package/views/dist/grid/chrome/grid-table-props.d.ts +6 -10
  149. package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -4
  150. package/views/dist/grid/core/editing-controller.d.ts +2 -1
  151. package/views/dist/grid/core/editing-controller.js +10 -2
  152. package/views/dist/grid/core/refusal-sentence.d.ts +3 -0
  153. package/views/dist/grid/core/refusal-sentence.js +2 -2
  154. package/views/dist/grid/core/write-states.d.ts +3 -1
  155. package/views/dist/grid/core/write-states.js +6 -2
  156. package/views/dist/grid/grid.css +1 -1
  157. package/views/dist/model/body-frame.d.ts +0 -32
  158. package/views/dist/model/body-frame.js +1 -15
  159. package/views/dist/model/column-inspect.d.ts +5 -5
  160. package/views/dist/model/column-inspect.js +2 -2
  161. package/views/dist/panels/customize-body.d.ts +1 -10
  162. package/views/dist/panels/customize-body.js +0 -3
  163. package/views/dist/panels/filter/MenuSelect.js +0 -5
  164. package/views/dist/panels/filter/RangeFilterBody.js +0 -1
  165. package/views/dist/panels/filter/details.d.ts +1 -5
  166. package/views/dist/panels/filter/details.js +0 -13
  167. package/views/dist/panels/filter/filter-list.d.ts +0 -1
  168. package/views/dist/panels/filter/filter-list.js +1 -1
  169. package/views/dist/panels/panel-button.d.ts +10 -12
  170. package/views/dist/panels/panel-button.js +1 -6
  171. package/views/dist/panels/react/chrome.d.ts +0 -17
  172. package/views/dist/panels/react/chrome.js +0 -8
  173. package/views/dist/panels/react/customize-body.d.ts +9 -12
  174. package/views/dist/panels/react/customize-body.js +57 -11
  175. package/views/dist/panels/react/customize.d.ts +9 -12
  176. package/views/dist/panels/react/customize.js +3 -112
  177. package/views/dist/panels/react/filter/FilterEditor.d.ts +4 -18
  178. package/views/dist/panels/react/filter/FilterEditor.js +6 -330
  179. package/views/dist/panels/react/filter/FilterFieldList.d.ts +1 -1
  180. package/views/dist/panels/react/filter/FilterFieldList.js +27 -59
  181. package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +1 -11
  182. package/views/dist/panels/react/filter/PhoneFilterEditor.js +8 -144
  183. package/views/dist/panels/react/filter/editor-ctx.d.ts +1 -33
  184. package/views/dist/panels/react/filter/editor-ctx.js +5 -33
  185. package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -6
  186. package/views/dist/panels/react/filter/filter-part-body.js +0 -5
  187. package/views/dist/panels/react/filter/rule-writes.d.ts +1 -26
  188. package/views/dist/panels/react/filter/rule-writes.js +4 -95
  189. package/views/dist/panels/react/order-details.d.ts +1 -26
  190. package/views/dist/panels/react/order-details.js +3 -69
  191. package/views/dist/panels/react/panel-header.js +0 -1
  192. package/views/dist/panels/react/popover.d.ts +4 -7
  193. package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +2 -4
  194. package/views/dist/panels/react/quick/QuickFiltersPanel.js +16 -137
  195. package/views/dist/panels/react/sort/SortEditor.d.ts +4 -4
  196. package/views/dist/panels/react/sort/SortEditor.js +8 -245
  197. package/views/dist/panels/react/sort/SortFieldList.d.ts +1 -1
  198. package/views/dist/panels/react/sort/SortFieldList.js +11 -25
  199. package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +2 -2
  200. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -16
  201. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
  202. package/views/dist/panels/react/toolbar/ToolbarSave.js +0 -4
  203. package/views/dist/panels/react/toolbar/ToolbarSearch.js +0 -1
  204. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -3
  205. package/views/dist/panels/react/view-actions.js +0 -1
  206. package/views/dist/panels/react/views-row/FoldingViewRow.js +2 -5
  207. package/views/dist/panels/react/views-row/ViewCreatePill.js +0 -1
  208. package/views/dist/panels/react/views-row/ViewPicker.js +7 -43
  209. package/views/dist/panels/react/views-row/ViewPickerRow.js +0 -2
  210. package/views/dist/panels/react/views-row/menu-classes.d.ts +0 -4
  211. package/views/dist/panels/react/views-row/menu-classes.js +0 -2
  212. package/views/dist/panels/react.d.ts +5 -12
  213. package/views/dist/panels/react.js +5 -12
  214. package/views/dist/provider/ViewsProvider.d.ts +2 -46
  215. package/views/dist/provider/ViewsProvider.js +2 -22
  216. package/views/dist/provider/components.d.ts +153 -106
  217. package/views/dist/provider/context.d.ts +1 -21
  218. package/views/dist/provider/missing-slot.d.ts +3 -7
  219. package/views/dist/provider/missing-slot.js +2 -9
  220. package/views/dist/react.d.ts +1 -2
  221. package/views/dist/selection/SelectionBar.js +2 -3
  222. package/views/dist/styles.css +40 -168
  223. package/views/dist/styles.unlayered.css +40 -168
  224. package/views/docs/contract.md +99 -123
  225. package/views/docs/getting-started.md +222 -2
  226. package/views/docs/guides/cells.md +222 -2
  227. package/views/docs/guides/display.md +1 -1
  228. package/views/docs/guides/editors.md +235 -20
  229. package/views/docs/guides/ports.md +1 -1
  230. package/views/docs/guides/selection.md +1 -1
  231. package/views/docs/guides/the-grid.md +14 -16
  232. package/views/docs/guides/the-provider.md +9 -15
  233. package/views/docs/reference/cells.md +1 -1
  234. package/views/docs/reference/controls.md +26 -13
  235. package/views/docs/reference/editors-chips.md +2 -2
  236. package/views/docs/reference/editors-date.md +4 -4
  237. package/views/docs/reference/editors-location.md +4 -7
  238. package/views/docs/reference/editors-name.md +3 -5
  239. package/views/docs/reference/editors-number.md +10 -10
  240. package/views/docs/reference/editors-panel.md +3 -3
  241. package/views/docs/reference/editors-range.md +3 -5
  242. package/views/docs/reference/editors-relation.md +4 -4
  243. package/views/docs/reference/editors-select.md +3 -3
  244. package/views/docs/reference/editors-text.md +3 -4
  245. package/views/docs/reference/editors-value-list.md +3 -3
  246. package/views/docs/reference/field-row.md +1 -1
  247. package/views/docs/reference/grid.md +2 -2
  248. package/views/docs/reference/panels-react.md +20 -34
  249. package/views/docs/reference/react.md +11 -18
  250. package/views/docs/reference/views.md +5 -5
  251. package/views/skills/views/SKILL.md +1 -1
  252. package/views/dist/editors/relation-panel.d.ts +0 -69
  253. package/views/dist/editors/relation-panel.js +0 -46
  254. package/views/dist/grid/chrome/GridColumnColorSection.d.ts +0 -13
  255. package/views/dist/grid/chrome/GridColumnColorSection.js +0 -40
  256. package/views/dist/grid/chrome/GridColumnDateSection.d.ts +0 -28
  257. package/views/dist/grid/chrome/GridColumnDateSection.js +0 -23
  258. package/views/dist/grid/chrome/GridColumnDurationSection.d.ts +0 -23
  259. package/views/dist/grid/chrome/GridColumnDurationSection.js +0 -24
  260. package/views/dist/grid/chrome/GridColumnNumberSection.d.ts +0 -29
  261. package/views/dist/grid/chrome/GridColumnNumberSection.js +0 -27
  262. package/views/dist/grid/chrome/GridColumnPercentSection.d.ts +0 -16
  263. package/views/dist/grid/chrome/GridColumnPercentSection.js +0 -16
  264. package/views/dist/grid/chrome/GridColumnSortSection.d.ts +0 -38
  265. package/views/dist/grid/chrome/GridColumnSortSection.js +0 -33
  266. package/views/dist/grid/chrome/GridFlyout.d.ts +0 -44
  267. package/views/dist/grid/chrome/GridFlyout.js +0 -80
  268. package/views/dist/grid/chrome/GridMenuRow.d.ts +0 -15
  269. package/views/dist/grid/chrome/GridMenuRow.js +0 -15
  270. package/views/dist/grid/chrome/grid-menu-search.d.ts +0 -7
  271. package/views/dist/grid/chrome/grid-menu-search.js +0 -7
  272. package/views/dist/panels/react/GroupBucketsList.d.ts +0 -16
  273. package/views/dist/panels/react/GroupBucketsList.js +0 -44
  274. package/views/dist/panels/react/LayoutColumnsList.d.ts +0 -24
  275. package/views/dist/panels/react/LayoutColumnsList.js +0 -101
  276. package/views/dist/panels/react/PopoverColumnDetail.d.ts +0 -11
  277. package/views/dist/panels/react/PopoverColumnDetail.js +0 -24
  278. package/views/dist/panels/react/drag.d.ts +0 -2
  279. package/views/dist/panels/react/drag.js +0 -5
  280. package/views/dist/panels/react/layout-detail.d.ts +0 -4
  281. package/views/dist/panels/react/layout-detail.js +0 -29
  282. package/views/dist/panels/react/root-list.d.ts +0 -6
  283. package/views/dist/panels/react/root-list.js +0 -31
  284. package/views/dist/panels/react/sort/use-sort-drag.d.ts +0 -17
  285. package/views/dist/panels/react/sort/use-sort-drag.js +0 -39
  286. package/views/dist/panels/react/view-footer.d.ts +0 -20
  287. package/views/dist/panels/react/view-footer.js +0 -41
@@ -90,8 +90,9 @@ import { ICON_NAMES } from "viewkitjs/views";
90
90
  import type { ViewsComponents, ViewsIcons } from "viewkitjs/views/react";
91
91
 
92
92
  const components: ViewsComponents = {
93
- Button: ({ children, onClick, disabled, type = "button", className, title }) => (
94
- <button type={type} onClick={onClick} disabled={disabled} className={className} title={title}>
93
+ // It draws every button ViewKit draws itself, so it forwards the ref and every prop it is handed to its element.
94
+ Button: ({ children, variant: _variant, size: _size, type = "button", ...rest }) => (
95
+ <button type={type} {...rest}>
95
96
  {children}
96
97
  </button>
97
98
  ),
@@ -142,6 +143,225 @@ const components: ViewsComponents = {
142
143
  Sheet: ({ open, children }) => (open ? <div role="dialog">{children}</div> : null),
143
144
  AppIcon: ({ name, className }) => <i data-icon={name} className={className} />,
144
145
  Markdown: ({ source, className }) => <div className={className}>{source}</div>,
146
+ // The required bodies: a box for a text and one for a number, each handing every change as it is made, a pick list, a
147
+ // relation's links, a date, a name, a place or a range, and several values.
148
+ TextBody: ({ label, value, onValueChange, onDone }) => (
149
+ <input
150
+ aria-label={label}
151
+ value={value}
152
+ onChange={(event) => onValueChange(event.target.value)}
153
+ onKeyDown={(event) => event.key === "Enter" && onDone()}
154
+ />
155
+ ),
156
+ NumberBody: ({ label, value, onValueChange, onDone }) => (
157
+ <input
158
+ aria-label={label}
159
+ inputMode="decimal"
160
+ value={value == null || Number.isNaN(value) ? "" : String(value)}
161
+ onChange={(event) => onValueChange(event.target.value === "" ? null : Number(event.target.value))}
162
+ onKeyDown={(event) => event.key === "Enter" && onDone()}
163
+ />
164
+ ),
165
+ // A pick list: a row per item handed, a press picking one (or ticking it in a list of several).
166
+ Picker: ({ label, items, value, onValueChange, onDone, multiple }) => {
167
+ const held = Array.isArray(value) ? value : value === null ? [] : [value];
168
+ return (
169
+ <div role="listbox" aria-label={label}>
170
+ {items.map((item) => (
171
+ <div
172
+ key={item.value}
173
+ role="option"
174
+ aria-selected={held.includes(item.value)}
175
+ onClick={() => {
176
+ if (!multiple) return onValueChange(item.value), onDone();
177
+ onValueChange(held.includes(item.value) ? held.filter((v) => v !== item.value) : [...held, item.value]);
178
+ }}
179
+ >
180
+ {item.label}
181
+ </div>
182
+ ))}
183
+ </div>
184
+ );
185
+ },
186
+ // A relation's links: a row per record, a press linking or unlinking it, and Done.
187
+ LinksBody: ({ label, items, links, onLinksChange, onDone }) => (
188
+ <div role="listbox" aria-label={label}>
189
+ {items.map((item) => {
190
+ const linked = links.some((link) => link.value === item.value);
191
+ return (
192
+ <div
193
+ key={item.value}
194
+ role="option"
195
+ aria-selected={linked}
196
+ onClick={() =>
197
+ onLinksChange(linked ? links.filter((link) => link.value !== item.value) : [...links, { value: item.value, roles: [] }])
198
+ }
199
+ >
200
+ {item.label}
201
+ </div>
202
+ );
203
+ })}
204
+ <button type="button" onClick={onDone}>
205
+ Done
206
+ </button>
207
+ </div>
208
+ ),
209
+ // A date: a line holding the day ("YYYY-MM-DD", or with "THH:MM"), Enter for done.
210
+ // Uncontrolled: the editor takes only a whole date, so a line it held would undo every key typed on the way to one.
211
+ DateBody: ({ label, value, onValueChange, onDone }) => (
212
+ <input
213
+ aria-label={label}
214
+ defaultValue={value ?? ""}
215
+ onChange={(event) => onValueChange(event.target.value === "" ? null : event.target.value)}
216
+ onKeyDown={(event) => event.key === "Enter" && onDone()}
217
+ />
218
+ ),
219
+ // A name, a place or a range: a box per part, Enter for done.
220
+ PartsBody: (props) => {
221
+ const done = (event: { key: string }) => event.key === "Enter" && props.onDone();
222
+ if (props.kind === "range") {
223
+ const { value, onValueChange } = props;
224
+ const end = (text: string) => (text === "" ? null : Number(text));
225
+ return (
226
+ <div role="group" aria-label={props.label}>
227
+ <input aria-label="From" value={value.low ?? ""} onChange={(event) => onValueChange({ ...value, low: end(event.target.value) })} onKeyDown={done} />
228
+ <input aria-label="To" value={value.high ?? ""} onChange={(event) => onValueChange({ ...value, high: end(event.target.value) })} onKeyDown={done} />
229
+ </div>
230
+ );
231
+ }
232
+ if (props.kind === "name") {
233
+ const { value, onValueChange } = props;
234
+ return (
235
+ <div role="group" aria-label={props.label}>
236
+ {(["given", "family", "full"] as const).map((part) => (
237
+ <input key={part} aria-label={part} value={value[part]} onChange={(event) => onValueChange({ ...value, [part]: event.target.value })} onKeyDown={done} />
238
+ ))}
239
+ </div>
240
+ );
241
+ }
242
+ const { value, onValueChange } = props;
243
+ return (
244
+ <div role="group" aria-label={props.label}>
245
+ {props.parts.map((part) => (
246
+ <input key={part} aria-label={props.words[part]} value={value[part] ?? ""} onChange={(event) => onValueChange({ ...value, [part]: event.target.value })} onKeyDown={done} />
247
+ ))}
248
+ </div>
249
+ );
250
+ },
251
+ // Several emails, phones, links or domains: a box per value, and a line that adds one on Enter (Enter on it empty is done).
252
+ ValuesBody: ({ label, value, onValueChange, onDone }) => (
253
+ <div role="group" aria-label={label}>
254
+ {value.map((line, at) => (
255
+ <input
256
+ key={at}
257
+ aria-label={label}
258
+ value={line.value}
259
+ onChange={(event) => onValueChange(value.map((each, i) => (i === at ? { ...each, value: event.target.value } : each)))}
260
+ />
261
+ ))}
262
+ <input
263
+ aria-label={`Add to ${label}`}
264
+ onKeyDown={(event) => {
265
+ if (event.key !== "Enter") return;
266
+ const text = event.currentTarget.value.trim();
267
+ if (text === "") return onDone();
268
+ onValueChange([...value, { value: text, main: value.length === 0 }]);
269
+ event.currentTarget.value = "";
270
+ }}
271
+ />
272
+ </div>
273
+ ),
274
+ // The toolbar's panels: your app draws each whole body (CONTROLS hands ViewKit's own). Here, each at its plainest.
275
+ SortBody: ({ label, options, onRulesChange, onDone }) => (
276
+ <div role="group" aria-label={label}>
277
+ {options.map((option) => (
278
+ <button key={option.value} type="button" onClick={() => onRulesChange([{ value: option.value, dir: "asc" }])}>
279
+ {option.label}
280
+ </button>
281
+ ))}
282
+ <button type="button" onClick={onDone}>
283
+ Done
284
+ </button>
285
+ </div>
286
+ ),
287
+ FilterBody: ({ label, filter, onFilterChange, onDone }) => (
288
+ <div role="group" aria-label={label}>
289
+ <button type="button" onClick={() => onFilterChange({ ...filter, items: [] })}>
290
+ Clear all
291
+ </button>
292
+ <button type="button" onClick={onDone}>
293
+ Done
294
+ </button>
295
+ </div>
296
+ ),
297
+ FilterPartBody: ({ label, rule, ways, onRuleChange, onDone }) => (
298
+ <div role="group" aria-label={label}>
299
+ {ways.map((way) => (
300
+ <button key={way.value} type="button" onClick={() => onRuleChange({ ...rule, operator: way.value })}>
301
+ {way.label}
302
+ </button>
303
+ ))}
304
+ <button type="button" onClick={onDone}>
305
+ Done
306
+ </button>
307
+ </div>
308
+ ),
309
+ FieldsBody: ({ label, fields, onPick }) => (
310
+ <div role="listbox" aria-label={label}>
311
+ {fields.map((field) => (
312
+ <div key={field.key} role="option" aria-selected={false} onClick={() => onPick(field.key)}>
313
+ {field.label}
314
+ </div>
315
+ ))}
316
+ </div>
317
+ ),
318
+ QuickFiltersBody: ({ label, fields, onHoldChange }) => (
319
+ <div role="group" aria-label={label}>
320
+ {fields.flatMap((field) =>
321
+ field.values.map((value) => (
322
+ <button
323
+ key={`${field.key}:${value.value}`}
324
+ type="button"
325
+ aria-pressed={value.held}
326
+ onClick={() => onHoldChange([{ fieldKey: field.key, values: [value.value] }])}
327
+ >
328
+ {value.label}
329
+ </button>
330
+ ))
331
+ )}
332
+ </div>
333
+ ),
334
+ ViewsListBody: ({ label, views, value, onViewChange, onDone }) => (
335
+ <div role="listbox" aria-label={label}>
336
+ {views.map((view) => (
337
+ <div
338
+ key={view.value}
339
+ role="option"
340
+ aria-selected={view.value === value}
341
+ onClick={() => {
342
+ onViewChange(view.value);
343
+ onDone();
344
+ }}
345
+ >
346
+ {view.label}
347
+ </div>
348
+ ))}
349
+ </div>
350
+ ),
351
+ // Customize: your app draws its whole body (CONTROLS.CustomizeBody is ViewKit's own). Here, its name, the layout's toggles and Done.
352
+ CustomizeBody: ({ label, layout, onDone }) => (
353
+ <div role="group" aria-label={label}>
354
+ {(layout?.toggles ?? []).map((toggle) => (
355
+ <label key={toggle.key}>
356
+ <input type="checkbox" checked={toggle.value} onChange={(event) => toggle.onChange(event.target.checked)} />
357
+ {toggle.label}
358
+ </label>
359
+ ))}
360
+ <button type="button" onClick={onDone}>
361
+ Done
362
+ </button>
363
+ </div>
364
+ ),
145
365
  };
146
366
 
147
367
  // The glyphs the rendering asks for, by meaning: map each to your icon library's component.
@@ -184,8 +184,9 @@ import { NOOP_PORTS, ViewsProvider, type ViewsComponents, type ViewsIcons } from
184
184
  import { renderToStaticMarkup } from "react-dom/server";
185
185
 
186
186
  const components: ViewsComponents = {
187
- Button: ({ children, onClick, disabled, type = "button", className, title }) => (
188
- <button type={type} onClick={onClick} disabled={disabled} className={className} title={title}>
187
+ // It draws every button ViewKit draws itself, so it forwards the ref and every prop it is handed to its element.
188
+ Button: ({ children, variant: _variant, size: _size, type = "button", ...rest }) => (
189
+ <button type={type} {...rest}>
189
190
  {children}
190
191
  </button>
191
192
  ),
@@ -236,6 +237,225 @@ const components: ViewsComponents = {
236
237
  Sheet: ({ open, children }) => (open ? <div role="dialog">{children}</div> : null),
237
238
  AppIcon: ({ name, className }) => <i data-icon={name} className={className} />,
238
239
  Markdown: ({ source, className }) => <div className={className}>{source}</div>,
240
+ // The required bodies: a box for a text and one for a number, each handing every change as it is made, a pick list, a
241
+ // relation's links, a date, a name, a place or a range, and several values.
242
+ TextBody: ({ label, value, onValueChange, onDone }) => (
243
+ <input
244
+ aria-label={label}
245
+ value={value}
246
+ onChange={(event) => onValueChange(event.target.value)}
247
+ onKeyDown={(event) => event.key === "Enter" && onDone()}
248
+ />
249
+ ),
250
+ NumberBody: ({ label, value, onValueChange, onDone }) => (
251
+ <input
252
+ aria-label={label}
253
+ inputMode="decimal"
254
+ value={value == null || Number.isNaN(value) ? "" : String(value)}
255
+ onChange={(event) => onValueChange(event.target.value === "" ? null : Number(event.target.value))}
256
+ onKeyDown={(event) => event.key === "Enter" && onDone()}
257
+ />
258
+ ),
259
+ // A pick list: a row per item handed, a press picking one (or ticking it in a list of several).
260
+ Picker: ({ label, items, value, onValueChange, onDone, multiple }) => {
261
+ const held = Array.isArray(value) ? value : value === null ? [] : [value];
262
+ return (
263
+ <div role="listbox" aria-label={label}>
264
+ {items.map((item) => (
265
+ <div
266
+ key={item.value}
267
+ role="option"
268
+ aria-selected={held.includes(item.value)}
269
+ onClick={() => {
270
+ if (!multiple) return onValueChange(item.value), onDone();
271
+ onValueChange(held.includes(item.value) ? held.filter((v) => v !== item.value) : [...held, item.value]);
272
+ }}
273
+ >
274
+ {item.label}
275
+ </div>
276
+ ))}
277
+ </div>
278
+ );
279
+ },
280
+ // A relation's links: a row per record, a press linking or unlinking it, and Done.
281
+ LinksBody: ({ label, items, links, onLinksChange, onDone }) => (
282
+ <div role="listbox" aria-label={label}>
283
+ {items.map((item) => {
284
+ const linked = links.some((link) => link.value === item.value);
285
+ return (
286
+ <div
287
+ key={item.value}
288
+ role="option"
289
+ aria-selected={linked}
290
+ onClick={() =>
291
+ onLinksChange(linked ? links.filter((link) => link.value !== item.value) : [...links, { value: item.value, roles: [] }])
292
+ }
293
+ >
294
+ {item.label}
295
+ </div>
296
+ );
297
+ })}
298
+ <button type="button" onClick={onDone}>
299
+ Done
300
+ </button>
301
+ </div>
302
+ ),
303
+ // A date: a line holding the day ("YYYY-MM-DD", or with "THH:MM"), Enter for done.
304
+ // Uncontrolled: the editor takes only a whole date, so a line it held would undo every key typed on the way to one.
305
+ DateBody: ({ label, value, onValueChange, onDone }) => (
306
+ <input
307
+ aria-label={label}
308
+ defaultValue={value ?? ""}
309
+ onChange={(event) => onValueChange(event.target.value === "" ? null : event.target.value)}
310
+ onKeyDown={(event) => event.key === "Enter" && onDone()}
311
+ />
312
+ ),
313
+ // A name, a place or a range: a box per part, Enter for done.
314
+ PartsBody: (props) => {
315
+ const done = (event: { key: string }) => event.key === "Enter" && props.onDone();
316
+ if (props.kind === "range") {
317
+ const { value, onValueChange } = props;
318
+ const end = (text: string) => (text === "" ? null : Number(text));
319
+ return (
320
+ <div role="group" aria-label={props.label}>
321
+ <input aria-label="From" value={value.low ?? ""} onChange={(event) => onValueChange({ ...value, low: end(event.target.value) })} onKeyDown={done} />
322
+ <input aria-label="To" value={value.high ?? ""} onChange={(event) => onValueChange({ ...value, high: end(event.target.value) })} onKeyDown={done} />
323
+ </div>
324
+ );
325
+ }
326
+ if (props.kind === "name") {
327
+ const { value, onValueChange } = props;
328
+ return (
329
+ <div role="group" aria-label={props.label}>
330
+ {(["given", "family", "full"] as const).map((part) => (
331
+ <input key={part} aria-label={part} value={value[part]} onChange={(event) => onValueChange({ ...value, [part]: event.target.value })} onKeyDown={done} />
332
+ ))}
333
+ </div>
334
+ );
335
+ }
336
+ const { value, onValueChange } = props;
337
+ return (
338
+ <div role="group" aria-label={props.label}>
339
+ {props.parts.map((part) => (
340
+ <input key={part} aria-label={props.words[part]} value={value[part] ?? ""} onChange={(event) => onValueChange({ ...value, [part]: event.target.value })} onKeyDown={done} />
341
+ ))}
342
+ </div>
343
+ );
344
+ },
345
+ // Several emails, phones, links or domains: a box per value, and a line that adds one on Enter (Enter on it empty is done).
346
+ ValuesBody: ({ label, value, onValueChange, onDone }) => (
347
+ <div role="group" aria-label={label}>
348
+ {value.map((line, at) => (
349
+ <input
350
+ key={at}
351
+ aria-label={label}
352
+ value={line.value}
353
+ onChange={(event) => onValueChange(value.map((each, i) => (i === at ? { ...each, value: event.target.value } : each)))}
354
+ />
355
+ ))}
356
+ <input
357
+ aria-label={`Add to ${label}`}
358
+ onKeyDown={(event) => {
359
+ if (event.key !== "Enter") return;
360
+ const text = event.currentTarget.value.trim();
361
+ if (text === "") return onDone();
362
+ onValueChange([...value, { value: text, main: value.length === 0 }]);
363
+ event.currentTarget.value = "";
364
+ }}
365
+ />
366
+ </div>
367
+ ),
368
+ // The toolbar's panels: your app draws each whole body (CONTROLS hands ViewKit's own). Here, each at its plainest.
369
+ SortBody: ({ label, options, onRulesChange, onDone }) => (
370
+ <div role="group" aria-label={label}>
371
+ {options.map((option) => (
372
+ <button key={option.value} type="button" onClick={() => onRulesChange([{ value: option.value, dir: "asc" }])}>
373
+ {option.label}
374
+ </button>
375
+ ))}
376
+ <button type="button" onClick={onDone}>
377
+ Done
378
+ </button>
379
+ </div>
380
+ ),
381
+ FilterBody: ({ label, filter, onFilterChange, onDone }) => (
382
+ <div role="group" aria-label={label}>
383
+ <button type="button" onClick={() => onFilterChange({ ...filter, items: [] })}>
384
+ Clear all
385
+ </button>
386
+ <button type="button" onClick={onDone}>
387
+ Done
388
+ </button>
389
+ </div>
390
+ ),
391
+ FilterPartBody: ({ label, rule, ways, onRuleChange, onDone }) => (
392
+ <div role="group" aria-label={label}>
393
+ {ways.map((way) => (
394
+ <button key={way.value} type="button" onClick={() => onRuleChange({ ...rule, operator: way.value })}>
395
+ {way.label}
396
+ </button>
397
+ ))}
398
+ <button type="button" onClick={onDone}>
399
+ Done
400
+ </button>
401
+ </div>
402
+ ),
403
+ FieldsBody: ({ label, fields, onPick }) => (
404
+ <div role="listbox" aria-label={label}>
405
+ {fields.map((field) => (
406
+ <div key={field.key} role="option" aria-selected={false} onClick={() => onPick(field.key)}>
407
+ {field.label}
408
+ </div>
409
+ ))}
410
+ </div>
411
+ ),
412
+ QuickFiltersBody: ({ label, fields, onHoldChange }) => (
413
+ <div role="group" aria-label={label}>
414
+ {fields.flatMap((field) =>
415
+ field.values.map((value) => (
416
+ <button
417
+ key={`${field.key}:${value.value}`}
418
+ type="button"
419
+ aria-pressed={value.held}
420
+ onClick={() => onHoldChange([{ fieldKey: field.key, values: [value.value] }])}
421
+ >
422
+ {value.label}
423
+ </button>
424
+ ))
425
+ )}
426
+ </div>
427
+ ),
428
+ ViewsListBody: ({ label, views, value, onViewChange, onDone }) => (
429
+ <div role="listbox" aria-label={label}>
430
+ {views.map((view) => (
431
+ <div
432
+ key={view.value}
433
+ role="option"
434
+ aria-selected={view.value === value}
435
+ onClick={() => {
436
+ onViewChange(view.value);
437
+ onDone();
438
+ }}
439
+ >
440
+ {view.label}
441
+ </div>
442
+ ))}
443
+ </div>
444
+ ),
445
+ // Customize: your app draws its whole body (CONTROLS.CustomizeBody is ViewKit's own). Here, its name, the layout's toggles and Done.
446
+ CustomizeBody: ({ label, layout, onDone }) => (
447
+ <div role="group" aria-label={label}>
448
+ {(layout?.toggles ?? []).map((toggle) => (
449
+ <label key={toggle.key}>
450
+ <input type="checkbox" checked={toggle.value} onChange={(event) => toggle.onChange(event.target.checked)} />
451
+ {toggle.label}
452
+ </label>
453
+ ))}
454
+ <button type="button" onClick={onDone}>
455
+ Done
456
+ </button>
457
+ </div>
458
+ ),
239
459
  };
240
460
 
241
461
  const icons = Object.fromEntries(
@@ -94,7 +94,7 @@ A field says what the value is. The rest arrives in `DisplayOptions`, from the s
94
94
 
95
95
  - The row's answers: `currency` (the code this value is in), `nameFallback` (the words for an empty name, say the person's email), `labelFallback` and `optionColors`.
96
96
  - The reader's choices: `dateStyle`, `durationStyle`, `decimals`, `withTime`, `percentDisplay` and `wrap`.
97
- - A boolean's verbs and words: `onToggle`, `booleanDisabled`, `booleanIcon`, `booleanCheckbox`, `marker`, `markerReason` and `onResolve`. `booleanCheckbox` is a checkbox control of yours (the components map's `Checkbox`): handed one, the checkbox style draws it alone in place of the tick box and its switch, as the grid does while the provider's `gridCheckboxes` is `checkbox`, and a field row while `fieldRowCheckboxes` is.
97
+ - A boolean's verbs and words: `onToggle`, `booleanDisabled`, `booleanIcon`, `booleanCheckbox`, `marker`, `markerReason` and `onResolve`. `booleanCheckbox` is a checkbox control of yours (the components map's `Checkbox`): handed one, the checkbox style draws it alone in place of the tick box and its switch, as the grid and a field row do.
98
98
  - A relation's: `entityIcon` and `relationWrap`.
99
99
  - `slotOwnsClick`, for a host whose own element is already the button, such as a calendar card: every core then draws bare content, with no link, no toggle and a count that opens nothing.
100
100
  - `hostOwnsPlainClick`, for a host whose plain click on a value is its own, as the grid's click selects its cell: an email, phone, url or domain stays a link, marked `data-cell-link`, but no longer stops its click, so your host decides (the grid follows it only on a ⌘- or Ctrl-click).