@timeax/form-palette 0.1.0 → 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.d.mts +2 -2
- package/dist/extra.d.ts +2 -2
- package/dist/extra.js +21 -15
- package/dist/extra.js.map +1 -1
- package/dist/extra.mjs +21 -15
- package/dist/extra.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -15
- package/dist/index.mjs.map +1 -1
- package/dist/{variant-aFXJGBXI.d.mts → variant-BGkGWsSy.d.mts} +1 -0
- package/dist/{variant-Jrd0I0Ey.d.ts → variant-B_L0opEi.d.ts} +1 -0
- 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,
|
|
@@ -19367,6 +19368,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19367
19368
|
formatFileSize = formatSizeDefault,
|
|
19368
19369
|
placeholder = "Select file...",
|
|
19369
19370
|
className,
|
|
19371
|
+
custom,
|
|
19370
19372
|
dropAreaClassName,
|
|
19371
19373
|
listClassName,
|
|
19372
19374
|
triggerClassName,
|
|
@@ -19392,7 +19394,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19392
19394
|
} = props;
|
|
19393
19395
|
const joinControls = mode === "default" ? joinControlsProp != null ? joinControlsProp : true : false;
|
|
19394
19396
|
const extendBoxToControls = mode === "default" ? extendBoxToControlsProp != null ? extendBoxToControlsProp : true : false;
|
|
19395
|
-
const items = value != null ?
|
|
19397
|
+
const items = (_a = toArray2(value)) != null ? _a : [];
|
|
19396
19398
|
const isDisabled = Boolean(disabled || readOnly);
|
|
19397
19399
|
const [dragOver, setDragOver] = React.useState(false);
|
|
19398
19400
|
const [selectedIds, setSelectedIds] = React.useState(
|
|
@@ -19476,12 +19478,16 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19476
19478
|
setSelectedIds(/* @__PURE__ */ new Set());
|
|
19477
19479
|
}, [emitChange, items, selectedIds]);
|
|
19478
19480
|
const openPicker = React.useCallback(async () => {
|
|
19479
|
-
var
|
|
19481
|
+
var _a2;
|
|
19480
19482
|
if (isDisabled) return;
|
|
19481
|
-
let resolvedLoader = customLoader != null ? customLoader : getPaletteUtil("customLoader");
|
|
19483
|
+
let resolvedLoader = customLoader != null ? customLoader : custom && getPaletteUtil("customLoader");
|
|
19482
19484
|
if (resolvedLoader) {
|
|
19483
19485
|
try {
|
|
19484
|
-
const result = await resolvedLoader({
|
|
19486
|
+
const result = await resolvedLoader({
|
|
19487
|
+
multiple,
|
|
19488
|
+
current: items,
|
|
19489
|
+
allowedTypes: toArray2(accept)
|
|
19490
|
+
});
|
|
19485
19491
|
if (!result) return;
|
|
19486
19492
|
const normalized = toArray2(result).map(normaliseFileLike);
|
|
19487
19493
|
if (mergeMode === "replace" || !multiple) {
|
|
@@ -19497,7 +19503,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19497
19503
|
}
|
|
19498
19504
|
return;
|
|
19499
19505
|
}
|
|
19500
|
-
(
|
|
19506
|
+
(_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
19501
19507
|
}, [
|
|
19502
19508
|
customLoader,
|
|
19503
19509
|
emitChange,
|
|
@@ -19516,18 +19522,18 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19516
19522
|
);
|
|
19517
19523
|
const onDrop = React.useCallback(
|
|
19518
19524
|
(e4) => {
|
|
19519
|
-
var
|
|
19525
|
+
var _a2;
|
|
19520
19526
|
e4.preventDefault();
|
|
19521
19527
|
setDragOver(false);
|
|
19522
|
-
if (isDisabled || !((
|
|
19528
|
+
if (isDisabled || !((_a2 = e4.dataTransfer.files) == null ? void 0 : _a2.length)) return;
|
|
19523
19529
|
const files = normaliseFromFiles(e4.dataTransfer.files);
|
|
19524
19530
|
handleAddItems(files, "drop");
|
|
19525
19531
|
},
|
|
19526
19532
|
[handleAddItems, isDisabled]
|
|
19527
19533
|
);
|
|
19528
19534
|
const onNativeChange = (e4) => {
|
|
19529
|
-
var
|
|
19530
|
-
if ((
|
|
19535
|
+
var _a2;
|
|
19536
|
+
if ((_a2 = e4.target.files) == null ? void 0 : _a2.length) {
|
|
19531
19537
|
handleAddItems(normaliseFromFiles(e4.target.files), "input");
|
|
19532
19538
|
}
|
|
19533
19539
|
e4.target.value = "";
|
|
@@ -19541,8 +19547,8 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19541
19547
|
const [preview2, setPreview] = React.useState(null);
|
|
19542
19548
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
19543
19549
|
React.useEffect(() => {
|
|
19544
|
-
var
|
|
19545
|
-
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);
|
|
19546
19552
|
if (!isImage2) {
|
|
19547
19553
|
setPreview(null);
|
|
19548
19554
|
return;
|
|
@@ -19928,7 +19934,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19928
19934
|
),
|
|
19929
19935
|
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
19930
19936
|
items.map((item) => {
|
|
19931
|
-
var
|
|
19937
|
+
var _a2;
|
|
19932
19938
|
const selected = selectedIds.has(item.id);
|
|
19933
19939
|
const toggle = () => {
|
|
19934
19940
|
const next = new Set(selectedIds);
|
|
@@ -19955,7 +19961,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
19955
19961
|
),
|
|
19956
19962
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
19957
19963
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
19958
|
-
/* @__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 }),
|
|
19959
19965
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
19960
19966
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(
|
|
19961
19967
|
item.size
|
|
@@ -20073,7 +20079,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
20073
20079
|
] })
|
|
20074
20080
|
] }),
|
|
20075
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) => {
|
|
20076
|
-
var
|
|
20082
|
+
var _a2;
|
|
20077
20083
|
const selected = selectedIds.has(item.id);
|
|
20078
20084
|
const toggle = () => {
|
|
20079
20085
|
const next = new Set(selectedIds);
|
|
@@ -20108,7 +20114,7 @@ var ShadcnFileVariant = React.forwardRef(function ShadcnFileVariant2(props, ref)
|
|
|
20108
20114
|
),
|
|
20109
20115
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
20110
20116
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
20111
|
-
/* @__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 }) }),
|
|
20112
20118
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
20113
20119
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(item.size) }),
|
|
20114
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" }) }),
|