@arkitektio/bsx 4.2.0 → 5.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 (307) hide show
  1. package/README.md +39 -18
  2. package/dist/bsx/parse.d.ts +13 -7
  3. package/dist/bsx/parse.d.ts.map +1 -1
  4. package/dist/bsx/parse.js +18 -57
  5. package/dist/bsx/parse.js.map +1 -1
  6. package/dist/bsx/print.d.ts.map +1 -1
  7. package/dist/bsx/print.js +22 -35
  8. package/dist/bsx/print.js.map +1 -1
  9. package/dist/bsx/references.d.ts +5 -5
  10. package/dist/bsx/references.d.ts.map +1 -1
  11. package/dist/bsx/references.js +124 -30
  12. package/dist/bsx/references.js.map +1 -1
  13. package/dist/catalogs/html.d.ts +1 -1
  14. package/dist/catalogs/html.d.ts.map +1 -1
  15. package/dist/catalogs/html.js +3 -3
  16. package/dist/catalogs/html.js.map +1 -1
  17. package/dist/catalogs/index.d.ts +209 -139
  18. package/dist/catalogs/index.d.ts.map +1 -1
  19. package/dist/catalogs/index.js +6 -2
  20. package/dist/catalogs/index.js.map +1 -1
  21. package/dist/catalogs/logo.d.ts +5 -5
  22. package/dist/catalogs/logo.d.ts.map +1 -1
  23. package/dist/catalogs/logo.js +3 -3
  24. package/dist/catalogs/logo.js.map +1 -1
  25. package/dist/catalogs/parts/data.d.ts +6 -6
  26. package/dist/catalogs/parts/feedback.d.ts +15 -15
  27. package/dist/catalogs/parts/forms.d.ts +55 -27
  28. package/dist/catalogs/parts/forms.d.ts.map +1 -1
  29. package/dist/catalogs/parts/forms.js +32 -0
  30. package/dist/catalogs/parts/forms.js.map +1 -1
  31. package/dist/catalogs/parts/html.d.ts +1 -1
  32. package/dist/catalogs/parts/html.d.ts.map +1 -1
  33. package/dist/catalogs/parts/html.js +1 -1
  34. package/dist/catalogs/parts/html.js.map +1 -1
  35. package/dist/catalogs/parts/icons.d.ts +11 -11
  36. package/dist/catalogs/parts/icons.js +1 -1
  37. package/dist/catalogs/parts/index.d.ts +183 -137
  38. package/dist/catalogs/parts/index.d.ts.map +1 -1
  39. package/dist/catalogs/parts/layout.d.ts +11 -1
  40. package/dist/catalogs/parts/layout.d.ts.map +1 -1
  41. package/dist/catalogs/parts/layout.js +9 -0
  42. package/dist/catalogs/parts/layout.js.map +1 -1
  43. package/dist/catalogs/parts/logo.d.ts +8 -8
  44. package/dist/catalogs/parts/logo.d.ts.map +1 -1
  45. package/dist/catalogs/parts/logo.js +2 -2
  46. package/dist/catalogs/parts/logo.js.map +1 -1
  47. package/dist/catalogs/parts/navigation.d.ts +20 -20
  48. package/dist/catalogs/parts/overlays.d.ts +55 -55
  49. package/dist/catalogs/parts/run.d.ts +13 -5
  50. package/dist/catalogs/parts/run.d.ts.map +1 -1
  51. package/dist/catalogs/parts/run.js +1 -1
  52. package/dist/catalogs/parts/scene.d.ts +12 -4
  53. package/dist/catalogs/parts/scene.d.ts.map +1 -1
  54. package/dist/catalogs/parts/scene.js +4 -0
  55. package/dist/catalogs/parts/scene.js.map +1 -1
  56. package/dist/catalogs/parts/structure.js +2 -2
  57. package/dist/catalogs/parts/toast.js +1 -1
  58. package/dist/catalogs/parts/toast.js.map +1 -1
  59. package/dist/catalogs/parts/typography.js +1 -1
  60. package/dist/catalogs/parts/typography.js.map +1 -1
  61. package/dist/catalogs/props.d.ts +3 -3
  62. package/dist/catalogs/scene.d.ts +13 -5
  63. package/dist/catalogs/scene.d.ts.map +1 -1
  64. package/dist/catalogs/scene.js +3 -3
  65. package/dist/catalogs/scene.js.map +1 -1
  66. package/dist/catalogs/shadcn.d.ts +106 -58
  67. package/dist/catalogs/shadcn.d.ts.map +1 -1
  68. package/dist/catalogs/shadcn.js +6 -4
  69. package/dist/catalogs/shadcn.js.map +1 -1
  70. package/dist/catalogs/structure.d.ts +1 -1
  71. package/dist/catalogs/structure.d.ts.map +1 -1
  72. package/dist/catalogs/structure.js +3 -3
  73. package/dist/catalogs/structure.js.map +1 -1
  74. package/dist/catalogs/ui.d.ts +83 -73
  75. package/dist/catalogs/ui.d.ts.map +1 -1
  76. package/dist/catalogs/ui.js +4 -3
  77. package/dist/catalogs/ui.js.map +1 -1
  78. package/dist/catalogs.d.ts +1 -1
  79. package/dist/catalogs.d.ts.map +1 -1
  80. package/dist/catalogs.js +2 -2
  81. package/dist/catalogs.js.map +1 -1
  82. package/dist/ports.js +1 -1
  83. package/dist/ports.js.map +1 -1
  84. package/dist/renderer/BlokRenderer.d.ts +4 -1
  85. package/dist/renderer/BlokRenderer.d.ts.map +1 -1
  86. package/dist/renderer/BlokRenderer.js +5 -1
  87. package/dist/renderer/BlokRenderer.js.map +1 -1
  88. package/dist/renderer/baseCatalog.d.ts +8 -6
  89. package/dist/renderer/baseCatalog.d.ts.map +1 -1
  90. package/dist/renderer/baseCatalog.js +7 -5
  91. package/dist/renderer/baseCatalog.js.map +1 -1
  92. package/dist/renderer/bloks/control.d.ts +14 -0
  93. package/dist/renderer/bloks/control.d.ts.map +1 -1
  94. package/dist/renderer/bloks/control.js +105 -6
  95. package/dist/renderer/bloks/control.js.map +1 -1
  96. package/dist/renderer/bloks/data.d.ts +6 -6
  97. package/dist/renderer/bloks/feedback.d.ts +15 -15
  98. package/dist/renderer/bloks/forms.d.ts +51 -27
  99. package/dist/renderer/bloks/forms.d.ts.map +1 -1
  100. package/dist/renderer/bloks/forms.js +56 -0
  101. package/dist/renderer/bloks/forms.js.map +1 -1
  102. package/dist/renderer/bloks/html.js +2 -2
  103. package/dist/renderer/bloks/icons.d.ts +5 -5
  104. package/dist/renderer/bloks/index.d.ts +166 -134
  105. package/dist/renderer/bloks/index.d.ts.map +1 -1
  106. package/dist/renderer/bloks/index.js +1 -1
  107. package/dist/renderer/bloks/layout.d.ts +9 -1
  108. package/dist/renderer/bloks/layout.d.ts.map +1 -1
  109. package/dist/renderer/bloks/layout.js +15 -0
  110. package/dist/renderer/bloks/layout.js.map +1 -1
  111. package/dist/renderer/bloks/logo/index.d.ts +5 -5
  112. package/dist/renderer/bloks/logo/index.d.ts.map +1 -1
  113. package/dist/renderer/bloks/logo/index.js +2 -2
  114. package/dist/renderer/bloks/logo/index.js.map +1 -1
  115. package/dist/renderer/bloks/navigation.d.ts +20 -20
  116. package/dist/renderer/bloks/overlays.d.ts +55 -55
  117. package/dist/renderer/bloks/run/components.d.ts +6 -2
  118. package/dist/renderer/bloks/run/components.d.ts.map +1 -1
  119. package/dist/renderer/bloks/run/components.js +1 -1
  120. package/dist/renderer/bloks/run/host.d.ts +32 -3
  121. package/dist/renderer/bloks/run/host.d.ts.map +1 -1
  122. package/dist/renderer/bloks/run/host.js.map +1 -1
  123. package/dist/renderer/bloks/scene/index.d.ts +6 -2
  124. package/dist/renderer/bloks/scene/index.d.ts.map +1 -1
  125. package/dist/renderer/bloks/toast.d.ts +1 -1
  126. package/dist/renderer/bloks/typography.js +1 -1
  127. package/dist/renderer/catalog.d.ts +4 -7
  128. package/dist/renderer/catalog.d.ts.map +1 -1
  129. package/dist/renderer/catalog.js +7 -31
  130. package/dist/renderer/catalog.js.map +1 -1
  131. package/dist/renderer/declare.d.ts +31 -19
  132. package/dist/renderer/declare.d.ts.map +1 -1
  133. package/dist/renderer/declare.js +44 -18
  134. package/dist/renderer/declare.js.map +1 -1
  135. package/dist/renderer/functions/v2/index.d.ts.map +1 -1
  136. package/dist/renderer/functions/v2/index.js +39 -0
  137. package/dist/renderer/functions/v2/index.js.map +1 -1
  138. package/dist/renderer/runtime/catalog.d.ts +27 -7
  139. package/dist/renderer/runtime/catalog.d.ts.map +1 -1
  140. package/dist/renderer/runtime/catalog.js +30 -3
  141. package/dist/renderer/runtime/catalog.js.map +1 -1
  142. package/dist/renderer/runtime/components.d.ts +7 -1
  143. package/dist/renderer/runtime/components.d.ts.map +1 -1
  144. package/dist/renderer/runtime/components.js +3 -0
  145. package/dist/renderer/runtime/components.js.map +1 -1
  146. package/dist/renderer/runtime/context.d.ts +2 -0
  147. package/dist/renderer/runtime/context.d.ts.map +1 -1
  148. package/dist/renderer/runtime/context.js +4 -0
  149. package/dist/renderer/runtime/context.js.map +1 -1
  150. package/dist/renderer/runtime/describe.d.ts +14 -4
  151. package/dist/renderer/runtime/describe.d.ts.map +1 -1
  152. package/dist/renderer/runtime/describe.js +3 -0
  153. package/dist/renderer/runtime/describe.js.map +1 -1
  154. package/dist/renderer/runtime/hooks.d.ts.map +1 -1
  155. package/dist/renderer/runtime/hooks.js +1 -0
  156. package/dist/renderer/runtime/hooks.js.map +1 -1
  157. package/dist/renderer/runtime/index.d.ts +1 -0
  158. package/dist/renderer/runtime/index.d.ts.map +1 -1
  159. package/dist/renderer/runtime/index.js +1 -0
  160. package/dist/renderer/runtime/index.js.map +1 -1
  161. package/dist/renderer/runtime/preflight.d.ts.map +1 -1
  162. package/dist/renderer/runtime/preflight.js +5 -2
  163. package/dist/renderer/runtime/preflight.js.map +1 -1
  164. package/dist/renderer/runtime/resolution.d.ts +2 -0
  165. package/dist/renderer/runtime/resolution.d.ts.map +1 -1
  166. package/dist/renderer/runtime/resolution.js +17 -1
  167. package/dist/renderer/runtime/resolution.js.map +1 -1
  168. package/dist/renderer/runtime/schemas.d.ts +5 -5
  169. package/dist/renderer/runtime/task.d.ts +25 -2
  170. package/dist/renderer/runtime/task.d.ts.map +1 -1
  171. package/dist/renderer/runtime/task.js +11 -2
  172. package/dist/renderer/runtime/task.js.map +1 -1
  173. package/dist/renderer/runtime/text.d.ts +28 -0
  174. package/dist/renderer/runtime/text.d.ts.map +1 -0
  175. package/dist/renderer/runtime/text.js +82 -0
  176. package/dist/renderer/runtime/text.js.map +1 -0
  177. package/dist/renderer/runtime/types.d.ts +7 -2
  178. package/dist/renderer/runtime/types.d.ts.map +1 -1
  179. package/dist/runtime.d.ts +0 -1
  180. package/dist/runtime.d.ts.map +1 -1
  181. package/dist/runtime.js +0 -1
  182. package/dist/runtime.js.map +1 -1
  183. package/dist/scene.d.ts +1 -1
  184. package/dist/scene.d.ts.map +1 -1
  185. package/dist/scene.js +2 -2
  186. package/dist/scene.js.map +1 -1
  187. package/dist/shadcn.d.ts +169 -137
  188. package/dist/shadcn.d.ts.map +1 -1
  189. package/dist/shadcn.js +8 -5
  190. package/dist/shadcn.js.map +1 -1
  191. package/dist/spec/bsx_v2.json +3080 -2372
  192. package/dist/spec/catalogs/base@3.json +13029 -0
  193. package/dist/spec/catalogs/base@3.json.js +13029 -0
  194. package/dist/spec/catalogs/orkestrator@1.json +489 -0
  195. package/dist/spec/catalogs/orkestrator@1.json.js +489 -0
  196. package/dist/spec/catalogs.d.ts +109 -46
  197. package/dist/spec/catalogs.d.ts.map +1 -1
  198. package/dist/spec/catalogs.js +241 -73
  199. package/dist/spec/catalogs.js.map +1 -1
  200. package/dist/spec/vocabulary.d.ts +21 -3
  201. package/dist/spec/vocabulary.d.ts.map +1 -1
  202. package/dist/spec/vocabulary.js +16 -2
  203. package/dist/spec/vocabulary.js.map +1 -1
  204. package/dist/spec/vocabulary.json +73 -27
  205. package/dist/spec/vocabulary.json.js +73 -27
  206. package/dist/vendor/core/ui/button-group.d.ts +1 -1
  207. package/dist/vendor/core/ui/button.d.ts +1 -1
  208. package/dist/vendor/core/ui/field.d.ts +1 -1
  209. package/package.json +1 -1
  210. package/src/bsx/infer.test.ts +18 -26
  211. package/src/bsx/language.test.ts +2 -2
  212. package/src/bsx/parse.ts +18 -62
  213. package/src/bsx/partial.test.ts +1 -1
  214. package/src/bsx/print.ts +24 -34
  215. package/src/bsx/references.test.ts +71 -10
  216. package/src/bsx/references.ts +114 -35
  217. package/src/catalogs/catalogs.test.ts +45 -14
  218. package/src/catalogs/html.ts +3 -3
  219. package/src/catalogs/index.ts +6 -2
  220. package/src/catalogs/logo.ts +3 -3
  221. package/src/catalogs/parts/forms.ts +32 -0
  222. package/src/catalogs/parts/html.ts +1 -1
  223. package/src/catalogs/parts/icons.ts +1 -1
  224. package/src/catalogs/parts/layout.ts +11 -0
  225. package/src/catalogs/parts/logo.ts +2 -2
  226. package/src/catalogs/parts/run.ts +1 -1
  227. package/src/catalogs/parts/scene.ts +6 -0
  228. package/src/catalogs/parts/structure.ts +2 -2
  229. package/src/catalogs/parts/toast.ts +1 -1
  230. package/src/catalogs/parts/typography.ts +1 -1
  231. package/src/catalogs/scene.ts +3 -3
  232. package/src/catalogs/shadcn.ts +6 -4
  233. package/src/catalogs/structure.ts +3 -3
  234. package/src/catalogs/ui.ts +4 -3
  235. package/src/catalogs.ts +9 -2
  236. package/src/ports.ts +1 -1
  237. package/src/renderer/BlokRenderer.tsx +9 -0
  238. package/src/renderer/addBlokComponents.test.tsx +8 -22
  239. package/src/renderer/baseCatalog.ts +7 -5
  240. package/src/renderer/bloks/components.test.tsx +2 -2
  241. package/src/renderer/bloks/control.tsx +133 -6
  242. package/src/renderer/bloks/flow.test.tsx +1 -1
  243. package/src/renderer/bloks/forms.tsx +126 -0
  244. package/src/renderer/bloks/html.tsx +2 -2
  245. package/src/renderer/bloks/index.ts +1 -1
  246. package/src/renderer/bloks/layout.tsx +28 -0
  247. package/src/renderer/bloks/logo/index.tsx +2 -2
  248. package/src/renderer/bloks/run/components.tsx +1 -1
  249. package/src/renderer/bloks/run/host.tsx +33 -3
  250. package/src/renderer/bloks/run/space.test.tsx +76 -0
  251. package/src/renderer/bloks/time.test.tsx +1 -1
  252. package/src/renderer/bloks/toast.tsx +1 -1
  253. package/src/renderer/bloks/typography.tsx +1 -1
  254. package/src/renderer/catalog.tsx +7 -31
  255. package/src/renderer/declare.test.ts +41 -0
  256. package/src/renderer/declare.ts +70 -32
  257. package/src/renderer/functions/v2/functions.test.ts +40 -1
  258. package/src/renderer/functions/v2/index.ts +47 -0
  259. package/src/renderer/runtime/catalog.ts +35 -10
  260. package/src/renderer/runtime/components.tsx +10 -1
  261. package/src/renderer/runtime/context.tsx +6 -0
  262. package/src/renderer/runtime/describe.ts +17 -4
  263. package/src/renderer/runtime/hooks.ts +1 -0
  264. package/src/renderer/runtime/index.ts +1 -0
  265. package/src/renderer/runtime/preflight.ts +5 -2
  266. package/src/renderer/runtime/resolution.test.ts +14 -0
  267. package/src/renderer/runtime/resolution.ts +15 -1
  268. package/src/renderer/runtime/task.ts +33 -4
  269. package/src/renderer/runtime/text.test.tsx +65 -0
  270. package/src/renderer/runtime/text.ts +88 -0
  271. package/src/renderer/runtime/types.ts +7 -2
  272. package/src/runtime.ts +0 -1
  273. package/src/scene.ts +2 -2
  274. package/src/shadcn.ts +8 -5
  275. package/src/spec/bsx_v2.json +3080 -2372
  276. package/src/spec/catalogs/base@3.json +13029 -0
  277. package/src/spec/catalogs/orkestrator@1.json +489 -0
  278. package/src/spec/catalogs.ts +257 -101
  279. package/src/spec/spec.test.ts +107 -21
  280. package/src/spec/vocabulary.json +73 -27
  281. package/src/spec/vocabulary.ts +36 -7
  282. package/dist/renderer/modules.d.ts +0 -4
  283. package/dist/renderer/modules.d.ts.map +0 -1
  284. package/dist/renderer/modules.js +0 -11
  285. package/dist/renderer/modules.js.map +0 -1
  286. package/dist/spec/catalogs/base@2.json +0 -222
  287. package/dist/spec/catalogs/base@2.json.js +0 -222
  288. package/dist/spec/catalogs/html@1.json +0 -308
  289. package/dist/spec/catalogs/html@1.json.js +0 -308
  290. package/dist/spec/catalogs/logo@1.json +0 -1687
  291. package/dist/spec/catalogs/logo@1.json.js +0 -1687
  292. package/dist/spec/catalogs/scene@1.json +0 -858
  293. package/dist/spec/catalogs/scene@1.json.js +0 -858
  294. package/dist/spec/catalogs/shadcn@1.json +0 -3860
  295. package/dist/spec/catalogs/shadcn@1.json.js +0 -3860
  296. package/dist/spec/catalogs/structure@1.json +0 -185
  297. package/dist/spec/catalogs/structure@1.json.js +0 -185
  298. package/dist/spec/catalogs/ui@1.json +0 -5349
  299. package/dist/spec/catalogs/ui@1.json.js +0 -5349
  300. package/src/renderer/modules.ts +0 -12
  301. package/src/spec/catalogs/base@2.json +0 -222
  302. package/src/spec/catalogs/html@1.json +0 -308
  303. package/src/spec/catalogs/logo@1.json +0 -1687
  304. package/src/spec/catalogs/scene@1.json +0 -858
  305. package/src/spec/catalogs/shadcn@1.json +0 -3860
  306. package/src/spec/catalogs/structure@1.json +0 -185
  307. package/src/spec/catalogs/ui@1.json +0 -5349
@@ -3,6 +3,16 @@ import {Button as ShadButton} from '../../vendor/core/ui/button';
3
3
  import {ButtonGroup as ShadButtonGroup} from '../../vendor/core/ui/button-group';
4
4
  import {Calendar as ShadCalendar} from '../../vendor/core/ui/calendar';
5
5
  import {Checkbox as ShadCheckbox} from '../../vendor/core/ui/checkbox';
6
+ import {
7
+ Command as ShadCommand,
8
+ CommandEmpty as ShadCommandEmpty,
9
+ CommandGroup as ShadCommandGroup,
10
+ CommandInput as ShadCommandInput,
11
+ CommandItem as ShadCommandItem,
12
+ CommandList as ShadCommandList,
13
+ } from '../../vendor/core/ui/command';
14
+ import {Popover as ShadPopover, PopoverContent as ShadPopoverContent, PopoverTrigger as ShadPopoverTrigger} from '../../vendor/core/ui/popover';
15
+ import {CalendarDays, Check, ChevronsUpDown} from 'lucide-react';
6
16
  import {
7
17
  Field as ShadField,
8
18
  FieldDescription as ShadFieldDescription,
@@ -765,6 +775,120 @@ const CalendarRender: BlokRender<Contracts['Calendar']> = ({component, schema})
765
775
  );
766
776
  };
767
777
 
778
+ const optionsOf = (raw: unknown): {value: string; label: string}[] =>
779
+ (Array.isArray(raw) ? raw : []).flatMap(option => {
780
+ if (typeof option === 'string') return [{value: option, label: option}];
781
+ if (option !== null && typeof option === 'object' && typeof (option as {value?: unknown}).value === 'string') {
782
+ const {value, label} = option as {value: string; label?: unknown};
783
+ return [{value, label: typeof label === 'string' ? label : value}];
784
+ }
785
+ return [];
786
+ });
787
+
788
+ const ComboboxRender: BlokRender<Contracts['Combobox']> = ({component, schema}) => {
789
+ const blok = useBlok(component, schema);
790
+ const bind = useValue(blok.bind);
791
+ const value = useValue(blok.value);
792
+ const defaultValue = useValue(blok.defaultValue);
793
+ const options = optionsOf(useValue(blok.options));
794
+ const placeholder = useValue(blok.placeholder);
795
+ const searchPlaceholder = useValue(blok.searchPlaceholder);
796
+ const emptyText = useValue(blok.emptyText);
797
+ const disabled = useValue(blok.disabled);
798
+ const className = useValue(blok.className);
799
+ const onChange = useEventAction(blok.onChange);
800
+ const [open, setOpen] = React.useState(false);
801
+
802
+ const controlled = useControlledValue<string>({bind, value, defaultValue, fallback: '', parse: asString});
803
+ const picked = options.find(option => option.value === controlled.value);
804
+
805
+ return (
806
+ <ShadPopover open={open} onOpenChange={setOpen}>
807
+ <ShadPopoverTrigger asChild>
808
+ <ShadButton
809
+ type="button"
810
+ variant="outline"
811
+ role="combobox"
812
+ aria-expanded={open}
813
+ disabled={disabled === true}
814
+ className={cn('w-full justify-between font-normal', !picked && 'text-muted-foreground', className)}
815
+ >
816
+ <span className="truncate">{picked?.label ?? (asString(placeholder) || 'Pick one')}</span>
817
+ <ChevronsUpDown className="size-4 shrink-0 opacity-50" />
818
+ </ShadButton>
819
+ </ShadPopoverTrigger>
820
+ <ShadPopoverContent className="w-(--radix-popover-trigger-width) p-0" align="start">
821
+ <ShadCommand>
822
+ <ShadCommandInput placeholder={asString(searchPlaceholder) || 'Search'} />
823
+ <ShadCommandList>
824
+ <ShadCommandEmpty>{asString(emptyText) || 'Nothing found'}</ShadCommandEmpty>
825
+ <ShadCommandGroup>
826
+ {options.map(option => (
827
+ <ShadCommandItem
828
+ key={option.value}
829
+ // Typing matches what is read, not the value behind it.
830
+ value={option.label}
831
+ onSelect={() => {
832
+ controlled.setValue(option.value);
833
+ onChange?.(option.value);
834
+ setOpen(false);
835
+ }}
836
+ >
837
+ <span className="truncate">{option.label}</span>
838
+ {option.value === controlled.value ? <Check className="ml-auto size-4" /> : null}
839
+ </ShadCommandItem>
840
+ ))}
841
+ </ShadCommandGroup>
842
+ </ShadCommandList>
843
+ </ShadCommand>
844
+ </ShadPopoverContent>
845
+ </ShadPopover>
846
+ );
847
+ };
848
+
849
+ const DatePickerRender: BlokRender<Contracts['DatePicker']> = ({component, schema}) => {
850
+ const blok = useBlok(component, schema);
851
+ const bind = useValue(blok.bind);
852
+ const value = useValue(blok.value);
853
+ const defaultValue = useValue(blok.defaultValue);
854
+ const placeholder = useValue(blok.placeholder);
855
+ const disabled = useValue(blok.disabled);
856
+ const className = useValue(blok.className);
857
+ const onChange = useEventAction(blok.onChange);
858
+ const [open, setOpen] = React.useState(false);
859
+
860
+ const controlled = useControlledValue<string>({bind, value, defaultValue, fallback: '', parse: asString});
861
+ const picked = parseIsoDate(controlled.value);
862
+
863
+ return (
864
+ <ShadPopover open={open} onOpenChange={setOpen}>
865
+ <ShadPopoverTrigger asChild>
866
+ <ShadButton
867
+ type="button"
868
+ variant="outline"
869
+ disabled={disabled === true}
870
+ className={cn('w-full justify-start gap-2 font-normal', !picked && 'text-muted-foreground', className)}
871
+ >
872
+ <CalendarDays className="size-4 shrink-0 opacity-50" />
873
+ <span className="truncate">{picked ? picked.toLocaleDateString(undefined, {dateStyle: 'medium', timeZone: 'UTC'}) : asString(placeholder) || 'Pick a date'}</span>
874
+ </ShadButton>
875
+ </ShadPopoverTrigger>
876
+ <ShadPopoverContent className="w-auto p-0" align="start">
877
+ <ShadCalendar
878
+ mode="single"
879
+ selected={picked}
880
+ onSelect={next => {
881
+ const nextValue = next ? toIsoDate(next) : '';
882
+ controlled.setValue(nextValue);
883
+ onChange?.(nextValue);
884
+ setOpen(false);
885
+ }}
886
+ />
887
+ </ShadPopoverContent>
888
+ </ShadPopover>
889
+ );
890
+ };
891
+
768
892
  export const formRenders = {
769
893
  Button: ButtonRender,
770
894
  ButtonGroup: ButtonGroupRender,
@@ -791,4 +915,6 @@ export const formRenders = {
791
915
  FieldSet: FieldSetRender,
792
916
  Field: FieldRender,
793
917
  Calendar: CalendarRender,
918
+ Combobox: ComboboxRender,
919
+ DatePicker: DatePickerRender,
794
920
  };
@@ -8,8 +8,8 @@ import {renderContent, textPresentationClasses, useTextPresentationProps} from '
8
8
  type Contracts = typeof htmlContracts;
9
9
 
10
10
  /**
11
- * ui@1's links and media: `Link`, `Image` and `Code`. Raw HTML tags are not
12
- * part of the language; html@1 keeps only `div`, `p` and `span`, the
11
+ * The ui family's links and media: `Link`, `Image` and `Code`. Raw HTML tags are not
12
+ * part of the language; the html family keeps only `div`, `p` and `span`, the
13
13
  * containers that translate directly to React Native (View, Text).
14
14
  */
15
15
 
@@ -13,7 +13,7 @@ import {typographyRenders} from './typography';
13
13
 
14
14
  /**
15
15
  * The shadcn/HTML/SVG renders, by component name: what `@arkitektio/bsx/shadcn`
16
- * implements ui@1, html@1, logo@1 and shadcn@1 with. Grouped by family as the
16
+ * implements the ui family, the html family, the logo family and the shadcn family with. Grouped by family as the
17
17
  * contracts are (`catalogs/parts`).
18
18
  */
19
19
  export const domRenders = {
@@ -166,6 +166,33 @@ const ScrollAreaRender: BlokRender<Contracts['ScrollArea']> = ({buildChild, comp
166
166
  );
167
167
  };
168
168
 
169
+ /**
170
+ * A long list. Its rows are the children a `foreach` draws straight into it:
171
+ * each is left unlaid and unpainted until it scrolls near the view
172
+ * (`content-visibility`), so a list of thousands costs what a screenful does
173
+ * to draw. The rows are still mounted, as a renderer without a window of its
174
+ * own would mount them.
175
+ */
176
+ const ListRender: BlokRender<Contracts['List']> = ({buildChild, component, schema}) => {
177
+ const blok = useBlok(component, schema);
178
+ const children = useValue(blok.children);
179
+ const className = useValue(blok.className);
180
+ const height = useValue(blok.height);
181
+
182
+ return (
183
+ <div
184
+ className={cn(
185
+ 'flex min-h-0 min-w-0 flex-col overflow-y-auto [&>*]:shrink-0 [&>*]:[contain-intrinsic-size:auto_2.5rem] [&>*]:[content-visibility:auto]',
186
+ !height && 'h-full',
187
+ className,
188
+ )}
189
+ style={{height}}
190
+ >
191
+ {renderChildList(children, buildChild)}
192
+ </div>
193
+ );
194
+ };
195
+
169
196
  const ResizableRender: BlokRender<Contracts['Resizable']> = ({buildChild, component, schema}) => {
170
197
  const blok = useBlok(component, schema);
171
198
  const children = useValue(blok.children);
@@ -293,6 +320,7 @@ export const layoutRenders = {
293
320
  Separator: SeparatorRender,
294
321
  AspectRatio: AspectRatioRender,
295
322
  ScrollArea: ScrollAreaRender,
323
+ List: ListRender,
296
324
  Resizable: ResizableRender,
297
325
  ResizablePanel: ResizablePanelRender,
298
326
  ResizableHandle: ResizableHandleRender,
@@ -22,7 +22,7 @@ import {
22
22
  type Contracts = typeof logoContracts;
23
23
 
24
24
  /**
25
- * The `logo@1` module drawn: see the contract for the language. A node's id is
25
+ * The `logo` family drawn: see the contract for the language. A node's id is
26
26
  * the BSX `id`, and that is what a gradient or a clip path is referenced by.
27
27
  * Ids are made unique per drawing, so two logos on one page never share a
28
28
  * gradient.
@@ -265,7 +265,7 @@ const ClipPathRender: BlokRender<Contracts['ClipPath']> = args => {
265
265
  );
266
266
  };
267
267
 
268
- /** The `logo@1` module: the root, seven shapes, text, and what shapes reference. */
268
+ /** The `logo` family: the root, seven shapes, text, and what shapes reference. */
269
269
  export const logoRenders = {
270
270
  AgentLogo: LogoRootRender,
271
271
  ActionLogo: LogoRootRender,
@@ -16,7 +16,7 @@ import {progressFraction, routePoints, splitRoute, throughKeys} from './math';
16
16
  type Contracts = typeof runContracts;
17
17
 
18
18
  /**
19
- * The components that place an action's dependencies in 3D (scene@1). `Space`
19
+ * The components that place an action's dependencies in 3D (the scene family). `Space`
20
20
  * is a scene whose layout is a shared room, `Placed` draws the agent a
21
21
  * dependency is bound to with that agent's own scene blok where the room keeps
22
22
  * it, and `Route` draws a line through several.
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  /**
4
4
  * What an action's own blok needs from the app that shows a run of it.
5
5
  *
6
- * The blok core draws `Space`, `Placed`, `Route` and `ask`; it does not know
6
+ * The blok core draws `Space`, `Placed`, `Route`, `ask` and `timeline`; it does not know
7
7
  * which agents a run got, how an agent's own scene blok is found, where a room
8
8
  * keeps its devices, or how an ask is answered. The host answers those through
9
9
  * these contexts: the run (rekuest, from the task or a dry run) and the rooms
@@ -13,6 +13,16 @@ import * as React from 'react';
13
13
  * `Popout`'s card is rendered by the scene's HTML half, outside the blok.
14
14
  */
15
15
 
16
+ /** How an `<args />` narrows the form it draws. */
17
+ export type BlokArgsOptions = {
18
+ /** Only these port keys. */
19
+ only?: readonly string[];
20
+ /** Not these port keys. */
21
+ omit?: readonly string[];
22
+ /** What it does with the arguments the caller gave: leaves them out (`hide`, the default) or lists them, locked (`show`). */
23
+ given?: 'hide' | 'show';
24
+ };
25
+
16
26
  /** An agent a run binds a dependency key to. */
17
27
  export type BlokRunAgent = {id: string; name: string};
18
28
 
@@ -21,8 +31,28 @@ export type BlokRunHost = {
21
31
  agentsFor: (key: string) => readonly BlokRunAgent[];
22
32
  /** The run's open ask, answered in place (answering resumes the run); nothing while none is open. */
23
33
  renderAsk: () => React.ReactNode;
24
- /** The form of the arguments of the run an assign blok starts (`<args />`); absent where no run is being started. */
25
- renderArgs?: () => React.ReactNode;
34
+ /**
35
+ * The form of the arguments of the run an assign blok starts (`<args />`); absent where no run is
36
+ * being started. It draws the rest: every argument the caller did not give and no `<arg />` places,
37
+ * narrowed by `options`.
38
+ */
39
+ renderArgs?: (options?: BlokArgsOptions) => React.ReactNode;
40
+ /** One argument of that run, by port key (`<arg key="image" />`); nothing for one the caller gave. */
41
+ renderArg?: (key: string) => React.ReactNode;
42
+ /** The picker of the run's dependencies (`<deps />`): every dependency no `<dep />` places. */
43
+ renderDeps?: () => React.ReactNode;
44
+ /** The picker of one dependency of that run, by key (`<dep key="microscope" />`). */
45
+ renderDep?: (key: string) => React.ReactNode;
46
+ /** What the run returned, as its return ports show it (`<returns />`); nothing before the first yield. */
47
+ renderReturns?: (options?: Pick<BlokArgsOptions, 'only' | 'omit'>) => React.ReactNode;
48
+ /** Where the run stands, as one line (`<status />`). */
49
+ renderStatus?: () => React.ReactNode;
50
+ /**
51
+ * The run's time slider (`<timeline />`): moving it moves what the host shows of the run, this
52
+ * blok with it. Absent where the run has no clock; a host that draws a slider of its own leaves
53
+ * that out for a blok that places this one.
54
+ */
55
+ renderTimeline?: () => React.ReactNode;
26
56
  };
27
57
 
28
58
  const NO_AGENTS: readonly BlokRunAgent[] = Object.freeze([]);
@@ -65,3 +65,79 @@ describe('the argument form an assign blok places', () => {
65
65
  expect(bare.queryByTestId('args-form')).toBeNull();
66
66
  });
67
67
  });
68
+
69
+ describe('the time slider a task blok places', () => {
70
+ it('draws what the host gives for <timeline />, and nothing without a host', () => {
71
+ const tree = [{id: 'root', component: 'Html', children: [{id: 'slider', component: 'timeline'}]}];
72
+ const run: BlokRunHost = {agentsFor: () => [], renderAsk: () => null, renderTimeline: () => <div data-testid="timeline" />};
73
+ const hosted = render(
74
+ <BlokRunHostProvider value={run}>
75
+ <BlokRenderer catalog={testCatalog()} uiComponents={tree} />
76
+ </BlokRunHostProvider>,
77
+ );
78
+ expect(hosted.getByTestId('timeline')).toBeTruthy();
79
+ hosted.unmount();
80
+ const bare = render(<BlokRenderer catalog={testCatalog()} uiComponents={tree} />);
81
+ expect(bare.queryByTestId('timeline')).toBeNull();
82
+ });
83
+ });
84
+
85
+ describe('what an assign blok places one by one', () => {
86
+ it('hands <args /> its options, and <arg />, <deps />, <dep /> their keys', () => {
87
+ const tree = [
88
+ {
89
+ id: 'root',
90
+ component: 'Html',
91
+ children: [
92
+ {id: 'one', component: 'arg', props: [{key: 'key', static_value: 'exposure'}]},
93
+ {id: 'rest', component: 'args', props: [{key: 'omit', static_value: 'gain offset'}, {key: 'given', static_value: 'show'}]},
94
+ {id: 'dep', component: 'dep', props: [{key: 'key', static_value: 'robot'}]},
95
+ {id: 'deps', component: 'deps'},
96
+ ],
97
+ },
98
+ ];
99
+ const renderArgs = vi.fn(() => <div data-testid="args-form" />);
100
+ const run: BlokRunHost = {
101
+ agentsFor: () => [],
102
+ renderAsk: () => null,
103
+ renderArgs,
104
+ renderArg: key => <div data-testid={`arg-${key}`} />,
105
+ renderDeps: () => <div data-testid="deps" />,
106
+ renderDep: key => <div data-testid={`dep-${key}`} />,
107
+ };
108
+ const hosted = render(
109
+ <BlokRunHostProvider value={run}>
110
+ <BlokRenderer catalog={testCatalog()} uiComponents={tree} />
111
+ </BlokRunHostProvider>,
112
+ );
113
+ expect(hosted.getByTestId('arg-exposure')).toBeTruthy();
114
+ expect(hosted.getByTestId('dep-robot')).toBeTruthy();
115
+ expect(hosted.getByTestId('deps')).toBeTruthy();
116
+ expect(renderArgs).toHaveBeenLastCalledWith({only: undefined, omit: ['gain', 'offset'], given: 'show'});
117
+ });
118
+ });
119
+
120
+ describe('what a task blok places of its run', () => {
121
+ it('draws what the host gives for <returns /> and <status />', () => {
122
+ const tree = [
123
+ {
124
+ id: 'root',
125
+ component: 'Html',
126
+ children: [
127
+ {id: 'status', component: 'status'},
128
+ {id: 'result', component: 'returns', props: [{key: 'only', static_value: ['image']}]},
129
+ ],
130
+ },
131
+ ];
132
+ const renderReturns = vi.fn(() => <div data-testid="returns" />);
133
+ const run: BlokRunHost = {agentsFor: () => [], renderAsk: () => null, renderReturns, renderStatus: () => <div data-testid="status" />};
134
+ const hosted = render(
135
+ <BlokRunHostProvider value={run}>
136
+ <BlokRenderer catalog={testCatalog()} uiComponents={tree} />
137
+ </BlokRunHostProvider>,
138
+ );
139
+ expect(hosted.getByTestId('status')).toBeTruthy();
140
+ expect(hosted.getByTestId('returns')).toBeTruthy();
141
+ expect(renderReturns).toHaveBeenLastCalledWith({only: ['image'], omit: undefined});
142
+ });
143
+ });
@@ -4,7 +4,7 @@ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
4
4
  import {renderBsx, testCatalog} from './testing';
5
5
 
6
6
  /**
7
- * `<Time value relative? format?>` (ui@1): a moment, absolute or relative.
7
+ * `<Time value relative? format?>` (the ui family): a moment, absolute or relative.
8
8
  * Relative time ticks inside the component, against the wall clock live and
9
9
  * against `then` while travelling; a blok never reads the clock itself.
10
10
  */
@@ -16,7 +16,7 @@ type Contracts = typeof toastContracts;
16
16
 
17
17
  /**
18
18
  * `<Toast task={move}>`: a notification when a task settles, once per task
19
- * (ui@1). Each outcome slot (`done`, `failed`, `cancelled`) is optional and
19
+ * (the ui family). Each outcome slot (`done`, `failed`, `cancelled`) is optional and
20
20
  * holds the text shown for it:
21
21
  *
22
22
  * <Toast task={move}>
@@ -115,7 +115,7 @@ const useClock = (active: boolean, target: number | null): number => {
115
115
  };
116
116
 
117
117
  /**
118
- * `<Time value relative? format?>` (ui@1): a moment, absolute or relative.
118
+ * `<Time value relative? format?>` (the ui family): a moment, absolute or relative.
119
119
  * Relative time is measured from the viewed moment: the wall clock live
120
120
  * (ticking here), `then` while travelling, so the past renders as it did.
121
121
  */
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import {baseBlokCatalog} from './baseCatalog';
3
- import {moduleShadowsOf} from './modules';
4
3
  import {blokPlatform} from '../platform';
5
4
  import type {BlokCatalog, BlokComponentDefinition} from './runtime';
6
5
 
@@ -18,57 +17,34 @@ export const BlokCatalogProvider = ({catalog, children}: {catalog: BlokCatalog;
18
17
  <BlokCatalogContext.Provider value={catalog}>{children}</BlokCatalogContext.Provider>
19
18
  );
20
19
 
21
- /** The app's catalog when no provider says otherwise: the platform's, or base@2 alone. */
20
+ /** The app's catalog when no provider says otherwise: the platform's, or the language's own elements alone. */
22
21
  export const appBlokCatalog = (): BlokCatalog => blokPlatform().catalog ?? baseBlokCatalog;
23
22
 
24
23
  /** The catalog the app provides here, or the app's. */
25
24
  export const useBlokCatalog = (): BlokCatalog => React.useContext(BlokCatalogContext) ?? appBlokCatalog();
26
25
 
27
- /** A component of a global catalog (`ui@1`, `scene@1`): what a module may draw over. */
28
- const isGlobal = (component: BlokComponentDefinition | undefined): boolean => component?.origin?.includes('@') === true;
29
-
30
26
  /**
31
27
  * Adds components a module brings (`ModuleBuiltins.bloks`) to the catalog, so
32
28
  * everything that reads the app's catalog (the renderer, the registrar, the
33
29
  * export) offers them. Called once, by the composition root that installs the
34
30
  * modules; core never imports a module.
35
31
  *
36
- * A module may draw over a global catalog's component (its own `Slider`):
37
- * the module's is rendered, as the spec's `blok_view` says, and the validator
38
- * warns `catalog.shadow` where a blok uses it. Any other name the catalog
39
- * already holds (base's, the app's own, another module's) is refused, whoever
40
- * brought it. Returns the undo, which puts a drawn-over component back (a dev
41
- * hot reload installs the modules again).
32
+ * A catalog only adds: a name the catalog already holds (the language's, the
33
+ * base catalog's, the app's own, another module's) is refused, whoever brought
34
+ * it. Returns the undo (a dev hot reload installs the modules again).
42
35
  */
43
36
  export const addBlokComponents = (
44
37
  components: readonly BlokComponentDefinition[],
45
38
  catalog: BlokCatalog,
46
39
  ): (() => void) => {
47
- const shadows = moduleShadowsOf(catalog);
48
- const taken = components.filter(component => {
49
- const held = catalog.components.get(component.name);
50
- return held !== undefined && (!isGlobal(held) || shadows.has(component.name));
51
- });
40
+ const taken = components.filter(component => catalog.components.has(component.name));
52
41
  if (taken.length > 0) {
53
42
  throw new Error(`Blok components already in the catalog: ${taken.map(component => component.name).join(', ')}`);
54
43
  }
55
- const previous = new Map<string, BlokComponentDefinition>();
56
- for (const component of components) {
57
- const drawnOver = catalog.components.get(component.name);
58
- if (drawnOver) {
59
- previous.set(component.name, drawnOver);
60
- shadows.add(component.name);
61
- }
62
- catalog.components.set(component.name, component);
63
- }
44
+ for (const component of components) catalog.components.set(component.name, component);
64
45
  return () => {
65
46
  for (const component of components) {
66
- if (catalog.components.get(component.name) !== component) continue;
67
- const restored = previous.get(component.name);
68
- if (restored) {
69
- catalog.components.set(component.name, restored);
70
- shadows.delete(component.name);
71
- } else catalog.components.delete(component.name);
47
+ if (catalog.components.get(component.name) === component) catalog.components.delete(component.name);
72
48
  }
73
49
  };
74
50
  };
@@ -0,0 +1,41 @@
1
+ import {describe, expect, it} from 'vitest';
2
+ import * as z from 'zod';
3
+ import {threeScene} from '../scene';
4
+ import {shadcnExtras, shadcnHtml, shadcnLogo, shadcnUi} from '../shadcn';
5
+ import {hostedStructure} from '../ports/structure/index';
6
+ import {ORKESTRATOR_CATALOG_ID, parseSpecCatalog} from '../spec/catalogs';
7
+ import {addBlokComponents} from './catalog';
8
+ import {blokCatalogSpec, declareBlokUi, ownComponentsOf} from './declare';
9
+ import {BASE_CATALOG_ADDRESS, createBlokComponent, ownBlokCatalog} from './runtime';
10
+
11
+ const gauge = createBlokComponent({name: 'Gauge', service: 'lab', schema: z.object({value: z.number().optional().describe('What it reads.')}).describe('A gauge.')}, () => null);
12
+
13
+ describe('declareBlokUi', () => {
14
+ it('speaks the base catalog in the contexts it draws whole', () => {
15
+ const whole = declareBlokUi({name: 'whole', implements: [shadcnUi, shadcnHtml, shadcnLogo, shadcnExtras, threeScene, hostedStructure]});
16
+ expect(whole.contexts).toEqual(['HTML', 'SCENE', 'LOGO']);
17
+ expect(whole.claims).toEqual(['base@3']);
18
+ const flat = declareBlokUi({name: 'flat', implements: [shadcnUi, shadcnHtml, shadcnLogo, shadcnExtras, hostedStructure]});
19
+ expect(flat.contexts).toEqual(['HTML', 'LOGO']);
20
+ const logos = declareBlokUi({name: 'logos', implements: [shadcnLogo]});
21
+ expect([logos.contexts, logos.claims]).toEqual([['LOGO'], ['base@3']]);
22
+ expect(declareBlokUi({name: 'none', implements: []}).claims).toEqual([]);
23
+ });
24
+
25
+ it('publishes what it draws beyond the base catalog as an app catalog', () => {
26
+ const ui = declareBlokUi({
27
+ name: 'lab',
28
+ implements: [shadcnUi, ownBlokCatalog({name: 'lab', version: 1, description: 'A lab.'}, [gauge])],
29
+ });
30
+ expect(ui.claims).toEqual(['lab@1']);
31
+ expect(ownComponentsOf(ui.catalog).map(component => component.name)).toEqual(['Gauge']);
32
+ const undo = addBlokComponents([createBlokComponent({name: 'Dial', schema: z.object({})}, () => null)], ui.catalog);
33
+ const spec = blokCatalogSpec({id: 'https://acme.example/catalogs/lab/v1', name: 'lab', version: 1, description: 'A lab.'}, ui.catalog);
34
+ undo();
35
+ expect([spec.id, spec.version, spec.minor, spec.extends]).toEqual(['https://acme.example/catalogs/lab/v1', 1, 0, BASE_CATALOG_ADDRESS]);
36
+ expect(spec.components.map(component => [component.name, component.service])).toEqual([['Dial', undefined], ['Gauge', 'lab']]);
37
+ const parsed = parseSpecCatalog(spec, 'lab');
38
+ expect(parsed.components.find(component => component.name === 'Gauge')?.service).toBe('lab');
39
+ expect(blokCatalogSpec({id: ORKESTRATOR_CATALOG_ID, name: 'orkestrator', version: 1, extends: BASE_CATALOG_ADDRESS, description: ''}, ui.catalog).extends).toBe(BASE_CATALOG_ADDRESS);
40
+ });
41
+ });