@nomos-ui/form 0.0.23 → 0.0.25
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/components/file-input.d.ts +59 -44
- package/dist/components/file-input.d.ts.map +1 -1
- package/dist/components/file-input.js +32 -42
- package/dist/components/file-input.js.map +1 -1
- package/dist/components/form-file-input.js +1 -1
- package/dist/components/form-file-input.js.map +1 -1
- package/dist/exports/index.d.ts +2 -2
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/exports/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,27 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* The `id` is a stable random key generated on ingestion so React
|
|
5
|
-
* reconciliation stays correct even when the same filename is added twice.
|
|
6
|
-
*/
|
|
7
|
-
export type FileInputFile = {
|
|
8
|
-
/** The native browser `File` object. */
|
|
9
|
-
file: File;
|
|
10
|
-
/**
|
|
11
|
-
* Stable random identifier assigned when the file is added.
|
|
12
|
-
* Use this as the React `key` and to target a specific file for removal.
|
|
13
|
-
*/
|
|
14
|
-
id: string;
|
|
15
|
-
};
|
|
16
|
-
export type FileInputProps = {
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type FileInputPropsBase = {
|
|
17
3
|
/** Additional class name for the root container. */
|
|
18
4
|
className?: string;
|
|
19
|
-
/**
|
|
20
|
-
|
|
5
|
+
/** Props forwarded to the dropzone wrapper div. */
|
|
6
|
+
dropzoneProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
21
7
|
/** Label text rendered above the dropzone. */
|
|
22
8
|
label?: string;
|
|
23
|
-
/**
|
|
24
|
-
|
|
9
|
+
/** Props forwarded to the label wrapper div. */
|
|
10
|
+
labelProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
25
11
|
/** Marks the field as required for native form validation. */
|
|
26
12
|
required?: boolean;
|
|
27
13
|
/**
|
|
@@ -54,30 +40,45 @@ export type FileInputProps = {
|
|
|
54
40
|
*/
|
|
55
41
|
maxSize?: number;
|
|
56
42
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
43
|
+
* Fired when a file is rejected before being added to the list.
|
|
44
|
+
* Common reasons: file exceeds `maxSize`.
|
|
45
|
+
*
|
|
46
|
+
* @param message - A human-readable description of why the file was rejected.
|
|
59
47
|
*/
|
|
60
|
-
|
|
48
|
+
onError?: (message: string) => void;
|
|
49
|
+
/** Disables the dropzone click / drag and all per-file remove buttons. */
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
};
|
|
52
|
+
type FileInputPropsSingle = FileInputPropsBase & {
|
|
53
|
+
/**
|
|
54
|
+
* When `false` (default) `onChange` receives a single `File | null`.
|
|
55
|
+
*/
|
|
56
|
+
multiple?: false;
|
|
57
|
+
/** The currently selected file, or `null` when empty. */
|
|
58
|
+
value?: File | null;
|
|
59
|
+
/**
|
|
60
|
+
* Fired whenever the selected file changes or is removed.
|
|
61
|
+
*
|
|
62
|
+
* @param file - The selected file, or `null` when cleared.
|
|
63
|
+
*/
|
|
64
|
+
onChange?: (file: File | null) => void;
|
|
65
|
+
};
|
|
66
|
+
type FileInputPropsMultiple = FileInputPropsBase & {
|
|
67
|
+
/**
|
|
68
|
+
* When `true` `onChange` receives the full updated `File[]`.
|
|
69
|
+
*/
|
|
70
|
+
multiple: true;
|
|
61
71
|
/**
|
|
62
72
|
* Controlled list of currently accepted files.
|
|
63
73
|
* Pass an empty array (`[]`) to represent an empty / reset state.
|
|
64
74
|
*/
|
|
65
|
-
value?:
|
|
75
|
+
value?: File[];
|
|
66
76
|
/**
|
|
67
77
|
* Fired whenever the file list changes — either a file was added or removed.
|
|
68
78
|
*
|
|
69
79
|
* @param files - The complete updated file list.
|
|
70
80
|
*/
|
|
71
|
-
onChange?: (files:
|
|
72
|
-
/**
|
|
73
|
-
* Fired when a file is rejected before being added to the list.
|
|
74
|
-
* Common reasons: file exceeds `maxSize`.
|
|
75
|
-
*
|
|
76
|
-
* @param message - A human-readable description of why the file was rejected.
|
|
77
|
-
*/
|
|
78
|
-
onError?: (message: string) => void;
|
|
79
|
-
/** Disables the dropzone click / drag and all per-file remove buttons. */
|
|
80
|
-
disabled?: boolean;
|
|
81
|
+
onChange?: (files: File[]) => void;
|
|
81
82
|
};
|
|
82
83
|
/**
|
|
83
84
|
* A file-upload input that follows the shadcn component ideology.
|
|
@@ -87,25 +88,39 @@ export type FileInputProps = {
|
|
|
87
88
|
* - Label + required sign + tip + error pattern identical to `Input` / `Textarea`
|
|
88
89
|
* - Drag-and-drop with a clear visual drag state
|
|
89
90
|
* - Per-file rows listing name, size, and a remove button
|
|
90
|
-
* - Single or multiple file support
|
|
91
|
+
* - Single or multiple file support — `onChange` type is narrowed automatically
|
|
92
|
+
* - Pure `File` / `File[]` public API — no wrapper objects leaked to consumers
|
|
93
|
+
* - React keys managed internally via `WeakMap` + `crypto.randomUUID()`
|
|
91
94
|
*
|
|
92
|
-
* @example
|
|
95
|
+
* @example Single file
|
|
93
96
|
* ```tsx
|
|
94
|
-
* const [
|
|
97
|
+
* const [file, setFile] = React.useState<File | null>(null);
|
|
95
98
|
*
|
|
96
99
|
* <FileInput
|
|
97
100
|
* label="Resume"
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* accept=".pdf,.doc,.docx"
|
|
101
|
-
* acceptLabel="PDF, DOC, DOCX"
|
|
101
|
+
* accept=".pdf"
|
|
102
|
+
* acceptLabel="PDF"
|
|
102
103
|
* maxSize={50 * 1024 * 1024}
|
|
103
|
-
*
|
|
104
|
+
* value={file}
|
|
105
|
+
* onChange={setFile}
|
|
106
|
+
* />
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* @example Multiple files
|
|
110
|
+
* ```tsx
|
|
111
|
+
* const [files, setFiles] = React.useState<File[]>([]);
|
|
112
|
+
*
|
|
113
|
+
* <FileInput
|
|
114
|
+
* label="Attachments"
|
|
115
|
+
* multiple
|
|
116
|
+
* accept=".pdf,.docx"
|
|
117
|
+
* acceptLabel="PDF, DOCX"
|
|
104
118
|
* value={files}
|
|
105
119
|
* onChange={setFiles}
|
|
106
|
-
* onError={(msg) => toast.error(msg)}
|
|
107
120
|
* />
|
|
108
121
|
* ```
|
|
109
122
|
*/
|
|
110
|
-
export
|
|
123
|
+
export type FileInputProps = FileInputPropsSingle | FileInputPropsMultiple;
|
|
124
|
+
export default function FileInput({ className, dropzoneProps, label, labelProps, required, showRequiredSign, tip, error, accept, acceptLabel, maxSize, multiple, value, onChange, onError, disabled, }: FileInputProps): import("react/jsx-runtime").JSX.Element;
|
|
125
|
+
export {};
|
|
111
126
|
//# sourceMappingURL=file-input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-input.d.ts","sourceRoot":"","sources":["../../src/components/file-input.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-input.d.ts","sourceRoot":"","sources":["../../src/components/file-input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,KAAK,kBAAkB,GAAG;IACxB,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,aAAa,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IACrD,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,UAAU,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IAClD,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,KAAK,oBAAoB,GAAG,kBAAkB,GAAG;IAC/C;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,yDAAyD;IACzD,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,KAAK,sBAAsB,GAAG,kBAAkB,GAAG;IACjD;;OAEG;IACH,QAAQ,EAAE,IAAI,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAQ3E,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,SAAS,EACT,aAAa,EACb,KAAK,EACL,UAAU,EACV,QAAgB,EAChB,gBAAwB,EACxB,GAAG,EACH,KAAK,EACL,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAgB,EAChB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAgB,GACjB,EAAE,cAAc,2CAwLhB"}
|
|
@@ -38,7 +38,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
38
38
|
const React = __importStar(require("react"));
|
|
39
39
|
const lucide_react_1 = require("lucide-react");
|
|
40
40
|
const utils_1 = require("../utils/shadcn-ui/utils");
|
|
41
|
-
/** Converts a raw byte count into a human-readable string (B / KB / MB). */
|
|
42
41
|
function formatBytes(bytes) {
|
|
43
42
|
if (bytes < 1024)
|
|
44
43
|
return `${bytes} B`;
|
|
@@ -46,41 +45,21 @@ function formatBytes(bytes) {
|
|
|
46
45
|
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
47
46
|
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
48
47
|
}
|
|
49
|
-
|
|
50
|
-
function generateId() {
|
|
51
|
-
return Math.random().toString(36).slice(2, 9);
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* A file-upload input that follows the shadcn component ideology.
|
|
55
|
-
*
|
|
56
|
-
* Features:
|
|
57
|
-
* - Semantic design tokens (`foreground`, `muted-foreground`, `destructive`, …)
|
|
58
|
-
* - Label + required sign + tip + error pattern identical to `Input` / `Textarea`
|
|
59
|
-
* - Drag-and-drop with a clear visual drag state
|
|
60
|
-
* - Per-file rows listing name, size, and a remove button
|
|
61
|
-
* - Single or multiple file support
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```tsx
|
|
65
|
-
* const [files, setFiles] = React.useState<FileInputFile[]>([]);
|
|
66
|
-
*
|
|
67
|
-
* <FileInput
|
|
68
|
-
* label="Resume"
|
|
69
|
-
* required
|
|
70
|
-
* showRequiredSign
|
|
71
|
-
* accept=".pdf,.doc,.docx"
|
|
72
|
-
* acceptLabel="PDF, DOC, DOCX"
|
|
73
|
-
* maxSize={50 * 1024 * 1024}
|
|
74
|
-
* tip="Max 50 MB per file."
|
|
75
|
-
* value={files}
|
|
76
|
-
* onChange={setFiles}
|
|
77
|
-
* onError={(msg) => toast.error(msg)}
|
|
78
|
-
* />
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
function FileInput({ className, dropzoneClassName, label, labelClassName, required = false, showRequiredSign = false, tip, error, accept, acceptLabel, maxSize, multiple = false, value = [], onChange, onError, disabled = false, }) {
|
|
48
|
+
function FileInput({ className, dropzoneProps, label, labelProps, required = false, showRequiredSign = false, tip, error, accept, acceptLabel, maxSize, multiple = false, value, onChange, onError, disabled = false, }) {
|
|
82
49
|
const inputRef = React.useRef(null);
|
|
83
50
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
51
|
+
const idMapRef = React.useRef(new WeakMap());
|
|
52
|
+
function getFileId(file) {
|
|
53
|
+
if (!idMapRef.current.has(file)) {
|
|
54
|
+
idMapRef.current.set(file, crypto.randomUUID());
|
|
55
|
+
}
|
|
56
|
+
return idMapRef.current.get(file);
|
|
57
|
+
}
|
|
58
|
+
const fileList = multiple
|
|
59
|
+
? (value ?? [])
|
|
60
|
+
: value
|
|
61
|
+
? [value]
|
|
62
|
+
: [];
|
|
84
63
|
function processFiles(rawFiles) {
|
|
85
64
|
if (!rawFiles || disabled)
|
|
86
65
|
return;
|
|
@@ -90,15 +69,24 @@ function FileInput({ className, dropzoneClassName, label, labelClassName, requir
|
|
|
90
69
|
onError?.(`"${file.name}" exceeds the maximum size of ${formatBytes(maxSize)}.`);
|
|
91
70
|
return;
|
|
92
71
|
}
|
|
93
|
-
incoming.push(
|
|
72
|
+
incoming.push(file);
|
|
94
73
|
});
|
|
95
74
|
if (!incoming.length)
|
|
96
75
|
return;
|
|
97
|
-
|
|
98
|
-
|
|
76
|
+
if (multiple) {
|
|
77
|
+
onChange?.([...fileList, ...incoming]);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
onChange?.(incoming[0] ?? null);
|
|
81
|
+
}
|
|
99
82
|
}
|
|
100
|
-
function removeFile(
|
|
101
|
-
|
|
83
|
+
function removeFile(file) {
|
|
84
|
+
if (multiple) {
|
|
85
|
+
onChange?.(fileList.filter((f) => f !== file));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
onChange?.(null);
|
|
89
|
+
}
|
|
102
90
|
if (inputRef.current)
|
|
103
91
|
inputRef.current.value = "";
|
|
104
92
|
}
|
|
@@ -116,9 +104,11 @@ function FileInput({ className, dropzoneClassName, label, labelClassName, requir
|
|
|
116
104
|
setIsDragging(false);
|
|
117
105
|
processFiles(e.dataTransfer.files);
|
|
118
106
|
}
|
|
119
|
-
const
|
|
120
|
-
|
|
107
|
+
const { className: dropzoneClassName, ...restDropzoneProps } = dropzoneProps ?? {};
|
|
108
|
+
const { className: labelClassName, ...restLabelProps } = labelProps ?? {};
|
|
109
|
+
const hasFiles = fileList.length > 0;
|
|
110
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, utils_1.cn)("w-full space-y-1.5", className), children: [label && ((0, jsx_runtime_1.jsxs)("div", { ...restLabelProps, className: (0, utils_1.cn)("flex items-center gap-1", labelClassName), children: [(0, jsx_runtime_1.jsx)("label", { className: "text-sm font-bold text-foreground", children: label }), required && showRequiredSign && ((0, jsx_runtime_1.jsx)(lucide_react_1.AsteriskIcon, { className: "h-3 w-3 text-destructive" }))] })), (0, jsx_runtime_1.jsxs)("div", { ...restDropzoneProps, onDragOver: onDragOver, onDragLeave: onDragLeave, onDrop: onDrop, className: (0, utils_1.cn)("relative flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed px-6 py-8 text-center transition-colors", "border-input bg-transparent", !disabled && "hover:border-ring/50 hover:bg-accent/40", isDragging && "border-ring bg-accent/60", error && "border-destructive", disabled && "cursor-not-allowed opacity-50", dropzoneClassName), children: [(0, jsx_runtime_1.jsx)("input", { ref: inputRef, type: "file", accept: accept, multiple: multiple, disabled: disabled, className: "absolute inset-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed", onChange: (e) => processFiles(e.target.files) }), (0, jsx_runtime_1.jsx)(lucide_react_1.CloudUploadIcon, { className: (0, utils_1.cn)("h-8 w-8 transition-colors", isDragging ? "text-ring" : "text-muted-foreground"), strokeWidth: 1.5 }), (0, jsx_runtime_1.jsxs)("div", { className: "pointer-events-none select-none space-y-1", children: [(0, jsx_runtime_1.jsx)("p", { className: "text-sm font-medium text-foreground", children: "Choose a file or drag & drop it here" }), (acceptLabel || maxSize) && ((0, jsx_runtime_1.jsx)("p", { className: "text-xs text-muted-foreground", children: [acceptLabel, maxSize ? `up to ${formatBytes(maxSize)}` : null]
|
|
121
111
|
.filter(Boolean)
|
|
122
|
-
.join(", ") }))] }), (0, jsx_runtime_1.jsx)("span", { className: "pointer-events-none select-none inline-flex items-center rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-xs", children: "Browse File" })] }), hasFiles && ((0, jsx_runtime_1.jsx)("ul", { className: "space-y-2", children:
|
|
112
|
+
.join(", ") }))] }), (0, jsx_runtime_1.jsx)("span", { className: "pointer-events-none select-none inline-flex items-center rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-xs", children: "Browse File" })] }), hasFiles && ((0, jsx_runtime_1.jsx)("ul", { className: "space-y-2", children: fileList.map((file) => ((0, jsx_runtime_1.jsxs)("li", { className: "flex items-center gap-3 rounded-lg border border-input bg-background px-3 py-2.5 shadow-xs", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-md border border-input bg-muted", children: (0, jsx_runtime_1.jsx)(lucide_react_1.FileIcon, { className: "h-4 w-4 text-muted-foreground" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0 flex-1", children: [(0, jsx_runtime_1.jsx)("p", { className: "truncate text-sm font-medium text-foreground", children: file.name }), (0, jsx_runtime_1.jsx)("p", { className: "text-xs text-muted-foreground", children: formatBytes(file.size) })] }), !disabled && ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => removeFile(file), className: "shrink-0 rounded-full p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", "aria-label": `Remove ${file.name}`, children: (0, jsx_runtime_1.jsx)(lucide_react_1.XIcon, { className: "h-4 w-4" }) }))] }, getFileId(file)))) })), tip && !error && ((0, jsx_runtime_1.jsx)("p", { className: "text-xs text-muted-foreground tip-message", children: tip })), error && ((0, jsx_runtime_1.jsxs)("p", { className: "text-xs text-destructive error-message", children: ["*", error] }))] }));
|
|
123
113
|
}
|
|
124
114
|
//# sourceMappingURL=file-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-input.js","sourceRoot":"","sources":["../../src/components/file-input.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"file-input.js","sourceRoot":"","sources":["../../src/components/file-input.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwIA,4BAyMC;;AAjVD,6CAA+B;AAC/B,+CAA8E;AAC9E,oDAA8C;AAgI9C,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC;AAED,SAAwB,SAAS,CAAC,EAChC,SAAS,EACT,aAAa,EACb,KAAK,EACL,UAAU,EACV,QAAQ,GAAG,KAAK,EAChB,gBAAgB,GAAG,KAAK,EACxB,GAAG,EACH,KAAK,EACL,MAAM,EACN,WAAW,EACX,OAAO,EACP,QAAQ,GAAG,KAAK,EAChB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,GAAG,KAAK,GACD;IACf,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;IACtD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,QA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EAEN,iCAAM,SAAS,EAAC,iJAAiJ,4BAE1J,IACH,EAEL,QAAQ,IAAI,CACX,+BAAI,SAAS,EAAC,WAAW,YACtB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACtB,gCAEE,SAAS,EAAC,4FAA4F,aAEtG,gCAAK,SAAS,EAAC,2FAA2F,YACxG,uBAAC,uBAAQ,IAAC,SAAS,EAAC,+BAA+B,GAAG,GAClD,EAEN,iCAAK,SAAS,EAAC,gBAAgB,aAC7B,8BAAG,SAAS,EAAC,8CAA8C,YACxD,IAAI,CAAC,IAAI,GACR,EACJ,8BAAG,SAAS,EAAC,+BAA+B,YACzC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GACrB,IACA,EAEL,CAAC,QAAQ,IAAI,CACZ,mCACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAC/B,SAAS,EAAC,0LAA0L,gBACxL,UAAU,IAAI,CAAC,IAAI,EAAE,YAEjC,uBAAC,oBAAK,IAAC,SAAS,EAAC,SAAS,GAAG,GACtB,CACV,KAzBI,SAAS,CAAC,IAAI,CAAC,CA0BjB,CACN,CAAC,GACC,CACN,EAEA,GAAG,IAAI,CAAC,KAAK,IAAI,CAChB,8BAAG,SAAS,EAAC,2CAA2C,YAAE,GAAG,GAAK,CACnE,EAEA,KAAK,IAAI,CACR,+BAAG,SAAS,EAAC,wCAAwC,kBAAG,KAAK,IAAK,CACnE,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -39,7 +39,7 @@ const form_helpers_1 = require("../utils/helpers/form.helpers");
|
|
|
39
39
|
function FormFileInput({ control, name, ...props }) {
|
|
40
40
|
return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { control: control, name: name, rules: {
|
|
41
41
|
required: props.required ? "Required" : false,
|
|
42
|
-
}, render: ({ field: { onChange, value }, formState: { errors } }) => ((0, jsx_runtime_1.jsx)(file_input_1.default, { ...props, value: value
|
|
42
|
+
}, render: ({ field: { onChange, value }, formState: { errors } }) => ((0, jsx_runtime_1.jsx)(file_input_1.default, { ...props, value: value, onChange: onChange, onError: (errorMessage) => {
|
|
43
43
|
control.setError(name, {
|
|
44
44
|
type: "manual",
|
|
45
45
|
message: errorMessage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-file-input.js","sourceRoot":"","sources":["../../src/components/form-file-input.tsx"],"names":[],"mappings":";;;;;AAgDA,gCA4BC;;AA5ED,qDAAyE;AACzE,8DAAyD;AACzD,gEAAsE;AAkBtE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAwB,aAAa,CAAmC,EACtE,OAAO,EACP,IAAI,EACJ,GAAG,KAAK,EACyB;IACjC,OAAO,CACL,uBAAC,4BAAU,IACT,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK;SAC9C,EACD,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CACjE,uBAAC,oBAAS,OACJ,KAAK,EACT,KAAK,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"form-file-input.js","sourceRoot":"","sources":["../../src/components/form-file-input.tsx"],"names":[],"mappings":";;;;;AAgDA,gCA4BC;;AA5ED,qDAAyE;AACzE,8DAAyD;AACzD,gEAAsE;AAkBtE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAwB,aAAa,CAAmC,EACtE,OAAO,EACP,IAAI,EACJ,GAAG,KAAK,EACyB;IACjC,OAAO,CACL,uBAAC,4BAAU,IACT,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE;YACL,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK;SAC9C,EACD,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CACjE,uBAAC,oBAAS,OACJ,KAAK,EACT,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,YAAoB,EAAE,EAAE;gBAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE;oBACrB,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,YAAY;iBACtB,CAAC,CAAC;YACL,CAAC,EACD,KAAK,EAAE,IAAA,oCAAqB,EAAC,MAAM,EAAE,IAAI,CAAC,GAC1C,CACH,GACD,CACH,CAAC;AACJ,CAAC"}
|
package/dist/exports/index.d.ts
CHANGED
|
@@ -7,11 +7,11 @@ import Textarea from "../components/textarea";
|
|
|
7
7
|
import FormTextarea from "../components/form-textarea";
|
|
8
8
|
import FormImageInput from "../components/form-image-input";
|
|
9
9
|
import ImageInput from "../components/image-input";
|
|
10
|
-
import FileInput, { FileInputProps
|
|
10
|
+
import FileInput, { FileInputProps } from "../components/file-input";
|
|
11
11
|
import FormFileInput, { FormFileInputProps } from "../components/form-file-input";
|
|
12
12
|
import FormDebugInfo from "../components/form-debug-info";
|
|
13
13
|
export { Button, FormDebugInfo, FormInput, Input, Select, FormSelect, Textarea, FormTextarea, ImageInput, FormImageInput, FileInput, FormFileInput, };
|
|
14
|
-
export type { SelectOption, SelectProps, FormSelectProps, FormFileInputProps, FileInputProps,
|
|
14
|
+
export type { SelectOption, SelectProps, FormSelectProps, FormFileInputProps, FileInputProps, };
|
|
15
15
|
export * from "../components/input";
|
|
16
16
|
export * from "../components/form-input";
|
|
17
17
|
export * from "../components/button";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,UAAU,EAAE,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAC1C,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,MAAM,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,UAAU,EAAE,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,SAAS,EAAE,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,aAAa,EAAE,EACpB,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EACL,MAAM,EACN,aAAa,EACb,SAAS,EACT,KAAK,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,cAAc,EACd,SAAS,EACT,aAAa,GACd,CAAC;AACF,YAAY,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,CAAC;AACF,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,kEAA0C;AAgBxC,iBAhBK,gBAAM,CAgBL;AAfR,0EAAiD;AAiB/C,oBAjBK,oBAAS,CAiBL;AAhBX,gEAAwC;AAiBtC,gBAjBK,eAAK,CAiBL;AAhBP,kEAAyE;AAiBvE,iBAjBK,gBAAM,CAiBL;AAhBR,4EAAwE;AAiBtE,qBAjBK,qBAAU,CAiBL;AAhBZ,sEAA8C;AAiB5C,mBAjBK,kBAAQ,CAiBL;AAhBV,gFAAuD;AAiBrD,uBAjBK,uBAAY,CAiBL;AAhBd,sFAA4D;AAkB1D,yBAlBK,0BAAc,CAkBL;AAjBhB,4EAAmD;AAgBjD,qBAhBK,qBAAU,CAgBL;AAfZ,0EAAqE;AAiBnE,oBAjBK,oBAAS,CAiBL;AAhBX,oFAEuC;AAerC,wBAjBK,yBAAa,CAiBL;AAdf,oFAA0D;AAIxD,wBAJK,yBAAa,CAIL;AAmBf,sDAAoC;AACpC,2DAAyC;AACzC,uDAAqC;AACrC,2DAAyC;AACzC,gEAA8C"}
|