@timeax/form-palette 0.1.1 → 0.1.2
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/extra.js +19 -14
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +19 -14
- package/dist/extra.mjs.map +1 -1
- package/dist/index.js +19 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19701,6 +19701,7 @@ var FileThumbnail = ({ item }) => {
|
|
|
19701
19701
|
) : /* @__PURE__ */ jsxRuntime.jsx(File2, { className: "h-4 w-4 text-muted-foreground/50" }) });
|
|
19702
19702
|
};
|
|
19703
19703
|
var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant2(props, ref) {
|
|
19704
|
+
var _a;
|
|
19704
19705
|
const {
|
|
19705
19706
|
value,
|
|
19706
19707
|
onValue,
|
|
@@ -19753,7 +19754,7 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
19753
19754
|
} = props;
|
|
19754
19755
|
const joinControls = mode === "default" ? joinControlsProp != null ? joinControlsProp : true : false;
|
|
19755
19756
|
const extendBoxToControls = mode === "default" ? extendBoxToControlsProp != null ? extendBoxToControlsProp : true : false;
|
|
19756
|
-
const items = value != null ?
|
|
19757
|
+
const items = (_a = toArray(value)) != null ? _a : [];
|
|
19757
19758
|
const isDisabled = Boolean(disabled || readOnly);
|
|
19758
19759
|
const [dragOver, setDragOver] = React68__namespace.useState(false);
|
|
19759
19760
|
const [selectedIds, setSelectedIds] = React68__namespace.useState(
|
|
@@ -19837,12 +19838,16 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
19837
19838
|
setSelectedIds(/* @__PURE__ */ new Set());
|
|
19838
19839
|
}, [emitChange, items, selectedIds]);
|
|
19839
19840
|
const openPicker = React68__namespace.useCallback(async () => {
|
|
19840
|
-
var
|
|
19841
|
+
var _a2;
|
|
19841
19842
|
if (isDisabled) return;
|
|
19842
19843
|
let resolvedLoader = customLoader != null ? customLoader : custom && getPaletteUtil("customLoader");
|
|
19843
19844
|
if (resolvedLoader) {
|
|
19844
19845
|
try {
|
|
19845
|
-
const result = await resolvedLoader({
|
|
19846
|
+
const result = await resolvedLoader({
|
|
19847
|
+
multiple,
|
|
19848
|
+
current: items,
|
|
19849
|
+
allowedTypes: toArray(accept)
|
|
19850
|
+
});
|
|
19846
19851
|
if (!result) return;
|
|
19847
19852
|
const normalized = toArray(result).map(normaliseFileLike);
|
|
19848
19853
|
if (mergeMode === "replace" || !multiple) {
|
|
@@ -19858,7 +19863,7 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
19858
19863
|
}
|
|
19859
19864
|
return;
|
|
19860
19865
|
}
|
|
19861
|
-
(
|
|
19866
|
+
(_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
19862
19867
|
}, [
|
|
19863
19868
|
customLoader,
|
|
19864
19869
|
emitChange,
|
|
@@ -19877,18 +19882,18 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
19877
19882
|
);
|
|
19878
19883
|
const onDrop = React68__namespace.useCallback(
|
|
19879
19884
|
(e4) => {
|
|
19880
|
-
var
|
|
19885
|
+
var _a2;
|
|
19881
19886
|
e4.preventDefault();
|
|
19882
19887
|
setDragOver(false);
|
|
19883
|
-
if (isDisabled || !((
|
|
19888
|
+
if (isDisabled || !((_a2 = e4.dataTransfer.files) == null ? void 0 : _a2.length)) return;
|
|
19884
19889
|
const files = normaliseFromFiles(e4.dataTransfer.files);
|
|
19885
19890
|
handleAddItems(files, "drop");
|
|
19886
19891
|
},
|
|
19887
19892
|
[handleAddItems, isDisabled]
|
|
19888
19893
|
);
|
|
19889
19894
|
const onNativeChange = (e4) => {
|
|
19890
|
-
var
|
|
19891
|
-
if ((
|
|
19895
|
+
var _a2;
|
|
19896
|
+
if ((_a2 = e4.target.files) == null ? void 0 : _a2.length) {
|
|
19892
19897
|
handleAddItems(normaliseFromFiles(e4.target.files), "input");
|
|
19893
19898
|
}
|
|
19894
19899
|
e4.target.value = "";
|
|
@@ -19902,8 +19907,8 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
19902
19907
|
const [preview2, setPreview] = React68__namespace.useState(null);
|
|
19903
19908
|
const [isOpen, setIsOpen] = React68__namespace.useState(false);
|
|
19904
19909
|
React68__namespace.useEffect(() => {
|
|
19905
|
-
var
|
|
19906
|
-
const isImage2 = ((
|
|
19910
|
+
var _a2;
|
|
19911
|
+
const isImage2 = ((_a2 = item.type) == null ? void 0 : _a2.startsWith("image/")) || item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i);
|
|
19907
19912
|
if (!isImage2) {
|
|
19908
19913
|
setPreview(null);
|
|
19909
19914
|
return;
|
|
@@ -20289,7 +20294,7 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
20289
20294
|
),
|
|
20290
20295
|
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
20291
20296
|
items.map((item) => {
|
|
20292
|
-
var
|
|
20297
|
+
var _a2;
|
|
20293
20298
|
const selected = selectedIds.has(item.id);
|
|
20294
20299
|
const toggle = () => {
|
|
20295
20300
|
const next = new Set(selectedIds);
|
|
@@ -20316,7 +20321,7 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
20316
20321
|
),
|
|
20317
20322
|
/* @__PURE__ */ jsxRuntime.jsx(FileThumbnail, { item }),
|
|
20318
20323
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
20319
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate font-medium", children: (
|
|
20324
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate font-medium", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }),
|
|
20320
20325
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
20321
20326
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatFileSize(
|
|
20322
20327
|
item.size
|
|
@@ -20434,7 +20439,7 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
20434
20439
|
] })
|
|
20435
20440
|
] }),
|
|
20436
20441
|
/* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: cn("mt-1 w-full", listClassName), children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-2", children: items.map((item, index) => {
|
|
20437
|
-
var
|
|
20442
|
+
var _a2;
|
|
20438
20443
|
const selected = selectedIds.has(item.id);
|
|
20439
20444
|
const toggle = () => {
|
|
20440
20445
|
const next = new Set(selectedIds);
|
|
@@ -20469,7 +20474,7 @@ var ShadcnFileVariant = React68__namespace.forwardRef(function ShadcnFileVariant
|
|
|
20469
20474
|
),
|
|
20470
20475
|
/* @__PURE__ */ jsxRuntime.jsx(FileThumbnail, { item }),
|
|
20471
20476
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
20472
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium text-foreground", children: (
|
|
20477
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-medium text-foreground", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }) }),
|
|
20473
20478
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
20474
20479
|
/* @__PURE__ */ jsxRuntime.jsx("span", { children: formatFileSize(item.size) }),
|
|
20475
20480
|
item.status === "loading" && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex items-center gap-1 text-primary", children: /* @__PURE__ */ jsxRuntime.jsx(LoaderCircle, { className: "h-3 w-3 animate-spin" }) }),
|