@sankhyalabs/ezui 1.1.78 → 1.1.81

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 (153) hide show
  1. package/dist/cjs/{AssetsUtils-dd585fba.js → AssetsUtils-02db4f46.js} +1 -1
  2. package/dist/cjs/ez-action-chip.cjs.entry.js +1 -1
  3. package/dist/cjs/ez-application.cjs.entry.js +1 -1
  4. package/dist/cjs/ez-button_3.cjs.entry.js +520 -0
  5. package/dist/cjs/ez-calendar_14.cjs.entry.js +2598 -0
  6. package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
  7. package/dist/cjs/{ez-button_11.cjs.entry.js → ez-grid.cjs.entry.js} +14 -1410
  8. package/dist/cjs/ez-icon.cjs.entry.js +30 -0
  9. package/dist/cjs/ez-label-chip.cjs.entry.js +1 -1
  10. package/dist/cjs/ez-modal_2.cjs.entry.js +370 -0
  11. package/dist/cjs/ez-popover.cjs.entry.js +2 -2
  12. package/dist/cjs/ez-popup.cjs.entry.js +1 -1
  13. package/dist/cjs/ez-time-input.cjs.entry.js +3 -3
  14. package/dist/cjs/ez-toast.cjs.entry.js +1 -1
  15. package/dist/cjs/ezui.cjs.js +2 -2
  16. package/dist/cjs/{index-4e4bae01.js → index-2003dec4.js} +0 -10
  17. package/dist/cjs/{index-40ebb2be.js → index-4fc4a0a4.js} +86 -63
  18. package/dist/cjs/loader.cjs.js +2 -2
  19. package/dist/collection/collection-manifest.json +0 -2
  20. package/dist/collection/components/ez-form/DataBinder.js +50 -0
  21. package/dist/collection/components/ez-form/ez-form.css +1 -15
  22. package/dist/collection/components/ez-form/ez-form.js +112 -427
  23. package/dist/collection/components/ez-form/fieldbuilder/FieldBuilder.js +46 -0
  24. package/dist/collection/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.js +11 -0
  25. package/dist/collection/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.js +14 -0
  26. package/dist/collection/components/ez-form/fieldbuilder/tpl/DateInput.tpl.js +9 -0
  27. package/dist/collection/components/ez-form/fieldbuilder/tpl/FileInput.tpl.js +5 -0
  28. package/dist/collection/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.js +13 -0
  29. package/dist/collection/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.js +5 -0
  30. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextArea.tpl.js +5 -0
  31. package/dist/collection/components/ez-form/fieldbuilder/tpl/TextInput.tpl.js +5 -0
  32. package/dist/collection/components/ez-form/store/form.slice.js +38 -0
  33. package/dist/collection/components/ez-form/structure/FormItem.js +11 -0
  34. package/dist/collection/components/ez-form/structure/FormSheet.js +5 -0
  35. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +86 -0
  36. package/dist/collection/components/test-du/test-du.js +65 -23
  37. package/dist/custom-elements/index.d.ts +0 -12
  38. package/dist/custom-elements/index.js +462 -2104
  39. package/dist/esm/{AssetsUtils-3803e935.js → AssetsUtils-76ca41e1.js} +1 -1
  40. package/dist/esm/ez-action-chip.entry.js +1 -1
  41. package/dist/esm/ez-application.entry.js +1 -1
  42. package/dist/esm/ez-button_3.entry.js +514 -0
  43. package/dist/esm/ez-calendar_14.entry.js +2581 -0
  44. package/dist/esm/ez-dialog.entry.js +1 -1
  45. package/dist/esm/{ez-button_11.entry.js → ez-grid.entry.js} +4 -1390
  46. package/dist/esm/ez-icon.entry.js +26 -0
  47. package/dist/esm/ez-label-chip.entry.js +1 -1
  48. package/dist/esm/ez-modal_2.entry.js +365 -0
  49. package/dist/esm/ez-popover.entry.js +2 -2
  50. package/dist/esm/ez-popup.entry.js +1 -1
  51. package/dist/esm/ez-time-input.entry.js +3 -3
  52. package/dist/esm/ez-toast.entry.js +1 -1
  53. package/dist/esm/ezui.js +2 -2
  54. package/dist/esm/{index-1dacecd3.js → index-077c7fcf.js} +0 -10
  55. package/dist/esm/{index-ca8700cb.js → index-e31373d9.js} +85 -61
  56. package/dist/esm/loader.js +2 -2
  57. package/dist/ezui/ezui.esm.js +1 -1
  58. package/dist/ezui/{p-516d0e0f.entry.js → p-0a2056d9.entry.js} +1 -1
  59. package/dist/ezui/{p-74f978db.entry.js → p-1c8d64d0.entry.js} +46 -46
  60. package/dist/ezui/p-1e36e3ff.entry.js +1 -0
  61. package/dist/ezui/p-446ec85b.js +1 -0
  62. package/dist/ezui/{p-a18a2d7b.entry.js → p-57ea4b84.entry.js} +1 -1
  63. package/dist/ezui/{p-5a86e18a.entry.js → p-6d157776.entry.js} +1 -1
  64. package/dist/ezui/p-7de3c95d.js +1 -0
  65. package/dist/ezui/p-8b9ef58b.entry.js +1 -0
  66. package/dist/ezui/{p-c6d469fc.entry.js → p-920bb8c9.entry.js} +1 -1
  67. package/dist/ezui/p-983bd291.js +1 -0
  68. package/dist/ezui/p-9dbf569a.entry.js +1 -0
  69. package/dist/ezui/p-a4a39579.entry.js +1 -0
  70. package/dist/ezui/{p-8d6cdd3e.entry.js → p-aef3394b.entry.js} +1 -1
  71. package/dist/ezui/p-d64a3939.entry.js +1 -0
  72. package/dist/ezui/{p-5da66d3e.entry.js → p-da31cd21.entry.js} +1 -1
  73. package/dist/ezui/{p-f3c5f27e.entry.js → p-da63000f.entry.js} +1 -1
  74. package/dist/types/components/ez-form/DataBinder.d.ts +10 -0
  75. package/dist/types/components/ez-form/ez-form.d.ts +25 -32
  76. package/dist/types/components/ez-form/fieldbuilder/FieldBuilder.d.ts +2 -0
  77. package/dist/types/components/ez-form/fieldbuilder/tpl/CheckBox.tpl.d.ts +3 -0
  78. package/dist/types/components/ez-form/fieldbuilder/tpl/ComboBox.tpl.d.ts +4 -0
  79. package/dist/types/components/ez-form/fieldbuilder/tpl/DateInput.tpl.d.ts +8 -0
  80. package/dist/types/components/ez-form/fieldbuilder/tpl/FileInput.tpl.d.ts +4 -0
  81. package/dist/types/components/ez-form/fieldbuilder/tpl/NumberInput.tpl.d.ts +8 -0
  82. package/dist/types/components/ez-form/fieldbuilder/tpl/SearchInput.tpl.d.ts +4 -0
  83. package/dist/types/components/ez-form/fieldbuilder/tpl/TextArea.tpl.d.ts +4 -0
  84. package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +4 -0
  85. package/dist/types/components/ez-form/store/form.slice.d.ts +24 -0
  86. package/dist/types/components/ez-form/structure/FormItem.d.ts +9 -0
  87. package/dist/types/components/ez-form/structure/FormSheet.d.ts +9 -0
  88. package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +27 -0
  89. package/dist/types/components/test-du/test-du.d.ts +8 -2
  90. package/dist/types/components.d.ts +9 -63
  91. package/package.json +2 -2
  92. package/react/components.d.ts +0 -2
  93. package/react/components.js +0 -2
  94. package/react/components.js.map +1 -1
  95. package/dist/cjs/ApplicationUtils-d1c1db56.js +0 -35
  96. package/dist/cjs/DataUnit-fdd7c70e.js +0 -474
  97. package/dist/cjs/DateUtils-716769e0.js +0 -46
  98. package/dist/cjs/ez-calendar.cjs.entry.js +0 -217
  99. package/dist/cjs/ez-collapsible-box_6.cjs.entry.js +0 -634
  100. package/dist/cjs/ez-combo-box.cjs.entry.js +0 -254
  101. package/dist/cjs/ez-date-time-input.cjs.entry.js +0 -133
  102. package/dist/cjs/ez-form.cjs.entry.js +0 -1838
  103. package/dist/cjs/ez-number-input.cjs.entry.js +0 -74
  104. package/dist/cjs/form-metadata.cjs.entry.js +0 -129
  105. package/dist/collection/components/ez-form/assets/trash-can-outline.svg +0 -3
  106. package/dist/collection/components/ez-form/store/Form.actions.js +0 -132
  107. package/dist/collection/components/ez-form/store/Form.reducer.js +0 -194
  108. package/dist/collection/components/ez-form/store/Form.selectors.js +0 -44
  109. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +0 -301
  110. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +0 -8
  111. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +0 -24
  112. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +0 -227
  113. package/dist/collection/components/ez-form/subcomponents/place-holder.js +0 -14
  114. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +0 -95
  115. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +0 -27
  116. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +0 -41
  117. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +0 -37
  118. package/dist/esm/ApplicationUtils-01280a9d.js +0 -33
  119. package/dist/esm/DataUnit-1cd45202.js +0 -464
  120. package/dist/esm/DateUtils-0a1bbd7a.js +0 -44
  121. package/dist/esm/ez-calendar.entry.js +0 -213
  122. package/dist/esm/ez-collapsible-box_6.entry.js +0 -625
  123. package/dist/esm/ez-combo-box.entry.js +0 -250
  124. package/dist/esm/ez-date-time-input.entry.js +0 -129
  125. package/dist/esm/ez-form.entry.js +0 -1834
  126. package/dist/esm/ez-number-input.entry.js +0 -70
  127. package/dist/esm/form-metadata.entry.js +0 -125
  128. package/dist/ezui/assets/trash-can-outline.svg +0 -3
  129. package/dist/ezui/p-14bee38e.entry.js +0 -1
  130. package/dist/ezui/p-37a611ea.js +0 -1
  131. package/dist/ezui/p-3a09c678.entry.js +0 -1
  132. package/dist/ezui/p-43c15c94.entry.js +0 -1
  133. package/dist/ezui/p-7107d7ef.js +0 -1
  134. package/dist/ezui/p-72ff3c95.entry.js +0 -1
  135. package/dist/ezui/p-88f45a83.entry.js +0 -1
  136. package/dist/ezui/p-8f4851a6.js +0 -1
  137. package/dist/ezui/p-9dfd537e.js +0 -1
  138. package/dist/ezui/p-a0331955.entry.js +0 -1
  139. package/dist/ezui/p-a15093e3.entry.js +0 -1
  140. package/dist/ezui/p-a19f2af3.entry.js +0 -1
  141. package/dist/ezui/p-c89629eb.js +0 -1
  142. package/dist/ezui/p-da929c01.js +0 -1
  143. package/dist/types/components/ez-form/store/Form.actions.d.ts +0 -111
  144. package/dist/types/components/ez-form/store/Form.reducer.d.ts +0 -20
  145. package/dist/types/components/ez-form/store/Form.selectors.d.ts +0 -14
  146. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +0 -91
  147. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +0 -24
  148. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +0 -16
  149. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +0 -3
  150. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +0 -11
  151. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +0 -13
  152. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +0 -14
  153. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +0 -19
@@ -0,0 +1,2598 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-2003dec4.js');
6
+ const index$1 = require('./index-4fc4a0a4.js');
7
+ const FloatingManager = require('./FloatingManager-6cfeb947.js');
8
+ const CSSVarsUtils = require('./CSSVarsUtils-66e86394.js');
9
+
10
+ class DateUtils {
11
+ static clearTime(date, adjustDayLightSavingTime = true) {
12
+ const newDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
13
+ return adjustDayLightSavingTime ? DateUtils.adjustDLST(newDate) : newDate;
14
+ }
15
+ static strToDate(strValue, adjustDayLightSavingTime = true, monthYearMode = false) {
16
+ /** monthYearMode é um booleano para usar o formato MM/YYYY.
17
+ * Quando ativado, é retornado o primeiro dia do mês apenas para construir a data.
18
+ * Não há necessidade de verificar o horário de verão quando utilizado esse modo. */
19
+ let parts;
20
+ if (monthYearMode) {
21
+ parts = /^(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
22
+ }
23
+ else {
24
+ parts = /^(3[01]|[1-2]\d|0[1-9]|[1-9])[^\d]?(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
25
+ }
26
+ if (!parts) {
27
+ return undefined;
28
+ }
29
+ var day = monthYearMode ? 1 : Number(parts[1]);
30
+ var month = Number(parts[(monthYearMode ? 1 : 2)]);
31
+ var year = Number(parts[(monthYearMode ? 2 : 3)]);
32
+ var hour = Number(parts[(monthYearMode ? 3 : 4)] || 0);
33
+ var min = Number(parts[(monthYearMode ? 4 : 5)] || 0);
34
+ var sec = Number(parts[(monthYearMode ? 5 : 6)] || 0);
35
+ if (year < 100) {
36
+ year += year < 30 ? 2000 : 1900;
37
+ }
38
+ let date = new Date(year, month - 1, day, hour, min, sec, 0);
39
+ if (adjustDayLightSavingTime === true && !monthYearMode && hour == 0) {
40
+ date = DateUtils.adjustDLST(date);
41
+ }
42
+ return date;
43
+ }
44
+ static adjustDLST(date) {
45
+ //Work around para corrigir o Bug do horário de verão.
46
+ if (date.getHours() == 23) {
47
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 1, 0, 0, 0);
48
+ }
49
+ return date;
50
+ }
51
+ }
52
+
53
+ 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);--ez-calendar__body--border-radius:var(--border--radius-medium, 12px);--ez-calendar__body--shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-calendar__header-line--stroke:2px;--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 var(--space--small, 12px);--ez-calendar__cell--width:var(--space--large, 24px);--ez-calendar__cell--padding:var(--space--extra-small, 3px) 0px;--ez-calendar__cell--border-radius:var(--border--radius-small, 6px);--ez-calendar__cell--over--background-color:var(--color--strokes, #E2F4EF);--ez-calendar__cell--outset--color:var(--color--strokes, #C0C0C0);--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--strokes, #E2F4EF);--ez-calendar__btn-today--border-radius:var(--border--radius-small, 6px);position:relative;display:flex;user-select:none}.calendar{z-index:var(--more-visible, 2);display:flex;flex-direction:column;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--medium, 12px);margin: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--large, 600);font-size:var(--title--medium, 16px);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--small, 12px);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)}.calendar__cell--secondary{color:var(--ez-calendar__cell--outset--color)}.calendar__cell--unselectable:hover{background-color:unset;border-radius:unset;cursor:unset}.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__body{padding:var(--space--small, 6px) 0px}.calendar__footer{display:flex;flex-direction:column}.calendar__btn-today{border:none;background-color:unset;cursor:pointer;font-weight:var(--text-weight--large, 600);font-size:var(--title--small);padding:var(--space--extra-small, 6px);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}.calendarTime{margin-left:-10px;display:flex;flex-direction:column;padding:12px 6px;padding-left:16px;padding-bottom:0px;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:180px;padding:0px;margin:0px;overflow:auto}.calendar__column::-webkit-scrollbar{width:0px;max-width:0px;min-width:0px}.calendarTime__header{padding-left:6px;padding-right:6px;display:flex;justify-content:space-between;padding-bottom:var(--space--medium, 12px);margin:var(--space--small, 6px) var(--space--, 12px);font-weight:var(--text-weight--large, 600);font-size:var(--title--medium, 16px);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);font-family:var(--ez-calendar--font-family);color:var(--ez-calendar--color);text-shadow:var(--ez-calendar--text-shadow)}.separatorTime{color:#A2ABB9}.endHidden{-webkit-mask-image:linear-gradient(180deg, #000 calc(100% - 48px), transparent 100%)}";
54
+
55
+ let EzCalendar = class {
56
+ constructor(hostRef) {
57
+ index.registerInstance(this, hostRef);
58
+ this.ezChange = index.createEvent(this, "ezChange", 7);
59
+ this._firstRender = true;
60
+ this._todayLabel = "Hoje";
61
+ this._weekDayLabels = ["D", "S", "T", "Q", "Q", "S", "S"];
62
+ this._monthLabels = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
63
+ this._hoursLabel = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"];
64
+ this._minutosLabel = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"];
65
+ /**
66
+ * A data selecionada no calendário
67
+ */
68
+ this.value = new Date();
69
+ /**
70
+ * No modo floating o calendário só se tornará visível
71
+ * quando o método show() for acionado.
72
+ */
73
+ this.floating = false;
74
+ /**
75
+ * Exibe ou não as horas e minutos no calendario
76
+ */
77
+ this.time = false;
78
+ /**
79
+ * Exibe ou não os segundos no calendario
80
+ */
81
+ this.showSeconds = false;
82
+ }
83
+ /**
84
+ * Usado no modo floating. Faz com que o componente seja exibido.
85
+ * É possível determinar ajustes de posicionamento através dos parâmetros
86
+ * top, left, bottom e right. Esses parâmetros devem ser informados como
87
+ * strings no formato css.
88
+ */
89
+ async show(top, left, bottom, right) {
90
+ if (this.floating) {
91
+ this._floatingID = FloatingManager.FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
92
+ window.requestAnimationFrame(() => {
93
+ this._box.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
94
+ });
95
+ }
96
+ }
97
+ /**
98
+ * Método necessário para ajustar o posicionamento do calendar acima ou abaixo do ez-date-input conforme a disponibilidade de espaço.
99
+ */
100
+ async fitVertical(topOffset, bottomOffset) {
101
+ const neededHeight = this._container.getBoundingClientRect().bottom + this._calendarHeight;
102
+ const availableBottom = (window.innerHeight || document.documentElement.clientHeight) > neededHeight;
103
+ if (availableBottom) {
104
+ this.show(topOffset + "px", undefined, "unset");
105
+ }
106
+ else {
107
+ this.show("unset", undefined, bottomOffset + "px");
108
+ }
109
+ }
110
+ /**
111
+ * Usado no modo floating. Faz com que o componente seja ocultado.
112
+ */
113
+ async hide() {
114
+ if (this._floatingID !== undefined) {
115
+ FloatingManager.FloatingManager.close(this._floatingID);
116
+ this._floatingID = undefined;
117
+ }
118
+ }
119
+ valueChanged() {
120
+ if (this.value) {
121
+ this._currentPosition.setTime(this.value.getTime());
122
+ this._currentPosition.setDate(1);
123
+ }
124
+ }
125
+ getMonthLabel() {
126
+ return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
127
+ }
128
+ isSelectedDate(d) {
129
+ if (this.value) {
130
+ return this.value.getDate() == d.getDate() && this.value.getMonth() == d.getMonth() && this.value.getFullYear() == d.getFullYear();
131
+ }
132
+ return false;
133
+ }
134
+ changeMonth(offset) {
135
+ this._currentPosition.setMonth(this._currentPosition.getMonth() + offset);
136
+ index.forceUpdate(this);
137
+ }
138
+ selectDate(d) {
139
+ let newDate = d;
140
+ if (this.value && (this.time || this.showSeconds)) {
141
+ newDate.setHours(this.value.getHours());
142
+ newDate.setMinutes(this.value.getMinutes());
143
+ if (this.showSeconds) {
144
+ newDate.setSeconds(this.value.getSeconds());
145
+ }
146
+ else {
147
+ newDate.setSeconds(0);
148
+ }
149
+ }
150
+ this.value = newDate;
151
+ this.ezChange.emit();
152
+ }
153
+ selectHours(hour) {
154
+ if (!this.value) {
155
+ this.value = new Date();
156
+ }
157
+ this.value = new Date(this.value.getFullYear(), this.value.getMonth(), this.value.getDate(), hour, this.value.getMinutes(), this.value.getSeconds());
158
+ this.ezChange.emit();
159
+ }
160
+ selectMinutes(minute) {
161
+ if (!this.value) {
162
+ this.value = new Date();
163
+ }
164
+ this.value = new Date(this.value.getFullYear(), this.value.getMonth(), this.value.getDate(), this.value.getHours(), minute, this.value.getSeconds());
165
+ this.ezChange.emit();
166
+ }
167
+ selectSeconds(second) {
168
+ if (!this.value) {
169
+ this.value = new Date();
170
+ }
171
+ this.value = new Date(this.value.getFullYear(), this.value.getMonth(), this.value.getDate(), this.value.getHours(), this.value.getMinutes(), second);
172
+ this.ezChange.emit();
173
+ }
174
+ updateScroll(element) {
175
+ if (element) {
176
+ const { scrollHeight, clientHeight, scrollTop } = element;
177
+ const remainingScroll = scrollHeight - clientHeight - Math.ceil(scrollTop);
178
+ if (remainingScroll > 0) {
179
+ element.classList.add("endHidden");
180
+ }
181
+ else {
182
+ element.classList.remove("endHidden");
183
+ }
184
+ }
185
+ }
186
+ componentDidRender() {
187
+ if (this.floating && this._firstRender) {
188
+ this._calendarHeight = this._box.clientHeight;
189
+ this._box.remove();
190
+ this._firstRender = false;
191
+ }
192
+ this.updateScroll(this._hoursScroll);
193
+ this.updateScroll(this._minutesScroll);
194
+ this.updateScroll(this._secondsScroll);
195
+ }
196
+ componentDidLoad() {
197
+ if (this.time || this.showSeconds) {
198
+ this._hoursScroll.scrollTop = this._hoursSelect.offsetTop - 64;
199
+ this._minutesScroll.scrollTop = this._minutesSelect.offsetTop - 64;
200
+ if (this.showSeconds) {
201
+ this._secondsScroll.scrollTop = this._secondsSelect.offsetTop - 64;
202
+ }
203
+ }
204
+ }
205
+ render() {
206
+ if (this._currentPosition == null) {
207
+ this._currentPosition = new Date();
208
+ if (this.value) {
209
+ this._currentPosition.setTime(this.value.getTime());
210
+ }
211
+ this._currentPosition.setDate(1);
212
+ }
213
+ const firstDate = new Date();
214
+ firstDate.setTime(this._currentPosition.getTime());
215
+ firstDate.setDate(1 - firstDate.getDay());
216
+ return (index.h("section", { ref: elem => this._container = elem }, index.h("div", { ref: elem => this._box = elem, style: { display: 'flex' } }, index.h("div", { class: "calendar" }, index.h("div", { class: "calendar__header" }, index.h("button", { class: "calendar__btn-previous", onClick: () => this.changeMonth(-1) }), index.h("label", { class: "calendar__lbl-month" }, this.getMonthLabel()), index.h("button", { class: "calendar__btn-next", onClick: () => this.changeMonth(1) })), index.h("div", { class: "calendar__body" }, index.h("div", { class: "calendar__line" }, this._weekDayLabels.map(day => index.h("div", { class: "calendar__cell calendar__cell--unselectable" }, day))), [0, 7, 14, 21, 28, 35].map(offset => index.h("div", { class: "calendar__line" }, [0, 1, 2, 3, 4, 5, 6].map(index$1 => {
217
+ const date = new Date();
218
+ date.setTime(firstDate.getTime());
219
+ date.setDate(date.getDate() + offset + index$1);
220
+ let classNames = "calendar__cell";
221
+ if (this._currentPosition.getMonth() != date.getMonth()) {
222
+ classNames += " calendar__cell--secondary";
223
+ }
224
+ else if (this.isSelectedDate(date)) {
225
+ classNames += " calendar__cell--selected";
226
+ }
227
+ return index.h("div", { class: classNames, onClick: () => this.selectDate(date) }, date.getDate());
228
+ })))), index.h("div", { class: "calendar__footer" }, index.h("button", { class: "calendar__btn-today", onClick: () => this.selectDate(new Date()) }, this._todayLabel))), (this.time || this.showSeconds) &&
229
+ index.h("div", { class: "calendarTime" }, index.h("div", { class: "calendarTime__header" }, index.h("div", null, "H"), index.h("div", { class: "separatorTime" }, ":"), index.h("div", null, "M"), this.showSeconds &&
230
+ index.h("div", { class: "separatorTime" }, ":"), this.showSeconds &&
231
+ index.h("div", null, "S")), index.h("div", { class: "calendar__body ", style: { display: 'flex', paddingLeft: '6px', paddingRight: '6px' } }, index.h("div", { class: "calendar__column", ref: elem => this._hoursScroll = elem, onScroll: () => this.updateScroll(this._hoursScroll) }, this._hoursLabel.map((offset, index$1) => {
232
+ if (index$1 === this.value.getHours()) {
233
+ return (index.h("div", { style: { display: 'flex' }, ref: elem => this._hoursSelect = elem }, index.h("div", { class: "calendar__cell calendar__cell--selected", onClick: () => this.selectHours(index$1) }, offset), index.h("div", { class: "separatorTime" }, ":")));
234
+ }
235
+ else {
236
+ return (index.h("div", { style: { display: 'flex' } }, index.h("div", { class: "calendar__cell", onClick: () => this.selectHours(index$1) }, offset), index.h("div", { class: "separatorTime" }, ":")));
237
+ }
238
+ })), index.h("div", { class: "calendar__column", ref: elem => this._minutesScroll = elem, onScroll: () => this.updateScroll(this._minutesScroll) }, this._minutosLabel.map((offset, index$1) => {
239
+ if (index$1 === this.value.getMinutes()) {
240
+ return (index.h("div", { style: { display: 'flex' }, ref: elem => this._minutesSelect = elem }, index.h("div", { class: "calendar__cell calendar__cell--selected", onClick: () => this.selectMinutes(index$1) }, offset), this.showSeconds && index.h("div", { class: "separatorTime" }, ":")));
241
+ }
242
+ else {
243
+ return (index.h("div", { style: { display: 'flex' } }, index.h("div", { class: "calendar__cell", onClick: () => this.selectMinutes(index$1) }, offset), this.showSeconds && index.h("div", { class: "separatorTime" }, ":")));
244
+ }
245
+ })), this.showSeconds &&
246
+ index.h("div", { class: "calendar__column", ref: elem => this._secondsScroll = elem, onScroll: () => this.updateScroll(this._secondsScroll) }, this._minutosLabel.map((offset, index$1) => {
247
+ if (index$1 === this.value.getSeconds()) {
248
+ return (index.h("div", { class: "calendar__cell calendar__cell--selected", onClick: () => this.selectSeconds(index$1), ref: elem => this._secondsSelect = elem }, offset));
249
+ }
250
+ else {
251
+ return (index.h("div", { class: "calendar__cell", onClick: () => this.selectSeconds(index$1) }, offset));
252
+ }
253
+ })))))));
254
+ }
255
+ static get watchers() { return {
256
+ "value": ["valueChanged"]
257
+ }; }
258
+ };
259
+ EzCalendar.style = ezCalendarCss;
260
+
261
+ const ezCheckCss = ":host{--ez-check--box--width:18px;--ez-check--box--height:18px;--ez-check--width:calc(var(--ez-check--box--width) + 14px);--ez-check--height:calc(var(--ez-check--box--width) + 14px);--ez-check--border-radius:var(--border--radius-small);--ez-check--checked--background-color:var(--color--primary-200);--ez-check--focus--background-color:var(--color--strokes, #FFFFFF);--ez-check--hover--background-color:var(--background--medium);--ez-check--checked--disabled--background-color:var(--color--disable-secondary);--ez-check--border:var(--border--medium) var(--title--primary);--ez-check--disabled--border:var(--border--medium) var(--color--strokes);--ez-check--checked--border:var(--border--medium) var(--color--primary);--ez-check--checked--hover--background-color:var(--color--primary-200);--ez-check--checked--focus--background-color:var(--color--primary-300, #FFFFFF);--ez-check--check--image:url('data:image/svg+xml;utf8,<svg width=\"8\" height=\"7\" viewBox=\"0 0 8 7\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7.70002 0.398999L7.48502 0.207997C7.31524 0.0598858 7.09376 -0.0150438 6.86894 -0.000430025C6.64411 0.0141838 6.43419 0.117153 6.28502 0.285997L2.70002 4.332L1.61802 3.384C1.44837 3.23576 1.22697 3.16067 1.00214 3.17509C0.77732 3.18952 0.567332 3.2923 0.418019 3.461L0.229019 3.674C0.0752361 3.84797 -0.00437434 4.07521 0.00721192 4.30713C0.0187982 4.53904 0.120661 4.75722 0.291019 4.915L2.27402 6.762C2.35832 6.8432 2.45842 6.90618 2.56811 6.94702C2.67779 6.98787 2.79471 7.00571 2.91159 6.99942C3.02846 6.99314 3.14279 6.96287 3.24747 6.91049C3.35214 6.85812 3.44492 6.78477 3.52002 6.695L7.79102 1.638C7.94063 1.46048 8.01486 1.23149 7.99786 0.999963C7.98085 0.768436 7.87396 0.552749 7.70002 0.398999Z\"/></svg>');--ez-check--check--background-color:var(--color--primary);--ez-check--check--disabled--background-color:var(--color--strokes);--ez-switch--slider--width:34px;--ez-switch--slider--height:14px;--ez-switch--pin--width:20px;--ez-switch--pin--height:20px;--ez-switch--focus--width:32px;--ez-switch--focus--height:32px;--ez-switch--background-color:var(--color--strokes);--ez-switch--disabled--background-color:var(--color--disable-secondary);--ez-switch--checked--background-color:var(--color--primary-300);--ez-switch--pin--background-color:var(--background--xlight);--ez-switch--pin--disabled--background-color:var(--color--disable-secondary);--ez-switch--pin--checked--background-color:var(--color--primary);--ez-switch--pin--checked--disabled--background-color:#E8F7F4;--ez-switch--pin--focus--background-color:var(--text--disable);--ez-switch--pin--checked--focus--background-color:var(--color--primary);--ez-check--label--font-size:var(--text--medium, 14px);--ez-check--label--font-family:var(--font-pattern, Arial);--ez-check--label--color:var(--title--primary, #000);--ez-check--label--disabled--color:var(--text--disable, #AFB6C0);display:flex;width:100%;align-items:center;margin:0}input.regularMode{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;box-sizing:border-box;-webkit-appearance:none;appearance:none;cursor:pointer;border-radius:50%;position:relative;width:var(--ez-check--width);height:var(--ez-check--height)}input.regularMode:enabled:hover{background-color:var(--ez-check--hover--background-color)}input.regularMode:enabled:focus{outline:none;background-color:var(--ez-check--focus--background-color)}input.regularMode:disabled{cursor:auto;background:none}input.regularMode::before{box-sizing:border-box;content:\"\";display:block;width:var(--ez-check--box--width);height:var(--ez-check--box--height);border-radius:var(--ez-check--border-radius);border:var(--ez-check--border)}input.regularMode:disabled::before{border:var(--ez-check--disabled--border)}input.regularMode:checked:enabled:hover{background-color:var(--ez-check--checked--hover--background-color)}input.regularMode:checked:enabled:focus{background-color:var(--ez-check--checked--focus--background-color)}input.regularMode:checked::before{border:var(--ez-check--checked--border);background-color:var(--ez-check--checked--background-color)}input.regularMode:checked:disabled:before{border:var(--ez-check--disabled--border);background-color:var(--ez-check--checked--disabled--background-color)}input.regularMode:checked::after{display:flex;position:absolute;content:\"\";background-color:var(--ez-check--check--background-color);width:8px;height:7px;-webkit-mask-image:var(--ez-check--check--image);mask-image:var(--ez-check--check--image)}input.regularMode:checked:disabled::after{background-color:var(--ez-check--check--disabled--background-color)}input.switchMode{flex-shrink:0;-webkit-appearance:none;appearance:none;position:relative;outline:none;cursor:pointer;border-radius:20px;border:none;transition:background-color var(--transition);width:var(--ez-switch--slider--width);height:var(--ez-switch--slider--height);background-color:var(--ez-switch--background-color)}input.switchMode:disabled{background-color:var(--ez-switch--disabled--background-color)}input.switchMode::after{content:\"\";display:block;position:absolute;box-shadow:var(--shadow);transition:transform var(--transition);transition:background-color var(--transition);transform:translateY(-3px);border-radius:50%;width:var(--ez-switch--pin--width);height:var(--ez-switch--pin--height);background-color:var(--ez-switch--pin--background-color)}input.switchMode:disabled::after{background-color:var(--ez-switch--pin--disabled--background-color)}input.switchMode:checked{transition:background-color var(--transition);background-color:var(--ez-switch--checked--background-color)}input.switchMode::before{display:block;content:\"\";display:block;position:absolute;border-radius:50%;opacity:0;width:var(--ez-switch--focus--width);height:var(--ez-switch--focus--height);top:calc((var(--ez-switch--slider--height) - var(--ez-switch--focus--height)) / 2);left:calc((var(--ez-switch--pin--width) - var(--ez-switch--focus--width))/2);background-color:var(--ez-switch--pin--focus--background-color)}input.switchMode:focus::before{opacity:0.24;transition:opacity var(--transition)}input.switchMode:checked:focus::before{background-color:var(--ez-switch--pin--checked--focus--background-color);transform:translateX(calc(var(--ez-switch--slider--width) - var(--ez-switch--pin--width)))}input.switchMode:checked::after{transition:transform var(--transition);transition:background-color var(--transition);transform:translateX(calc(var(--ez-switch--slider--width) - var(--ez-switch--pin--width))) translateY(-3px);box-shadow:var(--shadow);background-color:var(--ez-switch--pin--checked--background-color)}input.switchMode:checked:disabled::after{background-color:var(--ez-switch--pin--checked--disabled--background-color)}.label{flex-shrink:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-check--label--color);text-shadow:var(--text-shadow);font-size:var(--ez-check--label--font-size);font-family:var(--ez-check--label--font-family);cursor:default;padding-left:var(--space--small)}.label--disabled{color:var(--ez-check--label--disabled--color)}";
262
+
263
+ let EzCheck = class {
264
+ constructor(hostRef) {
265
+ index.registerInstance(this, hostRef);
266
+ this.ezChange = index.createEvent(this, "ezChange", 7);
267
+ /**
268
+ * Deixa o campo disponível ou não para interação com o usuário.
269
+ */
270
+ this.enabled = true;
271
+ /**
272
+ * Existem dois modos de visualização: regular e switch.
273
+ * Se esta propriedade for omitida, o componete assume o formato "regular".
274
+ * No modo "regular" a visualização é a tradicional de uma caixinha marcada/desmarcada.
275
+ * No modo "switch" o campo tem uma interface em formato de um pino liga/desliga.
276
+ */
277
+ this.mode = "regular";
278
+ }
279
+ adjustMode() {
280
+ if (this.mode === "switch") {
281
+ this._inputElem.classList.remove("regularMode");
282
+ this._inputElem.classList.add("switchMode");
283
+ }
284
+ else {
285
+ this._inputElem.classList.remove("switchMode");
286
+ this._inputElem.classList.add("regularMode");
287
+ }
288
+ }
289
+ //---------------------------------------------
290
+ // Public methods
291
+ //---------------------------------------------
292
+ /**
293
+ * Devolve o modo escolhido para o componente
294
+ */
295
+ async getMode() {
296
+ return this.mode;
297
+ }
298
+ /**
299
+ * Faz o foco no componente de input
300
+ */
301
+ async setFocus() {
302
+ this._inputElem.focus();
303
+ }
304
+ componentDidLoad() {
305
+ this.adjustMode();
306
+ }
307
+ changeValue() {
308
+ this.value = !this.value;
309
+ this.ezChange.emit(this.value);
310
+ }
311
+ getLabelClasses() {
312
+ let classes = "label";
313
+ if (!this.enabled) {
314
+ classes += " label--disabled";
315
+ }
316
+ return classes;
317
+ }
318
+ render() {
319
+ return (index.h(index.Host, null, index.h("input", { type: "checkbox", class: "regularMode", checked: this.value === true, onChange: () => { this.changeValue(); }, disabled: !this.enabled, ref: (el) => this._inputElem = el }), this.label ? index.h("label", { class: this.getLabelClasses(), onClick: () => { this.changeValue(); }, title: this.label }, this.label) : undefined));
320
+ }
321
+ static get watchers() { return {
322
+ "mode": ["adjustMode"]
323
+ }; }
324
+ };
325
+ EzCheck.style = ezCheckCss;
326
+
327
+ const ezCollapsibleBoxCss = ":host{--ez-collapsible-box--height:42px;--ez-collapsible-box--font-size:var(--title--medium, 14px);--ez-collapsible-box--font-family:var(--font-pattern, Arial);--ez-collapsible-box--font-weight:var(--text-weight--large, 600);--ez-collapsible-box--color:var(--title--primary);--ez-collapsible-box__btn--image--xsmall:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"12px\" width=\"7.5px\"><path d=\"M 0,10.56 4.5967752,6.0000006 0,1.3800006 1.4516132,0 7.5,6.0000006 1.4516132,12 Z\"/></svg>');--ez-collapsible-box__btn--image--small:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"14px\" width=\"8.68px\"><path d=\"M 0,12.32 5.3200012,7.0000007 0,1.6100007 1.6800004,0 8.68,7.0000007 1.6800004,14 Z\"/></svg>');--ez-collapsible-box__btn--image--medium: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-collapsible-box__btn--image--large:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"18px\" width=\"11.25px\"><path d=\"M 0,15.84 6.8951628,9.0000009 0,2.0700009 2.1774198,0 11.25,9.0000009 2.1774198,18 Z\"/></svg>');--ez-collapsible-box__btn--image--xlarge:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"20px\" width=\"12.5px\"><path d=\"M 0,17.6 7.661292,10.000001 0,2.300001 2.4193553,0 12.5,10.000001 2.4193553,20 Z\"/></svg>');--ez-collapsible-box__btn--fill:var(--ez-collapsible-box--color);--ez-collapsible-box__btn--width:10px;--ez-collapsible-box__btn--height:16px;display:flex;flex-wrap:wrap;width:100%}.collapsible-box__title{width:100%;align-self:center;display:flex;box-sizing:border-box}.collapsible-box__label{white-space:nowrap;overflow:hidden;cursor:pointer;text-overflow:ellipsis;width:100%;font-family:var(--ez-collapsible-box--font-family);font-size:var(--ez-collapsible-box--font-size);font-weight:var(--ez-collapsible-box--font-weight);color:var(--ez-collapsible-box--color)}.collapsible-box__label--icon-right{white-space:nowrap;overflow:hidden;cursor:pointer;text-overflow:ellipsis;font-family:var(--ez-collapsible-box--font-family);font-size:var(--ez-collapsible-box--font-size);font-weight:var(--ez-collapsible-box--font-weight);color:var(--ez-collapsible-box--color)}.collapsible-box__btn{outline:none;border:none;background-color:unset;cursor:pointer;padding:1px 6px}.collapsible-box__btn::after{content:'';display:flex;background-color:var(--ez-collapsible-box__btn--fill);width:var(--ez-collapsible-box__btn--width);height:var(--ez-collapsible-box__btn--height);transition:transform var(--transition);transform:rotate(90deg)}.collapsible-box__btn--xsmall::after{width:7.5px;height:12px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--xsmall);mask-image:var(--ez-collapsible-box__btn--image--xsmall)}.collapsible-box__btn--small::after{width:8.68px;height:14px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--small);mask-image:var(--ez-collapsible-box__btn--image--small)}.collapsible-box__btn--medium::after{width:10px;height:16px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--medium);mask-image:var(--ez-collapsible-box__btn--image--medium)}.collapsible-box__btn--large::after{width:11.25px;height:18px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--large);mask-image:var(--ez-collapsible-box__btn--image--large)}.collapsible-box__btn--xlarge::after{width:12.5px;height:20px;-webkit-mask-image:var(--ez-collapsible-box__btn--image--xlarge);mask-image:var(--ez-collapsible-box__btn--image--xlarge)}.collapsible-box__btn--collapsed::after{transform:rotate(0deg)}.font--xsmall{font-size:10px}.font--small{font-size:12px}.font--medium{font-size:14px}.font--large{font-size:16px}.font--xlarge{font-size:20px}";
328
+
329
+ let EzCollapsibleBox = class {
330
+ constructor(hostRef) {
331
+ index.registerInstance(this, hostRef);
332
+ this.ezChange = index.createEvent(this, "ezChange", 7);
333
+ /**
334
+ * Valor externalizado que garante a exibição ou não do componente
335
+ */
336
+ this.value = false;
337
+ /**
338
+ * Define o tamanho do texto e do ícone do componente.
339
+ */
340
+ this.headerSize = "small";
341
+ /**
342
+ * Define o local onde o ícone será renderizado.
343
+ */
344
+ this.iconPlacement = "left";
345
+ }
346
+ observeValue() {
347
+ this.ezChange.emit();
348
+ }
349
+ /**
350
+ * Esconde ou revela o conteúdo do componente
351
+ */
352
+ async showHide() {
353
+ this.value = !this.value;
354
+ }
355
+ render() {
356
+ return (index.h(index.Host, null, this.iconPlacement == "right" ?
357
+ index.h("div", { class: "collapsible-box__title" }, index.h("label", { class: (this.iconPlacement == "right" ? "collapsible-box__label--icon-right " : "collapsible-box__label ") + (this.headerSize ? "font--" + this.headerSize : ""), onClick: () => this.showHide(), title: this.label }, this.label), index.h("button", { class: this.value ? "collapsible-box__btn collapsible-box__btn--collapsed " + "collapsible-box__btn--" + this.headerSize : "collapsible-box__btn " + "collapsible-box__btn--" + this.headerSize, onClick: () => this.showHide() }))
358
+ :
359
+ index.h("div", { class: "collapsible-box__title" }, index.h("button", { class: this.value ? "collapsible-box__btn collapsible-box__btn--collapsed " + "collapsible-box__btn--" + this.headerSize : "collapsible-box__btn " + "collapsible-box__btn--" + this.headerSize, onClick: () => this.showHide() }), index.h("label", { class: (this.iconPlacement == "right" ? "collapsible-box__label--icon-right " : "collapsible-box__label ") + (this.headerSize ? "font--" + this.headerSize : ""), onClick: () => this.showHide(), title: this.label }, this.label)), !this.value ? index.h("slot", null) : null));
360
+ }
361
+ static get watchers() { return {
362
+ "value": ["observeValue"]
363
+ }; }
364
+ };
365
+ EzCollapsibleBox.style = ezCollapsibleBoxCss;
366
+
367
+ const ezComboBoxCss = ":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn-search--background-color:var(--text--primary, #626e82);--ez-combo-box__btn-search-disabled--background-color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-search-hover--background-color:var(--color--primary, #4e4e4e);--ez-combo-box__btn-options--background-color:var(--text--primary, #626e82);--ez-combo-box__btn-options-disabled--background-color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-options-hover--background-color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #919191);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium));--ez-combo-box__drop-down-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"16px\"><path d=\"M 1.8585859,3.0707069 7.9999998,9.2121212 14.141414,3.0707069 16,5.0101006 7.9999998,12.929293 0,4.9292932 Z\"/></svg>');--ez-combo-box__search-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"22px\" width=\"22px\"><path d=\"m 9.4,2.3 c 4.1,0 7.4,3.2 7.4,7.2 0,1.8 -0.7,3.4 -1.8,4.7 l 0.3,0.3 h 0.9 l 5.7,5.6 -1.7,1.7 -5.7,-5.6 V 15.3 L 14.3,15 C 13,16.1 11.3,16.7 9.5,16.7 5.3,16.7 2,13.5 2,9.5 2,5.5 5.3,2.3 9.4,2.3 m 0,2.2 c -2.9,0 -5.1,2.2 -5.1,5 0,2.8 2.3,5 5.1,5 2.8,0 5.1,-2.2 5.1,-5 0,-2.8 -2.2,-5 -5.1,-5 z\"/></svg>');--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}.list-container{position:relative;width:100%}.options-list{box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);display:flex;flex-direction:column;background-color:var(--ez-combo-box--background-color--xlight);padding:var(--ez-combo-box--space--small);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);scroll-behavior:smooth;max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small));overflow:auto}.item{text-align:left;display:flex;justify-content:space-between;align-items:center;border-radius:var(--ez-combo-box--border-radius-small);padding:0 var(--ez-combo-box--space--small);list-style-type:none;min-height:var(--ez-combo-box__list-height)}.item--label{text-align:left;flex-basis:85%;flex-grow:1;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.item--value{text-align:right;flex-basis:15%;flex-grow:0;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large);font-family:var(--ez-combo-box--font-family);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn-open-options{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-options:disabled{cursor:unset}.btn-open-options::after{content:'';display:flex;background-color:var(--ez-combo-box__btn-options--background-color);width:16px;height:16px;-webkit-mask-image:var(--ez-combo-box__drop-down-image);mask-image:var(--ez-combo-box__drop-down-image)}.btn-open-options:disabled:after{background-color:var(--ez-combo-box__btn-options-disabled--background-color)}.btn-open-options:enabled:hover::after{background-color:var(--ez-combo-box__btn-options-hover--background-color)}.btn-open-search{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-search:disabled{cursor:unset}.btn-open-search::after{content:'';display:flex;background-color:var(--ez-combo-box__btn-search--background-color);width:22px;height:22px;-webkit-mask-image:var(--ez-combo-box__search-image);mask-image:var(--ez-combo-box__search-image)}.btn-open-search:disabled:after{background-color:var(--ez-combo-box__btn-search-disabled--background-color)}.btn-open-search:enabled:hover::after{background-color:var(--ez-combo-box__btn-search-hover--background-color)}";
368
+
369
+ let EzComboBox = class {
370
+ constructor(hostRef) {
371
+ index.registerInstance(this, hostRef);
372
+ this.ezChange = index.createEvent(this, "ezChange", 7);
373
+ /**
374
+ * Deixa o campo disponível ou não para interação com usuário.
375
+ */
376
+ this.enabled = true;
377
+ /**
378
+ * Ajusta a opção de mostrar o "value" ao selecionar uma opção. Por padrão não mostra.
379
+ */
380
+ this.showSelectedValue = false;
381
+ /**
382
+ * Ajusta a opção de mostrar o "value" para cada opção. Por padrão não mostra
383
+ */
384
+ this.showOptionValue = false;
385
+ }
386
+ internalUpdate() {
387
+ if (this._inputElement) {
388
+ this._inputElement.value = this.getText();
389
+ }
390
+ this.hideOptions();
391
+ this._criteria = undefined;
392
+ this._preSelection = undefined;
393
+ this.updateVisibleOptions();
394
+ }
395
+ getText() {
396
+ let text = "";
397
+ const selected = this.getSelectedOption();
398
+ if (selected) {
399
+ text = this.showSelectedValue ? `${selected.value} - ${selected.label}` : selected.label;
400
+ }
401
+ return text;
402
+ }
403
+ getSelectedOption() {
404
+ if (typeof this.value === "string" || this.value instanceof String) {
405
+ return this._visibleOptions.find(o => o.value === this.value);
406
+ }
407
+ return this.value;
408
+ }
409
+ updateVisibleOptions() {
410
+ let opts = this._source || [];
411
+ if (!this.searchMode && this._criteria) {
412
+ const upperCriteria = this._criteria.toUpperCase();
413
+ opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(upperCriteria) > -1);
414
+ }
415
+ this._visibleOptions = [{ value: undefined, label: "" }].concat(opts);
416
+ }
417
+ buildItem(opt, index$1) {
418
+ return index.h("li", { class: index$1 === this._preSelection ? "item preselected" : "item", id: `item_${opt.value}`, onMouseDown: () => this.selectOption(opt), onMouseOver: () => this._preSelection = undefined }, index.h("span", { class: "item--label", title: opt.label }, opt.label), this.showOptionValue ? index.h("span", { class: "item--value", title: opt.value }, opt.value) : undefined);
419
+ }
420
+ showOptions() {
421
+ if (!this.enabled) {
422
+ return;
423
+ }
424
+ //FIXME: Provavelmente isso fará com que o popup abra em uma
425
+ //posição errada no futuro. Preferi fazer simples no começo,
426
+ //porque não quis onerar o text input com essa funcionalidade...
427
+ const top = this.errorMessage ? "0px" : "-17px";
428
+ this._floatingID = FloatingManager.FloatingManager.float(this._optionsList, this._listContainer, { autoClose: true, top });
429
+ window.requestAnimationFrame(() => {
430
+ this._optionsList.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
431
+ });
432
+ }
433
+ hideOptions() {
434
+ if (this._floatingID !== undefined) {
435
+ FloatingManager.FloatingManager.close(this._floatingID);
436
+ }
437
+ this._floatingID = undefined;
438
+ }
439
+ isOptionsVisible() {
440
+ return this._floatingID !== undefined && FloatingManager.FloatingManager.isFloating(this._floatingID);
441
+ }
442
+ nextOption() {
443
+ if (this.searchMode && !this.isOptionsVisible()) {
444
+ return;
445
+ }
446
+ this.showOptions();
447
+ this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
448
+ this.scrollToOption(this._visibleOptions[this._preSelection], true);
449
+ }
450
+ previousOption() {
451
+ this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
452
+ this.scrollToOption(this._visibleOptions[this._preSelection], false);
453
+ }
454
+ scrollToOption(opt, down) {
455
+ window.requestAnimationFrame(() => {
456
+ const liElem = this._optionsList.querySelector(`li#item_${opt.value}`);
457
+ if (liElem) {
458
+ const parent = liElem.parentElement;
459
+ const parentRect = parent.getBoundingClientRect();
460
+ const itemRect = liElem.getBoundingClientRect();
461
+ if (down && itemRect.bottom > parentRect.bottom) {
462
+ parent.scrollTop = itemRect.top;
463
+ }
464
+ else if (!down && itemRect.top < parentRect.top) {
465
+ parent.scrollTop = 0;
466
+ }
467
+ }
468
+ });
469
+ }
470
+ selectCurrentOption() {
471
+ if (this._preSelection !== undefined) {
472
+ this.selectOption(this._visibleOptions[this._preSelection]);
473
+ this._preSelection = undefined;
474
+ }
475
+ }
476
+ selectOption(opt) {
477
+ const currentOpt = this.getSelectedOption();
478
+ if (currentOpt !== opt) {
479
+ const adjustedOpt = !(opt === null || opt === void 0 ? void 0 : opt.value) ? undefined : opt;
480
+ this.value = adjustedOpt;
481
+ this.errorMessage = "";
482
+ this.ezChange.emit(adjustedOpt);
483
+ }
484
+ else {
485
+ this.internalUpdate();
486
+ }
487
+ }
488
+ updateSource(source) {
489
+ if (source instanceof Promise) {
490
+ source.then(result => this.updateSource(result));
491
+ this.updateVisibleOptions();
492
+ }
493
+ else {
494
+ this._source = source;
495
+ this.updateVisibleOptions();
496
+ }
497
+ }
498
+ loadOptions(mode, argument = "") {
499
+ this._criteria = argument;
500
+ if (this.optionLoader) {
501
+ this.updateSource(this.optionLoader({ mode, argument }));
502
+ }
503
+ else {
504
+ this.updateSource(this.options);
505
+ }
506
+ }
507
+ cancelPreselection() {
508
+ if (!this._inputElement.value && this.value) {
509
+ this.selectOption(undefined);
510
+ }
511
+ else {
512
+ this.internalUpdate();
513
+ }
514
+ }
515
+ //---------------------------------------------
516
+ // Lifecycle web component
517
+ //---------------------------------------------
518
+ componentWillLoad() {
519
+ if (this.options === undefined) {
520
+ this.options = [];
521
+ const optionsTags = this.el.querySelectorAll("option");
522
+ if (optionsTags) {
523
+ optionsTags.forEach(e => {
524
+ let label = e.innerText;
525
+ let value = e.getAttribute("value");
526
+ if (!value) {
527
+ value = label;
528
+ }
529
+ this.options.push({ label, value });
530
+ e.hidden = true;
531
+ });
532
+ }
533
+ }
534
+ if (this.searchMode) {
535
+ this.updateSource([]);
536
+ }
537
+ else {
538
+ this.loadOptions("PRELOAD");
539
+ }
540
+ }
541
+ componentDidRender() {
542
+ if (this._floatingID === undefined) {
543
+ this._optionsList.remove();
544
+ }
545
+ }
546
+ componentDidLoad() {
547
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this.el, this._inputElement);
548
+ }
549
+ //---------------------------------------------
550
+ // Event handlers
551
+ //---------------------------------------------
552
+ onTextInputChangeHandler(event) {
553
+ if (!this._criteria) {
554
+ this._inputElement.value = event.data;
555
+ }
556
+ const argument = event.target.value;
557
+ this._criteria = argument;
558
+ if (this._criteria) {
559
+ if (this.searchMode) {
560
+ if (this._changeDeboucingTimeout) {
561
+ window.clearTimeout(this._changeDeboucingTimeout);
562
+ }
563
+ this._changeDeboucingTimeout = window.setTimeout(() => {
564
+ this.loadOptions("PREDICTIVE", argument);
565
+ }, 200);
566
+ }
567
+ else {
568
+ this.updateVisibleOptions();
569
+ }
570
+ this.showOptions();
571
+ }
572
+ }
573
+ onTextInputClickHandler() {
574
+ if (!this.searchMode) {
575
+ this.showOptions();
576
+ }
577
+ }
578
+ keyDownHandler(event) {
579
+ switch (event.key) {
580
+ case "ArrowDown":
581
+ this.nextOption();
582
+ break;
583
+ case "ArrowUp":
584
+ this.previousOption();
585
+ break;
586
+ case "Enter":
587
+ this.selectCurrentOption();
588
+ break;
589
+ case "Escape":
590
+ this.cancelPreselection();
591
+ break;
592
+ }
593
+ event.stopPropagation();
594
+ }
595
+ onTextInputFocusOutHandler() {
596
+ this.cancelPreselection();
597
+ }
598
+ render() {
599
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._inputElement = elem, enabled: this.enabled, onInput: evt => this.onTextInputChangeHandler(evt), onClick: () => this.onTextInputClickHandler(), onFocusout: () => this.onTextInputFocusOutHandler(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, value: this.getText(), errorMessage: this.errorMessage }, this.searchMode ?
600
+ index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { this.loadOptions("ADVANCED"); }, slot: "leftIcon" })
601
+ :
602
+ index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), index.h("section", { class: "list-container", ref: elem => this._listContainer = elem }, index.h("div", { class: "options-list", ref: elem => this._optionsList = elem }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
603
+ }
604
+ get el() { return index.getElement(this); }
605
+ static get watchers() { return {
606
+ "value": ["internalUpdate"]
607
+ }; }
608
+ };
609
+ EzComboBox.style = ezComboBoxCss;
610
+
611
+ 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)}";
612
+
613
+ let EzDateInput = class {
614
+ constructor(hostRef) {
615
+ index.registerInstance(this, hostRef);
616
+ this.ezChange = index.createEvent(this, "ezChange", 7);
617
+ /**
618
+ * Deixa o campo disponível ou não para uso.
619
+ */
620
+ this.enabled = true;
621
+ }
622
+ setLabel() {
623
+ this._textInput.label = this.label;
624
+ }
625
+ setErrorMessage() {
626
+ this._textInput.errorMessage = this.errorMessage;
627
+ }
628
+ applyValueToInput() {
629
+ if (this._textInput) {
630
+ this._textInput.value = this.getTextValue(this.value);
631
+ }
632
+ }
633
+ changeValue(newValue) {
634
+ newValue = newValue == null ? null : DateUtils.clearTime(newValue);
635
+ this._textInput.errorMessage = "";
636
+ if (newValue !== this.value) {
637
+ this.value = newValue;
638
+ this.ezChange.emit();
639
+ }
640
+ }
641
+ showCalendar() {
642
+ this.parseDate();
643
+ this._calendar.value = this.value;
644
+ //FIXME: Provavelmente isso fará com que o popup abra em uma
645
+ //posição errada no futuro. Preferi fazer simples no começo,
646
+ //porque não quis onerar o text input com essa funcionalidade...
647
+ const top = this._textInput.errorMessage ? 0 : -17;
648
+ this._calendar.fitVertical(top, this._elem.clientHeight);
649
+ }
650
+ hideCalendar() {
651
+ this.changeValue(this._calendar.value);
652
+ this._calendar.hide();
653
+ }
654
+ parseDate() {
655
+ const strValue = this._textInput.value;
656
+ const parsedDate = DateUtils.strToDate(strValue);
657
+ if (parsedDate || !strValue) {
658
+ if (this.value === parsedDate) {
659
+ this.changeValue(this.value);
660
+ }
661
+ else {
662
+ this.changeValue(parsedDate);
663
+ }
664
+ }
665
+ else {
666
+ this._textInput.errorMessage = "O valor digitado não é uma data válida";
667
+ }
668
+ }
669
+ getTextValue(d) {
670
+ return d ? new Intl.DateTimeFormat("pt-BR").format(d) : null;
671
+ }
672
+ componentDidLoad() {
673
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
674
+ }
675
+ render() {
676
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
677
+ if (event.key === "H" || event.key === "h")
678
+ this.changeValue(new Date());
679
+ }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errorMessage: this.errorMessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
680
+ }
681
+ get _elem() { return index.getElement(this); }
682
+ static get watchers() { return {
683
+ "label": ["setLabel"],
684
+ "errorMessage": ["setErrorMessage"],
685
+ "value": ["applyValueToInput"]
686
+ }; }
687
+ };
688
+ EzDateInput.style = ezDateInputCss;
689
+
690
+ const ezDateTimeInputCss = ":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)}";
691
+
692
+ let EzDateTimeInput = class {
693
+ constructor(hostRef) {
694
+ index.registerInstance(this, hostRef);
695
+ this.ezChange = index.createEvent(this, "ezChange", 7);
696
+ /**
697
+ * Deixa o campo disponível ou não para uso.
698
+ */
699
+ this.enabled = true;
700
+ /**
701
+ * Exibe ou não os segundos no input
702
+ */
703
+ this.showSeconds = false;
704
+ }
705
+ setLabel() {
706
+ this._textInput.label = this.label;
707
+ }
708
+ setErrorMessage() {
709
+ this._textInput.errorMessage = this.errorMessage;
710
+ }
711
+ applyValueToInput() {
712
+ if (this._textInput) {
713
+ this._textInput.value = this.getTextValue(this.value);
714
+ }
715
+ }
716
+ onChangeKeyDown(ev) {
717
+ const input = this._textInput.shadowRoot.querySelector('input');
718
+ if (ev.key === "H" || ev.key === "h") {
719
+ this.changeValue(new Date());
720
+ }
721
+ else if (ev.shiftKey && ev.key === "Tab") {
722
+ if (input.selectionStart > 0) {
723
+ let selectIni = input.value.lastIndexOf(" ", input.selectionStart);
724
+ if (selectIni !== -1) {
725
+ input.setSelectionRange(0, selectIni);
726
+ ev.preventDefault();
727
+ }
728
+ }
729
+ }
730
+ else if (ev.key === "Tab") {
731
+ if (input.value.length !== input.selectionEnd) {
732
+ let selectIni = input.value.indexOf(" ", input.selectionEnd);
733
+ selectIni = selectIni === -1 ? input.selectionEnd : selectIni + 1;
734
+ input.setSelectionRange(selectIni, input.value.length);
735
+ ev.preventDefault();
736
+ }
737
+ }
738
+ }
739
+ onFocused() {
740
+ const input = this._textInput.shadowRoot.querySelector('input');
741
+ if (input.selectionStart !== input.selectionEnd) {
742
+ let selectIni = input.value.indexOf(" ", input.selectionStart);
743
+ selectIni = selectIni === -1 ? input.value.length : selectIni;
744
+ input.setSelectionRange(0, selectIni);
745
+ }
746
+ }
747
+ onClicked() {
748
+ const input = this._textInput.shadowRoot.querySelector('input');
749
+ let selectIni = input.value.lastIndexOf(" ", input.selectionEnd);
750
+ selectIni = selectIni === -1 ? 0 : selectIni + 1;
751
+ selectIni = selectIni > input.selectionEnd ? 0 : selectIni;
752
+ let selectFin = selectIni === 0 ? input.value.indexOf(" ") : input.value.length;
753
+ input.setSelectionRange(selectIni, selectFin);
754
+ }
755
+ changeValue(newValue) {
756
+ this._textInput.errorMessage = "";
757
+ if (newValue !== this.value) {
758
+ this.value = newValue;
759
+ this.ezChange.emit();
760
+ }
761
+ }
762
+ showCalendar() {
763
+ const top = this._textInput.errorMessage ? 0 : -17;
764
+ this._calendar.fitVertical(top, this._elem.clientHeight);
765
+ this._calendar.style.visibility = 'inherit';
766
+ }
767
+ parseDate() {
768
+ const strValue = this._textInput.value;
769
+ const partsDateTime = (strValue && strValue.length > 0) ? strValue.split(" ") : [];
770
+ const onlyDate = partsDateTime.length > 0 ? partsDateTime[0] : strValue;
771
+ const onlyTime = partsDateTime[1] ? partsDateTime[1] : "";
772
+ const parsedTime = index$1.TimeFormatter.prepareValue(onlyTime, this.showSeconds);
773
+ const strDateTime = onlyDate + (parsedTime && " " + parsedTime);
774
+ const parsedDate = DateUtils.strToDate(strDateTime);
775
+ if (parsedDate || !strValue) {
776
+ if (this.value === parsedDate) {
777
+ this.changeValue(this.value);
778
+ }
779
+ else {
780
+ this.changeValue(parsedDate);
781
+ }
782
+ }
783
+ else {
784
+ this._textInput.errorMessage = "O valor digitado não é uma data válida";
785
+ }
786
+ }
787
+ getTextValue(d) {
788
+ const options = {
789
+ year: 'numeric', month: 'numeric', day: 'numeric',
790
+ hour: 'numeric', minute: 'numeric'
791
+ };
792
+ const optionsSecond = {
793
+ year: 'numeric', month: 'numeric', day: 'numeric',
794
+ hour: 'numeric', minute: 'numeric', second: 'numeric'
795
+ };
796
+ return d ? (new Intl.DateTimeFormat('pt-BR', this.showSeconds ? optionsSecond : options).format(d)) : null;
797
+ }
798
+ componentDidLoad() {
799
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
800
+ }
801
+ render() {
802
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => { this.onChangeKeyDown(event); }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/: ", enabled: this.enabled, errorMessage: this.errorMessage, onFocus: () => this.onFocused(), onClick: () => this.onClicked() }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.changeValue(this._calendar.value); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem, time: true, showSeconds: this.showSeconds })));
803
+ }
804
+ get _elem() { return index.getElement(this); }
805
+ static get watchers() { return {
806
+ "label": ["setLabel"],
807
+ "errorMessage": ["setErrorMessage"],
808
+ "value": ["applyValueToInput"]
809
+ }; }
810
+ };
811
+ EzDateTimeInput.style = ezDateTimeInputCss;
812
+
813
+ const buildTextArea = ({ name, label }) => {
814
+ return (index.h("div", { class: "col col--sd-12 padding--small", key: name },
815
+ index.h("ez-text-area", { label: label, "data-field-name": name })));
816
+ };
817
+
818
+ const buildTextInput = ({ name, label }) => {
819
+ return (index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
820
+ index.h("ez-text-input", { label: label, "data-field-name": name, key: name })));
821
+ };
822
+
823
+ const buildSwitch = (fieldConfig) => {
824
+ return buildField$1(fieldConfig.name, fieldConfig.label, true);
825
+ };
826
+ const buildCheckBox = (fieldConfig) => {
827
+ return buildField$1(fieldConfig.name, fieldConfig.label, false);
828
+ };
829
+ function buildField$1(fieldName, fieldLabel, switchMode = false) {
830
+ return (index.h("div", { class: "col col--sd-12 col--tb-3 padding--small align--middle padding-bottom--large" },
831
+ index.h("ez-check", { label: fieldLabel, mode: switchMode ? "switch" : "regular", "data-field-name": fieldName, key: fieldName })));
832
+ }
833
+
834
+ const buildComboBox = ({ name, label }, properties) => {
835
+ const prop = properties === null || properties === void 0 ? void 0 : properties.options;
836
+ let options;
837
+ if (typeof prop === "string") {
838
+ const parsed = JSON.parse(prop);
839
+ options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
840
+ }
841
+ else {
842
+ options = prop;
843
+ }
844
+ return (index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
845
+ index.h("ez-combo-box", { label: label, "data-field-name": name, key: name, options: options })));
846
+ };
847
+
848
+ const buildSearch = ({ name, label }) => {
849
+ return (index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
850
+ index.h("ez-search", { label: label, optionLoader: (_argument) => { }, "data-field-name": name, key: name })));
851
+ };
852
+
853
+ const buildFile = ({ name, label }) => {
854
+ return (index.h("div", { class: "col col--sd-12 padding--small" },
855
+ index.h("ez-upload", { label: label, urlUpload: "", requestHeaders: "", maxFiles: 10, "data-field-name": name, key: name })));
856
+ };
857
+
858
+ const buildDate = ({ name, label }) => {
859
+ return (index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
860
+ index.h("ez-date-input", { label: label, "data-field-name": name, key: name })));
861
+ };
862
+ const buildTimeDate = ({ name, label }) => {
863
+ return (index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
864
+ index.h("ez-date-time-input", { label: label, "data-field-name": name, key: name })));
865
+ };
866
+
867
+ const buildDecimal = ({ name, label }, properties) => {
868
+ const precision = Number((properties === null || properties === void 0 ? void 0 : properties.precision) || 2);
869
+ const prettyPrecision = Number((properties === null || properties === void 0 ? void 0 : properties.prettyPrecision) || precision);
870
+ return buildNumeric(name, label, precision, prettyPrecision);
871
+ };
872
+ const buildInteger = ({ name, label }) => {
873
+ return buildNumeric(name, label, 0, 0);
874
+ };
875
+ function buildNumeric(fieldName, fieldLabel, precision, prettyPrecision) {
876
+ return (index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
877
+ index.h("ez-number-input", { label: fieldLabel, precision: precision, prettyPrecision: prettyPrecision, "data-field-name": fieldName, key: fieldName })));
878
+ }
879
+
880
+ const uiBuilders = new Map();
881
+ uiBuilders.set(index$1.UserInterface.LONGTEXT, buildTextArea);
882
+ uiBuilders.set(index$1.UserInterface.CHECKBOX, buildCheckBox);
883
+ uiBuilders.set(index$1.UserInterface.SWITCH, buildSwitch);
884
+ uiBuilders.set(index$1.UserInterface.OPTIONSELECTOR, buildComboBox);
885
+ uiBuilders.set(index$1.UserInterface.SEARCH, buildSearch);
886
+ uiBuilders.set(index$1.UserInterface.FILE, buildFile);
887
+ uiBuilders.set(index$1.UserInterface.DATE, buildDate);
888
+ uiBuilders.set(index$1.UserInterface.DATETIME, buildTimeDate);
889
+ uiBuilders.set(index$1.UserInterface.DECIMALNUMBER, buildDecimal);
890
+ uiBuilders.set(index$1.UserInterface.INTEGERNUMBER, buildInteger);
891
+ const buildField = (field) => {
892
+ const descriptor = field.descriptor;
893
+ const config = Object.assign({}, field.config);
894
+ let builder;
895
+ let props;
896
+ if (descriptor) {
897
+ builder = uiBuilders.get(descriptor.userInterface);
898
+ if (!config.label) {
899
+ config.label = descriptor.label;
900
+ }
901
+ if (!config.name) {
902
+ config.name = descriptor.name;
903
+ }
904
+ if (config.required === undefined) {
905
+ config.required = descriptor.required;
906
+ }
907
+ props = descriptor.properties;
908
+ }
909
+ if (config.required) {
910
+ config.label = `* ${config.label} (obrigatório)`;
911
+ }
912
+ if (!builder) {
913
+ builder = buildTextInput;
914
+ }
915
+ return builder(config, props);
916
+ };
917
+
918
+ const FormItem = ({ source }) => {
919
+ if ("items" in source) {
920
+ const fieldSet = source;
921
+ return index.h("ez-collapsible-box", { label: source.label }, fieldSet.items.map(fi => buildField(fi)));
922
+ }
923
+ else {
924
+ return buildField(source);
925
+ }
926
+ };
927
+
928
+ const FormSheet = ({ store, source }) => {
929
+ return (index.h("div", { class: "box__container" }, source.items.map(item => index.h(FormItem, { store: store, source: item }))));
930
+ };
931
+
932
+ class FormMetadata {
933
+ constructor() {
934
+ this._sheets = new Map();
935
+ this._requiredFields = [];
936
+ }
937
+ getSheet(name) {
938
+ return this._sheets.get(name);
939
+ }
940
+ getAllSheets() {
941
+ return this._sheets;
942
+ }
943
+ addSheet(sheet) {
944
+ this._sheets.set(sheet.name, sheet);
945
+ this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
946
+ }
947
+ getRequiredFields() {
948
+ return this._requiredFields;
949
+ }
950
+ }
951
+ const buildFromDataUnit = (dataUnit) => {
952
+ var _a;
953
+ const unitMD = dataUnit.metadata;
954
+ const metadata = new FormMetadata();
955
+ if (unitMD) {
956
+ const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
957
+ metadata.addSheet({
958
+ label: unitMD.label,
959
+ name: unitMD.name,
960
+ items: visibleFields.map(descriptor => { return { descriptor }; }),
961
+ requiredFields: visibleFields
962
+ .filter(descriptor => descriptor.required)
963
+ .map(descriptor => descriptor.name)
964
+ });
965
+ }
966
+ return metadata;
967
+ };
968
+ const buildFromConfig = (fields, dataUnit) => {
969
+ const sheets = new Map();
970
+ const requiredFields = [];
971
+ fields.forEach(config => {
972
+ if (config.visible !== false) {
973
+ const tab = config.tab || "Geral";
974
+ const descriptor = dataUnit.getField(config.name);
975
+ if (!sheets.has(tab)) {
976
+ sheets.set(tab, new Map());
977
+ }
978
+ let isRequired = false;
979
+ if (config.required === undefined) {
980
+ if (descriptor) {
981
+ isRequired = descriptor.required;
982
+ }
983
+ }
984
+ else {
985
+ isRequired = config.required;
986
+ }
987
+ if (isRequired) {
988
+ requiredFields.push(config.name);
989
+ }
990
+ const tabItens = sheets.get(tab);
991
+ const fieldMD = { config, descriptor };
992
+ const group = config.group;
993
+ if (group) {
994
+ const key = `group::${group}`;
995
+ if (!tabItens.has(key)) {
996
+ tabItens.set(key, { label: group, items: [fieldMD] });
997
+ }
998
+ else {
999
+ tabItens.get(key).items.push(fieldMD);
1000
+ }
1001
+ }
1002
+ else {
1003
+ tabItens.set(config.name, fieldMD);
1004
+ }
1005
+ }
1006
+ });
1007
+ const metadata = new FormMetadata();
1008
+ sheets.forEach((value, key) => {
1009
+ metadata.addSheet({
1010
+ label: key,
1011
+ name: key,
1012
+ items: Array.from(value.values()),
1013
+ requiredFields
1014
+ });
1015
+ });
1016
+ return metadata;
1017
+ };
1018
+
1019
+ /**
1020
+ * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
1021
+ *
1022
+ * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
1023
+ * during build.
1024
+ * @param {number} code
1025
+ */
1026
+ function formatProdErrorMessage(code) {
1027
+ return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
1028
+ }
1029
+
1030
+ // Inlined version of the `symbol-observable` polyfill
1031
+ var $$observable = (function () {
1032
+ return typeof Symbol === 'function' && Symbol.observable || '@@observable';
1033
+ })();
1034
+
1035
+ /**
1036
+ * These are private action types reserved by Redux.
1037
+ * For any unknown actions, you must return the current state.
1038
+ * If the current state is undefined, you must return the initial state.
1039
+ * Do not reference these action types directly in your code.
1040
+ */
1041
+ var randomString = function randomString() {
1042
+ return Math.random().toString(36).substring(7).split('').join('.');
1043
+ };
1044
+
1045
+ var ActionTypes = {
1046
+ INIT: "@@redux/INIT" + randomString(),
1047
+ REPLACE: "@@redux/REPLACE" + randomString(),
1048
+ PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
1049
+ return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
1050
+ }
1051
+ };
1052
+
1053
+ /**
1054
+ * @param {any} obj The object to inspect.
1055
+ * @returns {boolean} True if the argument appears to be a plain object.
1056
+ */
1057
+ function isPlainObject(obj) {
1058
+ if (typeof obj !== 'object' || obj === null) return false;
1059
+ var proto = obj;
1060
+
1061
+ while (Object.getPrototypeOf(proto) !== null) {
1062
+ proto = Object.getPrototypeOf(proto);
1063
+ }
1064
+
1065
+ return Object.getPrototypeOf(obj) === proto;
1066
+ }
1067
+
1068
+ /**
1069
+ * Creates a Redux store that holds the state tree.
1070
+ * The only way to change the data in the store is to call `dispatch()` on it.
1071
+ *
1072
+ * There should only be a single store in your app. To specify how different
1073
+ * parts of the state tree respond to actions, you may combine several reducers
1074
+ * into a single reducer function by using `combineReducers`.
1075
+ *
1076
+ * @param {Function} reducer A function that returns the next state tree, given
1077
+ * the current state tree and the action to handle.
1078
+ *
1079
+ * @param {any} [preloadedState] The initial state. You may optionally specify it
1080
+ * to hydrate the state from the server in universal apps, or to restore a
1081
+ * previously serialized user session.
1082
+ * If you use `combineReducers` to produce the root reducer function, this must be
1083
+ * an object with the same shape as `combineReducers` keys.
1084
+ *
1085
+ * @param {Function} [enhancer] The store enhancer. You may optionally specify it
1086
+ * to enhance the store with third-party capabilities such as middleware,
1087
+ * time travel, persistence, etc. The only store enhancer that ships with Redux
1088
+ * is `applyMiddleware()`.
1089
+ *
1090
+ * @returns {Store} A Redux store that lets you read the state, dispatch actions
1091
+ * and subscribe to changes.
1092
+ */
1093
+
1094
+ function createStore(reducer, preloadedState, enhancer) {
1095
+ var _ref2;
1096
+
1097
+ if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
1098
+ throw new Error(formatProdErrorMessage(0) );
1099
+ }
1100
+
1101
+ if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
1102
+ enhancer = preloadedState;
1103
+ preloadedState = undefined;
1104
+ }
1105
+
1106
+ if (typeof enhancer !== 'undefined') {
1107
+ if (typeof enhancer !== 'function') {
1108
+ throw new Error(formatProdErrorMessage(1) );
1109
+ }
1110
+
1111
+ return enhancer(createStore)(reducer, preloadedState);
1112
+ }
1113
+
1114
+ if (typeof reducer !== 'function') {
1115
+ throw new Error(formatProdErrorMessage(2) );
1116
+ }
1117
+
1118
+ var currentReducer = reducer;
1119
+ var currentState = preloadedState;
1120
+ var currentListeners = [];
1121
+ var nextListeners = currentListeners;
1122
+ var isDispatching = false;
1123
+ /**
1124
+ * This makes a shallow copy of currentListeners so we can use
1125
+ * nextListeners as a temporary list while dispatching.
1126
+ *
1127
+ * This prevents any bugs around consumers calling
1128
+ * subscribe/unsubscribe in the middle of a dispatch.
1129
+ */
1130
+
1131
+ function ensureCanMutateNextListeners() {
1132
+ if (nextListeners === currentListeners) {
1133
+ nextListeners = currentListeners.slice();
1134
+ }
1135
+ }
1136
+ /**
1137
+ * Reads the state tree managed by the store.
1138
+ *
1139
+ * @returns {any} The current state tree of your application.
1140
+ */
1141
+
1142
+
1143
+ function getState() {
1144
+ if (isDispatching) {
1145
+ throw new Error(formatProdErrorMessage(3) );
1146
+ }
1147
+
1148
+ return currentState;
1149
+ }
1150
+ /**
1151
+ * Adds a change listener. It will be called any time an action is dispatched,
1152
+ * and some part of the state tree may potentially have changed. You may then
1153
+ * call `getState()` to read the current state tree inside the callback.
1154
+ *
1155
+ * You may call `dispatch()` from a change listener, with the following
1156
+ * caveats:
1157
+ *
1158
+ * 1. The subscriptions are snapshotted just before every `dispatch()` call.
1159
+ * If you subscribe or unsubscribe while the listeners are being invoked, this
1160
+ * will not have any effect on the `dispatch()` that is currently in progress.
1161
+ * However, the next `dispatch()` call, whether nested or not, will use a more
1162
+ * recent snapshot of the subscription list.
1163
+ *
1164
+ * 2. The listener should not expect to see all state changes, as the state
1165
+ * might have been updated multiple times during a nested `dispatch()` before
1166
+ * the listener is called. It is, however, guaranteed that all subscribers
1167
+ * registered before the `dispatch()` started will be called with the latest
1168
+ * state by the time it exits.
1169
+ *
1170
+ * @param {Function} listener A callback to be invoked on every dispatch.
1171
+ * @returns {Function} A function to remove this change listener.
1172
+ */
1173
+
1174
+
1175
+ function subscribe(listener) {
1176
+ if (typeof listener !== 'function') {
1177
+ throw new Error(formatProdErrorMessage(4) );
1178
+ }
1179
+
1180
+ if (isDispatching) {
1181
+ throw new Error(formatProdErrorMessage(5) );
1182
+ }
1183
+
1184
+ var isSubscribed = true;
1185
+ ensureCanMutateNextListeners();
1186
+ nextListeners.push(listener);
1187
+ return function unsubscribe() {
1188
+ if (!isSubscribed) {
1189
+ return;
1190
+ }
1191
+
1192
+ if (isDispatching) {
1193
+ throw new Error(formatProdErrorMessage(6) );
1194
+ }
1195
+
1196
+ isSubscribed = false;
1197
+ ensureCanMutateNextListeners();
1198
+ var index = nextListeners.indexOf(listener);
1199
+ nextListeners.splice(index, 1);
1200
+ currentListeners = null;
1201
+ };
1202
+ }
1203
+ /**
1204
+ * Dispatches an action. It is the only way to trigger a state change.
1205
+ *
1206
+ * The `reducer` function, used to create the store, will be called with the
1207
+ * current state tree and the given `action`. Its return value will
1208
+ * be considered the **next** state of the tree, and the change listeners
1209
+ * will be notified.
1210
+ *
1211
+ * The base implementation only supports plain object actions. If you want to
1212
+ * dispatch a Promise, an Observable, a thunk, or something else, you need to
1213
+ * wrap your store creating function into the corresponding middleware. For
1214
+ * example, see the documentation for the `redux-thunk` package. Even the
1215
+ * middleware will eventually dispatch plain object actions using this method.
1216
+ *
1217
+ * @param {Object} action A plain object representing “what changed”. It is
1218
+ * a good idea to keep actions serializable so you can record and replay user
1219
+ * sessions, or use the time travelling `redux-devtools`. An action must have
1220
+ * a `type` property which may not be `undefined`. It is a good idea to use
1221
+ * string constants for action types.
1222
+ *
1223
+ * @returns {Object} For convenience, the same action object you dispatched.
1224
+ *
1225
+ * Note that, if you use a custom middleware, it may wrap `dispatch()` to
1226
+ * return something else (for example, a Promise you can await).
1227
+ */
1228
+
1229
+
1230
+ function dispatch(action) {
1231
+ if (!isPlainObject(action)) {
1232
+ throw new Error(formatProdErrorMessage(7) );
1233
+ }
1234
+
1235
+ if (typeof action.type === 'undefined') {
1236
+ throw new Error(formatProdErrorMessage(8) );
1237
+ }
1238
+
1239
+ if (isDispatching) {
1240
+ throw new Error(formatProdErrorMessage(9) );
1241
+ }
1242
+
1243
+ try {
1244
+ isDispatching = true;
1245
+ currentState = currentReducer(currentState, action);
1246
+ } finally {
1247
+ isDispatching = false;
1248
+ }
1249
+
1250
+ var listeners = currentListeners = nextListeners;
1251
+
1252
+ for (var i = 0; i < listeners.length; i++) {
1253
+ var listener = listeners[i];
1254
+ listener();
1255
+ }
1256
+
1257
+ return action;
1258
+ }
1259
+ /**
1260
+ * Replaces the reducer currently used by the store to calculate the state.
1261
+ *
1262
+ * You might need this if your app implements code splitting and you want to
1263
+ * load some of the reducers dynamically. You might also need this if you
1264
+ * implement a hot reloading mechanism for Redux.
1265
+ *
1266
+ * @param {Function} nextReducer The reducer for the store to use instead.
1267
+ * @returns {void}
1268
+ */
1269
+
1270
+
1271
+ function replaceReducer(nextReducer) {
1272
+ if (typeof nextReducer !== 'function') {
1273
+ throw new Error(formatProdErrorMessage(10) );
1274
+ }
1275
+
1276
+ currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
1277
+ // Any reducers that existed in both the new and old rootReducer
1278
+ // will receive the previous state. This effectively populates
1279
+ // the new state tree with any relevant data from the old one.
1280
+
1281
+ dispatch({
1282
+ type: ActionTypes.REPLACE
1283
+ });
1284
+ }
1285
+ /**
1286
+ * Interoperability point for observable/reactive libraries.
1287
+ * @returns {observable} A minimal observable of state changes.
1288
+ * For more information, see the observable proposal:
1289
+ * https://github.com/tc39/proposal-observable
1290
+ */
1291
+
1292
+
1293
+ function observable() {
1294
+ var _ref;
1295
+
1296
+ var outerSubscribe = subscribe;
1297
+ return _ref = {
1298
+ /**
1299
+ * The minimal observable subscription method.
1300
+ * @param {Object} observer Any object that can be used as an observer.
1301
+ * The observer object should have a `next` method.
1302
+ * @returns {subscription} An object with an `unsubscribe` method that can
1303
+ * be used to unsubscribe the observable from the store, and prevent further
1304
+ * emission of values from the observable.
1305
+ */
1306
+ subscribe: function subscribe(observer) {
1307
+ if (typeof observer !== 'object' || observer === null) {
1308
+ throw new Error(formatProdErrorMessage(11) );
1309
+ }
1310
+
1311
+ function observeState() {
1312
+ if (observer.next) {
1313
+ observer.next(getState());
1314
+ }
1315
+ }
1316
+
1317
+ observeState();
1318
+ var unsubscribe = outerSubscribe(observeState);
1319
+ return {
1320
+ unsubscribe: unsubscribe
1321
+ };
1322
+ }
1323
+ }, _ref[$$observable] = function () {
1324
+ return this;
1325
+ }, _ref;
1326
+ } // When a store is created, an "INIT" action is dispatched so that every
1327
+ // reducer returns their initial state. This effectively populates
1328
+ // the initial state tree.
1329
+
1330
+
1331
+ dispatch({
1332
+ type: ActionTypes.INIT
1333
+ });
1334
+ return _ref2 = {
1335
+ dispatch: dispatch,
1336
+ subscribe: subscribe,
1337
+ getState: getState,
1338
+ replaceReducer: replaceReducer
1339
+ }, _ref2[$$observable] = observable, _ref2;
1340
+ }
1341
+
1342
+ const inicialState = {};
1343
+ /////////////////////////////// REDUCERS ///////////////////////////////
1344
+ function formReducer(state = inicialState, action) {
1345
+ switch (action.type) {
1346
+ case FormActions.METADATA_LOADED:
1347
+ return Object.assign(Object.assign({}, state), { formMetadata: action.payload });
1348
+ case FormActions.CHANGE_TAB:
1349
+ return Object.assign(Object.assign({}, state), { currentSheet: action.payload });
1350
+ default:
1351
+ return state;
1352
+ }
1353
+ }
1354
+ /////////////////////////////// ACTION CREATORS ///////////////////////////////
1355
+ function loadMetadata(formMetadata) {
1356
+ return {
1357
+ type: FormActions.METADATA_LOADED,
1358
+ payload: formMetadata
1359
+ };
1360
+ }
1361
+ function changeTab(currentSheet) {
1362
+ return {
1363
+ type: FormActions.CHANGE_TAB,
1364
+ payload: currentSheet
1365
+ };
1366
+ }
1367
+ /////////////////////////////// SELECTORS ///////////////////////////////
1368
+ function selectFormMetadata(state) {
1369
+ return state.formMetadata;
1370
+ }
1371
+ function selectCurrentSheet(state) {
1372
+ return state.currentSheet ? state.formMetadata.getSheet(state.currentSheet) : Array.from(state.formMetadata.getAllSheets().values())[0];
1373
+ }
1374
+ /////////////////////////////// TYPES ///////////////////////////////
1375
+ var FormActions;
1376
+ (function (FormActions) {
1377
+ FormActions["METADATA_LOADED"] = "FORM/METADATA_LOADED";
1378
+ FormActions["CHANGE_TAB"] = "FORM/CHANGE_TAB";
1379
+ })(FormActions || (FormActions = {}));
1380
+
1381
+ class DataBinder {
1382
+ constructor(dataUnit) {
1383
+ this._fields = new Map();
1384
+ this._dataUnit = dataUnit;
1385
+ this._dataUnit.subscribe(_action => {
1386
+ var _a;
1387
+ (_a = this._fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
1388
+ this.updateValue(field.fieldName, field.field);
1389
+ });
1390
+ });
1391
+ }
1392
+ bind(fields) {
1393
+ fields.forEach(fieldElement => {
1394
+ const fieldName = fieldElement.dataset.fieldName;
1395
+ this.updateBind(fieldName, fieldElement);
1396
+ this.updateValue(fieldName, fieldElement);
1397
+ });
1398
+ }
1399
+ updateValue(fieldName, field) {
1400
+ field["value"] = this._dataUnit.getFieldValue(fieldName);
1401
+ }
1402
+ updateBind(fieldName, field) {
1403
+ const oldBind = this._fields.get(fieldName);
1404
+ if (oldBind) {
1405
+ oldBind.destroy();
1406
+ }
1407
+ this._fields.set(fieldName, Bind.create(fieldName, field, (fieldName, newValue) => this.setFieldValue(fieldName, newValue)));
1408
+ }
1409
+ setFieldValue(fieldName, newValue) {
1410
+ if (this._dataUnit.records.length === 0) {
1411
+ this._dataUnit.addRecord();
1412
+ }
1413
+ this._dataUnit.setFieldValue(fieldName, newValue);
1414
+ }
1415
+ }
1416
+ class Bind {
1417
+ destroy() {
1418
+ this.field.removeEventListener(this.eventName, this.eventListener);
1419
+ }
1420
+ static create(fieldName, field, callback) {
1421
+ const b = new Bind();
1422
+ b.fieldName = fieldName;
1423
+ b.field = field;
1424
+ //FIXME: Verificar se o field é um EzField
1425
+ b.eventListener = (evt) => { callback(fieldName, evt.detail); };
1426
+ b.eventName = "ezChange";
1427
+ b.field.addEventListener(b.eventName, b.eventListener);
1428
+ return b;
1429
+ }
1430
+ }
1431
+
1432
+ class ApplicationUtils {
1433
+ static async showDialog(title, message, icon = null, confirm, critical = false) {
1434
+ return new Promise(resolve => {
1435
+ let dialog = document.querySelector("ez-dialog");
1436
+ if (!dialog) {
1437
+ dialog = document.createElement("ez-dialog");
1438
+ window.document.body.appendChild(dialog);
1439
+ }
1440
+ dialog.show(title, message, critical, confirm, icon).then(ok => resolve(ok));
1441
+ });
1442
+ }
1443
+ static async alert(title, message, icon = null) {
1444
+ return ApplicationUtils.showDialog(title, message, icon, false, false);
1445
+ }
1446
+ static async error(title, message, icon = null) {
1447
+ return ApplicationUtils.showDialog(title, message, icon, false, true);
1448
+ }
1449
+ static async confirm(title, message, icon = null, critical = false) {
1450
+ return ApplicationUtils.showDialog(title, message, icon, true, critical);
1451
+ }
1452
+ static async info(message) {
1453
+ let toast = document.querySelector("ez-toast");
1454
+ if (!toast) {
1455
+ toast = document.createElement("ez-toast");
1456
+ window.document.body.appendChild(toast);
1457
+ }
1458
+ toast.message = message;
1459
+ toast.fadeTime = 4000;
1460
+ toast.show();
1461
+ }
1462
+ }
1463
+
1464
+ const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}";
1465
+
1466
+ let EzForm = class {
1467
+ constructor(hostRef) {
1468
+ index.registerInstance(this, hostRef);
1469
+ }
1470
+ submit() {
1471
+ return Promise.resolve();
1472
+ }
1473
+ cancel() {
1474
+ return Promise.resolve();
1475
+ }
1476
+ validate() {
1477
+ return new Promise((accept, reject) => {
1478
+ const metadata = selectFormMetadata(this._store.getState());
1479
+ const requiredFields = this._staticFields
1480
+ .filter(f => f.dataset.required)
1481
+ .map(f => f.dataset.fieldName)
1482
+ .concat(metadata.getRequiredFields());
1483
+ const records = this.dataUnit.records;
1484
+ for (let i = 0; i < records.length; i++) {
1485
+ if (!this.validateRequired(requiredFields, records[i])) {
1486
+ reject();
1487
+ break;
1488
+ }
1489
+ }
1490
+ accept();
1491
+ });
1492
+ }
1493
+ validateRequired(requiredFields, record) {
1494
+ const invalidFields = [];
1495
+ requiredFields.forEach(field => {
1496
+ const value = record[field];
1497
+ const fieldElem = this._element.querySelector(`[data-field-name=${field}]`);
1498
+ if (value === null || value === undefined || value === "") {
1499
+ invalidFields.push(field);
1500
+ fieldElem["errorMessage"] = "Essa informação é obrigatória";
1501
+ }
1502
+ else {
1503
+ fieldElem["errorMessage"] = "";
1504
+ }
1505
+ });
1506
+ const isValid = invalidFields.length === 0;
1507
+ if (!isValid) {
1508
+ ApplicationUtils.info("Há pelo menos um campo obrigatório não preenchido.");
1509
+ }
1510
+ return isValid;
1511
+ }
1512
+ getDynamicContent() {
1513
+ var _a;
1514
+ const formMD = selectFormMetadata(this._store.getState());
1515
+ if (!formMD)
1516
+ return null;
1517
+ const currentSheet = selectCurrentSheet((_a = this._store) === null || _a === void 0 ? void 0 : _a.getState());
1518
+ if (!currentSheet) {
1519
+ return null;
1520
+ }
1521
+ const allSheets = Array.from(formMD.getAllSheets().values());
1522
+ const result = [];
1523
+ if (allSheets.length > 1) {
1524
+ result.push(index.h("ez-tabselector", { onEzChange: (evt) => this._store.dispatch(changeTab(evt.detail)), selectedTab: currentSheet.name }, allSheets.map(s => index.h("ez-tab", { tabKey: s.name, label: s.label }))));
1525
+ }
1526
+ result.push(index.h(FormSheet, { store: this._store, source: currentSheet }));
1527
+ return result;
1528
+ }
1529
+ processMetadata() {
1530
+ if (!this.isStatic()) {
1531
+ const metadata = this.config && this.config.length > 0 ? buildFromConfig(this.config, this.dataUnit) : buildFromDataUnit(this.dataUnit);
1532
+ this._store.dispatch(loadMetadata(metadata));
1533
+ }
1534
+ }
1535
+ isStatic() {
1536
+ var _a;
1537
+ return ((_a = this._staticFields) === null || _a === void 0 ? void 0 : _a.length) > 0;
1538
+ }
1539
+ componentWillLoad() {
1540
+ if (this.dataUnit === undefined) {
1541
+ this.dataUnit = new index$1.DataUnit("ez-form");
1542
+ }
1543
+ this.dataUnit.subscribe(action => {
1544
+ if (action.type === index$1.Action.METADATA_LOADED) {
1545
+ this.processMetadata();
1546
+ }
1547
+ });
1548
+ this._dataBinder = new DataBinder(this.dataUnit);
1549
+ this._store = createStore(formReducer);
1550
+ this._store.subscribe(() => index.forceUpdate(this));
1551
+ this._staticFields = Array.from(this._element.querySelectorAll("[data-field-name]"));
1552
+ this.processMetadata();
1553
+ }
1554
+ componentDidRender() {
1555
+ this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")));
1556
+ }
1557
+ render() {
1558
+ return (index.h(index.Host, null, this.isStatic() ? null : this.getDynamicContent()));
1559
+ }
1560
+ get _element() { return index.getElement(this); }
1561
+ };
1562
+ EzForm.style = ezFormCss;
1563
+
1564
+ const ezNumberInputCss = ":host{display:block;width:100%}";
1565
+
1566
+ let EzNumberInput = class {
1567
+ constructor(hostRef) {
1568
+ index.registerInstance(this, hostRef);
1569
+ this.ezChange = index.createEvent(this, "ezChange", 7);
1570
+ /**
1571
+ * Deixa o campo disponível ou não para uso.
1572
+ */
1573
+ this.enabled = true;
1574
+ }
1575
+ setLabel() {
1576
+ this._textInput.label = this.label;
1577
+ }
1578
+ setErrorMessage() {
1579
+ this._textInput.errorMessage = this.errorMessage;
1580
+ }
1581
+ applyValueToInput() {
1582
+ if (this._textInput) {
1583
+ this._textInput.value = this.getTextValue(this.value);
1584
+ }
1585
+ }
1586
+ changeValue(newValue) {
1587
+ this.errorMessage = "";
1588
+ if (newValue && newValue !== this.value) {
1589
+ this.value = newValue;
1590
+ this.ezChange.emit(this.value);
1591
+ }
1592
+ }
1593
+ parseNumber() {
1594
+ const parsedNumber = this._textInput.value ? index$1.NumberUtils.stringToNumber(this._textInput.value) : null;
1595
+ if (parsedNumber != null && isNaN(parsedNumber)) {
1596
+ this.errorMessage = "O valor digitado não é um número válido";
1597
+ }
1598
+ else {
1599
+ try {
1600
+ this.changeValue(parsedNumber);
1601
+ }
1602
+ catch (e) {
1603
+ this.errorMessage = e.message;
1604
+ return;
1605
+ }
1606
+ }
1607
+ }
1608
+ getTextValue(value) {
1609
+ if (value) {
1610
+ return this.precision > 0 ? index$1.NumberUtils.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
1611
+ }
1612
+ return null;
1613
+ }
1614
+ componentDidLoad() {
1615
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
1616
+ }
1617
+ render() {
1618
+ return (index.h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage }));
1619
+ }
1620
+ get _elem() { return index.getElement(this); }
1621
+ static get watchers() { return {
1622
+ "label": ["setLabel"],
1623
+ "errorMessage": ["setErrorMessage"],
1624
+ "value": ["applyValueToInput"]
1625
+ }; }
1626
+ };
1627
+ EzNumberInput.style = ezNumberInputCss;
1628
+
1629
+ const ezSearchCss = ":host{width:100%}";
1630
+
1631
+ let EzSearch = class {
1632
+ constructor(hostRef) {
1633
+ index.registerInstance(this, hostRef);
1634
+ this.ezChange = index.createEvent(this, "ezChange", 7);
1635
+ this.showPopup = index.createEvent(this, "showPopup", 7);
1636
+ /**
1637
+ * Deixa o campo disponível ou não.
1638
+ */
1639
+ this.enabled = true;
1640
+ /**
1641
+ * Ajusta a opção de mostrar o "value" ao selecionar uma opção.
1642
+ */
1643
+ this.showSelectedValue = true;
1644
+ /**
1645
+ * Ajusta a opção de mostrar o "value" para cada opção.
1646
+ */
1647
+ this.showOptionValue = true;
1648
+ }
1649
+ updateValue() {
1650
+ if (this._comboElement) {
1651
+ this._comboElement.value = this.value;
1652
+ }
1653
+ }
1654
+ onComboChange(evt) {
1655
+ evt.stopPropagation();
1656
+ this.value = evt.detail;
1657
+ this.ezChange.emit(evt.detail);
1658
+ }
1659
+ componentDidLoad() {
1660
+ CSSVarsUtils.CSSVarsUtils.applyVarsTextInput(this._elem, this._comboElement);
1661
+ }
1662
+ render() {
1663
+ return (index.h("ez-combo-box", { ref: elem => this._comboElement = elem, value: this.value, label: this.label, enabled: this.enabled, errorMessage: this.errorMessage, optionLoader: this.optionLoader, searchMode: true, onEzChange: evt => this.onComboChange(evt), showSelectedValue: this.showSelectedValue, showOptionValue: this.showOptionValue }));
1664
+ }
1665
+ ;
1666
+ get _elem() { return index.getElement(this); }
1667
+ static get watchers() { return {
1668
+ "value": ["updateValue"]
1669
+ }; }
1670
+ };
1671
+ EzSearch.style = ezSearchCss;
1672
+
1673
+ const ezTabselectorCss = "@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50%)}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px)}}:host{display:flex;position:relative;width:100%;overflow:hidden;--tabselector--backward-icon: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>');--tabselector--forward-icon: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>')}.scroll{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto;scrollbar-width:none}.scroll.startHidden{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px)}.scroll.midle{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px, #000 calc(100% - 48px), transparent calc(100% - 20px))}.scroll.endHidden{-webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab{display:flex;border:none;min-width:100px;background-color:unset;cursor:pointer;padding:6px 12px;align-items:center;justify-content:center;color:var(--text--primary, #626e82);font-family:var(--font-pattern, \"Sora, Algerian\");font-size:var(--title--small, 14px)}.tab:focus,.forward-button,.backward-button{outline:none}.is-active{position:relative;color:var(--color--primary, #008561)}.is-active::after{content:\"\";position:absolute;width:100%;height:100%;background-color:var(--color--primary, #008561);clip-path:inset(calc(100% - 3px) 0px 0px 0px);animation:activate 0.25s ease-in-out}.is-focused{border:1px dashed var(--color--primary, #000000c5)}.tab-label{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--text-shadow);margin-bottom:var(--space--extra-small, 3px)}.forward-button,.backward-button{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.backward-button{left:0px}.forward-button::after,.backward-button::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:10px;height:16px}.forward-button::after{-webkit-mask-image:var(--tabselector--forward-icon);mask-image:var(--tabselector--forward-icon)}.backward-button::after{-webkit-mask-image:var(--tabselector--backward-icon);mask-image:var(--tabselector--backward-icon)}.forward-button:hover::after,.backward-button:hover::after{background-color:var(--color--primary, #4e4e4e)}.hidden{display:none}.scroll::-webkit-scrollbar{display:none}";
1674
+
1675
+ let EzTabselector = class {
1676
+ constructor(hostRef) {
1677
+ index.registerInstance(this, hostRef);
1678
+ this.ezChange = index.createEvent(this, "ezChange", 7);
1679
+ this.setFocusedParam = (ev) => {
1680
+ if (ev.key === "Enter") {
1681
+ this.selectedIndex = this.focusedIndex;
1682
+ this.focusedIndex = undefined;
1683
+ this.selectedTab = this._processedTabs[this.selectedIndex]["tabKey"];
1684
+ this.handleTabClick(this.selectedTab, parseInt(this.selectedIndex));
1685
+ ev.preventDefault();
1686
+ this.setFocusedTab(this.selectedIndex);
1687
+ }
1688
+ else if (ev.key === "ArrowLeft" || ev.key === "ArrowRight") {
1689
+ let operator = undefined;
1690
+ if (ev.key === "ArrowLeft") {
1691
+ operator = false;
1692
+ }
1693
+ else if (ev.key === "ArrowRight") {
1694
+ operator = true;
1695
+ }
1696
+ else {
1697
+ return;
1698
+ }
1699
+ if (this.focusedIndex === undefined) {
1700
+ if (operator === false) {
1701
+ this.focusedIndex = this.selectedIndex !== undefined ? (parseInt(this.selectedIndex) - 1).toString() : undefined;
1702
+ }
1703
+ else {
1704
+ this.focusedIndex = this.selectedIndex !== undefined ? (parseInt(this.selectedIndex) + 1).toString() : undefined;
1705
+ }
1706
+ }
1707
+ else {
1708
+ if (operator === false) {
1709
+ this.focusedIndex = (parseInt(this.focusedIndex) - 1).toString();
1710
+ }
1711
+ else {
1712
+ this.focusedIndex = (parseInt(this.focusedIndex) + 1).toString();
1713
+ }
1714
+ }
1715
+ if (parseInt(this.focusedIndex) < 0) {
1716
+ this.focusedIndex = "0";
1717
+ }
1718
+ else if (parseInt(this.focusedIndex) > this._processedTabs.length - 1) {
1719
+ this.focusedIndex = (this._processedTabs.length - 1).toString();
1720
+ }
1721
+ this.setFocusedBtn(true, this.focusedIndex);
1722
+ this.setFocusedTab(this.focusedIndex);
1723
+ this.ezChange.emit(this.selectedTab);
1724
+ }
1725
+ else if (ev.key === "Tab" || ev.key === "Escape") {
1726
+ this.focusedIndex = undefined;
1727
+ this.selectedTab = this._processedTabs[this.selectedIndex]["tabKey"];
1728
+ this.handleTabClick(this.selectedTab, parseInt(this.selectedIndex));
1729
+ ev.preventDefault();
1730
+ this.setFocusedTab(this.selectedIndex);
1731
+ }
1732
+ // this.setFocusedTab();
1733
+ };
1734
+ }
1735
+ handleTabClick(tab, index) {
1736
+ this.selectedIndex = index.toString();
1737
+ this.focusedIndex = undefined;
1738
+ this.selectedTab = tab;
1739
+ this.ezChange.emit(this.selectedTab);
1740
+ this.setFocusedBtn(false, this.selectedIndex);
1741
+ }
1742
+ componentWillRender() {
1743
+ if (!this._processedTabs) {
1744
+ this._processedTabs = [];
1745
+ if (this.tabs) {
1746
+ this.tabs.split(",").forEach((label) => {
1747
+ label = label.trim();
1748
+ this._processedTabs.push(new Tab(label, label));
1749
+ });
1750
+ }
1751
+ this._hostElem.querySelectorAll("ez-tab").forEach((elem) => {
1752
+ const tabKey = elem.getAttribute("tabKey");
1753
+ const label = elem.getAttribute("label");
1754
+ const t = new Tab(label, tabKey);
1755
+ const content = elem.firstChild;
1756
+ if (content) {
1757
+ content.setAttribute("slot", "tab" + this._processedTabs.length);
1758
+ this._hostElem.appendChild(content);
1759
+ }
1760
+ this._processedTabs.push(t);
1761
+ });
1762
+ }
1763
+ }
1764
+ handleSlotChange(ev) {
1765
+ const slot = ev.target;
1766
+ const content = slot.assignedElements()[0];
1767
+ if (content) {
1768
+ content.style.marginLeft = "6px";
1769
+ }
1770
+ }
1771
+ scrollBackward() {
1772
+ const container = this._scrollContainer;
1773
+ if (container) {
1774
+ container.scrollLeft -= container.clientWidth;
1775
+ }
1776
+ }
1777
+ scrollFoward() {
1778
+ const container = this._scrollContainer;
1779
+ if (container) {
1780
+ let lastTab = null;
1781
+ container.querySelectorAll(".tab").forEach((tab) => {
1782
+ if (tab.getBoundingClientRect().right < container.clientWidth) {
1783
+ lastTab = tab;
1784
+ }
1785
+ });
1786
+ container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
1787
+ }
1788
+ }
1789
+ componentDidRender() {
1790
+ this.updateScroll();
1791
+ }
1792
+ updateScroll() {
1793
+ const container = this._scrollContainer;
1794
+ if (container) {
1795
+ const { scrollWidth, clientWidth, scrollLeft } = container;
1796
+ const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
1797
+ this._startHidden = container.scrollLeft > 0;
1798
+ this._endHidden = remainingScroll > 0;
1799
+ if (this._startHidden) {
1800
+ this._backwardButton.classList.remove("hidden");
1801
+ }
1802
+ else {
1803
+ this._backwardButton.classList.add("hidden");
1804
+ }
1805
+ if (this._endHidden) {
1806
+ this._forwardButton.classList.remove("hidden");
1807
+ }
1808
+ else {
1809
+ this._forwardButton.classList.add("hidden");
1810
+ }
1811
+ const classNames = ["", "startHidden", "endHidden", "midle"];
1812
+ const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
1813
+ classNames.forEach((name) => {
1814
+ if (name !== currentClass && container.classList.contains(name)) {
1815
+ container.classList.remove(name);
1816
+ }
1817
+ });
1818
+ if (currentClass && !container.classList.contains(currentClass)) {
1819
+ container.classList.add(currentClass);
1820
+ }
1821
+ }
1822
+ }
1823
+ domScrollHandler() {
1824
+ window.clearTimeout(this._scrollCallBack);
1825
+ this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
1826
+ }
1827
+ setFocusedTab(index) {
1828
+ window.clearTimeout(this._scrollCallBackTest);
1829
+ this._scrollCallBackTest = window.setTimeout(() => {
1830
+ const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
1831
+ tabtoscroll.scrollIntoView();
1832
+ }, 200);
1833
+ }
1834
+ getTextWidth(text) {
1835
+ if (this._textMesurement === undefined) {
1836
+ this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
1837
+ }
1838
+ const context = this._textMesurement.getContext("2d");
1839
+ context.font = "14px Sora, Algerian";
1840
+ return Math.min(220, 24 + context.measureText(text).width) + "px";
1841
+ }
1842
+ ;
1843
+ setFocusedBtn(visible, parameter) {
1844
+ const tabsButtons = this._scrollContainer.querySelectorAll(".tab");
1845
+ tabsButtons.forEach((el) => {
1846
+ el.classList.remove("is-focused");
1847
+ if (el.id === "tab" + parameter && visible) {
1848
+ el.classList.add("is-focused");
1849
+ }
1850
+ });
1851
+ }
1852
+ render() {
1853
+ return (index.h(index.Host, null, index.h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }), index.h("div", { class: "scroll", ref: (el) => this._scrollContainer = el, onScroll: () => this.domScrollHandler(), onKeyDown: (ev) => this.setFocusedParam(ev) }, this._processedTabs.map((tab, index$1) => {
1854
+ const labelStyle = { "min-width": this.getTextWidth(tab.label) };
1855
+ const tabId = "tab" + index$1;
1856
+ const isSelected = index$1 === parseInt(this.selectedIndex) || (this.selectedTab && tab.tabKey === this.selectedTab);
1857
+ if (isSelected) {
1858
+ this.selectedTab = tab.tabKey;
1859
+ this.selectedIndex = index$1.toString();
1860
+ }
1861
+ return index.h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab.tabKey, index$1), style: labelStyle }, index.h("span", { class: "tab-label", title: tab.label }, tab.label), index.h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
1862
+ })), index.h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
1863
+ }
1864
+ get _hostElem() { return index.getElement(this); }
1865
+ };
1866
+ class Tab {
1867
+ constructor(label, tabKey) {
1868
+ this.label = label;
1869
+ this.tabKey = tabKey;
1870
+ }
1871
+ }
1872
+ EzTabselector.style = ezTabselectorCss;
1873
+
1874
+ const ezTextAreaCss = ":host{--text-area--width:100%;--text-area--border-radius:var(--border--radius-medium, 12px);--text-area--font-size:var(--text--medium, 14px);--text-area--font-family:var(--font-pattern, Arial);--text-area--font-weight:var(--text-weight--large, 500);--text-area--color:var(--title--primary, #000);--text-area__input--background-color:var(--background--medium, #e0e0e0);--text-area__input--border:var(--border--medium, 2px solid);--text-area__input--border-color:var(--text-area__input--background-color);--text-area__input--focus--border-color:var(--color--primary, #008561);--text-area__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--text-area__input--disabled--color:var(--text--disable, #AFB6C0);--text-area__input--error--border-color:#CC2936;--text-area__message_box--font-size:var(--text--small, 12px);--text-area__message_box--info--color:var(--color--success, #22085d);--text-area__message_box--error--color:var(--color--error, #FF0000);--text-area__label--floating--top:6px;--text-area__label--padding-top:12px;--text-area__label--padding-left:14px;--text-area__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--text-area--width)}textarea{box-sizing:border-box;border:none;resize:none;margin-top:calc(var(--space--medium, 12px) + 4px);width:100%;font-weight:var(--text-weight--large, 600);font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);color:var(--text-area--color);padding:0;background:none}textarea:focus{outline:none}textarea:disabled{background-color:transparent;color:var(--text-area__input--disabled--color)}.textarea{width:100%;box-sizing:border-box;padding-left:var(--space--medium);padding-right:var(--space--extra-small);border-radius:var(--text-area--border-radius);border:var(--text-area__input--border);border-color:var(--text-area__input--border-color);background-color:var(--text-area__input--background-color)}.textarea--focus{border-color:var(--text-area__input--focus--border-color)}.textarea.hasError{color:var(--text-area--color);border-color:var(--text-area__input--error--border-color)}.message-box{min-height:16px;min-width:100%;margin-top:2px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--text-area--font-family);font-size:var(--text-area__message_box--font-size);color:var(--text-area__message_box--info--color)}.hasError{color:var(--text-area__message_box--error--color)}.textarea__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--text-area__label--padding-right));left:var(--text-area--space--medium);font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color);top:var(--text-area__label--padding-top);left:var(--text-area__label--padding-left);padding-right:var(--text-area__label--padding-right)}.textarea__label--floated{font-family:var(--text-area--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--text-area__label--floating--top)}.textarea__label--disabled{color:var(--text-area__input--disabled--color)}";
1875
+
1876
+ let EzTextArea = class {
1877
+ constructor(hostRef) {
1878
+ index.registerInstance(this, hostRef);
1879
+ this.ezChange = index.createEvent(this, "ezChange", 7);
1880
+ /**
1881
+ * Deixa o campo disponível ou não para digitação.
1882
+ */
1883
+ this.enabled = true;
1884
+ /**
1885
+ * Ajusta o número de linhas e consequentemente o height do textarea. Valor default: 4
1886
+ */
1887
+ this.rows = 4;
1888
+ }
1889
+ showError() {
1890
+ const hasError = typeof this.errorMessage === 'string' && this.errorMessage !== '';
1891
+ if (hasError) {
1892
+ this._container.classList.add('hasError');
1893
+ this._messageBoxElem.classList.add('hasError');
1894
+ }
1895
+ else {
1896
+ this._container.classList.remove('hasError');
1897
+ this._messageBoxElem.classList.remove('hasError');
1898
+ }
1899
+ }
1900
+ updateInputValue() {
1901
+ this._inputElem.value = this.value;
1902
+ this.handleChange();
1903
+ this.adjustFloatingLabel();
1904
+ this.ezChange.emit(this.value);
1905
+ }
1906
+ adjustFloatingLabel() {
1907
+ if (this.label) {
1908
+ const hasValue = this.value && this.value.toString().length > 0;
1909
+ const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
1910
+ if (hasValue || this.isFocused()) {
1911
+ if (!containsFloatedClass) {
1912
+ this._labelElem.classList.add("textarea__label--floated");
1913
+ }
1914
+ }
1915
+ else {
1916
+ if (containsFloatedClass) {
1917
+ this._labelElem.classList.remove("textarea__label--floated");
1918
+ }
1919
+ }
1920
+ }
1921
+ }
1922
+ isFocused() {
1923
+ return this._hostElement.shadowRoot.activeElement !== null;
1924
+ }
1925
+ //---------------------------------------------
1926
+ // Public methods
1927
+ //---------------------------------------------
1928
+ /**
1929
+ * Faz o foco no componente de input
1930
+ */
1931
+ async setFocus() {
1932
+ this._inputElem.focus();
1933
+ }
1934
+ /**
1935
+ * Remove o foco no componente de input
1936
+ */
1937
+ async setBlur() {
1938
+ this._inputElem.blur();
1939
+ }
1940
+ //---------------------------------------------
1941
+ // Event handlers
1942
+ //---------------------------------------------
1943
+ handleFocusout() {
1944
+ this.adjustFloatingLabel();
1945
+ if (this._container && this._container.classList.contains("textarea--focus")) {
1946
+ this._container.classList.remove("textarea--focus");
1947
+ }
1948
+ }
1949
+ handleChange() {
1950
+ this.errorMessage = "";
1951
+ this.value = this._inputElem.value;
1952
+ }
1953
+ handleFocus() {
1954
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
1955
+ this._labelElem.classList.add("textarea__label--floated");
1956
+ }
1957
+ if (this._container && !this._container.classList.contains("textarea--focus")) {
1958
+ this._container.classList.add("textarea--focus");
1959
+ }
1960
+ }
1961
+ //---------------------------------------------
1962
+ // Lifecycle web component
1963
+ //---------------------------------------------
1964
+ componentDidLoad() {
1965
+ this.showError();
1966
+ this.adjustFloatingLabel();
1967
+ }
1968
+ render() {
1969
+ return (index.h(index.Host, null, index.h("div", { class: "textarea", ref: (el) => this._container = el }, this.label ?
1970
+ index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "textarea__label" : "textarea__label textarea__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
1971
+ : null, index.h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows })), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
1972
+ }
1973
+ get _hostElement() { return index.getElement(this); }
1974
+ static get watchers() { return {
1975
+ "errorMessage": ["showError"],
1976
+ "value": ["updateInputValue"]
1977
+ }; }
1978
+ };
1979
+ EzTextArea.style = ezTextAreaCss;
1980
+
1981
+ const ezTextInputCss = ":host{--ez-text-input--height:42px;--ez-text-input--width:100%;--ez-text-input__icon--width:48px;--ez-text-input--border-radius:var(--border--radius-medium, 12px);--ez-text-input--font-size:var(--text--medium, 14px);--ez-text-input--font-family:var(--font-pattern, Arial);--ez-text-input--font-weight:var(--text-weight--large, 500);--ez-text-input--color:var(--title--primary, #000);--ez-text-input__input--background-color:var(--background--medium, #e0e0e0);--ez-text-input__input--border:var(--border--medium, 2px solid);--ez-text-input__input--border-color:var(--ez-text-input__input--background-color);--ez-text-input__input--focus--border-color:var(--color--alert-cold-800, #042EFF);--ez-text-input__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-text-input__input--disabled--color:var(--text--disable, #AFB6C0);--ez-text-input__input--error--border-color:#CC2936;--ez-text-input__message_box--font-size:var(--text--small, 12px);--ez-text-input__message_box--info--color:var(--color--success, #22085d);--ez-text-input__message_box--error--color:var(--color--error, #FF0000);--ez-text-input__label--floating--top:6px;--ez-text-input__label--padding-top:12px;--ez-text-input__label--padding-left:14px;--ez-text-input__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--ez-text-input--width)}input{width:100%;box-sizing:border-box;padding:var(--space--medium, 6px);font-weight:var(--text-weight--large, 600);height:var(--ez-text-input--height);border-radius:var(--ez-text-input--border-radius);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);border:var(--ez-text-input__input--border);border-color:var(--ez-text-input__input--border-color);background-color:var(--ez-text-input__input--background-color);color:var(--ez-text-input--color)}input:disabled{background-color:var(--ez-text-input__input--disabled--background-color);color:var(--ez-text-input__input--disabled--color)}input:focus{outline:none;border-color:var(--ez-text-input__input--focus--border-color)}input.icon--left{padding-left:var(--ez-text-input__icon--width)}input.icon--right{padding-right:var(--ez-text-input__icon--width)}input.hasError{color:var(--ez-text-input--color);border-color:var(--ez-text-input__input--error--border-color)}input.text--right{text-align:right}.message-box{display:flex;min-height:16px;min-width:100%;margin-top:2px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input__message_box--font-size);color:var(--ez-text-input__message_box--info--color)}.hasError{color:var(--ez-text-input__message_box--error--color)}.input__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--ez-text-input__label--padding-right));left:var(--ez-text-input--space--medium);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color);top:var(--ez-text-input__label--padding-top);left:var(--ez-text-input__label--padding-left);padding-right:var(--ez-text-input__label--padding-right)}.input__label--floated{font-family:var(--ez-text-input--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--ez-text-input__label--floating--top)}.input__label--disabled{color:var(--ez-text-input__input--disabled--color)}.input__label--left{text-align:left;left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--right{right:var(--ez-text-input__icon--width);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--left.input__label--right{left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width) * 2)}.input--with--label{padding-bottom:0}";
1982
+
1983
+ let EzTextInput = class {
1984
+ constructor(hostRef) {
1985
+ index.registerInstance(this, hostRef);
1986
+ this.ezChange = index.createEvent(this, "ezChange", 7);
1987
+ /**
1988
+ * Deixa o campo disponível ou não para digitação.
1989
+ */
1990
+ this.enabled = true;
1991
+ }
1992
+ showError() {
1993
+ const hasError = typeof this.errorMessage === "string" && this.errorMessage !== "";
1994
+ if (hasError) {
1995
+ this._inputElem.classList.add("hasError");
1996
+ this._messageBoxElem.classList.add("hasError");
1997
+ }
1998
+ else {
1999
+ this._inputElem.classList.remove("hasError");
2000
+ this._messageBoxElem.classList.remove("hasError");
2001
+ }
2002
+ }
2003
+ prepareMask() {
2004
+ if (this.mask) {
2005
+ if (this._maskFormatter == undefined) {
2006
+ this._maskFormatter = new index$1.MaskFormatter(this.mask);
2007
+ }
2008
+ else {
2009
+ this._maskFormatter.mask = this.mask;
2010
+ }
2011
+ }
2012
+ }
2013
+ updateInputValue() {
2014
+ if (this._inputElem) {
2015
+ this._inputElem.value = this.value;
2016
+ }
2017
+ this.handleChange();
2018
+ this.errorMessage = "";
2019
+ this.ezChange.emit(this.value);
2020
+ this.adjustFloatingLabel();
2021
+ }
2022
+ adjustFloatingLabel() {
2023
+ if (this.label && this._labelElem) {
2024
+ if (this._inputElem && !this._inputElem.classList.contains("input--with--label")) {
2025
+ this._inputElem.classList.add("input--with--label");
2026
+ }
2027
+ const hasValue = this.value && this.value.toString().length > 0;
2028
+ const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
2029
+ if (hasValue || this.isFocused()) {
2030
+ if (!containsFloatedClass) {
2031
+ this._labelElem.classList.add("input__label--floated");
2032
+ }
2033
+ }
2034
+ else {
2035
+ if (containsFloatedClass) {
2036
+ this._labelElem.classList.remove("input__label--floated");
2037
+ }
2038
+ }
2039
+ }
2040
+ }
2041
+ isFocused() {
2042
+ return this._hostElement.shadowRoot.activeElement !== null;
2043
+ }
2044
+ //---------------------------------------------
2045
+ // Public methods
2046
+ //---------------------------------------------
2047
+ /**
2048
+ * Faz o foco no componente de input
2049
+ */
2050
+ async setFocus() {
2051
+ this._inputElem.focus();
2052
+ }
2053
+ /**
2054
+ * Remove o foco no componente de input
2055
+ */
2056
+ async setBlur() {
2057
+ this._inputElem.blur();
2058
+ }
2059
+ //---------------------------------------------
2060
+ // Event handlers
2061
+ //---------------------------------------------
2062
+ handleFocusout() {
2063
+ const value = this._inputElem.value;
2064
+ if (value && this._maskFormatter) {
2065
+ try {
2066
+ this._inputElem.value = this._maskFormatter.format(value);
2067
+ }
2068
+ catch (e) {
2069
+ this.errorMessage = e.message;
2070
+ }
2071
+ }
2072
+ this.value = this._inputElem.value;
2073
+ this.adjustFloatingLabel();
2074
+ }
2075
+ isValidValue(value) {
2076
+ if (this.restrict) {
2077
+ return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
2078
+ }
2079
+ return true;
2080
+ }
2081
+ handleChange() {
2082
+ if (!this._inputElem) {
2083
+ return;
2084
+ }
2085
+ const value = this._inputElem.value;
2086
+ if (this.isValidValue(value)) {
2087
+ this._lastValidValue = value;
2088
+ }
2089
+ else {
2090
+ this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
2091
+ }
2092
+ this.value = this._inputElem.value;
2093
+ }
2094
+ handleSlotChange(ev) {
2095
+ const slot = ev.target;
2096
+ const content = slot.assignedElements()[0];
2097
+ if (content) {
2098
+ content.style.position = "absolute";
2099
+ content.style.display = "flex";
2100
+ content.style.alignItems = "center";
2101
+ content.style.justifyContent = "center";
2102
+ content.style.overflow = "hidden";
2103
+ content.style.top = "0px";
2104
+ content.style.width = "var(--ez-text-input__icon--width)";
2105
+ content.style.height = "var(--ez-text-input--height)";
2106
+ if (slot.name == "leftIcon") {
2107
+ content.style.left = "0px";
2108
+ content.style.borderRadius = "var(--ez-text-input--border-radius) 0 0 var(--ez-text-input--border-radius)";
2109
+ this._inputElem.classList.add("icon--left");
2110
+ if (this._labelElem) {
2111
+ this._labelElem.classList.add("input__label--left");
2112
+ }
2113
+ }
2114
+ else if (slot.name == "rightIcon") {
2115
+ content.style.right = "0px";
2116
+ content.style.borderRadius = "0 var(--ez-text-input--border-radius) var(--ez-text-input--border-radius) 0";
2117
+ this._inputElem.classList.add("icon--right");
2118
+ if (this._labelElem) {
2119
+ this._labelElem.classList.add("input__label--right");
2120
+ }
2121
+ }
2122
+ }
2123
+ this.showError();
2124
+ }
2125
+ doFocus() {
2126
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
2127
+ this._labelElem.classList.add("input__label--floated");
2128
+ }
2129
+ }
2130
+ //---------------------------------------------
2131
+ // Lifecycle web component
2132
+ //---------------------------------------------
2133
+ componentDidLoad() {
2134
+ this.showError();
2135
+ this.prepareMask();
2136
+ this.adjustFloatingLabel();
2137
+ }
2138
+ componentWillLoad() {
2139
+ this.prepareMask();
2140
+ if (this.value) {
2141
+ if (this._maskFormatter) {
2142
+ try {
2143
+ this.value = this._maskFormatter.format(this.value);
2144
+ }
2145
+ catch (e) {
2146
+ this.errorMessage = e.message;
2147
+ }
2148
+ }
2149
+ if (!this.isValidValue(this.value)) {
2150
+ this._lastValidValue = "";
2151
+ this.value = "";
2152
+ }
2153
+ }
2154
+ }
2155
+ render() {
2156
+ return (index.h(index.Host, null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
2157
+ index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
2158
+ : null, index.h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
2159
+ }
2160
+ get _hostElement() { return index.getElement(this); }
2161
+ static get watchers() { return {
2162
+ "errorMessage": ["showError"],
2163
+ "mask": ["prepareMask"],
2164
+ "value": ["updateInputValue"]
2165
+ }; }
2166
+ };
2167
+ EzTextInput.style = ezTextInputCss;
2168
+
2169
+ class RemoteFile {
2170
+ constructor(file) {
2171
+ this.file = file;
2172
+ this.size = file.size;
2173
+ this.name = file.name;
2174
+ }
2175
+ abortUpload() {
2176
+ if (this._uploadingXhr) {
2177
+ this._aborted = true;
2178
+ this._uploadingXhr.abort();
2179
+ this._uploadingXhr = undefined;
2180
+ }
2181
+ }
2182
+ isUploading() {
2183
+ return this._uploadingXhr !== undefined;
2184
+ }
2185
+ async upload(server, headers, updateCallBack) {
2186
+ return new Promise((resolve, reject) => {
2187
+ const xhr = new XMLHttpRequest();
2188
+ this._uploadingXhr = xhr;
2189
+ this._aborted = false;
2190
+ this.progress = 0;
2191
+ xhr.upload.onprogress = (e) => {
2192
+ const loaded = e.loaded;
2193
+ const total = e.total;
2194
+ this.progress = ~~((loaded / total) * 100);
2195
+ updateCallBack(this, loaded, total);
2196
+ };
2197
+ xhr.onreadystatechange = () => {
2198
+ if (xhr.readyState == 4) {
2199
+ this._uploadingXhr = undefined;
2200
+ const status = xhr.status;
2201
+ if (!this._aborted) {
2202
+ if (status === 0) {
2203
+ reject("Servidor indisponível");
2204
+ }
2205
+ else if (status >= 500) {
2206
+ reject("Erro inesperado no servidor");
2207
+ }
2208
+ else if (status >= 400) {
2209
+ reject("Operação não permitida");
2210
+ }
2211
+ }
2212
+ const response = xhr.response;
2213
+ if (response) {
2214
+ resolve(JSON.parse(response));
2215
+ }
2216
+ }
2217
+ };
2218
+ xhr.ontimeout = () => {
2219
+ reject("Tempo limite de transferência atingido.");
2220
+ };
2221
+ const formData = new FormData();
2222
+ formData.append("ARQUIVO", this.file, this.file.name);
2223
+ xhr.open("POST", server, true);
2224
+ if (headers) {
2225
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
2226
+ }
2227
+ xhr.send(formData);
2228
+ });
2229
+ }
2230
+ async delete(item, server, headers) {
2231
+ return new Promise((resolve, reject) => {
2232
+ const xhr = new XMLHttpRequest();
2233
+ xhr.onreadystatechange = () => {
2234
+ if (xhr.readyState == 4) {
2235
+ if (xhr.status === 0) {
2236
+ reject("Servidor indisponível");
2237
+ }
2238
+ else if (xhr.status >= 500) {
2239
+ reject("Erro inesperado no servidor");
2240
+ }
2241
+ else if (xhr.status >= 400) {
2242
+ reject("Operação não permitida");
2243
+ }
2244
+ resolve(true);
2245
+ }
2246
+ };
2247
+ xhr.ontimeout = () => {
2248
+ reject("Tempo limite de remoção atingido.");
2249
+ };
2250
+ xhr.open("DELETE", server, true);
2251
+ if (headers) {
2252
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
2253
+ }
2254
+ xhr.send(JSON.stringify(item));
2255
+ });
2256
+ }
2257
+ }
2258
+
2259
+ const ezUploadCss = ":host{--ez-upload--height:42px;--ez-upload--width:100%;--ez-upload__icon--width:48px;--ez-upload__container--background-color:var(--background--medium, #d2dce9);--ez-upload__color--primary:var(--color--primary, #008561);--ez-upload--padding--extra-small:var(--space--extra-small, 3px);--ez-upload--padding--small:var(--space--small, 6px);--ez-upload--padding--medium:var(--space--medium, 12px);--ez-upload--padding--large:var(--space--large, 24px);--ez-upload__border--color:var(--color-strokes, #DCE0E8);--ez-upload--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--ez-upload--text--primary:var(--text-primary, #626e82);--ez-upload--font-size:var(--text--medium, 14px);--ez-upload--font-family:var(--font-pattern, Arial);--ez-upload--font-weight:var(--text-weight--large, 500);--ez-upload__btn__cancel-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"8x\" width=\"8px\"><path d=\"M 8,0.8 7.2,0 4,3.2 0.8,0 0,0.8 3.2,4 0,7.2 0.8,8 4,4.8 7.2,8 8,7.2 4.8,4 Z\"/></svg>');--ez-upload__file-icon-image:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"11x\" width=\"9px\"><path d=\"M 1.2272719,8.4999999 V 2.75 c 0,-1.1045695 1.4652499,-2 3.2727273,-2 1.8074777,0 3.2727281,0.8954305 3.2727281,2 V 8.9999999 C 7.7727273,9.690356 6.8569456,10.25 5.7272719,10.25 4.5975985,10.25 3.6818174,9.690356 3.6818174,8.9999999 V 3.75 c 0,-0.2761425 0.3663125,-0.5 0.8181818,-0.5 0.4518694,0 0.8181818,0.2238575 0.8181818,0.5 V 8.4999999 H 6.5454537 V 3.75 C 6.5454537,3.059644 5.6296725,2.5 4.4999992,2.5 3.3703258,2.5 2.4545446,3.059644 2.4545446,3.75 V 8.9999999 C 2.4545446,10.10457 3.9197945,11 5.7272719,11 7.5347496,11 9,10.10457 9,8.9999999 V 2.75 C 9,1.231217 6.9852809,0 4.4999992,0 2.0147181,5e-7 0,1.231217 0,2.75 v 5.7499999 z\"/></svg>');display:flex;flex-wrap:wrap;position:relative;font-family:var(--ez-upload--font-family);font-size:var(--ez-upload--font-size);width:var(--ez-upload--width);font-weight:var(--ez-upload--font-weight)}.iu{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:var(--ez-upload--padding--small);width:100%;border-radius:12px;box-sizing:border-box}.iu__container{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;border:2px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.iu__footer{display:flex;flex-wrap:wrap;justify-content:flex-start;width:100%;padding:0 var(--ez-upload--padding--medium) var(--ez-upload--padding--medium) var(--ez-upload--padding--medium);box-sizing:border-box}.iu__item{display:flex;width:100%;justify-content:flex-start;align-items:center;align-self:center;padding-bottom:var(--ez-upload--padding--extra-small);box-sizing:border-box;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.iu__item-label{display:flex;max-width:80%;align-self:stretch;align-items:center}.file__name{font-weight:200}.box__content{width:100%;justify-content:center;align-items:center;height:100%;border:1px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.box__container{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:6px;width:100%;border-radius:12px}a:-webkit-any-link{color:#008561;fill:#008561;cursor:pointer;text-decoration:none}progress[value]{display:flex;width:100%;appearance:none;border:1px solid var(--ez-upload__border--color);height:12px;justify-content:flex-start;align-items:center;border-radius:3px;position:relative}progress[value]::-webkit-progress-bar{display:flex;-webkit-appearance:none;width:100%;background-color:rgb(255, 255, 255);border-radius:2px;padding:2px}progress[value]::-webkit-progress-value{display:flex;width:100%;background-color:var(--ez-upload__color--primary)}.text--center{text-align:center}.align--middle{align-self:center;align-items:center}.text{font-family:\"Sora\", \"Algerian\";text-shadow:0 0 0 #353535, 0 0 1px transparent}.text--primary{color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.text--ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.text--medium{font-size:14px}.text--small{font-size:12px}.btn-cancel{outline:none;border:none;background-color:unset;cursor:pointer}.btn-cancel::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:8px;height:8px;-webkit-mask-image:var(--ez-upload__btn__cancel-image);mask-image:var(--ez-upload__btn__cancel-image)}.iu_header{display:flex;flex-direction:column;width:100%}.iu__label{padding:var(--space--small);box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-upload--font-family);font-size:var(--text--extra-small);font-weight:var(--ez-upload--font-weight);color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.iu__file-icon{outline:none;border:none;background-color:unset;cursor:pointer}.iu__file-icon:disabled{cursor:unset}.iu__file-icon::after{content:'';display:flex;background-color:var(--text--primary, #626e82);width:9px;height:11px;-webkit-mask-image:var(--ez-upload__file-icon-image);mask-image:var(--ez-upload__file-icon-image)}.iu__file-icon:disabled::after{background-color:var(--text--disable, #AFB6C0)}.iu__icon-label{justify-content:center;display:flex;cursor:pointer;padding:var(--ez-upload--padding--large) 0px;box-sizing:border-box}.background--disabled{background-color:var(--color--disable-secondary, #F2F5F8)}.text--disabled{color:var(--text--disable, #AFB6C0)}.mouse-pointer--disabled{cursor:unset}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}";
2260
+
2261
+ let EzUpload = class {
2262
+ constructor(hostRef) {
2263
+ index.registerInstance(this, hostRef);
2264
+ this.ezChange = index.createEvent(this, "ezChange", 7);
2265
+ this._filePointers = new Map();
2266
+ /**
2267
+ * Deixa o campo disponível ou não para digitação.
2268
+ */
2269
+ this.enabled = true;
2270
+ }
2271
+ changeValue(newValue) {
2272
+ if (newValue !== this._updatingValue) {
2273
+ this._filePointers.forEach(f => {
2274
+ if (this.isRemoteFile(f)) {
2275
+ f.abortUpload();
2276
+ }
2277
+ });
2278
+ this._filePointers = new Map();
2279
+ this.updateFilePointers();
2280
+ }
2281
+ this._updatingValue = undefined;
2282
+ }
2283
+ updateFilePointers() {
2284
+ if (this.value) {
2285
+ this.value.forEach(ezFile => this._filePointers.set(ezFile.name, ezFile));
2286
+ }
2287
+ }
2288
+ normalizeRequestHeaders() {
2289
+ this._requestHeaders = new Map();
2290
+ if (typeof this.requestHeaders == "string") {
2291
+ try {
2292
+ this.requestHeaders = JSON.parse(this.requestHeaders);
2293
+ }
2294
+ catch (e) {
2295
+ this.requestHeaders = undefined;
2296
+ }
2297
+ }
2298
+ for (var key in this.requestHeaders) {
2299
+ this._requestHeaders.set(key, this.requestHeaders[key]);
2300
+ }
2301
+ }
2302
+ /**
2303
+ * Método responsável por adicionar um ou mais arquivos ao componente.
2304
+ */
2305
+ async addFiles(files) {
2306
+ if (this.maxFiles > 0) {
2307
+ let countDistinctFiles = this._filePointers.size;
2308
+ files.forEach(file => {
2309
+ if (!this._filePointers.has(file.name)) {
2310
+ countDistinctFiles++;
2311
+ }
2312
+ });
2313
+ if (countDistinctFiles > this.maxFiles) {
2314
+ this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
2315
+ return;
2316
+ }
2317
+ }
2318
+ Array.prototype.forEach.call(files, this.addFile.bind(this));
2319
+ }
2320
+ async addFile(file) {
2321
+ const oldFile = this._filePointers.get(file.name);
2322
+ if (oldFile) {
2323
+ ApplicationUtils.confirm("Substituir arquivo", `Já existe um arquivo chamado "${file.name}". Deseja substituí-lo?`)
2324
+ .then(ok => {
2325
+ if (ok) {
2326
+ if (this.isRemoteFile(oldFile)) {
2327
+ oldFile.abortUpload();
2328
+ }
2329
+ this.doAddFile(file);
2330
+ }
2331
+ });
2332
+ }
2333
+ else {
2334
+ this.doAddFile(file);
2335
+ }
2336
+ }
2337
+ async doAddFile(file) {
2338
+ if (this.validateFile(file)) {
2339
+ const uploadingFile = new RemoteFile(file);
2340
+ this._filePointers.set(file.name, uploadingFile);
2341
+ uploadingFile.upload(this.urlUpload, this._requestHeaders, (file) => this.updateFeedback(file))
2342
+ .then((files) => files.forEach(ezFile => this.finishUpload(ezFile)))
2343
+ .catch(msg => this.showError(msg));
2344
+ index.forceUpdate(this);
2345
+ }
2346
+ }
2347
+ finishUpload(ezFile) {
2348
+ this._filePointers.set(ezFile.name, ezFile);
2349
+ this.updateValue();
2350
+ }
2351
+ updateValue() {
2352
+ this._updatingValue = [];
2353
+ this._filePointers.forEach(f => {
2354
+ if (!this.isRemoteFile(f)) {
2355
+ this._updatingValue.push(f);
2356
+ }
2357
+ });
2358
+ this.value = this._updatingValue;
2359
+ this.ezChange.emit(this.value);
2360
+ }
2361
+ buildProgressId(uploading) {
2362
+ let sanitizedName = uploading.name.replace(/[^a-z0-9_]/gi, "_");
2363
+ return `PROGRESS_${sanitizedName}_${uploading.file.lastModified}`;
2364
+ }
2365
+ updateFeedback(uf) {
2366
+ window.requestAnimationFrame(() => {
2367
+ if (this._host) {
2368
+ const progress = this._host.shadowRoot.querySelector("#" + this.buildProgressId(uf));
2369
+ if (progress) {
2370
+ progress.value = uf.progress;
2371
+ }
2372
+ }
2373
+ });
2374
+ }
2375
+ validateFile(file) {
2376
+ if (!this._filePointers.has(file.name) && this.maxFiles > 0 && this._filePointers.size >= this.maxFiles) {
2377
+ this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`);
2378
+ return false;
2379
+ }
2380
+ if (file.size === 0) {
2381
+ this.showError(`Erro de permissão: O arquivo "${file.name}" não pode ser enviado.`);
2382
+ return false;
2383
+ }
2384
+ if (!this.urlUpload) {
2385
+ this.showError("Endereço de upload não informado");
2386
+ return false;
2387
+ }
2388
+ if (this.maxFileSize >= 0 && file.size > this.maxFileSize) {
2389
+ this.showError("O tamanho máximo dos arquivos é de " + this.formatBytes(this.maxFileSize));
2390
+ return false;
2391
+ }
2392
+ return true;
2393
+ }
2394
+ showError(message) {
2395
+ ApplicationUtils.alert("Enviando arquivo", message);
2396
+ }
2397
+ formatBytes(bytes, decimals = 1) {
2398
+ if (bytes === 0)
2399
+ return "0 Bytes";
2400
+ const k = 1024;
2401
+ const dm = decimals < 0 ? 0 : decimals;
2402
+ const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
2403
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
2404
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
2405
+ }
2406
+ onFileInputChange(event) {
2407
+ const input = event.target;
2408
+ this.addFiles(Array.from(input.files));
2409
+ this._fileInput.value = "";
2410
+ }
2411
+ isRemoteFile(item) {
2412
+ return "file" in item;
2413
+ }
2414
+ removeFromList(name) {
2415
+ this._filePointers.delete(name);
2416
+ this.updateValue();
2417
+ }
2418
+ removeFile(name) {
2419
+ const item = this._filePointers.get(name);
2420
+ if (this.isRemoteFile(item)) {
2421
+ item.abortUpload();
2422
+ this.removeFromList(name);
2423
+ }
2424
+ else {
2425
+ if (this.urlDelete) {
2426
+ const uploadingFile = new RemoteFile(null);
2427
+ this._filePointers.set(item.name, uploadingFile);
2428
+ uploadingFile.delete(item, this.urlDelete, null)
2429
+ .then(_ok => this.removeFromList(name))
2430
+ .catch(msg => this.showError(msg));
2431
+ }
2432
+ else {
2433
+ this.removeFromList(name);
2434
+ }
2435
+ }
2436
+ }
2437
+ openFilesDialog() {
2438
+ if (this.enabled) {
2439
+ this._fileInput.click();
2440
+ }
2441
+ }
2442
+ componentDidLoad() {
2443
+ if (this.enabled && this._dropZone && window.FileList && window.File) {
2444
+ this._dropZone.addEventListener("dragover", event => {
2445
+ event.stopPropagation();
2446
+ event.preventDefault();
2447
+ event.dataTransfer.dropEffect = "copy";
2448
+ this._dropZone.style.background = "#c2dbff";
2449
+ });
2450
+ this._dropZone.addEventListener("drop", event => {
2451
+ event.stopPropagation();
2452
+ event.preventDefault();
2453
+ this.addFiles(Array.from(event.dataTransfer.files));
2454
+ this._dropZone.style.background = "";
2455
+ });
2456
+ this._dropZone.addEventListener("dragleave", _event => {
2457
+ this._dropZone.style.background = "";
2458
+ });
2459
+ }
2460
+ }
2461
+ componentWillRender() {
2462
+ if (this.value) {
2463
+ if (this._filePointers.size < this.value.length) {
2464
+ this.updateFilePointers();
2465
+ }
2466
+ }
2467
+ }
2468
+ render() {
2469
+ return (index.h("div", { ref: (el) => this._dropZone = el, class: this.evalDisabledClass("iu", "background--disabled") }, index.h("div", { class: "iu__container", onClick: () => this.openFilesDialog() }, index.h("div", { class: "iu_header" }, this.label ? index.h("label", { class: this.evalDisabledClass("iu__label", "text--disabled"), title: this.label }, this.label) : null, index.h("div", { class: this.evalDisabledClass("iu__icon-label", "mouse-pointer--disabled") }, index.h("button", { class: "iu__file-icon", disabled: !this.enabled }), index.h("div", { class: this.evalDisabledClass("text text--center text--medium text--primary", "text--disabled") }, this.enabled ? "Arraste e solte ou clique para adicionar arquivos" : "Somente leitura"))), this.buildFooter()), index.h("input", { ref: (el) => this._fileInput = el, onChange: (ev) => this.onFileInputChange(ev), type: "file", multiple: true, hidden: true })));
2470
+ }
2471
+ buildFooter() {
2472
+ if (this._filePointers.size === 0) {
2473
+ return null;
2474
+ }
2475
+ const items = [];
2476
+ this._filePointers.forEach(item => items.push(this.buildFileItem(item)));
2477
+ return (index.h("div", { class: "iu__footer" }, items));
2478
+ }
2479
+ buildFileItem(item) {
2480
+ const fileName = item.name;
2481
+ const progress = Number(item["progress"]);
2482
+ const downloadURL = item["downloadURL"];
2483
+ const label = `${fileName} (${this.formatBytes(item.size)})`;
2484
+ return (index.h("div", { class: "iu__item", key: fileName, onClick: evt => evt.stopPropagation() }, index.h("div", { class: "iu__item-label modificador" }, index.h("div", { title: label, class: "col--stretch align--middle file__name text text--primary text--small text--ellipsis align--middle" }, downloadURL ? index.h("a", { href: downloadURL, download: true }, label) : label)), isNaN(progress)
2485
+ ?
2486
+ null
2487
+ :
2488
+ index.h("div", { class: "col col--sd-4 col--stretch align--middle" }, index.h("progress", { id: this.buildProgressId(item), value: progress, max: "100" })), this.enabled
2489
+ ?
2490
+ index.h("div", { class: "col col--stretch align--middle" }, index.h("button", { class: "btn-cancel ", onClick: () => this.removeFile(fileName) }))
2491
+ :
2492
+ null));
2493
+ }
2494
+ evalDisabledClass(regularClasses, disabledClass) {
2495
+ return this.enabled ? regularClasses : `${regularClasses} ${disabledClass}`;
2496
+ }
2497
+ get _host() { return index.getElement(this); }
2498
+ static get watchers() { return {
2499
+ "value": ["changeValue"],
2500
+ "requestHeaders": ["normalizeRequestHeaders"]
2501
+ }; }
2502
+ };
2503
+ EzUpload.style = ezUploadCss;
2504
+
2505
+ const testDuCss = ":host{display:block}";
2506
+
2507
+ let TestDu = class {
2508
+ constructor(hostRef) {
2509
+ index.registerInstance(this, hostRef);
2510
+ }
2511
+ componentWillLoad() {
2512
+ this.dataUnit = new index$1.DataUnit("testes_com_formulario");
2513
+ this.dataUnit.metadata = {
2514
+ name: "dd://br.com.sankhya.fin.cad.movimentacaoFinanceira/Financeiro",
2515
+ label: "Parceiro",
2516
+ fields: [
2517
+ {
2518
+ name: "CODPARC",
2519
+ label: "Parceiro",
2520
+ dataType: index$1.DataType.NUMBER,
2521
+ userInterface: index$1.UserInterface.SEARCH,
2522
+ required: true,
2523
+ properties: {}
2524
+ },
2525
+ {
2526
+ name: "RECDESP",
2527
+ label: "Receita/Despesa",
2528
+ dataType: index$1.DataType.TEXT,
2529
+ userInterface: index$1.UserInterface.OPTIONSELECTOR,
2530
+ required: true,
2531
+ properties: { options: `{"-1": "Despesa", "1": "Receita"}` }
2532
+ },
2533
+ {
2534
+ name: "P",
2535
+ label: "pera",
2536
+ dataType: index$1.DataType.TEXT,
2537
+ userInterface: index$1.UserInterface.OPTIONSELECTOR,
2538
+ properties: { options: `{"M": "Madura", "V": "Verde", "P": "Passada"}` }
2539
+ },
2540
+ {
2541
+ name: "ME",
2542
+ label: "ME",
2543
+ dataType: index$1.DataType.NUMBER,
2544
+ userInterface: index$1.UserInterface.DECIMALNUMBER,
2545
+ properties: { precision: 4, prettyPrecision: 1 }
2546
+ }
2547
+ ]
2548
+ };
2549
+ this.formConfig = [
2550
+ { name: "CODPARC", label: "Parceiro" },
2551
+ { name: "NOMEPARC", label: "Mamão" },
2552
+ { name: "P", label: "Pêra", group: "Grupo 1" },
2553
+ { name: "ME", label: "Melancia", tab: "aba 1", group: "Grupo 2" },
2554
+ { name: "L", label: "Laranja", tab: "aba 1", group: "Grupo 1" },
2555
+ { name: "LI", label: "Limão", tab: "aba 1", group: "Grupo 2" }
2556
+ ];
2557
+ this.dataUnit.records = [
2558
+ {
2559
+ __record__id__: "1321321321321321",
2560
+ CODPARC: 10,
2561
+ NOMEPARC: "Parceiro 10",
2562
+ P: "M",
2563
+ L: "Bagaço",
2564
+ LI: "Azedo"
2565
+ }
2566
+ ];
2567
+ }
2568
+ render() {
2569
+ //return this.conteudoEstatico();
2570
+ //return this.somenteDataUnit();
2571
+ return this.configurado();
2572
+ }
2573
+ conteudoEstatico() {
2574
+ return (index.h("div", null, index.h("button", { onClick: () => this.form.validate() }, "Validate"), index.h("ez-form", { ref: ref => this.form = ref }, index.h("div", null, index.h("ez-text-input", { label: "Nome (Label est\u00E1tico)", "data-field-name": "NOMEPARC", "data-required": "true" }), index.h("ez-text-input", { label: "C\u00F3d parc (Label est\u00E1tico)", "data-field-name": "CODPARC", "data-required": "true" })))));
2575
+ }
2576
+ somenteDataUnit() {
2577
+ return (index.h("ez-form", { dataUnit: this.dataUnit }));
2578
+ }
2579
+ configurado() {
2580
+ return (index.h("ez-form", { dataUnit: this.dataUnit, config: this.formConfig, ref: ref => this.form = ref }));
2581
+ }
2582
+ };
2583
+ TestDu.style = testDuCss;
2584
+
2585
+ exports.ez_calendar = EzCalendar;
2586
+ exports.ez_check = EzCheck;
2587
+ exports.ez_collapsible_box = EzCollapsibleBox;
2588
+ exports.ez_combo_box = EzComboBox;
2589
+ exports.ez_date_input = EzDateInput;
2590
+ exports.ez_date_time_input = EzDateTimeInput;
2591
+ exports.ez_form = EzForm;
2592
+ exports.ez_number_input = EzNumberInput;
2593
+ exports.ez_search = EzSearch;
2594
+ exports.ez_tabselector = EzTabselector;
2595
+ exports.ez_text_area = EzTextArea;
2596
+ exports.ez_text_input = EzTextInput;
2597
+ exports.ez_upload = EzUpload;
2598
+ exports.test_du = TestDu;