@zonsh/ui 0.4.1 → 0.6.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/CHANGELOG.md +639 -0
- package/README.md +49 -21
- package/dist/brand.d.ts +3 -0
- package/dist/brand.js +7 -0
- package/dist/components/_breadcrumb-more.d.ts +6 -0
- package/dist/components/_breadcrumb-more.js +5 -0
- package/dist/components/_drawing-svg.d.ts +11 -0
- package/dist/components/_drawing-svg.js +30 -0
- package/dist/components/_media.d.ts +159 -0
- package/dist/components/_media.js +266 -0
- package/dist/components/_overlay.d.ts +8 -5
- package/dist/components/_overlay.js +11 -6
- package/dist/components/_scheduler-calendar.d.ts +71 -0
- package/dist/components/_scheduler-calendar.js +940 -0
- package/dist/components/_scheduler-editor.d.ts +29 -0
- package/dist/components/_scheduler-editor.js +111 -0
- package/dist/components/_scheduler-menu.d.ts +16 -0
- package/dist/components/_scheduler-menu.js +18 -0
- package/dist/components/_scheduler-parts.d.ts +164 -0
- package/dist/components/_scheduler-parts.js +327 -0
- package/dist/components/_suggest-list.d.ts +142 -0
- package/dist/components/_suggest-list.js +159 -0
- package/dist/components/_toolbar-more.d.ts +24 -0
- package/dist/components/_toolbar-more.js +25 -0
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +7 -7
- package/dist/components/action-sheet.d.ts +88 -0
- package/dist/components/action-sheet.js +124 -0
- package/dist/components/alert-dialog.js +3 -1
- package/dist/components/alert.d.ts +11 -18
- package/dist/components/alert.js +9 -6
- package/dist/components/app-bar.d.ts +93 -0
- package/dist/components/app-bar.js +175 -0
- package/dist/components/ascii-field.js +2 -1
- package/dist/components/audio-player.d.ts +134 -0
- package/dist/components/audio-player.js +618 -0
- package/dist/components/avatar.d.ts +6 -6
- package/dist/components/avatar.js +13 -11
- package/dist/components/badge.d.ts +12 -12
- package/dist/components/badge.js +7 -5
- package/dist/components/bottom-nav.d.ts +53 -11
- package/dist/components/bottom-nav.js +389 -24
- package/dist/components/breadcrumb.d.ts +11 -2
- package/dist/components/breadcrumb.js +60 -6
- package/dist/components/button-group.js +5 -1
- package/dist/components/button.d.ts +23 -6
- package/dist/components/button.js +64 -8
- package/dist/components/calendar.js +8 -6
- package/dist/components/card.d.ts +10 -8
- package/dist/components/card.js +15 -14
- package/dist/components/carousel.d.ts +2 -2
- package/dist/components/carousel.js +21 -8
- package/dist/components/chart.d.ts +38 -1
- package/dist/components/chart.js +27 -5
- package/dist/components/checkbox.js +2 -2
- package/dist/components/code-block.d.ts +9 -2
- package/dist/components/code-block.js +26 -7
- package/dist/components/collapsible.js +4 -4
- package/dist/components/color-picker.d.ts +2 -2
- package/dist/components/color-picker.js +5 -5
- package/dist/components/combobox.d.ts +26 -7
- package/dist/components/combobox.js +32 -13
- package/dist/components/command.d.ts +29 -5
- package/dist/components/command.js +37 -12
- package/dist/components/context-menu.d.ts +5 -2
- package/dist/components/context-menu.js +24 -3
- package/dist/components/conversation.d.ts +1 -1
- package/dist/components/conversation.js +77 -16
- package/dist/components/copy-button.d.ts +1 -1
- package/dist/components/copy-button.js +8 -6
- package/dist/components/data-table.d.ts +6 -6
- package/dist/components/data-table.js +41 -15
- package/dist/components/date-picker.d.ts +31 -9
- package/dist/components/date-picker.js +100 -18
- package/dist/components/dialog.d.ts +17 -10
- package/dist/components/dialog.js +20 -13
- package/dist/components/drawer.d.ts +26 -8
- package/dist/components/drawer.js +75 -16
- package/dist/components/drawing.d.ts +25 -0
- package/dist/components/drawing.js +32 -0
- package/dist/components/empty.js +2 -2
- package/dist/components/feature-list.d.ts +65 -13
- package/dist/components/feature-list.js +116 -15
- package/dist/components/field.js +2 -2
- package/dist/components/file-drop.d.ts +9 -7
- package/dist/components/file-drop.js +8 -43
- package/dist/components/filter-bar.d.ts +10 -9
- package/dist/components/filter-bar.js +42 -25
- package/dist/components/graph.d.ts +19 -3
- package/dist/components/graph.js +190 -28
- package/dist/components/illustration.js +53 -31
- package/dist/components/input-group.d.ts +6 -11
- package/dist/components/input-group.js +21 -19
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +3 -3
- package/dist/components/item.d.ts +9 -6
- package/dist/components/item.js +13 -8
- package/dist/components/kbd.d.ts +1 -1
- package/dist/components/kbd.js +1 -1
- package/dist/components/layout.d.ts +2 -1
- package/dist/components/layout.js +55 -11
- package/dist/components/lightbox.d.ts +76 -9
- package/dist/components/lightbox.js +354 -48
- package/dist/components/locale.d.ts +6 -6
- package/dist/components/logo.d.ts +21 -1
- package/dist/components/logo.js +32 -2
- package/dist/components/markdown-editor.d.ts +275 -0
- package/dist/components/markdown-editor.js +831 -0
- package/dist/components/mentions.d.ts +153 -0
- package/dist/components/mentions.js +507 -0
- package/dist/components/menu.d.ts +2 -1
- package/dist/components/menu.js +5 -4
- package/dist/components/menubar.d.ts +23 -5
- package/dist/components/menubar.js +153 -31
- package/dist/components/message.d.ts +62 -11
- package/dist/components/message.js +51 -14
- package/dist/components/meter.js +1 -1
- package/dist/components/money-input.d.ts +1 -1
- package/dist/components/money-input.js +1 -1
- package/dist/components/native-select.d.ts +2 -2
- package/dist/components/native-select.js +4 -4
- package/dist/components/navigation-menu.d.ts +3 -1
- package/dist/components/navigation-menu.js +23 -10
- package/dist/components/number-field.d.ts +2 -9
- package/dist/components/number-field.js +90 -26
- package/dist/components/number-roll.d.ts +26 -0
- package/dist/components/number-roll.js +81 -0
- package/dist/components/otp-field.d.ts +1 -1
- package/dist/components/otp-field.js +24 -3
- package/dist/components/pagination.d.ts +11 -3
- package/dist/components/pagination.js +59 -13
- package/dist/components/pdf-viewer.d.ts +1 -1
- package/dist/components/pdf-viewer.js +8 -8
- package/dist/components/phone-input.d.ts +1 -1
- package/dist/components/phone-input.js +2 -2
- package/dist/components/popover.js +5 -3
- package/dist/components/preview-card.d.ts +37 -2
- package/dist/components/preview-card.js +226 -2
- package/dist/components/progress.js +1 -1
- package/dist/components/prompt-input.d.ts +1 -1
- package/dist/components/prompt-input.js +35 -17
- package/dist/components/pull-to-refresh.d.ts +50 -0
- package/dist/components/pull-to-refresh.js +189 -0
- package/dist/components/quote.d.ts +6 -1
- package/dist/components/quote.js +3 -2
- package/dist/components/radio-group.js +8 -3
- package/dist/components/rating.d.ts +4 -1
- package/dist/components/rating.js +131 -10
- package/dist/components/reasoning.d.ts +1 -1
- package/dist/components/reasoning.js +7 -3
- package/dist/components/resizable.d.ts +1 -1
- package/dist/components/resizable.js +2 -2
- package/dist/components/response.d.ts +4 -3
- package/dist/components/response.js +39 -15
- package/dist/components/scheduler.d.ts +352 -0
- package/dist/components/scheduler.js +1717 -0
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/select.d.ts +17 -4
- package/dist/components/select.js +140 -9
- package/dist/components/separator.d.ts +1 -1
- package/dist/components/separator.js +3 -3
- package/dist/components/sidebar.d.ts +44 -3
- package/dist/components/sidebar.js +90 -31
- package/dist/components/site-header.d.ts +18 -13
- package/dist/components/site-header.js +26 -9
- package/dist/components/skeleton.d.ts +18 -8
- package/dist/components/skeleton.js +23 -8
- package/dist/components/slider.js +2 -2
- package/dist/components/sortable.d.ts +55 -4
- package/dist/components/sortable.js +187 -94
- package/dist/components/sources.d.ts +1 -1
- package/dist/components/sources.js +2 -2
- package/dist/components/spinner.d.ts +4 -4
- package/dist/components/spinner.js +4 -4
- package/dist/components/stat.d.ts +21 -4
- package/dist/components/stat.js +17 -8
- package/dist/components/stepper.d.ts +1 -1
- package/dist/components/stepper.js +8 -7
- package/dist/components/suggestions.d.ts +11 -3
- package/dist/components/suggestions.js +10 -4
- package/dist/components/swipe-actions.d.ts +66 -0
- package/dist/components/swipe-actions.js +292 -0
- package/dist/components/switch.js +1 -1
- package/dist/components/table.d.ts +13 -7
- package/dist/components/table.js +124 -23
- package/dist/components/tabs.js +15 -8
- package/dist/components/tag.d.ts +19 -20
- package/dist/components/tag.js +9 -5
- package/dist/components/tags-input.d.ts +2 -7
- package/dist/components/tags-input.js +11 -8
- package/dist/components/textarea.d.ts +3 -2
- package/dist/components/textarea.js +4 -3
- package/dist/components/theme.d.ts +50 -7
- package/dist/components/theme.js +168 -12
- package/dist/components/time-field.d.ts +6 -10
- package/dist/components/time-field.js +19 -9
- package/dist/components/timeline.d.ts +19 -3
- package/dist/components/timeline.js +21 -9
- package/dist/components/tippy.d.ts +17 -1
- package/dist/components/tippy.js +95 -15
- package/dist/components/toast.d.ts +2 -7
- package/dist/components/toast.js +12 -8
- package/dist/components/toggle-group.d.ts +7 -1
- package/dist/components/toggle-group.js +17 -5
- package/dist/components/toggle.d.ts +2 -2
- package/dist/components/toggle.js +3 -2
- package/dist/components/tool-call.d.ts +1 -1
- package/dist/components/tool-call.js +8 -3
- package/dist/components/toolbar.d.ts +57 -4
- package/dist/components/toolbar.js +219 -16
- package/dist/components/tooltip.d.ts +5 -3
- package/dist/components/tooltip.js +14 -6
- package/dist/components/tour.d.ts +1 -1
- package/dist/components/tour.js +70 -24
- package/dist/components/tree.js +33 -10
- package/dist/components/typography.d.ts +31 -8
- package/dist/components/typography.js +21 -10
- package/dist/components/video-player.d.ts +7 -2
- package/dist/components/video-player.js +182 -225
- package/dist/index.d.ts +99 -92
- package/dist/index.js +99 -92
- package/dist/lib/calendar.d.ts +153 -0
- package/dist/lib/calendar.js +312 -0
- package/dist/lib/cn.d.ts +3 -1
- package/dist/lib/cn.js +5 -0
- package/dist/lib/code-highlight.d.ts +14 -0
- package/dist/lib/code-highlight.js +81 -18
- package/dist/lib/drag.d.ts +39 -0
- package/dist/lib/drag.js +96 -0
- package/dist/lib/editorial-assets.js +16 -8
- package/dist/lib/figure/figures/automation.js +25 -6
- package/dist/lib/figure/figures/bar-chart.js +6 -1
- package/dist/lib/figure/figures/brackets-classic.js +4 -1
- package/dist/lib/figure/figures/city.js +12 -2
- package/dist/lib/figure/figures/conveyor.js +17 -4
- package/dist/lib/figure/figures/database.js +5 -2
- package/dist/lib/figure/figures/documents.js +11 -3
- package/dist/lib/figure/figures/inbox.js +5 -2
- package/dist/lib/figure/figures/laptop.js +3 -1
- package/dist/lib/figure/figures/pipeline.js +45 -10
- package/dist/lib/figure/figures/platform.js +62 -7
- package/dist/lib/figure/figures/server.js +21 -5
- package/dist/lib/figure/figures/spreadsheet.js +29 -5
- package/dist/lib/figure/kernel.d.ts +4 -2
- package/dist/lib/figure/kernel.js +10 -5
- package/dist/lib/figure/parts.js +6 -2
- package/dist/lib/files.d.ts +31 -0
- package/dist/lib/files.js +60 -0
- package/dist/lib/gesture.d.ts +70 -0
- package/dist/lib/gesture.js +141 -0
- package/dist/lib/glide.d.ts +10 -4
- package/dist/lib/glide.js +14 -5
- package/dist/lib/icons.d.ts +1 -0
- package/dist/lib/icons.js +6 -0
- package/dist/lib/illustration-library.js +1 -6
- package/dist/lib/markdown-edit.d.ts +112 -0
- package/dist/lib/markdown-edit.js +557 -0
- package/dist/lib/markdown-rich-editor.d.ts +188 -0
- package/dist/lib/markdown-rich-editor.js +1153 -0
- package/dist/lib/markdown-rich.d.ts +63 -0
- package/dist/lib/markdown-rich.js +534 -0
- package/dist/lib/mentions.d.ts +100 -0
- package/dist/lib/mentions.js +246 -0
- package/dist/lib/motion.d.ts +18 -0
- package/dist/lib/motion.js +43 -5
- package/dist/lib/number-roll.d.ts +89 -0
- package/dist/lib/number-roll.js +391 -0
- package/dist/lib/platform.d.ts +6 -0
- package/dist/lib/platform.js +14 -0
- package/dist/lib/portal-container.d.ts +9 -0
- package/dist/lib/portal-container.js +10 -0
- package/dist/lib/press.d.ts +5 -0
- package/dist/lib/press.js +186 -0
- package/dist/lib/scheduler.d.ts +128 -0
- package/dist/lib/scheduler.js +272 -0
- package/dist/lib/scroll-edges.d.ts +9 -0
- package/dist/lib/scroll-edges.js +50 -0
- package/dist/lib/table-fit.d.ts +4 -3
- package/dist/lib/table-fit.js +92 -25
- package/dist/lib/theme-preset.d.ts +267 -0
- package/dist/lib/theme-preset.js +1046 -0
- package/dist/lib/theme-script.d.ts +23 -3
- package/dist/lib/theme-script.js +17 -5
- package/dist/lib/tippy/sprite.d.ts +36 -4
- package/dist/lib/tippy/sprite.js +188 -15
- package/dist/lib/tone.d.ts +4 -0
- package/dist/lib/tone.js +1 -0
- package/dist/messages/de.d.ts +3 -3
- package/dist/messages/de.js +274 -3
- package/dist/skills/zon-ui/SKILL.md +279 -0
- package/dist/skills/zon-ui/references/authoring.md +265 -0
- package/dist/skills/zon-ui/references/brand.md +416 -0
- package/dist/skills/zon-ui/references/components/accordion.md +199 -0
- package/dist/skills/zon-ui/references/components/action-sheet.md +268 -0
- package/dist/skills/zon-ui/references/components/alert-dialog.md +276 -0
- package/dist/skills/zon-ui/references/components/alert.md +167 -0
- package/dist/skills/zon-ui/references/components/app-bar.md +307 -0
- package/dist/skills/zon-ui/references/components/ascii-field.md +121 -0
- package/dist/skills/zon-ui/references/components/aspect-ratio.md +112 -0
- package/dist/skills/zon-ui/references/components/audio-player.md +231 -0
- package/dist/skills/zon-ui/references/components/avatar.md +98 -0
- package/dist/skills/zon-ui/references/components/badge.md +227 -0
- package/dist/skills/zon-ui/references/components/bottom-nav.md +709 -0
- package/dist/skills/zon-ui/references/components/breadcrumb.md +143 -0
- package/dist/skills/zon-ui/references/components/button-group.md +216 -0
- package/dist/skills/zon-ui/references/components/button.md +309 -0
- package/dist/skills/zon-ui/references/components/calendar.md +296 -0
- package/dist/skills/zon-ui/references/components/card.md +158 -0
- package/dist/skills/zon-ui/references/components/carousel.md +297 -0
- package/dist/skills/zon-ui/references/components/chart.md +739 -0
- package/dist/skills/zon-ui/references/components/chat.md +417 -0
- package/dist/skills/zon-ui/references/components/checkbox.md +219 -0
- package/dist/skills/zon-ui/references/components/code-block.md +143 -0
- package/dist/skills/zon-ui/references/components/code-highlight.md +118 -0
- package/dist/skills/zon-ui/references/components/collapsible.md +146 -0
- package/dist/skills/zon-ui/references/components/color-picker.md +200 -0
- package/dist/skills/zon-ui/references/components/combobox.md +455 -0
- package/dist/skills/zon-ui/references/components/command.md +326 -0
- package/dist/skills/zon-ui/references/components/contact-form.md +562 -0
- package/dist/skills/zon-ui/references/components/context-menu.md +159 -0
- package/dist/skills/zon-ui/references/components/conversation.md +146 -0
- package/dist/skills/zon-ui/references/components/copy-button.md +162 -0
- package/dist/skills/zon-ui/references/components/crm.md +1022 -0
- package/dist/skills/zon-ui/references/components/dashboard.md +612 -0
- package/dist/skills/zon-ui/references/components/data-table.md +776 -0
- package/dist/skills/zon-ui/references/components/date-picker.md +444 -0
- package/dist/skills/zon-ui/references/components/dialog.md +335 -0
- package/dist/skills/zon-ui/references/components/direction.md +165 -0
- package/dist/skills/zon-ui/references/components/drawer.md +276 -0
- package/dist/skills/zon-ui/references/components/drawing.md +94 -0
- package/dist/skills/zon-ui/references/components/empty.md +225 -0
- package/dist/skills/zon-ui/references/components/feature-list.md +412 -0
- package/dist/skills/zon-ui/references/components/field.md +209 -0
- package/dist/skills/zon-ui/references/components/file-drop.md +234 -0
- package/dist/skills/zon-ui/references/components/filter-bar.md +485 -0
- package/dist/skills/zon-ui/references/components/form.md +970 -0
- package/dist/skills/zon-ui/references/components/graph.md +339 -0
- package/dist/skills/zon-ui/references/components/illustration.md +497 -0
- package/dist/skills/zon-ui/references/components/inbox.md +263 -0
- package/dist/skills/zon-ui/references/components/input-group.md +339 -0
- package/dist/skills/zon-ui/references/components/input.md +189 -0
- package/dist/skills/zon-ui/references/components/item.md +277 -0
- package/dist/skills/zon-ui/references/components/kanban.md +626 -0
- package/dist/skills/zon-ui/references/components/kbd.md +116 -0
- package/dist/skills/zon-ui/references/components/label.md +104 -0
- package/dist/skills/zon-ui/references/components/layout.md +291 -0
- package/dist/skills/zon-ui/references/components/lightbox.md +235 -0
- package/dist/skills/zon-ui/references/components/locale.md +279 -0
- package/dist/skills/zon-ui/references/components/logo.md +257 -0
- package/dist/skills/zon-ui/references/components/markdown-editor.md +558 -0
- package/dist/skills/zon-ui/references/components/mentions.md +512 -0
- package/dist/skills/zon-ui/references/components/menu.md +218 -0
- package/dist/skills/zon-ui/references/components/menubar.md +292 -0
- package/dist/skills/zon-ui/references/components/message.md +243 -0
- package/dist/skills/zon-ui/references/components/meter.md +105 -0
- package/dist/skills/zon-ui/references/components/money-input.md +333 -0
- package/dist/skills/zon-ui/references/components/native-select.md +197 -0
- package/dist/skills/zon-ui/references/components/navigation-menu.md +253 -0
- package/dist/skills/zon-ui/references/components/number-field.md +210 -0
- package/dist/skills/zon-ui/references/components/number-roll.md +175 -0
- package/dist/skills/zon-ui/references/components/onboarding.md +896 -0
- package/dist/skills/zon-ui/references/components/otp-field.md +166 -0
- package/dist/skills/zon-ui/references/components/pagination.md +109 -0
- package/dist/skills/zon-ui/references/components/pdf-viewer.md +177 -0
- package/dist/skills/zon-ui/references/components/phone-input.md +252 -0
- package/dist/skills/zon-ui/references/components/popover.md +176 -0
- package/dist/skills/zon-ui/references/components/preview-card.md +193 -0
- package/dist/skills/zon-ui/references/components/pricing.md +724 -0
- package/dist/skills/zon-ui/references/components/progress.md +92 -0
- package/dist/skills/zon-ui/references/components/prompt-input.md +307 -0
- package/dist/skills/zon-ui/references/components/pull-to-refresh.md +188 -0
- package/dist/skills/zon-ui/references/components/quote.md +115 -0
- package/dist/skills/zon-ui/references/components/radio-group.md +215 -0
- package/dist/skills/zon-ui/references/components/rating.md +260 -0
- package/dist/skills/zon-ui/references/components/reasoning.md +102 -0
- package/dist/skills/zon-ui/references/components/resizable.md +213 -0
- package/dist/skills/zon-ui/references/components/response.md +170 -0
- package/dist/skills/zon-ui/references/components/scheduler.md +732 -0
- package/dist/skills/zon-ui/references/components/scroll-area.md +122 -0
- package/dist/skills/zon-ui/references/components/select.md +351 -0
- package/dist/skills/zon-ui/references/components/separator.md +103 -0
- package/dist/skills/zon-ui/references/components/settings.md +793 -0
- package/dist/skills/zon-ui/references/components/shop.md +1715 -0
- package/dist/skills/zon-ui/references/components/sidebar.md +813 -0
- package/dist/skills/zon-ui/references/components/sign-in.md +1639 -0
- package/dist/skills/zon-ui/references/components/site-header.md +303 -0
- package/dist/skills/zon-ui/references/components/skeleton.md +256 -0
- package/dist/skills/zon-ui/references/components/slider.md +172 -0
- package/dist/skills/zon-ui/references/components/sortable.md +405 -0
- package/dist/skills/zon-ui/references/components/sources.md +106 -0
- package/dist/skills/zon-ui/references/components/spinner.md +222 -0
- package/dist/skills/zon-ui/references/components/stat.md +267 -0
- package/dist/skills/zon-ui/references/components/stepper.md +285 -0
- package/dist/skills/zon-ui/references/components/suggestions.md +146 -0
- package/dist/skills/zon-ui/references/components/swipe-actions.md +344 -0
- package/dist/skills/zon-ui/references/components/switch.md +160 -0
- package/dist/skills/zon-ui/references/components/table.md +999 -0
- package/dist/skills/zon-ui/references/components/tabs.md +258 -0
- package/dist/skills/zon-ui/references/components/tag.md +115 -0
- package/dist/skills/zon-ui/references/components/tags-input.md +216 -0
- package/dist/skills/zon-ui/references/components/textarea.md +95 -0
- package/dist/skills/zon-ui/references/components/theme-editor.md +3940 -0
- package/dist/skills/zon-ui/references/components/theme.md +362 -0
- package/dist/skills/zon-ui/references/components/time-field.md +222 -0
- package/dist/skills/zon-ui/references/components/timeline.md +285 -0
- package/dist/skills/zon-ui/references/components/tippy.md +243 -0
- package/dist/skills/zon-ui/references/components/toast.md +220 -0
- package/dist/skills/zon-ui/references/components/toggle-group.md +261 -0
- package/dist/skills/zon-ui/references/components/toggle.md +167 -0
- package/dist/skills/zon-ui/references/components/tool-call.md +146 -0
- package/dist/skills/zon-ui/references/components/toolbar.md +260 -0
- package/dist/skills/zon-ui/references/components/tooltip.md +172 -0
- package/dist/skills/zon-ui/references/components/tour.md +423 -0
- package/dist/skills/zon-ui/references/components/tree.md +481 -0
- package/dist/skills/zon-ui/references/components/typography.md +347 -0
- package/dist/skills/zon-ui/references/components/video-player.md +386 -0
- package/dist/skills/zon-ui/references/marketing.md +467 -0
- package/dist/skills/zon-ui/references/motion.md +455 -0
- package/dist/skills/zon-ui/references/recipes.md +1232 -0
- package/dist/skills/zon-ui/references/tokens.md +866 -0
- package/dist/sources/accordion.css +4 -0
- package/dist/sources/action-sheet.css +11 -0
- package/dist/sources/alert-dialog.css +6 -0
- package/dist/sources/alert.css +3 -0
- package/dist/sources/app-bar.css +14 -0
- package/dist/sources/ascii-field.css +3 -0
- package/dist/sources/aspect-ratio.css +3 -0
- package/dist/sources/audio-player.css +20 -0
- package/dist/sources/avatar.css +3 -0
- package/dist/sources/badge.css +3 -0
- package/dist/sources/bottom-nav.css +9 -0
- package/dist/sources/breadcrumb.css +14 -0
- package/dist/sources/button-group.css +3 -0
- package/dist/sources/button.css +9 -0
- package/dist/sources/calendar.css +13 -0
- package/dist/sources/card.css +3 -0
- package/dist/sources/carousel.css +11 -0
- package/dist/sources/chart.css +5 -0
- package/dist/sources/checkbox.css +6 -0
- package/dist/sources/code-block.css +13 -0
- package/dist/sources/collapsible.css +4 -0
- package/dist/sources/color-picker.css +13 -0
- package/dist/sources/combobox.css +13 -0
- package/dist/sources/command.css +13 -0
- package/dist/sources/context-menu.css +12 -0
- package/dist/sources/conversation.css +10 -0
- package/dist/sources/copy-button.css +10 -0
- package/dist/sources/data-table.css +27 -0
- package/dist/sources/date-picker.css +20 -0
- package/dist/sources/dialog.css +9 -0
- package/dist/sources/direction.css +2 -0
- package/dist/sources/drawer.css +9 -0
- package/dist/sources/drawing.css +5 -0
- package/dist/sources/empty.css +3 -0
- package/dist/sources/feature-list.css +4 -0
- package/dist/sources/field.css +4 -0
- package/dist/sources/file-drop.css +15 -0
- package/dist/sources/filter-bar.css +30 -0
- package/dist/sources/form.css +4 -0
- package/dist/sources/graph.css +19 -0
- package/dist/sources/illustration.css +28 -0
- package/dist/sources/input-group.css +7 -0
- package/dist/sources/input.css +3 -0
- package/dist/sources/item.css +4 -0
- package/dist/sources/kbd.css +5 -0
- package/dist/sources/label.css +3 -0
- package/dist/sources/layout.css +3 -0
- package/dist/sources/lightbox.css +33 -0
- package/dist/sources/locale.css +2 -0
- package/dist/sources/logo.css +4 -0
- package/dist/sources/markdown-editor.css +41 -0
- package/dist/sources/mentions.css +13 -0
- package/dist/sources/menu.css +11 -0
- package/dist/sources/menubar.css +14 -0
- package/dist/sources/message.css +16 -0
- package/dist/sources/meter.css +4 -0
- package/dist/sources/money-input.css +10 -0
- package/dist/sources/native-select.css +4 -0
- package/dist/sources/navigation-menu.css +8 -0
- package/dist/sources/number-field.css +8 -0
- package/dist/sources/number-roll.css +6 -0
- package/dist/sources/otp-field.css +5 -0
- package/dist/sources/pagination.css +11 -0
- package/dist/sources/pdf-viewer.css +30 -0
- package/dist/sources/phone-input.css +20 -0
- package/dist/sources/popover.css +7 -0
- package/dist/sources/preview-card.css +7 -0
- package/dist/sources/progress.css +4 -0
- package/dist/sources/prompt-input.css +15 -0
- package/dist/sources/pull-to-refresh.css +14 -0
- package/dist/sources/quote.css +3 -0
- package/dist/sources/radio-group.css +5 -0
- package/dist/sources/rating.css +6 -0
- package/dist/sources/reasoning.css +6 -0
- package/dist/sources/resizable.css +4 -0
- package/dist/sources/response.css +16 -0
- package/dist/sources/scheduler.css +44 -0
- package/dist/sources/scroll-area.css +3 -0
- package/dist/sources/select.css +12 -0
- package/dist/sources/separator.css +3 -0
- package/dist/sources/sidebar.css +19 -0
- package/dist/sources/site-header.css +15 -0
- package/dist/sources/skeleton.css +3 -0
- package/dist/sources/slider.css +6 -0
- package/dist/sources/sortable.css +12 -0
- package/dist/sources/sources.css +6 -0
- package/dist/sources/spinner.css +6 -0
- package/dist/sources/stat.css +9 -0
- package/dist/sources/stepper.css +6 -0
- package/dist/sources/suggestions.css +10 -0
- package/dist/sources/swipe-actions.css +20 -0
- package/dist/sources/switch.css +5 -0
- package/dist/sources/table.css +7 -0
- package/dist/sources/tabs.css +5 -0
- package/dist/sources/tag.css +3 -0
- package/dist/sources/tags-input.css +6 -0
- package/dist/sources/textarea.css +3 -0
- package/dist/sources/theme.css +13 -0
- package/dist/sources/time-field.css +7 -0
- package/dist/sources/timeline.css +7 -0
- package/dist/sources/tippy.css +6 -0
- package/dist/sources/toast.css +6 -0
- package/dist/sources/toggle-group.css +5 -0
- package/dist/sources/toggle.css +3 -0
- package/dist/sources/tool-call.css +16 -0
- package/dist/sources/toolbar.css +14 -0
- package/dist/sources/tooltip.css +6 -0
- package/dist/sources/tour.css +14 -0
- package/dist/sources/tree.css +6 -0
- package/dist/sources/typography.css +4 -0
- package/dist/sources/video-player.css +21 -0
- package/dist/styles/ai.css +3 -0
- package/dist/styles/brand.css +98 -0
- package/dist/styles/core.css +266 -0
- package/dist/styles/editor.css +3 -0
- package/dist/styles/expressive.css +75 -77
- package/dist/styles/fonts.css +61 -117
- package/dist/styles/graph.css +4 -0
- package/dist/styles/illustration.css +4 -0
- package/dist/styles/index.css +11 -193
- package/dist/styles/material.css +177 -31
- package/dist/styles/parts/ai.css +20 -14
- package/dist/styles/parts/brand.css +2 -2
- package/dist/styles/parts/controls.css +51 -38
- package/dist/styles/parts/data.css +43 -11
- package/dist/styles/parts/editor.css +372 -0
- package/dist/styles/parts/feedback.css +75 -15
- package/dist/styles/parts/foundations.css +12 -7
- package/dist/styles/parts/graph.css +25 -9
- package/dist/styles/parts/inputs.css +172 -9
- package/dist/styles/parts/isometric.css +6 -5
- package/dist/styles/parts/navigation.css +237 -25
- package/dist/styles/parts/overlays.css +110 -8
- package/dist/styles/parts/pdf.css +15 -9
- package/dist/styles/pdf.css +3 -0
- package/dist/styles/prose.css +3 -0
- package/dist/styles/tokens.css +105 -15
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +5 -0
- package/dist/vite.d.ts +48 -59
- package/dist/vite.js +54 -21
- package/package.json +69 -2
package/dist/components/graph.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { applyEdgeChanges, applyNodeChanges, Background, BackgroundVariant, BaseEdge, ConnectionLineType, EdgeLabelRenderer, getSmoothStepPath, getStraightPath, getViewportForBounds, Handle, MiniMap, Panel, Position, ReactFlow, ReactFlowProvider, useInternalNode, useReactFlow, } from "@xyflow/react";
|
|
4
|
-
import { ArrowLeftRightIcon, CircleDotIcon, MaximizeIcon, MinusIcon, PencilIcon, PlusIcon, Trash2Icon, WandSparklesIcon, } from "
|
|
4
|
+
import { ArrowLeftRightIcon, ArrowRightIcon, CircleDotIcon, MaximizeIcon, MinusIcon, PencilIcon, PlusIcon, Trash2Icon, WandSparklesIcon, } from "../lib/icons.js";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
|
-
import { cssDuration } from "../lib/motion.js";
|
|
7
|
+
import { cssDuration, cssEase } from "../lib/motion.js";
|
|
8
|
+
import { useShortcutKeys } from "../lib/platform.js";
|
|
8
9
|
import { LANE_HEADER, lanes, layered, network, dragSimulation, } from "../lib/graph-layout.js";
|
|
9
10
|
import { Avatar } from "./avatar.js";
|
|
10
11
|
import { useMessages } from "./locale.js";
|
|
11
|
-
import { ContextMenu, ContextMenuContent, ContextMenuGroup, ContextMenuGroupLabel, ContextMenuItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuTrigger, } from "./context-menu.js";
|
|
12
|
+
import { ContextMenu, ContextMenuContent, ContextMenuGroup, ContextMenuGroupLabel, ContextMenuItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from "./context-menu.js";
|
|
12
13
|
import { Toolbar, ToolbarButton, ToolbarGroup, ToolbarSeparator } from "./toolbar.js";
|
|
13
14
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
14
15
|
/** Networks of up to this many nodes settle live around a dragged node. */
|
|
15
16
|
const LIVE_DRAG_MAX = 300;
|
|
17
|
+
/** One d3-force tick: the simulation is tuned for one per frame at 60Hz. */
|
|
18
|
+
const TICK_MS = 1000 / 60;
|
|
16
19
|
const newNodes = {
|
|
17
20
|
task: "New step",
|
|
18
21
|
start: "Start",
|
|
@@ -52,6 +55,7 @@ const defaultMessages = {
|
|
|
52
55
|
addLabel: "Add a label",
|
|
53
56
|
reverse: "Reverse direction",
|
|
54
57
|
removeConnection: "Remove connection",
|
|
58
|
+
connectTo: "Connect to",
|
|
55
59
|
enterKey: "Enter",
|
|
56
60
|
deleteKey: "Del",
|
|
57
61
|
connection: (from, to, directed) => `${from} ${directed ? "to" : "and"} ${to}`,
|
|
@@ -62,6 +66,9 @@ const defaultMessages = {
|
|
|
62
66
|
edgeHelp: "Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.",
|
|
63
67
|
handle: "Handle",
|
|
64
68
|
moved: (direction, x, y) => `Moved selected node ${direction}. New position, x: ${x}, y: ${y}`,
|
|
69
|
+
touchHint: "Use two fingers to move the graph",
|
|
70
|
+
empty: "Nothing to show yet.",
|
|
71
|
+
emptyEditable: "Nothing here yet. Add a node to start.",
|
|
65
72
|
};
|
|
66
73
|
const GraphContext = React.createContext(null);
|
|
67
74
|
const useGraph = () => React.useContext(GraphContext);
|
|
@@ -251,15 +258,15 @@ function NodeView({ id, data }) {
|
|
|
251
258
|
const state = { "data-dim": data.dim ? "" : undefined, "data-lit": data.lit ? "" : undefined };
|
|
252
259
|
// Shapes whose name sits under them: events and gateways.
|
|
253
260
|
if (kind === "start" || kind === "end" || kind === "event" || kind === "gateway") {
|
|
254
|
-
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": kind, ...state, className: "relative size-full", children: [_jsx(Handles, {}), _jsx("div", { "data-slot": "graph-shape", className: "grid size-full place-items-center", children: kind === "gateway" && (_jsx("span", { className: "font-mono text-
|
|
261
|
+
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": kind, ...state, className: "relative size-full", children: [_jsx(Handles, {}), _jsx("div", { "data-slot": "graph-shape", className: "grid size-full place-items-center", children: kind === "gateway" && (_jsx("span", { className: "font-mono text-18 leading-none text-foreground", children: glyph[n.gateway ?? "exclusive"] })) }), _jsx("div", { className: "pointer-events-none absolute top-full left-1/2 mt-2 w-max max-w-40 -translate-x-1/2 text-center font-mono text-11 leading-tight text-muted-foreground", children: _jsx(Label, { kind: "node", id: id, value: n.label, className: "pointer-events-auto" }) })] }));
|
|
255
262
|
}
|
|
256
263
|
if (kind === "note") {
|
|
257
|
-
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": "note", ...state, className: "flex size-full items-center ps-3 text-
|
|
264
|
+
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": "note", ...state, className: "flex size-full items-center ps-3 text-13 leading-snug text-muted-foreground", children: [_jsx(Handles, {}), _jsx(Label, { kind: "node", id: id, value: n.label, className: "line-clamp-2 whitespace-normal" })] }));
|
|
258
265
|
}
|
|
259
266
|
if (kind === "person") {
|
|
260
|
-
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": "person", ...state, className: "flex size-full flex-col items-center gap-1.5 pt-1 text-center", children: [_jsx(Handles, {}), _jsx(Avatar, { "data-slot": "graph-avatar", src: n.image, name: n.label, size: "lg" }), _jsxs("div", { className: "flex w-full min-w-0 flex-col items-center gap-0.5", children: [_jsx(Label, { kind: "node", id: id, value: n.label, className: "max-w-full text-
|
|
267
|
+
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": "person", ...state, className: "flex size-full flex-col items-center gap-1.5 pt-1 text-center", children: [_jsx(Handles, {}), _jsx(Avatar, { "data-slot": "graph-avatar", src: n.image, name: n.label, size: "lg" }), _jsxs("div", { className: "flex w-full min-w-0 flex-col items-center gap-0.5", children: [_jsx(Label, { kind: "node", id: id, value: n.label, className: "max-w-full text-13 font-medium text-foreground" }), n.meta && (_jsx("span", { className: "max-w-full truncate font-mono text-11 text-muted-foreground", children: n.meta }))] })] }));
|
|
261
268
|
}
|
|
262
|
-
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": kind, ...state, className: cn("flex size-full min-w-0 items-center gap-2.5 material-raised text-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground", kind === "entity" ? "rounded-full px-3.5 text-
|
|
269
|
+
return (_jsxs("div", { "data-slot": "graph-node", "data-kind": kind, ...state, className: cn("flex size-full min-w-0 items-center gap-2.5 material-raised text-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:text-muted-foreground", kind === "entity" ? "rounded-full px-3.5 text-13" : "rounded-button px-3.5 text-14"), children: [_jsx(Handles, {}), n.icon, _jsxs("div", { className: "flex min-w-0 flex-col", children: [_jsx(Label, { kind: "node", id: id, value: n.label, className: "leading-tight" }), n.meta && kind === "task" && (_jsx("span", { className: "mt-1 truncate font-mono text-11 leading-normal text-muted-foreground", children: n.meta }))] })] }));
|
|
263
270
|
}
|
|
264
271
|
function GroupView({ id, data }) {
|
|
265
272
|
// A swimlane: a band with its name in a strip at the start, set along the flow.
|
|
@@ -429,7 +436,16 @@ const edgeTypes = { zon: EdgeView };
|
|
|
429
436
|
export function Graph(props) {
|
|
430
437
|
return (_jsx(ReactFlowProvider, { children: _jsx(GraphCanvas, { ...props }) }));
|
|
431
438
|
}
|
|
432
|
-
|
|
439
|
+
/** Under this frame width (px) a flow with no `direction` reads down and the minimap is left out. */
|
|
440
|
+
const NARROW_FRAME = 480;
|
|
441
|
+
/**
|
|
442
|
+
* How "fit" frames the graph: a margin all round, and room at the bottom for the controls, which
|
|
443
|
+
* float over the canvas there — a tall graph fitted by its height would end under them.
|
|
444
|
+
*/
|
|
445
|
+
const fitWithControls = { padding: { top: 0.18, x: 0.18, bottom: "84px" }, maxZoom: 1.15 };
|
|
446
|
+
const fitBare = { padding: 0.18, maxZoom: 1.15 };
|
|
447
|
+
const fitFrame = (controls) => (controls ? fitWithControls : fitBare);
|
|
448
|
+
function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", direction: directionProp, editable = false, onChange, onSelect, newNodeKind, minimap = false, controls = true, background = "dots", variant = "region", emptyMessage, labels, className, ...props }) {
|
|
433
449
|
const text = useMessages("graph", defaultMessages, labels);
|
|
434
450
|
const textRef = React.useRef(text);
|
|
435
451
|
textRef.current = text;
|
|
@@ -440,22 +456,95 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
440
456
|
"handle.ariaLabel": text.handle,
|
|
441
457
|
"minimap.ariaLabel": text.minimap,
|
|
442
458
|
}), [text]);
|
|
443
|
-
const
|
|
459
|
+
const frame = React.useRef(null);
|
|
460
|
+
// A narrow frame, as on a phone. There a flow without a direction of its own reads down — laid
|
|
461
|
+
// out to the right it would be a thin strip, too small to read when it fits and cut off when
|
|
462
|
+
// not — and the minimap stays out of the way of the controls it would cover.
|
|
463
|
+
const [narrow, setNarrow] = React.useState(false);
|
|
464
|
+
React.useLayoutEffect(() => {
|
|
465
|
+
const el = frame.current;
|
|
466
|
+
if (!el || typeof ResizeObserver === "undefined")
|
|
467
|
+
return;
|
|
468
|
+
const measure = (width) => setNarrow(width > 0 && width < NARROW_FRAME);
|
|
469
|
+
measure(el.getBoundingClientRect().width);
|
|
470
|
+
const observer = new ResizeObserver(() => measure(el.getBoundingClientRect().width));
|
|
471
|
+
observer.observe(el);
|
|
472
|
+
return () => observer.disconnect();
|
|
473
|
+
}, []);
|
|
474
|
+
// On a touch-only device the graph lets the page scroll, as a map does: one finger scrolls the
|
|
475
|
+
// page, two fingers pan and pinch the graph. A graph is most of a phone's screen; panning on one
|
|
476
|
+
// finger would leave the page little to scroll by. Editable, one finger still drags a node.
|
|
477
|
+
const touchOnly = !useShortcutKeys().hasKeyboard;
|
|
478
|
+
const [touchHint, setTouchHint] = React.useState(false);
|
|
479
|
+
React.useEffect(() => {
|
|
480
|
+
const el = frame.current;
|
|
481
|
+
if (!el || !touchOnly)
|
|
482
|
+
return;
|
|
483
|
+
let from = null;
|
|
484
|
+
let timer;
|
|
485
|
+
// React Flow does not pan from a touch inside `.nopan`: the frame wears it while one finger is
|
|
486
|
+
// down and drops it as a second lands, so a two-finger gesture pans and zooms.
|
|
487
|
+
const start = (event) => {
|
|
488
|
+
const target = event.target;
|
|
489
|
+
const own = target.closest(".react-flow__panel, .react-flow__minimap");
|
|
490
|
+
const drags = editable && target.closest(".react-flow__node, .react-flow__handle");
|
|
491
|
+
if (event.touches.length === 1 && !own && !drags) {
|
|
492
|
+
el.classList.add("nopan");
|
|
493
|
+
from = { x: event.touches[0].clientX, y: event.touches[0].clientY };
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
el.classList.remove("nopan");
|
|
497
|
+
from = null;
|
|
498
|
+
setTouchHint(false);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
const move = (event) => {
|
|
502
|
+
const t = event.touches[0];
|
|
503
|
+
if (!from || !t || event.touches.length > 1)
|
|
504
|
+
return;
|
|
505
|
+
if (Math.hypot(t.clientX - from.x, t.clientY - from.y) < 10)
|
|
506
|
+
return;
|
|
507
|
+
from = null;
|
|
508
|
+
setTouchHint(true);
|
|
509
|
+
clearTimeout(timer);
|
|
510
|
+
timer = setTimeout(() => setTouchHint(false), 1600);
|
|
511
|
+
};
|
|
512
|
+
const end = (event) => {
|
|
513
|
+
if (event.touches.length)
|
|
514
|
+
return;
|
|
515
|
+
el.classList.remove("nopan");
|
|
516
|
+
from = null;
|
|
517
|
+
};
|
|
518
|
+
const options = { capture: true, passive: true };
|
|
519
|
+
el.addEventListener("touchstart", start, options);
|
|
520
|
+
el.addEventListener("touchmove", move, options);
|
|
521
|
+
el.addEventListener("touchend", end, options);
|
|
522
|
+
el.addEventListener("touchcancel", end, options);
|
|
523
|
+
return () => {
|
|
524
|
+
clearTimeout(timer);
|
|
525
|
+
el.classList.remove("nopan");
|
|
526
|
+
el.removeEventListener("touchstart", start, options);
|
|
527
|
+
el.removeEventListener("touchmove", move, options);
|
|
528
|
+
el.removeEventListener("touchend", end, options);
|
|
529
|
+
el.removeEventListener("touchcancel", end, options);
|
|
530
|
+
};
|
|
531
|
+
}, [touchOnly, editable]);
|
|
532
|
+
const direction = directionProp ?? (layout === "tree" || (layout === "flow" && narrow) ? "down" : "right");
|
|
444
533
|
const flow = useReactFlow();
|
|
445
534
|
const markers = React.useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
446
|
-
const frame = React.useRef(null);
|
|
447
535
|
const describedBy = `${markers}-connections`;
|
|
448
536
|
const [state, setState] = React.useState(() => build({ nodes: nodesProp, edges: edgesProp }, layout, direction));
|
|
449
537
|
const latest = React.useRef(state);
|
|
450
538
|
latest.current = state;
|
|
451
539
|
// The value last sent out: when it comes back as props, it is not laid out again.
|
|
452
540
|
const sent = React.useRef(null);
|
|
453
|
-
|
|
541
|
+
// Before paint: a flow that turns down in a narrow frame is never drawn the other way first.
|
|
542
|
+
React.useLayoutEffect(() => {
|
|
454
543
|
if (sent.current && sent.current.nodes === nodesProp && sent.current.edges === edgesProp)
|
|
455
544
|
return;
|
|
456
545
|
setState(build({ nodes: nodesProp, edges: edgesProp }, layout, direction));
|
|
457
|
-
requestAnimationFrame(() => void flow.fitView({
|
|
458
|
-
}, [nodesProp, edgesProp, layout, direction, flow]);
|
|
546
|
+
requestAnimationFrame(() => void flow.fitView({ ...fitFrame(controls), duration: 0 }));
|
|
547
|
+
}, [nodesProp, edgesProp, layout, direction, flow, controls]);
|
|
459
548
|
const emit = React.useCallback((next) => {
|
|
460
549
|
if (!onChange)
|
|
461
550
|
return;
|
|
@@ -609,9 +698,10 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
609
698
|
const value = toValue(from.nodes, from.edges);
|
|
610
699
|
const next = build({ nodes: value.nodes.map(({ position: _p, size: _s, ...n }) => n), edges: value.edges }, layout, direction);
|
|
611
700
|
const el = frame.current;
|
|
612
|
-
|
|
701
|
+
// Twice --duration: a move the interface makes on its own, ended within 300ms.
|
|
702
|
+
const duration = el ? cssDuration(el) * 2 : 0;
|
|
613
703
|
// Without motion (reduced motion) the camera jumps too.
|
|
614
|
-
const fit = () => requestAnimationFrame(() => void flow.fitView({
|
|
704
|
+
const fit = () => requestAnimationFrame(() => void flow.fitView({ ...fitFrame(controls), duration }));
|
|
615
705
|
if (!el || !duration) {
|
|
616
706
|
setState(next);
|
|
617
707
|
emit(next);
|
|
@@ -625,7 +715,8 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
625
715
|
const camera1 = pane
|
|
626
716
|
? getViewportForBounds(boxAround(next.nodes.filter((n) => !n.parentId)), pane.clientWidth, pane.clientHeight, 0.2, 1.15, 0.18)
|
|
627
717
|
: null;
|
|
628
|
-
|
|
718
|
+
// The interface moves the nodes from A to B on its own: ease in and out.
|
|
719
|
+
const ease = cssEase("--ease-move", el);
|
|
629
720
|
// No keyframes: the animation only keeps the clock; its progress places the nodes.
|
|
630
721
|
const clock = el.animate([], { duration, easing: ease });
|
|
631
722
|
let raf = 0;
|
|
@@ -672,7 +763,7 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
672
763
|
emit(latest.current);
|
|
673
764
|
},
|
|
674
765
|
};
|
|
675
|
-
}, [direction, emit, flow, layout]);
|
|
766
|
+
}, [controls, direction, emit, flow, layout]);
|
|
676
767
|
/* Networks: a dragged node pulls its neighbours along, and the rest settles around it. */
|
|
677
768
|
const physics = React.useRef(null);
|
|
678
769
|
const reduce = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
@@ -699,8 +790,21 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
699
790
|
const sizes = new Map(s.nodes.map((n) => [n.id, { w: n.width ?? 0, h: n.height ?? 0 }]));
|
|
700
791
|
const byId = new Map(sim.map((d) => [d.id, d]));
|
|
701
792
|
const held = new Set([node.id]);
|
|
702
|
-
|
|
703
|
-
|
|
793
|
+
// d3-force is tuned for one tick per 60Hz frame: tick by the time that has passed, so a
|
|
794
|
+
// 120Hz screen does not settle twice as fast and a dropped frame does not stall it.
|
|
795
|
+
let last = 0;
|
|
796
|
+
let owed = 0;
|
|
797
|
+
const step = (now) => {
|
|
798
|
+
owed += last ? Math.min(now - last, 50) / TICK_MS : 1;
|
|
799
|
+
last = now;
|
|
800
|
+
// One to three ticks a frame; time beyond that (a long stall) is dropped, not caught up.
|
|
801
|
+
const ticks = Math.min(3, Math.floor(owed));
|
|
802
|
+
owed = ticks === 3 ? 0 : owed - ticks;
|
|
803
|
+
if (!ticks) {
|
|
804
|
+
frame = requestAnimationFrame(step);
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
simulation.tick(ticks);
|
|
704
808
|
setState((prev) => {
|
|
705
809
|
const next = {
|
|
706
810
|
...prev,
|
|
@@ -785,6 +889,44 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
785
889
|
else
|
|
786
890
|
setTarget({ type: "pane", at: flow.screenToFlowPosition({ x: event.clientX, y: event.clientY }) });
|
|
787
891
|
};
|
|
892
|
+
/*
|
|
893
|
+
* Moving around from the keyboard, while the focus is on a node, a connection or the canvas
|
|
894
|
+
* (not the controls, the map or a label being edited): the arrows pan the view — 40px, or
|
|
895
|
+
* 160px with Shift — and + and − zoom it. Where a node can move (`editable`) and the focused
|
|
896
|
+
* node is selected, the arrows are React Flow's and move the selection, so the two never clash.
|
|
897
|
+
* Without `editable` the arrows never move a node.
|
|
898
|
+
*/
|
|
899
|
+
const onCanvasKey = (event) => {
|
|
900
|
+
if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey)
|
|
901
|
+
return;
|
|
902
|
+
const el = event.target;
|
|
903
|
+
if (el.closest("input, textarea, [contenteditable], .react-flow__panel, .react-flow__minimap"))
|
|
904
|
+
return;
|
|
905
|
+
if (!el.closest(".react-flow") && el !== event.currentTarget)
|
|
906
|
+
return;
|
|
907
|
+
const pan = { ArrowLeft: [1, 0], ArrowRight: [-1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] }[event.key];
|
|
908
|
+
if (pan) {
|
|
909
|
+
const moving = editable &&
|
|
910
|
+
(el.closest(".react-flow__nodesselection") ||
|
|
911
|
+
el.closest(".react-flow__node")?.classList.contains("selected"));
|
|
912
|
+
if (moving)
|
|
913
|
+
return;
|
|
914
|
+
event.preventDefault();
|
|
915
|
+
// Before React Flow's own handler on the node, which would move it.
|
|
916
|
+
event.stopPropagation();
|
|
917
|
+
const step = event.shiftKey ? 160 : 40;
|
|
918
|
+
const { x, y, zoom } = flow.getViewport();
|
|
919
|
+
void flow.setViewport({ x: x + pan[0] * step, y: y + pan[1] * step, zoom });
|
|
920
|
+
}
|
|
921
|
+
else if (event.key === "+" || event.key === "=") {
|
|
922
|
+
event.preventDefault();
|
|
923
|
+
void flow.zoomIn();
|
|
924
|
+
}
|
|
925
|
+
else if (event.key === "-" || event.key === "_") {
|
|
926
|
+
event.preventDefault();
|
|
927
|
+
void flow.zoomOut();
|
|
928
|
+
}
|
|
929
|
+
};
|
|
788
930
|
const removeNode = (id) => onNodesChange([{ type: "remove", id }]);
|
|
789
931
|
const removeEdge = (id) => onEdgesChange([{ type: "remove", id }]);
|
|
790
932
|
const reverse = (id) => {
|
|
@@ -804,22 +946,42 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
804
946
|
emit(next);
|
|
805
947
|
};
|
|
806
948
|
const targetEdge = target?.type === "edge" ? state.edges.find((e) => e.id === target.id) : undefined;
|
|
949
|
+
// The nodes the targeted node can be connected to: every other node it isn't yet connected to.
|
|
950
|
+
const connectable = target?.type === "node"
|
|
951
|
+
? state.nodes.filter((n) => n.type !== "zon-group" &&
|
|
952
|
+
n.id !== target.id &&
|
|
953
|
+
!state.edges.some((e) => (e.source === target.id && e.target === n.id) ||
|
|
954
|
+
(e.source === n.id && e.target === target.id)))
|
|
955
|
+
: [];
|
|
807
956
|
const stepped = layout === "flow" || layout === "tree";
|
|
808
957
|
const nodeLabels = React.useMemo(() => new Map(state.nodes.map((n) => [n.id, n.data.node.label])), [state.nodes]);
|
|
809
|
-
const canvas = (_jsxs(ReactFlow, { nodes: shown.nodes, edges: shown.edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: editable ? onConnect : undefined, onConnectEnd: editable ? onConnectEnd : undefined, onNodeMouseEnter: (_, n) => n.type !== "zon-group" && setHovered(n.id), onNodeMouseLeave: () => setHovered(null), onNodeDragStart: onNodeDragStart, onNodeDrag: onNodeDrag, onNodeDragStop: onNodeDragStop, onSelectionChange: onSelectionChange, nodesConnectable: editable, edgesReconnectable: false, deleteKeyCode: editable ? ["Backspace", "Delete"] : null, connectionLineType: stepped ? ConnectionLineType.SmoothStep : ConnectionLineType.Straight, fitView: true, fitViewOptions:
|
|
810
|
-
return (_jsx(GraphContext.Provider, { value: context, children: _jsxs("div", { ref: frame, "data-slot": "graph", "data-layout": layout, "data-editable": editable ? "" : undefined, className: cn("relative h-[min(40rem,80svh)] w-full overflow-hidden", variant === "card" ? "surface-card [--card-padding:0]" : "surface-container", className), onKeyDown: (event) => {
|
|
811
|
-
// Editable: Enter on a focused node opens its label.
|
|
812
|
-
|
|
813
|
-
if (!editable || event.key !== "Enter" || !node?.dataset.id || editing)
|
|
958
|
+
const canvas = (_jsxs(ReactFlow, { nodes: shown.nodes, edges: shown.edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onConnect: editable ? onConnect : undefined, onConnectEnd: editable ? onConnectEnd : undefined, onNodeMouseEnter: (_, n) => n.type !== "zon-group" && setHovered(n.id), onNodeMouseLeave: () => setHovered(null), onNodeDragStart: onNodeDragStart, onNodeDrag: onNodeDrag, onNodeDragStop: onNodeDragStop, onSelectionChange: onSelectionChange, nodesConnectable: editable, nodesDraggable: editable || !touchOnly, edgesReconnectable: false, deleteKeyCode: editable ? ["Backspace", "Delete"] : null, connectionLineType: stepped ? ConnectionLineType.SmoothStep : ConnectionLineType.Straight, fitView: true, fitViewOptions: fitFrame(controls), minZoom: 0.2, maxZoom: 2, proOptions: { hideAttribution: true }, ariaLabelConfig: ariaLabelConfig, "aria-describedby": describedBy, children: [background !== "none" && (_jsx(Background, { variant: background === "lines" ? BackgroundVariant.Lines : BackgroundVariant.Dots, gap: background === "lines" ? 32 : 20, size: 1 })), minimap && !narrow && (_jsx(MiniMap, { position: "bottom-right", style: { width: 152, height: 100 }, pannable: true, zoomable: true, nodeBorderRadius: 4, ariaLabel: text.minimap })), controls && (_jsx(Panel, { position: "bottom-left", children: _jsx(GraphControls, { text: text, editable: editable, tidy: layout === "none" ? undefined : tidy, add: () => addNode() }) }))] }));
|
|
959
|
+
return (_jsx(GraphContext.Provider, { value: context, children: _jsxs("div", { ref: frame, "data-slot": "graph", "data-layout": layout, "data-editable": editable ? "" : undefined, "data-touch": touchOnly ? "" : undefined, "data-empty": state.nodes.length === 0 ? "" : undefined, className: cn("relative h-[min(40rem,80svh)] w-full overflow-hidden", variant === "card" ? "surface-card [--card-padding:0]" : "surface-container", className), onKeyDownCapture: onCanvasKey, onKeyDown: (event) => {
|
|
960
|
+
// Editable: Enter on a focused node or connection opens its label.
|
|
961
|
+
if (!editable || event.key !== "Enter" || editing)
|
|
814
962
|
return;
|
|
815
|
-
event.
|
|
816
|
-
|
|
817
|
-
|
|
963
|
+
const el = event.target;
|
|
964
|
+
const node = el.closest(".react-flow__node");
|
|
965
|
+
const edge = el.closest(".react-flow__edge");
|
|
966
|
+
if (node?.dataset.id) {
|
|
967
|
+
event.preventDefault();
|
|
968
|
+
setEditing({ kind: "node", id: node.dataset.id });
|
|
969
|
+
}
|
|
970
|
+
else if (edge?.dataset.id) {
|
|
971
|
+
event.preventDefault();
|
|
972
|
+
setEditing({ kind: "edge", id: edge.dataset.id });
|
|
973
|
+
}
|
|
974
|
+
}, ...props, children: [_jsx("svg", { "aria-hidden": true, className: "absolute size-0", children: _jsx("defs", { children: ["rest", "lit"].map((tone) => (_jsx("marker", { id: `${markers}-${tone}`, viewBox: "0 0 10 10", refX: "9", refY: "5", markerWidth: "7", markerHeight: "7", orient: "auto-start-reverse", children: _jsx("path", { d: "M1 1.5 L9 5 L1 8.5 Z", "data-tone": tone, className: "zon-graph-arrow" }) }, tone))) }) }), touchOnly && (_jsx("div", { "aria-hidden": true, "data-slot": "graph-touch-hint", "data-shown": touchHint ? "" : undefined, className: "pointer-events-none absolute inset-x-4 top-1/2 z-10 flex -translate-y-1/2 justify-center opacity-0 transition-opacity duration-(--duration-fade) ease-(--ease) data-shown:opacity-100", children: _jsx("p", { className: "rounded-button material-menu px-3 py-2 text-center text-sm text-foreground", children: text.touchHint }) })), editable ? (_jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { className: "absolute inset-0", onContextMenuCapture: pick, children: canvas }), _jsxs(ContextMenuContent, { children: [target?.type === "pane" && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuGroup, { children: [_jsx(ContextMenuGroupLabel, { children: text.addHere }), addable[layout].map((kind) => (_jsxs(ContextMenuItem, { onClick: () => addNode(target.at, kind), children: [_jsx(PlusIcon, {}), text.kind(kind)] }, kind)))] }), _jsx(ContextMenuSeparator, {}), layout !== "none" && (_jsxs(ContextMenuItem, { onClick: tidy, children: [_jsx(WandSparklesIcon, {}), text.tidy] })), _jsxs(ContextMenuItem, { onClick: () => void flow.fitView({ ...fitFrame(controls), duration: cssDuration() * 2 }), children: [_jsx(MaximizeIcon, {}), text.fit] })] })), (target?.type === "node" || target?.type === "group") && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuItem, { onClick: () => setEditing({ kind: "node", id: target.id }), children: [_jsx(PencilIcon, {}), text.rename, _jsx(ContextMenuShortcut, { children: text.enterKey })] }), target.type === "node" && connectable.length > 0 && (_jsxs(ContextMenuSub, { children: [_jsxs(ContextMenuSubTrigger, { children: [_jsx(ArrowRightIcon, { className: "rtl:-scale-x-100" }), text.connectTo] }), _jsx(ContextMenuSubContent, { children: connectable.map((n) => (_jsx(ContextMenuItem, { onClick: () => onConnect({
|
|
975
|
+
source: target.id,
|
|
976
|
+
target: n.id,
|
|
977
|
+
sourceHandle: null,
|
|
978
|
+
targetHandle: null,
|
|
979
|
+
}), children: n.data.node.label }, n.id))) })] })), target.type === "node" && (_jsxs(_Fragment, { children: [_jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { variant: "destructive", onClick: () => removeNode(target.id), children: [_jsx(Trash2Icon, {}), text.delete, _jsx(ContextMenuShortcut, { children: text.deleteKey })] })] }))] })), target?.type === "edge" && (_jsxs(_Fragment, { children: [_jsxs(ContextMenuItem, { onClick: () => setEditing({ kind: "edge", id: target.id }), children: [_jsx(PencilIcon, {}), targetEdge?.data?.edge.label ? text.renameLabel : text.addLabel] }), targetEdge && isDirected(targetEdge.data.edge, layout) && (_jsxs(ContextMenuItem, { onClick: () => reverse(target.id), children: [_jsx(ArrowLeftRightIcon, {}), text.reverse] })), _jsx(ContextMenuSeparator, {}), _jsxs(ContextMenuItem, { variant: "destructive", onClick: () => removeEdge(target.id), children: [_jsx(Trash2Icon, {}), text.removeConnection, _jsx(ContextMenuShortcut, { children: text.deleteKey })] })] }))] })] })) : (canvas), state.nodes.length === 0 && (_jsx("div", { "data-slot": "graph-empty", className: "pointer-events-none absolute inset-x-6 top-1/2 z-5 flex -translate-y-1/2 justify-center", children: _jsx("p", { className: "m-0 max-w-sm text-center text-sm text-balance text-muted-foreground", children: emptyMessage ?? (editable ? text.emptyEditable : text.empty) }) })), _jsx("ul", { id: describedBy, className: "sr-only", children: state.edges.map((e) => (_jsxs("li", { children: [text.connection(nodeLabels.get(e.source) ?? e.source, nodeLabels.get(e.target) ?? e.target, isDirected(e.data.edge, layout)), e.data.edge.label ? `: ${e.data.edge.label}` : ""] }, e.id))) })] }) }));
|
|
818
980
|
}
|
|
819
981
|
function ControlButton({ label, onClick, children, }) {
|
|
820
982
|
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(ToolbarButton, { "aria-label": label, onClick: onClick }), children: children }), _jsx(TooltipContent, { side: "top", children: label })] }));
|
|
821
983
|
}
|
|
822
984
|
function GraphControls({ text, editable, tidy, add, }) {
|
|
823
985
|
const flow = useReactFlow();
|
|
824
|
-
return (_jsxs(Toolbar, { "aria-label": text.controls, "data-slot": "graph-controls", children: [_jsxs(ToolbarGroup, { children: [_jsx(ControlButton, { label: text.zoomIn, onClick: () => void flow.zoomIn({ duration:
|
|
986
|
+
return (_jsxs(Toolbar, { "aria-label": text.controls, "data-slot": "graph-controls", children: [_jsxs(ToolbarGroup, { children: [_jsx(ControlButton, { label: text.zoomIn, onClick: () => void flow.zoomIn({ duration: cssDuration() * 2 }), children: _jsx(PlusIcon, {}) }), _jsx(ControlButton, { label: text.zoomOut, onClick: () => void flow.zoomOut({ duration: cssDuration() * 2 }), children: _jsx(MinusIcon, {}) }), _jsx(ControlButton, { label: text.fit, onClick: () => void flow.fitView({ ...fitFrame(true), duration: cssDuration() * 2 }), children: _jsx(MaximizeIcon, {}) })] }), (editable || tidy) && _jsx(ToolbarSeparator, {}), _jsxs(ToolbarGroup, { children: [editable && (_jsx(ControlButton, { label: text.addNode, onClick: add, children: _jsx(CircleDotIcon, {}) })), tidy && (_jsx(ControlButton, { label: text.tidy, onClick: tidy, children: _jsx(WandSparklesIcon, {}) }))] })] }));
|
|
825
987
|
}
|
|
@@ -3,9 +3,9 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { editorialSource } from "../lib/editorial-assets.js";
|
|
6
|
-
import { INLINE_INK } from "../lib/illustration-drawings.js";
|
|
7
6
|
import { getIllustration, } from "../lib/illustration-library.js";
|
|
8
7
|
import { mountFigure } from "../lib/figure/kernel.js";
|
|
8
|
+
import { DrawingSvg as DrawingSvgBase } from "./_drawing-svg.js";
|
|
9
9
|
/* ── Metadata ───────────────────────────────────────────────────────────────── */
|
|
10
10
|
export { illustrationKinds, illustrations } from "../lib/illustration-info.js";
|
|
11
11
|
/**
|
|
@@ -60,33 +60,8 @@ function IsoFigure({ entry, animate, active, title, className, style, }) {
|
|
|
60
60
|
return (_jsx("svg", { ref: ref, "data-slot": "illustration", "data-kind": "iso", "data-name": entry.id, "data-static": animate ? undefined : "", "data-active": active ? "" : undefined, viewBox: "0 0 400 320", fill: "none", role: title ? "img" : undefined, "aria-label": title, "aria-hidden": title ? undefined : true, focusable: "false", className: cn("block aspect-[5/4] h-auto w-full max-w-full overflow-visible select-none", className), style: style }));
|
|
61
61
|
}
|
|
62
62
|
/* ── Drawings ───────────────────────────────────────────────────────────────── */
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
: /^(data|aria)-/.test(k)
|
|
66
|
-
? k
|
|
67
|
-
: k.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
68
|
-
function toReact(node, key) {
|
|
69
|
-
if (!node)
|
|
70
|
-
return null;
|
|
71
|
-
if (typeof node === "string")
|
|
72
|
-
return node;
|
|
73
|
-
if (Array.isArray(node))
|
|
74
|
-
return node.map((c, i) => toReact(c, i));
|
|
75
|
-
const props = { key };
|
|
76
|
-
for (const [k, v] of Object.entries(node.attrs)) {
|
|
77
|
-
if (v === undefined || v === null || v === false)
|
|
78
|
-
continue;
|
|
79
|
-
props[reactAttr(k)] = v;
|
|
80
|
-
}
|
|
81
|
-
return React.createElement(node.tag, props, ...node.children.map((c, i) => toReact(c, i)));
|
|
82
|
-
}
|
|
83
|
-
function useUid(prefix) {
|
|
84
|
-
return prefix + React.useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
85
|
-
}
|
|
86
|
-
function DrawingSvg({ entry, variant, title, className, style, }) {
|
|
87
|
-
const uid = useUid(`ep-${entry.name}`);
|
|
88
|
-
const d = entry.draw({ uid, ink: INLINE_INK, variant });
|
|
89
|
-
return (_jsxs("svg", { "data-slot": "illustration", "data-kind": entry.kind, "data-name": entry.id, "data-variant": variant, viewBox: d.viewBox, preserveAspectRatio: d.preserveAspectRatio ?? "xMidYMid meet", fill: "none", role: title ? "img" : undefined, "aria-label": title, "aria-hidden": title ? undefined : true, focusable: "false", className: cn("block h-auto max-h-full w-full select-none", className), style: style, children: [title && _jsx("title", { children: title }), d.body.map((c, i) => toReact(c, i))] }));
|
|
63
|
+
function DrawingSvg({ entry, variant, ...props }) {
|
|
64
|
+
return _jsx(DrawingSvgBase, { name: entry.name, draw: entry.draw, variant: variant, ...props });
|
|
90
65
|
}
|
|
91
66
|
/* ── Sheets ─────────────────────────────────────────────────────────────────── */
|
|
92
67
|
function SheetFigure({ entry, title, className, style }) {
|
|
@@ -114,20 +89,67 @@ function EditorialImage({ entry, priority, title, className, style, }) {
|
|
|
114
89
|
function CornerMark({ className }) {
|
|
115
90
|
return (_jsx("svg", { "aria-hidden": true, focusable: "false", viewBox: "0 0 13 13", className: cn("pointer-events-none absolute z-3 size-[13px] text-(--sheet-mark)", className), children: _jsx("path", { d: "M6.5 0v13M0 6.5h13", stroke: "currentColor", strokeWidth: "1", shapeRendering: "crispEdges" }) }));
|
|
116
91
|
}
|
|
92
|
+
const sheetLights = new WeakMap();
|
|
93
|
+
/**
|
|
94
|
+
* One frame of a sheet's light: read the pointer against the sheet once, however many moves came
|
|
95
|
+
* in, and close most of the way to it by the time since the last frame — the same at any refresh
|
|
96
|
+
* rate. It eases after the pointer like a light, rather than sticking to it like a cursor, and
|
|
97
|
+
* stops once it is there.
|
|
98
|
+
*/
|
|
99
|
+
function stepLight(el, now) {
|
|
100
|
+
const l = sheetLights.get(el);
|
|
101
|
+
if (!l)
|
|
102
|
+
return;
|
|
103
|
+
const rect = el.getBoundingClientRect();
|
|
104
|
+
const tx = rect.width ? ((l.cx - rect.left) / rect.width) * 100 : 0;
|
|
105
|
+
const ty = rect.height ? ((l.cy - rect.top) / rect.height) * 100 : 0;
|
|
106
|
+
if (!l.placed) {
|
|
107
|
+
l.placed = true;
|
|
108
|
+
l.x = tx;
|
|
109
|
+
l.y = ty;
|
|
110
|
+
}
|
|
111
|
+
const dt = l.last ? Math.min(64, now - l.last) : 16;
|
|
112
|
+
l.last = now;
|
|
113
|
+
const k = 1 - Math.exp(-dt / 70);
|
|
114
|
+
l.x += (tx - l.x) * k;
|
|
115
|
+
l.y += (ty - l.y) * k;
|
|
116
|
+
const done = Math.abs(tx - l.x) < 0.05 && Math.abs(ty - l.y) < 0.05;
|
|
117
|
+
if (done) {
|
|
118
|
+
l.x = tx;
|
|
119
|
+
l.y = ty;
|
|
120
|
+
}
|
|
121
|
+
el.style.setProperty("--lx", `${l.x.toFixed(2)}%`);
|
|
122
|
+
el.style.setProperty("--ly", `${l.y.toFixed(2)}%`);
|
|
123
|
+
if (done) {
|
|
124
|
+
l.frame = 0;
|
|
125
|
+
l.last = 0;
|
|
126
|
+
}
|
|
127
|
+
else
|
|
128
|
+
l.frame = requestAnimationFrame((t) => stepLight(el, t));
|
|
129
|
+
}
|
|
117
130
|
function setLight(event, lit) {
|
|
118
131
|
const el = event.currentTarget;
|
|
119
132
|
if (event.pointerType !== "mouse" && event.pointerType !== "pen")
|
|
120
133
|
return;
|
|
121
134
|
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
122
135
|
return;
|
|
136
|
+
let l = sheetLights.get(el);
|
|
137
|
+
if (!l)
|
|
138
|
+
sheetLights.set(el, (l = { x: 0, y: 0, cx: 0, cy: 0, last: 0, frame: 0, placed: false }));
|
|
123
139
|
if (!lit) {
|
|
140
|
+
// The light fades out where it is; the next entry places it afresh.
|
|
141
|
+
cancelAnimationFrame(l.frame);
|
|
142
|
+
l.frame = 0;
|
|
143
|
+
l.last = 0;
|
|
144
|
+
l.placed = false;
|
|
124
145
|
el.dataset.lit = "false";
|
|
125
146
|
return;
|
|
126
147
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
el.style.setProperty("--ly", `${(((event.clientY - rect.top) / rect.height) * 100).toFixed(2)}%`);
|
|
148
|
+
l.cx = event.clientX;
|
|
149
|
+
l.cy = event.clientY;
|
|
130
150
|
el.dataset.lit = "true";
|
|
151
|
+
if (!l.frame)
|
|
152
|
+
l.frame = requestAnimationFrame((t) => stepLight(el, t));
|
|
131
153
|
}
|
|
132
154
|
/**
|
|
133
155
|
* SpecSheet — the frame of the `sheet/…` entries, for your own sheets and walls: a square-cornered
|
|
@@ -9,13 +9,13 @@ export interface InputGroupMessages {
|
|
|
9
9
|
clear: string;
|
|
10
10
|
}
|
|
11
11
|
declare module "./locale" {
|
|
12
|
-
interface
|
|
12
|
+
interface LocaleMessages {
|
|
13
13
|
inputGroup: InputGroupMessages;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
declare const groupSizes: {
|
|
17
|
-
readonly sm: "min-h-(--control-h-sm) text-
|
|
18
|
-
readonly default: "min-h-(--control-h) text-base sm:text-
|
|
17
|
+
readonly sm: "min-h-(--control-h-sm) text-13 pointer-coarse:text-base";
|
|
18
|
+
readonly default: "min-h-(--control-h) text-base sm:text-15";
|
|
19
19
|
};
|
|
20
20
|
export interface InputGroupProps extends React.ComponentProps<"div"> {
|
|
21
21
|
/** `sm` (30px) for dense surfaces; `default` (38px) everywhere else. */
|
|
@@ -77,7 +77,7 @@ declare const buttonSizes: {
|
|
|
77
77
|
/** 24px — fits the dense group, or a quiet action in the default one. */
|
|
78
78
|
readonly sm: "min-h-(--control-inset-sm) gap-1 rounded-(--input-group-button-radius) px-2 text-xs leading-none";
|
|
79
79
|
/** 30px — fits the 38px group with a 3px inset, like a segment. */
|
|
80
|
-
readonly default: "min-h-(--control-inset) gap-1.5 rounded-(--input-group-button-radius) px-2.5 text-
|
|
80
|
+
readonly default: "min-h-(--control-inset) gap-1.5 rounded-(--input-group-button-radius) px-2.5 text-13 leading-none";
|
|
81
81
|
readonly "icon-sm": "size-(--control-inset-sm) rounded-full p-0 [&_svg:not([class*='size-'])]:size-[min(14px,calc(var(--control-inset-sm)-4px))]";
|
|
82
82
|
readonly icon: "size-(--control-inset) rounded-full p-0";
|
|
83
83
|
};
|
|
@@ -104,11 +104,6 @@ export interface InputGroupPasswordToggleProps extends Omit<InputGroupButtonProp
|
|
|
104
104
|
* Default "Show password", or `messages.inputGroup.showPassword` from a LocaleProvider.
|
|
105
105
|
*/
|
|
106
106
|
label?: string;
|
|
107
|
-
/** @deprecated A toggle keeps one name: use `label`. Only `show` is read, as that name. */
|
|
108
|
-
labels?: {
|
|
109
|
-
show?: string;
|
|
110
|
-
hide?: string;
|
|
111
|
-
};
|
|
112
107
|
}
|
|
113
108
|
/**
|
|
114
109
|
* InputGroupPasswordToggle — the show/hide button for a password: a ghost icon button with an
|
|
@@ -118,7 +113,7 @@ export interface InputGroupPasswordToggleProps extends Omit<InputGroupButtonProp
|
|
|
118
113
|
* `aria-pressed` while the password is shown — a toggle's name never changes with its state.
|
|
119
114
|
* Switch the input's `type` with `visible`.
|
|
120
115
|
*/
|
|
121
|
-
export declare function InputGroupPasswordToggle({ visible, onVisibleChange, label,
|
|
116
|
+
export declare function InputGroupPasswordToggle({ visible, onVisibleChange, label, ref, onClick, ...props }: InputGroupPasswordToggleProps): React.JSX.Element;
|
|
122
117
|
export interface InputGroupClearButtonProps extends Omit<InputGroupButtonProps, "variant" | "size" | "children" | "onClick"> {
|
|
123
118
|
/**
|
|
124
119
|
* Clear your state (`setQuery("")`). Without it, the button empties the field itself and fires
|
|
@@ -132,7 +127,7 @@ export interface InputGroupClearButtonProps extends Omit<InputGroupButtonProps,
|
|
|
132
127
|
* InputGroupClearButton — empties the field it sits in, smoothly: the text is erased right to
|
|
133
128
|
* left behind a soft edge, as if typed away, then the value clears and focus returns to the
|
|
134
129
|
* field. The button fades out while the field is empty and back in when there is text, instead of
|
|
135
|
-
* popping in and out.
|
|
130
|
+
* popping in and out. The keyboard (Enter, Space) and reduced motion clear at once.
|
|
136
131
|
*/
|
|
137
132
|
export declare function InputGroupClearButton({ onClear, label, ref, className, ...props }: InputGroupClearButtonProps): React.JSX.Element;
|
|
138
133
|
export {};
|