@sankhyalabs/ezui 1.1.40 → 1.1.41

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.
@@ -67,10 +67,9 @@ export const Field = ({ dataUnit, field, forceScroll, enabled }) => {
67
67
  const target = getProp(properties, 'URL');
68
68
  const strHeaders = getProp(properties, 'HEADERS');
69
69
  const headers = strHeaders ? JSON.parse(strHeaders) : {};
70
+ const maxfiles = Number(getProp(properties, "maxfiles") || 0);
70
71
  return (h("div", { class: "col col--sd-12 padding--small" },
71
- h("ez-upload", { onEzChange: (event) => {
72
- changeFieldHandler(event.target['value']);
73
- }, target: target, headers: headers, value: value })));
72
+ h("ez-upload", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.detail), urlupload: target, requestheaders: headers, maxfiles: maxfiles })));
74
73
  case 'DATE':
75
74
  return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
76
75
  h("ez-date-input", { value: !value ? null : DateUtils.clearTime(value), label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem), key: key }));
@@ -21,14 +21,7 @@ export const NavigationBar = ({ dataUnit: du, buttonProps, enabled }) => {
21
21
  buttonProps.removeVisible ? h("ez-button", { key: du.name + '_remove', label: "Remover", enabled: enabled && du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
22
22
  buttonProps.addVisible ? h("ez-button", { key: du.name + '_add', label: "Adicionar", enabled: enabled, onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
23
23
  buttonProps.reloadVisible ? h("ez-button", { key: du.name + '_reload', title: "Recarregar", enabled: enabled, mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
24
- buttonProps.cancelVisible ? h("ez-button", { key: du.name + '_cancel', label: "Cancelar", enabled: enabled && du.hasChanges(), onClick: () => {
25
- Application.confirm("Confirmar cancelamento", "Você perderá a edição atual do registro. Deseja continuar?", /*
26
- getAssetPath("./assets/trash-can-outline.svg")*/ null, true).then(ok => {
27
- if (ok) {
28
- du.cancel();
29
- }
30
- });
31
- }, class: "button--secondary margin-right--medium" }) : null,
24
+ buttonProps.cancelVisible ? h("ez-button", { key: du.name + '_cancel', label: "Cancelar", enabled: enabled && du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
32
25
  buttonProps.saveVisible ? h("ez-button", { key: du.name + '_save', label: "Salvar", enabled: enabled && du.hasChanges(), onClick: () => du.save(), class: "button--primary margin-right--medium" }) : null);
33
26
  }
34
27
  else {
@@ -0,0 +1,89 @@
1
+ export default class RemoteFile {
2
+ constructor(file) {
3
+ this.file = file;
4
+ this.size = file.size;
5
+ this.name = file.name;
6
+ }
7
+ abortUpload() {
8
+ if (this._uploadingXhr) {
9
+ this._aborted = true;
10
+ this._uploadingXhr.abort();
11
+ this._uploadingXhr = undefined;
12
+ }
13
+ }
14
+ isUploading() {
15
+ return this._uploadingXhr !== undefined;
16
+ }
17
+ async upload(server, headers, updateCallBack) {
18
+ return new Promise((resolve, reject) => {
19
+ const xhr = new XMLHttpRequest();
20
+ this._uploadingXhr = xhr;
21
+ this._aborted = false;
22
+ this.progress = 0;
23
+ xhr.upload.onprogress = (e) => {
24
+ const loaded = e.loaded;
25
+ const total = e.total;
26
+ this.progress = ~~((loaded / total) * 100);
27
+ updateCallBack(this, loaded, total);
28
+ };
29
+ xhr.onreadystatechange = () => {
30
+ if (xhr.readyState == 4) {
31
+ this._uploadingXhr = undefined;
32
+ const status = xhr.status;
33
+ if (!this._aborted) {
34
+ if (status === 0) {
35
+ reject("Servidor indisponível");
36
+ }
37
+ else if (status >= 500) {
38
+ reject("Erro inesperado no servidor");
39
+ }
40
+ else if (status >= 400) {
41
+ reject("Operação não permitida");
42
+ }
43
+ }
44
+ const response = xhr.response;
45
+ if (response) {
46
+ resolve(JSON.parse(response));
47
+ }
48
+ }
49
+ };
50
+ xhr.ontimeout = () => {
51
+ reject("Tempo limite de transferência atingido.");
52
+ };
53
+ const formData = new FormData();
54
+ formData.append("ARQUIVO", this.file, this.file.name);
55
+ xhr.open("POST", server, true);
56
+ if (headers) {
57
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
58
+ }
59
+ xhr.send(formData);
60
+ });
61
+ }
62
+ async delete(item, server, headers) {
63
+ return new Promise((resolve, reject) => {
64
+ const xhr = new XMLHttpRequest();
65
+ xhr.onreadystatechange = () => {
66
+ if (xhr.readyState == 4) {
67
+ if (xhr.status === 0) {
68
+ reject("Servidor indisponível");
69
+ }
70
+ else if (xhr.status >= 500) {
71
+ reject("Erro inesperado no servidor");
72
+ }
73
+ else if (xhr.status >= 400) {
74
+ reject("Operação não permitida");
75
+ }
76
+ resolve(true);
77
+ }
78
+ };
79
+ xhr.ontimeout = () => {
80
+ reject("Tempo limite de remoção atingido.");
81
+ };
82
+ xhr.open("DELETE", server, true);
83
+ if (headers) {
84
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
85
+ }
86
+ xhr.send(JSON.stringify(item));
87
+ });
88
+ }
89
+ }
@@ -53,7 +53,6 @@
53
53
 
54
54
  .iu__container {
55
55
  width: 100%;
56
- height: 100%;
57
56
  display: flex;
58
57
  flex-wrap: wrap;
59
58
  justify-content: center;
@@ -200,6 +199,22 @@ progress[value]::-webkit-progress-value {
200
199
  clip-path: path("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");
201
200
  }
202
201
 
202
+ .iu__label{
203
+ padding: var(--space--small);
204
+ padding-top: 0;
205
+ box-sizing: border-box;
206
+ overflow: hidden;
207
+ text-overflow: ellipsis;
208
+ white-space: nowrap;
209
+
210
+ /*public*/
211
+ font-family: var(--iu--font-family);
212
+ font-size: var(--text--extra-small);
213
+ font-weight: var( --iu--font-weight);
214
+ color: var(--iu--text--primary);
215
+ text-shadow: var(--iu--text-shadow);
216
+ }
217
+
203
218
  .iu__file-icon {
204
219
  outline: none;
205
220
  border: none;