@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,66 +0,0 @@
|
|
|
1
|
-
import { forwardRef, type InputHTMLAttributes } from "react";
|
|
2
|
-
import { SearchIcon } from "../../icons/icons";
|
|
3
|
-
import { cn } from "../../lib/class-names";
|
|
4
|
-
import { ExpandingSearchField } from "./expanding-search-field";
|
|
5
|
-
|
|
6
|
-
export type SearchFieldSize = "sm" | "md" | "lg";
|
|
7
|
-
|
|
8
|
-
const pillSizes: Record<SearchFieldSize, string> = {
|
|
9
|
-
sm: "control-field flex items-center gap-1.5 rounded-full px-2.5 py-1 text-caption text-label-tertiary",
|
|
10
|
-
md: "control-field flex items-center gap-2 rounded-full px-3 py-2 text-subheadline text-label-tertiary",
|
|
11
|
-
lg: "control-field flex items-center gap-2.5 rounded-full px-4 py-2.5 text-body text-label-tertiary",
|
|
12
|
-
};
|
|
13
|
-
const iconSizes: Record<SearchFieldSize, number> = {
|
|
14
|
-
sm: 13,
|
|
15
|
-
md: 15,
|
|
16
|
-
lg: 17,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export interface SearchFieldProps
|
|
20
|
-
extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
21
|
-
/** Expand a single pill from its search icon on focus. @default false */
|
|
22
|
-
collapsible?: boolean;
|
|
23
|
-
/** Pill height, icon size and text scale (non-collapsible variant). @default "md" */
|
|
24
|
-
size?: SearchFieldSize;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(
|
|
28
|
-
function SearchField(
|
|
29
|
-
{
|
|
30
|
-
className,
|
|
31
|
-
placeholder = "Search",
|
|
32
|
-
collapsible = false,
|
|
33
|
-
size = "md",
|
|
34
|
-
...props
|
|
35
|
-
},
|
|
36
|
-
ref,
|
|
37
|
-
) {
|
|
38
|
-
if (collapsible)
|
|
39
|
-
return (
|
|
40
|
-
<ExpandingSearchField
|
|
41
|
-
{...props}
|
|
42
|
-
inputRef={ref}
|
|
43
|
-
className={className}
|
|
44
|
-
placeholder={placeholder}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
const accessibleName = props["aria-labelledby"]
|
|
48
|
-
? undefined
|
|
49
|
-
: (props["aria-label"] ?? placeholder);
|
|
50
|
-
return (
|
|
51
|
-
<label className={cn(pillSizes[size], className)}>
|
|
52
|
-
<span aria-hidden="true" className="shrink-0">
|
|
53
|
-
<SearchIcon size={iconSizes[size]} strokeWidth={2} />
|
|
54
|
-
</span>
|
|
55
|
-
<input
|
|
56
|
-
ref={ref}
|
|
57
|
-
type="search"
|
|
58
|
-
placeholder={placeholder}
|
|
59
|
-
aria-label={accessibleName}
|
|
60
|
-
className="text-label placeholder:text-label-tertiary min-w-0 grow bg-transparent outline-none"
|
|
61
|
-
{...props}
|
|
62
|
-
/>
|
|
63
|
-
</label>
|
|
64
|
-
);
|
|
65
|
-
},
|
|
66
|
-
);
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useCallback,
|
|
4
|
-
useContext,
|
|
5
|
-
useId,
|
|
6
|
-
useRef,
|
|
7
|
-
useState,
|
|
8
|
-
useEffect,
|
|
9
|
-
type ComponentProps,
|
|
10
|
-
} from "react";
|
|
11
|
-
import { cn } from "../../lib/class-names";
|
|
12
|
-
|
|
13
|
-
export type SearchListSize = "sm" | "md" | "lg";
|
|
14
|
-
|
|
15
|
-
const fieldSizes: Record<SearchListSize, string> = {
|
|
16
|
-
sm: "min-h-8 w-full rounded-full border border-separator bg-fill/60 px-3 text-caption text-label outline-none focus-visible:ring-2 focus-visible:ring-accent-text/50",
|
|
17
|
-
md: "min-h-11 w-full rounded-full border border-separator bg-fill/60 px-4 text-subheadline text-label outline-none focus-visible:ring-2 focus-visible:ring-accent-text/50",
|
|
18
|
-
lg: "min-h-13 w-full rounded-full border border-separator bg-fill/60 px-5 text-body text-label outline-none focus-visible:ring-2 focus-visible:ring-accent-text/50",
|
|
19
|
-
};
|
|
20
|
-
const headingSizes: Record<SearchListSize, string> = {
|
|
21
|
-
sm: "px-1.5 py-1.5 text-caption2 font-medium text-label-tertiary",
|
|
22
|
-
md: "px-2 py-2 text-caption font-medium text-label-tertiary",
|
|
23
|
-
lg: "px-2.5 py-2.5 text-subheadline font-medium text-label-tertiary",
|
|
24
|
-
};
|
|
25
|
-
const itemSizes: Record<SearchListSize, string> = {
|
|
26
|
-
sm: "flex min-h-8 w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-footnote text-label hover:bg-fill aria-selected:bg-fill [@media(pointer:coarse)]:min-h-10",
|
|
27
|
-
md: "flex min-h-9 w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-subheadline text-label hover:bg-fill aria-selected:bg-fill [@media(pointer:coarse)]:min-h-11",
|
|
28
|
-
lg: "flex min-h-11 w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left text-body text-label hover:bg-fill aria-selected:bg-fill [@media(pointer:coarse)]:min-h-13",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
type SearchState = {
|
|
32
|
-
query: string;
|
|
33
|
-
setQuery: (query: string) => void;
|
|
34
|
-
active: string;
|
|
35
|
-
listId: string;
|
|
36
|
-
open: boolean;
|
|
37
|
-
visible: number;
|
|
38
|
-
register: (id: string, visible: boolean | null) => void;
|
|
39
|
-
size: SearchListSize;
|
|
40
|
-
};
|
|
41
|
-
const SearchContext = createContext<SearchState | null>(null);
|
|
42
|
-
function useSearch() {
|
|
43
|
-
const search = useContext(SearchContext);
|
|
44
|
-
if (!search) throw new Error("Search list controls need a SearchList parent");
|
|
45
|
-
return search;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function SearchList({
|
|
49
|
-
loop = true,
|
|
50
|
-
open = true,
|
|
51
|
-
size = "md",
|
|
52
|
-
onKeyDown,
|
|
53
|
-
className,
|
|
54
|
-
...props
|
|
55
|
-
}: ComponentProps<"div"> & {
|
|
56
|
-
loop?: boolean;
|
|
57
|
-
open?: boolean;
|
|
58
|
-
/** Field, item and heading density. @default "md" */
|
|
59
|
-
size?: SearchListSize;
|
|
60
|
-
}) {
|
|
61
|
-
const [query, setQuery] = useState("");
|
|
62
|
-
const updateQuery = useCallback((next: string) => {
|
|
63
|
-
setQuery(next);
|
|
64
|
-
setActive("");
|
|
65
|
-
}, []);
|
|
66
|
-
const [active, setActive] = useState("");
|
|
67
|
-
const [results, setResults] = useState<Record<string, boolean>>({});
|
|
68
|
-
const listId = useId();
|
|
69
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
70
|
-
const register = useCallback(
|
|
71
|
-
(id: string, visible: boolean | null) =>
|
|
72
|
-
setResults((previous) => {
|
|
73
|
-
if (visible === null) {
|
|
74
|
-
const next = { ...previous };
|
|
75
|
-
delete next[id];
|
|
76
|
-
return next;
|
|
77
|
-
}
|
|
78
|
-
if (previous[id] === visible) return previous;
|
|
79
|
-
return { ...previous, [id]: visible };
|
|
80
|
-
}),
|
|
81
|
-
[],
|
|
82
|
-
);
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (!open) return;
|
|
85
|
-
const available = Object.keys(results).filter((id) => results[id]);
|
|
86
|
-
if (!available.includes(active)) setActive(available[0] ?? "");
|
|
87
|
-
}, [open, results, active]);
|
|
88
|
-
return (
|
|
89
|
-
<SearchContext
|
|
90
|
-
value={{
|
|
91
|
-
query,
|
|
92
|
-
setQuery: updateQuery,
|
|
93
|
-
active,
|
|
94
|
-
listId,
|
|
95
|
-
open,
|
|
96
|
-
visible: Object.values(results).filter(Boolean).length,
|
|
97
|
-
register,
|
|
98
|
-
size,
|
|
99
|
-
}}
|
|
100
|
-
>
|
|
101
|
-
<div
|
|
102
|
-
{...props}
|
|
103
|
-
ref={ref}
|
|
104
|
-
role="presentation"
|
|
105
|
-
className={cn("relative", className)}
|
|
106
|
-
onKeyDown={(event) => {
|
|
107
|
-
onKeyDown?.(event);
|
|
108
|
-
if (event.defaultPrevented || !open || event.nativeEvent.isComposing)
|
|
109
|
-
return;
|
|
110
|
-
const items = Array.from(
|
|
111
|
-
ref.current?.querySelectorAll<HTMLButtonElement>(
|
|
112
|
-
"[data-search-result]:not([hidden]):not(:disabled)",
|
|
113
|
-
) ?? [],
|
|
114
|
-
);
|
|
115
|
-
if (!items.length || event.altKey || event.ctrlKey || event.metaKey)
|
|
116
|
-
return;
|
|
117
|
-
const index = items.findIndex((item) => item.id === active);
|
|
118
|
-
if (event.key === "Enter") {
|
|
119
|
-
if (
|
|
120
|
-
event.target instanceof HTMLElement &&
|
|
121
|
-
event.target.closest("button, a")
|
|
122
|
-
)
|
|
123
|
-
return;
|
|
124
|
-
event.preventDefault();
|
|
125
|
-
(items[index] ?? items[0])?.click();
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
129
|
-
event.preventDefault();
|
|
130
|
-
const delta = event.key === "ArrowDown" ? 1 : -1;
|
|
131
|
-
const next =
|
|
132
|
-
index < 0
|
|
133
|
-
? delta === 1
|
|
134
|
-
? 0
|
|
135
|
-
: items.length - 1
|
|
136
|
-
: loop
|
|
137
|
-
? (index + delta + items.length) % items.length
|
|
138
|
-
: Math.max(0, Math.min(items.length - 1, index + delta));
|
|
139
|
-
const item = items[next];
|
|
140
|
-
if (!item) return;
|
|
141
|
-
setActive(item.id);
|
|
142
|
-
item.scrollIntoView({
|
|
143
|
-
block: "nearest",
|
|
144
|
-
});
|
|
145
|
-
}}
|
|
146
|
-
/>
|
|
147
|
-
</SearchContext>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
export function SearchListField({
|
|
151
|
-
value,
|
|
152
|
-
onValueChange,
|
|
153
|
-
className,
|
|
154
|
-
...props
|
|
155
|
-
}: Omit<ComponentProps<"input">, "value" | "onChange"> & {
|
|
156
|
-
value?: string;
|
|
157
|
-
onValueChange?: (value: string) => void;
|
|
158
|
-
}) {
|
|
159
|
-
const search = useSearch();
|
|
160
|
-
useEffect(() => {
|
|
161
|
-
if (value !== undefined) search.setQuery(value);
|
|
162
|
-
}, [value, search.setQuery]);
|
|
163
|
-
return (
|
|
164
|
-
<input
|
|
165
|
-
{...props}
|
|
166
|
-
role="combobox"
|
|
167
|
-
aria-autocomplete="list"
|
|
168
|
-
aria-expanded={search.open}
|
|
169
|
-
aria-controls={search.open ? search.listId : undefined}
|
|
170
|
-
aria-activedescendant={
|
|
171
|
-
search.open && search.active ? search.active : undefined
|
|
172
|
-
}
|
|
173
|
-
aria-label={props["aria-label"] ?? props.placeholder}
|
|
174
|
-
value={value ?? search.query}
|
|
175
|
-
onChange={(event) => {
|
|
176
|
-
search.setQuery(event.target.value);
|
|
177
|
-
onValueChange?.(event.target.value);
|
|
178
|
-
}}
|
|
179
|
-
className={cn(fieldSizes[search.size], className)}
|
|
180
|
-
/>
|
|
181
|
-
);
|
|
182
|
-
}
|
|
183
|
-
export function SearchListResults({
|
|
184
|
-
className,
|
|
185
|
-
...props
|
|
186
|
-
}: ComponentProps<"div">) {
|
|
187
|
-
const search = useSearch();
|
|
188
|
-
return (
|
|
189
|
-
<div
|
|
190
|
-
{...props}
|
|
191
|
-
id={search.listId}
|
|
192
|
-
role="listbox"
|
|
193
|
-
hidden={!search.open}
|
|
194
|
-
className={cn("overflow-y-auto p-1", className)}
|
|
195
|
-
/>
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
export function SearchListEmpty(props: ComponentProps<"div">) {
|
|
199
|
-
const search = useSearch();
|
|
200
|
-
return search.visible ? null : <div {...props} role="status" />;
|
|
201
|
-
}
|
|
202
|
-
export function SearchListGroup({
|
|
203
|
-
heading,
|
|
204
|
-
children,
|
|
205
|
-
className,
|
|
206
|
-
...props
|
|
207
|
-
}: ComponentProps<"div"> & {
|
|
208
|
-
heading?: React.ReactNode;
|
|
209
|
-
}) {
|
|
210
|
-
const search = useSearch();
|
|
211
|
-
const id = useId();
|
|
212
|
-
return (
|
|
213
|
-
<div
|
|
214
|
-
{...props}
|
|
215
|
-
role="group"
|
|
216
|
-
className={cn(
|
|
217
|
-
"not-has-[[data-search-result]:not([hidden])]:hidden",
|
|
218
|
-
className,
|
|
219
|
-
)}
|
|
220
|
-
aria-labelledby={heading ? id : undefined}
|
|
221
|
-
>
|
|
222
|
-
{heading && (
|
|
223
|
-
<div id={id} className={headingSizes[search.size]}>
|
|
224
|
-
{heading}
|
|
225
|
-
</div>
|
|
226
|
-
)}
|
|
227
|
-
{children}
|
|
228
|
-
</div>
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
export function SearchListItem({
|
|
232
|
-
value,
|
|
233
|
-
keywords = [],
|
|
234
|
-
onSelect,
|
|
235
|
-
className,
|
|
236
|
-
...props
|
|
237
|
-
}: Omit<ComponentProps<"button">, "value" | "onSelect"> & {
|
|
238
|
-
value: string;
|
|
239
|
-
keywords?: string[];
|
|
240
|
-
onSelect?: (value: string) => void;
|
|
241
|
-
}) {
|
|
242
|
-
const search = useSearch();
|
|
243
|
-
const id = useId();
|
|
244
|
-
const haystack = [value, ...keywords].join(" ").toLocaleLowerCase();
|
|
245
|
-
const visible = search.query
|
|
246
|
-
.toLocaleLowerCase()
|
|
247
|
-
.trim()
|
|
248
|
-
.split(/\s+/)
|
|
249
|
-
.every((word) => haystack.includes(word));
|
|
250
|
-
useEffect(() => {
|
|
251
|
-
search.register(id, visible && !props.disabled);
|
|
252
|
-
return () => search.register(id, null);
|
|
253
|
-
}, [id, visible, props.disabled, search.register]);
|
|
254
|
-
return (
|
|
255
|
-
<button
|
|
256
|
-
{...props}
|
|
257
|
-
type="button"
|
|
258
|
-
id={id}
|
|
259
|
-
role="option"
|
|
260
|
-
tabIndex={-1}
|
|
261
|
-
hidden={!visible}
|
|
262
|
-
data-search-result=""
|
|
263
|
-
aria-selected={search.active === id}
|
|
264
|
-
data-selected={search.active === id ? "true" : undefined}
|
|
265
|
-
className={cn(itemSizes[search.size], className)}
|
|
266
|
-
onMouseDown={(event) => {
|
|
267
|
-
props.onMouseDown?.(event);
|
|
268
|
-
if (!event.defaultPrevented) event.preventDefault();
|
|
269
|
-
}}
|
|
270
|
-
onClick={(event) => {
|
|
271
|
-
props.onClick?.(event);
|
|
272
|
-
if (!event.defaultPrevented) onSelect?.(value);
|
|
273
|
-
}}
|
|
274
|
-
/>
|
|
275
|
-
);
|
|
276
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { useId, type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
|
|
4
|
-
export type SectionSize = "sm" | "md" | "lg";
|
|
5
|
-
|
|
6
|
-
const titleSizes: Record<SectionSize, string> = {
|
|
7
|
-
sm: "px-3 text-caption",
|
|
8
|
-
md: "px-4 text-footnote",
|
|
9
|
-
lg: "px-5 text-subheadline",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const footerSizes: Record<SectionSize, string> = {
|
|
13
|
-
sm: "px-3",
|
|
14
|
-
md: "px-4",
|
|
15
|
-
lg: "px-5",
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export interface SectionProps extends HTMLAttributes<HTMLElement> {
|
|
19
|
-
/** Optional group heading and accessible name. */
|
|
20
|
-
title?: string;
|
|
21
|
-
/** Supporting text below the grouped rows. */
|
|
22
|
-
footer?: ReactNode;
|
|
23
|
-
/** Rows, typically LabeledContent. */
|
|
24
|
-
children?: ReactNode;
|
|
25
|
-
/** Title and footer text scale + padding. @default "md" */
|
|
26
|
-
size?: SectionSize;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* A titled, inset group of rows with an optional footer, as in iOS Settings
|
|
31
|
-
* and SwiftUI's grouped `List` with `Section(header:footer:)`. Rows are
|
|
32
|
-
* usually `LabeledContent`; dividers between them come for free.
|
|
33
|
-
*/
|
|
34
|
-
export function Section({
|
|
35
|
-
title,
|
|
36
|
-
footer,
|
|
37
|
-
children,
|
|
38
|
-
className,
|
|
39
|
-
size = "md",
|
|
40
|
-
...props
|
|
41
|
-
}: SectionProps) {
|
|
42
|
-
const headingId = useId();
|
|
43
|
-
return (
|
|
44
|
-
<section
|
|
45
|
-
aria-labelledby={title ? headingId : undefined}
|
|
46
|
-
className={cn("flex flex-col gap-2", className)}
|
|
47
|
-
{...props}
|
|
48
|
-
>
|
|
49
|
-
{title && (
|
|
50
|
-
<h2
|
|
51
|
-
id={headingId}
|
|
52
|
-
className={cn(titleSizes[size], "text-label-tertiary font-medium")}
|
|
53
|
-
>
|
|
54
|
-
{title}
|
|
55
|
-
</h2>
|
|
56
|
-
)}
|
|
57
|
-
{/* A group can be only a note, e.g. where to find something on this device. */}
|
|
58
|
-
{children ? (
|
|
59
|
-
<div className="divide-separator/60 border-separator/60 bg-elevated flex flex-col divide-y overflow-hidden rounded-3xl border">
|
|
60
|
-
{children}
|
|
61
|
-
</div>
|
|
62
|
-
) : null}
|
|
63
|
-
{footer && (
|
|
64
|
-
<div
|
|
65
|
-
className={cn(
|
|
66
|
-
footerSizes[size],
|
|
67
|
-
"text-caption text-label-tertiary leading-snug",
|
|
68
|
-
)}
|
|
69
|
-
>
|
|
70
|
-
{footer}
|
|
71
|
-
</div>
|
|
72
|
-
)}
|
|
73
|
-
</section>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TextField, type TextFieldProps } from "../text-field/text-field";
|
|
2
|
-
|
|
3
|
-
/** TextField's native input props, with the password type managed by SecureField. */
|
|
4
|
-
export type SecureFieldProps = Omit<TextFieldProps, "type">;
|
|
5
|
-
|
|
6
|
-
export function SecureField(props: SecureFieldProps) {
|
|
7
|
-
return <TextField {...props} type="password" />;
|
|
8
|
-
}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { motion, useReducedMotion } from "motion/react";
|
|
2
|
-
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
-
import { cn } from "../../lib/class-names";
|
|
4
|
-
import { haptic } from "../../lib/haptics";
|
|
5
|
-
import { spring } from "../../motion/transitions";
|
|
6
|
-
import { Picker } from "../picker/picker";
|
|
7
|
-
|
|
8
|
-
export type SegmentedControlSize = "sm" | "md" | "lg";
|
|
9
|
-
|
|
10
|
-
const segmentPaddings: Record<SegmentedControlSize, string> = {
|
|
11
|
-
sm: "p-[2px]",
|
|
12
|
-
md: "p-[3px]",
|
|
13
|
-
lg: "p-[4px]",
|
|
14
|
-
};
|
|
15
|
-
const segmentLabelClasses: Record<SegmentedControlSize, string> = {
|
|
16
|
-
sm: "min-w-[52px] px-2 py-0.5 text-caption2 whitespace-nowrap",
|
|
17
|
-
md: "min-w-[64px] px-3 py-1 text-footnote whitespace-nowrap",
|
|
18
|
-
lg: "min-w-[80px] px-4 py-1.5 text-subheadline whitespace-nowrap",
|
|
19
|
-
};
|
|
20
|
-
const segmentRadius: Record<SegmentedControlSize, string> = {
|
|
21
|
-
sm: "rounded-sm",
|
|
22
|
-
md: "rounded-md",
|
|
23
|
-
lg: "rounded-lg",
|
|
24
|
-
};
|
|
25
|
-
const fallbackPickerSizes: Record<SegmentedControlSize, string> = {
|
|
26
|
-
sm: "rounded-md py-1 text-caption2 font-semibold",
|
|
27
|
-
md: "rounded-lg py-1.5 text-footnote font-semibold",
|
|
28
|
-
lg: "rounded-lg py-2 text-subheadline font-semibold",
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export interface SegmentedControlProps<T extends string> {
|
|
32
|
-
/** Value of the selected segment. */
|
|
33
|
-
value: T;
|
|
34
|
-
/** The choices, in display order. */
|
|
35
|
-
options: ReadonlyArray<{ value: T; label: string }>;
|
|
36
|
-
/** Called with the selected segment's value. */
|
|
37
|
-
onChange: (value: NoInfer<T>) => void;
|
|
38
|
-
/** Accessible name for the group and its compact picker. */
|
|
39
|
-
label: string;
|
|
40
|
-
/** Custom classes for the control container. */
|
|
41
|
-
className?: string;
|
|
42
|
-
/** Segment padding, label text scale and min-width. @default "md" */
|
|
43
|
-
size?: SegmentedControlSize;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Mutually exclusive choices with a sliding selection, as on Apple
|
|
48
|
-
* platforms. When the labels can't all fit the space it is given (a long
|
|
49
|
-
* translation, a narrow pane) it becomes a pop-up button instead of
|
|
50
|
-
* squeezing or spilling its text.
|
|
51
|
-
*/
|
|
52
|
-
export function SegmentedControl<T extends string>({
|
|
53
|
-
value,
|
|
54
|
-
options,
|
|
55
|
-
onChange,
|
|
56
|
-
label,
|
|
57
|
-
className,
|
|
58
|
-
size = "md",
|
|
59
|
-
}: SegmentedControlProps<T>) {
|
|
60
|
-
const id = useId();
|
|
61
|
-
const reducedMotion = useReducedMotion();
|
|
62
|
-
const frame = useRef<HTMLDivElement>(null);
|
|
63
|
-
const measure = useRef<HTMLDivElement>(null);
|
|
64
|
-
const [fits, setFits] = useState(true);
|
|
65
|
-
|
|
66
|
-
useLayoutEffect(() => {
|
|
67
|
-
const box = frame.current;
|
|
68
|
-
const natural = measure.current;
|
|
69
|
-
if (!box || !natural) return;
|
|
70
|
-
const check = () => setFits(natural.offsetWidth <= box.clientWidth + 0.5);
|
|
71
|
-
check();
|
|
72
|
-
const observer = new ResizeObserver(check);
|
|
73
|
-
observer.observe(box);
|
|
74
|
-
observer.observe(natural);
|
|
75
|
-
return () => observer.disconnect();
|
|
76
|
-
}, []);
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<div ref={frame} className={cn("relative w-full min-w-0", className)}>
|
|
80
|
-
{/* The control at its natural size, to know whether it fits. */}
|
|
81
|
-
<div
|
|
82
|
-
ref={measure}
|
|
83
|
-
aria-hidden="true"
|
|
84
|
-
className={cn(
|
|
85
|
-
"pointer-events-none invisible absolute top-0 flex w-max font-semibold",
|
|
86
|
-
segmentPaddings[size],
|
|
87
|
-
segmentLabelClasses[size].replace(/min-w-\[[^\]]+\]\s*/, ""),
|
|
88
|
-
)}
|
|
89
|
-
>
|
|
90
|
-
{options.map((option) => (
|
|
91
|
-
<span key={option.value} className={segmentLabelClasses[size]}>
|
|
92
|
-
{option.label}
|
|
93
|
-
</span>
|
|
94
|
-
))}
|
|
95
|
-
</div>
|
|
96
|
-
{fits ? (
|
|
97
|
-
<fieldset
|
|
98
|
-
className={cn(
|
|
99
|
-
"bg-fill flex w-full rounded-lg shadow-[inset_0_1px_2px_rgb(40_30_0/0.06)]",
|
|
100
|
-
segmentPaddings[size],
|
|
101
|
-
)}
|
|
102
|
-
>
|
|
103
|
-
<legend className="sr-only">{label}</legend>
|
|
104
|
-
{options.map((option) => {
|
|
105
|
-
const selected = option.value === value;
|
|
106
|
-
return (
|
|
107
|
-
<label
|
|
108
|
-
key={option.value}
|
|
109
|
-
className={cn(
|
|
110
|
-
"has-[:focus-visible]:ring-accent/60 relative isolate flex-1 cursor-pointer text-center whitespace-nowrap transition-colors has-[:focus-visible]:ring-2",
|
|
111
|
-
segmentLabelClasses[size].replace("whitespace-nowrap", ""),
|
|
112
|
-
segmentRadius[size],
|
|
113
|
-
selected
|
|
114
|
-
? "text-label font-semibold"
|
|
115
|
-
: "text-label-secondary hover:text-label font-medium",
|
|
116
|
-
)}
|
|
117
|
-
>
|
|
118
|
-
<input
|
|
119
|
-
type="radio"
|
|
120
|
-
name={id}
|
|
121
|
-
value={option.value}
|
|
122
|
-
checked={selected}
|
|
123
|
-
onChange={() => {
|
|
124
|
-
haptic("selection");
|
|
125
|
-
onChange(option.value);
|
|
126
|
-
}}
|
|
127
|
-
className="sr-only"
|
|
128
|
-
/>
|
|
129
|
-
{selected && (
|
|
130
|
-
<motion.span
|
|
131
|
-
layoutId={`segment-${id}`}
|
|
132
|
-
className={cn(
|
|
133
|
-
"bg-elevated absolute inset-0 -z-10 shadow-[0_0_0_0.5px_rgb(0_0_0/0.06),0_1px_2px_rgb(0_0_0/0.08),0_3px_8px_-2px_rgb(0_0_0/0.10)]",
|
|
134
|
-
segmentRadius[size],
|
|
135
|
-
)}
|
|
136
|
-
transition={reducedMotion ? { duration: 0 } : spring.snappy}
|
|
137
|
-
/>
|
|
138
|
-
)}
|
|
139
|
-
{option.label}
|
|
140
|
-
</label>
|
|
141
|
-
);
|
|
142
|
-
})}
|
|
143
|
-
</fieldset>
|
|
144
|
-
) : (
|
|
145
|
-
<Picker<T>
|
|
146
|
-
label={label}
|
|
147
|
-
value={value}
|
|
148
|
-
options={options}
|
|
149
|
-
onChange={onChange}
|
|
150
|
-
searchable={false}
|
|
151
|
-
className={fallbackPickerSizes[size]}
|
|
152
|
-
size={size === "sm" ? "sm" : size === "lg" ? "lg" : "md"}
|
|
153
|
-
/>
|
|
154
|
-
)}
|
|
155
|
-
</div>
|
|
156
|
-
);
|
|
157
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { FLOATING_LAYER, ownsFloatingLayer } from "../../lib/floating-layers";
|
|
2
|
-
|
|
3
|
-
const surfaces: HTMLElement[] = [];
|
|
4
|
-
const isolated = new Map<HTMLElement, boolean>();
|
|
5
|
-
let overflow = "";
|
|
6
|
-
let overflowPriority = "";
|
|
7
|
-
|
|
8
|
-
function restoreBackground() {
|
|
9
|
-
for (const [element, inert] of isolated) element.inert = inert;
|
|
10
|
-
isolated.clear();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function isolateBackground() {
|
|
14
|
-
restoreBackground();
|
|
15
|
-
const surface = surfaces.at(-1);
|
|
16
|
-
if (!surface) return;
|
|
17
|
-
const roots = [surface.parentElement ?? surface];
|
|
18
|
-
for (const layer of document.querySelectorAll<HTMLElement>(
|
|
19
|
-
`[${FLOATING_LAYER}]`,
|
|
20
|
-
)) {
|
|
21
|
-
if (ownsFloatingLayer(surface, layer)) roots.push(layer);
|
|
22
|
-
}
|
|
23
|
-
const visit = (parent: HTMLElement) => {
|
|
24
|
-
for (const child of parent.children) {
|
|
25
|
-
if (!(child instanceof HTMLElement)) continue;
|
|
26
|
-
if (roots.includes(child)) continue;
|
|
27
|
-
if (roots.some((root) => child.contains(root))) {
|
|
28
|
-
visit(child);
|
|
29
|
-
} else if (!child.matches("script, style, link")) {
|
|
30
|
-
isolated.set(child, child.inert);
|
|
31
|
-
child.inert = true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
visit(document.body);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** Keeps nested sheets and their portaled controls above an inactive background. */
|
|
39
|
-
export function enterModalEnvironment(surface: HTMLElement): () => void {
|
|
40
|
-
if (!surfaces.length) {
|
|
41
|
-
overflow = document.body.style.getPropertyValue("overflow");
|
|
42
|
-
overflowPriority = document.body.style.getPropertyPriority("overflow");
|
|
43
|
-
document.body.style.setProperty("overflow", "hidden");
|
|
44
|
-
}
|
|
45
|
-
surfaces.push(surface);
|
|
46
|
-
isolateBackground();
|
|
47
|
-
const preventBackgroundScroll = (event: WheelEvent | TouchEvent) => {
|
|
48
|
-
if (surfaces.at(-1) !== surface) return;
|
|
49
|
-
const target = event.target;
|
|
50
|
-
if (
|
|
51
|
-
target instanceof Element &&
|
|
52
|
-
(surface.contains(target) || ownsFloatingLayer(surface, target))
|
|
53
|
-
)
|
|
54
|
-
return;
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
};
|
|
57
|
-
document.addEventListener("wheel", preventBackgroundScroll, {
|
|
58
|
-
passive: false,
|
|
59
|
-
});
|
|
60
|
-
document.addEventListener("touchmove", preventBackgroundScroll, {
|
|
61
|
-
passive: false,
|
|
62
|
-
});
|
|
63
|
-
const observer = new MutationObserver(() => {
|
|
64
|
-
if (surfaces.at(-1) === surface) isolateBackground();
|
|
65
|
-
});
|
|
66
|
-
observer.observe(document.body, {
|
|
67
|
-
childList: true,
|
|
68
|
-
subtree: true,
|
|
69
|
-
});
|
|
70
|
-
return () => {
|
|
71
|
-
observer.disconnect();
|
|
72
|
-
document.removeEventListener("wheel", preventBackgroundScroll);
|
|
73
|
-
document.removeEventListener("touchmove", preventBackgroundScroll);
|
|
74
|
-
surfaces.splice(surfaces.indexOf(surface), 1);
|
|
75
|
-
isolateBackground();
|
|
76
|
-
if (!surfaces.length) {
|
|
77
|
-
if (overflow)
|
|
78
|
-
document.body.style.setProperty("overflow", overflow, overflowPriority);
|
|
79
|
-
else document.body.style.removeProperty("overflow");
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|