@nysds/nys-fileinput 1.4.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.
@@ -0,0 +1 @@
1
+ export * from "./nys-fileinput";
@@ -0,0 +1,46 @@
1
+ import { LitElement } from "lit";
2
+ import "./nys-fileitem";
3
+ export declare class NysFileinput extends LitElement {
4
+ id: string;
5
+ name: string;
6
+ label: string;
7
+ description: string;
8
+ multiple: boolean;
9
+ accept: string;
10
+ disabled: boolean;
11
+ required: boolean;
12
+ optional: boolean;
13
+ showError: boolean;
14
+ errorMessage: string;
15
+ dropzone: boolean;
16
+ width: "lg" | "full";
17
+ static styles: import("lit").CSSResult;
18
+ private _selectedFiles;
19
+ private _dragActive;
20
+ private get _isDropDisabled();
21
+ private _internals;
22
+ /********************** Lifecycle updates **********************/
23
+ static formAssociated: boolean;
24
+ constructor();
25
+ connectedCallback(): void;
26
+ disconnectedCallback(): void;
27
+ firstUpdated(): void;
28
+ /********************** Form Integration **********************/
29
+ private _setValue;
30
+ private _manageRequire;
31
+ private _setValidityMessage;
32
+ private _validate;
33
+ /******************** Functions ********************/
34
+ private _saveSelectedFiles;
35
+ private _processFile;
36
+ private _dispatchChangeEvent;
37
+ private _openFileDialog;
38
+ /******************** Event Handlers ********************/
39
+ private _handleFileChange;
40
+ private _handleFileRemove;
41
+ private _onDragOver;
42
+ private _onDragLeave;
43
+ private _onDrop;
44
+ private _handleInvalid;
45
+ render(): import("lit-html").TemplateResult<1>;
46
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,980 @@
1
+ import { css as D, LitElement as F, html as c } from "lit";
2
+ /*!
3
+ * ▒█▄░▒█ ▒█░░▒█ ▒█▀▀▀█ ▒█▀▀▄ ▒█▀▀▀█
4
+ * ▒█▒█▒█ ▒█▄▄▄█ ░▀▀▀▄▄ ▒█░▒█ ░▀▀▀▄▄
5
+ * ▒█░░▀█ ░░▒█░░ ▒█▄▄▄█ ▒█▄▄▀ ▒█▄▄▄█
6
+ *
7
+ * Fileinput Component
8
+ * Part of the New York State Design System
9
+ * Repository: https://github.com/its-hcd/nysds
10
+ * License: MIT
11
+ */
12
+ /**
13
+ * @license
14
+ * Copyright 2019 Google LLC
15
+ * SPDX-License-Identifier: BSD-3-Clause
16
+ */
17
+ const _ = globalThis, E = _.ShadowRoot && (_.ShadyCSS === void 0 || _.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, A = Symbol(), P = /* @__PURE__ */ new WeakMap();
18
+ let M = class {
19
+ constructor(e, t, s) {
20
+ if (this._$cssResult$ = !0, s !== A) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
21
+ this.cssText = e, this.t = t;
22
+ }
23
+ get styleSheet() {
24
+ let e = this.o;
25
+ const t = this.t;
26
+ if (E && e === void 0) {
27
+ const s = t !== void 0 && t.length === 1;
28
+ s && (e = P.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), s && P.set(t, e));
29
+ }
30
+ return e;
31
+ }
32
+ toString() {
33
+ return this.cssText;
34
+ }
35
+ };
36
+ const O = (r) => new M(typeof r == "string" ? r : r + "", void 0, A), R = (r, e) => {
37
+ if (E) r.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet);
38
+ else for (const t of e) {
39
+ const s = document.createElement("style"), i = _.litNonce;
40
+ i !== void 0 && s.setAttribute("nonce", i), s.textContent = t.cssText, r.appendChild(s);
41
+ }
42
+ }, k = E ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((e) => {
43
+ let t = "";
44
+ for (const s of e.cssRules) t += s.cssText;
45
+ return O(t);
46
+ })(r) : r;
47
+ /**
48
+ * @license
49
+ * Copyright 2017 Google LLC
50
+ * SPDX-License-Identifier: BSD-3-Clause
51
+ */
52
+ const { is: q, defineProperty: j, getOwnPropertyDescriptor: L, getOwnPropertyNames: T, getOwnPropertySymbols: V, getPrototypeOf: I } = Object, u = globalThis, C = u.trustedTypes, B = C ? C.emptyScript : "", w = u.reactiveElementPolyfillSupport, y = (r, e) => r, v = { toAttribute(r, e) {
53
+ switch (e) {
54
+ case Boolean:
55
+ r = r ? B : null;
56
+ break;
57
+ case Object:
58
+ case Array:
59
+ r = r == null ? r : JSON.stringify(r);
60
+ }
61
+ return r;
62
+ }, fromAttribute(r, e) {
63
+ let t = r;
64
+ switch (e) {
65
+ case Boolean:
66
+ t = r !== null;
67
+ break;
68
+ case Number:
69
+ t = r === null ? null : Number(r);
70
+ break;
71
+ case Object:
72
+ case Array:
73
+ try {
74
+ t = JSON.parse(r);
75
+ } catch {
76
+ t = null;
77
+ }
78
+ }
79
+ return t;
80
+ } }, S = (r, e) => !q(r, e), U = { attribute: !0, type: String, converter: v, reflect: !1, hasChanged: S };
81
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), u.litPropertyMetadata ?? (u.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
82
+ class g extends HTMLElement {
83
+ static addInitializer(e) {
84
+ this._$Ei(), (this.l ?? (this.l = [])).push(e);
85
+ }
86
+ static get observedAttributes() {
87
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
88
+ }
89
+ static createProperty(e, t = U) {
90
+ if (t.state && (t.attribute = !1), this._$Ei(), this.elementProperties.set(e, t), !t.noAccessor) {
91
+ const s = Symbol(), i = this.getPropertyDescriptor(e, s, t);
92
+ i !== void 0 && j(this.prototype, e, i);
93
+ }
94
+ }
95
+ static getPropertyDescriptor(e, t, s) {
96
+ const { get: i, set: n } = L(this.prototype, e) ?? { get() {
97
+ return this[t];
98
+ }, set(o) {
99
+ this[t] = o;
100
+ } };
101
+ return { get() {
102
+ return i == null ? void 0 : i.call(this);
103
+ }, set(o) {
104
+ const a = i == null ? void 0 : i.call(this);
105
+ n.call(this, o), this.requestUpdate(e, a, s);
106
+ }, configurable: !0, enumerable: !0 };
107
+ }
108
+ static getPropertyOptions(e) {
109
+ return this.elementProperties.get(e) ?? U;
110
+ }
111
+ static _$Ei() {
112
+ if (this.hasOwnProperty(y("elementProperties"))) return;
113
+ const e = I(this);
114
+ e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
115
+ }
116
+ static finalize() {
117
+ if (this.hasOwnProperty(y("finalized"))) return;
118
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(y("properties"))) {
119
+ const t = this.properties, s = [...T(t), ...V(t)];
120
+ for (const i of s) this.createProperty(i, t[i]);
121
+ }
122
+ const e = this[Symbol.metadata];
123
+ if (e !== null) {
124
+ const t = litPropertyMetadata.get(e);
125
+ if (t !== void 0) for (const [s, i] of t) this.elementProperties.set(s, i);
126
+ }
127
+ this._$Eh = /* @__PURE__ */ new Map();
128
+ for (const [t, s] of this.elementProperties) {
129
+ const i = this._$Eu(t, s);
130
+ i !== void 0 && this._$Eh.set(i, t);
131
+ }
132
+ this.elementStyles = this.finalizeStyles(this.styles);
133
+ }
134
+ static finalizeStyles(e) {
135
+ const t = [];
136
+ if (Array.isArray(e)) {
137
+ const s = new Set(e.flat(1 / 0).reverse());
138
+ for (const i of s) t.unshift(k(i));
139
+ } else e !== void 0 && t.push(k(e));
140
+ return t;
141
+ }
142
+ static _$Eu(e, t) {
143
+ const s = t.attribute;
144
+ return s === !1 ? void 0 : typeof s == "string" ? s : typeof e == "string" ? e.toLowerCase() : void 0;
145
+ }
146
+ constructor() {
147
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
148
+ }
149
+ _$Ev() {
150
+ var e;
151
+ this._$ES = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (e = this.constructor.l) == null || e.forEach((t) => t(this));
152
+ }
153
+ addController(e) {
154
+ var t;
155
+ (this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(e), this.renderRoot !== void 0 && this.isConnected && ((t = e.hostConnected) == null || t.call(e));
156
+ }
157
+ removeController(e) {
158
+ var t;
159
+ (t = this._$EO) == null || t.delete(e);
160
+ }
161
+ _$E_() {
162
+ const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
163
+ for (const s of t.keys()) this.hasOwnProperty(s) && (e.set(s, this[s]), delete this[s]);
164
+ e.size > 0 && (this._$Ep = e);
165
+ }
166
+ createRenderRoot() {
167
+ const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
168
+ return R(e, this.constructor.elementStyles), e;
169
+ }
170
+ connectedCallback() {
171
+ var e;
172
+ this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((t) => {
173
+ var s;
174
+ return (s = t.hostConnected) == null ? void 0 : s.call(t);
175
+ });
176
+ }
177
+ enableUpdating(e) {
178
+ }
179
+ disconnectedCallback() {
180
+ var e;
181
+ (e = this._$EO) == null || e.forEach((t) => {
182
+ var s;
183
+ return (s = t.hostDisconnected) == null ? void 0 : s.call(t);
184
+ });
185
+ }
186
+ attributeChangedCallback(e, t, s) {
187
+ this._$AK(e, s);
188
+ }
189
+ _$EC(e, t) {
190
+ var n;
191
+ const s = this.constructor.elementProperties.get(e), i = this.constructor._$Eu(e, s);
192
+ if (i !== void 0 && s.reflect === !0) {
193
+ const o = (((n = s.converter) == null ? void 0 : n.toAttribute) !== void 0 ? s.converter : v).toAttribute(t, s.type);
194
+ this._$Em = e, o == null ? this.removeAttribute(i) : this.setAttribute(i, o), this._$Em = null;
195
+ }
196
+ }
197
+ _$AK(e, t) {
198
+ var n;
199
+ const s = this.constructor, i = s._$Eh.get(e);
200
+ if (i !== void 0 && this._$Em !== i) {
201
+ const o = s.getPropertyOptions(i), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((n = o.converter) == null ? void 0 : n.fromAttribute) !== void 0 ? o.converter : v;
202
+ this._$Em = i, this[i] = a.fromAttribute(t, o.type), this._$Em = null;
203
+ }
204
+ }
205
+ requestUpdate(e, t, s) {
206
+ if (e !== void 0) {
207
+ if (s ?? (s = this.constructor.getPropertyOptions(e)), !(s.hasChanged ?? S)(this[e], t)) return;
208
+ this.P(e, t, s);
209
+ }
210
+ this.isUpdatePending === !1 && (this._$ES = this._$ET());
211
+ }
212
+ P(e, t, s) {
213
+ this._$AL.has(e) || this._$AL.set(e, t), s.reflect === !0 && this._$Em !== e && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(e);
214
+ }
215
+ async _$ET() {
216
+ this.isUpdatePending = !0;
217
+ try {
218
+ await this._$ES;
219
+ } catch (t) {
220
+ Promise.reject(t);
221
+ }
222
+ const e = this.scheduleUpdate();
223
+ return e != null && await e, !this.isUpdatePending;
224
+ }
225
+ scheduleUpdate() {
226
+ return this.performUpdate();
227
+ }
228
+ performUpdate() {
229
+ var s;
230
+ if (!this.isUpdatePending) return;
231
+ if (!this.hasUpdated) {
232
+ if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
233
+ for (const [n, o] of this._$Ep) this[n] = o;
234
+ this._$Ep = void 0;
235
+ }
236
+ const i = this.constructor.elementProperties;
237
+ if (i.size > 0) for (const [n, o] of i) o.wrapped !== !0 || this._$AL.has(n) || this[n] === void 0 || this.P(n, this[n], o);
238
+ }
239
+ let e = !1;
240
+ const t = this._$AL;
241
+ try {
242
+ e = this.shouldUpdate(t), e ? (this.willUpdate(t), (s = this._$EO) == null || s.forEach((i) => {
243
+ var n;
244
+ return (n = i.hostUpdate) == null ? void 0 : n.call(i);
245
+ }), this.update(t)) : this._$EU();
246
+ } catch (i) {
247
+ throw e = !1, this._$EU(), i;
248
+ }
249
+ e && this._$AE(t);
250
+ }
251
+ willUpdate(e) {
252
+ }
253
+ _$AE(e) {
254
+ var t;
255
+ (t = this._$EO) == null || t.forEach((s) => {
256
+ var i;
257
+ return (i = s.hostUpdated) == null ? void 0 : i.call(s);
258
+ }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
259
+ }
260
+ _$EU() {
261
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
262
+ }
263
+ get updateComplete() {
264
+ return this.getUpdateComplete();
265
+ }
266
+ getUpdateComplete() {
267
+ return this._$ES;
268
+ }
269
+ shouldUpdate(e) {
270
+ return !0;
271
+ }
272
+ update(e) {
273
+ this._$Ej && (this._$Ej = this._$Ej.forEach((t) => this._$EC(t, this[t]))), this._$EU();
274
+ }
275
+ updated(e) {
276
+ }
277
+ firstUpdated(e) {
278
+ }
279
+ }
280
+ g.elementStyles = [], g.shadowRootOptions = { mode: "open" }, g[y("elementProperties")] = /* @__PURE__ */ new Map(), g[y("finalized")] = /* @__PURE__ */ new Map(), w == null || w({ ReactiveElement: g }), (u.reactiveElementVersions ?? (u.reactiveElementVersions = [])).push("2.0.4");
281
+ /**
282
+ * @license
283
+ * Copyright 2017 Google LLC
284
+ * SPDX-License-Identifier: BSD-3-Clause
285
+ */
286
+ const N = { attribute: !0, type: String, converter: v, reflect: !1, hasChanged: S }, H = (r = N, e, t) => {
287
+ const { kind: s, metadata: i } = t;
288
+ let n = globalThis.litPropertyMetadata.get(i);
289
+ if (n === void 0 && globalThis.litPropertyMetadata.set(i, n = /* @__PURE__ */ new Map()), n.set(t.name, r), s === "accessor") {
290
+ const { name: o } = t;
291
+ return { set(a) {
292
+ const d = e.get.call(this);
293
+ e.set.call(this, a), this.requestUpdate(o, d, r);
294
+ }, init(a) {
295
+ return a !== void 0 && this.P(o, void 0, r), a;
296
+ } };
297
+ }
298
+ if (s === "setter") {
299
+ const { name: o } = t;
300
+ return function(a) {
301
+ const d = this[o];
302
+ e.call(this, a), this.requestUpdate(o, d, r);
303
+ };
304
+ }
305
+ throw Error("Unsupported decorator location: " + s);
306
+ };
307
+ function l(r) {
308
+ return (e, t) => typeof t == "object" ? H(r, e, t) : ((s, i, n) => {
309
+ const o = i.hasOwnProperty(n);
310
+ return i.constructor.createProperty(n, o ? { ...s, wrapped: !0 } : s), o ? Object.getOwnPropertyDescriptor(i, n) : void 0;
311
+ })(r, e, t);
312
+ }
313
+ const K = {
314
+ png: [137, 80, 78, 71, 13, 10, 26, 10],
315
+ jpg: (r) => r.length >= 4 && r[0] === 255 && r[1] === 216 && r[2] === 255 && [224, 225, 219].includes(r[3]),
316
+ pdf: (r) => {
317
+ let e = 0;
318
+ for (; e < r.length && [32, 10, 13].includes(r[e]); )
319
+ e++;
320
+ return r[e] === 37 && r[e + 1] === 80 && r[e + 2] === 68 && r[e + 3] === 70;
321
+ },
322
+ gif: [71, 73, 70, 56],
323
+ mp4: (r) => {
324
+ const e = [102, 116, 121, 112];
325
+ for (let t = 0; t <= r.length - e.length; t++) {
326
+ let s = !0;
327
+ for (let i = 0; i < e.length; i++)
328
+ if (r[t + i] !== e[i]) {
329
+ s = !1;
330
+ break;
331
+ }
332
+ if (s) return !0;
333
+ }
334
+ return !1;
335
+ }
336
+ };
337
+ function W(r, e) {
338
+ if (typeof e == "function") return e(r);
339
+ if (r.length < e.length) return !1;
340
+ for (let t = 0; t < e.length; t++)
341
+ if (r[t] !== e[t]) return !1;
342
+ return !0;
343
+ }
344
+ const z = {
345
+ "image/png": ["png"],
346
+ "image/jpeg": ["jpg"],
347
+ "image/jpg": ["jpg"],
348
+ "image/*": ["png", "jpg", "gif"],
349
+ "video/mp4": ["mp4"],
350
+ "video/*": ["mp4"],
351
+ "application/pdf": ["pdf"],
352
+ ".pdf": ["pdf"],
353
+ ".jpg": ["jpg"],
354
+ ".jpeg": ["jpg"],
355
+ ".png": ["png"],
356
+ ".mp4": ["mp4"]
357
+ };
358
+ async function G(r, e) {
359
+ if (!e || e.trim() === "") return !0;
360
+ const s = await r.slice(0, 32).arrayBuffer(), i = new Uint8Array(s), o = e.toLowerCase().split(",").map((d) => d.trim()), a = /* @__PURE__ */ new Set();
361
+ for (const d of o)
362
+ if (z[d])
363
+ for (const m of z[d])
364
+ a.add(m);
365
+ o.some((d) => d.startsWith("image/")) && (a.add("png"), a.add("jpg")), o.some((d) => d.startsWith("video/")) && a.add("mp4");
366
+ for (const d of a) {
367
+ const m = K[d];
368
+ if (m && W(i, m)) return !0;
369
+ }
370
+ return a.size === 0;
371
+ }
372
+ const J = D`
373
+ :host {
374
+ /* Global Fileinput Styles */
375
+ --_nys-fileinput-gap: var(--nys-space-100, 8px);
376
+
377
+ /* Typography */
378
+ --_nys-fileinput-font-size: var(--nys-font-size-ui-md, 16px);
379
+ --_nys-fileinput-font-weight: var(--nys-font-weight-semibold, 600);
380
+ --_nys-fileinput-line-height: var(--nys-font-lineheight-ui-md, 24px);
381
+ --_nys-fileinput-font-family: var(
382
+ --nys-font-family-ui,
383
+ var(
384
+ --nys-font-family-sans,
385
+ "Proxima Nova",
386
+ "Helvetica Neue",
387
+ "Helvetica",
388
+ "Arial",
389
+ sans-serif
390
+ )
391
+ );
392
+
393
+ /* Dropzone */
394
+ --_nys-fileinput-dropzone-background: var(--nys-color-ink-reverse, #fff);
395
+ --_nys-fileinput-dropzone-radius: var(
396
+ --nys-radius-lg,
397
+ var(--nys-space-100, 8px)
398
+ );
399
+ --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) dashed
400
+ var(--nys-color-neutral-300, #a7a9ab);
401
+ --_nys-fileinput-dropzone-color: var(--nys-color-text-disabled, #bec0c1);
402
+ }
403
+
404
+ .nys-fileinput {
405
+ display: flex;
406
+ flex-direction: column;
407
+ align-items: flex-start;
408
+ justify-content: center;
409
+ gap: var(--_nys-fileinput-gap);
410
+ font-family: var(--_nys-fileinput-font-family);
411
+ font-size: var(--_nys-fileinput-font-size);
412
+ font-weight: var(--_nys-fileinput-font-weight);
413
+ line-height: var(--_nys-fileinput-line-height);
414
+ }
415
+ :host([width="lg"]) .nys-fileinput {
416
+ max-width: var(--nys-form-width-lg, 384px);
417
+ }
418
+
419
+ ul {
420
+ list-style-type: none;
421
+ padding: 0px;
422
+ margin: 0px;
423
+ width: 100%;
424
+ display: flex;
425
+ flex-direction: column;
426
+ gap: var(--_nys-fileinput-gap);
427
+ }
428
+
429
+ /***** Dragzone *****/
430
+ .nys-fileinput__dropzone {
431
+ display: flex;
432
+ padding: var(--nys-space-400, 32px) var(--nys-space-200, 16px);
433
+ justify-content: center;
434
+ align-items: center;
435
+ gap: 12px;
436
+ align-self: stretch;
437
+ border-radius: var(--_nys-fileinput-dropzone-radius);
438
+ border: var(--_nys-fileinput-dropzone-border);
439
+ background: var(--_nys-fileinput-dropzone-background);
440
+ }
441
+
442
+ .nys-fileinput__dropzone:hover {
443
+ cursor: pointer;
444
+ --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) dashed
445
+ var(--nys-color-neutral-900, #1b1b1b);
446
+ }
447
+
448
+ .nys-fileinput__dropzone.drag-active {
449
+ --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) solid
450
+ var(--nys-color-neutral-900, #1b1b1b);
451
+ --_nys-fileinput-dropzone-background: var(--nys-color-theme-faint, #f7fafd);
452
+ }
453
+
454
+ .nys-fileinput__dropzone.error {
455
+ --_nys-fileinput-dropzone-border: var(--nys-border-width-md, 2px) dashed
456
+ var(--nys-color-danger, #b52c2c);
457
+ }
458
+
459
+ .nys-fileinput__dropzone.disabled {
460
+ cursor: not-allowed;
461
+ --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) dashed
462
+ var(--nys-color-neutral-300, #a7a9ab);
463
+ --_nys-fileinput-dropzone-background: var(--nys-color-neutral-10, #f6f6f6);
464
+ color: var(--_nys-fileinput-dropzone-color);
465
+ }
466
+
467
+ progress {
468
+ display: flex;
469
+ width: 100%;
470
+ height: 6px;
471
+ border-radius: var(--nys-radius-round, 1776px);
472
+ background: var(--_nys-fileinput-progress-background);
473
+ overflow: hidden;
474
+ appearance: none;
475
+ border: none;
476
+ }
477
+ progress::-moz-progress-bar {
478
+ background: var(--_nys-fileinput-progress-background);
479
+ }
480
+ progress::-webkit-progress-value {
481
+ background: var(--_nys-fileinput-progress-background);
482
+ }
483
+ progress::-webkit-progress-bar {
484
+ background: var(--_nys-fileinput-progress-background);
485
+ }
486
+ `, Q = D`
487
+ :host {
488
+ /* Global fileitem Styles */
489
+ --_nys-fileitem-items-radius: var(--nys-radius-md, 4px);
490
+ --_nys-fileitem-items-padding: var(--nys-space-100, 8px)
491
+ var(--nys-space-200, 16px);
492
+ --_nys-fileitem-items-border: var(--nys-border-width-sm, 1px) solid
493
+ var(--nys-color-neutral-100, #d0d0ce);
494
+ --_nys-fileitem-error-color: var(--nys-color-danger, #b52c2c);
495
+
496
+ /* Typography */
497
+ --_nys-fileitem-font-family: var(
498
+ --nys-font-family-ui,
499
+ var(
500
+ --nys-font-family-sans,
501
+ "Proxima Nova",
502
+ "Helvetica Neue",
503
+ "Helvetica",
504
+ "Arial",
505
+ sans-serif
506
+ )
507
+ );
508
+ --_nys-fileitem-font-size: var(--nys-font-size-ui-md, 16px);
509
+ --_nys-fileitem-font-weight-400: var(--nys-font-weight-regular, 400);
510
+ --_nys-fileitem-line-height: var(--nys-font-lineheight-ui-md, 24px);
511
+ --_nys-fileitem-letterspacing: var(--nys-font-letterspacing-ui-md, 0.044px);
512
+
513
+ /* Progress Bar */
514
+ --_nys-fileitem-progress-background: var(--nys-color-neutral-50, #ededed);
515
+ --_nys-fileitem-progress-fill-background: var(--nys-color-info, #004dd1);
516
+ }
517
+
518
+ /***** File List Item *****/
519
+ .file-item {
520
+ position: relative;
521
+ border-radius: var(--_nys-fileitem-items-radius);
522
+ border: var(--_nys-fileitem-items-border);
523
+ }
524
+
525
+ .file-item.error {
526
+ --_nys-fileitem-items-border: var(--nys-border-width-sm, 1px) solid
527
+ var(--nys-color-danger, #b52c2c);
528
+ }
529
+
530
+ .file-item__main {
531
+ display: flex;
532
+ justify-items: center;
533
+ align-items: center;
534
+ gap: var(--_nys-fileinput-gap);
535
+ padding: var(--_nys-fileitem-items-padding);
536
+ height: 56px;
537
+ box-sizing: border-box;
538
+ }
539
+
540
+ .file-item__info {
541
+ display: flex;
542
+ flex-direction: column;
543
+ width: 100%;
544
+ font-family: var(--_nys-fileitem-font-family);
545
+ font-size: var(--_nys-fileitem-font-size);
546
+ font-style: normal;
547
+ font-weight: var(--_nys-fileitem-font-weight-400);
548
+ line-height: var(--_nys-fileitem-line-height);
549
+ letter-spacing: var(--_nys-fileitem-letterspacing);
550
+ }
551
+
552
+ .file-item p {
553
+ margin: 0;
554
+ }
555
+
556
+ .error-msg {
557
+ color: var(--_nys-fileitem-error-color);
558
+ text-overflow: ellipsis;
559
+ }
560
+
561
+ /**** Progress Bar ****/
562
+ progress {
563
+ position: absolute;
564
+ bottom: 0;
565
+ display: flex;
566
+ width: 100%;
567
+ height: 6px;
568
+ border-radius: var(--nys-radius-round, 1776px);
569
+ background: var(--_nys-fileitem-progress-fill-background);
570
+ overflow: hidden;
571
+ appearance: none;
572
+ }
573
+ /* Track */
574
+ progress::-moz-progress-bar {
575
+ background: var(--_nys-fileitem-progress-background);
576
+ }
577
+ /* Filled value (the blue bar) */
578
+ progress::-webkit-progress-value {
579
+ background: var(--_nys-fileitem-progress-fill-background);
580
+ }
581
+ /* Firefox */
582
+ progress::-webkit-progress-bar {
583
+ background: var(--_nys-fileitem-progress-background);
584
+ }
585
+
586
+ /**** Icon ****/
587
+ .file-icon[name="progress_activity"] {
588
+ animation: spin 1s linear infinite;
589
+ }
590
+
591
+ .file-icon[name="error"] {
592
+ color: var(--_nys-fileitem-error-color);
593
+ }
594
+
595
+ @keyframes spin {
596
+ 0% {
597
+ transform: rotate(0deg);
598
+ }
599
+ 100% {
600
+ transform: rotate(360deg);
601
+ }
602
+ }
603
+ `;
604
+ var X = Object.defineProperty, $ = (r, e, t, s) => {
605
+ for (var i = void 0, n = r.length - 1, o; n >= 0; n--)
606
+ (o = r[n]) && (i = o(e, t, i) || i);
607
+ return i && X(e, t, i), i;
608
+ };
609
+ const x = class x extends F {
610
+ constructor() {
611
+ super(...arguments), this.filename = "", this.status = "pending", this.progress = 0, this.errorMessage = "";
612
+ }
613
+ _handleRemove() {
614
+ this.dispatchEvent(
615
+ new CustomEvent("nys-fileRemove", {
616
+ detail: { filename: this.filename },
617
+ bubbles: !0,
618
+ composed: !0
619
+ })
620
+ );
621
+ }
622
+ truncateFilename(e) {
623
+ const t = e.lastIndexOf(".");
624
+ if (t === -1)
625
+ return e.length > 30 ? e.slice(0, 30) + "..." : e;
626
+ const s = e.slice(t), i = e.slice(0, t), n = 30;
627
+ if (i.length <= n)
628
+ return e;
629
+ const o = i.slice(0, n - 3), a = i.slice(-3);
630
+ return `${o}...${a}${s}`;
631
+ }
632
+ render() {
633
+ return c`
634
+ <div class="file-item ${this.status}">
635
+ <div class="file-item__main" role="group" aria-label="Filename: ${this.filename}">
636
+ <nys-icon
637
+ class="file-icon"
638
+ name=${this.status === "processing" ? "progress_activity" : this.status === "error" ? "error" : "attach_file"}
639
+ size="2xl"
640
+ ></nys-icon>
641
+ <div class="file-item__info">
642
+ <p">
643
+ ${this.truncateFilename(this.filename)}
644
+ </p>
645
+ ${this.errorMessage ? c`<p
646
+ class="error-msg"
647
+ role="alert"
648
+ aria-live="assertive"
649
+ id="${this.filename}-error"
650
+ >
651
+ ${this.errorMessage}
652
+ </p>` : null}
653
+ </div>
654
+ <nys-button
655
+ circle
656
+ icon="close"
657
+ ariaLabel="close button"
658
+ size="sm"
659
+ variant="ghost"
660
+ .onClick=${() => this._handleRemove()}
661
+ ></nys-button>
662
+ </div>
663
+ ${this.status === "processing" ? c`<div
664
+ class="progress-container"
665
+ role="progressbar"
666
+ aria-valuemin="0"
667
+ aria-valuemax="100"
668
+ aria-valuenow="${this.progress}"
669
+ aria-label="Upload progress for ${this.filename}"
670
+ >
671
+ <progress value=${this.progress} max="100"></progress>
672
+ </div>` : null}
673
+ </div>
674
+ `;
675
+ }
676
+ };
677
+ x.styles = Q;
678
+ let f = x;
679
+ $([
680
+ l({ type: String })
681
+ ], f.prototype, "filename");
682
+ $([
683
+ l({ type: String })
684
+ ], f.prototype, "status");
685
+ $([
686
+ l({ type: Number })
687
+ ], f.prototype, "progress");
688
+ $([
689
+ l({ type: String })
690
+ ], f.prototype, "errorMessage");
691
+ customElements.define("nys-fileitem", f);
692
+ var Y = Object.defineProperty, h = (r, e, t, s) => {
693
+ for (var i = void 0, n = r.length - 1, o; n >= 0; n--)
694
+ (o = r[n]) && (i = o(e, t, i) || i);
695
+ return i && Y(e, t, i), i;
696
+ };
697
+ let Z = 0;
698
+ const b = class b extends F {
699
+ // allows use of elementInternals' API
700
+ constructor() {
701
+ super(), this.id = "", this.name = "", this.label = "", this.description = "", this.multiple = !1, this.accept = "", this.disabled = !1, this.required = !1, this.optional = !1, this.showError = !1, this.errorMessage = "", this.dropzone = !1, this.width = "full", this._selectedFiles = [], this._dragActive = !1, this._internals = this.attachInternals();
702
+ }
703
+ get _isDropDisabled() {
704
+ return this.disabled || !this.multiple && this._selectedFiles.length > 0;
705
+ }
706
+ // Generate a unique ID if one is not provided
707
+ connectedCallback() {
708
+ super.connectedCallback(), this.id || (this.id = `nys-fileinput-${Date.now()}-${Z++}`), this.addEventListener("invalid", this._handleInvalid);
709
+ }
710
+ disconnectedCallback() {
711
+ super.disconnectedCallback(), this.removeEventListener("invalid", this._handleInvalid);
712
+ }
713
+ firstUpdated() {
714
+ this._setValue();
715
+ }
716
+ /********************** Form Integration **********************/
717
+ _setValue() {
718
+ var e;
719
+ if (this.multiple) {
720
+ const t = this._selectedFiles.map((s) => s.file);
721
+ if (t.length > 0) {
722
+ const s = new FormData();
723
+ t.forEach((i) => {
724
+ s.append(this.name, i);
725
+ }), this._internals.setFormValue(s);
726
+ } else
727
+ this._internals.setFormValue(null);
728
+ } else {
729
+ const t = ((e = this._selectedFiles[0]) == null ? void 0 : e.file) || null;
730
+ this._internals.setFormValue(t);
731
+ }
732
+ this._manageRequire();
733
+ }
734
+ // Called to internally set the initial internalElement required flag.
735
+ _manageRequire() {
736
+ var i;
737
+ const e = (i = this.shadowRoot) == null ? void 0 : i.querySelector("input");
738
+ if (!e) return;
739
+ const t = this.errorMessage || "Please upload a file.";
740
+ this.required && this._selectedFiles.length == 0 ? (this._internals.ariaRequired = "true", this._internals.setValidity({ valueMissing: !0 }, t, e)) : (this._internals.ariaRequired = "false", this._internals.setValidity({}));
741
+ }
742
+ _setValidityMessage(e = "") {
743
+ var s, i;
744
+ const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector("input");
745
+ t && (this.showError = e === (this.errorMessage || "Please upload a file."), (i = this.errorMessage) != null && i.trim() && e !== "" && (e = this.errorMessage), this._internals.setValidity(
746
+ e ? { customError: !0 } : {},
747
+ e,
748
+ t
749
+ ));
750
+ }
751
+ _validate() {
752
+ const e = this._selectedFiles.some(
753
+ (i) => i.status === "error"
754
+ ), t = this.required && this._selectedFiles.length === 0;
755
+ let s = "";
756
+ t ? s = this.errorMessage || "Please upload a file." : e && (s = "One or more files are invalid."), this._setValidityMessage(s);
757
+ }
758
+ /******************** Functions ********************/
759
+ // Store the files to be displayed
760
+ async _saveSelectedFiles(e) {
761
+ if (this._selectedFiles.some(
762
+ (i) => i.file.name == e.name
763
+ ) || !this.multiple && this._selectedFiles.length >= 1) return;
764
+ const s = {
765
+ file: e,
766
+ progress: 0,
767
+ status: "pending"
768
+ };
769
+ this._selectedFiles.push(s), await this._processFile(s), this._setValue(), this._validate();
770
+ }
771
+ // Read the contents of stored files, this will indicate loading progress of the uploaded files
772
+ async _processFile(e) {
773
+ e.status = "processing";
774
+ try {
775
+ if (!await G(e.file, this.accept)) {
776
+ e.status = "error", e.errorMsg = "File format does not match expected type.", this.requestUpdate();
777
+ return;
778
+ }
779
+ const s = new FileReader();
780
+ s.onprogress = (i) => {
781
+ if (i.lengthComputable) {
782
+ const n = Math.round(i.loaded * 100 / i.total);
783
+ e.progress = n, this.requestUpdate();
784
+ }
785
+ }, s.onload = () => {
786
+ e.progress = 100, e.status = "done", this.requestUpdate();
787
+ }, s.onerror = () => {
788
+ e.status = "error", e.errorMsg = "Failed to load file.", this.requestUpdate();
789
+ }, s.readAsArrayBuffer(e.file);
790
+ } catch {
791
+ e.status = "error", e.errorMsg = "Error validating file.", this.requestUpdate();
792
+ }
793
+ }
794
+ _dispatchChangeEvent() {
795
+ this.dispatchEvent(
796
+ new CustomEvent("nys-change", {
797
+ detail: { files: this._selectedFiles },
798
+ bubbles: !0,
799
+ composed: !0
800
+ })
801
+ );
802
+ }
803
+ _openFileDialog() {
804
+ const e = this.renderRoot.querySelector(
805
+ ".hidden-file-input"
806
+ );
807
+ e == null || e.click();
808
+ }
809
+ /******************** Event Handlers ********************/
810
+ // Access the selected files & add new files to the internal list via the hidden <input type="file">
811
+ _handleFileChange(e) {
812
+ const t = e.target, s = t.files;
813
+ (s ? Array.from(s) : []).map((n) => {
814
+ this._saveSelectedFiles(n);
815
+ }), t.value = "", this.requestUpdate(), this._dispatchChangeEvent();
816
+ }
817
+ _handleFileRemove(e) {
818
+ const t = e.detail.filename;
819
+ this._selectedFiles = this._selectedFiles.filter(
820
+ (s) => s.file.name !== t
821
+ ), this._setValue(), this._validate(), this.requestUpdate(), this._dispatchChangeEvent();
822
+ }
823
+ _onDragOver(e) {
824
+ this.disabled || (e.stopPropagation(), e.preventDefault(), this._dragActive || (this._dragActive = !0, this.requestUpdate()));
825
+ }
826
+ // Mostly used for styling purpose
827
+ _onDragLeave(e) {
828
+ this.disabled || (e.stopPropagation(), e.preventDefault(), e.currentTarget === e.target && (this._dragActive = !1, this.requestUpdate()));
829
+ }
830
+ _onDrop(e) {
831
+ var i;
832
+ if (this.disabled) return;
833
+ e.preventDefault(), this._dragActive = !1, this.requestUpdate();
834
+ const t = (i = e.dataTransfer) == null ? void 0 : i.files;
835
+ if (!t) return;
836
+ const s = Array.from(t);
837
+ this.multiple ? s.forEach((n) => {
838
+ this._saveSelectedFiles(n);
839
+ }) : this._saveSelectedFiles(s[0]), this.requestUpdate(), this._dispatchChangeEvent();
840
+ }
841
+ _handleInvalid(e) {
842
+ var s;
843
+ e.preventDefault(), this._validate();
844
+ const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector("input");
845
+ if (t) {
846
+ const i = this._internals.form;
847
+ i ? Array.from(i.elements).find(
848
+ (a) => typeof a.checkValidity == "function" && !a.checkValidity()
849
+ ) === this && t.focus() : t.focus();
850
+ }
851
+ }
852
+ render() {
853
+ return c`<div
854
+ class="nys-fileinput"
855
+ @nys-fileRemove=${this._handleFileRemove}
856
+ >
857
+ <nys-label
858
+ id=${this.id}
859
+ label=${this.label}
860
+ description=${this.description}
861
+ flag=${this.required ? "required" : this.optional ? "optional" : ""}
862
+ >
863
+ <slot name="description" slot="description">${this.description}</slot>
864
+ </nys-label>
865
+
866
+ <input
867
+ id=${this.id}
868
+ class="hidden-file-input"
869
+ type="file"
870
+ name=${this.name}
871
+ ?multiple=${this.multiple}
872
+ accept=${this.accept}
873
+ ?required=${this.required}
874
+ ?disabled=${this.disabled || !this.multiple && this._selectedFiles.length > 0}
875
+ aria-disabled="${this.disabled}"
876
+ aria-label="Drag files here or choose from folder"
877
+ aria-describedby="file-input-specific-hint"
878
+ style="position: absolute; width: 1px; height: 1px; opacity: 0;"
879
+ @change=${this._handleFileChange}
880
+ />
881
+
882
+ ${this.dropzone ? c`<div
883
+ class="nys-fileinput__dropzone
884
+ ${this._dragActive ? "drag-active" : ""}
885
+ ${this._isDropDisabled ? "disabled" : ""}
886
+ ${this.showError && !this._isDropDisabled ? "error" : ""}"
887
+ @click=${this._isDropDisabled ? null : this._openFileDialog}
888
+ @keydown=${(e) => !this._isDropDisabled && (e.key === "Enter" || e.key === " ") && this._openFileDialog()}
889
+ @dragover=${this._isDropDisabled ? null : this._onDragOver}
890
+ @dragleave=${this._isDropDisabled ? null : this._onDragLeave}
891
+ @drop=${this._isDropDisabled ? null : this._onDrop}
892
+ >
893
+ ${this._dragActive ? c`<p>Drop file to upload</p>` : c` <nys-button
894
+ id="file-btn"
895
+ name="file-btn"
896
+ label=${this.multiple ? "Choose files" : "Choose file"}
897
+ variant="outline"
898
+ ?disabled=${this._isDropDisabled}
899
+ .onClick=${(e) => {
900
+ e.stopPropagation(), this._openFileDialog();
901
+ }}
902
+ ></nys-button>
903
+ <p>or drag here</p>`}
904
+ </div>` : c`<nys-button
905
+ id="file-btn"
906
+ name="file-btn"
907
+ label=${this.multiple ? "Choose files" : "Choose file"}
908
+ variant="outline"
909
+ ?disabled=${this.disabled || !this.multiple && this._selectedFiles.length > 0}
910
+ .onClick=${() => this._openFileDialog()}
911
+ ></nys-button>`}
912
+ ${this.showError ? c`
913
+ <nys-errormessage
914
+ ?showError=${this.showError}
915
+ errorMessage=${this._internals.validationMessage || this.errorMessage}
916
+ ></nys-errormessage>
917
+ ` : null}
918
+ ${this._selectedFiles.length > 0 ? c`
919
+ <ul>
920
+ ${this._selectedFiles.map(
921
+ (e) => c`<li>
922
+ <nys-fileitem
923
+ filename=${e.file.name}
924
+ status=${e.status}
925
+ progress=${e.progress}
926
+ errorMessage=${e.errorMsg || ""}
927
+ ></nys-fileitem>
928
+ </li>`
929
+ )}
930
+ </ul>
931
+ ` : null}
932
+ </div>`;
933
+ }
934
+ };
935
+ b.styles = J, b.formAssociated = !0;
936
+ let p = b;
937
+ h([
938
+ l({ type: String })
939
+ ], p.prototype, "id");
940
+ h([
941
+ l({ type: String, reflect: !0 })
942
+ ], p.prototype, "name");
943
+ h([
944
+ l({ type: String })
945
+ ], p.prototype, "label");
946
+ h([
947
+ l({ type: String })
948
+ ], p.prototype, "description");
949
+ h([
950
+ l({ type: Boolean })
951
+ ], p.prototype, "multiple");
952
+ h([
953
+ l({ type: String })
954
+ ], p.prototype, "accept");
955
+ h([
956
+ l({ type: Boolean, reflect: !0 })
957
+ ], p.prototype, "disabled");
958
+ h([
959
+ l({ type: Boolean, reflect: !0 })
960
+ ], p.prototype, "required");
961
+ h([
962
+ l({ type: Boolean, reflect: !0 })
963
+ ], p.prototype, "optional");
964
+ h([
965
+ l({ type: Boolean, reflect: !0 })
966
+ ], p.prototype, "showError");
967
+ h([
968
+ l({ type: String })
969
+ ], p.prototype, "errorMessage");
970
+ h([
971
+ l({ type: Boolean })
972
+ ], p.prototype, "dropzone");
973
+ h([
974
+ l({ type: String, reflect: !0 })
975
+ ], p.prototype, "width");
976
+ customElements.get("nys-fileinput") || customElements.define("nys-fileinput", p);
977
+ export {
978
+ p as NysFileinput
979
+ };
980
+ //# sourceMappingURL=nys-fileinput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nys-fileinput.js","sources":["../../../node_modules/@lit/reactive-element/css-tag.js","../../../node_modules/@lit/reactive-element/reactive-element.js","../../../node_modules/@lit/reactive-element/decorators/property.js","../src/validateFileHeader.ts","../src/nys-fileinput.styles.ts","../src/nys-fileitem.styles.ts","../src/nys-fileitem.ts","../src/nys-fileinput.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&\"adoptedStyleSheets\"in Document.prototype&&\"replace\"in CSSStyleSheet.prototype,s=Symbol(),o=new WeakMap;class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s)throw Error(\"CSSResult is not constructable. Use `unsafeCSS` or `css` instead.\");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o.set(s,t))}return t}toString(){return this.cssText}}const r=t=>new n(\"string\"==typeof t?t:t+\"\",void 0,s),i=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if(\"number\"==typeof t)return t;throw Error(\"Value passed to 'css' function must be a 'css' function result: \"+t+\". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.\")})(s)+t[o+1]),t[0]);return new n(o,t,s)},S=(s,o)=>{if(e)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement(\"style\"),n=t.litNonce;void 0!==n&&o.setAttribute(\"nonce\",n),o.textContent=e.cssText,s.appendChild(o)}},c=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e=\"\";for(const s of t.cssRules)e+=s.cssText;return r(e)})(t):t;export{n as CSSResult,S as adoptStyles,i as css,c as getCompatibleStyle,e as supportsAdoptingStyleSheets,r as unsafeCSS};\n//# sourceMappingURL=css-tag.js.map\n","import{getCompatibleStyle as t,adoptStyles as s}from\"./css-tag.js\";export{CSSResult,adoptStyles,css,getCompatibleStyle,supportsAdoptingStyleSheets,unsafeCSS}from\"./css-tag.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{is:i,defineProperty:e,getOwnPropertyDescriptor:r,getOwnPropertyNames:h,getOwnPropertySymbols:o,getPrototypeOf:n}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:\"\",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},f=(t,s)=>!i(t,s),y={attribute:!0,type:String,converter:u,reflect:!1,hasChanged:f};Symbol.metadata??=Symbol(\"metadata\"),a.litPropertyMetadata??=new WeakMap;class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e(this.prototype,t,r)}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t}};return{get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y}static _$Ei(){if(this.hasOwnProperty(d(\"elementProperties\")))return;const t=n(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(d(\"finalized\")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d(\"properties\"))){const t=this.properties,s=[...h(t),...o(t)];for(const i of s)this.createProperty(i,t[i])}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i)}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(t(s))}else void 0!==s&&i.push(t(s));return i}static _$Eu(t,s){const i=s.attribute;return!1===i?void 0:\"string\"==typeof i?i:\"string\"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return s(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,s,i){this._$AK(t,i)}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r=\"function\"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f)(this[t],s))return;this.P(t,s,i)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i)}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}}b.elementStyles=[],b.shadowRootOptions={mode:\"open\"},b[d(\"elementProperties\")]=new Map,b[d(\"finalized\")]=new Map,p?.({ReactiveElement:b}),(a.reactiveElementVersions??=[]).push(\"2.0.4\");export{b as ReactiveElement,u as defaultConverter,f as notEqual};\n//# sourceMappingURL=reactive-element.js.map\n","import{defaultConverter as t,notEqual as e}from\"../reactive-element.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const o={attribute:!0,type:String,converter:t,reflect:!1,hasChanged:e},r=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),s.set(r.name,t),\"accessor\"===n){const{name:o}=r;return{set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t)},init(e){return void 0!==e&&this.P(o,void 0,t),e}}}if(\"setter\"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t)}}throw Error(\"Unsupported decorator location: \"+n)};function n(t){return(e,o)=>\"object\"==typeof o?r(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,r?{...t,wrapped:!0}:t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}export{n as property,r as standardProperty};\n//# sourceMappingURL=property.js.map\n","/*\n * Validates a file's true format by inspecting its header (magic number).\n * Rejects files whose extension or \"accept\" type you expect, but whose header does NOT match.\n */\nconst magicNumbers: Record<\n string,\n number[] | ((header: Uint8Array) => boolean)\n> = {\n png: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a],\n jpg: (header) => {\n return (\n header.length >= 4 &&\n header[0] === 0xff &&\n header[1] === 0xd8 &&\n header[2] === 0xff &&\n [0xe0, 0xe1, 0xdb].includes(header[3])\n );\n },\n pdf: (header) => {\n let i = 0;\n while (i < header.length && [0x20, 0x0a, 0x0d].includes(header[i])) {\n i++;\n }\n return (\n header[i] === 0x25 &&\n header[i + 1] === 0x50 &&\n header[i + 2] === 0x44 &&\n header[i + 3] === 0x46\n );\n },\n gif: [0x47, 0x49, 0x46, 0x38],\n mp4: (header) => {\n const ftyp = [0x66, 0x74, 0x79, 0x70];\n for (let i = 0; i <= header.length - ftyp.length; i++) {\n let match = true;\n for (let j = 0; j < ftyp.length; j++) {\n if (header[i + j] !== ftyp[j]) {\n match = false;\n break;\n }\n }\n if (match) return true;\n }\n return false;\n },\n};\n\nfunction matchesMagic(\n header: Uint8Array,\n magic: number[] | ((h: Uint8Array) => boolean),\n): boolean {\n if (typeof magic === \"function\") return magic(header);\n if (header.length < magic.length) return false;\n for (let i = 0; i < magic.length; i++) {\n if (header[i] !== magic[i]) return false;\n }\n return true;\n}\n\n// Map of file type aliases\nconst acceptKeyMap: Record<string, string[]> = {\n \"image/png\": [\"png\"],\n \"image/jpeg\": [\"jpg\"],\n \"image/jpg\": [\"jpg\"],\n \"image/*\": [\"png\", \"jpg\", \"gif\"],\n \"video/mp4\": [\"mp4\"],\n \"video/*\": [\"mp4\"],\n \"application/pdf\": [\"pdf\"],\n \".pdf\": [\"pdf\"],\n \".jpg\": [\"jpg\"],\n \".jpeg\": [\"jpg\"],\n \".png\": [\"png\"],\n \".mp4\": [\"mp4\"],\n};\n\nexport async function validateFileHeader(\n file: File,\n accept: string,\n): Promise<boolean> {\n if (!accept || accept.trim() === \"\") return true;\n\n const blob = file.slice(0, 32); // Read first 32 bytes for wider coverage\n const buffer = await blob.arrayBuffer();\n const header = new Uint8Array(buffer);\n\n const acceptLower = accept.toLowerCase();\n const acceptItems = acceptLower.split(\",\").map((a) => a.trim());\n\n const acceptedKeys = new Set<string>();\n\n for (const item of acceptItems) {\n if (acceptKeyMap[item]) {\n for (const key of acceptKeyMap[item]) {\n acceptedKeys.add(key);\n }\n }\n }\n\n // Support wildcards and fallback logic\n if (acceptItems.some((a) => a.startsWith(\"image/\"))) {\n acceptedKeys.add(\"png\");\n acceptedKeys.add(\"jpg\");\n }\n if (acceptItems.some((a) => a.startsWith(\"video/\"))) {\n acceptedKeys.add(\"mp4\");\n }\n\n for (const key of acceptedKeys) {\n const magic = magicNumbers[key];\n if (magic && matchesMagic(header, magic)) return true;\n }\n\n return acceptedKeys.size === 0; // If nothing matched but accept was vague (like unknown ext), fallback\n}\n","import { css } from \"lit\";\n\nexport default css`\n :host {\n /* Global Fileinput Styles */\n --_nys-fileinput-gap: var(--nys-space-100, 8px);\n\n /* Typography */\n --_nys-fileinput-font-size: var(--nys-font-size-ui-md, 16px);\n --_nys-fileinput-font-weight: var(--nys-font-weight-semibold, 600);\n --_nys-fileinput-line-height: var(--nys-font-lineheight-ui-md, 24px);\n --_nys-fileinput-font-family: var(\n --nys-font-family-ui,\n var(\n --nys-font-family-sans,\n \"Proxima Nova\",\n \"Helvetica Neue\",\n \"Helvetica\",\n \"Arial\",\n sans-serif\n )\n );\n\n /* Dropzone */\n --_nys-fileinput-dropzone-background: var(--nys-color-ink-reverse, #fff);\n --_nys-fileinput-dropzone-radius: var(\n --nys-radius-lg,\n var(--nys-space-100, 8px)\n );\n --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) dashed\n var(--nys-color-neutral-300, #a7a9ab);\n --_nys-fileinput-dropzone-color: var(--nys-color-text-disabled, #bec0c1);\n }\n\n .nys-fileinput {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n gap: var(--_nys-fileinput-gap);\n font-family: var(--_nys-fileinput-font-family);\n font-size: var(--_nys-fileinput-font-size);\n font-weight: var(--_nys-fileinput-font-weight);\n line-height: var(--_nys-fileinput-line-height);\n }\n :host([width=\"lg\"]) .nys-fileinput {\n max-width: var(--nys-form-width-lg, 384px);\n }\n\n ul {\n list-style-type: none;\n padding: 0px;\n margin: 0px;\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: var(--_nys-fileinput-gap);\n }\n\n /***** Dragzone *****/\n .nys-fileinput__dropzone {\n display: flex;\n padding: var(--nys-space-400, 32px) var(--nys-space-200, 16px);\n justify-content: center;\n align-items: center;\n gap: 12px;\n align-self: stretch;\n border-radius: var(--_nys-fileinput-dropzone-radius);\n border: var(--_nys-fileinput-dropzone-border);\n background: var(--_nys-fileinput-dropzone-background);\n }\n\n .nys-fileinput__dropzone:hover {\n cursor: pointer;\n --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) dashed\n var(--nys-color-neutral-900, #1b1b1b);\n }\n\n .nys-fileinput__dropzone.drag-active {\n --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) solid\n var(--nys-color-neutral-900, #1b1b1b);\n --_nys-fileinput-dropzone-background: var(--nys-color-theme-faint, #f7fafd);\n }\n\n .nys-fileinput__dropzone.error {\n --_nys-fileinput-dropzone-border: var(--nys-border-width-md, 2px) dashed\n var(--nys-color-danger, #b52c2c);\n }\n\n .nys-fileinput__dropzone.disabled {\n cursor: not-allowed;\n --_nys-fileinput-dropzone-border: var(--nys-border-width-sm, 1px) dashed\n var(--nys-color-neutral-300, #a7a9ab);\n --_nys-fileinput-dropzone-background: var(--nys-color-neutral-10, #f6f6f6);\n color: var(--_nys-fileinput-dropzone-color);\n }\n\n progress {\n display: flex;\n width: 100%;\n height: 6px;\n border-radius: var(--nys-radius-round, 1776px);\n background: var(--_nys-fileinput-progress-background);\n overflow: hidden;\n appearance: none;\n border: none;\n }\n progress::-moz-progress-bar {\n background: var(--_nys-fileinput-progress-background);\n }\n progress::-webkit-progress-value {\n background: var(--_nys-fileinput-progress-background);\n }\n progress::-webkit-progress-bar {\n background: var(--_nys-fileinput-progress-background);\n }\n`;\n","import { css } from \"lit\";\n\nexport default css`\n :host {\n /* Global fileitem Styles */\n --_nys-fileitem-items-radius: var(--nys-radius-md, 4px);\n --_nys-fileitem-items-padding: var(--nys-space-100, 8px)\n var(--nys-space-200, 16px);\n --_nys-fileitem-items-border: var(--nys-border-width-sm, 1px) solid\n var(--nys-color-neutral-100, #d0d0ce);\n --_nys-fileitem-error-color: var(--nys-color-danger, #b52c2c);\n\n /* Typography */\n --_nys-fileitem-font-family: var(\n --nys-font-family-ui,\n var(\n --nys-font-family-sans,\n \"Proxima Nova\",\n \"Helvetica Neue\",\n \"Helvetica\",\n \"Arial\",\n sans-serif\n )\n );\n --_nys-fileitem-font-size: var(--nys-font-size-ui-md, 16px);\n --_nys-fileitem-font-weight-400: var(--nys-font-weight-regular, 400);\n --_nys-fileitem-line-height: var(--nys-font-lineheight-ui-md, 24px);\n --_nys-fileitem-letterspacing: var(--nys-font-letterspacing-ui-md, 0.044px);\n\n /* Progress Bar */\n --_nys-fileitem-progress-background: var(--nys-color-neutral-50, #ededed);\n --_nys-fileitem-progress-fill-background: var(--nys-color-info, #004dd1);\n }\n\n /***** File List Item *****/\n .file-item {\n position: relative;\n border-radius: var(--_nys-fileitem-items-radius);\n border: var(--_nys-fileitem-items-border);\n }\n\n .file-item.error {\n --_nys-fileitem-items-border: var(--nys-border-width-sm, 1px) solid\n var(--nys-color-danger, #b52c2c);\n }\n\n .file-item__main {\n display: flex;\n justify-items: center;\n align-items: center;\n gap: var(--_nys-fileinput-gap);\n padding: var(--_nys-fileitem-items-padding);\n height: 56px;\n box-sizing: border-box;\n }\n\n .file-item__info {\n display: flex;\n flex-direction: column;\n width: 100%;\n font-family: var(--_nys-fileitem-font-family);\n font-size: var(--_nys-fileitem-font-size);\n font-style: normal;\n font-weight: var(--_nys-fileitem-font-weight-400);\n line-height: var(--_nys-fileitem-line-height);\n letter-spacing: var(--_nys-fileitem-letterspacing);\n }\n\n .file-item p {\n margin: 0;\n }\n\n .error-msg {\n color: var(--_nys-fileitem-error-color);\n text-overflow: ellipsis;\n }\n\n /**** Progress Bar ****/\n progress {\n position: absolute;\n bottom: 0;\n display: flex;\n width: 100%;\n height: 6px;\n border-radius: var(--nys-radius-round, 1776px);\n background: var(--_nys-fileitem-progress-fill-background);\n overflow: hidden;\n appearance: none;\n }\n /* Track */\n progress::-moz-progress-bar {\n background: var(--_nys-fileitem-progress-background);\n }\n /* Filled value (the blue bar) */\n progress::-webkit-progress-value {\n background: var(--_nys-fileitem-progress-fill-background);\n }\n /* Firefox */\n progress::-webkit-progress-bar {\n background: var(--_nys-fileitem-progress-background);\n }\n\n /**** Icon ****/\n .file-icon[name=\"progress_activity\"] {\n animation: spin 1s linear infinite;\n }\n\n .file-icon[name=\"error\"] {\n color: var(--_nys-fileitem-error-color);\n }\n\n @keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n`;\n","import { LitElement, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport styles from \"./nys-fileitem.styles\";\n\nexport class NysFileItem extends LitElement {\n @property({ type: String }) filename = \"\";\n @property({ type: String }) status:\n | \"pending\"\n | \"processing\"\n | \"done\"\n | \"error\" = \"pending\";\n @property({ type: Number }) progress = 0;\n @property({ type: String }) errorMessage = \"\";\n\n static styles = styles;\n\n private _handleRemove() {\n this.dispatchEvent(\n new CustomEvent(\"nys-fileRemove\", {\n detail: { filename: this.filename },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private truncateFilename(filename: string): string {\n const lastDotIndex = filename.lastIndexOf(\".\");\n if (lastDotIndex === -1) {\n // No extension, truncate to max 30 chars + ellipsis if needed\n return filename.length > 30 ? filename.slice(0, 30) + \"...\" : filename;\n }\n\n const extension = filename.slice(lastDotIndex); // e.g. \".pdf\"\n const namePart = filename.slice(0, lastDotIndex);\n\n // Show at most 30 chars total in namePart (including last 3 chars before extension)\n const maxNameLength = 30;\n if (namePart.length <= maxNameLength) {\n return filename; // no truncation needed\n }\n\n const startPart = namePart.slice(0, maxNameLength - 3);\n const endPart = namePart.slice(-3);\n\n return `${startPart}...${endPart}${extension}`;\n }\n\n render() {\n return html`\n <div class=\"file-item ${this.status}\">\n <div class=\"file-item__main\" role=\"group\" aria-label=\"Filename: ${this.filename}\">\n <nys-icon\n class=\"file-icon\"\n name=${\n this.status === \"processing\"\n ? \"progress_activity\"\n : this.status === \"error\"\n ? \"error\"\n : \"attach_file\"\n }\n size=\"2xl\"\n ></nys-icon>\n <div class=\"file-item__info\">\n <p\">\n ${this.truncateFilename(this.filename)}\n </p>\n ${\n this.errorMessage\n ? html`<p\n class=\"error-msg\"\n role=\"alert\"\n aria-live=\"assertive\"\n id=\"${this.filename}-error\"\n >\n ${this.errorMessage}\n </p>`\n : null\n }\n </div>\n <nys-button\n circle\n icon=\"close\"\n ariaLabel=\"close button\"\n size=\"sm\"\n variant=\"ghost\"\n .onClick=${() => this._handleRemove()}\n ></nys-button>\n </div>\n ${\n this.status === \"processing\"\n ? html`<div\n class=\"progress-container\"\n role=\"progressbar\"\n aria-valuemin=\"0\"\n aria-valuemax=\"100\"\n aria-valuenow=\"${this.progress}\"\n aria-label=\"Upload progress for ${this.filename}\"\n >\n <progress value=${this.progress} max=\"100\"></progress>\n </div>`\n : null\n }\n </div>\n `;\n }\n}\n\ncustomElements.define(\"nys-fileitem\", NysFileItem);\n","import { LitElement, html } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport { validateFileHeader } from \"./validateFileHeader\";\nimport styles from \"./nys-fileinput.styles\";\nimport \"./nys-fileitem\";\n\nlet fileinputIdCounter = 0; // Counter for generating unique IDs\n\ninterface FileWithProgress {\n file: File;\n progress: number;\n status: \"pending\" | \"processing\" | \"done\" | \"error\";\n errorMsg?: string;\n}\n\nexport class NysFileinput extends LitElement {\n @property({ type: String }) id = \"\";\n @property({ type: String, reflect: true }) name = \"\";\n @property({ type: String }) label = \"\";\n @property({ type: String }) description = \"\";\n @property({ type: Boolean }) multiple = false;\n @property({ type: String }) accept = \"\"; // e.g. \"image/*,.pdf\"\n @property({ type: Boolean, reflect: true }) disabled = false;\n @property({ type: Boolean, reflect: true }) required = false;\n @property({ type: Boolean, reflect: true }) optional = false;\n @property({ type: Boolean, reflect: true }) showError = false;\n @property({ type: String }) errorMessage = \"\";\n @property({ type: Boolean }) dropzone = false;\n @property({ type: String, reflect: true }) width: \"lg\" | \"full\" = \"full\";\n\n static styles = styles;\n\n private _selectedFiles: FileWithProgress[] = [];\n private _dragActive = false;\n private get _isDropDisabled(): boolean {\n return this.disabled || (!this.multiple && this._selectedFiles.length > 0);\n }\n\n private _internals: ElementInternals;\n\n /********************** Lifecycle updates **********************/\n static formAssociated = true; // allows use of elementInternals' API\n\n constructor() {\n super();\n this._internals = this.attachInternals();\n }\n\n // Generate a unique ID if one is not provided\n connectedCallback() {\n super.connectedCallback();\n if (!this.id) {\n this.id = `nys-fileinput-${Date.now()}-${fileinputIdCounter++}`;\n }\n\n this.addEventListener(\"invalid\", this._handleInvalid);\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n this.removeEventListener(\"invalid\", this._handleInvalid);\n }\n\n firstUpdated() {\n // This ensures our element always participates in the form\n this._setValue();\n }\n\n /********************** Form Integration **********************/\n private _setValue() {\n // for multiple file uploads, we upload File object as an array\n if (this.multiple) {\n const files = this._selectedFiles.map((entry) => entry.file);\n\n if (files.length > 0) {\n const formData = new FormData();\n files.forEach((file) => {\n formData.append(this.name, file);\n });\n this._internals.setFormValue(formData);\n } else {\n this._internals.setFormValue(null);\n }\n } else {\n const singleFile = this._selectedFiles[0]?.file || null;\n this._internals.setFormValue(singleFile);\n }\n\n this._manageRequire(); // Check validation when value is set\n }\n\n // Called to internally set the initial internalElement required flag.\n private _manageRequire() {\n const input = this.shadowRoot?.querySelector(\"input\");\n if (!input) return;\n\n const message = this.errorMessage || \"Please upload a file.\";\n const isInvalid = this.required && this._selectedFiles.length == 0;\n\n if (isInvalid) {\n this._internals.ariaRequired = \"true\"; // Screen readers should announce error\n this._internals.setValidity({ valueMissing: true }, message, input);\n } else {\n this._internals.ariaRequired = \"false\"; // Reset when valid\n this._internals.setValidity({});\n }\n }\n\n private _setValidityMessage(message: string = \"\") {\n const input = this.shadowRoot?.querySelector(\"input\");\n if (!input) return;\n\n // Toggle the HTML <div> tag error message\n this.showError = message === (this.errorMessage || \"Please upload a file.\");\n // If user sets errorMessage, this will always override the native validation message\n if (this.errorMessage?.trim() && message !== \"\") {\n message = this.errorMessage;\n }\n\n this._internals.setValidity(\n message ? { customError: true } : {},\n message,\n input,\n );\n }\n\n private _validate() {\n const hasCorruptedFiles = this._selectedFiles.some(\n (entry) => entry.status === \"error\",\n );\n const isEmpty = this.required && this._selectedFiles.length === 0;\n\n let message = \"\";\n if (isEmpty) {\n message = this.errorMessage || \"Please upload a file.\";\n } else if (hasCorruptedFiles) {\n message = \"One or more files are invalid.\";\n }\n\n this._setValidityMessage(message);\n }\n\n /******************** Functions ********************/\n // Store the files to be displayed\n private async _saveSelectedFiles(file: File) {\n const isDuplicate = this._selectedFiles.some(\n (existingFile) => existingFile.file.name == file.name,\n );\n if (isDuplicate) return;\n\n if (!this.multiple && this._selectedFiles.length >= 1) return;\n\n const entry: FileWithProgress = {\n file,\n progress: 0,\n status: \"pending\",\n };\n\n this._selectedFiles.push(entry);\n await this._processFile(entry);\n\n // Now that the file is added, update form value and validation\n this._setValue();\n this._validate();\n }\n\n // Read the contents of stored files, this will indicate loading progress of the uploaded files\n private async _processFile(entry: FileWithProgress) {\n entry.status = \"processing\";\n\n try {\n const isValid = await validateFileHeader(entry.file, this.accept);\n if (!isValid) {\n entry.status = \"error\";\n entry.errorMsg = \"File format does not match expected type.\";\n this.requestUpdate();\n return;\n }\n\n const reader = new FileReader();\n\n reader.onprogress = (e) => {\n if (e.lengthComputable) {\n const percentage = Math.round((e.loaded * 100) / e.total);\n entry.progress = percentage;\n this.requestUpdate();\n }\n };\n\n reader.onload = () => {\n entry.progress = 100;\n entry.status = \"done\";\n this.requestUpdate();\n };\n\n reader.onerror = () => {\n entry.status = \"error\";\n entry.errorMsg = \"Failed to load file.\";\n this.requestUpdate();\n };\n\n reader.readAsArrayBuffer(entry.file);\n } catch {\n entry.status = \"error\";\n entry.errorMsg = \"Error validating file.\";\n this.requestUpdate();\n }\n }\n\n private _dispatchChangeEvent() {\n this.dispatchEvent(\n new CustomEvent(\"nys-change\", {\n detail: { files: this._selectedFiles },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private _openFileDialog() {\n const input = this.renderRoot.querySelector(\n \".hidden-file-input\",\n ) as HTMLInputElement;\n\n input?.click();\n }\n\n /******************** Event Handlers ********************/\n // Access the selected files & add new files to the internal list via the hidden <input type=\"file\">\n private _handleFileChange(e: Event) {\n const input = e.target as HTMLInputElement;\n const files = input.files;\n const newFiles = files ? Array.from(files) : []; // changes FileList to array\n\n // Store the uploaded files\n newFiles.map((file) => {\n this._saveSelectedFiles(file);\n });\n\n input.value = \"\";\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n }\n\n private _handleFileRemove(e: CustomEvent) {\n const filenameToRemove = e.detail.filename;\n\n // Remove selected files\n this._selectedFiles = this._selectedFiles.filter(\n (existingFile) => existingFile.file.name !== filenameToRemove,\n );\n this._setValue();\n this._validate();\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n }\n\n private _onDragOver(e: DragEvent) {\n if (this.disabled) return;\n\n e.stopPropagation();\n e.preventDefault();\n if (!this._dragActive) {\n this._dragActive = true; // For styling purpose\n this.requestUpdate();\n }\n }\n\n // Mostly used for styling purpose\n private _onDragLeave(e: DragEvent) {\n if (this.disabled) return;\n\n e.stopPropagation();\n e.preventDefault();\n // Only reset if leaving the dropzone itself (not children)\n if (e.currentTarget === e.target) {\n this._dragActive = false; // For styling purpose\n this.requestUpdate();\n }\n }\n\n private _onDrop(e: DragEvent) {\n if (this.disabled) return;\n\n e.preventDefault();\n this._dragActive = false; // For styling purpose\n this.requestUpdate();\n\n const files = e.dataTransfer?.files;\n if (!files) return;\n\n const newFiles = Array.from(files);\n\n if (this.multiple) {\n newFiles.forEach((file) => {\n this._saveSelectedFiles(file);\n });\n } else {\n this._saveSelectedFiles(newFiles[0]);\n }\n\n this.requestUpdate();\n this._dispatchChangeEvent();\n }\n\n private _handleInvalid(event: Event) {\n event.preventDefault();\n this._validate();\n\n const input = this.shadowRoot?.querySelector(\"input\");\n if (input) {\n // Focus only if this is the first invalid element (top-down approach)\n const form = this._internals.form;\n if (form) {\n const elements = Array.from(form.elements) as Array<\n HTMLElement & { checkValidity?: () => boolean }\n >;\n // Find the first element in the form that is invalid\n const firstInvalidElement = elements.find(\n (element) =>\n typeof element.checkValidity === \"function\" &&\n !element.checkValidity(),\n );\n if (firstInvalidElement === this) {\n input.focus();\n }\n } else {\n // If not part of a form, simply focus.\n input.focus();\n }\n }\n }\n\n render() {\n return html`<div\n class=\"nys-fileinput\"\n @nys-fileRemove=${this._handleFileRemove}\n >\n <nys-label\n id=${this.id}\n label=${this.label}\n description=${this.description}\n flag=${this.required ? \"required\" : this.optional ? \"optional\" : \"\"}\n >\n <slot name=\"description\" slot=\"description\">${this.description}</slot>\n </nys-label>\n\n <input\n id=${this.id}\n class=\"hidden-file-input\"\n type=\"file\"\n name=${this.name}\n ?multiple=${this.multiple}\n accept=${this.accept}\n ?required=${this.required}\n ?disabled=${this.disabled ||\n (!this.multiple && this._selectedFiles.length > 0)}\n aria-disabled=\"${this.disabled}\"\n aria-label=\"Drag files here or choose from folder\"\n aria-describedby=\"file-input-specific-hint\"\n style=\"position: absolute; width: 1px; height: 1px; opacity: 0;\"\n @change=${this._handleFileChange}\n />\n\n ${!this.dropzone\n ? html`<nys-button\n id=\"file-btn\"\n name=\"file-btn\"\n label=${this.multiple ? \"Choose files\" : \"Choose file\"}\n variant=\"outline\"\n ?disabled=${this.disabled ||\n (!this.multiple && this._selectedFiles.length > 0)}\n .onClick=${() => this._openFileDialog()}\n ></nys-button>`\n : html`<div\n class=\"nys-fileinput__dropzone\n ${this._dragActive ? \"drag-active\" : \"\"}\n ${this._isDropDisabled ? \"disabled\" : \"\"}\n ${this.showError && !this._isDropDisabled ? \"error\" : \"\"}\"\n @click=${this._isDropDisabled ? null : this._openFileDialog}\n @keydown=${(e: KeyboardEvent) =>\n !this._isDropDisabled &&\n (e.key === \"Enter\" || e.key === \" \") &&\n this._openFileDialog()}\n @dragover=${this._isDropDisabled ? null : this._onDragOver}\n @dragleave=${this._isDropDisabled ? null : this._onDragLeave}\n @drop=${this._isDropDisabled ? null : this._onDrop}\n >\n ${this._dragActive\n ? html`<p>Drop file to upload</p>`\n : html` <nys-button\n id=\"file-btn\"\n name=\"file-btn\"\n label=${this.multiple ? \"Choose files\" : \"Choose file\"}\n variant=\"outline\"\n ?disabled=${this._isDropDisabled}\n .onClick=${(e: Event) => {\n e.stopPropagation();\n this._openFileDialog();\n }}\n ></nys-button>\n <p>or drag here</p>`}\n </div>`}\n ${this.showError\n ? html`\n <nys-errormessage\n ?showError=${this.showError}\n errorMessage=${this._internals.validationMessage ||\n this.errorMessage}\n ></nys-errormessage>\n `\n : null}\n ${this._selectedFiles.length > 0\n ? html`\n <ul>\n ${this._selectedFiles.map(\n (entry) =>\n html`<li>\n <nys-fileitem\n filename=${entry.file.name}\n status=${entry.status}\n progress=${entry.progress}\n errorMessage=${entry.errorMsg || \"\"}\n ></nys-fileitem>\n </li>`,\n )}\n </ul>\n `\n : null}\n </div>`;\n }\n}\n\nif (!customElements.get(\"nys-fileinput\")) {\n customElements.define(\"nys-fileinput\", NysFileinput);\n}\n"],"names":["t","e","s","o","n$2","r","n","S","c","i","h","a","l","p","d","u","f","y","b","_a","magicNumbers","header","ftyp","match","j","matchesMagic","magic","acceptKeyMap","validateFileHeader","file","accept","buffer","acceptItems","acceptedKeys","item","key","styles$1","css","styles","_NysFileItem","LitElement","filename","lastDotIndex","extension","namePart","maxNameLength","startPart","endPart","html","NysFileItem","__decorateClass","property","fileinputIdCounter","_NysFileinput","files","entry","formData","singleFile","input","message","_b","hasCorruptedFiles","isEmpty","existingFile","reader","percentage","filenameToRemove","newFiles","event","form","element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CAAS;AAAA,GAZhBoB,EAYkB,WAAA,UAAA;AACcrB,EAAA;AAAA,EAA1CC,EAAS,EAAE,MAAM,QAAQ,SAAS,IAAM;AAAA,GAb9BoB,EAagC,WAAA,OAAA;AAuZxC,eAAe,IAAI,eAAe,KACrC,eAAe,OAAO,iBAAiBA,CAAY;","x_google_ignoreList":[0,1,2]}
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { LitElement } from "lit";
2
+ export declare class NysFileItem extends LitElement {
3
+ filename: string;
4
+ status: "pending" | "processing" | "done" | "error";
5
+ progress: number;
6
+ errorMessage: string;
7
+ static styles: import("lit").CSSResult;
8
+ private _handleRemove;
9
+ private truncateFilename;
10
+ render(): import("lit-html").TemplateResult<1>;
11
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export declare function validateFileHeader(file: File, accept: string): Promise<boolean>;
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@nysds/nys-fileinput",
3
+ "version": "1.4.0",
4
+ "description": "The Fileinput component from the NYS Design System.",
5
+ "module": "dist/nys-fileinput.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/nys-fileinput.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "type": "module",
14
+ "files": [
15
+ "dist/"
16
+ ],
17
+ "scripts": {
18
+ "dev": "tsc --emitDeclarationOnly && vite",
19
+ "build": "tsc --emitDeclarationOnly && vite build",
20
+ "test": "vite build && wtr",
21
+ "build:watch": "tsc --emitDeclarationOnly && vite build --watch",
22
+ "test:watch": "vite build && wtr --watch"
23
+ },
24
+ "peerDependencies": {
25
+ "lit": "^3.2.1",
26
+ "@nysds/nys-icon": "^1.4.0",
27
+ "@nysds/nys-button": "^1.4.0",
28
+ "@nysds/nys-label": "^1.4.0",
29
+ "@nysds/nys-errormessage": "^1.4.0"
30
+ },
31
+ "devDependencies": {
32
+ "lit": "^3.2.1",
33
+ "@nysds/nys-icon": "^1.4.0",
34
+ "@nysds/nys-button": "^1.4.0",
35
+ "@nysds/nys-label": "^1.4.0",
36
+ "@nysds/nys-errormessage": "^1.4.0",
37
+ "typescript": "^5.7.2",
38
+ "vite": "^6.3.4"
39
+ },
40
+ "keywords": [
41
+ "new-york-state",
42
+ "design-system",
43
+ "web-components",
44
+ "lit",
45
+ "nys",
46
+ "fileinput",
47
+ "forms"
48
+ ],
49
+ "author": "New York State Design System Team",
50
+ "license": "MIT"
51
+ }