@passui/react 0.1.17 → 0.1.20
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 +140 -1
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/dist/types/src/appearance/index.d.ts +2 -0
- package/dist/types/src/appearance/platform.d.ts +9 -0
- package/dist/types/src/appearance/theme.d.ts +71 -0
- package/dist/types/src/components/accordion/accordion.d.ts +19 -0
- package/dist/types/src/components/ambient/ambient.d.ts +12 -0
- package/dist/types/src/components/ambient/index.d.ts +1 -0
- package/dist/types/src/components/aspect-ratio/aspect-ratio.d.ts +7 -0
- package/dist/types/src/components/breadcrumb/breadcrumb.d.ts +16 -0
- package/dist/types/src/components/button/button-styles.d.ts +12 -0
- package/dist/types/src/components/button/button.d.ts +32 -0
- package/dist/types/src/components/button/icon-button.d.ts +10 -0
- package/dist/types/src/components/button/pending-spinner.d.ts +5 -0
- package/dist/types/src/components/button/use-pending-indicator.d.ts +2 -0
- package/dist/types/src/components/chip/chip.d.ts +7 -0
- package/dist/types/src/components/code-block/code-block.d.ts +10 -0
- package/dist/types/src/components/combo-box/combo-box.d.ts +9 -0
- package/dist/types/src/components/command/command.d.ts +18 -0
- package/dist/types/src/components/compact-date-picker/calendar-month.d.ts +25 -0
- package/dist/types/src/components/compact-date-picker/compact-date-picker.d.ts +27 -0
- package/dist/types/src/components/compact-time-picker/compact-time-picker.d.ts +26 -0
- package/dist/types/src/components/compact-time-picker/time-value.d.ts +18 -0
- package/dist/types/src/components/content-unavailable-view/content-unavailable-view.d.ts +9 -0
- package/dist/types/src/components/content-view/content-view.d.ts +48 -0
- package/dist/types/src/components/content-view/index.d.ts +1 -0
- package/dist/types/src/components/context-menu/conceal-menu-source.d.ts +2 -0
- package/dist/types/src/components/context-menu/context-menu-host.d.ts +2 -0
- package/dist/types/src/components/context-menu/context-menu-store.d.ts +57 -0
- package/dist/types/src/components/context-menu/menu-navigation.d.ts +6 -0
- package/dist/types/src/components/context-menu/menu-position.d.ts +21 -0
- package/dist/types/src/components/context-menu/menu-reveal.d.ts +17 -0
- package/dist/types/src/components/context-menu/use-context-menu.d.ts +14 -0
- package/dist/types/src/components/conversation/conversation.d.ts +43 -0
- package/dist/types/src/components/conversation/index.d.ts +1 -0
- package/dist/types/src/components/date-picker/date-picker.d.ts +16 -0
- package/dist/types/src/components/date-picker/date-value.d.ts +2 -0
- package/dist/types/src/components/dialog/dialog-host.d.ts +6 -0
- package/dist/types/src/components/dialog/dialog-store.d.ts +23 -0
- package/dist/types/src/components/dialog/dialog.d.ts +30 -0
- package/dist/types/src/components/dialog/index.d.ts +1 -0
- package/dist/types/src/components/disclosure-group/disclosure-group.d.ts +15 -0
- package/dist/types/src/components/divider/divider.d.ts +9 -0
- package/dist/types/src/components/inline-disclosure/inline-disclosure.d.ts +15 -0
- package/dist/types/src/components/keyboard-shortcut/keyboard-shortcut.d.ts +5 -0
- package/dist/types/src/components/labeled-content/labeled-content.d.ts +19 -0
- package/dist/types/src/components/locale-switcher/index.d.ts +1 -0
- package/dist/types/src/components/locale-switcher/locale-switcher.d.ts +10 -0
- package/dist/types/src/components/menu/menu.d.ts +16 -0
- package/dist/types/src/components/one-time-code/one-time-code.d.ts +18 -0
- package/dist/types/src/components/picker/picker-trigger.d.ts +2 -0
- package/dist/types/src/components/picker/picker.d.ts +43 -0
- package/dist/types/src/components/popover/anchored-surface.d.ts +13 -0
- package/dist/types/src/components/popover/popover-fit.d.ts +21 -0
- package/dist/types/src/components/popover/popover.d.ts +18 -0
- package/dist/types/src/components/profile-image/profile-image.d.ts +4 -0
- package/dist/types/src/components/progress-view/progress-view.d.ts +13 -0
- package/dist/types/src/components/progress-view/use-liquid-progress.d.ts +3 -0
- package/dist/types/src/components/radio-group/radio-group.d.ts +17 -0
- package/dist/types/src/components/search-field/expanding-search-field.d.ts +5 -0
- package/dist/types/src/components/search-field/search-field.d.ts +6 -0
- package/dist/types/src/components/search-list/search-list.d.ts +19 -0
- package/dist/types/src/components/section/section.d.ts +15 -0
- package/dist/types/src/components/secure-field/secure-field.d.ts +4 -0
- package/dist/types/src/components/segmented-control/segmented-control.d.ts +20 -0
- package/dist/types/src/components/sheet/modal-environment.d.ts +2 -0
- package/dist/types/src/components/sheet/sheet-portal.d.ts +5 -0
- package/dist/types/src/components/sheet/sheet.d.ts +21 -0
- package/dist/types/src/components/sheet/use-sheet-focus.d.ts +3 -0
- package/dist/types/src/components/sidebar/sidebar.d.ts +19 -0
- package/dist/types/src/components/skeleton/skeleton.d.ts +6 -0
- package/dist/types/src/components/slider/slider.d.ts +14 -0
- package/dist/types/src/components/slosh-slider/liquid-step.d.ts +6 -0
- package/dist/types/src/components/slosh-slider/slosh-slider.d.ts +18 -0
- package/dist/types/src/components/stat-tile/index.d.ts +1 -0
- package/dist/types/src/components/stat-tile/stat-tile.d.ts +15 -0
- package/dist/types/src/components/status-indicator/status-indicator.d.ts +14 -0
- package/dist/types/src/components/stepper/rolling-digit.d.ts +11 -0
- package/dist/types/src/components/stepper/stepper.d.ts +19 -0
- package/dist/types/src/components/swatch-picker/swatch-picker.d.ts +17 -0
- package/dist/types/src/components/tab-bar/tab-bar.d.ts +40 -0
- package/dist/types/src/components/tab-view/tab-view.d.ts +24 -0
- package/dist/types/src/components/table/table.d.ts +10 -0
- package/dist/types/src/components/text-editor/text-editor.d.ts +2 -0
- package/dist/types/src/components/text-field/text-field.d.ts +20 -0
- package/dist/types/src/components/toast/toast-store.d.ts +47 -0
- package/dist/types/src/components/toast/toaster.d.ts +10 -0
- package/dist/types/src/components/toggle/toggle.d.ts +17 -0
- package/dist/types/src/components/tooltip/tooltip-host.d.ts +6 -0
- package/dist/types/src/components/view-controller/index.d.ts +1 -0
- package/dist/types/src/components/view-controller/view-controller.d.ts +21 -0
- package/dist/types/src/components/wake-slider/wake-slider.d.ts +12 -0
- package/dist/types/src/hooks/scroll/minimize-decision.d.ts +2 -0
- package/dist/types/src/hooks/use-anchored-disclosure.d.ts +9 -0
- package/dist/types/src/hooks/use-anchored-placement.d.ts +7 -0
- package/dist/types/src/hooks/use-dismiss.d.ts +9 -0
- package/dist/types/src/hooks/use-floating-dismiss.d.ts +3 -0
- package/dist/types/src/hooks/use-media-query.d.ts +21 -0
- package/dist/types/src/hooks/use-minimize-on-scroll.d.ts +6 -0
- package/dist/types/src/hooks/use-visual-viewport.d.ts +4 -0
- package/dist/types/src/hooks/viewport/types.d.ts +19 -0
- package/dist/types/src/hooks/viewport/viewport-metrics.d.ts +3 -0
- package/dist/types/src/icons/icons.d.ts +612 -0
- package/dist/types/src/index.d.ts +71 -0
- package/dist/types/src/lib/anchored-placement.d.ts +39 -0
- package/dist/types/src/lib/class-names.d.ts +2 -0
- package/dist/types/src/lib/clipboard.d.ts +6 -0
- package/dist/types/src/lib/date.d.ts +50 -0
- package/dist/types/src/lib/floating-layers.d.ts +8 -0
- package/dist/types/src/lib/haptics.d.ts +8 -0
- package/dist/types/src/lib/language.d.ts +4 -0
- package/dist/types/src/lib/range-value.d.ts +4 -0
- package/dist/types/src/lib/screen-edges.d.ts +12 -0
- package/dist/types/src/lib/shapes.d.ts +17 -0
- package/dist/types/src/motion/transitions.d.ts +97 -0
- package/dist/types/src/tokens.d.ts +1 -0
- package/package.json +248 -40
- package/src/appearance/platform.tsx +10 -47
- package/src/appearance/theme.tsx +42 -142
- package/src/components/accordion/accordion.tsx +48 -0
- package/src/components/ambient/ambient.tsx +2 -10
- package/src/components/aspect-ratio/aspect-ratio.tsx +22 -0
- package/src/components/breadcrumb/breadcrumb.tsx +53 -0
- package/src/components/button/button-styles.ts +13 -31
- package/src/components/button/button.tsx +24 -15
- package/src/components/button/icon-button.tsx +14 -56
- package/src/components/button/use-pending-indicator.ts +2 -7
- package/src/components/chip/chip.tsx +8 -13
- package/src/components/code-block/code-block.tsx +41 -0
- package/src/components/combo-box/combo-box.tsx +13 -0
- package/src/components/command/command.tsx +119 -0
- package/src/components/compact-date-picker/calendar-month.ts +13 -57
- package/src/components/compact-date-picker/compact-date-picker.tsx +72 -195
- package/src/components/compact-time-picker/compact-time-picker.tsx +74 -195
- package/src/components/compact-time-picker/time-value.ts +4 -16
- package/src/components/content-unavailable-view/content-unavailable-view.tsx +37 -0
- package/src/components/content-view/content-view.tsx +13 -56
- package/src/components/context-menu/conceal-menu-source.ts +1 -4
- package/src/components/context-menu/context-menu-host.tsx +132 -198
- package/src/components/context-menu/context-menu-store.ts +5 -14
- package/src/components/context-menu/menu-navigation.ts +29 -0
- package/src/components/context-menu/menu-position.ts +6 -27
- package/src/components/context-menu/menu-reveal.ts +14 -52
- package/src/components/context-menu/use-context-menu.ts +6 -30
- package/src/components/conversation/conversation.tsx +26 -72
- package/src/components/date-picker/date-picker.tsx +8 -37
- package/src/components/date-picker/date-value.ts +5 -30
- package/src/components/dialog/dialog-host.tsx +37 -76
- package/src/components/dialog/dialog-store.ts +16 -7
- package/src/components/dialog/dialog.tsx +23 -80
- package/src/components/disclosure-group/disclosure-group.tsx +79 -0
- package/src/components/divider/divider.tsx +31 -0
- package/src/components/inline-disclosure/inline-disclosure.tsx +49 -0
- package/src/components/keyboard-shortcut/keyboard-shortcut.tsx +17 -0
- package/src/components/labeled-content/labeled-content.tsx +24 -18
- package/src/components/locale-switcher/locale-switcher.tsx +20 -70
- package/src/components/menu/menu.tsx +68 -0
- package/src/components/one-time-code/one-time-code.tsx +168 -0
- package/src/components/picker/picker-trigger.ts +10 -0
- package/src/components/picker/picker.tsx +165 -283
- package/src/components/popover/anchored-surface.tsx +223 -0
- package/src/components/popover/popover-fit.ts +69 -0
- package/src/components/popover/popover.tsx +209 -63
- package/src/components/profile-image/profile-image.tsx +6 -28
- package/src/components/progress-view/progress-view.tsx +70 -0
- package/src/components/progress-view/use-liquid-progress.ts +43 -0
- package/src/components/radio-group/radio-group.tsx +63 -0
- package/src/components/search-field/expanding-search-field.tsx +183 -0
- package/src/components/search-field/search-field.tsx +25 -7
- package/src/components/search-list/search-list.tsx +58 -75
- package/src/components/section/section.tsx +18 -17
- package/src/components/secure-field/secure-field.tsx +5 -7
- package/src/components/segmented-control/segmented-control.tsx +20 -29
- package/src/components/sheet/modal-environment.ts +16 -54
- package/src/components/sheet/sheet-portal.tsx +10 -42
- package/src/components/sheet/sheet.tsx +17 -25
- package/src/components/sheet/use-sheet-focus.ts +15 -51
- package/src/components/sidebar/sidebar.tsx +44 -38
- package/src/components/skeleton/skeleton.tsx +19 -0
- package/src/components/slider/slider.tsx +76 -0
- package/src/components/slosh-slider/liquid-step.ts +42 -0
- package/src/components/slosh-slider/slosh-slider.tsx +251 -0
- package/src/components/stat-tile/stat-tile.tsx +9 -30
- package/src/components/status-indicator/status-indicator.tsx +12 -19
- package/src/components/stepper/rolling-digit.tsx +77 -0
- package/src/components/stepper/stepper.tsx +101 -0
- package/src/components/swatch-picker/swatch-picker.tsx +19 -15
- package/src/components/tab-bar/tab-bar.tsx +59 -59
- package/src/components/tab-view/tab-view.tsx +52 -57
- package/src/components/table/table.tsx +14 -62
- package/src/components/text-editor/text-editor.tsx +2 -12
- package/src/components/text-field/text-field.tsx +53 -44
- package/src/components/toast/toast-store.ts +9 -30
- package/src/components/toast/toaster.tsx +90 -104
- package/src/components/toggle/toggle.tsx +165 -44
- package/src/components/tooltip/tooltip-host.tsx +70 -67
- package/src/components/view-controller/view-controller.tsx +4 -21
- package/src/components/wake-slider/wake-slider.tsx +237 -0
- package/src/hooks/scroll/minimize-decision.ts +1 -5
- package/src/hooks/use-anchored-disclosure.ts +23 -0
- package/src/hooks/use-anchored-placement.ts +7 -14
- package/src/hooks/use-dismiss.ts +5 -23
- package/src/hooks/use-floating-dismiss.ts +28 -0
- package/src/hooks/use-media-query.ts +12 -31
- package/src/hooks/use-minimize-on-scroll.ts +10 -34
- package/src/hooks/use-visual-viewport.ts +5 -14
- package/src/hooks/viewport/viewport-metrics.ts +4 -16
- package/src/icons/icons.tsx +229 -183
- package/src/index.ts +27 -1
- package/src/lib/anchored-placement.ts +12 -18
- package/src/lib/class-names.ts +1 -2
- package/src/lib/clipboard.ts +14 -0
- package/src/lib/date.ts +4 -15
- package/src/lib/floating-layers.ts +18 -8
- package/src/lib/haptics.ts +1 -3
- package/src/lib/language.ts +2 -7
- package/src/lib/range-value.ts +32 -0
- package/src/lib/screen-edges.ts +2 -6
- package/src/lib/shapes.ts +5 -20
- package/src/motion/transitions.ts +18 -12
- package/src/styles/code-block.css +33 -0
- package/src/styles/motion-controls.css +189 -0
- package/src/styles/styles.css +3 -0
- package/src/components/ambient/ambient.docs.tsx +0 -68
- package/src/components/ambient/examples/ambient-images.tsx +0 -30
- package/src/components/ambient/examples/ambient-now-playing.tsx +0 -55
- package/src/components/ambient/examples/ambient-showcase.tsx +0 -33
- package/src/components/ambient/examples/ambient-usage.tsx +0 -19
- package/src/components/button/button.docs.tsx +0 -116
- package/src/components/button/examples/button-disabled.tsx +0 -19
- package/src/components/button/examples/button-icon.tsx +0 -39
- package/src/components/button/examples/button-link.tsx +0 -12
- package/src/components/button/examples/button-pending.tsx +0 -27
- package/src/components/button/examples/button-showcase.tsx +0 -115
- package/src/components/button/examples/button-sizes.tsx +0 -12
- package/src/components/button/examples/button-usage.tsx +0 -12
- package/src/components/button/examples/button-variants.tsx +0 -15
- package/src/components/button/examples/button-with-icon.tsx +0 -32
- package/src/components/button/examples/icon-button-player.tsx +0 -38
- package/src/components/button/examples/icon-button-showcase.tsx +0 -83
- package/src/components/button/examples/icon-button-usage.tsx +0 -11
- package/src/components/button/examples/icon-button-variants.tsx +0 -39
- package/src/components/button/icon-button.docs.tsx +0 -68
- package/src/components/chip/chip.docs.tsx +0 -37
- package/src/components/chip/examples/chip-in-rows.tsx +0 -19
- package/src/components/chip/examples/chip-showcase.tsx +0 -51
- package/src/components/chip/examples/chip-tones.tsx +0 -13
- package/src/components/chip/examples/chip-usage.tsx +0 -5
- package/src/components/compact-date-picker/compact-date-picker.docs.tsx +0 -81
- package/src/components/compact-date-picker/examples/compact-date-picker-showcase.tsx +0 -35
- package/src/components/compact-date-picker/examples/compact-date-picker-usage.tsx +0 -22
- package/src/components/compact-time-picker/compact-time-picker.docs.tsx +0 -80
- package/src/components/compact-time-picker/examples/compact-time-picker-showcase.tsx +0 -31
- package/src/components/compact-time-picker/examples/compact-time-picker-usage.tsx +0 -21
- package/src/components/content-view/content-view.docs.tsx +0 -61
- package/src/components/content-view/examples/content-view-header-action.tsx +0 -33
- package/src/components/content-view/examples/content-view-showcase.tsx +0 -65
- package/src/components/content-view/examples/content-view-stats.tsx +0 -35
- package/src/components/content-view/examples/content-view-usage.tsx +0 -14
- package/src/components/context-menu/context-menu.docs.tsx +0 -92
- package/src/components/context-menu/examples/context-menu-checked.tsx +0 -37
- package/src/components/context-menu/examples/context-menu-list.tsx +0 -85
- package/src/components/context-menu/examples/context-menu-showcase.tsx +0 -56
- package/src/components/context-menu/examples/context-menu-toolbar.tsx +0 -63
- package/src/components/context-menu/examples/context-menu-usage.tsx +0 -24
- package/src/components/conversation/conversation.docs.tsx +0 -88
- package/src/components/conversation/examples/conversation-composer.tsx +0 -36
- package/src/components/conversation/examples/conversation-days.tsx +0 -48
- package/src/components/conversation/examples/conversation-showcase.tsx +0 -71
- package/src/components/conversation/examples/conversation-usage.tsx +0 -28
- package/src/components/date-picker/date-picker.docs.tsx +0 -88
- package/src/components/date-picker/examples/date-picker-locales.tsx +0 -41
- package/src/components/date-picker/examples/date-picker-past-only.tsx +0 -29
- package/src/components/date-picker/examples/date-picker-showcase.tsx +0 -49
- package/src/components/date-picker/examples/date-picker-usage.tsx +0 -22
- package/src/components/dialog/dialog.docs.tsx +0 -114
- package/src/components/dialog/examples/dialog-confirm.tsx +0 -24
- package/src/components/dialog/examples/dialog-form.tsx +0 -46
- package/src/components/dialog/examples/dialog-inline.tsx +0 -48
- package/src/components/dialog/examples/dialog-showcase.tsx +0 -53
- package/src/components/dialog/examples/dialog-usage.tsx +0 -31
- package/src/components/labeled-content/examples/labeled-content-descriptions.tsx +0 -37
- package/src/components/labeled-content/examples/labeled-content-showcase.tsx +0 -54
- package/src/components/labeled-content/examples/labeled-content-usage.tsx +0 -22
- package/src/components/labeled-content/examples/labeled-content-values.tsx +0 -26
- package/src/components/labeled-content/examples/labeled-content-wide.tsx +0 -46
- package/src/components/labeled-content/labeled-content.docs.tsx +0 -69
- package/src/components/locale-switcher/examples/locale-switcher-native-names.tsx +0 -30
- package/src/components/locale-switcher/examples/locale-switcher-showcase.tsx +0 -46
- package/src/components/locale-switcher/examples/locale-switcher-translated-page.tsx +0 -35
- package/src/components/locale-switcher/examples/locale-switcher-usage.tsx +0 -20
- package/src/components/locale-switcher/locale-switcher.docs.tsx +0 -91
- package/src/components/picker/examples/picker-details.tsx +0 -44
- package/src/components/picker/examples/picker-searchable.tsx +0 -48
- package/src/components/picker/examples/picker-showcase.tsx +0 -66
- package/src/components/picker/examples/picker-usage.tsx +0 -20
- package/src/components/picker/picker.docs.tsx +0 -68
- package/src/components/popover/examples/popover-help.tsx +0 -57
- package/src/components/popover/examples/popover-menu.tsx +0 -51
- package/src/components/popover/examples/popover-showcase.tsx +0 -61
- package/src/components/popover/examples/popover-usage.tsx +0 -31
- package/src/components/popover/popover.docs.tsx +0 -84
- package/src/components/profile-image/examples/profile-image-fallbacks.tsx +0 -29
- package/src/components/profile-image/examples/profile-image-group.tsx +0 -34
- package/src/components/profile-image/examples/profile-image-showcase.tsx +0 -30
- package/src/components/profile-image/examples/profile-image-usage.tsx +0 -14
- package/src/components/profile-image/profile-image.docs.tsx +0 -81
- package/src/components/search-field/examples/search-field-filter.tsx +0 -53
- package/src/components/search-field/examples/search-field-showcase.tsx +0 -56
- package/src/components/search-field/examples/search-field-toolbar.tsx +0 -27
- package/src/components/search-field/examples/search-field-usage.tsx +0 -18
- package/src/components/search-field/search-field.docs.tsx +0 -58
- package/src/components/search-list/examples/search-list-dropdown.tsx +0 -53
- package/src/components/search-list/examples/search-list-groups.tsx +0 -64
- package/src/components/search-list/examples/search-list-showcase.tsx +0 -67
- package/src/components/search-list/examples/search-list-usage.tsx +0 -27
- package/src/components/search-list/search-list.docs.tsx +0 -87
- package/src/components/section/examples/section-actions.tsx +0 -35
- package/src/components/section/examples/section-groups.tsx +0 -41
- package/src/components/section/examples/section-showcase.tsx +0 -63
- package/src/components/section/examples/section-usage.tsx +0 -19
- package/src/components/section/section.docs.tsx +0 -51
- package/src/components/secure-field/examples/secure-field-new-password.tsx +0 -56
- package/src/components/secure-field/examples/secure-field-reveal.tsx +0 -20
- package/src/components/secure-field/examples/secure-field-showcase.tsx +0 -62
- package/src/components/secure-field/examples/secure-field-usage.tsx +0 -19
- package/src/components/secure-field/secure-field.docs.tsx +0 -72
- package/src/components/segmented-control/examples/segmented-control-overflow.tsx +0 -28
- package/src/components/segmented-control/examples/segmented-control-showcase.tsx +0 -59
- package/src/components/segmented-control/examples/segmented-control-usage.tsx +0 -20
- package/src/components/segmented-control/examples/segmented-control-views.tsx +0 -32
- package/src/components/segmented-control/segmented-control.docs.tsx +0 -61
- package/src/components/sheet/examples/sheet-choices.tsx +0 -58
- package/src/components/sheet/examples/sheet-share.tsx +0 -51
- package/src/components/sheet/examples/sheet-showcase.tsx +0 -74
- package/src/components/sheet/examples/sheet-usage.tsx +0 -32
- package/src/components/sheet/sheet.docs.tsx +0 -75
- package/src/components/sidebar/examples/sidebar-groups.tsx +0 -133
- package/src/components/sidebar/examples/sidebar-showcase.tsx +0 -123
- package/src/components/sidebar/examples/sidebar-unread.tsx +0 -66
- package/src/components/sidebar/examples/sidebar-usage.tsx +0 -52
- package/src/components/sidebar/sidebar.docs.tsx +0 -135
- package/src/components/stat-tile/examples/stat-tile-filters.tsx +0 -32
- package/src/components/stat-tile/examples/stat-tile-grid.tsx +0 -21
- package/src/components/stat-tile/examples/stat-tile-showcase.tsx +0 -52
- package/src/components/stat-tile/examples/stat-tile-usage.tsx +0 -13
- package/src/components/stat-tile/stat-tile.docs.tsx +0 -60
- package/src/components/status-indicator/examples/status-indicator-live.tsx +0 -34
- package/src/components/status-indicator/examples/status-indicator-showcase.tsx +0 -39
- package/src/components/status-indicator/examples/status-indicator-states.tsx +0 -17
- package/src/components/status-indicator/examples/status-indicator-usage.tsx +0 -9
- package/src/components/status-indicator/status-indicator.docs.tsx +0 -43
- package/src/components/swatch-picker/examples/swatch-picker-accents.tsx +0 -42
- package/src/components/swatch-picker/examples/swatch-picker-labels.tsx +0 -45
- package/src/components/swatch-picker/examples/swatch-picker-showcase.tsx +0 -70
- package/src/components/swatch-picker/examples/swatch-picker-usage.tsx +0 -39
- package/src/components/swatch-picker/swatch-picker.docs.tsx +0 -60
- package/src/components/tab-bar/examples/tab-bar-five-tabs.tsx +0 -66
- package/src/components/tab-bar/examples/tab-bar-minimize.tsx +0 -71
- package/src/components/tab-bar/examples/tab-bar-showcase.tsx +0 -82
- package/src/components/tab-bar/examples/tab-bar-usage.tsx +0 -54
- package/src/components/tab-bar/tab-bar.docs.tsx +0 -136
- package/src/components/tab-view/examples/tab-view-keyboard.tsx +0 -39
- package/src/components/tab-view/examples/tab-view-settings.tsx +0 -56
- package/src/components/tab-view/examples/tab-view-showcase.tsx +0 -53
- package/src/components/tab-view/examples/tab-view-usage.tsx +0 -23
- package/src/components/tab-view/tab-view.docs.tsx +0 -77
- package/src/components/table/examples/table-empty.tsx +0 -53
- package/src/components/table/examples/table-invoices.tsx +0 -102
- package/src/components/table/examples/table-selection.tsx +0 -150
- package/src/components/table/examples/table-showcase.tsx +0 -115
- package/src/components/table/examples/table-usage.tsx +0 -67
- package/src/components/table/examples/table-wide.tsx +0 -75
- package/src/components/table/table.docs.tsx +0 -131
- package/src/components/text-editor/examples/text-editor-comment.tsx +0 -48
- package/src/components/text-editor/examples/text-editor-count.tsx +0 -38
- package/src/components/text-editor/examples/text-editor-showcase.tsx +0 -58
- package/src/components/text-editor/examples/text-editor-usage.tsx +0 -25
- package/src/components/text-editor/text-editor.docs.tsx +0 -61
- package/src/components/text-field/examples/text-field-icons.tsx +0 -72
- package/src/components/text-field/examples/text-field-showcase.tsx +0 -50
- package/src/components/text-field/examples/text-field-usage.tsx +0 -18
- package/src/components/text-field/examples/text-field-validation.tsx +0 -27
- package/src/components/text-field/text-field.docs.tsx +0 -118
- package/src/components/toast/examples/toast-action.tsx +0 -32
- package/src/components/toast/examples/toast-promise.tsx +0 -45
- package/src/components/toast/examples/toast-showcase.tsx +0 -49
- package/src/components/toast/examples/toast-usage.tsx +0 -13
- package/src/components/toast/toast.docs.tsx +0 -79
- package/src/components/toggle/examples/toggle-checkboxes.tsx +0 -43
- package/src/components/toggle/examples/toggle-settings.tsx +0 -31
- package/src/components/toggle/examples/toggle-showcase.tsx +0 -59
- package/src/components/toggle/examples/toggle-usage.tsx +0 -13
- package/src/components/toggle/toggle.docs.tsx +0 -69
- package/src/components/tooltip/examples/tooltip-icon-buttons.tsx +0 -27
- package/src/components/tooltip/examples/tooltip-shortcuts.tsx +0 -38
- package/src/components/tooltip/examples/tooltip-showcase.tsx +0 -44
- package/src/components/tooltip/examples/tooltip-usage.tsx +0 -13
- package/src/components/tooltip/tooltip.docs.tsx +0 -56
- package/src/components/view-controller/examples/view-controller-action.tsx +0 -27
- package/src/components/view-controller/examples/view-controller-settings.tsx +0 -31
- package/src/components/view-controller/examples/view-controller-showcase.tsx +0 -45
- package/src/components/view-controller/examples/view-controller-usage.tsx +0 -19
- package/src/components/view-controller/view-controller.docs.tsx +0 -71
- package/src/docs/index.ts +0 -3
- package/src/docs/registry.ts +0 -113
- package/src/docs/snippet.ts +0 -17
- package/src/docs/types.ts +0 -180
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useState,
|
|
6
|
-
type ComponentProps,
|
|
7
|
-
} from "react"
|
|
1
|
+
import { createContext, useContext, useEffect, useState, type ComponentProps } from "react"
|
|
8
2
|
import { cn } from "../../lib/class-names"
|
|
9
3
|
|
|
10
4
|
const ImageContext = createContext<{
|
|
11
5
|
loaded: boolean
|
|
12
6
|
setLoaded: (loaded: boolean) => void
|
|
13
7
|
}>({ loaded: false, setLoaded: () => {} })
|
|
14
|
-
export function ProfileImage({
|
|
15
|
-
className,
|
|
16
|
-
...props
|
|
17
|
-
}: ComponentProps<"span">) {
|
|
8
|
+
export function ProfileImage({ className, ...props }: ComponentProps<"span">) {
|
|
18
9
|
const [loaded, setLoaded] = useState(false)
|
|
19
10
|
return (
|
|
20
11
|
<ImageContext value={{ loaded, setLoaded }}>
|
|
@@ -46,10 +37,7 @@ export function ProfileImageContent({
|
|
|
46
37
|
alt=""
|
|
47
38
|
{...props}
|
|
48
39
|
src={src}
|
|
49
|
-
className={cn(
|
|
50
|
-
"absolute inset-0 size-full object-cover",
|
|
51
|
-
className
|
|
52
|
-
)}
|
|
40
|
+
className={cn("absolute inset-0 size-full object-cover", className)}
|
|
53
41
|
onLoad={(event) => {
|
|
54
42
|
setLoaded(true)
|
|
55
43
|
onLoad?.(event)
|
|
@@ -57,24 +45,14 @@ export function ProfileImageContent({
|
|
|
57
45
|
onError={(event) => {
|
|
58
46
|
setLoaded(false)
|
|
59
47
|
onError?.(event)
|
|
60
|
-
event.currentTarget.style.visibility =
|
|
61
|
-
"hidden"
|
|
48
|
+
event.currentTarget.style.visibility = "hidden"
|
|
62
49
|
}}
|
|
63
50
|
/>
|
|
64
51
|
)
|
|
65
52
|
}
|
|
66
|
-
export function ProfileImageFallback({
|
|
67
|
-
className,
|
|
68
|
-
...props
|
|
69
|
-
}: ComponentProps<"span">) {
|
|
53
|
+
export function ProfileImageFallback({ className, ...props }: ComponentProps<"span">) {
|
|
70
54
|
const { loaded } = useContext(ImageContext)
|
|
71
55
|
return loaded ? null : (
|
|
72
|
-
<span
|
|
73
|
-
{...props}
|
|
74
|
-
className={cn(
|
|
75
|
-
"text-footnote font-medium",
|
|
76
|
-
className
|
|
77
|
-
)}
|
|
78
|
-
/>
|
|
56
|
+
<span {...props} className={cn("text-footnote font-medium", className)} />
|
|
79
57
|
)
|
|
80
58
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type HTMLAttributes, useRef } from "react"
|
|
2
|
+
import { useLiquidProgress } from "./use-liquid-progress"
|
|
3
|
+
import { cn } from "../../lib/class-names"
|
|
4
|
+
import { clampRange } from "../../lib/range-value"
|
|
5
|
+
|
|
6
|
+
export type ProgressViewSize = "sm" | "md" | "lg"
|
|
7
|
+
|
|
8
|
+
export interface ProgressViewProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
9
|
+
label: string
|
|
10
|
+
/** Omit for an indeterminate operation. */
|
|
11
|
+
value?: number
|
|
12
|
+
max?: number
|
|
13
|
+
size?: ProgressViewSize
|
|
14
|
+
/** Secondary text, such as bytes uploaded. */
|
|
15
|
+
detail?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const trackHeight: Record<ProgressViewSize, string> = {
|
|
19
|
+
sm: "h-1",
|
|
20
|
+
md: "h-2",
|
|
21
|
+
lg: "h-3",
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A determinate or indeterminate progress track respecting reduced motion. */
|
|
25
|
+
export function ProgressView({
|
|
26
|
+
label,
|
|
27
|
+
value,
|
|
28
|
+
max = 100,
|
|
29
|
+
size = "md",
|
|
30
|
+
detail,
|
|
31
|
+
className,
|
|
32
|
+
...props
|
|
33
|
+
}: ProgressViewProps) {
|
|
34
|
+
const limit = Number.isFinite(max) && max > 0 ? max : 100
|
|
35
|
+
const current = value === undefined ? undefined : clampRange(value, 0, limit)
|
|
36
|
+
const progress = current === undefined ? undefined : (current / limit) * 100
|
|
37
|
+
const fill = useRef<HTMLDivElement>(null)
|
|
38
|
+
useLiquidProgress(fill, progress)
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div {...props} className={cn("flex min-w-0 flex-col gap-2", className)}>
|
|
42
|
+
<div className="flex items-center justify-between gap-3 text-footnote">
|
|
43
|
+
<span className="font-semibold text-label">{label}</span>
|
|
44
|
+
{detail && <span className="text-label-secondary">{detail}</span>}
|
|
45
|
+
</div>
|
|
46
|
+
<div
|
|
47
|
+
role="progressbar"
|
|
48
|
+
aria-label={label}
|
|
49
|
+
aria-valuemin={current === undefined ? undefined : 0}
|
|
50
|
+
aria-valuemax={current === undefined ? undefined : limit}
|
|
51
|
+
aria-valuenow={current}
|
|
52
|
+
className={cn(
|
|
53
|
+
"relative w-full overflow-hidden rounded-full bg-separator/70",
|
|
54
|
+
trackHeight[size]
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
<div
|
|
58
|
+
ref={fill}
|
|
59
|
+
aria-hidden="true"
|
|
60
|
+
className={cn(
|
|
61
|
+
"h-full rounded-full bg-accent",
|
|
62
|
+
current !== undefined && "passui-progress-fill",
|
|
63
|
+
current === undefined && "w-1/3 animate-pulse motion-reduce:animate-none"
|
|
64
|
+
)}
|
|
65
|
+
style={progress === undefined ? undefined : { width: `${progress}%` }}
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type RefObject, useLayoutEffect, useRef } from "react"
|
|
2
|
+
import { useMediaQuery } from "../../hooks/use-media-query"
|
|
3
|
+
import { clampRange } from "../../lib/range-value"
|
|
4
|
+
import { stepLiquid } from "../slosh-slider/liquid-step"
|
|
5
|
+
|
|
6
|
+
/** Read-only progress shares the liquid fill without acquiring slider semantics. */
|
|
7
|
+
export function useLiquidProgress(
|
|
8
|
+
ref: RefObject<HTMLDivElement | null>,
|
|
9
|
+
target: number | undefined
|
|
10
|
+
) {
|
|
11
|
+
const reduced = useMediaQuery("(prefers-reduced-motion: reduce)")
|
|
12
|
+
const state = useRef({ fill: target ?? 0, velocity: 0 })
|
|
13
|
+
useLayoutEffect(() => {
|
|
14
|
+
const element = ref.current
|
|
15
|
+
if (!element || target === undefined) return
|
|
16
|
+
let frame = 0
|
|
17
|
+
let previous = 0
|
|
18
|
+
const paint = () => {
|
|
19
|
+
element.style.width = `${state.current.fill}%`
|
|
20
|
+
element.style.setProperty(
|
|
21
|
+
"--progress-lean",
|
|
22
|
+
`${reduced ? 0 : clampRange(state.current.velocity * 0.4, -4, 4)}px`
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
if (reduced) {
|
|
26
|
+
state.current = { fill: target, velocity: 0 }
|
|
27
|
+
paint()
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
const tick = (now: number) => {
|
|
31
|
+
const dt = previous ? Math.min(2.5, (now - previous) / 16.67) : 1
|
|
32
|
+
previous = now
|
|
33
|
+
state.current = stepLiquid(state.current, target, 15, dt)
|
|
34
|
+
paint()
|
|
35
|
+
if (state.current.fill !== target || state.current.velocity)
|
|
36
|
+
frame = requestAnimationFrame(tick)
|
|
37
|
+
}
|
|
38
|
+
paint()
|
|
39
|
+
if (state.current.fill !== target || state.current.velocity)
|
|
40
|
+
frame = requestAnimationFrame(tick)
|
|
41
|
+
return () => cancelAnimationFrame(frame)
|
|
42
|
+
}, [ref, target, reduced])
|
|
43
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useId } from "react"
|
|
2
|
+
import { cn } from "../../lib/class-names"
|
|
3
|
+
|
|
4
|
+
export interface RadioGroupOption<T extends string> {
|
|
5
|
+
value: T
|
|
6
|
+
label: string
|
|
7
|
+
description?: string
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
}
|
|
10
|
+
export interface RadioGroupProps<T extends string> {
|
|
11
|
+
value: T
|
|
12
|
+
onChange: (value: NoInfer<T>) => void
|
|
13
|
+
label: string
|
|
14
|
+
options: readonly RadioGroupOption<T>[]
|
|
15
|
+
disabled?: boolean
|
|
16
|
+
name?: string
|
|
17
|
+
className?: string
|
|
18
|
+
}
|
|
19
|
+
/** A labelled choice group using the browser's native radio keyboard behavior. */
|
|
20
|
+
export function RadioGroup<T extends string>({
|
|
21
|
+
value,
|
|
22
|
+
onChange,
|
|
23
|
+
label,
|
|
24
|
+
options,
|
|
25
|
+
disabled,
|
|
26
|
+
name,
|
|
27
|
+
className,
|
|
28
|
+
}: RadioGroupProps<T>) {
|
|
29
|
+
const id = useId()
|
|
30
|
+
return (
|
|
31
|
+
<fieldset disabled={disabled} className={cn("flex min-w-0 flex-col gap-2", className)}>
|
|
32
|
+
<legend className="mb-2 text-footnote font-medium text-label-secondary">{label}</legend>
|
|
33
|
+
{options.map((option, index) => (
|
|
34
|
+
<label
|
|
35
|
+
key={option.value}
|
|
36
|
+
className="flex min-h-8 items-start gap-2 text-subheadline text-label has-disabled:opacity-40 [@media(pointer:coarse)]:min-h-11"
|
|
37
|
+
>
|
|
38
|
+
<input
|
|
39
|
+
type="radio"
|
|
40
|
+
name={name ?? id}
|
|
41
|
+
value={option.value}
|
|
42
|
+
checked={value === option.value}
|
|
43
|
+
disabled={option.disabled}
|
|
44
|
+
onChange={() => onChange(option.value)}
|
|
45
|
+
aria-describedby={option.description ? `${id}-${index}` : undefined}
|
|
46
|
+
className="mt-1 size-4 shrink-0 accent-accent-text focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent-text"
|
|
47
|
+
/>
|
|
48
|
+
<span>
|
|
49
|
+
{option.label}
|
|
50
|
+
{option.description && (
|
|
51
|
+
<span
|
|
52
|
+
id={`${id}-${index}`}
|
|
53
|
+
className="block text-footnote text-label-secondary"
|
|
54
|
+
>
|
|
55
|
+
{option.description}
|
|
56
|
+
</span>
|
|
57
|
+
)}
|
|
58
|
+
</span>
|
|
59
|
+
</label>
|
|
60
|
+
))}
|
|
61
|
+
</fieldset>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type InputHTMLAttributes,
|
|
3
|
+
type Ref,
|
|
4
|
+
useEffect,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from "react"
|
|
9
|
+
import { useMediaQuery } from "../../hooks/use-media-query"
|
|
10
|
+
import { SearchIcon } from "../../icons/icons"
|
|
11
|
+
import { cn } from "../../lib/class-names"
|
|
12
|
+
import { springs } from "@passui/tokens/motion"
|
|
13
|
+
|
|
14
|
+
/** One object: the field stays inside the pill, and the lens never moves within it. */
|
|
15
|
+
export function ExpandingSearchField({
|
|
16
|
+
inputRef,
|
|
17
|
+
className,
|
|
18
|
+
placeholder = "Search",
|
|
19
|
+
...props
|
|
20
|
+
}: InputHTMLAttributes<HTMLInputElement> & { inputRef: Ref<HTMLInputElement> }) {
|
|
21
|
+
const [expanded, setExpanded] = useState(Boolean(props.value ?? props.defaultValue))
|
|
22
|
+
const reduced = useMediaQuery("(prefers-reduced-motion: reduce)")
|
|
23
|
+
const frame = useRef<HTMLDivElement>(null)
|
|
24
|
+
const pill = useRef<HTMLLabelElement>(null)
|
|
25
|
+
const input = useRef<HTMLInputElement>(null)
|
|
26
|
+
const geometry = useRef({
|
|
27
|
+
width: expanded ? 320 : 44,
|
|
28
|
+
velocity: 0,
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 0,
|
|
31
|
+
vx: 0,
|
|
32
|
+
vy: 0,
|
|
33
|
+
pullX: 0,
|
|
34
|
+
pullY: 0,
|
|
35
|
+
capacity: 320,
|
|
36
|
+
raf: 0,
|
|
37
|
+
})
|
|
38
|
+
const current = useRef({ expanded, reduced })
|
|
39
|
+
const wake = useRef<() => void>(() => {})
|
|
40
|
+
useLayoutEffect(() => {
|
|
41
|
+
const box = frame.current,
|
|
42
|
+
label = pill.current,
|
|
43
|
+
field = input.current
|
|
44
|
+
if (!box || !label || !field) return
|
|
45
|
+
const s = geometry.current
|
|
46
|
+
let previous = 0
|
|
47
|
+
const tick = (now: number) => {
|
|
48
|
+
const dt = previous ? Math.min(0.032, (now - previous) / 1000) : 1 / 60
|
|
49
|
+
previous = now
|
|
50
|
+
const target = current.current.expanded ? s.capacity : Math.min(44, s.capacity)
|
|
51
|
+
const pullX = current.current.expanded ? 0 : s.pullX
|
|
52
|
+
const pullY = current.current.expanded ? 0 : s.pullY
|
|
53
|
+
const { stiffness, damping, mass } = springs.smooth
|
|
54
|
+
if (current.current.reduced) {
|
|
55
|
+
s.width = target
|
|
56
|
+
s.x = 0
|
|
57
|
+
s.y = 0
|
|
58
|
+
s.velocity = 0
|
|
59
|
+
s.vx = 0
|
|
60
|
+
s.vy = 0
|
|
61
|
+
} else {
|
|
62
|
+
s.velocity += (((target - s.width) * stiffness - s.velocity * damping) / mass) * dt
|
|
63
|
+
s.width += s.velocity * dt
|
|
64
|
+
s.vx += (((pullX - s.x) * stiffness - s.vx * damping) / mass) * dt
|
|
65
|
+
s.vy += (((pullY - s.y) * stiffness - s.vy * damping) / mass) * dt
|
|
66
|
+
s.x += s.vx * dt
|
|
67
|
+
s.y += s.vy * dt
|
|
68
|
+
}
|
|
69
|
+
label.style.width = `${Math.max(0, s.width)}px`
|
|
70
|
+
label.style.transform = `translate(${s.x}px, ${s.y}px)`
|
|
71
|
+
/* One number drives the field's reveal; focus lands with the
|
|
72
|
+
expansion, so the caret arrives while the shape is growing. */
|
|
73
|
+
const progress = (s.width - 44) / Math.max(1, s.capacity - 44)
|
|
74
|
+
field.style.opacity = String(Math.max(0, Math.min(1, (progress - 0.55) / 0.45)))
|
|
75
|
+
if (
|
|
76
|
+
Math.abs(s.width - target) < 0.05 &&
|
|
77
|
+
Math.abs(s.velocity) < 0.05 &&
|
|
78
|
+
Math.abs(s.x - pullX) + Math.abs(s.y - pullY) + Math.abs(s.vx) + Math.abs(s.vy) <
|
|
79
|
+
0.05
|
|
80
|
+
) {
|
|
81
|
+
label.style.width = `${target}px`
|
|
82
|
+
s.raf = 0
|
|
83
|
+
previous = 0
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
s.raf = requestAnimationFrame(tick)
|
|
87
|
+
}
|
|
88
|
+
wake.current = () => {
|
|
89
|
+
if (!s.raf) s.raf = requestAnimationFrame(tick)
|
|
90
|
+
}
|
|
91
|
+
const measure = () => {
|
|
92
|
+
s.capacity = Math.min(320, box.clientWidth)
|
|
93
|
+
wake.current()
|
|
94
|
+
}
|
|
95
|
+
measure()
|
|
96
|
+
const observer = new ResizeObserver(measure)
|
|
97
|
+
observer.observe(box)
|
|
98
|
+
return () => {
|
|
99
|
+
observer.disconnect()
|
|
100
|
+
cancelAnimationFrame(s.raf)
|
|
101
|
+
s.raf = 0
|
|
102
|
+
}
|
|
103
|
+
}, [])
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
current.current = { expanded, reduced }
|
|
106
|
+
wake.current()
|
|
107
|
+
}, [expanded, reduced])
|
|
108
|
+
return (
|
|
109
|
+
<div
|
|
110
|
+
ref={frame}
|
|
111
|
+
className={cn(
|
|
112
|
+
"relative flex h-11 w-full max-w-xs items-center justify-center",
|
|
113
|
+
className
|
|
114
|
+
)}
|
|
115
|
+
onPointerMove={(event) => {
|
|
116
|
+
if (expanded || reduced || event.pointerType !== "mouse") return
|
|
117
|
+
// Measure the frame, which stays still; measuring the object being
|
|
118
|
+
// moved creates a feedback loop and a visible shiver.
|
|
119
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
120
|
+
const dx = event.clientX - rect.left - rect.width / 2,
|
|
121
|
+
dy = event.clientY - rect.top - rect.height / 2
|
|
122
|
+
const distance = Math.hypot(dx, dy),
|
|
123
|
+
pull = Math.max(0, 1 - distance / 72) ** 1.4 * 7
|
|
124
|
+
geometry.current.pullX = distance ? (dx / distance) * pull : 0
|
|
125
|
+
geometry.current.pullY = distance ? (dy / distance) * pull : 0
|
|
126
|
+
wake.current()
|
|
127
|
+
}}
|
|
128
|
+
onPointerLeave={() => {
|
|
129
|
+
geometry.current.pullX = 0
|
|
130
|
+
geometry.current.pullY = 0
|
|
131
|
+
wake.current()
|
|
132
|
+
}}
|
|
133
|
+
>
|
|
134
|
+
<label
|
|
135
|
+
ref={pill}
|
|
136
|
+
className={cn(
|
|
137
|
+
"passui-search-pill control-field relative block h-11 max-w-full overflow-hidden rounded-full",
|
|
138
|
+
props.disabled && "opacity-40"
|
|
139
|
+
)}
|
|
140
|
+
style={{ width: expanded ? 320 : 44 }}
|
|
141
|
+
>
|
|
142
|
+
<SearchIcon
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
size={18}
|
|
145
|
+
className="pointer-events-none absolute top-1/2 start-[13px] -translate-y-1/2 text-label-secondary"
|
|
146
|
+
/>
|
|
147
|
+
<input
|
|
148
|
+
{...props}
|
|
149
|
+
ref={(node) => {
|
|
150
|
+
input.current = node
|
|
151
|
+
if (typeof inputRef === "function") inputRef(node)
|
|
152
|
+
else if (inputRef) inputRef.current = node
|
|
153
|
+
}}
|
|
154
|
+
type="search"
|
|
155
|
+
placeholder={placeholder}
|
|
156
|
+
aria-label={
|
|
157
|
+
props["aria-labelledby"] ? undefined : (props["aria-label"] ?? placeholder)
|
|
158
|
+
}
|
|
159
|
+
className="h-11 w-full min-w-0 bg-transparent ps-11 pe-3 text-subheadline text-label outline-none placeholder:text-label-tertiary"
|
|
160
|
+
onFocus={(event) => {
|
|
161
|
+
setExpanded(true)
|
|
162
|
+
props.onFocus?.(event)
|
|
163
|
+
}}
|
|
164
|
+
onBlur={(event) => {
|
|
165
|
+
if (!event.currentTarget.value) setExpanded(false)
|
|
166
|
+
props.onBlur?.(event)
|
|
167
|
+
}}
|
|
168
|
+
onKeyDown={(event) => {
|
|
169
|
+
props.onKeyDown?.(event)
|
|
170
|
+
if (
|
|
171
|
+
!event.defaultPrevented &&
|
|
172
|
+
event.key === "Escape" &&
|
|
173
|
+
!event.currentTarget.value
|
|
174
|
+
) {
|
|
175
|
+
setExpanded(false)
|
|
176
|
+
event.currentTarget.blur()
|
|
177
|
+
}
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
</label>
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
@@ -1,26 +1,44 @@
|
|
|
1
1
|
import { forwardRef, type InputHTMLAttributes } from "react"
|
|
2
2
|
import { SearchIcon } from "../../icons/icons"
|
|
3
3
|
import { cn } from "../../lib/class-names"
|
|
4
|
+
import { ExpandingSearchField } from "./expanding-search-field"
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export interface SearchFieldProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
7
|
+
/** Expand a single pill from its search icon on focus. @default false */
|
|
8
|
+
collapsible?: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(function SearchField(
|
|
12
|
+
{ className, placeholder = "Search", collapsible = false, ...props },
|
|
10
13
|
ref
|
|
11
14
|
) {
|
|
15
|
+
if (collapsible)
|
|
16
|
+
return (
|
|
17
|
+
<ExpandingSearchField
|
|
18
|
+
{...props}
|
|
19
|
+
inputRef={ref}
|
|
20
|
+
className={className}
|
|
21
|
+
placeholder={placeholder}
|
|
22
|
+
/>
|
|
23
|
+
)
|
|
24
|
+
const accessibleName = props["aria-labelledby"]
|
|
25
|
+
? undefined
|
|
26
|
+
: (props["aria-label"] ?? placeholder)
|
|
12
27
|
return (
|
|
13
28
|
<label
|
|
14
29
|
className={cn(
|
|
15
|
-
"control-field flex items-center gap-2 rounded-
|
|
30
|
+
"control-field flex items-center gap-2 rounded-full px-3 py-2 text-subheadline text-label-tertiary",
|
|
16
31
|
className
|
|
17
32
|
)}
|
|
18
33
|
>
|
|
19
|
-
<
|
|
34
|
+
<span aria-hidden="true" className="shrink-0">
|
|
35
|
+
<SearchIcon size={15} strokeWidth={2} />
|
|
36
|
+
</span>
|
|
20
37
|
<input
|
|
21
38
|
ref={ref}
|
|
22
39
|
type="search"
|
|
23
40
|
placeholder={placeholder}
|
|
41
|
+
aria-label={accessibleName}
|
|
24
42
|
className="min-w-0 grow bg-transparent text-label outline-none placeholder:text-label-tertiary"
|
|
25
43
|
{...props}
|
|
26
44
|
/>
|