@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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
export type CodeBlockSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface CodeBlockProps extends Omit<ComponentProps<"div">, "children" | "size" | "title"> {
|
|
4
|
+
code: string;
|
|
5
|
+
/** Supply a highlighter's rendered pre/code element; source remains the fallback. */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/** Show a nonselectable line gutter. @default true */
|
|
8
|
+
lineNumbers?: boolean;
|
|
9
|
+
/** Code font size, padding and line gutter scale. @default "md" */
|
|
10
|
+
size?: CodeBlockSize;
|
|
11
|
+
/** A caption over the code, such as a file name. */
|
|
12
|
+
title?: string;
|
|
13
|
+
/** Replaces the caption with your own content, such as a tab strip that fills the row's height. */
|
|
14
|
+
header?: ReactNode;
|
|
15
|
+
/** The language's name, shown beside the caption. */
|
|
16
|
+
language?: string;
|
|
17
|
+
/** Show a copy button that writes `code`. @default false */
|
|
18
|
+
copyable?: boolean;
|
|
19
|
+
/** 1 based lines to mark with a soft accent band, for the lines a paragraph is about. */
|
|
20
|
+
highlightLines?: number[];
|
|
21
|
+
/** Wrap long lines instead of scrolling sideways. @default false */
|
|
22
|
+
wrap?: boolean;
|
|
23
|
+
/** Names for the copy button and the fold button, so apps can translate them. */
|
|
24
|
+
labels?: {
|
|
25
|
+
copy: string;
|
|
26
|
+
copied: string;
|
|
27
|
+
expand: string;
|
|
28
|
+
collapse: string;
|
|
29
|
+
};
|
|
30
|
+
/** Start folded, with an Expand code button, when the code has more lines than this. */
|
|
31
|
+
foldAfter?: number;
|
|
32
|
+
}
|
|
33
|
+
/** Code presentation without shipping a highlighter or formatter to consumers. */
|
|
34
|
+
export declare function CodeBlock({ code, children, lineNumbers, size, title, header, language, copyable, foldAfter, highlightLines, wrap, labels, className, ...props }: CodeBlockProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { copyText } from "./clipboard.js";
|
|
3
|
+
import { cx } from "./lib/cx.js";
|
|
4
|
+
import { haptic } from "./lib/haptics.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { Fragment, useEffect, useId, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { CheckIcon } from "@passui/icons/check";
|
|
9
|
+
import { CopyIcon } from "@passui/icons/copy";
|
|
10
|
+
// src/components/code-block.tsx
|
|
11
|
+
/** Code presentation without shipping a highlighter or formatter to consumers. */
|
|
12
|
+
function CodeBlock({ code, children, lineNumbers = true, size = "md", title, header, language, copyable = false, foldAfter, highlightLines, wrap = false, labels = {
|
|
13
|
+
copy: "Copy code",
|
|
14
|
+
copied: "Copied",
|
|
15
|
+
expand: "Expand code",
|
|
16
|
+
collapse: "Collapse code"
|
|
17
|
+
}, className, ...props }) {
|
|
18
|
+
const scope = useId();
|
|
19
|
+
const lines = code.split("\n");
|
|
20
|
+
const foldable = foldAfter !== void 0 && lines.length > foldAfter;
|
|
21
|
+
const [expanded, setExpanded] = useState(false);
|
|
22
|
+
const [copied, setCopied] = useState(false);
|
|
23
|
+
const folded = foldable && !expanded;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!copied) return;
|
|
26
|
+
const timer = window.setTimeout(() => setCopied(false), 1600);
|
|
27
|
+
return () => window.clearTimeout(timer);
|
|
28
|
+
}, [copied]);
|
|
29
|
+
async function copy() {
|
|
30
|
+
if (await copyText(code)) {
|
|
31
|
+
haptic("success");
|
|
32
|
+
setCopied(true);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
36
|
+
...props,
|
|
37
|
+
className: cx("passui-code-block relative", className),
|
|
38
|
+
"data-slot": "code-block",
|
|
39
|
+
"data-line-numbers": lineNumbers || void 0,
|
|
40
|
+
"data-size": size,
|
|
41
|
+
"data-wrap": wrap || void 0,
|
|
42
|
+
"data-code-block": scope,
|
|
43
|
+
children: [
|
|
44
|
+
highlightLines?.length ? /* @__PURE__ */ jsx("style", { children: highlightLines.map((line) => `[data-code-block="${scope}"] code > .line:nth-child(${line}){background:color-mix(in srgb,var(--color-accent) 14%,transparent);box-shadow:inset 2px 0 0 var(--color-accent)}`).join("") }) : null,
|
|
45
|
+
title || header || language || copyable ? /* @__PURE__ */ jsxs("div", {
|
|
46
|
+
className: cx("border-separator/60 flex min-h-9 items-center justify-between gap-3 border-b px-4", !header && "py-2"),
|
|
47
|
+
children: [header ?? /* @__PURE__ */ jsx("span", {
|
|
48
|
+
className: "text-caption text-label-tertiary min-w-0 truncate font-mono",
|
|
49
|
+
children: title
|
|
50
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
51
|
+
className: "flex shrink-0 items-center gap-1.5",
|
|
52
|
+
children: [language ? /* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: "bg-fill/70 text-caption2 text-label-secondary rounded-full px-2 py-1 font-medium",
|
|
54
|
+
children: language
|
|
55
|
+
}) : null, copyable ? /* @__PURE__ */ jsx(Button, {
|
|
56
|
+
variant: "ghost",
|
|
57
|
+
size: "icon-xs",
|
|
58
|
+
"aria-label": copied ? labels.copied : labels.copy,
|
|
59
|
+
onClick: copy,
|
|
60
|
+
children: copied ? /* @__PURE__ */ jsx(CheckIcon, { size: 16 }) : /* @__PURE__ */ jsx(CopyIcon, { size: 16 })
|
|
61
|
+
}) : null]
|
|
62
|
+
})]
|
|
63
|
+
}) : null,
|
|
64
|
+
/* @__PURE__ */ jsxs("div", {
|
|
65
|
+
className: cx("relative", folded && "max-h-36 overflow-hidden"),
|
|
66
|
+
children: [children ?? /* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: lines.map((line, index) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
67
|
+
className: "line",
|
|
68
|
+
children: line || " "
|
|
69
|
+
}), index < lines.length - 1 ? "\n" : null] }, line || index)) }) }), folded ? /* @__PURE__ */ jsx("div", { className: "from-elevated pointer-events-none absolute inset-x-0 bottom-0 h-20 bg-linear-to-t to-transparent" }) : null]
|
|
70
|
+
}),
|
|
71
|
+
foldable ? /* @__PURE__ */ jsx("div", {
|
|
72
|
+
className: cx("flex justify-center", folded ? "absolute inset-x-0 bottom-3" : "pb-4"),
|
|
73
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
74
|
+
size: "sm",
|
|
75
|
+
variant: "secondary",
|
|
76
|
+
"aria-expanded": expanded,
|
|
77
|
+
onClick: () => {
|
|
78
|
+
haptic("selection");
|
|
79
|
+
setExpanded((value) => !value);
|
|
80
|
+
},
|
|
81
|
+
children: expanded ? labels.collapse : labels.expand
|
|
82
|
+
})
|
|
83
|
+
}) : null
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export { CodeBlock };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RenderProp } from "./lib/render.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
import * as zagCollapsible from "@zag-js/collapsible";
|
|
4
|
+
export interface CollapsibleProps extends Omit<zagCollapsible.Props, "id" | "ids" | "onOpenChange"> {
|
|
5
|
+
onOpenChange?: (open: boolean) => void;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function Collapsible({ onOpenChange, children, className, ...props }: CollapsibleProps): import("react").JSX.Element;
|
|
10
|
+
export declare function CollapsibleTrigger({ render, ...props }: ComponentProps<"button"> & {
|
|
11
|
+
render?: RenderProp;
|
|
12
|
+
}): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
13
|
+
export declare function CollapsibleContent({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "./lib/cx.js";
|
|
3
|
+
import { mergeProps, renderPart } from "./lib/render.js";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { createContext, useContext, useId } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import * as zagCollapsible from "@zag-js/collapsible";
|
|
8
|
+
// src/components/collapsible.tsx
|
|
9
|
+
const Context = createContext(null);
|
|
10
|
+
function useCollapsible() {
|
|
11
|
+
const api = useContext(Context);
|
|
12
|
+
if (!api) throw new Error("Collapsible parts must be used inside <Collapsible>.");
|
|
13
|
+
return api;
|
|
14
|
+
}
|
|
15
|
+
function Collapsible({ onOpenChange, children, className, ...props }) {
|
|
16
|
+
const id = useId();
|
|
17
|
+
const service = useMachine(zagCollapsible.machine, {
|
|
18
|
+
id,
|
|
19
|
+
onOpenChange: ({ open }) => onOpenChange?.(open),
|
|
20
|
+
...props
|
|
21
|
+
});
|
|
22
|
+
const api = zagCollapsible.connect(service, normalizeProps);
|
|
23
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
24
|
+
value: api,
|
|
25
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
26
|
+
...api.getRootProps(),
|
|
27
|
+
"data-slot": "collapsible",
|
|
28
|
+
className,
|
|
29
|
+
children
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function CollapsibleTrigger({ render, ...props }) {
|
|
34
|
+
const api = useCollapsible();
|
|
35
|
+
return renderPart("button", mergeProps({
|
|
36
|
+
...api.getTriggerProps(),
|
|
37
|
+
"data-slot": "collapsible-trigger"
|
|
38
|
+
}, props), render);
|
|
39
|
+
}
|
|
40
|
+
function CollapsibleContent({ className, ...props }) {
|
|
41
|
+
const api = useCollapsible();
|
|
42
|
+
return /* @__PURE__ */ jsx("div", {
|
|
43
|
+
...api.getContentProps(),
|
|
44
|
+
"data-slot": "collapsible-content",
|
|
45
|
+
className: cx("collapse-motion", className),
|
|
46
|
+
...props
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { Collapsible, CollapsibleContent, CollapsibleTrigger };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import * as zagCombobox from "@zag-js/combobox";
|
|
3
|
+
export interface ComboboxItem {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ComboboxProps extends Omit<zagCombobox.Props<ComboboxItem>, "id" | "ids" | "collection" | "value" | "defaultValue" | "onValueChange" | "inputValue" | "defaultInputValue" | "onInputValueChange" | "placeholder"> {
|
|
9
|
+
items: ComboboxItem[];
|
|
10
|
+
value?: string | null;
|
|
11
|
+
defaultValue?: string | null;
|
|
12
|
+
onValueChange?: (value: string | null) => void;
|
|
13
|
+
placeholder?: string;
|
|
14
|
+
/** Shown when the query matches nothing. */
|
|
15
|
+
empty?: ReactNode;
|
|
16
|
+
/** The accessible name of the chevron button, so apps can translate it. @default "Show options" */
|
|
17
|
+
triggerLabel?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
invalid?: boolean;
|
|
20
|
+
name?: string;
|
|
21
|
+
"aria-label"?: string;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
/** A searchable single choice. Typing filters the list; arrow keys and Enter pick. */
|
|
25
|
+
export declare function Combobox({ items, value, defaultValue, onValueChange, placeholder, empty, triggerLabel, disabled, invalid, name, "aria-label": ariaLabel, className, ...props }: ComboboxProps): import("react").JSX.Element;
|
package/dist/combobox.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "./lib/cx.js";
|
|
3
|
+
import { Portal } from "./lib/portal.js";
|
|
4
|
+
import { usePresence } from "./lib/presence.js";
|
|
5
|
+
import { useWaterDrop } from "./lib/water-drop.js";
|
|
6
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
7
|
+
import { useId, useMemo, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import * as zagCombobox from "@zag-js/combobox";
|
|
10
|
+
// src/components/combobox.tsx
|
|
11
|
+
/** A searchable single choice. Typing filters the list; arrow keys and Enter pick. */
|
|
12
|
+
function Combobox({ items, value, defaultValue, onValueChange, placeholder = "Search", empty = "No results.", triggerLabel = "Show options", disabled, invalid, name, "aria-label": ariaLabel, className, ...props }) {
|
|
13
|
+
const id = useId();
|
|
14
|
+
const [query, setQuery] = useState("");
|
|
15
|
+
const filtered = useMemo(() => items.filter((i) => i.label.toLowerCase().includes(query.trim().toLowerCase())), [items, query]);
|
|
16
|
+
const collection = useMemo(() => zagCombobox.collection({
|
|
17
|
+
items: filtered,
|
|
18
|
+
itemToValue: (i) => i.value,
|
|
19
|
+
itemToString: (i) => i.label,
|
|
20
|
+
isItemDisabled: (i) => !!i.disabled
|
|
21
|
+
}), [filtered]);
|
|
22
|
+
const one = (v) => v === void 0 ? void 0 : v ? [v] : [];
|
|
23
|
+
const service = useMachine(zagCombobox.machine, {
|
|
24
|
+
id,
|
|
25
|
+
collection,
|
|
26
|
+
name,
|
|
27
|
+
disabled,
|
|
28
|
+
invalid,
|
|
29
|
+
value: one(value),
|
|
30
|
+
defaultValue: one(defaultValue),
|
|
31
|
+
openOnClick: true,
|
|
32
|
+
inputBehavior: "autohighlight",
|
|
33
|
+
onInputValueChange: ({ inputValue }) => setQuery(inputValue),
|
|
34
|
+
onValueChange: ({ value: next }) => {
|
|
35
|
+
onValueChange?.(next[0] ?? null);
|
|
36
|
+
setQuery("");
|
|
37
|
+
},
|
|
38
|
+
positioning: {
|
|
39
|
+
sameWidth: true,
|
|
40
|
+
fitViewport: true,
|
|
41
|
+
placement: "bottom-start",
|
|
42
|
+
offset: { mainAxis: 6 }
|
|
43
|
+
},
|
|
44
|
+
...props
|
|
45
|
+
});
|
|
46
|
+
const api = zagCombobox.connect(service, normalizeProps);
|
|
47
|
+
const drop = useWaterDrop({
|
|
48
|
+
sourceId: api.getControlProps().id,
|
|
49
|
+
keepSource: true,
|
|
50
|
+
material: "liquid-glass-dense squircle [--squircle-radius:1.25rem]"
|
|
51
|
+
});
|
|
52
|
+
const { ref, mounted, attrs } = usePresence(api.open, drop);
|
|
53
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
54
|
+
...api.getRootProps(),
|
|
55
|
+
"data-slot": "combobox",
|
|
56
|
+
className: cx("w-full", className),
|
|
57
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
58
|
+
...api.getControlProps(),
|
|
59
|
+
className: "relative",
|
|
60
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
61
|
+
...api.getInputProps(),
|
|
62
|
+
"aria-label": ariaLabel,
|
|
63
|
+
placeholder,
|
|
64
|
+
"data-slot": "combobox-input",
|
|
65
|
+
className: "bg-fill/60 text-footnote text-label placeholder:text-label-tertiary focus-visible:ring-accent/70 aria-invalid:ring-danger/70 h-8.5 w-full rounded-xl pr-9 pl-3 transition duration-(--duration-fast) outline-none focus-visible:ring-2 disabled:opacity-40 aria-invalid:ring-2 motion-reduce:transition-none"
|
|
66
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
67
|
+
...api.getTriggerProps(),
|
|
68
|
+
className: "group text-label-secondary focus-visible:ring-accent/70 absolute inset-y-0 right-1 flex w-9 items-center justify-center rounded-xl outline-none focus-visible:ring-2 disabled:opacity-40",
|
|
69
|
+
"aria-label": triggerLabel,
|
|
70
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
71
|
+
viewBox: "0 0 16 16",
|
|
72
|
+
className: "size-4 transition-transform duration-(--duration-fast) group-data-[state=open]:rotate-180 motion-reduce:transition-none",
|
|
73
|
+
fill: "none",
|
|
74
|
+
stroke: "currentColor",
|
|
75
|
+
strokeWidth: "2",
|
|
76
|
+
strokeLinecap: "round",
|
|
77
|
+
strokeLinejoin: "round",
|
|
78
|
+
"aria-hidden": "true",
|
|
79
|
+
children: /* @__PURE__ */ jsx("path", { d: "m4 6 4 4 4-4" })
|
|
80
|
+
})
|
|
81
|
+
})]
|
|
82
|
+
}), mounted ? /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx("div", {
|
|
83
|
+
...api.getPositionerProps(),
|
|
84
|
+
className: "z-[70]",
|
|
85
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
86
|
+
...api.getContentProps(),
|
|
87
|
+
...attrs,
|
|
88
|
+
ref,
|
|
89
|
+
hidden: false,
|
|
90
|
+
"data-slot": "combobox-content",
|
|
91
|
+
className: "liquid-glass-dense squircle morph-reset spring-smooth max-h-[min(18rem,var(--available-height,18rem))] w-max max-w-(--available-width,100vw) min-w-(--reference-width) origin-(--transform-origin,center) overflow-y-auto p-1.5 transition outline-none [--squircle-radius:1.25rem] data-ending-style:scale-[0.88] data-ending-style:opacity-0 data-starting-style:scale-[0.88] data-starting-style:opacity-0 data-[side=bottom]:origin-top data-[side=top]:origin-bottom motion-reduce:transition-none motion-reduce:data-ending-style:scale-100 motion-reduce:data-starting-style:scale-100",
|
|
92
|
+
children: filtered.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
93
|
+
className: "text-footnote text-label-secondary px-3 py-2",
|
|
94
|
+
children: empty
|
|
95
|
+
}) : filtered.map((item) => /* @__PURE__ */ jsxs("div", {
|
|
96
|
+
...api.getItemProps({ item }),
|
|
97
|
+
"data-slot": "combobox-item",
|
|
98
|
+
className: "text-footnote text-label data-highlighted:bg-accent/15 flex cursor-pointer items-center justify-between gap-3 rounded-xl px-3 py-2 data-disabled:opacity-40",
|
|
99
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
100
|
+
...api.getItemTextProps({ item }),
|
|
101
|
+
children: item.label
|
|
102
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
103
|
+
...api.getItemIndicatorProps({ item }),
|
|
104
|
+
className: "text-accent-text",
|
|
105
|
+
children: "✓"
|
|
106
|
+
})]
|
|
107
|
+
}, item.value))
|
|
108
|
+
})
|
|
109
|
+
}) }) : null]
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
export { Combobox };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A filterable list of actions. Arrow keys move, Enter runs, and typing filters.
|
|
4
|
+
* Compose it inside a Dialog for a command palette.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Command({ className, children, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
7
|
+
export declare function CommandInput({ className, ...props }: Omit<ComponentProps<"input">, "value" | "onChange">): import("react").JSX.Element;
|
|
8
|
+
export declare function CommandList({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
9
|
+
export declare function CommandEmpty({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element | null;
|
|
10
|
+
export declare function CommandGroup({ heading, className, children, ...props }: Omit<ComponentProps<"div">, "children"> & {
|
|
11
|
+
heading?: ReactNode;
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export type CommandItemProps = Omit<ComponentProps<"div">, "onSelect"> & {
|
|
15
|
+
value: string;
|
|
16
|
+
/** Extra words that match the query. */
|
|
17
|
+
keywords?: string;
|
|
18
|
+
onSelect?: (value: string) => void;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare function CommandItem({ value, keywords, onSelect, disabled, className, ...props }: CommandItemProps): import("react").JSX.Element | null;
|
|
22
|
+
export declare function CommandShortcut({ className, ...props }: ComponentProps<"span">): import("react").JSX.Element;
|
package/dist/command.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "./lib/cx.js";
|
|
3
|
+
import { createContext, useContext, useId, useMemo, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/components/command.tsx
|
|
6
|
+
const Context = createContext(null);
|
|
7
|
+
function useCommand() {
|
|
8
|
+
const ctx = useContext(Context);
|
|
9
|
+
if (!ctx) throw new Error("Command parts must be used inside <Command>.");
|
|
10
|
+
return ctx;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A filterable list of actions. Arrow keys move, Enter runs, and typing filters.
|
|
14
|
+
* Compose it inside a Dialog for a command palette.
|
|
15
|
+
*/
|
|
16
|
+
function Command({ className, children, ...props }) {
|
|
17
|
+
const listId = useId();
|
|
18
|
+
const [query, setQuery] = useState("");
|
|
19
|
+
const [active, setActive] = useState(null);
|
|
20
|
+
const [registry] = useState(() => /* @__PURE__ */ new Map());
|
|
21
|
+
const state = useMemo(() => {
|
|
22
|
+
const q = query.trim().toLowerCase();
|
|
23
|
+
const visible = [...registry].filter(([value, kw]) => !q || `${value} ${kw}`.toLowerCase().includes(q)).map(([value]) => value);
|
|
24
|
+
return {
|
|
25
|
+
query,
|
|
26
|
+
setQuery,
|
|
27
|
+
active,
|
|
28
|
+
setActive,
|
|
29
|
+
listId,
|
|
30
|
+
register: (value, keywords) => void registry.set(value, keywords),
|
|
31
|
+
visible
|
|
32
|
+
};
|
|
33
|
+
}, [
|
|
34
|
+
query,
|
|
35
|
+
active,
|
|
36
|
+
listId,
|
|
37
|
+
registry
|
|
38
|
+
]);
|
|
39
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
40
|
+
value: state,
|
|
41
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
42
|
+
"data-slot": "command",
|
|
43
|
+
className: cx("flex w-full flex-col overflow-hidden liquid-glass-dense squircle [--squircle-radius:1.5rem] text-label", className),
|
|
44
|
+
...props,
|
|
45
|
+
children
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function CommandInput({ className, ...props }) {
|
|
50
|
+
const c = useCommand();
|
|
51
|
+
return /* @__PURE__ */ jsx("input", {
|
|
52
|
+
role: "combobox",
|
|
53
|
+
"aria-expanded": true,
|
|
54
|
+
"aria-controls": c.listId,
|
|
55
|
+
"aria-activedescendant": c.active ? `${c.listId}-${c.active}` : void 0,
|
|
56
|
+
"data-slot": "command-input",
|
|
57
|
+
value: c.query,
|
|
58
|
+
onChange: (e) => {
|
|
59
|
+
c.setQuery(e.target.value);
|
|
60
|
+
c.setActive(null);
|
|
61
|
+
},
|
|
62
|
+
onKeyDown: (e) => {
|
|
63
|
+
const list = c.visible;
|
|
64
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
65
|
+
e.preventDefault();
|
|
66
|
+
const i = c.active ? list.indexOf(c.active) : -1;
|
|
67
|
+
const n = e.key === "ArrowDown" ? i + 1 : i - 1;
|
|
68
|
+
c.setActive(list[(n + list.length) % list.length] ?? null);
|
|
69
|
+
} else if (e.key === "Enter") document.getElementById(`${c.listId}-${c.active ?? list[0]}`)?.click();
|
|
70
|
+
},
|
|
71
|
+
className: cx("h-10 w-full border-b border-separator bg-transparent px-3 text-footnote outline-none placeholder:text-label-tertiary", className),
|
|
72
|
+
...props
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function CommandList({ className, ...props }) {
|
|
76
|
+
const c = useCommand();
|
|
77
|
+
return /* @__PURE__ */ jsx("div", {
|
|
78
|
+
role: "listbox",
|
|
79
|
+
id: c.listId,
|
|
80
|
+
"data-slot": "command-list",
|
|
81
|
+
className: cx("max-h-80 overflow-y-auto p-1.5", className),
|
|
82
|
+
...props
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function CommandEmpty({ className, ...props }) {
|
|
86
|
+
if (useCommand().visible.length > 0) return null;
|
|
87
|
+
return /* @__PURE__ */ jsx("div", {
|
|
88
|
+
"data-slot": "command-empty",
|
|
89
|
+
className: cx("px-3 py-6 text-center text-footnote text-label-secondary", className),
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function CommandGroup({ heading, className, children, ...props }) {
|
|
94
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
95
|
+
role: "group",
|
|
96
|
+
"data-slot": "command-group",
|
|
97
|
+
className: cx("py-1", className),
|
|
98
|
+
...props,
|
|
99
|
+
children: [heading ? /* @__PURE__ */ jsx("div", {
|
|
100
|
+
className: "text-caption text-label-secondary px-3 py-1 font-semibold",
|
|
101
|
+
children: heading
|
|
102
|
+
}) : null, children]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function CommandItem({ value, keywords = "", onSelect, disabled, className, ...props }) {
|
|
106
|
+
const c = useCommand();
|
|
107
|
+
c.register(value, keywords);
|
|
108
|
+
if (!c.visible.includes(value)) return null;
|
|
109
|
+
return /* @__PURE__ */ jsx("div", {
|
|
110
|
+
role: "option",
|
|
111
|
+
id: `${c.listId}-${value}`,
|
|
112
|
+
"aria-selected": c.active === value,
|
|
113
|
+
"aria-disabled": disabled,
|
|
114
|
+
"data-slot": "command-item",
|
|
115
|
+
"data-active": c.active === value ? "" : void 0,
|
|
116
|
+
onPointerMove: () => c.setActive(value),
|
|
117
|
+
onClick: () => !disabled && onSelect?.(value),
|
|
118
|
+
className: cx("flex cursor-pointer items-center gap-2 rounded-xl px-3 py-2 text-footnote aria-disabled:opacity-40 data-active:bg-accent/15", className),
|
|
119
|
+
...props
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function CommandShortcut({ className, ...props }) {
|
|
123
|
+
return /* @__PURE__ */ jsx("span", {
|
|
124
|
+
"data-slot": "command-shortcut",
|
|
125
|
+
className: cx("ml-auto text-caption text-label-tertiary", className),
|
|
126
|
+
...props
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-wide toasts: short messages that confirm, report progress or explain
|
|
3
|
+
* a failure. Call `toast` from anywhere; render one `<Toaster />`.
|
|
4
|
+
*/
|
|
5
|
+
export type ToastTone = "neutral" | "success" | "error" | "loading";
|
|
6
|
+
export type ToastSize = "sm" | "md" | "lg";
|
|
7
|
+
export interface ToastAction {
|
|
8
|
+
label: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface Toast {
|
|
12
|
+
id: number;
|
|
13
|
+
tone: ToastTone;
|
|
14
|
+
title: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
action?: ToastAction;
|
|
17
|
+
/** Milliseconds before it leaves on its own; `null` stays until dismissed. */
|
|
18
|
+
duration: number | null;
|
|
19
|
+
createdAt: number;
|
|
20
|
+
/** Pill size, content padding and title/description text scale. @default "md" */
|
|
21
|
+
size: ToastSize;
|
|
22
|
+
}
|
|
23
|
+
export interface ToastOptions {
|
|
24
|
+
description?: string;
|
|
25
|
+
action?: ToastAction;
|
|
26
|
+
duration?: number | null;
|
|
27
|
+
/** Pill size, content padding and title/description text scale. @default "md" */
|
|
28
|
+
size?: ToastSize;
|
|
29
|
+
}
|
|
30
|
+
/** Changes a toast in place; it morphs to its new state. */
|
|
31
|
+
declare function update(id: number, tone: ToastTone, title: string, options?: ToastOptions): number;
|
|
32
|
+
declare function dismiss(id: number): void;
|
|
33
|
+
/** A toast written as one object: `toast.success({ title: "Saved" })`. */
|
|
34
|
+
export interface ToastInput extends ToastOptions {
|
|
35
|
+
title: string;
|
|
36
|
+
}
|
|
37
|
+
/** A promise outcome: a plain title, or a title with its own description. */
|
|
38
|
+
type Message = string | {
|
|
39
|
+
title: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
};
|
|
42
|
+
interface PromiseMessages<T> {
|
|
43
|
+
loading: Message;
|
|
44
|
+
success: Message | ((value: T) => Message);
|
|
45
|
+
error: Message | ((error: unknown) => Message);
|
|
46
|
+
}
|
|
47
|
+
export declare const toast: ((input: string | ToastInput, options?: ToastOptions) => number) & {
|
|
48
|
+
success: (input: string | ToastInput, options?: ToastOptions) => number;
|
|
49
|
+
error: (input: string | ToastInput, options?: ToastOptions) => number;
|
|
50
|
+
loading: (input: string | ToastInput, options?: ToastOptions) => number;
|
|
51
|
+
/** Same quiet look as a plain toast; kept so `toast.info(...)` reads naturally. */
|
|
52
|
+
info: (input: string | ToastInput, options?: ToastOptions) => number;
|
|
53
|
+
/** Same quiet look as a plain toast; there is no separate warning tone. */
|
|
54
|
+
warning: (input: string | ToastInput, options?: ToastOptions) => number;
|
|
55
|
+
update: typeof update;
|
|
56
|
+
dismiss: typeof dismiss;
|
|
57
|
+
/** Shows progress, then morphs into the outcome. Returns the promise. */
|
|
58
|
+
promise<T>(promise: Promise<T>, messages: PromiseMessages<T>): Promise<T>;
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/components/toast/toast-store.ts
|
|
2
|
+
const DEFAULT_DURATION = 4200;
|
|
3
|
+
const MAX_VISIBLE = 3;
|
|
4
|
+
let toasts = [];
|
|
5
|
+
let nextId = 1;
|
|
6
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
7
|
+
const emit = () => {
|
|
8
|
+
for (const listener of listeners) listener();
|
|
9
|
+
};
|
|
10
|
+
function show(tone, title, options = {}) {
|
|
11
|
+
const id = nextId++;
|
|
12
|
+
const duration = options.duration !== void 0 ? options.duration : tone === "loading" ? null : DEFAULT_DURATION;
|
|
13
|
+
toasts = [{
|
|
14
|
+
id,
|
|
15
|
+
tone,
|
|
16
|
+
title,
|
|
17
|
+
description: options.description,
|
|
18
|
+
action: options.action,
|
|
19
|
+
duration,
|
|
20
|
+
createdAt: Date.now(),
|
|
21
|
+
size: options.size ?? "md"
|
|
22
|
+
}, ...toasts].slice(0, 5);
|
|
23
|
+
emit();
|
|
24
|
+
return id;
|
|
25
|
+
}
|
|
26
|
+
/** Changes a toast in place; it morphs to its new state. */
|
|
27
|
+
function update(id, tone, title, options = {}) {
|
|
28
|
+
if (!toasts.some((t) => t.id === id)) return show(tone, title, options);
|
|
29
|
+
toasts = toasts.map((t) => t.id === id ? {
|
|
30
|
+
...t,
|
|
31
|
+
tone,
|
|
32
|
+
title,
|
|
33
|
+
description: options.description,
|
|
34
|
+
action: options.action,
|
|
35
|
+
duration: options.duration !== void 0 ? options.duration : tone === "loading" ? null : DEFAULT_DURATION,
|
|
36
|
+
createdAt: Date.now(),
|
|
37
|
+
size: options.size ?? t.size
|
|
38
|
+
} : t);
|
|
39
|
+
emit();
|
|
40
|
+
return id;
|
|
41
|
+
}
|
|
42
|
+
function dismiss(id) {
|
|
43
|
+
toasts = toasts.filter((t) => t.id !== id);
|
|
44
|
+
emit();
|
|
45
|
+
}
|
|
46
|
+
/** Both call shapes reach `show` the same way: a title and its options. */
|
|
47
|
+
function resolve(input, options = {}) {
|
|
48
|
+
if (typeof input === "string") return [input, options];
|
|
49
|
+
const { title, ...rest } = input;
|
|
50
|
+
return [title, {
|
|
51
|
+
...rest,
|
|
52
|
+
...options
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
55
|
+
const open = (tone) => (input, options) => {
|
|
56
|
+
const [title, resolved] = resolve(input, options);
|
|
57
|
+
return show(tone, title, resolved);
|
|
58
|
+
};
|
|
59
|
+
const words = (message) => typeof message === "string" ? [message, {}] : [message.title, { description: message.description }];
|
|
60
|
+
const toast = Object.assign(open("neutral"), {
|
|
61
|
+
success: open("success"),
|
|
62
|
+
error: open("error"),
|
|
63
|
+
loading: open("loading"),
|
|
64
|
+
/** Same quiet look as a plain toast; kept so `toast.info(...)` reads naturally. */
|
|
65
|
+
info: open("neutral"),
|
|
66
|
+
/** Same quiet look as a plain toast; there is no separate warning tone. */
|
|
67
|
+
warning: open("neutral"),
|
|
68
|
+
update,
|
|
69
|
+
dismiss,
|
|
70
|
+
/** Shows progress, then morphs into the outcome. Returns the promise. */
|
|
71
|
+
promise(promise, messages) {
|
|
72
|
+
const [loading, loadingOptions] = words(messages.loading);
|
|
73
|
+
const id = show("loading", loading, loadingOptions);
|
|
74
|
+
promise.then((value) => {
|
|
75
|
+
const message = typeof messages.success === "function" ? messages.success(value) : messages.success;
|
|
76
|
+
const [title, options] = words(message);
|
|
77
|
+
update(id, "success", title, options);
|
|
78
|
+
}, (error) => {
|
|
79
|
+
const message = typeof messages.error === "function" ? messages.error(error) : messages.error;
|
|
80
|
+
const [title, options] = words(message);
|
|
81
|
+
update(id, "error", title, options);
|
|
82
|
+
});
|
|
83
|
+
return promise;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
function subscribeToasts(listener) {
|
|
87
|
+
listeners.add(listener);
|
|
88
|
+
return () => {
|
|
89
|
+
listeners.delete(listener);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function getToasts() {
|
|
93
|
+
return toasts;
|
|
94
|
+
}
|
|
95
|
+
const toastLimits = { visible: MAX_VISIBLE };
|
|
96
|
+
export { getToasts, subscribeToasts, toast, toastLimits };
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* filter, so where they meet looks liquid while they grow, morph between
|
|
5
5
|
* states and shrink away. Text is drawn above the filter to stay crisp.
|
|
6
6
|
*/
|
|
7
|
-
export declare function Toaster({ className, label
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}): import("react").JSX.Element;
|
|
7
|
+
export declare function Toaster({ className, label }: {
|
|
8
|
+
className?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
}): import("react").JSX.Element;
|