@sankhyalabs/ezui 1.1.77 → 1.1.80

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 (174) hide show
  1. package/dist/cjs/{AssetsUtils-dd585fba.js → AssetsUtils-02db4f46.js} +1 -1
  2. package/dist/cjs/CSSVarsUtils-66e86394.js +18 -0
  3. package/dist/cjs/ez-action-chip.cjs.entry.js +1 -1
  4. package/dist/cjs/ez-application.cjs.entry.js +1 -3
  5. package/dist/cjs/ez-button_3.cjs.entry.js +520 -0
  6. package/dist/cjs/ez-calendar_13.cjs.entry.js +2421 -0
  7. package/dist/cjs/ez-date-time-input.cjs.entry.js +26 -37
  8. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  9. package/dist/cjs/{ez-button_11.cjs.entry.js → ez-grid.cjs.entry.js} +14 -1410
  10. package/dist/cjs/ez-icon.cjs.entry.js +30 -0
  11. package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
  12. package/dist/cjs/ez-modal_2.cjs.entry.js +370 -0
  13. package/dist/cjs/ez-popover.cjs.entry.js +2 -2
  14. package/dist/cjs/ez-popup.cjs.entry.js +1 -1
  15. package/dist/cjs/ez-time-input.cjs.entry.js +4 -4
  16. package/dist/cjs/ez-toast.cjs.entry.js +1 -1
  17. package/dist/cjs/ezui.cjs.js +2 -2
  18. package/dist/cjs/{index-4e4bae01.js → index-2003dec4.js} +0 -10
  19. package/dist/cjs/{index-262d703b.js → index-a2266984.js} +18 -43
  20. package/dist/cjs/loader.cjs.js +2 -2
  21. package/dist/collection/collection-manifest.json +0 -2
  22. package/dist/collection/components/ez-application/ez-application.js +0 -2
  23. package/dist/collection/components/ez-calendar/ez-calendar.js +7 -2
  24. package/dist/collection/components/ez-combo-box/ez-combo-box.css +0 -5
  25. package/dist/collection/components/ez-combo-box/ez-combo-box.js +4 -0
  26. package/dist/collection/components/ez-date-input/ez-date-input.css +2 -2
  27. package/dist/collection/components/ez-date-input/ez-date-input.js +1 -1
  28. package/dist/collection/components/ez-date-time-input/ez-date-time-input.css +0 -5
  29. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +23 -34
  30. package/dist/collection/components/ez-form/DataBinder.js +44 -0
  31. package/dist/collection/components/ez-form/ez-form.css +1 -15
  32. package/dist/collection/components/ez-form/ez-form.js +112 -427
  33. package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +45 -0
  34. package/dist/collection/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.js +11 -0
  35. package/dist/collection/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.js +14 -0
  36. package/dist/collection/components/ez-form/fieldbuilder/tpl/DateInput.tpl.js +5 -0
  37. package/dist/collection/components/ez-form/fieldbuilder/tpl/FileInput.tpl.js +5 -0
  38. package/dist/collection/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.js +13 -0
  39. package/dist/collection/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.js +5 -0
  40. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextArea.tpl.js +5 -0
  41. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextInput.tpl.js +5 -0
  42. package/dist/collection/components/ez-form/store/form.slice.js +38 -0
  43. package/dist/collection/components/ez-form/structure/FormItem.js +11 -0
  44. package/dist/collection/components/ez-form/structure/FormSheet.js +5 -0
  45. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +86 -0
  46. package/dist/collection/components/ez-number-input/ez-number-input.css +0 -9
  47. package/dist/collection/components/ez-number-input/ez-number-input.js +20 -115
  48. package/dist/collection/components/ez-search/ez-search.js +6 -1
  49. package/dist/collection/components/test-du/test-du.js +65 -23
  50. package/dist/collection/utils/CSSVarsUtils.js +6 -6
  51. package/dist/custom-elements/index.d.ts +0 -12
  52. package/dist/custom-elements/index.js +530 -2278
  53. package/dist/esm/{AssetsUtils-3803e935.js → AssetsUtils-76ca41e1.js} +1 -1
  54. package/dist/esm/CSSVarsUtils-aeee9825.js +16 -0
  55. package/dist/esm/ez-action-chip.entry.js +1 -1
  56. package/dist/esm/ez-application.entry.js +1 -3
  57. package/dist/esm/ez-button_3.entry.js +514 -0
  58. package/dist/esm/ez-calendar_13.entry.js +2405 -0
  59. package/dist/esm/ez-date-time-input.entry.js +26 -37
  60. package/dist/esm/ez-dialog.entry.js +1 -1
  61. package/dist/esm/{ez-button_11.entry.js → ez-grid.entry.js} +4 -1390
  62. package/dist/esm/ez-icon.entry.js +26 -0
  63. package/dist/esm/ez-label-chip.entry.js +1 -1
  64. package/dist/esm/ez-modal_2.entry.js +365 -0
  65. package/dist/esm/ez-popover.entry.js +2 -2
  66. package/dist/esm/ez-popup.entry.js +1 -1
  67. package/dist/esm/ez-time-input.entry.js +4 -4
  68. package/dist/esm/ez-toast.entry.js +1 -1
  69. package/dist/esm/ezui.js +2 -2
  70. package/dist/esm/{index-1dacecd3.js → index-077c7fcf.js} +0 -10
  71. package/dist/esm/{index-cfd5e193.js → index-afe19542.js} +17 -40
  72. package/dist/esm/loader.js +2 -2
  73. package/dist/ezui/ezui.esm.js +1 -1
  74. package/dist/ezui/p-00b837e2.js +1 -0
  75. package/dist/ezui/{p-516d0e0f.entry.js → p-0a2056d9.entry.js} +1 -1
  76. package/dist/ezui/p-0d8368fc.entry.js +1 -0
  77. package/dist/ezui/p-1e36e3ff.entry.js +1 -0
  78. package/dist/ezui/p-446ec85b.js +1 -0
  79. package/dist/ezui/p-49f3432a.entry.js +1 -0
  80. package/dist/ezui/{p-1ea8187e.entry.js → p-5509ee41.entry.js} +46 -46
  81. package/dist/ezui/{p-a18a2d7b.entry.js → p-57ea4b84.entry.js} +1 -1
  82. package/dist/ezui/{p-5a86e18a.entry.js → p-6d157776.entry.js} +1 -1
  83. package/dist/ezui/{p-8c51a6aa.entry.js → p-7a1f2e0e.entry.js} +1 -1
  84. package/dist/ezui/p-7de3c95d.js +1 -0
  85. package/dist/ezui/{p-7ef97c5f.entry.js → p-857ead8e.entry.js} +1 -1
  86. package/dist/ezui/p-8b099482.js +1 -0
  87. package/dist/ezui/{p-c6d469fc.entry.js → p-920bb8c9.entry.js} +1 -1
  88. package/dist/ezui/p-a4a39579.entry.js +1 -0
  89. package/dist/ezui/p-d5699f29.entry.js +1 -0
  90. package/dist/ezui/p-d64a3939.entry.js +1 -0
  91. package/dist/ezui/{p-5da66d3e.entry.js → p-da31cd21.entry.js} +1 -1
  92. package/dist/types/components/ez-application/ez-application.d.ts +0 -2
  93. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +1 -0
  94. package/dist/types/components/ez-form/DataBinder.d.ts +10 -0
  95. package/dist/types/components/ez-form/ez-form.d.ts +25 -32
  96. package/dist/types/components/ez-form/fieldbuilder/FieldBuilder.d.ts +2 -0
  97. package/dist/types/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.d.ts +3 -0
  98. package/dist/types/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.d.ts +4 -0
  99. package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +4 -0
  100. package/dist/types/components/ez-form/fieldbuilder/tpl/FileInput.tpl.d.ts +4 -0
  101. package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +8 -0
  102. package/dist/types/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.d.ts +4 -0
  103. package/dist/types/components/ez-form/fieldbuilder/tpl/TextArea.tpl.d.ts +4 -0
  104. package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +4 -0
  105. package/dist/types/components/ez-form/store/form.slice.d.ts +24 -0
  106. package/dist/types/components/ez-form/structure/FormItem.d.ts +9 -0
  107. package/dist/types/components/ez-form/structure/FormSheet.d.ts +9 -0
  108. package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +27 -0
  109. package/dist/types/components/ez-number-input/ez-number-input.d.ts +3 -20
  110. package/dist/types/components/ez-search/ez-search.d.ts +2 -0
  111. package/dist/types/components/test-du/test-du.d.ts +8 -2
  112. package/dist/types/components.d.ts +12 -82
  113. package/dist/types/utils/CSSVarsUtils.d.ts +1 -1
  114. package/package.json +1 -1
  115. package/react/components.d.ts +0 -2
  116. package/react/components.js +0 -2
  117. package/react/components.js.map +1 -1
  118. package/dist/cjs/ApplicationUtils-d1c1db56.js +0 -35
  119. package/dist/cjs/CSSVarsUtils-f8827674.js +0 -18
  120. package/dist/cjs/DataUnit-fdd7c70e.js +0 -474
  121. package/dist/cjs/ez-calendar.cjs.entry.js +0 -212
  122. package/dist/cjs/ez-collapsible-box_6.cjs.entry.js +0 -630
  123. package/dist/cjs/ez-combo-box.cjs.entry.js +0 -250
  124. package/dist/cjs/ez-form.cjs.entry.js +0 -1838
  125. package/dist/cjs/ez-number-input.cjs.entry.js +0 -121
  126. package/dist/cjs/form-metadata.cjs.entry.js +0 -129
  127. package/dist/collection/components/ez-form/assets/trash-can-outline.svg +0 -3
  128. package/dist/collection/components/ez-form/store/Form.actions.js +0 -132
  129. package/dist/collection/components/ez-form/store/Form.reducer.js +0 -194
  130. package/dist/collection/components/ez-form/store/Form.selectors.js +0 -44
  131. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +0 -301
  132. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +0 -8
  133. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +0 -24
  134. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +0 -227
  135. package/dist/collection/components/ez-form/subcomponents/place-holder.js +0 -14
  136. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +0 -95
  137. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +0 -27
  138. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +0 -41
  139. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +0 -37
  140. package/dist/esm/ApplicationUtils-01280a9d.js +0 -33
  141. package/dist/esm/CSSVarsUtils-e0128b01.js +0 -16
  142. package/dist/esm/DataUnit-1cd45202.js +0 -464
  143. package/dist/esm/ez-calendar.entry.js +0 -208
  144. package/dist/esm/ez-collapsible-box_6.entry.js +0 -621
  145. package/dist/esm/ez-combo-box.entry.js +0 -246
  146. package/dist/esm/ez-form.entry.js +0 -1834
  147. package/dist/esm/ez-number-input.entry.js +0 -117
  148. package/dist/esm/form-metadata.entry.js +0 -125
  149. package/dist/ezui/assets/trash-can-outline.svg +0 -3
  150. package/dist/ezui/p-37a611ea.js +0 -1
  151. package/dist/ezui/p-45689464.entry.js +0 -1
  152. package/dist/ezui/p-57291f97.entry.js +0 -1
  153. package/dist/ezui/p-69416bec.entry.js +0 -1
  154. package/dist/ezui/p-7107d7ef.js +0 -1
  155. package/dist/ezui/p-88f45a83.entry.js +0 -1
  156. package/dist/ezui/p-8f4851a6.js +0 -1
  157. package/dist/ezui/p-9dfd537e.js +0 -1
  158. package/dist/ezui/p-a223eed8.entry.js +0 -1
  159. package/dist/ezui/p-b36308e7.js +0 -1
  160. package/dist/ezui/p-c0af195b.entry.js +0 -1
  161. package/dist/ezui/p-d1889704.js +0 -1
  162. package/dist/ezui/p-e7ee2836.entry.js +0 -1
  163. package/dist/ezui/p-f7b835cf.entry.js +0 -1
  164. package/dist/types/components/ez-form/store/Form.actions.d.ts +0 -111
  165. package/dist/types/components/ez-form/store/Form.reducer.d.ts +0 -20
  166. package/dist/types/components/ez-form/store/Form.selectors.d.ts +0 -14
  167. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +0 -91
  168. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +0 -24
  169. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +0 -16
  170. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +0 -3
  171. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +0 -11
  172. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +0 -13
  173. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +0 -14
  174. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +0 -19
@@ -1,250 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-4e4bae01.js');
6
- require('./index-262d703b.js');
7
- const FloatingManager = require('./FloatingManager-6cfeb947.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)}ez-text-input{--ez-text-input__input--background-color:var(--ez-combo-box__input--background-color, #FFFFFF);--ez-text-input__input--border-color:var(--ez-combo-box__input--border-color, #DCE0E8)}.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
- internalUpdate() {
29
- if (this._inputElement) {
30
- this._inputElement.value = this.getText();
31
- }
32
- this.hideOptions();
33
- this._criteria = undefined;
34
- this._preSelection = undefined;
35
- this.updateVisibleOptions();
36
- }
37
- getText() {
38
- let text = "";
39
- const selected = this.getSelectedOption();
40
- if (selected) {
41
- text = this.showSelectedValue ? `${selected.value} - ${selected.label}` : selected.label;
42
- }
43
- return text;
44
- }
45
- getSelectedOption() {
46
- if (typeof this.value === "string" || this.value instanceof String) {
47
- return this._visibleOptions.find(o => o.value === this.value);
48
- }
49
- return this.value;
50
- }
51
- updateVisibleOptions() {
52
- let opts = this._source || [];
53
- if (!this.searchMode && this._criteria) {
54
- const upperCriteria = this._criteria.toUpperCase();
55
- opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(upperCriteria) > -1);
56
- }
57
- this._visibleOptions = [{ value: undefined, label: "" }].concat(opts);
58
- }
59
- buildItem(opt, index$1) {
60
- 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);
61
- }
62
- showOptions() {
63
- if (!this.enabled) {
64
- return;
65
- }
66
- //FIXME: Provavelmente isso fará com que o popup abra em uma
67
- //posição errada no futuro. Preferi fazer simples no começo,
68
- //porque não quis onerar o text input com essa funcionalidade...
69
- const top = this.errorMessage ? "0px" : "-17px";
70
- this._floatingID = FloatingManager.FloatingManager.float(this._optionsList, this._listContainer, { autoClose: true, top });
71
- window.requestAnimationFrame(() => {
72
- this._optionsList.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
73
- });
74
- }
75
- hideOptions() {
76
- if (this._floatingID !== undefined) {
77
- FloatingManager.FloatingManager.close(this._floatingID);
78
- }
79
- this._floatingID = undefined;
80
- }
81
- isOptionsVisible() {
82
- return this._floatingID !== undefined && FloatingManager.FloatingManager.isFloating(this._floatingID);
83
- }
84
- nextOption() {
85
- if (this.searchMode && !this.isOptionsVisible()) {
86
- return;
87
- }
88
- this.showOptions();
89
- this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
90
- this.scrollToOption(this._visibleOptions[this._preSelection], true);
91
- }
92
- previousOption() {
93
- this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
94
- this.scrollToOption(this._visibleOptions[this._preSelection], false);
95
- }
96
- scrollToOption(opt, down) {
97
- window.requestAnimationFrame(() => {
98
- const liElem = this._optionsList.querySelector(`li#item_${opt.value}`);
99
- if (liElem) {
100
- const parent = liElem.parentElement;
101
- const parentRect = parent.getBoundingClientRect();
102
- const itemRect = liElem.getBoundingClientRect();
103
- if (down && itemRect.bottom > parentRect.bottom) {
104
- parent.scrollTop = itemRect.top;
105
- }
106
- else if (!down && itemRect.top < parentRect.top) {
107
- parent.scrollTop = 0;
108
- }
109
- }
110
- });
111
- }
112
- selectCurrentOption() {
113
- if (this._preSelection !== undefined) {
114
- this.selectOption(this._visibleOptions[this._preSelection]);
115
- this._preSelection = undefined;
116
- }
117
- }
118
- selectOption(opt) {
119
- const currentOpt = this.getSelectedOption();
120
- if (currentOpt !== opt) {
121
- const adjustedOpt = !(opt === null || opt === void 0 ? void 0 : opt.value) ? undefined : opt;
122
- this.value = adjustedOpt;
123
- this.errorMessage = "";
124
- this.ezChange.emit(adjustedOpt);
125
- }
126
- else {
127
- this.internalUpdate();
128
- }
129
- }
130
- updateSource(source) {
131
- if (source instanceof Promise) {
132
- source.then(result => this.updateSource(result));
133
- this.updateVisibleOptions();
134
- }
135
- else {
136
- this._source = source;
137
- this.updateVisibleOptions();
138
- }
139
- }
140
- loadOptions(mode, argument = "") {
141
- this._criteria = argument;
142
- if (this.optionLoader) {
143
- this.updateSource(this.optionLoader({ mode, argument }));
144
- }
145
- else {
146
- this.updateSource(this.options);
147
- }
148
- }
149
- cancelPreselection() {
150
- if (!this._inputElement.value && this.value) {
151
- this.selectOption(undefined);
152
- }
153
- else {
154
- this.internalUpdate();
155
- }
156
- }
157
- //---------------------------------------------
158
- // Lifecycle web component
159
- //---------------------------------------------
160
- componentWillLoad() {
161
- if (this.options === undefined) {
162
- this.options = [];
163
- const optionsTags = this.el.querySelectorAll("option");
164
- if (optionsTags) {
165
- optionsTags.forEach(e => {
166
- let label = e.innerText;
167
- let value = e.getAttribute("value");
168
- if (!value) {
169
- value = label;
170
- }
171
- this.options.push({ label, value });
172
- e.hidden = true;
173
- });
174
- }
175
- }
176
- if (this.searchMode) {
177
- this.updateSource([]);
178
- }
179
- else {
180
- this.loadOptions("PRELOAD");
181
- }
182
- }
183
- componentDidRender() {
184
- if (this._floatingID === undefined) {
185
- this._optionsList.remove();
186
- }
187
- }
188
- //---------------------------------------------
189
- // Event handlers
190
- //---------------------------------------------
191
- onTextInputChangeHandler(event) {
192
- if (!this._criteria) {
193
- this._inputElement.value = event.data;
194
- }
195
- const argument = event.target.value;
196
- this._criteria = argument;
197
- if (this._criteria) {
198
- if (this.searchMode) {
199
- if (this._changeDeboucingTimeout) {
200
- window.clearTimeout(this._changeDeboucingTimeout);
201
- }
202
- this._changeDeboucingTimeout = window.setTimeout(() => {
203
- this.loadOptions("PREDICTIVE", argument);
204
- }, 200);
205
- }
206
- else {
207
- this.updateVisibleOptions();
208
- }
209
- this.showOptions();
210
- }
211
- }
212
- onTextInputClickHandler() {
213
- if (!this.searchMode) {
214
- this.showOptions();
215
- }
216
- }
217
- keyDownHandler(event) {
218
- switch (event.key) {
219
- case "ArrowDown":
220
- this.nextOption();
221
- break;
222
- case "ArrowUp":
223
- this.previousOption();
224
- break;
225
- case "Enter":
226
- this.selectCurrentOption();
227
- break;
228
- case "Escape":
229
- this.cancelPreselection();
230
- break;
231
- }
232
- event.stopPropagation();
233
- }
234
- onTextInputFocusOutHandler() {
235
- this.cancelPreselection();
236
- }
237
- render() {
238
- 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(), errorMessage: this.errorMessage }, this.searchMode ?
239
- index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { this.loadOptions("ADVANCED"); }, slot: "leftIcon" })
240
- :
241
- 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))))));
242
- }
243
- get el() { return index.getElement(this); }
244
- static get watchers() { return {
245
- "value": ["internalUpdate"]
246
- }; }
247
- };
248
- EzComboBox.style = ezComboBoxCss;
249
-
250
- exports.ez_combo_box = EzComboBox;