@taicode/common-web 3.7.7 → 3.7.8

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 (271) hide show
  1. package/output/components/alert-dialog.d.ts +20 -0
  2. package/output/components/alert-dialog.d.ts.map +1 -0
  3. package/output/components/alert-dialog.js +65 -0
  4. package/output/components/alert.d.ts +11 -0
  5. package/output/components/alert.d.ts.map +1 -0
  6. package/output/components/alert.js +38 -0
  7. package/output/components/avatar.d.ts +13 -0
  8. package/output/components/avatar.d.ts.map +1 -0
  9. package/output/components/avatar.js +40 -0
  10. package/output/components/badge.d.ts +11 -0
  11. package/output/components/badge.d.ts.map +1 -0
  12. package/output/components/badge.js +39 -0
  13. package/output/components/button.d.ts +12 -0
  14. package/output/components/button.d.ts.map +1 -0
  15. package/output/components/button.js +48 -0
  16. package/output/components/calendar.d.ts +13 -0
  17. package/output/components/calendar.d.ts.map +1 -0
  18. package/output/components/calendar.js +57 -0
  19. package/output/components/card.d.ts +13 -0
  20. package/output/components/card.d.ts.map +1 -0
  21. package/output/components/card.js +43 -0
  22. package/output/components/chart.d.ts +56 -0
  23. package/output/components/chart.d.ts.map +1 -0
  24. package/output/components/chart.js +127 -0
  25. package/output/components/checkbox.d.ts +5 -0
  26. package/output/components/checkbox.d.ts.map +1 -0
  27. package/output/components/checkbox.js +21 -0
  28. package/output/components/command.d.ts +20 -0
  29. package/output/components/command.d.ts.map +1 -0
  30. package/output/components/command.js +55 -0
  31. package/output/components/dialog.d.ts +20 -0
  32. package/output/components/dialog.d.ts.map +1 -0
  33. package/output/components/dialog.js +58 -0
  34. package/output/components/direction.d.ts +9 -0
  35. package/output/components/direction.d.ts.map +1 -0
  36. package/output/components/direction.js +10 -0
  37. package/output/components/drawer.d.ts +14 -0
  38. package/output/components/drawer.d.ts.map +1 -0
  39. package/output/components/drawer.js +56 -0
  40. package/output/components/dropdown-menu.d.ts +29 -0
  41. package/output/components/dropdown-menu.d.ts.map +1 -0
  42. package/output/components/dropdown-menu.js +78 -0
  43. package/output/components/field.d.ts +39 -0
  44. package/output/components/field.d.ts.map +1 -0
  45. package/output/components/field.js +102 -0
  46. package/output/components/footer/index.d.ts +27 -0
  47. package/output/components/footer/index.d.ts.map +1 -0
  48. package/output/components/footer/index.js +17 -0
  49. package/output/components/form.d.ts +26 -0
  50. package/output/components/form.d.ts.map +1 -0
  51. package/output/components/form.js +69 -0
  52. package/output/components/index.d.ts +46 -0
  53. package/output/components/index.d.ts.map +1 -0
  54. package/output/components/index.js +45 -0
  55. package/output/components/input-group.d.ts +17 -0
  56. package/output/components/input-group.d.ts.map +1 -0
  57. package/output/components/input-group.js +75 -0
  58. package/output/components/input.d.ts +4 -0
  59. package/output/components/input.d.ts.map +1 -0
  60. package/output/components/input.js +19 -0
  61. package/output/components/item.d.ts +25 -0
  62. package/output/components/item.d.ts.map +1 -0
  63. package/output/components/item.js +89 -0
  64. package/output/components/json-view/index.d.ts +11 -0
  65. package/output/components/json-view/index.d.ts.map +1 -0
  66. package/output/components/json-view/index.js +52 -0
  67. package/output/components/json-view/lazy/index.d.ts +18 -0
  68. package/output/components/json-view/lazy/index.d.ts.map +1 -0
  69. package/output/components/json-view/lazy/index.js +22 -0
  70. package/output/components/kbd.d.ts +4 -0
  71. package/output/components/kbd.d.ts.map +1 -0
  72. package/output/components/kbd.js +22 -0
  73. package/output/components/label.d.ts +5 -0
  74. package/output/components/label.d.ts.map +1 -0
  75. package/output/components/label.js +20 -0
  76. package/output/components/list-actions/index.d.ts +23 -0
  77. package/output/components/list-actions/index.d.ts.map +1 -0
  78. package/output/components/list-actions/index.js +15 -0
  79. package/output/components/loading-button/index.d.ts +44 -0
  80. package/output/components/loading-button/index.d.ts.map +1 -0
  81. package/output/components/loading-button/index.js +75 -0
  82. package/output/components/loading-button/index.test.d.ts +2 -0
  83. package/output/components/loading-button/index.test.d.ts.map +1 -0
  84. package/output/components/loading-button/index.test.js +203 -0
  85. package/output/components/native-select.d.ts +9 -0
  86. package/output/components/native-select.d.ts.map +1 -0
  87. package/output/components/native-select.js +28 -0
  88. package/output/components/page-back-button/index.d.ts +8 -0
  89. package/output/components/page-back-button/index.d.ts.map +1 -0
  90. package/output/components/page-back-button/index.js +7 -0
  91. package/output/components/page-state.d.ts +19 -0
  92. package/output/components/page-state.d.ts.map +1 -0
  93. package/output/components/page-state.js +13 -0
  94. package/output/components/pagination/index.d.ts +34 -0
  95. package/output/components/pagination/index.d.ts.map +1 -0
  96. package/output/components/pagination/index.js +75 -0
  97. package/output/components/popover.d.ts +11 -0
  98. package/output/components/popover.d.ts.map +1 -0
  99. package/output/components/popover.js +44 -0
  100. package/output/components/progress.d.ts +5 -0
  101. package/output/components/progress.d.ts.map +1 -0
  102. package/output/components/progress.js +21 -0
  103. package/output/components/radio-group.d.ts +6 -0
  104. package/output/components/radio-group.d.ts.map +1 -0
  105. package/output/components/radio-group.js +25 -0
  106. package/output/components/route-pending-indicator/index.d.ts +20 -0
  107. package/output/components/route-pending-indicator/index.d.ts.map +1 -0
  108. package/output/components/route-pending-indicator/index.js +17 -0
  109. package/output/components/scroll-area.d.ts +6 -0
  110. package/output/components/scroll-area.d.ts.map +1 -0
  111. package/output/components/scroll-area.js +24 -0
  112. package/output/components/searchable-select/index.d.ts +41 -0
  113. package/output/components/searchable-select/index.d.ts.map +1 -0
  114. package/output/components/searchable-select/index.js +46 -0
  115. package/output/components/select.d.ts +17 -0
  116. package/output/components/select.d.ts.map +1 -0
  117. package/output/components/select.js +58 -0
  118. package/output/components/separator.d.ts +5 -0
  119. package/output/components/separator.d.ts.map +1 -0
  120. package/output/components/separator.js +20 -0
  121. package/output/components/sheet.d.ts +16 -0
  122. package/output/components/sheet.d.ts.map +1 -0
  123. package/output/components/sheet.js +58 -0
  124. package/output/components/sidebar.d.ts +78 -0
  125. package/output/components/sidebar.d.ts.map +1 -0
  126. package/output/components/sidebar.js +233 -0
  127. package/output/components/size-provider/index.d.ts +2 -0
  128. package/output/components/size-provider/index.d.ts.map +1 -0
  129. package/output/components/size-provider/index.js +1 -0
  130. package/output/components/size-provider/size-provider.d.ts +9 -0
  131. package/output/components/size-provider/size-provider.d.ts.map +1 -0
  132. package/output/components/size-provider/size-provider.js +29 -0
  133. package/output/components/skeleton.d.ts +3 -0
  134. package/output/components/skeleton.d.ts.map +1 -0
  135. package/output/components/skeleton.js +18 -0
  136. package/output/components/sonner.d.ts +8 -0
  137. package/output/components/sonner.d.ts.map +1 -0
  138. package/output/components/sonner.js +34 -0
  139. package/output/components/spinner.d.ts +3 -0
  140. package/output/components/spinner.d.ts.map +1 -0
  141. package/output/components/spinner.js +19 -0
  142. package/output/components/switch.d.ts +8 -0
  143. package/output/components/switch.d.ts.map +1 -0
  144. package/output/components/switch.js +20 -0
  145. package/output/components/table.d.ts +11 -0
  146. package/output/components/table.d.ts.map +1 -0
  147. package/output/components/table.js +47 -0
  148. package/output/components/tabs.d.ts +12 -0
  149. package/output/components/tabs.d.ts.map +1 -0
  150. package/output/components/tabs.js +45 -0
  151. package/output/components/textarea.d.ts +4 -0
  152. package/output/components/textarea.d.ts.map +1 -0
  153. package/output/components/textarea.js +19 -0
  154. package/output/components/theme-switcher.d.ts +6 -0
  155. package/output/components/theme-switcher.d.ts.map +1 -0
  156. package/output/components/theme-switcher.js +19 -0
  157. package/output/components/toaster/index.d.ts +16 -0
  158. package/output/components/toaster/index.d.ts.map +1 -0
  159. package/output/components/toaster/index.js +70 -0
  160. package/output/components/toggle-group.d.ts +12 -0
  161. package/output/components/toggle-group.d.ts.map +1 -0
  162. package/output/components/toggle-group.js +38 -0
  163. package/output/components/toggle.d.ts +10 -0
  164. package/output/components/toggle.d.ts.map +1 -0
  165. package/output/components/toggle.js +38 -0
  166. package/output/components/tooltip.d.ts +8 -0
  167. package/output/components/tooltip.d.ts.map +1 -0
  168. package/output/components/tooltip.js +33 -0
  169. package/output/features/confirm-dialog/index.d.ts +41 -0
  170. package/output/features/confirm-dialog/index.d.ts.map +1 -0
  171. package/output/features/confirm-dialog/index.js +19 -0
  172. package/output/features/input-confirm/index.d.ts +26 -0
  173. package/output/features/input-confirm/index.d.ts.map +1 -0
  174. package/output/features/input-confirm/index.js +59 -0
  175. package/output/features/signin/context.d.ts +14 -0
  176. package/output/features/signin/context.d.ts.map +1 -0
  177. package/output/features/signin/context.js +13 -0
  178. package/output/features/signin/index.d.ts +58 -0
  179. package/output/features/signin/index.d.ts.map +1 -0
  180. package/output/features/signin/index.js +137 -0
  181. package/output/features/signin/service.d.ts +92 -0
  182. package/output/features/signin/service.d.ts.map +1 -0
  183. package/output/features/signin/service.js +519 -0
  184. package/output/features/signin/service.test.d.ts +2 -0
  185. package/output/features/signin/service.test.d.ts.map +1 -0
  186. package/output/features/signin/service.test.js +211 -0
  187. package/output/features/signin/types.d.ts +63 -0
  188. package/output/features/signin/types.d.ts.map +1 -0
  189. package/output/features/signin/types.js +1 -0
  190. package/output/hooks/use-loading/index.d.ts +6 -0
  191. package/output/hooks/use-loading/index.d.ts.map +1 -0
  192. package/output/hooks/use-loading/index.js +14 -0
  193. package/output/hooks/use-loading/index.test.d.ts +2 -0
  194. package/output/hooks/use-loading/index.test.d.ts.map +1 -0
  195. package/output/hooks/use-loading/index.test.js +24 -0
  196. package/output/hooks/use-mobile/index.d.ts +2 -0
  197. package/output/hooks/use-mobile/index.d.ts.map +1 -0
  198. package/output/hooks/use-mobile/index.js +16 -0
  199. package/output/hooks/use-observer/index.d.ts +2 -0
  200. package/output/hooks/use-observer/index.d.ts.map +1 -0
  201. package/output/hooks/use-observer/index.js +1 -0
  202. package/output/hooks/use-observer/use-observer.d.ts +3 -0
  203. package/output/hooks/use-observer/use-observer.d.ts.map +1 -0
  204. package/output/hooks/use-observer/use-observer.js +16 -0
  205. package/output/hooks/use-observer/use-observer.test.d.ts +2 -0
  206. package/output/hooks/use-observer/use-observer.test.d.ts.map +1 -0
  207. package/output/hooks/use-observer/use-observer.test.js +134 -0
  208. package/output/hooks/use-offline/index.d.ts +6 -0
  209. package/output/hooks/use-offline/index.d.ts.map +1 -0
  210. package/output/hooks/use-offline/index.js +19 -0
  211. package/output/layout/app/index.d.ts +34 -0
  212. package/output/layout/app/index.d.ts.map +1 -0
  213. package/output/layout/app/index.js +34 -0
  214. package/output/layout/dashboard/index.d.ts +76 -0
  215. package/output/layout/dashboard/index.d.ts.map +1 -0
  216. package/output/layout/dashboard/index.js +84 -0
  217. package/output/layout/index.d.ts +3 -0
  218. package/output/layout/index.d.ts.map +1 -0
  219. package/output/layout/index.js +2 -0
  220. package/output/services/cache-api/cache-api.d.ts +23 -0
  221. package/output/services/cache-api/cache-api.d.ts.map +1 -0
  222. package/output/services/cache-api/cache-api.js +145 -0
  223. package/output/services/cache-api/cache-api.test.d.ts +2 -0
  224. package/output/services/cache-api/cache-api.test.d.ts.map +1 -0
  225. package/output/services/cache-api/cache-api.test.js +610 -0
  226. package/output/services/cache-api/index.d.ts +2 -0
  227. package/output/services/cache-api/index.d.ts.map +1 -0
  228. package/output/services/cache-api/index.js +1 -0
  229. package/output/services/cached-fetch/index.d.ts +50 -0
  230. package/output/services/cached-fetch/index.d.ts.map +1 -0
  231. package/output/services/cached-fetch/index.js +196 -0
  232. package/output/services/service/index.d.ts +2 -0
  233. package/output/services/service/index.d.ts.map +1 -0
  234. package/output/services/service/index.js +1 -0
  235. package/output/services/service/service.d.ts +135 -0
  236. package/output/services/service/service.d.ts.map +1 -0
  237. package/output/services/service/service.js +276 -0
  238. package/output/services/service/service.test.d.ts +2 -0
  239. package/output/services/service/service.test.d.ts.map +1 -0
  240. package/output/services/service/service.test.js +1399 -0
  241. package/output/services/side-cache/index.d.ts +2 -0
  242. package/output/services/side-cache/index.d.ts.map +1 -0
  243. package/output/services/side-cache/index.js +1 -0
  244. package/output/services/side-cache/side-cache.d.ts +11 -0
  245. package/output/services/side-cache/side-cache.d.ts.map +1 -0
  246. package/output/services/side-cache/side-cache.js +161 -0
  247. package/output/services/side-cache/side-cache.test.d.ts +2 -0
  248. package/output/services/side-cache/side-cache.test.d.ts.map +1 -0
  249. package/output/services/side-cache/side-cache.test.js +271 -0
  250. package/output/utils/avatar/index.d.ts +28 -0
  251. package/output/utils/avatar/index.d.ts.map +1 -0
  252. package/output/utils/avatar/index.js +35 -0
  253. package/output/utils/delay/index.d.ts +2 -0
  254. package/output/utils/delay/index.d.ts.map +1 -0
  255. package/output/utils/delay/index.js +5 -0
  256. package/output/utils/form/index.d.ts +3 -0
  257. package/output/utils/form/index.d.ts.map +1 -0
  258. package/output/utils/form/index.js +1 -0
  259. package/output/utils/merge-class-names/index.d.ts +3 -0
  260. package/output/utils/merge-class-names/index.d.ts.map +1 -0
  261. package/output/utils/merge-class-names/index.js +5 -0
  262. package/output/utils/merge-class-names/index.test.d.ts +2 -0
  263. package/output/utils/merge-class-names/index.test.d.ts.map +1 -0
  264. package/output/utils/merge-class-names/index.test.js +7 -0
  265. package/output/utils/performance/index.d.ts +82 -0
  266. package/output/utils/performance/index.d.ts.map +1 -0
  267. package/output/utils/performance/index.js +129 -0
  268. package/output/utils/redirect/index.d.ts +6 -0
  269. package/output/utils/redirect/index.d.ts.map +1 -0
  270. package/output/utils/redirect/index.js +32 -0
  271. package/package.json +2 -2
@@ -0,0 +1,47 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from "react";
14
+ import { mergeClassNames } from "../utils/merge-class-names/index.js";
15
+ function Table(params) {
16
+ const { className } = params, props = __rest(params, ["className"]);
17
+ return (_jsx("div", { "data-slot": "table-container", className: "relative w-full overflow-x-auto", children: _jsx("table", Object.assign({ "data-slot": "table", className: mergeClassNames("w-full caption-bottom text-sm", className) }, props)) }));
18
+ }
19
+ function TableHeader(params) {
20
+ const { className } = params, props = __rest(params, ["className"]);
21
+ return (_jsx("thead", Object.assign({ "data-slot": "table-header", className: mergeClassNames("[&_tr]:border-b", className) }, props)));
22
+ }
23
+ function TableBody(params) {
24
+ const { className } = params, props = __rest(params, ["className"]);
25
+ return (_jsx("tbody", Object.assign({ "data-slot": "table-body", className: mergeClassNames("[&_tr:last-child]:border-0", className) }, props)));
26
+ }
27
+ function TableFooter(params) {
28
+ const { className } = params, props = __rest(params, ["className"]);
29
+ return (_jsx("tfoot", Object.assign({ "data-slot": "table-footer", className: mergeClassNames("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className) }, props)));
30
+ }
31
+ function TableRow(params) {
32
+ const { className } = params, props = __rest(params, ["className"]);
33
+ return (_jsx("tr", Object.assign({ "data-slot": "table-row", className: mergeClassNames("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className) }, props)));
34
+ }
35
+ function TableHead(params) {
36
+ const { className } = params, props = __rest(params, ["className"]);
37
+ return (_jsx("th", Object.assign({ "data-slot": "table-head", className: mergeClassNames("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0", className) }, props)));
38
+ }
39
+ function TableCell(params) {
40
+ const { className } = params, props = __rest(params, ["className"]);
41
+ return (_jsx("td", Object.assign({ "data-slot": "table-cell", className: mergeClassNames("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0", className) }, props)));
42
+ }
43
+ function TableCaption(params) {
44
+ const { className } = params, props = __rest(params, ["className"]);
45
+ return (_jsx("caption", Object.assign({ "data-slot": "table-caption", className: mergeClassNames("text-muted-foreground mt-4 text-sm", className) }, props)));
46
+ }
47
+ export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ import { Tabs as TabsPrimitive } from "radix-ui";
4
+ declare function Tabs(params: React.ComponentProps<typeof TabsPrimitive.Root>): React.JSX.Element;
5
+ declare const tabsListVariants: (props?: ({
6
+ variant?: "default" | "line" | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
+ declare function TabsList(params: React.ComponentProps<typeof TabsPrimitive.List> & VariantProps<typeof tabsListVariants>): React.JSX.Element;
9
+ declare function TabsTrigger(params: React.ComponentProps<typeof TabsPrimitive.Trigger>): React.JSX.Element;
10
+ declare function TabsContent(params: React.ComponentProps<typeof TabsPrimitive.Content>): React.JSX.Element;
11
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
12
+ //# sourceMappingURL=tabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../source/components/tabs.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAIhD,iBAAS,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,qBAiBpE;AAED,QAAA,MAAM,gBAAgB;;8EAarB,CAAA;AAED,iBAAS,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,IAAI,CAAC,GACvE,YAAY,CAAC,OAAO,gBAAgB,CAAC,qBActC;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,qBAkB9E;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,OAAO,CAAC,qBAY9E;AAED,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAA"}
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import * as React from "react";
15
+ import { cva } from "class-variance-authority";
16
+ import { Tabs as TabsPrimitive } from "radix-ui";
17
+ import { mergeClassNames } from "../utils/merge-class-names/index.js";
18
+ function Tabs(params) {
19
+ const { className, orientation = "horizontal" } = params, props = __rest(params, ["className", "orientation"]);
20
+ return (_jsx(TabsPrimitive.Root, Object.assign({ "data-slot": "tabs", "data-orientation": orientation, className: mergeClassNames("gap-2 group/tabs flex data-[orientation=horizontal]:flex-col", className) }, props)));
21
+ }
22
+ const tabsListVariants = cva("rounded-lg p-[3px] group-data-horizontal/tabs:h-9 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col", {
23
+ variants: {
24
+ variant: {
25
+ default: "bg-muted",
26
+ line: "gap-1 bg-transparent",
27
+ },
28
+ },
29
+ defaultVariants: {
30
+ variant: "default",
31
+ },
32
+ });
33
+ function TabsList(params) {
34
+ const { className, variant = "default" } = params, props = __rest(params, ["className", "variant"]);
35
+ return (_jsx(TabsPrimitive.List, Object.assign({ "data-slot": "tabs-list", "data-variant": variant, className: mergeClassNames(tabsListVariants({ variant }), className) }, props)));
36
+ }
37
+ function TabsTrigger(params) {
38
+ const { className } = params, props = __rest(params, ["className"]);
39
+ return (_jsx(TabsPrimitive.Trigger, Object.assign({ "data-slot": "tabs-trigger", className: mergeClassNames("gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent", "data-active:bg-background dark:data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 data-active:text-foreground", "after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100", className) }, props)));
40
+ }
41
+ function TabsContent(params) {
42
+ const { className } = params, props = __rest(params, ["className"]);
43
+ return (_jsx(TabsPrimitive.Content, Object.assign({ "data-slot": "tabs-content", className: mergeClassNames("text-sm flex-1 outline-none", className) }, props)));
44
+ }
45
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants };
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ declare function Textarea(params: React.ComponentProps<'textarea'>): React.JSX.Element;
3
+ export { Textarea };
4
+ //# sourceMappingURL=textarea.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../source/components/textarea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,iBAAS,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,qBAYzD;AAED,OAAO,EAAE,QAAQ,EAAE,CAAA"}
@@ -0,0 +1,19 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { mergeClassNames } from '../utils/merge-class-names/index.js';
15
+ function Textarea(params) {
16
+ const { className } = params, props = __rest(params, ["className"]);
17
+ return (_jsx("textarea", Object.assign({ "data-slot": "textarea", className: mergeClassNames('border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 rounded-md border bg-transparent px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] focus-visible:ring-[3px] aria-invalid:ring-[3px] md:text-sm placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50', className) }, props)));
18
+ }
19
+ export { Textarea };
@@ -0,0 +1,6 @@
1
+ export interface ThemeSwitcherProps {
2
+ toLightLabel?: string;
3
+ toDarkLabel?: string;
4
+ }
5
+ export declare function ThemeSwitcher(props: ThemeSwitcherProps): import("react").JSX.Element;
6
+ //# sourceMappingURL=theme-switcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-switcher.d.ts","sourceRoot":"","sources":["../../source/components/theme-switcher.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BA2BtD"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { Moon, Sun } from 'lucide-react';
4
+ import { Button } from './button.js';
5
+ export function ThemeSwitcher(props) {
6
+ const { toLightLabel = 'Switch to light mode', toDarkLabel = 'Switch to dark mode' } = props;
7
+ const [theme, setTheme] = useState(() => {
8
+ const savedTheme = localStorage.getItem('theme');
9
+ if (savedTheme === 'dark' || savedTheme === 'light')
10
+ return savedTheme;
11
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
12
+ });
13
+ useEffect(() => {
14
+ document.documentElement.classList.toggle('dark', theme === 'dark');
15
+ localStorage.setItem('theme', theme);
16
+ }, [theme]);
17
+ const label = theme === 'dark' ? toLightLabel : toDarkLabel;
18
+ return (_jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", onClick: () => setTheme(current => current === 'light' ? 'dark' : 'light'), "aria-label": label, title: label, children: theme === 'dark' ? _jsx(Sun, { className: "size-4" }) : _jsx(Moon, { className: "size-4" }) }));
19
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ interface ToastCatcherProps {
3
+ defaultMessage?: string;
4
+ children: React.ReactNode;
5
+ messages: Partial<Record<string, string>>;
6
+ }
7
+ /** 自动捕获和处理异步错误,无法识别的错误会保持原样 */
8
+ export declare function Toaster(props: ToastCatcherProps): React.JSX.Element;
9
+ export declare namespace Toaster {
10
+ var info: (content: React.ReactNode) => void;
11
+ var error: (content: React.ReactNode) => void;
12
+ var success: (content: React.ReactNode) => void;
13
+ var warning: (content: React.ReactNode) => void;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/components/toaster/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAA;AAIhD,UAAU,iBAAiB;IACzB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAC1C;AAED,+BAA+B;AAC/B,wBAAgB,OAAO,CAAC,KAAK,EAAE,iBAAiB,qBAkE/C;yBAlEe,OAAO;wBA2EE,KAAK,CAAC,SAAS;yBAId,KAAK,CAAC,SAAS;2BAIb,KAAK,CAAC,SAAS;2BAIf,KAAK,CAAC,SAAS"}
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useEffect, useRef } from 'react';
3
+ import { toast, Toaster as SonnerToaster } from 'sonner';
4
+ import { SystemError, UserError } from '@taicode/common-base';
5
+ /** 自动捕获和处理异步错误,无法识别的错误会保持原样 */
6
+ export function Toaster(props) {
7
+ const addEventListened = useRef(false);
8
+ const { messages = {}, defaultMessage } = props;
9
+ const handledErrors = useRef(new WeakSet());
10
+ useEffect(() => {
11
+ if (addEventListened.current)
12
+ return;
13
+ const errorHandler = (event) => {
14
+ const errorObject = event.error;
15
+ // 检查是否已经处理过这个错误对象
16
+ if (errorObject && handledErrors.current.has(errorObject)) {
17
+ event.preventDefault();
18
+ event.stopPropagation();
19
+ return;
20
+ }
21
+ if (SystemError.is(errorObject) || UserError.is(errorObject)) {
22
+ console.error('Caught error:', errorObject);
23
+ // 标记此错误已处理
24
+ handledErrors.current.add(errorObject);
25
+ event.preventDefault();
26
+ event.stopPropagation();
27
+ Toaster.error(messages[errorObject.type] || defaultMessage);
28
+ }
29
+ };
30
+ const unhandledRejectionHandler = (event) => {
31
+ const errorObject = event.reason;
32
+ // 检查是否已经处理过这个错误对象
33
+ if (errorObject && handledErrors.current.has(errorObject)) {
34
+ event.preventDefault();
35
+ event.stopPropagation();
36
+ return;
37
+ }
38
+ if (SystemError.is(errorObject) || UserError.is(errorObject)) {
39
+ console.error('Caught error:', errorObject);
40
+ // 标记此错误已处理
41
+ handledErrors.current.add(errorObject);
42
+ event.preventDefault();
43
+ event.stopPropagation();
44
+ Toaster.error(messages[errorObject.type] || defaultMessage);
45
+ }
46
+ };
47
+ window.addEventListener('error', errorHandler, true);
48
+ window.addEventListener('unhandledrejection', unhandledRejectionHandler, true);
49
+ addEventListened.current = true;
50
+ return () => {
51
+ window.removeEventListener('error', errorHandler, true);
52
+ window.removeEventListener('unhandledrejection', unhandledRejectionHandler, true);
53
+ addEventListened.current = false;
54
+ handledErrors.current = new WeakSet();
55
+ };
56
+ }, []);
57
+ return (_jsxs(_Fragment, { children: [props.children, _jsx(SonnerToaster, { position: "top-center", closeButton: true })] }));
58
+ }
59
+ Toaster.info = (content) => {
60
+ toast.info(content);
61
+ };
62
+ Toaster.error = (content) => {
63
+ toast.error(content);
64
+ };
65
+ Toaster.success = (content) => {
66
+ toast.success(content);
67
+ };
68
+ Toaster.warning = (content) => {
69
+ toast.warning(content);
70
+ };
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui';
4
+ import { toggleVariants } from './toggle.js';
5
+ type ToggleGroupParams = {
6
+ spacing?: number;
7
+ orientation?: 'horizontal' | 'vertical';
8
+ };
9
+ declare function ToggleGroup(params: React.ComponentProps<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants> & ToggleGroupParams): React.JSX.Element;
10
+ declare function ToggleGroupItem(params: React.ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>): React.JSX.Element;
11
+ export { ToggleGroup, ToggleGroupItem };
12
+ //# sourceMappingURL=toggle-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle-group.d.ts","sourceRoot":"","sources":["../../source/components/toggle-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,WAAW,IAAI,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,KAAK,iBAAiB,GAAG;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAA;CACxC,CAAA;AAcD,iBAAS,WAAW,CAClB,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,oBAAoB,CAAC,IAAI,CAAC,GAC5D,YAAY,CAAC,OAAO,cAAc,CAAC,GACnC,iBAAiB,qBAsBpB;AAED,iBAAS,eAAe,CACtB,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,oBAAoB,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,qBAwBrG;AAED,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAA"}
@@ -0,0 +1,38 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { useContext } from 'react';
15
+ import {} from 'class-variance-authority';
16
+ import { ToggleGroup as ToggleGroupPrimitive } from 'radix-ui';
17
+ import { mergeClassNames } from '../utils/merge-class-names/index.js';
18
+ import { toggleVariants } from './toggle.js';
19
+ const ToggleGroupContext = React.createContext({
20
+ size: 'default',
21
+ variant: 'default',
22
+ spacing: 0,
23
+ orientation: 'horizontal',
24
+ });
25
+ function ToggleGroup(params) {
26
+ const { className, variant, size, spacing = 0, orientation = 'horizontal', children } = params, props = __rest(params, ["className", "variant", "size", "spacing", "orientation", "children"]);
27
+ return (_jsx(ToggleGroupPrimitive.Root, Object.assign({ "data-slot": "toggle-group", "data-variant": variant, "data-size": size, "data-spacing": spacing, "data-orientation": orientation, style: { '--gap': spacing }, className: mergeClassNames('rounded-md data-[spacing=0]:data-[variant=outline]:shadow-xs group/toggle-group flex w-fit flex-row items-center gap-(--spacing(var(--gap))) data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch', className) }, props, { children: _jsx(ToggleGroupContext.Provider, { value: { variant, size, spacing, orientation }, children: children }) })));
28
+ }
29
+ function ToggleGroupItem(params) {
30
+ var _a, _b, _c, _d;
31
+ const { className, children, variant = 'default', size = 'default' } = params, props = __rest(params, ["className", "children", "variant", "size"]);
32
+ const context = useContext(ToggleGroupContext);
33
+ return (_jsx(ToggleGroupPrimitive.Item, Object.assign({ "data-slot": "toggle-group-item", "data-variant": (_a = context.variant) !== null && _a !== void 0 ? _a : variant, "data-size": (_b = context.size) !== null && _b !== void 0 ? _b : size, "data-spacing": context.spacing, className: mergeClassNames('data-[state=on]:bg-muted group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 group-data-[spacing=0]/toggle-group:shadow-none group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md shrink-0 focus:z-10 focus-visible:z-10 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t', toggleVariants({
34
+ variant: (_c = context.variant) !== null && _c !== void 0 ? _c : variant,
35
+ size: (_d = context.size) !== null && _d !== void 0 ? _d : size,
36
+ }), className) }, props, { children: children })));
37
+ }
38
+ export { ToggleGroup, ToggleGroupItem };
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { type VariantProps } from 'class-variance-authority';
3
+ import { Toggle as TogglePrimitive } from 'radix-ui';
4
+ declare const toggleVariants: (props?: ({
5
+ variant?: "default" | "outline" | null | undefined;
6
+ size?: "default" | "sm" | "lg" | null | undefined;
7
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
+ declare function Toggle(params: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>): React.JSX.Element;
9
+ export { Toggle, toggleVariants };
10
+ //# sourceMappingURL=toggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../source/components/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,UAAU,CAAA;AAIpD,QAAA,MAAM,cAAc;;;8EAmBnB,CAAA;AAED,iBAAS,MAAM,CACb,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,cAAc,CAAC,qBAUhG;AAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,38 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import * as React from 'react';
14
+ import { cva } from 'class-variance-authority';
15
+ import { Toggle as TogglePrimitive } from 'radix-ui';
16
+ import { mergeClassNames } from '../utils/merge-class-names/index.js';
17
+ const toggleVariants = cva("hover:text-foreground aria-pressed:bg-muted focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive gap-1 rounded-md text-sm font-medium transition-[color,box-shadow] [&_svg:not([class*='size-'])]:size-4 group/toggle hover:bg-muted inline-flex items-center justify-center whitespace-nowrap outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
18
+ variants: {
19
+ variant: {
20
+ default: 'bg-transparent',
21
+ outline: 'border-input hover:bg-muted border bg-transparent shadow-xs',
22
+ },
23
+ size: {
24
+ default: 'h-9 min-w-9 px-2',
25
+ sm: 'h-8 min-w-8 px-1.5',
26
+ lg: 'h-10 min-w-10 px-2.5',
27
+ },
28
+ },
29
+ defaultVariants: {
30
+ variant: 'default',
31
+ size: 'default',
32
+ },
33
+ });
34
+ function Toggle(params) {
35
+ const { className, variant = 'default', size = 'default' } = params, props = __rest(params, ["className", "variant", "size"]);
36
+ return (_jsx(TogglePrimitive.Root, Object.assign({ "data-slot": "toggle", className: mergeClassNames(toggleVariants({ variant, size, className })) }, props)));
37
+ }
38
+ export { Toggle, toggleVariants };
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ import { Tooltip as TooltipPrimitive } from "radix-ui";
3
+ declare function TooltipProvider(params: React.ComponentProps<typeof TooltipPrimitive.Provider>): React.JSX.Element;
4
+ declare function Tooltip(params: React.ComponentProps<typeof TooltipPrimitive.Root>): React.JSX.Element;
5
+ declare function TooltipTrigger(params: React.ComponentProps<typeof TooltipPrimitive.Trigger>): React.JSX.Element;
6
+ declare function TooltipContent(params: React.ComponentProps<typeof TooltipPrimitive.Content>): React.JSX.Element;
7
+ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
8
+ //# sourceMappingURL=tooltip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../source/components/tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAItD,iBAAS,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,qBAYtF;AAED,iBAAS,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,qBAK1E;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,qBAKpF;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,qBAuBpF;AAED,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,CAAA"}
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import * as React from "react";
15
+ import { Tooltip as TooltipPrimitive } from "radix-ui";
16
+ import { mergeClassNames } from "../utils/merge-class-names/index.js";
17
+ function TooltipProvider(params) {
18
+ const { delayDuration = 0 } = params, props = __rest(params, ["delayDuration"]);
19
+ return (_jsx(TooltipPrimitive.Provider, Object.assign({ "data-slot": "tooltip-provider", delayDuration: delayDuration }, props)));
20
+ }
21
+ function Tooltip(params) {
22
+ const props = __rest(params, []);
23
+ return _jsx(TooltipPrimitive.Root, Object.assign({ "data-slot": "tooltip" }, props));
24
+ }
25
+ function TooltipTrigger(params) {
26
+ const props = __rest(params, []);
27
+ return _jsx(TooltipPrimitive.Trigger, Object.assign({ "data-slot": "tooltip-trigger" }, props));
28
+ }
29
+ function TooltipContent(params) {
30
+ const { className, sideOffset = 0, children } = params, props = __rest(params, ["className", "sideOffset", "children"]);
31
+ return (_jsx(TooltipPrimitive.Portal, { children: _jsxs(TooltipPrimitive.Content, Object.assign({ "data-slot": "tooltip-content", sideOffset: sideOffset, className: mergeClassNames("data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 rounded-md px-3 py-1.5 text-xs bg-foreground text-background z-50 w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin)", className) }, props, { children: [children, _jsx(TooltipPrimitive.Arrow, { className: "size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground z-50 translate-y-[calc(-50%_-_2px)]" })] })) }));
32
+ }
33
+ export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
@@ -0,0 +1,41 @@
1
+ import { type ReactNode } from 'react';
2
+ import { buttonVariants } from '../../components/button.js';
3
+ import type { VariantProps } from 'class-variance-authority';
4
+ interface ConfirmDialogProps {
5
+ /** 是否打开对话框 */
6
+ open: boolean;
7
+ /** 打开状态变化回调 */
8
+ onOpenChange: (open: boolean) => void;
9
+ /** 对话框标题 */
10
+ title: string;
11
+ /** 对话框描述 */
12
+ description?: string | ReactNode;
13
+ /** 确认按钮文本 */
14
+ confirmText?: string;
15
+ /** 取消按钮文本 */
16
+ cancelText?: string;
17
+ /** 确认按钮变体 */
18
+ variant?: VariantProps<typeof buttonVariants>['variant'];
19
+ /** 确认回调 */
20
+ onConfirm: () => void | Promise<void>;
21
+ /** 是否正在执行(显示加载状态) */
22
+ loading?: boolean;
23
+ /** 危险操作的影响范围提示 */
24
+ impact?: ReactNode;
25
+ /** 设置后需要输入完全一致的短语才能确认 */
26
+ confirmPhrase?: string;
27
+ /** 确认短语当前输入值 */
28
+ confirmValue?: string;
29
+ /** 确认短语输入回调 */
30
+ onConfirmValueChange?: (value: string) => void;
31
+ /** 确认短语输入标签模板 */
32
+ confirmPhraseLabel?: (phrase: string) => string;
33
+ /** 加载中按钮文本 */
34
+ loadingText?: string;
35
+ }
36
+ /**
37
+ * 统一的确认对话框组件
38
+ */
39
+ export declare function ConfirmDialog(params: ConfirmDialogProps): import("react").JSX.Element;
40
+ export {};
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/features/confirm-dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAavD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAI5D,UAAU,kBAAkB;IAC1B,cAAc;IACd,IAAI,EAAE,OAAO,CAAA;IACb,eAAe;IACf,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,YAAY;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,YAAY;IACZ,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa;IACb,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC,SAAS,CAAC,CAAA;IACxD,WAAW;IACX,SAAS,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,qBAAqB;IACrB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,kBAAkB;IAClB,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB,yBAAyB;IACzB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,gBAAgB;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,eAAe;IACf,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9C,iBAAiB;IACjB,kBAAkB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/C,cAAc;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,kBAAkB,+BA2DvD"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import {} from 'react';
3
+ import { AlertTriangle } from 'lucide-react';
4
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '../../components/alert-dialog.js';
5
+ import { buttonVariants } from '../../components/button.js';
6
+ import { mergeClassNames } from '../../utils/merge-class-names/index.js';
7
+ /**
8
+ * 统一的确认对话框组件
9
+ */
10
+ export function ConfirmDialog(params) {
11
+ const { open, onOpenChange, title, description, confirmText = 'Confirm', cancelText = 'Cancel', variant = 'default', onConfirm, loading = false, impact, confirmPhrase, confirmValue = '', onConfirmValueChange, confirmPhraseLabel = (phrase) => `Type "${phrase}" to confirm`, loadingText = 'Processing...', } = params;
12
+ const phraseValid = !confirmPhrase || confirmValue === confirmPhrase;
13
+ return (_jsx(AlertDialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(AlertDialogContent, { children: [_jsxs(AlertDialogHeader, { children: [_jsxs(AlertDialogTitle, { className: mergeClassNames(variant === 'destructive' && 'flex items-center gap-2'), children: [variant === 'destructive' && _jsx(AlertTriangle, { className: "size-5 text-destructive" }), title] }), description && _jsx(AlertDialogDescription, { children: description }), impact && _jsx("div", { className: "rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive", children: impact }), confirmPhrase && onConfirmValueChange && (_jsxs("div", { className: "space-y-2 text-sm", children: [_jsx("label", { htmlFor: "confirm-phrase", children: confirmPhraseLabel(confirmPhrase) }), _jsx("input", { id: "confirm-phrase", value: confirmValue, onChange: event => onConfirmValueChange(event.target.value), className: "w-full rounded-md border bg-background px-3 py-2 outline-none focus-visible:ring-2 focus-visible:ring-ring", autoComplete: "off" })] }))] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: loading, children: cancelText }), _jsx(AlertDialogAction, { className: mergeClassNames(buttonVariants({ variant }), loading && 'opacity-50 cursor-not-allowed'), onClick: (e) => {
14
+ e.preventDefault();
15
+ if (!loading) {
16
+ onConfirm();
17
+ }
18
+ }, disabled: loading || !phraseValid, children: loading ? loadingText : confirmText })] })] }) }));
19
+ }
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ type InputConfirmContextType = {
3
+ resolve: (value: string) => Promise<unknown>;
4
+ };
5
+ export interface InputConfirmProviderProps extends React.PropsWithChildren {
6
+ /**
7
+ * 标题文案
8
+ */
9
+ title?: string;
10
+ /**
11
+ * 描述文案模板
12
+ */
13
+ description?: (value?: string) => string;
14
+ /**
15
+ * 取消按钮文案
16
+ */
17
+ cancelText?: string;
18
+ /**
19
+ * 确认按钮文案
20
+ */
21
+ confirmText?: string;
22
+ }
23
+ export declare function InputConfirmProvider(props: InputConfirmProviderProps): React.JSX.Element;
24
+ export declare function useInputConfirm(): InputConfirmContextType;
25
+ export {};
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/features/input-confirm/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAexE,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC7C,CAAA;AAQD,MAAM,WAAW,yBAA0B,SAAQ,KAAK,CAAC,iBAAiB;IACxE;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;IACxC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,qBAmFpE;AAGD,wBAAgB,eAAe,4BAK9B"}
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useCallback, useContext, useRef, useState } from 'react';
3
+ import { useForm } from 'react-hook-form';
4
+ import { LoadingButton } from '../../components/loading-button/index.js';
5
+ import { Button } from '../../components/button.js';
6
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '../../components/dialog.js';
7
+ import { Input } from '../../components/input.js';
8
+ const InputConfirmContext = React.createContext(null);
9
+ export function InputConfirmProvider(props) {
10
+ const { title = 'Confirm Action', description = (value) => `Type "${value}" to confirm`, cancelText = 'Cancel', confirmText = 'Confirm', children, } = props;
11
+ const [open, setOpen] = useState(false);
12
+ const [value, setValue] = useState();
13
+ const rejectRef = useRef(undefined);
14
+ const resolveRef = useRef(undefined);
15
+ const form = useForm({ defaultValues: { value: '' } });
16
+ const handleResolve = useCallback((value) => {
17
+ if (rejectRef.current != null || resolveRef.current != null) {
18
+ throw new Error('There are previous confirmations that are not completed');
19
+ }
20
+ const promise = new Promise((resolve, reject) => {
21
+ resolveRef.current = resolve;
22
+ rejectRef.current = reject;
23
+ setValue(value);
24
+ setOpen(true);
25
+ });
26
+ return promise;
27
+ }, []);
28
+ const clearPromiseRef = () => {
29
+ rejectRef.current = undefined;
30
+ resolveRef.current = undefined;
31
+ };
32
+ const handleClose = () => {
33
+ var _a;
34
+ (_a = rejectRef.current) === null || _a === void 0 ? void 0 : _a.call(rejectRef, undefined);
35
+ clearPromiseRef();
36
+ form.reset();
37
+ setOpen(false);
38
+ };
39
+ const handleTry = useCallback((formData) => {
40
+ var _a;
41
+ if (formData.value === value) {
42
+ (_a = resolveRef.current) === null || _a === void 0 ? void 0 : _a.call(resolveRef, undefined);
43
+ clearPromiseRef();
44
+ form.reset();
45
+ setOpen(false);
46
+ }
47
+ }, [value, form]);
48
+ const onSubmit = useCallback(() => {
49
+ form.handleSubmit(handleTry)();
50
+ }, [form, handleTry]);
51
+ return (_jsxs(InputConfirmContext.Provider, { value: { resolve: handleResolve }, children: [_jsx(Dialog, { open: open, onOpenChange: (isOpen) => !isOpen && handleClose(), children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: title }), _jsx(DialogDescription, { children: description(value) })] }), _jsx("div", { className: "py-4", children: _jsx(Input, Object.assign({}, form.register('value', { validate: v => v === value }))) }), _jsxs(DialogFooter, { children: [_jsx(LoadingButton, { as: Button, variant: "outline", onClick: handleClose, children: cancelText }), _jsx(Button, { disabled: !form.formState.isValid, onClick: onSubmit, children: confirmText })] })] }) }), children] }));
52
+ }
53
+ // eslint-disable-next-line react-refresh/only-export-components
54
+ export function useInputConfirm() {
55
+ const ctx = useContext(InputConfirmContext);
56
+ if (ctx == null)
57
+ throw new Error('InputConfirm context not found');
58
+ return ctx;
59
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * 登录上下文值
3
+ */
4
+ interface SigninContextValue {
5
+ signin: () => Promise<void>;
6
+ }
7
+ export declare const SigninContext: import("react").Context<SigninContextValue | null>;
8
+ /**
9
+ * 使用登录上下文
10
+ * 用于在任何子组件中调用登录方法
11
+ */
12
+ export declare function useSignin(): SigninContextValue;
13
+ export {};
14
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../source/features/signin/context.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B;AAED,eAAO,MAAM,aAAa,oDAAiD,CAAA;AAE3E;;;GAGG;AACH,wBAAgB,SAAS,uBAMxB"}