@heyramzi/ui 1.54.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/COMPONENTS.md +3 -2
- package/README.md +34 -9
- package/package.json +200 -7
- package/scripts/sync-shadcn.mjs +2 -2
- package/src/ai/ai-button/AiButton.svelte +1 -1
- package/src/ai/confirmation/Confirmation.svelte +1 -1
- package/src/ai/confirmation/ConfirmationAction.svelte +1 -1
- package/src/ai/confirmation/ConfirmationActions.svelte +1 -1
- package/src/ai/confirmation/ConfirmationTitle.svelte +1 -1
- package/src/ai/generation-progress/GenerationProgress.svelte +13 -13
- package/src/ai/loading-state/PixelLoader.svelte +1 -1
- package/src/ai/prompt-input/PromptInput.svelte +1 -1
- package/src/ai/prompt-input/PromptInputBody.svelte +1 -1
- package/src/ai/prompt-input/PromptInputSubmit.svelte +1 -1
- package/src/ai/prompt-input/PromptInputTextarea.svelte +1 -1
- package/src/ai/prompt-input/PromptInputToolbar.svelte +1 -1
- package/src/ai/reasoning/Reasoning.svelte +1 -1
- package/src/ai/reasoning/ReasoningContent.svelte +1 -1
- package/src/ai/reasoning/ReasoningTrigger.svelte +1 -1
- package/src/ai/response/Response.svelte +1 -1
- package/src/ai/suggestion/Suggestion.svelte +1 -1
- package/src/ai/suggestion/Suggestions.svelte +1 -1
- package/src/ai/thinking-dots/ThinkingDots.svelte +1 -1
- package/src/ai/typing-dots/TypingDots.svelte +1 -1
- package/src/ai/voice-waveform/VoiceWaveform.svelte +1 -1
- package/src/ambient.d.ts +8 -0
- package/src/brand/brand.test.ts +67 -0
- package/src/brand/index.ts +137 -0
- package/src/canvas/README.md +236 -0
- package/src/canvas/card/card-frame.svelte +61 -0
- package/src/canvas/card/card.css +39 -0
- package/src/canvas/card/resize-handles.svelte +119 -0
- package/src/canvas/card/resize.ts +33 -0
- package/src/canvas/chrome/chrome-zoom.svelte +120 -0
- package/src/canvas/chrome/chrome.css +231 -0
- package/src/canvas/chrome/lock-badge.svelte +18 -0
- package/src/canvas/chrome/side-handles.svelte +30 -0
- package/src/canvas/chrome/size-chip.svelte +45 -0
- package/src/canvas/chrome/snap-guides.svelte +69 -0
- package/src/canvas/components/icons/ToolIcon.svelte +30 -0
- package/src/canvas/components/shared/svg/PreviewSvg.svelte +67 -0
- package/src/canvas/components/shared/svg/ShapeOutline.svelte +76 -0
- package/src/canvas/components/shared/svg/StrokeNode.svelte +69 -0
- package/src/canvas/components/shared/svg/TextRule.svelte +37 -0
- package/src/canvas/edges/bend-handle.svelte +76 -0
- package/src/canvas/edges/edge-gradient.svelte +30 -0
- package/src/canvas/edges/edge-path.test.ts +58 -0
- package/src/canvas/edges/edge-path.ts +293 -0
- package/src/canvas/edges/gradient-edge.svelte +43 -0
- package/src/canvas/editor/context-menu.test.ts +65 -0
- package/src/canvas/editor/context-menu.ts +48 -0
- package/src/canvas/editor/dispatch.svelte.test.ts +243 -0
- package/src/canvas/editor/dispatch.svelte.ts +205 -0
- package/src/canvas/editor/editor-context.ts +62 -0
- package/src/canvas/editor/editor-mode.ts +67 -0
- package/src/canvas/editor/frame.ts +98 -0
- package/src/canvas/editor/hand-context.ts +15 -0
- package/src/canvas/editor/history-core.test.ts +239 -0
- package/src/canvas/editor/history-core.ts +247 -0
- package/src/canvas/editor/keymap.test.ts +161 -0
- package/src/canvas/editor/keymap.ts +151 -0
- package/src/canvas/editor/layout-actions.test.ts +156 -0
- package/src/canvas/editor/layout-actions.ts +219 -0
- package/src/canvas/editor/lock.test.ts +68 -0
- package/src/canvas/editor/lock.ts +87 -0
- package/src/canvas/editor/rebase.test.ts +208 -0
- package/src/canvas/editor/rebase.ts +272 -0
- package/src/canvas/editor/style.ts +184 -0
- package/src/canvas/editor/text-field-context.ts +41 -0
- package/src/canvas/editor/z-order.test.ts +75 -0
- package/src/canvas/editor/z-order.ts +87 -0
- package/src/canvas/headless/alignment.test.ts +59 -0
- package/src/canvas/headless/alignment.ts +23 -0
- package/src/canvas/headless/break-apart-find.ts +418 -0
- package/src/canvas/headless/break-apart-pieces.ts +104 -0
- package/src/canvas/headless/break-apart-plan.ts +439 -0
- package/src/canvas/headless/break-apart-style.ts +106 -0
- package/src/canvas/headless/break-apart.ts +244 -0
- package/src/canvas/headless/canvas-cleanup.test.ts +181 -0
- package/src/canvas/headless/canvas-cleanup.ts +102 -0
- package/src/canvas/headless/edge-anchors.test.ts +70 -0
- package/src/canvas/headless/edge-anchors.ts +143 -0
- package/src/canvas/headless/edge-memo.test.ts +58 -0
- package/src/canvas/headless/edge-memo.ts +32 -0
- package/src/canvas/headless/edge-serialization.test.ts +55 -0
- package/src/canvas/headless/edge-serialization.ts +32 -0
- package/src/canvas/headless/figure-geometry.ts +293 -0
- package/src/canvas/headless/fit-viewport.test.ts +85 -0
- package/src/canvas/headless/fit-viewport.ts +137 -0
- package/src/canvas/headless/grid.test.ts +34 -0
- package/src/canvas/headless/grid.ts +94 -0
- package/src/canvas/headless/icon-node.test.ts +23 -0
- package/src/canvas/headless/icon-node.ts +66 -0
- package/src/canvas/headless/index.ts +9 -0
- package/src/canvas/headless/linkify.test.ts +23 -0
- package/src/canvas/headless/linkify.ts +25 -0
- package/src/canvas/headless/pen-marks.ts +133 -0
- package/src/canvas/headless/sketch.test.ts +99 -0
- package/src/canvas/headless/sketch.ts +302 -0
- package/src/canvas/headless/snap-guides.test.ts +61 -0
- package/src/canvas/headless/snap-guides.ts +146 -0
- package/src/canvas/headless/svg-figure.test.ts +49 -0
- package/src/canvas/headless/svg-figure.ts +176 -0
- package/src/canvas/headless/table-layout.test.ts +158 -0
- package/src/canvas/headless/table-layout.ts +309 -0
- package/src/canvas/index.ts +35 -0
- package/src/canvas/lod/lod-mode.svelte.ts +30 -0
- package/src/canvas/lod/lod-switch.svelte +140 -0
- package/src/canvas/lod/render-all.svelte.ts +52 -0
- package/src/canvas/ops/arrange.ts +108 -0
- package/src/canvas/ops/ops.test.ts +98 -0
- package/src/canvas/ops/ops.ts +347 -0
- package/src/canvas/pen/PenField.svelte +128 -0
- package/src/canvas/pen/PenField.test.ts +87 -0
- package/src/canvas/pen/PenOverlay.svelte +172 -0
- package/src/canvas/pen/ShapeNode.svelte +64 -0
- package/src/canvas/pen/TextNode.svelte +97 -0
- package/src/canvas/pen/colors.ts +28 -0
- package/src/canvas/pen/eraser.ts +46 -0
- package/src/canvas/pen/geometry.ts +148 -0
- package/src/canvas/pen/host-field.test.svelte +13 -0
- package/src/canvas/pen/index.ts +40 -0
- package/src/canvas/pen/ops.ts +16 -0
- package/src/canvas/pen/pen-session.ts +177 -0
- package/src/canvas/pen/pen.css +149 -0
- package/src/canvas/pen/plugin.ts +139 -0
- package/src/canvas/pen/shapes.ts +104 -0
- package/src/canvas/pen/stroke-path.ts +54 -0
- package/src/canvas/pen/types.ts +96 -0
- package/src/canvas/pen/ui.ts +26 -0
- package/src/canvas/plugin.test.ts +45 -0
- package/src/canvas/plugin.ts +159 -0
- package/src/canvas/screen/GlyphIcon.svelte +25 -0
- package/src/canvas/screen/PartView.svelte +176 -0
- package/src/canvas/screen/ScreenBody.svelte +142 -0
- package/src/canvas/screen/ScreenCard.svelte +32 -0
- package/src/canvas/screen/glyphs/button.svg +1 -0
- package/src/canvas/screen/glyphs/close.svg +1 -0
- package/src/canvas/screen/glyphs/down.svg +1 -0
- package/src/canvas/screen/glyphs/header.svg +1 -0
- package/src/canvas/screen/glyphs/hills.svg +1 -0
- package/src/canvas/screen/glyphs/image.svg +1 -0
- package/src/canvas/screen/glyphs/input.svg +1 -0
- package/src/canvas/screen/glyphs/list.svg +1 -0
- package/src/canvas/screen/glyphs/modal.svg +1 -0
- package/src/canvas/screen/glyphs/plus.svg +1 -0
- package/src/canvas/screen/glyphs/up.svg +1 -0
- package/src/canvas/screen/glyphs.ts +40 -0
- package/src/canvas/screen/labels.ts +41 -0
- package/src/canvas/screen/parts.ts +164 -0
- package/src/canvas/screen/plugin.ts +67 -0
- package/src/canvas/screen/screen.css +593 -0
- package/src/canvas/screen/types.ts +47 -0
- package/src/canvas/screen/ui.ts +13 -0
- package/src/canvas/test-utils.ts +18 -0
- package/src/canvas/types.ts +53 -0
- package/src/canvas/ui/CanvasToolbar.svelte +169 -0
- package/src/canvas/ui/FrameLayer.svelte +116 -0
- package/src/canvas/ui/PenLayer.svelte +39 -0
- package/src/canvas/ui/StylePanel.svelte +268 -0
- package/src/canvas/ui/canvas-grid.svelte +156 -0
- package/src/canvas/ui/canvas-ui.css +350 -0
- package/src/canvas/ui/forward-wheel.ts +29 -0
- package/src/canvas/ui/icons.ts +124 -0
- package/src/canvas/ui/place-panel.ts +80 -0
- package/src/canvas/ui/shortcut-tip.test.ts +16 -0
- package/src/canvas/ui/shortcut-tip.ts +17 -0
- package/src/canvas/ui/tools.ts +146 -0
- package/src/charts/README.md +104 -0
- package/src/charts/ambient.d.ts +4 -0
- package/src/charts/animated-value.css +7 -0
- package/src/charts/animated-value.svelte +110 -0
- package/src/charts/area-chart.css +29 -0
- package/src/charts/area-chart.svelte +204 -0
- package/src/charts/bar-chart.css +119 -0
- package/src/charts/bar-chart.svelte +275 -0
- package/src/charts/charts.css +201 -0
- package/src/charts/crosshair.svelte +35 -0
- package/src/charts/dashboard/chart.ts +5 -0
- package/src/charts/dashboard/dashboard-empty.svelte +55 -0
- package/src/charts/dashboard/dashboard-section.svelte +58 -0
- package/src/charts/dashboard/data-panel.svelte +81 -0
- package/src/charts/dashboard/data-sort-head.svelte +102 -0
- package/src/charts/dashboard/data-table.svelte +278 -0
- package/src/charts/dashboard/data-table.ts +26 -0
- package/src/charts/dashboard/index.ts +25 -0
- package/src/charts/dashboard/panel-grid.svelte +43 -0
- package/src/charts/dashboard/period-filter.svelte +53 -0
- package/src/charts/dashboard/rating-chip.svelte +35 -0
- package/src/charts/dashboard/stat-band.svelte +47 -0
- package/src/charts/dashboard/stat-tile.svelte +176 -0
- package/src/charts/dashboard/windows.ts +8 -0
- package/src/charts/donut-chart.css +56 -0
- package/src/charts/donut-chart.svelte +158 -0
- package/src/charts/edge-fade.svelte +43 -0
- package/src/charts/edge-fade.ts +16 -0
- package/src/charts/figure.css +100 -0
- package/src/charts/figure.svelte +122 -0
- package/src/charts/gauge-chart.css +94 -0
- package/src/charts/gauge-chart.svelte +302 -0
- package/src/charts/hover-band.test.ts +30 -0
- package/src/charts/hover-band.ts +21 -0
- package/src/charts/hover-focus.svelte +85 -0
- package/src/charts/index.ts +31 -0
- package/src/charts/legend.css +136 -0
- package/src/charts/legend.svelte +112 -0
- package/src/charts/line-chart.css +26 -0
- package/src/charts/line-chart.svelte +256 -0
- package/src/charts/motion.ts +19 -0
- package/src/charts/number-chart.css +179 -0
- package/src/charts/number-chart.svelte +187 -0
- package/src/charts/primitives/chart-container.svelte +57 -0
- package/src/charts/primitives/chart-style.svelte +36 -0
- package/src/charts/primitives/chart-tooltip.svelte +161 -0
- package/src/charts/primitives/chart-utils.ts +54 -0
- package/src/charts/primitives/index.ts +11 -0
- package/src/charts/reference-line.css +18 -0
- package/src/charts/reference-line.svelte +31 -0
- package/src/charts/reveal.svelte +61 -0
- package/src/charts/ring-chart.css +104 -0
- package/src/charts/ring-chart.svelte +166 -0
- package/src/charts/sparkline.css +45 -0
- package/src/charts/sparkline.svelte +141 -0
- package/src/charts/stat-card.css +105 -0
- package/src/charts/stat-card.svelte +267 -0
- package/src/charts/time-series-chart.css +28 -0
- package/src/charts/time-series-chart.svelte +179 -0
- package/src/charts/trend-pill.css +38 -0
- package/src/charts/trend-pill.svelte +48 -0
- package/src/components/copy/clipboard.ts +13 -9
- package/src/components/copy/copy-button.svelte +2 -2
- package/src/components/data-table/row-arrow.svelte +1 -1
- package/src/components/data-table/sortable-head.svelte +1 -1
- package/src/components/docs/doc-page.svelte +1 -1
- package/src/components/docs/on-this-page.svelte +2 -2
- package/src/components/field-row/field-row.svelte +1 -1
- package/src/components/hold-to-confirm/hold-to-confirm.svelte +1 -1
- package/src/components/language-flag/language-flag.svelte +1 -1
- package/src/components/list-page/detail-empty.svelte +1 -1
- package/src/components/list-page/detail-header.svelte +1 -1
- package/src/components/list-page/detail-panel.svelte +1 -1
- package/src/components/list-page/detail-row.svelte +1 -1
- package/src/components/list-page/detail-stack.svelte +1 -1
- package/src/components/list-page/empty-state.svelte +1 -1
- package/src/components/list-page/filter-item.svelte +1 -1
- package/src/components/list-page/filter-popover.svelte +2 -2
- package/src/components/list-page/filter-section.ts +1 -1
- package/src/components/list-page/grouped-list.svelte +1 -1
- package/src/components/list-page/list-page-shell.svelte +1 -1
- package/src/components/list-page/list-table.ts +1 -1
- package/src/components/list-page/master-detail.svelte +1 -1
- package/src/components/list-page/notice-bar.svelte +1 -1
- package/src/components/list-page/prev-next.svelte +1 -1
- package/src/components/list-page/rail-body.svelte +1 -1
- package/src/components/list-page/rail-empty.svelte +1 -1
- package/src/components/list-page/rail-head.svelte +1 -1
- package/src/components/list-page/rail-row.svelte +1 -1
- package/src/components/list-page/section-label.svelte +2 -2
- package/src/components/list-page/toolbar-search.svelte +1 -1
- package/src/components/list-page/toolbar-trigger.ts +1 -1
- package/src/components/mark/mark.svelte +1 -1
- package/src/components/open-in/open-in.svelte +1 -1
- package/src/components/picker/mark-picker.svelte +1 -1
- package/src/components/picker/picker.svelte +1 -1
- package/src/components/section-card/section-card.svelte +1 -1
- package/src/components/segmented/animated-tabs.svelte +1 -1
- package/src/components/segmented/section-runs.svelte +1 -1
- package/src/components/segmented/segment.svelte +5 -5
- package/src/components/segmented/segmented-filter.svelte +1 -1
- package/src/components/segmented/segmented-nav.svelte +1 -1
- package/src/components/segmented/segmented-overflow.svelte +1 -1
- package/src/components/segmented/segmented-track.svelte +1 -1
- package/src/components/star-rating-input/star-rating-input.svelte +1 -1
- package/src/components/table-view/table-view.svelte +1 -1
- package/src/components/theme/theme-provider.svelte +6 -4
- package/src/components/toolbar/index.ts +5 -0
- package/src/components/toolbar/toolbar.svelte +168 -0
- package/src/components/toolbar/toolbar.test.ts +66 -0
- package/src/editor/README.md +58 -0
- package/src/editor/ambient.d.ts +1 -0
- package/src/editor/block-id.ts +77 -0
- package/src/editor/block-ops.test.ts +237 -0
- package/src/editor/block-ops.ts +157 -0
- package/src/editor/content.css +418 -0
- package/src/editor/editor-toolbar.svelte +303 -0
- package/src/editor/editor.svelte +462 -0
- package/src/editor/extensions.ts +145 -0
- package/src/editor/image-toolbar.svelte +123 -0
- package/src/editor/index.ts +17 -0
- package/src/editor/inline-editor.svelte +261 -0
- package/src/editor/markdown-escaping.test.ts +158 -0
- package/src/editor/markdown-marks.test.ts +89 -0
- package/src/editor/markdown-test-helpers.ts +13 -0
- package/src/editor/markdown-youtube.test.ts +93 -0
- package/src/editor/markdown.test.ts +250 -0
- package/src/editor/markdown.ts +511 -0
- package/src/editor/renderer.svelte +92 -0
- package/src/editor/serializer.test.ts +133 -0
- package/src/editor/serializer.ts +370 -0
- package/src/editor/slash-items.ts +115 -0
- package/src/editor/slash-menu.svelte +159 -0
- package/src/editor/youtube-url.ts +35 -0
- package/src/effects/animated-beam/AnimatedBeam.svelte +1 -1
- package/src/effects/border-beam/register-properties.ts +4 -2
- package/src/effects/image-comparison/ImageComparison.svelte +1 -1
- package/src/effects/image-reveal/ImageReveal.svelte +1 -1
- package/src/effects/interactive-hover-button/InteractiveHoverButton.svelte +13 -13
- package/src/effects/magic-card/MagicCard.svelte +1 -1
- package/src/effects/marquee/Marquee.svelte +1 -1
- package/src/effects/progressive-blur/ProgressiveBlur.svelte +1 -1
- package/src/effects/reveal/AnimatedGroup.svelte +1 -1
- package/src/effects/reveal/InView.svelte +1 -1
- package/src/effects/reveal/TextEffect.svelte +1 -1
- package/src/effects/shader-gradient/ShaderGradient.svelte +1 -1
- package/src/effects/spotlight/Spotlight.svelte +1 -1
- package/src/effects/theme-toggle/ThemeToggle.svelte +4 -4
- package/src/lib/result.ts +19 -0
- package/src/lib/utils.ts +18 -0
- package/src/onboarding/README.md +120 -0
- package/src/onboarding/define-tours.test.ts +50 -0
- package/src/onboarding/define-tours.ts +31 -0
- package/src/onboarding/demo.svelte +86 -0
- package/src/onboarding/index.ts +12 -0
- package/src/onboarding/onboarding-provider.svelte +120 -0
- package/src/onboarding/onboarding.svelte.ts +24 -0
- package/src/onboarding/pick.test.ts +79 -0
- package/src/onboarding/pick.ts +36 -0
- package/src/onboarding/stores.test.ts +103 -0
- package/src/onboarding/stores.ts +58 -0
- package/src/onboarding/tour-card.svelte +70 -0
- package/src/onboarding/tour-runner.svelte +197 -0
- package/src/onboarding/types.ts +34 -0
- package/src/onboarding/wait.ts +29 -0
- package/src/shadcn/accordion/accordion-content.svelte +1 -1
- package/src/shadcn/accordion/accordion-item.svelte +1 -1
- package/src/shadcn/accordion/accordion-trigger.svelte +1 -1
- package/src/shadcn/accordion/accordion.svelte +1 -1
- package/src/shadcn/alert/alert-description.svelte +1 -1
- package/src/shadcn/alert/alert-title.svelte +1 -1
- package/src/shadcn/alert/alert.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-action.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-cancel.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-content.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-description.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-footer.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-header.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-overlay.svelte +1 -1
- package/src/shadcn/alert-dialog/alert-dialog-title.svelte +1 -1
- package/src/shadcn/attachment/attachment-action.svelte +1 -1
- package/src/shadcn/attachment/attachment-actions.svelte +1 -1
- package/src/shadcn/attachment/attachment-content.svelte +1 -1
- package/src/shadcn/attachment/attachment-description.svelte +1 -1
- package/src/shadcn/attachment/attachment-group.svelte +1 -1
- package/src/shadcn/attachment/attachment-media.svelte +1 -1
- package/src/shadcn/attachment/attachment-title.svelte +1 -1
- package/src/shadcn/attachment/attachment-trigger.svelte +1 -1
- package/src/shadcn/attachment/attachment.svelte +1 -1
- package/src/shadcn/avatar/avatar-badge.svelte +1 -1
- package/src/shadcn/avatar/avatar-fallback.svelte +1 -1
- package/src/shadcn/avatar/avatar-group-count.svelte +1 -1
- package/src/shadcn/avatar/avatar-group.svelte +1 -1
- package/src/shadcn/avatar/avatar-image.svelte +1 -1
- package/src/shadcn/avatar/avatar.svelte +1 -1
- package/src/shadcn/badge/badge.svelte +1 -1
- package/src/shadcn/breadcrumb/breadcrumb-ellipsis.svelte +1 -1
- package/src/shadcn/breadcrumb/breadcrumb-item.svelte +1 -1
- package/src/shadcn/breadcrumb/breadcrumb-link.svelte +1 -1
- package/src/shadcn/breadcrumb/breadcrumb-list.svelte +1 -1
- package/src/shadcn/breadcrumb/breadcrumb-page.svelte +1 -1
- package/src/shadcn/breadcrumb/breadcrumb-separator.svelte +1 -1
- package/src/shadcn/breadcrumb/breadcrumb.svelte +1 -1
- package/src/shadcn/bubble/bubble-content.svelte +1 -1
- package/src/shadcn/bubble/bubble-group.svelte +1 -1
- package/src/shadcn/bubble/bubble-reactions.svelte +1 -1
- package/src/shadcn/bubble/bubble.svelte +1 -1
- package/src/shadcn/button/button.svelte +1 -1
- package/src/shadcn/calendar/calendar-cell.svelte +1 -1
- package/src/shadcn/calendar/calendar-day.svelte +1 -1
- package/src/shadcn/calendar/calendar-grid-body.svelte +1 -1
- package/src/shadcn/calendar/calendar-grid-head.svelte +1 -1
- package/src/shadcn/calendar/calendar-grid-row.svelte +1 -1
- package/src/shadcn/calendar/calendar-grid.svelte +1 -1
- package/src/shadcn/calendar/calendar-head-cell.svelte +1 -1
- package/src/shadcn/calendar/calendar-header.svelte +1 -1
- package/src/shadcn/calendar/calendar-heading.svelte +1 -1
- package/src/shadcn/calendar/calendar-month-select.svelte +1 -1
- package/src/shadcn/calendar/calendar-month.svelte +1 -1
- package/src/shadcn/calendar/calendar-months.svelte +1 -1
- package/src/shadcn/calendar/calendar-nav.svelte +1 -1
- package/src/shadcn/calendar/calendar-next-button.svelte +1 -1
- package/src/shadcn/calendar/calendar-prev-button.svelte +1 -1
- package/src/shadcn/calendar/calendar-year-select.svelte +1 -1
- package/src/shadcn/calendar/calendar.svelte +1 -1
- package/src/shadcn/card/card-action.svelte +1 -1
- package/src/shadcn/card/card-content.svelte +1 -1
- package/src/shadcn/card/card-description.svelte +1 -1
- package/src/shadcn/card/card-footer.svelte +1 -1
- package/src/shadcn/card/card-header.svelte +1 -1
- package/src/shadcn/card/card-title.svelte +1 -1
- package/src/shadcn/card/card.svelte +1 -1
- package/src/shadcn/checkbox/checkbox.svelte +1 -1
- package/src/shadcn/code-block/code-block-actions.svelte +1 -1
- package/src/shadcn/code-block/code-block-content.svelte +1 -1
- package/src/shadcn/code-block/code-block-footer.svelte +1 -1
- package/src/shadcn/code-block/code-block-header.svelte +1 -1
- package/src/shadcn/code-block/code-block-line.svelte +1 -1
- package/src/shadcn/code-block/code-block-title.svelte +1 -1
- package/src/shadcn/code-block/code-block.svelte +1 -1
- package/src/shadcn/command/command-dialog.svelte +1 -1
- package/src/shadcn/command/command-empty.svelte +1 -1
- package/src/shadcn/command/command-group.svelte +1 -1
- package/src/shadcn/command/command-input.svelte +2 -2
- package/src/shadcn/command/command-item.svelte +1 -1
- package/src/shadcn/command/command-link-item.svelte +1 -1
- package/src/shadcn/command/command-list.svelte +1 -1
- package/src/shadcn/command/command-separator.svelte +1 -1
- package/src/shadcn/command/command-shortcut.svelte +1 -1
- package/src/shadcn/command/command.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-checkbox-item.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-content.svelte +2 -2
- package/src/shadcn/context-menu/context-menu-group-heading.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-item.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-label.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-radio-item.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-separator.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-shortcut.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-sub-content.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-sub-trigger.svelte +1 -1
- package/src/shadcn/context-menu/context-menu-trigger.svelte +1 -1
- package/src/shadcn/dialog/dialog-content.svelte +1 -1
- package/src/shadcn/dialog/dialog-description.svelte +1 -1
- package/src/shadcn/dialog/dialog-footer.svelte +1 -1
- package/src/shadcn/dialog/dialog-header.svelte +1 -1
- package/src/shadcn/dialog/dialog-overlay.svelte +1 -1
- package/src/shadcn/dialog/dialog-title.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-checkbox-item.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-content.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-group-heading.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-item.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-label.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-radio-item.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-separator.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-shortcut.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-sub-content.svelte +1 -1
- package/src/shadcn/dropdown-menu/dropdown-menu-sub-trigger.svelte +1 -1
- package/src/shadcn/empty/empty-content.svelte +1 -1
- package/src/shadcn/empty/empty-description.svelte +1 -1
- package/src/shadcn/empty/empty-header.svelte +1 -1
- package/src/shadcn/empty/empty-media.svelte +1 -1
- package/src/shadcn/empty/empty-title.svelte +1 -1
- package/src/shadcn/empty/empty.svelte +1 -1
- package/src/shadcn/field/field-content.svelte +1 -1
- package/src/shadcn/field/field-description.svelte +1 -1
- package/src/shadcn/field/field-error.svelte +1 -1
- package/src/shadcn/field/field-group.svelte +1 -1
- package/src/shadcn/field/field-label.svelte +1 -1
- package/src/shadcn/field/field-legend.svelte +1 -1
- package/src/shadcn/field/field-separator.svelte +1 -1
- package/src/shadcn/field/field-set.svelte +1 -1
- package/src/shadcn/field/field-title.svelte +1 -1
- package/src/shadcn/field/field.svelte +1 -1
- package/src/shadcn/field/simple-field.svelte +1 -1
- package/src/shadcn/hover-card/hover-card-content.svelte +1 -1
- package/src/shadcn/input/input.svelte +1 -1
- package/src/shadcn/input/secret-input.svelte +1 -1
- package/src/shadcn/input-otp/input-otp-group.svelte +1 -1
- package/src/shadcn/input-otp/input-otp-separator.svelte +1 -1
- package/src/shadcn/input-otp/input-otp-slot.svelte +1 -1
- package/src/shadcn/input-otp/input-otp.svelte +1 -1
- package/src/shadcn/kbd/kbd-group.svelte +1 -1
- package/src/shadcn/kbd/kbd.svelte +1 -1
- package/src/shadcn/label/label.svelte +1 -1
- package/src/shadcn/marker/marker-content.svelte +1 -1
- package/src/shadcn/marker/marker-icon.svelte +1 -1
- package/src/shadcn/marker/marker.svelte +1 -1
- package/src/shadcn/message/message-avatar.svelte +1 -1
- package/src/shadcn/message/message-content.svelte +1 -1
- package/src/shadcn/message/message-footer.svelte +1 -1
- package/src/shadcn/message/message-group.svelte +1 -1
- package/src/shadcn/message/message-header.svelte +1 -1
- package/src/shadcn/message/message.svelte +1 -1
- package/src/shadcn/message-scroller/message-scroller-button.svelte +1 -1
- package/src/shadcn/message-scroller/message-scroller-content.svelte +1 -1
- package/src/shadcn/message-scroller/message-scroller-item.svelte +1 -1
- package/src/shadcn/message-scroller/message-scroller-viewport.svelte +1 -1
- package/src/shadcn/message-scroller/message-scroller.svelte +1 -1
- package/src/shadcn/popover/popover-content.svelte +1 -1
- package/src/shadcn/popover/popover-description.svelte +1 -1
- package/src/shadcn/popover/popover-header.svelte +1 -1
- package/src/shadcn/popover/popover-title.svelte +1 -1
- package/src/shadcn/popover/popover-trigger.svelte +1 -1
- package/src/shadcn/progress/progress.svelte +1 -1
- package/src/shadcn/radio-group/radio-group-item.svelte +1 -1
- package/src/shadcn/radio-group/radio-group.svelte +1 -1
- package/src/shadcn/scroll-area/scroll-area-scrollbar.svelte +1 -1
- package/src/shadcn/scroll-area/scroll-area.svelte +1 -1
- package/src/shadcn/select/select-content.svelte +2 -2
- package/src/shadcn/select/select-group-heading.svelte +1 -1
- package/src/shadcn/select/select-group.svelte +1 -1
- package/src/shadcn/select/select-item.svelte +1 -1
- package/src/shadcn/select/select-label.svelte +1 -1
- package/src/shadcn/select/select-scroll-down-button.svelte +1 -1
- package/src/shadcn/select/select-scroll-up-button.svelte +1 -1
- package/src/shadcn/select/select-separator.svelte +1 -1
- package/src/shadcn/select/select-trigger.svelte +1 -1
- package/src/shadcn/separator/separator.svelte +1 -1
- package/src/shadcn/sheet/sheet-content.svelte +1 -1
- package/src/shadcn/sheet/sheet-description.svelte +1 -1
- package/src/shadcn/sheet/sheet-footer.svelte +1 -1
- package/src/shadcn/sheet/sheet-header.svelte +1 -1
- package/src/shadcn/sheet/sheet-overlay.svelte +1 -1
- package/src/shadcn/sheet/sheet-title.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-content.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-footer.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-group-action.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-group-content.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-group-label.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-group.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-header.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-input.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-inset.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-action.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-badge.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-button.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-item.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-skeleton.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-sub-button.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-sub-item.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu-sub.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-menu.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-provider.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-rail.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-separator.svelte +1 -1
- package/src/shadcn/sidebar/sidebar-trigger.svelte +1 -1
- package/src/shadcn/sidebar/sidebar.svelte +1 -1
- package/src/shadcn/skeleton/skeleton.svelte +1 -1
- package/src/shadcn/slider/slider.svelte +1 -1
- package/src/shadcn/spinner/spinner.svelte +1 -1
- package/src/shadcn/switch/switch.svelte +1 -1
- package/src/shadcn/table/table-body.svelte +1 -1
- package/src/shadcn/table/table-caption.svelte +1 -1
- package/src/shadcn/table/table-cell.svelte +1 -1
- package/src/shadcn/table/table-footer.svelte +1 -1
- package/src/shadcn/table/table-head.svelte +1 -1
- package/src/shadcn/table/table-header.svelte +1 -1
- package/src/shadcn/table/table-row.svelte +1 -1
- package/src/shadcn/table/table.svelte +1 -1
- package/src/shadcn/tabs/tabs-content.svelte +1 -1
- package/src/shadcn/tabs/tabs-list.svelte +1 -1
- package/src/shadcn/tabs/tabs-trigger.svelte +1 -1
- package/src/shadcn/tabs/tabs.svelte +1 -1
- package/src/shadcn/textarea/textarea.svelte +1 -1
- package/src/shadcn/toggle/toggle.svelte +1 -1
- package/src/shadcn/toggle-group/toggle-group-item.svelte +1 -1
- package/src/shadcn/toggle-group/toggle-group.svelte +1 -1
- package/src/shadcn/tooltip/tooltip-content.svelte +2 -2
- package/src/shadcn/trace/trace-collapsible-content.svelte +1 -1
- package/src/shadcn/trace/trace-collapsible-trigger.svelte +1 -1
- package/src/shadcn/trace/trace-collapsible.svelte +1 -1
- package/src/shadcn/trace/trace-description.svelte +1 -1
- package/src/shadcn/trace/trace-icon.svelte +1 -1
- package/src/shadcn/trace/trace-line.svelte +1 -1
- package/src/shadcn/trace/trace-title.svelte +1 -1
- package/src/shadcn/trace/trace.svelte +1 -1
- package/src/slides/Controls.svelte +138 -0
- package/src/slides/Deck.svelte +271 -0
- package/src/slides/Fragment.svelte +71 -0
- package/src/slides/Overview.svelte +113 -0
- package/src/slides/Presenter.svelte +292 -0
- package/src/slides/README.md +89 -0
- package/src/slides/Slide.svelte +179 -0
- package/src/slides/SlideList.svelte +19 -0
- package/src/slides/ambient.d.ts +1 -0
- package/src/slides/bridges.ts +69 -0
- package/src/slides/deck-controller.svelte.ts +292 -0
- package/src/slides/demo-slides.svelte +358 -0
- package/src/slides/demo.svelte +176 -0
- package/src/slides/export/capture.ts +113 -0
- package/src/slides/export/ffmpeg.ts +120 -0
- package/src/slides/export/index.ts +9 -0
- package/src/slides/export/launch.ts +10 -0
- package/src/slides/export/pdf.ts +152 -0
- package/src/slides/export/types.ts +48 -0
- package/src/slides/index.ts +19 -0
- package/src/slides/labels.ts +48 -0
- package/src/slides/layout.ts +51 -0
- package/src/slides/model.ts +47 -0
- package/src/slides/navigation.ts +100 -0
- package/src/slides/theme.css +205 -0
- package/src/slides/types.ts +86 -0
- package/src/tasks/README.md +312 -0
- package/src/tasks/ambient.d.ts +3 -0
- package/src/tasks/board-order.ts +137 -0
- package/src/tasks/dates.ts +31 -0
- package/src/tasks/define-statuses.ts +32 -0
- package/src/tasks/demo.svelte +389 -0
- package/src/tasks/detail/detail-demo.svelte +186 -0
- package/src/tasks/detail/detail-types.ts +54 -0
- package/src/tasks/detail/task-chip.svelte +28 -0
- package/src/tasks/detail/task-detail.svelte +315 -0
- package/src/tasks/detail/task-property.svelte +17 -0
- package/src/tasks/detail/task-thread.svelte +258 -0
- package/src/tasks/gantt/gantt-bar.svelte +243 -0
- package/src/tasks/gantt/gantt-grid.svelte +94 -0
- package/src/tasks/gantt/gantt-group-row.svelte +55 -0
- package/src/tasks/gantt/gantt-header.svelte +71 -0
- package/src/tasks/gantt/gantt-task-row.svelte +186 -0
- package/src/tasks/gantt/gantt.css +22 -0
- package/src/tasks/gantt/gantt.test.ts +77 -0
- package/src/tasks/gantt/logic.test.ts +163 -0
- package/src/tasks/gantt/logic.ts +248 -0
- package/src/tasks/inbox/inbox-card.svelte +283 -0
- package/src/tasks/inbox/inbox-draft.svelte +84 -0
- package/src/tasks/inbox/inbox-logic.ts +55 -0
- package/src/tasks/inbox/inbox-statuses.ts +48 -0
- package/src/tasks/inbox/inbox-trace.svelte +45 -0
- package/src/tasks/inbox/inbox-types.ts +108 -0
- package/src/tasks/inbox/inbox.svelte +203 -0
- package/src/tasks/inbox/index.ts +23 -0
- package/src/tasks/index.ts +85 -0
- package/src/tasks/kanban-board.svelte +561 -0
- package/src/tasks/kanban-column.svelte +117 -0
- package/src/tasks/kanban-drag.ts +38 -0
- package/src/tasks/kanban-types.ts +65 -0
- package/src/tasks/presets/sales.ts +16 -0
- package/src/tasks/record/demo-data.ts +286 -0
- package/src/tasks/record/field-section.svelte +53 -0
- package/src/tasks/record/fields.ts +142 -0
- package/src/tasks/record/format.ts +87 -0
- package/src/tasks/record/gutter.ts +2 -0
- package/src/tasks/record/index.ts +54 -0
- package/src/tasks/record/info-list.svelte +316 -0
- package/src/tasks/record/kinds.ts +42 -0
- package/src/tasks/record/logic.ts +324 -0
- package/src/tasks/record/next-up.svelte +70 -0
- package/src/tasks/record/project-list.svelte +133 -0
- package/src/tasks/record/record-demo.svelte +324 -0
- package/src/tasks/record/record-header.svelte +70 -0
- package/src/tasks/record/record-shell.svelte +138 -0
- package/src/tasks/record/record-stats.svelte +48 -0
- package/src/tasks/record/record-timeline.svelte +231 -0
- package/src/tasks/record/record.test.ts +350 -0
- package/src/tasks/record/steps-rail.svelte +474 -0
- package/src/tasks/record/types.ts +280 -0
- package/src/tasks/record/where-we-are.svelte +121 -0
- package/src/tasks/reorder.ts +19 -0
- package/src/tasks/side-panel-types.ts +16 -0
- package/src/tasks/side-panel.svelte +193 -0
- package/src/tasks/status-badge.svelte +63 -0
- package/src/tasks/status-dot.svelte +228 -0
- package/src/tasks/status-icon.svelte +30 -0
- package/src/tasks/status-types.ts +40 -0
- package/src/tasks/task-gantt.svelte +230 -0
- package/src/tasks/task-list.svelte +470 -0
- package/src/tasks/task-types.ts +33 -0
- package/src/tasks/time/duration.ts +69 -0
- package/src/tasks/time/time-chip.svelte +62 -0
- package/src/tasks/time/time-dot.svelte +58 -0
- package/src/tasks/time/time-ring.svelte +74 -0
- package/src/tasks/time/time-tracker.svelte +565 -0
- package/src/tasks/time/time-types.ts +74 -0
- package/src/tasks/use-kanban-dnd.svelte.ts +173 -0
- package/src/tokens/base.css +5 -5
- package/src/tokens/palette.css +115 -120
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// The style panel model: what a selection takes, and the ops that restyle it.
|
|
2
|
+
// A change is one patchNode per card, so it is one undo step.
|
|
3
|
+
|
|
4
|
+
import type { CanvasOp } from "../ops/ops.js";
|
|
5
|
+
import { PEN_COLORS, SHAPE_NODE, STROKE_NODE, TEXT_NODE, type PenColor } from "../pen/types.js";
|
|
6
|
+
|
|
7
|
+
export type FillValue = PenColor | "none";
|
|
8
|
+
export type FontWeight = "regular" | "bold";
|
|
9
|
+
/** Thin, regular, thick. A level maps to a different width on a stroke, a shape and a frame. */
|
|
10
|
+
export type WidthLevel = 0 | 1 | 2;
|
|
11
|
+
|
|
12
|
+
export interface StyleValues {
|
|
13
|
+
fill: FillValue;
|
|
14
|
+
stroke: PenColor;
|
|
15
|
+
width: WidthLevel;
|
|
16
|
+
fontSize: number;
|
|
17
|
+
fontWeight: FontWeight;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type StyleControl = keyof StyleValues;
|
|
21
|
+
|
|
22
|
+
export const FONT_SIZES = [16, 20, 28, 40] as const;
|
|
23
|
+
|
|
24
|
+
export interface StyleNode {
|
|
25
|
+
id: string;
|
|
26
|
+
type?: string;
|
|
27
|
+
data: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const SHAPE_WIDTHS = [2, 3, 5] as const;
|
|
31
|
+
const PEN_WIDTHS = [2, 4, 8] as const;
|
|
32
|
+
const HIGHLIGHTER_WIDTHS = [12, 20, 32] as const;
|
|
33
|
+
const FRAME_WIDTHS = [1, 2, 4] as const;
|
|
34
|
+
|
|
35
|
+
type Kind = "shape" | "text" | "stroke" | "frame";
|
|
36
|
+
|
|
37
|
+
const CONTROLS: Record<Kind, readonly StyleControl[]> = {
|
|
38
|
+
shape: ["fill", "stroke", "width"],
|
|
39
|
+
text: ["stroke", "fontSize", "fontWeight"],
|
|
40
|
+
stroke: ["stroke", "width"],
|
|
41
|
+
frame: ["fill", "stroke", "width"],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function kindOf(node: StyleNode, frameType: string): Kind | null {
|
|
45
|
+
if (node.type === SHAPE_NODE) return "shape";
|
|
46
|
+
if (node.type === TEXT_NODE) return "text";
|
|
47
|
+
if (node.type === STROKE_NODE) return "stroke";
|
|
48
|
+
// Only a frame from the F tool wears a fill and a line; a group draws its own colour.
|
|
49
|
+
return node.type === frameType && node.data.frame === true ? "frame" : null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function widthsOf(kind: Kind, node: StyleNode): readonly number[] {
|
|
53
|
+
if (kind === "shape") return SHAPE_WIDTHS;
|
|
54
|
+
if (kind === "frame") return FRAME_WIDTHS;
|
|
55
|
+
return node.data.tool === "highlighter" ? HIGHLIGHTER_WIDTHS : PEN_WIDTHS;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function widthKey(kind: Kind): string {
|
|
59
|
+
if (kind === "stroke") return "size";
|
|
60
|
+
return "strokeWidth";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function colorOf(value: unknown): PenColor | undefined {
|
|
64
|
+
return PEN_COLORS.find((color) => color === value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function levelOf(kind: Kind, node: StyleNode): WidthLevel {
|
|
68
|
+
const widths = widthsOf(kind, node);
|
|
69
|
+
// A frame nobody styled draws the thinnest line, and a pen mark its middle one.
|
|
70
|
+
const stored = Number(node.data[widthKey(kind)]);
|
|
71
|
+
if (!Number.isFinite(stored)) return kind === "frame" ? 0 : 1;
|
|
72
|
+
let nearest = 0;
|
|
73
|
+
for (let at = 1; at < widths.length; at += 1) {
|
|
74
|
+
if (Math.abs(widths[at] - stored) < Math.abs(widths[nearest] - stored)) nearest = at;
|
|
75
|
+
}
|
|
76
|
+
return nearest as WidthLevel;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** What a card of each kind shows, given the colour it draws in. */
|
|
80
|
+
const VALUES: Record<Kind, (node: StyleNode, color: PenColor) => Partial<StyleValues>> = {
|
|
81
|
+
shape: (node, color) => ({
|
|
82
|
+
fill: node.data.filled ? (colorOf(node.data.fill) ?? color) : "none",
|
|
83
|
+
stroke: color,
|
|
84
|
+
width: levelOf("shape", node),
|
|
85
|
+
}),
|
|
86
|
+
text: (node, color) => ({
|
|
87
|
+
stroke: color,
|
|
88
|
+
fontSize: Number(node.data.fontSize) || 20,
|
|
89
|
+
fontWeight: node.data.fontWeight === "bold" ? "bold" : "regular",
|
|
90
|
+
}),
|
|
91
|
+
stroke: (node, color) => ({ stroke: color, width: levelOf("stroke", node) }),
|
|
92
|
+
frame: (node) => ({
|
|
93
|
+
fill: colorOf(node.data.fill) ?? "none",
|
|
94
|
+
stroke: colorOf(node.data.stroke) ?? "ink",
|
|
95
|
+
width: levelOf("frame", node),
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function valuesOf(kind: Kind, node: StyleNode): Partial<StyleValues> {
|
|
100
|
+
return VALUES[kind](node, colorOf(node.data.color) ?? "ink");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface StyleSummary {
|
|
104
|
+
/** Every control some selected card answers to. */
|
|
105
|
+
controls: ReadonlySet<StyleControl>;
|
|
106
|
+
/** A value every card that has the control agrees on. Missing where they differ. */
|
|
107
|
+
values: Partial<StyleValues>;
|
|
108
|
+
/** The widths a control shows, in px, for the first card that has one. */
|
|
109
|
+
widths: readonly number[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** What the panel shows for a selection, or null when nothing in it takes a style. */
|
|
113
|
+
export function summarizeStyle(
|
|
114
|
+
nodes: readonly StyleNode[],
|
|
115
|
+
frameType: string,
|
|
116
|
+
): StyleSummary | null {
|
|
117
|
+
const controls = new Set<StyleControl>();
|
|
118
|
+
const seen = new Map<StyleControl, Set<unknown>>();
|
|
119
|
+
let widths: readonly number[] = [];
|
|
120
|
+
for (const node of nodes) {
|
|
121
|
+
const kind = kindOf(node, frameType);
|
|
122
|
+
if (!kind) continue;
|
|
123
|
+
const values = valuesOf(kind, node);
|
|
124
|
+
for (const control of CONTROLS[kind]) {
|
|
125
|
+
controls.add(control);
|
|
126
|
+
const set = seen.get(control) ?? new Set();
|
|
127
|
+
set.add(values[control]);
|
|
128
|
+
seen.set(control, set);
|
|
129
|
+
}
|
|
130
|
+
if (widths.length === 0 && CONTROLS[kind].includes("width")) widths = widthsOf(kind, node);
|
|
131
|
+
}
|
|
132
|
+
if (controls.size === 0) return null;
|
|
133
|
+
const values: Partial<StyleValues> = {};
|
|
134
|
+
for (const [control, set] of seen) {
|
|
135
|
+
if (set.size === 1) Object.assign(values, { [control]: [...set][0] });
|
|
136
|
+
}
|
|
137
|
+
return { controls, values, widths };
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** A frame keeps its fill as is; a shape's fill also says whether it is filled. */
|
|
141
|
+
function fillData(kind: Kind, fill: FillValue): Record<string, unknown> {
|
|
142
|
+
if (kind === "frame") return { fill };
|
|
143
|
+
return fill === "none" ? { filled: false } : { filled: true, fill };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function textData(change: Partial<StyleValues>): Record<string, unknown> {
|
|
147
|
+
const data: Record<string, unknown> = {};
|
|
148
|
+
if (change.fontSize !== undefined) data.fontSize = change.fontSize;
|
|
149
|
+
if (change.fontWeight !== undefined) data.fontWeight = change.fontWeight;
|
|
150
|
+
return data;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function dataFor(
|
|
154
|
+
kind: Kind,
|
|
155
|
+
node: StyleNode,
|
|
156
|
+
change: Partial<StyleValues>,
|
|
157
|
+
): Record<string, unknown> {
|
|
158
|
+
const data: Record<string, unknown> = {};
|
|
159
|
+
if (change.stroke) data[kind === "frame" ? "stroke" : "color"] = change.stroke;
|
|
160
|
+
if (change.fill !== undefined && (kind === "shape" || kind === "frame")) {
|
|
161
|
+
Object.assign(data, fillData(kind, change.fill));
|
|
162
|
+
}
|
|
163
|
+
if (change.width !== undefined && kind !== "text") {
|
|
164
|
+
data[widthKey(kind)] = widthsOf(kind, node)[change.width];
|
|
165
|
+
}
|
|
166
|
+
if (kind === "text") Object.assign(data, textData(change));
|
|
167
|
+
return data;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** One patch per card the change applies to. All of them are one undo step when dispatched together. */
|
|
171
|
+
export function styleOps(
|
|
172
|
+
nodes: readonly StyleNode[],
|
|
173
|
+
change: Partial<StyleValues>,
|
|
174
|
+
frameType: string,
|
|
175
|
+
): CanvasOp[] {
|
|
176
|
+
const ops: CanvasOp[] = [];
|
|
177
|
+
for (const node of nodes) {
|
|
178
|
+
const kind = kindOf(node, frameType);
|
|
179
|
+
if (!kind) continue;
|
|
180
|
+
const data = dataFor(kind, node, change);
|
|
181
|
+
if (Object.keys(data).length > 0) ops.push({ kind: "patchNode", nodeId: node.id, data });
|
|
182
|
+
}
|
|
183
|
+
return ops;
|
|
184
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// The text field a host hands the pen. A plain textarea keeps the canvas MIT-clean; a host that
|
|
2
|
+
// formats text provides a component, set once with the page skin.
|
|
3
|
+
|
|
4
|
+
import { getContext, setContext, type Component } from "svelte";
|
|
5
|
+
|
|
6
|
+
/** What the pen asks of a text field. A host component takes these and may take more. */
|
|
7
|
+
export type TextFieldProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
ariaLabel?: string;
|
|
11
|
+
class?: string;
|
|
12
|
+
style?: string;
|
|
13
|
+
/** `live` is true while typing, so a run of keystrokes folds into one undo step. */
|
|
14
|
+
onCommit: (next: string, live: boolean) => void;
|
|
15
|
+
/** A click on the text opens it. A pen text that opens on double-click turns this off. */
|
|
16
|
+
clickToEdit?: boolean;
|
|
17
|
+
/** The field closed: focus left it or Escape. */
|
|
18
|
+
onExit?: () => void;
|
|
19
|
+
/** Shown, never opened: a locked card. */
|
|
20
|
+
readonly?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** What the pen calls on a field it holds a reference to. */
|
|
24
|
+
export type TextFieldHandle = {
|
|
25
|
+
edit: (point?: { x: number; y: number }) => void | Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type TextFieldComponent = Component<TextFieldProps, TextFieldHandle>;
|
|
29
|
+
|
|
30
|
+
/** For a host that mounts a pen node with `mount(..., { context })`, as a test does. */
|
|
31
|
+
export const TEXT_FIELD_KEY = Symbol("canvas-text-field");
|
|
32
|
+
|
|
33
|
+
/** Call during component init. */
|
|
34
|
+
export function setTextField(component: TextFieldComponent): void {
|
|
35
|
+
setContext(TEXT_FIELD_KEY, component);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The host's field, or null: the pen then draws its own textarea. */
|
|
39
|
+
export function useTextField(): TextFieldComponent | null {
|
|
40
|
+
return getContext<TextFieldComponent | undefined>(TEXT_FIELD_KEY) ?? null;
|
|
41
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
2
|
+
import type { Node } from "@xyflow/svelte";
|
|
3
|
+
import { reorderStack, topLayer } from "./z-order.js";
|
|
4
|
+
|
|
5
|
+
function card(id: string, extra: Partial<Node> = {}): Node {
|
|
6
|
+
return { id, type: "note", position: { x: 0, y: 0 }, data: {}, ...extra };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/** Ids bottom to top, as the canvas paints them. */
|
|
10
|
+
function stack(nodes: Node[], parentId?: string): string[] {
|
|
11
|
+
return nodes
|
|
12
|
+
.map((node, index) => ({ node, index }))
|
|
13
|
+
.filter(({ node }) => (node.parentId ?? "") === (parentId ?? ""))
|
|
14
|
+
.sort((a, b) => (a.node.zIndex ?? 0) - (b.node.zIndex ?? 0) || a.index - b.index)
|
|
15
|
+
.map(({ node }) => node.id);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe("reorderStack", () => {
|
|
19
|
+
const board = [card("a"), card("b"), card("c"), card("d")];
|
|
20
|
+
|
|
21
|
+
it("brings one card to the front and sends one to the back", () => {
|
|
22
|
+
expect(stack(reorderStack(board, new Set(["a"]), "front") ?? board)).toEqual([
|
|
23
|
+
"b",
|
|
24
|
+
"c",
|
|
25
|
+
"d",
|
|
26
|
+
"a",
|
|
27
|
+
]);
|
|
28
|
+
expect(stack(reorderStack(board, new Set(["d"]), "back") ?? board)).toEqual([
|
|
29
|
+
"d",
|
|
30
|
+
"a",
|
|
31
|
+
"b",
|
|
32
|
+
"c",
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("moves one step and keeps picked cards in their order", () => {
|
|
37
|
+
const up = reorderStack(board, new Set(["a", "c"]), "forward") ?? board;
|
|
38
|
+
expect(stack(up)).toEqual(["b", "a", "d", "c"]);
|
|
39
|
+
const down = reorderStack(board, new Set(["b", "d"]), "backward") ?? board;
|
|
40
|
+
expect(stack(down)).toEqual(["b", "a", "d", "c"]);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("returns null when nothing would change", () => {
|
|
44
|
+
expect(reorderStack(board, new Set(["d"]), "front")).toBeNull();
|
|
45
|
+
expect(reorderStack(board, new Set(["a"]), "back")).toBeNull();
|
|
46
|
+
expect(reorderStack(board, new Set(["d"]), "forward")).toBeNull();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("writes only the layers that changed", () => {
|
|
50
|
+
const next = reorderStack(board, new Set(["a"]), "front") ?? board;
|
|
51
|
+
expect(next.find((n) => n.id === "b")?.zIndex).toBeUndefined();
|
|
52
|
+
expect(next.find((n) => n.id === "a")?.zIndex).toBe(3);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("stacks children inside their own group and leaves ink out", () => {
|
|
56
|
+
const nodes = [
|
|
57
|
+
card("g", { type: "wrapper" }),
|
|
58
|
+
card("x", { parentId: "g" }),
|
|
59
|
+
card("y", { parentId: "g" }),
|
|
60
|
+
card("ink", { type: "stroke" }),
|
|
61
|
+
];
|
|
62
|
+
const next = reorderStack(nodes, new Set(["x"]), "front") ?? nodes;
|
|
63
|
+
expect(stack(next, "g")).toEqual(["y", "x"]);
|
|
64
|
+
expect(next.find((n) => n.id === "g")?.zIndex).toBeUndefined();
|
|
65
|
+
expect(reorderStack(nodes, new Set(["ink"]), "front")).toBeNull();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("topLayer", () => {
|
|
70
|
+
it("is undefined until a card has been raised, then one above the top", () => {
|
|
71
|
+
expect(topLayer([card("a"), card("b")])).toBeUndefined();
|
|
72
|
+
expect(topLayer([card("a", { zIndex: 4 }), card("b")])).toBe(5);
|
|
73
|
+
expect(topLayer([card("g"), card("x", { parentId: "g", zIndex: 9 })])).toBeUndefined();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Stacking order for cards: pure functions over nodes. A card's place is its `zIndex` (missing
|
|
2
|
+
// is 0), and array order breaks a tie, as xyflow paints equal layers.
|
|
3
|
+
|
|
4
|
+
import type { Node } from "@xyflow/svelte";
|
|
5
|
+
|
|
6
|
+
export type StackMove = "forward" | "backward" | "front" | "back";
|
|
7
|
+
|
|
8
|
+
/** Ink is an annotation layer pinned above every card by pen.css, so it has no place in a stack. */
|
|
9
|
+
export const INK_TYPES: ReadonlySet<string> = new Set(["stroke", "text", "shape"]);
|
|
10
|
+
|
|
11
|
+
type Slot = { node: Node; index: number };
|
|
12
|
+
|
|
13
|
+
function layerOf(node: Node): number {
|
|
14
|
+
return typeof node.zIndex === "number" ? node.zIndex : 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Cards stack among their siblings: a child never leaves its group's own stack. */
|
|
18
|
+
function stacks(nodes: readonly Node[]): Map<string, Slot[]> {
|
|
19
|
+
const byParent = new Map<string, Slot[]>();
|
|
20
|
+
nodes.forEach((node, index) => {
|
|
21
|
+
if (INK_TYPES.has(node.type ?? "")) return;
|
|
22
|
+
const key = node.parentId ?? "";
|
|
23
|
+
const stack = byParent.get(key) ?? [];
|
|
24
|
+
stack.push({ node, index });
|
|
25
|
+
byParent.set(key, stack);
|
|
26
|
+
});
|
|
27
|
+
for (const stack of byParent.values()) {
|
|
28
|
+
stack.sort((a, b) => layerOf(a.node) - layerOf(b.node) || a.index - b.index);
|
|
29
|
+
}
|
|
30
|
+
return byParent;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** One stack after a move, bottom first. Selected cards keep their order among themselves. */
|
|
34
|
+
function moved(stack: Slot[], picked: ReadonlySet<string>, move: StackMove): Slot[] {
|
|
35
|
+
const isPicked = (slot: Slot) => picked.has(slot.node.id);
|
|
36
|
+
if (move === "front") return [...stack.filter((s) => !isPicked(s)), ...stack.filter(isPicked)];
|
|
37
|
+
if (move === "back") return [...stack.filter(isPicked), ...stack.filter((s) => !isPicked(s))];
|
|
38
|
+
const next = [...stack];
|
|
39
|
+
// One step: each picked card trades places with the unpicked card beside it.
|
|
40
|
+
if (move === "forward") {
|
|
41
|
+
for (let i = next.length - 2; i >= 0; i--) {
|
|
42
|
+
if (isPicked(next[i]) && !isPicked(next[i + 1]))
|
|
43
|
+
[next[i], next[i + 1]] = [next[i + 1], next[i]];
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
for (let i = 1; i < next.length; i++) {
|
|
47
|
+
if (isPicked(next[i]) && !isPicked(next[i - 1]))
|
|
48
|
+
[next[i], next[i - 1]] = [next[i - 1], next[i]];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return next;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The board after a stacking move, or null when nothing changes. Only a stack holding a
|
|
56
|
+
* picked card is touched, and only cards whose layer changed are rewritten.
|
|
57
|
+
*/
|
|
58
|
+
export function reorderStack(
|
|
59
|
+
nodes: readonly Node[],
|
|
60
|
+
picked: ReadonlySet<string>,
|
|
61
|
+
move: StackMove,
|
|
62
|
+
): Node[] | null {
|
|
63
|
+
const layers = new Map<string, number>();
|
|
64
|
+
for (const stack of stacks(nodes).values()) {
|
|
65
|
+
if (!stack.some((slot) => picked.has(slot.node.id))) continue;
|
|
66
|
+
const next = moved(stack, picked, move);
|
|
67
|
+
if (next.every((slot, i) => slot === stack[i])) continue;
|
|
68
|
+
next.forEach((slot, rank) => {
|
|
69
|
+
if (layerOf(slot.node) !== rank) layers.set(slot.node.id, rank);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (layers.size === 0) return null;
|
|
73
|
+
return nodes.map((node) => {
|
|
74
|
+
const layer = layers.get(node.id);
|
|
75
|
+
return layer === undefined ? node : { ...node, zIndex: layer };
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The layer a new card needs to land on top of its siblings, or undefined while no card has been raised. */
|
|
80
|
+
export function topLayer(nodes: readonly Node[], parentId?: string): number | undefined {
|
|
81
|
+
let top = 0;
|
|
82
|
+
for (const node of nodes) {
|
|
83
|
+
if (INK_TYPES.has(node.type ?? "") || (node.parentId ?? "") !== (parentId ?? "")) continue;
|
|
84
|
+
top = Math.max(top, layerOf(node));
|
|
85
|
+
}
|
|
86
|
+
return top > 0 ? top + 1 : undefined;
|
|
87
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
2
|
+
import { alignNodesHorizontally, alignNodesVertically } from "./alignment.js";
|
|
3
|
+
import { makeNode } from "../test-utils.js";
|
|
4
|
+
|
|
5
|
+
describe("alignNodesHorizontally", () => {
|
|
6
|
+
it("sets all nodes to the topmost Y", () => {
|
|
7
|
+
const nodes = [
|
|
8
|
+
makeNode({ id: "a", position: { x: 0, y: 100 } }),
|
|
9
|
+
makeNode({ id: "b", position: { x: 50, y: 50 } }),
|
|
10
|
+
makeNode({ id: "c", position: { x: 100, y: 200 } }),
|
|
11
|
+
];
|
|
12
|
+
alignNodesHorizontally(nodes);
|
|
13
|
+
expect(nodes.map((n) => n.position.y)).toEqual([50, 50, 50]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("preserves X positions", () => {
|
|
17
|
+
const nodes = [
|
|
18
|
+
makeNode({ id: "a", position: { x: 10, y: 100 } }),
|
|
19
|
+
makeNode({ id: "b", position: { x: 200, y: 50 } }),
|
|
20
|
+
];
|
|
21
|
+
alignNodesHorizontally(nodes);
|
|
22
|
+
expect(nodes[0].position.x).toBe(10);
|
|
23
|
+
expect(nodes[1].position.x).toBe(200);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("does nothing for fewer than 2 nodes", () => {
|
|
27
|
+
const single = [makeNode({ id: "a", position: { x: 5, y: 99 } })];
|
|
28
|
+
alignNodesHorizontally(single);
|
|
29
|
+
expect(single[0].position.y).toBe(99);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe("alignNodesVertically", () => {
|
|
34
|
+
it("sets all nodes to the leftmost X", () => {
|
|
35
|
+
const nodes = [
|
|
36
|
+
makeNode({ id: "a", position: { x: 100, y: 0 } }),
|
|
37
|
+
makeNode({ id: "b", position: { x: 50, y: 50 } }),
|
|
38
|
+
makeNode({ id: "c", position: { x: 200, y: 100 } }),
|
|
39
|
+
];
|
|
40
|
+
alignNodesVertically(nodes);
|
|
41
|
+
expect(nodes.map((n) => n.position.x)).toEqual([50, 50, 50]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("preserves Y positions", () => {
|
|
45
|
+
const nodes = [
|
|
46
|
+
makeNode({ id: "a", position: { x: 100, y: 10 } }),
|
|
47
|
+
makeNode({ id: "b", position: { x: 50, y: 200 } }),
|
|
48
|
+
];
|
|
49
|
+
alignNodesVertically(nodes);
|
|
50
|
+
expect(nodes[0].position.y).toBe(10);
|
|
51
|
+
expect(nodes[1].position.y).toBe(200);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("does nothing for fewer than 2 nodes", () => {
|
|
55
|
+
const single = [makeNode({ id: "a", position: { x: 99, y: 5 } })];
|
|
56
|
+
alignNodesVertically(single);
|
|
57
|
+
expect(single[0].position.x).toBe(99);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CanvasNode } from "../types.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Align nodes horizontally (same row): set all to the topmost Y.
|
|
5
|
+
*/
|
|
6
|
+
export function alignNodesHorizontally(nodes: CanvasNode[]): void {
|
|
7
|
+
if (nodes.length < 2) return;
|
|
8
|
+
const targetY = Math.min(...nodes.map((n) => n.position.y));
|
|
9
|
+
for (const node of nodes) {
|
|
10
|
+
node.position = { ...node.position, y: targetY };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Align nodes vertically (same column): set all to the leftmost X.
|
|
16
|
+
*/
|
|
17
|
+
export function alignNodesVertically(nodes: CanvasNode[]): void {
|
|
18
|
+
if (nodes.length < 2) return;
|
|
19
|
+
const targetX = Math.min(...nodes.map((n) => n.position.x));
|
|
20
|
+
for (const node of nodes) {
|
|
21
|
+
node.position = { ...node.position, x: targetX };
|
|
22
|
+
}
|
|
23
|
+
}
|