@zonsh/ui 0.5.0 → 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 +6 -6
- 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/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 +388 -23
- 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 +63 -7
- 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 +27 -1
- package/dist/components/chart.js +15 -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 +3 -3
- 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 +35 -10
- 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 +67 -13
- package/dist/components/copy-button.d.ts +1 -1
- package/dist/components/copy-button.js +1 -1
- 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 +170 -25
- package/dist/components/illustration.js +3 -28
- package/dist/components/input-group.d.ts +5 -10
- package/dist/components/input-group.js +16 -16
- 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/lightbox.d.ts +76 -9
- package/dist/components/lightbox.js +333 -45
- 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 +97 -22
- package/dist/components/message.d.ts +62 -11
- package/dist/components/message.js +49 -13
- 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 -12
- package/dist/components/number-field.d.ts +2 -9
- package/dist/components/number-field.js +86 -36
- 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 +24 -14
- 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 +1 -1
- 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 +1 -1
- package/dist/components/response.js +18 -6
- 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 +57 -17
- package/dist/components/site-header.d.ts +18 -13
- package/dist/components/site-header.js +23 -11
- package/dist/components/skeleton.d.ts +17 -7
- package/dist/components/skeleton.js +22 -7
- package/dist/components/slider.js +2 -2
- package/dist/components/sortable.d.ts +55 -4
- package/dist/components/sortable.js +172 -103
- 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 +12 -6
- package/dist/components/table.js +78 -30
- package/dist/components/tabs.js +7 -4
- 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 +49 -6
- package/dist/components/theme.js +147 -9
- package/dist/components/time-field.d.ts +4 -9
- package/dist/components/time-field.js +6 -6
- 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 +16 -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 +4 -4
- package/dist/components/toolbar.d.ts +57 -4
- package/dist/components/toolbar.js +216 -16
- package/dist/components/tooltip.d.ts +1 -1
- package/dist/components/tooltip.js +4 -2
- package/dist/components/tour.d.ts +1 -1
- package/dist/components/tour.js +36 -15
- package/dist/components/tree.js +5 -5
- 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 +121 -220
- 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 +5 -0
- package/dist/lib/glide.js +9 -1
- 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 +1 -1
- package/dist/lib/table-fit.js +65 -8
- 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 +35 -56
- 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 -201
- package/dist/styles/material.css +138 -12
- package/dist/styles/parts/ai.css +18 -13
- package/dist/styles/parts/brand.css +2 -2
- package/dist/styles/parts/controls.css +29 -20
- package/dist/styles/parts/data.css +13 -9
- package/dist/styles/parts/editor.css +372 -0
- package/dist/styles/parts/feedback.css +32 -2
- 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 +206 -27
- package/dist/styles/parts/overlays.css +19 -4
- package/dist/styles/parts/pdf.css +2 -2
- package/dist/styles/pdf.css +3 -0
- package/dist/styles/prose.css +3 -0
- package/dist/styles/tokens.css +89 -14
- 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,14 +1,15 @@
|
|
|
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. */
|
|
@@ -54,6 +55,7 @@ const defaultMessages = {
|
|
|
54
55
|
addLabel: "Add a label",
|
|
55
56
|
reverse: "Reverse direction",
|
|
56
57
|
removeConnection: "Remove connection",
|
|
58
|
+
connectTo: "Connect to",
|
|
57
59
|
enterKey: "Enter",
|
|
58
60
|
deleteKey: "Del",
|
|
59
61
|
connection: (from, to, directed) => `${from} ${directed ? "to" : "and"} ${to}`,
|
|
@@ -64,6 +66,9 @@ const defaultMessages = {
|
|
|
64
66
|
edgeHelp: "Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.",
|
|
65
67
|
handle: "Handle",
|
|
66
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.",
|
|
67
72
|
};
|
|
68
73
|
const GraphContext = React.createContext(null);
|
|
69
74
|
const useGraph = () => React.useContext(GraphContext);
|
|
@@ -253,15 +258,15 @@ function NodeView({ id, data }) {
|
|
|
253
258
|
const state = { "data-dim": data.dim ? "" : undefined, "data-lit": data.lit ? "" : undefined };
|
|
254
259
|
// Shapes whose name sits under them: events and gateways.
|
|
255
260
|
if (kind === "start" || kind === "end" || kind === "event" || kind === "gateway") {
|
|
256
|
-
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" }) })] }));
|
|
257
262
|
}
|
|
258
263
|
if (kind === "note") {
|
|
259
|
-
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" })] }));
|
|
260
265
|
}
|
|
261
266
|
if (kind === "person") {
|
|
262
|
-
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 }))] })] }));
|
|
263
268
|
}
|
|
264
|
-
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 }))] })] }));
|
|
265
270
|
}
|
|
266
271
|
function GroupView({ id, data }) {
|
|
267
272
|
// A swimlane: a band with its name in a strip at the start, set along the flow.
|
|
@@ -431,7 +436,16 @@ const edgeTypes = { zon: EdgeView };
|
|
|
431
436
|
export function Graph(props) {
|
|
432
437
|
return (_jsx(ReactFlowProvider, { children: _jsx(GraphCanvas, { ...props }) }));
|
|
433
438
|
}
|
|
434
|
-
|
|
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 }) {
|
|
435
449
|
const text = useMessages("graph", defaultMessages, labels);
|
|
436
450
|
const textRef = React.useRef(text);
|
|
437
451
|
textRef.current = text;
|
|
@@ -442,22 +456,95 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
442
456
|
"handle.ariaLabel": text.handle,
|
|
443
457
|
"minimap.ariaLabel": text.minimap,
|
|
444
458
|
}), [text]);
|
|
445
|
-
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");
|
|
446
533
|
const flow = useReactFlow();
|
|
447
534
|
const markers = React.useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
448
|
-
const frame = React.useRef(null);
|
|
449
535
|
const describedBy = `${markers}-connections`;
|
|
450
536
|
const [state, setState] = React.useState(() => build({ nodes: nodesProp, edges: edgesProp }, layout, direction));
|
|
451
537
|
const latest = React.useRef(state);
|
|
452
538
|
latest.current = state;
|
|
453
539
|
// The value last sent out: when it comes back as props, it is not laid out again.
|
|
454
540
|
const sent = React.useRef(null);
|
|
455
|
-
|
|
541
|
+
// Before paint: a flow that turns down in a narrow frame is never drawn the other way first.
|
|
542
|
+
React.useLayoutEffect(() => {
|
|
456
543
|
if (sent.current && sent.current.nodes === nodesProp && sent.current.edges === edgesProp)
|
|
457
544
|
return;
|
|
458
545
|
setState(build({ nodes: nodesProp, edges: edgesProp }, layout, direction));
|
|
459
|
-
requestAnimationFrame(() => void flow.fitView({
|
|
460
|
-
}, [nodesProp, edgesProp, layout, direction, flow]);
|
|
546
|
+
requestAnimationFrame(() => void flow.fitView({ ...fitFrame(controls), duration: 0 }));
|
|
547
|
+
}, [nodesProp, edgesProp, layout, direction, flow, controls]);
|
|
461
548
|
const emit = React.useCallback((next) => {
|
|
462
549
|
if (!onChange)
|
|
463
550
|
return;
|
|
@@ -614,7 +701,7 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
614
701
|
// Twice --duration: a move the interface makes on its own, ended within 300ms.
|
|
615
702
|
const duration = el ? cssDuration(el) * 2 : 0;
|
|
616
703
|
// Without motion (reduced motion) the camera jumps too.
|
|
617
|
-
const fit = () => requestAnimationFrame(() => void flow.fitView({
|
|
704
|
+
const fit = () => requestAnimationFrame(() => void flow.fitView({ ...fitFrame(controls), duration }));
|
|
618
705
|
if (!el || !duration) {
|
|
619
706
|
setState(next);
|
|
620
707
|
emit(next);
|
|
@@ -629,7 +716,7 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
629
716
|
? getViewportForBounds(boxAround(next.nodes.filter((n) => !n.parentId)), pane.clientWidth, pane.clientHeight, 0.2, 1.15, 0.18)
|
|
630
717
|
: null;
|
|
631
718
|
// The interface moves the nodes from A to B on its own: ease in and out.
|
|
632
|
-
const ease =
|
|
719
|
+
const ease = cssEase("--ease-move", el);
|
|
633
720
|
// No keyframes: the animation only keeps the clock; its progress places the nodes.
|
|
634
721
|
const clock = el.animate([], { duration, easing: ease });
|
|
635
722
|
let raf = 0;
|
|
@@ -676,7 +763,7 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
676
763
|
emit(latest.current);
|
|
677
764
|
},
|
|
678
765
|
};
|
|
679
|
-
}, [direction, emit, flow, layout]);
|
|
766
|
+
}, [controls, direction, emit, flow, layout]);
|
|
680
767
|
/* Networks: a dragged node pulls its neighbours along, and the rest settles around it. */
|
|
681
768
|
const physics = React.useRef(null);
|
|
682
769
|
const reduce = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
@@ -802,6 +889,44 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
802
889
|
else
|
|
803
890
|
setTarget({ type: "pane", at: flow.screenToFlowPosition({ x: event.clientX, y: event.clientY }) });
|
|
804
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
|
+
};
|
|
805
930
|
const removeNode = (id) => onNodesChange([{ type: "remove", id }]);
|
|
806
931
|
const removeEdge = (id) => onEdgesChange([{ type: "remove", id }]);
|
|
807
932
|
const reverse = (id) => {
|
|
@@ -821,22 +946,42 @@ function GraphCanvas({ nodes: nodesProp, edges: edgesProp, layout = "flow", dire
|
|
|
821
946
|
emit(next);
|
|
822
947
|
};
|
|
823
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
|
+
: [];
|
|
824
956
|
const stepped = layout === "flow" || layout === "tree";
|
|
825
957
|
const nodeLabels = React.useMemo(() => new Map(state.nodes.map((n) => [n.id, n.data.node.label])), [state.nodes]);
|
|
826
|
-
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:
|
|
827
|
-
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) => {
|
|
828
|
-
// Editable: Enter on a focused node opens its label.
|
|
829
|
-
|
|
830
|
-
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)
|
|
831
962
|
return;
|
|
832
|
-
event.
|
|
833
|
-
|
|
834
|
-
|
|
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))) })] }) }));
|
|
835
980
|
}
|
|
836
981
|
function ControlButton({ label, onClick, children, }) {
|
|
837
982
|
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(ToolbarButton, { "aria-label": label, onClick: onClick }), children: children }), _jsx(TooltipContent, { side: "top", children: label })] }));
|
|
838
983
|
}
|
|
839
984
|
function GraphControls({ text, editable, tidy, add, }) {
|
|
840
985
|
const flow = useReactFlow();
|
|
841
|
-
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({
|
|
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, {}) }))] })] }));
|
|
842
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 }) {
|
|
@@ -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
|
|
@@ -3,16 +3,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Button as BaseButton } from "@base-ui/react/button";
|
|
4
4
|
import { Field as BaseField } from "@base-ui/react/field";
|
|
5
5
|
import { Input as BaseInput } from "@base-ui/react/input";
|
|
6
|
-
import { XIcon } from "
|
|
6
|
+
import { XIcon } from "../lib/icons.js";
|
|
7
7
|
import * as React from "react";
|
|
8
8
|
import { cn, sx } from "../lib/cn.js";
|
|
9
9
|
import { mergeRefs } from "../lib/merge-refs.js";
|
|
10
|
-
import { cssDuration } from "../lib/motion.js";
|
|
10
|
+
import { cssDuration, cssEase } from "../lib/motion.js";
|
|
11
11
|
import { useMessages } from "./locale.js";
|
|
12
12
|
const defaultMessages = { showPassword: "Show password", clear: "Clear" };
|
|
13
13
|
const groupSizes = {
|
|
14
|
-
sm: "min-h-(--control-h-sm) text-
|
|
15
|
-
default: "min-h-(--control-h) text-base sm:text-
|
|
14
|
+
sm: "min-h-(--control-h-sm) text-13 pointer-coarse:text-base",
|
|
15
|
+
default: "min-h-(--control-h) text-base sm:text-15",
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* InputGroup — one recessed field that holds an input (or textarea) together with addons:
|
|
@@ -56,7 +56,7 @@ export function InputGroupInput({ className, ...props }) {
|
|
|
56
56
|
export function InputGroupTextarea({ className, ...props }) {
|
|
57
57
|
return (_jsx(BaseField.Control, { "data-slot": "input-group-control", render: _jsx("textarea", {}), className: sx([
|
|
58
58
|
controlBase,
|
|
59
|
-
"field-sizing-content max-h-60 min-h-24 w-full resize-none px-3.5 py-3 text-base sm:text-
|
|
59
|
+
"field-sizing-content max-h-60 min-h-24 w-full resize-none px-3.5 py-3 text-base sm:text-15",
|
|
60
60
|
"group-has-[>[data-align=block-end]]/input-group:pb-1.5 group-has-[>[data-align=block-start]]/input-group:pt-1.5",
|
|
61
61
|
], className), ...props }));
|
|
62
62
|
}
|
|
@@ -91,7 +91,7 @@ export function InputGroupAddon({ align = "inline-start", className, onMouseDown
|
|
|
91
91
|
}
|
|
92
92
|
/** Plain text inside an addon: a prefix, a suffix or a count. Licht Mono, muted, tabular. */
|
|
93
93
|
export function InputGroupText({ className, ...props }) {
|
|
94
|
-
return (_jsx("span", { "data-slot": "input-group-text", className: cn("flex items-center gap-1.5 font-mono text-
|
|
94
|
+
return (_jsx("span", { "data-slot": "input-group-text", className: cn("flex items-center gap-1.5 font-mono text-13 whitespace-nowrap text-muted-foreground tabular-nums", "group-data-[size=sm]/input-group:text-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-3.5", className), ...props }));
|
|
95
95
|
}
|
|
96
96
|
const buttonVariants = {
|
|
97
97
|
secondary: "material-raised",
|
|
@@ -104,7 +104,7 @@ const buttonSizes = {
|
|
|
104
104
|
/** 24px — fits the dense group, or a quiet action in the default one. */
|
|
105
105
|
sm: "min-h-(--control-inset-sm) gap-1 rounded-(--input-group-button-radius) px-2 text-xs leading-none",
|
|
106
106
|
/** 30px — fits the 38px group with a 3px inset, like a segment. */
|
|
107
|
-
default: "min-h-(--control-inset) gap-1.5 rounded-(--input-group-button-radius) px-2.5 text-
|
|
107
|
+
default: "min-h-(--control-inset) gap-1.5 rounded-(--input-group-button-radius) px-2.5 text-13 leading-none",
|
|
108
108
|
"icon-sm": "size-(--control-inset-sm) rounded-full p-0 [&_svg:not([class*='size-'])]:size-[min(14px,calc(var(--control-inset-sm)-4px))]",
|
|
109
109
|
icon: "size-(--control-inset) rounded-full p-0",
|
|
110
110
|
};
|
|
@@ -126,10 +126,10 @@ export function InputGroupButton({ variant = "secondary", size = "default", clas
|
|
|
126
126
|
}
|
|
127
127
|
/*
|
|
128
128
|
* The reveal sweeps: on a press, the field's new text — or its dots — is uncovered left to right
|
|
129
|
-
* behind a soft 32px edge, across the text itself rather than the whole field,
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
129
|
+
* behind a soft 32px edge, across the text itself rather than the whole field, over 2 × --duration
|
|
130
|
+
* on --ease-glide (the brand ease spends most of its way in a frame or two, too soon to see). The
|
|
131
|
+
* value is there at once and the field stays usable, so revealing a password many times a day
|
|
132
|
+
* never means waiting. Only a press of the toggle plays it; reduced motion skips it.
|
|
133
133
|
*/
|
|
134
134
|
let measurer = null;
|
|
135
135
|
/**
|
|
@@ -190,7 +190,7 @@ const groupInput = (el) => el
|
|
|
190
190
|
* `aria-pressed` while the password is shown — a toggle's name never changes with its state.
|
|
191
191
|
* Switch the input's `type` with `visible`.
|
|
192
192
|
*/
|
|
193
|
-
export function InputGroupPasswordToggle({ visible, onVisibleChange, label,
|
|
193
|
+
export function InputGroupPasswordToggle({ visible, onVisibleChange, label, ref, onClick, ...props }) {
|
|
194
194
|
const text = useMessages("inputGroup", defaultMessages);
|
|
195
195
|
const own = React.useRef(null);
|
|
196
196
|
const pressed = React.useRef(false);
|
|
@@ -207,9 +207,9 @@ export function InputGroupPasswordToggle({ visible, onVisibleChange, label, labe
|
|
|
207
207
|
const duration = cssDuration(input) * 2;
|
|
208
208
|
if (!duration)
|
|
209
209
|
return;
|
|
210
|
-
input.animate(sweepFrames(input), { duration, easing: "
|
|
210
|
+
input.animate(sweepFrames(input), { duration, easing: cssEase("--ease-glide", input) });
|
|
211
211
|
}, [visible]);
|
|
212
|
-
return (_jsx(InputGroupButton, { ref: refs, "data-password-toggle": "", variant: "ghost", size: "icon", "aria-label": label ??
|
|
212
|
+
return (_jsx(InputGroupButton, { ref: refs, "data-password-toggle": "", variant: "ghost", size: "icon", "aria-label": label ?? text.showPassword, "aria-pressed": visible, onClick: (event) => {
|
|
213
213
|
pressed.current = true;
|
|
214
214
|
onVisibleChange(!visible);
|
|
215
215
|
onClick?.(event);
|
|
@@ -293,7 +293,7 @@ export function InputGroupClearButton({ onClear, label, ref, className, ...props
|
|
|
293
293
|
// Held at its end until the value is really gone, so the text never flashes back.
|
|
294
294
|
const erase = input.animate(sweepFrames(input, true), {
|
|
295
295
|
duration,
|
|
296
|
-
easing: "
|
|
296
|
+
easing: cssEase("--ease-glide", input),
|
|
297
297
|
fill: "forwards",
|
|
298
298
|
});
|
|
299
299
|
erase.onfinish = () => {
|
|
@@ -310,5 +310,5 @@ export function InputGroupClearButton({ onClear, label, ref, className, ...props
|
|
|
310
310
|
return (_jsx(InputGroupButton, { ref: refs, "data-clear-button": "", "data-empty": empty ? "" : undefined, variant: "ghost", size: "icon", "aria-label": label ?? text.clear, "aria-hidden": empty || undefined, tabIndex: empty ? -1 : undefined, onClick: clear, className: cn(
|
|
311
311
|
// The fade rides the material's own transition list (--material-motion), which a transition
|
|
312
312
|
// utility would replace.
|
|
313
|
-
"[--material-motion:opacity_var(--duration)_var(--ease),scale_var(--duration)_var(--ease)] data-empty:pointer-events-none data-empty:scale-75 data-empty:opacity-0", className), ...props, children: _jsx(XIcon, {}) }));
|
|
313
|
+
"[--material-motion:opacity_var(--duration-fade)_var(--ease),scale_var(--duration)_var(--ease)] data-empty:pointer-events-none data-empty:scale-75 data-empty:opacity-0", className), ...props, children: _jsx(XIcon, {}) }));
|
|
314
314
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Input as BaseInput } from "@base-ui/react/input";
|
|
2
2
|
declare const sizes: {
|
|
3
|
-
readonly sm: "min-h-(--control-h-sm) px-2.5 text-
|
|
4
|
-
readonly default: "min-h-(--control-h) px-3.5 text-base sm:text-
|
|
3
|
+
readonly sm: "min-h-(--control-h-sm) px-2.5 text-13 pointer-coarse:text-base [&[type=file]]:p-0.5 [&[type=file]]:leading-none file:h-(--control-inset-sm)";
|
|
4
|
+
readonly default: "min-h-(--control-h) px-3.5 text-base sm:text-15 [&[type=file]]:p-[3px] [&[type=file]]:leading-none file:h-(--control-inset)";
|
|
5
5
|
};
|
|
6
6
|
export interface InputProps extends Omit<BaseInput.Props, "size"> {
|
|
7
7
|
/** `sm` (30px) for dense surfaces; `default` (38px) everywhere else. */
|
package/dist/components/input.js
CHANGED
|
@@ -3,8 +3,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { Input as BaseInput } from "@base-ui/react/input";
|
|
4
4
|
import { sx } from "../lib/cn.js";
|
|
5
5
|
const sizes = {
|
|
6
|
-
sm: "min-h-(--control-h-sm) px-2.5 text-
|
|
7
|
-
default: "min-h-(--control-h) px-3.5 text-base sm:text-
|
|
6
|
+
sm: "min-h-(--control-h-sm) px-2.5 text-13 pointer-coarse:text-base [&[type=file]]:p-0.5 [&[type=file]]:leading-none file:h-(--control-inset-sm)",
|
|
7
|
+
default: "min-h-(--control-h) px-3.5 text-base sm:text-15 [&[type=file]]:p-[3px] [&[type=file]]:leading-none file:h-(--control-inset)",
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
10
10
|
* Input — a recessed single-line field. 10px radius, 38px default, 30px dense, full width of
|
|
@@ -17,7 +17,7 @@ export function Input({ size = "default", className, ...props }) {
|
|
|
17
17
|
// A file input's "Choose file" is a small raised button inside the field, inset like an
|
|
18
18
|
// InputGroup button (30px in 38, 24px in 30, 7px corners); the file name stays quiet.
|
|
19
19
|
"[&[type=file]]:cursor-pointer [&[type=file]]:text-muted-foreground",
|
|
20
|
-
"file:me-3 file:cursor-pointer file:rounded-item file:border-0 file:bg-control-surface file:bg-linear-to-b file:from-control-inner-edge file:to-transparent file:px-3 file:font-body file:text-
|
|
20
|
+
"file:me-3 file:cursor-pointer file:rounded-item file:border-0 file:bg-control-surface file:bg-linear-to-b file:from-control-inner-edge file:to-transparent file:px-3 file:font-body file:text-13 file:font-medium file:text-foreground file:shadow-raised file:hover:bg-control-hover",
|
|
21
21
|
// The search field's clear button (×) is a button: it takes the pointer.
|
|
22
22
|
"[&::-webkit-search-cancel-button]:cursor-pointer",
|
|
23
23
|
sizes[size],
|
|
@@ -11,9 +11,9 @@ declare const itemVariants: {
|
|
|
11
11
|
};
|
|
12
12
|
declare const itemSizes: {
|
|
13
13
|
/** 46px minimum: title + description. */
|
|
14
|
-
readonly default: "min-h-(--control-h-lg) gap-4 px-4 py-
|
|
14
|
+
readonly default: "min-h-(--control-h-lg) gap-4 px-4 py-[calc((var(--control-h-lg)-22px)/2)]";
|
|
15
15
|
/** 38px minimum: dense lists, settings rows. */
|
|
16
|
-
readonly sm: "min-h-(--control-h) gap-3 px-3 py-2";
|
|
16
|
+
readonly sm: "min-h-(--control-h) gap-3 px-3 py-[calc((var(--control-h)-22px)/2)]";
|
|
17
17
|
};
|
|
18
18
|
export type ItemVariant = keyof typeof itemVariants;
|
|
19
19
|
export type ItemSize = keyof typeof itemSizes;
|
|
@@ -33,12 +33,15 @@ export interface ItemProps extends useRender.ComponentProps<"div"> {
|
|
|
33
33
|
*/
|
|
34
34
|
export declare function Item({ variant, size, render, ref, className, ...props }: ItemProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
35
35
|
declare const itemMediaVariants: {
|
|
36
|
-
/**
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The child as is — an `Avatar`, a lucide icon at 20px. An SVG that sizes itself (`size-*`,
|
|
38
|
+
* `h-*` or `w-*`: a product drawing, an illustration) keeps its size.
|
|
39
|
+
*/
|
|
40
|
+
readonly default: "[&_svg:not([class*='size-'],[class^='h-'],[class*='_h-'],[class^='w-'],[class*='_w-'])]:size-5";
|
|
38
41
|
/** A raised 32px key with 7px corners holding a 16px icon. */
|
|
39
42
|
readonly icon: "size-8 rounded-item text-foreground [&_svg:not([class*='size-'])]:size-4 bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised";
|
|
40
|
-
/** A 40px thumbnail with 7px corners; the image
|
|
41
|
-
readonly image: "size-10 overflow-hidden rounded-item ring-1 ring-field-edge [&_img]:size-full [&_img]:object-cover";
|
|
43
|
+
/** A 40px thumbnail with 7px corners; the image — an `<img>` or an `<svg>` — fills it. */
|
|
44
|
+
readonly image: "size-10 overflow-hidden rounded-item ring-1 ring-field-edge [&_img]:size-full [&_img]:object-cover [&>svg]:size-full";
|
|
42
45
|
};
|
|
43
46
|
export type ItemMediaVariant = keyof typeof itemMediaVariants;
|
|
44
47
|
export interface ItemMediaProps extends React.ComponentProps<"div"> {
|