@sankhyalabs/ezui 1.1.73 → 1.1.76
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/dist/cjs/ez-action-chip.cjs.entry.js +2 -2
- package/dist/cjs/ez-button_16.cjs.entry.js +179 -165
- package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ez-label-chip.cjs.entry.js +12 -12
- package/dist/cjs/ez-list.cjs.entry.js +1 -1
- package/dist/cjs/ez-modal.cjs.entry.js +1 -1
- package/dist/cjs/ez-number-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-popover.cjs.entry.js +1 -1
- package/dist/cjs/ez-popup.cjs.entry.js +1 -1
- package/dist/cjs/ez-time-input.cjs.entry.js +21 -2
- package/dist/cjs/ez-toast.cjs.entry.js +5 -2
- package/dist/cjs/ezui.cjs.js +2 -2
- package/dist/cjs/{index-4d2896bb.js → index-9431aeeb.js} +2 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/ez-action-chip/ez-action-chip.css +21 -21
- package/dist/collection/components/ez-action-chip/ez-action-chip.js +1 -1
- package/dist/collection/components/ez-button/ez-button.css +62 -43
- package/dist/collection/components/ez-button/ez-button.js +9 -2
- package/dist/collection/components/ez-calendar/ez-calendar.css +64 -64
- package/dist/collection/components/ez-calendar/ez-calendar.js +12 -9
- package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +34 -34
- package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +12 -12
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +2 -2
- package/dist/collection/components/ez-date-input/ez-date-input.css +17 -3
- package/dist/collection/components/ez-date-input/ez-date-input.js +2 -2
- package/dist/collection/components/ez-form/ez-form.js +37 -35
- package/dist/collection/components/ez-form/store/Form.actions.js +16 -16
- package/dist/collection/components/ez-form/store/Form.reducer.js +17 -17
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +8 -8
- package/dist/collection/components/ez-form/subcomponents/form-metadata.js +12 -12
- package/dist/collection/components/ez-form/subcomponents/place-holder.js +1 -1
- package/dist/collection/components/ez-form/subcomponents/structure/Field.js +22 -22
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +7 -7
- package/dist/collection/components/ez-label-chip/ez-label-chip.css +49 -49
- package/dist/collection/components/ez-label-chip/ez-label-chip.js +11 -11
- package/dist/collection/components/ez-numeric-input/ez-numeric-input.css +4 -4
- package/dist/collection/components/ez-search/ez-search.js +9 -9
- package/dist/collection/components/ez-text-area/ez-text-area.css +48 -48
- package/dist/collection/components/ez-text-input/ez-text-input.css +60 -60
- package/dist/collection/components/ez-text-input/ez-text-input.js +16 -16
- package/dist/collection/components/ez-time-input/ez-time-input.js +3 -2
- package/dist/collection/components/ez-toast/ez-toast.css +9 -9
- package/dist/collection/components/ez-toast/ez-toast.js +4 -1
- package/dist/collection/components/ez-upload/ez-upload.css +41 -41
- package/dist/collection/components/ez-upload/ez-upload.js +53 -50
- package/dist/collection/utils/AssetsUtils.js +19 -0
- package/dist/custom-elements/index.js +219 -183
- package/dist/esm/ez-action-chip.entry.js +2 -2
- package/dist/esm/ez-button_16.entry.js +179 -165
- package/dist/esm/ez-dialog.entry.js +1 -1
- package/dist/esm/ez-label-chip.entry.js +12 -12
- package/dist/esm/ez-list.entry.js +1 -1
- package/dist/esm/ez-modal.entry.js +1 -1
- package/dist/esm/ez-number-input.entry.js +1 -1
- package/dist/esm/ez-popover.entry.js +1 -1
- package/dist/esm/ez-popup.entry.js +1 -1
- package/dist/esm/ez-time-input.entry.js +21 -2
- package/dist/esm/ez-toast.entry.js +5 -2
- package/dist/esm/ezui.js +2 -2
- package/dist/esm/{index-33153059.js → index-fd3c8023.js} +2 -1
- package/dist/esm/loader.js +2 -2
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-67410dfa.entry.js → p-11ae4ae7.entry.js} +1 -1
- package/dist/ezui/{p-50464bdf.entry.js → p-47fa3d6c.entry.js} +1 -1
- package/dist/ezui/p-66954a04.entry.js +1 -0
- package/dist/ezui/p-823ff0a0.entry.js +1 -0
- package/dist/ezui/{p-7f3bc6d9.entry.js → p-8ab6168f.entry.js} +1 -1
- package/dist/ezui/{p-15743b09.entry.js → p-9c1fb51c.entry.js} +1 -1
- package/dist/ezui/{p-061d21ba.entry.js → p-9d85125b.entry.js} +1 -1
- package/dist/ezui/p-a0b6eee2.entry.js +1 -0
- package/dist/ezui/p-a7b546b2.entry.js +1 -0
- package/dist/ezui/p-c833c94f.entry.js +1 -0
- package/dist/ezui/{p-8818da66.entry.js → p-d443f020.entry.js} +1 -1
- package/dist/ezui/{p-4df6f855.js → p-e0ab3746.js} +1 -1
- package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +2 -2
- package/dist/types/components/ez-calendar/ez-calendar.d.ts +4 -1
- package/dist/types/components/ez-collapsible-box/ez-collapsible-box.d.ts +3 -3
- package/dist/types/components/ez-form/ez-form.d.ts +9 -9
- package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +1 -1
- package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +1 -1
- package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +2 -2
- package/dist/types/components/ez-search/ez-search.d.ts +5 -5
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +1 -1
- package/dist/types/components/ez-toast/ez-toast.d.ts +3 -0
- package/dist/types/components/ez-upload/ez-upload.d.ts +10 -7
- package/dist/types/components.d.ts +47 -38
- package/dist/types/utils/AssetsUtils.d.ts +1 -0
- package/package.json +1 -1
- package/dist/ezui/p-0db8d49b.entry.js +0 -1
- package/dist/ezui/p-129b53df.entry.js +0 -1
- package/dist/ezui/p-25953d44.entry.js +0 -1
- package/dist/ezui/p-74809665.entry.js +0 -1
- package/dist/ezui/p-a99f8d42.entry.js +0 -1
|
@@ -2,50 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
/* dimensions */
|
|
4
4
|
/*@doc Define a altura do componente.*/
|
|
5
|
-
--
|
|
5
|
+
--ez-upload--height: 42px;
|
|
6
6
|
/*@doc Define a largura do componente.*/
|
|
7
|
-
--
|
|
7
|
+
--ez-upload--width: 100%;
|
|
8
8
|
/*@doc Define a largura do slot que contém o ícone.*/
|
|
9
|
-
--
|
|
9
|
+
--ez-upload__icon--width: 48px;
|
|
10
10
|
|
|
11
11
|
/* box--container */
|
|
12
12
|
/*@doc Define a cor de fundo do container.*/
|
|
13
|
-
--
|
|
13
|
+
--ez-upload__container--background-color: var(--background--medium, #d2dce9);
|
|
14
14
|
|
|
15
15
|
/* colors */
|
|
16
16
|
/*@doc Define a cor de fundo do container.*/
|
|
17
|
-
--
|
|
17
|
+
--ez-upload__color--primary: var(--color--primary, #008561);
|
|
18
18
|
|
|
19
19
|
/* espaçamento */
|
|
20
20
|
/*@doc Define os espaçamentos extra pequenos no componente.*/
|
|
21
|
-
--
|
|
21
|
+
--ez-upload--padding--extra-small: var(--space--extra-small, 3px);
|
|
22
22
|
/*@doc Define os espaçamentos pequenos no componente.*/
|
|
23
|
-
--
|
|
23
|
+
--ez-upload--padding--small: var(--space--small, 6px);
|
|
24
24
|
/*@doc Define os espaçamentos médios no componente.*/
|
|
25
|
-
--
|
|
25
|
+
--ez-upload--padding--medium: var(--space--medium, 12px);
|
|
26
26
|
/*@doc Define os espaçamentos grandes no componente.*/
|
|
27
|
-
--
|
|
27
|
+
--ez-upload--padding--large: var(--space--large, 24px);
|
|
28
28
|
|
|
29
29
|
/* border */
|
|
30
30
|
/*@doc Define a cor das bordas no componente.*/
|
|
31
|
-
--
|
|
31
|
+
--ez-upload__border--color: var(--color-strokes, #DCE0E8);
|
|
32
32
|
|
|
33
33
|
/* text */
|
|
34
34
|
/*@doc Define as sombras dos textos do componente.*/
|
|
35
|
-
--
|
|
35
|
+
--ez-upload--text-shadow: var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);
|
|
36
36
|
/*@doc Define a cor dos textos do componente.*/
|
|
37
|
-
--
|
|
37
|
+
--ez-upload--text--primary: var(--text-primary, #626e82);
|
|
38
38
|
/*@doc Define o tamanho dos textos do componente.*/
|
|
39
|
-
--
|
|
39
|
+
--ez-upload--font-size: var(--text--medium, 14px);
|
|
40
40
|
/*@doc Define a família dos textos do componente.*/
|
|
41
|
-
--
|
|
41
|
+
--ez-upload--font-family: var(--font-pattern, Arial);
|
|
42
42
|
/*@doc Define o peso dos textos do componente.*/
|
|
43
|
-
--
|
|
43
|
+
--ez-upload--font-weight: var(--text-weight--large, 500);
|
|
44
44
|
|
|
45
45
|
/*@doc Contém o ícone de cancelamento.*/
|
|
46
|
-
--
|
|
46
|
+
--ez-upload__btn__cancel-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="8x" width="8px"><path d="M 8,0.8 7.2,0 4,3.2 0.8,0 0,0.8 3.2,4 0,7.2 0.8,8 4,4.8 7.2,8 8,7.2 4.8,4 Z"/></svg>');
|
|
47
47
|
/*@doc Contém o ícone de arquivo.*/
|
|
48
|
-
--
|
|
48
|
+
--ez-upload__file-icon-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="11x" width="9px"><path d="M 1.2272719,8.4999999 V 2.75 c 0,-1.1045695 1.4652499,-2 3.2727273,-2 1.8074777,0 3.2727281,0.8954305 3.2727281,2 V 8.9999999 C 7.7727273,9.690356 6.8569456,10.25 5.7272719,10.25 4.5975985,10.25 3.6818174,9.690356 3.6818174,8.9999999 V 3.75 c 0,-0.2761425 0.3663125,-0.5 0.8181818,-0.5 0.4518694,0 0.8181818,0.2238575 0.8181818,0.5 V 8.4999999 H 6.5454537 V 3.75 C 6.5454537,3.059644 5.6296725,2.5 4.4999992,2.5 3.3703258,2.5 2.4545446,3.059644 2.4545446,3.75 V 8.9999999 C 2.4545446,10.10457 3.9197945,11 5.7272719,11 7.5347496,11 9,10.10457 9,8.9999999 V 2.75 C 9,1.231217 6.9852809,0 4.4999992,0 2.0147181,5e-7 0,1.231217 0,2.75 v 5.7499999 z"/></svg>');
|
|
49
49
|
|
|
50
50
|
/*private*/
|
|
51
51
|
display: flex;
|
|
@@ -53,17 +53,17 @@
|
|
|
53
53
|
position: relative;
|
|
54
54
|
|
|
55
55
|
/*public*/
|
|
56
|
-
font-family: var(--
|
|
57
|
-
font-size: var(--
|
|
58
|
-
width: var(--
|
|
59
|
-
font-weight: var(--
|
|
56
|
+
font-family: var(--ez-upload--font-family);
|
|
57
|
+
font-size: var(--ez-upload--font-size);
|
|
58
|
+
width: var(--ez-upload--width);
|
|
59
|
+
font-weight: var(--ez-upload--font-weight);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
.iu {
|
|
63
63
|
display: flex;
|
|
64
64
|
flex-wrap: wrap;
|
|
65
|
-
background-color: var(--
|
|
66
|
-
padding: var(--
|
|
65
|
+
background-color: var(--ez-upload__container--background-color);
|
|
66
|
+
padding: var(--ez-upload--padding--small);
|
|
67
67
|
width: 100%;
|
|
68
68
|
border-radius: 12px;
|
|
69
69
|
box-sizing: border-box;
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
flex-wrap: wrap;
|
|
76
76
|
justify-content: center;
|
|
77
77
|
align-items: center;
|
|
78
|
-
border: 2px dashed var(--
|
|
78
|
+
border: 2px dashed var(--ez-upload__border--color);
|
|
79
79
|
border-radius: 6px;
|
|
80
80
|
box-sizing: border-box;
|
|
81
81
|
}
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
flex-wrap: wrap;
|
|
86
86
|
justify-content: flex-start;
|
|
87
87
|
width: 100%;
|
|
88
|
-
padding: 0 var(--
|
|
88
|
+
padding: 0 var(--ez-upload--padding--medium) var(--ez-upload--padding--medium) var(--ez-upload--padding--medium);
|
|
89
89
|
box-sizing: border-box;
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
justify-content: flex-start;
|
|
96
96
|
align-items: center;
|
|
97
97
|
align-self: center;
|
|
98
|
-
padding-bottom: var(--
|
|
98
|
+
padding-bottom: var(--ez-upload--padding--extra-small);
|
|
99
99
|
box-sizing: border-box;
|
|
100
100
|
white-space: nowrap;
|
|
101
101
|
overflow: hidden;
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
justify-content: center;
|
|
119
119
|
align-items: center;
|
|
120
120
|
height: 100%;
|
|
121
|
-
border: 1px dashed var(--
|
|
121
|
+
border: 1px dashed var(--ez-upload__border--color);
|
|
122
122
|
border-radius: 6px;
|
|
123
123
|
box-sizing: border-box;
|
|
124
124
|
}
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
.box__container {
|
|
127
127
|
display: flex;
|
|
128
128
|
flex-wrap: wrap;
|
|
129
|
-
background-color: var(--
|
|
129
|
+
background-color: var(--ez-upload__container--background-color);
|
|
130
130
|
padding: 6px;
|
|
131
131
|
width: 100%;
|
|
132
132
|
border-radius: 12px;
|
|
@@ -145,7 +145,7 @@ progress[value] {
|
|
|
145
145
|
display: flex;
|
|
146
146
|
width: 100%;
|
|
147
147
|
appearance: none;
|
|
148
|
-
border: 1px solid var(--
|
|
148
|
+
border: 1px solid var(--ez-upload__border--color);
|
|
149
149
|
height: 12px;
|
|
150
150
|
justify-content: flex-start;
|
|
151
151
|
align-items: center;
|
|
@@ -165,7 +165,7 @@ progress[value]::-webkit-progress-bar {
|
|
|
165
165
|
progress[value]::-webkit-progress-value {
|
|
166
166
|
display: flex;
|
|
167
167
|
width: 100%;
|
|
168
|
-
background-color: var(--
|
|
168
|
+
background-color: var(--ez-upload__color--primary);
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
.text--center {
|
|
@@ -183,8 +183,8 @@ progress[value]::-webkit-progress-value {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
.text--primary {
|
|
186
|
-
color: var(--
|
|
187
|
-
text-shadow: var(--
|
|
186
|
+
color: var(--ez-upload--text--primary);
|
|
187
|
+
text-shadow: var(--ez-upload--text-shadow);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
.text--ellipsis {
|
|
@@ -214,8 +214,8 @@ progress[value]::-webkit-progress-value {
|
|
|
214
214
|
background-color: var(--text--primary, #008561);
|
|
215
215
|
width: 8px;
|
|
216
216
|
height: 8px;
|
|
217
|
-
-webkit-mask-image: var(--
|
|
218
|
-
mask-image: var(--
|
|
217
|
+
-webkit-mask-image: var(--ez-upload__btn__cancel-image);
|
|
218
|
+
mask-image: var(--ez-upload__btn__cancel-image);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
.iu_header {
|
|
@@ -232,11 +232,11 @@ progress[value]::-webkit-progress-value {
|
|
|
232
232
|
white-space: nowrap;
|
|
233
233
|
|
|
234
234
|
/*public*/
|
|
235
|
-
font-family: var(--
|
|
235
|
+
font-family: var(--ez-upload--font-family);
|
|
236
236
|
font-size: var(--text--extra-small);
|
|
237
|
-
font-weight: var(--
|
|
238
|
-
color: var(--
|
|
239
|
-
text-shadow: var(--
|
|
237
|
+
font-weight: var(--ez-upload--font-weight);
|
|
238
|
+
color: var(--ez-upload--text--primary);
|
|
239
|
+
text-shadow: var(--ez-upload--text-shadow);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
.iu__file-icon {
|
|
@@ -256,8 +256,8 @@ progress[value]::-webkit-progress-value {
|
|
|
256
256
|
background-color: var(--text--primary, #626e82);
|
|
257
257
|
width: 9px;
|
|
258
258
|
height: 11px;
|
|
259
|
-
-webkit-mask-image: var(--
|
|
260
|
-
mask-image: var(--
|
|
259
|
+
-webkit-mask-image: var(--ez-upload__file-icon-image);
|
|
260
|
+
mask-image: var(--ez-upload__file-icon-image);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
.iu__file-icon:disabled::after {
|
|
@@ -268,7 +268,7 @@ progress[value]::-webkit-progress-value {
|
|
|
268
268
|
justify-content: center;
|
|
269
269
|
display: flex;
|
|
270
270
|
cursor: pointer;
|
|
271
|
-
padding: var(--
|
|
271
|
+
padding: var(--ez-upload--padding--large) 0px;
|
|
272
272
|
box-sizing: border-box;
|
|
273
273
|
}
|
|
274
274
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component, h, Prop, Element, Event, Method, Watch, forceUpdate } from
|
|
2
|
-
import Application from
|
|
3
|
-
import RemoteFile from
|
|
1
|
+
import { Component, h, Prop, Element, Event, Method, Watch, forceUpdate } from "@stencil/core";
|
|
2
|
+
import Application from "../../utils/Application";
|
|
3
|
+
import RemoteFile from "./RemoteFile";
|
|
4
4
|
export class EzUpload {
|
|
5
5
|
constructor() {
|
|
6
6
|
this._filePointers = new Map();
|
|
@@ -28,28 +28,31 @@ export class EzUpload {
|
|
|
28
28
|
}
|
|
29
29
|
normalizeRequestHeaders() {
|
|
30
30
|
this._requestHeaders = new Map();
|
|
31
|
-
if (typeof this.
|
|
31
|
+
if (typeof this.requestHeaders == "string") {
|
|
32
32
|
try {
|
|
33
|
-
this.
|
|
33
|
+
this.requestHeaders = JSON.parse(this.requestHeaders);
|
|
34
34
|
}
|
|
35
35
|
catch (e) {
|
|
36
|
-
this.
|
|
36
|
+
this.requestHeaders = undefined;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
for (var key in this.
|
|
40
|
-
this._requestHeaders.set(key, this.
|
|
39
|
+
for (var key in this.requestHeaders) {
|
|
40
|
+
this._requestHeaders.set(key, this.requestHeaders[key]);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Método responsável por adicionar um ou mais arquivos ao componente.
|
|
45
|
+
*/
|
|
43
46
|
async addFiles(files) {
|
|
44
|
-
if (this.
|
|
47
|
+
if (this.maxFiles > 0) {
|
|
45
48
|
let countDistinctFiles = this._filePointers.size;
|
|
46
49
|
files.forEach(file => {
|
|
47
50
|
if (!this._filePointers.has(file.name)) {
|
|
48
51
|
countDistinctFiles++;
|
|
49
52
|
}
|
|
50
53
|
});
|
|
51
|
-
if (countDistinctFiles > this.
|
|
52
|
-
this.showError(`A quantidade máxima de arquivos é ${this.
|
|
54
|
+
if (countDistinctFiles > this.maxFiles) {
|
|
55
|
+
this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
|
|
53
56
|
return;
|
|
54
57
|
}
|
|
55
58
|
}
|
|
@@ -76,7 +79,7 @@ export class EzUpload {
|
|
|
76
79
|
if (this.validateFile(file)) {
|
|
77
80
|
const uploadingFile = new RemoteFile(file);
|
|
78
81
|
this._filePointers.set(file.name, uploadingFile);
|
|
79
|
-
uploadingFile.upload(this.
|
|
82
|
+
uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
|
|
80
83
|
.then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
|
|
81
84
|
.catch(msg => this.showError(msg));
|
|
82
85
|
forceUpdate(this);
|
|
@@ -97,13 +100,13 @@ export class EzUpload {
|
|
|
97
100
|
this.ezChange.emit(this.value);
|
|
98
101
|
}
|
|
99
102
|
buildProgressId(uploading) {
|
|
100
|
-
let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi,
|
|
103
|
+
let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
|
|
101
104
|
return `PROGRESS_${sanitizedName}_${uploading.file.lastModified}`;
|
|
102
105
|
}
|
|
103
106
|
updateFeedback(uf) {
|
|
104
107
|
window.requestAnimationFrame(() => {
|
|
105
108
|
if (this._host) {
|
|
106
|
-
const progress = this._host.shadowRoot.querySelector(
|
|
109
|
+
const progress = this._host.shadowRoot.querySelector("#" + this.buildProgressId(uf));
|
|
107
110
|
if (progress) {
|
|
108
111
|
progress.value = uf.progress;
|
|
109
112
|
}
|
|
@@ -111,20 +114,20 @@ export class EzUpload {
|
|
|
111
114
|
});
|
|
112
115
|
}
|
|
113
116
|
validateFile(file) {
|
|
114
|
-
if (!this._filePointers.has(file.name) && this.
|
|
115
|
-
this.showError(`A quantidade máxima de arquivos é ${this.
|
|
117
|
+
if (!this._filePointers.has(file.name) && this.maxFiles > 0 && this._filePointers.size >= this.maxFiles) {
|
|
118
|
+
this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
|
|
116
119
|
return false;
|
|
117
120
|
}
|
|
118
121
|
if (file.size === 0) {
|
|
119
122
|
this.showError(`Erro de permissão: O arquivo "${file.name}" não pode ser enviado.`);
|
|
120
123
|
return false;
|
|
121
124
|
}
|
|
122
|
-
if (!this.
|
|
125
|
+
if (!this.urlUpload) {
|
|
123
126
|
this.showError("Endereço de upload não informado");
|
|
124
127
|
return false;
|
|
125
128
|
}
|
|
126
|
-
if (this.
|
|
127
|
-
this.showError("O tamanho máximo dos arquivos é de " + this.formatBytes(this.
|
|
129
|
+
if (this.maxFileSize >= 0 && file.size > this.maxFileSize) {
|
|
130
|
+
this.showError("O tamanho máximo dos arquivos é de " + this.formatBytes(this.maxFileSize));
|
|
128
131
|
return false;
|
|
129
132
|
}
|
|
130
133
|
return true;
|
|
@@ -134,17 +137,17 @@ export class EzUpload {
|
|
|
134
137
|
}
|
|
135
138
|
formatBytes(bytes, decimals = 1) {
|
|
136
139
|
if (bytes === 0)
|
|
137
|
-
return
|
|
140
|
+
return "0 Bytes";
|
|
138
141
|
const k = 1024;
|
|
139
142
|
const dm = decimals < 0 ? 0 : decimals;
|
|
140
|
-
const sizes = [
|
|
143
|
+
const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
141
144
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
142
|
-
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) +
|
|
145
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
|
|
143
146
|
}
|
|
144
147
|
onFileInputChange(event) {
|
|
145
148
|
const input = event.target;
|
|
146
149
|
this.addFiles(Array.from(input.files));
|
|
147
|
-
this._fileInput.value =
|
|
150
|
+
this._fileInput.value = "";
|
|
148
151
|
}
|
|
149
152
|
isRemoteFile(item) {
|
|
150
153
|
return "file" in item;
|
|
@@ -160,10 +163,10 @@ export class EzUpload {
|
|
|
160
163
|
this.removeFromList(name);
|
|
161
164
|
}
|
|
162
165
|
else {
|
|
163
|
-
if (this.
|
|
166
|
+
if (this.urlDelete) {
|
|
164
167
|
const uploadingFile = new RemoteFile(null);
|
|
165
168
|
this._filePointers.set(item.name, uploadingFile);
|
|
166
|
-
uploadingFile.delete(item, this.
|
|
169
|
+
uploadingFile.delete(item, this.urlDelete, null)
|
|
167
170
|
.then(_ok => this.removeFromList(name))
|
|
168
171
|
.catch(msg => this.showError(msg));
|
|
169
172
|
}
|
|
@@ -179,20 +182,20 @@ export class EzUpload {
|
|
|
179
182
|
}
|
|
180
183
|
componentDidLoad() {
|
|
181
184
|
if (this.enabled && this._dropZone && window.FileList && window.File) {
|
|
182
|
-
this._dropZone.addEventListener(
|
|
185
|
+
this._dropZone.addEventListener("dragover", event => {
|
|
183
186
|
event.stopPropagation();
|
|
184
187
|
event.preventDefault();
|
|
185
|
-
event.dataTransfer.dropEffect =
|
|
186
|
-
this._dropZone.style.background =
|
|
188
|
+
event.dataTransfer.dropEffect = "copy";
|
|
189
|
+
this._dropZone.style.background = "#c2dbff";
|
|
187
190
|
});
|
|
188
|
-
this._dropZone.addEventListener(
|
|
191
|
+
this._dropZone.addEventListener("drop", event => {
|
|
189
192
|
event.stopPropagation();
|
|
190
193
|
event.preventDefault();
|
|
191
194
|
this.addFiles(Array.from(event.dataTransfer.files));
|
|
192
|
-
this._dropZone.style.background =
|
|
195
|
+
this._dropZone.style.background = "";
|
|
193
196
|
});
|
|
194
|
-
this._dropZone.addEventListener(
|
|
195
|
-
this._dropZone.style.background =
|
|
197
|
+
this._dropZone.addEventListener("dragleave", _event => {
|
|
198
|
+
this._dropZone.style.background = "";
|
|
196
199
|
});
|
|
197
200
|
}
|
|
198
201
|
}
|
|
@@ -204,13 +207,13 @@ export class EzUpload {
|
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
render() {
|
|
207
|
-
return (h("div", { ref: (el) => this._dropZone = el, class: this.evalDisabledClass(
|
|
210
|
+
return (h("div", { ref: (el) => this._dropZone = el, class: this.evalDisabledClass("iu", "background--disabled") },
|
|
208
211
|
h("div", { class: "iu__container", onClick: () => this.openFilesDialog() },
|
|
209
212
|
h("div", { class: "iu_header" },
|
|
210
|
-
this.label ? h("label", { class: this.evalDisabledClass(
|
|
211
|
-
h("div", { class: this.evalDisabledClass(
|
|
213
|
+
this.label ? h("label", { class: this.evalDisabledClass("iu__label", "text--disabled"), title: this.label }, this.label) : null,
|
|
214
|
+
h("div", { class: this.evalDisabledClass("iu__icon-label", "mouse-pointer--disabled") },
|
|
212
215
|
h("button", { class: "iu__file-icon", disabled: !this.enabled }),
|
|
213
|
-
h("div", { class: this.evalDisabledClass(
|
|
216
|
+
h("div", { class: this.evalDisabledClass("text text--center text--medium text--primary", "text--disabled") }, this.enabled ? "Arraste e solte ou clique para adicionar arquivos" : "Somente leitura"))),
|
|
214
217
|
this.buildFooter()),
|
|
215
218
|
h("input", { ref: (el) => this._fileInput = el, onChange: (ev) => this.onFileInputChange(ev), type: "file", multiple: true, hidden: true })));
|
|
216
219
|
}
|
|
@@ -224,8 +227,8 @@ export class EzUpload {
|
|
|
224
227
|
}
|
|
225
228
|
buildFileItem(item) {
|
|
226
229
|
const fileName = item.name;
|
|
227
|
-
const progress = Number(item[
|
|
228
|
-
const downloadURL = item[
|
|
230
|
+
const progress = Number(item["progress"]);
|
|
231
|
+
const downloadURL = item["downloadURL"];
|
|
229
232
|
const label = `${fileName} (${this.formatBytes(item.size)})`;
|
|
230
233
|
return (h("div", { class: "iu__item", key: fileName, onClick: evt => evt.stopPropagation() },
|
|
231
234
|
h("div", { class: "iu__item-label modificador" },
|
|
@@ -290,7 +293,7 @@ export class EzUpload {
|
|
|
290
293
|
"reflect": false,
|
|
291
294
|
"defaultValue": "true"
|
|
292
295
|
},
|
|
293
|
-
"
|
|
296
|
+
"maxFileSize": {
|
|
294
297
|
"type": "number",
|
|
295
298
|
"mutable": false,
|
|
296
299
|
"complexType": {
|
|
@@ -304,10 +307,10 @@ export class EzUpload {
|
|
|
304
307
|
"tags": [],
|
|
305
308
|
"text": "Define o tamanho m\u00E1ximo (em bytes) de cada arquivo que pode ser transferido"
|
|
306
309
|
},
|
|
307
|
-
"attribute": "
|
|
310
|
+
"attribute": "max-file-size",
|
|
308
311
|
"reflect": false
|
|
309
312
|
},
|
|
310
|
-
"
|
|
313
|
+
"maxFiles": {
|
|
311
314
|
"type": "number",
|
|
312
315
|
"mutable": false,
|
|
313
316
|
"complexType": {
|
|
@@ -321,10 +324,10 @@ export class EzUpload {
|
|
|
321
324
|
"tags": [],
|
|
322
325
|
"text": "Define um limite para a quantidade de arquivos"
|
|
323
326
|
},
|
|
324
|
-
"attribute": "
|
|
327
|
+
"attribute": "max-files",
|
|
325
328
|
"reflect": false
|
|
326
329
|
},
|
|
327
|
-
"
|
|
330
|
+
"requestHeaders": {
|
|
328
331
|
"type": "any",
|
|
329
332
|
"mutable": false,
|
|
330
333
|
"complexType": {
|
|
@@ -338,10 +341,10 @@ export class EzUpload {
|
|
|
338
341
|
"tags": [],
|
|
339
342
|
"text": "Headers para a requisi\u00E7\u00E3o Http"
|
|
340
343
|
},
|
|
341
|
-
"attribute": "
|
|
344
|
+
"attribute": "request-headers",
|
|
342
345
|
"reflect": false
|
|
343
346
|
},
|
|
344
|
-
"
|
|
347
|
+
"urlUpload": {
|
|
345
348
|
"type": "string",
|
|
346
349
|
"mutable": false,
|
|
347
350
|
"complexType": {
|
|
@@ -355,10 +358,10 @@ export class EzUpload {
|
|
|
355
358
|
"tags": [],
|
|
356
359
|
"text": "Define a URL de upload"
|
|
357
360
|
},
|
|
358
|
-
"attribute": "
|
|
361
|
+
"attribute": "url-upload",
|
|
359
362
|
"reflect": false
|
|
360
363
|
},
|
|
361
|
-
"
|
|
364
|
+
"urlDelete": {
|
|
362
365
|
"type": "string",
|
|
363
366
|
"mutable": false,
|
|
364
367
|
"complexType": {
|
|
@@ -372,7 +375,7 @@ export class EzUpload {
|
|
|
372
375
|
"tags": [],
|
|
373
376
|
"text": "Define a URL de dele\u00E7\u00E3o"
|
|
374
377
|
},
|
|
375
|
-
"attribute": "
|
|
378
|
+
"attribute": "url-delete",
|
|
376
379
|
"reflect": false
|
|
377
380
|
},
|
|
378
381
|
"value": {
|
|
@@ -443,7 +446,7 @@ export class EzUpload {
|
|
|
443
446
|
"return": "Promise<void>"
|
|
444
447
|
},
|
|
445
448
|
"docs": {
|
|
446
|
-
"text": "",
|
|
449
|
+
"text": "M\u00E9todo respons\u00E1vel por adicionar um ou mais arquivos ao componente.",
|
|
447
450
|
"tags": []
|
|
448
451
|
}
|
|
449
452
|
}
|
|
@@ -453,7 +456,7 @@ export class EzUpload {
|
|
|
453
456
|
"propName": "value",
|
|
454
457
|
"methodName": "changeValue"
|
|
455
458
|
}, {
|
|
456
|
-
"propName": "
|
|
459
|
+
"propName": "requestHeaders",
|
|
457
460
|
"methodName": "normalizeRequestHeaders"
|
|
458
461
|
}]; }
|
|
459
462
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getAssetPath, setAssetPath } from "@stencil/core";
|
|
2
|
+
export const getSpritePath = (sprite) => `${getContextAssetsPath("../assets/actions-sprite.svg")}#${sprite}`;
|
|
3
|
+
let ctxLoaded = false;
|
|
4
|
+
function getContextAssetsPath(resource) {
|
|
5
|
+
if (!ctxLoaded) {
|
|
6
|
+
const scriptElem = document.querySelector("script[data-ezui-assets-url]");
|
|
7
|
+
if (scriptElem) {
|
|
8
|
+
let assetsPath = scriptElem.dataset.ezuiAssetsUrl;
|
|
9
|
+
if (assetsPath) {
|
|
10
|
+
if (assetsPath.startsWith('/')) {
|
|
11
|
+
assetsPath = window.location.origin + assetsPath;
|
|
12
|
+
}
|
|
13
|
+
setAssetPath(assetsPath);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
ctxLoaded = true;
|
|
17
|
+
}
|
|
18
|
+
return getAssetPath(resource);
|
|
19
|
+
}
|