@particle-academy/react-fancy 5.8.0 → 5.10.0

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.cjs CHANGED
@@ -15273,6 +15273,7 @@ function PromptInput({
15273
15273
  const [attachments, setAttachments] = react.useState([]);
15274
15274
  const [picker, setPicker] = react.useState(null);
15275
15275
  const taRef = react.useRef(null);
15276
+ const fileRef = react.useRef(null);
15276
15277
  const [dragOver, setDragOver] = react.useState(false);
15277
15278
  const colors = mentionColor ?? DEFAULT_MENTION_COLOR;
15278
15279
  const tokens = react.useMemo(
@@ -15379,19 +15380,25 @@ function PromptInput({
15379
15380
  submit();
15380
15381
  }
15381
15382
  };
15382
- const onDrop = (e) => {
15383
- e.preventDefault();
15384
- setDragOver(false);
15385
- const files = Array.from(e.dataTransfer.files);
15383
+ const attach = (list) => {
15384
+ const files = Array.from(list ?? []);
15385
+ if (files.length === 0) return;
15386
15386
  setAttachments((cur) => [
15387
15387
  ...cur,
15388
15388
  ...files.map((f) => ({
15389
- id: `${f.name}-${Date.now()}-${Math.random()}`,
15389
+ id: crypto.randomUUID(),
15390
15390
  name: f.name,
15391
- bytes: f.size
15391
+ bytes: f.size,
15392
+ file: f,
15393
+ type: f.type
15392
15394
  }))
15393
15395
  ]);
15394
15396
  };
15397
+ const onDrop = (e) => {
15398
+ e.preventDefault();
15399
+ setDragOver(false);
15400
+ attach(e.dataTransfer.files);
15401
+ };
15395
15402
  return /* @__PURE__ */ jsxRuntime.jsxs(
15396
15403
  "div",
15397
15404
  {
@@ -15500,11 +15507,23 @@ function PromptInput({
15500
15507
  variant: "ghost",
15501
15508
  size: "sm",
15502
15509
  className: "shrink-0",
15503
- onClick: () => {
15504
- },
15510
+ onClick: () => fileRef.current?.click(),
15505
15511
  children: "\u{1F4CE} attach"
15506
15512
  }
15507
15513
  ) }),
15514
+ /* @__PURE__ */ jsxRuntime.jsx(
15515
+ "input",
15516
+ {
15517
+ ref: fileRef,
15518
+ type: "file",
15519
+ multiple: true,
15520
+ className: "hidden",
15521
+ onChange: (e) => {
15522
+ attach(e.target.files);
15523
+ e.target.value = "";
15524
+ }
15525
+ }
15526
+ ),
15508
15527
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden", children: [
15509
15528
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-1.5 w-24 shrink overflow-hidden rounded-full bg-zinc-200 dark:bg-zinc-700", children: /* @__PURE__ */ jsxRuntime.jsx(
15510
15529
  "div",