@sankhyalabs/ezui 1.1.8 → 1.1.9

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.
Files changed (141) hide show
  1. package/README.md +72 -72
  2. package/dist/cjs/{DataUnit-28b290cb.js → DataUnit-9a4a35ca.js} +415 -371
  3. package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
  4. package/dist/cjs/ez-button_14.cjs.entry.js +1911 -1911
  5. package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
  6. package/dist/cjs/ez-modal.cjs.entry.js +104 -104
  7. package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
  8. package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
  9. package/dist/cjs/form-metadata.cjs.entry.js +65 -65
  10. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
  11. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
  12. package/dist/collection/components/ez-button/ez-button.css +94 -94
  13. package/dist/collection/components/ez-button/ez-button.js +125 -125
  14. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
  15. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
  16. package/dist/collection/components/ez-check/ez-check.css +265 -265
  17. package/dist/collection/components/ez-check/ez-check.js +168 -168
  18. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
  19. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
  20. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
  21. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
  23. package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
  24. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
  25. package/dist/collection/components/ez-form/ez-form.css +19 -19
  26. package/dist/collection/components/ez-form/ez-form.js +368 -368
  27. package/dist/collection/components/ez-form/store/Form.actions.js +132 -132
  28. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -194
  29. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -44
  30. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +251 -207
  31. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
  32. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
  33. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
  34. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
  35. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
  36. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
  37. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -40
  38. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -27
  39. package/dist/collection/components/ez-icon/ez-icon.css +36 -36
  40. package/dist/collection/components/ez-icon/ez-icon.js +56 -56
  41. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
  42. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
  43. package/dist/collection/components/ez-modal/ez-modal.css +86 -86
  44. package/dist/collection/components/ez-modal/ez-modal.js +224 -224
  45. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
  46. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
  47. package/dist/collection/components/ez-popover/ez-popover.css +38 -38
  48. package/dist/collection/components/ez-popover/ez-popover.js +323 -323
  49. package/dist/collection/components/ez-search/ez-search.css +295 -295
  50. package/dist/collection/components/ez-search/ez-search.js +527 -527
  51. package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
  52. package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
  53. package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
  54. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
  55. package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
  56. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
  57. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
  58. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
  59. package/dist/collection/index.js +1 -1
  60. package/dist/collection/servidor.js +100 -100
  61. package/dist/collection/utils/FloatingManager.js +15 -15
  62. package/dist/collection/utils/utils.js +6 -6
  63. package/dist/custom-elements/index.js +3125 -3081
  64. package/dist/esm/{DataUnit-69e518fa.js → DataUnit-d5d4c9a3.js} +415 -371
  65. package/dist/esm/ez-action-chip.entry.js +41 -41
  66. package/dist/esm/ez-button_14.entry.js +1911 -1911
  67. package/dist/esm/ez-label-chip.entry.js +120 -120
  68. package/dist/esm/ez-modal.entry.js +104 -104
  69. package/dist/esm/ez-number-input.entry.js +236 -236
  70. package/dist/esm/ez-time-input.entry.js +168 -168
  71. package/dist/esm/form-metadata.entry.js +65 -65
  72. package/dist/esm/polyfills/core-js.js +0 -0
  73. package/dist/esm/polyfills/dom.js +0 -0
  74. package/dist/esm/polyfills/es5-html-element.js +0 -0
  75. package/dist/esm/polyfills/index.js +0 -0
  76. package/dist/esm/polyfills/system.js +0 -0
  77. package/dist/ezui/ezui.esm.js +1 -1
  78. package/dist/ezui/{p-b0974f4f.entry.js → p-0fcdfb51.entry.js} +1 -1
  79. package/dist/ezui/p-dac7a6c2.js +1 -0
  80. package/dist/ezui/{p-db11c600.entry.js → p-dbef7060.entry.js} +1 -1
  81. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  82. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  83. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  84. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  85. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  86. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  87. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  88. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  89. package/dist/types/components/ez-form/ez-form.d.ts +26 -31
  90. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -111
  91. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -20
  92. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -14
  93. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +60 -55
  94. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  95. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  96. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  97. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  98. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  99. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  100. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -17
  101. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  102. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  103. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -32
  104. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  105. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  106. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  107. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  108. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  109. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  110. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  111. package/dist/types/index.d.ts +1 -1
  112. package/dist/types/utils/utils.d.ts +2 -2
  113. package/package.json +114 -114
  114. package/dist/ezui/p-10ef58b3.js +0 -1
  115. package/react/components.d.ts +0 -22
  116. package/react/components.js +0 -25
  117. package/react/components.js.map +0 -1
  118. package/react/react-component-lib/createComponent.d.ts +0 -10
  119. package/react/react-component-lib/createComponent.js +0 -59
  120. package/react/react-component-lib/createComponent.js.map +0 -1
  121. package/react/react-component-lib/createOverlayComponent.d.ts +0 -20
  122. package/react/react-component-lib/createOverlayComponent.js +0 -89
  123. package/react/react-component-lib/createOverlayComponent.js.map +0 -1
  124. package/react/react-component-lib/index.d.ts +0 -2
  125. package/react/react-component-lib/index.js +0 -3
  126. package/react/react-component-lib/index.js.map +0 -1
  127. package/react/react-component-lib/interfaces.d.ts +0 -29
  128. package/react/react-component-lib/interfaces.js +0 -1
  129. package/react/react-component-lib/interfaces.js.map +0 -1
  130. package/react/react-component-lib/utils/attachProps.d.ts +0 -12
  131. package/react/react-component-lib/utils/attachProps.js +0 -96
  132. package/react/react-component-lib/utils/attachProps.js.map +0 -1
  133. package/react/react-component-lib/utils/case.d.ts +0 -2
  134. package/react/react-component-lib/utils/case.js +0 -7
  135. package/react/react-component-lib/utils/case.js.map +0 -1
  136. package/react/react-component-lib/utils/dev.d.ts +0 -2
  137. package/react/react-component-lib/utils/dev.js +0 -13
  138. package/react/react-component-lib/utils/dev.js.map +0 -1
  139. package/react/react-component-lib/utils/index.d.ts +0 -7
  140. package/react/react-component-lib/utils/index.js +0 -21
  141. package/react/react-component-lib/utils/index.js.map +0 -1
@@ -1,363 +1,363 @@
1
- import { Component, h, Element, Host, Prop, Method, State, Event, Watch } from '@stencil/core';
2
- export class EzComboBox {
3
- constructor() {
4
- this._inputLabelValue = '';
5
- /**
6
- * Valor associado ao componente. Este é o valor que o componente recebe ao selecionar uma opção do combobox.
7
- * Pode ser Label ou Value de acordo com a opção "labelasindex"
8
- * Caso seja atribuído um valor ao componente que não esteja na relação das options, este vai lançar msg de erro
9
- * (executo pala valor undefined)
10
- */
11
- this.value = undefined;
12
- /**
13
- * Label é o título do campo
14
- */
15
- this.label = undefined;
16
- /**
17
- * Deixa o campo disponível ou não para digitação.
18
- */
19
- this.enabled = true;
20
- /**
21
- * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
22
- */
23
- this.showvalue = false;
24
- }
25
- //---------------------------------------------
26
- // Public methods
27
- //---------------------------------------------
28
- /**
29
- * Faz o foco no componente de textarea
30
- */
31
- async setFocus() {
32
- this._textInput.setFocus();
33
- }
34
- /**
35
- * Remove o foco no componente de textarea
36
- */
37
- async setBlur() {
38
- this._textInput.setBlur();
39
- }
40
- updateValue() {
41
- const selectedOption = this.options.filter(opt => opt.value === this.value);
42
- if (selectedOption && selectedOption.length > 0) {
43
- this._textInput.value = selectedOption[0].label;
44
- }
45
- else {
46
- this.value = null;
47
- this._textInput.value = '';
48
- }
49
- }
50
- setErrorMessage() {
51
- this._textInput.errormessage = this.errormessage;
52
- }
53
- showOptions() {
54
- if (this.enabled) {
55
- this._criteria = undefined;
56
- const top = this._textInput.errormessage ? '0px' : '-17px';
57
- this._popover.show(top);
58
- }
59
- }
60
- updateSelection() {
61
- const selectedOption = this.options.filter(opt => opt.label === this._textInput.value);
62
- this.selectOption((selectedOption && selectedOption.length > 0) ? selectedOption[0] : null);
63
- }
64
- selectOption(opt) {
65
- this._popover.hide();
66
- this.value = opt ? opt.value : null;
67
- this.ezChange.emit();
68
- }
69
- buildItem(opt, index) {
70
- const className = index === this._preSelection ? "--li--preselected" : "";
71
- return h("li", { class: className, key: opt.value, id: 'item_' + opt.value, onMouseDown: () => this.selectOption(opt) },
72
- this.highlightMatch(opt.label),
73
- this.showvalue ? h("span", { class: '--li__spanvalue' }, opt.value) : null);
74
- }
75
- highlightMatch(label) {
76
- const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
77
- if (this._criteria) {
78
- const criteriaLength = this._criteria.length;
79
- const matchStart = label.toUpperCase().indexOf(this._criteria);
80
- if (matchStart > -1) {
81
- const strLabelStart = label.substr(0, matchStart);
82
- const strLabelEnd = label.substr(matchStart + criteriaLength);
83
- const strMatch = label.substr(matchStart, criteriaLength);
84
- return (h("span", { class: spanClassName },
85
- strLabelStart,
86
- h("strong", null, strMatch),
87
- strLabelEnd));
88
- }
89
- }
90
- return (h("span", { class: spanClassName }, label));
91
- }
92
- matchOptions() {
93
- this.showOptions();
94
- this._criteria = this._textInput.value.toLocaleUpperCase();
95
- this.filterOptions();
96
- }
97
- filterOptions() {
98
- this._preSelection = undefined;
99
- let opts = (this.options || []);
100
- if (this._criteria) {
101
- opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(this._criteria) > -1);
102
- }
103
- this._visibleOptions = [{ value: '', label: '' }].concat(opts);
104
- }
105
- nextOption() {
106
- this.showOptions();
107
- this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
108
- this.scrollToOption(this._visibleOptions[this._preSelection]);
109
- }
110
- previousOption() {
111
- this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
112
- this.scrollToOption(this._visibleOptions[this._preSelection]);
113
- }
114
- scrollToOption(opt) {
115
- const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
116
- if (liElem) {
117
- const parent = liElem.parentElement;
118
- const parentRect = parent.getBoundingClientRect();
119
- const itemRect = liElem.getBoundingClientRect();
120
- if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
121
- liElem.scrollIntoView();
122
- }
123
- }
124
- }
125
- selectCurrentOption() {
126
- if (this._preSelection !== undefined) {
127
- this.selectOption(this._visibleOptions[this._preSelection]);
128
- this._preSelection = undefined;
129
- }
130
- }
131
- keyDownHandler(event) {
132
- switch (event.key) {
133
- case "ArrowDown":
134
- this.nextOption();
135
- break;
136
- case "ArrowUp":
137
- this.previousOption();
138
- break;
139
- case "Enter":
140
- this.selectCurrentOption();
141
- break;
142
- }
143
- event.stopPropagation();
144
- }
145
- //---------------------------------------------
146
- // Lifecycle web component
147
- //---------------------------------------------
148
- componentWillLoad() {
149
- if (this.options === undefined) {
150
- this.options = [];
151
- const optionsTags = this.el.querySelectorAll('option');
152
- if (optionsTags) {
153
- optionsTags.forEach(e => {
154
- let label = e.innerText;
155
- let value = e.getAttribute('value');
156
- if (!value) {
157
- value = label;
158
- }
159
- this.options.push({ label, value });
160
- e.hidden = true;
161
- });
162
- }
163
- }
164
- this.filterOptions();
165
- }
166
- componentDidLoad() {
167
- this.updateValue();
168
- }
169
- render() {
170
- return (h(Host, null,
171
- h("ez-text-input", { ref: (el) => this._textInput = el, value: this._inputLabelValue, enabled: this.enabled, onInput: () => this.matchOptions(), onClick: () => this.showOptions(), onFocusout: () => this.updateSelection(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, errormessage: this.errormessage },
172
- h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })),
173
- h("ez-popover", { boxwidth: "100%", ref: el => this._popover = el, autoclose: true },
174
- h("div", { class: "list-container" }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
175
- }
176
- ;
177
- static get is() { return "ez-combo-box"; }
178
- static get encapsulation() { return "shadow"; }
179
- static get originalStyleUrls() { return {
180
- "$": ["ez-combo-box.css"]
181
- }; }
182
- static get styleUrls() { return {
183
- "$": ["ez-combo-box.css"]
184
- }; }
185
- static get properties() { return {
186
- "value": {
187
- "type": "string",
188
- "mutable": true,
189
- "complexType": {
190
- "original": "string",
191
- "resolved": "string",
192
- "references": {}
193
- },
194
- "required": false,
195
- "optional": false,
196
- "docs": {
197
- "tags": [],
198
- "text": "Valor associado ao componente. Este \u00E9 o valor que o componente recebe ao selecionar uma op\u00E7\u00E3o do combobox.\nPode ser Label ou Value de acordo com a op\u00E7\u00E3o \"labelasindex\"\nCaso seja atribu\u00EDdo um valor ao componente que n\u00E3o esteja na rela\u00E7\u00E3o das options, este vai lan\u00E7ar msg de erro\n(executo pala valor undefined)"
199
- },
200
- "attribute": "value",
201
- "reflect": true,
202
- "defaultValue": "undefined"
203
- },
204
- "label": {
205
- "type": "string",
206
- "mutable": false,
207
- "complexType": {
208
- "original": "string",
209
- "resolved": "string",
210
- "references": {}
211
- },
212
- "required": false,
213
- "optional": false,
214
- "docs": {
215
- "tags": [],
216
- "text": "Label \u00E9 o t\u00EDtulo do campo"
217
- },
218
- "attribute": "label",
219
- "reflect": true,
220
- "defaultValue": "undefined"
221
- },
222
- "enabled": {
223
- "type": "boolean",
224
- "mutable": false,
225
- "complexType": {
226
- "original": "boolean",
227
- "resolved": "boolean",
228
- "references": {}
229
- },
230
- "required": false,
231
- "optional": false,
232
- "docs": {
233
- "tags": [],
234
- "text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para digita\u00E7\u00E3o."
235
- },
236
- "attribute": "enabled",
237
- "reflect": true,
238
- "defaultValue": "true"
239
- },
240
- "showvalue": {
241
- "type": "boolean",
242
- "mutable": false,
243
- "complexType": {
244
- "original": "boolean",
245
- "resolved": "boolean",
246
- "references": {}
247
- },
248
- "required": false,
249
- "optional": false,
250
- "docs": {
251
- "tags": [],
252
- "text": "Ajusta a op\u00E7\u00E3o de mostrar o \"value\" para cada \"label\". Como default \"value\" n\u00E3o est\u00E1 presente (showvalue = false)"
253
- },
254
- "attribute": "showvalue",
255
- "reflect": true,
256
- "defaultValue": "false"
257
- },
258
- "options": {
259
- "type": "unknown",
260
- "mutable": true,
261
- "complexType": {
262
- "original": "Array<OptionsCombobox>",
263
- "resolved": "OptionsCombobox[]",
264
- "references": {
265
- "Array": {
266
- "location": "global"
267
- },
268
- "OptionsCombobox": {
269
- "location": "import",
270
- "path": "./ez-combo-box-interfaces"
271
- }
272
- }
273
- },
274
- "required": false,
275
- "optional": false,
276
- "docs": {
277
- "tags": [],
278
- "text": "/**\n Array no formato \"{value: string, label: string} que alimenta as op\u00E7\u00F5es do Combobox\""
279
- }
280
- },
281
- "errormessage": {
282
- "type": "string",
283
- "mutable": true,
284
- "complexType": {
285
- "original": "string",
286
- "resolved": "string",
287
- "references": {}
288
- },
289
- "required": false,
290
- "optional": false,
291
- "docs": {
292
- "tags": [],
293
- "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
294
- },
295
- "attribute": "errormessage",
296
- "reflect": true
297
- }
298
- }; }
299
- static get states() { return {
300
- "_inputLabelValue": {},
301
- "_criteria": {},
302
- "_preSelection": {},
303
- "_visibleOptions": {}
304
- }; }
305
- static get events() { return [{
306
- "method": "ezChange",
307
- "name": "ezChange",
308
- "bubbles": true,
309
- "cancelable": true,
310
- "composed": true,
311
- "docs": {
312
- "tags": [],
313
- "text": "Evento que \u00E9 disparado ao alterar o value do componente"
314
- },
315
- "complexType": {
316
- "original": "string",
317
- "resolved": "string",
318
- "references": {}
319
- }
320
- }]; }
321
- static get methods() { return {
322
- "setFocus": {
323
- "complexType": {
324
- "signature": "() => Promise<void>",
325
- "parameters": [],
326
- "references": {
327
- "Promise": {
328
- "location": "global"
329
- }
330
- },
331
- "return": "Promise<void>"
332
- },
333
- "docs": {
334
- "text": "Faz o foco no componente de textarea",
335
- "tags": []
336
- }
337
- },
338
- "setBlur": {
339
- "complexType": {
340
- "signature": "() => Promise<void>",
341
- "parameters": [],
342
- "references": {
343
- "Promise": {
344
- "location": "global"
345
- }
346
- },
347
- "return": "Promise<void>"
348
- },
349
- "docs": {
350
- "text": "Remove o foco no componente de textarea",
351
- "tags": []
352
- }
353
- }
354
- }; }
355
- static get elementRef() { return "el"; }
356
- static get watchers() { return [{
357
- "propName": "value",
358
- "methodName": "updateValue"
359
- }, {
360
- "propName": "errormessage",
361
- "methodName": "setErrorMessage"
362
- }]; }
363
- }
1
+ import { Component, h, Element, Host, Prop, Method, State, Event, Watch } from '@stencil/core';
2
+ export class EzComboBox {
3
+ constructor() {
4
+ this._inputLabelValue = '';
5
+ /**
6
+ * Valor associado ao componente. Este é o valor que o componente recebe ao selecionar uma opção do combobox.
7
+ * Pode ser Label ou Value de acordo com a opção "labelasindex"
8
+ * Caso seja atribuído um valor ao componente que não esteja na relação das options, este vai lançar msg de erro
9
+ * (executo pala valor undefined)
10
+ */
11
+ this.value = undefined;
12
+ /**
13
+ * Label é o título do campo
14
+ */
15
+ this.label = undefined;
16
+ /**
17
+ * Deixa o campo disponível ou não para digitação.
18
+ */
19
+ this.enabled = true;
20
+ /**
21
+ * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
22
+ */
23
+ this.showvalue = false;
24
+ }
25
+ //---------------------------------------------
26
+ // Public methods
27
+ //---------------------------------------------
28
+ /**
29
+ * Faz o foco no componente de textarea
30
+ */
31
+ async setFocus() {
32
+ this._textInput.setFocus();
33
+ }
34
+ /**
35
+ * Remove o foco no componente de textarea
36
+ */
37
+ async setBlur() {
38
+ this._textInput.setBlur();
39
+ }
40
+ updateValue() {
41
+ const selectedOption = this.options.filter(opt => opt.value === this.value);
42
+ if (selectedOption && selectedOption.length > 0) {
43
+ this._textInput.value = selectedOption[0].label;
44
+ }
45
+ else {
46
+ this.value = null;
47
+ this._textInput.value = '';
48
+ }
49
+ }
50
+ setErrorMessage() {
51
+ this._textInput.errormessage = this.errormessage;
52
+ }
53
+ showOptions() {
54
+ if (this.enabled) {
55
+ this._criteria = undefined;
56
+ const top = this._textInput.errormessage ? '0px' : '-17px';
57
+ this._popover.show(top);
58
+ }
59
+ }
60
+ updateSelection() {
61
+ const selectedOption = this.options.filter(opt => opt.label === this._textInput.value);
62
+ this.selectOption((selectedOption && selectedOption.length > 0) ? selectedOption[0] : null);
63
+ }
64
+ selectOption(opt) {
65
+ this._popover.hide();
66
+ this.value = opt ? opt.value : null;
67
+ this.ezChange.emit();
68
+ }
69
+ buildItem(opt, index) {
70
+ const className = index === this._preSelection ? "--li--preselected" : "";
71
+ return h("li", { class: className, key: opt.value, id: 'item_' + opt.value, onMouseDown: () => this.selectOption(opt) },
72
+ this.highlightMatch(opt.label),
73
+ this.showvalue ? h("span", { class: '--li__spanvalue' }, opt.value) : null);
74
+ }
75
+ highlightMatch(label) {
76
+ const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
77
+ if (this._criteria) {
78
+ const criteriaLength = this._criteria.length;
79
+ const matchStart = label.toUpperCase().indexOf(this._criteria);
80
+ if (matchStart > -1) {
81
+ const strLabelStart = label.substr(0, matchStart);
82
+ const strLabelEnd = label.substr(matchStart + criteriaLength);
83
+ const strMatch = label.substr(matchStart, criteriaLength);
84
+ return (h("span", { class: spanClassName },
85
+ strLabelStart,
86
+ h("strong", null, strMatch),
87
+ strLabelEnd));
88
+ }
89
+ }
90
+ return (h("span", { class: spanClassName }, label));
91
+ }
92
+ matchOptions() {
93
+ this.showOptions();
94
+ this._criteria = this._textInput.value.toLocaleUpperCase();
95
+ this.filterOptions();
96
+ }
97
+ filterOptions() {
98
+ this._preSelection = undefined;
99
+ let opts = (this.options || []);
100
+ if (this._criteria) {
101
+ opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(this._criteria) > -1);
102
+ }
103
+ this._visibleOptions = [{ value: '', label: '' }].concat(opts);
104
+ }
105
+ nextOption() {
106
+ this.showOptions();
107
+ this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
108
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
109
+ }
110
+ previousOption() {
111
+ this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
112
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
113
+ }
114
+ scrollToOption(opt) {
115
+ const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
116
+ if (liElem) {
117
+ const parent = liElem.parentElement;
118
+ const parentRect = parent.getBoundingClientRect();
119
+ const itemRect = liElem.getBoundingClientRect();
120
+ if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
121
+ liElem.scrollIntoView();
122
+ }
123
+ }
124
+ }
125
+ selectCurrentOption() {
126
+ if (this._preSelection !== undefined) {
127
+ this.selectOption(this._visibleOptions[this._preSelection]);
128
+ this._preSelection = undefined;
129
+ }
130
+ }
131
+ keyDownHandler(event) {
132
+ switch (event.key) {
133
+ case "ArrowDown":
134
+ this.nextOption();
135
+ break;
136
+ case "ArrowUp":
137
+ this.previousOption();
138
+ break;
139
+ case "Enter":
140
+ this.selectCurrentOption();
141
+ break;
142
+ }
143
+ event.stopPropagation();
144
+ }
145
+ //---------------------------------------------
146
+ // Lifecycle web component
147
+ //---------------------------------------------
148
+ componentWillLoad() {
149
+ if (this.options === undefined) {
150
+ this.options = [];
151
+ const optionsTags = this.el.querySelectorAll('option');
152
+ if (optionsTags) {
153
+ optionsTags.forEach(e => {
154
+ let label = e.innerText;
155
+ let value = e.getAttribute('value');
156
+ if (!value) {
157
+ value = label;
158
+ }
159
+ this.options.push({ label, value });
160
+ e.hidden = true;
161
+ });
162
+ }
163
+ }
164
+ this.filterOptions();
165
+ }
166
+ componentDidLoad() {
167
+ this.updateValue();
168
+ }
169
+ render() {
170
+ return (h(Host, null,
171
+ h("ez-text-input", { ref: (el) => this._textInput = el, value: this._inputLabelValue, enabled: this.enabled, onInput: () => this.matchOptions(), onClick: () => this.showOptions(), onFocusout: () => this.updateSelection(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, errormessage: this.errormessage },
172
+ h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })),
173
+ h("ez-popover", { boxwidth: "100%", ref: el => this._popover = el, autoclose: true },
174
+ h("div", { class: "list-container" }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
175
+ }
176
+ ;
177
+ static get is() { return "ez-combo-box"; }
178
+ static get encapsulation() { return "shadow"; }
179
+ static get originalStyleUrls() { return {
180
+ "$": ["ez-combo-box.css"]
181
+ }; }
182
+ static get styleUrls() { return {
183
+ "$": ["ez-combo-box.css"]
184
+ }; }
185
+ static get properties() { return {
186
+ "value": {
187
+ "type": "string",
188
+ "mutable": true,
189
+ "complexType": {
190
+ "original": "string",
191
+ "resolved": "string",
192
+ "references": {}
193
+ },
194
+ "required": false,
195
+ "optional": false,
196
+ "docs": {
197
+ "tags": [],
198
+ "text": "Valor associado ao componente. Este \u00E9 o valor que o componente recebe ao selecionar uma op\u00E7\u00E3o do combobox.\r\nPode ser Label ou Value de acordo com a op\u00E7\u00E3o \"labelasindex\"\r\nCaso seja atribu\u00EDdo um valor ao componente que n\u00E3o esteja na rela\u00E7\u00E3o das options, este vai lan\u00E7ar msg de erro\r\n(executo pala valor undefined)"
199
+ },
200
+ "attribute": "value",
201
+ "reflect": true,
202
+ "defaultValue": "undefined"
203
+ },
204
+ "label": {
205
+ "type": "string",
206
+ "mutable": false,
207
+ "complexType": {
208
+ "original": "string",
209
+ "resolved": "string",
210
+ "references": {}
211
+ },
212
+ "required": false,
213
+ "optional": false,
214
+ "docs": {
215
+ "tags": [],
216
+ "text": "Label \u00E9 o t\u00EDtulo do campo"
217
+ },
218
+ "attribute": "label",
219
+ "reflect": true,
220
+ "defaultValue": "undefined"
221
+ },
222
+ "enabled": {
223
+ "type": "boolean",
224
+ "mutable": false,
225
+ "complexType": {
226
+ "original": "boolean",
227
+ "resolved": "boolean",
228
+ "references": {}
229
+ },
230
+ "required": false,
231
+ "optional": false,
232
+ "docs": {
233
+ "tags": [],
234
+ "text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para digita\u00E7\u00E3o."
235
+ },
236
+ "attribute": "enabled",
237
+ "reflect": true,
238
+ "defaultValue": "true"
239
+ },
240
+ "showvalue": {
241
+ "type": "boolean",
242
+ "mutable": false,
243
+ "complexType": {
244
+ "original": "boolean",
245
+ "resolved": "boolean",
246
+ "references": {}
247
+ },
248
+ "required": false,
249
+ "optional": false,
250
+ "docs": {
251
+ "tags": [],
252
+ "text": "Ajusta a op\u00E7\u00E3o de mostrar o \"value\" para cada \"label\". Como default \"value\" n\u00E3o est\u00E1 presente (showvalue = false)"
253
+ },
254
+ "attribute": "showvalue",
255
+ "reflect": true,
256
+ "defaultValue": "false"
257
+ },
258
+ "options": {
259
+ "type": "unknown",
260
+ "mutable": true,
261
+ "complexType": {
262
+ "original": "Array<OptionsCombobox>",
263
+ "resolved": "OptionsCombobox[]",
264
+ "references": {
265
+ "Array": {
266
+ "location": "global"
267
+ },
268
+ "OptionsCombobox": {
269
+ "location": "import",
270
+ "path": "./ez-combo-box-interfaces"
271
+ }
272
+ }
273
+ },
274
+ "required": false,
275
+ "optional": false,
276
+ "docs": {
277
+ "tags": [],
278
+ "text": "/**\r\n Array no formato \"{value: string, label: string} que alimenta as op\u00E7\u00F5es do Combobox\""
279
+ }
280
+ },
281
+ "errormessage": {
282
+ "type": "string",
283
+ "mutable": true,
284
+ "complexType": {
285
+ "original": "string",
286
+ "resolved": "string",
287
+ "references": {}
288
+ },
289
+ "required": false,
290
+ "optional": false,
291
+ "docs": {
292
+ "tags": [],
293
+ "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
294
+ },
295
+ "attribute": "errormessage",
296
+ "reflect": true
297
+ }
298
+ }; }
299
+ static get states() { return {
300
+ "_inputLabelValue": {},
301
+ "_criteria": {},
302
+ "_preSelection": {},
303
+ "_visibleOptions": {}
304
+ }; }
305
+ static get events() { return [{
306
+ "method": "ezChange",
307
+ "name": "ezChange",
308
+ "bubbles": true,
309
+ "cancelable": true,
310
+ "composed": true,
311
+ "docs": {
312
+ "tags": [],
313
+ "text": "Evento que \u00E9 disparado ao alterar o value do componente"
314
+ },
315
+ "complexType": {
316
+ "original": "string",
317
+ "resolved": "string",
318
+ "references": {}
319
+ }
320
+ }]; }
321
+ static get methods() { return {
322
+ "setFocus": {
323
+ "complexType": {
324
+ "signature": "() => Promise<void>",
325
+ "parameters": [],
326
+ "references": {
327
+ "Promise": {
328
+ "location": "global"
329
+ }
330
+ },
331
+ "return": "Promise<void>"
332
+ },
333
+ "docs": {
334
+ "text": "Faz o foco no componente de textarea",
335
+ "tags": []
336
+ }
337
+ },
338
+ "setBlur": {
339
+ "complexType": {
340
+ "signature": "() => Promise<void>",
341
+ "parameters": [],
342
+ "references": {
343
+ "Promise": {
344
+ "location": "global"
345
+ }
346
+ },
347
+ "return": "Promise<void>"
348
+ },
349
+ "docs": {
350
+ "text": "Remove o foco no componente de textarea",
351
+ "tags": []
352
+ }
353
+ }
354
+ }; }
355
+ static get elementRef() { return "el"; }
356
+ static get watchers() { return [{
357
+ "propName": "value",
358
+ "methodName": "updateValue"
359
+ }, {
360
+ "propName": "errormessage",
361
+ "methodName": "setErrorMessage"
362
+ }]; }
363
+ }