@krollins/blueprint 0.1.11 → 0.1.13

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.
Files changed (95) hide show
  1. package/dist/components/accordion.js +393 -0
  2. package/dist/components/accordion.js.map +1 -0
  3. package/dist/components/alert.js +213 -0
  4. package/dist/components/alert.js.map +1 -0
  5. package/dist/components/avatar.js +237 -0
  6. package/dist/components/avatar.js.map +1 -0
  7. package/dist/components/badge.js +144 -0
  8. package/dist/components/badge.js.map +1 -0
  9. package/dist/components/breadcrumb.js +481 -0
  10. package/dist/components/breadcrumb.js.map +1 -0
  11. package/dist/components/button.js +192 -0
  12. package/dist/components/button.js.map +1 -0
  13. package/dist/components/card.js +223 -0
  14. package/dist/components/card.js.map +1 -0
  15. package/dist/components/checkbox.js +337 -0
  16. package/dist/components/checkbox.js.map +1 -0
  17. package/dist/components/color-picker.js +1660 -0
  18. package/dist/components/color-picker.js.map +1 -0
  19. package/dist/components/combobox.js +595 -0
  20. package/dist/components/combobox.js.map +1 -0
  21. package/dist/components/date-picker.js +726 -0
  22. package/dist/components/date-picker.js.map +1 -0
  23. package/dist/components/divider.js +214 -0
  24. package/dist/components/divider.js.map +1 -0
  25. package/dist/components/drawer.js +568 -0
  26. package/dist/components/drawer.js.map +1 -0
  27. package/dist/components/dropdown.js +377 -0
  28. package/dist/components/dropdown.js.map +1 -0
  29. package/dist/components/file-upload.js +669 -0
  30. package/dist/components/file-upload.js.map +1 -0
  31. package/dist/components/heading.js +161 -0
  32. package/dist/components/heading.js.map +1 -0
  33. package/dist/components/icon.js +599 -0
  34. package/dist/components/icon.js.map +1 -0
  35. package/dist/components/input.js +363 -0
  36. package/dist/components/input.js.map +1 -0
  37. package/dist/components/link.js +178 -0
  38. package/dist/components/link.js.map +1 -0
  39. package/dist/components/menu.js +331 -0
  40. package/dist/components/menu.js.map +1 -0
  41. package/dist/components/modal.js +317 -0
  42. package/dist/components/modal.js.map +1 -0
  43. package/dist/components/multi-select.js +642 -0
  44. package/dist/components/multi-select.js.map +1 -0
  45. package/dist/components/notification.js +429 -0
  46. package/dist/components/notification.js.map +1 -0
  47. package/dist/components/number-input.js +556 -0
  48. package/dist/components/number-input.js.map +1 -0
  49. package/dist/components/pagination.js +320 -0
  50. package/dist/components/pagination.js.map +1 -0
  51. package/dist/components/popover.js +597 -0
  52. package/dist/components/popover.js.map +1 -0
  53. package/dist/components/progress.js +219 -0
  54. package/dist/components/progress.js.map +1 -0
  55. package/dist/components/radio.js +321 -0
  56. package/dist/components/radio.js.map +1 -0
  57. package/dist/components/select.js +498 -0
  58. package/dist/components/select.js.map +1 -0
  59. package/dist/components/skeleton.js +240 -0
  60. package/dist/components/skeleton.js.map +1 -0
  61. package/dist/components/slider.js +9 -0
  62. package/dist/components/slider.js.map +1 -0
  63. package/dist/components/spinner.js +133 -0
  64. package/dist/components/spinner.js.map +1 -0
  65. package/dist/components/stepper.js +812 -0
  66. package/dist/components/stepper.js.map +1 -0
  67. package/dist/components/switch.js +380 -0
  68. package/dist/components/switch.js.map +1 -0
  69. package/dist/components/table.js +642 -0
  70. package/dist/components/table.js.map +1 -0
  71. package/dist/components/tabs.js +547 -0
  72. package/dist/components/tabs.js.map +1 -0
  73. package/dist/components/tag.js +291 -0
  74. package/dist/components/tag.js.map +1 -0
  75. package/dist/components/text.js +278 -0
  76. package/dist/components/text.js.map +1 -0
  77. package/dist/components/textarea.js +380 -0
  78. package/dist/components/textarea.js.map +1 -0
  79. package/dist/components/time-picker.js +457 -0
  80. package/dist/components/time-picker.js.map +1 -0
  81. package/dist/components/tooltip.js +239 -0
  82. package/dist/components/tooltip.js.map +1 -0
  83. package/dist/components/tree.js +582 -0
  84. package/dist/components/tree.js.map +1 -0
  85. package/dist/index.js +93 -17799
  86. package/dist/index.js.map +1 -1
  87. package/dist/shared/boolean-converter-XDGfS9LC.js +12 -0
  88. package/dist/shared/boolean-converter-XDGfS9LC.js.map +1 -0
  89. package/dist/shared/debounce-BckY30Sf.js +23 -0
  90. package/dist/shared/debounce-BckY30Sf.js.map +1 -0
  91. package/dist/shared/memoize-DlOFy-92.js +16 -0
  92. package/dist/shared/memoize-DlOFy-92.js.map +1 -0
  93. package/dist/shared/slider-BNt5TITl.js +484 -0
  94. package/dist/shared/slider-BNt5TITl.js.map +1 -0
  95. package/package.json +49 -3
@@ -0,0 +1,669 @@
1
+ import { css as u, LitElement as h, html as p, nothing as c } from "lit";
2
+ import { property as s, state as f, query as b, customElement as v } from "lit/decorators.js";
3
+ import { classMap as g } from "lit/directives/class-map.js";
4
+ import { b as _ } from "../shared/boolean-converter-XDGfS9LC.js";
5
+ const m = u`
6
+ /* Base styles */
7
+ :host {
8
+ display: block;
9
+ }
10
+
11
+ .file-upload {
12
+ font-family: var(--bp-font-family);
13
+ display: flex;
14
+ flex-direction: column;
15
+ gap: var(--bp-spacing-md);
16
+ }
17
+
18
+ /* Hidden file input - standard sr-only pattern */
19
+ input[type='file'] {
20
+ position: absolute;
21
+ width: var(--bp-spacing-0-5);
22
+ height: var(--bp-spacing-0-5);
23
+ padding: var(--bp-spacing-0);
24
+ margin: calc(var(--bp-spacing-0-5) * -1);
25
+ overflow: hidden;
26
+ clip: rect(0, 0, 0, 0);
27
+ white-space: nowrap;
28
+ border: 0;
29
+ }
30
+
31
+ /* Visually hidden but accessible - standard sr-only pattern */
32
+ .visually-hidden {
33
+ position: absolute;
34
+ width: var(--bp-spacing-0-5);
35
+ height: var(--bp-spacing-0-5);
36
+ padding: var(--bp-spacing-0);
37
+ margin: calc(var(--bp-spacing-0-5) * -1);
38
+ overflow: hidden;
39
+ clip: rect(0, 0, 0, 0);
40
+ white-space: nowrap;
41
+ border: 0;
42
+ }
43
+
44
+ /* Dropzone */
45
+ .file-upload__dropzone {
46
+ display: flex;
47
+ flex-direction: column;
48
+ align-items: center;
49
+ justify-content: center;
50
+ gap: var(--bp-spacing-sm);
51
+ padding: var(--bp-spacing-xl);
52
+ border: var(--bp-focus-width) dashed var(--bp-color-border);
53
+ border-radius: var(--bp-border-radius-lg);
54
+ background-color: var(--bp-color-surface);
55
+ cursor: pointer;
56
+ transition:
57
+ border-color var(--bp-transition-fast),
58
+ background-color var(--bp-transition-fast);
59
+ text-align: center;
60
+ }
61
+
62
+ .file-upload__dropzone:hover:not(.file-upload__dropzone--disabled) {
63
+ border-color: var(--bp-color-primary);
64
+ background-color: var(--bp-color-surface-elevated);
65
+ }
66
+
67
+ .file-upload__dropzone:focus-visible {
68
+ outline: var(--bp-focus-width) var(--bp-focus-style) var(--bp-color-focus);
69
+ outline-offset: var(--bp-focus-offset);
70
+ border-color: var(--bp-color-primary);
71
+ }
72
+
73
+ .file-upload__dropzone:active:not(.file-upload__dropzone--disabled) {
74
+ transform: scale(0.995);
75
+ }
76
+
77
+ /* Drag over state */
78
+ .file-upload__dropzone--drag-over {
79
+ border-color: var(--bp-color-primary);
80
+ background-color: var(--bp-color-surface-elevated);
81
+ border-style: solid;
82
+ }
83
+
84
+ /* Disabled state */
85
+ .file-upload__dropzone--disabled {
86
+ opacity: var(--bp-opacity-disabled);
87
+ cursor: not-allowed;
88
+ background-color: var(--bp-color-surface-subdued);
89
+ }
90
+
91
+ /* Icon */
92
+ .file-upload__icon {
93
+ width: var(--bp-spacing-2xl);
94
+ height: var(--bp-spacing-2xl);
95
+ color: var(--bp-color-text-muted);
96
+ transition: color var(--bp-transition-fast);
97
+ }
98
+
99
+ .file-upload__dropzone:hover:not(.file-upload__dropzone--disabled)
100
+ .file-upload__icon,
101
+ .file-upload__dropzone--drag-over .file-upload__icon {
102
+ color: var(--bp-color-primary);
103
+ }
104
+
105
+ /* Label */
106
+ .file-upload__label {
107
+ font-size: var(--bp-font-size-base);
108
+ font-weight: var(--bp-font-weight-medium);
109
+ color: var(--bp-color-text);
110
+ line-height: var(--bp-line-height-normal);
111
+ }
112
+
113
+ /* Description */
114
+ .file-upload__description {
115
+ font-size: var(--bp-font-size-sm);
116
+ color: var(--bp-color-text-muted);
117
+ line-height: var(--bp-line-height-normal);
118
+ }
119
+
120
+ /* Variants */
121
+ .file-upload__dropzone--success {
122
+ border-color: var(--bp-color-success);
123
+ }
124
+
125
+ .file-upload__dropzone--success:hover:not(.file-upload__dropzone--disabled) {
126
+ border-color: var(--bp-color-success);
127
+ }
128
+
129
+ .file-upload__dropzone--error {
130
+ border-color: var(--bp-color-error);
131
+ }
132
+
133
+ .file-upload__dropzone--error:hover:not(.file-upload__dropzone--disabled) {
134
+ border-color: var(--bp-color-error);
135
+ }
136
+
137
+ .file-upload__dropzone--warning {
138
+ border-color: var(--bp-color-warning);
139
+ }
140
+
141
+ .file-upload__dropzone--warning:hover:not(.file-upload__dropzone--disabled) {
142
+ border-color: var(--bp-color-warning);
143
+ }
144
+
145
+ /* Size variants */
146
+ .file-upload__dropzone--sm {
147
+ padding: var(--bp-spacing-lg);
148
+ gap: var(--bp-spacing-xs);
149
+ }
150
+
151
+ .file-upload__dropzone--sm .file-upload__icon {
152
+ width: var(--bp-spacing-xl);
153
+ height: var(--bp-spacing-xl);
154
+ }
155
+
156
+ .file-upload__dropzone--sm .file-upload__label {
157
+ font-size: var(--bp-font-size-sm);
158
+ }
159
+
160
+ .file-upload__dropzone--sm .file-upload__description {
161
+ font-size: var(--bp-font-size-xs);
162
+ }
163
+
164
+ .file-upload__dropzone--md {
165
+ padding: var(--bp-spacing-xl);
166
+ }
167
+
168
+ .file-upload__dropzone--lg {
169
+ padding: var(--bp-spacing-2xl);
170
+ gap: var(--bp-spacing-md);
171
+ }
172
+
173
+ .file-upload__dropzone--lg .file-upload__icon {
174
+ width: var(--bp-spacing-10);
175
+ height: var(--bp-spacing-10);
176
+ }
177
+
178
+ .file-upload__dropzone--lg .file-upload__label {
179
+ font-size: var(--bp-font-size-lg);
180
+ }
181
+
182
+ /* File list */
183
+ .file-upload__file-list {
184
+ display: flex;
185
+ flex-direction: column;
186
+ gap: var(--bp-spacing-sm);
187
+ }
188
+
189
+ .file-upload__file-item {
190
+ display: flex;
191
+ align-items: center;
192
+ gap: var(--bp-spacing-md);
193
+ padding: var(--bp-spacing-md);
194
+ background-color: var(--bp-color-surface);
195
+ border: var(--bp-border-width) solid var(--bp-color-border);
196
+ border-radius: var(--bp-border-radius-md);
197
+ transition:
198
+ background-color var(--bp-transition-fast),
199
+ border-color var(--bp-transition-fast),
200
+ transform var(--bp-transition-fast);
201
+ }
202
+
203
+ .file-upload__file-item:hover {
204
+ background-color: var(--bp-color-surface-elevated);
205
+ border-color: var(--bp-color-border-strong);
206
+ }
207
+
208
+ .file-upload__file-item:active {
209
+ transform: scale(0.99);
210
+ }
211
+
212
+ /* File preview */
213
+ .file-upload__preview {
214
+ width: var(--bp-spacing-10);
215
+ height: var(--bp-spacing-10);
216
+ object-fit: cover;
217
+ border-radius: var(--bp-border-radius-sm);
218
+ flex-shrink: 0;
219
+ }
220
+
221
+ .file-upload__file-icon {
222
+ width: var(--bp-spacing-10);
223
+ height: var(--bp-spacing-10);
224
+ display: flex;
225
+ align-items: center;
226
+ justify-content: center;
227
+ flex-shrink: 0;
228
+ color: var(--bp-color-text-muted);
229
+ transition: color var(--bp-transition-fast);
230
+ }
231
+
232
+ .file-upload__file-icon svg {
233
+ width: var(--bp-spacing-6);
234
+ height: var(--bp-spacing-6);
235
+ }
236
+
237
+ /* File info */
238
+ .file-upload__file-info {
239
+ display: flex;
240
+ flex-direction: column;
241
+ gap: var(--bp-spacing-2xs);
242
+ flex: 1;
243
+ min-width: 0;
244
+ }
245
+
246
+ .file-upload__file-name {
247
+ font-size: var(--bp-font-size-sm);
248
+ font-weight: var(--bp-font-weight-medium);
249
+ color: var(--bp-color-text);
250
+ white-space: nowrap;
251
+ overflow: hidden;
252
+ text-overflow: ellipsis;
253
+ line-height: var(--bp-line-height-normal);
254
+ }
255
+
256
+ .file-upload__file-size {
257
+ font-size: var(--bp-font-size-xs);
258
+ color: var(--bp-color-text-muted);
259
+ line-height: var(--bp-line-height-normal);
260
+ }
261
+
262
+ /* Remove button */
263
+ .file-upload__remove-button {
264
+ display: flex;
265
+ align-items: center;
266
+ justify-content: center;
267
+ width: var(--bp-spacing-6);
268
+ height: var(--bp-spacing-6);
269
+ padding: 0;
270
+ border: none;
271
+ background: transparent;
272
+ border-radius: var(--bp-border-radius-sm);
273
+ color: var(--bp-color-text-muted);
274
+ cursor: pointer;
275
+ transition:
276
+ background-color var(--bp-transition-fast),
277
+ color var(--bp-transition-fast);
278
+ flex-shrink: 0;
279
+ }
280
+
281
+ .file-upload__remove-button:hover:not(:disabled) {
282
+ background-color: var(--bp-color-error);
283
+ color: var(--bp-color-text-inverse);
284
+ }
285
+
286
+ .file-upload__remove-button:focus-visible {
287
+ outline: var(--bp-focus-width) var(--bp-focus-style) var(--bp-color-focus);
288
+ outline-offset: var(--bp-focus-offset);
289
+ }
290
+
291
+ .file-upload__remove-button:disabled {
292
+ cursor: not-allowed;
293
+ opacity: var(--bp-opacity-disabled);
294
+ }
295
+
296
+ .file-upload__remove-button svg {
297
+ width: var(--bp-spacing-4);
298
+ height: var(--bp-spacing-4);
299
+ }
300
+
301
+ /* Message */
302
+ .file-upload__message {
303
+ font-size: var(--bp-font-size-sm);
304
+ color: var(--bp-color-text-muted);
305
+ line-height: var(--bp-line-height-normal);
306
+ }
307
+
308
+ .file-upload__message--success {
309
+ color: var(--bp-color-success);
310
+ }
311
+
312
+ .file-upload__message--error {
313
+ color: var(--bp-color-error);
314
+ }
315
+
316
+ .file-upload__message--warning {
317
+ color: var(--bp-color-warning);
318
+ }
319
+ `;
320
+ var y = Object.defineProperty, z = Object.getOwnPropertyDescriptor, t = (e, i, r, l) => {
321
+ for (var a = l > 1 ? void 0 : l ? z(i, r) : i, n = e.length - 1, d; n >= 0; n--)
322
+ (d = e[n]) && (a = (l ? d(i, r, a) : d(a)) || a);
323
+ return l && a && y(i, r, a), a;
324
+ };
325
+ let o = class extends h {
326
+ constructor() {
327
+ super(), this.isDragOver = !1, this.files = [], this.name = "", this.label = "Drop files here or click to upload", this.description = "", this.accept = "", this.multiple = !1, this.maxSize = 0, this.maxFiles = 0, this.disabled = !1, this.required = !1, this.variant = "default", this.message = "", this.size = "md", this.showPreviews = !0;
328
+ }
329
+ /**
330
+ * Get the list of selected files
331
+ */
332
+ getFiles() {
333
+ return [...this.files];
334
+ }
335
+ /**
336
+ * Clear all selected files
337
+ */
338
+ clearFiles() {
339
+ this.files.forEach((e) => {
340
+ e.previewUrl && URL.revokeObjectURL(e.previewUrl);
341
+ }), this.files = [], this.fileInput && (this.fileInput.value = ""), this.dispatchChangeEvent();
342
+ }
343
+ /**
344
+ * Remove a specific file by ID
345
+ */
346
+ removeFile(e) {
347
+ const i = this.files.findIndex((r) => r.id === e);
348
+ if (i !== -1) {
349
+ const r = this.files[i];
350
+ r.previewUrl && URL.revokeObjectURL(r.previewUrl), this.files = this.files.filter((l) => l.id !== e), this.dispatchEvent(
351
+ new CustomEvent("bp-file-removed", {
352
+ detail: { file: r },
353
+ bubbles: !0,
354
+ composed: !0
355
+ })
356
+ ), this.dispatchChangeEvent();
357
+ }
358
+ }
359
+ handleClick() {
360
+ this.disabled || this.fileInput?.click();
361
+ }
362
+ handleKeyDown(e) {
363
+ this.disabled || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.fileInput?.click());
364
+ }
365
+ handleInputChange(e) {
366
+ const i = e.target;
367
+ i.files && this.processFiles(Array.from(i.files));
368
+ }
369
+ handleDragEnter(e) {
370
+ e.preventDefault(), e.stopPropagation(), this.disabled || (this.isDragOver = !0);
371
+ }
372
+ handleDragOver(e) {
373
+ e.preventDefault(), e.stopPropagation(), !this.disabled && e.dataTransfer && (e.dataTransfer.dropEffect = "copy");
374
+ }
375
+ handleDragLeave(e) {
376
+ e.preventDefault(), e.stopPropagation();
377
+ const i = e.relatedTarget;
378
+ this.contains(i) || (this.isDragOver = !1);
379
+ }
380
+ handleDrop(e) {
381
+ if (e.preventDefault(), e.stopPropagation(), this.isDragOver = !1, this.disabled) return;
382
+ const i = e.dataTransfer;
383
+ i?.files && this.processFiles(Array.from(i.files));
384
+ }
385
+ processFiles(e) {
386
+ const i = [];
387
+ for (const r of e) {
388
+ if (this.maxFiles > 0 && this.files.length + i.length >= this.maxFiles) {
389
+ this.dispatchRejectEvent(r, "Maximum number of files exceeded");
390
+ continue;
391
+ }
392
+ if (this.accept && !this.isFileTypeAccepted(r)) {
393
+ this.dispatchRejectEvent(r, "File type not accepted");
394
+ continue;
395
+ }
396
+ if (this.maxSize > 0 && r.size > this.maxSize) {
397
+ this.dispatchRejectEvent(r, "File size exceeds limit");
398
+ continue;
399
+ }
400
+ const l = {
401
+ file: r,
402
+ name: r.name,
403
+ size: r.size,
404
+ type: r.type,
405
+ id: this.generateFileId(),
406
+ status: "pending",
407
+ progress: 0
408
+ };
409
+ this.showPreviews && r.type.startsWith("image/") && (l.previewUrl = URL.createObjectURL(r)), i.push(l), this.dispatchEvent(
410
+ new CustomEvent("bp-file-added", {
411
+ detail: { file: l },
412
+ bubbles: !0,
413
+ composed: !0
414
+ })
415
+ );
416
+ }
417
+ i.length > 0 && (this.multiple ? this.files = [...this.files, ...i] : (this.files.forEach((r) => {
418
+ r.previewUrl && URL.revokeObjectURL(r.previewUrl);
419
+ }), this.files = i.slice(0, 1)), this.dispatchChangeEvent());
420
+ }
421
+ isFileTypeAccepted(e) {
422
+ if (!this.accept) return !0;
423
+ const i = this.accept.split(",").map((a) => a.trim().toLowerCase()), r = e.type.toLowerCase(), l = "." + e.name.split(".").pop()?.toLowerCase();
424
+ return i.some((a) => {
425
+ if (a === r || a === l) return !0;
426
+ if (a.endsWith("/*")) {
427
+ const n = a.slice(0, -2);
428
+ return r.startsWith(n + "/");
429
+ }
430
+ return !1;
431
+ });
432
+ }
433
+ dispatchChangeEvent() {
434
+ this.dispatchEvent(
435
+ new CustomEvent("bp-change", {
436
+ detail: { files: this.getFiles() },
437
+ bubbles: !0,
438
+ composed: !0
439
+ })
440
+ );
441
+ }
442
+ dispatchRejectEvent(e, i) {
443
+ this.dispatchEvent(
444
+ new CustomEvent("bp-file-rejected", {
445
+ detail: { file: e, reason: i },
446
+ bubbles: !0,
447
+ composed: !0
448
+ })
449
+ );
450
+ }
451
+ generateFileId() {
452
+ return `file-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
453
+ }
454
+ formatFileSize(e) {
455
+ if (e === 0) return "0 B";
456
+ const i = ["B", "KB", "MB", "GB"], r = Math.min(
457
+ Math.floor(Math.log(e) / Math.log(1024)),
458
+ i.length - 1
459
+ );
460
+ return `${(e / Math.pow(1024, r)).toFixed(r > 0 ? 1 : 0)} ${i[r]}`;
461
+ }
462
+ handleRemoveFile(e, i) {
463
+ e.stopPropagation(), this.removeFile(i);
464
+ }
465
+ renderUploadIcon() {
466
+ return p`
467
+ <svg
468
+ class="file-upload__icon"
469
+ part="icon"
470
+ viewBox="0 0 24 24"
471
+ fill="none"
472
+ stroke="currentColor"
473
+ stroke-width="2"
474
+ stroke-linecap="round"
475
+ stroke-linejoin="round"
476
+ aria-hidden="true"
477
+ >
478
+ <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />
479
+ <polyline points="17 8 12 3 7 8" />
480
+ <line x1="12" y1="3" x2="12" y2="15" />
481
+ </svg>
482
+ `;
483
+ }
484
+ renderFileList() {
485
+ return this.files.length === 0 ? c : p`
486
+ <div
487
+ class="file-upload__file-list"
488
+ part="file-list"
489
+ role="list"
490
+ aria-label="Selected files"
491
+ >
492
+ ${this.files.map(
493
+ (e) => p`
494
+ <div
495
+ class="file-upload__file-item"
496
+ part="file-item"
497
+ role="listitem"
498
+ >
499
+ ${e.previewUrl ? p`
500
+ <img
501
+ class="file-upload__preview"
502
+ src="${e.previewUrl}"
503
+ alt="Preview of ${e.name}"
504
+ />
505
+ ` : p`
506
+ <div class="file-upload__file-icon" aria-hidden="true">
507
+ <svg
508
+ viewBox="0 0 24 24"
509
+ fill="none"
510
+ stroke="currentColor"
511
+ stroke-width="2"
512
+ >
513
+ <path
514
+ d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"
515
+ />
516
+ <polyline points="14 2 14 8 20 8" />
517
+ </svg>
518
+ </div>
519
+ `}
520
+ <div class="file-upload__file-info">
521
+ <span class="file-upload__file-name" part="file-name"
522
+ >${e.name}</span
523
+ >
524
+ <span class="file-upload__file-size" part="file-size"
525
+ >${this.formatFileSize(e.size)}</span
526
+ >
527
+ </div>
528
+ <button
529
+ type="button"
530
+ class="file-upload__remove-button"
531
+ part="file-remove"
532
+ @click=${(i) => this.handleRemoveFile(i, e.id)}
533
+ aria-label="Remove ${e.name}"
534
+ ?disabled=${this.disabled}
535
+ >
536
+ <svg
537
+ viewBox="0 0 24 24"
538
+ fill="none"
539
+ stroke="currentColor"
540
+ stroke-width="2"
541
+ >
542
+ <line x1="18" y1="6" x2="6" y2="18" />
543
+ <line x1="6" y1="6" x2="18" y2="18" />
544
+ </svg>
545
+ </button>
546
+ </div>
547
+ `
548
+ )}
549
+ </div>
550
+ `;
551
+ }
552
+ render() {
553
+ const e = {
554
+ "file-upload__dropzone": !0,
555
+ "file-upload__dropzone--drag-over": this.isDragOver,
556
+ "file-upload__dropzone--disabled": this.disabled,
557
+ "file-upload__dropzone--has-files": this.files.length > 0,
558
+ [`file-upload__dropzone--${this.variant}`]: this.variant !== "default",
559
+ [`file-upload__dropzone--${this.size}`]: !0
560
+ }, i = this.accept ? `Accepted file types: ${this.accept}` : "", r = this.maxSize > 0 ? `Maximum file size: ${this.formatFileSize(this.maxSize)}` : "";
561
+ return p`
562
+ <div class="file-upload">
563
+ <div
564
+ class=${g(e)}
565
+ part="dropzone"
566
+ role="button"
567
+ tabindex=${this.disabled ? -1 : 0}
568
+ aria-disabled=${this.disabled}
569
+ aria-describedby="file-upload-description"
570
+ @click=${this.handleClick}
571
+ @keydown=${this.handleKeyDown}
572
+ @dragenter=${this.handleDragEnter}
573
+ @dragover=${this.handleDragOver}
574
+ @dragleave=${this.handleDragLeave}
575
+ @drop=${this.handleDrop}
576
+ >
577
+ <input
578
+ type="file"
579
+ part="input"
580
+ .name=${this.name}
581
+ .accept=${this.accept}
582
+ ?multiple=${this.multiple}
583
+ ?disabled=${this.disabled}
584
+ ?required=${this.required}
585
+ @change=${this.handleInputChange}
586
+ aria-hidden="true"
587
+ tabindex="-1"
588
+ />
589
+
590
+ ${this.renderUploadIcon()}
591
+
592
+ <span class="file-upload__label" part="label">${this.label}</span>
593
+
594
+ ${this.description ? p`<span class="file-upload__description" part="description"
595
+ >${this.description}</span
596
+ >` : c}
597
+ </div>
598
+
599
+ <span id="file-upload-description" class="visually-hidden">
600
+ ${i} ${r}
601
+ </span>
602
+
603
+ ${this.renderFileList()}
604
+ ${this.message ? p`<div
605
+ class="file-upload__message file-upload__message--${this.variant}"
606
+ part="message"
607
+ >
608
+ ${this.message}
609
+ </div>` : c}
610
+ </div>
611
+ `;
612
+ }
613
+ };
614
+ o.styles = [m];
615
+ t([
616
+ s({ type: String })
617
+ ], o.prototype, "name", 2);
618
+ t([
619
+ s({ type: String })
620
+ ], o.prototype, "label", 2);
621
+ t([
622
+ s({ type: String })
623
+ ], o.prototype, "description", 2);
624
+ t([
625
+ s({ type: String })
626
+ ], o.prototype, "accept", 2);
627
+ t([
628
+ s({ type: Boolean })
629
+ ], o.prototype, "multiple", 2);
630
+ t([
631
+ s({ type: Number })
632
+ ], o.prototype, "maxSize", 2);
633
+ t([
634
+ s({ type: Number })
635
+ ], o.prototype, "maxFiles", 2);
636
+ t([
637
+ s({ type: Boolean, reflect: !0 })
638
+ ], o.prototype, "disabled", 2);
639
+ t([
640
+ s({ type: Boolean })
641
+ ], o.prototype, "required", 2);
642
+ t([
643
+ s({ type: String })
644
+ ], o.prototype, "variant", 2);
645
+ t([
646
+ s({ type: String })
647
+ ], o.prototype, "message", 2);
648
+ t([
649
+ s({ type: String })
650
+ ], o.prototype, "size", 2);
651
+ t([
652
+ s({ converter: _, reflect: !0 })
653
+ ], o.prototype, "showPreviews", 2);
654
+ t([
655
+ f()
656
+ ], o.prototype, "isDragOver", 2);
657
+ t([
658
+ f()
659
+ ], o.prototype, "files", 2);
660
+ t([
661
+ b('input[type="file"]')
662
+ ], o.prototype, "fileInput", 2);
663
+ o = t([
664
+ v("bp-file-upload")
665
+ ], o);
666
+ export {
667
+ o as BpFileUpload
668
+ };
669
+ //# sourceMappingURL=file-upload.js.map