@sankhyalabs/ezui 1.1.37 → 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.
- package/dist/cjs/ez-button_16.cjs.entry.js +318 -207
- package/dist/cjs/ez-dialog.cjs.entry.js +4 -4
- package/dist/cjs/ez-popup.cjs.entry.js +3 -3
- package/dist/cjs/ez-toast.cjs.entry.js +37 -0
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +18 -8
- package/dist/collection/components/ez-dialog/ez-dialog.js +16 -12
- package/dist/collection/components/ez-form/assets/trash-can-outline.svg +3 -0
- package/dist/collection/components/ez-form/ez-form.js +9 -0
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +2 -1
- package/dist/collection/components/ez-form/subcomponents/form-metadata.js +1 -5
- package/dist/collection/components/ez-form/subcomponents/structure/Field.js +2 -3
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +6 -3
- package/dist/collection/components/ez-popup/ez-popup.js +5 -5
- package/dist/collection/components/ez-search/ez-search.js +9 -7
- package/dist/collection/components/ez-toast/ez-toast.css +108 -0
- package/dist/collection/components/ez-toast/ez-toast.js +113 -0
- package/dist/collection/components/ez-upload/RemoteFile.js +89 -0
- package/dist/collection/components/ez-upload/ez-upload.css +16 -1
- package/dist/collection/components/ez-upload/ez-upload.js +246 -296
- package/dist/collection/utils/Application.js +34 -0
- package/dist/custom-elements/index.d.ts +6 -0
- package/dist/custom-elements/index.js +364 -219
- package/dist/esm/ez-button_16.entry.js +318 -207
- package/dist/esm/ez-dialog.entry.js +4 -4
- package/dist/esm/ez-popup.entry.js +3 -3
- package/dist/esm/ez-toast.entry.js +33 -0
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/assets/trash-can-outline.svg +3 -0
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-1ff02df6.entry.js +1 -0
- package/dist/ezui/p-4a87d740.entry.js +1 -0
- package/dist/ezui/p-c3b18332.entry.js +1 -0
- package/dist/ezui/p-e9784201.entry.js +1 -0
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +2 -1
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +3 -3
- package/dist/types/components/ez-form/ez-form.d.ts +2 -0
- package/dist/types/components/ez-popup/ez-popup.d.ts +1 -1
- package/dist/types/components/ez-search/ez-search.d.ts +1 -1
- package/dist/types/components/ez-toast/ez-toast.d.ts +17 -0
- package/dist/types/components/ez-upload/RemoteFile.d.ts +14 -0
- package/dist/types/components/ez-upload/ez-upload.d.ts +49 -58
- package/dist/types/components.d.ts +95 -61
- package/dist/types/utils/Application.d.ts +6 -0
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
- package/dist/ezui/p-40fe4f51.entry.js +0 -1
- package/dist/ezui/p-964a1871.entry.js +0 -1
- package/dist/ezui/p-caa50ec5.entry.js +0 -1
|
@@ -1020,12 +1020,18 @@ let EzComboBox$1 = class extends HTMLElement {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
getText() {
|
|
1022
1022
|
let text = '';
|
|
1023
|
-
const selected = this.
|
|
1023
|
+
const selected = this.getSelectedOption();
|
|
1024
1024
|
if (selected) {
|
|
1025
1025
|
text = this.showselectedvalue ? `${selected.value} - ${selected.label}` : selected.label;
|
|
1026
1026
|
}
|
|
1027
1027
|
return text;
|
|
1028
1028
|
}
|
|
1029
|
+
getSelectedOption() {
|
|
1030
|
+
if (typeof this.value === 'string' || this.value instanceof String) {
|
|
1031
|
+
return this._visibleOptions.find(o => o.value === this.value);
|
|
1032
|
+
}
|
|
1033
|
+
return this.value;
|
|
1034
|
+
}
|
|
1029
1035
|
updateVisibleOptions() {
|
|
1030
1036
|
let opts = this._source || [];
|
|
1031
1037
|
if (!this.searchmode && this._criteria) {
|
|
@@ -1094,9 +1100,11 @@ let EzComboBox$1 = class extends HTMLElement {
|
|
|
1094
1100
|
}
|
|
1095
1101
|
}
|
|
1096
1102
|
selectOption(opt) {
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1103
|
+
const currentOpt = this.getSelectedOption();
|
|
1104
|
+
if (currentOpt !== opt) {
|
|
1105
|
+
const adjustedOpt = !(opt === null || opt === void 0 ? void 0 : opt.value) ? null : opt;
|
|
1106
|
+
this.value = adjustedOpt;
|
|
1107
|
+
this.ezChange.emit(adjustedOpt);
|
|
1100
1108
|
}
|
|
1101
1109
|
else {
|
|
1102
1110
|
this.internalUpdate();
|
|
@@ -1319,7 +1327,7 @@ let EzDialog$1 = class extends HTMLElement {
|
|
|
1319
1327
|
*/
|
|
1320
1328
|
this.oppened = false;
|
|
1321
1329
|
}
|
|
1322
|
-
handleButtonClick(selectedOption) {
|
|
1330
|
+
async handleButtonClick(selectedOption) {
|
|
1323
1331
|
this.oppened = false;
|
|
1324
1332
|
this.ezChange.emit(selectedOption);
|
|
1325
1333
|
}
|
|
@@ -1328,10 +1336,10 @@ let EzDialog$1 = class extends HTMLElement {
|
|
|
1328
1336
|
return (h("div", { class: "overlay" }, h("div", { class: "dialog" }, h("div", { class: this.critical === true ? "dialog__critical--indicator" : "dialog__warning--indicator" }), h("div", { class: "dialog__container" }, h("div", { class: "title__container" }, h("div", { class: "title__box" }, this.personalizedIconPath ?
|
|
1329
1337
|
h("svg", { class: "iconePersonalizado", role: "img" }, h("use", { xlinkHref: this.personalizedIconPath }))
|
|
1330
1338
|
:
|
|
1331
|
-
h("div", { class: this.critical ? "title-icon title-icon--critical" : "title-icon" }), h("div", { class: "title title--label" }, h("h2", null, this.
|
|
1332
|
-
h("div", { class: "button-yes-no__container" }, h("ez-button", { class: "button__no", mode: "link", label: "N\u00E3o", onClick: () => this.handleButtonClick(
|
|
1339
|
+
h("div", { class: this.critical ? "title-icon title-icon--critical" : "title-icon" }), h("div", { class: "title title--label" }, h("h2", null, this.ezTitle))), h("button", { class: "btn-close", onClick: () => { this.oppened = false; this.ezChange.emit(false); } })), h("div", { class: "text text--primary text--medium message" }, this.message), this.confirm ?
|
|
1340
|
+
h("div", { class: "button-yes-no__container" }, h("ez-button", { class: "button__no", mode: "link", label: "N\u00E3o", onClick: () => this.handleButtonClick(false) }), h("ez-button", { label: "Ok", onClick: () => this.handleButtonClick(true) }))
|
|
1333
1341
|
: undefined, !this.confirm ?
|
|
1334
|
-
h("div", { class: "button__ok--container" }, h("ez-button", { label: "Ok", onClick: () => this.handleButtonClick(
|
|
1342
|
+
h("div", { class: "button__ok--container" }, h("ez-button", { label: "Ok", onClick: () => this.handleButtonClick(true) }))
|
|
1335
1343
|
: undefined))));
|
|
1336
1344
|
}
|
|
1337
1345
|
return null;
|
|
@@ -2874,11 +2882,48 @@ function showHideNavBtn(state, { buttonName, status }) {
|
|
|
2874
2882
|
return Object.assign(Object.assign({}, state), { visibleButtons });
|
|
2875
2883
|
}
|
|
2876
2884
|
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2885
|
+
class Application {
|
|
2886
|
+
static async showDialog(title, message, icon = null, confirm, critical = false) {
|
|
2887
|
+
return new Promise(resolve => {
|
|
2888
|
+
let dialog = document.querySelector("ez-dialog");
|
|
2889
|
+
if (!dialog) {
|
|
2890
|
+
dialog = document.createElement("ez-dialog");
|
|
2891
|
+
window.document.body.appendChild(dialog);
|
|
2892
|
+
}
|
|
2893
|
+
dialog.ezTitle = title;
|
|
2894
|
+
dialog.message = message;
|
|
2895
|
+
dialog.critical = critical;
|
|
2896
|
+
dialog.confirm = confirm;
|
|
2897
|
+
dialog.personalizedIconPath = icon;
|
|
2898
|
+
dialog.oppened = true;
|
|
2899
|
+
dialog.addEventListener("ezChange", (evt) => resolve(evt.detail));
|
|
2900
|
+
});
|
|
2901
|
+
}
|
|
2902
|
+
static async alert(title, message, icon = null) {
|
|
2903
|
+
return Application.showDialog(title, message, icon, false, false);
|
|
2904
|
+
}
|
|
2905
|
+
static async confirm(title, message, icon = null, critical = false) {
|
|
2906
|
+
return Application.showDialog(title, message, icon, true, critical);
|
|
2907
|
+
}
|
|
2908
|
+
static async info(message) {
|
|
2909
|
+
let toast = document.querySelector("ez-toast");
|
|
2910
|
+
if (!toast) {
|
|
2911
|
+
toast = document.createElement("ez-toast");
|
|
2912
|
+
window.document.body.appendChild(toast);
|
|
2913
|
+
}
|
|
2914
|
+
toast.message = message;
|
|
2915
|
+
toast.fadeTime = 4000;
|
|
2916
|
+
toast.show();
|
|
2880
2917
|
}
|
|
2881
2918
|
}
|
|
2919
|
+
|
|
2920
|
+
function removeHandler(dataUnit) {
|
|
2921
|
+
Application.confirm("Exclusão de registro", "Tem certeza que deseja Remover?", null, true).then(ok => {
|
|
2922
|
+
if (ok) {
|
|
2923
|
+
dataUnit.remove();
|
|
2924
|
+
}
|
|
2925
|
+
});
|
|
2926
|
+
}
|
|
2882
2927
|
const NavigationBar = ({ dataUnit: du, buttonProps, enabled }) => {
|
|
2883
2928
|
if (buttonProps.previousVisible
|
|
2884
2929
|
|| buttonProps.nextVisible
|
|
@@ -3212,7 +3257,7 @@ class DataUnit {
|
|
|
3212
3257
|
});
|
|
3213
3258
|
const result = this.recordsValidator.validateRecords(this, recordsToValidate, triggedBy);
|
|
3214
3259
|
if (result.message) {
|
|
3215
|
-
|
|
3260
|
+
Application.info(result.message);
|
|
3216
3261
|
}
|
|
3217
3262
|
return result.isValid;
|
|
3218
3263
|
}
|
|
@@ -3290,10 +3335,9 @@ const Field = ({ dataUnit, field, forceScroll, enabled }) => {
|
|
|
3290
3335
|
const target = getProp(properties, 'URL');
|
|
3291
3336
|
const strHeaders = getProp(properties, 'HEADERS');
|
|
3292
3337
|
const headers = strHeaders ? JSON.parse(strHeaders) : {};
|
|
3338
|
+
const maxfiles = Number(getProp(properties, "maxfiles") || 0);
|
|
3293
3339
|
return (h("div", { class: "col col--sd-12 padding--small" },
|
|
3294
|
-
h("ez-upload", { onEzChange: (event) =>
|
|
3295
|
-
changeFieldHandler(event.target['value']);
|
|
3296
|
-
}, target: target, headers: headers, value: value })));
|
|
3340
|
+
h("ez-upload", { value: value, label: formattedLabel, enabled: isEnabled, onEzChange: (event) => changeFieldHandler(event.detail), urlupload: target, requestheaders: headers, maxfiles: maxfiles })));
|
|
3297
3341
|
case 'DATE':
|
|
3298
3342
|
return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData ? h("place-holder", null) :
|
|
3299
3343
|
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 }));
|
|
@@ -3388,6 +3432,7 @@ let EzForm$1 = class extends HTMLElement {
|
|
|
3388
3432
|
this._dataUnits = new Map();
|
|
3389
3433
|
this._duSources = new Map();
|
|
3390
3434
|
this._tabPositionByField = new Map();
|
|
3435
|
+
this._duToLoad = [];
|
|
3391
3436
|
}
|
|
3392
3437
|
cleanPreparedMetadata() {
|
|
3393
3438
|
this._preparedMetadata = undefined;
|
|
@@ -3527,6 +3572,9 @@ let EzForm$1 = class extends HTMLElement {
|
|
|
3527
3572
|
};
|
|
3528
3573
|
this._preparedMetadata = metadata.map((form, index) => {
|
|
3529
3574
|
const du = form.dataUnit;
|
|
3575
|
+
if (form.autoLoad) {
|
|
3576
|
+
this._duToLoad.push(du);
|
|
3577
|
+
}
|
|
3530
3578
|
this.decorateDU(du);
|
|
3531
3579
|
const duName = du.name;
|
|
3532
3580
|
this._duSources.set(duName, du);
|
|
@@ -3568,6 +3616,10 @@ let EzForm$1 = class extends HTMLElement {
|
|
|
3568
3616
|
}
|
|
3569
3617
|
}
|
|
3570
3618
|
}
|
|
3619
|
+
componentDidRender() {
|
|
3620
|
+
this._duToLoad.forEach(du => du.load());
|
|
3621
|
+
this._duToLoad = [];
|
|
3622
|
+
}
|
|
3571
3623
|
loadSearch(argument, context) {
|
|
3572
3624
|
const fieldSearchExecutor = this.parseExecutor(this.fieldsearchexecutor);
|
|
3573
3625
|
if (fieldSearchExecutor) {
|
|
@@ -3609,6 +3661,7 @@ let EzForm$1 = class extends HTMLElement {
|
|
|
3609
3661
|
render() {
|
|
3610
3662
|
return this._preparedMetadata ? h(FormSheet, { enabled: this.enabled, store: this._store, source: this._preparedMetadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
|
|
3611
3663
|
}
|
|
3664
|
+
static get assetsDirs() { return ["assets"]; }
|
|
3612
3665
|
get _host() { return this; }
|
|
3613
3666
|
static get watchers() { return {
|
|
3614
3667
|
"metadata": ["cleanPreparedMetadata"]
|
|
@@ -4304,9 +4357,9 @@ let EzPopup$1 = class extends HTMLElement {
|
|
|
4304
4357
|
}
|
|
4305
4358
|
render() {
|
|
4306
4359
|
if (this.opened) {
|
|
4307
|
-
return (h(Host, null, h("div", { class: "overlay" }, h("div", { class: "popup col " + this.size }, h("div", { class: "popup__container" }, h("div", { class: "popup__content" }, h("div", { class: "popup__header" }, this.
|
|
4308
|
-
h("div", { class: "title popup__title" }, this.
|
|
4309
|
-
: undefined, h("button", { class: this.
|
|
4360
|
+
return (h(Host, null, h("div", { class: "overlay" }, h("div", { class: "popup col " + this.size }, h("div", { class: "popup__container" }, h("div", { class: "popup__content" }, h("div", { class: "popup__header" }, this.ezTitle ?
|
|
4361
|
+
h("div", { class: "title popup__title" }, this.ezTitle)
|
|
4362
|
+
: undefined, h("button", { class: this.ezTitle ? "btn-close" : "btn-close btn-close--solo", onClick: () => { this.opened = false; this.ezChange.emit("CANCEL"); } })), h("div", { class: "popup__expandable-content" }, h("slot", null))))))));
|
|
4310
4363
|
}
|
|
4311
4364
|
return null;
|
|
4312
4365
|
}
|
|
@@ -4341,8 +4394,9 @@ let EzSearch$1 = class extends HTMLElement {
|
|
|
4341
4394
|
}
|
|
4342
4395
|
}
|
|
4343
4396
|
onComboChange(evt) {
|
|
4344
|
-
|
|
4345
|
-
this.
|
|
4397
|
+
evt.stopPropagation();
|
|
4398
|
+
this.value = evt.detail;
|
|
4399
|
+
this.ezChange.emit(evt.detail);
|
|
4346
4400
|
}
|
|
4347
4401
|
render() {
|
|
4348
4402
|
return (h("ez-combo-box", { ref: elem => this._comboElement = elem, value: this.value, label: this.label, enabled: this.enabled, errormessage: this.errormessage, optionloader: this.optionloader, searchmode: true, onEzChange: evt => this.onComboChange(evt), showselectedvalue: this.showselectedvalue, showoptionvalue: this.showoptionvalue }));
|
|
@@ -5038,145 +5092,249 @@ let EzTimeInput$1 = class extends HTMLElement {
|
|
|
5038
5092
|
static get style() { return ezTimeInputCss; }
|
|
5039
5093
|
};
|
|
5040
5094
|
|
|
5041
|
-
const
|
|
5095
|
+
const ezToastCss = ":host{--toast-z-index:var(--more-visible, 2);--toast-color--secondary:var(--color--secondary, #383c45);--toast-title--primary:var(--title--primary, #2b3a54);--toast-space--small:var(--space--small, 6px);--toast--close__image:url('data:image/svg+xml;utf8,<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" xmlns=\"http://www.w3.org/2000/svg%22%3E<path d=\"M 7.0060773,5.995511 11.461972,1.5397722 c 0.132856,-0.1328413 0.207547,-0.3130253 0.207547,-0.5009046 0,-0.18786999 -0.07469,-0.3680541 -0.207547,-0.5009048 -0.132857,-0.13284126 -0.31302,-0.20748126 -0.500927,-0.20748126 -0.187812,0 -0.36807,0.07464 -0.500926,0.20748126 L 6.0042244,4.9937015 1.5482921,0.5379628 C 1.4154357,0.40512154 1.2352533,0.33048154 1.0473657,0.33048154 c -0.18787813,0 -0.36807,0.07464 -0.50092647,0.20748126 -0.13285646,0.1328507 -0.20749026,0.31303481 -0.20749026,0.5009048 0,0.1878793 0.0746338,0.3680633 0.20749026,0.5009046 L 5.0023715,5.995511 0.54643923,10.452213 c -0.0676086,0.06534 -0.12151598,0.14352 -0.15859681,0.229916 -0.0370714,0.08639 -0.0565645,0.1794 -0.0573369,0.27335 -7.724e-4,0.09404 0.0171873,0.187331 0.0528423,0.274293 0.0356455,0.08705 0.0882688,0.166087 0.15479148,0.23256 0.0665321,0.06648 0.14562277,0.11897 0.2326735,0.154567 0.0870507,0.0356 0.18031463,0.05344 0.2743433,0.05259 0.094029,-8.5e-4 0.1869528,-0.02049 0.2733331,-0.0576 0.08639,-0.0372 0.1645078,-0.09121 0.2298029,-0.158817 L 6.0042244,6.9973204 10.460119,11.453078 c 0.132856,0.132851 0.313114,0.207444 0.500926,0.207444 0.187907,0 0.36807,-0.07459 0.500927,-0.207444 0.132856,-0.13285 0.207547,-0.313006 0.207547,-0.500904 0,-0.187898 -0.07469,-0.368054 -0.207547,-0.500905 z\"/></svg>')}.toast__container{position:fixed;display:flex;bottom:100px;z-index:var(--toast-z-index);left:100px;width:30%;box-sizing:border-box;background-color:var(--toast-color--secondary);border-radius:6px;align-items:center;padding:12px;visibility:hidden}.message__container{font-family:\"Sora\", \"Algerian\";text-shadow:0 0 0 #353535, 0 0 1px transparent;color:#FFFFFF;font-size:14px;width:90%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.message__conteiner--icon{padding-left:var(--toast-space--small);width:80%}.btn-close{display:flex;justify-content:flex-end;padding:0;outline:none;width:10%;border:none;background-color:unset;cursor:pointer}.btn-close::after{content:'';display:flex;background-color:#FFFFFF;width:12px;height:12px;-webkit-mask-image:var(--toast--close__image);mask-image:var(--toast--close__image)}.toast__container--oppened{animation:fadein 0.5s, fadeout 0.5s 3s;visibility:visible}@-webkit-keyframes fadein{from{left:-100px;opacity:0}to{left:100px;opacity:1}}@keyframes fadein{from{left:-100px;opacity:0}to{left:100px;opacity:1}}@-webkit-keyframes fadeout{from{left:100px;opacity:1}to{bottom:0;opacity:0}}@keyframes fadeout{from{left:100px;opacity:1}to{bottom:0;opacity:0}}";
|
|
5042
5096
|
|
|
5043
|
-
let
|
|
5097
|
+
let EzToast$1 = class extends HTMLElement {
|
|
5044
5098
|
constructor() {
|
|
5045
5099
|
super();
|
|
5046
5100
|
this.__registerHost();
|
|
5047
5101
|
this.__attachShadow();
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
this.
|
|
5102
|
+
/**
|
|
5103
|
+
* Controla o tempo de exibição do componente em milissegundos.
|
|
5104
|
+
*/
|
|
5105
|
+
this.fadeTime = 5000;
|
|
5106
|
+
/**
|
|
5107
|
+
* Adiciona ícone de check no componente.
|
|
5108
|
+
*/
|
|
5109
|
+
this.useIcon = false;
|
|
5052
5110
|
}
|
|
5053
|
-
|
|
5054
|
-
this.
|
|
5111
|
+
async show() {
|
|
5112
|
+
this.container.classList.add("toast__container--oppened");
|
|
5113
|
+
this.container.style.animation = `fadein 0.5s, fadeout 0.5s ${this.fadeTime / 1000}s`;
|
|
5114
|
+
setTimeout(() => {
|
|
5115
|
+
this.container.classList.remove("toast__container--oppened");
|
|
5116
|
+
this.container.style.animation = `none`;
|
|
5117
|
+
}, this.fadeTime + 400);
|
|
5055
5118
|
}
|
|
5056
|
-
|
|
5057
|
-
|
|
5119
|
+
render() {
|
|
5120
|
+
return (h("div", { ref: (el) => this.container = el, class: "toast__container" }, this.useIcon ?
|
|
5121
|
+
h("slot", { name: "icon" })
|
|
5122
|
+
: undefined, h("div", { class: this.useIcon ? "message__container message__conteiner--icon" : "message__container", title: this.message }, " ", this.message, " "), h("button", { class: "btn-close", onClick: () => { this.container.classList.remove("toast__container--oppened"); this.container.style.animation = `none`; } })));
|
|
5058
5123
|
}
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5124
|
+
static get style() { return ezToastCss; }
|
|
5125
|
+
};
|
|
5126
|
+
|
|
5127
|
+
class RemoteFile {
|
|
5128
|
+
constructor(file) {
|
|
5129
|
+
this.file = file;
|
|
5130
|
+
this.size = file.size;
|
|
5131
|
+
this.name = file.name;
|
|
5132
|
+
}
|
|
5133
|
+
abortUpload() {
|
|
5134
|
+
if (this._uploadingXhr) {
|
|
5135
|
+
this._aborted = true;
|
|
5136
|
+
this._uploadingXhr.abort();
|
|
5137
|
+
this._uploadingXhr = undefined;
|
|
5138
|
+
}
|
|
5139
|
+
}
|
|
5140
|
+
isUploading() {
|
|
5141
|
+
return this._uploadingXhr !== undefined;
|
|
5142
|
+
}
|
|
5143
|
+
async upload(server, headers, updateCallBack) {
|
|
5144
|
+
return new Promise((resolve, reject) => {
|
|
5145
|
+
const xhr = new XMLHttpRequest();
|
|
5146
|
+
this._uploadingXhr = xhr;
|
|
5147
|
+
this._aborted = false;
|
|
5148
|
+
this.progress = 0;
|
|
5149
|
+
xhr.upload.onprogress = (e) => {
|
|
5150
|
+
const loaded = e.loaded;
|
|
5151
|
+
const total = e.total;
|
|
5152
|
+
this.progress = ~~((loaded / total) * 100);
|
|
5153
|
+
updateCallBack(this, loaded, total);
|
|
5154
|
+
};
|
|
5155
|
+
xhr.onreadystatechange = () => {
|
|
5156
|
+
if (xhr.readyState == 4) {
|
|
5157
|
+
this._uploadingXhr = undefined;
|
|
5158
|
+
const status = xhr.status;
|
|
5159
|
+
if (!this._aborted) {
|
|
5160
|
+
if (status === 0) {
|
|
5161
|
+
reject("Servidor indisponível");
|
|
5162
|
+
}
|
|
5163
|
+
else if (status >= 500) {
|
|
5164
|
+
reject("Erro inesperado no servidor");
|
|
5165
|
+
}
|
|
5166
|
+
else if (status >= 400) {
|
|
5167
|
+
reject("Operação não permitida");
|
|
5168
|
+
}
|
|
5169
|
+
}
|
|
5170
|
+
const response = xhr.response;
|
|
5171
|
+
if (response) {
|
|
5172
|
+
resolve(JSON.parse(response));
|
|
5173
|
+
}
|
|
5174
|
+
}
|
|
5175
|
+
};
|
|
5176
|
+
xhr.ontimeout = () => {
|
|
5177
|
+
reject("Tempo limite de transferência atingido.");
|
|
5178
|
+
};
|
|
5179
|
+
const formData = new FormData();
|
|
5180
|
+
formData.append("ARQUIVO", this.file, this.file.name);
|
|
5181
|
+
xhr.open("POST", server, true);
|
|
5182
|
+
if (headers) {
|
|
5183
|
+
headers.forEach((value, key) => xhr.setRequestHeader(key, value));
|
|
5073
5184
|
}
|
|
5074
|
-
|
|
5185
|
+
xhr.send(formData);
|
|
5186
|
+
});
|
|
5075
5187
|
}
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
this.validatedEvent.emit({ isValid: isValid, fileName: file.name });
|
|
5084
|
-
return isValid;
|
|
5085
|
-
}
|
|
5086
|
-
_uploadFile(file) {
|
|
5087
|
-
const xhr = (file.xhr = this._createXhr());
|
|
5088
|
-
this.value = [];
|
|
5089
|
-
this.value.push({ name: file.name, size: file.size, xhr: file.xhr, strSize: this.formatBytes(file.size) });
|
|
5090
|
-
let stalledId;
|
|
5091
|
-
xhr.upload.onprogress = (e) => {
|
|
5092
|
-
clearTimeout(stalledId);
|
|
5093
|
-
const loaded = e.loaded, total = e.total, progress = ~~((loaded / total) * 100);
|
|
5094
|
-
let viewFile = this.value.find(f => f.name === file.name);
|
|
5095
|
-
if (viewFile) {
|
|
5096
|
-
viewFile.progress = progress;
|
|
5097
|
-
}
|
|
5098
|
-
this.value = [...this.value];
|
|
5099
|
-
};
|
|
5100
|
-
xhr.onreadystatechange = () => {
|
|
5101
|
-
this.errorMessage = '';
|
|
5102
|
-
if (xhr.readyState == 4) {
|
|
5103
|
-
clearTimeout(stalledId);
|
|
5104
|
-
file.indeterminate = file.uploading = false;
|
|
5105
|
-
if (xhr.status === 0) ;
|
|
5106
|
-
else if (xhr.status >= 500) {
|
|
5107
|
-
this.errorMessage = "Erro inesperado no servidor";
|
|
5108
|
-
}
|
|
5109
|
-
else if (xhr.status >= 400) {
|
|
5110
|
-
this.errorMessage = "Operação não permitida";
|
|
5111
|
-
}
|
|
5112
|
-
if (this.errorMessage && this.errorMessage.length > 0) {
|
|
5113
|
-
//TODO
|
|
5114
|
-
// Conferir com o time de UX um estado de erro ou remoção da lista
|
|
5115
|
-
// this.removeFile(file.name);
|
|
5116
|
-
alert(this.errorMessage);
|
|
5117
|
-
}
|
|
5118
|
-
else {
|
|
5119
|
-
if (xhr.response) {
|
|
5120
|
-
let response = JSON.parse(xhr.response);
|
|
5121
|
-
response.forEach(element => {
|
|
5122
|
-
let viewFile = this.value.find(f => f.name === this.decode_utf8(element.name));
|
|
5123
|
-
if (viewFile) {
|
|
5124
|
-
viewFile.progress = undefined;
|
|
5125
|
-
//Validar estado de erro com UX
|
|
5126
|
-
viewFile.error = false;
|
|
5127
|
-
delete viewFile.xhr;
|
|
5128
|
-
viewFile.downloadUrl = element.downloadURL;
|
|
5129
|
-
viewFile.lastModifiedDate = element.lastModifiedDate;
|
|
5130
|
-
viewFile.properties = element.properties;
|
|
5131
|
-
}
|
|
5132
|
-
});
|
|
5133
|
-
this.value = [...this.value];
|
|
5134
|
-
this.fileListChange();
|
|
5188
|
+
async delete(item, server, headers) {
|
|
5189
|
+
return new Promise((resolve, reject) => {
|
|
5190
|
+
const xhr = new XMLHttpRequest();
|
|
5191
|
+
xhr.onreadystatechange = () => {
|
|
5192
|
+
if (xhr.readyState == 4) {
|
|
5193
|
+
if (xhr.status === 0) {
|
|
5194
|
+
reject("Servidor indisponível");
|
|
5135
5195
|
}
|
|
5136
|
-
else {
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5196
|
+
else if (xhr.status >= 500) {
|
|
5197
|
+
reject("Erro inesperado no servidor");
|
|
5198
|
+
}
|
|
5199
|
+
else if (xhr.status >= 400) {
|
|
5200
|
+
reject("Operação não permitida");
|
|
5141
5201
|
}
|
|
5202
|
+
resolve(true);
|
|
5142
5203
|
}
|
|
5204
|
+
};
|
|
5205
|
+
xhr.ontimeout = () => {
|
|
5206
|
+
reject("Tempo limite de remoção atingido.");
|
|
5207
|
+
};
|
|
5208
|
+
xhr.open("DELETE", server, true);
|
|
5209
|
+
if (headers) {
|
|
5210
|
+
headers.forEach((value, key) => xhr.setRequestHeader(key, value));
|
|
5143
5211
|
}
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5212
|
+
xhr.send(JSON.stringify(item));
|
|
5213
|
+
});
|
|
5214
|
+
}
|
|
5215
|
+
}
|
|
5216
|
+
|
|
5217
|
+
const ezUploadCss = ":host{--iu--height:42px;--iu--width:100%;--iu__icon--width:48px;--iu__container--background-color:var(--background--medium, #d2dce9);--iu__color--primary:var(--color--primary, #008561);--iu--padding--extra-small:var(--space--extra-small, 3px);--iu--padding--small:var(--space--small, 6px);--iu--padding--medium:var(--space--medium, 12px);--iu--padding--large:var(--space--large, 24px);--iu--border-radius:var(--border--radius-medium, 12px);--iu__border--color:var(--color-strokes, #DCE0E8);--iu__input--border:var(--border--medium, 2px solid);--iu--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--iu--text--primary:var(--text-primary, #626e82);--iu--font-size:var(--text--medium, 14px);--iu--font-family:var(--font-pattern, Arial);--iu--font-weight:var(--text-weight--large, 500);display:flex;flex-wrap:wrap;position:relative;font-family:var(--iu--font-family);font-size:var(--iu--font-size);width:var(--iu--width);font-weight:var(--iu--font-weight)}.iu{display:flex;flex-wrap:wrap;background-color:var(--iu__container--background-color);padding:var(--iu--padding--small);width:100%;border-radius:12px;box-sizing:border-box}.iu__container{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;border:2px dashed var(--iu__border--color);border-radius:6px;box-sizing:border-box}.iu__footer{display:flex;flex-wrap:wrap;justify-content:flex-start;width:100%;padding:0 var(--iu--padding--medium) var(--iu--padding--medium) var(--iu--padding--medium);box-sizing:border-box}.iu__item{display:flex;width:100%;justify-content:flex-start;align-items:center;align-self:center;padding-bottom:var(--iu--padding--extra-small);box-sizing:border-box;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.iu__item-label{display:flex;max-width:80%;align-self:stretch;align-items:center}.file__name{font-weight:200}.box__content{width:100%;justify-content:center;align-items:center;height:100%;border:1px dashed var(--iu__border--color);border-radius:6px;box-sizing:border-box}.box__container{display:flex;flex-wrap:wrap;background-color:var(--iu__container--background-color);padding:6px;width:100%;border-radius:12px}a:-webkit-any-link{color:#008561;fill:#008561;cursor:pointer;text-decoration:none}progress[value]{display:flex;width:100%;appearance:none;border:1px solid var(--iu__border--color);height:12px;justify-content:flex-start;align-items:center;border-radius:3px;position:relative}progress[value]::-webkit-progress-bar{display:flex;-webkit-appearance:none;width:100%;background-color:rgb(255, 255, 255);border-radius:2px;padding:2px}progress[value]::-webkit-progress-value{display:flex;width:100%;background-color:var(--iu__color--primary)}.text--center{text-align:center}.align--middle{align-self:center;align-items:center}.text{font-family:\"Sora\", \"Algerian\";text-shadow:0 0 0 #353535, 0 0 1px transparent}.text--primary{color:var(--iu--text--primary);text-shadow:var(--iu--text-shadow)}.text--ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.text--medium{font-size:14px}.text--small{font-size:12px}.btn-cancel{outline:none;border:none;background-color:unset;cursor:pointer}.btn-cancel::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:8px;height:8px;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\")}.iu__label{padding:var(--space--small);padding-top:0;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--iu--font-family);font-size:var(--text--extra-small);font-weight:var( --iu--font-weight);color:var(--iu--text--primary);text-shadow:var(--iu--text-shadow)}.iu__file-icon{outline:none;border:none;background-color:unset;cursor:pointer}.iu__file-icon::after{content:'';display:flex;background-color:var(--text--primary, #626e82);width:9px;height:11px;clip-path:path(\"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\")}.iu__icon-label{justify-content:center;display:flex;cursor:pointer;padding:var(--iu--padding--large) 0px;box-sizing:border-box}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}";
|
|
5218
|
+
|
|
5219
|
+
let EzUpload$1 = class extends HTMLElement {
|
|
5220
|
+
constructor() {
|
|
5221
|
+
super();
|
|
5222
|
+
this.__registerHost();
|
|
5223
|
+
this.__attachShadow();
|
|
5224
|
+
this.ezChange = createEvent(this, "ezChange", 7);
|
|
5225
|
+
this._filePointers = new Map();
|
|
5226
|
+
/**
|
|
5227
|
+
* Deixa o campo disponível ou não para digitação.
|
|
5228
|
+
*/
|
|
5229
|
+
this.enabled = true;
|
|
5230
|
+
}
|
|
5231
|
+
updatePointers(newValue) {
|
|
5232
|
+
if (newValue !== this._updatingValue) {
|
|
5233
|
+
this._filePointers.forEach(f => {
|
|
5234
|
+
if (this.isRemoteFile(f)) {
|
|
5235
|
+
f.abortUpload();
|
|
5236
|
+
}
|
|
5237
|
+
});
|
|
5238
|
+
this._filePointers = new Map();
|
|
5239
|
+
if (newValue) {
|
|
5240
|
+
newValue.forEach(ezFile => this._filePointers.set(ezFile.name, ezFile));
|
|
5150
5241
|
}
|
|
5151
|
-
}
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
this.
|
|
5156
|
-
|
|
5157
|
-
file.uploading = file.indeterminate = true;
|
|
5158
|
-
file.complete = file.abort = file.error = file.held = false;
|
|
5159
|
-
xhr.send(formData);
|
|
5160
|
-
}
|
|
5161
|
-
_createXhr() {
|
|
5162
|
-
return new XMLHttpRequest();
|
|
5163
|
-
}
|
|
5164
|
-
_configureXhr(xhr) {
|
|
5165
|
-
if (typeof this.headers == 'string') {
|
|
5242
|
+
}
|
|
5243
|
+
this._updatingValue = undefined;
|
|
5244
|
+
}
|
|
5245
|
+
normalizeRequestHeaders() {
|
|
5246
|
+
this._requestHeaders = new Map();
|
|
5247
|
+
if (typeof this.requestheaders == 'string') {
|
|
5166
5248
|
try {
|
|
5167
|
-
this.
|
|
5249
|
+
this.requestheaders = JSON.parse(this.requestheaders);
|
|
5168
5250
|
}
|
|
5169
5251
|
catch (e) {
|
|
5170
|
-
this.
|
|
5252
|
+
this.requestheaders = undefined;
|
|
5253
|
+
}
|
|
5254
|
+
}
|
|
5255
|
+
for (var key in this.requestheaders) {
|
|
5256
|
+
this._requestHeaders.set(key, this.requestheaders[key]);
|
|
5257
|
+
}
|
|
5258
|
+
}
|
|
5259
|
+
async addFiles(files) {
|
|
5260
|
+
Array.prototype.forEach.call(files, this.addFile.bind(this));
|
|
5261
|
+
}
|
|
5262
|
+
async addFile(file) {
|
|
5263
|
+
const oldFile = this._filePointers.get(file.name);
|
|
5264
|
+
if (oldFile) {
|
|
5265
|
+
Application.confirm("Substituir arquivo", `Já existe um arquivo chamado "${file.name}". Deseja substituí-lo?`)
|
|
5266
|
+
.then(ok => {
|
|
5267
|
+
if (ok) {
|
|
5268
|
+
if (this.isRemoteFile(oldFile)) {
|
|
5269
|
+
oldFile.abortUpload();
|
|
5270
|
+
}
|
|
5271
|
+
this.doAddFile(file);
|
|
5272
|
+
}
|
|
5273
|
+
});
|
|
5274
|
+
}
|
|
5275
|
+
else {
|
|
5276
|
+
this.doAddFile(file);
|
|
5277
|
+
}
|
|
5278
|
+
}
|
|
5279
|
+
async doAddFile(file) {
|
|
5280
|
+
if (this.validateFile(file)) {
|
|
5281
|
+
const uploadingFile = new RemoteFile(file);
|
|
5282
|
+
this._filePointers.set(file.name, uploadingFile);
|
|
5283
|
+
uploadingFile.upload(this.urlupload, this._requestHeaders, (file) => this.updateFeedback(file))
|
|
5284
|
+
.then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
|
|
5285
|
+
.catch(msg => this.showError(msg));
|
|
5286
|
+
forceUpdate(this);
|
|
5287
|
+
}
|
|
5288
|
+
}
|
|
5289
|
+
finishUpload(ezFile) {
|
|
5290
|
+
this._filePointers.set(ezFile.name, ezFile);
|
|
5291
|
+
this.updateValue();
|
|
5292
|
+
}
|
|
5293
|
+
updateValue() {
|
|
5294
|
+
this._updatingValue = [];
|
|
5295
|
+
this._filePointers.forEach(f => {
|
|
5296
|
+
if (!this.isRemoteFile(f)) {
|
|
5297
|
+
this._updatingValue.push(f);
|
|
5298
|
+
}
|
|
5299
|
+
});
|
|
5300
|
+
this.value = this._updatingValue;
|
|
5301
|
+
this.ezChange.emit(this.value);
|
|
5302
|
+
}
|
|
5303
|
+
buildProgressId(uploading) {
|
|
5304
|
+
let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, '_');
|
|
5305
|
+
return `PROGRESS_${sanitizedName}_${uploading.file.lastModified}`;
|
|
5306
|
+
}
|
|
5307
|
+
updateFeedback(uf) {
|
|
5308
|
+
window.requestAnimationFrame(() => {
|
|
5309
|
+
if (this._host) {
|
|
5310
|
+
const progress = this._host.shadowRoot.querySelector('#' + this.buildProgressId(uf));
|
|
5311
|
+
if (progress) {
|
|
5312
|
+
progress.value = uf.progress;
|
|
5313
|
+
}
|
|
5171
5314
|
}
|
|
5315
|
+
});
|
|
5316
|
+
}
|
|
5317
|
+
validateFile(file) {
|
|
5318
|
+
if (this.maxfiles > 0 && this._filePointers.size >= this.maxfiles) {
|
|
5319
|
+
this.showError(`A quantidade máxima de arquivos é ${this.maxfiles}.`);
|
|
5320
|
+
return false;
|
|
5172
5321
|
}
|
|
5173
|
-
|
|
5174
|
-
|
|
5322
|
+
if (file.size === 0) {
|
|
5323
|
+
this.showError(`Erro de permissão: O arquivo "${file.name}" não pode ser enviado.`);
|
|
5324
|
+
return false;
|
|
5175
5325
|
}
|
|
5176
|
-
if (this.
|
|
5177
|
-
|
|
5326
|
+
if (!this.urlupload) {
|
|
5327
|
+
this.showError("Endereço de upload não informado");
|
|
5328
|
+
return false;
|
|
5178
5329
|
}
|
|
5179
|
-
|
|
5330
|
+
if (this.maxfilesize >= 0 && file.size > this.maxfilesize) {
|
|
5331
|
+
this.showError("O tamanho máximo dos arquivos é de " + this.formatBytes(this.maxfilesize));
|
|
5332
|
+
return false;
|
|
5333
|
+
}
|
|
5334
|
+
return true;
|
|
5335
|
+
}
|
|
5336
|
+
showError(message) {
|
|
5337
|
+
Application.alert("Enviando arquivo", message);
|
|
5180
5338
|
}
|
|
5181
5339
|
formatBytes(bytes, decimals = 1) {
|
|
5182
5340
|
if (bytes === 0)
|
|
@@ -5188,96 +5346,85 @@ let EzUpload$1 = class extends HTMLElement {
|
|
|
5188
5346
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
5189
5347
|
}
|
|
5190
5348
|
onFileInputChange(event) {
|
|
5191
|
-
|
|
5349
|
+
const input = event.target;
|
|
5350
|
+
this.addFiles(Array.from(input.files));
|
|
5192
5351
|
this._fileInput.value = '';
|
|
5193
5352
|
}
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5353
|
+
isRemoteFile(item) {
|
|
5354
|
+
return "file" in item;
|
|
5355
|
+
}
|
|
5356
|
+
removeFromList(name) {
|
|
5357
|
+
this._filePointers.delete(name);
|
|
5358
|
+
this.updateValue();
|
|
5359
|
+
}
|
|
5360
|
+
removeFile(name) {
|
|
5361
|
+
const item = this._filePointers.get(name);
|
|
5362
|
+
if (this.isRemoteFile(item)) {
|
|
5363
|
+
item.abortUpload();
|
|
5364
|
+
this.removeFromList(name);
|
|
5365
|
+
}
|
|
5366
|
+
else {
|
|
5367
|
+
if (this.urldelete) {
|
|
5368
|
+
const uploadingFile = new RemoteFile(null);
|
|
5369
|
+
this._filePointers.set(item.name, uploadingFile);
|
|
5370
|
+
uploadingFile.delete(item, this.urldelete, null)
|
|
5371
|
+
.then(_ok => this.removeFromList(name))
|
|
5372
|
+
.catch(msg => this.showError(msg));
|
|
5373
|
+
}
|
|
5374
|
+
else {
|
|
5375
|
+
this.removeFromList(name);
|
|
5376
|
+
}
|
|
5202
5377
|
}
|
|
5203
|
-
}*/
|
|
5204
|
-
decode_utf8(s) {
|
|
5205
|
-
return decodeURIComponent(escape(s));
|
|
5206
5378
|
}
|
|
5207
5379
|
componentDidLoad() {
|
|
5208
|
-
if (this.
|
|
5209
|
-
this.
|
|
5380
|
+
if (this._dropZone && window.FileList && window.File) {
|
|
5381
|
+
this._dropZone.addEventListener('dragover', event => {
|
|
5210
5382
|
event.stopPropagation();
|
|
5211
5383
|
event.preventDefault();
|
|
5212
5384
|
event.dataTransfer.dropEffect = 'copy';
|
|
5213
5385
|
});
|
|
5214
|
-
this.
|
|
5386
|
+
this._dropZone.addEventListener('drop', event => {
|
|
5215
5387
|
event.stopPropagation();
|
|
5216
5388
|
event.preventDefault();
|
|
5217
|
-
this.addFiles(event.dataTransfer.files);
|
|
5389
|
+
this.addFiles(Array.from(event.dataTransfer.files));
|
|
5218
5390
|
});
|
|
5219
5391
|
}
|
|
5220
5392
|
}
|
|
5221
|
-
|
|
5222
|
-
if (
|
|
5223
|
-
|
|
5393
|
+
openFilesDialog() {
|
|
5394
|
+
if (this.maxfiles > 0 && this._filePointers.size >= this.maxfiles) {
|
|
5395
|
+
this.showError(`A quantidade máxima de arquivos é ${this.maxfiles}.`);
|
|
5224
5396
|
}
|
|
5225
|
-
|
|
5226
|
-
this.
|
|
5397
|
+
else {
|
|
5398
|
+
this._fileInput.click();
|
|
5227
5399
|
}
|
|
5228
|
-
this.value = [...this.value.filter(function (value) { return value.name !== name; })];
|
|
5229
|
-
}
|
|
5230
|
-
removeFileFromServer(name, donwloadURL) {
|
|
5231
|
-
const xhr = this._createXhr();
|
|
5232
|
-
this.errorMessage = '';
|
|
5233
|
-
let stalledId;
|
|
5234
|
-
xhr.onreadystatechange = () => {
|
|
5235
|
-
if (xhr.readyState == 4) {
|
|
5236
|
-
clearTimeout(stalledId);
|
|
5237
|
-
if (xhr.status === 0) {
|
|
5238
|
-
this.errorMessage = "Servidor indisponível";
|
|
5239
|
-
}
|
|
5240
|
-
else if (xhr.status >= 500) {
|
|
5241
|
-
this.errorMessage = "Erro inesperado no servidor";
|
|
5242
|
-
}
|
|
5243
|
-
else if (xhr.status >= 400) {
|
|
5244
|
-
this.errorMessage = "Operação não permitida";
|
|
5245
|
-
}
|
|
5246
|
-
if (this.errorMessage && this.errorMessage.length > 0) {
|
|
5247
|
-
//TODO
|
|
5248
|
-
// Conferir com o time de UX um estado de erro ou remoção da lista
|
|
5249
|
-
// this.removeFile(file.name);
|
|
5250
|
-
alert(this.errorMessage);
|
|
5251
|
-
}
|
|
5252
|
-
}
|
|
5253
|
-
};
|
|
5254
|
-
xhr.ontimeout = () => {
|
|
5255
|
-
if (this.errorMessage && this.errorMessage.length > 0) {
|
|
5256
|
-
alert(this.errorMessage);
|
|
5257
|
-
}
|
|
5258
|
-
};
|
|
5259
|
-
const body = JSON.stringify({
|
|
5260
|
-
name: name,
|
|
5261
|
-
donwloadURL: donwloadURL,
|
|
5262
|
-
});
|
|
5263
|
-
xhr.open("DELETE", this.target, true);
|
|
5264
|
-
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
5265
|
-
this._configureXhr(xhr);
|
|
5266
|
-
xhr.send(body);
|
|
5267
5400
|
}
|
|
5268
5401
|
render() {
|
|
5269
|
-
|
|
5270
|
-
return (h(Host, null, h("slot", null, h("div", { ref: (el) => this.dropZone = el, class: "iu" }, h("div", { class: "iu__container" }, h("div", { onClick: () => this._fileInput.click(), class: "iu__icon-label" }, h("button", { class: "iu__file-icon" }), h("div", { class: "text text--center text--medium text--primary" }, "Arraste e solte ou clique para anexar arquivo")), ((_a = this.value) === null || _a === void 0 ? void 0 : _a.length) > 0 ?
|
|
5271
|
-
h("div", { class: "iu__footer" }, this.value.map(file => {
|
|
5272
|
-
return (h("div", { class: "iu__item" }, h("div", { class: "iu__item-label" + (file.progress ? " modificador " : " modificador ") }, file.downloadUrl ?
|
|
5273
|
-
h("div", { title: file.name + "(" + file.strSize + ")", class: "file__name text text--primary text--small text--ellipsis align--middle" }, h("a", { href: file.downloadUrl, download: true }, file.name, " (", file.strSize, ")"))
|
|
5274
|
-
:
|
|
5275
|
-
h("div", { title: file.name + "(" + file.strSize + ")", class: "col--stretch align--middle file__name text text--primary text--small text--ellipsis align--middle " }, file.name, " (", file.strSize, ")")), file.progress ?
|
|
5276
|
-
h("div", { class: "col col--sd-4 col--stretch align--middle" }, h("progress", { value: file.progress, max: "100" }))
|
|
5277
|
-
: undefined, h("div", { class: "col col--stretch align--middle" }, h("button", { class: "btn-cancel ", onClick: () => this.removeFile(file.name, file.xhr) }))));
|
|
5278
|
-
}))
|
|
5279
|
-
: undefined))), h("input", { ref: (el) => this._fileInput = el, type: "file", id: "fileInput", hidden: true, onChange: (ev) => this.onFileInputChange(ev), multiple: true })));
|
|
5402
|
+
return (h("div", { ref: (el) => this._dropZone = el, class: "iu" }, this.label ? h("label", { class: "iu__label", title: this.label }, this.label) : null, h("div", { class: "iu__container", onClick: () => this.openFilesDialog() }, h("div", { class: "iu__icon-label" }, h("button", { class: "iu__file-icon" }), h("div", { class: "text text--center text--medium text--primary" }, "Arraste e solte ou clique para adicionar arquivos")), this.buildFooter()), h("input", { ref: (el) => this._fileInput = el, onChange: (ev) => this.onFileInputChange(ev), type: "file", multiple: true, hidden: true })));
|
|
5280
5403
|
}
|
|
5404
|
+
buildFooter() {
|
|
5405
|
+
if (this._filePointers.size === 0) {
|
|
5406
|
+
return null;
|
|
5407
|
+
}
|
|
5408
|
+
const items = [];
|
|
5409
|
+
this._filePointers.forEach(item => items.push(this.buildFileItem(item)));
|
|
5410
|
+
return (h("div", { class: "iu__footer" }, items));
|
|
5411
|
+
}
|
|
5412
|
+
buildFileItem(item) {
|
|
5413
|
+
const fileName = item.name;
|
|
5414
|
+
const progress = Number(item['progress']);
|
|
5415
|
+
const downloadURL = item['downloadURL'];
|
|
5416
|
+
const label = `${fileName} (${this.formatBytes(item.size)})`;
|
|
5417
|
+
return (h("div", { class: "iu__item", key: fileName, onClick: evt => evt.stopPropagation() }, h("div", { class: "iu__item-label modificador" }, h("div", { title: label, class: "col--stretch align--middle file__name text text--primary text--small text--ellipsis align--middle" }, downloadURL ? h("a", { href: downloadURL, download: true }, label) : label)), isNaN(progress)
|
|
5418
|
+
?
|
|
5419
|
+
null
|
|
5420
|
+
:
|
|
5421
|
+
h("div", { class: "col col--sd-4 col--stretch align--middle" }, h("progress", { id: this.buildProgressId(item), value: progress, max: "100" })), h("div", { class: "col col--stretch align--middle" }, h("button", { class: "btn-cancel ", onClick: () => this.removeFile(fileName) }))));
|
|
5422
|
+
}
|
|
5423
|
+
get _host() { return this; }
|
|
5424
|
+
static get watchers() { return {
|
|
5425
|
+
"value": ["updatePointers"],
|
|
5426
|
+
"requestheaders": ["normalizeRequestHeaders"]
|
|
5427
|
+
}; }
|
|
5281
5428
|
static get style() { return ezUploadCss; }
|
|
5282
5429
|
};
|
|
5283
5430
|
|
|
@@ -5305,11 +5452,6 @@ let FormMetadata$1 = class extends HTMLElement {
|
|
|
5305
5452
|
properties.push({ name: "options", value: JSON.stringify(objOpts) });
|
|
5306
5453
|
}
|
|
5307
5454
|
else if (userInterface === "FILE") {
|
|
5308
|
-
/*<URL>http://localhost:8080/2a3skw-graphql/uploadFiles</URL>
|
|
5309
|
-
<HEADERS>
|
|
5310
|
-
<HEADER NAME="Authorization">dsfs</HEADER>
|
|
5311
|
-
</HEADER>
|
|
5312
|
-
</field> */
|
|
5313
5455
|
const urlElement = element.querySelector('URL');
|
|
5314
5456
|
const headersElement = element.querySelectorAll('HEADERS>HEADER');
|
|
5315
5457
|
if (urlElement) {
|
|
@@ -5322,6 +5464,7 @@ let FormMetadata$1 = class extends HTMLElement {
|
|
|
5322
5464
|
});
|
|
5323
5465
|
properties.push({ name: "HEADERS", value: JSON.stringify(headers) });
|
|
5324
5466
|
}
|
|
5467
|
+
this.addPropertyIfExists(properties, element, "maxfiles");
|
|
5325
5468
|
}
|
|
5326
5469
|
else {
|
|
5327
5470
|
if (!label) {
|
|
@@ -5426,9 +5569,9 @@ const EzButton = /*@__PURE__*/proxyCustomElement(EzButton$1, [1,"ez-button",{"la
|
|
|
5426
5569
|
const EzCalendar = /*@__PURE__*/proxyCustomElement(EzCalendar$1, [1,"ez-calendar",{"value":[1040],"floating":[516]}]);
|
|
5427
5570
|
const EzCheck = /*@__PURE__*/proxyCustomElement(EzCheck$1, [1,"ez-check",{"label":[513],"value":[1540],"enabled":[516],"mode":[513]}]);
|
|
5428
5571
|
const EzCollapsableBox = /*@__PURE__*/proxyCustomElement(EzCollapsableBox$1, [1,"ez-collapsable-box",{"value":[1540],"label":[513]}]);
|
|
5429
|
-
const EzComboBox = /*@__PURE__*/proxyCustomElement(EzComboBox$1, [1,"ez-combo-box",{"value":[
|
|
5572
|
+
const EzComboBox = /*@__PURE__*/proxyCustomElement(EzComboBox$1, [1,"ez-combo-box",{"value":[1537],"label":[513],"enabled":[516],"options":[1040],"errormessage":[1537],"searchmode":[4],"showselectedvalue":[4],"showoptionvalue":[4],"optionloader":[16],"_preSelection":[32],"_visibleOptions":[32]}]);
|
|
5430
5573
|
const EzDateInput = /*@__PURE__*/proxyCustomElement(EzDateInput$1, [1,"ez-date-input",{"label":[513],"value":[1040],"enabled":[516],"errormessage":[1537]}]);
|
|
5431
|
-
const EzDialog = /*@__PURE__*/proxyCustomElement(EzDialog$1, [1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"oppened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"
|
|
5574
|
+
const EzDialog = /*@__PURE__*/proxyCustomElement(EzDialog$1, [1,"ez-dialog",{"confirm":[1028],"critical":[1028],"message":[1025],"oppened":[1540],"personalizedIconPath":[1025,"personalized-icon-path"],"ezTitle":[1025,"ez-title"]}]);
|
|
5432
5575
|
const EzForm = /*@__PURE__*/proxyCustomElement(EzForm$1, [0,"ez-form",{"metadataexecutor":[1],"loadexecutor":[1],"saveexecutor":[1],"removeexecutor":[1],"fieldsearchexecutor":[1],"ignoresavevalidation":[4],"metadata":[16],"slavemode":[4],"enabled":[4]}]);
|
|
5433
5576
|
const EzIcon = /*@__PURE__*/proxyCustomElement(EzIcon$1, [1,"ez-icon",{"size":[513],"href":[513]}]);
|
|
5434
5577
|
const EzLabelChip = /*@__PURE__*/proxyCustomElement(EzLabelChip$1, [1,"ez-label-chip",{"label":[513],"enabled":[516],"removable":[516],"value":[1540]}]);
|
|
@@ -5436,13 +5579,14 @@ const EzModal = /*@__PURE__*/proxyCustomElement(EzModal$1, [1,"ez-modal",{"modal
|
|
|
5436
5579
|
const EzNumberInput = /*@__PURE__*/proxyCustomElement(NumberInput, [1,"ez-number-input",{"strvalue":[1025],"value":[1026],"label":[513],"enabled":[516],"errormessage":[1537],"precision":[1538],"prettyprecision":[1538],"textleft":[516],"formatnumber":[513]}]);
|
|
5437
5580
|
const EzNumericInput = /*@__PURE__*/proxyCustomElement(EzNumericInput$1, [1,"ez-numeric-input",{"label":[513],"value":[1538],"enabled":[516],"errormessage":[1537],"precision":[8],"prettyprecision":[8]}]);
|
|
5438
5581
|
const EzPopover = /*@__PURE__*/proxyCustomElement(EzPopover$1, [1,"ez-popover",{"autoclose":[516],"top":[1537],"left":[1537],"bottom":[1537],"right":[1537],"boxwidth":[513],"isOpened":[1540,"is-opened"]}]);
|
|
5439
|
-
const EzPopup = /*@__PURE__*/proxyCustomElement(EzPopup$1, [1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"
|
|
5440
|
-
const EzSearch = /*@__PURE__*/proxyCustomElement(EzSearch$1, [1,"ez-search",{"value":[
|
|
5582
|
+
const EzPopup = /*@__PURE__*/proxyCustomElement(EzPopup$1, [1,"ez-popup",{"size":[1],"opened":[1540],"useHeader":[1540,"use-header"],"ezTitle":[1,"ez-title"]}]);
|
|
5583
|
+
const EzSearch = /*@__PURE__*/proxyCustomElement(EzSearch$1, [1,"ez-search",{"value":[1537],"label":[1537],"enabled":[1540],"errormessage":[1537],"optionloader":[16],"showselectedvalue":[4],"showoptionvalue":[4]}]);
|
|
5441
5584
|
const EzTabselector = /*@__PURE__*/proxyCustomElement(EzTabselector$1, [1,"ez-tabselector",{"selectedindex":[1537],"selectedtab":[1537],"tabs":[1]}]);
|
|
5442
5585
|
const EzTextArea = /*@__PURE__*/proxyCustomElement(EzTextArea$1, [1,"ez-text-area",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errormessage":[1537],"rows":[1538]}]);
|
|
5443
5586
|
const EzTextInput = /*@__PURE__*/proxyCustomElement(EzTextInput$1, [1,"ez-text-input",{"label":[513],"value":[1537],"enabled":[516],"loading":[516],"errormessage":[1537],"onlynumber":[516],"mask":[1],"restrict":[1]}]);
|
|
5444
5587
|
const EzTimeInput = /*@__PURE__*/proxyCustomElement(EzTimeInput$1, [1,"ez-time-input",{"label":[513],"viewValue":[1537,"view-value"],"value":[1026],"enabled":[516],"errormessage":[1537],"showSeconds":[516,"show-seconds"]}]);
|
|
5445
|
-
const
|
|
5588
|
+
const EzToast = /*@__PURE__*/proxyCustomElement(EzToast$1, [1,"ez-toast",{"message":[1025],"fadeTime":[1026,"fade-time"],"useIcon":[1028,"use-icon"]}]);
|
|
5589
|
+
const EzUpload = /*@__PURE__*/proxyCustomElement(EzUpload$1, [1,"ez-upload",{"label":[1],"enabled":[4],"maxfilesize":[2],"maxfiles":[2],"requestheaders":[8],"urlupload":[1],"urldelete":[1],"value":[1040]}]);
|
|
5446
5590
|
const FormMetadata = /*@__PURE__*/proxyCustomElement(FormMetadata$1, [1,"form-metadata",{"name":[1],"label":[1],"dataunit":[1025],"many":[4],"autoload":[4],"metadata":[1040]}]);
|
|
5447
5591
|
const PlaceHolder = /*@__PURE__*/proxyCustomElement(PlaceHolder$1, [1,"place-holder"]);
|
|
5448
5592
|
const defineCustomElements = (opts) => {
|
|
@@ -5469,6 +5613,7 @@ const defineCustomElements = (opts) => {
|
|
|
5469
5613
|
EzTextArea,
|
|
5470
5614
|
EzTextInput,
|
|
5471
5615
|
EzTimeInput,
|
|
5616
|
+
EzToast,
|
|
5472
5617
|
EzUpload,
|
|
5473
5618
|
FormMetadata,
|
|
5474
5619
|
PlaceHolder
|
|
@@ -5480,4 +5625,4 @@ const defineCustomElements = (opts) => {
|
|
|
5480
5625
|
}
|
|
5481
5626
|
};
|
|
5482
5627
|
|
|
5483
|
-
export { EzActionChip, EzButton, EzCalendar, EzCheck, EzCollapsableBox, EzComboBox, EzDateInput, EzDialog, EzForm, EzIcon, EzLabelChip, EzModal, EzNumberInput, EzNumericInput, EzPopover, EzPopup, EzSearch, EzTabselector, EzTextArea, EzTextInput, EzTimeInput, EzUpload, FormMetadata, PlaceHolder, defineCustomElements };
|
|
5628
|
+
export { EzActionChip, EzButton, EzCalendar, EzCheck, EzCollapsableBox, EzComboBox, EzDateInput, EzDialog, EzForm, EzIcon, EzLabelChip, EzModal, EzNumberInput, EzNumericInput, EzPopover, EzPopup, EzSearch, EzTabselector, EzTextArea, EzTextInput, EzTimeInput, EzToast, EzUpload, FormMetadata, PlaceHolder, defineCustomElements };
|