@heyramzi/ui 2.8.0 → 2.10.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/COMPONENTS.md +1 -1
- package/README.md +1 -1
- package/dist/agents/helpers.js +52 -0
- package/dist/agents/index.js +3 -0
- package/dist/agents/page-state.js +65 -0
- package/dist/agents/types.js +1 -0
- package/dist/agents/vendor/color.js +149 -0
- package/dist/agents/vendor/draw.js +548 -0
- package/dist/agents/vendor/engine.js +632 -0
- package/dist/agents/vendor/mesh.js +727 -0
- package/dist/agents/vendor/plastic.js +3273 -0
- package/dist/agents/vendor/presets.js +171 -0
- package/dist/agents/vendor/shapes.js +24 -0
- package/dist/agents/vendor/ticker.js +56 -0
- package/dist/agents/vendor/types.js +0 -0
- package/dist/agents/vendor/wear.js +1525 -0
- package/dist/ai/ai-button/index.js +2 -0
- package/dist/ai/confirmation/confirmation-context.svelte.js +12 -0
- package/dist/ai/confirmation/index.js +9 -0
- package/dist/ai/generation-progress/index.js +2 -0
- package/dist/ai/index.js +11 -0
- package/dist/ai/loading-state/index.js +3 -0
- package/dist/ai/prompt-input/index.js +6 -0
- package/dist/ai/reasoning/index.js +4 -0
- package/dist/ai/reasoning/reasoning-context.svelte.js +12 -0
- package/dist/ai/response/index.js +3 -0
- package/dist/ai/suggestion/index.js +3 -0
- package/dist/ai/thinking-dots/index.js +3 -0
- package/dist/ai/typing-dots/index.js +2 -0
- package/dist/ai/voice-waveform/index.js +3 -0
- package/dist/animations/text-swap.js +30 -0
- package/dist/brand/index.js +65 -0
- package/dist/canvas/card/resize.js +10 -0
- package/dist/canvas/edges/edge-path.js +284 -0
- package/dist/canvas/editor/context-menu.js +42 -0
- package/dist/canvas/editor/dispatch.svelte.js +157 -0
- package/dist/canvas/editor/editor-context.js +8 -0
- package/dist/canvas/editor/editor-mode.js +0 -0
- package/dist/canvas/editor/frame.js +87 -0
- package/dist/canvas/editor/hand-context.js +8 -0
- package/dist/canvas/editor/history-core.js +221 -0
- package/dist/canvas/editor/keymap.js +193 -0
- package/dist/canvas/editor/layout-actions.js +170 -0
- package/dist/canvas/editor/lock.js +65 -0
- package/dist/canvas/editor/rebase.js +279 -0
- package/dist/canvas/editor/style.js +174 -0
- package/dist/canvas/editor/text-field-context.js +8 -0
- package/dist/canvas/editor/z-order.js +82 -0
- package/dist/canvas/headless/alignment.js +20 -0
- package/dist/canvas/headless/break-apart-find.js +324 -0
- package/dist/canvas/headless/break-apart-pieces.js +74 -0
- package/dist/canvas/headless/break-apart-plan.js +378 -0
- package/dist/canvas/headless/break-apart-style.js +93 -0
- package/dist/canvas/headless/break-apart.js +206 -0
- package/dist/canvas/headless/canvas-cleanup.js +70 -0
- package/dist/canvas/headless/edge-anchors.js +134 -0
- package/dist/canvas/headless/edge-memo.js +28 -0
- package/dist/canvas/headless/edge-serialization.js +31 -0
- package/dist/canvas/headless/figure-geometry.js +331 -0
- package/dist/canvas/headless/fit-viewport.js +82 -0
- package/dist/canvas/headless/grid.js +96 -0
- package/dist/canvas/headless/icon-node.js +45 -0
- package/dist/canvas/headless/index.js +1 -0
- package/dist/canvas/headless/linkify.js +25 -0
- package/dist/canvas/headless/pen-marks.js +115 -0
- package/dist/canvas/headless/sketch.js +250 -0
- package/dist/canvas/headless/snap-guides.js +100 -0
- package/dist/canvas/headless/svg-figure.js +137 -0
- package/dist/canvas/headless/table-layout.js +161 -0
- package/dist/canvas/index.js +25 -0
- package/dist/canvas/lod/lod-mode.svelte.js +22 -0
- package/dist/canvas/lod/render-all.svelte.js +45 -0
- package/dist/canvas/ops/arrange.js +83 -0
- package/dist/canvas/ops/ops.js +318 -0
- package/dist/canvas/pen/colors.js +41 -0
- package/dist/canvas/pen/eraser.js +35 -0
- package/dist/canvas/pen/geometry.js +143 -0
- package/dist/canvas/pen/index.js +9 -0
- package/dist/canvas/pen/ops.js +15 -0
- package/dist/canvas/pen/pen-session.js +171 -0
- package/dist/canvas/pen/plugin.js +129 -0
- package/dist/canvas/pen/shapes.js +80 -0
- package/dist/canvas/pen/stroke-path.js +37 -0
- package/dist/canvas/pen/types.js +30 -0
- package/dist/canvas/pen/ui.js +20 -0
- package/dist/canvas/plugin.js +51 -0
- package/dist/canvas/screen/glyphs.js +24 -0
- package/dist/canvas/screen/labels.js +24 -0
- package/dist/canvas/screen/parts.js +140 -0
- package/dist/canvas/screen/plugin.js +71 -0
- package/dist/canvas/screen/types.js +44 -0
- package/dist/canvas/screen/ui.js +13 -0
- package/dist/canvas/test-utils.js +18 -0
- package/dist/canvas/types.js +0 -0
- package/dist/canvas/ui/forward-wheel.js +27 -0
- package/dist/canvas/ui/icons.js +133 -0
- package/dist/canvas/ui/place-panel.js +57 -0
- package/dist/canvas/ui/shortcut-tip.js +18 -0
- package/dist/canvas/ui/tools.js +411 -0
- package/dist/charts/dashboard/chart.js +1 -0
- package/dist/charts/dashboard/data-table.js +7 -0
- package/dist/charts/dashboard/index.js +13 -0
- package/dist/charts/dashboard/windows.js +5 -0
- package/dist/charts/edge-fade.js +7 -0
- package/dist/charts/hover-band.js +13 -0
- package/dist/charts/index.js +19 -0
- package/dist/charts/motion.js +15 -0
- package/dist/charts/primitives/chart-utils.js +22 -0
- package/dist/charts/primitives/index.js +4 -0
- package/dist/components/copy/clipboard.js +38 -0
- package/dist/components/copy/copied.svelte.js +26 -0
- package/dist/components/copy/index.js +3 -0
- package/dist/components/data-table/data-table.js +55 -0
- package/dist/components/data-table/index.js +7 -0
- package/dist/components/docs/index.js +3 -0
- package/dist/components/docs/scroll-spy.svelte.js +71 -0
- package/dist/components/field-row/index.js +1 -0
- package/dist/components/hold-to-confirm/index.js +1 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/language-flag/index.js +1 -0
- package/dist/components/list-page/filter-section.js +4 -0
- package/dist/components/list-page/index.js +25 -0
- package/dist/components/list-page/list-table.js +5 -0
- package/dist/components/list-page/queue-rail.js +3 -0
- package/dist/components/list-page/section-host.js +8 -0
- package/dist/components/list-page/step.js +5 -0
- package/dist/components/list-page/types.js +0 -0
- package/dist/components/locale-switch/index.js +1 -0
- package/dist/components/mark/index.js +1 -0
- package/dist/components/open-in/index.js +1 -0
- package/dist/components/picker/index.js +3 -0
- package/dist/components/picker/trigger.js +33 -0
- package/dist/components/picker/types.js +0 -0
- package/dist/components/section-card/index.js +1 -0
- package/dist/components/section-header/index.js +2 -0
- package/dist/components/segmented/collapse.js +32 -0
- package/dist/components/segmented/index.js +8 -0
- package/dist/components/segmented/segmented.js +50 -0
- package/dist/components/star-rating-input/index.js +2 -0
- package/dist/components/svg/index.js +1 -0
- package/dist/components/table-view/index.js +1 -0
- package/dist/components/table-view/types.js +0 -0
- package/dist/components/tags-input/index.js +2 -0
- package/dist/components/tags-input/tags.js +90 -0
- package/dist/components/theme/index.js +3 -0
- package/dist/components/toolbar/index.js +3 -0
- package/dist/components/toolbar/toolbar-trigger.js +4 -0
- package/dist/editor/anchors.js +17 -0
- package/dist/editor/block-id.js +62 -0
- package/dist/editor/block-ops.js +105 -0
- package/dist/editor/doc-blocks.js +181 -0
- package/dist/editor/extensions.js +200 -0
- package/dist/editor/index.js +4 -0
- package/dist/editor/markdown-test-helpers.js +6 -0
- package/dist/editor/markdown.js +486 -0
- package/dist/editor/serializer.js +268 -0
- package/dist/editor/slash-items.js +104 -0
- package/dist/editor/youtube-url.js +27 -0
- package/dist/effects/animated-beam/index.js +1 -0
- package/dist/effects/animated-beam/path-calculator.svelte.js +42 -0
- package/dist/effects/animated-beam/types.js +0 -0
- package/dist/effects/border-beam/css.js +420 -0
- package/dist/effects/border-beam/presets.js +1792 -0
- package/dist/effects/border-beam/register-properties.js +39 -0
- package/dist/effects/border-beam/types.js +0 -0
- package/dist/effects/image-comparison/compare.js +4 -0
- package/dist/effects/image-reveal/index.js +1 -0
- package/dist/effects/image-reveal/types.js +0 -0
- package/dist/effects/magnetic/magnetic.js +54 -0
- package/dist/effects/reveal/index.js +4 -0
- package/dist/effects/reveal/observe.js +43 -0
- package/dist/effects/reveal/types.js +0 -0
- package/dist/effects/shader-gradient/color.js +34 -0
- package/dist/effects/shader-gradient/index.js +1 -0
- package/dist/effects/shader-gradient/renderer.js +320 -0
- package/dist/effects/shader-gradient/shaders.js +280 -0
- package/dist/effects/shader-gradient/types.js +0 -0
- package/dist/icons/apple-symbol-exports.js +126 -0
- package/dist/icons/sf-symbols.js +465 -0
- package/dist/icons/trades.js +34 -0
- package/dist/inbox/index.js +4 -0
- package/dist/inbox/logic.js +156 -0
- package/dist/inbox/types.js +46 -0
- package/dist/index.js +18 -0
- package/dist/lib/arrive.js +13 -0
- package/dist/lib/icon-types.js +0 -0
- package/dist/lib/initials.js +17 -0
- package/dist/lib/layout.js +1 -0
- package/dist/lib/panel.js +3 -0
- package/dist/lib/result.js +26 -0
- package/dist/lib/sliding-pill.js +45 -0
- package/dist/lib/theme-transition.js +53 -0
- package/dist/lib/tone.js +32 -0
- package/dist/lib/utils.js +5 -0
- package/dist/onboarding/define-tours.js +28 -0
- package/dist/onboarding/index.js +4 -0
- package/dist/onboarding/onboarding.svelte.js +15 -0
- package/dist/onboarding/pick.js +16 -0
- package/dist/onboarding/stores.js +50 -0
- package/dist/onboarding/types.js +1 -0
- package/dist/onboarding/wait.js +25 -0
- package/dist/panel/index.js +1 -0
- package/dist/panel/side-panel-types.js +0 -0
- package/dist/record/demo-data.js +512 -0
- package/dist/record/fields.js +148 -0
- package/dist/record/format.js +97 -0
- package/dist/record/gutter.js +1 -0
- package/dist/record/index.js +15 -0
- package/dist/record/kinds.js +110 -0
- package/dist/record/logic.js +255 -0
- package/dist/record/types.js +52 -0
- package/dist/shadcn/accordion/index.js +5 -0
- package/dist/shadcn/alert/index.js +5 -0
- package/dist/shadcn/alert-dialog/index.js +12 -0
- package/dist/shadcn/attachment/index.js +10 -0
- package/dist/shadcn/avatar/index.js +7 -0
- package/dist/shadcn/badge/index.js +2 -0
- package/dist/shadcn/breadcrumb/index.js +8 -0
- package/dist/shadcn/bubble/index.js +5 -0
- package/dist/shadcn/button/index.js +2 -0
- package/dist/shadcn/calendar/index.js +19 -0
- package/dist/shadcn/card/index.js +8 -0
- package/dist/shadcn/checkbox/index.js +2 -0
- package/dist/shadcn/code-block/index.js +9 -0
- package/dist/shadcn/collapsible/index.js +4 -0
- package/dist/shadcn/command/index.js +13 -0
- package/dist/shadcn/context-menu/index.js +17 -0
- package/dist/shadcn/dialog/index.js +11 -0
- package/dist/shadcn/dropdown-menu/index.js +19 -0
- package/dist/shadcn/dropdown-menu/menu-item.js +23 -0
- package/dist/shadcn/empty/index.js +7 -0
- package/dist/shadcn/field/index.js +12 -0
- package/dist/shadcn/hooks/highlighter.js +92 -0
- package/dist/shadcn/hooks/is-mobile.svelte.js +7 -0
- package/dist/shadcn/hooks/use-highlighted-code.svelte.js +65 -0
- package/dist/shadcn/hover-card/index.js +5 -0
- package/dist/shadcn/input/index.js +3 -0
- package/dist/shadcn/input-otp/index.js +5 -0
- package/dist/shadcn/kbd/index.js +3 -0
- package/dist/shadcn/label/index.js +2 -0
- package/dist/shadcn/marker/index.js +4 -0
- package/dist/shadcn/message/index.js +7 -0
- package/dist/shadcn/message-scroller/index.js +8 -0
- package/dist/shadcn/popover/index.js +9 -0
- package/dist/shadcn/progress/index.js +2 -0
- package/dist/shadcn/progress/tone.js +11 -0
- package/dist/shadcn/radio-group/index.js +3 -0
- package/dist/shadcn/scroll-area/index.js +3 -0
- package/dist/shadcn/select/index.js +12 -0
- package/dist/shadcn/separator/index.js +2 -0
- package/dist/shadcn/sheet/index.js +11 -0
- package/dist/shadcn/sidebar/constants.js +6 -0
- package/dist/shadcn/sidebar/context.svelte.js +38 -0
- package/dist/shadcn/sidebar/index.js +25 -0
- package/dist/shadcn/skeleton/index.js +2 -0
- package/dist/shadcn/slider/index.js +2 -0
- package/dist/shadcn/sonner/index.js +1 -0
- package/dist/shadcn/spinner/index.js +1 -0
- package/dist/shadcn/switch/index.js +2 -0
- package/dist/shadcn/table/index.js +9 -0
- package/dist/shadcn/tabs/index.js +5 -0
- package/dist/shadcn/textarea/index.js +2 -0
- package/dist/shadcn/toggle/index.js +3 -0
- package/dist/shadcn/toggle-group/index.js +3 -0
- package/dist/shadcn/tooltip/context.js +8 -0
- package/dist/shadcn/tooltip/index.js +6 -0
- package/dist/shadcn/trace/index.js +9 -0
- package/dist/slides/bridges.js +66 -0
- package/dist/slides/deck-controller.svelte.js +221 -0
- package/dist/slides/export/capture.js +81 -0
- package/dist/slides/export/ffmpeg.js +85 -0
- package/dist/slides/export/index.js +4 -0
- package/dist/slides/export/launch.js +8 -0
- package/dist/slides/export/pdf.js +78 -0
- package/dist/slides/export/types.js +0 -0
- package/dist/slides/index.js +7 -0
- package/dist/slides/labels.js +26 -0
- package/dist/slides/layout.js +47 -0
- package/dist/slides/model.js +9 -0
- package/dist/slides/navigation.js +89 -0
- package/dist/slides/types.js +6 -0
- package/dist/status/define-statuses.js +16 -0
- package/dist/status/index.js +4 -0
- package/dist/status/status-types.js +0 -0
- package/dist/test-setup.js +26 -0
- package/dist/thread/index.js +3 -0
- package/dist/thread/logic.js +94 -0
- package/dist/thread/types.js +23 -0
- package/dist/work/board-order.js +109 -0
- package/dist/work/dates.js +19 -0
- package/dist/work/detail/detail-types.js +20 -0
- package/dist/work/docs/edited.js +39 -0
- package/dist/work/docs/index.js +7 -0
- package/dist/work/docs/labels.js +38 -0
- package/dist/work/docs/menu.js +121 -0
- package/dist/work/docs/outline.js +39 -0
- package/dist/work/gantt/logic.js +260 -0
- package/dist/work/inbox/inbox-logic.js +94 -0
- package/dist/work/inbox/inbox-statuses.js +86 -0
- package/dist/work/inbox/inbox-types.js +0 -0
- package/dist/work/inbox/index.js +1 -0
- package/dist/work/index.js +21 -0
- package/dist/work/kanban-drag.js +25 -0
- package/dist/work/kanban-types.js +0 -0
- package/dist/work/presets/sales.js +35 -0
- package/dist/work/reorder.js +10 -0
- package/dist/work/task-types.js +0 -0
- package/dist/work/time/duration.js +60 -0
- package/dist/work/time/time-types.js +25 -0
- package/dist/work/use-kanban-dnd.svelte.js +128 -0
- package/package.json +102 -76
- package/src/agents/vendor/draw.ts +4 -4
- package/src/canvas/headless/canvas-cleanup.test.ts +1 -1
- package/src/canvas/ops/ops.ts +1 -1
- package/src/charts/area-chart.svelte +11 -1
- package/src/charts/bar-chart.svelte +18 -3
- package/src/charts/line-chart.svelte +11 -1
- package/src/components/data-table/data-table.ts +4 -5
- package/src/components/data-table/pagination.svelte +5 -3
- package/src/components/docs/on-this-page.svelte +82 -5
- package/src/components/docs/scroll-spy.svelte.ts +6 -1
- package/src/components/list-page/detail-header.svelte +7 -3
- package/src/components/list-page/empty-state.svelte +3 -1
- package/src/components/list-page/filter-popover.svelte +2 -2
- package/src/components/list-page/rail-row.svelte +5 -2
- package/src/components/mark/mark.svelte +2 -1
- package/src/components/section-card/section-card.svelte +3 -1
- package/src/components/section-header/section-header.svelte +5 -5
- package/src/components/segmented/segment.svelte +1 -1
- package/src/components/table-view/table-view.svelte +6 -1
- package/src/components/tags-input/tags-input.svelte +1 -1
- package/src/components/toolbar/toolbar-trigger.ts +8 -2
- package/src/components/toolbar/toolbar.svelte +1 -1
- package/src/editor/anchors.ts +28 -0
- package/src/editor/doc-blocks.ts +168 -0
- package/src/editor/doc-page.css +389 -0
- package/src/editor/editor.svelte +47 -5
- package/src/editor/extensions.ts +26 -2
- package/src/editor/markdown.ts +27 -2
- package/src/editor/slash-items.ts +18 -0
- package/src/icons/trades.ts +1 -1
- package/src/inbox/README.md +6 -4
- package/src/inbox/inbox.test.ts +1 -1
- package/src/inbox/index.ts +2 -2
- package/src/inbox/logic.ts +29 -5
- package/src/inbox/thread-inbox.svelte +219 -92
- package/src/inbox/types.ts +27 -1
- package/src/lib/initials.test.ts +25 -0
- package/src/lib/initials.ts +29 -0
- package/src/modules.test.ts +4 -64
- package/src/panel/README.md +1 -1
- package/src/record/README.md +1 -1
- package/src/record/demo-data.ts +4 -4
- package/src/record/info-list.svelte +5 -4
- package/src/record/next-up.svelte +1 -1
- package/src/record/project-list.svelte +1 -1
- package/src/record/record-demo.svelte +2 -2
- package/src/record/steps-rail.svelte +3 -3
- package/src/shadcn/badge/badge.svelte +1 -1
- package/src/shadcn/card/card-title.svelte +1 -5
- package/src/shadcn/empty/empty-description.svelte +1 -1
- package/src/shadcn/progress/progress.svelte +8 -1
- package/src/shadcn/table/table-cell.svelte +10 -2
- package/src/status/README.md +1 -1
- package/src/thread/README.md +2 -0
- package/src/thread/index.ts +9 -1
- package/src/thread/logic.ts +33 -3
- package/src/thread/thread-body.svelte +37 -0
- package/src/thread/thread-events.svelte +30 -0
- package/src/thread/thread.svelte +74 -59
- package/src/thread/types.ts +21 -0
- package/src/{tasks → work}/README.md +11 -8
- package/src/{tasks → work}/detail/task-thread.svelte +8 -15
- package/src/work/docs/doc-editor-page.svelte +194 -0
- package/src/work/docs/doc-menu.svelte +333 -0
- package/src/work/docs/docs-demo.svelte +227 -0
- package/src/work/docs/edited-chip.svelte +125 -0
- package/src/work/docs/edited.ts +54 -0
- package/src/work/docs/index.ts +38 -0
- package/src/work/docs/labels.ts +70 -0
- package/src/work/docs/menu.ts +127 -0
- package/src/work/docs/outline.ts +60 -0
- package/src/{tasks → work}/gantt/gantt-group-row.svelte +1 -1
- package/src/{tasks → work}/inbox/inbox-card.svelte +113 -50
- package/src/work/inbox/inbox-logic.ts +98 -0
- package/src/work/inbox/inbox-trace.svelte +58 -0
- package/src/{tasks → work}/inbox/inbox-types.ts +2 -0
- package/src/{tasks → work}/index.ts +0 -10
- package/src/{tasks → work}/kanban-board.svelte +1 -1
- package/src/{tasks → work}/task-list.svelte +1 -1
- package/src/{tasks → work}/time/time-tracker.svelte +2 -5
- package/src/tasks/inbox/inbox-logic.ts +0 -21
- package/src/tasks/inbox/inbox-trace.svelte +0 -51
- /package/src/{tasks → work}/ambient.d.ts +0 -0
- /package/src/{tasks → work}/board-order.ts +0 -0
- /package/src/{tasks → work}/dates.ts +0 -0
- /package/src/{tasks → work}/demo.svelte +0 -0
- /package/src/{tasks → work}/detail/detail-demo.svelte +0 -0
- /package/src/{tasks → work}/detail/detail-types.ts +0 -0
- /package/src/{tasks → work}/detail/task-chip.svelte +0 -0
- /package/src/{tasks → work}/detail/task-detail.svelte +0 -0
- /package/src/{tasks → work}/detail/task-property.svelte +0 -0
- /package/src/{tasks → work}/gantt/gantt-bar.svelte +0 -0
- /package/src/{tasks → work}/gantt/gantt-grid.svelte +0 -0
- /package/src/{tasks → work}/gantt/gantt-header.svelte +0 -0
- /package/src/{tasks → work}/gantt/gantt-task-row.svelte +0 -0
- /package/src/{tasks → work}/gantt/gantt.css +0 -0
- /package/src/{tasks → work}/gantt/gantt.test.ts +0 -0
- /package/src/{tasks → work}/gantt/logic.test.ts +0 -0
- /package/src/{tasks → work}/gantt/logic.ts +0 -0
- /package/src/{tasks → work}/inbox/inbox-draft.svelte +0 -0
- /package/src/{tasks → work}/inbox/inbox-statuses.ts +0 -0
- /package/src/{tasks → work}/inbox/index.ts +0 -0
- /package/src/{tasks → work}/kanban-column.svelte +0 -0
- /package/src/{tasks → work}/kanban-drag.ts +0 -0
- /package/src/{tasks → work}/kanban-types.ts +0 -0
- /package/src/{tasks → work}/presets/sales.ts +0 -0
- /package/src/{tasks → work}/reorder.ts +0 -0
- /package/src/{tasks → work}/task-gantt.svelte +0 -0
- /package/src/{tasks → work}/task-types.ts +0 -0
- /package/src/{tasks → work}/time/duration.ts +0 -0
- /package/src/{tasks → work}/time/time-chip.svelte +0 -0
- /package/src/{tasks → work}/time/time-dot.svelte +0 -0
- /package/src/{tasks → work}/time/time-ring.svelte +0 -0
- /package/src/{tasks → work}/time/time-types.ts +0 -0
- /package/src/{tasks → work}/use-kanban-dnd.svelte.ts +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
const CONFIRMATION_CONTEXT_KEY = Symbol("confirmation-context");
|
|
3
|
+
export function setConfirmationContext(value) {
|
|
4
|
+
setContext(CONFIRMATION_CONTEXT_KEY, value);
|
|
5
|
+
}
|
|
6
|
+
export function getConfirmationContext() {
|
|
7
|
+
const context = getContext(CONFIRMATION_CONTEXT_KEY);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("Confirmation parts must be used inside a <Confirmation>.");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Confirmation from "../../../src/ai/confirmation/Confirmation.svelte";
|
|
2
|
+
import ConfirmationTitle from "../../../src/ai/confirmation/ConfirmationTitle.svelte";
|
|
3
|
+
import ConfirmationRequest from "../../../src/ai/confirmation/ConfirmationRequest.svelte";
|
|
4
|
+
import ConfirmationAccepted from "../../../src/ai/confirmation/ConfirmationAccepted.svelte";
|
|
5
|
+
import ConfirmationRejected from "../../../src/ai/confirmation/ConfirmationRejected.svelte";
|
|
6
|
+
import ConfirmationFailed from "../../../src/ai/confirmation/ConfirmationFailed.svelte";
|
|
7
|
+
import ConfirmationActions from "../../../src/ai/confirmation/ConfirmationActions.svelte";
|
|
8
|
+
import ConfirmationAction from "../../../src/ai/confirmation/ConfirmationAction.svelte";
|
|
9
|
+
export { Confirmation, ConfirmationTitle, ConfirmationRequest, ConfirmationAccepted, ConfirmationRejected, ConfirmationFailed, ConfirmationActions, ConfirmationAction, Confirmation as Root, ConfirmationTitle as Title, ConfirmationRequest as Request, ConfirmationAccepted as Accepted, ConfirmationRejected as Rejected, ConfirmationFailed as Failed, ConfirmationActions as Actions, ConfirmationAction as Action };
|
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { TypingDots } from "./typing-dots/index.js";
|
|
2
|
+
export { Response } from "./response/index.js";
|
|
3
|
+
export { Suggestion, Suggestions } from "./suggestion/index.js";
|
|
4
|
+
export { PromptInput, PromptInputBody, PromptInputToolbar, PromptInputTextarea, PromptInputSubmit } from "./prompt-input/index.js";
|
|
5
|
+
export { Confirmation, ConfirmationTitle, ConfirmationRequest, ConfirmationAccepted, ConfirmationRejected, ConfirmationActions, ConfirmationAction } from "./confirmation/index.js";
|
|
6
|
+
export { ThinkingDots } from "./thinking-dots/index.js";
|
|
7
|
+
export { VoiceWaveform } from "./voice-waveform/index.js";
|
|
8
|
+
export { Reasoning, ReasoningTrigger, ReasoningContent } from "./reasoning/index.js";
|
|
9
|
+
export { PixelLoader } from "./loading-state/index.js";
|
|
10
|
+
export { AiButton } from "./ai-button/index.js";
|
|
11
|
+
export { GenerationProgress } from "./generation-progress/index.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import PromptInput from "../../../src/ai/prompt-input/PromptInput.svelte";
|
|
2
|
+
import PromptInputBody from "../../../src/ai/prompt-input/PromptInputBody.svelte";
|
|
3
|
+
import PromptInputToolbar from "../../../src/ai/prompt-input/PromptInputToolbar.svelte";
|
|
4
|
+
import PromptInputTextarea from "../../../src/ai/prompt-input/PromptInputTextarea.svelte";
|
|
5
|
+
import PromptInputSubmit from "../../../src/ai/prompt-input/PromptInputSubmit.svelte";
|
|
6
|
+
export { PromptInput, PromptInputBody, PromptInputToolbar, PromptInputTextarea, PromptInputSubmit, PromptInput as Root, PromptInputBody as Body, PromptInputToolbar as Toolbar, PromptInputTextarea as Textarea, PromptInputSubmit as Submit };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import Reasoning from "../../../src/ai/reasoning/Reasoning.svelte";
|
|
2
|
+
import ReasoningTrigger from "../../../src/ai/reasoning/ReasoningTrigger.svelte";
|
|
3
|
+
import ReasoningContent from "../../../src/ai/reasoning/ReasoningContent.svelte";
|
|
4
|
+
export { Reasoning, ReasoningTrigger, ReasoningContent, Reasoning as Root, ReasoningTrigger as Trigger, ReasoningContent as Content };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getContext, setContext } from "svelte";
|
|
2
|
+
const REASONING_CONTEXT_KEY = Symbol("reasoning-context");
|
|
3
|
+
export function setReasoningContext(value) {
|
|
4
|
+
setContext(REASONING_CONTEXT_KEY, value);
|
|
5
|
+
}
|
|
6
|
+
export function getReasoningContext() {
|
|
7
|
+
const context = getContext(REASONING_CONTEXT_KEY);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("Reasoning parts must be used inside a <Reasoning>.");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function parseDuration(value) {
|
|
2
|
+
if (!value) return 200;
|
|
3
|
+
const trimmed = value.trim();
|
|
4
|
+
if (trimmed.endsWith("ms")) return Number.parseFloat(trimmed);
|
|
5
|
+
if (trimmed.endsWith("s")) return Number.parseFloat(trimmed) * 1000;
|
|
6
|
+
const parsed = Number.parseFloat(trimmed);
|
|
7
|
+
return Number.isFinite(parsed) ? parsed : 200;
|
|
8
|
+
}
|
|
9
|
+
function prefersReducedMotion() {
|
|
10
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false;
|
|
11
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
12
|
+
}
|
|
13
|
+
export function swapText(el, newText, opts) {
|
|
14
|
+
if (prefersReducedMotion()) {
|
|
15
|
+
el.textContent = newText;
|
|
16
|
+
el.classList.remove("is-exit", "is-enter-start");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const durationMs = opts?.durationMs ?? parseDuration(getComputedStyle(el).getPropertyValue("--text-swap-dur"));
|
|
20
|
+
el.classList.add("t-text-swap", "is-exit");
|
|
21
|
+
window.setTimeout(()=>{
|
|
22
|
+
el.textContent = newText;
|
|
23
|
+
el.classList.remove("is-exit");
|
|
24
|
+
el.classList.add("is-enter-start");
|
|
25
|
+
requestAnimationFrame(()=>{
|
|
26
|
+
void el.offsetHeight;
|
|
27
|
+
el.classList.remove("is-enter-start");
|
|
28
|
+
});
|
|
29
|
+
}, durationMs);
|
|
30
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const COLOR_VARS = {
|
|
2
|
+
brand: "--brand",
|
|
3
|
+
brandOnDark: "--brand-on-dark",
|
|
4
|
+
highlight: "--brand-highlight",
|
|
5
|
+
signal: "--brand-signal",
|
|
6
|
+
ink: "--brand-ink",
|
|
7
|
+
surface: "--brand-surface",
|
|
8
|
+
line: "--brand-line",
|
|
9
|
+
raised: "--brand-raised",
|
|
10
|
+
paper: "--brand-paper",
|
|
11
|
+
surfaceLight: "--brand-surface-light",
|
|
12
|
+
lineLight: "--brand-line-light",
|
|
13
|
+
primary: "--brand-primary",
|
|
14
|
+
primaryForeground: "--brand-primary-foreground",
|
|
15
|
+
primaryOnDark: "--brand-primary-on-dark",
|
|
16
|
+
primaryForegroundOnDark: "--brand-primary-foreground-on-dark"
|
|
17
|
+
};
|
|
18
|
+
const FONT_VARS = {
|
|
19
|
+
sans: "--font-sans",
|
|
20
|
+
heading: "--font-heading",
|
|
21
|
+
mono: "--font-mono",
|
|
22
|
+
quote: "--font-quote"
|
|
23
|
+
};
|
|
24
|
+
export const BRAND_COLOR_VARS = COLOR_VARS;
|
|
25
|
+
export function defineBrand(brand) {
|
|
26
|
+
return brand;
|
|
27
|
+
}
|
|
28
|
+
function checked(name, value) {
|
|
29
|
+
if (/[;{}<>]/.test(value)) throw new Error(`brand: ${name} holds a character CSS would read as more than a value`);
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
export function brandVars(brand) {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [key, name] of Object.entries(COLOR_VARS)){
|
|
35
|
+
const value = brand.colors[key];
|
|
36
|
+
if (value !== undefined) out[name] = checked(name, value);
|
|
37
|
+
}
|
|
38
|
+
for (const [key, name] of Object.entries(FONT_VARS)){
|
|
39
|
+
const value = brand.fonts?.[key];
|
|
40
|
+
if (value !== undefined) out[name] = checked(name, value);
|
|
41
|
+
}
|
|
42
|
+
for (const [name, value] of Object.entries(brand.vars ?? {}))out[name] = checked(name, value);
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
export function brandStyle(brand) {
|
|
46
|
+
return Object.entries(brandVars(brand)).map(([name, value])=>`${name}:${value}`).join(";");
|
|
47
|
+
}
|
|
48
|
+
export function brandCss(brand, selector = ":root") {
|
|
49
|
+
const body = Object.entries(brandVars(brand)).map(([name, value])=>` ${name}: ${value};`).join("\n");
|
|
50
|
+
return `${selector} {\n${body}\n}\n`;
|
|
51
|
+
}
|
|
52
|
+
export function applyBrand(brand, root = document.documentElement) {
|
|
53
|
+
const vars = brandVars(brand);
|
|
54
|
+
const before = new Map();
|
|
55
|
+
for (const [name, value] of Object.entries(vars)){
|
|
56
|
+
before.set(name, root.style.getPropertyValue(name));
|
|
57
|
+
root.style.setProperty(name, value);
|
|
58
|
+
}
|
|
59
|
+
return ()=>{
|
|
60
|
+
for (const [name, value] of before){
|
|
61
|
+
if (value) root.style.setProperty(name, value);
|
|
62
|
+
else root.style.removeProperty(name);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const DEFAULT_MIN_WIDTH = 120;
|
|
2
|
+
export const DEFAULT_MAX_WIDTH = 2400;
|
|
3
|
+
export const DEFAULT_MIN_HEIGHT = 40;
|
|
4
|
+
export function userHeightOf(data) {
|
|
5
|
+
const value = data?.userHeight;
|
|
6
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
7
|
+
}
|
|
8
|
+
export function keptHeight(dragged, content) {
|
|
9
|
+
return Math.max(Math.round(dragged), Math.ceil(content));
|
|
10
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { getBezierPath, getSmoothStepPath, getStraightPath, Position } from "@xyflow/svelte";
|
|
2
|
+
import { bestAnchors, sideDetour, sideFromHandle } from "../headless/edge-anchors.js";
|
|
3
|
+
import { parseBox } from "../headless/edge-memo.js";
|
|
4
|
+
const CORNER = 8;
|
|
5
|
+
const DETOUR = 40;
|
|
6
|
+
const DETOUR_FLOOR = 8;
|
|
7
|
+
const OUT = {
|
|
8
|
+
top: {
|
|
9
|
+
x: 0,
|
|
10
|
+
y: -1
|
|
11
|
+
},
|
|
12
|
+
right: {
|
|
13
|
+
x: 1,
|
|
14
|
+
y: 0
|
|
15
|
+
},
|
|
16
|
+
bottom: {
|
|
17
|
+
x: 0,
|
|
18
|
+
y: 1
|
|
19
|
+
},
|
|
20
|
+
left: {
|
|
21
|
+
x: -1,
|
|
22
|
+
y: 0
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
export function readBend(data) {
|
|
26
|
+
const raw = data && typeof data === "object" ? data.bend : null;
|
|
27
|
+
return typeof raw === "number" && Number.isFinite(raw) ? raw : 0;
|
|
28
|
+
}
|
|
29
|
+
export function bendFromPointer(handle, pointer) {
|
|
30
|
+
const at = handle.axis === "x" ? pointer.x : pointer.y;
|
|
31
|
+
return Math.round(Math.min(handle.max, Math.max(handle.min, at)) - handle.base);
|
|
32
|
+
}
|
|
33
|
+
function mid(a, b) {
|
|
34
|
+
return (a + b) / 2;
|
|
35
|
+
}
|
|
36
|
+
function clamp(value, a, b) {
|
|
37
|
+
return Math.min(Math.max(a, b), Math.max(Math.min(a, b), value));
|
|
38
|
+
}
|
|
39
|
+
function runPoints(s, t, horizontal, at) {
|
|
40
|
+
return horizontal ? [
|
|
41
|
+
s,
|
|
42
|
+
{
|
|
43
|
+
x: at,
|
|
44
|
+
y: s.y
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
x: at,
|
|
48
|
+
y: t.y
|
|
49
|
+
},
|
|
50
|
+
t
|
|
51
|
+
] : [
|
|
52
|
+
s,
|
|
53
|
+
{
|
|
54
|
+
x: s.x,
|
|
55
|
+
y: at
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
x: t.x,
|
|
59
|
+
y: at
|
|
60
|
+
},
|
|
61
|
+
t
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function runHandle({ source: s, target: t }, horizontal, at, limits) {
|
|
65
|
+
const span = horizontal ? t.y - s.y : t.x - s.x;
|
|
66
|
+
if (!(Math.abs(span) > 1)) return null;
|
|
67
|
+
return {
|
|
68
|
+
axis: horizontal ? "x" : "y",
|
|
69
|
+
x: horizontal ? at : mid(s.x, t.x),
|
|
70
|
+
y: horizontal ? mid(s.y, t.y) : at,
|
|
71
|
+
...limits
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function sameSideElbow(anchors, bend) {
|
|
75
|
+
const { source: s, target: t } = anchors;
|
|
76
|
+
const out = OUT[s.side];
|
|
77
|
+
const horizontal = out.x !== 0;
|
|
78
|
+
const base = sideDetour(anchors, DETOUR);
|
|
79
|
+
const edge = sideDetour(anchors, 0);
|
|
80
|
+
const outward = horizontal ? out.x : out.y;
|
|
81
|
+
const at = clamp(base + bend, edge + outward * DETOUR_FLOOR, outward > 0 ? Infinity : -Infinity);
|
|
82
|
+
const handle = runHandle(anchors, horizontal, at, {
|
|
83
|
+
base,
|
|
84
|
+
min: outward > 0 ? edge + DETOUR_FLOOR : -Infinity,
|
|
85
|
+
max: outward > 0 ? Infinity : edge - DETOUR_FLOOR
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
points: runPoints(s, t, horizontal, at),
|
|
89
|
+
handle
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function acrossElbow(anchors, bend) {
|
|
93
|
+
const { source: s, target: t } = anchors;
|
|
94
|
+
const horizontal = OUT[s.side].x !== 0;
|
|
95
|
+
const base = horizontal ? mid(s.x, t.x) : mid(s.y, t.y);
|
|
96
|
+
const lo = horizontal ? Math.min(s.x, t.x) : Math.min(s.y, t.y);
|
|
97
|
+
const hi = horizontal ? Math.max(s.x, t.x) : Math.max(s.y, t.y);
|
|
98
|
+
const at = clamp(base + bend, lo, hi);
|
|
99
|
+
const handle = runHandle(anchors, horizontal, at, {
|
|
100
|
+
base,
|
|
101
|
+
min: lo,
|
|
102
|
+
max: hi
|
|
103
|
+
});
|
|
104
|
+
return {
|
|
105
|
+
points: runPoints(s, t, horizontal, at),
|
|
106
|
+
handle
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function cornerElbow(anchors) {
|
|
110
|
+
const { source: s, target: t } = anchors;
|
|
111
|
+
const inward = OUT[t.side];
|
|
112
|
+
const horizontalOut = OUT[s.side].x !== 0;
|
|
113
|
+
if (horizontalOut === (inward.x !== 0)) return null;
|
|
114
|
+
const corner = horizontalOut ? {
|
|
115
|
+
x: t.x,
|
|
116
|
+
y: s.y
|
|
117
|
+
} : {
|
|
118
|
+
x: s.x,
|
|
119
|
+
y: t.y
|
|
120
|
+
};
|
|
121
|
+
const arriving = horizontalOut ? Math.sign(t.y - s.y) : Math.sign(t.x - s.x);
|
|
122
|
+
const wanted = horizontalOut ? -inward.y : -inward.x;
|
|
123
|
+
return arriving === wanted ? {
|
|
124
|
+
points: [
|
|
125
|
+
s,
|
|
126
|
+
corner,
|
|
127
|
+
t
|
|
128
|
+
],
|
|
129
|
+
handle: null
|
|
130
|
+
} : null;
|
|
131
|
+
}
|
|
132
|
+
function elbowPoints(anchors, bend) {
|
|
133
|
+
const { source: s, target: t } = anchors;
|
|
134
|
+
if (s.side === t.side) return sameSideElbow(anchors, bend);
|
|
135
|
+
const out = OUT[s.side];
|
|
136
|
+
const inward = OUT[t.side];
|
|
137
|
+
const ahead = out.x * (t.x - s.x) + out.y * (t.y - s.y);
|
|
138
|
+
if (ahead <= 0) return null;
|
|
139
|
+
if (out.x === -inward.x && out.y === -inward.y) return acrossElbow(anchors, bend);
|
|
140
|
+
return cornerElbow(anchors);
|
|
141
|
+
}
|
|
142
|
+
function roundedPath(points) {
|
|
143
|
+
const pts = points.filter((p, i)=>i === 0 || p.x !== points[i - 1].x || p.y !== points[i - 1].y);
|
|
144
|
+
let d = `M ${pts[0].x} ${pts[0].y}`;
|
|
145
|
+
for(let i = 1; i < pts.length - 1; i++){
|
|
146
|
+
const a = pts[i - 1];
|
|
147
|
+
const b = pts[i];
|
|
148
|
+
const c = pts[i + 1];
|
|
149
|
+
const r = Math.min(CORNER, Math.hypot(b.x - a.x, b.y - a.y) / 2, Math.hypot(c.x - b.x, c.y - b.y) / 2);
|
|
150
|
+
const collinear = a.x === b.x && b.x === c.x || a.y === b.y && b.y === c.y;
|
|
151
|
+
if (collinear || !(r > 0.5)) {
|
|
152
|
+
d += ` L ${b.x} ${b.y}`;
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
const before = {
|
|
156
|
+
x: b.x - Math.sign(b.x - a.x) * r,
|
|
157
|
+
y: b.y - Math.sign(b.y - a.y) * r
|
|
158
|
+
};
|
|
159
|
+
const after = {
|
|
160
|
+
x: b.x + Math.sign(c.x - b.x) * r,
|
|
161
|
+
y: b.y + Math.sign(c.y - b.y) * r
|
|
162
|
+
};
|
|
163
|
+
d += ` L ${before.x} ${before.y} Q ${b.x} ${b.y} ${after.x} ${after.y}`;
|
|
164
|
+
}
|
|
165
|
+
const last = pts[pts.length - 1];
|
|
166
|
+
return `${d} L ${last.x} ${last.y}`;
|
|
167
|
+
}
|
|
168
|
+
function middleOf(points) {
|
|
169
|
+
let best = {
|
|
170
|
+
length: -1,
|
|
171
|
+
at: points[0]
|
|
172
|
+
};
|
|
173
|
+
for(let i = 1; i < points.length; i++){
|
|
174
|
+
const length = Math.hypot(points[i].x - points[i - 1].x, points[i].y - points[i - 1].y);
|
|
175
|
+
if (length > best.length) best = {
|
|
176
|
+
length,
|
|
177
|
+
at: {
|
|
178
|
+
x: mid(points[i].x, points[i - 1].x),
|
|
179
|
+
y: mid(points[i].y, points[i - 1].y)
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return best.at;
|
|
184
|
+
}
|
|
185
|
+
export function elbowCorners(route, anchors, bend = 0) {
|
|
186
|
+
if (route !== "elbow" || !anchors) return null;
|
|
187
|
+
return elbowPoints(anchors, bend)?.points ?? null;
|
|
188
|
+
}
|
|
189
|
+
export function routeEdgePath(route, geometry, anchors, bend = 0) {
|
|
190
|
+
if (route === "straight") {
|
|
191
|
+
const [path, labelX, labelY] = getStraightPath(geometry);
|
|
192
|
+
return {
|
|
193
|
+
path,
|
|
194
|
+
labelX,
|
|
195
|
+
labelY,
|
|
196
|
+
bend: null
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (route === "curved") {
|
|
200
|
+
const [path, labelX, labelY] = getBezierPath(geometry);
|
|
201
|
+
return {
|
|
202
|
+
path,
|
|
203
|
+
labelX,
|
|
204
|
+
labelY,
|
|
205
|
+
bend: null
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
const plan = anchors ? elbowPoints(anchors, bend) : null;
|
|
209
|
+
if (plan) {
|
|
210
|
+
const label = plan.handle ?? middleOf(plan.points);
|
|
211
|
+
return {
|
|
212
|
+
path: roundedPath(plan.points),
|
|
213
|
+
labelX: label.x,
|
|
214
|
+
labelY: label.y,
|
|
215
|
+
bend: plan.handle
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const [path, labelX, labelY] = getSmoothStepPath({
|
|
219
|
+
...geometry,
|
|
220
|
+
borderRadius: CORNER
|
|
221
|
+
});
|
|
222
|
+
return {
|
|
223
|
+
path,
|
|
224
|
+
labelX,
|
|
225
|
+
labelY,
|
|
226
|
+
bend: null
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
export function planLink(input) {
|
|
230
|
+
const from = parseBox(input.fromBox);
|
|
231
|
+
const to = parseBox(input.toBox);
|
|
232
|
+
let anchors = null;
|
|
233
|
+
let geometry = input.fallback;
|
|
234
|
+
if (from && to) {
|
|
235
|
+
anchors = bestAnchors(from, to, {
|
|
236
|
+
source: sideFromHandle(input.sourceHandle),
|
|
237
|
+
target: sideFromHandle(input.targetHandle)
|
|
238
|
+
});
|
|
239
|
+
geometry = {
|
|
240
|
+
sourceX: anchors.source.x,
|
|
241
|
+
sourceY: anchors.source.y,
|
|
242
|
+
sourcePosition: anchors.source.side,
|
|
243
|
+
targetX: anchors.target.x,
|
|
244
|
+
targetY: anchors.target.y,
|
|
245
|
+
targetPosition: anchors.target.side
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
...routeEdgePath(input.route, geometry, anchors, input.bend),
|
|
250
|
+
anchors,
|
|
251
|
+
geometry,
|
|
252
|
+
tips: arrowTips(input.route, geometry, anchors)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function into(side) {
|
|
256
|
+
switch(side){
|
|
257
|
+
case "left":
|
|
258
|
+
return 0;
|
|
259
|
+
case "right":
|
|
260
|
+
return Math.PI;
|
|
261
|
+
case "top":
|
|
262
|
+
return Math.PI / 2;
|
|
263
|
+
case "bottom":
|
|
264
|
+
return -Math.PI / 2;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
export function arrowTips(route, geometry, anchors) {
|
|
268
|
+
const { sourceX, sourceY, targetX, targetY } = geometry;
|
|
269
|
+
const straight = Math.atan2(targetY - sourceY, targetX - sourceX);
|
|
270
|
+
const startAngle = route === "straight" || !anchors ? straight + Math.PI : into(anchors.source.side);
|
|
271
|
+
const endAngle = route === "straight" || !anchors ? straight : into(anchors.target.side);
|
|
272
|
+
return {
|
|
273
|
+
start: {
|
|
274
|
+
x: sourceX,
|
|
275
|
+
y: sourceY,
|
|
276
|
+
angle: startAngle
|
|
277
|
+
},
|
|
278
|
+
end: {
|
|
279
|
+
x: targetX,
|
|
280
|
+
y: targetY,
|
|
281
|
+
angle: endAngle
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function rectOf(el) {
|
|
2
|
+
if (!el) return null;
|
|
3
|
+
const r = el.getBoundingClientRect();
|
|
4
|
+
return {
|
|
5
|
+
x: r.x,
|
|
6
|
+
y: r.y,
|
|
7
|
+
width: r.width,
|
|
8
|
+
height: r.height
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function tableCellOf(target) {
|
|
12
|
+
const cell = target.closest("[data-table-row]");
|
|
13
|
+
if (!cell) return null;
|
|
14
|
+
return {
|
|
15
|
+
row: Number(cell.dataset.tableRow),
|
|
16
|
+
col: Number(cell.dataset.tableCol)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function resolveContextMenuHit(event, nodes) {
|
|
20
|
+
const target = event.target;
|
|
21
|
+
const position = {
|
|
22
|
+
x: event.clientX,
|
|
23
|
+
y: event.clientY
|
|
24
|
+
};
|
|
25
|
+
const edgeId = target.closest(".svelte-flow__edge")?.getAttribute("data-id");
|
|
26
|
+
if (edgeId) return {
|
|
27
|
+
kind: "edge",
|
|
28
|
+
edgeId,
|
|
29
|
+
position
|
|
30
|
+
};
|
|
31
|
+
const nodeElement = target.closest("[data-id]");
|
|
32
|
+
const nodeId = nodeElement?.getAttribute("data-id") ?? null;
|
|
33
|
+
const node = nodeId ? nodes.find((n)=>n.id === nodeId) : undefined;
|
|
34
|
+
return {
|
|
35
|
+
kind: "canvas",
|
|
36
|
+
position,
|
|
37
|
+
anchorRect: rectOf(nodeElement),
|
|
38
|
+
nodeId,
|
|
39
|
+
nodeType: node?.type ?? null,
|
|
40
|
+
tableCell: tableCellOf(target)
|
|
41
|
+
};
|
|
42
|
+
}
|