@atmos.build/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/dist/components/alert-dialog.d.ts +14 -0
- package/dist/components/alert-dialog.js +40 -0
- package/dist/components/at-search.d.ts +35 -0
- package/dist/components/at-search.js +57 -0
- package/dist/components/attachment-thumbnail-stack.d.ts +13 -0
- package/dist/components/attachment-thumbnail-stack.js +23 -0
- package/dist/components/audio-preview.d.ts +33 -0
- package/dist/components/audio-preview.js +176 -0
- package/dist/components/avatar-uploader.d.ts +29 -0
- package/dist/components/avatar-uploader.js +67 -0
- package/dist/components/avatar.d.ts +12 -0
- package/dist/components/avatar.js +38 -0
- package/dist/components/badge.d.ts +9 -0
- package/dist/components/badge.js +25 -0
- package/dist/components/button-group.d.ts +12 -0
- package/dist/components/button-group.js +29 -0
- package/dist/components/button.d.ts +10 -0
- package/dist/components/button.js +42 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +154 -0
- package/dist/components/channel-list.d.ts +33 -0
- package/dist/components/channel-list.js +40 -0
- package/dist/components/charts/area-chart.d.ts +2 -0
- package/dist/components/charts/area-chart.js +5 -0
- package/dist/components/charts/bar-chart.d.ts +2 -0
- package/dist/components/charts/bar-chart.js +58 -0
- package/dist/components/charts/colors.d.ts +2 -0
- package/dist/components/charts/colors.js +42 -0
- package/dist/components/charts/hover.d.ts +20 -0
- package/dist/components/charts/hover.js +31 -0
- package/dist/components/charts/index.d.ts +10 -0
- package/dist/components/charts/index.js +9 -0
- package/dist/components/charts/layout.d.ts +35 -0
- package/dist/components/charts/layout.js +101 -0
- package/dist/components/charts/legend.d.ts +6 -0
- package/dist/components/charts/legend.js +7 -0
- package/dist/components/charts/line-area-chart.d.ts +4 -0
- package/dist/components/charts/line-area-chart.js +86 -0
- package/dist/components/charts/line-chart.d.ts +2 -0
- package/dist/components/charts/line-chart.js +5 -0
- package/dist/components/charts/pie-chart.d.ts +2 -0
- package/dist/components/charts/pie-chart.js +22 -0
- package/dist/components/charts/radar-chart.d.ts +2 -0
- package/dist/components/charts/radar-chart.js +29 -0
- package/dist/components/charts/radial-chart.d.ts +2 -0
- package/dist/components/charts/radial-chart.js +19 -0
- package/dist/components/charts/scatter-chart.d.ts +2 -0
- package/dist/components/charts/scatter-chart.js +16 -0
- package/dist/components/charts/story-data.d.ts +24 -0
- package/dist/components/charts/story-data.js +48 -0
- package/dist/components/charts/types.d.ts +43 -0
- package/dist/components/charts/types.js +1 -0
- package/dist/components/checkbox.d.ts +4 -0
- package/dist/components/checkbox.js +10 -0
- package/dist/components/chip.d.ts +25 -0
- package/dist/components/chip.js +36 -0
- package/dist/components/code-editor-theme.d.ts +19 -0
- package/dist/components/code-editor-theme.js +100 -0
- package/dist/components/collapsible-section-header.d.ts +82 -0
- package/dist/components/collapsible-section-header.js +82 -0
- package/dist/components/collection-view/collection-view-group-settings.d.ts +73 -0
- package/dist/components/collection-view/collection-view-group-settings.js +55 -0
- package/dist/components/collection-view/collection-view-settings.d.ts +115 -0
- package/dist/components/collection-view/collection-view-settings.js +146 -0
- package/dist/components/collection-view/collection-view.d.ts +87 -0
- package/dist/components/collection-view/collection-view.js +95 -0
- package/dist/components/collection-view/index.d.ts +6 -0
- package/dist/components/collection-view/index.js +6 -0
- package/dist/components/collection-view/use-collection-detail-navigation.d.ts +11 -0
- package/dist/components/collection-view/use-collection-detail-navigation.js +12 -0
- package/dist/components/collection-view/use-collection-escape.d.ts +9 -0
- package/dist/components/collection-view/use-collection-escape.js +20 -0
- package/dist/components/collection-view/use-collection-selection.d.ts +42 -0
- package/dist/components/collection-view/use-collection-selection.js +203 -0
- package/dist/components/color-picker.d.ts +18 -0
- package/dist/components/color-picker.js +77 -0
- package/dist/components/color-swatch-list.d.ts +16 -0
- package/dist/components/color-swatch-list.js +60 -0
- package/dist/components/combobox/combobox.d.ts +4 -0
- package/dist/components/combobox/combobox.js +70 -0
- package/dist/components/combobox/compound.d.ts +68 -0
- package/dist/components/combobox/compound.js +151 -0
- package/dist/components/combobox/context.d.ts +34 -0
- package/dist/components/combobox/context.js +123 -0
- package/dist/components/combobox/create-step.d.ts +12 -0
- package/dist/components/combobox/create-step.js +8 -0
- package/dist/components/combobox/index.d.ts +10 -0
- package/dist/components/combobox/index.js +5 -0
- package/dist/components/combobox/inline-create-form.d.ts +24 -0
- package/dist/components/combobox/inline-create-form.js +43 -0
- package/dist/components/combobox/types.d.ts +57 -0
- package/dist/components/combobox/types.js +10 -0
- package/dist/components/command.d.ts +35 -0
- package/dist/components/command.js +76 -0
- package/dist/components/comment-pin.d.ts +13 -0
- package/dist/components/comment-pin.js +33 -0
- package/dist/components/confidence-meter.d.ts +11 -0
- package/dist/components/confidence-meter.js +24 -0
- package/dist/components/context-menu.d.ts +31 -0
- package/dist/components/context-menu.js +54 -0
- package/dist/components/copy-button.d.ts +12 -0
- package/dist/components/copy-button.js +32 -0
- package/dist/components/date-picker.d.ts +29 -0
- package/dist/components/date-picker.js +86 -0
- package/dist/components/date-tile.d.ts +11 -0
- package/dist/components/date-tile.js +16 -0
- package/dist/components/date-time-picker.d.ts +25 -0
- package/dist/components/date-time-picker.js +153 -0
- package/dist/components/detail-breadcrumb-utils.d.ts +2 -0
- package/dist/components/detail-breadcrumb-utils.js +18 -0
- package/dist/components/detail-nav-bar.d.ts +28 -0
- package/dist/components/detail-nav-bar.js +28 -0
- package/dist/components/detail-top-bar.d.ts +49 -0
- package/dist/components/detail-top-bar.js +41 -0
- package/dist/components/dialog.d.ts +22 -0
- package/dist/components/dialog.js +51 -0
- package/dist/components/dropdown-menu.d.ts +29 -0
- package/dist/components/dropdown-menu.js +52 -0
- package/dist/components/editable-doc-title.d.ts +17 -0
- package/dist/components/editable-doc-title.js +147 -0
- package/dist/components/empty-state.d.ts +12 -0
- package/dist/components/empty-state.js +6 -0
- package/dist/components/filter-condition-editor.d.ts +18 -0
- package/dist/components/filter-condition-editor.js +102 -0
- package/dist/components/form-dialog.d.ts +30 -0
- package/dist/components/form-dialog.js +52 -0
- package/dist/components/formula-editor.d.ts +18 -0
- package/dist/components/formula-editor.js +154 -0
- package/dist/components/hover-card.d.ts +52 -0
- package/dist/components/hover-card.js +51 -0
- package/dist/components/icon-button.d.ts +15 -0
- package/dist/components/icon-button.js +18 -0
- package/dist/components/inline-alert.d.ts +11 -0
- package/dist/components/inline-alert.js +17 -0
- package/dist/components/input.d.ts +3 -0
- package/dist/components/input.js +7 -0
- package/dist/components/kanban-board.d.ts +27 -0
- package/dist/components/kanban-board.js +145 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/kbd.js +8 -0
- package/dist/components/label.d.ts +4 -0
- package/dist/components/label.js +9 -0
- package/dist/components/markdown-editor/index.d.ts +4 -0
- package/dist/components/markdown-editor/index.js +2 -0
- package/dist/components/markdown-editor/markdown-editor.d.ts +16 -0
- package/dist/components/markdown-editor/markdown-editor.js +53 -0
- package/dist/components/markdown-editor/serialize.d.ts +12 -0
- package/dist/components/markdown-editor/serialize.js +122 -0
- package/dist/components/markdown-editor/vim.d.ts +8 -0
- package/dist/components/markdown-editor/vim.js +394 -0
- package/dist/components/metric-grid.d.ts +41 -0
- package/dist/components/metric-grid.js +39 -0
- package/dist/components/microphone-priority.d.ts +29 -0
- package/dist/components/microphone-priority.js +15 -0
- package/dist/components/middle-truncate.d.ts +6 -0
- package/dist/components/middle-truncate.js +15 -0
- package/dist/components/multi-combobox.d.ts +48 -0
- package/dist/components/multi-combobox.js +221 -0
- package/dist/components/naut-avatar-engine.d.ts +83 -0
- package/dist/components/naut-avatar-engine.js +803 -0
- package/dist/components/naut-avatar.d.ts +31 -0
- package/dist/components/naut-avatar.js +108 -0
- package/dist/components/navigable-list.d.ts +4 -0
- package/dist/components/navigable-list.js +20 -0
- package/dist/components/note-icon-picker.d.ts +20 -0
- package/dist/components/note-icon-picker.js +84 -0
- package/dist/components/note-icon.d.ts +690 -0
- package/dist/components/note-icon.js +353 -0
- package/dist/components/note-row.d.ts +33 -0
- package/dist/components/note-row.js +29 -0
- package/dist/components/overlapping-dots.d.ts +10 -0
- package/dist/components/overlapping-dots.js +13 -0
- package/dist/components/overview-card.d.ts +12 -0
- package/dist/components/overview-card.js +9 -0
- package/dist/components/panel-header.d.ts +8 -0
- package/dist/components/panel-header.js +6 -0
- package/dist/components/panel-section-states.d.ts +9 -0
- package/dist/components/panel-section-states.js +10 -0
- package/dist/components/person-avatar.d.ts +10 -0
- package/dist/components/person-avatar.js +23 -0
- package/dist/components/photo-avatar.d.ts +11 -0
- package/dist/components/photo-avatar.js +24 -0
- package/dist/components/picker-field.d.ts +23 -0
- package/dist/components/picker-field.js +24 -0
- package/dist/components/popover-stack.d.ts +26 -0
- package/dist/components/popover-stack.js +89 -0
- package/dist/components/popover.d.ts +12 -0
- package/dist/components/popover.js +31 -0
- package/dist/components/portal-login-barrier.d.ts +12 -0
- package/dist/components/portal-login-barrier.js +41 -0
- package/dist/components/presence-dot.d.ts +8 -0
- package/dist/components/presence-dot.js +15 -0
- package/dist/components/presence-overlay.d.ts +27 -0
- package/dist/components/presence-overlay.js +34 -0
- package/dist/components/property-list.d.ts +64 -0
- package/dist/components/property-list.js +313 -0
- package/dist/components/property-panel.d.ts +54 -0
- package/dist/components/property-panel.js +87 -0
- package/dist/components/property-selector.d.ts +36 -0
- package/dist/components/property-selector.js +141 -0
- package/dist/components/provenance-chip.d.ts +12 -0
- package/dist/components/provenance-chip.js +17 -0
- package/dist/components/qr-code.d.ts +13 -0
- package/dist/components/qr-code.js +42 -0
- package/dist/components/qr-encode.d.ts +2 -0
- package/dist/components/qr-encode.js +469 -0
- package/dist/components/quantity-stepper.d.ts +25 -0
- package/dist/components/quantity-stepper.js +43 -0
- package/dist/components/radio-group.d.ts +5 -0
- package/dist/components/radio-group.js +13 -0
- package/dist/components/rename-dialog.d.ts +19 -0
- package/dist/components/rename-dialog.js +35 -0
- package/dist/components/row-surface.d.ts +1 -0
- package/dist/components/row-surface.js +5 -0
- package/dist/components/row-trailing.d.ts +30 -0
- package/dist/components/row-trailing.js +59 -0
- package/dist/components/run-status-badge.d.ts +16 -0
- package/dist/components/run-status-badge.js +43 -0
- package/dist/components/scroll-area.d.ts +5 -0
- package/dist/components/scroll-area.js +12 -0
- package/dist/components/select.d.ts +15 -0
- package/dist/components/select.js +39 -0
- package/dist/components/selectable-card.d.ts +33 -0
- package/dist/components/selectable-card.js +66 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +8 -0
- package/dist/components/settings-dialog-shell.d.ts +46 -0
- package/dist/components/settings-dialog-shell.js +48 -0
- package/dist/components/shimmer-text.d.ts +8 -0
- package/dist/components/shimmer-text.js +26 -0
- package/dist/components/side-panel-tokens.d.ts +27 -0
- package/dist/components/side-panel-tokens.js +26 -0
- package/dist/components/side-panel.d.ts +94 -0
- package/dist/components/side-panel.js +106 -0
- package/dist/components/skeleton.d.ts +2 -0
- package/dist/components/skeleton.js +6 -0
- package/dist/components/sortable.d.ts +65 -0
- package/dist/components/sortable.js +110 -0
- package/dist/components/spec-strip.d.ts +18 -0
- package/dist/components/spec-strip.js +15 -0
- package/dist/components/speech-playback.d.ts +25 -0
- package/dist/components/speech-playback.js +35 -0
- package/dist/components/sql-editor.d.ts +13 -0
- package/dist/components/sql-editor.js +228 -0
- package/dist/components/stat-tile.d.ts +7 -0
- package/dist/components/stat-tile.js +6 -0
- package/dist/components/status-badge.d.ts +17 -0
- package/dist/components/status-badge.js +8 -0
- package/dist/components/status-tone.d.ts +9 -0
- package/dist/components/status-tone.js +10 -0
- package/dist/components/sticky-header-fade.d.ts +8 -0
- package/dist/components/sticky-header-fade.js +11 -0
- package/dist/components/swatch-button.d.ts +14 -0
- package/dist/components/swatch-button.js +25 -0
- package/dist/components/switch.d.ts +6 -0
- package/dist/components/switch.js +9 -0
- package/dist/components/system-load/index.d.ts +6 -0
- package/dist/components/system-load/index.js +6 -0
- package/dist/components/system-load/load-block.d.ts +20 -0
- package/dist/components/system-load/load-block.js +23 -0
- package/dist/components/system-load/load-grid.d.ts +16 -0
- package/dist/components/system-load/load-grid.js +23 -0
- package/dist/components/system-load/load-meter.d.ts +25 -0
- package/dist/components/system-load/load-meter.js +29 -0
- package/dist/components/system-load/load-tone.d.ts +21 -0
- package/dist/components/system-load/load-tone.js +29 -0
- package/dist/components/system-load/meter-row.d.ts +31 -0
- package/dist/components/system-load/meter-row.js +29 -0
- package/dist/components/system-load/resource-meter.d.ts +19 -0
- package/dist/components/system-load/resource-meter.js +15 -0
- package/dist/components/tab-title-bar.d.ts +12 -0
- package/dist/components/tab-title-bar.js +9 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +29 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +97 -0
- package/dist/components/template-chip-input.d.ts +36 -0
- package/dist/components/template-chip-input.js +271 -0
- package/dist/components/template-input.d.ts +24 -0
- package/dist/components/template-input.js +57 -0
- package/dist/components/terminal-spinner.d.ts +11 -0
- package/dist/components/terminal-spinner.js +48 -0
- package/dist/components/textarea.d.ts +3 -0
- package/dist/components/textarea.js +7 -0
- package/dist/components/time-column.d.ts +24 -0
- package/dist/components/time-column.js +60 -0
- package/dist/components/timestamped-transcript.d.ts +38 -0
- package/dist/components/timestamped-transcript.js +29 -0
- package/dist/components/timezone-picker.d.ts +22 -0
- package/dist/components/timezone-picker.js +60 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +29 -0
- package/dist/components/transcription-overlay.d.ts +47 -0
- package/dist/components/transcription-overlay.js +30 -0
- package/dist/components/usage-bar.d.ts +17 -0
- package/dist/components/usage-bar.js +26 -0
- package/dist/components/view-query-bar.d.ts +13 -0
- package/dist/components/view-query-bar.js +13 -0
- package/dist/components/view-query-controls.d.ts +159 -0
- package/dist/components/view-query-controls.js +109 -0
- package/dist/components/view-save-menu.d.ts +20 -0
- package/dist/components/view-save-menu.js +13 -0
- package/dist/components/view-sort-editor.d.ts +40 -0
- package/dist/components/view-sort-editor.js +47 -0
- package/dist/components/voice-line.d.ts +37 -0
- package/dist/components/voice-line.js +293 -0
- package/dist/components/weekly-schedule-editor.d.ts +15 -0
- package/dist/components/weekly-schedule-editor.js +28 -0
- package/dist/flow/canvas/canvas-frame.d.ts +160 -0
- package/dist/flow/canvas/canvas-frame.js +521 -0
- package/dist/flow/canvas/collaborator-layer.d.ts +12 -0
- package/dist/flow/canvas/collaborator-layer.js +43 -0
- package/dist/flow/canvas/connector-edge.d.ts +22 -0
- package/dist/flow/canvas/connector-edge.js +61 -0
- package/dist/flow/canvas/editor-context.d.ts +23 -0
- package/dist/flow/canvas/editor-context.js +6 -0
- package/dist/flow/canvas/graph-core.d.ts +60 -0
- package/dist/flow/canvas/graph-core.js +296 -0
- package/dist/flow/canvas/minimap-sticky-overlay.d.ts +4 -0
- package/dist/flow/canvas/minimap-sticky-overlay.js +45 -0
- package/dist/flow/canvas/node-card.d.ts +46 -0
- package/dist/flow/canvas/node-card.js +56 -0
- package/dist/flow/canvas/node-library.d.ts +40 -0
- package/dist/flow/canvas/node-library.js +54 -0
- package/dist/flow/canvas/sticky-notes.d.ts +25 -0
- package/dist/flow/canvas/sticky-notes.js +101 -0
- package/dist/flow/collaborative-graph-presence.d.ts +28 -0
- package/dist/flow/collaborative-graph-presence.js +55 -0
- package/dist/flow/collaborative-graph-sync.d.ts +40 -0
- package/dist/flow/collaborative-graph-sync.js +127 -0
- package/dist/flow/editor/adapter.d.ts +64 -0
- package/dist/flow/editor/adapter.js +1 -0
- package/dist/flow/editor/command-registry.d.ts +10 -0
- package/dist/flow/editor/command-registry.js +35 -0
- package/dist/flow/editor/dag-canvas.d.ts +18 -0
- package/dist/flow/editor/dag-canvas.js +33 -0
- package/dist/flow/editor/flow-editor.d.ts +54 -0
- package/dist/flow/editor/flow-editor.js +199 -0
- package/dist/flow/editor/issues-popover.d.ts +11 -0
- package/dist/flow/editor/issues-popover.js +70 -0
- package/dist/flow/editor/library-rail.d.ts +19 -0
- package/dist/flow/editor/library-rail.js +25 -0
- package/dist/flow/editor/make-controller.d.ts +18 -0
- package/dist/flow/editor/make-controller.js +44 -0
- package/dist/flow/editor/node-chip.d.ts +2 -0
- package/dist/flow/editor/node-chip.js +16 -0
- package/dist/flow/editor/save-publish-bar.d.ts +27 -0
- package/dist/flow/editor/save-publish-bar.js +14 -0
- package/dist/flow/editor/settings-dialog.d.ts +11 -0
- package/dist/flow/editor/settings-dialog.js +11 -0
- package/dist/flow/editor/settings-shell.d.ts +21 -0
- package/dist/flow/editor/settings-shell.js +20 -0
- package/dist/flow/editor/side-rail.d.ts +22 -0
- package/dist/flow/editor/side-rail.js +15 -0
- package/dist/flow/editor/use-dag-editor.d.ts +94 -0
- package/dist/flow/editor/use-dag-editor.js +502 -0
- package/dist/flow/index.d.ts +25 -0
- package/dist/flow/index.js +25 -0
- package/dist/flow/presence-motion.d.ts +10 -0
- package/dist/flow/presence-motion.js +88 -0
- package/dist/flow/styles.css +1 -0
- package/dist/flow/use-collaborative-graph.d.ts +61 -0
- package/dist/flow/use-collaborative-graph.js +396 -0
- package/dist/flow/use-debounced-value.d.ts +1 -0
- package/dist/flow/use-debounced-value.js +10 -0
- package/dist/hooks/use-detail-nav.d.ts +11 -0
- package/dist/hooks/use-detail-nav.js +49 -0
- package/dist/hooks/use-flush-on-hide.d.ts +1 -0
- package/dist/hooks/use-flush-on-hide.js +21 -0
- package/dist/hooks/use-media-query.d.ts +1 -0
- package/dist/hooks/use-media-query.js +20 -0
- package/dist/hooks/use-virtualizer.d.ts +1 -0
- package/dist/hooks/use-virtualizer.js +1 -0
- package/dist/index.d.ts +139 -0
- package/dist/index.js +139 -0
- package/dist/lib/brand-style.d.ts +6 -0
- package/dist/lib/brand-style.js +16 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/composited-glint.d.ts +7 -0
- package/dist/lib/composited-glint.js +98 -0
- package/dist/lib/date-time-format.d.ts +2 -0
- package/dist/lib/date-time-format.js +21 -0
- package/dist/lib/disclosure-state.d.ts +11 -0
- package/dist/lib/disclosure-state.js +22 -0
- package/dist/lib/label-swatches.d.ts +10 -0
- package/dist/lib/label-swatches.js +24 -0
- package/dist/lib/local-ui-state.d.ts +10 -0
- package/dist/lib/local-ui-state.js +95 -0
- package/dist/lib/parse-loose-datetime.d.ts +1 -0
- package/dist/lib/parse-loose-datetime.js +180 -0
- package/dist/lib/parse-loose-time.d.ts +6 -0
- package/dist/lib/parse-loose-time.js +53 -0
- package/dist/lib/parse-loose.d.ts +1 -0
- package/dist/lib/parse-loose.js +170 -0
- package/dist/lib/react-19-jsx.d.ts +8 -0
- package/dist/lib/react-19-jsx.js +1 -0
- package/dist/lib/view-chrome.d.ts +5 -0
- package/dist/lib/view-chrome.js +5 -0
- package/dist/lib/view-query/config.d.ts +26 -0
- package/dist/lib/view-query/config.js +162 -0
- package/dist/lib/view-query/evaluate.d.ts +11 -0
- package/dist/lib/view-query/evaluate.js +196 -0
- package/dist/lib/view-query/group-order.d.ts +25 -0
- package/dist/lib/view-query/group-order.js +49 -0
- package/dist/lib/view-query/index.d.ts +6 -0
- package/dist/lib/view-query/index.js +6 -0
- package/dist/lib/view-query/model.d.ts +34 -0
- package/dist/lib/view-query/model.js +88 -0
- package/dist/lib/view-query/sort.d.ts +7 -0
- package/dist/lib/view-query/sort.js +30 -0
- package/dist/lib/view-query/types.d.ts +70 -0
- package/dist/lib/view-query/types.js +12 -0
- package/dist/lib/weekly-schedule.d.ts +8 -0
- package/dist/lib/weekly-schedule.js +10 -0
- package/dist/mcp-app/index.d.ts +4 -0
- package/dist/mcp-app/index.js +3 -0
- package/dist/mcp-app/shadcn.css +629 -0
- package/dist/mcp-app/styles.css +72 -0
- package/dist/mcp-app/theme.d.ts +2 -0
- package/dist/mcp-app/theme.js +62 -0
- package/dist/mcp-app/use-atmos-mcp-app.d.ts +109 -0
- package/dist/mcp-app/use-atmos-mcp-app.js +30 -0
- package/dist/mcp-app/vite.d.ts +7 -0
- package/dist/mcp-app/vite.js +30 -0
- package/dist/tokens/index.d.ts +7 -0
- package/dist/tokens/index.js +7 -0
- package/dist/tokens/semantic.css +110 -0
- package/dist/tokens/tokens.css +195 -0
- package/package.json +98 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
+
import { type Connection, type Edge as RfEdge, type Node as RfNode, type OnEdgesChange, type OnNodesChange } from 'reactflow';
|
|
3
|
+
import type { CollaborativeGraphPatch } from '../collaborative-graph-sync.js';
|
|
4
|
+
export interface EdgeBridgeSpec<TEdge> {
|
|
5
|
+
readonly source: string;
|
|
6
|
+
readonly target: string;
|
|
7
|
+
readonly handle: string | null | undefined;
|
|
8
|
+
readonly upstream?: RfEdge<TEdge>;
|
|
9
|
+
}
|
|
10
|
+
export interface MakeNodeDataContext<TData> {
|
|
11
|
+
readonly fromNode?: RfNode<TData>;
|
|
12
|
+
}
|
|
13
|
+
export interface UseDagEditorOptions<TData, TEdge> {
|
|
14
|
+
readonly makeNodeData: (kind: string, title: string, ctx?: MakeNodeDataContext<TData>) => TData;
|
|
15
|
+
readonly cloneNodeData?: (data: TData) => TData;
|
|
16
|
+
readonly isProtected: (node: RfNode<TData>) => boolean;
|
|
17
|
+
readonly isValidConnection?: (connection: Connection, nodes: RfNode<TData>[], edges: RfEdge<TEdge>[]) => boolean;
|
|
18
|
+
readonly initialNodes: RfNode<TData>[];
|
|
19
|
+
readonly initialEdges: RfEdge<TEdge>[];
|
|
20
|
+
readonly nodeType?: string;
|
|
21
|
+
readonly clipboardKind?: string;
|
|
22
|
+
readonly buildEdge?: (spec: EdgeBridgeSpec<TEdge>) => RfEdge<TEdge>;
|
|
23
|
+
readonly isSingleHandle?: (sourceId: string, handle: string | null, nodes: RfNode<TData>[]) => boolean;
|
|
24
|
+
readonly handleOrderOf?: (sourceId: string, sourceHandle: string | null | undefined, nodes: RfNode<TData>[]) => number | null;
|
|
25
|
+
}
|
|
26
|
+
type Snapshot<TData, TEdge> = {
|
|
27
|
+
nodes: RfNode<TData>[];
|
|
28
|
+
edges: RfEdge<TEdge>[];
|
|
29
|
+
};
|
|
30
|
+
export type RemoteGraphPhase = 'bootstrap' | 'peer';
|
|
31
|
+
export interface DagEditor<TData, TEdge> {
|
|
32
|
+
nodes: RfNode<TData>[];
|
|
33
|
+
edges: RfEdge<TEdge>[];
|
|
34
|
+
onNodesChange: OnNodesChange;
|
|
35
|
+
onEdgesChange: OnEdgesChange;
|
|
36
|
+
setNodes: Dispatch<SetStateAction<RfNode<TData>[]>>;
|
|
37
|
+
commitNodesQuiet: Dispatch<SetStateAction<RfNode<TData>[]>>;
|
|
38
|
+
setEdges: Dispatch<SetStateAction<RfEdge<TEdge>[]>>;
|
|
39
|
+
onConnect: (connection: Connection) => void;
|
|
40
|
+
isValidConnection: (connection: Connection) => boolean;
|
|
41
|
+
addNodeAt: (kind: string, at: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}, title?: string) => string | null;
|
|
45
|
+
addNodeAtEnd: (kind: string, title?: string) => string;
|
|
46
|
+
addConnectedNodeAt: (args: {
|
|
47
|
+
kind: string;
|
|
48
|
+
title?: string;
|
|
49
|
+
at: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
from?: {
|
|
54
|
+
sourceId: string;
|
|
55
|
+
handleId?: string | null;
|
|
56
|
+
};
|
|
57
|
+
to?: {
|
|
58
|
+
targetId: string;
|
|
59
|
+
};
|
|
60
|
+
}) => string;
|
|
61
|
+
insertNodeOnEdge: (edgeId: string, kind: string, title?: string) => string | null;
|
|
62
|
+
removeNode: (id: string) => void;
|
|
63
|
+
removeNodesAndEdges: (nodeIds: readonly string[], edgeIds?: readonly string[]) => void;
|
|
64
|
+
duplicateNode: (id: string) => void;
|
|
65
|
+
undo: () => void;
|
|
66
|
+
redo: () => void;
|
|
67
|
+
canUndo: boolean;
|
|
68
|
+
canRedo: boolean;
|
|
69
|
+
copy: () => void;
|
|
70
|
+
paste: () => void;
|
|
71
|
+
tidy: () => void;
|
|
72
|
+
selectNode: (id: string | null) => void;
|
|
73
|
+
deselectAll: () => void;
|
|
74
|
+
selectedNode: RfNode<TData> | null;
|
|
75
|
+
selectedNodeIds: string[];
|
|
76
|
+
updateNodeData: (id: string, patch: Partial<TData>) => void;
|
|
77
|
+
focusRequest: {
|
|
78
|
+
id: string;
|
|
79
|
+
seq: number;
|
|
80
|
+
} | null;
|
|
81
|
+
requestFocus: (id: string) => void;
|
|
82
|
+
isDirty: boolean;
|
|
83
|
+
dirtyRevision: number;
|
|
84
|
+
markSaved: () => void;
|
|
85
|
+
reset: (next?: {
|
|
86
|
+
nodes: RfNode<TData>[];
|
|
87
|
+
edges: RfEdge<TEdge>[];
|
|
88
|
+
}) => void;
|
|
89
|
+
applyRemoteGraph: (next: Snapshot<TData, TEdge>, phase: RemoteGraphPhase) => void;
|
|
90
|
+
applyRemotePatch: (patch: CollaborativeGraphPatch<TData, TEdge>, phase: RemoteGraphPhase) => void;
|
|
91
|
+
positionRevision: number;
|
|
92
|
+
}
|
|
93
|
+
export declare function useDagEditor<TData, TEdge = unknown>(opts: UseDagEditorOptions<TData, TEdge>): DagEditor<TData, TEdge>;
|
|
94
|
+
export {};
|
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { useEdgesState, useNodesState, } from 'reactflow';
|
|
4
|
+
import { createDagHistory, deserializeClipboard, edgeId, findFreePosition, inlineInsertOnEdge, layeredLayout, restitchEdgesWithoutNode, rfEdge as rfEdgeCore, serializeClipboard, wouldCycle, wouldCycleFromAdjacency, } from '../canvas/graph-core.js';
|
|
5
|
+
let nodeSeq = 0;
|
|
6
|
+
function freshNodeId(kind) {
|
|
7
|
+
nodeSeq += 1;
|
|
8
|
+
return `${kind}-${Date.now().toString(36)}-${nodeSeq.toString(36)}`;
|
|
9
|
+
}
|
|
10
|
+
export function useDagEditor(opts) {
|
|
11
|
+
const { makeNodeData, cloneNodeData, isProtected, isValidConnection: domainIsValidConnection, initialNodes, initialEdges, nodeType = 'atmos', clipboardKind = 'atmos-dag', buildEdge: buildEdgeOpt, isSingleHandle: isSingleHandleOpt, handleOrderOf, } = opts;
|
|
12
|
+
const buildEdge = useCallback((spec) => buildEdgeOpt
|
|
13
|
+
? buildEdgeOpt(spec)
|
|
14
|
+
: rfEdgeCore(spec.source, spec.target, {
|
|
15
|
+
...(spec.handle ? { handle: spec.handle } : {}),
|
|
16
|
+
type: nodeType,
|
|
17
|
+
}), [buildEdgeOpt, nodeType]);
|
|
18
|
+
const [nodes, setNodes, applyNodesChange] = useNodesState(initialNodes);
|
|
19
|
+
const [edges, setEdges, applyEdgesChange] = useEdgesState(initialEdges);
|
|
20
|
+
const [savedSnapshotKey, setSavedSnapshotKey] = useState(() => snapshotKey({ nodes: initialNodes, edges: initialEdges }));
|
|
21
|
+
const [dirtyRevision, setDirtyRevision] = useState(0);
|
|
22
|
+
const markDirty = useCallback(() => setDirtyRevision((r) => r + 1), []);
|
|
23
|
+
const [positionRevision, setPositionRevision] = useState(0);
|
|
24
|
+
const bumpPosition = useCallback(() => setPositionRevision((r) => r + 1), []);
|
|
25
|
+
const nodesRef = useRef(nodes);
|
|
26
|
+
const edgesRef = useRef(edges);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
nodesRef.current = nodes;
|
|
29
|
+
}, [nodes]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
edgesRef.current = edges;
|
|
32
|
+
}, [edges]);
|
|
33
|
+
const isSingleHandle = useCallback((sourceId, handle) => isSingleHandleOpt ? isSingleHandleOpt(sourceId, handle, nodesRef.current) : false, [isSingleHandleOpt]);
|
|
34
|
+
const historyRef = useRef(null);
|
|
35
|
+
if (historyRef.current == null)
|
|
36
|
+
historyRef.current = createDagHistory();
|
|
37
|
+
const [historyState, setHistoryState] = useState({ canUndo: false, canRedo: false });
|
|
38
|
+
const dragRecordedRef = useRef(false);
|
|
39
|
+
const [focusRequest, setFocusRequest] = useState(null);
|
|
40
|
+
const focusSeqRef = useRef(0);
|
|
41
|
+
const requestFocus = useCallback((id) => {
|
|
42
|
+
focusSeqRef.current += 1;
|
|
43
|
+
setFocusRequest({ id, seq: focusSeqRef.current });
|
|
44
|
+
}, []);
|
|
45
|
+
const syncHistoryState = useCallback(() => {
|
|
46
|
+
const history = historyRef.current;
|
|
47
|
+
if (!history)
|
|
48
|
+
return;
|
|
49
|
+
setHistoryState((cur) => {
|
|
50
|
+
const next = { canUndo: history.canUndo(), canRedo: history.canRedo() };
|
|
51
|
+
return cur.canUndo === next.canUndo && cur.canRedo === next.canRedo ? cur : next;
|
|
52
|
+
});
|
|
53
|
+
}, []);
|
|
54
|
+
const clearHistory = useCallback(() => {
|
|
55
|
+
historyRef.current?.clear();
|
|
56
|
+
syncHistoryState();
|
|
57
|
+
}, [syncHistoryState]);
|
|
58
|
+
const recordHistory = useCallback((coalesceKey) => {
|
|
59
|
+
historyRef.current?.record({ nodes: nodesRef.current, edges: edgesRef.current }, coalesceKey ?? null);
|
|
60
|
+
syncHistoryState();
|
|
61
|
+
}, [syncHistoryState]);
|
|
62
|
+
const restitchWithoutNode = useCallback((currentEdges, id) => restitchEdgesWithoutNode(currentEdges, id, ({ source, target, handle, upstream }) => buildEdge({ source, target, handle, upstream })), [buildEdge]);
|
|
63
|
+
const onNodesChange = useCallback((changes) => {
|
|
64
|
+
const dragStart = changes.some((c) => c.type === 'position' && c.dragging === true);
|
|
65
|
+
const dragEnd = changes.some((c) => c.type === 'position' && c.dragging === false);
|
|
66
|
+
if (dragStart && !dragRecordedRef.current) {
|
|
67
|
+
dragRecordedRef.current = true;
|
|
68
|
+
recordHistory();
|
|
69
|
+
}
|
|
70
|
+
if (dragEnd)
|
|
71
|
+
dragRecordedRef.current = false;
|
|
72
|
+
if (changes.some((c) => c.type === 'remove'))
|
|
73
|
+
recordHistory();
|
|
74
|
+
if (changes.some((c) => c.type !== 'select' && c.type !== 'dimensions' && c.type !== 'position')) {
|
|
75
|
+
markDirty();
|
|
76
|
+
}
|
|
77
|
+
if (dragEnd) {
|
|
78
|
+
markDirty();
|
|
79
|
+
bumpPosition();
|
|
80
|
+
}
|
|
81
|
+
applyNodesChange(changes);
|
|
82
|
+
}, [applyNodesChange, bumpPosition, markDirty, recordHistory]);
|
|
83
|
+
const onEdgesChange = useCallback((changes) => {
|
|
84
|
+
if (changes.some((c) => c.type === 'remove'))
|
|
85
|
+
recordHistory();
|
|
86
|
+
if (changes.some((c) => c.type !== 'select'))
|
|
87
|
+
markDirty();
|
|
88
|
+
applyEdgesChange(changes);
|
|
89
|
+
}, [applyEdgesChange, markDirty, recordHistory]);
|
|
90
|
+
const nodeById = useMemo(() => new Map(nodes.map((n) => [n.id, n])), [nodes]);
|
|
91
|
+
const edgeKeys = useMemo(() => new Set(edges.map((e) => edgeId(e.source, e.target, e.sourceHandle))), [edges]);
|
|
92
|
+
const adjacency = useMemo(() => {
|
|
93
|
+
const map = new Map();
|
|
94
|
+
for (const e of edges) {
|
|
95
|
+
const list = map.get(e.source) ?? [];
|
|
96
|
+
list.push(e.target);
|
|
97
|
+
map.set(e.source, list);
|
|
98
|
+
}
|
|
99
|
+
return map;
|
|
100
|
+
}, [edges]);
|
|
101
|
+
const isValidConnection = useCallback((connection) => {
|
|
102
|
+
if (!connection.source || !connection.target)
|
|
103
|
+
return false;
|
|
104
|
+
if (connection.source === connection.target)
|
|
105
|
+
return false;
|
|
106
|
+
if (!nodeById.has(connection.source) || !nodeById.has(connection.target))
|
|
107
|
+
return false;
|
|
108
|
+
if (edgeKeys.has(edgeId(connection.source, connection.target, connection.sourceHandle))) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (wouldCycleFromAdjacency(adjacency, connection.source, connection.target))
|
|
112
|
+
return false;
|
|
113
|
+
if (domainIsValidConnection && !domainIsValidConnection(connection, nodes, edges))
|
|
114
|
+
return false;
|
|
115
|
+
return true;
|
|
116
|
+
}, [adjacency, domainIsValidConnection, edgeKeys, edges, nodeById, nodes]);
|
|
117
|
+
const onConnect = useCallback((connection) => {
|
|
118
|
+
if (!isValidConnection(connection))
|
|
119
|
+
return;
|
|
120
|
+
const source = connection.source;
|
|
121
|
+
const target = connection.target;
|
|
122
|
+
if (!source || !target)
|
|
123
|
+
return;
|
|
124
|
+
recordHistory();
|
|
125
|
+
markDirty();
|
|
126
|
+
const handle = connection.sourceHandle ?? null;
|
|
127
|
+
setEdges((cur) => {
|
|
128
|
+
const filtered = isSingleHandle(source, handle)
|
|
129
|
+
? cur.filter((e) => !(e.source === source && (e.sourceHandle ?? null) === handle))
|
|
130
|
+
: cur;
|
|
131
|
+
return [...filtered, buildEdge({ source, target, handle })];
|
|
132
|
+
});
|
|
133
|
+
}, [buildEdge, isSingleHandle, isValidConnection, markDirty, recordHistory, setEdges]);
|
|
134
|
+
const makeNode = useCallback((kind, title, position, ctx) => ({
|
|
135
|
+
id: freshNodeId(kind),
|
|
136
|
+
type: nodeType,
|
|
137
|
+
position,
|
|
138
|
+
selected: true,
|
|
139
|
+
data: makeNodeData(kind, title ?? kind, ctx),
|
|
140
|
+
}), [makeNodeData, nodeType]);
|
|
141
|
+
const addNodeAt = useCallback((kind, at, title) => {
|
|
142
|
+
recordHistory();
|
|
143
|
+
markDirty();
|
|
144
|
+
const position = findFreePosition(nodesRef.current, at);
|
|
145
|
+
const node = makeNode(kind, title, position);
|
|
146
|
+
setNodes((cur) => [...cur.map((n) => ({ ...n, selected: false })), node]);
|
|
147
|
+
requestFocus(node.id);
|
|
148
|
+
return node.id;
|
|
149
|
+
}, [makeNode, markDirty, recordHistory, requestFocus, setNodes]);
|
|
150
|
+
const addNodeAtEnd = useCallback((kind, title) => {
|
|
151
|
+
recordHistory();
|
|
152
|
+
markDirty();
|
|
153
|
+
const fallbackX = nodesRef.current.reduce((max, n) => Math.max(max, n.position.x), 32) + 240;
|
|
154
|
+
const position = findFreePosition(nodesRef.current, { x: fallbackX, y: 160 });
|
|
155
|
+
const node = makeNode(kind, title, position);
|
|
156
|
+
setNodes((cur) => [...cur.map((n) => ({ ...n, selected: false })), node]);
|
|
157
|
+
requestFocus(node.id);
|
|
158
|
+
return node.id;
|
|
159
|
+
}, [makeNode, markDirty, recordHistory, requestFocus, setNodes]);
|
|
160
|
+
const addConnectedNodeAt = useCallback((args) => {
|
|
161
|
+
recordHistory();
|
|
162
|
+
markDirty();
|
|
163
|
+
const position = findFreePosition(nodesRef.current, args.at);
|
|
164
|
+
const fromNode = args.from
|
|
165
|
+
? nodesRef.current.find((n) => n.id === args.from?.sourceId)
|
|
166
|
+
: undefined;
|
|
167
|
+
const node = makeNode(args.kind, args.title, position, fromNode ? { fromNode } : undefined);
|
|
168
|
+
setNodes((cur) => [...cur.map((n) => ({ ...n, selected: false })), node]);
|
|
169
|
+
const from = args.from;
|
|
170
|
+
const to = args.to;
|
|
171
|
+
if (from) {
|
|
172
|
+
const handle = from.handleId ?? null;
|
|
173
|
+
setEdges((cur) => {
|
|
174
|
+
if (cur.some((e) => e.id === edgeId(from.sourceId, node.id, handle)))
|
|
175
|
+
return cur;
|
|
176
|
+
const filtered = isSingleHandle(from.sourceId, handle)
|
|
177
|
+
? cur.filter((e) => !(e.source === from.sourceId && (e.sourceHandle ?? null) === handle))
|
|
178
|
+
: cur;
|
|
179
|
+
return [...filtered, buildEdge({ source: from.sourceId, target: node.id, handle })];
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else if (to && !wouldCycle(edgesRef.current, node.id, to.targetId)) {
|
|
183
|
+
setEdges((cur) => {
|
|
184
|
+
if (cur.some((e) => e.id === edgeId(node.id, to.targetId, null)))
|
|
185
|
+
return cur;
|
|
186
|
+
return [...cur, buildEdge({ source: node.id, target: to.targetId, handle: null })];
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
requestFocus(node.id);
|
|
190
|
+
return node.id;
|
|
191
|
+
}, [
|
|
192
|
+
buildEdge,
|
|
193
|
+
isSingleHandle,
|
|
194
|
+
makeNode,
|
|
195
|
+
markDirty,
|
|
196
|
+
recordHistory,
|
|
197
|
+
requestFocus,
|
|
198
|
+
setEdges,
|
|
199
|
+
setNodes,
|
|
200
|
+
]);
|
|
201
|
+
const insertNodeOnEdge = useCallback((targetEdgeId, kind, title) => {
|
|
202
|
+
const edge = edgesRef.current.find((e) => e.id === targetEdgeId);
|
|
203
|
+
if (!edge)
|
|
204
|
+
return null;
|
|
205
|
+
const source = nodeById.get(edge.source);
|
|
206
|
+
const target = nodeById.get(edge.target);
|
|
207
|
+
recordHistory();
|
|
208
|
+
markDirty();
|
|
209
|
+
const inline = source && target ? inlineInsertOnEdge(source, target) : null;
|
|
210
|
+
const position = inline
|
|
211
|
+
? inline.position
|
|
212
|
+
: findFreePosition(nodesRef.current, { x: 256, y: 160 });
|
|
213
|
+
const node = makeNode(kind, title, position);
|
|
214
|
+
if (inline) {
|
|
215
|
+
setNodes((cur) => [
|
|
216
|
+
...cur.map((n) => ({ ...inline.shiftDownstream(n), selected: false })),
|
|
217
|
+
node,
|
|
218
|
+
]);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
setNodes((cur) => [...cur.map((n) => ({ ...n, selected: false })), node]);
|
|
222
|
+
}
|
|
223
|
+
setEdges((cur) => [
|
|
224
|
+
...cur.filter((e) => e.id !== targetEdgeId),
|
|
225
|
+
buildEdge({
|
|
226
|
+
source: edge.source,
|
|
227
|
+
target: node.id,
|
|
228
|
+
handle: edge.sourceHandle,
|
|
229
|
+
upstream: edge,
|
|
230
|
+
}),
|
|
231
|
+
buildEdge({ source: node.id, target: edge.target, handle: null }),
|
|
232
|
+
]);
|
|
233
|
+
requestFocus(node.id);
|
|
234
|
+
return node.id;
|
|
235
|
+
}, [buildEdge, makeNode, markDirty, nodeById, recordHistory, requestFocus, setEdges, setNodes]);
|
|
236
|
+
const removeNode = useCallback((id) => {
|
|
237
|
+
const node = nodeById.get(id);
|
|
238
|
+
if (node && isProtected(node))
|
|
239
|
+
return;
|
|
240
|
+
recordHistory();
|
|
241
|
+
markDirty();
|
|
242
|
+
setEdges((cur) => restitchWithoutNode(cur, id));
|
|
243
|
+
setNodes((cur) => cur.filter((n) => n.id !== id));
|
|
244
|
+
}, [isProtected, markDirty, nodeById, recordHistory, restitchWithoutNode, setEdges, setNodes]);
|
|
245
|
+
const removeNodesAndEdges = useCallback((nodeIds, edgeIds = []) => {
|
|
246
|
+
const removable = nodeIds.filter((id) => {
|
|
247
|
+
const node = nodeById.get(id);
|
|
248
|
+
return !(node && isProtected(node));
|
|
249
|
+
});
|
|
250
|
+
if (removable.length === 0 && edgeIds.length === 0)
|
|
251
|
+
return;
|
|
252
|
+
recordHistory();
|
|
253
|
+
markDirty();
|
|
254
|
+
const droppedEdges = new Set(edgeIds);
|
|
255
|
+
setEdges((cur) => {
|
|
256
|
+
let working = cur.filter((e) => !droppedEdges.has(e.id));
|
|
257
|
+
for (const id of removable)
|
|
258
|
+
working = restitchWithoutNode(working, id);
|
|
259
|
+
return working;
|
|
260
|
+
});
|
|
261
|
+
if (removable.length > 0) {
|
|
262
|
+
const dropped = new Set(removable);
|
|
263
|
+
setNodes((cur) => cur.filter((n) => !dropped.has(n.id)));
|
|
264
|
+
}
|
|
265
|
+
}, [isProtected, markDirty, nodeById, recordHistory, restitchWithoutNode, setEdges, setNodes]);
|
|
266
|
+
const duplicateNode = useCallback((id) => {
|
|
267
|
+
const original = nodesRef.current.find((n) => n.id === id);
|
|
268
|
+
if (!original)
|
|
269
|
+
return;
|
|
270
|
+
if (isProtected(original))
|
|
271
|
+
return;
|
|
272
|
+
recordHistory();
|
|
273
|
+
markDirty();
|
|
274
|
+
const copyId = freshNodeId(nodeType);
|
|
275
|
+
const position = findFreePosition(nodesRef.current, {
|
|
276
|
+
x: original.position.x + 48,
|
|
277
|
+
y: original.position.y + 48,
|
|
278
|
+
});
|
|
279
|
+
const data = cloneNodeData ? cloneNodeData(original.data) : { ...original.data };
|
|
280
|
+
setNodes((cur) => [
|
|
281
|
+
...cur.map((n) => ({ ...n, selected: false })),
|
|
282
|
+
{ ...original, id: copyId, selected: true, position, data },
|
|
283
|
+
]);
|
|
284
|
+
requestFocus(copyId);
|
|
285
|
+
}, [cloneNodeData, isProtected, markDirty, nodeType, recordHistory, requestFocus, setNodes]);
|
|
286
|
+
const updateNodeData = useCallback((id, patch) => {
|
|
287
|
+
recordHistory(`node:${id}`);
|
|
288
|
+
markDirty();
|
|
289
|
+
setNodes((cur) => cur.map((n) => (n.id === id ? { ...n, data: { ...n.data, ...patch } } : n)));
|
|
290
|
+
}, [markDirty, recordHistory, setNodes]);
|
|
291
|
+
const selectNode = useCallback((id) => {
|
|
292
|
+
setNodes((cur) => cur.map((n) => ({ ...n, selected: n.id === id })));
|
|
293
|
+
}, [setNodes]);
|
|
294
|
+
const deselectAll = useCallback(() => {
|
|
295
|
+
setNodes((cur) => cur.some((n) => n.selected) ? cur.map((n) => ({ ...n, selected: false })) : cur);
|
|
296
|
+
setEdges((cur) => cur.some((e) => e.selected) ? cur.map((e) => ({ ...e, selected: false })) : cur);
|
|
297
|
+
}, [setEdges, setNodes]);
|
|
298
|
+
const tidy = useCallback(() => {
|
|
299
|
+
recordHistory();
|
|
300
|
+
markDirty();
|
|
301
|
+
setNodes((cur) => {
|
|
302
|
+
if (cur.length === 0)
|
|
303
|
+
return cur;
|
|
304
|
+
const layout = layeredLayout(cur, edgesRef.current, handleOrderOf
|
|
305
|
+
? (sourceId, sourceHandle) => handleOrderOf(sourceId, sourceHandle, cur)
|
|
306
|
+
: undefined);
|
|
307
|
+
return cur.map((n) => ({ ...n, position: layout.get(n.id) ?? n.position }));
|
|
308
|
+
});
|
|
309
|
+
}, [handleOrderOf, markDirty, recordHistory, setNodes]);
|
|
310
|
+
const copy = useCallback(() => {
|
|
311
|
+
const selectedIds = new Set(nodesRef.current.filter((n) => n.selected).map((n) => n.id));
|
|
312
|
+
if (selectedIds.size === 0)
|
|
313
|
+
return;
|
|
314
|
+
const payload = serializeClipboard(clipboardKind, nodesRef.current, edgesRef.current, selectedIds);
|
|
315
|
+
clipboardRef.current = payload;
|
|
316
|
+
}, [clipboardKind]);
|
|
317
|
+
const clipboardRef = useRef(null);
|
|
318
|
+
const paste = useCallback(() => {
|
|
319
|
+
const payload = clipboardRef.current;
|
|
320
|
+
if (!payload)
|
|
321
|
+
return;
|
|
322
|
+
const decoded = deserializeClipboard(clipboardKind, payload, { nodeType });
|
|
323
|
+
if (!decoded || decoded.nodes.length === 0)
|
|
324
|
+
return;
|
|
325
|
+
recordHistory();
|
|
326
|
+
markDirty();
|
|
327
|
+
setNodes((cur) => [...cur.map((n) => ({ ...n, selected: false })), ...decoded.nodes]);
|
|
328
|
+
setEdges((cur) => [...cur, ...decoded.edges]);
|
|
329
|
+
const first = decoded.nodes[0];
|
|
330
|
+
if (first)
|
|
331
|
+
requestFocus(first.id);
|
|
332
|
+
}, [clipboardKind, markDirty, nodeType, recordHistory, requestFocus, setEdges, setNodes]);
|
|
333
|
+
const applySnapshot = useCallback((snapshot) => {
|
|
334
|
+
nodesRef.current = snapshot.nodes;
|
|
335
|
+
edgesRef.current = snapshot.edges;
|
|
336
|
+
setNodes(snapshot.nodes);
|
|
337
|
+
setEdges(snapshot.edges);
|
|
338
|
+
markDirty();
|
|
339
|
+
}, [markDirty, setEdges, setNodes]);
|
|
340
|
+
const markSaved = useCallback(() => {
|
|
341
|
+
setSavedSnapshotKey(snapshotKey({ nodes: nodesRef.current, edges: edgesRef.current }));
|
|
342
|
+
setDirtyRevision(0);
|
|
343
|
+
}, []);
|
|
344
|
+
const undo = useCallback(() => {
|
|
345
|
+
const history = historyRef.current;
|
|
346
|
+
if (!history)
|
|
347
|
+
return;
|
|
348
|
+
const previous = history.undo({ nodes: nodesRef.current, edges: edgesRef.current });
|
|
349
|
+
if (!previous)
|
|
350
|
+
return;
|
|
351
|
+
applySnapshot(previous);
|
|
352
|
+
syncHistoryState();
|
|
353
|
+
}, [applySnapshot, syncHistoryState]);
|
|
354
|
+
const redo = useCallback(() => {
|
|
355
|
+
const history = historyRef.current;
|
|
356
|
+
if (!history)
|
|
357
|
+
return;
|
|
358
|
+
const next = history.redo({ nodes: nodesRef.current, edges: edgesRef.current });
|
|
359
|
+
if (!next)
|
|
360
|
+
return;
|
|
361
|
+
applySnapshot(next);
|
|
362
|
+
syncHistoryState();
|
|
363
|
+
}, [applySnapshot, syncHistoryState]);
|
|
364
|
+
const reset = useCallback((next) => {
|
|
365
|
+
const nextNodes = next?.nodes ?? [];
|
|
366
|
+
const nextEdges = next?.edges ?? [];
|
|
367
|
+
nodesRef.current = nextNodes;
|
|
368
|
+
edgesRef.current = nextEdges;
|
|
369
|
+
setNodes(nextNodes);
|
|
370
|
+
setEdges(nextEdges);
|
|
371
|
+
clearHistory();
|
|
372
|
+
setSavedSnapshotKey(snapshotKey({ nodes: nextNodes, edges: nextEdges }));
|
|
373
|
+
setDirtyRevision(0);
|
|
374
|
+
}, [clearHistory, setEdges, setNodes]);
|
|
375
|
+
const applyRemoteGraph = useCallback((next, phase) => {
|
|
376
|
+
nodesRef.current = next.nodes;
|
|
377
|
+
edgesRef.current = next.edges;
|
|
378
|
+
setNodes(next.nodes);
|
|
379
|
+
setEdges(next.edges);
|
|
380
|
+
clearHistory();
|
|
381
|
+
const nextKey = snapshotKey(next);
|
|
382
|
+
if (phase === 'bootstrap') {
|
|
383
|
+
setSavedSnapshotKey(nextKey);
|
|
384
|
+
setDirtyRevision(0);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
setDirtyRevision((revision) => (nextKey === savedSnapshotKey ? 0 : revision + 1));
|
|
388
|
+
}
|
|
389
|
+
}, [clearHistory, savedSnapshotKey, setEdges, setNodes]);
|
|
390
|
+
const applyRemotePatch = useCallback((patch, phase) => {
|
|
391
|
+
applyRemoteGraph(applySnapshotPatch(nodesRef.current, edgesRef.current, patch), phase);
|
|
392
|
+
}, [applyRemoteGraph]);
|
|
393
|
+
const setDirtyNodes = useCallback((value) => {
|
|
394
|
+
recordHistory();
|
|
395
|
+
markDirty();
|
|
396
|
+
setNodes(value);
|
|
397
|
+
}, [markDirty, recordHistory, setNodes]);
|
|
398
|
+
// A quiet commit for internal, non-user edits (e.g. freezing node identity at
|
|
399
|
+
// save): it must NOT push an undo checkpoint or mark the graph dirty, so undo
|
|
400
|
+
// can never revert an identity stamp back to an unfrozen state.
|
|
401
|
+
const commitNodesQuiet = useCallback((value) => {
|
|
402
|
+
setNodes(value);
|
|
403
|
+
}, [setNodes]);
|
|
404
|
+
const setDirtyEdges = useCallback((value) => {
|
|
405
|
+
recordHistory();
|
|
406
|
+
markDirty();
|
|
407
|
+
setEdges(value);
|
|
408
|
+
}, [markDirty, recordHistory, setEdges]);
|
|
409
|
+
const selectedNodeIds = useMemo(() => nodes.filter((n) => n.selected).map((n) => n.id), [nodes]);
|
|
410
|
+
const selectedNode = useMemo(() => selectedNodeIds.length === 1 ? (nodeById.get(selectedNodeIds[0]) ?? null) : null, [nodeById, selectedNodeIds]);
|
|
411
|
+
return {
|
|
412
|
+
nodes,
|
|
413
|
+
edges,
|
|
414
|
+
onNodesChange,
|
|
415
|
+
onEdgesChange,
|
|
416
|
+
setNodes: setDirtyNodes,
|
|
417
|
+
commitNodesQuiet,
|
|
418
|
+
setEdges: setDirtyEdges,
|
|
419
|
+
onConnect,
|
|
420
|
+
isValidConnection,
|
|
421
|
+
addNodeAt,
|
|
422
|
+
addNodeAtEnd,
|
|
423
|
+
addConnectedNodeAt,
|
|
424
|
+
insertNodeOnEdge,
|
|
425
|
+
removeNode,
|
|
426
|
+
removeNodesAndEdges,
|
|
427
|
+
duplicateNode,
|
|
428
|
+
undo,
|
|
429
|
+
redo,
|
|
430
|
+
canUndo: historyState.canUndo,
|
|
431
|
+
canRedo: historyState.canRedo,
|
|
432
|
+
copy,
|
|
433
|
+
paste,
|
|
434
|
+
tidy,
|
|
435
|
+
selectNode,
|
|
436
|
+
deselectAll,
|
|
437
|
+
selectedNode,
|
|
438
|
+
selectedNodeIds,
|
|
439
|
+
updateNodeData,
|
|
440
|
+
focusRequest,
|
|
441
|
+
requestFocus,
|
|
442
|
+
isDirty: snapshotKey({ nodes, edges }) !== savedSnapshotKey,
|
|
443
|
+
dirtyRevision,
|
|
444
|
+
markSaved,
|
|
445
|
+
reset,
|
|
446
|
+
applyRemoteGraph,
|
|
447
|
+
applyRemotePatch,
|
|
448
|
+
positionRevision,
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function snapshotKey(snapshot) {
|
|
452
|
+
return JSON.stringify({
|
|
453
|
+
nodes: snapshot.nodes.map((node) => ({
|
|
454
|
+
id: node.id,
|
|
455
|
+
type: node.type ?? 'atmos',
|
|
456
|
+
position: { x: Math.round(node.position.x), y: Math.round(node.position.y) },
|
|
457
|
+
data: node.data,
|
|
458
|
+
})),
|
|
459
|
+
edges: snapshot.edges.map((edge) => ({
|
|
460
|
+
id: edge.id,
|
|
461
|
+
source: edge.source,
|
|
462
|
+
target: edge.target,
|
|
463
|
+
type: edge.type ?? 'atmos',
|
|
464
|
+
sourceHandle: edge.sourceHandle ?? null,
|
|
465
|
+
targetHandle: edge.targetHandle ?? null,
|
|
466
|
+
data: edge.data ?? null,
|
|
467
|
+
})),
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
function applySnapshotPatch(currentNodes, currentEdges, patch) {
|
|
471
|
+
const selected = new Set(currentNodes.filter((node) => node.selected).map((node) => node.id));
|
|
472
|
+
const deletedNodeIds = new Set(patch.nodes?.deleteIds ?? []);
|
|
473
|
+
const nodes = currentNodes.filter((node) => !deletedNodeIds.has(node.id));
|
|
474
|
+
const nodeIndex = new Map(nodes.map((node, index) => [node.id, index]));
|
|
475
|
+
for (const node of patch.nodes?.upsert ?? []) {
|
|
476
|
+
const next = { ...node, selected: selected.has(node.id) };
|
|
477
|
+
const index = nodeIndex.get(node.id);
|
|
478
|
+
if (index === undefined) {
|
|
479
|
+
nodeIndex.set(node.id, nodes.length);
|
|
480
|
+
nodes.push(next);
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
nodes[index] = next;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const deletedEdgeIds = new Set(patch.edges?.deleteIds ?? []);
|
|
487
|
+
const edges = currentEdges
|
|
488
|
+
.filter((edge) => !deletedNodeIds.has(edge.source) && !deletedNodeIds.has(edge.target))
|
|
489
|
+
.filter((edge) => !deletedEdgeIds.has(edge.id));
|
|
490
|
+
const edgeIndex = new Map(edges.map((edge, index) => [edge.id, index]));
|
|
491
|
+
for (const edge of patch.edges?.upsert ?? []) {
|
|
492
|
+
const index = edgeIndex.get(edge.id);
|
|
493
|
+
if (index === undefined) {
|
|
494
|
+
edgeIndex.set(edge.id, edges.length);
|
|
495
|
+
edges.push(edge);
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
edges[index] = edge;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return { nodes, edges };
|
|
502
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '../lib/react-19-jsx.js';
|
|
2
|
+
export * from './canvas/canvas-frame.js';
|
|
3
|
+
export * from './canvas/connector-edge.js';
|
|
4
|
+
export * from './canvas/editor-context.js';
|
|
5
|
+
export * from './canvas/graph-core.js';
|
|
6
|
+
export * from './canvas/node-card.js';
|
|
7
|
+
export * from './canvas/node-library.js';
|
|
8
|
+
export * from './canvas/sticky-notes.js';
|
|
9
|
+
export * from './collaborative-graph-presence.js';
|
|
10
|
+
export * from './collaborative-graph-sync.js';
|
|
11
|
+
export * from './use-collaborative-graph.js';
|
|
12
|
+
export * from './editor/adapter.js';
|
|
13
|
+
export * from './editor/command-registry.js';
|
|
14
|
+
export * from './editor/dag-canvas.js';
|
|
15
|
+
export * from './editor/flow-editor.js';
|
|
16
|
+
export * from './editor/issues-popover.js';
|
|
17
|
+
export * from './editor/library-rail.js';
|
|
18
|
+
export * from './editor/make-controller.js';
|
|
19
|
+
export * from './editor/node-chip.js';
|
|
20
|
+
export * from './editor/save-publish-bar.js';
|
|
21
|
+
export * from './editor/settings-dialog.js';
|
|
22
|
+
export * from './editor/settings-shell.js';
|
|
23
|
+
export * from './editor/side-rail.js';
|
|
24
|
+
export * from './editor/use-dag-editor.js';
|
|
25
|
+
export * from './use-debounced-value.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '../lib/react-19-jsx.js';
|
|
2
|
+
export * from './canvas/canvas-frame.js';
|
|
3
|
+
export * from './canvas/connector-edge.js';
|
|
4
|
+
export * from './canvas/editor-context.js';
|
|
5
|
+
export * from './canvas/graph-core.js';
|
|
6
|
+
export * from './canvas/node-card.js';
|
|
7
|
+
export * from './canvas/node-library.js';
|
|
8
|
+
export * from './canvas/sticky-notes.js';
|
|
9
|
+
export * from './collaborative-graph-presence.js';
|
|
10
|
+
export * from './collaborative-graph-sync.js';
|
|
11
|
+
export * from './use-collaborative-graph.js';
|
|
12
|
+
export * from './editor/adapter.js';
|
|
13
|
+
export * from './editor/command-registry.js';
|
|
14
|
+
export * from './editor/dag-canvas.js';
|
|
15
|
+
export * from './editor/flow-editor.js';
|
|
16
|
+
export * from './editor/issues-popover.js';
|
|
17
|
+
export * from './editor/library-rail.js';
|
|
18
|
+
export * from './editor/make-controller.js';
|
|
19
|
+
export * from './editor/node-chip.js';
|
|
20
|
+
export * from './editor/save-publish-bar.js';
|
|
21
|
+
export * from './editor/settings-dialog.js';
|
|
22
|
+
export * from './editor/settings-shell.js';
|
|
23
|
+
export * from './editor/side-rail.js';
|
|
24
|
+
export * from './editor/use-dag-editor.js';
|
|
25
|
+
export * from './use-debounced-value.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface MotionPoint {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
interface MotionTarget {
|
|
6
|
+
id: string;
|
|
7
|
+
point: MotionPoint | null | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare function useSmoothedFlowPoints(targets: readonly MotionTarget[]): ReadonlyMap<string, MotionPoint>;
|
|
10
|
+
export {};
|