@smwb/ui-react 2.5.0 → 2.6.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/assets/styles/less/components/confirmDialog/confirmDialog.entry.css +1 -0
- package/dist/assets/styles/less/components/fileDrop/fileDrop.entry.css +1 -0
- package/dist/assets/styles/less/components/fileInput/fileInput.entry.css +1 -0
- package/dist/assets/styles/less/components/floatingWindow/floatingWindow.entry.css +1 -0
- package/dist/components/dataDisplay/chat/chat.d.ts +1 -1
- package/dist/components/dataDisplay/chat/chat.js.map +1 -1
- package/dist/components/dataDisplay/chat/useChatFileUpload.d.ts +16 -4
- package/dist/components/dataDisplay/chat/useChatFileUpload.js +38 -29
- package/dist/components/dataDisplay/chat/useChatFileUpload.js.map +1 -1
- package/dist/components/feedBack/confirmDialog/confirmDialog.d.ts +27 -0
- package/dist/components/feedBack/confirmDialog/confirmDialog.js +49 -0
- package/dist/components/feedBack/confirmDialog/confirmDialog.js.map +1 -0
- package/dist/components/feedBack/confirmDialog/index.d.ts +2 -0
- package/dist/components/inputs/fileDrop/countPreview.js +15 -0
- package/dist/components/inputs/fileDrop/countPreview.js.map +1 -0
- package/dist/components/inputs/fileDrop/fileDrop.d.ts +1 -1
- package/dist/components/inputs/fileDrop/fileDrop.js +60 -0
- package/dist/components/inputs/fileDrop/fileDrop.js.map +1 -0
- package/dist/components/inputs/fileDrop/index.d.ts +9 -0
- package/dist/components/inputs/fileDrop/preview.js +41 -0
- package/dist/components/inputs/fileDrop/preview.js.map +1 -0
- package/dist/components/inputs/fileDrop/previewWrapper.js +27 -0
- package/dist/components/inputs/fileDrop/previewWrapper.js.map +1 -0
- package/dist/components/inputs/fileDrop/utils.js +7 -0
- package/dist/components/inputs/fileDrop/utils.js.map +1 -0
- package/dist/components/inputs/fileInput/fileInput.d.ts +1 -1
- package/dist/components/inputs/fileInput/fileInput.js +35 -0
- package/dist/components/inputs/fileInput/fileInput.js.map +1 -0
- package/dist/components/inputs/fileInput/index.d.ts +2 -0
- package/dist/components/layout/floatingWindow/floatingWindow.d.ts +92 -0
- package/dist/components/layout/floatingWindow/floatingWindow.js +311 -0
- package/dist/components/layout/floatingWindow/floatingWindow.js.map +1 -0
- package/dist/components/layout/floatingWindow/index.d.ts +2 -0
- package/dist/headless/components/dataDisplay/chat/chat.js.map +1 -1
- package/dist/headless/components/dataDisplay/chat/useChatFileUpload.js +38 -29
- package/dist/headless/components/dataDisplay/chat/useChatFileUpload.js.map +1 -1
- package/dist/headless/components/feedBack/confirmDialog/confirmDialog.js +48 -0
- package/dist/headless/components/feedBack/confirmDialog/confirmDialog.js.map +1 -0
- package/dist/headless/components/inputs/fileDrop/countPreview.js +15 -0
- package/dist/headless/components/inputs/fileDrop/countPreview.js.map +1 -0
- package/dist/headless/components/inputs/fileDrop/fileDrop.js +59 -0
- package/dist/headless/components/inputs/fileDrop/fileDrop.js.map +1 -0
- package/dist/headless/components/inputs/fileDrop/preview.js +41 -0
- package/dist/headless/components/inputs/fileDrop/preview.js.map +1 -0
- package/dist/headless/components/inputs/fileDrop/previewWrapper.js +27 -0
- package/dist/headless/components/inputs/fileDrop/previewWrapper.js.map +1 -0
- package/dist/headless/components/inputs/fileDrop/utils.js +7 -0
- package/dist/headless/components/inputs/fileDrop/utils.js.map +1 -0
- package/dist/headless/components/inputs/fileInput/fileInput.js +34 -0
- package/dist/headless/components/inputs/fileInput/fileInput.js.map +1 -0
- package/dist/headless/components/layout/floatingWindow/floatingWindow.js +310 -0
- package/dist/headless/components/layout/floatingWindow/floatingWindow.js.map +1 -0
- package/dist/headless/hooks/useDropzone.js +47 -0
- package/dist/headless/hooks/useDropzone.js.map +1 -0
- package/dist/headless/index.js +277 -259
- package/dist/headless/index.js.map +1 -1
- package/dist/hooks/useDropzone.d.ts +44 -0
- package/dist/hooks/useDropzone.js +47 -0
- package/dist/hooks/useDropzone.js.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +277 -259
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import n from "react";
|
|
2
|
+
function k(t) {
|
|
3
|
+
if (t)
|
|
4
|
+
return typeof t == "string" ? t : Object.entries(t).flatMap(([s, c]) => [s, ...c]).join(",");
|
|
5
|
+
}
|
|
6
|
+
function C(t = {}) {
|
|
7
|
+
const s = n.useRef(null), [c, f] = n.useState(!1), r = n.useRef(t);
|
|
8
|
+
r.current = t;
|
|
9
|
+
const o = n.useCallback(() => {
|
|
10
|
+
var e;
|
|
11
|
+
r.current.disabled || (e = s.current) == null || e.click();
|
|
12
|
+
}, []), i = n.useCallback((e, a) => {
|
|
13
|
+
if (!e) return;
|
|
14
|
+
const { maxFiles: l, onDrop: p, onDropAccepted: d } = r.current;
|
|
15
|
+
let u = Array.from(e);
|
|
16
|
+
l && l > 0 && (u = u.slice(0, l)), p == null || p(u, a), d == null || d(u, a);
|
|
17
|
+
}, []), b = n.useCallback(
|
|
18
|
+
() => ({
|
|
19
|
+
onClick: () => o(),
|
|
20
|
+
onDragOver: (e) => {
|
|
21
|
+
e.preventDefault(), r.current.disabled || f(!0);
|
|
22
|
+
},
|
|
23
|
+
onDragLeave: () => f(!1),
|
|
24
|
+
onDrop: (e) => {
|
|
25
|
+
var a, l;
|
|
26
|
+
e.preventDefault(), f(!1), r.current.disabled || i((l = (a = e.dataTransfer) == null ? void 0 : a.files) != null ? l : null, e);
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
[i, o]
|
|
30
|
+
), g = n.useCallback(
|
|
31
|
+
() => ({
|
|
32
|
+
type: "file",
|
|
33
|
+
multiple: r.current.multiple,
|
|
34
|
+
accept: k(r.current.accept),
|
|
35
|
+
disabled: r.current.disabled,
|
|
36
|
+
style: { display: "none" },
|
|
37
|
+
ref: s,
|
|
38
|
+
onChange: (e) => i(e.currentTarget.files, e)
|
|
39
|
+
}),
|
|
40
|
+
[i]
|
|
41
|
+
);
|
|
42
|
+
return { getRootProps: b, getInputProps: g, inputRef: s, isDragActive: c, open: o };
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
C as useDropzone
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=useDropzone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDropzone.js","sources":["../../src/hooks/useDropzone.ts"],"sourcesContent":["import React from \"react\";\n\n/** Record of mime → extensions (react-dropzone's `Accept` shape), or a raw accept string. */\nexport type DropzoneAccept = Record<string, string[]> | string;\n\nexport interface DropzoneOptions {\n /** Record of mime → extensions, or a raw accept string. */\n accept?: DropzoneAccept | undefined;\n multiple?: boolean | undefined;\n maxFiles?: number | undefined;\n disabled?: boolean | undefined;\n onDrop?: ((files: File[], event: React.SyntheticEvent | Event) => void) | undefined;\n onDropAccepted?: ((files: File[], event: React.SyntheticEvent | Event) => void) | undefined;\n}\n\nexport interface DropzoneRootProps {\n onClick: () => void;\n onDragOver: (event: React.DragEvent<HTMLElement>) => void;\n onDragLeave: () => void;\n onDrop: (event: React.DragEvent<HTMLElement>) => void;\n}\n\nexport interface DropzoneInputProps {\n type: \"file\";\n multiple: boolean | undefined;\n accept: string | undefined;\n disabled: boolean | undefined;\n style: React.CSSProperties;\n ref: React.RefObject<HTMLInputElement>;\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;\n}\n\nexport interface DropzoneState {\n getRootProps: () => DropzoneRootProps;\n getInputProps: () => DropzoneInputProps;\n inputRef: React.RefObject<HTMLInputElement>;\n isDragActive: boolean;\n open: () => void;\n}\n\nfunction acceptToString(accept: DropzoneOptions[\"accept\"]): string | undefined {\n if (!accept) return undefined;\n if (typeof accept === \"string\") return accept;\n return Object.entries(accept)\n .flatMap(([mime, exts]) => [mime, ...exts])\n .join(\",\");\n}\n\n/**\n * Dependency-free file dropzone — the React twin of ui-solid's `createDropzone`.\n * Provides root/input prop getters, drag-active state and a programmatic `open()`.\n *\n * Replaces the `react-dropzone` import this package used to carry: that package was\n * only ever a devDependency while the build externalises every bare import, so the\n * published bundle asked consumers for a module they were never told to install.\n */\nexport function useDropzone(options: DropzoneOptions = {}): DropzoneState {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const [isDragActive, setIsDragActive] = React.useState(false);\n\n // Latest options without re-creating the prop getters on every render.\n const optionsRef = React.useRef(options);\n optionsRef.current = options;\n\n const open = React.useCallback((): void => {\n if (!optionsRef.current.disabled) inputRef.current?.click();\n }, []);\n\n const handleFiles = React.useCallback((list: FileList | null, event: React.SyntheticEvent | Event): void => {\n if (!list) return;\n const { maxFiles, onDrop, onDropAccepted } = optionsRef.current;\n let files = Array.from(list);\n if (maxFiles && maxFiles > 0) files = files.slice(0, maxFiles);\n onDrop?.(files, event);\n onDropAccepted?.(files, event);\n }, []);\n\n const getRootProps = React.useCallback(\n (): DropzoneRootProps => ({\n onClick: () => open(),\n onDragOver: (event) => {\n event.preventDefault();\n if (!optionsRef.current.disabled) setIsDragActive(true);\n },\n onDragLeave: () => setIsDragActive(false),\n onDrop: (event) => {\n event.preventDefault();\n setIsDragActive(false);\n if (!optionsRef.current.disabled) handleFiles(event.dataTransfer?.files ?? null, event);\n },\n }),\n [handleFiles, open]\n );\n\n const getInputProps = React.useCallback(\n (): DropzoneInputProps => ({\n type: \"file\",\n multiple: optionsRef.current.multiple,\n accept: acceptToString(optionsRef.current.accept),\n disabled: optionsRef.current.disabled,\n style: { display: \"none\" },\n ref: inputRef,\n onChange: (event) => handleFiles(event.currentTarget.files, event),\n }),\n [handleFiles]\n );\n\n return { getRootProps, getInputProps, inputRef, isDragActive, open };\n}\n\nexport default useDropzone;\n"],"names":["acceptToString","accept","mime","exts","useDropzone","options","inputRef","React","isDragActive","setIsDragActive","optionsRef","open","_a","handleFiles","list","event","maxFiles","onDrop","onDropAccepted","files","getRootProps","_b","getInputProps"],"mappings":";AAwCA,SAASA,EAAeC,GAAuD;AAC7E,MAAKA;AACL,WAAI,OA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