@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
package/dist/layout.js ADDED
@@ -0,0 +1,323 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment } from 'react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { hasValue, hasChildren, isNamedField, isPseudo, isStorageGroup } from '@coffer-org/sdk/fields';
5
+ import { fieldLayout, elementKind, resolveRenderer, resolveFieldSpan } from "./registry.js";
6
+ import { visibleOptions } from '@coffer-org/sdk/condition';
7
+ import { fieldOptions } from "./lib/format.js";
8
+ import { withScopeValues, ParentValuesProvider } from "./render/field-scope.js";
9
+ import { parseJSON } from "./lib/json.js";
10
+ import { FlowRow, FlowCtx } from "./render/widgets/flow-row.js";
11
+ import { STACK, LAYOUT_STACK, GroupTitle, Rail, groupIcon } from "./render/chrome.js";
12
+ import { focusInPopup } from "./render/field-frame.js";
13
+ import { FieldAddressProvider } from "./render/field-address.js";
14
+ import { SlotProvider } from "./render/slot.js";
15
+ import { withChildWidth } from "./render/field-width.js";
16
+ import Markdown from "./Markdown.js";
17
+ function blockCommit(values, setValue) {
18
+ let last = values;
19
+ return (next) => {
20
+ const merged = next;
21
+ let result = undefined;
22
+ for (const k of Object.keys(merged)) {
23
+ if (merged[k] !== last[k])
24
+ result = setValue(k, merged[k]);
25
+ }
26
+ if (result instanceof Promise) {
27
+ void result.then((err) => {
28
+ if (!err)
29
+ last = merged;
30
+ });
31
+ }
32
+ else {
33
+ last = merged;
34
+ }
35
+ return result;
36
+ };
37
+ }
38
+ function InfoBlock({ text }) {
39
+ return _jsx(Markdown, { value: text });
40
+ }
41
+ function renderElementBridge(it, { bridge, t }) {
42
+ if (hasValue(it) && it.key !== undefined) {
43
+ const key = it.key;
44
+ if (bridge.isHidden(key))
45
+ return null;
46
+ const r = resolveRenderer({ kind: elementKind(it) });
47
+ if (!r) {
48
+ console.warn(`[LayoutRenderer] no renderer for kind '${elementKind(it)}'`);
49
+ return null;
50
+ }
51
+ const field = withScopeValues(it.type, bridge.values);
52
+ const derive = field.derived;
53
+ const value = bridge.getValue(key);
54
+ const keep = field.hints['multiple'] === true
55
+ ? Array.isArray(value)
56
+ ? value.map(String)
57
+ : parseJSON(value, []).map(String)
58
+ : typeof value === 'string'
59
+ ? value
60
+ : undefined;
61
+ const resolvedOptions = fieldOptions(field);
62
+ const selectOptions = resolvedOptions.length
63
+ ? visibleOptions(resolvedOptions, bridge.values ?? {}, keep)
64
+ : undefined;
65
+ const node = (_jsx("div", { onBlur: (e) => {
66
+ if (!focusInPopup(e.relatedTarget))
67
+ bridge.touch(key);
68
+ }, children: _jsx(FieldAddressProvider, { fieldKey: key, children: _jsx(SlotProvider, { field: it, value: value, commit: derive ? undefined : (v) => bridge.setValue(key, v), isHidden: bridge.isHidden, mode: derive ? 'view' : bridge.mode, children: _jsx(r.Page, { el: it, field: field, fieldKey: key, value: value, error: bridge.error(key), mode: derive ? 'view' : bridge.mode, label: field.label ? t(field.label) : undefined, required: bridge.requiredOf(key), recordCtx: bridge.recordCtx, selectOptions: selectOptions }) }) }) }));
69
+ const span = resolveFieldSpan(field);
70
+ return { node, layout: fieldLayout(field), span };
71
+ }
72
+ if (hasValue(it)) {
73
+ const r = resolveRenderer({ kind: elementKind(it) });
74
+ if (!r) {
75
+ console.warn(`[LayoutRenderer] no renderer for static kind '${elementKind(it)}'`);
76
+ return null;
77
+ }
78
+ const field = it.type;
79
+ const staticValue = typeof it.value === 'function' ? undefined : it.value;
80
+ const node = (_jsx(SlotProvider, { field: it, value: staticValue, children: _jsx(r.Page, { el: it, field: field, value: staticValue, mode: "view", label: field.label ? t(field.label) : undefined, recordCtx: bridge.recordCtx }) }));
81
+ const span = resolveFieldSpan(field);
82
+ return { node, layout: fieldLayout(field), span };
83
+ }
84
+ if (it.el === 'divider') {
85
+ return null;
86
+ }
87
+ if (it.el === 'info') {
88
+ return null;
89
+ }
90
+ if (it.el === 'button') {
91
+ const r = resolveRenderer({ kind: 'button' });
92
+ if (!r)
93
+ return null;
94
+ const node = _jsx(r.Page, { el: it, value: undefined, mode: bridge.mode, recordCtx: bridge.recordCtx });
95
+ return { node, layout: 'scalar', span: 3 };
96
+ }
97
+ return null;
98
+ }
99
+ function collect(items, ctx, bridgeCtx, display = 'wrap') {
100
+ const out = [];
101
+ let buffer = [];
102
+ let staticIdx = 0;
103
+ const flush = () => {
104
+ if (buffer.length) {
105
+ out.push({ kind: 'flow', items: buffer, scroll: display === 'scroll' });
106
+ buffer = [];
107
+ }
108
+ };
109
+ for (const it of items) {
110
+ if (bridgeCtx) {
111
+ if (isPseudo(it) && it.el === 'divider') {
112
+ flush();
113
+ out.push({ kind: 'divider', label: it.label });
114
+ continue;
115
+ }
116
+ if (isPseudo(it) && it.el === 'info') {
117
+ flush();
118
+ out.push({ kind: 'block', node: _jsx(InfoNode, { textKey: it.text }) });
119
+ continue;
120
+ }
121
+ if (!hasChildren(it)) {
122
+ const result = renderElementBridge(it, bridgeCtx);
123
+ if (result == null)
124
+ continue;
125
+ if (result.layout === 'block') {
126
+ flush();
127
+ out.push({ kind: 'block', node: result.node });
128
+ }
129
+ else {
130
+ const itemKey = hasValue(it) && it.key !== undefined ? it.key : `static-${staticIdx++}`;
131
+ buffer.push({
132
+ key: itemKey,
133
+ span: result.span,
134
+ node: _jsx(Fragment, { children: result.node }, itemKey),
135
+ });
136
+ }
137
+ continue;
138
+ }
139
+ continue;
140
+ }
141
+ if (isNamedField(it)) {
142
+ const node = ctx.renderField(it.key, it.type);
143
+ if (node == null)
144
+ continue;
145
+ if (fieldLayout(it.type) === 'block') {
146
+ flush();
147
+ out.push({ kind: 'block', node });
148
+ }
149
+ else {
150
+ const span = resolveFieldSpan(it.type);
151
+ buffer.push({ key: it.key, span, node: _jsx(Fragment, { children: node }, it.key) });
152
+ }
153
+ }
154
+ else if (isPseudo(it) && it.el === 'divider') {
155
+ flush();
156
+ out.push({ kind: 'divider', label: it.label });
157
+ }
158
+ else if (isPseudo(it) && it.el === 'info') {
159
+ flush();
160
+ out.push({ kind: 'block', node: _jsx(InfoNode, { textKey: it.text }) });
161
+ }
162
+ }
163
+ flush();
164
+ return out;
165
+ }
166
+ function InfoNode({ textKey }) {
167
+ const { t } = useTranslation();
168
+ return _jsx(InfoBlock, { text: t(textKey) });
169
+ }
170
+ function collapseDividers(nodes) {
171
+ const isPlainDivider = (n) => n.kind === 'divider' && !n.label;
172
+ const out = [];
173
+ for (const n of nodes) {
174
+ if (isPlainDivider(n)) {
175
+ if (!out.length)
176
+ continue;
177
+ if (isPlainDivider(out[out.length - 1]))
178
+ continue;
179
+ }
180
+ out.push(n);
181
+ }
182
+ while (out.length && isPlainDivider(out[out.length - 1]))
183
+ out.pop();
184
+ return out;
185
+ }
186
+ export function SectionShell({ label, icon, labelAfter, children, rail = true, tone = 'group', }) {
187
+ const body = _jsx("div", { className: `flex flex-col min-w-0 ${STACK}`, children: children });
188
+ return (_jsxs("section", { className: `flex flex-col min-w-0 ${STACK}`, children: [label && _jsx(GroupTitle, { label: label, icon: icon, actions: labelAfter, tone: tone }), rail && label ? _jsx(Rail, { children: body }) : body] }));
189
+ }
190
+ function GroupSection({ group, children }) {
191
+ const { t } = useTranslation();
192
+ return (_jsx(SectionShell, { label: group.label ? t(group.label) : undefined, icon: groupIcon(group), children: children }));
193
+ }
194
+ function RowSection({ group, children }) {
195
+ const { t } = useTranslation();
196
+ return (_jsxs("div", { className: "flex flex-col gap-1 min-w-0", children: [group.label && _jsx("span", { className: "text-xs text-muted", children: t(group.label) }), children] }));
197
+ }
198
+ function SheetSection({ group, renderCell, }) {
199
+ const { t } = useTranslation();
200
+ const rows = group.fields.map((el) => (hasChildren(el) ? el.fields : [el]));
201
+ const N = Math.max(1, ...rows.map((r) => r.length));
202
+ let visible = false;
203
+ const slots = [];
204
+ rows.forEach((row, ri) => {
205
+ for (let ci = 0; ci < N; ci++) {
206
+ const cell = row[ci];
207
+ const node = cell ? renderCell(cell) : null;
208
+ if (node)
209
+ visible = true;
210
+ slots.push(_jsx("div", { className: "min-w-0", children: node }, `${ri}-${ci}`));
211
+ }
212
+ });
213
+ if (!visible)
214
+ return null;
215
+ return (_jsx(FlowCtx.Provider, { value: true, children: _jsx(SectionShell, { label: group.label ? t(group.label) : undefined, icon: groupIcon(group), children: _jsx("div", { className: "overflow-x-auto", children: _jsx("div", { className: "grid gap-x-4 gap-y-2 items-start", style: { gridTemplateColumns: `repeat(${N}, max-content)` }, children: slots }) }) }) }));
216
+ }
217
+ function renderNodes(nodes, keyPrefix) {
218
+ const visible = nodes.filter((n) => n.kind !== 'divider' || n.label);
219
+ if (!visible.length)
220
+ return null;
221
+ return nodes.map((n, i) => {
222
+ const key = `${keyPrefix}-${i}`;
223
+ switch (n.kind) {
224
+ case 'flow':
225
+ return _jsx(FlowRow, { items: n.items, scroll: n.scroll }, key);
226
+ case 'block':
227
+ return _jsx(Fragment, { children: n.node }, key);
228
+ case 'group':
229
+ return _jsx(Fragment, { children: n.node }, key);
230
+ case 'divider':
231
+ return renderDivider(n.label, key);
232
+ }
233
+ });
234
+ }
235
+ export function LabelledDivider({ label }) {
236
+ const { t } = useTranslation();
237
+ return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "shrink-0 text-xs uppercase tracking-wider text-muted", children: t(label) }), _jsx("div", { className: "flex-1 border-t border-border" })] }));
238
+ }
239
+ function renderDivider(label, key) {
240
+ return label ? _jsx(LabelledDivider, { label: label }, key) : _jsx("hr", { className: "border-border" }, key);
241
+ }
242
+ function renderGroupNode(it, ctx, bridgeCtx) {
243
+ if (bridgeCtx) {
244
+ if (isStorageGroup(it)) {
245
+ const key = it.key;
246
+ const gVal = bridgeCtx.bridge.getValue(key);
247
+ if (bridgeCtx.bridge.isHidden(key))
248
+ return null;
249
+ const r = resolveRenderer({ kind: elementKind(it) });
250
+ if (!r) {
251
+ console.warn(`[LayoutRenderer] no renderer for storage group kind '${elementKind(it)}'`);
252
+ return null;
253
+ }
254
+ return (_jsx(SlotProvider, { field: it, value: gVal, commit: (v) => bridgeCtx.bridge.setValue(key, v), isHidden: bridgeCtx.bridge.isHidden, mode: bridgeCtx.bridge.mode, children: _jsx(r.Page, { el: it, value: gVal, error: bridgeCtx.bridge.error(key), mode: bridgeCtx.bridge.mode, recordCtx: bridgeCtx.bridge.recordCtx }) }));
255
+ }
256
+ if (it.display === 'sheet') {
257
+ return (_jsx(SheetSection, { group: it, renderCell: (cell) => hasChildren(cell) ? null : (renderElementBridge(cell, bridgeCtx)?.node ?? null) }));
258
+ }
259
+ if (it.kind !== undefined) {
260
+ const r = resolveRenderer({ kind: it.kind });
261
+ if (r) {
262
+ return (_jsx(FlowCtx.Provider, { value: true, children: withChildWidth(r.childWidth, _jsx(SlotProvider, { field: it, value: bridgeCtx.bridge.values, commit: blockCommit(bridgeCtx.bridge.values, bridgeCtx.bridge.setValue), isHidden: bridgeCtx.bridge.isHidden, mode: bridgeCtx.bridge.mode, children: _jsx(r.Page, { el: it, value: undefined, mode: bridgeCtx.bridge.mode, recordCtx: bridgeCtx.bridge.recordCtx }) })) }));
263
+ }
264
+ }
265
+ const innerNodes = collapseDividers(collect(it.fields, ctx, bridgeCtx, it.display === 'scroll' ? 'scroll' : 'wrap'));
266
+ const inner = renderNodes(innerNodes, 'g');
267
+ if (!inner)
268
+ return null;
269
+ if (it.display === 'scroll') {
270
+ return _jsx(RowSection, { group: it, children: inner });
271
+ }
272
+ const r = resolveRenderer({ kind: 'group' });
273
+ if (r) {
274
+ return (_jsx(SlotProvider, { field: it, value: undefined, children: _jsx(r.Page, { el: it, value: undefined, mode: bridgeCtx.bridge.mode, recordCtx: bridgeCtx.bridge.recordCtx, children: inner }) }));
275
+ }
276
+ return _jsx(GroupSection, { group: it, children: inner });
277
+ }
278
+ if (isStorageGroup(it)) {
279
+ return ctx.renderGroup?.(it.key, it) ?? null;
280
+ }
281
+ if (it.display === 'sheet') {
282
+ return (_jsx(SheetSection, { group: it, renderCell: (cell) => (isNamedField(cell) ? ctx.renderField(cell.key, cell.type) : null) }));
283
+ }
284
+ if (it.kind !== undefined) {
285
+ const r = resolveRenderer({ kind: it.kind });
286
+ if (r) {
287
+ return (_jsx(FlowCtx.Provider, { value: true, children: withChildWidth(r.childWidth, _jsx(SlotProvider, { field: it, value: ctx.values, commit: ctx.setValue ? blockCommit(ctx.values ?? {}, ctx.setValue) : undefined, isHidden: ctx.isHidden, mode: ctx.mode, children: _jsx(r.Page, { el: it, value: undefined, mode: ctx.mode ?? 'view', recordCtx: { library: '', shelf: '', recordId: null } }) })) }));
288
+ }
289
+ }
290
+ const inner = renderNodes(collapseDividers(collect(it.fields, ctx, undefined, it.display === 'scroll' ? 'scroll' : 'wrap')), 'g');
291
+ if (!inner)
292
+ return null;
293
+ return it.display === 'scroll' ? (_jsx(RowSection, { group: it, children: inner })) : (_jsx(GroupSection, { group: it, children: inner }));
294
+ }
295
+ export function LayoutRenderer({ items, ctx }) {
296
+ const { t } = useTranslation();
297
+ const bridgeCtx = ctx.bridge ? { bridge: ctx.bridge, t } : undefined;
298
+ const nodes = [];
299
+ let buffer = [];
300
+ const flushRun = () => {
301
+ if (buffer.length) {
302
+ nodes.push(...collect(buffer, ctx, bridgeCtx));
303
+ buffer = [];
304
+ }
305
+ };
306
+ for (const it of items) {
307
+ if (hasChildren(it)) {
308
+ flushRun();
309
+ const node = renderGroupNode(it, ctx, bridgeCtx);
310
+ if (node)
311
+ nodes.push({ kind: 'group', node });
312
+ }
313
+ else {
314
+ buffer.push(it);
315
+ }
316
+ }
317
+ flushRun();
318
+ const collapsed = collapseDividers(nodes);
319
+ const rendered = renderNodes(collapsed, 'l');
320
+ if (rendered == null)
321
+ return null;
322
+ return (_jsx(ParentValuesProvider, { values: ctx.bridge?.values, children: _jsx("div", { className: `@container flex flex-col min-w-0 ${LAYOUT_STACK}`, children: rendered }) }));
323
+ }
@@ -0,0 +1 @@
1
+ export declare function catColor(key: string): string;
@@ -0,0 +1,7 @@
1
+ const CAT_COUNT = 8;
2
+ export function catColor(key) {
3
+ let h = 0;
4
+ for (let i = 0; i < key.length; i++)
5
+ h = (h * 31 + key.charCodeAt(i)) | 0;
6
+ return `var(--cat-${(Math.abs(h) % CAT_COUNT) + 1})`;
7
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ type PossibleRef<T> = React.Ref<T> | undefined;
3
+ declare function composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T>;
4
+ declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T>;
5
+ export { composeRefs, useComposedRefs };
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ function setRef(ref, value) {
3
+ if (typeof ref === 'function') {
4
+ return ref(value);
5
+ }
6
+ if (ref !== null && ref !== undefined) {
7
+ ref.current = value;
8
+ }
9
+ }
10
+ function composeRefs(...refs) {
11
+ return (node) => {
12
+ let hasCleanup = false;
13
+ const cleanups = refs.map((ref) => {
14
+ const cleanup = setRef(ref, node);
15
+ if (!hasCleanup && typeof cleanup === 'function') {
16
+ hasCleanup = true;
17
+ }
18
+ return cleanup;
19
+ });
20
+ if (hasCleanup) {
21
+ return () => {
22
+ for (let i = 0; i < cleanups.length; i++) {
23
+ const cleanup = cleanups[i];
24
+ if (typeof cleanup === 'function') {
25
+ cleanup();
26
+ }
27
+ else {
28
+ setRef(refs[i], null);
29
+ }
30
+ }
31
+ };
32
+ }
33
+ };
34
+ }
35
+ function useComposedRefs(...refs) {
36
+ return React.useCallback(composeRefs(...refs), refs);
37
+ }
38
+ export { composeRefs, useComposedRefs };
@@ -0,0 +1,9 @@
1
+ export declare function isoToDate(iso: string): Date | undefined;
2
+ export declare function dateToIso(d: Date): string;
3
+ export declare function isoToDisplay(iso: string): string;
4
+ export declare function isoDateTimeToDisplay(iso: string): string;
5
+ export declare function splitDateTime(iso: string): {
6
+ date: string;
7
+ time: string;
8
+ };
9
+ export declare function joinDateTime(date: string, time: string): string;
@@ -0,0 +1,31 @@
1
+ import { format, parse, isValid } from 'date-fns';
2
+ export function isoToDate(iso) {
3
+ if (!iso)
4
+ return undefined;
5
+ const d = parse(iso.slice(0, 10), 'yyyy-MM-dd', new Date());
6
+ return isValid(d) ? d : undefined;
7
+ }
8
+ export function dateToIso(d) {
9
+ return format(d, 'yyyy-MM-dd');
10
+ }
11
+ export function isoToDisplay(iso) {
12
+ const d = isoToDate(iso);
13
+ return d ? format(d, 'dd.MM.yyyy') : '';
14
+ }
15
+ export function isoDateTimeToDisplay(iso) {
16
+ if (!iso)
17
+ return '';
18
+ const datePart = isoToDisplay(iso.slice(0, 10));
19
+ if (!datePart)
20
+ return '';
21
+ const time = iso.slice(11, 16);
22
+ return time ? `${datePart} ${time}` : datePart;
23
+ }
24
+ export function splitDateTime(iso) {
25
+ return { date: iso.slice(0, 10), time: iso.slice(11, 16) };
26
+ }
27
+ export function joinDateTime(date, time) {
28
+ if (!date)
29
+ return '';
30
+ return time ? `${date}T${time}` : date;
31
+ }
@@ -0,0 +1,14 @@
1
+ import type { FieldMeta, OptionItem } from '@coffer-org/sdk/fields';
2
+ type TFn = (key: string, opts?: Record<string, unknown>) => string;
3
+ export declare function formatDuration(secs: number, t: TFn): string;
4
+ export declare function asBool(v: unknown): boolean;
5
+ type OptionsCarrier = Pick<FieldMeta, 'options'> & {
6
+ hints?: FieldMeta['hints'];
7
+ };
8
+ export declare function fieldOptions(field: OptionsCarrier): OptionItem[];
9
+ export declare function optionLabel(t: TFn, field: OptionsCarrier, value: unknown): string;
10
+ export declare function sortedCountryOptions(t: TFn): {
11
+ code: string;
12
+ name: string;
13
+ }[];
14
+ export {};
@@ -0,0 +1,34 @@
1
+ import { COUNTRIES } from '@coffer-org/sdk/countries';
2
+ import { getOptionList } from "../schema-registry.js";
3
+ export function formatDuration(secs, t) {
4
+ const d = Math.floor(secs / 86400);
5
+ const h = Math.floor((secs % 86400) / 3600);
6
+ const m = Math.floor((secs % 3600) / 60);
7
+ const s = secs % 60;
8
+ const parts = [];
9
+ if (d)
10
+ parts.push(`${d} ${t('form.days')}`);
11
+ if (h)
12
+ parts.push(`${h} ${t('form.hours')}`);
13
+ if (m)
14
+ parts.push(`${m} ${t('form.minutes')}`);
15
+ if (s)
16
+ parts.push(`${s} ${t('form.seconds')}`);
17
+ return parts.length ? parts.join(' ') : `0 ${t('form.seconds')}`;
18
+ }
19
+ export function asBool(v) {
20
+ return v === true || v === 1 || v === '1' || v === 'true';
21
+ }
22
+ export function fieldOptions(field) {
23
+ if (field.options?.length)
24
+ return field.options;
25
+ const src = field.hints?.['source'];
26
+ return src ? getOptionList(src) : [];
27
+ }
28
+ export function optionLabel(t, field, value) {
29
+ const key = fieldOptions(field).find((o) => o.value === String(value))?.title;
30
+ return key ? t(key) : String(value ?? '');
31
+ }
32
+ export function sortedCountryOptions(t) {
33
+ return COUNTRIES.map((c) => ({ code: c.code, name: t(`core.countries.${c.code}`) })).sort((a, b) => a.name.localeCompare(b.name));
34
+ }
@@ -0,0 +1 @@
1
+ export declare function parseJSON<T>(v: unknown, fallback: T): T;
@@ -0,0 +1,12 @@
1
+ export function parseJSON(v, fallback) {
2
+ if (v === null || v === undefined || v === '')
3
+ return fallback;
4
+ if (typeof v === 'object')
5
+ return v;
6
+ try {
7
+ return JSON.parse(String(v));
8
+ }
9
+ catch {
10
+ return fallback;
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ import type { FieldMeta } from '@coffer-org/sdk/fields';
2
+ export declare function parseTagValues(v: unknown): string[];
3
+ export declare function isMultiValued(f: Pick<FieldMeta, 'kind' | 'hints'>): boolean;
@@ -0,0 +1,22 @@
1
+ export function parseTagValues(v) {
2
+ if (v === null || v === undefined || v === '')
3
+ return [];
4
+ if (Array.isArray(v))
5
+ return v.map(String).filter(Boolean);
6
+ if (typeof v === 'string') {
7
+ if (v.startsWith('[')) {
8
+ try {
9
+ const parsed = JSON.parse(v);
10
+ if (Array.isArray(parsed))
11
+ return parsed.map(String).filter(Boolean);
12
+ }
13
+ catch {
14
+ }
15
+ }
16
+ return v ? [v] : [];
17
+ }
18
+ return [String(v)];
19
+ }
20
+ export function isMultiValued(f) {
21
+ return f.kind === 'tags' || f.hints?.['multiple'] === true;
22
+ }
@@ -0,0 +1,7 @@
1
+ import type { ShelfDef } from '@coffer-org/sdk/shelf';
2
+ import type { OptionIcon } from '@coffer-org/sdk/fields';
3
+ export declare function recordOption(m: ShelfDef, row: Record<string, unknown>): {
4
+ icon?: OptionIcon;
5
+ title: string;
6
+ subtitle?: string;
7
+ };
@@ -0,0 +1,52 @@
1
+ import { inlineText, inlineImageKey, fieldEntries, isImageKind } from '@coffer-org/sdk/shelf';
2
+ import { mediaUrl } from "../host-services.js";
3
+ function firstImageName(value) {
4
+ if (typeof value !== 'string' || !value)
5
+ return undefined;
6
+ try {
7
+ const p = JSON.parse(value);
8
+ const first = Array.isArray(p) ? p[0] : p;
9
+ if (first && typeof first === 'object' && typeof first.name === 'string')
10
+ return first.name;
11
+ if (typeof first === 'string')
12
+ return first;
13
+ return undefined;
14
+ }
15
+ catch {
16
+ return value;
17
+ }
18
+ }
19
+ function kindOf(m, key) {
20
+ for (const [k, meta] of fieldEntries(m.fields))
21
+ if (k === key)
22
+ return meta.kind;
23
+ return undefined;
24
+ }
25
+ function iconFrom(m, key, row) {
26
+ const kind = kindOf(m, key);
27
+ if (kind && isImageKind(kind)) {
28
+ const name = firstImageName(row[key]);
29
+ return name ? { kind: 'image', value: mediaUrl(name) } : undefined;
30
+ }
31
+ return undefined;
32
+ }
33
+ export function recordOption(m, row) {
34
+ const sel = m.views?.select;
35
+ if (sel) {
36
+ const titleKeys = Array.isArray(sel.title) ? sel.title : [sel.title];
37
+ return {
38
+ icon: sel.icon ? iconFrom(m, sel.icon, row) : undefined,
39
+ title: titleKeys
40
+ .map((k) => String(row[k] ?? ''))
41
+ .filter(Boolean)
42
+ .join(' '),
43
+ subtitle: sel.subtitle ? String(row[sel.subtitle] ?? '') || undefined : undefined,
44
+ };
45
+ }
46
+ const imgKey = inlineImageKey(m);
47
+ const imgName = imgKey ? firstImageName(row[imgKey]) : undefined;
48
+ return {
49
+ icon: imgName ? { kind: 'image', value: mediaUrl(imgName) } : undefined,
50
+ title: inlineText(m, row),
51
+ };
52
+ }
@@ -0,0 +1,14 @@
1
+ export type LoadState = 'loading' | 'idle' | 'error';
2
+ export declare function clearRecordByIdCache(): void;
3
+ export interface RecordLabels {
4
+ rows: {
5
+ id: string;
6
+ label: string;
7
+ }[];
8
+ labelMap: Map<string, string>;
9
+ records: Record<string, unknown>[];
10
+ recordMap: Map<string, Record<string, unknown>>;
11
+ loadState: LoadState;
12
+ }
13
+ export declare function useRecordLabels(library: string, shelf: string, displayKey?: string, filter?: Record<string, string>): RecordLabels;
14
+ export declare function useRecordsByIds(library: string, shelf: string, ids: string[]): Map<string, Record<string, unknown>>;