@sankhyalabs/ezui 1.1.159 → 1.1.160
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-combo-box.cjs.entry.js +62 -27
- package/dist/cjs/ez-date-input.cjs.entry.js +71 -25
- package/dist/cjs/ez-date-time-input.cjs.entry.js +94 -31
- package/dist/cjs/ez-filter-input.cjs.entry.js +10 -4
- package/dist/cjs/ez-form.cjs.entry.js +54 -9
- package/dist/cjs/ez-grid.cjs.entry.js +9 -6
- package/dist/cjs/ez-number-input.cjs.entry.js +69 -25
- package/dist/cjs/ez-search.cjs.entry.js +20 -5
- package/dist/cjs/ez-text-area.cjs.entry.js +8 -2
- package/dist/cjs/ez-text-input.cjs.entry.js +30 -21
- package/dist/cjs/ez-time-input.cjs.entry.js +75 -40
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +81 -28
- package/dist/collection/components/ez-date-input/ez-date-input.js +87 -25
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +108 -31
- package/dist/collection/components/ez-filter-input/ez-filter-input.js +26 -4
- package/dist/collection/components/ez-form/DataBinder.js +12 -3
- package/dist/collection/components/ez-form/ez-form.js +43 -6
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +1 -1
- package/dist/collection/components/ez-grid/ez-grid.js +14 -7
- package/dist/collection/components/ez-number-input/ez-number-input.js +83 -25
- package/dist/collection/components/ez-search/ez-search.js +38 -5
- package/dist/collection/components/ez-text-area/ez-text-area.css +1 -1
- package/dist/collection/components/ez-text-area/ez-text-area.js +23 -1
- package/dist/collection/components/ez-text-input/ez-text-input.css +1 -1
- package/dist/collection/components/ez-text-input/ez-text-input.js +45 -38
- package/dist/collection/components/ez-time-input/ez-time-input.js +95 -59
- package/dist/custom-elements/index.js +504 -197
- package/dist/esm/ez-combo-box.entry.js +62 -27
- package/dist/esm/ez-date-input.entry.js +71 -25
- package/dist/esm/ez-date-time-input.entry.js +94 -31
- package/dist/esm/ez-filter-input.entry.js +10 -4
- package/dist/esm/ez-form.entry.js +54 -9
- package/dist/esm/ez-grid.entry.js +9 -6
- package/dist/esm/ez-number-input.entry.js +69 -25
- package/dist/esm/ez-search.entry.js +20 -5
- package/dist/esm/ez-text-area.entry.js +8 -2
- package/dist/esm/ez-text-input.entry.js +30 -21
- package/dist/esm/ez-time-input.entry.js +76 -41
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-003d53b1.entry.js +1 -0
- package/dist/ezui/p-267fa515.entry.js +1 -0
- package/dist/ezui/p-2acf7d59.entry.js +1 -0
- package/dist/ezui/p-403de0a4.entry.js +1 -0
- package/dist/ezui/p-4c3d136c.entry.js +1 -0
- package/dist/ezui/p-53bbba8e.entry.js +1 -0
- package/dist/ezui/p-6668c3b0.entry.js +1 -0
- package/dist/ezui/p-7fd6deec.entry.js +1 -0
- package/dist/ezui/p-ad6cc559.entry.js +1 -0
- package/dist/ezui/{p-be87ac5e.entry.js → p-ae2fea4c.entry.js} +1 -1
- package/dist/ezui/p-ff7b4b13.entry.js +1 -0
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +13 -7
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +10 -3
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +15 -7
- package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +5 -1
- package/dist/types/components/ez-form/DataBinder.d.ts +1 -1
- package/dist/types/components/ez-form/ez-form.d.ts +1 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +4 -1
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +14 -5
- package/dist/types/components/ez-search/ez-search.d.ts +6 -1
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +7 -6
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +17 -13
- package/dist/types/components.d.ts +43 -20
- package/package.json +1 -1
- package/dist/ezui/p-1859a3d8.entry.js +0 -1
- package/dist/ezui/p-49fdfa4b.entry.js +0 -1
- package/dist/ezui/p-4fdceb7d.entry.js +0 -1
- package/dist/ezui/p-6d4b1628.entry.js +0 -1
- package/dist/ezui/p-8f4fac31.entry.js +0 -1
- package/dist/ezui/p-91377c65.entry.js +0 -1
- package/dist/ezui/p-b524dfca.entry.js +0 -1
- package/dist/ezui/p-bc8aa27f.entry.js +0 -1
- package/dist/ezui/p-ec21ecce.entry.js +0 -1
- package/dist/ezui/p-fc9b9487.entry.js +0 -1
|
@@ -50,40 +50,66 @@ let EzComboBox = class {
|
|
|
50
50
|
*/
|
|
51
51
|
this.mode = "regular";
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
observeErrorMessage() {
|
|
54
|
+
var _a;
|
|
55
|
+
if (this._textInput) {
|
|
56
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
57
|
+
if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
58
|
+
this.setInputValue();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
observeValue(newValue, oldValue) {
|
|
63
|
+
var _a, _b, _c, _d;
|
|
64
|
+
if (this._textInput && newValue != oldValue) {
|
|
65
|
+
const newValueSelected = this.getSelectedOption(newValue);
|
|
66
|
+
const oldValueSelected = this.getSelectedOption(oldValue);
|
|
67
|
+
const currentValue = this.getSelectedOption(this.value);
|
|
68
|
+
if (((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) != ((_b = newValueSelected === null || newValueSelected === void 0 ? void 0 : newValueSelected.value) === null || _b === void 0 ? void 0 : _b.toString())) {
|
|
69
|
+
this.value = newValueSelected;
|
|
70
|
+
}
|
|
71
|
+
if (((_c = newValueSelected === null || newValueSelected === void 0 ? void 0 : newValueSelected.value) === null || _c === void 0 ? void 0 : _c.toString()) !== ((_d = oldValueSelected === null || oldValueSelected === void 0 ? void 0 : oldValueSelected.value) === null || _d === void 0 ? void 0 : _d.toString())) {
|
|
72
|
+
this.setInputValue();
|
|
73
|
+
const valueEmitted = newValueSelected === null ? undefined : newValueSelected;
|
|
74
|
+
this.ezChange.emit(valueEmitted);
|
|
75
|
+
}
|
|
76
|
+
this.hideOptions();
|
|
77
|
+
this._criteria = undefined;
|
|
78
|
+
this._preSelection = undefined;
|
|
79
|
+
this.updateVisibleOptions();
|
|
56
80
|
}
|
|
57
|
-
this.hideOptions();
|
|
58
|
-
this._criteria = undefined;
|
|
59
|
-
this._preSelection = undefined;
|
|
60
|
-
this.updateVisibleOptions();
|
|
61
81
|
}
|
|
62
82
|
/**
|
|
63
83
|
* Realiza o foco no componente de seleção
|
|
64
84
|
*/
|
|
65
85
|
async setFocus() {
|
|
66
|
-
this.
|
|
86
|
+
this._textInput.setFocus();
|
|
67
87
|
}
|
|
68
88
|
/**
|
|
69
89
|
* Remove o foco no componente de seleção
|
|
70
90
|
*/
|
|
71
91
|
async setBlur() {
|
|
72
|
-
this.
|
|
92
|
+
this._textInput.setBlur();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
96
|
+
*/
|
|
97
|
+
async isInvalid() {
|
|
98
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
73
99
|
}
|
|
74
100
|
getText() {
|
|
75
101
|
let text = "";
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
78
|
-
text = this.showSelectedValue ? `${
|
|
102
|
+
const currentValue = this.getSelectedOption(this.value);
|
|
103
|
+
if (currentValue) {
|
|
104
|
+
text = this.showSelectedValue ? `${currentValue.value} - ${currentValue.label}` : currentValue.label;
|
|
79
105
|
}
|
|
80
106
|
return text;
|
|
81
107
|
}
|
|
82
|
-
getSelectedOption() {
|
|
83
|
-
if (typeof
|
|
84
|
-
return this._visibleOptions.find(o => o.value ===
|
|
108
|
+
getSelectedOption(value) {
|
|
109
|
+
if (typeof value === "string" || value instanceof String) {
|
|
110
|
+
return this._visibleOptions.find(o => o.value === value);
|
|
85
111
|
}
|
|
86
|
-
return
|
|
112
|
+
return value;
|
|
87
113
|
}
|
|
88
114
|
updateVisibleOptions() {
|
|
89
115
|
let opts = this._source || [];
|
|
@@ -138,7 +164,7 @@ let EzComboBox = class {
|
|
|
138
164
|
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
139
165
|
//posição errada no futuro. Preferi fazer simples no começo,
|
|
140
166
|
//porque não quis onerar o text input com essa funcionalidade...
|
|
141
|
-
const top = (this.errorMessage || !this.canShowError || this.mode
|
|
167
|
+
const top = (this.errorMessage || !this.canShowError || this.mode === "slim") ? "0px" : "-19px";
|
|
142
168
|
this._floatingID = core.FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, top });
|
|
143
169
|
window.requestAnimationFrame(() => {
|
|
144
170
|
this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
@@ -221,15 +247,13 @@ let EzComboBox = class {
|
|
|
221
247
|
}
|
|
222
248
|
selectOption(newOption) {
|
|
223
249
|
var _a, _b;
|
|
224
|
-
const
|
|
225
|
-
if (((_a =
|
|
250
|
+
const currentValue = this.getSelectedOption(this.value);
|
|
251
|
+
if (((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = newOption === null || newOption === void 0 ? void 0 : newOption.value) === null || _b === void 0 ? void 0 : _b.toString())) {
|
|
226
252
|
const adjustedOpt = !(newOption === null || newOption === void 0 ? void 0 : newOption.value) ? undefined : newOption;
|
|
227
253
|
this.value = adjustedOpt;
|
|
228
|
-
this.errorMessage = "";
|
|
229
|
-
this.ezChange.emit(this.value);
|
|
230
254
|
}
|
|
231
255
|
else {
|
|
232
|
-
this.
|
|
256
|
+
this.setInputValue();
|
|
233
257
|
}
|
|
234
258
|
if (this.searchMode) {
|
|
235
259
|
this._visibleOptions = [];
|
|
@@ -246,11 +270,20 @@ let EzComboBox = class {
|
|
|
246
270
|
}
|
|
247
271
|
}
|
|
248
272
|
cancelPreselection() {
|
|
249
|
-
if (!this.
|
|
273
|
+
if (!this._textInput.value && this.value) {
|
|
250
274
|
this.selectOption(undefined);
|
|
251
275
|
}
|
|
252
276
|
else {
|
|
253
|
-
this.
|
|
277
|
+
this.setInputValue();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
setInputValue(clearError = true) {
|
|
281
|
+
const textValue = this.getText();
|
|
282
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
283
|
+
this._textInput.value = textValue;
|
|
284
|
+
if (clearError) {
|
|
285
|
+
this.errorMessage = "";
|
|
286
|
+
}
|
|
254
287
|
}
|
|
255
288
|
}
|
|
256
289
|
clearSearch() {
|
|
@@ -308,7 +341,8 @@ let EzComboBox = class {
|
|
|
308
341
|
}
|
|
309
342
|
}
|
|
310
343
|
componentDidLoad() {
|
|
311
|
-
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this.el, this.
|
|
344
|
+
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
|
|
345
|
+
this.setInputValue(false);
|
|
312
346
|
}
|
|
313
347
|
//---------------------------------------------
|
|
314
348
|
// Event handlers
|
|
@@ -328,7 +362,7 @@ let EzComboBox = class {
|
|
|
328
362
|
const argument = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
|
|
329
363
|
const argumentNumber = Number(argument || undefined);
|
|
330
364
|
if (!this._criteria) {
|
|
331
|
-
this.
|
|
365
|
+
this._textInput.value = event.data || argument;
|
|
332
366
|
}
|
|
333
367
|
this._criteria = argument;
|
|
334
368
|
if (argument && (!isNaN(argumentNumber) || argument.length >= this._limitCharsToSearch)) {
|
|
@@ -386,7 +420,7 @@ let EzComboBox = class {
|
|
|
386
420
|
}
|
|
387
421
|
render() {
|
|
388
422
|
var _a;
|
|
389
|
-
return (index.h(index.Host, null, index.h("ez-text-input", { class: this.suppressSearch ? "suppressed-search-input" : "", ref: elem => this.
|
|
423
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { class: this.suppressSearch ? "suppressed-search-input" : "", ref: elem => this._textInput = elem, "data-slave-mode": "true", enabled: this.enabled && !this.suppressSearch, onInput: event => this.onTextInputChangeHandler(event), onClick: () => this.onTextInputClickHandler(), onFocusout: () => this.onTextInputFocusOutHandler(), onKeyDown: event => this.keyDownHandler(event), label: this.label, canShowError: this.canShowError, errorMessage: this.errorMessage, mode: this.mode }, index.h("button", { class: "btn", slot: this.searchMode ? "leftIcon" : "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.handlerIconClick() }, index.h("ez-icon", { iconName: this.searchMode ? "search" : "chevron-down" })), this.searchMode && ((_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) && (this._criteria || this.value)
|
|
390
424
|
? index.h("button", { class: "btn", slot: "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.clearSearch() }, index.h("ez-icon", { iconName: "close" }))
|
|
391
425
|
: undefined), index.h("section", { class: "list-container", ref: elem => this._listContainer = elem }, index.h("div", { class: "list-wrapper", ref: elem => this._listWrapper = elem }, index.h("div", { class: "list-options", ref: elem => this._optionsList = elem }, this._visibleOptions.length === 0
|
|
392
426
|
&& index.h("div", { class: "message" }, !this._showLoading && index.h("span", { class: "message__no-result" }, this._textEmptyList), this._showLoading && index.h("div", { class: "message__loading" })), this.showOptionValue
|
|
@@ -395,6 +429,7 @@ let EzComboBox = class {
|
|
|
395
429
|
}
|
|
396
430
|
get el() { return index.getElement(this); }
|
|
397
431
|
static get watchers() { return {
|
|
432
|
+
"errorMessage": ["observeErrorMessage"],
|
|
398
433
|
"value": ["observeValue"]
|
|
399
434
|
}; }
|
|
400
435
|
};
|
|
@@ -14,6 +14,7 @@ let EzDateInput = class {
|
|
|
14
14
|
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
15
|
this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
|
|
16
16
|
this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
|
|
17
|
+
this._focused = false;
|
|
17
18
|
/**
|
|
18
19
|
* Deixa o campo disponível ou não para uso.
|
|
19
20
|
*/
|
|
@@ -24,18 +25,33 @@ let EzDateInput = class {
|
|
|
24
25
|
this.mode = "regular";
|
|
25
26
|
}
|
|
26
27
|
observeLabel() {
|
|
27
|
-
this._textInput
|
|
28
|
+
if (this._textInput) {
|
|
29
|
+
this._textInput.label = this.label;
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
observeErrorMessage() {
|
|
33
|
+
var _a;
|
|
30
34
|
if (this._textInput) {
|
|
31
35
|
this._textInput.errorMessage = this.errorMessage;
|
|
36
|
+
if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
37
|
+
this.setInputValue();
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
observeValue(newValue, oldValue) {
|
|
35
|
-
if (newValue != oldValue) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
if (this._textInput && newValue != oldValue) {
|
|
43
|
+
const newValueValidated = this.validateValue(newValue);
|
|
44
|
+
const oldValueValidated = this.validateValue(oldValue);
|
|
45
|
+
if ((newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime()) !== (oldValueValidated === null || oldValueValidated === void 0 ? void 0 : oldValueValidated.getTime())) {
|
|
46
|
+
const textValue = this.getTextValue(newValueValidated) || '';
|
|
47
|
+
const parsedDate = core.DateUtils.strToDate(textValue);
|
|
48
|
+
if ((parsedDate || !this._focused) && (this._textInput.value || '') !== textValue) {
|
|
49
|
+
this._textInput.value = textValue;
|
|
50
|
+
this._focused = false;
|
|
51
|
+
this.errorMessage = "";
|
|
52
|
+
}
|
|
53
|
+
const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
|
|
54
|
+
this.ezChange.emit(valueEmitted);
|
|
39
55
|
}
|
|
40
56
|
}
|
|
41
57
|
}
|
|
@@ -51,59 +67,89 @@ let EzDateInput = class {
|
|
|
51
67
|
async setBlur() {
|
|
52
68
|
this._textInput.setBlur();
|
|
53
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
72
|
+
*/
|
|
73
|
+
async isInvalid() {
|
|
74
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
75
|
+
}
|
|
54
76
|
changeValue(newValue) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if ((newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString())) {
|
|
60
|
-
this.value = newValue;
|
|
61
|
-
this.ezChange.emit(this.value);
|
|
77
|
+
const currentValue = this.validateValue(this.value);
|
|
78
|
+
const newValueValidated = this.validateValue(newValue);
|
|
79
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
80
|
+
this.value = newValueValidated;
|
|
62
81
|
}
|
|
63
82
|
}
|
|
64
83
|
showCalendar() {
|
|
65
|
-
this.
|
|
84
|
+
this.handleBlur();
|
|
66
85
|
this._calendar.value = this.value;
|
|
67
86
|
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
68
87
|
//posição errada no futuro. Preferi fazer simples no começo,
|
|
69
88
|
//porque não quis onerar o text input com essa funcionalidade...
|
|
70
|
-
const top = this.
|
|
89
|
+
const top = this.errorMessage || this.mode === "slim" ? 0 : -19;
|
|
71
90
|
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
72
91
|
}
|
|
73
92
|
hideCalendar() {
|
|
74
93
|
this.changeValue(this._calendar.value);
|
|
75
94
|
this._calendar.hide();
|
|
76
95
|
}
|
|
77
|
-
|
|
96
|
+
handleBlur() {
|
|
78
97
|
const strValue = this._textInput.value;
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
98
|
+
const newValue = core.DateUtils.strToDate(strValue);
|
|
99
|
+
if (newValue || !strValue) {
|
|
100
|
+
this.errorMessage = "";
|
|
101
|
+
const currentValue = this.validateValue(this.value);
|
|
102
|
+
const newValueValidated = this.validateValue(newValue);
|
|
103
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
104
|
+
if (newValueValidated) {
|
|
105
|
+
this._textInput.value = this.getTextValue(newValueValidated) || '';
|
|
106
|
+
this._focused = false;
|
|
107
|
+
}
|
|
108
|
+
this.ezCancelWaitingChange.emit();
|
|
83
109
|
}
|
|
84
110
|
else {
|
|
85
|
-
this.changeValue(
|
|
111
|
+
this.changeValue(newValueValidated);
|
|
86
112
|
}
|
|
87
113
|
}
|
|
88
114
|
else {
|
|
115
|
+
this.changeValue(undefined);
|
|
89
116
|
this.ezCancelWaitingChange.emit();
|
|
90
|
-
this.
|
|
117
|
+
this.errorMessage = "O valor digitado não é uma data válida";
|
|
91
118
|
}
|
|
92
119
|
}
|
|
93
120
|
getTextValue(d) {
|
|
94
121
|
return d ? new Intl.DateTimeFormat("pt-BR").format(d) : undefined;
|
|
95
122
|
}
|
|
96
|
-
|
|
97
|
-
this.
|
|
123
|
+
handleInput() {
|
|
124
|
+
const strValue = this._textInput.value;
|
|
125
|
+
const newValue = core.DateUtils.strToDate(strValue);
|
|
126
|
+
const currentValue = this.validateValue(this.value);
|
|
127
|
+
const newValueValidated = this.validateValue(newValue);
|
|
128
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
129
|
+
this._focused = true;
|
|
130
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
validateValue(value) {
|
|
134
|
+
return value instanceof Date && !isNaN(value.valueOf())
|
|
135
|
+
? core.DateUtils.clearTime(value)
|
|
136
|
+
: undefined;
|
|
137
|
+
}
|
|
138
|
+
setInputValue() {
|
|
139
|
+
const textValue = this.getTextValue(this.value) || '';
|
|
140
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
141
|
+
this._textInput.value = textValue;
|
|
142
|
+
}
|
|
98
143
|
}
|
|
99
144
|
componentDidLoad() {
|
|
100
145
|
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
146
|
+
this.setInputValue();
|
|
101
147
|
}
|
|
102
148
|
render() {
|
|
103
|
-
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem,
|
|
149
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, "data-slave-mode": "true", onKeyDown: event => {
|
|
104
150
|
if (event.key === "H" || event.key === "h")
|
|
105
151
|
this.changeValue(new Date());
|
|
106
|
-
}, label: this.label,
|
|
152
|
+
}, label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode }, 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 })));
|
|
107
153
|
}
|
|
108
154
|
get _elem() { return index.getElement(this); }
|
|
109
155
|
static get watchers() { return {
|
|
@@ -14,6 +14,7 @@ let EzDateTimeInput = class {
|
|
|
14
14
|
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
15
|
this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
|
|
16
16
|
this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
|
|
17
|
+
this._focused = false;
|
|
17
18
|
/**
|
|
18
19
|
* Deixa o campo disponível ou não para uso.
|
|
19
20
|
*/
|
|
@@ -28,14 +29,34 @@ let EzDateTimeInput = class {
|
|
|
28
29
|
this.mode = "regular";
|
|
29
30
|
}
|
|
30
31
|
observeLabel() {
|
|
31
|
-
this._textInput
|
|
32
|
+
if (this._textInput) {
|
|
33
|
+
this._textInput.label = this.label;
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
observeErrorMessage() {
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
observeValue() {
|
|
37
|
+
var _a;
|
|
37
38
|
if (this._textInput) {
|
|
38
|
-
this._textInput.
|
|
39
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
40
|
+
if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
41
|
+
this.setInputValue();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
observeValue(newValue, oldValue) {
|
|
46
|
+
if (this._textInput && newValue != oldValue) {
|
|
47
|
+
const newValueValidated = this.validateValue(newValue);
|
|
48
|
+
const oldValueValidated = this.validateValue(oldValue);
|
|
49
|
+
if ((newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime()) !== (oldValueValidated === null || oldValueValidated === void 0 ? void 0 : oldValueValidated.getTime())) {
|
|
50
|
+
const textValue = this.getTextValue(newValueValidated) || '';
|
|
51
|
+
const parsedDate = this.getParsedDateTime(textValue);
|
|
52
|
+
if ((parsedDate || !this._focused) && (this._textInput.value || '') !== textValue) {
|
|
53
|
+
this._textInput.value = textValue;
|
|
54
|
+
this._focused = false;
|
|
55
|
+
this.errorMessage = "";
|
|
56
|
+
}
|
|
57
|
+
const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
|
|
58
|
+
this.ezChange.emit(valueEmitted);
|
|
59
|
+
}
|
|
39
60
|
}
|
|
40
61
|
}
|
|
41
62
|
/**
|
|
@@ -50,30 +71,36 @@ let EzDateTimeInput = class {
|
|
|
50
71
|
async setBlur() {
|
|
51
72
|
this._textInput.setBlur();
|
|
52
73
|
}
|
|
53
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
76
|
+
*/
|
|
77
|
+
async isInvalid() {
|
|
78
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
79
|
+
}
|
|
80
|
+
handleKeyDown(event) {
|
|
54
81
|
const input = this._textInput.shadowRoot.querySelector('input');
|
|
55
|
-
if (
|
|
82
|
+
if (event.key === "H" || event.key === "h") {
|
|
56
83
|
this.changeValue(new Date());
|
|
57
84
|
}
|
|
58
|
-
else if (
|
|
85
|
+
else if (event.shiftKey && event.key === "Tab") {
|
|
59
86
|
if (input.selectionStart > 0) {
|
|
60
87
|
let selectIni = input.value.lastIndexOf(" ", input.selectionStart);
|
|
61
88
|
if (selectIni !== -1) {
|
|
62
89
|
input.setSelectionRange(0, selectIni);
|
|
63
|
-
|
|
90
|
+
event.preventDefault();
|
|
64
91
|
}
|
|
65
92
|
}
|
|
66
93
|
}
|
|
67
|
-
else if (
|
|
94
|
+
else if (event.key === "Tab") {
|
|
68
95
|
if (input.value.length !== input.selectionEnd) {
|
|
69
96
|
let selectIni = input.value.indexOf(" ", input.selectionEnd);
|
|
70
97
|
selectIni = selectIni === -1 ? input.selectionEnd : selectIni + 1;
|
|
71
98
|
input.setSelectionRange(selectIni, input.value.length);
|
|
72
|
-
|
|
99
|
+
event.preventDefault();
|
|
73
100
|
}
|
|
74
101
|
}
|
|
75
102
|
}
|
|
76
|
-
|
|
103
|
+
handleFocus() {
|
|
77
104
|
const input = this._textInput.shadowRoot.querySelector('input');
|
|
78
105
|
if (input.selectionStart !== input.selectionEnd) {
|
|
79
106
|
let selectIni = input.value.indexOf(" ", input.selectionStart);
|
|
@@ -81,7 +108,7 @@ let EzDateTimeInput = class {
|
|
|
81
108
|
input.setSelectionRange(0, selectIni);
|
|
82
109
|
}
|
|
83
110
|
}
|
|
84
|
-
|
|
111
|
+
handleClick() {
|
|
85
112
|
const input = this._textInput.shadowRoot.querySelector('input');
|
|
86
113
|
let selectIni = input.value.lastIndexOf(" ", input.selectionEnd);
|
|
87
114
|
selectIni = selectIni === -1 ? 0 : selectIni + 1;
|
|
@@ -90,37 +117,55 @@ let EzDateTimeInput = class {
|
|
|
90
117
|
input.setSelectionRange(selectIni, selectFin);
|
|
91
118
|
}
|
|
92
119
|
changeValue(newValue) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
if ((
|
|
96
|
-
this.value =
|
|
97
|
-
this.ezChange.emit(this.value);
|
|
120
|
+
const currentValue = this.validateValue(this.value);
|
|
121
|
+
const newValueValidated = this.validateValue(newValue);
|
|
122
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
123
|
+
this.value = newValueValidated;
|
|
98
124
|
}
|
|
99
125
|
}
|
|
100
126
|
showCalendar() {
|
|
101
|
-
const top = this.
|
|
127
|
+
const top = this.errorMessage || this.mode === "slim" ? 0 : -19;
|
|
102
128
|
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
103
129
|
this._calendar.style.visibility = 'inherit';
|
|
104
130
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
131
|
+
getParsedDateTime(strValue) {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
if (strValue === void 0) {
|
|
134
|
+
strValue = (((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "");
|
|
135
|
+
}
|
|
136
|
+
if (!strValue) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const partsDateTime = strValue.split(" ");
|
|
108
140
|
const onlyDate = partsDateTime.length > 0 ? partsDateTime[0] : strValue;
|
|
109
141
|
const onlyTime = partsDateTime[1] ? partsDateTime[1] : "";
|
|
110
142
|
const parsedTime = core.TimeFormatter.prepareValue(onlyTime, this.showSeconds);
|
|
111
143
|
const strDateTime = onlyDate + (parsedTime && " " + parsedTime);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
144
|
+
return core.DateUtils.strToDate(strDateTime);
|
|
145
|
+
}
|
|
146
|
+
handleBlur() {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
const strValue = ((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "";
|
|
149
|
+
const newValue = this.getParsedDateTime();
|
|
150
|
+
if (newValue || !strValue) {
|
|
151
|
+
this.errorMessage = "";
|
|
152
|
+
const currentValue = this.validateValue(this.value);
|
|
153
|
+
const newValueValidated = this.validateValue(newValue);
|
|
154
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
155
|
+
if (newValueValidated) {
|
|
156
|
+
this._textInput.value = this.getTextValue(newValueValidated) || '';
|
|
157
|
+
this._focused = false;
|
|
158
|
+
}
|
|
159
|
+
this.ezCancelWaitingChange.emit();
|
|
116
160
|
}
|
|
117
161
|
else {
|
|
118
|
-
this.changeValue(
|
|
162
|
+
this.changeValue(newValueValidated);
|
|
119
163
|
}
|
|
120
164
|
}
|
|
121
165
|
else {
|
|
166
|
+
this.changeValue(undefined);
|
|
122
167
|
this.ezCancelWaitingChange.emit();
|
|
123
|
-
this.
|
|
168
|
+
this.errorMessage = "O valor digitado não é uma data válida";
|
|
124
169
|
}
|
|
125
170
|
}
|
|
126
171
|
getTextValue(d) {
|
|
@@ -134,14 +179,32 @@ let EzDateTimeInput = class {
|
|
|
134
179
|
};
|
|
135
180
|
return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : undefined;
|
|
136
181
|
}
|
|
137
|
-
|
|
138
|
-
|
|
182
|
+
validateValue(value) {
|
|
183
|
+
return value instanceof Date && !isNaN(value.valueOf())
|
|
184
|
+
? value
|
|
185
|
+
: undefined;
|
|
186
|
+
}
|
|
187
|
+
handleInput() {
|
|
188
|
+
const newValue = this.getParsedDateTime();
|
|
189
|
+
const currentValue = this.validateValue(this.value);
|
|
190
|
+
const newValueValidated = this.validateValue(newValue);
|
|
191
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
192
|
+
this._focused = true;
|
|
193
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
setInputValue() {
|
|
197
|
+
const textValue = this.getTextValue(this.value) || '';
|
|
198
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
199
|
+
this._textInput.value = textValue;
|
|
200
|
+
}
|
|
139
201
|
}
|
|
140
202
|
componentDidLoad() {
|
|
141
203
|
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
204
|
+
this.setInputValue();
|
|
142
205
|
}
|
|
143
206
|
render() {
|
|
144
|
-
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem,
|
|
207
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, onKeyDown: event => { this.handleKeyDown(event); }, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), onFocus: () => this.handleFocus(), onClick: () => this.handleClick() }, 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 })));
|
|
145
208
|
}
|
|
146
209
|
get _elem() { return index.getElement(this); }
|
|
147
210
|
static get watchers() { return {
|
|
@@ -30,9 +30,10 @@ let EzFilterInput = class {
|
|
|
30
30
|
this._textInput.errorMessage = this.errorMessage;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
observeValue() {
|
|
34
|
-
if (this._textInput) {
|
|
35
|
-
this._textInput.value =
|
|
33
|
+
observeValue(newValue, oldValue) {
|
|
34
|
+
if (this._textInput && newValue != oldValue) {
|
|
35
|
+
this._textInput.value = newValue;
|
|
36
|
+
this.ezChange.emit(newValue);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
/**
|
|
@@ -47,12 +48,17 @@ let EzFilterInput = class {
|
|
|
47
48
|
async setBlur() {
|
|
48
49
|
this._textInput.setBlur();
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
53
|
+
*/
|
|
54
|
+
async isInvalid() {
|
|
55
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
56
|
+
}
|
|
50
57
|
changeValue(evt) {
|
|
51
58
|
const newValue = evt.detail;
|
|
52
59
|
this.errorMessage = "";
|
|
53
60
|
if (newValue !== this.value) {
|
|
54
61
|
this.value = newValue;
|
|
55
|
-
this.ezChange.emit(this.value);
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
componentDidLoad() {
|