@sankhyalabs/ezui 1.1.109 → 1.1.112
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/ApplicationUtils-c8f07135.js +39 -0
- package/dist/cjs/CSSVarsUtils-8fbdf2e0.js +19 -0
- package/dist/cjs/ez-button.cjs.entry.js +79 -0
- package/dist/cjs/ez-calendar.cjs.entry.js +223 -0
- package/dist/cjs/ez-check.cjs.entry.js +76 -0
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +47 -0
- package/dist/cjs/ez-combo-box.cjs.entry.js +278 -0
- package/dist/cjs/ez-date-input.cjs.entry.js +102 -0
- package/dist/cjs/ez-date-time-input.cjs.entry.js +145 -0
- package/dist/cjs/ez-form.cjs.entry.js +785 -0
- package/dist/cjs/ez-icon.cjs.entry.js +41 -0
- package/dist/cjs/{ez-button_3.cjs.entry.js → ez-list.cjs.entry.js} +0 -89
- package/dist/cjs/ez-modal.cjs.entry.js +65 -0
- package/dist/cjs/ez-number-input.cjs.entry.js +86 -0
- package/dist/cjs/ez-search.cjs.entry.js +64 -0
- package/dist/cjs/ez-tabselector.cjs.entry.js +198 -0
- package/dist/cjs/ez-text-area.cjs.entry.js +114 -0
- package/dist/cjs/ez-text-input.cjs.entry.js +201 -0
- package/dist/cjs/ez-time-input.cjs.entry.js +118 -0
- package/dist/cjs/ez-upload.cjs.entry.js +356 -0
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/{ez-modal_2.cjs.entry.js → grid-config.cjs.entry.js} +0 -59
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/select-box.cjs.entry.js +22 -0
- package/dist/cjs/test-du.cjs.entry.js +76 -0
- package/dist/collection/collection-manifest.json +132 -1
- package/dist/esm/ApplicationUtils-36e38de9.js +37 -0
- package/dist/esm/CSSVarsUtils-667e0016.js +17 -0
- package/dist/esm/ez-button.entry.js +75 -0
- package/dist/esm/ez-calendar.entry.js +219 -0
- package/dist/esm/ez-check.entry.js +72 -0
- package/dist/esm/ez-collapsible-box.entry.js +43 -0
- package/dist/esm/ez-combo-box.entry.js +274 -0
- package/dist/esm/ez-date-input.entry.js +98 -0
- package/dist/esm/ez-date-time-input.entry.js +141 -0
- package/dist/esm/ez-form.entry.js +781 -0
- package/dist/esm/ez-icon.entry.js +37 -0
- package/dist/esm/{ez-button_3.entry.js → ez-list.entry.js} +2 -89
- package/dist/esm/ez-modal.entry.js +61 -0
- package/dist/esm/ez-number-input.entry.js +82 -0
- package/dist/esm/ez-search.entry.js +60 -0
- package/dist/esm/ez-tabselector.entry.js +194 -0
- package/dist/esm/ez-text-area.entry.js +110 -0
- package/dist/esm/ez-text-input.entry.js +197 -0
- package/dist/esm/ez-time-input.entry.js +114 -0
- package/dist/esm/ez-upload.entry.js +352 -0
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/{ez-modal_2.entry.js → grid-config.entry.js} +1 -59
- package/dist/esm/loader.js +1 -1
- package/dist/esm/select-box.entry.js +18 -0
- package/dist/esm/test-du.entry.js +72 -0
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-25e87823.entry.js +1 -0
- package/dist/ezui/p-31b0e21a.entry.js +1 -0
- package/dist/ezui/p-363fc3af.entry.js +1 -0
- package/dist/ezui/p-3662c09e.entry.js +1 -0
- package/dist/ezui/p-3a8bf0a8.entry.js +1 -0
- package/dist/ezui/p-3c954800.entry.js +1 -0
- package/dist/ezui/p-44d4f8d6.entry.js +1 -0
- package/dist/ezui/p-59a8448a.entry.js +1 -0
- package/dist/ezui/p-62daf508.js +1 -0
- package/dist/ezui/p-65893e25.entry.js +1 -0
- package/dist/ezui/p-73d3f767.entry.js +1 -0
- package/dist/ezui/p-73d45b12.entry.js +1 -0
- package/dist/ezui/p-804c118a.entry.js +1 -0
- package/dist/ezui/p-97f77023.entry.js +1 -0
- package/dist/ezui/p-9aecc079.entry.js +1 -0
- package/dist/ezui/p-a5f1f9c4.entry.js +1 -0
- package/dist/ezui/p-bc2834fa.entry.js +1 -0
- package/dist/ezui/p-c27495d9.entry.js +1 -0
- package/dist/ezui/p-c6f2aa6c.entry.js +1 -0
- package/dist/ezui/p-d54c157f.js +1 -0
- package/dist/ezui/p-f26f6d67.entry.js +1 -0
- package/dist/ezui/p-f3f9c7e6.entry.js +1 -0
- package/dist/ezui/p-f78c7ec9.entry.js +1 -0
- package/package.json +3 -37
- package/dist/cjs/ez-calendar_16.cjs.entry.js +0 -2855
- package/dist/esm/ez-calendar_16.entry.js +0 -2836
- package/dist/ezui/p-6b257393.entry.js +0 -1
- package/dist/ezui/p-ae7c92b7.entry.js +0 -1
- package/dist/ezui/p-eaeaea64.entry.js +0 -1
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-88286449.js');
|
|
6
|
+
const core = require('@sankhyalabs/core');
|
|
7
|
+
const CSSVarsUtils = require('./CSSVarsUtils-8fbdf2e0.js');
|
|
8
|
+
|
|
9
|
+
const ezComboBoxCss = ":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn-search--background-color:var(--text--primary, #626e82);--ez-combo-box__btn-search-disabled--background-color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-search-hover--background-color:var(--color--primary, #4e4e4e);--ez-combo-box__btn-options--background-color:var(--text--primary, #626e82);--ez-combo-box__btn-options-disabled--background-color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-options-hover--background-color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #919191);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium));--ez-combo-box__drop-down-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"16px\"><path d=\"M 1.8585859,3.0707069 7.9999998,9.2121212 14.141414,3.0707069 16,5.0101006 7.9999998,12.929293 0,4.9292932 Z\"/></svg>');--ez-combo-box__search-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"22px\" width=\"22px\"><path d=\"m 9.4,2.3 c 4.1,0 7.4,3.2 7.4,7.2 0,1.8 -0.7,3.4 -1.8,4.7 l 0.3,0.3 h 0.9 l 5.7,5.6 -1.7,1.7 -5.7,-5.6 V 15.3 L 14.3,15 C 13,16.1 11.3,16.7 9.5,16.7 5.3,16.7 2,13.5 2,9.5 2,5.5 5.3,2.3 9.4,2.3 m 0,2.2 c -2.9,0 -5.1,2.2 -5.1,5 0,2.8 2.3,5 5.1,5 2.8,0 5.1,-2.2 5.1,-5 0,-2.8 -2.2,-5 -5.1,-5 z\"/></svg>');--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}.list-container{position:relative;width:100%}.options-list{box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);display:flex;flex-direction:column;background-color:var(--ez-combo-box--background-color--xlight);padding:var(--ez-combo-box--space--small);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);scroll-behavior:smooth;max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small));overflow:auto}.item{text-align:left;display:flex;justify-content:space-between;align-items:center;border-radius:var(--ez-combo-box--border-radius-small);padding:0 var(--ez-combo-box--space--small);list-style-type:none;min-height:var(--ez-combo-box__list-height)}.item--label{text-align:left;flex-basis:85%;flex-grow:1;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.item--value{text-align:right;flex-basis:15%;flex-grow:0;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn-open-options{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-options:disabled{cursor:unset}.btn-open-options::after{content:'';display:flex;background-color:var(--ez-combo-box__btn-options--background-color);width:16px;height:16px;-webkit-mask-image:var(--ez-combo-box__drop-down-image);mask-image:var(--ez-combo-box__drop-down-image)}.btn-open-options:disabled:after{background-color:var(--ez-combo-box__btn-options-disabled--background-color)}.btn-open-options:enabled:hover::after{background-color:var(--ez-combo-box__btn-options-hover--background-color)}.btn-open-search{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-search:disabled{cursor:unset}.btn-open-search::after{content:'';display:flex;background-color:var(--ez-combo-box__btn-search--background-color);width:22px;height:22px;-webkit-mask-image:var(--ez-combo-box__search-image);mask-image:var(--ez-combo-box__search-image)}.btn-open-search:disabled:after{background-color:var(--ez-combo-box__btn-search-disabled--background-color)}.btn-open-search:enabled:hover::after{background-color:var(--ez-combo-box__btn-search-hover--background-color)}";
|
|
10
|
+
|
|
11
|
+
let EzComboBox = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
index.registerInstance(this, hostRef);
|
|
14
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
|
+
/**
|
|
16
|
+
* Deixa o campo disponível ou não para interação com usuário.
|
|
17
|
+
*/
|
|
18
|
+
this.enabled = true;
|
|
19
|
+
/**
|
|
20
|
+
* Ajusta a opção de mostrar o "value" ao selecionar uma opção. Por padrão não mostra.
|
|
21
|
+
*/
|
|
22
|
+
this.showSelectedValue = false;
|
|
23
|
+
/**
|
|
24
|
+
* Ajusta a opção de mostrar o "value" para cada opção. Por padrão não mostra
|
|
25
|
+
*/
|
|
26
|
+
this.showOptionValue = false;
|
|
27
|
+
/**
|
|
28
|
+
* Remove a opção vazia da lista de opções
|
|
29
|
+
*/
|
|
30
|
+
this.suppressEmptyOption = false;
|
|
31
|
+
/**
|
|
32
|
+
* Permite exibir a mensagem de erro.
|
|
33
|
+
*/
|
|
34
|
+
this.canShowError = true;
|
|
35
|
+
}
|
|
36
|
+
internalUpdate() {
|
|
37
|
+
if (this._inputElement) {
|
|
38
|
+
this._inputElement.value = this.getText();
|
|
39
|
+
}
|
|
40
|
+
this.hideOptions();
|
|
41
|
+
this._criteria = undefined;
|
|
42
|
+
this._preSelection = undefined;
|
|
43
|
+
this.updateVisibleOptions();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Realiza o foco no componente de seleção
|
|
47
|
+
*/
|
|
48
|
+
async setFocus() {
|
|
49
|
+
this._inputElement.setFocus();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Remove o foco no componente de seleção
|
|
53
|
+
*/
|
|
54
|
+
async setBlur() {
|
|
55
|
+
this._inputElement.setBlur();
|
|
56
|
+
}
|
|
57
|
+
getText() {
|
|
58
|
+
let text = "";
|
|
59
|
+
const selected = this.getSelectedOption();
|
|
60
|
+
if (selected) {
|
|
61
|
+
text = this.showSelectedValue ? `${selected.value} - ${selected.label}` : selected.label;
|
|
62
|
+
}
|
|
63
|
+
return text;
|
|
64
|
+
}
|
|
65
|
+
getSelectedOption() {
|
|
66
|
+
if (typeof this.value === "string" || this.value instanceof String) {
|
|
67
|
+
return this._visibleOptions.find(o => o.value === this.value);
|
|
68
|
+
}
|
|
69
|
+
return this.value;
|
|
70
|
+
}
|
|
71
|
+
updateVisibleOptions() {
|
|
72
|
+
let opts = this._source || [];
|
|
73
|
+
if (!this.searchMode && this._criteria) {
|
|
74
|
+
const upperCriteria = this._criteria.toUpperCase();
|
|
75
|
+
opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(upperCriteria) > -1);
|
|
76
|
+
}
|
|
77
|
+
if (this.suppressEmptyOption) {
|
|
78
|
+
this._visibleOptions = opts;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this._visibleOptions = [{ value: undefined, label: "" }].concat(opts);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
buildItem(opt, index$1) {
|
|
85
|
+
return index.h("li", { class: index$1 === this._preSelection ? "item preselected" : "item", id: `item_${opt.value}`, onMouseDown: () => this.selectOption(opt), onMouseOver: () => this._preSelection = undefined }, index.h("span", { class: "item--label", title: opt.label }, opt.label), this.showOptionValue ? index.h("span", { class: "item--value", title: opt.value }, opt.value) : undefined);
|
|
86
|
+
}
|
|
87
|
+
showOptions() {
|
|
88
|
+
if (!this.enabled) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
92
|
+
//posição errada no futuro. Preferi fazer simples no começo,
|
|
93
|
+
//porque não quis onerar o text input com essa funcionalidade...
|
|
94
|
+
const top = (this.errorMessage || !this.canShowError) ? "0px" : "-17px";
|
|
95
|
+
this._floatingID = core.FloatingManager.float(this._optionsList, this._listContainer, { autoClose: true, top });
|
|
96
|
+
window.requestAnimationFrame(() => {
|
|
97
|
+
this._optionsList.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
hideOptions() {
|
|
101
|
+
if (this._floatingID !== undefined) {
|
|
102
|
+
core.FloatingManager.close(this._floatingID);
|
|
103
|
+
}
|
|
104
|
+
this._floatingID = undefined;
|
|
105
|
+
}
|
|
106
|
+
isOptionsVisible() {
|
|
107
|
+
return this._floatingID !== undefined && core.FloatingManager.isFloating(this._floatingID);
|
|
108
|
+
}
|
|
109
|
+
nextOption() {
|
|
110
|
+
if (this.searchMode && !this.isOptionsVisible()) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.showOptions();
|
|
114
|
+
this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
|
|
115
|
+
this.scrollToOption(this._visibleOptions[this._preSelection], true);
|
|
116
|
+
}
|
|
117
|
+
previousOption() {
|
|
118
|
+
this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
|
|
119
|
+
this.scrollToOption(this._visibleOptions[this._preSelection], false);
|
|
120
|
+
}
|
|
121
|
+
scrollToOption(opt, down) {
|
|
122
|
+
window.requestAnimationFrame(() => {
|
|
123
|
+
const liElem = this._optionsList.querySelector(`li#item_${opt.value}`);
|
|
124
|
+
if (liElem) {
|
|
125
|
+
const parent = liElem.parentElement;
|
|
126
|
+
const parentRect = parent.getBoundingClientRect();
|
|
127
|
+
const itemRect = liElem.getBoundingClientRect();
|
|
128
|
+
if (down && itemRect.bottom > parentRect.bottom) {
|
|
129
|
+
parent.scrollTop = itemRect.top;
|
|
130
|
+
}
|
|
131
|
+
else if (!down && itemRect.top < parentRect.top) {
|
|
132
|
+
parent.scrollTop = 0;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
selectCurrentOption() {
|
|
138
|
+
if (this._preSelection !== undefined) {
|
|
139
|
+
this.selectOption(this._visibleOptions[this._preSelection]);
|
|
140
|
+
this._preSelection = undefined;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
selectOption(opt) {
|
|
144
|
+
const currentOpt = this.getSelectedOption();
|
|
145
|
+
if (currentOpt !== opt) {
|
|
146
|
+
const adjustedOpt = !(opt === null || opt === void 0 ? void 0 : opt.value) ? undefined : opt;
|
|
147
|
+
this.value = adjustedOpt;
|
|
148
|
+
this.errorMessage = "";
|
|
149
|
+
this.ezChange.emit(adjustedOpt);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.internalUpdate();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
updateSource(source) {
|
|
156
|
+
if (source instanceof Promise) {
|
|
157
|
+
source.then(result => this.updateSource(result));
|
|
158
|
+
this.updateVisibleOptions();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this._source = source;
|
|
162
|
+
this.updateVisibleOptions();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
loadOptions(mode, argument = "") {
|
|
166
|
+
this._criteria = argument;
|
|
167
|
+
if (this.optionLoader) {
|
|
168
|
+
this.updateSource(this.optionLoader({ mode, argument }));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
this.updateSource(this.options);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
cancelPreselection() {
|
|
175
|
+
if (!this._inputElement.value && this.value) {
|
|
176
|
+
this.selectOption(undefined);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this.internalUpdate();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//---------------------------------------------
|
|
183
|
+
// Lifecycle web component
|
|
184
|
+
//---------------------------------------------
|
|
185
|
+
componentWillLoad() {
|
|
186
|
+
if (this.options === undefined) {
|
|
187
|
+
this.options = [];
|
|
188
|
+
const optionsTags = this.el.querySelectorAll("option");
|
|
189
|
+
if (optionsTags) {
|
|
190
|
+
optionsTags.forEach(e => {
|
|
191
|
+
let label = e.innerText;
|
|
192
|
+
let value = e.getAttribute("value");
|
|
193
|
+
if (!value) {
|
|
194
|
+
value = label;
|
|
195
|
+
}
|
|
196
|
+
this.options.push({ label, value });
|
|
197
|
+
e.hidden = true;
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (this.searchMode) {
|
|
202
|
+
this.updateSource([]);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
this.loadOptions("PRELOAD");
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
componentDidRender() {
|
|
209
|
+
if (this._floatingID === undefined) {
|
|
210
|
+
this._optionsList.remove();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
componentDidLoad() {
|
|
214
|
+
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this.el, this._inputElement);
|
|
215
|
+
}
|
|
216
|
+
//---------------------------------------------
|
|
217
|
+
// Event handlers
|
|
218
|
+
//---------------------------------------------
|
|
219
|
+
onTextInputChangeHandler(event) {
|
|
220
|
+
if (!this._criteria) {
|
|
221
|
+
this._inputElement.value = event.data;
|
|
222
|
+
}
|
|
223
|
+
const argument = event.target.value;
|
|
224
|
+
this._criteria = argument;
|
|
225
|
+
if (this._criteria) {
|
|
226
|
+
if (this.searchMode) {
|
|
227
|
+
if (this._changeDeboucingTimeout) {
|
|
228
|
+
window.clearTimeout(this._changeDeboucingTimeout);
|
|
229
|
+
}
|
|
230
|
+
this._changeDeboucingTimeout = window.setTimeout(() => {
|
|
231
|
+
this.loadOptions("PREDICTIVE", argument);
|
|
232
|
+
}, 200);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
this.updateVisibleOptions();
|
|
236
|
+
}
|
|
237
|
+
this.showOptions();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
onTextInputClickHandler() {
|
|
241
|
+
if (!this.searchMode) {
|
|
242
|
+
this.showOptions();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
keyDownHandler(event) {
|
|
246
|
+
switch (event.key) {
|
|
247
|
+
case "ArrowDown":
|
|
248
|
+
this.nextOption();
|
|
249
|
+
break;
|
|
250
|
+
case "ArrowUp":
|
|
251
|
+
this.previousOption();
|
|
252
|
+
break;
|
|
253
|
+
case "Enter":
|
|
254
|
+
this.selectCurrentOption();
|
|
255
|
+
break;
|
|
256
|
+
case "Escape":
|
|
257
|
+
this.cancelPreselection();
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
event.stopPropagation();
|
|
261
|
+
}
|
|
262
|
+
onTextInputFocusOutHandler() {
|
|
263
|
+
this.cancelPreselection();
|
|
264
|
+
}
|
|
265
|
+
render() {
|
|
266
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._inputElement = elem, enabled: this.enabled, onInput: evt => this.onTextInputChangeHandler(evt), onClick: () => this.onTextInputClickHandler(), onFocusout: () => this.onTextInputFocusOutHandler(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, value: this.getText(), canShowError: this.canShowError, errorMessage: this.errorMessage }, this.searchMode ?
|
|
267
|
+
index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { this.loadOptions("ADVANCED"); }, slot: "leftIcon" })
|
|
268
|
+
:
|
|
269
|
+
index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), index.h("section", { class: "list-container", ref: elem => this._listContainer = elem }, index.h("div", { class: "options-list", ref: elem => this._optionsList = elem }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
|
|
270
|
+
}
|
|
271
|
+
get el() { return index.getElement(this); }
|
|
272
|
+
static get watchers() { return {
|
|
273
|
+
"value": ["internalUpdate"]
|
|
274
|
+
}; }
|
|
275
|
+
};
|
|
276
|
+
EzComboBox.style = ezComboBoxCss;
|
|
277
|
+
|
|
278
|
+
exports.ez_combo_box = EzComboBox;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-88286449.js');
|
|
6
|
+
const core = require('@sankhyalabs/core');
|
|
7
|
+
const CSSVarsUtils = require('./CSSVarsUtils-8fbdf2e0.js');
|
|
8
|
+
|
|
9
|
+
const ezDateInputCss = ":host{display:block;width:100%;--ez-date-input__input--background-color:var(--background--medium, #e0e0e0);--ez-date-input__input--border-color:var(--ez-date-input__input--background-color);--ez-date-input__calendar-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"15px\"><path d=\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\"/></svg>')}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;-webkit-mask-image:var(--ez-date-input__calendar-image);mask-image:var(--ez-date-input__calendar-image)}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}ez-text-input{--text-input__input--background-color:var(--ez-date-input__input--background-color, #FFFFFF);--text-input__input--border-color:var(--ez-date-input__input--border-color, #DCE0E8)}";
|
|
10
|
+
|
|
11
|
+
let EzDateInput = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
index.registerInstance(this, hostRef);
|
|
14
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
|
+
/**
|
|
16
|
+
* Deixa o campo disponível ou não para uso.
|
|
17
|
+
*/
|
|
18
|
+
this.enabled = true;
|
|
19
|
+
}
|
|
20
|
+
setLabel() {
|
|
21
|
+
this._textInput.label = this.label;
|
|
22
|
+
}
|
|
23
|
+
setErrorMessage() {
|
|
24
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
25
|
+
}
|
|
26
|
+
applyValueToInput() {
|
|
27
|
+
if (this._textInput) {
|
|
28
|
+
this._textInput.value = this.getTextValue(this.value);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Realiza o foco no componente de data
|
|
33
|
+
*/
|
|
34
|
+
async setFocus() {
|
|
35
|
+
this._textInput.setFocus();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Remove o foco no componente de data
|
|
39
|
+
*/
|
|
40
|
+
async setBlur() {
|
|
41
|
+
this._textInput.setBlur();
|
|
42
|
+
}
|
|
43
|
+
changeValue(newValue) {
|
|
44
|
+
var _a;
|
|
45
|
+
newValue = newValue instanceof Date ? core.DateUtils.clearTime(newValue) : null;
|
|
46
|
+
this.value = this.value instanceof Date ? core.DateUtils.clearTime(this.value) : null;
|
|
47
|
+
this._textInput.errorMessage = "";
|
|
48
|
+
if ((newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString())) {
|
|
49
|
+
this.value = newValue;
|
|
50
|
+
this.ezChange.emit(this.value);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
showCalendar() {
|
|
54
|
+
this.parseDate();
|
|
55
|
+
this._calendar.value = this.value;
|
|
56
|
+
//FIXME: Provavelmente isso fará com que o popup abra em uma
|
|
57
|
+
//posição errada no futuro. Preferi fazer simples no começo,
|
|
58
|
+
//porque não quis onerar o text input com essa funcionalidade...
|
|
59
|
+
const top = this._textInput.errorMessage ? 0 : -17;
|
|
60
|
+
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
61
|
+
}
|
|
62
|
+
hideCalendar() {
|
|
63
|
+
this.changeValue(this._calendar.value);
|
|
64
|
+
this._calendar.hide();
|
|
65
|
+
}
|
|
66
|
+
parseDate() {
|
|
67
|
+
const strValue = this._textInput.value;
|
|
68
|
+
const parsedDate = core.DateUtils.strToDate(strValue);
|
|
69
|
+
if (parsedDate || !strValue) {
|
|
70
|
+
if (this.value === parsedDate) {
|
|
71
|
+
this.changeValue(this.value);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.changeValue(parsedDate);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this._textInput.errorMessage = "O valor digitado não é uma data válida";
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
getTextValue(d) {
|
|
82
|
+
return d ? new Intl.DateTimeFormat("pt-BR").format(d) : null;
|
|
83
|
+
}
|
|
84
|
+
componentDidLoad() {
|
|
85
|
+
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
86
|
+
}
|
|
87
|
+
render() {
|
|
88
|
+
return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
|
|
89
|
+
if (event.key === "H" || event.key === "h")
|
|
90
|
+
this.changeValue(new Date());
|
|
91
|
+
}, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage }, 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 })));
|
|
92
|
+
}
|
|
93
|
+
get _elem() { return index.getElement(this); }
|
|
94
|
+
static get watchers() { return {
|
|
95
|
+
"label": ["setLabel"],
|
|
96
|
+
"errorMessage": ["setErrorMessage"],
|
|
97
|
+
"value": ["applyValueToInput"]
|
|
98
|
+
}; }
|
|
99
|
+
};
|
|
100
|
+
EzDateInput.style = ezDateInputCss;
|
|
101
|
+
|
|
102
|
+
exports.ez_date_input = EzDateInput;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-88286449.js');
|
|
6
|
+
const core = require('@sankhyalabs/core');
|
|
7
|
+
const CSSVarsUtils = require('./CSSVarsUtils-8fbdf2e0.js');
|
|
8
|
+
|
|
9
|
+
const ezDateTimeInputCss = ":host{display:block;width:100%;--ez-date-input__input--background-color:var(--background--medium, #e0e0e0);--ez-date-input__input--border-color:var(--ez-date-input__input--background-color);--ez-date-input__calendar-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"15px\"><path d=\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\"/></svg>')}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;-webkit-mask-image:var(--ez-date-input__calendar-image);mask-image:var(--ez-date-input__calendar-image)}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}ez-text-input{--text-input__input--background-color:var(--ez-date-input__input--background-color, #FFFFFF);--text-input__input--border-color:var(--ez-date-input__input--border-color, #DCE0E8)}";
|
|
10
|
+
|
|
11
|
+
let EzDateTimeInput = class {
|
|
12
|
+
constructor(hostRef) {
|
|
13
|
+
index.registerInstance(this, hostRef);
|
|
14
|
+
this.ezChange = index.createEvent(this, "ezChange", 7);
|
|
15
|
+
/**
|
|
16
|
+
* Deixa o campo disponível ou não para uso.
|
|
17
|
+
*/
|
|
18
|
+
this.enabled = true;
|
|
19
|
+
/**
|
|
20
|
+
* Exibe ou não os segundos no input
|
|
21
|
+
*/
|
|
22
|
+
this.showSeconds = false;
|
|
23
|
+
}
|
|
24
|
+
setLabel() {
|
|
25
|
+
this._textInput.label = this.label;
|
|
26
|
+
}
|
|
27
|
+
setErrorMessage() {
|
|
28
|
+
this._textInput.errorMessage = this.errorMessage;
|
|
29
|
+
}
|
|
30
|
+
applyValueToInput() {
|
|
31
|
+
if (this._textInput) {
|
|
32
|
+
this._textInput.value = this.getTextValue(this.value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Realiza o foco no componente de datetime
|
|
37
|
+
*/
|
|
38
|
+
async setFocus() {
|
|
39
|
+
this._textInput.setFocus();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Remove o foco no componente de datetime
|
|
43
|
+
*/
|
|
44
|
+
async setBlur() {
|
|
45
|
+
this._textInput.setBlur();
|
|
46
|
+
}
|
|
47
|
+
onChangeKeyDown(ev) {
|
|
48
|
+
const input = this._textInput.shadowRoot.querySelector('input');
|
|
49
|
+
if (ev.key === "H" || ev.key === "h") {
|
|
50
|
+
this.changeValue(new Date());
|
|
51
|
+
}
|
|
52
|
+
else if (ev.shiftKey && ev.key === "Tab") {
|
|
53
|
+
if (input.selectionStart > 0) {
|
|
54
|
+
let selectIni = input.value.lastIndexOf(" ", input.selectionStart);
|
|
55
|
+
if (selectIni !== -1) {
|
|
56
|
+
input.setSelectionRange(0, selectIni);
|
|
57
|
+
ev.preventDefault();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (ev.key === "Tab") {
|
|
62
|
+
if (input.value.length !== input.selectionEnd) {
|
|
63
|
+
let selectIni = input.value.indexOf(" ", input.selectionEnd);
|
|
64
|
+
selectIni = selectIni === -1 ? input.selectionEnd : selectIni + 1;
|
|
65
|
+
input.setSelectionRange(selectIni, input.value.length);
|
|
66
|
+
ev.preventDefault();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
onFocused() {
|
|
71
|
+
const input = this._textInput.shadowRoot.querySelector('input');
|
|
72
|
+
if (input.selectionStart !== input.selectionEnd) {
|
|
73
|
+
let selectIni = input.value.indexOf(" ", input.selectionStart);
|
|
74
|
+
selectIni = selectIni === -1 ? input.value.length : selectIni;
|
|
75
|
+
input.setSelectionRange(0, selectIni);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
onClicked() {
|
|
79
|
+
const input = this._textInput.shadowRoot.querySelector('input');
|
|
80
|
+
let selectIni = input.value.lastIndexOf(" ", input.selectionEnd);
|
|
81
|
+
selectIni = selectIni === -1 ? 0 : selectIni + 1;
|
|
82
|
+
selectIni = selectIni > input.selectionEnd ? 0 : selectIni;
|
|
83
|
+
let selectFin = selectIni === 0 ? input.value.indexOf(" ") : input.value.length;
|
|
84
|
+
input.setSelectionRange(selectIni, selectFin);
|
|
85
|
+
}
|
|
86
|
+
changeValue(newValue) {
|
|
87
|
+
var _a;
|
|
88
|
+
this._textInput.errorMessage = "";
|
|
89
|
+
if ((newValue === null || newValue === void 0 ? void 0 : newValue.toString()) !== ((_a = this.value) === null || _a === void 0 ? void 0 : _a.toString())) {
|
|
90
|
+
this.value = newValue;
|
|
91
|
+
this.ezChange.emit(this.value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
showCalendar() {
|
|
95
|
+
const top = this._textInput.errorMessage ? 0 : -17;
|
|
96
|
+
this._calendar.fitVertical(top, this._elem.clientHeight);
|
|
97
|
+
this._calendar.style.visibility = 'inherit';
|
|
98
|
+
}
|
|
99
|
+
parseDate() {
|
|
100
|
+
const strValue = this._textInput.value;
|
|
101
|
+
const partsDateTime = (strValue && strValue.length > 0) ? strValue.split(" ") : [];
|
|
102
|
+
const onlyDate = partsDateTime.length > 0 ? partsDateTime[0] : strValue;
|
|
103
|
+
const onlyTime = partsDateTime[1] ? partsDateTime[1] : "";
|
|
104
|
+
const parsedTime = core.TimeFormatter.prepareValue(onlyTime, this.showSeconds);
|
|
105
|
+
const strDateTime = onlyDate + (parsedTime && " " + parsedTime);
|
|
106
|
+
const parsedDate = core.DateUtils.strToDate(strDateTime);
|
|
107
|
+
if (parsedDate || !strValue) {
|
|
108
|
+
if (this.value === parsedDate) {
|
|
109
|
+
this.changeValue(this.value);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.changeValue(parsedDate);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this._textInput.errorMessage = "O valor digitado não é uma data válida";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
getTextValue(d) {
|
|
120
|
+
const options = {
|
|
121
|
+
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
122
|
+
hour: 'numeric', minute: 'numeric'
|
|
123
|
+
};
|
|
124
|
+
const optionsSecond = {
|
|
125
|
+
year: 'numeric', month: 'numeric', day: 'numeric',
|
|
126
|
+
hour: 'numeric', minute: 'numeric', second: 'numeric'
|
|
127
|
+
};
|
|
128
|
+
return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : null;
|
|
129
|
+
}
|
|
130
|
+
componentDidLoad() {
|
|
131
|
+
CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
132
|
+
}
|
|
133
|
+
render() {
|
|
134
|
+
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, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, onFocus: () => this.onFocused(), onClick: () => this.onClicked() }, 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 })));
|
|
135
|
+
}
|
|
136
|
+
get _elem() { return index.getElement(this); }
|
|
137
|
+
static get watchers() { return {
|
|
138
|
+
"label": ["setLabel"],
|
|
139
|
+
"errorMessage": ["setErrorMessage"],
|
|
140
|
+
"value": ["applyValueToInput"]
|
|
141
|
+
}; }
|
|
142
|
+
};
|
|
143
|
+
EzDateTimeInput.style = ezDateTimeInputCss;
|
|
144
|
+
|
|
145
|
+
exports.ez_date_time_input = EzDateTimeInput;
|