@passui/react 0.1.46 → 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 -32
- package/dist/types/src/components/popover/popover-fit.d.ts +0 -21
- 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 -311
- 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 -334
- package/src/components/popover/popover-fit.ts +0 -74
- 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,151 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
2
|
-
import type * as React from "react";
|
|
3
|
-
|
|
4
|
-
import { cn } from "../../lib/class-names";
|
|
5
|
-
|
|
6
|
-
export type TableSize = "sm" | "md" | "lg";
|
|
7
|
-
|
|
8
|
-
const tableText: Record<TableSize, string> = {
|
|
9
|
-
sm: "text-footnote text-label",
|
|
10
|
-
md: "text-subheadline text-label",
|
|
11
|
-
lg: "text-body text-label",
|
|
12
|
-
};
|
|
13
|
-
const headCell: Record<TableSize, string> = {
|
|
14
|
-
sm: "h-8 px-2 text-start align-middle text-caption2 font-semibold whitespace-nowrap",
|
|
15
|
-
md: "h-10 px-3 text-start align-middle text-footnote font-semibold whitespace-nowrap",
|
|
16
|
-
lg: "h-12 px-4 text-start align-middle text-subheadline font-semibold whitespace-nowrap",
|
|
17
|
-
};
|
|
18
|
-
const bodyCell: Record<TableSize, string> = {
|
|
19
|
-
sm: "px-2 py-1.5 align-middle whitespace-nowrap",
|
|
20
|
-
md: "px-3 py-2.5 align-middle whitespace-nowrap",
|
|
21
|
-
lg: "px-4 py-3.5 align-middle whitespace-nowrap",
|
|
22
|
-
};
|
|
23
|
-
const captionText: Record<TableSize, string> = {
|
|
24
|
-
sm: "mt-3 text-caption2 text-label-secondary",
|
|
25
|
-
md: "mt-4 text-footnote text-label-secondary",
|
|
26
|
-
lg: "mt-5 text-subheadline text-label-secondary",
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const TableSizeContext = createContext<TableSize>("md");
|
|
30
|
-
const useTableSize = () => useContext(TableSizeContext);
|
|
31
|
-
|
|
32
|
-
function Table({
|
|
33
|
-
className,
|
|
34
|
-
size = "md",
|
|
35
|
-
...props
|
|
36
|
-
}: React.ComponentProps<"table"> & {
|
|
37
|
-
/** Row height, cell padding and text scale. @default "md" */ size?: TableSize;
|
|
38
|
-
}) {
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
data-slot="table-container"
|
|
42
|
-
className="relative w-full overflow-x-auto"
|
|
43
|
-
>
|
|
44
|
-
<TableSizeContext value={size}>
|
|
45
|
-
<table
|
|
46
|
-
data-slot="table"
|
|
47
|
-
className={cn(tableText[size], className)}
|
|
48
|
-
{...props}
|
|
49
|
-
/>
|
|
50
|
-
</TableSizeContext>
|
|
51
|
-
</div>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
|
|
56
|
-
return (
|
|
57
|
-
<thead
|
|
58
|
-
data-slot="table-header"
|
|
59
|
-
className={cn("[&_tr]:border-separator [&_tr]:border-b", className)}
|
|
60
|
-
{...props}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
|
|
66
|
-
return (
|
|
67
|
-
<tbody
|
|
68
|
-
data-slot="table-body"
|
|
69
|
-
className={cn("[&_tr:last-child]:border-0", className)}
|
|
70
|
-
{...props}
|
|
71
|
-
/>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
|
|
76
|
-
return (
|
|
77
|
-
<tfoot
|
|
78
|
-
data-slot="table-footer"
|
|
79
|
-
className={cn(
|
|
80
|
-
"border-separator bg-fill/50 border-t font-semibold [&>tr]:last:border-b-0",
|
|
81
|
-
className,
|
|
82
|
-
)}
|
|
83
|
-
{...props}
|
|
84
|
-
/>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
|
|
89
|
-
return (
|
|
90
|
-
<tr
|
|
91
|
-
data-slot="table-row"
|
|
92
|
-
className={cn(
|
|
93
|
-
"border-separator duration-fast hover:bg-fill/50 has-aria-expanded:bg-fill/50 border-b transition-colors",
|
|
94
|
-
"data-[state=selected]:bg-accent-soft/60",
|
|
95
|
-
className,
|
|
96
|
-
)}
|
|
97
|
-
{...props}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
103
|
-
const size = useTableSize();
|
|
104
|
-
return (
|
|
105
|
-
<th
|
|
106
|
-
data-slot="table-head"
|
|
107
|
-
className={cn(
|
|
108
|
-
headCell[size],
|
|
109
|
-
"text-label-secondary has-[[role=checkbox]]:pe-0",
|
|
110
|
-
className,
|
|
111
|
-
)}
|
|
112
|
-
{...props}
|
|
113
|
-
/>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
|
|
118
|
-
const size = useTableSize();
|
|
119
|
-
return (
|
|
120
|
-
<td
|
|
121
|
-
data-slot="table-cell"
|
|
122
|
-
className={cn(bodyCell[size], "has-[[role=checkbox]]:pe-0", className)}
|
|
123
|
-
{...props}
|
|
124
|
-
/>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function TableCaption({
|
|
129
|
-
className,
|
|
130
|
-
...props
|
|
131
|
-
}: React.ComponentProps<"caption">) {
|
|
132
|
-
const size = useTableSize();
|
|
133
|
-
return (
|
|
134
|
-
<caption
|
|
135
|
-
data-slot="table-caption"
|
|
136
|
-
className={cn(captionText[size], className)}
|
|
137
|
-
{...props}
|
|
138
|
-
/>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export {
|
|
143
|
-
Table,
|
|
144
|
-
TableBody,
|
|
145
|
-
TableCaption,
|
|
146
|
-
TableCell,
|
|
147
|
-
TableFooter,
|
|
148
|
-
TableHead,
|
|
149
|
-
TableHeader,
|
|
150
|
-
TableRow,
|
|
151
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ComponentProps } from "react";
|
|
2
|
-
import { cn } from "../../lib/class-names";
|
|
3
|
-
import { fieldSize, type TextFieldSize } from "../text-field/text-field";
|
|
4
|
-
|
|
5
|
-
const minHeights: Record<TextFieldSize, string> = {
|
|
6
|
-
xs: "min-h-24",
|
|
7
|
-
sm: "min-h-24",
|
|
8
|
-
md: "min-h-28",
|
|
9
|
-
lg: "min-h-32",
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type TextEditorSize = TextFieldSize;
|
|
13
|
-
|
|
14
|
-
export interface TextEditorProps
|
|
15
|
-
extends Omit<ComponentProps<"textarea">, "size"> {
|
|
16
|
-
/** Field surface scale; matches TextField's xs | sm | md | lg. @default "md" */
|
|
17
|
-
size?: TextEditorSize;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** A multi-line text field that reuses TextField's shared surface treatment. */
|
|
21
|
-
export function TextEditor({
|
|
22
|
-
className,
|
|
23
|
-
size = "md",
|
|
24
|
-
...props
|
|
25
|
-
}: TextEditorProps) {
|
|
26
|
-
const surface = fieldSize(size);
|
|
27
|
-
return (
|
|
28
|
-
<textarea
|
|
29
|
-
{...props}
|
|
30
|
-
className={cn(
|
|
31
|
-
"border-separator bg-elevated text-label placeholder:text-label-tertiary w-full min-w-0 resize-y border",
|
|
32
|
-
"focus-visible:outline-accent-text focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
33
|
-
"aria-invalid:border-danger disabled:cursor-not-allowed disabled:opacity-40",
|
|
34
|
-
surface.radius,
|
|
35
|
-
surface.padding,
|
|
36
|
-
surface.text,
|
|
37
|
-
minHeights[size],
|
|
38
|
-
className,
|
|
39
|
-
)}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { type ComponentProps, type ReactNode, useId, useState } from "react";
|
|
2
|
-
import { Button } from "../button/button";
|
|
3
|
-
import { cn } from "../../lib/class-names";
|
|
4
|
-
|
|
5
|
-
/** Shared text control classes for components that reuse TextField's surface. */
|
|
6
|
-
export const textControlClasses = cn(
|
|
7
|
-
"border-separator bg-elevated w-full min-w-0 rounded-xl border",
|
|
8
|
-
"text-body text-label placeholder:text-label-tertiary px-3 py-2",
|
|
9
|
-
"focus-visible:outline-accent-text focus-visible:outline-2 focus-visible:outline-offset-2",
|
|
10
|
-
"aria-invalid:border-danger disabled:cursor-not-allowed disabled:opacity-40",
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const fieldIconClasses = "flex shrink-0 items-center text-label-secondary";
|
|
14
|
-
|
|
15
|
-
/** Size scale shared across TextField, SecureField, and form fields. */
|
|
16
|
-
export type TextFieldSize = "xs" | "sm" | "md" | "lg";
|
|
17
|
-
|
|
18
|
-
export interface FieldSize {
|
|
19
|
-
height: string;
|
|
20
|
-
floatingHeight: string;
|
|
21
|
-
padding: string;
|
|
22
|
-
text: string;
|
|
23
|
-
radius: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function fieldSize(size: TextFieldSize): FieldSize {
|
|
27
|
-
switch (size) {
|
|
28
|
-
case "xs":
|
|
29
|
-
return {
|
|
30
|
-
height: "h-8",
|
|
31
|
-
floatingHeight: "h-9",
|
|
32
|
-
padding: "px-2.5",
|
|
33
|
-
text: "text-caption",
|
|
34
|
-
radius: "rounded-lg",
|
|
35
|
-
};
|
|
36
|
-
case "sm":
|
|
37
|
-
return {
|
|
38
|
-
height: "h-9",
|
|
39
|
-
floatingHeight: "h-10",
|
|
40
|
-
padding: "px-3",
|
|
41
|
-
text: "text-subheadline",
|
|
42
|
-
radius: "rounded-xl",
|
|
43
|
-
};
|
|
44
|
-
case "lg":
|
|
45
|
-
return {
|
|
46
|
-
height: "h-12",
|
|
47
|
-
floatingHeight: "h-14",
|
|
48
|
-
padding: "px-4",
|
|
49
|
-
text: "text-body",
|
|
50
|
-
radius: "rounded-xl",
|
|
51
|
-
};
|
|
52
|
-
default:
|
|
53
|
-
return {
|
|
54
|
-
height: "h-11",
|
|
55
|
-
floatingHeight: "h-12",
|
|
56
|
-
padding: "px-3",
|
|
57
|
-
text: "text-body",
|
|
58
|
-
radius: "rounded-xl",
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export type TextFieldProps = Omit<ComponentProps<"input">, "size"> & {
|
|
64
|
-
label: string;
|
|
65
|
-
description?: ReactNode;
|
|
66
|
-
errors?: string[];
|
|
67
|
-
/** A decorative icon before the text, such as a mail glyph. */
|
|
68
|
-
icon?: ReactNode;
|
|
69
|
-
/** A decorative icon after the text, such as a unit or a check. */
|
|
70
|
-
trailingIcon?: ReactNode;
|
|
71
|
-
/** An interactive control after the text, such as a clear button. Size it to the field: an `xs` or `icon-xs` button, never the default. */
|
|
72
|
-
action?: ReactNode;
|
|
73
|
-
revealLabels?: { show: string; hide: string };
|
|
74
|
-
/** Float the label into the outline on focus or when filled. @default "above" */
|
|
75
|
-
labelPlacement?: "above" | "floating";
|
|
76
|
-
/** Field height and text scale. @default "md" */
|
|
77
|
-
size?: TextFieldSize;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export function TextField({
|
|
81
|
-
label,
|
|
82
|
-
description,
|
|
83
|
-
errors = [],
|
|
84
|
-
icon,
|
|
85
|
-
trailingIcon,
|
|
86
|
-
action,
|
|
87
|
-
revealLabels,
|
|
88
|
-
labelPlacement = "above",
|
|
89
|
-
size = "md",
|
|
90
|
-
placeholder,
|
|
91
|
-
type = "text",
|
|
92
|
-
id: suppliedId,
|
|
93
|
-
className,
|
|
94
|
-
...props
|
|
95
|
-
}: TextFieldProps) {
|
|
96
|
-
const generatedId = useId();
|
|
97
|
-
const id = suppliedId ?? generatedId;
|
|
98
|
-
const [revealed, setRevealed] = useState(false);
|
|
99
|
-
const messages = Array.from(new Set(errors));
|
|
100
|
-
const reveal = type === "password" && revealLabels;
|
|
101
|
-
const dims = fieldSize(size);
|
|
102
|
-
return (
|
|
103
|
-
<div className="not-typeset flex flex-col gap-2">
|
|
104
|
-
{labelPlacement === "above" && (
|
|
105
|
-
<label htmlFor={id} className="text-subheadline font-semibold">
|
|
106
|
-
{label}
|
|
107
|
-
</label>
|
|
108
|
-
)}
|
|
109
|
-
<div
|
|
110
|
-
className={cn(
|
|
111
|
-
`relative flex items-center gap-2 ${dims.padding} ${dims.radius} bg-elevated`,
|
|
112
|
-
labelPlacement === "floating"
|
|
113
|
-
? "passui-floating-field"
|
|
114
|
-
: "border-separator focus-within:ring-accent/40 has-[:focus-visible]:ring-accent-text/70 border focus-within:ring-1 has-[:focus-visible]:ring-2",
|
|
115
|
-
)}
|
|
116
|
-
>
|
|
117
|
-
{labelPlacement === "floating" && (
|
|
118
|
-
<>
|
|
119
|
-
<fieldset aria-hidden="true" className="passui-field-outline">
|
|
120
|
-
<legend>
|
|
121
|
-
<span>{label}</span>
|
|
122
|
-
</legend>
|
|
123
|
-
</fieldset>
|
|
124
|
-
<label
|
|
125
|
-
htmlFor={id}
|
|
126
|
-
className={cn(
|
|
127
|
-
"passui-floating-label",
|
|
128
|
-
icon && "passui-floating-label-with-icon",
|
|
129
|
-
)}
|
|
130
|
-
>
|
|
131
|
-
{label}
|
|
132
|
-
</label>
|
|
133
|
-
</>
|
|
134
|
-
)}
|
|
135
|
-
{icon && (
|
|
136
|
-
<span aria-hidden className={fieldIconClasses}>
|
|
137
|
-
{icon}
|
|
138
|
-
</span>
|
|
139
|
-
)}
|
|
140
|
-
<input
|
|
141
|
-
{...props}
|
|
142
|
-
id={id}
|
|
143
|
-
type={reveal && revealed ? "text" : type}
|
|
144
|
-
placeholder={
|
|
145
|
-
placeholder ?? (labelPlacement === "floating" ? " " : label)
|
|
146
|
-
}
|
|
147
|
-
aria-invalid={messages.length > 0 || props["aria-invalid"]}
|
|
148
|
-
aria-describedby={
|
|
149
|
-
[
|
|
150
|
-
props["aria-describedby"],
|
|
151
|
-
(messages.length || description) && `${id}-description`,
|
|
152
|
-
]
|
|
153
|
-
.filter(Boolean)
|
|
154
|
-
.join(" ") || undefined
|
|
155
|
-
}
|
|
156
|
-
className={cn(
|
|
157
|
-
labelPlacement === "floating" ? dims.floatingHeight : dims.height,
|
|
158
|
-
"text-label w-full min-w-0 bg-transparent outline-none",
|
|
159
|
-
dims.text,
|
|
160
|
-
"placeholder:text-label-tertiary disabled:opacity-40",
|
|
161
|
-
className,
|
|
162
|
-
)}
|
|
163
|
-
/>
|
|
164
|
-
{trailingIcon && (
|
|
165
|
-
<span aria-hidden className={fieldIconClasses}>
|
|
166
|
-
{trailingIcon}
|
|
167
|
-
</span>
|
|
168
|
-
)}
|
|
169
|
-
{reveal && (
|
|
170
|
-
<Button
|
|
171
|
-
variant="ghost"
|
|
172
|
-
size="xs"
|
|
173
|
-
// sized to sit inside the 44px field; on touch a
|
|
174
|
-
// wider invisible area keeps a 44px target
|
|
175
|
-
className="-mr-1.5 shrink-0 whitespace-nowrap [@media(pointer:coarse)]:before:absolute [@media(pointer:coarse)]:before:-inset-1.5 [@media(pointer:coarse)]:before:content-['']"
|
|
176
|
-
aria-controls={id}
|
|
177
|
-
aria-label={revealed ? revealLabels.hide : revealLabels.show}
|
|
178
|
-
aria-pressed={revealed}
|
|
179
|
-
onClick={() => setRevealed(!revealed)}
|
|
180
|
-
>
|
|
181
|
-
{revealed ? revealLabels.hide : revealLabels.show}
|
|
182
|
-
</Button>
|
|
183
|
-
)}
|
|
184
|
-
{action}
|
|
185
|
-
</div>
|
|
186
|
-
{(messages.length > 0 || description) && (
|
|
187
|
-
<div
|
|
188
|
-
id={`${id}-description`}
|
|
189
|
-
role={messages.length ? "alert" : undefined}
|
|
190
|
-
className={cn(
|
|
191
|
-
"text-footnote",
|
|
192
|
-
messages.length ? "text-danger" : "text-label-secondary",
|
|
193
|
-
)}
|
|
194
|
-
>
|
|
195
|
-
{messages.length ? messages.join(". ") : description}
|
|
196
|
-
</div>
|
|
197
|
-
)}
|
|
198
|
-
</div>
|
|
199
|
-
);
|
|
200
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
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
|
-
|
|
8
|
-
export interface ToastAction {
|
|
9
|
-
label: string;
|
|
10
|
-
onClick: () => void;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface Toast {
|
|
14
|
-
id: number;
|
|
15
|
-
tone: ToastTone;
|
|
16
|
-
title: string;
|
|
17
|
-
description?: string;
|
|
18
|
-
action?: ToastAction;
|
|
19
|
-
/** Milliseconds before it leaves on its own; `null` stays until dismissed. */
|
|
20
|
-
duration: number | null;
|
|
21
|
-
createdAt: number;
|
|
22
|
-
/** Pill size, content padding and title/description text scale. @default "md" */
|
|
23
|
-
size: ToastSize;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface ToastOptions {
|
|
27
|
-
description?: string;
|
|
28
|
-
action?: ToastAction;
|
|
29
|
-
duration?: number | null;
|
|
30
|
-
/** Pill size, content padding and title/description text scale. @default "md" */
|
|
31
|
-
size?: ToastSize;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const DEFAULT_DURATION = 4200;
|
|
35
|
-
const MAX_VISIBLE = 3;
|
|
36
|
-
|
|
37
|
-
let toasts: Toast[] = [];
|
|
38
|
-
let nextId = 1;
|
|
39
|
-
const listeners = new Set<() => void>();
|
|
40
|
-
|
|
41
|
-
const emit = () => {
|
|
42
|
-
for (const listener of listeners) listener();
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
function show(
|
|
46
|
-
tone: ToastTone,
|
|
47
|
-
title: string,
|
|
48
|
-
options: ToastOptions = {},
|
|
49
|
-
): number {
|
|
50
|
-
const id = nextId++;
|
|
51
|
-
const duration =
|
|
52
|
-
options.duration !== undefined
|
|
53
|
-
? options.duration
|
|
54
|
-
: tone === "loading"
|
|
55
|
-
? null
|
|
56
|
-
: DEFAULT_DURATION;
|
|
57
|
-
toasts = [
|
|
58
|
-
{
|
|
59
|
-
id,
|
|
60
|
-
tone,
|
|
61
|
-
title,
|
|
62
|
-
description: options.description,
|
|
63
|
-
action: options.action,
|
|
64
|
-
duration,
|
|
65
|
-
createdAt: Date.now(),
|
|
66
|
-
size: options.size ?? "md",
|
|
67
|
-
},
|
|
68
|
-
...toasts,
|
|
69
|
-
].slice(0, MAX_VISIBLE + 2);
|
|
70
|
-
emit();
|
|
71
|
-
return id;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Changes a toast in place; it morphs to its new state. */
|
|
75
|
-
function update(
|
|
76
|
-
id: number,
|
|
77
|
-
tone: ToastTone,
|
|
78
|
-
title: string,
|
|
79
|
-
options: ToastOptions = {},
|
|
80
|
-
) {
|
|
81
|
-
if (!toasts.some((t) => t.id === id)) return show(tone, title, options);
|
|
82
|
-
toasts = toasts.map((t) =>
|
|
83
|
-
t.id === id
|
|
84
|
-
? {
|
|
85
|
-
...t,
|
|
86
|
-
tone,
|
|
87
|
-
title,
|
|
88
|
-
description: options.description,
|
|
89
|
-
action: options.action,
|
|
90
|
-
duration:
|
|
91
|
-
options.duration !== undefined
|
|
92
|
-
? options.duration
|
|
93
|
-
: tone === "loading"
|
|
94
|
-
? null
|
|
95
|
-
: DEFAULT_DURATION,
|
|
96
|
-
createdAt: Date.now(),
|
|
97
|
-
size: options.size ?? t.size,
|
|
98
|
-
}
|
|
99
|
-
: t,
|
|
100
|
-
);
|
|
101
|
-
emit();
|
|
102
|
-
return id;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function dismiss(id: number) {
|
|
106
|
-
toasts = toasts.filter((t) => t.id !== id);
|
|
107
|
-
emit();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
interface PromiseMessages<T> {
|
|
111
|
-
loading: string;
|
|
112
|
-
success: string | ((value: T) => string);
|
|
113
|
-
error: string | ((error: unknown) => string);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export const toast = Object.assign(
|
|
117
|
-
(title: string, options?: ToastOptions) => show("neutral", title, options),
|
|
118
|
-
{
|
|
119
|
-
success: (title: string, options?: ToastOptions) =>
|
|
120
|
-
show("success", title, options),
|
|
121
|
-
error: (title: string, options?: ToastOptions) =>
|
|
122
|
-
show("error", title, options),
|
|
123
|
-
loading: (title: string, options?: ToastOptions) =>
|
|
124
|
-
show("loading", title, options),
|
|
125
|
-
update,
|
|
126
|
-
dismiss,
|
|
127
|
-
/** Shows progress, then morphs into the outcome. Returns the promise. */
|
|
128
|
-
promise<T>(promise: Promise<T>, messages: PromiseMessages<T>): Promise<T> {
|
|
129
|
-
const id = show("loading", messages.loading);
|
|
130
|
-
promise.then(
|
|
131
|
-
(value) =>
|
|
132
|
-
update(
|
|
133
|
-
id,
|
|
134
|
-
"success",
|
|
135
|
-
typeof messages.success === "function"
|
|
136
|
-
? messages.success(value)
|
|
137
|
-
: messages.success,
|
|
138
|
-
),
|
|
139
|
-
(error: unknown) =>
|
|
140
|
-
update(
|
|
141
|
-
id,
|
|
142
|
-
"error",
|
|
143
|
-
typeof messages.error === "function"
|
|
144
|
-
? messages.error(error)
|
|
145
|
-
: messages.error,
|
|
146
|
-
),
|
|
147
|
-
);
|
|
148
|
-
return promise;
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
export function subscribeToasts(listener: () => void) {
|
|
154
|
-
listeners.add(listener);
|
|
155
|
-
return () => {
|
|
156
|
-
listeners.delete(listener);
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function getToasts(): Toast[] {
|
|
161
|
-
return toasts;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export const toastLimits = { visible: MAX_VISIBLE } as const;
|