@iamproperty/components 5.6.1-beta10 → 5.6.1-beta12
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/assets/css/core.min.css +1 -1
- package/assets/css/core.min.css.map +1 -1
- package/assets/css/style.min.css +1 -1
- package/assets/css/style.min.css.map +1 -1
- package/assets/js/components/accordion/accordion.component.min.js +1 -1
- package/assets/js/components/actionbar/actionbar.component.min.js +1 -1
- package/assets/js/components/address-lookup/address-lookup.component.min.js +1 -1
- package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
- package/assets/js/components/card/card.component.min.js +1 -1
- package/assets/js/components/carousel/carousel.component.min.js +1 -1
- package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
- package/assets/js/components/fileupload/fileupload.component.js +16 -0
- package/assets/js/components/fileupload/fileupload.component.min.js +6 -4
- package/assets/js/components/fileupload/fileupload.component.min.js.map +1 -1
- package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
- package/assets/js/components/header/header.component.min.js +1 -1
- package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
- package/assets/js/components/marketing/marketing.component.min.js +1 -1
- package/assets/js/components/multiselect/multiselect.component.min.js +1 -1
- package/assets/js/components/nav/nav.component.min.js +1 -1
- package/assets/js/components/notification/notification.component.min.js +1 -1
- package/assets/js/components/pagination/pagination.component.min.js +1 -1
- package/assets/js/components/search/search.component.min.js +1 -1
- package/assets/js/components/slider/slider.component.min.js +1 -1
- package/assets/js/components/table/table.component.min.js +1 -1
- package/assets/js/components/tabs/tabs.component.min.js +1 -1
- package/assets/js/dynamic.min.js +1 -1
- package/assets/js/modules/fileupload.js +42 -10
- package/assets/js/scripts.bundle.js +1 -1
- package/assets/js/scripts.bundle.min.js +1 -1
- package/assets/sass/elements/dialog.scss +1 -1
- package/assets/ts/components/fileupload/fileupload.component.ts +26 -0
- package/assets/ts/modules/fileupload.ts +62 -18
- package/dist/components.es.js +9 -9
- package/dist/components.umd.js +37 -35
- package/package.json +1 -1
|
@@ -5,11 +5,27 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
5
5
|
const dropArea = wrapper.querySelector('.drop-area');
|
|
6
6
|
const input = fileupload.querySelector('input');
|
|
7
7
|
const maxSize = fileupload.hasAttribute('data-maxsize') ? fileupload.getAttribute('data-maxsize') : 0;
|
|
8
|
+
const errorMsgSize = wrapper.querySelector('.invalid-feedback.size');
|
|
9
|
+
const errorMsgExt = wrapper.querySelector('.invalid-feedback.ext');
|
|
8
10
|
|
|
9
11
|
// We clone the input field to work as a buffer input field, this allows us to add new files without losing the old ones
|
|
10
12
|
const cloneInput = input.cloneNode();
|
|
11
13
|
dropArea.append(cloneInput);
|
|
12
14
|
|
|
15
|
+
let checkFileExt = function(filename){
|
|
16
|
+
|
|
17
|
+
if(!input.hasAttribute('accept'))
|
|
18
|
+
return true;
|
|
19
|
+
|
|
20
|
+
const nameExtension = filename.split('.').pop();
|
|
21
|
+
const acceptedTypes = input.getAttribute('accept');
|
|
22
|
+
|
|
23
|
+
if(acceptedTypes.includes(nameExtension))
|
|
24
|
+
return true;
|
|
25
|
+
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
13
29
|
wrapper.addEventListener('click', (event) => {
|
|
14
30
|
|
|
15
31
|
if (event && event.target instanceof HTMLElement && event.target.closest('.btn-primary')){
|
|
@@ -17,6 +33,9 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
17
33
|
const button = event.target.closest('.btn-primary');
|
|
18
34
|
|
|
19
35
|
// If the input allows multiples then use the buffer clone input
|
|
36
|
+
|
|
37
|
+
errorMsgExt.classList.remove('d-block');
|
|
38
|
+
errorMsgSize.classList.remove('d-block');
|
|
20
39
|
const inputTrigger = input.hasAttribute('multiple') ? cloneInput : input;
|
|
21
40
|
|
|
22
41
|
inputTrigger.click();
|
|
@@ -27,7 +46,6 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
27
46
|
|
|
28
47
|
if (event && event.target instanceof HTMLElement && event.target.closest('.files button')){
|
|
29
48
|
|
|
30
|
-
|
|
31
49
|
const dt = new DataTransfer();
|
|
32
50
|
const { files } = input;
|
|
33
51
|
const button = event.target.closest('.files button');
|
|
@@ -42,17 +60,8 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
42
60
|
|
|
43
61
|
input.files = dt.files // Assign the updates list
|
|
44
62
|
|
|
45
|
-
|
|
46
|
-
if(input.files.length == 0){
|
|
47
|
-
const emptyEvent = new Event('empty');
|
|
48
|
-
fileupload.dispatchEvent(emptyEvent);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
63
|
const changeEvent = new Event('change');
|
|
52
64
|
input.dispatchEvent(changeEvent);
|
|
53
|
-
|
|
54
|
-
const elementChangeEvent = new Event('elementChange');
|
|
55
|
-
fileupload.dispatchEvent(elementChangeEvent);
|
|
56
65
|
}
|
|
57
66
|
});
|
|
58
67
|
|
|
@@ -60,6 +69,7 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
60
69
|
cloneInput.addEventListener('change', (event) => {
|
|
61
70
|
|
|
62
71
|
if(input.hasAttribute('multiple')){
|
|
72
|
+
|
|
63
73
|
const filesArray = [...input.files, ...cloneInput.files];
|
|
64
74
|
|
|
65
75
|
let fileNames = [];
|
|
@@ -71,8 +81,17 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
71
81
|
|
|
72
82
|
const size = file.size/1000;
|
|
73
83
|
|
|
74
|
-
if(!fileNames.includes(file.name) && (maxSize == 0 || size < maxSize))
|
|
84
|
+
if(!fileNames.includes(file.name) && (maxSize == 0 || size < maxSize) && checkFileExt(file.name))
|
|
75
85
|
dt.items.add(file) // here you exclude the file. thus removing it.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
if(!checkFileExt(file.name)){
|
|
89
|
+
errorMsgExt.classList.add('d-block');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if(size > maxSize){
|
|
93
|
+
errorMsgSize.classList.add('d-block');
|
|
94
|
+
}
|
|
76
95
|
|
|
77
96
|
fileNames.push(file.name);
|
|
78
97
|
}
|
|
@@ -83,12 +102,9 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
83
102
|
|
|
84
103
|
input.files = cloneInput.files;
|
|
85
104
|
}
|
|
86
|
-
|
|
105
|
+
|
|
87
106
|
const changeEvent = new Event('change');
|
|
88
107
|
input.dispatchEvent(changeEvent);
|
|
89
|
-
|
|
90
|
-
const elementChangeEvent = new Event('elementChange');
|
|
91
|
-
fileupload.dispatchEvent(elementChangeEvent);
|
|
92
108
|
});
|
|
93
109
|
|
|
94
110
|
|
|
@@ -109,11 +125,40 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
109
125
|
|
|
110
126
|
input.addEventListener('change', (event) => {
|
|
111
127
|
|
|
128
|
+
if(input.files.length == 1) {
|
|
129
|
+
|
|
130
|
+
let file = input.files[0];
|
|
131
|
+
|
|
132
|
+
const size = file.size/1000;
|
|
133
|
+
|
|
134
|
+
if(!checkFileExt(file.name)){
|
|
135
|
+
errorMsgExt.classList.add('d-block');
|
|
136
|
+
|
|
137
|
+
const dt = new DataTransfer();
|
|
138
|
+
input.files = dt.files;
|
|
139
|
+
}
|
|
140
|
+
if(size > maxSize){
|
|
141
|
+
errorMsgSize.classList.add('d-block');
|
|
142
|
+
|
|
143
|
+
const dt = new DataTransfer();
|
|
144
|
+
input.files = dt.files;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
112
148
|
// Reset
|
|
113
149
|
filesWrapper.innerHTML = '';
|
|
114
150
|
|
|
115
|
-
for (const file of input.files)
|
|
151
|
+
for (const file of input.files){
|
|
116
152
|
filesWrapper.innerHTML += `<span class="file">${file.name} <button data-file="${file.name}">Remove</button></span>`;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const elementChangeEvent = new CustomEvent('elementchange', {detail: {"files": input.files}});
|
|
156
|
+
fileupload.dispatchEvent(elementChangeEvent);
|
|
157
|
+
|
|
158
|
+
if(input.files.length == 0){
|
|
159
|
+
const emptyEvent = new CustomEvent('empty');
|
|
160
|
+
fileupload.dispatchEvent(emptyEvent);
|
|
161
|
+
}
|
|
117
162
|
});
|
|
118
163
|
|
|
119
164
|
if(fileupload.hasAttribute('data-filename')){
|
|
@@ -123,7 +168,6 @@ function fileupload(fileupload: Element, wrapper: Element) {
|
|
|
123
168
|
if(filename)
|
|
124
169
|
filesWrapper.innerHTML += `<span class="file">${filename} <button data-file="${filename}">Remove</button></span>`;
|
|
125
170
|
}
|
|
126
|
-
|
|
127
171
|
}
|
|
128
172
|
|
|
129
|
-
export default fileupload;
|
|
173
|
+
export default fileupload;
|
package/dist/components.es.js
CHANGED
|
@@ -453,7 +453,7 @@ const N = /* @__PURE__ */ m(ne, [["render", Le]]), Se = {
|
|
|
453
453
|
},
|
|
454
454
|
created() {
|
|
455
455
|
this.$nextTick(function() {
|
|
456
|
-
import("./fileupload.component.min-
|
|
456
|
+
import("./fileupload.component.min-66885f0c.mjs").then((t) => {
|
|
457
457
|
window.customElements.get("iam-fileupload") || window.customElements.define("iam-fileupload", t.default);
|
|
458
458
|
}).catch((t) => {
|
|
459
459
|
console.log(t.message);
|
|
@@ -483,7 +483,7 @@ const qe = {
|
|
|
483
483
|
props: {},
|
|
484
484
|
mounted() {
|
|
485
485
|
this.$nextTick(function() {
|
|
486
|
-
import("./accordion.component.min-
|
|
486
|
+
import("./accordion.component.min-4f132ab2.mjs").then((t) => {
|
|
487
487
|
window.customElements.get("iam-accordion") || window.customElements.define("iam-accordion", t.default);
|
|
488
488
|
}).catch((t) => {
|
|
489
489
|
console.log(t.message);
|
|
@@ -619,7 +619,7 @@ const Va = /* @__PURE__ */ m(ze, [["render", Be]]), Oe = {
|
|
|
619
619
|
},
|
|
620
620
|
mounted() {
|
|
621
621
|
this.$nextTick(function() {
|
|
622
|
-
import("./carousel.component.min-
|
|
622
|
+
import("./carousel.component.min-73b52316.mjs").then((t) => {
|
|
623
623
|
window.customElements.get("iam-carousel") || window.customElements.define("iam-carousel", t.default);
|
|
624
624
|
}).catch((t) => {
|
|
625
625
|
console.log(t.message);
|
|
@@ -646,7 +646,7 @@ const Fa = /* @__PURE__ */ m(Oe, [["render", Ue]]), We = {
|
|
|
646
646
|
},
|
|
647
647
|
mounted() {
|
|
648
648
|
this.$nextTick(function() {
|
|
649
|
-
import("./header.component.min-
|
|
649
|
+
import("./header.component.min-6babe805.mjs").then((t) => {
|
|
650
650
|
window.customElements.get("iam-header") || window.customElements.define("iam-header", t.default);
|
|
651
651
|
}).catch((t) => {
|
|
652
652
|
console.log(t.message);
|
|
@@ -1042,7 +1042,7 @@ const Ua = /* @__PURE__ */ m(yt, [["render", Et]]), Ht = {
|
|
|
1042
1042
|
name: "Nav",
|
|
1043
1043
|
mounted() {
|
|
1044
1044
|
this.$nextTick(function() {
|
|
1045
|
-
import("./nav.component.min-
|
|
1045
|
+
import("./nav.component.min-1c53f611.mjs").then((t) => {
|
|
1046
1046
|
window.customElements.get("iam-nav") || window.customElements.define("iam-nav", t.default);
|
|
1047
1047
|
}).catch((t) => {
|
|
1048
1048
|
console.log(t.message);
|
|
@@ -1162,7 +1162,7 @@ const Xt = {
|
|
|
1162
1162
|
name: "Tabs",
|
|
1163
1163
|
created() {
|
|
1164
1164
|
this.$nextTick(function() {
|
|
1165
|
-
import("./tabs.component.min-
|
|
1165
|
+
import("./tabs.component.min-18847b6b.mjs").then((t) => {
|
|
1166
1166
|
window.customElements.get("iam-tabs") || window.customElements.define("iam-tabs", t.default);
|
|
1167
1167
|
}).catch((t) => {
|
|
1168
1168
|
console.log(t.message);
|
|
@@ -1309,7 +1309,7 @@ function pa(t, a, e, i, r, s) {
|
|
|
1309
1309
|
}
|
|
1310
1310
|
const Za = /* @__PURE__ */ m(ma, [["render", pa]]);
|
|
1311
1311
|
/*!
|
|
1312
|
-
* iamKey v5.6.1-
|
|
1312
|
+
* iamKey v5.6.1-beta12
|
|
1313
1313
|
* Copyright 2022-2024 iamproperty
|
|
1314
1314
|
*/
|
|
1315
1315
|
function ha(t, a) {
|
|
@@ -1479,7 +1479,7 @@ const ts = /* @__PURE__ */ m($a, [["render", ka]]), Aa = {
|
|
|
1479
1479
|
props: {},
|
|
1480
1480
|
mounted() {
|
|
1481
1481
|
this.$nextTick(function() {
|
|
1482
|
-
import("./actionbar.component.min-
|
|
1482
|
+
import("./actionbar.component.min-1c16dc77.mjs").then((t) => {
|
|
1483
1483
|
window.customElements.get("iam-actionbar") || window.customElements.define("iam-actionbar", t.default);
|
|
1484
1484
|
}).catch((t) => {
|
|
1485
1485
|
console.log(t.message);
|
|
@@ -1494,7 +1494,7 @@ function xa(t, a, e, i, r, s) {
|
|
|
1494
1494
|
}
|
|
1495
1495
|
const as = /* @__PURE__ */ m(Aa, [["render", xa]]);
|
|
1496
1496
|
/*!
|
|
1497
|
-
* iamKey v5.6.1-
|
|
1497
|
+
* iamKey v5.6.1-beta12
|
|
1498
1498
|
* Copyright 2022-2024 iamproperty
|
|
1499
1499
|
*/
|
|
1500
1500
|
class R extends HTMLElement {
|