tyrell-components 1.0.0-RC13 → 1.0.0-RC15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/css/tyrell-theme.css +192 -180
- package/css/tyrell.css +23 -0
- package/dist/tyrell-colors-static.css +1 -316
- package/dist/tyrell-theme.css +1 -1454
- package/dist/tyrell.css +1 -1371
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +20 -10
- package/lib/base/ty-component.js +196 -319
- package/lib/components/button.d.ts +3 -17
- package/lib/components/button.js +261 -295
- package/lib/components/calendar-month.d.ts +4 -50
- package/lib/components/calendar-month.js +443 -582
- package/lib/components/calendar-navigation.d.ts +3 -48
- package/lib/components/calendar-navigation.js +239 -362
- package/lib/components/calendar.d.ts +8 -83
- package/lib/components/calendar.js +616 -829
- package/lib/components/checkbox.d.ts +5 -72
- package/lib/components/checkbox.js +273 -416
- package/lib/components/copy.d.ts +4 -57
- package/lib/components/copy.js +280 -397
- package/lib/components/date-picker.d.ts +21 -163
- package/lib/components/date-picker.js +1143 -1674
- package/lib/components/file-upload.d.ts +9 -15
- package/lib/components/file-upload.js +404 -426
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +141 -230
- package/lib/components/input.d.ts +8 -108
- package/lib/components/input.js +593 -784
- package/lib/components/modal.d.ts +17 -26
- package/lib/components/modal.js +340 -484
- package/lib/components/option.d.ts +2 -9
- package/lib/components/option.js +168 -216
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +249 -380
- package/lib/components/radio.d.ts +5 -25
- package/lib/components/radio.js +407 -461
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +69 -103
- package/lib/components/scroll-container.d.ts +2 -12
- package/lib/components/scroll-container.js +293 -338
- package/lib/components/select.d.ts +87 -159
- package/lib/components/select.js +1609 -2090
- package/lib/components/selected-tags.d.ts +5 -48
- package/lib/components/selected-tags.js +188 -276
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +62 -68
- package/lib/components/switch.d.ts +1 -12
- package/lib/components/switch.js +214 -247
- package/lib/components/tab.d.ts +1 -6
- package/lib/components/tab.js +62 -69
- package/lib/components/tabs.d.ts +6 -63
- package/lib/components/tabs.js +545 -777
- package/lib/components/tag.d.ts +3 -37
- package/lib/components/tag.js +236 -335
- package/lib/components/textarea.d.ts +7 -87
- package/lib/components/textarea.js +457 -627
- package/lib/components/tooltip.d.ts +3 -11
- package/lib/components/tooltip.js +307 -443
- package/lib/components/wizard.d.ts +6 -54
- package/lib/components/wizard.js +405 -618
- package/lib/icons/fontawesome/brands.d.ts +0 -1
- package/lib/icons/fontawesome/brands.js +0 -8
- package/lib/icons/fontawesome/regular.d.ts +0 -1
- package/lib/icons/fontawesome/regular.js +0 -8
- package/lib/icons/fontawesome/solid.d.ts +0 -1
- package/lib/icons/fontawesome/solid.js +0 -8
- package/lib/icons/heroicons/micro.d.ts +0 -1
- package/lib/icons/heroicons/micro.js +392 -400
- package/lib/icons/heroicons/mini.d.ts +0 -1
- package/lib/icons/heroicons/mini.js +382 -390
- package/lib/icons/heroicons/outline.d.ts +0 -1
- package/lib/icons/heroicons/outline.js +337 -345
- package/lib/icons/heroicons/solid.d.ts +0 -1
- package/lib/icons/heroicons/solid.js +407 -415
- package/lib/icons/lucide.d.ts +0 -1
- package/lib/icons/lucide.js +24479 -26351
- package/lib/icons/material/filled.d.ts +0 -1
- package/lib/icons/material/filled.js +9653 -9663
- package/lib/icons/material/outlined.d.ts +0 -1
- package/lib/icons/material/outlined.js +10271 -10281
- package/lib/icons/material/round.d.ts +0 -1
- package/lib/icons/material/round.js +10495 -10505
- package/lib/icons/material/sharp.d.ts +0 -1
- package/lib/icons/material/sharp.js +9905 -9915
- package/lib/icons/material/two-tone.d.ts +0 -1
- package/lib/icons/material/two-tone.js +12792 -12802
- package/lib/index.d.ts +0 -1
- package/lib/index.js +21 -41
- package/lib/styles/button.d.ts +2 -20
- package/lib/styles/button.js +202 -404
- package/lib/styles/calendar-month.d.ts +1 -5
- package/lib/styles/calendar-month.js +127 -244
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +64 -104
- package/lib/styles/calendar.d.ts +1 -2
- package/lib/styles/calendar.js +9 -22
- package/lib/styles/checkbox.d.ts +0 -1
- package/lib/styles/checkbox.js +45 -94
- package/lib/styles/copy.d.ts +0 -1
- package/lib/styles/copy.js +67 -106
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +80 -115
- package/lib/styles/date-picker.d.ts +1 -5
- package/lib/styles/date-picker.js +261 -335
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +143 -188
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +92 -170
- package/lib/styles/input.d.ts +1 -6
- package/lib/styles/input.js +125 -290
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +71 -108
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +49 -64
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +42 -77
- package/lib/styles/radio.d.ts +0 -1
- package/lib/styles/radio.js +69 -110
- package/lib/styles/resize-observer.d.ts +1 -2
- package/lib/styles/resize-observer.js +2 -12
- package/lib/styles/scroll-container.d.ts +1 -2
- package/lib/styles/scroll-container.js +100 -149
- package/lib/styles/select-base.d.ts +0 -1
- package/lib/styles/select-base.js +597 -785
- package/lib/styles/select.d.ts +1 -2
- package/lib/styles/select.js +140 -236
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +22 -33
- package/lib/styles/switch.d.ts +0 -1
- package/lib/styles/switch.js +34 -73
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +22 -34
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +190 -222
- package/lib/styles/tag.d.ts +1 -5
- package/lib/styles/tag.js +136 -218
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +210 -319
- package/lib/styles/tooltip.d.ts +0 -1
- package/lib/styles/tooltip.js +3 -13
- package/lib/styles/wizard.d.ts +5 -21
- package/lib/styles/wizard.js +170 -306
- package/lib/types/common.d.ts +2 -2
- package/lib/types/common.js +6 -17
- package/lib/utils/calendar-utils.d.ts +4 -21
- package/lib/utils/calendar-utils.js +100 -273
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +273 -317
- package/lib/utils/flavor-sheet.d.ts +0 -1
- package/lib/utils/flavor-sheet.js +14 -37
- package/lib/utils/icon-registry.d.ts +0 -2
- package/lib/utils/icon-registry.js +137 -243
- package/lib/utils/icons.d.ts +0 -1
- package/lib/utils/icons.js +0 -9
- package/lib/utils/loader-registry.d.ts +0 -1
- package/lib/utils/loader-registry.js +3 -35
- package/lib/utils/locale.d.ts +2 -23
- package/lib/utils/locale.js +34 -120
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +1 -18
- package/lib/utils/number-format.d.ts +6 -3
- package/lib/utils/number-format.js +54 -110
- package/lib/utils/positioning.d.ts +50 -7
- package/lib/utils/positioning.js +224 -234
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +36 -144
- package/lib/utils/property-manager.d.ts +0 -1
- package/lib/utils/property-manager.js +126 -196
- package/lib/utils/resize-observer.d.ts +0 -1
- package/lib/utils/resize-observer.js +23 -59
- package/lib/utils/scroll-lock.d.ts +4 -11
- package/lib/utils/scroll-lock.js +65 -172
- package/lib/utils/styles.d.ts +0 -1
- package/lib/utils/styles.js +17 -41
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +4 -4
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/file-upload.d.ts.map +0 -1
- package/lib/components/file-upload.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js.map +0 -1
- package/lib/components/selected-tags.d.ts.map +0 -1
- package/lib/components/selected-tags.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/checkbox.d.ts.map +0 -1
- package/lib/styles/checkbox.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/custom-scrollbar.d.ts.map +0 -1
- package/lib/styles/custom-scrollbar.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/file-upload.d.ts.map +0 -1
- package/lib/styles/file-upload.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -8
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -849
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/radio.d.ts.map +0 -1
- package/lib/styles/radio.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/select-base.d.ts.map +0 -1
- package/lib/styles/select-base.js.map +0 -1
- package/lib/styles/select.d.ts.map +0 -1
- package/lib/styles/select.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/switch.d.ts.map +0 -1
- package/lib/styles/switch.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/custom-scrollbar.d.ts.map +0 -1
- package/lib/utils/custom-scrollbar.js.map +0 -1
- package/lib/utils/flavor-sheet.d.ts.map +0 -1
- package/lib/utils/flavor-sheet.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/icons.d.ts.map +0 -1
- package/lib/utils/icons.js.map +0 -1
- package/lib/utils/loader-registry.d.ts.map +0 -1
- package/lib/utils/loader-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/mobile.d.ts.map +0 -1
- package/lib/utils/mobile.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -58
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TyFileUpload Web Component
|
|
3
|
-
*
|
|
4
|
-
* Drop zone + file picker primitive. Replaces `<input type="file">` with
|
|
5
|
-
* a styleable, drag-and-drop-capable equivalent that works everywhere.
|
|
6
|
-
*
|
|
7
|
-
* - Click to browse or drag-and-drop
|
|
8
|
-
* - Multiple file support
|
|
9
|
-
* - Accept filter passed to the underlying file input
|
|
10
|
-
* - Emits `change` with `{ files, names }` on every selection
|
|
11
|
-
* - Form-associated: participates in FormData and form.reset()
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* <ty-file-upload name="avatar" accept="image/*" label="Profile photo"></ty-file-upload>
|
|
15
|
-
* <ty-file-upload name="docs" multiple accept=".pdf,.docx" label="Attachments"></ty-file-upload>
|
|
16
|
-
*/
|
|
17
1
|
import { TyComponent } from "../base/ty-component.js";
|
|
18
2
|
import { ensureStyles } from "../utils/styles.js";
|
|
19
3
|
import { fileUploadStyles } from "../styles/file-upload.js";
|
|
@@ -21,421 +5,415 @@ const UPLOAD_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
|
|
|
21
5
|
const FILE_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>`;
|
|
22
6
|
const X_ICON = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>`;
|
|
23
7
|
function formatBytes(bytes) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
8
|
+
if (bytes < 1024)
|
|
9
|
+
return `${bytes} B`;
|
|
10
|
+
if (bytes < 1024 * 1024)
|
|
11
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
12
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
13
|
+
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
14
|
+
return `${(bytes / 1024 / 1024 / 1024).toFixed(1)} GB`;
|
|
31
15
|
}
|
|
32
16
|
export class TyFileUpload extends TyComponent {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
// Error message
|
|
391
|
-
const errorEl = container.querySelector(".error-message");
|
|
392
|
-
errorEl.textContent = this.error;
|
|
393
|
-
errorEl.style.display = this.error ? "" : "none";
|
|
394
|
-
}
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this._files = [];
|
|
20
|
+
this._isDragging = false;
|
|
21
|
+
this._listenersSetup = false;
|
|
22
|
+
this._dropZoneClickHandler = null;
|
|
23
|
+
this._dropZoneKeydownHandler = null;
|
|
24
|
+
this._dropZoneFocusHandler = null;
|
|
25
|
+
this._dropZoneBlurHandler = null;
|
|
26
|
+
this._dragoverHandler = null;
|
|
27
|
+
this._dragleaveHandler = null;
|
|
28
|
+
this._dropHandler = null;
|
|
29
|
+
this._inputChangeHandler = null;
|
|
30
|
+
ensureStyles(this.shadowRoot, { css: fileUploadStyles, id: "ty-file-upload" });
|
|
31
|
+
}
|
|
32
|
+
onConnect() { }
|
|
33
|
+
onDisconnect() {
|
|
34
|
+
this.removeEventListeners();
|
|
35
|
+
}
|
|
36
|
+
onPropertiesChanged(_changes) { }
|
|
37
|
+
onFormReset() {
|
|
38
|
+
this._files = [];
|
|
39
|
+
this.updateFormValue();
|
|
40
|
+
if (this._connected)
|
|
41
|
+
this.render();
|
|
42
|
+
const fileInput = this.shadowRoot?.querySelector(".file-input");
|
|
43
|
+
if (fileInput)
|
|
44
|
+
fileInput.value = "";
|
|
45
|
+
}
|
|
46
|
+
getFormValue() {
|
|
47
|
+
if (this._files.length === 0 || !this.name)
|
|
48
|
+
return null;
|
|
49
|
+
const fd = new FormData();
|
|
50
|
+
for (const file of this._files) {
|
|
51
|
+
fd.append(this.name, file);
|
|
52
|
+
}
|
|
53
|
+
return fd;
|
|
54
|
+
}
|
|
55
|
+
matchesAccept(file) {
|
|
56
|
+
const accept = this.accept?.trim();
|
|
57
|
+
if (!accept)
|
|
58
|
+
return true;
|
|
59
|
+
return accept.split(",").some((raw) => {
|
|
60
|
+
const entry = raw.trim().toLowerCase();
|
|
61
|
+
if (!entry)
|
|
62
|
+
return false;
|
|
63
|
+
if (entry.startsWith("."))
|
|
64
|
+
return file.name.toLowerCase().endsWith(entry);
|
|
65
|
+
const type = file.type.toLowerCase();
|
|
66
|
+
if (entry.endsWith("/*"))
|
|
67
|
+
return type.startsWith(entry.slice(0, -1));
|
|
68
|
+
return type === entry;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
get files() {
|
|
72
|
+
return [...this._files];
|
|
73
|
+
}
|
|
74
|
+
get multiple() {
|
|
75
|
+
return this.getProperty("multiple");
|
|
76
|
+
}
|
|
77
|
+
set multiple(v) {
|
|
78
|
+
this.setProperty("multiple", v);
|
|
79
|
+
}
|
|
80
|
+
get accept() {
|
|
81
|
+
return this.getProperty("accept");
|
|
82
|
+
}
|
|
83
|
+
set accept(v) {
|
|
84
|
+
this.setProperty("accept", v);
|
|
85
|
+
}
|
|
86
|
+
get name() {
|
|
87
|
+
return this.getProperty("name");
|
|
88
|
+
}
|
|
89
|
+
set name(v) {
|
|
90
|
+
this.setProperty("name", v);
|
|
91
|
+
}
|
|
92
|
+
get disabled() {
|
|
93
|
+
return this.getProperty("disabled");
|
|
94
|
+
}
|
|
95
|
+
set disabled(v) {
|
|
96
|
+
this.setProperty("disabled", v);
|
|
97
|
+
}
|
|
98
|
+
get required() {
|
|
99
|
+
return this.getProperty("required");
|
|
100
|
+
}
|
|
101
|
+
set required(v) {
|
|
102
|
+
this.setProperty("required", v);
|
|
103
|
+
}
|
|
104
|
+
get label() {
|
|
105
|
+
return this.getProperty("label");
|
|
106
|
+
}
|
|
107
|
+
set label(v) {
|
|
108
|
+
this.setProperty("label", v);
|
|
109
|
+
}
|
|
110
|
+
get placeholder() {
|
|
111
|
+
return this.getProperty("placeholder");
|
|
112
|
+
}
|
|
113
|
+
set placeholder(v) {
|
|
114
|
+
this.setProperty("placeholder", v);
|
|
115
|
+
}
|
|
116
|
+
get error() {
|
|
117
|
+
return this.getProperty("error");
|
|
118
|
+
}
|
|
119
|
+
set error(v) {
|
|
120
|
+
this.setProperty("error", v);
|
|
121
|
+
}
|
|
122
|
+
get form() {
|
|
123
|
+
return this._internals.form;
|
|
124
|
+
}
|
|
125
|
+
setFiles(newFiles) {
|
|
126
|
+
this._files = this.multiple ? newFiles : newFiles.slice(0, 1);
|
|
127
|
+
this.updateFormValue();
|
|
128
|
+
this.render();
|
|
129
|
+
const detail = {
|
|
130
|
+
value: this._files,
|
|
131
|
+
files: this._files,
|
|
132
|
+
names: this._files.map((f) => f.name),
|
|
133
|
+
};
|
|
134
|
+
setTimeout(() => {
|
|
135
|
+
this.dispatchEvent(new CustomEvent("change", { detail, bubbles: true, composed: true }));
|
|
136
|
+
}, 0);
|
|
137
|
+
}
|
|
138
|
+
removeFile(index) {
|
|
139
|
+
const updated = [...this._files];
|
|
140
|
+
updated.splice(index, 1);
|
|
141
|
+
this.setFiles(updated);
|
|
142
|
+
const fileInput = this.shadowRoot?.querySelector(".file-input");
|
|
143
|
+
if (fileInput)
|
|
144
|
+
fileInput.value = "";
|
|
145
|
+
}
|
|
146
|
+
setupEventListeners() {
|
|
147
|
+
if (this._listenersSetup)
|
|
148
|
+
return;
|
|
149
|
+
const shadow = this.shadowRoot;
|
|
150
|
+
const dropZone = shadow.querySelector(".drop-zone");
|
|
151
|
+
const fileInput = shadow.querySelector(".file-input");
|
|
152
|
+
this._dropZoneClickHandler = (e) => {
|
|
153
|
+
if (this.disabled)
|
|
154
|
+
return;
|
|
155
|
+
if (e.target.closest(".file-remove"))
|
|
156
|
+
return;
|
|
157
|
+
fileInput.click();
|
|
158
|
+
};
|
|
159
|
+
this._dropZoneKeydownHandler = (e) => {
|
|
160
|
+
if (this.disabled)
|
|
161
|
+
return;
|
|
162
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
fileInput.click();
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this._dropZoneFocusHandler = () => {
|
|
168
|
+
dropZone.classList.add("focused");
|
|
169
|
+
};
|
|
170
|
+
this._dropZoneBlurHandler = () => {
|
|
171
|
+
dropZone.classList.remove("focused");
|
|
172
|
+
};
|
|
173
|
+
this._dragoverHandler = (e) => {
|
|
174
|
+
if (this.disabled)
|
|
175
|
+
return;
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
e.stopPropagation();
|
|
178
|
+
if (!this._isDragging) {
|
|
179
|
+
this._isDragging = true;
|
|
180
|
+
dropZone.classList.add("drag-active");
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
this._dragleaveHandler = (e) => {
|
|
184
|
+
if (!dropZone.contains(e.relatedTarget)) {
|
|
185
|
+
this._isDragging = false;
|
|
186
|
+
dropZone.classList.remove("drag-active");
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
this._dropHandler = (e) => {
|
|
190
|
+
if (this.disabled)
|
|
191
|
+
return;
|
|
192
|
+
e.preventDefault();
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
this._isDragging = false;
|
|
195
|
+
dropZone.classList.remove("drag-active");
|
|
196
|
+
const files = Array.from(e.dataTransfer?.files ?? []).filter((f) => this.matchesAccept(f));
|
|
197
|
+
if (files.length > 0)
|
|
198
|
+
this.setFiles(files);
|
|
199
|
+
};
|
|
200
|
+
this._inputChangeHandler = (e) => {
|
|
201
|
+
const input = e.target;
|
|
202
|
+
if (input.files && input.files.length > 0) {
|
|
203
|
+
this.setFiles(Array.from(input.files));
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
dropZone.addEventListener("click", this._dropZoneClickHandler);
|
|
207
|
+
dropZone.addEventListener("keydown", this._dropZoneKeydownHandler);
|
|
208
|
+
dropZone.addEventListener("focus", this._dropZoneFocusHandler);
|
|
209
|
+
dropZone.addEventListener("blur", this._dropZoneBlurHandler);
|
|
210
|
+
dropZone.addEventListener("dragover", this._dragoverHandler);
|
|
211
|
+
dropZone.addEventListener("dragleave", this._dragleaveHandler);
|
|
212
|
+
dropZone.addEventListener("drop", this._dropHandler);
|
|
213
|
+
fileInput.addEventListener("change", this._inputChangeHandler);
|
|
214
|
+
this._listenersSetup = true;
|
|
215
|
+
}
|
|
216
|
+
removeEventListeners() {
|
|
217
|
+
if (!this._listenersSetup)
|
|
218
|
+
return;
|
|
219
|
+
const shadow = this.shadowRoot;
|
|
220
|
+
if (!shadow)
|
|
221
|
+
return;
|
|
222
|
+
const dropZone = shadow.querySelector(".drop-zone");
|
|
223
|
+
const fileInput = shadow.querySelector(".file-input");
|
|
224
|
+
if (!dropZone || !fileInput)
|
|
225
|
+
return;
|
|
226
|
+
if (this._dropZoneClickHandler)
|
|
227
|
+
dropZone.removeEventListener("click", this._dropZoneClickHandler);
|
|
228
|
+
if (this._dropZoneKeydownHandler)
|
|
229
|
+
dropZone.removeEventListener("keydown", this._dropZoneKeydownHandler);
|
|
230
|
+
if (this._dropZoneFocusHandler)
|
|
231
|
+
dropZone.removeEventListener("focus", this._dropZoneFocusHandler);
|
|
232
|
+
if (this._dropZoneBlurHandler)
|
|
233
|
+
dropZone.removeEventListener("blur", this._dropZoneBlurHandler);
|
|
234
|
+
if (this._dragoverHandler)
|
|
235
|
+
dropZone.removeEventListener("dragover", this._dragoverHandler);
|
|
236
|
+
if (this._dragleaveHandler)
|
|
237
|
+
dropZone.removeEventListener("dragleave", this._dragleaveHandler);
|
|
238
|
+
if (this._dropHandler)
|
|
239
|
+
dropZone.removeEventListener("drop", this._dropHandler);
|
|
240
|
+
if (this._inputChangeHandler)
|
|
241
|
+
fileInput.removeEventListener("change", this._inputChangeHandler);
|
|
242
|
+
this._listenersSetup = false;
|
|
243
|
+
}
|
|
244
|
+
buildDropZoneClasses() {
|
|
245
|
+
const classes = ["drop-zone"];
|
|
246
|
+
if (this._isDragging)
|
|
247
|
+
classes.push("drag-active");
|
|
248
|
+
if (this._files.length > 0)
|
|
249
|
+
classes.push("has-files");
|
|
250
|
+
if (this.disabled)
|
|
251
|
+
classes.push("disabled");
|
|
252
|
+
if (this.error)
|
|
253
|
+
classes.push("error");
|
|
254
|
+
return classes.join(" ");
|
|
255
|
+
}
|
|
256
|
+
renderFileList(fileList) {
|
|
257
|
+
fileList.innerHTML = "";
|
|
258
|
+
for (let i = 0; i < this._files.length; i++) {
|
|
259
|
+
const file = this._files[i];
|
|
260
|
+
const item = document.createElement("div");
|
|
261
|
+
item.className = "file-item";
|
|
262
|
+
const icon = document.createElement("span");
|
|
263
|
+
icon.className = "file-icon";
|
|
264
|
+
icon.innerHTML = FILE_ICON;
|
|
265
|
+
const name = document.createElement("span");
|
|
266
|
+
name.className = "file-name";
|
|
267
|
+
name.textContent = file.name;
|
|
268
|
+
name.title = file.name;
|
|
269
|
+
const size = document.createElement("span");
|
|
270
|
+
size.className = "file-size";
|
|
271
|
+
size.textContent = formatBytes(file.size);
|
|
272
|
+
const removeBtn = document.createElement("button");
|
|
273
|
+
removeBtn.className = "file-remove";
|
|
274
|
+
removeBtn.type = "button";
|
|
275
|
+
removeBtn.innerHTML = X_ICON;
|
|
276
|
+
removeBtn.setAttribute("aria-label", `Remove ${file.name}`);
|
|
277
|
+
const capturedIndex = i;
|
|
278
|
+
removeBtn.addEventListener("click", (e) => {
|
|
279
|
+
e.stopPropagation();
|
|
280
|
+
this.removeFile(capturedIndex);
|
|
281
|
+
});
|
|
282
|
+
item.appendChild(icon);
|
|
283
|
+
item.appendChild(name);
|
|
284
|
+
item.appendChild(size);
|
|
285
|
+
item.appendChild(removeBtn);
|
|
286
|
+
fileList.appendChild(item);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
render() {
|
|
290
|
+
const shadow = this.shadowRoot;
|
|
291
|
+
let container = shadow.querySelector(".file-upload-container");
|
|
292
|
+
if (!container) {
|
|
293
|
+
container = document.createElement("div");
|
|
294
|
+
container.className = "file-upload-container";
|
|
295
|
+
const labelEl = document.createElement("div");
|
|
296
|
+
labelEl.className = "upload-label";
|
|
297
|
+
container.appendChild(labelEl);
|
|
298
|
+
const dropZone = document.createElement("div");
|
|
299
|
+
dropZone.className = "drop-zone";
|
|
300
|
+
dropZone.setAttribute("role", "button");
|
|
301
|
+
const fileInput = document.createElement("input");
|
|
302
|
+
fileInput.type = "file";
|
|
303
|
+
fileInput.className = "file-input";
|
|
304
|
+
fileInput.style.display = "none";
|
|
305
|
+
dropZone.appendChild(fileInput);
|
|
306
|
+
const uploadIcon = document.createElement("div");
|
|
307
|
+
uploadIcon.className = "upload-icon";
|
|
308
|
+
uploadIcon.innerHTML = UPLOAD_ICON;
|
|
309
|
+
dropZone.appendChild(uploadIcon);
|
|
310
|
+
const hintEl = document.createElement("div");
|
|
311
|
+
hintEl.className = "upload-hint";
|
|
312
|
+
dropZone.appendChild(hintEl);
|
|
313
|
+
const subHintEl = document.createElement("div");
|
|
314
|
+
subHintEl.className = "upload-sub-hint";
|
|
315
|
+
dropZone.appendChild(subHintEl);
|
|
316
|
+
container.appendChild(dropZone);
|
|
317
|
+
const fileList = document.createElement("div");
|
|
318
|
+
fileList.className = "file-list";
|
|
319
|
+
container.appendChild(fileList);
|
|
320
|
+
const errorEl = document.createElement("div");
|
|
321
|
+
errorEl.className = "error-message";
|
|
322
|
+
container.appendChild(errorEl);
|
|
323
|
+
shadow.appendChild(container);
|
|
324
|
+
this.setupEventListeners();
|
|
325
|
+
}
|
|
326
|
+
const labelEl = container.querySelector(".upload-label");
|
|
327
|
+
if (this.label) {
|
|
328
|
+
labelEl.style.display = "";
|
|
329
|
+
labelEl.innerHTML = "";
|
|
330
|
+
labelEl.appendChild(document.createTextNode(this.label));
|
|
331
|
+
if (this.required) {
|
|
332
|
+
const req = document.createElement("span");
|
|
333
|
+
req.className = "required-icon";
|
|
334
|
+
req.textContent = "*";
|
|
335
|
+
req.setAttribute("aria-hidden", "true");
|
|
336
|
+
labelEl.appendChild(req);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
labelEl.style.display = "none";
|
|
341
|
+
}
|
|
342
|
+
const dropZone = container.querySelector(".drop-zone");
|
|
343
|
+
dropZone.className = this.buildDropZoneClasses();
|
|
344
|
+
dropZone.tabIndex = this.disabled ? -1 : 0;
|
|
345
|
+
dropZone.setAttribute("aria-disabled", String(this.disabled));
|
|
346
|
+
dropZone.setAttribute("aria-label", this.placeholder || "Upload files");
|
|
347
|
+
const fileInput = container.querySelector(".file-input");
|
|
348
|
+
fileInput.multiple = this.multiple;
|
|
349
|
+
fileInput.accept = this.accept;
|
|
350
|
+
fileInput.disabled = this.disabled;
|
|
351
|
+
const uploadIcon = container.querySelector(".upload-icon");
|
|
352
|
+
uploadIcon.style.display = this._files.length > 0 ? "none" : "";
|
|
353
|
+
const hintEl = container.querySelector(".upload-hint");
|
|
354
|
+
if (this._files.length > 0) {
|
|
355
|
+
hintEl.innerHTML = `<strong>${this._files.length} file${this._files.length !== 1 ? "s" : ""} selected</strong>`;
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
hintEl.innerHTML = `Drop files here or <span class="browse-link">click to browse</span>`;
|
|
359
|
+
}
|
|
360
|
+
const subHintEl = container.querySelector(".upload-sub-hint");
|
|
361
|
+
if (this.accept && this._files.length === 0) {
|
|
362
|
+
subHintEl.textContent = `Accepted: ${this.accept}`;
|
|
363
|
+
subHintEl.style.display = "";
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
subHintEl.style.display = "none";
|
|
367
|
+
}
|
|
368
|
+
const fileList = container.querySelector(".file-list");
|
|
369
|
+
this.renderFileList(fileList);
|
|
370
|
+
const errorEl = container.querySelector(".error-message");
|
|
371
|
+
errorEl.textContent = this.error;
|
|
372
|
+
errorEl.style.display = this.error ? "" : "none";
|
|
373
|
+
}
|
|
395
374
|
}
|
|
396
375
|
TyFileUpload.formAssociated = true;
|
|
397
376
|
TyFileUpload.properties = {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
377
|
+
multiple: {
|
|
378
|
+
type: "boolean",
|
|
379
|
+
visual: true,
|
|
380
|
+
default: false,
|
|
381
|
+
},
|
|
382
|
+
accept: {
|
|
383
|
+
type: "string",
|
|
384
|
+
visual: true,
|
|
385
|
+
default: "",
|
|
386
|
+
},
|
|
387
|
+
name: {
|
|
388
|
+
type: "string",
|
|
389
|
+
default: "",
|
|
390
|
+
},
|
|
391
|
+
disabled: {
|
|
392
|
+
type: "boolean",
|
|
393
|
+
visual: true,
|
|
394
|
+
default: false,
|
|
395
|
+
},
|
|
396
|
+
required: {
|
|
397
|
+
type: "boolean",
|
|
398
|
+
visual: true,
|
|
399
|
+
default: false,
|
|
400
|
+
},
|
|
401
|
+
label: {
|
|
402
|
+
type: "string",
|
|
403
|
+
visual: true,
|
|
404
|
+
default: "",
|
|
405
|
+
},
|
|
406
|
+
placeholder: {
|
|
407
|
+
type: "string",
|
|
408
|
+
visual: true,
|
|
409
|
+
default: "Drop files here or click to browse",
|
|
410
|
+
},
|
|
411
|
+
error: {
|
|
412
|
+
type: "string",
|
|
413
|
+
visual: true,
|
|
414
|
+
default: "",
|
|
415
|
+
},
|
|
437
416
|
};
|
|
438
417
|
if (!customElements.get("ty-file-upload")) {
|
|
439
|
-
|
|
418
|
+
customElements.define("ty-file-upload", TyFileUpload);
|
|
440
419
|
}
|
|
441
|
-
//# sourceMappingURL=file-upload.js.map
|