@passui/react 0.1.46 → 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 -32
- package/dist/types/src/components/popover/popover-fit.d.ts +0 -21
- 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 -311
- 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 -334
- package/src/components/popover/popover-fit.ts +0 -74
- 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,311 +0,0 @@
|
|
|
1
|
-
import { getNativeLanguageName } from "../../lib/language";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
import { motion, useDragControls, useMotionValue } from "motion/react";
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
-
import { useDismiss } from "../../hooks/use-dismiss";
|
|
6
|
-
import { CheckIcon, GlobeIcon } from "../../icons/icons";
|
|
7
|
-
import { Popover } from "../popover";
|
|
8
|
-
|
|
9
|
-
export type LocaleSwitcherSize = "sm" | "md" | "lg";
|
|
10
|
-
|
|
11
|
-
const triggerSizes: Record<LocaleSwitcherSize, string> = {
|
|
12
|
-
sm: "glass-menu flex h-9 min-w-16 touch-none cursor-grab items-center justify-center gap-1.5 rounded-full px-3 text-caption2 font-semibold text-label active:cursor-grabbing",
|
|
13
|
-
md: "glass-menu flex h-12 min-w-20 touch-none cursor-grab items-center justify-center gap-2 rounded-full px-4 text-caption font-semibold text-label active:cursor-grabbing",
|
|
14
|
-
lg: "glass-menu flex h-14 min-w-24 touch-none cursor-grab items-center justify-center gap-2.5 rounded-full px-5 text-subheadline font-semibold text-label active:cursor-grabbing",
|
|
15
|
-
};
|
|
16
|
-
const iconSizes: Record<LocaleSwitcherSize, string> = {
|
|
17
|
-
sm: "size-4",
|
|
18
|
-
md: "size-5",
|
|
19
|
-
lg: "size-6",
|
|
20
|
-
};
|
|
21
|
-
const popoverWidths: Record<LocaleSwitcherSize, string> = {
|
|
22
|
-
sm: "w-44",
|
|
23
|
-
md: "w-52",
|
|
24
|
-
lg: "w-60",
|
|
25
|
-
};
|
|
26
|
-
const headerSizes: Record<LocaleSwitcherSize, string> = {
|
|
27
|
-
sm: "flex min-h-9 w-full items-center justify-center gap-1.5 rounded-4xl bg-fill/50 text-caption2 font-semibold text-label",
|
|
28
|
-
md: "flex min-h-12 w-full items-center justify-center gap-2 rounded-4xl bg-fill/50 text-caption font-semibold text-label",
|
|
29
|
-
lg: "flex min-h-14 w-full items-center justify-center gap-2.5 rounded-4xl bg-fill/50 text-subheadline font-semibold text-label",
|
|
30
|
-
};
|
|
31
|
-
const itemSizes: Record<LocaleSwitcherSize, string> = {
|
|
32
|
-
sm: "flex min-h-9 items-center justify-between gap-2 rounded-4xl px-3 py-2 text-left text-caption text-label outline-none",
|
|
33
|
-
md: "flex min-h-11 items-center justify-between gap-3 rounded-4xl px-3.5 py-2.5 text-left text-footnote text-label outline-none",
|
|
34
|
-
lg: "flex min-h-13 items-center justify-between gap-3 rounded-4xl px-4 py-3 text-left text-subheadline text-label outline-none",
|
|
35
|
-
};
|
|
36
|
-
const checkIconSizes: Record<LocaleSwitcherSize, string> = {
|
|
37
|
-
sm: "size-3.5 shrink-0",
|
|
38
|
-
md: "size-4 shrink-0",
|
|
39
|
-
lg: "size-5 shrink-0",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type Side = "left" | "right";
|
|
43
|
-
type Edge = "top" | "bottom";
|
|
44
|
-
|
|
45
|
-
type Anchor = {
|
|
46
|
-
side: Side;
|
|
47
|
-
edge: Edge;
|
|
48
|
-
x: number;
|
|
49
|
-
y: number;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const DEFAULT_ANCHOR: Anchor = {
|
|
53
|
-
side: "right",
|
|
54
|
-
edge: "bottom",
|
|
55
|
-
x: 20,
|
|
56
|
-
y: 20,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
function loadStoredAnchor(storageKey: string): Anchor | null {
|
|
60
|
-
try {
|
|
61
|
-
const raw = localStorage.getItem(storageKey);
|
|
62
|
-
if (!raw) return null;
|
|
63
|
-
const parsed = JSON.parse(raw) as Partial<Anchor>;
|
|
64
|
-
if (
|
|
65
|
-
(parsed.side === "left" || parsed.side === "right") &&
|
|
66
|
-
(parsed.edge === "top" || parsed.edge === "bottom") &&
|
|
67
|
-
typeof parsed.x === "number" &&
|
|
68
|
-
typeof parsed.y === "number"
|
|
69
|
-
) {
|
|
70
|
-
return {
|
|
71
|
-
side: parsed.side,
|
|
72
|
-
edge: parsed.edge,
|
|
73
|
-
x: parsed.x,
|
|
74
|
-
y: parsed.y,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
} catch {}
|
|
78
|
-
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function saveStoredAnchor(storageKey: string, anchor: Anchor) {
|
|
82
|
-
try {
|
|
83
|
-
localStorage.setItem(storageKey, JSON.stringify(anchor));
|
|
84
|
-
} catch {}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export type LocaleSwitcherProps<L extends string> = {
|
|
88
|
-
locales: readonly L[];
|
|
89
|
-
locale: L;
|
|
90
|
-
onSelect: (locale: L) => void;
|
|
91
|
-
/** localStorage key for where the person dragged it. */
|
|
92
|
-
storageKey: string;
|
|
93
|
-
label: string;
|
|
94
|
-
/** Trigger, header, list item and icon scale. @default "md" */
|
|
95
|
-
size?: LocaleSwitcherSize;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
/** A draggable floating language picker that snaps to the nearest corner. */
|
|
99
|
-
export function LocaleSwitcher<L extends string>({
|
|
100
|
-
locales,
|
|
101
|
-
locale,
|
|
102
|
-
onSelect,
|
|
103
|
-
storageKey,
|
|
104
|
-
label,
|
|
105
|
-
size = "md",
|
|
106
|
-
}: LocaleSwitcherProps<L>) {
|
|
107
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
108
|
-
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
109
|
-
const dragControls = useDragControls();
|
|
110
|
-
const x = useMotionValue(0);
|
|
111
|
-
const y = useMotionValue(0);
|
|
112
|
-
const [open, setOpen] = useState(false);
|
|
113
|
-
const [anchor, setAnchor] = useState(DEFAULT_ANCHOR);
|
|
114
|
-
|
|
115
|
-
const langs = Array.from(locales, (value) => ({
|
|
116
|
-
value: value,
|
|
117
|
-
label: getNativeLanguageName(value),
|
|
118
|
-
}));
|
|
119
|
-
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
const stored = loadStoredAnchor(storageKey);
|
|
122
|
-
if (stored) setAnchor(stored);
|
|
123
|
-
}, [storageKey]);
|
|
124
|
-
|
|
125
|
-
useDismiss(containerRef, open, () => setOpen(false));
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
if (open)
|
|
128
|
-
containerRef.current
|
|
129
|
-
?.querySelector<HTMLButtonElement>(
|
|
130
|
-
'[role="menuitemradio"][aria-checked="true"]',
|
|
131
|
-
)
|
|
132
|
-
?.focus();
|
|
133
|
-
}, [open]);
|
|
134
|
-
|
|
135
|
-
function commitDraggedPosition() {
|
|
136
|
-
const el = containerRef.current;
|
|
137
|
-
if (!el) return;
|
|
138
|
-
const rect = el.getBoundingClientRect();
|
|
139
|
-
const side: Side =
|
|
140
|
-
rect.left + rect.width / 2 < window.innerWidth / 2 ? "left" : "right";
|
|
141
|
-
const edge: Edge =
|
|
142
|
-
rect.top + rect.height / 2 < window.innerHeight / 2 ? "top" : "bottom";
|
|
143
|
-
const next: Anchor = {
|
|
144
|
-
side,
|
|
145
|
-
edge,
|
|
146
|
-
x: side === "left" ? rect.left : window.innerWidth - rect.right,
|
|
147
|
-
y: edge === "top" ? rect.top : window.innerHeight - rect.bottom,
|
|
148
|
-
};
|
|
149
|
-
setAnchor(next);
|
|
150
|
-
saveStoredAnchor(storageKey, next);
|
|
151
|
-
x.set(0);
|
|
152
|
-
y.set(0);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const growsUp = anchor.edge === "bottom";
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<motion.div
|
|
159
|
-
ref={containerRef}
|
|
160
|
-
drag
|
|
161
|
-
dragControls={dragControls}
|
|
162
|
-
dragListener={false}
|
|
163
|
-
dragMomentum={false}
|
|
164
|
-
dragElastic={0}
|
|
165
|
-
style={{
|
|
166
|
-
position: "fixed",
|
|
167
|
-
x,
|
|
168
|
-
y,
|
|
169
|
-
...(anchor.side === "left" ? { left: anchor.x } : { right: anchor.x }),
|
|
170
|
-
...(anchor.edge === "top" ? { top: anchor.y } : { bottom: anchor.y }),
|
|
171
|
-
}}
|
|
172
|
-
onDragEnd={commitDraggedPosition}
|
|
173
|
-
onDragStart={() => setOpen(false)}
|
|
174
|
-
onKeyDown={(event) => {
|
|
175
|
-
if (!open) return;
|
|
176
|
-
if (event.key === "Escape") {
|
|
177
|
-
event.preventDefault();
|
|
178
|
-
setOpen(false);
|
|
179
|
-
triggerRef.current?.focus();
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (event.key === "Tab") {
|
|
183
|
-
setOpen(false);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key))
|
|
187
|
-
return;
|
|
188
|
-
const options = Array.from(
|
|
189
|
-
containerRef.current?.querySelectorAll<HTMLButtonElement>(
|
|
190
|
-
'[role="menuitemradio"]',
|
|
191
|
-
) ?? [],
|
|
192
|
-
);
|
|
193
|
-
if (!options.length) return;
|
|
194
|
-
event.preventDefault();
|
|
195
|
-
const current = options.indexOf(
|
|
196
|
-
document.activeElement as HTMLButtonElement,
|
|
197
|
-
);
|
|
198
|
-
const next =
|
|
199
|
-
event.key === "Home"
|
|
200
|
-
? 0
|
|
201
|
-
: event.key === "End"
|
|
202
|
-
? options.length - 1
|
|
203
|
-
: (current +
|
|
204
|
-
(event.key === "ArrowDown" ? 1 : -1) +
|
|
205
|
-
options.length) %
|
|
206
|
-
options.length;
|
|
207
|
-
options[next]?.focus();
|
|
208
|
-
}}
|
|
209
|
-
className="z-60"
|
|
210
|
-
>
|
|
211
|
-
<Popover open={open} onOpenChange={setOpen}>
|
|
212
|
-
<Popover.Trigger
|
|
213
|
-
render={({
|
|
214
|
-
ref,
|
|
215
|
-
"aria-haspopup": ariaHasPopup,
|
|
216
|
-
"aria-expanded": ariaExpanded,
|
|
217
|
-
"aria-controls": ariaControls,
|
|
218
|
-
onClick,
|
|
219
|
-
onKeyDown,
|
|
220
|
-
}) => (
|
|
221
|
-
<button
|
|
222
|
-
ref={(node) => {
|
|
223
|
-
ref(node);
|
|
224
|
-
triggerRef.current = node;
|
|
225
|
-
}}
|
|
226
|
-
type="button"
|
|
227
|
-
aria-label={label}
|
|
228
|
-
aria-haspopup={ariaHasPopup}
|
|
229
|
-
aria-expanded={ariaExpanded}
|
|
230
|
-
aria-controls={ariaControls}
|
|
231
|
-
onPointerDown={(e) => dragControls.start(e)}
|
|
232
|
-
onClick={onClick}
|
|
233
|
-
onKeyDown={(event) => {
|
|
234
|
-
onKeyDown(event);
|
|
235
|
-
if (
|
|
236
|
-
!open &&
|
|
237
|
-
(event.key === "ArrowDown" || event.key === "ArrowUp")
|
|
238
|
-
) {
|
|
239
|
-
event.preventDefault();
|
|
240
|
-
setOpen(true);
|
|
241
|
-
}
|
|
242
|
-
}}
|
|
243
|
-
className={triggerSizes[size]}
|
|
244
|
-
>
|
|
245
|
-
<GlobeIcon aria-hidden="true" className={iconSizes[size]} />
|
|
246
|
-
{locale.toUpperCase()}
|
|
247
|
-
</button>
|
|
248
|
-
)}
|
|
249
|
-
/>
|
|
250
|
-
<Popover.Content
|
|
251
|
-
origin={anchor.side === "right" ? "top-right" : "top-left"}
|
|
252
|
-
role="menu"
|
|
253
|
-
label={label}
|
|
254
|
-
className={cn(
|
|
255
|
-
"top-0 flex max-w-[calc(100vw-2.5rem)] gap-2 p-2",
|
|
256
|
-
popoverWidths[size],
|
|
257
|
-
anchor.side === "right" ? "right-0" : "left-0",
|
|
258
|
-
growsUp ? "flex-col-reverse" : "flex-col",
|
|
259
|
-
)}
|
|
260
|
-
>
|
|
261
|
-
<button
|
|
262
|
-
type="button"
|
|
263
|
-
aria-label={label}
|
|
264
|
-
onClick={() => {
|
|
265
|
-
setOpen(false);
|
|
266
|
-
triggerRef.current?.focus();
|
|
267
|
-
}}
|
|
268
|
-
className={headerSizes[size]}
|
|
269
|
-
>
|
|
270
|
-
<GlobeIcon aria-hidden="true" className={iconSizes[size]} />
|
|
271
|
-
{locale.toUpperCase()}
|
|
272
|
-
</button>
|
|
273
|
-
<div className="flex flex-col gap-1">
|
|
274
|
-
{langs.map((item) => {
|
|
275
|
-
const active = item.value === locale;
|
|
276
|
-
return (
|
|
277
|
-
<button
|
|
278
|
-
key={item.value}
|
|
279
|
-
type="button"
|
|
280
|
-
role="menuitemradio"
|
|
281
|
-
aria-checked={active}
|
|
282
|
-
tabIndex={-1}
|
|
283
|
-
onClick={() => {
|
|
284
|
-
setOpen(false);
|
|
285
|
-
triggerRef.current?.focus();
|
|
286
|
-
if (!active) {
|
|
287
|
-
onSelect(item.value);
|
|
288
|
-
}
|
|
289
|
-
}}
|
|
290
|
-
className={cn(
|
|
291
|
-
itemSizes[size],
|
|
292
|
-
"hover:bg-fill/65 focus-visible:bg-fill/65 transition-colors",
|
|
293
|
-
active && "bg-accent/12 font-medium",
|
|
294
|
-
)}
|
|
295
|
-
>
|
|
296
|
-
{item.label}
|
|
297
|
-
{active && (
|
|
298
|
-
<CheckIcon
|
|
299
|
-
aria-hidden="true"
|
|
300
|
-
className={checkIconSizes[size]}
|
|
301
|
-
/>
|
|
302
|
-
)}
|
|
303
|
-
</button>
|
|
304
|
-
);
|
|
305
|
-
})}
|
|
306
|
-
</div>
|
|
307
|
-
</Popover.Content>
|
|
308
|
-
</Popover>
|
|
309
|
-
</motion.div>
|
|
310
|
-
);
|
|
311
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
forwardRef,
|
|
3
|
-
type ReactNode,
|
|
4
|
-
useRef,
|
|
5
|
-
useSyncExternalStore,
|
|
6
|
-
} from "react";
|
|
7
|
-
import { Button, type ButtonProps } from "../button/button";
|
|
8
|
-
import {
|
|
9
|
-
closeContextMenu,
|
|
10
|
-
getContextMenu,
|
|
11
|
-
openMenu,
|
|
12
|
-
subscribeContextMenu,
|
|
13
|
-
type ContextMenuEdge,
|
|
14
|
-
type ContextMenuItem,
|
|
15
|
-
} from "../context-menu/context-menu-store";
|
|
16
|
-
|
|
17
|
-
export interface MenuProps extends Omit<ButtonProps, "onClick" | "children"> {
|
|
18
|
-
/** Accessible name for the menu trigger. */
|
|
19
|
-
label: string;
|
|
20
|
-
/** Items are rendered by the app's existing ContextMenuHost. */
|
|
21
|
-
items: readonly ContextMenuItem[];
|
|
22
|
-
children: ReactNode;
|
|
23
|
-
/** Logical edge used to align the menu, including RTL. @default "leading" */
|
|
24
|
-
edge?: ContextMenuEdge;
|
|
25
|
-
/** Expand upward from the trigger instead of downward. @default false */
|
|
26
|
-
above?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** A declarative menu button using the same native host as context menus. */
|
|
30
|
-
export const Menu = forwardRef<HTMLButtonElement, MenuProps>(function Menu(
|
|
31
|
-
{
|
|
32
|
-
label,
|
|
33
|
-
items,
|
|
34
|
-
children,
|
|
35
|
-
edge = "leading",
|
|
36
|
-
above = false,
|
|
37
|
-
disabled,
|
|
38
|
-
...props
|
|
39
|
-
},
|
|
40
|
-
forwardedRef,
|
|
41
|
-
) {
|
|
42
|
-
const trigger = useRef<HTMLButtonElement>(null);
|
|
43
|
-
const current = useSyncExternalStore(
|
|
44
|
-
subscribeContextMenu,
|
|
45
|
-
getContextMenu,
|
|
46
|
-
() => null,
|
|
47
|
-
);
|
|
48
|
-
const expanded = Boolean(current && current.anchor === trigger.current);
|
|
49
|
-
|
|
50
|
-
const toggle = () => {
|
|
51
|
-
if (!trigger.current || disabled) return;
|
|
52
|
-
if (expanded) closeContextMenu(false);
|
|
53
|
-
else openMenu(trigger.current, [...items], { edge, above });
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<Button
|
|
58
|
-
{...props}
|
|
59
|
-
ref={(node) => {
|
|
60
|
-
trigger.current = node;
|
|
61
|
-
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
62
|
-
else if (forwardedRef) forwardedRef.current = node;
|
|
63
|
-
}}
|
|
64
|
-
type="button"
|
|
65
|
-
aria-label={label}
|
|
66
|
-
aria-haspopup="menu"
|
|
67
|
-
aria-expanded={expanded}
|
|
68
|
-
disabled={disabled}
|
|
69
|
-
onClick={toggle}
|
|
70
|
-
onKeyDown={(event) => {
|
|
71
|
-
props.onKeyDown?.(event);
|
|
72
|
-
if (event.defaultPrevented) return;
|
|
73
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
74
|
-
event.preventDefault();
|
|
75
|
-
if (!expanded) toggle();
|
|
76
|
-
} else if (event.key === "Escape" && expanded) {
|
|
77
|
-
event.preventDefault();
|
|
78
|
-
closeContextMenu();
|
|
79
|
-
}
|
|
80
|
-
}}
|
|
81
|
-
>
|
|
82
|
-
{children}
|
|
83
|
-
</Button>
|
|
84
|
-
);
|
|
85
|
-
});
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AnimatePresence,
|
|
3
|
-
type HTMLMotionProps,
|
|
4
|
-
motion,
|
|
5
|
-
useReducedMotion,
|
|
6
|
-
} from "motion/react";
|
|
7
|
-
import {
|
|
8
|
-
type ReactNode,
|
|
9
|
-
type RefObject,
|
|
10
|
-
useLayoutEffect,
|
|
11
|
-
useRef,
|
|
12
|
-
useState,
|
|
13
|
-
} from "react";
|
|
14
|
-
import { concealMenuSource } from "../context-menu/conceal-menu-source";
|
|
15
|
-
import {
|
|
16
|
-
menuSurfaceExit,
|
|
17
|
-
menuSurfaceReveal,
|
|
18
|
-
type MenuRect,
|
|
19
|
-
} from "../context-menu/menu-reveal";
|
|
20
|
-
import { useSheetFocus } from "../sheet/use-sheet-focus";
|
|
21
|
-
import { SheetPortal } from "../sheet/sheet-portal";
|
|
22
|
-
import { cn } from "../../lib/class-names";
|
|
23
|
-
import {
|
|
24
|
-
contentCrossfade,
|
|
25
|
-
fluidCollapse,
|
|
26
|
-
fluidOvershoot,
|
|
27
|
-
} from "../../motion/transitions";
|
|
28
|
-
|
|
29
|
-
export type MorphSize = "sm" | "md" | "lg";
|
|
30
|
-
|
|
31
|
-
const outerPaddings: Record<MorphSize, string> = {
|
|
32
|
-
sm: "p-4",
|
|
33
|
-
md: "p-6",
|
|
34
|
-
lg: "p-8",
|
|
35
|
-
};
|
|
36
|
-
const panelMaxWidths: Record<MorphSize, string> = {
|
|
37
|
-
sm: "max-w-sm",
|
|
38
|
-
md: "max-w-[720px]",
|
|
39
|
-
lg: "max-w-3xl",
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export interface MorphProps extends Omit<HTMLMotionProps<"div">, "children"> {
|
|
43
|
-
/** Controls whether the overlay is presented. */
|
|
44
|
-
open: boolean;
|
|
45
|
-
/** Called on Escape or outside press. */
|
|
46
|
-
onClose: () => void;
|
|
47
|
-
/** The element whose rect the overlay grows from and collapses back to. */
|
|
48
|
-
sourceRef: RefObject<HTMLElement | null>;
|
|
49
|
-
/** Accessible name (used when there is no labelledBy). */
|
|
50
|
-
label: string;
|
|
51
|
-
/** ID of a visible heading inside the overlay. */
|
|
52
|
-
labelledBy?: string;
|
|
53
|
-
/** Allow tapping the backdrop to close. Escape still calls onClose. @default true */
|
|
54
|
-
dismissOnOutsidePress?: boolean;
|
|
55
|
-
/** Outer padding and panel max-width. @default "md" */
|
|
56
|
-
size?: MorphSize;
|
|
57
|
-
className?: string;
|
|
58
|
-
children?: ReactNode;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* A modal overlay that morphs its glass material from a source element's
|
|
63
|
-
* rect to its own resting rect, then collapses back — Apple's
|
|
64
|
-
* matched-geometry effect. The source is concealed while the overlay is
|
|
65
|
-
* mounted so the material reads as the source itself springing open.
|
|
66
|
-
*
|
|
67
|
-
* Reuses `SheetPortal` (theme inheritance), `useSheetFocus` (focus trap,
|
|
68
|
-
* Escape, modal environment) and the same `menuSurfaceReveal` FLIP
|
|
69
|
-
* primitive that powers anchored `Popover` and `ContextMenu`.
|
|
70
|
-
*/
|
|
71
|
-
export function Morph({ open, ...props }: MorphProps) {
|
|
72
|
-
return <AnimatePresence>{open && <OpenMorph {...props} />}</AnimatePresence>;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function OpenMorph({
|
|
76
|
-
onClose,
|
|
77
|
-
sourceRef,
|
|
78
|
-
label,
|
|
79
|
-
labelledBy,
|
|
80
|
-
dismissOnOutsidePress = true,
|
|
81
|
-
size = "md",
|
|
82
|
-
className,
|
|
83
|
-
children,
|
|
84
|
-
...props
|
|
85
|
-
}: Omit<MorphProps, "open">) {
|
|
86
|
-
const panel = useRef<HTMLDivElement>(null);
|
|
87
|
-
const reducedMotion = useReducedMotion();
|
|
88
|
-
const [settled, setSettled] = useState(false);
|
|
89
|
-
const [target, setTarget] = useState<{
|
|
90
|
-
width: number;
|
|
91
|
-
height: number;
|
|
92
|
-
radius: number;
|
|
93
|
-
} | null>(null);
|
|
94
|
-
const [reveal, setReveal] = useState<ReturnType<
|
|
95
|
-
typeof menuSurfaceReveal
|
|
96
|
-
> | null>(null);
|
|
97
|
-
useSheetFocus(panel, onClose);
|
|
98
|
-
|
|
99
|
-
// Measure the panel's resting rect and the source's rect, then compute
|
|
100
|
-
// the reveal (initial material state) from menuSurfaceReveal. Re-measures
|
|
101
|
-
// on resize/scroll so the morph stays aligned if either moves.
|
|
102
|
-
useLayoutEffect(() => {
|
|
103
|
-
const surface = panel.current;
|
|
104
|
-
const source = sourceRef.current;
|
|
105
|
-
if (!surface) return;
|
|
106
|
-
const measure = () => {
|
|
107
|
-
const panelRect = surface.getBoundingClientRect();
|
|
108
|
-
const radius =
|
|
109
|
-
Number.parseFloat(getComputedStyle(surface).borderTopLeftRadius) || 0;
|
|
110
|
-
setTarget((current) =>
|
|
111
|
-
current &&
|
|
112
|
-
current.width === panelRect.width &&
|
|
113
|
-
current.height === panelRect.height &&
|
|
114
|
-
current.radius === radius
|
|
115
|
-
? current
|
|
116
|
-
: { width: panelRect.width, height: panelRect.height, radius },
|
|
117
|
-
);
|
|
118
|
-
const sourceRect = source?.getBoundingClientRect();
|
|
119
|
-
const sourceArg: MenuRect | undefined =
|
|
120
|
-
sourceRect && sourceRect.width > 0 && sourceRect.height > 0
|
|
121
|
-
? {
|
|
122
|
-
left: sourceRect.left,
|
|
123
|
-
top: sourceRect.top,
|
|
124
|
-
width: sourceRect.width,
|
|
125
|
-
height: sourceRect.height,
|
|
126
|
-
}
|
|
127
|
-
: undefined;
|
|
128
|
-
setReveal(
|
|
129
|
-
menuSurfaceReveal(sourceArg, {
|
|
130
|
-
left: panelRect.left,
|
|
131
|
-
top: panelRect.top,
|
|
132
|
-
width: panelRect.width,
|
|
133
|
-
height: panelRect.height,
|
|
134
|
-
radius,
|
|
135
|
-
}),
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
measure();
|
|
139
|
-
let frame = 0;
|
|
140
|
-
const schedule = () => {
|
|
141
|
-
cancelAnimationFrame(frame);
|
|
142
|
-
frame = requestAnimationFrame(measure);
|
|
143
|
-
};
|
|
144
|
-
const observer = new ResizeObserver(schedule);
|
|
145
|
-
observer.observe(surface);
|
|
146
|
-
if (source) observer.observe(source);
|
|
147
|
-
const viewport = window.visualViewport;
|
|
148
|
-
viewport?.addEventListener("resize", schedule);
|
|
149
|
-
viewport?.addEventListener("scroll", schedule);
|
|
150
|
-
window.addEventListener("resize", schedule);
|
|
151
|
-
window.addEventListener("scroll", schedule, true);
|
|
152
|
-
return () => {
|
|
153
|
-
observer.disconnect();
|
|
154
|
-
cancelAnimationFrame(frame);
|
|
155
|
-
viewport?.removeEventListener("resize", schedule);
|
|
156
|
-
viewport?.removeEventListener("scroll", schedule);
|
|
157
|
-
window.removeEventListener("resize", schedule);
|
|
158
|
-
window.removeEventListener("scroll", schedule, true);
|
|
159
|
-
};
|
|
160
|
-
}, [sourceRef]);
|
|
161
|
-
|
|
162
|
-
// Conceal the source while the morph is mounted; restore on unmount.
|
|
163
|
-
useLayoutEffect(() => {
|
|
164
|
-
const source = sourceRef.current;
|
|
165
|
-
if (!source) return;
|
|
166
|
-
const restore = concealMenuSource(source, false);
|
|
167
|
-
return () => {
|
|
168
|
-
restore();
|
|
169
|
-
};
|
|
170
|
-
}, [sourceRef]);
|
|
171
|
-
|
|
172
|
-
return (
|
|
173
|
-
<SheetPortal>
|
|
174
|
-
<div
|
|
175
|
-
className={cn(
|
|
176
|
-
"fixed inset-0 z-[75] flex items-center justify-center",
|
|
177
|
-
outerPaddings[size],
|
|
178
|
-
)}
|
|
179
|
-
>
|
|
180
|
-
<motion.div
|
|
181
|
-
aria-hidden="true"
|
|
182
|
-
className="absolute inset-0 bg-black/30 backdrop-blur-md"
|
|
183
|
-
initial={{ opacity: 0 }}
|
|
184
|
-
animate={{ opacity: 1 }}
|
|
185
|
-
exit={{ opacity: 0 }}
|
|
186
|
-
transition={reducedMotion ? { duration: 0 } : { duration: 0.18 }}
|
|
187
|
-
onClick={dismissOnOutsidePress ? onClose : undefined}
|
|
188
|
-
/>
|
|
189
|
-
<motion.div
|
|
190
|
-
ref={panel}
|
|
191
|
-
role="dialog"
|
|
192
|
-
aria-modal="true"
|
|
193
|
-
aria-label={labelledBy ? undefined : label}
|
|
194
|
-
aria-labelledby={labelledBy}
|
|
195
|
-
tabIndex={-1}
|
|
196
|
-
className={cn(
|
|
197
|
-
"rounded-5xl relative isolate flex w-full flex-col outline-none",
|
|
198
|
-
"max-h-[92%]",
|
|
199
|
-
panelMaxWidths[size],
|
|
200
|
-
settled && "overflow-hidden",
|
|
201
|
-
className,
|
|
202
|
-
)}
|
|
203
|
-
{...props}
|
|
204
|
-
>
|
|
205
|
-
{/* The morphing material — mirrors Popover's data-popover-surface
|
|
206
|
-
pattern. Starts at the source's rect (offset relative to the
|
|
207
|
-
panel) and grows to fill the panel, with the fluid overshoot
|
|
208
|
-
bounce. Border radius interpolates from the source's
|
|
209
|
-
"pillified" radius to the panel's authored radius. */}
|
|
210
|
-
<motion.div
|
|
211
|
-
key={reveal ? "surface" : "measure"}
|
|
212
|
-
aria-hidden="true"
|
|
213
|
-
data-morph-surface=""
|
|
214
|
-
onAnimationComplete={() => {
|
|
215
|
-
if (reveal) setSettled(true);
|
|
216
|
-
}}
|
|
217
|
-
className="glass-menu rounded-5xl pointer-events-none absolute top-0 left-0 -z-10"
|
|
218
|
-
style={{ width: "100%", height: "100%" }}
|
|
219
|
-
initial={reducedMotion || !reveal ? { opacity: 0 } : reveal}
|
|
220
|
-
animate={
|
|
221
|
-
target
|
|
222
|
-
? {
|
|
223
|
-
x: 0,
|
|
224
|
-
y: 0,
|
|
225
|
-
width: target.width,
|
|
226
|
-
height: target.height,
|
|
227
|
-
opacity: 1,
|
|
228
|
-
borderRadius: target.radius,
|
|
229
|
-
}
|
|
230
|
-
: undefined
|
|
231
|
-
}
|
|
232
|
-
exit={
|
|
233
|
-
reducedMotion || !reveal
|
|
234
|
-
? { opacity: 0 }
|
|
235
|
-
: { ...menuSurfaceExit(reveal), transition: fluidCollapse }
|
|
236
|
-
}
|
|
237
|
-
transition={
|
|
238
|
-
reducedMotion
|
|
239
|
-
? { duration: 0 }
|
|
240
|
-
: { ...fluidOvershoot, opacity: { duration: 0.18 } }
|
|
241
|
-
}
|
|
242
|
-
/>
|
|
243
|
-
<motion.div
|
|
244
|
-
className="flex min-h-0 flex-1 flex-col overflow-y-auto"
|
|
245
|
-
initial={reducedMotion ? false : contentCrossfade.initial}
|
|
246
|
-
animate={reducedMotion ? undefined : contentCrossfade.animate}
|
|
247
|
-
exit={reducedMotion ? undefined : contentCrossfade.exit}
|
|
248
|
-
transition={
|
|
249
|
-
reducedMotion ? { duration: 0 } : contentCrossfade.transition
|
|
250
|
-
}
|
|
251
|
-
>
|
|
252
|
-
{children}
|
|
253
|
-
</motion.div>
|
|
254
|
-
</motion.div>
|
|
255
|
-
</div>
|
|
256
|
-
</SheetPortal>
|
|
257
|
-
);
|
|
258
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Disclosure state that keeps the overlay mounted through its exit animation,
|
|
5
|
-
* mirroring `useAnchoredDisclosure`. Pair with a `useRef<HTMLElement>(null)`
|
|
6
|
-
* for the source.
|
|
7
|
-
*/
|
|
8
|
-
export function useMorphDisclosure(disabled = false) {
|
|
9
|
-
const [open, setOpen] = useState(false);
|
|
10
|
-
const [mounted, setMounted] = useState(false);
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (disabled) setOpen(false);
|
|
13
|
-
}, [disabled]);
|
|
14
|
-
const show = useCallback(() => {
|
|
15
|
-
setMounted(true);
|
|
16
|
-
setOpen(true);
|
|
17
|
-
}, []);
|
|
18
|
-
const toggle = useCallback(() => {
|
|
19
|
-
setMounted(true);
|
|
20
|
-
setOpen((value) => !value);
|
|
21
|
-
}, []);
|
|
22
|
-
const close = useCallback(() => setOpen(false), []);
|
|
23
|
-
const onExited = useCallback(() => {
|
|
24
|
-
if (!open || disabled) setMounted(false);
|
|
25
|
-
}, [open, disabled]);
|
|
26
|
-
return { open: open && !disabled, mounted, show, toggle, close, onExited };
|
|
27
|
-
}
|