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,441 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Button } from "../button/button.js";
5
+ import { Picker, usePicker } from "../picker/picker.js";
6
+ import { Popover } from "../popover/popover.js";
7
+ import { SheetButton } from "../sheet/bottom-sheet.js";
8
+ import { Flag } from "../flag/flag.js";
9
+ import { phoneMark, usePhoneForm } from "../internal/phone.js";
10
+ import { midWord, TEXT_KEYS, kept, textRefusal } from "../text-editor/check.js";
11
+ import { DIALS, countryName, dialOf, firstCountry, patternOf, phoneHanded, phoneOf } from "../text-editor/phone-number.js";
12
+ import { VALUES_EDITOR_ATTRS, valuesEditorWornOf } from "./looks.js";
13
+ import { added, handedList, labelFor, labelsOf, listOf, openOf, charsThatFit, splitEmail } from "./values.js";
14
+ import { valuesWords } from "./words.js";
15
+ import { FieldRowsRow as FieldRow, FieldRows } from "../field/field.js";
16
+ import { Input, InputGroupAddon, InputGroupButton } from "../input/input.js";
17
+ import { InlineInputGroup } from "../inline-input/inline-input.js";
18
+ import { cx } from "../../internal/cx.js";
19
+ import { moved, useReorder } from "../internal/reorder.js";
20
+ import { useShellHand } from "../internal/shell-hand.js";
21
+ import { spacingPx } from "../internal/read-token.js";
22
+ import { openerAt, useStepReturn } from "../internal/step-return.js";
23
+ import { EDITOR_INNER_ESCAPE } from "../../editors/inner-escape.js";
24
+ const ROW_28 = { "--inline-input-row": "calc(var(--vk-spacing) * 7)" };
25
+ const ROW_40 = { "--inline-input-row": "calc(var(--vk-spacing) * 10)" };
26
+ const glyph = (paths, className) => (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: paths.map((d) => _jsx("path", { d: d }, d)) }));
27
+ const dots = (x, y) => `M${x} ${y}m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`;
28
+ const GRIP = [dots(9, 5), dots(9, 12), dots(9, 19), dots(15, 5), dots(15, 12), dots(15, 19)], LINES = ["M4 6h16", "M4 12h16", "M4 18h16"];
29
+ const X = ["M18 6l-12 12", "M6 6l12 12"], TICK = ["M5 12l5 5l10 -10"], DOWN = ["M6 9l6 6l6 -6"], LEFT = ["M15 6l-6 6l6 6"];
30
+ const TRASH = ["M4 7l16 0", "M10 11l0 6", "M14 11l0 6", "M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12", "M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"];
31
+ const COPY = ["M7 9.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z", "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1"];
32
+ const PLUS = ["M12 5l0 14", "M5 12l14 0"];
33
+ const CALL = ["M5 4h4l2 5l-2.5 1.5a11 11 0 0 0 5 5l1.5 -2.5l5 2v4a2 2 0 0 1 -2 2a16 16 0 0 1 -15 -15a2 2 0 0 1 2 -2"];
34
+ const OPEN = ["M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6", "M11 13l9 -9", "M15 4h5v5"];
35
+ const ATTIO_ROWS = { cards: "one", edge: "off", height: "48", label: "104", lines: "across" };
36
+ const MIHAI_CARDS = { cards: "each", edge: "on", height: "56", label: "104", lines: "none" };
37
+ const MAIL = ["M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10z", "M3 7l9 6l9 -6"];
38
+ const WORLD = ["M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0", "M3.6 9h16.8", "M3.6 15h16.8", "M11.5 3a17 17 0 0 0 0 18", "M12.5 3a17 17 0 0 1 0 18"];
39
+ const LINK = ["M9 15l6 -6", "M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464", "M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463"];
40
+ const ICON = { email: MAIL, phone: LINES, link: LINK, domain: WORLD };
41
+ let ids = 0;
42
+ const rowsOf = (list) => listOf(list).map((v) => ({ id: ++ids, value: v.value, label: v.label }));
43
+ const same = (a, b) => JSON.stringify(listOf(a)) === JSON.stringify(listOf(b));
44
+ function firstOf(props) {
45
+ const held = rowsOf(props.value), m = props.moving != null && held[props.moving] ? props.moving : null;
46
+ const rows = m == null ? held : moved(held, m, 0);
47
+ const posed = m == null ? null : { id: held[m].id, mainId: held[0].id };
48
+ if (props.draft === "shell") {
49
+ const editing = props.typed != null && rows.length ? 0 : props.editing ?? null;
50
+ return { rows, posed, typed: "", tried: false, editing, editText: editing != null ? rows[editing]?.value ?? "" : "" };
51
+ }
52
+ return { rows, posed, typed: props.typed ?? "", tried: props.typed != null, editing: props.editing ?? null,
53
+ editText: props.editing != null ? rows[props.editing]?.value ?? "" : "" };
54
+ }
55
+ const ROOT = ":root-of-body";
56
+ export function useValuesEditorWorn(el) {
57
+ const [worn, setWorn] = React.useState(() => valuesEditorWornOf(null));
58
+ React.useLayoutEffect(() => {
59
+ if (!el)
60
+ return;
61
+ const read = () => setWorn((now) => { const next = valuesEditorWornOf(el); return Object.keys(next).every((k) => now[k] === next[k]) ? now : next; });
62
+ read();
63
+ const watch = new MutationObserver(read);
64
+ watch.observe(document.documentElement, { attributes: true, subtree: true, attributeFilter: VALUES_EDITOR_ATTRS });
65
+ return () => watch.disconnect();
66
+ }, [el]);
67
+ return worn;
68
+ }
69
+ const countries = new Map();
70
+ const countryItems = (language) => {
71
+ if (!countries.has(language))
72
+ countries.set(language, DIALS.map((d) => ({ value: d.country, label: `${countryName(d.country, language)} ${d.code}` })).sort((a, b) => a.label.localeCompare(b.label, language)));
73
+ return countries.get(language);
74
+ };
75
+ export function useValuesEditor(props) {
76
+ const { label, kind, value, onValueChange, onDone, dialCodes = [], autoFocus = true } = props;
77
+ const one = props.holds === "one", shell = props.draft === "shell";
78
+ const w = valuesWords(props.words), language = props.language ?? "en";
79
+ const labels = one ? [] : props.labels ?? (kind === "domain" ? [] : labelsOf(w.labels));
80
+ const phone = usePhoneForm(props.form), device = phoneMark(usePhoneForm());
81
+ const rule = React.useCallback((v) => (props.check ?? ((x) => textRefusal(kind, x)))(v), [props.check, kind]);
82
+ const [first] = React.useState(() => firstOf(props));
83
+ const [rows, setRows] = React.useState(first.rows), [posed, setPosed] = React.useState(first.posed);
84
+ const [typed, setTyped] = React.useState(first.typed), [tried, setTried] = React.useState(first.tried);
85
+ const [editing, setEditing] = React.useState(first.editing), [editText, setEditText] = React.useState(first.editText);
86
+ const [view, setView] = React.useState("rows"), [labelOf, setLabelOf] = React.useState(null);
87
+ const [checked, setChecked] = React.useState(false);
88
+ const [country, setCountry] = React.useState(props.dial ?? dialCodes[0]?.country);
89
+ const [rootEl, setRootEl] = React.useState(null);
90
+ const worn = useValuesEditorWorn(rootEl), attio = worn.line === "plus";
91
+ const edit = phone && worn.phone === "cards" ? null : editing;
92
+ const reading = country && dialOf(country) ? country : firstCountry();
93
+ const keepAs = (t) => kept(kind, t);
94
+ const lineRead = () => {
95
+ if (!(kind === "phone" && attio))
96
+ return added(kind, typed, rule, dial, keepAs);
97
+ if (!typed.trim())
98
+ return { error: "" };
99
+ const r = phoneOf(reading, typed);
100
+ if (!("value" in r))
101
+ return { ...r, typed: phoneHanded(reading, typed) };
102
+ if (!r.value)
103
+ return { error: "" };
104
+ const refused = props.check?.(r.value);
105
+ return refused ? { error: refused, typed: r.value } : r;
106
+ };
107
+ const dial = dialCodes.find((d) => d.country === country) ?? (country ? { country, code: "" } : undefined);
108
+ const settled = React.useRef(false), swapping = React.useRef(false), root = React.useRef(null);
109
+ const keys = TEXT_KEYS[kind];
110
+ const refusal = tried ? (() => { const r = lineRead(); return "error" in r && r.error ? r.error : null; })() : null;
111
+ const finishEdit = () => {
112
+ if (edit == null)
113
+ return true;
114
+ const v = editText.trim() ? keepAs(editText) : "";
115
+ if (v && rule(v))
116
+ return false;
117
+ setRows((rs) => (v ? rs.map((r, i) => (i === edit ? { ...r, value: v } : r)) : rs.filter((_, i) => i !== edit)));
118
+ setEditing(null);
119
+ return true;
120
+ };
121
+ const listNow = (line) => handedList(rows, edit == null ? null : { at: edit, text: editText }, line ? lineRead() : null, { check: rule, keep: keepAs, label: labels.length ? labelFor(kind, w.labels) : undefined, refused: shell });
122
+ const sameList = (a, b) => JSON.stringify(listOf(a).map((v) => [v.value, v.label ?? ""])) === JSON.stringify(listOf(b).map((v) => [v.value, v.label ?? ""]));
123
+ useShellHand(shell, shell ? listNow(true) : value, value, sameList, onValueChange, (v) => {
124
+ setRows(rowsOf(v));
125
+ setPosed(null);
126
+ setTyped("");
127
+ setTried(false);
128
+ setEditing(null);
129
+ setEditText("");
130
+ setView("rows");
131
+ setChecked(false);
132
+ setDrop(null);
133
+ });
134
+ const keep = (line = false) => {
135
+ settled.current = true;
136
+ if (shell) {
137
+ onDone?.();
138
+ return;
139
+ }
140
+ const next = listNow(line);
141
+ if (!same(next, value))
142
+ onValueChange(next);
143
+ onDone?.();
144
+ };
145
+ const asked = React.useRef(props);
146
+ asked.current = props;
147
+ const reset = () => {
148
+ const f = firstOf(asked.current);
149
+ setRows(f.rows);
150
+ setPosed(f.posed);
151
+ setTyped(f.typed);
152
+ setTried(f.tried);
153
+ setEditing(f.editing);
154
+ setEditText(f.editText);
155
+ setView("rows");
156
+ setChecked(false);
157
+ };
158
+ const leave = () => { settled.current = true; reset(); onDone?.(); };
159
+ React.useLayoutEffect(() => {
160
+ if (!rootEl)
161
+ return;
162
+ let frame = 0;
163
+ const cut = () => {
164
+ if (typeof Range === "undefined" || typeof Range.prototype.getBoundingClientRect !== "function")
165
+ return;
166
+ for (const name of rootEl.querySelectorAll(".o-values-editor-name[data-name]")) {
167
+ const text = name.firstChild, full = name.dataset.name;
168
+ if (!(text instanceof Text))
169
+ continue;
170
+ name.style.textOverflow = "clip";
171
+ if (text.nodeValue !== full)
172
+ text.nodeValue = full;
173
+ const room = name.getBoundingClientRect().width, range = document.createRange(), widths = [];
174
+ for (let i = 1; i <= full.length; i++) {
175
+ range.setStart(text, 0);
176
+ range.setEnd(text, i);
177
+ widths.push(range.getBoundingClientRect().width);
178
+ }
179
+ text.nodeValue = "…";
180
+ range.selectNodeContents(text);
181
+ const ellipsis = range.getBoundingClientRect().width;
182
+ const k = charsThatFit(widths, room + 0.5, ellipsis);
183
+ text.nodeValue = k === full.length ? full : full.slice(0, k) + "…";
184
+ name.style.textOverflow = "";
185
+ }
186
+ };
187
+ cut();
188
+ if (typeof ResizeObserver === "undefined")
189
+ return;
190
+ const watch = new ResizeObserver(() => { cancelAnimationFrame(frame); frame = requestAnimationFrame(cut); });
191
+ watch.observe(rootEl);
192
+ for (const pill of rootEl.querySelectorAll(".o-values-editor-pill")) {
193
+ watch.observe(pill, { box: "border-box" });
194
+ watch.observe(pill.querySelector(".o-values-editor-value"));
195
+ }
196
+ return () => { cancelAnimationFrame(frame); watch.disconnect(); };
197
+ }, [rootEl, worn.rows, rows, editing, view]);
198
+ const placeRoot = React.useCallback((el) => { root.current = el; setRootEl(el); if (!el) {
199
+ reset();
200
+ settled.current = false;
201
+ } }, []);
202
+ const add = () => {
203
+ const r = lineRead();
204
+ if ("value" in r) {
205
+ setRows((rs) => [...rs, { id: ++ids, value: r.value, label: labels.length ? labelFor(kind, w.labels) : undefined }]);
206
+ setTyped("");
207
+ setTried(false);
208
+ return "added";
209
+ }
210
+ if (!r.error)
211
+ return "empty";
212
+ setTried(true);
213
+ return "refused";
214
+ };
215
+ const remove = (i) => { setRows((rs) => rs.filter((_, j) => j !== i)); if (editing === i)
216
+ setEditing(null);
217
+ else if (editing != null && i < editing)
218
+ setEditing(editing - 1); };
219
+ const { gripProps, lift, dragging } = useReorder({ count: rows.length, onMove: (from, to) => setRows((rs) => moved(rs, from, to)), grip: ".o-values-editor-grip" });
220
+ const [mainHeld, setMainHeld] = React.useState();
221
+ const mainId = posed ? posed.mainId : dragging != null ? mainHeld : rows[0]?.id;
222
+ const lifted = (r, i) => (dragging === i || posed?.id === r.id ? "" : undefined);
223
+ const grip = (r, i, icon, size, look) => {
224
+ const g = gripProps(i);
225
+ return _jsx(Button, { kind: "quiet", shape: "icon", size: size, look: look, className: "o-values-editor-grip", "aria-label": w.move(r.value), icon: glyph(icon), ...g, onPointerDown: (e) => { setPosed(null); setMainHeld(rows[0]?.id); g.onPointerDown(e); } });
226
+ };
227
+ const [focusTo, setFocusTo] = React.useState(autoFocus && !phone ? (first.editing != null ? ".o-values-editor-edit input" : props.holds === "one" && first.rows.length ? ROOT : ".o-values-editor-line-input") : null);
228
+ React.useLayoutEffect(() => {
229
+ if (!focusTo || !root.current)
230
+ return;
231
+ const el = root.current, sel = focusTo;
232
+ setFocusTo(null);
233
+ requestAnimationFrame(() => {
234
+ const t = sel === ROOT ? el : el.querySelector(sel);
235
+ swapping.current = false;
236
+ t?.focus({ preventScroll: true });
237
+ if (shell && sel === ".o-values-editor-edit input" && t instanceof HTMLInputElement && /^(text|search|url|tel|password)$/.test(t.type))
238
+ t.setSelectionRange(t.value.length, t.value.length);
239
+ });
240
+ }, [focusTo, shell]);
241
+ const hold = () => { swapping.current = true; if (!phone)
242
+ root.current?.focus({ preventScroll: true }); };
243
+ const go = (to, row) => {
244
+ hold();
245
+ if (row != null)
246
+ setLabelOf(row);
247
+ if (phone && to === "rows")
248
+ requestAnimationFrame(() => { swapping.current = false; });
249
+ setView(to);
250
+ setFocusTo(to === "rows" ? (phone ? null : editing != null ? ".o-values-editor-edit input" : ".o-values-editor-line-input") : ".o-picker-input, [role='option']");
251
+ };
252
+ const back = () => go("rows");
253
+ const labelRow = labelOf != null ? rows[labelOf] : undefined;
254
+ useStepReturn(root, !phone ? [] : view === "label" && labelRow ? [openerAt(() => `[data-row="${CSS.escape(String(labelRow.id))}"] :is(.o-values-editor-label, .o-values-editor-edit-label)`)]
255
+ : view === "dial" ? [".o-values-editor-code"] : []);
256
+ const labelItems = [...labels, ...(labelOf != null && rows[labelOf]?.label && !labels.includes(rows[labelOf].label) ? [rows[labelOf].label] : [])].map((l) => ({ value: l, label: l }));
257
+ const setLabel = (l) => { if (typeof l === "string" && labelOf != null)
258
+ setRows((rs) => rs.map((r, i) => (i === labelOf ? { ...r, label: l } : r))); };
259
+ const names = React.useMemo(() => { try {
260
+ return new Intl.DisplayNames([language], { type: "region" });
261
+ }
262
+ catch {
263
+ return null;
264
+ } }, [language]);
265
+ const dialItems = dialCodes.map((d) => ({ value: d.country, label: `${names?.of(d.country) ?? d.country} ${d.code}`, as: { mark: _jsx(Flag, { code: d.country, size: phone ? "lg" : undefined }) } }));
266
+ const labelList = usePicker({ label: w.label, items: labelItems, value: labelOf != null ? rows[labelOf]?.label ?? null : null, onValueChange: setLabel, onCreate: (t) => t.trim(), onDone: back, search: w.labelSearch, form: "phone", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) });
267
+ const dialList = usePicker({ label: w.countryCode, items: attio ? countryItems(language) : dialItems, value: attio ? reading : country ?? null, onValueChange: (c) => { if (typeof c === "string")
268
+ setCountry(c); }, onDone: back, search: w.searchCountry, form: "phone", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) });
269
+ const hint = kind === "phone" && dial?.hint ? dial.hint : w.add[kind];
270
+ const under = worn.lists === "under";
271
+ const [drop, setDrop] = React.useState(null);
272
+ const popup = React.useRef(null);
273
+ const dropBack = React.useRef(null);
274
+ const closeDrop = () => { dropBack.current = root.current?.querySelector(drop?.what === "label" ? ".o-values-editor-edit input" : ".o-values-editor-line-input") ?? null; setDrop(null); };
275
+ const open = (what, row) => (e) => {
276
+ if (!under) {
277
+ go(what, row);
278
+ return;
279
+ }
280
+ if (row != null)
281
+ setLabelOf(row);
282
+ setDrop(drop?.what === what ? null : { what, at: e.currentTarget, row });
283
+ };
284
+ const [copied, setCopied] = React.useState(null);
285
+ React.useEffect(() => { if (!under)
286
+ setDrop(null); }, [under]);
287
+ const copy = (r) => () => {
288
+ try {
289
+ navigator.clipboard.writeText(r.value).then(() => setCopied(r.id), () => { });
290
+ }
291
+ catch { }
292
+ };
293
+ if (phone) {
294
+ const bad = checked ? rows.map((r) => rule(r.value)) : [];
295
+ const lineKeys = (e) => {
296
+ if (e.key !== "Enter" || midWord(e.nativeEvent))
297
+ return;
298
+ e.preventDefault();
299
+ if (shell && one) {
300
+ const r = lineRead();
301
+ if ("error" in r && r.error)
302
+ setTried(true);
303
+ onDone?.();
304
+ return;
305
+ }
306
+ if (one)
307
+ save();
308
+ else if (add() === "refused" && shell)
309
+ onDone?.();
310
+ };
311
+ const cardsLook = worn.phone === "cards", showLine = !(one && rows.length > 0);
312
+ const editKeys = (e) => { if (e.key === "Enter" && !midWord(e.nativeEvent)) {
313
+ e.preventDefault();
314
+ if (!finishEdit() && shell)
315
+ onDone?.();
316
+ } };
317
+ const card = (_jsxs(_Fragment, { children: [_jsxs(FieldRows, { look: ATTIO_ROWS, className: "o-values-editor-card", role: "list", "aria-label": label, children: [rows.map((r, i) => {
318
+ const act = openOf(kind, r.value);
319
+ return (_jsxs(React.Fragment, { children: [_jsxs(FieldRow, { as: "div", role: "listitem", className: "o-values-editor-row", "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), children: [!one && grip(r, i, GRIP, "32x44", { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none", icon: "16" }), editing === i ? (_jsxs(InlineInputGroup, { className: "o-values-editor-edit", style: ROW_40, children: [_jsx(Input, { "aria-label": w.change(r.value), value: editText, type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "done", onChange: (e) => setEditText(e.target.value), onKeyDown: editKeys }), labels.length > 0 && _jsx(InputGroupAddon, { side: "end", children: _jsx(InputGroupButton, { className: "o-values-editor-edit-label", size: "line", look: { radius: "none", corner: "round", edge: "none", words: "sm", icon: "14", hover: "words" }, "aria-label": w.labelIs(r.label ?? w.noLabel), onClick: () => go("label", i), iconEnd: glyph(DOWN), children: r.label ?? w.label }) })] })) : _jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "o-values-editor-value", onClick: () => { if (!finishEdit())
320
+ return; setEditing(i); setEditText(r.value); setFocusTo(".o-values-editor-edit input"); }, children: r.value }), r.label && labels.length > 0 && _jsx("span", { className: "o-values-editor-label", children: r.label }), _jsxs("span", { className: "o-values-editor-acts", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: { radius: "md", corner: "round", edge: "none", words: "inherit", icon: "20", hover: "none", press: "card" }, className: "o-values-editor-open", nativeButton: false, render: _jsx("a", { href: act.href }), "aria-label": w.open[kind](r.value), icon: glyph(kind === "phone" ? CALL : kind === "email" ? MAIL : OPEN) }), _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: { radius: "md", corner: "round", edge: "none", words: "inherit", icon: "20", hover: "none", press: "card" }, className: "o-values-editor-remove", "aria-label": w.remove(r.value), onClick: () => remove(i), icon: glyph(TRASH) })] })] })] }), bad[i] && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: bad[i] })] }, r.id));
321
+ }), showLine && (_jsxs("div", { className: "o-values-editor-line", "data-bad": refusal ? "" : undefined, children: [kind === "phone"
322
+ ? _jsxs(_Fragment, { children: [_jsx(Button, { kind: "quiet", size: "sm", look: { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "text", icon: "12", iconColour: "faint", pad: "8", gap: "4" }, className: "o-values-editor-code", "aria-label": w.countryIs(countryName(reading, language)), onClick: () => go("dial"), iconEnd: glyph(DOWN), children: reading }), _jsx("span", { className: "o-values-editor-prefix", children: dialOf(reading) })] })
323
+ : _jsx("span", { className: "o-values-editor-plus", children: glyph(PLUS) }), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-line-input", "aria-label": w.add[kind], value: typed, placeholder: kind === "phone" ? patternOf(reading) : w.cardLine[kind], type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "enter", onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }))] }), refusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: refusal })] }));
324
+ const cards = (_jsxs(FieldRows, { look: MIHAI_CARDS, className: "o-values-editor-cards", role: "list", "aria-label": label, children: [rows.map((r, i) => (_jsxs("div", { role: "listitem", "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), children: [_jsxs(FieldRow, { as: "div", className: "o-values-editor-card", children: [!one && grip(r, i, LINES, "20x24", { radius: "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none", icon: "20" }), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-card-input", "aria-label": w.nth[kind](i + 1), value: r.value, type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, onChange: (e) => setRows((rs) => rs.map((x) => (x.id === r.id ? { ...x, value: e.target.value } : x))) }), labels.length > 0 && _jsx(Button, { kind: "quiet", size: "line", look: { radius: "none", corner: "round", edge: "none", words: "sm", hover: "none" }, className: "o-values-editor-label", "aria-label": w.labelIs(r.label ?? w.noLabel), onClick: () => go("label", i), children: r.label ?? w.label }), _jsx(Button, { kind: "danger", shape: "round", size: "2xs", look: { edge: "none", words: "inherit", colour: "inherit", hover: "none" }, className: "o-values-editor-minus", "aria-label": w.remove(r.value), onClick: () => remove(i), children: _jsx("span", {}) })] }), bad[i] && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: bad[i] })] }, r.id))), showLine && _jsxs("div", { className: "o-values-editor-adding", children: [_jsxs(FieldRow, { className: "o-values-editor-card o-values-editor-new", children: [kind === "phone" ? _jsxs(_Fragment, { children: [dial && _jsx(Button, { kind: "quiet", shape: "icon", size: "line", look: { radius: "md", corner: "round", edge: "none", words: "xs-medium", colour: "text", disabled: "plain" }, className: "o-values-editor-code", "aria-label": w.countryCodeIs(dial.country), disabled: dialCodes.length < 2, onClick: () => go("dial"), icon: _jsx(Flag, { code: dial.country, size: "lg" }) }), dial && _jsx("span", { className: "o-values-editor-prefix", children: dial.code })] }) : glyph(ICON[kind]), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-card-input", value: typed, placeholder: w.add[kind], type: keys.type, inputMode: keys.inputMode, autofill: false, autoCapitalize: keys.autoCapitalize, enterKeyHint: "done", onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }), _jsx(Button, { kind: "soft", size: "lg", onClick: add, children: w.addButton })] }), refusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: refusal })] }));
325
+ const body = (_jsx("div", { ref: placeRoot, className: "o-values-editor", "data-kit": "values-editor", ...device, "data-values-form": "phone", "data-values-view": view, "data-values-holds": one ? "one" : "several", "data-values-phone": worn.phone, children: view === "label" ? labelList.body : view === "dial" ? dialList.body : cardsLook ? cards : card }));
326
+ if (view !== "rows")
327
+ return { body, head: { onBack: back, close: false }, title: view === "label" ? w.label : w.countryCode };
328
+ const save = () => {
329
+ if (edit != null && !finishEdit())
330
+ return;
331
+ if (rows.some((r) => rule(r.value))) {
332
+ setChecked(true);
333
+ return;
334
+ }
335
+ const r = lineRead();
336
+ if ("error" in r && r.error) {
337
+ setTried(true);
338
+ return;
339
+ }
340
+ keep(true);
341
+ };
342
+ if (shell)
343
+ return { body, head: {} };
344
+ return { body, head: { left: _jsx(SheetButton, { "aria-label": w.close, icon: glyph(X), onClick: leave }), right: _jsx(SheetButton, { kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: save }) } };
345
+ }
346
+ const onBlur = (e) => {
347
+ if (shell || settled.current || swapping.current || drop || !(e.target instanceof Node) || !e.currentTarget.contains(e.target))
348
+ return;
349
+ const to = e.relatedTarget;
350
+ if (to instanceof Node && (e.currentTarget.contains(to) || popup.current?.contains(to)))
351
+ return;
352
+ keep(true);
353
+ };
354
+ const onKeyDown = (e) => {
355
+ if (midWord(e.nativeEvent) || drop)
356
+ return;
357
+ if (shell) {
358
+ if (e.key === "Escape" && view !== "rows") {
359
+ e.preventDefault();
360
+ e.stopPropagation();
361
+ back();
362
+ }
363
+ return;
364
+ }
365
+ if (e.key === "Escape") {
366
+ e.preventDefault();
367
+ e.stopPropagation();
368
+ if (view !== "rows")
369
+ back();
370
+ else
371
+ keep(true);
372
+ }
373
+ };
374
+ const editKeys = (e) => {
375
+ if (e.key !== "Enter" || midWord(e.nativeEvent))
376
+ return;
377
+ e.preventDefault();
378
+ const v = editText.trim() ? keepAs(editText) : "";
379
+ if (v && rule(v)) {
380
+ if (shell)
381
+ onDone?.();
382
+ return;
383
+ }
384
+ if (one) {
385
+ keep();
386
+ return;
387
+ }
388
+ hold();
389
+ finishEdit();
390
+ setFocusTo(".o-values-editor-line-input");
391
+ };
392
+ const lineKeys = (e) => {
393
+ if (e.key !== "Enter" || midWord(e.nativeEvent))
394
+ return;
395
+ e.preventDefault();
396
+ if (one) {
397
+ const r = lineRead();
398
+ if ("error" in r && r.error)
399
+ setTried(true);
400
+ if ("value" in r || !r.error || shell)
401
+ keep(true);
402
+ return;
403
+ }
404
+ const a = add();
405
+ if (a === "empty" || (a === "refused" && shell))
406
+ keep();
407
+ };
408
+ const editRefusal = editing != null && editText.trim() ? rule(keepAs(editText)) : null;
409
+ const showLine = !(one && rows.length > 0);
410
+ const labelButton = (r, i) => labels.length > 0 && (_jsx(InputGroupAddon, { side: "end", children: _jsx(InputGroupButton, { className: "o-values-editor-edit-label", size: "line", look: under ? { radius: "xs", corner: "round", edge: "none", words: "sm", iconColour: "faint", pad: "4", hover: "words", open: "hovered" } : { radius: "none", corner: "round", edge: "none", words: "xs", hover: "words" }, "aria-label": w.labelIs(r.label ?? w.noLabel), "aria-haspopup": under ? "listbox" : undefined, "aria-expanded": under ? drop?.what === "label" : undefined, onClick: open("label", i), iconEnd: under ? glyph(DOWN) : undefined, children: r.label ?? w.label }) }));
411
+ const code = attio ? (_jsx(Button, { kind: "quiet", size: "2xs", look: { radius: "sm", corner: "round", edge: "none", words: "inherit", colour: "text", icon: "12", iconColour: "faint", pad: "6", open: "hovered" }, className: "o-values-editor-code", "aria-label": w.countryIs(countryName(reading, language)), "aria-haspopup": "listbox", "aria-expanded": drop?.what === "dial", onClick: open("dial"), iconEnd: glyph(DOWN), children: reading })) : dial && (_jsx(Button, { kind: "quiet", size: "26", look: { radius: "md", corner: "round", edge: "none", words: "xs-medium", colour: "text", disabled: "plain", icon: "12", iconColour: "faint" }, className: "o-values-editor-code", "aria-label": w.countryCodeIs(dial.country), disabled: dialCodes.length < 2, onClick: open("dial"), icon: _jsx(Flag, { code: dial.country }), iconEnd: dialCodes.length > 1 ? glyph(DOWN) : undefined, children: dial.country }));
412
+ const line = (_jsxs("div", { className: cx("o-values-editor-line", !attio && "o-popup-line"), "data-at": attio ? undefined : "foot", "data-bad": refusal ? "" : undefined, children: [kind === "phone"
413
+ ? _jsxs(_Fragment, { children: [code, attio ? _jsx("span", { className: "o-values-editor-prefix", children: dialOf(reading) }) : dial?.code && _jsx("span", { className: "o-values-editor-prefix", children: dial.code })] })
414
+ : attio ? _jsx("span", { className: "o-values-editor-plus", children: glyph(PLUS) }) : glyph(ICON[kind]), _jsx(Input, { chrome: "bare", numeric: true, className: "o-values-editor-line-input", "aria-label": w.add[kind], placeholder: kind === "phone" ? (attio ? patternOf(reading) : hint) : attio ? w.line[kind] : hint, value: typed, type: keys.type, inputMode: keys.inputMode, autofill: false, spellCheck: false, "aria-invalid": refusal ? true : undefined, onChange: (e) => setTyped(e.target.value), onKeyDown: lineKeys })] }));
415
+ const body = (_jsx("div", { ref: placeRoot, className: "o-values-editor", "data-kit": "values-editor", ...device, "data-values-form": "computer", "data-values-view": view, "data-values-holds": one ? "one" : "several", "data-values-rows": worn.rows, "data-values-main": worn.main, "data-values-line": worn.line, "data-values-lists": worn.lists, ...(view !== "rows" ? { [EDITOR_INNER_ESCAPE]: "" } : {}), role: "group", "aria-label": label, tabIndex: -1, onBlur: onBlur, onFocus: () => { settled.current = false; }, onKeyDown: onKeyDown, children: view === "rows" ? _jsxs(_Fragment, { children: [rows.length > 0 && (_jsx("div", { className: "o-values-editor-rows", role: "list", "aria-label": label, children: rows.map((r, i) => (_jsxs("div", { role: "listitem", className: "o-values-editor-row", "data-row": r.id, "data-lifted": lifted(r, i), style: lift(i), onPointerLeave: () => { if (copied === r.id)
416
+ setCopied(null); }, children: [!one && grip(r, i, GRIP, worn.rows === "copy" ? "2xs" : "20x24", { radius: worn.rows === "copy" ? "sm" : "md", corner: "round", edge: "none", words: "inherit", colour: "faint", cursor: "grab", hover: "none" }), editing === i ? (_jsxs(InlineInputGroup, { className: "o-values-editor-edit", style: ROW_28, "data-bad": editRefusal ? "" : undefined, children: [_jsx(Input, { numeric: true, "aria-label": w.change(r.value), value: editText, type: keys.type, inputMode: keys.inputMode, autofill: false, spellCheck: false, "aria-invalid": editRefusal ? true : undefined, onChange: (e) => setEditText(e.target.value), onKeyDown: editKeys, onBlur: (e) => { const to = e.relatedTarget; if (to && to !== root.current && root.current?.contains(to) && !e.currentTarget.parentElement?.contains(to) && !swapping.current)
417
+ finishEdit(); } }), labelButton(r, i)] })) : _jsxs(_Fragment, { children: [(() => {
418
+ const parts = kind === "email" ? splitEmail(r.value) : null;
419
+ const value = _jsx("button", { type: "button", className: "o-values-editor-value", "aria-label": r.value, onClick: () => { hold(); if (!finishEdit()) {
420
+ setFocusTo(".o-values-editor-edit input");
421
+ return;
422
+ } setEditing(i); setEditText(r.value); setFocusTo(".o-values-editor-edit input"); }, children: parts ? _jsxs(_Fragment, { children: [_jsx("span", { className: "o-values-editor-name", "data-name": parts[0], children: parts[0] }), _jsx("span", { className: "o-values-editor-domain", children: parts[1] })] }) : r.value });
423
+ return worn.rows === "copy" ? (_jsxs("span", { className: "o-values-editor-pill", children: [value, _jsx(Button, { kind: "quiet", shape: "icon", size: "20", look: { radius: "xs", corner: "round", edge: "none", words: "inherit", colour: "link", icon: "15", hover: "none" }, className: "o-values-editor-copy", "aria-label": w.copy(r.value), "data-copied": copied === r.id ? "" : undefined, onClick: copy(r), icon: glyph(copied === r.id ? TICK : COPY) })] })) : value;
424
+ })(), !one && worn.main === "pill" && r.id === mainId && _jsx("span", { className: "o-values-editor-main", children: w.main }), r.label && !one && _jsx("span", { className: "o-values-editor-label", children: r.label }), _jsx(Button, { kind: "quiet", shape: "icon", size: worn.rows === "copy" ? "2xs" : "22", look: worn.rows === "copy" ? { radius: "sm", corner: "round", edge: "none", words: "inherit", icon: "16" } : { radius: "md", corner: "round", edge: "none", words: "inherit" }, className: "o-values-editor-remove", "aria-label": w.remove(r.value), icon: glyph(worn.rows === "copy" ? TRASH : X), onClick: () => { hold(); remove(i); setFocusTo(editing != null ? ".o-values-editor-edit input" : ".o-values-editor-line-input"); } })] })] }, r.id))) })), editRefusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: editRefusal }), showLine && line, refusal && !shell && _jsx("p", { className: "o-values-editor-error", role: "alert", children: refusal }), under && (_jsx(Popover, { open: !!drop, popupData: props.popupData, anchor: drop?.at, side: "bottom", align: "start", sideOffset: spacingPx(1, drop?.at), finalFocus: dropBack, "aria-label": drop?.what === "label" ? w.label : w.country, style: { width: drop?.what === "label" ? "calc(var(--vk-spacing) * 48)" : "calc(var(--vk-spacing) * 60)" }, onOpenChange: (o, d) => {
425
+ if (o)
426
+ return;
427
+ closeDrop();
428
+ if (!shell && d.reason === "outside-press" && !(d.event?.target instanceof Node && root.current?.contains(d.event.target)))
429
+ keep(true);
430
+ }, onOutsidePress: (e) => (e.target instanceof Node && drop?.at.contains(e.target) ? false : undefined), children: _jsx("div", { ref: popup, children: drop?.what === "label"
431
+ ? _jsx(Picker, { label: w.label, items: labelItems, value: labelOf != null ? rows[labelOf]?.label ?? null : null, onValueChange: setLabel, onCreate: (t) => t.trim(), onDone: closeDrop, search: w.labelFind, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) })
432
+ : drop && _jsx(Picker, { label: w.country, items: attio ? countryItems(language) : dialItems, value: attio ? reading : country ?? null, onValueChange: (c) => { if (typeof c === "string")
433
+ setCountry(c); }, onDone: closeDrop, search: w.searchCountry, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) }) }) }))] }) : _jsxs(_Fragment, { children: [_jsxs("div", { className: "o-values-editor-back o-popup-line", children: [_jsx(Button, { kind: "quiet", shape: "icon", size: "xs", "aria-label": w.backTo(label.toLowerCase()), icon: glyph(LEFT), onClick: back }), _jsx("span", { children: view === "label" ? w.label : w.countryCode })] }), view === "label"
434
+ ? _jsx(Picker, { label: w.label, items: labelItems, value: labelOf != null ? rows[labelOf]?.label ?? null : null, onValueChange: setLabel, onCreate: (t) => t.trim(), onDone: back, search: w.labelFind, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) })
435
+ : _jsx(Picker, { label: w.countryCode, items: attio ? countryItems(language) : dialItems, value: attio ? reading : country ?? null, onValueChange: (c) => { if (typeof c === "string")
436
+ setCountry(c); }, onDone: back, search: w.findCountry, form: "computer", fromHeld: true, ...(w.picker ? { words: w.picker } : {}) })] }) }));
437
+ return { body, head: {} };
438
+ }
439
+ export function ValuesEditor(props) {
440
+ return _jsx(_Fragment, { children: useValuesEditor(props).body });
441
+ }
@@ -0,0 +1,71 @@
1
+ /** What a field holds several of. */
2
+ export type ValuesKind = "email" | "phone" | "link" | "domain";
3
+ /** One value of the list: what it is, its label (Work, Mobile), and whether it is the main one. */
4
+ export interface ListedValue {
5
+ value: string;
6
+ label?: string;
7
+ main?: boolean;
8
+ }
9
+ /** A phone's country code, as the field hands it in: the country (RO), its code (+40), and how a number is written there. */
10
+ export interface DialCode {
11
+ country: string;
12
+ code: string;
13
+ hint?: string;
14
+ }
15
+ /** The four labels' words, in the app's language. */
16
+ export interface LabelWords {
17
+ work: string;
18
+ personal: string;
19
+ mobile: string;
20
+ other: string;
21
+ }
22
+ /** The labels a value is picked from, in the words handed; unhanded, LABELS. */
23
+ export declare const labelsOf: (words?: LabelWords) => string[];
24
+ /** The labels a value is picked from, in English; one may be typed too. */
25
+ export declare const LABELS: string[];
26
+ /** A new value's label: Work for an email, Mobile for a phone, Other for a link, in the words handed; a domain has none. */
27
+ export declare const labelFor: (kind: ValuesKind, words?: LabelWords) => string | undefined;
28
+ /** The list with its main one first and marked main alone; with none marked, the first is the main one. */
29
+ export declare function listOf(values: ListedValue[]): ListedValue[];
30
+ /** An email as its name and its domain, split at its last @ (the domain keeps its @): on a touch screen the name is cut and
31
+ * the domain stays whole (KIT-455). Null for a value with no name before an @. */
32
+ export declare function splitEmail(value: string): [string, string] | null;
33
+ /** How many of a name's characters stand before its ellipsis: all of them when the whole fits `room`, else the most whose
34
+ * width with the ellipsis's does. `widths` are the widths after 1, 2, … characters, as a Range reads them (KIT-455). */
35
+ export declare function charsThatFit(widths: number[], room: number, ellipsis: number): number;
36
+ /** What the line reads: the value it adds, or why not ("" for nothing typed), with what was typed, trimmed. */
37
+ export type LineRead = {
38
+ value: string;
39
+ } | {
40
+ error: string;
41
+ typed?: string;
42
+ };
43
+ /** What the line adds: the value as `keep` keeps it (the body hands in the Text editor's kept; left out, trimmed), a phone's
44
+ * country code before it unless one is typed; or why `check` refuses it, with what was typed. Nothing typed is refused with no
45
+ * words: there is nothing to add. */
46
+ export declare function added(kind: ValuesKind, typed: string, check: (value: string) => string | null, dial?: DialCode, keep?: (typed: string) => string): LineRead;
47
+ /** What the list keeps, and what it hands a shell that keeps the draft (KIT-744), as one rule: the rows, a value being edited put
48
+ * back in its row (kept as `keep` keeps it; emptied, the row gone), rows left empty dropped, then what the line reads where it
49
+ * reads a value (`line`, as the line reads it: `added`, or a phone read in its country), with `label`; the first the main one.
50
+ * A refused edit keeps its row as it was, and a refused line hands nothing; with `refused` (a shell that judges the list
51
+ * itself, Mihai, 27 Nov 2026), each is handed as typed, so the holder refuses it and says why. */
52
+ export declare function handedList(rows: readonly {
53
+ value: string;
54
+ label?: string;
55
+ }[], edit: {
56
+ at: number;
57
+ text: string;
58
+ } | null, line: LineRead | null, o: {
59
+ check: (v: string) => string | null;
60
+ keep: (t: string) => string;
61
+ label?: string;
62
+ refused?: boolean;
63
+ }): ListedValue[];
64
+ /** What a cell shows: the main one, and how many more ("+40 773 768 874 +1"). */
65
+ export declare function valuesText(values: ListedValue[]): string;
66
+ /** A value's open action: a call, an email written, the page; and its name to a screen reader, in English (the body names it in
67
+ * the app's words). */
68
+ export declare function openOf(kind: ValuesKind, value: string): {
69
+ href: string;
70
+ label: string;
71
+ };
@@ -0,0 +1,59 @@
1
+ const ENGLISH = { work: "Work", personal: "Personal", mobile: "Mobile", other: "Other" };
2
+ export const labelsOf = (words = ENGLISH) => [words.work, words.personal, words.mobile, words.other];
3
+ export const LABELS = labelsOf(ENGLISH);
4
+ const NEW_LABEL = { email: "work", phone: "mobile", link: "other", domain: undefined };
5
+ export const labelFor = (kind, words = ENGLISH) => {
6
+ const k = NEW_LABEL[kind];
7
+ return k ? words[k] : undefined;
8
+ };
9
+ export function listOf(values) {
10
+ const at = Math.max(0, values.findIndex((v) => v.main));
11
+ const ordered = values.length ? [values[at], ...values.filter((_, i) => i !== at)] : [];
12
+ return ordered.map((v, i) => ({ ...v, main: i === 0 }));
13
+ }
14
+ export function splitEmail(value) {
15
+ const at = value.lastIndexOf("@");
16
+ return at > 0 ? [value.slice(0, at), value.slice(at)] : null;
17
+ }
18
+ export function charsThatFit(widths, room, ellipsis) {
19
+ if (!widths.length || widths[widths.length - 1] <= room)
20
+ return widths.length;
21
+ let k = 0;
22
+ while (k < widths.length && widths[k] + ellipsis <= room)
23
+ k++;
24
+ return k;
25
+ }
26
+ export function added(kind, typed, check, dial, keep = (t) => t.trim()) {
27
+ const v = typed.trim() ? keep(typed) : "";
28
+ if (!v)
29
+ return { error: "" };
30
+ const value = kind === "phone" && dial && !v.startsWith("+") ? `${dial.code} ${v}` : v;
31
+ const refusal = check(value);
32
+ return refusal ? { error: refusal, typed: typed.trim() } : { value };
33
+ }
34
+ export function handedList(rows, edit, line, o) {
35
+ const now = rows.flatMap((r, i) => {
36
+ if (!edit || i !== edit.at)
37
+ return [r];
38
+ const v = edit.text.trim() ? o.keep(edit.text) : "";
39
+ if (!v)
40
+ return [];
41
+ if (o.check(v))
42
+ return o.refused ? [{ ...r, value: edit.text.trim() }] : [r];
43
+ return [{ ...r, value: v }];
44
+ }).filter((r) => r.value.trim());
45
+ const typed = line && "value" in line ? line.value : line && o.refused && line.error && line.typed?.trim() ? line.typed.trim() : null;
46
+ const all = typed != null ? [...now, { value: typed, ...(o.label ? { label: o.label } : {}) }] : now;
47
+ return all.map((r, i) => ({ value: r.value, ...(r.label ? { label: r.label } : {}), main: i === 0 }));
48
+ }
49
+ export function valuesText(values) {
50
+ const list = listOf(values);
51
+ return list.length ? `${list[0].value}${list.length > 1 ? ` +${list.length - 1}` : ""}` : "";
52
+ }
53
+ export function openOf(kind, value) {
54
+ if (kind === "phone")
55
+ return { href: `tel:${value.replace(/[^\d+]/g, "")}`, label: `Call ${value}` };
56
+ if (kind === "email")
57
+ return { href: `mailto:${value}`, label: `Write to ${value}` };
58
+ return { href: /^https?:\/\//i.test(value) ? value : `https://${value}`, label: `Open ${value}` };
59
+ }
@@ -0,0 +1,50 @@
1
+ import type { PickerWords } from "../picker/picker.js";
2
+ import type { LabelWords, ValuesKind } from "./values.js";
3
+ export interface ValuesEditorWords {
4
+ /** Attio's line: "Add email…", "Add link…", "Add domain…" (a phone shows its pattern). */
5
+ line: Record<Exclude<ValuesKind, "phone">, string>;
6
+ /** Attio's card's line on a phone: "Add email", "Add link", "Add domain". */
7
+ cardLine: Record<Exclude<ValuesKind, "phone">, string>;
8
+ /** The line's name, and Mihai's placeholder: "Add an email". */
9
+ add: Record<ValuesKind, string>;
10
+ /** A card's box on a phone, in Mihai's look: "email 2". */
11
+ nth: Record<ValuesKind, (n: number) => string>;
12
+ /** Mihai's Add, on a phone. */
13
+ addButton: string;
14
+ /** A value's buttons. */
15
+ change: (value: string) => string;
16
+ copy: (value: string) => string;
17
+ move: (value: string) => string;
18
+ remove: (value: string) => string;
19
+ /** A value's open action: a call, an email written, the page. */
20
+ open: Record<ValuesKind, (value: string) => string>;
21
+ /** The main value's mark, in Mihai's look. */
22
+ main: string;
23
+ /** An unlabelled value's label button, the label list's name and its step's title. */
24
+ label: string;
25
+ /** A label button's name: "Label: Work", and "none" for no label. */
26
+ labelIs: (label: string) => string;
27
+ noLabel: string;
28
+ /** The label list's search, on a phone and on a computer. */
29
+ labelSearch: string;
30
+ labelFind: string;
31
+ /** The labels a value is picked from. */
32
+ labels: LabelWords;
33
+ /** A phone's country: the list's name, its searches, its step's title, and its button's names. */
34
+ country: string;
35
+ searchCountry: string;
36
+ findCountry: string;
37
+ countryCode: string;
38
+ countryIs: (country: string) => string;
39
+ countryCodeIs: (country: string) => string;
40
+ /** Back from a list in the values' place: "Back to emails" (the field's name, lowercased). */
41
+ backTo: (label: string) => string;
42
+ /** On a phone, its own sheet head's ✕ and ✓ (where no holder draws them). */
43
+ close: string;
44
+ save: string;
45
+ /** The words of its lists. */
46
+ picker?: Partial<PickerWords>;
47
+ }
48
+ export declare const VALUES_EDITOR_WORDS: ValuesEditorWords;
49
+ /** The words handed over the English. */
50
+ export declare const valuesWords: (given?: Partial<ValuesEditorWords>) => ValuesEditorWords;