@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/kbd.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/components/kbd.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Modifier names that read differently per platform: Apple shows its symbol,
|
|
6
|
+
* everyone else the word. Both are rendered and CSS picks one from `data-os`
|
|
7
|
+
* (set before first paint), so server and client markup always agree.
|
|
8
|
+
*/
|
|
9
|
+
const keys = {
|
|
10
|
+
mod: {
|
|
11
|
+
apple: "⌘",
|
|
12
|
+
other: "Ctrl"
|
|
13
|
+
},
|
|
14
|
+
cmd: {
|
|
15
|
+
apple: "⌘",
|
|
16
|
+
other: "Win"
|
|
17
|
+
},
|
|
18
|
+
ctrl: {
|
|
19
|
+
apple: "⌃",
|
|
20
|
+
other: "Ctrl"
|
|
21
|
+
},
|
|
22
|
+
alt: {
|
|
23
|
+
apple: "⌥",
|
|
24
|
+
other: "Alt"
|
|
25
|
+
},
|
|
26
|
+
option: {
|
|
27
|
+
apple: "⌥",
|
|
28
|
+
other: "Alt"
|
|
29
|
+
},
|
|
30
|
+
shift: {
|
|
31
|
+
apple: "⇧",
|
|
32
|
+
other: "Shift"
|
|
33
|
+
},
|
|
34
|
+
enter: {
|
|
35
|
+
apple: "↩",
|
|
36
|
+
other: "Enter"
|
|
37
|
+
},
|
|
38
|
+
backspace: {
|
|
39
|
+
apple: "⌫",
|
|
40
|
+
other: "Backspace"
|
|
41
|
+
},
|
|
42
|
+
delete: {
|
|
43
|
+
apple: "⌦",
|
|
44
|
+
other: "Del"
|
|
45
|
+
},
|
|
46
|
+
esc: {
|
|
47
|
+
apple: "⎋",
|
|
48
|
+
other: "Esc"
|
|
49
|
+
},
|
|
50
|
+
tab: {
|
|
51
|
+
apple: "⇥",
|
|
52
|
+
other: "Tab"
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const showApple = "hidden [:root[data-os=macos]_&]:inline [:root[data-os=ios]_&]:inline";
|
|
56
|
+
const showOther = "[:root[data-os=macos]_&]:hidden [:root[data-os=ios]_&]:hidden";
|
|
57
|
+
function renderKey(child) {
|
|
58
|
+
if (typeof child !== "string") return child;
|
|
59
|
+
const key = keys[child.toLowerCase()];
|
|
60
|
+
if (!key) return child;
|
|
61
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
62
|
+
"aria-hidden": "true",
|
|
63
|
+
className: showApple,
|
|
64
|
+
children: key.apple
|
|
65
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
66
|
+
className: showOther,
|
|
67
|
+
children: key.other
|
|
68
|
+
})] });
|
|
69
|
+
}
|
|
70
|
+
/** A keyboard key cap. Pass `Mod`, `Alt`, `Shift` and friends and the platform's own symbol shows. */
|
|
71
|
+
function Kbd({ className, children, ...props }) {
|
|
72
|
+
return /* @__PURE__ */ jsx("kbd", {
|
|
73
|
+
"data-slot": "kbd",
|
|
74
|
+
className: cx("pointer-events-none inline-flex h-5 min-w-5 select-none items-center justify-center gap-1 rounded-md bg-fill px-1.5 font-sans text-caption2 font-medium text-label-secondary shadow-[inset_0_-1px_0_var(--color-separator)]", className),
|
|
75
|
+
...props,
|
|
76
|
+
children: Array.isArray(children) ? children.map(renderKey) : renderKey(children)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function KbdGroup({ className, ...props }) {
|
|
80
|
+
return /* @__PURE__ */ jsx("span", {
|
|
81
|
+
"data-slot": "kbd-group",
|
|
82
|
+
className: cx("inline-flex items-center gap-1", className),
|
|
83
|
+
...props
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
export { Kbd, KbdGroup };
|
package/dist/label.d.ts
ADDED
package/dist/label.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/components/label.tsx
|
|
4
|
+
/** A native label. Pair it with a control through `htmlFor`. */
|
|
5
|
+
function Label({ className, ...props }) {
|
|
6
|
+
return /* @__PURE__ */ jsx("label", {
|
|
7
|
+
"data-slot": "label",
|
|
8
|
+
className: cx("flex select-none items-center gap-2 text-footnote font-medium leading-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
|
|
9
|
+
...props
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export { Label };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
export type LabeledContentSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface LabeledContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
/** The visible name of the row. */
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
/** Supporting text directly below the label. */
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
/** A glyph in a soft tile before the label, like a Settings row. */
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
/** The row's control or value. */
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
/** Places the control below the label at every width. @default false */
|
|
13
|
+
stacked?: boolean;
|
|
14
|
+
/** Places a wide control below its label on phones. @default false */
|
|
15
|
+
wide?: boolean;
|
|
16
|
+
/** Row padding density. @default "md" */
|
|
17
|
+
size?: LabeledContentSize;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A row: a label, an optional description, and its control at the trailing
|
|
21
|
+
* end, as SwiftUI's `LabeledContent`. Wide controls move under the label
|
|
22
|
+
* when there is no room beside it, rather than squeezing.
|
|
23
|
+
*/
|
|
24
|
+
export declare function LabeledContent({ label, description, icon, children, stacked, wide, size, className, ...props }: LabeledContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/components/labeled-content.tsx
|
|
4
|
+
const padding = {
|
|
5
|
+
sm: "px-3 py-1.5",
|
|
6
|
+
md: "px-4 py-2",
|
|
7
|
+
lg: "px-5 py-3"
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A row: a label, an optional description, and its control at the trailing
|
|
11
|
+
* end, as SwiftUI's `LabeledContent`. Wide controls move under the label
|
|
12
|
+
* when there is no room beside it, rather than squeezing.
|
|
13
|
+
*/
|
|
14
|
+
function LabeledContent({ label, description, icon, children, stacked, wide, size = "md", className, ...props }) {
|
|
15
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
"data-slot": "labeled-content",
|
|
17
|
+
className: cx("flex min-h-11 flex-wrap gap-x-4 gap-y-2", padding[size], stacked ? "flex-col items-stretch" : cx("items-center justify-between", wide && "max-sm:flex-col max-sm:items-stretch max-sm:gap-2"), className),
|
|
18
|
+
...props,
|
|
19
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: cx("flex min-w-0 flex-1 items-center gap-3 break-normal", !stacked && "basis-36", wide && "max-sm:basis-auto"),
|
|
21
|
+
children: [icon ? /* @__PURE__ */ jsx("span", {
|
|
22
|
+
"aria-hidden": "true",
|
|
23
|
+
className: "bg-fill text-label-secondary flex size-8 shrink-0 items-center justify-center rounded-lg [&_svg]:size-4",
|
|
24
|
+
children: icon
|
|
25
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
26
|
+
className: "flex min-w-0 flex-col gap-0",
|
|
27
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "text-subheadline text-label leading-tight",
|
|
29
|
+
children: label
|
|
30
|
+
}), description ? /* @__PURE__ */ jsx("span", {
|
|
31
|
+
className: "text-footnote text-label-secondary leading-snug",
|
|
32
|
+
children: description
|
|
33
|
+
}) : null]
|
|
34
|
+
})]
|
|
35
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: cx("ms-auto flex max-w-full min-w-0 shrink-0 justify-end [&>*]:max-w-full", stacked && "w-full", wide && "max-sm:w-full"),
|
|
37
|
+
children
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export { LabeledContent };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** A language's name in itself, capitalized: "Français", "中文". */
|
|
2
2
|
export declare function getNativeLanguageName(tag: string): string;
|
|
3
3
|
/** A language's name as read in `displayLocale`: "French" in English. */
|
|
4
|
-
export declare function getLocalizedLanguageName(tag: string, displayLocale: string): string;
|
|
4
|
+
export declare function getLocalizedLanguageName(tag: string, displayLocale: string): string;
|
package/dist/language.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/lib/language.ts
|
|
2
|
+
/** A language's name in itself, capitalized: "Français", "中文". */
|
|
3
|
+
function getNativeLanguageName(tag) {
|
|
4
|
+
const name = new Intl.DisplayNames([tag], { type: "language" }).of(tag);
|
|
5
|
+
return name ? name.charAt(0).toUpperCase() + name.slice(1) : tag;
|
|
6
|
+
}
|
|
7
|
+
/** A language's name as read in `displayLocale`: "French" in English. */
|
|
8
|
+
function getLocalizedLanguageName(tag, displayLocale) {
|
|
9
|
+
return new Intl.DisplayNames([displayLocale], { type: "language" }).of(tag) ?? tag;
|
|
10
|
+
}
|
|
11
|
+
export { getLocalizedLanguageName, getNativeLanguageName };
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PropsWithChildren, ReactNode } from "react";
|
|
2
|
+
type LayoutProps = PropsWithChildren<{
|
|
3
|
+
heading: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
}>;
|
|
6
|
+
type HeadingProps = {
|
|
7
|
+
/** The page title. Any node. */
|
|
8
|
+
title: ReactNode;
|
|
9
|
+
/** Sits directly under the title with no gap. Any node. */
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
/** Trailing control beside the title, such as a button or badge. */
|
|
12
|
+
action?: ReactNode;
|
|
13
|
+
size?: keyof typeof titleSizes;
|
|
14
|
+
};
|
|
15
|
+
declare const titleSizes: {
|
|
16
|
+
readonly default: "text-large-title leading-large-title";
|
|
17
|
+
readonly compact: "text-title leading-title font-semibold tracking-tight";
|
|
18
|
+
};
|
|
19
|
+
export declare function Layout({ heading, className, children }: LayoutProps): import("react").JSX.Element;
|
|
20
|
+
export declare namespace Layout {
|
|
21
|
+
export { Heading };
|
|
22
|
+
}
|
|
23
|
+
declare function Heading({ title, description, action, size }: HeadingProps): import("react").JSX.Element;
|
|
24
|
+
export {};
|
package/dist/layout.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { cx } from "./lib/cx.js";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/components/layout.tsx
|
|
4
|
+
const titleSizes = {
|
|
5
|
+
default: "text-large-title leading-large-title",
|
|
6
|
+
compact: "text-title leading-title font-semibold tracking-tight"
|
|
7
|
+
};
|
|
8
|
+
function Layout({ heading, className, children }) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("article", {
|
|
10
|
+
"data-slot": "layout",
|
|
11
|
+
className: cx("container mx-auto flex flex-col", "w-full gap-0 py-12 md:max-w-3xl", className),
|
|
12
|
+
children: [heading, /* @__PURE__ */ jsx("div", {
|
|
13
|
+
className: "mt-8 flex flex-col gap-6",
|
|
14
|
+
children
|
|
15
|
+
})]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function Heading({ title, description, action, size = "default" }) {
|
|
19
|
+
const centered = size === "compact";
|
|
20
|
+
return /* @__PURE__ */ jsxs("header", {
|
|
21
|
+
"data-slot": "layout-heading",
|
|
22
|
+
className: cx("flex flex-col gap-0", centered && "items-center text-center"),
|
|
23
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: cx("flex flex-wrap items-center gap-3", centered && "justify-center"),
|
|
25
|
+
children: [/* @__PURE__ */ jsx("h1", {
|
|
26
|
+
className: cx("m-0 min-w-0 wrap-anywhere", titleSizes[size]),
|
|
27
|
+
children: title
|
|
28
|
+
}), action]
|
|
29
|
+
}), description ? /* @__PURE__ */ jsx("div", {
|
|
30
|
+
className: cx("text-subheadline text-label-secondary m-0 max-w-prose leading-snug", centered && "text-center"),
|
|
31
|
+
children: description
|
|
32
|
+
}) : null]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
Layout.Heading = Heading;
|
|
36
|
+
export { Layout };
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
export interface AnchoredPlacement {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
left: number;
|
|
3
|
+
width: number;
|
|
4
|
+
top?: number;
|
|
5
|
+
bottom?: number;
|
|
6
|
+
/** Opens upward, so motion should grow from the bottom edge. */
|
|
7
|
+
above: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Set when the chosen side has less room than the panel needs: the
|
|
10
|
+
* panel scrolls inside this height instead of crossing the edge.
|
|
11
|
+
*/
|
|
12
|
+
maxHeight?: number;
|
|
13
13
|
}
|
|
14
14
|
/** The measurements placement decides on, so the math stays testable. */
|
|
15
15
|
export interface PlacementFrame {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
anchor: {
|
|
17
|
+
top: number;
|
|
18
|
+
bottom: number;
|
|
19
|
+
left: number;
|
|
20
|
+
};
|
|
21
|
+
viewport: {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
edges: {
|
|
26
|
+
top: number;
|
|
27
|
+
right: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
};
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Places a panel of `width` under its anchor, or above it when there's
|
|
@@ -36,4 +36,4 @@ export interface PlacementFrame {
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function placeInViewport({ anchor, viewport, edges }: PlacementFrame, width: number, needed: number, gap?: number, overlap?: boolean): AnchoredPlacement;
|
|
38
38
|
/** `placeInViewport` from live DOM measurements. */
|
|
39
|
-
export declare function placeAnchored(anchor: HTMLElement, width: number, needed: number, gap?: number, overlap?: boolean): AnchoredPlacement;
|
|
39
|
+
export declare function placeAnchored(anchor: HTMLElement, width: number, needed: number, gap?: number, overlap?: boolean): AnchoredPlacement;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { screenEdges } from "./screen-edges.js";
|
|
2
|
+
// src/lib/anchored-placement.ts
|
|
3
|
+
/**
|
|
4
|
+
* Places a panel of `width` under its anchor, or above it when there's
|
|
5
|
+
* less than `needed` height below and more room above, kept inside the
|
|
6
|
+
* screen's safe edges.
|
|
7
|
+
*/
|
|
8
|
+
function placeInViewport({ anchor, viewport, edges }, width, needed, gap = 6, overlap = false) {
|
|
9
|
+
if (overlap) gap = anchor.top - anchor.bottom;
|
|
10
|
+
const fitted = Math.min(width, viewport.width - edges.left - edges.right);
|
|
11
|
+
const left = Math.min(Math.max(edges.left, anchor.left), viewport.width - fitted - edges.right);
|
|
12
|
+
const roomBelow = viewport.height - anchor.bottom - gap - edges.bottom;
|
|
13
|
+
const roomAbove = anchor.top - gap - edges.top;
|
|
14
|
+
const above = roomBelow < needed && roomAbove > roomBelow;
|
|
15
|
+
const room = above ? roomAbove : roomBelow;
|
|
16
|
+
const placement = {
|
|
17
|
+
left,
|
|
18
|
+
width: fitted,
|
|
19
|
+
above,
|
|
20
|
+
...above ? { bottom: viewport.height - anchor.top + gap } : { top: anchor.bottom + gap }
|
|
21
|
+
};
|
|
22
|
+
if (room < needed) placement.maxHeight = room;
|
|
23
|
+
return placement;
|
|
24
|
+
}
|
|
25
|
+
/** `placeInViewport` from live DOM measurements. */
|
|
26
|
+
function placeAnchored(anchor, width, needed, gap = 6, overlap = false) {
|
|
27
|
+
const rect = anchor.getBoundingClientRect();
|
|
28
|
+
const viewport = window.visualViewport;
|
|
29
|
+
return placeInViewport({
|
|
30
|
+
anchor: {
|
|
31
|
+
top: rect.top,
|
|
32
|
+
bottom: rect.bottom,
|
|
33
|
+
left: rect.left
|
|
34
|
+
},
|
|
35
|
+
viewport: {
|
|
36
|
+
width: viewport?.width ?? window.innerWidth,
|
|
37
|
+
height: viewport?.height ?? window.innerHeight
|
|
38
|
+
},
|
|
39
|
+
edges: screenEdges()
|
|
40
|
+
}, width, needed, gap, overlap);
|
|
41
|
+
}
|
|
42
|
+
export { placeAnchored, placeInViewport };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// src/lib/calendar-month.ts
|
|
2
|
+
/** Reads `YYYY-MM-DD`; null for anything else, or a date that doesn't exist. */
|
|
3
|
+
function parseDay(value) {
|
|
4
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
5
|
+
if (!match) return null;
|
|
6
|
+
const [year, month, day] = [
|
|
7
|
+
Number(match[1]),
|
|
8
|
+
Number(match[2]),
|
|
9
|
+
Number(match[3])
|
|
10
|
+
];
|
|
11
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
12
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day ? {
|
|
13
|
+
year,
|
|
14
|
+
month,
|
|
15
|
+
day
|
|
16
|
+
} : null;
|
|
17
|
+
}
|
|
18
|
+
function formatDay({ year, month, day }) {
|
|
19
|
+
const pad = (value, width) => String(value).padStart(width, "0");
|
|
20
|
+
return `${pad(year, 4)}-${pad(month, 2)}-${pad(day, 2)}`;
|
|
21
|
+
}
|
|
22
|
+
/** Moves by whole days, across months and years. */
|
|
23
|
+
function addDays(day, count) {
|
|
24
|
+
const date = new Date(Date.UTC(day.year, day.month - 1, day.day + count));
|
|
25
|
+
return {
|
|
26
|
+
year: date.getUTCFullYear(),
|
|
27
|
+
month: date.getUTCMonth() + 1,
|
|
28
|
+
day: date.getUTCDate()
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Moves by months, keeping the day where the month allows (31 Jan + 1 is 28 or 29 Feb). */
|
|
32
|
+
function addMonths(day, count) {
|
|
33
|
+
const first = new Date(Date.UTC(day.year, day.month - 1 + count, 1));
|
|
34
|
+
const year = first.getUTCFullYear();
|
|
35
|
+
const month = first.getUTCMonth() + 1;
|
|
36
|
+
const last = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
37
|
+
return {
|
|
38
|
+
year,
|
|
39
|
+
month,
|
|
40
|
+
day: Math.min(day.day, last)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The first day of the week where `locale` is used, 1 (Monday) to 7
|
|
45
|
+
* (Sunday), from the browser where it knows, else Monday except in the
|
|
46
|
+
* places that start on Sunday.
|
|
47
|
+
*/
|
|
48
|
+
function firstWeekday(locale) {
|
|
49
|
+
try {
|
|
50
|
+
const info = new Intl.Locale(locale);
|
|
51
|
+
const first = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay;
|
|
52
|
+
if (first) return first;
|
|
53
|
+
const region = info.maximize().region ?? "";
|
|
54
|
+
return [
|
|
55
|
+
"US",
|
|
56
|
+
"CA",
|
|
57
|
+
"JP",
|
|
58
|
+
"KR",
|
|
59
|
+
"TW",
|
|
60
|
+
"BR",
|
|
61
|
+
"MX",
|
|
62
|
+
"IL",
|
|
63
|
+
"PH",
|
|
64
|
+
"IN"
|
|
65
|
+
].includes(region) ? 7 : 1;
|
|
66
|
+
} catch {
|
|
67
|
+
return 1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Six weeks covering `year`/`month`, starting on `firstDay` (1 to 7). */
|
|
71
|
+
function monthGrid(year, month, firstDay) {
|
|
72
|
+
const lead = ((new Date(Date.UTC(year, month - 1, 1)).getUTCDay() || 7) - firstDay + 7) % 7;
|
|
73
|
+
const start = addDays({
|
|
74
|
+
year,
|
|
75
|
+
month,
|
|
76
|
+
day: 1
|
|
77
|
+
}, -lead);
|
|
78
|
+
return Array.from({ length: 42 }, (_, index) => {
|
|
79
|
+
const day = addDays(start, index);
|
|
80
|
+
return {
|
|
81
|
+
...day,
|
|
82
|
+
inMonth: day.month === month && day.year === year
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** Whether `value` (`YYYY-MM-DD`) lies within the optional bounds. */
|
|
87
|
+
function withinBounds(value, min, max) {
|
|
88
|
+
return (!min || value >= min) && (!max || value <= max);
|
|
89
|
+
}
|
|
90
|
+
export { addDays, addMonths, firstWeekday, formatDay, monthGrid, parseDay, withinBounds };
|
package/dist/lib/cx.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { pageScale } from "@passui/tokens/motion";
|
|
2
|
+
// src/lib/drawer.math.ts
|
|
3
|
+
const clamp01 = (value) => Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
4
|
+
/**
|
|
5
|
+
* Page scale for a drawer that is `openness` open (0 closed, 1 fully open).
|
|
6
|
+
* Fully open the page ends `topOffset` px below the top of the screen:
|
|
7
|
+
* scale = (width - topOffset) / width, eased back to 1 as the drawer closes.
|
|
8
|
+
*/
|
|
9
|
+
function pageTransformAt(openness, viewportWidth) {
|
|
10
|
+
const o = clamp01(openness);
|
|
11
|
+
const width = Math.max(viewportWidth, 1);
|
|
12
|
+
return {
|
|
13
|
+
scale: 1 - (1 - Math.max(0, (width - pageScale.topOffset) / width)) * o,
|
|
14
|
+
radius: pageScale.radius * o,
|
|
15
|
+
translateY: pageScale.topOffset / 2 * o
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** With nested drawers the page stays as scaled as the most open one. */
|
|
19
|
+
function frontOpenness(layers) {
|
|
20
|
+
let max = 0;
|
|
21
|
+
for (const value of layers) max = Math.max(max, clamp01(value));
|
|
22
|
+
return max;
|
|
23
|
+
}
|
|
24
|
+
/** The tallest numeric snap point (a fraction of the viewport), or null if none. */
|
|
25
|
+
function tallestSnapPoint(snapPoints) {
|
|
26
|
+
const numbers = (snapPoints ?? []).filter((point) => typeof point === "number");
|
|
27
|
+
return numbers.length > 0 ? Math.max(...numbers) : null;
|
|
28
|
+
}
|
|
29
|
+
export { clamp01, frontOpenness, pageTransformAt, tallestSnapPoint };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/lib/floating-layers.ts
|
|
2
|
+
const FLOATING_LAYER = "data-floating-layer";
|
|
3
|
+
const anchors = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
/** Portals retain the ownership of the control that opened them. */
|
|
5
|
+
function registerFloatingLayer(layer, anchor) {
|
|
6
|
+
anchors.set(layer, anchor);
|
|
7
|
+
return () => anchors.delete(layer);
|
|
8
|
+
}
|
|
9
|
+
function ownsFloatingLayer(container, target) {
|
|
10
|
+
let layer = target?.closest(`[${FLOATING_LAYER}]`);
|
|
11
|
+
const visited = /* @__PURE__ */ new Set();
|
|
12
|
+
while (layer && !visited.has(layer)) {
|
|
13
|
+
visited.add(layer);
|
|
14
|
+
const anchor = anchors.get(layer);
|
|
15
|
+
if (!anchor) return false;
|
|
16
|
+
if (container.contains(anchor)) return true;
|
|
17
|
+
layer = anchor.closest(`[${FLOATING_LAYER}]`);
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
/** An element belongs to a surface either directly or through a portaled child layer. */
|
|
22
|
+
function belongsToFloatingSurface(surface, target) {
|
|
23
|
+
return Boolean(target && (surface.contains(target) || ownsFloatingLayer(surface, target)));
|
|
24
|
+
}
|
|
25
|
+
export { FLOATING_LAYER, belongsToFloatingSurface, ownsFloatingLayer, registerFloatingLayer };
|
|
@@ -5,4 +5,4 @@ export type HapticKind = "selection" | "light" | "medium" | "heavy" | "success"
|
|
|
5
5
|
* device (system haptics, a vibration, or nothing) and whether it's on.
|
|
6
6
|
*/
|
|
7
7
|
export declare function setHapticPlayer(next: (kind: HapticKind) => void): void;
|
|
8
|
-
export declare function haptic(kind: HapticKind): void;
|
|
8
|
+
export declare function haptic(kind: HapticKind): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/lib/haptics.ts
|
|
2
|
+
let player = () => {};
|
|
3
|
+
/**
|
|
4
|
+
* Components only ask for feedback; the app decides how it plays on this
|
|
5
|
+
* device (system haptics, a vibration, or nothing) and whether it's on.
|
|
6
|
+
*/
|
|
7
|
+
function setHapticPlayer(next) {
|
|
8
|
+
player = next;
|
|
9
|
+
}
|
|
10
|
+
function haptic(kind) {
|
|
11
|
+
player(kind);
|
|
12
|
+
}
|
|
13
|
+
export { haptic, setHapticPlayer };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { clampRange } from "./range-value.js";
|
|
2
|
+
// src/lib/liquid-step.ts
|
|
3
|
+
/** Bencho's frame-normalized liquid spring. See THIRD_PARTY_NOTICES.md. */
|
|
4
|
+
function stepLiquid(state, target, viscosity, dt) {
|
|
5
|
+
const soft = clampRange(viscosity, 0, 100) / 100;
|
|
6
|
+
target = clampRange(target, 0, 100);
|
|
7
|
+
dt = clampRange(dt, 0, 2.5);
|
|
8
|
+
if (soft === 0) return {
|
|
9
|
+
fill: target,
|
|
10
|
+
velocity: 0
|
|
11
|
+
};
|
|
12
|
+
const stiff = .34 - soft * .29;
|
|
13
|
+
const damp = .74 + soft * .22;
|
|
14
|
+
let velocity = (state.velocity + (target - state.fill) * stiff * dt) * damp ** dt;
|
|
15
|
+
let fill = state.fill + velocity * dt;
|
|
16
|
+
if (fill > 100) {
|
|
17
|
+
fill = 100;
|
|
18
|
+
velocity = -velocity * .42;
|
|
19
|
+
}
|
|
20
|
+
if (fill < 0) {
|
|
21
|
+
fill = 0;
|
|
22
|
+
velocity = -velocity * .42;
|
|
23
|
+
}
|
|
24
|
+
if (Math.abs(target - fill) < .02 && Math.abs(velocity) < .02) return {
|
|
25
|
+
fill: target,
|
|
26
|
+
velocity: 0
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
fill,
|
|
30
|
+
velocity
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export { stepLiquid };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { frontOpenness, pageTransformAt } from "./drawer.math.js";
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
|
+
// src/lib/page-scale.ts
|
|
4
|
+
/** Open drawers and how open each is. The page follows the most open one. */
|
|
5
|
+
const layers = /* @__PURE__ */ new Map();
|
|
6
|
+
let dragging = /* @__PURE__ */ new Set();
|
|
7
|
+
function apply() {
|
|
8
|
+
const page = document.querySelector("[data-passui-page]");
|
|
9
|
+
if (!page) return;
|
|
10
|
+
if (layers.size === 0) {
|
|
11
|
+
for (const name of [
|
|
12
|
+
"scale",
|
|
13
|
+
"radius",
|
|
14
|
+
"y"
|
|
15
|
+
]) page.style.removeProperty(`--passui-page-${name}`);
|
|
16
|
+
page.removeAttribute("data-passui-page-active");
|
|
17
|
+
page.removeAttribute("data-passui-page-dragging");
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const t = pageTransformAt(frontOpenness(layers.values()), window.innerWidth);
|
|
21
|
+
page.style.setProperty("--passui-page-scale", String(t.scale));
|
|
22
|
+
page.style.setProperty("--passui-page-radius", `${t.radius}px`);
|
|
23
|
+
page.style.setProperty("--passui-page-y", `${t.translateY}px`);
|
|
24
|
+
page.setAttribute("data-passui-page-active", "");
|
|
25
|
+
if (dragging.size > 0) page.setAttribute("data-passui-page-dragging", "");
|
|
26
|
+
else page.removeAttribute("data-passui-page-dragging");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Opt in page scaling for one drawer layer. Does nothing unless the app root
|
|
30
|
+
* carries `data-passui-page`. Pass `active` while the drawer is mounted and
|
|
31
|
+
* `openness` from 0 to 1, so the page eases back as the drawer leaves.
|
|
32
|
+
*/
|
|
33
|
+
function usePageScale(id, active, openness, swiping) {
|
|
34
|
+
useLayoutEffect(() => {
|
|
35
|
+
if (!active) {
|
|
36
|
+
layers.delete(id);
|
|
37
|
+
dragging.delete(id);
|
|
38
|
+
apply();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
layers.set(id, openness);
|
|
42
|
+
dragging = new Set(dragging);
|
|
43
|
+
if (swiping) dragging.add(id);
|
|
44
|
+
else dragging.delete(id);
|
|
45
|
+
apply();
|
|
46
|
+
}, [
|
|
47
|
+
id,
|
|
48
|
+
active,
|
|
49
|
+
openness,
|
|
50
|
+
swiping
|
|
51
|
+
]);
|
|
52
|
+
useLayoutEffect(() => () => {
|
|
53
|
+
layers.delete(id);
|
|
54
|
+
dragging.delete(id);
|
|
55
|
+
apply();
|
|
56
|
+
}, [id]);
|
|
57
|
+
}
|
|
58
|
+
export { usePageScale };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
// src/lib/portal.tsx
|
|
4
|
+
const subscribe = () => () => {};
|
|
5
|
+
/**
|
|
6
|
+
* Renders children into `document.body`. The server and the first hydration
|
|
7
|
+
* pass render nothing, so overlays never cause an id or markup mismatch.
|
|
8
|
+
*/
|
|
9
|
+
function Portal({ children, container }) {
|
|
10
|
+
return useSyncExternalStore(subscribe, () => true, () => false) ? createPortal(children, container ?? document.body) : null;
|
|
11
|
+
}
|
|
12
|
+
export { Portal };
|