@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,294 +0,0 @@
|
|
|
1
|
-
// Adapted from Bencho. See THIRD_PARTY_NOTICES.md for the MIT notice.
|
|
2
|
-
import { type CSSProperties, useEffect, useRef } from "react";
|
|
3
|
-
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
4
|
-
import { cn } from "../../lib/class-names";
|
|
5
|
-
import { clampRange as clamp } from "../../lib/range-value";
|
|
6
|
-
import { stepLiquid } from "./liquid-step";
|
|
7
|
-
|
|
8
|
-
export type SloshSliderSize = "sm" | "md" | "lg";
|
|
9
|
-
|
|
10
|
-
export interface SloshSliderProps {
|
|
11
|
-
label: string;
|
|
12
|
-
value?: number;
|
|
13
|
-
defaultValue?: number;
|
|
14
|
-
onChange?: (value: number) => void;
|
|
15
|
-
/** 0 is rigid; 100 is loose liquid. @default 15 */
|
|
16
|
-
viscosity?: number;
|
|
17
|
-
/** How far the handle coasts after release, 0–100. @default 55 */
|
|
18
|
-
momentum?: number;
|
|
19
|
-
/** Lean of the liquid's leading edge, 0–100. @default 45 */
|
|
20
|
-
tilt?: number;
|
|
21
|
-
/** Track corner, from square to a pill, 0–20. @default 20 */
|
|
22
|
-
corner?: number;
|
|
23
|
-
/** Track height and knob scale. @default "md" */
|
|
24
|
-
size?: SloshSliderSize;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
className?: string;
|
|
27
|
-
formatValue?: (value: number) => string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* A slider whose value has mass.
|
|
31
|
-
|
|
32
|
-
The handle is rigid — it is under your finger and anything under a
|
|
33
|
-
finger that lags it is broken. The FILL is a second spring behind it,
|
|
34
|
-
softer and barely damped, so a fast drag throws it past the handle,
|
|
35
|
-
into the end stop, and rocks it back before it settles.
|
|
36
|
-
|
|
37
|
-
The tilt is what sells it as liquid. A bar that lags is a laggy bar;
|
|
38
|
-
a bar whose leading edge leans has a meniscus. Same lag, different object.
|
|
39
|
-
|
|
40
|
-
The loop writes geometry directly and parks as soon as it rests.
|
|
41
|
-
React receives only changed integer values for the application's state. */
|
|
42
|
-
export function SloshSlider({
|
|
43
|
-
label,
|
|
44
|
-
value,
|
|
45
|
-
defaultValue = 62,
|
|
46
|
-
onChange,
|
|
47
|
-
viscosity = 15,
|
|
48
|
-
momentum = 55,
|
|
49
|
-
tilt = 45,
|
|
50
|
-
corner = 20,
|
|
51
|
-
size = "md",
|
|
52
|
-
disabled = false,
|
|
53
|
-
className,
|
|
54
|
-
formatValue,
|
|
55
|
-
}: SloshSliderProps) {
|
|
56
|
-
const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
57
|
-
const track = useRef<HTMLDivElement>(null);
|
|
58
|
-
const fillEl = useRef<HTMLDivElement>(null);
|
|
59
|
-
const knobEl = useRef<HTMLDivElement>(null);
|
|
60
|
-
const initial = clamp(value ?? defaultValue, 0, 100);
|
|
61
|
-
const state = useRef({
|
|
62
|
-
value: initial,
|
|
63
|
-
handleVelocity: 0,
|
|
64
|
-
fill: initial,
|
|
65
|
-
velocity: 0,
|
|
66
|
-
held: false,
|
|
67
|
-
raf: 0,
|
|
68
|
-
previous: 0,
|
|
69
|
-
last: { value: initial, time: 0 },
|
|
70
|
-
notified: Math.round(initial),
|
|
71
|
-
});
|
|
72
|
-
const settings = useRef({
|
|
73
|
-
viscosity,
|
|
74
|
-
momentum,
|
|
75
|
-
tilt,
|
|
76
|
-
reduced,
|
|
77
|
-
onChange,
|
|
78
|
-
formatValue,
|
|
79
|
-
});
|
|
80
|
-
settings.current = {
|
|
81
|
-
viscosity,
|
|
82
|
-
momentum,
|
|
83
|
-
tilt,
|
|
84
|
-
reduced,
|
|
85
|
-
onChange,
|
|
86
|
-
formatValue,
|
|
87
|
-
};
|
|
88
|
-
const run = useRef<() => void>(() => {});
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
const s = state.current;
|
|
92
|
-
const paint = () => {
|
|
93
|
-
if (!track.current || !fillEl.current || !knobEl.current) return;
|
|
94
|
-
fillEl.current.style.width = `${s.fill.toFixed(2)}%`;
|
|
95
|
-
knobEl.current.style.insetInlineStart = `${s.value.toFixed(2)}%`;
|
|
96
|
-
/* Proportional to how fast the fill is actually moving: upright
|
|
97
|
-
at rest, so it cannot be decoration when nothing travels. */
|
|
98
|
-
const lean = settings.current.reduced
|
|
99
|
-
? 0
|
|
100
|
-
: clamp(
|
|
101
|
-
(clamp(settings.current.tilt, 0, 100) / 100) * s.velocity * 3,
|
|
102
|
-
-20,
|
|
103
|
-
20,
|
|
104
|
-
);
|
|
105
|
-
fillEl.current.style.setProperty("--slosh-lean", `${lean.toFixed(2)}px`);
|
|
106
|
-
const next = Math.round(s.value);
|
|
107
|
-
track.current.setAttribute("aria-valuenow", String(next));
|
|
108
|
-
const spoken = settings.current.formatValue?.(next);
|
|
109
|
-
if (spoken) track.current.setAttribute("aria-valuetext", spoken);
|
|
110
|
-
else track.current.removeAttribute("aria-valuetext");
|
|
111
|
-
if (s.notified !== next) {
|
|
112
|
-
s.notified = next;
|
|
113
|
-
settings.current.onChange?.(next);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const tick = (time: number) => {
|
|
117
|
-
const dt = s.previous ? clamp((time - s.previous) / 16.67, 0, 2.5) : 1;
|
|
118
|
-
s.previous = time;
|
|
119
|
-
const knobs = settings.current;
|
|
120
|
-
/* Friction is per frame, raised to dt: a dropped frame must
|
|
121
|
-
not double the deceleration. The release is a throw, not a stop. */
|
|
122
|
-
if (!s.held && s.handleVelocity) {
|
|
123
|
-
s.value += s.handleVelocity * dt;
|
|
124
|
-
s.handleVelocity *=
|
|
125
|
-
(0.86 + (clamp(knobs.momentum, 0, 100) / 100) * 0.115) ** dt;
|
|
126
|
-
if (s.value <= 0 || s.value >= 100) {
|
|
127
|
-
s.value = clamp(s.value, 0, 100);
|
|
128
|
-
s.handleVelocity = 0;
|
|
129
|
-
}
|
|
130
|
-
if (Math.abs(s.handleVelocity) < 0.01) s.handleVelocity = 0;
|
|
131
|
-
}
|
|
132
|
-
const next = stepLiquid(
|
|
133
|
-
s,
|
|
134
|
-
s.value,
|
|
135
|
-
knobs.reduced ? 0 : knobs.viscosity,
|
|
136
|
-
dt,
|
|
137
|
-
);
|
|
138
|
-
s.fill = next.fill;
|
|
139
|
-
s.velocity = next.velocity;
|
|
140
|
-
paint();
|
|
141
|
-
if (
|
|
142
|
-
!s.handleVelocity &&
|
|
143
|
-
!s.velocity &&
|
|
144
|
-
Math.abs(s.fill - s.value) < 0.02
|
|
145
|
-
) {
|
|
146
|
-
s.raf = 0;
|
|
147
|
-
s.previous = 0;
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
s.raf = requestAnimationFrame(tick);
|
|
151
|
-
};
|
|
152
|
-
run.current = () => {
|
|
153
|
-
// The handle paints on the input event; it never waits for the fill.
|
|
154
|
-
paint();
|
|
155
|
-
if (!s.raf) s.raf = requestAnimationFrame(tick);
|
|
156
|
-
};
|
|
157
|
-
paint();
|
|
158
|
-
return () => {
|
|
159
|
-
cancelAnimationFrame(s.raf);
|
|
160
|
-
s.raf = 0;
|
|
161
|
-
s.previous = 0;
|
|
162
|
-
};
|
|
163
|
-
}, []);
|
|
164
|
-
|
|
165
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: Motion settings can wake a parked loop without changing its value.
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
const s = state.current;
|
|
168
|
-
if (
|
|
169
|
-
value !== undefined &&
|
|
170
|
-
Math.round(clamp(value, 0, 100)) !== s.notified
|
|
171
|
-
) {
|
|
172
|
-
s.value = clamp(value, 0, 100);
|
|
173
|
-
s.notified = Math.round(s.value);
|
|
174
|
-
s.handleVelocity = 0;
|
|
175
|
-
}
|
|
176
|
-
if (reduced || disabled) {
|
|
177
|
-
s.handleVelocity = 0;
|
|
178
|
-
s.held = false;
|
|
179
|
-
}
|
|
180
|
-
run.current();
|
|
181
|
-
}, [value, reduced, disabled, viscosity, tilt, formatValue]);
|
|
182
|
-
|
|
183
|
-
const readAt = (clientX: number) => {
|
|
184
|
-
const t = track.current;
|
|
185
|
-
if (!t) return 0;
|
|
186
|
-
const box = t.getBoundingClientRect();
|
|
187
|
-
const fraction = box.width ? (clientX - box.left) / box.width : 0;
|
|
188
|
-
return clamp(
|
|
189
|
-
(getComputedStyle(t).direction === "rtl" ? 1 - fraction : fraction) * 100,
|
|
190
|
-
0,
|
|
191
|
-
100,
|
|
192
|
-
);
|
|
193
|
-
};
|
|
194
|
-
const release = (cancelled = false) => {
|
|
195
|
-
const s = state.current;
|
|
196
|
-
if (!s.held) return;
|
|
197
|
-
s.held = false;
|
|
198
|
-
/* Leaves along its measured velocity, capped so a full-track flick
|
|
199
|
-
does not simply pin it. A cancelled gesture never throws. */
|
|
200
|
-
s.handleVelocity =
|
|
201
|
-
cancelled || reduced ? 0 : clamp(s.handleVelocity, -6, 6);
|
|
202
|
-
if (performance.now() - s.last.time > 100) s.handleVelocity = 0;
|
|
203
|
-
run.current();
|
|
204
|
-
};
|
|
205
|
-
return (
|
|
206
|
-
<div
|
|
207
|
-
className={cn(
|
|
208
|
-
"passui-slosh-slider not-typeset",
|
|
209
|
-
disabled && "opacity-40",
|
|
210
|
-
className,
|
|
211
|
-
)}
|
|
212
|
-
style={{ "--slosh-radius": `${clamp(corner, 0, 20)}px` } as CSSProperties}
|
|
213
|
-
data-size={size}
|
|
214
|
-
>
|
|
215
|
-
{/* Nothing but the track: the liquid is the value's motion, not a
|
|
216
|
-
second numeric readout that lags and overshoots beside it. */}
|
|
217
|
-
<div
|
|
218
|
-
ref={track}
|
|
219
|
-
className="passui-slosh-track"
|
|
220
|
-
role="slider"
|
|
221
|
-
tabIndex={disabled ? -1 : 0}
|
|
222
|
-
aria-label={label}
|
|
223
|
-
aria-disabled={disabled || undefined}
|
|
224
|
-
aria-valuemin={0}
|
|
225
|
-
aria-valuemax={100}
|
|
226
|
-
aria-valuenow={Math.round(initial)}
|
|
227
|
-
aria-valuetext={formatValue?.(Math.round(initial))}
|
|
228
|
-
onPointerDown={(event) => {
|
|
229
|
-
if (disabled || event.button !== 0) return;
|
|
230
|
-
event.currentTarget.focus();
|
|
231
|
-
event.currentTarget.setPointerCapture(event.pointerId);
|
|
232
|
-
const s = state.current;
|
|
233
|
-
s.held = true;
|
|
234
|
-
s.handleVelocity = 0;
|
|
235
|
-
s.value = readAt(event.clientX);
|
|
236
|
-
s.last = { value: s.value, time: performance.now() };
|
|
237
|
-
run.current();
|
|
238
|
-
}}
|
|
239
|
-
onPointerMove={(event) => {
|
|
240
|
-
const s = state.current;
|
|
241
|
-
if (!s.held || disabled) return;
|
|
242
|
-
const next = readAt(event.clientX);
|
|
243
|
-
const now = performance.now();
|
|
244
|
-
/* Per frame, not per ms: the loop's release velocity must
|
|
245
|
-
use the same unit as the spring. */
|
|
246
|
-
s.handleVelocity =
|
|
247
|
-
((next - s.last.value) / Math.max(1, now - s.last.time)) * 16.67;
|
|
248
|
-
s.last = { value: next, time: now };
|
|
249
|
-
s.value = next;
|
|
250
|
-
run.current();
|
|
251
|
-
}}
|
|
252
|
-
onPointerUp={() => release()}
|
|
253
|
-
onPointerCancel={() => release(true)}
|
|
254
|
-
onLostPointerCapture={() => release(true)}
|
|
255
|
-
onKeyDown={(event) => {
|
|
256
|
-
if (disabled) return;
|
|
257
|
-
const s = state.current;
|
|
258
|
-
const step = event.shiftKey ? 10 : 2;
|
|
259
|
-
const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
|
|
260
|
-
const next =
|
|
261
|
-
event.key === "ArrowUp" ||
|
|
262
|
-
event.key === (rtl ? "ArrowLeft" : "ArrowRight")
|
|
263
|
-
? s.value + step
|
|
264
|
-
: event.key === "ArrowDown" ||
|
|
265
|
-
event.key === (rtl ? "ArrowRight" : "ArrowLeft")
|
|
266
|
-
? s.value - step
|
|
267
|
-
: event.key === "Home"
|
|
268
|
-
? 0
|
|
269
|
-
: event.key === "End"
|
|
270
|
-
? 100
|
|
271
|
-
: null;
|
|
272
|
-
if (next === null) return;
|
|
273
|
-
event.preventDefault();
|
|
274
|
-
s.handleVelocity = 0;
|
|
275
|
-
s.value = clamp(next, 0, 100);
|
|
276
|
-
run.current();
|
|
277
|
-
}}
|
|
278
|
-
>
|
|
279
|
-
<div
|
|
280
|
-
aria-hidden="true"
|
|
281
|
-
ref={fillEl}
|
|
282
|
-
className="passui-slosh-fill"
|
|
283
|
-
style={{ width: `${initial}%` }}
|
|
284
|
-
/>
|
|
285
|
-
<div
|
|
286
|
-
aria-hidden="true"
|
|
287
|
-
ref={knobEl}
|
|
288
|
-
className="passui-slosh-knob"
|
|
289
|
-
style={{ insetInlineStart: `${initial}%` }}
|
|
290
|
-
/>
|
|
291
|
-
</div>
|
|
292
|
-
</div>
|
|
293
|
-
);
|
|
294
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./stat-tile";
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
|
|
4
|
-
export type StatTileTone = "critical";
|
|
5
|
-
export type StatTileSize = "sm" | "md" | "lg";
|
|
6
|
-
|
|
7
|
-
const tileSizes: Record<
|
|
8
|
-
StatTileSize,
|
|
9
|
-
{ padding: string; valueText: string; labelText: string }
|
|
10
|
-
> = {
|
|
11
|
-
sm: { padding: "p-3", valueText: "text-title3", labelText: "text-caption" },
|
|
12
|
-
md: { padding: "p-4", valueText: "text-title1", labelText: "text-footnote" },
|
|
13
|
-
lg: {
|
|
14
|
-
padding: "p-5",
|
|
15
|
-
valueText: "text-title",
|
|
16
|
-
labelText: "text-subheadline",
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export interface StatTileProps {
|
|
21
|
-
label: string;
|
|
22
|
-
value: number;
|
|
23
|
-
/** A quiet line under the number, like "3 signed in now". */
|
|
24
|
-
caption?: ReactNode;
|
|
25
|
-
/** Turns the number red once it's above zero. */
|
|
26
|
-
tone?: StatTileTone;
|
|
27
|
-
/** Makes the tile a toggle, e.g. a filter. */
|
|
28
|
-
onClick?: () => void;
|
|
29
|
-
active?: boolean;
|
|
30
|
-
/** Custom classes for the tile container. */
|
|
31
|
-
className?: string;
|
|
32
|
-
/** Tile padding and number scale. @default "md" */
|
|
33
|
-
size?: StatTileSize;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** One number with its label, optionally a toggle. */
|
|
37
|
-
export function StatTile({
|
|
38
|
-
label,
|
|
39
|
-
value,
|
|
40
|
-
caption,
|
|
41
|
-
tone,
|
|
42
|
-
onClick,
|
|
43
|
-
active = false,
|
|
44
|
-
className,
|
|
45
|
-
size = "md",
|
|
46
|
-
}: StatTileProps) {
|
|
47
|
-
const dims = tileSizes[size];
|
|
48
|
-
const body = (
|
|
49
|
-
<>
|
|
50
|
-
<span className={cn(dims.labelText, "text-label-secondary")}>
|
|
51
|
-
{label}
|
|
52
|
-
</span>
|
|
53
|
-
<span
|
|
54
|
-
className={cn(
|
|
55
|
-
"font-semibold tabular-nums",
|
|
56
|
-
dims.valueText,
|
|
57
|
-
tone === "critical" && value > 0 && "text-danger",
|
|
58
|
-
)}
|
|
59
|
-
>
|
|
60
|
-
{value.toLocaleString("en-US")}
|
|
61
|
-
</span>
|
|
62
|
-
{caption && (
|
|
63
|
-
<span className={cn(dims.labelText, "text-label-tertiary")}>
|
|
64
|
-
{caption}
|
|
65
|
-
</span>
|
|
66
|
-
)}
|
|
67
|
-
</>
|
|
68
|
-
);
|
|
69
|
-
const tileClass = cn(
|
|
70
|
-
"border-separator/35 bg-elevated flex min-w-0 flex-col gap-2 rounded-2xl border text-left shadow-xs",
|
|
71
|
-
dims.padding,
|
|
72
|
-
className,
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
if (!onClick) return <div className={tileClass}>{body}</div>;
|
|
76
|
-
return (
|
|
77
|
-
<button
|
|
78
|
-
type="button"
|
|
79
|
-
aria-pressed={active}
|
|
80
|
-
onClick={onClick}
|
|
81
|
-
className={cn(
|
|
82
|
-
tileClass,
|
|
83
|
-
"hover:bg-fill/60 ring-1 ring-transparent transition-colors",
|
|
84
|
-
active && "bg-fill/70 ring-label/15",
|
|
85
|
-
)}
|
|
86
|
-
>
|
|
87
|
-
{body}
|
|
88
|
-
</button>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
|
|
4
|
-
const dots = {
|
|
5
|
-
saved: "bg-success",
|
|
6
|
-
syncing: "bg-warning animate-pulse",
|
|
7
|
-
offline: "bg-label-tertiary",
|
|
8
|
-
} as const;
|
|
9
|
-
|
|
10
|
-
export type StatusIndicatorState = keyof typeof dots;
|
|
11
|
-
export type StatusIndicatorSize = "sm" | "md";
|
|
12
|
-
|
|
13
|
-
const dotSizes: Record<StatusIndicatorSize, string> = {
|
|
14
|
-
sm: "size-[6px]",
|
|
15
|
-
md: "size-[7px]",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const textSizes: Record<StatusIndicatorSize, string> = {
|
|
19
|
-
sm: "text-caption",
|
|
20
|
-
md: "text-footnote",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export interface StatusIndicatorProps extends HTMLAttributes<HTMLSpanElement> {
|
|
24
|
-
/** Visual treatment of the status dot. */
|
|
25
|
-
state: StatusIndicatorState;
|
|
26
|
-
children: ReactNode;
|
|
27
|
-
/** Dot diameter and text scale. @default "md" */
|
|
28
|
-
size?: StatusIndicatorSize;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function StatusIndicator({
|
|
32
|
-
state,
|
|
33
|
-
children,
|
|
34
|
-
size = "md",
|
|
35
|
-
className,
|
|
36
|
-
...props
|
|
37
|
-
}: StatusIndicatorProps) {
|
|
38
|
-
return (
|
|
39
|
-
<span
|
|
40
|
-
className={cn(
|
|
41
|
-
"text-label-tertiary flex items-center gap-1.5",
|
|
42
|
-
textSizes[size],
|
|
43
|
-
className,
|
|
44
|
-
)}
|
|
45
|
-
{...props}
|
|
46
|
-
>
|
|
47
|
-
<span
|
|
48
|
-
aria-hidden="true"
|
|
49
|
-
className={cn(dotSizes[size], "rounded-full", dots[state])}
|
|
50
|
-
/>
|
|
51
|
-
{children}
|
|
52
|
-
</span>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
3
|
-
|
|
4
|
-
/** Counts at a place retain carries: the tens column of 1284 targets 128. */
|
|
5
|
-
export function digitAt(count: number) {
|
|
6
|
-
return ((Math.floor(count) % 10) + 10) % 10;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function advanceDigit(
|
|
10
|
-
position: number,
|
|
11
|
-
velocity: number,
|
|
12
|
-
target: number,
|
|
13
|
-
frames: number,
|
|
14
|
-
) {
|
|
15
|
-
const nextVelocity =
|
|
16
|
-
(velocity + (target - position) * 0.16 * frames) * 0.7 ** frames;
|
|
17
|
-
return { position: position + nextVelocity * frames, velocity: nextVelocity };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Three recycled cells keep the strip continuous through either side of zero. */
|
|
21
|
-
export function RollingDigit({
|
|
22
|
-
count,
|
|
23
|
-
place,
|
|
24
|
-
}: {
|
|
25
|
-
count: number;
|
|
26
|
-
place: number;
|
|
27
|
-
}) {
|
|
28
|
-
const strip = useRef<HTMLSpanElement>(null);
|
|
29
|
-
const state = useRef({ position: count, velocity: 0 });
|
|
30
|
-
const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
let frame = 0;
|
|
33
|
-
let previous = 0;
|
|
34
|
-
let due = 0;
|
|
35
|
-
const paint = (position: number, velocity: number) => {
|
|
36
|
-
const node = strip.current;
|
|
37
|
-
if (!node) return;
|
|
38
|
-
const base = Math.floor(position);
|
|
39
|
-
for (let index = 0; index < node.children.length; index++) {
|
|
40
|
-
(node.children[index] as HTMLElement).textContent = String(
|
|
41
|
-
digitAt(base + index - 1),
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
node.style.transform = `translateY(${(-(position - base + 1) * 100) / 3}%)`;
|
|
45
|
-
node.style.filter = `blur(${Math.min(2, Math.abs(velocity) * 1.4)}px)`;
|
|
46
|
-
};
|
|
47
|
-
if (reduced) {
|
|
48
|
-
state.current = { position: count, velocity: 0 };
|
|
49
|
-
paint(count, 0);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const tick = (now: number) => {
|
|
53
|
-
if (!due) due = now + place * 28;
|
|
54
|
-
const frames = previous ? Math.min((now - previous) / (1000 / 60), 2) : 1;
|
|
55
|
-
previous = now;
|
|
56
|
-
if (now >= due) {
|
|
57
|
-
state.current = advanceDigit(
|
|
58
|
-
state.current.position,
|
|
59
|
-
state.current.velocity,
|
|
60
|
-
count,
|
|
61
|
-
frames,
|
|
62
|
-
);
|
|
63
|
-
if (
|
|
64
|
-
Math.abs(count - state.current.position) < 0.002 &&
|
|
65
|
-
Math.abs(state.current.velocity) < 0.002
|
|
66
|
-
) {
|
|
67
|
-
state.current = { position: count, velocity: 0 };
|
|
68
|
-
paint(count, 0);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
paint(state.current.position, state.current.velocity);
|
|
72
|
-
}
|
|
73
|
-
frame = requestAnimationFrame(tick);
|
|
74
|
-
};
|
|
75
|
-
frame = requestAnimationFrame(tick);
|
|
76
|
-
return () => cancelAnimationFrame(frame);
|
|
77
|
-
}, [count, place, reduced]);
|
|
78
|
-
return (
|
|
79
|
-
<span className="relative inline-block h-[1.5em] w-[1ch] overflow-hidden align-middle">
|
|
80
|
-
<span
|
|
81
|
-
ref={strip}
|
|
82
|
-
className="absolute inset-x-0 top-0 flex flex-col leading-[1.5em]"
|
|
83
|
-
style={{ transform: "translateY(-33.333333%)" }}
|
|
84
|
-
>
|
|
85
|
-
<span>{digitAt(count - 1)}</span>
|
|
86
|
-
<span>{digitAt(count)}</span>
|
|
87
|
-
<span>{digitAt(count + 1)}</span>
|
|
88
|
-
</span>
|
|
89
|
-
</span>
|
|
90
|
-
);
|
|
91
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { useId } from "react";
|
|
2
|
-
import { Button, type ButtonSize } from "../button/button";
|
|
3
|
-
import { cn } from "../../lib/class-names";
|
|
4
|
-
import { clampRange, stepRange } from "../../lib/range-value";
|
|
5
|
-
import { RollingDigit } from "./rolling-digit";
|
|
6
|
-
|
|
7
|
-
export type StepperSize = "sm" | "md" | "lg";
|
|
8
|
-
|
|
9
|
-
const labelText: Record<StepperSize, string> = {
|
|
10
|
-
sm: "min-w-0 text-footnote text-label",
|
|
11
|
-
md: "min-w-0 text-subheadline text-label",
|
|
12
|
-
lg: "min-w-0 text-body text-label",
|
|
13
|
-
};
|
|
14
|
-
const outputText: Record<StepperSize, string> = {
|
|
15
|
-
sm: "text-footnote tabular-nums text-label",
|
|
16
|
-
md: "text-subheadline tabular-nums text-label",
|
|
17
|
-
lg: "text-body tabular-nums text-label",
|
|
18
|
-
};
|
|
19
|
-
const buttonSizes: Record<StepperSize, { size: ButtonSize; cls: string }> = {
|
|
20
|
-
sm: {
|
|
21
|
-
size: "icon-sm",
|
|
22
|
-
cls: "size-7 rounded-none text-subheadline text-accent-text [@media(pointer:coarse)]:size-10",
|
|
23
|
-
},
|
|
24
|
-
md: {
|
|
25
|
-
size: "icon",
|
|
26
|
-
cls: "size-8 rounded-none text-title3 text-accent-text [@media(pointer:coarse)]:size-11",
|
|
27
|
-
},
|
|
28
|
-
lg: {
|
|
29
|
-
size: "icon-lg",
|
|
30
|
-
cls: "size-9 rounded-none text-title2 text-accent-text [@media(pointer:coarse)]:size-12",
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export interface StepperProps {
|
|
35
|
-
value: number;
|
|
36
|
-
onChange: (value: number) => void;
|
|
37
|
-
label: string;
|
|
38
|
-
/** Localized accessible names for each action. */
|
|
39
|
-
labels: { decrement: string; increment: string };
|
|
40
|
-
min?: number;
|
|
41
|
-
max?: number;
|
|
42
|
-
step?: number;
|
|
43
|
-
disabled?: boolean;
|
|
44
|
-
className?: string;
|
|
45
|
-
/** Formats the displayed value. */
|
|
46
|
-
formatValue?: (value: number) => string;
|
|
47
|
-
/** Label, output and +/- button scale. @default "md" */
|
|
48
|
-
size?: StepperSize;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Discrete increments with disabled boundary actions and a spoken value. */
|
|
52
|
-
export function Stepper({
|
|
53
|
-
value,
|
|
54
|
-
onChange,
|
|
55
|
-
label,
|
|
56
|
-
labels,
|
|
57
|
-
min = 0,
|
|
58
|
-
max = 100,
|
|
59
|
-
step = 1,
|
|
60
|
-
disabled = false,
|
|
61
|
-
className,
|
|
62
|
-
formatValue,
|
|
63
|
-
size = "md",
|
|
64
|
-
}: StepperProps) {
|
|
65
|
-
const id = useId();
|
|
66
|
-
const upper = Math.max(min, max);
|
|
67
|
-
const current = clampRange(value, min, upper);
|
|
68
|
-
const decrement = stepRange(current, -1, min, upper, step > 0 ? step : 1);
|
|
69
|
-
const increment = stepRange(current, 1, min, upper, step > 0 ? step : 1);
|
|
70
|
-
const displayed = formatValue?.(current) ?? String(current);
|
|
71
|
-
const digits = displayed.replace(/[^0-9]/g, "");
|
|
72
|
-
let digitIndex = 0;
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<div
|
|
76
|
-
className={cn(
|
|
77
|
-
"flex min-w-0 items-center justify-between gap-3",
|
|
78
|
-
className,
|
|
79
|
-
)}
|
|
80
|
-
>
|
|
81
|
-
<span id={id} className={labelText[size]}>
|
|
82
|
-
{label}
|
|
83
|
-
</span>
|
|
84
|
-
<div className="flex shrink-0 items-center gap-3">
|
|
85
|
-
<output
|
|
86
|
-
aria-live="polite"
|
|
87
|
-
aria-labelledby={id}
|
|
88
|
-
className={outputText[size]}
|
|
89
|
-
>
|
|
90
|
-
<span aria-hidden="true" className="inline-flex items-center">
|
|
91
|
-
{Array.from(displayed).map((character) => {
|
|
92
|
-
if (!/[0-9]/.test(character))
|
|
93
|
-
return <span key={`sep-${character}`}>{character}</span>;
|
|
94
|
-
const prefix = digits.slice(0, ++digitIndex);
|
|
95
|
-
const place = digits.length - digitIndex;
|
|
96
|
-
return (
|
|
97
|
-
<RollingDigit
|
|
98
|
-
key={`place-${place}`}
|
|
99
|
-
count={Number(prefix)}
|
|
100
|
-
place={place}
|
|
101
|
-
/>
|
|
102
|
-
);
|
|
103
|
-
})}
|
|
104
|
-
</span>
|
|
105
|
-
<span className="sr-only">{displayed}</span>
|
|
106
|
-
</output>
|
|
107
|
-
<div className="divide-separator bg-fill flex items-center divide-x overflow-hidden rounded-lg">
|
|
108
|
-
<Button
|
|
109
|
-
type="button"
|
|
110
|
-
variant="ghost"
|
|
111
|
-
size={buttonSizes[size].size}
|
|
112
|
-
aria-label={labels.decrement}
|
|
113
|
-
aria-describedby={id}
|
|
114
|
-
disabled={disabled || decrement === current}
|
|
115
|
-
onClick={() => onChange(decrement)}
|
|
116
|
-
className={buttonSizes[size].cls}
|
|
117
|
-
>
|
|
118
|
-
−
|
|
119
|
-
</Button>
|
|
120
|
-
<Button
|
|
121
|
-
type="button"
|
|
122
|
-
variant="ghost"
|
|
123
|
-
size={buttonSizes[size].size}
|
|
124
|
-
aria-label={labels.increment}
|
|
125
|
-
aria-describedby={id}
|
|
126
|
-
disabled={disabled || increment === current}
|
|
127
|
-
onClick={() => onChange(increment)}
|
|
128
|
-
className={buttonSizes[size].cls}
|
|
129
|
-
>
|
|
130
|
-
+
|
|
131
|
-
</Button>
|
|
132
|
-
</div>
|
|
133
|
-
</div>
|
|
134
|
-
</div>
|
|
135
|
-
);
|
|
136
|
-
}
|