@terra-symposium/docs 0.0.0-stage → 0.1.71
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/LICENSE +201 -0
- package/README.md +72 -2
- package/lib-dist/assets/fonts/AUTHENTICSans-130.woff +0 -0
- package/lib-dist/assets/fonts/AUTHENTICSans-130.woff2 +0 -0
- package/lib-dist/assets/fonts/AUTHENTICSans-150.woff +0 -0
- package/lib-dist/assets/fonts/AUTHENTICSans-150.woff2 +0 -0
- package/lib-dist/assets/fonts/AUTHENTICSans-90.woff +0 -0
- package/lib-dist/assets/fonts/AUTHENTICSans-90.woff2 +0 -0
- package/lib-dist/assets/fonts/Avara-Bold.woff +0 -0
- package/lib-dist/assets/fonts/Avara-Bold.woff2 +0 -0
- package/lib-dist/assets/fonts/Avara-BoldItalic.woff +0 -0
- package/lib-dist/assets/fonts/Avara-BoldItalic.woff2 +0 -0
- package/lib-dist/assets/fonts/InterVariable-Italic-latin-20260728.woff2 +0 -0
- package/lib-dist/assets/fonts/InterVariable-latin-20260728.woff2 +0 -0
- package/lib-dist/assets/fonts/OFL-1.1.txt +93 -0
- package/lib-dist/assets/fonts/README.md +7 -0
- package/lib-dist/assets/fonts/licenses/Inter-OFL-1.1.txt +92 -0
- package/lib-dist/assets/fonts/licenses/OFL-1.1.txt +93 -0
- package/lib-dist/components/Docs.d.ts +22 -0
- package/lib-dist/components/Docs.d.ts.map +1 -0
- package/lib-dist/components/Docs.js +9 -0
- package/lib-dist/components/Docs.js.map +1 -0
- package/lib-dist/components/LocalDocsWorkspace.d.ts +37 -0
- package/lib-dist/components/LocalDocsWorkspace.d.ts.map +1 -0
- package/lib-dist/components/LocalDocsWorkspace.js +207 -0
- package/lib-dist/components/LocalDocsWorkspace.js.map +1 -0
- package/lib-dist/components/NotFound.d.ts +8 -0
- package/lib-dist/components/NotFound.d.ts.map +1 -0
- package/lib-dist/components/NotFound.js +6 -0
- package/lib-dist/components/NotFound.js.map +1 -0
- package/lib-dist/components/SiteLayout.d.ts +25 -0
- package/lib-dist/components/SiteLayout.d.ts.map +1 -0
- package/lib-dist/components/SiteLayout.js +12 -0
- package/lib-dist/components/SiteLayout.js.map +1 -0
- package/lib-dist/components/StaticWorkspace.d.ts +25 -0
- package/lib-dist/components/StaticWorkspace.d.ts.map +1 -0
- package/lib-dist/components/StaticWorkspace.js +245 -0
- package/lib-dist/components/StaticWorkspace.js.map +1 -0
- package/lib-dist/components/StrictLocalWorkspaceHarness.d.ts +10 -0
- package/lib-dist/components/StrictLocalWorkspaceHarness.d.ts.map +1 -0
- package/lib-dist/components/StrictLocalWorkspaceHarness.js +12 -0
- package/lib-dist/components/StrictLocalWorkspaceHarness.js.map +1 -0
- package/lib-dist/components/blocks.d.ts +23 -0
- package/lib-dist/components/blocks.d.ts.map +1 -0
- package/lib-dist/components/blocks.js +396 -0
- package/lib-dist/components/blocks.js.map +1 -0
- package/lib-dist/components/navigation.d.ts +18 -0
- package/lib-dist/components/navigation.d.ts.map +1 -0
- package/lib-dist/components/navigation.js +9 -0
- package/lib-dist/components/navigation.js.map +1 -0
- package/lib-dist/components/terra/Workspace.d.ts +5 -0
- package/lib-dist/components/terra/Workspace.d.ts.map +1 -0
- package/lib-dist/components/terra/Workspace.js +190 -0
- package/lib-dist/components/terra/Workspace.js.map +1 -0
- package/lib-dist/components/terra/editor/TerraContentEditor.d.ts +15 -0
- package/lib-dist/components/terra/editor/TerraContentEditor.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/TerraContentEditor.js +358 -0
- package/lib-dist/components/terra/editor/TerraContentEditor.js.map +1 -0
- package/lib-dist/components/terra/editor/_blocks.d.ts +70 -0
- package/lib-dist/components/terra/editor/_blocks.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/_blocks.js +120 -0
- package/lib-dist/components/terra/editor/_blocks.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/BlockContext.d.ts +7 -0
- package/lib-dist/components/terra/editor/docs/BlockContext.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/BlockContext.js +60 -0
- package/lib-dist/components/terra/editor/docs/BlockContext.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.d.ts +12 -0
- package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.js +66 -0
- package/lib-dist/components/terra/editor/docs/DocsAttachmentPicker.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/TerraToolbar.d.ts +12 -0
- package/lib-dist/components/terra/editor/docs/TerraToolbar.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/TerraToolbar.js +169 -0
- package/lib-dist/components/terra/editor/docs/TerraToolbar.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Callout.d.ts +14 -0
- package/lib-dist/components/terra/editor/docs/_Callout.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Callout.js +45 -0
- package/lib-dist/components/terra/editor/docs/_Callout.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_CodeBlock.d.ts +39 -0
- package/lib-dist/components/terra/editor/docs/_CodeBlock.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_CodeBlock.js +560 -0
- package/lib-dist/components/terra/editor/docs/_CodeBlock.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_DocsCode.d.ts +14 -0
- package/lib-dist/components/terra/editor/docs/_DocsCode.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_DocsCode.js +128 -0
- package/lib-dist/components/terra/editor/docs/_DocsCode.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_DocsImage.d.ts +18 -0
- package/lib-dist/components/terra/editor/docs/_DocsImage.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_DocsImage.js +62 -0
- package/lib-dist/components/terra/editor/docs/_DocsImage.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Embed.d.ts +17 -0
- package/lib-dist/components/terra/editor/docs/_Embed.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Embed.js +73 -0
- package/lib-dist/components/terra/editor/docs/_Embed.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Math.d.ts +31 -0
- package/lib-dist/components/terra/editor/docs/_Math.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Math.js +138 -0
- package/lib-dist/components/terra/editor/docs/_Math.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Nodes.d.ts +15 -0
- package/lib-dist/components/terra/editor/docs/_Nodes.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Nodes.js +62 -0
- package/lib-dist/components/terra/editor/docs/_Nodes.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Raw.d.ts +15 -0
- package/lib-dist/components/terra/editor/docs/_Raw.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Raw.js +31 -0
- package/lib-dist/components/terra/editor/docs/_Raw.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Table.d.ts +12 -0
- package/lib-dist/components/terra/editor/docs/_Table.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Table.js +99 -0
- package/lib-dist/components/terra/editor/docs/_Table.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Tabs.d.ts +14 -0
- package/lib-dist/components/terra/editor/docs/_Tabs.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_Tabs.js +125 -0
- package/lib-dist/components/terra/editor/docs/_Tabs.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_TsDocs.d.ts +15 -0
- package/lib-dist/components/terra/editor/docs/_TsDocs.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_TsDocs.js +83 -0
- package/lib-dist/components/terra/editor/docs/_TsDocs.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/_math_inline.d.ts +14 -0
- package/lib-dist/components/terra/editor/docs/_math_inline.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/_math_inline.js +30 -0
- package/lib-dist/components/terra/editor/docs/_math_inline.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/heading.d.ts +23 -0
- package/lib-dist/components/terra/editor/docs/heading.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/heading.js +63 -0
- package/lib-dist/components/terra/editor/docs/heading.js.map +1 -0
- package/lib-dist/components/terra/editor/docs/index.d.ts +13 -0
- package/lib-dist/components/terra/editor/docs/index.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/docs/index.js +14 -0
- package/lib-dist/components/terra/editor/docs/index.js.map +1 -0
- package/lib-dist/components/terra/editor/terra-content.styles.d.ts +3 -0
- package/lib-dist/components/terra/editor/terra-content.styles.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/terra-content.styles.js +3 -0
- package/lib-dist/components/terra/editor/terra-content.styles.js.map +1 -0
- package/lib-dist/components/terra/editor/types.d.ts +40 -0
- package/lib-dist/components/terra/editor/types.d.ts.map +1 -0
- package/lib-dist/components/terra/editor/types.js +11 -0
- package/lib-dist/components/terra/editor/types.js.map +1 -0
- package/lib-dist/components/terra/flow/Nodes.d.ts +78 -0
- package/lib-dist/components/terra/flow/Nodes.d.ts.map +1 -0
- package/lib-dist/components/terra/flow/Nodes.js +1019 -0
- package/lib-dist/components/terra/flow/Nodes.js.map +1 -0
- package/lib-dist/components/terra/flow/_chrome.d.ts +267 -0
- package/lib-dist/components/terra/flow/_chrome.d.ts.map +1 -0
- package/lib-dist/components/terra/flow/_chrome.js +1009 -0
- package/lib-dist/components/terra/flow/_chrome.js.map +1 -0
- package/lib-dist/components/terra/flow/menuContext.d.ts +13 -0
- package/lib-dist/components/terra/flow/menuContext.d.ts.map +1 -0
- package/lib-dist/components/terra/flow/menuContext.js +10 -0
- package/lib-dist/components/terra/flow/menuContext.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_attachments.d.ts +20 -0
- package/lib-dist/components/terra/pages/docs/_attachments.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_attachments.js +1148 -0
- package/lib-dist/components/terra/pages/docs/_attachments.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_blocks.d.ts +48 -0
- package/lib-dist/components/terra/pages/docs/_blocks.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_blocks.js +203 -0
- package/lib-dist/components/terra/pages/docs/_blocks.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_editable.d.ts +61 -0
- package/lib-dist/components/terra/pages/docs/_editable.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_editable.js +442 -0
- package/lib-dist/components/terra/pages/docs/_editable.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_export-dialog.d.ts +19 -0
- package/lib-dist/components/terra/pages/docs/_export-dialog.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_export-dialog.js +78 -0
- package/lib-dist/components/terra/pages/docs/_export-dialog.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_icons.d.ts +20 -0
- package/lib-dist/components/terra/pages/docs/_icons.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_icons.js +29 -0
- package/lib-dist/components/terra/pages/docs/_icons.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_main.d.ts +54 -0
- package/lib-dist/components/terra/pages/docs/_main.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_main.js +710 -0
- package/lib-dist/components/terra/pages/docs/_main.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.d.ts +10 -0
- package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.js +597 -0
- package/lib-dist/components/terra/pages/docs/_manage-attachments-dialog.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_sidebar.d.ts +33 -0
- package/lib-dist/components/terra/pages/docs/_sidebar.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_sidebar.js +1437 -0
- package/lib-dist/components/terra/pages/docs/_sidebar.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_toc.d.ts +4 -0
- package/lib-dist/components/terra/pages/docs/_toc.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_toc.js +212 -0
- package/lib-dist/components/terra/pages/docs/_toc.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.d.ts +15 -0
- package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.js +207 -0
- package/lib-dist/components/terra/pages/docs/_toolbar-find-replace.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_toolbar.d.ts +22 -0
- package/lib-dist/components/terra/pages/docs/_toolbar.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_toolbar.js +1508 -0
- package/lib-dist/components/terra/pages/docs/_toolbar.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/_tree.d.ts +178 -0
- package/lib-dist/components/terra/pages/docs/_tree.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/_tree.js +1123 -0
- package/lib-dist/components/terra/pages/docs/_tree.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/use-block-nav.d.ts +5 -0
- package/lib-dist/components/terra/pages/docs/use-block-nav.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/use-block-nav.js +1306 -0
- package/lib-dist/components/terra/pages/docs/use-block-nav.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/use-media-paste.d.ts +5 -0
- package/lib-dist/components/terra/pages/docs/use-media-paste.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/use-media-paste.js +391 -0
- package/lib-dist/components/terra/pages/docs/use-media-paste.js.map +1 -0
- package/lib-dist/components/terra/pages/docs/use-render-tripwire.d.ts +2 -0
- package/lib-dist/components/terra/pages/docs/use-render-tripwire.d.ts.map +1 -0
- package/lib-dist/components/terra/pages/docs/use-render-tripwire.js +25 -0
- package/lib-dist/components/terra/pages/docs/use-render-tripwire.js.map +1 -0
- package/lib-dist/components/terra/ui.d.ts +28 -0
- package/lib-dist/components/terra/ui.d.ts.map +1 -0
- package/lib-dist/components/terra/ui.js +20 -0
- package/lib-dist/components/terra/ui.js.map +1 -0
- package/lib-dist/components/workspace-demo-fixture.d.ts +35 -0
- package/lib-dist/components/workspace-demo-fixture.d.ts.map +1 -0
- package/lib-dist/components/workspace-demo-fixture.js +820 -0
- package/lib-dist/components/workspace-demo-fixture.js.map +1 -0
- package/lib-dist/fonts/KaTeX_AMS-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_AMS-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Caligraphic-Bold.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Caligraphic-Bold.woff +0 -0
- package/lib-dist/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Caligraphic-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Caligraphic-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Fraktur-Bold.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Fraktur-Bold.woff +0 -0
- package/lib-dist/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Fraktur-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Fraktur-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Main-Bold.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Main-Bold.woff +0 -0
- package/lib-dist/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Main-BoldItalic.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Main-BoldItalic.woff +0 -0
- package/lib-dist/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Main-Italic.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Main-Italic.woff +0 -0
- package/lib-dist/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Main-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Main-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Math-BoldItalic.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Math-BoldItalic.woff +0 -0
- package/lib-dist/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Math-Italic.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Math-Italic.woff +0 -0
- package/lib-dist/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Bold.ttf +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Bold.woff +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Italic.ttf +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Italic.woff +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Script-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Script-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Size1-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Size1-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Size2-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Size2-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Size3-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Size3-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Size4-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Size4-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/lib-dist/fonts/KaTeX_Typewriter-Regular.ttf +0 -0
- package/lib-dist/fonts/KaTeX_Typewriter-Regular.woff +0 -0
- package/lib-dist/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/lib-dist/lib/astro.d.ts +8 -0
- package/lib-dist/lib/astro.d.ts.map +1 -0
- package/lib-dist/lib/astro.js +27 -0
- package/lib-dist/lib/astro.js.map +1 -0
- package/lib-dist/lib/docs-catalog.d.ts +5 -0
- package/lib-dist/lib/docs-catalog.d.ts.map +1 -0
- package/lib-dist/lib/docs-catalog.js +75 -0
- package/lib-dist/lib/docs-catalog.js.map +1 -0
- package/lib-dist/lib/docs-theme.d.ts +7 -0
- package/lib-dist/lib/docs-theme.d.ts.map +1 -0
- package/lib-dist/lib/docs-theme.js +51 -0
- package/lib-dist/lib/docs-theme.js.map +1 -0
- package/lib-dist/lib/host-runtime.d.ts +5 -0
- package/lib-dist/lib/host-runtime.d.ts.map +1 -0
- package/lib-dist/lib/host-runtime.js +23 -0
- package/lib-dist/lib/host-runtime.js.map +1 -0
- package/lib-dist/lib/host.d.ts +190 -0
- package/lib-dist/lib/host.d.ts.map +1 -0
- package/lib-dist/lib/host.js +2 -0
- package/lib-dist/lib/host.js.map +1 -0
- package/lib-dist/lib/index.d.ts +34 -0
- package/lib-dist/lib/index.d.ts.map +1 -0
- package/lib-dist/lib/index.js +27 -0
- package/lib-dist/lib/index.js.map +1 -0
- package/lib-dist/lib/markdown-model.d.ts +7 -0
- package/lib-dist/lib/markdown-model.d.ts.map +1 -0
- package/lib-dist/lib/markdown-model.js +2031 -0
- package/lib-dist/lib/markdown-model.js.map +1 -0
- package/lib-dist/lib/markdown.d.ts +3 -0
- package/lib-dist/lib/markdown.d.ts.map +1 -0
- package/lib-dist/lib/markdown.js +222 -0
- package/lib-dist/lib/markdown.js.map +1 -0
- package/lib-dist/lib/schema.d.ts +167 -0
- package/lib-dist/lib/schema.d.ts.map +1 -0
- package/lib-dist/lib/schema.js +63 -0
- package/lib-dist/lib/schema.js.map +1 -0
- package/lib-dist/lib/terra/custom-components.d.ts +5 -0
- package/lib-dist/lib/terra/custom-components.d.ts.map +1 -0
- package/lib-dist/lib/terra/custom-components.js +6 -0
- package/lib-dist/lib/terra/custom-components.js.map +1 -0
- package/lib-dist/lib/terra/docs/archive.d.ts +3 -0
- package/lib-dist/lib/terra/docs/archive.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/archive.js +654 -0
- package/lib-dist/lib/terra/docs/archive.js.map +1 -0
- package/lib-dist/lib/terra/docs/assets.d.ts +26 -0
- package/lib-dist/lib/terra/docs/assets.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/assets.js +74 -0
- package/lib-dist/lib/terra/docs/assets.js.map +1 -0
- package/lib-dist/lib/terra/docs/attachments.d.ts +4 -0
- package/lib-dist/lib/terra/docs/attachments.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/attachments.js +5 -0
- package/lib-dist/lib/terra/docs/attachments.js.map +1 -0
- package/lib-dist/lib/terra/docs/editor-dom.d.ts +50 -0
- package/lib-dist/lib/terra/docs/editor-dom.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/editor-dom.js +236 -0
- package/lib-dist/lib/terra/docs/editor-dom.js.map +1 -0
- package/lib-dist/lib/terra/docs/mutations.d.ts +10 -0
- package/lib-dist/lib/terra/docs/mutations.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/mutations.js +105 -0
- package/lib-dist/lib/terra/docs/mutations.js.map +1 -0
- package/lib-dist/lib/terra/docs/navigation.d.ts +6 -0
- package/lib-dist/lib/terra/docs/navigation.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/navigation.js +21 -0
- package/lib-dist/lib/terra/docs/navigation.js.map +1 -0
- package/lib-dist/lib/terra/docs/state.d.ts +186 -0
- package/lib-dist/lib/terra/docs/state.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/state.js +255 -0
- package/lib-dist/lib/terra/docs/state.js.map +1 -0
- package/lib-dist/lib/terra/docs/toolbar.d.ts +11 -0
- package/lib-dist/lib/terra/docs/toolbar.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/toolbar.js +41 -0
- package/lib-dist/lib/terra/docs/toolbar.js.map +1 -0
- package/lib-dist/lib/terra/docs/tree.d.ts +15 -0
- package/lib-dist/lib/terra/docs/tree.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/tree.js +61 -0
- package/lib-dist/lib/terra/docs/tree.js.map +1 -0
- package/lib-dist/lib/terra/docs/workspace.d.ts +396 -0
- package/lib-dist/lib/terra/docs/workspace.d.ts.map +1 -0
- package/lib-dist/lib/terra/docs/workspace.js +923 -0
- package/lib-dist/lib/terra/docs/workspace.js.map +1 -0
- package/lib-dist/lib/terra/flow/_layout.d.ts +30 -0
- package/lib-dist/lib/terra/flow/_layout.d.ts.map +1 -0
- package/lib-dist/lib/terra/flow/_layout.js +63 -0
- package/lib-dist/lib/terra/flow/_layout.js.map +1 -0
- package/lib-dist/lib/terra/flow/powerSource.d.ts +16 -0
- package/lib-dist/lib/terra/flow/powerSource.d.ts.map +1 -0
- package/lib-dist/lib/terra/flow/powerSource.js +65 -0
- package/lib-dist/lib/terra/flow/powerSource.js.map +1 -0
- package/lib-dist/lib/terra/regex.mjs +403 -0
- package/lib-dist/lib/terra/runtime/action-proxy.d.ts +45 -0
- package/lib-dist/lib/terra/runtime/action-proxy.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/action-proxy.js +19 -0
- package/lib-dist/lib/terra/runtime/action-proxy.js.map +1 -0
- package/lib-dist/lib/terra/runtime/content/block-jsx.d.ts +23 -0
- package/lib-dist/lib/terra/runtime/content/block-jsx.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/content/block-jsx.js +225 -0
- package/lib-dist/lib/terra/runtime/content/block-jsx.js.map +1 -0
- package/lib-dist/lib/terra/runtime/content/document-markdown.d.ts +41 -0
- package/lib-dist/lib/terra/runtime/content/document-markdown.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/content/document-markdown.js +536 -0
- package/lib-dist/lib/terra/runtime/content/document-markdown.js.map +1 -0
- package/lib-dist/lib/terra/runtime/content/markdown.d.ts +109 -0
- package/lib-dist/lib/terra/runtime/content/markdown.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/content/markdown.js +428 -0
- package/lib-dist/lib/terra/runtime/content/markdown.js.map +1 -0
- package/lib-dist/lib/terra/runtime/content.d.ts +150 -0
- package/lib-dist/lib/terra/runtime/content.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/content.js +1256 -0
- package/lib-dist/lib/terra/runtime/content.js.map +1 -0
- package/lib-dist/lib/terra/runtime/leaf.d.ts +5 -0
- package/lib-dist/lib/terra/runtime/leaf.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/leaf.js +13 -0
- package/lib-dist/lib/terra/runtime/leaf.js.map +1 -0
- package/lib-dist/lib/terra/runtime/nodes.d.ts +112 -0
- package/lib-dist/lib/terra/runtime/nodes.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/nodes.js +606 -0
- package/lib-dist/lib/terra/runtime/nodes.js.map +1 -0
- package/lib-dist/lib/terra/runtime/runtime.d.ts +31 -0
- package/lib-dist/lib/terra/runtime/runtime.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/runtime.js +86 -0
- package/lib-dist/lib/terra/runtime/runtime.js.map +1 -0
- package/lib-dist/lib/terra/runtime/shared.d.ts +35 -0
- package/lib-dist/lib/terra/runtime/shared.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/shared.js +124 -0
- package/lib-dist/lib/terra/runtime/shared.js.map +1 -0
- package/lib-dist/lib/terra/runtime/types.d.ts +529 -0
- package/lib-dist/lib/terra/runtime/types.d.ts.map +1 -0
- package/lib-dist/lib/terra/runtime/types.js +44 -0
- package/lib-dist/lib/terra/runtime/types.js.map +1 -0
- package/lib-dist/lib/workspace-types.d.ts +29 -0
- package/lib-dist/lib/workspace-types.d.ts.map +1 -0
- package/lib-dist/lib/workspace-types.js +2 -0
- package/lib-dist/lib/workspace-types.js.map +1 -0
- package/lib-dist/style.css +237 -0
- package/package.json +108 -3
- package/src/components/NotFound.astro +6 -0
- package/src/components/NotFound.tsx +48 -0
- package/src/components/SiteLayout.astro +42 -0
- package/src/components/navigation.tsx +48 -0
|
@@ -0,0 +1,1009 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// @ts-nocheck -- source-preserving extraction; public host contracts are typed in src/host.ts.
|
|
3
|
+
/**
|
|
4
|
+
* astro/src/components/flow/_chrome.tsx
|
|
5
|
+
* Shared React Flow presentation primitives.
|
|
6
|
+
*/
|
|
7
|
+
/*//////////////////////////////////////////////////
|
|
8
|
+
IMPORTS
|
|
9
|
+
//////////////////////////////////////////////////*/
|
|
10
|
+
// API
|
|
11
|
+
import { applyEdgeChanges, applyNodeChanges, getSmoothStepPath, useInternalNode, useNodeConnections, useReactFlow, useStore, } from '@xyflow/react';
|
|
12
|
+
import { canonicalId, cn, isNumber, isRec, isString, normArcGraph, resolvedEdges, } from '../../../lib/terra/runtime/runtime.js';
|
|
13
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
14
|
+
import { layoutGraph } from '../../../lib/terra/flow/_layout.js';
|
|
15
|
+
// COMPONENTS
|
|
16
|
+
import { Background, BackgroundVariant, BaseEdge, Controls, EdgeLabelRenderer, Handle, Position as HandlePos, ReactFlow, ReactFlowProvider, } from '@xyflow/react';
|
|
17
|
+
import { Button } from '@terra-symposium/styling/ui/terra-original';
|
|
18
|
+
import { ButtonGroup } from '@terra-symposium/styling/ui/terra-original';
|
|
19
|
+
import { Card, CardDescription } from '@terra-symposium/styling/ui/terra-original';
|
|
20
|
+
import { ErrorBoundary } from '../ui.js';
|
|
21
|
+
import { FitToScreen as FitToScreenIcon, MagicWand as MagicWandIcon, ZoomIn as ZoomInIcon, ZoomOut as ZoomOutIcon, } from '@carbon/icons-react';
|
|
22
|
+
import { Textarea } from '@terra-symposium/styling/ui/terra-original';
|
|
23
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@terra-symposium/styling/ui/terra-original';
|
|
24
|
+
/*//////////////////////////////////////////////////
|
|
25
|
+
CONFIG
|
|
26
|
+
//////////////////////////////////////////////////*/
|
|
27
|
+
/**
|
|
28
|
+
* Signals that the canonical canvas has completed its first fit and layout.
|
|
29
|
+
*
|
|
30
|
+
* @returns The context used to mark the initial layout state.
|
|
31
|
+
*/
|
|
32
|
+
const InitCtx = createContext(false);
|
|
33
|
+
const ARC_PORTS = {
|
|
34
|
+
inbound: ['inbound'],
|
|
35
|
+
outbound: ['default', 'bottom'],
|
|
36
|
+
};
|
|
37
|
+
const CLASS = { meta: 'text-xs opacity-70' };
|
|
38
|
+
const EDGE_LANE = {
|
|
39
|
+
gap: 20,
|
|
40
|
+
minWidth: 112,
|
|
41
|
+
maxWidth: 320,
|
|
42
|
+
appendageGap: 4,
|
|
43
|
+
appendageWidth: 128,
|
|
44
|
+
};
|
|
45
|
+
/*//////////////////////////////////////////////////
|
|
46
|
+
EDITOR
|
|
47
|
+
//////////////////////////////////////////////////*/
|
|
48
|
+
/**
|
|
49
|
+
* Owns generic graph changes while adapters retain domain persistence.
|
|
50
|
+
*
|
|
51
|
+
* @param props - Flow adapter and editability flag.
|
|
52
|
+
* @param adapter - Persistence adapter that reads and writes the graph state.
|
|
53
|
+
* @param disabled - Disabled state controlling whether use editor accepts interaction.
|
|
54
|
+
*
|
|
55
|
+
* @return The current editor state and mutation helpers.
|
|
56
|
+
*/
|
|
57
|
+
export function useEditor({ adapter, disabled = false, }) {
|
|
58
|
+
// STATES
|
|
59
|
+
const [els, setEls] = useState(adapter.read);
|
|
60
|
+
const ref = useRef(els);
|
|
61
|
+
ref.current = els;
|
|
62
|
+
// INIT
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
setEls(adapter.read);
|
|
65
|
+
}, [adapter.read]);
|
|
66
|
+
// HELPERS
|
|
67
|
+
const write = useCallback((n) => {
|
|
68
|
+
ref.current = n;
|
|
69
|
+
setEls(n);
|
|
70
|
+
adapter.write(n);
|
|
71
|
+
}, [adapter]);
|
|
72
|
+
const editable = useCallback((n) => adapter.editableNode?.(n) ?? true, [adapter]);
|
|
73
|
+
const selection = useCallback(() => {
|
|
74
|
+
const nodes = ref.current.nodes.filter((n) => n.selected && editable(n));
|
|
75
|
+
if (!nodes.length)
|
|
76
|
+
return null;
|
|
77
|
+
const ids = new Set(nodes.map((n) => n.id));
|
|
78
|
+
return {
|
|
79
|
+
version: 1,
|
|
80
|
+
nodes,
|
|
81
|
+
edges: ref.current.edges.filter((e) => ids.has(e.source) && ids.has(e.target)),
|
|
82
|
+
};
|
|
83
|
+
}, [editable]);
|
|
84
|
+
const copy = useCallback(() => {
|
|
85
|
+
const val = selection();
|
|
86
|
+
if (!val || !adapter.clipboardKey || typeof window === 'undefined')
|
|
87
|
+
return;
|
|
88
|
+
window.localStorage.setItem(adapter.clipboardKey, JSON.stringify(val));
|
|
89
|
+
}, [adapter.clipboardKey, selection]);
|
|
90
|
+
const deleteSel = useCallback(() => {
|
|
91
|
+
if (disabled)
|
|
92
|
+
return;
|
|
93
|
+
const ids = new Set(ref.current.nodes.filter((n) => n.selected && editable(n)).map((n) => n.id));
|
|
94
|
+
if (!ids.size)
|
|
95
|
+
return;
|
|
96
|
+
write({
|
|
97
|
+
nodes: ref.current.nodes.filter((n) => !ids.has(n.id)),
|
|
98
|
+
edges: ref.current.edges.filter((e) => !ids.has(e.source) && !ids.has(e.target)),
|
|
99
|
+
});
|
|
100
|
+
}, [disabled, editable, write]);
|
|
101
|
+
const cut = useCallback(() => {
|
|
102
|
+
if (disabled)
|
|
103
|
+
return;
|
|
104
|
+
copy();
|
|
105
|
+
deleteSel();
|
|
106
|
+
}, [copy, deleteSel, disabled]);
|
|
107
|
+
const paste = useCallback(() => {
|
|
108
|
+
if (disabled || !adapter.clipboardKey || typeof window === 'undefined')
|
|
109
|
+
return;
|
|
110
|
+
try {
|
|
111
|
+
const raw = JSON.parse(window.localStorage.getItem(adapter.clipboardKey) ?? 'null');
|
|
112
|
+
if (!isRec(raw) ||
|
|
113
|
+
raw.version !== 1 ||
|
|
114
|
+
!Array.isArray(raw.nodes) ||
|
|
115
|
+
!Array.isArray(raw.edges))
|
|
116
|
+
return;
|
|
117
|
+
const val = raw;
|
|
118
|
+
const ids = new Map(val.nodes.map((n) => [n.id, `n-${crypto.randomUUID()}`]));
|
|
119
|
+
write({
|
|
120
|
+
nodes: [
|
|
121
|
+
...ref.current.nodes.map((n) => ({ ...n, selected: false })),
|
|
122
|
+
...val.nodes.map((n) => ({
|
|
123
|
+
...(adapter.cloneNode?.(n, ids.get(n.id)) ?? { ...n, id: ids.get(n.id) }),
|
|
124
|
+
position: { x: n.position.x + 40, y: n.position.y + 40 },
|
|
125
|
+
selected: true,
|
|
126
|
+
})),
|
|
127
|
+
],
|
|
128
|
+
edges: [
|
|
129
|
+
...ref.current.edges,
|
|
130
|
+
...val.edges.map((e) => ({
|
|
131
|
+
...e,
|
|
132
|
+
id: `e-${crypto.randomUUID()}`,
|
|
133
|
+
source: ids.get(e.source),
|
|
134
|
+
target: ids.get(e.target),
|
|
135
|
+
})),
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
// Ignore stale or malformed local clipboard payloads.
|
|
141
|
+
}
|
|
142
|
+
}, [adapter.clipboardKey, disabled, write]);
|
|
143
|
+
const duplicate = useCallback(() => {
|
|
144
|
+
if (disabled)
|
|
145
|
+
return;
|
|
146
|
+
const val = selection();
|
|
147
|
+
if (!val)
|
|
148
|
+
return;
|
|
149
|
+
const ids = new Map(val.nodes.map((n) => [n.id, `n-${crypto.randomUUID()}`]));
|
|
150
|
+
write({
|
|
151
|
+
nodes: [
|
|
152
|
+
...ref.current.nodes.map((n) => ({ ...n, selected: false })),
|
|
153
|
+
...val.nodes.map((n) => ({
|
|
154
|
+
...(adapter.cloneNode?.(n, ids.get(n.id)) ?? { ...n, id: ids.get(n.id) }),
|
|
155
|
+
position: { x: n.position.x + 40, y: n.position.y + 40 },
|
|
156
|
+
selected: true,
|
|
157
|
+
})),
|
|
158
|
+
],
|
|
159
|
+
edges: [
|
|
160
|
+
...ref.current.edges,
|
|
161
|
+
...val.edges.map((e) => ({
|
|
162
|
+
...e,
|
|
163
|
+
id: `e-${crypto.randomUUID()}`,
|
|
164
|
+
source: ids.get(e.source),
|
|
165
|
+
target: ids.get(e.target),
|
|
166
|
+
})),
|
|
167
|
+
],
|
|
168
|
+
});
|
|
169
|
+
}, [adapter, disabled, selection, write]);
|
|
170
|
+
useEffect(() => {
|
|
171
|
+
if (typeof window === 'undefined')
|
|
172
|
+
return;
|
|
173
|
+
/**
|
|
174
|
+
* Handles keydown.
|
|
175
|
+
*
|
|
176
|
+
* @param e - Pointer event received from the flow canvas.
|
|
177
|
+
*/
|
|
178
|
+
const keydown = (e) => {
|
|
179
|
+
if (!(e.metaKey || e.ctrlKey) ||
|
|
180
|
+
e.target instanceof HTMLInputElement ||
|
|
181
|
+
e.target instanceof HTMLTextAreaElement ||
|
|
182
|
+
e.target?.isContentEditable)
|
|
183
|
+
return;
|
|
184
|
+
if (e.key.toLowerCase() === 'c') {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
copy();
|
|
187
|
+
}
|
|
188
|
+
else if (e.key.toLowerCase() === 'x') {
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
cut();
|
|
191
|
+
}
|
|
192
|
+
else if (e.key.toLowerCase() === 'v') {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
paste();
|
|
195
|
+
}
|
|
196
|
+
else if (e.key.toLowerCase() === 'd') {
|
|
197
|
+
e.preventDefault();
|
|
198
|
+
duplicate();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
window.addEventListener('keydown', keydown);
|
|
202
|
+
return () => {
|
|
203
|
+
window.removeEventListener('keydown', keydown);
|
|
204
|
+
};
|
|
205
|
+
}, [copy, cut, duplicate, paste]);
|
|
206
|
+
// RENDER
|
|
207
|
+
return {
|
|
208
|
+
...els,
|
|
209
|
+
selected: els.nodes.filter((n) => n.selected),
|
|
210
|
+
connect: useCallback((c) => {
|
|
211
|
+
if (disabled ||
|
|
212
|
+
!c.source ||
|
|
213
|
+
!c.target ||
|
|
214
|
+
adapter.validConnection?.(c, ref.current) === false)
|
|
215
|
+
return;
|
|
216
|
+
const e = adapter.createEdge?.(c, ref.current) ??
|
|
217
|
+
{
|
|
218
|
+
id: `e-${crypto.randomUUID()}`,
|
|
219
|
+
source: c.source,
|
|
220
|
+
target: c.target,
|
|
221
|
+
sourceHandle: c.sourceHandle,
|
|
222
|
+
targetHandle: c.targetHandle,
|
|
223
|
+
};
|
|
224
|
+
if (e)
|
|
225
|
+
write({ ...ref.current, edges: [...ref.current.edges, e] });
|
|
226
|
+
}, [adapter, disabled, write]),
|
|
227
|
+
copy,
|
|
228
|
+
cut,
|
|
229
|
+
deleteSelection: deleteSel,
|
|
230
|
+
duplicate,
|
|
231
|
+
layout: useCallback(() => {
|
|
232
|
+
if (!disabled && adapter.layout)
|
|
233
|
+
write(adapter.layout(ref.current));
|
|
234
|
+
}, [adapter, disabled, write]),
|
|
235
|
+
onEdgesChange: useCallback((v) => {
|
|
236
|
+
const permitted = disabled ? v.filter((c) => c.type === 'select') : v;
|
|
237
|
+
if (permitted.length)
|
|
238
|
+
write({ ...ref.current, edges: applyEdgeChanges(permitted, ref.current.edges) });
|
|
239
|
+
}, [disabled, write]),
|
|
240
|
+
onNodesChange: useCallback((v) => {
|
|
241
|
+
const permitted = disabled ? v.filter((c) => c.type === 'select') : v;
|
|
242
|
+
if (permitted.length)
|
|
243
|
+
write({ ...ref.current, nodes: applyNodeChanges(permitted, ref.current.nodes) });
|
|
244
|
+
}, [disabled, write]),
|
|
245
|
+
onSelectionChange: useCallback((v) => {
|
|
246
|
+
write({
|
|
247
|
+
...ref.current,
|
|
248
|
+
nodes: ref.current.nodes.map((n) => ({
|
|
249
|
+
...n,
|
|
250
|
+
selected: new Set(v.map((n) => n.id)).has(n.id),
|
|
251
|
+
})),
|
|
252
|
+
});
|
|
253
|
+
}, [write]),
|
|
254
|
+
paste,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/*//////////////////////////////////////////////////
|
|
258
|
+
LAYOUT
|
|
259
|
+
//////////////////////////////////////////////////*/
|
|
260
|
+
/**
|
|
261
|
+
* Reads a persisted custom position from node data when one is available.
|
|
262
|
+
*
|
|
263
|
+
* @param n - Node-like value with optional custom position metadata.
|
|
264
|
+
*
|
|
265
|
+
* @return The stored position when it is valid, otherwise `undefined`.
|
|
266
|
+
*/
|
|
267
|
+
export function getCustomPos(n) {
|
|
268
|
+
if (!isRec(n.data) || !('customPosition' in n.data))
|
|
269
|
+
return;
|
|
270
|
+
const point = n.data.customPosition;
|
|
271
|
+
return isRec(point) && isNumber(point.x) && isNumber(point.y)
|
|
272
|
+
? { x: point.x, y: point.y }
|
|
273
|
+
: undefined;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Resolves a node's structural group id from its parent or embedded data.
|
|
277
|
+
*
|
|
278
|
+
* @param n - Node-like value with optional parent metadata.
|
|
279
|
+
*
|
|
280
|
+
* @return The resolved group id when present, otherwise `undefined`.
|
|
281
|
+
*/
|
|
282
|
+
export function getGroupId(n) {
|
|
283
|
+
return n.parentId || (isRec(n.data) && isString(n.data.groupId) ? n.data.groupId : undefined);
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Measures a flow node using persisted dimensions, runtime measurements, or defaults.
|
|
287
|
+
*
|
|
288
|
+
* @param n - Node whose size is being resolved.
|
|
289
|
+
* @param defaults - Fallback dimensions used when the node has not been measured.
|
|
290
|
+
* @param extraHeight - Optional height override for nodes with dynamic content.
|
|
291
|
+
*
|
|
292
|
+
* @return The computed width and height used by layout.
|
|
293
|
+
*/
|
|
294
|
+
export function getNodeSize(n, defaults = {
|
|
295
|
+
width: 175,
|
|
296
|
+
height: 60,
|
|
297
|
+
groupWidth: 160,
|
|
298
|
+
groupHeight: 100,
|
|
299
|
+
erdWidth: 224,
|
|
300
|
+
erdHeight: 60,
|
|
301
|
+
}, extraHeight) {
|
|
302
|
+
const style = isRec(n.style) ? n.style : {};
|
|
303
|
+
const width = Number(n.measured?.width ??
|
|
304
|
+
style.width ??
|
|
305
|
+
(n.type === 'group'
|
|
306
|
+
? (defaults.groupWidth ?? defaults.width)
|
|
307
|
+
: n.type === 'erd'
|
|
308
|
+
? (defaults.erdWidth ?? defaults.width)
|
|
309
|
+
: defaults.width));
|
|
310
|
+
const height = extraHeight?.(n) ??
|
|
311
|
+
Number(n.measured?.height ??
|
|
312
|
+
style.height ??
|
|
313
|
+
(n.type === 'group' ? (defaults.groupHeight ?? defaults.height) : defaults.height));
|
|
314
|
+
return {
|
|
315
|
+
w: Number.isFinite(width) ? width : defaults.width,
|
|
316
|
+
h: Number.isFinite(height) ? height : defaults.height,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Creates the stable Arc layout used by both the editor and read-only canvas.
|
|
321
|
+
*
|
|
322
|
+
* @param customLayout - Optional host layout override.
|
|
323
|
+
*
|
|
324
|
+
* @return A layout callback for Arc nodes.
|
|
325
|
+
*/
|
|
326
|
+
export function useArcNodeLayout(customLayout) {
|
|
327
|
+
return useCallback((n, e) => {
|
|
328
|
+
if (customLayout)
|
|
329
|
+
return customLayout(n, e);
|
|
330
|
+
if (!n.length)
|
|
331
|
+
return n;
|
|
332
|
+
const sizeByType = {
|
|
333
|
+
content: { w: 208, h: 92 },
|
|
334
|
+
group: { w: 240, h: 160 },
|
|
335
|
+
default: { w: 160, h: 72 },
|
|
336
|
+
};
|
|
337
|
+
const getSize = (node) => {
|
|
338
|
+
const type = isRec(node.data) && isString(node.data.graphType) ? node.data.graphType : 'default';
|
|
339
|
+
return Object.hasOwn(sizeByType, type) ? sizeByType[type] : sizeByType.default;
|
|
340
|
+
};
|
|
341
|
+
return layoutGraph(n, e, 'TB', 32, 56, {
|
|
342
|
+
getSize,
|
|
343
|
+
placeNode: (node, dagreNode) => {
|
|
344
|
+
const size = getSize(node);
|
|
345
|
+
return {
|
|
346
|
+
...node,
|
|
347
|
+
position: { x: (dagreNode?.x ?? 0) - size.w / 2, y: (dagreNode?.y ?? 0) - size.h / 2 },
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
}).positionedNodes;
|
|
351
|
+
}, [customLayout]);
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Lays out a graph with Dagre and reprojects the result back to the node model.
|
|
355
|
+
*
|
|
356
|
+
* @param nodes - Nodes to position.
|
|
357
|
+
* @param edges - Graph connections rendered and updated by layout graph.
|
|
358
|
+
* @param direction - Layout direction that arranges layout graph's graph.
|
|
359
|
+
* @param nodeSep - Spacing between nodes on the same rank.
|
|
360
|
+
* @param rankSep - Spacing between ranks.
|
|
361
|
+
* @param opts - Layout hooks that adapt the generic Dagre result to the caller's node model.
|
|
362
|
+
*
|
|
363
|
+
* @returns Positioned nodes and the resulting graph height.
|
|
364
|
+
*/
|
|
365
|
+
export { layoutGraph } from '../../../lib/terra/flow/_layout.js';
|
|
366
|
+
/*//////////////////////////////////////////////////
|
|
367
|
+
NODE CHROME
|
|
368
|
+
//////////////////////////////////////////////////*/
|
|
369
|
+
/**
|
|
370
|
+
* Renders all handles for a node based on editability and required directions.
|
|
371
|
+
*
|
|
372
|
+
* @param props - Editable state and source/target handle positions that determine which connection points are active.
|
|
373
|
+
* @param sources - Required source handle directions.
|
|
374
|
+
* @param tgts - Required target handle directions.
|
|
375
|
+
* @param editable - Editability flag controlling whether handles accepts changes.
|
|
376
|
+
*
|
|
377
|
+
* @return The full handle set for a node.
|
|
378
|
+
*/
|
|
379
|
+
export function Handles({ editable = false, sources: srcs = [], tgts = [], }) {
|
|
380
|
+
return (_jsx(ErrorBoundary, { name: "Handles", children: ['target', 'source'].map((t) => [
|
|
381
|
+
{ id: 'top', pos: HandlePos.Top },
|
|
382
|
+
{ id: 'right', pos: HandlePos.Right },
|
|
383
|
+
{ id: 'bottom', pos: HandlePos.Bottom },
|
|
384
|
+
{ id: 'left', pos: HandlePos.Left },
|
|
385
|
+
].map((p) => (_jsx(Port, { id: p.id, type: t, position: p.pos, style: {
|
|
386
|
+
opacity: editable || (t === 'target' ? tgts : srcs).includes(p.id) ? 1 : 0,
|
|
387
|
+
pointerEvents: editable ? 'auto' : 'none',
|
|
388
|
+
} }, `${t}-${p.id}`)))) }));
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Renders a single styled React Flow handle with an optional tooltip.
|
|
392
|
+
*
|
|
393
|
+
* @param props - Handle identifier, direction, position, accessibility label, connectability, visibility, styling, and visual variant.
|
|
394
|
+
* @param ariaLabel - Accessible label for the handle.
|
|
395
|
+
* @param className - Extra classes applied to the handle.
|
|
396
|
+
* @param hidden - Hidden input supplied to port's operation.
|
|
397
|
+
* @param id - Handle identifier.
|
|
398
|
+
* @param isConnectable - Boolean flag controlling port's is connectable behaviour.
|
|
399
|
+
* @param position - Handle position around the node.
|
|
400
|
+
* @param style - Inline style values merged into port.
|
|
401
|
+
* @param title - Optional tooltip text.
|
|
402
|
+
* @param type - Handle direction.
|
|
403
|
+
* @param variant - Visual variant controlling port's presentation.
|
|
404
|
+
*
|
|
405
|
+
* @return A styled React Flow handle or a tooltip-wrapped handle.
|
|
406
|
+
*/
|
|
407
|
+
function Port({ ariaLabel, className, hidden = false, id, isConnectable, position: pos, style, title, type, variant = 'default', }) {
|
|
408
|
+
const choice = variant === 'choice';
|
|
409
|
+
const size = choice ? 12 : 8;
|
|
410
|
+
const handle = (_jsx(Handle, { type: type, position: pos, className: cn('flow-node-handle shadow-sm', className), style: {
|
|
411
|
+
...style,
|
|
412
|
+
boxSizing: 'border-box',
|
|
413
|
+
width: size,
|
|
414
|
+
height: size,
|
|
415
|
+
minWidth: size,
|
|
416
|
+
minHeight: size,
|
|
417
|
+
maxWidth: size,
|
|
418
|
+
maxHeight: size,
|
|
419
|
+
border: `2px solid ${choice ? '#f97316' : '#000'}`,
|
|
420
|
+
borderRadius: 0,
|
|
421
|
+
background: choice ? '#f97316' : '#000',
|
|
422
|
+
opacity: hidden ? 0 : style?.opacity,
|
|
423
|
+
pointerEvents: hidden ? 'none' : (style?.pointerEvents ?? 'auto'),
|
|
424
|
+
...(choice ? { clipPath: 'polygon(50% 0, 100% 50%, 50% 100%, 0 50%)' } : {}),
|
|
425
|
+
}, id: id, ...(ariaLabel ? { 'aria-label': ariaLabel } : {}), ...(isConnectable !== undefined ? { isConnectable } : {}) }));
|
|
426
|
+
return title ? (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: handle }), _jsx(TooltipContent, { size: "sm", children: title })] })) : (handle);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Renders the compact skeleton card used while a flow is resolving.
|
|
430
|
+
*
|
|
431
|
+
* @param props - Polymorphic card props.
|
|
432
|
+
* @param as - As input supplied to skeleton card's operation.
|
|
433
|
+
* @param className - Additional CSS classes merged into skeleton card.
|
|
434
|
+
* @param style - Inline style values merged into skeleton card.
|
|
435
|
+
*
|
|
436
|
+
* @return The loading skeleton card.
|
|
437
|
+
*/
|
|
438
|
+
export function SkeletonCard({ as = 'div', className, style, ...props }) {
|
|
439
|
+
const Element = as;
|
|
440
|
+
return (_jsx(ErrorBoundary, { name: "SkeletonCard", children: _jsxs(Element, { ...props, className: cn('relative flex h-16 items-center justify-center overflow-visible rounded-md border-2 px-3 py-2 shadow-sm', className), style: { backgroundColor: '#eaf8f9', borderColor: '#16899d', width: 208, ...style }, children: [_jsx("div", { className: "absolute left-1/2 top-0 z-10 h-2 w-6 -translate-x-1/2 -translate-y-1/2 rounded-full border shadow-sm", style: { backgroundColor: '#f7ffff', borderColor: '#16899d' } }), _jsxs("div", { className: "flex w-full animate-pulse flex-col items-center gap-2", children: [_jsx("div", { className: "h-4 w-[92%] rounded-md", style: { backgroundColor: '#5db9c6' } }), _jsx("div", { className: "mr-2 h-2.5 w-20 rounded-md", style: { backgroundColor: '#91d3db' } })] })] }) }));
|
|
441
|
+
}
|
|
442
|
+
/** Provides the common card, title, and metadata treatment for every Arc graph host. */
|
|
443
|
+
const DEFAULT_SKIN = {
|
|
444
|
+
Card: ({ children, className, onClick, selected, style, tone = 'default' }) => (_jsx(Card, { onClick: onClick, size: "sm", style: { overflow: 'visible', ...style }, className: cn('relative min-w-36 !overflow-visible !rounded !p-3 shadow-sm', {
|
|
445
|
+
caution: 'border-amber-500 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-100',
|
|
446
|
+
critical: 'border-red-500 bg-red-50 text-red-900 dark:border-red-800 dark:bg-red-950 dark:text-red-100',
|
|
447
|
+
default: 'border-primary-6 bg-primary-1 text-primary-12',
|
|
448
|
+
positive: 'border-green-600 bg-green-50 text-green-900 dark:border-green-700 dark:bg-green-950 dark:text-green-100',
|
|
449
|
+
primary: 'border-primary-7 bg-primary-2 text-primary-12',
|
|
450
|
+
}[tone], selected && 'ring-2 ring-primary-8', className), children: children })),
|
|
451
|
+
Input: (props) => _jsx(Textarea, { ...props }),
|
|
452
|
+
Text: ({ children, className }) => (_jsx(CardDescription, { className: className, children: children })),
|
|
453
|
+
};
|
|
454
|
+
const SkinCtx = createContext(DEFAULT_SKIN);
|
|
455
|
+
/**
|
|
456
|
+
* Returns the active workspace rendering skin.
|
|
457
|
+
*
|
|
458
|
+
* @return The current flow skin.
|
|
459
|
+
*/
|
|
460
|
+
function useSkin() {
|
|
461
|
+
return useContext(SkinCtx);
|
|
462
|
+
}
|
|
463
|
+
export { useEditor as useFlowEditor };
|
|
464
|
+
/**
|
|
465
|
+
* Compares two string arrays for element equality.
|
|
466
|
+
*
|
|
467
|
+
* @param a - First sequence of node or edge identifiers to compare.
|
|
468
|
+
* @param b - Second sequence whose length and elements must match the first.
|
|
469
|
+
*
|
|
470
|
+
* @return True when both arrays have equal length and matching string elements.
|
|
471
|
+
*/
|
|
472
|
+
function isArrayEqual(a, b) {
|
|
473
|
+
return a.length === b.length && a.every((v, i) => v === b[i]);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Renders the common Arc logic body through the active workspace skin.
|
|
477
|
+
*
|
|
478
|
+
* @param props - Flow node props.
|
|
479
|
+
* @param data - Logic node data.
|
|
480
|
+
*
|
|
481
|
+
* @return The rendered logic node body.
|
|
482
|
+
*/
|
|
483
|
+
export function LogicNode({ id, data }) {
|
|
484
|
+
const skin = useSkin();
|
|
485
|
+
const type = data.graphType ?? 'function';
|
|
486
|
+
const detail = type === 'function'
|
|
487
|
+
? data.function?.type
|
|
488
|
+
: type === 'condition'
|
|
489
|
+
? data.condition?.type
|
|
490
|
+
: undefined;
|
|
491
|
+
// prettier-ignore
|
|
492
|
+
return _jsx(ErrorBoundary, { name: 'LogicNode', children: _jsxs(skin.Card, { className: cn('flex flex-col justify-center', (type === 'origin' || type === 'terminal') && 'items-center rounded-full text-center'), style: { ... /* prettier-ignore */(type === 'origin' ? { background: '#f0fdf4', borderColor: '#16a34a', color: '#14532d' }
|
|
493
|
+
: type === 'terminal' ? { background: '#fef2f2', borderColor: '#ef4444', color: '#7f1d1d' }
|
|
494
|
+
: type === 'condition' ? { background: '#fffbeb', borderColor: '#f59e0b', color: '#78350f' }
|
|
495
|
+
: { background: '#eff6ff', borderColor: '#3b82f6', color: '#172554' }), height: 72, width: 160 }, tone: (type === 'origin' ? 'positive' : type === 'terminal' ? 'critical' : type === 'condition' ? 'caution' : 'primary'), children: [type !== 'origin' && ARC_PORTS.inbound.map(i => _jsx(Port, { id: i, type: 'target', position: HandlePos.Top, ariaLabel: 'Incoming route', title: 'Incoming route', isConnectable: type !== 'terminal' }, i)), _jsx("strong", { className: 'block w-full truncate whitespace-nowrap', children: type.slice(0, 1).toUpperCase() + type.slice(1) }), detail && _jsx(skin.Text, { className: CLASS.meta, children: detail }), Array.from(new Set([...ARC_PORTS.outbound, ...useStore(s => s.edges.filter(e => e.source === id).map(e => e.sourceHandle ?? 'default'), isArrayEqual)])).map(i => type === 'terminal' ? null : _jsx(Port, { id: i, type: 'source', position: HandlePos.Bottom, hidden: type === 'origin' || i === 'bottom', isConnectable: type !== 'origin' }, i))] }) });
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Supplies the standard React Flow control panel with Carbon icons.
|
|
499
|
+
*
|
|
500
|
+
* @param props - Panel position and disable flag.
|
|
501
|
+
* @param position - React Flow control-panel placement.
|
|
502
|
+
* @param disabled - Disabled state controlling whether zoom controls accepts interaction.
|
|
503
|
+
*
|
|
504
|
+
* @return The zoom control cluster.
|
|
505
|
+
*/
|
|
506
|
+
export function ZoomControls({ position: pos, disabled = false, }) {
|
|
507
|
+
const { fitView, zoomIn, zoomOut } = useReactFlow();
|
|
508
|
+
return (_jsx(ErrorBoundary, { name: "ZoomControls", children: _jsx(Controls, { position: pos, showZoom: false, showFitView: false, showInteractive: false, children: _jsx(ButtonGroup, { children: [
|
|
509
|
+
{ label: 'Zoom in', icon: _jsx(ZoomInIcon, { "aria-hidden": "true" }), onClick: zoomIn },
|
|
510
|
+
{ label: 'Zoom out', icon: _jsx(ZoomOutIcon, { "aria-hidden": "true" }), onClick: zoomOut },
|
|
511
|
+
{ label: 'Fit view', icon: _jsx(FitToScreenIcon, { "aria-hidden": "true" }), onClick: fitView },
|
|
512
|
+
].map(({ label: l, icon: i, onClick: o }) => (_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": l, title: l, disabled: disabled, onClick: () => void o(), children: i }, l))) }) }) }));
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Renders the shared floating context menu shell used by flow hosts.
|
|
516
|
+
*
|
|
517
|
+
* @param props - Menu state and content.
|
|
518
|
+
* @param state - Current menu position and visibility.
|
|
519
|
+
* @param children - Menu contents rendered inside the shell.
|
|
520
|
+
*
|
|
521
|
+
* @return The floating context menu when visible, otherwise `null`.
|
|
522
|
+
*/
|
|
523
|
+
function FloatingMenu({ state, children, }) {
|
|
524
|
+
if (!state.show)
|
|
525
|
+
return null;
|
|
526
|
+
// prettier-ignore
|
|
527
|
+
return (_jsx(Card, { className: 'fixed z-50', style: { left: state.x, top: state.y }, children: children }));
|
|
528
|
+
}
|
|
529
|
+
export { FloatingMenu as FlowContextMenu };
|
|
530
|
+
/*//////////////////////////////////////////////////
|
|
531
|
+
LOADING
|
|
532
|
+
//////////////////////////////////////////////////*/
|
|
533
|
+
/**
|
|
534
|
+
* Renders the loading affordance shown while a model adapter resolves graph state.
|
|
535
|
+
*
|
|
536
|
+
* @return The shared loading skeleton.
|
|
537
|
+
*/
|
|
538
|
+
export function Skeleton() {
|
|
539
|
+
return (_jsx(ErrorBoundary, { name: "Skeleton", children: _jsx("div", { className: "flex w-full items-center justify-center", style: { minHeight: 'calc(100vh - 20rem)' }, children: _jsxs("div", { className: "flex animate-pulse flex-col items-center gap-8", children: [_jsx(SkeletonCard, {}), _jsx(SkeletonCard, { className: "translate-x-16 opacity-70" }), _jsx(SkeletonCard, { className: "-translate-x-12 opacity-40" })] }) }) }));
|
|
540
|
+
}
|
|
541
|
+
/*//////////////////////////////////////////////////
|
|
542
|
+
ARC ADAPTER
|
|
543
|
+
//////////////////////////////////////////////////*/
|
|
544
|
+
/**
|
|
545
|
+
* Serializes an Arc flow canvas back into the graph model.
|
|
546
|
+
*
|
|
547
|
+
* @param flow - Flow canvas state.
|
|
548
|
+
* @param prev - Prev input supplied to arc graph from's operation.
|
|
549
|
+
*
|
|
550
|
+
* @return The serialized Arc graph.
|
|
551
|
+
*/
|
|
552
|
+
export function arcGraphFrom(flow, prev) {
|
|
553
|
+
return {
|
|
554
|
+
nodes: flow.nodes.map((n) => {
|
|
555
|
+
const prior = new Map(prev.nodes.map((i) => [i._key, i])).get(n.data.graphKey);
|
|
556
|
+
const type = n.data.graphType ||
|
|
557
|
+
(n.type === 'decision'
|
|
558
|
+
? 'function'
|
|
559
|
+
: n.type === 'origin' || n.type === 'terminal'
|
|
560
|
+
? n.type
|
|
561
|
+
: 'content');
|
|
562
|
+
const published = isRec(n.data.published) && isString(n.data.published._id)
|
|
563
|
+
? n.data.published._id
|
|
564
|
+
: undefined;
|
|
565
|
+
return {
|
|
566
|
+
...(prior ?? {}),
|
|
567
|
+
_key: n.data.graphKey || n.id,
|
|
568
|
+
type,
|
|
569
|
+
position: { ...n.position, ...(n.data.hierarchy ? { row: n.data.hierarchy.row } : {}) },
|
|
570
|
+
...(n.data.title ? { title: n.data.title } : {}),
|
|
571
|
+
...(n.parentId ? { parentId: n.parentId } : {}),
|
|
572
|
+
...(isRec(n.style)
|
|
573
|
+
? {
|
|
574
|
+
style: {
|
|
575
|
+
...(isNumber(n.style.width) ? { width: n.style.width } : {}),
|
|
576
|
+
...(isNumber(n.style.height) ? { height: n.style.height } : {}),
|
|
577
|
+
},
|
|
578
|
+
}
|
|
579
|
+
: {}),
|
|
580
|
+
...(prior?.problem || n.data.problemId || published
|
|
581
|
+
? {
|
|
582
|
+
problem: prior?.problem || {
|
|
583
|
+
_type: 'reference',
|
|
584
|
+
_ref: n.data.problemId || published || '',
|
|
585
|
+
},
|
|
586
|
+
}
|
|
587
|
+
: {}),
|
|
588
|
+
...(n.data.hidden ? { hidden: true } : {}),
|
|
589
|
+
...(type === 'function' && !prior?.function
|
|
590
|
+
? { function: { type: 'appendPrefix', value: '' } }
|
|
591
|
+
: {}),
|
|
592
|
+
...(type === 'condition' && !prior?.condition
|
|
593
|
+
? { condition: { type: 'random', weights: [] } }
|
|
594
|
+
: {}),
|
|
595
|
+
};
|
|
596
|
+
}),
|
|
597
|
+
edges: flow.edges.map((e) => ({
|
|
598
|
+
_key: e.id,
|
|
599
|
+
source: e.source,
|
|
600
|
+
target: e.target,
|
|
601
|
+
...(new Map(flow.nodes.map((n) => [n.id, n.data.graphType])).get(e.source) === 'content' &&
|
|
602
|
+
e.sourceHandle &&
|
|
603
|
+
!(
|
|
604
|
+
/*
|
|
605
|
+
* Lists the canonical flow handle positions used across the shared primitives.
|
|
606
|
+
*
|
|
607
|
+
* @returns The ordered handle names used by the flow canvas.
|
|
608
|
+
*/ ['top', 'right', 'bottom', 'left'].includes(e.sourceHandle))
|
|
609
|
+
? { handle: e.sourceHandle }
|
|
610
|
+
: {}),
|
|
611
|
+
...(e.data?.functions?.length
|
|
612
|
+
? { functions: e.data.functions }
|
|
613
|
+
: {}),
|
|
614
|
+
})),
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Renders the shared Arc canvas while hosts provide only policy and persistence callbacks.
|
|
619
|
+
*
|
|
620
|
+
* @param props - Arc elements, node renderers, layout function, labels, duration/hierarchy settings, and graph interaction callbacks.
|
|
621
|
+
* @param elements - Graph elements supplied to arc canvas for layout and rendering.
|
|
622
|
+
* @param annotationNodeTypes - Annotation node renderers available to arc canvas.
|
|
623
|
+
* @param arrangeIcon - Arrange icon input supplied to arc canvas's operation.
|
|
624
|
+
* @param editable - Editability flag controlling whether arc canvas accepts changes.
|
|
625
|
+
* @param readOnly - Editability flag that prevents graph mutations in arc canvas.
|
|
626
|
+
* @param onArrange - Callback invoked for arrange.
|
|
627
|
+
* @param onConnect - Callback invoked with a new connection created in arc canvas.
|
|
628
|
+
* @param onEdgesChange - Callback invoked with the updated edge changes from arc canvas.
|
|
629
|
+
* @param onInit - Callback invoked for init.
|
|
630
|
+
* @param onNodeClick - Callback invoked when a user selects a node in arc canvas.
|
|
631
|
+
* @param onNodeContextMenu - Callback invoked for node context menu.
|
|
632
|
+
* @param onNodesChange - Callback invoked with the updated node changes from arc canvas.
|
|
633
|
+
* @param onPaneContextMenu - Callback invoked for pane context menu.
|
|
634
|
+
* @param onProblemOpen - Callback invoked for problem open.
|
|
635
|
+
* @param onProblemTitleChange - Callback invoked for problem title change.
|
|
636
|
+
* @param onReady - Callback invoked when arc canvas finishes initialising its graph surface.
|
|
637
|
+
* @param onResizeEnd - Callback invoked for resize end.
|
|
638
|
+
*
|
|
639
|
+
* @return The shared Arc canvas.
|
|
640
|
+
*/
|
|
641
|
+
export function ArcCanvas({ elements: els, annotationNodeTypes, arrangeIcon = _jsx(MagicWandIcon, { "aria-hidden": "true" }), arrangeLabel = 'Arrange nodes', editable = false, layoutNodes, readOnly = false, showDuration = true, showHierarchyControls = true, onArrange, onConnect, onEdgesChange, onInit, onNodeClick, onNodeContextMenu: onNodeCtxMenu, onNodesChange, onPaneContextMenu: onPaneCtxMenu, onProblemOpen, onProblemTitleChange, onReady, onResizeEnd, }) {
|
|
642
|
+
// STATES
|
|
643
|
+
const arrangeNodes = useArcNodeLayout(layoutNodes);
|
|
644
|
+
// prettier-ignore
|
|
645
|
+
const topology = useMemo(() => JSON.stringify({ edges: els.edges.map(e => [e.id, e.source, e.sourceHandle, e.target]), nodes: els.nodes.map(n => [n.id, n.data.graphType, n.data.hierarchy?.row]) }), [els.edges, els.nodes]);
|
|
646
|
+
const layout = useRef(topology);
|
|
647
|
+
const [nodes, setNodes] = useState(() => arrangeNodes(els.nodes, els.edges));
|
|
648
|
+
// INIT
|
|
649
|
+
useEffect(() => {
|
|
650
|
+
setNodes((c) => {
|
|
651
|
+
if (layout.current !== topology) {
|
|
652
|
+
layout.current = topology;
|
|
653
|
+
return arrangeNodes(els.nodes, els.edges);
|
|
654
|
+
}
|
|
655
|
+
return els.nodes.map((n) => ({
|
|
656
|
+
...n,
|
|
657
|
+
position: new Map(c.map((n) => [n.id, n.position])).get(n.id) ?? n.position,
|
|
658
|
+
}));
|
|
659
|
+
});
|
|
660
|
+
}, [arrangeNodes, els.edges, els.nodes, topology]);
|
|
661
|
+
// HELPERS
|
|
662
|
+
// INIT
|
|
663
|
+
useEffect(() => {
|
|
664
|
+
return ((frame) => () => cancelAnimationFrame(frame))(requestAnimationFrame(() => onReady?.()));
|
|
665
|
+
}, [onReady]);
|
|
666
|
+
// RENDER
|
|
667
|
+
return (_jsx(ErrorBoundary, { name: "ArcCanvas", children: _jsx(ReactFlowProvider, { children: _jsx(TooltipProvider, { delayDuration: 120, children: _jsx(SkinCtx.Provider, { value: DEFAULT_SKIN, children: _jsx(InitCtx.Provider, { value: true, children: _jsxs(ReactFlow, { nodes: nodes
|
|
668
|
+
.filter((n) => !n.data.hidden)
|
|
669
|
+
.map((n) => ({
|
|
670
|
+
...n,
|
|
671
|
+
data: {
|
|
672
|
+
...n.data,
|
|
673
|
+
editable,
|
|
674
|
+
readOnly,
|
|
675
|
+
showDuration,
|
|
676
|
+
showHierarchyControls,
|
|
677
|
+
...(n.data.graphType === 'content'
|
|
678
|
+
? {
|
|
679
|
+
onOpen: () => n.data.problem && onProblemOpen?.(n.data.problem),
|
|
680
|
+
onTitleChange: (title) => onProblemTitleChange?.(n.id, title),
|
|
681
|
+
}
|
|
682
|
+
: {}),
|
|
683
|
+
...(n.data.hierarchy
|
|
684
|
+
? {
|
|
685
|
+
hierarchy: {
|
|
686
|
+
...n.data.hierarchy,
|
|
687
|
+
onChange: (pos) => onNodesChange?.([
|
|
688
|
+
{
|
|
689
|
+
id: n.id,
|
|
690
|
+
type: 'replace',
|
|
691
|
+
item: {
|
|
692
|
+
...n,
|
|
693
|
+
data: {
|
|
694
|
+
...n.data,
|
|
695
|
+
hierarchy: { ...n.data.hierarchy, ...pos },
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
]),
|
|
700
|
+
},
|
|
701
|
+
}
|
|
702
|
+
: {}),
|
|
703
|
+
...(n.data.graphType === 'group' || n.data.graphType === 'note'
|
|
704
|
+
? {
|
|
705
|
+
onResizeEnd: (_id, params) => onResizeEnd?.(n.id, params),
|
|
706
|
+
}
|
|
707
|
+
: {}),
|
|
708
|
+
},
|
|
709
|
+
})), edges: els.edges, nodeTypes: useMemo(() => ({
|
|
710
|
+
group: annotationNodeTypes?.group,
|
|
711
|
+
logicNode: LogicNode,
|
|
712
|
+
note: annotationNodeTypes?.note,
|
|
713
|
+
problemNode: ProblemNode,
|
|
714
|
+
}), [annotationNodeTypes]), edgeTypes: { custom: ArcEdge }, onInit: (i) => {
|
|
715
|
+
onInit?.(i);
|
|
716
|
+
requestAnimationFrame(() => {
|
|
717
|
+
void i.fitView({ padding: 0.1, duration: 50 });
|
|
718
|
+
});
|
|
719
|
+
}, onNodesChange: useCallback((c) => {
|
|
720
|
+
if (!onNodesChange)
|
|
721
|
+
return;
|
|
722
|
+
setNodes((s) => applyNodeChanges(c, s));
|
|
723
|
+
onNodesChange(c);
|
|
724
|
+
}, [onNodesChange]), ...(onEdgesChange ? { onEdgesChange } : {}), ...(onConnect
|
|
725
|
+
? {
|
|
726
|
+
onConnect: (connection) => onConnect({ ...connection, targetHandle: 'inbound' }),
|
|
727
|
+
}
|
|
728
|
+
: {}), ...(onNodeClick ? { onNodeClick } : {}), ...(onNodeCtxMenu ? { onNodeContextMenu: onNodeCtxMenu } : {}), ...(onPaneCtxMenu ? { onPaneContextMenu: onPaneCtxMenu } : {}), fitView: true, minZoom: 0.1, proOptions: { hideAttribution: true }, panOnScroll: true, panOnDrag: false, zoomOnScroll: false, selectionOnDrag: editable, nodesDraggable: editable, nodesConnectable: editable, elementsSelectable: editable, children: [onArrange && (_jsx(Controls, { position: "top-right", showFitView: false, showInteractive: false, showZoom: false, children: _jsx(ButtonGroup, { children: _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": arrangeLabel, title: arrangeLabel, onClick: () => {
|
|
729
|
+
setNodes(arrangeNodes(els.nodes, els.edges));
|
|
730
|
+
onArrange?.();
|
|
731
|
+
}, children: arrangeIcon }) }) })), _jsx(ZoomControls, { position: "bottom-right" }), _jsx(Background, { variant: BackgroundVariant.Dots })] }) }) }) }) }) }));
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Expands a persisted Arc into the one canonical node and edge projection.
|
|
735
|
+
*
|
|
736
|
+
* @param graph - Persisted Arc graph to expand.
|
|
737
|
+
* @param problems - Problems input supplied to arc canvas elements's operation.
|
|
738
|
+
* @param edgeData - Optional mapper that builds rendered edge metadata from a persisted edge and its source problem.
|
|
739
|
+
*
|
|
740
|
+
* @return The canonical canvas elements.
|
|
741
|
+
*/
|
|
742
|
+
export function arcCanvasElements(graph, problems, edgeData) {
|
|
743
|
+
const norm = normArcGraph(graph);
|
|
744
|
+
const byId = new Map(problems.map((p) => [canonicalId(p._id), p]));
|
|
745
|
+
return {
|
|
746
|
+
nodes: norm.nodes.map((n) => {
|
|
747
|
+
const problem = n.problem?._ref ? byId.get(canonicalId(n.problem._ref)) : undefined;
|
|
748
|
+
return {
|
|
749
|
+
id: n._key,
|
|
750
|
+
position: n.position ?? { x: 0, y: 0 },
|
|
751
|
+
type: n.type === 'content'
|
|
752
|
+
? 'problemNode'
|
|
753
|
+
: n.type === 'group' || n.type === 'note'
|
|
754
|
+
? n.type
|
|
755
|
+
: 'logicNode',
|
|
756
|
+
...(n.parentId ? { parentId: n.parentId } : {}),
|
|
757
|
+
...(n.style ? { style: n.style } : {}),
|
|
758
|
+
draggable: n.type !== 'origin' && n.type !== 'terminal' && !(n.position && 'row' in n.position),
|
|
759
|
+
selectable: n.type !== 'origin' && n.type !== 'terminal',
|
|
760
|
+
data: {
|
|
761
|
+
graphKey: n._key,
|
|
762
|
+
graphType: n.type,
|
|
763
|
+
title: n.type === 'content'
|
|
764
|
+
? problem?.title || 'Problem'
|
|
765
|
+
: n.title ||
|
|
766
|
+
(n.type === 'group'
|
|
767
|
+
? 'Container'
|
|
768
|
+
: n.type === 'note'
|
|
769
|
+
? 'Sticky note'
|
|
770
|
+
: n.type.slice(0, 1).toUpperCase() + n.type.slice(1)),
|
|
771
|
+
...(n.type === 'group' || n.type === 'note' ? { editable: true, id: n._key } : {}),
|
|
772
|
+
...(n.type === 'content'
|
|
773
|
+
? {
|
|
774
|
+
problem: {
|
|
775
|
+
id: n.problem?._ref ?? n._key,
|
|
776
|
+
...(problem?.title ? { title: problem.title } : {}),
|
|
777
|
+
...(problem?.duration !== undefined ? { duration: problem.duration } : {}),
|
|
778
|
+
...(problem?.choice?.opts || problem?.choice?.options
|
|
779
|
+
? {
|
|
780
|
+
choices: (problem.choice.opts?.length
|
|
781
|
+
? problem.choice.opts
|
|
782
|
+
: (problem.choice.options ?? [])).map((c) => ({ id: c._key, ...(c.label ? { label: c.label } : {}) })),
|
|
783
|
+
}
|
|
784
|
+
: {}),
|
|
785
|
+
},
|
|
786
|
+
...(problem ? { published: problem } : {}),
|
|
787
|
+
}
|
|
788
|
+
: {}),
|
|
789
|
+
...(n.function ? { function: n.function } : {}),
|
|
790
|
+
...(n.condition ? { condition: n.condition } : {}),
|
|
791
|
+
...(n.hidden ? { hidden: true } : {}),
|
|
792
|
+
...(n.position && 'row' in n.position && typeof n.position.row === 'number'
|
|
793
|
+
? { hierarchy: { row: n.position.row } }
|
|
794
|
+
: {}),
|
|
795
|
+
},
|
|
796
|
+
};
|
|
797
|
+
}),
|
|
798
|
+
edges: (() => {
|
|
799
|
+
const routes = [
|
|
800
|
+
...resolvedEdges(norm),
|
|
801
|
+
...norm.nodes.flatMap((n) => {
|
|
802
|
+
const problem = n.problem?._ref ? byId.get(canonicalId(n.problem._ref)) : undefined;
|
|
803
|
+
return (problem?.choice?.opts ?? problem?.choice?.options ?? []).flatMap((c) => {
|
|
804
|
+
// Authored choice options can project to null (options stored as plain strings lose
|
|
805
|
+
// their fields under the `options[]{...}` projection). Skip malformed entries rather
|
|
806
|
+
// than crashing the whole canvas on CMS content this renderer does not control.
|
|
807
|
+
if (!isRec(c))
|
|
808
|
+
return [];
|
|
809
|
+
const tgt = c.referral?._ref
|
|
810
|
+
? new Map(norm.nodes
|
|
811
|
+
.filter((n) => n.type === 'content' && n.problem?._ref)
|
|
812
|
+
.map((n) => [canonicalId(n.problem._ref), n._key])).get(canonicalId(c.referral._ref))
|
|
813
|
+
: undefined;
|
|
814
|
+
if (!tgt ||
|
|
815
|
+
new Set(norm.edges.map((e) => `${e.source}:${e.target}:${e.handle ?? ''}`)).has(`${n._key}:${tgt}:${c._key}`))
|
|
816
|
+
return [];
|
|
817
|
+
return [
|
|
818
|
+
{
|
|
819
|
+
_key: `choice:${n._key}:${c._key}:${tgt}`,
|
|
820
|
+
source: n._key,
|
|
821
|
+
target: tgt,
|
|
822
|
+
handle: c._key,
|
|
823
|
+
},
|
|
824
|
+
];
|
|
825
|
+
});
|
|
826
|
+
}),
|
|
827
|
+
].map((e) => {
|
|
828
|
+
return {
|
|
829
|
+
edge: e,
|
|
830
|
+
data: e.functions?.length || edgeData
|
|
831
|
+
? {
|
|
832
|
+
...(e.functions?.length ? { functions: e.functions } : {}),
|
|
833
|
+
...edgeData?.(e, byId.get(canonicalId(new Map(norm.nodes.map((n) => [n._key, n])).get(e.source)?.problem?._ref ??
|
|
834
|
+
''))),
|
|
835
|
+
}
|
|
836
|
+
: undefined,
|
|
837
|
+
};
|
|
838
|
+
});
|
|
839
|
+
const routesBySrc = new Map();
|
|
840
|
+
for (const route of routes) {
|
|
841
|
+
let list = routesBySrc.get(route.edge.source);
|
|
842
|
+
if (!list) {
|
|
843
|
+
list = [];
|
|
844
|
+
routesBySrc.set(route.edge.source, list);
|
|
845
|
+
}
|
|
846
|
+
list.push(route);
|
|
847
|
+
}
|
|
848
|
+
const laneMetaMap = new Map();
|
|
849
|
+
for (const [, group] of routesBySrc) {
|
|
850
|
+
const labelledRoutes = group.filter((r) => r.data?.label || r.data?.appendages?.length);
|
|
851
|
+
if (labelledRoutes.length > 0) {
|
|
852
|
+
const widths = labelledRoutes.map((r) => Math.min(EDGE_LANE.maxWidth, Math.max(EDGE_LANE.minWidth, (r.data.label?.length ?? 0) * 6 + 24, r.data.appendages?.length
|
|
853
|
+
? r.data.appendages.length * EDGE_LANE.appendageWidth +
|
|
854
|
+
(r.data.appendages.length - 1) * EDGE_LANE.appendageGap
|
|
855
|
+
: 0)));
|
|
856
|
+
let currOffset = -(widths.reduce((s, w) => s + w, 0) + (widths.length - 1) * EDGE_LANE.gap) / 2;
|
|
857
|
+
for (let i = 0; i < labelledRoutes.length; i++) {
|
|
858
|
+
const w = widths[i];
|
|
859
|
+
laneMetaMap.set(labelledRoutes[i].edge._key, {
|
|
860
|
+
laneWidth: w,
|
|
861
|
+
laneOffset: currOffset + w / 2,
|
|
862
|
+
});
|
|
863
|
+
currOffset += w + EDGE_LANE.gap;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
return routes.map(({ edge: e, data: d }) => {
|
|
868
|
+
const laneMeta = laneMetaMap.get(e._key);
|
|
869
|
+
return {
|
|
870
|
+
id: e._key,
|
|
871
|
+
source: e.source,
|
|
872
|
+
target: e.target,
|
|
873
|
+
sourceHandle: e.handle ?? 'default',
|
|
874
|
+
targetHandle: 'inbound',
|
|
875
|
+
type: 'custom',
|
|
876
|
+
...(d
|
|
877
|
+
? {
|
|
878
|
+
data: {
|
|
879
|
+
...d,
|
|
880
|
+
...(laneMeta?.laneOffset !== undefined
|
|
881
|
+
? { laneOffset: laneMeta.laneOffset }
|
|
882
|
+
: {}),
|
|
883
|
+
...(laneMeta?.laneWidth !== undefined ? { laneWidth: laneMeta.laneWidth } : {}),
|
|
884
|
+
},
|
|
885
|
+
}
|
|
886
|
+
: {}),
|
|
887
|
+
};
|
|
888
|
+
});
|
|
889
|
+
})(),
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Renders shared labelled Arc edges while the skin controls node primitives.
|
|
894
|
+
*
|
|
895
|
+
* @param props - Arc edge props.
|
|
896
|
+
* @param id - Identifier tying arc edge's output to its source record.
|
|
897
|
+
* @param source - Source node identifier for the connection drawn by arc edge.
|
|
898
|
+
* @param srcHandleId - Connection handle identifier supplied to arc edge.
|
|
899
|
+
* @param srcX - Horizontal connection coordinate supplied to arc edge.
|
|
900
|
+
* @param srcY - Vertical connection coordinate supplied to arc edge.
|
|
901
|
+
* @param srcPos - Connection anchor position supplied to arc edge.
|
|
902
|
+
* @param target - Target node identifier for the connection drawn by arc edge.
|
|
903
|
+
* @param tgtHandleId - Connection handle identifier supplied to arc edge.
|
|
904
|
+
* @param tgtX - Horizontal connection coordinate supplied to arc edge.
|
|
905
|
+
* @param tgtY - Vertical connection coordinate supplied to arc edge.
|
|
906
|
+
* @param tgtPosition - Connection anchor position supplied to arc edge.
|
|
907
|
+
* @param data - Data record supplied to arc edge.
|
|
908
|
+
*
|
|
909
|
+
* @return The rendered edge path and label layer.
|
|
910
|
+
*/
|
|
911
|
+
export function ArcEdge({ id, source: src, sourceHandleId: srcHandleId, sourceX: srcX, sourceY: srcY, sourcePosition: srcPos, target: tgt, targetHandleId: tgtHandleId, targetX: tgtX, targetY: tgtY, targetPosition: tgtPos, data, }) {
|
|
912
|
+
const appendages = data?.appendages ??
|
|
913
|
+
data?.functions?.map((f) => f.type === 'appendPrefix'
|
|
914
|
+
? { title: f.value, type: 'Prefix' }
|
|
915
|
+
: { title: 'Definition', type: f.type === 'appendTerm' ? 'Term' : 'Remove' });
|
|
916
|
+
const srcNode = useInternalNode(src);
|
|
917
|
+
const tgtNode = useInternalNode(tgt);
|
|
918
|
+
const srcHandle = srcNode?.internals.handleBounds?.source?.find((h) => h.id === srcHandleId);
|
|
919
|
+
const tgtHandle = tgtNode?.internals.handleBounds?.target?.find((h) => h.id === tgtHandleId);
|
|
920
|
+
// prettier-ignore
|
|
921
|
+
const srcCenter = srcHandle ? { x: srcNode.internals.positionAbsolute.x + srcHandle.x + srcHandle.width / 2, y: srcNode.internals.positionAbsolute.y + srcHandle.y + srcHandle.height / 2 } : { x: srcX, y: srcY };
|
|
922
|
+
// prettier-ignore
|
|
923
|
+
const tgtCenter = tgtHandle ? { x: tgtNode.internals.positionAbsolute.x + tgtHandle.x + tgtHandle.width / 2, y: tgtNode.internals.positionAbsolute.y + tgtHandle.y + tgtHandle.height / 2 } : { x: tgtX, y: tgtY };
|
|
924
|
+
const terminal = data?.terminal;
|
|
925
|
+
const vertical = (srcPos === HandlePos.Bottom || srcPos === HandlePos.Top) &&
|
|
926
|
+
(tgtPos === HandlePos.Bottom || tgtPos === HandlePos.Top);
|
|
927
|
+
const srcHeight = srcNode?.measured.height;
|
|
928
|
+
const tgtApproachY = tgtCenter.y - 24;
|
|
929
|
+
const bendY = terminal
|
|
930
|
+
? (srcHeight === undefined
|
|
931
|
+
? srcCenter.y
|
|
932
|
+
: srcNode
|
|
933
|
+
? srcNode.internals.positionAbsolute.y + srcHeight
|
|
934
|
+
: srcCenter.y) + 52
|
|
935
|
+
: !terminal && tgtCenter.y < srcCenter.y
|
|
936
|
+
? Math.min(srcCenter.y - 52, tgtApproachY - 24)
|
|
937
|
+
: (srcCenter.y + tgtApproachY) / 2;
|
|
938
|
+
const [fallback, fallbackX, fallbackY] = getSmoothStepPath({
|
|
939
|
+
sourceX: srcX,
|
|
940
|
+
sourceY: srcY,
|
|
941
|
+
sourcePosition: srcPos,
|
|
942
|
+
targetX: tgtX,
|
|
943
|
+
targetY: tgtY,
|
|
944
|
+
targetPosition: tgtPos,
|
|
945
|
+
offset: 16,
|
|
946
|
+
});
|
|
947
|
+
const laneX = srcCenter.x + (data?.laneOffset ?? 0);
|
|
948
|
+
return (_jsxs(ErrorBoundary, { name: "ArcEdge", children: [_jsx(BaseEdge, { id: id, path:
|
|
949
|
+
/* prettier-ignore */ terminal
|
|
950
|
+
? `M ${srcCenter.x},${srcCenter.y} V ${bendY} H ${laneX}` : vertical
|
|
951
|
+
? `M ${srcCenter.x},${srcCenter.y} V ${bendY} H ${laneX} V ${tgtApproachY} H ${tgtCenter.x} V ${tgtCenter.y}` : fallback }), (data?.label || appendages?.length) && (_jsx(EdgeLabelRenderer, { children: _jsxs("div", { className: cn('nodrag nopan flex max-w-80 flex-col items-center gap-1 text-[10px] leading-tight', data?.laneWidth ? 'w-full' : 'w-fit'), "aria-label": `${data?.terminal ? 'Terminal route. ' : ''}${data?.label ?? 'Route'}${appendages?.length ? `. ${appendages.map((a) => `${a.title}, ${a.type}`).join('; ')}` : ''}`, style: {
|
|
952
|
+
position: 'absolute',
|
|
953
|
+
transform: `translate(-50%, -50%) translate(${terminal || vertical ? laneX : fallbackX}px,${terminal ? bendY + 12 : vertical ? bendY : fallbackY}px)`,
|
|
954
|
+
...(data?.laneWidth ? { width: data.laneWidth } : {}),
|
|
955
|
+
}, children: [data?.label && (_jsx("span", { className: "block w-full truncate whitespace-nowrap rounded bg-white/95 px-1 text-center font-medium text-primary-12 shadow-sm", children: data.label })), _jsx("div", { className: "flex w-full flex-wrap items-start justify-center gap-0.5", children: appendages?.map((a, i) => (_jsxs("span", { className: cn('inline-flex h-5 w-32 min-w-0 max-w-32 items-baseline justify-center gap-1 overflow-hidden rounded px-1.5 py-0.5 text-center shadow-sm', data?.terminal ? 'bg-primary-9 text-white' : 'bg-secondary-8 text-secondary-12'), title: `${a.title} — ${a.type}`, children: [_jsx("span", { className: "min-w-0 truncate whitespace-nowrap", children: a.title }), _jsx("span", { className: "shrink-0 text-[9px] font-semibold uppercase tracking-wide opacity-75", children: a.type })] }, `${a.title}-${a.type}-${i}`))) })] }) }))] }));
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Renders the common problem card, its handles, title editing, and route affordances.
|
|
959
|
+
*
|
|
960
|
+
* @param props - Problem node props.
|
|
961
|
+
* @param id - Identifier tying problem node's output to its source record.
|
|
962
|
+
* @param data - Problem card data and callbacks.
|
|
963
|
+
* @param selected - Boolean flag controlling problem node's selected behaviour.
|
|
964
|
+
*
|
|
965
|
+
* @return The rendered problem node.
|
|
966
|
+
*/
|
|
967
|
+
export function ProblemNode({ id, data, selected, }) {
|
|
968
|
+
const skin = useSkin();
|
|
969
|
+
const input = useRef(null);
|
|
970
|
+
const outgoing = useStore((s) => s.edges.filter((e) => e.source === id).map((e) => e.sourceHandle ?? 'default'), isArrayEqual);
|
|
971
|
+
const choices = data.problem.choices ?? [];
|
|
972
|
+
const routes = [
|
|
973
|
+
{ id: 'default' },
|
|
974
|
+
...choices,
|
|
975
|
+
...Array.from(new Set(outgoing))
|
|
976
|
+
.filter((h) => h !== 'default' && !choices.some((c) => c.id === h))
|
|
977
|
+
.map((h) => ({ id: h })),
|
|
978
|
+
];
|
|
979
|
+
const connectable = data.editable !== false && data.draft !== false;
|
|
980
|
+
const terminus = useNodeConnections({ id: 'inbound' }).length > 0 &&
|
|
981
|
+
(!outgoing.length ||
|
|
982
|
+
(!outgoing.includes('default') && choices.some((c) => !outgoing.includes(c.id))));
|
|
983
|
+
useEffect(() => {
|
|
984
|
+
if (!data.renaming || !input.current)
|
|
985
|
+
return;
|
|
986
|
+
input.current.focus();
|
|
987
|
+
input.current.select();
|
|
988
|
+
}, [data.renaming]);
|
|
989
|
+
return (_jsx(ErrorBoundary, { name: "ProblemNode", children: _jsxs(skin.Card, { selected: selected, tone: terminus ? 'caution' : 'default', className: cn('relative flex w-52 flex-col', data.hierarchy && data.showHierarchyControls
|
|
990
|
+
? 'h-[120px]'
|
|
991
|
+
: data.showDuration === false
|
|
992
|
+
? 'h-16'
|
|
993
|
+
: 'h-[84px]', terminus && 'rounded-2xl'), onClick: (e) => {
|
|
994
|
+
if (!e.metaKey && !e.ctrlKey && !e.shiftKey)
|
|
995
|
+
data.onOpen?.();
|
|
996
|
+
}, children: [ARC_PORTS.inbound.map((i) => (_jsx(Port, { id: i, type: "target", position: HandlePos.Top, ariaLabel: "Incoming route", title: "Incoming route", isConnectable: connectable }, i))), data.readOnly ? (_jsx("strong", { className: "block truncate whitespace-nowrap leading-5", title: data.problem.title ?? 'Problem', children: data.problem.title ?? 'Problem' })) : (_jsx(skin.Input, { ref: input, rows: 1, defaultValue: data.problem.title ?? '', "aria-label": "Problem title", className: "h-5 !min-h-0 resize-none overflow-hidden whitespace-nowrap border-0 bg-transparent p-0 font-semibold leading-5 shadow-none outline-none focus-visible:ring-0", onClick: (e) => {
|
|
997
|
+
e.stopPropagation();
|
|
998
|
+
}, onChange: (e) => data.onTitleChange?.(e.currentTarget.value) })), data.showDuration !== false && data.problem.duration !== undefined && (_jsxs(skin.Text, { className: cn(CLASS.meta, 'mt-auto'), children: [data.problem.duration, " minutes"] })), data.showDuration !== false && data.duration && (_jsxs(skin.Text, { className: cn(CLASS.meta, data.problem.duration === undefined && 'mt-auto'), children: [data.duration.min === data.duration.max
|
|
999
|
+
? data.duration.min
|
|
1000
|
+
: `${data.duration.min}-${data.duration.max}`, ' ', "total"] })), data.hierarchy && data.showHierarchyControls !== false && (_jsx("div", { className: "mt-auto text-[10px]", onClick: (e) => {
|
|
1001
|
+
e.stopPropagation();
|
|
1002
|
+
}, children: _jsxs("label", { htmlFor: `problem-row-${id}`, className: "grid gap-0.5", children: [_jsx("span", { children: "Row" }), _jsx("input", { id: `problem-row-${id}`, className: "h-5 rounded border bg-background px-1", "aria-label": "Hierarchy row", type: "number", min: "1", value: data.hierarchy.row, onChange: (e) => data.hierarchy?.onChange?.({
|
|
1003
|
+
...data.hierarchy,
|
|
1004
|
+
row: Math.max(1, Number(e.currentTarget.value) || 1),
|
|
1005
|
+
}) })] }) })), skin.Meta?.({ problem: data.problem }), routes.map((r, i) => (_jsx(Port, { id: r.id, type: "source", position: HandlePos.Bottom, isConnectable: connectable, variant: r.id === 'default' ? 'default' : 'choice', ...(r.id === 'default'
|
|
1006
|
+
? { ariaLabel: 'Default referral', title: 'Default referral' }
|
|
1007
|
+
: { ariaLabel: `Choice route ${r.label ?? i}`, title: r.label }), style: { left: `${((i + 1) / (routes.length + 1)) * 100}%` } }, r.id)))] }) }));
|
|
1008
|
+
}
|
|
1009
|
+
//# sourceMappingURL=_chrome.js.map
|