viewkitjs 0.26.0 → 0.28.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 (294) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/MIGRATION.md +122 -7
  3. package/package.json +1 -1
  4. package/views/dist/cells/cell-format.d.ts +3 -1
  5. package/views/dist/cells/cell-format.js +2 -2
  6. package/views/dist/cells/use-cell-format.d.ts +8 -1
  7. package/views/dist/cells/use-cell-format.js +13 -2
  8. package/views/dist/contract.d.ts +240 -3
  9. package/views/dist/contract.js +238 -0
  10. package/views/dist/controls/alert/alert.d.ts +46 -0
  11. package/views/dist/controls/alert/alert.js +11 -0
  12. package/views/dist/controls/alert/looks.d.ts +4 -0
  13. package/views/dist/controls/alert/looks.js +19 -0
  14. package/views/dist/controls/alert/tokens.d.ts +92 -0
  15. package/views/dist/controls/alert/tokens.js +25 -0
  16. package/views/dist/controls/alert-dialog/alert-dialog.d.ts +50 -0
  17. package/views/dist/controls/alert-dialog/alert-dialog.js +67 -0
  18. package/views/dist/controls/alert-dialog/confirm.d.ts +13 -0
  19. package/views/dist/controls/alert-dialog/confirm.js +11 -0
  20. package/views/dist/controls/alert-dialog/looks.d.ts +4 -0
  21. package/views/dist/controls/alert-dialog/looks.js +17 -0
  22. package/views/dist/controls/alert-dialog/tokens.d.ts +119 -0
  23. package/views/dist/controls/alert-dialog/tokens.js +32 -0
  24. package/views/dist/controls/alert-dialog.css +95 -0
  25. package/views/dist/controls/alert.css +51 -0
  26. package/views/dist/controls/collapsible/collapsible.d.ts +39 -0
  27. package/views/dist/controls/collapsible/collapsible.js +18 -0
  28. package/views/dist/controls/collapsible/looks.d.ts +4 -0
  29. package/views/dist/controls/collapsible/looks.js +5 -0
  30. package/views/dist/controls/collapsible/map-collapse.d.ts +2 -0
  31. package/views/dist/controls/collapsible/map-collapse.js +6 -0
  32. package/views/dist/controls/collapsible/tokens.d.ts +68 -0
  33. package/views/dist/controls/collapsible/tokens.js +19 -0
  34. package/views/dist/controls/collapsible.css +83 -0
  35. package/views/dist/controls/compound-editor/map-parts-body.js +2 -1
  36. package/views/dist/controls/compound-editor/name-parts.js +10 -2
  37. package/views/dist/controls/compound-editor/place-parts.js +5 -1
  38. package/views/dist/controls/compound-editor/place.d.ts +2 -1
  39. package/views/dist/controls/compound-editor/place.js +2 -0
  40. package/views/dist/controls/controls.d.ts +17 -0
  41. package/views/dist/controls/controls.js +17 -0
  42. package/views/dist/controls/date-editor/date-editor.d.ts +2 -1
  43. package/views/dist/controls/date-editor/map-calendar.js +3 -1
  44. package/views/dist/controls/filter-editor/filter-editor.d.ts +56 -0
  45. package/views/dist/controls/filter-editor/filter-editor.js +208 -0
  46. package/views/dist/controls/filter-editor/how.d.ts +23 -0
  47. package/views/dist/controls/filter-editor/how.js +13 -0
  48. package/views/dist/controls/filter-editor/map-filter-body.d.ts +18 -0
  49. package/views/dist/controls/filter-editor/map-filter-body.js +164 -0
  50. package/views/dist/controls/filter-editor/map-rules.d.ts +85 -0
  51. package/views/dist/controls/filter-editor/map-rules.js +273 -0
  52. package/views/dist/controls/filter-editor/parts.d.ts +46 -0
  53. package/views/dist/controls/filter-editor/parts.js +75 -0
  54. package/views/dist/controls/filter-editor/rules.d.ts +104 -0
  55. package/views/dist/controls/filter-editor/rules.js +148 -0
  56. package/views/dist/controls/filter-editor/tokens.d.ts +83 -0
  57. package/views/dist/controls/filter-editor/tokens.js +23 -0
  58. package/views/dist/controls/filter-editor/words.d.ts +59 -0
  59. package/views/dist/controls/filter-editor/words.js +40 -0
  60. package/views/dist/controls/filter-editor.css +124 -0
  61. package/views/dist/controls/group-editor/group-editor.d.ts +56 -0
  62. package/views/dist/controls/group-editor/group-editor.js +126 -0
  63. package/views/dist/controls/group-editor/map-group-body.d.ts +19 -0
  64. package/views/dist/controls/group-editor/map-group-body.js +106 -0
  65. package/views/dist/controls/group-editor/rules.d.ts +48 -0
  66. package/views/dist/controls/group-editor/rules.js +41 -0
  67. package/views/dist/controls/group-editor/tokens.d.ts +15 -0
  68. package/views/dist/controls/group-editor/tokens.js +6 -0
  69. package/views/dist/controls/group-editor/words.d.ts +39 -0
  70. package/views/dist/controls/group-editor/words.js +21 -0
  71. package/views/dist/controls/group-editor.css +20 -0
  72. package/views/dist/controls/index.d.ts +35 -1
  73. package/views/dist/controls/index.js +35 -1
  74. package/views/dist/controls/internal/editor-parts.d.ts +47 -0
  75. package/views/dist/controls/internal/editor-parts.js +48 -0
  76. package/views/dist/controls/internal/step-return.d.ts +9 -0
  77. package/views/dist/controls/internal/step-return.js +27 -0
  78. package/views/dist/controls/links-editor/links-editor.d.ts +80 -0
  79. package/views/dist/controls/links-editor/links-editor.js +329 -0
  80. package/views/dist/controls/links-editor/links.d.ts +62 -0
  81. package/views/dist/controls/links-editor/links.js +50 -0
  82. package/views/dist/controls/links-editor/map-links-body.d.ts +10 -0
  83. package/views/dist/controls/links-editor/map-links-body.js +74 -0
  84. package/views/dist/controls/links-editor/tokens.d.ts +71 -0
  85. package/views/dist/controls/links-editor/tokens.js +20 -0
  86. package/views/dist/controls/links-editor/words.d.ts +56 -0
  87. package/views/dist/controls/links-editor/words.js +33 -0
  88. package/views/dist/controls/links-editor.css +132 -0
  89. package/views/dist/controls/menu-list/menu-list.d.ts +17 -2
  90. package/views/dist/controls/menu-list/menu-list.js +25 -16
  91. package/views/dist/controls/modal/looks.d.ts +4 -0
  92. package/views/dist/controls/modal/looks.js +25 -0
  93. package/views/dist/controls/modal/modal.d.ts +69 -0
  94. package/views/dist/controls/modal/modal.js +62 -0
  95. package/views/dist/controls/modal/tokens.d.ts +192 -0
  96. package/views/dist/controls/modal/tokens.js +50 -0
  97. package/views/dist/controls/modal.css +130 -0
  98. package/views/dist/controls/notice/notice.d.ts +49 -0
  99. package/views/dist/controls/notice/notice.js +35 -0
  100. package/views/dist/controls/notice/tokens.d.ts +99 -0
  101. package/views/dist/controls/notice/tokens.js +27 -0
  102. package/views/dist/controls/notice.css +100 -0
  103. package/views/dist/controls/number-editor/format.d.ts +31 -0
  104. package/views/dist/controls/number-editor/format.js +79 -0
  105. package/views/dist/controls/number-editor/looks.d.ts +14 -0
  106. package/views/dist/controls/number-editor/looks.js +17 -0
  107. package/views/dist/controls/number-editor/map-number-body.d.ts +16 -0
  108. package/views/dist/controls/number-editor/map-number-body.js +57 -0
  109. package/views/dist/controls/number-editor/number-editor.d.ts +72 -0
  110. package/views/dist/controls/number-editor/number-editor.js +202 -0
  111. package/views/dist/controls/number-editor/tokens.d.ts +28 -0
  112. package/views/dist/controls/number-editor/tokens.js +9 -0
  113. package/views/dist/controls/number-editor/words.d.ts +23 -0
  114. package/views/dist/controls/number-editor/words.js +13 -0
  115. package/views/dist/controls/number-editor.css +37 -0
  116. package/views/dist/controls/number-field/number-field.js +57 -5
  117. package/views/dist/controls/pane/looks.d.ts +4 -0
  118. package/views/dist/controls/pane/looks.js +11 -0
  119. package/views/dist/controls/pane/pane.d.ts +63 -0
  120. package/views/dist/controls/pane/pane.js +98 -0
  121. package/views/dist/controls/pane/state.d.ts +14 -0
  122. package/views/dist/controls/pane/state.js +7 -0
  123. package/views/dist/controls/pane/tokens.d.ts +79 -0
  124. package/views/dist/controls/pane/tokens.js +22 -0
  125. package/views/dist/controls/pane.css +104 -0
  126. package/views/dist/controls/picker/rows.d.ts +4 -2
  127. package/views/dist/controls/picker/rows.js +4 -3
  128. package/views/dist/controls/radio/radio.d.ts +33 -0
  129. package/views/dist/controls/radio/radio.js +19 -0
  130. package/views/dist/controls/radio/tokens.d.ts +127 -0
  131. package/views/dist/controls/radio/tokens.js +34 -0
  132. package/views/dist/controls/radio.css +104 -0
  133. package/views/dist/controls/sort-editor/map-sort-body.d.ts +9 -0
  134. package/views/dist/controls/sort-editor/map-sort-body.js +81 -0
  135. package/views/dist/controls/sort-editor/rules.d.ts +48 -0
  136. package/views/dist/controls/sort-editor/rules.js +24 -0
  137. package/views/dist/controls/sort-editor/sort-editor.d.ts +58 -0
  138. package/views/dist/controls/sort-editor/sort-editor.js +180 -0
  139. package/views/dist/controls/sort-editor/tokens.d.ts +79 -0
  140. package/views/dist/controls/sort-editor/tokens.js +22 -0
  141. package/views/dist/controls/sort-editor/words.d.ts +48 -0
  142. package/views/dist/controls/sort-editor/words.js +25 -0
  143. package/views/dist/controls/sort-editor.css +96 -0
  144. package/views/dist/controls/text-editor/phone-number.d.ts +4 -0
  145. package/views/dist/controls/text-editor/phone-number.js +20 -0
  146. package/views/dist/controls/text-editor/text-editor.js +2 -19
  147. package/views/dist/controls/toast/toast.d.ts +75 -0
  148. package/views/dist/controls/toast/toast.js +99 -0
  149. package/views/dist/controls/toast/tokens.d.ts +100 -0
  150. package/views/dist/controls/toast/tokens.js +27 -0
  151. package/views/dist/controls/toast.css +93 -0
  152. package/views/dist/controls/tokens.js +30 -0
  153. package/views/dist/controls/values-editor/looks.d.ts +16 -0
  154. package/views/dist/controls/values-editor/looks.js +19 -0
  155. package/views/dist/controls/values-editor/map-values-body.d.ts +12 -0
  156. package/views/dist/controls/values-editor/map-values-body.js +71 -0
  157. package/views/dist/controls/values-editor/tokens.d.ts +132 -0
  158. package/views/dist/controls/values-editor/tokens.js +35 -0
  159. package/views/dist/controls/values-editor/values-editor.d.ts +62 -0
  160. package/views/dist/controls/values-editor/values-editor.js +441 -0
  161. package/views/dist/controls/values-editor/values.d.ts +71 -0
  162. package/views/dist/controls/values-editor/values.js +59 -0
  163. package/views/dist/controls/values-editor/words.d.ts +50 -0
  164. package/views/dist/controls/values-editor/words.js +29 -0
  165. package/views/dist/controls/values-editor.css +207 -0
  166. package/views/dist/controls/views-list/looks.d.ts +13 -0
  167. package/views/dist/controls/views-list/looks.js +12 -0
  168. package/views/dist/controls/views-list/map-views-list-body.d.ts +19 -0
  169. package/views/dist/controls/views-list/map-views-list-body.js +65 -0
  170. package/views/dist/controls/views-list/rules.d.ts +72 -0
  171. package/views/dist/controls/views-list/rules.js +4 -0
  172. package/views/dist/controls/views-list/tokens.d.ts +11 -0
  173. package/views/dist/controls/views-list/tokens.js +5 -0
  174. package/views/dist/controls/views-list/views-list.d.ts +44 -0
  175. package/views/dist/controls/views-list/views-list.js +57 -0
  176. package/views/dist/controls/views-list/words.d.ts +22 -0
  177. package/views/dist/controls/views-list/words.js +3 -0
  178. package/views/dist/controls/views-list.css +8 -0
  179. package/views/dist/display/date.js +2 -2
  180. package/views/dist/display/format.js +10 -2
  181. package/views/dist/display/options.d.ts +3 -1
  182. package/views/dist/display/use-display-options.d.ts +3 -0
  183. package/views/dist/display/use-display-options.js +10 -2
  184. package/views/dist/display/viewer.d.ts +1 -1
  185. package/views/dist/display/viewer.js +1 -1
  186. package/views/dist/editors/DateEditor.js +11 -9
  187. package/views/dist/editors/NumberEditor.js +3 -1
  188. package/views/dist/editors/relation-panel.js +7 -1
  189. package/views/dist/editors/relation-picker.d.ts +2 -1
  190. package/views/dist/editors/relation-picker.js +4 -3
  191. package/views/dist/editors/relation-source.d.ts +4 -1
  192. package/views/dist/editors/relation-source.js +5 -2
  193. package/views/dist/field-row/editors/RowNumberEditor.js +2 -2
  194. package/views/dist/fields/number-edit.d.ts +6 -0
  195. package/views/dist/fields/number-edit.js +8 -1
  196. package/views/dist/grid/chrome/GridCellEditors.js +3 -3
  197. package/views/dist/grid/chrome/GridColumnDateSection.d.ts +4 -3
  198. package/views/dist/grid/chrome/GridColumnDateSection.js +4 -4
  199. package/views/dist/grid/chrome/GridColumnDurationSection.js +2 -2
  200. package/views/dist/grid/chrome/GridColumnMenu.js +6 -4
  201. package/views/dist/grid/chrome/GridDateEditor.d.ts +3 -1
  202. package/views/dist/grid/chrome/GridDateEditor.js +2 -1
  203. package/views/dist/grid/chrome/GridFooter.js +2 -2
  204. package/views/dist/grid/chrome/grid-column-menu-items.js +4 -2
  205. package/views/dist/grid/chrome/useGridBandFigures.js +2 -2
  206. package/views/dist/grid/chrome/useGridFittedWidths.d.ts +3 -0
  207. package/views/dist/grid/chrome/useGridFittedWidths.js +9 -3
  208. package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
  209. package/views/dist/grid/chrome/useGridKeyboard.js +5 -2
  210. package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -1
  211. package/views/dist/grid/core/commit-model.d.ts +7 -0
  212. package/views/dist/grid/core/commit-model.js +5 -1
  213. package/views/dist/grid/core/editing-controller.js +10 -2
  214. package/views/dist/grid/core/editing-model.js +3 -7
  215. package/views/dist/grid/core/undo-owner.d.ts +6 -0
  216. package/views/dist/grid/core/undo-owner.js +13 -0
  217. package/views/dist/grid/core/useGridEditing.d.ts +2 -0
  218. package/views/dist/grid/core/useGridEditing.js +4 -0
  219. package/views/dist/looks/index.d.ts +8 -0
  220. package/views/dist/looks/index.js +8 -0
  221. package/views/dist/looks/pieces.js +16 -0
  222. package/views/dist/panels/model.d.ts +6 -1
  223. package/views/dist/panels/react/customize-body.d.ts +4 -2
  224. package/views/dist/panels/react/customize-body.js +3 -3
  225. package/views/dist/panels/react/customize.js +4 -2
  226. package/views/dist/panels/react/filter/FilterEditor.js +2 -2
  227. package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +8 -2
  228. package/views/dist/panels/react/filter/PhoneFilterEditor.js +9 -6
  229. package/views/dist/panels/react/filter/filter-body.d.ts +8 -5
  230. package/views/dist/panels/react/filter/filter-body.js +17 -6
  231. package/views/dist/panels/react/filter/filter-part-body.d.ts +4 -1
  232. package/views/dist/panels/react/filter/filter-part-body.js +3 -1
  233. package/views/dist/panels/react/panel-sheet.d.ts +5 -1
  234. package/views/dist/panels/react/panel-sheet.js +6 -2
  235. package/views/dist/panels/react/panel-step.d.ts +12 -0
  236. package/views/dist/panels/react/panel-step.js +26 -0
  237. package/views/dist/panels/react/sort/SortEditor.d.ts +4 -0
  238. package/views/dist/panels/react/sort/SortEditor.js +5 -2
  239. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +8 -0
  240. package/views/dist/panels/react/toolbar/ReadyToolbar.js +84 -2
  241. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +2 -2
  242. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +16 -0
  243. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +49 -0
  244. package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +3 -1
  245. package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +4 -1
  246. package/views/dist/panels/react/toolbar/ToolbarFilters.js +36 -21
  247. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +4 -1
  248. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +2 -2
  249. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  250. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +15 -6
  251. package/views/dist/panels/react/toolbar/panel-part.d.ts +5 -1
  252. package/views/dist/panels/react/toolbar/panel-part.js +2 -2
  253. package/views/dist/panels/react/toolbar/use-filter-add.d.ts +16 -0
  254. package/views/dist/panels/react/toolbar/use-filter-add.js +32 -0
  255. package/views/dist/panels/react.d.ts +1 -0
  256. package/views/dist/panels/react.js +1 -0
  257. package/views/dist/panels/settings/filter-groups.js +35 -1
  258. package/views/dist/panels/settings/group-buckets.js +1 -0
  259. package/views/dist/provider/ViewsProvider.d.ts +7 -1
  260. package/views/dist/provider/ViewsProvider.js +23 -3
  261. package/views/dist/provider/components.d.ts +34 -4
  262. package/views/dist/provider/moment.d.ts +6 -0
  263. package/views/dist/provider/moment.js +10 -0
  264. package/views/dist/styles.css +1276 -51
  265. package/views/dist/styles.unlayered.css +1277 -51
  266. package/views/docs/contract.md +23 -15
  267. package/views/docs/controls/alert-dialog.md +37 -0
  268. package/views/docs/controls/alert.md +30 -0
  269. package/views/docs/controls/collapsible.md +22 -0
  270. package/views/docs/controls/filter-editor.md +28 -0
  271. package/views/docs/controls/group-editor.md +11 -0
  272. package/views/docs/controls/links-editor.md +25 -0
  273. package/views/docs/controls/modal.md +55 -0
  274. package/views/docs/controls/notice.md +32 -0
  275. package/views/docs/controls/number-editor.md +12 -0
  276. package/views/docs/controls/pane.md +25 -0
  277. package/views/docs/controls/radio.md +39 -0
  278. package/views/docs/controls/sort-editor.md +27 -0
  279. package/views/docs/controls/toast.md +32 -0
  280. package/views/docs/controls/values-editor.md +40 -0
  281. package/views/docs/controls/views-list.md +8 -0
  282. package/views/docs/guides/cells.md +1 -1
  283. package/views/docs/guides/display.md +1 -1
  284. package/views/docs/guides/the-grid.md +1 -1
  285. package/views/docs/guides/the-provider.md +19 -0
  286. package/views/docs/reference/cells.md +2 -2
  287. package/views/docs/reference/controls.md +326 -8
  288. package/views/docs/reference/display.md +2 -2
  289. package/views/docs/reference/editors-relation.md +1 -1
  290. package/views/docs/reference/looks.md +20 -3
  291. package/views/docs/reference/panels-react.md +7 -6
  292. package/views/docs/reference/panels.md +1 -1
  293. package/views/docs/reference/react.md +8 -8
  294. package/views/docs/reference/views.md +1 -0
@@ -0,0 +1,99 @@
1
+ export declare const NOTICE_TOKENS: readonly [{
2
+ readonly name: "--vk-spacing";
3
+ readonly kind: "size";
4
+ readonly outright: "--spacing";
5
+ }, {
6
+ readonly name: "--vk-radius-lg";
7
+ readonly kind: "size";
8
+ readonly outright: "--radius-lg";
9
+ }, {
10
+ readonly name: "--vk-fg";
11
+ readonly kind: "colour";
12
+ readonly outright: "--text";
13
+ }, {
14
+ readonly name: "--vk-font-size-sm";
15
+ readonly kind: "size";
16
+ readonly outright: "--text-sm";
17
+ }, {
18
+ readonly name: "--vk-line-height-sm";
19
+ readonly kind: "size";
20
+ readonly outright: "--text-sm--line-height";
21
+ }, {
22
+ readonly name: "--vk-duration-fast";
23
+ readonly kind: "motion";
24
+ readonly outright: "--duration-fast";
25
+ }, {
26
+ readonly name: "--vk-ease-in";
27
+ readonly kind: "motion";
28
+ readonly outright: "--ease-in";
29
+ }, {
30
+ readonly name: "--vk-info-subtler";
31
+ readonly kind: "colour";
32
+ readonly outright: "--background-information-subtler";
33
+ }, {
34
+ readonly name: "--vk-info";
35
+ readonly kind: "colour";
36
+ readonly outright: "--text-information";
37
+ }, {
38
+ readonly name: "--vk-success-subtler";
39
+ readonly kind: "colour";
40
+ readonly outright: "--background-success-subtler";
41
+ }, {
42
+ readonly name: "--vk-success";
43
+ readonly kind: "colour";
44
+ readonly outright: "--text-success";
45
+ }, {
46
+ readonly name: "--vk-warning-subtler";
47
+ readonly kind: "colour";
48
+ readonly outright: "--background-warning-subtler";
49
+ }, {
50
+ readonly name: "--vk-warning";
51
+ readonly kind: "colour";
52
+ readonly outright: "--text-warning";
53
+ }, {
54
+ readonly name: "--vk-danger-subtler";
55
+ readonly kind: "colour";
56
+ readonly outright: "--background-danger-subtler";
57
+ }, {
58
+ readonly name: "--vk-danger";
59
+ readonly kind: "colour";
60
+ readonly outright: "--text-danger";
61
+ }, {
62
+ readonly name: "--vk-sunken";
63
+ readonly kind: "colour";
64
+ readonly outright: "--surface-sunken";
65
+ }, {
66
+ readonly name: "--vk-border-subtle";
67
+ readonly kind: "colour";
68
+ readonly outright: "--border-subtle";
69
+ }, {
70
+ readonly name: "--vk-border-width";
71
+ readonly kind: "size";
72
+ readonly outright: "--border-width";
73
+ }, {
74
+ readonly name: "--vk-fg-subtle";
75
+ readonly kind: "colour";
76
+ readonly outright: "--text-subtle";
77
+ }, {
78
+ readonly name: "--vk-fg-subtlest";
79
+ readonly kind: "colour";
80
+ readonly outright: "--text-subtlest";
81
+ }, {
82
+ readonly name: "--vk-font-weight-semibold";
83
+ readonly kind: "size";
84
+ readonly outright: "--font-weight-semibold";
85
+ }, {
86
+ readonly name: "--vk-duration-base";
87
+ readonly kind: "motion";
88
+ readonly outright: "--duration-base";
89
+ }, {
90
+ readonly name: "--vk-ease-out";
91
+ readonly kind: "motion";
92
+ readonly outright: "--ease-out";
93
+ }, {
94
+ readonly name: "--vk-corner-smoothing";
95
+ readonly kind: "size";
96
+ readonly outright: "--corner-smoothing";
97
+ }];
98
+ /** The Notice's own machinery: its meaning's ground and edge, and how it fits its actions. */
99
+ export declare const NOTICE_PRIVATE: readonly ["--notice-"];
@@ -0,0 +1,27 @@
1
+ export const NOTICE_TOKENS = [
2
+ { name: "--vk-spacing", kind: "size", outright: "--spacing" },
3
+ { name: "--vk-radius-lg", kind: "size", outright: "--radius-lg" },
4
+ { name: "--vk-fg", kind: "colour", outright: "--text" },
5
+ { name: "--vk-font-size-sm", kind: "size", outright: "--text-sm" },
6
+ { name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
7
+ { name: "--vk-duration-fast", kind: "motion", outright: "--duration-fast" },
8
+ { name: "--vk-ease-in", kind: "motion", outright: "--ease-in" },
9
+ { name: "--vk-info-subtler", kind: "colour", outright: "--background-information-subtler" },
10
+ { name: "--vk-info", kind: "colour", outright: "--text-information" },
11
+ { name: "--vk-success-subtler", kind: "colour", outright: "--background-success-subtler" },
12
+ { name: "--vk-success", kind: "colour", outright: "--text-success" },
13
+ { name: "--vk-warning-subtler", kind: "colour", outright: "--background-warning-subtler" },
14
+ { name: "--vk-warning", kind: "colour", outright: "--text-warning" },
15
+ { name: "--vk-danger-subtler", kind: "colour", outright: "--background-danger-subtler" },
16
+ { name: "--vk-danger", kind: "colour", outright: "--text-danger" },
17
+ { name: "--vk-sunken", kind: "colour", outright: "--surface-sunken" },
18
+ { name: "--vk-border-subtle", kind: "colour", outright: "--border-subtle" },
19
+ { name: "--vk-border-width", kind: "size", outright: "--border-width" },
20
+ { name: "--vk-fg-subtle", kind: "colour", outright: "--text-subtle" },
21
+ { name: "--vk-fg-subtlest", kind: "colour", outright: "--text-subtlest" },
22
+ { name: "--vk-font-weight-semibold", kind: "size", outright: "--font-weight-semibold" },
23
+ { name: "--vk-duration-base", kind: "motion", outright: "--duration-base" },
24
+ { name: "--vk-ease-out", kind: "motion", outright: "--ease-out" },
25
+ { name: "--vk-corner-smoothing", kind: "size", outright: "--corner-smoothing" },
26
+ ];
27
+ export const NOTICE_PRIVATE = ["--notice-"];
@@ -0,0 +1,100 @@
1
+ /* The Notice. Every value it draws with is a public name (controls/notice/tokens.ts); this file only says which name
2
+ each part and meaning takes. Its actions are any
3
+ Button, a label's the Button's text kind; its × the quiet Button.
4
+
5
+ The rules sit in the components layer, so a utility class on a notice still wins. */
6
+ @layer components {
7
+
8
+ /* ── The notice: its meaning's ground, one step stronger than the palest, so it reads as its colour; no
9
+ edge (neutral, below, has a hairline); the radius's corners, 10px by 12px; the words in the text colour, never the meaning's ─────── */
10
+ .o-notice {
11
+ display: flex; align-items: flex-start; gap: calc(var(--vk-spacing) * 2.5); box-sizing: border-box; min-width: 0;
12
+ padding: calc(var(--vk-spacing) * 2.5) calc(var(--vk-spacing) * 3); border-radius: var(--vk-radius-lg); background-color: var(--notice-ground);
13
+ color: var(--vk-fg); font-size: var(--vk-font-size-sm); line-height: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm));
14
+ transition: opacity var(--vk-duration-fast) var(--vk-ease-in), translate var(--vk-duration-fast) var(--vk-ease-in);
15
+ }
16
+ /* The icon carries the meaning: 16px, level with the first line, 10px before the words. */
17
+ .o-notice-icon { flex: none; width: calc(var(--vk-spacing) * 4); height: calc(var(--vk-spacing) * 4); margin-top: calc(var(--vk-spacing) * 0.5); }
18
+ .o-notice[data-meaning="information"] { --notice-ground: var(--vk-info-subtler); }
19
+ .o-notice[data-meaning="information"] > .o-notice-icon { color: var(--vk-info); }
20
+ .o-notice[data-meaning="success"] { --notice-ground: var(--vk-success-subtler); }
21
+ .o-notice[data-meaning="success"] > .o-notice-icon { color: var(--vk-success); }
22
+ .o-notice[data-meaning="warning"] { --notice-ground: var(--vk-warning-subtler); }
23
+ .o-notice[data-meaning="warning"] > .o-notice-icon { color: var(--vk-warning); }
24
+ .o-notice[data-meaning="danger"] { --notice-ground: var(--vk-danger-subtler); }
25
+ .o-notice[data-meaning="danger"] > .o-notice-icon { color: var(--vk-danger); }
26
+ .o-notice-body { flex: 1 1 calc(var(--vk-spacing) * 55); min-width: 0; display: grid; gap: calc(var(--vk-spacing) * 0.5); }
27
+ .o-notice-body > p { margin: 0; }
28
+
29
+ /* ── Neutral: a plain fact with no colour of its own, a quiet well: the page's
30
+ sunken ground, a hairline edge inside, its icon in the quieter text colour ──────────────────────────────── */
31
+ .o-notice[data-meaning="neutral"] { --notice-ground: var(--vk-sunken); --notice-edge: var(--vk-border-subtle); box-shadow: inset 0 0 0 var(--vk-border-width) var(--vk-border-subtle); }
32
+ .o-notice[data-meaning="neutral"] > .o-notice-icon { color: var(--vk-fg-subtle); }
33
+ /* Its own icon, any 16px icon, in its meaning's colour like the meaning's own. */
34
+ span.o-notice-icon { display: grid; place-items: center; }
35
+ span.o-notice-icon > svg { width: 100%; height: 100%; }
36
+ /* Paragraphs, 8px apart; a link in its sentence underlined in the words' colour, as shadcn's. */
37
+ .o-notice-text > p { margin: 0; }
38
+ .o-notice-text > p + p { margin-top: calc(var(--vk-spacing) * 2); }
39
+ .o-notice-text a {
40
+ color: inherit; text-decoration: underline; text-decoration-thickness: var(--vk-border-width);
41
+ text-underline-offset: calc(var(--vk-spacing) * 0.75); text-decoration-color: var(--vk-fg-subtlest);
42
+ }
43
+ @media (hover: hover) { .o-notice-text a:hover { text-decoration-color: currentColor; } }
44
+
45
+ /* ── With a title: the title in semibold, the sentence under it quieter, 12px by 14px; its actions under
46
+ the sentence ──────────────────────────────────────────────────────────────────────────────────── */
47
+ .o-notice.o-notice-titled { gap: calc(var(--vk-spacing) * 3); padding: calc(var(--vk-spacing) * 3) calc(var(--vk-spacing) * 3.5); }
48
+ .o-notice-title { font-weight: var(--vk-font-weight-semibold); }
49
+ .o-notice-titled .o-notice-text { color: var(--vk-fg-subtle); }
50
+ .o-notice-below { display: flex; gap: calc(var(--vk-spacing) * 1); margin: calc(var(--vk-spacing) * 1.5) 0 0 calc(var(--vk-spacing) * -2.5); }
51
+ /* A first action that isn't the text kind (an outline) stands with its edge at the sentence's first letter. */
52
+ .o-notice-below:has(> :first-child:not(.o-button-text)) { margin-left: 0; }
53
+
54
+ /* ── Its actions at the end of its line; × puts it away: the Button, quiet, icon only, extra small ──── */
55
+ .o-notice-acts { flex: none; display: flex; align-items: center; gap: calc(var(--vk-spacing) * 0.5); margin: calc(var(--vk-spacing) * -1) calc(var(--vk-spacing) * -1.5) calc(var(--vk-spacing) * -1) 0; }
56
+ .o-button.o-notice-x { flex: none; margin: calc(var(--vk-spacing) * -1) calc(var(--vk-spacing) * -1.5) calc(var(--vk-spacing) * -1) 0; }
57
+ .o-notice-acts + .o-button.o-notice-x { margin-left: calc(var(--vk-spacing) * -2); }
58
+
59
+ /* ── Arrived because of something just done, it fades in; put away or resolved, it fades out ────────── */
60
+ .o-notice.o-notice-arrived { animation: vk-notice-fade-in var(--vk-duration-base) var(--vk-ease-out); }
61
+ .o-notice.o-notice-going { opacity: 0; translate: 0 calc(var(--vk-spacing) * -0.5); }
62
+
63
+ /* ── On the phone the actions drop under the sentence, lined up with it; × stays at the end of the first
64
+ line ────────────────────────────────────────────────────────────────────────────────────────────── */
65
+ .o-notice:where([data-vk-phone], [data-vk-phone] *) { flex-wrap: wrap; }
66
+ .o-notice-body:where([data-vk-phone], [data-vk-phone] *) { flex: 1 1 0; }
67
+ .o-notice:where([data-vk-phone], [data-vk-phone] *) > .o-notice-acts { order: 3; flex-basis: 100%; box-sizing: border-box; margin: calc(var(--vk-spacing) * 0.5) 0 calc(var(--vk-spacing) * -1.5); padding-left: calc(var(--vk-spacing) * 4); }
68
+ .o-notice-acts:where([data-vk-phone], [data-vk-phone] *) + .o-button.o-notice-x { margin-left: 0; }
69
+ /* A first action that isn't the text kind stands with its edge at the sentence's first letter: the icon and its gap. */
70
+ .o-notice:where([data-vk-phone], [data-vk-phone] *):has(> .o-notice-icon) > .o-notice-acts:has(> :first-child:not(.o-button-text)) { padding-left: calc(var(--vk-spacing) * 6.5); }
71
+ /* With no icon the sentence starts at the padding: so do the actions, the text kind's words with it. */
72
+ .o-notice:where([data-vk-phone], [data-vk-phone] *):not(:has(> .o-notice-icon)) > .o-notice-acts { padding-left: 0; }
73
+ .o-notice:where([data-vk-phone], [data-vk-phone] *):not(:has(> .o-notice-icon)) > .o-notice-acts:has(> :first-child.o-button-text) { margin-left: calc(var(--vk-spacing) * -2.5); }
74
+
75
+ /* Under reduced motion it just goes. */
76
+ @media (prefers-reduced-motion: reduce) { .o-notice { transition: none; } .o-notice.o-notice-arrived { animation: none; } }
77
+ /* ── Its corners smooth: following corner-smoothing, drawn with the smooth outline
78
+ (ViewKit's smooth.css) in every browser that knows shape(); one that doesn't keeps the corners above. Its round part is fitted to its
79
+ one line, as a control's is. Its ×, 6px in, rings itself 2px out, so the notice is never clipped: its edge (::before, neutral's
80
+ hairline, or its ground where it has none) and its ground (::after, a line in, its corner a line smaller) are layers inside it,
81
+ as the Popover's are. ── */
82
+ @supports (clip-path: shape(evenodd from 0 0, curve by 1px 1px with 1px 0 / 1px 0, close, move to 0 0, hline to 1px, close)) and (width: calc(tan(atan2(1px, 1px)) * 1px)) {
83
+ .o-notice {
84
+ --smooth-amount: var(--vk-corner-smoothing); --notice-side: calc(var(--vk-font-size-sm) * var(--vk-line-height-sm) + var(--vk-spacing) * 5);
85
+ --notice-fit: min(var(--vk-radius-lg), var(--notice-side) / (2 + 2 * var(--smooth-amount, 0.7)));
86
+ --smooth-t: var(--notice-fit); --smooth-side: var(--notice-side);
87
+ position: relative; isolation: isolate; border-radius: var(--notice-fit); background-color: transparent; box-shadow: none;
88
+ }
89
+ .o-notice[data-meaning="neutral"] { box-shadow: none; }
90
+ .o-notice::before, .o-notice::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; border-radius: inherit; }
91
+ .o-notice::before { background-color: var(--notice-edge, var(--notice-ground)); clip-path: shape(var(--smooth-outline)); }
92
+ .o-notice::after {
93
+ --smooth-t: max(0px, var(--notice-fit) - var(--vk-border-width));
94
+ inset: var(--vk-border-width); border-radius: calc(var(--notice-fit) - var(--vk-border-width)); background-color: var(--notice-ground); clip-path: shape(var(--smooth-outline));
95
+ }
96
+ }
97
+ }
98
+
99
+ /* What arrives shows from nothing. */
100
+ @keyframes vk-notice-fade-in { from { opacity: 0; } }
@@ -0,0 +1,31 @@
1
+ /** What is typed: a number, money (its currency before it) or a percent (its % after it). A range is the Compound editor's. */
2
+ export type NumberKind = "number" | "money" | "percent";
3
+ /** A currency money may be in: its code (EUR), its sign (€) and its name (Euro). */
4
+ export interface Currency {
5
+ code: string;
6
+ sign: string;
7
+ name: string;
8
+ }
9
+ /** A unit a number may be in, or a currency: its code (kg, EUR), its name, and the sign that stands for it where it has one (€);
10
+ * a unit with none is drawn by its code. */
11
+ export interface Unit {
12
+ code: string;
13
+ name: string;
14
+ sign?: string;
15
+ }
16
+ /** The locale the box reads what is typed with: the one handed, or, where the decimal separator handed isn't the one it writes, a
17
+ * locale that writes it (en for ".", de for ","). The box shows no grouping, so only the separator changes. */
18
+ export declare function boxLocale(locale: string | undefined, decimal?: "." | ","): string | undefined;
19
+ /** How money's currency and a percent's % stand in what a cell shows: Attio's code (EUR 84,000.00, 40%), or the sign
20
+ * (€ 84,000, 40 %). The Number editor's units option (looks.ts) picks it. */
21
+ export type Units = "code" | "sign";
22
+ /** What a cell shows of a number once it is kept; nothing for nothing held. In Attio's units (code, the default) a number
23
+ * keeps the field's decimals when it says them (else up to two), money is its code and the amount with two decimals
24
+ * unless the field says otherwise ("-EUR 1,500.00"), a percent stands against its number ("40%"), as Attio and ViewKit's
25
+ * own formatter draw them. In the sign's, today's: "1,250", "€ 84,000", "40 %". */
26
+ export declare function numberText(value: number | null, kind?: NumberKind, o?: {
27
+ currency?: Currency;
28
+ units?: Units;
29
+ decimals?: number;
30
+ }): string;
31
+ export declare function readTyped(text: string, decimal?: "." | ","): number | null;
@@ -0,0 +1,79 @@
1
+ const separators = new Map();
2
+ const separatorOf = (locale) => {
3
+ const key = locale ?? "";
4
+ if (!separators.has(key)) {
5
+ let at = ".";
6
+ try {
7
+ at = new Intl.NumberFormat(locale).formatToParts(1.5).find((p) => p.type === "decimal")?.value ?? ".";
8
+ }
9
+ catch { }
10
+ separators.set(key, at);
11
+ }
12
+ return separators.get(key);
13
+ };
14
+ export function boxLocale(locale, decimal) {
15
+ if (!decimal || separatorOf(locale) === decimal)
16
+ return locale;
17
+ return decimal === "," ? "de" : "en";
18
+ }
19
+ const formats = new Map();
20
+ const upToTwo = new Intl.NumberFormat("en", { maximumFractionDigits: 2 });
21
+ const n = (value) => upToTwo.format(value);
22
+ const exactly = (value, decimals) => {
23
+ if (!formats.has(decimals))
24
+ formats.set(decimals, new Intl.NumberFormat("en", { minimumFractionDigits: decimals, maximumFractionDigits: decimals }));
25
+ const out = formats.get(decimals).format(Math.abs(value));
26
+ return value < 0 && /[1-9]/.test(out) ? `-${out}` : out;
27
+ };
28
+ export function numberText(value, kind = "number", o = {}) {
29
+ if (value == null || Number.isNaN(value))
30
+ return "";
31
+ const { currency, units = "code", decimals } = o;
32
+ if (units === "sign")
33
+ return kind === "money" ? `${currency ? `${currency.sign} ` : ""}${n(value)}` : kind === "percent" ? `${n(value)} %` : n(value);
34
+ if (kind === "money") {
35
+ const amount = exactly(value, decimals ?? 2), minus = amount.startsWith("-");
36
+ return `${minus ? "-" : ""}${currency ? `${currency.code} ` : ""}${minus ? amount.slice(1) : amount}`;
37
+ }
38
+ if (kind === "percent")
39
+ return `${exactly(value, decimals ?? 0)}%`;
40
+ return decimals == null ? n(value) : exactly(value, decimals);
41
+ }
42
+ const exact = (body, decimal) => {
43
+ const group = decimal === "." ? "," : ".", at = body.indexOf(decimal);
44
+ if (at !== body.lastIndexOf(decimal))
45
+ return Number.NaN;
46
+ const head = at < 0 ? body : body.slice(0, at), fraction = at < 0 ? "" : body.slice(at + 1);
47
+ if (!/^\d*$/.test(fraction))
48
+ return Number.NaN;
49
+ const parts = head.split(group);
50
+ const digits = parts.length === 1 ? (/^\d*$/.test(head) ? head : null)
51
+ : /^[1-9]\d{0,2}$/.test(parts[0]) && parts.slice(1).every((x) => /^\d{3}$/.test(x)) ? parts.join("") : null;
52
+ if (digits == null || (digits === "" && fraction === ""))
53
+ return Number.NaN;
54
+ return Number(`${digits || "0"}.${fraction || "0"}`);
55
+ };
56
+ export function readTyped(text, decimal) {
57
+ const compact = text.replace(/[\s\u00a0\u202f]/g, "").replace(/[\u2212\u2012-\u2015]/g, "-");
58
+ if (!compact)
59
+ return null;
60
+ const m = /^([+-]?)([\d.,]+)$/.exec(compact);
61
+ if (!m)
62
+ return Number.NaN;
63
+ const body = m[2], dots = body.split(".").length - 1, commas = body.split(",").length - 1;
64
+ let sep;
65
+ if (decimal)
66
+ sep = decimal;
67
+ else if (dots && commas)
68
+ sep = body.lastIndexOf(".") > body.lastIndexOf(",") ? "." : ",";
69
+ else if (dots)
70
+ sep = dots === 1 ? "." : ",";
71
+ else if (commas !== 1)
72
+ sep = ".";
73
+ else {
74
+ const [head, tail] = body.split(",");
75
+ sep = /^[1-9]\d{0,2}$/.test(head) && /^\d{3}$/.test(tail) ? "." : ",";
76
+ }
77
+ const v = exact(body, sep);
78
+ return m[1] === "-" && v !== 0 ? -v : v;
79
+ }
@@ -0,0 +1,14 @@
1
+ import { type PieceLooks } from "../../looks/looks.js";
2
+ export type NumberEditorOptionId = "arrows" | "units" | "sheet";
3
+ /** What the body reads from the frame round it. */
4
+ export interface NumberEditorWorn {
5
+ arrows: "editing" | "none";
6
+ units: "code" | "sign";
7
+ sheet: "line" | "field";
8
+ }
9
+ /** The Number editor's options and looks. */
10
+ export declare const NUMBER_EDITOR_LOOKS: PieceLooks<NumberEditorOptionId>;
11
+ /** The options worn round `el`, each from the nearest frame that picks it; outside any frame, Attio's. */
12
+ export declare const numberEditorWornOf: (el: Element | null) => NumberEditorWorn;
13
+ /** The attributes the body watches, so a look changed while it is open reaches it. */
14
+ export declare const NUMBER_EDITOR_ATTRS: string[];
@@ -0,0 +1,17 @@
1
+ import { lookWornOf } from "../../looks/looks.js";
2
+ const options = [
3
+ { id: "arrows", name: "Arrows", device: "desktop", def: "editing", values: [{ id: "editing", name: "While editing" }, { id: "none", name: "None" }] },
4
+ { id: "units", name: "Units", def: "code", values: [{ id: "code", name: "Code" }, { id: "sign", name: "Sign" }] },
5
+ { id: "sheet", name: "In the Sheet", device: "phone", def: "line", values: [{ id: "line", name: "Line" }, { id: "field", name: "Number field" }] },
6
+ ];
7
+ export const NUMBER_EDITOR_LOOKS = {
8
+ id: "number-editor",
9
+ name: "Number editor",
10
+ options,
11
+ looks: [
12
+ { id: "attio", name: "Attio", picks: { arrows: "editing", units: "code", sheet: "line" } },
13
+ { id: "mihai", name: "Mihai's", picks: { arrows: "none", units: "sign", sheet: "field" } },
14
+ ],
15
+ };
16
+ export const numberEditorWornOf = (el) => lookWornOf(NUMBER_EDITOR_LOOKS, el, ["arrows", "units", "sheet"]);
17
+ export const NUMBER_EDITOR_ATTRS = NUMBER_EDITOR_LOOKS.options.map((o) => `data-number-editor-${o.id}`);
@@ -0,0 +1,16 @@
1
+ import { type ViewsMessageResolver } from "../../contract.js";
2
+ import type { ViewsNumberBodyProps } from "../../provider/components.js";
3
+ import type { Currency } from "./format.js";
4
+ import { type NumberEditorProps } from "./number-editor.js";
5
+ import type { NumberEditorWords } from "./words.js";
6
+ /** A currency's code as the editor's Currency: its sign (narrow, as € or £) in the locale and its name in the language, from
7
+ * Intl; a code Intl doesn't know is its own sign and name. */
8
+ export declare function currencyOf(code: string, locale: string, language?: string): Currency;
9
+ /** The Number editor's words in the app's messages: the number field's steps the old editors' keys, a currency's list the
10
+ * Currency menu's, the rest its own. */
11
+ export declare function numberEditorWordsOf(say: ViewsMessageResolver): NumberEditorWords;
12
+ /** ViewKit's number body's props as the Number editor's, held as a shell that keeps the draft. */
13
+ export declare function numberEditorPropsOf({ label, kind, value, unit, units, onValueChange, onDone, decimals, min, max, locale, decimal, align, typed, autoFocus, form }: ViewsNumberBodyProps, words?: NumberEditorWords, language?: string): NumberEditorProps;
14
+ /** ViewKit's number body, drawn as the Number editor in the app's words; on a phone, the currencies' step told to its sheet.
15
+ * Outside a provider (a page drawing the body alone), ViewKit's English. */
16
+ export declare function MapNumberBody(props: ViewsNumberBodyProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { resolveViewsMessage } from "../../contract.js";
5
+ import { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
6
+ import { ViewsContext } from "../../provider/context.js";
7
+ import { pickerWordsOf } from "../picker/map-picker.js";
8
+ import { useToldStep } from "../internal/told-step.js";
9
+ import { useNumberEditor } from "./number-editor.js";
10
+ const signs = new Map();
11
+ export function currencyOf(code, locale, language = locale) {
12
+ const key = `${locale}␟${language}␟${code}`;
13
+ if (!signs.has(key)) {
14
+ let sign = code, name = code;
15
+ try {
16
+ sign = new Intl.NumberFormat(locale, { style: "currency", currency: code, currencyDisplay: "narrowSymbol" }).formatToParts(0).find((p) => p.type === "currency")?.value ?? code;
17
+ }
18
+ catch { }
19
+ try {
20
+ name = new Intl.DisplayNames([language], { type: "currency" }).of(code) ?? code;
21
+ }
22
+ catch { }
23
+ signs.set(key, { code, sign, name });
24
+ }
25
+ return signs.get(key);
26
+ }
27
+ export function numberEditorWordsOf(say) {
28
+ return {
29
+ currency: say({ key: "views.menus.currency" }),
30
+ unit: say({ key: "views.editors.number-unit" }),
31
+ findCurrency: say({ key: "views.editors.number-find-currency" }),
32
+ searchCurrency: say({ key: "views.editors.number-search-currency" }),
33
+ findUnit: say({ key: "views.editors.number-find-unit" }),
34
+ searchUnit: say({ key: "views.editors.number-search-unit" }),
35
+ named: (unit, name) => say({ key: "views.editors.number-unit-named", values: { unit, name } }),
36
+ increase: say({ key: "views.editors.number-increase" }),
37
+ decrease: say({ key: "views.editors.number-decrease" }),
38
+ numberField: say({ key: "views.editors.number-field" }),
39
+ picker: pickerWordsOf(say),
40
+ };
41
+ }
42
+ export function numberEditorPropsOf({ label, kind, value, unit, units, onValueChange, onDone, decimals, min, max, locale, decimal, align, typed, autoFocus, form }, words, language) {
43
+ const codes = units?.length ? [...units] : unit ? [unit] : [];
44
+ const props = { label, kind, value, onValueChange, onDone, decimals, locale, align, autoFocus, form, draft: "shell", popupData: { [EDITOR_INNER_ESCAPE]: "" }, ...(words ? { words } : {}) };
45
+ if (kind === "money")
46
+ Object.assign(props, { currency: unit, currencies: codes.map((c) => currencyOf(c, locale, language)) });
47
+ else if (kind === "number" && unit)
48
+ Object.assign(props, { unit, units: codes.map((c) => ({ code: c, name: c })) });
49
+ return { ...props, ...(min !== undefined && { min }), ...(max !== undefined && { max }), ...(decimal && { decimal }), ...(typed !== undefined && { typed }) };
50
+ }
51
+ export function MapNumberBody(props) {
52
+ const views = React.useContext(ViewsContext), messages = views?.messages ?? resolveViewsMessage;
53
+ const words = React.useMemo(() => numberEditorWordsOf(messages), [messages]);
54
+ const parts = useNumberEditor(numberEditorPropsOf(props, words, views?.conventions.language));
55
+ useToldStep(parts, props.onStepChange);
56
+ return _jsx(_Fragment, { children: parts.body });
57
+ }
@@ -0,0 +1,72 @@
1
+ import * as React from "react";
2
+ import { type SheetHeadProps } from "../sheet/bottom-sheet.js";
3
+ import { type Currency, type NumberKind, type Unit } from "./format.js";
4
+ import { type NumberEditorWorn } from "./looks.js";
5
+ import { type NumberEditorWords } from "./words.js";
6
+ export type { Currency, NumberKind, Unit } from "./format.js";
7
+ /** The parts a shell pours in: the body, and on a phone the Sheet head's buttons, and its title while it is on a step of
8
+ * its own (money's currencies). */
9
+ export interface NumberEditorParts {
10
+ body: React.ReactNode;
11
+ head: Pick<SheetHeadProps, "left" | "right" | "onBack" | "close">;
12
+ title?: string;
13
+ }
14
+ interface Common {
15
+ /** The field's name: the Sheet's title, and the box's name to a screen reader. */
16
+ label: string;
17
+ /** The job is done and what holds it closes: after a keep, and after ✕, which leaves it as it was; Escape leaves it as it was. */
18
+ onDone?: () => void;
19
+ /** Takes the focus as it opens; a page standing several still says false. */
20
+ autoFocus?: boolean;
21
+ /** Which form; by default the phone's in a phone's window or in a PhoneHost screen, else the computer's. */
22
+ form?: "computer" | "phone";
23
+ }
24
+ export interface NumberEditorProps extends Common {
25
+ /** A number, money or a percent. */
26
+ kind?: NumberKind;
27
+ /** What the field holds. */
28
+ value: number | null;
29
+ /** Money: the code of the currency it is in. */
30
+ currency?: string;
31
+ /** Money: the currencies it may be in. One, or none, shows its sign with nothing to press. */
32
+ currencies?: Currency[];
33
+ /** A number: the code of the unit it is in (kg). */
34
+ unit?: string;
35
+ /** A number: the units it may be in, drawn as money's currencies are: one, or none, has nothing to press (in Attio's look the
36
+ * bare number, in Mihai's its unit's words). */
37
+ units?: Unit[];
38
+ /** What it keeps when it changed: the number, and money's currency or a number's unit. Enter or a press elsewhere on a
39
+ * computer, ✓ on a phone. Held as a shell, every change as it is made: null when its box is emptied, NaN for text that reads as
40
+ * no number, a unit picked with the value it holds. */
41
+ onValueChange: (value: number | null, unit?: string) => void;
42
+ min?: number;
43
+ max?: number;
44
+ /** What one arrow steps it by: 1 unless said; Shift and an arrow, ten times that. */
45
+ step?: number;
46
+ /** The most digits after the point its box takes: 2 unless said. */
47
+ decimals?: number;
48
+ /** How what is typed is read: the locale (BCP 47), and the decimal separator where it is stated: the box reads and steps with
49
+ * boxLocale's locale; held as a shell, what it hands is readTyped's reading, either separator where none is stated. */
50
+ locale?: string;
51
+ decimal?: "." | ",";
52
+ /** Where its value stands on a computer: at its end unless said (a cell), or at its start (a field row). */
53
+ align?: "start" | "end";
54
+ /** What was typed on what opened it (a key on a cell): the box starts with it. */
55
+ typed?: string;
56
+ /** What its own popups carry (the units' list on a computer), so what holds it knows them as its own. */
57
+ popupData?: Readonly<Record<`data-${string}`, string>>;
58
+ /** Where the draft, the close and a phone's ✕ and ✓ stand: `own` (the default), the Number editor's; `shell`, its holder's
59
+ * (ViewKit's number editor): `value` and money's `currency` or a number's `unit` are its holder's, every change is handed as it is made, Enter
60
+ * with any modifier only calls onDone, a press elsewhere and Escape keep nothing, and a phone hands no ✕ or ✓. As the Text
61
+ * editor's, the Picker's and the Date editor's. */
62
+ draft?: "own" | "shell";
63
+ /** Its words: its lists' names and searches, the code button's name and the number field's steps; English unless handed. */
64
+ words?: Partial<NumberEditorWords>;
65
+ }
66
+ /** The options worn round an element (looks.ts): a ref for it, and what it wears, Attio's until it stands, read again as
67
+ * Tweaks change them. */
68
+ export declare function useNumberEditorWorn(): [(el: Element | null) => void, NumberEditorWorn];
69
+ /** A number, money or a percent: its state and the parts a shell pours in. */
70
+ export declare function useNumberEditor(props: NumberEditorProps): NumberEditorParts;
71
+ /** The body alone: a number, money or a percent. */
72
+ export declare function NumberEditor(props: NumberEditorProps): import("react/jsx-runtime").JSX.Element;