@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
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { AirplayIcon, ArrowLeftIcon, AudioLinesIcon, CaptionsIcon, CaptionsOffIcon, ChevronLeftIcon, ChevronsLeftIcon, ChevronsRightIcon, GalleryVerticalEndIcon, LanguagesIcon, MaximizeIcon, MinimizeIcon, PauseIcon, PictureInPicture2Icon, PlayIcon, RotateCcwIcon, RotateCwIcon, SkipForwardIcon, VideoOffIcon, Volume1Icon, Volume2Icon, VolumeXIcon, } from "lucide-react";
|
|
3
|
+
import { AirplayIcon, ArrowLeftIcon, AudioLinesIcon, CaptionsIcon, CaptionsOffIcon, ChevronLeftIcon, ChevronsLeftIcon, ChevronsRightIcon, GalleryVerticalEndIcon, LanguagesIcon, MaximizeIcon, MinimizeIcon, PauseIcon, PictureInPicture2Icon, PlayIcon, RotateCcwIcon, RotateCwIcon, SkipForwardIcon, VideoOffIcon, } from "../lib/icons.js";
|
|
5
4
|
import * as React from "react";
|
|
6
5
|
import { cn } from "../lib/cn.js";
|
|
7
6
|
import { mergeRefs } from "../lib/merge-refs.js";
|
|
7
|
+
import { cssDuration, cssEase, cssTime } from "../lib/motion.js";
|
|
8
|
+
import { ChoiceMenu as MediaChoiceMenu, createPlayhead, atEnd, audible, bufferedEnd, DEFAULT_SPEEDS, formatTime, hushOthers, MediaClock, MediaControl, MediaScrubber, MediaVolume, readVolume, soundPlayers, TIME_STEP, usePlayhead, writeVolume, } from "./_media.js";
|
|
8
9
|
import { Button } from "./button.js";
|
|
9
|
-
import { DirectionProvider } from "./direction.js";
|
|
10
10
|
import { Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger, } from "./menu.js";
|
|
11
|
+
import { useMessages } from "./locale.js";
|
|
11
12
|
import { Skeleton } from "./skeleton.js";
|
|
12
13
|
import { Spinner } from "./spinner.js";
|
|
13
14
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
|
|
@@ -66,34 +67,32 @@ const playerVariants = {
|
|
|
66
67
|
card: "rounded-card surface-card [--card-padding:0]",
|
|
67
68
|
plain: "",
|
|
68
69
|
};
|
|
69
|
-
const DEFAULT_SPEEDS = [0.5, 0.75, 1, 1.25, 1.5, 2];
|
|
70
70
|
/** How long the controls stay after the pointer or keyboard was last used, while playing. */
|
|
71
71
|
const IDLE_MS = 2500;
|
|
72
72
|
/** How far the movie layout's skip buttons jump, in seconds. */
|
|
73
73
|
const SKIP = 10;
|
|
74
74
|
/** From this frame width the movie layout's controls grow to the prominent size. */
|
|
75
75
|
const LARGE_FRAME = 768;
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const FLASH_MS = 300;
|
|
76
|
+
/**
|
|
77
|
+
* Below this frame width (a phone held upright) the movie layout is too short for the title, the
|
|
78
|
+
* middle button, a subtitle and a skip beside the controls: they stack instead (see `narrow`).
|
|
79
|
+
*/
|
|
80
|
+
const NARROW_FRAME = 576;
|
|
82
81
|
/** The last moment of a segment that still offers its skip, so it doesn't flash at the cut. */
|
|
83
82
|
const SEGMENT_TAIL = 0.5;
|
|
84
83
|
/** How long a skip stays on its own, in seconds of playback; after that it shows with the controls. */
|
|
85
84
|
const SEGMENT_PROMPT = 15;
|
|
86
85
|
/** An automatic skip's countdown, in seconds of playback. */
|
|
87
86
|
const AUTO_COUNTDOWN = 10;
|
|
88
|
-
/** How far the playhead moves before the controls show its new time (s): often enough for the eye, not every frame. */
|
|
89
|
-
const TIME_STEP = 0.1;
|
|
90
|
-
/** 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. */
|
|
91
|
-
const SCRUB_STEP = 0.1;
|
|
92
87
|
/** A click on the picture this soon after a menu closed only closed the menu (ms). */
|
|
93
88
|
const MENU_CLOSE_MS = 400;
|
|
94
89
|
/** Two taps this close together are a double tap (ms). */
|
|
95
90
|
const DOUBLE_TAP_MS = 350;
|
|
96
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* A jump's readout ("+20s") stays this long after the last press or tap, so it can be read, and
|
|
93
|
+
* jumps the same way within it add to it (ms). Reading time, not motion: the readout answers the
|
|
94
|
+
* press in --duration and fades out on its own at the end (see `jump` below).
|
|
95
|
+
*/
|
|
97
96
|
const JUMP_MS = 1000;
|
|
98
97
|
/**
|
|
99
98
|
* A stream that stops while it plays loads again by itself after each of these pauses in turn (ms),
|
|
@@ -109,14 +108,6 @@ const SUBTITLE_SLOW_MS = 2000;
|
|
|
109
108
|
/** Asks for a subtitle file, and the pause between them (ms): cutting one out of a whole file can outlast a request. */
|
|
110
109
|
const SUBTITLE_TRIES = 4;
|
|
111
110
|
const SUBTITLE_RETRY_MS = 15_000;
|
|
112
|
-
/** 75 → "1:15", 3725 → "1:02:05". */
|
|
113
|
-
function formatTime(seconds) {
|
|
114
|
-
const s = Number.isFinite(seconds) && seconds > 0 ? Math.floor(seconds) : 0;
|
|
115
|
-
const h = Math.floor(s / 3600);
|
|
116
|
-
const m = Math.floor((s % 3600) / 60);
|
|
117
|
-
const rest = String(s % 60).padStart(2, "0");
|
|
118
|
-
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${rest}` : `${m}:${rest}`;
|
|
119
|
-
}
|
|
120
111
|
/**
|
|
121
112
|
* A cue's lines as text. Subtitles converted from ASS (most anime) keep its override tags, such
|
|
122
113
|
* as `{\\fad(250,0)\\blur2}`, and its `\\N` breaks; WebVTT itself has neither.
|
|
@@ -129,15 +120,6 @@ function cueLines(text) {
|
|
|
129
120
|
.map((line) => line.trim())
|
|
130
121
|
.filter(Boolean);
|
|
131
122
|
}
|
|
132
|
-
/** The end of the buffered range the playhead is in. */
|
|
133
|
-
function bufferedEnd(video) {
|
|
134
|
-
const { buffered, currentTime } = video;
|
|
135
|
-
for (let i = 0; i < buffered.length; i++) {
|
|
136
|
-
if (buffered.start(i) <= currentTime + 0.5 && currentTime <= buffered.end(i))
|
|
137
|
-
return buffered.end(i);
|
|
138
|
-
}
|
|
139
|
-
return 0;
|
|
140
|
-
}
|
|
141
123
|
/** The distinct values of one field across the versions, in the order they are listed. */
|
|
142
124
|
function choices(versions, field) {
|
|
143
125
|
return [...new Set(versions.map((v) => v[field]).filter((v) => !!v))];
|
|
@@ -155,82 +137,6 @@ const sourceKey = (src) => src === undefined ? "" : typeof src === "string" ? sr
|
|
|
155
137
|
* stream (HLS from a media server) is fetched from its beginning only to seek away again.
|
|
156
138
|
*/
|
|
157
139
|
const startingAt = (src, time) => time > 0 ? `${src.split("#")[0]}#t=${time.toFixed(1)}` : src;
|
|
158
|
-
const PLAYHEAD_START = { time: 0, scrub: null, buffered: 0 };
|
|
159
|
-
/**
|
|
160
|
-
* The playhead, kept outside React state. It moves ten times a second while the video plays, and
|
|
161
|
-
* only the parts that show it (the scrubber, the times, a segment's skip) follow it; the rest of
|
|
162
|
-
* the player doesn't redraw.
|
|
163
|
-
*/
|
|
164
|
-
function createPlayhead() {
|
|
165
|
-
let state = PLAYHEAD_START;
|
|
166
|
-
const listeners = new Set();
|
|
167
|
-
return {
|
|
168
|
-
get: () => state,
|
|
169
|
-
set(next) {
|
|
170
|
-
if (Object.keys(next).every((key) => next[key] === state[key]))
|
|
171
|
-
return;
|
|
172
|
-
state = { ...state, ...next };
|
|
173
|
-
for (const listener of listeners)
|
|
174
|
-
listener();
|
|
175
|
-
},
|
|
176
|
-
subscribe(listener) {
|
|
177
|
-
listeners.add(listener);
|
|
178
|
-
return () => {
|
|
179
|
-
listeners.delete(listener);
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* At the end, or within a scrubber step of it, of a video with a length that doesn't loop: decided
|
|
186
|
-
* by position, since a stream still fetching its last part doesn't know yet that it has ended.
|
|
187
|
-
*/
|
|
188
|
-
const atEnd = (video) => !video.loop && Number.isFinite(video.duration) && video.duration - video.currentTime <= SCRUB_STEP;
|
|
189
|
-
/** The players on the page that play with sound one at a time (`pauseOthers`). */
|
|
190
|
-
const soundPlayers = new Set();
|
|
191
|
-
const audible = (video) => !video.paused && !video.muted && video.volume > 0;
|
|
192
|
-
/** This player started with sound: the others that have sound pause. Muted ones play on. */
|
|
193
|
-
function hushOthers(video) {
|
|
194
|
-
if (!soundPlayers.has(video))
|
|
195
|
-
return;
|
|
196
|
-
for (const other of soundPlayers)
|
|
197
|
-
if (other !== video && audible(other))
|
|
198
|
-
other.pause();
|
|
199
|
-
}
|
|
200
|
-
/** The volume and mute stored under `volumeStorageKey`, when there are any and they're the player's own. */
|
|
201
|
-
function readVolume(key) {
|
|
202
|
-
try {
|
|
203
|
-
const stored = JSON.parse(window.localStorage.getItem(key) ?? "null");
|
|
204
|
-
const { volume, muted } = (stored ?? {});
|
|
205
|
-
return typeof volume === "number" && volume >= 0 && volume <= 1 && typeof muted === "boolean"
|
|
206
|
-
? { volume, muted }
|
|
207
|
-
: null;
|
|
208
|
-
}
|
|
209
|
-
catch {
|
|
210
|
-
// Storage unavailable (private mode, blocked site data), or something else's under that key: the defaults stand.
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function writeVolume(key, volume, muted) {
|
|
215
|
-
try {
|
|
216
|
-
window.localStorage.setItem(key, JSON.stringify({ volume, muted }));
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
// Ignore: remembering is a convenience.
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/** One value from the playhead: the component redraws when that value changes, not at every tick. */
|
|
223
|
-
function usePlayhead(playhead, select) {
|
|
224
|
-
return React.useSyncExternalStore(playhead.subscribe, () => select(playhead.get()), () => select(PLAYHEAD_START));
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* The track and its thumb, shared by the scrubber and the volume. The same material as `Slider`,
|
|
228
|
-
* and like it in a contrast theme (Windows), which paints fills over with the page colour: the
|
|
229
|
-
* value takes the system highlight and the thumb an edge.
|
|
230
|
-
*/
|
|
231
|
-
const trackClass = "relative h-1.5 w-full rounded-full material-field select-none";
|
|
232
|
-
const indicatorClass = "rounded-full bg-foreground-soft select-none forced-color-adjust-none forced-colors:bg-[Highlight]";
|
|
233
|
-
const thumbClass = cn("size-[18px] 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) ease-brand hover:bg-control-hover data-dragging:bg-control-hover", "has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-0 has-[:focus-visible]:outline-control-focus");
|
|
234
140
|
/**
|
|
235
141
|
* VideoPlayer — a video in the zon material: the picture letterboxed on black, and over it
|
|
236
142
|
* controls set dark whatever the page's theme — play, a scrubber with the buffered range and the
|
|
@@ -257,7 +163,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
257
163
|
const pointerFocus = React.useRef(false);
|
|
258
164
|
const video = React.useRef(null);
|
|
259
165
|
const movie = layout === "movie";
|
|
260
|
-
const labels =
|
|
166
|
+
const labels = useMessages("videoPlayer", DEFAULT_LABELS, labelOverrides);
|
|
261
167
|
const [playing, setPlaying] = React.useState(false);
|
|
262
168
|
const [started, setStarted] = React.useState(autoPlay);
|
|
263
169
|
const [ended, setEnded] = React.useState(false);
|
|
@@ -767,14 +673,19 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
767
673
|
const el = flashRef.current;
|
|
768
674
|
if (!flash || !el)
|
|
769
675
|
return;
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
676
|
+
// An answer to a press: 2 × --duration (300ms), the motion budget. Under reduced motion it
|
|
677
|
+
// only fades, over as long, on --duration-fade.
|
|
678
|
+
const moves = cssDuration(el) > 0;
|
|
679
|
+
const animation = el.animate(moves
|
|
680
|
+
? [
|
|
774
681
|
{ opacity: 0, transform: "scale(0.85)" },
|
|
775
682
|
{ opacity: 1, transform: "scale(1)", offset: 0.25 },
|
|
776
683
|
{ opacity: 0, transform: "scale(1.15)" },
|
|
777
|
-
]
|
|
684
|
+
]
|
|
685
|
+
: [{ opacity: 0 }, { opacity: 1, offset: 0.2 }, { opacity: 0 }], {
|
|
686
|
+
duration: (moves ? cssDuration(el) : cssTime("--duration-fade", el)) * 2,
|
|
687
|
+
easing: cssEase("--ease", el),
|
|
688
|
+
});
|
|
778
689
|
animation.onfinish = () => setFlash(null);
|
|
779
690
|
return () => animation.cancel();
|
|
780
691
|
}, [flash]);
|
|
@@ -833,17 +744,28 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
833
744
|
const el = jumpRef.current;
|
|
834
745
|
if (!jump || !el)
|
|
835
746
|
return;
|
|
836
|
-
const still = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
837
747
|
// Each press nudges it the way it went; only the first fades in, so a run of them doesn't blink.
|
|
748
|
+
// It answers the press in --duration (a fade alone under reduced motion), is held to be read,
|
|
749
|
+
// and fades out on its own over 2 × --duration-fade, while nobody is waiting on it.
|
|
838
750
|
const from = jump.first ? 0 : 1;
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
751
|
+
const moves = cssDuration(el) > 0;
|
|
752
|
+
const fade = cssTime("--duration-fade", el);
|
|
753
|
+
const arrive = (moves ? cssDuration(el) : fade) / JUMP_MS;
|
|
754
|
+
const leave = 1 - (fade * 2) / JUMP_MS;
|
|
755
|
+
const easing = cssEase("--ease", el);
|
|
756
|
+
const animation = el.animate(moves
|
|
757
|
+
? [
|
|
758
|
+
{ opacity: from, transform: `translateX(${jump.side * -6}px) scale(0.94)`, easing },
|
|
759
|
+
{ opacity: 1, transform: "none", offset: arrive },
|
|
760
|
+
{ opacity: 1, transform: "none", offset: leave, easing },
|
|
845
761
|
{ opacity: 0, transform: "none" },
|
|
846
|
-
]
|
|
762
|
+
]
|
|
763
|
+
: [
|
|
764
|
+
{ opacity: from, easing },
|
|
765
|
+
{ opacity: 1, offset: arrive },
|
|
766
|
+
{ opacity: 1, offset: leave, easing },
|
|
767
|
+
{ opacity: 0 },
|
|
768
|
+
], { duration: JUMP_MS });
|
|
847
769
|
animation.onfinish = () => setJump(null);
|
|
848
770
|
return () => animation.cancel();
|
|
849
771
|
}, [jump]);
|
|
@@ -1083,6 +1005,18 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
1083
1005
|
const controlsHidden = hidden || (!started && !focusIn);
|
|
1084
1006
|
// A big movie frame (a film on a laptop or a TV) gets the prominent controls and a thicker timeline.
|
|
1085
1007
|
const large = movie && frameWidth >= LARGE_FRAME;
|
|
1008
|
+
/*
|
|
1009
|
+
* A narrow movie frame (a phone held upright, about 180px tall) has no room beside the controls
|
|
1010
|
+
* for everything: the skip is small and sits on the end side just above them, the subtitle above
|
|
1011
|
+
* the skip, and the middle button gives its place to both (play and pause stay in the bar); a
|
|
1012
|
+
* line of subtitles hides the title while it shows.
|
|
1013
|
+
*/
|
|
1014
|
+
const narrow = movie && !large && frameWidth > 0 && frameWidth < NARROW_FRAME;
|
|
1015
|
+
const subtitlesOn = subtitle >= 0 && subtitle < tracks.length;
|
|
1016
|
+
// How far a skip on offer reaches in from the frame's end edge, in px (0: none on offer). Wider
|
|
1017
|
+
// frames keep the subtitle on the skip's row, narrowed on both sides to stay clear of it.
|
|
1018
|
+
const [skipReach, setSkipReach] = React.useState(0);
|
|
1019
|
+
const skipShown = skipReach > 0;
|
|
1086
1020
|
const size = movie ? "icon" : "icon-sm";
|
|
1087
1021
|
const textSize = large ? "lg" : movie ? "default" : "sm";
|
|
1088
1022
|
const timeText = large ? "text-sm" : "text-xs";
|
|
@@ -1126,18 +1060,16 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
1126
1060
|
/* ── The controls, placed by the layout below ── */
|
|
1127
1061
|
const playButton = (_jsx(Control, { label: ended ? labels.playAgain : playing ? labels.pause : labels.play, portal: portal, size: size, onClick: togglePlay, children: ended ? _jsx(RotateCcwIcon, {}) : playing ? _jsx(PauseIcon, {}) : _jsx(PlayIcon, {}) }));
|
|
1128
1062
|
const skipButtons = (_jsxs(_Fragment, { children: [_jsx(Control, { label: labels.skipBack(SKIP), portal: portal, size: size, onClick: () => jumpBy(-SKIP), children: _jsx(SkipIcon, { direction: "back", large: large }) }), _jsx(Control, { label: labels.skipForward(SKIP), portal: portal, size: size, onClick: () => jumpBy(SKIP), children: _jsx(SkipIcon, { direction: "forward", large: large }) })] }));
|
|
1129
|
-
const volumeControls = (
|
|
1063
|
+
const volumeControls = (_jsx(MediaVolume, { slot: "video-player", labels: labels, volume: volume, muted: muted, portal: portal, popupClassName: "theme-dark", size: size, large: large, onToggleMute: toggleMute, onVolumeChange: changeVolume,
|
|
1130
1064
|
// In the movie layout's row, free to narrow: its slider gives way before anything overflows.
|
|
1131
|
-
className:
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
movie ? "min-w-10 @min-[38.5rem]/video:block" : "@lg/video:block", large ? "w-24" : movie ? "w-20" : "w-16"), 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") })] }) }) })] }));
|
|
1136
|
-
const currentTime = _jsx(Clock, { playhead: playhead, className: timeText });
|
|
1065
|
+
className: movie ? "min-w-0" : "@max-md/video:mr-auto", sliderClassName: cn(
|
|
1066
|
+
// In the movie layout's one row it waits for room, and gives some back when the row runs short (a next control).
|
|
1067
|
+
movie ? "min-w-10 @min-[38.5rem]/video:block" : "@lg/video:block", large ? "w-24" : movie ? "w-20" : "w-16") }));
|
|
1068
|
+
const currentTime = _jsx(MediaClock, { slot: "video-player", playhead: playhead, className: timeText });
|
|
1137
1069
|
// Without a length (a live stream) there is no total, and nothing to count down.
|
|
1138
1070
|
const totalTime = ready ? (_jsx("span", { "data-slot": "video-player-duration", className: cn("shrink-0 font-mono text-muted-foreground tabular-nums", timeText), children: formatTime(duration) })) : null;
|
|
1139
1071
|
const remainingTime = ready ? (_jsx(TimeLeft, { playhead: playhead, duration: duration, labels: labels, className: timeText })) : null;
|
|
1140
|
-
const scrubber = (_jsx(
|
|
1072
|
+
const scrubber = (_jsx(MediaScrubber, { slot: "video-player", playhead: playhead, duration: duration, labels: labels, previews: previews, large: large, frameWidth: frameWidth, className: timeText, onSeek: seekTo, onScrub: scrub, onStep: seekBy }));
|
|
1141
1073
|
// One track toggles in the default layout; several, or the movie layout, get a menu. Its name
|
|
1142
1074
|
// says what it does now, like play's, so it reports no pressed state as well.
|
|
1143
1075
|
const subtitlesControl = tracks.length === 0 ? null : tracks.length === 1 && !movie ? (_jsx(Control, { label: subtitle >= 0 ? labels.hideSubtitles : labels.showSubtitles, portal: portal, size: size, onClick: toggleSubtitles, children: subtitle >= 0 ? _jsx(CaptionsIcon, {}) : _jsx(CaptionsOffIcon, {}) })) : (_jsx(ChoiceMenu, { label: labels.subtitles, portal: portal, onOpenChange: onMenuOpenChange, trigger: _jsx(Button, { variant: "ghost", size: size, "aria-label": `${labels.subtitles}, ${tracks[subtitle]?.label ?? labels.subtitlesOff}`, children: subtitle >= 0 ? _jsx(CaptionsIcon, {}) : _jsx(CaptionsOffIcon, {}) }), value: String(subtitle), onValueChange: (value) => chooseSubtitle(Number(value)), options: [
|
|
@@ -1171,7 +1103,7 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
1171
1103
|
const airPlayControl = canAirPlay ? (_jsx(Control, { label: labels.airPlay, portal: portal, size: size, "aria-pressed": airPlaying, onClick: pickAirPlay, children: _jsx(AirplayIcon, {}) })) : null;
|
|
1172
1104
|
const fullscreenControl = allowFullscreen && canFullscreen ? (_jsx(Control, { label: isFullscreen ? labels.exitFullScreen : labels.fullScreen, portal: portal, size: size, onClick: toggleFullscreen, children: isFullscreen ? _jsx(MinimizeIcon, {}) : _jsx(MaximizeIcon, {}) })) : null;
|
|
1173
1105
|
// Stepped back while playing (and before the first play), unless a control has keyboard focus (`hidden`).
|
|
1174
|
-
const controlsMotion = cn("transition-[opacity,translate] duration-(--duration) ease-
|
|
1106
|
+
const controlsMotion = cn("transition-[opacity,translate] [transition-duration:var(--duration-fade),var(--duration)] ease-(--ease)", "data-hidden:pointer-events-none data-hidden:opacity-0");
|
|
1175
1107
|
const hoverProps = {
|
|
1176
1108
|
onPointerEnter: (event) => event.pointerType !== "touch" && setOverControls(true),
|
|
1177
1109
|
onPointerLeave: () => setOverControls(false),
|
|
@@ -1194,30 +1126,43 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
1194
1126
|
"@container/video relative isolate w-full overflow-hidden bg-black font-body text-foreground select-none", "data-idle:cursor-none", playerVariants[variant], isFullscreen && "rounded-none border-0", className), style: { aspectRatio: isFullscreen ? undefined : aspectRatio, ...style }, ...props, children: [_jsxs("video", { ref: videoRefs, "data-slot": "video-player-video", poster: poster, autoPlay: autoPlay, loop: loop, muted: startMuted, playsInline: true, preload: "metadata", src: typeof current === "string" && current ? startingAt(current, startOf) : undefined, className: "absolute inset-0 size-full bg-black object-contain", children: [typeof current !== "string" &&
|
|
1195
1127
|
current.map((s, i) => (_jsx("source", { src: startingAt(s.src, startOf), type: s.type, onError: i === current.length - 1 ? fail : undefined }, s.src))), tracks
|
|
1196
1128
|
.filter((t) => !t.render)
|
|
1197
|
-
.map((t) => (_jsx("track", { src: loaded[t.src] ?? t.src, label: t.label, srcLang: t.srcLang, kind: t.kind ?? "subtitles" }, loaded[t.src] ?? t.src)))] }), _jsx("div", { "aria-hidden": true, "data-slot": "video-player-stage", className: "absolute inset-0", onPointerUp: handleStageClick, onDoubleClick: () => allowFullscreen && canFullscreen && toggleFullscreen() }), movie && (_jsxs(_Fragment, { children: [_jsx("div", { hidden: failed, "aria-hidden": true, "data-slot": "video-player-scrim", "data-hidden": hidden ? "" : undefined, className: cn("pointer-events-none absolute inset-0 bg-[linear-gradient(to_bottom,rgb(0_0_0/0.55),transparent_22%,transparent_40%,rgb(0_0_0/0.85))]", "transition-opacity duration-(--duration) ease-
|
|
1129
|
+
.map((t) => (_jsx("track", { src: loaded[t.src] ?? t.src, label: t.label, srcLang: t.srcLang, kind: t.kind ?? "subtitles" }, loaded[t.src] ?? t.src)))] }), _jsx("div", { "aria-hidden": true, "data-slot": "video-player-stage", className: "absolute inset-0", onPointerUp: handleStageClick, onDoubleClick: () => allowFullscreen && canFullscreen && toggleFullscreen() }), movie && (_jsxs(_Fragment, { children: [_jsx("div", { hidden: failed, "aria-hidden": true, "data-slot": "video-player-scrim", "data-hidden": hidden ? "" : undefined, className: cn("pointer-events-none absolute inset-0 bg-[linear-gradient(to_bottom,rgb(0_0_0/0.55),transparent_22%,transparent_40%,rgb(0_0_0/0.85))]", "transition-opacity duration-(--duration-fade) ease-(--ease) data-hidden:opacity-0") }), (title || onBack) && (_jsxs("div", { "data-slot": "video-player-title", "data-hidden": hidden ? "" : undefined, ...focusProps, className: cn("theme-dark pointer-events-none absolute inset-x-0 top-0 flex items-center gap-1 bg-transparent px-5 pt-4 @2xl/video:px-7 @2xl/video:pt-6", "transition-opacity duration-(--duration-fade) ease-(--ease) data-hidden:opacity-0 data-hidden:*:pointer-events-none!",
|
|
1198
1130
|
// The arrow stands over the play button, in the controls' own column; the title follows it.
|
|
1199
|
-
onBack && "pt-3 pl-3 @2xl/video:pt-5 @2xl/video:pl-5", large && "[--icon-button:var(--control-h-lg)] [&_button_svg:not([class*='size-'])]:size-5", large && onBack && "pt-5! pl-7!"), children: [onBack && (_jsx(Control, { label: labels.back, portal: portal, size: size, onClick: onBack, className: "pointer-events-auto", children: _jsx(ArrowLeftIcon, { className: "rtl:-scale-x-100" }) })), title && (_jsx("p", { className: "max-w-[min(100%,40rem)] min-w-0 truncate font-heading text-
|
|
1131
|
+
onBack && "pt-3 pl-3 @2xl/video:pt-5 @2xl/video:pl-5", large && "[--icon-button:var(--control-h-lg)] [&_button_svg:not([class*='size-'])]:size-5", large && onBack && "pt-5! pl-7!"), children: [onBack && (_jsx(Control, { label: labels.back, portal: portal, size: size, onClick: onBack, className: "pointer-events-auto", children: _jsx(ArrowLeftIcon, { className: "rtl:-scale-x-100" }) })), title && (_jsx("p", { className: cn("max-w-[min(100%,40rem)] min-w-0 truncate font-heading text-17 font-light text-foreground @2xl/video:text-2xl", "transition-opacity duration-(--duration-fade) ease-(--ease)", narrow && cue && "opacity-0"), children: title }))] }))] })), _jsx("div", { className: "theme-dark pointer-events-none absolute inset-0 flex items-center justify-center bg-transparent text-foreground", children: failed ? (_jsxs("div", { className: "flex flex-col items-center gap-4", children: [_jsxs("p", { "data-slot": "video-player-error", className: "flex items-center gap-2 font-mono text-xs text-muted-foreground", children: [_jsx(VideoOffIcon, { "aria-hidden": true, className: "size-4" }), labels.error] }), _jsxs("div", { className: "pointer-events-auto flex flex-wrap justify-center gap-2", children: [_jsx(Button, { variant: "secondary", size: "sm", onClick: retry, children: labels.retry }), nextQuality && (_jsx(Button, { variant: "ghost", size: "sm", onClick: () => {
|
|
1200
1132
|
switchVersion({ quality: nextQuality });
|
|
1201
1133
|
onQualityChange?.(nextQuality);
|
|
1202
1134
|
}, children: labels.tryQuality(nextQuality) }))] })] })) : preparing ? (_jsx(Spinner, { size: "lg", label: labels.loading })) : !started || ended ? (_jsx(Button, { "data-slot": "video-player-start", variant: "secondary", size: "icon", "aria-label": ended ? labels.playAgain : labels.play, onClick: togglePlay, className: "pointer-events-auto size-(--control-h-lg) [&_svg:not([class*='size-'])]:size-5", children: ended ? _jsx(RotateCcwIcon, {}) : _jsx(PlayIcon, { className: "translate-x-px" }) })) : waiting ? (_jsx(Spinner, { size: "lg", label: labels.loading })) : (_jsx(Button, { "data-slot": "video-player-center", "data-hidden": controlsHidden ? "" : undefined, variant: "secondary", size: "icon", "aria-label": playing ? labels.pause : labels.play, onClick: () => {
|
|
1203
1135
|
togglePlay();
|
|
1204
1136
|
wake();
|
|
1205
|
-
}, className: cn("pointer-events-auto hidden size-(--control-h-lg)
|
|
1137
|
+
}, className: cn("pointer-events-auto hidden size-(--control-h-lg) [&_svg:not([class*='size-'])]:size-5",
|
|
1138
|
+
// A narrow frame's middle goes to the subtitles and the skip.
|
|
1139
|
+
!(narrow && (subtitlesOn || skipShown)) && "pointer-coarse:inline-flex", "transition-opacity duration-(--duration-fade) ease-(--ease) data-hidden:pointer-events-none data-hidden:opacity-0"), children: playing ? _jsx(PauseIcon, {}) : _jsx(PlayIcon, { className: "translate-x-px" }) })) }), jump && (_jsx("div", { "aria-hidden": true, className: cn("theme-dark pointer-events-none absolute inset-y-0 flex w-1/3 items-center justify-center bg-transparent", jump.side < 0 ? "left-0" : "right-0"), children: _jsxs("div", { ref: jumpRef, "data-slot": "video-player-jump", className: cn("flex flex-col items-center justify-center gap-1 rounded-full bg-black/50 text-foreground opacity-0", movie ? "size-20 [&_svg]:size-7" : "size-14 [&_svg]:size-5"), children: [jump.side < 0 ? (_jsx(ChevronsLeftIcon, { strokeWidth: 1.5 })) : (_jsx(ChevronsRightIcon, { strokeWidth: 1.5 })), _jsx("span", { className: cn("font-mono leading-none tabular-nums", movie ? "text-xs" : "text-[10px]"), children: labels.jumped(jump.side * jump.seconds) })] }, jump.n) })), flash && (_jsx("div", { "aria-hidden": true, className: "theme-dark pointer-events-none absolute inset-0 flex items-center justify-center bg-transparent", children: _jsx("div", { ref: flashRef, "data-slot": "video-player-flash", className: cn("flex items-center justify-center rounded-full bg-black/50 text-foreground opacity-0", movie ? "size-20 [&_svg]:size-8" : "size-14 [&_svg]:size-6"), children: flash.playing ? _jsx(PlayIcon, { className: "translate-x-0.5" }) : _jsx(PauseIcon, {}) }, flash.n) })), _jsx("div", { ref: subtitleLayer, "aria-hidden": true, "data-slot": "video-player-subtitle-layer", className: cn("pointer-events-none absolute inset-0 transition-transform duration-(--duration) ease-(--ease)", !controlsHidden &&
|
|
1206
1140
|
(large
|
|
1207
1141
|
? "-translate-y-[calc(var(--control-h-lg)+56px)]"
|
|
1208
1142
|
: movie
|
|
1209
1143
|
? "-translate-y-[calc(var(--control-h)+44px)]"
|
|
1210
|
-
: "-translate-y-[calc(var(--control-h-sm)+28px)]")) }), (cue || subtitleSlow) && (_jsx("div", { "data-slot": "video-player-caption",
|
|
1211
|
-
//
|
|
1144
|
+
: "-translate-y-[calc(var(--control-h-sm)+28px)]")) }), (cue || subtitleSlow) && (_jsx("div", { "data-slot": "video-player-caption",
|
|
1145
|
+
// On the skip's row, narrowed on both sides, so it stays centred and clear of the skip.
|
|
1146
|
+
style: movie && !narrow && skipShown ? { left: skipReach + 8, right: skipReach + 8 } : undefined, className: cn("theme-dark pointer-events-none absolute flex justify-center bg-transparent text-center transition-[bottom] duration-(--duration) ease-(--ease)",
|
|
1147
|
+
// Clear of the back arrow when it reaches the top of a narrow frame.
|
|
1148
|
+
narrow && onBack && !controlsHidden ? "inset-x-14" : "inset-x-4",
|
|
1149
|
+
// Above the controls while they show; low in the frame when they step back. On a narrow
|
|
1150
|
+
// frame, above the skip too, which takes the row over the controls.
|
|
1212
1151
|
controlsHidden
|
|
1213
|
-
?
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1152
|
+
? narrow && skipShown
|
|
1153
|
+
? "bottom-[calc(var(--control-h-sm)+22px)]"
|
|
1154
|
+
: "bottom-4"
|
|
1155
|
+
: narrow
|
|
1156
|
+
? skipShown
|
|
1157
|
+
? "bottom-[calc(var(--control-h)+var(--control-h-sm)+48px)]"
|
|
1158
|
+
: "bottom-[calc(var(--control-h)+42px)]"
|
|
1159
|
+
: large
|
|
1160
|
+
? "bottom-[calc(var(--control-h-lg)+72px)]"
|
|
1161
|
+
: movie
|
|
1162
|
+
? "bottom-[calc(var(--control-h)+60px)]"
|
|
1163
|
+
: "bottom-[calc(var(--control-h-sm)+44px)] @max-md/video:bottom-[calc(var(--control-h-sm)*2+52px)]"), children: _jsx("span", { className: "text-[clamp(15px,2.2cqw,44px)]", children: _jsx("span", { className: cn("inline-block max-w-[min(90cqw,40em)] rounded-item bg-background/80 px-2 py-0.5 leading-snug [overflow-wrap:anywhere] text-foreground", !cue && "text-[0.7em] text-muted-foreground"), style: { fontSize: `${subtitleScale}em` }, children: cue
|
|
1219
1164
|
? cue.split("\n").map((line, i) => (_jsx("span", { dir: "auto", className: "block", children: line }, i)))
|
|
1220
|
-
: labels.preparingSubtitles }) }) })), _jsx(SegmentSkip, { playhead: playhead, segments: segments, live: started && !ended, failed: failed, playing: playing, titleKey: titleKey, sourceKey: srcKey, onSkip: skip, onPress: wake, controlsHidden: controlsHidden, large: large, movie: movie }), !failed &&
|
|
1165
|
+
: labels.preparingSubtitles }) }) })), _jsx(SegmentSkip, { playhead: playhead, segments: segments, live: started && !ended, failed: failed, playing: playing, titleKey: titleKey, sourceKey: srcKey, onSkip: skip, onPress: wake, controlsHidden: controlsHidden, large: large, movie: movie, narrow: narrow, onReachChange: setSkipReach }), !failed &&
|
|
1221
1166
|
(movie ? (_jsxs("div", { "data-slot": "video-player-controls", "data-hidden": controlsHidden ? "" : undefined, ...hoverProps, ...focusProps, className: cn("theme-dark absolute inset-x-0 bottom-0 flex flex-col gap-1 bg-transparent px-3 pb-2 @2xl/video:px-5 @2xl/video:pb-3",
|
|
1222
1167
|
// The prominent size: 46px round controls with larger icons.
|
|
1223
1168
|
large &&
|
|
@@ -1227,81 +1172,24 @@ export function VideoPlayer({ src, versions = [], defaultAudio, defaultQuality,
|
|
|
1227
1172
|
* A round ghost button with its name in a tooltip: 30px in the bar, 38px in the movie layout. The
|
|
1228
1173
|
* tooltips are set dark like the controls and their menus, whatever the page's theme.
|
|
1229
1174
|
*/
|
|
1230
|
-
function Control(
|
|
1231
|
-
return
|
|
1175
|
+
function Control(props) {
|
|
1176
|
+
return _jsx(MediaControl, { popupClassName: "theme-dark", ...props });
|
|
1232
1177
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
const time = usePlayhead(playhead, (s) => formatTime(s.scrub ?? s.time));
|
|
1237
|
-
return (_jsx("span", { "data-slot": "video-player-time", className: cn("shrink-0 font-mono text-foreground tabular-nums", className), children: time }));
|
|
1178
|
+
/** A control that opens a short list of choices, its menu and tooltip dark like the controls. */
|
|
1179
|
+
function ChoiceMenu(props) {
|
|
1180
|
+
return _jsx(MediaChoiceMenu, { popupClassName: "theme-dark", ...props });
|
|
1238
1181
|
}
|
|
1182
|
+
/* ── The parts that follow the playhead: each reads it from the store and redraws on its own ── */
|
|
1239
1183
|
/** What's left, at the timeline's end, the way streaming apps count down: "−18:56". */
|
|
1240
1184
|
function TimeLeft({ playhead, duration, labels, className, }) {
|
|
1241
1185
|
const left = usePlayhead(playhead, (s) => Math.floor(Math.max(0, duration - (s.scrub ?? s.time))));
|
|
1242
1186
|
return (_jsxs("span", { "data-slot": "video-player-remaining", className: cn("min-w-[6ch] shrink-0 text-right font-mono text-muted-foreground tabular-nums", className), children: [_jsx("span", { className: "sr-only", children: labels.remaining(labels.duration(left)) }), _jsxs("span", { "aria-hidden": true, children: ["\u2212", formatTime(left)] })] }));
|
|
1243
1187
|
}
|
|
1244
|
-
/**
|
|
1245
|
-
* The timeline: the part played, the buffered range, and the moment under the pointer with its
|
|
1246
|
-
* still. Left to right on any page, as a timeline runs: like the tape, not like the text.
|
|
1247
|
-
*/
|
|
1248
|
-
function Scrubber({ playhead, duration, labels, previews, large, frameWidth, className, onSeek, onScrub, onStep, }) {
|
|
1249
|
-
const ready = duration > 0;
|
|
1250
|
-
const shown = usePlayhead(playhead, (s) => s.scrub ?? s.time);
|
|
1251
|
-
const scrub = usePlayhead(playhead, (s) => s.scrub);
|
|
1252
|
-
const buffered = usePlayhead(playhead, (s) => s.buffered);
|
|
1253
|
-
const [hover, setHover] = React.useState(null);
|
|
1254
|
-
// The scrubber's width, for keeping a preview inside it.
|
|
1255
|
-
const [trackWidth, setTrackWidth] = React.useState(0);
|
|
1256
|
-
// The moment under the pointer, or under the thumb while dragging (touch has no hover).
|
|
1257
|
-
const peek = hover ?? (scrub !== null && ready ? { ratio: Math.min(1, scrub / duration), time: scrub } : null);
|
|
1258
|
-
const still = peek && previews ? previews(peek.time) : undefined;
|
|
1259
|
-
const stillWidth = Math.min(large ? PREVIEW_WIDTH_LARGE : PREVIEW_WIDTH, frameWidth * 0.4);
|
|
1260
|
-
const stillScale = still ? stillWidth / still.width : 1;
|
|
1261
|
-
// A preview stays within the timeline; a bare time label is narrow enough to centre anywhere.
|
|
1262
|
-
const peekLeft = !peek
|
|
1263
|
-
? 0
|
|
1264
|
-
: still && trackWidth > stillWidth
|
|
1265
|
-
? Math.min(Math.max(peek.ratio * trackWidth, stillWidth / 2), trackWidth - stillWidth / 2)
|
|
1266
|
-
: peek.ratio * trackWidth;
|
|
1267
|
-
return (_jsx(DirectionProvider, { direction: "ltr", children: _jsx(BaseSlider.Root, { "data-slot": "video-player-scrubber",
|
|
1268
|
-
// Without a length (a live stream) the playhead has no place on the track.
|
|
1269
|
-
value: ready ? shown : 0, min: 0, max: ready ? duration : 1, step: SCRUB_STEP, largeStep: 10, disabled: !ready, onValueChange: (value, { reason }) => {
|
|
1270
|
-
// Dragged or pressed, the thumb shows where it's going and holds the controls; a key only seeks.
|
|
1271
|
-
if (reason === "drag" || reason === "track-press")
|
|
1272
|
-
onScrub(value);
|
|
1273
|
-
else
|
|
1274
|
-
onSeek(value);
|
|
1275
|
-
}, onValueCommitted: () => onScrub(null), className: "min-w-0 flex-1", children: _jsxs(BaseSlider.Control, { className: cn("relative flex w-full cursor-pointer touch-none items-center data-disabled:cursor-default", large ? "py-3" : "py-2.5"), onPointerDown: (event) => setTrackWidth(event.currentTarget.getBoundingClientRect().width), onPointerMove: (event) => {
|
|
1276
|
-
if (event.pointerType === "touch" || !ready)
|
|
1277
|
-
return;
|
|
1278
|
-
const r = event.currentTarget.getBoundingClientRect();
|
|
1279
|
-
const ratio = Math.min(1, Math.max(0, (event.clientX - r.left) / r.width));
|
|
1280
|
-
setTrackWidth(r.width);
|
|
1281
|
-
setHover({ ratio, time: ratio * duration });
|
|
1282
|
-
}, onPointerLeave: () => setHover(null), children: [_jsxs(BaseSlider.Track, { className: cn(trackClass, large && "h-2"), children: [_jsx("span", { "aria-hidden": true, "data-slot": "video-player-buffered", className: "absolute inset-y-0 left-0 rounded-full bg-foreground/20 forced-color-adjust-none forced-colors:bg-[GrayText]", style: { width: ready ? `${Math.min(100, (buffered / duration) * 100)}%` : 0 } }), _jsx(BaseSlider.Indicator, { className: indicatorClass }), _jsx(BaseSlider.Thumb, { "aria-label": labels.seek, getAriaValueText: (_, value) => ready
|
|
1283
|
-
? labels.position(labels.duration(value), labels.duration(duration))
|
|
1284
|
-
: labels.duration(shown), className: cn(thumbClass, large && "size-5"), onKeyDown: (event) => {
|
|
1285
|
-
// Arrows step five seconds, the way the player's own shortcuts do.
|
|
1286
|
-
const forward = event.key === "ArrowRight" || event.key === "ArrowUp";
|
|
1287
|
-
const back = event.key === "ArrowLeft" || event.key === "ArrowDown";
|
|
1288
|
-
if (!forward && !back)
|
|
1289
|
-
return;
|
|
1290
|
-
event.preventDefault();
|
|
1291
|
-
onStep(forward ? 5 : -5);
|
|
1292
|
-
} })] }), peek && (_jsxs("span", { "aria-hidden": true, "data-slot": "video-player-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": "video-player-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: {
|
|
1293
|
-
transform: `translate(${-(still.x ?? 0) * stillScale}px, ${-(still.y ?? 0) * stillScale}px) scale(${stillScale})`,
|
|
1294
|
-
// A whole image is drawn at the still's size; a sheet at its own.
|
|
1295
|
-
...(still.x === undefined && still.y === undefined
|
|
1296
|
-
? { width: still.width, height: still.height }
|
|
1297
|
-
: {}),
|
|
1298
|
-
} }) })), _jsx("span", { className: still ? "py-1" : "px-1.5 py-0.5", children: formatTime(peek.time) })] }))] }) }) }));
|
|
1299
|
-
}
|
|
1300
1188
|
/**
|
|
1301
1189
|
* The skip over a stretch while it plays ("Skip intro"), with the fill that runs down while it's
|
|
1302
1190
|
* offered, and the automatic skips.
|
|
1303
1191
|
*/
|
|
1304
|
-
function SegmentSkip({ playhead, segments, live, failed, playing, titleKey, sourceKey, onSkip, onPress, controlsHidden, large, movie, }) {
|
|
1192
|
+
function SegmentSkip({ playhead, segments, live, failed, playing, titleKey, sourceKey, onSkip, onPress, controlsHidden, large, movie, narrow, onReachChange, }) {
|
|
1305
1193
|
// Without segments, the playhead is no concern of this.
|
|
1306
1194
|
const time = usePlayhead(playhead, (s) => (segments.length > 0 ? s.time : 0));
|
|
1307
1195
|
const segment = live ? segments.find((s) => time >= s.start && time < s.end - SEGMENT_TAIL) : undefined;
|
|
@@ -1360,32 +1248,45 @@ function SegmentSkip({ playhead, segments, live, failed, playing, titleKey, sour
|
|
|
1360
1248
|
return;
|
|
1361
1249
|
box.current.closest('[data-slot="video-player"]')?.focus({ preventScroll: true });
|
|
1362
1250
|
}, [shown]);
|
|
1251
|
+
const offered = Boolean(segment && !failed && shown);
|
|
1252
|
+
React.useLayoutEffect(() => {
|
|
1253
|
+
const el = box.current;
|
|
1254
|
+
const frame = el?.closest('[data-slot="video-player"]');
|
|
1255
|
+
if (!offered || !el || !frame) {
|
|
1256
|
+
onReachChange(0);
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
const measure = () => onReachChange(Math.ceil(frame.getBoundingClientRect().right - el.getBoundingClientRect().left));
|
|
1260
|
+
measure();
|
|
1261
|
+
const observer = new ResizeObserver(measure);
|
|
1262
|
+
observer.observe(el);
|
|
1263
|
+
observer.observe(frame);
|
|
1264
|
+
return () => observer.disconnect();
|
|
1265
|
+
}, [offered, onReachChange]);
|
|
1266
|
+
React.useEffect(() => () => onReachChange(0), [onReachChange]);
|
|
1363
1267
|
if (!segment || failed)
|
|
1364
1268
|
return null;
|
|
1365
1269
|
return (_jsx("div", { ref: box, "data-slot": "video-player-segment", "data-hidden": shown ? undefined : "",
|
|
1366
1270
|
// Gone for the pointer, the keyboard and screen readers alike.
|
|
1367
|
-
inert: !shown, className: cn("theme-dark pointer-events-none absolute right-3 flex bg-transparent transition-[bottom,opacity] duration
|
|
1271
|
+
inert: !shown, className: cn("theme-dark pointer-events-none absolute right-3 flex bg-transparent transition-[bottom,opacity] [transition-duration:var(--duration),var(--duration-fade)] ease-(--ease) @2xl/video:right-5", "data-hidden:opacity-0", large && "right-7!", controlsHidden
|
|
1368
1272
|
? large
|
|
1369
1273
|
? "bottom-7"
|
|
1370
1274
|
: "bottom-4"
|
|
1371
1275
|
: large
|
|
1372
1276
|
? "bottom-[calc(var(--control-h-lg)+72px)]"
|
|
1373
|
-
:
|
|
1374
|
-
? "bottom-[calc(var(--control-h)+
|
|
1375
|
-
:
|
|
1277
|
+
: narrow
|
|
1278
|
+
? "bottom-[calc(var(--control-h)+42px)]"
|
|
1279
|
+
: movie
|
|
1280
|
+
? "bottom-[calc(var(--control-h)+60px)]"
|
|
1281
|
+
: "bottom-[calc(var(--control-h-sm)+44px)] @max-md/video:bottom-[calc(var(--control-h-sm)*2+52px)]"), children: _jsxs(Button, { variant: "secondary", size: large ? "lg" : movie && !narrow ? "default" : "sm", onClick: () => {
|
|
1376
1282
|
onSkip(segment);
|
|
1377
1283
|
onPress();
|
|
1378
1284
|
},
|
|
1379
1285
|
// A long label ("Vorspann überspringen …") stays inside the frame, cut short.
|
|
1380
|
-
className: "pointer-events-auto relative max-w-[calc(100cqw-3.5rem)] overflow-hidden transition-opacity duration-(--duration) ease-
|
|
1286
|
+
className: "pointer-events-auto relative max-w-[calc(100cqw-3.5rem)] overflow-hidden transition-opacity duration-(--duration-fade) ease-(--ease) starting:opacity-0", children: [left > 0 && (_jsx("span", { "aria-hidden": true, "data-slot": "video-player-segment-fill",
|
|
1381
1287
|
// Gliding over one time step (0.1 s, two thirds of the motion token) to meet the next.
|
|
1382
1288
|
className: "absolute inset-y-0 left-0 w-full origin-left bg-foreground/20 transition-transform duration-[calc(var(--duration)*2/3)] ease-linear", style: { transform: `scaleX(${left})` } })), _jsx("span", { className: "relative min-w-0 truncate", children: segment.label })] }, segmentKey) }));
|
|
1383
1289
|
}
|
|
1384
|
-
/** A control that opens a short list of choices — subtitles, audio, quality, speed — named by a tooltip. */
|
|
1385
|
-
function ChoiceMenu({ label, portal, trigger, value, onValueChange, options, onOpenChange, }) {
|
|
1386
|
-
const detailed = options.some((option) => option.detail);
|
|
1387
|
-
return (_jsxs(Menu, { onOpenChange: onOpenChange, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(MenuTrigger, { render: trigger }) }), _jsx(TooltipContent, { portal: portal, className: "theme-dark", children: label })] }), _jsx(MenuContent, { side: "top", align: "end", portal: portal, className: cn("theme-dark", 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-[12px] text-muted-foreground tabular-nums", children: option.detail }))] }, option.value))) })] }) })] }));
|
|
1388
|
-
}
|
|
1389
1290
|
/**
|
|
1390
1291
|
* The series' episodes, a season at a time, to jump to another, the way streaming apps list them:
|
|
1391
1292
|
* a still with how much was watched, the number and title, the length and a line or two about it.
|
|
@@ -1419,7 +1320,7 @@ function EpisodesMenu({ seasons, current, onSeasonOpen, onSelect, labels, portal
|
|
|
1419
1320
|
// "10 episodes", from the episodes once they're there.
|
|
1420
1321
|
const countOf = (s) => {
|
|
1421
1322
|
const count = s.episodes?.length ?? s.count;
|
|
1422
|
-
return count == null ? null : (_jsx("span", { className: "shrink-0 font-mono text-
|
|
1323
|
+
return count == null ? null : (_jsx("span", { className: "shrink-0 font-mono text-12 text-muted-foreground tabular-nums", children: labels.episodeCount(count) }));
|
|
1423
1324
|
};
|
|
1424
1325
|
const header = season && (_jsxs(_Fragment, { children: [_jsx("span", { className: "min-w-0 flex-1 truncate text-foreground", children: season.label }), countOf(season)] }));
|
|
1425
1326
|
return (_jsxs(Menu, { onOpenChange: (next) => {
|
|
@@ -1434,12 +1335,12 @@ function EpisodesMenu({ seasons, current, onSeasonOpen, onSelect, labels, portal
|
|
|
1434
1335
|
}, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(MenuTrigger, { render: _jsx(Button, { variant: "ghost", size: size, "aria-label": labels.episodes, children: _jsx(GalleryVerticalEndIcon, {}) }) }) }), _jsx(TooltipContent, { portal: portal, className: "theme-dark", children: labels.episodes })] }), _jsx(MenuContent, { side: "top", align: "end", portal: portal, className: "theme-dark flex max-h-[min(36rem,var(--available-height,36rem))] w-[min(30rem,var(--available-width))] flex-col overflow-hidden", children: picking ? (_jsxs(MenuGroup, { className: "min-h-0 overflow-y-auto overscroll-contain", children: [_jsx(MenuGroupLabel, { children: labels.seasons }), _jsx(MenuRadioGroup, { value: season?.id ?? "", onValueChange: (id) => showSeason(String(id)), children: seasons.map((s) => (_jsxs(MenuRadioItem, { value: s.id, closeOnClick: false, children: [_jsx("span", { className: "flex-1", children: s.label }), countOf(s)] }, s.id))) })] })) : (_jsxs(_Fragment, { children: [seasons.length > 1 ? (_jsxs(MenuItem, { closeOnClick: false, onClick: () => setPicking(true), "aria-label": `${labels.seasons}: ${season?.label ?? ""}`, className: "shrink-0", children: [_jsx(ChevronLeftIcon, { className: "rtl:-scale-x-100" }), header] })) : (_jsx("div", { className: "flex min-h-(--control-h) shrink-0 items-center gap-2.5 px-2.5 text-sm", children: header })), _jsx(MenuSeparator, { className: "shrink-0" }), _jsx("div", { ref: list, className: "relative min-h-0 overflow-y-auto overscroll-contain", children: _jsx(MenuGroup, { "aria-label": season?.label, "aria-busy": !season?.episodes || undefined, children: season?.episodes
|
|
1435
1336
|
? season.episodes.map((e) => (_jsx(EpisodeItem, { episode: e, playing: e.id === current, labels: labels, onSelect: onSelect }, e.id)))
|
|
1436
1337
|
: // Rows the size of the ones to come, so the list doesn't jump when they do.
|
|
1437
|
-
Array.from({ length: Math.min(season?.count ?? 3, 6) }, (_, i) => (_jsxs("div", { className: "flex items-start gap-3 px-2.5 py-2", children: [_jsx(Skeleton, { shape: "item", className: "aspect-video w-28" }), _jsxs("div", { className: "flex flex-1 flex-col gap-
|
|
1338
|
+
Array.from({ length: Math.min(season?.count ?? 3, 6) }, (_, i) => (_jsxs("div", { className: "flex items-start gap-3 border border-transparent px-2.5 py-2 text-sm", children: [_jsx(Skeleton, { shape: "item", className: "aspect-video w-28" }), _jsxs("div", { className: "flex flex-1 flex-col gap-1 py-0.5", children: [_jsx(Skeleton, { className: "w-2/3" }), _jsx(Skeleton, { lines: 2, className: "text-13 leading-snug" })] })] }, i))) }) })] })) })] }));
|
|
1438
1339
|
}
|
|
1439
1340
|
/** One row of the episode list. The episode playing is marked, and choosing it only closes the list. */
|
|
1440
1341
|
function EpisodeItem({ episode: e, playing, labels, onSelect, }) {
|
|
1441
1342
|
const progress = Math.min(1, Math.max(0, e.progress ?? 0));
|
|
1442
|
-
return (_jsxs(MenuItem, { "data-current": playing ? "" : undefined, "aria-current": playing || undefined, onClick: () => !playing && onSelect(e.id), className: "items-start gap-3 py-2 data-current:bg-foreground/5", children: [_jsxs("span", { className: "relative aspect-video w-28 shrink-0 overflow-hidden rounded-item bg-black ring-1 ring-field-edge", children: [e.image && (_jsx("img", { src: e.image, alt: "", loading: "lazy", decoding: "async", draggable: false, className: "size-full object-cover" })), playing && (_jsx("span", { className: "absolute inset-0 flex items-center justify-center bg-black/45", children: _jsx(PlayIcon, { className: "size-4 translate-x-px text-foreground" }) })), progress > 0 && (_jsx("span", { className: "absolute inset-x-0 bottom-0 h-[3px] bg-foreground/25", children: _jsx("span", { className: "block h-full bg-foreground", style: { width: `${progress * 100}%` } }) }))] }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-1 py-0.5", children: [_jsxs("span", { className: "flex items-baseline gap-2", children: [e.number != null && (_jsx("span", { className: "shrink-0 font-mono text-
|
|
1343
|
+
return (_jsxs(MenuItem, { "data-current": playing ? "" : undefined, "aria-current": playing || undefined, onClick: () => !playing && onSelect(e.id), className: "items-start gap-3 py-2 data-current:bg-foreground/5", children: [_jsxs("span", { className: "relative aspect-video w-28 shrink-0 overflow-hidden rounded-item bg-black ring-1 ring-field-edge", children: [e.image && (_jsx("img", { src: e.image, alt: "", loading: "lazy", decoding: "async", draggable: false, className: "size-full object-cover" })), playing && (_jsx("span", { className: "absolute inset-0 flex items-center justify-center bg-black/45", children: _jsx(PlayIcon, { className: "size-4 translate-x-px text-foreground" }) })), progress > 0 && (_jsx("span", { className: "absolute inset-x-0 bottom-0 h-[3px] bg-foreground/25", children: _jsx("span", { className: "block h-full bg-foreground", style: { width: `${progress * 100}%` } }) }))] }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-1 py-0.5", children: [_jsxs("span", { className: "flex items-baseline gap-2", children: [e.number != null && (_jsx("span", { className: "shrink-0 font-mono text-12 text-muted-foreground tabular-nums", children: e.number })), _jsx("span", { className: "min-w-0 flex-1 truncate text-foreground", children: e.title }), (playing || e.duration) && (_jsx("span", { className: "shrink-0 font-mono text-12 text-muted-foreground", children: playing ? labels.nowPlaying : e.duration }))] }), e.description && (_jsx("span", { className: "line-clamp-2 text-13 leading-snug text-muted-foreground", children: e.description }))] })] }));
|
|
1443
1344
|
}
|
|
1444
1345
|
/** A turning arrow with the seconds it skips, set in Licht Mono inside it. */
|
|
1445
1346
|
function SkipIcon({ direction, large }) {
|