@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,90 @@
1
+ import { meetsDensity } from "./card-density.js";
2
+ import { resolveVisibleColumns } from "./column-state.js";
3
+ export const ZONE_BY_TYPE = {
4
+ title: { zone: "title" },
5
+ relation: { zone: "chips" },
6
+ status: { zone: "chips" },
7
+ select: { zone: "chips" },
8
+ multiselect: { zone: "chips" },
9
+ number: { zone: "figures" },
10
+ percent: { zone: "figures" },
11
+ currency: { zone: "figures" },
12
+ date: { zone: "footer" },
13
+ datetime: { zone: "footer" },
14
+ user: { zone: "chips" },
15
+ actor: { zone: "chips" },
16
+ rich_text: null,
17
+ range: { zone: "figures" },
18
+ text: null,
19
+ boolean: null,
20
+ url: null,
21
+ domain: null,
22
+ email: null,
23
+ phone: null,
24
+ location: null,
25
+ name: null,
26
+ };
27
+ const ZONE_FLOOR = {
28
+ body: "rich",
29
+ };
30
+ export function buildCardLines(items, idOf, breakIds) {
31
+ const lines = [];
32
+ for (const item of items) {
33
+ if (lines.length === 0 || breakIds.has(idOf(item)))
34
+ lines.push([]);
35
+ lines[lines.length - 1].push(item);
36
+ }
37
+ return lines;
38
+ }
39
+ const DEFAULT_ZONE_RANK = {
40
+ title: 0,
41
+ figures: 1,
42
+ chips: 2,
43
+ footer: 3,
44
+ body: 4,
45
+ };
46
+ function defaultBreakIds(fields) {
47
+ const first = fields.find((f) => f.zone === "footer");
48
+ return first ? [first.col.id] : [];
49
+ }
50
+ export function effectiveCardBreakIds(columns, state, excludeId) {
51
+ if (state?.breaks)
52
+ return state.breaks;
53
+ return defaultBreakIds(listCardFields(columns, state, { laneColumnId: excludeId }).fields);
54
+ }
55
+ export function cardZoneOf(col, density = "rich") {
56
+ const rule = col.card?.zone
57
+ ? { zone: col.card.zone, minDensity: ZONE_FLOOR[col.card.zone] }
58
+ : col.type
59
+ ? ZONE_BY_TYPE[col.type]
60
+ : null;
61
+ if (!rule)
62
+ return null;
63
+ return meetsDensity(rule.minDensity, density) ? rule.zone : null;
64
+ }
65
+ function listCardFields(columns, state, opts) {
66
+ const density = opts.density ?? "rich";
67
+ let title;
68
+ const fields = [];
69
+ for (const col of resolveVisibleColumns(columns, state)) {
70
+ if (col.id === opts.laneColumnId)
71
+ continue;
72
+ if (opts.suppressColumnId && col.id === opts.suppressColumnId)
73
+ continue;
74
+ const zone = cardZoneOf(col, density);
75
+ if (!zone)
76
+ continue;
77
+ if (zone === "title")
78
+ title ??= col;
79
+ else
80
+ fields.push({ col, zone });
81
+ }
82
+ if (!state?.order?.length) {
83
+ fields.sort((a, b) => DEFAULT_ZONE_RANK[a.zone] - DEFAULT_ZONE_RANK[b.zone]);
84
+ }
85
+ return { title, fields };
86
+ }
87
+ export function listCardLayout(columns, state, opts = {}) {
88
+ const { title, fields } = listCardFields(columns, state, opts);
89
+ return { title, fields, breakIds: new Set(state?.breaks ?? defaultBreakIds(fields)) };
90
+ }
@@ -0,0 +1,162 @@
1
+ import { type FieldConventions } from "@viewkitjs/fields";
2
+ import { type ViewsMessageResolver } from "../contract.js";
3
+ import type { ListColumn } from "./column-schema.js";
4
+ import { type GridEditorId } from "./column-types.js";
5
+ export type { GridEditorId };
6
+ export declare function gridEditorKind<Row>(col: ListColumn<Row>): GridEditorId | null;
7
+ export declare function gridColumnHasEditor<Row>(col: ListColumn<Row>): boolean;
8
+ /**
9
+ * The grid's WRITE policy — what a column accepts, and in what shape.
10
+ *
11
+ * This exists because `gridColumnHasEditor` was quietly answering two different
12
+ * questions: "does this column mount an editor?" (click / double-click / Enter /
13
+ * type-to-replace) and "can this column be written at all?" (Delete, the context
14
+ * menu's Cut/Clear, fill-drag, paste). Those came apart the moment a type could
15
+ * be written WITHOUT an editor — a boolean commits instantly, there is nothing
16
+ * to mount. Faking a registry entry to satisfy the second question would have
17
+ * made all four mount sites try to open an editor that doesn't exist.
18
+ *
19
+ * So: `gridColumnHasEditor` keeps the mount question, `columnWritable`
20
+ * answers the write question, and `gridNormalizeWrite` is the single place any
21
+ * value is checked and coerced before it reaches a commit.
22
+ */
23
+ /**
24
+ * Workspace-settings list capability config — the CONFIG layer of the three-layer
25
+ * chain `declaration (code) → config (workspace, DB) → prefs (user, DB)`, where
26
+ * each layer may ONLY SUBTRACT: config can never widen what the code (and
27
+ * ultimately the data model) permits. Sparse — absence at any level means the
28
+ * declaration wins. Core-safe mirror of the host's stored shape
29
+ * (public.workspace_list_settings.config); the host threads it in as a prop.
30
+ *
31
+ * NOT access control: this constrains the UI. The host's API routes guard
32
+ * their own writes independently, and a direct call bypasses this entirely.
33
+ */
34
+ export type ListColumnConfig = {
35
+ /** Column locked by workspace settings: no writes through ANY route (editor, Delete,
36
+ * Clear, fill, paste). Display, sort, hide and resize are untouched. */
37
+ locked?: boolean;
38
+ };
39
+ export type ListSettingsConfig = {
40
+ /** Whole list read-only for everyone: no cell writes anywhere. */
41
+ readOnly?: boolean;
42
+ /**
43
+ * Per-FIELD locks — keyed by `lockKeyOf(col)`: the column's field key when it
44
+ * presents one, its own id when it doesn't. `columns` is the stored name and
45
+ * stays for the rows already written; the key is a field's.
46
+ *
47
+ * A key matching neither a field nor a column is inert: nothing reads it, and
48
+ * a lock the declaration no longer offers simply stops applying.
49
+ */
50
+ columns?: Record<string, ListColumnConfig>;
51
+ };
52
+ /** Toggle one column's workspace-settings lock, keeping the config SPARSE (empty maps are
53
+ * dropped — `{}` = nothing locked = declaration wins). ONE builder shared by
54
+ * every editing surface (header menu, view-options Columns drill-in) so two
55
+ * doors can never produce different shapes. */
56
+ export declare function toggleListColumnLock(config: ListSettingsConfig | undefined, columnId: string): ListSettingsConfig;
57
+ /** Toggle the table-level read-only lock (sparse: off = key absent). */
58
+ export declare function toggleListReadOnly(config: ListSettingsConfig | undefined): ListSettingsConfig;
59
+ /** Boolean columns only: which write model this column follows. */
60
+ export declare function gridBooleanMode<Row>(col: ListColumn<Row>): "toggle" | "marker" | null;
61
+ /**
62
+ * Can this column be written — by ANY route (editor, Delete, Clear, fill,
63
+ * paste)? Booleans qualify without an editor; everything else still needs one.
64
+ *
65
+ * This is the DECLARATION layer only. Every gate site should ask the
66
+ * `gridColumnEffective*` variants below, which also apply the workspace config
67
+ * layer (`ListSettingsConfig`) — declaration → config → prefs, each may only
68
+ * subtract.
69
+ */
70
+ export declare function columnWritable<Row>(col: ListColumn<Row>): boolean;
71
+ /** Human label for a column in a toast/readout: header string, else its id. */
72
+ export declare function columnLabel<Row>(col: ListColumn<Row>): string;
73
+ /** A saved view can persist only columns backed by a declared field. */
74
+ export declare function columnManagedByView<Row>(col: ListColumn<Row>): boolean;
75
+ /** A saved view can PLACE a column — its position, width and visibility — when
76
+ * the column has a field, or is a computed column (`custom`): the view stores
77
+ * a computed column under its id, which its list's source names (`computed`,
78
+ * POR-496). Filtering and totals stay `columnManagedByView`'s: a computed
79
+ * column never filters, sorts, groups or totals. */
80
+ export declare function columnPlacedByView<Row>(col: ListColumn<Row>): boolean;
81
+ export declare const VIEW_FIELDLESS_FILTER_REASON = "Not a field of this list; a view cannot filter on it.";
82
+ /** Reorder the columns a view places while leaving the rest in their declared
83
+ * slots. Unknown and omitted ids follow resolveColumnOrder's forgiving
84
+ * behavior through the declared fallback: a FIELD the view does not name
85
+ * follows the ones it does; a COMPUTED column it does not name keeps its
86
+ * declared slot, exactly as a column the view cannot place does — every view
87
+ * stored before POR-496 names none, and must draw them where it always did.
88
+ * Once the view names one (a drag, a hide), it is placed like a field. */
89
+ export declare function resolveViewColumnOrder<Row>(columns: ListColumn<Row>[], requested?: readonly string[]): string[];
90
+ /** The complete order a Move or a header drag rewrites: the order the grid
91
+ * DRAWS. On a saved view that is `resolveViewColumnOrder` — a column the view
92
+ * does not name sits in its declared slot — never the declared-neighbour
93
+ * fallback, which puts it elsewhere and made a Move swap the wrong columns
94
+ * (POR-496). Off a view, the fallback is what the grid draws. */
95
+ export declare function baseColumnOrder<Row>(columns: ListColumn<Row>[], order: readonly string[] | undefined, viewBacked: boolean): string[];
96
+ /**
97
+ * THE KEY A LOCK IS STORED UNDER — the column's FIELD, when it has one.
98
+ *
99
+ * A lock is a rule about a field ("nobody edits Value in this workspace"), and
100
+ * it has to hold on every surface that field reaches: the grid cell, the drawer
101
+ * row, the board card. Those surfaces share the field key and nothing else —
102
+ * the grid calls `value_one_off` "value", and a drawer has no column ids at all
103
+ * — so the field key is the only identity all of them can ask under.
104
+ *
105
+ * A column with no field (a rollup, a pre-registry hand-written column) keeps
106
+ * its own id, which is still the only name it has.
107
+ *
108
+ * That is the field key, and `fieldKeyOf` is where it is computed — this name
109
+ * stays because a lock site reads better saying what it is looking up.
110
+ */
111
+ export declare function lockKeyOf<Row>(col: ListColumn<Row>): string;
112
+ /** Is this column locked by the workspace config (a column lock or the whole
113
+ * table's read-only)? Locks only ever SUBTRACT — they never grant. */
114
+ export declare function gridColumnLocked<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined): boolean;
115
+ /** Declaration && !locked — the writable answer every gate site should use. */
116
+ export declare function columnEffectiveWritable<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined): boolean;
117
+ /** Effective "accepts Clear/Cut/Delete-to-empty". */
118
+ export declare function gridColumnEffectiveClearable<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined): boolean;
119
+ /**
120
+ * Why a clear was refused — the toast string. Two DIFFERENT walls that must
121
+ * not read the same: "locked by workspace settings" is actionable (a permitted owner can unlock
122
+ * it); a required field never is, and its column-declared reason explains the
123
+ * data model. Falls back to the historic generic string.
124
+ */
125
+ export declare function gridClearRefusal<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined, messages?: ViewsMessageResolver): string;
126
+ /** Why this column can't be emptied, by DECLARATION alone — no workspace config
127
+ * consulted. The toast (`gridClearRefusal`) adds the lock case on top; the
128
+ * Settings readout wants only this half. One string, two surfaces. */
129
+ export declare function columnClearRefusal<Row>(col: ListColumn<Row>, messages?: ViewsMessageResolver): string;
130
+ /** Why this column can't be edited, in the user's words — the column's own
131
+ * declared reason, else the cause its field names (`lockReason`: derived,
132
+ * system-set, provider-owned, create-only), else what a hand-written cell is
133
+ * computed from. A `command` column gets no sentence — the caret is the
134
+ * affordance. One function so the grid's refusal toast and the Settings
135
+ * manifest can't word it differently. */
136
+ export declare function columnEditRefusal<Row>(col: ListColumn<Row>, conventions: FieldConventions, messages?: ViewsMessageResolver): string | undefined;
137
+ /** Why the grid won't edit this column — `gridClearRefusal`'s twin: the
138
+ * workspace's lock first, then the column's own reason. The one sentence a
139
+ * refused gesture (a click, a key, a paste) and a refused commit both say. */
140
+ export declare function gridEditRefusal<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined, conventions: FieldConventions, messages?: ViewsMessageResolver): string | undefined;
141
+ export type GridWriteResult = {
142
+ ok: true;
143
+ value: unknown;
144
+ } | {
145
+ ok: false;
146
+ reason: string;
147
+ };
148
+ /**
149
+ * THE write gate: coerce (the grid's rules, by column type), then — when the
150
+ * column presents a registry field — accept (the field's rules, by value).
151
+ * Columns not yet on a registry keep the old behaviour exactly.
152
+ */
153
+ export declare function gridNormalizeWrite<Row>(col: ListColumn<Row>, next: unknown, conventions: FieldConventions,
154
+ /** `region`: the record's country, where a phone typed without its country code is read. A host whose rows carry
155
+ * a country passes the row's here; absent, the conventions' region reads it. `messages`: the app's words for a
156
+ * refusal, the package's English when absent. `stored`: the cell's value before this edit, as stored; a value
157
+ * fields keeps by `stored` (a phone, a url) that comes back as it is here is kept, never read again. */
158
+ options?: {
159
+ region?: string | null;
160
+ messages?: ViewsMessageResolver;
161
+ stored?: unknown;
162
+ }): GridWriteResult;
@@ -0,0 +1,233 @@
1
+ import { acceptFieldCommit, isMultipleType, lockReason, valueTypeOf } from "@viewkitjs/fields";
2
+ import { resolveViewsMessage } from "../contract.js";
3
+ import { prettifyOptionValue, resolveColumnOrder } from "./column-state.js";
4
+ import { typeRule } from "./column-types.js";
5
+ import { fieldKeyOf } from "./view-rules.js";
6
+ export function gridEditorKind(col) {
7
+ if (!col.editable || !col.type)
8
+ return null;
9
+ if (col.multiple)
10
+ return col.field && col.type && isMultipleType(col.type) ? "values" : null;
11
+ if (col.type === "title" && col.field && valueTypeOf(col.field) === "name")
12
+ return "name";
13
+ return typeRule(col.type)?.editor ?? null;
14
+ }
15
+ export function gridColumnHasEditor(col) {
16
+ return gridEditorKind(col) != null;
17
+ }
18
+ export function toggleListColumnLock(config, columnId) {
19
+ const cur = config ?? {};
20
+ const cols = { ...(cur.columns ?? {}) };
21
+ if (cols[columnId]?.locked)
22
+ delete cols[columnId];
23
+ else
24
+ cols[columnId] = { locked: true };
25
+ const next = { ...cur };
26
+ if (Object.keys(cols).length === 0)
27
+ delete next.columns;
28
+ else
29
+ next.columns = cols;
30
+ return next;
31
+ }
32
+ export function toggleListReadOnly(config) {
33
+ const cur = config ?? {};
34
+ const next = { ...cur };
35
+ if (next.readOnly)
36
+ delete next.readOnly;
37
+ else
38
+ next.readOnly = true;
39
+ return next;
40
+ }
41
+ export function gridBooleanMode(col) {
42
+ if (col.type !== "boolean")
43
+ return null;
44
+ return col.format?.booleanDisplay === "marker" ? "marker" : "toggle";
45
+ }
46
+ export function columnWritable(col) {
47
+ if (col.custom)
48
+ return false;
49
+ if (col.command)
50
+ return false;
51
+ if (!col.editable)
52
+ return false;
53
+ return gridColumnHasEditor(col) || gridBooleanMode(col) != null;
54
+ }
55
+ export function columnLabel(col) {
56
+ return typeof col.header === "string" && col.header ? col.header : prettifyOptionValue(col.id);
57
+ }
58
+ export function columnManagedByView(col) {
59
+ return col.field != null;
60
+ }
61
+ export function columnPlacedByView(col) {
62
+ return col.field != null || col.custom != null;
63
+ }
64
+ export const VIEW_FIELDLESS_FILTER_REASON = "Not a field of this list; a view cannot filter on it.";
65
+ export function resolveViewColumnOrder(columns, requested = []) {
66
+ const managedIds = new Set(columns.filter(columnPlacedByView).map((column) => column.id));
67
+ const seen = new Set();
68
+ const managed = requested.filter((id) => {
69
+ if (!managedIds.has(id) || seen.has(id))
70
+ return false;
71
+ seen.add(id);
72
+ return true;
73
+ });
74
+ for (const column of columns) {
75
+ if (column.field != null && managedIds.has(column.id) && !seen.has(column.id)) {
76
+ seen.add(column.id);
77
+ managed.push(column.id);
78
+ }
79
+ }
80
+ let managedIndex = 0;
81
+ return columns.map((column) => (seen.has(column.id) ? managed[managedIndex++] : column.id));
82
+ }
83
+ export function baseColumnOrder(columns, order, viewBacked) {
84
+ return viewBacked
85
+ ? resolveViewColumnOrder(columns, order)
86
+ : resolveColumnOrder(columns, order ? [...order] : undefined).map((column) => column.id);
87
+ }
88
+ export function lockKeyOf(col) {
89
+ return fieldKeyOf(col);
90
+ }
91
+ export function gridColumnLocked(col, config) {
92
+ if (!config)
93
+ return false;
94
+ return !!config.readOnly || !!config.columns?.[lockKeyOf(col)]?.locked;
95
+ }
96
+ export function columnEffectiveWritable(col, config) {
97
+ return columnWritable(col) && !gridColumnLocked(col, config);
98
+ }
99
+ export function gridColumnEffectiveClearable(col, config) {
100
+ return columnEffectiveWritable(col, config) && !!col.clearable;
101
+ }
102
+ export function gridClearRefusal(col, config, messages = resolveViewsMessage) {
103
+ const declared = columnWritable(col) && !!col.clearable;
104
+ if (declared && gridColumnLocked(col, config)) {
105
+ return messages({ key: "views.grid.locked", values: { field: columnLabel(col) } });
106
+ }
107
+ return columnClearRefusal(col, messages);
108
+ }
109
+ export function columnClearRefusal(col, messages = resolveViewsMessage) {
110
+ return col.reasons?.clearable ?? messages({ key: "views.grid.not-clearable" });
111
+ }
112
+ export function columnEditRefusal(col, conventions, messages = resolveViewsMessage) {
113
+ return (col.reasons?.editable ??
114
+ (col.field ? lockReason(col.field, conventions) : undefined) ??
115
+ (col.custom ? messages({ key: "views.grid.computed", values: { from: col.custom.from } }) : undefined));
116
+ }
117
+ export function gridEditRefusal(col, config, conventions, messages = resolveViewsMessage) {
118
+ if (gridColumnLocked(col, config))
119
+ return messages({ key: "views.grid.locked", values: { field: columnLabel(col) } });
120
+ return columnEditRefusal(col, conventions, messages);
121
+ }
122
+ function parseBooleanish(next) {
123
+ if (typeof next === "boolean")
124
+ return next;
125
+ if (next == null)
126
+ return false;
127
+ if (typeof next === "number")
128
+ return next !== 0;
129
+ if (typeof next !== "string")
130
+ return undefined;
131
+ const s = next.trim().toLowerCase();
132
+ if (s === "" || s === "false" || s === "0" || s === "no" || s === "n")
133
+ return false;
134
+ if (s === "true" || s === "1" || s === "yes" || s === "y")
135
+ return true;
136
+ return undefined;
137
+ }
138
+ const EMAIL_SHAPE = /^\S+@\S+\.\S+$/;
139
+ const URL_SHAPE = /^https?:\/\/\S+\.\S+/i;
140
+ function isCleared(next) {
141
+ return next == null || (typeof next === "string" && next.trim() === "");
142
+ }
143
+ function coerceWrite(col, next, messages) {
144
+ if (col.multiple) {
145
+ if (isCleared(next) || Array.isArray(next))
146
+ return { ok: true, value: next };
147
+ if (typeof next !== "string")
148
+ return { ok: false, reason: messages({ key: "views.grid.write-not-list" }) };
149
+ return {
150
+ ok: true,
151
+ value: next
152
+ .split(col.type === "url" || col.type === "domain" ? /\n|,\s/ : ",")
153
+ .map((part) => part.trim())
154
+ .filter((part) => part !== ""),
155
+ };
156
+ }
157
+ switch (typeRule(col.type)?.value ?? "any") {
158
+ case "boolean": {
159
+ const parsed = parseBooleanish(next);
160
+ if (parsed === undefined)
161
+ return { ok: false, reason: messages({ key: "views.grid.write-not-boolean" }) };
162
+ if (gridBooleanMode(col) === "marker" && parsed) {
163
+ return { ok: false, reason: messages({ key: "views.grid.write-marker" }) };
164
+ }
165
+ return { ok: true, value: parsed };
166
+ }
167
+ case "email": {
168
+ if (isCleared(next))
169
+ return { ok: true, value: next };
170
+ if (typeof next !== "string")
171
+ return { ok: true, value: next };
172
+ const trimmed = next.trim();
173
+ if (!EMAIL_SHAPE.test(trimmed))
174
+ return { ok: false, reason: messages({ key: "views.grid.write-not-email" }) };
175
+ return { ok: true, value: trimmed };
176
+ }
177
+ case "url": {
178
+ if (isCleared(next))
179
+ return { ok: true, value: next };
180
+ if (typeof next !== "string")
181
+ return { ok: true, value: next };
182
+ const trimmed = next.trim();
183
+ if (!URL_SHAPE.test(trimmed)) {
184
+ return { ok: false, reason: messages({ key: "views.grid.write-not-url" }) };
185
+ }
186
+ return { ok: true, value: trimmed };
187
+ }
188
+ case "relation": {
189
+ if (isCleared(next))
190
+ return { ok: true, value: null };
191
+ if (typeof next !== "string")
192
+ return { ok: false, reason: messages({ key: "views.grid.write-not-link" }) };
193
+ const known = col.relation?.options;
194
+ if (known && !known.some((option) => option.id === next)) {
195
+ return { ok: false, reason: messages({ key: "views.grid.write-not-linkable" }) };
196
+ }
197
+ return { ok: true, value: next };
198
+ }
199
+ case "list": {
200
+ if (isCleared(next))
201
+ return { ok: true, value: [] };
202
+ if (!Array.isArray(next) && typeof next !== "string") {
203
+ return { ok: false, reason: messages({ key: "views.grid.write-not-list" }) };
204
+ }
205
+ const raw = Array.isArray(next) ? next : next.split(",");
206
+ const values = [];
207
+ for (const entry of raw) {
208
+ if (entry == null)
209
+ continue;
210
+ const trimmed = String(entry).trim();
211
+ if (trimmed === "" || values.includes(trimmed))
212
+ continue;
213
+ values.push(trimmed);
214
+ }
215
+ return { ok: true, value: values };
216
+ }
217
+ case "any":
218
+ return { ok: true, value: next };
219
+ }
220
+ }
221
+ export function gridNormalizeWrite(col, next, conventions, options = {}) {
222
+ const coerced = coerceWrite(col, next, options.messages ?? resolveViewsMessage);
223
+ if (!coerced.ok || !col.field)
224
+ return coerced;
225
+ if (isCleared(coerced.value))
226
+ return coerced;
227
+ return acceptFieldCommit(col.field, coerced.value, {
228
+ unitOptions: col.editUnit?.options,
229
+ conventions,
230
+ region: options.region,
231
+ stored: options.stored,
232
+ });
233
+ }
@@ -0,0 +1,106 @@
1
+ import type { ReactNode } from "react";
2
+ import { type FieldConventions } from "@viewkitjs/fields";
3
+ import type { ViewsMessageResolver } from "../contract.js";
4
+ import type { FilterConfig } from "../filters/filter-model.js";
5
+ import type { ListColumn, ListRelationValue } from "./column-schema.js";
6
+ import { type ListFilterEditor } from "./column-types.js";
7
+ import type { ListColumnState } from "./column-state.js";
8
+ import type { ListFilterRule, ListFilterRuleState } from "./preferences.js";
9
+ import type { ListFilterCapabilities } from "./filter-capabilities.js";
10
+ /**
11
+ * The Filter list, derived from the table's own columns.
12
+ *
13
+ * A list used to hand-author its filter dimensions, so the Filter drill-in
14
+ * showed whatever that one page happened to declare and nothing else — a table
15
+ * with a Name column had no way to filter by name unless someone wrote that
16
+ * dimension by hand. Here the columns ARE the inventory: every column is
17
+ * listed, in the user's column order, carrying its own type. What a row DOES
18
+ * when opened is the type's business (`filterEditor`), which is what lets
19
+ * one editor per type serve every table in the app.
20
+ *
21
+ * Pure and renderer-free — the icon arrives as a resolver so `chrome/` keeps
22
+ * owning the glyphs.
23
+ */
24
+ /** Which editor a column's type opens in the Filter drill-in. Declared once per
25
+ * type in `column-types.ts`, beside that type's editor and paste rules. */
26
+ export type { ListFilterEditor };
27
+ export declare function filterEditor<Row>(col: ListColumn<Row>): ListFilterEditor | null;
28
+ /** Section label for filters whose column is currently hidden from the table. */
29
+ export declare const HIDDEN_COLUMN_SECTION = "Hidden columns";
30
+ /** The decimals the cell is showing: the workspace's per-FIELD override wins
31
+ * over the column's declared default, so equality rounds to what is on
32
+ * screen — except on an integer field, which shows whole numbers whatever
33
+ * the reader set (spec §8.2). Keyed by field key; a field-less column's key
34
+ * is its id. */
35
+ export declare function numberDecimals<Row>(col: ListColumn<Row>, overrides?: Record<string, number>): number;
36
+ /**
37
+ * A boolean column's two choices, worded the way its CELL is worded — a filter
38
+ * offering "True / False" against a column that draws the word "flagged" makes
39
+ * you translate between the two. `format.booleanDisplay` already decides how
40
+ * the cell reads, so it decides how the filter reads.
41
+ */
42
+ export declare function booleanFilterOptions<Row>(col: ListColumn<Row>): {
43
+ value: string;
44
+ label: string;
45
+ }[];
46
+ /**
47
+ * Merge the columns with any dimensions the list declares by hand.
48
+ *
49
+ * Hand-declared dimensions do not disappear: something can be a real thing to
50
+ * filter on WITHOUT being a column (Transactions filters by direction and by
51
+ * currency, but the grid folds both into the Amount cell — there is no column
52
+ * to derive either from). So:
53
+ * - a declared filter whose `key` matches a column id REPLACES that column's
54
+ * derived row and keeps the column's position in the order;
55
+ * - a declared filter matching no column is appended, in declared order.
56
+ */
57
+ export declare function buildColumnFilters<Row>({ columns, order, declared, icon, rules, onRuleChange, selectValues, relationValues, decimals, columnState, viewId, capabilities, knownValues, knownLabels, onValuesWanted, parts, messages, conventions, }: {
58
+ columns: ListColumn<Row>[];
59
+ /** The user's column order, so Filter reads in the same order as the table. */
60
+ order?: string[];
61
+ declared?: FilterConfig<string>[];
62
+ icon?: (col: ListColumn<Row>) => ReactNode;
63
+ /** The persisted rules a wired editor reads and writes. */
64
+ rules?: ListFilterRuleState;
65
+ onRuleChange?: (columnId: string, rule: ListFilterRule | null) => void;
66
+ /** columnId → option values in display order, from `deriveGridSelectValues`
67
+ * (declared first, then whatever the data actually contains). The SAME list
68
+ * the cell editor offers, so you can never filter for a value you can't set
69
+ * — or fail to filter for one that's sitting in the table. */
70
+ selectValues?: Record<string, string[]>;
71
+ /** columnId → the relations PRESENT in the rows, from
72
+ * `deriveGridRelationValues`. Deliberately not the column's pickable
73
+ * candidates: the filter answers "which of the ones I can see", so it stays
74
+ * the size of the table rather than the size of the entity it points at. */
75
+ relationValues?: Record<string, ListRelationValue[]>;
76
+ /** columnId → the decimals the cell is currently showing (the user's
77
+ * per-column override), so equality rounds the way the eye does. */
78
+ decimals?: Record<string, number>;
79
+ /** The user's column state, so a filter can say whether its column is
80
+ * currently hidden. Hidden columns stay LISTED — a rule on one still
81
+ * narrows the list — they just group separately. */
82
+ columnState?: ListColumnState;
83
+ /** The view being drawn, so "hidden" means what THAT view hides — a column
84
+ * the rows look hides by default must not read as shown here. */
85
+ viewId?: string;
86
+ capabilities?: ListFilterCapabilities;
87
+ /** columnId → an open field's values as the host knows them (POR-845) — every value its records hold, read
88
+ * from the database — offered ahead of the values on screen. */
89
+ knownValues?: Record<string, string[]>;
90
+ /** columnId → value → its name, for a relation's, a user's or an actor's known values (POR-1480): a value the
91
+ * host did not name is not offered unless it is on screen. */
92
+ knownLabels?: Record<string, Readonly<Record<string, string>>>;
93
+ /** An open field's, a relation's, a user's or an actor's row opened: the host may ask for its values. */
94
+ onValuesWanted?: (columnId: string) => void;
95
+ /** One row per part of a value, right under its column (VK-57): "Location · Country", "Name · Given name"
96
+ * (`FILTER_PART_ROWS`). Keyed `partKey(columnId, part)` in `rules`, `onRuleChange`, `selectValues`, `knownValues`
97
+ * and `onValuesWanted`. A place's inert whole-value row gives way to its parts. Off by default. */
98
+ parts?: boolean;
99
+ /** Words for part rows; the package's English by default. */
100
+ messages?: ViewsMessageResolver;
101
+ /** The locale a country's name is read in (`conventions.locale`); English by default. */
102
+ conventions?: FieldConventions;
103
+ }): FilterConfig<string>[];
104
+ export declare function rowMatchesRules<Row>(row: Row, rules: ListFilterRuleState, columns: ListColumn<Row>[],
105
+ /** Per-column displayed decimals — see `numberDecimals`. */
106
+ decimals: Record<string, number> | undefined, conventions: FieldConventions): boolean;