@underverse-ui/underverse 1.0.180 → 1.0.182
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/api-reference.json +1 -1
- package/dist/index.cjs +40 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +40 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2197,13 +2197,14 @@ interface ImageUploadProps {
|
|
|
2197
2197
|
disabled?: boolean;
|
|
2198
2198
|
className?: string;
|
|
2199
2199
|
showPreview?: boolean;
|
|
2200
|
-
previewSize?: "sm" | "md" | "lg";
|
|
2200
|
+
previewSize?: "sx" | "sm" | "md" | "lg";
|
|
2201
2201
|
dragDropText?: string;
|
|
2202
2202
|
browseText?: string;
|
|
2203
2203
|
supportedFormatsText?: string;
|
|
2204
|
+
uploadAreaHeight?: string | number;
|
|
2204
2205
|
}
|
|
2205
2206
|
declare function ImageUpload({ onUpload, onRemove, maxSize, // Convert bytes to MB
|
|
2206
|
-
accept, multiple, disabled, className, showPreview, previewSize, dragDropText, browseText, supportedFormatsText, }: ImageUploadProps): react_jsx_runtime.JSX.Element;
|
|
2207
|
+
accept, multiple, disabled, className, showPreview, previewSize, dragDropText, browseText, supportedFormatsText, uploadAreaHeight, }: ImageUploadProps): react_jsx_runtime.JSX.Element;
|
|
2207
2208
|
|
|
2208
2209
|
interface UploadedFile {
|
|
2209
2210
|
id: string | number;
|
package/dist/index.d.ts
CHANGED
|
@@ -2197,13 +2197,14 @@ interface ImageUploadProps {
|
|
|
2197
2197
|
disabled?: boolean;
|
|
2198
2198
|
className?: string;
|
|
2199
2199
|
showPreview?: boolean;
|
|
2200
|
-
previewSize?: "sm" | "md" | "lg";
|
|
2200
|
+
previewSize?: "sx" | "sm" | "md" | "lg";
|
|
2201
2201
|
dragDropText?: string;
|
|
2202
2202
|
browseText?: string;
|
|
2203
2203
|
supportedFormatsText?: string;
|
|
2204
|
+
uploadAreaHeight?: string | number;
|
|
2204
2205
|
}
|
|
2205
2206
|
declare function ImageUpload({ onUpload, onRemove, maxSize, // Convert bytes to MB
|
|
2206
|
-
accept, multiple, disabled, className, showPreview, previewSize, dragDropText, browseText, supportedFormatsText, }: ImageUploadProps): react_jsx_runtime.JSX.Element;
|
|
2207
|
+
accept, multiple, disabled, className, showPreview, previewSize, dragDropText, browseText, supportedFormatsText, uploadAreaHeight, }: ImageUploadProps): react_jsx_runtime.JSX.Element;
|
|
2207
2208
|
|
|
2208
2209
|
interface UploadedFile {
|
|
2209
2210
|
id: string | number;
|
package/dist/index.js
CHANGED
|
@@ -21708,7 +21708,8 @@ function ImageUpload({
|
|
|
21708
21708
|
previewSize = "md",
|
|
21709
21709
|
dragDropText,
|
|
21710
21710
|
browseText,
|
|
21711
|
-
supportedFormatsText
|
|
21711
|
+
supportedFormatsText,
|
|
21712
|
+
uploadAreaHeight
|
|
21712
21713
|
}) {
|
|
21713
21714
|
const [isDragging, setIsDragging] = useState34(false);
|
|
21714
21715
|
const [uploading, setUploading] = useState34(false);
|
|
@@ -21717,10 +21718,12 @@ function ImageUpload({
|
|
|
21717
21718
|
const { addToast } = useToast();
|
|
21718
21719
|
const t = useSmartTranslations("OCR.imageUpload");
|
|
21719
21720
|
const previewSizes = {
|
|
21721
|
+
sx: "w-12 h-12",
|
|
21720
21722
|
sm: "w-16 h-16",
|
|
21721
21723
|
md: "w-24 h-24",
|
|
21722
21724
|
lg: "w-32 h-32"
|
|
21723
21725
|
};
|
|
21726
|
+
const compactUploadArea = typeof uploadAreaHeight === "number" ? uploadAreaHeight <= 150 : typeof uploadAreaHeight === "string" && /^\s*\d+(?:\.\d+)?px\s*$/.test(uploadAreaHeight) ? parseFloat(uploadAreaHeight) <= 150 : false;
|
|
21724
21727
|
const handleDragOver = useCallback19(
|
|
21725
21728
|
(e) => {
|
|
21726
21729
|
e.preventDefault();
|
|
@@ -21757,11 +21760,12 @@ function ImageUpload({
|
|
|
21757
21760
|
if (validFiles.length === 0) return;
|
|
21758
21761
|
setUploading(true);
|
|
21759
21762
|
try {
|
|
21763
|
+
let idCount = 0;
|
|
21760
21764
|
for (const file of validFiles) {
|
|
21761
21765
|
const formData = new FormData();
|
|
21762
21766
|
formData.append("file", file);
|
|
21763
21767
|
const response = {
|
|
21764
|
-
id: Date.now(),
|
|
21768
|
+
id: Date.now() + idCount,
|
|
21765
21769
|
path: "",
|
|
21766
21770
|
url: URL.createObjectURL(file),
|
|
21767
21771
|
originalName: file.name,
|
|
@@ -21788,6 +21792,7 @@ function ImageUpload({
|
|
|
21788
21792
|
type: "success",
|
|
21789
21793
|
message: `"${file.name}" uploaded successfully`
|
|
21790
21794
|
});
|
|
21795
|
+
idCount++;
|
|
21791
21796
|
}
|
|
21792
21797
|
} catch (error) {
|
|
21793
21798
|
console.error("Upload error:", error);
|
|
@@ -21833,11 +21838,14 @@ function ImageUpload({
|
|
|
21833
21838
|
"div",
|
|
21834
21839
|
{
|
|
21835
21840
|
className: cn(
|
|
21836
|
-
"relative border-2 border-dashed rounded-2xl md:rounded-3xl
|
|
21841
|
+
"relative border-2 border-dashed rounded-2xl md:rounded-3xl text-center transition-all duration-200",
|
|
21842
|
+
uploadAreaHeight ? "px-4 py-3 sm:px-6 sm:py-4" : "p-8",
|
|
21843
|
+
compactUploadArea && "px-3 py-2 sm:px-4 sm:py-3",
|
|
21837
21844
|
isDragging && !disabled ? "border-primary bg-primary/5 scale-[1.02]" : "border-border/50 hover:border-primary/50",
|
|
21838
21845
|
disabled && "opacity-50 cursor-not-allowed",
|
|
21839
21846
|
uploading && "pointer-events-none"
|
|
21840
21847
|
),
|
|
21848
|
+
style: uploadAreaHeight ? { height: uploadAreaHeight } : void 0,
|
|
21841
21849
|
onDragOver: handleDragOver,
|
|
21842
21850
|
onDragLeave: handleDragLeave,
|
|
21843
21851
|
onDrop: handleDrop,
|
|
@@ -21846,14 +21854,35 @@ function ImageUpload({
|
|
|
21846
21854
|
/* @__PURE__ */ jsx54(Loader24, { className: "w-6 h-6 animate-spin text-primary" }),
|
|
21847
21855
|
/* @__PURE__ */ jsx54("span", { className: "text-sm font-medium", children: "Uploading..." })
|
|
21848
21856
|
] }) }),
|
|
21849
|
-
/* @__PURE__ */ jsxs42(
|
|
21850
|
-
|
|
21851
|
-
|
|
21852
|
-
|
|
21853
|
-
|
|
21854
|
-
|
|
21855
|
-
|
|
21856
|
-
|
|
21857
|
+
/* @__PURE__ */ jsxs42(
|
|
21858
|
+
"div",
|
|
21859
|
+
{
|
|
21860
|
+
className: cn(
|
|
21861
|
+
"space-y-4",
|
|
21862
|
+
uploadAreaHeight && "flex h-full flex-col items-center justify-center gap-3 space-y-0",
|
|
21863
|
+
compactUploadArea && "flex-row items-center justify-between gap-3 text-left"
|
|
21864
|
+
),
|
|
21865
|
+
children: [
|
|
21866
|
+
/* @__PURE__ */ jsx54("div", { className: cn("bg-primary/10 rounded-full flex items-center justify-center shrink-0", compactUploadArea ? "w-9 h-9 mx-0" : "mx-auto w-12 h-12"), children: /* @__PURE__ */ jsx54(Upload, { className: cn("text-primary", compactUploadArea ? "w-4 h-4" : "w-6 h-6") }) }),
|
|
21867
|
+
/* @__PURE__ */ jsxs42("div", { className: cn("space-y-2", compactUploadArea && "flex min-w-0 flex-1 items-center justify-between gap-3 space-y-0"), children: [
|
|
21868
|
+
/* @__PURE__ */ jsx54("p", { className: cn("text-muted-foreground", compactUploadArea && "text-sm leading-tight whitespace-nowrap"), children: dragDropText || t("dragDropText") }),
|
|
21869
|
+
/* @__PURE__ */ jsx54(
|
|
21870
|
+
Button_default,
|
|
21871
|
+
{
|
|
21872
|
+
type: "button",
|
|
21873
|
+
variant: "outline",
|
|
21874
|
+
size: "sm",
|
|
21875
|
+
className: cn(compactUploadArea && "shrink-0"),
|
|
21876
|
+
onClick: handleBrowseClick,
|
|
21877
|
+
disabled: disabled || uploading,
|
|
21878
|
+
children: browseText || t("browseFiles")
|
|
21879
|
+
}
|
|
21880
|
+
)
|
|
21881
|
+
] }),
|
|
21882
|
+
!compactUploadArea && /* @__PURE__ */ jsx54("p", { className: "text-xs text-muted-foreground", children: supportedFormatsText || t("supportedFormats") })
|
|
21883
|
+
]
|
|
21884
|
+
}
|
|
21885
|
+
),
|
|
21857
21886
|
/* @__PURE__ */ jsx54(
|
|
21858
21887
|
"input",
|
|
21859
21888
|
{
|