@molecule/app-file-dropzone-angular 0.0.0-stage → 0.0.1-stage

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.
@@ -0,0 +1,178 @@
1
+ /**
2
+ * FileDropzone component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { type AfterViewInit, type DoCheck } from '@angular/core';
7
+ import type { UIClassMap } from '@molecule/app-ui';
8
+ import * as i0 from "@angular/core";
9
+ /**
10
+ * FileDropzone component.
11
+ *
12
+ * Drag-drop + click-to-browse file upload zone. Pure UI — apps handle the
13
+ * actual upload. Rejects files exceeding `maxSize` or not matching `accept`
14
+ * (best-effort extension/MIME check) via `onRejected`.
15
+ *
16
+ * The host IS the root `<div>` (`div[mol-file-dropzone]`), matching React's
17
+ * root exactly: `role`, `tabindex`, `data-mol-id`, the drag/click/keyboard
18
+ * handlers, the ClassMap classes and the inline drop-surface style live on it.
19
+ * `children` is projected content; the default copy renders only when nothing
20
+ * is projected.
21
+ *
22
+ * @remarks
23
+ * Angular projection needs the `<ng-content>` capture point mounted, so the
24
+ * default copy renders optimistically and {@link FileDropzone} withdraws it
25
+ * once it sees that the caller projected content (React renders one or the
26
+ * other, never both).
27
+ */
28
+ export declare class FileDropzone implements AfterViewInit, DoCheck {
29
+ /** Called with the File[] the user selected or dropped. */
30
+ onFiles?: (files: File[]) => void;
31
+ /** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
32
+ accept?: string;
33
+ /** Allow multi-file selection. Defaults to false. */
34
+ multiple?: boolean;
35
+ /** Max file size in bytes. Files exceeding are rejected. */
36
+ maxSize?: number;
37
+ /** Called with rejected files (wrong type or size). */
38
+ onRejected?: (files: File[]) => void;
39
+ /** Disabled state. */
40
+ disabled?: boolean;
41
+ /** Extra classes on the dropzone wrapper. */
42
+ className?: string;
43
+ /** The hidden file input (opened by a click or Enter/Space on the zone). */
44
+ private fileInput?;
45
+ /** The default "drop here" paragraph, while it renders. */
46
+ private defaultDropHere?;
47
+ /** The default accept-hint paragraph, while it renders. */
48
+ private defaultAccepts?;
49
+ /** The i18n handle (locale-reactive), read in an injection context. */
50
+ private readonly i18n;
51
+ /** The host element (the root `<div>`). */
52
+ private readonly el;
53
+ /** Whether a drag is over the zone (React's `useState`). */
54
+ private readonly dragging;
55
+ /** Whether the caller projected content (React's `children`). */
56
+ private readonly projected;
57
+ /** Whether the view (and its template nodes / queries) exists yet. */
58
+ private viewReady;
59
+ /** The drag-over fill, a theme token mixed into transparency. */
60
+ readonly backgroundStyle = "color-mix(in srgb, var(--mol-color-primary, #3366ff) 6%, transparent)";
61
+ /**
62
+ * The current class map.
63
+ * @returns The UIClassMap.
64
+ */
65
+ cm(): UIClassMap;
66
+ /**
67
+ * The wrapper class list (React's `cm.cn(cm.flex({…}), cm.sp('p', 6),
68
+ * cm.textCenter, !disabled ? cm.cursorPointer : undefined, className)`).
69
+ * @returns The class string.
70
+ */
71
+ classes(): string;
72
+ /**
73
+ * The dashed drop-surface border (React's `border`), thick in the primary
74
+ * colour while a drag is over the zone and muted otherwise.
75
+ * @returns The border declaration value.
76
+ */
77
+ borderStyle(): string;
78
+ /**
79
+ * The default "drop here" paragraph's class (React's
80
+ * `cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))`).
81
+ * @returns The class string.
82
+ */
83
+ dropHereClasses(): string;
84
+ /**
85
+ * The accept-hint paragraph's class (React's
86
+ * `cm.cn(cm.textSize('xs'), cm.sp('mt', 1))`).
87
+ * @returns The class string.
88
+ */
89
+ acceptsClasses(): string;
90
+ /**
91
+ * The default copy's first line (React's `fileDropzone.dropHere`).
92
+ * @returns The translated text.
93
+ */
94
+ dropHereText(): string;
95
+ /**
96
+ * The accept hint (React's `fileDropzone.accepts`). The text only renders
97
+ * while `accept` is set (the template's `@if`), so `''` never shows.
98
+ * @returns The translated text.
99
+ */
100
+ acceptsText(): string;
101
+ /**
102
+ * Whether the default copy is withdrawn because the caller projected
103
+ * content.
104
+ * @returns True when projected content replaces the default copy.
105
+ */
106
+ childrenProjected(): boolean;
107
+ /**
108
+ * Filters a file list into kept and rejected files, exactly as React does: a
109
+ * file over `maxSize` is rejected, then a file matching neither the accept
110
+ * extension nor the accept MIME token is rejected (`'*'` accepts everything).
111
+ *
112
+ * @param raw - The files the user dropped or picked.
113
+ * @returns The kept and rejected files.
114
+ */
115
+ filter(raw: FileList | File[]): {
116
+ kept: File[];
117
+ rejected: File[];
118
+ };
119
+ /**
120
+ * Filters the given file list and dispatches kept/rejected files to the
121
+ * callbacks — only the first kept file unless `multiple` is set.
122
+ *
123
+ * @param list - The files from the drop or the hidden input.
124
+ */
125
+ dispatch(list: FileList | File[]): void;
126
+ /** Opens the native file dialog through the hidden input. */
127
+ openDialog(): void;
128
+ /**
129
+ * React's `onDragOver`: prevents the browser's default (which would open the
130
+ * dropped file) and highlights the zone, unless disabled.
131
+ *
132
+ * @param event - The native drag event.
133
+ */
134
+ onDragOver(event: DragEvent): void;
135
+ /** React's `onDragLeave`: clears the highlight. */
136
+ onDragLeave(): void;
137
+ /**
138
+ * React's `onDrop`: always prevents the browser's default, clears the
139
+ * highlight, and dispatches the dropped files unless disabled.
140
+ *
141
+ * @param event - The native drop event.
142
+ */
143
+ onDrop(event: DragEvent): void;
144
+ /** React's `onClick`: opens the file dialog unless disabled. */
145
+ onClick(): void;
146
+ /**
147
+ * React's `onKeyDown`: `role="button"` gets no native keyboard activation —
148
+ * Enter/Space open the file dialog and prevent their defaults (Space would
149
+ * otherwise scroll the page).
150
+ *
151
+ * @param event - The native keyboard event.
152
+ */
153
+ onKeyDown(event: KeyboardEvent): void;
154
+ /**
155
+ * React's hidden input `onChange`: dispatches the picked files.
156
+ *
157
+ * @param event - The native change event.
158
+ */
159
+ onInputChange(event: Event): void;
160
+ /**
161
+ * Whether the caller projected any content (React's `children ?? default`).
162
+ * Latching: children cannot change after mount, so the first answer stands —
163
+ * without the latch, withdrawing the default copy would leave no node to
164
+ * compare against and the answer would oscillate.
165
+ *
166
+ * Runs only once the view is initialized: an earlier `ngDoCheck` runs before
167
+ * the template's nodes and the view queries exist, so every node would look
168
+ * like the caller's projection.
169
+ */
170
+ syncProjection(): void;
171
+ /** Reads the first render's projection once the view (and its content) exist. */
172
+ ngAfterViewInit(): void;
173
+ /** Re-reconciles the default copy with the projection after input writes. */
174
+ ngDoCheck(): void;
175
+ static ɵfac: i0.ɵɵFactoryDeclaration<FileDropzone, never>;
176
+ static ɵcmp: i0.ɵɵComponentDeclaration<FileDropzone, "div[mol-file-dropzone]", never, { "onFiles": { "alias": "onFiles"; "required": false; }; "accept": { "alias": "accept"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "maxSize": { "alias": "maxSize"; "required": false; }; "onRejected": { "alias": "onRejected"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, ["*"], true, never>;
177
+ }
178
+ //# sourceMappingURL=file-dropzone.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-dropzone.component.d.ts","sourceRoot":"","sources":["../src/file-dropzone.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,OAAO,EAKb,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAclD;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAuBa,YAAa,YAAW,aAAa,EAAE,OAAO;IACzD,2DAA2D;IAC3D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAA;IACjC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,uDAAuD;IACvD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,C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U,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAOlC,mDAAmD;IACnD,WAAW,IAAI,IAAI;IAInB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAM9B,gEAAgE;IAChE,OAAO,IAAI,IAAI;IAIf;;;;;;OAMG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;IAQrC;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAKjC;;;;;;;;;OASG;IACH,cAAc,IAAI,IAAI;IAatB,iFAAiF;IACjF,eAAe,IAAI,IAAI;IAKvB,6EAA6E;IAC7E,SAAS,IAAI,IAAI;yCAlRN,YAAY;2CAAZ,YAAY;CAqRxB"}
@@ -0,0 +1,373 @@
1
+ /**
2
+ * FileDropzone component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { Component, ElementRef, inject, signal, ViewChild, } from '@angular/core';
7
+ import { useTranslation } from '@molecule/app-angular';
8
+ import { getClassMap } from '@molecule/app-ui';
9
+ import * as i0 from "@angular/core";
10
+ const _c0 = ["fileInput"];
11
+ const _c1 = ["defaultDropHere"];
12
+ const _c2 = ["defaultAccepts"];
13
+ const _c3 = ["*"];
14
+ function FileDropzone_Conditional_3_Conditional_3_Template(rf, ctx) { if (rf & 1) {
15
+ i0.ɵɵdomElementStart(0, "p", null, 2);
16
+ i0.ɵɵtext(2);
17
+ i0.ɵɵdomElementEnd();
18
+ } if (rf & 2) {
19
+ const ctx_r0 = i0.ɵɵnextContext(2);
20
+ i0.ɵɵclassMap(ctx_r0.acceptsClasses());
21
+ i0.ɵɵadvance(2);
22
+ i0.ɵɵtextInterpolate(ctx_r0.acceptsText());
23
+ } }
24
+ function FileDropzone_Conditional_3_Template(rf, ctx) { if (rf & 1) {
25
+ i0.ɵɵdomElementStart(0, "p", null, 1);
26
+ i0.ɵɵtext(2);
27
+ i0.ɵɵdomElementEnd();
28
+ i0.ɵɵconditionalCreate(3, FileDropzone_Conditional_3_Conditional_3_Template, 3, 3, "p", 4);
29
+ } if (rf & 2) {
30
+ const ctx_r0 = i0.ɵɵnextContext();
31
+ i0.ɵɵclassMap(ctx_r0.dropHereClasses());
32
+ i0.ɵɵadvance(2);
33
+ i0.ɵɵtextInterpolate(ctx_r0.dropHereText());
34
+ i0.ɵɵadvance();
35
+ i0.ɵɵconditional(ctx_r0.accept ? 3 : -1);
36
+ } }
37
+ /**
38
+ * Whether a node is something a caller can see (an element, or a non-blank
39
+ * text node).
40
+ *
41
+ * @param node - The DOM node.
42
+ * @returns True when it renders anything.
43
+ */
44
+ const hasRenderable = (node) => node.nodeType === Node.ELEMENT_NODE ||
45
+ (node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim().length > 0);
46
+ /**
47
+ * FileDropzone component.
48
+ *
49
+ * Drag-drop + click-to-browse file upload zone. Pure UI — apps handle the
50
+ * actual upload. Rejects files exceeding `maxSize` or not matching `accept`
51
+ * (best-effort extension/MIME check) via `onRejected`.
52
+ *
53
+ * The host IS the root `<div>` (`div[mol-file-dropzone]`), matching React's
54
+ * root exactly: `role`, `tabindex`, `data-mol-id`, the drag/click/keyboard
55
+ * handlers, the ClassMap classes and the inline drop-surface style live on it.
56
+ * `children` is projected content; the default copy renders only when nothing
57
+ * is projected.
58
+ *
59
+ * @remarks
60
+ * Angular projection needs the `<ng-content>` capture point mounted, so the
61
+ * default copy renders optimistically and {@link FileDropzone} withdraws it
62
+ * once it sees that the caller projected content (React renders one or the
63
+ * other, never both).
64
+ */
65
+ export class FileDropzone {
66
+ /** Called with the File[] the user selected or dropped. */
67
+ onFiles;
68
+ /** Accept attribute (e.g. `'image/*'` or `'.pdf,.docx'`). */
69
+ accept;
70
+ /** Allow multi-file selection. Defaults to false. */
71
+ multiple;
72
+ /** Max file size in bytes. Files exceeding are rejected. */
73
+ maxSize;
74
+ /** Called with rejected files (wrong type or size). */
75
+ onRejected;
76
+ /** Disabled state. */
77
+ disabled;
78
+ /** Extra classes on the dropzone wrapper. */
79
+ className;
80
+ /** The hidden file input (opened by a click or Enter/Space on the zone). */
81
+ fileInput;
82
+ /** The default "drop here" paragraph, while it renders. */
83
+ defaultDropHere;
84
+ /** The default accept-hint paragraph, while it renders. */
85
+ defaultAccepts;
86
+ /** The i18n handle (locale-reactive), read in an injection context. */
87
+ i18n = useTranslation();
88
+ /** The host element (the root `<div>`). */
89
+ el = inject(ElementRef);
90
+ /** Whether a drag is over the zone (React's `useState`). */
91
+ dragging = signal(false, /* @ts-ignore */
92
+ ...(ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []));
93
+ /** Whether the caller projected content (React's `children`). */
94
+ projected = signal(false, /* @ts-ignore */
95
+ ...(ngDevMode ? [{ debugName: "projected" }] : /* istanbul ignore next */ []));
96
+ /** Whether the view (and its template nodes / queries) exists yet. */
97
+ viewReady = false;
98
+ /** The drag-over fill, a theme token mixed into transparency. */
99
+ backgroundStyle = 'color-mix(in srgb, var(--mol-color-primary, #3366ff) 6%, transparent)';
100
+ /**
101
+ * The current class map.
102
+ * @returns The UIClassMap.
103
+ */
104
+ cm() {
105
+ return getClassMap();
106
+ }
107
+ /**
108
+ * The wrapper class list (React's `cm.cn(cm.flex({…}), cm.sp('p', 6),
109
+ * cm.textCenter, !disabled ? cm.cursorPointer : undefined, className)`).
110
+ * @returns The class string.
111
+ */
112
+ classes() {
113
+ return this.cm().cn(this.cm().flex({ direction: 'col', align: 'center', justify: 'center' }), this.cm().sp('p', 6), this.cm().textCenter, !this.disabled ? this.cm().cursorPointer : undefined, this.className);
114
+ }
115
+ /**
116
+ * The dashed drop-surface border (React's `border`), thick in the primary
117
+ * colour while a drag is over the zone and muted otherwise.
118
+ * @returns The border declaration value.
119
+ */
120
+ borderStyle() {
121
+ return this.dragging()
122
+ ? '2px dashed var(--mol-color-primary, #3366ff)'
123
+ : '2px dashed var(--mol-color-border, rgba(128,128,128,0.35))';
124
+ }
125
+ /**
126
+ * The default "drop here" paragraph's class (React's
127
+ * `cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))`).
128
+ * @returns The class string.
129
+ */
130
+ dropHereClasses() {
131
+ return this.cm().cn(this.cm().textSize('sm'), this.cm().fontWeight('semibold'));
132
+ }
133
+ /**
134
+ * The accept-hint paragraph's class (React's
135
+ * `cm.cn(cm.textSize('xs'), cm.sp('mt', 1))`).
136
+ * @returns The class string.
137
+ */
138
+ acceptsClasses() {
139
+ return this.cm().cn(this.cm().textSize('xs'), this.cm().sp('mt', 1));
140
+ }
141
+ /**
142
+ * The default copy's first line (React's `fileDropzone.dropHere`).
143
+ * @returns The translated text.
144
+ */
145
+ dropHereText() {
146
+ return this.i18n.t('fileDropzone.dropHere', {}, { defaultValue: 'Drop files here or click to browse' });
147
+ }
148
+ /**
149
+ * The accept hint (React's `fileDropzone.accepts`). The text only renders
150
+ * while `accept` is set (the template's `@if`), so `''` never shows.
151
+ * @returns The translated text.
152
+ */
153
+ acceptsText() {
154
+ return this.i18n.t('fileDropzone.accepts', { accept: this.accept ?? '' }, { defaultValue: 'Accepts: {{accept}}' });
155
+ }
156
+ /**
157
+ * Whether the default copy is withdrawn because the caller projected
158
+ * content.
159
+ * @returns True when projected content replaces the default copy.
160
+ */
161
+ childrenProjected() {
162
+ return this.projected();
163
+ }
164
+ /**
165
+ * Filters a file list into kept and rejected files, exactly as React does: a
166
+ * file over `maxSize` is rejected, then a file matching neither the accept
167
+ * extension nor the accept MIME token is rejected (`'*'` accepts everything).
168
+ *
169
+ * @param raw - The files the user dropped or picked.
170
+ * @returns The kept and rejected files.
171
+ */
172
+ filter(raw) {
173
+ const arr = Array.from(raw);
174
+ const kept = [];
175
+ const rejected = [];
176
+ for (const f of arr) {
177
+ if (this.maxSize && f.size > this.maxSize) {
178
+ rejected.push(f);
179
+ continue;
180
+ }
181
+ // cheap accept check
182
+ if (this.accept) {
183
+ const okByExt = this.accept
184
+ .split(',')
185
+ .some((a) => a.trim() && f.name.toLowerCase().endsWith(a.trim().toLowerCase().replace(/^\./, '.')));
186
+ const okByMime = this.accept
187
+ .split(',')
188
+ .some((a) => a.trim() &&
189
+ f.type &&
190
+ (f.type === a.trim() ||
191
+ (a.trim().endsWith('/*') && f.type.startsWith(a.trim().replace('/*', '/')))));
192
+ if (!okByExt && !okByMime && this.accept !== '*') {
193
+ rejected.push(f);
194
+ continue;
195
+ }
196
+ }
197
+ kept.push(f);
198
+ }
199
+ return { kept, rejected };
200
+ }
201
+ /**
202
+ * Filters the given file list and dispatches kept/rejected files to the
203
+ * callbacks — only the first kept file unless `multiple` is set.
204
+ *
205
+ * @param list - The files from the drop or the hidden input.
206
+ */
207
+ dispatch(list) {
208
+ const { kept, rejected } = this.filter(list);
209
+ if (kept.length > 0)
210
+ this.onFiles?.(this.multiple ? kept : [kept[0]]);
211
+ if (rejected.length > 0)
212
+ this.onRejected?.(rejected);
213
+ }
214
+ /** Opens the native file dialog through the hidden input. */
215
+ openDialog() {
216
+ this.fileInput?.nativeElement.click();
217
+ }
218
+ /**
219
+ * React's `onDragOver`: prevents the browser's default (which would open the
220
+ * dropped file) and highlights the zone, unless disabled.
221
+ *
222
+ * @param event - The native drag event.
223
+ */
224
+ onDragOver(event) {
225
+ if (!this.disabled) {
226
+ event.preventDefault();
227
+ this.dragging.set(true);
228
+ }
229
+ }
230
+ /** React's `onDragLeave`: clears the highlight. */
231
+ onDragLeave() {
232
+ this.dragging.set(false);
233
+ }
234
+ /**
235
+ * React's `onDrop`: always prevents the browser's default, clears the
236
+ * highlight, and dispatches the dropped files unless disabled.
237
+ *
238
+ * @param event - The native drop event.
239
+ */
240
+ onDrop(event) {
241
+ event.preventDefault();
242
+ this.dragging.set(false);
243
+ if (!this.disabled && event.dataTransfer?.files)
244
+ this.dispatch(event.dataTransfer.files);
245
+ }
246
+ /** React's `onClick`: opens the file dialog unless disabled. */
247
+ onClick() {
248
+ if (!this.disabled)
249
+ this.openDialog();
250
+ }
251
+ /**
252
+ * React's `onKeyDown`: `role="button"` gets no native keyboard activation —
253
+ * Enter/Space open the file dialog and prevent their defaults (Space would
254
+ * otherwise scroll the page).
255
+ *
256
+ * @param event - The native keyboard event.
257
+ */
258
+ onKeyDown(event) {
259
+ if (this.disabled)
260
+ return;
261
+ if (event.key === 'Enter' || event.key === ' ' || event.key === 'Spacebar') {
262
+ event.preventDefault();
263
+ this.openDialog();
264
+ }
265
+ }
266
+ /**
267
+ * React's hidden input `onChange`: dispatches the picked files.
268
+ *
269
+ * @param event - The native change event.
270
+ */
271
+ onInputChange(event) {
272
+ const files = event.target.files;
273
+ if (files)
274
+ this.dispatch(files);
275
+ }
276
+ /**
277
+ * Whether the caller projected any content (React's `children ?? default`).
278
+ * Latching: children cannot change after mount, so the first answer stands —
279
+ * without the latch, withdrawing the default copy would leave no node to
280
+ * compare against and the answer would oscillate.
281
+ *
282
+ * Runs only once the view is initialized: an earlier `ngDoCheck` runs before
283
+ * the template's nodes and the view queries exist, so every node would look
284
+ * like the caller's projection.
285
+ */
286
+ syncProjection() {
287
+ if (!this.viewReady || this.projected())
288
+ return;
289
+ const host = this.el.nativeElement;
290
+ const own = new Set();
291
+ if (this.fileInput)
292
+ own.add(this.fileInput.nativeElement);
293
+ if (this.defaultDropHere)
294
+ own.add(this.defaultDropHere.nativeElement);
295
+ if (this.defaultAccepts)
296
+ own.add(this.defaultAccepts.nativeElement);
297
+ const projected = Array.from(host.childNodes).some((node) => !own.has(node) && hasRenderable(node));
298
+ if (projected)
299
+ this.projected.set(true);
300
+ }
301
+ /** Reads the first render's projection once the view (and its content) exist. */
302
+ ngAfterViewInit() {
303
+ this.viewReady = true;
304
+ this.syncProjection();
305
+ }
306
+ /** Re-reconciles the default copy with the projection after input writes. */
307
+ ngDoCheck() {
308
+ this.syncProjection();
309
+ }
310
+ static ɵfac = function FileDropzone_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || FileDropzone)(); };
311
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: FileDropzone, selectors: [["div", "mol-file-dropzone", ""]], viewQuery: function FileDropzone_Query(rf, ctx) { if (rf & 1) {
312
+ i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5);
313
+ } if (rf & 2) {
314
+ let _t;
315
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.fileInput = _t.first);
316
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.defaultDropHere = _t.first);
317
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.defaultAccepts = _t.first);
318
+ } }, hostAttrs: ["role", "button", "tabindex", "0", "data-mol-id", "file-dropzone"], hostVars: 11, hostBindings: function FileDropzone_HostBindings(rf, ctx) { if (rf & 1) {
319
+ i0.ɵɵlistener("dragover", function FileDropzone_dragover_HostBindingHandler($event) { return ctx.onDragOver($event); })("dragleave", function FileDropzone_dragleave_HostBindingHandler() { return ctx.onDragLeave(); })("drop", function FileDropzone_drop_HostBindingHandler($event) { return ctx.onDrop($event); })("click", function FileDropzone_click_HostBindingHandler() { return ctx.onClick(); })("keydown", function FileDropzone_keydown_HostBindingHandler($event) { return ctx.onKeyDown($event); });
320
+ } if (rf & 2) {
321
+ i0.ɵɵattribute("aria-disabled", ctx.disabled ?? null);
322
+ i0.ɵɵclassMap(ctx.classes());
323
+ i0.ɵɵstyleProp("border", ctx.borderStyle())("border-radius", "12px")("min-height", "140px")("background", ctx.dragging() ? ctx.backgroundStyle : null);
324
+ } }, inputs: { onFiles: "onFiles", accept: "accept", multiple: "multiple", maxSize: "maxSize", onRejected: "onRejected", disabled: "disabled", className: "className" }, ngContentSelectors: _c3, decls: 4, vars: 4, consts: [["fileInput", ""], ["defaultDropHere", ""], ["defaultAccepts", ""], ["type", "file", 2, "display", "none", 3, "change"], [3, "class"]], template: function FileDropzone_Template(rf, ctx) { if (rf & 1) {
325
+ i0.ɵɵprojectionDef();
326
+ i0.ɵɵdomElementStart(0, "input", 3, 0);
327
+ i0.ɵɵdomListener("change", function FileDropzone_Template_input_change_0_listener($event) { return ctx.onInputChange($event); });
328
+ i0.ɵɵdomElementEnd();
329
+ i0.ɵɵprojection(2);
330
+ i0.ɵɵconditionalCreate(3, FileDropzone_Conditional_3_Template, 4, 4);
331
+ } if (rf & 2) {
332
+ i0.ɵɵattribute("accept", ctx.accept ?? null)("multiple", ctx.multiple ? "" : null)("disabled", ctx.disabled ? "" : null);
333
+ i0.ɵɵadvance(3);
334
+ i0.ɵɵconditional(!ctx.childrenProjected() ? 3 : -1);
335
+ } }, encapsulation: 2 });
336
+ }
337
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(FileDropzone, [{
338
+ type: Component,
339
+ args: [{
340
+ selector: 'div[mol-file-dropzone]',
341
+ standalone: true,
342
+ inputs: ['onFiles', 'accept', 'multiple', 'maxSize', 'onRejected', 'disabled', 'className'],
343
+ host: {
344
+ role: 'button',
345
+ tabindex: '0',
346
+ 'data-mol-id': 'file-dropzone',
347
+ '[attr.aria-disabled]': 'disabled ?? null',
348
+ '[class]': 'classes()',
349
+ '[style.border]': 'borderStyle()',
350
+ '[style.border-radius]': '"12px"',
351
+ '[style.min-height]': '"140px"',
352
+ '[style.background]': 'dragging() ? backgroundStyle : null',
353
+ '(dragover)': 'onDragOver($event)',
354
+ '(dragleave)': 'onDragLeave()',
355
+ '(drop)': 'onDrop($event)',
356
+ '(click)': 'onClick()',
357
+ '(keydown)': 'onKeyDown($event)',
358
+ },
359
+ // prettier-ignore
360
+ template: `<input #fileInput type="file" [attr.accept]="accept ?? null" [attr.multiple]="multiple ? '' : null" [attr.disabled]="disabled ? '' : null" (change)="onInputChange($event)" style="display: none" /><ng-content></ng-content>@if (!childrenProjected()) {<p #defaultDropHere [class]="dropHereClasses()">{{ dropHereText() }}</p>@if (accept) {<p #defaultAccepts [class]="acceptsClasses()">{{ acceptsText() }}</p>}}`,
361
+ }]
362
+ }], null, { fileInput: [{
363
+ type: ViewChild,
364
+ args: ['fileInput']
365
+ }], defaultDropHere: [{
366
+ type: ViewChild,
367
+ args: ['defaultDropHere']
368
+ }], defaultAccepts: [{
369
+ type: ViewChild,
370
+ args: ['defaultAccepts']
371
+ }] }); })();
372
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(FileDropzone, { className: "FileDropzone", filePath: "file-dropzone.component.ts", lineNumber: 74 }); })();
373
+ //# sourceMappingURL=file-dropzone.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-dropzone.component.js","sourceRoot":"","sources":["../src/file-dropzone.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,SAAS,EAET,UAAU,EACV,MAAM,EACN,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;;;;;;;IAqD8S,qCAA8C;IAAA,YAAmB;IAAA,oBAAI;;;IAAlD,sCAA0B;IAAC,eAAmB;IAAnB,0CAAmB;;;IAAvJ,qCAAgD;IAAA,YAAoB;IAAA,oBAAI;IAAA,0FAAc;;;IAAlE,uCAA2B;IAAC,eAAoB;IAApB,2CAAoB;IAAI,cAAoF;IAApF,wCAAoF;;AAnDla;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,CAAC,IAAU,EAAW,EAAE,CAC5C,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;IACnC,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAElF;;;;;;;;;;;;;;;;;;GAkBG;AAwBH,MAAM,OAAO,YAAY;IACvB,2DAA2D;IAC3D,OAAO,CAA0B;IACjC,6DAA6D;IAC7D,MAAM,CAAS;IACf,qDAAqD;IACrD,QAAQ,CAAU;IA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E,mBAAmB;iBACjC;gBACD,kBAAkB;gBAClB,QAAQ,EAAE,wZAAwZ;aACna;;kBAkBE,SAAS;mBAAC,WAAW;;kBAErB,SAAS;mBAAC,iBAAiB;;kBAE3B,SAAS;mBAAC,gBAAgB;;kFArBhB,YAAY"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Angular file dropzone — drag-drop + click-to-browse file picker with
3
+ * accept / max-size filtering. Pure UI: it emits the chosen `File[]`
4
+ * and the host app performs the actual upload.
5
+ *
6
+ * Exports `<FileDropzone>` and its `FileDropzoneProps`. It is the Angular
7
+ * counterpart of `@molecule/app-file-dropzone-react`: same props and the same
8
+ * DOM for the same input.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Component } from '@angular/core'
13
+ * import { FileDropzone } from '@molecule/app-file-dropzone-angular'
14
+ *
15
+ * @Component({
16
+ * selector: 'app-avatar-upload',
17
+ * standalone: true,
18
+ * imports: [FileDropzone],
19
+ * template: `
20
+ * <div
21
+ * mol-file-dropzone
22
+ * accept="image/*"
23
+ * [maxSize]="5 * 1024 * 1024"
24
+ * [onFiles]="uploadAvatar"
25
+ * [onRejected]="showError"
26
+ * ></div>
27
+ * `,
28
+ * })
29
+ * export class AvatarUpload {
30
+ * avatar: File | null = null
31
+ * error = ''
32
+ * uploadAvatar = (files: File[]): void => {
33
+ * this.avatar = files[0] ?? null
34
+ * }
35
+ * showError = (files: File[]): void => {
36
+ * this.error = `${files.length} file(s) are not images under 5 MB`
37
+ * }
38
+ * }
39
+ * ```
40
+ *
41
+ * @remarks
42
+ * With `multiple` false (the default) only the FIRST accepted file is
43
+ * delivered to `onFiles`, even when the user drops several at once.
44
+ *
45
+ * The `accept` filter is a best-effort client-side check (file
46
+ * extension or MIME prefix match) — treat it as UX sugar and always
47
+ * re-validate on the server. Files failing `accept` or `maxSize` go to
48
+ * `onRejected` (both rejection causes arrive in the same callback).
49
+ *
50
+ * `children` is projected content (Angular cannot carry a node in an input):
51
+ * put it between the element's tags to replace the default "Drop files here or
52
+ * click to browse" copy, which translates via
53
+ * `@molecule/app-locales-file-dropzone`.
54
+ *
55
+ * The zone is a keyboard-activatable `role="button"` (`tabindex="0"`):
56
+ * pressing Enter or Space opens the native file dialog, matching a click.
57
+ *
58
+ * @module
59
+ */
60
+ export * from './file-dropzone.component.js';
61
+ export * from './types.js';
62
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AAEH,cAAc,8BAA8B,CAAA;AAC5C,cAAc,YAAY,CAAA"}