@elaraai/e3-ui 1.0.102 → 1.0.104

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 (326) hide show
  1. package/dist/src/allocation/functions.d.ts +2 -1
  2. package/dist/src/allocation/functions.d.ts.map +1 -1
  3. package/dist/src/allocation/functions.js +3 -2
  4. package/dist/src/allocation/functions.js.map +1 -1
  5. package/dist/src/allocation/index.d.ts +120 -1
  6. package/dist/src/allocation/index.d.ts.map +1 -1
  7. package/dist/src/allocation/index.js +24 -4
  8. package/dist/src/allocation/index.js.map +1 -1
  9. package/dist/src/bind/data-indexed.d.ts +25 -4
  10. package/dist/src/bind/data-indexed.d.ts.map +1 -1
  11. package/dist/src/bind/data-indexed.js +58 -7
  12. package/dist/src/bind/data-indexed.js.map +1 -1
  13. package/dist/src/bind/data.d.ts +12 -14
  14. package/dist/src/bind/data.d.ts.map +1 -1
  15. package/dist/src/bind/data.js +11 -11
  16. package/dist/src/bind/data.js.map +1 -1
  17. package/dist/src/bind/func.d.ts +7 -2
  18. package/dist/src/bind/func.d.ts.map +1 -1
  19. package/dist/src/bind/func.js +10 -3
  20. package/dist/src/bind/func.js.map +1 -1
  21. package/dist/src/bind/record.d.ts +6 -6
  22. package/dist/src/bind/record.d.ts.map +1 -1
  23. package/dist/src/bind/record.js.map +1 -1
  24. package/dist/src/calendar/index.d.ts +148 -1
  25. package/dist/src/calendar/index.d.ts.map +1 -1
  26. package/dist/src/calendar/index.js +55 -5
  27. package/dist/src/calendar/index.js.map +1 -1
  28. package/dist/src/decision/bind.d.ts.map +1 -1
  29. package/dist/src/decision/index.d.ts +218 -218
  30. package/dist/src/decision/index.d.ts.map +1 -1
  31. package/dist/src/decision/types.d.ts.map +1 -1
  32. package/dist/src/flowchart/canvas.d.ts +32 -14
  33. package/dist/src/flowchart/canvas.d.ts.map +1 -1
  34. package/dist/src/flowchart/canvas.js +21 -6
  35. package/dist/src/flowchart/canvas.js.map +1 -1
  36. package/dist/src/flowchart/details.d.ts +469 -0
  37. package/dist/src/flowchart/details.d.ts.map +1 -0
  38. package/dist/src/flowchart/details.js +1035 -0
  39. package/dist/src/flowchart/details.js.map +1 -0
  40. package/dist/src/flowchart/flowchart.d.ts +16 -72
  41. package/dist/src/flowchart/flowchart.d.ts.map +1 -1
  42. package/dist/src/flowchart/flowchart.js +10 -1
  43. package/dist/src/flowchart/flowchart.js.map +1 -1
  44. package/dist/src/flowchart/index.d.ts +282 -251
  45. package/dist/src/flowchart/index.d.ts.map +1 -1
  46. package/dist/src/flowchart/index.js +234 -220
  47. package/dist/src/flowchart/index.js.map +1 -1
  48. package/dist/src/flowchart/kinds.d.ts +438 -0
  49. package/dist/src/flowchart/kinds.d.ts.map +1 -0
  50. package/dist/src/flowchart/kinds.js +799 -0
  51. package/dist/src/flowchart/kinds.js.map +1 -0
  52. package/dist/src/flowchart/library.d.ts +155 -740
  53. package/dist/src/flowchart/library.d.ts.map +1 -1
  54. package/dist/src/flowchart/library.js +191 -673
  55. package/dist/src/flowchart/library.js.map +1 -1
  56. package/dist/src/flowchart/payload.d.ts +3654 -7845
  57. package/dist/src/flowchart/payload.d.ts.map +1 -1
  58. package/dist/src/flowchart/payload.js +331 -469
  59. package/dist/src/flowchart/payload.js.map +1 -1
  60. package/dist/src/flowchart/templates.d.ts +657 -0
  61. package/dist/src/flowchart/templates.d.ts.map +1 -0
  62. package/dist/src/flowchart/templates.js +658 -0
  63. package/dist/src/flowchart/templates.js.map +1 -0
  64. package/dist/src/flowchart/types.d.ts +2258 -214
  65. package/dist/src/flowchart/types.d.ts.map +1 -1
  66. package/dist/src/flowchart/types.js +374 -124
  67. package/dist/src/flowchart/types.js.map +1 -1
  68. package/dist/src/index.d.ts +13 -15
  69. package/dist/src/index.d.ts.map +1 -1
  70. package/dist/src/index.js +24 -29
  71. package/dist/src/index.js.map +1 -1
  72. package/dist/src/internal.d.ts +5 -7
  73. package/dist/src/internal.d.ts.map +1 -1
  74. package/dist/src/internal.js +12 -19
  75. package/dist/src/internal.js.map +1 -1
  76. package/dist/src/ontology/index.d.ts +44 -15
  77. package/dist/src/ontology/index.d.ts.map +1 -1
  78. package/dist/src/ontology/index.js +19 -11
  79. package/dist/src/ontology/index.js.map +1 -1
  80. package/dist/src/plan/builders.d.ts +26 -26
  81. package/dist/src/plan/builders.d.ts.map +1 -1
  82. package/dist/src/plan/builders.js.map +1 -1
  83. package/dist/src/plan/event-rows.d.ts +59 -58
  84. package/dist/src/plan/event-rows.d.ts.map +1 -1
  85. package/dist/src/plan/event-rows.js +6 -4
  86. package/dist/src/plan/event-rows.js.map +1 -1
  87. package/dist/src/plan/factories.js.map +1 -1
  88. package/dist/src/plan/ir.d.ts +1 -0
  89. package/dist/src/plan/ir.d.ts.map +1 -1
  90. package/dist/src/plan/library.d.ts.map +1 -1
  91. package/dist/src/plan/nested-checks.js.map +1 -1
  92. package/dist/src/plan/plan.d.ts +567 -423
  93. package/dist/src/plan/plan.d.ts.map +1 -1
  94. package/dist/src/plan/plan.js +67 -3
  95. package/dist/src/plan/plan.js.map +1 -1
  96. package/dist/src/plan/series.d.ts.map +1 -1
  97. package/dist/src/plan/series.js.map +1 -1
  98. package/dist/src/plan/types.d.ts +173 -172
  99. package/dist/src/plan/types.d.ts.map +1 -1
  100. package/dist/src/query/builder.d.ts +368 -321
  101. package/dist/src/query/builder.d.ts.map +1 -1
  102. package/dist/src/query/builder.js +12 -1
  103. package/dist/src/query/builder.js.map +1 -1
  104. package/dist/src/query/index.d.ts +5 -1
  105. package/dist/src/query/index.d.ts.map +1 -1
  106. package/dist/src/query/index.js +3 -1
  107. package/dist/src/query/index.js.map +1 -1
  108. package/dist/src/query/library.d.ts +6 -6
  109. package/dist/src/query/queries.d.ts +3 -3
  110. package/dist/src/roster/fit.d.ts +5 -2
  111. package/dist/src/roster/fit.d.ts.map +1 -1
  112. package/dist/src/roster/fit.js +5 -3
  113. package/dist/src/roster/fit.js.map +1 -1
  114. package/dist/src/roster/index.d.ts +103 -2
  115. package/dist/src/roster/index.d.ts.map +1 -1
  116. package/dist/src/roster/index.js +45 -6
  117. package/dist/src/roster/index.js.map +1 -1
  118. package/dist/src/runtime/index.d.ts +1 -3
  119. package/dist/src/runtime/index.d.ts.map +1 -1
  120. package/dist/src/runtime/index.js +1 -3
  121. package/dist/src/runtime/index.js.map +1 -1
  122. package/dist/src/schedule/fields.js.map +1 -1
  123. package/dist/src/schedule/library.js.map +1 -1
  124. package/dist/src/schedule/record-window.d.ts +27 -26
  125. package/dist/src/schedule/record-window.d.ts.map +1 -1
  126. package/dist/src/schedule/types.d.ts +196 -196
  127. package/dist/src/schematic/index.d.ts +1 -1
  128. package/dist/src/schematic/index.d.ts.map +1 -1
  129. package/dist/src/schematic/index.js +1 -1
  130. package/dist/src/schematic/index.js.map +1 -1
  131. package/dist/src/schematic/kinds.d.ts +4 -24
  132. package/dist/src/schematic/kinds.d.ts.map +1 -1
  133. package/dist/src/schematic/kinds.js +8 -212
  134. package/dist/src/schematic/kinds.js.map +1 -1
  135. package/dist/src/schematic/library.d.ts.map +1 -1
  136. package/dist/src/schematic/payload.d.ts +1688 -1549
  137. package/dist/src/schematic/payload.d.ts.map +1 -1
  138. package/dist/src/schematic/payload.js +38 -1
  139. package/dist/src/schematic/payload.js.map +1 -1
  140. package/dist/src/schematic/shapes.d.ts.map +1 -1
  141. package/dist/src/schematic/types.d.ts +978 -978
  142. package/dist/src/schematic/types.d.ts.map +1 -1
  143. package/dist/src/schematic/types.js +4 -36
  144. package/dist/src/schematic/types.js.map +1 -1
  145. package/dist/src/schematic/window.d.ts +9 -42
  146. package/dist/src/schematic/window.d.ts.map +1 -1
  147. package/dist/src/schematic/window.js +10 -115
  148. package/dist/src/schematic/window.js.map +1 -1
  149. package/dist/src/sheet/actions.d.ts +388 -0
  150. package/dist/src/sheet/actions.d.ts.map +1 -0
  151. package/dist/src/sheet/actions.js +594 -0
  152. package/dist/src/sheet/actions.js.map +1 -0
  153. package/dist/src/sheet/bridge.d.ts +12 -1
  154. package/dist/src/sheet/bridge.d.ts.map +1 -1
  155. package/dist/src/sheet/bridge.js +30 -6
  156. package/dist/src/sheet/bridge.js.map +1 -1
  157. package/dist/src/sheet/columns.d.ts +5 -2
  158. package/dist/src/sheet/columns.d.ts.map +1 -1
  159. package/dist/src/sheet/columns.js.map +1 -1
  160. package/dist/src/sheet/draft-bridge.d.ts +9 -4
  161. package/dist/src/sheet/draft-bridge.d.ts.map +1 -1
  162. package/dist/src/sheet/draft-bridge.js +22 -7
  163. package/dist/src/sheet/draft-bridge.js.map +1 -1
  164. package/dist/src/sheet/editing-types.d.ts +71 -71
  165. package/dist/src/sheet/fields.d.ts +13 -0
  166. package/dist/src/sheet/fields.d.ts.map +1 -1
  167. package/dist/src/sheet/fields.js +3 -0
  168. package/dist/src/sheet/fields.js.map +1 -1
  169. package/dist/src/sheet/group.js.map +1 -1
  170. package/dist/src/sheet/index.d.ts +32 -2
  171. package/dist/src/sheet/index.d.ts.map +1 -1
  172. package/dist/src/sheet/index.js +18 -3
  173. package/dist/src/sheet/index.js.map +1 -1
  174. package/dist/src/sheet/library.d.ts +8 -0
  175. package/dist/src/sheet/library.d.ts.map +1 -1
  176. package/dist/src/sheet/library.js.map +1 -1
  177. package/dist/src/sheet/link.d.ts.map +1 -1
  178. package/dist/src/sheet/record.js.map +1 -1
  179. package/dist/src/sheet/root.d.ts +23 -1
  180. package/dist/src/sheet/root.d.ts.map +1 -1
  181. package/dist/src/sheet/root.js +40 -5
  182. package/dist/src/sheet/root.js.map +1 -1
  183. package/dist/src/sheet/sheet.d.ts +9332 -5621
  184. package/dist/src/sheet/sheet.d.ts.map +1 -1
  185. package/dist/src/sheet/sheet.js +41 -2
  186. package/dist/src/sheet/sheet.js.map +1 -1
  187. package/dist/src/sheet/templates.d.ts +4 -0
  188. package/dist/src/sheet/templates.d.ts.map +1 -1
  189. package/dist/src/sheet/types.d.ts +13020 -5839
  190. package/dist/src/sheet/types.d.ts.map +1 -1
  191. package/dist/src/sheet/types.js +114 -2
  192. package/dist/src/sheet/types.js.map +1 -1
  193. package/dist/src/studio/builder.d.ts +6 -6
  194. package/dist/src/studio/library.d.ts +9 -9
  195. package/dist/src/studio/pages.d.ts +6 -6
  196. package/dist/src/studio/publish.d.ts +3 -3
  197. package/dist/src/utils/derive.d.ts +1 -1
  198. package/dist/src/utils/derive.js +1 -1
  199. package/dist/src/utils/derive.js.map +1 -1
  200. package/dist/src/utils/key-visibility.d.ts +1 -1
  201. package/dist/src/utils/record-kind.d.ts +625 -0
  202. package/dist/src/utils/record-kind.d.ts.map +1 -0
  203. package/dist/src/utils/record-kind.js +450 -0
  204. package/dist/src/utils/record-kind.js.map +1 -0
  205. package/dist/src/utils/views.d.ts +55 -0
  206. package/dist/src/utils/views.d.ts.map +1 -0
  207. package/dist/src/utils/views.js +72 -0
  208. package/dist/src/utils/views.js.map +1 -0
  209. package/dist/src/utils/vocabulary.d.ts +48 -0
  210. package/dist/src/utils/vocabulary.d.ts.map +1 -0
  211. package/dist/src/utils/vocabulary.js +47 -0
  212. package/dist/src/utils/vocabulary.js.map +1 -0
  213. package/dist/test/allocation/allocation.examples.d.ts +3 -1
  214. package/dist/test/allocation/allocation.examples.d.ts.map +1 -1
  215. package/dist/test/allocation/allocation.examples.js +81 -2
  216. package/dist/test/allocation/allocation.examples.js.map +1 -1
  217. package/dist/test/bind/data/data.examples.d.ts +1 -1
  218. package/dist/test/bind/func/func.examples.d.ts +19 -1
  219. package/dist/test/bind/func/func.examples.d.ts.map +1 -1
  220. package/dist/test/bind/func/func.examples.js +36 -1
  221. package/dist/test/bind/func/func.examples.js.map +1 -1
  222. package/dist/test/calendar/calendar.examples.d.ts +2 -0
  223. package/dist/test/calendar/calendar.examples.d.ts.map +1 -1
  224. package/dist/test/calendar/calendar.examples.js +80 -2
  225. package/dist/test/calendar/calendar.examples.js.map +1 -1
  226. package/dist/test/decision/queue.examples.d.ts +1 -0
  227. package/dist/test/decision/queue.examples.d.ts.map +1 -1
  228. package/dist/test/decision/queue.examples.js +12 -0
  229. package/dist/test/decision/queue.examples.js.map +1 -1
  230. package/dist/test/examples-package.d.ts.map +1 -1
  231. package/dist/test/examples-package.js +5 -4
  232. package/dist/test/examples-package.js.map +1 -1
  233. package/dist/test/flowchart/flowchart.examples.d.ts +1250 -4605
  234. package/dist/test/flowchart/flowchart.examples.d.ts.map +1 -1
  235. package/dist/test/flowchart/flowchart.examples.js +861 -512
  236. package/dist/test/flowchart/flowchart.examples.js.map +1 -1
  237. package/dist/test/ontology/ontology.examples.d.ts +2 -3
  238. package/dist/test/ontology/ontology.examples.d.ts.map +1 -1
  239. package/dist/test/ontology/ontology.examples.js +32 -21
  240. package/dist/test/ontology/ontology.examples.js.map +1 -1
  241. package/dist/test/plan/plan-events.examples.d.ts +1 -0
  242. package/dist/test/plan/plan-events.examples.d.ts.map +1 -1
  243. package/dist/test/plan/plan-events.examples.js +44 -0
  244. package/dist/test/plan/plan-events.examples.js.map +1 -1
  245. package/dist/test/plan/plan-nested.examples.d.ts +15 -15
  246. package/dist/test/plan/plan-nested.examples.d.ts.map +1 -1
  247. package/dist/test/plan/plan-nested.examples.js +5 -5
  248. package/dist/test/plan/plan-nested.examples.js.map +1 -1
  249. package/dist/test/plan/plan-records.examples.d.ts.map +1 -1
  250. package/dist/test/plan/plan-records.examples.js +1 -1
  251. package/dist/test/plan/plan-records.examples.js.map +1 -1
  252. package/dist/test/plan/plan.examples.js.map +1 -1
  253. package/dist/test/query/query.examples.d.ts +2 -0
  254. package/dist/test/query/query.examples.d.ts.map +1 -1
  255. package/dist/test/query/query.examples.js +37 -1
  256. package/dist/test/query/query.examples.js.map +1 -1
  257. package/dist/test/roster/domain.examples.d.ts.map +1 -1
  258. package/dist/test/roster/roster.examples.d.ts +2 -0
  259. package/dist/test/roster/roster.examples.d.ts.map +1 -1
  260. package/dist/test/roster/roster.examples.js +76 -15
  261. package/dist/test/roster/roster.examples.js.map +1 -1
  262. package/dist/test/schematic/schematic-records.examples.d.ts.map +1 -1
  263. package/dist/test/schematic/schematic-records.examples.js +6 -4
  264. package/dist/test/schematic/schematic-records.examples.js.map +1 -1
  265. package/dist/test/schematic/schematic.examples.d.ts +1 -0
  266. package/dist/test/schematic/schematic.examples.d.ts.map +1 -1
  267. package/dist/test/schematic/schematic.examples.js +144 -0
  268. package/dist/test/schematic/schematic.examples.js.map +1 -1
  269. package/dist/test/sheet/sheet-actions.examples.d.ts +1264 -0
  270. package/dist/test/sheet/sheet-actions.examples.d.ts.map +1 -0
  271. package/dist/test/sheet/sheet-actions.examples.js +394 -0
  272. package/dist/test/sheet/sheet-actions.examples.js.map +1 -0
  273. package/dist/test/sheet/sheet-records.examples.d.ts +1 -1
  274. package/dist/test/sheet/sheet.examples.d.ts +1 -0
  275. package/dist/test/sheet/sheet.examples.d.ts.map +1 -1
  276. package/dist/test/sheet/sheet.examples.js +77 -0
  277. package/dist/test/sheet/sheet.examples.js.map +1 -1
  278. package/dist/test/studio/studio.examples.d.ts +1 -0
  279. package/dist/test/studio/studio.examples.d.ts.map +1 -1
  280. package/dist/test/studio/studio.examples.js +18 -8
  281. package/dist/test/studio/studio.examples.js.map +1 -1
  282. package/package.json +14 -13
  283. package/dist/src/diff/index.d.ts +0 -407
  284. package/dist/src/diff/index.d.ts.map +0 -1
  285. package/dist/src/diff/index.js +0 -203
  286. package/dist/src/diff/index.js.map +0 -1
  287. package/dist/src/experiment/index.d.ts +0 -1033
  288. package/dist/src/experiment/index.d.ts.map +0 -1
  289. package/dist/src/experiment/index.js +0 -197
  290. package/dist/src/experiment/index.js.map +0 -1
  291. package/dist/src/experiment/types.d.ts +0 -1093
  292. package/dist/src/experiment/types.d.ts.map +0 -1
  293. package/dist/src/experiment/types.js +0 -423
  294. package/dist/src/experiment/types.js.map +0 -1
  295. package/dist/src/flowchart/over.d.ts +0 -227
  296. package/dist/src/flowchart/over.d.ts.map +0 -1
  297. package/dist/src/flowchart/over.js +0 -213
  298. package/dist/src/flowchart/over.js.map +0 -1
  299. package/dist/src/flowchart/patch.d.ts +0 -64
  300. package/dist/src/flowchart/patch.d.ts.map +0 -1
  301. package/dist/src/flowchart/patch.js +0 -67
  302. package/dist/src/flowchart/patch.js.map +0 -1
  303. package/dist/src/flowchart/values.d.ts +0 -271
  304. package/dist/src/flowchart/values.d.ts.map +0 -1
  305. package/dist/src/flowchart/values.js +0 -220
  306. package/dist/src/flowchart/values.js.map +0 -1
  307. package/dist/src/flowchart/window.d.ts +0 -306
  308. package/dist/src/flowchart/window.d.ts.map +0 -1
  309. package/dist/src/flowchart/window.js +0 -63
  310. package/dist/src/flowchart/window.js.map +0 -1
  311. package/dist/src/runtime/diff.d.ts +0 -36
  312. package/dist/src/runtime/diff.d.ts.map +0 -1
  313. package/dist/src/runtime/diff.js +0 -34
  314. package/dist/src/runtime/diff.js.map +0 -1
  315. package/dist/src/runtime/experiment.d.ts +0 -48
  316. package/dist/src/runtime/experiment.d.ts.map +0 -1
  317. package/dist/src/runtime/experiment.js +0 -10
  318. package/dist/src/runtime/experiment.js.map +0 -1
  319. package/dist/test/diff/diff.examples.d.ts +0 -313
  320. package/dist/test/diff/diff.examples.d.ts.map +0 -1
  321. package/dist/test/diff/diff.examples.js +0 -452
  322. package/dist/test/diff/diff.examples.js.map +0 -1
  323. package/dist/test/experiment/experiment.examples.d.ts +0 -1512
  324. package/dist/test/experiment/experiment.examples.d.ts.map +0 -1
  325. package/dist/test/experiment/experiment.examples.js +0 -609
  326. package/dist/test/experiment/experiment.examples.js.map +0 -1
@@ -3,420 +3,158 @@
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
5
  /**
6
- * `Flowchart.library` — the flowchart's library pane (#1246, #1248,
7
- * `Flowchart Builder Spec.md` decisions 5–8, §4.2, §4.4, FB13, FB25–FB29):
8
- * `library` lists the pane's tabs, in order, each a `Flowchart.library.*`
9
- * call. Left out, or empty, the flowchart has no library pane.
6
+ * `Flowchart.library` (#1501, `Flowchart Records Spec.md` R14, D5, D8): the
7
+ * library pane's tabs, which `library` lists in order, and their wire, which
8
+ * the renderer draws. A kind's cards are on the kind, as the Schematic's are —
9
+ * `Flowchart.templates(rows, { name, group?, values, source })`, rows of a
10
+ * record of the app's — and its tab lists them, following their source of the
11
+ * slice:
10
12
  *
11
- * - `Flowchart.library.flows()` (#1246) — the Flows tab: every flow the
12
- * flowchart holds by name, a click opening one on the canvas, and "+ New
13
- * flow" naming another. Over one flow there is none to list, so one flow's
14
- * library takes every tab but it.
15
- * - `Flowchart.library.states(rows, { … })` — state templates: one card per
16
- * row, its `drop` the fields of the state a card dropped on a lane adds.
17
- * - `Flowchart.library.transitions(rows, { … })` — transition templates: one
18
- * card per row, its `drop` the fields a card sets on the transition it lands
19
- * on.
20
- * - `Flowchart.library.tab(rows, { … })` — the author's own cards; given a
21
- * `drop`, its patch's type names what a card lands on: a state, a
22
- * transition, a lane's header or a decision's diamond.
13
+ * - `Flowchart.library.states()` — the Steps tab, the states' cards: one
14
+ * dropped on a lane adds a state there from its values, keyed `state-<n>`,
15
+ * its order between the cards it lands between.
16
+ * - `Flowchart.library.transitions()` — the Transitions tab, the transitions'
17
+ * cards: one dropped on a transition gives it its values, its ends kept.
18
+ * - `Flowchart.library.lanes()` — the Lanes tab, the lanes' cards: one dropped
19
+ * between two lanes, or at the band row's tail, adds a lane there from its
20
+ * values, keyed `lane-<n>`, its order between theirs.
21
+ * - `Flowchart.library.tab(rows, { … })` — the app's own cards: its `drop` a
22
+ * `Flowchart.patch(R, { … })` over one kind's row type, which names the kind
23
+ * its cards land on — a state's, a transition's, a lane's or a decision's —
24
+ * through the shared `buildScheduleTab`, as the Schematic's tabs are.
23
25
  *
24
- * Each data tab takes its own bound data (the user, 2026-10-08), apart from
25
- * the flows and from the other tabs, read as `Sheet.library.tab` reads its
26
- * rows: its accessors `(row, key) => …` reified once into a describe function
27
- * the rows' map then calls, a Dict's key the second argument and an Array's
28
- * index, printed, in its place. A card crosses the closed payload as the
29
- * fields its drop sets, typed by the row it lands on — a flow's rows are the
30
- * flowchart's own types. Dropped on the canvas (#1249), a state template adds
31
- * a state where it lands on a lane, a transition template retypes the
32
- * transition it lands on, and an author's card sets its fields on what its
33
- * drop's type names; ⏎ on a card drops it on the canvas's selection.
34
- *
35
- * Templates are records (#1340, ruling 9): the state and the transition
36
- * templates are each a record of their own, read whole
37
- * (`Data.bind(record).read()`, a `Dict<String, T>`), each card keyed by its
38
- * record's key, and each list names its `source` of the flowchart's one
39
- * `Slice.bindRecords`, which narrows its cards by those keys as it narrows
40
- * anything of that record's — a list written in the code names none, and is
41
- * refused, naming the change (#1346). An author's tab reads an `Array<T>` or
42
- * a `Dict<String, T>`, each card keyed by its `key`, a key that repeats
43
- * keeping its first card; naming a `source` it follows that source by its
44
- * cards' keys, and naming none it lists its rows whole.
26
+ * There is no Flows tab: the Flowchart draws one flowchart. Left out, or
27
+ * empty, the Flowchart has no library pane.
45
28
  *
46
29
  * @packageDocumentation
47
30
  */
48
- import { ArrayType, DictType, East, Expr, NullType, OptionType, SetType, StringType, StructType, VariantType, isTypeEqual, none, printType, some, variant, } from "@elaraai/east";
49
- import { tabSource, templatesSource } from "../utils/record-sources.js";
50
- import { FlowchartPatchTypeFor } from "./patch.js";
51
- import { FlowchartLaneType, FlowchartLinkType, FlowchartStateType, FlowchartTriggerType } from "./types.js";
31
+ import { ArrayType, East, Expr, OptionType, StringType, StructType, VariantType, isTypeEqual, none, printType, some, variant, } from "@elaraai/east";
32
+ import { ScheduleAuthorTabType, buildScheduleTab } from "../schedule/library.js";
33
+ export { ScheduleLibraryCardType as FlowchartLibraryCardType } from "../schedule/library.js";
52
34
  // ============================================================================
53
35
  // The wire
54
36
  // ============================================================================
55
37
  /**
56
- * A card a library tab lists that drops nothing: an author's card read, never
57
- * dragged.
58
- *
59
- * @property key - Its identity in its tab
60
- * @property label - Its title
61
- * @property meta - A line under its title
62
- * @property group - The group its tab lists it under
63
- */
64
- export const FlowchartCardType = StructType({
65
- key: StringType,
66
- label: StringType,
67
- meta: OptionType(StringType),
68
- group: OptionType(StringType),
69
- });
70
- /**
71
- * A state template's card: what it shows, and the fields of the state it
72
- * adds, over a state's defaults — the `Flowchart.patch(Flowchart.Types.State, …)`
73
- * its drop returns.
74
- */
75
- export const FlowchartStateCardType = StructType({
76
- ...FlowchartCardType.fields,
77
- sets: FlowchartPatchTypeFor(FlowchartStateType),
78
- });
79
- /**
80
- * A transition template's card: what it shows, and the fields it sets on the
81
- * transition it lands on — the `Flowchart.patch(Flowchart.Types.Link, …)` its
82
- * drop returns.
38
+ * A kind's tab on the wire: its name and icon, the author's when given; left
39
+ * out, the renderer names it in its words (`Steps`, `Transitions`, `Lanes`),
40
+ * so a host translates it. Its cards are its kind's. The tab an author lists
41
+ * is a {@link FlowchartKindTab}, which this is built from.
83
42
  */
84
- export const FlowchartTransitionCardType = StructType({
85
- ...FlowchartCardType.fields,
86
- sets: FlowchartPatchTypeFor(FlowchartLinkType),
87
- });
88
- /** An author's card that lands on a lane's header, and the lane's fields it sets. */
89
- export const FlowchartLaneCardType = StructType({
90
- ...FlowchartCardType.fields,
91
- sets: FlowchartPatchTypeFor(FlowchartLaneType),
92
- });
93
- /** An author's card that lands on a decision's diamond, and the decision's fields it sets. */
94
- export const FlowchartDecisionCardType = StructType({
95
- ...FlowchartCardType.fields,
96
- sets: FlowchartPatchTypeFor(FlowchartTriggerType),
43
+ export const FlowchartKindTabWireType = StructType({
44
+ name: OptionType(StringType),
45
+ icon: OptionType(StringType),
97
46
  });
98
47
  /**
99
- * An author's tab's cards, by what they land on — the type of the patch its
100
- * `drop` returns — each card with the fields it sets there.
48
+ * One tab of the library pane on the wire, in the order `library` lists them.
101
49
  *
102
- * @property none - The tab declares no `drop`: its cards are read, never dragged
103
- * @property state - Its cards land on a state
104
- * @property transition - Its cards land on a transition
105
- * @property lane - Its cards land on a lane's header
106
- * @property decision - Its cards land on a decision's diamond
50
+ * @property states - The Steps tab: the states' cards, which the states kind carries
51
+ * @property transitions - The Transitions tab: the transitions' cards
52
+ * @property lanes - The Lanes tab: the lanes' cards
53
+ * @property tab - The author's own: its name, its icon, the kind its cards land on, its cards and the source they follow
107
54
  */
108
- export const FlowchartLandsType = VariantType({
109
- none: ArrayType(FlowchartCardType),
110
- state: ArrayType(FlowchartStateCardType),
111
- transition: ArrayType(FlowchartTransitionCardType),
112
- lane: ArrayType(FlowchartLaneCardType),
113
- decision: ArrayType(FlowchartDecisionCardType),
55
+ export const FlowchartLibraryTabType = VariantType({
56
+ states: FlowchartKindTabWireType,
57
+ transitions: FlowchartKindTabWireType,
58
+ lanes: FlowchartKindTabWireType,
59
+ tab: ScheduleAuthorTabType,
114
60
  });
61
+ /** The cards a kind's `templates` takes, as a refusal writes them. */
62
+ const CARDS = "templates: Flowchart.templates(cards.read(), { name, values, source })";
63
+ /** How each kind's tab is named in a refusal, what its kind is called, and the kind with its cards, as a refusal writes it. */
64
+ const KIND_TABS = {
65
+ states: { call: "Flowchart.library.states()", noun: "states", declare: `Flowchart.states(record, { label, …, ${CARDS} })` },
66
+ transitions: { call: "Flowchart.library.transitions()", noun: "transitions", declare: `Flowchart.transitions(record, { from, to, …, ${CARDS} })` },
67
+ lanes: { call: "Flowchart.library.lanes()", noun: "lanes", declare: `Flowchart.lanes(record, { label, …, ${CARDS} })` },
68
+ };
115
69
  /**
116
- * One tab of the library pane, as `library` lists it (`Flowchart Builder
117
- * Spec.md` §4.2).
70
+ * A kind's tab, its options checked.
118
71
  *
119
- * @remarks
120
- * A card crosses the closed payload as the fields its drop sets, typed by the
121
- * row it lands on — a flow's rows are the flowchart's own types. A template
122
- * tab's name is the author's when given; left out, the renderer names it in
123
- * its words (`States`, `Transitions`), so a host translates it.
124
- *
125
- * @property flows - Every flow in the record — over a slice, those its `flows` source narrows them to; a click opens one
126
- * @property states - State templates from the tab's own record: its name, its icon, its cards, and the source of the slice they follow, by their keys (#1346)
127
- * @property transitions - Transition templates from the tab's own record: its name, its icon, its cards, and the source of the slice they follow, by their keys (#1346)
128
- * @property tab - The author's own cards: its name, its icon, its cards by what they land on, and the source of the slice they follow, by their keys — none, its cards whole (#1346)
72
+ * @param kind - The kind whose cards it lists
73
+ * @param options - The call's first argument
74
+ * @param rest - Any argument after it
75
+ * @returns The tab
76
+ * @throws {Error} When given anything but `{ name?, icon? }` — rows and a config, as the earlier form took, among them — naming the cards on the kind
129
77
  */
130
- export const FlowchartLibraryTabType = VariantType({
131
- flows: NullType,
132
- states: StructType({ name: OptionType(StringType), icon: OptionType(StringType), cards: ArrayType(FlowchartStateCardType), source: StringType }),
133
- transitions: StructType({ name: OptionType(StringType), icon: OptionType(StringType), cards: ArrayType(FlowchartTransitionCardType), source: StringType }),
134
- tab: StructType({ name: StringType, icon: OptionType(StringType), lands: FlowchartLandsType, source: OptionType(StringType) }),
135
- });
78
+ function kindTab(kind, options, rest) {
79
+ const { call, noun, declare } = KIND_TABS[kind];
80
+ const words = `${call} lists the ${noun}' cards, which are on the kind — ${declare} — and takes at most { name, icon }`;
81
+ if (rest.length > 0 || options instanceof Expr || (options !== undefined && (typeof options !== "object" || options === null || Array.isArray(options)))) {
82
+ throw new Error(words);
83
+ }
84
+ const o = (options ?? {});
85
+ for (const key of Object.keys(o)) {
86
+ if (key !== "name" && key !== "icon")
87
+ throw new Error(`${words} — \`${key}\` is neither`);
88
+ }
89
+ if (o["name"] !== undefined && (typeof o["name"] !== "string" || o["name"] === ""))
90
+ throw new Error(`${call}: \`name\` is the tab's name, a string`);
91
+ if (o["icon"] !== undefined && (typeof o["icon"] !== "string" || o["icon"] === ""))
92
+ throw new Error(`${call}: \`icon\` is a Font Awesome solid icon's name`);
93
+ return { kind, name: o["name"], icon: o["icon"] };
94
+ }
136
95
  /**
137
- * The Flows tab — `Flowchart.library.flows()` (FB13, FB14): every flow the
138
- * flowchart holds, by name, each card its name and its description — or, with
139
- * none, its counts — the open flow placed, and a flow whose drafts are not
140
- * yet saved marked Pending. A click opens a flow on the canvas, and the
141
- * tab's search reads names and descriptions. Where the flowchart edits — a
142
- * record, or the host's flows given `onApply`, and not read only — "+ New
143
- * flow" names another, refusing a name the flowchart holds, and opens it
144
- * empty, one lane, as a draft the history item saves or discards.
145
- *
146
- * @remarks
147
- * Over a record of flows, or the host's flows by name. Over one flow (`data`
148
- * of `Flowchart.Types.Flow`) it is refused, when the surface is built and by
149
- * the tag's types.
96
+ * The Steps tab — `Flowchart.library.states()` (R14, D8): the states' cards,
97
+ * `Flowchart.templates` on `Flowchart.states`, grouped by their `group` and
98
+ * searched by their name, each a drag source. One dropped on a lane adds a
99
+ * state there from its values, keyed `state-<n>`, its order between the
100
+ * cards it lands between. It follows its cards' source of the slice, counting
101
+ * what it shows.
150
102
  *
103
+ * @param options - The tab's name — `Steps` unless given — and its icon
104
+ * @param rest - Nothing: rows and a config, as the earlier form took, are refused
151
105
  * @returns The tab
152
- *
153
- * @example
154
- * ```tsx
155
- * // .tsx file with the `@jsxImportSource @elaraai/e3-ui` pragma
156
- * import { East } from "@elaraai/east";
157
- * import { Box, Reactive, UIComponentType } from "@elaraai/east-ui";
158
- * import { Flowchart, Record } from "@elaraai/e3-ui";
159
- * import e3 from "@elaraai/e3";
160
- *
161
- * export const depotFlows = e3.record("flowchart_depot_flows", Flowchart.Types.Flows, {
162
- * initial: Flowchart.values({
163
- * "Inbound parcels": {
164
- * description: "From the trailer to the van",
165
- * lanes: [{ key: "intake", label: "Intake" }, { key: "sort", label: "Sort" }, { key: "load", label: "Load" }],
166
- * states: [
167
- * { key: "ARV", label: "Arrived", lane: "intake" },
168
- * { key: "SCN", label: "Scanned", lane: "intake" },
169
- * { key: "CH*", label: "Sort chutes", lane: "sort", members: 12n },
170
- * { key: "LDD", label: "Loaded", lane: "load" },
171
- * ],
172
- * links: [
173
- * { from: "ARV", to: "SCN" },
174
- * { from: "SCN", to: "CH*", trigger: "route" },
175
- * { from: "CH*", to: "LDD" },
176
- * { from: "SCN", to: "SCN", kind: "observed" },
177
- * ],
178
- * triggers: [{ key: "route", label: "route", owner: "sort-planner" }],
179
- * },
180
- * "Returns": {
181
- * description: "From the counter back to the sender",
182
- * lanes: [{ key: "counter", label: "Counter" }, { key: "check", label: "Check" }, { key: "out", label: "Out" }],
183
- * states: [
184
- * { key: "RCV", label: "Received", lane: "counter" },
185
- * { key: "INS", label: "Inspected", lane: "check" },
186
- * { key: "RSD", label: "Resent", lane: "out" },
187
- * ],
188
- * links: [{ from: "RCV", to: "INS" }, { from: "INS", to: "RSD" }, { from: "INS", to: "BIN", kind: "observed" }],
189
- * },
190
- * }),
191
- * mutations: (mutation) => ({
192
- * patch: mutation.patch(),
193
- * }),
194
- * });
195
- *
196
- * const flowchart = East.function([], UIComponentType, (_$) => (
197
- * <Reactive>{$ => {
198
- * const flows = $.let(Record.bind(depotFlows));
199
- * return (
200
- * <Box height="500px">
201
- * <Flowchart record={flows} flow="Inbound parcels" library={[Flowchart.library.flows()]} />
202
- * </Box>
203
- * );
204
- * }}</Reactive>
205
- * ));
206
- * ```
106
+ * @throws {Error} When given anything but `{ name?, icon? }`, naming the cards on the kind
207
107
  */
208
- export function libraryFlows() {
209
- return { kind: "flows" };
108
+ export function libraryStates(options, ...rest) {
109
+ return kindTab("states", options, rest);
210
110
  }
211
111
  /**
212
- * The state templates — `Flowchart.library.states(rows, { … })` (FB26,
213
- * decisions 6 and 7): one card per row of the tab's own templates record —
214
- * its label, the line under it, the tab's icon — grouped by its `group` and
215
- * searched by its key, label and line. Each card is a drag source, and a click
216
- * selects it, a click on the selected card letting it go. A card dropped on a
217
- * lane adds a state there, seeded with the fields its `drop` sets over a
218
- * state's defaults (#1249).
219
- *
220
- * @remarks
221
- * Templates are records (#1340, ruling 9): the rows are a templates record's,
222
- * read whole — `Data.bind(record).read()`, a `Dict<String, T>` — apart from
223
- * the flows and from the other tabs, each accessor taking a row and its key.
224
- * A card's key is its record's key, and the tab follows `source`, the
225
- * flowchart's slice's source over that record, by it (#1346). Left out, the
226
- * tab's name is `States`, in the flowchart's words. Refused when the surface
227
- * is built: a list naming no source — one written in the code — or one the
228
- * slice lacks, or `flows`; rows that are no `Dict<String, T>`; a `key`, which
229
- * the record's keys are; a `drop` over another type than
230
- * `Flowchart.Types.State`; and the tab listed twice.
112
+ * The Transitions tab — `Flowchart.library.transitions()` (R14, D8): the
113
+ * transitions' cards, `Flowchart.templates` on `Flowchart.transitions`. One
114
+ * dropped on a transition gives it its values, its ends kept.
231
115
  *
232
- * @typeParam T - The rows' element type
233
- * @param rows - The templates record's rows — a `Dict<String, T>` expression, its binding's `read()`
234
- * @param config - The tab's name and icon, what each card shows, its `drop` and its `source` ({@link FlowchartStatesConfig})
116
+ * @param options - The tab's name — `Transitions` unless given — and its icon
117
+ * @param rest - Nothing: rows and a config, as the earlier form took, are refused
235
118
  * @returns The tab
236
- *
237
- * @example
238
- * ```tsx
239
- * // .tsx file with the `@jsxImportSource @elaraai/e3-ui` pragma
240
- * import { DictType, East, IntegerType, OptionType, StringType, StructType, none, some, variant } from "@elaraai/east";
241
- * import { Box, Reactive, Slice, UIComponentType } from "@elaraai/east-ui";
242
- * import { Data, Flowchart, Record } from "@elaraai/e3-ui";
243
- * import e3 from "@elaraai/e3";
244
- *
245
- * export const depotFlows = e3.record("flowchart_depot_flows", Flowchart.Types.Flows, {
246
- * initial: Flowchart.values({
247
- * "Inbound parcels": {
248
- * description: "From the trailer to the van",
249
- * lanes: [{ key: "intake", label: "Intake" }, { key: "sort", label: "Sort" }, { key: "load", label: "Load" }],
250
- * states: [
251
- * { key: "ARV", label: "Arrived", lane: "intake" },
252
- * { key: "SCN", label: "Scanned", lane: "intake" },
253
- * { key: "CH*", label: "Sort chutes", lane: "sort", members: 12n },
254
- * { key: "LDD", label: "Loaded", lane: "load" },
255
- * ],
256
- * links: [
257
- * { from: "ARV", to: "SCN" },
258
- * { from: "SCN", to: "CH*", trigger: "route" },
259
- * { from: "CH*", to: "LDD" },
260
- * { from: "SCN", to: "SCN", kind: "observed" },
261
- * ],
262
- * triggers: [{ key: "route", label: "route", owner: "sort-planner" }],
263
- * },
264
- * "Returns": {
265
- * description: "From the counter back to the sender",
266
- * lanes: [{ key: "counter", label: "Counter" }, { key: "check", label: "Check" }, { key: "out", label: "Out" }],
267
- * states: [
268
- * { key: "RCV", label: "Received", lane: "counter" },
269
- * { key: "INS", label: "Inspected", lane: "check" },
270
- * { key: "RSD", label: "Resent", lane: "out" },
271
- * ],
272
- * links: [{ from: "RCV", to: "INS" }, { from: "INS", to: "RSD" }, { from: "INS", to: "BIN", kind: "observed" }],
273
- * },
274
- * }),
275
- * mutations: (mutation) => ({
276
- * patch: mutation.patch(),
277
- * }),
278
- * });
279
- * export const StepTemplate = StructType({ name: StringType, kind: StringType, slots: OptionType(IntegerType) });
280
- * export const stepTemplates = e3.record("flowchart_step_templates", DictType(StringType, StepTemplate), {
281
- * initial: new Map([
282
- * ["ARV", { name: "Arrived", kind: "Intake", slots: none }],
283
- * ["SCN", { name: "Scanned", kind: "Intake", slots: none }],
284
- * ["CH*", { name: "Sort chutes", kind: "Sort", slots: some(12n) }],
285
- * ["HLD", { name: "Held", kind: "Hold", slots: none }],
286
- * ["LDD", { name: "Loaded", kind: "Load", slots: none }],
287
- * ]),
288
- * indexes: (index) => ({
289
- * flowchart_steps_by_kind: index.on(["kind"]),
290
- * }),
291
- * mutations: (mutation) => ({
292
- * // The step types' patch door: what another writer adds a step type through, the Steps tab's cards following.
293
- * patch: mutation.patch(),
294
- * }),
295
- * });
296
- * export const MoveTemplate = StructType({ kind: Flowchart.Types.Kind, decision: OptionType(StringType), note: StringType });
297
- * export const moveTemplates = e3.record("flowchart_move_templates", DictType(StringType, MoveTemplate), {
298
- * initial: new Map([
299
- * ["Observed", { kind: variant("observed", null), decision: none, note: "Mined from the scans" }],
300
- * ["Planned", { kind: variant("planned", null), decision: none, note: "The designed path" }],
301
- * ["Routed", { kind: variant("planned", null), decision: some("route"), note: "Governed by the route decision" }],
302
- * ]),
303
- * indexes: (index) => ({
304
- * flowchart_moves_by_kind: index.on(["kind"]),
305
- * }),
306
- * });
307
- * export const DecisionOwner = StructType({ name: StringType, desk: StringType });
308
- * export const decisionOwners = e3.record("flowchart_decision_owners", DictType(StringType, DecisionOwner), {
309
- * initial: new Map([
310
- * ["sort-planner", { name: "Sort planner", desk: "Sort hall" }],
311
- * ["customs-desk", { name: "Customs desk", desk: "Hold bay" }],
312
- * ]),
313
- * indexes: (index) => ({
314
- * flowchart_owners_by_desk: index.on(["desk"]),
315
- * }),
316
- * });
317
- *
318
- * const flowchart = East.function([], UIComponentType, (_$) => (
319
- * <Reactive>{$ => {
320
- * const flows = $.let(Record.bind(depotFlows));
321
- * // What a tab reads whole binds with Data.bind, which keeps it loaded beside its pages.
322
- * const steps = $.let(Data.bind(stepTemplates));
323
- * const moves = $.let(Data.bind(moveTemplates));
324
- * const owners = $.let(Data.bind(decisionOwners));
325
- * // One rail over the library's records, a source each (#1346): each tab follows the source it names.
326
- * const slice = $.let(Slice.bindRecords("flowchart.depot", {
327
- * steps: { source: Data.bindPaged(stepTemplates, { indexes: ["flowchart_steps_by_kind"] }), label: "Steps", icon: { prefix: "fas", name: "box" },
328
- * fields: { kind: { label: "Step kind", hints: ["Intake", "Sort", "Hold", "Load"] } } },
329
- * moves: { source: Data.bindPaged(moveTemplates, { indexes: ["flowchart_moves_by_kind"] }), label: "Transitions", icon: { prefix: "fas", name: "arrow-right" },
330
- * fields: { kind: { label: "Transition kind" } } },
331
- * owners: { source: Data.bindPaged(decisionOwners, { indexes: ["flowchart_owners_by_desk"] }), label: "Owners", icon: { prefix: "fas", name: "user-tie" },
332
- * fields: { desk: { label: "Desk", hints: ["Sort hall", "Hold bay"] } } },
333
- * }));
334
- * return (
335
- * <Box height="560px">
336
- * <Flowchart
337
- * record={flows}
338
- * flow="Inbound parcels"
339
- * name="depot"
340
- * slice={{ slice }}
341
- * library={[
342
- * Flowchart.library.flows(),
343
- * // Step types, a templates record by code: a card dropped on a lane adds a state seeded with what its drop sets.
344
- * Flowchart.library.states(steps.read(), {
345
- * name: "Steps", icon: "box", source: "steps",
346
- * label: s => s.name, meta: (_s, code) => some(code), group: s => s.kind,
347
- * drop: (s, code) => Flowchart.patch(Flowchart.Types.State, { key: code, label: some(s.name), members: s.slots }),
348
- * }),
349
- * // Transition types, a templates record by name: a card dropped on a transition retypes it.
350
- * Flowchart.library.transitions(moves.read(), {
351
- * icon: "arrow-right", source: "moves",
352
- * label: (_m, name) => name, meta: m => some(m.note),
353
- * drop: m => Flowchart.patch(Flowchart.Types.Link, { kind: some(m.kind), trigger: m.decision }),
354
- * }),
355
- * // The author's own cards, a record of roles: a role dropped on a decision owns it.
356
- * Flowchart.library.tab(owners.read(), {
357
- * name: "Owners", icon: "user-tie", source: "owners",
358
- * key: (_o, role) => role, label: o => o.name, meta: o => some(o.desk),
359
- * drop: (_o, role) => Flowchart.patch(Flowchart.Types.Trigger, { owner: some(role) }),
360
- * }),
361
- * ]}
362
- * />
363
- * </Box>
364
- * );
365
- * }}</Reactive>
366
- * ));
367
- * ```
119
+ * @throws {Error} When given anything but `{ name?, icon? }`, naming the cards on the kind
368
120
  */
369
- export function libraryStates(rows, config) {
370
- return { kind: "states", rows, config: config };
121
+ export function libraryTransitions(options, ...rest) {
122
+ return kindTab("transitions", options, rest);
371
123
  }
372
124
  /**
373
- * The transition templates — `Flowchart.library.transitions(rows, { … })`
374
- * (FB26, decision 8): one card per row of the tab's own rows, as
375
- * {@link libraryStates}' are, each a drag source that a click selects and a
376
- * second click lets go. A card dropped on a transition sets the fields its
377
- * `drop` sets on it — its kind, its decision and its other fields (#1249): a
378
- * connection makes a transition of the default type, and a card retypes it.
379
- *
380
- * @remarks
381
- * The rows are a templates record's, read as {@link libraryStates}' are, each
382
- * card keyed by its record's key, and the tab follows its `source` as theirs
383
- * does. Left out, the tab's name is `Transitions`, in the flowchart's words.
384
- * Refused when the surface is built: a list naming no source, or one the slice
385
- * lacks, or `flows`; rows that are no `Dict<String, T>`; a `key`; a `drop`
386
- * over another type than `Flowchart.Types.Link`; and the tab listed twice;
387
- * and, when the tab's cards are read, a card whose `drop` sets the
388
- * transition's `key`, `from` or `to` — the fields a patch sets are values its
389
- * rows give, which the build cannot see.
125
+ * The Lanes tab — `Flowchart.library.lanes()` (R14, D5): the lanes' cards,
126
+ * `Flowchart.templates` on `Flowchart.lanes`. One dropped between two lanes,
127
+ * or at the band row's tail, adds a lane there from its values, keyed
128
+ * `lane-<n>`, its order between theirs. + LANE stays on the canvas.
390
129
  *
391
- * @typeParam T - The rows' element type
392
- * @param rows - The templates record's rows — a `Dict<String, T>` expression, its binding's `read()`
393
- * @param config - The tab's name and icon, what each card shows, its `drop` and its `source` ({@link FlowchartTransitionsConfig})
130
+ * @param options - The tab's name — `Lanes` unless given — and its icon
131
+ * @param rest - Nothing: anything after the options is refused
394
132
  * @returns The tab
133
+ * @throws {Error} When given anything but `{ name?, icon? }`
395
134
  */
396
- export function libraryTransitions(rows, config) {
397
- return { kind: "transitions", rows, config: config };
135
+ export function libraryLanes(options, ...rest) {
136
+ return kindTab("lanes", options, rest);
398
137
  }
399
138
  /**
400
139
  * A tab of the author's own cards — `Flowchart.library.tab(rows, { … })`
401
- * (FB27): one card per row of the tab's own rows, as {@link libraryStates}'
402
- * are, a click selecting a card and a second click letting it go. Given a
403
- * `drop`, each card is a drag source, which lands where its patch's type says
404
- * — a state, a transition, a lane's header or a decision's diamond — and sets
405
- * its fields there (#1249); without one, the cards are read, never dragged.
140
+ * (R14): one card per row, its label and the line under it, grouped by its
141
+ * `group` and searched by its key, label and line. Given a `drop` —
142
+ * `Flowchart.patch(R, { … })` over one kind's row type, which names that kind
143
+ * — a card dropped on a row of that kind sets the fields the patch sets:
144
+ * an owner dropped on a decision's diamond, say. Without one, the cards are
145
+ * read, never dragged.
406
146
  *
407
147
  * @remarks
408
- * The rows are an `Array<T>` or a `Dict<String, T>` the app binds, each
409
- * accessor taking a row and its key, a Dict's key or an Array's index,
410
- * printed; a key that repeats keeps its first card. Naming a `source` of the
411
- * flowchart's slice (#1346), the tab follows it by its cards' keys, each a
412
- * row's key in that record; naming none, it lists its rows whole. A tab's
413
- * name is its identity in `library`. Refused when the surface is built: rows
414
- * that are neither an Array nor a `Dict<String, T>`; a `source` the slice
415
- * lacks; a `drop` over none of a flow's row types; and two tabs of one name.
148
+ * The rows are an `Array<T>`, each card keyed by its index, printed, or a
149
+ * `Dict<String, T>`, each by its key. Naming a `source` of the Flowchart's
150
+ * slice, the tab follows it by its cards' keys, each a row's key in that
151
+ * record — so its rows are that record's, a Dict; naming none, it lists its
152
+ * rows whole. A tab's name is its identity in `library`. `Flowchart.templates`'
153
+ * example, the depot, shows the tabs together, its Owners tab among them.
416
154
  *
417
155
  * @typeParam T - The rows' element type
418
156
  * @typeParam P - The patch `drop` returns
419
- * @param rows - The rows — an `Array<T>` or a `Dict<String, T>` value or expression, such as a binding's `read()`
157
+ * @param rows - The rows: an `Array<T>` or a `Dict<String, T>`, usually a record's `read()`
420
158
  * @param config - The tab's name and icon, what each card shows, its `drop` and its `source` ({@link FlowchartTabConfig})
421
159
  * @returns The tab
422
160
  */
@@ -425,320 +163,76 @@ export function libraryTab(rows, config) {
425
163
  }
426
164
  /** The library pane's tabs, each a factory (`Flowchart.library`). */
427
165
  export const FlowchartLibraryFactories = {
428
- flows: libraryFlows,
429
166
  states: libraryStates,
430
167
  transitions: libraryTransitions,
168
+ lanes: libraryLanes,
431
169
  tab: libraryTab,
432
170
  };
433
- /** The cards a key repeats on, folded: the first kept, in the rows' order — as a register's members fold. */
434
- function keepFirst(cardType) {
435
- return East.function([ArrayType(cardType)], ArrayType(cardType), ($, cards) => {
436
- const out = $.let([], ArrayType(cardType));
437
- const seen = $.let(new Set(), SetType(StringType));
438
- $.for(cards, ($2, card) => {
439
- const key = $2.let(card.key, StringType);
440
- $2.if(seen.has(key).not(), ($3) => {
441
- $3(seen.insert(key));
442
- $3(out.pushLast(card));
443
- });
444
- });
445
- return out;
446
- });
447
- }
448
- /** Each card type's fold, once. */
449
- const KEEP_FIRST = new Map([
450
- FlowchartCardType, FlowchartStateCardType, FlowchartTransitionCardType, FlowchartLaneCardType, FlowchartDecisionCardType,
451
- ].map((cardType) => [cardType, keepFirst(cardType)]));
452
- /** What an author's card lands on, by its drop's row type: the arm its cards ride, and their type. */
453
- const LANDINGS = [
454
- ["state", FlowchartStateType, FlowchartStateCardType],
455
- ["transition", FlowchartLinkType, FlowchartTransitionCardType],
456
- ["lane", FlowchartLaneType, FlowchartLaneCardType],
457
- ["decision", FlowchartTriggerType, FlowchartDecisionCardType],
458
- ];
459
171
  /** How a tab names itself in a refusal. */
460
172
  function tabName(tab) {
461
- return tab.kind === "tab" ? `the "${tab.config.name}" tab` : `Flowchart.library.${tab.kind}()`;
173
+ return tab.kind === "tab" ? `the "${tab.config.name}" tab` : KIND_TABS[tab.kind].call;
462
174
  }
463
- /**
464
- * A data tab's rows: a Dict by String keys — for a templates list, its
465
- * templates record's, each card that record's row by its key (#1346) — or,
466
- * for an author's tab, an Array too.
467
- *
468
- * @param tab - The tab
469
- * @returns The rows, as East reads them
470
- * @throws {Error} Naming the tab: rows that are neither an Array nor a `Dict<String, T>`, or a templates list's that are no `Dict<String, T>`
471
- */
472
- function rowsOf(tab) {
473
- const expr = East.value(tab.rows);
474
- const type = Expr.type(expr);
475
- if (type.type === "Dict" && type.key.type === "String")
476
- return { expr, dict: true, row: type.value };
477
- // A templates list's rows are its templates record's.
478
- const templates = tab.kind !== "tab";
479
- if (type.type === "Array" && !templates)
480
- return { expr, dict: false, row: type.value };
481
- if (type.type === "Array") {
482
- throw new Error(`Flowchart: ${tabName(tab)} lists templates, which are records — its rows are its templates record's, each card a row by its key: a Dict<String, T>, its binding's read() — and these are an Array`);
175
+ /** Whether a value is one of the library's tabs. */
176
+ function isTab(value) {
177
+ if (typeof value !== "object" || value === null)
178
+ return false;
179
+ const kind = value.kind;
180
+ if (kind === "tab") {
181
+ const config = value.config;
182
+ return typeof config === "object" && config !== null;
483
183
  }
484
- throw new Error(templates
485
- ? `Flowchart: ${tabName(tab)} reads its rows as a Dict<String, T> — its templates record's, its binding's read(), its own apart from the flows and the other tabs — and these are ${printType(type)}`
486
- : `Flowchart: ${tabName(tab)} reads its rows as an Array<T> or a Dict<String, T> — a value, or an expression such as a binding's read(), its own apart from the flows and the other tabs — and these are ${printType(type)}`);
184
+ return kind === "states" || kind === "transitions" || kind === "lanes";
487
185
  }
488
186
  /**
489
- * A templates list's cards are its record's rows, each keyed by its record's
490
- * key (#1346): a `key` given beside them — the accessor every list took
491
- * before its rows were a record's — is refused, naming the change.
492
- *
493
- * @param tab - The templates list
494
- * @throws {Error} Naming the list, when its config gives a `key`
495
- */
496
- function keyedByRecord(tab) {
497
- if ("key" in tab.config) {
498
- throw new Error(`Flowchart: ${tabName(tab)}'s cards are its templates record's rows, each keyed by the record's key, which its source follows — leave \`key\` out`);
499
- }
500
- }
501
- /**
502
- * A data tab's drop, reified once over its rows' type: the function a card's
503
- * fields are set by, and the type of the patch it returns.
504
- */
505
- function dropOf(rows, drop) {
506
- const fn = East.function([rows.row, StringType], undefined, (_$, row, key) => drop(row, key));
507
- return { fn, patch: Expr.type(fn).output };
508
- }
509
- /**
510
- * A data tab's cards: one per row, read through its accessors, each with what
511
- * its drop sets, when the tab's cards set anything, and a key that repeats
512
- * keeping its first card.
513
- *
514
- * @param rows - The tab's rows
515
- * @param config - What each card shows, and — an author's tab's — its key; with none, each card's key is its row's
516
- * @param cardType - The cards' type
517
- * @param sets - What a card sets, from its row and its key, checked as it is read; `undefined` for cards that set nothing
518
- * @returns The cards, in the rows' order
519
- */
520
- function cardsOf(rows, config, cardType, sets) {
521
- const keyOf = config.key;
522
- const describe = East.function([rows.row, StringType], cardType, ($, row, key) => {
523
- const card = $.let(keyOf === undefined ? key : keyOf(row, key), StringType);
524
- return {
525
- key: card,
526
- label: config.label(row, key),
527
- meta: config.meta !== undefined ? config.meta(row, key) : East.value(none, OptionType(StringType)),
528
- group: config.group !== undefined ? some(config.group(row, key)) : East.value(none, OptionType(StringType)),
529
- ...(sets === undefined ? {} : { sets: sets($, row, key, card) }),
530
- };
531
- });
532
- const list = rows.dict
533
- ? rows.expr.toArray(($, row, key) => {
534
- const read = $.const(describe);
535
- return read(row, key);
536
- })
537
- : rows.expr.map(($, row, index) => {
538
- const read = $.const(describe);
539
- return read(row, East.print(index));
540
- });
541
- const fold = KEEP_FIRST.get(cardType);
542
- return fold(list);
543
- }
544
- /**
545
- * The state templates on the wire: the tab's name and icon, its cards, each
546
- * with the state its drop seeds, and the source they follow.
187
+ * An author's tab's rows, as the shared tab reads them: a Dict by String keys
188
+ * as it is; an Array as a Dict keyed by each row's index, printed.
547
189
  *
548
190
  * @param tab - The tab
549
- * @param sources - The slice's sources
550
- * @returns The tab's wire value
551
- * @throws {Error} Naming the tab: a list naming no source of the slice, a `key`, rows that are no `Dict<String, T>`, or a `drop` over another type than a state's patch
191
+ * @returns Its declaration over Dict rows
192
+ * @throws {Error} Naming the tab: rows that are neither an Array nor a `Dict<String, T>`; an Array following a source,
193
+ * whose cards' keys are its indexes, never that record's keys; and a `key`, which the rows' keys are
552
194
  */
553
- function statesTab(tab, sources) {
554
- const source = templatesSource("Flowchart", TEMPLATES_CALL.states, tab.config.source, sources);
555
- keyedByRecord(tab);
556
- const rows = rowsOf(tab);
557
- const drop = dropOf(rows, tab.config.drop);
558
- if (!isTypeEqual(drop.patch, FlowchartPatchTypeFor(FlowchartStateType))) {
559
- throw new Error(`Flowchart: ${tabName(tab)}'s \`drop\` returns the fields of the state a card adds — Flowchart.patch(Flowchart.Types.State, { … }) — and this one returns ${printType(drop.patch)}`);
560
- }
561
- const cards = cardsOf(rows, tab.config, FlowchartStateCardType, ($, row, key) => {
562
- const seed = $.const(drop.fn);
563
- return seed(row, key);
564
- });
565
- // The cards' expression is typed loosely here; East checks it against the tab's type.
566
- return East.value(variant("states", {
567
- name: tab.config.name === undefined ? none : some(tab.config.name),
568
- icon: tab.config.icon === undefined ? none : some(tab.config.icon),
569
- cards,
570
- source,
571
- }), FlowchartLibraryTabType);
572
- }
573
- /**
574
- * The transition templates on the wire: the tab's name and icon, its cards,
575
- * each with what it sets on the transition it lands on — refused, as the card
576
- * is read, when that is the transition's `key`, `from` or `to` — and the source
577
- * they follow.
578
- *
579
- * @param tab - The tab
580
- * @param sources - The slice's sources
581
- * @returns The tab's wire value
582
- * @throws {Error} Naming the tab: a list naming no source of the slice, a `key`, rows that are no `Dict<String, T>`, or a `drop` over another type than a transition's patch
583
- */
584
- function transitionsTab(tab, sources) {
585
- const source = templatesSource("Flowchart", TEMPLATES_CALL.transitions, tab.config.source, sources);
586
- keyedByRecord(tab);
587
- const rows = rowsOf(tab);
588
- const drop = dropOf(rows, tab.config.drop);
589
- if (!isTypeEqual(drop.patch, FlowchartPatchTypeFor(FlowchartLinkType))) {
590
- throw new Error(`Flowchart: ${tabName(tab)}'s \`drop\` returns the fields a card sets on the transition it lands on — Flowchart.patch(Flowchart.Types.Link, { … }) — and this one returns ${printType(drop.patch)}`);
591
- }
592
- const name = tabName(tab);
593
- const cards = cardsOf(rows, tab.config, FlowchartTransitionCardType, ($, row, key, card) => {
594
- const retype = $.const(drop.fn);
595
- const patched = $.let(retype(row, key));
596
- const sets = patched;
597
- // A transition card retypes the transition it lands on: never its key, nor its ends.
598
- const refusal = (field) => East.str `Flowchart: ${name}'s card "${card}" sets a transition's \`${field}\` — a transition card retypes the transition it lands on, its kind, its decision and its other fields, never its key or its ends: leave \`key\`, \`from\` and \`to\` out of its Flowchart.patch`;
599
- $.if(sets.key.hasTag("some"), ($2) => { $2.error(refusal("key")); });
600
- $.if(sets.from.hasTag("some"), ($2) => { $2.error(refusal("from")); });
601
- $.if(sets.to.hasTag("some"), ($2) => { $2.error(refusal("to")); });
602
- return patched;
603
- });
604
- return East.value(variant("transitions", {
605
- name: tab.config.name === undefined ? none : some(tab.config.name),
606
- icon: tab.config.icon === undefined ? none : some(tab.config.icon),
607
- cards,
608
- source,
609
- }), FlowchartLibraryTabType);
610
- }
611
- /**
612
- * An author's tab on the wire: its name and icon, its cards by what they land
613
- * on — the row type of the patch its `drop` returns — or read, never dragged,
614
- * without one, and the source it follows, if it names one.
615
- *
616
- * @param tab - The tab
617
- * @param sources - The slice's sources
618
- * @returns The tab's wire value
619
- * @throws {Error} Naming the tab: a source the slice lacks, rows that are neither an Array nor a `Dict<String, T>`, or a `drop` over none of a flow's row types
620
- */
621
- function authorTab(tab, sources) {
622
- const source = tabSource("Flowchart", `"${tab.config.name}"`, tab.config.source, sources);
623
- const rows = rowsOf(tab);
624
- const config = tab.config;
625
- // Without a drop, its cards are read, never dragged: they land nowhere.
626
- let arm = "none";
627
- let cardType = FlowchartCardType;
628
- let sets = undefined;
629
- if (config.drop !== undefined) {
630
- const drop = dropOf(rows, config.drop);
631
- const landing = LANDINGS.find(([, rowType]) => isTypeEqual(drop.patch, FlowchartPatchTypeFor(rowType)));
632
- if (landing === undefined) {
633
- throw new Error(`Flowchart: ${tabName(tab)}'s \`drop\` returns a patch over one of a flow's rows, its type naming what a card lands on — Flowchart.patch(Flowchart.Types.State, Link, Lane or Trigger, { … }) — and this one returns ${printType(drop.patch)}`);
634
- }
635
- [arm, , cardType] = landing;
636
- sets = ($, row, key) => {
637
- const setsOf = $.const(drop.fn);
638
- return setsOf(row, key);
639
- };
640
- }
641
- const lands = East.value(variant(arm, cardsOf(rows, config, cardType, sets)), FlowchartLandsType);
642
- return East.value(variant("tab", {
643
- name: config.name,
644
- icon: config.icon === undefined ? none : some(config.icon),
645
- lands,
646
- source,
647
- }), FlowchartLibraryTabType);
648
- }
649
- /** The kinds of tab `library` lists. */
650
- const KINDS = new Set(["flows", "states", "transitions", "tab"]);
651
- /** How a templates refusal writes the declaration to make, by the list's kind. */
652
- const TEMPLATES_CALL = {
653
- states: "Flowchart.library.states(rows, { …, source: \"stateTemplates\" })",
654
- transitions: "Flowchart.library.transitions(rows, { …, source: \"transitionTemplates\" })",
655
- };
656
- /** A tab `library` lists, as a `Flowchart.library.*` call makes one; `undefined` for anything else. */
657
- function declaredTab(given) {
658
- const tab = given;
659
- if (tab === null || tab === undefined || typeof tab !== "object" || !KINDS.has(tab.kind)
660
- || (tab.kind !== "flows" && (typeof tab.config !== "object" || tab.config === null))) {
661
- return undefined;
195
+ function keyedRows(tab) {
196
+ if ("key" in tab.config) {
197
+ throw new Error(`Flowchart: ${tabName(tab)}'s cards are keyed by its rows' keys — a Dict's key, or an Array's index — leave \`key\` out`);
662
198
  }
663
- return tab;
664
- }
665
- /** Each tab `library` lists, as declared, those of no `Flowchart.library.*` call left out. */
666
- function declaredTabs(library) {
667
- return (Array.isArray(library) ? library : []).flatMap((given) => {
668
- const tab = declaredTab(given);
669
- return tab === undefined ? [] : [tab];
670
- });
671
- }
672
- /**
673
- * Checks the library's templates lists against the flowchart's slice, before
674
- * the slice itself is checked, so a list written in the code is refused with
675
- * the change to make before a source no list names is (#1340, ruling 9): each
676
- * templates list is a record of its own, naming its source of the flowchart's
677
- * one `Slice.bindRecords`.
678
- *
679
- * @param library - The flowchart's `library`, as given
680
- * @param names - The sources the slice names, read before it is checked (`sliceSourceNames`)
681
- * @throws {Error} Naming the list and the change to make: a list naming no source — one written in the code — or one the slice lacks, a list naming `flows`, and the state and the transition templates naming one source
682
- * @internal
683
- */
684
- export function checkTemplatesSources(library, names) {
685
- const lists = declaredTabs(library).flatMap((tab) => (tab.kind === "states" || tab.kind === "transitions" ? [tab] : []));
686
- for (const list of lists)
687
- templatesSource("Flowchart", TEMPLATES_CALL[list.kind], list.config.source, names);
688
- const flows = lists.find((list) => list.config.source === "flows");
689
- if (flows !== undefined) {
690
- throw new Error(`Flowchart: ${tabName(flows)} names the source 'flows', which narrows the flows — each templates list is a record of its own, and its own source of the slice`);
199
+ const rows = East.value(tab.rows);
200
+ const type = Expr.type(rows);
201
+ if (type.type === "Dict" && isTypeEqual(type.key, StringType))
202
+ return { ...tab, rows };
203
+ if (type.type !== "Array") {
204
+ throw new Error(`Flowchart: ${tabName(tab)} reads its rows as an Array<T> or a Dict<String, T> — a value, or an expression such as a record's read() — ` +
205
+ `and these are ${printType(type)}`);
691
206
  }
692
- // The two lists naming one source; a list listed twice is the library's refusal (`buildLibrary`).
693
- const states = lists.find((list) => list.kind === "states");
694
- const transitions = lists.find((list) => list.kind === "transitions");
695
- if (states !== undefined && transitions !== undefined && states.config.source === transitions.config.source) {
696
- throw new Error(`Flowchart: the state templates and the transition templates both name the source '${states.config.source}' — each templates list is a record of its own, and its own source of the slice`);
207
+ if (tab.config.source !== undefined) {
208
+ throw new Error(`Flowchart: ${tabName(tab)} follows the source '${tab.config.source}' by its cards' keys, each a row's key in that record — ` +
209
+ "read its rows as that record's, a Dict<String, T>, its binding's read(), never an Array keyed by index");
697
210
  }
211
+ const array = rows;
212
+ return { ...tab, rows: array.toDict(($, _row, index) => East.print(index), ($, row, _index) => row) };
698
213
  }
699
214
  /**
700
- * The sources the library names (#1346), each once, in its order: each
701
- * templates list's and each author's tab's — what the flowchart's slice may
702
- * hold beside `flows`.
215
+ * Builds the library pane on the wire (R14): its tabs in the order `library`
216
+ * lists them; none when it is left out.
703
217
  *
704
- * @param library - The flowchart's `library`, as given
705
- * @returns The sources' names
706
- * @internal
707
- */
708
- export function librarySources(library) {
709
- const named = declaredTabs(library).flatMap((tab) => (tab.kind === "flows" || tab.config.source === undefined ? [] : [tab.config.source]));
710
- return named.filter((source, i) => named.indexOf(source) === i);
711
- }
712
- /**
713
- * The library pane on the wire (`Flowchart Builder Spec.md` §4.2, §4.4, FB16,
714
- * FB25–FB29): its tabs in the order `library` lists them; none when it is
715
- * left out, or empty.
716
- *
717
- * @param library - The tabs, each a `Flowchart.library.*` call
718
- * @param many - Whether the flowchart holds flows by name, rather than one flow
719
- * @param sources - The flowchart's slice's sources, which each templates list's and each author's tab's `source` must be one of
218
+ * @param tabs - The tabs, each a `Flowchart.library.*` call
219
+ * @param ctx - What the library is built against
720
220
  * @returns The tabs on the wire
721
- * @throws {Error} Naming the tab and the remedy: a `library` that is no list
722
- * of `Flowchart.library.*` calls; a tab listed twice — the Flows tab, the
723
- * state templates or the transition templates, or two of the author's tabs
724
- * of one name; the Flows tab over one flow; and each of a data tab's
725
- * refusals — a source the slice lacks, rows that are neither an Array nor a
726
- * `Dict<String, T>` (a templates record's, for a templates list), a
727
- * templates list's `key`, and a `drop` of another type than its tab's
221
+ * @throws {Error} Naming the tab: a `library` that is no list of `Flowchart.library.*` calls; a tab listed twice (an
222
+ * author's tab by its name); a kind's tab when the Flowchart has no such kind, or the kind has no cards; and each of
223
+ * an author's tab's refusals — rows that are neither an Array nor a `Dict<String, T>`, an Array following a source,
224
+ * a `key`, a source the slice lacks, and a `drop` over no kind's row type, or over one several kinds share
728
225
  * @internal
729
226
  */
730
- export function buildLibrary(library, many, sources = []) {
731
- if (library === undefined)
227
+ export function buildFlowchartLibrary(tabs, ctx) {
228
+ if (tabs === undefined)
732
229
  return East.value([], ArrayType(FlowchartLibraryTabType));
733
- const LIST = "Flowchart: `library` lists the library pane's tabs, each a Flowchart.library.* call — library={[Flowchart.library.flows()]}";
734
- if (!Array.isArray(library))
735
- throw new Error(LIST);
230
+ if (!Array.isArray(tabs) || !tabs.every(isTab)) {
231
+ throw new Error("Flowchart: `library` lists the library pane's tabs, in order, each a Flowchart.library.* call — " +
232
+ "states(), transitions(), lanes() or tab(rows, { … })");
233
+ }
736
234
  const seen = new Set();
737
- const wires = library.map((given) => {
738
- const tab = declaredTab(given);
739
- if (tab === undefined)
740
- throw new Error(LIST);
741
- // A tab once: the Flows tab and the templates by kind, an author's tab by its name.
235
+ for (const tab of tabs) {
742
236
  const id = tab.kind === "tab" ? `tab:${tab.config.name}` : tab.kind;
743
237
  if (seen.has(id)) {
744
238
  throw new Error(tab.kind === "tab"
@@ -746,17 +240,41 @@ export function buildLibrary(library, many, sources = []) {
746
240
  : `Flowchart: the library lists ${tabName(tab)} twice — each tab once`);
747
241
  }
748
242
  seen.add(id);
749
- switch (tab.kind) {
750
- case "flows":
751
- if (!many) {
752
- throw new Error(`Flowchart: ${tabName(tab)} lists flows by name, and this \`data\` is one flow, Flowchart.Types.Flow — leave the Flows tab out of \`library\`, or pass the flows by name`);
753
- }
754
- return East.value(variant("flows", null), FlowchartLibraryTabType);
755
- case "states": return statesTab(tab, sources);
756
- case "transitions": return transitionsTab(tab, sources);
757
- case "tab": return authorTab(tab, sources);
243
+ if (tab.kind !== "tab") {
244
+ const { noun, declare } = KIND_TABS[tab.kind];
245
+ const kind = ctx.kinds.find((one) => one.sort === tab.kind);
246
+ if (kind === undefined) {
247
+ throw new Error(`Flowchart: the library lists ${tabName(tab)}, and this Flowchart has no ${noun} — give ${tab.kind}={${declare}}`);
248
+ }
249
+ if (!kind.templates) {
250
+ throw new Error(`Flowchart: the library lists ${tabName(tab)}, and the ${noun} have no cards — give them their cards: ${declare}`);
251
+ }
252
+ }
253
+ }
254
+ const landsOn = ctx.kinds.map((kind) => [kind.sort, { rowType: kind.rowType }]);
255
+ const wires = tabs.map((tab) => {
256
+ if (tab.kind === "tab") {
257
+ const keyed = keyedRows(tab);
258
+ return East.value(variant("tab", buildScheduleTab(keyed, landsOn, "Flowchart", ctx.sources, { kind: "kind", patch: "Flowchart.patch" })), FlowchartLibraryTabType);
758
259
  }
260
+ return East.value(variant(tab.kind, {
261
+ name: tab.name === undefined ? none : some(tab.name),
262
+ icon: tab.icon === undefined ? none : some(tab.icon),
263
+ }), FlowchartLibraryTabType);
759
264
  });
760
265
  return East.value(wires, ArrayType(FlowchartLibraryTabType));
761
266
  }
267
+ /**
268
+ * The sources of the slice the author's tabs name: each one the slice may
269
+ * hold, and its tab refused when the slice lacks it.
270
+ *
271
+ * @param tabs - The Flowchart's `library`
272
+ * @returns The sources its tabs name, in order
273
+ * @internal
274
+ */
275
+ export function flowchartTabSources(tabs) {
276
+ if (!Array.isArray(tabs))
277
+ return [];
278
+ return tabs.filter(isTab).flatMap((tab) => tab.kind === "tab" && tab.config.source !== undefined ? [tab.config.source] : []);
279
+ }
762
280
  //# sourceMappingURL=library.js.map