@coffer-org/web-ui 4.0.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 (387) hide show
  1. package/README.md +87 -0
  2. package/dist/Markdown.d.ts +4 -0
  3. package/dist/Markdown.js +13 -0
  4. package/dist/MarkdownEditor.d.ts +6 -0
  5. package/dist/MarkdownEditor.js +83 -0
  6. package/dist/actions/ActionButton.d.ts +7 -0
  7. package/dist/actions/ActionButton.js +54 -0
  8. package/dist/actions/PopupBody.d.ts +4 -0
  9. package/dist/actions/PopupBody.js +8 -0
  10. package/dist/actions/TemplateHost.d.ts +4 -0
  11. package/dist/actions/TemplateHost.js +36 -0
  12. package/dist/actions/registry.d.ts +20 -0
  13. package/dist/actions/registry.js +9 -0
  14. package/dist/components/ExtendReasonInfo.d.ts +6 -0
  15. package/dist/components/ExtendReasonInfo.js +12 -0
  16. package/dist/components/FavoriteButton.d.ts +8 -0
  17. package/dist/components/FavoriteButton.js +7 -0
  18. package/dist/components/Icon.d.ts +6 -0
  19. package/dist/components/Icon.js +12 -0
  20. package/dist/components/PageBody.d.ts +4 -0
  21. package/dist/components/PageBody.js +4 -0
  22. package/dist/components/RecordInline.d.ts +8 -0
  23. package/dist/components/RecordInline.js +29 -0
  24. package/dist/components/SaveStatus.d.ts +1 -0
  25. package/dist/components/SaveStatus.js +11 -0
  26. package/dist/components/Toolbar.d.ts +5 -0
  27. package/dist/components/Toolbar.js +4 -0
  28. package/dist/components/icons/color.d.ts +2 -0
  29. package/dist/components/icons/color.js +10 -0
  30. package/dist/components/icons/flag.d.ts +2 -0
  31. package/dist/components/icons/flag.js +6 -0
  32. package/dist/components/icons/lucide.d.ts +2 -0
  33. package/dist/components/icons/lucide.js +111 -0
  34. package/dist/components/icons/registry.d.ts +4 -0
  35. package/dist/components/icons/registry.js +22 -0
  36. package/dist/components/icons/simple.d.ts +2 -0
  37. package/dist/components/icons/simple.js +15 -0
  38. package/dist/components/icons/tabler.d.ts +2 -0
  39. package/dist/components/icons/tabler.js +11 -0
  40. package/dist/components/ui/FieldLabel.d.ts +9 -0
  41. package/dist/components/ui/FieldLabel.js +4 -0
  42. package/dist/components/ui/badge.d.ts +9 -0
  43. package/dist/components/ui/badge.js +19 -0
  44. package/dist/components/ui/button.d.ts +11 -0
  45. package/dist/components/ui/button.js +33 -0
  46. package/dist/components/ui/calendar.d.ts +8 -0
  47. package/dist/components/ui/calendar.js +72 -0
  48. package/dist/components/ui/card.d.ts +8 -0
  49. package/dist/components/ui/card.js +16 -0
  50. package/dist/components/ui/checkbox.d.ts +4 -0
  51. package/dist/components/ui/checkbox.js +8 -0
  52. package/dist/components/ui/chip-cls.d.ts +1 -0
  53. package/dist/components/ui/chip-cls.js +1 -0
  54. package/dist/components/ui/combobox.d.ts +24 -0
  55. package/dist/components/ui/combobox.js +58 -0
  56. package/dist/components/ui/confirm.d.ts +10 -0
  57. package/dist/components/ui/confirm.js +37 -0
  58. package/dist/components/ui/date-picker.d.ts +5 -0
  59. package/dist/components/ui/date-picker.js +16 -0
  60. package/dist/components/ui/dialog.d.ts +16 -0
  61. package/dist/components/ui/dialog.js +27 -0
  62. package/dist/components/ui/dropdown-menu.d.ts +15 -0
  63. package/dist/components/ui/dropdown-menu.js +18 -0
  64. package/dist/components/ui/input-group.d.ts +16 -0
  65. package/dist/components/ui/input-group.js +56 -0
  66. package/dist/components/ui/input.d.ts +3 -0
  67. package/dist/components/ui/input.js +6 -0
  68. package/dist/components/ui/label.d.ts +4 -0
  69. package/dist/components/ui/label.js +7 -0
  70. package/dist/components/ui/mask-input.d.ts +61 -0
  71. package/dist/components/ui/mask-input.js +1052 -0
  72. package/dist/components/ui/month-year-picker.d.ts +10 -0
  73. package/dist/components/ui/month-year-picker.js +46 -0
  74. package/dist/components/ui/option-icon.d.ts +15 -0
  75. package/dist/components/ui/option-icon.js +19 -0
  76. package/dist/components/ui/phone-input.d.ts +13 -0
  77. package/dist/components/ui/phone-input.js +53 -0
  78. package/dist/components/ui/popover.d.ts +11 -0
  79. package/dist/components/ui/popover.js +28 -0
  80. package/dist/components/ui/rating.d.ts +44 -0
  81. package/dist/components/ui/rating.js +501 -0
  82. package/dist/components/ui/scroll-area.d.ts +5 -0
  83. package/dist/components/ui/scroll-area.js +11 -0
  84. package/dist/components/ui/select-combobox.d.ts +25 -0
  85. package/dist/components/ui/select-combobox.js +36 -0
  86. package/dist/components/ui/select.d.ts +13 -0
  87. package/dist/components/ui/select.js +24 -0
  88. package/dist/components/ui/separator.d.ts +4 -0
  89. package/dist/components/ui/separator.js +7 -0
  90. package/dist/components/ui/switch.d.ts +4 -0
  91. package/dist/components/ui/switch.js +7 -0
  92. package/dist/components/ui/textarea.d.ts +3 -0
  93. package/dist/components/ui/textarea.js +6 -0
  94. package/dist/components/ui/time-picker.d.ts +84 -0
  95. package/dist/components/ui/time-picker.js +1258 -0
  96. package/dist/components/visually-hidden-input.d.ts +10 -0
  97. package/dist/components/visually-hidden-input.js +96 -0
  98. package/dist/hooks/use-as-ref.d.ts +3 -0
  99. package/dist/hooks/use-as-ref.js +10 -0
  100. package/dist/hooks/use-isomorphic-layout-effect.d.ts +3 -0
  101. package/dist/hooks/use-isomorphic-layout-effect.js +3 -0
  102. package/dist/hooks/use-lazy-ref.d.ts +3 -0
  103. package/dist/hooks/use-lazy-ref.js +9 -0
  104. package/dist/hooks/use-media-query.d.ts +3 -0
  105. package/dist/hooks/use-media-query.js +26 -0
  106. package/dist/host-services.d.ts +47 -0
  107. package/dist/host-services.js +35 -0
  108. package/dist/index.d.ts +70 -0
  109. package/dist/index.js +69 -0
  110. package/dist/layout.d.ts +29 -0
  111. package/dist/layout.js +323 -0
  112. package/dist/lib/cat-color.d.ts +1 -0
  113. package/dist/lib/cat-color.js +7 -0
  114. package/dist/lib/compose-refs.d.ts +5 -0
  115. package/dist/lib/compose-refs.js +38 -0
  116. package/dist/lib/date-format.d.ts +9 -0
  117. package/dist/lib/date-format.js +31 -0
  118. package/dist/lib/format.d.ts +14 -0
  119. package/dist/lib/format.js +34 -0
  120. package/dist/lib/json.d.ts +1 -0
  121. package/dist/lib/json.js +12 -0
  122. package/dist/lib/multi-value.d.ts +3 -0
  123. package/dist/lib/multi-value.js +22 -0
  124. package/dist/lib/record-option.d.ts +7 -0
  125. package/dist/lib/record-option.js +52 -0
  126. package/dist/lib/use-record-labels.d.ts +14 -0
  127. package/dist/lib/use-record-labels.js +130 -0
  128. package/dist/lib/utils.d.ts +2 -0
  129. package/dist/lib/utils.js +5 -0
  130. package/dist/list-view.d.ts +26 -0
  131. package/dist/list-view.js +11 -0
  132. package/dist/markdown/blocks.d.ts +10 -0
  133. package/dist/markdown/blocks.js +57 -0
  134. package/dist/markdown/extensions.d.ts +6 -0
  135. package/dist/markdown/extensions.js +25 -0
  136. package/dist/markdown/slash.d.ts +23 -0
  137. package/dist/markdown/slash.js +27 -0
  138. package/dist/markdown/toolbar.d.ts +13 -0
  139. package/dist/markdown/toolbar.js +119 -0
  140. package/dist/plugin-ui.d.ts +43 -0
  141. package/dist/plugin-ui.js +37 -0
  142. package/dist/registry.d.ts +26 -0
  143. package/dist/registry.js +169 -0
  144. package/dist/render/blocks/accordion.d.ts +1 -0
  145. package/dist/render/blocks/accordion.js +15 -0
  146. package/dist/render/blocks/aside.d.ts +1 -0
  147. package/dist/render/blocks/aside.js +14 -0
  148. package/dist/render/blocks/balance.d.ts +1 -0
  149. package/dist/render/blocks/balance.js +14 -0
  150. package/dist/render/blocks/bento.d.ts +1 -0
  151. package/dist/render/blocks/bento.js +24 -0
  152. package/dist/render/blocks/block-shell.d.ts +15 -0
  153. package/dist/render/blocks/block-shell.js +20 -0
  154. package/dist/render/blocks/calendar.d.ts +1 -0
  155. package/dist/render/blocks/calendar.js +142 -0
  156. package/dist/render/blocks/callout.d.ts +1 -0
  157. package/dist/render/blocks/callout.js +21 -0
  158. package/dist/render/blocks/chart.d.ts +1 -0
  159. package/dist/render/blocks/chart.js +46 -0
  160. package/dist/render/blocks/compare.d.ts +1 -0
  161. package/dist/render/blocks/compare.js +16 -0
  162. package/dist/render/blocks/countdown.d.ts +1 -0
  163. package/dist/render/blocks/countdown.js +36 -0
  164. package/dist/render/blocks/deck.d.ts +1 -0
  165. package/dist/render/blocks/deck.js +29 -0
  166. package/dist/render/blocks/epigraph.d.ts +1 -0
  167. package/dist/render/blocks/epigraph.js +13 -0
  168. package/dist/render/blocks/facets.d.ts +1 -0
  169. package/dist/render/blocks/facets.js +23 -0
  170. package/dist/render/blocks/figure.d.ts +1 -0
  171. package/dist/render/blocks/figure.js +13 -0
  172. package/dist/render/blocks/grid.d.ts +1 -0
  173. package/dist/render/blocks/grid.js +21 -0
  174. package/dist/render/blocks/heatmap.d.ts +1 -0
  175. package/dist/render/blocks/heatmap.js +135 -0
  176. package/dist/render/blocks/idcard.d.ts +1 -0
  177. package/dist/render/blocks/idcard.js +30 -0
  178. package/dist/render/blocks/identity.d.ts +1 -0
  179. package/dist/render/blocks/identity.js +46 -0
  180. package/dist/render/blocks/index.d.ts +40 -0
  181. package/dist/render/blocks/index.js +40 -0
  182. package/dist/render/blocks/journal.d.ts +1 -0
  183. package/dist/render/blocks/journal.js +50 -0
  184. package/dist/render/blocks/ledger.d.ts +1 -0
  185. package/dist/render/blocks/ledger.js +23 -0
  186. package/dist/render/blocks/manifest.d.ts +1 -0
  187. package/dist/render/blocks/manifest.js +50 -0
  188. package/dist/render/blocks/masthead.d.ts +1 -0
  189. package/dist/render/blocks/masthead.js +15 -0
  190. package/dist/render/blocks/meter.d.ts +1 -0
  191. package/dist/render/blocks/meter.js +32 -0
  192. package/dist/render/blocks/nutrition.d.ts +1 -0
  193. package/dist/render/blocks/nutrition.js +27 -0
  194. package/dist/render/blocks/people.d.ts +1 -0
  195. package/dist/render/blocks/people.js +35 -0
  196. package/dist/render/blocks/plaque.d.ts +1 -0
  197. package/dist/render/blocks/plaque.js +15 -0
  198. package/dist/render/blocks/properties.d.ts +1 -0
  199. package/dist/render/blocks/properties.js +22 -0
  200. package/dist/render/blocks/prose.d.ts +1 -0
  201. package/dist/render/blocks/prose.js +17 -0
  202. package/dist/render/blocks/receipt.d.ts +1 -0
  203. package/dist/render/blocks/receipt.js +23 -0
  204. package/dist/render/blocks/registry.d.ts +16 -0
  205. package/dist/render/blocks/registry.js +7 -0
  206. package/dist/render/blocks/relation-source.d.ts +2 -0
  207. package/dist/render/blocks/relation-source.js +6 -0
  208. package/dist/render/blocks/route.d.ts +1 -0
  209. package/dist/render/blocks/route.js +23 -0
  210. package/dist/render/blocks/score.d.ts +1 -0
  211. package/dist/render/blocks/score.js +15 -0
  212. package/dist/render/blocks/series.d.ts +23 -0
  213. package/dist/render/blocks/series.js +57 -0
  214. package/dist/render/blocks/specimen.d.ts +1 -0
  215. package/dist/render/blocks/specimen.js +19 -0
  216. package/dist/render/blocks/split.d.ts +1 -0
  217. package/dist/render/blocks/split.js +15 -0
  218. package/dist/render/blocks/spread.d.ts +1 -0
  219. package/dist/render/blocks/spread.js +15 -0
  220. package/dist/render/blocks/stack.d.ts +1 -0
  221. package/dist/render/blocks/stack.js +15 -0
  222. package/dist/render/blocks/stats.d.ts +1 -0
  223. package/dist/render/blocks/stats.js +23 -0
  224. package/dist/render/blocks/status.d.ts +1 -0
  225. package/dist/render/blocks/status.js +18 -0
  226. package/dist/render/blocks/table.d.ts +11 -0
  227. package/dist/render/blocks/table.js +136 -0
  228. package/dist/render/blocks/tabs.d.ts +1 -0
  229. package/dist/render/blocks/tabs.js +17 -0
  230. package/dist/render/blocks/terminal.d.ts +1 -0
  231. package/dist/render/blocks/terminal.js +18 -0
  232. package/dist/render/blocks/timeline.d.ts +1 -0
  233. package/dist/render/blocks/timeline.js +31 -0
  234. package/dist/render/box.d.ts +5 -0
  235. package/dist/render/box.js +23 -0
  236. package/dist/render/chrome.d.ts +64 -0
  237. package/dist/render/chrome.js +92 -0
  238. package/dist/render/core/amount.d.ts +1 -0
  239. package/dist/render/core/amount.js +19 -0
  240. package/dist/render/core/attachment.d.ts +29 -0
  241. package/dist/render/core/attachment.js +102 -0
  242. package/dist/render/core/choice.d.ts +1 -0
  243. package/dist/render/core/choice.js +40 -0
  244. package/dist/render/core/composite.d.ts +1 -0
  245. package/dist/render/core/composite.js +132 -0
  246. package/dist/render/core/datetime.d.ts +2 -0
  247. package/dist/render/core/datetime.js +215 -0
  248. package/dist/render/core/dimensions.d.ts +1 -0
  249. package/dist/render/core/dimensions.js +44 -0
  250. package/dist/render/core/embed.d.ts +11 -0
  251. package/dist/render/core/embed.js +99 -0
  252. package/dist/render/core/file.d.ts +12 -0
  253. package/dist/render/core/file.js +238 -0
  254. package/dist/render/core/illustrated.d.ts +39 -0
  255. package/dist/render/core/illustrated.js +113 -0
  256. package/dist/render/core/index.d.ts +23 -0
  257. package/dist/render/core/index.js +23 -0
  258. package/dist/render/core/layout-elements.d.ts +1 -0
  259. package/dist/render/core/layout-elements.js +78 -0
  260. package/dist/render/core/localpath.d.ts +6 -0
  261. package/dist/render/core/localpath.js +73 -0
  262. package/dist/render/core/money.d.ts +1 -0
  263. package/dist/render/core/money.js +39 -0
  264. package/dist/render/core/number.d.ts +17 -0
  265. package/dist/render/core/number.js +104 -0
  266. package/dist/render/core/period.d.ts +1 -0
  267. package/dist/render/core/period.js +60 -0
  268. package/dist/render/core/range.d.ts +1 -0
  269. package/dist/render/core/range.js +55 -0
  270. package/dist/render/core/reminder.d.ts +2 -0
  271. package/dist/render/core/reminder.js +56 -0
  272. package/dist/render/core/source.d.ts +3 -0
  273. package/dist/render/core/source.js +65 -0
  274. package/dist/render/core/stepper.d.ts +1 -0
  275. package/dist/render/core/stepper.js +81 -0
  276. package/dist/render/core/storage-group.d.ts +1 -0
  277. package/dist/render/core/storage-group.js +30 -0
  278. package/dist/render/core/text.d.ts +15 -0
  279. package/dist/render/core/text.js +370 -0
  280. package/dist/render/core/tristate.d.ts +1 -0
  281. package/dist/render/core/tristate.js +42 -0
  282. package/dist/render/core/weight.d.ts +4 -0
  283. package/dist/render/core/weight.js +38 -0
  284. package/dist/render/dispatch.d.ts +12 -0
  285. package/dist/render/dispatch.js +53 -0
  286. package/dist/render/display-override.d.ts +25 -0
  287. package/dist/render/display-override.js +23 -0
  288. package/dist/render/editor-mode.d.ts +4 -0
  289. package/dist/render/editor-mode.js +11 -0
  290. package/dist/render/field-address.d.ts +14 -0
  291. package/dist/render/field-address.js +10 -0
  292. package/dist/render/field-errors.d.ts +8 -0
  293. package/dist/render/field-errors.js +25 -0
  294. package/dist/render/field-frame.d.ts +20 -0
  295. package/dist/render/field-frame.js +78 -0
  296. package/dist/render/field-scope.d.ts +8 -0
  297. package/dist/render/field-scope.js +25 -0
  298. package/dist/render/field-width.d.ts +7 -0
  299. package/dist/render/field-width.js +12 -0
  300. package/dist/render/form-types.d.ts +12 -0
  301. package/dist/render/form-types.js +1 -0
  302. package/dist/render/hybrid-scope.d.ts +5 -0
  303. package/dist/render/hybrid-scope.js +9 -0
  304. package/dist/render/image.d.ts +64 -0
  305. package/dist/render/image.js +322 -0
  306. package/dist/render/live-kind.d.ts +7 -0
  307. package/dist/render/live-kind.js +104 -0
  308. package/dist/render/markdown-view.d.ts +5 -0
  309. package/dist/render/markdown-view.js +17 -0
  310. package/dist/render/multi.d.ts +10 -0
  311. package/dist/render/multi.js +26 -0
  312. package/dist/render/multiple-chips.d.ts +24 -0
  313. package/dist/render/multiple-chips.js +18 -0
  314. package/dist/render/option-list.d.ts +15 -0
  315. package/dist/render/option-list.js +47 -0
  316. package/dist/render/option-value.d.ts +20 -0
  317. package/dist/render/option-value.js +41 -0
  318. package/dist/render/picker-scrim.d.ts +7 -0
  319. package/dist/render/picker-scrim.js +32 -0
  320. package/dist/render/picker-surface.d.ts +5 -0
  321. package/dist/render/picker-surface.js +9 -0
  322. package/dist/render/popover-field.d.ts +16 -0
  323. package/dist/render/popover-field.js +153 -0
  324. package/dist/render/record-save-ctx.d.ts +11 -0
  325. package/dist/render/record-save-ctx.js +41 -0
  326. package/dist/render/shared.d.ts +92 -0
  327. package/dist/render/shared.js +182 -0
  328. package/dist/render/slot.d.ts +45 -0
  329. package/dist/render/slot.js +194 -0
  330. package/dist/render/sort-rows.d.ts +3 -0
  331. package/dist/render/sort-rows.js +38 -0
  332. package/dist/render/use-collection-rows.d.ts +10 -0
  333. package/dist/render/use-collection-rows.js +11 -0
  334. package/dist/render/use-field-edit.d.ts +28 -0
  335. package/dist/render/use-field-edit.js +50 -0
  336. package/dist/render/use-file-upload.d.ts +10 -0
  337. package/dist/render/use-file-upload.js +35 -0
  338. package/dist/render/use-form-bridge.d.ts +21 -0
  339. package/dist/render/use-form-bridge.js +53 -0
  340. package/dist/render/use-hybrid.d.ts +2 -0
  341. package/dist/render/use-hybrid.js +5 -0
  342. package/dist/render/widgets/attachment-group.d.ts +1 -0
  343. package/dist/render/widgets/attachment-group.js +35 -0
  344. package/dist/render/widgets/checklist-content.d.ts +15 -0
  345. package/dist/render/widgets/checklist-content.js +12 -0
  346. package/dist/render/widgets/checklist-group.d.ts +11 -0
  347. package/dist/render/widgets/checklist-group.js +47 -0
  348. package/dist/render/widgets/checklist-row.d.ts +14 -0
  349. package/dist/render/widgets/checklist-row.js +14 -0
  350. package/dist/render/widgets/display.d.ts +33 -0
  351. package/dist/render/widgets/display.js +97 -0
  352. package/dist/render/widgets/edit.d.ts +63 -0
  353. package/dist/render/widgets/edit.js +283 -0
  354. package/dist/render/widgets/fixed-collection.d.ts +11 -0
  355. package/dist/render/widgets/fixed-collection.js +34 -0
  356. package/dist/render/widgets/flow-row.d.ts +14 -0
  357. package/dist/render/widgets/flow-row.js +27 -0
  358. package/dist/render/widgets/group-edit.d.ts +9 -0
  359. package/dist/render/widgets/group-edit.js +23 -0
  360. package/dist/render/widgets/group-field.d.ts +9 -0
  361. package/dist/render/widgets/group-field.js +42 -0
  362. package/dist/render/widgets/group-widgets.d.ts +2 -0
  363. package/dist/render/widgets/group-widgets.js +41 -0
  364. package/dist/render/widgets/group.d.ts +26 -0
  365. package/dist/render/widgets/group.js +139 -0
  366. package/dist/render/widgets/illustrated-group.d.ts +1 -0
  367. package/dist/render/widgets/illustrated-group.js +41 -0
  368. package/dist/render/widgets/table-group.d.ts +11 -0
  369. package/dist/render/widgets/table-group.js +58 -0
  370. package/dist/render/widgets/two-cell-group.d.ts +21 -0
  371. package/dist/render/widgets/two-cell-group.js +42 -0
  372. package/dist/render/widgets/url-widget.d.ts +7 -0
  373. package/dist/render/widgets/url-widget.js +15 -0
  374. package/dist/render/widgets/weekday-grid.d.ts +13 -0
  375. package/dist/render/widgets/weekday-grid.js +47 -0
  376. package/dist/render/write.d.ts +5 -0
  377. package/dist/render/write.js +14 -0
  378. package/dist/schema-registry.d.ts +6 -0
  379. package/dist/schema-registry.js +25 -0
  380. package/dist/site-links.d.ts +13 -0
  381. package/dist/site-links.js +18 -0
  382. package/dist/strip-markdown.d.ts +1 -0
  383. package/dist/strip-markdown.js +11 -0
  384. package/dist/theme.css +189 -0
  385. package/dist/types.d.ts +84 -0
  386. package/dist/types.js +1 -0
  387. package/package.json +85 -0
@@ -0,0 +1,370 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React, { Suspense, lazy } from 'react';
3
+ import { Input } from "../../components/ui/input.js";
4
+ import { Button } from "../../components/ui/button.js";
5
+ import { Popover, PopoverContent, PopoverTrigger } from "../../components/ui/popover.js";
6
+ import { Textarea } from "../../components/ui/textarea.js";
7
+ import { Icon } from "../../components/Icon.js";
8
+ import { darkTheme } from '@uiw/react-json-view/dark';
9
+ import { lightTheme } from '@uiw/react-json-view/light';
10
+ import { MaskInput } from "../../components/ui/mask-input.js";
11
+ import { OptionIconView } from "../../components/ui/option-icon.js";
12
+ import { registerRenderer } from "../../registry.js";
13
+ import { hasOptions } from '@coffer-org/sdk/fields';
14
+ import { MultiTagInput, MultipleChips, useTranslation, Dash, hasValue, trunc, parseStrArray, multiView, orDash, } from "../shared.js";
15
+ import { parseJSON } from "../../lib/json.js";
16
+ import { stripMarkdown } from "../../strip-markdown.js";
17
+ import { optionLabel as fmtOptionLabel } from "../../lib/format.js";
18
+ import { OptionValue, OptionInput, optionChipProps, optionKeys } from "../option-value.js";
19
+ import { FieldFrame } from "../field-frame.js";
20
+ import { MarkdownView } from "../markdown-view.js";
21
+ const MarkdownEditor = lazy(() => import("../../MarkdownEditor.js"));
22
+ let markdownEditorWarm;
23
+ function warmMarkdownEditor() {
24
+ markdownEditorWarm ??= import("../../MarkdownEditor.js");
25
+ }
26
+ const CodeEditor = lazy(() => import('@uiw/react-textarea-code-editor'));
27
+ const JsonView = lazy(() => import('@uiw/react-json-view'));
28
+ const HexColorPicker = lazy(() => import('react-colorful').then((m) => ({ default: m.HexColorPicker })));
29
+ const PhoneInput = lazy(() => import("../../components/ui/phone-input.js").then((m) => ({ default: m.PhoneInput })));
30
+ const EXTRA_MASKS = {
31
+ iban: {
32
+ pattern: '#### #### #### #### #### #### #### ##',
33
+ transform: (v) => v.replace(/[^a-z0-9]/gi, '').toUpperCase(),
34
+ },
35
+ };
36
+ function TextInput({ name, field, value, onChange, selectOptions, excludeValues }) {
37
+ const h = field.hints;
38
+ const inputType = h.inputType ?? 'text';
39
+ if (hasOptions(field))
40
+ return (_jsx(OptionInput, { field: field, value: value, onChange: onChange, offered: selectOptions, exclude: excludeValues }));
41
+ if (h.multiple === true) {
42
+ return (_jsx(MultiTagInput, { value: value, onChange: onChange, renderInput: (v, set, add) => (_jsx(Input, { type: inputType, value: v, onChange: (e) => set(e.target.value), className: "flex-1", onKeyDown: (e) => {
43
+ if (e.key === 'Enter') {
44
+ e.preventDefault();
45
+ add();
46
+ }
47
+ } })) }));
48
+ }
49
+ const single = typeof value === 'string' ? value : String(value ?? '');
50
+ if (typeof h.mask === 'string') {
51
+ const maskDef = EXTRA_MASKS[h.mask] ?? h.mask;
52
+ const storeUnmasked = h.maskStore === 'unmasked';
53
+ return (_jsx(MaskInput, { id: name, mask: maskDef, value: single, onValueChange: (masked, unmasked) => onChange(storeUnmasked ? unmasked : masked) }));
54
+ }
55
+ return (_jsx(Input, { id: name, type: inputType, value: single, onChange: (e) => onChange(e.target.value), minLength: h.minLength, maxLength: h.maxLength }));
56
+ }
57
+ function TextDisplay({ field, value }) {
58
+ return multiView(field, value, (i) => _jsx(PlainValue, { field: field, value: i }), undefined, optionChipProps(field));
59
+ }
60
+ function TextPage(p) {
61
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", bare: p.bare, view: (v) => _jsx(TextDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(TextInput, { name: `field-${p.field.label}`, field: p.field, value: value, onChange: onChange, selectOptions: p.selectOptions, excludeValues: p.excludeValues })) }));
62
+ }
63
+ function PlainValue({ field, value }) {
64
+ return _jsx(OptionValue, { field: field, value: value });
65
+ }
66
+ function TextInline({ field, value }) {
67
+ const { t } = useTranslation();
68
+ if (field.hints['multiple'] === true) {
69
+ const items = (Array.isArray(value) ? value : parseStrArray(value)).map((v) => fmtOptionLabel(t, field, v));
70
+ return _jsx("span", { className: "truncate", children: items.length ? items.join(', ') : '—' });
71
+ }
72
+ return _jsx("span", { className: "truncate", children: trunc(fmtOptionLabel(t, field, value)) });
73
+ }
74
+ registerRenderer({
75
+ kinds: ['text', 'email', 'slug', 'unit'],
76
+ Page: TextPage,
77
+ Inline: TextInline,
78
+ Value: PlainValue,
79
+ keys: optionKeys,
80
+ });
81
+ function TelPage(p) {
82
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", width: "w-48", bare: p.bare, view: (v) => (hasValue(v) ? _jsx("span", { children: String(v) }) : _jsx(Dash, {})), edit: (value, onChange) => (_jsx(Suspense, { fallback: _jsx("div", { className: "text-sm text-muted", children: "\u2026" }), children: _jsx(PhoneInput, { value: String(value), onChange: (v) => onChange(v ?? '') }) })) }));
83
+ }
84
+ function TelInline({ value }) {
85
+ return _jsx("span", { className: "truncate", children: trunc(String(value ?? '')) });
86
+ }
87
+ registerRenderer({
88
+ kinds: ['tel'],
89
+ Page: TelPage,
90
+ Inline: TelInline,
91
+ });
92
+ const hrefOf = (s) => (/^[a-z][a-z0-9+.-]*:\/\//i.test(s) ? s : `https://${s}`);
93
+ function LinkAnchor({ value }) {
94
+ const s = String(value ?? '');
95
+ if (!s)
96
+ return _jsx(Dash, {});
97
+ return (_jsx("a", { href: hrefOf(s), target: "_blank", rel: "noopener noreferrer", className: "inline-block max-w-full truncate align-bottom text-primary underline hover:text-primary/80 transition-colors", title: s, children: s }));
98
+ }
99
+ function LinkPage(p) {
100
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", bare: p.bare, view: (v) => _jsx(LinkAnchor, { value: v }), edit: (value, onChange) => (_jsx(Input, { type: "url", value: String(value), onChange: (e) => onChange(e.target.value) })) }));
101
+ }
102
+ registerRenderer({
103
+ kinds: ['link'],
104
+ Page: LinkPage,
105
+ Inline: ({ value }) => _jsx(LinkAnchor, { value: value }),
106
+ Value: ({ value }) => _jsx(LinkAnchor, { value: value }),
107
+ });
108
+ function PasswordInput({ name, field, value, onChange }) {
109
+ if (field.hints['multiple'] === true) {
110
+ return (_jsx(MultiTagInput, { value: value, onChange: onChange, display: () => '•••', renderInput: (v, set, add) => (_jsx(Input, { type: "password", value: v, autoComplete: "new-password", onChange: (e) => set(e.target.value), className: "flex-1", onKeyDown: (e) => {
111
+ if (e.key === 'Enter') {
112
+ e.preventDefault();
113
+ add();
114
+ }
115
+ } })) }));
116
+ }
117
+ return (_jsx(Input, { id: name, type: "password", value: value, autoComplete: "current-password", onChange: (e) => onChange(e.target.value) }));
118
+ }
119
+ function PasswordDisplay({ field, value }) {
120
+ if (field.hints['multiple'] === true) {
121
+ return _jsx(MultipleChips, { items: parseJSON(value, []), content: () => '•••' });
122
+ }
123
+ return _jsx("span", { className: "text-muted text-sm select-none", children: "\u2022\u2022\u2022" });
124
+ }
125
+ function PasswordPage(p) {
126
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", bare: p.bare, view: (v) => _jsx(PasswordDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(PasswordInput, { name: `field-${p.field.label}`, field: p.field, value: String(value), onChange: onChange })) }));
127
+ }
128
+ function PasswordInline() {
129
+ return _jsx("span", { children: "\u2022\u2022\u2022" });
130
+ }
131
+ registerRenderer({
132
+ kinds: ['password'],
133
+ Page: PasswordPage,
134
+ Inline: PasswordInline,
135
+ });
136
+ function TextareaPage(p) {
137
+ const maxLength = p.field.hints['maxLength'];
138
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "textarea", width: "w-full", bare: p.bare, view: (v) => {
139
+ if (!hasValue(v))
140
+ return _jsx(Dash, {});
141
+ return _jsx("p", { className: "text-[15px] text-text/90 leading-relaxed whitespace-pre-wrap", children: String(v) });
142
+ }, edit: (value, onChange) => (_jsx(Textarea, { id: `field-${p.field.label}`, value: String(value), maxLength: maxLength, onChange: (e) => onChange(e.target.value) })) }));
143
+ }
144
+ function TextareaInline({ value }) {
145
+ return _jsx("span", { className: "truncate", children: trunc(String(value ?? '')) });
146
+ }
147
+ registerRenderer({
148
+ kinds: ['textarea'],
149
+ layout: 'block',
150
+ box: 'textarea',
151
+ Page: TextareaPage,
152
+ Inline: TextareaInline,
153
+ });
154
+ registerRenderer({
155
+ kinds: ['smalltext'],
156
+ Page: TextareaPage,
157
+ Inline: TextareaInline,
158
+ });
159
+ function I18nPage(p) {
160
+ const { t } = useTranslation();
161
+ const maxLength = p.field.hints['maxLength'];
162
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "textarea", width: "w-full", bare: p.bare, view: (v) => {
163
+ if (!hasValue(v))
164
+ return _jsx(Dash, {});
165
+ const s = String(v);
166
+ return (_jsx("p", { className: "text-[15px] text-text/90 leading-relaxed whitespace-pre-wrap", children: t(s, { defaultValue: s }) }));
167
+ }, edit: (value, onChange) => (_jsx(Textarea, { id: `field-${p.field.label}`, value: String(value), maxLength: maxLength, onChange: (e) => onChange(e.target.value) })) }));
168
+ }
169
+ function I18nInline({ value }) {
170
+ const { t } = useTranslation();
171
+ const s = String(value ?? '');
172
+ return _jsx("span", { className: "truncate", children: trunc(t(s, { defaultValue: s })) });
173
+ }
174
+ registerRenderer({
175
+ kinds: ['i18n'],
176
+ layout: 'block',
177
+ box: 'textarea',
178
+ Page: I18nPage,
179
+ Inline: I18nInline,
180
+ });
181
+ function MarkdownInput({ value, onChange }) {
182
+ const { t } = useTranslation();
183
+ return (_jsx("div", { className: "md-editor flex min-h-0 min-w-0 flex-1 flex-col", children: _jsx(Suspense, { fallback: _jsx("div", { className: "text-sm text-muted", children: "\u2026" }), children: _jsx(MarkdownEditor, { value: value, onChange: onChange, placeholder: t('form.mdPlaceholder') }) }) }));
184
+ }
185
+ function MarkdownDisplay({ value }) {
186
+ return orDash(value, (v) => _jsx(MarkdownView, { value: String(v) }));
187
+ }
188
+ function MarkdownPage(p) {
189
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "none", width: "w-full", bare: p.bare, view: (v) => (_jsx("div", { onPointerEnter: warmMarkdownEditor, onPointerDown: warmMarkdownEditor, onFocus: warmMarkdownEditor, children: _jsx(MarkdownDisplay, { field: p.field, value: v }) })), edit: (value, onChange) => (_jsx(MarkdownInput, { name: `field-${p.field.label}`, field: p.field, value: String(value), onChange: onChange })) }));
190
+ }
191
+ function MarkdownInline({ value }) {
192
+ const s = stripMarkdown(String(value ?? ''));
193
+ return _jsx("span", { className: "truncate", children: trunc(s) || '—' });
194
+ }
195
+ registerRenderer({
196
+ kinds: ['markdown'],
197
+ layout: 'block',
198
+ pickerSize: 'modal',
199
+ Page: MarkdownPage,
200
+ Inline: MarkdownInline,
201
+ });
202
+ function CodePage(p) {
203
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "none", width: "w-full", bare: p.bare, view: (v) => (_jsx("pre", { className: "min-w-0 min-h-32 text-[13px] leading-normal font-mono border border-transparent rounded-lg p-3 overflow-x-auto whitespace-pre-wrap text-text/90", children: hasValue(v) ? String(v) : _jsx(Dash, {}) })), edit: (value, onChange) => (_jsx("div", { "data-color-mode": "dark", className: "json-editor-wrap min-w-0", children: _jsx("div", { className: "rounded-xl overflow-hidden border border-border min-w-0", children: _jsx(Suspense, { fallback: _jsx("div", { className: "text-sm text-muted", children: "\u2026" }), children: _jsx(CodeEditor, { value: String(value), language: p.field.hints['language'] ?? 'text', onChange: (e) => onChange(e.target.value), padding: 12, style: {
204
+ fontFamily: 'ui-monospace, monospace',
205
+ fontSize: 13,
206
+ background: 'transparent',
207
+ minHeight: '8rem',
208
+ } }) }) }) })) }));
209
+ }
210
+ function CodeInline({ value }) {
211
+ return _jsx("span", { className: "truncate", children: trunc(String(value ?? '')) });
212
+ }
213
+ registerRenderer({
214
+ kinds: ['snippet'],
215
+ layout: 'block',
216
+ pickerSize: 'modal',
217
+ Page: CodePage,
218
+ Inline: CodeInline,
219
+ });
220
+ function jsonEditText(value) {
221
+ if (typeof value === 'string')
222
+ return value;
223
+ if (value == null)
224
+ return '';
225
+ return JSON.stringify(value, null, 2);
226
+ }
227
+ function JsonInput({ value, onChange }) {
228
+ let valid = true;
229
+ if (value.trim()) {
230
+ try {
231
+ JSON.parse(value);
232
+ }
233
+ catch {
234
+ valid = false;
235
+ }
236
+ }
237
+ return (_jsxs("div", { "data-color-mode": "dark", className: "json-editor-wrap min-w-0", children: [_jsx("div", { className: `rounded-xl overflow-hidden border min-w-0 ${valid ? 'border-border' : 'border-danger/60'}`, children: _jsx(Suspense, { fallback: _jsx("div", { className: "text-sm text-muted", children: "\u2026" }), children: _jsx(CodeEditor, { value: value, language: "json", placeholder: "{ }", onChange: (e) => onChange(e.target.value), padding: 12, style: {
238
+ fontFamily: 'ui-monospace, monospace',
239
+ fontSize: 13,
240
+ background: 'transparent',
241
+ minHeight: '8rem',
242
+ } }) }) }), !valid && (_jsxs("p", { className: "text-xs text-danger mt-1 flex items-center gap-1", children: [_jsx(Icon, { name: "lucide:alert-triangle", size: 12, className: "shrink-0" }), " JSON"] }))] }));
243
+ }
244
+ function JsonDisplay({ value }) {
245
+ if (value == null || value === '')
246
+ return _jsx("span", { className: "text-muted", children: "\u2014" });
247
+ let obj;
248
+ try {
249
+ obj = typeof value === 'object' ? value : JSON.parse(String(value));
250
+ }
251
+ catch {
252
+ obj = undefined;
253
+ }
254
+ const isDark = typeof document !== 'undefined' && document.documentElement.classList.contains('dark');
255
+ if (obj === null || typeof obj !== 'object') {
256
+ return (_jsx("pre", { className: "min-w-0 text-xs bg-surface border border-border rounded-lg p-3 overflow-x-auto text-muted font-mono", children: String(value) }));
257
+ }
258
+ return (_jsx("div", { className: "min-w-0 bg-surface border border-border rounded-lg p-3 overflow-x-auto font-mono text-xs", children: _jsx(Suspense, { fallback: _jsx("div", { className: "text-sm text-muted", children: "\u2026" }), children: _jsx(JsonView, { value: obj, style: { ...(isDark ? darkTheme : lightTheme), '--w-rjv-background-color': 'transparent' }, displayDataTypes: false, enableClipboard: true, collapsed: 2 }) }) }));
259
+ }
260
+ function JsonPage(p) {
261
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "none", width: "w-full", bare: p.bare, view: (v) => _jsx(JsonDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(JsonInput, { name: `field-${p.field.label}`, field: p.field, value: jsonEditText(value), onChange: onChange })) }));
262
+ }
263
+ registerRenderer({ kinds: ['json'], layout: 'block', pickerSize: 'modal', Page: JsonPage });
264
+ function colorChipContent(item) {
265
+ const str = String(item);
266
+ const valid = /^#[0-9a-fA-F]{6}$/.test(str);
267
+ return (_jsxs(_Fragment, { children: [valid && _jsx(OptionIconView, { icon: { kind: 'swatch', value: str }, size: "xs" }), _jsx("span", { className: "font-mono", children: str })] }));
268
+ }
269
+ function ColorPickerRow({ value, onChange, onEnter, }) {
270
+ const hex = /^#[0-9a-fA-F]{6}$/.test(value) ? value : '#000000';
271
+ return (_jsxs("div", { className: "flex min-h-9 items-center gap-2 pl-2", children: [_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", "aria-label": "pick color", className: "h-5 w-5 shrink-0 cursor-pointer rounded-full border border-border", style: { background: hex } }) }), _jsx(PopoverContent, { className: "w-auto p-2", children: _jsx(Suspense, { fallback: _jsx("div", { className: "flex h-[200px] w-[200px] items-center justify-center text-sm text-muted", children: "\u2026" }), children: _jsx(HexColorPicker, { color: hex, onChange: onChange }) }) })] }), _jsx(Input, { value: value, onChange: (e) => onChange(e.target.value), pattern: "#[0-9a-fA-F]{6}", maxLength: 7, className: "h-auto w-28 border-0 bg-transparent p-0 font-mono text-sm shadow-none focus-visible:ring-0", placeholder: "#000000", onKeyDown: onEnter
272
+ ? (e) => {
273
+ if (e.key !== 'Enter')
274
+ return;
275
+ e.preventDefault();
276
+ onEnter();
277
+ }
278
+ : undefined })] }));
279
+ }
280
+ export function ColorInput({ value, onChange, field }) {
281
+ if (field.hints['multiple'] === true) {
282
+ return (_jsx(MultiTagInput, { value: value, onChange: onChange, validate: (v) => /^#[0-9a-fA-F]{6}$/.test(v), display: colorChipContent, renderInput: (v, set, add) => _jsx(ColorPickerRow, { value: v, onChange: set, onEnter: add }) }));
283
+ }
284
+ return _jsx(ColorPickerRow, { value: typeof value === 'string' ? value : '', onChange: onChange });
285
+ }
286
+ function ColorValue({ value }) {
287
+ return _jsx(_Fragment, { children: colorChipContent(value) });
288
+ }
289
+ function ColorSwatches({ field, items }) {
290
+ const { t } = useTranslation();
291
+ const named = hasOptions(field);
292
+ return (_jsx("div", { className: "flex flex-wrap gap-2", children: items.map((item, idx) => {
293
+ const hex = String(item);
294
+ const valid = /^#[0-9a-fA-F]{6}$/.test(hex);
295
+ const name = named ? fmtOptionLabel(t, field, hex) : '';
296
+ return (_jsxs("figure", { className: "w-24 overflow-hidden rounded-xl border border-border", title: hex, children: [_jsx("div", { className: valid ? 'h-16 w-full' : 'h-16 w-full bg-elevated', style: valid ? { backgroundColor: hex } : undefined }), _jsxs("figcaption", { className: "flex flex-col bg-surface px-2 py-1 leading-tight", children: [name && name !== hex && _jsx("span", { className: "truncate text-xs", children: name }), _jsx("span", { className: "truncate font-mono text-xs text-muted", children: hex })] })] }, idx));
297
+ }) }));
298
+ }
299
+ function ColorDisplay({ field, value }) {
300
+ if (field.hints['multiple'] === true) {
301
+ const items = parseJSON(value, []);
302
+ if (!items.length)
303
+ return _jsx(Dash, {});
304
+ return _jsx(ColorSwatches, { field: field, items: items });
305
+ }
306
+ const hex = String(value);
307
+ if (!hex || !/^#[0-9a-fA-F]{6}$/.test(hex))
308
+ return _jsx(Dash, {});
309
+ return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(OptionIconView, { icon: { kind: 'swatch', value: hex }, size: "md" }), _jsx("span", { className: "font-mono text-sm", children: hex })] }));
310
+ }
311
+ function ColorPage(p) {
312
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", width: "w-fit", bare: p.bare, view: (v) => _jsx(ColorDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(ColorInput, { name: `field-${p.field.label}`, field: p.field, value: value, onChange: onChange })) }));
313
+ }
314
+ function ColorPickerBody({ draft, setDraft, save, remove, removeLabel }) {
315
+ const { t } = useTranslation();
316
+ const raw = typeof draft === 'string' ? draft : '';
317
+ const hex = /^#[0-9a-fA-F]{6}$/.test(raw) ? raw : '#000000';
318
+ return (_jsxs("div", { className: "flex min-w-0 flex-col gap-2", children: [_jsx(Suspense, { fallback: _jsx("div", { className: "flex h-40 items-center justify-center text-sm text-muted", children: "\u2026" }), children: _jsx(HexColorPicker, { color: hex, onChange: setDraft, style: { width: '100%' } }) }), _jsx(Input, { value: raw, onChange: (e) => setDraft(e.target.value), pattern: "#[0-9a-fA-F]{6}", maxLength: 7, placeholder: "#000000", className: "font-mono text-sm" }), _jsxs("div", { className: "flex items-center justify-end gap-2 border-t border-border pt-2", children: [remove && (_jsx(Button, { type: "button", variant: "destructiveOutline", size: "sm", className: "mr-auto", onClick: remove, children: removeLabel ?? t('actions.delete') })), _jsx(Button, { type: "button", size: "sm", onClick: () => save(), children: t('actions.save') })] })] }));
319
+ }
320
+ registerRenderer({ kinds: ['color'], Page: ColorPage, Value: ColorValue, Picker: ColorPickerBody });
321
+ function TagInput({ value, onChange, field }) {
322
+ const { t } = useTranslation();
323
+ const suggestions = field.hints['suggestions'];
324
+ const datalistId = React.useId();
325
+ const datalist = (taken) => suggestions && suggestions.length > 0 ? (_jsx("datalist", { id: datalistId, children: suggestions
326
+ .filter((s) => !taken.includes(s))
327
+ .map((s) => (_jsx("option", { value: s }, s))) })) : null;
328
+ if (field.hints['multiple'] === true) {
329
+ const items = parseStrArray(value);
330
+ return (_jsx(MultiTagInput, { value: value, onChange: onChange, renderInput: (v, set, add) => (_jsxs(_Fragment, { children: [datalist(items), _jsx(Input, { value: v, list: suggestions?.length ? datalistId : undefined, onChange: (e) => set(e.target.value), onKeyDown: (e) => {
331
+ if (e.key === 'Enter') {
332
+ e.preventDefault();
333
+ add();
334
+ }
335
+ }, placeholder: t('form.addTag'), className: "flex-1" })] })) }));
336
+ }
337
+ const single = typeof value === 'string' ? value : String(value ?? '');
338
+ return (_jsxs(_Fragment, { children: [datalist(single ? [single] : []), _jsx(Input, { value: single, list: suggestions?.length ? datalistId : undefined, onChange: (e) => onChange(e.target.value) })] }));
339
+ }
340
+ function TagDisplay({ field, value }) {
341
+ const items = field.hints['multiple'] === true ? parseJSON(value, []) : value ? [String(value)] : [];
342
+ return _jsx(MultipleChips, { items: items, content: (t) => String(t) });
343
+ }
344
+ function TagPage(p) {
345
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", bare: p.bare, view: (v) => _jsx(TagDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(TagInput, { name: `field-${p.field.label}`, field: p.field, value: value, onChange: onChange })) }));
346
+ }
347
+ function TagInline({ field, value }) {
348
+ if (field.hints['multiple'] === true) {
349
+ const a = parseStrArray(String(value ?? ''));
350
+ return _jsx("span", { className: "truncate", children: a.length ? String(a.length) : '—' });
351
+ }
352
+ return _jsx("span", { className: "truncate", children: trunc(String(value ?? '')) });
353
+ }
354
+ registerRenderer({
355
+ kinds: ['tag'],
356
+ Page: TagPage,
357
+ Inline: TagInline,
358
+ Value: PlainValue,
359
+ });
360
+ function TitlePage(p) {
361
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "title", bare: p.bare, view: (v) => hasValue(v) ? _jsx("span", { className: "text-[28px] font-bold text-text leading-tight", children: String(v) }) : _jsx(Dash, {}), edit: (value, onChange) => (_jsx("input", { id: `field-${p.field.label}`, value: String(value), onChange: (e) => onChange(e.target.value), style: { fontSize: '28px', padding: '4px 12px' }, className: "w-full rounded-lg border border-input bg-background font-bold text-text leading-tight outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring placeholder:text-muted/40", placeholder: "\u2026" })) }));
362
+ }
363
+ function TitleInline({ value }) {
364
+ return _jsx("span", { className: "truncate", children: trunc(String(value ?? '')) });
365
+ }
366
+ registerRenderer({
367
+ kinds: ['title'],
368
+ Page: TitlePage,
369
+ Inline: TitleInline,
370
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
3
+ import { Check, Minus, X } from 'lucide-react';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { registerRenderer } from "../../registry.js";
6
+ import { cn } from "../../lib/utils.js";
7
+ import { FieldFrame } from "../field-frame.js";
8
+ import { OptionList } from "../option-list.js";
9
+ import { useRecordSave } from "../record-save-ctx.js";
10
+ const CYCLE = { unknown: 'yes', yes: 'no', no: 'unknown' };
11
+ const CHECKED = { yes: true, no: false, unknown: 'indeterminate' };
12
+ const ORDER = ['yes', 'no', 'unknown'];
13
+ function TriCheckbox({ value, onChange, label }) {
14
+ const { saving } = useRecordSave();
15
+ const cur = (value || 'unknown');
16
+ return (_jsx(CheckboxPrimitive.Root, { checked: CHECKED[cur], disabled: saving, onCheckedChange: () => onChange?.(CYCLE[cur]), "aria-label": label, className: cn('peer h-4.5 w-4.5 shrink-0 rounded border border-input bg-background ring-offset-background transition-colors', 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground', 'data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground'), children: _jsx(CheckboxPrimitive.Indicator, { className: "flex items-center justify-center text-current", children: cur === 'yes' ? (_jsx(Check, { className: "h-3.5 w-3.5", strokeWidth: 3 })) : (_jsx(Minus, { className: "h-3.5 w-3.5", strokeWidth: 3 })) }) }));
17
+ }
18
+ function TriStateValue({ value }) {
19
+ const v = String(value || 'unknown') ?? 'unknown';
20
+ const Ico = INLINE_ICON[v] ?? Minus;
21
+ return _jsx(Ico, { size: 16, className: v === 'yes' ? 'text-accent' : v === 'no' ? 'text-danger' : 'text-muted' });
22
+ }
23
+ function TriStatePicker({ draft, save }) {
24
+ const { t } = useTranslation();
25
+ return (_jsx(OptionList, { options: ORDER.map((v) => ({ value: v, title: t(`triState.${v}`) })), value: String(draft || 'unknown'), multiple: false, literal: true, search: false, onPick: (v) => save(v) }));
26
+ }
27
+ function TriStatePage(p) {
28
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", width: "w-32", bare: p.bare, view: (v) => _jsx(TriStateValue, { field: p.field, value: v }), edit: (v, onChange) => _jsx(TriCheckbox, { value: String(v ?? ''), onChange: onChange, label: p.label }) }));
29
+ }
30
+ const INLINE_ICON = { yes: Check, unknown: Minus, no: X };
31
+ function TriStateInline({ value }) {
32
+ const v = String(value ?? 'unknown');
33
+ const Ico = INLINE_ICON[v] ?? Minus;
34
+ return _jsx(Ico, { size: 16, className: v === 'yes' ? 'text-accent' : v === 'no' ? 'text-danger' : 'text-muted' });
35
+ }
36
+ registerRenderer({
37
+ kinds: ['triState'],
38
+ Page: TriStatePage,
39
+ Inline: TriStateInline,
40
+ Value: TriStateValue,
41
+ Picker: TriStatePicker,
42
+ });
@@ -0,0 +1,4 @@
1
+ export declare function weightParts(grams: number | null | undefined): {
2
+ n: number;
3
+ unit: 'g' | 'kg';
4
+ } | null;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Input } from "../../components/ui/input.js";
5
+ import { registerRenderer } from "../../registry.js";
6
+ import { FieldFrame } from "../field-frame.js";
7
+ import { Dash } from "../shared.js";
8
+ export function weightParts(grams) {
9
+ if (grams == null || grams === '' || Number.isNaN(Number(grams)))
10
+ return null;
11
+ const g = Number(grams);
12
+ return g < 1000 ? { n: g, unit: 'g' } : { n: Number((g / 1000).toFixed(2)), unit: 'kg' };
13
+ }
14
+ function WeightView({ value }) {
15
+ const { t } = useTranslation();
16
+ const p = weightParts(value);
17
+ if (!p)
18
+ return _jsx(Dash, {});
19
+ return (_jsxs("span", { className: "tabular-nums", children: [p.n, " ", t(`core.units.${p.unit}`)] }));
20
+ }
21
+ function ScaleToggle({ unit, onPick, label }) {
22
+ const { t } = useTranslation();
23
+ return (_jsx("div", { role: "radiogroup", "aria-label": label, className: "flex shrink-0 rounded-lg border border-border p-0.5", children: ['g', 'kg'].map((u) => (_jsx("button", { type: "button", role: "radio", "aria-checked": u === unit, onClick: () => onPick(u), className: `rounded-md px-2 py-1 text-xs transition-colors ${u === unit ? 'bg-accent/15 text-accent' : 'text-muted hover:text-fg'}`, children: t(`core.units.${u}`) }, u))) }));
24
+ }
25
+ function WeightInput({ value, onChange, label }) {
26
+ const g = value === '' ? '' : Number(value);
27
+ const [unit, setUnit] = useState(g !== '' && Number(g) >= 1000 ? 'kg' : 'g');
28
+ const shown = g === '' ? '' : unit === 'kg' ? Number(g) / 1000 : g;
29
+ const toGrams = (n) => Math.round(unit === 'kg' ? n * 1000 : n);
30
+ return (_jsxs("div", { className: "flex gap-2 min-w-0", children: [_jsx(Input, { type: "number", className: "flex-1 min-w-0", min: 0, value: shown, onChange: (e) => onChange(e.target.value === '' ? '' : String(toGrams(Number(e.target.value)))) }), _jsx(ScaleToggle, { unit: unit, onPick: setUnit, label: label })] }));
31
+ }
32
+ function WeightPage(p) {
33
+ return (_jsx(FieldFrame, { field: p.field, value: p.value, label: p.label, required: p.required, error: p.error, mode: p.mode, geom: "inline", width: "w-40", bare: p.bare, view: (v) => _jsx(WeightView, { value: v }), edit: (value, onChange) => (_jsx(WeightInput, { value: String(value ?? ''), onChange: onChange, label: p.label ?? '' })) }));
34
+ }
35
+ function WeightInline({ value }) {
36
+ return _jsx(WeightView, { value: value });
37
+ }
38
+ registerRenderer({ kinds: ['weight'], Page: WeightPage, Inline: WeightInline });
@@ -0,0 +1,12 @@
1
+ import { type FieldMeta } from '@coffer-org/sdk/fields';
2
+ import type { FieldRenderProps, FieldKey, FieldKeyCtx } from '../types.ts';
3
+ export declare function FieldSlot(p: FieldRenderProps & {
4
+ extId?: string;
5
+ onChange?: (v: unknown) => void | Promise<string | undefined>;
6
+ }): import("react").JSX.Element;
7
+ export declare function FieldCell({ field, value, height }: {
8
+ field: FieldMeta;
9
+ value: unknown;
10
+ height?: number;
11
+ }): import("react").JSX.Element;
12
+ export declare function fieldKeys(field: FieldMeta, value: unknown, ctx: FieldKeyCtx): FieldKey[];
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { wrapKey } from '@coffer-org/sdk/fields';
4
+ import { resolveRenderer } from "../registry.js";
5
+ import { parseTagValues, isMultiValued } from "../lib/multi-value.js";
6
+ import { FieldAddressProvider } from "./field-address.js";
7
+ import { SlotProvider } from "./slot.js";
8
+ export function FieldSlot(p) {
9
+ const { onChange, ...rest } = p;
10
+ const r = resolveRenderer(p.field);
11
+ const node = useMemo(() => {
12
+ if (p.el)
13
+ return p.el;
14
+ if (p.fieldKey === undefined)
15
+ return undefined;
16
+ return wrapKey(p.fieldKey, {}, p.field);
17
+ }, [p.el, p.fieldKey, p.field]);
18
+ if (!r) {
19
+ console.warn('[render] no renderer for', p.field.kind);
20
+ return _jsx("span", { children: String(p.value) });
21
+ }
22
+ const page = _jsx(r.Page, { ...rest });
23
+ return (_jsx(FieldAddressProvider, { fieldKey: p.fieldKey, extId: p.extId, recordCtx: p.recordCtx, children: node ? (_jsx(SlotProvider, { field: node, value: p.value, commit: onChange, mode: p.mode, children: page })) : (page) }));
24
+ }
25
+ export function FieldCell({ field, value, height }) {
26
+ const r = resolveRenderer(field);
27
+ const inner = r?.Inline ? (_jsx(r.Inline, { field: field, value: value, height: height })) : (_jsx("span", { className: "truncate", children: String(value ?? '') }));
28
+ if (!height)
29
+ return inner;
30
+ return (_jsx("span", { className: "inline-flex min-w-0 items-center font-medium", style: { fontSize: Math.round(height * 0.7), lineHeight: 1.15 }, children: inner }));
31
+ }
32
+ export function fieldKeys(field, value, ctx) {
33
+ const r = resolveRenderer(field);
34
+ const one = (v) => {
35
+ if (r?.keys)
36
+ return r.keys(v, field, ctx);
37
+ if (v == null || v === '')
38
+ return [];
39
+ return [{ value: String(v), rawValue: v, label: String(v) }];
40
+ };
41
+ const elems = isMultiValued(field) ? parseTagValues(value) : [value];
42
+ const seen = new Set();
43
+ const out = [];
44
+ for (const e of elems) {
45
+ for (const k of one(e)) {
46
+ if (seen.has(k.value))
47
+ continue;
48
+ seen.add(k.value);
49
+ out.push(k);
50
+ }
51
+ }
52
+ return out;
53
+ }
@@ -0,0 +1,25 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { FieldMeta } from '@coffer-org/sdk/fields';
3
+ export type DisplayParams = {
4
+ value: unknown;
5
+ field: FieldMeta;
6
+ rendered: ReactNode;
7
+ label?: string;
8
+ renderedLabel: ReactNode;
9
+ };
10
+ export interface DisplayOverride {
11
+ (p: DisplayParams): ReactNode;
12
+ ownsLabel?: boolean;
13
+ }
14
+ export declare function DisplayOverrideProvider({ fn, children }: {
15
+ fn: DisplayOverride;
16
+ children: ReactNode;
17
+ }): import("react").JSX.Element;
18
+ export declare function DisplayOverrideReset({ children }: {
19
+ children: ReactNode;
20
+ }): import("react").JSX.Element;
21
+ export declare function useDisplayOverride(): DisplayOverride | undefined;
22
+ export declare function applyDisplay<A extends unknown[]>(view: (value: unknown, ...rest: A) => ReactNode, field: FieldMeta, override: DisplayOverride | undefined, chrome?: {
23
+ label?: string;
24
+ renderedLabel: ReactNode;
25
+ }): (value: unknown, ...rest: A) => ReactNode;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from 'react';
3
+ const DisplayOverrideContext = createContext(undefined);
4
+ export function DisplayOverrideProvider({ fn, children }) {
5
+ return _jsx(DisplayOverrideContext.Provider, { value: fn, children: children });
6
+ }
7
+ export function DisplayOverrideReset({ children }) {
8
+ return _jsx(DisplayOverrideContext.Provider, { value: undefined, children: children });
9
+ }
10
+ export function useDisplayOverride() {
11
+ return useContext(DisplayOverrideContext);
12
+ }
13
+ export function applyDisplay(view, field, override, chrome) {
14
+ if (!override)
15
+ return view;
16
+ return (value, ...rest) => override({
17
+ value,
18
+ field,
19
+ rendered: view(value, ...rest),
20
+ label: chrome?.label,
21
+ renderedLabel: chrome?.renderedLabel ?? null,
22
+ });
23
+ }
@@ -0,0 +1,4 @@
1
+ import type { FieldClient } from '@coffer-org/sdk/fields';
2
+ import type { EditorMode } from '../types.ts';
3
+ export type { EditorMode } from '../types.ts';
4
+ export declare function editorMode(field: Pick<FieldClient, 'kind' | 'hints'>): EditorMode;
@@ -0,0 +1,11 @@
1
+ import { resolveRenderer } from "../registry.js";
2
+ const MODES = new Set(['popover', 'modal', 'inplace', 'custom']);
3
+ function isEditorMode(v) {
4
+ return typeof v === 'string' && MODES.has(v);
5
+ }
6
+ export function editorMode(field) {
7
+ const override = field.hints?.['editor'];
8
+ if (isEditorMode(override))
9
+ return override;
10
+ return resolveRenderer(field)?.editor ?? 'popover';
11
+ }
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { RecordCtx } from '../types.ts';
3
+ export type FieldAddress = {
4
+ key?: string;
5
+ extId?: string;
6
+ recordCtx?: RecordCtx;
7
+ };
8
+ export declare function FieldAddressProvider({ fieldKey, extId, recordCtx, children, }: {
9
+ fieldKey?: string;
10
+ extId?: string;
11
+ recordCtx?: RecordCtx;
12
+ children: ReactNode;
13
+ }): import("react").JSX.Element;
14
+ export declare function useFieldAddress(): FieldAddress;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useMemo } from 'react';
3
+ const FieldAddressContext = createContext({});
4
+ export function FieldAddressProvider({ fieldKey, extId, recordCtx, children, }) {
5
+ const value = useMemo(() => ({ key: fieldKey, extId, recordCtx }), [fieldKey, extId, recordCtx]);
6
+ return _jsx(FieldAddressContext.Provider, { value: value, children: children });
7
+ }
8
+ export function useFieldAddress() {
9
+ return useContext(FieldAddressContext);
10
+ }
@@ -0,0 +1,8 @@
1
+ import type { ServerIssue } from '../host-services.ts';
2
+ export type ErrorAt = (path: (string | number)[]) => string | undefined;
3
+ export declare const FieldErrorsContext: import("react").Context<ErrorAt>;
4
+ export declare const useFieldErrors: () => ErrorAt;
5
+ export declare const pathKey: (path: (string | number)[]) => string;
6
+ export declare function makeIssueText(t: (k: string, params?: Record<string, unknown>) => string): (code: string, params?: Record<string, unknown>) => string;
7
+ export declare function mapIssues(issues: ServerIssue[], text: (code: string, params?: Record<string, unknown>) => string): Record<string, string>;
8
+ export declare function clearPrefix(errors: Record<string, string>, key: string): Record<string, string>;