@webdevarif/dashui 0.2.2 → 0.2.3
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.js +83 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1909,10 +1909,49 @@ function MediaPickerDialog({
|
|
|
1909
1909
|
onSelect
|
|
1910
1910
|
}) {
|
|
1911
1911
|
const [localSelected, setLocalSelected] = React20.useState(/* @__PURE__ */ new Set());
|
|
1912
|
+
const [isDragging, setIsDragging] = React20.useState(false);
|
|
1912
1913
|
const fileInputRef = React20.useRef(null);
|
|
1914
|
+
const dragCounterRef = React20.useRef(0);
|
|
1913
1915
|
React20.useEffect(() => {
|
|
1914
|
-
if (!open)
|
|
1916
|
+
if (!open) {
|
|
1917
|
+
setLocalSelected(/* @__PURE__ */ new Set());
|
|
1918
|
+
setIsDragging(false);
|
|
1919
|
+
dragCounterRef.current = 0;
|
|
1920
|
+
}
|
|
1915
1921
|
}, [open]);
|
|
1922
|
+
const handleDragEnter = (e) => {
|
|
1923
|
+
e.preventDefault();
|
|
1924
|
+
e.stopPropagation();
|
|
1925
|
+
if (e.dataTransfer.types.includes("Files")) {
|
|
1926
|
+
dragCounterRef.current++;
|
|
1927
|
+
setIsDragging(true);
|
|
1928
|
+
}
|
|
1929
|
+
};
|
|
1930
|
+
const handleDragLeave = (e) => {
|
|
1931
|
+
e.preventDefault();
|
|
1932
|
+
e.stopPropagation();
|
|
1933
|
+
dragCounterRef.current--;
|
|
1934
|
+
if (dragCounterRef.current <= 0) {
|
|
1935
|
+
dragCounterRef.current = 0;
|
|
1936
|
+
setIsDragging(false);
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
const handleDragOver = (e) => {
|
|
1940
|
+
e.preventDefault();
|
|
1941
|
+
e.stopPropagation();
|
|
1942
|
+
};
|
|
1943
|
+
const handleDrop = (e) => {
|
|
1944
|
+
e.preventDefault();
|
|
1945
|
+
e.stopPropagation();
|
|
1946
|
+
dragCounterRef.current = 0;
|
|
1947
|
+
setIsDragging(false);
|
|
1948
|
+
if (!onUpload || !e.dataTransfer.files.length) return;
|
|
1949
|
+
const accepted = accept === "images" ? Array.from(e.dataTransfer.files).filter((f) => f.type.startsWith("image/")) : Array.from(e.dataTransfer.files);
|
|
1950
|
+
if (!accepted.length) return;
|
|
1951
|
+
const dt = new DataTransfer();
|
|
1952
|
+
accepted.forEach((f) => dt.items.add(f));
|
|
1953
|
+
onUpload(dt.files);
|
|
1954
|
+
};
|
|
1916
1955
|
const typeOptions = ALL_TYPE_OPTIONS.filter(
|
|
1917
1956
|
(o) => accept === "images" ? o.value === "all" || o.value === "images" : true
|
|
1918
1957
|
);
|
|
@@ -2056,27 +2095,49 @@ function MediaPickerDialog({
|
|
|
2056
2095
|
"%"
|
|
2057
2096
|
] })
|
|
2058
2097
|
] }, i)) }),
|
|
2059
|
-
/* @__PURE__ */ jsxs20(
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2098
|
+
/* @__PURE__ */ jsxs20(
|
|
2099
|
+
"div",
|
|
2100
|
+
{
|
|
2101
|
+
className: "relative flex-1 overflow-y-auto p-4",
|
|
2102
|
+
onDragEnter: handleDragEnter,
|
|
2103
|
+
onDragLeave: handleDragLeave,
|
|
2104
|
+
onDragOver: handleDragOver,
|
|
2105
|
+
onDrop: handleDrop,
|
|
2106
|
+
children: [
|
|
2107
|
+
isDragging && onUpload && /* @__PURE__ */ jsxs20("div", { className: "pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed border-primary bg-primary/5 backdrop-blur-[1px]", children: [
|
|
2108
|
+
/* @__PURE__ */ jsxs20("svg", { className: "h-10 w-10 text-primary opacity-70", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2109
|
+
/* @__PURE__ */ jsx34("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
|
|
2110
|
+
/* @__PURE__ */ jsx34("polyline", { points: "17 8 12 3 7 8" }),
|
|
2111
|
+
/* @__PURE__ */ jsx34("line", { x1: "12", y1: "3", x2: "12", y2: "15" })
|
|
2112
|
+
] }),
|
|
2113
|
+
/* @__PURE__ */ jsxs20("p", { className: "text-sm font-medium text-primary", children: [
|
|
2114
|
+
"Drop ",
|
|
2115
|
+
accept === "images" ? "images" : "files",
|
|
2116
|
+
" to upload"
|
|
2117
|
+
] })
|
|
2118
|
+
] }),
|
|
2119
|
+
/* @__PURE__ */ jsx34(
|
|
2120
|
+
MediaGrid,
|
|
2121
|
+
{
|
|
2122
|
+
files,
|
|
2123
|
+
selected: localSelected,
|
|
2124
|
+
onSelect: handleFileSelect,
|
|
2125
|
+
loading,
|
|
2126
|
+
columns: 5,
|
|
2127
|
+
onUploadClick: onUpload ? () => fileInputRef.current?.click() : void 0
|
|
2128
|
+
}
|
|
2129
|
+
),
|
|
2130
|
+
hasMore && /* @__PURE__ */ jsx34("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsx34(
|
|
2131
|
+
"button",
|
|
2132
|
+
{
|
|
2133
|
+
onClick: onLoadMore,
|
|
2134
|
+
className: "rounded-lg border px-4 py-2 text-xs text-muted-foreground transition-colors hover:bg-accent",
|
|
2135
|
+
children: "Load more"
|
|
2136
|
+
}
|
|
2137
|
+
) })
|
|
2138
|
+
]
|
|
2139
|
+
}
|
|
2140
|
+
)
|
|
2080
2141
|
] })
|
|
2081
2142
|
] }),
|
|
2082
2143
|
localSelected.size > 0 && /* @__PURE__ */ jsxs20("div", { className: "flex items-center justify-between gap-4 border-t px-5 py-3 shrink-0 bg-muted/20", children: [
|