@k2b/ui 0.33.0 → 0.35.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 (310) hide show
  1. package/dist/base.css +14 -1
  2. package/dist/browser/actions/ContextMenu.js +13 -0
  3. package/dist/browser/actions/ContextMenu.js.map +1 -1
  4. package/dist/browser/actions/Dropdown.js +16 -4
  5. package/dist/browser/actions/Dropdown.js.map +1 -1
  6. package/dist/browser/actions/SelectionToolbar.js +129 -0
  7. package/dist/browser/actions/SelectionToolbar.js.map +1 -0
  8. package/dist/browser/actions/index.js +1 -0
  9. package/dist/browser/actions/index.js.map +1 -1
  10. package/dist/browser/charts.js +6 -0
  11. package/dist/browser/charts.js.map +1 -0
  12. package/dist/browser/chat/ChatComposer.js +525 -407
  13. package/dist/browser/chat/ChatComposer.js.map +1 -1
  14. package/dist/browser/chat/chat-messages.js +4 -0
  15. package/dist/browser/chat/chat-messages.js.map +1 -1
  16. package/dist/browser/chat/composer-document.js +19 -0
  17. package/dist/browser/chat/composer-document.js.map +1 -1
  18. package/dist/browser/chat/index.js.map +1 -1
  19. package/dist/browser/content/Chart.js +8 -0
  20. package/dist/browser/content/Chart.js.map +1 -1
  21. package/dist/browser/content/FileGrid.js +231 -9
  22. package/dist/browser/content/FileGrid.js.map +1 -1
  23. package/dist/browser/content/FileTypeIcon.js +15 -0
  24. package/dist/browser/content/FileTypeIcon.js.map +1 -1
  25. package/dist/browser/content/FileView.js +11 -4
  26. package/dist/browser/content/FileView.js.map +1 -1
  27. package/dist/browser/content/MatchText.js +61 -0
  28. package/dist/browser/content/MatchText.js.map +1 -0
  29. package/dist/browser/content/MessageRow.js +73 -53
  30. package/dist/browser/content/MessageRow.js.map +1 -1
  31. package/dist/browser/content/ReactionBar.js +3 -1
  32. package/dist/browser/content/ReactionBar.js.map +1 -1
  33. package/dist/browser/content/calendar-day-scroll.js +4 -3
  34. package/dist/browser/content/calendar-day-scroll.js.map +1 -1
  35. package/dist/browser/content/chart-bar.js +476 -0
  36. package/dist/browser/content/chart-bar.js.map +1 -0
  37. package/dist/browser/content/file-list-messages.js +52 -0
  38. package/dist/browser/content/file-list-messages.js.map +1 -0
  39. package/dist/browser/content/index.js +2 -1
  40. package/dist/browser/content/index.js.map +1 -1
  41. package/dist/browser/feedback/Tooltip.js +31 -14
  42. package/dist/browser/feedback/Tooltip.js.map +1 -1
  43. package/dist/browser/inputs/ChoiceList.js +178 -0
  44. package/dist/browser/inputs/ChoiceList.js.map +1 -0
  45. package/dist/browser/inputs/ChoiceSlider.js +314 -0
  46. package/dist/browser/inputs/ChoiceSlider.js.map +1 -0
  47. package/dist/browser/inputs/ChoiceTiles.js +135 -0
  48. package/dist/browser/inputs/ChoiceTiles.js.map +1 -0
  49. package/dist/browser/inputs/ColorChoices.js +120 -0
  50. package/dist/browser/inputs/ColorChoices.js.map +1 -0
  51. package/dist/browser/inputs/QrScanner.js +95 -13
  52. package/dist/browser/inputs/QrScanner.js.map +1 -1
  53. package/dist/browser/inputs/TextInput.js +15 -13
  54. package/dist/browser/inputs/TextInput.js.map +1 -1
  55. package/dist/browser/inputs/index.js +4 -0
  56. package/dist/browser/inputs/index.js.map +1 -1
  57. package/dist/browser/inputs/qr-messages.js +2 -0
  58. package/dist/browser/inputs/qr-messages.js.map +1 -1
  59. package/dist/browser/internal/radio-keys.js +13 -0
  60. package/dist/browser/internal/radio-keys.js.map +1 -0
  61. package/dist/browser/layout/AnchoredPopover.js +180 -0
  62. package/dist/browser/layout/AnchoredPopover.js.map +1 -0
  63. package/dist/browser/layout/AppWorkspace.js +155 -20
  64. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  65. package/dist/browser/layout/DetailPanel.js +443 -333
  66. package/dist/browser/layout/DetailPanel.js.map +1 -1
  67. package/dist/browser/layout/MobileShell.js +21 -7
  68. package/dist/browser/layout/MobileShell.js.map +1 -1
  69. package/dist/browser/layout/Settings.js +283 -175
  70. package/dist/browser/layout/Settings.js.map +1 -1
  71. package/dist/browser/layout/SidebarRailHint.js +79 -0
  72. package/dist/browser/layout/SidebarRailHint.js.map +1 -0
  73. package/dist/browser/layout/SidebarSwitcher.js +79 -66
  74. package/dist/browser/layout/SidebarSwitcher.js.map +1 -1
  75. package/dist/browser/layout/TabBar.js +18 -4
  76. package/dist/browser/layout/TabBar.js.map +1 -1
  77. package/dist/browser/layout/app-workspace-controller.js +11 -4
  78. package/dist/browser/layout/app-workspace-controller.js.map +1 -1
  79. package/dist/browser/layout/detail-panel-messages.js +4 -2
  80. package/dist/browser/layout/detail-panel-messages.js.map +1 -1
  81. package/dist/browser/layout/index.js +2 -1
  82. package/dist/browser/layout/index.js.map +1 -1
  83. package/dist/browser/layout/settings-messages.js +26 -2
  84. package/dist/browser/layout/settings-messages.js.map +1 -1
  85. package/dist/browser/surfaces/Avatar.js +2 -14
  86. package/dist/browser/surfaces/Avatar.js.map +1 -1
  87. package/dist/browser/surfaces/DotStrip.js +70 -0
  88. package/dist/browser/surfaces/DotStrip.js.map +1 -0
  89. package/dist/browser/surfaces/ProgressRing.js +3 -0
  90. package/dist/browser/surfaces/ProgressRing.js.map +1 -1
  91. package/dist/browser/surfaces/ResourceCard.js +125 -68
  92. package/dist/browser/surfaces/ResourceCard.js.map +1 -1
  93. package/dist/browser/surfaces/index.js +2 -0
  94. package/dist/browser/surfaces/index.js.map +1 -1
  95. package/dist/browser/surfaces/person-color.js +18 -0
  96. package/dist/browser/surfaces/person-color.js.map +1 -0
  97. package/dist/browser/surfaces/resource-messages.js +6 -2
  98. package/dist/browser/surfaces/resource-messages.js.map +1 -1
  99. package/dist/browser/text-editor/TextEditor.js +1358 -0
  100. package/dist/browser/text-editor/TextEditor.js.map +1 -0
  101. package/dist/browser/text-editor/clipboard-html.js +152 -0
  102. package/dist/browser/text-editor/clipboard-html.js.map +1 -0
  103. package/dist/browser/text-editor/clipboard-loading.js +68 -0
  104. package/dist/browser/text-editor/clipboard-loading.js.map +1 -0
  105. package/dist/browser/text-editor/clipboard.js +51 -0
  106. package/dist/browser/text-editor/clipboard.js.map +1 -0
  107. package/dist/browser/text-editor/engine.js +125 -0
  108. package/dist/browser/text-editor/engine.js.map +1 -0
  109. package/dist/browser/text-editor/format.js +218 -0
  110. package/dist/browser/text-editor/format.js.map +1 -0
  111. package/dist/browser/text-editor/formatted.js +164 -0
  112. package/dist/browser/text-editor/formatted.js.map +1 -0
  113. package/dist/browser/text-editor/language.js +19 -0
  114. package/dist/browser/text-editor/language.js.map +1 -0
  115. package/dist/browser/text-editor/markdown-table.js +563 -0
  116. package/dist/browser/text-editor/markdown-table.js.map +1 -0
  117. package/dist/browser/text-editor/messages.js +233 -0
  118. package/dist/browser/text-editor/messages.js.map +1 -0
  119. package/dist/browser/text-editor/paste.js +115 -0
  120. package/dist/browser/text-editor/paste.js.map +1 -0
  121. package/dist/browser/text-editor/table.js +1760 -0
  122. package/dist/browser/text-editor/table.js.map +1 -0
  123. package/dist/browser/text-editor.js +5 -0
  124. package/dist/browser/text-editor.js.map +1 -0
  125. package/dist/browser/widgets/Widget.js +3 -2
  126. package/dist/browser/widgets/Widget.js.map +1 -1
  127. package/dist/ssr/actions/ContextMenu.js +9 -0
  128. package/dist/ssr/actions/ContextMenu.js.map +1 -1
  129. package/dist/ssr/actions/Dropdown.js +15 -4
  130. package/dist/ssr/actions/Dropdown.js.map +1 -1
  131. package/dist/ssr/actions/SelectionToolbar.js +104 -0
  132. package/dist/ssr/actions/SelectionToolbar.js.map +1 -0
  133. package/dist/ssr/actions/index.js +1 -0
  134. package/dist/ssr/actions/index.js.map +1 -1
  135. package/dist/ssr/charts.js +6 -0
  136. package/dist/ssr/charts.js.map +1 -0
  137. package/dist/ssr/chat/ChatComposer.js +132 -53
  138. package/dist/ssr/chat/ChatComposer.js.map +1 -1
  139. package/dist/ssr/chat/chat-messages.js +4 -0
  140. package/dist/ssr/chat/chat-messages.js.map +1 -1
  141. package/dist/ssr/chat/composer-document.js +19 -0
  142. package/dist/ssr/chat/composer-document.js.map +1 -1
  143. package/dist/ssr/chat/index.js.map +1 -1
  144. package/dist/ssr/content/Chart.js +8 -0
  145. package/dist/ssr/content/Chart.js.map +1 -1
  146. package/dist/ssr/content/FileGrid.js +132 -5
  147. package/dist/ssr/content/FileGrid.js.map +1 -1
  148. package/dist/ssr/content/FileTypeIcon.js +15 -0
  149. package/dist/ssr/content/FileTypeIcon.js.map +1 -1
  150. package/dist/ssr/content/FileView.js +11 -4
  151. package/dist/ssr/content/FileView.js.map +1 -1
  152. package/dist/ssr/content/MatchText.js +56 -0
  153. package/dist/ssr/content/MatchText.js.map +1 -0
  154. package/dist/ssr/content/MessageRow.js +16 -6
  155. package/dist/ssr/content/MessageRow.js.map +1 -1
  156. package/dist/ssr/content/ReactionBar.js +3 -1
  157. package/dist/ssr/content/ReactionBar.js.map +1 -1
  158. package/dist/ssr/content/calendar-day-scroll.js +4 -3
  159. package/dist/ssr/content/calendar-day-scroll.js.map +1 -1
  160. package/dist/ssr/content/chart-bar.js +476 -0
  161. package/dist/ssr/content/chart-bar.js.map +1 -0
  162. package/dist/ssr/content/file-list-messages.js +52 -0
  163. package/dist/ssr/content/file-list-messages.js.map +1 -0
  164. package/dist/ssr/content/index.js +2 -1
  165. package/dist/ssr/content/index.js.map +1 -1
  166. package/dist/ssr/feedback/Tooltip.js +31 -14
  167. package/dist/ssr/feedback/Tooltip.js.map +1 -1
  168. package/dist/ssr/inputs/ChoiceList.js +95 -0
  169. package/dist/ssr/inputs/ChoiceList.js.map +1 -0
  170. package/dist/ssr/inputs/ChoiceSlider.js +191 -0
  171. package/dist/ssr/inputs/ChoiceSlider.js.map +1 -0
  172. package/dist/ssr/inputs/ChoiceTiles.js +61 -0
  173. package/dist/ssr/inputs/ChoiceTiles.js.map +1 -0
  174. package/dist/ssr/inputs/ColorChoices.js +60 -0
  175. package/dist/ssr/inputs/ColorChoices.js.map +1 -0
  176. package/dist/ssr/inputs/QrScanner.js +89 -10
  177. package/dist/ssr/inputs/QrScanner.js.map +1 -1
  178. package/dist/ssr/inputs/TextInput.js +13 -1
  179. package/dist/ssr/inputs/TextInput.js.map +1 -1
  180. package/dist/ssr/inputs/index.js +4 -0
  181. package/dist/ssr/inputs/index.js.map +1 -1
  182. package/dist/ssr/inputs/qr-messages.js +2 -0
  183. package/dist/ssr/inputs/qr-messages.js.map +1 -1
  184. package/dist/ssr/internal/radio-keys.js +13 -0
  185. package/dist/ssr/internal/radio-keys.js.map +1 -0
  186. package/dist/ssr/layout/AnchoredPopover.js +142 -0
  187. package/dist/ssr/layout/AnchoredPopover.js.map +1 -0
  188. package/dist/ssr/layout/AppWorkspace.js +154 -20
  189. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  190. package/dist/ssr/layout/DetailPanel.js +181 -108
  191. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  192. package/dist/ssr/layout/MobileShell.js +20 -6
  193. package/dist/ssr/layout/MobileShell.js.map +1 -1
  194. package/dist/ssr/layout/Settings.js +122 -45
  195. package/dist/ssr/layout/Settings.js.map +1 -1
  196. package/dist/ssr/layout/SidebarRailHint.js +79 -0
  197. package/dist/ssr/layout/SidebarRailHint.js.map +1 -0
  198. package/dist/ssr/layout/SidebarSwitcher.js +13 -3
  199. package/dist/ssr/layout/SidebarSwitcher.js.map +1 -1
  200. package/dist/ssr/layout/TabBar.js +11 -3
  201. package/dist/ssr/layout/TabBar.js.map +1 -1
  202. package/dist/ssr/layout/app-workspace-controller.js +11 -4
  203. package/dist/ssr/layout/app-workspace-controller.js.map +1 -1
  204. package/dist/ssr/layout/detail-panel-messages.js +4 -2
  205. package/dist/ssr/layout/detail-panel-messages.js.map +1 -1
  206. package/dist/ssr/layout/index.js +2 -1
  207. package/dist/ssr/layout/index.js.map +1 -1
  208. package/dist/ssr/layout/settings-messages.js +26 -2
  209. package/dist/ssr/layout/settings-messages.js.map +1 -1
  210. package/dist/ssr/surfaces/Avatar.js +2 -14
  211. package/dist/ssr/surfaces/Avatar.js.map +1 -1
  212. package/dist/ssr/surfaces/DotStrip.js +31 -0
  213. package/dist/ssr/surfaces/DotStrip.js.map +1 -0
  214. package/dist/ssr/surfaces/ProgressRing.js +3 -0
  215. package/dist/ssr/surfaces/ProgressRing.js.map +1 -1
  216. package/dist/ssr/surfaces/ResourceCard.js +40 -15
  217. package/dist/ssr/surfaces/ResourceCard.js.map +1 -1
  218. package/dist/ssr/surfaces/index.js +2 -0
  219. package/dist/ssr/surfaces/index.js.map +1 -1
  220. package/dist/ssr/surfaces/person-color.js +18 -0
  221. package/dist/ssr/surfaces/person-color.js.map +1 -0
  222. package/dist/ssr/surfaces/resource-messages.js +6 -2
  223. package/dist/ssr/surfaces/resource-messages.js.map +1 -1
  224. package/dist/ssr/text-editor/TextEditor.js +1155 -0
  225. package/dist/ssr/text-editor/TextEditor.js.map +1 -0
  226. package/dist/ssr/text-editor/clipboard-html.js +152 -0
  227. package/dist/ssr/text-editor/clipboard-html.js.map +1 -0
  228. package/dist/ssr/text-editor/clipboard-loading.js +68 -0
  229. package/dist/ssr/text-editor/clipboard-loading.js.map +1 -0
  230. package/dist/ssr/text-editor/clipboard.js +51 -0
  231. package/dist/ssr/text-editor/clipboard.js.map +1 -0
  232. package/dist/ssr/text-editor/engine.js +125 -0
  233. package/dist/ssr/text-editor/engine.js.map +1 -0
  234. package/dist/ssr/text-editor/format.js +218 -0
  235. package/dist/ssr/text-editor/format.js.map +1 -0
  236. package/dist/ssr/text-editor/formatted.js +164 -0
  237. package/dist/ssr/text-editor/formatted.js.map +1 -0
  238. package/dist/ssr/text-editor/language.js +19 -0
  239. package/dist/ssr/text-editor/language.js.map +1 -0
  240. package/dist/ssr/text-editor/markdown-table.js +563 -0
  241. package/dist/ssr/text-editor/markdown-table.js.map +1 -0
  242. package/dist/ssr/text-editor/messages.js +233 -0
  243. package/dist/ssr/text-editor/messages.js.map +1 -0
  244. package/dist/ssr/text-editor/paste.js +115 -0
  245. package/dist/ssr/text-editor/paste.js.map +1 -0
  246. package/dist/ssr/text-editor/table.js +1760 -0
  247. package/dist/ssr/text-editor/table.js.map +1 -0
  248. package/dist/ssr/text-editor.js +5 -0
  249. package/dist/ssr/text-editor.js.map +1 -0
  250. package/dist/ssr/widgets/Widget.js +3 -2
  251. package/dist/ssr/widgets/Widget.js.map +1 -1
  252. package/dist/styles.css +1 -1
  253. package/dist/types/actions/ContextMenu.d.ts +5 -0
  254. package/dist/types/actions/Dropdown.d.ts +7 -0
  255. package/dist/types/actions/SelectionToolbar.d.ts +38 -0
  256. package/dist/types/actions/index.d.ts +2 -0
  257. package/dist/types/charts.d.ts +5 -0
  258. package/dist/types/chat/ChatComposer.d.ts +15 -0
  259. package/dist/types/chat/chat-messages.d.ts +2 -0
  260. package/dist/types/chat/composer-document.d.ts +5 -0
  261. package/dist/types/chat/index.d.ts +1 -1
  262. package/dist/types/content/Chart.d.ts +2 -1
  263. package/dist/types/content/FileGrid.d.ts +43 -3
  264. package/dist/types/content/FileTypeIcon.d.ts +10 -0
  265. package/dist/types/content/FileView.d.ts +5 -1
  266. package/dist/types/content/MatchText.d.ts +21 -0
  267. package/dist/types/content/MessageRow.d.ts +2 -0
  268. package/dist/types/content/calendar-day-scroll.d.ts +2 -1
  269. package/dist/types/content/chart-bar.d.ts +60 -0
  270. package/dist/types/content/file-list-messages.d.ts +24 -0
  271. package/dist/types/content/index.d.ts +3 -2
  272. package/dist/types/feedback/Tooltip.d.ts +8 -2
  273. package/dist/types/inputs/ChoiceList.d.ts +28 -0
  274. package/dist/types/inputs/ChoiceSlider.d.ts +36 -0
  275. package/dist/types/inputs/ChoiceTiles.d.ts +25 -0
  276. package/dist/types/inputs/ColorChoices.d.ts +19 -0
  277. package/dist/types/inputs/index.d.ts +8 -0
  278. package/dist/types/inputs/qr-messages.d.ts +1 -0
  279. package/dist/types/internal/radio-keys.d.ts +5 -0
  280. package/dist/types/layout/AnchoredPopover.d.ts +31 -0
  281. package/dist/types/layout/AppWorkspace.d.ts +10 -0
  282. package/dist/types/layout/DetailPanel.d.ts +17 -0
  283. package/dist/types/layout/MobileShell.d.ts +5 -2
  284. package/dist/types/layout/Settings.d.ts +22 -0
  285. package/dist/types/layout/SidebarRailHint.d.ts +26 -0
  286. package/dist/types/layout/TabBar.d.ts +5 -0
  287. package/dist/types/layout/detail-panel-messages.d.ts +1 -0
  288. package/dist/types/layout/index.d.ts +3 -2
  289. package/dist/types/layout/settings-messages.d.ts +12 -0
  290. package/dist/types/surfaces/DotStrip.d.ts +22 -0
  291. package/dist/types/surfaces/ProgressRing.d.ts +2 -1
  292. package/dist/types/surfaces/ResourceCard.d.ts +9 -0
  293. package/dist/types/surfaces/index.d.ts +4 -1
  294. package/dist/types/surfaces/person-color.d.ts +10 -0
  295. package/dist/types/surfaces/resource-messages.d.ts +2 -0
  296. package/dist/types/text-editor/TextEditor.d.ts +69 -0
  297. package/dist/types/text-editor/clipboard-html.d.ts +9 -0
  298. package/dist/types/text-editor/clipboard-loading.d.ts +8 -0
  299. package/dist/types/text-editor/clipboard.d.ts +20 -0
  300. package/dist/types/text-editor/engine.d.ts +34 -0
  301. package/dist/types/text-editor/format.d.ts +34 -0
  302. package/dist/types/text-editor/formatted.d.ts +1 -0
  303. package/dist/types/text-editor/language.d.ts +8 -0
  304. package/dist/types/text-editor/markdown-table.d.ts +105 -0
  305. package/dist/types/text-editor/messages.d.ts +113 -0
  306. package/dist/types/text-editor/paste.d.ts +6 -0
  307. package/dist/types/text-editor/table.d.ts +81 -0
  308. package/dist/types/text-editor.d.ts +4 -0
  309. package/dist/types/widgets/Widget.d.ts +3 -2
  310. package/package.json +28 -3
@@ -0,0 +1,61 @@
1
+ import { ssr as _$ssr } from "solid-js/web";
2
+ import { createComponent as _$createComponent } from "solid-js/web";
3
+ import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
4
+ import { escape as _$escape } from "solid-js/web";
5
+ var _tmpl$ = ["<div class=\"k2b-choice-tiles__group\" role=\"radiogroup\"", ">", "</div>"],
6
+ _tmpl$2 = ["<button type=\"button\" role=\"radio\" class=\"k2b-choice-tiles__tile\"", "", "><span class=\"k2b-choice-tiles__visual\" aria-hidden=\"true\">", "</span><span class=\"k2b-choice-tiles__text\"><span class=\"k2b-choice-tiles__label\">", "</span>", "</span></button>"],
7
+ _tmpl$3 = ["<span class=\"k2b-choice-tiles__status\">", "</span>"];
8
+ import { For } from "solid-js";
9
+ import { createFieldMeta, Field, fieldDescribedBy } from "../internal/field";
10
+ import { radioKeyTarget } from "../internal/radio-keys";
11
+ import { resolveMaybeAccessor } from "./field-contract";
12
+ /**
13
+ * A labeled single choice shown as tiles with a preview, for picking how something looks: a face shape, a frame, a
14
+ * kind of picture. Every tile keeps its size when chosen, so nothing moves. Use `ChoiceChips` for text choices and
15
+ * `ColorChoices` for named colours.
16
+ */
17
+ export function ChoiceTiles(props) {
18
+ const meta = createFieldMeta(props.id);
19
+ let group;
20
+ const value = () => resolveMaybeAccessor(props.value) ?? null;
21
+ const tabStop = (option, index) => value() === option.value || index === 0 && !props.options.some(candidate => candidate.value === value());
22
+ const choose = (index, focus = false) => {
23
+ const option = props.options[index];
24
+ if (!option || props.disabled) return;
25
+ props.onValueChange?.(option.value);
26
+ props.onValueCommit?.(option.value);
27
+ // The radios in their current DOM order: options may have been reordered since they rendered.
28
+ if (focus) queueMicrotask(() => group?.querySelectorAll('[role="radio"]')[index]?.focus());
29
+ };
30
+ return _$createComponent(Field, {
31
+ meta: meta,
32
+ labelFor: false,
33
+ get ["class"]() {
34
+ return props.class;
35
+ },
36
+ get label() {
37
+ return props.label;
38
+ },
39
+ get description() {
40
+ return props.description;
41
+ },
42
+ get error() {
43
+ return props.error;
44
+ },
45
+ get required() {
46
+ return props.required;
47
+ },
48
+ get disabled() {
49
+ return props.disabled;
50
+ },
51
+ get children() {
52
+ return _$ssr(_tmpl$, _$ssrAttribute("data-layout", _$escape(props.layout ?? "grid", true), false) + _$ssrAttribute("data-dimmed", props.dimmed ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("aria-label", props.label ? _$escape(undefined, true) : _$escape(props["aria-label"], true), false) + _$ssrAttribute("aria-labelledby", props.label ? _$escape(meta.labelId, true) : _$escape(undefined, true), false) + _$ssrAttribute("aria-describedby", _$escape(fieldDescribedBy(meta, props), true), false) + _$ssrAttribute("aria-disabled", props.disabled ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(For, {
53
+ get each() {
54
+ return props.options;
55
+ },
56
+ children: (option, index) => _$ssr(_tmpl$2, _$ssrAttribute("aria-checked", _$escape(value(), true) === _$escape(option.value, true), false), _$ssrAttribute("disabled", props.disabled, true) + _$ssrAttribute("tabindex", tabStop(option, index()) ? 0 : -1, false), _$escape(option.visual), _$escape(option.label), props.layout === "row" && _$ssr(_tmpl$3, _$escape(option.status ?? "")))
57
+ })));
58
+ }
59
+ });
60
+ }
61
+ //# sourceMappingURL=ChoiceTiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["inputs/ChoiceTiles.tsx"],"sourcesContent":["import { For, type JSX } from \"solid-js\";\nimport { createFieldMeta, Field, fieldDescribedBy } from \"../internal/field\";\nimport { radioKeyTarget } from \"../internal/radio-keys\";\nimport type { ValueFieldProps } from \"./field-contract\";\nimport { resolveMaybeAccessor } from \"./field-contract\";\n\nexport type ChoiceTileOption<T extends string = string> = {\n value: T;\n label: string;\n /** What the choice looks like, such as a preview image; decorative, the label names the choice. */\n visual: JSX.Element;\n /** A short state under the label, such as \"Active\"; keeps its line, so tiles never change height. */\n status?: string;\n};\n\nexport type ChoiceTilesProps<T extends string = string> = Omit<ValueFieldProps<T | null>, \"onValueChange\" | \"onValueCommit\"> & {\n options: readonly ChoiceTileOption<T>[];\n /** `grid`: preview over label in as many columns as fit. `row`: preview beside label in one row, stacked on phones. */\n layout?: \"grid\" | \"row\";\n /** The choice is kept but has no visible effect right now; previews are dimmed, choosing still works. */\n dimmed?: boolean;\n onValueChange?: (value: T) => void;\n onValueCommit?: (value: T) => void;\n};\n\n/**\n * A labeled single choice shown as tiles with a preview, for picking how something looks: a face shape, a frame, a\n * kind of picture. Every tile keeps its size when chosen, so nothing moves. Use `ChoiceChips` for text choices and\n * `ColorChoices` for named colours.\n */\nexport function ChoiceTiles<T extends string = string>(props: ChoiceTilesProps<T>): JSX.Element {\n const meta = createFieldMeta(props.id);\n let group: HTMLDivElement | undefined;\n const value = () => resolveMaybeAccessor(props.value) ?? null;\n const tabStop = (option: ChoiceTileOption<T>, index: number) =>\n value() === option.value || (index === 0 && !props.options.some((candidate) => candidate.value === value()));\n const choose = (index: number, focus = false) => {\n const option = props.options[index];\n if (!option || props.disabled) return;\n props.onValueChange?.(option.value);\n props.onValueCommit?.(option.value);\n // The radios in their current DOM order: options may have been reordered since they rendered.\n if (focus) queueMicrotask(() => group?.querySelectorAll<HTMLButtonElement>('[role=\"radio\"]')[index]?.focus());\n };\n return (\n <Field\n meta={meta}\n labelFor={false}\n class={props.class}\n label={props.label}\n description={props.description}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <div\n class=\"k2b-choice-tiles__group\"\n ref={group}\n role=\"radiogroup\"\n data-layout={props.layout ?? \"grid\"}\n data-dimmed={props.dimmed ? \"true\" : undefined}\n aria-label={props.label ? undefined : props[\"aria-label\"]}\n aria-labelledby={props.label ? meta.labelId : undefined}\n aria-describedby={fieldDescribedBy(meta, props)}\n aria-disabled={props.disabled ? \"true\" : undefined}\n >\n <For each={props.options}>\n {(option, index) => (\n <button\n type=\"button\"\n role=\"radio\"\n class=\"k2b-choice-tiles__tile\"\n aria-checked={value() === option.value}\n disabled={props.disabled}\n tabIndex={tabStop(option, index()) ? 0 : -1}\n onClick={() => choose(index())}\n onKeyDown={(event) => {\n const target = radioKeyTarget(event.key, index(), props.options.length);\n if (target === undefined) return;\n event.preventDefault();\n choose(target, true);\n }}\n >\n <span class=\"k2b-choice-tiles__visual\" aria-hidden=\"true\">\n {option.visual}\n </span>\n <span class=\"k2b-choice-tiles__text\">\n <span class=\"k2b-choice-tiles__label\">{option.label}</span>\n {props.layout === \"row\" && <span class=\"k2b-choice-tiles__status\">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R,KAAK,CAAC,KAAK;IAAA;IAAA,IAClB,KAAK;MAAA,OAAE,KAAK,CAAC,KAAK;IAAA;IAAA,IAClB,WAAW;MAAA,OAAE,KAAK,CAAC,WAAW;IAAA;IAAA,IAC9B,KAAK;MAAA,OAAE,KAAK,CAAC,KAAK;IAAA;IAAA,IAClB,QAAQ;MAAA,OAAE,KAAK,CAAC,QAAQ;IAAA;IAAA,IACxB,QAAQ;MAAA,OAAE,KAAK,CAAC,QAAQ;IAAA;IAAA;MAAA,4DAMT,KAAK,CAAC,MAAM,IAAI,MAAM,gDACtB,KAAK,CAAC,MAAM,GAAG,MAAM,YAAG,SAAS,+CAClC,KAAK,CAAC,KAAK,YAAG,SAAS,mBAAG,KAAK,CAAC,YAAY,CAAC,oDACxC,KAAK,CAAC,KAAK,YAAG,IAAI,CAAC,OAAO,mBAAG,SAAS,8DACrC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,kDAChC,KAAK,CAAC,QAAQ,GAAG,MAAM,YAAG,SAAS,4CAEjD,GAAG;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,OAAO;QAAA;QAAA,UACrB,CAAC,MAAM,EAAE,KAAK,mDAKG,cAAK,CAAC,CAAC,qBAAK,MAAM,CAAC,KAAK,4CAC5B,KAAK,CAAC,QAAQ,qCACd,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,mBAUxC,MAAM,CAAC,MAAM,YAGyB,MAAM,CAAC,KAAK,GAClD,KAAK,CAAC,MAAM,KAAK,KAAK,4BAA4C,MAAM,CAAC,MAAM,IAAI,EAAE,EAAQ;MAGnG;IAAA;EAAA;AAKX","ignoreList":[]}
@@ -0,0 +1,60 @@
1
+ import { ssrStyleProperty as _$ssrStyleProperty } from "solid-js/web";
2
+ import { ssr as _$ssr } from "solid-js/web";
3
+ import { createComponent as _$createComponent } from "solid-js/web";
4
+ import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
5
+ import { escape as _$escape } from "solid-js/web";
6
+ var _tmpl$ = ["<div class=\"k2b-color-choices__group\" role=\"radiogroup\"", ">", "</div>"],
7
+ _tmpl$2 = ["<button type=\"button\" role=\"radio\" class=\"k2b-color-choices__swatch\" style=\"", "\"", "", "><i class=\"ti ti-check\" aria-hidden=\"true\"></i></button>"];
8
+ import { For } from "solid-js";
9
+ import { createFieldMeta, Field, fieldDescribedBy } from "../internal/field";
10
+ import { radioKeyTarget } from "../internal/radio-keys";
11
+ import { resolveMaybeAccessor } from "./field-contract";
12
+ /**
13
+ * A labeled single choice from a fixed palette of named colours, shown as round swatches. Use `ColorInput` when any
14
+ * colour is allowed.
15
+ */
16
+ export function ColorChoices(props) {
17
+ const meta = createFieldMeta(props.id);
18
+ let group;
19
+ const value = () => resolveMaybeAccessor(props.value) ?? null;
20
+ const tabStop = (option, index) => value() === option.value || index === 0 && !props.options.some(candidate => candidate.value === value());
21
+ const choose = (index, focus = false) => {
22
+ const option = props.options[index];
23
+ if (!option || props.disabled) return;
24
+ props.onValueChange?.(option.value);
25
+ props.onValueCommit?.(option.value);
26
+ // The radios in their current DOM order: options may have been reordered since they rendered.
27
+ if (focus) queueMicrotask(() => group?.querySelectorAll('[role="radio"]')[index]?.focus());
28
+ };
29
+ return _$createComponent(Field, {
30
+ meta: meta,
31
+ labelFor: false,
32
+ get ["class"]() {
33
+ return props.class;
34
+ },
35
+ get label() {
36
+ return props.label;
37
+ },
38
+ get description() {
39
+ return props.description;
40
+ },
41
+ get error() {
42
+ return props.error;
43
+ },
44
+ get required() {
45
+ return props.required;
46
+ },
47
+ get disabled() {
48
+ return props.disabled;
49
+ },
50
+ get children() {
51
+ return _$ssr(_tmpl$, _$ssrAttribute("aria-label", props.label ? _$escape(undefined, true) : _$escape(props["aria-label"], true), false) + _$ssrAttribute("aria-labelledby", props.label ? _$escape(meta.labelId, true) : _$escape(undefined, true), false) + _$ssrAttribute("aria-describedby", _$escape(fieldDescribedBy(meta, props), true), false) + _$ssrAttribute("aria-disabled", props.disabled ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(For, {
52
+ get each() {
53
+ return props.options;
54
+ },
55
+ children: (option, index) => _$ssr(_tmpl$2, _$ssrStyleProperty("--k2b-color-choice:", _$escape(option.color, true)), _$ssrAttribute("aria-checked", _$escape(value(), true) === _$escape(option.value, true), false) + _$ssrAttribute("aria-label", _$escape(option.label, true), false) + _$ssrAttribute("title", _$escape(option.label, true), false), _$ssrAttribute("disabled", props.disabled, true) + _$ssrAttribute("tabindex", tabStop(option, index()) ? 0 : -1, false))
56
+ })));
57
+ }
58
+ });
59
+ }
60
+ //# sourceMappingURL=ColorChoices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["inputs/ColorChoices.tsx"],"sourcesContent":["import { For, type JSX } from \"solid-js\";\nimport { createFieldMeta, Field, fieldDescribedBy } from \"../internal/field\";\nimport { radioKeyTarget } from \"../internal/radio-keys\";\nimport type { ValueFieldProps } from \"./field-contract\";\nimport { resolveMaybeAccessor } from \"./field-contract\";\n\nexport type ColorChoiceOption<T extends string = string> = {\n value: T;\n /** The colour's name; screen readers and the tooltip use it, so colour is never the only signal. */\n label: string;\n /** Any CSS colour. */\n color: string;\n};\n\nexport type ColorChoicesProps<T extends string = string> = Omit<ValueFieldProps<T | null>, \"onValueChange\" | \"onValueCommit\"> & {\n options: readonly ColorChoiceOption<T>[];\n onValueChange?: (value: T) => void;\n onValueCommit?: (value: T) => void;\n};\n\n/**\n * A labeled single choice from a fixed palette of named colours, shown as round swatches. Use `ColorInput` when any\n * colour is allowed.\n */\nexport function ColorChoices<T extends string = string>(props: ColorChoicesProps<T>): JSX.Element {\n const meta = createFieldMeta(props.id);\n let group: HTMLDivElement | undefined;\n const value = () => resolveMaybeAccessor(props.value) ?? null;\n const tabStop = (option: ColorChoiceOption<T>, index: number) =>\n value() === option.value || (index === 0 && !props.options.some((candidate) => candidate.value === value()));\n const choose = (index: number, focus = false) => {\n const option = props.options[index];\n if (!option || props.disabled) return;\n props.onValueChange?.(option.value);\n props.onValueCommit?.(option.value);\n // The radios in their current DOM order: options may have been reordered since they rendered.\n if (focus) queueMicrotask(() => group?.querySelectorAll<HTMLButtonElement>('[role=\"radio\"]')[index]?.focus());\n };\n return (\n <Field\n meta={meta}\n labelFor={false}\n class={props.class}\n label={props.label}\n description={props.description}\n error={props.error}\n required={props.required}\n disabled={props.disabled}\n >\n <div\n class=\"k2b-color-choices__group\"\n ref={group}\n role=\"radiogroup\"\n aria-label={props.label ? undefined : props[\"aria-label\"]}\n aria-labelledby={props.label ? meta.labelId : undefined}\n aria-describedby={fieldDescribedBy(meta, props)}\n aria-disabled={props.disabled ? \"true\" : undefined}\n >\n <For each={props.options}>\n {(option, index) => (\n <button\n type=\"button\"\n role=\"radio\"\n class=\"k2b-color-choices__swatch\"\n style={{ \"--k2b-color-choice\": option.color }}\n aria-checked={value() === option.value}\n aria-label={option.label}\n title={option.label}\n disabled={props.disabled}\n tabIndex={tabStop(option, index()) ? 0 : -1}\n onClick={() => choose(index())}\n onKeyDown={(event) => {\n const target = radioKeyTarget(event.key, index(), props.options.length);\n if (target === undefined) return;\n event.preventDefault();\n choose(target, true);\n }}\n >\n <i class=\"ti ti-check\" aria-hidden=\"true\" />\n </button>\n )}\n </For>\n </div>\n </Field>\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAS,GAAG,QAAkB,UAAU;AACxC,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,QAAQ,mBAAmB;AAC5E,SAAS,cAAc,QAAQ,wBAAwB;AAEvD,SAAS,oBAAoB,QAAQ,kBAAkB;AAgBvD;AACA;AACA;AACA;AACA,OAAO,SAAS,YAAY,CAA4B,KAA2B,EAAe;EAChG,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;EACtC,IAAI,KAAiC;EACrC,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI;EAC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KAAK,CAAC,kDAChC,KAAK,CAAC,QAAQ,GAAG,MAAM,YAAG,SAAS,4CAEjD,GAAG;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,OAAO;QAAA;QAAA,UACrB,CAAC,MAAM,EAAE,KAAK,uEAKoB,MAAM,CAAC,KAAK,yCAC7B,cAAK,CAAC,CAAC,qBAAK,MAAM,CAAC,KAAK,wDAC1B,MAAM,CAAC,KAAK,mDACjB,MAAM,CAAC,KAAK,4CACT,KAAK,CAAC,QAAQ,qCACd,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;MAW9C;IAAA;EAAA;AAKX","ignoreList":[]}
@@ -1,11 +1,13 @@
1
- import { createComponent as _$createComponent } from "solid-js/web";
2
1
  import { ssr as _$ssr } from "solid-js/web";
2
+ import { createComponent as _$createComponent } from "solid-js/web";
3
3
  import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
4
4
  import { escape as _$escape } from "solid-js/web";
5
5
  var _tmpl$ = ["<p class=\"k2b-qr-scanner__note\">", "</p>"],
6
- _tmpl$2 = ["<div", "><div class=\"k2b-qr-scanner__preview\"", "><video muted playsinline", "></video></div><p role=\"status\">", "</p>", "</div>"];
6
+ _tmpl$2 = ["<div", "><div class=\"k2b-qr-scanner__preview\"", "><video autoplay muted playsinline", "></video></div><p role=\"status\">", "</p>", "", "</div>"];
7
7
  import { timed } from "@k2b/stdlib/solid";
8
8
  import { createSignal, onCleanup, onMount, Show } from "solid-js";
9
+ import { Button } from "../actions/Button";
10
+ import { useUiMessages } from "../intl/messages";
9
11
  import { prefersReducedMotion } from "../motion";
10
12
  import { useQrMessages } from "./qr-messages";
11
13
 
@@ -87,6 +89,12 @@ const openCamera = async closed => {
87
89
  error
88
90
  };
89
91
  };
92
+
93
+ /**
94
+ * How long the camera may take to show its first picture. A working camera shows one well within a second; after three
95
+ * the person has looked at a black square long enough to need a way to start it again.
96
+ */
97
+ const firstPictureMs = 3000;
90
98
  const stopStream = stream => {
91
99
  for (const track of stream.getTracks()) track.stop();
92
100
  };
@@ -98,7 +106,9 @@ const stopStream = stream => {
98
106
  */
99
107
  export function QrScanner(props) {
100
108
  const qrMessages = useQrMessages();
109
+ const uiMessages = useUiMessages();
101
110
  const [starting, setStarting] = createSignal(true);
111
+ const [stalled, setStalled] = createSignal(false);
102
112
  const [invalid, setInvalid] = createSignal(false);
103
113
  let lastRejected;
104
114
  const resetRejected = timed.debounce(() => {
@@ -107,17 +117,21 @@ export function QrScanner(props) {
107
117
  const resetFeedback = timed.debounce(() => setInvalid(false), 1500);
108
118
  let video;
109
119
  let scanner;
120
+ let stream;
110
121
  let closed = false;
111
- let cleanupMotion;
122
+ const detach = [];
112
123
  const destroy = () => {
113
124
  closed = true;
114
- cleanupMotion?.();
125
+ for (const listener of detach.splice(0)) listener();
115
126
  resetRejected.cancel();
116
127
  resetFeedback.cancel();
117
- // pause(true) stops the camera stream immediately.
128
+ // pause(true) stops the camera stream immediately while the engine runs; a stream it never started stops here.
118
129
  void scanner?.pause(true);
119
130
  scanner?.destroy();
120
131
  scanner = undefined;
132
+ if (stream) stopStream(stream);
133
+ stream = undefined;
134
+ video.srcObject = null;
121
135
  };
122
136
  // Once closed, the host has unmounted the scanner or heard why it stopped; later failures stay silent.
123
137
  const fail = reason => {
@@ -125,6 +139,40 @@ export function QrScanner(props) {
125
139
  destroy();
126
140
  props.onError(reason);
127
141
  };
142
+ /**
143
+ * Waits for the camera picture. WebKit, above all in an installed web app, can leave a stream black: play() never
144
+ * settles or is refused. The scanner then offers to try again rather than wait in silence, and a picture that starts
145
+ * late still clears that offer.
146
+ */
147
+ let attempt = 0;
148
+ const show = async play => {
149
+ const current = ++attempt;
150
+ const latest = () => !closed && current === attempt;
151
+ setStalled(false);
152
+ const playing = play().then(() => video.videoWidth > 0, () => false);
153
+ let timer;
154
+ const shown = await Promise.race([playing, new Promise(resolve => {
155
+ timer = setTimeout(resolve, firstPictureMs, false);
156
+ })]);
157
+ clearTimeout(timer);
158
+ if (!latest()) return;
159
+ if (!shown) {
160
+ setStalled(true);
161
+ if (!(await playing) || !latest()) return;
162
+ }
163
+ setStalled(false);
164
+ setStarting(false);
165
+ };
166
+ /**
167
+ * Attaching the stream again restarts a player that stalled on it, and play() runs within the click, the gesture a
168
+ * refused play() may need. The engine already runs from its first start and scans from the play event it hears.
169
+ */
170
+ const retry = () => {
171
+ if (closed || !stream) return;
172
+ video.srcObject = null;
173
+ video.srcObject = stream;
174
+ void show(() => video.play());
175
+ };
128
176
  onMount(() => {
129
177
  const hidden = () => {
130
178
  if (document.visibilityState !== "visible") props.onStop();
@@ -182,21 +230,52 @@ export function QrScanner(props) {
182
230
  };
183
231
  applyMotion();
184
232
  motion.addEventListener("change", applyMotion);
185
- cleanupMotion = () => motion.removeEventListener("change", applyMotion);
233
+ detach.push(() => motion.removeEventListener("change", applyMotion));
234
+ // The engine places its scan region and frame on loadedmetadata, play, and a window resize. It misses a picture
235
+ // that turns, as when a tablet rotates, and a preview that changes size alone; replay loadedmetadata for both,
236
+ // or the region stays where the old picture had it and the frame sits off-centre.
237
+ const relayout = () => {
238
+ if (video.videoWidth > 0) video.dispatchEvent(new Event("loadedmetadata"));
239
+ };
240
+ video.addEventListener("resize", relayout);
241
+ const resized = new ResizeObserver(relayout);
242
+ resized.observe(video);
243
+ detach.push(() => {
244
+ video.removeEventListener("resize", relayout);
245
+ resized.disconnect();
246
+ });
186
247
  const camera = await openCamera(() => closed);
187
248
  if ("error" in camera) return fail(camera.error);
188
249
  if (closed) return stopStream(camera.stream);
189
250
  // qr-scanner plays a stream that is already set instead of opening its own.
190
- video.srcObject = camera.stream;
251
+ stream = camera.stream;
252
+ video.srcObject = stream;
191
253
  video.style.transform = camera.mirrored ? "scaleX(-1)" : "";
192
- await scanner.start();
193
- if (!closed) setStarting(false);
254
+ // start() awaits the engine's play() of this stream.
255
+ const engine = scanner;
256
+ await show(() => engine.start());
194
257
  } catch {
195
258
  fail("unavailable");
196
259
  }
197
260
  })();
198
261
  });
199
- return _$ssr(_tmpl$2, _$ssrAttribute("class", props.class ? `k2b-qr-scanner ${_$escape(props.class, true)}` : "k2b-qr-scanner", false), _$ssrAttribute("data-invalid", _$escape(invalid() || undefined, true), false), _$ssrAttribute("aria-label", _$escape(qrMessages().qrCameraPreview, true), false), starting() ? _$escape(qrMessages().qrCameraStarting) : _$escape(props.instructions ?? qrMessages().qrCameraInstructions), _$escape(_$createComponent(Show, {
262
+ return _$ssr(_tmpl$2, _$ssrAttribute("class", props.class ? `k2b-qr-scanner ${_$escape(props.class, true)}` : "k2b-qr-scanner", false), _$ssrAttribute("data-invalid", _$escape(invalid() || undefined, true), false), _$ssrAttribute("aria-label", _$escape(qrMessages().qrCameraPreview, true), false), stalled() ? _$escape(qrMessages().qrCameraStalled) : starting() ? _$escape(qrMessages().qrCameraStarting) : _$escape(props.instructions ?? qrMessages().qrCameraInstructions), _$escape(_$createComponent(Show, {
263
+ get when() {
264
+ return stalled();
265
+ },
266
+ get children() {
267
+ return _$createComponent(Button, {
268
+ type: "button",
269
+ size: "sm",
270
+ variant: "secondary",
271
+ "class": "k2b-qr-scanner__retry",
272
+ onClick: retry,
273
+ get children() {
274
+ return uiMessages().tryAgain;
275
+ }
276
+ });
277
+ }
278
+ })), _$escape(_$createComponent(Show, {
200
279
  get when() {
201
280
  return !starting();
202
281
  },
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["inputs/QrScanner.tsx"],"sourcesContent":["import { timed } from \"@k2b/stdlib/solid\";\nimport type QrScannerEngine from \"qr-scanner\";\nimport { createSignal, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { prefersReducedMotion } from \"../motion\";\nimport { useQrMessages } from \"./qr-messages\";\n\n/**\n * Why the scanner could not start, as far as the browser tells: `\"denied\"` when camera access is off, `\"no-camera\"`\n * when the device has no camera, `\"in-use\"` when the camera is busy or could not start, most often because another app\n * holds it, and `\"unavailable\"` for anything else, including a scanning engine that cannot load.\n */\nexport type QrScannerError = \"denied\" | \"no-camera\" | \"in-use\" | \"unavailable\";\n\nexport type QrScannerProps = {\n /** Decoded text is untrusted. Return `true` to accept it and stop the camera, `false` to reject it and keep scanning. */\n onResult: (text: string) => boolean;\n /** The page was hidden or left; unmount the scanner. */\n onStop: () => void;\n /**\n * The camera or the scanning engine could not start; the scanner has stopped. Offer another way in. A frame that\n * cannot be decoded never ends here.\n */\n onError: (reason: QrScannerError) => void;\n /** What to point the camera at. Defaults to a generic QR code hint. */\n instructions?: string;\n class?: string;\n};\n\nconst sizes: MediaTrackConstraints[] = [{ width: { min: 1024 } }, { width: { min: 768 } }, {}];\n/** The rear camera at a resolution that keeps small codes readable, then any camera: the order qr-scanner tries. */\nconst cameraRequests: MediaTrackConstraints[] = [...sizes.map((size) => ({ ...size, facingMode: { exact: \"environment\" } })), ...sizes];\n\nconst errorName = (error: unknown): string => (typeof error === \"object\" && error !== null && \"name\" in error ? String(error.name) : \"\");\n\nconst cameraFailure = (name: string): QrScannerError => {\n if (name === \"NotAllowedError\" || name === \"SecurityError\") return \"denied\";\n if (name === \"NotFoundError\" || name === \"OverconstrainedError\") return \"no-camera\";\n if (name === \"NotReadableError\") return \"in-use\";\n return \"unavailable\";\n};\n\n/** The facing a track reports, or else the one its label names, as qr-scanner reads it. */\nconst facingOf = (track: MediaStreamTrack | undefined): string | undefined => {\n if (!track) return undefined;\n const { facingMode } = track.getSettings();\n if (facingMode) return facingMode;\n if (/rear|back|environment/i.test(track.label)) return \"environment\";\n if (/front|user|face/i.test(track.label)) return \"user\";\n return undefined;\n};\n\n/**\n * Opens the camera here rather than in qr-scanner, which turns every failure into \"Camera not found.\". A refusal ends\n * the search, because asking again could show the permission prompt again. Any other failure may belong to the request,\n * such as a camera that cannot start at the larger size, so the next, looser request follows, as in qr-scanner. When\n * none succeeds, a camera that exists but fails outweighs a request no camera could meet. A closed scanner asks no more.\n */\nconst openCamera = async (closed: () => boolean): Promise<{ stream: MediaStream; mirrored: boolean } | { error: QrScannerError }> => {\n if (!navigator.mediaDevices) return { error: \"unavailable\" };\n let error: QrScannerError = \"no-camera\";\n for (const video of cameraRequests) {\n if (closed()) break;\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ video, audio: false });\n const facing = facingOf(stream.getVideoTracks()[0]);\n // Like qr-scanner, mirror a front camera, and a camera of unknown facing that the rear request did not find.\n return { stream, mirrored: facing ? facing === \"user\" : !video.facingMode };\n } catch (failure) {\n const reason = cameraFailure(errorName(failure));\n if (reason === \"denied\") return { error: reason };\n if (reason !== \"no-camera\") error = reason;\n }\n }\n return { error };\n};\n\nconst stopStream = (stream: MediaStream) => {\n for (const track of stream.getTracks()) track.stop();\n};\n\n/**\n * Scans a QR code with the rear camera. Each mount owns exactly one camera session, which stops when the scanner\n * unmounts, the page is hidden, or a result is accepted. The scanning engine loads only when the scanner mounts.\n * Decoded content is never logged.\n */\nexport function QrScanner(props: QrScannerProps): JSX.Element {\n const qrMessages = useQrMessages();\n const [starting, setStarting] = createSignal(true);\n const [invalid, setInvalid] = createSignal(false);\n let lastRejected: string | undefined;\n const resetRejected = timed.debounce(() => {\n lastRejected = undefined;\n }, 1000);\n const resetFeedback = timed.debounce(() => setInvalid(false), 1500);\n let video!: HTMLVideoElement;\n let scanner: QrScannerEngine | undefined;\n let closed = false;\n let cleanupMotion: (() => void) | undefined;\n const destroy = () => {\n closed = true;\n cleanupMotion?.();\n resetRejected.cancel();\n resetFeedback.cancel();\n // pause(true) stops the camera stream immediately.\n void scanner?.pause(true);\n scanner?.destroy();\n scanner = undefined;\n };\n // Once closed, the host has unmounted the scanner or heard why it stopped; later failures stay silent.\n const fail = (reason: QrScannerError) => {\n if (closed) return;\n destroy();\n props.onError(reason);\n };\n onMount(() => {\n const hidden = () => {\n if (document.visibilityState !== \"visible\") props.onStop();\n };\n const leaving = () => props.onStop();\n document.addEventListener(\"visibilitychange\", hidden);\n window.addEventListener(\"pagehide\", leaving);\n onCleanup(() => {\n destroy();\n document.removeEventListener(\"visibilitychange\", hidden);\n window.removeEventListener(\"pagehide\", leaving);\n });\n void (async () => {\n try {\n const { default: Engine } = await import(\"qr-scanner\");\n if (closed || document.visibilityState !== \"visible\") return;\n scanner = new Engine(\n video,\n (result) => {\n if (closed) return;\n // Rearm only after a full second without a decoded QR, not between individual frames.\n resetRejected.debouncedFn();\n if (result.data === lastRejected) return;\n if (props.onResult(result.data)) {\n destroy();\n return;\n }\n lastRejected = result.data;\n setInvalid(true);\n resetFeedback.debouncedFn();\n },\n {\n highlightScanRegion: true,\n // A frame that cannot be decoded never ends the session: the camera runs, and the next frame may read.\n // An engine error other than an empty frame, which the native BarcodeDetector reports as \"Scanner error:\n // No QR code found\", means the detector cannot read on this device. Fall back to the bundled worker for\n // the page through the flag qr-scanner 1.4.2 sets itself for \"not implemented\" and \"service unavailable\";\n // it swaps engines after this frame. Worker errors carry the same prefix; the flag changes nothing there.\n // qr-scanner reports frames only as strings: an Error means the engine itself did not load, such as a\n // decoder chunk gone after a deploy or a worker that cannot start, and no later frame can read. Never log\n // decoded content or frame data.\n onDecodeError: (error) => {\n if (typeof error !== \"string\") return fail(\"unavailable\");\n if (error.startsWith(\"Scanner error: \") && !error.endsWith(Engine.NO_QR_CODE_FOUND)) {\n Reflect.set(Engine, \"_disableBarcodeDetector\", true);\n }\n },\n },\n );\n const motion = matchMedia(\"(prefers-reduced-motion: reduce)\");\n const applyMotion = () => {\n for (const animation of scanner?.$overlay?.getAnimations({ subtree: true }) ?? []) {\n if (prefersReducedMotion()) animation.pause();\n else animation.play();\n }\n };\n applyMotion();\n motion.addEventListener(\"change\", applyMotion);\n cleanupMotion = () => motion.removeEventListener(\"change\", applyMotion);\n const camera = await openCamera(() => closed);\n if (\"error\" in camera) return fail(camera.error);\n if (closed) return stopStream(camera.stream);\n // qr-scanner plays a stream that is already set instead of opening its own.\n video.srcObject = camera.stream;\n video.style.transform = camera.mirrored ? \"scaleX(-1)\" : \"\";\n await scanner.start();\n if (!closed) setStarting(false);\n } catch {\n fail(\"unavailable\");\n }\n })();\n });\n return (\n <div class={props.class ? `k2b-qr-scanner ${props.class}` : \"k2b-qr-scanner\"}>\n <div class=\"k2b-qr-scanner__preview\" data-invalid={invalid() || undefined}>\n {/* Live camera preview contains no prerecorded speech or audio. */}\n <video ref={video} muted playsinline aria-label={qrMessages().qrCameraPreview} />\n </div>\n <p role=\"status\">{starting() ? qrMessages().qrCameraStarting : (props.instructions ?? qrMessages().qrCameraInstructions)}</p>\n <Show when={!starting()}>\n <p class=\"k2b-qr-scanner__note\">{qrMessages().qrCameraPrivacy}</p>\n </Show>\n </div>\n );\n}\n\nexport default QrScanner;\n"],"mappings":";;;;;;AAAA,SAAS,KAAK,QAAQ,mBAAmB;AAEzC,SAAS,YAAY,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AAC3E,SAAS,oBAAoB,QAAQ,WAAW;AAChD,SAAS,aAAa,QAAQ,eAAe;;AAE7C;AACA;AACA;AACA;AACA;;AAkBA,MAAM,KAA8B,GAAG,CAAC;EAAE,KAAK,EAAE;IAAE,GAAG,EAAE;EAAK;AAAE,CAAC,EAAE;EAAE,KAAK,EAAE;IAAE,GAAG,EAAE;EAAI;AAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9F;AACA,MAAM,cAAuC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAE,IAAI,KAAM;EAAE,GAAG,IAAI;EAAE,UAAU,EAAE;IAAE,KAAK,EAAE;EAAc;AAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC;AAEvI,MAAM,SAAS,GAAI,KAAc,IAAc,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAG;AAExI,MAAM,aAAa,GAAI,IAAY,IAAqB;EACtD,IAAI,IAAI,KAAK,iBAAiB,IAAI,IAAI,KAAK,eAAe,EAAE,OAAO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AAK,CAAC;MACjC,CAAC,CAAC,MAAM;QACN,IAAI,CAAC,aAAa,CAAC;MACrB;IACF,CAAC,EAAE,CAAC;EACN,CAAC,CAAC;EACF,8CACc,KAAK,CAAC,KAAK,GAAG,2BAAkB,KAAK,CAAC,KAAK,SAAE,GAAG,gBAAgB,kDACvB,OAAO,CAAC,CAAC,IAAI,SAAS,uDAEtB,UAAU,CAAC,CAAC,CAAC,eAAe,iBAE7D,QAAQ,CAAC,CAAC,YAAG,UAAU,CAAC,CAAC,CAAC,gBAAgB,aAAI,KAAK,CAAC,YAAY,IAAI,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,6BACvH,IAAI;IAAA,IAAC,IAAI;MAAA,OAAE,CAAC,QAAQ,CAAC,CAAC;IAAA;IAAA;MAAA,8BACY,UAAU,CAAC,CAAC,CAAC,eAAe;IAAA;EAAA;AAIrE;AAEA,eAAe,SAAS","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["inputs/QrScanner.tsx"],"sourcesContent":["import { timed } from \"@k2b/stdlib/solid\";\nimport type QrScannerEngine from \"qr-scanner\";\nimport { createSignal, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { Button } from \"../actions/Button\";\nimport { useUiMessages } from \"../intl/messages\";\nimport { prefersReducedMotion } from \"../motion\";\nimport { useQrMessages } from \"./qr-messages\";\n\n/**\n * Why the scanner could not start, as far as the browser tells: `\"denied\"` when camera access is off, `\"no-camera\"`\n * when the device has no camera, `\"in-use\"` when the camera is busy or could not start, most often because another app\n * holds it, and `\"unavailable\"` for anything else, including a scanning engine that cannot load.\n */\nexport type QrScannerError = \"denied\" | \"no-camera\" | \"in-use\" | \"unavailable\";\n\nexport type QrScannerProps = {\n /** Decoded text is untrusted. Return `true` to accept it and stop the camera, `false` to reject it and keep scanning. */\n onResult: (text: string) => boolean;\n /** The page was hidden or left; unmount the scanner. */\n onStop: () => void;\n /**\n * The camera or the scanning engine could not start; the scanner has stopped. Offer another way in. A frame that\n * cannot be decoded never ends here.\n */\n onError: (reason: QrScannerError) => void;\n /** What to point the camera at. Defaults to a generic QR code hint. */\n instructions?: string;\n class?: string;\n};\n\nconst sizes: MediaTrackConstraints[] = [{ width: { min: 1024 } }, { width: { min: 768 } }, {}];\n/** The rear camera at a resolution that keeps small codes readable, then any camera: the order qr-scanner tries. */\nconst cameraRequests: MediaTrackConstraints[] = [...sizes.map((size) => ({ ...size, facingMode: { exact: \"environment\" } })), ...sizes];\n\nconst errorName = (error: unknown): string => (typeof error === \"object\" && error !== null && \"name\" in error ? String(error.name) : \"\");\n\nconst cameraFailure = (name: string): QrScannerError => {\n if (name === \"NotAllowedError\" || name === \"SecurityError\") return \"denied\";\n if (name === \"NotFoundError\" || name === \"OverconstrainedError\") return \"no-camera\";\n if (name === \"NotReadableError\") return \"in-use\";\n return \"unavailable\";\n};\n\n/** The facing a track reports, or else the one its label names, as qr-scanner reads it. */\nconst facingOf = (track: MediaStreamTrack | undefined): string | undefined => {\n if (!track) return undefined;\n const { facingMode } = track.getSettings();\n if (facingMode) return facingMode;\n if (/rear|back|environment/i.test(track.label)) return \"environment\";\n if (/front|user|face/i.test(track.label)) return \"user\";\n return undefined;\n};\n\n/**\n * Opens the camera here rather than in qr-scanner, which turns every failure into \"Camera not found.\". A refusal ends\n * the search, because asking again could show the permission prompt again. Any other failure may belong to the request,\n * such as a camera that cannot start at the larger size, so the next, looser request follows, as in qr-scanner. When\n * none succeeds, a camera that exists but fails outweighs a request no camera could meet. A closed scanner asks no more.\n */\nconst openCamera = async (closed: () => boolean): Promise<{ stream: MediaStream; mirrored: boolean } | { error: QrScannerError }> => {\n if (!navigator.mediaDevices) return { error: \"unavailable\" };\n let error: QrScannerError = \"no-camera\";\n for (const video of cameraRequests) {\n if (closed()) break;\n try {\n const stream = await navigator.mediaDevices.getUserMedia({ video, audio: false });\n const facing = facingOf(stream.getVideoTracks()[0]);\n // Like qr-scanner, mirror a front camera, and a camera of unknown facing that the rear request did not find.\n return { stream, mirrored: facing ? facing === \"user\" : !video.facingMode };\n } catch (failure) {\n const reason = cameraFailure(errorName(failure));\n if (reason === \"denied\") return { error: reason };\n if (reason !== \"no-camera\") error = reason;\n }\n }\n return { error };\n};\n\n/**\n * How long the camera may take to show its first picture. A working camera shows one well within a second; after three\n * the person has looked at a black square long enough to need a way to start it again.\n */\nconst firstPictureMs = 3000;\n\nconst stopStream = (stream: MediaStream) => {\n for (const track of stream.getTracks()) track.stop();\n};\n\n/**\n * Scans a QR code with the rear camera. Each mount owns exactly one camera session, which stops when the scanner\n * unmounts, the page is hidden, or a result is accepted. The scanning engine loads only when the scanner mounts.\n * Decoded content is never logged.\n */\nexport function QrScanner(props: QrScannerProps): JSX.Element {\n const qrMessages = useQrMessages();\n const uiMessages = useUiMessages();\n const [starting, setStarting] = createSignal(true);\n const [stalled, setStalled] = createSignal(false);\n const [invalid, setInvalid] = createSignal(false);\n let lastRejected: string | undefined;\n const resetRejected = timed.debounce(() => {\n lastRejected = undefined;\n }, 1000);\n const resetFeedback = timed.debounce(() => setInvalid(false), 1500);\n let video!: HTMLVideoElement;\n let scanner: QrScannerEngine | undefined;\n let stream: MediaStream | undefined;\n let closed = false;\n const detach: (() => void)[] = [];\n const destroy = () => {\n closed = true;\n for (const listener of detach.splice(0)) listener();\n resetRejected.cancel();\n resetFeedback.cancel();\n // pause(true) stops the camera stream immediately while the engine runs; a stream it never started stops here.\n void scanner?.pause(true);\n scanner?.destroy();\n scanner = undefined;\n if (stream) stopStream(stream);\n stream = undefined;\n video.srcObject = null;\n };\n // Once closed, the host has unmounted the scanner or heard why it stopped; later failures stay silent.\n const fail = (reason: QrScannerError) => {\n if (closed) return;\n destroy();\n props.onError(reason);\n };\n /**\n * Waits for the camera picture. WebKit, above all in an installed web app, can leave a stream black: play() never\n * settles or is refused. The scanner then offers to try again rather than wait in silence, and a picture that starts\n * late still clears that offer.\n */\n let attempt = 0;\n const show = async (play: () => Promise<void>) => {\n const current = ++attempt;\n const latest = () => !closed && current === attempt;\n setStalled(false);\n const playing = play().then(\n () => video.videoWidth > 0,\n () => false,\n );\n let timer: ReturnType<typeof setTimeout> | undefined;\n const shown = await Promise.race([\n playing,\n new Promise<false>((resolve) => {\n timer = setTimeout(resolve, firstPictureMs, false);\n }),\n ]);\n clearTimeout(timer);\n if (!latest()) return;\n if (!shown) {\n setStalled(true);\n if (!(await playing) || !latest()) return;\n }\n setStalled(false);\n setStarting(false);\n };\n /**\n * Attaching the stream again restarts a player that stalled on it, and play() runs within the click, the gesture a\n * refused play() may need. The engine already runs from its first start and scans from the play event it hears.\n */\n const retry = () => {\n if (closed || !stream) return;\n video.srcObject = null;\n video.srcObject = stream;\n void show(() => video.play());\n };\n onMount(() => {\n const hidden = () => {\n if (document.visibilityState !== \"visible\") props.onStop();\n };\n const leaving = () => props.onStop();\n document.addEventListener(\"visibilitychange\", hidden);\n window.addEventListener(\"pagehide\", leaving);\n onCleanup(() => {\n destroy();\n document.removeEventListener(\"visibilitychange\", hidden);\n window.removeEventListener(\"pagehide\", leaving);\n });\n void (async () => {\n try {\n const { default: Engine } = await import(\"qr-scanner\");\n if (closed || document.visibilityState !== \"visible\") return;\n scanner = new Engine(\n video,\n (result) => {\n if (closed) return;\n // Rearm only after a full second without a decoded QR, not between individual frames.\n resetRejected.debouncedFn();\n if (result.data === lastRejected) return;\n if (props.onResult(result.data)) {\n destroy();\n return;\n }\n lastRejected = result.data;\n setInvalid(true);\n resetFeedback.debouncedFn();\n },\n {\n highlightScanRegion: true,\n // A frame that cannot be decoded never ends the session: the camera runs, and the next frame may read.\n // An engine error other than an empty frame, which the native BarcodeDetector reports as \"Scanner error:\n // No QR code found\", means the detector cannot read on this device. Fall back to the bundled worker for\n // the page through the flag qr-scanner 1.4.2 sets itself for \"not implemented\" and \"service unavailable\";\n // it swaps engines after this frame. Worker errors carry the same prefix; the flag changes nothing there.\n // qr-scanner reports frames only as strings: an Error means the engine itself did not load, such as a\n // decoder chunk gone after a deploy or a worker that cannot start, and no later frame can read. Never log\n // decoded content or frame data.\n onDecodeError: (error) => {\n if (typeof error !== \"string\") return fail(\"unavailable\");\n if (error.startsWith(\"Scanner error: \") && !error.endsWith(Engine.NO_QR_CODE_FOUND)) {\n Reflect.set(Engine, \"_disableBarcodeDetector\", true);\n }\n },\n },\n );\n const motion = matchMedia(\"(prefers-reduced-motion: reduce)\");\n const applyMotion = () => {\n for (const animation of scanner?.$overlay?.getAnimations({ subtree: true }) ?? []) {\n if (prefersReducedMotion()) animation.pause();\n else animation.play();\n }\n };\n applyMotion();\n motion.addEventListener(\"change\", applyMotion);\n detach.push(() => motion.removeEventListener(\"change\", applyMotion));\n // The engine places its scan region and frame on loadedmetadata, play, and a window resize. It misses a picture\n // that turns, as when a tablet rotates, and a preview that changes size alone; replay loadedmetadata for both,\n // or the region stays where the old picture had it and the frame sits off-centre.\n const relayout = () => {\n if (video.videoWidth > 0) video.dispatchEvent(new Event(\"loadedmetadata\"));\n };\n video.addEventListener(\"resize\", relayout);\n const resized = new ResizeObserver(relayout);\n resized.observe(video);\n detach.push(() => {\n video.removeEventListener(\"resize\", relayout);\n resized.disconnect();\n });\n const camera = await openCamera(() => closed);\n if (\"error\" in camera) return fail(camera.error);\n if (closed) return stopStream(camera.stream);\n // qr-scanner plays a stream that is already set instead of opening its own.\n stream = camera.stream;\n video.srcObject = stream;\n video.style.transform = camera.mirrored ? \"scaleX(-1)\" : \"\";\n // start() awaits the engine's play() of this stream.\n const engine = scanner;\n await show(() => engine.start());\n } catch {\n fail(\"unavailable\");\n }\n })();\n });\n return (\n <div class={props.class ? `k2b-qr-scanner ${props.class}` : \"k2b-qr-scanner\"}>\n <div class=\"k2b-qr-scanner__preview\" data-invalid={invalid() || undefined}>\n {/* Live camera preview contains no prerecorded speech or audio. */}\n <video ref={video} autoplay muted playsinline aria-label={qrMessages().qrCameraPreview} />\n </div>\n <p role=\"status\">\n {stalled()\n ? qrMessages().qrCameraStalled\n : starting()\n ? qrMessages().qrCameraStarting\n : (props.instructions ?? qrMessages().qrCameraInstructions)}\n </p>\n <Show when={stalled()}>\n <Button type=\"button\" size=\"sm\" variant=\"secondary\" class=\"k2b-qr-scanner__retry\" onClick={retry}>\n {uiMessages().tryAgain}\n </Button>\n </Show>\n <Show when={!starting()}>\n <p class=\"k2b-qr-scanner__note\">{qrMessages().qrCameraPrivacy}</p>\n </Show>\n </div>\n );\n}\n\nexport default QrScanner;\n"],"mappings":";;;;;;AAAA,SAAS,KAAK,QAAQ,mBAAmB;AAEzC,SAAS,YAAY,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AAC3E,SAAS,MAAM,QAAQ,mBAAmB;AAC1C,SAAS,aAAa,QAAQ,kBAAkB;AAChD,SAAS,oBAAoB,QAAQ,WAAW;AAChD,SAAS,aAAa,QAAQ,eAAe;;AAE7C;AACA;AACA;AACA;AACA;;AAkBA,MAAM,KAA8B,GAAG,CAAC;EAAE,KAAK,EAAE;IAAE,GAAG,EAAE;EAAK;AAAE,CAAC,EAAE;EAAE,KAAK,EAAE;IAAE,GAAG,EAAE;EAAI;AAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9F;AACA,MAAM,cAAuC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAE,IAAI,KAAM;EAAE,GAAG,IAAI;EAAE,UAAU,EAAE;IAAE,KAAK,EAAE;EAAc;AAAE,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC;AAEvI,MAAM,SAAS,GAAI,KAAc,IAAc,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,IAAI,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAG;AAExI,MAAM,aAAa,GAAI,IAAY,IAAqB;EACtD,IAAI,IAAI,KAAK,iBAAiB,IAAI,IAAI,KAAK,eAAe,EAAE,OAAO,QAAQ;EAC3E,IAAI,IAAI,KAAK,eAAe,IAAI,IAAI,KAAK,sBAAsB,EAAE,OAAO,WAAW;EACn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,IAAI;QAAM,OAAO;QAAA;QAA2C,OAAO,EAAE,KAAK;QAAA;UAAA,OAC7F,UAAU,CAAC,CAAC,CAAC,QAAQ;QAAA;MAAA;IAAA;EAAA,gCAGzB,IAAI;IAAA,IAAC,IAAI;MAAA,OAAE,CAAC,QAAQ,CAAC,CAAC;IAAA;IAAA;MAAA,8BACY,UAAU,CAAC,CAAC,CAAC,eAAe;IAAA;EAAA;AAIrE;AAEA,eAAe,SAAS","ignoreList":[]}
@@ -21,7 +21,7 @@ import { MarkdownEditor } from "./markdown/MarkdownEditor";
21
21
  export function TextInput(props) {
22
22
  const messages = useUiMessages();
23
23
  const inputMessages = useInputMessages();
24
- const [local, rest] = splitProps(props, ["activeIcon", "aria-describedby", "aria-label", "class", "clearLabel", "clearable", "completions", "description", "error", "externalErrorId", "icon", "id", "label", "lines", "markdown", "minLength", "maxLength", "monospace", "multiline", "onClear", "onValueCommit", "onSubmit", "onValueChange", "password", "prefix", "required", "suffix", "type", "value", "variant", "abbreviations"]);
24
+ const [local, rest] = splitProps(props, ["activeIcon", "aria-describedby", "aria-label", "class", "clearLabel", "clearable", "completions", "description", "error", "externalErrorId", "icon", "id", "label", "lines", "markdown", "minLength", "maxLength", "onKeyDown", "monospace", "multiline", "onClear", "onValueCommit", "onSubmit", "onValueChange", "password", "prefix", "required", "suffix", "type", "value", "variant", "abbreviations"]);
25
25
  const meta = createFieldMeta(local.id);
26
26
  const value = () => resolveMaybeAccessor(local.value) ?? "";
27
27
  const error = () => resolveMaybeAccessor(local.error);
@@ -46,6 +46,18 @@ export function TextInput(props) {
46
46
  const verbatim = () => local.password || local.type === "email" || local.type === "url" || /\b(username|email|url)\b/.test(String(rest.autocomplete ?? ""));
47
47
  const input = next => local.onValueChange?.(next);
48
48
  const commit = next => local.onValueCommit?.(next);
49
+ const submitOnEnter = event => {
50
+ if (local.onSubmit && event.key === "Enter" && !event.shiftKey && !event.metaKey) {
51
+ event.preventDefault();
52
+ local.onSubmit();
53
+ }
54
+ };
55
+ /** The caller's key handler runs first; Enter submits unless it handled the key. */
56
+ const keyDown = event => {
57
+ const handler = local.onKeyDown;
58
+ if (typeof handler === "function") handler(event);else if (Array.isArray(handler)) handler[0](handler[1], event);
59
+ if (!event.defaultPrevented) submitOnEnter(event);
60
+ };
49
61
  const clear = event => {
50
62
  // Clearing removes the button. Return to the field before notifying the caller, whose handler
51
63
  // may deliberately navigate or move focus somewhere else.
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["inputs/TextInput.tsx"],"sourcesContent":["import { createSignal, type JSX, Show, splitProps } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { createFieldMeta, Field, fieldControlAria } from \"../internal/field\";\nimport { useUiMessages } from \"../intl/messages\";\nimport type { Completion } from \"./completion\";\nimport type { ValueFieldProps } from \"./field-contract\";\nimport { commitFieldValue, resolveMaybeAccessor } from \"./field-contract\";\nimport { useInputMessages } from \"./input-messages\";\nimport { MarkdownEditor } from \"./markdown/MarkdownEditor\";\n\nexport type TextInputProps = Omit<\n JSX.InputHTMLAttributes<HTMLInputElement>,\n \"onChange\" | \"onInput\" | \"prefix\" | \"suffix\" | \"type\" | \"value\" | keyof ValueFieldProps<string>\n> &\n ValueFieldProps<string> & {\n minLength?: number;\n maxLength?: number;\n type?: \"text\" | \"search\" | \"email\" | \"url\" | \"tel\";\n variant?: \"default\" | \"ai\" | \"compact\";\n /** Set false for a plain field without a leading icon. */\n icon?: string | false;\n activeIcon?: string;\n /** ID of a consumer-owned visible error; caller owns its announcement. Native controls only. */\n externalErrorId?: string;\n prefix?: JSX.Element;\n suffix?: JSX.Element;\n clearable?: boolean;\n onClear?: () => void;\n clearLabel?: string;\n multiline?: boolean;\n monospace?: boolean;\n password?: boolean;\n markdown?: boolean;\n onSubmit?: () => void;\n lines?: number;\n abbreviations?: Record<string, string>;\n completions?: readonly Completion[];\n };\n\nexport function TextInput(props: TextInputProps): JSX.Element {\n const messages = useUiMessages();\n const inputMessages = useInputMessages();\n const [local, rest] = splitProps(props, [\n \"activeIcon\",\n \"aria-describedby\",\n \"aria-label\",\n \"class\",\n \"clearLabel\",\n \"clearable\",\n \"completions\",\n \"description\",\n \"error\",\n \"externalErrorId\",\n \"icon\",\n \"id\",\n \"label\",\n \"lines\",\n \"markdown\",\n \"minLength\",\n \"maxLength\",\n \"monospace\",\n \"multiline\",\n \"onClear\",\n \"onValueCommit\",\n \"onSubmit\",\n \"onValueChange\",\n \"password\",\n \"prefix\",\n \"required\",\n \"suffix\",\n \"type\",\n \"value\",\n \"variant\",\n \"abbreviations\",\n ]);\n const meta = createFieldMeta(local.id);\n const value = () => resolveMaybeAccessor(local.value) ?? \"\";\n const error = () => resolveMaybeAccessor(local.error);\n // HTML IDs are single nonempty tokens; numeric starts and punctuation are valid.\n const externalErrorId = () => {\n const id = local.externalErrorId;\n return id && !/[\\t\\n\\f\\r ]/.test(id) ? id : undefined;\n };\n const controlMeta = {\n ...meta,\n get errorId() {\n return externalErrorId() ?? meta.errorId;\n },\n };\n const [passwordVisible, setPasswordVisible] = createSignal(false);\n const multiline = () => Boolean(local.multiline || local.markdown);\n const compact = () => local.variant === \"compact\";\n const icon = () =>\n local.icon === false\n ? \"\"\n : (local.icon ?? (local.variant === \"ai\" ? \"ti ti-sparkles\" : local.markdown ? \"ti ti-markdown\" : \"ti ti-cursor-text\"));\n // A custom icon stays while typing (a search field keeps its magnifier); only the default icon switches to the pencil.\n const activeIcon = () => local.activeIcon ?? (local.icon || undefined) ?? (local.variant === \"ai\" ? \"ti ti-sparkles\" : \"ti ti-pencil\");\n // Names, addresses and passwords are typed exactly: phone keyboards must not capitalize or \"correct\" them.\n const verbatim = () =>\n local.password || local.type === \"email\" || local.type === \"url\" || /\\b(username|email|url)\\b/.test(String(rest.autocomplete ?? \"\"));\n const input = (next: string) => local.onValueChange?.(next);\n const commit = (next: string) => local.onValueCommit?.(next);\n const clear: JSX.EventHandler<HTMLButtonElement, MouseEvent> = (event) => {\n // Clearing removes the button. Return to the field before notifying the caller, whose handler\n // may deliberately navigate or move focus somewhere else.\n event.currentTarget.ownerDocument.getElementById(meta.controlId)?.focus();\n if (local.onClear) {\n local.onClear();\n return;\n }\n commitFieldValue(local, \"\");\n };\n\n return (\n <Show\n when={local.markdown}\n fallback={\n <Field\n class={local.class}\n label={local.label}\n description={local.description}\n error={externalErrorId() ? undefined : error()}\n meta={meta}\n required={local.required}\n disabled={rest.disabled}\n >\n <div\n class=\"k2b-input-shell k2b-text-input\"\n data-variant={compact() ? \"compact\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n data-ai={local.variant === \"ai\" ? \"true\" : undefined}\n data-multiline={multiline() ? \"true\" : undefined}\n data-monospace={local.monospace ? \"true\" : undefined}\n style={multiline() ? { \"--k2b-editor-lines\": String(local.lines ?? 3) } : undefined}\n >\n <Show when={!compact() && local.icon !== false}>\n <span class=\"k2b-input-shell__icon k2b-text-input__icon\" aria-hidden=\"true\">\n <i class={icon()} />\n <i class={activeIcon()} />\n </span>\n </Show>\n <Show when={local.prefix}>\n <span class=\"k2b-input-shell__affix\">{local.prefix}</span>\n </Show>\n <Show\n when={multiline()}\n fallback={\n <input\n autocapitalize={verbatim() ? \"none\" : undefined}\n autocorrect={verbatim() ? \"off\" : undefined}\n spellcheck={verbatim() ? false : undefined}\n {...rest}\n id={meta.controlId}\n class=\"k2b-input\"\n size={rest.size ?? (compact() ? 9 : undefined)}\n type={local.password && !passwordVisible() ? \"password\" : (local.type ?? \"text\")}\n value={value()}\n minlength={local.minLength}\n maxlength={local.maxLength}\n required={local.required}\n {...fieldControlAria(controlMeta, local)}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={(event) => {\n if (local.onSubmit && event.key === \"Enter\" && !event.shiftKey && !event.metaKey) {\n event.preventDefault();\n local.onSubmit();\n }\n }}\n />\n }\n >\n <textarea\n {...(rest as unknown as JSX.TextareaHTMLAttributes<HTMLTextAreaElement>)}\n id={meta.controlId}\n class=\"k2b-input k2b-text-input__textarea\"\n value={value()}\n rows={local.lines ?? 3}\n required={local.required}\n minlength={local.minLength}\n maxlength={local.maxLength}\n {...fieldControlAria(controlMeta, local)}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={(event) => {\n if (local.onSubmit && event.key === \"Enter\" && !event.shiftKey && !event.metaKey) {\n event.preventDefault();\n local.onSubmit();\n }\n }}\n >\n {/* HTML consumes one leading newline in textarea content. */}\n {isServer ? `\\n${value()}` : undefined}\n </textarea>\n </Show>\n <Show when={local.suffix}>\n <span class=\"k2b-input-shell__affix\">{local.suffix}</span>\n </Show>\n <Show when={local.clearable && value() && !multiline() && !local.password && !rest.disabled && !rest.readOnly}>\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear k2b-input-clear-action\"\n aria-label={local.clearLabel ?? messages().clear}\n onClick={clear}\n >\n <i class=\"ti ti-x\" aria-hidden=\"true\" />\n </button>\n </Show>\n <Show when={local.password && !multiline()}>\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear\"\n aria-label={passwordVisible() ? inputMessages().hidePassword : inputMessages().showPassword}\n aria-pressed={passwordVisible()}\n disabled={rest.disabled}\n onClick={() => setPasswordVisible((visible) => !visible)}\n >\n <i class={passwordVisible() ? \"ti ti-eye-off\" : \"ti ti-eye\"} aria-hidden=\"true\" />\n </button>\n </Show>\n </div>\n </Field>\n }\n >\n <MarkdownEditor\n class={local.class}\n label={local.label}\n description={local.description}\n error={error()}\n id={meta.controlId}\n name={rest.name}\n value={value()}\n onValueChange={input}\n onValueCommit={local.onValueCommit}\n onSubmit={local.onSubmit}\n placeholder={rest.placeholder}\n disabled={rest.disabled}\n required={local.required}\n lines={local.lines}\n maxLength={local.maxLength}\n spellcheck={rest.spellcheck === undefined ? undefined : rest.spellcheck === true || rest.spellcheck === \"true\"}\n abbreviations={local.abbreviations}\n completions={local.completions}\n aria-label={local[\"aria-label\"]}\n aria-describedby={local[\"aria-describedby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3,"names":[],"sources":["inputs/TextInput.tsx"],"sourcesContent":["import { createSignal, type JSX, Show, splitProps } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { createFieldMeta, Field, fieldControlAria } from \"../internal/field\";\nimport { useUiMessages } from \"../intl/messages\";\nimport type { Completion } from \"./completion\";\nimport type { ValueFieldProps } from \"./field-contract\";\nimport { commitFieldValue, resolveMaybeAccessor } from \"./field-contract\";\nimport { useInputMessages } from \"./input-messages\";\nimport { MarkdownEditor } from \"./markdown/MarkdownEditor\";\n\nexport type TextInputProps = Omit<\n JSX.InputHTMLAttributes<HTMLInputElement>,\n \"onChange\" | \"onInput\" | \"prefix\" | \"suffix\" | \"type\" | \"value\" | keyof ValueFieldProps<string>\n> &\n ValueFieldProps<string> & {\n minLength?: number;\n maxLength?: number;\n type?: \"text\" | \"search\" | \"email\" | \"url\" | \"tel\";\n variant?: \"default\" | \"ai\" | \"compact\";\n /** Set false for a plain field without a leading icon. */\n icon?: string | false;\n activeIcon?: string;\n /** ID of a consumer-owned visible error; caller owns its announcement. Native controls only. */\n externalErrorId?: string;\n prefix?: JSX.Element;\n suffix?: JSX.Element;\n clearable?: boolean;\n onClear?: () => void;\n clearLabel?: string;\n multiline?: boolean;\n monospace?: boolean;\n password?: boolean;\n markdown?: boolean;\n onSubmit?: () => void;\n lines?: number;\n abbreviations?: Record<string, string>;\n completions?: readonly Completion[];\n };\n\nexport function TextInput(props: TextInputProps): JSX.Element {\n const messages = useUiMessages();\n const inputMessages = useInputMessages();\n const [local, rest] = splitProps(props, [\n \"activeIcon\",\n \"aria-describedby\",\n \"aria-label\",\n \"class\",\n \"clearLabel\",\n \"clearable\",\n \"completions\",\n \"description\",\n \"error\",\n \"externalErrorId\",\n \"icon\",\n \"id\",\n \"label\",\n \"lines\",\n \"markdown\",\n \"minLength\",\n \"maxLength\",\n \"onKeyDown\",\n \"monospace\",\n \"multiline\",\n \"onClear\",\n \"onValueCommit\",\n \"onSubmit\",\n \"onValueChange\",\n \"password\",\n \"prefix\",\n \"required\",\n \"suffix\",\n \"type\",\n \"value\",\n \"variant\",\n \"abbreviations\",\n ]);\n const meta = createFieldMeta(local.id);\n const value = () => resolveMaybeAccessor(local.value) ?? \"\";\n const error = () => resolveMaybeAccessor(local.error);\n // HTML IDs are single nonempty tokens; numeric starts and punctuation are valid.\n const externalErrorId = () => {\n const id = local.externalErrorId;\n return id && !/[\\t\\n\\f\\r ]/.test(id) ? id : undefined;\n };\n const controlMeta = {\n ...meta,\n get errorId() {\n return externalErrorId() ?? meta.errorId;\n },\n };\n const [passwordVisible, setPasswordVisible] = createSignal(false);\n const multiline = () => Boolean(local.multiline || local.markdown);\n const compact = () => local.variant === \"compact\";\n const icon = () =>\n local.icon === false\n ? \"\"\n : (local.icon ?? (local.variant === \"ai\" ? \"ti ti-sparkles\" : local.markdown ? \"ti ti-markdown\" : \"ti ti-cursor-text\"));\n // A custom icon stays while typing (a search field keeps its magnifier); only the default icon switches to the pencil.\n const activeIcon = () => local.activeIcon ?? (local.icon || undefined) ?? (local.variant === \"ai\" ? \"ti ti-sparkles\" : \"ti ti-pencil\");\n // Names, addresses and passwords are typed exactly: phone keyboards must not capitalize or \"correct\" them.\n const verbatim = () =>\n local.password || local.type === \"email\" || local.type === \"url\" || /\\b(username|email|url)\\b/.test(String(rest.autocomplete ?? \"\"));\n const input = (next: string) => local.onValueChange?.(next);\n const commit = (next: string) => local.onValueCommit?.(next);\n const submitOnEnter = (event: KeyboardEvent) => {\n if (local.onSubmit && event.key === \"Enter\" && !event.shiftKey && !event.metaKey) {\n event.preventDefault();\n local.onSubmit();\n }\n };\n /** The caller's key handler runs first; Enter submits unless it handled the key. */\n const keyDown: JSX.EventHandler<HTMLInputElement, KeyboardEvent> = (event) => {\n const handler = local.onKeyDown;\n if (typeof handler === \"function\") handler(event);\n else if (Array.isArray(handler)) handler[0](handler[1], event);\n if (!event.defaultPrevented) submitOnEnter(event);\n };\n const clear: JSX.EventHandler<HTMLButtonElement, MouseEvent> = (event) => {\n // Clearing removes the button. Return to the field before notifying the caller, whose handler\n // may deliberately navigate or move focus somewhere else.\n event.currentTarget.ownerDocument.getElementById(meta.controlId)?.focus();\n if (local.onClear) {\n local.onClear();\n return;\n }\n commitFieldValue(local, \"\");\n };\n\n return (\n <Show\n when={local.markdown}\n fallback={\n <Field\n class={local.class}\n label={local.label}\n description={local.description}\n error={externalErrorId() ? undefined : error()}\n meta={meta}\n required={local.required}\n disabled={rest.disabled}\n >\n <div\n class=\"k2b-input-shell k2b-text-input\"\n data-variant={compact() ? \"compact\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n data-ai={local.variant === \"ai\" ? \"true\" : undefined}\n data-multiline={multiline() ? \"true\" : undefined}\n data-monospace={local.monospace ? \"true\" : undefined}\n style={multiline() ? { \"--k2b-editor-lines\": String(local.lines ?? 3) } : undefined}\n >\n <Show when={!compact() && local.icon !== false}>\n <span class=\"k2b-input-shell__icon k2b-text-input__icon\" aria-hidden=\"true\">\n <i class={icon()} />\n <i class={activeIcon()} />\n </span>\n </Show>\n <Show when={local.prefix}>\n <span class=\"k2b-input-shell__affix\">{local.prefix}</span>\n </Show>\n <Show\n when={multiline()}\n fallback={\n <input\n autocapitalize={verbatim() ? \"none\" : undefined}\n autocorrect={verbatim() ? \"off\" : undefined}\n spellcheck={verbatim() ? false : undefined}\n {...rest}\n id={meta.controlId}\n class=\"k2b-input\"\n size={rest.size ?? (compact() ? 9 : undefined)}\n type={local.password && !passwordVisible() ? \"password\" : (local.type ?? \"text\")}\n value={value()}\n minlength={local.minLength}\n maxlength={local.maxLength}\n required={local.required}\n {...fieldControlAria(controlMeta, local)}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={keyDown}\n />\n }\n >\n <textarea\n {...(rest as unknown as JSX.TextareaHTMLAttributes<HTMLTextAreaElement>)}\n id={meta.controlId}\n class=\"k2b-input k2b-text-input__textarea\"\n value={value()}\n rows={local.lines ?? 3}\n required={local.required}\n minlength={local.minLength}\n maxlength={local.maxLength}\n {...fieldControlAria(controlMeta, local)}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={submitOnEnter}\n >\n {/* HTML consumes one leading newline in textarea content. */}\n {isServer ? `\\n${value()}` : undefined}\n </textarea>\n </Show>\n <Show when={local.suffix}>\n <span class=\"k2b-input-shell__affix\">{local.suffix}</span>\n </Show>\n <Show when={local.clearable && value() && !multiline() && !local.password && !rest.disabled && !rest.readOnly}>\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear k2b-input-clear-action\"\n aria-label={local.clearLabel ?? messages().clear}\n onClick={clear}\n >\n <i class=\"ti ti-x\" aria-hidden=\"true\" />\n </button>\n </Show>\n <Show when={local.password && !multiline()}>\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear\"\n aria-label={passwordVisible() ? inputMessages().hidePassword : inputMessages().showPassword}\n aria-pressed={passwordVisible()}\n disabled={rest.disabled}\n onClick={() => setPasswordVisible((visible) => !visible)}\n >\n <i class={passwordVisible() ? \"ti ti-eye-off\" : \"ti ti-eye\"} aria-hidden=\"true\" />\n </button>\n </Show>\n </div>\n </Field>\n }\n >\n <MarkdownEditor\n class={local.class}\n label={local.label}\n description={local.description}\n error={error()}\n id={meta.controlId}\n name={rest.name}\n value={value()}\n onValueChange={input}\n onValueCommit={local.onValueCommit}\n onSubmit={local.onSubmit}\n placeholder={rest.placeholder}\n disabled={rest.disabled}\n required={local.required}\n lines={local.lines}\n maxLength={local.maxLength}\n spellcheck={rest.spellcheck === undefined ? undefined : rest.spellcheck === true || rest.spellcheck === \"true\"}\n abbreviations={local.abbreviations}\n completions={local.completions}\n aria-label={local[\"aria-label\"]}\n aria-describedby={local[\"aria-describedby\"]}\n />\n </Show>\n );\n}\n\nexport default TextInput;\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,YAAY,EAAY,IAAI,EAAE,UAAU,QAAQ,UAAU;AACnE,S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K;UAAA,OAAE,KAAK,CAAC,KAAK;QAAA;QAAA,IAClB,SAAS;UAAA,OAAE,KAAK,CAAC,SAAS;QAAA;QAAA,IAC1B,UAAU;UAAA,OAAE,iBAAI,CAAC,UAAU,KAAK,SAAS,MAAG,SAAS,GAAG,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM;QAAA;QAAA,IAC9G,aAAa;UAAA,OAAE,KAAK,CAAC,aAAa;QAAA;QAAA,IAClC,WAAW;UAAA,OAAE,KAAK,CAAC,WAAW;QAAA;QAAA;UAAA,OAClB,KAAK,CAAC,YAAY,CAAC;QAAA;QAAA;UAAA,OACb,KAAK,CAAC,kBAAkB,CAAC;QAAA;MAAA;IAAA;EAAA;AAInD;AAEA,eAAe,SAAS","ignoreList":[]}
@@ -4,6 +4,10 @@ export { Checkbox } from "./Checkbox";
4
4
  export { CheckboxCard } from "./CheckboxCard";
5
5
  export { ChoiceChips } from "./ChoiceChips";
6
6
  export { ColorInput, PinInput, Slider } from "./ChoiceInputs";
7
+ export { ChoiceList } from "./ChoiceList";
8
+ export { ChoiceSlider } from "./ChoiceSlider";
9
+ export { ChoiceTiles } from "./ChoiceTiles";
10
+ export { ColorChoices } from "./ColorChoices";
7
11
  export { Combobox } from "./Combobox";
8
12
  export { abbreviations } from "./completion";
9
13
  export { DatePicker, DateRangePicker, DateTimePicker } from "./DatePicker";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["inputs/index.ts"],"sourcesContent":["export type { AutocompleteEditorProps } from \"./AutocompleteEditor\";\nexport { AutocompleteEditor } from \"./AutocompleteEditor\";\nexport type {\n AutocompleteSelectOption,\n AutocompleteSelectProps,\n AutocompleteSelectSearchResult,\n} from \"./AutocompleteSelect\";\nexport { AutocompleteSelect } from \"./AutocompleteSelect\";\nexport type { CheckboxProps } from \"./Checkbox\";\nexport { Checkbox } from \"./Checkbox\";\nexport type { CheckboxCardProps } from \"./CheckboxCard\";\nexport { CheckboxCard } from \"./CheckboxCard\";\nexport type { ChoiceChipOption, ChoiceChipsProps } from \"./ChoiceChips\";\nexport { ChoiceChips } from \"./ChoiceChips\";\nexport type {\n ColorInputProps,\n PinInputProps,\n SliderProps,\n} from \"./ChoiceInputs\";\nexport { ColorInput, PinInput, Slider } from \"./ChoiceInputs\";\nexport type { ComboboxOption, ComboboxProps } from \"./Combobox\";\nexport { Combobox } from \"./Combobox\";\nexport type { ChoiceOption, ChoiceOptionsLoader } from \"./choice\";\nexport type {\n Completion,\n QueryContext,\n SuggestContext,\n Suggestion,\n} from \"./completion\";\nexport { abbreviations } from \"./completion\";\nexport type {\n DatePickerBaseProps,\n DatePickerProps,\n DatePreset,\n DateRangePickerProps,\n DateRangeValue,\n DateTimePickerProps,\n DurationPreset,\n} from \"./DatePicker\";\nexport { DatePicker, DateRangePicker, DateTimePicker } from \"./DatePicker\";\nexport type { EmojiPickerPopoverProps, EmojiPickerProps } from \"./emoji/EmojiPicker\";\nexport { EmojiPicker } from \"./emoji/EmojiPicker\";\nexport type { EmojiSkinTone } from \"./emoji/emoji-index\";\nexport { rememberEmoji } from \"./emoji/emoji-index\";\nexport type { FileDropDetails, FileDropOptions, FileDropRejection, FileDropTargetProps } from \"./FileDropTarget\";\nexport { FileDropTarget, fileDropTarget } from \"./FileDropTarget\";\nexport type { FileDropzoneProps, ImageCropperProps, ImageInputProps } from \"./FileInputs\";\nexport { FileDropzone, ImageCropper, ImageInput } from \"./FileInputs\";\nexport type { DateContext, FieldProps, MaybeAccessor, ValueFieldProps } from \"./field-contract\";\nexport { DEFAULT_ICON_GROUPS, DEFAULT_ICON_OPTIONS } from \"./icon-options\";\nexport type {\n ImageCropAspect,\n ImageCropOutput,\n ImageCropRect,\n ImageCropRotation,\n ImageCropSize,\n ImageCropSource,\n ImageCropState,\n} from \"./image-crop\";\nexport {\n clampImageCropRect,\n createCroppedImageCanvas,\n createCroppedImageDataUrl,\n getInitialImageCropRect,\n imageCropRectToPixels,\n normalizeImageCropRotation,\n resizeImageCropAroundCenter,\n rotateImageCropRight,\n} from \"./image-crop\";\nexport type {\n MultiSelectFetchDataFn,\n MultiSelectInputProps,\n MultiSelectOption,\n} from \"./MultiSelectInput\";\nexport { MultiSelectInput } from \"./MultiSelectInput\";\nexport type { MarkdownEditorProps } from \"./markdown/MarkdownEditor\";\nexport { MarkdownEditor } from \"./markdown/MarkdownEditor\";\nexport type { NumberInputProps } from \"./NumberInput\";\nexport { NumberInput } from \"./NumberInput\";\nexport type { QrScannerError, QrScannerProps } from \"./QrScanner\";\nexport { QrScanner } from \"./QrScanner\";\nexport type {\n RichSelectFact,\n RichSelectFooter,\n RichSelectItem,\n RichSelectProps,\n RichSelectSection,\n RichSelectStatus,\n} from \"./RichSelect\";\nexport { RichSelect, RichSelectFacts } from \"./RichSelect\";\nexport type { ChoiceAppearance, SelectGridSize, SelectGroup, SelectOption, SelectProps, SelectSourceOption, SelectView } from \"./Select\";\nexport { Select } from \"./Select\";\nexport type { SelectChipOption, SelectChipProps } from \"./SelectChip\";\nexport { SelectChip } from \"./SelectChip\";\nexport type { SignatureInputProps } from \"./SignatureInput\";\nexport { SignatureInput } from \"./SignatureInput\";\nexport type { IconInputProps, IconOption } from \"./SpecialInputs\";\nexport { IconInput } from \"./SpecialInputs\";\nexport type { SwitchProps } from \"./Switch\";\nexport { Switch } from \"./Switch\";\nexport type { SignaturePngOptions, SignatureValue } from \"./signature\";\nexport { parseSignature, signatureToPng } from \"./signature\";\nexport type { TagEditorItem, TagEditorLabels, TagEditorProps, TagEditorValue } from \"./TagEditor\";\nexport { TagEditor } from \"./TagEditor\";\nexport type { TagsInputProps } from \"./TagsInput\";\nexport { TagsInput } from \"./TagsInput\";\nexport type {\n TemplateEditorLayout,\n TemplateEditorProps,\n TemplatePreviewProps,\n TemplateSampleDataProps,\n TemplateVariable,\n TemplateVariableKind,\n} from \"./TemplateEditor\";\nexport {\n createTemplateEditorPanesLayout,\n TemplateEditor,\n TemplatePreview,\n TemplateSampleData,\n} from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S,QAAQ,aAAa;AASvC,SACE,+BAA+B,EAC/B,cAAc,EACd,eAAe,EACf,kBAAkB,QACb,kBAAkB;AAEzB,SAAS,SAAS,QAAQ,aAAa","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["inputs/index.ts"],"sourcesContent":["export type { AutocompleteEditorProps } from \"./AutocompleteEditor\";\nexport { AutocompleteEditor } from \"./AutocompleteEditor\";\nexport type {\n AutocompleteSelectOption,\n AutocompleteSelectProps,\n AutocompleteSelectSearchResult,\n} from \"./AutocompleteSelect\";\nexport { AutocompleteSelect } from \"./AutocompleteSelect\";\nexport type { CheckboxProps } from \"./Checkbox\";\nexport { Checkbox } from \"./Checkbox\";\nexport type { CheckboxCardProps } from \"./CheckboxCard\";\nexport { CheckboxCard } from \"./CheckboxCard\";\nexport type { ChoiceChipOption, ChoiceChipsProps } from \"./ChoiceChips\";\nexport { ChoiceChips } from \"./ChoiceChips\";\nexport type {\n ColorInputProps,\n PinInputProps,\n SliderProps,\n} from \"./ChoiceInputs\";\nexport { ColorInput, PinInput, Slider } from \"./ChoiceInputs\";\nexport type { ChoiceListOption, ChoiceListProps } from \"./ChoiceList\";\nexport { ChoiceList } from \"./ChoiceList\";\nexport type { ChoiceSliderOption, ChoiceSliderProps } from \"./ChoiceSlider\";\nexport { ChoiceSlider } from \"./ChoiceSlider\";\nexport type { ChoiceTileOption, ChoiceTilesProps } from \"./ChoiceTiles\";\nexport { ChoiceTiles } from \"./ChoiceTiles\";\nexport type { ColorChoiceOption, ColorChoicesProps } from \"./ColorChoices\";\nexport { ColorChoices } from \"./ColorChoices\";\nexport type { ComboboxOption, ComboboxProps } from \"./Combobox\";\nexport { Combobox } from \"./Combobox\";\nexport type { ChoiceOption, ChoiceOptionsLoader } from \"./choice\";\nexport type {\n Completion,\n QueryContext,\n SuggestContext,\n Suggestion,\n} from \"./completion\";\nexport { abbreviations } from \"./completion\";\nexport type {\n DatePickerBaseProps,\n DatePickerProps,\n DatePreset,\n DateRangePickerProps,\n DateRangeValue,\n DateTimePickerProps,\n DurationPreset,\n} from \"./DatePicker\";\nexport { DatePicker, DateRangePicker, DateTimePicker } from \"./DatePicker\";\nexport type { EmojiPickerPopoverProps, EmojiPickerProps } from \"./emoji/EmojiPicker\";\nexport { EmojiPicker } from \"./emoji/EmojiPicker\";\nexport type { EmojiSkinTone } from \"./emoji/emoji-index\";\nexport { rememberEmoji } from \"./emoji/emoji-index\";\nexport type { FileDropDetails, FileDropOptions, FileDropRejection, FileDropTargetProps } from \"./FileDropTarget\";\nexport { FileDropTarget, fileDropTarget } from \"./FileDropTarget\";\nexport type { FileDropzoneProps, ImageCropperProps, ImageInputProps } from \"./FileInputs\";\nexport { FileDropzone, ImageCropper, ImageInput } from \"./FileInputs\";\nexport type { DateContext, FieldProps, MaybeAccessor, ValueFieldProps } from \"./field-contract\";\nexport { DEFAULT_ICON_GROUPS, DEFAULT_ICON_OPTIONS } from \"./icon-options\";\nexport type {\n ImageCropAspect,\n ImageCropOutput,\n ImageCropRect,\n ImageCropRotation,\n ImageCropSize,\n ImageCropSource,\n ImageCropState,\n} from \"./image-crop\";\nexport {\n clampImageCropRect,\n createCroppedImageCanvas,\n createCroppedImageDataUrl,\n getInitialImageCropRect,\n imageCropRectToPixels,\n normalizeImageCropRotation,\n resizeImageCropAroundCenter,\n rotateImageCropRight,\n} from \"./image-crop\";\nexport type {\n MultiSelectFetchDataFn,\n MultiSelectInputProps,\n MultiSelectOption,\n} from \"./MultiSelectInput\";\nexport { MultiSelectInput } from \"./MultiSelectInput\";\nexport type { MarkdownEditorProps } from \"./markdown/MarkdownEditor\";\nexport { MarkdownEditor } from \"./markdown/MarkdownEditor\";\nexport type { NumberInputProps } from \"./NumberInput\";\nexport { NumberInput } from \"./NumberInput\";\nexport type { QrScannerError, QrScannerProps } from \"./QrScanner\";\nexport { QrScanner } from \"./QrScanner\";\nexport type {\n RichSelectFact,\n RichSelectFooter,\n RichSelectItem,\n RichSelectProps,\n RichSelectSection,\n RichSelectStatus,\n} from \"./RichSelect\";\nexport { RichSelect, RichSelectFacts } from \"./RichSelect\";\nexport type { ChoiceAppearance, SelectGridSize, SelectGroup, SelectOption, SelectProps, SelectSourceOption, SelectView } from \"./Select\";\nexport { Select } from \"./Select\";\nexport type { SelectChipOption, SelectChipProps } from \"./SelectChip\";\nexport { SelectChip } from \"./SelectChip\";\nexport type { SignatureInputProps } from \"./SignatureInput\";\nexport { SignatureInput } from \"./SignatureInput\";\nexport type { IconInputProps, IconOption } from \"./SpecialInputs\";\nexport { IconInput } from \"./SpecialInputs\";\nexport type { SwitchProps } from \"./Switch\";\nexport { Switch } from \"./Switch\";\nexport type { SignaturePngOptions, SignatureValue } from \"./signature\";\nexport { parseSignature, signatureToPng } from \"./signature\";\nexport type { TagEditorItem, TagEditorLabels, TagEditorProps, TagEditorValue } from \"./TagEditor\";\nexport { TagEditor } from \"./TagEditor\";\nexport type { TagsInputProps } from \"./TagsInput\";\nexport { TagsInput } from \"./TagsInput\";\nexport type {\n TemplateEditorLayout,\n TemplateEditorProps,\n TemplatePreviewProps,\n TemplateSampleDataProps,\n TemplateVariable,\n TemplateVariableKind,\n} from \"./TemplateEditor\";\nexport {\n createTemplateEditorPanesLayout,\n TemplateEditor,\n TemplatePreview,\n TemplateSampleData,\n} from \"./TemplateEditor\";\nexport type { TextInputProps } from \"./TextInput\";\nexport { TextInput } from \"./TextInput\";\n"],"mappings":"AACA,SAAS,kBAAkB,QAAQ,sBAAsB;AAMzD,SAAS,kBAAkB,QAAQ,sBAAsB;AAEzD,SAAS,QAAQ,QAAQ,YAAY;AAErC,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,WAAW,QAAQ,eAAe;AAM3C,SAAS,UAAU,EAAE,QAAQ,EAAE,MAAM,QAAQ,gBAAgB;AAE7D,SAAS,UAAU,QAAQ,cAAc;AAEzC,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,YAAY,QAAQ,gBAAgB;AAE7C,SAAS,QAAQ,QAAQ,YAAY;AAQrC,SAAS,aAAa,QAAQ,cAAc;AAU5C,SAAS,UAAU,EAAE,eAAe,EAAE,cAAc,QAAQ,cAAc;AAE1E,SAAS,WAAW,QAAQ,qBAAqB;AAEjD,SAAS,aAAa,QAAQ,qBAAqB;AAEnD,SAAS,cAAc,EAAE,cAAc,QAAQ,kBAAkB;AAEjE,SAAS,YAAY,EAAE,YAAY,EAAE,UAAU,QAAQ,cAAc;AAErE,SAAS,mBAAmB,EAAE,oBAAoB,QAAQ,gBAAgB;AAU1E,SACE,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,oBAAoB,QACf,cAAc;AAMrB,SAAS,gBAAgB,QAAQ,oBAAoB;AAErD,SAAS,cAAc,QAAQ,2BAA2B;AAE1D,SAAS,WAAW,QAAQ,eAAe;AAE3C,SAAS,SAAS,QAAQ,aAAa;AASvC,SAAS,UAAU,EAAE,eAAe,QAAQ,cAAc;AAE1D,SAAS,MAAM,QAAQ,UAAU;AAEjC,SAAS,UAAU,QAAQ,cAAc;AAEzC,SAAS,cAAc,QAAQ,kBAAkB;AAEjD,SAAS,SAAS,QAAQ,iBAAiB;AAE3C,SAAS,MAAM,QAAQ,UAAU;AAEjC,SAAS,cAAc,EAAE,cAAc,QAAQ,aAAa;AAE5D,SAAS,SAAS,QAAQ,aAAa;AAEvC,SAAS,SAAS,QAAQ,aAAa;AASvC,SACE,+BAA+B,EAC/B,cAAc,EACd,eAAe,EACf,kBAAkB,QACb,kBAAkB;AAEzB,SAAS,SAAS,QAAQ,aAAa","ignoreList":[]}
@@ -7,12 +7,14 @@ const qrMessages = i18n.define({
7
7
  qrCameraPreview: "Camera preview for scanning a QR code",
8
8
  qrCameraStarting: "Starting camera…",
9
9
  qrCameraInstructions: "Point the camera at a QR code.",
10
+ qrCameraStalled: "The camera is on, but its picture did not start.",
10
11
  qrCameraPrivacy: "Camera images stay on this device."
11
12
  },
12
13
  de: {
13
14
  qrCameraPreview: "Kameravorschau zum Scannen eines QR-Codes",
14
15
  qrCameraStarting: "Kamera wird gestartet…",
15
16
  qrCameraInstructions: "Richte die Kamera auf einen QR-Code.",
17
+ qrCameraStalled: "Die Kamera ist an, aber ihr Bild ist nicht gestartet.",
16
18
  qrCameraPrivacy: "Kamerabilder bleiben auf diesem Gerät."
17
19
  }
18
20
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["inputs/qr-messages.ts"],"sourcesContent":["import { i18n } from \"@k2b/stdlib\";\nimport { useLocale } from \"../intl/locale\";\n\nconst qrMessages = i18n.define({\n baseLocale: \"en\",\n messages: {\n en: {\n qrCameraPreview: \"Camera preview for scanning a QR code\",\n qrCameraStarting: \"Starting camera…\",\n qrCameraInstructions: \"Point the camera at a QR code.\",\n qrCameraPrivacy: \"Camera images stay on this device.\",\n },\n de: {\n qrCameraPreview: \"Kameravorschau zum Scannen eines QR-Codes\",\n qrCameraStarting: \"Kamera wird gestartet…\",\n qrCameraInstructions: \"Richte die Kamera auf einen QR-Code.\",\n qrCameraPrivacy: \"Kamerabilder bleiben auf diesem Gerät.\",\n },\n },\n});\n\nexport type QrMessages = ReturnType<(typeof qrMessages)[\"resolve\"]>[\"t\"];\n\n/** Resolved from the inherited render locale. */\nexport const useQrMessages = (): (() => QrMessages) => {\n const locale = useLocale();\n return () => qrMessages.resolve([locale()]).t;\n};\n\nexport const checkQrMessages = () => qrMessages.check();\n"],"mappings":"AAAA,SAAS,IAAI,QAAQ,aAAa;AAClC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;EAC7B,UAAU,EAAE,IAAI;EAChB,QAAQ,EAAE;IACR,EAAE,EAAE;MACF,eAAe,EAAE,uCAAuC;MACxD,gBAAgB,EAAE,kBAAkB;MACpC,oBAAoB,EAAE,gCAAgC;MACtD,eAAe,EAAE;IACnB,CAAC;IACD,EAAE,EAAE;MACF,eAAe,EAAE,2CAA2C;MAC5D,gBAAgB,EAAE,wBAAwB;MAC1C,oBAAoB,EAAE,sCAAsC;MAC5D,eAAe,EAAE;IACnB;EACF;AACF,CAAC,CAAC;AAIF;AACA,OAAO,MAAM,aAAa,GAAG,MAA0B;EACrD,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;EAC1B,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,OAAO,MAAM,eAAe,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["inputs/qr-messages.ts"],"sourcesContent":["import { i18n } from \"@k2b/stdlib\";\nimport { useLocale } from \"../intl/locale\";\n\nconst qrMessages = i18n.define({\n baseLocale: \"en\",\n messages: {\n en: {\n qrCameraPreview: \"Camera preview for scanning a QR code\",\n qrCameraStarting: \"Starting camera…\",\n qrCameraInstructions: \"Point the camera at a QR code.\",\n qrCameraStalled: \"The camera is on, but its picture did not start.\",\n qrCameraPrivacy: \"Camera images stay on this device.\",\n },\n de: {\n qrCameraPreview: \"Kameravorschau zum Scannen eines QR-Codes\",\n qrCameraStarting: \"Kamera wird gestartet…\",\n qrCameraInstructions: \"Richte die Kamera auf einen QR-Code.\",\n qrCameraStalled: \"Die Kamera ist an, aber ihr Bild ist nicht gestartet.\",\n qrCameraPrivacy: \"Kamerabilder bleiben auf diesem Gerät.\",\n },\n },\n});\n\nexport type QrMessages = ReturnType<(typeof qrMessages)[\"resolve\"]>[\"t\"];\n\n/** Resolved from the inherited render locale. */\nexport const useQrMessages = (): (() => QrMessages) => {\n const locale = useLocale();\n return () => qrMessages.resolve([locale()]).t;\n};\n\nexport const checkQrMessages = () => qrMessages.check();\n"],"mappings":"AAAA,SAAS,IAAI,QAAQ,aAAa;AAClC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;EAC7B,UAAU,EAAE,IAAI;EAChB,QAAQ,EAAE;IACR,EAAE,EAAE;MACF,eAAe,EAAE,uCAAuC;MACxD,gBAAgB,EAAE,kBAAkB;MACpC,oBAAoB,EAAE,gCAAgC;MACtD,eAAe,EAAE,kDAAkD;MACnE,eAAe,EAAE;IACnB,CAAC;IACD,EAAE,EAAE;MACF,eAAe,EAAE,2CAA2C;MAC5D,gBAAgB,EAAE,wBAAwB;MAC1C,oBAAoB,EAAE,sCAAsC;MAC5D,eAAe,EAAE,uDAAuD;MACxE,eAAe,EAAE;IACnB;EACF;AACF,CAAC,CAAC;AAIF;AACA,OAAO,MAAM,aAAa,GAAG,MAA0B;EACrD,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;EAC1B,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,OAAO,MAAM,eAAe,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Roving focus for a single-choice radio group: arrows move and select with wrapping, Home and End select the first
3
+ * and last option. Returns the index to select, or `undefined` for keys the group does not handle.
4
+ */
5
+ export const radioKeyTarget = (key, index, count) => {
6
+ if (count === 0) return undefined;
7
+ if (key === "ArrowRight" || key === "ArrowDown") return (index + 1) % count;
8
+ if (key === "ArrowLeft" || key === "ArrowUp") return (index - 1 + count) % count;
9
+ if (key === "Home") return 0;
10
+ if (key === "End") return count - 1;
11
+ return undefined;
12
+ };
13
+ //# sourceMappingURL=radio-keys.js.map