@passui/react 0.0.0-stage → 0.1.15
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/LICENSE +21 -0
- package/README.md +83 -2
- package/package.json +96 -5
- package/src/appearance/index.ts +2 -0
- package/src/appearance/platform.tsx +123 -0
- package/src/appearance/theme.tsx +535 -0
- package/src/components/ambient/ambient.docs.tsx +68 -0
- package/src/components/ambient/ambient.tsx +43 -0
- package/src/components/ambient/examples/ambient-images.tsx +30 -0
- package/src/components/ambient/examples/ambient-now-playing.tsx +55 -0
- package/src/components/ambient/examples/ambient-showcase.tsx +33 -0
- package/src/components/ambient/examples/ambient-usage.tsx +19 -0
- package/src/components/ambient/index.ts +1 -0
- package/src/components/button/button-styles.ts +60 -0
- package/src/components/button/button.docs.tsx +116 -0
- package/src/components/button/button.tsx +91 -0
- package/src/components/button/examples/button-disabled.tsx +19 -0
- package/src/components/button/examples/button-icon.tsx +39 -0
- package/src/components/button/examples/button-link.tsx +12 -0
- package/src/components/button/examples/button-pending.tsx +27 -0
- package/src/components/button/examples/button-showcase.tsx +115 -0
- package/src/components/button/examples/button-sizes.tsx +12 -0
- package/src/components/button/examples/button-usage.tsx +12 -0
- package/src/components/button/examples/button-variants.tsx +15 -0
- package/src/components/button/examples/button-with-icon.tsx +32 -0
- package/src/components/button/examples/icon-button-player.tsx +38 -0
- package/src/components/button/examples/icon-button-showcase.tsx +83 -0
- package/src/components/button/examples/icon-button-usage.tsx +11 -0
- package/src/components/button/examples/icon-button-variants.tsx +39 -0
- package/src/components/button/icon-button.docs.tsx +68 -0
- package/src/components/button/icon-button.tsx +73 -0
- package/src/components/button/pending-spinner.tsx +14 -0
- package/src/components/button/use-pending-indicator.ts +27 -0
- package/src/components/chip/chip.docs.tsx +37 -0
- package/src/components/chip/chip.tsx +35 -0
- package/src/components/chip/examples/chip-in-rows.tsx +19 -0
- package/src/components/chip/examples/chip-showcase.tsx +51 -0
- package/src/components/chip/examples/chip-tones.tsx +13 -0
- package/src/components/chip/examples/chip-usage.tsx +5 -0
- package/src/components/compact-date-picker/calendar-month.ts +131 -0
- package/src/components/compact-date-picker/compact-date-picker.docs.tsx +81 -0
- package/src/components/compact-date-picker/compact-date-picker.tsx +438 -0
- package/src/components/compact-date-picker/examples/compact-date-picker-showcase.tsx +35 -0
- package/src/components/compact-date-picker/examples/compact-date-picker-usage.tsx +22 -0
- package/src/components/compact-time-picker/compact-time-picker.docs.tsx +80 -0
- package/src/components/compact-time-picker/compact-time-picker.tsx +432 -0
- package/src/components/compact-time-picker/examples/compact-time-picker-showcase.tsx +31 -0
- package/src/components/compact-time-picker/examples/compact-time-picker-usage.tsx +21 -0
- package/src/components/compact-time-picker/time-value.ts +67 -0
- package/src/components/content-view/content-view.docs.tsx +61 -0
- package/src/components/content-view/content-view.tsx +197 -0
- package/src/components/content-view/examples/content-view-header-action.tsx +33 -0
- package/src/components/content-view/examples/content-view-showcase.tsx +65 -0
- package/src/components/content-view/examples/content-view-stats.tsx +35 -0
- package/src/components/content-view/examples/content-view-usage.tsx +14 -0
- package/src/components/content-view/index.ts +1 -0
- package/src/components/context-menu/conceal-menu-source.ts +33 -0
- package/src/components/context-menu/context-menu-host.tsx +445 -0
- package/src/components/context-menu/context-menu-store.ts +165 -0
- package/src/components/context-menu/context-menu.docs.tsx +92 -0
- package/src/components/context-menu/examples/context-menu-checked.tsx +37 -0
- package/src/components/context-menu/examples/context-menu-list.tsx +85 -0
- package/src/components/context-menu/examples/context-menu-showcase.tsx +56 -0
- package/src/components/context-menu/examples/context-menu-toolbar.tsx +63 -0
- package/src/components/context-menu/examples/context-menu-usage.tsx +24 -0
- package/src/components/context-menu/menu-position.ts +55 -0
- package/src/components/context-menu/menu-reveal.ts +75 -0
- package/src/components/context-menu/use-context-menu.ts +90 -0
- package/src/components/conversation/conversation.docs.tsx +88 -0
- package/src/components/conversation/conversation.tsx +279 -0
- package/src/components/conversation/examples/conversation-composer.tsx +36 -0
- package/src/components/conversation/examples/conversation-days.tsx +48 -0
- package/src/components/conversation/examples/conversation-showcase.tsx +71 -0
- package/src/components/conversation/examples/conversation-usage.tsx +28 -0
- package/src/components/conversation/index.ts +1 -0
- package/src/components/date-picker/date-picker.docs.tsx +88 -0
- package/src/components/date-picker/date-picker.tsx +103 -0
- package/src/components/date-picker/date-value.ts +37 -0
- package/src/components/date-picker/examples/date-picker-locales.tsx +41 -0
- package/src/components/date-picker/examples/date-picker-past-only.tsx +29 -0
- package/src/components/date-picker/examples/date-picker-showcase.tsx +49 -0
- package/src/components/date-picker/examples/date-picker-usage.tsx +22 -0
- package/src/components/dialog/dialog-host.tsx +156 -0
- package/src/components/dialog/dialog-store.ts +56 -0
- package/src/components/dialog/dialog.docs.tsx +114 -0
- package/src/components/dialog/dialog.tsx +200 -0
- package/src/components/dialog/examples/dialog-confirm.tsx +24 -0
- package/src/components/dialog/examples/dialog-form.tsx +46 -0
- package/src/components/dialog/examples/dialog-inline.tsx +48 -0
- package/src/components/dialog/examples/dialog-showcase.tsx +53 -0
- package/src/components/dialog/examples/dialog-usage.tsx +31 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/labeled-content/examples/labeled-content-descriptions.tsx +37 -0
- package/src/components/labeled-content/examples/labeled-content-showcase.tsx +54 -0
- package/src/components/labeled-content/examples/labeled-content-usage.tsx +22 -0
- package/src/components/labeled-content/examples/labeled-content-values.tsx +26 -0
- package/src/components/labeled-content/examples/labeled-content-wide.tsx +46 -0
- package/src/components/labeled-content/labeled-content.docs.tsx +69 -0
- package/src/components/labeled-content/labeled-content.tsx +66 -0
- package/src/components/locale-switcher/examples/locale-switcher-native-names.tsx +30 -0
- package/src/components/locale-switcher/examples/locale-switcher-showcase.tsx +46 -0
- package/src/components/locale-switcher/examples/locale-switcher-translated-page.tsx +35 -0
- package/src/components/locale-switcher/examples/locale-switcher-usage.tsx +20 -0
- package/src/components/locale-switcher/index.ts +1 -0
- package/src/components/locale-switcher/locale-switcher.docs.tsx +91 -0
- package/src/components/locale-switcher/locale-switcher.tsx +252 -0
- package/src/components/picker/examples/picker-details.tsx +44 -0
- package/src/components/picker/examples/picker-searchable.tsx +48 -0
- package/src/components/picker/examples/picker-showcase.tsx +66 -0
- package/src/components/picker/examples/picker-usage.tsx +20 -0
- package/src/components/picker/picker.docs.tsx +68 -0
- package/src/components/picker/picker.tsx +493 -0
- package/src/components/popover/examples/popover-help.tsx +57 -0
- package/src/components/popover/examples/popover-menu.tsx +51 -0
- package/src/components/popover/examples/popover-showcase.tsx +61 -0
- package/src/components/popover/examples/popover-usage.tsx +31 -0
- package/src/components/popover/popover.docs.tsx +84 -0
- package/src/components/popover/popover.tsx +138 -0
- package/src/components/profile-image/examples/profile-image-fallbacks.tsx +29 -0
- package/src/components/profile-image/examples/profile-image-group.tsx +34 -0
- package/src/components/profile-image/examples/profile-image-showcase.tsx +30 -0
- package/src/components/profile-image/examples/profile-image-usage.tsx +14 -0
- package/src/components/profile-image/profile-image.docs.tsx +81 -0
- package/src/components/profile-image/profile-image.tsx +80 -0
- package/src/components/search-field/examples/search-field-filter.tsx +53 -0
- package/src/components/search-field/examples/search-field-showcase.tsx +56 -0
- package/src/components/search-field/examples/search-field-toolbar.tsx +27 -0
- package/src/components/search-field/examples/search-field-usage.tsx +18 -0
- package/src/components/search-field/search-field.docs.tsx +58 -0
- package/src/components/search-field/search-field.tsx +29 -0
- package/src/components/search-list/examples/search-list-dropdown.tsx +53 -0
- package/src/components/search-list/examples/search-list-groups.tsx +64 -0
- package/src/components/search-list/examples/search-list-showcase.tsx +67 -0
- package/src/components/search-list/examples/search-list-usage.tsx +27 -0
- package/src/components/search-list/search-list.docs.tsx +87 -0
- package/src/components/search-list/search-list.tsx +265 -0
- package/src/components/section/examples/section-actions.tsx +35 -0
- package/src/components/section/examples/section-groups.tsx +41 -0
- package/src/components/section/examples/section-showcase.tsx +63 -0
- package/src/components/section/examples/section-usage.tsx +19 -0
- package/src/components/section/section.docs.tsx +51 -0
- package/src/components/section/section.tsx +41 -0
- package/src/components/secure-field/examples/secure-field-new-password.tsx +56 -0
- package/src/components/secure-field/examples/secure-field-reveal.tsx +20 -0
- package/src/components/secure-field/examples/secure-field-showcase.tsx +62 -0
- package/src/components/secure-field/examples/secure-field-usage.tsx +19 -0
- package/src/components/secure-field/secure-field.docs.tsx +72 -0
- package/src/components/secure-field/secure-field.tsx +10 -0
- package/src/components/segmented-control/examples/segmented-control-overflow.tsx +28 -0
- package/src/components/segmented-control/examples/segmented-control-showcase.tsx +59 -0
- package/src/components/segmented-control/examples/segmented-control-usage.tsx +20 -0
- package/src/components/segmented-control/examples/segmented-control-views.tsx +32 -0
- package/src/components/segmented-control/segmented-control.docs.tsx +61 -0
- package/src/components/segmented-control/segmented-control.tsx +122 -0
- package/src/components/sheet/examples/sheet-choices.tsx +58 -0
- package/src/components/sheet/examples/sheet-share.tsx +51 -0
- package/src/components/sheet/examples/sheet-showcase.tsx +74 -0
- package/src/components/sheet/examples/sheet-usage.tsx +32 -0
- package/src/components/sheet/modal-environment.ts +113 -0
- package/src/components/sheet/sheet-portal.tsx +89 -0
- package/src/components/sheet/sheet.docs.tsx +75 -0
- package/src/components/sheet/sheet.tsx +112 -0
- package/src/components/sheet/use-sheet-focus.ts +130 -0
- package/src/components/sidebar/examples/sidebar-groups.tsx +133 -0
- package/src/components/sidebar/examples/sidebar-showcase.tsx +123 -0
- package/src/components/sidebar/examples/sidebar-unread.tsx +66 -0
- package/src/components/sidebar/examples/sidebar-usage.tsx +52 -0
- package/src/components/sidebar/sidebar.docs.tsx +135 -0
- package/src/components/sidebar/sidebar.tsx +69 -0
- package/src/components/stat-tile/examples/stat-tile-filters.tsx +32 -0
- package/src/components/stat-tile/examples/stat-tile-grid.tsx +21 -0
- package/src/components/stat-tile/examples/stat-tile-showcase.tsx +52 -0
- package/src/components/stat-tile/examples/stat-tile-usage.tsx +13 -0
- package/src/components/stat-tile/index.ts +1 -0
- package/src/components/stat-tile/stat-tile.docs.tsx +60 -0
- package/src/components/stat-tile/stat-tile.tsx +68 -0
- package/src/components/status-indicator/examples/status-indicator-live.tsx +34 -0
- package/src/components/status-indicator/examples/status-indicator-showcase.tsx +39 -0
- package/src/components/status-indicator/examples/status-indicator-states.tsx +17 -0
- package/src/components/status-indicator/examples/status-indicator-usage.tsx +9 -0
- package/src/components/status-indicator/status-indicator.docs.tsx +43 -0
- package/src/components/status-indicator/status-indicator.tsx +35 -0
- package/src/components/swatch-picker/examples/swatch-picker-accents.tsx +42 -0
- package/src/components/swatch-picker/examples/swatch-picker-labels.tsx +45 -0
- package/src/components/swatch-picker/examples/swatch-picker-showcase.tsx +70 -0
- package/src/components/swatch-picker/examples/swatch-picker-usage.tsx +39 -0
- package/src/components/swatch-picker/swatch-picker.docs.tsx +60 -0
- package/src/components/swatch-picker/swatch-picker.tsx +96 -0
- package/src/components/tab-bar/examples/tab-bar-five-tabs.tsx +66 -0
- package/src/components/tab-bar/examples/tab-bar-minimize.tsx +71 -0
- package/src/components/tab-bar/examples/tab-bar-showcase.tsx +82 -0
- package/src/components/tab-bar/examples/tab-bar-usage.tsx +54 -0
- package/src/components/tab-bar/tab-bar.docs.tsx +136 -0
- package/src/components/tab-bar/tab-bar.tsx +148 -0
- package/src/components/tab-view/examples/tab-view-keyboard.tsx +39 -0
- package/src/components/tab-view/examples/tab-view-settings.tsx +56 -0
- package/src/components/tab-view/examples/tab-view-showcase.tsx +53 -0
- package/src/components/tab-view/examples/tab-view-usage.tsx +23 -0
- package/src/components/tab-view/tab-view.docs.tsx +77 -0
- package/src/components/tab-view/tab-view.tsx +130 -0
- package/src/components/table/examples/table-empty.tsx +53 -0
- package/src/components/table/examples/table-invoices.tsx +102 -0
- package/src/components/table/examples/table-selection.tsx +150 -0
- package/src/components/table/examples/table-showcase.tsx +115 -0
- package/src/components/table/examples/table-usage.tsx +67 -0
- package/src/components/table/examples/table-wide.tsx +75 -0
- package/src/components/table/table.docs.tsx +131 -0
- package/src/components/table/table.tsx +149 -0
- package/src/components/text-editor/examples/text-editor-comment.tsx +48 -0
- package/src/components/text-editor/examples/text-editor-count.tsx +38 -0
- package/src/components/text-editor/examples/text-editor-showcase.tsx +58 -0
- package/src/components/text-editor/examples/text-editor-usage.tsx +25 -0
- package/src/components/text-editor/text-editor.docs.tsx +61 -0
- package/src/components/text-editor/text-editor.tsx +19 -0
- package/src/components/text-field/examples/text-field-icons.tsx +72 -0
- package/src/components/text-field/examples/text-field-showcase.tsx +50 -0
- package/src/components/text-field/examples/text-field-usage.tsx +18 -0
- package/src/components/text-field/examples/text-field-validation.tsx +27 -0
- package/src/components/text-field/text-field.docs.tsx +118 -0
- package/src/components/text-field/text-field.tsx +135 -0
- package/src/components/toast/examples/toast-action.tsx +32 -0
- package/src/components/toast/examples/toast-promise.tsx +45 -0
- package/src/components/toast/examples/toast-showcase.tsx +49 -0
- package/src/components/toast/examples/toast-usage.tsx +13 -0
- package/src/components/toast/toast-store.ts +166 -0
- package/src/components/toast/toast.docs.tsx +79 -0
- package/src/components/toast/toaster.tsx +374 -0
- package/src/components/toggle/examples/toggle-checkboxes.tsx +43 -0
- package/src/components/toggle/examples/toggle-settings.tsx +31 -0
- package/src/components/toggle/examples/toggle-showcase.tsx +59 -0
- package/src/components/toggle/examples/toggle-usage.tsx +13 -0
- package/src/components/toggle/toggle.docs.tsx +69 -0
- package/src/components/toggle/toggle.tsx +85 -0
- package/src/components/tooltip/examples/tooltip-icon-buttons.tsx +27 -0
- package/src/components/tooltip/examples/tooltip-shortcuts.tsx +38 -0
- package/src/components/tooltip/examples/tooltip-showcase.tsx +44 -0
- package/src/components/tooltip/examples/tooltip-usage.tsx +13 -0
- package/src/components/tooltip/tooltip-host.tsx +156 -0
- package/src/components/tooltip/tooltip.docs.tsx +56 -0
- package/src/components/view-controller/examples/view-controller-action.tsx +27 -0
- package/src/components/view-controller/examples/view-controller-settings.tsx +31 -0
- package/src/components/view-controller/examples/view-controller-showcase.tsx +45 -0
- package/src/components/view-controller/examples/view-controller-usage.tsx +19 -0
- package/src/components/view-controller/index.ts +1 -0
- package/src/components/view-controller/view-controller.docs.tsx +71 -0
- package/src/components/view-controller/view-controller.tsx +81 -0
- package/src/docs/index.ts +3 -0
- package/src/docs/registry.ts +113 -0
- package/src/docs/snippet.ts +17 -0
- package/src/docs/types.ts +180 -0
- package/src/hooks/scroll/minimize-decision.ts +13 -0
- package/src/hooks/use-anchored-placement.ts +43 -0
- package/src/hooks/use-dismiss.ts +58 -0
- package/src/hooks/use-media-query.ts +106 -0
- package/src/hooks/use-minimize-on-scroll.ts +92 -0
- package/src/hooks/use-visual-viewport.ts +76 -0
- package/src/hooks/viewport/types.ts +19 -0
- package/src/hooks/viewport/viewport-metrics.ts +25 -0
- package/src/icons/icons.tsx +298 -0
- package/src/index.ts +78 -0
- package/src/lib/anchored-placement.ts +92 -0
- package/src/lib/class-names.ts +21 -0
- package/src/lib/date.ts +96 -0
- package/src/lib/floating-layers.ts +28 -0
- package/src/lib/haptics.ts +25 -0
- package/src/lib/language.ts +21 -0
- package/src/lib/screen-edges.ts +45 -0
- package/src/lib/shapes.ts +70 -0
- package/src/motion/transitions.ts +30 -0
- package/src/styles/base.css +1 -0
- package/src/styles/styles.css +3 -0
- package/src/styles/theme.css +1 -0
- package/src/styles/typeset.css +1 -0
- package/src/styles/utilities.css +1 -0
- package/src/tokens.ts +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Sheet } from "@passui/react/sheet"
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
motion,
|
|
5
|
+
useReducedMotion,
|
|
6
|
+
} from "motion/react"
|
|
7
|
+
import { createPortal } from "react-dom"
|
|
8
|
+
import { Button } from "@passui/react/button"
|
|
9
|
+
import { cn } from "@passui/react/cn"
|
|
10
|
+
import {
|
|
11
|
+
createContext,
|
|
12
|
+
useContext,
|
|
13
|
+
useId,
|
|
14
|
+
type FormEvent,
|
|
15
|
+
type ReactNode,
|
|
16
|
+
} from "react"
|
|
17
|
+
|
|
18
|
+
const CloseContext = createContext<() => void>(() => {})
|
|
19
|
+
export type DialogPresentation =
|
|
20
|
+
| "drawer"
|
|
21
|
+
| "center"
|
|
22
|
+
| "inline"
|
|
23
|
+
export type DialogTone = "default" | "destructive"
|
|
24
|
+
|
|
25
|
+
type DialogProps = {
|
|
26
|
+
open: boolean
|
|
27
|
+
onOpenChange: (open: boolean) => void
|
|
28
|
+
title: ReactNode
|
|
29
|
+
description?: ReactNode
|
|
30
|
+
children?: ReactNode
|
|
31
|
+
footer?: ReactNode
|
|
32
|
+
presentation?: DialogPresentation
|
|
33
|
+
className?: string
|
|
34
|
+
onSubmit?: (event: FormEvent<HTMLFormElement>) => void
|
|
35
|
+
}
|
|
36
|
+
type ActionsProps = {
|
|
37
|
+
submitLabel: ReactNode
|
|
38
|
+
cancelLabel: ReactNode
|
|
39
|
+
pending?: boolean
|
|
40
|
+
disabled?: boolean
|
|
41
|
+
tone?: DialogTone
|
|
42
|
+
onConfirm?: () => void
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function Dialog({
|
|
46
|
+
open,
|
|
47
|
+
onOpenChange,
|
|
48
|
+
title,
|
|
49
|
+
description,
|
|
50
|
+
children,
|
|
51
|
+
footer,
|
|
52
|
+
presentation = "drawer",
|
|
53
|
+
className,
|
|
54
|
+
onSubmit,
|
|
55
|
+
}: DialogProps) {
|
|
56
|
+
const titleId = useId()
|
|
57
|
+
const reducedMotion = useReducedMotion()
|
|
58
|
+
const close = () => onOpenChange(false)
|
|
59
|
+
const content = (
|
|
60
|
+
<>
|
|
61
|
+
{presentation !== "inline" && (
|
|
62
|
+
<h2
|
|
63
|
+
id={titleId}
|
|
64
|
+
className="text-title3 font-semibold"
|
|
65
|
+
>
|
|
66
|
+
{title}
|
|
67
|
+
</h2>
|
|
68
|
+
)}
|
|
69
|
+
{description && (
|
|
70
|
+
<p className="text-footnote text-label-secondary">
|
|
71
|
+
{description}
|
|
72
|
+
</p>
|
|
73
|
+
)}
|
|
74
|
+
{children && (
|
|
75
|
+
<div className="flex flex-col gap-4">
|
|
76
|
+
{children}
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
{footer && (
|
|
80
|
+
<div className="flex flex-wrap justify-end gap-2 pt-3">
|
|
81
|
+
{footer}
|
|
82
|
+
</div>
|
|
83
|
+
)}
|
|
84
|
+
</>
|
|
85
|
+
)
|
|
86
|
+
const body = (
|
|
87
|
+
<CloseContext value={close}>
|
|
88
|
+
{onSubmit ? (
|
|
89
|
+
<form
|
|
90
|
+
onSubmit={onSubmit}
|
|
91
|
+
className={cn(
|
|
92
|
+
"flex min-h-0 flex-col gap-4 overflow-y-auto p-5",
|
|
93
|
+
className
|
|
94
|
+
)}
|
|
95
|
+
>
|
|
96
|
+
{content}
|
|
97
|
+
</form>
|
|
98
|
+
) : (
|
|
99
|
+
<div
|
|
100
|
+
className={cn(
|
|
101
|
+
"flex min-h-0 flex-col gap-4 overflow-y-auto p-5",
|
|
102
|
+
className
|
|
103
|
+
)}
|
|
104
|
+
>
|
|
105
|
+
{content}
|
|
106
|
+
</div>
|
|
107
|
+
)}
|
|
108
|
+
</CloseContext>
|
|
109
|
+
)
|
|
110
|
+
if (presentation === "inline")
|
|
111
|
+
return (
|
|
112
|
+
<AnimatePresence initial={false}>
|
|
113
|
+
{open && (
|
|
114
|
+
<motion.div
|
|
115
|
+
key={titleId}
|
|
116
|
+
initial={{
|
|
117
|
+
height: reducedMotion
|
|
118
|
+
? "auto"
|
|
119
|
+
: 0,
|
|
120
|
+
opacity: 0,
|
|
121
|
+
}}
|
|
122
|
+
animate={{
|
|
123
|
+
height: "auto",
|
|
124
|
+
opacity: 1,
|
|
125
|
+
}}
|
|
126
|
+
exit={{
|
|
127
|
+
height: reducedMotion
|
|
128
|
+
? "auto"
|
|
129
|
+
: 0,
|
|
130
|
+
opacity: 0,
|
|
131
|
+
}}
|
|
132
|
+
transition={{
|
|
133
|
+
duration: reducedMotion
|
|
134
|
+
? 0
|
|
135
|
+
: 0.28,
|
|
136
|
+
ease: [0.22, 1, 0.36, 1],
|
|
137
|
+
}}
|
|
138
|
+
className="overflow-hidden"
|
|
139
|
+
>
|
|
140
|
+
{body}
|
|
141
|
+
</motion.div>
|
|
142
|
+
)}
|
|
143
|
+
</AnimatePresence>
|
|
144
|
+
)
|
|
145
|
+
if (typeof document === "undefined") return null
|
|
146
|
+
return createPortal(
|
|
147
|
+
<Sheet
|
|
148
|
+
open={open}
|
|
149
|
+
onClose={close}
|
|
150
|
+
label=""
|
|
151
|
+
labelledBy={titleId}
|
|
152
|
+
>
|
|
153
|
+
{body}
|
|
154
|
+
</Sheet>,
|
|
155
|
+
document.body
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The standard footer: a primary action and a cancel that closes the dialog. */
|
|
160
|
+
function Actions({
|
|
161
|
+
submitLabel,
|
|
162
|
+
cancelLabel,
|
|
163
|
+
pending = false,
|
|
164
|
+
disabled = false,
|
|
165
|
+
tone = "default",
|
|
166
|
+
onConfirm,
|
|
167
|
+
}: ActionsProps) {
|
|
168
|
+
const close = useContext(CloseContext)
|
|
169
|
+
return (
|
|
170
|
+
<>
|
|
171
|
+
<Button
|
|
172
|
+
type={onConfirm ? "button" : "submit"}
|
|
173
|
+
variant={
|
|
174
|
+
tone === "destructive"
|
|
175
|
+
? "ghost"
|
|
176
|
+
: "default"
|
|
177
|
+
}
|
|
178
|
+
className={
|
|
179
|
+
tone === "destructive"
|
|
180
|
+
? "bg-danger/10 text-danger"
|
|
181
|
+
: undefined
|
|
182
|
+
}
|
|
183
|
+
isPending={pending}
|
|
184
|
+
disabled={disabled}
|
|
185
|
+
onClick={onConfirm}
|
|
186
|
+
>
|
|
187
|
+
{submitLabel}
|
|
188
|
+
</Button>
|
|
189
|
+
<Button
|
|
190
|
+
type="button"
|
|
191
|
+
variant="secondary"
|
|
192
|
+
onClick={close}
|
|
193
|
+
>
|
|
194
|
+
{cancelLabel}
|
|
195
|
+
</Button>
|
|
196
|
+
</>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
Dialog.Actions = Actions
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { confirmDialog, toast } from "@passui/react"
|
|
2
|
+
import { Button } from "@passui/react/button"
|
|
3
|
+
|
|
4
|
+
export function DialogConfirm() {
|
|
5
|
+
return (
|
|
6
|
+
<Button
|
|
7
|
+
variant="destructive"
|
|
8
|
+
onClick={async () => {
|
|
9
|
+
// resolves true when confirmed; needs one <DialogHost />
|
|
10
|
+
const confirmed = await confirmDialog({
|
|
11
|
+
title: "Delete this app?",
|
|
12
|
+
message:
|
|
13
|
+
"People signed in with it will be signed out.",
|
|
14
|
+
confirmLabel: "Delete",
|
|
15
|
+
cancelLabel: "Cancel",
|
|
16
|
+
destructive: true,
|
|
17
|
+
})
|
|
18
|
+
if (confirmed) toast.success("App deleted")
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
Delete app
|
|
22
|
+
</Button>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { toast } from "@passui/react"
|
|
2
|
+
import { Button } from "@passui/react/button"
|
|
3
|
+
import { Dialog } from "@passui/react/dialog"
|
|
4
|
+
import { TextField } from "@passui/react/text-field"
|
|
5
|
+
import { useState } from "react"
|
|
6
|
+
|
|
7
|
+
export function DialogForm() {
|
|
8
|
+
const [open, setOpen] = useState(false)
|
|
9
|
+
const [name, setName] = useState("Pass console")
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<>
|
|
13
|
+
<Button
|
|
14
|
+
variant="secondary"
|
|
15
|
+
onClick={() => setOpen(true)}
|
|
16
|
+
>
|
|
17
|
+
Rename project
|
|
18
|
+
</Button>
|
|
19
|
+
<Dialog
|
|
20
|
+
open={open}
|
|
21
|
+
onOpenChange={setOpen}
|
|
22
|
+
title="Rename project"
|
|
23
|
+
onSubmit={(event) => {
|
|
24
|
+
event.preventDefault()
|
|
25
|
+
setOpen(false)
|
|
26
|
+
toast.success(`Renamed to ${name}`)
|
|
27
|
+
}}
|
|
28
|
+
footer={
|
|
29
|
+
<Dialog.Actions
|
|
30
|
+
submitLabel="Rename"
|
|
31
|
+
cancelLabel="Cancel"
|
|
32
|
+
disabled={!name.trim()}
|
|
33
|
+
/>
|
|
34
|
+
}
|
|
35
|
+
>
|
|
36
|
+
<TextField
|
|
37
|
+
label="Name"
|
|
38
|
+
value={name}
|
|
39
|
+
onChange={(event) =>
|
|
40
|
+
setName(event.target.value)
|
|
41
|
+
}
|
|
42
|
+
/>
|
|
43
|
+
</Dialog>
|
|
44
|
+
</>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button"
|
|
2
|
+
import { Dialog } from "@passui/react/dialog"
|
|
3
|
+
import { TextField } from "@passui/react/text-field"
|
|
4
|
+
import { useState } from "react"
|
|
5
|
+
|
|
6
|
+
export function DialogInline() {
|
|
7
|
+
const [open, setOpen] = useState(false)
|
|
8
|
+
const [email, setEmail] = useState("")
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div className="flex w-full max-w-sm flex-col gap-2 rounded-4xl bg-elevated p-2 ring-1 ring-separator/60">
|
|
12
|
+
<Button
|
|
13
|
+
variant="ghost"
|
|
14
|
+
className="self-start"
|
|
15
|
+
onClick={() => setOpen(!open)}
|
|
16
|
+
>
|
|
17
|
+
{open ? "Cancel" : "Add a recovery email"}
|
|
18
|
+
</Button>
|
|
19
|
+
<Dialog
|
|
20
|
+
open={open}
|
|
21
|
+
onOpenChange={setOpen}
|
|
22
|
+
presentation="inline"
|
|
23
|
+
title="Recovery email"
|
|
24
|
+
description="We only use it if you lose access."
|
|
25
|
+
onSubmit={(event) => {
|
|
26
|
+
event.preventDefault()
|
|
27
|
+
setOpen(false)
|
|
28
|
+
}}
|
|
29
|
+
footer={
|
|
30
|
+
<Dialog.Actions
|
|
31
|
+
submitLabel="Add"
|
|
32
|
+
cancelLabel="Cancel"
|
|
33
|
+
disabled={!email}
|
|
34
|
+
/>
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
<TextField
|
|
38
|
+
label="Email"
|
|
39
|
+
type="email"
|
|
40
|
+
value={email}
|
|
41
|
+
onChange={(event) =>
|
|
42
|
+
setEmail(event.target.value)
|
|
43
|
+
}
|
|
44
|
+
/>
|
|
45
|
+
</Dialog>
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { LabeledContent, Section, toast } from "@passui/react"
|
|
2
|
+
import { Button } from "@passui/react/button"
|
|
3
|
+
import { Dialog } from "@passui/react/dialog"
|
|
4
|
+
import { useState } from "react"
|
|
5
|
+
|
|
6
|
+
export function DialogShowcase() {
|
|
7
|
+
const [open, setOpen] = useState(false)
|
|
8
|
+
const [pending, setPending] = useState(false)
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div className="w-full max-w-sm">
|
|
12
|
+
<Section title="Devices">
|
|
13
|
+
<LabeledContent
|
|
14
|
+
label="iPad mini"
|
|
15
|
+
description="Last used 3 weeks ago"
|
|
16
|
+
>
|
|
17
|
+
<Button
|
|
18
|
+
variant="ghost"
|
|
19
|
+
size="sm"
|
|
20
|
+
className="text-danger"
|
|
21
|
+
onClick={() => setOpen(true)}
|
|
22
|
+
>
|
|
23
|
+
Sign out
|
|
24
|
+
</Button>
|
|
25
|
+
</LabeledContent>
|
|
26
|
+
</Section>
|
|
27
|
+
<Dialog
|
|
28
|
+
open={open}
|
|
29
|
+
onOpenChange={setOpen}
|
|
30
|
+
title="Sign out of iPad mini?"
|
|
31
|
+
description="It will need your password or a passkey to sign back in."
|
|
32
|
+
footer={
|
|
33
|
+
<Dialog.Actions
|
|
34
|
+
submitLabel="Sign out"
|
|
35
|
+
cancelLabel="Cancel"
|
|
36
|
+
tone="destructive"
|
|
37
|
+
pending={pending}
|
|
38
|
+
onConfirm={() => {
|
|
39
|
+
setPending(true)
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
setPending(false)
|
|
42
|
+
setOpen(false)
|
|
43
|
+
toast.success(
|
|
44
|
+
"Signed out of iPad mini"
|
|
45
|
+
)
|
|
46
|
+
}, 900)
|
|
47
|
+
}}
|
|
48
|
+
/>
|
|
49
|
+
}
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Button } from "@passui/react/button"
|
|
2
|
+
import { Dialog } from "@passui/react/dialog"
|
|
3
|
+
import { useState } from "react"
|
|
4
|
+
|
|
5
|
+
export function DialogUsage() {
|
|
6
|
+
const [open, setOpen] = useState(false)
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<Button
|
|
11
|
+
variant="secondary"
|
|
12
|
+
onClick={() => setOpen(true)}
|
|
13
|
+
>
|
|
14
|
+
Sign out
|
|
15
|
+
</Button>
|
|
16
|
+
<Dialog
|
|
17
|
+
open={open}
|
|
18
|
+
onOpenChange={setOpen}
|
|
19
|
+
title="Sign out of Pass?"
|
|
20
|
+
description="You can sign back in at any time."
|
|
21
|
+
footer={
|
|
22
|
+
<Dialog.Actions
|
|
23
|
+
submitLabel="Sign out"
|
|
24
|
+
cancelLabel="Cancel"
|
|
25
|
+
onConfirm={() => setOpen(false)}
|
|
26
|
+
/>
|
|
27
|
+
}
|
|
28
|
+
/>
|
|
29
|
+
</>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dialog"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LabeledContent, Section } from "@passui/react"
|
|
2
|
+
import { Toggle } from "@passui/react/toggle"
|
|
3
|
+
import { useState } from "react"
|
|
4
|
+
|
|
5
|
+
export function LabeledContentDescriptions() {
|
|
6
|
+
const [alerts, setAlerts] = useState(true)
|
|
7
|
+
const [digest, setDigest] = useState(false)
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="w-full max-w-sm">
|
|
11
|
+
<Section title="Email">
|
|
12
|
+
<LabeledContent
|
|
13
|
+
label="Sign-in alerts"
|
|
14
|
+
description="When a new device signs in to your account."
|
|
15
|
+
>
|
|
16
|
+
<Toggle
|
|
17
|
+
label="Sign-in alerts"
|
|
18
|
+
labelHidden
|
|
19
|
+
checked={alerts}
|
|
20
|
+
onChange={setAlerts}
|
|
21
|
+
/>
|
|
22
|
+
</LabeledContent>
|
|
23
|
+
<LabeledContent
|
|
24
|
+
label="Weekly digest"
|
|
25
|
+
description="A summary of activity every Monday."
|
|
26
|
+
>
|
|
27
|
+
<Toggle
|
|
28
|
+
label="Weekly digest"
|
|
29
|
+
labelHidden
|
|
30
|
+
checked={digest}
|
|
31
|
+
onChange={setDigest}
|
|
32
|
+
/>
|
|
33
|
+
</LabeledContent>
|
|
34
|
+
</Section>
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LabeledContent,
|
|
3
|
+
Section,
|
|
4
|
+
SegmentedControl,
|
|
5
|
+
} from "@passui/react"
|
|
6
|
+
import { TextField } from "@passui/react/text-field"
|
|
7
|
+
import { useState } from "react"
|
|
8
|
+
|
|
9
|
+
export function LabeledContentShowcase() {
|
|
10
|
+
const [density, setDensity] = useState("comfortable")
|
|
11
|
+
const [signature, setSignature] = useState(
|
|
12
|
+
"Sent from Passui"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className="w-full max-w-md">
|
|
17
|
+
<Section title="Mail">
|
|
18
|
+
<LabeledContent
|
|
19
|
+
label="Density"
|
|
20
|
+
description="How much fits on screen."
|
|
21
|
+
wide
|
|
22
|
+
>
|
|
23
|
+
<SegmentedControl
|
|
24
|
+
label="Density"
|
|
25
|
+
value={density}
|
|
26
|
+
onChange={setDensity}
|
|
27
|
+
options={[
|
|
28
|
+
{
|
|
29
|
+
value: "compact",
|
|
30
|
+
label: "Compact",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: "comfortable",
|
|
34
|
+
label: "Comfortable",
|
|
35
|
+
},
|
|
36
|
+
]}
|
|
37
|
+
/>
|
|
38
|
+
</LabeledContent>
|
|
39
|
+
<LabeledContent label="Signature" stacked>
|
|
40
|
+
<TextField
|
|
41
|
+
label="Signature"
|
|
42
|
+
value={signature}
|
|
43
|
+
onChange={(event) =>
|
|
44
|
+
setSignature(event.target.value)
|
|
45
|
+
}
|
|
46
|
+
/>
|
|
47
|
+
</LabeledContent>
|
|
48
|
+
<LabeledContent label="Account">
|
|
49
|
+
aiko@example.com
|
|
50
|
+
</LabeledContent>
|
|
51
|
+
</Section>
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { LabeledContent } from "@passui/react"
|
|
2
|
+
import { Toggle } from "@passui/react/toggle"
|
|
3
|
+
import { useState } from "react"
|
|
4
|
+
|
|
5
|
+
export function LabeledContentUsage() {
|
|
6
|
+
const [previews, setPreviews] = useState(true)
|
|
7
|
+
return (
|
|
8
|
+
<div className="w-full max-w-sm rounded-3xl border border-separator/60 bg-elevated">
|
|
9
|
+
<LabeledContent
|
|
10
|
+
label="Show previews"
|
|
11
|
+
description="Shows the first lines of each note."
|
|
12
|
+
>
|
|
13
|
+
<Toggle
|
|
14
|
+
label="Show previews"
|
|
15
|
+
labelHidden
|
|
16
|
+
checked={previews}
|
|
17
|
+
onChange={setPreviews}
|
|
18
|
+
/>
|
|
19
|
+
</LabeledContent>
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Chip, LabeledContent, Section } from "@passui/react"
|
|
2
|
+
|
|
3
|
+
export function LabeledContentValues() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="w-full max-w-sm">
|
|
6
|
+
<Section
|
|
7
|
+
title="Account"
|
|
8
|
+
footer="Contact support to change your account ID."
|
|
9
|
+
>
|
|
10
|
+
<LabeledContent label="Account ID">
|
|
11
|
+
<span className="font-mono text-footnote text-label-secondary">
|
|
12
|
+
pass_7f3a9c
|
|
13
|
+
</span>
|
|
14
|
+
</LabeledContent>
|
|
15
|
+
<LabeledContent label="Plan">
|
|
16
|
+
<Chip tone="accent">Family</Chip>
|
|
17
|
+
</LabeledContent>
|
|
18
|
+
<LabeledContent label="Member since">
|
|
19
|
+
<span className="text-subheadline text-label-secondary">
|
|
20
|
+
March 2024
|
|
21
|
+
</span>
|
|
22
|
+
</LabeledContent>
|
|
23
|
+
</Section>
|
|
24
|
+
</div>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LabeledContent,
|
|
3
|
+
Section,
|
|
4
|
+
SegmentedControl,
|
|
5
|
+
} from "@passui/react"
|
|
6
|
+
import { TextField } from "@passui/react/text-field"
|
|
7
|
+
import { useState } from "react"
|
|
8
|
+
|
|
9
|
+
export function LabeledContentWide() {
|
|
10
|
+
const [theme, setTheme] = useState("system")
|
|
11
|
+
const [nickname, setNickname] = useState("Aiko")
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className="w-full max-w-md">
|
|
15
|
+
<Section title="Profile">
|
|
16
|
+
<LabeledContent label="Appearance" wide>
|
|
17
|
+
<SegmentedControl
|
|
18
|
+
label="Appearance"
|
|
19
|
+
value={theme}
|
|
20
|
+
onChange={setTheme}
|
|
21
|
+
options={[
|
|
22
|
+
{
|
|
23
|
+
value: "system",
|
|
24
|
+
label: "System",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
value: "light",
|
|
28
|
+
label: "Light",
|
|
29
|
+
},
|
|
30
|
+
{ value: "dark", label: "Dark" },
|
|
31
|
+
]}
|
|
32
|
+
/>
|
|
33
|
+
</LabeledContent>
|
|
34
|
+
<LabeledContent label="Nickname" stacked>
|
|
35
|
+
<TextField
|
|
36
|
+
label="Nickname"
|
|
37
|
+
value={nickname}
|
|
38
|
+
onChange={(event) =>
|
|
39
|
+
setNickname(event.target.value)
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
</LabeledContent>
|
|
43
|
+
</Section>
|
|
44
|
+
</div>
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { LabeledContentValues } from "./examples/labeled-content-values"
|
|
2
|
+
import { LabeledContentWide } from "./examples/labeled-content-wide"
|
|
3
|
+
import { LabeledContentDescriptions } from "./examples/labeled-content-descriptions"
|
|
4
|
+
import { defineDocs } from "../../docs/types"
|
|
5
|
+
import { Toggle } from "../toggle/toggle"
|
|
6
|
+
import { LabeledContentShowcase } from "./examples/labeled-content-showcase"
|
|
7
|
+
import { LabeledContentUsage } from "./examples/labeled-content-usage"
|
|
8
|
+
import { LabeledContent } from "./labeled-content"
|
|
9
|
+
|
|
10
|
+
type DemoProps = {
|
|
11
|
+
label: string
|
|
12
|
+
description?: string
|
|
13
|
+
stacked?: boolean
|
|
14
|
+
wide?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const labeledContentDocs = defineDocs<DemoProps>()({
|
|
18
|
+
slug: "labeled-content",
|
|
19
|
+
name: "LabeledContent",
|
|
20
|
+
importPath: "@passui/react",
|
|
21
|
+
controls: {
|
|
22
|
+
label: {
|
|
23
|
+
kind: "text",
|
|
24
|
+
default: "Show previews",
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
description: {
|
|
28
|
+
kind: "text",
|
|
29
|
+
default: "Shows the first lines of each note.",
|
|
30
|
+
},
|
|
31
|
+
stacked: { kind: "boolean", default: false },
|
|
32
|
+
wide: { kind: "boolean", default: false },
|
|
33
|
+
},
|
|
34
|
+
render: (values) => (
|
|
35
|
+
<div className="w-full max-w-sm rounded-3xl border border-separator/60 bg-elevated">
|
|
36
|
+
<LabeledContent {...values}>
|
|
37
|
+
<Toggle
|
|
38
|
+
label={values.label}
|
|
39
|
+
labelHidden
|
|
40
|
+
checked
|
|
41
|
+
onChange={() => {}}
|
|
42
|
+
/>
|
|
43
|
+
</LabeledContent>
|
|
44
|
+
</div>
|
|
45
|
+
),
|
|
46
|
+
childrenSnippet: () => ({
|
|
47
|
+
imports: [
|
|
48
|
+
'import { useState } from "react"',
|
|
49
|
+
'import { Toggle } from "@passui/react/toggle"',
|
|
50
|
+
],
|
|
51
|
+
setup: ["const [on, setOn] = useState(true)"],
|
|
52
|
+
children:
|
|
53
|
+
'<Toggle label="Show previews" labelHidden checked={on} onChange={setOn} />',
|
|
54
|
+
}),
|
|
55
|
+
usage: LabeledContentUsage,
|
|
56
|
+
showcase: LabeledContentShowcase,
|
|
57
|
+
examples: [
|
|
58
|
+
{
|
|
59
|
+
id: "descriptions",
|
|
60
|
+
component: LabeledContentDescriptions,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: "wide",
|
|
64
|
+
component: LabeledContentWide,
|
|
65
|
+
playground: { wide: true },
|
|
66
|
+
},
|
|
67
|
+
{ id: "values", component: LabeledContentValues },
|
|
68
|
+
],
|
|
69
|
+
})
|