@photoroom/ui 0.1.580 → 0.1.581
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.
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
+
import type { FolderGroup } from "../../unsorted/FileUploader";
|
|
2
3
|
export type DropZoneProps = Readonly<({
|
|
3
4
|
density?: "compact";
|
|
4
5
|
ctaLabel?: never;
|
|
6
|
+
allowFolders?: never;
|
|
7
|
+
folderCtaLabel?: never;
|
|
5
8
|
} | {
|
|
6
9
|
density: "regular";
|
|
7
10
|
ctaLabel: string;
|
|
11
|
+
allowFolders?: false;
|
|
12
|
+
folderCtaLabel?: never;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Folder mode: a second CTA opens the OS folder picker and dropped directories
|
|
16
|
+
* are traversed. Regular density only — compact has no CTA to sit beside — and
|
|
17
|
+
* it owns its content, so `children` is unavailable.
|
|
18
|
+
*/
|
|
19
|
+
| {
|
|
20
|
+
density: "regular";
|
|
21
|
+
ctaLabel: string;
|
|
22
|
+
allowFolders: true;
|
|
23
|
+
folderCtaLabel: string;
|
|
24
|
+
children?: never;
|
|
8
25
|
}) & {
|
|
9
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Receives the picked or dropped files. `isFolder` marks a directory import
|
|
28
|
+
* and `folders` carries its top-level subfolder groups — both undefined
|
|
29
|
+
* unless `allowFolders` is set.
|
|
30
|
+
*/
|
|
31
|
+
onFileChange: (files: FileList, isShiftPressed?: boolean, isFolder?: boolean, folders?: FolderGroup[]) => void;
|
|
10
32
|
onClick?: () => void;
|
|
11
33
|
/** Side-effect hook fired right before the picker opens; does not replace it. Ignored when `onClick` is set. */
|
|
12
34
|
onOpenFilePicker?: () => void;
|
|
@@ -18,5 +40,5 @@ export type DropZoneProps = Readonly<({
|
|
|
18
40
|
testId?: string;
|
|
19
41
|
autoFocus?: boolean;
|
|
20
42
|
}>;
|
|
21
|
-
export declare const DropZone: ({ onFileChange, onClick, onOpenFilePicker, multiple, children, title, dropTitle, density, ctaLabel, className, testId, autoFocus, }: DropZoneProps) => import("react").JSX.Element;
|
|
43
|
+
export declare const DropZone: ({ onFileChange, onClick, onOpenFilePicker, multiple, children, title, dropTitle, density, ctaLabel, allowFolders, folderCtaLabel, className, testId, autoFocus, }: DropZoneProps) => import("react").JSX.Element;
|
|
22
44
|
//# sourceMappingURL=DropZone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropZone.d.ts","sourceRoot":"","sources":["../../../../src/components/input/DropZone/DropZone.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DropZone.d.ts","sourceRoot":"","sources":["../../../../src/components/input/DropZone/DropZone.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAe,MAAM,OAAO,CAAC;AAI/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,MAAM,aAAa,GAAG,QAAQ,CAClC,CACI;IAAE,OAAO,CAAC,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC;IAAC,YAAY,CAAC,EAAE,KAAK,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,GACvF;IAAE,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,KAAK,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE;AACxF;;;;GAIG;GACD;IACE,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,IAAI,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CACJ,GAAG;IACF;;;;OAIG;IACH,YAAY,EAAE,CACZ,KAAK,EAAE,QAAQ,EACf,cAAc,CAAC,EAAE,OAAO,EACxB,QAAQ,CAAC,EAAE,OAAO,EAClB,OAAO,CAAC,EAAE,WAAW,EAAE,KACpB,IAAI,CAAC;IACV,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,gHAAgH;IAChH,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CACF,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,mKAetB,aAAa,gCA8If,CAAC"}
|
package/index.mjs
CHANGED
|
@@ -48228,69 +48228,108 @@ var l3 = (e) => e.isFile === !0, u3 = (e) => e.isDirectory === !0, Mge = new Int
|
|
|
48228
48228
|
waitForFiles: p,
|
|
48229
48229
|
waitForFile: m
|
|
48230
48230
|
};
|
|
48231
|
-
}, Fge = ({ onFileChange: e, onClick: t, onOpenFilePicker: n, multiple: r, children: i, title: a, dropTitle: o, density: s = "compact", ctaLabel: c,
|
|
48232
|
-
let { isDragging:
|
|
48231
|
+
}, Fge = ({ onFileChange: e, onClick: t, onOpenFilePicker: n, multiple: r, children: i, title: a, dropTitle: o, density: s = "compact", ctaLabel: c, allowFolders: l, folderCtaLabel: u, className: d, testId: f, autoFocus: p }) => {
|
|
48232
|
+
let { isDragging: m, inputRef: h, folderInputRef: g, openFilePicker: _, openFolderPicker: v, handleChange: y, handleFolderChange: b, handleDragEnter: x, handleDragLeave: S, handleDragOver: C, handleDrop: w } = m3({
|
|
48233
|
+
onFileChange: e,
|
|
48234
|
+
allowFolders: l
|
|
48235
|
+
}), T = B(() => {
|
|
48233
48236
|
if (typeof t == "function") {
|
|
48234
48237
|
t();
|
|
48235
48238
|
return;
|
|
48236
48239
|
}
|
|
48237
|
-
n?.(),
|
|
48240
|
+
n?.(), _();
|
|
48238
48241
|
}, [
|
|
48239
48242
|
t,
|
|
48240
48243
|
n,
|
|
48241
|
-
|
|
48242
|
-
])
|
|
48244
|
+
_
|
|
48245
|
+
]), E = B(() => {
|
|
48246
|
+
n?.(), v();
|
|
48247
|
+
}, [n, v]);
|
|
48243
48248
|
return /* @__PURE__ */ L("div", {
|
|
48244
|
-
className: U("interaction-transition", "relative",
|
|
48245
|
-
"data-testid":
|
|
48246
|
-
children: [
|
|
48247
|
-
|
|
48248
|
-
|
|
48249
|
-
|
|
48250
|
-
|
|
48251
|
-
|
|
48252
|
-
|
|
48253
|
-
|
|
48254
|
-
|
|
48255
|
-
|
|
48256
|
-
|
|
48257
|
-
|
|
48258
|
-
|
|
48259
|
-
|
|
48260
|
-
|
|
48261
|
-
|
|
48262
|
-
autoFocus: d,
|
|
48263
|
-
className: H("interaction-transition", "group/dropzone", "rounded-500", "border-neutral-alpha-400 border border-dashed", "w-full appearance-none select-none", "hover:bg-background-borderless-subdued-hover focus-visible:bg-background-borderless-subdued-hover active:bg-background-borderless-subdued-down", "focus-visible:ring-misc-focus-indicator focus-visible:misc-border-size-focus-ring outline-hidden", "disabled:pointer-events-none disabled:opacity-30"),
|
|
48264
|
-
children: i || (s === "compact" ? /* @__PURE__ */ L("div", {
|
|
48265
|
-
className: "flex items-center justify-center gap-2 p-6",
|
|
48266
|
-
children: [/* @__PURE__ */ I(me, { className: "text-content-tertiary size-5 shrink-0" }), /* @__PURE__ */ I("span", {
|
|
48267
|
-
className: "component-500 text-content-secondary text-start",
|
|
48268
|
-
children: a
|
|
48269
|
-
})]
|
|
48270
|
-
}) : /* @__PURE__ */ I("div", {
|
|
48271
|
-
className: "flex items-center justify-center px-4 py-10",
|
|
48249
|
+
className: U("interaction-transition", "relative", d),
|
|
48250
|
+
"data-testid": f,
|
|
48251
|
+
children: [
|
|
48252
|
+
/* @__PURE__ */ I(a3, {
|
|
48253
|
+
showOverlay: m,
|
|
48254
|
+
onDragEnter: x,
|
|
48255
|
+
onDragLeave: S,
|
|
48256
|
+
onDragOver: C,
|
|
48257
|
+
onDrop: w,
|
|
48258
|
+
overlay: /* @__PURE__ */ I("div", {
|
|
48259
|
+
className: "absolute inset-0 flex bg-white",
|
|
48260
|
+
children: /* @__PURE__ */ I("div", {
|
|
48261
|
+
className: H("interaction-transition", "rounded-500 border-content-accent border", "flex flex-1 flex-col items-center justify-center p-6", "component-500 bg-background-accent-subdued text-content-accent"),
|
|
48262
|
+
children: o
|
|
48263
|
+
})
|
|
48264
|
+
}),
|
|
48265
|
+
children: l ? /* @__PURE__ */ I("div", {
|
|
48266
|
+
className: H("interaction-transition", "rounded-500", "border-neutral-alpha-400 border border-dashed", "w-full select-none"),
|
|
48272
48267
|
children: /* @__PURE__ */ L("div", {
|
|
48273
|
-
className: "flex flex-col items-center justify-center gap-2",
|
|
48274
|
-
children: [/* @__PURE__ */
|
|
48275
|
-
|
|
48276
|
-
|
|
48277
|
-
|
|
48278
|
-
|
|
48279
|
-
|
|
48280
|
-
|
|
48281
|
-
|
|
48268
|
+
className: "flex flex-col items-center justify-center gap-2 px-4 py-10",
|
|
48269
|
+
children: [/* @__PURE__ */ L("div", {
|
|
48270
|
+
className: "flex flex-wrap items-center justify-center gap-2",
|
|
48271
|
+
children: [/* @__PURE__ */ I(yd, {
|
|
48272
|
+
variant: "secondary",
|
|
48273
|
+
density: "regular",
|
|
48274
|
+
icon: me,
|
|
48275
|
+
onClick: T,
|
|
48276
|
+
autoFocus: p,
|
|
48277
|
+
children: c
|
|
48278
|
+
}), /* @__PURE__ */ I(yd, {
|
|
48279
|
+
variant: "secondary",
|
|
48280
|
+
density: "regular",
|
|
48281
|
+
icon: A,
|
|
48282
|
+
onClick: E,
|
|
48283
|
+
children: u
|
|
48284
|
+
})]
|
|
48282
48285
|
}), /* @__PURE__ */ I("span", {
|
|
48283
48286
|
className: "component-500 text-content-secondary text-center",
|
|
48284
48287
|
children: a
|
|
48285
48288
|
})]
|
|
48286
48289
|
})
|
|
48287
|
-
})
|
|
48290
|
+
}) : /* @__PURE__ */ I("button", {
|
|
48291
|
+
type: "button",
|
|
48292
|
+
onClick: T,
|
|
48293
|
+
autoFocus: p,
|
|
48294
|
+
className: H("interaction-transition", "group/dropzone", "rounded-500", "border-neutral-alpha-400 border border-dashed", "w-full appearance-none select-none", "hover:bg-background-borderless-subdued-hover focus-visible:bg-background-borderless-subdued-hover active:bg-background-borderless-subdued-down", "focus-visible:ring-misc-focus-indicator focus-visible:misc-border-size-focus-ring outline-hidden", "disabled:pointer-events-none disabled:opacity-30"),
|
|
48295
|
+
children: i || (s === "compact" ? /* @__PURE__ */ L("div", {
|
|
48296
|
+
className: "flex items-center justify-center gap-2 p-6",
|
|
48297
|
+
children: [/* @__PURE__ */ I(me, { className: "text-content-tertiary size-5 shrink-0" }), /* @__PURE__ */ I("span", {
|
|
48298
|
+
className: "component-500 text-content-secondary text-start",
|
|
48299
|
+
children: a
|
|
48300
|
+
})]
|
|
48301
|
+
}) : /* @__PURE__ */ I("div", {
|
|
48302
|
+
className: "flex items-center justify-center px-4 py-10",
|
|
48303
|
+
children: /* @__PURE__ */ L("div", {
|
|
48304
|
+
className: "flex flex-col items-center justify-center gap-2",
|
|
48305
|
+
children: [/* @__PURE__ */ I(yd, {
|
|
48306
|
+
as: "span",
|
|
48307
|
+
variant: "secondary",
|
|
48308
|
+
density: "regular",
|
|
48309
|
+
icon: me,
|
|
48310
|
+
tabIndex: -1,
|
|
48311
|
+
className: H("group-active/dropzone:bg-background-subdued-down", "pointer-events-none"),
|
|
48312
|
+
children: c
|
|
48313
|
+
}), /* @__PURE__ */ I("span", {
|
|
48314
|
+
className: "component-500 text-content-secondary text-center",
|
|
48315
|
+
children: a
|
|
48316
|
+
})]
|
|
48317
|
+
})
|
|
48318
|
+
}))
|
|
48319
|
+
})
|
|
48320
|
+
}),
|
|
48321
|
+
/* @__PURE__ */ I(c3, {
|
|
48322
|
+
multiple: r,
|
|
48323
|
+
onChange: y,
|
|
48324
|
+
ref: h
|
|
48325
|
+
}),
|
|
48326
|
+
l === !0 && /* @__PURE__ */ I(c3, {
|
|
48327
|
+
multiple: !0,
|
|
48328
|
+
onChange: b,
|
|
48329
|
+
ref: g,
|
|
48330
|
+
directory: !0
|
|
48288
48331
|
})
|
|
48289
|
-
|
|
48290
|
-
multiple: r,
|
|
48291
|
-
onChange: h,
|
|
48292
|
-
ref: p
|
|
48293
|
-
})]
|
|
48332
|
+
]
|
|
48294
48333
|
});
|
|
48295
48334
|
}, h3 = ({ label: e, icon: t, additionalContent: n, className: r, disabled: i, ref: a, ...o }) => /* @__PURE__ */ L("button", {
|
|
48296
48335
|
ref: a,
|