@coze-arch/cli 0.0.1-alpha.af3865 → 0.0.1-alpha.afbc41
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 +1 -0
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +13 -12
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
- package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
- package/lib/__templates__/expo/client/eslint.config.mjs +7 -0
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/client/package.json +35 -35
- package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
- package/lib/__templates__/expo/package.json +1 -1
- package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +3 -2
- package/lib/__templates__/expo/pnpm-lock.yaml +340 -1736
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +56 -0
- package/lib/__templates__/native-static/.coze +11 -0
- package/lib/__templates__/native-static/index.html +33 -0
- package/lib/__templates__/native-static/styles/main.css +136 -0
- package/lib/__templates__/native-static/template.config.js +22 -0
- package/lib/__templates__/nextjs/README.md +5 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
- package/lib/__templates__/nextjs/next.config.ts +1 -2
- package/lib/__templates__/nextjs/package.json +5 -6
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1145 -109
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +8 -2
- package/lib/__templates__/nextjs/scripts/start.sh +7 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
- package/lib/__templates__/nextjs/src/app/page.tsx +17 -60
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- package/lib/__templates__/nextjs/template.config.js +49 -14
- package/lib/__templates__/nextjs/tsconfig.json +1 -1
- package/lib/__templates__/nuxt-vue/.coze +12 -0
- package/lib/__templates__/nuxt-vue/README.md +73 -0
- package/lib/__templates__/nuxt-vue/_gitignore +24 -0
- package/lib/__templates__/nuxt-vue/_npmrc +23 -0
- package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
- package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
- package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
- package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
- package/lib/__templates__/nuxt-vue/package.json +35 -0
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
- package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
- package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
- package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
- package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
- package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
- package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
- package/lib/__templates__/nuxt-vue/template.config.js +87 -0
- package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
- package/lib/__templates__/taro/.coze +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
- package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
- package/lib/__templates__/taro/README.md +763 -0
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/babel.config.js +12 -0
- package/lib/__templates__/taro/config/dev.ts +9 -0
- package/lib/__templates__/taro/config/index.ts +238 -0
- package/lib/__templates__/taro/config/prod.ts +34 -0
- package/lib/__templates__/taro/eslint.config.mjs +135 -0
- package/lib/__templates__/taro/key/private.appid.key +0 -0
- package/lib/__templates__/taro/package.json +112 -0
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
- package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
- package/lib/__templates__/taro/project.config.json +15 -0
- package/lib/__templates__/taro/server/nest-cli.json +10 -0
- package/lib/__templates__/taro/server/package.json +40 -0
- package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
- package/lib/__templates__/taro/server/src/app.module.ts +10 -0
- package/lib/__templates__/taro/server/src/app.service.ts +8 -0
- package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
- package/lib/__templates__/taro/server/src/main.ts +49 -0
- package/lib/__templates__/taro/server/tsconfig.json +24 -0
- package/lib/__templates__/taro/src/app.config.ts +11 -0
- package/lib/__templates__/taro/src/app.css +156 -0
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
- package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
- package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
- package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
- package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
- package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
- package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
- package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
- package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
- package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
- package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
- package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
- package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
- package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
- package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
- package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
- package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
- package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
- package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
- package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
- package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
- package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
- package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
- package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
- package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
- package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
- package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
- package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
- package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
- package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
- package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
- package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
- package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
- package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
- package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
- package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
- package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
- package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
- package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
- package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
- package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
- package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
- package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
- package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
- package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
- package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
- package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
- package/lib/__templates__/taro/src/index.html +39 -0
- package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
- package/lib/__templates__/taro/src/lib/measure.ts +115 -0
- package/lib/__templates__/taro/src/lib/platform.ts +12 -0
- package/lib/__templates__/taro/src/lib/utils.ts +6 -0
- package/lib/__templates__/taro/src/network.ts +39 -0
- package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
- package/lib/__templates__/taro/src/pages/index/index.css +1 -0
- package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
- package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
- package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/taro/stylelint.config.mjs +4 -0
- package/lib/__templates__/taro/template.config.js +68 -0
- package/lib/__templates__/taro/tsconfig.json +29 -0
- package/lib/__templates__/taro/types/global.d.ts +32 -0
- package/lib/__templates__/templates.json +75 -0
- package/lib/__templates__/vite/README.md +190 -11
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +6 -1
- package/lib/__templates__/vite/package.json +14 -3
- package/lib/__templates__/vite/pnpm-lock.yaml +820 -1593
- package/lib/__templates__/vite/scripts/build.sh +4 -1
- package/lib/__templates__/vite/scripts/dev.sh +9 -2
- package/lib/__templates__/vite/scripts/start.sh +9 -3
- package/lib/__templates__/vite/server/routes/index.ts +31 -0
- package/lib/__templates__/vite/server/server.ts +65 -0
- package/lib/__templates__/vite/server/vite.ts +67 -0
- package/lib/__templates__/vite/src/main.ts +17 -47
- package/lib/__templates__/vite/template.config.js +49 -14
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +5 -0
- package/lib/cli.js +160 -159
- package/package.json +7 -3
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { View } from "@tarojs/components"
|
|
3
|
+
import { type VariantProps } from "class-variance-authority"
|
|
4
|
+
import { cn } from "@/lib/utils"
|
|
5
|
+
import { buttonVariants } from "@/components/ui/button"
|
|
6
|
+
import { Portal } from "@/components/ui/portal"
|
|
7
|
+
import { useKeyboardOffset } from "@/lib/hooks/use-keyboard-offset"
|
|
8
|
+
|
|
9
|
+
const AlertDialogContext = React.createContext<{
|
|
10
|
+
open?: boolean
|
|
11
|
+
onOpenChange?: (open: boolean) => void
|
|
12
|
+
} | null>(null)
|
|
13
|
+
|
|
14
|
+
const usePresence = (open: boolean | undefined, durationMs: number) => {
|
|
15
|
+
const [present, setPresent] = React.useState(!!open)
|
|
16
|
+
const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
17
|
+
|
|
18
|
+
React.useEffect(() => {
|
|
19
|
+
if (open) {
|
|
20
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
21
|
+
timeoutRef.current = null
|
|
22
|
+
setPresent(true)
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
timeoutRef.current = setTimeout(() => setPresent(false), durationMs)
|
|
27
|
+
return () => {
|
|
28
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
|
29
|
+
timeoutRef.current = null
|
|
30
|
+
}
|
|
31
|
+
}, [open, durationMs])
|
|
32
|
+
|
|
33
|
+
return present
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const AlertDialog = ({
|
|
37
|
+
children,
|
|
38
|
+
open: openProp,
|
|
39
|
+
defaultOpen = false,
|
|
40
|
+
onOpenChange
|
|
41
|
+
}: {
|
|
42
|
+
children: React.ReactNode,
|
|
43
|
+
open?: boolean,
|
|
44
|
+
defaultOpen?: boolean,
|
|
45
|
+
onOpenChange?: (open: boolean) => void
|
|
46
|
+
}) => {
|
|
47
|
+
const [openState, setOpenState] = React.useState(defaultOpen || false)
|
|
48
|
+
const open = openProp !== undefined ? openProp : openState
|
|
49
|
+
|
|
50
|
+
const handleOpenChange = (newOpen: boolean) => {
|
|
51
|
+
if (openProp === undefined) {
|
|
52
|
+
setOpenState(newOpen)
|
|
53
|
+
}
|
|
54
|
+
onOpenChange?.(newOpen)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<AlertDialogContext.Provider value={{ open, onOpenChange: handleOpenChange }}>
|
|
59
|
+
{children}
|
|
60
|
+
</AlertDialogContext.Provider>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const AlertDialogTrigger = React.forwardRef<
|
|
65
|
+
React.ElementRef<typeof View>,
|
|
66
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
67
|
+
>(({ className, children, ...props }, ref) => {
|
|
68
|
+
const context = React.useContext(AlertDialogContext)
|
|
69
|
+
return (
|
|
70
|
+
<View
|
|
71
|
+
ref={ref}
|
|
72
|
+
className={className}
|
|
73
|
+
onClick={(e) => {
|
|
74
|
+
e.stopPropagation()
|
|
75
|
+
context?.onOpenChange?.(true)
|
|
76
|
+
}}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
{children}
|
|
80
|
+
</View>
|
|
81
|
+
)
|
|
82
|
+
})
|
|
83
|
+
AlertDialogTrigger.displayName = "AlertDialogTrigger"
|
|
84
|
+
|
|
85
|
+
const AlertDialogPortal = ({ children }) => {
|
|
86
|
+
const context = React.useContext(AlertDialogContext)
|
|
87
|
+
const present = usePresence(context?.open, 200)
|
|
88
|
+
if (!present) return null
|
|
89
|
+
return <Portal>{children}</Portal>
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const AlertDialogOverlay = React.forwardRef<
|
|
93
|
+
React.ElementRef<typeof View>,
|
|
94
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
95
|
+
>(({ className, ...props }, ref) => {
|
|
96
|
+
const context = React.useContext(AlertDialogContext)
|
|
97
|
+
const state = context?.open ? "open" : "closed"
|
|
98
|
+
return (
|
|
99
|
+
<View
|
|
100
|
+
ref={ref}
|
|
101
|
+
data-state={state}
|
|
102
|
+
className={cn(
|
|
103
|
+
"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",
|
|
104
|
+
className
|
|
105
|
+
)}
|
|
106
|
+
onClick={(e) => {
|
|
107
|
+
e.stopPropagation()
|
|
108
|
+
// Unlike Dialog, AlertDialog typically forces explicit action/cancel.
|
|
109
|
+
// But user might want it to close on overlay click.
|
|
110
|
+
// Standard shadcn/radix alert dialog usually does NOT close on overlay click?
|
|
111
|
+
// Radix Alert Dialog does NOT close on overlay click by default.
|
|
112
|
+
// We will leave it as is (no close on click) or optional?
|
|
113
|
+
// For now, let's follow standard pattern: it blocks interaction.
|
|
114
|
+
}}
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
)
|
|
118
|
+
})
|
|
119
|
+
AlertDialogOverlay.displayName = "AlertDialogOverlay"
|
|
120
|
+
|
|
121
|
+
const AlertDialogContent = React.forwardRef<
|
|
122
|
+
React.ElementRef<typeof View>,
|
|
123
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
124
|
+
>(({ className, children, style, ...props }, ref) => {
|
|
125
|
+
const context = React.useContext(AlertDialogContext)
|
|
126
|
+
const offset = useKeyboardOffset()
|
|
127
|
+
const state = context?.open ? "open" : "closed"
|
|
128
|
+
return (
|
|
129
|
+
<AlertDialogPortal>
|
|
130
|
+
<View className="fixed inset-0 z-50">
|
|
131
|
+
<AlertDialogOverlay />
|
|
132
|
+
<View
|
|
133
|
+
ref={ref}
|
|
134
|
+
data-state={state}
|
|
135
|
+
className={cn(
|
|
136
|
+
"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",
|
|
137
|
+
className
|
|
138
|
+
)}
|
|
139
|
+
style={{
|
|
140
|
+
...(style as object),
|
|
141
|
+
top: offset > 0 ? `calc(50% - ${offset / 2}px)` : undefined
|
|
142
|
+
}}
|
|
143
|
+
onClick={(e) => e.stopPropagation()}
|
|
144
|
+
{...props}
|
|
145
|
+
>
|
|
146
|
+
{children}
|
|
147
|
+
</View>
|
|
148
|
+
</View>
|
|
149
|
+
</AlertDialogPortal>
|
|
150
|
+
)
|
|
151
|
+
})
|
|
152
|
+
AlertDialogContent.displayName = "AlertDialogContent"
|
|
153
|
+
|
|
154
|
+
const AlertDialogHeader = ({
|
|
155
|
+
className,
|
|
156
|
+
...props
|
|
157
|
+
}: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
158
|
+
<View
|
|
159
|
+
className={cn(
|
|
160
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
161
|
+
className
|
|
162
|
+
)}
|
|
163
|
+
{...props}
|
|
164
|
+
/>
|
|
165
|
+
)
|
|
166
|
+
AlertDialogHeader.displayName = "AlertDialogHeader"
|
|
167
|
+
|
|
168
|
+
const AlertDialogFooter = ({
|
|
169
|
+
className,
|
|
170
|
+
...props
|
|
171
|
+
}: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
172
|
+
<View
|
|
173
|
+
className={cn(
|
|
174
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
175
|
+
className
|
|
176
|
+
)}
|
|
177
|
+
{...props}
|
|
178
|
+
/>
|
|
179
|
+
)
|
|
180
|
+
AlertDialogFooter.displayName = "AlertDialogFooter"
|
|
181
|
+
|
|
182
|
+
const AlertDialogTitle = React.forwardRef<
|
|
183
|
+
React.ElementRef<typeof View>,
|
|
184
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
185
|
+
>(({ className, ...props }, ref) => (
|
|
186
|
+
<View
|
|
187
|
+
ref={ref}
|
|
188
|
+
className={cn("text-lg font-semibold", className)}
|
|
189
|
+
{...props}
|
|
190
|
+
/>
|
|
191
|
+
))
|
|
192
|
+
AlertDialogTitle.displayName = "AlertDialogTitle"
|
|
193
|
+
|
|
194
|
+
const AlertDialogDescription = React.forwardRef<
|
|
195
|
+
React.ElementRef<typeof View>,
|
|
196
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
197
|
+
>(({ className, ...props }, ref) => (
|
|
198
|
+
<View
|
|
199
|
+
ref={ref}
|
|
200
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
201
|
+
{...props}
|
|
202
|
+
/>
|
|
203
|
+
))
|
|
204
|
+
AlertDialogDescription.displayName = "AlertDialogDescription"
|
|
205
|
+
|
|
206
|
+
const AlertDialogAction = React.forwardRef<
|
|
207
|
+
React.ElementRef<typeof View>,
|
|
208
|
+
React.ComponentPropsWithoutRef<typeof View> & VariantProps<typeof buttonVariants>
|
|
209
|
+
>(({ className, variant, size, onClick, ...props }, ref) => {
|
|
210
|
+
const context = React.useContext(AlertDialogContext)
|
|
211
|
+
return (
|
|
212
|
+
<View
|
|
213
|
+
ref={ref}
|
|
214
|
+
className={cn(buttonVariants({ variant, size }), "w-full sm:w-auto", className)}
|
|
215
|
+
onClick={(e) => {
|
|
216
|
+
context?.onOpenChange?.(false)
|
|
217
|
+
onClick?.(e)
|
|
218
|
+
}}
|
|
219
|
+
{...props}
|
|
220
|
+
/>
|
|
221
|
+
)
|
|
222
|
+
})
|
|
223
|
+
AlertDialogAction.displayName = "AlertDialogAction"
|
|
224
|
+
|
|
225
|
+
const AlertDialogCancel = React.forwardRef<
|
|
226
|
+
React.ElementRef<typeof View>,
|
|
227
|
+
React.ComponentPropsWithoutRef<typeof View> & VariantProps<typeof buttonVariants>
|
|
228
|
+
>(({ className, variant = "outline", size, onClick, ...props }, ref) => {
|
|
229
|
+
const context = React.useContext(AlertDialogContext)
|
|
230
|
+
return (
|
|
231
|
+
<View
|
|
232
|
+
ref={ref}
|
|
233
|
+
className={cn(
|
|
234
|
+
buttonVariants({ variant, size }),
|
|
235
|
+
"mt-2 sm:mt-0 w-full sm:w-auto",
|
|
236
|
+
className
|
|
237
|
+
)}
|
|
238
|
+
onClick={(e) => {
|
|
239
|
+
context?.onOpenChange?.(false)
|
|
240
|
+
onClick?.(e)
|
|
241
|
+
}}
|
|
242
|
+
{...props}
|
|
243
|
+
/>
|
|
244
|
+
)
|
|
245
|
+
})
|
|
246
|
+
AlertDialogCancel.displayName = "AlertDialogCancel"
|
|
247
|
+
|
|
248
|
+
export {
|
|
249
|
+
AlertDialog,
|
|
250
|
+
AlertDialogPortal,
|
|
251
|
+
AlertDialogOverlay,
|
|
252
|
+
AlertDialogTrigger,
|
|
253
|
+
AlertDialogContent,
|
|
254
|
+
AlertDialogHeader,
|
|
255
|
+
AlertDialogFooter,
|
|
256
|
+
AlertDialogTitle,
|
|
257
|
+
AlertDialogDescription,
|
|
258
|
+
AlertDialogAction,
|
|
259
|
+
AlertDialogCancel,
|
|
260
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { View } from "@tarojs/components"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const alertVariants = cva(
|
|
8
|
+
"relative w-full rounded-lg border p-4 [&>svg+*]:pl-7 [&>svg+*+*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default: "bg-background text-foreground",
|
|
13
|
+
destructive:
|
|
14
|
+
"border-destructive border-opacity-50 text-destructive dark:border-destructive [&>svg]:text-destructive",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
variant: "default",
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
const Alert = React.forwardRef<
|
|
24
|
+
React.ElementRef<typeof View>,
|
|
25
|
+
React.ComponentPropsWithoutRef<typeof View> & VariantProps<typeof alertVariants>
|
|
26
|
+
>(({ className, variant, ...props }, ref) => (
|
|
27
|
+
<View
|
|
28
|
+
ref={ref}
|
|
29
|
+
role="alert"
|
|
30
|
+
className={cn(alertVariants({ variant }), className)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
))
|
|
34
|
+
Alert.displayName = "Alert"
|
|
35
|
+
|
|
36
|
+
const AlertTitle = React.forwardRef<
|
|
37
|
+
React.ElementRef<typeof View>,
|
|
38
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
39
|
+
>(({ className, ...props }, ref) => (
|
|
40
|
+
<View
|
|
41
|
+
ref={ref}
|
|
42
|
+
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
))
|
|
46
|
+
AlertTitle.displayName = "AlertTitle"
|
|
47
|
+
|
|
48
|
+
const AlertDescription = React.forwardRef<
|
|
49
|
+
React.ElementRef<typeof View>,
|
|
50
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
51
|
+
>(({ className, ...props }, ref) => (
|
|
52
|
+
<View
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn("text-sm [&_p]:leading-relaxed", className)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
))
|
|
58
|
+
AlertDescription.displayName = "AlertDescription"
|
|
59
|
+
|
|
60
|
+
export { Alert, AlertTitle, AlertDescription }
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { View } from "@tarojs/components"
|
|
3
|
+
|
|
4
|
+
const AspectRatio = React.forwardRef<
|
|
5
|
+
React.ElementRef<typeof View>,
|
|
6
|
+
Omit<React.ComponentPropsWithoutRef<typeof View>, "style"> & {
|
|
7
|
+
ratio?: number
|
|
8
|
+
style?: React.CSSProperties
|
|
9
|
+
}
|
|
10
|
+
>(({ className, ratio = 1 / 1, style, ...props }, ref) => (
|
|
11
|
+
<View
|
|
12
|
+
ref={ref}
|
|
13
|
+
style={{
|
|
14
|
+
position: 'relative',
|
|
15
|
+
width: '100%',
|
|
16
|
+
paddingBottom: `${100 / ratio}%`,
|
|
17
|
+
...style
|
|
18
|
+
}}
|
|
19
|
+
className={className}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<View style={{
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: 0,
|
|
25
|
+
left: 0,
|
|
26
|
+
right: 0,
|
|
27
|
+
bottom: 0,
|
|
28
|
+
}}
|
|
29
|
+
>
|
|
30
|
+
{props.children}
|
|
31
|
+
</View>
|
|
32
|
+
</View>
|
|
33
|
+
))
|
|
34
|
+
AspectRatio.displayName = "AspectRatio"
|
|
35
|
+
|
|
36
|
+
export { AspectRatio }
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { View, Image } from "@tarojs/components"
|
|
3
|
+
import { cn } from "@/lib/utils"
|
|
4
|
+
|
|
5
|
+
const AvatarContext = React.createContext<{
|
|
6
|
+
status: "loading" | "error" | "loaded"
|
|
7
|
+
setStatus: (status: "loading" | "error" | "loaded") => void
|
|
8
|
+
} | null>(null)
|
|
9
|
+
|
|
10
|
+
const Avatar = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof View>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
13
|
+
>(({ className, ...props }, ref) => {
|
|
14
|
+
const [status, setStatus] = React.useState<"loading" | "error" | "loaded">("loading")
|
|
15
|
+
return (
|
|
16
|
+
<AvatarContext.Provider value={{ status, setStatus }}>
|
|
17
|
+
<View
|
|
18
|
+
ref={ref}
|
|
19
|
+
className={cn(
|
|
20
|
+
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
|
|
21
|
+
className
|
|
22
|
+
)}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
</AvatarContext.Provider>
|
|
26
|
+
)
|
|
27
|
+
})
|
|
28
|
+
Avatar.displayName = "Avatar"
|
|
29
|
+
|
|
30
|
+
const AvatarImage = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof Image>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof Image>
|
|
33
|
+
>(({ className, src, ...props }, ref) => {
|
|
34
|
+
const context = React.useContext(AvatarContext)
|
|
35
|
+
|
|
36
|
+
const handleLoad = (e) => {
|
|
37
|
+
context?.setStatus("loaded")
|
|
38
|
+
props.onLoad?.(e)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const handleError = (e) => {
|
|
42
|
+
context?.setStatus("error")
|
|
43
|
+
props.onError?.(e)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Image
|
|
48
|
+
ref={ref}
|
|
49
|
+
src={src}
|
|
50
|
+
className={cn(
|
|
51
|
+
"aspect-square h-full w-full",
|
|
52
|
+
className,
|
|
53
|
+
context?.status !== "loaded" && "w-0 h-0 opacity-0 absolute"
|
|
54
|
+
)}
|
|
55
|
+
onLoad={handleLoad}
|
|
56
|
+
onError={handleError}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
AvatarImage.displayName = "AvatarImage"
|
|
62
|
+
|
|
63
|
+
const AvatarFallback = React.forwardRef<
|
|
64
|
+
React.ElementRef<typeof View>,
|
|
65
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
66
|
+
>(({ className, ...props }, ref) => {
|
|
67
|
+
const context = React.useContext(AvatarContext)
|
|
68
|
+
|
|
69
|
+
if (context?.status === "loaded") return null
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<View
|
|
73
|
+
ref={ref}
|
|
74
|
+
className={cn(
|
|
75
|
+
"flex h-full w-full items-center justify-center rounded-full bg-muted",
|
|
76
|
+
className
|
|
77
|
+
)}
|
|
78
|
+
{...props}
|
|
79
|
+
/>
|
|
80
|
+
)
|
|
81
|
+
})
|
|
82
|
+
AvatarFallback.displayName = "AvatarFallback"
|
|
83
|
+
|
|
84
|
+
export { Avatar, AvatarImage, AvatarFallback }
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { View } from "@tarojs/components"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const badgeVariants = cva(
|
|
8
|
+
"inline-flex items-center rounded-full border px-3 py-1 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"border-transparent bg-primary text-primary-foreground hover:bg-primary hover:bg-opacity-80",
|
|
14
|
+
secondary:
|
|
15
|
+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary hover:bg-opacity-80",
|
|
16
|
+
destructive:
|
|
17
|
+
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive hover:bg-opacity-80",
|
|
18
|
+
outline: "text-foreground",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
variant: "default",
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
export interface BadgeProps
|
|
28
|
+
extends React.ComponentPropsWithoutRef<typeof View>,
|
|
29
|
+
VariantProps<typeof badgeVariants> {}
|
|
30
|
+
|
|
31
|
+
function Badge({ className, variant, ...props }: BadgeProps) {
|
|
32
|
+
return (
|
|
33
|
+
<View className={cn(badgeVariants({ variant }), className)} {...props} />
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { Badge, badgeVariants }
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { View } from "@tarojs/components"
|
|
3
|
+
import { ChevronRight, Ellipsis } from "lucide-react-taro"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const Breadcrumb = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof View>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof View> & {
|
|
10
|
+
separator?: React.ReactNode
|
|
11
|
+
}
|
|
12
|
+
>(({ ...props }, ref) => <View ref={ref} aria-label="breadcrumb" {...props} />)
|
|
13
|
+
Breadcrumb.displayName = "Breadcrumb"
|
|
14
|
+
|
|
15
|
+
const BreadcrumbList = React.forwardRef<
|
|
16
|
+
React.ElementRef<typeof View>,
|
|
17
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
18
|
+
>(({ className, ...props }, ref) => (
|
|
19
|
+
<View
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={cn(
|
|
22
|
+
"flex flex-wrap items-center gap-2 break-words text-sm text-muted-foreground sm:gap-3",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
))
|
|
28
|
+
BreadcrumbList.displayName = "BreadcrumbList"
|
|
29
|
+
|
|
30
|
+
const BreadcrumbItem = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof View>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
33
|
+
>(({ className, ...props }, ref) => (
|
|
34
|
+
<View
|
|
35
|
+
ref={ref}
|
|
36
|
+
className={cn("inline-flex items-center gap-2", className)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
))
|
|
40
|
+
BreadcrumbItem.displayName = "BreadcrumbItem"
|
|
41
|
+
|
|
42
|
+
const BreadcrumbLink = React.forwardRef<
|
|
43
|
+
React.ElementRef<typeof View>,
|
|
44
|
+
React.ComponentPropsWithoutRef<typeof View> & {
|
|
45
|
+
asChild?: boolean
|
|
46
|
+
href?: string
|
|
47
|
+
}
|
|
48
|
+
>(({ asChild, className, href, ...props }, ref) => {
|
|
49
|
+
const linkProps = href ? { url: href } : {}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<View
|
|
53
|
+
ref={ref}
|
|
54
|
+
className={cn("transition-colors hover:text-foreground", className)}
|
|
55
|
+
{...linkProps}
|
|
56
|
+
{...props as any}
|
|
57
|
+
/>
|
|
58
|
+
)
|
|
59
|
+
})
|
|
60
|
+
BreadcrumbLink.displayName = "BreadcrumbLink"
|
|
61
|
+
|
|
62
|
+
const BreadcrumbPage = React.forwardRef<
|
|
63
|
+
React.ElementRef<typeof View>,
|
|
64
|
+
React.ComponentPropsWithoutRef<typeof View>
|
|
65
|
+
>(({ className, ...props }, ref) => (
|
|
66
|
+
<View
|
|
67
|
+
ref={ref}
|
|
68
|
+
role="link"
|
|
69
|
+
aria-disabled="true"
|
|
70
|
+
aria-current="page"
|
|
71
|
+
className={cn("font-normal text-foreground", className)}
|
|
72
|
+
{...props}
|
|
73
|
+
/>
|
|
74
|
+
))
|
|
75
|
+
BreadcrumbPage.displayName = "BreadcrumbPage"
|
|
76
|
+
|
|
77
|
+
const BreadcrumbSeparator = ({
|
|
78
|
+
children,
|
|
79
|
+
className,
|
|
80
|
+
...props
|
|
81
|
+
}: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
82
|
+
<View
|
|
83
|
+
role="presentation"
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
className={cn("[&>svg]:w-4 [&>svg]:h-4 flex items-center", className)}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
{children ?? <ChevronRight size={16} />}
|
|
89
|
+
</View>
|
|
90
|
+
)
|
|
91
|
+
BreadcrumbSeparator.displayName = "BreadcrumbSeparator"
|
|
92
|
+
|
|
93
|
+
const BreadcrumbEllipsis = ({
|
|
94
|
+
className,
|
|
95
|
+
...props
|
|
96
|
+
}: React.ComponentPropsWithoutRef<typeof View>) => (
|
|
97
|
+
<View
|
|
98
|
+
role="presentation"
|
|
99
|
+
aria-hidden="true"
|
|
100
|
+
className={cn("flex h-9 w-9 items-center justify-center", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
>
|
|
103
|
+
<Ellipsis color="#737373" size={16} />
|
|
104
|
+
<View className="sr-only">More</View>
|
|
105
|
+
</View>
|
|
106
|
+
)
|
|
107
|
+
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis"
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
Breadcrumb,
|
|
111
|
+
BreadcrumbList,
|
|
112
|
+
BreadcrumbItem,
|
|
113
|
+
BreadcrumbLink,
|
|
114
|
+
BreadcrumbPage,
|
|
115
|
+
BreadcrumbSeparator,
|
|
116
|
+
BreadcrumbEllipsis,
|
|
117
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { View } from "@tarojs/components"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
import { Separator } from "@/components/ui/separator"
|
|
7
|
+
|
|
8
|
+
const buttonGroupVariants = cva(
|
|
9
|
+
"flex w-fit items-stretch",
|
|
10
|
+
{
|
|
11
|
+
variants: {
|
|
12
|
+
orientation: {
|
|
13
|
+
horizontal:
|
|
14
|
+
"[&>view:nth-child(n+2)]:rounded-l-none [&>view:nth-child(n+2)]:border-l-0 [&>view:nth-last-child(n+2)]:rounded-r-none",
|
|
15
|
+
vertical:
|
|
16
|
+
"flex-col [&>view:nth-child(n+2)]:rounded-t-none [&>view:nth-child(n+2)]:border-t-0 [&>view:nth-last-child(n+2)]:rounded-b-none",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
orientation: "horizontal",
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
function ButtonGroup({
|
|
26
|
+
className,
|
|
27
|
+
orientation,
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentPropsWithoutRef<typeof View> & VariantProps<typeof buttonGroupVariants>) {
|
|
30
|
+
return (
|
|
31
|
+
<View
|
|
32
|
+
role="group"
|
|
33
|
+
data-slot="button-group"
|
|
34
|
+
data-orientation={orientation}
|
|
35
|
+
className={cn(buttonGroupVariants({ orientation }), className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function ButtonGroupText({
|
|
42
|
+
className,
|
|
43
|
+
asChild = false,
|
|
44
|
+
...props
|
|
45
|
+
}: React.ComponentPropsWithoutRef<typeof View> & {
|
|
46
|
+
asChild?: boolean
|
|
47
|
+
}) {
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<View
|
|
51
|
+
className={cn(
|
|
52
|
+
"bg-muted shadow-xs flex items-center gap-2 rounded-md border px-4 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
|
|
53
|
+
className
|
|
54
|
+
)}
|
|
55
|
+
{...props}
|
|
56
|
+
/>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function ButtonGroupSeparator({
|
|
61
|
+
className,
|
|
62
|
+
orientation = "vertical",
|
|
63
|
+
...props
|
|
64
|
+
}: React.ComponentPropsWithoutRef<typeof Separator>) {
|
|
65
|
+
return (
|
|
66
|
+
<Separator
|
|
67
|
+
data-slot="button-group-separator"
|
|
68
|
+
orientation={orientation}
|
|
69
|
+
className={cn(
|
|
70
|
+
"bg-input relative !m-0 self-stretch data-[orientation=vertical]:h-auto",
|
|
71
|
+
className
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
/>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
ButtonGroup,
|
|
80
|
+
ButtonGroupSeparator,
|
|
81
|
+
ButtonGroupText,
|
|
82
|
+
buttonGroupVariants,
|
|
83
|
+
}
|