@zonsh/ui 0.4.1 → 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 +7 -7
- 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/ascii-field.js +2 -1
- 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 +389 -24
- 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 +64 -8
- 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 +38 -1
- package/dist/components/chart.js +27 -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 +4 -4
- 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 +37 -12
- 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 +77 -16
- package/dist/components/copy-button.d.ts +1 -1
- package/dist/components/copy-button.js +8 -6
- 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 +190 -28
- package/dist/components/illustration.js +53 -31
- package/dist/components/input-group.d.ts +6 -11
- package/dist/components/input-group.js +21 -19
- 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/layout.d.ts +2 -1
- package/dist/components/layout.js +55 -11
- package/dist/components/lightbox.d.ts +76 -9
- package/dist/components/lightbox.js +354 -48
- 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 +153 -31
- package/dist/components/message.d.ts +62 -11
- package/dist/components/message.js +51 -14
- 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 -10
- package/dist/components/number-field.d.ts +2 -9
- package/dist/components/number-field.js +90 -26
- 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 +35 -17
- 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 +8 -3
- 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 +4 -3
- package/dist/components/response.js +39 -15
- 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 +90 -31
- package/dist/components/site-header.d.ts +18 -13
- package/dist/components/site-header.js +26 -9
- package/dist/components/skeleton.d.ts +18 -8
- package/dist/components/skeleton.js +23 -8
- package/dist/components/slider.js +2 -2
- package/dist/components/sortable.d.ts +55 -4
- package/dist/components/sortable.js +187 -94
- 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 +13 -7
- package/dist/components/table.js +124 -23
- package/dist/components/tabs.js +15 -8
- 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 +50 -7
- package/dist/components/theme.js +168 -12
- package/dist/components/time-field.d.ts +6 -10
- package/dist/components/time-field.js +19 -9
- 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 +17 -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 +8 -3
- package/dist/components/toolbar.d.ts +57 -4
- package/dist/components/toolbar.js +219 -16
- package/dist/components/tooltip.d.ts +5 -3
- package/dist/components/tooltip.js +14 -6
- package/dist/components/tour.d.ts +1 -1
- package/dist/components/tour.js +70 -24
- package/dist/components/tree.js +33 -10
- 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 +182 -225
- 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 +10 -4
- package/dist/lib/glide.js +14 -5
- 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 +4 -3
- package/dist/lib/table-fit.js +92 -25
- 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 +75 -77
- 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 -193
- package/dist/styles/material.css +177 -31
- package/dist/styles/parts/ai.css +20 -14
- package/dist/styles/parts/brand.css +2 -2
- package/dist/styles/parts/controls.css +51 -38
- package/dist/styles/parts/data.css +43 -11
- package/dist/styles/parts/editor.css +372 -0
- package/dist/styles/parts/feedback.css +75 -15
- 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 +237 -25
- package/dist/styles/parts/overlays.css +110 -8
- package/dist/styles/parts/pdf.css +15 -9
- package/dist/styles/pdf.css +3 -0
- package/dist/styles/prose.css +3 -0
- package/dist/styles/tokens.css +105 -15
- package/dist/theme.d.ts +1 -0
- package/dist/theme.js +5 -0
- package/dist/vite.d.ts +48 -59
- package/dist/vite.js +54 -21
- package/package.json +69 -2
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The digit roll's engine, shared by NumberRoll and NumberField: a number drawn as cells — one per
|
|
3
|
+
* digit, separator or sign — whose changed digits roll like an odometer's to their new value.
|
|
4
|
+
*
|
|
5
|
+
* Each digit is a short tape of characters stacked in one grid cell and moved by `--roll-y` (a
|
|
6
|
+
* registered number, so the Web Animations API tweens it). A new value that arrives mid-roll reads
|
|
7
|
+
* where each tape is now, keeps the one or two characters in view, adds the new one on the side the
|
|
8
|
+
* value moves to and rolls on from there: a fast run of changes keeps rolling and lands exactly on
|
|
9
|
+
* the last value, never snapping. Places that come or go open and close their width; separators and
|
|
10
|
+
* signs only fade. The keyframes-free CSS lives in parts/inputs.css, under `[data-roll-face]`.
|
|
11
|
+
*/
|
|
12
|
+
/** The parts that make up the number itself, laid out left to right in every locale. */
|
|
13
|
+
export const CORE = new Set(["integer", "group", "decimal", "fraction"]);
|
|
14
|
+
const DIGITS = new Set(["integer", "fraction"]);
|
|
15
|
+
/** The most moving digits that wait for the one before: 1/12 of the roll apart, three steps at most. */
|
|
16
|
+
export const STAGGER_STEPS = 3;
|
|
17
|
+
/** @internal The formatted value as cells, each keyed by its place. */
|
|
18
|
+
export function cellsOf(parts) {
|
|
19
|
+
const integerDigits = parts
|
|
20
|
+
.filter((p) => p.type === "integer")
|
|
21
|
+
.reduce((n, p) => n + Array.from(p.value).length, 0);
|
|
22
|
+
let place = integerDigits;
|
|
23
|
+
let fraction = 0;
|
|
24
|
+
const seen = {};
|
|
25
|
+
const cells = [];
|
|
26
|
+
for (const part of parts) {
|
|
27
|
+
if (part.type === "integer") {
|
|
28
|
+
for (const char of Array.from(part.value))
|
|
29
|
+
cells.push({ key: `i${--place}`, type: part.type, char });
|
|
30
|
+
}
|
|
31
|
+
else if (part.type === "fraction") {
|
|
32
|
+
for (const char of Array.from(part.value))
|
|
33
|
+
cells.push({ key: `f${fraction++}`, type: part.type, char });
|
|
34
|
+
}
|
|
35
|
+
else if (part.type === "group") {
|
|
36
|
+
// Named by the place of the digit after it: 999 → 1,000 grows the separator before the hundreds.
|
|
37
|
+
cells.push({ key: `g${place - 1}`, type: part.type, char: part.value });
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const n = (seen[part.type] = (seen[part.type] ?? -1) + 1);
|
|
41
|
+
cells.push({ key: `${part.type}${n}`, type: part.type, char: part.value });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return cells;
|
|
45
|
+
}
|
|
46
|
+
const DIGIT = /\p{Nd}/u;
|
|
47
|
+
/**
|
|
48
|
+
* @internal Text already formatted (a NumberField's input) as cells: digits before `decimal` are
|
|
49
|
+
* the integer, after it the fraction; a sign between integer digits is a group separator.
|
|
50
|
+
*/
|
|
51
|
+
export function cellsOfText(text, decimal) {
|
|
52
|
+
const chars = Array.from(text);
|
|
53
|
+
const point = chars.lastIndexOf(decimal);
|
|
54
|
+
const parts = [];
|
|
55
|
+
chars.forEach((char, i) => {
|
|
56
|
+
let type;
|
|
57
|
+
if (DIGIT.test(char))
|
|
58
|
+
type = point >= 0 && i > point ? "fraction" : "integer";
|
|
59
|
+
else if (i === point)
|
|
60
|
+
type = "decimal";
|
|
61
|
+
else if ((point < 0 || i < point) && DIGIT.test(chars[i - 1] ?? "") && DIGIT.test(chars[i + 1] ?? ""))
|
|
62
|
+
type = "group";
|
|
63
|
+
else
|
|
64
|
+
type = "literal";
|
|
65
|
+
parts.push({ type, value: char });
|
|
66
|
+
});
|
|
67
|
+
return cellsOf(parts);
|
|
68
|
+
}
|
|
69
|
+
/** @internal The cells of a step from one value to the next: what stays, changes, comes and goes. */
|
|
70
|
+
export function rollCells(from, to) {
|
|
71
|
+
const before = new Map(from.map((c) => [c.key, c]));
|
|
72
|
+
const after = new Set(to.map((c) => c.key));
|
|
73
|
+
const out = [];
|
|
74
|
+
const take = (cell) => {
|
|
75
|
+
const old = before.get(cell.key);
|
|
76
|
+
const state = !old ? "enter" : old.char === cell.char ? "same" : "change";
|
|
77
|
+
out.push({ ...cell, state, from: old?.char });
|
|
78
|
+
};
|
|
79
|
+
let j = 0;
|
|
80
|
+
for (const old of from) {
|
|
81
|
+
if (after.has(old.key)) {
|
|
82
|
+
const at = to.findIndex((c, i) => i >= j && c.key === old.key);
|
|
83
|
+
if (at < 0)
|
|
84
|
+
continue;
|
|
85
|
+
for (; j <= at; j++)
|
|
86
|
+
take(to[j]);
|
|
87
|
+
}
|
|
88
|
+
else
|
|
89
|
+
out.push({ ...old, state: "leave", from: old.char });
|
|
90
|
+
}
|
|
91
|
+
for (; j < to.length; j++)
|
|
92
|
+
take(to[j]);
|
|
93
|
+
// The least significant moving digit rolls first, the next one a step later, three steps at most.
|
|
94
|
+
let step = 0;
|
|
95
|
+
for (let i = out.length - 1; i >= 0; i--) {
|
|
96
|
+
const cell = out[i];
|
|
97
|
+
if (cell.state === "same")
|
|
98
|
+
continue;
|
|
99
|
+
// A separator that comes or goes moves with the digit before it: 999 → 1,000 opens both together.
|
|
100
|
+
if (DIGITS.has(cell.type))
|
|
101
|
+
cell.step = Math.min(step++, STAGGER_STEPS);
|
|
102
|
+
else if (cell.type === "group")
|
|
103
|
+
cell.step = Math.min(step, STAGGER_STEPS);
|
|
104
|
+
}
|
|
105
|
+
return out;
|
|
106
|
+
}
|
|
107
|
+
const escape = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
108
|
+
/** @internal The face's markup at rest, for the server's render: the same the engine builds. */
|
|
109
|
+
export function faceHtml(cells) {
|
|
110
|
+
const cell = (c) => DIGITS.has(c.type)
|
|
111
|
+
? `<span data-cell="" data-digit=""><span data-c="${escape(c.char)}"></span></span>`
|
|
112
|
+
: `<span data-cell=""><span data-c="${escape(c.char)}"></span></span>`;
|
|
113
|
+
const before = [];
|
|
114
|
+
const core = [];
|
|
115
|
+
const after = [];
|
|
116
|
+
for (const c of cells)
|
|
117
|
+
(CORE.has(c.type) ? core : core.length ? after : before).push(cell(c));
|
|
118
|
+
return `${before.join("")}<span dir="ltr" data-number="">${core.join("")}</span>${after.join("")}`;
|
|
119
|
+
}
|
|
120
|
+
function glyph(char, i) {
|
|
121
|
+
const g = document.createElement("span");
|
|
122
|
+
g.setAttribute("data-c", char);
|
|
123
|
+
if (i)
|
|
124
|
+
g.style.setProperty("--i", String(i));
|
|
125
|
+
return g;
|
|
126
|
+
}
|
|
127
|
+
/** Puts `kids` in `parent` in order, moving only the ones out of place. */
|
|
128
|
+
function sync(parent, kids) {
|
|
129
|
+
kids.forEach((kid, i) => {
|
|
130
|
+
if (parent.children[i] !== kid)
|
|
131
|
+
parent.insertBefore(kid, parent.children[i] ?? null);
|
|
132
|
+
});
|
|
133
|
+
while (parent.children.length > kids.length)
|
|
134
|
+
parent.lastElementChild.remove();
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @internal The engine: owns the children of `face`. `set` moves to a new value — rolling from
|
|
138
|
+
* wherever each digit is — and `jump` puts one in place. `onRolling` reports when motion starts and
|
|
139
|
+
* when everything has landed.
|
|
140
|
+
*/
|
|
141
|
+
export class NumberRoller {
|
|
142
|
+
face;
|
|
143
|
+
onRolling;
|
|
144
|
+
cells = new Map();
|
|
145
|
+
order = [];
|
|
146
|
+
number;
|
|
147
|
+
running = new Set();
|
|
148
|
+
rolling = false;
|
|
149
|
+
constructor(face, cells, onRolling) {
|
|
150
|
+
this.face = face;
|
|
151
|
+
this.onRolling = onRolling;
|
|
152
|
+
this.number = document.createElement("span");
|
|
153
|
+
this.number.dir = "ltr";
|
|
154
|
+
this.number.setAttribute("data-number", "");
|
|
155
|
+
this.jump(cells);
|
|
156
|
+
}
|
|
157
|
+
/** The text it shows or is rolling to. */
|
|
158
|
+
get text() {
|
|
159
|
+
return this.order
|
|
160
|
+
.map((k) => this.cells.get(k))
|
|
161
|
+
.filter((c) => !c.leaving)
|
|
162
|
+
.map((c) => c.char)
|
|
163
|
+
.join("");
|
|
164
|
+
}
|
|
165
|
+
get isRolling() {
|
|
166
|
+
return this.rolling;
|
|
167
|
+
}
|
|
168
|
+
/** The value in place at once: anything rolling stops where it was going. */
|
|
169
|
+
jump(cells) {
|
|
170
|
+
this.cancelAll();
|
|
171
|
+
this.cells.clear();
|
|
172
|
+
for (const c of cells)
|
|
173
|
+
this.cells.set(c.key, this.make(c, c.char));
|
|
174
|
+
this.order = cells.map((c) => c.key);
|
|
175
|
+
this.place();
|
|
176
|
+
this.setRolling(false);
|
|
177
|
+
}
|
|
178
|
+
/** Rolls to a new value from wherever every digit is now. */
|
|
179
|
+
set(cells, o) {
|
|
180
|
+
if (!(o.duration > 0) || typeof this.face.animate !== "function" || !this.face.isConnected) {
|
|
181
|
+
return this.jump(cells);
|
|
182
|
+
}
|
|
183
|
+
const now = this.order.map((k) => {
|
|
184
|
+
const c = this.cells.get(k);
|
|
185
|
+
// A place on its way out counts as empty, so a value that brings it back opens it again.
|
|
186
|
+
return { key: k, type: c.type, char: c.leaving ? "" : c.char };
|
|
187
|
+
});
|
|
188
|
+
const steps = rollCells(now, cells);
|
|
189
|
+
for (const s of steps)
|
|
190
|
+
if (!this.cells.has(s.key))
|
|
191
|
+
this.cells.set(s.key, this.make(s, ""));
|
|
192
|
+
this.order = steps.map((s) => s.key);
|
|
193
|
+
this.place();
|
|
194
|
+
for (const s of steps) {
|
|
195
|
+
if (s.state === "same")
|
|
196
|
+
continue;
|
|
197
|
+
const cell = this.cells.get(s.key);
|
|
198
|
+
const leave = s.state === "leave";
|
|
199
|
+
if (leave && cell.leaving)
|
|
200
|
+
continue;
|
|
201
|
+
const idle = !cell.move && !cell.size && !cell.fade;
|
|
202
|
+
const delay = o.stagger && idle ? ((s.step ?? 0) * o.duration) / 12 : 0;
|
|
203
|
+
const timing = {
|
|
204
|
+
duration: o.duration,
|
|
205
|
+
easing: o.easing,
|
|
206
|
+
delay,
|
|
207
|
+
fill: "backwards",
|
|
208
|
+
};
|
|
209
|
+
// Coming (or coming back while it was going): its place opens.
|
|
210
|
+
const enter = !leave && (s.state === "enter" || cell.leaving);
|
|
211
|
+
if (cell.digit) {
|
|
212
|
+
this.roll(cell, leave ? "" : s.char, o.dir, timing);
|
|
213
|
+
}
|
|
214
|
+
else if (!leave && !enter) {
|
|
215
|
+
// A separator or sign that changes swaps in place.
|
|
216
|
+
cell.char = s.char;
|
|
217
|
+
cell.el.firstElementChild?.setAttribute("data-c", s.char);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
if (enter) {
|
|
221
|
+
cell.char = s.char;
|
|
222
|
+
cell.el.firstElementChild?.setAttribute("data-c", s.char);
|
|
223
|
+
}
|
|
224
|
+
this.fade(cell, leave ? 0 : 1, timing);
|
|
225
|
+
}
|
|
226
|
+
if (enter || leave)
|
|
227
|
+
this.size(cell, leave, timing);
|
|
228
|
+
cell.leaving = leave;
|
|
229
|
+
}
|
|
230
|
+
if (this.running.size === 0)
|
|
231
|
+
this.settle();
|
|
232
|
+
}
|
|
233
|
+
/** Stops every animation; the engine is done. */
|
|
234
|
+
destroy() {
|
|
235
|
+
this.cancelAll();
|
|
236
|
+
}
|
|
237
|
+
make(c, char) {
|
|
238
|
+
const el = document.createElement("span");
|
|
239
|
+
el.setAttribute("data-cell", "");
|
|
240
|
+
const digit = DIGITS.has(c.type);
|
|
241
|
+
if (digit)
|
|
242
|
+
el.setAttribute("data-digit", "");
|
|
243
|
+
el.append(glyph(char));
|
|
244
|
+
if (!char) {
|
|
245
|
+
// A new place starts closed.
|
|
246
|
+
el.style.width = "0px";
|
|
247
|
+
if (!digit)
|
|
248
|
+
el.style.opacity = "0";
|
|
249
|
+
}
|
|
250
|
+
return { key: c.key, type: c.type, digit, el, tape: [char], char, leaving: false };
|
|
251
|
+
}
|
|
252
|
+
place() {
|
|
253
|
+
const before = [];
|
|
254
|
+
const core = [];
|
|
255
|
+
const after = [];
|
|
256
|
+
for (const k of this.order) {
|
|
257
|
+
const c = this.cells.get(k);
|
|
258
|
+
(CORE.has(c.type) ? core : core.length ? after : before).push(c.el);
|
|
259
|
+
}
|
|
260
|
+
sync(this.face, [...before, this.number, ...after]);
|
|
261
|
+
sync(this.number, core);
|
|
262
|
+
}
|
|
263
|
+
/** Where the digit's tape is now, mid-roll included. */
|
|
264
|
+
position(cell) {
|
|
265
|
+
const read = parseFloat(getComputedStyle(cell.el).getPropertyValue("--roll-y"));
|
|
266
|
+
const own = parseFloat(cell.el.style.getPropertyValue("--roll-y")) || 0;
|
|
267
|
+
const y = cell.move && Number.isFinite(read) ? read : own;
|
|
268
|
+
return Math.min(Math.max(y, 0), cell.tape.length - 1);
|
|
269
|
+
}
|
|
270
|
+
roll(cell, to, dir, timing) {
|
|
271
|
+
if (to === cell.char)
|
|
272
|
+
return;
|
|
273
|
+
const y = this.position(cell);
|
|
274
|
+
const lo = Math.floor(y);
|
|
275
|
+
// The one or two characters in view now; the rest of the tape has rolled away.
|
|
276
|
+
const kept = cell.tape.slice(lo, Math.ceil(y) + 1);
|
|
277
|
+
let from = y - lo;
|
|
278
|
+
let tape;
|
|
279
|
+
let target;
|
|
280
|
+
if (dir > 0) {
|
|
281
|
+
// Up: the new character comes from below — or the one below already is it.
|
|
282
|
+
if (kept.at(-1) === to)
|
|
283
|
+
[tape, target] = [kept, kept.length - 1];
|
|
284
|
+
else
|
|
285
|
+
[tape, target] = [[...kept, to], kept.length];
|
|
286
|
+
}
|
|
287
|
+
else if (kept[0] === to)
|
|
288
|
+
[tape, target] = [kept, 0];
|
|
289
|
+
else {
|
|
290
|
+
tape = [to, ...kept];
|
|
291
|
+
target = 0;
|
|
292
|
+
from += 1;
|
|
293
|
+
}
|
|
294
|
+
this.stop(cell.move);
|
|
295
|
+
cell.move = undefined;
|
|
296
|
+
cell.tape = tape;
|
|
297
|
+
cell.char = to;
|
|
298
|
+
cell.el.replaceChildren(...tape.map((c, i) => glyph(c, i)));
|
|
299
|
+
cell.el.style.setProperty("--roll-y", String(target));
|
|
300
|
+
if (from !== target) {
|
|
301
|
+
cell.move = this.animate(cell, [{ "--roll-y": from }, { "--roll-y": target }], timing);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/** Opens or closes the cell's place from its width now. */
|
|
305
|
+
size(cell, close, timing) {
|
|
306
|
+
const el = cell.el;
|
|
307
|
+
const from = el.getBoundingClientRect().width;
|
|
308
|
+
this.stop(cell.size);
|
|
309
|
+
cell.size = undefined;
|
|
310
|
+
el.style.width = "";
|
|
311
|
+
const to = close ? 0 : el.getBoundingClientRect().width;
|
|
312
|
+
el.style.width = `${to}px`;
|
|
313
|
+
if (from !== to)
|
|
314
|
+
cell.size = this.animate(cell, [{ width: `${from}px` }, { width: `${to}px` }], timing);
|
|
315
|
+
}
|
|
316
|
+
fade(cell, to, timing) {
|
|
317
|
+
const el = cell.el;
|
|
318
|
+
const read = parseFloat(getComputedStyle(el).opacity);
|
|
319
|
+
const from = Number.isFinite(read) ? read : 1 - to;
|
|
320
|
+
this.stop(cell.fade);
|
|
321
|
+
cell.fade = undefined;
|
|
322
|
+
el.style.opacity = String(to);
|
|
323
|
+
if (from !== to)
|
|
324
|
+
cell.fade = this.animate(cell, [{ opacity: from }, { opacity: to }], timing);
|
|
325
|
+
}
|
|
326
|
+
animate(cell, keyframes, timing) {
|
|
327
|
+
const a = cell.el.animate(keyframes, timing);
|
|
328
|
+
// A roll replaced mid-way is cancelled on purpose.
|
|
329
|
+
a.finished?.catch(() => { });
|
|
330
|
+
// Started now rather than at the next frame, so a run of fast changes (a held key) moves on
|
|
331
|
+
// every frame instead of holding still for one at each change.
|
|
332
|
+
const now = document.timeline?.currentTime;
|
|
333
|
+
if (typeof now === "number")
|
|
334
|
+
a.startTime = now;
|
|
335
|
+
this.running.add(a);
|
|
336
|
+
cell.el.setAttribute("data-moving", "");
|
|
337
|
+
this.setRolling(true);
|
|
338
|
+
a.addEventListener("finish", () => {
|
|
339
|
+
if (!this.running.delete(a))
|
|
340
|
+
return;
|
|
341
|
+
if (cell.move === a)
|
|
342
|
+
cell.move = undefined;
|
|
343
|
+
if (cell.size === a)
|
|
344
|
+
cell.size = undefined;
|
|
345
|
+
if (cell.fade === a)
|
|
346
|
+
cell.fade = undefined;
|
|
347
|
+
if (this.running.size === 0)
|
|
348
|
+
this.settle();
|
|
349
|
+
});
|
|
350
|
+
return a;
|
|
351
|
+
}
|
|
352
|
+
stop(a) {
|
|
353
|
+
if (!a)
|
|
354
|
+
return;
|
|
355
|
+
this.running.delete(a);
|
|
356
|
+
a.cancel();
|
|
357
|
+
}
|
|
358
|
+
cancelAll() {
|
|
359
|
+
for (const a of [...this.running])
|
|
360
|
+
this.stop(a);
|
|
361
|
+
for (const c of this.cells.values())
|
|
362
|
+
c.move = c.size = c.fade = undefined;
|
|
363
|
+
}
|
|
364
|
+
/** Everything has landed: each tape back to its one character, closed places gone. */
|
|
365
|
+
settle() {
|
|
366
|
+
for (const [key, c] of this.cells) {
|
|
367
|
+
if (c.leaving) {
|
|
368
|
+
c.el.remove();
|
|
369
|
+
this.cells.delete(key);
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
372
|
+
if (c.digit && (c.tape.length > 1 || c.el.style.getPropertyValue("--roll-y"))) {
|
|
373
|
+
c.tape = [c.char];
|
|
374
|
+
c.el.replaceChildren(glyph(c.char));
|
|
375
|
+
c.el.style.removeProperty("--roll-y");
|
|
376
|
+
}
|
|
377
|
+
c.el.style.width = "";
|
|
378
|
+
c.el.style.opacity = "";
|
|
379
|
+
c.el.removeAttribute("data-moving");
|
|
380
|
+
c.move = c.size = c.fade = undefined;
|
|
381
|
+
}
|
|
382
|
+
this.order = this.order.filter((k) => this.cells.has(k));
|
|
383
|
+
this.setRolling(false);
|
|
384
|
+
}
|
|
385
|
+
setRolling(on) {
|
|
386
|
+
if (this.rolling === on)
|
|
387
|
+
return;
|
|
388
|
+
this.rolling = on;
|
|
389
|
+
this.onRolling?.(on);
|
|
390
|
+
}
|
|
391
|
+
}
|
package/dist/lib/platform.d.ts
CHANGED
|
@@ -36,3 +36,9 @@ export declare function keyNames(keys: string[], mod: string, names?: KeyNames):
|
|
|
36
36
|
* modifiers in Apple's order), joined with "+" elsewhere ("Ctrl+Shift+Z").
|
|
37
37
|
*/
|
|
38
38
|
export declare function formatShortcut(keys: string[], mod: string, names?: KeyNames): string;
|
|
39
|
+
/**
|
|
40
|
+
* A phone: a coarse primary pointer and a viewport under 768px — where a Select opens the native
|
|
41
|
+
* picker (`native="touch"`) and a FilterBar edits in a bottom sheet. False on the server, and
|
|
42
|
+
* when not `enabled`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function usePhone(enabled?: boolean): boolean;
|
package/dist/lib/platform.js
CHANGED
|
@@ -73,3 +73,17 @@ export function formatShortcut(keys, mod, names) {
|
|
|
73
73
|
});
|
|
74
74
|
return keyNames(sorted, mod).join("");
|
|
75
75
|
}
|
|
76
|
+
const PHONE_QUERY = "(pointer: coarse) and (width < 48rem)";
|
|
77
|
+
const subscribePhone = (onChange) => {
|
|
78
|
+
const mq = window.matchMedia(PHONE_QUERY);
|
|
79
|
+
mq.addEventListener("change", onChange);
|
|
80
|
+
return () => mq.removeEventListener("change", onChange);
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A phone: a coarse primary pointer and a viewport under 768px — where a Select opens the native
|
|
84
|
+
* picker (`native="touch"`) and a FilterBar edits in a bottom sheet. False on the server, and
|
|
85
|
+
* when not `enabled`.
|
|
86
|
+
*/
|
|
87
|
+
export function usePhone(enabled = true) {
|
|
88
|
+
return React.useSyncExternalStore(enabled ? subscribePhone : noSubscribe, () => enabled && window.matchMedia(PHONE_QUERY).matches, () => false);
|
|
89
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the library's popups portal to: the element ThemeScope keeps at the end of `<body>` with
|
|
3
|
+
* its theme, so a menu, a dialog or a toast opened inside a themed area takes that area's theme.
|
|
4
|
+
* `undefined` outside a ThemeScope: Base UI's default, `document.body`. `null` while the scope is
|
|
5
|
+
* still making its element: the popup waits for it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PortalContainerContext: import("react").Context<HTMLElement | null | undefined>;
|
|
8
|
+
/** The element popups portal to here (see PortalContainerContext). */
|
|
9
|
+
export declare const usePortalContainer: () => HTMLElement | null | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Where the library's popups portal to: the element ThemeScope keeps at the end of `<body>` with
|
|
4
|
+
* its theme, so a menu, a dialog or a toast opened inside a themed area takes that area's theme.
|
|
5
|
+
* `undefined` outside a ThemeScope: Base UI's default, `document.body`. `null` while the scope is
|
|
6
|
+
* still making its element: the popup waits for it.
|
|
7
|
+
*/
|
|
8
|
+
export const PortalContainerContext = createContext(undefined);
|
|
9
|
+
/** The element popups portal to here (see PortalContainerContext). */
|
|
10
|
+
export const usePortalContainer = () => useContext(PortalContainerContext);
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Press feedback for the phone parts: an element marked `data-press` takes `data-pressing` the
|
|
3
|
+
* moment a finger, pen or mouse goes down on it, and loses it when the press ends — or as soon as
|
|
4
|
+
* it moves (a scroll, a swipe), so a list that is being scrolled never lights up its rows.
|
|
5
|
+
*
|
|
6
|
+
* The browser's own `:active` is not enough on a phone: Chrome shows it only once it is sure the
|
|
7
|
+
* touch is not a scroll, and iOS Safari only with a touch listener in place. So the press is
|
|
8
|
+
* written here, from one set of listeners on the document, installed while a part that uses it is
|
|
9
|
+
* mounted. The styles answer `data-pressing`: the `press-shade` utility (material.css) darkens a
|
|
10
|
+
* flat surface, and the button materials sink as they do on `:active`.
|
|
11
|
+
*
|
|
12
|
+
* A press inside a pressable row lands on the innermost pressable or button under the finger, so
|
|
13
|
+
* a "…" button in a row presses itself, not the row. Text fields never press.
|
|
14
|
+
*
|
|
15
|
+
* Pressed, the thing under the finger also gives a little: it shrinks to 97% (a small target) or
|
|
16
|
+
* 98.5% (a row or a card 200px and wider) in 0.6 × --duration-fade, and springs back over
|
|
17
|
+
* --duration on --ease when it is let go. Scale only, so nothing around it moves. A pressable
|
|
18
|
+
* inside a `data-press-group` (a card of choices) shrinks the whole group instead, so a row's
|
|
19
|
+
* shade still meets the card's edge. `--press-scale: 1` on an element turns it off (a control
|
|
20
|
+
* with a press scale of its own). None under reduced motion, where --duration is 0.
|
|
21
|
+
*/
|
|
22
|
+
import * as React from "react";
|
|
23
|
+
import { GESTURE_SLOP } from "./gesture.js";
|
|
24
|
+
import { cssDuration, cssEase, cssTime } from "./motion.js";
|
|
25
|
+
const PRESSABLE = "[data-press]";
|
|
26
|
+
const BUTTON = "button, [role=button]";
|
|
27
|
+
const FIELD = "input, textarea, select, [contenteditable]:not([contenteditable=false])";
|
|
28
|
+
let press = null;
|
|
29
|
+
let installs = 0;
|
|
30
|
+
/** The press's scale on each element that has one, so a release continues from where it is. */
|
|
31
|
+
const shrinks = new WeakMap();
|
|
32
|
+
/** What a press on `el` scales: its card when it is one of a group of choices, else itself. */
|
|
33
|
+
const scaleTarget = (el) => el.closest("[data-press-group]") ?? el;
|
|
34
|
+
/** How far a target shrinks: a little for a small target, less for a full-width row or card. */
|
|
35
|
+
function pressScale(el) {
|
|
36
|
+
const own = Number.parseFloat(getComputedStyle(el).getPropertyValue("--press-scale"));
|
|
37
|
+
if (Number.isFinite(own))
|
|
38
|
+
return own;
|
|
39
|
+
return el.offsetWidth >= 200 ? 0.985 : 0.97;
|
|
40
|
+
}
|
|
41
|
+
/** Scales `el` to `to` from wherever it is now, on a scripted animation (no CSS of its own). */
|
|
42
|
+
function scaleTo(el, to, duration) {
|
|
43
|
+
if (typeof el.animate !== "function")
|
|
44
|
+
return;
|
|
45
|
+
const running = shrinks.get(el);
|
|
46
|
+
const from = running ? getComputedStyle(el).scale : "1";
|
|
47
|
+
running?.cancel();
|
|
48
|
+
if (to === 1 && (from === "none" || from === "1")) {
|
|
49
|
+
shrinks.delete(el);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const animation = el.animate([{ scale: from === "none" ? "1" : from }, { scale: `${to}` }], {
|
|
53
|
+
duration,
|
|
54
|
+
easing: cssEase("--ease", el),
|
|
55
|
+
fill: "forwards",
|
|
56
|
+
});
|
|
57
|
+
shrinks.set(el, animation);
|
|
58
|
+
if (to === 1) {
|
|
59
|
+
animation.onfinish = () => {
|
|
60
|
+
if (shrinks.get(el) !== animation)
|
|
61
|
+
return;
|
|
62
|
+
animation.cancel();
|
|
63
|
+
shrinks.delete(el);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** Shrinks what the press landed on, unless motion is reduced or it opts out. */
|
|
68
|
+
function shrink(el) {
|
|
69
|
+
const duration = cssDuration(el);
|
|
70
|
+
if (!duration)
|
|
71
|
+
return;
|
|
72
|
+
const target = scaleTarget(el);
|
|
73
|
+
const to = pressScale(target);
|
|
74
|
+
if (to < 1)
|
|
75
|
+
scaleTo(target, to, cssTime("--duration-fade", el) * 0.6);
|
|
76
|
+
}
|
|
77
|
+
/** Lets the shrink go: it springs back over --duration on --ease, from where it had got to. */
|
|
78
|
+
function unshrink(el) {
|
|
79
|
+
const target = scaleTarget(el);
|
|
80
|
+
if (shrinks.has(target))
|
|
81
|
+
scaleTo(target, 1, cssDuration(el));
|
|
82
|
+
}
|
|
83
|
+
const disabled = (el) => el.matches(":disabled, [aria-disabled=true], [data-disabled]") || !!el.closest("[inert]");
|
|
84
|
+
/** The element a press at `target` lands on, or null when it lands on nothing pressable. */
|
|
85
|
+
function pressTarget(target) {
|
|
86
|
+
if (!(target instanceof Element))
|
|
87
|
+
return null;
|
|
88
|
+
if (target.closest(FIELD))
|
|
89
|
+
return null;
|
|
90
|
+
const row = target.closest(PRESSABLE);
|
|
91
|
+
if (!row)
|
|
92
|
+
return null;
|
|
93
|
+
// A button inside the pressable takes the press itself: its material answers data-pressing.
|
|
94
|
+
const button = target.closest(BUTTON);
|
|
95
|
+
const el = button && row.contains(button) && button !== row ? button : row;
|
|
96
|
+
return disabled(el) ? null : el;
|
|
97
|
+
}
|
|
98
|
+
/** Ends the press. `cancel`: it moved or scrolled, so it lets go at once, with no ease. */
|
|
99
|
+
function release(cancel) {
|
|
100
|
+
const p = press;
|
|
101
|
+
if (!p)
|
|
102
|
+
return;
|
|
103
|
+
press = null;
|
|
104
|
+
clearTimeout(p.timer);
|
|
105
|
+
const end = () => {
|
|
106
|
+
p.el.toggleAttribute("data-press-cancel", cancel);
|
|
107
|
+
p.el.removeAttribute("data-pressing");
|
|
108
|
+
// Even a press a scroll took over eases back: a jump of a few pixels as a list starts to move
|
|
109
|
+
// would read as a jolt.
|
|
110
|
+
unshrink(p.el);
|
|
111
|
+
};
|
|
112
|
+
if (cancel)
|
|
113
|
+
return end();
|
|
114
|
+
// A quick tap still shows: the press holds until it has fully sunk (0.6 × --duration-fade).
|
|
115
|
+
const left = cssTime("--duration-fade", p.el) * 0.6 - (performance.now() - p.at);
|
|
116
|
+
if (left > 0)
|
|
117
|
+
p.timer = window.setTimeout(end, left);
|
|
118
|
+
else
|
|
119
|
+
end();
|
|
120
|
+
}
|
|
121
|
+
function onPointerDown(event) {
|
|
122
|
+
if (!event.isPrimary || (event.pointerType === "mouse" && event.button !== 0))
|
|
123
|
+
return;
|
|
124
|
+
if (press) {
|
|
125
|
+
clearTimeout(press.timer);
|
|
126
|
+
press.el.removeAttribute("data-pressing");
|
|
127
|
+
unshrink(press.el);
|
|
128
|
+
press = null;
|
|
129
|
+
}
|
|
130
|
+
const el = pressTarget(event.target);
|
|
131
|
+
if (!el)
|
|
132
|
+
return;
|
|
133
|
+
el.removeAttribute("data-press-cancel");
|
|
134
|
+
el.setAttribute("data-pressing", "");
|
|
135
|
+
shrink(el);
|
|
136
|
+
press = {
|
|
137
|
+
el,
|
|
138
|
+
pointer: event.pointerId,
|
|
139
|
+
x: event.clientX,
|
|
140
|
+
y: event.clientY,
|
|
141
|
+
at: performance.now(),
|
|
142
|
+
timer: 0,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function onPointerMove(event) {
|
|
146
|
+
if (!press || event.pointerId !== press.pointer)
|
|
147
|
+
return;
|
|
148
|
+
if (Math.hypot(event.clientX - press.x, event.clientY - press.y) >= GESTURE_SLOP)
|
|
149
|
+
release(true);
|
|
150
|
+
}
|
|
151
|
+
function onPointerUp(event) {
|
|
152
|
+
if (press && event.pointerId === press.pointer)
|
|
153
|
+
release(event.type === "pointercancel");
|
|
154
|
+
}
|
|
155
|
+
const onScroll = () => release(true);
|
|
156
|
+
function install() {
|
|
157
|
+
if (installs++ > 0 || typeof document === "undefined")
|
|
158
|
+
return;
|
|
159
|
+
document.addEventListener("pointerdown", onPointerDown, { capture: true, passive: true });
|
|
160
|
+
document.addEventListener("pointermove", onPointerMove, { capture: true, passive: true });
|
|
161
|
+
document.addEventListener("pointerup", onPointerUp, { capture: true, passive: true });
|
|
162
|
+
document.addEventListener("pointercancel", onPointerUp, { capture: true, passive: true });
|
|
163
|
+
document.addEventListener("scroll", onScroll, { capture: true, passive: true });
|
|
164
|
+
window.addEventListener("blur", onScroll);
|
|
165
|
+
}
|
|
166
|
+
function uninstall() {
|
|
167
|
+
if (--installs > 0 || typeof document === "undefined")
|
|
168
|
+
return;
|
|
169
|
+
release(true);
|
|
170
|
+
document.removeEventListener("pointerdown", onPointerDown, { capture: true });
|
|
171
|
+
document.removeEventListener("pointermove", onPointerMove, { capture: true });
|
|
172
|
+
document.removeEventListener("pointerup", onPointerUp, { capture: true });
|
|
173
|
+
document.removeEventListener("pointercancel", onPointerUp, { capture: true });
|
|
174
|
+
document.removeEventListener("scroll", onScroll, { capture: true });
|
|
175
|
+
window.removeEventListener("blur", onScroll);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Keeps the press listeners installed while the calling part is mounted. Mark the elements that
|
|
179
|
+
* answer a press with `data-press` (and `press-shade` for a flat surface).
|
|
180
|
+
*/
|
|
181
|
+
export function usePressFeedback() {
|
|
182
|
+
React.useEffect(() => {
|
|
183
|
+
install();
|
|
184
|
+
return uninstall;
|
|
185
|
+
}, []);
|
|
186
|
+
}
|