@molecule/app-file-dropzone-react 4.0.3 → 5.0.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/README.md CHANGED
@@ -3,13 +3,13 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-26T01:31:04.458Z
6
+ Generated: 2026-11-26T08:58:20.561Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-file-dropzone-react
10
10
 
11
11
  File dropzone — drag-drop + click-to-browse file picker with
12
- accept / max-size filtering. Pure UI: it emits the chosen `File[]`
12
+ accept / max-size filtering. Pure UI: it emits portable `PickedFile` values
13
13
  and the host app performs the actual upload.
14
14
 
15
15
  Exports `<FileDropzone>` and its `FileDropzoneProps`.
@@ -57,8 +57,8 @@ Props for {@link FileDropzone}.
57
57
 
58
58
  ```typescript
59
59
  interface FileDropzoneProps {
60
- /** Called with the File[] the user selected or dropped. */
61
- onFiles: (files: File[]) => void
60
+ /** Called with the files the user selected or dropped, in selection order. */
61
+ onFiles: (files: readonly PickedFile[]) => void
62
62
  /** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
63
63
  accept?: string
64
64
  /** Allow multi-file selection. Defaults to false. */
@@ -66,7 +66,7 @@ interface FileDropzoneProps {
66
66
  /** Max file size in bytes. Files exceeding are rejected. */
67
67
  maxSize?: number
68
68
  /** Called with rejected files (wrong type or size). */
69
- onRejected?: (files: File[]) => void
69
+ onRejected?: (files: readonly PickedFile[]) => void
70
70
  /** Optional content rendered inside the dropzone (defaults to standard upload copy). */
71
71
  children?: ReactNode
72
72
  /** Disabled state. */
@@ -110,7 +110,7 @@ Peer dependencies:
110
110
  - `@molecule/app-filesystem` ^1.1.0
111
111
  - `@molecule/app-react` ^4.13.0
112
112
  - `@molecule/app-ui` ^1.0.1
113
- - `@molecule/app-ui-react` ^4.0.0
113
+ - `@molecule/app-ui-react` ^4.12.0
114
114
  - `react` ^18.0.0 || ^19.0.0
115
115
 
116
116
  ### Runtime Dependencies
@@ -128,6 +128,8 @@ The `accept` filter is a best-effort client-side check (file
128
128
  extension or MIME prefix match) — treat it as UX sugar and always
129
129
  re-validate on the server. Files failing `accept` or `maxSize` go to
130
130
  `onRejected` (both rejection causes arrive in the same callback).
131
+ Read selected bytes with `arrayBuffer()` or append a file to a multipart
132
+ body with `file.appendTo(formData, fieldName)`.
131
133
 
132
134
  Pass `children` to replace the default "Drop files here or click to
133
135
  browse" copy; the default copy translates via
@@ -1,8 +1,9 @@
1
1
  import type { JSX, ReactNode } from 'react';
2
+ import type { PickedFile } from '@molecule/app-filesystem';
2
3
  /** Props for {@link FileDropzone}. */
3
4
  export interface FileDropzoneProps {
4
- /** Called with the File[] the user selected or dropped. */
5
- onFiles: (files: File[]) => void;
5
+ /** Called with the files the user selected or dropped, in selection order. */
6
+ onFiles: (files: readonly PickedFile[]) => void;
6
7
  /** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
7
8
  accept?: string;
8
9
  /** Allow multi-file selection. Defaults to false. */
@@ -10,7 +11,7 @@ export interface FileDropzoneProps {
10
11
  /** Max file size in bytes. Files exceeding are rejected. */
11
12
  maxSize?: number;
12
13
  /** Called with rejected files (wrong type or size). */
13
- onRejected?: (files: File[]) => void;
14
+ onRejected?: (files: readonly PickedFile[]) => void;
14
15
  /** Optional content rendered inside the dropzone (defaults to standard upload copy). */
15
16
  children?: ReactNode;
16
17
  /** Disabled state. */
@@ -1 +1 @@
1
- {"version":3,"file":"FileDropzone.d.ts","sourceRoot":"","sources":["../src/FileDropzone.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQ3C,sCAAsC;AACtC,MAAM,WAAW,iBAAi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E,SAAS,UAAU,EAAE,KAAK,IAAI,CAAA;IACnD,wFAAwF;IACxF,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,MAAM,EACN,QAAgB,EAChB,OAAO,EACP,UAAU,EACV,QAAQ,EAAE,YAAY,EACtB,QAAQ,EACR,SAAS,GACV,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAwDjC"}
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useRef, useState } from 'react';
3
- import { createBrowserFileInput } from '@molecule/app-filesystem';
2
+ import { useState } from 'react';
4
3
  import { useTranslation } from '@molecule/app-react';
5
4
  import { slot } from '@molecule/app-react/render';
6
5
  import { getClassMap } from '@molecule/app-ui';
6
+ import { FileField, Text } from '@molecule/app-ui-react/elements';
7
7
  /**
8
8
  * Drag-drop + click-to-browse file upload zone. Pure UI — apps handle
9
9
  * the actual upload.
@@ -17,21 +17,13 @@ export function FileDropzone({ onFiles, accept, multiple = false, maxSize, onRej
17
17
  const cm = getClassMap();
18
18
  const { t } = useTranslation();
19
19
  const [dragging, setDragging] = useState(false);
20
- const inputRef = useRef(null);
21
- const handlers = createBrowserFileInput(() => inputRef.current, () => ({ accept, disabled, maxSize, multiple, onFiles, onRejected }), (file) => file);
22
- return (_jsxs("div", { onDragOver: (e) => {
23
- if (handlers.onDragOver(e))
24
- setDragging(true);
25
- }, onDragLeave: () => setDragging(false), onDrop: (e) => {
26
- setDragging(false);
27
- handlers.onDrop(e);
28
- }, onClick: handlers.onClick, onKeyDown: handlers.onKeyDown, "data-mol-id": "file-dropzone", role: "button", tabIndex: 0, "aria-disabled": disabled, className: cm.cn(cm.flex({ direction: 'col', align: 'center', justify: 'center' }), cm.sp('p', 6), cm.textCenter, !disabled ? cm.cursorPointer : undefined, className),
20
+ return (_jsx(FileField, { accept: accept, multiple: multiple, maxSize: maxSize, disabled: disabled, onValueChange: onFiles, onRejected: onRejected, webDrop: { onActiveChange: setDragging }, webInputDisplayNone: true, "data-mol-id": "file-dropzone", role: "button", tabIndex: 0, className: cm.cn(cm.flex({ direction: 'col', align: 'center', justify: 'center' }), cm.sp('p', 6), cm.textCenter, !disabled ? cm.cursorPointer : undefined, className),
29
21
  /* mol-bespoke-button: a drop SURFACE, not a CTA — a 140px dashed target
30
22
  that the user drops files onto and whose border thickens on drag-over.
31
23
  No `cm.button()` tier is a dashed drop region. The colours are theme
32
24
  tokens now; the old `rgba(0,0,0,…)` dashes were invisible on a dark
33
25
  background. */
34
- style: {
26
+ webStyle: {
35
27
  border: dragging
36
28
  ? '2px dashed var(--mol-color-primary, #3366ff)'
37
29
  : '2px dashed var(--mol-color-border, rgba(128,128,128,0.35))',
@@ -40,5 +32,5 @@ export function FileDropzone({ onFiles, accept, multiple = false, maxSize, onRej
40
32
  background: dragging
41
33
  ? 'color-mix(in srgb, var(--mol-color-primary, #3366ff) 6%, transparent)'
42
34
  : undefined,
43
- }, children: [_jsx("input", { ref: inputRef, type: "file", accept: accept, multiple: multiple, disabled: disabled, onChange: handlers.onChange, style: { display: 'none' } }), children ?? (_jsxs(_Fragment, { children: [_jsx("p", { className: cm.cn(cm.textSize('sm'), cm.fontWeight('semibold')), children: t('fileDropzone.dropHere', {}, { defaultValue: 'Drop files here or click to browse' }) }), accept && (_jsx("p", { className: cm.cn(cm.textSize('xs'), cm.sp('mt', 1)), children: t('fileDropzone.accepts', { accept }, { defaultValue: 'Accepts: {{accept}}' }) }))] }))] }));
35
+ }, children: children ?? (_jsxs(_Fragment, { children: [_jsx(Text, { as: "p", className: cm.cn(cm.textSize('sm'), cm.fontWeight('semibold')), children: t('fileDropzone.dropHere', {}, { defaultValue: 'Drop files here or click to browse' }) }), accept && (_jsx(Text, { as: "p", className: cm.cn(cm.textSize('xs'), cm.sp('mt', 1)), children: t('fileDropzone.accepts', { accept }, { defaultValue: 'Accepts: {{accept}}' }) }))] })) }));
44
36
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * File dropzone — drag-drop + click-to-browse file picker with
3
- * accept / max-size filtering. Pure UI: it emits the chosen `File[]`
3
+ * accept / max-size filtering. Pure UI: it emits portable `PickedFile` values
4
4
  * and the host app performs the actual upload.
5
5
  *
6
6
  * Exports `<FileDropzone>` and its `FileDropzoneProps`.
@@ -30,6 +30,8 @@
30
30
  * extension or MIME prefix match) — treat it as UX sugar and always
31
31
  * re-validate on the server. Files failing `accept` or `maxSize` go to
32
32
  * `onRejected` (both rejection causes arrive in the same callback).
33
+ * Read selected bytes with `arrayBuffer()` or append a file to a multipart
34
+ * body with `file.appendTo(formData, fieldName)`.
33
35
  *
34
36
  * Pass `children` to replace the default "Drop files here or click to
35
37
  * browse" copy; the default copy translates via
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,cAAc,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,cAAc,mBAAmB,CAAA"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * File dropzone — drag-drop + click-to-browse file picker with
3
- * accept / max-size filtering. Pure UI: it emits the chosen `File[]`
3
+ * accept / max-size filtering. Pure UI: it emits portable `PickedFile` values
4
4
  * and the host app performs the actual upload.
5
5
  *
6
6
  * Exports `<FileDropzone>` and its `FileDropzoneProps`.
@@ -30,6 +30,8 @@
30
30
  * extension or MIME prefix match) — treat it as UX sugar and always
31
31
  * re-validate on the server. Files failing `accept` or `maxSize` go to
32
32
  * `onRejected` (both rejection causes arrive in the same callback).
33
+ * Read selected bytes with `arrayBuffer()` or append a file to a multipart
34
+ * body with `file.appendTo(formData, fieldName)`.
33
35
  *
34
36
  * Pass `children` to replace the default "Drop files here or click to
35
37
  * browse" copy; the default copy translates via
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-file-dropzone-react",
3
- "version": "4.0.3",
3
+ "version": "5.0.0",
4
4
  "description": "Drag-drop file upload area with click-to-browse, accept/size filtering, and a content slot",
5
5
  "homepage": "https://www.molecule.dev/packages/app-file-dropzone-react",
6
6
  "type": "module",
@@ -36,14 +36,14 @@
36
36
  "@molecule/app-filesystem": "^1.1.0",
37
37
  "@molecule/app-react": "^4.13.0",
38
38
  "@molecule/app-ui": "^1.0.1",
39
- "@molecule/app-ui-react": "^4.0.0",
39
+ "@molecule/app-ui-react": "^4.12.0",
40
40
  "react": "^18.0.0 || ^19.0.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@molecule/app-filesystem": "1.1.0",
44
44
  "@molecule/app-react": "4.17.0",
45
- "@molecule/app-ui": "1.13.0",
46
- "@molecule/app-ui-react": "4.11.0",
45
+ "@molecule/app-ui": "1.14.0",
46
+ "@molecule/app-ui-react": "4.12.1",
47
47
  "@testing-library/react": "16.3.3",
48
48
  "@types/node": "26.6.5",
49
49
  "@types/react": "19.3.0",