@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
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
# Mentions
|
|
2
|
+
|
|
3
|
+
```tsx
|
|
4
|
+
import { Avatar, Field, FieldDescription, FieldLabel, Mentions, type MentionsTrigger, Textarea } from "@zonsh/ui";
|
|
5
|
+
import { AlarmClockIcon, CircleDotIcon, UserPlusIcon } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
interface Person {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const people: Person[] = [
|
|
15
|
+
{ id: "mira", label: "Mira Okafor", description: "@mira" },
|
|
16
|
+
{ id: "jonas", label: "Jonas Weber", description: "@jonas" },
|
|
17
|
+
{ id: "ada", label: "Ada Lindqvist", description: "@ada" },
|
|
18
|
+
{ id: "tomas", label: "Tomás Ibarra", description: "@tomas" },
|
|
19
|
+
{ id: "lena", label: "Lena Hofmann", description: "@lena" },
|
|
20
|
+
{ id: "kofi", label: "Kofi Mensah", description: "@kofi" },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const mention: MentionsTrigger<Person> = {
|
|
24
|
+
char: "@",
|
|
25
|
+
label: "People",
|
|
26
|
+
items: people,
|
|
27
|
+
// The handle goes into the text; the list shows the name.
|
|
28
|
+
insert: (person) => `@${person.id} `,
|
|
29
|
+
// Finds the handles already in the text, so a saved draft shows its mentions too.
|
|
30
|
+
pattern: new RegExp(`@(${people.map((p) => p.id).join("|")})`),
|
|
31
|
+
renderItem: (person) => (
|
|
32
|
+
<>
|
|
33
|
+
<Avatar size="sm" name={person.label} aria-hidden />
|
|
34
|
+
<span className="min-w-0 flex-1 truncate">{person.label}</span>
|
|
35
|
+
<span className="shrink-0 font-mono text-xs text-muted-foreground">{person.description}</span>
|
|
36
|
+
</>
|
|
37
|
+
),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
interface Issue {
|
|
41
|
+
id: string;
|
|
42
|
+
label: string;
|
|
43
|
+
description: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const issues: Issue[] = [
|
|
47
|
+
{ id: "412", label: "Footnotes are dropped in the EPUB export", description: "#412" },
|
|
48
|
+
{ id: "409", label: "Table of contents skips level-three headings", description: "#409" },
|
|
49
|
+
{ id: "398", label: "Smart quotes break inline code", description: "#398" },
|
|
50
|
+
{ id: "377", label: "Spellcheck ignores the project dictionary", description: "#377" },
|
|
51
|
+
{ id: "351", label: "Images lose their alt text on paste", description: "#351" },
|
|
52
|
+
{ id: "322", label: "Word count includes front matter", description: "#322" },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/** A stand-in for a search endpoint: answers after a moment, and stops when the query changes. */
|
|
56
|
+
function searchIssues(query: string, { signal }: { signal: AbortSignal }) {
|
|
57
|
+
return new Promise<Issue[]>((resolve, reject) => {
|
|
58
|
+
const timer = setTimeout(() => {
|
|
59
|
+
const q = query.toLowerCase();
|
|
60
|
+
resolve(issues.filter((i) => i.id.startsWith(q) || i.label.toLowerCase().includes(q)));
|
|
61
|
+
}, 400);
|
|
62
|
+
signal.addEventListener("abort", () => {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
reject(signal.reason);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const issueTrigger: MentionsTrigger<Issue> = {
|
|
70
|
+
char: "#",
|
|
71
|
+
label: "Issues",
|
|
72
|
+
items: searchIssues,
|
|
73
|
+
debounce: 150,
|
|
74
|
+
insert: (issue) => `#${issue.id} `,
|
|
75
|
+
pattern: /#\d+/,
|
|
76
|
+
renderItem: (issue) => (
|
|
77
|
+
<>
|
|
78
|
+
<CircleDotIcon aria-hidden className="size-4 shrink-0 text-muted-foreground" />
|
|
79
|
+
<span className="min-w-0 flex-1 truncate">{issue.label}</span>
|
|
80
|
+
<span className="shrink-0 font-mono text-xs text-muted-foreground tabular-nums">
|
|
81
|
+
{issue.description}
|
|
82
|
+
</span>
|
|
83
|
+
</>
|
|
84
|
+
),
|
|
85
|
+
empty: "No open issue matches. Try a number or another word.",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
interface Action {
|
|
89
|
+
id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
description: string;
|
|
92
|
+
icon: React.ReactNode;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const actions: Action[] = [
|
|
96
|
+
{ id: "remind", label: "Remind me", description: "/remind", icon: <AlarmClockIcon /> },
|
|
97
|
+
{ id: "assign", label: "Assign", description: "/assign", icon: <UserPlusIcon /> },
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
// Three kinds, three looks: people boxed, actions in a tone, issue numbers as text. Each trigger's
|
|
101
|
+
// `pattern` also finds its mentions in text nobody picked here — the saved draft in the field.
|
|
102
|
+
const looks: MentionsTrigger<any>[] = [
|
|
103
|
+
mention,
|
|
104
|
+
{
|
|
105
|
+
char: "/",
|
|
106
|
+
label: "Actions",
|
|
107
|
+
items: actions,
|
|
108
|
+
itemToString: (action: Action) => action.id,
|
|
109
|
+
insert: (action: Action) => `/${action.id} `,
|
|
110
|
+
appearance: "text",
|
|
111
|
+
tone: "violet",
|
|
112
|
+
pattern: new RegExp(`/(${actions.map((a) => a.id).join("|")})`),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
...issueTrigger,
|
|
116
|
+
items: issues,
|
|
117
|
+
debounce: 0,
|
|
118
|
+
appearance: "text",
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
export function Basic() {
|
|
123
|
+
return (
|
|
124
|
+
<Field className="w-full max-w-md">
|
|
125
|
+
<FieldLabel>Review note</FieldLabel>
|
|
126
|
+
<Mentions triggers={looks}>
|
|
127
|
+
<Textarea defaultValue="The EPUB export still drops footnotes, see #412. @mira can you take a look? /remind Friday " />
|
|
128
|
+
</Mentions>
|
|
129
|
+
<FieldDescription>Type @ for a person, # for an issue, / for an action.</FieldDescription>
|
|
130
|
+
</Field>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Suggestions at the caret of a field you already have — the list `MarkdownEditor` uses for mentions and "/". Type a trigger (`@`, `#`, `/` or any other) at a word start and a menu-material list with 38px rows opens under that line, filtered by what follows. Focus never leaves the field.
|
|
136
|
+
|
|
137
|
+
## Usage
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { Mentions, Textarea } from "@zonsh/ui";
|
|
141
|
+
|
|
142
|
+
const people = [
|
|
143
|
+
{ id: "mira", label: "Mira Okafor", description: "@mira" },
|
|
144
|
+
{ id: "jonas", label: "Jonas Weber", description: "@jonas" },
|
|
145
|
+
];
|
|
146
|
+
|
|
147
|
+
<Mentions triggers={[{ char: "@", items: people, insert: (p) => `@${p.id} ` }]}>
|
|
148
|
+
<Textarea aria-label="Comment" />
|
|
149
|
+
</Mentions>;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
The props you'll reach for: `triggers` (`char`, `items`, `insert`), the field as `children` or `inputRef`, and `onSelect`. For a component that renders its own textarea, pass a ref:
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
const ref = React.useRef<HTMLTextAreaElement>(null);
|
|
156
|
+
|
|
157
|
+
<textarea ref={ref} />
|
|
158
|
+
<Mentions inputRef={ref} triggers={triggers} onOpenChange={setSuggesting} />
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
The list sits under the trigger, not the caret, so it stays put as the query grows; it flips above when there is no room, follows scrolling, and opens leftward in right-to-left text.
|
|
162
|
+
|
|
163
|
+
## When to use
|
|
164
|
+
|
|
165
|
+
- References in free text: people in a comment, issues in a pull request, a `/` block menu, `:` for emoji — in any field, including `PromptInput` or `InputGroupTextarea` via `inputRef`.
|
|
166
|
+
- One value for the whole field is a `Combobox`; free-typed chips are `TagsInput`.
|
|
167
|
+
|
|
168
|
+
## Examples
|
|
169
|
+
|
|
170
|
+
### Async results
|
|
171
|
+
|
|
172
|
+
A function source gets the query and an `AbortSignal` and returns matches or a promise. The last results stay up under "Loading…"; a newer query aborts the older request. `debounce` waits for a pause; `empty` says what to try.
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { Avatar, Field, FieldDescription, FieldLabel, Mentions, type MentionsTrigger, Textarea } from "@zonsh/ui";
|
|
176
|
+
import { CircleDotIcon } from "lucide-react";
|
|
177
|
+
|
|
178
|
+
// Person, people, mention, Issue, issues, searchIssues, issueTrigger: as in the first example on this page that uses them.
|
|
179
|
+
|
|
180
|
+
export function Issues() {
|
|
181
|
+
return (
|
|
182
|
+
<Field className="w-full max-w-md">
|
|
183
|
+
<FieldLabel>Pull request description</FieldLabel>
|
|
184
|
+
<Mentions triggers={[issueTrigger, mention]}>
|
|
185
|
+
<Textarea defaultValue="Keeps footnote markers when exporting to EPUB. Fixes #412, reviewed by @jonas. " />
|
|
186
|
+
</Mentions>
|
|
187
|
+
<FieldDescription># links an open issue, searched as you type; @ mentions a reviewer.</FieldDescription>
|
|
188
|
+
</Field>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Commands in another field
|
|
194
|
+
|
|
195
|
+
A ref to the `InputGroup` uses its first textarea. `insert` returns what replaces `/todo` — a Markdown block; return `""` to only remove it and act in `onSelect`.
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { Field, FieldLabel, InputGroup, InputGroupAddon, InputGroupText, InputGroupTextarea, Mentions } from "@zonsh/ui";
|
|
199
|
+
import { CheckSquareIcon, HeadingIcon, MinusIcon, QuoteIcon } from "lucide-react";
|
|
200
|
+
import * as React from "react";
|
|
201
|
+
|
|
202
|
+
interface Block {
|
|
203
|
+
id: string;
|
|
204
|
+
label: string;
|
|
205
|
+
description: string;
|
|
206
|
+
icon: React.ReactNode;
|
|
207
|
+
text: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const blocks: Block[] = [
|
|
211
|
+
{ id: "todo", label: "To-do", description: "/todo", icon: <CheckSquareIcon />, text: "- [ ] " },
|
|
212
|
+
{ id: "heading", label: "Heading", description: "/heading", icon: <HeadingIcon />, text: "## " },
|
|
213
|
+
{ id: "quote", label: "Quote", description: "/quote", icon: <QuoteIcon />, text: "> " },
|
|
214
|
+
{ id: "divider", label: "Divider", description: "/divider", icon: <MinusIcon />, text: "---\n" },
|
|
215
|
+
];
|
|
216
|
+
|
|
217
|
+
export function Commands() {
|
|
218
|
+
// The field belongs to another component (an InputGroup here, an editor elsewhere): pass a ref
|
|
219
|
+
// to it, or to an element around it.
|
|
220
|
+
const ref = React.useRef<HTMLDivElement>(null);
|
|
221
|
+
return (
|
|
222
|
+
<Field className="w-full max-w-md">
|
|
223
|
+
<FieldLabel>Recipe notes</FieldLabel>
|
|
224
|
+
<InputGroup ref={ref}>
|
|
225
|
+
<InputGroupTextarea
|
|
226
|
+
placeholder="Type / for a block"
|
|
227
|
+
defaultValue={"## Sourdough\n- [ ] Feed the starter the night before\n> Keep the dough at 24 °C\n"}
|
|
228
|
+
/>
|
|
229
|
+
<InputGroupAddon align="block-end">
|
|
230
|
+
<InputGroupText>Markdown</InputGroupText>
|
|
231
|
+
</InputGroupAddon>
|
|
232
|
+
</InputGroup>
|
|
233
|
+
<Mentions
|
|
234
|
+
inputRef={ref}
|
|
235
|
+
triggers={[
|
|
236
|
+
{
|
|
237
|
+
char: "/",
|
|
238
|
+
label: "Blocks",
|
|
239
|
+
items: blocks,
|
|
240
|
+
itemToString: (block: Block) => block.id,
|
|
241
|
+
insert: (block: Block) => block.text,
|
|
242
|
+
},
|
|
243
|
+
]}
|
|
244
|
+
/>
|
|
245
|
+
</Field>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Styles and tones
|
|
251
|
+
|
|
252
|
+
Both appearances in the ink and the six category tones.
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
import { Eyebrow, MentionToken, type MentionTone } from "@zonsh/ui";
|
|
256
|
+
|
|
257
|
+
const tones: { tone: MentionTone; label: string }[] = [
|
|
258
|
+
{ tone: "default", label: "Ink · default" },
|
|
259
|
+
{ tone: "blue", label: "Blue" },
|
|
260
|
+
{ tone: "aqua", label: "Aqua" },
|
|
261
|
+
{ tone: "violet", label: "Violet" },
|
|
262
|
+
{ tone: "magenta", label: "Magenta" },
|
|
263
|
+
{ tone: "orange", label: "Orange" },
|
|
264
|
+
{ tone: "lime", label: "Lime" },
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
/** Every appearance × tone, the same sentence in each, to compare them side by side. */
|
|
268
|
+
export function AppearancesAndTones() {
|
|
269
|
+
return (
|
|
270
|
+
<div className="@container w-full max-w-2xl">
|
|
271
|
+
<div className="grid grid-cols-1 gap-x-6 text-[15px] text-foreground-soft @md:grid-cols-[7rem_minmax(0,1fr)_minmax(0,1fr)]">
|
|
272
|
+
<div className="hidden @md:contents">
|
|
273
|
+
<span />
|
|
274
|
+
<Eyebrow className="pb-2">Chip</Eyebrow>
|
|
275
|
+
<Eyebrow className="pb-2">Text</Eyebrow>
|
|
276
|
+
</div>
|
|
277
|
+
{tones.map(({ tone, label }) => (
|
|
278
|
+
<div
|
|
279
|
+
key={tone}
|
|
280
|
+
className="grid gap-1.5 border-t border-border/60 py-2.5 @md:col-span-3 @md:grid-cols-subgrid @md:items-baseline"
|
|
281
|
+
>
|
|
282
|
+
<Eyebrow>{label}</Eyebrow>
|
|
283
|
+
<p>
|
|
284
|
+
<MentionToken trigger="@" tone={tone}>
|
|
285
|
+
@mira
|
|
286
|
+
</MentionToken>{" "}
|
|
287
|
+
reviewed the draft.
|
|
288
|
+
</p>
|
|
289
|
+
<p>
|
|
290
|
+
Fixed in{" "}
|
|
291
|
+
<MentionToken trigger="#" appearance="text" tone={tone}>
|
|
292
|
+
#412
|
|
293
|
+
</MentionToken>{" "}
|
|
294
|
+
on Friday.
|
|
295
|
+
</p>
|
|
296
|
+
</div>
|
|
297
|
+
))}
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Read-only text
|
|
305
|
+
|
|
306
|
+
`MentionToken` draws the same mark in a message, a comment or a reply.
|
|
307
|
+
|
|
308
|
+
```tsx
|
|
309
|
+
import { MentionToken } from "@zonsh/ui";
|
|
310
|
+
|
|
311
|
+
export function ReadOnly() {
|
|
312
|
+
return (
|
|
313
|
+
<p className="max-w-md text-[15px] leading-relaxed text-foreground-soft">
|
|
314
|
+
<MentionToken trigger="@">@jonas</MentionToken> moved the chapter draft to review and linked{" "}
|
|
315
|
+
<MentionToken trigger="#" appearance="text">
|
|
316
|
+
#398
|
|
317
|
+
</MentionToken>
|
|
318
|
+
.{" "}
|
|
319
|
+
<MentionToken trigger="/" appearance="text" tone="violet">
|
|
320
|
+
/remind
|
|
321
|
+
</MentionToken>{" "}
|
|
322
|
+
is set for Friday.
|
|
323
|
+
</p>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### States
|
|
329
|
+
|
|
330
|
+
The field keeps its own `Field` states; `disabled` stops suggesting.
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
import { Avatar, Field, FieldDescription, FieldError, FieldLabel, Mentions, type MentionsTrigger, Textarea } from "@zonsh/ui";
|
|
334
|
+
import { AlarmClockIcon, CircleDotIcon, UserPlusIcon } from "lucide-react";
|
|
335
|
+
import * as React from "react";
|
|
336
|
+
|
|
337
|
+
// Person, people, mention, Issue, issues, searchIssues, issueTrigger, Action, actions, looks: as in the first example on this page that uses them.
|
|
338
|
+
|
|
339
|
+
export function States() {
|
|
340
|
+
const [note, setNote] = React.useState("@mira ");
|
|
341
|
+
const tooShort = note.trim().length < 12;
|
|
342
|
+
return (
|
|
343
|
+
// Two columns when the demo itself is wide enough, so a phone-width frame stacks them.
|
|
344
|
+
<div className="@container w-full max-w-3xl">
|
|
345
|
+
<div className="grid gap-6 @xl:grid-cols-2">
|
|
346
|
+
<Field invalid={tooShort}>
|
|
347
|
+
<FieldLabel>Hand-over note</FieldLabel>
|
|
348
|
+
<Mentions triggers={looks}>
|
|
349
|
+
<Textarea value={note} onChange={(event) => setNote(event.currentTarget.value)} />
|
|
350
|
+
</Mentions>
|
|
351
|
+
{tooShort ? (
|
|
352
|
+
<FieldError match>Say what is left to do, not only who takes it.</FieldError>
|
|
353
|
+
) : (
|
|
354
|
+
<FieldDescription>Type @ for the person who takes it over.</FieldDescription>
|
|
355
|
+
)}
|
|
356
|
+
</Field>
|
|
357
|
+
<Field disabled>
|
|
358
|
+
<FieldLabel>Review note</FieldLabel>
|
|
359
|
+
<Mentions triggers={looks} disabled>
|
|
360
|
+
<Textarea defaultValue="Signed off by @jonas, see #398." />
|
|
361
|
+
</Mentions>
|
|
362
|
+
<FieldDescription>Closed with the review.</FieldDescription>
|
|
363
|
+
</Field>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## How mentions look
|
|
371
|
+
|
|
372
|
+
A picked mention stays marked. Each trigger sets its `appearance`:
|
|
373
|
+
|
|
374
|
+
- `"chip"` — a raised key hugging the text, 5px corners, in the control material. The default for `@`.
|
|
375
|
+
- `"text"` — the text in a medium weight. The default for other triggers.
|
|
376
|
+
- `"none"` — plain text, as typed.
|
|
377
|
+
|
|
378
|
+
`tone` gives a trigger a category tone — a chip's 10% tint in a 30% edge, or the text's ink.
|
|
379
|
+
|
|
380
|
+
A mention is the text a pick inserted ("@mira", without the trailing space), from a word start to a word end, and moves with the text. Editing it or typing a letter right after makes it plain; undo, or retyping or pasting the same text, restores it. A pick that inserts something else (a Markdown block, nothing) is not a mention. For mentions nobody picked — the initial value, a paste, a typed handle — give the trigger a `pattern`, matched at word starts only.
|
|
381
|
+
|
|
382
|
+
### Choosing a look
|
|
383
|
+
|
|
384
|
+
Start in the ink — shape and trigger character mark a mention. Use a tone only when kinds must be told apart at a glance, one per kind, never per person. A good pairing: people as ink chips, channels blue text, commands violet text.
|
|
385
|
+
|
|
386
|
+
```tsx
|
|
387
|
+
const triggers: MentionsTrigger<any>[] = [
|
|
388
|
+
{ char: "@", items: people, appearance: "chip" }, // in the ink: the kind that matters most is boxed
|
|
389
|
+
{ char: "#", items: channels, appearance: "text", tone: "blue" },
|
|
390
|
+
{ char: "/", items: commands, appearance: "text", tone: "violet" },
|
|
391
|
+
];
|
|
392
|
+
|
|
393
|
+
<Mentions triggers={triggers}>
|
|
394
|
+
<Textarea aria-label="Message" />
|
|
395
|
+
</Mentions>;
|
|
396
|
+
|
|
397
|
+
// The same looks where the message is only read:
|
|
398
|
+
<MentionToken trigger="@">@mira</MentionToken>
|
|
399
|
+
<MentionToken trigger="#" appearance="text" tone="blue">#launch</MentionToken>
|
|
400
|
+
<MentionToken trigger="/" appearance="text" tone="violet">/remind</MentionToken>
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### In text that is only read
|
|
404
|
+
|
|
405
|
+
`MentionToken`'s look lives in the stylesheet, on the span
|
|
406
|
+
|
|
407
|
+
```html
|
|
408
|
+
<span data-slot="mention" data-appearance="chip" data-tone="violet" data-trigger="/">/remind</span>
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
so any rich-text editor rendering that span gets it too. `data-tone` is omitted (or `default`) for the ink, or a tone name; `data-trigger` is for your own styles.
|
|
412
|
+
|
|
413
|
+
### How it is drawn in a field
|
|
414
|
+
|
|
415
|
+
A field can't style part of its text, so Mentions keeps an `aria-hidden` copy right behind it (`data-slot="mentions-highlight"`) with the same font, padding, wrapping, size and scroll, each mention in the span above. The field turns transparent (`data-mentions-highlight`) and the copy takes its fill. With only ink chips, the field draws its own text and the copy only the boxes; when a mention needs colour or weight, the field's letters go transparent (caret and selection stay) and the copy draws every letter — `text` heavier by a hairline stroke, chips' padding taken back by a margin, so no letter moves.
|
|
416
|
+
|
|
417
|
+
Limits: a value set from outside without an event or render (`field.value = …` in a timer) catches up on the next keystroke. The copy sits in the field's parent, gives a static field `position: relative`, and does not follow a transformed field. Under forced colours the system draws the text and the copy outlines mentions.
|
|
418
|
+
|
|
419
|
+
## Props
|
|
420
|
+
|
|
421
|
+
| Prop | Type | Default |
|
|
422
|
+
| -------------- | ------------------------------------------------------- | ---------- |
|
|
423
|
+
| `triggers` | `MentionsTrigger[]` | required |
|
|
424
|
+
| `children` | the field, or an element holding one | — |
|
|
425
|
+
| `inputRef` | `RefObject` to the field, or an element holding one | — |
|
|
426
|
+
| `onSelect` | `(item, { trigger, text }) => void` | — |
|
|
427
|
+
| `onOpenChange` | `(open: boolean) => void` | — |
|
|
428
|
+
| `disabled` | `boolean` | `false` |
|
|
429
|
+
| `side` | `"bottom" \| "top"`: before it flips | `"bottom"` |
|
|
430
|
+
| `sideOffset` | `number` | `6` |
|
|
431
|
+
| `positioner` | Base UI Positioner props (`collisionPadding` …) | — |
|
|
432
|
+
| `portal` | Base UI Portal props (`container`) | — |
|
|
433
|
+
| `labels` | `{ label?, loading?, empty?, results?: (n) => string }` | English |
|
|
434
|
+
| `className` | `string`: the popup | — |
|
|
435
|
+
|
|
436
|
+
A child gets a ref merged with its own; if it is a wrapper, the first textarea or text input inside is used. With `inputRef`, children render as they are. A `LocaleProvider` sets `labels` for every Mentions (`messages.mentions`).
|
|
437
|
+
|
|
438
|
+
### `MentionsTrigger`
|
|
439
|
+
|
|
440
|
+
| Prop | Type | Default |
|
|
441
|
+
| -------------- | ------------------------------------------------------------------------------ | ------------------------------- |
|
|
442
|
+
| `char` | `string`: `"@"`, `"#"`, `"/"`, `"::"` | required |
|
|
443
|
+
| `items` | `T[]`, or `(query, { signal }) => T[] \| Promise<T[]>` | required |
|
|
444
|
+
| `itemToString` | `(item) => string`: filtered by, inserted by default | `item.label`, or the item |
|
|
445
|
+
| `itemToKey` | `(item) => string` | `item.id`, or `itemToString` |
|
|
446
|
+
| `insert` | `(item) => string` | trigger + text + a space |
|
|
447
|
+
| `renderItem` | `(item) => ReactNode`: a row's content | icon, label, mono description |
|
|
448
|
+
| `onSelect` | `(item) => void` | — |
|
|
449
|
+
| `label` | `string`: the list's accessible name | `"Suggestions"` |
|
|
450
|
+
| `empty` | `ReactNode`, or `null` to close instead | `"No matches"` |
|
|
451
|
+
| `allowSpaces` | `boolean`: "@Ada Lov" stays one query | `false` |
|
|
452
|
+
| `maxLength` | `number`: the longest query looked for | `50` |
|
|
453
|
+
| `limit` | `number`: the most items shown | `50` |
|
|
454
|
+
| `debounce` | `number`: ms before a function source is called | `0` |
|
|
455
|
+
| `appearance` | `"chip" \| "text" \| "none"`: how its mentions look | `"chip"` for `@`, else `"text"` |
|
|
456
|
+
| `tone` | `"default" \| "blue" \| "aqua" \| "violet" \| "magenta" \| "orange" \| "lime"` | `"default"`, the ink |
|
|
457
|
+
| `pattern` | `RegExp`: text that is a mention though nobody picked it | — |
|
|
458
|
+
|
|
459
|
+
Lists are filtered ignoring case and accents — prefix matches first, then word starts, then anywhere. A function filters itself.
|
|
460
|
+
|
|
461
|
+
### `MentionsOption`
|
|
462
|
+
|
|
463
|
+
The item shape the default row knows: `id`, `label`, `description` (mono, at the end) and `icon`. Any item works with `itemToString` and `renderItem`.
|
|
464
|
+
|
|
465
|
+
### `MentionToken`
|
|
466
|
+
|
|
467
|
+
The same mark as a span, for read-only text. Children are the mention's text, trigger included.
|
|
468
|
+
|
|
469
|
+
| Prop | Type | Default |
|
|
470
|
+
| ------------ | ------------------------------------------------------------------------------ | -------------------- |
|
|
471
|
+
| `appearance` | `"chip" \| "text"` | `"chip"` |
|
|
472
|
+
| `tone` | `"default" \| "blue" \| "aqua" \| "violet" \| "magenta" \| "orange" \| "lime"` | `"default"`, the ink |
|
|
473
|
+
| `trigger` | `string`: written to `data-trigger` | — |
|
|
474
|
+
|
|
475
|
+
Other span props pass through. It does not wrap.
|
|
476
|
+
|
|
477
|
+
Data attributes: `data-slot="mentions-highlight"` on the copy behind the field, with `data-mode="box"` or `"ink"`, and `data-mentions-highlight` with the same value on the field; `data-slot="mention"` with `data-appearance`, `data-tone` and `data-trigger` on each mention. `data-slot="mentions-content"` on the popup, `mentions-list` on the listbox, `mentions-item` with `data-highlighted` on each option, `mentions-loading` and `mentions-empty` on those rows.
|
|
478
|
+
|
|
479
|
+
## Brand rules
|
|
480
|
+
|
|
481
|
+
- **Do** show what tells items apart: a name and a mono handle, a title and a mono issue number.
|
|
482
|
+
- **Do** insert something stable — a handle or an id — when the label could change.
|
|
483
|
+
- **Do** keep mentions in the ink unless kinds must be told apart; then one tone per kind, the same everywhere.
|
|
484
|
+
- **Don't** colour rows by kind. A small muted icon says what an item is.
|
|
485
|
+
- **Don't** give every trigger a chip. Box the one that matters most (people); let the rest be text.
|
|
486
|
+
- **Don't** make a trigger of a character people type mid-word; it only opens at a word start, so `ada@example.com` stays an address.
|
|
487
|
+
|
|
488
|
+
## Accessibility
|
|
489
|
+
|
|
490
|
+
- The field becomes a combobox (`role="combobox"`, `aria-autocomplete="list"`) with `aria-expanded`, `aria-controls` on the `listbox` and `aria-activedescendant` on the highlighted `option`, so screen readers read each option while focus stays in the text. Its own attributes return when Mentions unmounts or is disabled.
|
|
491
|
+
- A polite status reads the number of suggestions, "Loading…" or "No matches".
|
|
492
|
+
- Modified Enter passes through to the field, as does Enter with nothing to pick. Keys are handled before the field's `onKeyDown`, so a host's Enter-to-send doesn't fire on a pick; a host's `onKeyDownCapture` runs first and can check `onOpenChange`'s state.
|
|
493
|
+
- While an IME is composing, nothing is looked up and Enter confirms the composition.
|
|
494
|
+
- What is read is the field's text as typed; the copy is hidden. A mention is never marked by colour alone — it keeps its trigger character.
|
|
495
|
+
- A pick goes through the browser's editing, so one undo takes it back; failing that, the text is set and an `input` event dispatched for a controlled `onChange`.
|
|
496
|
+
- On a phone the list is at most 18rem, never wider than the screen, and flips above the line when the keyboard leaves no room.
|
|
497
|
+
|
|
498
|
+
### Keyboard
|
|
499
|
+
|
|
500
|
+
| Key | Does |
|
|
501
|
+
| ------------------- | -------------------------------------------------------------------------- |
|
|
502
|
+
| a trigger (`@`) | At a word start, opens the list under it |
|
|
503
|
+
| ↓ / ↑ | Moves the highlight, wrapping at the ends |
|
|
504
|
+
| Enter / Tab | Inserts the highlighted item in place of the trigger and query |
|
|
505
|
+
| Escape | Closes the list and keeps the text; it stays closed for that trigger |
|
|
506
|
+
| ⌘Z / Ctrl+Z | Takes a pick back |
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
- Import: `import { Mentions, MentionToken } from "@zonsh/ui"`
|
|
511
|
+
- Source: `packages/ui/src/components/mentions.tsx`
|
|
512
|
+
- Primitive: `@base-ui/react/popover` (Base UI docs: `node_modules/@base-ui/react/docs/react/components/popover.md`)
|