@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
package/dist/sheet.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "./lib/cx.js";
|
|
3
|
+
import { Portal } from "./lib/portal.js";
|
|
4
|
+
import { usePresence } from "./lib/presence.js";
|
|
5
|
+
import { mergeProps, renderPart } from "./lib/render.js";
|
|
6
|
+
import { useSwipeTouchAction } from "./lib/swipe-touch-action.js";
|
|
7
|
+
import { useVisualViewportVars } from "./lib/visual-viewport.js";
|
|
8
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
9
|
+
import { createContext, useContext, useId, useRef } from "react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import * as drawer from "@zag-js/drawer";
|
|
12
|
+
// src/components/sheet.tsx
|
|
13
|
+
const Context = createContext(null);
|
|
14
|
+
function useSheet() {
|
|
15
|
+
const ctx = useContext(Context);
|
|
16
|
+
if (!ctx) throw new Error("Sheet parts must be used inside <Sheet>.");
|
|
17
|
+
return ctx;
|
|
18
|
+
}
|
|
19
|
+
/** Physical side to the direction that dismisses it, honouring right to left. */
|
|
20
|
+
function swipeToDismiss(side, rtl) {
|
|
21
|
+
if (side === "top") return "up";
|
|
22
|
+
if (side === "bottom") return "down";
|
|
23
|
+
return side === "right" !== rtl ? "end" : "start";
|
|
24
|
+
}
|
|
25
|
+
/** A panel that slides in from any edge and swipes away. Renders no element of its own. */
|
|
26
|
+
function Sheet({ children, side = "right", ...props }) {
|
|
27
|
+
const id = useId();
|
|
28
|
+
const service = useMachine(drawer.machine, {
|
|
29
|
+
id,
|
|
30
|
+
swipeDirection: swipeToDismiss(side, props.dir === "rtl"),
|
|
31
|
+
...props
|
|
32
|
+
});
|
|
33
|
+
const api = drawer.connect(service, normalizeProps);
|
|
34
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
35
|
+
value: {
|
|
36
|
+
api,
|
|
37
|
+
side
|
|
38
|
+
},
|
|
39
|
+
children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function SheetTrigger({ render, ...props }) {
|
|
43
|
+
const { api } = useSheet();
|
|
44
|
+
return renderPart("button", mergeProps({
|
|
45
|
+
...api.getTriggerProps(),
|
|
46
|
+
"data-slot": "sheet-trigger"
|
|
47
|
+
}, props), render);
|
|
48
|
+
}
|
|
49
|
+
function SheetClose({ render, ...props }) {
|
|
50
|
+
const { api } = useSheet();
|
|
51
|
+
const { id: _id, ...closeProps } = api.getCloseTriggerProps();
|
|
52
|
+
return renderPart("button", mergeProps({
|
|
53
|
+
...closeProps,
|
|
54
|
+
"data-slot": "sheet-close"
|
|
55
|
+
}, props), render);
|
|
56
|
+
}
|
|
57
|
+
const placement = {
|
|
58
|
+
right: {
|
|
59
|
+
positioner: "justify-end",
|
|
60
|
+
panel: "h-full w-3/4 max-w-sm rounded-l-3xl data-ending-style:translate-x-full data-starting-style:translate-x-full"
|
|
61
|
+
},
|
|
62
|
+
left: {
|
|
63
|
+
positioner: "justify-start",
|
|
64
|
+
panel: "h-full w-3/4 max-w-sm rounded-r-3xl data-ending-style:-translate-x-full data-starting-style:-translate-x-full"
|
|
65
|
+
},
|
|
66
|
+
top: {
|
|
67
|
+
positioner: "items-start",
|
|
68
|
+
panel: "max-h-full w-full rounded-b-3xl data-ending-style:-translate-y-full data-starting-style:-translate-y-full"
|
|
69
|
+
},
|
|
70
|
+
bottom: {
|
|
71
|
+
positioner: "items-end",
|
|
72
|
+
panel: "max-h-full w-full rounded-t-3xl data-ending-style:translate-y-full data-starting-style:translate-y-full"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/** Backdrop, panel and focus trap. Mounts only while open or leaving. */
|
|
76
|
+
function SheetContent({ className, render, ...props }) {
|
|
77
|
+
const { api, side } = useSheet();
|
|
78
|
+
const { ref, mounted, attrs } = usePresence(api.open);
|
|
79
|
+
const positioner = useRef(null);
|
|
80
|
+
useVisualViewportVars(positioner, mounted);
|
|
81
|
+
useSwipeTouchAction(ref, mounted, side === "top" || side === "bottom" ? "y" : "x");
|
|
82
|
+
if (!mounted) return null;
|
|
83
|
+
const state = {
|
|
84
|
+
...attrs,
|
|
85
|
+
"data-open": api.open ? "" : void 0
|
|
86
|
+
};
|
|
87
|
+
return /* @__PURE__ */ jsxs(Portal, { children: [/* @__PURE__ */ jsx("div", {
|
|
88
|
+
...api.getBackdropProps(),
|
|
89
|
+
...state,
|
|
90
|
+
hidden: false,
|
|
91
|
+
"data-slot": "sheet-overlay",
|
|
92
|
+
className: "ease-standard fixed inset-0 z-[60] bg-black/30 backdrop-blur-sm transition-opacity duration-(--duration-normal) data-ending-style:opacity-0 data-starting-style:opacity-0 data-swiping:opacity-[calc(1-var(--drawer-swipe-progress))] data-swiping:transition-none motion-reduce:transition-none"
|
|
93
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
94
|
+
...api.getPositionerProps(),
|
|
95
|
+
ref: positioner,
|
|
96
|
+
hidden: false,
|
|
97
|
+
className: cx("fixed inset-x-0 top-(--visual-viewport-top,0px) z-[60] flex h-(--visual-viewport-height,100dvh)", placement[side].positioner),
|
|
98
|
+
children: renderPart("div", mergeProps({
|
|
99
|
+
...api.getContentProps(),
|
|
100
|
+
...state,
|
|
101
|
+
ref,
|
|
102
|
+
hidden: false,
|
|
103
|
+
"data-slot": "sheet-content",
|
|
104
|
+
"data-side": side,
|
|
105
|
+
className: cx("relative flex flex-col overflow-y-auto overscroll-contain glass-menu squircle p-6 pt-[max(1.5rem,env(safe-area-inset-top))] pb-[max(1.5rem,env(safe-area-inset-bottom))] text-label outline-none transition-[transform,translate] duration-(--duration-sheet) ease-(--ease-sheet) motion-reduce:transition-none motion-reduce:data-ending-style:translate-x-0 motion-reduce:data-ending-style:translate-y-0 motion-reduce:data-starting-style:translate-x-0 motion-reduce:data-starting-style:translate-y-0 motion-reduce:data-ending-style:opacity-0 motion-reduce:data-starting-style:opacity-0", placement[side].panel, className)
|
|
106
|
+
}, props), render)
|
|
107
|
+
})] });
|
|
108
|
+
}
|
|
109
|
+
function SheetHeader({ className, ...props }) {
|
|
110
|
+
return /* @__PURE__ */ jsx("div", {
|
|
111
|
+
"data-slot": "sheet-header",
|
|
112
|
+
className: cx("flex flex-col gap-1.5", className),
|
|
113
|
+
...props
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function SheetFooter({ className, ...props }) {
|
|
117
|
+
return /* @__PURE__ */ jsx("div", {
|
|
118
|
+
"data-slot": "sheet-footer",
|
|
119
|
+
className: cx("mt-auto flex flex-col gap-2 pt-4", className),
|
|
120
|
+
...props
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function SheetTitle({ className, ...props }) {
|
|
124
|
+
const { api } = useSheet();
|
|
125
|
+
return /* @__PURE__ */ jsx("h2", {
|
|
126
|
+
...api.getTitleProps(),
|
|
127
|
+
"data-slot": "sheet-title",
|
|
128
|
+
className: cx("text-headline font-semibold text-label", className),
|
|
129
|
+
...props
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function SheetDescription({ className, ...props }) {
|
|
133
|
+
const { api } = useSheet();
|
|
134
|
+
return /* @__PURE__ */ jsx("p", {
|
|
135
|
+
...api.getDescriptionProps(),
|
|
136
|
+
"data-slot": "sheet-description",
|
|
137
|
+
className: cx("text-footnote text-label-secondary", className),
|
|
138
|
+
...props
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
export { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { RenderProp } from "./lib/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
export type SidebarSize = "sm" | "md" | "lg";
|
|
4
|
+
/** The navigation landmark that holds groups of rows. Name it with `aria-label`. */
|
|
5
|
+
export declare function Sidebar({ className, ...props }: ComponentProps<"nav">): import("react").JSX.Element;
|
|
6
|
+
/** A titled run of rows. */
|
|
7
|
+
export declare function SidebarGroup({ className, ...props }: ComponentProps<"section">): import("react").JSX.Element;
|
|
8
|
+
export type SidebarGroupLabelProps = ComponentProps<"h2"> & {
|
|
9
|
+
/** Matches the rows' size. @default "md" */
|
|
10
|
+
size?: SidebarSize;
|
|
11
|
+
};
|
|
12
|
+
/** The group's heading, bold enough to read as a category. */
|
|
13
|
+
export declare function SidebarGroupLabel({ size, className, ...props }: SidebarGroupLabelProps): import("react").JSX.Element;
|
|
14
|
+
export declare function SidebarMenu({ className, ...props }: ComponentProps<"ul">): import("react").JSX.Element;
|
|
15
|
+
export declare function SidebarMenuItem({ className, ...props }: ComponentProps<"li">): import("react").JSX.Element;
|
|
16
|
+
export type SidebarMenuButtonProps = ComponentProps<"a"> & {
|
|
17
|
+
/** The current destination. */
|
|
18
|
+
isActive?: boolean;
|
|
19
|
+
/** Row height, text and corners. @default "md" */
|
|
20
|
+
size?: SidebarSize;
|
|
21
|
+
/** A glyph before the label. */
|
|
22
|
+
icon?: ReactNode;
|
|
23
|
+
/** A count or status at the end. */
|
|
24
|
+
badge?: ReactNode;
|
|
25
|
+
/** Use your router's link, or a button. */
|
|
26
|
+
render?: RenderProp;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* One row. It is an anchor by default; pass `render` for a router link or a
|
|
30
|
+
* button. The current row carries `aria-current="page"` and the accent.
|
|
31
|
+
*/
|
|
32
|
+
export declare function SidebarMenuButton({ isActive, size, icon, badge, className, children, render, ...props }: SidebarMenuButtonProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
package/dist/sidebar.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { mergeProps, renderPart } from "./lib/render.js";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/components/sidebar.tsx
|
|
5
|
+
const rows = {
|
|
6
|
+
sm: "min-h-7 rounded-lg px-2 py-0.5 text-footnote [@media(pointer:coarse)]:min-h-10",
|
|
7
|
+
md: "min-h-8.5 rounded-xl px-2.5 py-1 text-subheadline [@media(pointer:coarse)]:min-h-11",
|
|
8
|
+
lg: "min-h-10 rounded-2xl px-3 py-2 text-body [@media(pointer:coarse)]:min-h-13"
|
|
9
|
+
};
|
|
10
|
+
const headings = {
|
|
11
|
+
sm: "px-2 pb-1 text-footnote",
|
|
12
|
+
md: "px-2.5 pb-1.5 text-footnote",
|
|
13
|
+
lg: "px-3 pb-2 text-subheadline"
|
|
14
|
+
};
|
|
15
|
+
const counts = {
|
|
16
|
+
sm: "text-caption2",
|
|
17
|
+
md: "text-footnote",
|
|
18
|
+
lg: "text-subheadline"
|
|
19
|
+
};
|
|
20
|
+
/** The navigation landmark that holds groups of rows. Name it with `aria-label`. */
|
|
21
|
+
function Sidebar({ className, ...props }) {
|
|
22
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
23
|
+
"data-slot": "sidebar",
|
|
24
|
+
className: cx("flex w-full flex-col gap-5", className),
|
|
25
|
+
...props
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** A titled run of rows. */
|
|
29
|
+
function SidebarGroup({ className, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx("section", {
|
|
31
|
+
"data-slot": "sidebar-group",
|
|
32
|
+
className: cx("flex flex-col gap-0.5", className),
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** The group's heading, bold enough to read as a category. */
|
|
37
|
+
function SidebarGroupLabel({ size = "md", className, ...props }) {
|
|
38
|
+
return /* @__PURE__ */ jsx("h2", {
|
|
39
|
+
"data-slot": "sidebar-group-label",
|
|
40
|
+
className: cx("m-0 font-semibold text-label", headings[size], className),
|
|
41
|
+
...props
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function SidebarMenu({ className, ...props }) {
|
|
45
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
46
|
+
"data-slot": "sidebar-menu",
|
|
47
|
+
className: cx("m-0 flex list-none flex-col gap-px p-0", className),
|
|
48
|
+
...props
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
52
|
+
return /* @__PURE__ */ jsx("li", {
|
|
53
|
+
"data-slot": "sidebar-menu-item",
|
|
54
|
+
className: cx("min-w-0", className),
|
|
55
|
+
...props
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One row. It is an anchor by default; pass `render` for a router link or a
|
|
60
|
+
* button. The current row carries `aria-current="page"` and the accent.
|
|
61
|
+
*/
|
|
62
|
+
function SidebarMenuButton({ isActive, size = "md", icon, badge, className, children, render, ...props }) {
|
|
63
|
+
return renderPart("a", mergeProps({
|
|
64
|
+
"data-slot": "sidebar-menu-button",
|
|
65
|
+
"data-active": isActive ? "" : void 0,
|
|
66
|
+
"aria-current": isActive ? "page" : void 0,
|
|
67
|
+
className: cx("group flex w-full items-center gap-2.5 no-underline outline-none transition-colors duration-(--duration-fast) focus-visible:ring-2 focus-visible:ring-accent/70 motion-reduce:transition-none", rows[size], isActive ? "bg-fill font-medium text-label" : "text-label-secondary hover:bg-fill/70 hover:text-label", className),
|
|
68
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
69
|
+
icon ? /* @__PURE__ */ jsx("span", {
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
className: cx("flex shrink-0 transition-colors", isActive ? "text-accent-text" : "text-label-secondary"),
|
|
72
|
+
children: icon
|
|
73
|
+
}) : null,
|
|
74
|
+
/* @__PURE__ */ jsx("span", {
|
|
75
|
+
className: "grow truncate",
|
|
76
|
+
children
|
|
77
|
+
}),
|
|
78
|
+
badge != null ? /* @__PURE__ */ jsx("span", {
|
|
79
|
+
className: cx("tabular-nums", counts[size], isActive ? "text-accent-text" : "text-label-tertiary"),
|
|
80
|
+
children: badge
|
|
81
|
+
}) : null
|
|
82
|
+
] })
|
|
83
|
+
}, props), render);
|
|
84
|
+
}
|
|
85
|
+
export { Sidebar, SidebarGroup, SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem };
|
package/dist/skeleton.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/components/skeleton.tsx
|
|
4
|
+
/** A placeholder block while content loads. Size it with classes. */
|
|
5
|
+
function Skeleton({ className, ...props }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", {
|
|
7
|
+
"data-slot": "skeleton",
|
|
8
|
+
"aria-hidden": "true",
|
|
9
|
+
className: cx("animate-pulse rounded-xl bg-fill motion-reduce:animate-none", className),
|
|
10
|
+
...props
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export { Skeleton };
|
package/dist/slider.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as zagSlider from "@zag-js/slider";
|
|
2
|
+
export interface SliderProps extends Omit<zagSlider.Props, "id" | "ids" | "value" | "defaultValue" | "onValueChange"> {
|
|
3
|
+
value?: number | number[];
|
|
4
|
+
defaultValue?: number | number[];
|
|
5
|
+
onValueChange?: (value: number[]) => void;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/** A draggable range control. Pass an array for two or more thumbs. */
|
|
9
|
+
export declare function Slider({ value, defaultValue, onValueChange, className, ...props }: SliderProps): import("react").JSX.Element;
|
package/dist/slider.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "./lib/cx.js";
|
|
3
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import * as zagSlider from "@zag-js/slider";
|
|
7
|
+
// src/components/slider.tsx
|
|
8
|
+
const toArray = (v) => v === void 0 ? void 0 : Array.isArray(v) ? v : [v];
|
|
9
|
+
/** A draggable range control. Pass an array for two or more thumbs. */
|
|
10
|
+
function Slider({ value, defaultValue, onValueChange, className, ...props }) {
|
|
11
|
+
const id = useId();
|
|
12
|
+
const service = useMachine(zagSlider.machine, {
|
|
13
|
+
id,
|
|
14
|
+
value: toArray(value),
|
|
15
|
+
defaultValue: toArray(defaultValue) ?? (value === void 0 ? [props.min ?? 0] : void 0),
|
|
16
|
+
onValueChange: ({ value: next }) => onValueChange?.(next),
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
const api = zagSlider.connect(service, normalizeProps);
|
|
20
|
+
return /* @__PURE__ */ jsx("div", {
|
|
21
|
+
...api.getRootProps(),
|
|
22
|
+
"data-slot": "slider",
|
|
23
|
+
className: cx("w-full data-disabled:opacity-40", className),
|
|
24
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
25
|
+
...api.getControlProps(),
|
|
26
|
+
className: "relative flex h-8 w-full touch-none items-center",
|
|
27
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
28
|
+
...api.getTrackProps(),
|
|
29
|
+
className: "bg-fill h-2 w-full overflow-hidden rounded-full",
|
|
30
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
31
|
+
...api.getRangeProps(),
|
|
32
|
+
className: "bg-accent h-full rounded-full"
|
|
33
|
+
})
|
|
34
|
+
}), api.value.map((_, index) => /* @__PURE__ */ jsx("div", {
|
|
35
|
+
...api.getThumbProps({ index }),
|
|
36
|
+
className: "focus-visible:ring-accent/70 spring-snappy size-7 rounded-full bg-white shadow-[0_1px_4px_rgb(0_0_0/0.3)] transition-transform outline-none focus-visible:ring-2 data-dragging:scale-125 motion-reduce:transition-none",
|
|
37
|
+
children: /* @__PURE__ */ jsx("input", { ...api.getHiddenInputProps({ index }) })
|
|
38
|
+
}, index))]
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export { Slider };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type SloshSliderSize = "sm" | "md" | "lg";
|
|
2
|
+
export interface SloshSliderProps {
|
|
3
|
+
label: string;
|
|
4
|
+
value?: number;
|
|
5
|
+
defaultValue?: number;
|
|
6
|
+
onChange?: (value: number) => void;
|
|
7
|
+
/** 0 is rigid; 100 is loose liquid. @default 15 */
|
|
8
|
+
viscosity?: number;
|
|
9
|
+
/** How far the handle coasts after release, 0–100. @default 55 */
|
|
10
|
+
momentum?: number;
|
|
11
|
+
/** Lean of the liquid's leading edge, 0–100. @default 45 */
|
|
12
|
+
tilt?: number;
|
|
13
|
+
/** Track corner, from square to a pill, 0–20. @default 20 */
|
|
14
|
+
corner?: number;
|
|
15
|
+
/** Track height and knob scale. @default "md" */
|
|
16
|
+
size?: SloshSliderSize;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
className?: string;
|
|
19
|
+
formatValue?: (value: number) => string;
|
|
20
|
+
}
|
|
21
|
+
export declare function SloshSlider({ label, value, defaultValue, onChange, viscosity, momentum, tilt, corner, size, disabled, className, formatValue }: SloshSliderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMediaQuery } from "./use-media-query.js";
|
|
3
|
+
import { cx } from "./lib/cx.js";
|
|
4
|
+
import { stepLiquid } from "./lib/liquid-step.js";
|
|
5
|
+
import { clampRange } from "./lib/range-value.js";
|
|
6
|
+
import { useEffect, useRef } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/components/slosh-slider.tsx
|
|
9
|
+
function SloshSlider({ label, value, defaultValue = 62, onChange, viscosity = 15, momentum = 55, tilt = 45, corner = 20, size = "md", disabled = false, className, formatValue }) {
|
|
10
|
+
const reduced = useMediaQuery("(prefers-reduced-motion: reduce)");
|
|
11
|
+
const track = useRef(null);
|
|
12
|
+
const fillEl = useRef(null);
|
|
13
|
+
const knobEl = useRef(null);
|
|
14
|
+
const initial = clampRange(value ?? defaultValue, 0, 100);
|
|
15
|
+
const state = useRef({
|
|
16
|
+
value: initial,
|
|
17
|
+
handleVelocity: 0,
|
|
18
|
+
fill: initial,
|
|
19
|
+
velocity: 0,
|
|
20
|
+
held: false,
|
|
21
|
+
raf: 0,
|
|
22
|
+
previous: 0,
|
|
23
|
+
last: {
|
|
24
|
+
value: initial,
|
|
25
|
+
time: 0
|
|
26
|
+
},
|
|
27
|
+
notified: Math.round(initial)
|
|
28
|
+
});
|
|
29
|
+
const settings = useRef({
|
|
30
|
+
viscosity,
|
|
31
|
+
momentum,
|
|
32
|
+
tilt,
|
|
33
|
+
reduced,
|
|
34
|
+
onChange,
|
|
35
|
+
formatValue
|
|
36
|
+
});
|
|
37
|
+
settings.current = {
|
|
38
|
+
viscosity,
|
|
39
|
+
momentum,
|
|
40
|
+
tilt,
|
|
41
|
+
reduced,
|
|
42
|
+
onChange,
|
|
43
|
+
formatValue
|
|
44
|
+
};
|
|
45
|
+
const run = useRef(() => {});
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const s = state.current;
|
|
48
|
+
const paint = () => {
|
|
49
|
+
if (!track.current || !fillEl.current || !knobEl.current) return;
|
|
50
|
+
fillEl.current.style.width = `${s.fill.toFixed(2)}%`;
|
|
51
|
+
knobEl.current.style.insetInlineStart = `${s.value.toFixed(2)}%`;
|
|
52
|
+
const lean = settings.current.reduced ? 0 : clampRange(clampRange(settings.current.tilt, 0, 100) / 100 * s.velocity * 3, -20, 20);
|
|
53
|
+
fillEl.current.style.setProperty("--slosh-lean", `${lean.toFixed(2)}px`);
|
|
54
|
+
const next = Math.round(s.value);
|
|
55
|
+
track.current.setAttribute("aria-valuenow", String(next));
|
|
56
|
+
const spoken = settings.current.formatValue?.(next);
|
|
57
|
+
if (spoken) track.current.setAttribute("aria-valuetext", spoken);
|
|
58
|
+
else track.current.removeAttribute("aria-valuetext");
|
|
59
|
+
if (s.notified !== next) {
|
|
60
|
+
s.notified = next;
|
|
61
|
+
settings.current.onChange?.(next);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const tick = (time) => {
|
|
65
|
+
const dt = s.previous ? clampRange((time - s.previous) / 16.67, 0, 2.5) : 1;
|
|
66
|
+
s.previous = time;
|
|
67
|
+
const knobs = settings.current;
|
|
68
|
+
if (!s.held && s.handleVelocity) {
|
|
69
|
+
s.value += s.handleVelocity * dt;
|
|
70
|
+
s.handleVelocity *= (.86 + clampRange(knobs.momentum, 0, 100) / 100 * .115) ** dt;
|
|
71
|
+
if (s.value <= 0 || s.value >= 100) {
|
|
72
|
+
s.value = clampRange(s.value, 0, 100);
|
|
73
|
+
s.handleVelocity = 0;
|
|
74
|
+
}
|
|
75
|
+
if (Math.abs(s.handleVelocity) < .01) s.handleVelocity = 0;
|
|
76
|
+
}
|
|
77
|
+
const next = stepLiquid(s, s.value, knobs.reduced ? 0 : knobs.viscosity, dt);
|
|
78
|
+
s.fill = next.fill;
|
|
79
|
+
s.velocity = next.velocity;
|
|
80
|
+
paint();
|
|
81
|
+
if (!s.handleVelocity && !s.velocity && Math.abs(s.fill - s.value) < .02) {
|
|
82
|
+
s.raf = 0;
|
|
83
|
+
s.previous = 0;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
s.raf = requestAnimationFrame(tick);
|
|
87
|
+
};
|
|
88
|
+
run.current = () => {
|
|
89
|
+
paint();
|
|
90
|
+
if (!s.raf) s.raf = requestAnimationFrame(tick);
|
|
91
|
+
};
|
|
92
|
+
paint();
|
|
93
|
+
return () => {
|
|
94
|
+
cancelAnimationFrame(s.raf);
|
|
95
|
+
s.raf = 0;
|
|
96
|
+
s.previous = 0;
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const s = state.current;
|
|
101
|
+
if (value !== void 0 && Math.round(clampRange(value, 0, 100)) !== s.notified) {
|
|
102
|
+
s.value = clampRange(value, 0, 100);
|
|
103
|
+
s.notified = Math.round(s.value);
|
|
104
|
+
s.handleVelocity = 0;
|
|
105
|
+
}
|
|
106
|
+
if (reduced || disabled) {
|
|
107
|
+
s.handleVelocity = 0;
|
|
108
|
+
s.held = false;
|
|
109
|
+
}
|
|
110
|
+
run.current();
|
|
111
|
+
}, [
|
|
112
|
+
value,
|
|
113
|
+
reduced,
|
|
114
|
+
disabled,
|
|
115
|
+
viscosity,
|
|
116
|
+
tilt,
|
|
117
|
+
formatValue
|
|
118
|
+
]);
|
|
119
|
+
const readAt = (clientX) => {
|
|
120
|
+
const t = track.current;
|
|
121
|
+
if (!t) return 0;
|
|
122
|
+
const box = t.getBoundingClientRect();
|
|
123
|
+
const fraction = box.width ? (clientX - box.left) / box.width : 0;
|
|
124
|
+
return clampRange((getComputedStyle(t).direction === "rtl" ? 1 - fraction : fraction) * 100, 0, 100);
|
|
125
|
+
};
|
|
126
|
+
const release = (cancelled = false) => {
|
|
127
|
+
const s = state.current;
|
|
128
|
+
if (!s.held) return;
|
|
129
|
+
s.held = false;
|
|
130
|
+
s.handleVelocity = cancelled || reduced ? 0 : clampRange(s.handleVelocity, -6, 6);
|
|
131
|
+
if (performance.now() - s.last.time > 100) s.handleVelocity = 0;
|
|
132
|
+
run.current();
|
|
133
|
+
};
|
|
134
|
+
return /* @__PURE__ */ jsx("div", {
|
|
135
|
+
className: cx("passui-slosh-slider not-typeset", disabled && "opacity-40", className),
|
|
136
|
+
style: { "--slosh-radius": `${clampRange(corner, 0, 20)}px` },
|
|
137
|
+
"data-size": size,
|
|
138
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
139
|
+
ref: track,
|
|
140
|
+
className: "passui-slosh-track",
|
|
141
|
+
role: "slider",
|
|
142
|
+
tabIndex: disabled ? -1 : 0,
|
|
143
|
+
"aria-label": label,
|
|
144
|
+
"aria-disabled": disabled || void 0,
|
|
145
|
+
"aria-valuemin": 0,
|
|
146
|
+
"aria-valuemax": 100,
|
|
147
|
+
"aria-valuenow": Math.round(initial),
|
|
148
|
+
"aria-valuetext": formatValue?.(Math.round(initial)),
|
|
149
|
+
onPointerDown: (event) => {
|
|
150
|
+
if (disabled || event.button !== 0) return;
|
|
151
|
+
event.currentTarget.focus();
|
|
152
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
153
|
+
const s = state.current;
|
|
154
|
+
s.held = true;
|
|
155
|
+
s.handleVelocity = 0;
|
|
156
|
+
s.value = readAt(event.clientX);
|
|
157
|
+
s.last = {
|
|
158
|
+
value: s.value,
|
|
159
|
+
time: performance.now()
|
|
160
|
+
};
|
|
161
|
+
run.current();
|
|
162
|
+
},
|
|
163
|
+
onPointerMove: (event) => {
|
|
164
|
+
const s = state.current;
|
|
165
|
+
if (!s.held || disabled) return;
|
|
166
|
+
const next = readAt(event.clientX);
|
|
167
|
+
const now = performance.now();
|
|
168
|
+
s.handleVelocity = (next - s.last.value) / Math.max(1, now - s.last.time) * 16.67;
|
|
169
|
+
s.last = {
|
|
170
|
+
value: next,
|
|
171
|
+
time: now
|
|
172
|
+
};
|
|
173
|
+
s.value = next;
|
|
174
|
+
run.current();
|
|
175
|
+
},
|
|
176
|
+
onPointerUp: () => release(),
|
|
177
|
+
onPointerCancel: () => release(true),
|
|
178
|
+
onLostPointerCapture: () => release(true),
|
|
179
|
+
onKeyDown: (event) => {
|
|
180
|
+
if (disabled) return;
|
|
181
|
+
const s = state.current;
|
|
182
|
+
const step = event.shiftKey ? 10 : 2;
|
|
183
|
+
const rtl = getComputedStyle(event.currentTarget).direction === "rtl";
|
|
184
|
+
const next = event.key === "ArrowUp" || event.key === (rtl ? "ArrowLeft" : "ArrowRight") ? s.value + step : event.key === "ArrowDown" || event.key === (rtl ? "ArrowRight" : "ArrowLeft") ? s.value - step : event.key === "Home" ? 0 : event.key === "End" ? 100 : null;
|
|
185
|
+
if (next === null) return;
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
s.handleVelocity = 0;
|
|
188
|
+
s.value = clampRange(next, 0, 100);
|
|
189
|
+
run.current();
|
|
190
|
+
},
|
|
191
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
192
|
+
"aria-hidden": "true",
|
|
193
|
+
ref: fillEl,
|
|
194
|
+
className: "passui-slosh-fill",
|
|
195
|
+
style: { width: `${initial}%` }
|
|
196
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
197
|
+
"aria-hidden": "true",
|
|
198
|
+
ref: knobEl,
|
|
199
|
+
className: "passui-slosh-knob",
|
|
200
|
+
style: { insetInlineStart: `${initial}%` }
|
|
201
|
+
})]
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
export { SloshSlider };
|
package/dist/spinner.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/components/spinner.tsx
|
|
4
|
+
/** An indeterminate activity indicator. Colour follows the text colour. */
|
|
5
|
+
function Spinner({ className, ...props }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
7
|
+
role: "status",
|
|
8
|
+
"aria-label": "Loading",
|
|
9
|
+
"data-slot": "spinner",
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
fill: "none",
|
|
12
|
+
stroke: "currentColor",
|
|
13
|
+
strokeWidth: "2.5",
|
|
14
|
+
strokeLinecap: "round",
|
|
15
|
+
className: cx("size-4 animate-spin motion-reduce:animate-[spin_2s_linear_infinite]", className),
|
|
16
|
+
...props,
|
|
17
|
+
children: /* @__PURE__ */ jsx("path", { d: "M12 3a9 9 0 1 0 9 9" })
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export { Spinner };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export type StatTileTone = "critical";
|
|
3
|
+
export type StatTileSize = "sm" | "md" | "lg";
|
|
4
|
+
export interface StatTileProps {
|
|
5
|
+
label: string;
|
|
6
|
+
value: number;
|
|
7
|
+
/** A quiet line under the number, like "3 signed in now". */
|
|
8
|
+
caption?: ReactNode;
|
|
9
|
+
/** Turns the number red once it's above zero. */
|
|
10
|
+
tone?: StatTileTone;
|
|
11
|
+
/** Makes the tile a toggle, e.g. a filter. */
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
active?: boolean;
|
|
14
|
+
/** Custom classes for the tile container. */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Tile padding and number scale. @default "md" */
|
|
17
|
+
size?: StatTileSize;
|
|
18
|
+
}
|
|
19
|
+
/** One number with its label, optionally a toggle. */
|
|
20
|
+
export declare function StatTile({ label, value, caption, tone, onClick, active, className, size }: StatTileProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/components/stat-tile.tsx
|
|
4
|
+
const tileSizes = {
|
|
5
|
+
sm: {
|
|
6
|
+
padding: "p-3",
|
|
7
|
+
valueText: "text-title3",
|
|
8
|
+
labelText: "text-caption"
|
|
9
|
+
},
|
|
10
|
+
md: {
|
|
11
|
+
padding: "p-4",
|
|
12
|
+
valueText: "text-title1",
|
|
13
|
+
labelText: "text-footnote"
|
|
14
|
+
},
|
|
15
|
+
lg: {
|
|
16
|
+
padding: "p-5",
|
|
17
|
+
valueText: "text-title",
|
|
18
|
+
labelText: "text-subheadline"
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
/** One number with its label, optionally a toggle. */
|
|
22
|
+
function StatTile({ label, value, caption, tone, onClick, active = false, className, size = "md" }) {
|
|
23
|
+
const dims = tileSizes[size];
|
|
24
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
|
+
/* @__PURE__ */ jsx("span", {
|
|
26
|
+
className: cx(dims.labelText, "text-label-secondary"),
|
|
27
|
+
children: label
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ jsx("span", {
|
|
30
|
+
className: cx("font-semibold tabular-nums", dims.valueText, tone === "critical" && value > 0 && "text-danger"),
|
|
31
|
+
children: value.toLocaleString("en-US")
|
|
32
|
+
}),
|
|
33
|
+
caption && /* @__PURE__ */ jsx("span", {
|
|
34
|
+
className: cx(dims.labelText, "text-label-tertiary"),
|
|
35
|
+
children: caption
|
|
36
|
+
})
|
|
37
|
+
] });
|
|
38
|
+
const tileClass = cx("border-separator/35 bg-elevated flex min-w-0 flex-col gap-2 rounded-2xl border text-left shadow-xs", dims.padding, className);
|
|
39
|
+
if (!onClick) return /* @__PURE__ */ jsx("div", {
|
|
40
|
+
"data-slot": "stat-tile",
|
|
41
|
+
className: tileClass,
|
|
42
|
+
children: body
|
|
43
|
+
});
|
|
44
|
+
return /* @__PURE__ */ jsx("button", {
|
|
45
|
+
type: "button",
|
|
46
|
+
"data-slot": "stat-tile",
|
|
47
|
+
"aria-pressed": active,
|
|
48
|
+
onClick,
|
|
49
|
+
className: cx(tileClass, "hover:bg-fill/60 ring-1 ring-transparent transition-colors", active && "bg-fill/70 ring-label/15"),
|
|
50
|
+
children: body
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export { StatTile };
|