@mozaic-ds/web-components 0.4.1-beta.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/ClickOutside-63071e7a.js +15 -1
- package/public/ClickOutside-63071e7a.js.map +1 -1
- package/public/DataTableDefaultAction.nested-4da4dc44.js +759 -1
- package/public/DataTableDefaultAction.nested-4da4dc44.js.map +1 -1
- package/public/DataTableUtilities-60220c78.js +370 -1
- package/public/DataTableUtilities-60220c78.js.map +1 -1
- package/public/EventForward-8492ff62.js +109 -1
- package/public/EventForward-8492ff62.js.map +1 -1
- package/public/EventHandler-02058705.js +15 -1
- package/public/EventHandler-02058705.js.map +1 -1
- package/public/array-5b770a93.js +13 -1
- package/public/array-5b770a93.js.map +1 -1
- package/public/axis-fbc0f7b5.js +174 -1
- package/public/axis-fbc0f7b5.js.map +1 -1
- package/public/band-d7a07d2c.js +186 -1
- package/public/band-d7a07d2c.js.map +1 -1
- package/public/components/accordion/Accordion.js +365 -1
- package/public/components/accordion/Accordion.js.map +1 -1
- package/public/components/autocomplete/Autocomplete.js +1515 -1
- package/public/components/autocomplete/Autocomplete.js.map +1 -1
- package/public/components/badge/Badge.js +155 -1
- package/public/components/badge/Badge.js.map +1 -1
- package/public/components/badge/Badge.nested.js +101 -1
- package/public/components/badge/Badge.nested.js.map +1 -1
- package/public/components/breadcrumb/Breadcrumb.js +372 -1
- package/public/components/breadcrumb/Breadcrumb.js.map +1 -1
- package/public/components/breadcrumb/Breadcrumb.nested.js +319 -1
- package/public/components/breadcrumb/Breadcrumb.nested.js.map +1 -1
- package/public/components/button/Button.js +1138 -1
- package/public/components/button/Button.js.map +1 -1
- package/public/components/card/Card.js +369 -1
- package/public/components/card/Card.js.map +1 -1
- package/public/components/chart/BarChart.js +582 -1
- package/public/components/chart/BarChart.js.map +1 -1
- package/public/components/chart/Donut.js +1189 -1
- package/public/components/chart/Donut.js.map +1 -1
- package/public/components/chart/GroupedBarChart.js +750 -1
- package/public/components/chart/GroupedBarChart.js.map +1 -1
- package/public/components/chart/LineChart.js +1731 -1
- package/public/components/chart/LineChart.js.map +1 -1
- package/public/components/chart/Radar.js +729 -1
- package/public/components/chart/Radar.js.map +1 -1
- package/public/components/chart/StackedBarChart.js +745 -1
- package/public/components/chart/StackedBarChart.js.map +1 -1
- package/public/components/checkbox/Checkbox.js +307 -1
- package/public/components/checkbox/Checkbox.js.map +1 -1
- package/public/components/checkboxgroup/checkboxGroup.js +404 -1
- package/public/components/checkboxgroup/checkboxGroup.js.map +1 -1
- package/public/components/datatable/DataTable.js +3064 -1
- package/public/components/datatable/DataTable.js.map +1 -1
- package/public/components/datatable/DataTableDefaultAction.nested.js +4 -1
- package/public/components/datatable/DataTableDefaultAction.nested.js.map +1 -1
- package/public/components/datatable/DataTableDefaultEdtion.nested.js +164 -1
- package/public/components/datatable/DataTableDefaultEdtion.nested.js.map +1 -1
- package/public/components/datatable/DataTableDefaultFilterTags.nested.js +380 -1
- package/public/components/datatable/DataTableDefaultFilterTags.nested.js.map +1 -1
- package/public/components/datatable/DataTableDefaultSelection.nested.js +424 -1
- package/public/components/datatable/DataTableDefaultSelection.nested.js.map +1 -1
- package/public/components/datatable/DataTableDefaultSelectionLabel.nested.js +263 -1
- package/public/components/datatable/DataTableDefaultSelectionLabel.nested.js.map +1 -1
- package/public/components/datatable/DataTableFooter.nested.js +637 -1
- package/public/components/datatable/DataTableFooter.nested.js.map +1 -1
- package/public/components/dropdown/Dropdown.js +1426 -1
- package/public/components/dropdown/Dropdown.js.map +1 -1
- package/public/components/field/Field.js +375 -1
- package/public/components/field/Field.js.map +1 -1
- package/public/components/fileuploader/FileUploader.js +555 -1
- package/public/components/fileuploader/FileUploader.js.map +1 -1
- package/public/components/fileuploader/ResultFile.nested.js +265 -1
- package/public/components/fileuploader/ResultFile.nested.js.map +1 -1
- package/public/components/flag/Flag.js +174 -1
- package/public/components/flag/Flag.js.map +1 -1
- package/public/components/header/Header.js +903 -1
- package/public/components/header/Header.js.map +1 -1
- package/public/components/hero/Hero.js +271 -1
- package/public/components/hero/Hero.js.map +1 -1
- package/public/components/layer/Layer.js +453 -1
- package/public/components/layer/Layer.js.map +1 -1
- package/public/components/link/Link.js +380 -1
- package/public/components/link/Link.js.map +1 -1
- package/public/components/listbox/Listbox.js +595 -1
- package/public/components/listbox/Listbox.js.map +1 -1
- package/public/components/listbox/Listbox.nested.js +629 -1
- package/public/components/listbox/Listbox.nested.js.map +1 -1
- package/public/components/loader/Loader.js +246 -1
- package/public/components/loader/Loader.js.map +1 -1
- package/public/components/loader/Loader.nested.js +176 -1
- package/public/components/loader/Loader.nested.js.map +1 -1
- package/public/components/modal/Modal.js +395 -1
- package/public/components/modal/Modal.js.map +1 -1
- package/public/components/notification/Notification.js +458 -1
- package/public/components/notification/Notification.js.map +1 -1
- package/public/components/optionbutton/OptionButton.js +316 -1
- package/public/components/optionbutton/OptionButton.js.map +1 -1
- package/public/components/overlay/Overlay.js +104 -1
- package/public/components/overlay/Overlay.js.map +1 -1
- package/public/components/overlay/OverlayLoader.js +151 -1
- package/public/components/overlay/OverlayLoader.js.map +1 -1
- package/public/components/pagination/Pagination.js +613 -1
- package/public/components/pagination/Pagination.js.map +1 -1
- package/public/components/passwordinput/PasswordInput.js +291 -1
- package/public/components/passwordinput/PasswordInput.js.map +1 -1
- package/public/components/phonenumber/PhoneNumber.js +6894 -1
- package/public/components/phonenumber/PhoneNumber.js.map +1 -1
- package/public/components/phonenumber/PhoneNumber.svelte +72 -9
- package/public/components/price/Price.js +768 -1
- package/public/components/price/Price.js.map +1 -1
- package/public/components/progressbar/ProgressBar.js +278 -1
- package/public/components/progressbar/ProgressBar.js.map +1 -1
- package/public/components/quantityselector/QuantitySelector.js +333 -1
- package/public/components/quantityselector/QuantitySelector.js.map +1 -1
- package/public/components/radio/Radio.js +273 -1
- package/public/components/radio/Radio.js.map +1 -1
- package/public/components/radiogroup/RadioGroup.js +414 -1
- package/public/components/radiogroup/RadioGroup.js.map +1 -1
- package/public/components/ratings/StarsInput.js +292 -1
- package/public/components/ratings/StarsInput.js.map +1 -1
- package/public/components/ratings/StarsResult.js +246 -1
- package/public/components/ratings/StarsResult.js.map +1 -1
- package/public/components/select/Select.js +451 -1
- package/public/components/select/Select.js.map +1 -1
- package/public/components/sidebar/Sidebar.js +784 -1
- package/public/components/sidebar/Sidebar.js.map +1 -1
- package/public/components/sidebar/sidebar-feature-group.nested.js +594 -1
- package/public/components/sidebar/sidebar-feature-group.nested.js.map +1 -1
- package/public/components/sidebar/sidebar-feature.nested.js +402 -1
- package/public/components/sidebar/sidebar-feature.nested.js.map +1 -1
- package/public/components/sidebar/sidebar-section.nested.js +394 -1
- package/public/components/sidebar/sidebar-section.nested.js.map +1 -1
- package/public/components/sidebar/sidebar-segment.nested.js +200 -1
- package/public/components/sidebar/sidebar-segment.nested.js.map +1 -1
- package/public/components/sidebar/sidebar-separator.nested.js +49 -1
- package/public/components/sidebar/sidebar-separator.nested.js.map +1 -1
- package/public/components/sidebar/sidebar-sub-features.nested.js +312 -1
- package/public/components/sidebar/sidebar-sub-features.nested.js.map +1 -1
- package/public/components/sidebar/sidebar-user.nested.js +733 -1
- package/public/components/sidebar/sidebar-user.nested.js.map +1 -1
- package/public/components/stepper/Stepper.js +371 -1
- package/public/components/stepper/Stepper.js.map +1 -1
- package/public/components/tabs/Tabs.js +615 -1
- package/public/components/tabs/Tabs.js.map +1 -1
- package/public/components/tabs/Tabs.nested.js +472 -1
- package/public/components/tabs/Tabs.nested.js.map +1 -1
- package/public/components/tag/Tag.js +665 -1
- package/public/components/tag/Tag.js.map +1 -1
- package/public/components/tag/Tag.nested.js +554 -1
- package/public/components/tag/Tag.nested.js.map +1 -1
- package/public/components/taglist/TagList.js +475 -1
- package/public/components/taglist/TagList.js.map +1 -1
- package/public/components/textarea/Textarea.js +303 -1
- package/public/components/textarea/Textarea.js.map +1 -1
- package/public/components/textinput/Textinput.js +497 -1
- package/public/components/textinput/Textinput.js.map +1 -1
- package/public/components/textinput/Textinput.nested.js +320 -1
- package/public/components/textinput/Textinput.nested.js.map +1 -1
- package/public/components/toggle/Toggle.js +278 -1
- package/public/components/toggle/Toggle.js.map +1 -1
- package/public/components/tooltip/Tooltip.js +173 -1
- package/public/components/tooltip/Tooltip.js.map +1 -1
- package/public/index-c33b3772.js +873 -1
- package/public/index-c33b3772.js.map +1 -1
- package/public/linear-f46d7e9e.js +700 -1
- package/public/linear-f46d7e9e.js.map +1 -1
- package/public/path-1b5da959.js +186 -1
- package/public/path-1b5da959.js.map +1 -1
- package/public/sidebar-service-275bf9ef.js +129 -1
- package/public/sidebar-service-275bf9ef.js.map +1 -1
- package/public/symbol-b05a6e2b.js +169 -1
- package/public/symbol-b05a6e2b.js.map +1 -1
- package/public/transform-15d69d5d.js +2743 -1
- package/public/transform-15d69d5d.js.map +1 -1
- package/public/utilities/stories/phonenumber/PhoneNumber.stories.d.ts.map +1 -1
|
@@ -1,2 +1,556 @@
|
|
|
1
|
-
import{S as
|
|
1
|
+
import { S as SvelteElement, i as init, a as attribute_to_object, b as insert, f as flush, s as safe_not_equal, e as element, d as space, t as text, n as noop, g as attr, j as append, l as listen, k as set_data, C as transition_in, D as transition_out, E as check_outros, o as detach, x as create_component, A as mount_component, G as destroy_component, M as group_outros, v as binding_callbacks } from '../../index-c33b3772.js';
|
|
2
|
+
import { E as EventHandler } from '../../EventHandler-02058705.js';
|
|
3
|
+
import ResultFile_nested from './ResultFile.nested.js';
|
|
4
|
+
|
|
5
|
+
/* src/components/fileuploader/FileUploader.svelte generated by Svelte v3.58.0 */
|
|
6
|
+
|
|
7
|
+
function create_if_block_1(ctx) {
|
|
8
|
+
let resultfile;
|
|
9
|
+
let current;
|
|
10
|
+
|
|
11
|
+
resultfile = new ResultFile_nested({
|
|
12
|
+
props: {
|
|
13
|
+
files: /*files*/ ctx[7],
|
|
14
|
+
allowedExtensions: /*allowedExtensions*/ ctx[10],
|
|
15
|
+
disabled: /*disabled*/ ctx[5],
|
|
16
|
+
maxSize: /*maxSize*/ ctx[11],
|
|
17
|
+
removelabel: /*removelabel*/ ctx[6]
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
resultfile.$on("file-removed", /*deleteFile*/ ctx[13]);
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
c() {
|
|
25
|
+
create_component(resultfile.$$.fragment);
|
|
26
|
+
},
|
|
27
|
+
m(target, anchor) {
|
|
28
|
+
mount_component(resultfile, target, anchor);
|
|
29
|
+
current = true;
|
|
30
|
+
},
|
|
31
|
+
p(ctx, dirty) {
|
|
32
|
+
const resultfile_changes = {};
|
|
33
|
+
if (dirty & /*files*/ 128) resultfile_changes.files = /*files*/ ctx[7];
|
|
34
|
+
if (dirty & /*allowedExtensions*/ 1024) resultfile_changes.allowedExtensions = /*allowedExtensions*/ ctx[10];
|
|
35
|
+
if (dirty & /*disabled*/ 32) resultfile_changes.disabled = /*disabled*/ ctx[5];
|
|
36
|
+
if (dirty & /*maxSize*/ 2048) resultfile_changes.maxSize = /*maxSize*/ ctx[11];
|
|
37
|
+
if (dirty & /*removelabel*/ 64) resultfile_changes.removelabel = /*removelabel*/ ctx[6];
|
|
38
|
+
resultfile.$set(resultfile_changes);
|
|
39
|
+
},
|
|
40
|
+
i(local) {
|
|
41
|
+
if (current) return;
|
|
42
|
+
transition_in(resultfile.$$.fragment, local);
|
|
43
|
+
current = true;
|
|
44
|
+
},
|
|
45
|
+
o(local) {
|
|
46
|
+
transition_out(resultfile.$$.fragment, local);
|
|
47
|
+
current = false;
|
|
48
|
+
},
|
|
49
|
+
d(detaching) {
|
|
50
|
+
destroy_component(resultfile, detaching);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// (126:2) {#if uploadedFiles.length > 0}
|
|
56
|
+
function create_if_block(ctx) {
|
|
57
|
+
let resultfile;
|
|
58
|
+
let current;
|
|
59
|
+
|
|
60
|
+
resultfile = new ResultFile_nested({
|
|
61
|
+
props: {
|
|
62
|
+
files: /*uploadedFiles*/ ctx[9],
|
|
63
|
+
allowedExtensions: /*allowedExtensions*/ ctx[10],
|
|
64
|
+
disabled: /*disabled*/ ctx[5],
|
|
65
|
+
maxSize: /*maxSize*/ ctx[11],
|
|
66
|
+
removelabel: /*removelabel*/ ctx[6]
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
resultfile.$on("file-removed", /*deleteFile*/ ctx[13]);
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
c() {
|
|
74
|
+
create_component(resultfile.$$.fragment);
|
|
75
|
+
},
|
|
76
|
+
m(target, anchor) {
|
|
77
|
+
mount_component(resultfile, target, anchor);
|
|
78
|
+
current = true;
|
|
79
|
+
},
|
|
80
|
+
p(ctx, dirty) {
|
|
81
|
+
const resultfile_changes = {};
|
|
82
|
+
if (dirty & /*uploadedFiles*/ 512) resultfile_changes.files = /*uploadedFiles*/ ctx[9];
|
|
83
|
+
if (dirty & /*allowedExtensions*/ 1024) resultfile_changes.allowedExtensions = /*allowedExtensions*/ ctx[10];
|
|
84
|
+
if (dirty & /*disabled*/ 32) resultfile_changes.disabled = /*disabled*/ ctx[5];
|
|
85
|
+
if (dirty & /*maxSize*/ 2048) resultfile_changes.maxSize = /*maxSize*/ ctx[11];
|
|
86
|
+
if (dirty & /*removelabel*/ 64) resultfile_changes.removelabel = /*removelabel*/ ctx[6];
|
|
87
|
+
resultfile.$set(resultfile_changes);
|
|
88
|
+
},
|
|
89
|
+
i(local) {
|
|
90
|
+
if (current) return;
|
|
91
|
+
transition_in(resultfile.$$.fragment, local);
|
|
92
|
+
current = true;
|
|
93
|
+
},
|
|
94
|
+
o(local) {
|
|
95
|
+
transition_out(resultfile.$$.fragment, local);
|
|
96
|
+
current = false;
|
|
97
|
+
},
|
|
98
|
+
d(detaching) {
|
|
99
|
+
destroy_component(resultfile, detaching);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function create_fragment(ctx) {
|
|
105
|
+
let div;
|
|
106
|
+
let input;
|
|
107
|
+
let t0;
|
|
108
|
+
let label_1;
|
|
109
|
+
let span;
|
|
110
|
+
let t1;
|
|
111
|
+
let t2;
|
|
112
|
+
let t3;
|
|
113
|
+
let current;
|
|
114
|
+
let mounted;
|
|
115
|
+
let dispose;
|
|
116
|
+
let if_block0 = /*displayfileslist*/ ctx[0] && /*files*/ ctx[7].length > 0 && create_if_block_1(ctx);
|
|
117
|
+
let if_block1 = /*uploadedFiles*/ ctx[9].length > 0 && create_if_block(ctx);
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
c() {
|
|
121
|
+
div = element("div");
|
|
122
|
+
input = element("input");
|
|
123
|
+
t0 = space();
|
|
124
|
+
label_1 = element("label");
|
|
125
|
+
span = element("span");
|
|
126
|
+
t1 = text(/*label*/ ctx[2]);
|
|
127
|
+
t2 = space();
|
|
128
|
+
if (if_block0) if_block0.c();
|
|
129
|
+
t3 = space();
|
|
130
|
+
if (if_block1) if_block1.c();
|
|
131
|
+
this.c = noop;
|
|
132
|
+
attr(input, "id", /*id*/ ctx[1]);
|
|
133
|
+
attr(input, "type", "file");
|
|
134
|
+
attr(input, "class", "mc-fileuploader__input");
|
|
135
|
+
attr(input, "accept", /*accept*/ ctx[3]);
|
|
136
|
+
input.multiple = /*multiple*/ ctx[4];
|
|
137
|
+
input.disabled = /*disabled*/ ctx[5];
|
|
138
|
+
attr(span, "class", "mc-fileuploader__label--center");
|
|
139
|
+
attr(label_1, "for", /*id*/ ctx[1]);
|
|
140
|
+
attr(label_1, "class", "mc-fileuploader__label");
|
|
141
|
+
attr(div, "class", "mc-fileuploader");
|
|
142
|
+
},
|
|
143
|
+
m(target, anchor) {
|
|
144
|
+
insert(target, div, anchor);
|
|
145
|
+
append(div, input);
|
|
146
|
+
append(div, t0);
|
|
147
|
+
append(div, label_1);
|
|
148
|
+
append(label_1, span);
|
|
149
|
+
append(span, t1);
|
|
150
|
+
append(div, t2);
|
|
151
|
+
if (if_block0) if_block0.m(div, null);
|
|
152
|
+
append(div, t3);
|
|
153
|
+
if (if_block1) if_block1.m(div, null);
|
|
154
|
+
/*div_binding*/ ctx[17](div);
|
|
155
|
+
current = true;
|
|
156
|
+
|
|
157
|
+
if (!mounted) {
|
|
158
|
+
dispose = listen(input, "change", /*handleChange*/ ctx[12]);
|
|
159
|
+
mounted = true;
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
p(ctx, [dirty]) {
|
|
163
|
+
if (!current || dirty & /*id*/ 2) {
|
|
164
|
+
attr(input, "id", /*id*/ ctx[1]);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!current || dirty & /*accept*/ 8) {
|
|
168
|
+
attr(input, "accept", /*accept*/ ctx[3]);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!current || dirty & /*multiple*/ 16) {
|
|
172
|
+
input.multiple = /*multiple*/ ctx[4];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!current || dirty & /*disabled*/ 32) {
|
|
176
|
+
input.disabled = /*disabled*/ ctx[5];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (!current || dirty & /*label*/ 4) set_data(t1, /*label*/ ctx[2]);
|
|
180
|
+
|
|
181
|
+
if (!current || dirty & /*id*/ 2) {
|
|
182
|
+
attr(label_1, "for", /*id*/ ctx[1]);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (/*displayfileslist*/ ctx[0] && /*files*/ ctx[7].length > 0) {
|
|
186
|
+
if (if_block0) {
|
|
187
|
+
if_block0.p(ctx, dirty);
|
|
188
|
+
|
|
189
|
+
if (dirty & /*displayfileslist, files*/ 129) {
|
|
190
|
+
transition_in(if_block0, 1);
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
if_block0 = create_if_block_1(ctx);
|
|
194
|
+
if_block0.c();
|
|
195
|
+
transition_in(if_block0, 1);
|
|
196
|
+
if_block0.m(div, t3);
|
|
197
|
+
}
|
|
198
|
+
} else if (if_block0) {
|
|
199
|
+
group_outros();
|
|
200
|
+
|
|
201
|
+
transition_out(if_block0, 1, 1, () => {
|
|
202
|
+
if_block0 = null;
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
check_outros();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (/*uploadedFiles*/ ctx[9].length > 0) {
|
|
209
|
+
if (if_block1) {
|
|
210
|
+
if_block1.p(ctx, dirty);
|
|
211
|
+
|
|
212
|
+
if (dirty & /*uploadedFiles*/ 512) {
|
|
213
|
+
transition_in(if_block1, 1);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
if_block1 = create_if_block(ctx);
|
|
217
|
+
if_block1.c();
|
|
218
|
+
transition_in(if_block1, 1);
|
|
219
|
+
if_block1.m(div, null);
|
|
220
|
+
}
|
|
221
|
+
} else if (if_block1) {
|
|
222
|
+
group_outros();
|
|
223
|
+
|
|
224
|
+
transition_out(if_block1, 1, 1, () => {
|
|
225
|
+
if_block1 = null;
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
check_outros();
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
i(local) {
|
|
232
|
+
if (current) return;
|
|
233
|
+
transition_in(if_block0);
|
|
234
|
+
transition_in(if_block1);
|
|
235
|
+
current = true;
|
|
236
|
+
},
|
|
237
|
+
o(local) {
|
|
238
|
+
transition_out(if_block0);
|
|
239
|
+
transition_out(if_block1);
|
|
240
|
+
current = false;
|
|
241
|
+
},
|
|
242
|
+
d(detaching) {
|
|
243
|
+
if (detaching) detach(div);
|
|
244
|
+
if (if_block0) if_block0.d();
|
|
245
|
+
if (if_block1) if_block1.d();
|
|
246
|
+
/*div_binding*/ ctx[17](null);
|
|
247
|
+
mounted = false;
|
|
248
|
+
dispose();
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function removeFromArray(fileList, value) {
|
|
254
|
+
const array = Array.from(fileList);
|
|
255
|
+
const idx = array.indexOf(value);
|
|
256
|
+
|
|
257
|
+
if (idx !== -1) {
|
|
258
|
+
array.splice(idx, 1);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return array;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function instance($$self, $$props, $$invalidate) {
|
|
265
|
+
let allowedExtensions;
|
|
266
|
+
let uploadedFiles;
|
|
267
|
+
let maxSize;
|
|
268
|
+
let { id } = $$props;
|
|
269
|
+
let { label } = $$props;
|
|
270
|
+
let { accept } = $$props;
|
|
271
|
+
let { multiple = true } = $$props;
|
|
272
|
+
let { allowedextensions } = $$props;
|
|
273
|
+
let { maxsize } = $$props;
|
|
274
|
+
let { displayfileslist = false } = $$props;
|
|
275
|
+
let { disabled = false } = $$props;
|
|
276
|
+
let { removelabel = 'Remove' } = $$props;
|
|
277
|
+
let { uploadedfiles } = $$props;
|
|
278
|
+
let files;
|
|
279
|
+
let root;
|
|
280
|
+
let eventHandler = new EventHandler();
|
|
281
|
+
|
|
282
|
+
function checkFileSize(fileSize) {
|
|
283
|
+
const fileSizeMB = fileSize / 1024 / 1024;
|
|
284
|
+
|
|
285
|
+
if (maxSize && fileSizeMB > maxSize) {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function checkFileExtension(fileName) {
|
|
293
|
+
if (allowedExtensions && allowedExtensions.length > 0) {
|
|
294
|
+
const extension = fileName.slice((fileName.lastIndexOf('.') - 1 >>> 0) + 2);
|
|
295
|
+
|
|
296
|
+
if (allowedExtensions && !allowedExtensions.includes(String(extension))) {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function handleChange(e) {
|
|
305
|
+
const target = e.target;
|
|
306
|
+
$$invalidate(7, files = target.files);
|
|
307
|
+
$$invalidate(0, displayfileslist = true);
|
|
308
|
+
const invalidFiles = [];
|
|
309
|
+
const fileList = [...files];
|
|
310
|
+
|
|
311
|
+
fileList.forEach((file, index) => {
|
|
312
|
+
const fileName = file.name;
|
|
313
|
+
const fileSize = file.size;
|
|
314
|
+
const validExtension = checkFileExtension(fileName);
|
|
315
|
+
const validSize = checkFileSize(fileSize);
|
|
316
|
+
let errorType = '';
|
|
317
|
+
|
|
318
|
+
if (!validExtension) {
|
|
319
|
+
errorType = 'invalid-extension';
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (!validSize) {
|
|
323
|
+
errorType = 'invalid-size';
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (!validExtension || !validSize) {
|
|
327
|
+
invalidFiles.push({ index, fileName, fileSize, errorType });
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
if (invalidFiles.length > 0) {
|
|
332
|
+
eventHandler.dispatch('invalid-files', invalidFiles);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
eventHandler.dispatch('change', files);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function deleteFile(e) {
|
|
339
|
+
$$invalidate(7, files = [...uploadedFiles]);
|
|
340
|
+
$$invalidate(7, files = removeFromArray(files, e.detail));
|
|
341
|
+
const fileuploader = root.querySelector('.mc-fileuploader__input');
|
|
342
|
+
fileuploader.value = '';
|
|
343
|
+
$$invalidate(9, uploadedFiles = files);
|
|
344
|
+
eventHandler.dispatch('file-removed', e.detail);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
function div_binding($$value) {
|
|
348
|
+
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
349
|
+
root = $$value;
|
|
350
|
+
$$invalidate(8, root);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
$$self.$$set = $$props => {
|
|
355
|
+
if ('id' in $$props) $$invalidate(1, id = $$props.id);
|
|
356
|
+
if ('label' in $$props) $$invalidate(2, label = $$props.label);
|
|
357
|
+
if ('accept' in $$props) $$invalidate(3, accept = $$props.accept);
|
|
358
|
+
if ('multiple' in $$props) $$invalidate(4, multiple = $$props.multiple);
|
|
359
|
+
if ('allowedextensions' in $$props) $$invalidate(14, allowedextensions = $$props.allowedextensions);
|
|
360
|
+
if ('maxsize' in $$props) $$invalidate(15, maxsize = $$props.maxsize);
|
|
361
|
+
if ('displayfileslist' in $$props) $$invalidate(0, displayfileslist = $$props.displayfileslist);
|
|
362
|
+
if ('disabled' in $$props) $$invalidate(5, disabled = $$props.disabled);
|
|
363
|
+
if ('removelabel' in $$props) $$invalidate(6, removelabel = $$props.removelabel);
|
|
364
|
+
if ('uploadedfiles' in $$props) $$invalidate(16, uploadedfiles = $$props.uploadedfiles);
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
$$self.$$.update = () => {
|
|
368
|
+
if ($$self.$$.dirty & /*allowedextensions*/ 16384) {
|
|
369
|
+
$$invalidate(10, allowedExtensions = allowedextensions ? JSON.parse(allowedextensions) : []);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if ($$self.$$.dirty & /*uploadedfiles*/ 65536) {
|
|
373
|
+
$$invalidate(9, uploadedFiles = uploadedfiles ? JSON.parse(uploadedfiles) : []);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if ($$self.$$.dirty & /*files*/ 128) ;
|
|
377
|
+
|
|
378
|
+
if ($$self.$$.dirty & /*maxsize*/ 32768) {
|
|
379
|
+
$$invalidate(11, maxSize = maxsize ? maxsize : undefined);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
return [
|
|
384
|
+
displayfileslist,
|
|
385
|
+
id,
|
|
386
|
+
label,
|
|
387
|
+
accept,
|
|
388
|
+
multiple,
|
|
389
|
+
disabled,
|
|
390
|
+
removelabel,
|
|
391
|
+
files,
|
|
392
|
+
root,
|
|
393
|
+
uploadedFiles,
|
|
394
|
+
allowedExtensions,
|
|
395
|
+
maxSize,
|
|
396
|
+
handleChange,
|
|
397
|
+
deleteFile,
|
|
398
|
+
allowedextensions,
|
|
399
|
+
maxsize,
|
|
400
|
+
uploadedfiles,
|
|
401
|
+
div_binding
|
|
402
|
+
];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
class FileUploader extends SvelteElement {
|
|
406
|
+
constructor(options) {
|
|
407
|
+
super();
|
|
408
|
+
const style = document.createElement('style');
|
|
409
|
+
style.textContent = `.mc-fileuploader{position:relative;display:block}.mc-fileuploader__input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0;visibility:visible;white-space:nowrap}.mc-fileuploader__label{font-family:"LeroyMerlin", sans-serif;font-weight:600;cursor:pointer;border-radius:4px;text-align:center;border:2px solid transparent;-webkit-transition:all ease 200ms;-o-transition:all ease 200ms;transition:all ease 200ms;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;vertical-align:middle;font-size:1rem;line-height:1.375;padding:0.6875rem 1.5rem;min-height:3rem;min-width:3rem;color:#188803;border-color:#188803;background-color:#ffffff;margin:0;-webkit-box-shadow:none;box-shadow:none;text-decoration:none;outline:none;-webkit-box-sizing:border-box;box-sizing:border-box}.mc-fileuploader__label:hover{background-color:#ebf5de;color:#006902}.mc-fileuploader__label:active{background-color:#c5e39e;color:#035010}.mc-fileuploader__label:active{background-color:#c5e39e;color:#035010}.mc-fileuploader__label:disabled{background-color:#cccccc;border-color:transparent;color:#666666;cursor:not-allowed}.mc-fileuploader__label::before{content:"";width:1.5rem;height:1.5rem;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMS41cmVtIiB3aWR0aD0iMS41cmVtIiBmaWxsPSIjMTg4ODAzIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjx0aXRsZT5NZWRpYV9VcGxvYWRfMjRweDwvdGl0bGU+PHBhdGggZD0iTTguNzEsNy43MSwxMSw1LjQxVjE2YTEsMSwwLDAsMCwyLDBWNS40MWwyLjI5LDIuM2ExLDEsMCwwLDAsMS40MiwwLDEsMSwwLDAsMCwwLTEuNDJsLTQtNGExLDEsMCwwLDAtMS40MiwwbC00LDRBMSwxLDAsMSwwLDguNzEsNy43MVoiLz48cGF0aCBkPSJNMTYuMjIsMTIuNDRhMSwxLDAsMCwwLTEuMi43NywxLDEsMCwwLDAsLjc2LDEuMTlDMTguNTUsMTUsMjAsMTYuMTcsMjAsMTdjMCwxLjIyLTMuMTIsMy04LDNzLTgtMS43OC04LTNjMC0uODMsMS40NS0yLDQuMjItMi42QTEsMSwwLDAsMCw5LDEzLjIxYTEsMSwwLDAsMC0xLjItLjc3QzQuMTYsMTMuMjUsMiwxNSwyLDE3YzAsMi44NSw0LjMsNSwxMCw1czEwLTIuMTUsMTAtNUMyMiwxNSwxOS44NCwxMy4yNSwxNi4yMiwxMi40NFoiLz48L3N2Zz4=") no-repeat;background-size:1.5rem;margin-right:0.5rem;margin-left:-0.5rem}:focus+.mc-fileuploader__label{-webkit-box-shadow:0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #0b96cc;box-shadow:0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #0b96cc}:hover+.mc-fileuploader__label{color:#006902;background-color:#ebf5de}:disabled+.mc-fileuploader__label{color:#666666;background-color:#cccccc;border-color:transparent;cursor:not-allowed}:disabled+.mc-fileuploader__label::before{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMS41cmVtIiB3aWR0aD0iMS41cmVtIiBmaWxsPSIjNjY2NjY2IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjx0aXRsZT5NZWRpYV9VcGxvYWRfMjRweDwvdGl0bGU+PHBhdGggZD0iTTguNzEsNy43MSwxMSw1LjQxVjE2YTEsMSwwLDAsMCwyLDBWNS40MWwyLjI5LDIuM2ExLDEsMCwwLDAsMS40MiwwLDEsMSwwLDAsMCwwLTEuNDJsLTQtNGExLDEsMCwwLDAtMS40MiwwbC00LDRBMSwxLDAsMSwwLDguNzEsNy43MVoiLz48cGF0aCBkPSJNMTYuMjIsMTIuNDRhMSwxLDAsMCwwLTEuMi43NywxLDEsMCwwLDAsLjc2LDEuMTlDMTguNTUsMTUsMjAsMTYuMTcsMjAsMTdjMCwxLjIyLTMuMTIsMy04LDNzLTgtMS43OC04LTNjMC0uODMsMS40NS0yLDQuMjItMi42QTEsMSwwLDAsMCw5LDEzLjIxYTEsMSwwLDAsMC0xLjItLjc3QzQuMTYsMTMuMjUsMiwxNSwyLDE3YzAsMi44NSw0LjMsNSwxMCw1czEwLTIuMTUsMTAtNUMyMiwxNSwxOS44NCwxMy4yNSwxNi4yMiwxMi40NFoiLz48L3N2Zz4=") no-repeat}`;
|
|
410
|
+
this.shadowRoot.appendChild(style);
|
|
411
|
+
|
|
412
|
+
init(
|
|
413
|
+
this,
|
|
414
|
+
{
|
|
415
|
+
target: this.shadowRoot,
|
|
416
|
+
props: attribute_to_object(this.attributes),
|
|
417
|
+
customElement: true
|
|
418
|
+
},
|
|
419
|
+
instance,
|
|
420
|
+
create_fragment,
|
|
421
|
+
safe_not_equal,
|
|
422
|
+
{
|
|
423
|
+
id: 1,
|
|
424
|
+
label: 2,
|
|
425
|
+
accept: 3,
|
|
426
|
+
multiple: 4,
|
|
427
|
+
allowedextensions: 14,
|
|
428
|
+
maxsize: 15,
|
|
429
|
+
displayfileslist: 0,
|
|
430
|
+
disabled: 5,
|
|
431
|
+
removelabel: 6,
|
|
432
|
+
uploadedfiles: 16
|
|
433
|
+
},
|
|
434
|
+
null
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
if (options) {
|
|
438
|
+
if (options.target) {
|
|
439
|
+
insert(options.target, this, options.anchor);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (options.props) {
|
|
443
|
+
this.$set(options.props);
|
|
444
|
+
flush();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
static get observedAttributes() {
|
|
450
|
+
return [
|
|
451
|
+
"id",
|
|
452
|
+
"label",
|
|
453
|
+
"accept",
|
|
454
|
+
"multiple",
|
|
455
|
+
"allowedextensions",
|
|
456
|
+
"maxsize",
|
|
457
|
+
"displayfileslist",
|
|
458
|
+
"disabled",
|
|
459
|
+
"removelabel",
|
|
460
|
+
"uploadedfiles"
|
|
461
|
+
];
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
get id() {
|
|
465
|
+
return this.$$.ctx[1];
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
set id(id) {
|
|
469
|
+
this.$$set({ id });
|
|
470
|
+
flush();
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
get label() {
|
|
474
|
+
return this.$$.ctx[2];
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
set label(label) {
|
|
478
|
+
this.$$set({ label });
|
|
479
|
+
flush();
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
get accept() {
|
|
483
|
+
return this.$$.ctx[3];
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
set accept(accept) {
|
|
487
|
+
this.$$set({ accept });
|
|
488
|
+
flush();
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
get multiple() {
|
|
492
|
+
return this.$$.ctx[4];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
set multiple(multiple) {
|
|
496
|
+
this.$$set({ multiple });
|
|
497
|
+
flush();
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
get allowedextensions() {
|
|
501
|
+
return this.$$.ctx[14];
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
set allowedextensions(allowedextensions) {
|
|
505
|
+
this.$$set({ allowedextensions });
|
|
506
|
+
flush();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
get maxsize() {
|
|
510
|
+
return this.$$.ctx[15];
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
set maxsize(maxsize) {
|
|
514
|
+
this.$$set({ maxsize });
|
|
515
|
+
flush();
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
get displayfileslist() {
|
|
519
|
+
return this.$$.ctx[0];
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
set displayfileslist(displayfileslist) {
|
|
523
|
+
this.$$set({ displayfileslist });
|
|
524
|
+
flush();
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
get disabled() {
|
|
528
|
+
return this.$$.ctx[5];
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
set disabled(disabled) {
|
|
532
|
+
this.$$set({ disabled });
|
|
533
|
+
flush();
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
get removelabel() {
|
|
537
|
+
return this.$$.ctx[6];
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
set removelabel(removelabel) {
|
|
541
|
+
this.$$set({ removelabel });
|
|
542
|
+
flush();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
get uploadedfiles() {
|
|
546
|
+
return this.$$.ctx[16];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
set uploadedfiles(uploadedfiles) {
|
|
550
|
+
this.$$set({ uploadedfiles });
|
|
551
|
+
flush();
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
export { FileUploader as default };
|
|
2
556
|
//# sourceMappingURL=FileUploader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUploader.js","sources":["../../../src/components/fileuploader/FileUploader.svelte"],"sourcesContent":["<svelte:options tag={null} />\n\n<script lang=\"ts\">\n // @ts-nocheck\n import { EventHandler } from '../../utilities/EventHandler';\n import ResultFile from './ResultFile.nested.svelte';\n\n export let id: string;\n export let label: string;\n export let accept: string;\n export let multiple = true;\n export let allowedextensions: string;\n export let maxsize: number;\n export let displayfileslist = false;\n export let disabled = false;\n export let removelabel = 'Remove';\n export let uploadedfiles: string;\n\n let files: FileList;\n let root: HTMLElement;\n let eventHandler = new EventHandler();\n\n $: allowedExtensions = allowedextensions ? JSON.parse(allowedextensions) : [];\n $: uploadedFiles = uploadedfiles ? JSON.parse(uploadedfiles) : [];\n $: files;\n $: maxSize = maxsize ? maxsize : undefined;\n\n function checkFileSize(fileSize: number): boolean {\n const fileSizeMB = fileSize / 1024 / 1024; // in MB\n if (maxSize && fileSizeMB > maxSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function checkFileExtension(fileName: string): boolean {\n if (allowedExtensions && allowedExtensions.length > 0) {\n const extension: string = fileName.slice(\n ((fileName.lastIndexOf('.') - 1) >>> 0) + 2,\n );\n if (allowedExtensions && !allowedExtensions.includes(String(extension))) {\n return false; // invalid\n }\n }\n\n return true; // valid\n }\n\n function checkFileStatus(file: File): boolean {\n const validExtension = allowedExtensions\n ? checkFileExtension(file.name)\n : true;\n const validSize = checkFileSize(file.size);\n\n if (!validExtension || !validSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function handleChange(e: Event): void {\n const target = e.target as HTMLInputElement;\n files = target.files as FileList;\n displayfileslist = true;\n const invalidFiles: Array = [];\n const fileList = [...files];\n fileList.forEach((file, index) => {\n const fileName = file.name;\n const fileSize = file.size;\n const validExtension = checkFileExtension(fileName);\n const validSize = checkFileSize(fileSize);\n let errorType = '';\n\n if (!validExtension) {\n errorType = 'invalid-extension';\n }\n\n if (!validSize) {\n errorType = 'invalid-size';\n }\n\n if (!validExtension || !validSize) {\n invalidFiles.push({\n index: index,\n fileName: fileName,\n fileSize: fileSize,\n errorType: errorType,\n });\n }\n });\n\n if (invalidFiles.length > 0) {\n eventHandler.dispatch('invalid-files', invalidFiles);\n }\n eventHandler.dispatch('change', files);\n }\n\n function removeFromArray(fileList: FileList, value: File): FileList {\n const array = Array.from(fileList);\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array as FileList;\n }\n\n function deleteFile(e: CustomEvent): void {\n files = [...uploadedFiles];\n files = removeFromArray(files, e.detail);\n const fileuploader = root.querySelector(\n '.mc-fileuploader__input',\n ) as HTMLInputElement;\n fileuploader.value = '';\n uploadedFiles = files;\n eventHandler.dispatch('file-removed', e.detail);\n }\n\n function hasInvalidFiles(e: CustomEvent): void {\n eventHandler.dispatch('invalid-files', e.detail);\n }\n</script>\n\n<div class=\"mc-fileuploader\" bind:this={root}>\n <input\n {id}\n type=\"file\"\n class=\"mc-fileuploader__input\"\n {accept}\n {multiple}\n {disabled}\n on:change={handleChange}\n />\n <label for={id} class=\"mc-fileuploader__label\">\n <span class=\"mc-fileuploader__label--center\">\n {label}\n </span>\n </label>\n {#if displayfileslist && files.length > 0}\n <ResultFile\n {files}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n {#if uploadedFiles.length > 0}\n <ResultFile\n files={uploadedFiles}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n</div>\n\n<style lang=\"scss\">\n @import '@mozaic-ds/styles/settings-tools/all-settings';\n @import '@mozaic-ds/styles/components/c.file-uploader';\n</style>\n"],"names":[
|
|
1
|
+
{"version":3,"file":"FileUploader.js","sources":["../../../src/components/fileuploader/FileUploader.svelte"],"sourcesContent":["<svelte:options tag={null} />\n\n<script lang=\"ts\">\n // @ts-nocheck\n import { EventHandler } from '../../utilities/EventHandler';\n import ResultFile from './ResultFile.nested.svelte';\n\n export let id: string;\n export let label: string;\n export let accept: string;\n export let multiple = true;\n export let allowedextensions: string;\n export let maxsize: number;\n export let displayfileslist = false;\n export let disabled = false;\n export let removelabel = 'Remove';\n export let uploadedfiles: string;\n\n let files: FileList;\n let root: HTMLElement;\n let eventHandler = new EventHandler();\n\n $: allowedExtensions = allowedextensions ? JSON.parse(allowedextensions) : [];\n $: uploadedFiles = uploadedfiles ? JSON.parse(uploadedfiles) : [];\n $: files;\n $: maxSize = maxsize ? maxsize : undefined;\n\n function checkFileSize(fileSize: number): boolean {\n const fileSizeMB = fileSize / 1024 / 1024; // in MB\n if (maxSize && fileSizeMB > maxSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function checkFileExtension(fileName: string): boolean {\n if (allowedExtensions && allowedExtensions.length > 0) {\n const extension: string = fileName.slice(\n ((fileName.lastIndexOf('.') - 1) >>> 0) + 2,\n );\n if (allowedExtensions && !allowedExtensions.includes(String(extension))) {\n return false; // invalid\n }\n }\n\n return true; // valid\n }\n\n function checkFileStatus(file: File): boolean {\n const validExtension = allowedExtensions\n ? checkFileExtension(file.name)\n : true;\n const validSize = checkFileSize(file.size);\n\n if (!validExtension || !validSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function handleChange(e: Event): void {\n const target = e.target as HTMLInputElement;\n files = target.files as FileList;\n displayfileslist = true;\n const invalidFiles: Array = [];\n const fileList = [...files];\n fileList.forEach((file, index) => {\n const fileName = file.name;\n const fileSize = file.size;\n const validExtension = checkFileExtension(fileName);\n const validSize = checkFileSize(fileSize);\n let errorType = '';\n\n if (!validExtension) {\n errorType = 'invalid-extension';\n }\n\n if (!validSize) {\n errorType = 'invalid-size';\n }\n\n if (!validExtension || !validSize) {\n invalidFiles.push({\n index: index,\n fileName: fileName,\n fileSize: fileSize,\n errorType: errorType,\n });\n }\n });\n\n if (invalidFiles.length > 0) {\n eventHandler.dispatch('invalid-files', invalidFiles);\n }\n eventHandler.dispatch('change', files);\n }\n\n function removeFromArray(fileList: FileList, value: File): FileList {\n const array = Array.from(fileList);\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array as FileList;\n }\n\n function deleteFile(e: CustomEvent): void {\n files = [...uploadedFiles];\n files = removeFromArray(files, e.detail);\n const fileuploader = root.querySelector(\n '.mc-fileuploader__input',\n ) as HTMLInputElement;\n fileuploader.value = '';\n uploadedFiles = files;\n eventHandler.dispatch('file-removed', e.detail);\n }\n\n function hasInvalidFiles(e: CustomEvent): void {\n eventHandler.dispatch('invalid-files', e.detail);\n }\n</script>\n\n<div class=\"mc-fileuploader\" bind:this={root}>\n <input\n {id}\n type=\"file\"\n class=\"mc-fileuploader__input\"\n {accept}\n {multiple}\n {disabled}\n on:change={handleChange}\n />\n <label for={id} class=\"mc-fileuploader__label\">\n <span class=\"mc-fileuploader__label--center\">\n {label}\n </span>\n </label>\n {#if displayfileslist && files.length > 0}\n <ResultFile\n {files}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n {#if uploadedFiles.length > 0}\n <ResultFile\n files={uploadedFiles}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n</div>\n\n<style lang=\"scss\">\n @import '@mozaic-ds/styles/settings-tools/all-settings';\n @import '@mozaic-ds/styles/components/c.file-uploader';\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;+CAgJuB,GAAU,CAAA,EAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAKpB,GAAa,CAAA,CAAA,CAAA;;;;;;;;+CAKH,GAAU,CAAA,EAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;mFALpB,GAAa,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAZnB,CAAA,IAAA,SAAA,wBAAA,GAAgB,CAAI,CAAA,CAAA,cAAA,GAAK,CAAC,CAAA,CAAA,CAAA,MAAM,GAAG,CAAC,IAAA,iBAAA,CAAA,GAAA,CAAA,CAAA;mCAUpC,GAAa,CAAA,CAAA,CAAA,CAAC,MAAM,GA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