@passui/react 0.1.47 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -109
- package/THIRD_PARTY_NOTICES.md +29 -0
- package/dist/accordion.d.ts +15 -0
- package/dist/accordion.js +93 -0
- package/dist/alert-dialog.d.ts +26 -0
- package/dist/alert-dialog.js +142 -0
- package/dist/alert.d.ts +10 -0
- package/dist/alert.js +28 -0
- package/dist/{types/src/components/ambient/ambient.d.ts → ambient.d.ts} +4 -4
- package/dist/ambient.js +22 -0
- package/dist/{types/src/appearance → appearance}/platform.d.ts +3 -3
- package/dist/appearance/platform.js +43 -0
- package/dist/appearance/theme.d.ts +71 -0
- package/dist/appearance/theme.js +236 -0
- package/dist/appearance.d.ts +3 -0
- package/dist/appearance.js +3 -0
- package/dist/{types/src/components/aspect-ratio/aspect-ratio.d.ts → aspect-ratio.d.ts} +4 -4
- package/dist/aspect-ratio.js +17 -0
- package/dist/avatar.d.ts +5 -0
- package/dist/avatar.js +43 -0
- package/dist/badge.d.ts +8 -0
- package/dist/badge.js +21 -0
- package/dist/breadcrumb.d.ts +13 -0
- package/dist/breadcrumb.js +63 -0
- package/dist/button-group.d.ts +5 -0
- package/dist/button-group.js +14 -0
- package/dist/button.d.ts +21 -0
- package/dist/button.js +58 -0
- package/dist/calendar.d.ts +35 -0
- package/dist/calendar.js +225 -0
- package/dist/card.d.ts +9 -0
- package/dist/card.js +54 -0
- package/dist/chart.d.ts +30 -0
- package/dist/chart.js +226 -0
- package/dist/checkbox.d.ts +13 -0
- package/dist/checkbox.js +53 -0
- package/dist/{types/src/lib/clipboard.d.ts → clipboard.d.ts} +1 -1
- package/dist/clipboard.js +16 -0
- package/dist/cn.d.ts +2 -0
- package/dist/cn.js +10 -0
- package/dist/code-block.d.ts +34 -0
- package/dist/code-block.js +87 -0
- package/dist/collapsible.d.ts +13 -0
- package/dist/collapsible.js +49 -0
- package/dist/combobox.d.ts +25 -0
- package/dist/combobox.js +112 -0
- package/dist/command.d.ts +22 -0
- package/dist/command.js +129 -0
- package/dist/components/toast/toast-store.d.ts +60 -0
- package/dist/components/toast/toast-store.js +96 -0
- package/dist/{types/src/components → components}/toast/toaster.d.ts +4 -4
- package/dist/components/toast/toaster.js +345 -0
- package/dist/context-menu.d.ts +2 -0
- package/dist/context-menu.js +2 -0
- package/dist/conversation.d.ts +48 -0
- package/dist/conversation.js +202 -0
- package/dist/date-time-picker.d.ts +50 -0
- package/dist/date-time-picker.js +235 -0
- package/dist/date.d.ts +50 -0
- package/dist/date.js +77 -0
- package/dist/dialog.d.ts +21 -0
- package/dist/dialog.js +113 -0
- package/dist/drawer.d.ts +30 -0
- package/dist/drawer.js +140 -0
- package/dist/dropdown-menu.d.ts +56 -0
- package/dist/dropdown-menu.js +295 -0
- package/dist/empty.d.ts +11 -0
- package/dist/empty.js +51 -0
- package/dist/field.d.ts +16 -0
- package/dist/field.js +47 -0
- package/{src/hooks/scroll/minimize-decision.ts → dist/hooks/scroll/minimize-decision.js} +3 -5
- package/dist/{types/src/hooks → hooks}/use-anchored-placement.d.ts +2 -2
- package/dist/hooks/use-anchored-placement.js +33 -0
- package/dist/{types/src/hooks → hooks}/use-minimize-on-scroll.d.ts +1 -1
- package/dist/hooks/use-minimize-on-scroll.js +59 -0
- package/dist/{types/src/hooks → hooks}/use-visual-viewport.d.ts +2 -2
- package/{src/hooks/use-visual-viewport.ts → dist/hooks/use-visual-viewport.js} +20 -35
- package/dist/hooks/viewport/types.d.ts +7 -0
- package/dist/hooks/viewport/viewport-metrics.js +13 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +80 -0
- package/dist/input-group.d.ts +17 -0
- package/dist/input-group.js +55 -0
- package/dist/input-otp.d.ts +13 -0
- package/dist/input-otp.js +36 -0
- package/dist/input.d.ts +4 -0
- package/dist/input.js +14 -0
- package/dist/item.d.ts +49 -0
- package/dist/item.js +142 -0
- package/dist/kbd.d.ts +4 -0
- package/dist/kbd.js +86 -0
- package/dist/label.d.ts +3 -0
- package/dist/label.js +12 -0
- package/dist/labeled-content.d.ts +24 -0
- package/dist/labeled-content.js +41 -0
- package/dist/{types/src/lib/language.d.ts → language.d.ts} +1 -1
- package/dist/language.js +11 -0
- package/dist/layout.d.ts +24 -0
- package/dist/layout.js +36 -0
- package/dist/{types/src/lib → lib}/anchored-placement.d.ts +27 -27
- package/dist/lib/anchored-placement.js +42 -0
- package/dist/lib/calendar-month.js +90 -0
- package/dist/lib/cx.js +6 -0
- package/dist/lib/drawer.math.js +29 -0
- package/dist/lib/floating-layers.d.ts +3 -0
- package/dist/lib/floating-layers.js +25 -0
- package/dist/{types/src/lib → lib}/haptics.d.ts +1 -1
- package/dist/lib/haptics.js +13 -0
- package/dist/lib/liquid-step.js +33 -0
- package/dist/lib/page-scale.js +58 -0
- package/dist/lib/portal.js +12 -0
- package/dist/lib/presence.js +53 -0
- package/dist/lib/range-value.js +25 -0
- package/dist/lib/render.d.ts +8 -0
- package/dist/lib/render.js +42 -0
- package/dist/lib/rolling-digit.js +83 -0
- package/dist/{types/src/lib → lib}/screen-edges.d.ts +5 -5
- package/dist/lib/screen-edges.js +30 -0
- package/dist/lib/swipe-touch-action.js +34 -0
- package/dist/lib/visual-viewport.js +27 -0
- package/dist/lib/water-drop.js +412 -0
- package/dist/lib/wheel.js +125 -0
- package/dist/list.d.ts +26 -0
- package/dist/list.js +80 -0
- package/dist/locales.d.ts +18 -0
- package/dist/locales.js +36 -0
- package/dist/marker.d.ts +13 -0
- package/dist/marker.js +33 -0
- package/dist/motion/transitions.d.ts +170 -0
- package/dist/motion/transitions.js +156 -0
- package/dist/pagination.d.ts +30 -0
- package/dist/pagination.js +117 -0
- package/dist/popover.d.ts +26 -0
- package/dist/popover.js +101 -0
- package/dist/progress.d.ts +9 -0
- package/dist/progress.js +24 -0
- package/dist/questionnaire.d.ts +46 -0
- package/dist/questionnaire.js +133 -0
- package/dist/radio-group.d.ts +21 -0
- package/dist/radio-group.js +67 -0
- package/dist/search-field.d.ts +18 -0
- package/dist/search-field.js +45 -0
- package/dist/segmented-control.d.ts +16 -0
- package/dist/segmented-control.js +25 -0
- package/dist/select.d.ts +24 -0
- package/dist/select.js +107 -0
- package/dist/separator.d.ts +9 -0
- package/dist/separator.js +17 -0
- package/dist/{types/src/lib/shapes.d.ts → shapes.d.ts} +2 -2
- package/dist/shapes.js +65 -0
- package/dist/sheet.d.ts +24 -0
- package/dist/sheet.js +141 -0
- package/dist/sidebar.d.ts +32 -0
- package/dist/sidebar.js +85 -0
- package/dist/skeleton.d.ts +3 -0
- package/dist/skeleton.js +13 -0
- package/dist/slider.d.ts +9 -0
- package/dist/slider.js +42 -0
- package/dist/slosh-slider.d.ts +21 -0
- package/dist/slosh-slider.js +205 -0
- package/dist/spinner.d.ts +3 -0
- package/dist/spinner.js +20 -0
- package/dist/stat-tile.d.ts +20 -0
- package/dist/stat-tile.js +53 -0
- package/dist/stepper.d.ts +22 -0
- package/dist/stepper.js +98 -0
- package/dist/swatch-picker.d.ts +22 -0
- package/dist/swatch-picker.js +70 -0
- package/dist/switch.d.ts +10 -0
- package/dist/switch.js +44 -0
- package/dist/tab-bar.d.ts +15 -0
- package/dist/tab-bar.js +34 -0
- package/dist/{types/src/components/table/table.d.ts → table.d.ts} +3 -3
- package/dist/table.js +93 -0
- package/dist/tabs.d.ts +32 -0
- package/dist/tabs.js +131 -0
- package/dist/text.d.ts +25 -0
- package/dist/text.js +44 -0
- package/dist/textarea.d.ts +3 -0
- package/dist/textarea.js +13 -0
- package/dist/toast.d.ts +3 -0
- package/dist/toast.js +3 -0
- package/dist/toggle-group.d.ts +20 -0
- package/dist/toggle-group.js +68 -0
- package/dist/toggle.d.ts +24 -0
- package/dist/toggle.js +37 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tooltip.d.ts +21 -0
- package/dist/tooltip.js +61 -0
- package/dist/trace.d.ts +14 -0
- package/dist/trace.js +54 -0
- package/dist/{types/src/hooks/use-dismiss.d.ts → use-dismiss.d.ts} +3 -3
- package/dist/use-dismiss.js +38 -0
- package/dist/{types/src/hooks/use-media-query.d.ts → use-media-query.d.ts} +12 -12
- package/dist/use-media-query.js +56 -0
- package/dist/use-os.d.ts +12 -0
- package/dist/use-os.js +17 -0
- package/dist/wake-slider.d.ts +15 -0
- package/dist/wake-slider.js +174 -0
- package/package.json +122 -253
- package/src/styles/code-block.css +4 -0
- package/src/styles/globals.css +5 -0
- package/src/styles/motion-controls.css +10 -0
- package/src/styles/page-scale.css +27 -0
- package/src/styles/styles.css +4 -2
- package/dist/types/src/appearance/index.d.ts +0 -2
- package/dist/types/src/appearance/theme.d.ts +0 -71
- package/dist/types/src/components/accordion/accordion.d.ts +0 -23
- package/dist/types/src/components/ambient/index.d.ts +0 -1
- package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +0 -19
- package/dist/types/src/components/button/button-styles.d.ts +0 -12
- package/dist/types/src/components/button/button.d.ts +0 -32
- package/dist/types/src/components/button/icon-button.d.ts +0 -10
- package/dist/types/src/components/button/pending-spinner.d.ts +0 -5
- package/dist/types/src/components/button/use-pending-indicator.d.ts +0 -2
- package/dist/types/src/components/chip/chip.d.ts +0 -10
- package/dist/types/src/components/code-block/code-block.d.ts +0 -13
- package/dist/types/src/components/combo-box/combo-box.d.ts +0 -9
- package/dist/types/src/components/command/command.d.ts +0 -18
- package/dist/types/src/components/compact-date-picker/calendar-month.d.ts +0 -25
- package/dist/types/src/components/compact-date-picker/compact-date-picker.d.ts +0 -30
- package/dist/types/src/components/compact-time-picker/compact-time-picker.d.ts +0 -29
- package/dist/types/src/components/compact-time-picker/time-value.d.ts +0 -18
- package/dist/types/src/components/content-unavailable-view/content-unavailable-view.d.ts +0 -12
- package/dist/types/src/components/content-view/content-view.d.ts +0 -51
- package/dist/types/src/components/content-view/index.d.ts +0 -1
- package/dist/types/src/components/context-menu/conceal-menu-source.d.ts +0 -2
- package/dist/types/src/components/context-menu/context-menu-host.d.ts +0 -2
- package/dist/types/src/components/context-menu/context-menu-store.d.ts +0 -62
- package/dist/types/src/components/context-menu/menu-navigation.d.ts +0 -6
- package/dist/types/src/components/context-menu/menu-position.d.ts +0 -21
- package/dist/types/src/components/context-menu/menu-reveal.d.ts +0 -26
- package/dist/types/src/components/context-menu/use-context-menu.d.ts +0 -14
- package/dist/types/src/components/conversation/conversation.d.ts +0 -48
- package/dist/types/src/components/conversation/index.d.ts +0 -1
- package/dist/types/src/components/date-picker/date-picker.d.ts +0 -19
- package/dist/types/src/components/date-picker/date-value.d.ts +0 -2
- package/dist/types/src/components/dialog/dialog-host.d.ts +0 -6
- package/dist/types/src/components/dialog/dialog-store.d.ts +0 -23
- package/dist/types/src/components/dialog/dialog.d.ts +0 -33
- package/dist/types/src/components/dialog/index.d.ts +0 -1
- package/dist/types/src/components/disclosure-group/disclosure-group.d.ts +0 -18
- package/dist/types/src/components/divider/divider.d.ts +0 -9
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +0 -15
- package/dist/types/src/components/keyboard-shortcut/keyboard-shortcut.d.ts +0 -8
- package/dist/types/src/components/labeled-content/labeled-content.d.ts +0 -22
- package/dist/types/src/components/locale-switcher/index.d.ts +0 -1
- package/dist/types/src/components/locale-switcher/locale-switcher.d.ts +0 -13
- package/dist/types/src/components/menu/menu.d.ts +0 -16
- package/dist/types/src/components/morph/index.d.ts +0 -2
- package/dist/types/src/components/morph/morph.d.ts +0 -32
- package/dist/types/src/components/morph/use-morph-disclosure.d.ts +0 -13
- package/dist/types/src/components/one-time-code/one-time-code.d.ts +0 -26
- package/dist/types/src/components/picker/picker-trigger.d.ts +0 -3
- package/dist/types/src/components/picker/picker.d.ts +0 -46
- package/dist/types/src/components/popover/anchored-surface.d.ts +0 -17
- package/dist/types/src/components/popover/index.d.ts +0 -41
- package/dist/types/src/components/popover/popover-content.d.ts +0 -38
- package/dist/types/src/components/popover/popover-root.d.ts +0 -22
- package/dist/types/src/components/popover/popover-trigger.d.ts +0 -23
- package/dist/types/src/components/profile-image/profile-image.d.ts +0 -9
- package/dist/types/src/components/progress-view/progress-view.d.ts +0 -13
- package/dist/types/src/components/progress-view/use-liquid-progress.d.ts +0 -3
- package/dist/types/src/components/radio-group/radio-group.d.ts +0 -20
- package/dist/types/src/components/search-field/expanding-search-field.d.ts +0 -5
- package/dist/types/src/components/search-field/search-field.d.ts +0 -9
- package/dist/types/src/components/search-list/search-list.d.ts +0 -22
- package/dist/types/src/components/section/section.d.ts +0 -18
- package/dist/types/src/components/secure-field/secure-field.d.ts +0 -4
- package/dist/types/src/components/segmented-control/segmented-control.d.ts +0 -25
- package/dist/types/src/components/sheet/modal-environment.d.ts +0 -2
- package/dist/types/src/components/sheet/sheet-portal.d.ts +0 -5
- package/dist/types/src/components/sheet/sheet.d.ts +0 -26
- package/dist/types/src/components/sheet/use-sheet-focus.d.ts +0 -3
- package/dist/types/src/components/sidebar/sidebar.d.ts +0 -24
- package/dist/types/src/components/skeleton/skeleton.d.ts +0 -9
- package/dist/types/src/components/slider/slider.d.ts +0 -17
- package/dist/types/src/components/slosh-slider/liquid-step.d.ts +0 -6
- package/dist/types/src/components/slosh-slider/slosh-slider.d.ts +0 -21
- package/dist/types/src/components/stat-tile/index.d.ts +0 -1
- package/dist/types/src/components/stat-tile/stat-tile.d.ts +0 -20
- package/dist/types/src/components/status-indicator/status-indicator.d.ts +0 -17
- package/dist/types/src/components/stepper/rolling-digit.d.ts +0 -11
- package/dist/types/src/components/stepper/stepper.d.ts +0 -22
- package/dist/types/src/components/swatch-picker/swatch-picker.d.ts +0 -22
- package/dist/types/src/components/tab-bar/tab-bar.d.ts +0 -43
- package/dist/types/src/components/tab-view/tab-view.d.ts +0 -27
- package/dist/types/src/components/text-editor/text-editor.d.ts +0 -9
- package/dist/types/src/components/text-field/text-field.d.ts +0 -33
- package/dist/types/src/components/toast/toast-store.d.ts +0 -52
- package/dist/types/src/components/toggle/toggle.d.ts +0 -22
- package/dist/types/src/components/tooltip/tooltip-host.d.ts +0 -7
- package/dist/types/src/components/view-controller/index.d.ts +0 -1
- package/dist/types/src/components/view-controller/view-controller.d.ts +0 -21
- package/dist/types/src/components/wake-slider/wake-slider.d.ts +0 -15
- package/dist/types/src/hooks/scroll/minimize-decision.d.ts +0 -2
- package/dist/types/src/hooks/use-anchored-disclosure.d.ts +0 -9
- package/dist/types/src/hooks/use-floating-dismiss.d.ts +0 -3
- package/dist/types/src/hooks/viewport/types.d.ts +0 -19
- package/dist/types/src/hooks/viewport/viewport-metrics.d.ts +0 -3
- package/dist/types/src/icons/icons.d.ts +0 -616
- package/dist/types/src/index.d.ts +0 -73
- package/dist/types/src/lib/class-names.d.ts +0 -2
- package/dist/types/src/lib/date.d.ts +0 -50
- package/dist/types/src/lib/floating-layers.d.ts +0 -8
- package/dist/types/src/lib/range-value.d.ts +0 -4
- package/dist/types/src/machines/popover.machine.d.ts +0 -30
- package/dist/types/src/motion/transitions.d.ts +0 -170
- package/src/appearance/index.ts +0 -2
- package/src/appearance/platform.tsx +0 -102
- package/src/appearance/theme.tsx +0 -467
- package/src/components/accordion/accordion.tsx +0 -70
- package/src/components/ambient/ambient.tsx +0 -35
- package/src/components/ambient/index.ts +0 -1
- package/src/components/aspect-ratio/aspect-ratio.tsx +0 -27
- package/src/components/breadcrumb/breadcrumb.tsx +0 -73
- package/src/components/button/button-styles.ts +0 -49
- package/src/components/button/button.tsx +0 -107
- package/src/components/button/icon-button.tsx +0 -33
- package/src/components/button/pending-spinner.tsx +0 -14
- package/src/components/button/use-pending-indicator.ts +0 -22
- package/src/components/chip/chip.tsx +0 -45
- package/src/components/code-block/code-block.tsx +0 -48
- package/src/components/combo-box/combo-box.tsx +0 -13
- package/src/components/command/command.tsx +0 -149
- package/src/components/compact-date-picker/calendar-month.ts +0 -109
- package/src/components/compact-date-picker/compact-date-picker.tsx +0 -337
- package/src/components/compact-time-picker/compact-time-picker.tsx +0 -321
- package/src/components/compact-time-picker/time-value.ts +0 -58
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +0 -78
- package/src/components/content-view/content-view.tsx +0 -215
- package/src/components/content-view/index.ts +0 -1
- package/src/components/context-menu/conceal-menu-source.ts +0 -30
- package/src/components/context-menu/context-menu-host.tsx +0 -459
- package/src/components/context-menu/context-menu-store.ts +0 -167
- package/src/components/context-menu/menu-navigation.ts +0 -36
- package/src/components/context-menu/menu-position.ts +0 -38
- package/src/components/context-menu/menu-reveal.ts +0 -42
- package/src/components/context-menu/use-context-menu.ts +0 -73
- package/src/components/conversation/conversation.tsx +0 -309
- package/src/components/conversation/index.ts +0 -1
- package/src/components/date-picker/date-picker.tsx +0 -106
- package/src/components/date-picker/date-value.ts +0 -22
- package/src/components/dialog/dialog-host.tsx +0 -119
- package/src/components/dialog/dialog-store.ts +0 -66
- package/src/components/dialog/dialog.tsx +0 -211
- package/src/components/dialog/index.ts +0 -1
- package/src/components/disclosure-group/disclosure-group.tsx +0 -108
- package/src/components/divider/divider.tsx +0 -33
- package/src/components/inline-disclosure/inline-disclosure.tsx +0 -53
- package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +0 -32
- package/src/components/labeled-content/labeled-content.tsx +0 -84
- package/src/components/locale-switcher/index.ts +0 -1
- package/src/components/locale-switcher/locale-switcher.tsx +0 -310
- package/src/components/menu/menu.tsx +0 -85
- package/src/components/morph/index.ts +0 -2
- package/src/components/morph/morph.tsx +0 -258
- package/src/components/morph/use-morph-disclosure.ts +0 -27
- package/src/components/one-time-code/one-time-code.tsx +0 -234
- package/src/components/picker/picker-trigger.ts +0 -22
- package/src/components/picker/picker.tsx +0 -404
- package/src/components/popover/anchored-surface.tsx +0 -264
- package/src/components/popover/index.ts +0 -50
- package/src/components/popover/popover-content.tsx +0 -374
- package/src/components/popover/popover-root.tsx +0 -97
- package/src/components/popover/popover-trigger.tsx +0 -71
- package/src/components/profile-image/profile-image.tsx +0 -96
- package/src/components/progress-view/progress-view.tsx +0 -72
- package/src/components/progress-view/use-liquid-progress.ts +0 -43
- package/src/components/radio-group/radio-group.tsx +0 -86
- package/src/components/search-field/expanding-search-field.tsx +0 -197
- package/src/components/search-field/search-field.tsx +0 -66
- package/src/components/search-list/search-list.tsx +0 -276
- package/src/components/section/section.tsx +0 -75
- package/src/components/secure-field/secure-field.tsx +0 -8
- package/src/components/segmented-control/segmented-control.tsx +0 -157
- package/src/components/sheet/modal-environment.ts +0 -82
- package/src/components/sheet/sheet-portal.tsx +0 -62
- package/src/components/sheet/sheet.tsx +0 -165
- package/src/components/sheet/use-sheet-focus.ts +0 -109
- package/src/components/sidebar/sidebar.tsx +0 -102
- package/src/components/skeleton/skeleton.tsx +0 -38
- package/src/components/slider/slider.tsx +0 -134
- package/src/components/slosh-slider/liquid-step.ts +0 -43
- package/src/components/slosh-slider/slosh-slider.tsx +0 -294
- package/src/components/stat-tile/index.ts +0 -1
- package/src/components/stat-tile/stat-tile.tsx +0 -90
- package/src/components/status-indicator/status-indicator.tsx +0 -54
- package/src/components/stepper/rolling-digit.tsx +0 -91
- package/src/components/stepper/stepper.tsx +0 -136
- package/src/components/swatch-picker/swatch-picker.tsx +0 -138
- package/src/components/tab-bar/tab-bar.tsx +0 -182
- package/src/components/tab-view/tab-view.tsx +0 -155
- package/src/components/table/table.tsx +0 -151
- package/src/components/text-editor/text-editor.tsx +0 -42
- package/src/components/text-field/text-field.tsx +0 -200
- package/src/components/toast/toast-store.ts +0 -164
- package/src/components/toast/toaster.tsx +0 -407
- package/src/components/toggle/toggle.tsx +0 -320
- package/src/components/tooltip/tooltip-host.tsx +0 -178
- package/src/components/view-controller/index.ts +0 -1
- package/src/components/view-controller/view-controller.tsx +0 -75
- package/src/components/wake-slider/wake-slider.tsx +0 -260
- package/src/hooks/use-anchored-disclosure.ts +0 -23
- package/src/hooks/use-anchored-placement.ts +0 -40
- package/src/hooks/use-dismiss.ts +0 -44
- package/src/hooks/use-floating-dismiss.ts +0 -30
- package/src/hooks/use-media-query.ts +0 -94
- package/src/hooks/use-minimize-on-scroll.ts +0 -77
- package/src/hooks/viewport/types.ts +0 -19
- package/src/hooks/viewport/viewport-metrics.ts +0 -19
- package/src/icons/icons.tsx +0 -458
- package/src/index.ts +0 -107
- package/src/lib/anchored-placement.ts +0 -91
- package/src/lib/class-names.ts +0 -21
- package/src/lib/clipboard.ts +0 -15
- package/src/lib/date.ts +0 -86
- package/src/lib/floating-layers.ts +0 -53
- package/src/lib/haptics.ts +0 -23
- package/src/lib/language.ts +0 -16
- package/src/lib/range-value.ts +0 -38
- package/src/lib/screen-edges.ts +0 -44
- package/src/lib/shapes.ts +0 -59
- package/src/machines/popover.machine.ts +0 -51
- package/src/motion/transitions.ts +0 -97
- package/src/tokens.ts +0 -1
- /package/dist/{types/src/tokens.d.ts → tokens.js} +0 -0
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type CSSProperties,
|
|
3
|
-
type InputHTMLAttributes,
|
|
4
|
-
type Ref,
|
|
5
|
-
useEffect,
|
|
6
|
-
useId,
|
|
7
|
-
useRef,
|
|
8
|
-
} from "react";
|
|
9
|
-
import { CheckIcon } from "../../icons/icons";
|
|
10
|
-
import { cn } from "../../lib/class-names";
|
|
11
|
-
|
|
12
|
-
export type OneTimeCodeStatus = "idle" | "verifying" | "success" | "error";
|
|
13
|
-
export type OneTimeCodeFormat = "numeric" | "alphanumeric";
|
|
14
|
-
export type OneTimeCodeSize = "sm" | "md" | "lg";
|
|
15
|
-
|
|
16
|
-
const checkSizes: Record<OneTimeCodeSize, number> = {
|
|
17
|
-
sm: 20,
|
|
18
|
-
md: 24,
|
|
19
|
-
lg: 28,
|
|
20
|
-
};
|
|
21
|
-
const statusText: Record<OneTimeCodeSize, string> = {
|
|
22
|
-
sm: "mt-1.5 text-caption2",
|
|
23
|
-
md: "mt-2 text-footnote",
|
|
24
|
-
lg: "mt-2.5 text-subheadline",
|
|
25
|
-
};
|
|
26
|
-
export interface OneTimeCodeProps
|
|
27
|
-
extends Omit<
|
|
28
|
-
InputHTMLAttributes<HTMLInputElement>,
|
|
29
|
-
"value" | "defaultValue" | "onChange" | "type" | "maxLength" | "size"
|
|
30
|
-
> {
|
|
31
|
-
label: string;
|
|
32
|
-
value: string;
|
|
33
|
-
onChange: (value: string) => void;
|
|
34
|
-
/** Called when a complete code is entered, including paste and autofill. */
|
|
35
|
-
onComplete?: (value: string) => void;
|
|
36
|
-
/** Number of characters, 3–8. @default 6 */
|
|
37
|
-
length?: number;
|
|
38
|
-
/** Accepted characters. Alphanumeric codes use uppercase ASCII letters and digits. @default "numeric" */
|
|
39
|
-
format?: OneTimeCodeFormat;
|
|
40
|
-
/** Ref to the single native input, for focus and selection. */
|
|
41
|
-
ref?: Ref<HTMLInputElement>;
|
|
42
|
-
status?: OneTimeCodeStatus;
|
|
43
|
-
/** Localized verification feedback announced without reading decorative cells. */
|
|
44
|
-
statusLabel?: string;
|
|
45
|
-
/** Cell height, digit text scale and check icon size. @default "md" */
|
|
46
|
-
size?: OneTimeCodeSize;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** Normalize common numeric keyboards and optional ASCII letters in one native field. */
|
|
50
|
-
export function normalizeCode(
|
|
51
|
-
value: string,
|
|
52
|
-
length: number,
|
|
53
|
-
format: OneTimeCodeFormat = "numeric",
|
|
54
|
-
) {
|
|
55
|
-
return Array.from(value, (digit) => {
|
|
56
|
-
const point = digit.codePointAt(0) ?? 0;
|
|
57
|
-
for (const base of [0x30, 0x660, 0x6f0, 0xff10]) {
|
|
58
|
-
if (point >= base && point < base + 10) return String(point - base);
|
|
59
|
-
}
|
|
60
|
-
return format === "alphanumeric" && /^[a-z]$/i.test(digit)
|
|
61
|
-
? digit.toUpperCase()
|
|
62
|
-
: "";
|
|
63
|
-
})
|
|
64
|
-
.join("")
|
|
65
|
-
.slice(0, length);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/** Six cells, one field: paste, autofill, selection and Backspace stay native. */
|
|
69
|
-
export function OneTimeCode({
|
|
70
|
-
label,
|
|
71
|
-
value,
|
|
72
|
-
onChange,
|
|
73
|
-
onComplete,
|
|
74
|
-
length = 6,
|
|
75
|
-
format = "numeric",
|
|
76
|
-
ref,
|
|
77
|
-
status = "idle",
|
|
78
|
-
statusLabel,
|
|
79
|
-
size = "md",
|
|
80
|
-
className,
|
|
81
|
-
disabled,
|
|
82
|
-
id: suppliedId,
|
|
83
|
-
...props
|
|
84
|
-
}: OneTimeCodeProps) {
|
|
85
|
-
const generated = useId();
|
|
86
|
-
const id = suppliedId ?? generated;
|
|
87
|
-
const filter = `otp-goo-${generated.replace(/:/g, "")}`;
|
|
88
|
-
const input = useRef<HTMLInputElement>(null);
|
|
89
|
-
const count = Number.isFinite(length)
|
|
90
|
-
? Math.max(3, Math.min(8, Math.round(length)))
|
|
91
|
-
: 6;
|
|
92
|
-
const code = normalizeCode(value, count, format);
|
|
93
|
-
const locked =
|
|
94
|
-
disabled ||
|
|
95
|
-
props.readOnly ||
|
|
96
|
-
status === "verifying" ||
|
|
97
|
-
status === "success";
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
if (status === "error") input.current?.select();
|
|
100
|
-
}, [status]);
|
|
101
|
-
const update = (next: string) => {
|
|
102
|
-
if (locked) return;
|
|
103
|
-
const normalized = normalizeCode(next, count, format);
|
|
104
|
-
onChange(normalized);
|
|
105
|
-
if (normalized.length === count && normalized !== code)
|
|
106
|
-
onComplete?.(normalized);
|
|
107
|
-
};
|
|
108
|
-
return (
|
|
109
|
-
<div
|
|
110
|
-
className={cn("passui-one-time-code not-typeset", className)}
|
|
111
|
-
data-status={status}
|
|
112
|
-
data-size={size}
|
|
113
|
-
style={
|
|
114
|
-
{
|
|
115
|
-
"--otp-length": count,
|
|
116
|
-
"--otp-middle": (count - 1) / 2,
|
|
117
|
-
} as CSSProperties
|
|
118
|
-
}
|
|
119
|
-
>
|
|
120
|
-
<svg aria-hidden="true" width="0" height="0" className="absolute">
|
|
121
|
-
<defs>
|
|
122
|
-
<filter
|
|
123
|
-
id={filter}
|
|
124
|
-
x="-20%"
|
|
125
|
-
y="-50%"
|
|
126
|
-
width="140%"
|
|
127
|
-
height="200%"
|
|
128
|
-
colorInterpolationFilters="sRGB"
|
|
129
|
-
>
|
|
130
|
-
<feGaussianBlur stdDeviation="3" result="smear" />
|
|
131
|
-
<feColorMatrix
|
|
132
|
-
in="smear"
|
|
133
|
-
type="matrix"
|
|
134
|
-
values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 24 -10"
|
|
135
|
-
/>
|
|
136
|
-
</filter>
|
|
137
|
-
</defs>
|
|
138
|
-
</svg>
|
|
139
|
-
<div className="passui-otp-row" dir="ltr">
|
|
140
|
-
{/* A right code fuses: cells converge on one point while a capsule
|
|
141
|
-
grows there. The filter joins the material, never the digits. */}
|
|
142
|
-
<div
|
|
143
|
-
aria-hidden="true"
|
|
144
|
-
className="passui-otp-materials"
|
|
145
|
-
style={{ filter: `url(#${filter})` }}
|
|
146
|
-
>
|
|
147
|
-
{Array.from({ length: count }, (_, index) => (
|
|
148
|
-
<span
|
|
149
|
-
key={index}
|
|
150
|
-
className="passui-otp-cell"
|
|
151
|
-
style={{ "--otp-index": index } as CSSProperties}
|
|
152
|
-
/>
|
|
153
|
-
))}
|
|
154
|
-
<span className="passui-otp-capsule" />
|
|
155
|
-
</div>
|
|
156
|
-
<div aria-hidden="true" className="passui-otp-digits">
|
|
157
|
-
{Array.from({ length: count }, (_, index) => (
|
|
158
|
-
<span
|
|
159
|
-
key={index}
|
|
160
|
-
className="passui-otp-digit"
|
|
161
|
-
data-active={
|
|
162
|
-
index === Math.min(code.length, count - 1) || undefined
|
|
163
|
-
}
|
|
164
|
-
style={{ "--otp-index": index } as CSSProperties}
|
|
165
|
-
>
|
|
166
|
-
{code[index] && (
|
|
167
|
-
<span key={code[index] ?? index} className="passui-otp-glyph">
|
|
168
|
-
{code[index]}
|
|
169
|
-
</span>
|
|
170
|
-
)}
|
|
171
|
-
</span>
|
|
172
|
-
))}
|
|
173
|
-
</div>
|
|
174
|
-
<CheckIcon
|
|
175
|
-
aria-hidden="true"
|
|
176
|
-
className="passui-otp-check"
|
|
177
|
-
size={checkSizes[size]}
|
|
178
|
-
/>
|
|
179
|
-
<input
|
|
180
|
-
{...props}
|
|
181
|
-
ref={(node) => {
|
|
182
|
-
input.current = node;
|
|
183
|
-
if (typeof ref === "function") return ref(node);
|
|
184
|
-
if (ref) ref.current = node;
|
|
185
|
-
}}
|
|
186
|
-
id={id}
|
|
187
|
-
type="text"
|
|
188
|
-
inputMode={format === "numeric" ? "numeric" : "text"}
|
|
189
|
-
autoComplete={props.autoComplete ?? "one-time-code"}
|
|
190
|
-
autoCapitalize={format === "alphanumeric" ? "characters" : "off"}
|
|
191
|
-
spellCheck={false}
|
|
192
|
-
pattern={format === "numeric" ? "[0-9]*" : "[A-Za-z0-9]*"}
|
|
193
|
-
maxLength={count}
|
|
194
|
-
minLength={count}
|
|
195
|
-
aria-label={label}
|
|
196
|
-
value={code}
|
|
197
|
-
disabled={disabled}
|
|
198
|
-
readOnly={locked}
|
|
199
|
-
aria-busy={status === "verifying" || undefined}
|
|
200
|
-
aria-invalid={status === "error" || props["aria-invalid"]}
|
|
201
|
-
aria-describedby={
|
|
202
|
-
[props["aria-describedby"], statusLabel && `${id}-status`]
|
|
203
|
-
.filter(Boolean)
|
|
204
|
-
.join(" ") || undefined
|
|
205
|
-
}
|
|
206
|
-
onChange={(event) => update(event.target.value)}
|
|
207
|
-
onPaste={(event) => {
|
|
208
|
-
props.onPaste?.(event);
|
|
209
|
-
if (event.defaultPrevented || locked) return;
|
|
210
|
-
const pasted = event.clipboardData.getData("text");
|
|
211
|
-
const normalized = normalizeCode(pasted, count, format);
|
|
212
|
-
if (normalized && normalized !== pasted) {
|
|
213
|
-
event.preventDefault();
|
|
214
|
-
update(normalized);
|
|
215
|
-
}
|
|
216
|
-
}}
|
|
217
|
-
className="passui-otp-input"
|
|
218
|
-
/>
|
|
219
|
-
</div>
|
|
220
|
-
{statusLabel && (
|
|
221
|
-
<p
|
|
222
|
-
id={`${id}-status`}
|
|
223
|
-
role="status"
|
|
224
|
-
className={cn(
|
|
225
|
-
statusText[size],
|
|
226
|
-
status === "error" ? "text-danger" : "text-label-secondary",
|
|
227
|
-
)}
|
|
228
|
-
>
|
|
229
|
-
{statusLabel}
|
|
230
|
-
</p>
|
|
231
|
-
)}
|
|
232
|
-
</div>
|
|
233
|
-
);
|
|
234
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { cn } from "../../lib/class-names";
|
|
2
|
-
|
|
3
|
-
export type PickerSize = "sm" | "md" | "lg";
|
|
4
|
-
|
|
5
|
-
const triggerSizes: Record<PickerSize, string> = {
|
|
6
|
-
sm: "px-2.5 py-1.5 text-caption rounded-lg",
|
|
7
|
-
md: "px-3 py-2 text-subheadline rounded-lg",
|
|
8
|
-
lg: "px-4 py-3 text-body rounded-xl",
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/** Shared field treatment for the popup-based Picker, date and time controls. */
|
|
12
|
-
export function pickerTriggerStyle(
|
|
13
|
-
className?: string,
|
|
14
|
-
size: PickerSize = "md",
|
|
15
|
-
) {
|
|
16
|
-
return cn(
|
|
17
|
-
"control-field text-label flex w-full min-w-0 items-center gap-2 text-start",
|
|
18
|
-
"disabled:cursor-not-allowed disabled:opacity-40",
|
|
19
|
-
triggerSizes[size],
|
|
20
|
-
className,
|
|
21
|
-
);
|
|
22
|
-
}
|
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import { useAnchoredDisclosure } from "../../hooks/use-anchored-disclosure";
|
|
2
|
-
import {
|
|
3
|
-
type KeyboardEvent,
|
|
4
|
-
useCallback,
|
|
5
|
-
useEffect,
|
|
6
|
-
useId,
|
|
7
|
-
useMemo,
|
|
8
|
-
useRef,
|
|
9
|
-
useState,
|
|
10
|
-
} from "react";
|
|
11
|
-
import { createPortal } from "react-dom";
|
|
12
|
-
import { CheckIcon, SearchIcon, SelectorIcon } from "../../icons/icons";
|
|
13
|
-
import { cn } from "../../lib/class-names";
|
|
14
|
-
import { haptic } from "../../lib/haptics";
|
|
15
|
-
import { AnchoredSurface } from "../popover/anchored-surface";
|
|
16
|
-
import { pickerTriggerStyle, type PickerSize } from "./picker-trigger";
|
|
17
|
-
|
|
18
|
-
export interface PickerOption<T extends string> {
|
|
19
|
-
value: T;
|
|
20
|
-
label: string;
|
|
21
|
-
/** A quieter second line or trailing note, such as "Free" or a region. */
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
keywords?: string[];
|
|
24
|
-
detail?: string;
|
|
25
|
-
/** The option's own language, so it is spoken and shaped right. */
|
|
26
|
-
lang?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Values and callbacks share the option value type, including literal unions. */
|
|
30
|
-
export interface PickerProps<T extends string> {
|
|
31
|
-
/** The selected option's value. */
|
|
32
|
-
value: T;
|
|
33
|
-
/** Available choices. Use a literal union for a fixed set of values. */
|
|
34
|
-
options: ReadonlyArray<PickerOption<T>>;
|
|
35
|
-
/** Called with the selected option value. */
|
|
36
|
-
onChange: (value: NoInfer<T>) => void;
|
|
37
|
-
/** Accessible name for the trigger. */
|
|
38
|
-
label: string;
|
|
39
|
-
/** Shown when the selected value has no matching option. */
|
|
40
|
-
placeholder?: string;
|
|
41
|
-
/** Defaults to on for lists of ten or more options. */
|
|
42
|
-
searchable?: boolean;
|
|
43
|
-
/** Label for the filter field. @default "Search" */
|
|
44
|
-
searchPlaceholder?: string;
|
|
45
|
-
/** Shown when the filter matches nothing. @default "No matches" */
|
|
46
|
-
emptyLabel?: string;
|
|
47
|
-
/** Offers a new value when no option has the same label or value. */
|
|
48
|
-
onCreate?: (query: string) => void;
|
|
49
|
-
/** Localized creation action; receives the trimmed query. */
|
|
50
|
-
createLabel?: (query: string) => string;
|
|
51
|
-
className?: string;
|
|
52
|
-
/** Prevents opening or choosing an option. @default false */
|
|
53
|
-
disabled?: boolean;
|
|
54
|
-
/** Trigger height and text scale. @default "md" */
|
|
55
|
-
size?: PickerSize;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Long lists get a filter field, as in the system pickers. */
|
|
59
|
-
const SEARCH_FROM = 10;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* A pop-up button: shows the chosen value and opens a list that floats
|
|
63
|
-
* above everything, flips upward near the bottom edge and filters long
|
|
64
|
-
* lists. Replaces the browser's own select, which looks foreign on every
|
|
65
|
-
* platform.
|
|
66
|
-
*/
|
|
67
|
-
export function Picker<T extends string>({
|
|
68
|
-
value,
|
|
69
|
-
options,
|
|
70
|
-
onChange,
|
|
71
|
-
label,
|
|
72
|
-
placeholder,
|
|
73
|
-
searchable,
|
|
74
|
-
searchPlaceholder = "Search",
|
|
75
|
-
emptyLabel = "No matches",
|
|
76
|
-
className,
|
|
77
|
-
onCreate,
|
|
78
|
-
createLabel,
|
|
79
|
-
disabled = false,
|
|
80
|
-
size = "md",
|
|
81
|
-
}: PickerProps<T>) {
|
|
82
|
-
const panel = useAnchoredDisclosure(disabled);
|
|
83
|
-
const { open } = panel;
|
|
84
|
-
const trigger = useRef<HTMLButtonElement>(null);
|
|
85
|
-
const listId = useId();
|
|
86
|
-
const selected = options.find((option) => option.value === value);
|
|
87
|
-
|
|
88
|
-
const close = useCallback(
|
|
89
|
-
(refocus: boolean) => {
|
|
90
|
-
panel.close();
|
|
91
|
-
if (refocus) trigger.current?.focus({ preventScroll: true });
|
|
92
|
-
},
|
|
93
|
-
[panel.close],
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const onTriggerKey = (event: KeyboardEvent<HTMLButtonElement>) => {
|
|
97
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
98
|
-
event.preventDefault();
|
|
99
|
-
panel.show();
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<>
|
|
105
|
-
<button
|
|
106
|
-
ref={trigger}
|
|
107
|
-
type="button"
|
|
108
|
-
role="combobox"
|
|
109
|
-
aria-label={label}
|
|
110
|
-
aria-haspopup="listbox"
|
|
111
|
-
aria-expanded={open && !disabled}
|
|
112
|
-
aria-controls={open && !disabled ? listId : undefined}
|
|
113
|
-
disabled={disabled}
|
|
114
|
-
onClick={() => panel.toggle()}
|
|
115
|
-
onKeyDown={onTriggerKey}
|
|
116
|
-
className={pickerTriggerStyle(className, size)}
|
|
117
|
-
>
|
|
118
|
-
<span
|
|
119
|
-
lang={selected?.lang}
|
|
120
|
-
className={cn(
|
|
121
|
-
"min-w-0 grow truncate",
|
|
122
|
-
!selected && "text-label-tertiary",
|
|
123
|
-
)}
|
|
124
|
-
>
|
|
125
|
-
{selected?.label ?? placeholder ?? ""}
|
|
126
|
-
</span>
|
|
127
|
-
<SelectorIcon
|
|
128
|
-
size={15}
|
|
129
|
-
strokeWidth={2}
|
|
130
|
-
className="text-label-tertiary shrink-0"
|
|
131
|
-
/>
|
|
132
|
-
</button>
|
|
133
|
-
{typeof document !== "undefined" &&
|
|
134
|
-
createPortal(
|
|
135
|
-
panel.mounted && trigger.current ? (
|
|
136
|
-
<SelectList
|
|
137
|
-
open={open}
|
|
138
|
-
onExited={panel.onExited}
|
|
139
|
-
id={listId}
|
|
140
|
-
anchor={trigger.current}
|
|
141
|
-
options={options}
|
|
142
|
-
value={value}
|
|
143
|
-
label={label}
|
|
144
|
-
searchable={
|
|
145
|
-
searchable ??
|
|
146
|
-
(Boolean(onCreate) || options.length >= SEARCH_FROM)
|
|
147
|
-
}
|
|
148
|
-
searchPlaceholder={searchPlaceholder}
|
|
149
|
-
emptyLabel={emptyLabel}
|
|
150
|
-
onCreate={onCreate}
|
|
151
|
-
createLabel={createLabel}
|
|
152
|
-
onPick={(next) => {
|
|
153
|
-
close(true);
|
|
154
|
-
if (next === value) return;
|
|
155
|
-
haptic("selection");
|
|
156
|
-
onChange(next);
|
|
157
|
-
}}
|
|
158
|
-
onClose={close}
|
|
159
|
-
/>
|
|
160
|
-
) : null,
|
|
161
|
-
document.body,
|
|
162
|
-
)}
|
|
163
|
-
</>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function SelectList<T extends string>({
|
|
168
|
-
open,
|
|
169
|
-
onExited,
|
|
170
|
-
id,
|
|
171
|
-
anchor,
|
|
172
|
-
options,
|
|
173
|
-
value,
|
|
174
|
-
label,
|
|
175
|
-
searchable,
|
|
176
|
-
searchPlaceholder,
|
|
177
|
-
emptyLabel,
|
|
178
|
-
onPick,
|
|
179
|
-
onClose,
|
|
180
|
-
onCreate,
|
|
181
|
-
createLabel,
|
|
182
|
-
}: {
|
|
183
|
-
open: boolean;
|
|
184
|
-
onExited: () => void;
|
|
185
|
-
id: string;
|
|
186
|
-
anchor: HTMLElement;
|
|
187
|
-
options: ReadonlyArray<PickerOption<T>>;
|
|
188
|
-
value: T;
|
|
189
|
-
label: string;
|
|
190
|
-
searchable: boolean;
|
|
191
|
-
searchPlaceholder: string;
|
|
192
|
-
emptyLabel: string;
|
|
193
|
-
onCreate?: (query: string) => void;
|
|
194
|
-
createLabel?: (query: string) => string;
|
|
195
|
-
onPick: (value: T) => void;
|
|
196
|
-
onClose: (refocus: boolean) => void;
|
|
197
|
-
}) {
|
|
198
|
-
const list = useRef<HTMLDivElement>(null);
|
|
199
|
-
const search = useRef<HTMLInputElement>(null);
|
|
200
|
-
const [query, setQuery] = useState("");
|
|
201
|
-
const typed = useRef({ text: "", at: 0 });
|
|
202
|
-
|
|
203
|
-
const shown = useMemo(() => {
|
|
204
|
-
const needle = query.trim().toLocaleLowerCase();
|
|
205
|
-
if (!needle) return options;
|
|
206
|
-
return options.filter((option) =>
|
|
207
|
-
`${option.label} ${option.detail ?? ""} ${option.value} ${(option.keywords ?? []).join(" ")}`
|
|
208
|
-
.toLocaleLowerCase()
|
|
209
|
-
.includes(needle),
|
|
210
|
-
);
|
|
211
|
-
}, [options, query]);
|
|
212
|
-
|
|
213
|
-
const enabled = shown.filter((option) => !option.disabled);
|
|
214
|
-
const trimmed = query.trim();
|
|
215
|
-
const canCreate = Boolean(
|
|
216
|
-
onCreate &&
|
|
217
|
-
trimmed &&
|
|
218
|
-
!options.some(
|
|
219
|
-
(option) =>
|
|
220
|
-
option.label.toLocaleLowerCase() === trimmed.toLocaleLowerCase() ||
|
|
221
|
-
option.value.toLocaleLowerCase() === trimmed.toLocaleLowerCase(),
|
|
222
|
-
),
|
|
223
|
-
);
|
|
224
|
-
const create = () => {
|
|
225
|
-
if (!canCreate) return;
|
|
226
|
-
onClose(true);
|
|
227
|
-
onCreate?.(trimmed);
|
|
228
|
-
};
|
|
229
|
-
const [active, setActive] = useState(() =>
|
|
230
|
-
Math.max(
|
|
231
|
-
0,
|
|
232
|
-
options
|
|
233
|
-
.filter((option) => !option.disabled)
|
|
234
|
-
.findIndex((option) => option.value === value),
|
|
235
|
-
),
|
|
236
|
-
);
|
|
237
|
-
const last = enabled.length + (canCreate ? 1 : 0) - 1;
|
|
238
|
-
const activeOption = enabled[Math.min(active, last)];
|
|
239
|
-
const activeId = activeOption
|
|
240
|
-
? `${id}-${activeOption.value}`
|
|
241
|
-
: canCreate
|
|
242
|
-
? `${id}-create`
|
|
243
|
-
: undefined;
|
|
244
|
-
|
|
245
|
-
useEffect(() => {
|
|
246
|
-
if (searchable) search.current?.focus();
|
|
247
|
-
else list.current?.focus();
|
|
248
|
-
}, [searchable]);
|
|
249
|
-
|
|
250
|
-
// The chosen option starts in view, then follows the keyboard.
|
|
251
|
-
useEffect(() => {
|
|
252
|
-
if (!activeOption) return;
|
|
253
|
-
list.current
|
|
254
|
-
?.querySelector(`[data-value="${CSS.escape(activeOption.value)}"]`)
|
|
255
|
-
?.scrollIntoView({ block: "nearest" });
|
|
256
|
-
}, [activeOption]);
|
|
257
|
-
|
|
258
|
-
const onKeyDown = (event: KeyboardEvent) => {
|
|
259
|
-
const step = (to: number) => {
|
|
260
|
-
event.preventDefault();
|
|
261
|
-
setActive(Math.max(0, Math.min(last, to)));
|
|
262
|
-
};
|
|
263
|
-
const current = Math.min(active, last);
|
|
264
|
-
if (event.key === "ArrowDown") step(current + 1);
|
|
265
|
-
else if (event.key === "ArrowUp") step(current - 1);
|
|
266
|
-
else if (event.key === "Home" && !searchable) step(0);
|
|
267
|
-
else if (event.key === "End" && !searchable) step(last);
|
|
268
|
-
else if (event.key === "PageDown") step(current + 8);
|
|
269
|
-
else if (event.key === "PageUp") step(current - 8);
|
|
270
|
-
else if (event.key === "Enter" || (event.key === " " && !searchable)) {
|
|
271
|
-
event.preventDefault();
|
|
272
|
-
if (activeOption) onPick(activeOption.value);
|
|
273
|
-
else if (canCreate) create();
|
|
274
|
-
} else if (event.key === "Escape") {
|
|
275
|
-
event.preventDefault();
|
|
276
|
-
event.stopPropagation();
|
|
277
|
-
onClose(true);
|
|
278
|
-
} else if (event.key === "Tab") {
|
|
279
|
-
onClose(false);
|
|
280
|
-
} else if (
|
|
281
|
-
!searchable &&
|
|
282
|
-
event.key.length === 1 &&
|
|
283
|
-
!event.metaKey &&
|
|
284
|
-
!event.ctrlKey
|
|
285
|
-
) {
|
|
286
|
-
// Type to jump, as in a native pop-up button.
|
|
287
|
-
const now = Date.now();
|
|
288
|
-
const text =
|
|
289
|
-
(now - typed.current.at < 700 ? typed.current.text : "") + event.key;
|
|
290
|
-
typed.current = { text, at: now };
|
|
291
|
-
const match = enabled.findIndex((option) =>
|
|
292
|
-
option.label.toLocaleLowerCase().startsWith(text.toLocaleLowerCase()),
|
|
293
|
-
);
|
|
294
|
-
if (match >= 0) setActive(match);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
return (
|
|
299
|
-
<AnchoredSurface
|
|
300
|
-
open={open}
|
|
301
|
-
onExited={onExited}
|
|
302
|
-
anchor={anchor}
|
|
303
|
-
width={Math.min(Math.max(anchor.getBoundingClientRect().width, 220), 360)}
|
|
304
|
-
needed={240}
|
|
305
|
-
onClose={onClose}
|
|
306
|
-
onKeyDown={onKeyDown}
|
|
307
|
-
contentClassName="overflow-hidden"
|
|
308
|
-
>
|
|
309
|
-
{searchable && (
|
|
310
|
-
<div className="border-separator/70 flex shrink-0 items-center gap-2 border-b px-3 py-2">
|
|
311
|
-
<SearchIcon size={15} className="text-label-tertiary shrink-0" />
|
|
312
|
-
<input
|
|
313
|
-
ref={search}
|
|
314
|
-
value={query}
|
|
315
|
-
placeholder={searchPlaceholder}
|
|
316
|
-
aria-label={searchPlaceholder}
|
|
317
|
-
aria-controls={id}
|
|
318
|
-
aria-activedescendant={activeId}
|
|
319
|
-
onChange={(event) => {
|
|
320
|
-
setQuery(event.target.value);
|
|
321
|
-
setActive(0);
|
|
322
|
-
}}
|
|
323
|
-
className="text-subheadline text-label placeholder:text-label-tertiary min-w-0 grow bg-transparent outline-none"
|
|
324
|
-
/>
|
|
325
|
-
</div>
|
|
326
|
-
)}
|
|
327
|
-
<div
|
|
328
|
-
ref={list}
|
|
329
|
-
id={id}
|
|
330
|
-
role="listbox"
|
|
331
|
-
aria-label={label}
|
|
332
|
-
tabIndex={-1}
|
|
333
|
-
aria-activedescendant={activeId}
|
|
334
|
-
className="no-scrollbar flex min-h-0 flex-col overflow-y-auto overscroll-contain p-1.5 outline-none"
|
|
335
|
-
>
|
|
336
|
-
{shown.map((option) => {
|
|
337
|
-
const chosen = option.value === value;
|
|
338
|
-
const focused = option === activeOption;
|
|
339
|
-
return (
|
|
340
|
-
// biome-ignore lint/a11y/useKeyWithClickEvents: option div handles keyboard via role=option and aria-selected
|
|
341
|
-
<div
|
|
342
|
-
key={option.value}
|
|
343
|
-
id={`${id}-${option.value}`}
|
|
344
|
-
data-value={option.value}
|
|
345
|
-
role="option"
|
|
346
|
-
tabIndex={-1}
|
|
347
|
-
aria-selected={chosen}
|
|
348
|
-
aria-disabled={option.disabled || undefined}
|
|
349
|
-
lang={option.lang}
|
|
350
|
-
onPointerMove={() =>
|
|
351
|
-
!option.disabled && setActive(enabled.indexOf(option))
|
|
352
|
-
}
|
|
353
|
-
onClick={() => !option.disabled && onPick(option.value)}
|
|
354
|
-
className={cn(
|
|
355
|
-
"text-subheadline flex min-h-8 cursor-default items-center gap-2 rounded-lg px-2 py-1.5 [@media(pointer:coarse)]:min-h-11",
|
|
356
|
-
focused ? "bg-fill" : "",
|
|
357
|
-
option.disabled && "opacity-40",
|
|
358
|
-
chosen ? "text-label font-semibold" : "text-label",
|
|
359
|
-
)}
|
|
360
|
-
>
|
|
361
|
-
<span className="flex w-4 shrink-0 justify-center">
|
|
362
|
-
{chosen && (
|
|
363
|
-
<CheckIcon
|
|
364
|
-
size={15}
|
|
365
|
-
strokeWidth={2.4}
|
|
366
|
-
className="text-accent-text"
|
|
367
|
-
/>
|
|
368
|
-
)}
|
|
369
|
-
</span>
|
|
370
|
-
<span className="min-w-0 grow break-words">{option.label}</span>
|
|
371
|
-
{option.detail && (
|
|
372
|
-
<span className="text-caption text-label-tertiary shrink-0 font-normal">
|
|
373
|
-
{option.detail}
|
|
374
|
-
</span>
|
|
375
|
-
)}
|
|
376
|
-
</div>
|
|
377
|
-
);
|
|
378
|
-
})}
|
|
379
|
-
{canCreate && (
|
|
380
|
-
// biome-ignore lint/a11y/useKeyWithClickEvents: create div handles keyboard via role=option
|
|
381
|
-
<div
|
|
382
|
-
id={`${id}-create`}
|
|
383
|
-
role="option"
|
|
384
|
-
aria-selected={false}
|
|
385
|
-
tabIndex={-1}
|
|
386
|
-
onPointerMove={() => setActive(enabled.length)}
|
|
387
|
-
onClick={create}
|
|
388
|
-
className={cn(
|
|
389
|
-
"text-subheadline text-accent-text flex min-h-9 cursor-default items-center rounded-lg px-2 py-1.5",
|
|
390
|
-
!activeOption && "bg-fill",
|
|
391
|
-
)}
|
|
392
|
-
>
|
|
393
|
-
{createLabel?.(trimmed) ?? trimmed}
|
|
394
|
-
</div>
|
|
395
|
-
)}
|
|
396
|
-
{shown.length === 0 && !canCreate && (
|
|
397
|
-
<p className="text-footnote text-label-tertiary px-3 py-2">
|
|
398
|
-
{emptyLabel}
|
|
399
|
-
</p>
|
|
400
|
-
)}
|
|
401
|
-
</div>
|
|
402
|
-
</AnchoredSurface>
|
|
403
|
-
);
|
|
404
|
-
}
|