@sankhyalabs/ezui 1.1.6 → 1.1.10

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 (149) hide show
  1. package/README.md +72 -72
  2. package/dist/cjs/{DataUnit-09a6e7be.js → DataUnit-95368a67.js} +418 -361
  3. package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
  4. package/dist/cjs/ez-button_14.cjs.entry.js +1933 -1847
  5. package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
  6. package/dist/cjs/ez-modal.cjs.entry.js +102 -95
  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/ezui.cjs.js +1 -1
  10. package/dist/cjs/form-metadata.cjs.entry.js +65 -65
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
  13. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
  14. package/dist/collection/components/ez-button/ez-button.css +94 -94
  15. package/dist/collection/components/ez-button/ez-button.js +125 -125
  16. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
  17. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
  18. package/dist/collection/components/ez-check/ez-check.css +265 -265
  19. package/dist/collection/components/ez-check/ez-check.js +168 -168
  20. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
  21. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
  22. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
  23. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
  24. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
  25. package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
  26. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
  27. package/dist/collection/components/ez-form/ez-form.css +19 -19
  28. package/dist/collection/components/ez-form/ez-form.js +390 -289
  29. package/dist/collection/components/ez-form/store/Form.actions.js +132 -123
  30. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -174
  31. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -43
  32. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +252 -207
  33. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
  34. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
  35. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
  36. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
  37. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
  38. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
  39. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -33
  40. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -18
  41. package/dist/collection/components/ez-icon/ez-icon.css +36 -36
  42. package/dist/collection/components/ez-icon/ez-icon.js +56 -56
  43. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
  44. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
  45. package/dist/collection/components/ez-modal/ez-modal.css +86 -86
  46. package/dist/collection/components/ez-modal/ez-modal.js +222 -200
  47. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
  48. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
  49. package/dist/collection/components/ez-popover/ez-popover.css +38 -38
  50. package/dist/collection/components/ez-popover/ez-popover.js +323 -323
  51. package/dist/collection/components/ez-search/ez-search.css +295 -295
  52. package/dist/collection/components/ez-search/ez-search.js +527 -527
  53. package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
  54. package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
  55. package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
  56. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
  57. package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
  58. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
  59. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
  60. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
  61. package/dist/collection/index.js +1 -1
  62. package/dist/collection/servidor.js +100 -100
  63. package/dist/collection/utils/FloatingManager.js +15 -15
  64. package/dist/collection/utils/utils.js +6 -6
  65. package/dist/custom-elements/index.js +3146 -2998
  66. package/dist/esm/{DataUnit-7a983910.js → DataUnit-4bb6a396.js} +417 -362
  67. package/dist/esm/ez-action-chip.entry.js +41 -41
  68. package/dist/esm/ez-button_14.entry.js +1933 -1847
  69. package/dist/esm/ez-label-chip.entry.js +120 -120
  70. package/dist/esm/ez-modal.entry.js +103 -96
  71. package/dist/esm/ez-number-input.entry.js +236 -236
  72. package/dist/esm/ez-time-input.entry.js +168 -168
  73. package/dist/esm/ezui.js +1 -1
  74. package/dist/esm/form-metadata.entry.js +65 -65
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/polyfills/core-js.js +0 -0
  77. package/dist/esm/polyfills/dom.js +0 -0
  78. package/dist/esm/polyfills/es5-html-element.js +0 -0
  79. package/dist/esm/polyfills/index.js +0 -0
  80. package/dist/esm/polyfills/system.js +0 -0
  81. package/dist/ezui/ezui.esm.js +1 -1
  82. package/dist/ezui/p-11d20338.js +1 -0
  83. package/dist/ezui/{p-3c3a43aa.entry.js → p-5d30e51c.entry.js} +1 -1
  84. package/dist/ezui/p-77fdb4fd.entry.js +1 -0
  85. package/dist/ezui/p-e056fb23.entry.js +1 -0
  86. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  87. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  88. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  89. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  90. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  91. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  92. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  93. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  94. package/dist/types/components/ez-form/ez-form.d.ts +27 -27
  95. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -104
  96. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -11
  97. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -13
  98. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +61 -48
  99. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  100. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  101. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  102. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  103. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  104. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  105. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -7
  106. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  107. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  108. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -26
  109. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  110. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  111. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  112. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  113. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  114. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  115. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  116. package/dist/types/components.d.ts +8 -0
  117. package/dist/types/index.d.ts +1 -1
  118. package/dist/types/utils/utils.d.ts +2 -2
  119. package/package.json +114 -114
  120. package/react/components.d.ts +22 -0
  121. package/react/components.js +25 -0
  122. package/react/components.js.map +1 -0
  123. package/react/react-component-lib/createComponent.d.ts +10 -0
  124. package/react/react-component-lib/createComponent.js +59 -0
  125. package/react/react-component-lib/createComponent.js.map +1 -0
  126. package/react/react-component-lib/createOverlayComponent.d.ts +20 -0
  127. package/react/react-component-lib/createOverlayComponent.js +89 -0
  128. package/react/react-component-lib/createOverlayComponent.js.map +1 -0
  129. package/react/react-component-lib/index.d.ts +2 -0
  130. package/react/react-component-lib/index.js +3 -0
  131. package/react/react-component-lib/index.js.map +1 -0
  132. package/react/react-component-lib/interfaces.d.ts +29 -0
  133. package/react/react-component-lib/interfaces.js +1 -0
  134. package/react/react-component-lib/interfaces.js.map +1 -0
  135. package/react/react-component-lib/utils/attachProps.d.ts +12 -0
  136. package/react/react-component-lib/utils/attachProps.js +96 -0
  137. package/react/react-component-lib/utils/attachProps.js.map +1 -0
  138. package/react/react-component-lib/utils/case.d.ts +2 -0
  139. package/react/react-component-lib/utils/case.js +7 -0
  140. package/react/react-component-lib/utils/case.js.map +1 -0
  141. package/react/react-component-lib/utils/dev.d.ts +2 -0
  142. package/react/react-component-lib/utils/dev.js +13 -0
  143. package/react/react-component-lib/utils/dev.js.map +1 -0
  144. package/react/react-component-lib/utils/index.d.ts +7 -0
  145. package/react/react-component-lib/utils/index.js +21 -0
  146. package/react/react-component-lib/utils/index.js.map +1 -0
  147. package/dist/ezui/p-5185cbf1.entry.js +0 -1
  148. package/dist/ezui/p-5d600057.entry.js +0 -1
  149. package/dist/ezui/p-9f819174.js +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.\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
- }
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
+ }