@sankhyalabs/ezui 1.1.141 → 1.1.142
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-date-input.cjs.entry.js +16 -5
- package/dist/cjs/ez-date-time-input.cjs.entry.js +7 -1
- package/dist/cjs/ez-form.cjs.entry.js +53 -8
- package/dist/cjs/ez-number-input.cjs.entry.js +8 -1
- package/dist/cjs/ez-text-area.cjs.entry.js +35 -22
- package/dist/cjs/ez-text-input.cjs.entry.js +11 -9
- package/dist/cjs/ez-time-input.cjs.entry.js +5 -0
- package/dist/cjs/ez-upload.cjs.entry.js +28 -9
- package/dist/collection/components/ez-date-input/ez-date-input.js +49 -5
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +40 -1
- package/dist/collection/components/ez-form/DataBinder.js +54 -8
- package/dist/collection/components/ez-form/ez-form.js +0 -1
- package/dist/collection/components/ez-number-input/ez-number-input.js +41 -1
- package/dist/collection/components/ez-text-area/ez-text-area.js +35 -22
- package/dist/collection/components/ez-text-input/ez-text-input.js +11 -9
- package/dist/collection/components/ez-time-input/ez-time-input.js +38 -0
- package/dist/collection/components/ez-upload/RemoteFile.js +6 -1
- package/dist/collection/components/ez-upload/ez-upload.js +36 -8
- package/dist/custom-elements/index.js +164 -56
- package/dist/esm/ez-date-input.entry.js +16 -5
- package/dist/esm/ez-date-time-input.entry.js +7 -1
- package/dist/esm/ez-form.entry.js +54 -9
- package/dist/esm/ez-number-input.entry.js +8 -1
- package/dist/esm/ez-text-area.entry.js +35 -22
- package/dist/esm/ez-text-input.entry.js +11 -9
- package/dist/esm/ez-time-input.entry.js +5 -0
- package/dist/esm/ez-upload.entry.js +28 -9
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-140f7085.entry.js +1 -0
- package/dist/ezui/p-24e98dc1.entry.js +1 -0
- package/dist/ezui/p-49fdfa4b.entry.js +1 -0
- package/dist/ezui/p-4fdceb7d.entry.js +1 -0
- package/dist/ezui/p-7746460e.entry.js +1 -0
- package/dist/ezui/p-87808290.entry.js +1 -0
- package/dist/ezui/p-b524dfca.entry.js +1 -0
- package/dist/ezui/p-ec21ecce.entry.js +1 -0
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +12 -1
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +11 -0
- package/dist/types/components/ez-form/DataBinder.d.ts +1 -0
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +11 -0
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -3
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +1 -1
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +10 -0
- package/dist/types/components/ez-upload/ez-upload.d.ts +5 -0
- package/dist/types/components.d.ts +36 -0
- package/package.json +1 -1
- package/dist/ezui/p-248361f5.entry.js +0 -1
- package/dist/ezui/p-347b145b.entry.js +0 -1
- package/dist/ezui/p-9b82c2fe.entry.js +0 -1
- package/dist/ezui/p-b8d64970.entry.js +0 -1
- package/dist/ezui/p-c620258b.entry.js +0 -1
- package/dist/ezui/p-cb73bee7.entry.js +0 -1
- package/dist/ezui/p-db0981c1.entry.js +0 -1
- package/dist/ezui/p-ec8419f1.entry.js +0 -1
|
@@ -12,6 +12,8 @@ let EzDateInput = class {
|
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
index.registerInstance(this, hostRef);
|
|
14
14
|
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
|
+
this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
|
|
16
|
+
this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
|
|
15
17
|
/**
|
|
16
18
|
* Deixa o campo disponível ou não para uso.
|
|
17
19
|
*/
|
|
@@ -25,11 +27,16 @@ let EzDateInput = class {
|
|
|
25
27
|
this._textInput.label = this.label;
|
|
26
28
|
}
|
|
27
29
|
observeErrorMessage() {
|
|
28
|
-
this._textInput.errorMessage = this.errorMessage;
|
|
29
|
-
}
|
|
30
|
-
observeValue() {
|
|
31
30
|
if (this._textInput) {
|
|
32
|
-
this._textInput.
|
|
31
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
observeValue(newValue, oldValue) {
|
|
35
|
+
if (newValue != oldValue) {
|
|
36
|
+
if (this._textInput) {
|
|
37
|
+
this.errorMessage = "";
|
|
38
|
+
this._textInput.value = this.getTextValue(this.value);
|
|
39
|
+
}
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
42
|
/**
|
|
@@ -79,12 +86,16 @@ let EzDateInput = class {
|
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
88
|
else {
|
|
89
|
+
this.ezCancelWaitingChange.emit();
|
|
82
90
|
this._textInput.errorMessage = "O valor digitado não é uma data válida";
|
|
83
91
|
}
|
|
84
92
|
}
|
|
85
93
|
getTextValue(d) {
|
|
86
94
|
return d ? new Intl.DateTimeFormat("pt-BR").format(d) : undefined;
|
|
87
95
|
}
|
|
96
|
+
startChange() {
|
|
97
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
98
|
+
}
|
|
88
99
|
componentDidLoad() {
|
|
89
100
|
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
90
101
|
}
|
|
@@ -92,7 +103,7 @@ let EzDateInput = class {
|
|
|
92
103
|
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
|
|
93
104
|
if (event.key === "H" || event.key === "h")
|
|
94
105
|
this.changeValue(new Date());
|
|
95
|
-
}, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
|
|
106
|
+
}, label: this.label, value: this.getTextValue(this.value), onInput: () => this.startChange(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
|
|
96
107
|
}
|
|
97
108
|
get _elem() { return index.getElement(this); }
|
|
98
109
|
static get watchers() { return {
|
|
@@ -12,6 +12,8 @@ let EzDateTimeInput = class {
|
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
index.registerInstance(this, hostRef);
|
|
14
14
|
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
|
+
this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
|
|
16
|
+
this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
|
|
15
17
|
/**
|
|
16
18
|
* Deixa o campo disponível ou não para uso.
|
|
17
19
|
*/
|
|
@@ -117,6 +119,7 @@ let EzDateTimeInput = class {
|
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
else {
|
|
122
|
+
this.ezCancelWaitingChange.emit();
|
|
120
123
|
this._textInput.errorMessage = "O valor digitado não é uma data válida";
|
|
121
124
|
}
|
|
122
125
|
}
|
|
@@ -131,11 +134,14 @@ let EzDateTimeInput = class {
|
|
|
131
134
|
};
|
|
132
135
|
return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : undefined;
|
|
133
136
|
}
|
|
137
|
+
startChange() {
|
|
138
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
139
|
+
}
|
|
134
140
|
componentDidLoad() {
|
|
135
141
|
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
136
142
|
}
|
|
137
143
|
render() {
|
|
138
|
-
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
|
|
144
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onInput: () => this.startChange(), onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
|
|
139
145
|
}
|
|
140
146
|
get _elem() { return index.getElement(this); }
|
|
141
147
|
static get watchers() { return {
|
|
@@ -654,11 +654,7 @@ class DataBinder {
|
|
|
654
654
|
this._dataUnit.unsubscribe(this.onDataUnitEvent);
|
|
655
655
|
}
|
|
656
656
|
updateValue(fieldName, field) {
|
|
657
|
-
|
|
658
|
-
const newValue = this._dataUnit.getFieldValue(fieldName);
|
|
659
|
-
if (oldValue != newValue) {
|
|
660
|
-
field["value"] = newValue;
|
|
661
|
-
}
|
|
657
|
+
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
662
658
|
}
|
|
663
659
|
updateBind(fieldName, field) {
|
|
664
660
|
const oldBind = this._fields.get(fieldName);
|
|
@@ -666,21 +662,53 @@ class DataBinder {
|
|
|
666
662
|
oldBind.destroy();
|
|
667
663
|
}
|
|
668
664
|
field["value"] = this._dataUnit.getFieldValue(fieldName);
|
|
669
|
-
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
665
|
+
this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, waitingChange) => this.changeStarted(fieldName, waitingChange), (fieldName) => this.cancelWaitingChange(fieldName), (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
|
|
670
666
|
this.bindSearchOptionsLoader(fieldName, field);
|
|
671
667
|
this.applyEzUploadContext(fieldName, field);
|
|
672
668
|
}
|
|
673
669
|
changeStarted(fieldName, waitingChange) {
|
|
670
|
+
/**
|
|
671
|
+
* se o waitingChange não é blocante, add um event listener pra
|
|
672
|
+
* fazer o accept da promise
|
|
673
|
+
*
|
|
674
|
+
* se não tiver promise no waitingChange, eu crio uma e resolvo no bind
|
|
675
|
+
*
|
|
676
|
+
*
|
|
677
|
+
*/
|
|
674
678
|
if (this._dataUnit.records.length === 0) {
|
|
675
679
|
this._dataUnit.addRecord();
|
|
676
680
|
}
|
|
681
|
+
if (!waitingChange.blocking && waitingChange.promise == undefined) {
|
|
682
|
+
const bind = this._fields.get(fieldName);
|
|
683
|
+
if (bind) {
|
|
684
|
+
waitingChange.promise = new Promise((resolve, reject) => {
|
|
685
|
+
bind.waitingChangePromiseResolve = resolve;
|
|
686
|
+
bind.waitingChangePromiseReject = reject;
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
}
|
|
677
690
|
this._dataUnit.startChange(fieldName, waitingChange);
|
|
678
691
|
}
|
|
692
|
+
cancelWaitingChange(fieldName) {
|
|
693
|
+
if (this._dataUnit.waitingForChange(fieldName)) {
|
|
694
|
+
this._dataUnit.cancelWaitingChange(fieldName);
|
|
695
|
+
const bind = this._fields.get(fieldName);
|
|
696
|
+
if (bind) {
|
|
697
|
+
bind.rejectWaitingChange(new core.WaitingChangeException("Change canceled", fieldName));
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
679
701
|
setFieldValue(fieldName, newValue) {
|
|
680
702
|
if (this._dataUnit.records.length === 0) {
|
|
681
703
|
this._dataUnit.addRecord();
|
|
682
704
|
}
|
|
683
705
|
this._dataUnit.setFieldValue(fieldName, newValue);
|
|
706
|
+
if (this._dataUnit.waitingForChange(fieldName)) {
|
|
707
|
+
const bind = this._fields.get(fieldName);
|
|
708
|
+
if (bind) {
|
|
709
|
+
bind.acceptWaitingChange();
|
|
710
|
+
}
|
|
711
|
+
}
|
|
684
712
|
}
|
|
685
713
|
bindSearchOptionsLoader(fieldName, field) {
|
|
686
714
|
if (field.nodeName === "EZ-SEARCH" && field["optionLoader"] == undefined) {
|
|
@@ -709,18 +737,36 @@ class DataBinder {
|
|
|
709
737
|
class Bind {
|
|
710
738
|
constructor() {
|
|
711
739
|
this.startChangeEventName = "ezStartChange";
|
|
740
|
+
this.cancelWaitingChangeEventName = "ezCancelWaitingChange";
|
|
712
741
|
this.changeEventName = "ezChange";
|
|
713
742
|
}
|
|
714
743
|
destroy() {
|
|
715
744
|
this.field.removeEventListener(this.startChangeEventName, this.startChangeListener);
|
|
745
|
+
this.field.removeEventListener(this.cancelWaitingChangeEventName, this.cancelWaitingChangeListener);
|
|
716
746
|
this.field.removeEventListener(this.changeEventName, this.changeListener);
|
|
717
747
|
}
|
|
718
|
-
|
|
748
|
+
acceptWaitingChange() {
|
|
749
|
+
if (this.waitingChangePromiseResolve) {
|
|
750
|
+
this.waitingChangePromiseResolve();
|
|
751
|
+
this.waitingChangePromiseReject = undefined;
|
|
752
|
+
this.waitingChangePromiseResolve = undefined;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
rejectWaitingChange(reason) {
|
|
756
|
+
if (this.waitingChangePromiseReject) {
|
|
757
|
+
this.waitingChangePromiseReject(reason);
|
|
758
|
+
this.waitingChangePromiseReject = undefined;
|
|
759
|
+
this.waitingChangePromiseResolve = undefined;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
static create(fieldName, field, startChangeCallback, cancelWaitingChangeCallback, changeCallback) {
|
|
719
763
|
const b = new Bind();
|
|
720
764
|
b.field = field;
|
|
721
765
|
b.fieldName = fieldName;
|
|
722
766
|
b.startChangeListener = (evt) => { startChangeCallback(fieldName, evt.detail); };
|
|
723
767
|
b.field.addEventListener(b.startChangeEventName, b.startChangeListener);
|
|
768
|
+
b.cancelWaitingChangeListener = () => { cancelWaitingChangeCallback(fieldName); };
|
|
769
|
+
b.field.addEventListener(b.cancelWaitingChangeEventName, b.cancelWaitingChangeListener);
|
|
724
770
|
b.changeListener = (evt) => { changeCallback(fieldName, evt.detail); };
|
|
725
771
|
b.field.addEventListener(b.changeEventName, b.changeListener);
|
|
726
772
|
return b;
|
|
@@ -825,7 +871,6 @@ let EzForm = class {
|
|
|
825
871
|
}
|
|
826
872
|
}
|
|
827
873
|
if (action.type === core.Action.RECORDS_ADDED) {
|
|
828
|
-
debugger;
|
|
829
874
|
const metadata = selectFormMetadata(this._store.getState());
|
|
830
875
|
const defaultValues = metadata.getDefaultValues();
|
|
831
876
|
if (defaultValues) {
|
|
@@ -12,6 +12,8 @@ let EzNumberInput = class {
|
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
index.registerInstance(this, hostRef);
|
|
14
14
|
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
|
+
this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
|
|
16
|
+
this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
|
|
15
17
|
/**
|
|
16
18
|
* Deixa o campo disponível ou não para uso.
|
|
17
19
|
*/
|
|
@@ -61,6 +63,7 @@ let EzNumberInput = class {
|
|
|
61
63
|
parseNumber() {
|
|
62
64
|
const parsedNumber = this._textInput.value ? core.NumberUtils.stringToNumber(this._textInput.value) : undefined;
|
|
63
65
|
if (parsedNumber !== undefined && isNaN(parsedNumber)) {
|
|
66
|
+
this.ezCancelWaitingChange.emit();
|
|
64
67
|
this.errorMessage = "O valor digitado não é um número válido";
|
|
65
68
|
}
|
|
66
69
|
else {
|
|
@@ -68,6 +71,7 @@ let EzNumberInput = class {
|
|
|
68
71
|
this.changeValue(parsedNumber);
|
|
69
72
|
}
|
|
70
73
|
catch (e) {
|
|
74
|
+
this.ezCancelWaitingChange.emit();
|
|
71
75
|
this.errorMessage = e.message;
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
@@ -79,11 +83,14 @@ let EzNumberInput = class {
|
|
|
79
83
|
}
|
|
80
84
|
return undefined;
|
|
81
85
|
}
|
|
86
|
+
startChange() {
|
|
87
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
88
|
+
}
|
|
82
89
|
componentDidLoad() {
|
|
83
90
|
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
84
91
|
}
|
|
85
92
|
render() {
|
|
86
|
-
return (index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }));
|
|
93
|
+
return (index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, onInput: () => this.startChange(), value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }));
|
|
87
94
|
}
|
|
88
95
|
get _elem() { return index.getElement(this); }
|
|
89
96
|
static get watchers() { return {
|
|
@@ -39,11 +39,17 @@ let EzTextArea = class {
|
|
|
39
39
|
(_b = this._messageBoxElem) === null || _b === void 0 ? void 0 : _b.classList.remove('hasError');
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
observeValue() {
|
|
43
|
-
this._inputElem
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
observeValue(newValue, oldValue) {
|
|
43
|
+
if (this._inputElem) {
|
|
44
|
+
if (newValue != oldValue) {
|
|
45
|
+
if (this.canChangeValue()) {
|
|
46
|
+
this._inputElem.value = this.value || "";
|
|
47
|
+
}
|
|
48
|
+
this.adjustFloatingLabel();
|
|
49
|
+
this.errorMessage = "";
|
|
50
|
+
this.ezChange.emit(this.value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
observeMode() {
|
|
49
55
|
if (this._initialRows == undefined) {
|
|
@@ -61,6 +67,27 @@ let EzTextArea = class {
|
|
|
61
67
|
this._initialRows = rows;
|
|
62
68
|
}
|
|
63
69
|
}
|
|
70
|
+
//---------------------------------------------
|
|
71
|
+
// Public methods
|
|
72
|
+
//---------------------------------------------
|
|
73
|
+
/**
|
|
74
|
+
* Faz o foco no componente de input
|
|
75
|
+
*/
|
|
76
|
+
async setFocus() {
|
|
77
|
+
this._inputElem.focus();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Remove o foco no componente de input
|
|
81
|
+
*/
|
|
82
|
+
async setBlur() {
|
|
83
|
+
this._inputElem.blur();
|
|
84
|
+
}
|
|
85
|
+
//---------------------------------------------
|
|
86
|
+
// Private methods
|
|
87
|
+
//---------------------------------------------
|
|
88
|
+
canChangeValue() {
|
|
89
|
+
return this._inputElem && (this.value || "") !== this._inputElem.value;
|
|
90
|
+
}
|
|
64
91
|
adjustFloatingLabel() {
|
|
65
92
|
if (this.label && this._labelElem) {
|
|
66
93
|
const hasValue = this.value && this.value.toString().length > 0;
|
|
@@ -81,21 +108,6 @@ let EzTextArea = class {
|
|
|
81
108
|
return this._hostElement.shadowRoot.activeElement !== null;
|
|
82
109
|
}
|
|
83
110
|
//---------------------------------------------
|
|
84
|
-
// Public methods
|
|
85
|
-
//---------------------------------------------
|
|
86
|
-
/**
|
|
87
|
-
* Faz o foco no componente de input
|
|
88
|
-
*/
|
|
89
|
-
async setFocus() {
|
|
90
|
-
this._inputElem.focus();
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Remove o foco no componente de input
|
|
94
|
-
*/
|
|
95
|
-
async setBlur() {
|
|
96
|
-
this._inputElem.blur();
|
|
97
|
-
}
|
|
98
|
-
//---------------------------------------------
|
|
99
111
|
// Event handlers
|
|
100
112
|
//---------------------------------------------
|
|
101
113
|
handleFocusout() {
|
|
@@ -105,8 +117,9 @@ let EzTextArea = class {
|
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
handleChange() {
|
|
108
|
-
this.
|
|
109
|
-
|
|
120
|
+
if (this.canChangeValue()) {
|
|
121
|
+
this.value = this._inputElem.value;
|
|
122
|
+
}
|
|
110
123
|
}
|
|
111
124
|
handleFocus() {
|
|
112
125
|
if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
|
|
@@ -52,17 +52,19 @@ let EzTextInput = class {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
observeValue() {
|
|
55
|
+
observeValue(newValue, oldValue) {
|
|
56
56
|
if (this._inputElem) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
if (newValue != oldValue) {
|
|
58
|
+
this._inputElem.value = this.value || "";
|
|
59
|
+
this.handleChange();
|
|
60
|
+
this.adjustFloatingLabel();
|
|
61
|
+
if (this.slaveMode) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.errorMessage = "";
|
|
65
|
+
this.ezChange.emit(this.value);
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
|
-
this.errorMessage = "";
|
|
65
|
-
this.ezChange.emit(this.value);
|
|
66
68
|
}
|
|
67
69
|
adjustFloatingLabel() {
|
|
68
70
|
if (this.label && this._labelElem) {
|
|
@@ -12,6 +12,8 @@ let EzTimeInput = class {
|
|
|
12
12
|
constructor(hostRef) {
|
|
13
13
|
index.registerInstance(this, hostRef);
|
|
14
14
|
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
|
+
this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
|
|
16
|
+
this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
|
|
15
17
|
/**
|
|
16
18
|
* Deixa o campo disponível ou não para digitação.
|
|
17
19
|
*/
|
|
@@ -72,10 +74,12 @@ let EzTimeInput = class {
|
|
|
72
74
|
this.prepareValue(this.viewValue);
|
|
73
75
|
if (this.viewValue && !core.TimeFormatter.validateTime(this.viewValue, this.showSeconds)) {
|
|
74
76
|
this._oldViewValue = this.viewValue;
|
|
77
|
+
this.ezCancelWaitingChange.emit();
|
|
75
78
|
this.errorMessage = "Favor inserir um horário válido.";
|
|
76
79
|
}
|
|
77
80
|
else {
|
|
78
81
|
if (this.viewValue === this._oldViewValue) {
|
|
82
|
+
this.ezCancelWaitingChange.emit();
|
|
79
83
|
return;
|
|
80
84
|
}
|
|
81
85
|
this._oldViewValue = this.viewValue;
|
|
@@ -94,6 +98,7 @@ let EzTimeInput = class {
|
|
|
94
98
|
}
|
|
95
99
|
}
|
|
96
100
|
handleChange() {
|
|
101
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
97
102
|
this.viewValue = this._inputElem.value;
|
|
98
103
|
this.value = core.NumberUtils.stringToNumber(this.viewValue.replace(/\D/g, ""));
|
|
99
104
|
}
|
|
@@ -50,7 +50,12 @@ class RemoteFile {
|
|
|
50
50
|
}
|
|
51
51
|
const response = xhr.response;
|
|
52
52
|
if (response) {
|
|
53
|
-
|
|
53
|
+
try {
|
|
54
|
+
resolve(JSON.parse(response));
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
reject(`Servidor não retornou um objeto válido: ${response}.\n${error}`);
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
}
|
|
56
61
|
};
|
|
@@ -102,6 +107,7 @@ let EzUpload = class {
|
|
|
102
107
|
index.registerInstance(this, hostRef);
|
|
103
108
|
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
104
109
|
this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
|
|
110
|
+
this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
|
|
105
111
|
this._filePointers = new Map();
|
|
106
112
|
/**
|
|
107
113
|
* Deixa o campo disponível ou não para digitação.
|
|
@@ -190,14 +196,27 @@ let EzUpload = class {
|
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
198
|
async doAddFile(file) {
|
|
193
|
-
|
|
194
|
-
this.
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
try {
|
|
200
|
+
if (this.validateFile(file)) {
|
|
201
|
+
this.ezStartChange.emit({ waitmessage: "Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio.", blocking: true });
|
|
202
|
+
const uploadingFile = new RemoteFile(file);
|
|
203
|
+
const oldPointer = this._filePointers.get(file.name);
|
|
204
|
+
if (oldPointer && this.isRemoteFile(oldPointer)) {
|
|
205
|
+
oldPointer.abortUpload();
|
|
206
|
+
}
|
|
207
|
+
this._filePointers.set(file.name, uploadingFile);
|
|
208
|
+
uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
|
|
209
|
+
.then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
|
|
210
|
+
.catch(msg => {
|
|
211
|
+
this.ezCancelWaitingChange.emit();
|
|
212
|
+
this.showError(msg);
|
|
213
|
+
});
|
|
214
|
+
index.forceUpdate(this);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
this.ezCancelWaitingChange.emit();
|
|
219
|
+
throw error;
|
|
201
220
|
}
|
|
202
221
|
}
|
|
203
222
|
finishUpload(ezFile) {
|
|
@@ -16,11 +16,16 @@ export class EzDateInput {
|
|
|
16
16
|
this._textInput.label = this.label;
|
|
17
17
|
}
|
|
18
18
|
observeErrorMessage() {
|
|
19
|
-
this._textInput.errorMessage = this.errorMessage;
|
|
20
|
-
}
|
|
21
|
-
observeValue() {
|
|
22
19
|
if (this._textInput) {
|
|
23
|
-
this._textInput.
|
|
20
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
observeValue(newValue, oldValue) {
|
|
24
|
+
if (newValue != oldValue) {
|
|
25
|
+
if (this._textInput) {
|
|
26
|
+
this.errorMessage = "";
|
|
27
|
+
this._textInput.value = this.getTextValue(this.value);
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
}
|
|
26
31
|
/**
|
|
@@ -70,19 +75,23 @@ export class EzDateInput {
|
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
else {
|
|
78
|
+
this.ezCancelWaitingChange.emit();
|
|
73
79
|
this._textInput.errorMessage = "O valor digitado não é uma data válida";
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
getTextValue(d) {
|
|
77
83
|
return d ? new Intl.DateTimeFormat("pt-BR").format(d) : undefined;
|
|
78
84
|
}
|
|
85
|
+
startChange() {
|
|
86
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
87
|
+
}
|
|
79
88
|
componentDidLoad() {
|
|
80
89
|
CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
81
90
|
}
|
|
82
91
|
render() {
|
|
83
92
|
return (h(Host, null,
|
|
84
93
|
h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { if (event.key === "H" || event.key === "h")
|
|
85
|
-
this.changeValue(new Date()); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true },
|
|
94
|
+
this.changeValue(new Date()); }, label: this.label, value: this.getTextValue(this.value), onInput: () => this.startChange(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true },
|
|
86
95
|
h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })),
|
|
87
96
|
h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
|
|
88
97
|
}
|
|
@@ -204,6 +213,41 @@ export class EzDateInput {
|
|
|
204
213
|
}
|
|
205
214
|
}
|
|
206
215
|
}
|
|
216
|
+
}, {
|
|
217
|
+
"method": "ezStartChange",
|
|
218
|
+
"name": "ezStartChange",
|
|
219
|
+
"bubbles": true,
|
|
220
|
+
"cancelable": true,
|
|
221
|
+
"composed": true,
|
|
222
|
+
"docs": {
|
|
223
|
+
"tags": [],
|
|
224
|
+
"text": "Evento emitido ao iniciar a altera\u00E7\u00E3o (remover ou adicionar um arquivo)."
|
|
225
|
+
},
|
|
226
|
+
"complexType": {
|
|
227
|
+
"original": "WaitingChange",
|
|
228
|
+
"resolved": "WaitingChange",
|
|
229
|
+
"references": {
|
|
230
|
+
"WaitingChange": {
|
|
231
|
+
"location": "import",
|
|
232
|
+
"path": "@sankhyalabs/core"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}, {
|
|
237
|
+
"method": "ezCancelWaitingChange",
|
|
238
|
+
"name": "ezCancelWaitingChange",
|
|
239
|
+
"bubbles": true,
|
|
240
|
+
"cancelable": true,
|
|
241
|
+
"composed": true,
|
|
242
|
+
"docs": {
|
|
243
|
+
"tags": [],
|
|
244
|
+
"text": "Entre o evento ezStartChange e ezChange, se por algum motivo n\u00E3o foi poss\u00EDvel\ncompletar a altera\u00E7\u00E3o, esse evento \u00E9 disparado."
|
|
245
|
+
},
|
|
246
|
+
"complexType": {
|
|
247
|
+
"original": "void",
|
|
248
|
+
"resolved": "void",
|
|
249
|
+
"references": {}
|
|
250
|
+
}
|
|
207
251
|
}]; }
|
|
208
252
|
static get methods() { return {
|
|
209
253
|
"setFocus": {
|
|
@@ -108,6 +108,7 @@ export class EzDateTimeInput {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
|
+
this.ezCancelWaitingChange.emit();
|
|
111
112
|
this._textInput.errorMessage = "O valor digitado não é uma data válida";
|
|
112
113
|
}
|
|
113
114
|
}
|
|
@@ -122,12 +123,15 @@ export class EzDateTimeInput {
|
|
|
122
123
|
};
|
|
123
124
|
return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : undefined;
|
|
124
125
|
}
|
|
126
|
+
startChange() {
|
|
127
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
128
|
+
}
|
|
125
129
|
componentDidLoad() {
|
|
126
130
|
CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
127
131
|
}
|
|
128
132
|
render() {
|
|
129
133
|
return (h(Host, null,
|
|
130
|
-
h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true },
|
|
134
|
+
h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onInput: () => this.startChange(), onFocus: () => this.onFocused(), onClick: () => this.onClicked(), slaveMode: true },
|
|
131
135
|
h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })),
|
|
132
136
|
h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
|
|
133
137
|
}
|
|
@@ -267,6 +271,41 @@ export class EzDateTimeInput {
|
|
|
267
271
|
}
|
|
268
272
|
}
|
|
269
273
|
}
|
|
274
|
+
}, {
|
|
275
|
+
"method": "ezStartChange",
|
|
276
|
+
"name": "ezStartChange",
|
|
277
|
+
"bubbles": true,
|
|
278
|
+
"cancelable": true,
|
|
279
|
+
"composed": true,
|
|
280
|
+
"docs": {
|
|
281
|
+
"tags": [],
|
|
282
|
+
"text": "Evento emitido ao iniciar a altera\u00E7\u00E3o (remover ou adicionar um arquivo)."
|
|
283
|
+
},
|
|
284
|
+
"complexType": {
|
|
285
|
+
"original": "WaitingChange",
|
|
286
|
+
"resolved": "WaitingChange",
|
|
287
|
+
"references": {
|
|
288
|
+
"WaitingChange": {
|
|
289
|
+
"location": "import",
|
|
290
|
+
"path": "@sankhyalabs/core"
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}, {
|
|
295
|
+
"method": "ezCancelWaitingChange",
|
|
296
|
+
"name": "ezCancelWaitingChange",
|
|
297
|
+
"bubbles": true,
|
|
298
|
+
"cancelable": true,
|
|
299
|
+
"composed": true,
|
|
300
|
+
"docs": {
|
|
301
|
+
"tags": [],
|
|
302
|
+
"text": "Entre o evento ezStartChange e ezChange, se por algum motivo n\u00E3o foi poss\u00EDvel\ncompletar a altera\u00E7\u00E3o, esse evento \u00E9 disparado."
|
|
303
|
+
},
|
|
304
|
+
"complexType": {
|
|
305
|
+
"original": "void",
|
|
306
|
+
"resolved": "void",
|
|
307
|
+
"references": {}
|
|
308
|
+
}
|
|
270
309
|
}]; }
|
|
271
310
|
static get methods() { return {
|
|
272
311
|
"setFocus": {
|