@zonsh/ui 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +639 -0
- package/README.md +49 -21
- package/dist/brand.d.ts +3 -0
- package/dist/brand.js +7 -0
- package/dist/components/_breadcrumb-more.d.ts +6 -0
- package/dist/components/_breadcrumb-more.js +5 -0
- package/dist/components/_drawing-svg.d.ts +11 -0
- package/dist/components/_drawing-svg.js +30 -0
- package/dist/components/_media.d.ts +159 -0
- package/dist/components/_media.js +266 -0
- package/dist/components/_overlay.d.ts +8 -5
- package/dist/components/_overlay.js +11 -6
- package/dist/components/_scheduler-calendar.d.ts +71 -0
- package/dist/components/_scheduler-calendar.js +940 -0
- package/dist/components/_scheduler-editor.d.ts +29 -0
- package/dist/components/_scheduler-editor.js +111 -0
- package/dist/components/_scheduler-menu.d.ts +16 -0
- package/dist/components/_scheduler-menu.js +18 -0
- package/dist/components/_scheduler-parts.d.ts +164 -0
- package/dist/components/_scheduler-parts.js +327 -0
- package/dist/components/_suggest-list.d.ts +142 -0
- package/dist/components/_suggest-list.js +159 -0
- package/dist/components/_toolbar-more.d.ts +24 -0
- package/dist/components/_toolbar-more.js +25 -0
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +6 -6
- package/dist/components/action-sheet.d.ts +88 -0
- package/dist/components/action-sheet.js +124 -0
- package/dist/components/alert-dialog.js +3 -1
- package/dist/components/alert.d.ts +11 -18
- package/dist/components/alert.js +9 -6
- package/dist/components/app-bar.d.ts +93 -0
- package/dist/components/app-bar.js +175 -0
- package/dist/components/audio-player.d.ts +134 -0
- package/dist/components/audio-player.js +618 -0
- package/dist/components/avatar.d.ts +6 -6
- package/dist/components/avatar.js +13 -11
- package/dist/components/badge.d.ts +12 -12
- package/dist/components/badge.js +7 -5
- package/dist/components/bottom-nav.d.ts +53 -11
- package/dist/components/bottom-nav.js +388 -23
- package/dist/components/breadcrumb.d.ts +11 -2
- package/dist/components/breadcrumb.js +60 -6
- package/dist/components/button-group.js +5 -1
- package/dist/components/button.d.ts +23 -6
- package/dist/components/button.js +63 -7
- package/dist/components/calendar.js +8 -6
- package/dist/components/card.d.ts +10 -8
- package/dist/components/card.js +15 -14
- package/dist/components/carousel.d.ts +2 -2
- package/dist/components/carousel.js +21 -8
- package/dist/components/chart.d.ts +27 -1
- package/dist/components/chart.js +15 -5
- package/dist/components/checkbox.js +2 -2
- package/dist/components/code-block.d.ts +9 -2
- package/dist/components/code-block.js +26 -7
- package/dist/components/collapsible.js +3 -3
- package/dist/components/color-picker.d.ts +2 -2
- package/dist/components/color-picker.js +5 -5
- package/dist/components/combobox.d.ts +26 -7
- package/dist/components/combobox.js +32 -13
- package/dist/components/command.d.ts +29 -5
- package/dist/components/command.js +35 -10
- package/dist/components/context-menu.d.ts +5 -2
- package/dist/components/context-menu.js +24 -3
- package/dist/components/conversation.d.ts +1 -1
- package/dist/components/conversation.js +67 -13
- package/dist/components/copy-button.d.ts +1 -1
- package/dist/components/copy-button.js +1 -1
- package/dist/components/data-table.d.ts +6 -6
- package/dist/components/data-table.js +41 -15
- package/dist/components/date-picker.d.ts +31 -9
- package/dist/components/date-picker.js +100 -18
- package/dist/components/dialog.d.ts +17 -10
- package/dist/components/dialog.js +20 -13
- package/dist/components/drawer.d.ts +26 -8
- package/dist/components/drawer.js +75 -16
- package/dist/components/drawing.d.ts +25 -0
- package/dist/components/drawing.js +32 -0
- package/dist/components/empty.js +2 -2
- package/dist/components/feature-list.d.ts +65 -13
- package/dist/components/feature-list.js +116 -15
- package/dist/components/field.js +2 -2
- package/dist/components/file-drop.d.ts +9 -7
- package/dist/components/file-drop.js +8 -43
- package/dist/components/filter-bar.d.ts +10 -9
- package/dist/components/filter-bar.js +42 -25
- package/dist/components/graph.d.ts +19 -3
- package/dist/components/graph.js +170 -25
- package/dist/components/illustration.js +3 -28
- package/dist/components/input-group.d.ts +5 -10
- package/dist/components/input-group.js +16 -16
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +3 -3
- package/dist/components/item.d.ts +9 -6
- package/dist/components/item.js +13 -8
- package/dist/components/kbd.d.ts +1 -1
- package/dist/components/kbd.js +1 -1
- package/dist/components/lightbox.d.ts +76 -9
- package/dist/components/lightbox.js +333 -45
- package/dist/components/locale.d.ts +6 -6
- package/dist/components/logo.d.ts +21 -1
- package/dist/components/logo.js +32 -2
- package/dist/components/markdown-editor.d.ts +275 -0
- package/dist/components/markdown-editor.js +831 -0
- package/dist/components/mentions.d.ts +153 -0
- package/dist/components/mentions.js +507 -0
- package/dist/components/menu.d.ts +2 -1
- package/dist/components/menu.js +5 -4
- package/dist/components/menubar.d.ts +23 -5
- package/dist/components/menubar.js +97 -22
- package/dist/components/message.d.ts +62 -11
- package/dist/components/message.js +49 -13
- package/dist/components/meter.js +1 -1
- package/dist/components/money-input.d.ts +1 -1
- package/dist/components/money-input.js +1 -1
- package/dist/components/native-select.d.ts +2 -2
- package/dist/components/native-select.js +4 -4
- package/dist/components/navigation-menu.d.ts +3 -1
- package/dist/components/navigation-menu.js +23 -12
- package/dist/components/number-field.d.ts +2 -9
- package/dist/components/number-field.js +86 -36
- package/dist/components/number-roll.d.ts +26 -0
- package/dist/components/number-roll.js +81 -0
- package/dist/components/otp-field.d.ts +1 -1
- package/dist/components/otp-field.js +24 -3
- package/dist/components/pagination.d.ts +11 -3
- package/dist/components/pagination.js +59 -13
- package/dist/components/pdf-viewer.d.ts +1 -1
- package/dist/components/pdf-viewer.js +8 -8
- package/dist/components/phone-input.d.ts +1 -1
- package/dist/components/phone-input.js +2 -2
- package/dist/components/popover.js +5 -3
- package/dist/components/preview-card.d.ts +37 -2
- package/dist/components/preview-card.js +226 -2
- package/dist/components/progress.js +1 -1
- package/dist/components/prompt-input.d.ts +1 -1
- package/dist/components/prompt-input.js +24 -14
- package/dist/components/pull-to-refresh.d.ts +50 -0
- package/dist/components/pull-to-refresh.js +189 -0
- package/dist/components/quote.d.ts +6 -1
- package/dist/components/quote.js +3 -2
- package/dist/components/radio-group.js +1 -1
- package/dist/components/rating.d.ts +4 -1
- package/dist/components/rating.js +131 -10
- package/dist/components/reasoning.d.ts +1 -1
- package/dist/components/reasoning.js +7 -3
- package/dist/components/resizable.d.ts +1 -1
- package/dist/components/resizable.js +2 -2
- package/dist/components/response.d.ts +1 -1
- package/dist/components/response.js +18 -6
- package/dist/components/scheduler.d.ts +352 -0
- package/dist/components/scheduler.js +1717 -0
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/select.d.ts +17 -4
- package/dist/components/select.js +140 -9
- package/dist/components/separator.d.ts +1 -1
- package/dist/components/separator.js +3 -3
- package/dist/components/sidebar.d.ts +44 -3
- package/dist/components/sidebar.js +57 -17
- package/dist/components/site-header.d.ts +18 -13
- package/dist/components/site-header.js +23 -11
- package/dist/components/skeleton.d.ts +17 -7
- package/dist/components/skeleton.js +22 -7
- package/dist/components/slider.js +2 -2
- package/dist/components/sortable.d.ts +55 -4
- package/dist/components/sortable.js +172 -103
- package/dist/components/sources.d.ts +1 -1
- package/dist/components/sources.js +2 -2
- package/dist/components/spinner.d.ts +4 -4
- package/dist/components/spinner.js +4 -4
- package/dist/components/stat.d.ts +21 -4
- package/dist/components/stat.js +17 -8
- package/dist/components/stepper.d.ts +1 -1
- package/dist/components/stepper.js +8 -7
- package/dist/components/suggestions.d.ts +11 -3
- package/dist/components/suggestions.js +10 -4
- package/dist/components/swipe-actions.d.ts +66 -0
- package/dist/components/swipe-actions.js +292 -0
- package/dist/components/switch.js +1 -1
- package/dist/components/table.d.ts +12 -6
- package/dist/components/table.js +78 -30
- package/dist/components/tabs.js +7 -4
- package/dist/components/tag.d.ts +19 -20
- package/dist/components/tag.js +9 -5
- package/dist/components/tags-input.d.ts +2 -7
- package/dist/components/tags-input.js +11 -8
- package/dist/components/textarea.d.ts +3 -2
- package/dist/components/textarea.js +4 -3
- package/dist/components/theme.d.ts +49 -6
- package/dist/components/theme.js +147 -9
- package/dist/components/time-field.d.ts +4 -9
- package/dist/components/time-field.js +6 -6
- package/dist/components/timeline.d.ts +19 -3
- package/dist/components/timeline.js +21 -9
- package/dist/components/tippy.d.ts +17 -1
- package/dist/components/tippy.js +95 -15
- package/dist/components/toast.d.ts +2 -7
- package/dist/components/toast.js +12 -8
- package/dist/components/toggle-group.d.ts +7 -1
- package/dist/components/toggle-group.js +16 -5
- package/dist/components/toggle.d.ts +2 -2
- package/dist/components/toggle.js +3 -2
- package/dist/components/tool-call.d.ts +1 -1
- package/dist/components/tool-call.js +4 -4
- package/dist/components/toolbar.d.ts +57 -4
- package/dist/components/toolbar.js +216 -16
- package/dist/components/tooltip.d.ts +1 -1
- package/dist/components/tooltip.js +4 -2
- package/dist/components/tour.d.ts +1 -1
- package/dist/components/tour.js +36 -15
- package/dist/components/tree.js +5 -5
- package/dist/components/typography.d.ts +31 -8
- package/dist/components/typography.js +21 -10
- package/dist/components/video-player.d.ts +7 -2
- package/dist/components/video-player.js +121 -220
- package/dist/index.d.ts +99 -92
- package/dist/index.js +99 -92
- package/dist/lib/calendar.d.ts +153 -0
- package/dist/lib/calendar.js +312 -0
- package/dist/lib/cn.d.ts +3 -1
- package/dist/lib/cn.js +5 -0
- package/dist/lib/code-highlight.d.ts +14 -0
- package/dist/lib/code-highlight.js +81 -18
- package/dist/lib/drag.d.ts +39 -0
- package/dist/lib/drag.js +96 -0
- package/dist/lib/editorial-assets.js +16 -8
- package/dist/lib/figure/figures/automation.js +25 -6
- package/dist/lib/figure/figures/bar-chart.js +6 -1
- package/dist/lib/figure/figures/brackets-classic.js +4 -1
- package/dist/lib/figure/figures/city.js +12 -2
- package/dist/lib/figure/figures/conveyor.js +17 -4
- package/dist/lib/figure/figures/database.js +5 -2
- package/dist/lib/figure/figures/documents.js +11 -3
- package/dist/lib/figure/figures/inbox.js +5 -2
- package/dist/lib/figure/figures/laptop.js +3 -1
- package/dist/lib/figure/figures/pipeline.js +45 -10
- package/dist/lib/figure/figures/platform.js +62 -7
- package/dist/lib/figure/figures/server.js +21 -5
- package/dist/lib/figure/figures/spreadsheet.js +29 -5
- package/dist/lib/figure/kernel.d.ts +4 -2
- package/dist/lib/figure/kernel.js +10 -5
- package/dist/lib/figure/parts.js +6 -2
- package/dist/lib/files.d.ts +31 -0
- package/dist/lib/files.js +60 -0
- package/dist/lib/gesture.d.ts +70 -0
- package/dist/lib/gesture.js +141 -0
- package/dist/lib/glide.d.ts +5 -0
- package/dist/lib/glide.js +9 -1
- package/dist/lib/icons.d.ts +1 -0
- package/dist/lib/icons.js +6 -0
- package/dist/lib/illustration-library.js +1 -6
- package/dist/lib/markdown-edit.d.ts +112 -0
- package/dist/lib/markdown-edit.js +557 -0
- package/dist/lib/markdown-rich-editor.d.ts +188 -0
- package/dist/lib/markdown-rich-editor.js +1153 -0
- package/dist/lib/markdown-rich.d.ts +63 -0
- package/dist/lib/markdown-rich.js +534 -0
- package/dist/lib/mentions.d.ts +100 -0
- package/dist/lib/mentions.js +246 -0
- package/dist/lib/motion.d.ts +18 -0
- package/dist/lib/motion.js +43 -5
- package/dist/lib/number-roll.d.ts +89 -0
- package/dist/lib/number-roll.js +391 -0
- package/dist/lib/platform.d.ts +6 -0
- package/dist/lib/platform.js +14 -0
- package/dist/lib/portal-container.d.ts +9 -0
- package/dist/lib/portal-container.js +10 -0
- package/dist/lib/press.d.ts +5 -0
- package/dist/lib/press.js +186 -0
- package/dist/lib/scheduler.d.ts +128 -0
- package/dist/lib/scheduler.js +272 -0
- package/dist/lib/scroll-edges.d.ts +9 -0
- package/dist/lib/scroll-edges.js +50 -0
- package/dist/lib/table-fit.d.ts +1 -1
- package/dist/lib/table-fit.js +65 -8
- package/dist/lib/theme-preset.d.ts +267 -0
- package/dist/lib/theme-preset.js +1046 -0
- package/dist/lib/theme-script.d.ts +23 -3
- package/dist/lib/theme-script.js +17 -5
- package/dist/lib/tippy/sprite.d.ts +36 -4
- package/dist/lib/tippy/sprite.js +188 -15
- package/dist/lib/tone.d.ts +4 -0
- package/dist/lib/tone.js +1 -0
- package/dist/messages/de.d.ts +3 -3
- package/dist/messages/de.js +274 -3
- package/dist/skills/zon-ui/SKILL.md +279 -0
- package/dist/skills/zon-ui/references/authoring.md +265 -0
- package/dist/skills/zon-ui/references/brand.md +416 -0
- package/dist/skills/zon-ui/references/components/accordion.md +199 -0
- package/dist/skills/zon-ui/references/components/action-sheet.md +268 -0
- package/dist/skills/zon-ui/references/components/alert-dialog.md +276 -0
- package/dist/skills/zon-ui/references/components/alert.md +167 -0
- package/dist/skills/zon-ui/references/components/app-bar.md +307 -0
- package/dist/skills/zon-ui/references/components/ascii-field.md +121 -0
- package/dist/skills/zon-ui/references/components/aspect-ratio.md +112 -0
- package/dist/skills/zon-ui/references/components/audio-player.md +231 -0
- package/dist/skills/zon-ui/references/components/avatar.md +98 -0
- package/dist/skills/zon-ui/references/components/badge.md +227 -0
- package/dist/skills/zon-ui/references/components/bottom-nav.md +709 -0
- package/dist/skills/zon-ui/references/components/breadcrumb.md +143 -0
- package/dist/skills/zon-ui/references/components/button-group.md +216 -0
- package/dist/skills/zon-ui/references/components/button.md +309 -0
- package/dist/skills/zon-ui/references/components/calendar.md +296 -0
- package/dist/skills/zon-ui/references/components/card.md +158 -0
- package/dist/skills/zon-ui/references/components/carousel.md +297 -0
- package/dist/skills/zon-ui/references/components/chart.md +739 -0
- package/dist/skills/zon-ui/references/components/chat.md +417 -0
- package/dist/skills/zon-ui/references/components/checkbox.md +219 -0
- package/dist/skills/zon-ui/references/components/code-block.md +143 -0
- package/dist/skills/zon-ui/references/components/code-highlight.md +118 -0
- package/dist/skills/zon-ui/references/components/collapsible.md +146 -0
- package/dist/skills/zon-ui/references/components/color-picker.md +200 -0
- package/dist/skills/zon-ui/references/components/combobox.md +455 -0
- package/dist/skills/zon-ui/references/components/command.md +326 -0
- package/dist/skills/zon-ui/references/components/contact-form.md +562 -0
- package/dist/skills/zon-ui/references/components/context-menu.md +159 -0
- package/dist/skills/zon-ui/references/components/conversation.md +146 -0
- package/dist/skills/zon-ui/references/components/copy-button.md +162 -0
- package/dist/skills/zon-ui/references/components/crm.md +1022 -0
- package/dist/skills/zon-ui/references/components/dashboard.md +612 -0
- package/dist/skills/zon-ui/references/components/data-table.md +776 -0
- package/dist/skills/zon-ui/references/components/date-picker.md +444 -0
- package/dist/skills/zon-ui/references/components/dialog.md +335 -0
- package/dist/skills/zon-ui/references/components/direction.md +165 -0
- package/dist/skills/zon-ui/references/components/drawer.md +276 -0
- package/dist/skills/zon-ui/references/components/drawing.md +94 -0
- package/dist/skills/zon-ui/references/components/empty.md +225 -0
- package/dist/skills/zon-ui/references/components/feature-list.md +412 -0
- package/dist/skills/zon-ui/references/components/field.md +209 -0
- package/dist/skills/zon-ui/references/components/file-drop.md +234 -0
- package/dist/skills/zon-ui/references/components/filter-bar.md +485 -0
- package/dist/skills/zon-ui/references/components/form.md +970 -0
- package/dist/skills/zon-ui/references/components/graph.md +339 -0
- package/dist/skills/zon-ui/references/components/illustration.md +497 -0
- package/dist/skills/zon-ui/references/components/inbox.md +263 -0
- package/dist/skills/zon-ui/references/components/input-group.md +339 -0
- package/dist/skills/zon-ui/references/components/input.md +189 -0
- package/dist/skills/zon-ui/references/components/item.md +277 -0
- package/dist/skills/zon-ui/references/components/kanban.md +626 -0
- package/dist/skills/zon-ui/references/components/kbd.md +116 -0
- package/dist/skills/zon-ui/references/components/label.md +104 -0
- package/dist/skills/zon-ui/references/components/layout.md +291 -0
- package/dist/skills/zon-ui/references/components/lightbox.md +235 -0
- package/dist/skills/zon-ui/references/components/locale.md +279 -0
- package/dist/skills/zon-ui/references/components/logo.md +257 -0
- package/dist/skills/zon-ui/references/components/markdown-editor.md +558 -0
- package/dist/skills/zon-ui/references/components/mentions.md +512 -0
- package/dist/skills/zon-ui/references/components/menu.md +218 -0
- package/dist/skills/zon-ui/references/components/menubar.md +292 -0
- package/dist/skills/zon-ui/references/components/message.md +243 -0
- package/dist/skills/zon-ui/references/components/meter.md +105 -0
- package/dist/skills/zon-ui/references/components/money-input.md +333 -0
- package/dist/skills/zon-ui/references/components/native-select.md +197 -0
- package/dist/skills/zon-ui/references/components/navigation-menu.md +253 -0
- package/dist/skills/zon-ui/references/components/number-field.md +210 -0
- package/dist/skills/zon-ui/references/components/number-roll.md +175 -0
- package/dist/skills/zon-ui/references/components/onboarding.md +896 -0
- package/dist/skills/zon-ui/references/components/otp-field.md +166 -0
- package/dist/skills/zon-ui/references/components/pagination.md +109 -0
- package/dist/skills/zon-ui/references/components/pdf-viewer.md +177 -0
- package/dist/skills/zon-ui/references/components/phone-input.md +252 -0
- package/dist/skills/zon-ui/references/components/popover.md +176 -0
- package/dist/skills/zon-ui/references/components/preview-card.md +193 -0
- package/dist/skills/zon-ui/references/components/pricing.md +724 -0
- package/dist/skills/zon-ui/references/components/progress.md +92 -0
- package/dist/skills/zon-ui/references/components/prompt-input.md +307 -0
- package/dist/skills/zon-ui/references/components/pull-to-refresh.md +188 -0
- package/dist/skills/zon-ui/references/components/quote.md +115 -0
- package/dist/skills/zon-ui/references/components/radio-group.md +215 -0
- package/dist/skills/zon-ui/references/components/rating.md +260 -0
- package/dist/skills/zon-ui/references/components/reasoning.md +102 -0
- package/dist/skills/zon-ui/references/components/resizable.md +213 -0
- package/dist/skills/zon-ui/references/components/response.md +170 -0
- package/dist/skills/zon-ui/references/components/scheduler.md +732 -0
- package/dist/skills/zon-ui/references/components/scroll-area.md +122 -0
- package/dist/skills/zon-ui/references/components/select.md +351 -0
- package/dist/skills/zon-ui/references/components/separator.md +103 -0
- package/dist/skills/zon-ui/references/components/settings.md +793 -0
- package/dist/skills/zon-ui/references/components/shop.md +1715 -0
- package/dist/skills/zon-ui/references/components/sidebar.md +813 -0
- package/dist/skills/zon-ui/references/components/sign-in.md +1639 -0
- package/dist/skills/zon-ui/references/components/site-header.md +303 -0
- package/dist/skills/zon-ui/references/components/skeleton.md +256 -0
- package/dist/skills/zon-ui/references/components/slider.md +172 -0
- package/dist/skills/zon-ui/references/components/sortable.md +405 -0
- package/dist/skills/zon-ui/references/components/sources.md +106 -0
- package/dist/skills/zon-ui/references/components/spinner.md +222 -0
- package/dist/skills/zon-ui/references/components/stat.md +267 -0
- package/dist/skills/zon-ui/references/components/stepper.md +285 -0
- package/dist/skills/zon-ui/references/components/suggestions.md +146 -0
- package/dist/skills/zon-ui/references/components/swipe-actions.md +344 -0
- package/dist/skills/zon-ui/references/components/switch.md +160 -0
- package/dist/skills/zon-ui/references/components/table.md +999 -0
- package/dist/skills/zon-ui/references/components/tabs.md +258 -0
- package/dist/skills/zon-ui/references/components/tag.md +115 -0
- package/dist/skills/zon-ui/references/components/tags-input.md +216 -0
- package/dist/skills/zon-ui/references/components/textarea.md +95 -0
- package/dist/skills/zon-ui/references/components/theme-editor.md +3940 -0
- package/dist/skills/zon-ui/references/components/theme.md +362 -0
- package/dist/skills/zon-ui/references/components/time-field.md +222 -0
- package/dist/skills/zon-ui/references/components/timeline.md +285 -0
- package/dist/skills/zon-ui/references/components/tippy.md +243 -0
- package/dist/skills/zon-ui/references/components/toast.md +220 -0
- package/dist/skills/zon-ui/references/components/toggle-group.md +261 -0
- package/dist/skills/zon-ui/references/components/toggle.md +167 -0
- package/dist/skills/zon-ui/references/components/tool-call.md +146 -0
- package/dist/skills/zon-ui/references/components/toolbar.md +260 -0
- package/dist/skills/zon-ui/references/components/tooltip.md +172 -0
- package/dist/skills/zon-ui/references/components/tour.md +423 -0
- package/dist/skills/zon-ui/references/components/tree.md +481 -0
- package/dist/skills/zon-ui/references/components/typography.md +347 -0
- package/dist/skills/zon-ui/references/components/video-player.md +386 -0
- package/dist/skills/zon-ui/references/marketing.md +467 -0
- package/dist/skills/zon-ui/references/motion.md +455 -0
- package/dist/skills/zon-ui/references/recipes.md +1232 -0
- package/dist/skills/zon-ui/references/tokens.md +866 -0
- package/dist/sources/accordion.css +4 -0
- package/dist/sources/action-sheet.css +11 -0
- package/dist/sources/alert-dialog.css +6 -0
- package/dist/sources/alert.css +3 -0
- package/dist/sources/app-bar.css +14 -0
- package/dist/sources/ascii-field.css +3 -0
- package/dist/sources/aspect-ratio.css +3 -0
- package/dist/sources/audio-player.css +20 -0
- package/dist/sources/avatar.css +3 -0
- package/dist/sources/badge.css +3 -0
- package/dist/sources/bottom-nav.css +9 -0
- package/dist/sources/breadcrumb.css +14 -0
- package/dist/sources/button-group.css +3 -0
- package/dist/sources/button.css +9 -0
- package/dist/sources/calendar.css +13 -0
- package/dist/sources/card.css +3 -0
- package/dist/sources/carousel.css +11 -0
- package/dist/sources/chart.css +5 -0
- package/dist/sources/checkbox.css +6 -0
- package/dist/sources/code-block.css +13 -0
- package/dist/sources/collapsible.css +4 -0
- package/dist/sources/color-picker.css +13 -0
- package/dist/sources/combobox.css +13 -0
- package/dist/sources/command.css +13 -0
- package/dist/sources/context-menu.css +12 -0
- package/dist/sources/conversation.css +10 -0
- package/dist/sources/copy-button.css +10 -0
- package/dist/sources/data-table.css +27 -0
- package/dist/sources/date-picker.css +20 -0
- package/dist/sources/dialog.css +9 -0
- package/dist/sources/direction.css +2 -0
- package/dist/sources/drawer.css +9 -0
- package/dist/sources/drawing.css +5 -0
- package/dist/sources/empty.css +3 -0
- package/dist/sources/feature-list.css +4 -0
- package/dist/sources/field.css +4 -0
- package/dist/sources/file-drop.css +15 -0
- package/dist/sources/filter-bar.css +30 -0
- package/dist/sources/form.css +4 -0
- package/dist/sources/graph.css +19 -0
- package/dist/sources/illustration.css +28 -0
- package/dist/sources/input-group.css +7 -0
- package/dist/sources/input.css +3 -0
- package/dist/sources/item.css +4 -0
- package/dist/sources/kbd.css +5 -0
- package/dist/sources/label.css +3 -0
- package/dist/sources/layout.css +3 -0
- package/dist/sources/lightbox.css +33 -0
- package/dist/sources/locale.css +2 -0
- package/dist/sources/logo.css +4 -0
- package/dist/sources/markdown-editor.css +41 -0
- package/dist/sources/mentions.css +13 -0
- package/dist/sources/menu.css +11 -0
- package/dist/sources/menubar.css +14 -0
- package/dist/sources/message.css +16 -0
- package/dist/sources/meter.css +4 -0
- package/dist/sources/money-input.css +10 -0
- package/dist/sources/native-select.css +4 -0
- package/dist/sources/navigation-menu.css +8 -0
- package/dist/sources/number-field.css +8 -0
- package/dist/sources/number-roll.css +6 -0
- package/dist/sources/otp-field.css +5 -0
- package/dist/sources/pagination.css +11 -0
- package/dist/sources/pdf-viewer.css +30 -0
- package/dist/sources/phone-input.css +20 -0
- package/dist/sources/popover.css +7 -0
- package/dist/sources/preview-card.css +7 -0
- package/dist/sources/progress.css +4 -0
- package/dist/sources/prompt-input.css +15 -0
- package/dist/sources/pull-to-refresh.css +14 -0
- package/dist/sources/quote.css +3 -0
- package/dist/sources/radio-group.css +5 -0
- package/dist/sources/rating.css +6 -0
- package/dist/sources/reasoning.css +6 -0
- package/dist/sources/resizable.css +4 -0
- package/dist/sources/response.css +16 -0
- package/dist/sources/scheduler.css +44 -0
- package/dist/sources/scroll-area.css +3 -0
- package/dist/sources/select.css +12 -0
- package/dist/sources/separator.css +3 -0
- package/dist/sources/sidebar.css +19 -0
- package/dist/sources/site-header.css +15 -0
- package/dist/sources/skeleton.css +3 -0
- package/dist/sources/slider.css +6 -0
- package/dist/sources/sortable.css +12 -0
- package/dist/sources/sources.css +6 -0
- package/dist/sources/spinner.css +6 -0
- package/dist/sources/stat.css +9 -0
- package/dist/sources/stepper.css +6 -0
- package/dist/sources/suggestions.css +10 -0
- package/dist/sources/swipe-actions.css +20 -0
- package/dist/sources/switch.css +5 -0
- package/dist/sources/table.css +7 -0
- package/dist/sources/tabs.css +5 -0
- package/dist/sources/tag.css +3 -0
- package/dist/sources/tags-input.css +6 -0
- package/dist/sources/textarea.css +3 -0
- package/dist/sources/theme.css +13 -0
- package/dist/sources/time-field.css +7 -0
- package/dist/sources/timeline.css +7 -0
- package/dist/sources/tippy.css +6 -0
- package/dist/sources/toast.css +6 -0
- package/dist/sources/toggle-group.css +5 -0
- package/dist/sources/toggle.css +3 -0
- package/dist/sources/tool-call.css +16 -0
- package/dist/sources/toolbar.css +14 -0
- package/dist/sources/tooltip.css +6 -0
- package/dist/sources/tour.css +14 -0
- package/dist/sources/tree.css +6 -0
- package/dist/sources/typography.css +4 -0
- package/dist/sources/video-player.css +21 -0
- package/dist/styles/ai.css +3 -0
- package/dist/styles/brand.css +98 -0
- package/dist/styles/core.css +266 -0
- package/dist/styles/editor.css +3 -0
- package/dist/styles/expressive.css +35 -56
- package/dist/styles/fonts.css +61 -117
- package/dist/styles/graph.css +4 -0
- package/dist/styles/illustration.css +4 -0
- package/dist/styles/index.css +11 -201
- package/dist/styles/material.css +138 -12
- package/dist/styles/parts/ai.css +18 -13
- package/dist/styles/parts/brand.css +2 -2
- package/dist/styles/parts/controls.css +29 -20
- package/dist/styles/parts/data.css +13 -9
- package/dist/styles/parts/editor.css +372 -0
- package/dist/styles/parts/feedback.css +32 -2
- package/dist/styles/parts/foundations.css +12 -7
- package/dist/styles/parts/graph.css +25 -9
- package/dist/styles/parts/inputs.css +172 -9
- package/dist/styles/parts/isometric.css +6 -5
- package/dist/styles/parts/navigation.css +206 -27
- package/dist/styles/parts/overlays.css +19 -4
- package/dist/styles/parts/pdf.css +2 -2
- package/dist/styles/pdf.css +3 -0
- package/dist/styles/prose.css +3 -0
- package/dist/styles/tokens.css +89 -14
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +5 -0
- package/dist/vite.d.ts +48 -59
- package/dist/vite.js +54 -21
- package/package.json +69 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ The zon component library: React 19 components on Base UI, styled in the zon
|
|
|
4
4
|
material with Tailwind CSS v4. Monochrome, three typefaces, one motion curve.
|
|
5
5
|
|
|
6
6
|
```bash
|
|
7
|
-
npm install @zonsh/ui
|
|
7
|
+
npm install @zonsh/ui lucide-react
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
```css
|
|
@@ -18,33 +18,59 @@ import { Button, Dialog, DialogContent, DialogTrigger } from "@zonsh/ui";
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
The stylesheet points your Tailwind at the components' classes, so there is nothing to
|
|
21
|
-
configure. Requires React 19 and Tailwind CSS 4.1.15 or later.
|
|
21
|
+
configure. Requires React 19 and Tailwind CSS 4.1.15 or later. `lucide-react` is a peer
|
|
22
|
+
dependency: the components draw their icons with it and every example imports its icons from
|
|
23
|
+
it, so install it beside the library (pnpm and Yarn don't let an app import a package it doesn't
|
|
24
|
+
list itself). Dark mode: add `.dark` to
|
|
22
25
|
`<html>` (see `ThemeProvider` and `themeScript`).
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
`styles.css` is the design system on a plain `--background` page. zon.sh's own look, the still
|
|
28
|
+
grain and faint light on the page ground, is opt-in:
|
|
29
|
+
|
|
30
|
+
```css
|
|
31
|
+
@import "@zonsh/ui/brand.css"; /* after styles.css */
|
|
32
|
+
```
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
Vite, the plugin proxies them from zon.sh:
|
|
34
|
+
## Loading less CSS
|
|
28
35
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
To load less CSS, import the core, the parts your components need, and in place of scanning the whole package the sources of the components you import. A component's sources name the files it is built from:
|
|
37
|
+
|
|
38
|
+
```css
|
|
39
|
+
@import "tailwindcss";
|
|
40
|
+
@import "@zonsh/ui/styles/core.css";
|
|
41
|
+
@import "@zonsh/ui/styles/prose.css"; /* only if you use them: prose, ai, graph, pdf, editor, illustration */
|
|
42
|
+
@import "@zonsh/ui/sources/button.css"; /* one per component you import, named after its file */
|
|
43
|
+
@import "@zonsh/ui/sources/table.css";
|
|
33
44
|
```
|
|
34
45
|
|
|
35
|
-
|
|
46
|
+
The core holds the tokens, fonts, materials and every component's styles but those parts: `prose.css` (Prose, Code Block), `ai.css` (Prompt Input, Reasoning, Response, with `prose.css`), `graph.css` (Graph), `pdf.css` (PDF Viewer), `editor.css` (Markdown Editor) and `illustration.css` (Illustrations). `@zonsh/ui/brand.css` (zon.sh's page ground) goes after them, if you want it.
|
|
47
|
+
|
|
48
|
+
## Fonts
|
|
49
|
+
|
|
50
|
+
Licht, Licht Sans and Licht Mono come with the stylesheet: `@import "@zonsh/ui/styles.css"`
|
|
51
|
+
brings their `@font-face` rules from [`licht`](https://www.npmjs.com/package/licht),
|
|
52
|
+
a dependency, and your bundler (Vite, Next.js, anything that runs Tailwind) copies the WOFF2 files
|
|
53
|
+
into the build. They are served from your own origin, never hotlinked, and there is nothing to set
|
|
54
|
+
up. An app set up before 0.6.0 removes `zonFonts()` (from `@zonsh/ui/vite`, now gone) and any
|
|
55
|
+
`/licht/fonts` rewrite.
|
|
56
|
+
|
|
57
|
+
The build lists every cut of the three families, 52 WOFF2 files (about 1.4 MB; `LichtSerif-*` is
|
|
58
|
+
Licht, the headline face). That is disk, not page weight: a browser downloads only the cuts a page
|
|
59
|
+
sets, usually Licht Light, Licht Sans at two or three weights and Licht Mono Regular.
|
|
60
|
+
|
|
61
|
+
## Bundle size
|
|
62
|
+
|
|
63
|
+
A first Vite build of an app on the library often passes Vite's 500 kB chunk warning: Base UI,
|
|
64
|
+
React DOM and the components are most of it, about 200 kB gzipped for a plain app. That is
|
|
65
|
+
expected, not a mistake to fix by hand. Split the app's routes with `lazy()` and dynamic
|
|
66
|
+
`import()`, keep the heavy parts on their own entries (`@zonsh/ui/chart`, `/data-table`,
|
|
67
|
+
`/illustration` …), or raise `build.chunkSizeWarningLimit` once you have looked.
|
|
36
68
|
|
|
37
69
|
## Next.js
|
|
38
70
|
|
|
39
71
|
The components are client modules, so a server component renders them as they are. Make
|
|
40
72
|
`app/globals.css` just the two imports above (the template's own styles and Geist fonts would
|
|
41
|
-
override zon's)
|
|
42
|
-
|
|
43
|
-
```ts
|
|
44
|
-
async rewrites() {
|
|
45
|
-
return [{ source: "/licht/fonts/:path*", destination: "https://www.zon.sh/licht/fonts/:path*" }];
|
|
46
|
-
}
|
|
47
|
-
```
|
|
73
|
+
override zon's). Nothing goes in `next.config.ts`.
|
|
48
74
|
|
|
49
75
|
## Optional components
|
|
50
76
|
|
|
@@ -61,6 +87,7 @@ you use one; the package lists it as an optional peer dependency.
|
|
|
61
87
|
| `@zonsh/ui/filter-bar` | `react-day-picker` |
|
|
62
88
|
| `@zonsh/ui/graph` | `@xyflow/react` `@dagrejs/dagre` `d3-force` |
|
|
63
89
|
| `@zonsh/ui/pdf-viewer` | `pdfjs-dist` |
|
|
90
|
+
| `@zonsh/ui/markdown-editor` | `@tiptap/core` `@tiptap/pm` `@tiptap/react` `@tiptap/starter-kit` `@tiptap/extension-list` `@tiptap/extensions` `@tiptap/markdown` |
|
|
64
91
|
| `@zonsh/ui/resizable` | `react-resizable-panels` |
|
|
65
92
|
|
|
66
93
|
`@zonsh/ui/illustration` has its own path too, with nothing to add: its editorial images are
|
|
@@ -70,14 +97,15 @@ with the package and loads the first time a code block appears.
|
|
|
70
97
|
## Docs and agents
|
|
71
98
|
|
|
72
99
|
Every component, with live examples and the brand guide: [zon.sh/ui](https://zon.sh/ui). For
|
|
73
|
-
agents, the same docs come as [llms.txt](https://zon.sh/ui/llms.txt) and as
|
|
100
|
+
agents, the same docs come as [llms.txt](https://zon.sh/ui/llms.txt) and as a Claude skill inside
|
|
101
|
+
this package, at the version you installed:
|
|
74
102
|
|
|
75
103
|
```bash
|
|
76
|
-
|
|
104
|
+
cp -r node_modules/@zonsh/ui/dist/skills/zon-ui .claude/skills/
|
|
77
105
|
```
|
|
78
106
|
|
|
79
107
|
Versions: while the library is `0.x`, a minor release may break, always with a migration note in
|
|
80
|
-
the changelog, and a patch never does
|
|
81
|
-
|
|
108
|
+
the changelog, and a patch never does. From 1.0 on, only a major release breaks: a minor adds, and
|
|
109
|
+
what goes away is deprecated in a minor first and removed in the next major.
|
|
82
110
|
|
|
83
111
|
MIT licensed.
|
package/dist/brand.d.ts
ADDED
package/dist/brand.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// `@zonsh/ui/brand`: the zon brand's own pieces, apart from the components every product uses —
|
|
2
|
+
// the crescent mark and the lockup (`Logo`, `LogoMark`, the brackets) and `Wordmark`, the
|
|
3
|
+
// `AsciiField` hero backdrop, and Tippy, the mascot. Semver-stable like the rest, but zon's:
|
|
4
|
+
// a product of your own reaches for them only to show zon.
|
|
5
|
+
export * from "./components/logo.js";
|
|
6
|
+
export * from "./components/ascii-field.js";
|
|
7
|
+
export * from "./components/tippy.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Menu, MenuContent, MenuItem, MenuLinkItem, MenuTrigger } from "./menu.js";
|
|
3
|
+
export default function BreadcrumbMore({ items, label, className, }) {
|
|
4
|
+
return (_jsxs(Menu, { children: [_jsx(MenuTrigger, { "data-slot": "breadcrumb-more", "aria-label": label, className: className, children: "\u2026" }), _jsx(MenuContent, { className: "min-w-44", children: items.map((item, i) => item.href || item.render ? (_jsx(MenuLinkItem, { "data-slot": "breadcrumb-more-item", href: item.href, render: item.render, closeOnClick: true, children: item.label }, i)) : (_jsx(MenuItem, { "data-slot": "breadcrumb-more-item", disabled: true, children: item.label }, i))) })] }));
|
|
5
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type DrawCtx, type Drawing } from "../lib/illustration-drawings.js";
|
|
3
|
+
export declare function DrawingSvg({ name, draw, variant, title, className, style, }: {
|
|
4
|
+
/** The part of the library id after the slash: `horizon`. */
|
|
5
|
+
name: string;
|
|
6
|
+
draw: (ctx: DrawCtx) => Drawing;
|
|
7
|
+
variant: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { INLINE_INK } from "../lib/illustration-drawings.js";
|
|
5
|
+
// One library drawing as inline SVG: the `Drawing…` components and `Illustration` draw with it.
|
|
6
|
+
const reactAttr = (k) => k === "class"
|
|
7
|
+
? "className"
|
|
8
|
+
: /^(data|aria)-/.test(k)
|
|
9
|
+
? k
|
|
10
|
+
: k.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
11
|
+
function toReact(node, key) {
|
|
12
|
+
if (!node)
|
|
13
|
+
return null;
|
|
14
|
+
if (typeof node === "string")
|
|
15
|
+
return node;
|
|
16
|
+
if (Array.isArray(node))
|
|
17
|
+
return node.map((c, i) => toReact(c, i));
|
|
18
|
+
const props = { key };
|
|
19
|
+
for (const [k, v] of Object.entries(node.attrs)) {
|
|
20
|
+
if (v === undefined || v === null || v === false)
|
|
21
|
+
continue;
|
|
22
|
+
props[reactAttr(k)] = v;
|
|
23
|
+
}
|
|
24
|
+
return React.createElement(node.tag, props, ...node.children.map((c, i) => toReact(c, i)));
|
|
25
|
+
}
|
|
26
|
+
export function DrawingSvg({ name, draw, variant, title, className, style, }) {
|
|
27
|
+
const uid = `ep-${name}` + React.useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
28
|
+
const d = draw({ uid, ink: INLINE_INK, variant });
|
|
29
|
+
return (_jsxs("svg", { "data-slot": "illustration", "data-kind": "drawing", "data-name": `drawing/${name}`, "data-variant": variant, viewBox: d.viewBox, preserveAspectRatio: d.preserveAspectRatio ?? "xMidYMid meet", fill: "none", role: title ? "img" : undefined, "aria-label": title, "aria-hidden": title ? undefined : true, focusable: "false", className: cn("block h-auto max-h-full w-full select-none", className), style: style, children: [title && _jsx("title", { children: title }), d.body.map((c, i) => toReact(c, i))] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Button } from "./button.js";
|
|
3
|
+
/** The speed menu's rates. */
|
|
4
|
+
export declare const DEFAULT_SPEEDS: readonly [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
5
|
+
/** The scrubber's step (s). Its last value rounds to a step, so a drag to the end may land up to half a step short. */
|
|
6
|
+
export declare const SCRUB_STEP = 0.1;
|
|
7
|
+
/** How far the playhead moves before the controls show its new time (s): often enough for the eye, not every frame. */
|
|
8
|
+
export declare const TIME_STEP = 0.1;
|
|
9
|
+
/** 75 → "1:15", 3725 → "1:02:05". Anything not a positive, finite number is "0:00". */
|
|
10
|
+
export declare function formatTime(seconds: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* `count` values from `values`, each the largest magnitude in its share of them: raw samples
|
|
13
|
+
* into a waveform's peaks, or peaks into as many bars as there is room for. Fewer values than
|
|
14
|
+
* `count` repeat, so the bars still span the width. Non-finite values count as 0.
|
|
15
|
+
*/
|
|
16
|
+
export declare function bucketPeaks(values: ArrayLike<number>, count: number): number[];
|
|
17
|
+
/** The end of the buffered range the playhead is in. */
|
|
18
|
+
export declare function bufferedEnd(media: HTMLMediaElement): number;
|
|
19
|
+
/** Popups rendered into the player (in full screen), or at the end of `<body>`. */
|
|
20
|
+
export type Portal = {
|
|
21
|
+
container: React.RefObject<HTMLDivElement | null>;
|
|
22
|
+
} | undefined;
|
|
23
|
+
/** Where the playhead is, where the scrubber's thumb is being dragged to (else null), and how far the media has loaded. */
|
|
24
|
+
export interface Playhead {
|
|
25
|
+
time: number;
|
|
26
|
+
scrub: number | null;
|
|
27
|
+
buffered: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The playhead, kept outside React state. It moves ten times a second while the media plays, and
|
|
31
|
+
* only the parts that show it (the scrubber, the times, a segment's skip) follow it; the rest of
|
|
32
|
+
* the player doesn't redraw.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createPlayhead(): {
|
|
35
|
+
get: () => Playhead;
|
|
36
|
+
set(next: Partial<Playhead>): void;
|
|
37
|
+
subscribe(listener: () => void): () => void;
|
|
38
|
+
};
|
|
39
|
+
export type PlayheadStore = ReturnType<typeof createPlayhead>;
|
|
40
|
+
/** One value from the playhead: the component redraws when that value changes, not at every tick. */
|
|
41
|
+
export declare function usePlayhead<T>(playhead: PlayheadStore, select: (state: Playhead) => T): T;
|
|
42
|
+
/**
|
|
43
|
+
* At the end, or within a scrubber step of it, of media with a length that doesn't loop: decided
|
|
44
|
+
* by position, since a stream still fetching its last part doesn't know yet that it has ended.
|
|
45
|
+
*/
|
|
46
|
+
export declare const atEnd: (media: HTMLMediaElement) => boolean;
|
|
47
|
+
/** The players on the page, video and audio, that play with sound one at a time (`pauseOthers`). */
|
|
48
|
+
export declare const soundPlayers: Set<HTMLMediaElement>;
|
|
49
|
+
export declare const audible: (media: HTMLMediaElement) => boolean;
|
|
50
|
+
/** This player started with sound: the others that have sound pause. Muted ones play on. */
|
|
51
|
+
export declare function hushOthers(media: HTMLMediaElement): void;
|
|
52
|
+
/** The volume and mute stored under `volumeStorageKey`, when there are any and they're the player's own. */
|
|
53
|
+
export declare function readVolume(key: string): {
|
|
54
|
+
volume: number;
|
|
55
|
+
muted: boolean;
|
|
56
|
+
} | null;
|
|
57
|
+
export declare function writeVolume(key: string, volume: number, muted: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* The track and its thumb, shared by the scrubber and the volume. The same material as `Slider`,
|
|
60
|
+
* and like it in a contrast theme (Windows), which paints fills over with the page colour: the
|
|
61
|
+
* value takes the system highlight and the thumb an edge.
|
|
62
|
+
*/
|
|
63
|
+
export declare const trackClass = "relative h-1.5 w-full rounded-full material-field select-none";
|
|
64
|
+
export declare const indicatorClass = "rounded-full bg-foreground-soft select-none forced-color-adjust-none forced-colors:bg-[Highlight]";
|
|
65
|
+
export declare const thumbClass: string;
|
|
66
|
+
/** The words the shared parts say: the scrubber's name and value, and the volume's. */
|
|
67
|
+
export interface MediaLabels {
|
|
68
|
+
seek: string;
|
|
69
|
+
/** A length of time in words, for screen readers: "1 minute 15 seconds". */
|
|
70
|
+
duration: (seconds: number) => string;
|
|
71
|
+
/** The scrubber's value, from two `duration`s: "1 minute 15 seconds of 3 minutes". */
|
|
72
|
+
position: (time: string, total: string) => string;
|
|
73
|
+
mute: string;
|
|
74
|
+
unmute: string;
|
|
75
|
+
volume: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A round ghost button with its name in a tooltip. `popupClassName` themes the tooltip: `theme-dark`
|
|
79
|
+
* for controls over a picture, or the theme scope a player sits in, which a portalled popup leaves.
|
|
80
|
+
*/
|
|
81
|
+
export declare function MediaControl({ label, portal, popupClassName, children, ...props }: React.ComponentProps<typeof Button> & {
|
|
82
|
+
label: string;
|
|
83
|
+
portal?: Portal;
|
|
84
|
+
popupClassName?: string;
|
|
85
|
+
}): React.JSX.Element;
|
|
86
|
+
/** A control that opens a short list of choices — subtitles, audio, quality, speed — named by a tooltip. */
|
|
87
|
+
export declare function ChoiceMenu({ label, portal, popupClassName, trigger, value, onValueChange, options, onOpenChange, }: {
|
|
88
|
+
label: string;
|
|
89
|
+
portal?: Portal;
|
|
90
|
+
/** Themes the menu and its tooltip, as `MediaControl`'s. */
|
|
91
|
+
popupClassName?: string;
|
|
92
|
+
trigger: React.ReactElement;
|
|
93
|
+
value: string;
|
|
94
|
+
onValueChange: (value: string) => void;
|
|
95
|
+
options: {
|
|
96
|
+
value: string;
|
|
97
|
+
label: string;
|
|
98
|
+
detail?: string;
|
|
99
|
+
}[];
|
|
100
|
+
onOpenChange?: (open: boolean) => void;
|
|
101
|
+
}): React.JSX.Element;
|
|
102
|
+
/** The playhead's time, or the dragged thumb's, in Licht Mono: "1:15". It redraws once a second. */
|
|
103
|
+
export declare function MediaClock({ slot, playhead, className, }: {
|
|
104
|
+
/** The player's own slot, before `-time`. */
|
|
105
|
+
slot: string;
|
|
106
|
+
playhead: PlayheadStore;
|
|
107
|
+
className?: string;
|
|
108
|
+
}): React.JSX.Element;
|
|
109
|
+
/** Mute, and beside it a volume slider where there is a fine pointer and room for one. */
|
|
110
|
+
export declare function MediaVolume({ slot, labels, volume, muted, portal, popupClassName, size, large, className, sliderClassName, onToggleMute, onVolumeChange, }: {
|
|
111
|
+
slot: string;
|
|
112
|
+
labels: Pick<MediaLabels, "mute" | "unmute" | "volume">;
|
|
113
|
+
volume: number;
|
|
114
|
+
muted: boolean;
|
|
115
|
+
portal?: Portal;
|
|
116
|
+
popupClassName?: string;
|
|
117
|
+
size: "icon" | "icon-sm";
|
|
118
|
+
large?: boolean;
|
|
119
|
+
className?: string;
|
|
120
|
+
/** When the slider shows, and how wide it is: hidden unless this shows it. */
|
|
121
|
+
sliderClassName?: string;
|
|
122
|
+
onToggleMute: () => void;
|
|
123
|
+
/** A level from 0 to 1. */
|
|
124
|
+
onVolumeChange: (volume: number) => void;
|
|
125
|
+
}): React.JSX.Element;
|
|
126
|
+
/** A still of one moment above the timeline: a whole image, or one tile of a sprite sheet. */
|
|
127
|
+
export interface MediaPreview {
|
|
128
|
+
src: string;
|
|
129
|
+
width: number;
|
|
130
|
+
height: number;
|
|
131
|
+
x?: number;
|
|
132
|
+
y?: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The timeline: the part played, the buffered range, and the moment under the pointer, with its
|
|
136
|
+
* still where there are `previews`. Given `peaks`, the track is a waveform of bars: the played
|
|
137
|
+
* part in the foreground ink, the buffered part a step lighter, the rest muted. Left to right on
|
|
138
|
+
* any page, as a timeline runs: like the tape, not like the text.
|
|
139
|
+
*/
|
|
140
|
+
export declare function MediaScrubber({ slot, playhead, duration, labels, previews, peaks, dense, large, frameWidth, className, onSeek, onScrub, onStep, }: {
|
|
141
|
+
slot: string;
|
|
142
|
+
playhead: PlayheadStore;
|
|
143
|
+
duration: number;
|
|
144
|
+
labels: Pick<MediaLabels, "seek" | "duration" | "position">;
|
|
145
|
+
previews?: (time: number) => MediaPreview | undefined;
|
|
146
|
+
/** Draws the track as a waveform of these peaks, each from 0 to 1. */
|
|
147
|
+
peaks?: readonly number[];
|
|
148
|
+
/** The waveform at the dense size: 30px tall in all. */
|
|
149
|
+
dense?: boolean;
|
|
150
|
+
large?: boolean;
|
|
151
|
+
frameWidth?: number;
|
|
152
|
+
/** The times' text size. */
|
|
153
|
+
className?: string;
|
|
154
|
+
onSeek: (time: number) => void;
|
|
155
|
+
/** The thumb is dragged (or the track pressed) to a moment; null once it's let go. */
|
|
156
|
+
onScrub: (time: number | null) => void;
|
|
157
|
+
/** An arrow key's step, in seconds. */
|
|
158
|
+
onStep: (seconds: number) => void;
|
|
159
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Private building blocks shared by the media players (VideoPlayer, AudioPlayer): the playhead
|
|
4
|
+
* store, the time in Licht Mono, the scrubber with its buffered range and the time under the
|
|
5
|
+
* pointer, the volume, the round controls with their tooltips, the choice menus, and the rule that
|
|
6
|
+
* one player plays with sound at a time. The leading underscore keeps this file out of the
|
|
7
|
+
* generated index: nothing here is public API.
|
|
8
|
+
*/
|
|
9
|
+
import { Slider as BaseSlider } from "@base-ui/react/slider";
|
|
10
|
+
import { Volume1Icon, Volume2Icon, VolumeXIcon } from "../lib/icons.js";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { cn } from "../lib/cn.js";
|
|
13
|
+
import { Button } from "./button.js";
|
|
14
|
+
import { DirectionProvider } from "./direction.js";
|
|
15
|
+
import { Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuRadioGroup, MenuRadioItem, MenuTrigger, } from "./menu.js";
|
|
16
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
17
|
+
/** The speed menu's rates. */
|
|
18
|
+
export const DEFAULT_SPEEDS = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
19
|
+
/** The scrubber's step (s). Its last value rounds to a step, so a drag to the end may land up to half a step short. */
|
|
20
|
+
export const SCRUB_STEP = 0.1;
|
|
21
|
+
/** How far the playhead moves before the controls show its new time (s): often enough for the eye, not every frame. */
|
|
22
|
+
export const TIME_STEP = 0.1;
|
|
23
|
+
/** How wide a timeline preview shows: the normal and the large movie layout. */
|
|
24
|
+
const PREVIEW_WIDTH = 176;
|
|
25
|
+
const PREVIEW_WIDTH_LARGE = 256;
|
|
26
|
+
/** A waveform bar and the gap after it, in px: how many bars a scrubber of a given width draws. */
|
|
27
|
+
const BAR_PITCH = 3;
|
|
28
|
+
/** 75 → "1:15", 3725 → "1:02:05". Anything not a positive, finite number is "0:00". */
|
|
29
|
+
export function formatTime(seconds) {
|
|
30
|
+
const s = Number.isFinite(seconds) && seconds > 0 ? Math.floor(seconds) : 0;
|
|
31
|
+
const h = Math.floor(s / 3600);
|
|
32
|
+
const m = Math.floor((s % 3600) / 60);
|
|
33
|
+
const rest = String(s % 60).padStart(2, "0");
|
|
34
|
+
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${rest}` : `${m}:${rest}`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `count` values from `values`, each the largest magnitude in its share of them: raw samples
|
|
38
|
+
* into a waveform's peaks, or peaks into as many bars as there is room for. Fewer values than
|
|
39
|
+
* `count` repeat, so the bars still span the width. Non-finite values count as 0.
|
|
40
|
+
*/
|
|
41
|
+
export function bucketPeaks(values, count) {
|
|
42
|
+
const n = values.length;
|
|
43
|
+
const bars = Math.max(0, Math.floor(count));
|
|
44
|
+
if (n === 0 || bars === 0)
|
|
45
|
+
return [];
|
|
46
|
+
const out = new Array(bars);
|
|
47
|
+
for (let i = 0; i < bars; i++) {
|
|
48
|
+
const start = Math.floor((i * n) / bars);
|
|
49
|
+
const end = Math.max(start + 1, Math.floor(((i + 1) * n) / bars));
|
|
50
|
+
let peak = 0;
|
|
51
|
+
for (let j = start; j < end && j < n; j++) {
|
|
52
|
+
const v = Math.abs(values[j]);
|
|
53
|
+
if (Number.isFinite(v) && v > peak)
|
|
54
|
+
peak = v;
|
|
55
|
+
}
|
|
56
|
+
out[i] = peak;
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
/** The end of the buffered range the playhead is in. */
|
|
61
|
+
export function bufferedEnd(media) {
|
|
62
|
+
const { buffered, currentTime } = media;
|
|
63
|
+
for (let i = 0; i < buffered.length; i++) {
|
|
64
|
+
if (buffered.start(i) <= currentTime + 0.5 && currentTime <= buffered.end(i))
|
|
65
|
+
return buffered.end(i);
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
const PLAYHEAD_START = { time: 0, scrub: null, buffered: 0 };
|
|
70
|
+
/**
|
|
71
|
+
* The playhead, kept outside React state. It moves ten times a second while the media plays, and
|
|
72
|
+
* only the parts that show it (the scrubber, the times, a segment's skip) follow it; the rest of
|
|
73
|
+
* the player doesn't redraw.
|
|
74
|
+
*/
|
|
75
|
+
export function createPlayhead() {
|
|
76
|
+
let state = PLAYHEAD_START;
|
|
77
|
+
const listeners = new Set();
|
|
78
|
+
return {
|
|
79
|
+
get: () => state,
|
|
80
|
+
set(next) {
|
|
81
|
+
if (Object.keys(next).every((key) => next[key] === state[key]))
|
|
82
|
+
return;
|
|
83
|
+
state = { ...state, ...next };
|
|
84
|
+
for (const listener of listeners)
|
|
85
|
+
listener();
|
|
86
|
+
},
|
|
87
|
+
subscribe(listener) {
|
|
88
|
+
listeners.add(listener);
|
|
89
|
+
return () => {
|
|
90
|
+
listeners.delete(listener);
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/** One value from the playhead: the component redraws when that value changes, not at every tick. */
|
|
96
|
+
export function usePlayhead(playhead, select) {
|
|
97
|
+
return React.useSyncExternalStore(playhead.subscribe, () => select(playhead.get()), () => select(PLAYHEAD_START));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* At the end, or within a scrubber step of it, of media with a length that doesn't loop: decided
|
|
101
|
+
* by position, since a stream still fetching its last part doesn't know yet that it has ended.
|
|
102
|
+
*/
|
|
103
|
+
export const atEnd = (media) => !media.loop && Number.isFinite(media.duration) && media.duration - media.currentTime <= SCRUB_STEP;
|
|
104
|
+
/** The players on the page, video and audio, that play with sound one at a time (`pauseOthers`). */
|
|
105
|
+
export const soundPlayers = new Set();
|
|
106
|
+
export const audible = (media) => !media.paused && !media.muted && media.volume > 0;
|
|
107
|
+
/** This player started with sound: the others that have sound pause. Muted ones play on. */
|
|
108
|
+
export function hushOthers(media) {
|
|
109
|
+
if (!soundPlayers.has(media))
|
|
110
|
+
return;
|
|
111
|
+
for (const other of soundPlayers)
|
|
112
|
+
if (other !== media && audible(other))
|
|
113
|
+
other.pause();
|
|
114
|
+
}
|
|
115
|
+
/** The volume and mute stored under `volumeStorageKey`, when there are any and they're the player's own. */
|
|
116
|
+
export function readVolume(key) {
|
|
117
|
+
try {
|
|
118
|
+
const stored = JSON.parse(window.localStorage.getItem(key) ?? "null");
|
|
119
|
+
const { volume, muted } = (stored ?? {});
|
|
120
|
+
return typeof volume === "number" && volume >= 0 && volume <= 1 && typeof muted === "boolean"
|
|
121
|
+
? { volume, muted }
|
|
122
|
+
: null;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
// Storage unavailable (private mode, blocked site data), or something else's under that key: the defaults stand.
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export function writeVolume(key, volume, muted) {
|
|
130
|
+
try {
|
|
131
|
+
window.localStorage.setItem(key, JSON.stringify({ volume, muted }));
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// Ignore: remembering is a convenience.
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The track and its thumb, shared by the scrubber and the volume. The same material as `Slider`,
|
|
139
|
+
* and like it in a contrast theme (Windows), which paints fills over with the page colour: the
|
|
140
|
+
* value takes the system highlight and the thumb an edge.
|
|
141
|
+
*/
|
|
142
|
+
export const trackClass = "relative h-1.5 w-full rounded-full material-field select-none";
|
|
143
|
+
export const indicatorClass = "rounded-full bg-foreground-soft select-none forced-color-adjust-none forced-colors:bg-[Highlight]";
|
|
144
|
+
export const thumbClass = cn("size-(--slider-thumb) rounded-full bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-thumb select-none forced-colors:border-2", "transition-[background-color,box-shadow] duration-(--duration-fade) ease-(--ease) hover:bg-control-hover data-dragging:bg-control-hover", "has-[:focus-visible]:outline-(length:--focus-width) has-[:focus-visible]:outline-offset-0 has-[:focus-visible]:outline-control-focus");
|
|
145
|
+
/**
|
|
146
|
+
* A round ghost button with its name in a tooltip. `popupClassName` themes the tooltip: `theme-dark`
|
|
147
|
+
* for controls over a picture, or the theme scope a player sits in, which a portalled popup leaves.
|
|
148
|
+
*/
|
|
149
|
+
export function MediaControl({ label, portal, popupClassName, children, ...props }) {
|
|
150
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(Button, { variant: "ghost", "aria-label": label, ...props }), children: children }), _jsx(TooltipContent, { portal: portal, className: popupClassName, children: label })] }));
|
|
151
|
+
}
|
|
152
|
+
/** A control that opens a short list of choices — subtitles, audio, quality, speed — named by a tooltip. */
|
|
153
|
+
export function ChoiceMenu({ label, portal, popupClassName, trigger, value, onValueChange, options, onOpenChange, }) {
|
|
154
|
+
const detailed = options.some((option) => option.detail);
|
|
155
|
+
return (_jsxs(Menu, { onOpenChange: onOpenChange, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(MenuTrigger, { render: trigger }) }), _jsx(TooltipContent, { portal: portal, className: popupClassName, children: label })] }), _jsx(MenuContent, { side: "top", align: "end", portal: portal, className: cn(popupClassName, detailed ? "min-w-56" : "min-w-36"), children: _jsxs(MenuGroup, { children: [_jsx(MenuGroupLabel, { children: label }), _jsx(MenuRadioGroup, { value: value, onValueChange: (next) => onValueChange(String(next)), children: options.map((option) => (_jsxs(MenuRadioItem, { value: option.value, closeOnClick: true, children: [_jsx("span", { className: "flex-1", children: option.label }), option.detail && (_jsx("span", { className: "font-mono text-12 text-muted-foreground tabular-nums", children: option.detail }))] }, option.value))) })] }) })] }));
|
|
156
|
+
}
|
|
157
|
+
/** The playhead's time, or the dragged thumb's, in Licht Mono: "1:15". It redraws once a second. */
|
|
158
|
+
export function MediaClock({ slot, playhead, className, }) {
|
|
159
|
+
const time = usePlayhead(playhead, (s) => formatTime(s.scrub ?? s.time));
|
|
160
|
+
return (_jsx("span", { "data-slot": `${slot}-time`, className: cn("shrink-0 font-mono text-foreground tabular-nums", className), children: time }));
|
|
161
|
+
}
|
|
162
|
+
/** Mute, and beside it a volume slider where there is a fine pointer and room for one. */
|
|
163
|
+
export function MediaVolume({ slot, labels, volume, muted, portal, popupClassName, size, large, className, sliderClassName, onToggleMute, onVolumeChange, }) {
|
|
164
|
+
const silent = muted || volume === 0;
|
|
165
|
+
return (_jsxs("div", { "data-slot": `${slot}-volume`, className: cn("flex items-center", className), children: [_jsx(MediaControl, { label: silent ? labels.unmute : labels.mute, portal: portal, popupClassName: popupClassName, size: size, onClick: onToggleMute, children: silent ? _jsx(VolumeXIcon, {}) : volume < 0.5 ? _jsx(Volume1Icon, {}) : _jsx(Volume2Icon, {}) }), _jsx(BaseSlider.Root, { "data-slot": `${slot}-volume-slider`, value: muted ? 0 : Math.round(volume * 100), min: 0, max: 100, step: 5, onValueChange: (value) => onVolumeChange(value / 100),
|
|
166
|
+
// Touch devices (iPhone, iPad) take the volume from their buttons only: no slider there.
|
|
167
|
+
className: cn("hidden pointer-coarse:hidden!", sliderClassName), children: _jsx(BaseSlider.Control, { className: "flex w-full cursor-pointer touch-none items-center py-2.5 pr-2.5 pl-1.5", children: _jsxs(BaseSlider.Track, { className: cn(trackClass, large && "h-2"), children: [_jsx(BaseSlider.Indicator, { className: indicatorClass }), _jsx(BaseSlider.Thumb, { "aria-label": labels.volume, className: cn(thumbClass, large && "size-5") })] }) }) })] }));
|
|
168
|
+
}
|
|
169
|
+
/** The waveform's bars, as tall as their peaks, centred on the track's middle, in the current colour. */
|
|
170
|
+
const Bars = React.memo(function Bars({ bars }) {
|
|
171
|
+
return bars.map((peak, i) => (_jsx("span", { className: "min-w-px flex-1 rounded-full bg-current", style: { height: `${Math.max(8, Math.min(1, peak) * 100)}%` } }, i)));
|
|
172
|
+
});
|
|
173
|
+
/** One layer of bars over the whole track; the buffered and played layers are cut off by a clip-path. */
|
|
174
|
+
const barLayer = "absolute inset-0 flex items-center gap-px";
|
|
175
|
+
/**
|
|
176
|
+
* The timeline: the part played, the buffered range, and the moment under the pointer, with its
|
|
177
|
+
* still where there are `previews`. Given `peaks`, the track is a waveform of bars: the played
|
|
178
|
+
* part in the foreground ink, the buffered part a step lighter, the rest muted. Left to right on
|
|
179
|
+
* any page, as a timeline runs: like the tape, not like the text.
|
|
180
|
+
*/
|
|
181
|
+
export function MediaScrubber({ slot, playhead, duration, labels, previews, peaks, dense, large = false, frameWidth = 0, className, onSeek, onScrub, onStep, }) {
|
|
182
|
+
const ready = duration > 0;
|
|
183
|
+
const shown = usePlayhead(playhead, (s) => s.scrub ?? s.time);
|
|
184
|
+
const scrub = usePlayhead(playhead, (s) => s.scrub);
|
|
185
|
+
const buffered = usePlayhead(playhead, (s) => s.buffered);
|
|
186
|
+
const [hover, setHover] = React.useState(null);
|
|
187
|
+
// The scrubber's width, for keeping a preview inside it and for how many bars a waveform draws.
|
|
188
|
+
const [trackWidth, setTrackWidth] = React.useState(0);
|
|
189
|
+
const control = React.useRef(null);
|
|
190
|
+
const waveform = peaks !== undefined && peaks.length > 0;
|
|
191
|
+
// A waveform follows its width, so its bars stay as thin as they were drawn.
|
|
192
|
+
React.useEffect(() => {
|
|
193
|
+
const el = control.current;
|
|
194
|
+
if (!waveform || !el)
|
|
195
|
+
return;
|
|
196
|
+
const observer = new ResizeObserver(([entry]) => entry && setTrackWidth(entry.contentRect.width));
|
|
197
|
+
observer.observe(el);
|
|
198
|
+
return () => observer.disconnect();
|
|
199
|
+
}, [waveform]);
|
|
200
|
+
const bars = React.useMemo(() => {
|
|
201
|
+
if (!waveform)
|
|
202
|
+
return [];
|
|
203
|
+
// Before it's measured (and on the server), at most 48: a short row that fills in once known.
|
|
204
|
+
const count = trackWidth > 0 ? Math.max(8, Math.floor((trackWidth + 1) / BAR_PITCH)) : 48;
|
|
205
|
+
const loudest = Math.max(...peaks);
|
|
206
|
+
const scale = loudest > 1 ? 1 / loudest : 1;
|
|
207
|
+
return bucketPeaks(peaks, count).map((p) => p * scale);
|
|
208
|
+
}, [waveform, peaks, trackWidth]);
|
|
209
|
+
// The moment under the pointer, or under the thumb while dragging (touch has no hover).
|
|
210
|
+
const peek = hover ?? (scrub !== null && ready ? { ratio: Math.min(1, scrub / duration), time: scrub } : null);
|
|
211
|
+
const still = peek && previews ? previews(peek.time) : undefined;
|
|
212
|
+
const stillWidth = Math.min(large ? PREVIEW_WIDTH_LARGE : PREVIEW_WIDTH, frameWidth * 0.4);
|
|
213
|
+
const stillScale = still ? stillWidth / still.width : 1;
|
|
214
|
+
// A preview stays within the timeline; a bare time label is narrow enough to centre anywhere.
|
|
215
|
+
const peekLeft = !peek
|
|
216
|
+
? 0
|
|
217
|
+
: still && trackWidth > stillWidth
|
|
218
|
+
? Math.min(Math.max(peek.ratio * trackWidth, stillWidth / 2), trackWidth - stillWidth / 2)
|
|
219
|
+
: peek.ratio * trackWidth;
|
|
220
|
+
const playedPct = ready ? Math.min(100, (shown / duration) * 100) : 0;
|
|
221
|
+
const bufferedPct = ready ? Math.min(100, (buffered / duration) * 100) : 0;
|
|
222
|
+
return (_jsx(DirectionProvider, { direction: "ltr", children: _jsx(BaseSlider.Root, { "data-slot": `${slot}-scrubber`, "data-waveform": waveform ? "" : undefined,
|
|
223
|
+
// Without a length (a live stream) the playhead has no place on the track.
|
|
224
|
+
value: ready ? shown : 0, min: 0, max: ready ? duration : 1, step: SCRUB_STEP, largeStep: 10, disabled: !ready, onValueChange: (value, { reason }) => {
|
|
225
|
+
// Dragged or pressed, the thumb shows where it's going and holds the controls; a key only seeks.
|
|
226
|
+
if (reason === "drag" || reason === "track-press")
|
|
227
|
+
onScrub(value);
|
|
228
|
+
else
|
|
229
|
+
onSeek(value);
|
|
230
|
+
}, onValueCommitted: () => onScrub(null), className: "min-w-0 flex-1", children: _jsxs(BaseSlider.Control, { ref: control, className: cn("group/scrubber relative flex w-full cursor-pointer touch-none items-center data-disabled:cursor-default", waveform ? "py-[5px]" : large ? "py-3" : "py-2.5"), onPointerDown: (event) => setTrackWidth(event.currentTarget.getBoundingClientRect().width), onPointerMove: (event) => {
|
|
231
|
+
if (event.pointerType === "touch" || !ready)
|
|
232
|
+
return;
|
|
233
|
+
const r = event.currentTarget.getBoundingClientRect();
|
|
234
|
+
const ratio = Math.min(1, Math.max(0, (event.clientX - r.left) / r.width));
|
|
235
|
+
setTrackWidth(r.width);
|
|
236
|
+
setHover({ ratio, time: ratio * duration });
|
|
237
|
+
}, onPointerLeave: () => setHover(null), children: [waveform ? (_jsxs(BaseSlider.Track, { className: cn("relative w-full select-none", dense ? "h-5" : "h-7"), children: [_jsxs("span", { "aria-hidden": true, "data-slot": `${slot}-waveform`, className: "pointer-events-none absolute inset-0 forced-color-adjust-none", children: [_jsx("span", { className: cn(barLayer, "text-foreground/20 forced-colors:text-[GrayText]"), children: _jsx(Bars, { bars: bars }) }), _jsx("span", { className: cn(barLayer, "text-foreground/35 forced-colors:text-[GrayText]"), style: { clipPath: `inset(0 ${100 - bufferedPct}% 0 0)` }, children: _jsx(Bars, { bars: bars }) }), _jsx("span", { className: cn(barLayer, "text-foreground forced-colors:text-[Highlight]"), style: { clipPath: `inset(0 ${100 - playedPct}% 0 0)` }, children: _jsx(Bars, { bars: bars }) })] }), _jsx(BaseSlider.Thumb, { "aria-label": labels.seek, getAriaValueText: (_, value) => ready
|
|
238
|
+
? labels.position(labels.duration(value), labels.duration(duration))
|
|
239
|
+
: labels.duration(shown), className: cn(
|
|
240
|
+
// The playhead as a line through the bars, shown while the pointer is over them,
|
|
241
|
+
// while dragging and with keyboard focus; the played bars say where it is otherwise.
|
|
242
|
+
"h-full w-0.5 rounded-full bg-foreground opacity-0 select-none forced-colors:bg-[Highlight]", "transition-opacity duration-(--duration-fade) ease-(--ease)", "group-hover/scrubber:opacity-100 has-[:focus-visible]:opacity-100 data-dragging:opacity-100", "has-[:focus-visible]:outline-(length:--focus-width) has-[:focus-visible]:outline-offset-0 has-[:focus-visible]:outline-control-focus", "group-data-disabled/scrubber:hidden"), onKeyDown: (event) => {
|
|
243
|
+
const forward = event.key === "ArrowRight" || event.key === "ArrowUp";
|
|
244
|
+
const back = event.key === "ArrowLeft" || event.key === "ArrowDown";
|
|
245
|
+
if (!forward && !back)
|
|
246
|
+
return;
|
|
247
|
+
event.preventDefault();
|
|
248
|
+
onStep(forward ? 5 : -5);
|
|
249
|
+
} })] })) : (_jsxs(BaseSlider.Track, { className: cn(trackClass, large && "h-2"), children: [_jsx("span", { "aria-hidden": true, "data-slot": `${slot}-buffered`, className: "absolute inset-y-0 left-0 rounded-full bg-foreground/20 forced-color-adjust-none forced-colors:bg-[GrayText]", style: { width: `${bufferedPct}%` } }), _jsx(BaseSlider.Indicator, { className: indicatorClass }), _jsx(BaseSlider.Thumb, { "aria-label": labels.seek, getAriaValueText: (_, value) => ready
|
|
250
|
+
? labels.position(labels.duration(value), labels.duration(duration))
|
|
251
|
+
: labels.duration(shown), className: cn(thumbClass, large && "size-5"), onKeyDown: (event) => {
|
|
252
|
+
// Arrows step five seconds, the way the player's own shortcuts do.
|
|
253
|
+
const forward = event.key === "ArrowRight" || event.key === "ArrowUp";
|
|
254
|
+
const back = event.key === "ArrowLeft" || event.key === "ArrowDown";
|
|
255
|
+
if (!forward && !back)
|
|
256
|
+
return;
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
onStep(forward ? 5 : -5);
|
|
259
|
+
} })] })), peek && (_jsxs("span", { "aria-hidden": true, "data-slot": `${slot}-hover-time`, className: cn("pointer-events-none absolute bottom-full flex -translate-x-1/2 flex-col items-center overflow-hidden rounded-item material-menu font-mono text-foreground tabular-nums", still ? "mb-2" : "mb-1.5", className), style: { left: trackWidth ? peekLeft : `${peek.ratio * 100}%` }, children: [still && (_jsx("span", { "data-slot": `${slot}-preview`, className: "relative block overflow-hidden bg-black", style: { width: stillWidth, height: (stillWidth * still.height) / still.width }, children: _jsx("img", { src: still.src, alt: "", draggable: false, className: "absolute top-0 left-0 max-w-none origin-top-left", style: {
|
|
260
|
+
transform: `translate(${-(still.x ?? 0) * stillScale}px, ${-(still.y ?? 0) * stillScale}px) scale(${stillScale})`,
|
|
261
|
+
// A whole image is drawn at the still's size; a sheet at its own.
|
|
262
|
+
...(still.x === undefined && still.y === undefined
|
|
263
|
+
? { width: still.width, height: still.height }
|
|
264
|
+
: {}),
|
|
265
|
+
} }) })), _jsx("span", { className: still ? "py-1" : "px-1.5 py-0.5", children: formatTime(peek.time) })] }))] }) }) }));
|
|
266
|
+
}
|