@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
@@ -23,6 +23,11 @@ class CSSVarsUtils {
23
23
  CSSVarsUtils.applyIfExists(host, child, '--ez-text-input--height');
24
24
  CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--disabled--background-color');
25
25
  CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--disabled--color');
26
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input--height--slim');
27
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input--border-radius');
28
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--focus--border-color');
29
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__icon--width');
30
+ CSSVarsUtils.applyIfExists(host, child, '--ez-text-input__input--focus--icon-color');
26
31
  }
27
32
  }
28
33
  static applyVarsButton(host, child) {
@@ -0,0 +1,99 @@
1
+ import { UserInterface } from '@sankhyalabs/core';
2
+ import { A as ApplicationUtils } from './ApplicationUtils-d9a34a16.js';
3
+
4
+ const buildFieldMetadata = (descriptor, config) => {
5
+ let { name, label, group } = Object.assign({}, config);
6
+ let { readOnly, required } = Object.assign({}, config);
7
+ let props;
8
+ let userInterface;
9
+ if (descriptor) {
10
+ label = label || descriptor.label;
11
+ name = name || descriptor.name;
12
+ required = descriptor.required || (config === null || config === void 0 ? void 0 : config.required);
13
+ readOnly = descriptor.readOnly || (config === null || config === void 0 ? void 0 : config.readOnly);
14
+ props = descriptor.properties;
15
+ userInterface = descriptor.userInterface;
16
+ }
17
+ return {
18
+ name, label, group,
19
+ readOnly, required,
20
+ props,
21
+ userInterface: userInterface || UserInterface.SHORTTEXT
22
+ };
23
+ };
24
+
25
+ class RecordValidationProcessor {
26
+ constructor(dataUnit, validationSource, validator) {
27
+ this._dataUnit = dataUnit;
28
+ this._validationSource = validationSource;
29
+ this._validator = validator;
30
+ }
31
+ validate() {
32
+ return new Promise((accept, reject) => {
33
+ const records = this._dataUnit.getModifiedRecords();
34
+ for (let i = 0; i < records.length; i++) {
35
+ const record = records[i];
36
+ const invalidResults = [];
37
+ let validationResult = this.validateRequired(record);
38
+ if (validationResult && !validationResult.isValid) {
39
+ invalidResults.push(validationResult);
40
+ }
41
+ if (this._validator) {
42
+ validationResult = this._validator.validateRecord(record);
43
+ if (validationResult && !validationResult.isValid) {
44
+ invalidResults.push(validationResult);
45
+ }
46
+ }
47
+ if (invalidResults.length > 0) {
48
+ this.processValidationResult(invalidResults, record.__record__id__);
49
+ reject();
50
+ break;
51
+ }
52
+ }
53
+ return accept();
54
+ });
55
+ }
56
+ validateRequired(record) {
57
+ const requiredFields = this._validationSource.getRequiredFields();
58
+ const invalidFields = [];
59
+ new Set(requiredFields).forEach(field => {
60
+ const value = record[field];
61
+ if (value == undefined || value === "") {
62
+ const errorMessage = this._validationSource.getMessageForField(field, record.__record__id__);
63
+ if (errorMessage) {
64
+ invalidFields.push({ name: field, message: errorMessage });
65
+ }
66
+ else {
67
+ invalidFields.push({ name: field, message: "Essa informação é obrigatória" });
68
+ }
69
+ }
70
+ });
71
+ if (invalidFields.length > 0) {
72
+ return { isValid: false, invalidFields, infoMessage: "Há pelo menos um campo obrigatório não preenchido." };
73
+ }
74
+ return undefined;
75
+ }
76
+ processValidationResult(validationResult, recordId) {
77
+ validationResult.forEach(invalidResult => {
78
+ const invalidFields = invalidResult.invalidFields;
79
+ if (invalidFields) {
80
+ invalidFields.forEach(field => {
81
+ this.markAsInvalid(field, recordId);
82
+ });
83
+ }
84
+ if (invalidResult.infoMessage) {
85
+ ApplicationUtils.info(invalidResult.infoMessage);
86
+ }
87
+ if (invalidResult.errorMessage) {
88
+ const { errorTitle, errorMessage } = invalidResult;
89
+ ApplicationUtils.error(errorTitle, errorMessage);
90
+ }
91
+ });
92
+ }
93
+ markAsInvalid(field, recordId) {
94
+ this._dataUnit.setInvalidField(field.name, field.message, recordId);
95
+ this._validationSource.markAsInvalid(field, recordId);
96
+ }
97
+ }
98
+
99
+ export { RecordValidationProcessor as R, buildFieldMetadata as b };
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-296b8458.js';
2
2
  import { FloatingManager, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import './ApplicationUtils-d9a34a16.js';
4
- import { C as CSSVarsUtils } from './CSSVarsUtils-00f67f32.js';
4
+ import { C as CSSVarsUtils } from './CSSVarsUtils-a97cfa29.js';
5
5
  import './DialogType-54a62731.js';
6
6
  import './CheckMode-bdb2ec19.js';
7
7
 
@@ -1,4 +1,4 @@
1
- import { r as registerInstance, c as createEvent, f as forceUpdate, h } from './index-296b8458.js';
1
+ import { r as registerInstance, c as createEvent, f as forceUpdate, h, g as getElement } from './index-296b8458.js';
2
2
  import { FloatingManager } from '@sankhyalabs/core';
3
3
 
4
4
  const ezCalendarCss = ":host{--ez-calendar--font-family:var(--font-pattern, Arial);--ez-calendar--color:var(--title--primary, #626e82);--ez-calendar--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--ez-calendar__body--background-color:var(--background--xlight, #FFF);--ez-calendar__time--background-color:var(--background--xlight, #FAFAFA);--ez-calendar__body--padding:var(--space--medium, 12px) var(--space--small, 6px);--ez-calendar__body--border-radius:var(--border--radius-medium, 12px);--ez-calendar__body--shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-container--z-index:var(--more-visible, 2);--ez-calendar__header-line--stroke:1px;--ez-calendar__header-line--color:var(--color--strokes, #C0C0C0);--ez-calendar__nav-btn--fill:var(--text--primary, #008561);--ez-calendar__nav-btn--hover--fill:var(--color--primary, #350404);--ez-calendar__nav-btn--width:10px;--ez-calendar__nav-btn--height:16px;--ez-calendar__nav-btn--previous-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\"/></svg>');--ez-calendar__nav-btn--next-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\"/></svg>');--ez-calendar__cell--margin:0px 1.5px;--ez-calendar__cell--width:var(--space--large, 24px);--ez-calendar__cell--padding:1.5px 0px;--ez-calendar__cell--border-radius:var(--border--radius-small, 6px);--ez-calendar__cell--over--background-color:var(--color--primary, #E2F4EF);--ez-calendar__cell--over--color:var(--color--primary-300, #008561);--ez-calendar__cell--outset--color:var(--color--disable-primary, #E5EAF0);--ez-calendar__cell--selected--background-color:var(--color--primary, #008561);--ez-calendar__cell--selected--color:var(--color--inverted, #FFF);--ez-calendar__btn-today--color:var(--color--primary);--ez-calendar__btn-today--hover--background-color:var(--color--primary-300, #E2F4EF);--ez-calendar__btn-today--border-radius:var(--border--radius-small, 6px);position:relative;display:flex;user-select:none}.calendar__container{display:flex;z-index:var(--more-visible, 2)}.calendar{display:flex;flex-direction:column;z-index:var(--more-visible, 2);background-color:var(--ez-calendar__body--background-color);padding:var(--ez-calendar__body--padding);border-radius:var(--ez-calendar__body--border-radius);box-shadow:var(--ez-calendar__body--shadow)}.calendar__header{display:flex;justify-content:space-between;padding-bottom:var(--space--small, 6px);margin:0px var(--space--, 12px) var(--space--small, 6px) var(--space--, 12px);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow);border-bottom:solid var(--ez-calendar__header-line--stroke) var(--ez-calendar__header-line--color)}.calendar__btn-next,.calendar__btn-previous{outline:none;border:none;background-color:unset;cursor:pointer;padding:0px}.calendar__btn-next::after,.calendar__btn-previous::after{content:'';display:flex;background-color:var(--ez-calendar__nav-btn--fill);width:var(--ez-calendar__nav-btn--width);height:var(--ez-calendar__nav-btn--height)}.calendar__btn-previous::after{-webkit-mask-image:var(--ez-calendar__nav-btn--previous-image);mask-image:var(--ez-calendar__nav-btn--previous-image)}.calendar__btn-next::after{-webkit-mask-image:var(--ez-calendar__nav-btn--next-image);mask-image:var(--ez-calendar__nav-btn--next-image)}.calendar__btn-next:hover::after,.calendar__btn-previous:hover::after{background-color:var(--ez-calendar__nav-btn--hover--fill)}.calendar__lbl-month{font-weight:var(--text-weight--extra-large, 700);font-size:var(--title--small, 14px);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow)}.calendar__line{display:flex;padding:0px;margin:0px}.calendar__cell{display:flex;justify-content:center;align-content:center;cursor:pointer;font-size:var(--text--extra-small, 10px);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow);padding:var(--ez-calendar__cell--padding);margin:var(--ez-calendar__cell--margin);min-width:var(--ez-calendar__cell--width);border-radius:var(--ez-calendar__cell--border-radius)}.calendar__cell:hover{background-color:var(--ez-calendar__cell--over--background-color);color:var(--ez-calendar__cell--over--color)}.calendar__cell--secondary{color:var(--ez-calendar__cell--outset--color)}.calendar__cell--unselectable:hover{background-color:unset;border-radius:unset;cursor:unset;color:var(--ez-calendar--color)}.calendar__cell--unselectable{font-weight:var(--text-weight--large, 600);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow)}.calendar__cell--selected,.calendar__cell--selected:hover{background-color:var(--ez-calendar__cell--selected--background-color);color:var(--ez-calendar__cell--selected--color)}.calendar__footer{display:flex;flex-direction:column}.calendar__btn-today{border:none;background-color:unset;cursor:pointer;padding:0px;font-weight:var(--text-weight--large, 600);font-size:var(--title--extra-small, 12px);font-family:var(--ez-calendar--font-family);text-shadow:var(--ez-calendar--text-shadow);color:var(--ez-calendar__btn-today--color);border-radius:var(--ez-calendar__btn-today--border-radius)}.calendar__btn-today:hover{background-color:var(--ez-calendar__btn-today--hover--background-color)}section{display:flex}.calendar-time{margin-left:-10px;display:flex;flex-direction:column;padding:12px 0px 0px 10px;background-color:var(--ez-calendar__time--background-color);border-top-right-radius:var(--ez-calendar__body--border-radius);border-bottom-right-radius:var(--ez-calendar__body--border-radius);box-shadow:var(--ez-calendar__body--shadow)}.calendar__column{height:136px;padding:0px;margin:0px;overflow:auto;scrollbar-width:none}.calendar__column::-webkit-scrollbar{width:0px;max-width:0px;min-width:0px}.calendar-time__header{display:flex;justify-content:space-between;padding-left:var(--space--small, 6px);padding-right:var(--space--small, 6px);padding-bottom:var(--space--small, 6px);margin:0px var(--space--, 12px) var(--space--small, 6px) var(--space--, 12px);font-weight:var(--text-weight--extra-large, 700);font-size:var(--title--small, 14px);text-shadow:var(--ez-calendar--text-shadow);border-bottom:solid var(--ez-calendar__header-line--stroke) var(--ez-calendar__header-line--color);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow)}.separatorTime{color:#A2ABB9;padding:0px 1px;line-height:16px;font-size:17px;font-weight:normal}.endHidden{-webkit-mask-image:linear-gradient(180deg, #000 calc(100% - 48px), transparent 100%)}.calendar__column .calendar__cell{margin:0px;padding:1.5px 1.5px}";
@@ -24,15 +24,24 @@ const EzCalendar = class {
24
24
  */
25
25
  async show(top, left, bottom, right) {
26
26
  if (this.floating) {
27
- this._floatingID = FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
28
- window.requestAnimationFrame(() => {
29
- this._box.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
27
+ this._floatingID = FloatingManager.float(this._box, this._container, {
28
+ isFixed: this.isFixed(),
29
+ autoClose: true,
30
+ top,
31
+ left,
32
+ bottom,
33
+ right
30
34
  });
31
- this.scroll();
35
+ if (!this.isFixed()) {
36
+ window.requestAnimationFrame(() => {
37
+ this._box.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
38
+ });
39
+ this.scroll();
40
+ }
32
41
  }
33
42
  }
34
43
  /**
35
- * Ajusta o posicionamento do ez-calendar conforme a disponibilidade de espaço.
44
+ * Ajusta o posicionamento vertical do ez-calendar conforme a disponibilidade de espaço.
36
45
  */
37
46
  async fitVertical(topOffset, bottomOffset) {
38
47
  const neededHeight = this._container.getBoundingClientRect().bottom + this._calendarHeight;
@@ -44,6 +53,16 @@ const EzCalendar = class {
44
53
  this.show("unset", undefined, bottomOffset + "px");
45
54
  }
46
55
  }
56
+ /**
57
+ * Ajusta o posicionamento horizontal do ez-calendar conforme a disponibilidade de espaço.
58
+ */
59
+ async fitHorizontal(rightOffset) {
60
+ const neededWidth = this._container.getBoundingClientRect().right + this._calendarWidth;
61
+ const availableRight = (window.innerWidth || document.documentElement.clientWidth) > neededWidth;
62
+ if (!availableRight) {
63
+ this.show(undefined, "unset", undefined, rightOffset + "px");
64
+ }
65
+ }
47
66
  /**
48
67
  * Oculta o ez-calendar.
49
68
  */
@@ -59,6 +78,14 @@ const EzCalendar = class {
59
78
  this._currentPosition.setDate(1);
60
79
  }
61
80
  }
81
+ scrollListener() {
82
+ if (this.floating && this.isFixed()) {
83
+ this.hide();
84
+ }
85
+ }
86
+ isFixed() {
87
+ return this._hostElem.dataset.isFixed === "true";
88
+ }
62
89
  getMonthLabel() {
63
90
  return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
64
91
  }
@@ -123,6 +150,7 @@ const EzCalendar = class {
123
150
  componentDidRender() {
124
151
  if (this.floating && this._firstRender) {
125
152
  this._calendarHeight = this._box.clientHeight;
153
+ this._calendarWidth = this._box.clientWidth;
126
154
  this._box.remove();
127
155
  this._firstRender = false;
128
156
  }
@@ -196,6 +224,7 @@ const EzCalendar = class {
196
224
  }
197
225
  })))))));
198
226
  }
227
+ get _hostElem() { return getElement(this); }
199
228
  static get watchers() { return {
200
229
  "value": ["observeValue"]
201
230
  }; }
@@ -1,12 +1,12 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-296b8458.js';
2
2
  import { ObjectUtils, FloatingManager, StringUtils, ElementIDUtils } from '@sankhyalabs/core';
3
3
  import { A as ApplicationUtils } from './ApplicationUtils-d9a34a16.js';
4
- import { C as CSSVarsUtils } from './CSSVarsUtils-00f67f32.js';
4
+ import { C as CSSVarsUtils } from './CSSVarsUtils-a97cfa29.js';
5
5
  import './DialogType-54a62731.js';
6
6
  import './CheckMode-bdb2ec19.js';
7
7
  import { R as REQUIRED_INFO } from './constants-6dab64f7.js';
8
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--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)}}";
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--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)}}";
10
10
 
11
11
  const EzComboBox = class {
12
12
  constructor(hostRef) {
@@ -38,6 +38,7 @@ const EzComboBox = class {
38
38
  this.suppressEmptyOption = false;
39
39
  this.canShowError = true;
40
40
  this.mode = "regular";
41
+ this.listOptionsPosition = undefined;
41
42
  }
42
43
  observeErrorMessage() {
43
44
  var _a;
@@ -80,17 +81,38 @@ const EzComboBox = class {
80
81
  return;
81
82
  this.loadOptions(SearchMode.PRELOAD);
82
83
  }
84
+ /*
85
+ * Retorna uma promise com o valor da opção selecionada,
86
+ * que será resolvida quando o backend devolver este dado.
87
+ */
88
+ async getValueAsync() {
89
+ if (!this._showLoading) {
90
+ return new Promise(resolve => resolve(this.value));
91
+ }
92
+ return new Promise(resolve => {
93
+ let id = setInterval(() => {
94
+ if (!this._showLoading) {
95
+ clearInterval(id);
96
+ resolve(this.value);
97
+ }
98
+ }, 100);
99
+ });
100
+ }
83
101
  /**
84
102
  * Aplica o foco no campo.
85
103
  */
86
104
  async setFocus() {
87
- this._textInput.setFocus();
105
+ if (this._textInput) {
106
+ this._textInput.setFocus();
107
+ }
88
108
  }
89
109
  /**
90
110
  * Remove o foco do campo.
91
111
  */
92
112
  async setBlur() {
93
- this._textInput.setBlur();
113
+ if (this._textInput) {
114
+ this._textInput.setBlur();
115
+ }
94
116
  }
95
117
  /**
96
118
  * Retorna se o conteúdo é inválido.
@@ -105,16 +127,61 @@ const EzComboBox = class {
105
127
  this.clearSearch();
106
128
  }
107
129
  scrollListener() {
108
- if (!this._floatingID)
130
+ var _a;
131
+ if (this._floatingID == undefined) {
109
132
  return;
110
- window.requestAnimationFrame(() => {
111
- this.updateListPosition();
112
- });
133
+ }
134
+ if ((_a = this.listOptionsPosition) === null || _a === void 0 ? void 0 : _a.hardPosition) {
135
+ this.hideOptions();
136
+ }
137
+ else {
138
+ window.requestAnimationFrame(() => {
139
+ this.updateListPosition();
140
+ });
141
+ }
113
142
  }
114
143
  updateListPosition() {
115
- const { top } = this._listContainer.getBoundingClientRect();
116
- const margin = (this.errorMessage || !this.canShowError || this.mode === "slim") ? 6 : -13;
117
- this._listWrapper.style.top = `${(top + margin)}px`;
144
+ let { verticalPosition, horizontalPosition, fromBottom, fromRight, bottomLimit, hardPosition } = this.getListPosition();
145
+ const elementRect = this._listWrapper.getBoundingClientRect();
146
+ const containerRect = this._listContainer.getBoundingClientRect();
147
+ const textInputRect = this._textInput.getBoundingClientRect();
148
+ const limitHeight = bottomLimit || window.innerHeight;
149
+ const neededHeight = containerRect.bottom + elementRect.height;
150
+ if (!fromBottom && (elementRect.top < 0 || neededHeight > limitHeight)) {
151
+ fromBottom = true;
152
+ }
153
+ if (!hardPosition) {
154
+ verticalPosition = verticalPosition || 0;
155
+ horizontalPosition = horizontalPosition || 0;
156
+ if (fromBottom) {
157
+ verticalPosition = window.innerHeight - textInputRect.top + verticalPosition;
158
+ }
159
+ else {
160
+ verticalPosition += containerRect.top;
161
+ }
162
+ if (fromRight) {
163
+ horizontalPosition = window.innerWidth - textInputRect.right + horizontalPosition;
164
+ }
165
+ else {
166
+ horizontalPosition += containerRect.left;
167
+ }
168
+ }
169
+ if (verticalPosition != undefined) {
170
+ this._listWrapper.style[fromBottom ? "bottom" : "top"] = `${verticalPosition}px`;
171
+ this._listWrapper.style[fromBottom ? "top" : "bottom"] = "";
172
+ }
173
+ if (horizontalPosition != undefined) {
174
+ this._listWrapper.style[fromRight ? "right" : "left"] = `${horizontalPosition}px`;
175
+ this._listWrapper.style[fromRight ? "left" : "right"] = "";
176
+ }
177
+ }
178
+ getListPosition() {
179
+ if (this.listOptionsPosition) {
180
+ return this.listOptionsPosition;
181
+ }
182
+ return {
183
+ verticalPosition: (this.errorMessage || !this.canShowError || this.mode === "slim") ? 6 : -13
184
+ };
118
185
  }
119
186
  isDifferentValues(firstValue, secondValue) {
120
187
  return ObjectUtils.objectToString(firstValue || {}) !== ObjectUtils.objectToString(secondValue || {});
@@ -197,13 +264,18 @@ const EzComboBox = class {
197
264
  showOptions() {
198
265
  if (!this.enabled)
199
266
  return;
267
+ if (this.isOptionsVisible()) {
268
+ return;
269
+ }
200
270
  if (!!this._resizeObserver)
201
271
  this._resizeObserver.observe(this._textInput);
202
- this._floatingID = FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, isFixed: true });
272
+ this._floatingID = FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, isFixed: true, backClickListener: () => this.hideOptions() });
203
273
  this.setFocus();
204
274
  window.requestAnimationFrame(() => {
205
275
  this.updateListPosition();
206
- this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
276
+ if (!this.listOptionsPosition) {
277
+ this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
278
+ }
207
279
  });
208
280
  }
209
281
  hideOptions() {
@@ -233,7 +305,7 @@ const EzComboBox = class {
233
305
  window.requestAnimationFrame(() => {
234
306
  const liElem = (opt === null || opt === void 0 ? void 0 : opt.value) ? this._optionsList.querySelector(`li#item_${opt.value.replace(/[<>\[\]#=]/g, '\\$&').replace(/:/g, '\\:')}`) : undefined;
235
307
  if (liElem)
236
- liElem.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "start" });
308
+ liElem.scrollIntoView({ behavior: "smooth", block: "nearest" });
237
309
  });
238
310
  }
239
311
  selectCurrentOption() {
@@ -289,6 +361,7 @@ const EzComboBox = class {
289
361
  this._visibleOptions = [];
290
362
  this.clearSource();
291
363
  }
364
+ this.setFocus();
292
365
  }
293
366
  loadOptions(mode, argument = "") {
294
367
  this._criteria = argument;
@@ -546,9 +619,11 @@ const EzComboBox = class {
546
619
  switch (event.key) {
547
620
  case "ArrowDown":
548
621
  this.nextOption();
622
+ event.stopPropagation();
549
623
  break;
550
624
  case "ArrowUp":
551
625
  this.previousOption();
626
+ event.stopPropagation();
552
627
  break;
553
628
  case "Enter":
554
629
  this.selectCurrentOption();
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-296b8458.js';
2
2
  import { DateUtils, ElementIDUtils } from '@sankhyalabs/core';
3
- import { C as CSSVarsUtils } from './CSSVarsUtils-00f67f32.js';
3
+ import { C as CSSVarsUtils } from './CSSVarsUtils-a97cfa29.js';
4
4
 
5
5
  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)}";
6
6
 
@@ -10,7 +10,9 @@ const EzDateInput = class {
10
10
  this.ezChange = createEvent(this, "ezChange", 7);
11
11
  this.ezStartChange = createEvent(this, "ezStartChange", 7);
12
12
  this.ezCancelWaitingChange = createEvent(this, "ezCancelWaitingChange", 7);
13
+ this._changePending = false;
13
14
  this._focused = false;
15
+ this._valuePromiseCallbacks = [];
14
16
  this.label = undefined;
15
17
  this.value = undefined;
16
18
  this.enabled = true;
@@ -48,6 +50,7 @@ const EzDateInput = class {
48
50
  this.ezChange.emit(valueEmitted);
49
51
  }
50
52
  }
53
+ this._changePending = false;
51
54
  }
52
55
  /**
53
56
  * Aplica o foco no campo.
@@ -67,6 +70,18 @@ const EzDateInput = class {
67
70
  async isInvalid() {
68
71
  return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
69
72
  }
73
+ /*
74
+ * Retorna uma promise com o valor da opção selecionada,
75
+ * que será resolvida quando o backend devolver este dado.
76
+ */
77
+ async getValueAsync() {
78
+ if (this._changePending) {
79
+ return new Promise(accept => {
80
+ this._valuePromiseCallbacks.push(accept);
81
+ });
82
+ }
83
+ return Promise.resolve(this.value);
84
+ }
70
85
  changeValue(newValue) {
71
86
  const currentValue = DateUtils.validateDate(this.value);
72
87
  const newValueValidated = DateUtils.validateDate(newValue);
@@ -77,10 +92,14 @@ const EzDateInput = class {
77
92
  showCalendar() {
78
93
  this.handleBlur();
79
94
  this._calendar.value = this.value;
80
- //FIXME: Provavelmente isso fará com que o popup abra em uma
81
- //posição errada no futuro. Preferi fazer simples no começo,
82
- //porque não quis onerar o text input com essa funcionalidade...
83
- const top = this.errorMessage || this.mode === "slim" ? 6 : -13;
95
+ let top;
96
+ if (this.isFixed()) {
97
+ top = 29;
98
+ this._calendar.fitHorizontal(0);
99
+ }
100
+ else {
101
+ top = this.errorMessage || this.mode === "slim" ? 6 : -13;
102
+ }
84
103
  this._calendar.fitVertical(top, this._elem.clientHeight);
85
104
  }
86
105
  hideCalendar() {
@@ -88,27 +107,35 @@ const EzDateInput = class {
88
107
  this._calendar.hide();
89
108
  }
90
109
  handleBlur() {
91
- const strValue = this._textInput.value;
92
- const newValue = DateUtils.strToDate(strValue);
93
- if (newValue || !strValue) {
94
- this.errorMessage = "";
95
- const currentValue = DateUtils.validateDate(this.value);
96
- const newValueValidated = DateUtils.validateDate(newValue);
97
- if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
98
- if (newValueValidated) {
99
- this._textInput.value = this.getTextValue(newValueValidated) || '';
100
- this._focused = false;
110
+ try {
111
+ const strValue = this._textInput.value;
112
+ const newValue = DateUtils.strToDate(strValue);
113
+ if (newValue || !strValue) {
114
+ this.errorMessage = "";
115
+ const currentValue = DateUtils.validateDate(this.value);
116
+ const newValueValidated = DateUtils.validateDate(newValue);
117
+ if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) === (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
118
+ if (newValueValidated) {
119
+ this._textInput.value = this.getTextValue(newValueValidated) || '';
120
+ this._focused = false;
121
+ }
122
+ this.ezCancelWaitingChange.emit();
123
+ }
124
+ else {
125
+ this.changeValue(newValueValidated);
101
126
  }
102
- this.ezCancelWaitingChange.emit();
103
127
  }
104
128
  else {
105
- this.changeValue(newValueValidated);
129
+ this.changeValue(undefined);
130
+ this.ezCancelWaitingChange.emit();
131
+ this.errorMessage = "O valor digitado não é uma data válida";
106
132
  }
107
133
  }
108
- else {
109
- this.changeValue(undefined);
110
- this.ezCancelWaitingChange.emit();
111
- this.errorMessage = "O valor digitado não é uma data válida";
134
+ finally {
135
+ for (const callback of this._valuePromiseCallbacks) {
136
+ callback(this.value);
137
+ }
138
+ this._valuePromiseCallbacks = [];
112
139
  }
113
140
  }
114
141
  getTextValue(d) {
@@ -120,6 +147,7 @@ const EzDateInput = class {
120
147
  const currentValue = DateUtils.validateDate(this.value);
121
148
  const newValueValidated = DateUtils.validateDate(newValue);
122
149
  if ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.getTime()) !== (newValueValidated === null || newValueValidated === void 0 ? void 0 : newValueValidated.getTime())) {
150
+ this._changePending = true;
123
151
  this._focused = true;
124
152
  this.ezStartChange.emit({ waitmessage: "", blocking: false });
125
153
  }
@@ -133,13 +161,16 @@ const EzDateInput = class {
133
161
  this._textInput.value = textValue;
134
162
  }
135
163
  }
164
+ isFixed() {
165
+ return this._elem.dataset.isFixed === "true";
166
+ }
136
167
  componentDidLoad() {
137
168
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
138
169
  this.setInputValue();
139
170
  }
140
171
  render() {
141
172
  ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
142
- return (h(Host, null, h("ez-text-input", { "data-element-id": 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 }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
173
+ return (h(Host, null, h("ez-text-input", { "data-element-id": 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 }, h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), h("ez-calendar", { ref: elem => this._calendar = elem, "data-element-id": ElementIDUtils.getInternalIDInfo("calendar"), onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, "data-is-fixed": this._elem.dataset.isFixed })));
143
174
  }
144
175
  get _elem() { return getElement(this); }
145
176
  static get watchers() { return {