@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,39 @@
1
+ import type { FieldMeta } from '@coffer-org/sdk/fields';
2
+ export declare function illustratedSlots(field: FieldMeta): {
3
+ tKey: string;
4
+ iKey: string;
5
+ };
6
+ export declare function illustratedLayout(field: FieldMeta): {
7
+ width: number;
8
+ side: 'left' | 'right';
9
+ };
10
+ export declare function illustratedImageKind(field: FieldMeta): string;
11
+ export declare function IllustratedPicture({ name, width, kind }: {
12
+ name: string;
13
+ width: number;
14
+ kind?: string;
15
+ }): import("react").JSX.Element;
16
+ export declare function IllustratedFloat({ width, side, picture, prose, }: {
17
+ width: number;
18
+ side: 'left' | 'right';
19
+ picture: React.ReactNode;
20
+ prose: React.ReactNode;
21
+ }): import("react").JSX.Element;
22
+ export declare function IllustratedBody({ field, value }: {
23
+ field: FieldMeta;
24
+ value: unknown;
25
+ }): import("react").JSX.Element;
26
+ export declare function IllustratedImageCell({ image, fixed, width, kind, onChange, }: {
27
+ image: unknown;
28
+ fixed: boolean;
29
+ width: number;
30
+ kind?: string;
31
+ onChange?: (v: unknown) => void;
32
+ }): import("react").JSX.Element;
33
+ export declare function IllustratedTextCell({ text, fixed, meta, label, onChange, }: {
34
+ text: unknown;
35
+ fixed: boolean;
36
+ meta: FieldMeta;
37
+ label?: string;
38
+ onChange?: (v: unknown) => void | Promise<string | undefined>;
39
+ }): import("react").JSX.Element;
@@ -0,0 +1,113 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { partValueKeys } from '@coffer-org/sdk/fields';
4
+ import { registerRenderer } from "../../registry.js";
5
+ import { Textarea } from "../../components/ui/textarea.js";
6
+ import { FieldFrame } from "../field-frame.js";
7
+ import { FieldLabel, FieldError } from "../chrome.js";
8
+ import { PopoverField } from "../popover-field.js";
9
+ import { Dash, compositeRoleValue, useCompositeLiveGate } from "../shared.js";
10
+ import { MarkdownView } from "../markdown-view.js";
11
+ import { Thumb, Lightbox, ImageWidget, parseFileRecs } from "../image.js";
12
+ const DEFAULT_WIDTH = 170;
13
+ export function illustratedSlots(field) {
14
+ const slots = partValueKeys(field.parts ?? []);
15
+ return { tKey: slots['text'] ?? 'text', iKey: slots['image'] ?? 'image' };
16
+ }
17
+ function parseIllustrated(v, field) {
18
+ const { tKey, iKey } = illustratedSlots(field);
19
+ const obj = v && typeof v === 'object' ? v : null;
20
+ if (!obj)
21
+ return {};
22
+ return { text: obj[tKey], image: obj[iKey] };
23
+ }
24
+ export function illustratedLayout(field) {
25
+ const config = (field.hints['config'] ?? {});
26
+ return { width: config.imageWidth ?? DEFAULT_WIDTH, side: config.side ?? 'left' };
27
+ }
28
+ export function illustratedImageKind(field) {
29
+ return field.parts?.find((p) => p.role === 'image')?.meta.kind ?? 'image';
30
+ }
31
+ const aspectFor = (kind) => (kind === 'poster' ? 'aspect-[2/3]' : 'aspect-square');
32
+ export function IllustratedPicture({ name, width, kind = 'image' }) {
33
+ const [open, setOpen] = useState(false);
34
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "data-testid": "illustrated-image", onClick: () => setOpen(true), style: { '--illus-w': `${width}px` }, className: `relative block ${aspectFor(kind)} w-full cursor-zoom-in overflow-hidden rounded-xl border border-border transition-colors hover:border-accent sm:w-(--illus-w)`, children: _jsx(Thumb, { name: name }) }), open && _jsx(Lightbox, { images: [name], index: 0, onClose: () => setOpen(false), onIndex: () => { } })] }));
35
+ }
36
+ export function IllustratedFloat({ width, side, picture, prose, }) {
37
+ return (_jsxs("div", { className: "min-w-0", children: [picture != null && (_jsx("div", { "data-testid": "illustrated-figure", style: { '--illus-w': `${width}px` }, className: `mb-3 w-full sm:mb-2 sm:w-(--illus-w) ${side === 'right' ? 'sm:float-right sm:ml-4' : 'sm:float-left sm:mr-4'}`, children: picture })), prose != null && _jsx("div", { className: "min-w-0", children: prose }), _jsx("div", { className: "clear-both" })] }));
38
+ }
39
+ export function IllustratedBody({ field, value }) {
40
+ const { text, image } = parseIllustrated(value, field);
41
+ const { width, side } = illustratedLayout(field);
42
+ const rec = image != null && image !== '' ? parseFileRecs(image)[0] : undefined;
43
+ const hasText = text != null && text !== '';
44
+ return (_jsx(IllustratedFloat, { width: width, side: side, picture: rec ? _jsx(IllustratedPicture, { name: rec.name, width: width, kind: illustratedImageKind(field) }) : null, prose: hasText ? (_jsx("div", { "data-testid": "illustrated-text", className: "min-w-0", children: _jsx(MarkdownView, { value: String(text) }) })) : null }));
45
+ }
46
+ function IllustratedInput({ field, value, onChange, }) {
47
+ const { tKey, iKey } = illustratedSlots(field);
48
+ const { text, image } = parseIllustrated(value, field);
49
+ const { width } = illustratedLayout(field);
50
+ const kind = illustratedImageKind(field);
51
+ const rec = image != null && image !== '' ? parseFileRecs(image)[0] : undefined;
52
+ const textPart = field.parts?.find((p) => p.role === 'text');
53
+ const textFixed = textPart != null && textPart.mode !== 'stored';
54
+ const imagePart = field.parts?.find((p) => p.role === 'image');
55
+ const imageFixed = imagePart != null && imagePart.mode !== 'stored';
56
+ const set = (next) => {
57
+ const t = compositeRoleValue(next.text);
58
+ const i = compositeRoleValue(next.image);
59
+ onChange(t == null && i == null ? '' : { [tKey]: t, [iKey]: i });
60
+ };
61
+ return (_jsxs("div", { className: "flex flex-col gap-3 min-w-0", children: [imageFixed ? (_jsx("div", { className: "text-sm text-muted", children: rec ? _jsx(IllustratedPicture, { name: rec.name, width: width, kind: kind }) : _jsx(Dash, {}) })) : (_jsx(ImageWidget, { value: image ?? '', onChange: (v) => set({ text, image: v }), width: width, poster: kind === 'poster' })), textFixed ? (_jsx("p", { className: "text-[15px] text-muted whitespace-pre-wrap", children: text != null && text !== '' ? String(text) : _jsx(Dash, {}) })) : (_jsx(Textarea, { id: `field-${field.label}`, value: text == null ? '' : String(text), onChange: (e) => set({ text: e.target.value, image }) }))] }));
62
+ }
63
+ export function IllustratedImageCell({ image, fixed, width, kind = 'image', onChange, }) {
64
+ const rec = image != null && image !== '' ? parseFileRecs(image)[0] : undefined;
65
+ if (fixed || !onChange) {
66
+ return (_jsx("div", { className: "text-sm text-muted", children: rec ? _jsx(IllustratedPicture, { name: rec.name, width: width, kind: kind }) : _jsx(Dash, {}) }));
67
+ }
68
+ return _jsx(ImageWidget, { value: image ?? '', onChange: onChange, width: width, poster: kind === 'poster' });
69
+ }
70
+ export function IllustratedTextCell({ text, fixed, meta, label, onChange, }) {
71
+ if (fixed || !onChange) {
72
+ return (_jsx("p", { className: "text-[15px] text-muted whitespace-pre-wrap", children: text != null && text !== '' ? String(text) : _jsx(Dash, {}) }));
73
+ }
74
+ const pickerField = { ...meta, kind: 'markdown', hints: { ...meta.hints, noLabel: true } };
75
+ return (_jsx(PopoverField, { field: pickerField, value: text ?? '', label: label, geom: "none", width: "w-full", view: (v) => (v != null && v !== '' ? _jsx(MarkdownView, { value: String(v) }) : _jsx(Dash, {})), edit: (v, set) => _jsx(Textarea, { value: v == null ? '' : String(v), onChange: (e) => set(e.target.value) }), onCommit: onChange }));
76
+ }
77
+ function IllustratedLive({ field, value, onChange, label, required, error, }) {
78
+ const { tKey, iKey } = illustratedSlots(field);
79
+ const { text, image } = parseIllustrated(value, field);
80
+ const { width, side } = illustratedLayout(field);
81
+ const kind = illustratedImageKind(field);
82
+ const textPart = field.parts?.find((p) => p.role === 'text');
83
+ const textFixed = textPart != null && textPart.mode !== 'stored';
84
+ const imagePart = field.parts?.find((p) => p.role === 'image');
85
+ const imageFixed = imagePart != null && imagePart.mode !== 'stored';
86
+ const noLabel = field.hints['noLabel'] === true || label === undefined;
87
+ const write = (nextText, nextImage) => {
88
+ const t = compositeRoleValue(nextText);
89
+ const i = compositeRoleValue(nextImage);
90
+ return onChange(t == null && i == null ? '' : { [tKey]: t, [iKey]: i });
91
+ };
92
+ return (_jsxs("div", { className: "group/field relative w-full", children: [!noLabel && _jsx(FieldLabel, { label: label, required: required }), _jsx(IllustratedFloat, { width: width, side: side, picture: _jsx(IllustratedImageCell, { image: image, fixed: imageFixed, width: width, kind: kind, onChange: imageFixed ? undefined : (v) => void write(text, v) }), prose: _jsx(IllustratedTextCell, { text: text, fixed: textFixed, meta: textPart?.meta ?? field, label: label, onChange: textFixed ? undefined : (v) => write(v, image) }) }), _jsx(FieldError, { error: error })] }));
93
+ }
94
+ function IllustratedPage(p) {
95
+ const { live, write } = useCompositeLiveGate(p);
96
+ if (live) {
97
+ return (_jsx(IllustratedLive, { field: p.field, value: p.value, onChange: write, label: p.label, required: p.required, error: p.error }));
98
+ }
99
+ 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(IllustratedBody, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(IllustratedInput, { field: p.field, value: value, onChange: onChange })) }));
100
+ }
101
+ function IllustratedInline({ field, value }) {
102
+ const { text } = parseIllustrated(value, field);
103
+ if (text == null || text === '')
104
+ return _jsx("span", { className: "text-muted", children: "\u2014" });
105
+ return _jsx("span", { className: "truncate", children: String(text) });
106
+ }
107
+ registerRenderer({
108
+ kinds: ['illustrated'],
109
+ layout: 'block',
110
+ Page: IllustratedPage,
111
+ Inline: IllustratedInline,
112
+ editor: 'custom',
113
+ });
@@ -0,0 +1,23 @@
1
+ import './text.tsx';
2
+ import './localpath.tsx';
3
+ import './number.tsx';
4
+ import './datetime.tsx';
5
+ import './choice.tsx';
6
+ import './illustrated.tsx';
7
+ import './attachment.tsx';
8
+ import './composite.tsx';
9
+ import './amount.tsx';
10
+ import './file.tsx';
11
+ import './period.tsx';
12
+ import './storage-group.tsx';
13
+ import '../widgets/group-widgets.tsx';
14
+ import './layout-elements.tsx';
15
+ import './tristate.tsx';
16
+ import './stepper.tsx';
17
+ import './money.tsx';
18
+ import './range.tsx';
19
+ import './source.tsx';
20
+ import './embed.tsx';
21
+ import './reminder.tsx';
22
+ import './weight.tsx';
23
+ import './dimensions.tsx';
@@ -0,0 +1,23 @@
1
+ import "./text.js";
2
+ import "./localpath.js";
3
+ import "./number.js";
4
+ import "./datetime.js";
5
+ import "./choice.js";
6
+ import "./illustrated.js";
7
+ import "./attachment.js";
8
+ import "./composite.js";
9
+ import "./amount.js";
10
+ import "./file.js";
11
+ import "./period.js";
12
+ import "./storage-group.js";
13
+ import "../widgets/group-widgets.js";
14
+ import "./layout-elements.js";
15
+ import "./tristate.js";
16
+ import "./stepper.js";
17
+ import "./money.js";
18
+ import "./range.js";
19
+ import "./source.js";
20
+ import "./embed.js";
21
+ import "./reminder.js";
22
+ import "./weight.js";
23
+ import "./dimensions.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,78 @@
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 { toast } from 'sonner';
5
+ import { registerRenderer } from "../../registry.js";
6
+ import { Button } from "../../components/ui/button.js";
7
+ import { Icon } from "../../components/Icon.js";
8
+ import { Dialog, DialogContent, DialogHeader } from "../../components/ui/dialog.js";
9
+ import { resolveAction } from "../../actions/registry.js";
10
+ import { TemplateHost } from "../../actions/TemplateHost.js";
11
+ import { PopupBody } from "../../actions/PopupBody.js";
12
+ import { SectionShell, LabelledDivider } from "../../layout.js";
13
+ import { groupIcon } from "../chrome.js";
14
+ import Markdown from "../../Markdown.js";
15
+ function DividerPage({ el }) {
16
+ const label = el?.label;
17
+ return label ? _jsx(LabelledDivider, { label: label }) : _jsx("hr", { className: "border-border" });
18
+ }
19
+ function InfoPage({ el }) {
20
+ const { t } = useTranslation();
21
+ return (_jsx("div", { className: "rounded-lg border border-border/60 bg-muted/15 px-4 py-3 text-sm text-text", children: _jsx(Markdown, { value: t(el.text) }) }));
22
+ }
23
+ function ButtonPage(props) {
24
+ const { t } = useTranslation();
25
+ const el = props.el;
26
+ const ctx = props.recordCtx;
27
+ const [loading, setLoading] = useState(false);
28
+ const [popup, setPopup] = useState(null);
29
+ const show = (ui) => {
30
+ if (ui.kind === 'popup') {
31
+ setPopup(ui);
32
+ return;
33
+ }
34
+ const body = ui.component ? (_jsx(TemplateHost, { name: ui.component.name, data: ui.component.data })) : (t(ui.message ?? '', ui.params));
35
+ if (ui.variant === 'success')
36
+ toast.success(body);
37
+ else if (ui.variant === 'error')
38
+ toast.error(body);
39
+ else
40
+ toast(body);
41
+ };
42
+ const run = async () => {
43
+ const handler = resolveAction(el.value);
44
+ if (!handler) {
45
+ toast.error(t('actions.actionNotFound'));
46
+ return;
47
+ }
48
+ setLoading(true);
49
+ try {
50
+ const res = await handler({ library: ctx.library, shelf: ctx.shelf, recordId: ctx.recordId ?? '' });
51
+ if (res)
52
+ show(res);
53
+ else
54
+ toast.success(t('actions.actionSuccess'));
55
+ }
56
+ catch (e) {
57
+ const ui = e.ui;
58
+ if (ui)
59
+ show(ui);
60
+ else
61
+ toast.error(e instanceof Error ? e.message : t('actions.actionError'));
62
+ }
63
+ finally {
64
+ setLoading(false);
65
+ }
66
+ };
67
+ return (_jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [_jsxs(Button, { variant: el.variant ?? 'outline', onClick: run, disabled: loading, className: "max-w-full min-w-0", children: [loading ? (_jsx("span", { className: "animate-spin inline-block w-4 h-4 border-2 border-current/30 border-t-current rounded-full" })) : (el.icon && _jsx(Icon, { name: el.icon, size: 16 })), _jsx("span", { className: "truncate", children: t(el.label) })] }), _jsx(Dialog, { open: !!popup, onOpenChange: (o) => !o && setPopup(null), children: _jsx(DialogContent, { children: _jsx(DialogHeader, { children: popup && _jsx(PopupBody, { ui: popup }) }) }) })] }));
68
+ }
69
+ function GroupPage({ el, children }) {
70
+ const { t } = useTranslation();
71
+ const g = el;
72
+ const label = g.label ? t(g.label) : undefined;
73
+ return (_jsx(SectionShell, { label: label, icon: groupIcon(g), children: children }));
74
+ }
75
+ registerRenderer({ kinds: ['divider'], layout: 'block', Page: DividerPage });
76
+ registerRenderer({ kinds: ['info'], layout: 'block', Page: InfoPage });
77
+ registerRenderer({ kinds: ['button'], layout: 'scalar', Page: ButtonPage });
78
+ registerRenderer({ kinds: ['group'], layout: 'block', Page: GroupPage, editor: 'custom' });
@@ -0,0 +1,6 @@
1
+ export declare function splitPath(input: string): {
2
+ dirPrefix: string;
3
+ partial: string;
4
+ };
5
+ export declare function joinPath(dir: string, name: string): string;
6
+ export declare function parentPath(dir: string): string;
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { Folder, FileText, ChevronRight, CornerLeftUp, Check, Eye, EyeOff } from 'lucide-react';
5
+ import { Input } from "../../components/ui/input.js";
6
+ import { Button } from "../../components/ui/button.js";
7
+ import { Popover, PopoverTrigger, PopoverContent } from "../../components/ui/popover.js";
8
+ import { ScrollArea } from "../../components/ui/scroll-area.js";
9
+ import { registerRenderer } from "../../registry.js";
10
+ import { listDir } from "../../host-services.js";
11
+ import { hasValue, trunc, Dash } from "../shared.js";
12
+ import { FieldFrame } from "../field-frame.js";
13
+ export function splitPath(input) {
14
+ const i = input.lastIndexOf('/');
15
+ if (i < 0)
16
+ return { dirPrefix: '', partial: input };
17
+ return { dirPrefix: input.slice(0, i), partial: input.slice(i + 1) };
18
+ }
19
+ export function joinPath(dir, name) {
20
+ return `${dir.replace(/\/+$/, '')}/${name}`;
21
+ }
22
+ export function parentPath(dir) {
23
+ const d = dir.replace(/\/+$/, '');
24
+ const i = d.lastIndexOf('/');
25
+ if (i < 0)
26
+ return '~';
27
+ return d.slice(0, i) || '/';
28
+ }
29
+ function PathBrowser({ dirsOnly, exts, initialDir, onPick, }) {
30
+ const { t } = useTranslation();
31
+ const [dir, setDir] = useState(initialDir || '~');
32
+ const [entries, setEntries] = useState([]);
33
+ const [showHidden, setShowHidden] = useState(false);
34
+ const [failed, setFailed] = useState(false);
35
+ useEffect(() => {
36
+ let off = false;
37
+ setFailed(false);
38
+ listDir(dir, !dirsOnly ? exts : undefined)
39
+ .then((es) => {
40
+ if (!off)
41
+ setEntries(es);
42
+ })
43
+ .catch((error) => {
44
+ if (off)
45
+ return;
46
+ console.error('[localpath] listDir failed:', error);
47
+ setEntries([]);
48
+ setFailed(true);
49
+ });
50
+ return () => {
51
+ off = true;
52
+ };
53
+ }, [dir, dirsOnly, exts]);
54
+ const visible = entries.filter((e) => (dirsOnly ? e.isDir : true) && (showHidden || !e.name.startsWith('.')));
55
+ return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex items-center gap-1.5", children: [_jsx(Button, { variant: "ghost", size: "iconSm", onClick: () => setDir(parentPath(dir)), "aria-label": "up", disabled: dir === '~' || dir === '/', children: _jsx(CornerLeftUp, { size: 15 }) }), _jsx("span", { className: "flex-1 truncate font-mono text-xs text-muted", title: dir, children: dir }), _jsx(Button, { variant: "ghost", size: "iconSm", onClick: () => setShowHidden((v) => !v), "aria-label": "hidden", title: showHidden ? 'Hide dotfiles' : 'Show dotfiles', children: showHidden ? _jsx(Eye, { size: 15 }) : _jsx(EyeOff, { size: 15 }) })] }), _jsx(ScrollArea, { className: "h-56 -mx-1 px-1", children: _jsxs("div", { className: "flex flex-col", children: [failed ? (_jsx("span", { className: "px-2 py-3 text-xs text-danger", children: t('localpath.listFailed') })) : (visible.length === 0 && _jsx("span", { className: "px-2 py-3 text-xs text-muted", children: "\u2014" })), visible.map((e) => (_jsxs("div", { className: "group flex items-center rounded-md hover:bg-elevated", children: [_jsxs("button", { type: "button", className: "flex min-w-0 flex-1 items-center gap-2 px-2 py-1.5 text-left text-sm", onClick: () => (e.isDir ? setDir(joinPath(dir, e.name)) : onPick(joinPath(dir, e.name), false)), children: [e.isDir ? (_jsx(Folder, { size: 15, className: "shrink-0 text-muted" })) : (_jsx(FileText, { size: 15, className: "shrink-0 text-muted" })), _jsx("span", { className: "truncate", children: e.name }), e.isDir && (_jsx(ChevronRight, { size: 14, className: "ml-auto shrink-0 text-muted opacity-0 group-hover:opacity-100" }))] }), dirsOnly && e.isDir && (_jsx(Button, { variant: "ghost", size: "iconSm", className: "mr-1", onClick: () => onPick(joinPath(dir, e.name), true), "aria-label": "select", title: "Select folder", children: _jsx(Check, { size: 15 }) }))] }, e.name)))] }) }), dirsOnly && (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => onPick(dir, true), children: [_jsx(Check, { size: 14 }), " Choose this directory"] }))] }));
56
+ }
57
+ function LocalPathInput({ name, field, value, onChange, }) {
58
+ const dirsOnly = field.kind === 'localDir';
59
+ const exts = field.hints['exts'];
60
+ const [open, setOpen] = useState(false);
61
+ return (_jsxs("div", { className: "flex items-stretch gap-1.5", children: [_jsx(Input, { id: name, value: value, onChange: (e) => onChange(e.target.value), placeholder: "~/\u2026", spellCheck: false, autoComplete: "off" }), _jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "outline", size: "icon", "aria-label": "browse", children: _jsx(Folder, { size: 16 }) }) }), _jsx(PopoverContent, { align: "end", className: "w-80 p-3", children: open && (_jsx(PathBrowser, { dirsOnly: dirsOnly, exts: exts, initialDir: splitPath(value).dirPrefix || '~', onPick: (path, isDir) => {
62
+ onChange(isDir ? `${path.replace(/\/+$/, '')}/` : path);
63
+ if (!isDir)
64
+ setOpen(false);
65
+ } })) })] })] }));
66
+ }
67
+ function PathPage(p) {
68
+ 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) => (hasValue(v) ? _jsx("span", { className: "font-mono text-sm break-all", children: String(v) }) : _jsx(Dash, {})), edit: (value, onChange) => (_jsx(LocalPathInput, { name: `field-${p.field.label}`, field: p.field, value: String(value), onChange: onChange })) }));
69
+ }
70
+ function PathInline({ value }) {
71
+ return _jsx("span", { className: "font-mono truncate", children: trunc(String(value ?? '')) });
72
+ }
73
+ registerRenderer({ kinds: ['localDir', 'localFile'], Page: PathPage, Inline: PathInline });
@@ -0,0 +1 @@
1
+ export declare function fmtMoney(value: unknown, currency?: string): string;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { NumericFormat } from 'react-number-format';
3
+ import { currencySymbol } from '@coffer-org/sdk/currencies';
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
+ function currencyOf(field) {
9
+ const c = field.hints['currencyValue'];
10
+ return typeof c === 'string' && c ? c : undefined;
11
+ }
12
+ export function fmtMoney(value, currency) {
13
+ if (value == null || value === '' || Number.isNaN(Number(value)))
14
+ return '';
15
+ const n = Number(value);
16
+ if (!currency)
17
+ return new Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(n);
18
+ try {
19
+ return new Intl.NumberFormat(undefined, { style: 'currency', currency }).format(n);
20
+ }
21
+ catch {
22
+ return `${new Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(n)} ${currencySymbol(currency)}`;
23
+ }
24
+ }
25
+ function MoneyView({ value, field }) {
26
+ const s = fmtMoney(value, currencyOf(field));
27
+ return s ? _jsx("span", { className: "tabular-nums", children: s }) : _jsx(Dash, {});
28
+ }
29
+ function MoneyInput({ field, value, onChange }) {
30
+ const cur = currencyOf(field);
31
+ return (_jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [_jsx(NumericFormat, { customInput: Input, className: "flex-1 min-w-0", value: value == null || value === '' ? '' : Number(value), thousandSeparator: true, decimalScale: 2, min: field.hints['min'], max: field.hints['max'], placeholder: "0.00", onValueChange: (vals) => onChange(vals.value === '' ? '' : (vals.floatValue ?? '')) }), cur && _jsx("span", { className: "shrink-0 text-xs text-muted", children: currencySymbol(cur) })] }));
32
+ }
33
+ function MoneyPage(p) {
34
+ 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(MoneyView, { value: v, field: p.field }), edit: (value, onChange) => (_jsx(MoneyInput, { field: p.field, value: value, onChange: onChange })) }));
35
+ }
36
+ function MoneyInline({ value, field }) {
37
+ return _jsx(MoneyView, { value: value, field: field });
38
+ }
39
+ registerRenderer({ kinds: ['money'], Page: MoneyPage, Inline: MoneyInline });
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import type { FieldMeta } from '@coffer-org/sdk/fields';
3
+ interface FieldInputProps {
4
+ name: string;
5
+ field: FieldMeta;
6
+ value: unknown;
7
+ onChange: (v: number | string) => void;
8
+ }
9
+ export declare function numberChipContent(item: unknown): React.ReactNode;
10
+ export declare function NumberInput({ name, field, value, onChange }: FieldInputProps): React.JSX.Element;
11
+ export declare function RatingControl({ value, onChange, field, }: {
12
+ value: unknown;
13
+ onChange?: (v: number | string) => void;
14
+ field: FieldMeta;
15
+ }): React.JSX.Element;
16
+ export declare function DurationInput({ value, onChange, field }: FieldInputProps): React.JSX.Element;
17
+ export {};
@@ -0,0 +1,104 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { NumericFormat } from 'react-number-format';
3
+ import { Input } from "../../components/ui/input.js";
4
+ import { Rating, RatingItem } from "../../components/ui/rating.js";
5
+ import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from "../../components/ui/input-group.js";
6
+ import { registerRenderer } from "../../registry.js";
7
+ import { MultiTagInput, MultipleChips, Dash, useTranslation, orDash } from "../shared.js";
8
+ import { parseJSON } from "../../lib/json.js";
9
+ import { formatDuration } from "../../lib/format.js";
10
+ import { FieldFrame } from "../field-frame.js";
11
+ import { EDIT_INLINE_PAD } from "../chrome.js";
12
+ import { Icon } from "../../components/Icon.js";
13
+ export function numberChipContent(item) {
14
+ return _jsx("span", { className: "font-mono", children: String(item) });
15
+ }
16
+ export function NumberInput({ name, field, value, onChange }) {
17
+ const h = field.hints;
18
+ if (field.hints['multiple'] === true) {
19
+ return (_jsx(MultiTagInput, { value: value, onChange: onChange, validate: (v) => !isNaN(Number(v)) && v !== '', display: numberChipContent, renderInput: (v, set, add) => (_jsx(Input, { type: "number", value: v, onChange: (e) => set(e.target.value), placeholder: "0", className: "flex-1", onKeyDown: (e) => {
20
+ if (e.key === 'Enter') {
21
+ e.preventDefault();
22
+ add();
23
+ }
24
+ } })) }));
25
+ }
26
+ return (_jsx(NumericFormat, { customInput: Input, id: name, value: value === '' || value == null ? '' : String(value), thousandSeparator: true, decimalScale: field.column === 'integer' ? 0 : undefined, min: h.min, max: h.max, step: h.step, onValueChange: (vals) => onChange(vals.floatValue ?? ''), placeholder: "0" }));
27
+ }
28
+ function NumberValue({ value }) {
29
+ return _jsx(_Fragment, { children: numberChipContent(value) });
30
+ }
31
+ function NumberDisplay({ field, value }) {
32
+ if (field.hints['multiple'] === true) {
33
+ return _jsx(MultipleChips, { items: parseJSON(value, []), content: numberChipContent });
34
+ }
35
+ return orDash(value, (v) => _jsx("span", { children: String(v) }));
36
+ }
37
+ function NumberPage(p) {
38
+ 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(NumberDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(NumberInput, { name: `field-${p.field.label}`, field: p.field, value: value, onChange: onChange })) }));
39
+ }
40
+ registerRenderer({ kinds: ['number'], Page: NumberPage, Value: NumberValue });
41
+ const ratingStars = (max) => Array.from({ length: max }, (_, i) => (_jsx(RatingItem, { className: "size-5 text-yellow-400 data-[state=empty]:text-border" }, i)));
42
+ export function RatingControl({ value, onChange, field, }) {
43
+ const max = Number(field.hints['max'] ?? 5);
44
+ const current = value ? Number(value) : 0;
45
+ return (_jsx("div", { className: `flex items-center min-h-9${onChange ? '' : ' pointer-events-none'}`, children: _jsx(Rating, { value: current, max: max, clearable: true, readOnly: !onChange, activationMode: "manual", onValueChange: (v) => onChange?.(v === 0 ? '' : v), "aria-label": field.label, children: ratingStars(max) }) }));
46
+ }
47
+ function RatingValue({ field, value }) {
48
+ return _jsx(RatingControl, { field: field, value: value });
49
+ }
50
+ function RatingPicker({ field, draft, save }) {
51
+ return _jsx(RatingControl, { field: field, value: draft, onChange: (v) => save(v) });
52
+ }
53
+ function RatingPage(p) {
54
+ 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-fit", bare: p.bare, view: (v) => _jsx(RatingControl, { field: p.field, value: v }), edit: (v, onChange) => _jsx(RatingControl, { field: p.field, value: v, onChange: onChange }) }));
55
+ }
56
+ function RatingInline({ value }) {
57
+ const n = Number(value);
58
+ return (_jsx("span", { className: "inline-flex items-center gap-0.5 truncate", children: Number.isNaN(n) || !n ? ('—') : (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "lucide:star", size: 12, className: "fill-current text-yellow-400" }), n] })) }));
59
+ }
60
+ registerRenderer({
61
+ kinds: ['rating'],
62
+ Page: RatingPage,
63
+ Inline: RatingInline,
64
+ Value: RatingValue,
65
+ Picker: RatingPicker,
66
+ });
67
+ export function DurationInput({ value, onChange, field }) {
68
+ const { t } = useTranslation();
69
+ const step = Number(field.hints['step'] ?? 60);
70
+ const secs = value ? Number(value) : 0;
71
+ const d = Math.floor(secs / 86400);
72
+ const h = Math.floor((secs % 86400) / 3600);
73
+ const m = Math.floor((secs % 3600) / 60);
74
+ const s = secs % 60;
75
+ const showSeconds = step < 60;
76
+ function commit(days, hours, minutes, seconds) {
77
+ const total = Math.max(0, days * 86400 + hours * 3600 + minutes * 60 + seconds);
78
+ onChange(total > 0 ? total : '');
79
+ }
80
+ const Unit = ({ val, unit, ...rest }) => (_jsxs(InputGroup, { className: "w-[5.25rem]", children: [_jsx(InputGroupInput, { type: "number", value: val || '', min: 0, placeholder: "0", ...rest }), _jsx(InputGroupAddon, { align: "inline-end", children: _jsx(InputGroupText, { children: unit }) })] }));
81
+ return (_jsxs("div", { className: `flex items-center gap-2 flex-wrap ${EDIT_INLINE_PAD}`, children: [_jsx(Unit, { val: d, unit: t('form.days'), onChange: (e) => commit(Number(e.target.value) || 0, h, m, s) }), _jsx(Unit, { val: h, unit: t('form.hours'), max: 23, onChange: (e) => commit(d, Number(e.target.value) || 0, m, s) }), _jsx(Unit, { val: m, unit: t('form.minutes'), max: 59, step: showSeconds ? 1 : Math.max(1, Math.floor(step / 60)), onChange: (e) => commit(d, h, Number(e.target.value) || 0, s) }), showSeconds && (_jsx(Unit, { val: s, unit: t('form.seconds'), max: 59, step: step, onChange: (e) => commit(d, h, m, Number(e.target.value) || 0) }))] }));
82
+ }
83
+ function DurationDisplay({ value }) {
84
+ const { t } = useTranslation();
85
+ const secs = Number(value);
86
+ if (!secs || Number.isNaN(secs))
87
+ return _jsx(Dash, {});
88
+ return _jsx("span", { className: "text-sm", children: formatDuration(secs, t) });
89
+ }
90
+ function DurationPage(p) {
91
+ 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(DurationDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(DurationInput, { name: `field-${p.field.label}`, field: p.field, value: value, onChange: onChange })) }));
92
+ }
93
+ function DurationInline({ value }) {
94
+ const { t } = useTranslation();
95
+ const secs = Number(value);
96
+ if (!secs || Number.isNaN(secs))
97
+ return _jsx("span", { children: "\u2014" });
98
+ return _jsx("span", { className: "truncate", children: formatDuration(secs, t) });
99
+ }
100
+ registerRenderer({
101
+ kinds: ['duration'],
102
+ Page: DurationPage,
103
+ Inline: DurationInline,
104
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,60 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { RowWidget } from "../widgets/edit.js";
3
+ import { registerRenderer } from "../../registry.js";
4
+ import { partValueKeys } from '@coffer-org/sdk/fields';
5
+ import { useTranslation, MultipleChips } from "../shared.js";
6
+ import { FieldFrame } from "../field-frame.js";
7
+ function periodSlots(field) {
8
+ const slots = partValueKeys(field.parts ?? []);
9
+ return { fromKey: slots['from'] ?? 'from', untilKey: slots['until'] ?? 'until' };
10
+ }
11
+ function toRanges(value) {
12
+ if (Array.isArray(value))
13
+ return value;
14
+ if (value && typeof value === 'object' && Object.keys(value).length)
15
+ return [value];
16
+ if (typeof value === 'string' && value) {
17
+ try {
18
+ const v = JSON.parse(value);
19
+ if (Array.isArray(v))
20
+ return v;
21
+ if (v && typeof v === 'object' && Object.keys(v).length)
22
+ return [v];
23
+ }
24
+ catch {
25
+ }
26
+ }
27
+ return [];
28
+ }
29
+ function fmtPart(s, granularity) {
30
+ if (!s)
31
+ return '…';
32
+ return granularity === 'datetime' ? String(s).replace('T', ' ') : String(s);
33
+ }
34
+ function fmtRange(p, granularity, fromKey, untilKey) {
35
+ return `${fmtPart(p[fromKey], granularity)}–${fmtPart(p[untilKey], granularity)}`;
36
+ }
37
+ function PeriodInput({ field, value, onChange }) {
38
+ const { t } = useTranslation();
39
+ return _jsx(RowWidget, { value: value, onChange: onChange, field: field, t: t });
40
+ }
41
+ function PeriodDisplay({ field, value }) {
42
+ const granularity = field.hints['granularity'] ?? 'day';
43
+ const { fromKey, untilKey } = periodSlots(field);
44
+ const ranges = toRanges(value);
45
+ return (_jsx(MultipleChips, { items: ranges, content: (p) => _jsx("span", { className: "font-mono", children: fmtRange(p, granularity, fromKey, untilKey) }) }));
46
+ }
47
+ function PeriodPage(p) {
48
+ 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(PeriodDisplay, { field: p.field, value: v }), edit: (value, onChange) => (_jsx(PeriodInput, { name: `field-${p.field.label}`, field: p.field, value: value, onChange: onChange })) }));
49
+ }
50
+ function PeriodInline({ value, field }) {
51
+ const granularity = field.hints['granularity'] ?? 'day';
52
+ const { fromKey, untilKey } = periodSlots(field);
53
+ const ranges = toRanges(value);
54
+ return (_jsx("span", { className: "truncate", children: ranges.length ? ranges.map((p) => fmtRange(p, granularity, fromKey, untilKey)).join(', ') : '—' }));
55
+ }
56
+ registerRenderer({
57
+ kinds: ['period'],
58
+ Page: PeriodPage,
59
+ Inline: PeriodInline,
60
+ });
@@ -0,0 +1 @@
1
+ export {};