@passui/react 0.1.47 → 0.2.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/README.md +29 -109
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/accordion.d.ts +15 -0
- package/dist/accordion.js +93 -0
- package/dist/alert-dialog.d.ts +26 -0
- package/dist/alert-dialog.js +142 -0
- package/dist/alert.d.ts +10 -0
- package/dist/alert.js +28 -0
- package/dist/{types/src/components/ambient/ambient.d.ts → ambient.d.ts} +4 -4
- package/dist/ambient.js +22 -0
- package/dist/{types/src/appearance → appearance}/platform.d.ts +3 -3
- package/dist/appearance/platform.js +43 -0
- package/dist/appearance/theme.d.ts +71 -0
- package/dist/appearance/theme.js +236 -0
- package/dist/appearance.d.ts +3 -0
- package/dist/appearance.js +3 -0
- package/dist/{types/src/components/aspect-ratio/aspect-ratio.d.ts → aspect-ratio.d.ts} +4 -4
- package/dist/aspect-ratio.js +17 -0
- package/dist/avatar.d.ts +5 -0
- package/dist/avatar.js +43 -0
- package/dist/badge.d.ts +8 -0
- package/dist/badge.js +21 -0
- package/dist/breadcrumb.d.ts +13 -0
- package/dist/breadcrumb.js +63 -0
- package/dist/button-group.d.ts +5 -0
- package/dist/button-group.js +14 -0
- package/dist/button.d.ts +21 -0
- package/dist/button.js +58 -0
- package/dist/calendar.d.ts +35 -0
- package/dist/calendar.js +225 -0
- package/dist/card.d.ts +9 -0
- package/dist/card.js +54 -0
- package/dist/chart.d.ts +30 -0
- package/dist/chart.js +226 -0
- package/dist/checkbox.d.ts +13 -0
- package/dist/checkbox.js +53 -0
- package/dist/{types/src/lib/clipboard.d.ts → clipboard.d.ts} +1 -1
- package/dist/clipboard.js +16 -0
- package/dist/cn.d.ts +2 -0
- package/dist/cn.js +10 -0
- package/dist/code-block.d.ts +34 -0
- package/dist/code-block.js +87 -0
- package/dist/collapsible.d.ts +13 -0
- package/dist/collapsible.js +49 -0
- package/dist/combobox.d.ts +25 -0
- package/dist/combobox.js +112 -0
- package/dist/command.d.ts +22 -0
- package/dist/command.js +129 -0
- package/dist/components/toast/toast-store.d.ts +60 -0
- package/dist/components/toast/toast-store.js +96 -0
- package/dist/{types/src/components → components}/toast/toaster.d.ts +4 -4
- package/dist/components/toast/toaster.js +345 -0
- package/dist/context-menu.d.ts +2 -0
- package/dist/context-menu.js +2 -0
- package/dist/conversation.d.ts +48 -0
- package/dist/conversation.js +202 -0
- package/dist/date-time-picker.d.ts +50 -0
- package/dist/date-time-picker.js +235 -0
- package/dist/date.d.ts +50 -0
- package/dist/date.js +77 -0
- package/dist/dialog.d.ts +21 -0
- package/dist/dialog.js +113 -0
- package/dist/drawer.d.ts +30 -0
- package/dist/drawer.js +140 -0
- package/dist/dropdown-menu.d.ts +56 -0
- package/dist/dropdown-menu.js +295 -0
- package/dist/empty.d.ts +11 -0
- package/dist/empty.js +51 -0
- package/dist/field.d.ts +16 -0
- package/dist/field.js +47 -0
- package/{src/hooks/scroll/minimize-decision.ts → dist/hooks/scroll/minimize-decision.js} +3 -5
- package/dist/{types/src/hooks → hooks}/use-anchored-placement.d.ts +2 -2
- package/dist/hooks/use-anchored-placement.js +33 -0
- package/dist/{types/src/hooks → hooks}/use-minimize-on-scroll.d.ts +1 -1
- package/dist/hooks/use-minimize-on-scroll.js +59 -0
- package/dist/{types/src/hooks → hooks}/use-visual-viewport.d.ts +2 -2
- package/{src/hooks/use-visual-viewport.ts → dist/hooks/use-visual-viewport.js} +20 -35
- package/dist/hooks/viewport/types.d.ts +7 -0
- package/dist/hooks/viewport/viewport-metrics.js +13 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +80 -0
- package/dist/input-group.d.ts +17 -0
- package/dist/input-group.js +55 -0
- package/dist/input-otp.d.ts +13 -0
- package/dist/input-otp.js +36 -0
- package/dist/input.d.ts +4 -0
- package/dist/input.js +14 -0
- package/dist/item.d.ts +49 -0
- package/dist/item.js +142 -0
- package/dist/kbd.d.ts +4 -0
- package/dist/kbd.js +86 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +12 -0
- package/dist/labeled-content.d.ts +24 -0
- package/dist/labeled-content.js +41 -0
- package/dist/{types/src/lib/language.d.ts → language.d.ts} +1 -1
- package/dist/language.js +11 -0
- package/dist/layout.d.ts +24 -0
- package/dist/layout.js +36 -0
- package/dist/{types/src/lib → lib}/anchored-placement.d.ts +27 -27
- package/dist/lib/anchored-placement.js +42 -0
- package/dist/lib/calendar-month.js +90 -0
- package/dist/lib/cx.js +6 -0
- package/dist/lib/drawer.math.js +29 -0
- package/dist/lib/floating-layers.d.ts +3 -0
- package/dist/lib/floating-layers.js +25 -0
- package/dist/{types/src/lib → lib}/haptics.d.ts +1 -1
- package/dist/lib/haptics.js +13 -0
- package/dist/lib/liquid-step.js +33 -0
- package/dist/lib/page-scale.js +58 -0
- package/dist/lib/portal.js +12 -0
- package/dist/lib/presence.js +53 -0
- package/dist/lib/range-value.js +25 -0
- package/dist/lib/render.d.ts +8 -0
- package/dist/lib/render.js +42 -0
- package/dist/lib/rolling-digit.js +83 -0
- package/dist/{types/src/lib → lib}/screen-edges.d.ts +5 -5
- package/dist/lib/screen-edges.js +30 -0
- package/dist/lib/swipe-touch-action.js +34 -0
- package/dist/lib/visual-viewport.js +27 -0
- package/dist/lib/water-drop.js +412 -0
- package/dist/lib/wheel.js +125 -0
- package/dist/list.d.ts +26 -0
- package/dist/list.js +80 -0
- package/dist/locales.d.ts +18 -0
- package/dist/locales.js +36 -0
- package/dist/marker.d.ts +13 -0
- package/dist/marker.js +33 -0
- package/dist/motion/transitions.d.ts +170 -0
- package/dist/motion/transitions.js +156 -0
- package/dist/pagination.d.ts +30 -0
- package/dist/pagination.js +117 -0
- package/dist/popover.d.ts +26 -0
- package/dist/popover.js +101 -0
- package/dist/progress.d.ts +9 -0
- package/dist/progress.js +24 -0
- package/dist/questionnaire.d.ts +46 -0
- package/dist/questionnaire.js +133 -0
- package/dist/radio-group.d.ts +21 -0
- package/dist/radio-group.js +67 -0
- package/dist/search-field.d.ts +18 -0
- package/dist/search-field.js +45 -0
- package/dist/segmented-control.d.ts +16 -0
- package/dist/segmented-control.js +25 -0
- package/dist/select.d.ts +24 -0
- package/dist/select.js +107 -0
- package/dist/separator.d.ts +9 -0
- package/dist/separator.js +17 -0
- package/dist/{types/src/lib/shapes.d.ts → shapes.d.ts} +2 -2
- package/dist/shapes.js +65 -0
- package/dist/sheet.d.ts +24 -0
- package/dist/sheet.js +141 -0
- package/dist/sidebar.d.ts +32 -0
- package/dist/sidebar.js +85 -0
- package/dist/skeleton.d.ts +3 -0
- package/dist/skeleton.js +13 -0
- package/dist/slider.d.ts +9 -0
- package/dist/slider.js +42 -0
- package/dist/slosh-slider.d.ts +21 -0
- package/dist/slosh-slider.js +205 -0
- package/dist/spinner.d.ts +3 -0
- package/dist/spinner.js +20 -0
- package/dist/stat-tile.d.ts +20 -0
- package/dist/stat-tile.js +53 -0
- package/dist/stepper.d.ts +22 -0
- package/dist/stepper.js +98 -0
- package/dist/swatch-picker.d.ts +22 -0
- package/dist/swatch-picker.js +70 -0
- package/dist/switch.d.ts +10 -0
- package/dist/switch.js +44 -0
- package/dist/tab-bar.d.ts +15 -0
- package/dist/tab-bar.js +34 -0
- package/dist/{types/src/components/table/table.d.ts → table.d.ts} +3 -3
- package/dist/table.js +93 -0
- package/dist/tabs.d.ts +32 -0
- package/dist/tabs.js +131 -0
- package/dist/text.d.ts +25 -0
- package/dist/text.js +44 -0
- package/dist/textarea.d.ts +3 -0
- package/dist/textarea.js +13 -0
- package/dist/toast.d.ts +3 -0
- package/dist/toast.js +3 -0
- package/dist/toggle-group.d.ts +20 -0
- package/dist/toggle-group.js +68 -0
- package/dist/toggle.d.ts +24 -0
- package/dist/toggle.js +37 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tooltip.d.ts +21 -0
- package/dist/tooltip.js +61 -0
- package/dist/trace.d.ts +14 -0
- package/dist/trace.js +54 -0
- package/dist/{types/src/hooks/use-dismiss.d.ts → use-dismiss.d.ts} +3 -3
- package/dist/use-dismiss.js +38 -0
- package/dist/{types/src/hooks/use-media-query.d.ts → use-media-query.d.ts} +12 -12
- package/dist/use-media-query.js +56 -0
- package/dist/use-os.d.ts +12 -0
- package/dist/use-os.js +17 -0
- package/dist/wake-slider.d.ts +15 -0
- package/dist/wake-slider.js +174 -0
- package/package.json +122 -253
- package/src/styles/code-block.css +4 -0
- package/src/styles/globals.css +5 -0
- package/src/styles/motion-controls.css +10 -0
- package/src/styles/page-scale.css +27 -0
- package/src/styles/styles.css +4 -2
- package/dist/types/src/appearance/index.d.ts +0 -2
- package/dist/types/src/appearance/theme.d.ts +0 -71
- package/dist/types/src/components/accordion/accordion.d.ts +0 -23
- package/dist/types/src/components/ambient/index.d.ts +0 -1
- package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +0 -19
- package/dist/types/src/components/button/button-styles.d.ts +0 -12
- package/dist/types/src/components/button/button.d.ts +0 -32
- package/dist/types/src/components/button/icon-button.d.ts +0 -10
- package/dist/types/src/components/button/pending-spinner.d.ts +0 -5
- package/dist/types/src/components/button/use-pending-indicator.d.ts +0 -2
- package/dist/types/src/components/chip/chip.d.ts +0 -10
- package/dist/types/src/components/code-block/code-block.d.ts +0 -13
- package/dist/types/src/components/combo-box/combo-box.d.ts +0 -9
- package/dist/types/src/components/command/command.d.ts +0 -18
- package/dist/types/src/components/compact-date-picker/calendar-month.d.ts +0 -25
- package/dist/types/src/components/compact-date-picker/compact-date-picker.d.ts +0 -30
- package/dist/types/src/components/compact-time-picker/compact-time-picker.d.ts +0 -29
- package/dist/types/src/components/compact-time-picker/time-value.d.ts +0 -18
- package/dist/types/src/components/content-unavailable-view/content-unavailable-view.d.ts +0 -12
- package/dist/types/src/components/content-view/content-view.d.ts +0 -51
- package/dist/types/src/components/content-view/index.d.ts +0 -1
- package/dist/types/src/components/context-menu/conceal-menu-source.d.ts +0 -2
- package/dist/types/src/components/context-menu/context-menu-host.d.ts +0 -2
- package/dist/types/src/components/context-menu/context-menu-store.d.ts +0 -62
- package/dist/types/src/components/context-menu/menu-navigation.d.ts +0 -6
- package/dist/types/src/components/context-menu/menu-position.d.ts +0 -21
- package/dist/types/src/components/context-menu/menu-reveal.d.ts +0 -26
- package/dist/types/src/components/context-menu/use-context-menu.d.ts +0 -14
- package/dist/types/src/components/conversation/conversation.d.ts +0 -48
- package/dist/types/src/components/conversation/index.d.ts +0 -1
- package/dist/types/src/components/date-picker/date-picker.d.ts +0 -19
- package/dist/types/src/components/date-picker/date-value.d.ts +0 -2
- package/dist/types/src/components/dialog/dialog-host.d.ts +0 -6
- package/dist/types/src/components/dialog/dialog-store.d.ts +0 -23
- package/dist/types/src/components/dialog/dialog.d.ts +0 -33
- package/dist/types/src/components/dialog/index.d.ts +0 -1
- package/dist/types/src/components/disclosure-group/disclosure-group.d.ts +0 -18
- package/dist/types/src/components/divider/divider.d.ts +0 -9
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +0 -15
- package/dist/types/src/components/keyboard-shortcut/keyboard-shortcut.d.ts +0 -8
- package/dist/types/src/components/labeled-content/labeled-content.d.ts +0 -22
- package/dist/types/src/components/locale-switcher/index.d.ts +0 -1
- package/dist/types/src/components/locale-switcher/locale-switcher.d.ts +0 -13
- package/dist/types/src/components/menu/menu.d.ts +0 -16
- package/dist/types/src/components/morph/index.d.ts +0 -2
- package/dist/types/src/components/morph/morph.d.ts +0 -32
- package/dist/types/src/components/morph/use-morph-disclosure.d.ts +0 -13
- package/dist/types/src/components/one-time-code/one-time-code.d.ts +0 -26
- package/dist/types/src/components/picker/picker-trigger.d.ts +0 -3
- package/dist/types/src/components/picker/picker.d.ts +0 -46
- package/dist/types/src/components/popover/anchored-surface.d.ts +0 -17
- package/dist/types/src/components/popover/index.d.ts +0 -41
- package/dist/types/src/components/popover/popover-content.d.ts +0 -38
- package/dist/types/src/components/popover/popover-root.d.ts +0 -22
- package/dist/types/src/components/popover/popover-trigger.d.ts +0 -23
- package/dist/types/src/components/profile-image/profile-image.d.ts +0 -9
- package/dist/types/src/components/progress-view/progress-view.d.ts +0 -13
- package/dist/types/src/components/progress-view/use-liquid-progress.d.ts +0 -3
- package/dist/types/src/components/radio-group/radio-group.d.ts +0 -20
- package/dist/types/src/components/search-field/expanding-search-field.d.ts +0 -5
- package/dist/types/src/components/search-field/search-field.d.ts +0 -9
- package/dist/types/src/components/search-list/search-list.d.ts +0 -22
- package/dist/types/src/components/section/section.d.ts +0 -18
- package/dist/types/src/components/secure-field/secure-field.d.ts +0 -4
- package/dist/types/src/components/segmented-control/segmented-control.d.ts +0 -25
- package/dist/types/src/components/sheet/modal-environment.d.ts +0 -2
- package/dist/types/src/components/sheet/sheet-portal.d.ts +0 -5
- package/dist/types/src/components/sheet/sheet.d.ts +0 -26
- package/dist/types/src/components/sheet/use-sheet-focus.d.ts +0 -3
- package/dist/types/src/components/sidebar/sidebar.d.ts +0 -24
- package/dist/types/src/components/skeleton/skeleton.d.ts +0 -9
- package/dist/types/src/components/slider/slider.d.ts +0 -17
- package/dist/types/src/components/slosh-slider/liquid-step.d.ts +0 -6
- package/dist/types/src/components/slosh-slider/slosh-slider.d.ts +0 -21
- package/dist/types/src/components/stat-tile/index.d.ts +0 -1
- package/dist/types/src/components/stat-tile/stat-tile.d.ts +0 -20
- package/dist/types/src/components/status-indicator/status-indicator.d.ts +0 -17
- package/dist/types/src/components/stepper/rolling-digit.d.ts +0 -11
- package/dist/types/src/components/stepper/stepper.d.ts +0 -22
- package/dist/types/src/components/swatch-picker/swatch-picker.d.ts +0 -22
- package/dist/types/src/components/tab-bar/tab-bar.d.ts +0 -43
- package/dist/types/src/components/tab-view/tab-view.d.ts +0 -27
- package/dist/types/src/components/text-editor/text-editor.d.ts +0 -9
- package/dist/types/src/components/text-field/text-field.d.ts +0 -33
- package/dist/types/src/components/toast/toast-store.d.ts +0 -52
- package/dist/types/src/components/toggle/toggle.d.ts +0 -22
- package/dist/types/src/components/tooltip/tooltip-host.d.ts +0 -7
- package/dist/types/src/components/view-controller/index.d.ts +0 -1
- package/dist/types/src/components/view-controller/view-controller.d.ts +0 -21
- package/dist/types/src/components/wake-slider/wake-slider.d.ts +0 -15
- package/dist/types/src/hooks/scroll/minimize-decision.d.ts +0 -2
- package/dist/types/src/hooks/use-anchored-disclosure.d.ts +0 -9
- package/dist/types/src/hooks/use-floating-dismiss.d.ts +0 -3
- package/dist/types/src/hooks/viewport/types.d.ts +0 -19
- package/dist/types/src/hooks/viewport/viewport-metrics.d.ts +0 -3
- package/dist/types/src/icons/icons.d.ts +0 -616
- package/dist/types/src/index.d.ts +0 -73
- package/dist/types/src/lib/class-names.d.ts +0 -2
- package/dist/types/src/lib/date.d.ts +0 -50
- package/dist/types/src/lib/floating-layers.d.ts +0 -8
- package/dist/types/src/lib/range-value.d.ts +0 -4
- package/dist/types/src/machines/popover.machine.d.ts +0 -30
- package/dist/types/src/motion/transitions.d.ts +0 -170
- package/src/appearance/index.ts +0 -2
- package/src/appearance/platform.tsx +0 -102
- package/src/appearance/theme.tsx +0 -467
- package/src/components/accordion/accordion.tsx +0 -70
- package/src/components/ambient/ambient.tsx +0 -35
- package/src/components/ambient/index.ts +0 -1
- package/src/components/aspect-ratio/aspect-ratio.tsx +0 -27
- package/src/components/breadcrumb/breadcrumb.tsx +0 -73
- package/src/components/button/button-styles.ts +0 -49
- package/src/components/button/button.tsx +0 -107
- package/src/components/button/icon-button.tsx +0 -33
- package/src/components/button/pending-spinner.tsx +0 -14
- package/src/components/button/use-pending-indicator.ts +0 -22
- package/src/components/chip/chip.tsx +0 -45
- package/src/components/code-block/code-block.tsx +0 -48
- package/src/components/combo-box/combo-box.tsx +0 -13
- package/src/components/command/command.tsx +0 -149
- package/src/components/compact-date-picker/calendar-month.ts +0 -109
- package/src/components/compact-date-picker/compact-date-picker.tsx +0 -337
- package/src/components/compact-time-picker/compact-time-picker.tsx +0 -321
- package/src/components/compact-time-picker/time-value.ts +0 -58
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +0 -78
- package/src/components/content-view/content-view.tsx +0 -215
- package/src/components/content-view/index.ts +0 -1
- package/src/components/context-menu/conceal-menu-source.ts +0 -30
- package/src/components/context-menu/context-menu-host.tsx +0 -459
- package/src/components/context-menu/context-menu-store.ts +0 -167
- package/src/components/context-menu/menu-navigation.ts +0 -36
- package/src/components/context-menu/menu-position.ts +0 -38
- package/src/components/context-menu/menu-reveal.ts +0 -42
- package/src/components/context-menu/use-context-menu.ts +0 -73
- package/src/components/conversation/conversation.tsx +0 -309
- package/src/components/conversation/index.ts +0 -1
- package/src/components/date-picker/date-picker.tsx +0 -106
- package/src/components/date-picker/date-value.ts +0 -22
- package/src/components/dialog/dialog-host.tsx +0 -119
- package/src/components/dialog/dialog-store.ts +0 -66
- package/src/components/dialog/dialog.tsx +0 -211
- package/src/components/dialog/index.ts +0 -1
- package/src/components/disclosure-group/disclosure-group.tsx +0 -108
- package/src/components/divider/divider.tsx +0 -33
- package/src/components/inline-disclosure/inline-disclosure.tsx +0 -53
- package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +0 -32
- package/src/components/labeled-content/labeled-content.tsx +0 -84
- package/src/components/locale-switcher/index.ts +0 -1
- package/src/components/locale-switcher/locale-switcher.tsx +0 -310
- package/src/components/menu/menu.tsx +0 -85
- package/src/components/morph/index.ts +0 -2
- package/src/components/morph/morph.tsx +0 -258
- package/src/components/morph/use-morph-disclosure.ts +0 -27
- package/src/components/one-time-code/one-time-code.tsx +0 -234
- package/src/components/picker/picker-trigger.ts +0 -22
- package/src/components/picker/picker.tsx +0 -404
- package/src/components/popover/anchored-surface.tsx +0 -264
- package/src/components/popover/index.ts +0 -50
- package/src/components/popover/popover-content.tsx +0 -374
- package/src/components/popover/popover-root.tsx +0 -97
- package/src/components/popover/popover-trigger.tsx +0 -71
- package/src/components/profile-image/profile-image.tsx +0 -96
- package/src/components/progress-view/progress-view.tsx +0 -72
- package/src/components/progress-view/use-liquid-progress.ts +0 -43
- package/src/components/radio-group/radio-group.tsx +0 -86
- package/src/components/search-field/expanding-search-field.tsx +0 -197
- package/src/components/search-field/search-field.tsx +0 -66
- package/src/components/search-list/search-list.tsx +0 -276
- package/src/components/section/section.tsx +0 -75
- package/src/components/secure-field/secure-field.tsx +0 -8
- package/src/components/segmented-control/segmented-control.tsx +0 -157
- package/src/components/sheet/modal-environment.ts +0 -82
- package/src/components/sheet/sheet-portal.tsx +0 -62
- package/src/components/sheet/sheet.tsx +0 -165
- package/src/components/sheet/use-sheet-focus.ts +0 -109
- package/src/components/sidebar/sidebar.tsx +0 -102
- package/src/components/skeleton/skeleton.tsx +0 -38
- package/src/components/slider/slider.tsx +0 -134
- package/src/components/slosh-slider/liquid-step.ts +0 -43
- package/src/components/slosh-slider/slosh-slider.tsx +0 -294
- package/src/components/stat-tile/index.ts +0 -1
- package/src/components/stat-tile/stat-tile.tsx +0 -90
- package/src/components/status-indicator/status-indicator.tsx +0 -54
- package/src/components/stepper/rolling-digit.tsx +0 -91
- package/src/components/stepper/stepper.tsx +0 -136
- package/src/components/swatch-picker/swatch-picker.tsx +0 -138
- package/src/components/tab-bar/tab-bar.tsx +0 -182
- package/src/components/tab-view/tab-view.tsx +0 -155
- package/src/components/table/table.tsx +0 -151
- package/src/components/text-editor/text-editor.tsx +0 -42
- package/src/components/text-field/text-field.tsx +0 -200
- package/src/components/toast/toast-store.ts +0 -164
- package/src/components/toast/toaster.tsx +0 -407
- package/src/components/toggle/toggle.tsx +0 -320
- package/src/components/tooltip/tooltip-host.tsx +0 -178
- package/src/components/view-controller/index.ts +0 -1
- package/src/components/view-controller/view-controller.tsx +0 -75
- package/src/components/wake-slider/wake-slider.tsx +0 -260
- package/src/hooks/use-anchored-disclosure.ts +0 -23
- package/src/hooks/use-anchored-placement.ts +0 -40
- package/src/hooks/use-dismiss.ts +0 -44
- package/src/hooks/use-floating-dismiss.ts +0 -30
- package/src/hooks/use-media-query.ts +0 -94
- package/src/hooks/use-minimize-on-scroll.ts +0 -77
- package/src/hooks/viewport/types.ts +0 -19
- package/src/hooks/viewport/viewport-metrics.ts +0 -19
- package/src/icons/icons.tsx +0 -458
- package/src/index.ts +0 -107
- package/src/lib/anchored-placement.ts +0 -91
- package/src/lib/class-names.ts +0 -21
- package/src/lib/clipboard.ts +0 -15
- package/src/lib/date.ts +0 -86
- package/src/lib/floating-layers.ts +0 -53
- package/src/lib/haptics.ts +0 -23
- package/src/lib/language.ts +0 -16
- package/src/lib/range-value.ts +0 -38
- package/src/lib/screen-edges.ts +0 -44
- package/src/lib/shapes.ts +0 -59
- package/src/machines/popover.machine.ts +0 -51
- package/src/motion/transitions.ts +0 -97
- package/src/tokens.ts +0 -1
- /package/dist/{types/src/tokens.d.ts → tokens.js} +0 -0
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import { clampRange as clamp } from "../../lib/range-value";
|
|
2
|
-
// Adapted from Bencho. See THIRD_PARTY_NOTICES.md for the MIT notice.
|
|
3
|
-
import { type CSSProperties, useEffect, useRef, useState } from "react";
|
|
4
|
-
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
5
|
-
import { cn } from "../../lib/class-names";
|
|
6
|
-
|
|
7
|
-
/* ══ Wake slider ══════════════════════════════════════════
|
|
8
|
-
A range with no thumb: a row of thin bars, solid up to the
|
|
9
|
-
value and faint after it, with the reading beside them. Drag
|
|
10
|
-
anywhere along it. Drag slowly and the bars simply fill; drag
|
|
11
|
-
fast and every bar the value sweeps past springs up, taller the
|
|
12
|
-
faster you went, and settles back — a wake left behind the hand.
|
|
13
|
-
|
|
14
|
-
── EACH BAR HOLDS A LITTLE ENERGY ──────────────────────
|
|
15
|
-
When the value crosses a bar, that bar takes energy from the
|
|
16
|
-
speed of the drag. Every frame all of it decays at the same
|
|
17
|
-
rate, so the bars crossed longest ago have fallen furthest: the
|
|
18
|
-
tallest ones are always at the hand and the run tails off
|
|
19
|
-
behind it. That falloff IS the wake; nothing draws it.
|
|
20
|
-
|
|
21
|
-
── WRITTEN, NOT RENDERED ───────────────────────────────
|
|
22
|
-
The heights change every frame, so they go straight onto each
|
|
23
|
-
bar's transform from a ref. React renders when the value
|
|
24
|
-
changes, which is what the reading and the colours need, and
|
|
25
|
-
the loop runs only while some bar still has energy. */
|
|
26
|
-
|
|
27
|
-
const H: Record<WakeSliderSize, number> = { sm: 16, md: 20, lg: 26 }; // a bar at rest, px
|
|
28
|
-
|
|
29
|
-
export type WakeSliderSize = "sm" | "md" | "lg";
|
|
30
|
-
|
|
31
|
-
export interface WakeSliderProps {
|
|
32
|
-
label: string;
|
|
33
|
-
value?: number;
|
|
34
|
-
defaultValue?: number;
|
|
35
|
-
onChange?: (value: number) => void;
|
|
36
|
-
bars?: number;
|
|
37
|
-
wake?: number;
|
|
38
|
-
disabled?: boolean;
|
|
39
|
-
className?: string;
|
|
40
|
-
formatValue?: (value: number) => string;
|
|
41
|
-
/** Bar height at rest and value text scale. @default "md" */
|
|
42
|
-
size?: WakeSliderSize;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function WakeSlider({
|
|
46
|
-
label,
|
|
47
|
-
value: controlledValue,
|
|
48
|
-
defaultValue = 50,
|
|
49
|
-
onChange,
|
|
50
|
-
disabled = false,
|
|
51
|
-
className,
|
|
52
|
-
formatValue,
|
|
53
|
-
size = "md",
|
|
54
|
-
/* how many bars make the track */
|
|
55
|
-
bars = 36,
|
|
56
|
-
/* how high the wake rises, 0..100 */
|
|
57
|
-
wake = 60,
|
|
58
|
-
}: WakeSliderProps) {
|
|
59
|
-
const n = Math.round(clamp(Number.isFinite(bars) ? bars : 36, 12, 64));
|
|
60
|
-
const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
61
|
-
const [value, setValue] = useState(() =>
|
|
62
|
-
clamp(controlledValue ?? defaultValue, 0, 100),
|
|
63
|
-
);
|
|
64
|
-
const track = useRef<HTMLDivElement | null>(null);
|
|
65
|
-
const els = useRef<(HTMLSpanElement | null)[]>([]);
|
|
66
|
-
const st = useRef({
|
|
67
|
-
energy: new Float32Array(n),
|
|
68
|
-
down: false,
|
|
69
|
-
lastX: 0,
|
|
70
|
-
lastT: 0,
|
|
71
|
-
speed: 0,
|
|
72
|
-
raf: 0,
|
|
73
|
-
at: value / 100, // the value as a fraction, without React in the way
|
|
74
|
-
lastBar: -1,
|
|
75
|
-
});
|
|
76
|
-
const knob = useRef(wake);
|
|
77
|
-
knob.current = reduced ? 0 : clamp(wake, 0, 100);
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (controlledValue === undefined) return;
|
|
80
|
-
const next = clamp(controlledValue, 0, 100);
|
|
81
|
-
st.current.at = next / 100;
|
|
82
|
-
setValue(next);
|
|
83
|
-
}, [controlledValue]);
|
|
84
|
-
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
if (!reduced) return;
|
|
87
|
-
cancelAnimationFrame(st.current.raf);
|
|
88
|
-
st.current.raf = 0;
|
|
89
|
-
st.current.energy.fill(0);
|
|
90
|
-
for (const bar of els.current) if (bar) bar.style.transform = "none";
|
|
91
|
-
}, [reduced]);
|
|
92
|
-
|
|
93
|
-
/* a new bar count is a new row */
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
st.current.energy = new Float32Array(n);
|
|
96
|
-
}, [n]);
|
|
97
|
-
|
|
98
|
-
const loop = () => {
|
|
99
|
-
const s = st.current;
|
|
100
|
-
if (s.raf) return;
|
|
101
|
-
let prev = performance.now();
|
|
102
|
-
const run = (now: number) => {
|
|
103
|
-
const dt = Math.min(0.05, (now - prev) / 1000);
|
|
104
|
-
prev = now;
|
|
105
|
-
let live = false;
|
|
106
|
-
const fall = Math.exp(-dt * 6.5);
|
|
107
|
-
for (let i = 0; i < s.energy.length; i++) {
|
|
108
|
-
s.energy[i] *= fall;
|
|
109
|
-
if (s.energy[i] < 0.002) s.energy[i] = 0;
|
|
110
|
-
else live = true;
|
|
111
|
-
const b = els.current[i];
|
|
112
|
-
/* up to 2.6 times as tall at the very top of the knob */
|
|
113
|
-
if (b)
|
|
114
|
-
b.style.transform = `scaleY(${(1 + s.energy[i] * 1.6).toFixed(3)})`;
|
|
115
|
-
}
|
|
116
|
-
s.raf = live ? requestAnimationFrame(run) : 0;
|
|
117
|
-
};
|
|
118
|
-
s.raf = requestAnimationFrame(run);
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
useEffect(() => () => cancelAnimationFrame(st.current.raf), []);
|
|
122
|
-
|
|
123
|
-
/* move the value to a fraction, waking every bar it passes */
|
|
124
|
-
const to = (f: number, speed: number) => {
|
|
125
|
-
const s = st.current;
|
|
126
|
-
f = clamp(f, 0, 1);
|
|
127
|
-
const from = s.at;
|
|
128
|
-
s.at = f;
|
|
129
|
-
const a = Math.round(from * (n - 1));
|
|
130
|
-
const b = Math.round(f * (n - 1));
|
|
131
|
-
/* how hard: the drag's speed in bars per second, through a
|
|
132
|
-
curve that saturates, scaled by the knob */
|
|
133
|
-
const push = (1 - Math.exp(-speed / 900)) * (knob.current / 60);
|
|
134
|
-
const lo = Math.min(a, b);
|
|
135
|
-
const hi = Math.max(a, b);
|
|
136
|
-
for (let i = lo; i <= hi; i++) s.energy[i] = Math.max(s.energy[i], push);
|
|
137
|
-
if (b !== s.lastBar) {
|
|
138
|
-
s.lastBar = b;
|
|
139
|
-
}
|
|
140
|
-
const next = Math.round(f * 100);
|
|
141
|
-
setValue(next);
|
|
142
|
-
onChange?.(next);
|
|
143
|
-
if (!reduced && knob.current > 0) loop();
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const frac = (clientX: number) => {
|
|
147
|
-
const r = (track.current ?? document.body).getBoundingClientRect();
|
|
148
|
-
const fraction = r.width ? (clientX - r.left) / r.width : 0;
|
|
149
|
-
return getComputedStyle(track.current ?? document.body).direction === "rtl"
|
|
150
|
-
? 1 - fraction
|
|
151
|
-
: fraction;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const lit = Math.round((value / 100) * (n - 1));
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div
|
|
158
|
-
className={cn(
|
|
159
|
-
"passui-wake-slider not-typeset",
|
|
160
|
-
disabled && "opacity-40",
|
|
161
|
-
className,
|
|
162
|
-
)}
|
|
163
|
-
data-size={size}
|
|
164
|
-
>
|
|
165
|
-
<div
|
|
166
|
-
ref={track}
|
|
167
|
-
className="passui-wake-track"
|
|
168
|
-
role="slider"
|
|
169
|
-
tabIndex={disabled ? -1 : 0}
|
|
170
|
-
aria-label={label}
|
|
171
|
-
aria-disabled={disabled || undefined}
|
|
172
|
-
aria-valuetext={formatValue?.(value)}
|
|
173
|
-
aria-valuemin={0}
|
|
174
|
-
aria-valuemax={100}
|
|
175
|
-
aria-valuenow={value}
|
|
176
|
-
style={{ height: H[size] * 2.6, "--wake-bars": n } as CSSProperties}
|
|
177
|
-
onPointerDown={(e) => {
|
|
178
|
-
if (disabled || e.button !== 0) return;
|
|
179
|
-
e.currentTarget.focus();
|
|
180
|
-
const s = st.current;
|
|
181
|
-
try {
|
|
182
|
-
e.currentTarget.setPointerCapture(e.pointerId);
|
|
183
|
-
} catch {
|
|
184
|
-
/* a scripted pointer */
|
|
185
|
-
}
|
|
186
|
-
s.down = true;
|
|
187
|
-
s.lastX = e.clientX;
|
|
188
|
-
s.lastT = performance.now();
|
|
189
|
-
s.speed = 0;
|
|
190
|
-
to(frac(e.clientX), 0);
|
|
191
|
-
}}
|
|
192
|
-
onPointerMove={(e) => {
|
|
193
|
-
const s = st.current;
|
|
194
|
-
if (!s.down || disabled) return;
|
|
195
|
-
const now = performance.now();
|
|
196
|
-
const dt = Math.max(0.008, (now - s.lastT) / 1000);
|
|
197
|
-
/* speed in px per second, smoothed so one jittery frame
|
|
198
|
-
cannot fake a fling */
|
|
199
|
-
const v = Math.abs(e.clientX - s.lastX) / dt;
|
|
200
|
-
s.speed = s.speed * 0.5 + v * 0.5;
|
|
201
|
-
s.lastX = e.clientX;
|
|
202
|
-
s.lastT = now;
|
|
203
|
-
to(frac(e.clientX), s.speed);
|
|
204
|
-
}}
|
|
205
|
-
onPointerUp={(e) => {
|
|
206
|
-
st.current.down = false;
|
|
207
|
-
try {
|
|
208
|
-
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
209
|
-
} catch {
|
|
210
|
-
/* never captured */
|
|
211
|
-
}
|
|
212
|
-
}}
|
|
213
|
-
onLostPointerCapture={() => {
|
|
214
|
-
st.current.down = false;
|
|
215
|
-
}}
|
|
216
|
-
onPointerCancel={() => {
|
|
217
|
-
st.current.down = false;
|
|
218
|
-
}}
|
|
219
|
-
onKeyDown={(e) => {
|
|
220
|
-
if (disabled) return;
|
|
221
|
-
const step = e.shiftKey ? 10 : 1;
|
|
222
|
-
let next: number | null = null;
|
|
223
|
-
const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
|
|
224
|
-
if (
|
|
225
|
-
e.key === "ArrowUp" ||
|
|
226
|
-
e.key === (rtl ? "ArrowLeft" : "ArrowRight")
|
|
227
|
-
)
|
|
228
|
-
next = value + step;
|
|
229
|
-
if (
|
|
230
|
-
e.key === "ArrowDown" ||
|
|
231
|
-
e.key === (rtl ? "ArrowRight" : "ArrowLeft")
|
|
232
|
-
)
|
|
233
|
-
next = value - step;
|
|
234
|
-
if (e.key === "Home") next = 0;
|
|
235
|
-
if (e.key === "End") next = 100;
|
|
236
|
-
if (next === null) return;
|
|
237
|
-
e.preventDefault();
|
|
238
|
-
/* a key press is a small, quick step: a little wake */
|
|
239
|
-
to(clamp(next, 0, 100) / 100, 600);
|
|
240
|
-
}}
|
|
241
|
-
>
|
|
242
|
-
{Array.from({ length: n }, (_, i) => (
|
|
243
|
-
<span
|
|
244
|
-
key={i}
|
|
245
|
-
ref={(b) => {
|
|
246
|
-
els.current[i] = b;
|
|
247
|
-
}}
|
|
248
|
-
aria-hidden="true"
|
|
249
|
-
className="passui-wake-bar"
|
|
250
|
-
data-on={(value > 0 && i <= lit) || undefined}
|
|
251
|
-
style={{ height: H[size] }}
|
|
252
|
-
/>
|
|
253
|
-
))}
|
|
254
|
-
</div>
|
|
255
|
-
<span aria-hidden="true" className="passui-wake-value">
|
|
256
|
-
{formatValue?.(value) ?? value}
|
|
257
|
-
</span>
|
|
258
|
-
</div>
|
|
259
|
-
);
|
|
260
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
/** Keep the panel mounted until its material has returned to the trigger. */
|
|
4
|
-
export function useAnchoredDisclosure(disabled = false) {
|
|
5
|
-
const [open, setOpen] = useState(false);
|
|
6
|
-
const [mounted, setMounted] = useState(false);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
if (disabled) setOpen(false);
|
|
9
|
-
}, [disabled]);
|
|
10
|
-
const show = useCallback(() => {
|
|
11
|
-
setMounted(true);
|
|
12
|
-
setOpen(true);
|
|
13
|
-
}, []);
|
|
14
|
-
const toggle = useCallback(() => {
|
|
15
|
-
setMounted(true);
|
|
16
|
-
setOpen((current) => !current);
|
|
17
|
-
}, []);
|
|
18
|
-
const close = useCallback(() => setOpen(false), []);
|
|
19
|
-
const onExited = useCallback(() => {
|
|
20
|
-
if (!open || disabled) setMounted(false);
|
|
21
|
-
}, [open, disabled]);
|
|
22
|
-
return { open: open && !disabled, mounted, show, toggle, close, onExited };
|
|
23
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
type AnchoredPlacement,
|
|
4
|
-
placeAnchored,
|
|
5
|
-
} from "../lib/anchored-placement";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Places a panel of `width` and `needed` height under its anchor and
|
|
9
|
-
* keeps it there: re-places while the viewport resizes or anything
|
|
10
|
-
* scrolls, so it never hangs off the screen.
|
|
11
|
-
*/
|
|
12
|
-
export function useAnchoredPlacement(
|
|
13
|
-
anchor: HTMLElement,
|
|
14
|
-
width: number,
|
|
15
|
-
needed: number,
|
|
16
|
-
overlap = false,
|
|
17
|
-
): AnchoredPlacement {
|
|
18
|
-
const [placement, setPlacement] = useState(() =>
|
|
19
|
-
placeAnchored(anchor, width, needed, 6, overlap),
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
useLayoutEffect(() => {
|
|
23
|
-
const replace = () =>
|
|
24
|
-
setPlacement(placeAnchored(anchor, width, needed, 6, overlap));
|
|
25
|
-
replace();
|
|
26
|
-
const viewport = window.visualViewport;
|
|
27
|
-
viewport?.addEventListener("resize", replace);
|
|
28
|
-
viewport?.addEventListener("scroll", replace);
|
|
29
|
-
window.addEventListener("resize", replace);
|
|
30
|
-
window.addEventListener("scroll", replace, true);
|
|
31
|
-
return () => {
|
|
32
|
-
viewport?.removeEventListener("resize", replace);
|
|
33
|
-
viewport?.removeEventListener("scroll", replace);
|
|
34
|
-
window.removeEventListener("resize", replace);
|
|
35
|
-
window.removeEventListener("scroll", replace, true);
|
|
36
|
-
};
|
|
37
|
-
}, [anchor, width, needed, overlap]);
|
|
38
|
-
|
|
39
|
-
return placement;
|
|
40
|
-
}
|
package/src/hooks/use-dismiss.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { type RefObject, useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
belongsToFloatingSurface,
|
|
4
|
-
ownsFloatingLayer,
|
|
5
|
-
} from "../lib/floating-layers";
|
|
6
|
-
|
|
7
|
-
/** Marks a floating layer (a pop-up list, a menu) whose clicks belong to what opened it. */
|
|
8
|
-
export { FLOATING_LAYER } from "../lib/floating-layers";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Calls `onDismiss` when the user presses Escape or clicks outside `ref`
|
|
12
|
-
* while `active`, for menus, popovers and sheets. Clicks in a floating
|
|
13
|
-
* layer opened from inside, such as a pop-up button's list, don't count.
|
|
14
|
-
*/
|
|
15
|
-
export function useDismiss(
|
|
16
|
-
ref: RefObject<HTMLElement | null>,
|
|
17
|
-
active: boolean,
|
|
18
|
-
onDismiss: () => void,
|
|
19
|
-
): void {
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
if (!active) return;
|
|
22
|
-
const onPointerDown = (event: PointerEvent) => {
|
|
23
|
-
const target = event.target as Element;
|
|
24
|
-
const surface = ref.current;
|
|
25
|
-
if (surface && belongsToFloatingSurface(surface, target)) return;
|
|
26
|
-
onDismiss();
|
|
27
|
-
};
|
|
28
|
-
const onKeyDown = (event: KeyboardEvent) => {
|
|
29
|
-
if (event.defaultPrevented) return;
|
|
30
|
-
if (ref.current && ownsFloatingLayer(ref.current, document.activeElement))
|
|
31
|
-
return;
|
|
32
|
-
if (event.key === "Escape") {
|
|
33
|
-
event.preventDefault();
|
|
34
|
-
onDismiss();
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
document.addEventListener("pointerdown", onPointerDown);
|
|
38
|
-
window.addEventListener("keydown", onKeyDown);
|
|
39
|
-
return () => {
|
|
40
|
-
document.removeEventListener("pointerdown", onPointerDown);
|
|
41
|
-
window.removeEventListener("keydown", onKeyDown);
|
|
42
|
-
};
|
|
43
|
-
}, [ref, active, onDismiss]);
|
|
44
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type RefObject, useEffect } from "react";
|
|
2
|
-
import { isOutsideFloatingSurface } from "../lib/floating-layers";
|
|
3
|
-
|
|
4
|
-
/** Dismiss an anchored portal without stealing focus from outside pointer interactions. */
|
|
5
|
-
export function useFloatingDismiss(
|
|
6
|
-
surface: RefObject<HTMLElement | null>,
|
|
7
|
-
anchor: HTMLElement,
|
|
8
|
-
onDismiss: (restoreFocus: boolean) => void,
|
|
9
|
-
) {
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const onPointer = (event: PointerEvent) => {
|
|
12
|
-
if (isOutsideFloatingSurface(surface.current, anchor, event.target))
|
|
13
|
-
onDismiss(false);
|
|
14
|
-
};
|
|
15
|
-
const onFocus = (event: FocusEvent) => {
|
|
16
|
-
if (isOutsideFloatingSurface(surface.current, anchor, event.target))
|
|
17
|
-
onDismiss(false);
|
|
18
|
-
};
|
|
19
|
-
const onBlur = () => onDismiss(false);
|
|
20
|
-
|
|
21
|
-
document.addEventListener("pointerdown", onPointer, true);
|
|
22
|
-
document.addEventListener("focusin", onFocus, true);
|
|
23
|
-
window.addEventListener("blur", onBlur);
|
|
24
|
-
return () => {
|
|
25
|
-
document.removeEventListener("pointerdown", onPointer, true);
|
|
26
|
-
document.removeEventListener("focusin", onFocus, true);
|
|
27
|
-
window.removeEventListener("blur", onBlur);
|
|
28
|
-
};
|
|
29
|
-
}, [surface, anchor, onDismiss]);
|
|
30
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { useCallback, useSyncExternalStore } from "react";
|
|
2
|
-
|
|
3
|
-
const BREAKPOINTS = {
|
|
4
|
-
"2xl": 1536,
|
|
5
|
-
"3xl": 1600,
|
|
6
|
-
"4xl": 2000,
|
|
7
|
-
lg: 1024,
|
|
8
|
-
md: 800,
|
|
9
|
-
sm: 640,
|
|
10
|
-
xl: 1280,
|
|
11
|
-
} as const;
|
|
12
|
-
|
|
13
|
-
export type Breakpoint = keyof typeof BREAKPOINTS;
|
|
14
|
-
export type BreakpointQuery =
|
|
15
|
-
| Breakpoint
|
|
16
|
-
| `max-${Breakpoint}`
|
|
17
|
-
| `${Breakpoint}:max-${Breakpoint}`;
|
|
18
|
-
function resolveMin(value: Breakpoint | number): string {
|
|
19
|
-
const px = typeof value === "number" ? value : BREAKPOINTS[value];
|
|
20
|
-
return `(min-width: ${px}px)`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function resolveMax(value: Breakpoint | number): string {
|
|
24
|
-
const px = typeof value === "number" ? value : BREAKPOINTS[value];
|
|
25
|
-
return `(max-width: ${px - 1}px)`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function parseQuery(
|
|
29
|
-
query: BreakpointQuery | MediaQueryInput | (string & {}),
|
|
30
|
-
): string {
|
|
31
|
-
if (typeof query !== "string") {
|
|
32
|
-
const parts: string[] = [];
|
|
33
|
-
if (query.min != null) parts.push(resolveMin(query.min));
|
|
34
|
-
if (query.max != null) parts.push(resolveMax(query.max));
|
|
35
|
-
if (query.pointer === "coarse") parts.push("(pointer: coarse)");
|
|
36
|
-
if (query.pointer === "fine") parts.push("(pointer: fine)");
|
|
37
|
-
if (parts.length === 0) return "(min-width: 0px)";
|
|
38
|
-
return parts.join(" and ");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (query.startsWith("(")) return query;
|
|
42
|
-
|
|
43
|
-
const parts: string[] = [];
|
|
44
|
-
for (const segment of query.split(":")) {
|
|
45
|
-
if (segment.startsWith("max-")) {
|
|
46
|
-
const bp = segment.slice(4);
|
|
47
|
-
if (bp in BREAKPOINTS) parts.push(resolveMax(bp as Breakpoint));
|
|
48
|
-
} else if (segment in BREAKPOINTS) {
|
|
49
|
-
parts.push(resolveMin(segment as Breakpoint));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return parts.length > 0 ? parts.join(" and ") : query;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function getServerSnapshot(): boolean {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type MediaQueryInput = {
|
|
61
|
-
min?: Breakpoint | number;
|
|
62
|
-
max?: Breakpoint | number;
|
|
63
|
-
/** Touch-like input (finger). Use "fine" for mouse/trackpad. */
|
|
64
|
-
pointer?: PointerPrecision;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type PointerPrecision = "coarse" | "fine";
|
|
68
|
-
|
|
69
|
-
export function useMediaQuery(
|
|
70
|
-
query: BreakpointQuery | MediaQueryInput | (string & {}),
|
|
71
|
-
): boolean {
|
|
72
|
-
const mediaQuery = parseQuery(query);
|
|
73
|
-
|
|
74
|
-
const subscribe = useCallback(
|
|
75
|
-
(callback: () => void) => {
|
|
76
|
-
if (typeof window === "undefined") return () => {};
|
|
77
|
-
const mql = window.matchMedia(mediaQuery);
|
|
78
|
-
mql.addEventListener("change", callback);
|
|
79
|
-
return () => mql.removeEventListener("change", callback);
|
|
80
|
-
},
|
|
81
|
-
[mediaQuery],
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const getSnapshot = useCallback(() => {
|
|
85
|
-
if (typeof window === "undefined") return false;
|
|
86
|
-
return window.matchMedia(mediaQuery).matches;
|
|
87
|
-
}, [mediaQuery]);
|
|
88
|
-
|
|
89
|
-
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function useIsMobile(): boolean {
|
|
93
|
-
return useMediaQuery("(max-width: 768px)");
|
|
94
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { minimizeDecision } from "./scroll/minimize-decision";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Minimized while you scroll down through content, restored when you scroll
|
|
6
|
-
* back up or reach the top: iOS 26's `tabBarMinimizeBehavior(.onScrollDown)`.
|
|
7
|
-
* Listens to every scroll container, since each screen scrolls its own pane.
|
|
8
|
-
*/
|
|
9
|
-
export function useMinimizeOnScroll() {
|
|
10
|
-
const [minimized, setMinimized] = useState(false);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
const anchors = new WeakMap<Element, number>();
|
|
13
|
-
let intent: number | null = null;
|
|
14
|
-
const onIntent = () => {
|
|
15
|
-
intent = performance.now();
|
|
16
|
-
};
|
|
17
|
-
const onKey = (event: KeyboardEvent) => {
|
|
18
|
-
if (
|
|
19
|
-
[
|
|
20
|
-
"ArrowDown",
|
|
21
|
-
"ArrowUp",
|
|
22
|
-
"PageDown",
|
|
23
|
-
"PageUp",
|
|
24
|
-
"Home",
|
|
25
|
-
"End",
|
|
26
|
-
" ",
|
|
27
|
-
].includes(event.key)
|
|
28
|
-
)
|
|
29
|
-
onIntent();
|
|
30
|
-
};
|
|
31
|
-
const onPointer = (event: PointerEvent) => {
|
|
32
|
-
if (event.buttons === 1) onIntent();
|
|
33
|
-
};
|
|
34
|
-
const onScroll = (event: Event) => {
|
|
35
|
-
const pane =
|
|
36
|
-
event.target instanceof Element
|
|
37
|
-
? event.target
|
|
38
|
-
: document.scrollingElement;
|
|
39
|
-
if (
|
|
40
|
-
!pane ||
|
|
41
|
-
pane.closest("[role=dialog], [data-floating-layer]") ||
|
|
42
|
-
pane.scrollHeight <= pane.clientHeight + 1
|
|
43
|
-
)
|
|
44
|
-
return;
|
|
45
|
-
const top = pane.scrollTop;
|
|
46
|
-
const userDriven = intent !== null && performance.now() - intent < 2000;
|
|
47
|
-
const anchor = anchors.get(pane) ?? 0;
|
|
48
|
-
const next = minimizeDecision(top, anchor, userDriven);
|
|
49
|
-
if (next !== null) setMinimized(next);
|
|
50
|
-
if (next !== null || !userDriven) anchors.set(pane, top);
|
|
51
|
-
};
|
|
52
|
-
document.addEventListener("touchmove", onIntent, {
|
|
53
|
-
passive: true,
|
|
54
|
-
});
|
|
55
|
-
document.addEventListener("wheel", onIntent, {
|
|
56
|
-
passive: true,
|
|
57
|
-
});
|
|
58
|
-
document.addEventListener("pointermove", onPointer, {
|
|
59
|
-
passive: true,
|
|
60
|
-
});
|
|
61
|
-
document.addEventListener("keydown", onKey);
|
|
62
|
-
document.addEventListener("scroll", onScroll, {
|
|
63
|
-
capture: true,
|
|
64
|
-
passive: true,
|
|
65
|
-
});
|
|
66
|
-
return () => {
|
|
67
|
-
document.removeEventListener("scroll", onScroll, {
|
|
68
|
-
capture: true,
|
|
69
|
-
});
|
|
70
|
-
document.removeEventListener("touchmove", onIntent);
|
|
71
|
-
document.removeEventListener("wheel", onIntent);
|
|
72
|
-
document.removeEventListener("pointermove", onPointer);
|
|
73
|
-
document.removeEventListener("keydown", onKey);
|
|
74
|
-
};
|
|
75
|
-
}, []);
|
|
76
|
-
return [minimized, setMinimized] as const;
|
|
77
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type ViewportInput = {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
top: number;
|
|
5
|
-
left: number;
|
|
6
|
-
layoutHeight: number;
|
|
7
|
-
editing: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type ViewportMetrics = {
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
top: number;
|
|
13
|
-
left: number;
|
|
14
|
-
keyboardOpen: boolean;
|
|
15
|
-
};
|
|
16
|
-
export type ViewportBaseline = {
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ViewportBaseline, ViewportInput, ViewportMetrics } from "./types";
|
|
2
|
-
|
|
3
|
-
/** A resized WebView and Safari's overlaid keyboard share one visible rectangle. */
|
|
4
|
-
export function viewportMetrics(
|
|
5
|
-
input: ViewportInput,
|
|
6
|
-
baseline: ViewportBaseline,
|
|
7
|
-
): ViewportMetrics {
|
|
8
|
-
const visibleHeight = Math.min(
|
|
9
|
-
input.height,
|
|
10
|
-
Math.max(0, input.layoutHeight - input.top),
|
|
11
|
-
);
|
|
12
|
-
return {
|
|
13
|
-
width: input.width,
|
|
14
|
-
height: visibleHeight,
|
|
15
|
-
top: input.top,
|
|
16
|
-
left: input.left,
|
|
17
|
-
keyboardOpen: input.editing && baseline.height - visibleHeight > 120,
|
|
18
|
-
};
|
|
19
|
-
}
|