@sankhyalabs/ezui 5.10.8 → 5.11.0-dev.2

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 (137) hide show
  1. package/README.md +0 -1
  2. package/dist/cjs/{CSSVarsUtils-af809e73.js → CSSVarsUtils-b136a156.js} +5 -0
  3. package/dist/cjs/RecordValidationProcessor-edd23705.js +102 -0
  4. package/dist/cjs/ez-actions-button.cjs.entry.js +1 -1
  5. package/dist/cjs/ez-calendar.cjs.entry.js +34 -5
  6. package/dist/cjs/ez-combo-box.cjs.entry.js +89 -14
  7. package/dist/cjs/ez-date-input.cjs.entry.js +53 -22
  8. package/dist/cjs/ez-date-time-input.cjs.entry.js +53 -19
  9. package/dist/cjs/ez-filter-input_2.cjs.entry.js +1 -1
  10. package/dist/cjs/ez-form.cjs.entry.js +9 -83
  11. package/dist/cjs/ez-grid.cjs.entry.js +488 -6
  12. package/dist/cjs/ez-number-input.cjs.entry.js +39 -15
  13. package/dist/cjs/ez-search.cjs.entry.js +11 -2
  14. package/dist/cjs/ez-text-area.cjs.entry.js +6 -2
  15. package/dist/cjs/ez-text-input.cjs.entry.js +7 -4
  16. package/dist/cjs/ez-time-input.cjs.entry.js +11 -7
  17. package/dist/cjs/ezui.cjs.js +1 -1
  18. package/dist/cjs/loader.cjs.js +1 -1
  19. package/dist/collection/collection-manifest.json +2 -2
  20. package/dist/collection/components/ez-calendar/ez-calendar.js +63 -6
  21. package/dist/collection/components/ez-combo-box/ez-combo-box.css +6 -0
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +122 -12
  23. package/dist/collection/components/ez-date-input/ez-date-input.js +71 -21
  24. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +71 -18
  25. package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +40 -7
  26. package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +1 -0
  27. package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +230 -0
  28. package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +49 -0
  29. package/dist/collection/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.js +10 -0
  30. package/dist/collection/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.js +4 -0
  31. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +38 -0
  32. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +40 -0
  33. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +20 -0
  34. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +15 -0
  35. package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +41 -0
  36. package/dist/collection/components/ez-grid/ez-grid.js +67 -0
  37. package/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
  38. package/dist/collection/components/ez-number-input/ez-number-input.js +62 -15
  39. package/dist/collection/components/ez-search/ez-search.css +1 -1
  40. package/dist/collection/components/ez-search/ez-search.js +46 -1
  41. package/dist/collection/components/ez-text-area/ez-text-area.css +4 -0
  42. package/dist/collection/components/ez-text-area/ez-text-area.js +23 -1
  43. package/dist/collection/components/ez-text-input/ez-text-input.css +8 -1
  44. package/dist/collection/components/ez-text-input/ez-text-input.js +14 -5
  45. package/dist/collection/components/ez-time-input/ez-time-input.css +4 -0
  46. package/dist/collection/components/ez-time-input/ez-time-input.js +18 -7
  47. package/dist/collection/utils/CSSVarsUtils.js +5 -0
  48. package/dist/collection/utils/form/DataBinder.js +7 -62
  49. package/dist/collection/utils/form/FormMetadata.js +3 -22
  50. package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +21 -0
  51. package/dist/collection/utils/validators/recordvalidator/IValidationResult.js +1 -0
  52. package/dist/collection/utils/validators/recordvalidator/IValidationSource.js +1 -0
  53. package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +74 -0
  54. package/dist/custom-elements/index.js +922 -203
  55. package/dist/esm/{CSSVarsUtils-00f67f32.js → CSSVarsUtils-a97cfa29.js} +5 -0
  56. package/dist/esm/RecordValidationProcessor-abc814af.js +99 -0
  57. package/dist/esm/ez-actions-button.entry.js +1 -1
  58. package/dist/esm/ez-calendar.entry.js +35 -6
  59. package/dist/esm/ez-combo-box.entry.js +89 -14
  60. package/dist/esm/ez-date-input.entry.js +53 -22
  61. package/dist/esm/ez-date-time-input.entry.js +53 -19
  62. package/dist/esm/ez-filter-input_2.entry.js +1 -1
  63. package/dist/esm/ez-form.entry.js +10 -84
  64. package/dist/esm/ez-grid.entry.js +489 -7
  65. package/dist/esm/ez-number-input.entry.js +39 -15
  66. package/dist/esm/ez-search.entry.js +11 -2
  67. package/dist/esm/ez-text-area.entry.js +6 -2
  68. package/dist/esm/ez-text-input.entry.js +7 -4
  69. package/dist/esm/ez-time-input.entry.js +11 -7
  70. package/dist/esm/ezui.js +1 -1
  71. package/dist/esm/loader.js +1 -1
  72. package/dist/ezui/ezui.esm.js +1 -1
  73. package/dist/ezui/p-028f264f.entry.js +1 -0
  74. package/dist/ezui/p-391de0e4.entry.js +1 -0
  75. package/dist/ezui/p-4535da17.entry.js +1 -0
  76. package/dist/ezui/p-5cef0264.entry.js +1 -0
  77. package/dist/ezui/p-7eb3e1a5.js +1 -0
  78. package/dist/ezui/p-86a2036d.js +1 -0
  79. package/dist/ezui/{p-12303d2e.entry.js → p-87e85160.entry.js} +1 -1
  80. package/dist/ezui/p-90fa4cb3.entry.js +1 -0
  81. package/dist/ezui/p-9f41b414.entry.js +1 -0
  82. package/dist/ezui/p-ce035beb.entry.js +1 -0
  83. package/dist/ezui/p-d43b22f3.entry.js +1 -0
  84. package/dist/ezui/p-e2dfd935.entry.js +1 -0
  85. package/dist/ezui/p-e67d0bd5.entry.js +1 -0
  86. package/dist/ezui/{p-c7a23be9.entry.js → p-fd54b5b4.entry.js} +2 -2
  87. package/dist/ezui/{p-f1a537e3.entry.js → p-ff82b176.entry.js} +1 -1
  88. package/dist/types/components/ez-calendar/ez-calendar.d.ts +9 -1
  89. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +14 -0
  90. package/dist/types/components/ez-date-input/ez-date-input.d.ts +4 -0
  91. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +4 -0
  92. package/dist/types/components/ez-form-view/interfaces/IFormViewField.d.ts +2 -14
  93. package/dist/types/components/ez-grid/controller/EzGridController.d.ts +18 -0
  94. package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
  95. package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +38 -0
  96. package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +10 -0
  97. package/dist/types/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.d.ts +1 -0
  98. package/dist/types/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.d.ts +9 -0
  99. package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +10 -0
  100. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.d.ts +4 -0
  101. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.d.ts +5 -0
  102. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.d.ts +4 -0
  103. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.d.ts +3 -0
  104. package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.d.ts +4 -0
  105. package/dist/types/components/ez-grid/ez-grid.d.ts +13 -0
  106. package/dist/types/components/ez-number-input/ez-number-input.d.ts +5 -1
  107. package/dist/types/components/ez-search/ez-search.d.ts +6 -1
  108. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
  109. package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -1
  110. package/dist/types/components/ez-time-input/ez-time-input.d.ts +2 -1
  111. package/dist/types/components.d.ts +65 -6
  112. package/dist/types/utils/form/DataBinder.d.ts +1 -3
  113. package/dist/types/utils/form/interfaces/IFormConfig.d.ts +1 -1
  114. package/dist/types/utils/form/interfaces/index.d.ts +4 -4
  115. package/dist/types/utils/interfaces/AbstractFieldMetadata.d.ts +17 -0
  116. package/dist/types/utils/{form/interfaces → interfaces}/IFieldConfig.d.ts +2 -2
  117. package/dist/types/utils/validators/recordvalidator/IValidationSource.d.ts +6 -0
  118. package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +13 -0
  119. package/package.json +2 -2
  120. package/dist/ezui/p-00c7c25d.entry.js +0 -1
  121. package/dist/ezui/p-0b160fec.entry.js +0 -1
  122. package/dist/ezui/p-0bd54a6f.entry.js +0 -1
  123. package/dist/ezui/p-39153935.entry.js +0 -1
  124. package/dist/ezui/p-4a5e37a7.js +0 -1
  125. package/dist/ezui/p-5782443e.entry.js +0 -1
  126. package/dist/ezui/p-5d45e384.entry.js +0 -1
  127. package/dist/ezui/p-70ea4beb.entry.js +0 -1
  128. package/dist/ezui/p-78a6e049.entry.js +0 -1
  129. package/dist/ezui/p-8bcb197f.entry.js +0 -1
  130. package/dist/ezui/p-a4c9f3c4.entry.js +0 -1
  131. /package/dist/collection/{utils/form/interfaces/IFieldConfig.js → components/ez-grid/controller/ag-grid/editor/IUICellEditor.js} +0 -0
  132. /package/dist/collection/utils/{form/interfaces/IInvalidField.js → interfaces/IFieldConfig.js} +0 -0
  133. /package/dist/collection/utils/{form/interfaces/IRecordValidator.js → validators/recordvalidator/IInvalidField.js} +0 -0
  134. /package/dist/collection/utils/{form/interfaces/IValidationResult.js → validators/recordvalidator/IRecordValidator.js} +0 -0
  135. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IInvalidField.d.ts +0 -0
  136. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IRecordValidator.d.ts +0 -0
  137. /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IValidationResult.d.ts +0 -0
package/README.md CHANGED
@@ -68,7 +68,6 @@ Hoje estamos utilizando o padrão de semantic release baseado no [angular](https
68
68
  o build do ezui, link do react-output e ezui, build do react-output e a disponibilização da dist do react-output no diretório correto do ezui.
69
69
  - `npm run build`
70
70
 
71
-
72
71
  ## Para conhecer detalhes do projeto acesse:
73
72
  - [Olá EZUi](https://git.sankhya.com.br/sankhyalabs/ez-ui/-/wikis/Ol%C3%A1-EzUI)
74
73
  - [Diretrizes de codificação](https://git.sankhya.com.br/sankhyalabs/ez-ui/-/wikis/Diretrizes-de-codifica%C3%A7%C3%A3o)
@@ -25,6 +25,11 @@ class CSSVarsUtils {
25
25
  CSSVarsUtils.applyIfExists(host, child, '--ez-text-input--height');
26
26
  CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--disabled--background-color');
27
27
  CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--disabled--color');
28
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input--height--slim');
29
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input--border-radius');
30
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--focus--border-color');
31
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__icon--width');
32
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--focus--icon-color');
28
33
  }
29
34
  }
30
35
  static applyVarsButton(host, child) {
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ const core = require('@sankhyalabs/core');
4
+ const ApplicationUtils = require('./ApplicationUtils-2e444734.js');
5
+
6
+ const buildFieldMetadata = (descriptor, config) => {
7
+ let { name, label, group } = Object.assign({}, config);
8
+ let { readOnly, required } = Object.assign({}, config);
9
+ let props;
10
+ let userInterface;
11
+ if (descriptor) {
12
+ label = label || descriptor.label;
13
+ name = name || descriptor.name;
14
+ required = descriptor.required || (config === null || config === void 0 ? void 0 : config.required);
15
+ readOnly = descriptor.readOnly || (config === null || config === void 0 ? void 0 : config.readOnly);
16
+ props = descriptor.properties;
17
+ userInterface = descriptor.userInterface;
18
+ }
19
+ return {
20
+ name, label, group,
21
+ readOnly, required,
22
+ props,
23
+ userInterface: userInterface || core.UserInterface.SHORTTEXT
24
+ };
25
+ };
26
+
27
+ class RecordValidationProcessor {
28
+ constructor(dataUnit, validationSource, validator) {
29
+ this._dataUnit = dataUnit;
30
+ this._validationSource = validationSource;
31
+ this._validator = validator;
32
+ }
33
+ validate() {
34
+ return new Promise((accept, reject) => {
35
+ const records = this._dataUnit.getModifiedRecords();
36
+ for (let i = 0; i < records.length; i++) {
37
+ const record = records[i];
38
+ const invalidResults = [];
39
+ let validationResult = this.validateRequired(record);
40
+ if (validationResult && !validationResult.isValid) {
41
+ invalidResults.push(validationResult);
42
+ }
43
+ if (this._validator) {
44
+ validationResult = this._validator.validateRecord(record);
45
+ if (validationResult && !validationResult.isValid) {
46
+ invalidResults.push(validationResult);
47
+ }
48
+ }
49
+ if (invalidResults.length > 0) {
50
+ this.processValidationResult(invalidResults, record.__record__id__);
51
+ reject();
52
+ break;
53
+ }
54
+ }
55
+ return accept();
56
+ });
57
+ }
58
+ validateRequired(record) {
59
+ const requiredFields = this._validationSource.getRequiredFields();
60
+ const invalidFields = [];
61
+ new Set(requiredFields).forEach(field => {
62
+ const value = record[field];
63
+ if (value == undefined || value === "") {
64
+ const errorMessage = this._validationSource.getMessageForField(field, record.__record__id__);
65
+ if (errorMessage) {
66
+ invalidFields.push({ name: field, message: errorMessage });
67
+ }
68
+ else {
69
+ invalidFields.push({ name: field, message: "Essa informação é obrigatória" });
70
+ }
71
+ }
72
+ });
73
+ if (invalidFields.length > 0) {
74
+ return { isValid: false, invalidFields, infoMessage: "Há pelo menos um campo obrigatório não preenchido." };
75
+ }
76
+ return undefined;
77
+ }
78
+ processValidationResult(validationResult, recordId) {
79
+ validationResult.forEach(invalidResult => {
80
+ const invalidFields = invalidResult.invalidFields;
81
+ if (invalidFields) {
82
+ invalidFields.forEach(field => {
83
+ this.markAsInvalid(field, recordId);
84
+ });
85
+ }
86
+ if (invalidResult.infoMessage) {
87
+ ApplicationUtils.ApplicationUtils.info(invalidResult.infoMessage);
88
+ }
89
+ if (invalidResult.errorMessage) {
90
+ const { errorTitle, errorMessage } = invalidResult;
91
+ ApplicationUtils.ApplicationUtils.error(errorTitle, errorMessage);
92
+ }
93
+ });
94
+ }
95
+ markAsInvalid(field, recordId) {
96
+ this._dataUnit.setInvalidField(field.name, field.message, recordId);
97
+ this._validationSource.markAsInvalid(field, recordId);
98
+ }
99
+ }
100
+
101
+ exports.RecordValidationProcessor = RecordValidationProcessor;
102
+ exports.buildFieldMetadata = buildFieldMetadata;
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-1064511f.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  require('./ApplicationUtils-2e444734.js');
8
- const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
8
+ const CSSVarsUtils = require('./CSSVarsUtils-b136a156.js');
9
9
  require('./DialogType-2114c337.js');
10
10
  require('./CheckMode-ecb90b87.js');
11
11
 
@@ -28,15 +28,24 @@ const EzCalendar = class {
28
28
  */
29
29
  async show(top, left, bottom, right) {
30
30
  if (this.floating) {
31
- this._floatingID = core.FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
32
- window.requestAnimationFrame(() => {
33
- this._box.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
31
+ this._floatingID = core.FloatingManager.float(this._box, this._container, {
32
+ isFixed: this.isFixed(),
33
+ autoClose: true,
34
+ top,
35
+ left,
36
+ bottom,
37
+ right
34
38
  });
35
- this.scroll();
39
+ if (!this.isFixed()) {
40
+ window.requestAnimationFrame(() => {
41
+ this._box.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
42
+ });
43
+ this.scroll();
44
+ }
36
45
  }
37
46
  }
38
47
  /**
39
- * Ajusta o posicionamento do ez-calendar conforme a disponibilidade de espaço.
48
+ * Ajusta o posicionamento vertical do ez-calendar conforme a disponibilidade de espaço.
40
49
  */
41
50
  async fitVertical(topOffset, bottomOffset) {
42
51
  const neededHeight = this._container.getBoundingClientRect().bottom + this._calendarHeight;
@@ -48,6 +57,16 @@ const EzCalendar = class {
48
57
  this.show("unset", undefined, bottomOffset + "px");
49
58
  }
50
59
  }
60
+ /**
61
+ * Ajusta o posicionamento horizontal do ez-calendar conforme a disponibilidade de espaço.
62
+ */
63
+ async fitHorizontal(rightOffset) {
64
+ const neededWidth = this._container.getBoundingClientRect().right + this._calendarWidth;
65
+ const availableRight = (window.innerWidth || document.documentElement.clientWidth) > neededWidth;
66
+ if (!availableRight) {
67
+ this.show(undefined, "unset", undefined, rightOffset + "px");
68
+ }
69
+ }
51
70
  /**
52
71
  * Oculta o ez-calendar.
53
72
  */
@@ -63,6 +82,14 @@ const EzCalendar = class {
63
82
  this._currentPosition.setDate(1);
64
83
  }
65
84
  }
85
+ scrollListener() {
86
+ if (this.floating && this.isFixed()) {
87
+ this.hide();
88
+ }
89
+ }
90
+ isFixed() {
91
+ return this._hostElem.dataset.isFixed === "true";
92
+ }
66
93
  getMonthLabel() {
67
94
  return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
68
95
  }
@@ -127,6 +154,7 @@ const EzCalendar = class {
127
154
  componentDidRender() {
128
155
  if (this.floating && this._firstRender) {
129
156
  this._calendarHeight = this._box.clientHeight;
157
+ this._calendarWidth = this._box.clientWidth;
130
158
  this._box.remove();
131
159
  this._firstRender = false;
132
160
  }
@@ -200,6 +228,7 @@ const EzCalendar = class {
200
228
  }
201
229
  })))))));
202
230
  }
231
+ get _hostElem() { return index.getElement(this); }
203
232
  static get watchers() { return {
204
233
  "value": ["observeValue"]
205
234
  }; }
@@ -5,12 +5,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-1064511f.js');
6
6
  const core = require('@sankhyalabs/core');
7
7
  const ApplicationUtils = require('./ApplicationUtils-2e444734.js');
8
- const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
8
+ const CSSVarsUtils = require('./CSSVarsUtils-b136a156.js');
9
9
  require('./DialogType-2114c337.js');
10
10
  require('./CheckMode-ecb90b87.js');
11
11
  const constants = require('./constants-3a1d64fb.js');
12
12
 
13
- 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--line-height:calc(var(--text--medium, 14px) + 4px);--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--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--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) + 4px);--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__scrollbar--color-default:var(--scrollbar--default, #626e82);--ez-combo-box__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--ez-combo-box__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--ez-combo-box__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--ez-combo-box__scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:0;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small) + 9px);background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;padding:0;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;gap:3px;scrollbar-color:var(--ez-combo-box__scrollbar--color-clicked) var(--ez-combo-box__scrollbar--color-background)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__scrollbar--color-background);width:var(--ez-combo-box__scrollbar--width);max-width:var(--ez-combo-box__scrollbar--width);min-width:var(--ez-combo-box__scrollbar--width)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__scrollbar--color-background);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__scrollbar--color-default);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb:vertical:hover,.list-options::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--ez-combo-box__scrollbar--color-hover)}.list-options::-webkit-scrollbar-thumb:vertical:active,.list-options::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--ez-combo-box__scrollbar--color-clicked)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size);line-height:var(--ez-combo-box--line-height)}.item__label{font-weight:var(--ez-combo-box--font-weight--medium)}.item__label--bold{font-weight:var(--ez-combo-box--font-weight--large)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large)}.item__value--hidden{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:14px;height:14px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
13
+ 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--line-height:calc(var(--text--medium, 14px) + 4px);--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--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--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) + 4px);--ez-combo-box__list-min-width:64px;--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__scrollbar--color-default:var(--scrollbar--default, #626e82);--ez-combo-box__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--ez-combo-box__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--ez-combo-box__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--ez-combo-box__scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{min-width:var(--ez-combo-box__list-min-width);position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:0;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small) + 9px);background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;padding:0;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;gap:3px;scrollbar-color:var(--ez-combo-box__scrollbar--color-clicked) var(--ez-combo-box__scrollbar--color-background)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__scrollbar--color-background);width:var(--ez-combo-box__scrollbar--width);max-width:var(--ez-combo-box__scrollbar--width);min-width:var(--ez-combo-box__scrollbar--width)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__scrollbar--color-background);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__scrollbar--color-default);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb:vertical:hover,.list-options::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--ez-combo-box__scrollbar--color-hover)}.list-options::-webkit-scrollbar-thumb:vertical:active,.list-options::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--ez-combo-box__scrollbar--color-clicked)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size);line-height:var(--ez-combo-box--line-height)}.item__label{font-weight:var(--ez-combo-box--font-weight--medium)}.item__label--bold{font-weight:var(--ez-combo-box--font-weight--large)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large)}.item__value--hidden{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:14px;height:14px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";
14
14
 
15
15
  const EzComboBox = class {
16
16
  constructor(hostRef) {
@@ -42,6 +42,7 @@ const EzComboBox = class {
42
42
  this.suppressEmptyOption = false;
43
43
  this.canShowError = true;
44
44
  this.mode = "regular";
45
+ this.listOptionsPosition = undefined;
45
46
  }
46
47
  observeErrorMessage() {
47
48
  var _a;
@@ -84,17 +85,38 @@ const EzComboBox = class {
84
85
  return;
85
86
  this.loadOptions(SearchMode.PRELOAD);
86
87
  }
88
+ /*
89
+ * Retorna uma promise com o valor da opção selecionada,
90
+ * que será resolvida quando o backend devolver este dado.
91
+ */
92
+ async getValueAsync() {
93
+ if (!this._showLoading) {
94
+ return new Promise(resolve => resolve(this.value));
95
+ }
96
+ return new Promise(resolve => {
97
+ let id = setInterval(() => {
98
+ if (!this._showLoading) {
99
+ clearInterval(id);
100
+ resolve(this.value);
101
+ }
102
+ }, 100);
103
+ });
104
+ }
87
105
  /**
88
106
  * Aplica o foco no campo.
89
107
  */
90
108
  async setFocus() {
91
- this._textInput.setFocus();
109
+ if (this._textInput) {
110
+ this._textInput.setFocus();
111
+ }
92
112
  }
93
113
  /**
94
114
  * Remove o foco do campo.
95
115
  */
96
116
  async setBlur() {
97
- this._textInput.setBlur();
117
+ if (this._textInput) {
118
+ this._textInput.setBlur();
119
+ }
98
120
  }
99
121
  /**
100
122
  * Retorna se o conteúdo é inválido.
@@ -109,16 +131,61 @@ const EzComboBox = class {
109
131
  this.clearSearch();
110
132
  }
111
133
  scrollListener() {
112
- if (!this._floatingID)
134
+ var _a;
135
+ if (this._floatingID == undefined) {
113
136
  return;
114
- window.requestAnimationFrame(() => {
115
- this.updateListPosition();
116
- });
137
+ }
138
+ if ((_a = this.listOptionsPosition) === null || _a === void 0 ? void 0 : _a.hardPosition) {
139
+ this.hideOptions();
140
+ }
141
+ else {
142
+ window.requestAnimationFrame(() => {
143
+ this.updateListPosition();
144
+ });
145
+ }
117
146
  }
118
147
  updateListPosition() {
119
- const { top } = this._listContainer.getBoundingClientRect();
120
- const margin = (this.errorMessage || !this.canShowError || this.mode === "slim") ? 6 : -13;
121
- this._listWrapper.style.top = `${(top + margin)}px`;
148
+ let { verticalPosition, horizontalPosition, fromBottom, fromRight, bottomLimit, hardPosition } = this.getListPosition();
149
+ const elementRect = this._listWrapper.getBoundingClientRect();
150
+ const containerRect = this._listContainer.getBoundingClientRect();
151
+ const textInputRect = this._textInput.getBoundingClientRect();
152
+ const limitHeight = bottomLimit || window.innerHeight;
153
+ const neededHeight = containerRect.bottom + elementRect.height;
154
+ if (!fromBottom && (elementRect.top < 0 || neededHeight > limitHeight)) {
155
+ fromBottom = true;
156
+ }
157
+ if (!hardPosition) {
158
+ verticalPosition = verticalPosition || 0;
159
+ horizontalPosition = horizontalPosition || 0;
160
+ if (fromBottom) {
161
+ verticalPosition = window.innerHeight - textInputRect.top + verticalPosition;
162
+ }
163
+ else {
164
+ verticalPosition += containerRect.top;
165
+ }
166
+ if (fromRight) {
167
+ horizontalPosition = window.innerWidth - textInputRect.right + horizontalPosition;
168
+ }
169
+ else {
170
+ horizontalPosition += containerRect.left;
171
+ }
172
+ }
173
+ if (verticalPosition != undefined) {
174
+ this._listWrapper.style[fromBottom ? "bottom" : "top"] = `${verticalPosition}px`;
175
+ this._listWrapper.style[fromBottom ? "top" : "bottom"] = "";
176
+ }
177
+ if (horizontalPosition != undefined) {
178
+ this._listWrapper.style[fromRight ? "right" : "left"] = `${horizontalPosition}px`;
179
+ this._listWrapper.style[fromRight ? "left" : "right"] = "";
180
+ }
181
+ }
182
+ getListPosition() {
183
+ if (this.listOptionsPosition) {
184
+ return this.listOptionsPosition;
185
+ }
186
+ return {
187
+ verticalPosition: (this.errorMessage || !this.canShowError || this.mode === "slim") ? 6 : -13
188
+ };
122
189
  }
123
190
  isDifferentValues(firstValue, secondValue) {
124
191
  return core.ObjectUtils.objectToString(firstValue || {}) !== core.ObjectUtils.objectToString(secondValue || {});
@@ -201,13 +268,18 @@ const EzComboBox = class {
201
268
  showOptions() {
202
269
  if (!this.enabled)
203
270
  return;
271
+ if (this.isOptionsVisible()) {
272
+ return;
273
+ }
204
274
  if (!!this._resizeObserver)
205
275
  this._resizeObserver.observe(this._textInput);
206
- this._floatingID = core.FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, isFixed: true });
276
+ this._floatingID = core.FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, isFixed: true, backClickListener: () => this.hideOptions() });
207
277
  this.setFocus();
208
278
  window.requestAnimationFrame(() => {
209
279
  this.updateListPosition();
210
- this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
280
+ if (!this.listOptionsPosition) {
281
+ this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
282
+ }
211
283
  });
212
284
  }
213
285
  hideOptions() {
@@ -237,7 +309,7 @@ const EzComboBox = class {
237
309
  window.requestAnimationFrame(() => {
238
310
  const liElem = (opt === null || opt === void 0 ? void 0 : opt.value) ? this._optionsList.querySelector(`li#item_${opt.value.replace(/[<>\[\]#=]/g, '\\$&').replace(/:/g, '\\:')}`) : undefined;
239
311
  if (liElem)
240
- liElem.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "start" });
312
+ liElem.scrollIntoView({ behavior: "smooth", block: "nearest" });
241
313
  });
242
314
  }
243
315
  selectCurrentOption() {
@@ -293,6 +365,7 @@ const EzComboBox = class {
293
365
  this._visibleOptions = [];
294
366
  this.clearSource();
295
367
  }
368
+ this.setFocus();
296
369
  }
297
370
  loadOptions(mode, argument = "") {
298
371
  this._criteria = argument;
@@ -550,9 +623,11 @@ const EzComboBox = class {
550
623
  switch (event.key) {
551
624
  case "ArrowDown":
552
625
  this.nextOption();
626
+ event.stopPropagation();
553
627
  break;
554
628
  case "ArrowUp":
555
629
  this.previousOption();
630
+ event.stopPropagation();
556
631
  break;
557
632
  case "Enter":
558
633
  this.selectCurrentOption();
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-1064511f.js');
6
6
  const core = require('@sankhyalabs/core');
7
- const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
7
+ const CSSVarsUtils = require('./CSSVarsUtils-b136a156.js');
8
8
 
9
9
  const ezDateInputCss = ":host{display:block;width:100%;--ez-date-input__input--background-color:var(--background--medium, #e0e0e0);--ez-date-input__input--border-color:var(--ez-date-input__input--background-color);--ez-date-input__calendar-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"15px\"><path d=\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\"/></svg>')}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;-webkit-mask-image:var(--ez-date-input__calendar-image);mask-image:var(--ez-date-input__calendar-image)}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}ez-text-input{--text-input__input--background-color:var(--ez-date-input__input--background-color, #FFFFFF);--text-input__input--border-color:var(--ez-date-input__input--border-color, #DCE0E8)}";
10
10
 
@@ -14,7 +14,9 @@ const EzDateInput = class {
14
14
  this.ezChange = index.createEvent(this, "ezChange", 7);
15
15
  this.ezStartChange = index.createEvent(this, "ezStartChange", 7);
16
16
  this.ezCancelWaitingChange = index.createEvent(this, "ezCancelWaitingChange", 7);
17
+ this._changePending = false;
17
18
  this._focused = false;
19
+ this._valuePromiseCallbacks = [];
18
20
  this.label = undefined;
19
21
  this.value = undefined;
20
22
  this.enabled = true;
@@ -52,6 +54,7 @@ const EzDateInput = class {
52
54
  this.ezChange.emit(valueEmitted);
53
55
  }
54
56
  }
57
+ this._changePending = false;
55
58
  }
56
59
  /**
57
60
  * Aplica o foco no campo.
@@ -71,6 +74,18 @@ const EzDateInput = class {
71
74
  async isInvalid() {
72
75
  return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
73
76
  }
77
+ /*
78
+ * Retorna uma promise com o valor da opção selecionada,
79
+ * que será resolvida quando o backend devolver este dado.
80
+ */
81
+ async getValueAsync() {
82
+ if (this._changePending) {
83
+ return new Promise(accept => {
84
+ this._valuePromiseCallbacks.push(accept);
85
+ });
86
+ }
87
+ return Promise.resolve(this.value);
88
+ }
74
89
  changeValue(newValue) {
75
90
  const currentValue = core.DateUtils.validateDate(this.value);
76
91
  const newValueValidated = core.DateUtils.validateDate(newValue);
@@ -81,10 +96,14 @@ const EzDateInput = class {
81
96
  showCalendar() {
82
97
  this.handleBlur();
83
98
  this._calendar.value = this.value;
84
- //FIXME: Provavelmente isso fará com que o popup abra em uma
85
- //posição errada no futuro. Preferi fazer simples no começo,
86
- //porque não quis onerar o text input com essa funcionalidade...
87
- const top = this.errorMessage || this.mode === "slim" ? 6 : -13;
99
+ let top;
100
+ if (this.isFixed()) {
101
+ top = 29;
102
+ this._calendar.fitHorizontal(0);
103
+ }
104
+ else {
105
+ top = this.errorMessage || this.mode === "slim" ? 6 : -13;
106
+ }
88
107
  this._calendar.fitVertical(top, this._elem.clientHeight);
89
108
  }
90
109
  hideCalendar() {
@@ -92,27 +111,35 @@ const EzDateInput = class {
92
111
  this._calendar.hide();
93
112
  }
94
113
  handleBlur() {
95
- const strValue = this._textInput.value;
96
- const newValue = core.DateUtils.strToDate(strValue);
97
- if (newValue || !strValue) {
98
- this.errorMessage = "";
99
- const currentValue = core.DateUtils.validateDate(this.value);
100
- const newValueValidated = core.DateUtils.validateDate(newValue);
101
- if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
102
- if (newValueValidated) {
103
- this._textInput.value = this.getTextValue(newValueValidated) || '';
104
- this._focused = false;
114
+ try {
115
+ const strValue = this._textInput.value;
116
+ const newValue = core.DateUtils.strToDate(strValue);
117
+ if (newValue || !strValue) {
118
+ this.errorMessage = "";
119
+ const currentValue = core.DateUtils.validateDate(this.value);
120
+ const newValueValidated = core.DateUtils.validateDate(newValue);
121
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
122
+ if (newValueValidated) {
123
+ this._textInput.value = this.getTextValue(newValueValidated) || '';
124
+ this._focused = false;
125
+ }
126
+ this.ezCancelWaitingChange.emit();
127
+ }
128
+ else {
129
+ this.changeValue(newValueValidated);
105
130
  }
106
- this.ezCancelWaitingChange.emit();
107
131
  }
108
132
  else {
109
- this.changeValue(newValueValidated);
133
+ this.changeValue(undefined);
134
+ this.ezCancelWaitingChange.emit();
135
+ this.errorMessage = "O valor digitado não é uma data válida";
110
136
  }
111
137
  }
112
- else {
113
- this.changeValue(undefined);
114
- this.ezCancelWaitingChange.emit();
115
- this.errorMessage = "O valor digitado não é uma data válida";
138
+ finally {
139
+ for (const callback of this._valuePromiseCallbacks) {
140
+ callback(this.value);
141
+ }
142
+ this._valuePromiseCallbacks = [];
116
143
  }
117
144
  }
118
145
  getTextValue(d) {
@@ -124,6 +151,7 @@ const EzDateInput = class {
124
151
  const currentValue = core.DateUtils.validateDate(this.value);
125
152
  const newValueValidated = core.DateUtils.validateDate(newValue);
126
153
  if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
154
+ this._changePending = true;
127
155
  this._focused = true;
128
156
  this.ezStartChange.emit({ waitmessage: "", blocking: false });
129
157
  }
@@ -137,13 +165,16 @@ const EzDateInput = class {
137
165
  this._textInput.value = textValue;
138
166
  }
139
167
  }
168
+ isFixed() {
169
+ return this._elem.dataset.isFixed === "true";
170
+ }
140
171
  componentDidLoad() {
141
172
  CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
142
173
  this.setInputValue();
143
174
  }
144
175
  render() {
145
176
  core.ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
146
- return (index.h(index.Host, null, index.h("ez-text-input", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
177
+ return (index.h(index.Host, null, index.h("ez-text-input", { "data-element-id": core.ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: (evt) => this.handleInput(evt), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { ref: elem => this._calendar = elem, "data-element-id": core.ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, "data-is-fixed": this._elem.dataset.isFixed })));
147
178
  }
148
179
  get _elem() { return index.getElement(this); }
149
180
  static get watchers() { return {