@coze-arch/cli 0.0.1-beta.6 → 0.0.3

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 (239) hide show
  1. package/README.md +1 -0
  2. package/lib/__templates__/expo/.coze +7 -2
  3. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +229 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  6. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  7. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +46 -0
  8. package/lib/__templates__/expo/README.md +68 -7
  9. package/lib/__templates__/expo/_gitignore +2 -1
  10. package/lib/__templates__/expo/_npmrc +4 -5
  11. package/lib/__templates__/expo/client/app/+not-found.tsx +15 -64
  12. package/lib/__templates__/expo/client/app/_layout.tsx +15 -12
  13. package/lib/__templates__/expo/client/app/index.tsx +1 -0
  14. package/lib/__templates__/expo/client/app.config.ts +76 -0
  15. package/lib/__templates__/expo/client/components/Screen.tsx +3 -19
  16. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  17. package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
  18. package/lib/__templates__/expo/client/constants/theme.ts +117 -58
  19. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
  20. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  21. package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +40 -10
  22. package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
  23. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  24. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  25. package/lib/__templates__/expo/client/metro.config.js +124 -0
  26. package/lib/__templates__/expo/client/package.json +95 -0
  27. package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
  28. package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
  29. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +11 -10
  30. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  31. package/lib/__templates__/expo/client/utils/index.ts +23 -2
  32. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  33. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  34. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  35. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  36. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
  37. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
  38. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
  39. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  40. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  41. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  42. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  43. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
  44. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
  45. package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
  46. package/lib/__templates__/expo/package.json +16 -101
  47. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  48. package/lib/__templates__/expo/pnpm-lock.yaml +1622 -3274
  49. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  50. package/lib/__templates__/expo/server/build.js +21 -0
  51. package/lib/__templates__/expo/server/package.json +34 -0
  52. package/lib/__templates__/expo/server/src/index.ts +20 -0
  53. package/lib/__templates__/expo/server/tsconfig.json +24 -0
  54. package/lib/__templates__/expo/template.config.js +58 -1
  55. package/lib/__templates__/expo/tsconfig.json +1 -24
  56. package/lib/__templates__/native-static/.coze +11 -0
  57. package/lib/__templates__/native-static/index.html +33 -0
  58. package/lib/__templates__/native-static/styles/main.css +136 -0
  59. package/lib/__templates__/native-static/template.config.js +22 -0
  60. package/lib/__templates__/nextjs/.coze +4 -3
  61. package/lib/__templates__/nextjs/README.md +5 -0
  62. package/lib/__templates__/nextjs/_gitignore +1 -0
  63. package/lib/__templates__/nextjs/_npmrc +2 -1
  64. package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
  65. package/lib/__templates__/nextjs/next.config.ts +11 -0
  66. package/lib/__templates__/nextjs/package.json +15 -1
  67. package/lib/__templates__/nextjs/pnpm-lock.yaml +7694 -4394
  68. package/lib/__templates__/nextjs/scripts/build.sh +4 -1
  69. package/lib/__templates__/nextjs/scripts/dev.sh +15 -28
  70. package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
  71. package/lib/__templates__/nextjs/scripts/start.sh +7 -1
  72. package/lib/__templates__/nextjs/src/app/globals.css +109 -89
  73. package/lib/__templates__/nextjs/src/app/layout.tsx +20 -33
  74. package/lib/__templates__/nextjs/src/app/page.tsx +18 -49
  75. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +29 -22
  76. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +228 -230
  77. package/lib/__templates__/nextjs/src/server.ts +35 -0
  78. package/lib/__templates__/nextjs/template.config.js +68 -3
  79. package/lib/__templates__/nextjs/tsconfig.json +1 -1
  80. package/lib/__templates__/nuxt-vue/.coze +12 -0
  81. package/lib/__templates__/nuxt-vue/README.md +73 -0
  82. package/lib/__templates__/nuxt-vue/_gitignore +25 -0
  83. package/lib/__templates__/nuxt-vue/_npmrc +23 -0
  84. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  85. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  86. package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
  87. package/lib/__templates__/nuxt-vue/nuxt.config.ts +126 -0
  88. package/lib/__templates__/nuxt-vue/package.json +35 -0
  89. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  90. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  91. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  92. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  93. package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
  94. package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
  95. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  96. package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
  97. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  98. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  99. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  100. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  101. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  102. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  103. package/lib/__templates__/taro/.coze +14 -0
  104. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  105. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  106. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  107. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  108. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  109. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  110. package/lib/__templates__/taro/README.md +763 -0
  111. package/lib/__templates__/taro/_gitignore +41 -0
  112. package/lib/__templates__/taro/_npmrc +18 -0
  113. package/lib/__templates__/taro/babel.config.js +12 -0
  114. package/lib/__templates__/taro/config/dev.ts +9 -0
  115. package/lib/__templates__/taro/config/index.ts +238 -0
  116. package/lib/__templates__/taro/config/prod.ts +34 -0
  117. package/lib/__templates__/taro/eslint.config.mjs +135 -0
  118. package/lib/__templates__/taro/key/private.appid.key +0 -0
  119. package/lib/__templates__/taro/package.json +112 -0
  120. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  121. package/lib/__templates__/taro/pnpm-lock.yaml +23412 -0
  122. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  123. package/lib/__templates__/taro/project.config.json +15 -0
  124. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  125. package/lib/__templates__/taro/server/package.json +40 -0
  126. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  127. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  128. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  129. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  130. package/lib/__templates__/taro/server/src/main.ts +49 -0
  131. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  132. package/lib/__templates__/taro/src/app.config.ts +11 -0
  133. package/lib/__templates__/taro/src/app.css +156 -0
  134. package/lib/__templates__/taro/src/app.tsx +9 -0
  135. package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
  136. package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
  137. package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
  138. package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
  139. package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
  140. package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
  141. package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
  142. package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
  143. package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
  144. package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
  145. package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
  146. package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
  147. package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
  148. package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
  149. package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
  150. package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
  151. package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
  152. package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
  153. package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
  154. package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
  155. package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
  156. package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
  157. package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
  158. package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
  159. package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
  160. package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
  161. package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
  162. package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
  163. package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
  164. package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
  165. package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
  166. package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
  167. package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
  168. package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
  169. package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
  170. package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
  171. package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
  172. package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
  173. package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
  174. package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
  175. package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
  176. package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
  177. package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
  178. package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
  179. package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
  180. package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
  181. package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
  182. package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
  183. package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
  184. package/lib/__templates__/taro/src/index.html +39 -0
  185. package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
  186. package/lib/__templates__/taro/src/lib/measure.ts +115 -0
  187. package/lib/__templates__/taro/src/lib/platform.ts +12 -0
  188. package/lib/__templates__/taro/src/lib/utils.ts +6 -0
  189. package/lib/__templates__/taro/src/network.ts +39 -0
  190. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  191. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  192. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  193. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  194. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  195. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
  196. package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
  197. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  198. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  199. package/lib/__templates__/taro/template.config.js +68 -0
  200. package/lib/__templates__/taro/tsconfig.json +29 -0
  201. package/lib/__templates__/taro/types/global.d.ts +32 -0
  202. package/lib/__templates__/templates.json +173 -36
  203. package/lib/__templates__/vite/.coze +4 -3
  204. package/lib/__templates__/vite/README.md +383 -26
  205. package/lib/__templates__/vite/_gitignore +2 -0
  206. package/lib/__templates__/vite/_npmrc +2 -1
  207. package/lib/__templates__/vite/eslint.config.mjs +14 -0
  208. package/lib/__templates__/vite/package.json +23 -3
  209. package/lib/__templates__/vite/pnpm-lock.yaml +2509 -293
  210. package/lib/__templates__/vite/scripts/build.sh +4 -1
  211. package/lib/__templates__/vite/scripts/dev.sh +16 -28
  212. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  213. package/lib/__templates__/vite/scripts/start.sh +9 -3
  214. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  215. package/lib/__templates__/vite/server/server.ts +65 -0
  216. package/lib/__templates__/vite/server/vite.ts +67 -0
  217. package/lib/__templates__/vite/src/main.ts +17 -48
  218. package/lib/__templates__/vite/template.config.js +77 -7
  219. package/lib/__templates__/vite/tsconfig.json +4 -3
  220. package/lib/__templates__/vite/vite.config.ts +8 -3
  221. package/lib/cli.js +1545 -526
  222. package/package.json +20 -7
  223. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -109
  224. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -257
  225. package/lib/__templates__/expo/app.json +0 -63
  226. package/lib/__templates__/expo/babel.config.js +0 -9
  227. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  228. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  229. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  230. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +0 -1
  231. package/lib/__templates__/expo/client/index.js +0 -12
  232. package/lib/__templates__/expo/client/screens/home/index.tsx +0 -54
  233. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  234. package/lib/__templates__/expo/metro.config.js +0 -53
  235. package/lib/__templates__/expo/src/index.ts +0 -12
  236. package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
  237. package/lib/__templates__/nextjs/server.mjs +0 -50
  238. package/lib/__templates__/vite/.vscode/settings.json +0 -7
  239. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
@@ -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
+ }