@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/extra.mjs
CHANGED
|
@@ -19341,6 +19341,7 @@ var FileThumbnail = ({ item }) => {
|
|
|
19341
19341
|
) : /* @__PURE__ */ jsx(File2, { className: "h-4 w-4 text-muted-foreground/50" }) });
|
|
19342
19342
|
};
|
|
19343
19343
|
var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref) {
|
|
19344
|
+
var _a;
|
|
19344
19345
|
const {
|
|
19345
19346
|
value,
|
|
19346
19347
|
onValue,
|
|
@@ -19393,7 +19394,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19393
19394
|
} = props;
|
|
19394
19395
|
const joinControls = mode === "default" ? joinControlsProp != null ? joinControlsProp : true : false;
|
|
19395
19396
|
const extendBoxToControls = mode === "default" ? extendBoxToControlsProp != null ? extendBoxToControlsProp : true : false;
|
|
19396
|
-
const items = value != null ?
|
|
19397
|
+
const items = (_a = toArray2(value)) != null ? _a : [];
|
|
19397
19398
|
const isDisabled = Boolean(disabled || readOnly);
|
|
19398
19399
|
const [dragOver, setDragOver] = React.useState(false);
|
|
19399
19400
|
const [selectedIds, setSelectedIds] = React.useState(
|
|
@@ -19477,12 +19478,16 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19477
19478
|
setSelectedIds(/* @__PURE__ */ new Set());
|
|
19478
19479
|
}, [emitChange, items, selectedIds]);
|
|
19479
19480
|
const openPicker = React.useCallback(async () => {
|
|
19480
|
-
var
|
|
19481
|
+
var _a2;
|
|
19481
19482
|
if (isDisabled) return;
|
|
19482
19483
|
let resolvedLoader = customLoader != null ? customLoader : custom && getPaletteUtil("customLoader");
|
|
19483
19484
|
if (resolvedLoader) {
|
|
19484
19485
|
try {
|
|
19485
|
-
const result = await resolvedLoader({
|
|
19486
|
+
const result = await resolvedLoader({
|
|
19487
|
+
multiple,
|
|
19488
|
+
current: items,
|
|
19489
|
+
allowedTypes: toArray2(accept)
|
|
19490
|
+
});
|
|
19486
19491
|
if (!result) return;
|
|
19487
19492
|
const normalized = toArray2(result).map(normaliseFileLike);
|
|
19488
19493
|
if (mergeMode === "replace" || !multiple) {
|
|
@@ -19498,7 +19503,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19498
19503
|
}
|
|
19499
19504
|
return;
|
|
19500
19505
|
}
|
|
19501
|
-
(
|
|
19506
|
+
(_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
19502
19507
|
}, [
|
|
19503
19508
|
customLoader,
|
|
19504
19509
|
emitChange,
|
|
@@ -19517,18 +19522,18 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19517
19522
|
);
|
|
19518
19523
|
const onDrop = React.useCallback(
|
|
19519
19524
|
(e4) => {
|
|
19520
|
-
var
|
|
19525
|
+
var _a2;
|
|
19521
19526
|
e4.preventDefault();
|
|
19522
19527
|
setDragOver(false);
|
|
19523
|
-
if (isDisabled || !((
|
|
19528
|
+
if (isDisabled || !((_a2 = e4.dataTransfer.files) == null ? void 0 : _a2.length)) return;
|
|
19524
19529
|
const files = normaliseFromFiles(e4.dataTransfer.files);
|
|
19525
19530
|
handleAddItems(files, "drop");
|
|
19526
19531
|
},
|
|
19527
19532
|
[handleAddItems, isDisabled]
|
|
19528
19533
|
);
|
|
19529
19534
|
const onNativeChange = (e4) => {
|
|
19530
|
-
var
|
|
19531
|
-
if ((
|
|
19535
|
+
var _a2;
|
|
19536
|
+
if ((_a2 = e4.target.files) == null ? void 0 : _a2.length) {
|
|
19532
19537
|
handleAddItems(normaliseFromFiles(e4.target.files), "input");
|
|
19533
19538
|
}
|
|
19534
19539
|
e4.target.value = "";
|
|
@@ -19542,8 +19547,8 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19542
19547
|
const [preview2, setPreview] = React.useState(null);
|
|
19543
19548
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
19544
19549
|
React.useEffect(() => {
|
|
19545
|
-
var
|
|
19546
|
-
const isImage2 = ((
|
|
19550
|
+
var _a2;
|
|
19551
|
+
const isImage2 = ((_a2 = item.type) == null ? void 0 : _a2.startsWith("image/")) || item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i);
|
|
19547
19552
|
if (!isImage2) {
|
|
19548
19553
|
setPreview(null);
|
|
19549
19554
|
return;
|
|
@@ -19929,7 +19934,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19929
19934
|
),
|
|
19930
19935
|
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
19931
19936
|
items.map((item) => {
|
|
19932
|
-
var
|
|
19937
|
+
var _a2;
|
|
19933
19938
|
const selected = selectedIds.has(item.id);
|
|
19934
19939
|
const toggle = () => {
|
|
19935
19940
|
const next = new Set(selectedIds);
|
|
@@ -19956,7 +19961,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19956
19961
|
),
|
|
19957
19962
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
19958
19963
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
19959
|
-
/* @__PURE__ */ jsx("div", { className: "truncate font-medium", children: (
|
|
19964
|
+
/* @__PURE__ */ jsx("div", { className: "truncate font-medium", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }),
|
|
19960
19965
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
19961
19966
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(
|
|
19962
19967
|
item.size
|
|
@@ -20074,7 +20079,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
20074
20079
|
] })
|
|
20075
20080
|
] }),
|
|
20076
20081
|
/* @__PURE__ */ jsx(ScrollArea, { className: cn("mt-1 w-full", listClassName), children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: items.map((item, index) => {
|
|
20077
|
-
var
|
|
20082
|
+
var _a2;
|
|
20078
20083
|
const selected = selectedIds.has(item.id);
|
|
20079
20084
|
const toggle = () => {
|
|
20080
20085
|
const next = new Set(selectedIds);
|
|
@@ -20109,7 +20114,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
20109
20114
|
),
|
|
20110
20115
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
20111
20116
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
20112
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: (
|
|
20117
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }) }),
|
|
20113
20118
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
20114
20119
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(item.size) }),
|
|
20115
20120
|
item.status === "loading" && /* @__PURE__ */ jsx("span", { className: "flex items-center gap-1 text-primary", children: /* @__PURE__ */ jsx(LoaderCircle, { className: "h-3 w-3 animate-spin" }) }),
|