@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/index.mjs
CHANGED
|
@@ -19663,6 +19663,7 @@ var FileThumbnail = ({ item }) => {
|
|
|
19663
19663
|
) : /* @__PURE__ */ jsx(File2, { className: "h-4 w-4 text-muted-foreground/50" }) });
|
|
19664
19664
|
};
|
|
19665
19665
|
var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, ref) {
|
|
19666
|
+
var _a;
|
|
19666
19667
|
const {
|
|
19667
19668
|
value,
|
|
19668
19669
|
onValue,
|
|
@@ -19689,6 +19690,7 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
19689
19690
|
formatFileSize = formatSizeDefault,
|
|
19690
19691
|
placeholder = "Select file...",
|
|
19691
19692
|
className,
|
|
19693
|
+
custom,
|
|
19692
19694
|
dropAreaClassName,
|
|
19693
19695
|
listClassName,
|
|
19694
19696
|
triggerClassName,
|
|
@@ -19714,7 +19716,7 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
19714
19716
|
} = props;
|
|
19715
19717
|
const joinControls = mode === "default" ? joinControlsProp != null ? joinControlsProp : true : false;
|
|
19716
19718
|
const extendBoxToControls = mode === "default" ? extendBoxToControlsProp != null ? extendBoxToControlsProp : true : false;
|
|
19717
|
-
const items = value != null ?
|
|
19719
|
+
const items = (_a = toArray(value)) != null ? _a : [];
|
|
19718
19720
|
const isDisabled = Boolean(disabled || readOnly);
|
|
19719
19721
|
const [dragOver, setDragOver] = React68.useState(false);
|
|
19720
19722
|
const [selectedIds, setSelectedIds] = React68.useState(
|
|
@@ -19798,12 +19800,16 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
19798
19800
|
setSelectedIds(/* @__PURE__ */ new Set());
|
|
19799
19801
|
}, [emitChange, items, selectedIds]);
|
|
19800
19802
|
const openPicker = React68.useCallback(async () => {
|
|
19801
|
-
var
|
|
19803
|
+
var _a2;
|
|
19802
19804
|
if (isDisabled) return;
|
|
19803
|
-
let resolvedLoader = customLoader != null ? customLoader : getPaletteUtil("customLoader");
|
|
19805
|
+
let resolvedLoader = customLoader != null ? customLoader : custom && getPaletteUtil("customLoader");
|
|
19804
19806
|
if (resolvedLoader) {
|
|
19805
19807
|
try {
|
|
19806
|
-
const result = await resolvedLoader({
|
|
19808
|
+
const result = await resolvedLoader({
|
|
19809
|
+
multiple,
|
|
19810
|
+
current: items,
|
|
19811
|
+
allowedTypes: toArray(accept)
|
|
19812
|
+
});
|
|
19807
19813
|
if (!result) return;
|
|
19808
19814
|
const normalized = toArray(result).map(normaliseFileLike);
|
|
19809
19815
|
if (mergeMode === "replace" || !multiple) {
|
|
@@ -19819,7 +19825,7 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
19819
19825
|
}
|
|
19820
19826
|
return;
|
|
19821
19827
|
}
|
|
19822
|
-
(
|
|
19828
|
+
(_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
|
|
19823
19829
|
}, [
|
|
19824
19830
|
customLoader,
|
|
19825
19831
|
emitChange,
|
|
@@ -19838,18 +19844,18 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
19838
19844
|
);
|
|
19839
19845
|
const onDrop = React68.useCallback(
|
|
19840
19846
|
(e4) => {
|
|
19841
|
-
var
|
|
19847
|
+
var _a2;
|
|
19842
19848
|
e4.preventDefault();
|
|
19843
19849
|
setDragOver(false);
|
|
19844
|
-
if (isDisabled || !((
|
|
19850
|
+
if (isDisabled || !((_a2 = e4.dataTransfer.files) == null ? void 0 : _a2.length)) return;
|
|
19845
19851
|
const files = normaliseFromFiles(e4.dataTransfer.files);
|
|
19846
19852
|
handleAddItems(files, "drop");
|
|
19847
19853
|
},
|
|
19848
19854
|
[handleAddItems, isDisabled]
|
|
19849
19855
|
);
|
|
19850
19856
|
const onNativeChange = (e4) => {
|
|
19851
|
-
var
|
|
19852
|
-
if ((
|
|
19857
|
+
var _a2;
|
|
19858
|
+
if ((_a2 = e4.target.files) == null ? void 0 : _a2.length) {
|
|
19853
19859
|
handleAddItems(normaliseFromFiles(e4.target.files), "input");
|
|
19854
19860
|
}
|
|
19855
19861
|
e4.target.value = "";
|
|
@@ -19863,8 +19869,8 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
19863
19869
|
const [preview2, setPreview] = React68.useState(null);
|
|
19864
19870
|
const [isOpen, setIsOpen] = React68.useState(false);
|
|
19865
19871
|
React68.useEffect(() => {
|
|
19866
|
-
var
|
|
19867
|
-
const isImage2 = ((
|
|
19872
|
+
var _a2;
|
|
19873
|
+
const isImage2 = ((_a2 = item.type) == null ? void 0 : _a2.startsWith("image/")) || item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i);
|
|
19868
19874
|
if (!isImage2) {
|
|
19869
19875
|
setPreview(null);
|
|
19870
19876
|
return;
|
|
@@ -20250,7 +20256,7 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
20250
20256
|
),
|
|
20251
20257
|
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
20252
20258
|
items.map((item) => {
|
|
20253
|
-
var
|
|
20259
|
+
var _a2;
|
|
20254
20260
|
const selected = selectedIds.has(item.id);
|
|
20255
20261
|
const toggle = () => {
|
|
20256
20262
|
const next = new Set(selectedIds);
|
|
@@ -20277,7 +20283,7 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
20277
20283
|
),
|
|
20278
20284
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
20279
20285
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
20280
|
-
/* @__PURE__ */ jsx("div", { className: "truncate font-medium", children: (
|
|
20286
|
+
/* @__PURE__ */ jsx("div", { className: "truncate font-medium", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }),
|
|
20281
20287
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
20282
20288
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(
|
|
20283
20289
|
item.size
|
|
@@ -20395,7 +20401,7 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
20395
20401
|
] })
|
|
20396
20402
|
] }),
|
|
20397
20403
|
/* @__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) => {
|
|
20398
|
-
var
|
|
20404
|
+
var _a2;
|
|
20399
20405
|
const selected = selectedIds.has(item.id);
|
|
20400
20406
|
const toggle = () => {
|
|
20401
20407
|
const next = new Set(selectedIds);
|
|
@@ -20430,7 +20436,7 @@ var ShadcnFileVariant = React68.forwardRef(function ShadcnFileVariant2(props, re
|
|
|
20430
20436
|
),
|
|
20431
20437
|
/* @__PURE__ */ jsx(FileThumbnail, { item }),
|
|
20432
20438
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
20433
|
-
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-2", children: /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium text-foreground", children: (
|
|
20439
|
+
/* @__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 }) }),
|
|
20434
20440
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
|
|
20435
20441
|
/* @__PURE__ */ jsx("span", { children: formatFileSize(item.size) }),
|
|
20436
20442
|
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" }) }),
|