@viewkitjs/views 0.0.0-stage → 0.2.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 (451) hide show
  1. package/CHANGELOG.md +615 -0
  2. package/LICENSE.md +7 -0
  3. package/README.md +99 -2
  4. package/dist/atoms/CommandMenu.d.ts +2 -0
  5. package/dist/atoms/CommandMenu.js +20 -0
  6. package/dist/atoms/List.d.ts +2 -0
  7. package/dist/atoms/List.js +6 -0
  8. package/dist/atoms/LoadMore.d.ts +2 -0
  9. package/dist/atoms/LoadMore.js +25 -0
  10. package/dist/atoms/Loading.d.ts +2 -0
  11. package/dist/atoms/Loading.js +7 -0
  12. package/dist/atoms/PlatformMark.d.ts +2 -0
  13. package/dist/atoms/PlatformMark.js +4 -0
  14. package/dist/atoms/RelationLink.d.ts +2 -0
  15. package/dist/atoms/RelationLink.js +6 -0
  16. package/dist/atoms/Row.d.ts +3 -0
  17. package/dist/atoms/Row.js +30 -0
  18. package/dist/atoms/RowMenu.d.ts +2 -0
  19. package/dist/atoms/RowMenu.js +112 -0
  20. package/dist/atoms/StatusBadge.d.ts +2 -0
  21. package/dist/atoms/StatusBadge.js +7 -0
  22. package/dist/atoms/StatusMarker.d.ts +2 -0
  23. package/dist/atoms/StatusMarker.js +19 -0
  24. package/dist/atoms/Tag.d.ts +2 -0
  25. package/dist/atoms/Tag.js +13 -0
  26. package/dist/atoms/TickBox.d.ts +2 -0
  27. package/dist/atoms/TickBox.js +8 -0
  28. package/dist/atoms/defaults.d.ts +2 -0
  29. package/dist/atoms/defaults.js +27 -0
  30. package/dist/atoms/tones.d.ts +5 -0
  31. package/dist/atoms/tones.js +28 -0
  32. package/dist/atoms/types.d.ts +178 -0
  33. package/dist/atoms/types.js +3 -0
  34. package/dist/cells/cell-format.d.ts +138 -0
  35. package/dist/cells/cell-format.js +16 -0
  36. package/dist/cells/cell-title.d.ts +17 -0
  37. package/dist/cells/cell-title.js +8 -0
  38. package/dist/cells/cell-values.d.ts +28 -0
  39. package/dist/cells/cell-values.js +87 -0
  40. package/dist/cells/index.d.ts +4 -0
  41. package/dist/cells/index.js +4 -0
  42. package/dist/cells/legacy-field.d.ts +52 -0
  43. package/dist/cells/legacy-field.js +164 -0
  44. package/dist/cells/relation-wrap.d.ts +3 -0
  45. package/dist/cells/relation-wrap.js +24 -0
  46. package/dist/cells/use-cell-format.d.ts +5 -0
  47. package/dist/cells/use-cell-format.js +10 -0
  48. package/dist/contract.d.ts +461 -0
  49. package/dist/contract.js +682 -0
  50. package/dist/display/actor.d.ts +4 -0
  51. package/dist/display/actor.js +26 -0
  52. package/dist/display/boolean.d.ts +18 -0
  53. package/dist/display/boolean.js +43 -0
  54. package/dist/display/breakdown.d.ts +15 -0
  55. package/dist/display/breakdown.js +32 -0
  56. package/dist/display/currency.d.ts +9 -0
  57. package/dist/display/currency.js +29 -0
  58. package/dist/display/date.d.ts +12 -0
  59. package/dist/display/date.js +26 -0
  60. package/dist/display/display-cores.d.ts +31 -0
  61. package/dist/display/display-cores.js +57 -0
  62. package/dist/display/entity-chip.d.ts +26 -0
  63. package/dist/display/entity-chip.js +9 -0
  64. package/dist/display/format.d.ts +66 -0
  65. package/dist/display/format.js +190 -0
  66. package/dist/display/index.d.ts +8 -0
  67. package/dist/display/index.js +7 -0
  68. package/dist/display/link.d.ts +29 -0
  69. package/dist/display/link.js +50 -0
  70. package/dist/display/location.d.ts +8 -0
  71. package/dist/display/location.js +22 -0
  72. package/dist/display/multi-value.d.ts +18 -0
  73. package/dist/display/multi-value.js +28 -0
  74. package/dist/display/name.d.ts +6 -0
  75. package/dist/display/name.js +14 -0
  76. package/dist/display/number.d.ts +11 -0
  77. package/dist/display/number.js +27 -0
  78. package/dist/display/options.d.ts +153 -0
  79. package/dist/display/options.js +1 -0
  80. package/dist/display/percent.d.ts +4 -0
  81. package/dist/display/percent.js +40 -0
  82. package/dist/display/phone.d.ts +11 -0
  83. package/dist/display/phone.js +45 -0
  84. package/dist/display/range.d.ts +6 -0
  85. package/dist/display/range.js +29 -0
  86. package/dist/display/relation.d.ts +4 -0
  87. package/dist/display/relation.js +29 -0
  88. package/dist/display/rich-text.d.ts +10 -0
  89. package/dist/display/rich-text.js +34 -0
  90. package/dist/display/select.d.ts +6 -0
  91. package/dist/display/select.js +38 -0
  92. package/dist/display/text-class.d.ts +23 -0
  93. package/dist/display/text-class.js +5 -0
  94. package/dist/display/text.d.ts +19 -0
  95. package/dist/display/text.js +8 -0
  96. package/dist/display/use-display-options.d.ts +2 -0
  97. package/dist/display/use-display-options.js +14 -0
  98. package/dist/display/user.d.ts +11 -0
  99. package/dist/display/user.js +10 -0
  100. package/dist/display/value-list.d.ts +10 -0
  101. package/dist/display/value-list.js +12 -0
  102. package/dist/display/viewer.d.ts +4 -0
  103. package/dist/display/viewer.js +11 -0
  104. package/dist/display/web-href.d.ts +8 -0
  105. package/dist/display/web-href.js +12 -0
  106. package/dist/editors/ChipsEditor.d.ts +59 -0
  107. package/dist/editors/ChipsEditor.js +73 -0
  108. package/dist/editors/DateEditor.d.ts +25 -0
  109. package/dist/editors/DateEditor.js +122 -0
  110. package/dist/editors/LocationEditor.d.ts +22 -0
  111. package/dist/editors/LocationEditor.js +228 -0
  112. package/dist/editors/NameEditor.d.ts +22 -0
  113. package/dist/editors/NameEditor.js +92 -0
  114. package/dist/editors/NumberEditor.d.ts +67 -0
  115. package/dist/editors/NumberEditor.js +86 -0
  116. package/dist/editors/RangeEditor.d.ts +22 -0
  117. package/dist/editors/RangeEditor.js +70 -0
  118. package/dist/editors/RelationEditor.d.ts +65 -0
  119. package/dist/editors/RelationEditor.js +64 -0
  120. package/dist/editors/SelectEditor.d.ts +72 -0
  121. package/dist/editors/SelectEditor.js +59 -0
  122. package/dist/editors/ValueListEditor.d.ts +38 -0
  123. package/dist/editors/ValueListEditor.js +217 -0
  124. package/dist/editors/edit-cores.d.ts +83 -0
  125. package/dist/editors/edit-cores.js +38 -0
  126. package/dist/editors/edit-session.d.ts +74 -0
  127. package/dist/editors/edit-session.js +35 -0
  128. package/dist/editors/open-values.d.ts +28 -0
  129. package/dist/editors/open-values.js +26 -0
  130. package/dist/editors/relation-source.d.ts +66 -0
  131. package/dist/editors/relation-source.js +102 -0
  132. package/dist/fields/binding.d.ts +87 -0
  133. package/dist/fields/binding.js +117 -0
  134. package/dist/fields/currency.d.ts +82 -0
  135. package/dist/fields/currency.js +41 -0
  136. package/dist/fields/denomination.d.ts +42 -0
  137. package/dist/fields/denomination.js +11 -0
  138. package/dist/fields/edit-core-types.d.ts +40 -0
  139. package/dist/fields/edit-core-types.js +29 -0
  140. package/dist/fields/format-knobs.d.ts +34 -0
  141. package/dist/fields/format-knobs.js +36 -0
  142. package/dist/fields/menus.d.ts +28 -0
  143. package/dist/fields/menus.js +1 -0
  144. package/dist/fields/money.d.ts +60 -0
  145. package/dist/fields/money.js +78 -0
  146. package/dist/fields/number-edit.d.ts +11 -0
  147. package/dist/fields/number-edit.js +17 -0
  148. package/dist/fields/prepare-write.d.ts +55 -0
  149. package/dist/fields/prepare-write.js +67 -0
  150. package/dist/fields/relation-source-types.d.ts +54 -0
  151. package/dist/fields/relation-source-types.js +1 -0
  152. package/dist/figures.d.ts +52 -0
  153. package/dist/figures.js +63 -0
  154. package/dist/filters/date-filter.d.ts +2 -0
  155. package/dist/filters/date-filter.js +1 -0
  156. package/dist/filters/filter-model.d.ts +176 -0
  157. package/dist/filters/filter-model.js +41 -0
  158. package/dist/filters/number-filter.d.ts +2 -0
  159. package/dist/filters/number-filter.js +1 -0
  160. package/dist/filters/range-filter.d.ts +2 -0
  161. package/dist/filters/range-filter.js +1 -0
  162. package/dist/filters/registry.d.ts +103 -0
  163. package/dist/filters/registry.js +8 -0
  164. package/dist/filters/relation-filter.d.ts +16 -0
  165. package/dist/filters/relation-filter.js +53 -0
  166. package/dist/filters/text-filter.d.ts +2 -0
  167. package/dist/filters/text-filter.js +1 -0
  168. package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
  169. package/dist/grid/chrome/GridAddColumn.js +29 -0
  170. package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
  171. package/dist/grid/chrome/GridAggregateMenu.js +27 -0
  172. package/dist/grid/chrome/GridCellEditors.d.ts +64 -0
  173. package/dist/grid/chrome/GridCellEditors.js +55 -0
  174. package/dist/grid/chrome/GridCellOutline.d.ts +70 -0
  175. package/dist/grid/chrome/GridCellOutline.js +21 -0
  176. package/dist/grid/chrome/GridChipsEditor.d.ts +28 -0
  177. package/dist/grid/chrome/GridChipsEditor.js +40 -0
  178. package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
  179. package/dist/grid/chrome/GridColumnColorSection.js +40 -0
  180. package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
  181. package/dist/grid/chrome/GridColumnDateSection.js +23 -0
  182. package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
  183. package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
  184. package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
  185. package/dist/grid/chrome/GridColumnMenu.js +99 -0
  186. package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
  187. package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
  188. package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
  189. package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
  190. package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
  191. package/dist/grid/chrome/GridColumnSortSection.js +16 -0
  192. package/dist/grid/chrome/GridDateEditor.d.ts +22 -0
  193. package/dist/grid/chrome/GridDateEditor.js +31 -0
  194. package/dist/grid/chrome/GridFlyout.d.ts +44 -0
  195. package/dist/grid/chrome/GridFlyout.js +80 -0
  196. package/dist/grid/chrome/GridFooter.d.ts +23 -0
  197. package/dist/grid/chrome/GridFooter.js +81 -0
  198. package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
  199. package/dist/grid/chrome/GridGroupMenu.js +57 -0
  200. package/dist/grid/chrome/GridHeader.d.ts +61 -0
  201. package/dist/grid/chrome/GridHeader.js +37 -0
  202. package/dist/grid/chrome/GridLongTextEditor.d.ts +36 -0
  203. package/dist/grid/chrome/GridLongTextEditor.js +127 -0
  204. package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
  205. package/dist/grid/chrome/GridMenuRow.js +15 -0
  206. package/dist/grid/chrome/GridNameEditor.d.ts +19 -0
  207. package/dist/grid/chrome/GridNameEditor.js +36 -0
  208. package/dist/grid/chrome/GridNumberEditor.d.ts +35 -0
  209. package/dist/grid/chrome/GridNumberEditor.js +25 -0
  210. package/dist/grid/chrome/GridRangeEditor.d.ts +20 -0
  211. package/dist/grid/chrome/GridRangeEditor.js +25 -0
  212. package/dist/grid/chrome/GridRelationEditor.d.ts +21 -0
  213. package/dist/grid/chrome/GridRelationEditor.js +30 -0
  214. package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
  215. package/dist/grid/chrome/GridResizeHandle.js +19 -0
  216. package/dist/grid/chrome/GridRow.d.ts +25 -0
  217. package/dist/grid/chrome/GridRow.js +136 -0
  218. package/dist/grid/chrome/GridRowActions.d.ts +32 -0
  219. package/dist/grid/chrome/GridRowActions.js +25 -0
  220. package/dist/grid/chrome/GridRowCells.d.ts +4 -0
  221. package/dist/grid/chrome/GridRowCells.js +133 -0
  222. package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
  223. package/dist/grid/chrome/GridRowGlyph.js +13 -0
  224. package/dist/grid/chrome/GridSelectEditor.d.ts +18 -0
  225. package/dist/grid/chrome/GridSelectEditor.js +49 -0
  226. package/dist/grid/chrome/GridStructure.d.ts +48 -0
  227. package/dist/grid/chrome/GridStructure.js +45 -0
  228. package/dist/grid/chrome/GridTable.d.ts +4 -0
  229. package/dist/grid/chrome/GridTable.js +125 -0
  230. package/dist/grid/chrome/GridTableSurface.d.ts +15 -0
  231. package/dist/grid/chrome/GridTableSurface.js +6 -0
  232. package/dist/grid/chrome/GridTextEditor.d.ts +11 -0
  233. package/dist/grid/chrome/GridTextEditor.js +40 -0
  234. package/dist/grid/chrome/GridValueListEditor.d.ts +18 -0
  235. package/dist/grid/chrome/GridValueListEditor.js +36 -0
  236. package/dist/grid/chrome/StuckMarker.d.ts +16 -0
  237. package/dist/grid/chrome/StuckMarker.js +34 -0
  238. package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
  239. package/dist/grid/chrome/cell-clipboard.js +28 -0
  240. package/dist/grid/chrome/cells.d.ts +21 -0
  241. package/dist/grid/chrome/cells.js +20 -0
  242. package/dist/grid/chrome/checks.d.ts +35 -0
  243. package/dist/grid/chrome/checks.js +22 -0
  244. package/dist/grid/chrome/column-glyph.d.ts +14 -0
  245. package/dist/grid/chrome/column-glyph.js +44 -0
  246. package/dist/grid/chrome/editors.d.ts +9 -0
  247. package/dist/grid/chrome/editors.js +10 -0
  248. package/dist/grid/chrome/grid-cell-classes.d.ts +59 -0
  249. package/dist/grid/chrome/grid-cell-classes.js +30 -0
  250. package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
  251. package/dist/grid/chrome/grid-menu-search.js +7 -0
  252. package/dist/grid/chrome/grid-row-props.d.ts +131 -0
  253. package/dist/grid/chrome/grid-row-props.js +1 -0
  254. package/dist/grid/chrome/grid-styles.d.ts +37 -0
  255. package/dist/grid/chrome/grid-styles.js +8 -0
  256. package/dist/grid/chrome/grid-table-props.d.ts +173 -0
  257. package/dist/grid/chrome/grid-table-props.js +1 -0
  258. package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
  259. package/dist/grid/chrome/useGridBatchApi.js +35 -0
  260. package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
  261. package/dist/grid/chrome/useGridColumnLayout.js +206 -0
  262. package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
  263. package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
  264. package/dist/grid/chrome/useGridKeyboard.d.ts +47 -0
  265. package/dist/grid/chrome/useGridKeyboard.js +274 -0
  266. package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
  267. package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
  268. package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
  269. package/dist/grid/chrome/useGridRailReveal.js +67 -0
  270. package/dist/grid/chrome/useGridRangeActions.d.ts +49 -0
  271. package/dist/grid/chrome/useGridRangeActions.js +188 -0
  272. package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
  273. package/dist/grid/chrome/useGridRangeGestures.js +190 -0
  274. package/dist/grid/chrome/useGridRowContextMenu.d.ts +35 -0
  275. package/dist/grid/chrome/useGridRowContextMenu.js +127 -0
  276. package/dist/grid/chrome/useGridScaleStyles.d.ts +1 -0
  277. package/dist/grid/chrome/useGridScaleStyles.js +29 -0
  278. package/dist/grid/chrome/useGridScrollSync.d.ts +38 -0
  279. package/dist/grid/chrome/useGridScrollSync.js +176 -0
  280. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +55 -0
  281. package/dist/grid/chrome/useGridTableInteractionModel.js +197 -0
  282. package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
  283. package/dist/grid/chrome/useGridTableSelection.js +55 -0
  284. package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
  285. package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
  286. package/dist/grid/core/clipboard-model.d.ts +81 -0
  287. package/dist/grid/core/clipboard-model.js +291 -0
  288. package/dist/grid/core/column-values.d.ts +27 -0
  289. package/dist/grid/core/column-values.js +76 -0
  290. package/dist/grid/core/commit-model.d.ts +34 -0
  291. package/dist/grid/core/commit-model.js +3 -0
  292. package/dist/grid/core/coordinates.d.ts +48 -0
  293. package/dist/grid/core/coordinates.js +27 -0
  294. package/dist/grid/core/edit-values.d.ts +9 -0
  295. package/dist/grid/core/edit-values.js +1 -0
  296. package/dist/grid/core/editing-controller.d.ts +59 -0
  297. package/dist/grid/core/editing-controller.js +240 -0
  298. package/dist/grid/core/editing-model.d.ts +78 -0
  299. package/dist/grid/core/editing-model.js +136 -0
  300. package/dist/grid/core/grid-scale.d.ts +14 -0
  301. package/dist/grid/core/grid-scale.js +8 -0
  302. package/dist/grid/core/nav.d.ts +94 -0
  303. package/dist/grid/core/nav.js +92 -0
  304. package/dist/grid/core/pending-reconciliation.d.ts +50 -0
  305. package/dist/grid/core/pending-reconciliation.js +49 -0
  306. package/dist/grid/core/range-model.d.ts +25 -0
  307. package/dist/grid/core/range-model.js +59 -0
  308. package/dist/grid/core/spreadsheet-operations.d.ts +85 -0
  309. package/dist/grid/core/spreadsheet-operations.js +253 -0
  310. package/dist/grid/core/useGridEditing.d.ts +43 -0
  311. package/dist/grid/core/useGridEditing.js +90 -0
  312. package/dist/grid/core/useGridRange.d.ts +20 -0
  313. package/dist/grid/core/useGridRange.js +24 -0
  314. package/dist/grid/core/value-equality.d.ts +32 -0
  315. package/dist/grid/core/value-equality.js +34 -0
  316. package/dist/grid/index.d.ts +18 -0
  317. package/dist/grid/index.js +5 -0
  318. package/dist/grid/useGridTablePrefs.d.ts +50 -0
  319. package/dist/grid/useGridTablePrefs.js +101 -0
  320. package/dist/grouping/sort-groups.d.ts +18 -0
  321. package/dist/grouping/sort-groups.js +33 -0
  322. package/dist/grouping/types.d.ts +10 -0
  323. package/dist/grouping/types.js +1 -0
  324. package/dist/index.d.ts +28 -0
  325. package/dist/index.js +28 -0
  326. package/dist/internal/chip.d.ts +4 -0
  327. package/dist/internal/chip.js +3 -0
  328. package/dist/internal/cx.d.ts +3 -0
  329. package/dist/internal/cx.js +3 -0
  330. package/dist/internal/viewport.d.ts +5 -0
  331. package/dist/internal/viewport.js +29 -0
  332. package/dist/model/aggregates.d.ts +59 -0
  333. package/dist/model/aggregates.js +186 -0
  334. package/dist/model/card-density.d.ts +8 -0
  335. package/dist/model/card-density.js +10 -0
  336. package/dist/model/card-layout.d.ts +85 -0
  337. package/dist/model/card-layout.js +90 -0
  338. package/dist/model/column-capabilities.d.ts +162 -0
  339. package/dist/model/column-capabilities.js +233 -0
  340. package/dist/model/column-filters.d.ts +106 -0
  341. package/dist/model/column-filters.js +321 -0
  342. package/dist/model/column-format.d.ts +103 -0
  343. package/dist/model/column-format.js +1 -0
  344. package/dist/model/column-from.d.ts +28 -0
  345. package/dist/model/column-from.js +160 -0
  346. package/dist/model/column-inspect.d.ts +18 -0
  347. package/dist/model/column-inspect.js +6 -0
  348. package/dist/model/column-knobs.d.ts +20 -0
  349. package/dist/model/column-knobs.js +16 -0
  350. package/dist/model/column-money.d.ts +13 -0
  351. package/dist/model/column-money.js +27 -0
  352. package/dist/model/column-order.d.ts +36 -0
  353. package/dist/model/column-order.js +68 -0
  354. package/dist/model/column-schema.d.ts +335 -0
  355. package/dist/model/column-schema.js +1 -0
  356. package/dist/model/column-sort.d.ts +17 -0
  357. package/dist/model/column-sort.js +11 -0
  358. package/dist/model/column-state.d.ts +77 -0
  359. package/dist/model/column-state.js +95 -0
  360. package/dist/model/column-types.d.ts +109 -0
  361. package/dist/model/column-types.js +50 -0
  362. package/dist/model/column-warnings.d.ts +44 -0
  363. package/dist/model/column-warnings.js +24 -0
  364. package/dist/model/density.d.ts +3 -0
  365. package/dist/model/density.js +13 -0
  366. package/dist/model/field-type-of.d.ts +21 -0
  367. package/dist/model/field-type-of.js +11 -0
  368. package/dist/model/filter-capabilities.d.ts +1 -0
  369. package/dist/model/filter-capabilities.js +1 -0
  370. package/dist/model/index.d.ts +38 -0
  371. package/dist/model/index.js +20 -0
  372. package/dist/model/part-rows.d.ts +28 -0
  373. package/dist/model/part-rows.js +40 -0
  374. package/dist/model/preferences.d.ts +155 -0
  375. package/dist/model/preferences.js +84 -0
  376. package/dist/model/prefs-buckets.d.ts +173 -0
  377. package/dist/model/prefs-buckets.js +71 -0
  378. package/dist/model/relation-filters.d.ts +45 -0
  379. package/dist/model/relation-filters.js +78 -0
  380. package/dist/model/render-count.d.ts +2 -0
  381. package/dist/model/render-count.js +24 -0
  382. package/dist/model/row-icon.d.ts +23 -0
  383. package/dist/model/row-icon.js +5 -0
  384. package/dist/model/view-rules.d.ts +73 -0
  385. package/dist/model/view-rules.js +216 -0
  386. package/dist/provider/ViewsProvider.d.ts +26 -0
  387. package/dist/provider/ViewsProvider.js +16 -0
  388. package/dist/provider/components.d.ts +230 -0
  389. package/dist/provider/components.js +3 -0
  390. package/dist/provider/context.d.ts +20 -0
  391. package/dist/provider/context.js +10 -0
  392. package/dist/provider/icons.d.ts +6 -0
  393. package/dist/provider/icons.js +1 -0
  394. package/dist/provider/menu-groups.d.ts +8 -0
  395. package/dist/provider/menu-groups.js +38 -0
  396. package/dist/provider/ports.d.ts +57 -0
  397. package/dist/provider/ports.js +9 -0
  398. package/dist/react.d.ts +9 -0
  399. package/dist/react.js +4 -0
  400. package/dist/selection/SelectCheckbox.d.ts +17 -0
  401. package/dist/selection/SelectCheckbox.js +11 -0
  402. package/dist/selection/index.d.ts +7 -0
  403. package/dist/selection/index.js +6 -0
  404. package/dist/selection/model.d.ts +55 -0
  405. package/dist/selection/model.js +86 -0
  406. package/dist/selection/row-click.d.ts +35 -0
  407. package/dist/selection/row-click.js +20 -0
  408. package/dist/selection/types.d.ts +17 -0
  409. package/dist/selection/types.js +1 -0
  410. package/dist/selection/useCheckDragSelect.d.ts +61 -0
  411. package/dist/selection/useCheckDragSelect.js +165 -0
  412. package/dist/selection/useListSelection.d.ts +39 -0
  413. package/dist/selection/useListSelection.js +48 -0
  414. package/dist/selection/useListSelectionShortcuts.d.ts +6 -0
  415. package/dist/selection/useListSelectionShortcuts.js +14 -0
  416. package/dist/selection/useRestIntent.d.ts +18 -0
  417. package/dist/selection/useRestIntent.js +35 -0
  418. package/docs/contract.md +525 -0
  419. package/docs/getting-started.md +250 -0
  420. package/docs/guides/atoms.md +245 -0
  421. package/docs/guides/cells.md +302 -0
  422. package/docs/guides/columns.md +412 -0
  423. package/docs/guides/display.md +203 -0
  424. package/docs/guides/editors.md +404 -0
  425. package/docs/guides/ports.md +246 -0
  426. package/docs/guides/selection.md +270 -0
  427. package/docs/guides/the-grid.md +677 -0
  428. package/docs/guides/the-provider.md +446 -0
  429. package/docs/index.md +50 -0
  430. package/docs/install.md +67 -0
  431. package/docs/reference/cells.md +28 -0
  432. package/docs/reference/display.md +42 -0
  433. package/docs/reference/editors-chips.md +6 -0
  434. package/docs/reference/editors-date.md +6 -0
  435. package/docs/reference/editors-location.md +10 -0
  436. package/docs/reference/editors-name.md +6 -0
  437. package/docs/reference/editors-number.md +11 -0
  438. package/docs/reference/editors-open-values.md +9 -0
  439. package/docs/reference/editors-range.md +6 -0
  440. package/docs/reference/editors-relation.md +9 -0
  441. package/docs/reference/editors-select.md +8 -0
  442. package/docs/reference/editors-session.md +9 -0
  443. package/docs/reference/editors-value-list.md +6 -0
  444. package/docs/reference/editors.md +5 -0
  445. package/docs/reference/grid.md +39 -0
  446. package/docs/reference/react.md +86 -0
  447. package/docs/reference/selection.md +33 -0
  448. package/docs/reference/views.md +601 -0
  449. package/docs/reshaping.md +19 -0
  450. package/package.json +118 -3
  451. package/skills/views/SKILL.md +102 -0
@@ -0,0 +1,73 @@
1
+ import { type FieldType } from "@viewkitjs/fields";
2
+ import { type FilterRelationRule, type FilterRule, type FilterTree, type ViewFieldReader } from "@viewkitjs/fields/query";
3
+ import type { ListColumn } from "./column-schema.js";
4
+ import type { ListFilterRule, ListFilterRuleState } from "./preferences.js";
5
+ /** THE KEY A COLUMN IS KNOWN BY OFF THE GRID — its FIELD, when it has one, and
6
+ * otherwise its own id, which is the only name it has. Every surface that is
7
+ * not the grid (a saved view's rows, a drawer, a lock) asks under this: they
8
+ * share the field key and nothing else. `lockKeyOf` is this function under the
9
+ * name a lock site reads best. */
10
+ export declare function fieldKeyOf<Row>(col: ListColumn<Row>): string;
11
+ /**
12
+ * The Filter panel's editors speak `ListFilterRule` (one rule per column,
13
+ * keyed by column id); a saved view speaks `FilterRule` (keyed by field key,
14
+ * with the option-set operators). The panel keeps editing the ROOT level of a
15
+ * view's tree through these two conversions; nested groups pass through
16
+ * untouched and are drawn by the group editor.
17
+ */
18
+ export declare function fromListFilterRule(fieldKey: string, type: FieldType, rule: ListFilterRule,
19
+ /** The part of the value a part row's rule reads (VK-57); absent, the rule reads the whole value. */
20
+ part?: string): FilterRule | null;
21
+ export declare function toListFilterRule(type: FieldType, rule: FilterRule,
22
+ /** `parts`: a rule on one part of the value maps onto its part row's editor (VK-57). Without it, such a rule has
23
+ * no editor: the column's own row edits the whole value only. */
24
+ opts?: {
25
+ parts?: boolean;
26
+ }): ListFilterRule | null;
27
+ /** The root-level rules a column can edit, keyed by column id; with `parts`, a rule on one part of a value under its
28
+ * part key (`partKey(columnId, part)`). */
29
+ export declare function rootRulesByColumn<Row>(tree: FilterTree, columns: ListColumn<Row>[], opts?: {
30
+ parts?: boolean;
31
+ }): ListFilterRuleState;
32
+ /** The tree with its root rules replaced by `state`, a whole-value key per column and, with `parts`, a part key per
33
+ * part row. Groups, relation rules and every rule no panel row can name (a country `is_none_of`, a part no table
34
+ * lists, a whole rule `toListFilterRule` maps to null) are kept as they are, never cleared. */
35
+ export declare function withRootRuleState<Row>(tree: FilterTree, columns: ListColumn<Row>[], state: ListFilterRuleState, opts?: {
36
+ parts?: boolean;
37
+ }): FilterTree;
38
+ /** The root relation rules, by relation field key — the Filter panel's Related records rows (POR-704). */
39
+ export declare function rootRelationRules(tree: FilterTree): Record<string, FilterRelationRule>;
40
+ /** The tree with its root relation rules replaced by `rules`; every other rule and group untouched. */
41
+ export declare function withRootRelationRules(tree: FilterTree, rules: Readonly<Record<string, FilterRelationRule>>): FilterTree;
42
+ /** Replace (or drop, on null) the root rule for one column, or with `part` its rule on that part of the value; groups
43
+ * untouched. */
44
+ export declare function withRootRule<Row>(tree: FilterTree, col: ListColumn<Row>, rule: ListFilterRule | null, part?: string): FilterTree;
45
+ /**
46
+ * HOW A VIEW READS THIS LIST'S ROWS — the bridge from a field key to a value.
47
+ *
48
+ * A view names `stage`; the list holds a column whose `field.key` is `stage`
49
+ * and whose accessor knows how to reach it. Built from the columns rather than
50
+ * from a module's binding, because the binding layer is the module's and this
51
+ * one is the grid's: every list that carries typed columns already has
52
+ * everything needed here, and one that does not has no fields for a view to
53
+ * name in the first place.
54
+ *
55
+ * `accessor` WINS OVER `editAccessor` — a view reads what the reader sees.
56
+ * That is the contract `ViewFieldReader.read` already states ("the DISPLAY
57
+ * value — what the cell draws — so a rule compares what is on screen"), and it
58
+ * is the only reading under which a filter, a sort and a group agree with the
59
+ * column they are named after. The Transactions ledger is where the two come
60
+ * apart hardest: its Amount column converts every row into the display currency
61
+ * and signs it by direction, so `> 100` under the stored read would compare a
62
+ * hundred of whatever currency each row happens to be kept in; its Date column
63
+ * is the coalesced `occurred_at ?? expected_at`, so a rule under the stored read
64
+ * would drop every payment that has only ever been expected.
65
+ *
66
+ * `editAccessor` is the FALLBACK, for a column that draws itself and so has no
67
+ * display accessor at all (`accessor: null` — see `columnFrom`). It remains the
68
+ * right read for an EDITOR, which opens on the stored value, and every editing
69
+ * surface keeps preferring it (`clipboard-model`, `pending-reconciliation`,
70
+ * `card-edit`). Those two questions are different, and this is the one that asks
71
+ * what is on screen.
72
+ */
73
+ export declare function viewReaderFrom<Row>(columns: ListColumn<Row>[], decimals?: Record<string, number>): ViewFieldReader<Row>;
@@ -0,0 +1,216 @@
1
+ import { valueTypeOf } from "@viewkitjs/fields";
2
+ import { denominationOf } from "../fields/denomination.js";
3
+ import { isFilterGroup, isRelationRule, operatorsFor, } from "@viewkitjs/fields/query";
4
+ import { FILTER_PART_ROWS, partKey } from "./part-rows.js";
5
+ export function fieldKeyOf(col) {
6
+ return col.field?.key ?? col.id;
7
+ }
8
+ export function fromListFilterRule(fieldKey, type, rule, part) {
9
+ const whole = wholeFromListFilterRule(fieldKey, type, rule);
10
+ return whole && part !== undefined ? { ...whole, part } : whole;
11
+ }
12
+ function wholeFromListFilterRule(fieldKey, type, rule) {
13
+ switch (rule.editor) {
14
+ case "text":
15
+ return { fieldKey, operator: rule.operator, value: rule.query };
16
+ case "number":
17
+ return rule.operator === "between"
18
+ ? { fieldKey, operator: "between", value: [rule.value ?? 0, rule.value2 ?? 0] }
19
+ : { fieldKey, operator: rule.operator, value: rule.value };
20
+ case "date":
21
+ if (rule.operator === "is_relative")
22
+ return {
23
+ fieldKey,
24
+ operator: "is_relative",
25
+ value: { direction: rule.direction ?? "this", unit: rule.unit ?? "week" },
26
+ };
27
+ if (rule.operator === "is_between")
28
+ return { fieldKey, operator: "is_between", value: [rule.from ?? "", rule.to ?? ""] };
29
+ return { fieldKey, operator: rule.operator, value: rule.from ?? null };
30
+ case "options":
31
+ if (type === "boolean") {
32
+ if (rule.values.length !== 1)
33
+ return null;
34
+ return { fieldKey, operator: "is", value: rule.values[0] === "true" };
35
+ }
36
+ return rule.values.length ? { fieldKey, operator: "is_any_of", value: rule.values } : null;
37
+ case "range":
38
+ return rule.operator === "overlaps" || rule.operator === "within"
39
+ ? { fieldKey, operator: rule.operator, value: [rule.value ?? null, rule.value2 ?? null] }
40
+ : { fieldKey, operator: rule.operator, value: rule.value };
41
+ }
42
+ }
43
+ export function toListFilterRule(type, rule, opts) {
44
+ if (rule.part !== undefined)
45
+ return opts?.parts ? partListFilterRule(type, rule, rule.part) : null;
46
+ switch (type) {
47
+ case "text":
48
+ case "url":
49
+ case "domain":
50
+ case "email":
51
+ case "phone":
52
+ case "rich_text":
53
+ return {
54
+ editor: "text",
55
+ operator: rule.operator,
56
+ query: typeof rule.value === "string" ? rule.value : "",
57
+ };
58
+ case "number":
59
+ case "percent":
60
+ case "currency":
61
+ 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
+ };
68
+ return {
69
+ editor: "number",
70
+ operator: rule.operator,
71
+ value: typeof rule.value === "number" ? rule.value : null,
72
+ };
73
+ case "date":
74
+ case "datetime": {
75
+ const v = rule.value;
76
+ if (rule.operator === "is_relative" && v && typeof v === "object" && "direction" in v)
77
+ return { editor: "date", operator: "is_relative", direction: v.direction, unit: v.unit };
78
+ if (Array.isArray(v))
79
+ return { editor: "date", operator: "is_between", from: String(v[0]), to: String(v[1]) };
80
+ return {
81
+ editor: "date",
82
+ operator: rule.operator,
83
+ from: typeof v === "string" ? v : null,
84
+ };
85
+ }
86
+ case "select":
87
+ case "status":
88
+ case "multiselect":
89
+ case "relation":
90
+ case "user":
91
+ case "actor":
92
+ return rule.operator === "is_any_of" && Array.isArray(rule.value)
93
+ ? { editor: "options", values: [...rule.value] }
94
+ : null;
95
+ case "boolean":
96
+ return rule.operator === "is"
97
+ ? { editor: "options", values: [String(rule.value === true)] }
98
+ : null;
99
+ case "range":
100
+ return Array.isArray(rule.value)
101
+ ? {
102
+ editor: "range",
103
+ operator: rule.operator,
104
+ value: rule.value[0] ?? null,
105
+ value2: rule.value[1] ?? null,
106
+ }
107
+ : {
108
+ editor: "range",
109
+ operator: rule.operator,
110
+ value: typeof rule.value === "number" ? rule.value : null,
111
+ };
112
+ case "location":
113
+ return null;
114
+ case "name":
115
+ return {
116
+ editor: "text",
117
+ operator: rule.operator,
118
+ query: typeof rule.value === "string" ? rule.value : "",
119
+ };
120
+ case "lookup":
121
+ case "rollup":
122
+ case "formula":
123
+ return null;
124
+ }
125
+ }
126
+ function partListFilterRule(type, rule, part) {
127
+ if (!FILTER_PART_ROWS[type]?.includes(part))
128
+ return null;
129
+ const ops = operatorsFor(type, part);
130
+ if (!ops.includes(rule.operator))
131
+ return null;
132
+ if (ops[0] === "is_any_of")
133
+ return rule.operator === "is_any_of" && Array.isArray(rule.value)
134
+ ? { editor: "options", values: [...rule.value] }
135
+ : null;
136
+ return {
137
+ editor: "text",
138
+ operator: rule.operator,
139
+ query: typeof rule.value === "string" ? rule.value : "",
140
+ };
141
+ }
142
+ export function rootRulesByColumn(tree, columns, opts) {
143
+ const out = {};
144
+ for (const item of tree.items) {
145
+ if (isFilterGroup(item) || isRelationRule(item))
146
+ continue;
147
+ const col = columns.find((c) => fieldKeyOf(c) === item.fieldKey);
148
+ if (!col?.field)
149
+ continue;
150
+ const rule = toListFilterRule(valueTypeOf(col.field), item, opts);
151
+ if (rule)
152
+ out[item.part === undefined ? col.id : partKey(col.id, item.part)] = rule;
153
+ }
154
+ return out;
155
+ }
156
+ export function withRootRuleState(tree, columns, state, opts) {
157
+ const named = rootRulesByColumn(tree, columns, opts);
158
+ let next = tree;
159
+ for (const col of columns) {
160
+ if (!col.field)
161
+ 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);
168
+ }
169
+ }
170
+ return next;
171
+ }
172
+ export function rootRelationRules(tree) {
173
+ const out = {};
174
+ for (const item of tree.items)
175
+ if (isRelationRule(item))
176
+ out[item.fieldKey] = item;
177
+ return out;
178
+ }
179
+ export function withRootRelationRules(tree, rules) {
180
+ const kept = tree.items.filter((item) => !isRelationRule(item));
181
+ return { op: tree.op, items: [...kept, ...Object.values(rules)] };
182
+ }
183
+ export function withRootRule(tree, col, rule, part) {
184
+ const key = fieldKeyOf(col);
185
+ const type = col.field ? valueTypeOf(col.field) : undefined;
186
+ const kept = tree.items.filter((item) => isFilterGroup(item) ||
187
+ isRelationRule(item) ||
188
+ item.fieldKey !== key ||
189
+ item.part !== part ||
190
+ (part !== undefined && (!type || !toListFilterRule(type, item, { parts: true }))));
191
+ const next = rule && col.field ? fromListFilterRule(key, valueTypeOf(col.field), rule, part) : null;
192
+ return { op: tree.op, items: next ? [...kept, next] : kept };
193
+ }
194
+ export function viewReaderFrom(columns, decimals = {}) {
195
+ const byKey = new Map();
196
+ for (const col of columns) {
197
+ if (col.field)
198
+ byKey.set(col.field.key, col);
199
+ }
200
+ return {
201
+ fieldOf: (key) => byKey.get(key)?.field,
202
+ read: (row, key) => {
203
+ const col = byKey.get(key);
204
+ if (!col)
205
+ return undefined;
206
+ return (col.accessor ?? col.editAccessor)?.(row);
207
+ },
208
+ decimalsOf: (key) => {
209
+ const col = byKey.get(key);
210
+ if (!col)
211
+ return undefined;
212
+ return decimals[key] ?? col.format?.decimals;
213
+ },
214
+ codeOf: (row, key) => denominationOf(byKey.get(key), row),
215
+ };
216
+ }
@@ -0,0 +1,26 @@
1
+ import { type ReactNode } from "react";
2
+ import type { FieldConventions } from "@viewkitjs/fields";
3
+ import { type ViewsMessageResolver } from "../contract.js";
4
+ import type { ViewsAtoms } from "../atoms/types.js";
5
+ import type { FieldPresentation } from "../display/options.js";
6
+ import type { ViewsComponents } from "./components.js";
7
+ import type { ViewsIcons } from "./icons.js";
8
+ import { type ViewsPorts } from "./ports.js";
9
+ export { useViews, type ViewsContextValue } from "./context.js";
10
+ export type ViewsProviderProps = {
11
+ components: ViewsComponents;
12
+ icons: ViewsIcons;
13
+ ports: ViewsPorts;
14
+ conventions: FieldConventions;
15
+ /** The app's own atoms, each over the default of its name. Pass a module-level
16
+ * object: a new one each render re-renders every view. */
17
+ atoms?: Partial<ViewsAtoms>;
18
+ /** The app's wording for the package's own messages. Default: the package's English. */
19
+ messages?: ViewsMessageResolver;
20
+ /** How the app's numbers, dates and durations read: given the package's defaults, return the
21
+ * app's. It is called where a value is drawn, so the app's provider imports none of the
22
+ * display. Absent, the package's defaults in the conventions' locale. */
23
+ presentation?: (defaults: FieldPresentation) => FieldPresentation;
24
+ children: ReactNode;
25
+ };
26
+ export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { resolveViewsMessage } from "../contract.js";
5
+ import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
6
+ import { ViewsContext } from "./context.js";
7
+ import { withSettledGroups } from "./menu-groups.js";
8
+ import { browserConfirm } from "./ports.js";
9
+ export { useViews } from "./context.js";
10
+ export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, }) {
11
+ const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
12
+ const settled = useMemo(() => ({ ...components, Menu: withSettledGroups(components.Menu) }), [components]);
13
+ const resolved = useMemo(() => (ports.confirm ? ports : { ...ports, confirm: browserConfirm }), [ports]);
14
+ const value = useMemo(() => ({ components: settled, atoms: merged, conventions, icons, ports: resolved, messages, presentation }), [settled, merged, conventions, icons, resolved, messages, presentation]);
15
+ return _jsx(ViewsContext.Provider, { value: value, children: children });
16
+ }
@@ -0,0 +1,230 @@
1
+ import type { ComponentType, CSSProperties, KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent, ReactElement, ReactNode, Ref, RefObject } from "react";
2
+ /** Where a floating part attaches: an element, a ref to one, or a point (a context menu). */
3
+ export type ViewsAnchor = HTMLElement | RefObject<HTMLElement | null> | {
4
+ x: number;
5
+ y: number;
6
+ } | null;
7
+ export type ViewsSide = "top" | "right" | "bottom" | "left";
8
+ export type ViewsAlign = "start" | "center" | "end";
9
+ /** Why a floating part closed, by Base UI's names; an adapter maps its own reasons onto these,
10
+ * and any other reason is `none`. */
11
+ export type ViewsCloseReason = "trigger-press" | "outside-press" | "escape-key" | "focus-out" | "item-press" | "close-press" | "swipe" | "none";
12
+ export type ViewsOpenChange = (open: boolean, details?: {
13
+ reason?: ViewsCloseReason;
14
+ }) => void;
15
+ export type ViewsButtonProps = {
16
+ children?: ReactNode;
17
+ onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
18
+ disabled?: boolean;
19
+ variant?: "default" | "ghost" | "outline" | "destructive";
20
+ size?: "default" | "sm" | "icon";
21
+ type?: "button" | "submit";
22
+ className?: string;
23
+ "aria-label"?: string;
24
+ title?: string;
25
+ };
26
+ export type ViewsPopoverProps = {
27
+ open: boolean;
28
+ onOpenChange: ViewsOpenChange;
29
+ anchor: ViewsAnchor;
30
+ side?: ViewsSide;
31
+ align?: ViewsAlign;
32
+ sideOffset?: number;
33
+ alignOffset?: number;
34
+ /** False keeps focus where it was when the popup opens (an editor that owns
35
+ * its own input); that editor focuses its input with `preventScroll`, so the
36
+ * page stays where it is however the popup places itself. Default true. */
37
+ initialFocus?: boolean;
38
+ /** Called on a press outside the popup before it closes; return false to keep it open.
39
+ * `event` is the pointer press, with its `target` where the press landed, also when the
40
+ * focus that press moves is what would close the popup: a vetoed press holds against its
41
+ * focus too. Focus leaving by keyboard (a Tab out) closes without asking. */
42
+ onOutsidePress?: (event: Event) => void | false;
43
+ /** Called on Escape before the popup closes; return false to keep it open. */
44
+ onEscape?: (event: KeyboardEvent) => void | false;
45
+ /** The popup's look. `panel` is the app's card popover; `menu` is its menu
46
+ * panel's surface, for a popover that holds a list: no inset (the list
47
+ * carries its own) and no card width (it is as wide as its list). Default
48
+ * `panel`. */
49
+ chrome?: "panel" | "menu";
50
+ /** A click inside the popup. A popup is a portal, so its clicks still bubble
51
+ * through the React tree to the anchor's row; the rendering stops them here. */
52
+ onPanelClick?: (event: ReactMouseEvent<HTMLDivElement>) => void;
53
+ /** `data-*` attributes set on the popup element, for the rendering's own selectors. */
54
+ panelData?: Readonly<Record<`data-${string}`, string>>;
55
+ /** The popup's own style, where a class cannot say it: a width that follows the cell it opens on. */
56
+ style?: CSSProperties;
57
+ className?: string;
58
+ children: ReactNode;
59
+ };
60
+ /** The app mounts one tooltip provider above the views; a tooltip never mounts its own. */
61
+ export type ViewsTooltipProps = {
62
+ content: ReactNode;
63
+ children: ReactElement;
64
+ side?: ViewsSide;
65
+ align?: ViewsAlign;
66
+ delayMs?: number;
67
+ className?: string;
68
+ };
69
+ export type ViewsCheckboxProps = {
70
+ checked: boolean;
71
+ /** Partly ticked: some, not all. The box draws its partial mark instead of the tick while this
72
+ * is true; a press on it while `checked` is false hands `true`. Default false. */
73
+ indeterminate?: boolean;
74
+ /** `details.event` is the press that changed it, as Base UI reports it — a list reads its
75
+ * `shiftKey` for a range. An adapter that cannot tell hands nothing. */
76
+ onCheckedChange: (checked: boolean, details?: {
77
+ event: Event;
78
+ }) => void;
79
+ /** The partial (indeterminate) mark's colour: `muted` (default), or `brand` for a select-all
80
+ * whose partial state is a live selection. */
81
+ partialTone?: "muted" | "brand";
82
+ disabled?: boolean;
83
+ className?: string;
84
+ tabIndex?: number;
85
+ "aria-label"?: string;
86
+ };
87
+ /** A menu is data: the app draws it with its own primitive. */
88
+ export type ViewsMenuItem = {
89
+ key: string;
90
+ label: ReactNode;
91
+ icon?: ReactNode;
92
+ onSelect?: () => void;
93
+ disabled?: boolean;
94
+ destructive?: boolean;
95
+ /** A checkable row: the app draws its tick. A checkable row closes the menu like any row. */
96
+ 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
99
+ * disables every row under it: the provider hands the app's `Menu` those rows already `disabled`. */
100
+ children?: ViewsMenuItem[];
101
+ separatorBefore?: boolean;
102
+ /** A keyboard hint drawn at the row's end, never bound by the menu. */
103
+ shortcut?: string;
104
+ /** A link item: the row is an anchor and `onSelect` still fires. */
105
+ href?: string;
106
+ };
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. */
109
+ export type ViewsMenuProps = {
110
+ open: boolean;
111
+ onOpenChange: ViewsOpenChange;
112
+ anchor: ViewsAnchor;
113
+ items: ViewsMenuItem[];
114
+ side?: ViewsSide;
115
+ align?: ViewsAlign;
116
+ className?: string;
117
+ };
118
+ /** The command list's parts, the shape both cmdk-based shadcn copies already have. */
119
+ export type ViewsCommandParts = {
120
+ Root: ComponentType<{
121
+ children: ReactNode;
122
+ className?: string;
123
+ label?: string;
124
+ /** False hands filtering to the host (a remote search already filtered). Default true. */
125
+ shouldFilter?: boolean;
126
+ /** Scores an item against the search: 0 hides it, higher ranks it first. */
127
+ filter?: (value: string, search: string) => number;
128
+ /** The arrows wrap from the last item to the first and back. Default false. */
129
+ loop?: boolean;
130
+ }>;
131
+ Input: ComponentType<{
132
+ value: string;
133
+ onValueChange: (value: string) => void;
134
+ placeholder?: string;
135
+ autoFocus?: boolean;
136
+ className?: string;
137
+ ref?: Ref<HTMLInputElement>;
138
+ onKeyDown?: (event: ReactKeyboardEvent<HTMLInputElement>) => void;
139
+ /** `search` draws the app's search row (its glyph and divider); `bare` draws
140
+ * the input alone, for a field that frames it itself. Default `search`. */
141
+ chrome?: "search" | "bare";
142
+ }>;
143
+ List: ComponentType<{
144
+ children: ReactNode;
145
+ className?: string;
146
+ }>;
147
+ Empty: ComponentType<{
148
+ children: ReactNode;
149
+ className?: string;
150
+ }>;
151
+ Group: ComponentType<{
152
+ children: ReactNode;
153
+ heading?: ReactNode;
154
+ className?: string;
155
+ }>;
156
+ Item: ComponentType<{
157
+ value: string;
158
+ onSelect: (value: string) => void;
159
+ disabled?: boolean;
160
+ /** The value this item stands for is the current one. The app colours the item as its
161
+ * chosen row; the check is the package's, drawn by the row inside, so the item draws no
162
+ * tick of its own. */
163
+ chosen?: boolean;
164
+ children: ReactNode;
165
+ className?: string;
166
+ }>;
167
+ };
168
+ /** A calendar over ISO days (`YYYY-MM-DD`) and months (`YYYY-MM`); the app's date library stays its own. */
169
+ export type ViewsCalendarProps = {
170
+ value: string | null;
171
+ onChange: (day: string | null) => void;
172
+ min?: string;
173
+ max?: string;
174
+ /** The month shown. Controlled with `onMonthChange`; without it the calendar keeps its own. */
175
+ month?: string;
176
+ onMonthChange?: (month: string) => void;
177
+ /** `dropdown` draws month and year pickers in the caption. Default `label`. */
178
+ captionLayout?: "label" | "dropdown";
179
+ /** The first and last months the caption's pickers offer. */
180
+ startMonth?: string;
181
+ endMonth?: string;
182
+ /** The conventions' locale (BCP 47). The calendar draws its month and weekday names and starts
183
+ * its week as this locale does; an adapter may ignore it and keep its calendar's own. */
184
+ locale: string;
185
+ className?: string;
186
+ };
187
+ export type ViewsCollapseProps = {
188
+ open: boolean;
189
+ children: ReactNode;
190
+ className?: string;
191
+ /** A class on the box that crops the content (a bleed, a padding the crop must not shave). */
192
+ clipClassName?: string;
193
+ durationMs?: number;
194
+ };
195
+ /** A phone sheet. `snap` is a hint: an app whose sheet has no snap points ignores it. */
196
+ export type ViewsSheetProps = {
197
+ open: boolean;
198
+ onOpenChange: ViewsOpenChange;
199
+ title?: ReactNode;
200
+ description?: string;
201
+ snap?: "full" | "half" | "peek" | "auto";
202
+ className?: string;
203
+ children: ReactNode;
204
+ };
205
+ export type ViewsComponents = {
206
+ Button: ComponentType<ViewsButtonProps>;
207
+ Popover: ComponentType<ViewsPopoverProps>;
208
+ Tooltip: ComponentType<ViewsTooltipProps>;
209
+ Checkbox: ComponentType<ViewsCheckboxProps>;
210
+ Menu: ComponentType<ViewsMenuProps>;
211
+ Command: ViewsCommandParts;
212
+ Calendar: ComponentType<ViewsCalendarProps>;
213
+ Collapse: ComponentType<ViewsCollapseProps>;
214
+ Sheet: ComponentType<ViewsSheetProps>;
215
+ /** The app's own icon component by the app's own names, for glyphs a host
216
+ * declares (`rowIcon`, a binding's `icon`). It draws on the first paint,
217
+ * because rows are measured as they mount: map the names from a static
218
+ * record, never icons loaded on demand. Semantic glyphs use `icons`. */
219
+ AppIcon: ComponentType<{
220
+ name: string;
221
+ className?: string;
222
+ }>;
223
+ /** The app's own markdown renderer, for rich text: the package draws no
224
+ * markdown itself (it may import only React and zod). `source` is the stored
225
+ * markdown, whole. */
226
+ Markdown: ComponentType<{
227
+ source: string;
228
+ className?: string;
229
+ }>;
230
+ };
@@ -0,0 +1,3 @@
1
+ const _mapMatchesContract = true;
2
+ void _mapMatchesContract;
3
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { FieldConventions } from "@viewkitjs/fields";
2
+ import type { ViewsMessageResolver } from "../contract.js";
3
+ import type { ViewsAtoms } from "../atoms/types.js";
4
+ import type { FieldPresentation } from "../display/options.js";
5
+ import type { ViewsComponents } from "./components.js";
6
+ import type { ViewsIcons } from "./icons.js";
7
+ import type { ViewsResolvedPorts } from "./ports.js";
8
+ export type ViewsContextValue = {
9
+ components: ViewsComponents;
10
+ atoms: ViewsAtoms;
11
+ icons: ViewsIcons;
12
+ /** The app's ports, with `confirm` always a function (the browser's where the app handed none). */
13
+ ports: ViewsResolvedPorts;
14
+ messages: ViewsMessageResolver;
15
+ conventions: FieldConventions;
16
+ /** The app's formatting: given the package's defaults, return the app's. */
17
+ presentation?: (defaults: FieldPresentation) => FieldPresentation;
18
+ };
19
+ export declare const ViewsContext: import("react").Context<ViewsContextValue | null>;
20
+ export declare function useViews(): ViewsContextValue;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { createContext, useContext } from "react";
3
+ export const ViewsContext = createContext(null);
4
+ export function useViews() {
5
+ const value = useContext(ViewsContext);
6
+ if (!value) {
7
+ throw new Error("useViews() needs a <ViewsProvider> above it: mount one at the app's client root with its components, icons, ports and conventions.");
8
+ }
9
+ return value;
10
+ }
@@ -0,0 +1,6 @@
1
+ import type { ComponentType } from "react";
2
+ import type { ViewsIconName } from "../contract.js";
3
+ export type ViewsIconProps = {
4
+ className?: string;
5
+ };
6
+ export type ViewsIcons = Record<ViewsIconName, ComponentType<ViewsIconProps>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { type ComponentType } from "react";
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. */
5
+ export declare function settleMenuGroups(items: ViewsMenuItem[]): ViewsMenuItem[];
6
+ /** The app's Menu, handed its items settled. One wrapper per app Menu, so an open menu never
7
+ * remounts; a wrapper handed in again (a nested provider) comes back as it is. */
8
+ export declare function withSettledGroups(Menu: ComponentType<ViewsMenuProps>): ComponentType<ViewsMenuProps>;
@@ -0,0 +1,38 @@
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
+ }));
8
+ }
9
+ export function settleMenuGroups(items) {
10
+ let changed = false;
11
+ const settled = items.map((item) => {
12
+ if (!item.children || item.children.length === 0)
13
+ return item;
14
+ const children = item.disabled ? disableAll(item.children) : settleMenuGroups(item.children);
15
+ if (children === item.children)
16
+ return item;
17
+ changed = true;
18
+ return { ...item, children };
19
+ });
20
+ return changed ? settled : items;
21
+ }
22
+ const wrappers = new WeakMap();
23
+ const settledMenus = new WeakSet();
24
+ export function withSettledGroups(Menu) {
25
+ if (settledMenus.has(Menu))
26
+ return Menu;
27
+ const known = wrappers.get(Menu);
28
+ if (known)
29
+ return known;
30
+ function SettledMenu(props) {
31
+ const items = useMemo(() => settleMenuGroups(props.items), [props.items]);
32
+ return createElement(Menu, { ...props, items });
33
+ }
34
+ SettledMenu.displayName = `Settled(${Menu.displayName ?? (Menu.name || "Menu")})`;
35
+ wrappers.set(Menu, SettledMenu);
36
+ settledMenus.add(SettledMenu);
37
+ return SettledMenu;
38
+ }