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