@deftui/react 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { useCopyToClipboard } from "./vendor/coss/hooks/use-copy-to-clipboard.mjs";
2
2
  import { useIsMobile, useMediaQuery } from "./vendor/coss/hooks/use-media-query.mjs";
3
+ import { FileUploadProps, useFileUpload as useStore } from "./vendor/diceui/file-upload.mjs";
3
4
  import { Button } from "./vendor/shadcn/button.mjs";
4
5
  import { AlertDialogHandle, createAlertDialogHandle } from "./vendor/shadcn/alert-dialog.mjs";
5
6
  import { Separator } from "./vendor/shadcn/separator.mjs";
@@ -19,12 +20,14 @@ import { DatePicker, DateRange, DateRangePicker, TimePicker } from "./widgets/da
19
20
  import { Badge } from "./vendor/shadcn/badge.mjs";
20
21
  import { Switch } from "./vendor/shadcn/switch.mjs";
21
22
  import { Spinner } from "./vendor/shadcn/spinner.mjs";
23
+ import { Skeleton } from "./vendor/shadcn/skeleton.mjs";
24
+ import { Checkbox } from "./vendor/shadcn/checkbox.mjs";
22
25
  import { Textarea } from "./vendor/shadcn/textarea.mjs";
23
26
  import { ScrollArea } from "./vendor/coss/scroll-area.mjs";
24
27
  import { Form } from "./vendor/coss/form.mjs";
25
28
  import { IconSwap } from "./vendor/tailored/icon-swap.mjs";
26
- import { AlertDialog, ButtonGroup, Card, Combobox, Dialog, Drawer, Dropdown, Empty, Field, InputGroup, Kbd, Popover, Progress, Radio, Select, Table, Tabs, Tooltip } from "./widgets/index.mjs";
29
+ import { AlertDialog, ButtonGroup, Calendar, Card, Combobox, Dialog, Drawer, Dropdown, Empty, Field, FileUpload, InputGroup, Kbd, Popover, Progress, Radio, Select, Table, Tabs, Tooltip } from "./widgets/index.mjs";
27
30
  import { cn } from "cn";
28
31
  import { cva } from "class-variance-authority";
29
32
  import { mergeProps } from "@base-ui/react/merge-props";
30
- export { AlertDialog, type AlertDialogHandle, Badge, Breadcrumb, Button, ButtonGroup, Card, Carousel, Combobox, type ComboboxItemCollection, type ComboboxPrimitiveValue, type CreateComboboxItemsOptions, DatePicker, type DateRange, DateRangePicker, Dialog, type DialogHandle, Drawer, type DrawerHandle, Dropdown, Empty, Field, Form, IconSwap, Image, ImageProps, Input, InputGroup, Kbd, Label, Lightbox, type LightboxActions, type LightboxBackdrop, type LightboxCaptions, type LightboxChangeReason, type LightboxClose, type LightboxContent, type LightboxControl, type LightboxControlContext, type LightboxCounter, type LightboxDownload, type LightboxImageChangeEventDetails, type LightboxImageItem, type LightboxItem, type LightboxMore, type LightboxNext, type LightboxOpenEventDetails, type LightboxPrevious, type LightboxProps, type LightboxSlide, type LightboxSlides, type LightboxThumbnail, type LightboxThumbnails, type LightboxToolbar, type LightboxTrigger, type LightboxTriggerProps, type LightboxVideoItem, type LightboxViewport, type LightboxZoom, type LightboxZoomButton, Pagination, Popover, Progress, Radio, ScrollArea, Select, Separator, Sidebar, Spinner, Switch, Table, Tabs, Textarea, TimePicker, Toaster as ToastProvider, Tooltip, cn, createAlertDialogHandle, createComboboxItems, createDialogHandle, createDrawerHandle, cva, mergeProps, toast, useCopyToClipboard, useIsMobile, type useLightbox, useMediaQuery, useSidebar };
33
+ export { AlertDialog, type AlertDialogHandle, Badge, Breadcrumb, Button, ButtonGroup, Calendar, Card, Carousel, Checkbox, Combobox, type ComboboxItemCollection, type ComboboxPrimitiveValue, type CreateComboboxItemsOptions, DatePicker, type DateRange, DateRangePicker, Dialog, type DialogHandle, Drawer, type DrawerHandle, Dropdown, Empty, Field, FileUpload, type FileUploadProps, Form, IconSwap, Image, ImageProps, Input, InputGroup, Kbd, Label, Lightbox, type LightboxActions, type LightboxBackdrop, type LightboxCaptions, type LightboxChangeReason, type LightboxClose, type LightboxContent, type LightboxControl, type LightboxControlContext, type LightboxCounter, type LightboxDownload, type LightboxImageChangeEventDetails, type LightboxImageItem, type LightboxItem, type LightboxMore, type LightboxNext, type LightboxOpenEventDetails, type LightboxPrevious, type LightboxProps, type LightboxSlide, type LightboxSlides, type LightboxThumbnail, type LightboxThumbnails, type LightboxToolbar, type LightboxTrigger, type LightboxTriggerProps, type LightboxVideoItem, type LightboxViewport, type LightboxZoom, type LightboxZoomButton, Pagination, Popover, Progress, Radio, ScrollArea, Select, Separator, Sidebar, Skeleton, Spinner, Switch, Table, Tabs, Textarea, TimePicker, Toaster as ToastProvider, Tooltip, cn, createAlertDialogHandle, createComboboxItems, createDialogHandle, createDrawerHandle, cva, mergeProps, toast, useCopyToClipboard, useStore as useFileUpload, useIsMobile, type useLightbox, useMediaQuery, useSidebar };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { useCopyToClipboard } from "./vendor/coss/hooks/use-copy-to-clipboard.mjs";
2
2
  import { useIsMobile, useMediaQuery } from "./vendor/coss/hooks/use-media-query.mjs";
3
+ import { useFileUpload as useStore } from "./vendor/diceui/file-upload.mjs";
3
4
  import { Spinner } from "./vendor/shadcn/spinner.mjs";
4
5
  import { Button } from "./vendor/shadcn/button.mjs";
5
6
  import { createAlertDialogHandle } from "./vendor/shadcn/alert-dialog.mjs";
@@ -11,6 +12,7 @@ import { createDialogHandle } from "./vendor/shadcn/dialog.mjs";
11
12
  import { createDrawerHandle } from "./vendor/shadcn/drawer.mjs";
12
13
  import { Label } from "./vendor/shadcn/label.mjs";
13
14
  import { Toaster, toast } from "./vendor/shadcn/toast.mjs";
15
+ import { Skeleton } from "./vendor/shadcn/skeleton.mjs";
14
16
  import { useSidebar } from "./vendor/shadcn/sidebar.mjs";
15
17
  import { Sidebar } from "./widgets/sidebar.mjs";
16
18
  import { Breadcrumb } from "./widgets/breadcrumb.mjs";
@@ -19,11 +21,12 @@ import { Carousel, Image, Lightbox } from "./widgets/multimedia.mjs";
19
21
  import { DatePicker, DateRangePicker, TimePicker } from "./widgets/datetime-picker.mjs";
20
22
  import { Badge } from "./vendor/shadcn/badge.mjs";
21
23
  import { Switch } from "./vendor/shadcn/switch.mjs";
24
+ import { Checkbox } from "./vendor/shadcn/checkbox.mjs";
22
25
  import { ScrollArea } from "./vendor/coss/scroll-area.mjs";
23
26
  import { Form } from "./vendor/coss/form.mjs";
24
27
  import { IconSwap } from "./vendor/tailored/icon-swap.mjs";
25
- import { AlertDialog, ButtonGroup, Card, Combobox, Dialog, Drawer, Dropdown, Empty, Field, InputGroup, Kbd, Popover, Progress, Radio, Select, Table, Tabs, Tooltip } from "./widgets/index.mjs";
28
+ import { AlertDialog, ButtonGroup, Calendar, Card, Combobox, Dialog, Drawer, Dropdown, Empty, Field, FileUpload, InputGroup, Kbd, Popover, Progress, Radio, Select, Table, Tabs, Tooltip } from "./widgets/index.mjs";
26
29
  import { cn } from "cn";
27
30
  import { cva } from "class-variance-authority";
28
31
  import { mergeProps } from "@base-ui/react/merge-props";
29
- export { AlertDialog, Badge, Breadcrumb, Button, ButtonGroup, Card, Carousel, Combobox, DatePicker, DateRangePicker, Dialog, Drawer, Dropdown, Empty, Field, Form, IconSwap, Image, Input, InputGroup, Kbd, Label, Lightbox, Pagination, Popover, Progress, Radio, ScrollArea, Select, Separator, Sidebar, Spinner, Switch, Table, Tabs, Textarea, TimePicker, Toaster as ToastProvider, Tooltip, cn, createAlertDialogHandle, createComboboxItems, createDialogHandle, createDrawerHandle, cva, mergeProps, toast, useCopyToClipboard, useIsMobile, useMediaQuery, useSidebar };
32
+ export { AlertDialog, Badge, Breadcrumb, Button, ButtonGroup, Calendar, Card, Carousel, Checkbox, Combobox, DatePicker, DateRangePicker, Dialog, Drawer, Dropdown, Empty, Field, FileUpload, Form, IconSwap, Image, Input, InputGroup, Kbd, Label, Lightbox, Pagination, Popover, Progress, Radio, ScrollArea, Select, Separator, Sidebar, Skeleton, Spinner, Switch, Table, Tabs, Textarea, TimePicker, Toaster as ToastProvider, Tooltip, cn, createAlertDialogHandle, createComboboxItems, createDialogHandle, createDrawerHandle, cva, mergeProps, toast, useCopyToClipboard, useStore as useFileUpload, useIsMobile, useMediaQuery, useSidebar };
@@ -16,6 +16,7 @@ shadcn 组件使用 `components.json` 中的 `base-vega` 风格和 Lucide 图标
16
16
  | `@coss/scroll-area` | [coss/scroll-area.tsx](coss/scroll-area.tsx) | [Scroll Area](https://coss.com/ui/docs/components/scroll-area) | — |
17
17
  | `@coss/use-copy-to-clipboard` | [coss/hooks/use-copy-to-clipboard.ts](coss/hooks/use-copy-to-clipboard.ts) | [useCopyToClipboard](https://coss.com/ui/docs/hooks/use-copy-to-clipboard) | — |
18
18
  | `@coss/use-media-query` | [coss/hooks/use-media-query.ts](coss/hooks/use-media-query.ts) | [useMediaQuery](https://coss.com/ui/docs/hooks/use-media-query) | 断点:`md` 设为 768px,与 Tailwind 默认值一致 |
19
+ | `@diceui/file-upload` | [diceui/file-upload.tsx](diceui/file-upload.tsx) | [File Upload](https://diceui.com/docs/components/base/file-upload) | — |
19
20
  | `alert-dialog` | [shadcn/alert-dialog.tsx](shadcn/alert-dialog.tsx) | [Alert Dialog](https://ui.shadcn.com/docs/components/base/alert-dialog) | 额外导出 `createAlertDialogHandle` 及其类型 |
20
21
  | `badge` | [shadcn/badge.tsx](shadcn/badge.tsx) | [Badge](https://ui.shadcn.com/docs/components/base/badge) | 提供 `info`、`success`、`warning` 语义变体 |
21
22
  | `breadcrumb` | [shadcn/breadcrumb.tsx](shadcn/breadcrumb.tsx) | [Breadcrumb](https://ui.shadcn.com/docs/components/base/breadcrumb) | — |
@@ -24,6 +25,7 @@ shadcn 组件使用 `components.json` 中的 `base-vega` 风格和 Lucide 图标
24
25
  | `calendar` | [shadcn/calendar.tsx](shadcn/calendar.tsx) | [Calendar](https://ui.shadcn.com/docs/components/base/calendar) | 将 `react-day-picker` 导入改为 `@daypicker/react` |
25
26
  | `card` | [shadcn/card.tsx](shadcn/card.tsx) | [Card](https://ui.shadcn.com/docs/components/base/card) | — |
26
27
  | `carousel` | [shadcn/carousel.tsx](shadcn/carousel.tsx) | [Carousel](https://ui.shadcn.com/docs/components/base/carousel) | — |
28
+ | `checkbox` | [shadcn/checkbox.tsx](shadcn/checkbox.tsx) | [Checkbox](https://ui.shadcn.com/docs/components/base/checkbox) | — |
27
29
  | `combobox` | [shadcn/combobox.tsx](shadcn/combobox.tsx) | [Combobox](https://ui.shadcn.com/docs/components/base/combobox) | 额外导出 `createComboboxItems` 及其类型 |
28
30
  | `dialog` | [shadcn/dialog.tsx](shadcn/dialog.tsx) | [Dialog](https://ui.shadcn.com/docs/components/base/dialog) | 额外导出 `createDialogHandle` 及其类型 |
29
31
  | `direction` | [shadcn/direction.tsx](shadcn/direction.tsx) | [Direction](https://ui.shadcn.com/docs/components/base/direction) | — |
@@ -0,0 +1,74 @@
1
+ import * as React$1 from "react";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ type Direction = "ltr" | "rtl";
4
+ interface FileState {
5
+ file: File;
6
+ progress: number;
7
+ error?: string;
8
+ status: "idle" | "uploading" | "error" | "success";
9
+ }
10
+ interface StoreState {
11
+ files: Map<File, FileState>;
12
+ dragOver: boolean;
13
+ invalid: boolean;
14
+ }
15
+ declare function useStore<T>(selector: (state: StoreState) => T): T;
16
+ interface FileUploadProps extends Omit<React$1.ComponentProps<"div"> & useRender.ComponentProps<"div">, "defaultValue" | "onChange"> {
17
+ value?: File[];
18
+ defaultValue?: File[];
19
+ onValueChange?: (files: File[]) => void;
20
+ onAccept?: (files: File[]) => void;
21
+ onFileAccept?: (file: File) => void;
22
+ onFileReject?: (file: File, message: string) => void;
23
+ onFileValidate?: (file: File) => string | null | undefined;
24
+ onUpload?: (files: File[], options: {
25
+ onProgress: (file: File, progress: number) => void;
26
+ onSuccess: (file: File) => void;
27
+ onError: (file: File, error: Error) => void;
28
+ }) => Promise<void> | void;
29
+ accept?: string;
30
+ maxFiles?: number;
31
+ maxSize?: number;
32
+ dir?: Direction;
33
+ label?: string;
34
+ name?: string;
35
+ disabled?: boolean;
36
+ invalid?: boolean;
37
+ multiple?: boolean;
38
+ required?: boolean;
39
+ }
40
+ declare function FileUpload(props: FileUploadProps): React$1.JSX.Element;
41
+ interface FileUploadDropzoneProps extends React$1.ComponentProps<"div">, useRender.ComponentProps<"div"> {}
42
+ declare function FileUploadDropzone(props: FileUploadDropzoneProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
43
+ interface FileUploadTriggerProps extends React$1.ComponentProps<"button">, useRender.ComponentProps<"button"> {}
44
+ declare function FileUploadTrigger(props: FileUploadTriggerProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
45
+ interface FileUploadListProps extends React$1.ComponentProps<"div">, useRender.ComponentProps<"div"> {
46
+ orientation?: "horizontal" | "vertical";
47
+ forceMount?: boolean;
48
+ }
49
+ declare function FileUploadList(props: FileUploadListProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
50
+ interface FileUploadItemProps extends React$1.ComponentProps<"div">, useRender.ComponentProps<"div"> {
51
+ value: File;
52
+ }
53
+ declare function FileUploadItem(props: FileUploadItemProps): React$1.JSX.Element | null;
54
+ interface FileUploadItemPreviewProps extends React$1.ComponentProps<"div">, useRender.ComponentProps<"div"> {
55
+ previewRender?: (file: File, fallback: () => React$1.ReactNode) => React$1.ReactNode;
56
+ }
57
+ declare function FileUploadItemPreview(props: FileUploadItemPreviewProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
58
+ interface FileUploadItemMetadataProps extends React$1.ComponentProps<"div">, useRender.ComponentProps<"div"> {
59
+ size?: "default" | "sm";
60
+ }
61
+ declare function FileUploadItemMetadata(props: FileUploadItemMetadataProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
62
+ interface FileUploadItemProgressProps extends React$1.ComponentProps<"div">, useRender.ComponentProps<"div"> {
63
+ variant?: "linear" | "circular" | "fill";
64
+ size?: number;
65
+ forceMount?: boolean;
66
+ }
67
+ declare function FileUploadItemProgress(props: FileUploadItemProgressProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
68
+ interface FileUploadItemDeleteProps extends React$1.ComponentProps<"button">, useRender.ComponentProps<"button"> {}
69
+ declare function FileUploadItemDelete(props: FileUploadItemDeleteProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
70
+ interface FileUploadClearProps extends React$1.ComponentProps<"button">, useRender.ComponentProps<"button"> {
71
+ forceMount?: boolean;
72
+ }
73
+ declare function FileUploadClear(props: FileUploadClearProps): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | null;
74
+ export { FileUpload, FileUploadClear, FileUploadDropzone, FileUploadItem, FileUploadItemDelete, FileUploadItemMetadata, FileUploadItemPreview, FileUploadItemProgress, FileUploadList, type FileUploadProps, FileUploadTrigger, useStore as useFileUpload };