viewkitjs 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/MIGRATION.md +97 -8
  3. package/package.json +1 -1
  4. package/views/dist/cells/cell-format.d.ts +2 -2
  5. package/views/dist/cells/cell-values.js +0 -2
  6. package/views/dist/contract.d.ts +15 -18
  7. package/views/dist/contract.js +13 -27
  8. package/views/dist/controls/controls.d.ts +2 -4
  9. package/views/dist/controls/controls.js +2 -2
  10. package/views/dist/controls/customize/customize.d.ts +51 -0
  11. package/views/dist/controls/customize/customize.js +128 -23
  12. package/views/dist/controls/customize/map-customize-body.d.ts +0 -3
  13. package/views/dist/controls/customize/map-customize-body.js +46 -11
  14. package/views/dist/controls/customize/map-ranges.d.ts +23 -0
  15. package/views/dist/controls/customize/map-ranges.js +41 -0
  16. package/views/dist/controls/customize/rules.d.ts +17 -1
  17. package/views/dist/controls/customize/rules.js +2 -0
  18. package/views/dist/controls/customize/words.d.ts +7 -0
  19. package/views/dist/controls/customize/words.js +5 -0
  20. package/views/dist/controls/customize.css +3 -0
  21. package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
  22. package/views/dist/controls/filter-editor/filter-editor.js +1 -0
  23. package/views/dist/controls/filter-editor/rules.d.ts +1 -2
  24. package/views/dist/controls/index.d.ts +8 -8
  25. package/views/dist/controls/index.js +8 -8
  26. package/views/dist/controls/menu-list/menu-list.d.ts +16 -1
  27. package/views/dist/controls/menu-list/menu-list.js +26 -8
  28. package/views/dist/controls/menu-list.css +8 -0
  29. package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +1 -1
  30. package/views/dist/controls/quick-filters/map-quick-filters-body.js +6 -3
  31. package/views/dist/controls/sheet/map-sheet.js +1 -1
  32. package/views/dist/controls/text-editor/map-text-body.d.ts +1 -1
  33. package/views/dist/controls/text-editor/map-text-body.js +2 -2
  34. package/views/dist/controls/text-editor/text-editor.d.ts +3 -0
  35. package/views/dist/controls/text-editor/text-editor.js +16 -2
  36. package/views/dist/controls/text-editor.css +11 -0
  37. package/views/dist/controls/values-editor/values.js +6 -2
  38. package/views/dist/display/options.d.ts +1 -1
  39. package/views/dist/display/rich-text.js +0 -1
  40. package/views/dist/editors/ChipsEditor.d.ts +4 -5
  41. package/views/dist/editors/ChipsEditor.js +12 -78
  42. package/views/dist/editors/DateEditor.d.ts +12 -16
  43. package/views/dist/editors/DateEditor.js +40 -191
  44. package/views/dist/editors/EditorPanel.d.ts +2 -6
  45. package/views/dist/editors/EditorPanel.js +2 -2
  46. package/views/dist/editors/LocationEditor.d.ts +11 -19
  47. package/views/dist/editors/LocationEditor.js +19 -211
  48. package/views/dist/editors/NameEditor.d.ts +8 -16
  49. package/views/dist/editors/NameEditor.js +11 -100
  50. package/views/dist/editors/NumberEditor.d.ts +14 -21
  51. package/views/dist/editors/NumberEditor.js +22 -49
  52. package/views/dist/editors/RangeEditor.d.ts +9 -33
  53. package/views/dist/editors/RangeEditor.js +12 -97
  54. package/views/dist/editors/RelationEditor.d.ts +6 -9
  55. package/views/dist/editors/RelationEditor.js +11 -30
  56. package/views/dist/editors/RelationSetEditor.d.ts +13 -24
  57. package/views/dist/editors/RelationSetEditor.js +33 -101
  58. package/views/dist/editors/SelectEditor.d.ts +15 -17
  59. package/views/dist/editors/SelectEditor.js +15 -94
  60. package/views/dist/editors/TextEditor.d.ts +23 -26
  61. package/views/dist/editors/TextEditor.js +11 -48
  62. package/views/dist/editors/ValueListEditor.d.ts +14 -23
  63. package/views/dist/editors/ValueListEditor.js +16 -202
  64. package/views/dist/editors/body-panel.d.ts +13 -7
  65. package/views/dist/editors/body-panel.js +3 -7
  66. package/views/dist/editors/edit-cores.d.ts +15 -15
  67. package/views/dist/editors/edit-cores.js +14 -14
  68. package/views/dist/editors/number-body.d.ts +1 -1
  69. package/views/dist/editors/number-step.d.ts +0 -34
  70. package/views/dist/editors/number-step.js +0 -37
  71. package/views/dist/editors/option-add-flow.d.ts +1 -13
  72. package/views/dist/editors/option-add-flow.js +0 -22
  73. package/views/dist/editors/relation-links-body.d.ts +2 -3
  74. package/views/dist/editors/relation-picker.d.ts +13 -3
  75. package/views/dist/editors/relation-source.d.ts +0 -22
  76. package/views/dist/editors/relation-source.js +0 -21
  77. package/views/dist/field-row/FieldRow.js +5 -6
  78. package/views/dist/field-row/FieldRowLane.js +0 -1
  79. package/views/dist/field-row/editors/RowChipsEditor.js +2 -2
  80. package/views/dist/field-row/editors/RowDateEditor.d.ts +2 -2
  81. package/views/dist/field-row/editors/RowDateEditor.js +2 -2
  82. package/views/dist/field-row/editors/RowNameEditor.d.ts +2 -5
  83. package/views/dist/field-row/editors/RowNameEditor.js +7 -12
  84. package/views/dist/field-row/editors/RowNumberEditor.d.ts +1 -1
  85. package/views/dist/field-row/editors/RowNumberEditor.js +4 -4
  86. package/views/dist/field-row/editors/RowPlaceEditor.js +3 -3
  87. package/views/dist/field-row/editors/RowRangeEditor.d.ts +2 -5
  88. package/views/dist/field-row/editors/RowRangeEditor.js +7 -14
  89. package/views/dist/field-row/editors/RowRelationEditor.js +3 -3
  90. package/views/dist/field-row/editors/RowSelectEditor.js +2 -2
  91. package/views/dist/field-row/editors/RowTextEditor.d.ts +1 -1
  92. package/views/dist/field-row/editors/RowTextEditor.js +3 -4
  93. package/views/dist/field-row/editors/RowValueListEditor.js +5 -5
  94. package/views/dist/field-row/field-row-button.d.ts +6 -9
  95. package/views/dist/field-row/field-row-button.js +1 -6
  96. package/views/dist/field-row/field-row-checkbox.d.ts +1 -1
  97. package/views/dist/field-row/row-target.d.ts +0 -7
  98. package/views/dist/field-row/row-target.js +0 -2
  99. package/views/dist/grid/chrome/GridAddColumn.d.ts +2 -1
  100. package/views/dist/grid/chrome/GridAddColumn.js +8 -66
  101. package/views/dist/grid/chrome/GridAggregateMenu.d.ts +5 -7
  102. package/views/dist/grid/chrome/GridAggregateMenu.js +20 -39
  103. package/views/dist/grid/chrome/GridCellEditors.d.ts +2 -2
  104. package/views/dist/grid/chrome/GridCellEditors.js +12 -12
  105. package/views/dist/grid/chrome/GridChipsEditor.js +3 -3
  106. package/views/dist/grid/chrome/GridColumnMenu.d.ts +11 -12
  107. package/views/dist/grid/chrome/GridColumnMenu.js +32 -93
  108. package/views/dist/grid/chrome/GridDateEditor.d.ts +6 -6
  109. package/views/dist/grid/chrome/GridDateEditor.js +3 -3
  110. package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -6
  111. package/views/dist/grid/chrome/GridGroupMenu.js +21 -62
  112. package/views/dist/grid/chrome/GridHeader.d.ts +1 -2
  113. package/views/dist/grid/chrome/GridHeader.js +2 -2
  114. package/views/dist/grid/chrome/GridLongTextEditor.d.ts +17 -38
  115. package/views/dist/grid/chrome/GridLongTextEditor.js +6 -7
  116. package/views/dist/grid/chrome/GridNameEditor.js +4 -4
  117. package/views/dist/grid/chrome/GridNumberEditor.d.ts +4 -5
  118. package/views/dist/grid/chrome/GridNumberEditor.js +3 -4
  119. package/views/dist/grid/chrome/GridPlaceEditor.d.ts +2 -5
  120. package/views/dist/grid/chrome/GridPlaceEditor.js +5 -5
  121. package/views/dist/grid/chrome/GridRangeEditor.d.ts +6 -12
  122. package/views/dist/grid/chrome/GridRangeEditor.js +7 -15
  123. package/views/dist/grid/chrome/GridRelationEditor.js +5 -5
  124. package/views/dist/grid/chrome/GridRow.js +0 -3
  125. package/views/dist/grid/chrome/GridRowActions.d.ts +1 -1
  126. package/views/dist/grid/chrome/GridRowActions.js +0 -5
  127. package/views/dist/grid/chrome/GridRowCells.js +9 -6
  128. package/views/dist/grid/chrome/GridSelectEditor.js +3 -3
  129. package/views/dist/grid/chrome/GridStructure.js +0 -1
  130. package/views/dist/grid/chrome/GridTable.js +1 -1
  131. package/views/dist/grid/chrome/GridTextEditor.d.ts +5 -7
  132. package/views/dist/grid/chrome/GridTextEditor.js +4 -17
  133. package/views/dist/grid/chrome/GridValueListEditor.js +4 -4
  134. package/views/dist/grid/chrome/grid-body-place.d.ts +2 -3
  135. package/views/dist/grid/chrome/grid-body-place.js +4 -8
  136. package/views/dist/grid/chrome/grid-button.d.ts +7 -10
  137. package/views/dist/grid/chrome/grid-button.js +1 -6
  138. package/views/dist/grid/chrome/grid-cell-classes.js +1 -1
  139. package/views/dist/grid/chrome/grid-column-menu-items.d.ts +4 -4
  140. package/views/dist/grid/chrome/grid-column-menu-items.js +10 -6
  141. package/views/dist/grid/chrome/grid-group-menu-parts.d.ts +5 -9
  142. package/views/dist/grid/chrome/grid-group-menu-parts.js +1 -3
  143. package/views/dist/grid/chrome/grid-hover.js +0 -1
  144. package/views/dist/grid/chrome/grid-menu-focus.d.ts +7 -31
  145. package/views/dist/grid/chrome/grid-menu-focus.js +7 -47
  146. package/views/dist/grid/chrome/grid-styles.d.ts +0 -3
  147. package/views/dist/grid/chrome/grid-styles.js +0 -1
  148. package/views/dist/grid/chrome/grid-table-props.d.ts +6 -10
  149. package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -4
  150. package/views/dist/grid/core/editing-controller.d.ts +2 -1
  151. package/views/dist/grid/core/editing-controller.js +10 -2
  152. package/views/dist/grid/core/refusal-sentence.d.ts +3 -0
  153. package/views/dist/grid/core/refusal-sentence.js +2 -2
  154. package/views/dist/grid/core/write-states.d.ts +3 -1
  155. package/views/dist/grid/core/write-states.js +6 -2
  156. package/views/dist/grid/grid.css +1 -1
  157. package/views/dist/model/body-frame.d.ts +0 -32
  158. package/views/dist/model/body-frame.js +1 -15
  159. package/views/dist/model/column-inspect.d.ts +5 -5
  160. package/views/dist/model/column-inspect.js +2 -2
  161. package/views/dist/panels/customize-body.d.ts +1 -10
  162. package/views/dist/panels/customize-body.js +0 -3
  163. package/views/dist/panels/filter/MenuSelect.js +0 -5
  164. package/views/dist/panels/filter/RangeFilterBody.js +0 -1
  165. package/views/dist/panels/filter/details.d.ts +1 -5
  166. package/views/dist/panels/filter/details.js +0 -13
  167. package/views/dist/panels/filter/filter-list.d.ts +0 -1
  168. package/views/dist/panels/filter/filter-list.js +1 -1
  169. package/views/dist/panels/panel-button.d.ts +10 -12
  170. package/views/dist/panels/panel-button.js +1 -6
  171. package/views/dist/panels/react/chrome.d.ts +0 -17
  172. package/views/dist/panels/react/chrome.js +0 -8
  173. package/views/dist/panels/react/customize-body.d.ts +9 -12
  174. package/views/dist/panels/react/customize-body.js +57 -11
  175. package/views/dist/panels/react/customize.d.ts +9 -12
  176. package/views/dist/panels/react/customize.js +3 -112
  177. package/views/dist/panels/react/filter/FilterEditor.d.ts +4 -18
  178. package/views/dist/panels/react/filter/FilterEditor.js +6 -330
  179. package/views/dist/panels/react/filter/FilterFieldList.d.ts +1 -1
  180. package/views/dist/panels/react/filter/FilterFieldList.js +27 -59
  181. package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +1 -11
  182. package/views/dist/panels/react/filter/PhoneFilterEditor.js +8 -144
  183. package/views/dist/panels/react/filter/editor-ctx.d.ts +1 -33
  184. package/views/dist/panels/react/filter/editor-ctx.js +5 -33
  185. package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -6
  186. package/views/dist/panels/react/filter/filter-part-body.js +0 -5
  187. package/views/dist/panels/react/filter/rule-writes.d.ts +1 -26
  188. package/views/dist/panels/react/filter/rule-writes.js +4 -95
  189. package/views/dist/panels/react/order-details.d.ts +1 -26
  190. package/views/dist/panels/react/order-details.js +3 -69
  191. package/views/dist/panels/react/panel-header.js +0 -1
  192. package/views/dist/panels/react/popover.d.ts +4 -7
  193. package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +2 -4
  194. package/views/dist/panels/react/quick/QuickFiltersPanel.js +16 -137
  195. package/views/dist/panels/react/sort/SortEditor.d.ts +4 -4
  196. package/views/dist/panels/react/sort/SortEditor.js +8 -245
  197. package/views/dist/panels/react/sort/SortFieldList.d.ts +1 -1
  198. package/views/dist/panels/react/sort/SortFieldList.js +11 -25
  199. package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +2 -2
  200. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -16
  201. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
  202. package/views/dist/panels/react/toolbar/ToolbarSave.js +0 -4
  203. package/views/dist/panels/react/toolbar/ToolbarSearch.js +0 -1
  204. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -3
  205. package/views/dist/panels/react/view-actions.js +0 -1
  206. package/views/dist/panels/react/views-row/FoldingViewRow.js +2 -5
  207. package/views/dist/panels/react/views-row/ViewCreatePill.js +0 -1
  208. package/views/dist/panels/react/views-row/ViewPicker.js +7 -43
  209. package/views/dist/panels/react/views-row/ViewPickerRow.js +0 -2
  210. package/views/dist/panels/react/views-row/menu-classes.d.ts +0 -4
  211. package/views/dist/panels/react/views-row/menu-classes.js +0 -2
  212. package/views/dist/panels/react.d.ts +5 -12
  213. package/views/dist/panels/react.js +5 -12
  214. package/views/dist/provider/ViewsProvider.d.ts +2 -46
  215. package/views/dist/provider/ViewsProvider.js +2 -22
  216. package/views/dist/provider/components.d.ts +153 -106
  217. package/views/dist/provider/context.d.ts +1 -21
  218. package/views/dist/provider/missing-slot.d.ts +3 -7
  219. package/views/dist/provider/missing-slot.js +2 -9
  220. package/views/dist/react.d.ts +1 -2
  221. package/views/dist/selection/SelectionBar.js +2 -3
  222. package/views/dist/styles.css +40 -168
  223. package/views/dist/styles.unlayered.css +40 -168
  224. package/views/docs/contract.md +99 -123
  225. package/views/docs/getting-started.md +222 -2
  226. package/views/docs/guides/cells.md +222 -2
  227. package/views/docs/guides/display.md +1 -1
  228. package/views/docs/guides/editors.md +235 -20
  229. package/views/docs/guides/ports.md +1 -1
  230. package/views/docs/guides/selection.md +1 -1
  231. package/views/docs/guides/the-grid.md +14 -16
  232. package/views/docs/guides/the-provider.md +9 -15
  233. package/views/docs/reference/cells.md +1 -1
  234. package/views/docs/reference/controls.md +26 -13
  235. package/views/docs/reference/editors-chips.md +2 -2
  236. package/views/docs/reference/editors-date.md +4 -4
  237. package/views/docs/reference/editors-location.md +4 -7
  238. package/views/docs/reference/editors-name.md +3 -5
  239. package/views/docs/reference/editors-number.md +10 -10
  240. package/views/docs/reference/editors-panel.md +3 -3
  241. package/views/docs/reference/editors-range.md +3 -5
  242. package/views/docs/reference/editors-relation.md +4 -4
  243. package/views/docs/reference/editors-select.md +3 -3
  244. package/views/docs/reference/editors-text.md +3 -4
  245. package/views/docs/reference/editors-value-list.md +3 -3
  246. package/views/docs/reference/field-row.md +1 -1
  247. package/views/docs/reference/grid.md +2 -2
  248. package/views/docs/reference/panels-react.md +20 -34
  249. package/views/docs/reference/react.md +11 -18
  250. package/views/docs/reference/views.md +5 -5
  251. package/views/skills/views/SKILL.md +1 -1
  252. package/views/dist/editors/relation-panel.d.ts +0 -69
  253. package/views/dist/editors/relation-panel.js +0 -46
  254. package/views/dist/grid/chrome/GridColumnColorSection.d.ts +0 -13
  255. package/views/dist/grid/chrome/GridColumnColorSection.js +0 -40
  256. package/views/dist/grid/chrome/GridColumnDateSection.d.ts +0 -28
  257. package/views/dist/grid/chrome/GridColumnDateSection.js +0 -23
  258. package/views/dist/grid/chrome/GridColumnDurationSection.d.ts +0 -23
  259. package/views/dist/grid/chrome/GridColumnDurationSection.js +0 -24
  260. package/views/dist/grid/chrome/GridColumnNumberSection.d.ts +0 -29
  261. package/views/dist/grid/chrome/GridColumnNumberSection.js +0 -27
  262. package/views/dist/grid/chrome/GridColumnPercentSection.d.ts +0 -16
  263. package/views/dist/grid/chrome/GridColumnPercentSection.js +0 -16
  264. package/views/dist/grid/chrome/GridColumnSortSection.d.ts +0 -38
  265. package/views/dist/grid/chrome/GridColumnSortSection.js +0 -33
  266. package/views/dist/grid/chrome/GridFlyout.d.ts +0 -44
  267. package/views/dist/grid/chrome/GridFlyout.js +0 -80
  268. package/views/dist/grid/chrome/GridMenuRow.d.ts +0 -15
  269. package/views/dist/grid/chrome/GridMenuRow.js +0 -15
  270. package/views/dist/grid/chrome/grid-menu-search.d.ts +0 -7
  271. package/views/dist/grid/chrome/grid-menu-search.js +0 -7
  272. package/views/dist/panels/react/GroupBucketsList.d.ts +0 -16
  273. package/views/dist/panels/react/GroupBucketsList.js +0 -44
  274. package/views/dist/panels/react/LayoutColumnsList.d.ts +0 -24
  275. package/views/dist/panels/react/LayoutColumnsList.js +0 -101
  276. package/views/dist/panels/react/PopoverColumnDetail.d.ts +0 -11
  277. package/views/dist/panels/react/PopoverColumnDetail.js +0 -24
  278. package/views/dist/panels/react/drag.d.ts +0 -2
  279. package/views/dist/panels/react/drag.js +0 -5
  280. package/views/dist/panels/react/layout-detail.d.ts +0 -4
  281. package/views/dist/panels/react/layout-detail.js +0 -29
  282. package/views/dist/panels/react/root-list.d.ts +0 -6
  283. package/views/dist/panels/react/root-list.js +0 -31
  284. package/views/dist/panels/react/sort/use-sort-drag.d.ts +0 -17
  285. package/views/dist/panels/react/sort/use-sort-drag.js +0 -39
  286. package/views/dist/panels/react/view-footer.d.ts +0 -20
  287. package/views/dist/panels/react/view-footer.js +0 -41
@@ -1,21 +1,15 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from "react";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { COUNTRY_CODES, countryName, LOCATION_PARTS, placeFormat, sameStoredValue, } from "viewkitjs/fields";
5
5
  import { loadRegions, regionLabel } from "viewkitjs/fields/places";
6
6
  import { placeWordKey } from "../contract.js";
7
- import { ELEMENT_RESET } from "../internal/reset.js";
8
7
  import { useViews } from "../provider/context.js";
9
- import { EDITOR_INNER_ESCAPE } from "./inner-escape.js";
10
8
  import { BodyFrame } from "./BodyFrame.js";
11
9
  import { useBodyStep } from "./body-step.js";
12
10
  import { mergeParts, placeBodyValue, samePlacePart, takePlaceParts } from "./parts-body.js";
13
- import { PickerFrame, usePickerForm } from "./picker-slot.js";
14
- import { tabbable, tabEnds } from "./tab-ends.js";
11
+ import { usePickerForm } from "./picker-slot.js";
15
12
  const GENERIC = ["line1", "line2", "postalCode", "city", "region"];
16
- function folded(text) {
17
- return text.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase();
18
- }
19
13
  function draftOf(initial) {
20
14
  const draft = {};
21
15
  for (const part of LOCATION_PARTS) {
@@ -29,37 +23,28 @@ function withFilled(kept, draft) {
29
23
  const filled = GENERIC.filter((part) => !kept.has(part) && draft[part]?.trim());
30
24
  return filled.length === 0 ? kept : new Set([...kept, ...filled]);
31
25
  }
32
- export const LocationEditor = forwardRef(function LocationEditor({ field, initial, allowEmpty = false, conventions, chrome = "bare", label, clearable = false, onRequestClose }, ref) {
26
+ export const LocationEditor = forwardRef(function LocationEditor({ field, initial, allowEmpty = false, conventions, label, onRequestClose }, ref) {
33
27
  const views = useViews();
34
28
  const locale = (conventions ?? views.conventions).language;
35
29
  const say = (message) => views.messages(message);
36
- const { List, Row, RowContent } = views.atoms;
37
- const { Command, Input, Picker, PartsBody } = views.components;
30
+ const { PartsBody } = views.components;
38
31
  const onStepChange = useBodyStep();
39
32
  const form = usePickerForm();
40
- const boxRef = useRef(null);
41
- const clearRef = useRef(null);
42
33
  const parts = field.parts ?? LOCATION_PARTS;
43
34
  const takesCountry = parts.includes("countryCode");
44
35
  const [draft, setDraftState] = useState(() => draftOf(initial));
45
36
  const draftRef = useRef(draft);
46
37
  const [keptShown, setKeptShown] = useState(() => withFilled(new Set(), draft));
47
- const clearedRef = useRef(false);
48
38
  const setDraft = (next) => {
49
- clearedRef.current = false;
50
39
  draftRef.current = next;
51
40
  setDraftState(next);
52
41
  setKeptShown((kept) => withFilled(kept, next));
53
42
  };
54
43
  const country = draft.countryCode?.trim() || null;
55
- const [choosingCountry, setChoosingCountry] = useState(takesCountry && !country);
56
- const [countryQuery, setCountryQuery] = useState("");
57
- const [choosingRegion, setChoosingRegion] = useState(false);
58
- const [regionQuery, setRegionQuery] = useState("");
59
44
  const [regions, setRegions] = useState(null);
60
45
  const format = placeFormat(country, locale);
61
46
  const editsRegion = parts.includes("region");
62
- const wantsRegions = (PartsBody !== undefined || !choosingCountry) && editsRegion && format.hasRegions && country !== null;
47
+ const wantsRegions = editsRegion && format.hasRegions && country !== null;
63
48
  useEffect(() => {
64
49
  if (!wantsRegions || !country)
65
50
  return;
@@ -70,7 +55,6 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
70
55
  };
71
56
  }, [wantsRegions, country]);
72
57
  const regionList = regions && regions.country === country && regions.list.length > 0 ? regions.list : null;
73
- const lastFocused = useRef(null);
74
58
  const rows = useMemo(() => {
75
59
  const laidOut = new Set();
76
60
  const lines = format.lines
@@ -101,10 +85,6 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
101
85
  const resolveClose = (reason) => {
102
86
  if (reason === "escape")
103
87
  return { kind: "cancel" };
104
- if (clearedRef.current) {
105
- const held = parts.some((part) => typeof initial?.[part] === "string" && initial[part].trim() !== "");
106
- return held ? { kind: "commit", payload: null } : { kind: "noop" };
107
- }
108
88
  const current = draftRef.current;
109
89
  const next = {};
110
90
  for (const part of parts) {
@@ -120,83 +100,6 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
120
100
  return { kind: "commit", payload: place };
121
101
  };
122
102
  useImperativeHandle(ref, () => ({ resolveClose }));
123
- useEffect(() => {
124
- const box = boxRef.current;
125
- if (!box || box.contains(document.activeElement))
126
- return;
127
- const last = lastFocused.current
128
- ? box.querySelector(`[data-place-part="${lastFocused.current}"]`)
129
- : null;
130
- (last ?? box.querySelector("[data-place-focus]"))?.focus({ preventScroll: true });
131
- }, [choosingCountry, choosingRegion, regionList]);
132
- const focusSearch = useCallback((el) => el?.focus({ preventScroll: true }), []);
133
- const pickCountry = (code) => {
134
- const current = draftRef.current;
135
- const next = { ...current, countryCode: code };
136
- if (current.countryCode !== code) {
137
- if (parts.includes("region"))
138
- next.region = null;
139
- if (parts.includes("regionCode"))
140
- next.regionCode = null;
141
- }
142
- setDraft(next);
143
- setCountryQuery("");
144
- setChoosingCountry(false);
145
- };
146
- const pickRegion = (region) => {
147
- const next = { ...draftRef.current, region: regionLabel(region, country ?? "", locale) };
148
- if (parts.includes("regionCode"))
149
- next.regionCode = region.code;
150
- setDraft(next);
151
- setRegionQuery("");
152
- setChoosingRegion(false);
153
- };
154
- const type = (part, value) => {
155
- const next = { ...draftRef.current, [part]: value };
156
- if (part === "region" && parts.includes("regionCode"))
157
- next.regionCode = null;
158
- setDraft(next);
159
- };
160
- const clearControl = () => clearRef.current ? tabEnds(clearRef.current).first : undefined;
161
- const walk = (from, backwards) => {
162
- const clear = clearControl();
163
- const controls = [...(boxRef.current?.querySelectorAll("[data-place-control]") ?? [])];
164
- if (clear)
165
- controls.push(clear);
166
- let to = controls[controls.indexOf(from) + (backwards ? -1 : 1)];
167
- if (!to && backwards && clear && from === clear && boxRef.current) {
168
- to = tabbable(boxRef.current).filter((el) => !clearRef.current?.contains(el)).at(-1);
169
- }
170
- if (to)
171
- to.focus();
172
- else
173
- onRequestClose(backwards ? "shift-tab" : "tab");
174
- };
175
- const tabFromList = (reason) => {
176
- const clear = reason === "tab" ? clearControl() : undefined;
177
- if (clear)
178
- clear.focus();
179
- else
180
- onRequestClose(reason);
181
- };
182
- const keys = (e) => {
183
- e.stopPropagation();
184
- if (e.key === "Escape") {
185
- onRequestClose("escape");
186
- }
187
- else if (e.key === "Enter" && e.target instanceof HTMLInputElement) {
188
- e.preventDefault();
189
- onRequestClose("enter");
190
- }
191
- else if (e.key === "Tab") {
192
- e.preventDefault();
193
- walk(e.target, e.shiftKey);
194
- }
195
- };
196
- const blur = (e) => {
197
- if (!boxRef.current?.contains(e.relatedTarget))
198
- onRequestClose("blur");
199
- };
200
103
  const wordOf = (part) => {
201
104
  if (part === "line1")
202
105
  return say({ key: "views.editors.place-line1" });
@@ -208,113 +111,18 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
208
111
  return say({ key: placeWordKey("region", format.words.region) });
209
112
  return say({ key: placeWordKey("postal", format.words.postalCode) });
210
113
  };
211
- const labelOf = (part) => {
212
- const word = wordOf(part);
213
- return format.required.includes(part)
214
- ? say({ key: "views.editors.place-required", values: { label: word } })
215
- : word;
216
- };
217
- const required = (part, control) => format.required.includes(part)
218
- ? control === "input"
219
- ? { "aria-required": true, "data-required": "" }
220
- : { "data-required": "" }
221
- : {};
222
- const framed = chrome === "field";
223
- const input = framed
224
- ? "w-24 min-w-0 flex-1 select-text"
225
- : "h-7 w-24 min-w-0 flex-1 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden";
226
- const button = framed
227
- ? "h-9 w-24 min-w-0 flex-1 cursor-pointer truncate rounded-md border border-(color:--vk-border) bg-transparent px-3 text-left text-(length:--vk-text) text-(color:--vk-fg) outline-hidden"
228
- : `${input} cursor-pointer truncate text-left`;
229
- const line = (box) => (framed ? _jsx("span", { className: "flex min-w-0 items-center gap-1.5", children: box }) : box);
230
- const search = (value, onChange, placeholder) => (_jsx(Command.Input, { ref: focusSearch, value: value, onValueChange: onChange, placeholder: placeholder, className: "h-9 text-(length:--vk-input-text,13px)", onKeyDown: (e) => {
231
- if (e.key === "Escape") {
232
- e.stopPropagation();
233
- if (choosingRegion)
234
- setChoosingRegion(false);
235
- else if (country)
236
- setChoosingCountry(false);
237
- else
238
- onRequestClose("escape");
239
- }
240
- else if (e.key === "Tab") {
241
- e.preventDefault();
242
- e.stopPropagation();
243
- tabFromList(e.shiftKey ? "shift-tab" : "tab");
244
- }
245
- } }));
246
- const list = (children) => (_jsxs(Command.List, { className: "max-h-64 overscroll-contain scrollbar-overlay", children: [children.length === 0 && (_jsx(Command.Empty, { className: "py-4 text-center text-xs text-(color:--vk-fg-subtle)", children: (conventions ?? views.conventions).messages({ key: "editor.nothing-matches" }) })), _jsx(Command.Group, { className: "p-0", children: _jsx(List, { children: children }) })] }));
247
- const listKeys = (e) => {
248
- if (e.key !== "Escape")
249
- return;
250
- e.stopPropagation();
251
- if (choosingRegion)
252
- setChoosingRegion(false);
253
- else if (country)
254
- setChoosingCountry(false);
255
- else
256
- onRequestClose("escape");
257
- };
258
- let body;
259
- if (choosingCountry && Picker) {
260
- body = (_jsx(PickerFrame, { onTab: tabFromList, onKey: listKeys, children: _jsx(Picker, { label: say({ key: "views.editors.place-country" }), items: countries.map(({ code, name }) => ({ value: code, label: name })), value: country, onValueChange: (code) => {
261
- if (typeof code === "string")
262
- pickCountry(code);
263
- }, onDone: () => { }, search: say({ key: "views.editors.place-country-search" }), autoFocus: true, form: form }) }));
264
- }
265
- else if (choosingRegion && regionList && Picker) {
266
- const keyed = regionList.map((region) => ({
267
- region,
268
- key: region.code ?? region.name,
269
- label: regionLabel(region, country ?? "", locale),
270
- }));
271
- body = (_jsx(PickerFrame, { onTab: tabFromList, onKey: listKeys, children: _jsx(Picker, { label: wordOf("region"), items: keyed.map(({ key, label }) => ({ value: key, label })), value: keyed.find(({ label }) => label === draft.region)?.key ?? null, onValueChange: (key) => {
272
- const found = keyed.find((each) => each.key === key);
273
- if (found)
274
- pickRegion(found.region);
275
- }, onDone: () => { }, search: say({ key: "views.editors.place-region-search" }), autoFocus: true, form: form }) }));
276
- }
277
- else if (choosingCountry) {
278
- const needle = folded(countryQuery.trim());
279
- const shown = countries.filter(({ code, name }) => needle === "" || folded(name).includes(needle) || code.toLowerCase() === needle);
280
- body = (_jsxs(Command.Root, { shouldFilter: false, loop: true, label: say({ key: "views.editors.place-country" }), children: [search(countryQuery, setCountryQuery, say({ key: "views.editors.place-country-search" })), list(shown.map(({ code, name }) => (_jsx(Command.Item, { value: code, onSelect: () => pickCountry(code), chosen: code === country, children: _jsx(RowContent, { size: "compact", label: name, chosen: code === country, chosenTint: false }) }, code))))] }));
281
- }
282
- else if (choosingRegion && regionList) {
283
- const needle = folded(regionQuery.trim());
284
- const labelled = regionList.map((region) => ({
285
- region,
286
- label: regionLabel(region, country ?? "", locale),
114
+ const boxes = GENERIC.filter((part) => parts.includes(part));
115
+ const labelOf = (region) => regionLabel(region, country ?? "", locale);
116
+ const take = (next) => {
117
+ const draftCountry = draftRef.current.countryCode?.trim() || "";
118
+ const list = regions && regions.country === draftCountry && regions.list.length > 0 ? regions.list : null;
119
+ const merged = mergeParts(draftRef.current, shownRef.current, next, samePlacePart);
120
+ setDraft(takePlaceParts(draftRef.current, merged, {
121
+ parts,
122
+ regions: list,
123
+ labelOf: (region) => regionLabel(region, draftCountry, locale),
287
124
  }));
288
- const shown = labelled.filter(({ label }) => needle === "" || folded(label).includes(needle));
289
- body = (_jsxs(Command.Root, { shouldFilter: false, loop: true, label: wordOf("region"), children: [search(regionQuery, setRegionQuery, say({ key: "views.editors.place-region-search" })), list(shown.map(({ region, label }) => (_jsx(Command.Item, { value: region.code ?? region.name, onSelect: () => pickRegion(region), chosen: label === draft.region, children: _jsx(RowContent, { size: "compact", label: label, chosen: label === draft.region, chosenTint: false }) }, region.code ?? region.name))))] }));
290
- }
291
- else {
292
- const focusPart = rows[0]?.[0];
293
- const focus = (part) => (part === focusPart ? { "data-place-focus": "" } : {});
294
- body = (_jsxs(_Fragment, { children: [takesCountry && country && line(_jsx("button", { type: "button", "data-place-control": "", "aria-label": `${say({ key: "views.editors.place-change-country" })}: ${countryName(country, locale)}`, onClick: () => setChoosingCountry(true), onKeyDown: keys, className: `${ELEMENT_RESET} ${button} font-medium`, children: countryName(country, locale) })), rows.map((row) => (_jsx("span", { className: "flex min-w-0 items-center gap-1.5", children: row.map((part) => part === "region" && regionList ? (_jsx("button", { type: "button", "data-place-control": "", ...focus(part), ...required(part, "button"), "data-place-part": part, "aria-label": draft.region ? `${labelOf(part)}: ${draft.region}` : labelOf(part), onFocus: () => (lastFocused.current = part), onClick: () => setChoosingRegion(true), onKeyDown: keys, className: `${ELEMENT_RESET} ${button} ${draft.region ? "" : "text-(color:--vk-fg-subtle)"}`, children: draft.region || labelOf(part) }, part)) : (_jsx(Input, { "data-place-control": "", ...focus(part), ...required(part, "input"), "data-place-part": part, onFocus: () => (lastFocused.current = part), value: draft[part] ?? "", "aria-label": labelOf(part), placeholder: labelOf(part), onChange: (e) => type(part, e.target.value), onKeyDown: keys, onClick: (e) => e.stopPropagation(), chrome: chrome, className: input }, part))) }, row.join(" "))))] }));
295
- }
296
- const inner = (choosingRegion && regionList !== null) || (choosingCountry && country !== null);
297
- if (PartsBody) {
298
- const boxes = GENERIC.filter((part) => parts.includes(part));
299
- const labelOf = (region) => regionLabel(region, country ?? "", locale);
300
- const take = (next) => {
301
- const draftCountry = draftRef.current.countryCode?.trim() || "";
302
- const list = regions && regions.country === draftCountry && regions.list.length > 0 ? regions.list : null;
303
- const merged = mergeParts(draftRef.current, shownRef.current, next, samePlacePart);
304
- setDraft(takePlaceParts(draftRef.current, merged, {
305
- parts,
306
- regions: list,
307
- labelOf: (region) => regionLabel(region, draftCountry, locale),
308
- }));
309
- };
310
- const words = Object.fromEntries(GENERIC.map((part) => [part, wordOf(part)]));
311
- return (_jsx(BodyFrame, { slot: "vk-parts-body", onRequestClose: onRequestClose, children: _jsx(PartsBody, { kind: "place", value: bodyValue, onValueChange: take, parts: boxes, rows: rows, words: words, required: format.required.filter((part) => boxes.includes(part)), ...(takesCountry ? { countries } : {}), ...(regionList ? { regions: regionList.map((region) => ({ code: region.code, name: labelOf(region) })) } : {}), ...(opensOnCountries ? { opens: "countries" } : {}), label: label ?? field.label, onDone: (how) => onRequestClose(how === "pick" ? "pick" : "enter"), empty: allowEmpty, autoFocus: true, form: form, ...(onStepChange && { onStepChange }) }) }));
312
- }
313
- return (_jsxs("div", { ref: boxRef, ...(inner ? { [EDITOR_INNER_ESCAPE]: "" } : {}), onBlur: blur, onMouseDown: (e) => {
314
- if (!(e.target instanceof HTMLInputElement))
315
- e.preventDefault();
316
- }, className: "flex w-full min-w-0 flex-col gap-1.5", children: [body, clearable && !inner && (_jsx("div", { ref: clearRef, onKeyDown: keys, className: "border-t border-(color:--vk-border) pt-1", children: _jsx(List, { children: _jsx(Row, { size: "compact", tone: "muted", label: (conventions ?? views.conventions).messages({ key: "date.clear" }), onClick: () => {
317
- clearedRef.current = true;
318
- onRequestClose("pick");
319
- } }) }) }))] }));
125
+ };
126
+ const words = Object.fromEntries(GENERIC.map((part) => [part, wordOf(part)]));
127
+ return (_jsx(BodyFrame, { slot: "vk-parts-body", onRequestClose: onRequestClose, children: _jsx(PartsBody, { kind: "place", value: bodyValue, onValueChange: take, parts: boxes, rows: rows, words: words, required: format.required.filter((part) => boxes.includes(part)), ...(takesCountry ? { countries } : {}), ...(regionList ? { regions: regionList.map((region) => ({ code: region.code, name: labelOf(region) })) } : {}), ...(opensOnCountries ? { opens: "countries" } : {}), label: label ?? field.label, onDone: (how) => onRequestClose(how === "pick" ? "pick" : "enter"), empty: allowEmpty, autoFocus: true, form: form, ...(onStepChange && { onStepChange }) }) }));
320
128
  });
@@ -1,29 +1,21 @@
1
- import { type CloseReason, type CloseResolution, type FieldConventions, type NameValue } from "viewkitjs/fields";
1
+ import type { CloseReason, CloseResolution, FieldConventions, NameValue } from "viewkitjs/fields";
2
2
  /**
3
- * A NAME — three text boxes, given, family and full. Once a part is edited, the
4
- * full box follows the parts ("given family") while nobody has typed in it, and
5
- * stops once a person does: the library never builds a full name behind them,
6
- * and an editor opened and closed untouched writes nothing, so Nagy Imre stays
7
- * written family first. A full name already stored that the parts would not
8
- * give is the person's own, and is left as it is. Tab walks the three boxes; a
9
- * blur that lands on another box is not a close. Three empty boxes are a
10
- * clear, committed only when the host allows one.
3
+ * A NAME — given, family and full, drawn by the app's `PartsBody` (`CONTROLS.PartsBody` is ViewKit's own). Once a
4
+ * part is edited, the full name follows the parts ("given family") while nobody has typed in it, and stops once a
5
+ * person does: the library never builds a full name behind them, and an editor opened and closed untouched writes
6
+ * nothing, so Nagy Imre stays written family first. A full name already stored that the parts would not give is the
7
+ * person's own, and is left as it is. An empty name is a clear, committed only when the host allows one.
11
8
  */
12
9
  export type NameEditorHandle = {
13
10
  resolveClose: (reason: CloseReason) => CloseResolution<NameValue | null>;
14
11
  };
15
12
  export declare const NameEditor: import("react").ForwardRefExoticComponent<{
16
13
  initial: NameValue | null;
17
- /** Type-to-replace: the character that opened the editor replaces the given box. */
14
+ /** Type-to-replace: the character that opened the editor replaces the given name. */
18
15
  seed?: string;
19
16
  allowEmpty?: boolean;
20
17
  conventions?: FieldConventions;
21
- /** How the boxes are drawn: `bare` in a cell or a popover, `field` where they stand on their own (a phone's
22
- * sheet), each in the app's field frame. Default `bare`. */
23
- chrome?: "bare" | "field";
24
- /** A frame drawn round each box, where nothing round the editor frames them (a field row's, in place). */
25
- boxClassName?: string;
26
- /** The field's name, for an app's `PartsBody`. Default: the full name's words. */
18
+ /** The field's name, for the app's `PartsBody`. Default: the full name's words. */
27
19
  label?: string;
28
20
  onRequestClose: (reason: CloseReason) => void;
29
21
  } & import("react").RefAttributes<NameEditorHandle>>;
@@ -1,39 +1,15 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, } from "react";
4
- import { isEmptyName, sameName, tidyName, } from "viewkitjs/fields";
5
- import { cx } from "../internal/cx.js";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
6
4
  import { useViews } from "../provider/context.js";
7
5
  import { BodyFrame } from "./BodyFrame.js";
8
6
  import { useBodyStep } from "./body-step.js";
9
- import { fromParts, mergeParts, nameBodyStart, nameBodyValue, resolveNameBody, takeNameParts, } from "./parts-body.js";
7
+ import { mergeParts, nameBodyStart, nameBodyValue, resolveNameBody, takeNameParts, } from "./parts-body.js";
10
8
  import { usePickerForm } from "./picker-slot.js";
11
- const ORDER = ["given", "family", "full"];
12
- const LABELS = {
13
- given: "views.editors.name-given",
14
- family: "views.editors.name-family",
15
- full: "views.editors.name-full",
16
- };
17
- export const NameEditor = forwardRef(function NameEditor({ initial, seed, allowEmpty = false, chrome = "bare", boxClassName, label, onRequestClose }, ref) {
9
+ export const NameEditor = forwardRef(function NameEditor({ initial, seed, allowEmpty = false, label, onRequestClose }, ref) {
18
10
  const views = useViews();
19
- const { Input, PartsBody } = views.components;
11
+ const { PartsBody } = views.components;
20
12
  const onStepChange = useBodyStep();
21
- const boxRef = useRef(null);
22
- const givenRef = useRef(null);
23
- const refs = {
24
- given: givenRef,
25
- family: useRef(null),
26
- full: useRef(null),
27
- };
28
- const [given, setGiven] = useState(seed ?? initial?.given ?? "");
29
- const [family, setFamily] = useState(initial?.family ?? "");
30
- const [ownFull, setOwnFull] = useState(() => {
31
- const stored = initial?.full?.trim() ?? "";
32
- return stored !== "" && stored !== fromParts(initial?.given ?? "", initial?.family ?? "");
33
- });
34
- const [typedFull, setTypedFull] = useState(initial?.full ?? "");
35
- const [partsEdited, setPartsEdited] = useState(seed !== undefined);
36
- const full = ownFull || !partsEdited ? typedFull : fromParts(given, family);
37
13
  const form = usePickerForm();
38
14
  const [bodyDraft, setBodyDraft] = useState(() => nameBodyStart(initial, seed));
39
15
  const bodyRef = useRef(bodyDraft);
@@ -42,78 +18,13 @@ export const NameEditor = forwardRef(function NameEditor({ initial, seed, allowE
42
18
  useLayoutEffect(() => {
43
19
  shownRef.current = bodyValue;
44
20
  });
45
- useEffect(() => {
46
- const el = givenRef.current;
47
- if (!el)
48
- return;
49
- el.focus({ preventScroll: true });
50
- el.setSelectionRange(el.value.length, el.value.length);
51
- }, []);
52
- const resolveClose = (reason) => {
53
- if (reason === "escape")
54
- return { kind: "cancel" };
55
- const next = tidyName({ full, given, family });
56
- if (sameName(next, initial))
57
- return { kind: "noop" };
58
- if (isEmptyName(next))
59
- return allowEmpty ? { kind: "commit", payload: null } : { kind: "cancel" };
60
- return { kind: "commit", payload: next };
61
- };
62
21
  useImperativeHandle(ref, () => ({
63
- resolveClose: PartsBody
64
- ? (reason) => resolveNameBody(reason, bodyRef.current, initial, allowEmpty)
65
- : resolveClose,
22
+ resolveClose: (reason) => resolveNameBody(reason, bodyRef.current, initial, allowEmpty),
66
23
  }));
67
- const keys = (which) => (e) => {
68
- e.stopPropagation();
69
- if (e.key === "Enter") {
70
- e.preventDefault();
71
- onRequestClose("enter");
72
- }
73
- else if (e.key === "Escape") {
74
- onRequestClose("escape");
75
- }
76
- else if (e.key === "Tab") {
77
- e.preventDefault();
78
- const at = ORDER.indexOf(which) + (e.shiftKey ? -1 : 1);
79
- const to = ORDER[at];
80
- if (to)
81
- refs[to].current?.focus();
82
- else
83
- onRequestClose(e.shiftKey ? "shift-tab" : "tab");
84
- }
24
+ const take = (next) => {
25
+ const merged = mergeParts(nameBodyValue(bodyRef.current), shownRef.current, next);
26
+ bodyRef.current = takeNameParts(bodyRef.current, merged);
27
+ setBodyDraft(bodyRef.current);
85
28
  };
86
- const blur = (e) => {
87
- if (!boxRef.current?.contains(e.relatedTarget))
88
- onRequestClose("blur");
89
- };
90
- const input = cx(chrome === "field"
91
- ? "w-28 min-w-0 flex-1 select-text"
92
- : "h-full w-28 min-w-0 flex-1 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", boxClassName);
93
- const box = (which, value, onChange) => {
94
- const label = views.messages({ key: LABELS[which] });
95
- return (_jsx(Input, { ref: refs[which], value: value, "aria-label": label, placeholder: label, onChange: (e) => onChange(e.target.value), onKeyDown: keys(which), onBlur: blur, onClick: (e) => e.stopPropagation(), chrome: chrome, className: input }));
96
- };
97
- const fullBox = box("full", full, (next) => {
98
- setOwnFull(true);
99
- setTypedFull(next);
100
- });
101
- if (PartsBody) {
102
- const take = (next) => {
103
- const merged = mergeParts(nameBodyValue(bodyRef.current), shownRef.current, next);
104
- bodyRef.current = takeNameParts(bodyRef.current, merged);
105
- setBodyDraft(bodyRef.current);
106
- };
107
- return (_jsx(BodyFrame, { slot: "vk-parts-body", onRequestClose: onRequestClose, children: _jsx(PartsBody, { kind: "name", value: bodyValue, onValueChange: take, label: label ?? views.messages({ key: "views.editors.name-full" }), onDone: (how) => onRequestClose(how === "pick" ? "pick" : "enter"), empty: allowEmpty, typed: seed, autoFocus: true, form: form, ...(onStepChange && { onStepChange }) }) }));
108
- }
109
- return (_jsxs("span", { ref: boxRef, onMouseDown: (e) => {
110
- if (!(e.target instanceof HTMLInputElement))
111
- e.preventDefault();
112
- }, className: "flex h-full w-full min-w-0 flex-col gap-1.5", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-1.5", children: [box("given", given, (next) => {
113
- setPartsEdited(true);
114
- setGiven(next);
115
- }), box("family", family, (next) => {
116
- setPartsEdited(true);
117
- setFamily(next);
118
- })] }), chrome === "field" ? (_jsx("span", { className: "flex min-w-0 items-center gap-1.5", children: fullBox })) : (fullBox)] }));
29
+ return (_jsx(BodyFrame, { slot: "vk-parts-body", onRequestClose: onRequestClose, children: _jsx(PartsBody, { kind: "name", value: bodyValue, onValueChange: take, label: label ?? views.messages({ key: "views.editors.name-full" }), onDone: (how) => onRequestClose(how === "pick" ? "pick" : "enter"), empty: allowEmpty, typed: seed, autoFocus: true, form: form, ...(onStepChange && { onStepChange }) }) }));
119
30
  });
@@ -1,20 +1,16 @@
1
1
  import { type CloseReason, type CloseResolution, type FieldConventions, type NumberCommit } from "viewkitjs/fields";
2
2
  import { type DurationUnit } from "viewkitjs/fields/query";
3
3
  /**
4
- * THE number-editing core — a typed field, and the unit it is denominated in.
4
+ * THE number-editing core — a number, money or a percent, and the unit it is denominated in. It draws the app's
5
+ * `NumberBody` (required) and keeps the draft, the rounding to the field's decimals and the close.
5
6
  *
6
7
  * INLINE, not anchored: it replaces the cell's own content rather than opening
7
8
  * a panel over it, which is why its close reasons are the keyboard's and the
8
9
  * blur's — enter · tab · shift-tab · escape · blur — and never `outside`.
9
10
  *
10
- * The unit chip is the exception it carries: a money value is a number AND its
11
- * currency, so the chip picks one, and its own popover must never blur the
12
- * input into a commit. That is why the blur decision lives here, in the core,
13
- * rather than with the host — only this component knows the picker is open.
14
- *
15
- * A DURATION is the other denomination it speaks (spec §8.4): the field is
11
+ * A DURATION is the one denomination no body has a form for (spec §8.4): the field is
16
12
  * edited as a person writes one — `2m 30s`, `90s`, a bare number of seconds —
17
- * and committed in the unit the field is STORED in. The host names that unit
13
+ * in the editor's own box, and committed in the unit the field is STORED in. The host names that unit
18
14
  * (`durationUnit`) and reads back a number in it; the conversion is the core's.
19
15
  */
20
16
  /** What a number commits: the value, and the unit it is in. The host maps that
@@ -25,19 +21,19 @@ export type NumberEditorHandle = {
25
21
  /** What this close means. Synchronous, idempotent, no timer. */
26
22
  resolveClose: (reason: CloseReason) => CloseResolution<NumberEditValue>;
27
23
  };
28
- export declare const NumberEditor: import("react").ForwardRefExoticComponent<{
24
+ export declare const NumberEditorHost: import("react").ForwardRefExoticComponent<{
29
25
  /** Signed raw value (e.g. -47.50 for an "out" transaction in its own currency). */
30
26
  initial: number;
31
27
  /** Type-to-replace: the character that opened this editor. Replaces the
32
28
  * field's text only — `initial` stays the numeric baseline the dirty-check
33
29
  * compares against, so seeding the same value still no-ops. */
34
30
  seed?: string;
35
- /** The row's current unit (currency). Undefined = plain number, no chip. */
31
+ /** The row's current unit (currency). Undefined = plain number. */
36
32
  unit?: string;
37
- /** Selectable units — presence makes the chip a picker. */
33
+ /** Selectable units: handed to the `NumberBody` as `units`. */
38
34
  unitOptions?: string[];
39
- /** The currency's code where the field fixes one (`numberEditCode`): drawn beside the amount
40
- * as a unit is, and never part of the commit. Ignored when `unit` is given. */
35
+ /** The currency's code where the field fixes one (`numberEditCode`): handed to the `NumberBody` as its unit, and
36
+ * never part of the commit. Ignored when `unit` is given. */
41
37
  code?: string;
42
38
  /** Rounding + initial formatting precision — in the STORED unit. An
43
39
  * integer field passes 0 (spec §8.2). */
@@ -51,9 +47,6 @@ export declare const NumberEditor: import("react").ForwardRefExoticComponent<{
51
47
  durationUnit?: DurationUnit;
52
48
  /** A blank input is a real null commit. Without this it remains a cancel. */
53
49
  allowEmpty?: boolean;
54
- /** Right-aligned columns put the chip on the LEFT so the number stays flush
55
- * with the column's right edge. */
56
- unitLeft?: boolean;
57
50
  /**
58
51
  * Which edge the figure sits against. `end` is the grid's — a spreadsheet
59
52
  * column is right-aligned, and the input has to open where the cell's
@@ -69,12 +62,12 @@ export declare const NumberEditor: import("react").ForwardRefExoticComponent<{
69
62
  type?: "number" | "percent" | "currency";
70
63
  /** The field's name: a `NumberBody`'s label. */
71
64
  label?: string;
72
- /** The field's lowest value: the editor's own box steps no lower, and a `NumberBody` is handed it. */
65
+ /** The field's lowest value: the `NumberBody` is handed it. */
73
66
  min?: number;
74
- /** The field's highest value: the editor's own box steps no higher, and a `NumberBody` is handed it. */
67
+ /** The field's highest value: the `NumberBody` is handed it. */
75
68
  max?: number;
76
- /** The host's reading of a value: its reason, or null. Handed to a `NumberBody`, asked with the value rounded to
77
- * `decimals`; unused by the editor's own box. Default: every value reads. */
69
+ /** The host's reading of a value: its reason, or null. Handed to the `NumberBody`, asked with the value rounded to
70
+ * `decimals`; unused by a duration's box. Default: every value reads. */
78
71
  check?: (value: number | null, unit?: string) => string | null;
79
72
  /** The session keeps on Escape: a `NumberBody`'s frame carries `EDITOR_INNER_ESCAPE`. Default false. */
80
73
  escapeKeeps?: boolean;
@@ -83,7 +76,7 @@ export declare const NumberEditor: import("react").ForwardRefExoticComponent<{
83
76
  closeOnBlur?: boolean;
84
77
  /** Where a `NumberBody` stands: `phone` in a sheet. Default `computer`. */
85
78
  form?: "computer" | "phone";
86
- /** A frame drawn round ViewKit's own box, where nothing round the editor frames it (a field row's, in place). */
79
+ /** A frame drawn round a duration's box, where nothing round the editor frames it (a field row's, in place). */
87
80
  boxClassName?: string;
88
81
  /** The core saw a key (or a blur) that means "done". */
89
82
  onRequestClose: (reason: CloseReason) => void;