@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 CHANGED
@@ -19378,6 +19378,7 @@ var FileThumbnail = ({ item }) => {
19378
19378
  ) : /* @__PURE__ */ jsxRuntime.jsx(File2, { className: "h-4 w-4 text-muted-foreground/50" }) });
19379
19379
  };
19380
19380
  var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(props, ref) {
19381
+ var _a;
19381
19382
  const {
19382
19383
  value,
19383
19384
  onValue,
@@ -19430,7 +19431,7 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
19430
19431
  } = props;
19431
19432
  const joinControls = mode === "default" ? joinControlsProp != null ? joinControlsProp : true : false;
19432
19433
  const extendBoxToControls = mode === "default" ? extendBoxToControlsProp != null ? extendBoxToControlsProp : true : false;
19433
- const items = value != null ? value : [];
19434
+ const items = (_a = toArray2(value)) != null ? _a : [];
19434
19435
  const isDisabled = Boolean(disabled || readOnly);
19435
19436
  const [dragOver, setDragOver] = React__namespace.useState(false);
19436
19437
  const [selectedIds, setSelectedIds] = React__namespace.useState(
@@ -19514,12 +19515,16 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
19514
19515
  setSelectedIds(/* @__PURE__ */ new Set());
19515
19516
  }, [emitChange, items, selectedIds]);
19516
19517
  const openPicker = React__namespace.useCallback(async () => {
19517
- var _a;
19518
+ var _a2;
19518
19519
  if (isDisabled) return;
19519
19520
  let resolvedLoader = customLoader != null ? customLoader : custom && getPaletteUtil("customLoader");
19520
19521
  if (resolvedLoader) {
19521
19522
  try {
19522
- const result = await resolvedLoader({ multiple, current: items, allowedTypes: toArray2(accept) });
19523
+ const result = await resolvedLoader({
19524
+ multiple,
19525
+ current: items,
19526
+ allowedTypes: toArray2(accept)
19527
+ });
19523
19528
  if (!result) return;
19524
19529
  const normalized = toArray2(result).map(normaliseFileLike);
19525
19530
  if (mergeMode === "replace" || !multiple) {
@@ -19535,7 +19540,7 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
19535
19540
  }
19536
19541
  return;
19537
19542
  }
19538
- (_a = fileInputRef.current) == null ? void 0 : _a.click();
19543
+ (_a2 = fileInputRef.current) == null ? void 0 : _a2.click();
19539
19544
  }, [
19540
19545
  customLoader,
19541
19546
  emitChange,
@@ -19554,18 +19559,18 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
19554
19559
  );
19555
19560
  const onDrop = React__namespace.useCallback(
19556
19561
  (e4) => {
19557
- var _a;
19562
+ var _a2;
19558
19563
  e4.preventDefault();
19559
19564
  setDragOver(false);
19560
- if (isDisabled || !((_a = e4.dataTransfer.files) == null ? void 0 : _a.length)) return;
19565
+ if (isDisabled || !((_a2 = e4.dataTransfer.files) == null ? void 0 : _a2.length)) return;
19561
19566
  const files = normaliseFromFiles(e4.dataTransfer.files);
19562
19567
  handleAddItems(files, "drop");
19563
19568
  },
19564
19569
  [handleAddItems, isDisabled]
19565
19570
  );
19566
19571
  const onNativeChange = (e4) => {
19567
- var _a;
19568
- if ((_a = e4.target.files) == null ? void 0 : _a.length) {
19572
+ var _a2;
19573
+ if ((_a2 = e4.target.files) == null ? void 0 : _a2.length) {
19569
19574
  handleAddItems(normaliseFromFiles(e4.target.files), "input");
19570
19575
  }
19571
19576
  e4.target.value = "";
@@ -19579,8 +19584,8 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
19579
19584
  const [preview2, setPreview] = React__namespace.useState(null);
19580
19585
  const [isOpen, setIsOpen] = React__namespace.useState(false);
19581
19586
  React__namespace.useEffect(() => {
19582
- var _a;
19583
- const isImage2 = ((_a = item.type) == null ? void 0 : _a.startsWith("image/")) || item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i);
19587
+ var _a2;
19588
+ const isImage2 = ((_a2 = item.type) == null ? void 0 : _a2.startsWith("image/")) || item.name.match(/\.(jpg|jpeg|png|gif|webp)$/i);
19584
19589
  if (!isImage2) {
19585
19590
  setPreview(null);
19586
19591
  return;
@@ -19966,7 +19971,7 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
19966
19971
  ),
19967
19972
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
19968
19973
  items.map((item) => {
19969
- var _a;
19974
+ var _a2;
19970
19975
  const selected = selectedIds.has(item.id);
19971
19976
  const toggle = () => {
19972
19977
  const next = new Set(selectedIds);
@@ -19993,7 +19998,7 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
19993
19998
  ),
19994
19999
  /* @__PURE__ */ jsxRuntime.jsx(FileThumbnail, { item }),
19995
20000
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
19996
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate font-medium", children: (_a = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a : item.name }),
20001
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate font-medium", children: (_a2 = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a2 : item.name }),
19997
20002
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
19998
20003
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatFileSize(
19999
20004
  item.size
@@ -20111,7 +20116,7 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
20111
20116
  ] })
20112
20117
  ] }),
20113
20118
  /* @__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) => {
20114
- var _a;
20119
+ var _a2;
20115
20120
  const selected = selectedIds.has(item.id);
20116
20121
  const toggle = () => {
20117
20122
  const next = new Set(selectedIds);
@@ -20146,7 +20151,7 @@ var ShadcnFileVariant = React__namespace.forwardRef(function ShadcnFileVariant2(
20146
20151
  ),
20147
20152
  /* @__PURE__ */ jsxRuntime.jsx(FileThumbnail, { item }),
20148
20153
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
20149
- /* @__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: (_a = formatFileName == null ? void 0 : formatFileName(item)) != null ? _a : item.name }) }),
20154
+ /* @__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 }) }),
20150
20155
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [
20151
20156
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: formatFileSize(item.size) }),
20152
20157
  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" }) }),