@zonsh/ui 0.5.0 → 0.6.1
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 +643 -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,327 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Private parts the Scheduler's timeline and calendar share: its words, the locale's week and date
|
|
4
|
+
* formats, how a span is said, and the classes a toned bar or event is drawn with.
|
|
5
|
+
*/
|
|
6
|
+
import { DAY, startOfDay } from "../lib/scheduler.js";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { Drawer, DrawerContent, DrawerHeader, DrawerTitle } from "./drawer.js";
|
|
9
|
+
import { Popover, PopoverContent } from "./popover.js";
|
|
10
|
+
import { cn } from "../lib/cn.js";
|
|
11
|
+
export const defaultMessages = {
|
|
12
|
+
zoom: "Zoom",
|
|
13
|
+
day: "Day",
|
|
14
|
+
week: "Week",
|
|
15
|
+
month: "Month",
|
|
16
|
+
today: "Today",
|
|
17
|
+
taskColumn: "Task",
|
|
18
|
+
resourceColumn: "Resource",
|
|
19
|
+
taskRole: "task",
|
|
20
|
+
bookingRole: "booking",
|
|
21
|
+
resizeList: "Resize the list",
|
|
22
|
+
instructions: "Left and right arrows move it. Shift with an arrow moves its end, Alt and Shift its start. Up and down go to the next item, Enter opens it.",
|
|
23
|
+
instructionsRows: "Left and right arrows move it. Shift with an arrow moves its end, Alt and Shift its start, Alt with up or down moves it to another row. Up and down go to the next item, Enter opens it.",
|
|
24
|
+
instructionsReadOnly: "Up and down go to the next item, Enter opens it.",
|
|
25
|
+
milestone: "Milestone",
|
|
26
|
+
progress: (percent) => `${percent}% done`,
|
|
27
|
+
locked: "Locked",
|
|
28
|
+
weekNumber: (week) => `W${week}`,
|
|
29
|
+
empty: "Nothing is scheduled yet.",
|
|
30
|
+
loading: "Loading the schedule",
|
|
31
|
+
pickedUp: (item, when) => `Picked up ${item}, ${when}.`,
|
|
32
|
+
moved: (item, when) => `${item} moved to ${when}.`,
|
|
33
|
+
movedRow: (item, row, when) => `${item} moved to ${row}, ${when}.`,
|
|
34
|
+
resized: (item, when) => `${item} now ${when}.`,
|
|
35
|
+
unchanged: (item, when) => `${item} stays ${when}.`,
|
|
36
|
+
cancelled: (item, when) => `Move cancelled. ${item} stays ${when}.`,
|
|
37
|
+
view: "View",
|
|
38
|
+
days: (count) => `${count} days`,
|
|
39
|
+
workWeek: "Work week",
|
|
40
|
+
timeline: "Timeline",
|
|
41
|
+
previous: "Previous",
|
|
42
|
+
next: "Next",
|
|
43
|
+
allDay: "All day",
|
|
44
|
+
eventRole: "event",
|
|
45
|
+
more: (count) => `+${count} more`,
|
|
46
|
+
bookingCount: (count) => (count === 1 ? "1 booking" : `${count} bookings`),
|
|
47
|
+
moreLabel: (count, day) => `${count} more on ${day}`,
|
|
48
|
+
showDay: (day) => `Show ${day}`,
|
|
49
|
+
instructionsTime: "Up and down arrows move it in time, left and right to another day. Shift with up or down moves its end, Alt and Shift its start. Tab goes to the next event, Enter opens it.",
|
|
50
|
+
instructionsDays: "Left and right arrows move it a day, up and down a week. Shift with left or right moves its end, Alt and Shift its start. Tab goes to the next event, Enter opens it.",
|
|
51
|
+
instructionsCalendarReadOnly: "Tab goes to the next event, Enter opens it.",
|
|
52
|
+
newItem: "New event",
|
|
53
|
+
creating: (when) => `New event, ${when}.`,
|
|
54
|
+
nothingOnDay: "Nothing on this day.",
|
|
55
|
+
newBooking: "New booking",
|
|
56
|
+
newTask: "New task",
|
|
57
|
+
editItem: (role) => `Edit ${role}`,
|
|
58
|
+
newEventHere: "New event here",
|
|
59
|
+
newBookingHere: "New booking here",
|
|
60
|
+
slotMenu: "Slot",
|
|
61
|
+
itemMenu: (item) => item,
|
|
62
|
+
edit: "Edit",
|
|
63
|
+
titleLabel: "Title",
|
|
64
|
+
dateLabel: "Date",
|
|
65
|
+
datesLabel: "Dates",
|
|
66
|
+
startLabel: "Starts",
|
|
67
|
+
endLabel: "Ends",
|
|
68
|
+
categoryLabel: "Category",
|
|
69
|
+
noCategory: "None",
|
|
70
|
+
toneName: (tone) => tone[0].toUpperCase() + tone.slice(1),
|
|
71
|
+
untitled: "Untitled",
|
|
72
|
+
timeMissing: "Fill in when it starts and ends.",
|
|
73
|
+
save: "Save",
|
|
74
|
+
cancel: "Cancel",
|
|
75
|
+
delete: "Delete",
|
|
76
|
+
rename: "Rename",
|
|
77
|
+
addTask: "Add task",
|
|
78
|
+
addRow: "Add row",
|
|
79
|
+
newRow: "New row",
|
|
80
|
+
addTaskTo: (group) => `Add task to ${group}`,
|
|
81
|
+
rowActions: (row) => `Actions for ${row}`,
|
|
82
|
+
rowName: "Name",
|
|
83
|
+
dependsOn: "Depends on",
|
|
84
|
+
linkHint: "Drag to another task to link",
|
|
85
|
+
linked: (from, to) => `${to} now waits for ${from}.`,
|
|
86
|
+
unlinked: (from, to) => `${to} no longer waits for ${from}.`,
|
|
87
|
+
created: (item, when) => `${item} added, ${when}.`,
|
|
88
|
+
saved: (item, when) => `${item} saved, ${when}.`,
|
|
89
|
+
deleted: (item) => `${item} deleted.`,
|
|
90
|
+
rowAdded: (row) => `${row} added.`,
|
|
91
|
+
rowDeleted: (row) => `${row} deleted.`,
|
|
92
|
+
};
|
|
93
|
+
/* ── Locale ────────────────────────────────────────────────────────────────── */
|
|
94
|
+
/** Regions whose weeks start on Sunday, for browsers without `Intl.Locale#getWeekInfo`. */
|
|
95
|
+
const SUNDAY_REGIONS = new Set([
|
|
96
|
+
"US",
|
|
97
|
+
"CA",
|
|
98
|
+
"MX",
|
|
99
|
+
"BR",
|
|
100
|
+
"JP",
|
|
101
|
+
"KR",
|
|
102
|
+
"TW",
|
|
103
|
+
"HK",
|
|
104
|
+
"IL",
|
|
105
|
+
"PH",
|
|
106
|
+
"IN",
|
|
107
|
+
"ZA",
|
|
108
|
+
"AU",
|
|
109
|
+
]);
|
|
110
|
+
/** The week's first day and its weekend days where `locale` is spoken. */
|
|
111
|
+
export function weekInfo(locale) {
|
|
112
|
+
try {
|
|
113
|
+
const loc = new Intl.Locale(locale ?? (typeof navigator !== "undefined" ? navigator.language : "en-US"));
|
|
114
|
+
const withInfo = loc;
|
|
115
|
+
const info = withInfo.getWeekInfo?.() ?? withInfo.weekInfo;
|
|
116
|
+
if (info)
|
|
117
|
+
return {
|
|
118
|
+
firstDay: (info.firstDay % 7),
|
|
119
|
+
weekend: info.weekend.map((d) => (d % 7)),
|
|
120
|
+
};
|
|
121
|
+
const region = loc.maximize().region ?? "";
|
|
122
|
+
return { firstDay: SUNDAY_REGIONS.has(region) ? 0 : 1, weekend: [6, 0] };
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return { firstDay: 1, weekend: [6, 0] };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export function formats(locale, hour12) {
|
|
129
|
+
// Wall time is read in UTC: the calendar fields are already the local ones.
|
|
130
|
+
const f = (options) => new Intl.DateTimeFormat(locale, { timeZone: "UTC", ...options });
|
|
131
|
+
const twelve = hour12 ??
|
|
132
|
+
/h1[12]/.test(new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hourCycle ?? "");
|
|
133
|
+
const clock = twelve ? { hourCycle: "h12" } : { hourCycle: "h23" };
|
|
134
|
+
return {
|
|
135
|
+
dayLong: f({ weekday: "short", day: "numeric", month: "short" }),
|
|
136
|
+
dayShort: f({ day: "numeric", month: "short" }),
|
|
137
|
+
weekday: f({ weekday: "short" }),
|
|
138
|
+
dayNumber: f({ day: "numeric" }),
|
|
139
|
+
month: f({ month: "long", year: "numeric" }),
|
|
140
|
+
hour: f(twelve ? { hour: "numeric", ...clock } : { hour: "2-digit", minute: "2-digit", ...clock }),
|
|
141
|
+
time: f({ hour: "numeric", minute: "2-digit", ...clock }),
|
|
142
|
+
dateTime: f({ day: "numeric", month: "short", hour: "numeric", minute: "2-digit", ...clock }),
|
|
143
|
+
dayTitle: f({ weekday: "long", day: "numeric", month: "long", year: "numeric" }),
|
|
144
|
+
rangeTitle: f({ day: "numeric", month: "short", year: "numeric" }),
|
|
145
|
+
dayFull: f({ weekday: "long", day: "numeric", month: "long" }),
|
|
146
|
+
hour12: twelve,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export function formatRange(format, a, b) {
|
|
150
|
+
try {
|
|
151
|
+
return format.formatRange(a, b);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
return `${format.format(a)} – ${format.format(b)}`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** A span as people say it: "Oct 5 – 9" for whole days (its end inclusive), times otherwise. */
|
|
158
|
+
export function describeSpan(fmt, span, milestone) {
|
|
159
|
+
const whole = span.start === startOfDay(span.start) && span.end === startOfDay(span.end);
|
|
160
|
+
if (milestone || span.end <= span.start)
|
|
161
|
+
return whole ? fmt.dayShort.format(span.start) : fmt.dateTime.format(span.start);
|
|
162
|
+
if (whole) {
|
|
163
|
+
const last = span.end - DAY;
|
|
164
|
+
return last <= span.start ? fmt.dayShort.format(span.start) : formatRange(fmt.dayShort, span.start, last);
|
|
165
|
+
}
|
|
166
|
+
return formatRange(fmt.dateTime, span.start, span.end);
|
|
167
|
+
}
|
|
168
|
+
/* ── Look ──────────────────────────────────────────────────────────────────── */
|
|
169
|
+
/* A coloured bar or event is a tint with a 1px edge of its colour and foreground text, like a Tag;
|
|
170
|
+
a bar's done part a stronger wash of the same. Spelled out per colour so Tailwind sees every class. */
|
|
171
|
+
export const toneClasses = {
|
|
172
|
+
success: "border-success/45 bg-success/12",
|
|
173
|
+
warning: "border-warning/45 bg-warning/12",
|
|
174
|
+
info: "border-info/45 bg-info/12",
|
|
175
|
+
destructive: "border-destructive/45 bg-destructive/12",
|
|
176
|
+
blue: "border-tone-blue/45 bg-tone-blue/12",
|
|
177
|
+
aqua: "border-tone-aqua/45 bg-tone-aqua/12",
|
|
178
|
+
violet: "border-tone-violet/45 bg-tone-violet/12",
|
|
179
|
+
magenta: "border-tone-magenta/45 bg-tone-magenta/12",
|
|
180
|
+
orange: "border-tone-orange/45 bg-tone-orange/12",
|
|
181
|
+
lime: "border-tone-lime/45 bg-tone-lime/12",
|
|
182
|
+
};
|
|
183
|
+
export const doneTones = {
|
|
184
|
+
success: "bg-success/22",
|
|
185
|
+
warning: "bg-warning/22",
|
|
186
|
+
info: "bg-info/22",
|
|
187
|
+
destructive: "bg-destructive/22",
|
|
188
|
+
blue: "bg-tone-blue/22",
|
|
189
|
+
aqua: "bg-tone-aqua/22",
|
|
190
|
+
violet: "bg-tone-violet/22",
|
|
191
|
+
magenta: "bg-tone-magenta/22",
|
|
192
|
+
orange: "bg-tone-orange/22",
|
|
193
|
+
lime: "bg-tone-lime/22",
|
|
194
|
+
};
|
|
195
|
+
/** A solid mark of the colour: a milestone's diamond, an event's dot or its edge. */
|
|
196
|
+
export const markTones = {
|
|
197
|
+
success: "bg-success",
|
|
198
|
+
warning: "bg-warning",
|
|
199
|
+
info: "bg-info",
|
|
200
|
+
destructive: "bg-destructive",
|
|
201
|
+
blue: "bg-tone-blue",
|
|
202
|
+
aqua: "bg-tone-aqua",
|
|
203
|
+
violet: "bg-tone-violet",
|
|
204
|
+
magenta: "bg-tone-magenta",
|
|
205
|
+
orange: "bg-tone-orange",
|
|
206
|
+
lime: "bg-tone-lime",
|
|
207
|
+
};
|
|
208
|
+
/** An item's colour as `--event`, for its stripe and its fill. Spelled out so Tailwind sees each. */
|
|
209
|
+
export const toneVars = {
|
|
210
|
+
success: "[--event:var(--success)]",
|
|
211
|
+
warning: "[--event:var(--warning)]",
|
|
212
|
+
info: "[--event:var(--info)]",
|
|
213
|
+
destructive: "[--event:var(--destructive)]",
|
|
214
|
+
blue: "[--event:var(--tone-blue)]",
|
|
215
|
+
aqua: "[--event:var(--tone-aqua)]",
|
|
216
|
+
violet: "[--event:var(--tone-violet)]",
|
|
217
|
+
magenta: "[--event:var(--tone-magenta)]",
|
|
218
|
+
orange: "[--event:var(--tone-orange)]",
|
|
219
|
+
lime: "[--event:var(--tone-lime)]",
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* A calendar event or a booking: a coloured one is a stripe of its colour on the leading edge over
|
|
223
|
+
* a 14% tint of it, mixed into the ground so it stays opaque where events overlap (a tint over a
|
|
224
|
+
* tint would show the one under it through); the past at half that. One without a colour sits in
|
|
225
|
+
* the raised material; a locked one flat in a dashed edge. In forced colours, where fills are
|
|
226
|
+
* dropped, every event keeps an edge in the text colour.
|
|
227
|
+
*/
|
|
228
|
+
export const eventLook = (o) => o.tone
|
|
229
|
+
? [
|
|
230
|
+
"border",
|
|
231
|
+
toneVars[o.tone],
|
|
232
|
+
o.past
|
|
233
|
+
? "bg-[color-mix(in_oklab,var(--event)_8%,var(--field-surface))] hover:bg-[color-mix(in_oklab,var(--event)_13%,var(--field-surface))]"
|
|
234
|
+
: "bg-[color-mix(in_oklab,var(--event)_14%,var(--field-surface))] hover:bg-[color-mix(in_oklab,var(--event)_20%,var(--field-surface))]",
|
|
235
|
+
"transition-[background-color] duration-(--duration-fade) ease-(--ease)",
|
|
236
|
+
!o.disabled && "border-transparent forced-colors:border-[CanvasText]",
|
|
237
|
+
o.disabled &&
|
|
238
|
+
"border-dashed border-[color-mix(in_oklab,var(--event)_45%,transparent)] forced-colors:border-[GrayText] forced-colors:text-[GrayText]",
|
|
239
|
+
]
|
|
240
|
+
.filter(Boolean)
|
|
241
|
+
.join(" ")
|
|
242
|
+
: o.disabled
|
|
243
|
+
? "border border-dashed border-field-edge bg-control-surface forced-colors:border-[GrayText] forced-colors:text-[GrayText]"
|
|
244
|
+
: cn("material-raised forced-colors:border-[CanvasText]",
|
|
245
|
+
// The past sits back: a flat fill, without the material's light from above.
|
|
246
|
+
o.past && "bg-none");
|
|
247
|
+
/** The stripe on an event's leading edge, in its colour. */
|
|
248
|
+
export const stripeClass = "pointer-events-none absolute inset-y-0 start-0 w-[3px] bg-(--event) forced-colors:bg-[CanvasText]";
|
|
249
|
+
export const clamp = (n, low, high) => Math.min(Math.max(n, low), high);
|
|
250
|
+
/* ── Details ───────────────────────────────────────────────────────────────── */
|
|
251
|
+
/** An item's details: a popover beside it, or a bottom drawer on a phone. */
|
|
252
|
+
export function SchedulerDetails({ narrow, item, anchor, onClose, labelledBy, side = "bottom", className, children, }) {
|
|
253
|
+
if (narrow)
|
|
254
|
+
return (_jsx(Drawer, { open: true, onOpenChange: (next) => !next && onClose(), children: _jsxs(DrawerContent, { children: [_jsx(DrawerHeader, { children: _jsx(DrawerTitle, { children: item.title }) }), _jsx("div", { className: "px-6 pb-6", children: children })] }) }));
|
|
255
|
+
return (_jsx(Popover, { open: true, onOpenChange: (next) => !next && onClose(), children: _jsx(PopoverContent, { "aria-label": labelledBy ? undefined : item.title, "aria-labelledby": labelledBy, side: side, align: "start", positioner: { anchor }, finalFocus: anchor, className: className, children: children }) }));
|
|
256
|
+
}
|
|
257
|
+
const CATEGORY_TONES = ["blue", "aqua", "violet", "magenta", "orange", "lime"];
|
|
258
|
+
/** The categories offered: the app's, or the category tones by name. */
|
|
259
|
+
export function categoriesOf(given, text) {
|
|
260
|
+
return given ?? CATEGORY_TONES.map((tone) => ({ id: tone, label: text.toneName(tone), tone }));
|
|
261
|
+
}
|
|
262
|
+
/** An item's category among those offered: its own, or the one of its tone. */
|
|
263
|
+
export function categoryOf(item, categories) {
|
|
264
|
+
if (item.category && categories.some((c) => c.id === item.category))
|
|
265
|
+
return item.category;
|
|
266
|
+
return categories.find((c) => c.tone === item.tone)?.id;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* The item the editor saves: the one it was opened on (or a new one, `id`) with the new words, time,
|
|
270
|
+
* row and category. A category gives its tone; with the app's own categories, its id too.
|
|
271
|
+
*/
|
|
272
|
+
export function editedItem(base, id, state, value, categories, given) {
|
|
273
|
+
const item = { ...(base ?? {}), id, title: value.title, start: value.start, end: value.end };
|
|
274
|
+
if (value.row !== undefined)
|
|
275
|
+
item.row = value.row;
|
|
276
|
+
if (state.kind === "event") {
|
|
277
|
+
if (value.allDay)
|
|
278
|
+
item.allDay = true;
|
|
279
|
+
else if (base?.allDay)
|
|
280
|
+
item.allDay = false;
|
|
281
|
+
}
|
|
282
|
+
const category = categories.find((c) => c.id === value.category);
|
|
283
|
+
if (category) {
|
|
284
|
+
item.tone = category.tone;
|
|
285
|
+
if (given)
|
|
286
|
+
item.category = category.id;
|
|
287
|
+
else
|
|
288
|
+
delete item.category;
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
delete item.tone;
|
|
292
|
+
delete item.category;
|
|
293
|
+
}
|
|
294
|
+
return item;
|
|
295
|
+
}
|
|
296
|
+
export function editorHeading(text, kind, isNew) {
|
|
297
|
+
if (isNew)
|
|
298
|
+
return kind === "booking" ? text.newBooking : kind === "task" ? text.newTask : text.newItem;
|
|
299
|
+
return text.editItem(kind === "booking" ? text.bookingRole : kind === "task" ? text.taskRole : text.eventRole);
|
|
300
|
+
}
|
|
301
|
+
/** An id for a new item or row. */
|
|
302
|
+
export const newId = () => typeof crypto !== "undefined" && "randomUUID" in crypto
|
|
303
|
+
? crypto.randomUUID()
|
|
304
|
+
: `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
305
|
+
// The editor needs react-day-picker and date-fns (its days are DatePickers); the menus do not, so
|
|
306
|
+
// they load on their own and a scheduler without those libraries still opens them.
|
|
307
|
+
const loadEditor = () => import("./_scheduler-editor.js");
|
|
308
|
+
const loadMenu = () => import("./_scheduler-menu.js");
|
|
309
|
+
/** Starts loading the editor and the menus, so the first one opens at once. */
|
|
310
|
+
export const preloadEditor = () => {
|
|
311
|
+
void loadMenu().catch(() => { });
|
|
312
|
+
void loadEditor().catch(() => { });
|
|
313
|
+
};
|
|
314
|
+
const LazyEditor = React.lazy(() => loadEditor().then((m) => ({ default: m.SchedulerEditor })));
|
|
315
|
+
const LazyMenu = React.lazy(() => loadMenu().then((m) => ({ default: m.SchedulerMenu })));
|
|
316
|
+
/** A menu of a slot, an item or a row: at a point, or beside an element. Loaded when first opened. */
|
|
317
|
+
export function SchedulerMenuHost(props) {
|
|
318
|
+
return (_jsx(React.Suspense, { fallback: null, children: _jsx(LazyMenu, { ...props }) }));
|
|
319
|
+
}
|
|
320
|
+
/** The editor, in a popover beside what it edits (a drawer on a phone). Loaded when first opened. */
|
|
321
|
+
export function SchedulerEditorHost({ narrow, state, anchor, text, hour12, rows, rowLabel, categories, onSave, onCancel, onDelete, side, }) {
|
|
322
|
+
const titleId = React.useId();
|
|
323
|
+
const heading = editorHeading(text, state.kind, !state.id);
|
|
324
|
+
return (_jsx(SchedulerDetails, { narrow: narrow, item: { title: heading }, anchor: anchor, onClose: onCancel, labelledBy: titleId, side: side, className: "w-80", children: _jsx(React.Suspense, { fallback: _jsx("div", { className: "h-64" }), children: _jsx(LazyEditor
|
|
325
|
+
// A new state is a new form.
|
|
326
|
+
, { kind: state.kind, isNew: !state.id, milestone: state.milestone, value: state.value, rows: rows, rowLabel: rowLabel, categories: categories, text: text, hour12: hour12, titleId: narrow ? undefined : titleId, onSave: onSave, onCancel: onCancel, onDelete: onDelete }, `${state.id ?? "new"}:${state.value.start.getTime()}`) }) }));
|
|
327
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/** The item shape the default row knows: any object with a `label`. */
|
|
4
|
+
export interface SuggestOption {
|
|
5
|
+
id?: string;
|
|
6
|
+
label: string;
|
|
7
|
+
/** A short hint at the end of the row, in mono: a handle, an issue number. */
|
|
8
|
+
description?: string;
|
|
9
|
+
/** An icon or a small avatar before the label. */
|
|
10
|
+
icon?: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/** Where a trigger's items come from: a list filtered for you, or a function of the query. */
|
|
13
|
+
export type SuggestSource<T> = readonly T[] | ((query: string, context: {
|
|
14
|
+
signal: AbortSignal;
|
|
15
|
+
}) => readonly T[] | Promise<readonly T[]>);
|
|
16
|
+
/** What the list needs of a trigger: Mentions' and the rich editor's share these. */
|
|
17
|
+
export interface SuggestTrigger<T = unknown> {
|
|
18
|
+
items: SuggestSource<T>;
|
|
19
|
+
itemToString?: (item: T) => string;
|
|
20
|
+
itemToKey?: (item: T) => string;
|
|
21
|
+
renderItem?: (item: T) => React.ReactNode;
|
|
22
|
+
label?: string;
|
|
23
|
+
empty?: React.ReactNode;
|
|
24
|
+
limit?: number;
|
|
25
|
+
debounce?: number;
|
|
26
|
+
}
|
|
27
|
+
/** An item's text: its `label`, or the item itself. */
|
|
28
|
+
export declare const suggestText: (item: unknown) => string;
|
|
29
|
+
/** A trigger's text of an item. */
|
|
30
|
+
export declare const suggestTextOf: (t: {
|
|
31
|
+
itemToString?: (item: any) => string;
|
|
32
|
+
} | undefined) => (item: unknown) => string;
|
|
33
|
+
/** A trigger's key of an item: `itemToKey`, its `id`, or its text. */
|
|
34
|
+
export declare const suggestKeyOf: (t: SuggestTrigger<any> | undefined, item: unknown) => string;
|
|
35
|
+
/**
|
|
36
|
+
* The results of a trigger for a query: a list ranked (label starts first, then a word start, then
|
|
37
|
+
* anywhere), or a function's, called after `debounce` and aborted when the query moves on. While a
|
|
38
|
+
* new query loads, the last results stay up, so the list doesn't flicker.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useSuggestItems(trigger: SuggestTrigger<any> | undefined, index: number, query: string): {
|
|
41
|
+
items: readonly unknown[];
|
|
42
|
+
pending: boolean;
|
|
43
|
+
hasItems: boolean;
|
|
44
|
+
showEmpty: boolean;
|
|
45
|
+
};
|
|
46
|
+
/** What the status says: "3 suggestions", "Loading…", "No matches", or nothing while closed. */
|
|
47
|
+
export declare function suggestAnnouncement(open: boolean, state: {
|
|
48
|
+
items: readonly unknown[];
|
|
49
|
+
pending: boolean;
|
|
50
|
+
showEmpty: boolean;
|
|
51
|
+
}, empty: React.ReactNode, words: {
|
|
52
|
+
results: (count: number) => string;
|
|
53
|
+
loading: string;
|
|
54
|
+
empty: string;
|
|
55
|
+
}): string;
|
|
56
|
+
/** A row of the list: 38px at 7px corners, raised when highlighted, as Menu's and Select's items. */
|
|
57
|
+
export declare const suggestOptionClass: string;
|
|
58
|
+
/** The default row: `icon`, `label` and `description` of a `SuggestOption`, or the item as text. */
|
|
59
|
+
export declare function SuggestDefaultItem({ item }: {
|
|
60
|
+
item: unknown;
|
|
61
|
+
}): React.JSX.Element;
|
|
62
|
+
export interface SuggestPopupProps {
|
|
63
|
+
open: boolean;
|
|
64
|
+
/** The caret's line, as a virtual element. */
|
|
65
|
+
anchor: {
|
|
66
|
+
getBoundingClientRect: () => DOMRect;
|
|
67
|
+
contextElement?: Element;
|
|
68
|
+
} | null;
|
|
69
|
+
/** The document whose body takes the live status: the field's. */
|
|
70
|
+
doc: Document | null | undefined;
|
|
71
|
+
/** Prefix of the parts' `data-slot`: `mentions` → `mentions-content`, `mentions-status`. */
|
|
72
|
+
slot: string;
|
|
73
|
+
/** What the polite status says. */
|
|
74
|
+
announce: string;
|
|
75
|
+
side?: "top" | "bottom";
|
|
76
|
+
sideOffset?: number;
|
|
77
|
+
dir?: string;
|
|
78
|
+
positioner?: Omit<BasePopover.Positioner.Props, "children" | "anchor">;
|
|
79
|
+
portal?: Omit<BasePopover.Portal.Props, "children">;
|
|
80
|
+
className?: string;
|
|
81
|
+
children: React.ReactNode;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The popup under the caret, in the menu material at 12px; it never takes focus, and pointing at
|
|
85
|
+
* it never takes focus from the field. At most 18rem wide and never wider than the screen, so it
|
|
86
|
+
* fits a phone; it flips above the line when there is no room below.
|
|
87
|
+
*/
|
|
88
|
+
export declare function SuggestPopup({ open, anchor, doc, slot, announce, side, sideOffset, dir, positioner, portal, className, children, }: SuggestPopupProps): React.JSX.Element;
|
|
89
|
+
export interface SuggestListProps<T> {
|
|
90
|
+
/** The listbox's id, which the field's `aria-controls` names; options are `${id}-${index}`. */
|
|
91
|
+
id: string;
|
|
92
|
+
label: string;
|
|
93
|
+
items: readonly T[];
|
|
94
|
+
/** The highlighted index, or -1. */
|
|
95
|
+
current: number;
|
|
96
|
+
onHighlight: (index: number) => void;
|
|
97
|
+
onPick: (item: T, index: number) => void;
|
|
98
|
+
renderItem: (item: T) => React.ReactNode;
|
|
99
|
+
itemKey: (item: T, index: number) => string;
|
|
100
|
+
/** Prefix of the parts' `data-slot`: `mentions` → `mentions-list`, `mentions-item`. */
|
|
101
|
+
slot: string;
|
|
102
|
+
busy?: boolean;
|
|
103
|
+
/** Attributes per option: `data-command` for a slash item. */
|
|
104
|
+
itemProps?: (item: T) => Record<string, string | undefined>;
|
|
105
|
+
/** The list's most height, before it scrolls. Default 18rem. */
|
|
106
|
+
maxHeight?: string;
|
|
107
|
+
}
|
|
108
|
+
/** The listbox of a suggestion popup. Keeps the highlighted option in view, within the list only. */
|
|
109
|
+
export declare function SuggestList<T>({ id, label, items, current, onHighlight, onPick, renderItem, itemKey, slot, busy, itemProps, maxHeight, }: SuggestListProps<T>): React.JSX.Element;
|
|
110
|
+
/** The row shown while an async source loads, with nothing to show yet. */
|
|
111
|
+
export declare function SuggestLoading({ slot, children }: {
|
|
112
|
+
slot: string;
|
|
113
|
+
children: React.ReactNode;
|
|
114
|
+
}): React.JSX.Element;
|
|
115
|
+
/** The row shown when nothing matches. */
|
|
116
|
+
export declare function SuggestEmpty({ slot, children }: {
|
|
117
|
+
slot: string;
|
|
118
|
+
children: React.ReactNode;
|
|
119
|
+
}): React.JSX.Element;
|
|
120
|
+
/**
|
|
121
|
+
* The results of a trigger, drawn: the list, or "Loading…" while it has none, or the empty text.
|
|
122
|
+
* The last open state stays drawn while the popup leaves.
|
|
123
|
+
*/
|
|
124
|
+
export declare function SuggestResults({ open, id, slot, trigger, state, current, onHighlight, onPick, words, }: {
|
|
125
|
+
open: boolean;
|
|
126
|
+
id: string;
|
|
127
|
+
slot: string;
|
|
128
|
+
trigger: SuggestTrigger<any> | undefined;
|
|
129
|
+
state: {
|
|
130
|
+
items: readonly unknown[];
|
|
131
|
+
pending: boolean;
|
|
132
|
+
showEmpty: boolean;
|
|
133
|
+
};
|
|
134
|
+
current: number;
|
|
135
|
+
onHighlight: (index: number) => void;
|
|
136
|
+
onPick: (item: unknown, index: number) => void;
|
|
137
|
+
words: {
|
|
138
|
+
label: string;
|
|
139
|
+
loading: string;
|
|
140
|
+
empty: string;
|
|
141
|
+
};
|
|
142
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* The one suggestion list under the caret, shared by `Mentions` (a textarea or an input) and the
|
|
4
|
+
* rich `MarkdownEditor` (its mention and slash lists): the results of a trigger — a list ranked
|
|
5
|
+
* for you, or a function of the query, sync or async — and the popup that shows them, in the menu
|
|
6
|
+
* material with 38px rows at 7px corners that lift when highlighted. The field keeps focus
|
|
7
|
+
* throughout: it points at the list with `aria-controls` and `aria-activedescendant`, and a polite
|
|
8
|
+
* status says how many there are, or that they are loading.
|
|
9
|
+
*
|
|
10
|
+
* Private (`_`): the hosts own the keys, the caret's anchor and what a pick does.
|
|
11
|
+
*/
|
|
12
|
+
import { Popover as BasePopover } from "@base-ui/react/popover";
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import { createPortal } from "react-dom";
|
|
15
|
+
import { cn, sx } from "../lib/cn.js";
|
|
16
|
+
import { rankItems } from "../lib/mentions.js";
|
|
17
|
+
import { Spinner } from "./spinner.js";
|
|
18
|
+
const NONE = [];
|
|
19
|
+
/** An item's text: its `label`, or the item itself. */
|
|
20
|
+
export const suggestText = (item) => item && typeof item === "object" && "label" in item ? String(item.label) : String(item);
|
|
21
|
+
/** A trigger's text of an item. */
|
|
22
|
+
export const suggestTextOf = (t) => (item) => t?.itemToString ? t.itemToString(item) : suggestText(item);
|
|
23
|
+
/** A trigger's key of an item: `itemToKey`, its `id`, or its text. */
|
|
24
|
+
export const suggestKeyOf = (t, item) => t?.itemToKey
|
|
25
|
+
? t.itemToKey(item)
|
|
26
|
+
: item && typeof item === "object" && "id" in item && item.id != null
|
|
27
|
+
? String(item.id)
|
|
28
|
+
: suggestTextOf(t)(item);
|
|
29
|
+
/**
|
|
30
|
+
* The results of a trigger for a query: a list ranked (label starts first, then a word start, then
|
|
31
|
+
* anywhere), or a function's, called after `debounce` and aborted when the query moves on. While a
|
|
32
|
+
* new query loads, the last results stay up, so the list doesn't flicker.
|
|
33
|
+
*/
|
|
34
|
+
export function useSuggestItems(trigger, index, query) {
|
|
35
|
+
const toText = React.useMemo(() => suggestTextOf(trigger), [trigger]);
|
|
36
|
+
const limit = trigger?.limit ?? 50;
|
|
37
|
+
const source = trigger?.items;
|
|
38
|
+
const listed = React.useMemo(() => (Array.isArray(source) ? rankItems(source, query, toText, limit) : null), [source, query, toText, limit]);
|
|
39
|
+
const [fetched, setFetched] = React.useState(null);
|
|
40
|
+
const [loading, setLoading] = React.useState(false);
|
|
41
|
+
const fetchKey = trigger && typeof source === "function" ? `${index}\u0000${query}` : null;
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (!fetchKey || typeof source !== "function") {
|
|
44
|
+
setLoading(false);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const controller = new AbortController();
|
|
48
|
+
let done = false;
|
|
49
|
+
const finish = (items) => {
|
|
50
|
+
done = true;
|
|
51
|
+
setFetched({ key: fetchKey, items: items.slice(0, limit) });
|
|
52
|
+
setLoading(false);
|
|
53
|
+
};
|
|
54
|
+
const go = () => {
|
|
55
|
+
let result;
|
|
56
|
+
try {
|
|
57
|
+
result = source(query, { signal: controller.signal });
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
result = [];
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(result) || typeof result?.then !== "function")
|
|
63
|
+
return finish(result ?? []);
|
|
64
|
+
setLoading(true);
|
|
65
|
+
result.then((items) => !controller.signal.aborted && finish(items), () => !controller.signal.aborted && finish([]));
|
|
66
|
+
};
|
|
67
|
+
const wait = trigger?.debounce ?? 0;
|
|
68
|
+
const timer = wait > 0 ? setTimeout(go, wait) : undefined;
|
|
69
|
+
if (wait > 0)
|
|
70
|
+
setLoading(true);
|
|
71
|
+
else
|
|
72
|
+
go();
|
|
73
|
+
return () => {
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
if (!done)
|
|
76
|
+
controller.abort();
|
|
77
|
+
};
|
|
78
|
+
// `source` and `trigger` change identity with the host's renders; the key says when to fetch.
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
}, [fetchKey]);
|
|
81
|
+
const items = listed ?? fetched?.items ?? NONE;
|
|
82
|
+
const pending = !listed && (loading || fetched?.key !== fetchKey);
|
|
83
|
+
const hasItems = items.length > 0;
|
|
84
|
+
const showEmpty = !!trigger && !hasItems && !pending && trigger.empty !== null;
|
|
85
|
+
return { items, pending, hasItems, showEmpty };
|
|
86
|
+
}
|
|
87
|
+
/** What the status says: "3 suggestions", "Loading…", "No matches", or nothing while closed. */
|
|
88
|
+
export function suggestAnnouncement(open, state, empty, words) {
|
|
89
|
+
if (!open)
|
|
90
|
+
return "";
|
|
91
|
+
if (state.items.length)
|
|
92
|
+
return words.results(state.items.length);
|
|
93
|
+
if (state.pending)
|
|
94
|
+
return words.loading;
|
|
95
|
+
if (state.showEmpty)
|
|
96
|
+
return typeof empty === "string" ? empty : words.empty;
|
|
97
|
+
return "";
|
|
98
|
+
}
|
|
99
|
+
/** A row of the list: 38px at 7px corners, raised when highlighted, as Menu's and Select's items. */
|
|
100
|
+
export const suggestOptionClass = cn("flex min-h-(--control-h) shrink-0 cursor-pointer items-center gap-2.5 rounded-item border border-transparent px-2.5 py-[clamp(0px,calc((var(--control-h)-22px)/2),6px)] text-sm text-foreground-soft outline-none select-none", "data-highlighted:border-control-inner-edge data-highlighted:bg-control-hover data-highlighted:text-foreground data-highlighted:shadow-highlight");
|
|
101
|
+
/** The default row: `icon`, `label` and `description` of a `SuggestOption`, or the item as text. */
|
|
102
|
+
export function SuggestDefaultItem({ item }) {
|
|
103
|
+
if (!item || typeof item !== "object" || !("label" in item))
|
|
104
|
+
return _jsx("span", { className: "min-w-0 flex-1 truncate", children: String(item) });
|
|
105
|
+
const { icon, label, description } = item;
|
|
106
|
+
return (_jsxs(_Fragment, { children: [icon != null && (_jsx("span", { "aria-hidden": true, "data-slot": "mentions-item-icon", className: "flex shrink-0 items-center text-muted-foreground [&_svg]:size-4", children: icon })), _jsx("span", { "data-slot": "mentions-item-label", className: "min-w-0 flex-1 truncate", children: label }), description && (_jsx("span", { "data-slot": "mentions-item-description", className: "max-w-[45%] shrink-0 truncate font-mono text-xs text-muted-foreground", children: description }))] }));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The popup under the caret, in the menu material at 12px; it never takes focus, and pointing at
|
|
110
|
+
* it never takes focus from the field. At most 18rem wide and never wider than the screen, so it
|
|
111
|
+
* fits a phone; it flips above the line when there is no room below.
|
|
112
|
+
*/
|
|
113
|
+
export function SuggestPopup({ open, anchor, doc, slot, announce, side = "bottom", sideOffset = 6, dir, positioner, portal, className, children, }) {
|
|
114
|
+
return (_jsxs(_Fragment, { children: [doc &&
|
|
115
|
+
createPortal(_jsx("span", { "data-slot": `${slot}-status`, role: "status", "aria-live": "polite", className: "sr-only", children: announce }), doc.body), _jsx(BasePopover.Root, { open: open, modal: false, children: _jsx(BasePopover.Portal, { ...portal, children: _jsx(BasePopover.Positioner, { anchor: anchor, side: side, align: "start", sideOffset: sideOffset, collisionPadding: 8, dir: dir, ...positioner, className: "z-50 outline-none", children: _jsx(BasePopover.Popup, { "data-slot": `${slot}-content`, role: "presentation", initialFocus: false, finalFocus: false, onMouseDown: (e) => e.preventDefault(), className: sx("w-72 max-w-(--available-width) popup-motion overflow-hidden rounded-button material-menu p-1 font-body outline-none", className), children: children }) }) }) })] }));
|
|
116
|
+
}
|
|
117
|
+
/** The listbox of a suggestion popup. Keeps the highlighted option in view, within the list only. */
|
|
118
|
+
export function SuggestList({ id, label, items, current, onHighlight, onPick, renderItem, itemKey, slot, busy, itemProps, maxHeight = "18rem", }) {
|
|
119
|
+
const list = React.useRef(null);
|
|
120
|
+
React.useEffect(() => {
|
|
121
|
+
const box = list.current;
|
|
122
|
+
const option = current >= 0 ? box?.querySelector(`[id="${id}-${current}"]`) : null;
|
|
123
|
+
if (!box || !option)
|
|
124
|
+
return;
|
|
125
|
+
const top = option.offsetTop;
|
|
126
|
+
const bottom = top + option.offsetHeight;
|
|
127
|
+
if (top < box.scrollTop)
|
|
128
|
+
box.scrollTop = top - 4;
|
|
129
|
+
else if (bottom > box.scrollTop + box.clientHeight)
|
|
130
|
+
box.scrollTop = bottom - box.clientHeight + 4;
|
|
131
|
+
}, [current, items, id]);
|
|
132
|
+
return (_jsx("div", { ref: list, id: id, role: "listbox", "aria-label": label, "aria-busy": busy || undefined, "data-slot": `${slot}-list`, className: "relative flex flex-col gap-px overflow-y-auto overscroll-contain", style: { maxHeight: `min(${maxHeight}, calc(var(--available-height) - 0.5rem))` }, children: items.map((item, i) => {
|
|
133
|
+
const highlighted = i === current;
|
|
134
|
+
return (_jsx("div", { id: `${id}-${i}`, role: "option", "aria-selected": highlighted, "data-slot": `${slot}-item`, "data-highlighted": highlighted ? "" : undefined, ...itemProps?.(item), onPointerMove: () => {
|
|
135
|
+
if (!highlighted)
|
|
136
|
+
onHighlight(i);
|
|
137
|
+
}, onClick: () => onPick(item, i), className: suggestOptionClass, children: renderItem(item) }, itemKey(item, i)));
|
|
138
|
+
}) }));
|
|
139
|
+
}
|
|
140
|
+
/** The row shown while an async source loads, with nothing to show yet. */
|
|
141
|
+
export function SuggestLoading({ slot, children }) {
|
|
142
|
+
return (_jsxs("div", { "data-slot": `${slot}-loading`, className: "flex min-h-(--control-h) items-center gap-2.5 px-2.5 text-sm text-muted-foreground", children: [_jsx(Spinner, { size: "sm", "aria-hidden": true }), children] }));
|
|
143
|
+
}
|
|
144
|
+
/** The row shown when nothing matches. */
|
|
145
|
+
export function SuggestEmpty({ slot, children }) {
|
|
146
|
+
return (_jsx("div", { "data-slot": `${slot}-empty`, className: "px-2.5 py-2.5 text-sm text-muted-foreground", children: children }));
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The results of a trigger, drawn: the list, or "Loading…" while it has none, or the empty text.
|
|
150
|
+
* The last open state stays drawn while the popup leaves.
|
|
151
|
+
*/
|
|
152
|
+
export function SuggestResults({ open, id, slot, trigger, state, current, onHighlight, onPick, words, }) {
|
|
153
|
+
const shown = React.useRef({ trigger, ...state, current });
|
|
154
|
+
if (open)
|
|
155
|
+
shown.current = { trigger, ...state, current };
|
|
156
|
+
const view = shown.current;
|
|
157
|
+
const t = view.trigger;
|
|
158
|
+
return (_jsxs(_Fragment, { children: [view.items.length > 0 && (_jsx(SuggestList, { id: id, label: t?.label ?? words.label, busy: view.pending, slot: slot, items: view.items, current: view.current, onHighlight: onHighlight, onPick: onPick, itemKey: (item, i) => `${suggestKeyOf(t, item)}\u0000${i}`, renderItem: (item) => (t?.renderItem ? t.renderItem(item) : _jsx(SuggestDefaultItem, { item: item })) })), view.items.length === 0 && view.pending && (_jsx(SuggestLoading, { slot: slot, children: words.loading })), view.items.length === 0 && !view.pending && view.showEmpty && (_jsx(SuggestEmpty, { slot: slot, children: t?.empty ?? words.empty }))] }));
|
|
159
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** What a foldable button tells the toolbar, to stand in for it in the "…" menu. */
|
|
3
|
+
export interface FoldEntry {
|
|
4
|
+
label: string;
|
|
5
|
+
icon: React.ReactNode;
|
|
6
|
+
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
/** `aria-pressed`: a toggle, shown as a checkbox item. */
|
|
9
|
+
pressed?: boolean;
|
|
10
|
+
shortcut?: string[];
|
|
11
|
+
priority: number;
|
|
12
|
+
}
|
|
13
|
+
export default function ToolbarMore({ items, label, host, className, }: {
|
|
14
|
+
items: {
|
|
15
|
+
id: string;
|
|
16
|
+
entry: React.RefObject<FoldEntry>;
|
|
17
|
+
}[];
|
|
18
|
+
label: string;
|
|
19
|
+
/** Where focus goes after the menu closes; the "…" button's own, without one. */
|
|
20
|
+
host: {
|
|
21
|
+
onMenuClose?: () => void;
|
|
22
|
+
} | null;
|
|
23
|
+
className: string;
|
|
24
|
+
}): React.JSX.Element | null;
|