@jxsuite/studio 4.1.0 → 5.1.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 (612) hide show
  1. package/README.md +1 -1
  2. package/data/elements-meta.json +5 -15
  3. package/data/html-meta.json +51 -6
  4. package/dist/chunks/{2020-n6tfwnda.js → 2020-g79n01v9.js} +14 -14
  5. package/dist/chunks/action-group-sp6tna8v.js +118 -0
  6. package/dist/chunks/adapter-nj7tnjfn.js +13 -0
  7. package/dist/chunks/cf-account-picker-qwkm9zrf.js +495 -0
  8. package/dist/chunks/cf-settings-71bv5zn9.js +20 -0
  9. package/dist/chunks/color-area-v17df7b8.js +154 -0
  10. package/dist/chunks/color-field-anwybnkn.js +208 -0
  11. package/dist/chunks/color-slider-44ez96fc.js +79 -0
  12. package/dist/chunks/color-xgg3kfw7.js +35 -0
  13. package/dist/chunks/combobox-5e7jev23.js +236 -0
  14. package/dist/chunks/components-vj72gqtq.js +20 -0
  15. package/dist/chunks/content-source-5mex4x1h.js +46 -0
  16. package/dist/chunks/convert-to-repeater-n64h8znc.js +639 -0
  17. package/dist/chunks/dialog-s890b918.js +85 -0
  18. package/dist/chunks/editor-3qhbg51x.js +35 -0
  19. package/dist/chunks/entry-commands-234hjnqw.js +42 -0
  20. package/dist/chunks/extension-sections-3hpcambp.js +651 -0
  21. package/dist/chunks/file-ops-8yhd83xr.js +47 -0
  22. package/dist/chunks/files-hnxqxtsg.js +72 -0
  23. package/dist/chunks/format-host-779sfp2n.js +40 -0
  24. package/dist/chunks/fs-events-b88z7g4h.js +18 -0
  25. package/dist/chunks/git-panel-xwj8fpab.js +49 -0
  26. package/dist/chunks/icons-yy10wk9r.js +402 -0
  27. package/dist/chunks/iframe-entry-15g3n6xv.js +114 -0
  28. package/dist/chunks/iframe-entry-b27vq81n.js +203 -0
  29. package/dist/chunks/iframe-entry-nbyxee1y.js +154 -0
  30. package/dist/chunks/iframe-host-syr0f9sb.js +115 -0
  31. package/dist/chunks/{index-wcnt3r9g.js → index-mdmyx6s2.js} +11 -11
  32. package/dist/chunks/index-n4j7qxyr.js +109 -0
  33. package/dist/chunks/{javascript-q8kpmfah.js → javascript-xvrfrpkb.js} +8 -9
  34. package/dist/chunks/{jsonMode-dkr040ga.js → jsonMode-tyx2kj6p.js} +526 -527
  35. package/dist/chunks/jx-validate-j0wxk72w.js +15 -0
  36. package/dist/chunks/layers-ff81wthn.js +30 -0
  37. package/dist/chunks/layers-panel-pnnghw12.js +40 -0
  38. package/dist/chunks/listbox-6v2ac08j.js +44 -0
  39. package/dist/chunks/lit-html-m244w9nh.js +17 -0
  40. package/dist/chunks/media-picker-cqhhxhhe.js +33 -0
  41. package/dist/chunks/menu-9p2w46gj.js +15 -0
  42. package/dist/chunks/menu-q99sy9rf.js +285 -0
  43. package/dist/chunks/{monaco-binding-rj6xpx9y.js → monaco-binding-sw6en4dw.js} +12 -15
  44. package/dist/chunks/monaco-buffer-bhy3hb6m.js +24 -0
  45. package/dist/chunks/{monaco-setup-vx9bhp1d.js → monaco-setup-8r62fj6y.js} +27 -37
  46. package/dist/chunks/notify-628t0anh.js +21 -0
  47. package/dist/chunks/number-field-5cndyft8.js +72 -0
  48. package/dist/chunks/parse-0zx14y15.js +10 -0
  49. package/dist/chunks/platform-ts9cg1a4.js +15 -0
  50. package/dist/chunks/popover-47z3ytva.js +25 -0
  51. package/dist/chunks/publish-panel-5zt840sy.js +27 -0
  52. package/dist/chunks/quick-search-3748564r.js +45 -0
  53. package/dist/chunks/references-qvvxej7h.js +26 -0
  54. package/dist/chunks/right-panel-eccz92qt.js +45 -0
  55. package/dist/chunks/section-registry-5pq32t0q.js +25 -0
  56. package/dist/chunks/select-2r16ez41.js +49 -0
  57. package/dist/chunks/split-g7nm1rgb.js +191 -0
  58. package/dist/chunks/studio-0hqbpbd0.js +62 -0
  59. package/dist/chunks/{studio-kryvsw6j.js → studio-1k325pwf.js} +48 -48
  60. package/dist/chunks/{studio-b55y6ewx.js → studio-1knfqgy7.js} +58 -58
  61. package/dist/chunks/{studio-2b946z26.js → studio-1z1kcjv4.js} +3628 -6095
  62. package/dist/chunks/studio-3773086z.js +111 -0
  63. package/dist/chunks/{studio-4r1pv6zf.js → studio-38emantv.js} +22 -5
  64. package/dist/chunks/{studio-x813zp48.js → studio-3rz5md06.js} +30 -30
  65. package/dist/chunks/{studio-ynxwkrzd.js → studio-4wbb9ct0.js} +1953 -1785
  66. package/dist/chunks/studio-5te5tqng.js +81 -0
  67. package/dist/chunks/studio-5wt9nvhd.js +4763 -0
  68. package/dist/chunks/{studio-p4ngc046.js → studio-6ewqv390.js} +9 -9
  69. package/dist/chunks/{studio-9ab8gqsm.js → studio-6nzaktvy.js} +7 -7
  70. package/dist/chunks/studio-6xa21ej9.js +28 -0
  71. package/dist/chunks/{studio-5ehhackm.js → studio-727xh0e3.js} +19 -19
  72. package/dist/chunks/{studio-gcye7qka.js → studio-7e11jpa9.js} +21 -21
  73. package/dist/chunks/{studio-q7v10cg2.js → studio-7r42c6ca.js} +17 -7
  74. package/dist/chunks/studio-7xnmgv66.js +13615 -0
  75. package/dist/chunks/studio-8scdew0e.js +258 -0
  76. package/dist/chunks/{studio-fbf92ckf.js → studio-93zafjcm.js} +275 -163
  77. package/dist/chunks/{studio-dg7zyt5x.js → studio-98b3z07n.js} +1 -1
  78. package/dist/chunks/studio-a79k90n9.js +1162 -0
  79. package/dist/chunks/studio-aj37eer3.js +422 -0
  80. package/dist/chunks/studio-b0k5tqgp.js +2432 -0
  81. package/dist/chunks/studio-b4s9eykd.js +2811 -0
  82. package/dist/chunks/{studio-f3wqjtk5.js → studio-d0300636.js} +5076 -18
  83. package/dist/chunks/{studio-b9b6t1dg.js → studio-e1f24eff.js} +5664 -5666
  84. package/dist/chunks/studio-e1pgga3k.js +839 -0
  85. package/dist/chunks/{studio-g1wdche0.js → studio-esrxgwh6.js} +80 -80
  86. package/dist/chunks/{studio-q43a5y9h.js → studio-g3jevyjt.js} +16 -16
  87. package/dist/chunks/studio-gb13095a.js +2806 -0
  88. package/dist/chunks/{studio-3n4ndrzh.js → studio-h4nvnjvz.js} +303 -303
  89. package/dist/chunks/{studio-dm19q43r.js → studio-hhvs4sdg.js} +10 -10
  90. package/dist/chunks/{studio-x4qkdat5.js → studio-js8nv53n.js} +1749 -2481
  91. package/dist/chunks/{studio-qjy2z9bv.js → studio-jxp12rnj.js} +32 -137
  92. package/dist/chunks/{studio-trxrabqf.js → studio-k75n7vhp.js} +527 -283
  93. package/dist/chunks/{studio-q9jd1a60.js → studio-kcgff4r0.js} +15 -18
  94. package/dist/chunks/studio-kkqkcp3d.js +17668 -0
  95. package/dist/chunks/studio-mhhyamxf.js +763 -0
  96. package/dist/chunks/{studio-cft9r4r7.js → studio-nq5yf5mp.js} +22 -22
  97. package/dist/chunks/{studio-685s0ytq.js → studio-nqgawfks.js} +572 -572
  98. package/dist/chunks/studio-nzzpvzx9.js +185 -0
  99. package/dist/chunks/{studio-xrapxwwc.js → studio-p1dw8wfw.js} +55 -29
  100. package/dist/chunks/{studio-3bqpr0zh.js → studio-pxbgypmg.js} +299 -110
  101. package/dist/chunks/studio-q0a3yk4n.js +33 -0
  102. package/dist/chunks/{studio-wcy8trfx.js → studio-q3x06vmj.js} +23 -22
  103. package/dist/chunks/{studio-6yw4y3my.js → studio-qhhm6hbt.js} +8 -8
  104. package/dist/chunks/studio-qk4bfsq2.js +362 -0
  105. package/dist/chunks/{studio-msd847zn.js → studio-qk90fgqm.js} +361 -90
  106. package/dist/chunks/{studio-jkftxyvz.js → studio-r6nvacqs.js} +5861 -2154
  107. package/dist/chunks/{studio-53n8bp04.js → studio-r6xmmtfh.js} +1 -1
  108. package/dist/chunks/{studio-tvgyw9xw.js → studio-rnyf3f8e.js} +83 -250
  109. package/dist/chunks/studio-rs76k67r.js +12 -0
  110. package/dist/chunks/studio-sbjyc8bt.js +954 -0
  111. package/dist/chunks/{studio-1wagb550.js → studio-syg2tadj.js} +11 -11
  112. package/dist/chunks/{studio-t5wqwzdh.js → studio-tjjk7jvk.js} +1 -1
  113. package/dist/chunks/studio-tqgryxwg.js +1171 -0
  114. package/dist/chunks/studio-try13h8c.js +8448 -0
  115. package/dist/chunks/studio-vfq8qpjt.js +1219 -0
  116. package/dist/chunks/studio-vhv5tgxm.js +51 -0
  117. package/dist/chunks/{studio-ahn3pdgx.js → studio-vw7mzp6z.js} +52 -38
  118. package/dist/chunks/studio-wqpngpsk.js +174 -0
  119. package/dist/chunks/studio-wqz6dggm.js +1356 -0
  120. package/dist/chunks/{studio-92ab2jqe.js → studio-y9zedyjn.js} +14 -14
  121. package/dist/chunks/studio-yxa81f45.js +12 -0
  122. package/dist/chunks/studio-zdn2g6dt.js +148 -0
  123. package/dist/chunks/swatch-group-t0n6h2rn.js +139 -0
  124. package/dist/chunks/tabs-wbp1cdws.js +156 -0
  125. package/dist/chunks/textfield-abk6qyee.js +73 -0
  126. package/dist/chunks/toast-780pvfbv.js +27 -0
  127. package/dist/chunks/toast-host-3sqv46sn.js +116 -0
  128. package/dist/chunks/toolbar-xbh5bhtr.js +194 -0
  129. package/dist/chunks/tooltip-eptb614w.js +369 -0
  130. package/dist/chunks/tree-a73p0pqm.js +367 -0
  131. package/dist/chunks/{tsMode-76kr53q0.js → tsMode-jy4m86rv.js} +83 -85
  132. package/dist/chunks/workspace-t55jdjbx.js +69 -0
  133. package/dist/chunks/{ws-client-6shc5rze.js → ws-client-ny4zc51r.js} +20 -22
  134. package/dist/iframe-entry.js +1873 -673
  135. package/dist/studio.js +52757 -36535
  136. package/dist/workers/editor.worker.js +1040 -1085
  137. package/dist/workers/json.worker.js +1946 -1991
  138. package/dist/workers/ts.worker.js +4960 -5005
  139. package/index.html +1 -0
  140. package/package.json +18 -52
  141. package/src/about/about-modal.ts +72 -123
  142. package/src/browse/library-commands.ts +20 -49
  143. package/src/browse/library-layouts.ts +87 -218
  144. package/src/browse/library-pane.ts +406 -438
  145. package/src/canvas/canvas-helpers.ts +0 -49
  146. package/src/canvas/canvas-live-render.ts +25 -2
  147. package/src/canvas/canvas-render.ts +666 -231
  148. package/src/canvas/canvas-surface.ts +0 -1
  149. package/src/canvas/canvas-utils.ts +333 -113
  150. package/src/canvas/dialog-path.ts +76 -0
  151. package/src/canvas/dialog-state.ts +67 -0
  152. package/src/canvas/diff-marks.ts +252 -0
  153. package/src/canvas/diff-toolbar.ts +349 -0
  154. package/src/canvas/diff-view.ts +123 -0
  155. package/src/canvas/edit-width-drag.ts +187 -0
  156. package/src/canvas/edit-width.ts +150 -0
  157. package/src/canvas/iframe-entry.ts +125 -8
  158. package/src/canvas/iframe-host.ts +271 -15
  159. package/src/canvas/iframe-interaction.ts +133 -13
  160. package/src/canvas/iframe-patch.ts +7 -1
  161. package/src/canvas/iframe-position.ts +5 -6
  162. package/src/canvas/iframe-protocol.ts +106 -5
  163. package/src/canvas/iframe-render.ts +373 -5
  164. package/src/canvas/iframe-slash.ts +2 -2
  165. package/src/canvas/iframe-subtree.ts +5 -8
  166. package/src/canvas/path-mapping.ts +25 -3
  167. package/src/canvas/popover-path.ts +106 -0
  168. package/src/canvas/popover-state.ts +155 -0
  169. package/src/canvas/surface-registry.ts +21 -10
  170. package/src/collab/presence-chips.ts +51 -73
  171. package/src/commands/app-commands.ts +10 -0
  172. package/src/commands/budget.ts +12 -0
  173. package/src/commands/command-args.ts +404 -6
  174. package/src/commands/defaults.ts +44 -14
  175. package/src/commands/live-context.ts +11 -5
  176. package/src/commands/reference.ts +12 -2
  177. package/src/commands/registry.ts +177 -10
  178. package/src/commands/run-reported.ts +120 -0
  179. package/src/content/entry-commands.ts +16 -23
  180. package/src/content/entry-editor.ts +144 -101
  181. package/src/editor/canvas-slash-bridge.ts +2 -2
  182. package/src/editor/context-menu.ts +49 -200
  183. package/src/editor/convert-to-component.ts +42 -82
  184. package/src/editor/convert-to-repeater.ts +132 -173
  185. package/src/editor/inline-edit.ts +11 -0
  186. package/src/editor/shortcuts.ts +76 -49
  187. package/src/editor/slash-menu.ts +150 -157
  188. package/src/files/components.ts +39 -0
  189. package/src/files/file-ops.ts +117 -11
  190. package/src/files/files.ts +944 -660
  191. package/src/files/json-layout.ts +474 -0
  192. package/src/files/serialize-document.ts +8 -1
  193. package/src/format/convert-file.ts +16 -10
  194. package/src/format/format-host.ts +50 -1
  195. package/src/github/github-auth.ts +71 -29
  196. package/src/github/github-publish.ts +57 -65
  197. package/src/grid/cell-editors.ts +46 -4
  198. package/src/grid/cell-popovers.ts +65 -62
  199. package/src/grid/grid-open.ts +86 -64
  200. package/src/grid/grid-panel.ts +390 -469
  201. package/src/grid/redirects-grid.ts +40 -44
  202. package/src/hosting/layout.ts +2 -0
  203. package/src/i18n/i18n-commands.ts +137 -62
  204. package/src/media/media-pane.ts +83 -133
  205. package/src/new-project/add-repo-modal.ts +125 -176
  206. package/src/new-project/import-tab.ts +181 -252
  207. package/src/new-project/location-fields.ts +93 -160
  208. package/src/new-project/new-project-modal.ts +376 -367
  209. package/src/packages/jxsuite-update.ts +76 -18
  210. package/src/packages/pull-package-sync.ts +5 -1
  211. package/src/panels/activity-panel.ts +137 -104
  212. package/src/panels/ai-chat/chat-markdown.ts +15 -13
  213. package/src/panels/ai-chat/chat-view.ts +307 -472
  214. package/src/panels/ai-chat/composer.ts +175 -163
  215. package/src/panels/ai-chat/sessions-view.ts +31 -62
  216. package/src/panels/ai-panel.ts +213 -185
  217. package/src/panels/block-action-bar.ts +444 -645
  218. package/src/panels/bottom-dock.ts +112 -47
  219. package/src/panels/chat-panel.ts +19 -14
  220. package/src/panels/data-explorer.ts +141 -102
  221. package/src/panels/data-grid.ts +183 -150
  222. package/src/panels/dnd.ts +75 -20
  223. package/src/panels/editors.ts +26 -19
  224. package/src/panels/elements-panel.ts +243 -186
  225. package/src/panels/empty-state.ts +26 -42
  226. package/src/panels/events-panel.ts +950 -729
  227. package/src/panels/formula-workspace.ts +434 -207
  228. package/src/panels/frontmatter-fields.ts +185 -153
  229. package/src/panels/frontmatter-panel.ts +411 -187
  230. package/src/panels/git-diff-open.ts +148 -0
  231. package/src/panels/git-panel.ts +679 -605
  232. package/src/panels/head-panel.ts +617 -435
  233. package/src/panels/i18n-panel.ts +148 -135
  234. package/src/panels/imports-panel.ts +388 -414
  235. package/src/panels/jump-bar.ts +175 -147
  236. package/src/panels/layers-panel.ts +785 -671
  237. package/src/panels/left-panel.ts +166 -94
  238. package/src/panels/navigator-panels.ts +1 -1
  239. package/src/panels/pane-context.ts +529 -677
  240. package/src/panels/pane-grid.ts +265 -241
  241. package/src/panels/panel-registry.ts +15 -4
  242. package/src/panels/problems-panel.ts +181 -99
  243. package/src/panels/properties-panel.ts +1525 -966
  244. package/src/panels/provenance.ts +31 -113
  245. package/src/panels/quick-search.ts +223 -184
  246. package/src/panels/right-panel.ts +135 -169
  247. package/src/panels/seo-modal.ts +346 -167
  248. package/src/panels/settings-menu.ts +114 -661
  249. package/src/panels/settings-pane.ts +102 -86
  250. package/src/panels/signals-panel.ts +1318 -1172
  251. package/src/panels/statement-editor.ts +556 -428
  252. package/src/panels/style-panel.ts +1367 -630
  253. package/src/panels/style-utils.ts +36 -32
  254. package/src/panels/stylebook-doc.ts +30 -73
  255. package/src/panels/stylebook-layers-panel.ts +202 -109
  256. package/src/panels/stylebook-panel.ts +124 -88
  257. package/src/panels/tab-strip.ts +386 -288
  258. package/src/platforms/cloud.ts +106 -16
  259. package/src/platforms/devserver.ts +13 -0
  260. package/src/publish/deploy-checklist.ts +124 -78
  261. package/src/publish/publish-commands.ts +4 -12
  262. package/src/publish/publish-panel.ts +134 -328
  263. package/src/services/a11y-report.ts +100 -43
  264. package/src/services/ai-command-tools.ts +538 -0
  265. package/src/services/ai-project-tools.ts +8 -2
  266. package/src/services/ai-session-store.ts +6 -0
  267. package/src/services/ai-system-prompt.ts +112 -24
  268. package/src/services/ai-tools.ts +36 -212
  269. package/src/services/ai-write-report.ts +174 -0
  270. package/src/services/document-assistant.ts +59 -8
  271. package/src/services/idle.ts +16 -14
  272. package/src/services/live-surfaces.ts +237 -0
  273. package/src/services/model-uri.ts +75 -0
  274. package/src/services/notify.ts +63 -6
  275. package/src/services/popover-report.ts +325 -0
  276. package/src/services/surface-registry.ts +56 -0
  277. package/src/services/tool-executor.ts +6 -0
  278. package/src/settings/contexts-section.ts +301 -299
  279. package/src/settings/contributed-section.ts +361 -222
  280. package/src/settings/css-vars-editor.ts +320 -325
  281. package/src/settings/defs-editor.ts +572 -535
  282. package/src/settings/dependencies-editor.ts +79 -107
  283. package/src/settings/extension-commands.ts +379 -0
  284. package/src/settings/extension-rows.ts +113 -0
  285. package/src/settings/extensions-section.ts +287 -0
  286. package/src/settings/general-settings.ts +130 -181
  287. package/src/settings/head-editor.ts +10 -305
  288. package/src/settings/locales-section.ts +146 -196
  289. package/src/settings/preferences-accounts.ts +1 -1
  290. package/src/settings/preferences-dialog.ts +350 -330
  291. package/src/settings/project-sections.ts +108 -181
  292. package/src/settings/schema-field-ui.ts +11 -399
  293. package/src/settings/section-registry.ts +8 -1
  294. package/src/settings/settings-document.ts +31 -29
  295. package/src/shell/tree.ts +42 -87
  296. package/src/shell.ts +48 -36
  297. package/src/studio.ts +104 -69
  298. package/src/style/token-ref.ts +0 -39
  299. package/src/surfaces/about.json +263 -0
  300. package/src/surfaces/about.ts +163 -0
  301. package/src/surfaces/add-repo.json +486 -0
  302. package/src/surfaces/add-repo.ts +236 -0
  303. package/src/surfaces/ai-chat.json +2185 -0
  304. package/src/surfaces/ai-chat.ts +549 -0
  305. package/src/surfaces/ai-credentials-form.json +332 -0
  306. package/src/surfaces/ai-credentials-form.ts +151 -0
  307. package/src/surfaces/ai-managed-connect.json +108 -0
  308. package/src/surfaces/ai-managed-connect.ts +123 -0
  309. package/src/surfaces/ai-model-picker.json +114 -0
  310. package/src/surfaces/ai-model-picker.ts +139 -0
  311. package/src/surfaces/block-action-bar.json +640 -0
  312. package/src/surfaces/block-action-bar.ts +368 -0
  313. package/src/surfaces/bottom-dock.json +154 -0
  314. package/src/surfaces/bottom-dock.ts +125 -0
  315. package/src/surfaces/canvas-stage.json +444 -0
  316. package/src/surfaces/canvas-stage.ts +253 -0
  317. package/src/surfaces/cf-account-picker.json +300 -0
  318. package/src/surfaces/cf-account-picker.ts +214 -0
  319. package/src/surfaces/commandbar.json +985 -0
  320. package/src/{panels/toolbar.ts → surfaces/commandbar.ts} +417 -391
  321. package/src/surfaces/convert-repeater.json +309 -0
  322. package/src/surfaces/convert-repeater.ts +276 -0
  323. package/src/surfaces/data-actions.json +157 -0
  324. package/src/surfaces/data-actions.ts +115 -0
  325. package/src/surfaces/dialog.json +289 -0
  326. package/src/surfaces/dialog.ts +343 -0
  327. package/src/surfaces/diff-toolbar.json +266 -0
  328. package/src/surfaces/diff-toolbar.ts +139 -0
  329. package/src/surfaces/doc-header.json +739 -0
  330. package/src/surfaces/doc-header.ts +223 -0
  331. package/src/surfaces/empty-state.json +152 -0
  332. package/src/surfaces/empty-state.ts +173 -0
  333. package/src/surfaces/entry-editor.json +281 -0
  334. package/src/surfaces/entry-editor.ts +191 -0
  335. package/src/surfaces/expression-editor.json +977 -0
  336. package/src/surfaces/expression-editor.ts +266 -0
  337. package/src/surfaces/files-panel.json +592 -0
  338. package/src/surfaces/files-panel.ts +301 -0
  339. package/src/surfaces/formula-palette.json +364 -0
  340. package/src/surfaces/formula-palette.ts +340 -0
  341. package/src/surfaces/git-panel.json +1822 -0
  342. package/src/surfaces/git-panel.ts +272 -0
  343. package/src/surfaces/github-auth.json +112 -0
  344. package/src/surfaces/github-auth.ts +139 -0
  345. package/src/surfaces/github-publish.json +206 -0
  346. package/src/surfaces/github-publish.ts +169 -0
  347. package/src/surfaces/grid-cell.json +218 -0
  348. package/src/surfaces/grid-cell.ts +120 -0
  349. package/src/surfaces/grid-open.json +147 -0
  350. package/src/surfaces/grid-open.ts +87 -0
  351. package/src/surfaces/grid-panel.json +706 -0
  352. package/src/surfaces/grid-panel.ts +206 -0
  353. package/src/surfaces/grid-replace.json +179 -0
  354. package/src/surfaces/grid-replace.ts +89 -0
  355. package/src/surfaces/grid-views.json +446 -0
  356. package/src/surfaces/grid-views.ts +172 -0
  357. package/src/surfaces/inspector-dock.json +187 -0
  358. package/src/surfaces/inspector-dock.ts +161 -0
  359. package/src/surfaces/jump-bar.json +243 -0
  360. package/src/surfaces/jump-bar.ts +129 -0
  361. package/src/surfaces/jxsuite-update.json +146 -0
  362. package/src/surfaces/jxsuite-update.ts +149 -0
  363. package/src/surfaces/library-pane.json +1509 -0
  364. package/src/surfaces/library-pane.ts +363 -0
  365. package/src/surfaces/logic-panel.json +1949 -0
  366. package/src/surfaces/logic-panel.ts +369 -0
  367. package/src/surfaces/logic-workspace.json +685 -0
  368. package/src/surfaces/logic-workspace.ts +238 -0
  369. package/src/surfaces/media-browser.json +303 -0
  370. package/src/surfaces/media-browser.ts +145 -0
  371. package/src/surfaces/media-field.json +163 -0
  372. package/src/surfaces/media-field.ts +116 -0
  373. package/src/surfaces/media-pane.json +513 -0
  374. package/src/surfaces/media-pane.ts +197 -0
  375. package/src/surfaces/menu.json +232 -0
  376. package/src/surfaces/menu.ts +375 -0
  377. package/src/surfaces/navigator-dock.json +113 -0
  378. package/src/surfaces/navigator-dock.ts +130 -0
  379. package/src/surfaces/new-project.json +1654 -0
  380. package/src/surfaces/new-project.ts +411 -0
  381. package/src/surfaces/palette.json +535 -0
  382. package/src/surfaces/pane-context.json +1497 -0
  383. package/src/surfaces/pane-context.ts +513 -0
  384. package/src/surfaces/pane-grid.json +188 -0
  385. package/src/surfaces/pane-grid.ts +250 -0
  386. package/src/surfaces/panel-activity.json +563 -0
  387. package/src/surfaces/panel-activity.ts +187 -0
  388. package/src/surfaces/panel-data.json +141 -0
  389. package/src/surfaces/panel-data.ts +156 -0
  390. package/src/surfaces/panel-deploy-checklist.json +283 -0
  391. package/src/surfaces/panel-deploy-checklist.ts +175 -0
  392. package/src/surfaces/panel-elements.json +367 -0
  393. package/src/surfaces/panel-elements.ts +175 -0
  394. package/src/surfaces/panel-i18n.json +569 -0
  395. package/src/surfaces/panel-i18n.ts +212 -0
  396. package/src/surfaces/panel-imports.json +780 -0
  397. package/src/surfaces/panel-imports.ts +209 -0
  398. package/src/surfaces/panel-outline.json +734 -0
  399. package/src/surfaces/panel-outline.ts +326 -0
  400. package/src/surfaces/panel-page.json +1017 -0
  401. package/src/surfaces/panel-page.ts +240 -0
  402. package/src/surfaces/panel-problems.json +497 -0
  403. package/src/surfaces/panel-problems.ts +157 -0
  404. package/src/surfaces/panel-signals.json +1973 -0
  405. package/src/surfaces/panel-signals.ts +436 -0
  406. package/src/surfaces/panel-stylebook-layers.json +317 -0
  407. package/src/surfaces/panel-stylebook-layers.ts +155 -0
  408. package/src/surfaces/preferences.json +850 -0
  409. package/src/surfaces/preferences.ts +332 -0
  410. package/src/surfaces/progress-modal.json +110 -0
  411. package/src/surfaces/progress-modal.ts +150 -0
  412. package/src/surfaces/properties-panel.json +1578 -0
  413. package/src/surfaces/properties-panel.ts +337 -0
  414. package/src/surfaces/publish.json +945 -0
  415. package/src/surfaces/publish.ts +392 -0
  416. package/src/surfaces/push-plan.json +110 -0
  417. package/src/surfaces/push-plan.ts +87 -0
  418. package/src/surfaces/rail.json +255 -0
  419. package/src/surfaces/rail.ts +206 -0
  420. package/src/surfaces/reference-field.json +191 -0
  421. package/src/surfaces/reference-field.ts +168 -0
  422. package/src/surfaces/schema-builder.json +1011 -0
  423. package/src/surfaces/schema-builder.ts +181 -0
  424. package/src/surfaces/schema-form.json +1013 -0
  425. package/src/surfaces/schema-form.ts +287 -0
  426. package/src/surfaces/secret-field.json +60 -0
  427. package/src/surfaces/secret-field.ts +146 -0
  428. package/src/surfaces/seo.json +932 -0
  429. package/src/surfaces/seo.ts +334 -0
  430. package/src/surfaces/settings-contexts.json +538 -0
  431. package/src/surfaces/settings-contexts.ts +196 -0
  432. package/src/surfaces/settings-contributed.json +489 -0
  433. package/src/surfaces/settings-contributed.ts +199 -0
  434. package/src/surfaces/settings-css-vars.json +820 -0
  435. package/src/surfaces/settings-css-vars.ts +199 -0
  436. package/src/surfaces/settings-defs.json +1363 -0
  437. package/src/surfaces/settings-defs.ts +232 -0
  438. package/src/surfaces/settings-deploy.json +108 -0
  439. package/src/surfaces/settings-deploy.ts +135 -0
  440. package/src/surfaces/settings-extensions.json +486 -0
  441. package/src/surfaces/settings-extensions.ts +201 -0
  442. package/src/surfaces/settings-head.json +779 -0
  443. package/src/surfaces/settings-head.ts +397 -0
  444. package/src/surfaces/settings-locales.json +420 -0
  445. package/src/surfaces/settings-locales.ts +137 -0
  446. package/src/surfaces/settings-overview.json +423 -0
  447. package/src/surfaces/settings-overview.ts +218 -0
  448. package/src/surfaces/settings-packages.json +549 -0
  449. package/src/surfaces/settings-packages.ts +158 -0
  450. package/src/surfaces/settings-pane.json +147 -0
  451. package/src/surfaces/settings-pane.ts +150 -0
  452. package/src/surfaces/settings-rawjson.json +104 -0
  453. package/src/surfaces/settings-rawjson.ts +107 -0
  454. package/src/surfaces/shell.json +99 -0
  455. package/src/surfaces/shell.ts +30 -0
  456. package/src/surfaces/slash-menu.json +180 -0
  457. package/src/surfaces/slash-menu.ts +272 -0
  458. package/src/surfaces/statements.json +607 -0
  459. package/src/surfaces/statements.ts +238 -0
  460. package/src/surfaces/statusbar.json +94 -0
  461. package/src/{panels → surfaces}/statusbar.ts +164 -90
  462. package/src/surfaces/style-panel.json +1643 -0
  463. package/src/surfaces/style-panel.ts +338 -0
  464. package/src/surfaces/stylebook-chrome.json +122 -0
  465. package/src/surfaces/stylebook-chrome.ts +122 -0
  466. package/src/surfaces/tab-strip.json +448 -0
  467. package/src/surfaces/tab-strip.ts +200 -0
  468. package/src/surfaces/target-line.json +419 -0
  469. package/src/surfaces/target-line.ts +349 -0
  470. package/src/surfaces/toasts.json +189 -0
  471. package/src/surfaces/welcome.json +571 -0
  472. package/src/surfaces/welcome.ts +338 -0
  473. package/src/tabs/project-config.ts +111 -21
  474. package/src/tabs/tab.ts +52 -1
  475. package/src/types.ts +22 -0
  476. package/src/ui/ai-credentials-form.ts +104 -100
  477. package/src/ui/ai-managed-connect.ts +54 -36
  478. package/src/ui/ai-model-picker.ts +75 -47
  479. package/src/ui/cf-account-picker.ts +76 -141
  480. package/src/ui/color-selector.ts +80 -301
  481. package/src/ui/dynamic-slot.ts +43 -283
  482. package/src/ui/expression-editor.ts +797 -576
  483. package/src/ui/field-input.ts +8 -181
  484. package/src/ui/form-controls.ts +838 -366
  485. package/src/ui/formula-chips.ts +80 -85
  486. package/src/ui/kit.ts +33 -0
  487. package/src/ui/layers.ts +296 -593
  488. package/src/ui/media-picker.ts +203 -284
  489. package/src/ui/panel-resize.ts +251 -64
  490. package/src/ui/popover-surface.ts +153 -0
  491. package/src/ui/progress-modal.ts +22 -60
  492. package/src/ui/regions.ts +13 -7
  493. package/src/ui/schema-form.ts +906 -440
  494. package/src/ui/surface.ts +122 -0
  495. package/src/ui/unit-selector.ts +15 -131
  496. package/src/ui/value-source.ts +14 -0
  497. package/src/ui/virtual-window.ts +88 -9
  498. package/src/utils/canvas-media.ts +72 -0
  499. package/src/utils/edit-display.ts +7 -2
  500. package/src/utils/element-selectors.ts +69 -0
  501. package/src/utils/link-target.ts +2 -2
  502. package/src/utils/studio-utils.ts +0 -10
  503. package/src/view.ts +15 -0
  504. package/src/workspace/pane-derive.ts +36 -14
  505. package/src/workspace/workspace.ts +75 -6
  506. package/styles/canvas.css +72 -467
  507. package/styles/forced-colors.css +48 -82
  508. package/styles/forced-colors.json +41 -0
  509. package/styles/inspector.css +2 -1301
  510. package/styles/overlays.css +96 -2823
  511. package/styles/panels.css +6 -1423
  512. package/styles/shell-frame.css +272 -0
  513. package/styles/shell-frame.json +227 -0
  514. package/styles/shell.css +0 -1568
  515. package/styles/tokens.css +65 -136
  516. package/styles/tokens.json +84 -0
  517. package/dist/chunks/Overlay.dev-etqjwyf9.js +0 -23
  518. package/dist/chunks/adapter-jkcyhgtr.js +0 -14
  519. package/dist/chunks/cf-account-picker-en86v7x7.js +0 -163
  520. package/dist/chunks/cf-settings-45fgyx8y.js +0 -21
  521. package/dist/chunks/components-zmx10t62.js +0 -21
  522. package/dist/chunks/content-source-48xg86wj.js +0 -49
  523. package/dist/chunks/convert-to-repeater-43tfn7cs.js +0 -268
  524. package/dist/chunks/editor-cptq5jp1.js +0 -37
  525. package/dist/chunks/entry-commands-e63f1xc0.js +0 -46
  526. package/dist/chunks/extension-sections-txv08xxg.js +0 -311
  527. package/dist/chunks/file-ops-wbh4hhsx.js +0 -48
  528. package/dist/chunks/files-3kfkwhk4.js +0 -93
  529. package/dist/chunks/flow-qbfgrpeh.js +0 -634
  530. package/dist/chunks/focus-trap.esm-9t2drp0g.js +0 -1025
  531. package/dist/chunks/focus-visible-6eg70z18.js +0 -167
  532. package/dist/chunks/format-host-w16q81tf.js +0 -43
  533. package/dist/chunks/fs-events-hrrg328g.js +0 -21
  534. package/dist/chunks/git-panel-532whr1y.js +0 -59
  535. package/dist/chunks/index-zqxmqxmh.js +0 -109
  536. package/dist/chunks/jx-validate-8er6gbxy.js +0 -19
  537. package/dist/chunks/layers-panel-07hm7g5j.js +0 -67
  538. package/dist/chunks/layers-q75tj2mf.js +0 -45
  539. package/dist/chunks/lit-html-j055mkh8.js +0 -22
  540. package/dist/chunks/monaco-buffer-dqw0xxpx.js +0 -25
  541. package/dist/chunks/notify-yjm79n4s.js +0 -30
  542. package/dist/chunks/parse-24d0gay3.js +0 -19
  543. package/dist/chunks/platform-ba1j1gbh.js +0 -16
  544. package/dist/chunks/publish-panel-v9st96ja.js +0 -29
  545. package/dist/chunks/quick-search-zccjp6gv.js +0 -66
  546. package/dist/chunks/references-3qx8fkyp.js +0 -29
  547. package/dist/chunks/right-panel-vm3b6kwy.js +0 -46
  548. package/dist/chunks/section-registry-sx1ykvkw.js +0 -30
  549. package/dist/chunks/sp-overlay.dev-qgvhnxf4.js +0 -18
  550. package/dist/chunks/sp-popover.dev-n2etmqdp.js +0 -9
  551. package/dist/chunks/sp-progress-circle.dev-hryhj0es.js +0 -15
  552. package/dist/chunks/sp-tooltip.dev-4sastdnw.js +0 -15
  553. package/dist/chunks/sp-tray.dev-tkbscm06.js +0 -199
  554. package/dist/chunks/studio-0a5qrh01.js +0 -3
  555. package/dist/chunks/studio-0bq6eh7v.js +0 -12
  556. package/dist/chunks/studio-18j3bmcz.js +0 -14
  557. package/dist/chunks/studio-1ngbejft.js +0 -181
  558. package/dist/chunks/studio-4b5z1x43.js +0 -424
  559. package/dist/chunks/studio-4n2b5gzb.js +0 -357
  560. package/dist/chunks/studio-4rzyrtjz.js +0 -426
  561. package/dist/chunks/studio-5fx3g9jg.js +0 -4325
  562. package/dist/chunks/studio-5myknm0a.js +0 -1903
  563. package/dist/chunks/studio-7afd21nw.js +0 -67
  564. package/dist/chunks/studio-7nte2hj4.js +0 -613
  565. package/dist/chunks/studio-8jpzqk5s.js +0 -128
  566. package/dist/chunks/studio-8q517dfr.js +0 -24
  567. package/dist/chunks/studio-950k0dx6.js +0 -6939
  568. package/dist/chunks/studio-9n4mrmnb.js +0 -184
  569. package/dist/chunks/studio-a0tswy0w.js +0 -58
  570. package/dist/chunks/studio-ahnzd9rg.js +0 -23
  571. package/dist/chunks/studio-bgxt93ga.js +0 -62
  572. package/dist/chunks/studio-cmb03bg5.js +0 -13890
  573. package/dist/chunks/studio-d1ks410h.js +0 -175
  574. package/dist/chunks/studio-ef49pnzx.js +0 -387
  575. package/dist/chunks/studio-eqq1w638.js +0 -113
  576. package/dist/chunks/studio-ew0djmhg.js +0 -341
  577. package/dist/chunks/studio-gfgb8pe6.js +0 -1652
  578. package/dist/chunks/studio-h4rxscfc.js +0 -10
  579. package/dist/chunks/studio-jc994dnr.js +0 -1066
  580. package/dist/chunks/studio-kyh9avvv.js +0 -28
  581. package/dist/chunks/studio-m3hwn7y1.js +0 -120
  582. package/dist/chunks/studio-mtfnaqs9.js +0 -659
  583. package/dist/chunks/studio-n6j9t10q.js +0 -318
  584. package/dist/chunks/studio-n8b9wqwy.js +0 -291
  585. package/dist/chunks/studio-qcy05dp8.js +0 -1743
  586. package/dist/chunks/studio-qq6jym04.js +0 -53
  587. package/dist/chunks/studio-rdx8jcxy.js +0 -83
  588. package/dist/chunks/studio-rn9ta2mz.js +0 -111
  589. package/dist/chunks/studio-t7qb9db8.js +0 -665
  590. package/dist/chunks/studio-tmc5emrw.js +0 -8
  591. package/dist/chunks/studio-z6nw2ek2.js +0 -18
  592. package/dist/chunks/studio-zczps70q.js +0 -378
  593. package/dist/chunks/studio-zqazsct2.js +0 -1823
  594. package/dist/chunks/workspace-fjx52ryv.js +0 -89
  595. package/src/panels/activity-bar.ts +0 -251
  596. package/src/panels/panel-scheduler.ts +0 -219
  597. package/src/panels/style-inputs.ts +0 -237
  598. package/src/panels/target-line.ts +0 -274
  599. package/src/panels/welcome-screen.ts +0 -346
  600. package/src/ui/button-group.ts +0 -102
  601. package/src/ui/choice-field.ts +0 -72
  602. package/src/ui/field-row.ts +0 -249
  603. package/src/ui/formula-palette.ts +0 -213
  604. package/src/ui/icons.ts +0 -52
  605. package/src/ui/jx-theme.ts +0 -130
  606. package/src/ui/spectrum.ts +0 -340
  607. package/src/ui/value-selector.ts +0 -174
  608. package/src/ui/widgets.ts +0 -172
  609. /package/dist/chunks/{javascript-s56a8dpk.css → javascript-4abzjcy9.css} +0 -0
  610. /package/dist/chunks/{jsonMode-zr9sw0c7.css → jsonMode-vvmpmk34.css} +0 -0
  611. /package/dist/chunks/{monaco-setup-pav68602.css → monaco-setup-8vbyqnhr.css} +0 -0
  612. /package/dist/chunks/{tsMode-ef187txx.css → tsMode-hnxxb73h.css} +0 -0
@@ -0,0 +1,2811 @@
1
+ import {
2
+ loadFormats2,
3
+ formatByName2,
4
+ formatForPath2,
5
+ defaultContentFormat2,
6
+ formatSerialize2
7
+ } from "./studio-vw7mzp6z.js";
8
+ import {
9
+ effectScope,
10
+ effect,
11
+ reactive,
12
+ notify2
13
+ } from "./studio-p1dw8wfw.js";
14
+ import {
15
+ projectState
16
+ } from "./studio-6ewqv390.js";
17
+ import {
18
+ recordDocOp,
19
+ transactDoc,
20
+ mutateUpdateFrontmatter,
21
+ stringArg,
22
+ booleanArg,
23
+ enumArg,
24
+ argsSchema,
25
+ derivedEnumProperty,
26
+ booleanProperty,
27
+ stringProperty,
28
+ LOCALE_PLACEHOLDER,
29
+ collectionForDirectory,
30
+ camelToLabel,
31
+ toCamelCase,
32
+ workspace2,
33
+ activeTab2,
34
+ activateTab2
35
+ } from "./studio-k75n7vhp.js";
36
+ import {
37
+ errorMessage2
38
+ } from "./studio-yxa81f45.js";
39
+ import {
40
+ activeRegistry
41
+ } from "./studio-kkqkcp3d.js";
42
+ import {
43
+ paneRegion,
44
+ registerSurface,
45
+ mountSurface
46
+ } from "./studio-vfq8qpjt.js";
47
+ import {
48
+ registerFormControl,
49
+ referenceTarget,
50
+ mountSchemaForm,
51
+ resolveContextPointer
52
+ } from "./studio-js8nv53n.js";
53
+ import {
54
+ DRAFT_FIELD,
55
+ DRAFT_MEANING,
56
+ isDraftEntry,
57
+ hasDraftAxis,
58
+ setIncludeDrafts,
59
+ reloadDraftAwareGrids2
60
+ } from "./studio-1knfqgy7.js";
61
+ import {
62
+ serializeJson
63
+ } from "./studio-qk90fgqm.js";
64
+ import {
65
+ notePreviewOverlayEdit
66
+ } from "./studio-gb13095a.js";
67
+ import {
68
+ entryCollection,
69
+ entryCollections,
70
+ collectionOfPath,
71
+ seedEntry,
72
+ missingRequired
73
+ } from "./studio-qhhm6hbt.js";
74
+ import {
75
+ cloneValue2
76
+ } from "./studio-727xh0e3.js";
77
+ import {
78
+ __preload
79
+ } from "./studio-5te5tqng.js";
80
+
81
+ // src/settings/schema-field-ui.ts
82
+ var FIELD_TYPES = ["string", "number", "boolean", "array", "object", "reference"];
83
+ var FORMAT_OPTIONS = ["", "image", "date", "color"];
84
+ function detectFieldType(schema) {
85
+ if (schema.$ref) {
86
+ return "reference";
87
+ }
88
+ return schema.type || "string";
89
+ }
90
+ function detectFieldFormat(schema) {
91
+ if (schema.type === "array" && schema.items?.format) {
92
+ return schema.items.format;
93
+ }
94
+ return schema.format || "";
95
+ }
96
+ function schemaForType(type, format) {
97
+ switch (type) {
98
+ case "number": {
99
+ return { type: "number" };
100
+ }
101
+ case "boolean": {
102
+ return { type: "boolean" };
103
+ }
104
+ case "array": {
105
+ return format ? { items: { format, type: "string" }, type: "array" } : { items: { type: "string" }, type: "array" };
106
+ }
107
+ case "object": {
108
+ return { properties: {}, required: [], type: "object" };
109
+ }
110
+ case "reference": {
111
+ return { $ref: "#/content/" };
112
+ }
113
+ default: {
114
+ return format ? { format, type: "string" } : { type: "string" };
115
+ }
116
+ }
117
+ }
118
+ // src/surfaces/schema-builder.json
119
+ var schema_builder_default = {
120
+ $schema: "https://jxsuite.com/schema/v1",
121
+ $id: "StudioSchemaBuilder",
122
+ $description: 'The `schema-builder` form control (specs/extensions.md §9.1): the visual editor for a JSON Schema object, drawn as one card per property. A descriptor names it with `"ui": { "<prop>": { "control": "schema-builder" } }`, and `ui/schema-form.ts` mounts it into the empty host its own document announces for that field. The adapter (`surfaces/schema-builder.ts`) hands in the fields already classified and every draft the reader is part-way through typing; `ui/form-controls.ts` decides what a field may be renamed to and what reaches the host\'s `onChange`. Nothing here reads a schema: a document that re-derived a field\'s type while drawing would be a second opinion about what one module already owns. **The card is `surfaces/settings-defs.json`\'s, part for part.** Data Shapes edits the project\'s `$defs` and this edits a content type\'s `schema`; they are the same object with the same six controls per row, so the row vocabulary — `card`, `field-row`, `field-label`, `field-name`, `field-type`, `field-format`, `field-required`, `field-delete`, `nested`, `nested-card`, `nested-add-name`/`-type`/`-button`, `ref-target`, `add-form` — is ONE vocabulary, and the row views it is drawn from are that surface\'s own types rather than a second declaration of them. What differs is only what encloses it: Data Shapes carries the two-column chrome that chooses WHICH shape is being edited, and this one is handed the object to edit.',
123
+ tagName: "div",
124
+ attributes: {
125
+ part: "builder"
126
+ },
127
+ style: {
128
+ $description: "What `.schema-builder`, `.schema-field-list`, `.schema-field-card`, `.schema-field-row`, `.schema-field-nested`, `.schema-field-name-input`, `.schema-nested-add`, `.schema-nested-add-name` and `.schema-add-field` said in `styles/overlays.css`, keyed on `part` and re-pointed at the studio token layer — the same translation `surfaces/settings-defs.json` carries, because it is the same card. Two values could not come with them. `.schema-field-card--nested` read `var(--spectrum-gray-300, #444)`, and the caption was an `sp-field-label` at whatever size Spectrum drew it; a document is mounted in the pane rather than inside `<sp-theme>`, so both would have taken their hard-coded fallback every time. The nested card takes the studio layer's `--border`, and the caption says what it is in the type ramp instead.",
129
+ display: "block",
130
+ '& [part="fields"]': {
131
+ display: "flex",
132
+ flexDirection: "column",
133
+ gap: "4px",
134
+ marginBottom: "12px"
135
+ },
136
+ '& [part="card"], & [part="nested-card"]': {
137
+ border: "1px solid var(--border)",
138
+ borderRadius: "var(--radius)",
139
+ padding: "6px 10px"
140
+ },
141
+ '& [part="field-row"]': {
142
+ display: "flex",
143
+ alignItems: "center",
144
+ gap: "8px"
145
+ },
146
+ '& [part="field-label"]': {
147
+ $description: "The field's name in words: a caption on the row rather than a label for a control, since the raw key beside it is what the reader edits and what carries the accessible name.",
148
+ flex: "none",
149
+ minWidth: "84px",
150
+ fontSize: "var(--jx-text-sm)",
151
+ color: "var(--fg-dim)",
152
+ overflowWrap: "anywhere"
153
+ },
154
+ '& [part="field-name"]': {
155
+ flex: "1",
156
+ maxWidth: "140px"
157
+ },
158
+ '& [part="nested"]': {
159
+ marginLeft: "16px",
160
+ marginTop: "6px",
161
+ paddingLeft: "8px",
162
+ borderLeft: "2px solid var(--border)",
163
+ display: "flex",
164
+ flexDirection: "column",
165
+ gap: "4px"
166
+ },
167
+ '& [part="ref-target"]': {
168
+ display: "flex",
169
+ marginTop: "6px",
170
+ maxWidth: "220px"
171
+ },
172
+ '& [part="nested-add"]': {
173
+ display: "flex",
174
+ alignItems: "center",
175
+ gap: "6px",
176
+ padding: "4px 0"
177
+ },
178
+ '& [part="nested-add-name"]': {
179
+ flex: "1",
180
+ maxWidth: "120px"
181
+ },
182
+ '& [part="add-form"]': {
183
+ display: "flex",
184
+ alignItems: "center",
185
+ gap: "8px",
186
+ padding: "8px 0"
187
+ }
188
+ },
189
+ children: [
190
+ {
191
+ tagName: "div",
192
+ attributes: {
193
+ part: "fields"
194
+ },
195
+ children: [
196
+ {
197
+ $prototype: "Array",
198
+ items: {
199
+ $ref: "#/state/fields"
200
+ },
201
+ key: {
202
+ $ref: "$map/item/key"
203
+ },
204
+ map: {
205
+ tagName: "div",
206
+ attributes: {
207
+ part: "card",
208
+ "data-field": "${$map.item.key}"
209
+ },
210
+ children: [
211
+ {
212
+ tagName: "div",
213
+ attributes: {
214
+ part: "field-row"
215
+ },
216
+ children: [
217
+ {
218
+ tagName: "span",
219
+ attributes: {
220
+ part: "field-label"
221
+ },
222
+ textContent: "${$map.item.label}"
223
+ },
224
+ {
225
+ tagName: "jx-textfield",
226
+ attributes: {
227
+ part: "field-name"
228
+ },
229
+ $props: {
230
+ label: "Name for ${$map.item.label}",
231
+ size: "sm",
232
+ value: {
233
+ $ref: "$map/item/name"
234
+ }
235
+ },
236
+ onchange: {
237
+ $prototype: "Function",
238
+ body: [
239
+ {
240
+ operator: "call",
241
+ target: {
242
+ $ref: "#/state/renameField"
243
+ },
244
+ value: [
245
+ {
246
+ $ref: "$map/item/key"
247
+ },
248
+ {
249
+ $ref: "event#/target/value"
250
+ }
251
+ ]
252
+ }
253
+ ]
254
+ }
255
+ },
256
+ {
257
+ tagName: "jx-select",
258
+ attributes: {
259
+ part: "field-type"
260
+ },
261
+ $props: {
262
+ label: "Type for ${$map.item.label}",
263
+ size: "sm",
264
+ options: {
265
+ $ref: "#/state/typeOptions"
266
+ },
267
+ value: {
268
+ $ref: "$map/item/type"
269
+ }
270
+ },
271
+ onchange: {
272
+ $prototype: "Function",
273
+ body: [
274
+ {
275
+ operator: "call",
276
+ target: {
277
+ $ref: "#/state/setType"
278
+ },
279
+ value: [
280
+ {
281
+ $ref: "$map/item/key"
282
+ },
283
+ {
284
+ $ref: "event#/target/value"
285
+ }
286
+ ]
287
+ }
288
+ ]
289
+ }
290
+ },
291
+ {
292
+ tagName: "div",
293
+ attributes: {
294
+ part: "format-slot",
295
+ role: "none"
296
+ },
297
+ style: {
298
+ display: "contents"
299
+ },
300
+ $switch: {
301
+ $ref: "$map/item/hasFormat"
302
+ },
303
+ cases: {
304
+ true: {
305
+ tagName: "jx-select",
306
+ attributes: {
307
+ part: "field-format"
308
+ },
309
+ $props: {
310
+ label: "Format for ${$map.item.label}",
311
+ size: "sm",
312
+ options: {
313
+ $ref: "#/state/formatOptions"
314
+ },
315
+ value: {
316
+ $ref: "$map/item/format"
317
+ }
318
+ },
319
+ onchange: {
320
+ $prototype: "Function",
321
+ body: [
322
+ {
323
+ operator: "call",
324
+ target: {
325
+ $ref: "#/state/setFormat"
326
+ },
327
+ value: [
328
+ {
329
+ $ref: "$map/item/key"
330
+ },
331
+ {
332
+ $ref: "event#/target/value"
333
+ }
334
+ ]
335
+ }
336
+ ]
337
+ }
338
+ }
339
+ }
340
+ },
341
+ {
342
+ tagName: "jx-switch",
343
+ $description: "Whether the object requires this field. The word on screen is the name: `Req` is slotted rather than passed as `label`, because the kit's switch wraps its control in the label the slot lands in, and a second name would be announced over the top of it. Which row it belongs to is the tooltip's job instead, which is what `hint` is.",
344
+ attributes: {
345
+ part: "field-required"
346
+ },
347
+ $props: {
348
+ hint: "Require ${$map.item.label}",
349
+ size: "sm",
350
+ checked: {
351
+ $ref: "$map/item/required"
352
+ }
353
+ },
354
+ onchange: {
355
+ $prototype: "Function",
356
+ body: [
357
+ {
358
+ operator: "call",
359
+ target: {
360
+ $ref: "#/state/setRequired"
361
+ },
362
+ value: [
363
+ {
364
+ $ref: "$map/item/key"
365
+ },
366
+ {
367
+ $ref: "event#/target/checked"
368
+ }
369
+ ]
370
+ }
371
+ ]
372
+ },
373
+ children: [
374
+ {
375
+ tagName: "span",
376
+ textContent: "Req"
377
+ }
378
+ ]
379
+ },
380
+ {
381
+ tagName: "jx-action-button",
382
+ attributes: {
383
+ part: "field-delete"
384
+ },
385
+ $props: {
386
+ label: "Delete ${$map.item.label}",
387
+ hint: "Delete ${$map.item.label}",
388
+ icon: "trash",
389
+ quiet: true,
390
+ size: "sm"
391
+ },
392
+ onclick: {
393
+ $prototype: "Function",
394
+ body: [
395
+ {
396
+ operator: "call",
397
+ target: {
398
+ $ref: "#/state/removeField"
399
+ },
400
+ value: [
401
+ {
402
+ $ref: "$map/item/key"
403
+ }
404
+ ]
405
+ }
406
+ ]
407
+ }
408
+ }
409
+ ]
410
+ },
411
+ {
412
+ tagName: "div",
413
+ attributes: {
414
+ part: "extra-slot",
415
+ role: "none"
416
+ },
417
+ style: {
418
+ display: "contents"
419
+ },
420
+ $switch: {
421
+ $ref: "$map/item/extra"
422
+ },
423
+ cases: {
424
+ reference: {
425
+ tagName: "div",
426
+ attributes: {
427
+ part: "ref-target"
428
+ },
429
+ children: [
430
+ {
431
+ tagName: "jx-select",
432
+ attributes: {
433
+ part: "ref-target-select"
434
+ },
435
+ $props: {
436
+ label: "Target for ${$map.item.label}",
437
+ size: "sm",
438
+ options: {
439
+ $ref: "#/state/targets"
440
+ },
441
+ value: {
442
+ $ref: "$map/item/refTarget"
443
+ }
444
+ },
445
+ onchange: {
446
+ $prototype: "Function",
447
+ body: [
448
+ {
449
+ operator: "call",
450
+ target: {
451
+ $ref: "#/state/setTarget"
452
+ },
453
+ value: [
454
+ {
455
+ $ref: "$map/item/key"
456
+ },
457
+ {
458
+ $ref: "event#/target/value"
459
+ }
460
+ ]
461
+ }
462
+ ]
463
+ }
464
+ }
465
+ ]
466
+ },
467
+ nested: {
468
+ tagName: "div",
469
+ attributes: {
470
+ part: "nested"
471
+ },
472
+ children: [
473
+ {
474
+ $prototype: "Array",
475
+ items: {
476
+ $ref: "$map/item/children"
477
+ },
478
+ key: {
479
+ $ref: "$map/item/key"
480
+ },
481
+ map: {
482
+ tagName: "div",
483
+ attributes: {
484
+ part: "nested-card",
485
+ "data-nested": "${$map.item.key}"
486
+ },
487
+ children: [
488
+ {
489
+ tagName: "div",
490
+ attributes: {
491
+ part: "field-row"
492
+ },
493
+ children: [
494
+ {
495
+ tagName: "jx-textfield",
496
+ attributes: {
497
+ part: "field-name"
498
+ },
499
+ $props: {
500
+ label: "Name for ${$map.item.parent}.${$map.item.key}",
501
+ size: "sm",
502
+ value: {
503
+ $ref: "$map/item/name"
504
+ }
505
+ },
506
+ onchange: {
507
+ $prototype: "Function",
508
+ body: [
509
+ {
510
+ operator: "call",
511
+ target: {
512
+ $ref: "#/state/renameNested"
513
+ },
514
+ value: [
515
+ {
516
+ $ref: "$map/item/parent"
517
+ },
518
+ {
519
+ $ref: "$map/item/key"
520
+ },
521
+ {
522
+ $ref: "event#/target/value"
523
+ }
524
+ ]
525
+ }
526
+ ]
527
+ }
528
+ },
529
+ {
530
+ tagName: "jx-select",
531
+ attributes: {
532
+ part: "field-type"
533
+ },
534
+ $props: {
535
+ label: "Type for ${$map.item.parent}.${$map.item.key}",
536
+ size: "sm",
537
+ options: {
538
+ $ref: "#/state/typeOptions"
539
+ },
540
+ value: {
541
+ $ref: "$map/item/type"
542
+ }
543
+ },
544
+ onchange: {
545
+ $prototype: "Function",
546
+ body: [
547
+ {
548
+ operator: "call",
549
+ target: {
550
+ $ref: "#/state/setNestedType"
551
+ },
552
+ value: [
553
+ {
554
+ $ref: "$map/item/parent"
555
+ },
556
+ {
557
+ $ref: "$map/item/key"
558
+ },
559
+ {
560
+ $ref: "event#/target/value"
561
+ }
562
+ ]
563
+ }
564
+ ]
565
+ }
566
+ },
567
+ {
568
+ tagName: "div",
569
+ attributes: {
570
+ part: "format-slot",
571
+ role: "none"
572
+ },
573
+ style: {
574
+ display: "contents"
575
+ },
576
+ $switch: {
577
+ $ref: "$map/item/hasFormat"
578
+ },
579
+ cases: {
580
+ true: {
581
+ tagName: "jx-select",
582
+ attributes: {
583
+ part: "field-format"
584
+ },
585
+ $props: {
586
+ label: "Format for ${$map.item.parent}.${$map.item.key}",
587
+ size: "sm",
588
+ options: {
589
+ $ref: "#/state/formatOptions"
590
+ },
591
+ value: {
592
+ $ref: "$map/item/format"
593
+ }
594
+ },
595
+ onchange: {
596
+ $prototype: "Function",
597
+ body: [
598
+ {
599
+ operator: "call",
600
+ target: {
601
+ $ref: "#/state/setNestedFormat"
602
+ },
603
+ value: [
604
+ {
605
+ $ref: "$map/item/parent"
606
+ },
607
+ {
608
+ $ref: "$map/item/key"
609
+ },
610
+ {
611
+ $ref: "event#/target/value"
612
+ }
613
+ ]
614
+ }
615
+ ]
616
+ }
617
+ }
618
+ }
619
+ },
620
+ {
621
+ tagName: "jx-switch",
622
+ attributes: {
623
+ part: "field-required"
624
+ },
625
+ $props: {
626
+ hint: "Require ${$map.item.parent}.${$map.item.key}",
627
+ size: "sm",
628
+ checked: {
629
+ $ref: "$map/item/required"
630
+ }
631
+ },
632
+ onchange: {
633
+ $prototype: "Function",
634
+ body: [
635
+ {
636
+ operator: "call",
637
+ target: {
638
+ $ref: "#/state/setNestedRequired"
639
+ },
640
+ value: [
641
+ {
642
+ $ref: "$map/item/parent"
643
+ },
644
+ {
645
+ $ref: "$map/item/key"
646
+ },
647
+ {
648
+ $ref: "event#/target/checked"
649
+ }
650
+ ]
651
+ }
652
+ ]
653
+ },
654
+ children: [
655
+ {
656
+ tagName: "span",
657
+ textContent: "Req"
658
+ }
659
+ ]
660
+ },
661
+ {
662
+ tagName: "jx-action-button",
663
+ attributes: {
664
+ part: "field-delete"
665
+ },
666
+ $props: {
667
+ label: "Delete ${$map.item.parent}.${$map.item.key}",
668
+ hint: "Delete ${$map.item.parent}.${$map.item.key}",
669
+ icon: "trash",
670
+ quiet: true,
671
+ size: "sm"
672
+ },
673
+ onclick: {
674
+ $prototype: "Function",
675
+ body: [
676
+ {
677
+ operator: "call",
678
+ target: {
679
+ $ref: "#/state/removeNested"
680
+ },
681
+ value: [
682
+ {
683
+ $ref: "$map/item/parent"
684
+ },
685
+ {
686
+ $ref: "$map/item/key"
687
+ }
688
+ ]
689
+ }
690
+ ]
691
+ }
692
+ }
693
+ ]
694
+ }
695
+ ]
696
+ }
697
+ },
698
+ {
699
+ tagName: "div",
700
+ attributes: {
701
+ part: "nested-add"
702
+ },
703
+ children: [
704
+ {
705
+ tagName: "jx-textfield",
706
+ attributes: {
707
+ part: "nested-add-name"
708
+ },
709
+ $props: {
710
+ label: "New field in ${$map.item.label}",
711
+ placeholder: "field name",
712
+ size: "sm",
713
+ value: {
714
+ $ref: "$map/item/draftName"
715
+ }
716
+ },
717
+ oninput: {
718
+ $prototype: "Function",
719
+ body: [
720
+ {
721
+ operator: "call",
722
+ target: {
723
+ $ref: "#/state/editDraftName"
724
+ },
725
+ value: [
726
+ {
727
+ $ref: "$map/item/key"
728
+ },
729
+ {
730
+ $ref: "event#/target/value"
731
+ }
732
+ ]
733
+ }
734
+ ]
735
+ },
736
+ onkeydown: {
737
+ $prototype: "Function",
738
+ body: [
739
+ {
740
+ $switch: {
741
+ $ref: "event#/key"
742
+ },
743
+ cases: {
744
+ Enter: [
745
+ {
746
+ preventDefault: true
747
+ },
748
+ {
749
+ operator: "call",
750
+ target: {
751
+ $ref: "#/state/addNested"
752
+ },
753
+ value: [
754
+ {
755
+ $ref: "$map/item/key"
756
+ }
757
+ ]
758
+ }
759
+ ]
760
+ }
761
+ }
762
+ ]
763
+ }
764
+ },
765
+ {
766
+ tagName: "jx-select",
767
+ attributes: {
768
+ part: "nested-add-type"
769
+ },
770
+ $props: {
771
+ label: "Type of the new field in ${$map.item.label}",
772
+ size: "sm",
773
+ options: {
774
+ $ref: "#/state/typeOptions"
775
+ },
776
+ value: {
777
+ $ref: "$map/item/draftType"
778
+ }
779
+ },
780
+ onchange: {
781
+ $prototype: "Function",
782
+ body: [
783
+ {
784
+ operator: "call",
785
+ target: {
786
+ $ref: "#/state/editDraftType"
787
+ },
788
+ value: [
789
+ {
790
+ $ref: "$map/item/key"
791
+ },
792
+ {
793
+ $ref: "event#/target/value"
794
+ }
795
+ ]
796
+ }
797
+ ]
798
+ }
799
+ },
800
+ {
801
+ tagName: "jx-action-button",
802
+ attributes: {
803
+ part: "nested-add-button"
804
+ },
805
+ $props: {
806
+ label: "Add a field to ${$map.item.label}",
807
+ hint: "Add a field to ${$map.item.label}",
808
+ icon: "plus",
809
+ quiet: true,
810
+ size: "sm"
811
+ },
812
+ onclick: {
813
+ $prototype: "Function",
814
+ body: [
815
+ {
816
+ operator: "call",
817
+ target: {
818
+ $ref: "#/state/addNested"
819
+ },
820
+ value: [
821
+ {
822
+ $ref: "$map/item/key"
823
+ }
824
+ ]
825
+ }
826
+ ]
827
+ }
828
+ }
829
+ ]
830
+ }
831
+ ]
832
+ }
833
+ }
834
+ }
835
+ ]
836
+ }
837
+ }
838
+ ]
839
+ },
840
+ {
841
+ tagName: "div",
842
+ attributes: {
843
+ part: "add-slot",
844
+ role: "none"
845
+ },
846
+ style: {
847
+ display: "contents"
848
+ },
849
+ $switch: {
850
+ $ref: "#/state/addState"
851
+ },
852
+ cases: {
853
+ closed: {
854
+ tagName: "jx-action-button",
855
+ attributes: {
856
+ part: "add-open"
857
+ },
858
+ $props: {
859
+ label: "Add Field",
860
+ icon: "plus",
861
+ quiet: true,
862
+ size: "sm"
863
+ },
864
+ onclick: {
865
+ $prototype: "Function",
866
+ body: [
867
+ {
868
+ operator: "call",
869
+ target: {
870
+ $ref: "#/state/openAdd"
871
+ },
872
+ value: []
873
+ }
874
+ ]
875
+ },
876
+ children: [
877
+ {
878
+ tagName: "span",
879
+ textContent: "Add Field"
880
+ }
881
+ ]
882
+ },
883
+ open: {
884
+ tagName: "div",
885
+ attributes: {
886
+ part: "add-form"
887
+ },
888
+ children: [
889
+ {
890
+ tagName: "jx-textfield",
891
+ attributes: {
892
+ part: "add-name"
893
+ },
894
+ $props: {
895
+ label: "New field name",
896
+ placeholder: "Field name",
897
+ size: "sm",
898
+ value: {
899
+ $ref: "#/state/addName"
900
+ }
901
+ },
902
+ oninput: {
903
+ $prototype: "Function",
904
+ body: [
905
+ {
906
+ operator: "call",
907
+ target: {
908
+ $ref: "#/state/editAddName"
909
+ },
910
+ value: [
911
+ {
912
+ $ref: "event#/target/value"
913
+ }
914
+ ]
915
+ }
916
+ ]
917
+ },
918
+ onkeydown: {
919
+ $prototype: "Function",
920
+ body: [
921
+ {
922
+ $switch: {
923
+ $ref: "event#/key"
924
+ },
925
+ cases: {
926
+ Enter: [
927
+ {
928
+ preventDefault: true
929
+ },
930
+ {
931
+ operator: "call",
932
+ target: {
933
+ $ref: "#/state/confirmAdd"
934
+ },
935
+ value: []
936
+ }
937
+ ],
938
+ Escape: [
939
+ {
940
+ preventDefault: true
941
+ },
942
+ {
943
+ operator: "call",
944
+ target: {
945
+ $ref: "#/state/cancelAdd"
946
+ },
947
+ value: []
948
+ }
949
+ ]
950
+ }
951
+ }
952
+ ]
953
+ }
954
+ },
955
+ {
956
+ tagName: "jx-select",
957
+ attributes: {
958
+ part: "add-type"
959
+ },
960
+ $props: {
961
+ label: "Type of the new field",
962
+ size: "sm",
963
+ options: {
964
+ $ref: "#/state/typeOptions"
965
+ },
966
+ value: {
967
+ $ref: "#/state/addType"
968
+ }
969
+ },
970
+ onchange: {
971
+ $prototype: "Function",
972
+ body: [
973
+ {
974
+ operator: "call",
975
+ target: {
976
+ $ref: "#/state/editAddType"
977
+ },
978
+ value: [
979
+ {
980
+ $ref: "event#/target/value"
981
+ }
982
+ ]
983
+ }
984
+ ]
985
+ }
986
+ },
987
+ {
988
+ tagName: "div",
989
+ attributes: {
990
+ part: "add-format-slot",
991
+ role: "none"
992
+ },
993
+ style: {
994
+ display: "contents"
995
+ },
996
+ $switch: {
997
+ $ref: "#/state/addHasFormat"
998
+ },
999
+ cases: {
1000
+ true: {
1001
+ tagName: "jx-select",
1002
+ attributes: {
1003
+ part: "add-format"
1004
+ },
1005
+ $props: {
1006
+ label: "Format of the new field",
1007
+ size: "sm",
1008
+ options: {
1009
+ $ref: "#/state/formatOptions"
1010
+ },
1011
+ value: {
1012
+ $ref: "#/state/addFormat"
1013
+ }
1014
+ },
1015
+ onchange: {
1016
+ $prototype: "Function",
1017
+ body: [
1018
+ {
1019
+ operator: "call",
1020
+ target: {
1021
+ $ref: "#/state/editAddFormat"
1022
+ },
1023
+ value: [
1024
+ {
1025
+ $ref: "event#/target/value"
1026
+ }
1027
+ ]
1028
+ }
1029
+ ]
1030
+ }
1031
+ }
1032
+ }
1033
+ },
1034
+ {
1035
+ tagName: "jx-switch",
1036
+ attributes: {
1037
+ part: "add-required"
1038
+ },
1039
+ $props: {
1040
+ hint: "Require the new field",
1041
+ size: "sm",
1042
+ checked: {
1043
+ $ref: "#/state/addRequired"
1044
+ }
1045
+ },
1046
+ onchange: {
1047
+ $prototype: "Function",
1048
+ body: [
1049
+ {
1050
+ operator: "call",
1051
+ target: {
1052
+ $ref: "#/state/editAddRequired"
1053
+ },
1054
+ value: [
1055
+ {
1056
+ $ref: "event#/target/checked"
1057
+ }
1058
+ ]
1059
+ }
1060
+ ]
1061
+ },
1062
+ children: [
1063
+ {
1064
+ tagName: "span",
1065
+ textContent: "Required"
1066
+ }
1067
+ ]
1068
+ },
1069
+ {
1070
+ tagName: "jx-button",
1071
+ attributes: {
1072
+ part: "add-confirm"
1073
+ },
1074
+ $props: {
1075
+ size: "sm"
1076
+ },
1077
+ onclick: {
1078
+ $prototype: "Function",
1079
+ body: [
1080
+ {
1081
+ operator: "call",
1082
+ target: {
1083
+ $ref: "#/state/confirmAdd"
1084
+ },
1085
+ value: []
1086
+ }
1087
+ ]
1088
+ },
1089
+ children: [
1090
+ {
1091
+ tagName: "span",
1092
+ textContent: "Add"
1093
+ }
1094
+ ]
1095
+ },
1096
+ {
1097
+ tagName: "jx-button",
1098
+ attributes: {
1099
+ part: "add-cancel"
1100
+ },
1101
+ $props: {
1102
+ size: "sm",
1103
+ quiet: true
1104
+ },
1105
+ onclick: {
1106
+ $prototype: "Function",
1107
+ body: [
1108
+ {
1109
+ operator: "call",
1110
+ target: {
1111
+ $ref: "#/state/cancelAdd"
1112
+ },
1113
+ value: []
1114
+ }
1115
+ ]
1116
+ },
1117
+ children: [
1118
+ {
1119
+ tagName: "span",
1120
+ textContent: "Cancel"
1121
+ }
1122
+ ]
1123
+ }
1124
+ ]
1125
+ }
1126
+ }
1127
+ }
1128
+ ]
1129
+ };
1130
+
1131
+ // src/surfaces/schema-builder.ts
1132
+ registerSurface("schema-builder", schema_builder_default);
1133
+ function emptyView() {
1134
+ return {
1135
+ addFormat: "",
1136
+ addHasFormat: true,
1137
+ addName: "",
1138
+ addRequired: false,
1139
+ addState: "closed",
1140
+ addType: "string",
1141
+ fields: [],
1142
+ formatOptions: [],
1143
+ targets: [],
1144
+ typeOptions: []
1145
+ };
1146
+ }
1147
+ function mountSchemaBuilderSurface(host, actions) {
1148
+ host.textContent = "";
1149
+ const scope = reactive({ ...emptyView(), ...actions });
1150
+ let handle = null;
1151
+ let mounting = true;
1152
+ let disposed = false;
1153
+ const mount = () => mountSurface("schema-builder", scope, host).then((mounted) => {
1154
+ mounting = false;
1155
+ if (disposed) {
1156
+ mounted.dispose();
1157
+ return mounted.root;
1158
+ }
1159
+ handle = mounted;
1160
+ return mounted.root;
1161
+ });
1162
+ const ready = mount();
1163
+ return {
1164
+ dispose() {
1165
+ disposed = true;
1166
+ handle?.dispose();
1167
+ handle = null;
1168
+ host.textContent = "";
1169
+ },
1170
+ host,
1171
+ ready,
1172
+ update(view) {
1173
+ scope.addFormat = view.addFormat;
1174
+ scope.addHasFormat = view.addHasFormat;
1175
+ scope.addName = view.addName;
1176
+ scope.addRequired = view.addRequired;
1177
+ scope.addState = view.addState;
1178
+ scope.addType = view.addType;
1179
+ scope.fields = view.fields;
1180
+ scope.formatOptions = view.formatOptions;
1181
+ scope.targets = view.targets;
1182
+ scope.typeOptions = view.typeOptions;
1183
+ if (disposed || mounting || handle !== null && host.contains(handle.root)) {
1184
+ return;
1185
+ }
1186
+ handle?.dispose();
1187
+ handle = null;
1188
+ mounting = true;
1189
+ host.textContent = "";
1190
+ mount();
1191
+ }
1192
+ };
1193
+ }
1194
+ // src/surfaces/reference-field.json
1195
+ var reference_field_default = {
1196
+ $schema: "https://jxsuite.com/schema/v1",
1197
+ $id: "StudioReferenceField",
1198
+ $description: 'The `reference` form control — site-architecture.md §6.1\'s `{ "$ref": "#/content/x" }` and §7.4\'s entry picker. Registered once and dispatched to by `ui/schema-form.ts` for any property whose `$ref` names a collection, so the settings forms, the entry editor and an array-of-objects cell all draw the same control without any of them knowing it exists. `ui/form-controls.ts` decides which of the three states the field is in and what each gesture commits; nothing here reads a schema or lists a directory. The three states are drawn as three different controls on purpose: a picker while the entries are known, a TEXT field while they are not — a failed read leaves the value editable with the reason beside it, because swapping it for an empty dropdown would present "no entries" and "could not find out" as the same screen — and a disabled picker saying so while the read is in flight.',
1199
+ tagName: "div",
1200
+ attributes: {
1201
+ part: "reference",
1202
+ role: "none"
1203
+ },
1204
+ style: {
1205
+ $description: "The five `.reference-*` rules from `styles/inspector.css`, keyed on `part` and re-pointed at the studio token layer. Two values could not come with them. The note read `var(--spectrum-font-size-50, 11px)`, which resolves only inside `<sp-theme>` — this document is mounted in a settings pane, an entry editor or a frontmatter card, all outside that element, so it would silently have taken its hard-coded fallback every time. And `.reference-missing` coloured ONE row of the dropdown red; the kit's select offers a row a face, a swatch and a border style but no tone, so the dangling entry says what it is in words (\"— not found\") and the colour is not replaced by a second channel. The 6px gap comes onto the kit's spacing scale.",
1206
+ display: "flex",
1207
+ flex: "1",
1208
+ minWidth: "0",
1209
+ alignItems: "center",
1210
+ gap: "var(--jx-space-2)",
1211
+ '& [part="picker"], & [part="text"]': {
1212
+ flex: "1",
1213
+ minWidth: "0"
1214
+ },
1215
+ '& [part="note"]': {
1216
+ margin: "0",
1217
+ color: "var(--fg-dim)",
1218
+ fontSize: "var(--jx-text-sm)",
1219
+ lineHeight: "1.4"
1220
+ },
1221
+ '& [part="note"][data-tone="danger"]': {
1222
+ $description: "A listing that failed is a FAULT rather than a fact about the project, and the two notes this control draws are otherwise the same sentence in the same place.",
1223
+ color: "var(--danger)"
1224
+ },
1225
+ '& [part="retry"]': {
1226
+ flex: "none"
1227
+ }
1228
+ },
1229
+ children: [
1230
+ {
1231
+ tagName: "div",
1232
+ attributes: {
1233
+ part: "control-slot",
1234
+ role: "none"
1235
+ },
1236
+ style: {
1237
+ display: "contents"
1238
+ },
1239
+ $switch: {
1240
+ $ref: "#/state/kind"
1241
+ },
1242
+ cases: {
1243
+ picker: {
1244
+ $description: "The collection's entries. The empty row is `\"\"` rather than a sentinel, because the kit's select treats the empty string as a legal value a reader can arrow to; a dangling reference is kept in the list and marked, since blanking the field would delete the evidence and the value in one repaint. While the read is in flight the same control is disabled and offers one row saying so.",
1245
+ tagName: "jx-select",
1246
+ attributes: {
1247
+ part: "picker"
1248
+ },
1249
+ $props: {
1250
+ size: "sm",
1251
+ label: {
1252
+ $ref: "#/state/label"
1253
+ },
1254
+ options: {
1255
+ $ref: "#/state/options"
1256
+ },
1257
+ value: {
1258
+ $ref: "#/state/value"
1259
+ },
1260
+ disabled: {
1261
+ $ref: "#/state/disabled"
1262
+ }
1263
+ },
1264
+ onchange: {
1265
+ $prototype: "Function",
1266
+ body: [
1267
+ {
1268
+ operator: "call",
1269
+ target: {
1270
+ $ref: "#/state/choose"
1271
+ },
1272
+ value: [
1273
+ {
1274
+ $ref: "event#/target/value"
1275
+ }
1276
+ ]
1277
+ }
1278
+ ]
1279
+ }
1280
+ },
1281
+ text: {
1282
+ $description: "The id as the string it is: what a reader gets when the choices could not be listed, and when the control was named by a `ui.control` override on a property that references nothing. Refusing to draw anything would lose the value that is already there.",
1283
+ tagName: "jx-textfield",
1284
+ attributes: {
1285
+ part: "text"
1286
+ },
1287
+ $props: {
1288
+ size: "sm",
1289
+ label: {
1290
+ $ref: "#/state/label"
1291
+ },
1292
+ value: {
1293
+ $ref: "#/state/value"
1294
+ }
1295
+ },
1296
+ onchange: {
1297
+ $prototype: "Function",
1298
+ body: [
1299
+ {
1300
+ operator: "call",
1301
+ target: {
1302
+ $ref: "#/state/edit"
1303
+ },
1304
+ value: [
1305
+ {
1306
+ $ref: "event#/target/value"
1307
+ }
1308
+ ]
1309
+ }
1310
+ ]
1311
+ }
1312
+ }
1313
+ }
1314
+ },
1315
+ {
1316
+ tagName: "div",
1317
+ attributes: {
1318
+ part: "note-slot",
1319
+ role: "none"
1320
+ },
1321
+ style: {
1322
+ display: "contents"
1323
+ },
1324
+ $switch: {
1325
+ $ref: "#/state/hasNote"
1326
+ },
1327
+ cases: {
1328
+ true: {
1329
+ tagName: "p",
1330
+ attributes: {
1331
+ part: "note",
1332
+ "data-tone": "${state.noteTone}",
1333
+ role: "status"
1334
+ },
1335
+ textContent: "${state.note}"
1336
+ }
1337
+ }
1338
+ },
1339
+ {
1340
+ tagName: "div",
1341
+ attributes: {
1342
+ part: "retry-slot",
1343
+ role: "none"
1344
+ },
1345
+ style: {
1346
+ display: "contents"
1347
+ },
1348
+ $switch: {
1349
+ $ref: "#/state/canRetry"
1350
+ },
1351
+ cases: {
1352
+ true: {
1353
+ $description: "Offered only where there is something to try again — a listing that failed. It used to be offered only where the HOST passed a repaint hook, because a template control cannot draw a second frame of its own and a button that cannot do the thing it is named after is worse than its absence. A mounted control redraws itself, so the condition is now the failure rather than the host.",
1354
+ tagName: "jx-action-button",
1355
+ attributes: {
1356
+ part: "retry"
1357
+ },
1358
+ $props: {
1359
+ size: "sm",
1360
+ quiet: true,
1361
+ label: "Retry listing entries"
1362
+ },
1363
+ onclick: {
1364
+ $prototype: "Function",
1365
+ body: [
1366
+ {
1367
+ operator: "call",
1368
+ target: {
1369
+ $ref: "#/state/retry"
1370
+ },
1371
+ value: []
1372
+ }
1373
+ ]
1374
+ },
1375
+ children: [
1376
+ {
1377
+ tagName: "span",
1378
+ textContent: "Retry"
1379
+ }
1380
+ ]
1381
+ }
1382
+ }
1383
+ }
1384
+ ]
1385
+ };
1386
+
1387
+ // src/surfaces/reference-field.ts
1388
+ registerSurface("reference-field", reference_field_default);
1389
+ function emptyView2() {
1390
+ return {
1391
+ canRetry: false,
1392
+ disabled: true,
1393
+ hasNote: false,
1394
+ kind: "picker",
1395
+ label: "",
1396
+ note: "",
1397
+ noteTone: "dim",
1398
+ options: [],
1399
+ value: ""
1400
+ };
1401
+ }
1402
+ function mountReferenceFieldSurface(host, actions) {
1403
+ host.textContent = "";
1404
+ const scope = reactive({ ...emptyView2(), ...actions });
1405
+ let handle = null;
1406
+ let mounting = true;
1407
+ let disposed = false;
1408
+ const mount = () => mountSurface("reference-field", scope, host).then((mounted) => {
1409
+ mounting = false;
1410
+ if (disposed) {
1411
+ mounted.dispose();
1412
+ return mounted.root;
1413
+ }
1414
+ handle = mounted;
1415
+ return mounted.root;
1416
+ });
1417
+ const ready = mount();
1418
+ return {
1419
+ dispose() {
1420
+ disposed = true;
1421
+ handle?.dispose();
1422
+ handle = null;
1423
+ host.textContent = "";
1424
+ },
1425
+ host,
1426
+ ready,
1427
+ update(view) {
1428
+ scope.canRetry = view.canRetry;
1429
+ scope.disabled = view.disabled;
1430
+ scope.hasNote = view.hasNote;
1431
+ scope.kind = view.kind;
1432
+ scope.label = view.label;
1433
+ scope.note = view.note;
1434
+ scope.noteTone = view.noteTone;
1435
+ scope.options = view.options;
1436
+ scope.value = view.value;
1437
+ if (disposed || mounting || handle !== null && host.contains(handle.root)) {
1438
+ return;
1439
+ }
1440
+ handle?.dispose();
1441
+ handle = null;
1442
+ mounting = true;
1443
+ host.textContent = "";
1444
+ mount();
1445
+ }
1446
+ };
1447
+ }
1448
+ // src/surfaces/secret-field.json
1449
+ var secret_field_default = {
1450
+ $schema: "https://jxsuite.com/schema/v1",
1451
+ $id: "StudioSecretField",
1452
+ $description: 'The `secret` form control (specs/extensions.md §9.1, §13): one password field whose VALUE goes to the platform\'s secret store and never to project.json. A descriptor names it with `"ui": { "<field>": { "control": "secret" } }`, and `ui/schema-form.ts` mounts it into the empty host its own document announces for that field. **A surface never renders back the secret it describes, and this document is where that is visible rather than remembered**: the only thing bound to the field\'s value is `#/state/shown`, a scope path whose whole purpose is to hold nothing. What the field is worth is said in the placeholder instead — the env NAME the store gave it, which is the only half of a secret a screen may carry. `ui/form-controls.ts` decides everything else: whether the host has a secret store at all, what the placeholder says, what a commit is worth and what the field persists.',
1453
+ tagName: "div",
1454
+ attributes: {
1455
+ part: "secret",
1456
+ role: "none"
1457
+ },
1458
+ style: {
1459
+ $description: "`.secret-field` carried no rule anywhere — it was one of `check-styles.ts`'s ALLOWED_ORPHANS, a class emitted only so a test could find the control — so there is nothing to translate and the wrapper takes no box of its own. The field takes the width of the control host the form drew, which is the flex item; a kit field is inline-flex by default and would otherwise sit at its intrinsic width in a row sized for it.",
1460
+ display: "contents",
1461
+ '& [part="field"]': {
1462
+ width: "100%"
1463
+ }
1464
+ },
1465
+ children: [
1466
+ {
1467
+ $description: "`autocomplete: new-password` because this is a place to PUT a secret rather than to prove one: without it a password manager offers to fill the field with a credential belonging to whatever site the reader last logged in to, and the offer is the manager's own UI drawn over an editor. The value binding is `#/state/shown` and nothing else ever writes to it — see the document description.",
1468
+ tagName: "jx-textfield",
1469
+ attributes: {
1470
+ part: "field"
1471
+ },
1472
+ $props: {
1473
+ type: "password",
1474
+ size: "sm",
1475
+ autocomplete: "new-password",
1476
+ label: {
1477
+ $ref: "#/state/label"
1478
+ },
1479
+ placeholder: {
1480
+ $ref: "#/state/placeholder"
1481
+ },
1482
+ disabled: {
1483
+ $ref: "#/state/disabled"
1484
+ },
1485
+ value: {
1486
+ $ref: "#/state/shown"
1487
+ }
1488
+ },
1489
+ onchange: {
1490
+ $prototype: "Function",
1491
+ body: [
1492
+ {
1493
+ operator: "call",
1494
+ target: {
1495
+ $ref: "#/state/commit"
1496
+ },
1497
+ value: [
1498
+ {
1499
+ $ref: "event#/target/value"
1500
+ }
1501
+ ]
1502
+ }
1503
+ ],
1504
+ description: "The change bubbles out of the field's own input, so what the reader typed is read off the event rather than off the element — and it is read here, handed to the flow, and never written back onto the scope."
1505
+ }
1506
+ }
1507
+ ]
1508
+ };
1509
+
1510
+ // src/surfaces/secret-field.ts
1511
+ registerSurface("secret-field", secret_field_default);
1512
+ function emptyView3() {
1513
+ return { disabled: true, label: "", placeholder: "Not set" };
1514
+ }
1515
+ function mountSecretFieldSurface(host, actions) {
1516
+ host.textContent = "";
1517
+ const scope = reactive({ ...emptyView3(), ...actions, shown: "" });
1518
+ let handle = null;
1519
+ let mounting = true;
1520
+ let disposed = false;
1521
+ const mount = () => mountSurface("secret-field", scope, host).then((mounted) => {
1522
+ mounting = false;
1523
+ if (disposed) {
1524
+ mounted.dispose();
1525
+ return mounted.root;
1526
+ }
1527
+ handle = mounted;
1528
+ return mounted.root;
1529
+ });
1530
+ const ready = mount();
1531
+ return {
1532
+ clear() {
1533
+ scope.shown = " ";
1534
+ scope.shown = "";
1535
+ },
1536
+ dispose() {
1537
+ disposed = true;
1538
+ handle?.dispose();
1539
+ handle = null;
1540
+ host.textContent = "";
1541
+ },
1542
+ host,
1543
+ ready,
1544
+ update(view) {
1545
+ scope.disabled = view.disabled;
1546
+ scope.label = view.label;
1547
+ scope.placeholder = view.placeholder;
1548
+ if (disposed || mounting || handle !== null && host.contains(handle.root)) {
1549
+ return;
1550
+ }
1551
+ handle?.dispose();
1552
+ handle = null;
1553
+ mounting = true;
1554
+ host.textContent = "";
1555
+ mount();
1556
+ }
1557
+ };
1558
+ }
1559
+
1560
+ // src/ui/form-controls.ts
1561
+ var TYPE_ROWS = FIELD_TYPES.map((type) => ({ label: type, value: type }));
1562
+ var FORMAT_ROWS = FORMAT_OPTIONS.map((format) => ({
1563
+ label: format || "(none)",
1564
+ value: format
1565
+ }));
1566
+ var BLANK_FIELD = { format: "", name: "", required: false, type: "string" };
1567
+ var targetRows = [];
1568
+ var targetNames = " ";
1569
+ function targetsFor(ctx) {
1570
+ const content = ctx.resolvePointer("#/$context/content");
1571
+ const names = content && typeof content === "object" && !Array.isArray(content) ? Object.keys(content) : [];
1572
+ const id = names.join(" ");
1573
+ if (id !== targetNames) {
1574
+ targetNames = id;
1575
+ targetRows = names.map((name) => ({ label: name, value: name }));
1576
+ }
1577
+ return targetRows;
1578
+ }
1579
+ function takesFormat(type) {
1580
+ return type === "string" || type === "array";
1581
+ }
1582
+ function readSchema(value) {
1583
+ return value && typeof value === "object" && !Array.isArray(value) ? value : { properties: {}, required: [], type: "object" };
1584
+ }
1585
+ function cloneSchema(value) {
1586
+ const draft = JSON.parse(JSON.stringify(readSchema(value)));
1587
+ draft.type ??= "object";
1588
+ draft.properties ??= {};
1589
+ draft.required ??= [];
1590
+ return draft;
1591
+ }
1592
+ function nameId(key) {
1593
+ return `name:${key}`;
1594
+ }
1595
+ function requiredId(key) {
1596
+ return `required:${key}`;
1597
+ }
1598
+ function nestedId(parent, key) {
1599
+ return `${parent} ${key}`;
1600
+ }
1601
+ function shown(ui, id, held) {
1602
+ return ui.echo?.id === id ? ui.echo.value : held;
1603
+ }
1604
+ function nestedView(ui, parent, key, schema, required) {
1605
+ const id = nestedId(parent, key);
1606
+ const type = detectFieldType(schema);
1607
+ return {
1608
+ format: detectFieldFormat(schema),
1609
+ hasFormat: takesFormat(type),
1610
+ key,
1611
+ name: shown(ui, nameId(id), key),
1612
+ parent,
1613
+ required: shown(ui, requiredId(id), required),
1614
+ type
1615
+ };
1616
+ }
1617
+ function fieldView(ui, key, schema, required, hasTargets) {
1618
+ const type = detectFieldType(schema);
1619
+ const nested = type === "object";
1620
+ const draft = ui.drafts.get(key);
1621
+ const childRequired = schema.required ?? [];
1622
+ return {
1623
+ children: nested ? Object.entries(schema.properties ?? {}).map(([child, sub]) => nestedView(ui, key, child, sub, childRequired.includes(child))) : [],
1624
+ draftName: draft?.name ?? "",
1625
+ draftType: draft?.type ?? "string",
1626
+ extra: type === "reference" && hasTargets ? "reference" : nested ? "nested" : "none",
1627
+ format: detectFieldFormat(schema),
1628
+ hasFormat: takesFormat(type),
1629
+ key,
1630
+ label: camelToLabel(key),
1631
+ name: shown(ui, nameId(key), key),
1632
+ refTarget: schema.$ref ? schema.$ref.replace(/^#\/[^/]+\//, "") : "",
1633
+ required: shown(ui, requiredId(key), required),
1634
+ type
1635
+ };
1636
+ }
1637
+ function renameKey(properties, from, to) {
1638
+ const next = {};
1639
+ for (const [key, value] of Object.entries(properties)) {
1640
+ next[key === from ? to : key] = value;
1641
+ delete properties[key];
1642
+ }
1643
+ Object.assign(properties, next);
1644
+ }
1645
+ function markRequired(holder, key, required) {
1646
+ holder.required ??= [];
1647
+ const at = holder.required.indexOf(key);
1648
+ if (required && at === -1) {
1649
+ holder.required.push(key);
1650
+ }
1651
+ if (!required && at !== -1) {
1652
+ holder.required.splice(at, 1);
1653
+ }
1654
+ }
1655
+ function mountSchemaBuilder(host, args) {
1656
+ let latest = args;
1657
+ let committed = null;
1658
+ const ui = {
1659
+ add: { ...BLANK_FIELD },
1660
+ addOpen: false,
1661
+ drafts: new Map,
1662
+ echo: null
1663
+ };
1664
+ const source = () => committed ?? readSchema(latest.value);
1665
+ const project = () => {
1666
+ const schema = source();
1667
+ const required = schema.required ?? [];
1668
+ const rows = targetsFor(latest.ctx);
1669
+ return {
1670
+ addFormat: ui.add.format,
1671
+ addHasFormat: takesFormat(ui.add.type),
1672
+ addName: ui.add.name,
1673
+ addRequired: ui.add.required,
1674
+ addState: ui.addOpen ? "open" : "closed",
1675
+ addType: ui.add.type,
1676
+ fields: Object.entries(schema.properties ?? {}).map(([key, property]) => fieldView(ui, key, property, required.includes(key), rows.length > 0)),
1677
+ formatOptions: FORMAT_ROWS,
1678
+ targets: rows,
1679
+ typeOptions: TYPE_ROWS
1680
+ };
1681
+ };
1682
+ const redraw = () => surface.update(project());
1683
+ const say = (id, value) => {
1684
+ ui.echo = { id, value };
1685
+ redraw();
1686
+ };
1687
+ const refuse = () => {
1688
+ ui.echo = null;
1689
+ redraw();
1690
+ };
1691
+ const write = (mutate) => {
1692
+ const draft = cloneSchema(source());
1693
+ if (!mutate(draft)) {
1694
+ refuse();
1695
+ return;
1696
+ }
1697
+ committed = draft;
1698
+ ui.echo = null;
1699
+ latest.onChange(draft);
1700
+ redraw();
1701
+ };
1702
+ const parentOf = (draft, parent) => draft.properties[parent];
1703
+ const draftOf = (parent) => {
1704
+ let draft = ui.drafts.get(parent);
1705
+ if (!draft) {
1706
+ draft = { name: "", type: "string" };
1707
+ ui.drafts.set(parent, draft);
1708
+ }
1709
+ return draft;
1710
+ };
1711
+ const surface = mountSchemaBuilderSurface(host, {
1712
+ addNested(parent) {
1713
+ const draft = draftOf(parent);
1714
+ const name = toCamelCase(draft.name.trim());
1715
+ if (!name) {
1716
+ return;
1717
+ }
1718
+ write((next) => {
1719
+ const holder = parentOf(next, parent);
1720
+ if (!holder) {
1721
+ return false;
1722
+ }
1723
+ holder.properties ??= {};
1724
+ holder.properties[name] = schemaForType(draft.type || "string");
1725
+ draft.name = "";
1726
+ return true;
1727
+ });
1728
+ },
1729
+ cancelAdd() {
1730
+ ui.addOpen = false;
1731
+ ui.add = { ...BLANK_FIELD };
1732
+ redraw();
1733
+ },
1734
+ confirmAdd() {
1735
+ const name = toCamelCase(ui.add.name.trim());
1736
+ if (!name) {
1737
+ return;
1738
+ }
1739
+ const { format, required, type } = ui.add;
1740
+ ui.addOpen = false;
1741
+ ui.add = { ...BLANK_FIELD };
1742
+ write((next) => {
1743
+ next.properties[name] = schemaForType(type, format || undefined);
1744
+ if (required) {
1745
+ markRequired(next, name, true);
1746
+ }
1747
+ return true;
1748
+ });
1749
+ },
1750
+ editAddFormat(value) {
1751
+ ui.add.format = value;
1752
+ redraw();
1753
+ },
1754
+ editAddName(value) {
1755
+ ui.add.name = value;
1756
+ redraw();
1757
+ },
1758
+ editAddRequired(required) {
1759
+ ui.add.required = required;
1760
+ redraw();
1761
+ },
1762
+ editAddType(value) {
1763
+ ui.add.type = value;
1764
+ redraw();
1765
+ },
1766
+ editDraftName(parent, value) {
1767
+ draftOf(parent).name = value;
1768
+ redraw();
1769
+ },
1770
+ editDraftType(parent, value) {
1771
+ draftOf(parent).type = value;
1772
+ redraw();
1773
+ },
1774
+ openAdd() {
1775
+ ui.addOpen = true;
1776
+ ui.add = { ...BLANK_FIELD };
1777
+ redraw();
1778
+ },
1779
+ removeField(key) {
1780
+ write((next) => {
1781
+ if (!next.properties[key]) {
1782
+ return false;
1783
+ }
1784
+ delete next.properties[key];
1785
+ next.required = next.required.filter((name) => name !== key);
1786
+ return true;
1787
+ });
1788
+ },
1789
+ removeNested(parent, key) {
1790
+ write((next) => {
1791
+ const holder = parentOf(next, parent);
1792
+ if (!holder?.properties?.[key]) {
1793
+ return false;
1794
+ }
1795
+ delete holder.properties[key];
1796
+ if (holder.required) {
1797
+ holder.required = holder.required.filter((name) => name !== key);
1798
+ }
1799
+ return true;
1800
+ });
1801
+ },
1802
+ renameField(key, value) {
1803
+ say(nameId(key), value);
1804
+ const name = toCamelCase(value.trim());
1805
+ write((next) => {
1806
+ if (!next.properties[key] || !name || name === key || next.properties[name]) {
1807
+ return false;
1808
+ }
1809
+ renameKey(next.properties, key, name);
1810
+ next.required = next.required.map((entry) => entry === key ? name : entry);
1811
+ return true;
1812
+ });
1813
+ },
1814
+ renameNested(parent, key, value) {
1815
+ say(nameId(nestedId(parent, key)), value);
1816
+ const name = toCamelCase(value.trim());
1817
+ write((next) => {
1818
+ const holder = parentOf(next, parent);
1819
+ if (!holder?.properties?.[key] || !name || name === key || holder.properties[name]) {
1820
+ return false;
1821
+ }
1822
+ renameKey(holder.properties, key, name);
1823
+ if (holder.required) {
1824
+ holder.required = holder.required.map((entry) => entry === key ? name : entry);
1825
+ }
1826
+ return true;
1827
+ });
1828
+ },
1829
+ setFormat(key, value) {
1830
+ write((next) => {
1831
+ const property = next.properties[key];
1832
+ if (!property) {
1833
+ return false;
1834
+ }
1835
+ next.properties[key] = schemaForType(property.type || "string", value || undefined);
1836
+ return true;
1837
+ });
1838
+ },
1839
+ setNestedFormat(parent, key, value) {
1840
+ write((next) => {
1841
+ const holder = parentOf(next, parent);
1842
+ const property = holder?.properties?.[key];
1843
+ if (!holder?.properties || !property) {
1844
+ return false;
1845
+ }
1846
+ holder.properties[key] = schemaForType(property.type || "string", value || undefined);
1847
+ return true;
1848
+ });
1849
+ },
1850
+ setNestedRequired(parent, key, required) {
1851
+ say(requiredId(nestedId(parent, key)), required);
1852
+ write((next) => {
1853
+ const holder = parentOf(next, parent);
1854
+ if (!holder) {
1855
+ return false;
1856
+ }
1857
+ markRequired(holder, key, required);
1858
+ return true;
1859
+ });
1860
+ },
1861
+ setNestedType(parent, key, value) {
1862
+ write((next) => {
1863
+ const holder = parentOf(next, parent);
1864
+ const property = holder?.properties?.[key];
1865
+ if (!holder?.properties || !property) {
1866
+ return false;
1867
+ }
1868
+ const format = takesFormat(value) ? detectFieldFormat(property) : undefined;
1869
+ holder.properties[key] = schemaForType(value, format || undefined);
1870
+ return true;
1871
+ });
1872
+ },
1873
+ setRequired(key, required) {
1874
+ say(requiredId(key), required);
1875
+ write((next) => {
1876
+ if (!next.properties[key]) {
1877
+ return false;
1878
+ }
1879
+ markRequired(next, key, required);
1880
+ return true;
1881
+ });
1882
+ },
1883
+ setTarget(key, value) {
1884
+ write((next) => {
1885
+ if (!next.properties[key]) {
1886
+ return false;
1887
+ }
1888
+ next.properties[key] = { $ref: `#/content/${value}` };
1889
+ return true;
1890
+ });
1891
+ },
1892
+ setType(key, value) {
1893
+ write((next) => {
1894
+ const property = next.properties[key];
1895
+ if (!property) {
1896
+ return false;
1897
+ }
1898
+ const format = takesFormat(value) ? detectFieldFormat(property) : undefined;
1899
+ next.properties[key] = schemaForType(value, format || undefined);
1900
+ return true;
1901
+ });
1902
+ }
1903
+ });
1904
+ redraw();
1905
+ return {
1906
+ dispose: () => surface.dispose(),
1907
+ update(next) {
1908
+ latest = next;
1909
+ committed = null;
1910
+ ui.echo = null;
1911
+ redraw();
1912
+ }
1913
+ };
1914
+ }
1915
+ var schemaBuilderControl = { mount: mountSchemaBuilder };
1916
+ registerFormControl("schema-builder", schemaBuilderControl);
1917
+ function envNameOf(value) {
1918
+ return typeof value === "string" && value ? value : null;
1919
+ }
1920
+ function mountSecret(host, args) {
1921
+ let latest = args;
1922
+ const redraw = () => {
1923
+ const envName = envNameOf(latest.value);
1924
+ surface.update({
1925
+ disabled: !latest.ctx.commitSecret,
1926
+ label: latest.key,
1927
+ placeholder: envName ? `Stored as ${envName}` : "Not set"
1928
+ });
1929
+ };
1930
+ const surface = mountSecretFieldSurface(host, {
1931
+ commit(value) {
1932
+ const { commitSecret } = latest.ctx;
1933
+ if (!commitSecret || !value) {
1934
+ return;
1935
+ }
1936
+ surface.clear();
1937
+ const { key, onChange } = latest;
1938
+ const envName = envNameOf(latest.value);
1939
+ Promise.resolve(commitSecret(key, value)).then((name) => {
1940
+ if (typeof name === "string" && name && name !== envName) {
1941
+ onChange(name);
1942
+ }
1943
+ });
1944
+ }
1945
+ });
1946
+ redraw();
1947
+ return {
1948
+ dispose: () => surface.dispose(),
1949
+ update(next) {
1950
+ latest = next;
1951
+ redraw();
1952
+ }
1953
+ };
1954
+ }
1955
+ var secretControl = { mount: mountSecret };
1956
+ registerFormControl("secret", secretControl);
1957
+ var entryIdCache = new Map;
1958
+ var entryIdResult = new Map;
1959
+ var entryIdWaiting = new Map;
1960
+ function invalidateReferenceEntries(collection) {
1961
+ if (collection === undefined) {
1962
+ entryIdCache.clear();
1963
+ entryIdResult.clear();
1964
+ entryIdWaiting.clear();
1965
+ } else {
1966
+ entryIdCache.delete(collection);
1967
+ entryIdResult.delete(collection);
1968
+ entryIdWaiting.delete(collection);
1969
+ }
1970
+ }
1971
+ function entryIdsFor(collection) {
1972
+ const known = entryIdCache.get(collection);
1973
+ if (known) {
1974
+ return known;
1975
+ }
1976
+ const pending = (__preload("5mex4x1h"), import("./content-source-5mex4x1h.js")).then((m) => m.listCollectionEntryIds(collection));
1977
+ entryIdCache.set(collection, pending);
1978
+ return pending;
1979
+ }
1980
+ function referenceEntryState(collection, onSettled) {
1981
+ const done = entryIdResult.get(collection);
1982
+ if (done) {
1983
+ return done;
1984
+ }
1985
+ const pending = entryIdsFor(collection);
1986
+ const waiting = entryIdWaiting.get(collection);
1987
+ if (waiting) {
1988
+ if (onSettled) {
1989
+ waiting.add(onSettled);
1990
+ }
1991
+ return null;
1992
+ }
1993
+ entryIdWaiting.set(collection, new Set(onSettled ? [onSettled] : []));
1994
+ const settle = (result) => {
1995
+ if (entryIdCache.get(collection) !== pending) {
1996
+ return;
1997
+ }
1998
+ const listeners = entryIdWaiting.get(collection);
1999
+ entryIdWaiting.delete(collection);
2000
+ entryIdResult.set(collection, result);
2001
+ for (const run of listeners ?? []) {
2002
+ run();
2003
+ }
2004
+ };
2005
+ pending.then((ids) => settle({ ids }), (error) => settle({ error: errorMessage2(error) }));
2006
+ return null;
2007
+ }
2008
+ function referenceView(args, onSettled) {
2009
+ const current = typeof args.value === "string" ? args.value : "";
2010
+ const base = {
2011
+ canRetry: false,
2012
+ disabled: false,
2013
+ hasNote: false,
2014
+ label: args.key,
2015
+ note: "",
2016
+ noteTone: "dim",
2017
+ options: [],
2018
+ value: current
2019
+ };
2020
+ const collection = referenceTarget(args.schema);
2021
+ if (collection === null) {
2022
+ return {
2023
+ ...base,
2024
+ hasNote: true,
2025
+ kind: "text",
2026
+ note: 'No collection referenced — add "$ref": "#/content/<type>" to this field.'
2027
+ };
2028
+ }
2029
+ const state = referenceEntryState(collection, onSettled);
2030
+ if (state === null) {
2031
+ return {
2032
+ ...base,
2033
+ disabled: true,
2034
+ kind: "picker",
2035
+ options: [{ label: "Loading…", value: current }]
2036
+ };
2037
+ }
2038
+ if ("error" in state) {
2039
+ return {
2040
+ ...base,
2041
+ canRetry: true,
2042
+ hasNote: true,
2043
+ kind: "text",
2044
+ note: `Could not list ${collection} entries — ${state.error}`,
2045
+ noteTone: "danger"
2046
+ };
2047
+ }
2048
+ const dangling = current !== "" && !state.ids.includes(current);
2049
+ return {
2050
+ ...base,
2051
+ hasNote: state.ids.length === 0,
2052
+ kind: "picker",
2053
+ note: state.ids.length === 0 ? `No ${collection} entries yet.` : "",
2054
+ options: [
2055
+ { label: "—", value: "" },
2056
+ ...dangling ? [{ label: `${current} — not found`, value: current }] : [],
2057
+ ...state.ids.map((id) => ({ label: id, value: id }))
2058
+ ]
2059
+ };
2060
+ }
2061
+ function mountReference(host, args) {
2062
+ let latest = args;
2063
+ let disposed = false;
2064
+ const redraw = () => {
2065
+ if (!disposed) {
2066
+ surface.update(referenceView(latest, redraw));
2067
+ }
2068
+ };
2069
+ const surface = mountReferenceFieldSurface(host, {
2070
+ choose(value) {
2071
+ latest.onChange(value === "" ? undefined : value);
2072
+ },
2073
+ edit(value) {
2074
+ latest.onChange(value.trim() || undefined);
2075
+ },
2076
+ retry() {
2077
+ const collection = referenceTarget(latest.schema);
2078
+ if (collection !== null) {
2079
+ invalidateReferenceEntries(collection);
2080
+ }
2081
+ redraw();
2082
+ }
2083
+ });
2084
+ redraw();
2085
+ return {
2086
+ dispose() {
2087
+ disposed = true;
2088
+ surface.dispose();
2089
+ },
2090
+ update(next) {
2091
+ latest = next;
2092
+ redraw();
2093
+ }
2094
+ };
2095
+ }
2096
+ var referenceControl = { mount: mountReference };
2097
+ registerFormControl("reference", referenceControl);
2098
+ // src/surfaces/entry-editor.json
2099
+ var entry_editor_default = {
2100
+ $schema: "https://jxsuite.com/schema/v1",
2101
+ $id: "StudioEntryEditor",
2102
+ $description: "The Entry editor (§7.4) — one content entry's fields, in a pane, as a Jx document over the kit. The adapter (`surfaces/entry-editor.ts`) hands in a projection; `content/entry-editor.ts` decides everything in it — which collection the file belongs to, which record its fields live in, which required keys are absent and what a draft flag commits into. The FORM is an island: a schema is `ui/schema-form.ts`'s subject, so this document renders an empty `fields` node and the flow places the element that engine hands back (studio-ui-guidelines.md §9.3, §9.4). That is the whole of the difference between this and the card the lit version drew, and it is why the engine converting in batch 7 is what unblocked this one.",
2103
+ tagName: "div",
2104
+ attributes: {
2105
+ part: "entry",
2106
+ "data-jx-region": "${state.region}"
2107
+ },
2108
+ style: {
2109
+ $description: "What `.entry-editor`, `.entry-editor-header`, `.entry-editor-collection`, `.entry-draft-switch`, `.entry-editor-fields`, `.entry-editor-note` and `.entry-editor-empty` said in `styles/overlays.css`, keyed on `part` and re-pointed at the studio token layer. This editor was the only emitter of all seven, so those rules are dead in the stylesheet from here; a central sweep removes them rather than this change, which owns no stylesheet. Every `--spectrum-font-size-*` reference is gone rather than renamed: those names resolve only inside `<sp-theme>`, and a pane editor is mounted outside it, so each would silently have taken its hard-coded fallback.",
2110
+ height: "100%",
2111
+ padding: "var(--jx-space-5)",
2112
+ overflowY: "auto",
2113
+ background: "var(--bg-panel)",
2114
+ '& [part="header"]': {
2115
+ display: "flex",
2116
+ alignItems: "center",
2117
+ gap: "var(--jx-space-4)",
2118
+ marginBottom: "var(--jx-space-5)"
2119
+ },
2120
+ '& [part="name"]': {
2121
+ margin: "0",
2122
+ fontSize: "var(--jx-text-lg)",
2123
+ fontWeight: "600",
2124
+ color: "var(--fg)"
2125
+ },
2126
+ '& [part="collection"]': {
2127
+ padding: "1px var(--jx-space-3)",
2128
+ borderRadius: "var(--radius)",
2129
+ background: "var(--bg)",
2130
+ color: "var(--fg-dim)",
2131
+ fontSize: "var(--jx-text-sm)"
2132
+ },
2133
+ '& [part="draft"]': {
2134
+ $description: "Pushed to the far end of the header rather than placed there: the heading and the collection chip are both content-width, so `margin-left: auto` is what keeps the switch on the right edge whatever the entry is called.",
2135
+ marginLeft: "auto"
2136
+ },
2137
+ '& [part="fields"]': {
2138
+ $description: "The schema form's host is `display: contents`, so its rows are the flex items of THIS box — which is why the column lives here and not inside the engine.",
2139
+ display: "flex",
2140
+ flexDirection: "column"
2141
+ },
2142
+ '& [part="note"]': {
2143
+ margin: "0 0 var(--jx-space-4)",
2144
+ color: "var(--fg-dim)",
2145
+ fontSize: "var(--jx-text-md)",
2146
+ lineHeight: "1.5"
2147
+ },
2148
+ '& [part="empty"]': {
2149
+ display: "flex",
2150
+ maxWidth: "46ch",
2151
+ flexDirection: "column",
2152
+ alignItems: "flex-start",
2153
+ gap: "var(--jx-space-3)",
2154
+ color: "var(--fg-dim)",
2155
+ fontSize: "var(--jx-text-md)",
2156
+ lineHeight: "1.5"
2157
+ }
2158
+ },
2159
+ children: [
2160
+ {
2161
+ tagName: "div",
2162
+ attributes: {
2163
+ part: "stage-slot",
2164
+ role: "none"
2165
+ },
2166
+ style: {
2167
+ display: "contents"
2168
+ },
2169
+ $switch: {
2170
+ $ref: "#/state/stage"
2171
+ },
2172
+ cases: {
2173
+ entry: {
2174
+ tagName: "div",
2175
+ attributes: {
2176
+ part: "body",
2177
+ role: "none"
2178
+ },
2179
+ style: {
2180
+ display: "contents"
2181
+ },
2182
+ children: [
2183
+ {
2184
+ tagName: "div",
2185
+ attributes: {
2186
+ part: "header"
2187
+ },
2188
+ children: [
2189
+ {
2190
+ tagName: "h3",
2191
+ attributes: {
2192
+ part: "name"
2193
+ },
2194
+ textContent: "${state.name}"
2195
+ },
2196
+ {
2197
+ tagName: "span",
2198
+ attributes: {
2199
+ part: "collection"
2200
+ },
2201
+ textContent: "${state.collection}"
2202
+ },
2203
+ {
2204
+ tagName: "div",
2205
+ attributes: {
2206
+ part: "draft-slot",
2207
+ role: "none"
2208
+ },
2209
+ style: {
2210
+ display: "contents"
2211
+ },
2212
+ $switch: {
2213
+ $ref: "#/state/draftAxis"
2214
+ },
2215
+ cases: {
2216
+ shown: {
2217
+ $description: "No `label`: the slotted word is on screen and carries the name, so an aria-label would be read twice. The tooltip is `hint`, which is what DRAFT_MEANING has always been.",
2218
+ tagName: "jx-switch",
2219
+ attributes: {
2220
+ part: "draft"
2221
+ },
2222
+ $props: {
2223
+ checked: {
2224
+ $ref: "#/state/draft"
2225
+ },
2226
+ hint: "${state.draftHint}",
2227
+ size: "sm"
2228
+ },
2229
+ onchange: {
2230
+ $prototype: "Function",
2231
+ body: [
2232
+ {
2233
+ operator: "call",
2234
+ target: {
2235
+ $ref: "#/state/setDraft"
2236
+ },
2237
+ value: [
2238
+ {
2239
+ $ref: "event#/target/checked"
2240
+ }
2241
+ ]
2242
+ }
2243
+ ]
2244
+ },
2245
+ children: [
2246
+ {
2247
+ tagName: "span",
2248
+ textContent: "Draft"
2249
+ }
2250
+ ]
2251
+ }
2252
+ }
2253
+ }
2254
+ ]
2255
+ },
2256
+ {
2257
+ tagName: "div",
2258
+ attributes: {
2259
+ part: "note-slot",
2260
+ role: "none"
2261
+ },
2262
+ style: {
2263
+ display: "contents"
2264
+ },
2265
+ $switch: {
2266
+ $ref: "#/state/noteState"
2267
+ },
2268
+ cases: {
2269
+ shown: {
2270
+ tagName: "p",
2271
+ attributes: {
2272
+ part: "note"
2273
+ },
2274
+ textContent: "${state.note}"
2275
+ }
2276
+ }
2277
+ },
2278
+ {
2279
+ $description: "An island: `ui/schema-form.ts` draws this entry's fields into this node, and nothing in this document knows what a schema is.",
2280
+ tagName: "div",
2281
+ attributes: {
2282
+ part: "fields",
2283
+ "data-jx-region": "${state.fieldsRegion}"
2284
+ }
2285
+ }
2286
+ ]
2287
+ },
2288
+ empty: {
2289
+ $description: "The mode is reachable from the palette and from `__jxAutomation` on any tab, so this state is real: it names the reason and the fix rather than drawing an empty form.",
2290
+ tagName: "div",
2291
+ attributes: {
2292
+ part: "empty"
2293
+ },
2294
+ children: [
2295
+ {
2296
+ tagName: "p",
2297
+ attributes: {
2298
+ part: "empty-line"
2299
+ },
2300
+ textContent: "${state.emptyLine}"
2301
+ },
2302
+ {
2303
+ tagName: "p",
2304
+ attributes: {
2305
+ part: "note"
2306
+ },
2307
+ children: [
2308
+ {
2309
+ tagName: "span",
2310
+ textContent: "A collection is a "
2311
+ },
2312
+ {
2313
+ tagName: "code",
2314
+ textContent: "content"
2315
+ },
2316
+ {
2317
+ tagName: "span",
2318
+ textContent: " entry in "
2319
+ },
2320
+ {
2321
+ tagName: "code",
2322
+ textContent: "project.json"
2323
+ },
2324
+ {
2325
+ tagName: "span",
2326
+ textContent: " whose "
2327
+ },
2328
+ {
2329
+ tagName: "code",
2330
+ textContent: "source"
2331
+ },
2332
+ {
2333
+ tagName: "span",
2334
+ textContent: " directory contains this file and which declares a "
2335
+ },
2336
+ {
2337
+ tagName: "code",
2338
+ textContent: "schema"
2339
+ },
2340
+ {
2341
+ tagName: "span",
2342
+ textContent: "."
2343
+ }
2344
+ ]
2345
+ },
2346
+ {
2347
+ tagName: "jx-action-button",
2348
+ attributes: {
2349
+ part: "content-types"
2350
+ },
2351
+ $props: {
2352
+ label: "Content types",
2353
+ size: "sm"
2354
+ },
2355
+ onclick: {
2356
+ $prototype: "Function",
2357
+ body: [
2358
+ {
2359
+ operator: "call",
2360
+ target: {
2361
+ $ref: "#/state/openContentTypes"
2362
+ },
2363
+ value: []
2364
+ }
2365
+ ]
2366
+ },
2367
+ children: [
2368
+ {
2369
+ tagName: "span",
2370
+ textContent: "Content types…"
2371
+ }
2372
+ ]
2373
+ }
2374
+ ]
2375
+ }
2376
+ }
2377
+ }
2378
+ ]
2379
+ };
2380
+
2381
+ // src/surfaces/entry-editor.ts
2382
+ registerSurface("entry-editor", entry_editor_default);
2383
+ function project(scope, view) {
2384
+ scope.region = view.region;
2385
+ scope.fieldsRegion = view.fieldsRegion;
2386
+ scope.stage = view.stage;
2387
+ scope.name = view.name;
2388
+ scope.collection = view.collection;
2389
+ scope.draftAxis = view.draftAxis;
2390
+ scope.draft = view.draft;
2391
+ scope.draftHint = view.draftHint;
2392
+ scope.noteState = view.noteState;
2393
+ scope.note = view.note;
2394
+ scope.emptyLine = view.emptyLine;
2395
+ }
2396
+ function partOf(def) {
2397
+ const attributes = def?.attributes;
2398
+ const part = attributes?.["part"];
2399
+ return typeof part === "string" ? part : "";
2400
+ }
2401
+ function mountEntryEditorSurface(host, view, actions, islands) {
2402
+ host.replaceChildren();
2403
+ const scope = reactive({
2404
+ collection: "",
2405
+ draft: false,
2406
+ draftAxis: "hidden",
2407
+ draftHint: "",
2408
+ emptyLine: "",
2409
+ fieldsRegion: "",
2410
+ name: "",
2411
+ note: "",
2412
+ noteState: "hidden",
2413
+ openContentTypes: actions.openContentTypes,
2414
+ region: "",
2415
+ setDraft: actions.setDraft,
2416
+ stage: "empty"
2417
+ });
2418
+ project(scope, view);
2419
+ let mounted = null;
2420
+ let disposed = false;
2421
+ const ready = mountSurface("entry-editor", scope, host, {
2422
+ onNodeCreated: (element, _path, def) => {
2423
+ if (element instanceof HTMLElement && partOf(def) === "fields") {
2424
+ islands.fieldsSlot(element);
2425
+ }
2426
+ }
2427
+ }).then((surface) => {
2428
+ if (disposed) {
2429
+ surface.dispose();
2430
+ return surface.root;
2431
+ }
2432
+ mounted = surface;
2433
+ return surface.root;
2434
+ });
2435
+ return {
2436
+ attached: () => {
2437
+ if (disposed) {
2438
+ return false;
2439
+ }
2440
+ const root = mounted?.root;
2441
+ return root === undefined ? true : root instanceof HTMLElement && host.contains(root);
2442
+ },
2443
+ dispose() {
2444
+ disposed = true;
2445
+ mounted?.dispose();
2446
+ mounted = null;
2447
+ },
2448
+ ready,
2449
+ update: (next) => project(scope, next)
2450
+ };
2451
+ }
2452
+
2453
+ // src/content/entry-fields.ts
2454
+ function fieldsAreDocument(tab) {
2455
+ return tab.doc.sourceFormat == null && tab.doc.mode !== "content";
2456
+ }
2457
+ function entryFields(tab) {
2458
+ return fieldsAreDocument(tab) ? tab.doc.document : tab.doc.content?.frontmatter ?? {};
2459
+ }
2460
+ function mutateDocumentField(tab, field, value) {
2461
+ const doc = tab.doc.document;
2462
+ const before = Object.hasOwn(doc, field) ? cloneValue2(doc[field]) : undefined;
2463
+ const deletes = value === undefined || value === null || value === "";
2464
+ if (deletes) {
2465
+ delete doc[field];
2466
+ } else {
2467
+ doc[field] = value;
2468
+ }
2469
+ const after = deletes ? undefined : cloneValue2(value);
2470
+ recordDocOp({
2471
+ forward: { key: field, op: "set-key", path: [], value: after },
2472
+ inverse: { key: field, op: "set-key", path: [], value: before }
2473
+ });
2474
+ tab.doc.dirty = true;
2475
+ notePreviewOverlayEdit();
2476
+ }
2477
+ function mutateEntryField(tab, field, value) {
2478
+ if (fieldsAreDocument(tab)) {
2479
+ mutateDocumentField(tab, field, value);
2480
+ } else {
2481
+ mutateUpdateFrontmatter(tab, field, value);
2482
+ }
2483
+ }
2484
+ function commitEntryFields(tab, patch) {
2485
+ transactDoc(tab, (t) => {
2486
+ for (const [field, value] of Object.entries(patch)) {
2487
+ mutateEntryField(t, field, value);
2488
+ }
2489
+ });
2490
+ }
2491
+
2492
+ // src/content/entry-editor.ts
2493
+ var ENTRY_MODE = "entry";
2494
+ var ENTRY_TAB_MODES = [ENTRY_MODE];
2495
+ var _active = new Map;
2496
+ function activeIn(paneId) {
2497
+ return _active.get(paneId) ?? null;
2498
+ }
2499
+ function entryPaneMounted(paneId, tab) {
2500
+ const panel = activeIn(paneId);
2501
+ return panel !== null && panel.tabId === tab.id && panel.wrap.isConnected && panel.surface.attached();
2502
+ }
2503
+ function detachEntryPane(paneId) {
2504
+ const panel = _active.get(paneId);
2505
+ if (!panel) {
2506
+ return;
2507
+ }
2508
+ panel.scope.stop();
2509
+ panel.surface.dispose();
2510
+ _active.delete(paneId);
2511
+ }
2512
+ function setEntryDraft(tab, draft) {
2513
+ transactDoc(tab, (t) => mutateEntryField(t, DRAFT_FIELD, draft));
2514
+ }
2515
+ function entryDraftPill(tab) {
2516
+ const collection = collectionOfPath(tab.documentPath);
2517
+ const fields = entryFields(tab);
2518
+ if (!collection || !hasDraftAxis(collection.schema, fields)) {
2519
+ return null;
2520
+ }
2521
+ const draft = isDraftEntry(fields);
2522
+ return {
2523
+ draft,
2524
+ text: draft ? "Draft" : "Published",
2525
+ title: draft ? DRAFT_MEANING : "Not marked a draft."
2526
+ };
2527
+ }
2528
+ function formContext(tab) {
2529
+ return {
2530
+ fieldKeyPrefix: `entry:${tab.id}`,
2531
+ resolvePointer: (pointer, scope) => resolveContextPointer(pointer, {
2532
+ projectConfig: projectState?.projectConfig ?? {},
2533
+ scope
2534
+ })
2535
+ };
2536
+ }
2537
+ function absentRequiredErrors(collection, fields) {
2538
+ const errors = {};
2539
+ for (const field of missingRequired(collection.schema, fields)) {
2540
+ errors[field] = "Required — this entry does not have one.";
2541
+ }
2542
+ return errors;
2543
+ }
2544
+ function emptyLine(tab) {
2545
+ return `${tab.documentPath ?? "This document"} is not an entry of any content collection, so there is no schema to draw a form from.`;
2546
+ }
2547
+ function entryView(paneId, tab, collection) {
2548
+ const region = paneRegion(paneId, "entry");
2549
+ const fieldsRegion = paneRegion(paneId, "entry/fields");
2550
+ if (!collection) {
2551
+ return {
2552
+ collection: "",
2553
+ draft: false,
2554
+ draftAxis: "hidden",
2555
+ draftHint: DRAFT_MEANING,
2556
+ emptyLine: emptyLine(tab),
2557
+ fieldsRegion,
2558
+ name: "",
2559
+ note: "",
2560
+ noteState: "hidden",
2561
+ region,
2562
+ stage: "empty"
2563
+ };
2564
+ }
2565
+ const fields = entryFields(tab);
2566
+ const draft = isDraftEntry(fields);
2567
+ return {
2568
+ collection: collection.name,
2569
+ draft,
2570
+ draftAxis: hasDraftAxis(collection.schema, fields) ? "shown" : "hidden",
2571
+ draftHint: DRAFT_MEANING,
2572
+ emptyLine: "",
2573
+ fieldsRegion,
2574
+ name: tab.documentPath?.split("/").pop() ?? "Untitled",
2575
+ note: DRAFT_MEANING,
2576
+ noteState: draft ? "shown" : "hidden",
2577
+ region,
2578
+ stage: "entry"
2579
+ };
2580
+ }
2581
+ function renderEntryMode(surface, tab) {
2582
+ const { paneId, wrap: canvasWrap } = surface;
2583
+ if (entryPaneMounted(paneId, tab)) {
2584
+ return;
2585
+ }
2586
+ detachEntryPane(paneId);
2587
+ let panel = null;
2588
+ let formHost = null;
2589
+ const redraw = () => {
2590
+ if (panel !== null && activeIn(paneId) === panel) {
2591
+ draw();
2592
+ }
2593
+ };
2594
+ const paintForm = (collection) => {
2595
+ if (!formHost || !collection) {
2596
+ return;
2597
+ }
2598
+ const fields = entryFields(tab);
2599
+ const form = mountSchemaForm(`entry:${paneId}`, collection.schema, fields, {
2600
+ context: formContext(tab),
2601
+ errors: absentRequiredErrors(collection, fields),
2602
+ onChange: (patch) => commitEntryFields(tab, patch),
2603
+ rerender: redraw
2604
+ });
2605
+ if (form.parentNode !== formHost) {
2606
+ formHost.replaceChildren(form);
2607
+ }
2608
+ };
2609
+ const draw = () => {
2610
+ const collection = collectionOfPath(tab.documentPath);
2611
+ if (!collection) {
2612
+ formHost = null;
2613
+ }
2614
+ panel?.surface.update(entryView(paneId, tab, collection));
2615
+ paintForm(collection);
2616
+ };
2617
+ const scope = effectScope();
2618
+ const mounted = mountEntryEditorSurface(canvasWrap, entryView(paneId, tab, collectionOfPath(tab.documentPath)), {
2619
+ openContentTypes: () => {
2620
+ activeRegistry()?.run("settings.open", { section: "content" });
2621
+ },
2622
+ setDraft: (draft) => setEntryDraft(tab, draft)
2623
+ }, {
2624
+ fieldsSlot: (host) => {
2625
+ formHost = host;
2626
+ paintForm(collectionOfPath(tab.documentPath));
2627
+ }
2628
+ });
2629
+ panel = { paneId, scope, surface: mounted, tabId: tab.id, wrap: canvasWrap };
2630
+ _active.set(paneId, panel);
2631
+ scope.run(() => {
2632
+ effect(() => {
2633
+ if (activeIn(paneId) !== panel) {
2634
+ return;
2635
+ }
2636
+ tab.doc.document;
2637
+ tab.doc.content?.frontmatter;
2638
+ projectState?.projectConfig?.content;
2639
+ draw();
2640
+ });
2641
+ });
2642
+ }
2643
+ async function openEntryEditor(path) {
2644
+ const { openFileInTab } = await (__preload("hnxqxtsg"), import("./files-hnxqxtsg.js"));
2645
+ await openFileInTab(path);
2646
+ for (const [id, tab] of workspace2.tabs.entries()) {
2647
+ if (tab.documentPath !== path) {
2648
+ continue;
2649
+ }
2650
+ for (const mode of ENTRY_TAB_MODES) {
2651
+ if (!tab.capabilities.modes.includes(mode)) {
2652
+ tab.capabilities.modes.unshift(mode);
2653
+ }
2654
+ }
2655
+ tab.session.ui.canvasMode = ENTRY_MODE;
2656
+ tab.session.ui.preview = false;
2657
+ activateTab2(id);
2658
+ return tab;
2659
+ }
2660
+ return null;
2661
+ }
2662
+
2663
+ // src/content/entry-commands.ts
2664
+ function creatableCollections() {
2665
+ return entryCollections().map((collection) => collection.name);
2666
+ }
2667
+ async function seedText(collection) {
2668
+ const seed = seedEntry(collection.schema);
2669
+ const formatName = (collection.def.format ? formatByName2(collection.def.format)?.name : undefined) ?? formatForPath2(`untitled${collection.ext}`)?.name ?? defaultContentFormat2()?.name;
2670
+ if (collection.ext === ".json" || formatName === undefined) {
2671
+ return serializeJson(seed, null);
2672
+ }
2673
+ return formatSerialize2(formatName, { ...seed, children: [] }, { frontmatter: Object.keys(seed).length > 0, mode: "roundtrip" });
2674
+ }
2675
+ async function createEntry2(collectionName, opts = {}) {
2676
+ const collection = entryCollection(collectionName);
2677
+ if (!collection) {
2678
+ notify2.error(`No content collection named "${collectionName}" to create an entry in.`, {
2679
+ detail: "A collection needs a `content` entry in project.json whose `source` is a directory. A " + "collection whose source names a single file (a CSV catalogue) has rows, not entry files.",
2680
+ source: "Content"
2681
+ });
2682
+ return null;
2683
+ }
2684
+ await loadFormats2().catch(() => {});
2685
+ let content;
2686
+ try {
2687
+ content = await seedText(collection);
2688
+ } catch (error) {
2689
+ notify2.error(`Could not prepare a new ${collection.name} entry.`, {
2690
+ detail: errorMessage2(error),
2691
+ path: collection.dir,
2692
+ source: "Content"
2693
+ });
2694
+ return null;
2695
+ }
2696
+ const requested = opts.dir;
2697
+ const destination = requested !== undefined && collectionForDirectory(requested)?.name === collection.name ? requested : collection.dir;
2698
+ if (destination.includes(LOCALE_PLACEHOLDER)) {
2699
+ notify2.error(`"${collection.name}" is a localized collection.`, {
2700
+ detail: `Its entries live in one directory per language (${collection.dir}). Open the folder for ` + "the language you are writing in and create the entry there.",
2701
+ path: collection.dir,
2702
+ source: "Content"
2703
+ });
2704
+ return null;
2705
+ }
2706
+ const { createFileIn } = await (__preload("hnxqxtsg"), import("./files-hnxqxtsg.js"));
2707
+ const created = await createFileIn({
2708
+ content,
2709
+ dir: destination,
2710
+ format: { ext: collection.ext, kind: "fixed" },
2711
+ source: "Content",
2712
+ suggestedName: "untitled",
2713
+ title: `New ${collection.name} entry`
2714
+ });
2715
+ if (created === null) {
2716
+ return null;
2717
+ }
2718
+ invalidateReferenceEntries(collection.name);
2719
+ await openEntryEditor(created);
2720
+ return created;
2721
+ }
2722
+ function activeEntryTab() {
2723
+ const tab = activeTab2.value;
2724
+ return tab && collectionOfPath(tab.documentPath) ? tab : null;
2725
+ }
2726
+ function contentCommands() {
2727
+ return [
2728
+ {
2729
+ args: argsSchema({
2730
+ collection: derivedEnumProperty(creatableCollections, "The content collection the entry is created in.")
2731
+ }),
2732
+ category: "File",
2733
+ id: "content.newEntry",
2734
+ level: "project",
2735
+ menus: ["palette"],
2736
+ group: "1_file",
2737
+ requires: "a project with a directory-backed content collection",
2738
+ when: (ctx) => ctx.project.open,
2739
+ enablement: () => creatableCollections().length > 0,
2740
+ undo: "project",
2741
+ run: async (_ctx, args) => {
2742
+ const names = creatableCollections();
2743
+ await createEntry2(enumArg("content.newEntry", args, "collection", names));
2744
+ },
2745
+ title: "New Entry"
2746
+ },
2747
+ {
2748
+ args: argsSchema({
2749
+ path: stringProperty("Project-relative path of the entry file to open.")
2750
+ }),
2751
+ category: "File",
2752
+ id: "content.openEntry",
2753
+ level: "project",
2754
+ menus: ["context/file", "palette"],
2755
+ group: "1_file",
2756
+ requires: "an open project",
2757
+ when: (ctx) => ctx.project.open,
2758
+ run: async (_ctx, args) => {
2759
+ await openEntryEditor(stringArg("content.openEntry", args, "path"));
2760
+ },
2761
+ title: "Open Entry Form"
2762
+ },
2763
+ {
2764
+ args: argsSchema({
2765
+ draft: booleanProperty("True marks the open entry a draft; false marks it published. Written as a `draft` field on the entry.")
2766
+ }),
2767
+ category: "Document",
2768
+ id: "content.setDraft",
2769
+ level: "document",
2770
+ menus: ["context/tab", "palette"],
2771
+ group: "3_document",
2772
+ requires: "a content entry open",
2773
+ when: (ctx) => ctx.document.open,
2774
+ enablement: () => activeEntryTab() !== null,
2775
+ undo: "document",
2776
+ run: (_ctx, args) => {
2777
+ const tab = activeEntryTab();
2778
+ if (!tab) {
2779
+ throw new Error("content.setDraft: the active document is not a content entry");
2780
+ }
2781
+ setEntryDraft(tab, booleanArg("content.setDraft", args, "draft"));
2782
+ },
2783
+ title: "Set Draft"
2784
+ },
2785
+ {
2786
+ args: argsSchema({
2787
+ include: booleanProperty("True lists entries marked `draft: true` alongside the rest.")
2788
+ }),
2789
+ category: "View",
2790
+ id: "content.setIncludeDrafts",
2791
+ level: "project",
2792
+ menus: ["palette"],
2793
+ group: "2_view",
2794
+ requires: "an open project",
2795
+ when: (ctx) => ctx.project.open,
2796
+ run: async (_ctx, args) => {
2797
+ setIncludeDrafts(booleanArg("content.setIncludeDrafts", args, "include"));
2798
+ await reloadDraftAwareGrids2();
2799
+ },
2800
+ title: "Include Drafts"
2801
+ }
2802
+ ];
2803
+ }
2804
+ function registerContentCommands2(registry) {
2805
+ registry.registerAll(contentCommands());
2806
+ }
2807
+
2808
+ export { FIELD_TYPES, FORMAT_OPTIONS, detectFieldType, detectFieldFormat, schemaForType, referenceEntryState, entryFields, entryPaneMounted, detachEntryPane, entryDraftPill, renderEntryMode, createEntry2, registerContentCommands2 };
2809
+
2810
+ //# debugId=BCB2AC86669613BA64756E2164756E21
2811
+ //# sourceMappingURL=studio-b4s9eykd.js.map