@demokit-ui/demokit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/README.md +128 -0
  2. package/dist/app/background-decor.d.ts +1 -0
  3. package/dist/app/background-decor.js +38 -0
  4. package/dist/app/container.d.ts +12 -0
  5. package/dist/app/container.js +29 -0
  6. package/dist/app/demo1-shell.d.ts +43 -0
  7. package/dist/app/demo1-shell.js +616 -0
  8. package/dist/app/tweak-panel.d.ts +22 -0
  9. package/dist/app/tweak-panel.js +182 -0
  10. package/dist/components/apexcharts.css +101 -0
  11. package/dist/components/scrollable.css +120 -0
  12. package/dist/config/settings.config.d.ts +2 -0
  13. package/dist/config/settings.config.js +33 -0
  14. package/dist/config/types.d.ts +50 -0
  15. package/dist/config.reui.css +337 -0
  16. package/dist/demos/demo1.css +176 -0
  17. package/dist/index.d.ts +14 -0
  18. package/dist/index.js +484 -0
  19. package/dist/kit/components/chart/chart/chart.d.ts +57 -0
  20. package/dist/kit/components/chart/chart/chart.js +206 -0
  21. package/dist/kit/components/composite/action-bar/action-bar.d.ts +10 -0
  22. package/dist/kit/components/composite/action-bar/action-bar.js +38 -0
  23. package/dist/kit/components/composite/action-card/action-card.d.ts +13 -0
  24. package/dist/kit/components/composite/action-card/action-card.js +35 -0
  25. package/dist/kit/components/composite/activity-feed/activity-feed.d.ts +17 -0
  26. package/dist/kit/components/composite/activity-feed/activity-feed.js +26 -0
  27. package/dist/kit/components/composite/alert-card/alert-card.d.ts +10 -0
  28. package/dist/kit/components/composite/alert-card/alert-card.js +37 -0
  29. package/dist/kit/components/composite/approval-flow/approval-flow.d.ts +51 -0
  30. package/dist/kit/components/composite/approval-flow/approval-flow.js +185 -0
  31. package/dist/kit/components/composite/auth-shell/auth-shell.d.ts +10 -0
  32. package/dist/kit/components/composite/auth-shell/auth-shell.js +32 -0
  33. package/dist/kit/components/composite/board-toolbar/board-toolbar.d.ts +12 -0
  34. package/dist/kit/components/composite/board-toolbar/board-toolbar.js +44 -0
  35. package/dist/kit/components/composite/chart-card/chart-card.d.ts +14 -0
  36. package/dist/kit/components/composite/chart-card/chart-card.js +64 -0
  37. package/dist/kit/components/composite/chart-toolbar/chart-toolbar.d.ts +17 -0
  38. package/dist/kit/components/composite/chart-toolbar/chart-toolbar.js +48 -0
  39. package/dist/kit/components/composite/data-section/data-section.d.ts +17 -0
  40. package/dist/kit/components/composite/data-section/data-section.js +73 -0
  41. package/dist/kit/components/composite/description-grid/description-grid.d.ts +12 -0
  42. package/dist/kit/components/composite/description-grid/description-grid.js +36 -0
  43. package/dist/kit/components/composite/detail-header/detail-header.d.ts +19 -0
  44. package/dist/kit/components/composite/detail-header/detail-header.js +43 -0
  45. package/dist/kit/components/composite/filter-panel/filter-panel.d.ts +18 -0
  46. package/dist/kit/components/composite/filter-panel/filter-panel.js +86 -0
  47. package/dist/kit/components/composite/filter-toolbar/filter-toolbar.d.ts +14 -0
  48. package/dist/kit/components/composite/filter-toolbar/filter-toolbar.js +59 -0
  49. package/dist/kit/components/composite/forgot-password-form/forgot-password-form.d.ts +9 -0
  50. package/dist/kit/components/composite/forgot-password-form/forgot-password-form.js +34 -0
  51. package/dist/kit/components/composite/form-section/form-section.d.ts +9 -0
  52. package/dist/kit/components/composite/form-section/form-section.js +16 -0
  53. package/dist/kit/components/composite/kanban-board/kanban-board.d.ts +50 -0
  54. package/dist/kit/components/composite/kanban-board/kanban-board.js +55 -0
  55. package/dist/kit/components/composite/login-card/login-card.d.ts +33 -0
  56. package/dist/kit/components/composite/login-card/login-card.js +138 -0
  57. package/dist/kit/components/composite/message-list-card/message-list-card.d.ts +20 -0
  58. package/dist/kit/components/composite/message-list-card/message-list-card.js +83 -0
  59. package/dist/kit/components/composite/metric-card/metric-card.d.ts +18 -0
  60. package/dist/kit/components/composite/metric-card/metric-card.js +37 -0
  61. package/dist/kit/components/composite/milestone-card/milestone-card.d.ts +12 -0
  62. package/dist/kit/components/composite/milestone-card/milestone-card.js +33 -0
  63. package/dist/kit/components/composite/oauth-login-buttons/oauth-login-buttons.d.ts +14 -0
  64. package/dist/kit/components/composite/oauth-login-buttons/oauth-login-buttons.js +32 -0
  65. package/dist/kit/components/composite/page-header/page-header.d.ts +12 -0
  66. package/dist/kit/components/composite/page-header/page-header.js +66 -0
  67. package/dist/kit/components/composite/profile-card/profile-card.d.ts +16 -0
  68. package/dist/kit/components/composite/profile-card/profile-card.js +28 -0
  69. package/dist/kit/components/composite/progress-card/progress-card.d.ts +16 -0
  70. package/dist/kit/components/composite/progress-card/progress-card.js +23 -0
  71. package/dist/kit/components/composite/project-card/project-card.d.ts +17 -0
  72. package/dist/kit/components/composite/project-card/project-card.js +46 -0
  73. package/dist/kit/components/composite/shortcut-card/shortcut-card.d.ts +13 -0
  74. package/dist/kit/components/composite/shortcut-card/shortcut-card.js +35 -0
  75. package/dist/kit/components/composite/sprint-summary/sprint-summary.d.ts +15 -0
  76. package/dist/kit/components/composite/sprint-summary/sprint-summary.js +43 -0
  77. package/dist/kit/components/composite/state-panel/state-panel.d.ts +12 -0
  78. package/dist/kit/components/composite/state-panel/state-panel.js +79 -0
  79. package/dist/kit/components/composite/summary-card/summary-card.d.ts +15 -0
  80. package/dist/kit/components/composite/summary-card/summary-card.js +25 -0
  81. package/dist/kit/components/composite/task-card/task-card.d.ts +14 -0
  82. package/dist/kit/components/composite/task-card/task-card.js +49 -0
  83. package/dist/kit/components/composite/timeline/timeline.d.ts +46 -0
  84. package/dist/kit/components/composite/timeline/timeline.js +176 -0
  85. package/dist/kit/components/composite/todo-card/todo-card.d.ts +26 -0
  86. package/dist/kit/components/composite/todo-card/todo-card.js +101 -0
  87. package/dist/kit/components/data-display/avatar/avatar.d.ts +12 -0
  88. package/dist/kit/components/data-display/avatar/avatar.js +61 -0
  89. package/dist/kit/components/data-display/avatar-group/avatar-group.d.ts +22 -0
  90. package/dist/kit/components/data-display/avatar-group/avatar-group.js +184 -0
  91. package/dist/kit/components/data-display/badge/badge.d.ts +29 -0
  92. package/dist/kit/components/data-display/badge/badge.js +203 -0
  93. package/dist/kit/components/data-display/card/card.d.ts +15 -0
  94. package/dist/kit/components/data-display/card/card.js +119 -0
  95. package/dist/kit/components/data-display/data-grid/data-grid-column-filter.d.ts +15 -0
  96. package/dist/kit/components/data-display/data-grid/data-grid-column-filter.js +74 -0
  97. package/dist/kit/components/data-display/data-grid/data-grid-column-header.d.ts +12 -0
  98. package/dist/kit/components/data-display/data-grid/data-grid-column-header.js +171 -0
  99. package/dist/kit/components/data-display/data-grid/data-grid-column-visibility.d.ts +7 -0
  100. package/dist/kit/components/data-display/data-grid/data-grid-column-visibility.js +24 -0
  101. package/dist/kit/components/data-display/data-grid/data-grid-pagination.d.ts +15 -0
  102. package/dist/kit/components/data-display/data-grid/data-grid-pagination.js +132 -0
  103. package/dist/kit/components/data-display/data-grid/data-grid-table-dnd-rows.d.ts +9 -0
  104. package/dist/kit/components/data-display/data-grid/data-grid-table-dnd-rows.js +61 -0
  105. package/dist/kit/components/data-display/data-grid/data-grid-table-dnd.d.ts +5 -0
  106. package/dist/kit/components/data-display/data-grid/data-grid-table-dnd.js +86 -0
  107. package/dist/kit/components/data-display/data-grid/data-grid-table.d.ts +59 -0
  108. package/dist/kit/components/data-display/data-grid/data-grid-table.js +356 -0
  109. package/dist/kit/components/data-display/data-grid/data-grid.d.ts +87 -0
  110. package/dist/kit/components/data-display/data-grid/data-grid.js +87 -0
  111. package/dist/kit/components/data-display/kbd/kbd.d.ts +8 -0
  112. package/dist/kit/components/data-display/kbd/kbd.js +27 -0
  113. package/dist/kit/components/data-display/money-amount/money-amount.d.ts +27 -0
  114. package/dist/kit/components/data-display/money-amount/money-amount.js +91 -0
  115. package/dist/kit/components/data-display/progress/progress.d.ts +6 -0
  116. package/dist/kit/components/data-display/progress/progress.js +29 -0
  117. package/dist/kit/components/data-display/skeleton/skeleton.d.ts +3 -0
  118. package/dist/kit/components/data-display/skeleton/skeleton.js +8 -0
  119. package/dist/kit/components/data-display/sliding-number/sliding-number.d.ts +7 -0
  120. package/dist/kit/components/data-display/sliding-number/sliding-number.js +41 -0
  121. package/dist/kit/components/data-display/stepper/stepper.d.ts +61 -0
  122. package/dist/kit/components/data-display/stepper/stepper.js +230 -0
  123. package/dist/kit/components/data-display/table/table.d.ts +28 -0
  124. package/dist/kit/components/data-display/table/table.js +156 -0
  125. package/dist/kit/components/decorative/aurora-background/aurora-background.d.ts +7 -0
  126. package/dist/kit/components/decorative/aurora-background/aurora-background.js +60 -0
  127. package/dist/kit/components/decorative/grid-background/grid-background.d.ts +22 -0
  128. package/dist/kit/components/decorative/grid-background/grid-background.js +46 -0
  129. package/dist/kit/components/decorative/shimmering-text/shimmering-text.d.ts +29 -0
  130. package/dist/kit/components/decorative/shimmering-text/shimmering-text.js +64 -0
  131. package/dist/kit/components/decorative/text-reveal/text-reveal.d.ts +17 -0
  132. package/dist/kit/components/decorative/text-reveal/text-reveal.js +277 -0
  133. package/dist/kit/components/feedback/alert/alert.d.ts +21 -0
  134. package/dist/kit/components/feedback/alert/alert.js +236 -0
  135. package/dist/kit/components/feedback/alert-dialog/alert-dialog.d.ts +16 -0
  136. package/dist/kit/components/feedback/alert-dialog/alert-dialog.js +117 -0
  137. package/dist/kit/components/feedback/context-menu/context-menu.d.ts +24 -0
  138. package/dist/kit/components/feedback/context-menu/context-menu.js +183 -0
  139. package/dist/kit/components/feedback/dialog/dialog.d.ts +22 -0
  140. package/dist/kit/components/feedback/dialog/dialog.js +120 -0
  141. package/dist/kit/components/feedback/drawer/drawer.d.ts +13 -0
  142. package/dist/kit/components/feedback/drawer/drawer.js +76 -0
  143. package/dist/kit/components/feedback/dropdown-menu/dropdown-menu.d.ts +25 -0
  144. package/dist/kit/components/feedback/dropdown-menu/dropdown-menu.js +200 -0
  145. package/dist/kit/components/feedback/hover-card/hover-card.d.ts +6 -0
  146. package/dist/kit/components/feedback/hover-card/hover-card.js +34 -0
  147. package/dist/kit/components/feedback/popover/popover.d.ts +6 -0
  148. package/dist/kit/components/feedback/popover/popover.js +34 -0
  149. package/dist/kit/components/feedback/sheet/sheet.d.ts +22 -0
  150. package/dist/kit/components/feedback/sheet/sheet.js +128 -0
  151. package/dist/kit/components/feedback/sonner/sonner.d.ts +5 -0
  152. package/dist/kit/components/feedback/sonner/sonner.js +21 -0
  153. package/dist/kit/components/feedback/title-help/title-help.d.ts +10 -0
  154. package/dist/kit/components/feedback/title-help/title-help.js +44 -0
  155. package/dist/kit/components/feedback/tooltip/tooltip.d.ts +11 -0
  156. package/dist/kit/components/feedback/tooltip/tooltip.js +49 -0
  157. package/dist/kit/components/form/button/button.d.ts +23 -0
  158. package/dist/kit/components/form/button/button.js +380 -0
  159. package/dist/kit/components/form/calendar/calendar.d.ts +4 -0
  160. package/dist/kit/components/form/calendar/calendar.js +47 -0
  161. package/dist/kit/components/form/checkbox/checkbox.d.ts +8 -0
  162. package/dist/kit/components/form/checkbox/checkbox.js +39 -0
  163. package/dist/kit/components/form/command/command.d.ts +21 -0
  164. package/dist/kit/components/form/command/command.js +116 -0
  165. package/dist/kit/components/form/datefield/datefield.d.ts +14 -0
  166. package/dist/kit/components/form/datefield/datefield.js +74 -0
  167. package/dist/kit/components/form/file-upload/file-upload.d.ts +56 -0
  168. package/dist/kit/components/form/file-upload/file-upload.js +338 -0
  169. package/dist/kit/components/form/form/form.d.ts +24 -0
  170. package/dist/kit/components/form/form/form.js +86 -0
  171. package/dist/kit/components/form/input/input.d.ts +22 -0
  172. package/dist/kit/components/form/input/input.js +182 -0
  173. package/dist/kit/components/form/label/label.d.ts +8 -0
  174. package/dist/kit/components/form/label/label.js +28 -0
  175. package/dist/kit/components/form/radio-group/radio-group.d.ts +13 -0
  176. package/dist/kit/components/form/radio-group/radio-group.js +79 -0
  177. package/dist/kit/components/form/select/select.d.ts +25 -0
  178. package/dist/kit/components/form/select/select.js +194 -0
  179. package/dist/kit/components/form/slider/slider.d.ts +5 -0
  180. package/dist/kit/components/form/slider/slider.js +34 -0
  181. package/dist/kit/components/form/switch/switch.d.ts +20 -0
  182. package/dist/kit/components/form/switch/switch.js +158 -0
  183. package/dist/kit/components/form/textarea/textarea.d.ts +7 -0
  184. package/dist/kit/components/form/textarea/textarea.js +34 -0
  185. package/dist/kit/components/form/toggle/toggle.d.ts +9 -0
  186. package/dist/kit/components/form/toggle/toggle.js +36 -0
  187. package/dist/kit/components/form/toggle-group/toggle-group.d.ts +7 -0
  188. package/dist/kit/components/form/toggle-group/toggle-group.js +62 -0
  189. package/dist/kit/components/index.d.ts +108 -0
  190. package/dist/kit/components/layout/accordion/accordion.d.ts +13 -0
  191. package/dist/kit/components/layout/accordion/accordion.js +124 -0
  192. package/dist/kit/components/layout/aspect-ratio/aspect-ratio.d.ts +4 -0
  193. package/dist/kit/components/layout/aspect-ratio/aspect-ratio.js +8 -0
  194. package/dist/kit/components/layout/collapsible/collapsible.d.ts +6 -0
  195. package/dist/kit/components/layout/collapsible/collapsible.js +32 -0
  196. package/dist/kit/components/layout/resizable/resizable.d.ts +24 -0
  197. package/dist/kit/components/layout/resizable/resizable.js +32 -0
  198. package/dist/kit/components/layout/scroll-area/scroll-area.d.ts +8 -0
  199. package/dist/kit/components/layout/scroll-area/scroll-area.js +48 -0
  200. package/dist/kit/components/layout/separator/separator.d.ts +4 -0
  201. package/dist/kit/components/layout/separator/separator.js +23 -0
  202. package/dist/kit/components/navigation/accordion-menu/accordion-menu.d.ts +51 -0
  203. package/dist/kit/components/navigation/accordion-menu/accordion-menu.js +290 -0
  204. package/dist/kit/components/navigation/breadcrumb/breadcrumb.d.ts +13 -0
  205. package/dist/kit/components/navigation/breadcrumb/breadcrumb.js +76 -0
  206. package/dist/kit/components/navigation/menubar/menubar.d.ts +25 -0
  207. package/dist/kit/components/navigation/menubar/menubar.js +218 -0
  208. package/dist/kit/components/navigation/navigation-menu/navigation-menu.d.ts +14 -0
  209. package/dist/kit/components/navigation/navigation-menu/navigation-menu.js +137 -0
  210. package/dist/kit/components/navigation/pagination/pagination.d.ts +6 -0
  211. package/dist/kit/components/navigation/pagination/pagination.js +38 -0
  212. package/dist/kit/components/navigation/scrollspy/scrollspy.d.ts +14 -0
  213. package/dist/kit/components/navigation/scrollspy/scrollspy.js +84 -0
  214. package/dist/kit/components/navigation/tabs/tabs.d.ts +16 -0
  215. package/dist/kit/components/navigation/tabs/tabs.js +172 -0
  216. package/dist/kit/themes/theme-toggle.d.ts +1 -0
  217. package/dist/kit/themes/theme-toggle.js +56 -0
  218. package/dist/kit/tokens/chart-palette.d.ts +1 -0
  219. package/dist/kit/tokens/chart-palette.js +12 -0
  220. package/dist/lib/utils.d.ts +8 -0
  221. package/dist/lib/utils.js +8 -0
  222. package/dist/providers/demokit-provider.d.ts +4 -0
  223. package/dist/providers/demokit-provider.js +9 -0
  224. package/dist/providers/settings-provider.d.ts +15 -0
  225. package/dist/providers/settings-provider.js +78 -0
  226. package/dist/providers/theme-provider.d.ts +4 -0
  227. package/dist/providers/theme-provider.js +9 -0
  228. package/dist/providers/tooltips-provider.d.ts +4 -0
  229. package/dist/providers/tooltips-provider.js +8 -0
  230. package/dist/styles.css +237 -0
  231. package/package.json +72 -0
@@ -0,0 +1,74 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { cn as r } from "../../../../lib/utils.js";
3
+ import { inputVariants as o } from "../input/input.js";
4
+ import { DateField as l, composeRenderProps as n, DateInput as s, DateSegment as u, TimeField as c } from "react-aria-components";
5
+ function x({ className: t, children: e, ...a }) {
6
+ return /* @__PURE__ */ i(
7
+ l,
8
+ {
9
+ className: n(t, (d) => r(d)),
10
+ "data-slot": "datefield",
11
+ ...a,
12
+ children: e
13
+ }
14
+ );
15
+ }
16
+ function w({ className: t, children: e, ...a }) {
17
+ return /* @__PURE__ */ i(
18
+ c,
19
+ {
20
+ className: n(t, (d) => r(d)),
21
+ "data-slot": "datefield",
22
+ ...a,
23
+ children: e
24
+ }
25
+ );
26
+ }
27
+ function f({ className: t, ...e }) {
28
+ return /* @__PURE__ */ i(
29
+ u,
30
+ {
31
+ className: n(
32
+ t,
33
+ (a) => r(
34
+ `
35
+ text-foreground inline-flex rounded px-0.5 caret-transparent outline-hidden data-[type=literal]:text-muted-foreground/70 data-[type=literal]:px-0
36
+ data-placeholder:text-muted-foreground/70
37
+ data-invalid:data-focused:bg-destructive data-invalid:data-placeholder:text-destructive data-invalid:text-destructive data-invalid:data-focused:data-placeholder:text-destructive-foreground data-invalid:data-focused:text-destructive-foreground
38
+ data-focused:bg-accent data-focused:data-placeholder:text-foreground data-focused:text-foreground
39
+ data-disabled:cursor-not-allowed data-disabled:opacity-50
40
+ `,
41
+ a
42
+ )
43
+ ),
44
+ ...e,
45
+ "data-invalid": !0
46
+ }
47
+ );
48
+ }
49
+ const p = `
50
+ relative inline-flex items-center overflow-hidden whitespace-nowrap
51
+ data-focus-within:ring-ring/30 data-focus-within:border-ring data-focus-within:outline-none data-focus-within:ring-[3px]
52
+ data-focus-within:has-aria-invalid:ring-destructive/20 data-focus-within:has-aria-invalid:border-destructive
53
+ `;
54
+ function D({ className: t, variant: e = "md", ...a }) {
55
+ return /* @__PURE__ */ i(
56
+ s,
57
+ {
58
+ "data-slot": "input",
59
+ className: n(
60
+ t,
61
+ (d) => r(o({ variant: e }), p, d)
62
+ ),
63
+ ...a,
64
+ children: (d) => /* @__PURE__ */ i(f, { segment: d })
65
+ }
66
+ );
67
+ }
68
+ export {
69
+ x as DateField,
70
+ D as DateInput,
71
+ f as DateSegment,
72
+ w as TimeField,
73
+ p as dateInputStyles
74
+ };
@@ -0,0 +1,56 @@
1
+ import * as React from 'react';
2
+ export type FileMetadata = {
3
+ name: string;
4
+ size: number;
5
+ type: string;
6
+ url: string;
7
+ id: string;
8
+ };
9
+ export type FileWithPreview = {
10
+ file: File | FileMetadata;
11
+ id: string;
12
+ preview?: string;
13
+ };
14
+ export type FileUploadOptions = {
15
+ maxFiles?: number;
16
+ maxSize?: number;
17
+ accept?: string;
18
+ multiple?: boolean;
19
+ initialFiles?: FileMetadata[];
20
+ onFilesChange?: (files: FileWithPreview[]) => void;
21
+ onFilesAdded?: (addedFiles: FileWithPreview[]) => void;
22
+ };
23
+ export type FileUploadState = {
24
+ files: FileWithPreview[];
25
+ isDragging: boolean;
26
+ errors: string[];
27
+ };
28
+ export type FileUploadActions = {
29
+ addFiles: (files: FileList | File[]) => void;
30
+ removeFile: (id: string) => void;
31
+ clearFiles: () => void;
32
+ clearErrors: () => void;
33
+ handleDragEnter: (event: React.DragEvent<HTMLElement>) => void;
34
+ handleDragLeave: (event: React.DragEvent<HTMLElement>) => void;
35
+ handleDragOver: (event: React.DragEvent<HTMLElement>) => void;
36
+ handleDrop: (event: React.DragEvent<HTMLElement>) => void;
37
+ handleFileChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
38
+ openFileDialog: () => void;
39
+ getInputProps: (props?: React.InputHTMLAttributes<HTMLInputElement>) => React.InputHTMLAttributes<HTMLInputElement> & {
40
+ ref: React.Ref<HTMLInputElement>;
41
+ };
42
+ };
43
+ export type FileUploadProps = Omit<React.ComponentProps<'div'>, 'children'> & FileUploadOptions & {
44
+ label?: React.ReactNode;
45
+ description?: React.ReactNode;
46
+ browseLabel?: React.ReactNode;
47
+ disabled?: boolean;
48
+ showFileList?: boolean;
49
+ dropzoneClassName?: string;
50
+ listClassName?: string;
51
+ errorClassName?: string;
52
+ };
53
+ export declare function useFileUpload(options?: FileUploadOptions): [FileUploadState, FileUploadActions];
54
+ declare function FileUpload({ maxFiles, maxSize, accept, multiple, initialFiles, onFilesChange, onFilesAdded, label, description, browseLabel, disabled, showFileList, className, dropzoneClassName, listClassName, errorClassName, ...props }: FileUploadProps): import("react/jsx-runtime").JSX.Element;
55
+ export declare function formatBytes(bytes: number, decimals?: number): string;
56
+ export { FileUpload };
@@ -0,0 +1,338 @@
1
+ import { jsxs as h, jsx as o } from "react/jsx-runtime";
2
+ import * as l from "react";
3
+ import { RiUpload2Line as q, RiFileTextLine as G, RiCloseLine as Y } from "@remixicon/react";
4
+ import { cn as E } from "../../../../lib/utils.js";
5
+ import { Button as j } from "../button/button.js";
6
+ function C(t) {
7
+ return typeof File < "u" && t instanceof File;
8
+ }
9
+ function w(t) {
10
+ return t.name;
11
+ }
12
+ function A(t) {
13
+ return t.size;
14
+ }
15
+ function H(t) {
16
+ return C(t) ? t.type || "" : t.type;
17
+ }
18
+ function J(t) {
19
+ const c = w(t), f = c.includes(".") ? c.split(".").pop() : "";
20
+ return f ? `.${f}` : "";
21
+ }
22
+ function W(t, c) {
23
+ return `File "${w(t)}" ${c}.`;
24
+ }
25
+ function Q(t = {}) {
26
+ const {
27
+ maxFiles: c = 1 / 0,
28
+ maxSize: f = 1 / 0,
29
+ accept: g = "*",
30
+ multiple: u = !1,
31
+ initialFiles: b = [],
32
+ onFilesChange: x,
33
+ onFilesAdded: z
34
+ } = t, [y, m] = l.useState({
35
+ files: b.map((e) => ({
36
+ file: e,
37
+ id: e.id,
38
+ preview: e.url
39
+ })),
40
+ isDragging: !1,
41
+ errors: []
42
+ }), i = l.useRef(null), $ = l.useCallback(
43
+ (e) => {
44
+ if (A(e) > f)
45
+ return W(e, `exceeds the maximum size of ${I(f)}`);
46
+ if (g !== "*") {
47
+ const s = g.split(",").map((d) => d.trim()), n = H(e), p = J(e);
48
+ if (!s.some((d) => {
49
+ if (d.startsWith("."))
50
+ return p.toLowerCase() === d.toLowerCase();
51
+ if (d.endsWith("/*")) {
52
+ const a = d.split("/")[0];
53
+ return n.startsWith(`${a}/`);
54
+ }
55
+ return n === d;
56
+ }))
57
+ return W(e, "is not an accepted file type");
58
+ }
59
+ return null;
60
+ },
61
+ [g, f]
62
+ ), L = l.useCallback((e) => C(e) ? URL.createObjectURL(e) : e.url, []), R = l.useCallback((e) => C(e) ? `${e.name}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}` : e.id, []), D = l.useCallback(() => {
63
+ m((e) => {
64
+ e.files.forEach((n) => {
65
+ n.preview && C(n.file) && URL.revokeObjectURL(n.preview);
66
+ }), i.current && (i.current.value = "");
67
+ const s = [];
68
+ return x?.(s), {
69
+ ...e,
70
+ files: s,
71
+ errors: []
72
+ };
73
+ });
74
+ }, [x]), v = l.useCallback(
75
+ (e) => {
76
+ if (!e || e.length === 0) return;
77
+ const s = Array.from(e), n = [];
78
+ if (m((r) => ({ ...r, errors: [] })), u || D(), u && c !== 1 / 0 && y.files.length + s.length > c) {
79
+ n.push(`You can only upload a maximum of ${c} files.`), m((r) => ({ ...r, errors: n }));
80
+ return;
81
+ }
82
+ const p = [];
83
+ s.forEach((r) => {
84
+ if (u && y.files.some(
85
+ (K) => w(K.file) === r.name && A(K.file) === r.size
86
+ ))
87
+ return;
88
+ const d = $(r);
89
+ if (d) {
90
+ n.push(d);
91
+ return;
92
+ }
93
+ p.push({
94
+ file: r,
95
+ id: R(r),
96
+ preview: L(r)
97
+ });
98
+ }), p.length > 0 ? (z?.(p), m((r) => {
99
+ const d = u ? [...r.files, ...p] : p;
100
+ return x?.(d), {
101
+ ...r,
102
+ files: d,
103
+ errors: n
104
+ };
105
+ })) : n.length > 0 && m((r) => ({
106
+ ...r,
107
+ errors: n
108
+ })), i.current && (i.current.value = "");
109
+ },
110
+ [
111
+ D,
112
+ L,
113
+ R,
114
+ c,
115
+ u,
116
+ z,
117
+ x,
118
+ y.files,
119
+ $
120
+ ]
121
+ ), U = l.useCallback(
122
+ (e) => {
123
+ m((s) => {
124
+ const n = s.files.find((r) => r.id === e);
125
+ n?.preview && C(n.file) && URL.revokeObjectURL(n.preview);
126
+ const p = s.files.filter((r) => r.id !== e);
127
+ return x?.(p), {
128
+ ...s,
129
+ files: p,
130
+ errors: []
131
+ };
132
+ });
133
+ },
134
+ [x]
135
+ ), k = l.useCallback(() => {
136
+ m((e) => ({
137
+ ...e,
138
+ errors: []
139
+ }));
140
+ }, []), T = l.useCallback((e) => {
141
+ e.preventDefault(), e.stopPropagation(), m((s) => ({ ...s, isDragging: !0 }));
142
+ }, []), F = l.useCallback((e) => {
143
+ e.preventDefault(), e.stopPropagation(), !e.currentTarget.contains(e.relatedTarget) && m((s) => ({ ...s, isDragging: !1 }));
144
+ }, []), B = l.useCallback((e) => {
145
+ e.preventDefault(), e.stopPropagation();
146
+ }, []), P = l.useCallback(
147
+ (e) => {
148
+ e.preventDefault(), e.stopPropagation(), m((s) => ({ ...s, isDragging: !1 })), !i.current?.disabled && e.dataTransfer.files?.length > 0 && v(u ? e.dataTransfer.files : [e.dataTransfer.files[0]]);
149
+ },
150
+ [v, u]
151
+ ), N = l.useCallback(
152
+ (e) => {
153
+ e.target.files?.length && v(e.target.files);
154
+ },
155
+ [v]
156
+ ), M = l.useCallback(() => {
157
+ i.current?.click();
158
+ }, []), O = l.useCallback(
159
+ (e = {}) => ({
160
+ ...e,
161
+ type: "file",
162
+ onChange: N,
163
+ accept: e.accept ?? g,
164
+ multiple: e.multiple ?? u,
165
+ ref: i
166
+ }),
167
+ [g, N, u]
168
+ );
169
+ return [
170
+ y,
171
+ {
172
+ addFiles: v,
173
+ removeFile: U,
174
+ clearFiles: D,
175
+ clearErrors: k,
176
+ handleDragEnter: T,
177
+ handleDragLeave: F,
178
+ handleDragOver: B,
179
+ handleDrop: P,
180
+ handleFileChange: N,
181
+ openFileDialog: M,
182
+ getInputProps: O
183
+ }
184
+ ];
185
+ }
186
+ function _({
187
+ maxFiles: t = 5,
188
+ maxSize: c = 10 * 1024 * 1024,
189
+ accept: f = "*",
190
+ multiple: g = !0,
191
+ initialFiles: u,
192
+ onFilesChange: b,
193
+ onFilesAdded: x,
194
+ label: z = "点击或拖拽文件到此处",
195
+ description: y,
196
+ browseLabel: m = "选择文件",
197
+ disabled: i = !1,
198
+ showFileList: $ = !0,
199
+ className: L,
200
+ dropzoneClassName: R,
201
+ listClassName: D,
202
+ errorClassName: v,
203
+ ...U
204
+ }) {
205
+ const [
206
+ { files: k, isDragging: T, errors: F },
207
+ {
208
+ removeFile: B,
209
+ clearFiles: P,
210
+ clearErrors: N,
211
+ handleDragEnter: M,
212
+ handleDragLeave: O,
213
+ handleDragOver: e,
214
+ handleDrop: s,
215
+ openFileDialog: n,
216
+ getInputProps: p
217
+ }
218
+ ] = Q({
219
+ maxFiles: t,
220
+ maxSize: c,
221
+ accept: f,
222
+ multiple: g,
223
+ initialFiles: u,
224
+ onFilesChange: b,
225
+ onFilesAdded: x
226
+ }), r = y ?? `支持 ${g ? `最多 ${t} 个文件` : "单个文件"},单文件不超过 ${I(c)}。`;
227
+ function d(a) {
228
+ i || (a.key === "Enter" || a.key === " ") && (a.preventDefault(), n());
229
+ }
230
+ return /* @__PURE__ */ h("div", { "data-slot": "file-upload", className: E("space-y-3", L), ...U, children: [
231
+ /* @__PURE__ */ h(
232
+ "div",
233
+ {
234
+ role: "button",
235
+ tabIndex: i ? -1 : 0,
236
+ "aria-disabled": i,
237
+ "data-dragging": T || void 0,
238
+ "data-slot": "file-upload-dropzone",
239
+ onClick: i ? void 0 : n,
240
+ onKeyDown: d,
241
+ onDragEnter: i ? void 0 : M,
242
+ onDragLeave: i ? void 0 : O,
243
+ onDragOver: i ? void 0 : e,
244
+ onDrop: i ? void 0 : s,
245
+ className: E(
246
+ "flex cursor-pointer flex-col items-center justify-center rounded-xl border-2 border-dashed px-6 py-10 text-center transition-colors",
247
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",
248
+ T ? "border-primary bg-primary/5" : "border-border hover:border-primary/40",
249
+ i && "cursor-not-allowed opacity-60 hover:border-border",
250
+ R
251
+ ),
252
+ children: [
253
+ /* @__PURE__ */ o("div", { className: "mb-3 flex size-10 items-center justify-center rounded-full bg-primary/10 text-primary", children: /* @__PURE__ */ o(q, { className: "size-5" }) }),
254
+ /* @__PURE__ */ o("div", { className: "text-sm font-medium text-foreground", children: z }),
255
+ r && /* @__PURE__ */ o("div", { className: "mt-1 max-w-md text-xs text-muted-foreground", children: r }),
256
+ /* @__PURE__ */ o(
257
+ j,
258
+ {
259
+ type: "button",
260
+ size: "sm",
261
+ variant: "outline",
262
+ className: "mt-4",
263
+ disabled: i,
264
+ onClick: (a) => {
265
+ a.stopPropagation(), n();
266
+ },
267
+ children: m
268
+ }
269
+ ),
270
+ /* @__PURE__ */ o("input", { ...p({ accept: f, multiple: g, disabled: i, className: "sr-only" }) })
271
+ ]
272
+ }
273
+ ),
274
+ F.length > 0 && /* @__PURE__ */ h(
275
+ "div",
276
+ {
277
+ "data-slot": "file-upload-errors",
278
+ className: E("rounded-lg border border-destructive/20 bg-destructive/5 p-3", v),
279
+ children: [
280
+ /* @__PURE__ */ h("div", { className: "flex items-center justify-between gap-3", children: [
281
+ /* @__PURE__ */ h("div", { className: "text-xs font-medium text-destructive", children: [
282
+ F.length,
283
+ " 个错误"
284
+ ] }),
285
+ /* @__PURE__ */ o(j, { size: "sm", variant: "ghost", onClick: N, children: "清除" })
286
+ ] }),
287
+ /* @__PURE__ */ o("ul", { className: "mt-1.5 space-y-1 text-xs text-destructive", children: F.map((a) => /* @__PURE__ */ o("li", { children: a }, a)) })
288
+ ]
289
+ }
290
+ ),
291
+ $ && k.length > 0 && /* @__PURE__ */ h(
292
+ "div",
293
+ {
294
+ "data-slot": "file-upload-list",
295
+ className: E("overflow-hidden rounded-lg border border-border bg-card", D),
296
+ children: [
297
+ /* @__PURE__ */ h("div", { className: "flex items-center justify-between gap-3 border-b border-border px-3 py-2", children: [
298
+ /* @__PURE__ */ h("div", { className: "text-xs font-medium text-foreground", children: [
299
+ "已选 ",
300
+ k.length,
301
+ " 个文件"
302
+ ] }),
303
+ /* @__PURE__ */ o(j, { size: "sm", variant: "ghost", onClick: P, children: "全部清除" })
304
+ ] }),
305
+ /* @__PURE__ */ o("ul", { className: "divide-y divide-border", children: k.map((a) => /* @__PURE__ */ h("li", { className: "flex items-center gap-3 px-3 py-2 text-sm", children: [
306
+ /* @__PURE__ */ o("span", { className: "flex size-8 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground", children: /* @__PURE__ */ o(G, { className: "size-4" }) }),
307
+ /* @__PURE__ */ h("span", { className: "min-w-0 flex-1", children: [
308
+ /* @__PURE__ */ o("span", { className: "block truncate font-medium text-foreground", children: w(a.file) }),
309
+ /* @__PURE__ */ o("span", { className: "block text-xs text-muted-foreground", children: I(A(a.file)) })
310
+ ] }),
311
+ /* @__PURE__ */ o(
312
+ j,
313
+ {
314
+ type: "button",
315
+ size: "sm",
316
+ mode: "icon",
317
+ variant: "ghost",
318
+ "aria-label": `移除 ${w(a.file)}`,
319
+ onClick: () => B(a.id),
320
+ children: /* @__PURE__ */ o(Y, { className: "size-4" })
321
+ }
322
+ )
323
+ ] }, a.id)) })
324
+ ]
325
+ }
326
+ )
327
+ ] });
328
+ }
329
+ function I(t, c = 2) {
330
+ if (t === 0) return "0 Bytes";
331
+ const f = 1024, g = c < 0 ? 0 : c, u = ["Bytes", "KB", "MB", "GB", "TB"], b = Math.min(Math.floor(Math.log(t) / Math.log(f)), u.length - 1);
332
+ return `${Number.parseFloat((t / Math.pow(f, b)).toFixed(g))} ${u[b]}`;
333
+ }
334
+ export {
335
+ _ as FileUpload,
336
+ I as formatBytes,
337
+ Q as useFileUpload
338
+ };
@@ -0,0 +1,24 @@
1
+ import { Slot } from '@radix-ui/react-slot';
2
+ import { Label as LabelPrimitive } from 'radix-ui';
3
+ import { ControllerProps, FieldPath, FieldValues } from 'react-hook-form';
4
+ import * as React from 'react';
5
+ declare const Form: <TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: import('react-hook-form').FormProviderProps<TFieldValues, TContext, TTransformedValues>) => React.JSX.Element;
6
+ declare const FormField: <TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({ ...props }: ControllerProps<TFieldValues, TName>) => import("react/jsx-runtime").JSX.Element;
7
+ declare const useFormField: () => {
8
+ invalid: boolean;
9
+ isDirty: boolean;
10
+ isTouched: boolean;
11
+ isValidating: boolean;
12
+ error?: import('react-hook-form').FieldError;
13
+ id: string;
14
+ name: string;
15
+ formItemId: string;
16
+ formDescriptionId: string;
17
+ formMessageId: string;
18
+ };
19
+ declare function FormItem({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): import("react/jsx-runtime").JSX.Element;
20
+ declare function FormLabel({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
21
+ declare function FormControl({ ...props }: React.ComponentProps<typeof Slot>): import("react/jsx-runtime").JSX.Element;
22
+ declare function FormDescription({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>): import("react/jsx-runtime").JSX.Element | null;
23
+ declare function FormMessage({ className, children, ...props }: React.HTMLAttributes<HTMLParagraphElement>): import("react/jsx-runtime").JSX.Element | null;
24
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
@@ -0,0 +1,86 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import * as s from "react";
3
+ import { cn as d } from "../../../../lib/utils.js";
4
+ import { Label as f } from "../label/label.js";
5
+ import { Slot as u } from "@radix-ui/react-slot";
6
+ import { FormProvider as F, Controller as x, useFormContext as I } from "react-hook-form";
7
+ const h = F, c = s.createContext({}), $ = ({
8
+ ...t
9
+ }) => /* @__PURE__ */ n(c.Provider, { value: { name: t.name }, children: /* @__PURE__ */ n(x, { ...t }) }), a = () => {
10
+ const t = s.useContext(c), e = s.useContext(l), { getFieldState: o, formState: r } = I(), i = o(t.name, r);
11
+ if (!t)
12
+ throw new Error("useFormField should be used within <FormField>");
13
+ const { id: m } = e;
14
+ return {
15
+ id: m,
16
+ name: t.name,
17
+ formItemId: `${m}-form-item`,
18
+ formDescriptionId: `${m}-form-item-description`,
19
+ formMessageId: `${m}-form-item-message`,
20
+ ...i
21
+ };
22
+ }, l = s.createContext({});
23
+ function S({ className: t, ...e }) {
24
+ const o = s.useId(), { error: r } = a();
25
+ return /* @__PURE__ */ n(l.Provider, { value: { id: o }, children: /* @__PURE__ */ n("div", { "data-slot": "form-item", className: d("flex flex-col gap-2.5", t), "data-invalid": !!r, ...e }) });
26
+ }
27
+ function D({ className: t, ...e }) {
28
+ const { formItemId: o } = a();
29
+ return /* @__PURE__ */ n(
30
+ f,
31
+ {
32
+ "data-slot": "form-label",
33
+ className: d("font-medium text-foreground", t),
34
+ htmlFor: o,
35
+ ...e
36
+ }
37
+ );
38
+ }
39
+ function M({ ...t }) {
40
+ const { error: e, formItemId: o, formDescriptionId: r, formMessageId: i } = a();
41
+ return /* @__PURE__ */ n(
42
+ u,
43
+ {
44
+ "data-slot": "form-control",
45
+ id: o,
46
+ "aria-describedby": e ? `${r} ${i}` : `${r}`,
47
+ "aria-invalid": !!e,
48
+ ...t
49
+ }
50
+ );
51
+ }
52
+ function N({ className: t, ...e }) {
53
+ const { formDescriptionId: o, error: r } = a();
54
+ return r ? null : /* @__PURE__ */ n(
55
+ "div",
56
+ {
57
+ "data-slot": "form-description",
58
+ id: o,
59
+ className: d("text-xs text-muted-foreground -mt-0.5", t),
60
+ ...e
61
+ }
62
+ );
63
+ }
64
+ function w({ className: t, children: e, ...o }) {
65
+ const { error: r, formMessageId: i } = a(), m = r ? String(r?.message) : e;
66
+ return m ? /* @__PURE__ */ n(
67
+ "div",
68
+ {
69
+ "data-slot": "form-message",
70
+ id: i,
71
+ className: d("-mt-0.5 text-xs font-normal text-destructive", t),
72
+ ...o,
73
+ children: m
74
+ }
75
+ ) : null;
76
+ }
77
+ export {
78
+ h as Form,
79
+ M as FormControl,
80
+ N as FormDescription,
81
+ $ as FormField,
82
+ S as FormItem,
83
+ D as FormLabel,
84
+ w as FormMessage,
85
+ a as useFormField
86
+ };
@@ -0,0 +1,22 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import * as React from 'react';
3
+ declare const inputVariants: (props?: ({
4
+ variant?: "sm" | "md" | "lg" | null | undefined;
5
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
+ declare const inputAddonVariants: (props?: ({
7
+ variant?: "sm" | "md" | "lg" | null | undefined;
8
+ mode?: "default" | "icon" | null | undefined;
9
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
10
+ declare const inputGroupVariants: (props?: ({} & import('class-variance-authority/types').ClassProp) | undefined) => string;
11
+ declare const inputWrapperVariants: (props?: ({
12
+ variant?: "sm" | "md" | "lg" | null | undefined;
13
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
14
+ declare function Input({ className, type, variant, ...props }: React.ComponentProps<'input'> & VariantProps<typeof inputVariants>): import("react/jsx-runtime").JSX.Element;
15
+ declare function InputAddon({ className, variant, mode, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputAddonVariants>): import("react/jsx-runtime").JSX.Element;
16
+ declare function InputGroup({ className, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputGroupVariants>): import("react/jsx-runtime").JSX.Element;
17
+ declare function InputWrapper({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputWrapperVariants>): import("react/jsx-runtime").JSX.Element;
18
+ declare function NativeDateInput({ className, wrapperClassName, iconClassName, variant, ...props }: Omit<React.ComponentProps<'input'>, 'type'> & VariantProps<typeof inputVariants> & {
19
+ wrapperClassName?: string;
20
+ iconClassName?: string;
21
+ }): import("react/jsx-runtime").JSX.Element;
22
+ export { Input, InputAddon, InputGroup, InputWrapper, NativeDateInput, inputVariants, inputAddonVariants };