@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
|
@@ -46,40 +46,66 @@ let EzComboBox = class {
|
|
|
46
46
|
*/
|
|
47
47
|
this.mode = "regular";
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
observeErrorMessage() {
|
|
50
|
+
var _a;
|
|
51
|
+
if (this._textInput) {
|
|
52
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
53
|
+
if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
54
|
+
this.setInputValue();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
observeValue(newValue, oldValue) {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
if (this._textInput && newValue != oldValue) {
|
|
61
|
+
const newValueSelected = this.getSelectedOption(newValue);
|
|
62
|
+
const oldValueSelected = this.getSelectedOption(oldValue);
|
|
63
|
+
const currentValue = this.getSelectedOption(this.value);
|
|
64
|
+
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())) {
|
|
65
|
+
this.value = newValueSelected;
|
|
66
|
+
}
|
|
67
|
+
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())) {
|
|
68
|
+
this.setInputValue();
|
|
69
|
+
const valueEmitted = newValueSelected === null ? undefined : newValueSelected;
|
|
70
|
+
this.ezChange.emit(valueEmitted);
|
|
71
|
+
}
|
|
72
|
+
this.hideOptions();
|
|
73
|
+
this._criteria = undefined;
|
|
74
|
+
this._preSelection = undefined;
|
|
75
|
+
this.updateVisibleOptions();
|
|
52
76
|
}
|
|
53
|
-
this.hideOptions();
|
|
54
|
-
this._criteria = undefined;
|
|
55
|
-
this._preSelection = undefined;
|
|
56
|
-
this.updateVisibleOptions();
|
|
57
77
|
}
|
|
58
78
|
/**
|
|
59
79
|
* Realiza o foco no componente de seleção
|
|
60
80
|
*/
|
|
61
81
|
async setFocus() {
|
|
62
|
-
this.
|
|
82
|
+
this._textInput.setFocus();
|
|
63
83
|
}
|
|
64
84
|
/**
|
|
65
85
|
* Remove o foco no componente de seleção
|
|
66
86
|
*/
|
|
67
87
|
async setBlur() {
|
|
68
|
-
this.
|
|
88
|
+
this._textInput.setBlur();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
92
|
+
*/
|
|
93
|
+
async isInvalid() {
|
|
94
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
69
95
|
}
|
|
70
96
|
getText() {
|
|
71
97
|
let text = "";
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
text = this.showSelectedValue ? `${
|
|
98
|
+
const currentValue = this.getSelectedOption(this.value);
|
|
99
|
+
if (currentValue) {
|
|
100
|
+
text = this.showSelectedValue ? `${currentValue.value} - ${currentValue.label}` : currentValue.label;
|
|
75
101
|
}
|
|
76
102
|
return text;
|
|
77
103
|
}
|
|
78
|
-
getSelectedOption() {
|
|
79
|
-
if (typeof
|
|
80
|
-
return this._visibleOptions.find(o => o.value ===
|
|
104
|
+
getSelectedOption(value) {
|
|
105
|
+
if (typeof value === "string" || value instanceof String) {
|
|
106
|
+
return this._visibleOptions.find(o => o.value === value);
|
|
81
107
|
}
|
|
82
|
-
return
|
|
108
|
+
return value;
|
|
83
109
|
}
|
|
84
110
|
updateVisibleOptions() {
|
|
85
111
|
let opts = this._source || [];
|
|
@@ -134,7 +160,7 @@ let EzComboBox = class {
|
|
|
134
160
|
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
135
161
|
//posição errada no futuro. Preferi fazer simples no começo,
|
|
136
162
|
//porque não quis onerar o text input com essa funcionalidade...
|
|
137
|
-
const top = (this.errorMessage || !this.canShowError || this.mode
|
|
163
|
+
const top = (this.errorMessage || !this.canShowError || this.mode === "slim") ? "0px" : "-19px";
|
|
138
164
|
this._floatingID = FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, top });
|
|
139
165
|
window.requestAnimationFrame(() => {
|
|
140
166
|
this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
@@ -217,15 +243,13 @@ let EzComboBox = class {
|
|
|
217
243
|
}
|
|
218
244
|
selectOption(newOption) {
|
|
219
245
|
var _a, _b;
|
|
220
|
-
const
|
|
221
|
-
if (((_a =
|
|
246
|
+
const currentValue = this.getSelectedOption(this.value);
|
|
247
|
+
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())) {
|
|
222
248
|
const adjustedOpt = !(newOption === null || newOption === void 0 ? void 0 : newOption.value) ? undefined : newOption;
|
|
223
249
|
this.value = adjustedOpt;
|
|
224
|
-
this.errorMessage = "";
|
|
225
|
-
this.ezChange.emit(this.value);
|
|
226
250
|
}
|
|
227
251
|
else {
|
|
228
|
-
this.
|
|
252
|
+
this.setInputValue();
|
|
229
253
|
}
|
|
230
254
|
if (this.searchMode) {
|
|
231
255
|
this._visibleOptions = [];
|
|
@@ -242,11 +266,20 @@ let EzComboBox = class {
|
|
|
242
266
|
}
|
|
243
267
|
}
|
|
244
268
|
cancelPreselection() {
|
|
245
|
-
if (!this.
|
|
269
|
+
if (!this._textInput.value && this.value) {
|
|
246
270
|
this.selectOption(undefined);
|
|
247
271
|
}
|
|
248
272
|
else {
|
|
249
|
-
this.
|
|
273
|
+
this.setInputValue();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
setInputValue(clearError = true) {
|
|
277
|
+
const textValue = this.getText();
|
|
278
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
279
|
+
this._textInput.value = textValue;
|
|
280
|
+
if (clearError) {
|
|
281
|
+
this.errorMessage = "";
|
|
282
|
+
}
|
|
250
283
|
}
|
|
251
284
|
}
|
|
252
285
|
clearSearch() {
|
|
@@ -304,7 +337,8 @@ let EzComboBox = class {
|
|
|
304
337
|
}
|
|
305
338
|
}
|
|
306
339
|
componentDidLoad() {
|
|
307
|
-
CSSVarsUtils.applyVarsTextInput(this.el, this.
|
|
340
|
+
CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
|
|
341
|
+
this.setInputValue(false);
|
|
308
342
|
}
|
|
309
343
|
//---------------------------------------------
|
|
310
344
|
// Event handlers
|
|
@@ -324,7 +358,7 @@ let EzComboBox = class {
|
|
|
324
358
|
const argument = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
|
|
325
359
|
const argumentNumber = Number(argument || undefined);
|
|
326
360
|
if (!this._criteria) {
|
|
327
|
-
this.
|
|
361
|
+
this._textInput.value = event.data || argument;
|
|
328
362
|
}
|
|
329
363
|
this._criteria = argument;
|
|
330
364
|
if (argument && (!isNaN(argumentNumber) || argument.length >= this._limitCharsToSearch)) {
|
|
@@ -382,7 +416,7 @@ let EzComboBox = class {
|
|
|
382
416
|
}
|
|
383
417
|
render() {
|
|
384
418
|
var _a;
|
|
385
|
-
return (h(Host, null, h("ez-text-input", { class: this.suppressSearch ? "suppressed-search-input" : "", ref: elem => this.
|
|
419
|
+
return (h(Host, null, 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 }, h("button", { class: "btn", slot: this.searchMode ? "leftIcon" : "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.handlerIconClick() }, 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)
|
|
386
420
|
? h("button", { class: "btn", slot: "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.clearSearch() }, h("ez-icon", { iconName: "close" }))
|
|
387
421
|
: undefined), h("section", { class: "list-container", ref: elem => this._listContainer = elem }, h("div", { class: "list-wrapper", ref: elem => this._listWrapper = elem }, h("div", { class: "list-options", ref: elem => this._optionsList = elem }, this._visibleOptions.length === 0
|
|
388
422
|
&& h("div", { class: "message" }, !this._showLoading && h("span", { class: "message__no-result" }, this._textEmptyList), this._showLoading && h("div", { class: "message__loading" })), this.showOptionValue
|
|
@@ -391,6 +425,7 @@ let EzComboBox = class {
|
|
|
391
425
|
}
|
|
392
426
|
get el() { return getElement(this); }
|
|
393
427
|
static get watchers() { return {
|
|
428
|
+
"errorMessage": ["observeErrorMessage"],
|
|
394
429
|
"value": ["observeValue"]
|
|
395
430
|
}; }
|
|
396
431
|
};
|
|
@@ -10,6 +10,7 @@ let EzDateInput = class {
|
|
|
10
10
|
this.ezChange = createEvent(this, "ezChange", 7);
|
|
11
11
|
this.ezStartChange = createEvent(this, "ezStartChange", 7);
|
|
12
12
|
this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
|
|
13
|
+
this._focused = false;
|
|
13
14
|
/**
|
|
14
15
|
* Deixa o campo disponível ou não para uso.
|
|
15
16
|
*/
|
|
@@ -20,18 +21,33 @@ let EzDateInput = class {
|
|
|
20
21
|
this.mode = "regular";
|
|
21
22
|
}
|
|
22
23
|
observeLabel() {
|
|
23
|
-
this._textInput
|
|
24
|
+
if (this._textInput) {
|
|
25
|
+
this._textInput.label = this.label;
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
observeErrorMessage() {
|
|
29
|
+
var _a;
|
|
26
30
|
if (this._textInput) {
|
|
27
31
|
this._textInput.errorMessage = this.errorMessage;
|
|
32
|
+
if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
33
|
+
this.setInputValue();
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
}
|
|
30
37
|
observeValue(newValue, oldValue) {
|
|
31
|
-
if (newValue != oldValue) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
if (this._textInput && newValue != oldValue) {
|
|
39
|
+
const newValueValidated = this.validateValue(newValue);
|
|
40
|
+
const oldValueValidated = this.validateValue(oldValue);
|
|
41
|
+
if ((newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime()) !== (oldValueValidated === null || oldValueValidated === void 0 ? void 0 : oldValueValidated.getTime())) {
|
|
42
|
+
const textValue = this.getTextValue(newValueValidated) || '';
|
|
43
|
+
const parsedDate = DateUtils.strToDate(textValue);
|
|
44
|
+
if ((parsedDate || !this._focused) && (this._textInput.value || '') !== textValue) {
|
|
45
|
+
this._textInput.value = textValue;
|
|
46
|
+
this._focused = false;
|
|
47
|
+
this.errorMessage = "";
|
|
48
|
+
}
|
|
49
|
+
const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
|
|
50
|
+
this.ezChange.emit(valueEmitted);
|
|
35
51
|
}
|
|
36
52
|
}
|
|
37
53
|
}
|
|
@@ -47,59 +63,89 @@ let EzDateInput = class {
|
|
|
47
63
|
async setBlur() {
|
|
48
64
|
this._textInput.setBlur();
|
|
49
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
68
|
+
*/
|
|
69
|
+
async isInvalid() {
|
|
70
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
71
|
+
}
|
|
50
72
|
changeValue(newValue) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if ((newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString())) {
|
|
56
|
-
this.value = newValue;
|
|
57
|
-
this.ezChange.emit(this.value);
|
|
73
|
+
const currentValue = this.validateValue(this.value);
|
|
74
|
+
const newValueValidated = this.validateValue(newValue);
|
|
75
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
76
|
+
this.value = newValueValidated;
|
|
58
77
|
}
|
|
59
78
|
}
|
|
60
79
|
showCalendar() {
|
|
61
|
-
this.
|
|
80
|
+
this.handleBlur();
|
|
62
81
|
this._calendar.value = this.value;
|
|
63
82
|
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
64
83
|
//posição errada no futuro. Preferi fazer simples no começo,
|
|
65
84
|
//porque não quis onerar o text input com essa funcionalidade...
|
|
66
|
-
const top = this.
|
|
85
|
+
const top = this.errorMessage || this.mode === "slim" ? 0 : -19;
|
|
67
86
|
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
68
87
|
}
|
|
69
88
|
hideCalendar() {
|
|
70
89
|
this.changeValue(this._calendar.value);
|
|
71
90
|
this._calendar.hide();
|
|
72
91
|
}
|
|
73
|
-
|
|
92
|
+
handleBlur() {
|
|
74
93
|
const strValue = this._textInput.value;
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
const newValue = DateUtils.strToDate(strValue);
|
|
95
|
+
if (newValue || !strValue) {
|
|
96
|
+
this.errorMessage = "";
|
|
97
|
+
const currentValue = this.validateValue(this.value);
|
|
98
|
+
const newValueValidated = this.validateValue(newValue);
|
|
99
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
100
|
+
if (newValueValidated) {
|
|
101
|
+
this._textInput.value = this.getTextValue(newValueValidated) || '';
|
|
102
|
+
this._focused = false;
|
|
103
|
+
}
|
|
104
|
+
this.ezCancelWaitingChange.emit();
|
|
79
105
|
}
|
|
80
106
|
else {
|
|
81
|
-
this.changeValue(
|
|
107
|
+
this.changeValue(newValueValidated);
|
|
82
108
|
}
|
|
83
109
|
}
|
|
84
110
|
else {
|
|
111
|
+
this.changeValue(undefined);
|
|
85
112
|
this.ezCancelWaitingChange.emit();
|
|
86
|
-
this.
|
|
113
|
+
this.errorMessage = "O valor digitado não é uma data válida";
|
|
87
114
|
}
|
|
88
115
|
}
|
|
89
116
|
getTextValue(d) {
|
|
90
117
|
return d ? new Intl.DateTimeFormat("pt-BR").format(d) : undefined;
|
|
91
118
|
}
|
|
92
|
-
|
|
93
|
-
this.
|
|
119
|
+
handleInput() {
|
|
120
|
+
const strValue = this._textInput.value;
|
|
121
|
+
const newValue = DateUtils.strToDate(strValue);
|
|
122
|
+
const currentValue = this.validateValue(this.value);
|
|
123
|
+
const newValueValidated = this.validateValue(newValue);
|
|
124
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
125
|
+
this._focused = true;
|
|
126
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
validateValue(value) {
|
|
130
|
+
return value instanceof Date && !isNaN(value.valueOf())
|
|
131
|
+
? DateUtils.clearTime(value)
|
|
132
|
+
: undefined;
|
|
133
|
+
}
|
|
134
|
+
setInputValue() {
|
|
135
|
+
const textValue = this.getTextValue(this.value) || '';
|
|
136
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
137
|
+
this._textInput.value = textValue;
|
|
138
|
+
}
|
|
94
139
|
}
|
|
95
140
|
componentDidLoad() {
|
|
96
141
|
CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
142
|
+
this.setInputValue();
|
|
97
143
|
}
|
|
98
144
|
render() {
|
|
99
|
-
return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem,
|
|
145
|
+
return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem, "data-slave-mode": "true", onKeyDown: event => {
|
|
100
146
|
if (event.key === "H" || event.key === "h")
|
|
101
147
|
this.changeValue(new Date());
|
|
102
|
-
}, label: this.label,
|
|
148
|
+
}, label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
|
|
103
149
|
}
|
|
104
150
|
get _elem() { return getElement(this); }
|
|
105
151
|
static get watchers() { return {
|
|
@@ -10,6 +10,7 @@ let EzDateTimeInput = class {
|
|
|
10
10
|
this.ezChange = createEvent(this, "ezChange", 7);
|
|
11
11
|
this.ezStartChange = createEvent(this, "ezStartChange", 7);
|
|
12
12
|
this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
|
|
13
|
+
this._focused = false;
|
|
13
14
|
/**
|
|
14
15
|
* Deixa o campo disponível ou não para uso.
|
|
15
16
|
*/
|
|
@@ -24,14 +25,34 @@ let EzDateTimeInput = 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() {
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
observeValue() {
|
|
33
|
+
var _a;
|
|
33
34
|
if (this._textInput) {
|
|
34
|
-
this._textInput.
|
|
35
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
36
|
+
if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
37
|
+
this.setInputValue();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
observeValue(newValue, oldValue) {
|
|
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 = this.getParsedDateTime(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);
|
|
55
|
+
}
|
|
35
56
|
}
|
|
36
57
|
}
|
|
37
58
|
/**
|
|
@@ -46,30 +67,36 @@ let EzDateTimeInput = class {
|
|
|
46
67
|
async setBlur() {
|
|
47
68
|
this._textInput.setBlur();
|
|
48
69
|
}
|
|
49
|
-
|
|
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
|
+
}
|
|
76
|
+
handleKeyDown(event) {
|
|
50
77
|
const input = this._textInput.shadowRoot.querySelector('input');
|
|
51
|
-
if (
|
|
78
|
+
if (event.key === "H" || event.key === "h") {
|
|
52
79
|
this.changeValue(new Date());
|
|
53
80
|
}
|
|
54
|
-
else if (
|
|
81
|
+
else if (event.shiftKey && event.key === "Tab") {
|
|
55
82
|
if (input.selectionStart > 0) {
|
|
56
83
|
let selectIni = input.value.lastIndexOf(" ", input.selectionStart);
|
|
57
84
|
if (selectIni !== -1) {
|
|
58
85
|
input.setSelectionRange(0, selectIni);
|
|
59
|
-
|
|
86
|
+
event.preventDefault();
|
|
60
87
|
}
|
|
61
88
|
}
|
|
62
89
|
}
|
|
63
|
-
else if (
|
|
90
|
+
else if (event.key === "Tab") {
|
|
64
91
|
if (input.value.length !== input.selectionEnd) {
|
|
65
92
|
let selectIni = input.value.indexOf(" ", input.selectionEnd);
|
|
66
93
|
selectIni = selectIni === -1 ? input.selectionEnd : selectIni + 1;
|
|
67
94
|
input.setSelectionRange(selectIni, input.value.length);
|
|
68
|
-
|
|
95
|
+
event.preventDefault();
|
|
69
96
|
}
|
|
70
97
|
}
|
|
71
98
|
}
|
|
72
|
-
|
|
99
|
+
handleFocus() {
|
|
73
100
|
const input = this._textInput.shadowRoot.querySelector('input');
|
|
74
101
|
if (input.selectionStart !== input.selectionEnd) {
|
|
75
102
|
let selectIni = input.value.indexOf(" ", input.selectionStart);
|
|
@@ -77,7 +104,7 @@ let EzDateTimeInput = class {
|
|
|
77
104
|
input.setSelectionRange(0, selectIni);
|
|
78
105
|
}
|
|
79
106
|
}
|
|
80
|
-
|
|
107
|
+
handleClick() {
|
|
81
108
|
const input = this._textInput.shadowRoot.querySelector('input');
|
|
82
109
|
let selectIni = input.value.lastIndexOf(" ", input.selectionEnd);
|
|
83
110
|
selectIni = selectIni === -1 ? 0 : selectIni + 1;
|
|
@@ -86,37 +113,55 @@ let EzDateTimeInput = class {
|
|
|
86
113
|
input.setSelectionRange(selectIni, selectFin);
|
|
87
114
|
}
|
|
88
115
|
changeValue(newValue) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if ((
|
|
92
|
-
this.value =
|
|
93
|
-
this.ezChange.emit(this.value);
|
|
116
|
+
const currentValue = this.validateValue(this.value);
|
|
117
|
+
const newValueValidated = this.validateValue(newValue);
|
|
118
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
119
|
+
this.value = newValueValidated;
|
|
94
120
|
}
|
|
95
121
|
}
|
|
96
122
|
showCalendar() {
|
|
97
|
-
const top = this.
|
|
123
|
+
const top = this.errorMessage || this.mode === "slim" ? 0 : -19;
|
|
98
124
|
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
99
125
|
this._calendar.style.visibility = 'inherit';
|
|
100
126
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
127
|
+
getParsedDateTime(strValue) {
|
|
128
|
+
var _a, _b;
|
|
129
|
+
if (strValue === void 0) {
|
|
130
|
+
strValue = (((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "");
|
|
131
|
+
}
|
|
132
|
+
if (!strValue) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const partsDateTime = strValue.split(" ");
|
|
104
136
|
const onlyDate = partsDateTime.length > 0 ? partsDateTime[0] : strValue;
|
|
105
137
|
const onlyTime = partsDateTime[1] ? partsDateTime[1] : "";
|
|
106
138
|
const parsedTime = TimeFormatter.prepareValue(onlyTime, this.showSeconds);
|
|
107
139
|
const strDateTime = onlyDate + (parsedTime && " " + parsedTime);
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
140
|
+
return DateUtils.strToDate(strDateTime);
|
|
141
|
+
}
|
|
142
|
+
handleBlur() {
|
|
143
|
+
var _a, _b;
|
|
144
|
+
const strValue = ((_b = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim()) || "";
|
|
145
|
+
const newValue = this.getParsedDateTime();
|
|
146
|
+
if (newValue || !strValue) {
|
|
147
|
+
this.errorMessage = "";
|
|
148
|
+
const currentValue = this.validateValue(this.value);
|
|
149
|
+
const newValueValidated = this.validateValue(newValue);
|
|
150
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
151
|
+
if (newValueValidated) {
|
|
152
|
+
this._textInput.value = this.getTextValue(newValueValidated) || '';
|
|
153
|
+
this._focused = false;
|
|
154
|
+
}
|
|
155
|
+
this.ezCancelWaitingChange.emit();
|
|
112
156
|
}
|
|
113
157
|
else {
|
|
114
|
-
this.changeValue(
|
|
158
|
+
this.changeValue(newValueValidated);
|
|
115
159
|
}
|
|
116
160
|
}
|
|
117
161
|
else {
|
|
162
|
+
this.changeValue(undefined);
|
|
118
163
|
this.ezCancelWaitingChange.emit();
|
|
119
|
-
this.
|
|
164
|
+
this.errorMessage = "O valor digitado não é uma data válida";
|
|
120
165
|
}
|
|
121
166
|
}
|
|
122
167
|
getTextValue(d) {
|
|
@@ -130,14 +175,32 @@ let EzDateTimeInput = class {
|
|
|
130
175
|
};
|
|
131
176
|
return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : undefined;
|
|
132
177
|
}
|
|
133
|
-
|
|
134
|
-
|
|
178
|
+
validateValue(value) {
|
|
179
|
+
return value instanceof Date && !isNaN(value.valueOf())
|
|
180
|
+
? value
|
|
181
|
+
: undefined;
|
|
182
|
+
}
|
|
183
|
+
handleInput() {
|
|
184
|
+
const newValue = this.getParsedDateTime();
|
|
185
|
+
const currentValue = this.validateValue(this.value);
|
|
186
|
+
const newValueValidated = this.validateValue(newValue);
|
|
187
|
+
if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
|
|
188
|
+
this._focused = true;
|
|
189
|
+
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
setInputValue() {
|
|
193
|
+
const textValue = this.getTextValue(this.value) || '';
|
|
194
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
195
|
+
this._textInput.value = textValue;
|
|
196
|
+
}
|
|
135
197
|
}
|
|
136
198
|
componentDidLoad() {
|
|
137
199
|
CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
200
|
+
this.setInputValue();
|
|
138
201
|
}
|
|
139
202
|
render() {
|
|
140
|
-
return (h(Host, null, h("ez-text-input", { ref: elem => this._textInput = elem,
|
|
203
|
+
return (h(Host, null, 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() }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
|
|
141
204
|
}
|
|
142
205
|
get _elem() { return getElement(this); }
|
|
143
206
|
static get watchers() { return {
|
|
@@ -26,9 +26,10 @@ let EzFilterInput = class {
|
|
|
26
26
|
this._textInput.errorMessage = this.errorMessage;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
observeValue() {
|
|
30
|
-
if (this._textInput) {
|
|
31
|
-
this._textInput.value =
|
|
29
|
+
observeValue(newValue, oldValue) {
|
|
30
|
+
if (this._textInput && newValue != oldValue) {
|
|
31
|
+
this._textInput.value = newValue;
|
|
32
|
+
this.ezChange.emit(newValue);
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
@@ -43,12 +44,17 @@ let EzFilterInput = class {
|
|
|
43
44
|
async setBlur() {
|
|
44
45
|
this._textInput.setBlur();
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
49
|
+
*/
|
|
50
|
+
async isInvalid() {
|
|
51
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
52
|
+
}
|
|
46
53
|
changeValue(evt) {
|
|
47
54
|
const newValue = evt.detail;
|
|
48
55
|
this.errorMessage = "";
|
|
49
56
|
if (newValue !== this.value) {
|
|
50
57
|
this.value = newValue;
|
|
51
|
-
this.ezChange.emit(this.value);
|
|
52
58
|
}
|
|
53
59
|
}
|
|
54
60
|
componentDidLoad() {
|