@passui/react 0.1.17 → 0.1.19
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 +102 -1
- 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/ambient/ambient.d.ts +12 -0
- package/dist/types/src/components/ambient/index.d.ts +1 -0
- package/dist/types/src/components/button/button-styles.d.ts +12 -0
- package/dist/types/src/components/button/button.d.ts +30 -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/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-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 +22 -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 +21 -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 +13 -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/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/picker/picker-trigger.d.ts +2 -0
- package/dist/types/src/components/picker/picker.d.ts +37 -0
- package/dist/types/src/components/popover/popover-fit.d.ts +21 -0
- package/dist/types/src/components/popover/popover.d.ts +14 -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/search-field/search-field.d.ts +2 -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 +18 -0
- package/dist/types/src/components/slider/slider.d.ts +14 -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/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 +18 -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/hooks/scroll/minimize-decision.d.ts +2 -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 +58 -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 +192 -40
- package/src/appearance/platform.tsx +10 -47
- package/src/appearance/theme.tsx +42 -142
- package/src/components/ambient/ambient.tsx +2 -10
- package/src/components/button/button-styles.ts +13 -31
- package/src/components/button/button.tsx +19 -14
- 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/compact-date-picker/calendar-month.ts +13 -57
- package/src/components/compact-date-picker/compact-date-picker.tsx +44 -123
- package/src/components/compact-time-picker/compact-time-picker.tsx +46 -130
- package/src/components/compact-time-picker/time-value.ts +4 -16
- 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 +125 -195
- package/src/components/context-menu/context-menu-store.ts +3 -11
- 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 +13 -54
- 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 +31 -76
- package/src/components/dialog/dialog-store.ts +1 -3
- package/src/components/dialog/dialog.tsx +23 -80
- package/src/components/disclosure-group/disclosure-group.tsx +70 -0
- package/src/components/divider/divider.tsx +31 -0
- package/src/components/inline-disclosure/inline-disclosure.tsx +49 -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/picker/picker-trigger.ts +10 -0
- package/src/components/picker/picker.tsx +72 -203
- package/src/components/popover/popover-fit.ts +69 -0
- package/src/components/popover/popover.tsx +94 -77
- package/src/components/profile-image/profile-image.tsx +6 -28
- package/src/components/progress-view/progress-view.tsx +65 -0
- package/src/components/search-field/search-field.tsx +27 -25
- package/src/components/search-list/search-list.tsx +43 -69
- 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 +27 -30
- package/src/components/slider/slider.tsx +76 -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/stepper.tsx +80 -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 +11 -40
- package/src/components/toast/toast-store.ts +9 -30
- package/src/components/toast/toaster.tsx +90 -104
- package/src/components/toggle/toggle.tsx +28 -24
- package/src/components/tooltip/tooltip-host.tsx +70 -67
- package/src/components/view-controller/view-controller.tsx +4 -21
- package/src/hooks/scroll/minimize-decision.ts +1 -5
- package/src/hooks/use-anchored-placement.ts +4 -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 +167 -121
- package/src/index.ts +9 -1
- package/src/lib/anchored-placement.ts +5 -15
- 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/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,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AnimatePresence,
|
|
3
|
-
type HTMLMotionProps,
|
|
4
|
-
motion,
|
|
5
|
-
useReducedMotion,
|
|
6
|
-
} from "motion/react"
|
|
1
|
+
import { AnimatePresence, type HTMLMotionProps, motion, useReducedMotion } from "motion/react"
|
|
7
2
|
import { useLayoutEffect, useRef, useState } from "react"
|
|
8
3
|
import { cn } from "../../lib/class-names"
|
|
9
4
|
import { screenEdges } from "../../lib/screen-edges"
|
|
10
|
-
import {
|
|
5
|
+
import { floatingPanelMotion } from "../../motion/transitions"
|
|
6
|
+
import { fitPopover, type PopoverFit } from "./popover-fit"
|
|
11
7
|
|
|
12
8
|
export type PopoverOrigin = "top-left" | "top-right"
|
|
13
9
|
|
|
@@ -17,24 +13,14 @@ export interface PopoverProps extends HTMLMotionProps<"div"> {
|
|
|
17
13
|
origin?: PopoverOrigin
|
|
18
14
|
}
|
|
19
15
|
|
|
20
|
-
interface PopoverFit {
|
|
21
|
-
shift: number
|
|
22
|
-
maxWidth?: number
|
|
23
|
-
maxHeight?: number
|
|
24
|
-
}
|
|
25
|
-
|
|
26
16
|
/**
|
|
27
17
|
* A glass surface that springs open from its anchor. Position it with
|
|
28
18
|
* `className` (it is absolutely positioned within a relative parent); it
|
|
29
|
-
*
|
|
30
|
-
*
|
|
19
|
+
* flips above its relative parent when the bottom edge is short, and
|
|
20
|
+
* stays inside the visible viewport as it resizes or scrolls.
|
|
31
21
|
*/
|
|
32
22
|
export function Popover({ open, ...props }: PopoverProps) {
|
|
33
|
-
return
|
|
34
|
-
<AnimatePresence>
|
|
35
|
-
{open && <OpenPopover {...props} />}
|
|
36
|
-
</AnimatePresence>
|
|
37
|
-
)
|
|
23
|
+
return <AnimatePresence>{open && <OpenPopover {...props} />}</AnimatePresence>
|
|
38
24
|
}
|
|
39
25
|
|
|
40
26
|
function OpenPopover({
|
|
@@ -46,90 +32,121 @@ function OpenPopover({
|
|
|
46
32
|
}: Omit<PopoverProps, "open">) {
|
|
47
33
|
const ref = useRef<HTMLDivElement>(null)
|
|
48
34
|
const reducedMotion = useReducedMotion()
|
|
49
|
-
const [fit, setFit] = useState<PopoverFit>({
|
|
35
|
+
const [fit, setFit] = useState<PopoverFit>({
|
|
36
|
+
shiftX: 0,
|
|
37
|
+
shiftY: 0,
|
|
38
|
+
maxWidth: 0,
|
|
39
|
+
above: false,
|
|
40
|
+
})
|
|
41
|
+
const popoverMotion = floatingPanelMotion(fit.above ? "above" : "below")
|
|
50
42
|
|
|
51
43
|
useLayoutEffect(() => {
|
|
52
44
|
const refit = () => {
|
|
53
45
|
const element = ref.current
|
|
54
46
|
if (!element) return
|
|
55
|
-
//
|
|
47
|
+
// Measure the authored position without the opening animation or
|
|
48
|
+
// our viewport correction. This prevents cumulative drift.
|
|
56
49
|
const transform = element.style.transform
|
|
50
|
+
const translate = element.style.translate
|
|
51
|
+
const maxHeight = element.style.maxHeight
|
|
52
|
+
const maxWidth = element.style.maxWidth
|
|
57
53
|
element.style.transform = "none"
|
|
54
|
+
element.style.translate = "none"
|
|
55
|
+
element.style.maxHeight = "none"
|
|
56
|
+
element.style.maxWidth = "none"
|
|
58
57
|
const rect = element.getBoundingClientRect()
|
|
58
|
+
const neededHeight = Math.max(rect.height, element.scrollHeight)
|
|
59
59
|
element.style.transform = transform
|
|
60
|
+
element.style.translate = translate
|
|
61
|
+
element.style.maxHeight = maxHeight
|
|
62
|
+
element.style.maxWidth = maxWidth
|
|
63
|
+
|
|
64
|
+
const visualViewport = window.visualViewport
|
|
65
|
+
const offsetLeft = visualViewport?.offsetLeft ?? 0
|
|
66
|
+
const offsetTop = visualViewport?.offsetTop ?? 0
|
|
60
67
|
const edges = screenEdges()
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:
|
|
68
|
+
const offsetParent = element.offsetParent
|
|
69
|
+
const anchor =
|
|
70
|
+
offsetParent instanceof HTMLElement && offsetParent !== document.body
|
|
71
|
+
? offsetParent.getBoundingClientRect()
|
|
72
|
+
: undefined
|
|
73
|
+
const next = fitPopover(
|
|
74
|
+
{
|
|
75
|
+
left: rect.left,
|
|
76
|
+
top: rect.top,
|
|
77
|
+
width: rect.width,
|
|
78
|
+
height: neededHeight,
|
|
79
|
+
},
|
|
80
|
+
anchor,
|
|
81
|
+
{
|
|
82
|
+
viewport: {
|
|
83
|
+
width: offsetLeft + (visualViewport?.width ?? window.innerWidth),
|
|
84
|
+
height: offsetTop + (visualViewport?.height ?? window.innerHeight),
|
|
85
|
+
},
|
|
86
|
+
edges: {
|
|
87
|
+
...edges,
|
|
88
|
+
left: offsetLeft + edges.left,
|
|
89
|
+
top: offsetTop + edges.top,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
6,
|
|
93
|
+
origin
|
|
94
|
+
)
|
|
95
|
+
setFit((current) => {
|
|
96
|
+
if (
|
|
97
|
+
current.shiftX === next.shiftX &&
|
|
98
|
+
current.shiftY === next.shiftY &&
|
|
99
|
+
current.maxWidth === next.maxWidth &&
|
|
100
|
+
current.maxHeight === next.maxHeight &&
|
|
101
|
+
current.above === next.above
|
|
102
|
+
)
|
|
103
|
+
return current
|
|
104
|
+
return next
|
|
78
105
|
})
|
|
79
106
|
}
|
|
80
107
|
refit()
|
|
108
|
+
let frame = 0
|
|
109
|
+
const scheduleRefit = () => {
|
|
110
|
+
cancelAnimationFrame(frame)
|
|
111
|
+
frame = requestAnimationFrame(refit)
|
|
112
|
+
}
|
|
113
|
+
const observer = new ResizeObserver(scheduleRefit)
|
|
114
|
+
if (ref.current) observer.observe(ref.current)
|
|
81
115
|
const viewport = window.visualViewport
|
|
82
|
-
viewport?.addEventListener("resize",
|
|
83
|
-
viewport?.addEventListener("scroll",
|
|
84
|
-
window.addEventListener("resize",
|
|
85
|
-
window.addEventListener("scroll",
|
|
116
|
+
viewport?.addEventListener("resize", scheduleRefit)
|
|
117
|
+
viewport?.addEventListener("scroll", scheduleRefit)
|
|
118
|
+
window.addEventListener("resize", scheduleRefit)
|
|
119
|
+
window.addEventListener("scroll", scheduleRefit, true)
|
|
86
120
|
return () => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
121
|
+
observer.disconnect()
|
|
122
|
+
cancelAnimationFrame(frame)
|
|
123
|
+
viewport?.removeEventListener("resize", scheduleRefit)
|
|
124
|
+
viewport?.removeEventListener("scroll", scheduleRefit)
|
|
125
|
+
window.removeEventListener("resize", scheduleRefit)
|
|
126
|
+
window.removeEventListener("scroll", scheduleRefit, true)
|
|
91
127
|
}
|
|
92
|
-
}, [])
|
|
128
|
+
}, [origin])
|
|
93
129
|
|
|
94
130
|
return (
|
|
95
131
|
<motion.div
|
|
96
132
|
ref={ref}
|
|
97
133
|
{...popoverMotion}
|
|
98
|
-
initial={
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
animate={
|
|
104
|
-
reducedMotion
|
|
105
|
-
? { opacity: 1 }
|
|
106
|
-
: popoverMotion.animate
|
|
107
|
-
}
|
|
108
|
-
exit={
|
|
109
|
-
reducedMotion
|
|
110
|
-
? { opacity: 0 }
|
|
111
|
-
: popoverMotion.exit
|
|
112
|
-
}
|
|
113
|
-
transition={
|
|
114
|
-
reducedMotion
|
|
115
|
-
? { duration: 0 }
|
|
116
|
-
: popoverMotion.transition
|
|
117
|
-
}
|
|
134
|
+
initial={reducedMotion ? { opacity: 0 } : popoverMotion.initial}
|
|
135
|
+
animate={reducedMotion ? { opacity: 1 } : popoverMotion.animate}
|
|
136
|
+
exit={reducedMotion ? { opacity: 0 } : popoverMotion.exit}
|
|
137
|
+
transition={reducedMotion ? { duration: 0 } : popoverMotion.transition}
|
|
118
138
|
style={{
|
|
119
139
|
transformOrigin:
|
|
120
140
|
origin === "top-left"
|
|
121
|
-
?
|
|
122
|
-
: "100% 0%"
|
|
123
|
-
|
|
124
|
-
maxWidth: fit.maxWidth,
|
|
141
|
+
? `0% ${fit.above ? "100%" : "0%"}`
|
|
142
|
+
: `100% ${fit.above ? "100%" : "0%"}`,
|
|
143
|
+
translate: `${fit.shiftX}px ${fit.shiftY}px`,
|
|
144
|
+
maxWidth: fit.maxWidth || undefined,
|
|
125
145
|
maxHeight: fit.maxHeight,
|
|
126
|
-
overflowY: fit.maxHeight ? "auto" : undefined,
|
|
146
|
+
overflowY: fit.maxHeight !== undefined ? "auto" : undefined,
|
|
127
147
|
...style,
|
|
128
148
|
}}
|
|
129
|
-
className={cn(
|
|
130
|
-
"glass-menu absolute z-40 rounded-5xl",
|
|
131
|
-
className
|
|
132
|
-
)}
|
|
149
|
+
className={cn("glass-menu absolute z-40 rounded-5xl", className)}
|
|
133
150
|
{...props}
|
|
134
151
|
>
|
|
135
152
|
{children}
|
|
@@ -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,65 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "react"
|
|
2
|
+
import { cn } from "../../lib/class-names"
|
|
3
|
+
import { clampRange } from "../../lib/range-value"
|
|
4
|
+
|
|
5
|
+
export type ProgressViewSize = "sm" | "md" | "lg"
|
|
6
|
+
|
|
7
|
+
export interface ProgressViewProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
8
|
+
label: string
|
|
9
|
+
/** Omit for an indeterminate operation. */
|
|
10
|
+
value?: number
|
|
11
|
+
max?: number
|
|
12
|
+
size?: ProgressViewSize
|
|
13
|
+
/** Secondary text, such as bytes uploaded. */
|
|
14
|
+
detail?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const trackHeight: Record<ProgressViewSize, string> = {
|
|
18
|
+
sm: "h-1",
|
|
19
|
+
md: "h-2",
|
|
20
|
+
lg: "h-3",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A determinate or indeterminate progress track respecting reduced motion. */
|
|
24
|
+
export function ProgressView({
|
|
25
|
+
label,
|
|
26
|
+
value,
|
|
27
|
+
max = 100,
|
|
28
|
+
size = "md",
|
|
29
|
+
detail,
|
|
30
|
+
className,
|
|
31
|
+
...props
|
|
32
|
+
}: ProgressViewProps) {
|
|
33
|
+
const limit = Number.isFinite(max) && max > 0 ? max : 100
|
|
34
|
+
const current = value === undefined ? undefined : clampRange(value, 0, limit)
|
|
35
|
+
const progress = current === undefined ? undefined : (current / limit) * 100
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div {...props} className={cn("flex min-w-0 flex-col gap-2", className)}>
|
|
39
|
+
<div className="flex items-center justify-between gap-3 text-footnote">
|
|
40
|
+
<span className="font-semibold text-label">{label}</span>
|
|
41
|
+
{detail && <span className="text-label-secondary">{detail}</span>}
|
|
42
|
+
</div>
|
|
43
|
+
<div
|
|
44
|
+
role="progressbar"
|
|
45
|
+
aria-label={label}
|
|
46
|
+
aria-valuemin={current === undefined ? undefined : 0}
|
|
47
|
+
aria-valuemax={current === undefined ? undefined : limit}
|
|
48
|
+
aria-valuenow={current}
|
|
49
|
+
className={cn(
|
|
50
|
+
"relative w-full overflow-hidden rounded-full bg-separator/70",
|
|
51
|
+
trackHeight[size]
|
|
52
|
+
)}
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
aria-hidden="true"
|
|
56
|
+
className={cn(
|
|
57
|
+
"h-full rounded-full bg-accent",
|
|
58
|
+
current === undefined && "w-1/3 animate-pulse motion-reduce:animate-none"
|
|
59
|
+
)}
|
|
60
|
+
style={progress === undefined ? undefined : { width: `${progress}%` }}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
@@ -2,28 +2,30 @@ import { forwardRef, type InputHTMLAttributes } from "react"
|
|
|
2
2
|
import { SearchIcon } from "../../icons/icons"
|
|
3
3
|
import { cn } from "../../lib/class-names"
|
|
4
4
|
|
|
5
|
-
export const SearchField = forwardRef<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
export const SearchField = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(
|
|
6
|
+
function SearchField({ className, placeholder = "Search", ...props }, ref) {
|
|
7
|
+
const accessibleName = props["aria-labelledby"]
|
|
8
|
+
? undefined
|
|
9
|
+
: (props["aria-label"] ?? placeholder)
|
|
10
|
+
return (
|
|
11
|
+
<label
|
|
12
|
+
className={cn(
|
|
13
|
+
"control-field flex items-center gap-2 rounded-lg px-2.5 py-2 text-subheadline text-label-tertiary",
|
|
14
|
+
className
|
|
15
|
+
)}
|
|
16
|
+
>
|
|
17
|
+
<span aria-hidden="true" className="shrink-0">
|
|
18
|
+
<SearchIcon size={15} strokeWidth={2} />
|
|
19
|
+
</span>
|
|
20
|
+
<input
|
|
21
|
+
ref={ref}
|
|
22
|
+
type="search"
|
|
23
|
+
placeholder={placeholder}
|
|
24
|
+
aria-label={accessibleName}
|
|
25
|
+
className="min-w-0 grow bg-transparent text-label outline-none placeholder:text-label-tertiary"
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
</label>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
)
|
|
@@ -22,15 +22,12 @@ type SearchState = {
|
|
|
22
22
|
const SearchContext = createContext<SearchState | null>(null)
|
|
23
23
|
function useSearch() {
|
|
24
24
|
const search = useContext(SearchContext)
|
|
25
|
-
if (!search)
|
|
26
|
-
throw new Error(
|
|
27
|
-
"Search list controls need a SearchList parent"
|
|
28
|
-
)
|
|
25
|
+
if (!search) throw new Error("Search list controls need a SearchList parent")
|
|
29
26
|
return search
|
|
30
27
|
}
|
|
31
28
|
|
|
32
29
|
export function SearchList({
|
|
33
|
-
loop
|
|
30
|
+
loop = true,
|
|
34
31
|
open = true,
|
|
35
32
|
onKeyDown,
|
|
36
33
|
className,
|
|
@@ -41,9 +38,7 @@ export function SearchList({
|
|
|
41
38
|
}) {
|
|
42
39
|
const [query, setQuery] = useState("")
|
|
43
40
|
const [active, setActive] = useState("")
|
|
44
|
-
const [results, setResults] = useState<
|
|
45
|
-
Record<string, boolean>
|
|
46
|
-
>({})
|
|
41
|
+
const [results, setResults] = useState<Record<string, boolean>>({})
|
|
47
42
|
const listId = useId()
|
|
48
43
|
const ref = useRef<HTMLDivElement>(null)
|
|
49
44
|
const register = useCallback(
|
|
@@ -70,9 +65,7 @@ export function SearchList({
|
|
|
70
65
|
active,
|
|
71
66
|
listId,
|
|
72
67
|
open,
|
|
73
|
-
visible:
|
|
74
|
-
Object.values(results).filter(Boolean)
|
|
75
|
-
.length,
|
|
68
|
+
visible: Object.values(results).filter(Boolean).length,
|
|
76
69
|
register,
|
|
77
70
|
}}
|
|
78
71
|
>
|
|
@@ -82,39 +75,35 @@ export function SearchList({
|
|
|
82
75
|
className={cn("relative", className)}
|
|
83
76
|
onKeyDown={(event) => {
|
|
84
77
|
onKeyDown?.(event)
|
|
85
|
-
if (event.defaultPrevented || !open)
|
|
86
|
-
return
|
|
78
|
+
if (event.defaultPrevented || !open) return
|
|
87
79
|
const items = Array.from(
|
|
88
80
|
ref.current?.querySelectorAll<HTMLButtonElement>(
|
|
89
81
|
"[data-search-result]:not([hidden]):not(:disabled)"
|
|
90
82
|
) ?? []
|
|
91
83
|
)
|
|
92
|
-
if (!items.length) return
|
|
93
|
-
const index = items.findIndex(
|
|
94
|
-
(item) => item.id === active
|
|
95
|
-
)
|
|
84
|
+
if (!items.length || event.altKey || event.ctrlKey || event.metaKey) return
|
|
85
|
+
const index = items.findIndex((item) => item.id === active)
|
|
96
86
|
if (event.key === "Enter") {
|
|
87
|
+
if (
|
|
88
|
+
event.target instanceof HTMLElement &&
|
|
89
|
+
event.target.closest("button, a")
|
|
90
|
+
)
|
|
91
|
+
return
|
|
97
92
|
event.preventDefault()
|
|
98
93
|
;(items[index] ?? items[0])?.click()
|
|
99
94
|
return
|
|
100
95
|
}
|
|
101
|
-
if (
|
|
102
|
-
event.key !== "ArrowDown" &&
|
|
103
|
-
event.key !== "ArrowUp"
|
|
104
|
-
)
|
|
105
|
-
return
|
|
96
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return
|
|
106
97
|
event.preventDefault()
|
|
98
|
+
const delta = event.key === "ArrowDown" ? 1 : -1
|
|
107
99
|
const next =
|
|
108
100
|
index < 0
|
|
109
|
-
?
|
|
101
|
+
? delta === 1
|
|
110
102
|
? 0
|
|
111
103
|
: items.length - 1
|
|
112
|
-
:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
: -1) +
|
|
116
|
-
items.length) %
|
|
117
|
-
items.length
|
|
104
|
+
: loop
|
|
105
|
+
? (index + delta + items.length) % items.length
|
|
106
|
+
: Math.max(0, Math.min(items.length - 1, index + delta))
|
|
118
107
|
const item = items[next]
|
|
119
108
|
if (!item) return
|
|
120
109
|
setActive(item.id)
|
|
@@ -143,14 +132,8 @@ export function SearchListField({
|
|
|
143
132
|
aria-autocomplete="list"
|
|
144
133
|
aria-expanded={search.open}
|
|
145
134
|
aria-controls={search.listId}
|
|
146
|
-
aria-activedescendant={
|
|
147
|
-
|
|
148
|
-
? search.active
|
|
149
|
-
: undefined
|
|
150
|
-
}
|
|
151
|
-
aria-label={
|
|
152
|
-
props["aria-label"] ?? props.placeholder
|
|
153
|
-
}
|
|
135
|
+
aria-activedescendant={search.open && search.active ? search.active : undefined}
|
|
136
|
+
aria-label={props["aria-label"] ?? props.placeholder}
|
|
154
137
|
value={value ?? search.query}
|
|
155
138
|
onChange={(event) => {
|
|
156
139
|
search.setQuery(event.target.value)
|
|
@@ -163,10 +146,7 @@ export function SearchListField({
|
|
|
163
146
|
/>
|
|
164
147
|
)
|
|
165
148
|
}
|
|
166
|
-
export function SearchListResults({
|
|
167
|
-
className,
|
|
168
|
-
...props
|
|
169
|
-
}: ComponentProps<"div">) {
|
|
149
|
+
export function SearchListResults({ className, ...props }: ComponentProps<"div">) {
|
|
170
150
|
const search = useSearch()
|
|
171
151
|
return (
|
|
172
152
|
<div
|
|
@@ -178,42 +158,34 @@ export function SearchListResults({
|
|
|
178
158
|
/>
|
|
179
159
|
)
|
|
180
160
|
}
|
|
181
|
-
export function SearchListEmpty(
|
|
182
|
-
props: ComponentProps<"div">
|
|
183
|
-
) {
|
|
161
|
+
export function SearchListEmpty(props: ComponentProps<"div">) {
|
|
184
162
|
const search = useSearch()
|
|
185
|
-
return search.visible ? null :
|
|
186
|
-
<div {...props} role="status" />
|
|
187
|
-
)
|
|
163
|
+
return search.visible ? null : <div {...props} role="status" />
|
|
188
164
|
}
|
|
189
165
|
export function SearchListGroup({
|
|
190
166
|
heading,
|
|
191
167
|
children,
|
|
192
168
|
className,
|
|
193
169
|
...props
|
|
194
|
-
}: ComponentProps<"
|
|
170
|
+
}: ComponentProps<"div"> & {
|
|
195
171
|
heading?: React.ReactNode
|
|
196
172
|
}) {
|
|
197
173
|
const id = useId()
|
|
198
174
|
return (
|
|
199
|
-
|
|
175
|
+
// biome-ignore lint/a11y/useSemanticElements: Listbox option groups are not form fieldsets.
|
|
176
|
+
<div
|
|
200
177
|
{...props}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
className
|
|
204
|
-
)}
|
|
178
|
+
role="group"
|
|
179
|
+
className={cn("not-has-[[data-search-result]:not([hidden])]:hidden", className)}
|
|
205
180
|
aria-labelledby={heading ? id : undefined}
|
|
206
181
|
>
|
|
207
182
|
{heading && (
|
|
208
|
-
<
|
|
209
|
-
id={id}
|
|
210
|
-
className="px-2 py-2 text-caption font-medium text-label-tertiary"
|
|
211
|
-
>
|
|
183
|
+
<div id={id} className="px-2 py-2 text-caption font-medium text-label-tertiary">
|
|
212
184
|
{heading}
|
|
213
|
-
</
|
|
185
|
+
</div>
|
|
214
186
|
)}
|
|
215
187
|
{children}
|
|
216
|
-
</
|
|
188
|
+
</div>
|
|
217
189
|
)
|
|
218
190
|
}
|
|
219
191
|
export function SearchListItem({
|
|
@@ -229,18 +201,16 @@ export function SearchListItem({
|
|
|
229
201
|
}) {
|
|
230
202
|
const search = useSearch()
|
|
231
203
|
const id = useId()
|
|
232
|
-
const haystack = [value, ...keywords]
|
|
233
|
-
.join(" ")
|
|
234
|
-
.toLocaleLowerCase()
|
|
204
|
+
const haystack = [value, ...keywords].join(" ").toLocaleLowerCase()
|
|
235
205
|
const visible = search.query
|
|
236
206
|
.toLocaleLowerCase()
|
|
237
207
|
.trim()
|
|
238
208
|
.split(/\s+/)
|
|
239
209
|
.every((word) => haystack.includes(word))
|
|
240
210
|
useEffect(() => {
|
|
241
|
-
search.register(id, visible)
|
|
211
|
+
search.register(id, visible && !props.disabled)
|
|
242
212
|
return () => search.register(id, null)
|
|
243
|
-
}, [id, visible, search.register])
|
|
213
|
+
}, [id, visible, props.disabled, search.register])
|
|
244
214
|
return (
|
|
245
215
|
<button
|
|
246
216
|
{...props}
|
|
@@ -251,15 +221,19 @@ export function SearchListItem({
|
|
|
251
221
|
hidden={!visible}
|
|
252
222
|
data-search-result=""
|
|
253
223
|
aria-selected={search.active === id}
|
|
254
|
-
data-selected={
|
|
255
|
-
search.active === id ? "true" : undefined
|
|
256
|
-
}
|
|
224
|
+
data-selected={search.active === id ? "true" : undefined}
|
|
257
225
|
className={cn(
|
|
258
226
|
"flex w-full items-center gap-2 rounded-xl px-3 py-2 text-left hover:bg-fill aria-selected:bg-accent-soft",
|
|
259
227
|
className
|
|
260
228
|
)}
|
|
261
|
-
onMouseDown={(event) =>
|
|
262
|
-
|
|
229
|
+
onMouseDown={(event) => {
|
|
230
|
+
props.onMouseDown?.(event)
|
|
231
|
+
if (!event.defaultPrevented) event.preventDefault()
|
|
232
|
+
}}
|
|
233
|
+
onClick={(event) => {
|
|
234
|
+
props.onClick?.(event)
|
|
235
|
+
if (!event.defaultPrevented) onSelect?.(value)
|
|
236
|
+
}}
|
|
263
237
|
/>
|
|
264
238
|
)
|
|
265
239
|
}
|