@iamproperty/components 5.6.1-beta10 → 5.6.1-beta11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/assets/css/core.min.css +1 -1
  2. package/assets/css/core.min.css.map +1 -1
  3. package/assets/css/style.min.css +1 -1
  4. package/assets/css/style.min.css.map +1 -1
  5. package/assets/js/components/accordion/accordion.component.min.js +1 -1
  6. package/assets/js/components/actionbar/actionbar.component.min.js +1 -1
  7. package/assets/js/components/address-lookup/address-lookup.component.min.js +1 -1
  8. package/assets/js/components/applied-filters/applied-filters.component.min.js +1 -1
  9. package/assets/js/components/card/card.component.min.js +1 -1
  10. package/assets/js/components/carousel/carousel.component.min.js +1 -1
  11. package/assets/js/components/collapsible-side/collapsible-side.component.min.js +1 -1
  12. package/assets/js/components/fileupload/fileupload.component.js +16 -0
  13. package/assets/js/components/fileupload/fileupload.component.min.js +6 -4
  14. package/assets/js/components/fileupload/fileupload.component.min.js.map +1 -1
  15. package/assets/js/components/filterlist/filterlist.component.min.js +1 -1
  16. package/assets/js/components/header/header.component.min.js +1 -1
  17. package/assets/js/components/inline-edit/inline-edit.component.min.js +1 -1
  18. package/assets/js/components/marketing/marketing.component.min.js +1 -1
  19. package/assets/js/components/multiselect/multiselect.component.min.js +1 -1
  20. package/assets/js/components/nav/nav.component.min.js +1 -1
  21. package/assets/js/components/notification/notification.component.min.js +1 -1
  22. package/assets/js/components/pagination/pagination.component.min.js +1 -1
  23. package/assets/js/components/search/search.component.min.js +1 -1
  24. package/assets/js/components/slider/slider.component.min.js +1 -1
  25. package/assets/js/components/table/table.component.min.js +1 -1
  26. package/assets/js/components/tabs/tabs.component.min.js +1 -1
  27. package/assets/js/dynamic.min.js +1 -1
  28. package/assets/js/modules/fileupload.js +30 -15
  29. package/assets/js/scripts.bundle.js +1 -1
  30. package/assets/js/scripts.bundle.min.js +1 -1
  31. package/assets/sass/elements/dialog.scss +1 -1
  32. package/assets/ts/components/fileupload/fileupload.component.ts +26 -0
  33. package/assets/ts/modules/fileupload.ts +42 -17
  34. package/dist/components.es.js +9 -9
  35. package/dist/components.umd.js +41 -39
  36. package/package.json +1 -1
@@ -5,6 +5,8 @@ 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();
@@ -17,7 +19,7 @@ function fileupload(fileupload: Element, wrapper: Element) {
17
19
  const button = event.target.closest('.btn-primary');
18
20
 
19
21
  // If the input allows multiples then use the buffer clone input
20
- const inputTrigger = input.hasAttribute('multiple') ? cloneInput : input;
22
+ const inputTrigger = cloneInput;
21
23
 
22
24
  inputTrigger.click();
23
25
  }
@@ -56,33 +58,54 @@ function fileupload(fileupload: Element, wrapper: Element) {
56
58
  }
57
59
  });
58
60
 
61
+
62
+ let checkFileExt = function(filename){
63
+
64
+ if(!input.hasAttribute('accept'))
65
+ return true;
66
+
67
+ const nameExtension = filename.split('.').pop();
68
+ const acceptedTypes = input.getAttribute('accept');
69
+
70
+ if(acceptedTypes.includes(nameExtension))
71
+ return true;
72
+
73
+ return false;
74
+ }
75
+
59
76
  // Buffer input change event
60
77
  cloneInput.addEventListener('change', (event) => {
61
78
 
62
- if(input.hasAttribute('multiple')){
63
- const filesArray = [...input.files, ...cloneInput.files];
64
-
65
- let fileNames = [];
79
+ errorMsgExt.classList.remove('d-block');
80
+ errorMsgSize.classList.remove('d-block');
81
+ const filesArray = [...input.files, ...cloneInput.files];
82
+
83
+ let fileNames = [];
66
84
 
67
- const dt = new DataTransfer();
85
+ const dt = new DataTransfer();
68
86
 
69
- for (let i = 0; i < filesArray.length; i++) {
70
- const file = filesArray[i]
87
+ for (let i = 0; i < filesArray.length; i++) {
88
+ const file = filesArray[i]
71
89
 
72
- const size = file.size/1000;
90
+ const size = file.size/1000;
73
91
 
74
- if(!fileNames.includes(file.name) && (maxSize == 0 || size < maxSize))
75
- dt.items.add(file) // here you exclude the file. thus removing it.
92
+ if(!fileNames.includes(file.name) && (maxSize == 0 || size < maxSize) && checkFileExt(file.name))
93
+ dt.items.add(file) // here you exclude the file. thus removing it.
76
94
 
77
- fileNames.push(file.name);
95
+
96
+ if(!checkFileExt(file.name)){
97
+ errorMsgExt.classList.add('d-block');
78
98
  }
79
99
 
80
- input.files = dt.files;
81
- }
82
- else {
83
-
84
- input.files = cloneInput.files;
100
+ if(size > maxSize){
101
+ errorMsgSize.classList.add('d-block');
102
+ }
103
+
104
+
105
+ fileNames.push(file.name);
85
106
  }
107
+
108
+ input.files = dt.files;
86
109
 
87
110
  const changeEvent = new Event('change');
88
111
  input.dispatchEvent(changeEvent);
@@ -118,6 +141,8 @@ function fileupload(fileupload: Element, wrapper: Element) {
118
141
 
119
142
  if(fileupload.hasAttribute('data-filename')){
120
143
 
144
+ filesWrapper.innerHTML = '';
145
+
121
146
  let filename = fileupload.getAttribute('data-filename');
122
147
 
123
148
  if(filename)
@@ -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-625bb079.mjs").then((t) => {
456
+ import("./fileupload.component.min-d04c9cbf.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-d924027b.mjs").then((t) => {
486
+ import("./accordion.component.min-0f3749d3.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-3840e135.mjs").then((t) => {
622
+ import("./carousel.component.min-f4ba4195.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-55899ec0.mjs").then((t) => {
649
+ import("./header.component.min-0983036c.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-476aecec.mjs").then((t) => {
1045
+ import("./nav.component.min-8947100c.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-a3dcb1cb.mjs").then((t) => {
1165
+ import("./tabs.component.min-22fd4142.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-beta10
1312
+ * iamKey v5.6.1-beta11
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-0c275400.mjs").then((t) => {
1482
+ import("./actionbar.component.min-0ca7ff8f.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-beta10
1497
+ * iamKey v5.6.1-beta11
1498
1498
  * Copyright 2022-2024 iamproperty
1499
1499
  */
1500
1500
  class R extends HTMLElement {