@arcfusionz/arc-primitive-ui 0.2.12 → 0.2.14

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.
@@ -0,0 +1,190 @@
1
+ import { ButtonProps } from "../Button/Button.js";
2
+ import "../Button/index.js";
3
+ import { ComponentPropsWithoutRef, ReactNode } from "react";
4
+ import { useRender } from "@base-ui/react/use-render";
5
+ //#region src/components/FileUpload/FileUpload.d.ts
6
+ /** Built-in reasons a file is rejected. `validate` may add more of these. */
7
+ type FileUploadRejectionCode = "file-invalid-type" | "file-too-small" | "file-too-large" | "too-many-files";
8
+ /** A file that failed validation, with every reason it failed. */
9
+ interface FileUploadRejection {
10
+ file: File;
11
+ errors: FileUploadRejectionCode[];
12
+ }
13
+ /** Per-file lifecycle the consumer drives while uploading. */
14
+ type FileUploadItemStatus = "idle" | "uploading" | "success" | "error";
15
+ /** State exposed on the root element as `data-*` and to the `render` callback. */
16
+ interface FileUploadRenderState extends Record<string, unknown> {
17
+ /** A file is being dragged over the dropzone. */
18
+ dragging: boolean;
19
+ /** The upload is disabled. */
20
+ disabled: boolean;
21
+ /** The upload is marked invalid. */
22
+ invalid: boolean;
23
+ /** No files are selected. */
24
+ empty: boolean;
25
+ }
26
+ /** `1023 B`, `1.5 KB`, `12 MB` — a compact, locale-neutral size readout. */
27
+ declare function formatFileSize(bytes: number): string;
28
+ /** Public view of the upload's state and controls, for custom compositions. */
29
+ interface FileUploadHandle {
30
+ /** The currently selected files. */
31
+ files: File[];
32
+ /** A file is being dragged over the dropzone. */
33
+ isDragging: boolean;
34
+ /** The upload is disabled. */
35
+ disabled: boolean;
36
+ /** The upload is marked invalid. */
37
+ invalid: boolean;
38
+ /** Open the native file picker. */
39
+ open: () => void;
40
+ /** Remove one file from the selection. */
41
+ remove: (file: File) => void;
42
+ /** Clear the whole selection. */
43
+ clear: () => void;
44
+ }
45
+ /**
46
+ * Read the enclosing `FileUpload`'s state and controls — for building custom
47
+ * pieces the flat parts don't cover (a file counter, an "Upload all" button, a
48
+ * dropzone that hides once a file is chosen). Must be called under `FileUpload`.
49
+ */
50
+ declare function useFileUpload(): FileUploadHandle;
51
+ interface FileUploadProps extends Omit<ComponentPropsWithoutRef<"div">, "className" | "onChange" | "defaultValue" | "children"> {
52
+ /** Accepted types as the native `accept` string, e.g. `"image/*,.pdf"`. Enforced client-side too, so dropped files are gated the same as picked ones. */
53
+ accept?: string;
54
+ /** Allow selecting more than one file. When `false` (default) a new selection replaces the current one. */
55
+ multiple?: boolean;
56
+ /** Cap the number of files kept (only applies when `multiple`). Extra files are rejected with `too-many-files`. */
57
+ maxFiles?: number;
58
+ /** Reject files larger than this many bytes with `file-too-large`. */
59
+ maxSize?: number;
60
+ /** Reject files smaller than this many bytes with `file-too-small`. */
61
+ minSize?: number;
62
+ /** Extra validation run after the built-in checks; return the codes a file fails, or `null` to accept it. */
63
+ validate?: (file: File) => FileUploadRejectionCode[] | null;
64
+ /** Enable drag-and-drop onto the dropzone. Defaults to `true`. */
65
+ allowDrop?: boolean;
66
+ /** Prevent a file dropped outside the dropzone from navigating the browser. Defaults to `true`. */
67
+ preventDocumentDrop?: boolean;
68
+ /** Let the user pick a whole directory (`webkitdirectory`; Chromium/WebKit only). */
69
+ directory?: boolean;
70
+ /** Open the device camera on mobile instead of the file browser. */
71
+ capture?: "user" | "environment";
72
+ /** Controlled list of selected files. Pair with `onValueChange`. */
73
+ value?: File[];
74
+ /** Initial selection for the uncontrolled case. */
75
+ defaultValue?: File[];
76
+ /** Called whenever the selection changes (accepted files added, or a file removed). */
77
+ onValueChange?: (files: File[]) => void;
78
+ /** Called with the files newly accepted in a selection or drop. */
79
+ onAccept?: (files: File[]) => void;
80
+ /** Called with the files rejected in a selection or drop and why. */
81
+ onReject?: (rejections: FileUploadRejection[]) => void;
82
+ /** Disable the whole control. Inherited from a surrounding `Field` when unset. */
83
+ disabled?: boolean;
84
+ /** Mark the control invalid (destructive styling). Inherited from a surrounding `Field` when unset. */
85
+ invalid?: boolean;
86
+ /** Convey the field is required. Inherited from a surrounding `Field` when unset. */
87
+ required?: boolean;
88
+ /** `name` for the hidden input so the selection submits with a native form. */
89
+ name?: string;
90
+ /** Accessible name for the hidden file input. */
91
+ inputLabel?: string;
92
+ /** Replace the rendered root `div` or inspect `{ dragging, disabled, invalid, empty }`. */
93
+ render?: useRender.RenderProp<FileUploadRenderState>;
94
+ /** Compose the pieces: `FileUploadDropzone`, `FileUploadList`, `FileUploadTrigger`. */
95
+ children?: ReactNode;
96
+ className?: string;
97
+ }
98
+ /**
99
+ * Drag-and-drop / browse file selection built on a native input. Owns the
100
+ * selected-file list, drag interaction, and client-side validation (`accept`,
101
+ * `maxSize`/`minSize`, `maxFiles`, custom `validate`); the actual upload stays
102
+ * with the consumer, reflected per file through `FileUploadItem`. The empty
103
+ * dropzone is a `SystemState` (`upload` / `upload-error`).
104
+ *
105
+ * Accessibility: the input is visually hidden and the `FileUploadTrigger`
106
+ * button is the focusable, keyboard-operable control (drag-and-drop is a
107
+ * pointer enhancement). Announce added or rejected files yourself — the
108
+ * component is not a live region. Inside a `Field` it inherits
109
+ * `disabled`/`invalid`/`required`.
110
+ */
111
+ declare const FileUpload: import("react").ForwardRefExoticComponent<FileUploadProps & import("react").RefAttributes<HTMLDivElement>>;
112
+ interface FileUploadDropzoneVariantsOptions {
113
+ className?: string;
114
+ }
115
+ /**
116
+ * Class list for an element styled as the dashed drop area — for building a
117
+ * bespoke dropzone while keeping the brand's border, hover, and drag/invalid
118
+ * looks. The drag state hooks are `data-dragging` / `data-invalid` /
119
+ * `data-disabled`.
120
+ */
121
+ declare function fileUploadDropzoneVariants({ className }?: FileUploadDropzoneVariantsOptions): string;
122
+ interface FileUploadDropzoneProps extends Omit<ComponentPropsWithoutRef<"div">, "className"> {
123
+ /** Replace the default `SystemState` prompt + `FileUploadTrigger`. */
124
+ children?: ReactNode;
125
+ className?: string;
126
+ }
127
+ /**
128
+ * The dashed drop area. Clicking anywhere in it opens the picker (a pointer
129
+ * convenience); the `FileUploadTrigger` inside is the focusable control for
130
+ * keyboard and assistive tech. With no `children` it renders a `SystemState`
131
+ * (`upload`, or `upload-error` when invalid) with a browse button; pass
132
+ * `children` to supply your own prompt. Highlights via `data-dragging` while a
133
+ * file is dragged over it.
134
+ */
135
+ declare const FileUploadDropzone: import("react").ForwardRefExoticComponent<FileUploadDropzoneProps & import("react").RefAttributes<HTMLDivElement>>;
136
+ type FileUploadTriggerProps = ButtonProps;
137
+ /**
138
+ * Button that opens the file picker. Rendered inside `FileUploadDropzone` by
139
+ * default; use it on its own for a compact "attach a file" control with no drop
140
+ * area. Defaults to the `outline` variant and an upload-icon + "Browse files"
141
+ * label. A custom label opts into an icon via `startIcon`; pass
142
+ * `startIcon={null}` to remove the default one. Inherits the upload's
143
+ * `disabled` state.
144
+ */
145
+ declare const FileUploadTrigger: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
146
+ interface FileUploadListProps extends Omit<ComponentPropsWithoutRef<"ul">, "className" | "children"> {
147
+ /**
148
+ * Omit to auto-render a `FileUploadItem` per selected file. Pass a function
149
+ * `(file, index) => ReactNode` to render items with your own upload
150
+ * `status`/`progress`, or pass elements to render them verbatim.
151
+ */
152
+ children?: ReactNode | ((file: File, index: number) => ReactNode);
153
+ className?: string;
154
+ }
155
+ /**
156
+ * Container for the selected files. `role="list"` is set explicitly so the
157
+ * list semantics survive the `flex` reset in Safari/VoiceOver. Renders nothing
158
+ * while empty in the default (auto or render-prop) mode.
159
+ */
160
+ declare const FileUploadList: import("react").ForwardRefExoticComponent<FileUploadListProps & import("react").RefAttributes<HTMLUListElement>>;
161
+ interface FileUploadItemProps extends Omit<ComponentPropsWithoutRef<"li">, "className" | "children"> {
162
+ /** The file this row represents (name, size, and type come from it). */
163
+ file: File;
164
+ /** Upload lifecycle you drive: `uploading` shows a progress bar, `success`/`error` a status icon. */
165
+ status?: FileUploadItemStatus;
166
+ /** Completion 0–100 while `status="uploading"`. Omit for an indeterminate bar. */
167
+ progress?: number;
168
+ /** Message shown while `status="error"`, in place of the size. */
169
+ error?: ReactNode;
170
+ /** Show the remove button. Defaults to `true`. */
171
+ removable?: boolean;
172
+ /** Remove handler. Defaults to removing this file from the selection. */
173
+ onRemove?: () => void;
174
+ /** Accessible name for the remove button. Defaults to `Remove {file name}`. */
175
+ removeLabel?: string;
176
+ /** Leading visual. Defaults to an auto thumbnail for images, else a file icon. */
177
+ preview?: ReactNode;
178
+ /** Replace the entire row body. */
179
+ children?: ReactNode;
180
+ className?: string;
181
+ }
182
+ /**
183
+ * One selected file: a thumbnail (auto-generated for images) or file icon, the
184
+ * name, and — depending on `status` — its size, an upload progress bar, or an
185
+ * error message, plus a remove button. `status`/`progress`/`error` are
186
+ * consumer-driven so the row reflects real upload state.
187
+ */
188
+ declare const FileUploadItem: import("react").ForwardRefExoticComponent<FileUploadItemProps & import("react").RefAttributes<HTMLLIElement>>;
189
+ //#endregion
190
+ export { FileUpload, FileUploadDropzone, FileUploadDropzoneProps, FileUploadDropzoneVariantsOptions, FileUploadHandle, FileUploadItem, FileUploadItemProps, FileUploadItemStatus, FileUploadList, FileUploadListProps, FileUploadProps, FileUploadRejection, FileUploadRejectionCode, FileUploadRenderState, FileUploadTrigger, FileUploadTriggerProps, fileUploadDropzoneVariants, formatFileSize, useFileUpload };