@fabricator-ui/react-native 0.0.0-stage → 0.10.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 +8 -2
- package/dist/LICENSE.md +25 -0
- package/dist/NOTICE.md +24 -0
- package/dist/lib/data-variants.ts +23 -0
- package/dist/lib/density-scale.ts +208 -0
- package/dist/lib/fabricator/css-object.ts +2 -0
- package/dist/lib/fabricator/density-scale.ts +210 -0
- package/dist/lib/fabricator/density-variables.ts +37 -0
- package/dist/lib/fabricator/motion-speeds.ts +566 -0
- package/dist/lib/fabricator/radius.ts +240 -0
- package/dist/lib/feedback.ts +124 -0
- package/dist/lib/field-frame.ts +53 -0
- package/dist/lib/field-model.ts +112 -0
- package/dist/lib/fluid-hover-model.ts +142 -0
- package/dist/lib/fluid-hover.tsx +788 -0
- package/dist/lib/icon-stroke.ts +38 -0
- package/dist/lib/motion-tokens.ts +97 -0
- package/dist/lib/motion.ts +292 -0
- package/dist/lib/overlay-model.ts +205 -0
- package/dist/lib/press-wash.tsx +73 -0
- package/dist/lib/render.tsx +53 -0
- package/dist/lib/select-model.ts +87 -0
- package/dist/lib/sheet-model.ts +101 -0
- package/dist/lib/sheet-surface.tsx +429 -0
- package/dist/lib/sound-recipes.ts +449 -0
- package/dist/lib/spring-model.ts +214 -0
- package/dist/lib/surface-color.tsx +27 -0
- package/dist/lib/text-children.ts +43 -0
- package/dist/styles.css +610 -0
- package/dist/ui/badge.tsx +108 -0
- package/dist/ui/button.tsx +285 -0
- package/dist/ui/card.tsx +365 -0
- package/dist/ui/checkbox.tsx +230 -0
- package/dist/ui/collapsible.tsx +194 -0
- package/dist/ui/density.tsx +79 -0
- package/dist/ui/dialog.tsx +232 -0
- package/dist/ui/dropdown-menu.tsx +687 -0
- package/dist/ui/fabricator-root.tsx +68 -0
- package/dist/ui/input.tsx +63 -0
- package/dist/ui/label.tsx +22 -0
- package/dist/ui/select.tsx +616 -0
- package/dist/ui/switch.tsx +177 -0
- package/dist/ui/tabs.tsx +272 -0
- package/dist/ui/text.tsx +125 -0
- package/dist/ui/textarea.tsx +65 -0
- package/package.json +54 -4
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import * as CollapsiblePrimitive from "@rn-primitives/collapsible"
|
|
3
|
+
import { useControllableState } from "@rn-primitives/hooks"
|
|
4
|
+
import { cn } from "cn"
|
|
5
|
+
import { View } from "react-native"
|
|
6
|
+
import Animated, {
|
|
7
|
+
runOnJS,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
useSharedValue,
|
|
10
|
+
withTiming,
|
|
11
|
+
} from "react-native-reanimated"
|
|
12
|
+
|
|
13
|
+
import { useFeedback } from "../lib/feedback"
|
|
14
|
+
import { useMotion } from "../lib/motion"
|
|
15
|
+
import { resolveRender, type RenderProps } from "../lib/render"
|
|
16
|
+
import { renderTextChildren } from "./text"
|
|
17
|
+
|
|
18
|
+
const CollapsibleContext = React.createContext(false)
|
|
19
|
+
|
|
20
|
+
function Collapsible({
|
|
21
|
+
open,
|
|
22
|
+
defaultOpen = false,
|
|
23
|
+
onOpenChange,
|
|
24
|
+
children,
|
|
25
|
+
...props
|
|
26
|
+
}: CollapsiblePrimitive.RootProps) {
|
|
27
|
+
const [isOpen = false, setIsOpen] = useControllableState({
|
|
28
|
+
prop: open,
|
|
29
|
+
defaultProp: defaultOpen,
|
|
30
|
+
onChange: onOpenChange,
|
|
31
|
+
})
|
|
32
|
+
return (
|
|
33
|
+
<CollapsibleContext value={isOpen}>
|
|
34
|
+
<CollapsiblePrimitive.Root
|
|
35
|
+
data-slot="collapsible"
|
|
36
|
+
data-state={isOpen ? "open" : "closed"}
|
|
37
|
+
open={isOpen}
|
|
38
|
+
onOpenChange={setIsOpen}
|
|
39
|
+
{...props}
|
|
40
|
+
>
|
|
41
|
+
{renderTextChildren(children)}
|
|
42
|
+
</CollapsiblePrimitive.Root>
|
|
43
|
+
</CollapsibleContext>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function CollapsibleTrigger({
|
|
48
|
+
className,
|
|
49
|
+
render,
|
|
50
|
+
asChild,
|
|
51
|
+
children,
|
|
52
|
+
onPress,
|
|
53
|
+
...props
|
|
54
|
+
}: Omit<CollapsiblePrimitive.TriggerProps, "children"> &
|
|
55
|
+
RenderProps & { children?: React.ReactNode }) {
|
|
56
|
+
const isOpen = React.use(CollapsibleContext)
|
|
57
|
+
const feedback = useFeedback()
|
|
58
|
+
const resolved = resolveRender({ render, asChild, children })
|
|
59
|
+
return (
|
|
60
|
+
<CollapsiblePrimitive.Trigger
|
|
61
|
+
data-slot="collapsible-trigger"
|
|
62
|
+
data-state={isOpen ? "open" : "closed"}
|
|
63
|
+
hitSlop={12}
|
|
64
|
+
className={cn("active:opacity-70 disabled:opacity-50", className)}
|
|
65
|
+
onPress={(event) => {
|
|
66
|
+
// Composed with a control, that control sounds: Button can't give up its
|
|
67
|
+
// own, and two at once would be worse than the wrong one.
|
|
68
|
+
if (!resolved.asChild) feedback(isOpen ? "collapse" : "expand")
|
|
69
|
+
onPress?.(event)
|
|
70
|
+
}}
|
|
71
|
+
{...props}
|
|
72
|
+
asChild={resolved.asChild}
|
|
73
|
+
>
|
|
74
|
+
{resolved.asChild
|
|
75
|
+
? resolved.children
|
|
76
|
+
: renderTextChildren(resolved.children)}
|
|
77
|
+
</CollapsiblePrimitive.Trigger>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A panel that opens and closes on its measured height, on the disclosure
|
|
83
|
+
* timing. Settled open, the height is its content's, so something growing inside
|
|
84
|
+
* needs no measure. Reduced motion drops the height's travel and keeps a fade.
|
|
85
|
+
* Its content unmounts once closed, as Base UI's panel does, unless `keepMounted`.
|
|
86
|
+
* Accordion's panels are this one too, on the bounce role: the height springs
|
|
87
|
+
* past its content and back both ways, and the content fades with it.
|
|
88
|
+
*/
|
|
89
|
+
function DisclosurePanel({
|
|
90
|
+
isOpen,
|
|
91
|
+
keepMounted = false,
|
|
92
|
+
motionRole = "disclosure",
|
|
93
|
+
className,
|
|
94
|
+
children,
|
|
95
|
+
style,
|
|
96
|
+
...props
|
|
97
|
+
}: Omit<
|
|
98
|
+
React.ComponentProps<typeof Animated.View>,
|
|
99
|
+
"children" | "className"
|
|
100
|
+
> & {
|
|
101
|
+
isOpen: boolean
|
|
102
|
+
keepMounted?: boolean
|
|
103
|
+
motionRole?: "disclosure" | "bounce"
|
|
104
|
+
className?: string
|
|
105
|
+
children?: React.ReactNode
|
|
106
|
+
}) {
|
|
107
|
+
const motion = useMotion(motionRole)
|
|
108
|
+
const isReduced = motion.isReduced
|
|
109
|
+
const isSpring = motionRole === "bounce"
|
|
110
|
+
const [isMounted, setIsMounted] = React.useState(isOpen)
|
|
111
|
+
if (isOpen && !isMounted) setIsMounted(true)
|
|
112
|
+
|
|
113
|
+
const [hasHeight, setHasHeight] = React.useState(false)
|
|
114
|
+
const measured = useSharedValue(0)
|
|
115
|
+
const progress = useSharedValue(isOpen ? 1 : 0)
|
|
116
|
+
React.useEffect(() => {
|
|
117
|
+
// Opening waits for the content's height. The curve moves fastest at its
|
|
118
|
+
// start, so frames lost to the measure would show as a jump.
|
|
119
|
+
if (isOpen && !hasHeight) return
|
|
120
|
+
progress.value = withTiming(
|
|
121
|
+
isOpen ? 1 : 0,
|
|
122
|
+
{
|
|
123
|
+
duration: isOpen ? motion.enterMs : motion.exitMs,
|
|
124
|
+
easing: isSpring
|
|
125
|
+
? motion.bounceEasing
|
|
126
|
+
: isOpen
|
|
127
|
+
? motion.enterEasing
|
|
128
|
+
: motion.exitEasing,
|
|
129
|
+
},
|
|
130
|
+
(finished) => {
|
|
131
|
+
if (!finished || isOpen || keepMounted) return
|
|
132
|
+
runOnJS(setIsMounted)(false)
|
|
133
|
+
runOnJS(setHasHeight)(false)
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
}, [hasHeight, isOpen, isSpring, keepMounted, motion, progress])
|
|
137
|
+
|
|
138
|
+
const heightStyle = useAnimatedStyle(() => {
|
|
139
|
+
if (isReduced) {
|
|
140
|
+
return {
|
|
141
|
+
opacity: progress.value,
|
|
142
|
+
height: progress.value > 0 ? "auto" : 0,
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// A spring passes 1 on its way and ends on it exactly: only then is it open.
|
|
146
|
+
if (progress.value === 1) return { height: "auto", opacity: 1 }
|
|
147
|
+
const height = Math.max(0, measured.value * progress.value)
|
|
148
|
+
if (!isSpring) return { height }
|
|
149
|
+
return { height, opacity: Math.min(1, Math.max(0, progress.value)) }
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<Animated.View
|
|
154
|
+
data-state={isOpen ? "open" : "closed"}
|
|
155
|
+
role="region"
|
|
156
|
+
aria-hidden={!isOpen}
|
|
157
|
+
accessibilityElementsHidden={!isOpen}
|
|
158
|
+
importantForAccessibility={isOpen ? "auto" : "no-hide-descendants"}
|
|
159
|
+
pointerEvents={isOpen ? "auto" : "none"}
|
|
160
|
+
className={"fab:overflow-hidden"}
|
|
161
|
+
style={[heightStyle, style]}
|
|
162
|
+
{...props}
|
|
163
|
+
>
|
|
164
|
+
{isMounted || keepMounted ? (
|
|
165
|
+
<View
|
|
166
|
+
className={className}
|
|
167
|
+
onLayout={(event) => {
|
|
168
|
+
measured.value = event.nativeEvent.layout.height
|
|
169
|
+
setHasHeight(true)
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
{renderTextChildren(children)}
|
|
173
|
+
</View>
|
|
174
|
+
) : null}
|
|
175
|
+
</Animated.View>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function CollapsibleContent({
|
|
180
|
+
className,
|
|
181
|
+
...props
|
|
182
|
+
}: Omit<React.ComponentProps<typeof DisclosurePanel>, "isOpen">) {
|
|
183
|
+
const isOpen = React.use(CollapsibleContext)
|
|
184
|
+
return (
|
|
185
|
+
<DisclosurePanel
|
|
186
|
+
data-slot="collapsible-content"
|
|
187
|
+
isOpen={isOpen}
|
|
188
|
+
className={cn("w-full", className)}
|
|
189
|
+
{...props}
|
|
190
|
+
/>
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export { Collapsible, CollapsibleContent, CollapsibleTrigger, DisclosurePanel }
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { ScopedVariables, useCSSVariable } from "uniwind"
|
|
3
|
+
|
|
4
|
+
import { getDensityVariables } from "../lib/fabricator/density-variables"
|
|
5
|
+
import {
|
|
6
|
+
getDensityName,
|
|
7
|
+
getDensityTokens,
|
|
8
|
+
getSizeDensity,
|
|
9
|
+
getXsSize,
|
|
10
|
+
type SizeDensity,
|
|
11
|
+
} from "../lib/density-scale"
|
|
12
|
+
import { parseNumber } from "../lib/motion-tokens"
|
|
13
|
+
|
|
14
|
+
type Density = SizeDensity
|
|
15
|
+
|
|
16
|
+
const DensityContext = React.createContext<Density | undefined>(undefined)
|
|
17
|
+
|
|
18
|
+
/** A density's tokens for everything inside it, without changing the context. */
|
|
19
|
+
function DensityScope({
|
|
20
|
+
density,
|
|
21
|
+
children,
|
|
22
|
+
}: {
|
|
23
|
+
density?: Density
|
|
24
|
+
children?: React.ReactNode
|
|
25
|
+
}) {
|
|
26
|
+
const variables = React.useMemo(
|
|
27
|
+
() =>
|
|
28
|
+
density ? getDensityVariables(getDensityTokens(density)) : undefined,
|
|
29
|
+
[density]
|
|
30
|
+
)
|
|
31
|
+
if (!variables) return children
|
|
32
|
+
return <ScopedVariables variables={variables}>{children}</ScopedVariables>
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Sets the density for everything inside it, including the menus, popovers and
|
|
37
|
+
* sheets it opens: those leave the React tree, so they read `useDensity()` and
|
|
38
|
+
* set their own scope.
|
|
39
|
+
*/
|
|
40
|
+
function DensityProvider({
|
|
41
|
+
density,
|
|
42
|
+
children,
|
|
43
|
+
}: {
|
|
44
|
+
density: Density
|
|
45
|
+
children?: React.ReactNode
|
|
46
|
+
}) {
|
|
47
|
+
return (
|
|
48
|
+
<DensityContext value={density}>
|
|
49
|
+
<DensityScope density={density}>{children}</DensityScope>
|
|
50
|
+
</DensityContext>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The nearest DensityProvider's density; undefined outside one. */
|
|
55
|
+
function useDensity() {
|
|
56
|
+
return React.use(DensityContext)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* What a control's `size` makes of the density around it: the density to pin it to,
|
|
61
|
+
* if any, and the height of a control there. Call it outside the control's own scope.
|
|
62
|
+
*/
|
|
63
|
+
function useControlSize(size?: string | null) {
|
|
64
|
+
const around = getDensityName(parseNumber(useCSSVariable("--density-36"), 36))
|
|
65
|
+
const density = getSizeDensity(size, around)
|
|
66
|
+
return {
|
|
67
|
+
density,
|
|
68
|
+
height: getDensityTokens(density ?? around).space[36],
|
|
69
|
+
xs: getXsSize(around),
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
DensityProvider,
|
|
75
|
+
DensityScope,
|
|
76
|
+
useControlSize,
|
|
77
|
+
useDensity,
|
|
78
|
+
type Density,
|
|
79
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { XIcon } from "@fabricator-ui/icons-react-native"
|
|
3
|
+
import * as DialogPrimitive from "@rn-primitives/dialog"
|
|
4
|
+
import { cn } from "cn"
|
|
5
|
+
import { KeyboardAvoidingView, Platform, View } from "react-native"
|
|
6
|
+
import Animated from "react-native-reanimated"
|
|
7
|
+
|
|
8
|
+
import { useMountFeedback } from "../lib/feedback"
|
|
9
|
+
import { useSurfaceAnimation } from "../lib/motion"
|
|
10
|
+
import { NO_LAYOUT } from "../lib/overlay-model"
|
|
11
|
+
import { resolveRender, type RenderProps } from "../lib/render"
|
|
12
|
+
import { Button } from "./button"
|
|
13
|
+
import { DensityScope, useDensity } from "./density"
|
|
14
|
+
import { renderTextChildren, Text, TextStyle } from "./text"
|
|
15
|
+
|
|
16
|
+
function Dialog(props: DialogPrimitive.RootProps) {
|
|
17
|
+
return (
|
|
18
|
+
<DialogPrimitive.Root data-slot="dialog" style={NO_LAYOUT} {...props} />
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DialogTrigger({
|
|
23
|
+
render,
|
|
24
|
+
asChild,
|
|
25
|
+
children,
|
|
26
|
+
...props
|
|
27
|
+
}: Omit<DialogPrimitive.TriggerProps, "children"> &
|
|
28
|
+
RenderProps & { children?: React.ReactNode }) {
|
|
29
|
+
const resolved = resolveRender({ render, asChild, children })
|
|
30
|
+
return (
|
|
31
|
+
<DialogPrimitive.Trigger
|
|
32
|
+
data-slot="dialog-trigger"
|
|
33
|
+
{...props}
|
|
34
|
+
asChild={resolved.asChild}
|
|
35
|
+
>
|
|
36
|
+
{resolved.asChild
|
|
37
|
+
? resolved.children
|
|
38
|
+
: renderTextChildren(resolved.children)}
|
|
39
|
+
</DialogPrimitive.Trigger>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function DialogPortal(props: DialogPrimitive.PortalProps) {
|
|
44
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function DialogClose({
|
|
48
|
+
render,
|
|
49
|
+
asChild,
|
|
50
|
+
children,
|
|
51
|
+
...props
|
|
52
|
+
}: Omit<DialogPrimitive.CloseProps, "children"> &
|
|
53
|
+
RenderProps & { children?: React.ReactNode }) {
|
|
54
|
+
const resolved = resolveRender({ render, asChild, children })
|
|
55
|
+
return (
|
|
56
|
+
<DialogPrimitive.Close
|
|
57
|
+
data-slot="dialog-close"
|
|
58
|
+
{...props}
|
|
59
|
+
asChild={resolved.asChild}
|
|
60
|
+
>
|
|
61
|
+
{resolved.asChild
|
|
62
|
+
? resolved.children
|
|
63
|
+
: renderTextChildren(resolved.children)}
|
|
64
|
+
</DialogPrimitive.Close>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function DialogOverlay({
|
|
69
|
+
className,
|
|
70
|
+
...props
|
|
71
|
+
}: React.ComponentProps<typeof Animated.View>) {
|
|
72
|
+
const { entering, exiting } = useSurfaceAnimation("dialog", { scale: 1 })
|
|
73
|
+
return (
|
|
74
|
+
<Animated.View
|
|
75
|
+
data-slot="dialog-overlay"
|
|
76
|
+
pointerEvents="none"
|
|
77
|
+
entering={entering}
|
|
78
|
+
exiting={exiting}
|
|
79
|
+
className={cn("bg-black/40 dark:bg-black/80 absolute inset-0", className)}
|
|
80
|
+
{...props}
|
|
81
|
+
/>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The primitive's portal renders this only while the dialog is open.
|
|
86
|
+
function DialogFeedback() {
|
|
87
|
+
useMountFeedback("dialog")
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function DialogContent({
|
|
92
|
+
className,
|
|
93
|
+
children,
|
|
94
|
+
showCloseButton = true,
|
|
95
|
+
...props
|
|
96
|
+
}: DialogPrimitive.ContentProps & {
|
|
97
|
+
showCloseButton?: boolean
|
|
98
|
+
}) {
|
|
99
|
+
const density = useDensity()
|
|
100
|
+
const { entering, exiting } = useSurfaceAnimation("dialog")
|
|
101
|
+
return (
|
|
102
|
+
<DialogPortal>
|
|
103
|
+
<DensityScope density={density}>
|
|
104
|
+
<DialogFeedback />
|
|
105
|
+
<DialogPrimitive.Overlay
|
|
106
|
+
aria-modal
|
|
107
|
+
className={"fab:absolute fab:inset-0 fab:items-center fab:justify-center"}
|
|
108
|
+
>
|
|
109
|
+
<DialogOverlay />
|
|
110
|
+
<KeyboardAvoidingView
|
|
111
|
+
behavior={Platform.OS === "ios" ? "padding" : undefined}
|
|
112
|
+
className={"fab:w-full fab:items-center"}
|
|
113
|
+
>
|
|
114
|
+
<Animated.View
|
|
115
|
+
entering={entering}
|
|
116
|
+
exiting={exiting}
|
|
117
|
+
className={"fab:w-full fab:items-center"}
|
|
118
|
+
>
|
|
119
|
+
<TextStyle className={"fab:text-popover-foreground fab:text-(length:--density-text-13)"}>
|
|
120
|
+
<DialogPrimitive.Content
|
|
121
|
+
data-slot="dialog-content"
|
|
122
|
+
className={cn("bg-surface-5 shadow-surface-5 max-w-[92%] gap-(--density-16) rounded-(--radius-surface) p-(--density-24) sm:max-w-[400px] corner-curve w-full", className)}
|
|
123
|
+
{...props}
|
|
124
|
+
>
|
|
125
|
+
{renderTextChildren(children)}
|
|
126
|
+
{showCloseButton && (
|
|
127
|
+
<DialogClose
|
|
128
|
+
accessibilityLabel="Close"
|
|
129
|
+
render={
|
|
130
|
+
<Button
|
|
131
|
+
variant="ghost"
|
|
132
|
+
size="icon-sm"
|
|
133
|
+
className={"fab:end-3 fab:top-3 fab:absolute"}
|
|
134
|
+
/>
|
|
135
|
+
}
|
|
136
|
+
>
|
|
137
|
+
<XIcon />
|
|
138
|
+
</DialogClose>
|
|
139
|
+
)}
|
|
140
|
+
</DialogPrimitive.Content>
|
|
141
|
+
</TextStyle>
|
|
142
|
+
</Animated.View>
|
|
143
|
+
</KeyboardAvoidingView>
|
|
144
|
+
</DialogPrimitive.Overlay>
|
|
145
|
+
</DensityScope>
|
|
146
|
+
</DialogPortal>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function DialogHeader({
|
|
151
|
+
className,
|
|
152
|
+
children,
|
|
153
|
+
...props
|
|
154
|
+
}: React.ComponentProps<typeof View>) {
|
|
155
|
+
return (
|
|
156
|
+
<View
|
|
157
|
+
data-slot="dialog-header"
|
|
158
|
+
className={cn("gap-(--density-6) flex-col", className)}
|
|
159
|
+
{...props}
|
|
160
|
+
>
|
|
161
|
+
{renderTextChildren(children)}
|
|
162
|
+
</View>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function DialogFooter({
|
|
167
|
+
className,
|
|
168
|
+
showCloseButton = false,
|
|
169
|
+
children,
|
|
170
|
+
...props
|
|
171
|
+
}: React.ComponentProps<typeof View> & {
|
|
172
|
+
showCloseButton?: boolean
|
|
173
|
+
}) {
|
|
174
|
+
return (
|
|
175
|
+
<View
|
|
176
|
+
data-slot="dialog-footer"
|
|
177
|
+
className={cn("mt-2 gap-(--density-8) sm:flex-row sm:justify-end flex-col-reverse", className)}
|
|
178
|
+
{...props}
|
|
179
|
+
>
|
|
180
|
+
{renderTextChildren(children)}
|
|
181
|
+
{showCloseButton && (
|
|
182
|
+
<DialogClose render={<Button variant="outline" />}>
|
|
183
|
+
<Text>Close</Text>
|
|
184
|
+
</DialogClose>
|
|
185
|
+
)}
|
|
186
|
+
</View>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function DialogTitle({
|
|
191
|
+
className,
|
|
192
|
+
...props
|
|
193
|
+
}: React.ComponentProps<typeof Text>) {
|
|
194
|
+
return (
|
|
195
|
+
<DialogPrimitive.Title asChild>
|
|
196
|
+
<Text
|
|
197
|
+
data-slot="dialog-title"
|
|
198
|
+
role="heading"
|
|
199
|
+
className={cn("text-foreground text-(length:--density-text-16) leading-tight font-bold", className)}
|
|
200
|
+
{...props}
|
|
201
|
+
/>
|
|
202
|
+
</DialogPrimitive.Title>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function DialogDescription({
|
|
207
|
+
className,
|
|
208
|
+
...props
|
|
209
|
+
}: React.ComponentProps<typeof Text>) {
|
|
210
|
+
return (
|
|
211
|
+
<DialogPrimitive.Description asChild>
|
|
212
|
+
<Text
|
|
213
|
+
data-slot="dialog-description"
|
|
214
|
+
className={cn("text-muted-foreground text-(length:--density-text-13)", className)}
|
|
215
|
+
{...props}
|
|
216
|
+
/>
|
|
217
|
+
</DialogPrimitive.Description>
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export {
|
|
222
|
+
Dialog,
|
|
223
|
+
DialogClose,
|
|
224
|
+
DialogContent,
|
|
225
|
+
DialogDescription,
|
|
226
|
+
DialogFooter,
|
|
227
|
+
DialogHeader,
|
|
228
|
+
DialogOverlay,
|
|
229
|
+
DialogPortal,
|
|
230
|
+
DialogTitle,
|
|
231
|
+
DialogTrigger,
|
|
232
|
+
}
|