@passui/react 0.1.46 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -109
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/accordion.d.ts +15 -0
- package/dist/accordion.js +93 -0
- package/dist/alert-dialog.d.ts +26 -0
- package/dist/alert-dialog.js +142 -0
- package/dist/alert.d.ts +10 -0
- package/dist/alert.js +28 -0
- package/dist/{types/src/components/ambient/ambient.d.ts → ambient.d.ts} +4 -4
- package/dist/ambient.js +22 -0
- package/dist/{types/src/appearance → appearance}/platform.d.ts +3 -3
- package/dist/appearance/platform.js +43 -0
- package/dist/appearance/theme.d.ts +71 -0
- package/dist/appearance/theme.js +236 -0
- package/dist/appearance.d.ts +3 -0
- package/dist/appearance.js +3 -0
- package/dist/{types/src/components/aspect-ratio/aspect-ratio.d.ts → aspect-ratio.d.ts} +4 -4
- package/dist/aspect-ratio.js +17 -0
- package/dist/avatar.d.ts +5 -0
- package/dist/avatar.js +43 -0
- package/dist/badge.d.ts +8 -0
- package/dist/badge.js +21 -0
- package/dist/breadcrumb.d.ts +13 -0
- package/dist/breadcrumb.js +63 -0
- package/dist/button-group.d.ts +5 -0
- package/dist/button-group.js +14 -0
- package/dist/button.d.ts +21 -0
- package/dist/button.js +58 -0
- package/dist/calendar.d.ts +35 -0
- package/dist/calendar.js +225 -0
- package/dist/card.d.ts +9 -0
- package/dist/card.js +54 -0
- package/dist/chart.d.ts +30 -0
- package/dist/chart.js +226 -0
- package/dist/checkbox.d.ts +13 -0
- package/dist/checkbox.js +53 -0
- package/dist/{types/src/lib/clipboard.d.ts → clipboard.d.ts} +1 -1
- package/dist/clipboard.js +16 -0
- package/dist/cn.d.ts +2 -0
- package/dist/cn.js +10 -0
- package/dist/code-block.d.ts +34 -0
- package/dist/code-block.js +87 -0
- package/dist/collapsible.d.ts +13 -0
- package/dist/collapsible.js +49 -0
- package/dist/combobox.d.ts +25 -0
- package/dist/combobox.js +112 -0
- package/dist/command.d.ts +22 -0
- package/dist/command.js +129 -0
- package/dist/components/toast/toast-store.d.ts +60 -0
- package/dist/components/toast/toast-store.js +96 -0
- package/dist/{types/src/components → components}/toast/toaster.d.ts +4 -4
- package/dist/components/toast/toaster.js +345 -0
- package/dist/context-menu.d.ts +2 -0
- package/dist/context-menu.js +2 -0
- package/dist/conversation.d.ts +48 -0
- package/dist/conversation.js +202 -0
- package/dist/date-time-picker.d.ts +50 -0
- package/dist/date-time-picker.js +235 -0
- package/dist/date.d.ts +50 -0
- package/dist/date.js +77 -0
- package/dist/dialog.d.ts +21 -0
- package/dist/dialog.js +113 -0
- package/dist/drawer.d.ts +30 -0
- package/dist/drawer.js +140 -0
- package/dist/dropdown-menu.d.ts +56 -0
- package/dist/dropdown-menu.js +295 -0
- package/dist/empty.d.ts +11 -0
- package/dist/empty.js +51 -0
- package/dist/field.d.ts +16 -0
- package/dist/field.js +47 -0
- package/{src/hooks/scroll/minimize-decision.ts → dist/hooks/scroll/minimize-decision.js} +3 -5
- package/dist/{types/src/hooks → hooks}/use-anchored-placement.d.ts +2 -2
- package/dist/hooks/use-anchored-placement.js +33 -0
- package/dist/{types/src/hooks → hooks}/use-minimize-on-scroll.d.ts +1 -1
- package/dist/hooks/use-minimize-on-scroll.js +59 -0
- package/dist/{types/src/hooks → hooks}/use-visual-viewport.d.ts +2 -2
- package/{src/hooks/use-visual-viewport.ts → dist/hooks/use-visual-viewport.js} +20 -35
- package/dist/hooks/viewport/types.d.ts +7 -0
- package/dist/hooks/viewport/viewport-metrics.js +13 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +80 -0
- package/dist/input-group.d.ts +17 -0
- package/dist/input-group.js +55 -0
- package/dist/input-otp.d.ts +13 -0
- package/dist/input-otp.js +36 -0
- package/dist/input.d.ts +4 -0
- package/dist/input.js +14 -0
- package/dist/item.d.ts +49 -0
- package/dist/item.js +142 -0
- package/dist/kbd.d.ts +4 -0
- package/dist/kbd.js +86 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +12 -0
- package/dist/labeled-content.d.ts +24 -0
- package/dist/labeled-content.js +41 -0
- package/dist/{types/src/lib/language.d.ts → language.d.ts} +1 -1
- package/dist/language.js +11 -0
- package/dist/layout.d.ts +24 -0
- package/dist/layout.js +36 -0
- package/dist/{types/src/lib → lib}/anchored-placement.d.ts +27 -27
- package/dist/lib/anchored-placement.js +42 -0
- package/dist/lib/calendar-month.js +90 -0
- package/dist/lib/cx.js +6 -0
- package/dist/lib/drawer.math.js +29 -0
- package/dist/lib/floating-layers.d.ts +3 -0
- package/dist/lib/floating-layers.js +25 -0
- package/dist/{types/src/lib → lib}/haptics.d.ts +1 -1
- package/dist/lib/haptics.js +13 -0
- package/dist/lib/liquid-step.js +33 -0
- package/dist/lib/page-scale.js +58 -0
- package/dist/lib/portal.js +12 -0
- package/dist/lib/presence.js +53 -0
- package/dist/lib/range-value.js +25 -0
- package/dist/lib/render.d.ts +8 -0
- package/dist/lib/render.js +42 -0
- package/dist/lib/rolling-digit.js +83 -0
- package/dist/{types/src/lib → lib}/screen-edges.d.ts +5 -5
- package/dist/lib/screen-edges.js +30 -0
- package/dist/lib/swipe-touch-action.js +34 -0
- package/dist/lib/visual-viewport.js +27 -0
- package/dist/lib/water-drop.js +412 -0
- package/dist/lib/wheel.js +125 -0
- package/dist/list.d.ts +26 -0
- package/dist/list.js +80 -0
- package/dist/locales.d.ts +18 -0
- package/dist/locales.js +36 -0
- package/dist/marker.d.ts +13 -0
- package/dist/marker.js +33 -0
- package/dist/motion/transitions.d.ts +170 -0
- package/dist/motion/transitions.js +156 -0
- package/dist/pagination.d.ts +30 -0
- package/dist/pagination.js +117 -0
- package/dist/popover.d.ts +26 -0
- package/dist/popover.js +101 -0
- package/dist/progress.d.ts +9 -0
- package/dist/progress.js +24 -0
- package/dist/questionnaire.d.ts +46 -0
- package/dist/questionnaire.js +133 -0
- package/dist/radio-group.d.ts +21 -0
- package/dist/radio-group.js +67 -0
- package/dist/search-field.d.ts +18 -0
- package/dist/search-field.js +45 -0
- package/dist/segmented-control.d.ts +16 -0
- package/dist/segmented-control.js +25 -0
- package/dist/select.d.ts +24 -0
- package/dist/select.js +107 -0
- package/dist/separator.d.ts +9 -0
- package/dist/separator.js +17 -0
- package/dist/{types/src/lib/shapes.d.ts → shapes.d.ts} +2 -2
- package/dist/shapes.js +65 -0
- package/dist/sheet.d.ts +24 -0
- package/dist/sheet.js +141 -0
- package/dist/sidebar.d.ts +32 -0
- package/dist/sidebar.js +85 -0
- package/dist/skeleton.d.ts +3 -0
- package/dist/skeleton.js +13 -0
- package/dist/slider.d.ts +9 -0
- package/dist/slider.js +42 -0
- package/dist/slosh-slider.d.ts +21 -0
- package/dist/slosh-slider.js +205 -0
- package/dist/spinner.d.ts +3 -0
- package/dist/spinner.js +20 -0
- package/dist/stat-tile.d.ts +20 -0
- package/dist/stat-tile.js +53 -0
- package/dist/stepper.d.ts +22 -0
- package/dist/stepper.js +98 -0
- package/dist/swatch-picker.d.ts +22 -0
- package/dist/swatch-picker.js +70 -0
- package/dist/switch.d.ts +10 -0
- package/dist/switch.js +44 -0
- package/dist/tab-bar.d.ts +15 -0
- package/dist/tab-bar.js +34 -0
- package/dist/{types/src/components/table/table.d.ts → table.d.ts} +3 -3
- package/dist/table.js +93 -0
- package/dist/tabs.d.ts +32 -0
- package/dist/tabs.js +131 -0
- package/dist/text.d.ts +25 -0
- package/dist/text.js +44 -0
- package/dist/textarea.d.ts +3 -0
- package/dist/textarea.js +13 -0
- package/dist/toast.d.ts +3 -0
- package/dist/toast.js +3 -0
- package/dist/toggle-group.d.ts +20 -0
- package/dist/toggle-group.js +68 -0
- package/dist/toggle.d.ts +24 -0
- package/dist/toggle.js +37 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tooltip.d.ts +21 -0
- package/dist/tooltip.js +61 -0
- package/dist/trace.d.ts +14 -0
- package/dist/trace.js +54 -0
- package/dist/{types/src/hooks/use-dismiss.d.ts → use-dismiss.d.ts} +3 -3
- package/dist/use-dismiss.js +38 -0
- package/dist/{types/src/hooks/use-media-query.d.ts → use-media-query.d.ts} +12 -12
- package/dist/use-media-query.js +56 -0
- package/dist/use-os.d.ts +12 -0
- package/dist/use-os.js +17 -0
- package/dist/wake-slider.d.ts +15 -0
- package/dist/wake-slider.js +174 -0
- package/package.json +122 -253
- package/src/styles/code-block.css +4 -0
- package/src/styles/globals.css +5 -0
- package/src/styles/motion-controls.css +10 -0
- package/src/styles/page-scale.css +27 -0
- package/src/styles/styles.css +4 -2
- package/dist/types/src/appearance/index.d.ts +0 -2
- package/dist/types/src/appearance/theme.d.ts +0 -71
- package/dist/types/src/components/accordion/accordion.d.ts +0 -23
- package/dist/types/src/components/ambient/index.d.ts +0 -1
- package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +0 -19
- package/dist/types/src/components/button/button-styles.d.ts +0 -12
- package/dist/types/src/components/button/button.d.ts +0 -32
- package/dist/types/src/components/button/icon-button.d.ts +0 -10
- package/dist/types/src/components/button/pending-spinner.d.ts +0 -5
- package/dist/types/src/components/button/use-pending-indicator.d.ts +0 -2
- package/dist/types/src/components/chip/chip.d.ts +0 -10
- package/dist/types/src/components/code-block/code-block.d.ts +0 -13
- package/dist/types/src/components/combo-box/combo-box.d.ts +0 -9
- package/dist/types/src/components/command/command.d.ts +0 -18
- package/dist/types/src/components/compact-date-picker/calendar-month.d.ts +0 -25
- package/dist/types/src/components/compact-date-picker/compact-date-picker.d.ts +0 -30
- package/dist/types/src/components/compact-time-picker/compact-time-picker.d.ts +0 -29
- package/dist/types/src/components/compact-time-picker/time-value.d.ts +0 -18
- package/dist/types/src/components/content-unavailable-view/content-unavailable-view.d.ts +0 -12
- package/dist/types/src/components/content-view/content-view.d.ts +0 -51
- package/dist/types/src/components/content-view/index.d.ts +0 -1
- package/dist/types/src/components/context-menu/conceal-menu-source.d.ts +0 -2
- package/dist/types/src/components/context-menu/context-menu-host.d.ts +0 -2
- package/dist/types/src/components/context-menu/context-menu-store.d.ts +0 -62
- package/dist/types/src/components/context-menu/menu-navigation.d.ts +0 -6
- package/dist/types/src/components/context-menu/menu-position.d.ts +0 -21
- package/dist/types/src/components/context-menu/menu-reveal.d.ts +0 -26
- package/dist/types/src/components/context-menu/use-context-menu.d.ts +0 -14
- package/dist/types/src/components/conversation/conversation.d.ts +0 -48
- package/dist/types/src/components/conversation/index.d.ts +0 -1
- package/dist/types/src/components/date-picker/date-picker.d.ts +0 -19
- package/dist/types/src/components/date-picker/date-value.d.ts +0 -2
- package/dist/types/src/components/dialog/dialog-host.d.ts +0 -6
- package/dist/types/src/components/dialog/dialog-store.d.ts +0 -23
- package/dist/types/src/components/dialog/dialog.d.ts +0 -33
- package/dist/types/src/components/dialog/index.d.ts +0 -1
- package/dist/types/src/components/disclosure-group/disclosure-group.d.ts +0 -18
- package/dist/types/src/components/divider/divider.d.ts +0 -9
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +0 -15
- package/dist/types/src/components/keyboard-shortcut/keyboard-shortcut.d.ts +0 -8
- package/dist/types/src/components/labeled-content/labeled-content.d.ts +0 -22
- package/dist/types/src/components/locale-switcher/index.d.ts +0 -1
- package/dist/types/src/components/locale-switcher/locale-switcher.d.ts +0 -13
- package/dist/types/src/components/menu/menu.d.ts +0 -16
- package/dist/types/src/components/morph/index.d.ts +0 -2
- package/dist/types/src/components/morph/morph.d.ts +0 -32
- package/dist/types/src/components/morph/use-morph-disclosure.d.ts +0 -13
- package/dist/types/src/components/one-time-code/one-time-code.d.ts +0 -26
- package/dist/types/src/components/picker/picker-trigger.d.ts +0 -3
- package/dist/types/src/components/picker/picker.d.ts +0 -46
- package/dist/types/src/components/popover/anchored-surface.d.ts +0 -17
- package/dist/types/src/components/popover/index.d.ts +0 -41
- package/dist/types/src/components/popover/popover-content.d.ts +0 -32
- package/dist/types/src/components/popover/popover-fit.d.ts +0 -21
- package/dist/types/src/components/popover/popover-root.d.ts +0 -22
- package/dist/types/src/components/popover/popover-trigger.d.ts +0 -23
- package/dist/types/src/components/profile-image/profile-image.d.ts +0 -9
- package/dist/types/src/components/progress-view/progress-view.d.ts +0 -13
- package/dist/types/src/components/progress-view/use-liquid-progress.d.ts +0 -3
- package/dist/types/src/components/radio-group/radio-group.d.ts +0 -20
- package/dist/types/src/components/search-field/expanding-search-field.d.ts +0 -5
- package/dist/types/src/components/search-field/search-field.d.ts +0 -9
- package/dist/types/src/components/search-list/search-list.d.ts +0 -22
- package/dist/types/src/components/section/section.d.ts +0 -18
- package/dist/types/src/components/secure-field/secure-field.d.ts +0 -4
- package/dist/types/src/components/segmented-control/segmented-control.d.ts +0 -25
- package/dist/types/src/components/sheet/modal-environment.d.ts +0 -2
- package/dist/types/src/components/sheet/sheet-portal.d.ts +0 -5
- package/dist/types/src/components/sheet/sheet.d.ts +0 -26
- package/dist/types/src/components/sheet/use-sheet-focus.d.ts +0 -3
- package/dist/types/src/components/sidebar/sidebar.d.ts +0 -24
- package/dist/types/src/components/skeleton/skeleton.d.ts +0 -9
- package/dist/types/src/components/slider/slider.d.ts +0 -17
- package/dist/types/src/components/slosh-slider/liquid-step.d.ts +0 -6
- package/dist/types/src/components/slosh-slider/slosh-slider.d.ts +0 -21
- package/dist/types/src/components/stat-tile/index.d.ts +0 -1
- package/dist/types/src/components/stat-tile/stat-tile.d.ts +0 -20
- package/dist/types/src/components/status-indicator/status-indicator.d.ts +0 -17
- package/dist/types/src/components/stepper/rolling-digit.d.ts +0 -11
- package/dist/types/src/components/stepper/stepper.d.ts +0 -22
- package/dist/types/src/components/swatch-picker/swatch-picker.d.ts +0 -22
- package/dist/types/src/components/tab-bar/tab-bar.d.ts +0 -43
- package/dist/types/src/components/tab-view/tab-view.d.ts +0 -27
- package/dist/types/src/components/text-editor/text-editor.d.ts +0 -9
- package/dist/types/src/components/text-field/text-field.d.ts +0 -33
- package/dist/types/src/components/toast/toast-store.d.ts +0 -52
- package/dist/types/src/components/toggle/toggle.d.ts +0 -22
- package/dist/types/src/components/tooltip/tooltip-host.d.ts +0 -7
- package/dist/types/src/components/view-controller/index.d.ts +0 -1
- package/dist/types/src/components/view-controller/view-controller.d.ts +0 -21
- package/dist/types/src/components/wake-slider/wake-slider.d.ts +0 -15
- package/dist/types/src/hooks/scroll/minimize-decision.d.ts +0 -2
- package/dist/types/src/hooks/use-anchored-disclosure.d.ts +0 -9
- package/dist/types/src/hooks/use-floating-dismiss.d.ts +0 -3
- package/dist/types/src/hooks/viewport/types.d.ts +0 -19
- package/dist/types/src/hooks/viewport/viewport-metrics.d.ts +0 -3
- package/dist/types/src/icons/icons.d.ts +0 -616
- package/dist/types/src/index.d.ts +0 -73
- package/dist/types/src/lib/class-names.d.ts +0 -2
- package/dist/types/src/lib/date.d.ts +0 -50
- package/dist/types/src/lib/floating-layers.d.ts +0 -8
- package/dist/types/src/lib/range-value.d.ts +0 -4
- package/dist/types/src/machines/popover.machine.d.ts +0 -30
- package/dist/types/src/motion/transitions.d.ts +0 -170
- package/src/appearance/index.ts +0 -2
- package/src/appearance/platform.tsx +0 -102
- package/src/appearance/theme.tsx +0 -467
- package/src/components/accordion/accordion.tsx +0 -70
- package/src/components/ambient/ambient.tsx +0 -35
- package/src/components/ambient/index.ts +0 -1
- package/src/components/aspect-ratio/aspect-ratio.tsx +0 -27
- package/src/components/breadcrumb/breadcrumb.tsx +0 -73
- package/src/components/button/button-styles.ts +0 -49
- package/src/components/button/button.tsx +0 -107
- package/src/components/button/icon-button.tsx +0 -33
- package/src/components/button/pending-spinner.tsx +0 -14
- package/src/components/button/use-pending-indicator.ts +0 -22
- package/src/components/chip/chip.tsx +0 -45
- package/src/components/code-block/code-block.tsx +0 -48
- package/src/components/combo-box/combo-box.tsx +0 -13
- package/src/components/command/command.tsx +0 -149
- package/src/components/compact-date-picker/calendar-month.ts +0 -109
- package/src/components/compact-date-picker/compact-date-picker.tsx +0 -337
- package/src/components/compact-time-picker/compact-time-picker.tsx +0 -321
- package/src/components/compact-time-picker/time-value.ts +0 -58
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +0 -78
- package/src/components/content-view/content-view.tsx +0 -215
- package/src/components/content-view/index.ts +0 -1
- package/src/components/context-menu/conceal-menu-source.ts +0 -30
- package/src/components/context-menu/context-menu-host.tsx +0 -459
- package/src/components/context-menu/context-menu-store.ts +0 -167
- package/src/components/context-menu/menu-navigation.ts +0 -36
- package/src/components/context-menu/menu-position.ts +0 -38
- package/src/components/context-menu/menu-reveal.ts +0 -42
- package/src/components/context-menu/use-context-menu.ts +0 -73
- package/src/components/conversation/conversation.tsx +0 -309
- package/src/components/conversation/index.ts +0 -1
- package/src/components/date-picker/date-picker.tsx +0 -106
- package/src/components/date-picker/date-value.ts +0 -22
- package/src/components/dialog/dialog-host.tsx +0 -119
- package/src/components/dialog/dialog-store.ts +0 -66
- package/src/components/dialog/dialog.tsx +0 -211
- package/src/components/dialog/index.ts +0 -1
- package/src/components/disclosure-group/disclosure-group.tsx +0 -108
- package/src/components/divider/divider.tsx +0 -33
- package/src/components/inline-disclosure/inline-disclosure.tsx +0 -53
- package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +0 -32
- package/src/components/labeled-content/labeled-content.tsx +0 -84
- package/src/components/locale-switcher/index.ts +0 -1
- package/src/components/locale-switcher/locale-switcher.tsx +0 -311
- package/src/components/menu/menu.tsx +0 -85
- package/src/components/morph/index.ts +0 -2
- package/src/components/morph/morph.tsx +0 -258
- package/src/components/morph/use-morph-disclosure.ts +0 -27
- package/src/components/one-time-code/one-time-code.tsx +0 -234
- package/src/components/picker/picker-trigger.ts +0 -22
- package/src/components/picker/picker.tsx +0 -404
- package/src/components/popover/anchored-surface.tsx +0 -264
- package/src/components/popover/index.ts +0 -50
- package/src/components/popover/popover-content.tsx +0 -334
- package/src/components/popover/popover-fit.ts +0 -74
- package/src/components/popover/popover-root.tsx +0 -97
- package/src/components/popover/popover-trigger.tsx +0 -71
- package/src/components/profile-image/profile-image.tsx +0 -96
- package/src/components/progress-view/progress-view.tsx +0 -72
- package/src/components/progress-view/use-liquid-progress.ts +0 -43
- package/src/components/radio-group/radio-group.tsx +0 -86
- package/src/components/search-field/expanding-search-field.tsx +0 -197
- package/src/components/search-field/search-field.tsx +0 -66
- package/src/components/search-list/search-list.tsx +0 -276
- package/src/components/section/section.tsx +0 -75
- package/src/components/secure-field/secure-field.tsx +0 -8
- package/src/components/segmented-control/segmented-control.tsx +0 -157
- package/src/components/sheet/modal-environment.ts +0 -82
- package/src/components/sheet/sheet-portal.tsx +0 -62
- package/src/components/sheet/sheet.tsx +0 -165
- package/src/components/sheet/use-sheet-focus.ts +0 -109
- package/src/components/sidebar/sidebar.tsx +0 -102
- package/src/components/skeleton/skeleton.tsx +0 -38
- package/src/components/slider/slider.tsx +0 -134
- package/src/components/slosh-slider/liquid-step.ts +0 -43
- package/src/components/slosh-slider/slosh-slider.tsx +0 -294
- package/src/components/stat-tile/index.ts +0 -1
- package/src/components/stat-tile/stat-tile.tsx +0 -90
- package/src/components/status-indicator/status-indicator.tsx +0 -54
- package/src/components/stepper/rolling-digit.tsx +0 -91
- package/src/components/stepper/stepper.tsx +0 -136
- package/src/components/swatch-picker/swatch-picker.tsx +0 -138
- package/src/components/tab-bar/tab-bar.tsx +0 -182
- package/src/components/tab-view/tab-view.tsx +0 -155
- package/src/components/table/table.tsx +0 -151
- package/src/components/text-editor/text-editor.tsx +0 -42
- package/src/components/text-field/text-field.tsx +0 -200
- package/src/components/toast/toast-store.ts +0 -164
- package/src/components/toast/toaster.tsx +0 -407
- package/src/components/toggle/toggle.tsx +0 -320
- package/src/components/tooltip/tooltip-host.tsx +0 -178
- package/src/components/view-controller/index.ts +0 -1
- package/src/components/view-controller/view-controller.tsx +0 -75
- package/src/components/wake-slider/wake-slider.tsx +0 -260
- package/src/hooks/use-anchored-disclosure.ts +0 -23
- package/src/hooks/use-anchored-placement.ts +0 -40
- package/src/hooks/use-dismiss.ts +0 -44
- package/src/hooks/use-floating-dismiss.ts +0 -30
- package/src/hooks/use-media-query.ts +0 -94
- package/src/hooks/use-minimize-on-scroll.ts +0 -77
- package/src/hooks/viewport/types.ts +0 -19
- package/src/hooks/viewport/viewport-metrics.ts +0 -19
- package/src/icons/icons.tsx +0 -458
- package/src/index.ts +0 -107
- package/src/lib/anchored-placement.ts +0 -91
- package/src/lib/class-names.ts +0 -21
- package/src/lib/clipboard.ts +0 -15
- package/src/lib/date.ts +0 -86
- package/src/lib/floating-layers.ts +0 -53
- package/src/lib/haptics.ts +0 -23
- package/src/lib/language.ts +0 -16
- package/src/lib/range-value.ts +0 -38
- package/src/lib/screen-edges.ts +0 -44
- package/src/lib/shapes.ts +0 -59
- package/src/machines/popover.machine.ts +0 -51
- package/src/motion/transitions.ts +0 -97
- package/src/tokens.ts +0 -1
- /package/dist/{types/src/tokens.d.ts → tokens.js} +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { formatDay, parseDay } from "./lib/calendar-month.js";
|
|
3
|
+
import { cx } from "./lib/cx.js";
|
|
4
|
+
import { Wheel } from "./lib/wheel.js";
|
|
5
|
+
import { buttonVariants } from "./button.js";
|
|
6
|
+
import { Calendar } from "./calendar.js";
|
|
7
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
8
|
+
import { useMemo, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
// src/components/date-time-picker.tsx
|
|
11
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
12
|
+
function parseTime(value) {
|
|
13
|
+
const match = /^(\d{2}):(\d{2})$/.exec(value);
|
|
14
|
+
if (!match) return null;
|
|
15
|
+
const hour = Number(match[1]);
|
|
16
|
+
const minute = Number(match[2]);
|
|
17
|
+
return hour < 24 && minute < 60 ? {
|
|
18
|
+
hour,
|
|
19
|
+
minute
|
|
20
|
+
} : null;
|
|
21
|
+
}
|
|
22
|
+
const today = () => {
|
|
23
|
+
const now = /* @__PURE__ */ new Date();
|
|
24
|
+
return formatDay({
|
|
25
|
+
year: now.getFullYear(),
|
|
26
|
+
month: now.getMonth() + 1,
|
|
27
|
+
day: now.getDate()
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
/** Hour, minute and (where the locale uses one) AM/PM wheels, like the iOS time wheels. */
|
|
31
|
+
function TimeWheels({ value, onChange, locale, step, labels }) {
|
|
32
|
+
const time = parseTime(value) ?? {
|
|
33
|
+
hour: 9,
|
|
34
|
+
minute: 0
|
|
35
|
+
};
|
|
36
|
+
const twelve = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hour12 ?? false;
|
|
37
|
+
const emit = (hour, minute) => onChange(`${pad(hour)}:${pad(minute)}`);
|
|
38
|
+
const pm = time.hour >= 12;
|
|
39
|
+
const hours = useMemo(() => (twelve ? Array.from({ length: 12 }, (_, i) => i + 1) : Array.from({ length: 24 }, (_, i) => i)).map((hour) => ({
|
|
40
|
+
value: hour,
|
|
41
|
+
label: pad(hour)
|
|
42
|
+
})), [twelve]);
|
|
43
|
+
const minutes = useMemo(() => {
|
|
44
|
+
const all = Array.from({ length: Math.ceil(60 / step) }, (_, index) => index * step);
|
|
45
|
+
if (!all.includes(time.minute)) all.push(time.minute);
|
|
46
|
+
return all.sort((a, b) => a - b).map((minute) => ({
|
|
47
|
+
value: minute,
|
|
48
|
+
label: pad(minute)
|
|
49
|
+
}));
|
|
50
|
+
}, [step, time.minute]);
|
|
51
|
+
const periods = useMemo(() => {
|
|
52
|
+
const name = (hour) => new Intl.DateTimeFormat(locale, {
|
|
53
|
+
hour: "numeric",
|
|
54
|
+
hour12: true,
|
|
55
|
+
timeZone: "UTC"
|
|
56
|
+
}).formatToParts(new Date(Date.UTC(2e3, 0, 1, hour))).find((part) => part.type === "dayPeriod")?.value ?? "";
|
|
57
|
+
return [{
|
|
58
|
+
value: "am",
|
|
59
|
+
label: name(1)
|
|
60
|
+
}, {
|
|
61
|
+
value: "pm",
|
|
62
|
+
label: name(13)
|
|
63
|
+
}];
|
|
64
|
+
}, [locale]);
|
|
65
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
66
|
+
className: "flex justify-center gap-1",
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx(Wheel, {
|
|
69
|
+
label: labels.hour,
|
|
70
|
+
options: hours,
|
|
71
|
+
value: twelve ? time.hour % 12 || 12 : time.hour,
|
|
72
|
+
onValueChange: (hour) => emit(twelve ? hour % 12 + (pm ? 12 : 0) : hour, time.minute),
|
|
73
|
+
className: "w-16"
|
|
74
|
+
}),
|
|
75
|
+
/* @__PURE__ */ jsx(Wheel, {
|
|
76
|
+
label: labels.minute,
|
|
77
|
+
options: minutes,
|
|
78
|
+
value: time.minute,
|
|
79
|
+
onValueChange: (minute) => emit(time.hour, minute),
|
|
80
|
+
className: "w-16"
|
|
81
|
+
}),
|
|
82
|
+
twelve ? /* @__PURE__ */ jsx(Wheel, {
|
|
83
|
+
label: labels.period,
|
|
84
|
+
options: periods,
|
|
85
|
+
value: pm ? "pm" : "am",
|
|
86
|
+
onValueChange: (next) => emit(time.hour % 12 + (next === "pm" ? 12 : 0), time.minute),
|
|
87
|
+
className: "w-16"
|
|
88
|
+
}) : null
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** One chip that opens its own panel, the way the iOS compact date picker does. */
|
|
93
|
+
function Chip({ label, shown, placeholder, disabled, className, children }) {
|
|
94
|
+
const [open, setOpen] = useState(false);
|
|
95
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
96
|
+
open,
|
|
97
|
+
onOpenChange: (details) => setOpen(details.open),
|
|
98
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
99
|
+
disabled,
|
|
100
|
+
"aria-label": label,
|
|
101
|
+
className: cx(buttonVariants({
|
|
102
|
+
variant: "secondary",
|
|
103
|
+
className: "justify-between gap-3 font-medium"
|
|
104
|
+
}), !shown && "text-label-tertiary", className),
|
|
105
|
+
children: shown || placeholder || label
|
|
106
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
107
|
+
"aria-label": label,
|
|
108
|
+
className: "w-auto",
|
|
109
|
+
children: children(() => setOpen(false))
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* One picker for dates, times, both together, and ranges, the way Apple's
|
|
115
|
+
* compact DatePicker works: a chip for the date, a chip for the time, each
|
|
116
|
+
* opening its own panel. The date panel is a calendar whose month title opens
|
|
117
|
+
* month and year wheels, so a far date is one flick and not a hundred taps.
|
|
118
|
+
* The time panel is hour, minute and period wheels. Values are plain strings
|
|
119
|
+
* (`YYYY-MM-DD`, `HH:MM`, `YYYY-MM-DDTHH:MM`) or a `{ from, to }` range, so
|
|
120
|
+
* they go straight to a form or an API.
|
|
121
|
+
*/
|
|
122
|
+
function DateTimePicker(props) {
|
|
123
|
+
const { label, locale, placeholder, min, max, labels, disabled, className } = props;
|
|
124
|
+
const dayFormat = new Intl.DateTimeFormat(locale, {
|
|
125
|
+
dateStyle: "medium",
|
|
126
|
+
timeZone: "UTC"
|
|
127
|
+
});
|
|
128
|
+
const timeFormat = new Intl.DateTimeFormat(locale, {
|
|
129
|
+
timeStyle: "short",
|
|
130
|
+
timeZone: "UTC"
|
|
131
|
+
});
|
|
132
|
+
const showDay = (value) => {
|
|
133
|
+
const day = parseDay(value.slice(0, 10));
|
|
134
|
+
return day ? dayFormat.format(new Date(Date.UTC(day.year, day.month - 1, day.day))) : "";
|
|
135
|
+
};
|
|
136
|
+
const showTime = (value) => {
|
|
137
|
+
const time = parseTime(value);
|
|
138
|
+
return time ? timeFormat.format(new Date(Date.UTC(2e3, 0, 1, time.hour, time.minute))) : "";
|
|
139
|
+
};
|
|
140
|
+
const step = props.minuteStep ?? 5;
|
|
141
|
+
if (props.mode === "range") {
|
|
142
|
+
const { from, to } = props.value;
|
|
143
|
+
return /* @__PURE__ */ jsx(Chip, {
|
|
144
|
+
label,
|
|
145
|
+
shown: from ? `${showDay(from)}${to ? ` – ${showDay(to)}` : " –"}` : "",
|
|
146
|
+
placeholder,
|
|
147
|
+
disabled,
|
|
148
|
+
className,
|
|
149
|
+
children: (close) => /* @__PURE__ */ jsx(Calendar, {
|
|
150
|
+
mode: "range",
|
|
151
|
+
label,
|
|
152
|
+
locale,
|
|
153
|
+
min,
|
|
154
|
+
max,
|
|
155
|
+
labels,
|
|
156
|
+
value: props.value,
|
|
157
|
+
onValueChange: (next) => {
|
|
158
|
+
props.onValueChange(next);
|
|
159
|
+
if (next.to) close();
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (props.mode === "time") return /* @__PURE__ */ jsx(Chip, {
|
|
165
|
+
label,
|
|
166
|
+
shown: showTime(props.value),
|
|
167
|
+
placeholder,
|
|
168
|
+
disabled,
|
|
169
|
+
className,
|
|
170
|
+
children: () => /* @__PURE__ */ jsx(TimeWheels, {
|
|
171
|
+
value: props.value,
|
|
172
|
+
onChange: props.onValueChange,
|
|
173
|
+
locale,
|
|
174
|
+
step,
|
|
175
|
+
labels
|
|
176
|
+
})
|
|
177
|
+
});
|
|
178
|
+
if (props.mode === "datetime") {
|
|
179
|
+
const [date = "", time = ""] = props.value.split("T");
|
|
180
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
181
|
+
"data-slot": "date-time-picker",
|
|
182
|
+
className: cx("inline-flex flex-wrap gap-1.5", className),
|
|
183
|
+
children: [/* @__PURE__ */ jsx(Chip, {
|
|
184
|
+
label,
|
|
185
|
+
shown: showDay(date),
|
|
186
|
+
placeholder,
|
|
187
|
+
disabled,
|
|
188
|
+
children: (close) => /* @__PURE__ */ jsx(Calendar, {
|
|
189
|
+
label,
|
|
190
|
+
locale,
|
|
191
|
+
min,
|
|
192
|
+
max,
|
|
193
|
+
labels,
|
|
194
|
+
value: date,
|
|
195
|
+
onValueChange: (next) => {
|
|
196
|
+
props.onValueChange(`${next}T${time || "09:00"}`);
|
|
197
|
+
close();
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
}), /* @__PURE__ */ jsx(Chip, {
|
|
201
|
+
label: labels.hour,
|
|
202
|
+
shown: showTime(time),
|
|
203
|
+
placeholder: showTime("09:00"),
|
|
204
|
+
disabled,
|
|
205
|
+
children: () => /* @__PURE__ */ jsx(TimeWheels, {
|
|
206
|
+
value: time,
|
|
207
|
+
onChange: (next) => props.onValueChange(`${date || today()}T${next}`),
|
|
208
|
+
locale,
|
|
209
|
+
step,
|
|
210
|
+
labels
|
|
211
|
+
})
|
|
212
|
+
})]
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return /* @__PURE__ */ jsx(Chip, {
|
|
216
|
+
label,
|
|
217
|
+
shown: showDay(props.value),
|
|
218
|
+
placeholder,
|
|
219
|
+
disabled,
|
|
220
|
+
className,
|
|
221
|
+
children: (close) => /* @__PURE__ */ jsx(Calendar, {
|
|
222
|
+
label,
|
|
223
|
+
locale,
|
|
224
|
+
min,
|
|
225
|
+
max,
|
|
226
|
+
labels,
|
|
227
|
+
value: props.value,
|
|
228
|
+
onValueChange: (next) => {
|
|
229
|
+
props.onValueChange(next);
|
|
230
|
+
close();
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
export { DateTimePicker };
|
package/dist/date.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare const PRESETS: {
|
|
2
|
+
/** Aug 30, 2026 */
|
|
3
|
+
PP: {
|
|
4
|
+
dateStyle: "medium";
|
|
5
|
+
};
|
|
6
|
+
/** August 30, 2026 */
|
|
7
|
+
PPP: {
|
|
8
|
+
dateStyle: "long";
|
|
9
|
+
};
|
|
10
|
+
/** Aug 30, 2026, 2:15 PM */
|
|
11
|
+
PPp: {
|
|
12
|
+
dateStyle: "medium";
|
|
13
|
+
timeStyle: "short";
|
|
14
|
+
};
|
|
15
|
+
/** August 30, 2026 at 2:15 PM */
|
|
16
|
+
PPPp: {
|
|
17
|
+
dateStyle: "long";
|
|
18
|
+
timeStyle: "short";
|
|
19
|
+
};
|
|
20
|
+
/** Aug 30 */
|
|
21
|
+
"MMM d": {
|
|
22
|
+
month: "short";
|
|
23
|
+
day: "numeric";
|
|
24
|
+
};
|
|
25
|
+
/** Aug 30, 14:15 */
|
|
26
|
+
"MMM d, HH:mm": {
|
|
27
|
+
month: "short";
|
|
28
|
+
day: "numeric";
|
|
29
|
+
hour: "2-digit";
|
|
30
|
+
minute: "2-digit";
|
|
31
|
+
hourCycle: "h23";
|
|
32
|
+
};
|
|
33
|
+
/** Aug 30, 14:15:09 */
|
|
34
|
+
"MMM d, HH:mm:ss": {
|
|
35
|
+
month: "short";
|
|
36
|
+
day: "numeric";
|
|
37
|
+
hour: "2-digit";
|
|
38
|
+
minute: "2-digit";
|
|
39
|
+
second: "2-digit";
|
|
40
|
+
hourCycle: "h23";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type DatePreset = keyof typeof PRESETS;
|
|
44
|
+
/** A stored UTC timestamp shown as its UTC wall-clock time, whatever the viewer's timezone. */
|
|
45
|
+
export declare function formatUtc(date: Date | string | number, preset: DatePreset): string;
|
|
46
|
+
/** The viewer's local time of day, like 2:15 PM. */
|
|
47
|
+
export declare function formatTime(date: Date | string | number): string;
|
|
48
|
+
/** "5 minutes ago", "in 30 days": the largest whole unit that fits. */
|
|
49
|
+
export declare function fromNow(date: Date | string | number): string;
|
|
50
|
+
export {};
|
package/dist/date.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// src/lib/date.ts
|
|
2
|
+
const LOCALE = "en-US";
|
|
3
|
+
const PRESETS = {
|
|
4
|
+
/** Aug 30, 2026 */
|
|
5
|
+
PP: { dateStyle: "medium" },
|
|
6
|
+
/** August 30, 2026 */
|
|
7
|
+
PPP: { dateStyle: "long" },
|
|
8
|
+
/** Aug 30, 2026, 2:15 PM */
|
|
9
|
+
PPp: {
|
|
10
|
+
dateStyle: "medium",
|
|
11
|
+
timeStyle: "short"
|
|
12
|
+
},
|
|
13
|
+
/** August 30, 2026 at 2:15 PM */
|
|
14
|
+
PPPp: {
|
|
15
|
+
dateStyle: "long",
|
|
16
|
+
timeStyle: "short"
|
|
17
|
+
},
|
|
18
|
+
/** Aug 30 */
|
|
19
|
+
"MMM d": {
|
|
20
|
+
month: "short",
|
|
21
|
+
day: "numeric"
|
|
22
|
+
},
|
|
23
|
+
/** Aug 30, 14:15 */
|
|
24
|
+
"MMM d, HH:mm": {
|
|
25
|
+
month: "short",
|
|
26
|
+
day: "numeric",
|
|
27
|
+
hour: "2-digit",
|
|
28
|
+
minute: "2-digit",
|
|
29
|
+
hourCycle: "h23"
|
|
30
|
+
},
|
|
31
|
+
/** Aug 30, 14:15:09 */
|
|
32
|
+
"MMM d, HH:mm:ss": {
|
|
33
|
+
month: "short",
|
|
34
|
+
day: "numeric",
|
|
35
|
+
hour: "2-digit",
|
|
36
|
+
minute: "2-digit",
|
|
37
|
+
second: "2-digit",
|
|
38
|
+
hourCycle: "h23"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const formatters = /* @__PURE__ */ new Map();
|
|
42
|
+
function formatter(key, options) {
|
|
43
|
+
let cached = formatters.get(key);
|
|
44
|
+
if (!cached) {
|
|
45
|
+
cached = new Intl.DateTimeFormat(LOCALE, options);
|
|
46
|
+
formatters.set(key, cached);
|
|
47
|
+
}
|
|
48
|
+
return cached;
|
|
49
|
+
}
|
|
50
|
+
/** A stored UTC timestamp shown as its UTC wall-clock time, whatever the viewer's timezone. */
|
|
51
|
+
function formatUtc(date, preset) {
|
|
52
|
+
return formatter(`utc:${preset}`, {
|
|
53
|
+
...PRESETS[preset],
|
|
54
|
+
timeZone: "UTC"
|
|
55
|
+
}).format(new Date(date));
|
|
56
|
+
}
|
|
57
|
+
/** The viewer's local time of day, like 2:15 PM. */
|
|
58
|
+
function formatTime(date) {
|
|
59
|
+
return formatter("local:time", { timeStyle: "short" }).format(new Date(date));
|
|
60
|
+
}
|
|
61
|
+
const UNITS = [
|
|
62
|
+
["year", 31536e3],
|
|
63
|
+
["month", 2592e3],
|
|
64
|
+
["week", 604800],
|
|
65
|
+
["day", 86400],
|
|
66
|
+
["hour", 3600],
|
|
67
|
+
["minute", 60]
|
|
68
|
+
];
|
|
69
|
+
let relative;
|
|
70
|
+
/** "5 minutes ago", "in 30 days": the largest whole unit that fits. */
|
|
71
|
+
function fromNow(date) {
|
|
72
|
+
relative ??= new Intl.RelativeTimeFormat(LOCALE, { numeric: "auto" });
|
|
73
|
+
const seconds = (new Date(date).getTime() - Date.now()) / 1e3;
|
|
74
|
+
for (const [unit, size] of UNITS) if (Math.abs(seconds) >= size) return relative.format(Math.round(seconds / size), unit);
|
|
75
|
+
return relative.format(0, "second");
|
|
76
|
+
}
|
|
77
|
+
export { formatTime, formatUtc, fromNow };
|
package/dist/dialog.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RenderProp } from "./lib/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import * as dialog from "@zag-js/dialog";
|
|
4
|
+
export interface DialogProps extends Omit<dialog.Props, "id" | "ids" | "role"> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/** Owns the open state. Renders no element, so parts can sit anywhere inside it. */
|
|
8
|
+
export declare function Dialog({ children, ...props }: DialogProps): import("react").JSX.Element;
|
|
9
|
+
type PartProps<T extends "button" | "div" | "h2" | "p"> = ComponentProps<T> & {
|
|
10
|
+
/** Render your own element instead of the default one. */
|
|
11
|
+
render?: RenderProp;
|
|
12
|
+
};
|
|
13
|
+
export declare function DialogTrigger({ render, ...props }: PartProps<"button">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
export declare function DialogClose({ render, ...props }: PartProps<"button">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
15
|
+
/** The backdrop, centred panel and focus trap. Mounts only while open or leaving. */
|
|
16
|
+
export declare function DialogContent({ className, render, ...props }: PartProps<"div">): import("react").JSX.Element | null;
|
|
17
|
+
export declare function DialogHeader({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
18
|
+
export declare function DialogFooter({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
19
|
+
export declare function DialogTitle({ className, ...props }: ComponentProps<"h2">): import("react").JSX.Element;
|
|
20
|
+
export declare function DialogDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
21
|
+
export {};
|
package/dist/dialog.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
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 { useVisualViewportVars } from "./lib/visual-viewport.js";
|
|
7
|
+
import { useWaterDrop } from "./lib/water-drop.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 dialog from "@zag-js/dialog";
|
|
12
|
+
// src/components/dialog.tsx
|
|
13
|
+
const Context = createContext(null);
|
|
14
|
+
function useDialog() {
|
|
15
|
+
const api = useContext(Context);
|
|
16
|
+
if (!api) throw new Error("Dialog parts must be used inside <Dialog>.");
|
|
17
|
+
return api;
|
|
18
|
+
}
|
|
19
|
+
/** Owns the open state. Renders no element, so parts can sit anywhere inside it. */
|
|
20
|
+
function Dialog({ children, ...props }) {
|
|
21
|
+
const id = useId();
|
|
22
|
+
const service = useMachine(dialog.machine, {
|
|
23
|
+
id,
|
|
24
|
+
...props
|
|
25
|
+
});
|
|
26
|
+
const api = dialog.connect(service, normalizeProps);
|
|
27
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
28
|
+
value: api,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function DialogTrigger({ render, ...props }) {
|
|
33
|
+
const api = useDialog();
|
|
34
|
+
return renderPart("button", mergeProps({
|
|
35
|
+
...api.getTriggerProps(),
|
|
36
|
+
"data-slot": "dialog-trigger"
|
|
37
|
+
}, props), render);
|
|
38
|
+
}
|
|
39
|
+
function DialogClose({ render, ...props }) {
|
|
40
|
+
const { id: _id, ...closeProps } = useDialog().getCloseTriggerProps();
|
|
41
|
+
return renderPart("button", mergeProps({
|
|
42
|
+
...closeProps,
|
|
43
|
+
"data-slot": "dialog-close"
|
|
44
|
+
}, props), render);
|
|
45
|
+
}
|
|
46
|
+
/** The backdrop, centred panel and focus trap. Mounts only while open or leaving. */
|
|
47
|
+
function DialogContent({ className, render, ...props }) {
|
|
48
|
+
const api = useDialog();
|
|
49
|
+
const drop = useWaterDrop({
|
|
50
|
+
sourceId: api.getTriggerProps().id,
|
|
51
|
+
material: "glass-menu squircle [--squircle-radius:1.75rem]"
|
|
52
|
+
});
|
|
53
|
+
const { ref, mounted, attrs } = usePresence(api.open, drop);
|
|
54
|
+
const positioner = useRef(null);
|
|
55
|
+
useVisualViewportVars(positioner, mounted);
|
|
56
|
+
if (!mounted) return null;
|
|
57
|
+
const state = {
|
|
58
|
+
...attrs,
|
|
59
|
+
"data-open": api.open ? "" : void 0
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ jsxs(Portal, { children: [/* @__PURE__ */ jsx("div", {
|
|
62
|
+
...api.getBackdropProps(),
|
|
63
|
+
...state,
|
|
64
|
+
hidden: false,
|
|
65
|
+
"data-slot": "dialog-overlay",
|
|
66
|
+
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 motion-reduce:transition-none"
|
|
67
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
68
|
+
...api.getPositionerProps(),
|
|
69
|
+
ref: positioner,
|
|
70
|
+
className: "fixed inset-x-0 top-(--visual-viewport-top,0px) z-[60] flex h-(--visual-viewport-height,100dvh) items-center justify-center p-4",
|
|
71
|
+
children: renderPart("div", mergeProps({
|
|
72
|
+
...api.getContentProps(),
|
|
73
|
+
...state,
|
|
74
|
+
ref,
|
|
75
|
+
hidden: false,
|
|
76
|
+
"data-slot": "dialog-content",
|
|
77
|
+
className: cx("relative grid max-h-full w-full max-w-lg gap-4 overflow-y-auto glass-menu squircle morph-reset [--squircle-radius:1.75rem] p-6 text-label outline-none transition spring-smooth data-ending-style:scale-[0.88] data-starting-style:scale-[0.88] data-ending-style:opacity-0 data-starting-style:opacity-0 motion-reduce:transition-none motion-reduce:data-ending-style:scale-100 motion-reduce:data-starting-style:scale-100", className)
|
|
78
|
+
}, props), render)
|
|
79
|
+
})] });
|
|
80
|
+
}
|
|
81
|
+
function DialogHeader({ className, ...props }) {
|
|
82
|
+
return /* @__PURE__ */ jsx("div", {
|
|
83
|
+
"data-slot": "dialog-header",
|
|
84
|
+
className: cx("flex flex-col gap-1.5", className),
|
|
85
|
+
...props
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function DialogFooter({ className, ...props }) {
|
|
89
|
+
return /* @__PURE__ */ jsx("div", {
|
|
90
|
+
"data-slot": "dialog-footer",
|
|
91
|
+
className: cx("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
|
|
92
|
+
...props
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function DialogTitle({ className, ...props }) {
|
|
96
|
+
const api = useDialog();
|
|
97
|
+
return /* @__PURE__ */ jsx("h2", {
|
|
98
|
+
...api.getTitleProps(),
|
|
99
|
+
"data-slot": "dialog-title",
|
|
100
|
+
className: cx("text-headline font-semibold text-label", className),
|
|
101
|
+
...props
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function DialogDescription({ className, ...props }) {
|
|
105
|
+
const api = useDialog();
|
|
106
|
+
return /* @__PURE__ */ jsx("p", {
|
|
107
|
+
...api.getDescriptionProps(),
|
|
108
|
+
"data-slot": "dialog-description",
|
|
109
|
+
className: cx("text-footnote text-label-secondary", className),
|
|
110
|
+
...props
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger };
|
package/dist/drawer.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RenderProp } from "./lib/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import * as drawer from "@zag-js/drawer";
|
|
4
|
+
export interface DrawerProps extends Omit<drawer.Props, "id" | "ids" | "role" | "stack" | "swipeDirection" | "snapPoint" | "defaultSnapPoint"> {
|
|
5
|
+
/** Snap point to rest at first. Uncontrolled. */
|
|
6
|
+
defaultSnapPoint?: drawer.SnapPoint;
|
|
7
|
+
/** Controlled snap point. Pair with `onSnapPointChange`. */
|
|
8
|
+
activeSnapPoint?: drawer.SnapPoint | null;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** A bottom sheet you drag down to dismiss. Renders no element of its own. */
|
|
12
|
+
export declare function Drawer({ children, activeSnapPoint, ...props }: DrawerProps): import("react").JSX.Element;
|
|
13
|
+
type PartProps<T extends "button" | "div" | "h2" | "p"> = ComponentProps<T> & {
|
|
14
|
+
/** Render your own element instead of the default one. */
|
|
15
|
+
render?: RenderProp;
|
|
16
|
+
};
|
|
17
|
+
export declare function DrawerTrigger({ render, ...props }: PartProps<"button">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
18
|
+
export declare function DrawerClose({ render, ...props }: PartProps<"button">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
19
|
+
/**
|
|
20
|
+
* Backdrop, panel and focus trap. Mounts while open or leaving. As tall as its
|
|
21
|
+
* content, or as tall as the biggest numeric `snapPoints` entry.
|
|
22
|
+
*/
|
|
23
|
+
export declare function DrawerContent({ className, render, style, ...props }: PartProps<"div">): import("react").JSX.Element | null;
|
|
24
|
+
/** The grab handle. Dragging it moves the drawer even when the content scrolls. */
|
|
25
|
+
export declare function DrawerHandle({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
26
|
+
export declare function DrawerHeader({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
27
|
+
export declare function DrawerFooter({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
28
|
+
export declare function DrawerTitle({ className, ...props }: ComponentProps<"h2">): import("react").JSX.Element;
|
|
29
|
+
export declare function DrawerDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
|
|
30
|
+
export {};
|
package/dist/drawer.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "./lib/cx.js";
|
|
3
|
+
import { tallestSnapPoint } from "./lib/drawer.math.js";
|
|
4
|
+
import { usePageScale } from "./lib/page-scale.js";
|
|
5
|
+
import { Portal } from "./lib/portal.js";
|
|
6
|
+
import { usePresence } from "./lib/presence.js";
|
|
7
|
+
import { mergeProps, renderPart } from "./lib/render.js";
|
|
8
|
+
import { useSwipeTouchAction } from "./lib/swipe-touch-action.js";
|
|
9
|
+
import { useVisualViewportVars } from "./lib/visual-viewport.js";
|
|
10
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
11
|
+
import { createContext, useContext, useId, useRef } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import * as drawer from "@zag-js/drawer";
|
|
14
|
+
// src/components/drawer.tsx
|
|
15
|
+
const Context = createContext(null);
|
|
16
|
+
function useDrawer() {
|
|
17
|
+
const api = useContext(Context);
|
|
18
|
+
if (!api) throw new Error("Drawer parts must be used inside <Drawer>.");
|
|
19
|
+
return api;
|
|
20
|
+
}
|
|
21
|
+
/** A bottom sheet you drag down to dismiss. Renders no element of its own. */
|
|
22
|
+
function Drawer({ children, activeSnapPoint, ...props }) {
|
|
23
|
+
const id = useId();
|
|
24
|
+
const service = useMachine(drawer.machine, {
|
|
25
|
+
id,
|
|
26
|
+
swipeDirection: "down",
|
|
27
|
+
snapPoint: activeSnapPoint,
|
|
28
|
+
...props
|
|
29
|
+
});
|
|
30
|
+
const api = drawer.connect(service, normalizeProps);
|
|
31
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
32
|
+
value: api,
|
|
33
|
+
children
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function DrawerTrigger({ render, ...props }) {
|
|
37
|
+
const api = useDrawer();
|
|
38
|
+
return renderPart("button", mergeProps({
|
|
39
|
+
...api.getTriggerProps(),
|
|
40
|
+
"data-slot": "drawer-trigger"
|
|
41
|
+
}, props), render);
|
|
42
|
+
}
|
|
43
|
+
function DrawerClose({ render, ...props }) {
|
|
44
|
+
const { id: _id, ...closeProps } = useDrawer().getCloseTriggerProps();
|
|
45
|
+
return renderPart("button", mergeProps({
|
|
46
|
+
...closeProps,
|
|
47
|
+
"data-slot": "drawer-close"
|
|
48
|
+
}, props), render);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Backdrop, panel and focus trap. Mounts while open or leaving. As tall as its
|
|
52
|
+
* content, or as tall as the biggest numeric `snapPoints` entry.
|
|
53
|
+
*/
|
|
54
|
+
function DrawerContent({ className, render, style, ...props }) {
|
|
55
|
+
const api = useDrawer();
|
|
56
|
+
const id = useId();
|
|
57
|
+
const { ref, mounted, attrs } = usePresence(api.open);
|
|
58
|
+
const positioner = useRef(null);
|
|
59
|
+
useVisualViewportVars(positioner, mounted);
|
|
60
|
+
useSwipeTouchAction(ref, mounted, "y");
|
|
61
|
+
const openness = !api.open ? 0 : api.getContentSize() ? api.getOpenPercentage() : 1;
|
|
62
|
+
usePageScale(id, mounted, openness, api.dragging);
|
|
63
|
+
if (!mounted) return null;
|
|
64
|
+
const state = {
|
|
65
|
+
...attrs,
|
|
66
|
+
"data-open": api.open ? "" : void 0
|
|
67
|
+
};
|
|
68
|
+
const tallest = tallestSnapPoint(api.snapPoints);
|
|
69
|
+
return /* @__PURE__ */ jsxs(Portal, { children: [/* @__PURE__ */ jsx("div", {
|
|
70
|
+
...api.getBackdropProps(),
|
|
71
|
+
...state,
|
|
72
|
+
hidden: false,
|
|
73
|
+
"data-slot": "drawer-overlay",
|
|
74
|
+
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"
|
|
75
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
76
|
+
...api.getPositionerProps(),
|
|
77
|
+
ref: positioner,
|
|
78
|
+
hidden: false,
|
|
79
|
+
className: "fixed inset-x-0 top-(--visual-viewport-top,0px) z-[60] flex h-(--visual-viewport-height,100dvh) items-end justify-center",
|
|
80
|
+
children: renderPart("div", mergeProps({
|
|
81
|
+
...api.getContentProps(),
|
|
82
|
+
...state,
|
|
83
|
+
ref,
|
|
84
|
+
hidden: false,
|
|
85
|
+
"data-slot": "drawer-content",
|
|
86
|
+
style: {
|
|
87
|
+
...tallest ? { height: `${tallest * 100}%` } : null,
|
|
88
|
+
...style
|
|
89
|
+
},
|
|
90
|
+
className: cx("relative flex max-h-[calc(100%-1.625rem)] w-full max-w-xl flex-col overflow-y-auto overscroll-contain rounded-t-3xl glass-menu squircle pb-[env(safe-area-inset-bottom)] text-label outline-none transition-[transform,translate,scale] duration-(--duration-sheet) ease-(--ease-sheet) data-ending-style:translate-y-full data-starting-style:translate-y-full data-nested-drawer-open:origin-bottom data-nested-drawer-open:scale-[calc(1-0.04*var(--nested-drawers,0))] motion-reduce:transition-none motion-reduce:data-ending-style:translate-y-0 motion-reduce:data-starting-style:translate-y-0 motion-reduce:data-ending-style:opacity-0 motion-reduce:data-starting-style:opacity-0", className)
|
|
91
|
+
}, props), render)
|
|
92
|
+
})] });
|
|
93
|
+
}
|
|
94
|
+
/** The grab handle. Dragging it moves the drawer even when the content scrolls. */
|
|
95
|
+
function DrawerHandle({ className, ...props }) {
|
|
96
|
+
const api = useDrawer();
|
|
97
|
+
return /* @__PURE__ */ jsx("div", {
|
|
98
|
+
...api.getGrabberProps(),
|
|
99
|
+
"data-slot": "drawer-handle",
|
|
100
|
+
className: cx("flex h-6 w-full shrink-0 cursor-grab items-center justify-center", className),
|
|
101
|
+
...props,
|
|
102
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
103
|
+
...api.getGrabberIndicatorProps(),
|
|
104
|
+
className: "bg-label-secondary/40 h-1.5 w-10 rounded-full"
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function DrawerHeader({ className, ...props }) {
|
|
109
|
+
return /* @__PURE__ */ jsx("div", {
|
|
110
|
+
"data-slot": "drawer-header",
|
|
111
|
+
className: cx("flex flex-col gap-1.5 px-6 pt-2 text-center", className),
|
|
112
|
+
...props
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function DrawerFooter({ className, ...props }) {
|
|
116
|
+
return /* @__PURE__ */ jsx("div", {
|
|
117
|
+
"data-slot": "drawer-footer",
|
|
118
|
+
className: cx("mt-auto flex flex-col gap-2 p-6", className),
|
|
119
|
+
...props
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function DrawerTitle({ className, ...props }) {
|
|
123
|
+
const api = useDrawer();
|
|
124
|
+
return /* @__PURE__ */ jsx("h2", {
|
|
125
|
+
...api.getTitleProps(),
|
|
126
|
+
"data-slot": "drawer-title",
|
|
127
|
+
className: cx("text-headline font-semibold text-label", className),
|
|
128
|
+
...props
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function DrawerDescription({ className, ...props }) {
|
|
132
|
+
const api = useDrawer();
|
|
133
|
+
return /* @__PURE__ */ jsx("p", {
|
|
134
|
+
...api.getDescriptionProps(),
|
|
135
|
+
"data-slot": "drawer-description",
|
|
136
|
+
className: cx("text-footnote text-label-secondary", className),
|
|
137
|
+
...props
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
export { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHandle, DrawerHeader, DrawerTitle, DrawerTrigger };
|