@jxsuite/studio 4.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/data/elements-meta.json +5 -15
- package/data/html-meta.json +51 -6
- package/dist/chunks/{2020-xp8vnwma.js → 2020-g79n01v9.js} +14 -14
- package/dist/chunks/action-group-sp6tna8v.js +118 -0
- package/dist/chunks/adapter-nj7tnjfn.js +13 -0
- package/dist/chunks/cf-account-picker-fyf63pmy.js +495 -0
- package/dist/chunks/cf-settings-71bv5zn9.js +20 -0
- package/dist/chunks/color-area-v17df7b8.js +154 -0
- package/dist/chunks/color-field-anwybnkn.js +208 -0
- package/dist/chunks/color-slider-44ez96fc.js +79 -0
- package/dist/chunks/color-xgg3kfw7.js +35 -0
- package/dist/chunks/combobox-5e7jev23.js +236 -0
- package/dist/chunks/components-2w1f35qs.js +18 -0
- package/dist/chunks/content-source-3wqeas45.js +46 -0
- package/dist/chunks/convert-to-repeater-d0cgnb6d.js +639 -0
- package/dist/chunks/dialog-s890b918.js +85 -0
- package/dist/chunks/editor-3qhbg51x.js +35 -0
- package/dist/chunks/entry-commands-d6g50j7s.js +42 -0
- package/dist/chunks/extension-sections-fy7q4fe9.js +651 -0
- package/dist/chunks/file-ops-3btj6st0.js +47 -0
- package/dist/chunks/files-ef8fgs3w.js +72 -0
- package/dist/chunks/format-host-3c33nwr8.js +40 -0
- package/dist/chunks/fs-events-13tj6sex.js +18 -0
- package/dist/chunks/git-panel-4wp2rn9b.js +49 -0
- package/dist/chunks/icons-yy10wk9r.js +402 -0
- package/dist/chunks/iframe-entry-15g3n6xv.js +114 -0
- package/dist/chunks/iframe-entry-b27vq81n.js +203 -0
- package/dist/chunks/iframe-entry-nbyxee1y.js +154 -0
- package/dist/chunks/iframe-host-jgesd924.js +115 -0
- package/dist/chunks/{index-nj44jpzj.js → index-mdmyx6s2.js} +11 -11
- package/dist/chunks/index-n4j7qxyr.js +109 -0
- package/dist/chunks/{javascript-q8kpmfah.js → javascript-xvrfrpkb.js} +8 -9
- package/dist/chunks/{jsonMode-dkr040ga.js → jsonMode-tyx2kj6p.js} +526 -527
- package/dist/chunks/jx-validate-j0wxk72w.js +15 -0
- package/dist/chunks/layers-1nq5evsh.js +29 -0
- package/dist/chunks/layers-panel-ar2gh90g.js +40 -0
- package/dist/chunks/listbox-6v2ac08j.js +44 -0
- package/dist/chunks/lit-html-m244w9nh.js +17 -0
- package/dist/chunks/media-picker-2qbetq73.js +33 -0
- package/dist/chunks/menu-q99sy9rf.js +285 -0
- package/dist/chunks/menu-rf7n72mf.js +14 -0
- package/dist/chunks/{monaco-binding-rj6xpx9y.js → monaco-binding-sw6en4dw.js} +12 -15
- package/dist/chunks/monaco-buffer-bhy3hb6m.js +24 -0
- package/dist/chunks/{monaco-setup-rws7k4br.js → monaco-setup-8r62fj6y.js} +27 -37
- package/dist/chunks/notify-628t0anh.js +21 -0
- package/dist/chunks/number-field-5cndyft8.js +72 -0
- package/dist/chunks/parse-0zx14y15.js +10 -0
- package/dist/chunks/platform-ts9cg1a4.js +15 -0
- package/dist/chunks/popover-47z3ytva.js +25 -0
- package/dist/chunks/publish-panel-98f7sr3g.js +27 -0
- package/dist/chunks/quick-search-srzz83k2.js +45 -0
- package/dist/chunks/references-n553f0e1.js +26 -0
- package/dist/chunks/right-panel-rrgx2dn3.js +45 -0
- package/dist/chunks/section-registry-5pq32t0q.js +25 -0
- package/dist/chunks/select-2r16ez41.js +49 -0
- package/dist/chunks/split-g7nm1rgb.js +191 -0
- package/dist/chunks/studio-0hqbpbd0.js +62 -0
- package/dist/chunks/studio-18avnhjp.js +2430 -0
- package/dist/chunks/{studio-kryvsw6j.js → studio-1k325pwf.js} +48 -48
- package/dist/chunks/{studio-hbtp0eh1.js → studio-25hkdrkw.js} +356 -85
- package/dist/chunks/studio-26d7myd1.js +258 -0
- package/dist/chunks/{studio-p8j86wag.js → studio-38emantv.js} +22 -5
- package/dist/chunks/studio-3gxv60tn.js +422 -0
- package/dist/chunks/{studio-8swrjbny.js → studio-3hxkd92t.js} +275 -163
- package/dist/chunks/studio-4m0haseg.js +185 -0
- package/dist/chunks/{studio-ynxwkrzd.js → studio-4wbb9ct0.js} +1953 -1785
- package/dist/chunks/{studio-gv8vvshc.js → studio-5523bpzt.js} +11 -11
- package/dist/chunks/{studio-5q69gfag.js → studio-57mf66w2.js} +1753 -2484
- package/dist/chunks/studio-5jy81t3s.js +17463 -0
- package/dist/chunks/studio-5rt7sqa0.js +1168 -0
- package/dist/chunks/studio-5te5tqng.js +81 -0
- package/dist/chunks/{studio-p4ngc046.js → studio-6ewqv390.js} +9 -9
- package/dist/chunks/{studio-9ab8gqsm.js → studio-6nzaktvy.js} +7 -7
- package/dist/chunks/studio-6xa21ej9.js +28 -0
- package/dist/chunks/{studio-5ehhackm.js → studio-727xh0e3.js} +19 -19
- package/dist/chunks/{studio-eenfkt4e.js → studio-79y5sz51.js} +52 -38
- package/dist/chunks/{studio-4q0wznzf.js → studio-7e11jpa9.js} +461 -145
- package/dist/chunks/{studio-q7v10cg2.js → studio-7r42c6ca.js} +17 -7
- package/dist/chunks/studio-7xptrg0j.js +954 -0
- package/dist/chunks/{studio-cft9r4r7.js → studio-81390n6f.js} +22 -22
- package/dist/chunks/{studio-q43a5y9h.js → studio-8jn5yhyn.js} +16 -16
- package/dist/chunks/studio-8qtrpzr3.js +839 -0
- package/dist/chunks/{studio-dg7zyt5x.js → studio-98b3z07n.js} +1 -1
- package/dist/chunks/studio-9xxz1q69.js +1356 -0
- package/dist/chunks/studio-akbww0j5.js +13615 -0
- package/dist/chunks/studio-arfpe389.js +195 -0
- package/dist/chunks/{studio-2zkz8evn.js → studio-az3zd49t.js} +473 -281
- package/dist/chunks/studio-cpvb2ed1.js +1171 -0
- package/dist/chunks/{studio-9r6j5ev1.js → studio-d0300636.js} +5078 -19
- package/dist/chunks/{studio-bgxt93ga.js → studio-d055c37e.js} +13 -13
- package/dist/chunks/studio-d1ja2x9r.js +362 -0
- package/dist/chunks/{studio-b9b6t1dg.js → studio-e1f24eff.js} +5664 -5666
- package/dist/chunks/{studio-4pqqxbrt.js → studio-em9nw8eh.js} +301 -112
- package/dist/chunks/studio-erdatzvp.js +1190 -0
- package/dist/chunks/{studio-g1wdche0.js → studio-esrxgwh6.js} +80 -80
- package/dist/chunks/studio-fabxk6r9.js +2811 -0
- package/dist/chunks/{studio-3n4ndrzh.js → studio-h4nvnjvz.js} +303 -303
- package/dist/chunks/studio-hhvs4sdg.js +195 -0
- package/dist/chunks/{studio-68n67094.js → studio-kcgff4r0.js} +15 -18
- package/dist/chunks/{studio-685s0ytq.js → studio-nqgawfks.js} +572 -572
- package/dist/chunks/{studio-xrapxwwc.js → studio-p1dw8wfw.js} +55 -29
- package/dist/chunks/studio-pm6hgy7r.js +4763 -0
- package/dist/chunks/studio-q0a3yk4n.js +33 -0
- package/dist/chunks/{studio-wcy8trfx.js → studio-q3x06vmj.js} +23 -22
- package/dist/chunks/studio-qahxvnan.js +111 -0
- package/dist/chunks/{studio-53n8bp04.js → studio-r6xmmtfh.js} +1 -1
- package/dist/chunks/{studio-kjjsjak4.js → studio-rkstz940.js} +3661 -6136
- package/dist/chunks/{studio-tvgyw9xw.js → studio-rnyf3f8e.js} +83 -250
- package/dist/chunks/studio-rpyah2ew.js +2805 -0
- package/dist/chunks/studio-rs76k67r.js +12 -0
- package/dist/chunks/{studio-yxrkyv8a.js → studio-s6z853aq.js} +12108 -11766
- package/dist/chunks/{studio-sf7zjgv1.js → studio-sgdc5pfc.js} +8 -8
- package/dist/chunks/studio-tb3ev01j.js +763 -0
- package/dist/chunks/{studio-t5wqwzdh.js → studio-tjjk7jvk.js} +1 -1
- package/dist/chunks/studio-vhv5tgxm.js +51 -0
- package/dist/chunks/{studio-htsf0w6m.js → studio-vz68yn9e.js} +31 -154
- package/dist/chunks/studio-wqpngpsk.js +174 -0
- package/dist/chunks/{studio-eesa1myv.js → studio-x3rty6tr.js} +58 -58
- package/dist/chunks/studio-xsykpvsh.js +8448 -0
- package/dist/chunks/{studio-92ab2jqe.js → studio-y9zedyjn.js} +14 -14
- package/dist/chunks/studio-yxa81f45.js +12 -0
- package/dist/chunks/swatch-group-t0n6h2rn.js +139 -0
- package/dist/chunks/tabs-wbp1cdws.js +156 -0
- package/dist/chunks/textfield-abk6qyee.js +73 -0
- package/dist/chunks/toast-780pvfbv.js +27 -0
- package/dist/chunks/toast-host-3sqv46sn.js +116 -0
- package/dist/chunks/toolbar-xbh5bhtr.js +194 -0
- package/dist/chunks/tooltip-eptb614w.js +369 -0
- package/dist/chunks/tree-a73p0pqm.js +367 -0
- package/dist/chunks/{tsMode-76kr53q0.js → tsMode-jy4m86rv.js} +83 -85
- package/dist/chunks/workspace-wrew8zk4.js +69 -0
- package/dist/chunks/{ws-client-6shc5rze.js → ws-client-ny4zc51r.js} +20 -22
- package/dist/iframe-entry.js +1812 -698
- package/dist/manifest.json +7 -0
- package/dist/studio.js +52900 -36573
- package/dist/workers/editor.worker.js +1040 -1085
- package/dist/workers/json.worker.js +1946 -1991
- package/dist/workers/ts.worker.js +4960 -5005
- package/favicon.ico +0 -0
- package/index.html +2 -0
- package/package.json +22 -55
- package/src/about/about-modal.ts +73 -123
- package/src/browse/library-commands.ts +20 -49
- package/src/browse/library-layouts.ts +87 -218
- package/src/browse/library-pane.ts +406 -438
- package/src/canvas/canvas-helpers.ts +0 -49
- package/src/canvas/canvas-live-render.ts +25 -2
- package/src/canvas/canvas-render.ts +666 -231
- package/src/canvas/canvas-surface.ts +0 -1
- package/src/canvas/canvas-utils.ts +310 -117
- package/src/canvas/dialog-path.ts +76 -0
- package/src/canvas/dialog-state.ts +67 -0
- package/src/canvas/diff-marks.ts +252 -0
- package/src/canvas/diff-toolbar.ts +349 -0
- package/src/canvas/diff-view.ts +123 -0
- package/src/canvas/edit-width-drag.ts +187 -0
- package/src/canvas/edit-width.ts +150 -0
- package/src/canvas/iframe-entry.ts +125 -8
- package/src/canvas/iframe-host.ts +271 -15
- package/src/canvas/iframe-interaction.ts +133 -13
- package/src/canvas/iframe-patch.ts +7 -1
- package/src/canvas/iframe-position.ts +5 -6
- package/src/canvas/iframe-protocol.ts +106 -5
- package/src/canvas/iframe-render.ts +373 -5
- package/src/canvas/iframe-slash.ts +2 -2
- package/src/canvas/iframe-subtree.ts +5 -8
- package/src/canvas/path-mapping.ts +25 -3
- package/src/canvas/popover-path.ts +106 -0
- package/src/canvas/popover-state.ts +155 -0
- package/src/canvas/surface-registry.ts +21 -10
- package/src/collab/presence-chips.ts +51 -73
- package/src/commands/app-commands.ts +10 -0
- package/src/commands/budget.ts +12 -0
- package/src/commands/command-args.ts +369 -6
- package/src/commands/defaults.ts +44 -14
- package/src/commands/live-context.ts +11 -5
- package/src/commands/reference.ts +12 -2
- package/src/commands/registry.ts +165 -8
- package/src/content/entry-commands.ts +16 -23
- package/src/content/entry-editor.ts +144 -101
- package/src/editor/canvas-slash-bridge.ts +2 -2
- package/src/editor/context-menu.ts +49 -200
- package/src/editor/convert-to-component.ts +42 -82
- package/src/editor/convert-to-repeater.ts +132 -173
- package/src/editor/inline-edit.ts +11 -0
- package/src/editor/shortcuts.ts +65 -26
- package/src/editor/slash-menu.ts +150 -157
- package/src/files/file-ops.ts +117 -11
- package/src/files/files.ts +949 -664
- package/src/files/json-layout.ts +474 -0
- package/src/files/media-paths.ts +13 -42
- package/src/files/media-usage.ts +41 -131
- package/src/files/serialize-document.ts +8 -1
- package/src/format/convert-file.ts +16 -10
- package/src/format/format-host.ts +50 -1
- package/src/github/github-auth.ts +71 -29
- package/src/github/github-publish.ts +57 -65
- package/src/grid/cell-editors.ts +46 -4
- package/src/grid/cell-popovers.ts +65 -62
- package/src/grid/grid-open.ts +86 -64
- package/src/grid/grid-panel.ts +390 -469
- package/src/grid/redirects-grid.ts +40 -44
- package/src/hosting/document.ts +2 -0
- package/src/hosting/layout.ts +10 -0
- package/src/i18n/i18n-commands.ts +127 -62
- package/src/media/media-pane.ts +83 -133
- package/src/new-project/add-repo-modal.ts +125 -176
- package/src/new-project/import-tab.ts +201 -250
- package/src/new-project/location-fields.ts +101 -165
- package/src/new-project/new-project-modal.ts +376 -367
- package/src/packages/jxsuite-update.ts +76 -18
- package/src/panels/activity-panel.ts +137 -104
- package/src/panels/ai-chat/chat-markdown.ts +15 -13
- package/src/panels/ai-chat/chat-view.ts +307 -472
- package/src/panels/ai-chat/composer.ts +175 -153
- package/src/panels/ai-chat/sessions-view.ts +31 -62
- package/src/panels/ai-panel.ts +210 -185
- package/src/panels/block-action-bar.ts +437 -643
- package/src/panels/bottom-dock.ts +112 -47
- package/src/panels/chat-panel.ts +19 -14
- package/src/panels/data-explorer.ts +141 -102
- package/src/panels/data-grid.ts +183 -150
- package/src/panels/dnd.ts +75 -20
- package/src/panels/editors.ts +26 -19
- package/src/panels/elements-panel.ts +243 -186
- package/src/panels/empty-state.ts +26 -42
- package/src/panels/events-panel.ts +950 -729
- package/src/panels/formula-workspace.ts +434 -207
- package/src/panels/frontmatter-fields.ts +185 -153
- package/src/panels/frontmatter-panel.ts +411 -187
- package/src/panels/git-diff-open.ts +148 -0
- package/src/panels/git-panel.ts +679 -605
- package/src/panels/head-panel.ts +617 -435
- package/src/panels/i18n-panel.ts +153 -133
- package/src/panels/imports-panel.ts +388 -414
- package/src/panels/jump-bar.ts +174 -147
- package/src/panels/layers-panel.ts +785 -671
- package/src/panels/left-panel.ts +166 -94
- package/src/panels/navigator-panels.ts +1 -1
- package/src/panels/pane-context.ts +529 -677
- package/src/panels/pane-grid.ts +265 -241
- package/src/panels/panel-registry.ts +15 -4
- package/src/panels/problems-panel.ts +177 -99
- package/src/panels/properties-panel.ts +1525 -966
- package/src/panels/provenance.ts +31 -113
- package/src/panels/quick-search.ts +217 -172
- package/src/panels/right-panel.ts +135 -169
- package/src/panels/seo-modal.ts +346 -167
- package/src/panels/settings-menu.ts +109 -646
- package/src/panels/settings-pane.ts +102 -86
- package/src/panels/signals-panel.ts +1318 -1172
- package/src/panels/statement-editor.ts +556 -428
- package/src/panels/style-panel.ts +1367 -630
- package/src/panels/style-utils.ts +36 -32
- package/src/panels/stylebook-doc.ts +30 -73
- package/src/panels/stylebook-layers-panel.ts +202 -109
- package/src/panels/stylebook-panel.ts +124 -88
- package/src/panels/tab-strip.ts +385 -287
- package/src/platforms/cloud.ts +347 -86
- package/src/platforms/devserver.ts +13 -0
- package/src/publish/deploy-checklist.ts +124 -78
- package/src/publish/publish-commands.ts +4 -12
- package/src/publish/publish-panel.ts +165 -299
- package/src/services/a11y-report.ts +100 -43
- package/src/services/ai-command-tools.ts +468 -0
- package/src/services/ai-import-tools.ts +50 -12
- package/src/services/ai-models.ts +108 -1
- package/src/services/ai-session-store.ts +6 -0
- package/src/services/ai-system-prompt.ts +110 -18
- package/src/services/ai-tools.ts +28 -143
- package/src/services/ai-write-report.ts +174 -0
- package/src/services/context-manager.ts +12 -1
- package/src/services/document-assistant.ts +50 -2
- package/src/services/idle.ts +16 -14
- package/src/services/live-surfaces.ts +237 -0
- package/src/services/model-uri.ts +75 -0
- package/src/services/notify.ts +63 -6
- package/src/services/popover-report.ts +325 -0
- package/src/services/surface-registry.ts +56 -0
- package/src/services/tool-executor.ts +17 -0
- package/src/settings/contexts-section.ts +301 -299
- package/src/settings/contributed-section.ts +361 -222
- package/src/settings/css-vars-editor.ts +320 -325
- package/src/settings/defs-editor.ts +572 -535
- package/src/settings/dependencies-editor.ts +79 -107
- package/src/settings/extension-commands.ts +379 -0
- package/src/settings/extension-rows.ts +113 -0
- package/src/settings/extensions-section.ts +287 -0
- package/src/settings/general-settings.ts +130 -181
- package/src/settings/head-editor.ts +10 -305
- package/src/settings/locales-section.ts +146 -196
- package/src/settings/preferences-accounts.ts +193 -12
- package/src/settings/preferences-dialog.ts +384 -307
- package/src/settings/project-sections.ts +108 -181
- package/src/settings/schema-field-ui.ts +11 -399
- package/src/settings/section-registry.ts +8 -1
- package/src/settings/settings-document.ts +31 -29
- package/src/shell/tree.ts +42 -87
- package/src/shell.ts +48 -36
- package/src/studio.ts +90 -67
- package/src/style/token-ref.ts +0 -39
- package/src/surfaces/about.json +263 -0
- package/src/surfaces/about.ts +163 -0
- package/src/surfaces/add-repo.json +486 -0
- package/src/surfaces/add-repo.ts +236 -0
- package/src/surfaces/ai-chat.json +2185 -0
- package/src/surfaces/ai-chat.ts +549 -0
- package/src/surfaces/ai-credentials-form.json +332 -0
- package/src/surfaces/ai-credentials-form.ts +151 -0
- package/src/surfaces/ai-managed-connect.json +108 -0
- package/src/surfaces/ai-managed-connect.ts +123 -0
- package/src/surfaces/ai-model-picker.json +114 -0
- package/src/surfaces/ai-model-picker.ts +139 -0
- package/src/surfaces/block-action-bar.json +640 -0
- package/src/surfaces/block-action-bar.ts +368 -0
- package/src/surfaces/bottom-dock.json +154 -0
- package/src/surfaces/bottom-dock.ts +125 -0
- package/src/surfaces/canvas-stage.json +444 -0
- package/src/surfaces/canvas-stage.ts +253 -0
- package/src/surfaces/cf-account-picker.json +300 -0
- package/src/surfaces/cf-account-picker.ts +214 -0
- package/src/surfaces/commandbar.json +984 -0
- package/src/{panels/toolbar.ts → surfaces/commandbar.ts} +414 -389
- package/src/surfaces/convert-repeater.json +309 -0
- package/src/surfaces/convert-repeater.ts +276 -0
- package/src/surfaces/data-actions.json +157 -0
- package/src/surfaces/data-actions.ts +115 -0
- package/src/surfaces/dialog.json +289 -0
- package/src/surfaces/dialog.ts +343 -0
- package/src/surfaces/diff-toolbar.json +266 -0
- package/src/surfaces/diff-toolbar.ts +139 -0
- package/src/surfaces/doc-header.json +739 -0
- package/src/surfaces/doc-header.ts +223 -0
- package/src/surfaces/empty-state.json +152 -0
- package/src/surfaces/empty-state.ts +173 -0
- package/src/surfaces/entry-editor.json +281 -0
- package/src/surfaces/entry-editor.ts +191 -0
- package/src/surfaces/expression-editor.json +977 -0
- package/src/surfaces/expression-editor.ts +266 -0
- package/src/surfaces/files-panel.json +592 -0
- package/src/surfaces/files-panel.ts +301 -0
- package/src/surfaces/formula-palette.json +364 -0
- package/src/surfaces/formula-palette.ts +340 -0
- package/src/surfaces/git-panel.json +1822 -0
- package/src/surfaces/git-panel.ts +272 -0
- package/src/surfaces/github-auth.json +112 -0
- package/src/surfaces/github-auth.ts +139 -0
- package/src/surfaces/github-publish.json +206 -0
- package/src/surfaces/github-publish.ts +169 -0
- package/src/surfaces/grid-cell.json +218 -0
- package/src/surfaces/grid-cell.ts +120 -0
- package/src/surfaces/grid-open.json +147 -0
- package/src/surfaces/grid-open.ts +87 -0
- package/src/surfaces/grid-panel.json +706 -0
- package/src/surfaces/grid-panel.ts +206 -0
- package/src/surfaces/grid-replace.json +179 -0
- package/src/surfaces/grid-replace.ts +89 -0
- package/src/surfaces/grid-views.json +446 -0
- package/src/surfaces/grid-views.ts +172 -0
- package/src/surfaces/inspector-dock.json +187 -0
- package/src/surfaces/inspector-dock.ts +161 -0
- package/src/surfaces/jump-bar.json +243 -0
- package/src/surfaces/jump-bar.ts +129 -0
- package/src/surfaces/jxsuite-update.json +146 -0
- package/src/surfaces/jxsuite-update.ts +149 -0
- package/src/surfaces/library-pane.json +1509 -0
- package/src/surfaces/library-pane.ts +363 -0
- package/src/surfaces/logic-panel.json +1949 -0
- package/src/surfaces/logic-panel.ts +369 -0
- package/src/surfaces/logic-workspace.json +685 -0
- package/src/surfaces/logic-workspace.ts +238 -0
- package/src/surfaces/media-browser.json +303 -0
- package/src/surfaces/media-browser.ts +145 -0
- package/src/surfaces/media-field.json +163 -0
- package/src/surfaces/media-field.ts +116 -0
- package/src/surfaces/media-pane.json +513 -0
- package/src/surfaces/media-pane.ts +197 -0
- package/src/surfaces/menu.json +232 -0
- package/src/surfaces/menu.ts +375 -0
- package/src/surfaces/navigator-dock.json +113 -0
- package/src/surfaces/navigator-dock.ts +130 -0
- package/src/surfaces/new-project.json +1654 -0
- package/src/surfaces/new-project.ts +411 -0
- package/src/surfaces/palette.json +535 -0
- package/src/surfaces/pane-context.json +1497 -0
- package/src/surfaces/pane-context.ts +513 -0
- package/src/surfaces/pane-grid.json +188 -0
- package/src/surfaces/pane-grid.ts +250 -0
- package/src/surfaces/panel-activity.json +563 -0
- package/src/surfaces/panel-activity.ts +187 -0
- package/src/surfaces/panel-data.json +141 -0
- package/src/surfaces/panel-data.ts +156 -0
- package/src/surfaces/panel-deploy-checklist.json +283 -0
- package/src/surfaces/panel-deploy-checklist.ts +175 -0
- package/src/surfaces/panel-elements.json +367 -0
- package/src/surfaces/panel-elements.ts +175 -0
- package/src/surfaces/panel-i18n.json +569 -0
- package/src/surfaces/panel-i18n.ts +212 -0
- package/src/surfaces/panel-imports.json +780 -0
- package/src/surfaces/panel-imports.ts +209 -0
- package/src/surfaces/panel-outline.json +734 -0
- package/src/surfaces/panel-outline.ts +326 -0
- package/src/surfaces/panel-page.json +1017 -0
- package/src/surfaces/panel-page.ts +240 -0
- package/src/surfaces/panel-problems.json +497 -0
- package/src/surfaces/panel-problems.ts +157 -0
- package/src/surfaces/panel-signals.json +1973 -0
- package/src/surfaces/panel-signals.ts +436 -0
- package/src/surfaces/panel-stylebook-layers.json +317 -0
- package/src/surfaces/panel-stylebook-layers.ts +155 -0
- package/src/surfaces/preferences.json +850 -0
- package/src/surfaces/preferences.ts +332 -0
- package/src/surfaces/progress-modal.json +110 -0
- package/src/surfaces/progress-modal.ts +150 -0
- package/src/surfaces/properties-panel.json +1578 -0
- package/src/surfaces/properties-panel.ts +337 -0
- package/src/surfaces/publish.json +945 -0
- package/src/surfaces/publish.ts +392 -0
- package/src/surfaces/push-plan.json +110 -0
- package/src/surfaces/push-plan.ts +87 -0
- package/src/surfaces/rail.json +255 -0
- package/src/surfaces/rail.ts +206 -0
- package/src/surfaces/reference-field.json +191 -0
- package/src/surfaces/reference-field.ts +168 -0
- package/src/surfaces/schema-builder.json +1011 -0
- package/src/surfaces/schema-builder.ts +181 -0
- package/src/surfaces/schema-form.json +1013 -0
- package/src/surfaces/schema-form.ts +287 -0
- package/src/surfaces/secret-field.json +60 -0
- package/src/surfaces/secret-field.ts +146 -0
- package/src/surfaces/seo.json +932 -0
- package/src/surfaces/seo.ts +334 -0
- package/src/surfaces/settings-contexts.json +538 -0
- package/src/surfaces/settings-contexts.ts +196 -0
- package/src/surfaces/settings-contributed.json +489 -0
- package/src/surfaces/settings-contributed.ts +199 -0
- package/src/surfaces/settings-css-vars.json +820 -0
- package/src/surfaces/settings-css-vars.ts +199 -0
- package/src/surfaces/settings-defs.json +1363 -0
- package/src/surfaces/settings-defs.ts +232 -0
- package/src/surfaces/settings-deploy.json +108 -0
- package/src/surfaces/settings-deploy.ts +135 -0
- package/src/surfaces/settings-extensions.json +486 -0
- package/src/surfaces/settings-extensions.ts +201 -0
- package/src/surfaces/settings-head.json +779 -0
- package/src/surfaces/settings-head.ts +397 -0
- package/src/surfaces/settings-locales.json +420 -0
- package/src/surfaces/settings-locales.ts +137 -0
- package/src/surfaces/settings-overview.json +423 -0
- package/src/surfaces/settings-overview.ts +218 -0
- package/src/surfaces/settings-packages.json +549 -0
- package/src/surfaces/settings-packages.ts +158 -0
- package/src/surfaces/settings-pane.json +147 -0
- package/src/surfaces/settings-pane.ts +150 -0
- package/src/surfaces/settings-rawjson.json +104 -0
- package/src/surfaces/settings-rawjson.ts +107 -0
- package/src/surfaces/shell.json +99 -0
- package/src/surfaces/shell.ts +30 -0
- package/src/surfaces/slash-menu.json +180 -0
- package/src/surfaces/slash-menu.ts +272 -0
- package/src/surfaces/statements.json +607 -0
- package/src/surfaces/statements.ts +238 -0
- package/src/surfaces/statusbar.json +94 -0
- package/src/{panels → surfaces}/statusbar.ts +163 -90
- package/src/surfaces/style-panel.json +1643 -0
- package/src/surfaces/style-panel.ts +338 -0
- package/src/surfaces/stylebook-chrome.json +122 -0
- package/src/surfaces/stylebook-chrome.ts +122 -0
- package/src/surfaces/tab-strip.json +448 -0
- package/src/surfaces/tab-strip.ts +200 -0
- package/src/surfaces/target-line.json +419 -0
- package/src/surfaces/target-line.ts +349 -0
- package/src/surfaces/toasts.json +189 -0
- package/src/surfaces/welcome.json +571 -0
- package/src/surfaces/welcome.ts +338 -0
- package/src/tabs/project-config.ts +71 -15
- package/src/tabs/tab.ts +52 -1
- package/src/types.ts +49 -3
- package/src/ui/ai-credentials-form.ts +104 -100
- package/src/ui/ai-managed-connect.ts +116 -49
- package/src/ui/ai-model-picker.ts +102 -47
- package/src/ui/cf-account-picker.ts +135 -0
- package/src/ui/color-selector.ts +80 -301
- package/src/ui/dynamic-slot.ts +43 -283
- package/src/ui/expression-editor.ts +797 -576
- package/src/ui/field-input.ts +8 -181
- package/src/ui/form-controls.ts +838 -366
- package/src/ui/formula-chips.ts +80 -85
- package/src/ui/kit.ts +33 -0
- package/src/ui/layers.ts +293 -593
- package/src/ui/media-picker.ts +203 -284
- package/src/ui/panel-resize.ts +251 -64
- package/src/ui/popover-surface.ts +153 -0
- package/src/ui/progress-modal.ts +22 -60
- package/src/ui/regions.ts +13 -7
- package/src/ui/schema-form.ts +906 -440
- package/src/ui/surface.ts +122 -0
- package/src/ui/unit-selector.ts +15 -131
- package/src/ui/value-source.ts +14 -0
- package/src/ui/virtual-window.ts +88 -9
- package/src/utils/canvas-media.ts +72 -0
- package/src/utils/edit-display.ts +7 -2
- package/src/utils/element-selectors.ts +69 -0
- package/src/utils/link-target.ts +2 -2
- package/src/utils/studio-utils.ts +0 -10
- package/src/view.ts +15 -0
- package/src/workspace/pane-derive.ts +36 -14
- package/src/workspace/workspace.ts +15 -6
- package/styles/canvas.css +72 -467
- package/styles/forced-colors.css +48 -82
- package/styles/forced-colors.json +41 -0
- package/styles/inspector.css +2 -1301
- package/styles/overlays.css +96 -2823
- package/styles/panels.css +6 -1423
- package/styles/shell-frame.css +272 -0
- package/styles/shell-frame.json +227 -0
- package/styles/shell.css +0 -1532
- package/styles/tokens.css +65 -136
- package/styles/tokens.json +84 -0
- package/dist/chunks/Overlay.dev-723bv0df.js +0 -23
- package/dist/chunks/adapter-jkcyhgtr.js +0 -14
- package/dist/chunks/cf-settings-45fgyx8y.js +0 -21
- package/dist/chunks/components-zmx10t62.js +0 -21
- package/dist/chunks/content-source-t88vb2dr.js +0 -49
- package/dist/chunks/convert-to-repeater-dhw1nrz9.js +0 -268
- package/dist/chunks/editor-cptq5jp1.js +0 -37
- package/dist/chunks/entry-commands-6z6bhxg0.js +0 -46
- package/dist/chunks/extension-sections-3ydgjbdy.js +0 -311
- package/dist/chunks/file-ops-rskmhxyq.js +0 -48
- package/dist/chunks/files-0cratsr0.js +0 -92
- package/dist/chunks/flow-qbfgrpeh.js +0 -634
- package/dist/chunks/focus-trap.esm-ggawf1hy.js +0 -1024
- package/dist/chunks/focus-visible-6eg70z18.js +0 -167
- package/dist/chunks/format-host-tgcmfs4p.js +0 -43
- package/dist/chunks/fs-events-hrrg328g.js +0 -21
- package/dist/chunks/git-panel-0yywyk76.js +0 -58
- package/dist/chunks/index-zqxmqxmh.js +0 -109
- package/dist/chunks/jx-validate-8q2g05x1.js +0 -19
- package/dist/chunks/layers-panel-z3tqe5cd.js +0 -67
- package/dist/chunks/layers-q75tj2mf.js +0 -45
- package/dist/chunks/lit-html-j055mkh8.js +0 -22
- package/dist/chunks/monaco-buffer-dqw0xxpx.js +0 -25
- package/dist/chunks/notify-yjm79n4s.js +0 -30
- package/dist/chunks/parse-24d0gay3.js +0 -19
- package/dist/chunks/platform-ba1j1gbh.js +0 -16
- package/dist/chunks/publish-panel-54jvhskq.js +0 -28
- package/dist/chunks/quick-search-cgfmjwq5.js +0 -65
- package/dist/chunks/references-3qx8fkyp.js +0 -29
- package/dist/chunks/right-panel-cqp8bc4v.js +0 -46
- package/dist/chunks/section-registry-sx1ykvkw.js +0 -30
- package/dist/chunks/sp-overlay.dev-yztmtrs1.js +0 -18
- package/dist/chunks/sp-popover.dev-n2etmqdp.js +0 -9
- package/dist/chunks/sp-progress-circle.dev-hryhj0es.js +0 -15
- package/dist/chunks/sp-tooltip.dev-xcvpnqr0.js +0 -15
- package/dist/chunks/sp-tray.dev-tkbscm06.js +0 -199
- package/dist/chunks/studio-0a5qrh01.js +0 -3
- package/dist/chunks/studio-18j3bmcz.js +0 -14
- package/dist/chunks/studio-1hbqnt19.js +0 -1823
- package/dist/chunks/studio-4rzyrtjz.js +0 -426
- package/dist/chunks/studio-5rywrkxz.js +0 -1903
- package/dist/chunks/studio-7afd21nw.js +0 -67
- package/dist/chunks/studio-7nte2hj4.js +0 -613
- package/dist/chunks/studio-8jpzqk5s.js +0 -128
- package/dist/chunks/studio-8q517dfr.js +0 -24
- package/dist/chunks/studio-9c4k4vhv.js +0 -357
- package/dist/chunks/studio-9n4mrmnb.js +0 -184
- package/dist/chunks/studio-a0tswy0w.js +0 -58
- package/dist/chunks/studio-ahjfdy6e.js +0 -387
- package/dist/chunks/studio-ahnzd9rg.js +0 -23
- package/dist/chunks/studio-bw5dz6km.js +0 -608
- package/dist/chunks/studio-cb12yz9w.js +0 -15055
- package/dist/chunks/studio-d1ks410h.js +0 -175
- package/dist/chunks/studio-eqq1w638.js +0 -113
- package/dist/chunks/studio-ex8zyp98.js +0 -1813
- package/dist/chunks/studio-h4rxscfc.js +0 -10
- package/dist/chunks/studio-kyh9avvv.js +0 -28
- package/dist/chunks/studio-kyk2v92a.js +0 -659
- package/dist/chunks/studio-m3hwn7y1.js +0 -120
- package/dist/chunks/studio-mmv72a27.js +0 -4344
- package/dist/chunks/studio-n8b9wqwy.js +0 -291
- package/dist/chunks/studio-pdfjntbk.js +0 -6939
- package/dist/chunks/studio-qq6jym04.js +0 -53
- package/dist/chunks/studio-r1r7afxx.js +0 -1066
- package/dist/chunks/studio-rdx8jcxy.js +0 -83
- package/dist/chunks/studio-rn9ta2mz.js +0 -111
- package/dist/chunks/studio-t7qb9db8.js +0 -665
- package/dist/chunks/studio-tmc5emrw.js +0 -8
- package/dist/chunks/studio-txwkm6p9.js +0 -12
- package/dist/chunks/studio-v38hmvx1.js +0 -390
- package/dist/chunks/studio-vadzgkrz.js +0 -318
- package/dist/chunks/studio-wx5609xd.js +0 -341
- package/dist/chunks/studio-z6nw2ek2.js +0 -18
- package/dist/chunks/studio-zczps70q.js +0 -378
- package/dist/chunks/workspace-xpres40v.js +0 -89
- package/src/panels/activity-bar.ts +0 -251
- package/src/panels/panel-scheduler.ts +0 -219
- package/src/panels/style-inputs.ts +0 -237
- package/src/panels/target-line.ts +0 -274
- package/src/panels/welcome-screen.ts +0 -346
- package/src/ui/button-group.ts +0 -102
- package/src/ui/choice-field.ts +0 -72
- package/src/ui/field-row.ts +0 -249
- package/src/ui/formula-palette.ts +0 -213
- package/src/ui/icons.ts +0 -52
- package/src/ui/jx-theme.ts +0 -130
- package/src/ui/spectrum.ts +0 -340
- package/src/ui/value-selector.ts +0 -174
- package/src/ui/widgets.ts +0 -172
- /package/dist/chunks/{javascript-s56a8dpk.css → javascript-4abzjcy9.css} +0 -0
- /package/dist/chunks/{jsonMode-zr9sw0c7.css → jsonMode-vvmpmk34.css} +0 -0
- /package/dist/chunks/{monaco-setup-pav68602.css → monaco-setup-8vbyqnhr.css} +0 -0
- /package/dist/chunks/{tsMode-ef187txx.css → tsMode-hnxxb73h.css} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference lib="dom" />
|
|
2
2
|
/**
|
|
3
|
-
* The Logic tab — everything about how this element BEHAVES.
|
|
3
|
+
* The Logic tab — everything about how this element BEHAVES. The FLOW behind the `logic-panel`
|
|
4
|
+
* surface.
|
|
4
5
|
*
|
|
5
6
|
* Plan §6.5 re-split the inspector by task rather than by data type, and this is the tab that
|
|
6
7
|
* gained by it. Wiring a `$switch`, wiring a repeater to a collection and wiring a click handler
|
|
@@ -13,19 +14,36 @@
|
|
|
13
14
|
* - **Events** — declared events, bindings, inline bodies, expressions.
|
|
14
15
|
* - **Observed Attributes · CSS Properties · CSS Parts** — a custom element's outward contract.
|
|
15
16
|
*
|
|
16
|
-
* The
|
|
17
|
-
*
|
|
17
|
+
* **The markup left.** It is `surfaces/logic-panel.json`, mounted by `surfaces/logic-panel.ts`, and
|
|
18
|
+
* what is here is the part that was never markup: what the selection is, which rungs a position
|
|
19
|
+
* permits, what a handler holds, which elements of a multi-selection disagree about a key, and what
|
|
20
|
+
* a gesture writes.
|
|
18
21
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
22
|
+
* **This tab does not go through the Inspector's scheduler.** `panels/panel-scheduler.ts` defers a
|
|
23
|
+
* repaint while focus is inside the dock, because a lit re-render would take the node a reader is
|
|
24
|
+
* typing into. A document does not have that problem — one runtime effect per bound property, and
|
|
25
|
+
* an equal write is skipped — so the tab watches the facts it draws and re-projects, and
|
|
26
|
+
* `right-panel.ts` leaves its container alone exactly as it leaves the assistant's.
|
|
27
|
+
*
|
|
28
|
+
* Three things the conversion settled, and each was a defect rather than a translation:
|
|
29
|
+
*
|
|
30
|
+
* - **A binding had two controls that did the same thing.** The provenance chip cleared the key and
|
|
31
|
+
* the trash button beside it cleared the same key. §12.5 calls a second list of actions a defect;
|
|
32
|
+
* there is one control now, and it carries the dot that says whether the selection agrees.
|
|
33
|
+
* - **The sections would not stay shut.** Repeating list, Condition and Events were rendered with a
|
|
34
|
+
* hard-coded `open`, so collapsing one lasted until the next repaint. They persist through
|
|
35
|
+
* `inspectorSections` like every other section in the dock.
|
|
36
|
+
* - **The event NAME is free-form without being a bespoke combobox.** It was a `jx-value-selector` —
|
|
37
|
+
* a LitElement over Spectrum, dual-mode, with its own popover — for a field that needs a short
|
|
38
|
+
* list of suggestions and the ability to refuse none of them. It is the kit's menu plus the one
|
|
39
|
+
* prompt dialog Studio already has.
|
|
40
|
+
*
|
|
41
|
+
* @docs studio/logic/events
|
|
21
42
|
*/
|
|
22
43
|
|
|
23
44
|
import { getNodeAtPath, renderOnly } from "../store";
|
|
24
|
-
import { html, nothing } from "lit-html";
|
|
25
|
-
import { live } from "lit-html/directives/live.js";
|
|
26
45
|
import { activeTab } from "../workspace/workspace";
|
|
27
46
|
import { primarySelection, unifyValues } from "../tabs/selection";
|
|
28
|
-
import { renderProvenanceChip } from "./provenance";
|
|
29
47
|
import {
|
|
30
48
|
mutateAddDef,
|
|
31
49
|
mutateAddSwitchCase,
|
|
@@ -34,15 +52,23 @@ import {
|
|
|
34
52
|
mutateUpdateProperty,
|
|
35
53
|
transactDoc,
|
|
36
54
|
} from "../tabs/transact";
|
|
37
|
-
import { clickAnythingTo,
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
55
|
+
import { clickAnythingTo, openPageAction, staleSelectionMessage } from "./empty-state";
|
|
56
|
+
import { mountExpressionEditor } from "../ui/expression-editor";
|
|
57
|
+
import { mountStatementEditor } from "./statement-editor";
|
|
40
58
|
import { inspectorStatementsRegion } from "../ui/regions";
|
|
41
59
|
import { livePreviewExpression } from "../services/live-preview";
|
|
42
|
-
import {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
import {
|
|
61
|
+
effectiveSlotMode,
|
|
62
|
+
hasStashedSlotValue,
|
|
63
|
+
slotModeSeed,
|
|
64
|
+
stashSlotValue,
|
|
65
|
+
switchSlotMode,
|
|
66
|
+
} from "../ui/dynamic-slot";
|
|
67
|
+
import { VALUE_SOURCE_LABELS, capsForPosition, slotCaps, slotMode } from "../ui/value-source";
|
|
68
|
+
import { cloneValue } from "../tabs/doc-op-apply";
|
|
69
|
+
import { openMenu } from "../surfaces/menu";
|
|
70
|
+
import { showPromptDialog } from "../ui/layers";
|
|
71
|
+
import { effect, effectScope } from "../reactivity";
|
|
46
72
|
import {
|
|
47
73
|
bindableSignalNames,
|
|
48
74
|
defaultAsString,
|
|
@@ -50,8 +76,9 @@ import {
|
|
|
50
76
|
mapSignalsFor,
|
|
51
77
|
setInspectorSection,
|
|
52
78
|
} from "./properties-panel";
|
|
53
|
-
import { collectCssParts } from "./signals-panel";
|
|
79
|
+
import { collectCssParts, isCustomElementDoc } from "./signals-panel";
|
|
54
80
|
import { openLogicTarget } from "./formula-workspace";
|
|
81
|
+
import { emptyLogicView, mountLogicSurface } from "../surfaces/logic-panel";
|
|
55
82
|
import {
|
|
56
83
|
getEventBinding,
|
|
57
84
|
isExpressionDef,
|
|
@@ -60,9 +87,19 @@ import {
|
|
|
60
87
|
isRef,
|
|
61
88
|
} from "@jxsuite/schema/guards";
|
|
62
89
|
|
|
90
|
+
import type {
|
|
91
|
+
LogicBindingView,
|
|
92
|
+
LogicBodyKind,
|
|
93
|
+
LogicEmptyAction,
|
|
94
|
+
LogicFieldView,
|
|
95
|
+
LogicOption,
|
|
96
|
+
LogicSurface,
|
|
97
|
+
LogicView,
|
|
98
|
+
} from "../surfaces/logic-panel";
|
|
63
99
|
import type { JsonValue } from "../types";
|
|
64
|
-
import type {
|
|
65
|
-
import type {
|
|
100
|
+
import type { EffectScope } from "@vue/reactivity";
|
|
101
|
+
import type { SignalOption } from "../ui/dynamic-slot";
|
|
102
|
+
import type { SlotCapsSource, SlotMode } from "../ui/value-source";
|
|
66
103
|
import type { JxPath } from "../state";
|
|
67
104
|
import type {
|
|
68
105
|
CemEvent,
|
|
@@ -70,6 +107,7 @@ import type {
|
|
|
70
107
|
JxFunctionDef,
|
|
71
108
|
JxMutableNode,
|
|
72
109
|
JxPrototypeDef,
|
|
110
|
+
JxStatement,
|
|
73
111
|
} from "@jxsuite/schema/types";
|
|
74
112
|
|
|
75
113
|
/**
|
|
@@ -77,9 +115,8 @@ import type {
|
|
|
77
115
|
*
|
|
78
116
|
* These ten were a closed `sp-picker`, so `ondragover`, `onpointerdown`, `onwheel`, `onpaste` and
|
|
79
117
|
* every custom event a component emits were unbindable from the Inspector: the plan's §6.5 asks for
|
|
80
|
-
* "a free-form combobox instead of a hard-coded list of ten", and
|
|
81
|
-
*
|
|
82
|
-
* field stop being a list of ten"). The widget was written and never wired.
|
|
118
|
+
* "a free-form combobox instead of a hard-coded list of ten". The list is still ten, and it is a
|
|
119
|
+
* list of SUGGESTIONS now — the menu's last row asks for any other name.
|
|
83
120
|
*/
|
|
84
121
|
export const EVENT_NAMES = [
|
|
85
122
|
"onclick",
|
|
@@ -94,18 +131,8 @@ export const EVENT_NAMES = [
|
|
|
94
131
|
"onmouseleave",
|
|
95
132
|
];
|
|
96
133
|
|
|
97
|
-
/**
|
|
98
|
-
|
|
99
|
-
const seen = new Set<string>();
|
|
100
|
-
const out: { label: string; value: string }[] = [];
|
|
101
|
-
for (const name of [...declared, ...EVENT_NAMES]) {
|
|
102
|
-
if (!seen.has(name)) {
|
|
103
|
-
seen.add(name);
|
|
104
|
-
out.push({ label: name, value: name });
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
134
|
+
/** A name this element may bind. Anything matching is accepted; the menu only suggests. */
|
|
135
|
+
const EVENT_NAME_PATTERN = /^on[a-z][\da-z-]*$/i;
|
|
109
136
|
|
|
110
137
|
/**
|
|
111
138
|
* The rungs an `on*` handler permits, derived from the schema (`RefObject | ExpressionEntry |
|
|
@@ -129,215 +156,8 @@ function seedForHandlerMode(mode: SlotMode, functionDefs: [string, unknown][]):
|
|
|
129
156
|
return firstFn ? { $ref: `#/state/${firstFn[0]}` } : { $ref: "" };
|
|
130
157
|
}
|
|
131
158
|
|
|
132
|
-
// ─── The
|
|
133
|
-
|
|
134
|
-
/** Arguments for {@link bindableFieldRow}. */
|
|
135
|
-
interface BindableRowOpts {
|
|
136
|
-
/** The `data-prop` key — what `inspector/field:<prop>` addresses. */
|
|
137
|
-
prop: string;
|
|
138
|
-
label: string;
|
|
139
|
-
/** The raw document value: a JSON literal, `{ $ref }`, a `${}` template or an `$expression`. */
|
|
140
|
-
rawValue: unknown;
|
|
141
|
-
onChange: (v?: JsonValue) => void;
|
|
142
|
-
/** Removes the position outright. Absent means the position is mandatory and cannot be cleared. */
|
|
143
|
-
onClear?: (() => void) | undefined;
|
|
144
|
-
/** Extra signals this position may bind to — `$map/item` and friends inside a template. */
|
|
145
|
-
extraSignals?: SignalOption[] | null;
|
|
146
|
-
/** Stable identity for the dynamic slot's per-mode value memory; must include the node path. */
|
|
147
|
-
fieldKey: string;
|
|
148
|
-
/** The document position being edited — the rungs follow from its schema, never from here. */
|
|
149
|
-
caps: SlotCapsSource;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* A bindable value as a first-class field row.
|
|
154
|
-
*
|
|
155
|
-
* This used to render a bare `<div class="field-row">` with a label and a widget: no set-dot, no
|
|
156
|
-
* clear affordance, no error slot — the three things every other row in the inspector has had since
|
|
157
|
-
* `renderFieldRow` landed. Repeater and Switch fields were the last second-class rows in the
|
|
158
|
-
* inspector, which is exactly what §12 P5 item 6 names.
|
|
159
|
-
*
|
|
160
|
-
* Every position it serves is a single-line expression (a collection, a filter, a sort key, a
|
|
161
|
-
* `$switch`), so it draws one literal editor rather than dispatching over a widget type — the
|
|
162
|
-
* textarea and checkbox arms it used to carry had no caller in either tab.
|
|
163
|
-
*/
|
|
164
|
-
function bindableFieldRow({
|
|
165
|
-
prop,
|
|
166
|
-
label,
|
|
167
|
-
rawValue,
|
|
168
|
-
onChange,
|
|
169
|
-
onClear,
|
|
170
|
-
extraSignals = null,
|
|
171
|
-
fieldKey,
|
|
172
|
-
caps,
|
|
173
|
-
}: BindableRowOpts) {
|
|
174
|
-
const defs = activeTab.value!.doc.document.state || {};
|
|
175
|
-
const boundRef = isRef(rawValue) ? rawValue.$ref : null;
|
|
176
|
-
const staticVal = slotMode(rawValue) === "literal" ? (rawValue ?? "") : "";
|
|
177
|
-
|
|
178
|
-
// De-escalating to literal restores the bound signal's declared default (old unbind behavior).
|
|
179
|
-
const literalDefault = boundRef
|
|
180
|
-
? defaultAsString(defs[boundRef.startsWith("#/state/") ? boundRef.slice(8) : boundRef]) ||
|
|
181
|
-
undefined
|
|
182
|
-
: undefined;
|
|
183
|
-
|
|
184
|
-
const slot = renderDynamicSlot({
|
|
185
|
-
caps,
|
|
186
|
-
extraSignals,
|
|
187
|
-
fieldKey,
|
|
188
|
-
literalDefault,
|
|
189
|
-
onChange,
|
|
190
|
-
staticWidget: spTextField(`prop:${label}`, String(staticVal), (v: string) => onChange(v)),
|
|
191
|
-
stateDefs: bindableSignalNames(activeTab.value!.doc.document),
|
|
192
|
-
value: rawValue,
|
|
193
|
-
});
|
|
194
|
-
return renderFieldRow({
|
|
195
|
-
hasValue: rawValue !== undefined && rawValue !== "",
|
|
196
|
-
label,
|
|
197
|
-
labelExtra: slot.modeButton,
|
|
198
|
-
prop,
|
|
199
|
-
widget: slot.widget,
|
|
200
|
-
...(onClear ? { onClear } : {}),
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// ─── Repeating list ──────────────────────────────────────────────────────────
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* The repeater's items / filter / sort, and the way into its template.
|
|
208
|
-
*
|
|
209
|
-
* Filter and Sort are always drawn. They used to hide behind `+ Add filter`, which seeded `{ $ref:
|
|
210
|
-
* "#/state/" }` — a binding to the empty pointer, which is not a signal — so the row opened already
|
|
211
|
-
* bound to nothing and the only way to type a literal was to cycle the mode ring twice (§11.4).
|
|
212
|
-
* There is no seed to fix, because a repeater has exactly three inputs and an empty row states that
|
|
213
|
-
* better than a button does: type into it and it is set, clear it and it is gone.
|
|
214
|
-
*/
|
|
215
|
-
function renderRepeaterFieldsTemplate(node: JxMutableNode, path: JxPath) {
|
|
216
|
-
const key = path.join("/");
|
|
217
|
-
const clear = (name: string) => () =>
|
|
218
|
-
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, name));
|
|
219
|
-
const optional = (name: "filter" | "sort", label: string) =>
|
|
220
|
-
bindableFieldRow({
|
|
221
|
-
caps: name === "filter" ? "repeaterFilter" : "repeaterSort",
|
|
222
|
-
fieldKey: `prop|${key}|${name}`,
|
|
223
|
-
label,
|
|
224
|
-
onChange: (v?: JsonValue) =>
|
|
225
|
-
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, name, v || undefined)),
|
|
226
|
-
onClear: clear(name),
|
|
227
|
-
prop: name,
|
|
228
|
-
rawValue: node[name],
|
|
229
|
-
});
|
|
230
|
-
return html`
|
|
231
|
-
${bindableFieldRow({
|
|
232
|
-
caps: "repeaterItems",
|
|
233
|
-
fieldKey: `prop|${key}|items`,
|
|
234
|
-
label: "Items",
|
|
235
|
-
onChange: (v?: JsonValue) =>
|
|
236
|
-
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, "items", v)),
|
|
237
|
-
prop: "items",
|
|
238
|
-
rawValue: node.items,
|
|
239
|
-
})}
|
|
240
|
-
${optional("filter", "Filter")} ${optional("sort", "Sort")}
|
|
241
|
-
${
|
|
242
|
-
node.map
|
|
243
|
-
? html`
|
|
244
|
-
<sp-action-button
|
|
245
|
-
size="s"
|
|
246
|
-
class="logic-edit-template"
|
|
247
|
-
@click=${() => {
|
|
248
|
-
activeTab.value!.session.selection = [[...path, "map"]];
|
|
249
|
-
}}
|
|
250
|
-
>Edit template →</sp-action-button
|
|
251
|
-
>
|
|
252
|
-
`
|
|
253
|
-
: nothing
|
|
254
|
-
}
|
|
255
|
-
`;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// ─── Condition ───────────────────────────────────────────────────────────────
|
|
259
|
-
|
|
260
|
-
/** The `$switch` expression and its cases — each case a field row like every other. */
|
|
261
|
-
function renderSwitchFieldsTemplate(
|
|
262
|
-
node: JxMutableNode,
|
|
263
|
-
path: JxPath,
|
|
264
|
-
mapSignals: SignalOption[] | null,
|
|
265
|
-
) {
|
|
266
|
-
const caseNames = Object.keys(node.cases || {});
|
|
267
|
-
return html`
|
|
268
|
-
${bindableFieldRow({
|
|
269
|
-
// `SwitchDef` is a $ref and nothing else, so From data… is the only rung — a $switch is
|
|
270
|
-
// Inherently dynamic, and de-escalating it would delete the key and demote the node.
|
|
271
|
-
caps: "switchDiscriminant",
|
|
272
|
-
extraSignals: mapSignals,
|
|
273
|
-
fieldKey: `prop|${path.join("/")}|$switch`,
|
|
274
|
-
label: "Expression",
|
|
275
|
-
onChange: (v?: JsonValue) =>
|
|
276
|
-
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, "$switch", v)),
|
|
277
|
-
prop: "$switch",
|
|
278
|
-
rawValue: node.$switch,
|
|
279
|
-
})}
|
|
280
|
-
<div class="logic-subhead">Cases</div>
|
|
281
|
-
${caseNames.map((caseName) => {
|
|
282
|
-
let debounce: ReturnType<typeof setTimeout> | undefined;
|
|
283
|
-
return renderFieldRow({
|
|
284
|
-
hasValue: true,
|
|
285
|
-
label: "Case",
|
|
286
|
-
prop: `case:${caseName}`,
|
|
287
|
-
provenance: {
|
|
288
|
-
onClick: () =>
|
|
289
|
-
transactDoc(activeTab.value!, (t) => mutateRemoveSwitchCase(t, path, caseName)),
|
|
290
|
-
state: "set",
|
|
291
|
-
title: `Remove case "${caseName}"`,
|
|
292
|
-
},
|
|
293
|
-
widget: html`
|
|
294
|
-
<div class="logic-case-row">
|
|
295
|
-
<sp-textfield
|
|
296
|
-
size="s"
|
|
297
|
-
class="logic-case-name"
|
|
298
|
-
.value=${live(caseName)}
|
|
299
|
-
@input=${(e: Event) => {
|
|
300
|
-
clearTimeout(debounce);
|
|
301
|
-
const next = (e.target as HTMLInputElement).value;
|
|
302
|
-
debounce = setTimeout(() => {
|
|
303
|
-
if (next && next !== caseName) {
|
|
304
|
-
transactDoc(activeTab.value, (t) =>
|
|
305
|
-
mutateRenameSwitchCase(t, path, caseName, next),
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
}, 500);
|
|
309
|
-
}}
|
|
310
|
-
></sp-textfield>
|
|
311
|
-
<sp-action-button
|
|
312
|
-
size="xs"
|
|
313
|
-
quiet
|
|
314
|
-
class="logic-case-open"
|
|
315
|
-
title="Edit case"
|
|
316
|
-
@click=${(e: Event) => {
|
|
317
|
-
e.stopPropagation();
|
|
318
|
-
activeTab.value!.session.selection = [[...path, "cases", caseName]];
|
|
319
|
-
}}
|
|
320
|
-
>→</sp-action-button
|
|
321
|
-
>
|
|
322
|
-
</div>
|
|
323
|
-
`,
|
|
324
|
-
});
|
|
325
|
-
})}
|
|
326
|
-
<span
|
|
327
|
-
class="kv-add"
|
|
328
|
-
@click=${() => {
|
|
329
|
-
transactDoc(activeTab.value, (t) =>
|
|
330
|
-
mutateAddSwitchCase(t, path, `case${caseNames.length + 1}`),
|
|
331
|
-
);
|
|
332
|
-
}}
|
|
333
|
-
>+ Add case</span
|
|
334
|
-
>
|
|
335
|
-
`;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// ─── Events ──────────────────────────────────────────────────────────────────
|
|
159
|
+
// ─── The Mixed contract ──────────────────────────────────────────────────────
|
|
339
160
|
|
|
340
|
-
/** The event bindings themselves — declared events, then one block per bound `on*` key. */
|
|
341
161
|
/**
|
|
342
162
|
* The Logic tab's Mixed contract (§6.5), stated once because it is a judgement, not a mechanism.
|
|
343
163
|
*
|
|
@@ -352,8 +172,8 @@ function renderSwitchFieldsTemplate(
|
|
|
352
172
|
* keystroke into six different bodies would destroy five of them, and showing one body while
|
|
353
173
|
* claiming to edit six is the lie the Mixed chip exists to prevent.
|
|
354
174
|
*
|
|
355
|
-
* So the row
|
|
356
|
-
*
|
|
175
|
+
* So the row's dot reads `mixed` when the selected elements disagree about a key — including when
|
|
176
|
+
* some of them do not bind it at all — and the body below it stays what it always was: the
|
|
357
177
|
* primary's, edited alone.
|
|
358
178
|
*
|
|
359
179
|
* @param {readonly JxPath[]} targets
|
|
@@ -387,520 +207,921 @@ function mixedEventCount(doc: JxMutableNode, targets: readonly JxPath[], evKey:
|
|
|
387
207
|
return unifyValues(values).mixed ? targets.length : 0;
|
|
388
208
|
}
|
|
389
209
|
|
|
390
|
-
|
|
391
|
-
node: JxMutableNode,
|
|
392
|
-
selection: JxPath,
|
|
393
|
-
isCustomElement: boolean,
|
|
394
|
-
targets: readonly JxPath[] = [selection],
|
|
395
|
-
) {
|
|
396
|
-
const tab = activeTab.value!;
|
|
397
|
-
const defs = tab.doc.document.state || {};
|
|
398
|
-
const functionDefs = Object.entries(defs).filter(
|
|
399
|
-
([, d]) =>
|
|
400
|
-
(d as JxPrototypeDef)?.$prototype === "Function" || (d as Record<string, unknown>)?.$handler,
|
|
401
|
-
);
|
|
210
|
+
// ─── The projection's plans ──────────────────────────────────────────────────
|
|
402
211
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
${allEmits.map(
|
|
419
|
-
(ev) => html`
|
|
420
|
-
<div class="declared-event-row" title=${ev.description || ""}>
|
|
421
|
-
<code class="event-code">${ev.name || "(unnamed)"}</code>
|
|
422
|
-
<span class="event-source">← ${ev._fn}</span>
|
|
423
|
-
${
|
|
424
|
-
isJsonObject(ev.type) && typeof ev.type.text === "string"
|
|
425
|
-
? html`<span class="event-type">${ev.type.text}</span>`
|
|
426
|
-
: nothing
|
|
427
|
-
}
|
|
428
|
-
</div>
|
|
429
|
-
`,
|
|
430
|
-
)}
|
|
431
|
-
</div>
|
|
432
|
-
<sp-divider size="s"></sp-divider>
|
|
433
|
-
`;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
212
|
+
/** Everything a bindable row needs, on the flow's side of the seam. */
|
|
213
|
+
interface FieldPlan {
|
|
214
|
+
label: string;
|
|
215
|
+
caps: SlotCapsSource;
|
|
216
|
+
value: unknown;
|
|
217
|
+
mode: SlotMode;
|
|
218
|
+
offered: SlotMode[];
|
|
219
|
+
onChange: (v?: JsonValue) => void;
|
|
220
|
+
onClear?: (() => void) | undefined;
|
|
221
|
+
extraSignals: SignalOption[] | null;
|
|
222
|
+
literalDefault: JsonValue | undefined;
|
|
223
|
+
stateDefs: readonly string[];
|
|
224
|
+
/** Fills the row's control host when the active rung is a formula. */
|
|
225
|
+
paint?: (host: HTMLElement) => void;
|
|
226
|
+
}
|
|
436
227
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
${declaredEventsT}
|
|
447
|
-
<div class="events-section">
|
|
448
|
-
${
|
|
449
|
-
eventEntries.length > 0
|
|
450
|
-
? html` <sp-field-label size="s">Event Bindings</sp-field-label> `
|
|
451
|
-
: nothing
|
|
452
|
-
}
|
|
453
|
-
${eventEntries.map(([evKey, evVal]) => {
|
|
454
|
-
const inlineFn: JxFunctionDef | null = isFunctionDef(evVal) ? evVal : null;
|
|
455
|
-
const expression = isExpressionDef(evVal) ? evVal.$expression : null;
|
|
456
|
-
const refValue = isRef(evVal) ? evVal.$ref : null;
|
|
457
|
-
const currentMode = slotMode(evVal);
|
|
458
|
-
const modeFieldKey = `event|${selection.join("/")}|${evKey}`;
|
|
459
|
-
return html`
|
|
460
|
-
<div class="event-binding">
|
|
461
|
-
<div class="event-row">
|
|
462
|
-
<jx-value-selector
|
|
463
|
-
size="s"
|
|
464
|
-
class="event-name"
|
|
465
|
-
.value=${evKey}
|
|
466
|
-
.options=${eventNameOptions(Object.keys(node).filter((k) => k.startsWith("on")))}
|
|
467
|
-
@change=${(e: Event) => {
|
|
468
|
-
const newKey = (e.target as HTMLInputElement).value.trim();
|
|
469
|
-
// A NAME, not a menu choice: the field is free-form now, so it has to refuse
|
|
470
|
-
// What it cannot bind rather than trusting a list it no longer constrains.
|
|
471
|
-
if (newKey && newKey !== evKey && /^on[a-z][\da-z-]*$/i.test(newKey)) {
|
|
472
|
-
// Renaming the key moves the binding on every selected element, in one step.
|
|
473
|
-
transactDoc(activeTab.value, (t) => {
|
|
474
|
-
for (const target of targets) {
|
|
475
|
-
const existing = getEventBinding(
|
|
476
|
-
getNodeAtPath(t.doc.document, target) as JxMutableNode,
|
|
477
|
-
evKey,
|
|
478
|
-
);
|
|
479
|
-
if (existing === undefined) {
|
|
480
|
-
continue;
|
|
481
|
-
}
|
|
482
|
-
mutateUpdateProperty(t, target, evKey);
|
|
483
|
-
mutateUpdateProperty(t, target, newKey, existing as JsonValue);
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
}}
|
|
488
|
-
>
|
|
489
|
-
></jx-value-selector
|
|
490
|
-
>
|
|
491
|
-
<sp-picker
|
|
492
|
-
size="s"
|
|
493
|
-
class="event-mode"
|
|
494
|
-
.value=${live(currentMode)}
|
|
495
|
-
@change=${(e: Event) => {
|
|
496
|
-
const next = (e.target as HTMLInputElement).value as SlotMode;
|
|
497
|
-
/* The same ladder the inspector's rows offer, remembering the representation
|
|
498
|
-
it left: switching to Formula and back used to throw the handler body away. */
|
|
499
|
-
commitToTargets(
|
|
500
|
-
targets,
|
|
501
|
-
evKey,
|
|
502
|
-
switchSlotMode(
|
|
503
|
-
modeFieldKey,
|
|
504
|
-
currentMode,
|
|
505
|
-
next,
|
|
506
|
-
evVal as JsonValue,
|
|
507
|
-
seedForHandlerMode(next, functionDefs),
|
|
508
|
-
) ?? seedForHandlerMode(next, functionDefs),
|
|
509
|
-
);
|
|
510
|
-
}}
|
|
511
|
-
>
|
|
512
|
-
${HANDLER_MODES.map(
|
|
513
|
-
(m) => html`<sp-menu-item value=${m}>${VALUE_SOURCE_LABELS[m]}</sp-menu-item>`,
|
|
514
|
-
)}
|
|
515
|
-
</sp-picker>
|
|
516
|
-
${renderProvenanceChip(evKey, {
|
|
517
|
-
state: mixedEventCount(tab.doc.document, targets, evKey) > 0 ? "mixed" : "set",
|
|
518
|
-
donor: String(targets.length),
|
|
519
|
-
onClick: () => commitToTargets(targets, evKey),
|
|
520
|
-
title:
|
|
521
|
-
mixedEventCount(tab.doc.document, targets, evKey) > 0
|
|
522
|
-
? `${targets.length} selected elements bind ${evKey} differently — ` +
|
|
523
|
-
`clearing removes it from all of them`
|
|
524
|
-
: `Clear ${evKey}`,
|
|
525
|
-
})}
|
|
526
|
-
<sp-action-button size="xs" quiet @click=${() => commitToTargets(targets, evKey)}>
|
|
527
|
-
<sp-icon-delete slot="icon"></sp-icon-delete>
|
|
528
|
-
</sp-action-button>
|
|
529
|
-
</div>
|
|
530
|
-
${
|
|
531
|
-
inlineFn
|
|
532
|
-
? html`
|
|
533
|
-
<div class="event-body-mode" style="display:flex;justify-content:flex-end">
|
|
534
|
-
<sp-action-group size="s" compact class="body-mode-toggle">
|
|
535
|
-
<sp-action-button
|
|
536
|
-
size="s"
|
|
537
|
-
class="body-mode-statements"
|
|
538
|
-
?selected=${Array.isArray(inlineFn.body)}
|
|
539
|
-
@click=${() => {
|
|
540
|
-
if (!Array.isArray(inlineFn.body)) {
|
|
541
|
-
transactDoc(activeTab.value, (t) =>
|
|
542
|
-
mutateUpdateProperty(t, selection, evKey, {
|
|
543
|
-
...inlineFn,
|
|
544
|
-
body: [],
|
|
545
|
-
}),
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
}}
|
|
549
|
-
>
|
|
550
|
-
Statements
|
|
551
|
-
</sp-action-button>
|
|
552
|
-
<sp-action-button
|
|
553
|
-
size="s"
|
|
554
|
-
class="body-mode-code"
|
|
555
|
-
?selected=${!Array.isArray(inlineFn.body)}
|
|
556
|
-
@click=${() => {
|
|
557
|
-
if (Array.isArray(inlineFn.body)) {
|
|
558
|
-
transactDoc(activeTab.value, (t) =>
|
|
559
|
-
mutateUpdateProperty(t, selection, evKey, {
|
|
560
|
-
...inlineFn,
|
|
561
|
-
body: "",
|
|
562
|
-
}),
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
}}
|
|
566
|
-
>
|
|
567
|
-
Code
|
|
568
|
-
</sp-action-button>
|
|
569
|
-
</sp-action-group>
|
|
570
|
-
</div>
|
|
571
|
-
${
|
|
572
|
-
Array.isArray(inlineFn.body)
|
|
573
|
-
? renderStatementEditor(
|
|
574
|
-
inlineFn.body,
|
|
575
|
-
(next) =>
|
|
576
|
-
transactDoc(activeTab.value, (t) =>
|
|
577
|
-
mutateUpdateProperty(t, selection, evKey, {
|
|
578
|
-
...inlineFn,
|
|
579
|
-
body: next,
|
|
580
|
-
}),
|
|
581
|
-
),
|
|
582
|
-
{
|
|
583
|
-
allowEventRef: true,
|
|
584
|
-
emits: inlineFn.emits ?? [],
|
|
585
|
-
// The Inspector's copy, named by the handler it edits. It answered
|
|
586
|
-
// To `navigator/statements` until the docks were split, and then
|
|
587
|
-
// To a bare `inspector/statements` — which this `.map` stamps once
|
|
588
|
-
// Per structured handler, so two handlers on a node made two
|
|
589
|
-
// Elements answer to it and `resolveRegion` took the second.
|
|
590
|
-
region: inspectorStatementsRegion(evKey),
|
|
591
|
-
stateDefs: Object.keys(defs),
|
|
592
|
-
stateEntries: defs,
|
|
593
|
-
},
|
|
594
|
-
)
|
|
595
|
-
: html`
|
|
596
|
-
<div class="event-body-row">
|
|
597
|
-
<sp-textfield
|
|
598
|
-
size="s"
|
|
599
|
-
multiline
|
|
600
|
-
grows
|
|
601
|
-
placeholder="// handler body"
|
|
602
|
-
.value=${live(typeof inlineFn.body === "string" ? inlineFn.body : "")}
|
|
603
|
-
@input=${(e: Event) => {
|
|
604
|
-
transactDoc(activeTab.value, (t) =>
|
|
605
|
-
mutateUpdateProperty(t, selection, evKey, {
|
|
606
|
-
$prototype: "Function",
|
|
607
|
-
body: (e.target as HTMLInputElement).value,
|
|
608
|
-
parameters: inlineFn?.parameters || [],
|
|
609
|
-
}),
|
|
610
|
-
);
|
|
611
|
-
}}
|
|
612
|
-
>
|
|
613
|
-
</sp-textfield>
|
|
614
|
-
<sp-action-button
|
|
615
|
-
size="xs"
|
|
616
|
-
quiet
|
|
617
|
-
title="Open in editor"
|
|
618
|
-
@click=${() => {
|
|
619
|
-
openLogicTarget({
|
|
620
|
-
editing: { eventKey: evKey, path: selection, type: "event" },
|
|
621
|
-
surface: "function",
|
|
622
|
-
});
|
|
623
|
-
}}
|
|
624
|
-
>
|
|
625
|
-
<sp-icon-code slot="icon"></sp-icon-code>
|
|
626
|
-
</sp-action-button>
|
|
627
|
-
</div>
|
|
628
|
-
`
|
|
629
|
-
}
|
|
630
|
-
`
|
|
631
|
-
: expression
|
|
632
|
-
? html`
|
|
633
|
-
<div class="event-body-row">
|
|
634
|
-
<div style="flex:1;min-width:0">
|
|
635
|
-
${renderExpressionEditor(
|
|
636
|
-
expression,
|
|
637
|
-
(newNode: unknown) =>
|
|
638
|
-
transactDoc(activeTab.value, (t) =>
|
|
639
|
-
mutateUpdateProperty(t, selection, evKey, {
|
|
640
|
-
$expression: newNode,
|
|
641
|
-
}),
|
|
642
|
-
),
|
|
643
|
-
{
|
|
644
|
-
allowEventRef: true,
|
|
645
|
-
// Live-context evaluation in the canvas iframe, snapshot fallback
|
|
646
|
-
// (M6). The selection path is the context, so a binding inside a
|
|
647
|
-
// Repeater template previews with the first item's $map scope.
|
|
648
|
-
preview: livePreviewExpression(
|
|
649
|
-
tab,
|
|
650
|
-
`event:${JSON.stringify(selection)}:${evKey}`,
|
|
651
|
-
expression,
|
|
652
|
-
selection,
|
|
653
|
-
() => renderOnly("rightPanel"),
|
|
654
|
-
),
|
|
655
|
-
onInsertDef: (defName, def) =>
|
|
656
|
-
transactDoc(activeTab.value, (t) =>
|
|
657
|
-
mutateAddDef(t, defName, def as Record<string, JsonValue>),
|
|
658
|
-
),
|
|
659
|
-
stateDefs: Object.keys(defs),
|
|
660
|
-
stateEntries: defs,
|
|
661
|
-
},
|
|
662
|
-
)}
|
|
663
|
-
</div>
|
|
664
|
-
<sp-action-button
|
|
665
|
-
size="xs"
|
|
666
|
-
quiet
|
|
667
|
-
title="Open in formula workspace"
|
|
668
|
-
@click=${() => {
|
|
669
|
-
openLogicTarget({
|
|
670
|
-
editing: { eventKey: evKey, path: selection, type: "event" },
|
|
671
|
-
surface: "formula",
|
|
672
|
-
});
|
|
673
|
-
}}
|
|
674
|
-
>
|
|
675
|
-
<sp-icon-align-bottom slot="icon"></sp-icon-align-bottom>
|
|
676
|
-
</sp-action-button>
|
|
677
|
-
</div>
|
|
678
|
-
`
|
|
679
|
-
: html`
|
|
680
|
-
<sp-picker
|
|
681
|
-
size="s"
|
|
682
|
-
class="event-handler"
|
|
683
|
-
.value=${live(refValue || "__none__")}
|
|
684
|
-
@change=${(e: Event) => {
|
|
685
|
-
if (
|
|
686
|
-
(e.target as HTMLInputElement).value &&
|
|
687
|
-
(e.target as HTMLInputElement).value !== "__none__"
|
|
688
|
-
) {
|
|
689
|
-
transactDoc(activeTab.value, (t) =>
|
|
690
|
-
mutateUpdateProperty(t, selection, evKey, {
|
|
691
|
-
$ref: (e.target as HTMLInputElement).value,
|
|
692
|
-
}),
|
|
693
|
-
);
|
|
694
|
-
} else {
|
|
695
|
-
transactDoc(activeTab.value, (t) =>
|
|
696
|
-
mutateUpdateProperty(t, selection, evKey),
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
}}
|
|
700
|
-
>
|
|
701
|
-
<sp-menu-item value="__none__">— none —</sp-menu-item>
|
|
702
|
-
${functionDefs.map(
|
|
703
|
-
([fName]) =>
|
|
704
|
-
html`<sp-menu-item value=${`#/state/${fName}`}
|
|
705
|
-
>${fName}</sp-menu-item
|
|
706
|
-
>`,
|
|
707
|
-
)}
|
|
708
|
-
</sp-picker>
|
|
709
|
-
`
|
|
710
|
-
}
|
|
711
|
-
</div>
|
|
712
|
-
`;
|
|
713
|
-
})}
|
|
714
|
-
<sp-action-button
|
|
715
|
-
size="s"
|
|
716
|
-
quiet
|
|
717
|
-
@click=${() => {
|
|
718
|
-
let evName = "onclick";
|
|
719
|
-
for (const name of EVENT_NAMES) {
|
|
720
|
-
if (!node[name]) {
|
|
721
|
-
evName = name;
|
|
722
|
-
break;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
if (functionDefs.length > 0) {
|
|
726
|
-
transactDoc(activeTab.value, (t) =>
|
|
727
|
-
mutateUpdateProperty(t, selection, evName, {
|
|
728
|
-
$ref: `#/state/${functionDefs[0]![0]}`,
|
|
729
|
-
}),
|
|
730
|
-
);
|
|
731
|
-
} else {
|
|
732
|
-
transactDoc(activeTab.value, (t) =>
|
|
733
|
-
mutateUpdateProperty(t, selection, evName, {
|
|
734
|
-
$prototype: "Function",
|
|
735
|
-
body: "",
|
|
736
|
-
parameters: [],
|
|
737
|
-
}),
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
}}
|
|
741
|
-
>
|
|
742
|
-
<sp-icon-add slot="icon"></sp-icon-add>
|
|
743
|
-
Add Event
|
|
744
|
-
</sp-action-button>
|
|
745
|
-
</div>
|
|
746
|
-
</div>
|
|
747
|
-
`;
|
|
228
|
+
/** Everything an event binding needs. */
|
|
229
|
+
interface BindingPlan {
|
|
230
|
+
key: string;
|
|
231
|
+
value: unknown;
|
|
232
|
+
mode: SlotMode;
|
|
233
|
+
fn: JxFunctionDef | null;
|
|
234
|
+
body: LogicBodyKind;
|
|
235
|
+
paint?: (host: HTMLElement) => void;
|
|
236
|
+
mountStatements?: (host: HTMLElement) => void;
|
|
748
237
|
}
|
|
749
238
|
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
?open=${isInspectorSectionOpen("__observed", false)}
|
|
760
|
-
@sp-accordion-item-toggle=${() =>
|
|
761
|
-
setInspectorSection("__observed", !isInspectorSectionOpen("__observed", false))}
|
|
762
|
-
>
|
|
763
|
-
<div class="style-section-body">
|
|
764
|
-
${
|
|
765
|
-
entries.length === 0
|
|
766
|
-
? renderEmptyState({
|
|
767
|
-
compact: true,
|
|
768
|
-
message:
|
|
769
|
-
"Attributes let a page set this component from markup. " +
|
|
770
|
-
'Name an "attribute" on a data entry to expose it here.',
|
|
771
|
-
})
|
|
772
|
-
: entries.map(([key, d]) => {
|
|
773
|
-
const def = d as Record<string, unknown>;
|
|
774
|
-
return renderStaticKvRow({
|
|
775
|
-
detail: `→ ${key}`,
|
|
776
|
-
name: String(def.attribute),
|
|
777
|
-
...(def.type ? { value: String(def.type) } : {}),
|
|
778
|
-
...(def.reflects ? { tags: ["reflects"] } : {}),
|
|
779
|
-
});
|
|
780
|
-
})
|
|
781
|
-
}
|
|
782
|
-
</div>
|
|
783
|
-
</sp-accordion-item>
|
|
784
|
-
`;
|
|
239
|
+
interface Plans {
|
|
240
|
+
fields: Map<string, FieldPlan>;
|
|
241
|
+
bindings: Map<string, BindingPlan>;
|
|
242
|
+
cases: Set<string>;
|
|
243
|
+
/** The whole selection this projection commits to. */
|
|
244
|
+
targets: JxPath[];
|
|
245
|
+
/** The primary selection — the one whose bodies are edited. */
|
|
246
|
+
selection: JxPath | null;
|
|
247
|
+
functionDefs: [string, unknown][];
|
|
785
248
|
}
|
|
786
249
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
250
|
+
let plans: Plans = {
|
|
251
|
+
bindings: new Map(),
|
|
252
|
+
cases: new Set(),
|
|
253
|
+
fields: new Map(),
|
|
254
|
+
functionDefs: [],
|
|
255
|
+
selection: null,
|
|
256
|
+
targets: [],
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// ─── Building the view ───────────────────────────────────────────────────────
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Whether a position has anywhere else to go.
|
|
263
|
+
*
|
|
264
|
+
* Not `offered.length > 1`. A `$switch` discriminant permits exactly one rung — it is a `$ref` and
|
|
265
|
+
* nothing else — and a document that holds a `${…}` template there is on a rung the schema does not
|
|
266
|
+
* permit, which is precisely when the reader needs the chip to work. The question is whether the
|
|
267
|
+
* ladder offers a rung this value is not already on.
|
|
268
|
+
*/
|
|
269
|
+
function canMove(mode: SlotMode, offered: readonly SlotMode[]): boolean {
|
|
270
|
+
return offered.some((rung) => rung !== mode);
|
|
806
271
|
}
|
|
807
272
|
|
|
808
|
-
/** The
|
|
809
|
-
function
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
return html`
|
|
815
|
-
<sp-accordion-item
|
|
816
|
-
label="CSS Parts"
|
|
817
|
-
?open=${isInspectorSectionOpen("__cssparts", false)}
|
|
818
|
-
@sp-accordion-item-toggle=${() =>
|
|
819
|
-
setInspectorSection("__cssparts", !isInspectorSectionOpen("__cssparts", false))}
|
|
820
|
-
>
|
|
821
|
-
<div class="style-section-body">
|
|
822
|
-
${parts.map((p) => renderStaticKvRow({ detail: `<${p.tag}>`, name: p.name }))}
|
|
823
|
-
</div>
|
|
824
|
-
</sp-accordion-item>
|
|
825
|
-
`;
|
|
273
|
+
/** The Value Source chip's accessible name — and whether the position offers a choice at all. */
|
|
274
|
+
function sourceHint(mode: SlotMode, offered: readonly SlotMode[]): string {
|
|
275
|
+
const label = VALUE_SOURCE_LABELS[mode];
|
|
276
|
+
return canMove(mode, offered)
|
|
277
|
+
? `Value source: ${label} — click to change`
|
|
278
|
+
: `Value source: ${label} (no other source available here)`;
|
|
826
279
|
}
|
|
827
280
|
|
|
828
|
-
|
|
281
|
+
/** Every pointer the From data… rung offers on a bindable position. */
|
|
282
|
+
function refOptions(plan: FieldPlan): LogicOption[] {
|
|
283
|
+
return [
|
|
284
|
+
...plan.stateDefs.map((name) => ({ label: name, value: `#/state/${name}` })),
|
|
285
|
+
...(plan.extraSignals ?? []),
|
|
286
|
+
];
|
|
287
|
+
}
|
|
829
288
|
|
|
830
289
|
/**
|
|
831
|
-
*
|
|
290
|
+
* One bindable row, as the document draws it.
|
|
291
|
+
*
|
|
292
|
+
* Every position it serves is a single-line expression, so it draws one widget rather than
|
|
293
|
+
* dispatching over a widget type — the textarea and checkbox arms the lit version carried had no
|
|
294
|
+
* caller in either tab.
|
|
295
|
+
*/
|
|
296
|
+
function fieldView(key: string, prop: string, plan: FieldPlan): LogicFieldView {
|
|
297
|
+
const set = plan.value !== undefined && plan.value !== "";
|
|
298
|
+
const literal = plan.mode === "literal" || plan.mode === "function";
|
|
299
|
+
return {
|
|
300
|
+
clearLocked: !plan.onClear,
|
|
301
|
+
clearTitle: plan.onClear ? `Clear ${plan.label}` : `${plan.label} cannot be cleared`,
|
|
302
|
+
dotState: set ? "set" : "unset",
|
|
303
|
+
key,
|
|
304
|
+
kind: plan.mode === "expression" ? "control" : plan.mode === "ref" ? "select" : "text",
|
|
305
|
+
label: plan.label,
|
|
306
|
+
mono: plan.mode === "template",
|
|
307
|
+
options: plan.mode === "ref" ? refOptions(plan) : [],
|
|
308
|
+
placeholder: plan.mode === "template" ? "${state.…}" : "",
|
|
309
|
+
prop,
|
|
310
|
+
source: plan.mode,
|
|
311
|
+
sourceHint: sourceHint(plan.mode, plan.offered),
|
|
312
|
+
sourceLabel: VALUE_SOURCE_LABELS[plan.mode],
|
|
313
|
+
sourceLocked: !canMove(plan.mode, plan.offered),
|
|
314
|
+
tone: "",
|
|
315
|
+
value: literal
|
|
316
|
+
? String(plan.value ?? "")
|
|
317
|
+
: plan.mode === "ref"
|
|
318
|
+
? isRef(plan.value)
|
|
319
|
+
? plan.value.$ref
|
|
320
|
+
: ""
|
|
321
|
+
: String(plan.value ?? ""),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** Register a bindable row and return the view the document draws for it. */
|
|
326
|
+
function addField(
|
|
327
|
+
fields: Map<string, FieldPlan>,
|
|
328
|
+
key: string,
|
|
329
|
+
prop: string,
|
|
330
|
+
spec: Omit<FieldPlan, "mode" | "offered">,
|
|
331
|
+
): LogicFieldView {
|
|
332
|
+
const offered = slotCaps(spec.caps);
|
|
333
|
+
const mode = effectiveSlotMode(key, spec.value);
|
|
334
|
+
const plan: FieldPlan = { ...spec, mode, offered };
|
|
335
|
+
if (mode === "expression") {
|
|
336
|
+
const node = (spec.value as { $expression?: unknown } | undefined)?.$expression;
|
|
337
|
+
plan.paint = (host) =>
|
|
338
|
+
mountExpressionEditor(
|
|
339
|
+
host,
|
|
340
|
+
node,
|
|
341
|
+
(next) => spec.onChange({ $expression: next } as JsonValue),
|
|
342
|
+
{
|
|
343
|
+
allowEventRef: false,
|
|
344
|
+
stateDefs: [...spec.stateDefs],
|
|
345
|
+
stateEntries: null,
|
|
346
|
+
},
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
fields.set(key, plan);
|
|
350
|
+
return fieldView(key, prop, plan);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Build the whole projection, and the plans every key in it addresses.
|
|
355
|
+
*
|
|
356
|
+
* Exported for its own test: the projection IS the tab now, so what it contains and what a key
|
|
357
|
+
* addresses are the contract, not an implementation detail of a template.
|
|
832
358
|
*
|
|
833
|
-
* @
|
|
834
|
-
* tab's mode and ui, which the dock already has in hand.
|
|
359
|
+
* @returns {LogicView}
|
|
835
360
|
*/
|
|
836
|
-
export function
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
const
|
|
361
|
+
export function projectLogicPanel(): LogicView {
|
|
362
|
+
const fields = new Map<string, FieldPlan>();
|
|
363
|
+
const bindings = new Map<string, BindingPlan>();
|
|
364
|
+
const cases = new Set<string>();
|
|
365
|
+
const view = emptyLogicView();
|
|
840
366
|
const tab = activeTab.value;
|
|
841
367
|
const selection = primarySelection(tab?.session.selection);
|
|
842
368
|
const doc = tab?.doc.document;
|
|
369
|
+
const nothingToWire = (message: string, actions: LogicEmptyAction[] = []): LogicView => {
|
|
370
|
+
plans = { bindings, cases, fields, functionDefs: [], selection: null, targets: [] };
|
|
371
|
+
view.emptyActions = actions;
|
|
372
|
+
view.emptyMessage = message;
|
|
373
|
+
view.hasEmptyActions = actions.length > 0;
|
|
374
|
+
return view;
|
|
375
|
+
};
|
|
376
|
+
/* Three states, three sentences. The dock used to draw one of them itself — a no-document state
|
|
377
|
+
rendered INTO each tab's container — and it cannot any more: the container is a mounted
|
|
378
|
+
document's, and painting over it would take the field a reader is typing into. So the tab says
|
|
379
|
+
its own words, which it should have all along: "open a page" and "click something" are not the
|
|
380
|
+
same instruction. */
|
|
381
|
+
if (!tab || !doc) {
|
|
382
|
+
return nothingToWire("Open a page to inspect and wire what you click.", [
|
|
383
|
+
{ id: "open-page", label: "Open a page…" },
|
|
384
|
+
]);
|
|
385
|
+
}
|
|
843
386
|
if (!selection) {
|
|
844
|
-
return
|
|
387
|
+
return nothingToWire(clickAnythingTo("wire it up"));
|
|
845
388
|
}
|
|
846
|
-
const node = getNodeAtPath(doc
|
|
389
|
+
const node = getNodeAtPath(doc, selection) as JxMutableNode | undefined;
|
|
847
390
|
if (!node) {
|
|
848
|
-
return
|
|
391
|
+
return nothingToWire(staleSelectionMessage());
|
|
849
392
|
}
|
|
850
393
|
|
|
394
|
+
view.state = "ready";
|
|
395
|
+
const defs = doc.state || {};
|
|
396
|
+
const functionDefs = Object.entries(defs).filter(
|
|
397
|
+
([, d]) =>
|
|
398
|
+
(d as JxPrototypeDef)?.$prototype === "Function" || (d as Record<string, unknown>)?.$handler,
|
|
399
|
+
);
|
|
851
400
|
// The whole selection the Logic tab wires. `[selection]` when one element is selected — which is
|
|
852
401
|
// Every existing call site's behaviour, unchanged.
|
|
853
|
-
const targets: JxPath[] =
|
|
854
|
-
|
|
402
|
+
const targets: JxPath[] = tab.session.selection.length > 0 ? tab.session.selection : [selection];
|
|
403
|
+
plans = { bindings, cases, fields, functionDefs, selection, targets };
|
|
404
|
+
|
|
855
405
|
const isMapNode = node.$prototype === "Array";
|
|
856
406
|
const isSwitchNode = Boolean(node.$switch);
|
|
857
407
|
const isRoot = selection.length === 0;
|
|
858
|
-
const isCustomElement = isCustomElementDoc(
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
408
|
+
const isCustomElement = isCustomElementDoc({
|
|
409
|
+
document: doc,
|
|
410
|
+
mode: tab.doc.mode,
|
|
411
|
+
selection: tab.session.selection,
|
|
412
|
+
ui: tab.session.ui,
|
|
413
|
+
});
|
|
414
|
+
const stateDefs = bindableSignalNames(doc);
|
|
415
|
+
const key = selection.join("/");
|
|
416
|
+
/* De-escalating to Fixed value restores the bound signal's declared default — the old unbind
|
|
417
|
+
behaviour, and the reason the ladder has to be told what a position's default IS. */
|
|
418
|
+
const literalDefaultOf = (raw: unknown): JsonValue | undefined => {
|
|
419
|
+
const bound = isRef(raw) ? raw.$ref : null;
|
|
420
|
+
if (!bound) {
|
|
421
|
+
return undefined;
|
|
422
|
+
}
|
|
423
|
+
return (
|
|
424
|
+
defaultAsString(defs[bound.startsWith("#/state/") ? bound.slice(8) : bound]) || undefined
|
|
425
|
+
);
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
// ── Repeating list ────────────────────────────────────────────────────────
|
|
429
|
+
if (isMapNode) {
|
|
430
|
+
view.hasRepeater = true;
|
|
431
|
+
view.repeaterOpen = isInspectorSectionOpen("__repeater", true);
|
|
432
|
+
const commit = (name: string) => (v?: JsonValue) =>
|
|
433
|
+
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, name, v || undefined));
|
|
434
|
+
const optional = (name: "filter" | "sort", label: string) =>
|
|
435
|
+
addField(fields, `prop|${key}|${name}`, name, {
|
|
436
|
+
caps: name === "filter" ? "repeaterFilter" : "repeaterSort",
|
|
437
|
+
extraSignals: null,
|
|
438
|
+
label,
|
|
439
|
+
literalDefault: literalDefaultOf(node[name]),
|
|
440
|
+
onChange: commit(name),
|
|
441
|
+
onClear: () =>
|
|
442
|
+
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, name)),
|
|
443
|
+
stateDefs,
|
|
444
|
+
value: node[name],
|
|
445
|
+
});
|
|
446
|
+
view.repeaterFields = [
|
|
447
|
+
addField(fields, `prop|${key}|items`, "items", {
|
|
448
|
+
caps: "repeaterItems",
|
|
449
|
+
extraSignals: null,
|
|
450
|
+
label: "Items",
|
|
451
|
+
literalDefault: literalDefaultOf(node.items),
|
|
452
|
+
onChange: (v?: JsonValue) =>
|
|
453
|
+
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, "items", v)),
|
|
454
|
+
stateDefs,
|
|
455
|
+
value: node.items,
|
|
456
|
+
}),
|
|
457
|
+
optional("filter", "Filter"),
|
|
458
|
+
optional("sort", "Sort"),
|
|
459
|
+
];
|
|
460
|
+
view.hasTemplate = Boolean(node.map);
|
|
461
|
+
}
|
|
878
462
|
|
|
463
|
+
// ── Condition ─────────────────────────────────────────────────────────────
|
|
464
|
+
if (isSwitchNode) {
|
|
465
|
+
view.hasCondition = true;
|
|
466
|
+
view.conditionOpen = isInspectorSectionOpen("__condition", true);
|
|
467
|
+
view.conditionFields = [
|
|
468
|
+
addField(fields, `prop|${key}|$switch`, "$switch", {
|
|
469
|
+
// `SwitchDef` is a $ref and nothing else, so From data… is the only rung — a $switch is
|
|
470
|
+
// Inherently dynamic, and de-escalating it would delete the key and demote the node.
|
|
471
|
+
caps: "switchDiscriminant",
|
|
472
|
+
extraSignals: mapSignalsFor(selection),
|
|
473
|
+
label: "Expression",
|
|
474
|
+
literalDefault: literalDefaultOf(node.$switch),
|
|
475
|
+
onChange: (v?: JsonValue) =>
|
|
476
|
+
transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, "$switch", v)),
|
|
477
|
+
stateDefs,
|
|
478
|
+
value: node.$switch,
|
|
479
|
+
}),
|
|
480
|
+
];
|
|
481
|
+
view.cases = Object.keys(node.cases || {}).map((caseName) => {
|
|
482
|
+
cases.add(caseName);
|
|
483
|
+
return {
|
|
484
|
+
key: caseName,
|
|
485
|
+
name: caseName,
|
|
486
|
+
openTitle: `Edit case "${caseName}"`,
|
|
487
|
+
prop: `case:${caseName}`,
|
|
488
|
+
removeTitle: `Remove case "${caseName}"`,
|
|
489
|
+
};
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// ── Events ────────────────────────────────────────────────────────────────
|
|
879
494
|
// A repeater is not an element: it has no `on*` position to bind, and offering "Add Event" on one
|
|
880
495
|
// Writes a handler onto a node the renderer never mounts.
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
496
|
+
if (!isMapNode) {
|
|
497
|
+
view.hasEvents = true;
|
|
498
|
+
view.eventsOpen = isInspectorSectionOpen("__events", true);
|
|
499
|
+
if (isCustomElement) {
|
|
500
|
+
const declared: LogicView["declared"] = [];
|
|
501
|
+
for (const [fnName, d] of Object.entries(defs)) {
|
|
502
|
+
if (isFunctionDef(d) && Array.isArray(d.emits)) {
|
|
503
|
+
for (const [i, ev] of (d.emits as CemEvent[]).entries()) {
|
|
504
|
+
declared.push({
|
|
505
|
+
key: `${fnName}:${ev.name || i}`,
|
|
506
|
+
name: ev.name || "(unnamed)",
|
|
507
|
+
source: `← ${fnName}`,
|
|
508
|
+
title: ev.description || "",
|
|
509
|
+
type: isJsonObject(ev.type) && typeof ev.type.text === "string" ? ev.type.text : "",
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
view.declared = declared;
|
|
515
|
+
view.hasDeclared = declared.length > 0;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/* Resolved once, as pairs: asking `getEventBinding` for the key and then again for the value
|
|
519
|
+
left an `if (!evVal) return nothing` arm nothing could ever reach. */
|
|
520
|
+
const entries = Object.keys(node)
|
|
521
|
+
.filter((k) => k.startsWith("on"))
|
|
522
|
+
.map((k) => [k, getEventBinding(node, k)] as const)
|
|
523
|
+
.filter((pair): pair is [string, JxEventBinding] => pair[1] !== undefined);
|
|
524
|
+
view.bindings = entries.map(([evKey, evVal]) => bindingView(bindings, evKey, evVal, defs));
|
|
525
|
+
view.hasBindings = entries.length > 0;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// ── The custom element's outward contract ────────────────────────────────
|
|
529
|
+
if (isCustomElement && isRoot) {
|
|
530
|
+
const observed = Object.entries(defs).filter(
|
|
531
|
+
([, d]) => (d as Record<string, unknown>).attribute,
|
|
532
|
+
);
|
|
533
|
+
view.hasObserved = true;
|
|
534
|
+
view.observedOpen = isInspectorSectionOpen("__observed", false);
|
|
535
|
+
view.observedEmpty = observed.length === 0;
|
|
536
|
+
view.observed = observed.map(([name, d]) => {
|
|
537
|
+
const def = d as Record<string, unknown>;
|
|
538
|
+
return {
|
|
539
|
+
detail: `→ ${name}`,
|
|
540
|
+
key: name,
|
|
541
|
+
name: String(def.attribute),
|
|
542
|
+
prop: `attribute:${name}`,
|
|
543
|
+
tags: def.reflects ? "reflects" : "",
|
|
544
|
+
value: def.type ? String(def.type) : "",
|
|
545
|
+
};
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
const cssProps = Object.entries(node.style || {}).filter(([k]) => k.startsWith("--"));
|
|
549
|
+
view.hasCssProps = cssProps.length > 0;
|
|
550
|
+
view.cssPropsOpen = isInspectorSectionOpen("__cssprops", false);
|
|
551
|
+
view.cssProps = cssProps.map(([name, value]) => ({
|
|
552
|
+
detail: "",
|
|
553
|
+
key: name,
|
|
554
|
+
name,
|
|
555
|
+
prop: `cssprop:${name}`,
|
|
556
|
+
tags: "",
|
|
557
|
+
value: String(value),
|
|
558
|
+
}));
|
|
559
|
+
|
|
560
|
+
const parts = collectCssParts(doc);
|
|
561
|
+
view.hasCssParts = parts.length > 0;
|
|
562
|
+
view.cssPartsOpen = isInspectorSectionOpen("__cssparts", false);
|
|
563
|
+
view.cssParts = parts.map((p) => ({
|
|
564
|
+
detail: `<${p.tag}>`,
|
|
565
|
+
key: `${p.tag}:${p.name}`,
|
|
566
|
+
name: p.name,
|
|
567
|
+
prop: `csspart:${p.name}`,
|
|
568
|
+
tags: "",
|
|
569
|
+
value: "",
|
|
570
|
+
}));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
return view;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/** One `on*` key, and the plan behind it. */
|
|
577
|
+
function bindingView(
|
|
578
|
+
bindings: Map<string, BindingPlan>,
|
|
579
|
+
evKey: string,
|
|
580
|
+
evVal: JxEventBinding,
|
|
581
|
+
defs: Record<string, unknown>,
|
|
582
|
+
): LogicBindingView {
|
|
583
|
+
const { functionDefs, selection, targets } = plans;
|
|
584
|
+
const tab = activeTab.value!;
|
|
585
|
+
const fn: JxFunctionDef | null = isFunctionDef(evVal) ? evVal : null;
|
|
586
|
+
const expression = isExpressionDef(evVal) ? evVal.$expression : null;
|
|
587
|
+
const mode = slotMode(evVal);
|
|
588
|
+
const structured = Boolean(fn && Array.isArray(fn.body));
|
|
589
|
+
const body: LogicBodyKind = fn
|
|
590
|
+
? structured
|
|
591
|
+
? "statements"
|
|
592
|
+
: "code"
|
|
593
|
+
: expression
|
|
594
|
+
? "expression"
|
|
595
|
+
: "ref";
|
|
596
|
+
const mixed = mixedEventCount(tab.doc.document, targets, evKey) > 0;
|
|
597
|
+
const plan: BindingPlan = { body, fn, key: evKey, mode, value: evVal };
|
|
598
|
+
|
|
599
|
+
if (fn && structured && selection) {
|
|
600
|
+
plan.mountStatements = (host) =>
|
|
601
|
+
mountStatementEditor(
|
|
602
|
+
host,
|
|
603
|
+
fn.body as JxStatement[],
|
|
604
|
+
(next) =>
|
|
605
|
+
transactDoc(activeTab.value, (t) =>
|
|
606
|
+
mutateUpdateProperty(t, selection, evKey, {
|
|
607
|
+
...fn,
|
|
608
|
+
body: next as unknown as JsonValue,
|
|
609
|
+
}),
|
|
610
|
+
),
|
|
611
|
+
{
|
|
612
|
+
allowEventRef: true,
|
|
613
|
+
emits: fn.emits ?? [],
|
|
614
|
+
/* The Inspector's copy, named by the handler it edits. It answered to
|
|
615
|
+
`navigator/statements` until the docks were split, and then to a bare
|
|
616
|
+
`inspector/statements` — which the binding list stamps once per structured handler, so
|
|
617
|
+
two handlers on a node made two elements answer to it and `resolveRegion` took the
|
|
618
|
+
second. */
|
|
619
|
+
region: inspectorStatementsRegion(evKey),
|
|
620
|
+
stateDefs: Object.keys(defs),
|
|
621
|
+
stateEntries: defs as never,
|
|
622
|
+
},
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
if (expression && selection) {
|
|
626
|
+
/* Live-context evaluation in the canvas iframe, snapshot fallback (M6). The selection path is
|
|
627
|
+
the context, so a binding inside a repeater template previews with the first item's $map
|
|
628
|
+
scope. */
|
|
629
|
+
const preview = livePreviewExpression(
|
|
630
|
+
tab,
|
|
631
|
+
`event:${JSON.stringify(selection)}:${evKey}`,
|
|
632
|
+
expression,
|
|
633
|
+
selection,
|
|
634
|
+
() => renderOnly("rightPanel"),
|
|
635
|
+
);
|
|
636
|
+
const commitExpression = (newNode: unknown) =>
|
|
637
|
+
transactDoc(activeTab.value, (t) =>
|
|
638
|
+
mutateUpdateProperty(t, selection, evKey, { $expression: newNode as JsonValue }),
|
|
639
|
+
);
|
|
640
|
+
const insertDef = (defName: string, def: unknown) =>
|
|
641
|
+
transactDoc(activeTab.value, (t) =>
|
|
642
|
+
mutateAddDef(t, defName, def as Record<string, JsonValue>),
|
|
643
|
+
);
|
|
644
|
+
plan.paint = (host) =>
|
|
645
|
+
mountExpressionEditor(host, expression, commitExpression, {
|
|
646
|
+
allowEventRef: true,
|
|
647
|
+
onInsertDef: insertDef,
|
|
648
|
+
preview,
|
|
649
|
+
stateDefs: Object.keys(defs),
|
|
650
|
+
stateEntries: defs as never,
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
bindings.set(evKey, plan);
|
|
654
|
+
|
|
655
|
+
return {
|
|
656
|
+
body,
|
|
657
|
+
clearTitle: mixed
|
|
658
|
+
? `${targets.length} selected elements bind ${evKey} differently — clearing removes it from all of them`
|
|
659
|
+
: `Clear ${evKey}`,
|
|
660
|
+
code: fn && !structured && typeof fn.body === "string" ? fn.body : "",
|
|
661
|
+
codeChecked: body === "code" ? "true" : "false",
|
|
662
|
+
dotState: mixed ? "mixed" : "set",
|
|
663
|
+
key: evKey,
|
|
664
|
+
name: evKey,
|
|
665
|
+
nameTitle: `Event: ${evKey} — click to change`,
|
|
666
|
+
openTitle: body === "expression" ? "Open in formula workspace" : "Open in editor",
|
|
667
|
+
refOptions: [
|
|
668
|
+
{ label: "— none —", value: "" },
|
|
669
|
+
...functionDefs.map(([fName]) => ({ label: fName, value: `#/state/${fName}` })),
|
|
670
|
+
],
|
|
671
|
+
refValue: isRef(evVal) ? evVal.$ref : "",
|
|
672
|
+
showToggle: Boolean(fn),
|
|
673
|
+
source: mode,
|
|
674
|
+
sourceHint: sourceHint(mode, HANDLER_MODES),
|
|
675
|
+
sourceLabel: VALUE_SOURCE_LABELS[mode],
|
|
676
|
+
statementsChecked: body === "statements" ? "true" : "false",
|
|
677
|
+
tone: mixed ? "warning" : "",
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
// ─── The surface ─────────────────────────────────────────────────────────────
|
|
682
|
+
|
|
683
|
+
let surface: LogicSurface | null = null;
|
|
684
|
+
let watcher: EffectScope | null = null;
|
|
685
|
+
/** Every island host the tab has been handed, so a re-projection can repaint it. */
|
|
686
|
+
const controlHosts = new Map<string, HTMLElement>();
|
|
687
|
+
const expressionHosts = new Map<string, HTMLElement>();
|
|
688
|
+
const statementHosts = new Map<string, HTMLElement>();
|
|
689
|
+
|
|
690
|
+
/** The section ids the document names, and the keys `inspectorSections` stores them under. */
|
|
691
|
+
const SECTION_KEYS: Record<string, string> = {
|
|
692
|
+
condition: "__condition",
|
|
693
|
+
cssparts: "__cssparts",
|
|
694
|
+
cssprops: "__cssprops",
|
|
695
|
+
events: "__events",
|
|
696
|
+
observed: "__observed",
|
|
697
|
+
repeater: "__repeater",
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Mount the Logic tab into the container the Inspector owns, and subscribe to what it draws.
|
|
702
|
+
*
|
|
703
|
+
* `null` unbinds. Called once from the right panel's container setup — the same seam
|
|
704
|
+
* `panels/ai-panel.ts` uses, for the same reason: the container is built once for the life of the
|
|
705
|
+
* window, and the dock must not render over a mounted document.
|
|
706
|
+
*
|
|
707
|
+
* @param {HTMLElement | null} el
|
|
708
|
+
*/
|
|
709
|
+
export function bindLogicPanelHost(el: HTMLElement | null): void {
|
|
710
|
+
watcher?.stop();
|
|
711
|
+
watcher = null;
|
|
712
|
+
surface?.dispose();
|
|
713
|
+
surface = null;
|
|
714
|
+
controlHosts.clear();
|
|
715
|
+
expressionHosts.clear();
|
|
716
|
+
statementHosts.clear();
|
|
717
|
+
if (!el) {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
surface = mountLogicSurface(
|
|
721
|
+
el,
|
|
722
|
+
projectLogicPanel(),
|
|
723
|
+
{
|
|
724
|
+
addCase: () => {
|
|
725
|
+
const { selection } = plans;
|
|
726
|
+
if (selection) {
|
|
727
|
+
transactDoc(activeTab.value, (t) =>
|
|
728
|
+
mutateAddSwitchCase(t, selection, `case${plans.cases.size + 1}`),
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
addEvent: addEventBinding,
|
|
733
|
+
clearEvent: (key) => commitToTargets(plans.targets, key),
|
|
734
|
+
clearField: (key) => plans.fields.get(key)?.onClear?.(),
|
|
735
|
+
editTemplate: () => {
|
|
736
|
+
const { selection } = plans;
|
|
737
|
+
if (selection && activeTab.value) {
|
|
738
|
+
activeTab.value.session.selection = [[...selection, "map"]];
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
openCase: (key) => {
|
|
742
|
+
const { selection } = plans;
|
|
743
|
+
if (selection && activeTab.value) {
|
|
744
|
+
activeTab.value.session.selection = [[...selection, "cases", key]];
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
openEditor: (key) => {
|
|
748
|
+
const { selection } = plans;
|
|
749
|
+
const plan = plans.bindings.get(key);
|
|
750
|
+
if (selection && plan) {
|
|
751
|
+
openLogicTarget({
|
|
752
|
+
editing: { eventKey: key, path: selection, type: "event" },
|
|
753
|
+
surface: plan.body === "expression" ? "formula" : "function",
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
},
|
|
757
|
+
pickEventName: openEventNameMenu,
|
|
758
|
+
pickHandler: openHandlerMenu,
|
|
759
|
+
pickSource: openSourceMenu,
|
|
760
|
+
runEmptyAction: (id) => {
|
|
761
|
+
if (id === "open-page") {
|
|
762
|
+
openPageAction().run();
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
removeCase: (key) => {
|
|
766
|
+
const { selection } = plans;
|
|
767
|
+
if (selection) {
|
|
768
|
+
transactDoc(activeTab.value, (t) => mutateRemoveSwitchCase(t, selection, key));
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
renameCase: (key, value) => {
|
|
772
|
+
const { selection } = plans;
|
|
773
|
+
if (selection && value && value !== key) {
|
|
774
|
+
transactDoc(activeTab.value, (t) => mutateRenameSwitchCase(t, selection, key, value));
|
|
775
|
+
}
|
|
776
|
+
},
|
|
777
|
+
setBodyMode: setHandlerBodyMode,
|
|
778
|
+
setCode: (key, value) => {
|
|
779
|
+
const { selection } = plans;
|
|
780
|
+
const plan = plans.bindings.get(key);
|
|
781
|
+
if (selection && plan?.fn) {
|
|
782
|
+
transactDoc(activeTab.value, (t) =>
|
|
783
|
+
mutateUpdateProperty(t, selection, key, {
|
|
784
|
+
$prototype: "Function",
|
|
785
|
+
body: value,
|
|
786
|
+
parameters: (plan.fn?.parameters as JsonValue) || [],
|
|
787
|
+
}),
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
},
|
|
791
|
+
setField: (key, value) => {
|
|
792
|
+
const plan = plans.fields.get(key);
|
|
793
|
+
if (!plan) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
if (plan.mode === "ref") {
|
|
797
|
+
plan.onChange(value ? ({ $ref: value } as JsonValue) : undefined);
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
plan.onChange(value);
|
|
801
|
+
},
|
|
802
|
+
setHandlerRef: (key, value) => {
|
|
803
|
+
const { selection } = plans;
|
|
804
|
+
if (!selection) {
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
transactDoc(activeTab.value, (t) =>
|
|
808
|
+
mutateUpdateProperty(t, selection, key, value ? { $ref: value } : undefined),
|
|
809
|
+
);
|
|
810
|
+
},
|
|
811
|
+
setSection: (id, open) => {
|
|
812
|
+
const stored = SECTION_KEYS[id];
|
|
813
|
+
if (stored) {
|
|
814
|
+
setInspectorSection(stored, open);
|
|
815
|
+
}
|
|
816
|
+
},
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
controlSlot: (key, host) => {
|
|
820
|
+
controlHosts.set(key, host);
|
|
821
|
+
plans.fields.get(key)?.paint?.(host);
|
|
822
|
+
},
|
|
823
|
+
expressionSlot: (key, host) => {
|
|
824
|
+
expressionHosts.set(key, host);
|
|
825
|
+
plans.bindings.get(key)?.paint?.(host);
|
|
826
|
+
},
|
|
827
|
+
statementsSlot: (key, host) => {
|
|
828
|
+
statementHosts.set(key, host);
|
|
829
|
+
plans.bindings.get(key)?.mountStatements?.(host);
|
|
830
|
+
},
|
|
831
|
+
},
|
|
832
|
+
);
|
|
833
|
+
watch();
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
/** Whether a projection is already queued for the end of this tick. */
|
|
837
|
+
let queued = false;
|
|
838
|
+
|
|
839
|
+
/**
|
|
840
|
+
* Re-project; the surface follows.
|
|
841
|
+
*
|
|
842
|
+
* Coalesced on a microtask for the reason `panels/ai-panel.ts` gives: a transaction writes several
|
|
843
|
+
* reactive facts in one tick and the projection walks the whole selection, so running it per write
|
|
844
|
+
* would rebuild the same view three times for one edit.
|
|
845
|
+
*/
|
|
846
|
+
export function renderLogicPanel(): void {
|
|
847
|
+
if (queued || !surface) {
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
queued = true;
|
|
851
|
+
queueMicrotask(() => {
|
|
852
|
+
queued = false;
|
|
853
|
+
if (!surface) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
surface.update(projectLogicPanel());
|
|
857
|
+
/* The document's own bindings settle on a microtask, so the islands are brought up on the next
|
|
858
|
+
one — after the rows the runtime is about to reconcile exist. A host whose row is gone is
|
|
859
|
+
dropped rather than repainted. */
|
|
860
|
+
queueMicrotask(repaintIslands);
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/** Fill every island the tab still has, and forget the ones whose row went away. */
|
|
865
|
+
function repaintIslands(): void {
|
|
866
|
+
for (const [key, host] of controlHosts) {
|
|
867
|
+
const plan = plans.fields.get(key);
|
|
868
|
+
if (!plan || !host.isConnected) {
|
|
869
|
+
controlHosts.delete(key);
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
plan.paint?.(host);
|
|
873
|
+
}
|
|
874
|
+
for (const [key, host] of expressionHosts) {
|
|
875
|
+
const plan = plans.bindings.get(key);
|
|
876
|
+
if (!plan || !host.isConnected) {
|
|
877
|
+
expressionHosts.delete(key);
|
|
878
|
+
continue;
|
|
879
|
+
}
|
|
880
|
+
plan.paint?.(host);
|
|
881
|
+
}
|
|
882
|
+
for (const [key, host] of statementHosts) {
|
|
883
|
+
const plan = plans.bindings.get(key);
|
|
884
|
+
if (!plan || !host.isConnected) {
|
|
885
|
+
statementHosts.delete(key);
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
plan.mountStatements?.(host);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Re-project on the facts the tab draws.
|
|
894
|
+
*
|
|
895
|
+
* The Inspector's own scheduler is deliberately not in this path: its focus guard exists because a
|
|
896
|
+
* lit repaint takes the node a reader is typing into, and a document's binding skips a write that
|
|
897
|
+
* resolved to the value the control already holds.
|
|
898
|
+
*/
|
|
899
|
+
function watch(): void {
|
|
900
|
+
watcher?.stop();
|
|
901
|
+
watcher = effectScope();
|
|
902
|
+
watcher.run(() => {
|
|
903
|
+
effect(() => {
|
|
904
|
+
const tab = activeTab.value;
|
|
905
|
+
if (tab) {
|
|
906
|
+
void tab.doc.document;
|
|
907
|
+
void tab.doc.mode;
|
|
908
|
+
// The whole SET, joined — a bare property read would not re-trigger when the selection
|
|
909
|
+
// Changes WITHIN the array.
|
|
910
|
+
void tab.session.selection.map((path) => path.join("/")).join("|");
|
|
911
|
+
void tab.session.ui.inspectorSections;
|
|
912
|
+
}
|
|
913
|
+
renderLogicPanel();
|
|
914
|
+
});
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
// ─── The menus ───────────────────────────────────────────────────────────────
|
|
919
|
+
|
|
920
|
+
/** The rung picker for a bindable row: every source this position permits, one action away (§6.3). */
|
|
921
|
+
function openSourceMenu(key: string, anchor: HTMLElement): void {
|
|
922
|
+
const plan = plans.fields.get(key);
|
|
923
|
+
if (!plan || !canMove(plan.mode, plan.offered)) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
openMenu({
|
|
927
|
+
label: "Value source",
|
|
928
|
+
opener: anchor,
|
|
929
|
+
region: "value-source",
|
|
930
|
+
rows: plan.offered.map((rung) => ({
|
|
931
|
+
checked: (rung === plan.mode ? "true" : "false") as "true" | "false",
|
|
932
|
+
destructive: false,
|
|
933
|
+
disabled: false,
|
|
934
|
+
dividerAbove: false,
|
|
935
|
+
id: rung,
|
|
936
|
+
title: VALUE_SOURCE_LABELS[rung],
|
|
937
|
+
})),
|
|
938
|
+
run: (id) => {
|
|
939
|
+
const next = id as SlotMode;
|
|
940
|
+
if (next === plan.mode) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
/* Leaving From data… seeds an empty Fixed value stash with the signal's declared default, so
|
|
944
|
+
unbind-restores-default survives a detour (ref → mixed text → fixed value). */
|
|
945
|
+
if (
|
|
946
|
+
plan.mode === "ref" &&
|
|
947
|
+
plan.literalDefault !== undefined &&
|
|
948
|
+
!hasStashedSlotValue(key, "literal")
|
|
949
|
+
) {
|
|
950
|
+
stashSlotValue(key, "literal", plan.literalDefault);
|
|
951
|
+
}
|
|
952
|
+
plan.onChange(
|
|
953
|
+
switchSlotMode(
|
|
954
|
+
key,
|
|
955
|
+
plan.mode,
|
|
956
|
+
next,
|
|
957
|
+
cloneValue(plan.value as JsonValue | undefined),
|
|
958
|
+
slotModeSeed(next, {
|
|
959
|
+
extraSignals: plan.extraSignals,
|
|
960
|
+
literalDefault: plan.literalDefault,
|
|
961
|
+
stateDefs: plan.stateDefs,
|
|
962
|
+
}),
|
|
963
|
+
),
|
|
964
|
+
);
|
|
965
|
+
},
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
/** The handler's rung picker — the same ladder, remembering the representation it left. */
|
|
970
|
+
function openHandlerMenu(key: string, anchor: HTMLElement): void {
|
|
971
|
+
const plan = plans.bindings.get(key);
|
|
972
|
+
if (!plan) {
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
openMenu({
|
|
976
|
+
label: "Value source",
|
|
977
|
+
opener: anchor,
|
|
978
|
+
region: "value-source",
|
|
979
|
+
rows: HANDLER_MODES.map((rung) => ({
|
|
980
|
+
checked: (rung === plan.mode ? "true" : "false") as "true" | "false",
|
|
981
|
+
destructive: false,
|
|
982
|
+
disabled: false,
|
|
983
|
+
dividerAbove: false,
|
|
984
|
+
id: rung,
|
|
985
|
+
title: VALUE_SOURCE_LABELS[rung],
|
|
986
|
+
})),
|
|
987
|
+
run: (id) => {
|
|
988
|
+
const next = id as SlotMode;
|
|
989
|
+
if (next === plan.mode) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
const seed = seedForHandlerMode(next, plans.functionDefs);
|
|
993
|
+
commitToTargets(
|
|
994
|
+
plans.targets,
|
|
995
|
+
key,
|
|
996
|
+
switchSlotMode(
|
|
997
|
+
`event|${plans.selection?.join("/") ?? ""}|${key}`,
|
|
998
|
+
plan.mode,
|
|
999
|
+
next,
|
|
1000
|
+
plan.value as JsonValue,
|
|
1001
|
+
seed,
|
|
1002
|
+
) ?? seed,
|
|
1003
|
+
);
|
|
1004
|
+
},
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* The event NAME menu: what this element already binds, the ten worth suggesting, and Other….
|
|
1010
|
+
*
|
|
1011
|
+
* A NAME, not a menu choice — the field refuses what it cannot bind rather than trusting a list it
|
|
1012
|
+
* does not constrain, which is why the pattern is checked on the way out of the prompt as well.
|
|
1013
|
+
*/
|
|
1014
|
+
function openEventNameMenu(key: string, anchor: HTMLElement): void {
|
|
1015
|
+
const bound = [...plans.bindings.keys()];
|
|
1016
|
+
const suggestions = [...new Set([...bound, ...EVENT_NAMES])];
|
|
1017
|
+
openMenu({
|
|
1018
|
+
label: "Event name",
|
|
1019
|
+
opener: anchor,
|
|
1020
|
+
region: "event-name",
|
|
1021
|
+
rows: [
|
|
1022
|
+
...suggestions.map((name) => ({
|
|
1023
|
+
checked: (name === key ? "true" : "false") as "true" | "false",
|
|
1024
|
+
destructive: false,
|
|
1025
|
+
disabled: false,
|
|
1026
|
+
dividerAbove: false,
|
|
1027
|
+
id: name,
|
|
1028
|
+
title: name,
|
|
1029
|
+
})),
|
|
1030
|
+
{
|
|
1031
|
+
destructive: false,
|
|
1032
|
+
disabled: false,
|
|
1033
|
+
dividerAbove: true,
|
|
1034
|
+
id: "__custom__",
|
|
1035
|
+
run: () => {
|
|
1036
|
+
void showPromptDialog("Event name", {
|
|
1037
|
+
message: "Any DOM or custom event this element emits — onpointerdown, ondragover.",
|
|
1038
|
+
placeholder: "onpointerdown",
|
|
1039
|
+
validate: (value) =>
|
|
1040
|
+
EVENT_NAME_PATTERN.test(value.trim())
|
|
1041
|
+
? ""
|
|
1042
|
+
: "An event key starts with “on” and continues in letters, digits or hyphens.",
|
|
1043
|
+
value: key,
|
|
1044
|
+
}).then((name) => {
|
|
1045
|
+
if (name) {
|
|
1046
|
+
renameEvent(key, name.trim());
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
},
|
|
1050
|
+
title: "Other name…",
|
|
1051
|
+
},
|
|
1052
|
+
],
|
|
1053
|
+
run: (id) => renameEvent(key, id),
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/** Move a binding onto a different key, on every selected element, in one step. */
|
|
1058
|
+
function renameEvent(evKey: string, newKey: string): void {
|
|
1059
|
+
if (!newKey || newKey === evKey || !EVENT_NAME_PATTERN.test(newKey)) {
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
transactDoc(activeTab.value, (t) => {
|
|
1063
|
+
for (const target of plans.targets) {
|
|
1064
|
+
const existing = getEventBinding(
|
|
1065
|
+
getNodeAtPath(t.doc.document, target) as JxMutableNode,
|
|
1066
|
+
evKey,
|
|
1067
|
+
);
|
|
1068
|
+
if (existing === undefined) {
|
|
1069
|
+
continue;
|
|
1070
|
+
}
|
|
1071
|
+
mutateUpdateProperty(t, target, evKey);
|
|
1072
|
+
mutateUpdateProperty(t, target, newKey, existing as JsonValue);
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Switch an inline handler between a structured body and a code body.
|
|
1079
|
+
*
|
|
1080
|
+
* A change of REPRESENTATION, not of view: a `JxStatement[]` and a string are two different values
|
|
1081
|
+
* in the document, so the toggle rewrites the entry rather than choosing a renderer.
|
|
1082
|
+
*/
|
|
1083
|
+
function setHandlerBodyMode(key: string, mode: string): void {
|
|
1084
|
+
const { selection } = plans;
|
|
1085
|
+
const plan = plans.bindings.get(key);
|
|
1086
|
+
const fn = plan?.fn;
|
|
1087
|
+
if (!selection || !fn) {
|
|
1088
|
+
return;
|
|
1089
|
+
}
|
|
1090
|
+
const structured = Array.isArray(fn.body);
|
|
1091
|
+
if ((mode === "statements") === structured) {
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
transactDoc(activeTab.value, (t) =>
|
|
1095
|
+
mutateUpdateProperty(t, selection, key, {
|
|
1096
|
+
...fn,
|
|
1097
|
+
body: (mode === "statements" ? [] : "") as JsonValue,
|
|
1098
|
+
}),
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
/** Add a binding on the first unbound suggestion, pointed at the first function this document has. */
|
|
1103
|
+
function addEventBinding(): void {
|
|
1104
|
+
const { functionDefs, selection } = plans;
|
|
1105
|
+
const tab = activeTab.value;
|
|
1106
|
+
if (!selection || !tab) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
const node = getNodeAtPath(tab.doc.document, selection) as JxMutableNode | undefined;
|
|
1110
|
+
let evName = "onclick";
|
|
1111
|
+
for (const name of EVENT_NAMES) {
|
|
1112
|
+
if (!node?.[name]) {
|
|
1113
|
+
evName = name;
|
|
1114
|
+
break;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
transactDoc(activeTab.value, (t) =>
|
|
1118
|
+
mutateUpdateProperty(
|
|
1119
|
+
t,
|
|
1120
|
+
selection,
|
|
1121
|
+
evName,
|
|
1122
|
+
functionDefs.length > 0
|
|
1123
|
+
? { $ref: `#/state/${functionDefs[0]![0]}` }
|
|
1124
|
+
: { $prototype: "Function", body: "", parameters: [] },
|
|
1125
|
+
),
|
|
1126
|
+
);
|
|
906
1127
|
}
|