@coze-arch/cli 0.0.1-alpha.de5a13 → 0.0.1-alpha.deaedf

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.
Files changed (143) hide show
  1. package/README.md +1 -0
  2. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +1 -1
  3. package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
  4. package/lib/__templates__/expo/client/eslint.config.mjs +7 -0
  5. package/lib/__templates__/expo/client/metro.config.js +3 -0
  6. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
  7. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
  8. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
  9. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
  10. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
  11. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
  12. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
  13. package/lib/__templates__/expo/pnpm-lock.yaml +8 -5
  14. package/lib/__templates__/expo/server/package.json +1 -1
  15. package/lib/__templates__/native-static/.coze +11 -0
  16. package/lib/__templates__/native-static/index.html +33 -0
  17. package/lib/__templates__/native-static/styles/main.css +136 -0
  18. package/lib/__templates__/native-static/template.config.js +22 -0
  19. package/lib/__templates__/nextjs/.babelrc +3 -0
  20. package/lib/__templates__/nextjs/README.md +5 -0
  21. package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
  22. package/lib/__templates__/nextjs/next.config.ts +1 -2
  23. package/lib/__templates__/nextjs/package.json +3 -6
  24. package/lib/__templates__/nextjs/pnpm-lock.yaml +1036 -10
  25. package/lib/__templates__/nextjs/scripts/build.sh +4 -1
  26. package/lib/__templates__/nextjs/scripts/dev.sh +8 -2
  27. package/lib/__templates__/nextjs/scripts/start.sh +7 -1
  28. package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
  29. package/lib/__templates__/nextjs/src/app/page.tsx +1 -2
  30. package/lib/__templates__/nextjs/src/server.ts +35 -0
  31. package/lib/__templates__/nextjs/tsconfig.json +1 -1
  32. package/lib/__templates__/nuxt-vue/.coze +12 -0
  33. package/lib/__templates__/nuxt-vue/README.md +73 -0
  34. package/lib/__templates__/nuxt-vue/_gitignore +24 -0
  35. package/lib/__templates__/nuxt-vue/_npmrc +23 -0
  36. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  37. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  38. package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
  39. package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
  40. package/lib/__templates__/nuxt-vue/package.json +35 -0
  41. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  42. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  43. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  44. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  45. package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
  46. package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
  47. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  48. package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
  49. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  50. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  51. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  52. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  53. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  54. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  55. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +107 -37
  56. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -1
  57. package/lib/__templates__/taro/README.md +138 -62
  58. package/lib/__templates__/taro/config/index.ts +105 -41
  59. package/lib/__templates__/taro/config/prod.ts +4 -5
  60. package/lib/__templates__/taro/eslint.config.mjs +82 -4
  61. package/lib/__templates__/taro/package.json +23 -7
  62. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  63. package/lib/__templates__/taro/pnpm-lock.yaml +1198 -214
  64. package/lib/__templates__/taro/server/package.json +3 -1
  65. package/lib/__templates__/taro/src/app.css +140 -47
  66. package/lib/__templates__/taro/src/app.tsx +9 -0
  67. package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
  68. package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
  69. package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
  70. package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
  71. package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
  72. package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
  73. package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
  74. package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
  75. package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
  76. package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
  77. package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
  78. package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
  79. package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
  80. package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
  81. package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
  82. package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
  83. package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
  84. package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
  85. package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
  86. package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
  87. package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
  88. package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
  89. package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
  90. package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
  91. package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
  92. package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
  93. package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
  94. package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
  95. package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
  96. package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
  97. package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
  98. package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
  99. package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
  100. package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
  101. package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
  102. package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
  103. package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
  104. package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
  105. package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
  106. package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
  107. package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
  108. package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
  109. package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
  110. package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
  111. package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
  112. package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
  113. package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
  114. package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
  115. package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
  116. package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
  117. package/lib/__templates__/taro/src/lib/measure.ts +115 -0
  118. package/lib/__templates__/taro/src/lib/platform.ts +12 -0
  119. package/lib/__templates__/taro/src/lib/utils.ts +6 -0
  120. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  121. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  122. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
  123. package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
  124. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  125. package/lib/__templates__/templates.json +43 -0
  126. package/lib/__templates__/vite/README.md +190 -11
  127. package/lib/__templates__/vite/_gitignore +1 -0
  128. package/lib/__templates__/vite/eslint.config.mjs +6 -1
  129. package/lib/__templates__/vite/package.json +14 -5
  130. package/lib/__templates__/vite/pnpm-lock.yaml +768 -24
  131. package/lib/__templates__/vite/scripts/build.sh +4 -1
  132. package/lib/__templates__/vite/scripts/dev.sh +9 -2
  133. package/lib/__templates__/vite/scripts/start.sh +9 -3
  134. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  135. package/lib/__templates__/vite/server/server.ts +65 -0
  136. package/lib/__templates__/vite/server/vite.ts +67 -0
  137. package/lib/__templates__/vite/tsconfig.json +4 -3
  138. package/lib/__templates__/vite/vite.config.ts +5 -0
  139. package/lib/cli.js +124 -103
  140. package/package.json +7 -3
  141. package/lib/__templates__/taro/src/app.ts +0 -14
  142. package/lib/__templates__/taro/src/utils/h5-styles.ts +0 -22
  143. package/lib/__templates__/taro/src/utils/wx-debug.ts +0 -23
@@ -0,0 +1,256 @@
1
+ import * as React from "react"
2
+ import { View } from "@tarojs/components"
3
+ import { X } from "lucide-react-taro"
4
+ import { cn } from "@/lib/utils"
5
+ import { Portal } from "@/components/ui/portal"
6
+ import { useKeyboardOffset } from "@/lib/hooks/use-keyboard-offset"
7
+
8
+ const DialogContext = React.createContext<{
9
+ open?: boolean
10
+ onOpenChange?: (open: boolean) => void
11
+ } | null>(null)
12
+
13
+ const usePresence = (open: boolean | undefined, durationMs: number) => {
14
+ const [present, setPresent] = React.useState(!!open)
15
+ const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)
16
+
17
+ React.useEffect(() => {
18
+ if (open) {
19
+ if (timeoutRef.current) clearTimeout(timeoutRef.current)
20
+ timeoutRef.current = null
21
+ setPresent(true)
22
+ return
23
+ }
24
+
25
+ timeoutRef.current = setTimeout(() => setPresent(false), durationMs)
26
+ return () => {
27
+ if (timeoutRef.current) clearTimeout(timeoutRef.current)
28
+ timeoutRef.current = null
29
+ }
30
+ }, [open, durationMs])
31
+
32
+ return present
33
+ }
34
+
35
+ interface DialogProps {
36
+ children: React.ReactNode
37
+ open?: boolean
38
+ defaultOpen?: boolean
39
+ onOpenChange?: (open: boolean) => void
40
+ modal?: boolean
41
+ }
42
+
43
+ const Dialog = ({ children, open: openProp, defaultOpen, onOpenChange }: DialogProps) => {
44
+ const [openState, setOpenState] = React.useState(defaultOpen || false)
45
+ const open = openProp !== undefined ? openProp : openState
46
+
47
+ const handleOpenChange = (newOpen: boolean) => {
48
+ if (openProp === undefined) {
49
+ setOpenState(newOpen)
50
+ }
51
+ onOpenChange?.(newOpen)
52
+ }
53
+
54
+ return (
55
+ <DialogContext.Provider value={{ open, onOpenChange: handleOpenChange }}>
56
+ {children}
57
+ </DialogContext.Provider>
58
+ )
59
+ }
60
+
61
+ const DialogTrigger = React.forwardRef<
62
+ React.ElementRef<typeof View>,
63
+ React.ComponentPropsWithoutRef<typeof View> & { asChild?: boolean }
64
+ >(({ className, children, asChild, ...props }, ref) => {
65
+ const context = React.useContext(DialogContext)
66
+ return (
67
+ <View
68
+ ref={ref}
69
+ className={cn("w-fit", className)}
70
+ onClick={(e) => {
71
+ e.stopPropagation()
72
+ context?.onOpenChange?.(true)
73
+ }}
74
+ {...props}
75
+ >
76
+ {children}
77
+ </View>
78
+ )
79
+ })
80
+ DialogTrigger.displayName = "DialogTrigger"
81
+
82
+ const DialogPortal = ({ children }: { children: React.ReactNode }) => {
83
+ const context = React.useContext(DialogContext)
84
+ const present = usePresence(context?.open, 200)
85
+ if (!present) return null
86
+
87
+ return <Portal>{children}</Portal>
88
+ }
89
+
90
+ const DialogOverlay = React.forwardRef<
91
+ React.ElementRef<typeof View>,
92
+ React.ComponentPropsWithoutRef<typeof View>
93
+ >(({ className, onClick, ...props }, ref) => {
94
+ const context = React.useContext(DialogContext)
95
+ const state = context?.open ? "open" : "closed"
96
+ return (
97
+ <View
98
+ ref={ref}
99
+ data-state={state}
100
+ className={cn(
101
+ "fixed inset-0 isolate z-50 bg-black bg-opacity-10 transition-opacity duration-100 supports-[backdrop-filter]:backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
102
+ className
103
+ )}
104
+ onClick={(e) => {
105
+ e.stopPropagation()
106
+ onClick?.(e)
107
+ context?.onOpenChange?.(false)
108
+ }}
109
+ {...props}
110
+ />
111
+ )
112
+ })
113
+ DialogOverlay.displayName = "DialogOverlay"
114
+
115
+ interface DialogContentProps extends React.ComponentPropsWithoutRef<typeof View> {
116
+ closeClassName?: string
117
+ }
118
+
119
+ const DialogContent = React.forwardRef<
120
+ React.ElementRef<typeof View>,
121
+ DialogContentProps
122
+ >(({ className, children, style, closeClassName, ...props }, ref) => {
123
+ const context = React.useContext(DialogContext)
124
+ const offset = useKeyboardOffset()
125
+ const state = context?.open ? "open" : "closed"
126
+
127
+ return (
128
+ <DialogPortal>
129
+ <View
130
+ className="fixed inset-0 z-50"
131
+ onClick={() => context?.onOpenChange?.(false)}
132
+ >
133
+ <DialogOverlay />
134
+ <View
135
+ ref={ref}
136
+ data-state={state}
137
+ className={cn(
138
+ "fixed left-[50%] top-[50%] z-50 grid w-[calc(100%-2rem)] max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] rounded-xl",
139
+ className
140
+ )}
141
+ style={{
142
+ ...(style as object),
143
+ top: offset > 0 ? `calc(50% - ${offset / 2}px)` : undefined
144
+ }}
145
+ onClick={(e) => e.stopPropagation()}
146
+ {...props}
147
+ >
148
+ {children}
149
+ <View
150
+ data-slot="dialog-close"
151
+ className={cn(
152
+ "absolute right-4 top-4 flex h-6 w-6 items-center justify-center rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
153
+ closeClassName
154
+ )}
155
+ data-state={state}
156
+ onClick={(e) => {
157
+ e.stopPropagation()
158
+ context?.onOpenChange?.(false)
159
+ }}
160
+ >
161
+ <X size={16} />
162
+ <View className="sr-only">Close</View>
163
+ </View>
164
+ </View>
165
+ </View>
166
+ </DialogPortal>
167
+ )
168
+ })
169
+ DialogContent.displayName = "DialogContent"
170
+
171
+ const DialogHeader = ({
172
+ className,
173
+ ...props
174
+ }: React.ComponentPropsWithoutRef<typeof View>) => (
175
+ <View
176
+ className={cn(
177
+ "flex flex-col space-y-2 text-center sm:text-left",
178
+ className
179
+ )}
180
+ {...props}
181
+ />
182
+ )
183
+ DialogHeader.displayName = "DialogHeader"
184
+
185
+ const DialogFooter = ({
186
+ className,
187
+ ...props
188
+ }: React.ComponentPropsWithoutRef<typeof View>) => (
189
+ <View
190
+ className={cn(
191
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
192
+ className
193
+ )}
194
+ {...props}
195
+ />
196
+ )
197
+ DialogFooter.displayName = "DialogFooter"
198
+
199
+ const DialogTitle = React.forwardRef<
200
+ React.ElementRef<typeof View>,
201
+ React.ComponentPropsWithoutRef<typeof View>
202
+ >(({ className, ...props }, ref) => (
203
+ <View
204
+ ref={ref}
205
+ className={cn(
206
+ "text-lg font-semibold leading-none tracking-tight",
207
+ className
208
+ )}
209
+ {...props}
210
+ />
211
+ ))
212
+ DialogTitle.displayName = "DialogTitle"
213
+
214
+ const DialogDescription = React.forwardRef<
215
+ React.ElementRef<typeof View>,
216
+ React.ComponentPropsWithoutRef<typeof View>
217
+ >(({ className, ...props }, ref) => (
218
+ <View
219
+ ref={ref}
220
+ className={cn("text-sm text-muted-foreground", className)}
221
+ {...props}
222
+ />
223
+ ))
224
+ DialogDescription.displayName = "DialogDescription"
225
+
226
+ const DialogClose = React.forwardRef<
227
+ React.ElementRef<typeof View>,
228
+ React.ComponentPropsWithoutRef<typeof View>
229
+ >(({ className, ...props }, ref) => {
230
+ const context = React.useContext(DialogContext)
231
+ return (
232
+ <View
233
+ ref={ref}
234
+ className={className}
235
+ onClick={(e) => {
236
+ e.stopPropagation()
237
+ context?.onOpenChange?.(false)
238
+ }}
239
+ {...props}
240
+ />
241
+ )
242
+ })
243
+ DialogClose.displayName = "DialogClose"
244
+
245
+ export {
246
+ Dialog,
247
+ DialogPortal,
248
+ DialogOverlay,
249
+ DialogTrigger,
250
+ DialogClose,
251
+ DialogContent,
252
+ DialogHeader,
253
+ DialogFooter,
254
+ DialogTitle,
255
+ DialogDescription,
256
+ }
@@ -0,0 +1,192 @@
1
+ import * as React from "react"
2
+ import { View } from "@tarojs/components"
3
+ import { cn } from "@/lib/utils"
4
+ import { Portal } from "@/components/ui/portal"
5
+
6
+ const DrawerContext = React.createContext<{
7
+ open?: boolean
8
+ onOpenChange?: (open: boolean) => void
9
+ } | null>(null)
10
+
11
+ interface DrawerProps extends React.ComponentPropsWithoutRef<typeof View> {
12
+ shouldScaleBackground?: boolean
13
+ open?: boolean
14
+ defaultOpen?: boolean
15
+ onOpenChange?: (open: boolean) => void
16
+ }
17
+
18
+ const Drawer = ({
19
+ shouldScaleBackground = true,
20
+ children,
21
+ open: openProp,
22
+ defaultOpen,
23
+ onOpenChange,
24
+ ...props
25
+ }: DrawerProps) => {
26
+ const [openState, setOpenState] = React.useState(defaultOpen || false)
27
+ const open = openProp !== undefined ? openProp : openState
28
+
29
+ const handleOpenChange = (newOpen: boolean) => {
30
+ if (openProp === undefined) {
31
+ setOpenState(newOpen)
32
+ }
33
+ onOpenChange?.(newOpen)
34
+ }
35
+
36
+ return (
37
+ <DrawerContext.Provider value={{ open, onOpenChange: handleOpenChange }}>
38
+ <View {...props}>{children}</View>
39
+ </DrawerContext.Provider>
40
+ )
41
+ }
42
+ Drawer.displayName = "Drawer"
43
+
44
+ const DrawerTrigger = React.forwardRef<
45
+ React.ElementRef<typeof View>,
46
+ React.ComponentPropsWithoutRef<typeof View> & { asChild?: boolean }
47
+ >(({ className, children, asChild, ...props }, ref) => {
48
+ const context = React.useContext(DrawerContext)
49
+ return (
50
+ <View
51
+ ref={ref}
52
+ className={cn("w-fit", className)}
53
+ onClick={(e) => {
54
+ e.stopPropagation()
55
+ context?.onOpenChange?.(true)
56
+ }}
57
+ {...props}
58
+ >
59
+ {children}
60
+ </View>
61
+ )
62
+ })
63
+ DrawerTrigger.displayName = "DrawerTrigger"
64
+
65
+ const DrawerPortal = ({ children }: { children: React.ReactNode }) => {
66
+ const context = React.useContext(DrawerContext)
67
+ if (!context?.open) return null
68
+ return <Portal>{children}</Portal>
69
+ }
70
+
71
+ const DrawerClose = React.forwardRef<
72
+ React.ElementRef<typeof View>,
73
+ React.ComponentPropsWithoutRef<typeof View> & { asChild?: boolean }
74
+ >(({ className, children, asChild, ...props }, ref) => {
75
+ const context = React.useContext(DrawerContext)
76
+ return (
77
+ <View
78
+ ref={ref}
79
+ className={className}
80
+ onClick={(e) => {
81
+ e.stopPropagation()
82
+ context?.onOpenChange?.(false)
83
+ }}
84
+ {...props}
85
+ >
86
+ {children}
87
+ </View>
88
+ )
89
+ })
90
+ DrawerClose.displayName = "DrawerClose"
91
+
92
+ const DrawerOverlay = React.forwardRef<
93
+ React.ElementRef<typeof View>,
94
+ React.ComponentPropsWithoutRef<typeof View>
95
+ >(({ className, ...props }, ref) => {
96
+ const context = React.useContext(DrawerContext)
97
+ return (
98
+ <View
99
+ ref={ref}
100
+ className={cn(
101
+ "fixed inset-0 isolate z-50 bg-black bg-opacity-10 transition-opacity duration-100 supports-[backdrop-filter]:backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
102
+ className
103
+ )}
104
+ onClick={() => context?.onOpenChange?.(false)}
105
+ {...props}
106
+ />
107
+ )
108
+ })
109
+ DrawerOverlay.displayName = "DrawerOverlay"
110
+
111
+ const DrawerContent = React.forwardRef<
112
+ React.ElementRef<typeof View>,
113
+ React.ComponentPropsWithoutRef<typeof View>
114
+ >(({ className, children, ...props }, ref) => (
115
+ <DrawerPortal>
116
+ <DrawerOverlay />
117
+ <View
118
+ ref={ref}
119
+ className={cn(
120
+ "fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[10px] border bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom duration-300",
121
+ className
122
+ )}
123
+ {...props}
124
+ >
125
+ <View className="mx-auto mt-4 h-2 w-[100px] rounded-full bg-muted" />
126
+ {children}
127
+ </View>
128
+ </DrawerPortal>
129
+ ))
130
+ DrawerContent.displayName = "DrawerContent"
131
+
132
+ const DrawerHeader = ({
133
+ className,
134
+ ...props
135
+ }: React.ComponentPropsWithoutRef<typeof View>) => (
136
+ <View
137
+ className={cn("grid gap-2 p-4 text-center sm:text-left", className)}
138
+ {...props}
139
+ />
140
+ )
141
+ DrawerHeader.displayName = "DrawerHeader"
142
+
143
+ const DrawerFooter = ({
144
+ className,
145
+ ...props
146
+ }: React.ComponentPropsWithoutRef<typeof View>) => (
147
+ <View
148
+ className={cn("mt-auto flex flex-col gap-2 p-4", className)}
149
+ {...props}
150
+ />
151
+ )
152
+ DrawerFooter.displayName = "DrawerFooter"
153
+
154
+ const DrawerTitle = React.forwardRef<
155
+ React.ElementRef<typeof View>,
156
+ React.ComponentPropsWithoutRef<typeof View>
157
+ >(({ className, ...props }, ref) => (
158
+ <View
159
+ ref={ref}
160
+ className={cn(
161
+ "text-lg font-semibold leading-none tracking-tight",
162
+ className
163
+ )}
164
+ {...props}
165
+ />
166
+ ))
167
+ DrawerTitle.displayName = "DrawerTitle"
168
+
169
+ const DrawerDescription = React.forwardRef<
170
+ React.ElementRef<typeof View>,
171
+ React.ComponentPropsWithoutRef<typeof View>
172
+ >(({ className, ...props }, ref) => (
173
+ <View
174
+ ref={ref}
175
+ className={cn("text-sm text-muted-foreground", className)}
176
+ {...props}
177
+ />
178
+ ))
179
+ DrawerDescription.displayName = "DrawerDescription"
180
+
181
+ export {
182
+ Drawer,
183
+ DrawerPortal,
184
+ DrawerOverlay,
185
+ DrawerTrigger,
186
+ DrawerClose,
187
+ DrawerContent,
188
+ DrawerHeader,
189
+ DrawerFooter,
190
+ DrawerTitle,
191
+ DrawerDescription,
192
+ }