@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,62 +0,0 @@
|
|
|
1
|
-
import { type ReactNode, useLayoutEffect, useRef, useState } from "react";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
|
|
4
|
-
/** Escape transformed page layers while retaining the source's scoped appearance. */
|
|
5
|
-
export function SheetPortal({ children }: { children: ReactNode }) {
|
|
6
|
-
const source = useRef<HTMLSpanElement>(null);
|
|
7
|
-
const [host, setHost] = useState<HTMLDivElement | null>(null);
|
|
8
|
-
useLayoutEffect(() => {
|
|
9
|
-
const marker = source.current;
|
|
10
|
-
if (!marker) return;
|
|
11
|
-
const document = marker.ownerDocument;
|
|
12
|
-
const layer = document.createElement("div");
|
|
13
|
-
layer.dataset.passuiOverlay = "";
|
|
14
|
-
layer.style.display = "contents";
|
|
15
|
-
const attributes = ["data-theme", "data-accent", "data-os", "dir"];
|
|
16
|
-
let properties = new Set<string>();
|
|
17
|
-
const inherit = () => {
|
|
18
|
-
for (const name of attributes) {
|
|
19
|
-
const value = marker.closest(`[${name}]`)?.getAttribute(name);
|
|
20
|
-
if (value === null || value === undefined) layer.removeAttribute(name);
|
|
21
|
-
else layer.setAttribute(name, value);
|
|
22
|
-
}
|
|
23
|
-
const computed = getComputedStyle(marker);
|
|
24
|
-
const next = new Set<string>();
|
|
25
|
-
for (const name of computed) {
|
|
26
|
-
if (!name.startsWith("--")) continue;
|
|
27
|
-
next.add(name);
|
|
28
|
-
layer.style.setProperty(name, computed.getPropertyValue(name));
|
|
29
|
-
}
|
|
30
|
-
for (const name of properties)
|
|
31
|
-
if (!next.has(name)) layer.style.removeProperty(name);
|
|
32
|
-
properties = next;
|
|
33
|
-
layer.style.colorScheme = computed.colorScheme;
|
|
34
|
-
layer.style.fontFamily = computed.fontFamily;
|
|
35
|
-
layer.style.direction = computed.direction;
|
|
36
|
-
};
|
|
37
|
-
inherit();
|
|
38
|
-
document.body.appendChild(layer);
|
|
39
|
-
setHost(layer);
|
|
40
|
-
const observer = new MutationObserver(inherit);
|
|
41
|
-
for (
|
|
42
|
-
let ancestor = marker.parentElement;
|
|
43
|
-
ancestor;
|
|
44
|
-
ancestor = ancestor.parentElement
|
|
45
|
-
) {
|
|
46
|
-
observer.observe(ancestor, {
|
|
47
|
-
attributes: true,
|
|
48
|
-
attributeFilter: [...attributes, "style", "class"],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return () => {
|
|
52
|
-
observer.disconnect();
|
|
53
|
-
layer.remove();
|
|
54
|
-
};
|
|
55
|
-
}, []);
|
|
56
|
-
return (
|
|
57
|
-
<>
|
|
58
|
-
<span ref={source} hidden aria-hidden="true" />
|
|
59
|
-
{host && createPortal(children, host)}
|
|
60
|
-
</>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
|
2
|
-
import { type ReactNode, useRef } from "react";
|
|
3
|
-
import { useVisualViewport } from "../../hooks/use-visual-viewport";
|
|
4
|
-
import { cn } from "../../lib/class-names";
|
|
5
|
-
import { contentCrossfade, spring, zoomReveal } from "../../motion/transitions";
|
|
6
|
-
import { SheetPortal } from "./sheet-portal";
|
|
7
|
-
import { useSheetFocus } from "./use-sheet-focus";
|
|
8
|
-
|
|
9
|
-
export type SheetPlacement = "adaptive" | "center";
|
|
10
|
-
export type SheetSize = "sm" | "md" | "lg";
|
|
11
|
-
|
|
12
|
-
const outerPaddings: Record<SheetSize, string> = {
|
|
13
|
-
sm: "p-4",
|
|
14
|
-
md: "p-6",
|
|
15
|
-
lg: "p-8",
|
|
16
|
-
};
|
|
17
|
-
const panelMaxWidths: Record<SheetSize, string> = {
|
|
18
|
-
sm: "max-w-sm",
|
|
19
|
-
md: "max-w-[560px]",
|
|
20
|
-
lg: "max-w-2xl",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export interface SheetProps {
|
|
24
|
-
/** Controls whether the sheet is presented. */
|
|
25
|
-
open: boolean;
|
|
26
|
-
/** Called on Escape or an outside press. */
|
|
27
|
-
onClose: () => void;
|
|
28
|
-
/** Allow tapping the backdrop to close. Escape still calls onClose. @default true */
|
|
29
|
-
dismissOnOutsidePress?: boolean;
|
|
30
|
-
/** Read out by screen readers as the sheet's name. */
|
|
31
|
-
label: string;
|
|
32
|
-
/** ID of a visible heading to use instead of label for the accessible name. */
|
|
33
|
-
labelledBy?: string;
|
|
34
|
-
/** `adaptive` rises from the bottom on phones; `center` always floats. @default "adaptive" */
|
|
35
|
-
placement?: SheetPlacement;
|
|
36
|
-
/** Outer padding and panel max-width. @default "md" */
|
|
37
|
-
size?: SheetSize;
|
|
38
|
-
className?: string;
|
|
39
|
-
children: ReactNode;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* A modal card: rises from the bottom edge on phones and floats in the
|
|
44
|
-
* middle on larger screens. Escape or a tap outside closes it.
|
|
45
|
-
*/
|
|
46
|
-
export function Sheet({ open, ...props }: SheetProps) {
|
|
47
|
-
return (
|
|
48
|
-
<AnimatePresence>
|
|
49
|
-
{open && (
|
|
50
|
-
<SheetPortal>
|
|
51
|
-
<OpenSheet {...props} />
|
|
52
|
-
</SheetPortal>
|
|
53
|
-
)}
|
|
54
|
-
</AnimatePresence>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function OpenSheet({
|
|
59
|
-
onClose,
|
|
60
|
-
dismissOnOutsidePress = true,
|
|
61
|
-
label,
|
|
62
|
-
labelledBy,
|
|
63
|
-
placement = "adaptive",
|
|
64
|
-
size = "md",
|
|
65
|
-
className,
|
|
66
|
-
children,
|
|
67
|
-
}: Omit<SheetProps, "open">) {
|
|
68
|
-
const panel = useRef<HTMLDivElement>(null);
|
|
69
|
-
const reducedMotion = useReducedMotion();
|
|
70
|
-
const viewport = useVisualViewport();
|
|
71
|
-
useSheetFocus(panel, onClose);
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<div
|
|
75
|
-
className={cn(
|
|
76
|
-
"fixed inset-0 z-[65] flex justify-center",
|
|
77
|
-
placement === "center"
|
|
78
|
-
? cn("items-center", outerPaddings[size])
|
|
79
|
-
: cn("items-end sm:items-center", `sm:${outerPaddings[size]}`),
|
|
80
|
-
)}
|
|
81
|
-
style={
|
|
82
|
-
viewport
|
|
83
|
-
? {
|
|
84
|
-
top: viewport.top,
|
|
85
|
-
left: viewport.left,
|
|
86
|
-
width: viewport.width,
|
|
87
|
-
height: viewport.height,
|
|
88
|
-
bottom: "auto",
|
|
89
|
-
right: "auto",
|
|
90
|
-
}
|
|
91
|
-
: undefined
|
|
92
|
-
}
|
|
93
|
-
>
|
|
94
|
-
<motion.div
|
|
95
|
-
aria-hidden="true"
|
|
96
|
-
className="absolute inset-0 bg-black/30 backdrop-blur-md"
|
|
97
|
-
initial={{ opacity: 0 }}
|
|
98
|
-
animate={{ opacity: 1 }}
|
|
99
|
-
exit={{ opacity: 0 }}
|
|
100
|
-
onClick={dismissOnOutsidePress ? onClose : undefined}
|
|
101
|
-
/>
|
|
102
|
-
<motion.div
|
|
103
|
-
ref={panel}
|
|
104
|
-
role="dialog"
|
|
105
|
-
aria-modal="true"
|
|
106
|
-
aria-label={labelledBy ? undefined : label}
|
|
107
|
-
aria-labelledby={labelledBy}
|
|
108
|
-
tabIndex={-1}
|
|
109
|
-
className={cn(
|
|
110
|
-
"glass-menu relative flex w-full flex-col overflow-hidden",
|
|
111
|
-
"max-h-[92%]",
|
|
112
|
-
panelMaxWidths[size],
|
|
113
|
-
placement === "center"
|
|
114
|
-
? "rounded-sheet"
|
|
115
|
-
: "rounded-t-sheet sm:rounded-sheet",
|
|
116
|
-
className,
|
|
117
|
-
)}
|
|
118
|
-
style={{
|
|
119
|
-
transformOrigin:
|
|
120
|
-
placement === "center" ? "center center" : "bottom center",
|
|
121
|
-
}}
|
|
122
|
-
initial={
|
|
123
|
-
reducedMotion
|
|
124
|
-
? { opacity: 0 }
|
|
125
|
-
: placement === "center"
|
|
126
|
-
? zoomReveal.initial
|
|
127
|
-
: { y: 40, opacity: 0, scale: 0.96 }
|
|
128
|
-
}
|
|
129
|
-
animate={
|
|
130
|
-
reducedMotion
|
|
131
|
-
? { opacity: 1 }
|
|
132
|
-
: placement === "center"
|
|
133
|
-
? zoomReveal.animate
|
|
134
|
-
: { y: 0, opacity: 1, scale: 1 }
|
|
135
|
-
}
|
|
136
|
-
exit={
|
|
137
|
-
reducedMotion
|
|
138
|
-
? { opacity: 0 }
|
|
139
|
-
: placement === "center"
|
|
140
|
-
? zoomReveal.exit
|
|
141
|
-
: { y: 30, opacity: 0, scale: 0.98 }
|
|
142
|
-
}
|
|
143
|
-
transition={
|
|
144
|
-
reducedMotion
|
|
145
|
-
? { duration: 0 }
|
|
146
|
-
: placement === "center"
|
|
147
|
-
? zoomReveal.transition
|
|
148
|
-
: { ...spring.bouncy, opacity: { duration: 0.18 } }
|
|
149
|
-
}
|
|
150
|
-
>
|
|
151
|
-
<motion.div
|
|
152
|
-
className="flex min-h-0 flex-1 flex-col overflow-y-auto"
|
|
153
|
-
initial={reducedMotion ? false : contentCrossfade.initial}
|
|
154
|
-
animate={reducedMotion ? undefined : contentCrossfade.animate}
|
|
155
|
-
exit={reducedMotion ? undefined : contentCrossfade.exit}
|
|
156
|
-
transition={
|
|
157
|
-
reducedMotion ? { duration: 0 } : contentCrossfade.transition
|
|
158
|
-
}
|
|
159
|
-
>
|
|
160
|
-
{children}
|
|
161
|
-
</motion.div>
|
|
162
|
-
</motion.div>
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type RefObject,
|
|
3
|
-
useEffect,
|
|
4
|
-
useLayoutEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { ownsFloatingLayer } from "../../lib/floating-layers";
|
|
9
|
-
import { enterModalEnvironment } from "./modal-environment";
|
|
10
|
-
|
|
11
|
-
const sheets: HTMLElement[] = [];
|
|
12
|
-
const focusableSelector = [
|
|
13
|
-
"a[href]",
|
|
14
|
-
"button",
|
|
15
|
-
"input:not([type=hidden])",
|
|
16
|
-
"select",
|
|
17
|
-
"textarea",
|
|
18
|
-
"[tabindex]",
|
|
19
|
-
"[contenteditable=true]",
|
|
20
|
-
].join(",");
|
|
21
|
-
|
|
22
|
-
function focusableElements(panel: HTMLElement): HTMLElement[] {
|
|
23
|
-
return Array.from(
|
|
24
|
-
panel.querySelectorAll<HTMLElement>(focusableSelector),
|
|
25
|
-
).filter(
|
|
26
|
-
(element) =>
|
|
27
|
-
element.tabIndex >= 0 &&
|
|
28
|
-
!element.matches(":disabled") &&
|
|
29
|
-
!element.closest("[inert]") &&
|
|
30
|
-
element.getClientRects().length > 0 &&
|
|
31
|
-
getComputedStyle(element).visibility !== "hidden",
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Keeps keyboard focus in the foremost sheet, including its floating pickers. */
|
|
36
|
-
export function useSheetFocus(
|
|
37
|
-
panel: RefObject<HTMLDivElement | null>,
|
|
38
|
-
onClose: () => void,
|
|
39
|
-
) {
|
|
40
|
-
// Capture before children mount, since a child may use autoFocus.
|
|
41
|
-
const [opener] = useState(() =>
|
|
42
|
-
typeof document === "undefined" ? null : document.activeElement,
|
|
43
|
-
);
|
|
44
|
-
const close = useRef(onClose);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
close.current = onClose;
|
|
47
|
-
}, [onClose]);
|
|
48
|
-
|
|
49
|
-
useLayoutEffect(() => {
|
|
50
|
-
const surface = panel.current;
|
|
51
|
-
if (!surface) return;
|
|
52
|
-
sheets.push(surface);
|
|
53
|
-
const foremost = () => sheets.at(-1) === surface;
|
|
54
|
-
const focusFirst = () => (focusableElements(surface)[0] ?? surface).focus();
|
|
55
|
-
const inFloatingLayer = (element: Element | null) =>
|
|
56
|
-
ownsFloatingLayer(surface, element);
|
|
57
|
-
const belongsToSheet = (element: Element | null) =>
|
|
58
|
-
surface.contains(element) || inFloatingLayer(element);
|
|
59
|
-
|
|
60
|
-
if (!surface.contains(document.activeElement))
|
|
61
|
-
surface.focus({ preventScroll: true });
|
|
62
|
-
const leaveModalEnvironment = enterModalEnvironment(surface);
|
|
63
|
-
|
|
64
|
-
const onFocus = (event: FocusEvent) => {
|
|
65
|
-
if (foremost() && !belongsToSheet(event.target as Element | null))
|
|
66
|
-
focusFirst();
|
|
67
|
-
};
|
|
68
|
-
const onKey = (event: KeyboardEvent) => {
|
|
69
|
-
if (!foremost() || event.defaultPrevented) return;
|
|
70
|
-
if (event.key === "Escape") {
|
|
71
|
-
// Floating controls handle their own Escape before the sheet.
|
|
72
|
-
if (inFloatingLayer(document.activeElement)) return;
|
|
73
|
-
event.preventDefault();
|
|
74
|
-
event.stopPropagation();
|
|
75
|
-
close.current();
|
|
76
|
-
}
|
|
77
|
-
if (event.key !== "Tab") return;
|
|
78
|
-
const controls = focusableElements(surface);
|
|
79
|
-
const first = controls[0] ?? surface;
|
|
80
|
-
const last = controls.at(-1) ?? surface;
|
|
81
|
-
const active = document.activeElement;
|
|
82
|
-
if (
|
|
83
|
-
event.shiftKey &&
|
|
84
|
-
(active === surface || active === first || !surface.contains(active))
|
|
85
|
-
) {
|
|
86
|
-
event.preventDefault();
|
|
87
|
-
last.focus();
|
|
88
|
-
} else if (
|
|
89
|
-
!event.shiftKey &&
|
|
90
|
-
(active === last || !surface.contains(active) || active === surface)
|
|
91
|
-
) {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
first.focus();
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
document.addEventListener("focusin", onFocus);
|
|
98
|
-
window.addEventListener("keydown", onKey);
|
|
99
|
-
return () => {
|
|
100
|
-
const wasForemost = foremost();
|
|
101
|
-
sheets.splice(sheets.indexOf(surface), 1);
|
|
102
|
-
document.removeEventListener("focusin", onFocus);
|
|
103
|
-
window.removeEventListener("keydown", onKey);
|
|
104
|
-
leaveModalEnvironment();
|
|
105
|
-
if (wasForemost && opener instanceof HTMLElement && opener.isConnected)
|
|
106
|
-
opener.focus();
|
|
107
|
-
};
|
|
108
|
-
}, [panel, opener]);
|
|
109
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { useId, type ReactNode } from "react";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
|
|
4
|
-
export interface SidebarSectionProps {
|
|
5
|
-
/** Visible heading for this group of navigation rows. */
|
|
6
|
-
title: string;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface SidebarItemContentProps {
|
|
11
|
-
icon?: ReactNode;
|
|
12
|
-
/** Optional trailing count. */
|
|
13
|
-
count?: number;
|
|
14
|
-
/** Matches the router link's active state. */
|
|
15
|
-
active?: boolean;
|
|
16
|
-
children: ReactNode;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function SidebarSection({
|
|
20
|
-
title,
|
|
21
|
-
children,
|
|
22
|
-
size = "md",
|
|
23
|
-
}: SidebarSectionProps & { size?: SidebarSize }) {
|
|
24
|
-
const headingId = useId();
|
|
25
|
-
return (
|
|
26
|
-
<section aria-labelledby={headingId} className="flex flex-col gap-0.5">
|
|
27
|
-
<h2 id={headingId} className={sidebarHeadingSizes[size]}>
|
|
28
|
-
{title}
|
|
29
|
-
</h2>
|
|
30
|
-
{children}
|
|
31
|
-
</section>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** Classes for a sidebar row; apply to the app's router link. */
|
|
36
|
-
export type SidebarDensity = "regular" | "compact";
|
|
37
|
-
export type SidebarSize = "sm" | "md" | "lg";
|
|
38
|
-
|
|
39
|
-
const sidebarItemSizes: Record<SidebarSize, string> = {
|
|
40
|
-
sm: "min-h-8 rounded-lg px-2 py-1 text-footnote [@media(pointer:coarse)]:min-h-10",
|
|
41
|
-
md: "rounded-2xl px-2.5 py-[7px] text-subheadline",
|
|
42
|
-
lg: "rounded-2xl px-3 py-2.5 text-body [@media(pointer:coarse)]:min-h-13",
|
|
43
|
-
};
|
|
44
|
-
const sidebarHeadingSizes: Record<SidebarSize, string> = {
|
|
45
|
-
sm: "px-2 pb-1 text-caption2 font-semibold text-label-tertiary",
|
|
46
|
-
md: "px-2.5 pb-1.5 text-caption font-semibold text-label-tertiary",
|
|
47
|
-
lg: "px-3 pb-2 text-subheadline font-semibold text-label-tertiary",
|
|
48
|
-
};
|
|
49
|
-
const sidebarCountSizes: Record<SidebarSize, string> = {
|
|
50
|
-
sm: "text-caption2 tabular-nums",
|
|
51
|
-
md: "text-footnote tabular-nums",
|
|
52
|
-
lg: "text-subheadline tabular-nums",
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export function sidebarItemClass(
|
|
56
|
-
active?: boolean,
|
|
57
|
-
density: SidebarDensity = "regular",
|
|
58
|
-
size?: SidebarSize,
|
|
59
|
-
): string {
|
|
60
|
-
const resolved = size ?? (density === "compact" ? "sm" : "md");
|
|
61
|
-
return cn(
|
|
62
|
-
"group text-label duration-fast focus-visible:outline-accent-text flex w-full items-center gap-2.5 no-underline transition-colors focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
63
|
-
sidebarItemSizes[resolved],
|
|
64
|
-
active
|
|
65
|
-
? "bg-fill font-medium"
|
|
66
|
-
: "text-label-secondary hover:bg-fill/70 hover:text-label font-normal",
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function SidebarItemContent({
|
|
71
|
-
icon,
|
|
72
|
-
count,
|
|
73
|
-
active,
|
|
74
|
-
size = "md",
|
|
75
|
-
children,
|
|
76
|
-
}: SidebarItemContentProps & { size?: SidebarSize }) {
|
|
77
|
-
return (
|
|
78
|
-
<>
|
|
79
|
-
{icon && (
|
|
80
|
-
<span
|
|
81
|
-
className={cn(
|
|
82
|
-
"flex transition-colors",
|
|
83
|
-
active ? "text-accent-text" : "text-label-secondary",
|
|
84
|
-
)}
|
|
85
|
-
>
|
|
86
|
-
{icon}
|
|
87
|
-
</span>
|
|
88
|
-
)}
|
|
89
|
-
<span className="grow truncate">{children}</span>
|
|
90
|
-
{count !== undefined && (
|
|
91
|
-
<span
|
|
92
|
-
className={cn(
|
|
93
|
-
sidebarCountSizes[size],
|
|
94
|
-
active ? "text-accent-text" : "text-label-tertiary",
|
|
95
|
-
)}
|
|
96
|
-
>
|
|
97
|
-
{count}
|
|
98
|
-
</span>
|
|
99
|
-
)}
|
|
100
|
-
</>
|
|
101
|
-
);
|
|
102
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from "react";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
|
|
4
|
-
export type SkeletonSize = "sm" | "md" | "lg";
|
|
5
|
-
|
|
6
|
-
const minHeights: Record<SkeletonSize, string> = {
|
|
7
|
-
sm: "min-h-3 rounded-md",
|
|
8
|
-
md: "min-h-4 rounded-md",
|
|
9
|
-
lg: "min-h-6 rounded-lg",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface SkeletonProps extends ComponentProps<"div"> {
|
|
13
|
-
label?: string;
|
|
14
|
-
/** Minimum height and rounding. @default "md" */
|
|
15
|
-
size?: SkeletonSize;
|
|
16
|
-
}
|
|
17
|
-
/** A loading placeholder that becomes still when Reduce Motion is enabled. */
|
|
18
|
-
export function Skeleton({
|
|
19
|
-
label,
|
|
20
|
-
size = "md",
|
|
21
|
-
className,
|
|
22
|
-
...props
|
|
23
|
-
}: SkeletonProps) {
|
|
24
|
-
return (
|
|
25
|
-
<div
|
|
26
|
-
{...props}
|
|
27
|
-
role={label ? "status" : undefined}
|
|
28
|
-
aria-hidden={label ? undefined : true}
|
|
29
|
-
className={cn(
|
|
30
|
-
"bg-fill motion-safe:animate-pulse",
|
|
31
|
-
minHeights[size],
|
|
32
|
-
className,
|
|
33
|
-
)}
|
|
34
|
-
>
|
|
35
|
-
{label && <span className="sr-only">{label}</span>}
|
|
36
|
-
</div>
|
|
37
|
-
);
|
|
38
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps, useId } from "react";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
import { clampRange } from "../../lib/range-value";
|
|
4
|
-
|
|
5
|
-
export type SliderSize = "sm" | "md" | "lg";
|
|
6
|
-
|
|
7
|
-
const labelSizes: Record<SliderSize, string> = {
|
|
8
|
-
sm: "text-footnote font-semibold text-label",
|
|
9
|
-
md: "text-subheadline font-semibold text-label",
|
|
10
|
-
lg: "text-body font-semibold text-label",
|
|
11
|
-
};
|
|
12
|
-
const inputHeights: Record<SliderSize, string> = {
|
|
13
|
-
sm: "h-9",
|
|
14
|
-
md: "h-11",
|
|
15
|
-
lg: "h-13",
|
|
16
|
-
};
|
|
17
|
-
const descriptionSizes: Record<SliderSize, string> = {
|
|
18
|
-
sm: "text-caption2 text-label-secondary",
|
|
19
|
-
md: "text-footnote text-label-secondary",
|
|
20
|
-
lg: "text-subheadline text-label-secondary",
|
|
21
|
-
};
|
|
22
|
-
// Track height, thumb size, and the webkit thumb's -mt offset (derived from
|
|
23
|
-
// (thumb - track) / 2: md (20-6)/2=7, sm (16-4)/2=6, lg (24-8)/2=8).
|
|
24
|
-
const webkitTrack: Record<SliderSize, string> = {
|
|
25
|
-
sm: "[&::-webkit-slider-runnable-track]:h-1 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-separator",
|
|
26
|
-
md: "[&::-webkit-slider-runnable-track]:h-1.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-separator",
|
|
27
|
-
lg: "[&::-webkit-slider-runnable-track]:h-2 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-separator",
|
|
28
|
-
};
|
|
29
|
-
const webkitThumb: Record<SliderSize, string> = {
|
|
30
|
-
sm: "[&::-webkit-slider-thumb]:-mt-[6px] [&::-webkit-slider-thumb]:size-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-accent [&::-webkit-slider-thumb]:bg-elevated [&::-webkit-slider-thumb]:shadow-sm",
|
|
31
|
-
md: "[&::-webkit-slider-thumb]:-mt-[7px] [&::-webkit-slider-thumb]:size-5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-accent [&::-webkit-slider-thumb]:bg-elevated [&::-webkit-slider-thumb]:shadow-sm",
|
|
32
|
-
lg: "[&::-webkit-slider-thumb]:-mt-[8px] [&::-webkit-slider-thumb]:size-6 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-accent [&::-webkit-slider-thumb]:bg-elevated [&::-webkit-slider-thumb]:shadow-sm",
|
|
33
|
-
};
|
|
34
|
-
const mozTrack: Record<SliderSize, string> = {
|
|
35
|
-
sm: "[&::-moz-range-track]:h-1 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-separator",
|
|
36
|
-
md: "[&::-moz-range-track]:h-1.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-separator",
|
|
37
|
-
lg: "[&::-moz-range-track]:h-2 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-separator",
|
|
38
|
-
};
|
|
39
|
-
const mozProgress: Record<SliderSize, string> = {
|
|
40
|
-
sm: "[&::-moz-range-progress]:h-1 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:bg-accent",
|
|
41
|
-
md: "[&::-moz-range-progress]:h-1.5 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:bg-accent",
|
|
42
|
-
lg: "[&::-moz-range-progress]:h-2 [&::-moz-range-progress]:rounded-full [&::-moz-range-progress]:bg-accent",
|
|
43
|
-
};
|
|
44
|
-
const mozThumb: Record<SliderSize, string> = {
|
|
45
|
-
sm: "[&::-moz-range-thumb]:size-3 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-accent [&::-moz-range-thumb]:bg-elevated",
|
|
46
|
-
md: "[&::-moz-range-thumb]:size-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-accent [&::-moz-range-thumb]:bg-elevated",
|
|
47
|
-
lg: "[&::-moz-range-thumb]:size-5 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-accent [&::-moz-range-thumb]:bg-elevated",
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export interface SliderProps
|
|
51
|
-
extends Omit<
|
|
52
|
-
ComponentProps<"input">,
|
|
53
|
-
| "type"
|
|
54
|
-
| "value"
|
|
55
|
-
| "defaultValue"
|
|
56
|
-
| "onChange"
|
|
57
|
-
| "min"
|
|
58
|
-
| "max"
|
|
59
|
-
| "step"
|
|
60
|
-
| "size"
|
|
61
|
-
> {
|
|
62
|
-
value: number;
|
|
63
|
-
onChange: (value: number) => void;
|
|
64
|
-
label: string;
|
|
65
|
-
min?: number;
|
|
66
|
-
max?: number;
|
|
67
|
-
step?: number;
|
|
68
|
-
description?: string;
|
|
69
|
-
/** Provides a localized, spoken description of the current value. */
|
|
70
|
-
formatValue?: (value: number) => string;
|
|
71
|
-
/** Track height, thumb size and label/description text scale. @default "md" */
|
|
72
|
-
size?: SliderSize;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Native keyboard, touch and pointer behavior with Passui's control treatment. */
|
|
76
|
-
export function Slider({
|
|
77
|
-
value,
|
|
78
|
-
onChange,
|
|
79
|
-
label,
|
|
80
|
-
min = 0,
|
|
81
|
-
max = 100,
|
|
82
|
-
step = 1,
|
|
83
|
-
description,
|
|
84
|
-
formatValue,
|
|
85
|
-
size = "md",
|
|
86
|
-
id: suppliedId,
|
|
87
|
-
className,
|
|
88
|
-
disabled,
|
|
89
|
-
...props
|
|
90
|
-
}: SliderProps) {
|
|
91
|
-
const generatedId = useId();
|
|
92
|
-
const id = suppliedId ?? generatedId;
|
|
93
|
-
const upper = Math.max(min, max);
|
|
94
|
-
const current = clampRange(value, min, upper);
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<div
|
|
98
|
-
className={cn("flex min-w-0 flex-col gap-2", disabled && "opacity-45")}
|
|
99
|
-
>
|
|
100
|
-
<label htmlFor={id} className={labelSizes[size]}>
|
|
101
|
-
{label}
|
|
102
|
-
</label>
|
|
103
|
-
<input
|
|
104
|
-
{...props}
|
|
105
|
-
id={id}
|
|
106
|
-
type="range"
|
|
107
|
-
min={min}
|
|
108
|
-
max={upper}
|
|
109
|
-
step={step > 0 ? step : 1}
|
|
110
|
-
value={current}
|
|
111
|
-
disabled={disabled || upper === min}
|
|
112
|
-
aria-valuetext={formatValue?.(current)}
|
|
113
|
-
aria-describedby={description ? `${id}-description` : undefined}
|
|
114
|
-
onChange={(event) => onChange(Number(event.currentTarget.value))}
|
|
115
|
-
className={cn(
|
|
116
|
-
"accent-accent w-full min-w-0 cursor-pointer appearance-none bg-transparent",
|
|
117
|
-
inputHeights[size],
|
|
118
|
-
"focus-visible:outline-accent-text focus-visible:rounded-lg focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
119
|
-
webkitTrack[size],
|
|
120
|
-
webkitThumb[size],
|
|
121
|
-
mozTrack[size],
|
|
122
|
-
mozProgress[size],
|
|
123
|
-
mozThumb[size],
|
|
124
|
-
className,
|
|
125
|
-
)}
|
|
126
|
-
/>
|
|
127
|
-
{description && (
|
|
128
|
-
<p id={`${id}-description`} className={descriptionSizes[size]}>
|
|
129
|
-
{description}
|
|
130
|
-
</p>
|
|
131
|
-
)}
|
|
132
|
-
</div>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { clampRange } from "../../lib/range-value";
|
|
2
|
-
|
|
3
|
-
export interface LiquidState {
|
|
4
|
-
fill: number;
|
|
5
|
-
velocity: number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/** Bencho's frame-normalized liquid spring. See THIRD_PARTY_NOTICES.md. */
|
|
9
|
-
export function stepLiquid(
|
|
10
|
-
state: LiquidState,
|
|
11
|
-
target: number,
|
|
12
|
-
viscosity: number,
|
|
13
|
-
dt: number,
|
|
14
|
-
): LiquidState {
|
|
15
|
-
const soft = clampRange(viscosity, 0, 100) / 100;
|
|
16
|
-
target = clampRange(target, 0, 100);
|
|
17
|
-
dt = clampRange(dt, 0, 2.5);
|
|
18
|
-
if (soft === 0) {
|
|
19
|
-
/* 0 is an ordinary slider and has to be exactly that,
|
|
20
|
-
not a very stiff spring that still rings. */
|
|
21
|
-
return { fill: target, velocity: 0 };
|
|
22
|
-
}
|
|
23
|
-
/* Stiffness falls and damping rises together: thin liquid is slow to
|
|
24
|
-
answer and slow to forget, which is why these are one knob. */
|
|
25
|
-
const stiff = 0.34 - soft * 0.29;
|
|
26
|
-
const damp = 0.74 + soft * 0.22;
|
|
27
|
-
let velocity =
|
|
28
|
-
(state.velocity + (target - state.fill) * stiff * dt) * damp ** dt;
|
|
29
|
-
let fill = state.fill + velocity * dt;
|
|
30
|
-
/* The end stop is a wall, and a wall gives some back. Without this
|
|
31
|
-
the overshoot is swallowed exactly where you are looking at it. */
|
|
32
|
-
if (fill > 100) {
|
|
33
|
-
fill = 100;
|
|
34
|
-
velocity = -velocity * 0.42;
|
|
35
|
-
}
|
|
36
|
-
if (fill < 0) {
|
|
37
|
-
fill = 0;
|
|
38
|
-
velocity = -velocity * 0.42;
|
|
39
|
-
}
|
|
40
|
-
if (Math.abs(target - fill) < 0.02 && Math.abs(velocity) < 0.02)
|
|
41
|
-
return { fill: target, velocity: 0 };
|
|
42
|
-
return { fill, velocity };
|
|
43
|
-
}
|