@sankhyalabs/ezui 1.1.6 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +72 -72
  2. package/dist/cjs/{DataUnit-09a6e7be.js → DataUnit-95368a67.js} +418 -361
  3. package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
  4. package/dist/cjs/ez-button_14.cjs.entry.js +1933 -1847
  5. package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
  6. package/dist/cjs/ez-modal.cjs.entry.js +102 -95
  7. package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
  8. package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
  9. package/dist/cjs/ezui.cjs.js +1 -1
  10. package/dist/cjs/form-metadata.cjs.entry.js +65 -65
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
  13. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
  14. package/dist/collection/components/ez-button/ez-button.css +94 -94
  15. package/dist/collection/components/ez-button/ez-button.js +125 -125
  16. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
  17. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
  18. package/dist/collection/components/ez-check/ez-check.css +265 -265
  19. package/dist/collection/components/ez-check/ez-check.js +168 -168
  20. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
  21. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
  22. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
  23. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
  24. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
  25. package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
  26. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
  27. package/dist/collection/components/ez-form/ez-form.css +19 -19
  28. package/dist/collection/components/ez-form/ez-form.js +390 -289
  29. package/dist/collection/components/ez-form/store/Form.actions.js +132 -123
  30. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -174
  31. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -43
  32. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +252 -207
  33. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
  34. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
  35. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
  36. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
  37. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
  38. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
  39. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -33
  40. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -18
  41. package/dist/collection/components/ez-icon/ez-icon.css +36 -36
  42. package/dist/collection/components/ez-icon/ez-icon.js +56 -56
  43. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
  44. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
  45. package/dist/collection/components/ez-modal/ez-modal.css +86 -86
  46. package/dist/collection/components/ez-modal/ez-modal.js +222 -200
  47. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
  48. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
  49. package/dist/collection/components/ez-popover/ez-popover.css +38 -38
  50. package/dist/collection/components/ez-popover/ez-popover.js +323 -323
  51. package/dist/collection/components/ez-search/ez-search.css +295 -295
  52. package/dist/collection/components/ez-search/ez-search.js +527 -527
  53. package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
  54. package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
  55. package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
  56. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
  57. package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
  58. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
  59. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
  60. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
  61. package/dist/collection/index.js +1 -1
  62. package/dist/collection/servidor.js +100 -100
  63. package/dist/collection/utils/FloatingManager.js +15 -15
  64. package/dist/collection/utils/utils.js +6 -6
  65. package/dist/custom-elements/index.js +3146 -2998
  66. package/dist/esm/{DataUnit-7a983910.js → DataUnit-4bb6a396.js} +417 -362
  67. package/dist/esm/ez-action-chip.entry.js +41 -41
  68. package/dist/esm/ez-button_14.entry.js +1933 -1847
  69. package/dist/esm/ez-label-chip.entry.js +120 -120
  70. package/dist/esm/ez-modal.entry.js +103 -96
  71. package/dist/esm/ez-number-input.entry.js +236 -236
  72. package/dist/esm/ez-time-input.entry.js +168 -168
  73. package/dist/esm/ezui.js +1 -1
  74. package/dist/esm/form-metadata.entry.js +65 -65
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/polyfills/core-js.js +0 -0
  77. package/dist/esm/polyfills/dom.js +0 -0
  78. package/dist/esm/polyfills/es5-html-element.js +0 -0
  79. package/dist/esm/polyfills/index.js +0 -0
  80. package/dist/esm/polyfills/system.js +0 -0
  81. package/dist/ezui/ezui.esm.js +1 -1
  82. package/dist/ezui/p-11d20338.js +1 -0
  83. package/dist/ezui/{p-3c3a43aa.entry.js → p-5d30e51c.entry.js} +1 -1
  84. package/dist/ezui/p-77fdb4fd.entry.js +1 -0
  85. package/dist/ezui/p-e056fb23.entry.js +1 -0
  86. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  87. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  88. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  89. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  90. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  91. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  92. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  93. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  94. package/dist/types/components/ez-form/ez-form.d.ts +27 -27
  95. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -104
  96. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -11
  97. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -13
  98. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +61 -48
  99. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  100. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  101. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  102. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  103. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  104. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  105. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -7
  106. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  107. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  108. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -26
  109. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  110. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  111. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  112. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  113. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  114. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  115. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  116. package/dist/types/components.d.ts +8 -0
  117. package/dist/types/index.d.ts +1 -1
  118. package/dist/types/utils/utils.d.ts +2 -2
  119. package/package.json +114 -114
  120. package/react/components.d.ts +22 -0
  121. package/react/components.js +25 -0
  122. package/react/components.js.map +1 -0
  123. package/react/react-component-lib/createComponent.d.ts +10 -0
  124. package/react/react-component-lib/createComponent.js +59 -0
  125. package/react/react-component-lib/createComponent.js.map +1 -0
  126. package/react/react-component-lib/createOverlayComponent.d.ts +20 -0
  127. package/react/react-component-lib/createOverlayComponent.js +89 -0
  128. package/react/react-component-lib/createOverlayComponent.js.map +1 -0
  129. package/react/react-component-lib/index.d.ts +2 -0
  130. package/react/react-component-lib/index.js +3 -0
  131. package/react/react-component-lib/index.js.map +1 -0
  132. package/react/react-component-lib/interfaces.d.ts +29 -0
  133. package/react/react-component-lib/interfaces.js +1 -0
  134. package/react/react-component-lib/interfaces.js.map +1 -0
  135. package/react/react-component-lib/utils/attachProps.d.ts +12 -0
  136. package/react/react-component-lib/utils/attachProps.js +96 -0
  137. package/react/react-component-lib/utils/attachProps.js.map +1 -0
  138. package/react/react-component-lib/utils/case.d.ts +2 -0
  139. package/react/react-component-lib/utils/case.js +7 -0
  140. package/react/react-component-lib/utils/case.js.map +1 -0
  141. package/react/react-component-lib/utils/dev.d.ts +2 -0
  142. package/react/react-component-lib/utils/dev.js +13 -0
  143. package/react/react-component-lib/utils/dev.js.map +1 -0
  144. package/react/react-component-lib/utils/index.d.ts +7 -0
  145. package/react/react-component-lib/utils/index.js +21 -0
  146. package/react/react-component-lib/utils/index.js.map +1 -0
  147. package/dist/ezui/p-5185cbf1.entry.js +0 -1
  148. package/dist/ezui/p-5d600057.entry.js +0 -1
  149. package/dist/ezui/p-9f819174.js +0 -1
@@ -4,50 +4,50 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-9403fe8f.js');
6
6
  const RequestMetadata = require('./RequestMetadata-2cd01e8a.js');
7
- const DataUnit = require('./DataUnit-09a6e7be.js');
7
+ const DataUnit = require('./DataUnit-95368a67.js');
8
8
 
9
9
  const ezButtonCss = ":host{--bt--min-width:100px;--bt--height:42px;--bt__icon--width:18px;--bt__inline__icon--padding:12px;--bt--padding-top:var(--space--medium, 12px);--bt--padding-bottom:var(--space--medium, 12px);--bt--padding-right:var(--space--large, 24px);--bt--padding-left:var(--space--large, 24px);--bt--color:var(--text--inverted, #FFF);--bt--font-size:var(--text--medium, 14px);--bt--font-family:var(--font-pattern, Arial);--bt--font-weight:var(--text-weight--large);--bt--background-color:var(--color--primary, #c0c0c0);--bt--border-radius:var(--border--radius-large, 12px);--bt--border:none;--bt--hover--background-color:var(--color--primary-700, var(--bt--background-color));--bt--disabled--color:var(--color--disable-primary, var(--bt--color));--bt--disabled--background-color:var(--color--disabled, var(--bt--background-color));--bt--focus--border:var(--bt--border);--bt--focus--box-shadow:none}button{display:flex;align-items:center;justify-content:center;margin:0;cursor:pointer;transition:background-color 0.2s linear;min-width:var(--bt--min-width);height:var(--bt--height);font-family:var(--bt--font-family);font-size:var(--bt--font-size);font-weight:var(--bt--font-weight);padding:var(--bt--padding-top) var(--bt--padding-right) var(--bt--padding-bottom) var(--bt--padding-left);border-radius:var(--bt--border-radius);background-color:var(--bt--background-color);color:var(--bt--color);fill:var(--bt--color);border:var(--bt--border)}button:hover{background-color:var(--bt--hover--background-color)}button:focus{outline:none;border:var(--bt--focus--border);box-shadow:var(--bt--focus--box-shadow)}button:disabled{background-color:var(--bt--disabled--background-color);color:var(--bt--disabled--color);fill:var(--bt--disabled--color);border:none;cursor:no-drop}button.icon{width:42px;min-width:42px;height:42px;padding:0px}a{font-family:var(--bt--font-family);font-size:var(--bt--font-size);font-weight:var(--bt--font-weight);cursor:pointer;display:flex;align-items:center;justify-content:center}";
10
10
 
11
- const EzButton = class {
12
- constructor(hostRef) {
13
- index.registerInstance(this, hostRef);
14
- /**
15
- * Deixa o botão disponível ou não para interação com o usuário.
16
- */
17
- this.enabled = true;
18
- /**
19
- * Define o modo de uso do botão; opções: icon, link e regular
20
- */
21
- this.mode = "regular";
22
- }
23
- handleSlotChange(ev) {
24
- const slot = ev.target;
25
- const content = slot.assignedElements()[0];
26
- if (this.mode == "link") {
27
- content.style.display = "inline";
28
- if (slot.name == "leftIcon") {
29
- content.style.paddingRight = "var(--bt__inline__icon--padding)";
30
- }
31
- else if (slot.name == "rightIcon") {
32
- content.style.paddingLeft = "var(--bt__inline__icon--padding)";
33
- }
34
- }
35
- }
36
- render() {
37
- if (this.mode == "icon") {
38
- return (index.h("button", { class: "icon", type: "button", disabled: !this.enabled }, index.h("ez-icon", { class: "icon", href: this.image, size: "large", onClick: evt => {
39
- if (!this.enabled)
40
- evt.stopPropagation();
41
- } })));
42
- }
43
- else if (this.mode == "link") {
44
- return (index.h("a", null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
45
- }
46
- else {
47
- return (index.h("button", { type: "button", disabled: !this.enabled }, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
48
- }
49
- }
50
- };
11
+ const EzButton = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ /**
15
+ * Deixa o botão disponível ou não para interação com o usuário.
16
+ */
17
+ this.enabled = true;
18
+ /**
19
+ * Define o modo de uso do botão; opções: icon, link e regular
20
+ */
21
+ this.mode = "regular";
22
+ }
23
+ handleSlotChange(ev) {
24
+ const slot = ev.target;
25
+ const content = slot.assignedElements()[0];
26
+ if (this.mode == "link") {
27
+ content.style.display = "inline";
28
+ if (slot.name == "leftIcon") {
29
+ content.style.paddingRight = "var(--bt__inline__icon--padding)";
30
+ }
31
+ else if (slot.name == "rightIcon") {
32
+ content.style.paddingLeft = "var(--bt__inline__icon--padding)";
33
+ }
34
+ }
35
+ }
36
+ render() {
37
+ if (this.mode == "icon") {
38
+ return (index.h("button", { class: "icon", type: "button", disabled: !this.enabled }, index.h("ez-icon", { class: "icon", href: this.image, size: "large", onClick: evt => {
39
+ if (!this.enabled)
40
+ evt.stopPropagation();
41
+ } })));
42
+ }
43
+ else if (this.mode == "link") {
44
+ return (index.h("a", null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
45
+ }
46
+ else {
47
+ return (index.h("button", { type: "button", disabled: !this.enabled }, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
48
+ }
49
+ }
50
+ };
51
51
  EzButton.style = ezButtonCss;
52
52
 
53
53
  class FloatingEntry {
@@ -197,439 +197,439 @@ class DateUtils {
197
197
 
198
198
  const ezCalendarCss = ":host{--cal--font-family:var(--font-pattern, Arial);--cal--color:var(--title--primary, #626e82);--cal--text-shadow:var(--text-shadow, 0 0 0 #353535,0 0 1px transparent);--cal__body--background-color:var(--background--xlight, #FFF);--cal__body--padding:var(--space--medium, 12px);--cal__body--border-radius:var(--border--radius-medium, 12px);--cal__body--shadow:var(--shadow, 0px 0px 16px 0px #000);--cal__header-line--stroke:2px;--cal__header-line--color:var(--color--strokes, #C0C0C0);--cal__nav-btn--fill:var(--text--primary, #008561);--cal__nav-btn--over--fill:var(--color--primary, #350404);--cal__nav-btn--width:10px;--cal__nav-btn--height:16px;--cal__nav-btn--previous-path:path(\"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\");--cal__nav-btn--next-path:path(\"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\");--cal__cell--margin:0px var(--space--small, 12px);--cal__cell--width:var(--space--large, 24px);--cal__cell--padding:var(--space--extra-small, 3px) 0px;--cal__cell--border-radius:var(--border--radius-small, 6px);--cal__cell--over--background-color:var(--color--strokes, #C0C0C0);--cal__cell--outset--color:var(--color--strokes, #C0C0C0);--cal__cell--selected--background-color:var(--color--primary, #008561);--cal__cell--selected--color:var(--color--inverted, #FFF);--cal__btn-today--color:var(--color--primary);--cal__btn-today--hover--background-color:var(--color--strokes, #C0C0C0);--cal__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(--cal__body--background-color);padding:var(--cal__body--padding);border-radius:var(--cal__body--border-radius);box-shadow:var(--cal__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(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow);border-bottom:solid var(--cal__header-line--stroke) var(--cal__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(--cal__nav-btn--fill);width:var(--cal__nav-btn--width);height:var(--cal__nav-btn--height)}.calendar__btn-previous::after{clip-path:var(--cal__nav-btn--previous-path)}.calendar__btn-next::after{clip-path:var(--cal__nav-btn--next-path)}.calendar__btn-next:hover::after,.calendar__btn-previous:hover::after{background-color:var(--cal__nav-btn--over--fill)}.calendar__lbl-month{font-weight:var(--text-weight--large, 600);font-size:var(--title--medium, 16px);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--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(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow);padding:var(--cal__cell--padding);margin:var(--cal__cell--margin);min-width:var(--cal__cell--width);border-radius:var(--cal__cell--border-radius)}.calendar__cell:hover{background-color:var(--cal__cell--over--background-color)}.calendar__cell--secondary{color:var(--cal__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(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow)}.calendar__cell--selected,.calendar__cell--selected:hover{background-color:var(--cal__cell--selected--background-color);color:var(--cal__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(--cal--font-family);text-shadow:var(--cal--text-shadow);color:var(--cal__btn-today--color);border-radius:var(--cal__btn-today--border-radius)}.calendar__btn-today:hover{background-color:var(--cal__btn-today--hover--background-color)}";
199
199
 
200
- const EzCalendar = class {
201
- constructor(hostRef) {
202
- index.registerInstance(this, hostRef);
203
- this.ezChange = index.createEvent(this, "ezChange", 7);
204
- this._firstRender = true;
205
- this._todayLabel = 'Hoje';
206
- this._weekDayLabels = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];
207
- this._monthLabels = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];
208
- /**
209
- * A data selecionada no calendário
210
- */
211
- this.value = new Date();
212
- /**
213
- * No modo floating o calendário só se tornará visível
214
- * quando o método show() for acionado.
215
- */
216
- this.floating = false;
217
- }
218
- /**
219
- * Usado no modo floating. Faz com que o componente seja exibido.
220
- * É possível determinar ajustes de posicionamento através dos parâmetros
221
- * top, left, bottom e right. Esses parâmetros devem ser informados como
222
- * strings no formato css.
223
- */
224
- async show(top, left, bottom, right) {
225
- if (this.floating) {
226
- this._floatingID = FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
227
- }
228
- }
229
- /**
230
- * Usado no modo floating. Faz com que o componente seja ocultado.
231
- */
232
- async hide() {
233
- if (this._floatingID !== undefined) {
234
- FloatingManager.close(this._floatingID);
235
- this._floatingID = undefined;
236
- }
237
- }
238
- valueChanged() {
239
- if (this.value) {
240
- this._currentPosition.setTime(this.value.getTime());
241
- this._currentPosition.setDate(1);
242
- }
243
- }
244
- getMonthLabel() {
245
- return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
246
- }
247
- isSelectedDate(d) {
248
- if (this.value) {
249
- return this.value.getDate() == d.getDate() && this.value.getMonth() == d.getMonth() && this.value.getFullYear() == d.getFullYear();
250
- }
251
- return false;
252
- }
253
- changeMonth(offset) {
254
- this._currentPosition.setMonth(this._currentPosition.getMonth() + offset);
255
- index.forceUpdate(this);
256
- }
257
- selectDate(d) {
258
- this.value = d;
259
- this.ezChange.emit();
260
- }
261
- componentDidRender() {
262
- if (this.floating && this._firstRender) {
263
- this._box.remove();
264
- this._firstRender = false;
265
- }
266
- }
267
- render() {
268
- if (this._currentPosition == null) {
269
- this._currentPosition = new Date();
270
- this._currentPosition.setTime(this.value.getTime());
271
- this._currentPosition.setDate(1);
272
- }
273
- const firstDate = new Date();
274
- firstDate.setTime(this._currentPosition.getTime());
275
- firstDate.setDate(1 - firstDate.getDay());
276
- return (index.h("section", { ref: elem => this._container = elem }, index.h("div", { class: "calendar", ref: elem => this._box = elem }, 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 => {
277
- const date = new Date();
278
- date.setTime(firstDate.getTime());
279
- date.setDate(date.getDate() + offset + index$1);
280
- let classNames = "calendar__cell";
281
- if (this._currentPosition.getMonth() != date.getMonth()) {
282
- classNames += " calendar__cell--secondary";
283
- }
284
- else if (this.isSelectedDate(date)) {
285
- classNames += " calendar__cell--selected";
286
- }
287
- return index.h("div", { class: classNames, onClick: () => this.selectDate(date) }, date.getDate());
288
- })))), index.h("div", { class: "calendar__footer" }, index.h("button", { class: "calendar__btn-today", onClick: () => this.selectDate(new Date()) }, this._todayLabel)))));
289
- }
290
- static get watchers() { return {
291
- "value": ["valueChanged"]
292
- }; }
293
- };
200
+ const EzCalendar = class {
201
+ constructor(hostRef) {
202
+ index.registerInstance(this, hostRef);
203
+ this.ezChange = index.createEvent(this, "ezChange", 7);
204
+ this._firstRender = true;
205
+ this._todayLabel = 'Hoje';
206
+ this._weekDayLabels = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];
207
+ this._monthLabels = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];
208
+ /**
209
+ * A data selecionada no calendário
210
+ */
211
+ this.value = new Date();
212
+ /**
213
+ * No modo floating o calendário só se tornará visível
214
+ * quando o método show() for acionado.
215
+ */
216
+ this.floating = false;
217
+ }
218
+ /**
219
+ * Usado no modo floating. Faz com que o componente seja exibido.
220
+ * É possível determinar ajustes de posicionamento através dos parâmetros
221
+ * top, left, bottom e right. Esses parâmetros devem ser informados como
222
+ * strings no formato css.
223
+ */
224
+ async show(top, left, bottom, right) {
225
+ if (this.floating) {
226
+ this._floatingID = FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
227
+ }
228
+ }
229
+ /**
230
+ * Usado no modo floating. Faz com que o componente seja ocultado.
231
+ */
232
+ async hide() {
233
+ if (this._floatingID !== undefined) {
234
+ FloatingManager.close(this._floatingID);
235
+ this._floatingID = undefined;
236
+ }
237
+ }
238
+ valueChanged() {
239
+ if (this.value) {
240
+ this._currentPosition.setTime(this.value.getTime());
241
+ this._currentPosition.setDate(1);
242
+ }
243
+ }
244
+ getMonthLabel() {
245
+ return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
246
+ }
247
+ isSelectedDate(d) {
248
+ if (this.value) {
249
+ return this.value.getDate() == d.getDate() && this.value.getMonth() == d.getMonth() && this.value.getFullYear() == d.getFullYear();
250
+ }
251
+ return false;
252
+ }
253
+ changeMonth(offset) {
254
+ this._currentPosition.setMonth(this._currentPosition.getMonth() + offset);
255
+ index.forceUpdate(this);
256
+ }
257
+ selectDate(d) {
258
+ this.value = d;
259
+ this.ezChange.emit();
260
+ }
261
+ componentDidRender() {
262
+ if (this.floating && this._firstRender) {
263
+ this._box.remove();
264
+ this._firstRender = false;
265
+ }
266
+ }
267
+ render() {
268
+ if (this._currentPosition == null) {
269
+ this._currentPosition = new Date();
270
+ this._currentPosition.setTime(this.value.getTime());
271
+ this._currentPosition.setDate(1);
272
+ }
273
+ const firstDate = new Date();
274
+ firstDate.setTime(this._currentPosition.getTime());
275
+ firstDate.setDate(1 - firstDate.getDay());
276
+ return (index.h("section", { ref: elem => this._container = elem }, index.h("div", { class: "calendar", ref: elem => this._box = elem }, 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 => {
277
+ const date = new Date();
278
+ date.setTime(firstDate.getTime());
279
+ date.setDate(date.getDate() + offset + index$1);
280
+ let classNames = "calendar__cell";
281
+ if (this._currentPosition.getMonth() != date.getMonth()) {
282
+ classNames += " calendar__cell--secondary";
283
+ }
284
+ else if (this.isSelectedDate(date)) {
285
+ classNames += " calendar__cell--selected";
286
+ }
287
+ return index.h("div", { class: classNames, onClick: () => this.selectDate(date) }, date.getDate());
288
+ })))), index.h("div", { class: "calendar__footer" }, index.h("button", { class: "calendar__btn-today", onClick: () => this.selectDate(new Date()) }, this._todayLabel)))));
289
+ }
290
+ static get watchers() { return {
291
+ "value": ["valueChanged"]
292
+ }; }
293
+ };
294
294
  EzCalendar.style = ezCalendarCss;
295
295
 
296
296
  const ezCheckCss = ":host{--chk--box--width:18px;--chk--box--height:18px;--chk--width:calc(var(--chk--box--width) + 14px);--chk--height:calc(var(--chk--box--width) + 14px);--chk--border-radius:var(--border--radius-small);--chk--checked--background-color:var(--color--primary-200);--chk--focus--background-color:var(--color--strokes, #FFFFFF);--chk--hover--background-color:var(--background--medium);--chk--checked--disabled--background-color:var(--color--disable-secondary);--chk--border:var(--border--medium) var(--title--primary);--chk--disabled--border:var(--border--medium) var(--color--strokes);--chk--checked--border:var(--border--medium) var(--color--primary);--chk--checked--hover--background-color:var(--color--primary-200);--chk--checked--focus--background-color:var(--color--primary-300, #FFFFFF);--chk--check--clip-path:polygon(40% 70%, 46% 73%, 51% 71%, 93% 21%, 93% 16%, 83% 8%, 76% 9%, 47% 45%, 43% 44%, 38% 39%, 30% 37%, 22% 47%, 23% 54%, 40% 70%);--chk--check--background-color:var(--color--primary);--chk--check--disabled--background-color:var(--color--strokes);--swt--slider--width:34px;--swt--slider--height:14px;--swt--pin--width:20px;--swt--pin--height:20px;--swt--focus--width:32px;--swt--focus--height:32px;--swt--background-color:var(--color--strokes);--swt--disabled--background-color:var(--color--disable-secondary);--swt--checked--background-color:var(--color--primary-300);--swt--pin--background-color:var(--background--xlight);--swt--pin--disabled--background-color:var(--color--disable-secondary);--swt--pin--checked--background-color:var(--color--primary);--swt--pin--checked--disabled--background-color:#E8F7F4;--swt--pin--focus--background-color:var(--text--disable);--swt--pin--checked--focus--background-color:var(--color--primary);width:100%}input.regularMode{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;box-sizing:border-box;-webkit-appearance:none;cursor:pointer;border-radius:50%;width:var(--chk--width);height:var(--chk--height)}input.regularMode:enabled:hover{background-color:var(--chk--hover--background-color)}input.regularMode:enabled:focus{outline:none;background-color:var(--chk--focus--background-color)}input.regularMode:disabled{cursor:auto;background:none}input.regularMode::before{box-sizing:border-box;content:\"\";display:block;width:var(--chk--box--width);height:var(--chk--box--height);border-radius:var(--chk--border-radius);border:var(--chk--border)}input.regularMode:disabled::before{border:var(--chk--disabled--border)}input.regularMode:checked:enabled:hover{background-color:var(--chk--checked--hover--background-color)}input.regularMode:checked:enabled:focus{background-color:var(--chk--checked--focus--background-color)}input.regularMode:checked::before{border:var(--chk--checked--border);background-color:var(--chk--checked--background-color)}input.regularMode:checked:disabled:before{border:var(--chk--disabled--border);background-color:var(--chk--checked--disabled--background-color)}input.regularMode:checked::after{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;content:\"\";position:absolute;margin-top:3px;margin-left:-1px;width:12px;height:12px;background-color:var(--chk--check--background-color);clip-path:var(--chk--check--clip-path)}input.regularMode:checked:disabled::after{background-color:var(--chk--check--disabled--background-color)}input.switchMode{appearance:none;position:relative;outline:none;cursor:pointer;border-radius:20px;border:none;transition:background-color var(--transition);width:var(--swt--slider--width);height:var(--swt--slider--height);background-color:var(--swt--background-color)}input.switchMode:disabled{background-color:var(--swt--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(--swt--pin--width);height:var(--swt--pin--height);background-color:var(--swt--pin--background-color)}input.switchMode:disabled::after{background-color:var(--swt--pin--disabled--background-color)}input.switchMode:checked{transition:background-color var(--transition);background-color:var(--swt--checked--background-color)}input.switchMode::before{display:block;content:\"\";display:block;position:absolute;border-radius:50%;opacity:0;width:var(--swt--focus--width);height:var(--swt--focus--height);top:calc((var(--swt--slider--height) - var(--swt--focus--height)) / 2);left:calc((var(--swt--pin--width) - var(--swt--focus--width))/2);background-color:var(--swt--pin--focus--background-color)}input.switchMode:focus::before{opacity:0.24;transition:opacity var(--transition)}input.switchMode:checked:focus::before{background-color:var(--swt--pin--checked--focus--background-color);transform:translateX(calc(var(--swt--slider--width) - var(--swt--pin--width)))}input.switchMode:checked::after{transition:transform var(--transition);transition:background-color var(--transition);transform:translateX(calc(var(--swt--slider--width) - var(--swt--pin--width))) translateY(-3px);box-shadow:var(--shadow);background-color:var(--swt--pin--checked--background-color)}input.switchMode:checked:disabled::after{background-color:var(--swt--pin--checked--disabled--background-color)}";
297
297
 
298
- const EzCheck = class {
299
- constructor(hostRef) {
300
- index.registerInstance(this, hostRef);
301
- this.valueChange = index.createEvent(this, "valueChange", 7);
302
- /**
303
- * Deixa o campo disponível ou não interagir com o usuário.
304
- */
305
- this.enabled = true;
306
- /**
307
- * Existem dois modos de visualização: regular e switch.
308
- * Se esta propriedade for omitida, o componete assume o formato "regular";
309
- * No modo "regular" a visualização é a tradicional de uma caixinha marcada/desmarcada.
310
- * No modo "switch" o campo tem uma interface em formato de um pino liga/desliga.
311
- */
312
- this.mode = "regular";
313
- }
314
- adjustMode() {
315
- if (this.mode === "switch") {
316
- this._inputElem.classList.remove("regularMode");
317
- this._inputElem.classList.add("switchMode");
318
- }
319
- else {
320
- this._inputElem.classList.remove("switchMode");
321
- this._inputElem.classList.add("regularMode");
322
- }
323
- }
324
- //---------------------------------------------
325
- // Public methods
326
- //---------------------------------------------
327
- /**
328
- * Devolve o modo escolhido para o componente
329
- */
330
- async getMode() {
331
- return this.mode;
332
- }
333
- /**
334
- * Faz o foco no componente de input
335
- */
336
- async setFocus() {
337
- this._inputElem.focus();
338
- }
339
- componentDidLoad() {
340
- this.adjustMode();
341
- }
342
- changeValue() {
343
- this.value = !this.value;
344
- this.valueChange.emit();
345
- }
346
- render() {
347
- return (index.h("input", { type: "checkbox", class: "regularMode", checked: this.value === true, onChange: () => { this.changeValue(); }, disabled: !this.enabled, ref: (el) => this._inputElem = el }));
348
- }
349
- static get watchers() { return {
350
- "mode": ["adjustMode"]
351
- }; }
352
- };
298
+ const EzCheck = class {
299
+ constructor(hostRef) {
300
+ index.registerInstance(this, hostRef);
301
+ this.valueChange = index.createEvent(this, "valueChange", 7);
302
+ /**
303
+ * Deixa o campo disponível ou não interagir com o usuário.
304
+ */
305
+ this.enabled = true;
306
+ /**
307
+ * Existem dois modos de visualização: regular e switch.
308
+ * Se esta propriedade for omitida, o componete assume o formato "regular";
309
+ * No modo "regular" a visualização é a tradicional de uma caixinha marcada/desmarcada.
310
+ * No modo "switch" o campo tem uma interface em formato de um pino liga/desliga.
311
+ */
312
+ this.mode = "regular";
313
+ }
314
+ adjustMode() {
315
+ if (this.mode === "switch") {
316
+ this._inputElem.classList.remove("regularMode");
317
+ this._inputElem.classList.add("switchMode");
318
+ }
319
+ else {
320
+ this._inputElem.classList.remove("switchMode");
321
+ this._inputElem.classList.add("regularMode");
322
+ }
323
+ }
324
+ //---------------------------------------------
325
+ // Public methods
326
+ //---------------------------------------------
327
+ /**
328
+ * Devolve o modo escolhido para o componente
329
+ */
330
+ async getMode() {
331
+ return this.mode;
332
+ }
333
+ /**
334
+ * Faz o foco no componente de input
335
+ */
336
+ async setFocus() {
337
+ this._inputElem.focus();
338
+ }
339
+ componentDidLoad() {
340
+ this.adjustMode();
341
+ }
342
+ changeValue() {
343
+ this.value = !this.value;
344
+ this.valueChange.emit();
345
+ }
346
+ render() {
347
+ return (index.h("input", { type: "checkbox", class: "regularMode", checked: this.value === true, onChange: () => { this.changeValue(); }, disabled: !this.enabled, ref: (el) => this._inputElem = el }));
348
+ }
349
+ static get watchers() { return {
350
+ "mode": ["adjustMode"]
351
+ }; }
352
+ };
353
353
  EzCheck.style = ezCheckCss;
354
354
 
355
355
  const ezCollapsableBoxCss = ":host{--collapsable-box--height:42px;--collapsable-box--font-size:var(--title--medium, 14px);--collapsable-box--font-family:var(--font-pattern, Arial);--collapsable-box--font-weight:var(--text-weight--large, 600);--collapsable-box--color:var(--title--primary);--collapsable-box__btn--path:path(\"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\");--collapsable-box__btn--fill:var(--collapsable-box--color);--collapsable-box__btn--width:10px;--collapsable-box__btn--height:16px;display:flex;flex-wrap:wrap;width:100%}.collapsable-box__title{width:100%;display:flex;box-sizing:border-box}.collapsable-box__label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;font-family:var(--collapsable-box--font-family);font-size:var(--collapsable-box--font-size);font-weight:var(--collapsable-box--font-weight);color:var(--collapsable-box--color)}.collapsable-box__btn{outline:none;border:none;background-color:unset;cursor:pointer;padding:1px 6px}.collapsable-box__btn::after{content:'';display:flex;clip-path:var(--collapsable-box__btn--path);background-color:var( --collapsable-box__btn--fill);width:var(--collapsable-box__btn--width);height:var(--collapsable-box__btn--height);transition:transform var(--transition);transform:rotate(90deg)}.collapsable-box__btn--collapsed::after{transform:rotate(0deg)}";
356
356
 
357
- const EzCollapsableBox = class {
358
- constructor(hostRef) {
359
- index.registerInstance(this, hostRef);
360
- this.ezChange = index.createEvent(this, "ezChange", 7);
361
- /**
362
- * Valor externalizado que garante a exibição ou não do componente
363
- */
364
- this.value = false;
365
- }
366
- observeValue() {
367
- this.ezChange.emit();
368
- }
369
- /**
370
- * Esconde ou revela o conteúdo do componente
371
- */
372
- async showHide() {
373
- this.value = !this.value;
374
- }
375
- render() {
376
- return (index.h(index.Host, null, index.h("div", { class: "collapsable-box__title" }, index.h("button", { class: this.value ? "collapsable-box__btn collapsable-box__btn--collapsed" : "collapsable-box__btn", onClick: () => this.showHide() }), index.h("label", { class: "collapsable-box__label", title: this.label }, this.label)), !this.value ? index.h("slot", null) : null));
377
- }
378
- static get watchers() { return {
379
- "value": ["observeValue"]
380
- }; }
381
- };
357
+ const EzCollapsableBox = class {
358
+ constructor(hostRef) {
359
+ index.registerInstance(this, hostRef);
360
+ this.ezChange = index.createEvent(this, "ezChange", 7);
361
+ /**
362
+ * Valor externalizado que garante a exibição ou não do componente
363
+ */
364
+ this.value = false;
365
+ }
366
+ observeValue() {
367
+ this.ezChange.emit();
368
+ }
369
+ /**
370
+ * Esconde ou revela o conteúdo do componente
371
+ */
372
+ async showHide() {
373
+ this.value = !this.value;
374
+ }
375
+ render() {
376
+ return (index.h(index.Host, null, index.h("div", { class: "collapsable-box__title" }, index.h("button", { class: this.value ? "collapsable-box__btn collapsable-box__btn--collapsed" : "collapsable-box__btn", onClick: () => this.showHide() }), index.h("label", { class: "collapsable-box__label", title: this.label }, this.label)), !this.value ? index.h("slot", null) : null));
377
+ }
378
+ static get watchers() { return {
379
+ "value": ["observeValue"]
380
+ }; }
381
+ };
382
382
  EzCollapsableBox.style = ezCollapsableBoxCss;
383
383
 
384
384
  const ezComboBoxCss = ":host{--cx--height:42px;--cx--width:100%;--cx__icon--width:48px;--cx--border-radius:var(--border--radius-medium, 12px);--cx--border-radius-small:var(--border--radius-small, 6px);--cx--font-size:var(--text--medium, 14px);--cx--font-family:var(--font-pattern, Arial);--cx--font-weight--large:var(--text-weight--large, 500);--cx--font-weight--medium:var(--text-weight--medium, 400);--cx--space--medium:var(--space--medium, 12px);--cx--space--small:var(--space--small, 6px);--cx--shadow:var(--shadow, 0px 0px 16px 0px rgba(0, 38, 111, .12));--cx--background-color--xlight:var(--background--xlight,#fff);--cx__input--background-color:var(--background--medium, #e0e0e0);--cx__input--border:var(--border--medium, 2px solid);--cx__input--border-color:var(--cx__input--background-color);--cx__input--focus--border-color:var(--color--primary, #008561);--cx__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--cx__input--disabled--color:var(--text--disable, #AFB6C0);--cx__input--error--border-color:#CC2936;--cx__label--color:var(--title--primary, #919191);--cx__message_box--font-size:var(--text--small, 12px);--cx__message_box--info--color:var(--color--success, #22085d);--cx__message_box--error--color:var(--color--error, #FF0000);--cx__list-text--primary:var(--text--primary,#626e82);--cx__list-text--secondary:var(--text--secondary,#a2abb9);--cx__list-height:calc(var(--cx--font-size) + var(--cx--space--medium));display:flex;flex-wrap:wrap;position:relative;width:var(--cx--width)}ez-text-input{--it__input--background-color:var(--cx__input--background-color, #FFFFFF);--it__input--border-color:var(--cx__input--border-color, #DCE0E8)}.invisible{visibility:hidden}.list-container{scroll-behavior:smooth;z-index:var(--cx__list-z-index);padding:var(--cx--space--small);background:var(--cx--background-color--xlight);border-radius:var(--cx--border-radius);width:100%;overflow:auto;box-sizing:border-box;max-height:calc(4*var(--cx__list-height) + 2*var(--cx--space--small))}li{list-style-type:none;border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);display:flex;justify-content:space-between;align-items:center}li:hover{background-color:var(--background--medium)}.--li--preselected{background-color:var(--background--strong)}.--li__spanlabel{color:var(--cx__list-text--primary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--large);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:80%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanlabel--full-width{color:var(--cx__list-text--primary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--large);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:100%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanvalue{color:var(--cx__list-text--secondary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--medium);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:20%;min-width:20px;overflow-x:hidden;text-align:left}.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(--text--primary, #008561);width:16px;height:16px;clip-path:path(\"M 1.8585859,3.0707069 7.9999998,9.2121212 14.141414,3.0707069 16,5.0101006 7.9999998,12.929293 0,4.9292932 Z\")}.btn-open-options:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-options:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}";
385
385
 
386
- const EzComboBox = class {
387
- constructor(hostRef) {
388
- index.registerInstance(this, hostRef);
389
- this.ezChange = index.createEvent(this, "ezChange", 7);
390
- this._inputLabelValue = '';
391
- /**
392
- * Valor associado ao componente. Este é o valor que o componente recebe ao selecionar uma opção do combobox.
393
- * Pode ser Label ou Value de acordo com a opção "labelasindex"
394
- * Caso seja atribuído um valor ao componente que não esteja na relação das options, este vai lançar msg de erro
395
- * (executo pala valor undefined)
396
- */
397
- this.value = undefined;
398
- /**
399
- * Label é o título do campo
400
- */
401
- this.label = undefined;
402
- /**
403
- * Deixa o campo disponível ou não para digitação.
404
- */
405
- this.enabled = true;
406
- /**
407
- * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
408
- */
409
- this.showvalue = false;
410
- }
411
- //---------------------------------------------
412
- // Public methods
413
- //---------------------------------------------
414
- /**
415
- * Faz o foco no componente de textarea
416
- */
417
- async setFocus() {
418
- this._textInput.setFocus();
419
- }
420
- /**
421
- * Remove o foco no componente de textarea
422
- */
423
- async setBlur() {
424
- this._textInput.setBlur();
425
- }
426
- updateValue() {
427
- const selectedOption = this.options.filter(opt => opt.value === this.value);
428
- if (selectedOption && selectedOption.length > 0) {
429
- this._textInput.value = selectedOption[0].label;
430
- }
431
- else {
432
- this.value = null;
433
- this._textInput.value = '';
434
- }
435
- }
436
- setErrorMessage() {
437
- this._textInput.errormessage = this.errormessage;
438
- }
439
- showOptions() {
440
- if (this.enabled) {
441
- this._criteria = undefined;
442
- const top = this._textInput.errormessage ? '0px' : '-17px';
443
- this._popover.show(top);
444
- }
445
- }
446
- updateSelection() {
447
- const selectedOption = this.options.filter(opt => opt.label === this._textInput.value);
448
- this.selectOption((selectedOption && selectedOption.length > 0) ? selectedOption[0] : null);
449
- }
450
- selectOption(opt) {
451
- this._popover.hide();
452
- this.value = opt ? opt.value : null;
453
- this.ezChange.emit();
454
- }
455
- buildItem(opt, index$1) {
456
- const className = index$1 === this._preSelection ? "--li--preselected" : "";
457
- return index.h("li", { class: className, key: opt.value, id: 'item_' + opt.value, onMouseDown: () => this.selectOption(opt) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { class: '--li__spanvalue' }, opt.value) : null);
458
- }
459
- highlightMatch(label) {
460
- const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
461
- if (this._criteria) {
462
- const criteriaLength = this._criteria.length;
463
- const matchStart = label.toUpperCase().indexOf(this._criteria);
464
- if (matchStart > -1) {
465
- const strLabelStart = label.substr(0, matchStart);
466
- const strLabelEnd = label.substr(matchStart + criteriaLength);
467
- const strMatch = label.substr(matchStart, criteriaLength);
468
- return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
469
- }
470
- }
471
- return (index.h("span", { class: spanClassName }, label));
472
- }
473
- matchOptions() {
474
- this.showOptions();
475
- this._criteria = this._textInput.value.toLocaleUpperCase();
476
- this.filterOptions();
477
- }
478
- filterOptions() {
479
- this._preSelection = undefined;
480
- let opts = (this.options || []);
481
- if (this._criteria) {
482
- opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(this._criteria) > -1);
483
- }
484
- this._visibleOptions = [{ value: '', label: '' }].concat(opts);
485
- }
486
- nextOption() {
487
- this.showOptions();
488
- this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
489
- this.scrollToOption(this._visibleOptions[this._preSelection]);
490
- }
491
- previousOption() {
492
- this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
493
- this.scrollToOption(this._visibleOptions[this._preSelection]);
494
- }
495
- scrollToOption(opt) {
496
- const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
497
- if (liElem) {
498
- const parent = liElem.parentElement;
499
- const parentRect = parent.getBoundingClientRect();
500
- const itemRect = liElem.getBoundingClientRect();
501
- if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
502
- liElem.scrollIntoView();
503
- }
504
- }
505
- }
506
- selectCurrentOption() {
507
- if (this._preSelection !== undefined) {
508
- this.selectOption(this._visibleOptions[this._preSelection]);
509
- this._preSelection = undefined;
510
- }
511
- }
512
- keyDownHandler(event) {
513
- switch (event.key) {
514
- case "ArrowDown":
515
- this.nextOption();
516
- break;
517
- case "ArrowUp":
518
- this.previousOption();
519
- break;
520
- case "Enter":
521
- this.selectCurrentOption();
522
- break;
523
- }
524
- event.stopPropagation();
525
- }
526
- //---------------------------------------------
527
- // Lifecycle web component
528
- //---------------------------------------------
529
- componentWillLoad() {
530
- if (this.options === undefined) {
531
- this.options = [];
532
- const optionsTags = this.el.querySelectorAll('option');
533
- if (optionsTags) {
534
- optionsTags.forEach(e => {
535
- let label = e.innerText;
536
- let value = e.getAttribute('value');
537
- if (!value) {
538
- value = label;
539
- }
540
- this.options.push({ label, value });
541
- e.hidden = true;
542
- });
543
- }
544
- }
545
- this.filterOptions();
546
- }
547
- componentDidLoad() {
548
- this.updateValue();
549
- }
550
- render() {
551
- return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => this._textInput = el, value: this._inputLabelValue, enabled: this.enabled, onInput: () => this.matchOptions(), onClick: () => this.showOptions(), onFocusout: () => this.updateSelection(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), index.h("ez-popover", { boxwidth: "100%", ref: el => this._popover = el, autoclose: true }, index.h("div", { class: "list-container" }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
552
- }
553
- ;
554
- get el() { return index.getElement(this); }
555
- static get watchers() { return {
556
- "value": ["updateValue"],
557
- "errormessage": ["setErrorMessage"]
558
- }; }
559
- };
386
+ const EzComboBox = class {
387
+ constructor(hostRef) {
388
+ index.registerInstance(this, hostRef);
389
+ this.ezChange = index.createEvent(this, "ezChange", 7);
390
+ this._inputLabelValue = '';
391
+ /**
392
+ * Valor associado ao componente. Este é o valor que o componente recebe ao selecionar uma opção do combobox.
393
+ * Pode ser Label ou Value de acordo com a opção "labelasindex"
394
+ * Caso seja atribuído um valor ao componente que não esteja na relação das options, este vai lançar msg de erro
395
+ * (executo pala valor undefined)
396
+ */
397
+ this.value = undefined;
398
+ /**
399
+ * Label é o título do campo
400
+ */
401
+ this.label = undefined;
402
+ /**
403
+ * Deixa o campo disponível ou não para digitação.
404
+ */
405
+ this.enabled = true;
406
+ /**
407
+ * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
408
+ */
409
+ this.showvalue = false;
410
+ }
411
+ //---------------------------------------------
412
+ // Public methods
413
+ //---------------------------------------------
414
+ /**
415
+ * Faz o foco no componente de textarea
416
+ */
417
+ async setFocus() {
418
+ this._textInput.setFocus();
419
+ }
420
+ /**
421
+ * Remove o foco no componente de textarea
422
+ */
423
+ async setBlur() {
424
+ this._textInput.setBlur();
425
+ }
426
+ updateValue() {
427
+ const selectedOption = this.options.filter(opt => opt.value === this.value);
428
+ if (selectedOption && selectedOption.length > 0) {
429
+ this._textInput.value = selectedOption[0].label;
430
+ }
431
+ else {
432
+ this.value = null;
433
+ this._textInput.value = '';
434
+ }
435
+ }
436
+ setErrorMessage() {
437
+ this._textInput.errormessage = this.errormessage;
438
+ }
439
+ showOptions() {
440
+ if (this.enabled) {
441
+ this._criteria = undefined;
442
+ const top = this._textInput.errormessage ? '0px' : '-17px';
443
+ this._popover.show(top);
444
+ }
445
+ }
446
+ updateSelection() {
447
+ const selectedOption = this.options.filter(opt => opt.label === this._textInput.value);
448
+ this.selectOption((selectedOption && selectedOption.length > 0) ? selectedOption[0] : null);
449
+ }
450
+ selectOption(opt) {
451
+ this._popover.hide();
452
+ this.value = opt ? opt.value : null;
453
+ this.ezChange.emit();
454
+ }
455
+ buildItem(opt, index$1) {
456
+ const className = index$1 === this._preSelection ? "--li--preselected" : "";
457
+ return index.h("li", { class: className, key: opt.value, id: 'item_' + opt.value, onMouseDown: () => this.selectOption(opt) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { class: '--li__spanvalue' }, opt.value) : null);
458
+ }
459
+ highlightMatch(label) {
460
+ const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
461
+ if (this._criteria) {
462
+ const criteriaLength = this._criteria.length;
463
+ const matchStart = label.toUpperCase().indexOf(this._criteria);
464
+ if (matchStart > -1) {
465
+ const strLabelStart = label.substr(0, matchStart);
466
+ const strLabelEnd = label.substr(matchStart + criteriaLength);
467
+ const strMatch = label.substr(matchStart, criteriaLength);
468
+ return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
469
+ }
470
+ }
471
+ return (index.h("span", { class: spanClassName }, label));
472
+ }
473
+ matchOptions() {
474
+ this.showOptions();
475
+ this._criteria = this._textInput.value.toLocaleUpperCase();
476
+ this.filterOptions();
477
+ }
478
+ filterOptions() {
479
+ this._preSelection = undefined;
480
+ let opts = (this.options || []);
481
+ if (this._criteria) {
482
+ opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(this._criteria) > -1);
483
+ }
484
+ this._visibleOptions = [{ value: '', label: '' }].concat(opts);
485
+ }
486
+ nextOption() {
487
+ this.showOptions();
488
+ this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
489
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
490
+ }
491
+ previousOption() {
492
+ this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
493
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
494
+ }
495
+ scrollToOption(opt) {
496
+ const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
497
+ if (liElem) {
498
+ const parent = liElem.parentElement;
499
+ const parentRect = parent.getBoundingClientRect();
500
+ const itemRect = liElem.getBoundingClientRect();
501
+ if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
502
+ liElem.scrollIntoView();
503
+ }
504
+ }
505
+ }
506
+ selectCurrentOption() {
507
+ if (this._preSelection !== undefined) {
508
+ this.selectOption(this._visibleOptions[this._preSelection]);
509
+ this._preSelection = undefined;
510
+ }
511
+ }
512
+ keyDownHandler(event) {
513
+ switch (event.key) {
514
+ case "ArrowDown":
515
+ this.nextOption();
516
+ break;
517
+ case "ArrowUp":
518
+ this.previousOption();
519
+ break;
520
+ case "Enter":
521
+ this.selectCurrentOption();
522
+ break;
523
+ }
524
+ event.stopPropagation();
525
+ }
526
+ //---------------------------------------------
527
+ // Lifecycle web component
528
+ //---------------------------------------------
529
+ componentWillLoad() {
530
+ if (this.options === undefined) {
531
+ this.options = [];
532
+ const optionsTags = this.el.querySelectorAll('option');
533
+ if (optionsTags) {
534
+ optionsTags.forEach(e => {
535
+ let label = e.innerText;
536
+ let value = e.getAttribute('value');
537
+ if (!value) {
538
+ value = label;
539
+ }
540
+ this.options.push({ label, value });
541
+ e.hidden = true;
542
+ });
543
+ }
544
+ }
545
+ this.filterOptions();
546
+ }
547
+ componentDidLoad() {
548
+ this.updateValue();
549
+ }
550
+ render() {
551
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => this._textInput = el, value: this._inputLabelValue, enabled: this.enabled, onInput: () => this.matchOptions(), onClick: () => this.showOptions(), onFocusout: () => this.updateSelection(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), index.h("ez-popover", { boxwidth: "100%", ref: el => this._popover = el, autoclose: true }, index.h("div", { class: "list-container" }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
552
+ }
553
+ ;
554
+ get el() { return index.getElement(this); }
555
+ static get watchers() { return {
556
+ "value": ["updateValue"],
557
+ "errormessage": ["setErrorMessage"]
558
+ }; }
559
+ };
560
560
  EzComboBox.style = ezComboBoxCss;
561
561
 
562
562
  const ezDateInputCss = ":host{display:block;width:100%;--it__input--background-color:var(--background--medium, #e0e0e0);--it__input--border-color:var(--it__input--background-color)}.text-input{--it__input--background-color:inherit;--it__input--border-color:inherit}.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;clip-path:path(\"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\")}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}";
563
563
 
564
- const EzDateInput = class {
565
- constructor(hostRef) {
566
- index.registerInstance(this, hostRef);
567
- this.ezChange = index.createEvent(this, "ezChange", 7);
568
- /**
569
- * Deixa o campo disponível ou não para uso.
570
- */
571
- this.enabled = true;
572
- }
573
- setLabel() {
574
- this._textInput.label = this.label;
575
- }
576
- setErrorMessage() {
577
- this._textInput.errormessage = this.errormessage;
578
- }
579
- applyValueToInput() {
580
- this._textInput.value = this.getTextValue(this.value);
581
- }
582
- changeValue(newValue) {
583
- newValue = newValue == null ? null : DateUtils.clearTime(newValue);
584
- this._textInput.errormessage = "";
585
- if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
586
- this.value = newValue;
587
- this.ezChange.emit();
588
- }
589
- }
590
- showCalendar() {
591
- this.parseDate();
592
- this._calendar.value = this.value;
593
- //FIXME: Provavelmente isso fará com que o popup abra em uma
594
- //posição errada no futuro. Preferi fazer simples no começo,
595
- //porque não quis onerar o text input com essa funcionalidade...
596
- const top = this._textInput.errormessage ? '0px' : '-17px';
597
- this._calendar.show(top);
598
- }
599
- hideCalendar() {
600
- this.changeValue(this._calendar.value);
601
- this._calendar.hide();
602
- }
603
- parseDate() {
604
- const strValue = this._textInput.value;
605
- const parsedDate = DateUtils.strToDate(strValue);
606
- if (parsedDate || !strValue) {
607
- if (this.value === parsedDate) {
608
- this.changeValue(this.value);
609
- }
610
- else {
611
- this.changeValue(parsedDate);
612
- }
613
- }
614
- else {
615
- this._textInput.errormessage = "O valor digitado não é uma data válida";
616
- }
617
- }
618
- getTextValue(d) {
619
- return d ? new Intl.DateTimeFormat('pt-BR').format(d) : null;
620
- }
621
- render() {
622
- return (index.h(index.Host, null, index.h("ez-text-input", { class: "text-input", ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
623
- if (event.key === 'H' || event.key === 'h')
624
- this.changeValue(new Date());
625
- }, 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 })));
626
- }
627
- static get watchers() { return {
628
- "label": ["setLabel"],
629
- "errormessage": ["setErrorMessage"],
630
- "value": ["applyValueToInput"]
631
- }; }
632
- };
564
+ const EzDateInput = class {
565
+ constructor(hostRef) {
566
+ index.registerInstance(this, hostRef);
567
+ this.ezChange = index.createEvent(this, "ezChange", 7);
568
+ /**
569
+ * Deixa o campo disponível ou não para uso.
570
+ */
571
+ this.enabled = true;
572
+ }
573
+ setLabel() {
574
+ this._textInput.label = this.label;
575
+ }
576
+ setErrorMessage() {
577
+ this._textInput.errormessage = this.errormessage;
578
+ }
579
+ applyValueToInput() {
580
+ this._textInput.value = this.getTextValue(this.value);
581
+ }
582
+ changeValue(newValue) {
583
+ newValue = newValue == null ? null : DateUtils.clearTime(newValue);
584
+ this._textInput.errormessage = "";
585
+ if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
586
+ this.value = newValue;
587
+ this.ezChange.emit();
588
+ }
589
+ }
590
+ showCalendar() {
591
+ this.parseDate();
592
+ this._calendar.value = this.value;
593
+ //FIXME: Provavelmente isso fará com que o popup abra em uma
594
+ //posição errada no futuro. Preferi fazer simples no começo,
595
+ //porque não quis onerar o text input com essa funcionalidade...
596
+ const top = this._textInput.errormessage ? '0px' : '-17px';
597
+ this._calendar.show(top);
598
+ }
599
+ hideCalendar() {
600
+ this.changeValue(this._calendar.value);
601
+ this._calendar.hide();
602
+ }
603
+ parseDate() {
604
+ const strValue = this._textInput.value;
605
+ const parsedDate = DateUtils.strToDate(strValue);
606
+ if (parsedDate || !strValue) {
607
+ if (this.value === parsedDate) {
608
+ this.changeValue(this.value);
609
+ }
610
+ else {
611
+ this.changeValue(parsedDate);
612
+ }
613
+ }
614
+ else {
615
+ this._textInput.errormessage = "O valor digitado não é uma data válida";
616
+ }
617
+ }
618
+ getTextValue(d) {
619
+ return d ? new Intl.DateTimeFormat('pt-BR').format(d) : null;
620
+ }
621
+ render() {
622
+ return (index.h(index.Host, null, index.h("ez-text-input", { class: "text-input", ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
623
+ if (event.key === 'H' || event.key === 'h')
624
+ this.changeValue(new Date());
625
+ }, 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 })));
626
+ }
627
+ static get watchers() { return {
628
+ "label": ["setLabel"],
629
+ "errormessage": ["setErrorMessage"],
630
+ "value": ["applyValueToInput"]
631
+ }; }
632
+ };
633
633
  EzDateInput.style = ezDateInputCss;
634
634
 
635
635
  function _defineProperty(obj, key, value) {
@@ -1826,1439 +1826,1525 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
1826
1826
 
1827
1827
  const undoable = /*@__PURE__*/getDefaultExportFromCjs(lib);
1828
1828
 
1829
- const inicialState = {
1830
- currentTabIndex: {},
1831
- currentRecordIndex: {},
1832
- changes: {},
1833
- collapsedGroups: {},
1834
- newRecordIndex: {}
1835
- };
1836
- function formReducer(state = inicialState, action) {
1837
- switch (action.type) {
1838
- case 'FORM/COLLAPSEGROUP':
1839
- return collapseGroup(state, action.payload);
1840
- case 'FORM/CHANGETAB':
1841
- return changeTab(state, action.payload.formId, action.payload.index);
1842
- case 'FORM/NAVIGATE':
1843
- return navigate(state, action.payload);
1844
- case 'FORM/INSERT':
1845
- return insertRecord(state, action.payload);
1846
- case 'FORM/CHANGEFIELD':
1847
- return changeFieldValue(state, action.payload);
1848
- case 'FORM/CLEAREDITION':
1849
- return clearEdition(state, action.payload);
1850
- case 'FORM/INVALIDFIELD':
1851
- return navigateToInvalid(state, action.payload);
1852
- default:
1853
- return state;
1854
- }
1855
- }
1856
- function formNonHistoricReducer(state = { dataLoading: {}, invalidFields: {} }, action) {
1857
- switch (action.type) {
1858
- case 'FORM/DATALOADING':
1859
- return dataLoading(state, action.payload);
1860
- case 'FORM/DATALOADED':
1861
- return dataLoaded(state, action.payload);
1862
- case 'FORM/SAVINGCHANGES':
1863
- return savingChanges(state, action.payload);
1864
- case 'FORM/CHANGESSAVED':
1865
- return changesSaved(state, action.payload);
1866
- case 'FORM/REMOVINGRECORD':
1867
- return removingRecord(state, action.payload);
1868
- case 'FORM/RECORDREMOVED':
1869
- return recordRemoved(state, action.payload);
1870
- case 'FORM/INVALIDFIELD':
1871
- return invalidField(state, action.payload);
1872
- case 'FORM/CLEAREDITION':
1873
- return clearAllInvalidFields(state, action.payload);
1874
- case 'FORM/CHANGEFIELD':
1875
- return clearInvalidField(state, action.payload);
1876
- default:
1877
- return state;
1878
- }
1879
- }
1880
- function collapseGroup(state, { collapseId, collapsed }) {
1881
- const currentCollapsed = Object.assign({}, state.collapsedGroups);
1882
- if (collapsed) {
1883
- currentCollapsed[collapseId] = true;
1884
- }
1885
- else {
1886
- delete currentCollapsed[collapseId];
1887
- }
1888
- return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
1889
- }
1890
- function changeTab(state, formId, index) {
1891
- const currentTabIndex = Object.assign({}, state.currentTabIndex);
1892
- currentTabIndex[formId] = index;
1893
- return Object.assign(Object.assign({}, state), { currentTabIndex });
1894
- }
1895
- function navigate(state, { dataUnit, limit, backward }) {
1896
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1897
- const recIndex = currentRecordIndex[dataUnit] || 0;
1898
- return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
1899
- }
1900
- function gotoIndex(state, dataUnit, index) {
1901
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1902
- currentRecordIndex[dataUnit] = index;
1903
- return Object.assign(Object.assign({}, state), { currentRecordIndex });
1904
- }
1905
- function insertRecord(state, { dataUnit, insertionIndex }) {
1906
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1907
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
1908
- currentRecordIndex[dataUnit] = insertionIndex;
1909
- newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
1910
- return Object.assign(Object.assign({}, state), { currentRecordIndex,
1911
- newRecordIndex });
1912
- }
1913
- function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
1914
- const changes = Object.assign({}, state.changes);
1915
- const dataUnitChanges = Object.assign({}, changes[dataUnit]);
1916
- const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
1917
- recordChanges[fieldName] = value;
1918
- dataUnitChanges[recordId] = recordChanges;
1919
- changes[dataUnit] = dataUnitChanges;
1920
- const invalidFields = Object.assign({}, state.invalidFields);
1921
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1922
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1923
- delete errorMessages[fieldName];
1924
- dataUnitInvalidRecords[recordId] = errorMessages;
1925
- invalidFields[dataUnit] = dataUnitInvalidRecords;
1926
- return Object.assign(Object.assign({}, state), { changes,
1927
- invalidFields, invalidFieldSelected: undefined });
1928
- }
1929
- function clearEdition(state, { dataUnit, recordsLimit }) {
1930
- const changes = Object.assign({}, state.changes);
1931
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
1932
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1933
- delete changes[dataUnit];
1934
- delete newRecordIndex[dataUnit];
1935
- const recIndex = currentRecordIndex[dataUnit] || 0;
1936
- currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
1937
- return Object.assign(Object.assign({}, state), { changes,
1938
- newRecordIndex,
1939
- currentRecordIndex });
1940
- }
1941
- function navigateToInvalid(state, payload) {
1942
- let newState = Object.assign({}, state);
1943
- if (newState.invalidFieldSelected === undefined) {
1944
- newState.invalidFieldSelected = true;
1945
- newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
1946
- newState = changeTab(newState, payload.tabController, payload.tabIndex);
1947
- }
1948
- return newState;
1949
- }
1950
- function dataLoading(state, { dataUnit }) {
1951
- const dataLoading = Object.assign({}, state.dataLoading);
1952
- dataLoading[dataUnit] = true;
1953
- return Object.assign(Object.assign({}, state), { dataLoading });
1954
- }
1955
- function dataLoaded(state, { dataUnit }) {
1956
- const dataLoading = Object.assign({}, state.dataLoading);
1957
- delete dataLoading[dataUnit];
1958
- return Object.assign(Object.assign({}, state), { dataLoading });
1959
- }
1960
- function savingChanges(state, { dataUnit }) {
1961
- const dataLoading = Object.assign({}, state.dataLoading);
1962
- dataLoading[dataUnit] = true;
1963
- return Object.assign(Object.assign({}, state), { dataLoading });
1964
- }
1965
- function changesSaved(state, { dataUnit }) {
1966
- const dataLoading = Object.assign({}, state.dataLoading);
1967
- delete dataLoading[dataUnit];
1968
- return Object.assign(Object.assign({}, state), { dataLoading });
1969
- }
1970
- function removingRecord(state, { dataUnit }) {
1971
- const dataLoading = Object.assign({}, state.dataLoading);
1972
- dataLoading[dataUnit] = true;
1973
- return Object.assign(Object.assign({}, state), { dataLoading });
1974
- }
1975
- function recordRemoved(state, { dataUnit }) {
1976
- const dataLoading = Object.assign({}, state.dataLoading);
1977
- delete dataLoading[dataUnit];
1978
- return Object.assign(Object.assign({}, state), { dataLoading });
1979
- }
1980
- function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
1981
- const invalidFields = Object.assign({}, state.invalidFields);
1982
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1983
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1984
- errorMessages[fieldName] = errorMessage;
1985
- dataUnitInvalidRecords[recordId] = errorMessages;
1986
- invalidFields[dataUnit] = dataUnitInvalidRecords;
1987
- return Object.assign(Object.assign({}, state), { invalidFields });
1988
- }
1989
- function clearAllInvalidFields(state, { dataUnit }) {
1990
- const invalidFields = Object.assign({}, state.invalidFields);
1991
- delete invalidFields[dataUnit];
1992
- return Object.assign(Object.assign({}, state), { invalidFields });
1993
- }
1994
- function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
1995
- const invalidFields = Object.assign({}, state.invalidFields);
1996
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1997
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1998
- delete errorMessages[fieldName];
1999
- dataUnitInvalidRecords[recordId] = errorMessages;
2000
- invalidFields[dataUnit] = dataUnitInvalidRecords;
2001
- return Object.assign(Object.assign({}, state), { invalidFields });
1829
+ const inicialHistState = {
1830
+ currentTabIndex: {},
1831
+ currentRecordIndex: {},
1832
+ changes: {},
1833
+ collapsedGroups: {},
1834
+ newRecordIndex: {}
1835
+ };
1836
+ const inicialNonHistState = {
1837
+ dataLoading: {},
1838
+ invalidFields: {},
1839
+ visibleButtons: {
1840
+ previousVisible: true,
1841
+ nextVisible: true,
1842
+ addVisible: true,
1843
+ removeVisible: true,
1844
+ saveVisible: true,
1845
+ cancelVisible: true,
1846
+ reloadVisible: true
1847
+ }
1848
+ };
1849
+ function formReducer(state = inicialHistState, action) {
1850
+ switch (action.type) {
1851
+ case 'FORM/COLLAPSEGROUP':
1852
+ return collapseGroup(state, action.payload);
1853
+ case 'FORM/CHANGETAB':
1854
+ return changeTab(state, action.payload.formId, action.payload.index);
1855
+ case 'FORM/NAVIGATE':
1856
+ return navigate(state, action.payload);
1857
+ case 'FORM/INSERT':
1858
+ return insertRecord(state, action.payload);
1859
+ case 'FORM/CHANGEFIELD':
1860
+ return changeFieldValue(state, action.payload);
1861
+ case 'FORM/CLEAREDITION':
1862
+ return clearEdition(state, action.payload);
1863
+ case 'FORM/INVALIDFIELD':
1864
+ return navigateToInvalid(state, action.payload);
1865
+ default:
1866
+ return state;
1867
+ }
1868
+ }
1869
+ function formNonHistoricReducer(state = inicialNonHistState, action) {
1870
+ switch (action.type) {
1871
+ case 'FORM/DATALOADING':
1872
+ return dataLoading(state, action.payload);
1873
+ case 'FORM/DATALOADED':
1874
+ return dataLoaded(state, action.payload);
1875
+ case 'FORM/SAVINGCHANGES':
1876
+ return savingChanges(state, action.payload);
1877
+ case 'FORM/CHANGESSAVED':
1878
+ return changesSaved(state, action.payload);
1879
+ case 'FORM/REMOVINGRECORD':
1880
+ return removingRecord(state, action.payload);
1881
+ case 'FORM/RECORDREMOVED':
1882
+ return recordRemoved(state, action.payload);
1883
+ case 'FORM/INVALIDFIELD':
1884
+ return invalidField(state, action.payload);
1885
+ case 'FORM/CLEAREDITION':
1886
+ return clearAllInvalidFields(state, action.payload);
1887
+ case 'FORM/CHANGEFIELD':
1888
+ return clearInvalidField(state, action.payload);
1889
+ case 'FORM/SHOWHIDENAVBTN':
1890
+ return showHideNavBtn(state, action.payload);
1891
+ default:
1892
+ return state;
1893
+ }
1894
+ }
1895
+ function collapseGroup(state, { collapseId, collapsed }) {
1896
+ const currentCollapsed = Object.assign({}, state.collapsedGroups);
1897
+ if (collapsed) {
1898
+ currentCollapsed[collapseId] = true;
1899
+ }
1900
+ else {
1901
+ delete currentCollapsed[collapseId];
1902
+ }
1903
+ return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
1904
+ }
1905
+ function changeTab(state, formId, index) {
1906
+ const currentTabIndex = Object.assign({}, state.currentTabIndex);
1907
+ currentTabIndex[formId] = index;
1908
+ return Object.assign(Object.assign({}, state), { currentTabIndex });
1909
+ }
1910
+ function navigate(state, { dataUnit, limit, backward }) {
1911
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1912
+ const recIndex = currentRecordIndex[dataUnit] || 0;
1913
+ return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
1914
+ }
1915
+ function gotoIndex(state, dataUnit, index) {
1916
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1917
+ currentRecordIndex[dataUnit] = index;
1918
+ return Object.assign(Object.assign({}, state), { currentRecordIndex });
1919
+ }
1920
+ function insertRecord(state, { dataUnit, insertionIndex }) {
1921
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1922
+ const newRecordIndex = Object.assign({}, state.newRecordIndex);
1923
+ currentRecordIndex[dataUnit] = insertionIndex;
1924
+ newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
1925
+ return Object.assign(Object.assign({}, state), { currentRecordIndex,
1926
+ newRecordIndex });
1927
+ }
1928
+ function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
1929
+ const changes = Object.assign({}, state.changes);
1930
+ const dataUnitChanges = Object.assign({}, changes[dataUnit]);
1931
+ const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
1932
+ recordChanges[fieldName] = value;
1933
+ dataUnitChanges[recordId] = recordChanges;
1934
+ changes[dataUnit] = dataUnitChanges;
1935
+ const invalidFields = Object.assign({}, state.invalidFields);
1936
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1937
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1938
+ delete errorMessages[fieldName];
1939
+ dataUnitInvalidRecords[recordId] = errorMessages;
1940
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
1941
+ return Object.assign(Object.assign({}, state), { changes,
1942
+ invalidFields, invalidFieldSelected: undefined });
1943
+ }
1944
+ function clearEdition(state, { dataUnit, recordsLimit }) {
1945
+ const changes = Object.assign({}, state.changes);
1946
+ const newRecordIndex = Object.assign({}, state.newRecordIndex);
1947
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1948
+ delete changes[dataUnit];
1949
+ delete newRecordIndex[dataUnit];
1950
+ const recIndex = currentRecordIndex[dataUnit] || 0;
1951
+ currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
1952
+ return Object.assign(Object.assign({}, state), { changes,
1953
+ newRecordIndex,
1954
+ currentRecordIndex });
1955
+ }
1956
+ function navigateToInvalid(state, payload) {
1957
+ let newState = Object.assign({}, state);
1958
+ if (newState.invalidFieldSelected === undefined) {
1959
+ newState.invalidFieldSelected = true;
1960
+ newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
1961
+ newState = changeTab(newState, payload.tabController, payload.tabIndex);
1962
+ }
1963
+ return newState;
1964
+ }
1965
+ function dataLoading(state, { dataUnit }) {
1966
+ const dataLoading = Object.assign({}, state.dataLoading);
1967
+ dataLoading[dataUnit] = true;
1968
+ return Object.assign(Object.assign({}, state), { dataLoading });
1969
+ }
1970
+ function dataLoaded(state, { dataUnit }) {
1971
+ const dataLoading = Object.assign({}, state.dataLoading);
1972
+ delete dataLoading[dataUnit];
1973
+ return Object.assign(Object.assign({}, state), { dataLoading });
1974
+ }
1975
+ function savingChanges(state, { dataUnit }) {
1976
+ const dataLoading = Object.assign({}, state.dataLoading);
1977
+ dataLoading[dataUnit] = true;
1978
+ return Object.assign(Object.assign({}, state), { dataLoading });
1979
+ }
1980
+ function changesSaved(state, { dataUnit }) {
1981
+ const dataLoading = Object.assign({}, state.dataLoading);
1982
+ delete dataLoading[dataUnit];
1983
+ return Object.assign(Object.assign({}, state), { dataLoading });
1984
+ }
1985
+ function removingRecord(state, { dataUnit }) {
1986
+ const dataLoading = Object.assign({}, state.dataLoading);
1987
+ dataLoading[dataUnit] = true;
1988
+ return Object.assign(Object.assign({}, state), { dataLoading });
1989
+ }
1990
+ function recordRemoved(state, { dataUnit }) {
1991
+ const dataLoading = Object.assign({}, state.dataLoading);
1992
+ delete dataLoading[dataUnit];
1993
+ return Object.assign(Object.assign({}, state), { dataLoading });
1994
+ }
1995
+ function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
1996
+ const invalidFields = Object.assign({}, state.invalidFields);
1997
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1998
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1999
+ errorMessages[fieldName] = errorMessage;
2000
+ dataUnitInvalidRecords[recordId] = errorMessages;
2001
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
2002
+ return Object.assign(Object.assign({}, state), { invalidFields });
2003
+ }
2004
+ function clearAllInvalidFields(state, { dataUnit }) {
2005
+ const invalidFields = Object.assign({}, state.invalidFields);
2006
+ delete invalidFields[dataUnit];
2007
+ return Object.assign(Object.assign({}, state), { invalidFields });
2008
+ }
2009
+ function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
2010
+ const invalidFields = Object.assign({}, state.invalidFields);
2011
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
2012
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
2013
+ delete errorMessages[fieldName];
2014
+ dataUnitInvalidRecords[recordId] = errorMessages;
2015
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
2016
+ return Object.assign(Object.assign({}, state), { invalidFields });
2017
+ }
2018
+ function showHideNavBtn(state, { buttonName, status }) {
2019
+ const visibleButtons = Object.assign({}, state.visibleButtons);
2020
+ visibleButtons[buttonName] = status;
2021
+ return Object.assign(Object.assign({}, state), { visibleButtons });
2002
2022
  }
2003
2023
 
2004
- function removeHandler(dataUnit) {
2005
- if (confirm("Tem certeza que deseja Remover?")) {
2006
- dataUnit.remove();
2007
- }
2008
- }
2009
- const NavigationBar = ({ dataUnit: du }) => {
2010
- return index.h("div", { class: "col col--sd-12 align--right" },
2011
- du.cardinality !== '1' ? [
2012
- index.h("ez-button", { title: "Registro anterior", mode: "icon", enabled: du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }),
2013
- index.h("ez-button", { title: "Pr\u00F3ximo registro", mode: "icon", enabled: du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }),
2014
- index.h("ez-button", { title: "Incluir registro", mode: "icon", onClick: () => du.insert(), image: "/themes/default/images/icons/actions-sprite.svg#plus-circle-inverted", class: "button--secondary margin-right--medium" }),
2015
- index.h("ez-button", { title: "Remover registro", mode: "icon", enabled: du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" })
2016
- ] : null,
2017
- index.h("ez-button", { title: "Salvar altera\u00E7\u00F5es", mode: "icon", enabled: du.hasChanges(), onClick: () => du.save(), image: "/themes/default/images/icons/actions-sprite.svg#check-circle-inverted", class: "button--secondary margin-right--medium" }),
2018
- index.h("ez-button", { title: "Descartar altera\u00E7\u00F5es", mode: "icon", enabled: du.hasChanges(), onClick: () => du.cancel(), image: "/themes/default/images/icons/actions-sprite.svg#close-circle-inverted", class: "button--secondary margin-right--medium" }),
2019
- index.h("ez-button", { title: "Carregar registros", mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }));
2024
+ function removeHandler(dataUnit) {
2025
+ if (confirm("Tem certeza que deseja Remover?")) {
2026
+ dataUnit.remove();
2027
+ }
2028
+ }
2029
+ const NavigationBar = ({ dataUnit: du, buttonProps }) => {
2030
+ if (buttonProps.previousVisible
2031
+ || buttonProps.nextVisible
2032
+ || buttonProps.addVisible
2033
+ || buttonProps.removeVisible
2034
+ || buttonProps.saveVisible
2035
+ || buttonProps.cancelVisible
2036
+ || buttonProps.reloadVisible) {
2037
+ return index.h("div", { class: "col col--sd-12 align--right" },
2038
+ buttonProps.previousVisible ? index.h("ez-button", { title: "Registro anterior", mode: "icon", enabled: du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2039
+ buttonProps.nextVisible ? index.h("ez-button", { title: "Pr\u00F3ximo registro", mode: "icon", enabled: du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2040
+ buttonProps.removeVisible ? index.h("ez-button", { label: "Remover", enabled: du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2041
+ buttonProps.addVisible ? index.h("ez-button", { label: "Adicionar", onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
2042
+ buttonProps.reloadVisible ? index.h("ez-button", { title: "Recarregar", mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
2043
+ buttonProps.cancelVisible ? index.h("ez-button", { label: "Cancelar", enabled: du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
2044
+ buttonProps.saveVisible ? index.h("ez-button", { label: "Salvar", enabled: du.hasChanges(), onClick: () => du.save(), class: "button--primary margin-right--medium" }) : null);
2045
+ }
2046
+ else {
2047
+ return null;
2048
+ }
2020
2049
  };
2021
2050
 
2022
- var DependencyType;
2023
- (function (DependencyType) {
2024
- DependencyType["SEARCHING"] = "SEARCHING";
2025
- DependencyType["REQUIREMENT"] = "REQUIREMENT";
2026
- DependencyType["VISIBILITY"] = "REQUIREMENT";
2051
+ var DependencyType;
2052
+ (function (DependencyType) {
2053
+ DependencyType["SEARCHING"] = "SEARCHING";
2054
+ DependencyType["REQUIREMENT"] = "REQUIREMENT";
2055
+ DependencyType["VISIBILITY"] = "REQUIREMENT";
2027
2056
  })(DependencyType || (DependencyType = {}));
2028
2057
 
2029
- function scrollToView(forceScroll, elem) {
2030
- if (forceScroll) {
2031
- window.requestAnimationFrame(() => elem.scrollIntoView());
2032
- }
2033
- }
2034
- const Field = ({ dataUnit, source, forceScroll }) => {
2035
- const { name, label, userInterface, properties, required, dependencies } = source;
2036
- const value = dataUnit.getValue(name) || null;
2037
- const loadingData = dataUnit.isLoading();
2038
- const formattedLabel = required ? `* ${label} (obrigatório)` : label;
2039
- const errorMessage = dataUnit.getErrorMessage(name);
2040
- const changeFieldHandler = (newValue) => {
2041
- dataUnit.changeValue(name, newValue);
2042
- };
2043
- switch (userInterface) {
2044
- case 'LONGTEXT':
2045
- return index.h("div", { class: "col col--sd-12 padding--small" },
2046
- index.h("ez-text-area", { label: formattedLabel, onInput: evt => changeFieldHandler(evt.target['value']), value: value || '', errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2047
- case 'CHECKBOX':
2048
- return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2049
- index.h("ez-check", { onInput: evt => changeFieldHandler(evt.target['value']), ref: elem => scrollToView(forceScroll, elem) }));
2050
- case 'SWITCH':
2051
- return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2052
- index.h("div", { class: "row" },
2053
- index.h("div", { class: "col col--sd-2" },
2054
- index.h("ez-check", { mode: "switch", value: value === "S", ref: elem => scrollToView(forceScroll, elem) })),
2055
- index.h("div", { class: "col col--sd-10" },
2056
- index.h("label", { class: "text text--primary text--medium" }, label))));
2057
- case 'OPTIONSELECTOR':
2058
- const optsObj = JSON.parse(properties.find(prop => prop.name === 'options').value);
2059
- return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2060
- index.h("ez-combo-box", { value: value, label: formattedLabel, onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }, Object.keys(optsObj).map(key => index.h("option", { value: key }, optsObj[key]))));
2061
- case 'SEARCH':
2062
- const context = {};
2063
- properties.forEach(({ name, value }) => {
2064
- context[name] = value;
2065
- });
2066
- let criteriaList = [];
2067
- dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
2068
- var _a;
2069
- if (dependency.type === DependencyType.SEARCHING) {
2070
- if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
2071
- let criteria = {
2072
- expression: dependency.expression,
2073
- paramNames: [...dependency.masterFields],
2074
- paramResolver: name => dataUnit.getValue(name)
2075
- };
2076
- criteriaList.push(criteria);
2077
- }
2078
- }
2079
- });
2080
- if (criteriaList.length > 0) {
2081
- context['CRITERIA'] = criteriaList;
2082
- }
2083
- return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2084
- index.h("ez-search", { label: label, onEzChange: (event) => changeFieldHandler(event.target['value']), showvalue: true, value: value, loadexecutor: (argument, callback) => dataUnit.fieldSearchExecutor(argument, context, callback) }));
2085
- case 'DATE':
2086
- return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2087
- index.h("ez-date-input", { label: formattedLabel, enabled: true, value: !value ? null : DateUtils.clearTime(value), onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2088
- //IMAGE, FILE, DATE, DATETIME, ELAPSEDTIME, DECIMALNUMBER, INTEGERNUMBER, PASSWORD, MASKEDTEXT, HTML
2089
- default:
2090
- return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData
2091
- ?
2092
- index.h("place-holder", null)
2093
- :
2094
- index.h("ez-text-input", { loading: loadingData, label: formattedLabel, onInput: (event) => changeFieldHandler(event.target['value']), value: value, errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2095
- }
2058
+ function scrollToView(forceScroll, elem) {
2059
+ if (forceScroll) {
2060
+ window.requestAnimationFrame(() => elem.scrollIntoView());
2061
+ }
2062
+ }
2063
+ const Field = ({ dataUnit, source, forceScroll }) => {
2064
+ const { name, label, userInterface, properties, required, dependencies } = source;
2065
+ const value = dataUnit.getValue(name) || null;
2066
+ const loadingData = dataUnit.isLoading();
2067
+ const formattedLabel = required ? `* ${label} (obrigatório)` : label;
2068
+ const errorMessage = dataUnit.getErrorMessage(name);
2069
+ const changeFieldHandler = (newValue) => {
2070
+ dataUnit.changeValue(name, newValue);
2071
+ };
2072
+ switch (userInterface) {
2073
+ case 'LONGTEXT':
2074
+ return index.h("div", { class: "col col--sd-12 padding--small" },
2075
+ index.h("ez-text-area", { label: formattedLabel, onInput: evt => changeFieldHandler(evt.target['value']), value: value || '', errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2076
+ case 'CHECKBOX':
2077
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2078
+ index.h("ez-check", { onInput: evt => changeFieldHandler(evt.target['value']), ref: elem => scrollToView(forceScroll, elem) }));
2079
+ case 'SWITCH':
2080
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2081
+ index.h("div", { class: "row" },
2082
+ index.h("div", { class: "col col--sd-2" },
2083
+ index.h("ez-check", { mode: "switch", value: value === "S", ref: elem => scrollToView(forceScroll, elem) })),
2084
+ index.h("div", { class: "col col--sd-10" },
2085
+ index.h("label", { class: "text text--primary text--medium" }, label))));
2086
+ case 'OPTIONSELECTOR':
2087
+ const optsObj = JSON.parse(properties.find(prop => prop.name === 'options').value);
2088
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2089
+ index.h("ez-combo-box", { value: value, label: formattedLabel, onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }, Object.keys(optsObj).map(key => index.h("option", { value: key }, optsObj[key]))));
2090
+ case 'SEARCH':
2091
+ const context = {};
2092
+ properties.forEach(({ name, value }) => {
2093
+ context[name] = value;
2094
+ });
2095
+ let criteriaList = [];
2096
+ dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
2097
+ var _a;
2098
+ if (dependency.type === DependencyType.SEARCHING) {
2099
+ if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
2100
+ let criteria = {
2101
+ expression: dependency.expression,
2102
+ paramNames: [...dependency.masterFields],
2103
+ paramResolver: name => dataUnit.getValue(name)
2104
+ };
2105
+ criteriaList.push(criteria);
2106
+ }
2107
+ }
2108
+ });
2109
+ if (criteriaList.length > 0) {
2110
+ context['CRITERIA'] = criteriaList;
2111
+ }
2112
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2113
+ index.h("ez-search", { label: label, onEzChange: (event) => changeFieldHandler(event.target['value']), showvalue: true, value: value, loadexecutor: (argument, callback) => dataUnit.fieldSearchExecutor(argument, context, callback) }));
2114
+ case 'DATE':
2115
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2116
+ index.h("ez-date-input", { label: formattedLabel, enabled: true, value: !value ? null : DateUtils.clearTime(value), onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2117
+ //IMAGE, FILE, DATE, DATETIME, ELAPSEDTIME, DECIMALNUMBER, INTEGERNUMBER, PASSWORD, MASKEDTEXT, HTML
2118
+ default:
2119
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData
2120
+ ?
2121
+ index.h("place-holder", null)
2122
+ :
2123
+ index.h("ez-text-input", { loading: loadingData, label: formattedLabel, onInput: (event) => changeFieldHandler(event.target['value']), value: value, errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2124
+ }
2096
2125
  };
2097
2126
 
2098
- const FieldSet = ({ store, formName, source, dataUnit }) => {
2099
- const { label, fields } = source;
2100
- const fieldSetName = formName + label;
2101
- let isCollapsed = DataUnit.selectIsCollapsedFieldSet(store.getState(), formName + label);
2102
- let fieldToScroll;
2103
- source.fields.forEach((field) => {
2104
- if (fieldToScroll === undefined) {
2105
- const fieldError = dataUnit.getErrorMessage(field.name);
2106
- if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
2107
- fieldToScroll = field.name;
2108
- }
2109
- }
2110
- });
2111
- if (fieldToScroll) {
2112
- isCollapsed = false;
2113
- }
2114
- return index.h("div", { class: "col col--sd-12 padding--small" },
2115
- index.h("div", { class: "row margin-top--large" },
2116
- index.h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
2117
- index.h("ez-collapsable-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(DataUnit.collapseExpandGroup(fieldSetName, !isCollapsed)) }),
2118
- isCollapsed ? null :
2119
- index.h("div", { class: "col col--sd-12" }, fields.map(field => index.h(Field, { source: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
2127
+ const FieldSet = ({ store, formName, source, dataUnit }) => {
2128
+ const { label, fields } = source;
2129
+ const fieldSetName = formName + label;
2130
+ let isCollapsed = DataUnit.selectIsCollapsedFieldSet(store.getState(), formName + label);
2131
+ let fieldToScroll;
2132
+ source.fields.forEach((field) => {
2133
+ if (fieldToScroll === undefined) {
2134
+ const fieldError = dataUnit.getErrorMessage(field.name);
2135
+ if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
2136
+ fieldToScroll = field.name;
2137
+ }
2138
+ }
2139
+ });
2140
+ if (fieldToScroll) {
2141
+ isCollapsed = false;
2142
+ }
2143
+ return index.h("div", { class: "col col--sd-12 padding--small" },
2144
+ index.h("div", { class: "row margin-top--large" },
2145
+ index.h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
2146
+ index.h("ez-collapsable-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(DataUnit.collapseExpandGroup(fieldSetName, !isCollapsed)) }),
2147
+ isCollapsed ? null :
2148
+ index.h("div", { class: "col col--sd-12" }, fields.map(field => index.h(Field, { source: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
2120
2149
  };
2121
2150
 
2122
- function buildFormItem(source, formName, store, dataUnit) {
2123
- if ("fields" in source) {
2124
- return index.h(FieldSet, { source: source, store: store, formName: formName, dataUnit: dataUnit });
2125
- }
2126
- const errorMsg = dataUnit.getErrorMessage(source.name);
2127
- const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
2128
- return index.h(Field, { source: source, dataUnit: dataUnit, forceScroll: forceScroll });
2129
- }
2130
- const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder }) => {
2131
- const selectedTab = DataUnit.selectCurrentTab(store.getState(), parentName);
2132
- const tabs = source.length > 1 ? source.map(form => index.h("ez-tab", { label: form.label, tabKey: form.name })) : null;
2133
- const { subForms, items, name } = source[selectedTab];
2134
- const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit);
2135
- source[selectedTab].dataUnit = dataUnit;
2136
- const hasSubForms = subForms && subForms.length > 0;
2137
- const changeTabHandler = (index) => {
2138
- store.dispatch(DataUnit.changeTab(parentName, index));
2139
- };
2140
- //todos os campos e subformulários precisam estar ligados a um DU
2141
- const currentDU = dataUnit || parentDataUnit;
2142
- return index.h("div", { class: "form-sheet" },
2143
- tabs ? index.h("ez-tabselector", { selectedindex: selectedTab, selectedtab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
2144
- dataUnit ? index.h(NavigationBar, { dataUnit: dataUnit }) : null,
2145
- index.h("div", { class: "tab__container" },
2146
- items ? items.map(item => buildFormItem(item, name, store, currentDU)) : null,
2147
- hasSubForms ? index.h(FormSheet, { store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
2151
+ function buildFormItem(source, formName, store, dataUnit) {
2152
+ if ("fields" in source) {
2153
+ return index.h(FieldSet, { source: source, store: store, formName: formName, dataUnit: dataUnit });
2154
+ }
2155
+ const errorMsg = dataUnit.getErrorMessage(source.name);
2156
+ const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
2157
+ return index.h(Field, { source: source, dataUnit: dataUnit, forceScroll: forceScroll });
2158
+ }
2159
+ const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder }) => {
2160
+ const selectedTab = DataUnit.selectCurrentTab(store.getState(), parentName);
2161
+ const tabs = source.length > 1 ? source.map(form => index.h("ez-tab", { label: form.label, tabKey: form.name })) : null;
2162
+ const { subForms, items, name } = source[selectedTab];
2163
+ const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit, parentDataUnit);
2164
+ source[selectedTab].dataUnit = dataUnit;
2165
+ const hasSubForms = subForms && subForms.length > 0;
2166
+ const changeTabHandler = (index) => {
2167
+ store.dispatch(DataUnit.changeTab(parentName, index));
2168
+ };
2169
+ //todos os campos e subformulários precisam estar ligados a um DU
2170
+ const currentDU = dataUnit || parentDataUnit;
2171
+ let buttons = DataUnit.selectVisibleButtons(store.getState());
2172
+ if (currentDU.cardinality === "1") {
2173
+ buttons.addVisible = false;
2174
+ buttons.removeVisible = false;
2175
+ buttons.nextVisible = false;
2176
+ buttons.previousVisible = false;
2177
+ }
2178
+ return index.h("div", { class: "form-sheet" },
2179
+ tabs ? index.h("ez-tabselector", { selectedindex: selectedTab, selectedtab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
2180
+ dataUnit ? index.h(NavigationBar, { dataUnit: dataUnit, buttonProps: buttons }) : null,
2181
+ index.h("div", { class: "tab__container" },
2182
+ items ? items.map(item => buildFormItem(item, name, store, currentDU)) : null,
2183
+ hasSubForms ? index.h(FormSheet, { store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
2148
2184
  };
2149
2185
 
2150
2186
  const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}.form-sheet{display:flex;width:100%;flex-wrap:wrap;position:relative}.tab__container{display:flex;width:100%;flex-wrap:wrap;position:relative}";
2151
2187
 
2152
- const EzForm = class {
2153
- constructor(hostRef) {
2154
- index.registerInstance(this, hostRef);
2155
- this._requiredFieldsByDU = {};
2156
- }
2157
- validateRecords(dataUnit, records) {
2158
- const result = { isValid: true, message: '' };
2159
- const reqFields = this._requiredFieldsByDU[dataUnit.name];
2160
- records.forEach(record => {
2161
- reqFields.forEach(field => {
2162
- const recordIndex = record["record__index"];
2163
- const fieldName = field.name;
2164
- const fieldValue = record[fieldName];
2165
- if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
2166
- this._store.dispatch(DataUnit.invalidField(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
2167
- result.isValid = false;
2168
- }
2169
- });
2170
- });
2171
- if (!result.isValid) {
2172
- result.message = "Há pelo menos um campo obrigatório não preenchido.";
2173
- }
2174
- return result;
2175
- }
2176
- componentWillRender() {
2177
- if (this._store === undefined) {
2178
- const rootReducer = combineReducers({
2179
- "hist": undoable(formReducer),
2180
- "nonhist": formNonHistoricReducer
2181
- });
2182
- this._store = createStore(rootReducer, applyMiddleware(thunk));
2183
- this._store.subscribe(() => { index.forceUpdate(this); });
2184
- }
2185
- }
2186
- loadMDFromExecutor(callBack) {
2187
- if (this._loadMetadataFunction) {
2188
- const result = this._loadMetadataFunction();
2189
- if (result) {
2190
- if (result instanceof Promise) {
2191
- result.then(md => {
2192
- callBack(md);
2193
- });
2194
- }
2195
- else {
2196
- callBack(result);
2197
- }
2198
- }
2199
- }
2200
- }
2201
- loadMDFromElement(callBack) {
2202
- const metadata = [];
2203
- Array.from(this._host.children).forEach(elem => {
2204
- if (elem.tagName === "FORM-METADATA") {
2205
- const formMetadata = elem;
2206
- metadata.push(formMetadata.metadata);
2207
- }
2208
- });
2209
- callBack(metadata.length > 0 ? metadata : null);
2210
- }
2211
- updateMetadata(metadata) {
2212
- if (metadata) {
2213
- const processFields = (duName, form, tabController, tabIndex) => {
2214
- var _a;
2215
- let requiredFields = this._requiredFieldsByDU[duName];
2216
- if (requiredFields === undefined) {
2217
- requiredFields = [];
2218
- this._requiredFieldsByDU[duName] = requiredFields;
2219
- }
2220
- form.items.forEach(item => {
2221
- if ("fields" in item) {
2222
- const fSet = item;
2223
- fSet.fields.forEach(f => {
2224
- f.tabControler = tabController;
2225
- f.tabIndex = tabIndex;
2226
- if (f.required) {
2227
- requiredFields.push(f);
2228
- }
2229
- });
2230
- }
2231
- else {
2232
- const f = item;
2233
- f.tabControler = tabController;
2234
- f.tabIndex = tabIndex;
2235
- if (f.required) {
2236
- requiredFields.push(f);
2237
- }
2238
- }
2239
- });
2240
- (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
2241
- const subDU = subForm.dataUnit ? subForm.dataUnit.name : duName;
2242
- processFields(subDU, subForm, form.name, index);
2243
- });
2244
- };
2245
- this.metadata = metadata;
2246
- metadata.map((form, index) => {
2247
- processFields(form.dataUnit.name, form, "__MAIN__FORM__", index);
2248
- });
2249
- this._store.dispatch(DataUnit.formLoad());
2250
- }
2251
- }
2252
- parseExecutor(executor) {
2253
- if (executor) {
2254
- return executor instanceof Function ? executor : eval(executor);
2255
- }
2256
- return null;
2257
- }
2258
- componentDidLoad() {
2259
- this._loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
2260
- this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2261
- this._saveFunction = this.parseExecutor(this.saveexecutor);
2262
- this._removeFunction = this.parseExecutor(this.removeexecutor);
2263
- this._fieldSearchFunction = this.parseExecutor(this.fieldsearchexecutor);
2264
- if (this.metadata) {
2265
- this.updateMetadata(this.metadata);
2266
- }
2267
- else {
2268
- this.loadMDFromElement((md) => this.updateMetadata(md));
2269
- if (!this.metadata) {
2270
- this.loadMDFromExecutor((md) => this.updateMetadata(md));
2271
- }
2272
- }
2273
- }
2274
- buildDataUnit(dataUnit) {
2275
- if (dataUnit) {
2276
- const { name, records, cardinality } = dataUnit;
2277
- if (!(dataUnit instanceof DataUnit.DataUnit)) {
2278
- dataUnit = new DataUnit.DataUnit(name, cardinality);
2279
- if (records) {
2280
- dataUnit.records = records;
2281
- }
2282
- dataUnit.store = this._store;
2283
- dataUnit.loadExecutor = this._loadDataFunction;
2284
- dataUnit.saveExecutor = this._saveFunction;
2285
- dataUnit.removeExecutor = this._removeFunction;
2286
- dataUnit.recordsValidator = this;
2287
- dataUnit.fieldSearchExecutor = this._fieldSearchFunction;
2288
- }
2289
- }
2290
- return dataUnit;
2291
- }
2292
- render() {
2293
- return this.metadata ? index.h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du) => this.buildDataUnit(du) }) : null;
2294
- }
2295
- get _host() { return index.getElement(this); }
2296
- };
2188
+ const EzForm = class {
2189
+ constructor(hostRef) {
2190
+ index.registerInstance(this, hostRef);
2191
+ this._dataUnits = new Map();
2192
+ this._duSources = new Map();
2193
+ this._requiredFieldsByDU = {};
2194
+ }
2195
+ async validate() {
2196
+ for (let i = 0; i < this._duSources.size; i++) {
2197
+ const duName = Array.from(this._duSources.keys())[i];
2198
+ let du = this._dataUnits.get(duName);
2199
+ if (du === undefined) {
2200
+ const source = this._duSources.get(duName);
2201
+ du = this.buildDataUnit(source, source.parentDUName);
2202
+ }
2203
+ if (!du.validateRecords()) {
2204
+ return false;
2205
+ }
2206
+ }
2207
+ return true;
2208
+ }
2209
+ async getChanges() {
2210
+ let allChanges = [];
2211
+ for (let i = 0; i < this._dataUnits.size; i++) {
2212
+ const du = Array.from(this._dataUnits.values())[i];
2213
+ //Só devemos buscar as alterações de DU raiz, pois os sub DUs serão enviados junto.
2214
+ if (!du.parentDU) {
2215
+ const duChanges = du.getChangesToSave();
2216
+ if (duChanges) {
2217
+ allChanges = allChanges.concat(duChanges);
2218
+ }
2219
+ }
2220
+ }
2221
+ return allChanges;
2222
+ }
2223
+ validateRecords(dataUnit, records) {
2224
+ const result = { isValid: true, message: '' };
2225
+ const reqFields = this._requiredFieldsByDU[dataUnit.name];
2226
+ const recordValidator = record => {
2227
+ reqFields.forEach(field => {
2228
+ const recordIndex = record["record__index"];
2229
+ const fieldName = field.name;
2230
+ const fieldValue = record[fieldName];
2231
+ if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
2232
+ this._store.dispatch(DataUnit.invalidField(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
2233
+ result.isValid = false;
2234
+ result.message = "Há pelo menos um campo obrigatório não preenchido.";
2235
+ }
2236
+ });
2237
+ };
2238
+ if (records.length == 0) {
2239
+ recordValidator({});
2240
+ }
2241
+ else {
2242
+ records.forEach(recordValidator);
2243
+ }
2244
+ return result;
2245
+ }
2246
+ componentWillRender() {
2247
+ if (this._store === undefined) {
2248
+ const rootReducer = combineReducers({
2249
+ "hist": undoable(formReducer),
2250
+ "nonhist": formNonHistoricReducer
2251
+ });
2252
+ this._store = createStore(rootReducer, applyMiddleware(thunk));
2253
+ this._store.subscribe(() => { index.forceUpdate(this); });
2254
+ if (this.slavemode) {
2255
+ this._store.dispatch(DataUnit.showHideNavigationButtons("saveVisible", false));
2256
+ this._store.dispatch(DataUnit.showHideNavigationButtons("cancelVisible", false));
2257
+ this._store.dispatch(DataUnit.showHideNavigationButtons("reloadVisible", false));
2258
+ }
2259
+ }
2260
+ }
2261
+ loadMDFromExecutor(callBack) {
2262
+ const loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
2263
+ if (loadMetadataFunction) {
2264
+ const result = loadMetadataFunction();
2265
+ if (result) {
2266
+ if (result instanceof Promise) {
2267
+ result.then(md => {
2268
+ callBack(md);
2269
+ });
2270
+ }
2271
+ else {
2272
+ callBack(result);
2273
+ }
2274
+ }
2275
+ }
2276
+ }
2277
+ loadMDFromElement(callBack) {
2278
+ const metadata = [];
2279
+ Array.from(this._host.children).forEach(elem => {
2280
+ if (elem.tagName === "FORM-METADATA") {
2281
+ const formMetadata = elem;
2282
+ metadata.push(formMetadata.metadata);
2283
+ }
2284
+ });
2285
+ callBack(metadata.length > 0 ? metadata : null);
2286
+ }
2287
+ updateMetadata(metadata) {
2288
+ if (metadata) {
2289
+ const processFields = (duName, form, tabController, tabIndex) => {
2290
+ var _a;
2291
+ let requiredFields = this._requiredFieldsByDU[duName];
2292
+ if (requiredFields === undefined) {
2293
+ requiredFields = [];
2294
+ this._requiredFieldsByDU[duName] = requiredFields;
2295
+ }
2296
+ form.items.forEach(item => {
2297
+ if ("fields" in item) {
2298
+ const fSet = item;
2299
+ fSet.fields.forEach(f => {
2300
+ f.tabControler = tabController;
2301
+ f.tabIndex = tabIndex;
2302
+ if (f.required) {
2303
+ requiredFields.push(f);
2304
+ }
2305
+ });
2306
+ }
2307
+ else {
2308
+ const f = item;
2309
+ f.tabControler = tabController;
2310
+ f.tabIndex = tabIndex;
2311
+ if (f.required) {
2312
+ requiredFields.push(f);
2313
+ }
2314
+ }
2315
+ });
2316
+ (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
2317
+ const subDu = subForm.dataUnit;
2318
+ if (subDu) {
2319
+ this._duSources.set(subDu.name, subDu);
2320
+ subDu.parentDUName = duName;
2321
+ }
2322
+ processFields(subDu ? subDu.name : duName, subForm, form.name, index);
2323
+ });
2324
+ };
2325
+ this.metadata = metadata;
2326
+ metadata.map((form, index) => {
2327
+ const du = form.dataUnit;
2328
+ const duName = du.name;
2329
+ this._duSources.set(duName, du);
2330
+ processFields(duName, form, "__MAIN__FORM__", index);
2331
+ });
2332
+ this._store.dispatch(DataUnit.formLoad());
2333
+ }
2334
+ }
2335
+ parseExecutor(executor) {
2336
+ if (executor) {
2337
+ return executor instanceof Function ? executor : eval(executor);
2338
+ }
2339
+ return null;
2340
+ }
2341
+ componentDidLoad() {
2342
+ if (this.metadata) {
2343
+ this.updateMetadata(this.metadata);
2344
+ }
2345
+ else {
2346
+ this.loadMDFromElement((md) => this.updateMetadata(md));
2347
+ if (!this.metadata) {
2348
+ this.loadMDFromExecutor((md) => this.updateMetadata(md));
2349
+ }
2350
+ }
2351
+ }
2352
+ buildDataUnit(dataUnit, parentDataUnit) {
2353
+ if (dataUnit) {
2354
+ const { name, unitLabel, records, cardinality } = dataUnit;
2355
+ if (!(dataUnit instanceof DataUnit.DataUnit)) {
2356
+ let parent;
2357
+ if (parentDataUnit instanceof DataUnit.DataUnit) {
2358
+ parent = parentDataUnit;
2359
+ }
2360
+ else {
2361
+ parent = this._dataUnits.get(parentDataUnit);
2362
+ }
2363
+ dataUnit = new DataUnit.DataUnit(name, unitLabel, cardinality, parent);
2364
+ this._dataUnits.set(dataUnit.name, dataUnit);
2365
+ if (records) {
2366
+ dataUnit.records = records;
2367
+ }
2368
+ dataUnit.store = this._store;
2369
+ dataUnit.loadExecutor = this.parseExecutor(this.loadexecutor);
2370
+ dataUnit.saveExecutor = this.parseExecutor(this.saveexecutor);
2371
+ dataUnit.removeExecutor = this.parseExecutor(this.removeexecutor);
2372
+ dataUnit.recordsValidator = this;
2373
+ dataUnit.fieldSearchExecutor = this.parseExecutor(this.fieldsearchexecutor);
2374
+ }
2375
+ }
2376
+ return dataUnit;
2377
+ }
2378
+ render() {
2379
+ return this.metadata ? index.h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
2380
+ }
2381
+ get _host() { return index.getElement(this); }
2382
+ };
2297
2383
  EzForm.style = ezFormCss;
2298
2384
 
2299
2385
  const ezIconCss = ":host{display:block;overflow:hidden;position:relative}svg{display:flex;justify-content:center;align-items:center;fill:var(--color--icon)}.x-small{width:12px;height:12px}.small{width:16px;height:16px}.medium{width:20px;height:20px}.large{width:24px;height:24px}.x-large{width:30px;height:30px}";
2300
2386
 
2301
- const EzIcon = class {
2302
- constructor(hostRef) {
2303
- index.registerInstance(this, hostRef);
2304
- /*Tamanho do icone*/
2305
- this.size = 'medium';
2306
- }
2307
- render() {
2308
- return (index.h("svg", { class: this.size, role: "img" }, index.h("use", { xlinkHref: this.href })));
2309
- }
2310
- };
2387
+ const EzIcon = class {
2388
+ constructor(hostRef) {
2389
+ index.registerInstance(this, hostRef);
2390
+ /*Tamanho do icone*/
2391
+ this.size = 'medium';
2392
+ }
2393
+ render() {
2394
+ return (index.h("svg", { class: this.size, role: "img" }, index.h("use", { xlinkHref: this.href })));
2395
+ }
2396
+ };
2311
2397
  EzIcon.style = ezIconCss;
2312
2398
 
2313
2399
  const ezPopoverCss = ":host{--pop__box--border-radius:var(--border--radius-medium, 12px);--pop__box--box-shadow:var(--shadow, 0px 0px 16px 0px #000);position:relative;display:flex;user-select:none;width:100%}.box{z-index:var(--more-visible, 1);display:flex;flex-direction:column;height:fit-content;background-color:transparent;border-radius:var(--pop__box--border-radius);box-shadow:var(--pop__box--box-shadow)}.box--fit-content{width:fit-content}.box--full-width{width:100%}";
2314
2400
 
2315
- const EzPopover = class {
2316
- constructor(hostRef) {
2317
- index.registerInstance(this, hostRef);
2318
- this._firstRender = true;
2319
- /**
2320
- * No modo floating = false o popover só se tornará visível
2321
- * quando o método show() for acionado.
2322
- */
2323
- this.autoclose = true;
2324
- /**
2325
- * Offset top do popover em relação ao componente pai
2326
- */
2327
- this.top = '0px';
2328
- /**
2329
- * Offset left do popover em relação ao componente pai
2330
- */
2331
- this.left = '0px';
2332
- /**
2333
- * Offset bottom do popover em relação ao componente pai
2334
- */
2335
- this.bottom = '0px';
2336
- /**
2337
- * Offset right do popover em relação ao componente pai
2338
- */
2339
- this.right = '0px';
2340
- /**
2341
- * Ajusta o comportamento da largura do popover.
2342
- * Opções: "100% e "fit-content" (default)
2343
- */
2344
- this.boxwidth = 'fit-content';
2345
- }
2346
- /**
2347
- * Atualiza a posição do popover em relação ao componente pai.
2348
- */
2349
- async updatePosition(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2350
- const floatingOptions = {
2351
- autoClose: this.autoclose,
2352
- top,
2353
- left,
2354
- bottom,
2355
- right,
2356
- innerClickTest: (_container, node) => {
2357
- if (_container.contains(node)) {
2358
- return true;
2359
- }
2360
- if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2361
- return true;
2362
- }
2363
- //Here: we pass this._box as parameter but we need to change to _host
2364
- //because we need to get the lasChild (inner content to put in slot)
2365
- _container = this._host;
2366
- return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2367
- }
2368
- };
2369
- FloatingManager.updateFloatPosition(this._box, this._container, floatingOptions);
2370
- }
2371
- /**
2372
- * Faz com que o popover seja renderizado na DOM.
2373
- *
2374
- */
2375
- async show(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2376
- const floatingOptions = {
2377
- autoClose: this.autoclose,
2378
- top,
2379
- left,
2380
- bottom,
2381
- right,
2382
- innerClickTest: (_container, node) => {
2383
- if (_container.contains(node)) {
2384
- return true;
2385
- }
2386
- if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2387
- return true;
2388
- }
2389
- // Here: we pass this._box as parameter but we need to change to _host
2390
- // because we need to get the lasChild (inner content to put in slot)
2391
- _container = this._host;
2392
- return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2393
- }
2394
- };
2395
- this._floatingID = FloatingManager.float(this._box, this._container, floatingOptions);
2396
- this.isOpened = true;
2397
- }
2398
- /**
2399
- * Usado no modo floating. Faz com que o componente seja ocultado.
2400
- */
2401
- async hide() {
2402
- if (this._floatingID !== undefined) {
2403
- FloatingManager.close(this._floatingID);
2404
- this._floatingID = undefined;
2405
- this.isOpened = false;
2406
- }
2407
- }
2408
- componentDidRender() {
2409
- if (this._firstRender) {
2410
- this._box.remove();
2411
- this._firstRender = false;
2412
- }
2413
- }
2414
- render() {
2415
- return (index.h(index.Host, null, index.h("section", { ref: el => this._container = el }, index.h("div", { class: `box ${this.boxwidth === 'fit-content' ? 'box--fit-content' : 'box--full-width'}`, ref: el => this._box = el }, index.h("slot", null)))));
2416
- }
2417
- get _host() { return index.getElement(this); }
2418
- };
2401
+ const EzPopover = class {
2402
+ constructor(hostRef) {
2403
+ index.registerInstance(this, hostRef);
2404
+ this._firstRender = true;
2405
+ /**
2406
+ * No modo floating = false o popover só se tornará visível
2407
+ * quando o método show() for acionado.
2408
+ */
2409
+ this.autoclose = true;
2410
+ /**
2411
+ * Offset top do popover em relação ao componente pai
2412
+ */
2413
+ this.top = '0px';
2414
+ /**
2415
+ * Offset left do popover em relação ao componente pai
2416
+ */
2417
+ this.left = '0px';
2418
+ /**
2419
+ * Offset bottom do popover em relação ao componente pai
2420
+ */
2421
+ this.bottom = '0px';
2422
+ /**
2423
+ * Offset right do popover em relação ao componente pai
2424
+ */
2425
+ this.right = '0px';
2426
+ /**
2427
+ * Ajusta o comportamento da largura do popover.
2428
+ * Opções: "100% e "fit-content" (default)
2429
+ */
2430
+ this.boxwidth = 'fit-content';
2431
+ }
2432
+ /**
2433
+ * Atualiza a posição do popover em relação ao componente pai.
2434
+ */
2435
+ async updatePosition(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2436
+ const floatingOptions = {
2437
+ autoClose: this.autoclose,
2438
+ top,
2439
+ left,
2440
+ bottom,
2441
+ right,
2442
+ innerClickTest: (_container, node) => {
2443
+ if (_container.contains(node)) {
2444
+ return true;
2445
+ }
2446
+ if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2447
+ return true;
2448
+ }
2449
+ //Here: we pass this._box as parameter but we need to change to _host
2450
+ //because we need to get the lasChild (inner content to put in slot)
2451
+ _container = this._host;
2452
+ return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2453
+ }
2454
+ };
2455
+ FloatingManager.updateFloatPosition(this._box, this._container, floatingOptions);
2456
+ }
2457
+ /**
2458
+ * Faz com que o popover seja renderizado na DOM.
2459
+ *
2460
+ */
2461
+ async show(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2462
+ const floatingOptions = {
2463
+ autoClose: this.autoclose,
2464
+ top,
2465
+ left,
2466
+ bottom,
2467
+ right,
2468
+ innerClickTest: (_container, node) => {
2469
+ if (_container.contains(node)) {
2470
+ return true;
2471
+ }
2472
+ if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2473
+ return true;
2474
+ }
2475
+ // Here: we pass this._box as parameter but we need to change to _host
2476
+ // because we need to get the lasChild (inner content to put in slot)
2477
+ _container = this._host;
2478
+ return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2479
+ }
2480
+ };
2481
+ this._floatingID = FloatingManager.float(this._box, this._container, floatingOptions);
2482
+ this.isOpened = true;
2483
+ }
2484
+ /**
2485
+ * Usado no modo floating. Faz com que o componente seja ocultado.
2486
+ */
2487
+ async hide() {
2488
+ if (this._floatingID !== undefined) {
2489
+ FloatingManager.close(this._floatingID);
2490
+ this._floatingID = undefined;
2491
+ this.isOpened = false;
2492
+ }
2493
+ }
2494
+ componentDidRender() {
2495
+ if (this._firstRender) {
2496
+ this._box.remove();
2497
+ this._firstRender = false;
2498
+ }
2499
+ }
2500
+ render() {
2501
+ return (index.h(index.Host, null, index.h("section", { ref: el => this._container = el }, index.h("div", { class: `box ${this.boxwidth === 'fit-content' ? 'box--fit-content' : 'box--full-width'}`, ref: el => this._box = el }, index.h("slot", null)))));
2502
+ }
2503
+ get _host() { return index.getElement(this); }
2504
+ };
2419
2505
  EzPopover.style = ezPopoverCss;
2420
2506
 
2421
2507
  const ezSearchCss = ":host{--srch--height:42px;--srch--width:100%;--srch__icon--width:48px;--srch--border-radius:var(--border--radius-medium, 12px);--srch--border-radius-small:var(--border--radius-small, 6px);--srch--font-size:var(--text--medium, 14px);--srch--font-family:var(--font-pattern, Arial);--srch--font-weight--large:var(--text-weight--large, 500);--srch--font-weight--medium:var(--text-weight--medium, 400);--srch--space--medium:var(--space--medium, 12px);--srch--space--small:var(--space--small, 6px);--srch--shadow:var(--shadow, 0px 0px 16px 0px rgba(0, 38, 111, .12));--srch--background-color--xlight:var(--background--xlight,#fff);--srch__list-z-index:var(--more-visible, 1);--srch__input--background-color:var(--background--medium, #e0e0e0);--srch__input--border:var(--border--medium, 2px solid);--srch__input--border-color:var(--srch__input--background-color);--srch__input--focus--border-color:var(--color--primary, #008561);--srch__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--srch__input--disabled--color:var(--text--disable, #AFB6C0);--srch__input--error--border-color:#CC2936;--srch__label--color:var(--title--primary, #919191);--srch__message_box--font-size:var(--text--small, 12px);--srch__message_box--info--color:var(--color--success, #22085d);--srch__message_box--error--color:var(--color--error, #FF0000);--srch__list-text--primary:var(--text--primary,#626e82);--srch__list-text--secondary:var(--text--secondary,#a2abb9);--srch__list-height:calc(4px + var(--srch--font-size) + var(--srch--space--medium));display:flex;flex-wrap:wrap;position:relative;width:var(--srch--width)}ez-text-input{--it__input--background-color:var(--srch__input--background-color, #FFFFFF);--it__input--border-color:var(--srch__input--border-color, #DCE0E8)}input{width:100%;box-sizing:border-box;padding:var(--space--medium);height:var(--srch--height);border-radius:var(--srch--border-radius);font-family:var(--srch--font-family);font-size:var(--srch--font-size);border:var(--srch__input--border);border-color:var(--srch__input--border-color);background-color:var(--srch__input--background-color);font-weight:var(--text-weight--large)}input:disabled{background-color:var(--srch__input--disabled--background-color);color:var(--srch__input--disabled--color)}input:focus{outline:none;border-color:var(--srch__input--focus--border-color)}input.icon--left{padding-left:var(--srch__icon--width)}input.icon--right{padding-right:var(--srch__icon--width)}input::placeholder{color:var(--srch__placeholder--color);font-weight:var(--srch__placeholder--font-weight)}input:disabled::placeholder{color:var(--srch__placeholder--disabled--color)}input.hasError{color:inherit;border-color:var(--srch__input--error--border-color)}input.text--right{text-align:right}ez-text-input{--it__input--background-color:var(--srch__input--background-color, #FFFFFF);--it__input--border-color:var(--srch__input--border-color, #DCE0E8)}.message-box{min-height:0;min-width:100%;margin-top:2px;line-height:12px;font-family:var(--srch--font-family);font-size:var(--srch__message_box--font-size);color:var(--srch__message_box--info--color)}.hasError{min-height:16px;color:var(--srch__message_box--error--color)}.input__label{font-size:var(--text--medium);font-weight:var(--text-weight--large);left:var(--space--medium);position:absolute;color:var(--title--primary);top:var(--space--medium);font-family:var(--srch--font-family);-webkit-transition:font-size .3s, top .3s;transition:font-size .3s, top .3s;z-index:var(--visible)}.input__label--floated{font-family:var(--srch--font-family);font-size:var(--text--extra-small);top:var(--space--small);color:var(--text--primary)}.input__label--left{left:var(--srch__icon--width)}.input--with--label{padding-bottom:0}.message-box{min-height:16px;min-width:100%;margin-top:2px;line-height:12px;font-family:var(--srch--font-family);font-size:var(--srch__message_box--font-size);color:var(--srch__message_box--info--color)}.hasError{color:var(--srch__message_box--error--color)}.list-container{z-index:var(--srch__list-z-index);padding:var(--srch--space--small);background:var(--srch--background-color--xlight);border-radius:var(--srch--border-radius);width:100%;overflow:auto;box-sizing:border-box;max-height:calc(4*var(--srch__list-height) + 2*var(--srch--space--small))}li{list-style-type:none;border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);display:flex;justify-content:space-between;align-items:center}li:hover{background-color:var(--background--medium)}.--li__spanlabel{color:var(--srch__list-text--primary);border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);height:var(--srch__list-height);font-weight:var(--srch--font-weight--large);font-family:var(--srch--font-family);line-height:var(--srch__list-height);vertical-align:middle;text-overflow:ellipsis;width:80%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanlabel--full-width{color:var(--srch__list-text--primary);border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);height:var(--srch__list-height);font-weight:var(--srch--font-weight--large);font-family:var(--srch--font-family);line-height:var(--srch__list-height);vertical-align:middle;text-overflow:ellipsis;width:100%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanvalue{color:var(--srch__list-text--secondary);border-radius:var(--srch--border-radius-small);padding:0 var(--srch--space--small);height:var(--srch__list-height);font-weight:var(--srch--font-weight--medium);font-family:var(--srch--font-family);line-height:var(--srch__list-height);vertical-align:middle;text-overflow:ellipsis;width:20%;min-width:20px;overflow-x:hidden;text-align:right}.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(--text--primary, #008561);width:22px;height:22px;clip-path:path(\"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\")}.btn-open-search:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-search:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}.--li--preselected{background-color:var(--background--strong)}";
2422
2508
 
2423
- const EzSearch = class {
2424
- constructor(hostRef) {
2425
- index.registerInstance(this, hostRef);
2426
- this.ezChange = index.createEvent(this, "ezChange", 7);
2427
- this._options = [];
2428
- this._classSelect = 'list-container--4row';
2429
- /**
2430
- * Deixa o campo disponível ou não para digitação.
2431
- */
2432
- this.enabled = true;
2433
- /**
2434
- * Quantidade máxima de itens guardados no localstorage
2435
- */
2436
- this.qtdHotItems = 6;
2437
- /**
2438
- * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
2439
- */
2440
- this.showvalue = false;
2441
- ///// HOTSEARCH /////
2442
- this.buildId = () => {
2443
- return btoa(`${this.hotsearchid}:${location.pathname}`);
2444
- };
2445
- this.getStorageItems = (key) => {
2446
- let storageValueStr = localStorage.getItem('hotSearch-ez-search:' + key);
2447
- let storageItems = [];
2448
- if (storageValueStr !== null) {
2449
- storageItems = JSON.parse(storageValueStr);
2450
- }
2451
- return storageItems;
2452
- };
2453
- this.orderHotList = (list) => {
2454
- return list.sort((a, b) => {
2455
- let time1 = new Date(a.dtRecent).getTime();
2456
- let time2 = new Date(b.dtRecent).getTime();
2457
- let qtd1 = a.qtd;
2458
- let qtd2 = b.qtd;
2459
- if (time1 < time2)
2460
- return -1;
2461
- if (time1 > time2)
2462
- return 1;
2463
- if (qtd1 > qtd2)
2464
- return -1;
2465
- if (qtd1 < qtd2)
2466
- return 1;
2467
- return 0;
2468
- });
2469
- };
2470
- this.saveStorageItem = (key, value) => {
2471
- if (value == '' || value == undefined)
2472
- return;
2473
- let storageItem = this.getStorageItems(key);
2474
- let element = this.getElement(storageItem, value);
2475
- if (element) {
2476
- element.qtd++;
2477
- element.dtRecent = this.getOnlyDate();
2478
- }
2479
- else {
2480
- if (storageItem.length >= this.qtdHotItems) {
2481
- storageItem = this.orderHotList(storageItem);
2482
- storageItem.splice(-1, 1);
2483
- }
2484
- storageItem.push({
2485
- description: value,
2486
- qtd: 1,
2487
- dtRecent: this.getOnlyDate()
2488
- });
2489
- }
2490
- localStorage.setItem('hotSearch-ez-search:' + key, JSON.stringify(storageItem));
2491
- return storageItem;
2492
- };
2493
- this.adjustOptions = (arrayOptions) => {
2494
- let optionsTemp = [];
2495
- arrayOptions.map(el => {
2496
- optionsTemp.push({
2497
- value: el.value,
2498
- label: el.label,
2499
- ajustedValue: el.value === null || el.value === undefined || el.value === '' ? el.label : el.value,
2500
- });
2501
- });
2502
- return optionsTemp;
2503
- };
2504
- this.sortArrayOptions = (array, propname) => {
2505
- const sortedArray = array.sort(function (a, b) {
2506
- if (a[propname] < b[propname]) {
2507
- return -1;
2508
- }
2509
- if (a[propname] > b[propname]) {
2510
- return 1;
2511
- }
2512
- return 0;
2513
- });
2514
- return sortedArray;
2515
- };
2516
- }
2517
- valueChanged() {
2518
- var _a;
2519
- if (this.value) {
2520
- this.ezChange.emit({ value: this.value, label: (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value });
2521
- let key = this.buildId();
2522
- this.saveStorageItem(key, this.value);
2523
- }
2524
- }
2525
- //ajustar ao fim do teste
2526
- onInputTeste() {
2527
- if (this._inputElem) {
2528
- this.handleChange();
2529
- }
2530
- }
2531
- getElement(storageItem, value) {
2532
- return storageItem.find(e => e.description === value);
2533
- }
2534
- getOnlyDate() {
2535
- let dt = new Date();
2536
- dt.setHours(0);
2537
- dt.setMinutes(0);
2538
- dt.setSeconds(0);
2539
- dt.setUTCMilliseconds(0);
2540
- return dt.toString();
2541
- }
2542
- onInputChange(ev) {
2543
- const el = ev.target;
2544
- let key = this.buildId();
2545
- this.saveStorageItem(key, el.value);
2546
- }
2547
- buildDataList() {
2548
- try {
2549
- if (this.hotsearchid === undefined) {
2550
- return;
2551
- }
2552
- let key = this.buildId();
2553
- let optionsArray = [];
2554
- this._options = [];
2555
- if (this.getStorageItems(key).length > 0) {
2556
- this.orderHotList(this.getStorageItems(key))
2557
- .forEach((el) => {
2558
- optionsArray.push({
2559
- value: el.description,
2560
- label: el.description,
2561
- });
2562
- });
2563
- this._options = [{ value: '', label: '' }].concat(optionsArray);
2564
- this.buildOptions();
2565
- }
2566
- }
2567
- catch (err) {
2568
- this.errormessage = err;
2569
- }
2570
- }
2571
- ///// EVENT HANDLERS
2572
- buildItem(opt, index$1) {
2573
- const className = index$1 === this._preSelection ? "--li--preselected" : "";
2574
- return index.h("li", { class: className, key: opt.ajustedValue, accessKey: opt.label.toString(), id: 'item_' + opt.ajustedValue, onMouseDown: (ev) => this.handleSetValueByOption(ev) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { title: opt.ajustedValue, class: '--li__spanvalue' }, opt.ajustedValue) : null);
2575
- }
2576
- highlightMatch(label) {
2577
- var _a;
2578
- const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
2579
- if ((_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) {
2580
- const criteriaLength = this._inputElem.value.length;
2581
- const matchStart = label.toUpperCase().indexOf(this._inputElem.value);
2582
- if (matchStart > -1) {
2583
- const strLabelStart = label.substr(0, matchStart);
2584
- const strLabelEnd = label.substr(matchStart + criteriaLength);
2585
- const strMatch = label.substr(matchStart, criteriaLength);
2586
- return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
2587
- }
2588
- }
2589
- return (index.h("span", { class: spanClassName }, label));
2590
- }
2591
- showOptions() {
2592
- if (this.enabled) {
2593
- const top = this._inputElem.errormessage ? '0px' : '-17px';
2594
- this._popover.show(top);
2595
- }
2596
- }
2597
- nextOption() {
2598
- this.showOptions();
2599
- this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
2600
- this.scrollToOption(this._visibleOptions[this._preSelection]);
2601
- }
2602
- previousOption() {
2603
- this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
2604
- this.scrollToOption(this._visibleOptions[this._preSelection]);
2605
- }
2606
- scrollToOption(opt) {
2607
- const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
2608
- if (liElem) {
2609
- const parent = liElem.parentElement;
2610
- const parentRect = parent.getBoundingClientRect();
2611
- const itemRect = liElem.getBoundingClientRect();
2612
- if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
2613
- liElem.scrollIntoView();
2614
- }
2615
- }
2616
- }
2617
- selectCurrentOption() {
2618
- if (this._preSelection !== undefined) {
2619
- this.selectOption(this._visibleOptions[this._preSelection]);
2620
- this._preSelection = undefined;
2621
- }
2622
- }
2623
- selectOption(opt) {
2624
- this._popover.hide();
2625
- this.value = opt === null || opt === void 0 ? void 0 : opt.ajustedValue;
2626
- this._inputElem.value = opt.value;
2627
- //Definir com a equipe de design se vai ser utilizado dessa forma.
2628
- // this._inputElem.value = opt.value? opt.value + " - "+ opt?.label: '';
2629
- }
2630
- keyDownHandler(event) {
2631
- switch (event.key) {
2632
- case "ArrowDown":
2633
- this.nextOption();
2634
- break;
2635
- case "ArrowUp":
2636
- this.previousOption();
2637
- break;
2638
- case "Enter":
2639
- this.selectCurrentOption();
2640
- break;
2641
- }
2642
- event.stopPropagation();
2643
- }
2644
- handleSetValueByOption(ev) {
2645
- this._popover.hide();
2646
- const spanEl = ev.target;
2647
- const sourceElement = ev.composedPath()[0];
2648
- let li;
2649
- if (sourceElement.tagName === 'SPAN') {
2650
- li = spanEl.parentNode;
2651
- }
2652
- else {
2653
- li = spanEl.parentNode.parentNode;
2654
- }
2655
- this.value = li.id.split('_')[1];
2656
- this._inputElem.value = li.accessKey;
2657
- this.ezChange.emit();
2658
- }
2659
- handleChange() {
2660
- if (this._changeDeboucing) {
2661
- window.clearTimeout(this._changeDeboucing);
2662
- }
2663
- this._changeDeboucing = window.setTimeout(() => {
2664
- var _a, _b;
2665
- if (((_b = (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) <= 0) {
2666
- return;
2667
- }
2668
- /* save tip on localStorage */
2669
- let key = this.buildId();
2670
- this.saveStorageItem(key, this._inputElem.value);
2671
- /* load data */
2672
- if (this.loadexecutor) {
2673
- this._loadDataFunction(this._inputElem.value, (serverData) => { this.populateOptions(serverData); });
2674
- }
2675
- }, 200);
2676
- }
2677
- normalizeResult(data) {
2678
- let options = [];
2679
- if (data instanceof Array) {
2680
- options = data;
2681
- }
2682
- else {
2683
- if (data instanceof Object) {
2684
- for (var key in data) {
2685
- let newOption = { value: '', label: '' };
2686
- newOption.value = key;
2687
- newOption.label = data[key];
2688
- options.push(newOption);
2689
- }
2690
- }
2691
- }
2692
- this._options = [{ value: '', label: '' }].concat(options);
2693
- this.buildOptions();
2694
- }
2695
- populateOptions(serverData) {
2696
- if (serverData instanceof Promise) {
2697
- serverData.then(this.normalizeResult);
2698
- }
2699
- else {
2700
- this.normalizeResult(serverData);
2701
- }
2702
- }
2703
- buildOptions() {
2704
- var _a;
2705
- this._visibleOptions = [];
2706
- this._visibleOptions = this.adjustOptions(this._options);
2707
- this._visibleOptions = this.sortArrayOptions(this._visibleOptions, 'label');
2708
- if (this._visibleOptions.length > 0) {
2709
- (_a = this._divElem) === null || _a === void 0 ? void 0 : _a.classList.add(this._classSelect);
2710
- this.showOptions();
2711
- }
2712
- }
2713
- setClassForSpanLabel() {
2714
- if (!this.showvalue) {
2715
- return '--li__spanlabel--full-width';
2716
- }
2717
- else {
2718
- return '--li__spanlabel';
2719
- }
2720
- }
2721
- handleFocus() {
2722
- if (this._inputElem && (!this._inputElem.value || this._inputElem.value.length === 0)) {
2723
- this.buildDataList();
2724
- }
2725
- }
2726
- parseExecutor(executor) {
2727
- if (executor) {
2728
- return executor instanceof Function ? executor : eval(executor);
2729
- }
2730
- return null;
2731
- }
2732
- componentDidLoad() {
2733
- if (this.value && this.value.length > 0) {
2734
- this._inputElem.value = this.value;
2735
- }
2736
- this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2737
- }
2738
- render() {
2739
- var _a;
2740
- return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => { this._inputElem = el; }, label: this.label, enabled: this.enabled, onFocus: () => { this.handleFocus(); }, onInput: () => { this.handleChange(); }, onKeyDown: event => this.keyDownHandler(event), errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { alert("Esta ação irá abrir o PopUp!"); }, slot: "leftIcon" })), index.h("ez-popover", { boxwidth: '100%', ref: el => this._popover = el }, index.h("div", { class: 'list-container', ref: (el) => this._divElem = el }, (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.map((opt, index) => this.buildItem(opt, index))))));
2741
- }
2742
- ;
2743
- get el() { return index.getElement(this); }
2744
- static get watchers() { return {
2745
- "value": ["valueChanged"]
2746
- }; }
2747
- };
2509
+ const EzSearch = class {
2510
+ constructor(hostRef) {
2511
+ index.registerInstance(this, hostRef);
2512
+ this.ezChange = index.createEvent(this, "ezChange", 7);
2513
+ this._options = [];
2514
+ this._classSelect = 'list-container--4row';
2515
+ /**
2516
+ * Deixa o campo disponível ou não para digitação.
2517
+ */
2518
+ this.enabled = true;
2519
+ /**
2520
+ * Quantidade máxima de itens guardados no localstorage
2521
+ */
2522
+ this.qtdHotItems = 6;
2523
+ /**
2524
+ * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
2525
+ */
2526
+ this.showvalue = false;
2527
+ ///// HOTSEARCH /////
2528
+ this.buildId = () => {
2529
+ return btoa(`${this.hotsearchid}:${location.pathname}`);
2530
+ };
2531
+ this.getStorageItems = (key) => {
2532
+ let storageValueStr = localStorage.getItem('hotSearch-ez-search:' + key);
2533
+ let storageItems = [];
2534
+ if (storageValueStr !== null) {
2535
+ storageItems = JSON.parse(storageValueStr);
2536
+ }
2537
+ return storageItems;
2538
+ };
2539
+ this.orderHotList = (list) => {
2540
+ return list.sort((a, b) => {
2541
+ let time1 = new Date(a.dtRecent).getTime();
2542
+ let time2 = new Date(b.dtRecent).getTime();
2543
+ let qtd1 = a.qtd;
2544
+ let qtd2 = b.qtd;
2545
+ if (time1 < time2)
2546
+ return -1;
2547
+ if (time1 > time2)
2548
+ return 1;
2549
+ if (qtd1 > qtd2)
2550
+ return -1;
2551
+ if (qtd1 < qtd2)
2552
+ return 1;
2553
+ return 0;
2554
+ });
2555
+ };
2556
+ this.saveStorageItem = (key, value) => {
2557
+ if (value == '' || value == undefined)
2558
+ return;
2559
+ let storageItem = this.getStorageItems(key);
2560
+ let element = this.getElement(storageItem, value);
2561
+ if (element) {
2562
+ element.qtd++;
2563
+ element.dtRecent = this.getOnlyDate();
2564
+ }
2565
+ else {
2566
+ if (storageItem.length >= this.qtdHotItems) {
2567
+ storageItem = this.orderHotList(storageItem);
2568
+ storageItem.splice(-1, 1);
2569
+ }
2570
+ storageItem.push({
2571
+ description: value,
2572
+ qtd: 1,
2573
+ dtRecent: this.getOnlyDate()
2574
+ });
2575
+ }
2576
+ localStorage.setItem('hotSearch-ez-search:' + key, JSON.stringify(storageItem));
2577
+ return storageItem;
2578
+ };
2579
+ this.adjustOptions = (arrayOptions) => {
2580
+ let optionsTemp = [];
2581
+ arrayOptions.map(el => {
2582
+ optionsTemp.push({
2583
+ value: el.value,
2584
+ label: el.label,
2585
+ ajustedValue: el.value === null || el.value === undefined || el.value === '' ? el.label : el.value,
2586
+ });
2587
+ });
2588
+ return optionsTemp;
2589
+ };
2590
+ this.sortArrayOptions = (array, propname) => {
2591
+ const sortedArray = array.sort(function (a, b) {
2592
+ if (a[propname] < b[propname]) {
2593
+ return -1;
2594
+ }
2595
+ if (a[propname] > b[propname]) {
2596
+ return 1;
2597
+ }
2598
+ return 0;
2599
+ });
2600
+ return sortedArray;
2601
+ };
2602
+ }
2603
+ valueChanged() {
2604
+ var _a;
2605
+ if (this.value) {
2606
+ this.ezChange.emit({ value: this.value, label: (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value });
2607
+ let key = this.buildId();
2608
+ this.saveStorageItem(key, this.value);
2609
+ }
2610
+ }
2611
+ //ajustar ao fim do teste
2612
+ onInputTeste() {
2613
+ if (this._inputElem) {
2614
+ this.handleChange();
2615
+ }
2616
+ }
2617
+ getElement(storageItem, value) {
2618
+ return storageItem.find(e => e.description === value);
2619
+ }
2620
+ getOnlyDate() {
2621
+ let dt = new Date();
2622
+ dt.setHours(0);
2623
+ dt.setMinutes(0);
2624
+ dt.setSeconds(0);
2625
+ dt.setUTCMilliseconds(0);
2626
+ return dt.toString();
2627
+ }
2628
+ onInputChange(ev) {
2629
+ const el = ev.target;
2630
+ let key = this.buildId();
2631
+ this.saveStorageItem(key, el.value);
2632
+ }
2633
+ buildDataList() {
2634
+ try {
2635
+ if (this.hotsearchid === undefined) {
2636
+ return;
2637
+ }
2638
+ let key = this.buildId();
2639
+ let optionsArray = [];
2640
+ this._options = [];
2641
+ if (this.getStorageItems(key).length > 0) {
2642
+ this.orderHotList(this.getStorageItems(key))
2643
+ .forEach((el) => {
2644
+ optionsArray.push({
2645
+ value: el.description,
2646
+ label: el.description,
2647
+ });
2648
+ });
2649
+ this._options = [{ value: '', label: '' }].concat(optionsArray);
2650
+ this.buildOptions();
2651
+ }
2652
+ }
2653
+ catch (err) {
2654
+ this.errormessage = err;
2655
+ }
2656
+ }
2657
+ ///// EVENT HANDLERS
2658
+ buildItem(opt, index$1) {
2659
+ const className = index$1 === this._preSelection ? "--li--preselected" : "";
2660
+ return index.h("li", { class: className, key: opt.ajustedValue, accessKey: opt.label.toString(), id: 'item_' + opt.ajustedValue, onMouseDown: (ev) => this.handleSetValueByOption(ev) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { title: opt.ajustedValue, class: '--li__spanvalue' }, opt.ajustedValue) : null);
2661
+ }
2662
+ highlightMatch(label) {
2663
+ var _a;
2664
+ const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
2665
+ if ((_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) {
2666
+ const criteriaLength = this._inputElem.value.length;
2667
+ const matchStart = label.toUpperCase().indexOf(this._inputElem.value);
2668
+ if (matchStart > -1) {
2669
+ const strLabelStart = label.substr(0, matchStart);
2670
+ const strLabelEnd = label.substr(matchStart + criteriaLength);
2671
+ const strMatch = label.substr(matchStart, criteriaLength);
2672
+ return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
2673
+ }
2674
+ }
2675
+ return (index.h("span", { class: spanClassName }, label));
2676
+ }
2677
+ showOptions() {
2678
+ if (this.enabled) {
2679
+ const top = this._inputElem.errormessage ? '0px' : '-17px';
2680
+ this._popover.show(top);
2681
+ }
2682
+ }
2683
+ nextOption() {
2684
+ this.showOptions();
2685
+ this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
2686
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
2687
+ }
2688
+ previousOption() {
2689
+ this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
2690
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
2691
+ }
2692
+ scrollToOption(opt) {
2693
+ const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
2694
+ if (liElem) {
2695
+ const parent = liElem.parentElement;
2696
+ const parentRect = parent.getBoundingClientRect();
2697
+ const itemRect = liElem.getBoundingClientRect();
2698
+ if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
2699
+ liElem.scrollIntoView();
2700
+ }
2701
+ }
2702
+ }
2703
+ selectCurrentOption() {
2704
+ if (this._preSelection !== undefined) {
2705
+ this.selectOption(this._visibleOptions[this._preSelection]);
2706
+ this._preSelection = undefined;
2707
+ }
2708
+ }
2709
+ selectOption(opt) {
2710
+ this._popover.hide();
2711
+ this.value = opt === null || opt === void 0 ? void 0 : opt.ajustedValue;
2712
+ this._inputElem.value = opt.value;
2713
+ //Definir com a equipe de design se vai ser utilizado dessa forma.
2714
+ // this._inputElem.value = opt.value? opt.value + " - "+ opt?.label: '';
2715
+ }
2716
+ keyDownHandler(event) {
2717
+ switch (event.key) {
2718
+ case "ArrowDown":
2719
+ this.nextOption();
2720
+ break;
2721
+ case "ArrowUp":
2722
+ this.previousOption();
2723
+ break;
2724
+ case "Enter":
2725
+ this.selectCurrentOption();
2726
+ break;
2727
+ }
2728
+ event.stopPropagation();
2729
+ }
2730
+ handleSetValueByOption(ev) {
2731
+ this._popover.hide();
2732
+ const spanEl = ev.target;
2733
+ const sourceElement = ev.composedPath()[0];
2734
+ let li;
2735
+ if (sourceElement.tagName === 'SPAN') {
2736
+ li = spanEl.parentNode;
2737
+ }
2738
+ else {
2739
+ li = spanEl.parentNode.parentNode;
2740
+ }
2741
+ this.value = li.id.split('_')[1];
2742
+ this._inputElem.value = li.accessKey;
2743
+ this.ezChange.emit();
2744
+ }
2745
+ handleChange() {
2746
+ if (this._changeDeboucing) {
2747
+ window.clearTimeout(this._changeDeboucing);
2748
+ }
2749
+ this._changeDeboucing = window.setTimeout(() => {
2750
+ var _a, _b;
2751
+ if (((_b = (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) <= 0) {
2752
+ return;
2753
+ }
2754
+ /* save tip on localStorage */
2755
+ let key = this.buildId();
2756
+ this.saveStorageItem(key, this._inputElem.value);
2757
+ /* load data */
2758
+ if (this.loadexecutor) {
2759
+ this._loadDataFunction(this._inputElem.value, (serverData) => { this.populateOptions(serverData); });
2760
+ }
2761
+ }, 200);
2762
+ }
2763
+ normalizeResult(data) {
2764
+ let options = [];
2765
+ if (data instanceof Array) {
2766
+ options = data;
2767
+ }
2768
+ else {
2769
+ if (data instanceof Object) {
2770
+ for (var key in data) {
2771
+ let newOption = { value: '', label: '' };
2772
+ newOption.value = key;
2773
+ newOption.label = data[key];
2774
+ options.push(newOption);
2775
+ }
2776
+ }
2777
+ }
2778
+ this._options = [{ value: '', label: '' }].concat(options);
2779
+ this.buildOptions();
2780
+ }
2781
+ populateOptions(serverData) {
2782
+ if (serverData instanceof Promise) {
2783
+ serverData.then(this.normalizeResult);
2784
+ }
2785
+ else {
2786
+ this.normalizeResult(serverData);
2787
+ }
2788
+ }
2789
+ buildOptions() {
2790
+ var _a;
2791
+ this._visibleOptions = [];
2792
+ this._visibleOptions = this.adjustOptions(this._options);
2793
+ this._visibleOptions = this.sortArrayOptions(this._visibleOptions, 'label');
2794
+ if (this._visibleOptions.length > 0) {
2795
+ (_a = this._divElem) === null || _a === void 0 ? void 0 : _a.classList.add(this._classSelect);
2796
+ this.showOptions();
2797
+ }
2798
+ }
2799
+ setClassForSpanLabel() {
2800
+ if (!this.showvalue) {
2801
+ return '--li__spanlabel--full-width';
2802
+ }
2803
+ else {
2804
+ return '--li__spanlabel';
2805
+ }
2806
+ }
2807
+ handleFocus() {
2808
+ if (this._inputElem && (!this._inputElem.value || this._inputElem.value.length === 0)) {
2809
+ this.buildDataList();
2810
+ }
2811
+ }
2812
+ parseExecutor(executor) {
2813
+ if (executor) {
2814
+ return executor instanceof Function ? executor : eval(executor);
2815
+ }
2816
+ return null;
2817
+ }
2818
+ componentDidLoad() {
2819
+ if (this.value && this.value.length > 0) {
2820
+ this._inputElem.value = this.value;
2821
+ }
2822
+ this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2823
+ }
2824
+ render() {
2825
+ var _a;
2826
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => { this._inputElem = el; }, label: this.label, enabled: this.enabled, onFocus: () => { this.handleFocus(); }, onInput: () => { this.handleChange(); }, onKeyDown: event => this.keyDownHandler(event), errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { alert("Esta ação irá abrir o PopUp!"); }, slot: "leftIcon" })), index.h("ez-popover", { boxwidth: '100%', ref: el => this._popover = el }, index.h("div", { class: 'list-container', ref: (el) => this._divElem = el }, (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.map((opt, index) => this.buildItem(opt, index))))));
2827
+ }
2828
+ ;
2829
+ get el() { return index.getElement(this); }
2830
+ static get watchers() { return {
2831
+ "value": ["valueChanged"]
2832
+ }; }
2833
+ };
2748
2834
  EzSearch.style = ezSearchCss;
2749
2835
 
2750
2836
  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;margin-bottom:var(--space--large, 24px);--tab__box--box-shadow:var(--shadow, 0px 0px 8px 0px #000)}.scroll{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto}.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;clip-path:path(\"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\")}.backward-button::after{clip-path:path(\"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\")}.forward-button:hover::after,.backward-button:hover::after{background-color:var(--color--primary, #4e4e4e)}.hidden{display:none}.scroll::-webkit-scrollbar{display:none}";
2751
2837
 
2752
- const EzTabselector = class {
2753
- constructor(hostRef) {
2754
- index.registerInstance(this, hostRef);
2755
- this.change = index.createEvent(this, "change", 7);
2756
- this.setFoucusedParam = (ev) => {
2757
- if (ev.key === 'Enter') {
2758
- this.selectedindex = this.foucusedindex;
2759
- this.foucusedindex = undefined;
2760
- this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2761
- this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2762
- ev.preventDefault();
2763
- this.setFocusedTab(this.selectedindex);
2764
- }
2765
- else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
2766
- let operator = undefined;
2767
- if (ev.key === 'ArrowLeft') {
2768
- operator = false;
2769
- }
2770
- else if (ev.key === 'ArrowRight') {
2771
- operator = true;
2772
- }
2773
- else {
2774
- return;
2775
- }
2776
- if (this.foucusedindex === undefined) {
2777
- if (operator === false) {
2778
- this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
2779
- }
2780
- else {
2781
- this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
2782
- }
2783
- }
2784
- else {
2785
- if (operator === false) {
2786
- this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
2787
- }
2788
- else {
2789
- this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
2790
- }
2791
- }
2792
- if (parseInt(this.foucusedindex) < 0) {
2793
- this.foucusedindex = '0';
2794
- }
2795
- else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
2796
- this.foucusedindex = (this._processedTabs.length - 1).toString();
2797
- }
2798
- this.setFoucusedBtn(true, this.foucusedindex);
2799
- this.setFocusedTab(this.foucusedindex);
2800
- this.change.emit();
2801
- }
2802
- else if (ev.key === 'Tab' || ev.key === 'Escape') {
2803
- this.foucusedindex = undefined;
2804
- this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2805
- this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2806
- ev.preventDefault();
2807
- this.setFocusedTab(this.selectedindex);
2808
- }
2809
- // this.setFocusedTab();
2810
- };
2811
- }
2812
- handleTabClick(tab, index) {
2813
- this.selectedindex = index.toString();
2814
- this.foucusedindex = undefined;
2815
- this.selectedtab = tab;
2816
- this.change.emit();
2817
- this.setFoucusedBtn(false, this.selectedindex);
2818
- }
2819
- componentWillRender() {
2820
- if (!this._processedTabs) {
2821
- this._processedTabs = [];
2822
- if (this.tabs) {
2823
- this.tabs.split(',').forEach((label) => {
2824
- label = label.trim();
2825
- this._processedTabs.push(new Tab(label, label));
2826
- });
2827
- }
2828
- this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
2829
- const tabKey = elem.getAttribute('tabKey');
2830
- const label = elem.getAttribute('label');
2831
- const t = new Tab(label, tabKey);
2832
- const content = elem.firstChild;
2833
- if (content) {
2834
- content.setAttribute('slot', 'tab' + this._processedTabs.length);
2835
- this._hostElem.appendChild(content);
2836
- }
2837
- this._processedTabs.push(t);
2838
- });
2839
- }
2840
- }
2841
- handleSlotChange(ev) {
2842
- const slot = ev.target;
2843
- const content = slot.assignedElements()[0];
2844
- if (content) {
2845
- content.style.marginLeft = "6px";
2846
- }
2847
- }
2848
- scrollBackward() {
2849
- const container = this._scrollContainer;
2850
- if (container) {
2851
- container.scrollLeft -= container.clientWidth;
2852
- }
2853
- }
2854
- scrollFoward() {
2855
- const container = this._scrollContainer;
2856
- if (container) {
2857
- let lastTab = null;
2858
- container.querySelectorAll('.tab').forEach((tab) => {
2859
- if (tab.getBoundingClientRect().right < container.clientWidth) {
2860
- lastTab = tab;
2861
- }
2862
- });
2863
- container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
2864
- }
2865
- }
2866
- componentDidRender() {
2867
- this.updateScroll();
2868
- }
2869
- updateScroll() {
2870
- const container = this._scrollContainer;
2871
- if (container) {
2872
- const { scrollWidth, clientWidth, scrollLeft } = container;
2873
- const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
2874
- this._startHidden = container.scrollLeft > 0;
2875
- this._endHidden = remainingScroll > 0;
2876
- if (this._startHidden) {
2877
- this._backwardButton.classList.remove('hidden');
2878
- }
2879
- else {
2880
- this._backwardButton.classList.add('hidden');
2881
- }
2882
- if (this._endHidden) {
2883
- this._forwardButton.classList.remove('hidden');
2884
- }
2885
- else {
2886
- this._forwardButton.classList.add('hidden');
2887
- }
2888
- const classNames = ['', 'startHidden', 'endHidden', 'midle'];
2889
- const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
2890
- classNames.forEach((name) => {
2891
- if (name !== currentClass && container.classList.contains(name)) {
2892
- container.classList.remove(name);
2893
- }
2894
- });
2895
- if (currentClass && !container.classList.contains(currentClass)) {
2896
- container.classList.add(currentClass);
2897
- }
2898
- }
2899
- }
2900
- domScrollHandler() {
2901
- window.clearTimeout(this._scrollCallBack);
2902
- this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
2903
- }
2904
- setFocusedTab(index) {
2905
- window.clearTimeout(this._scrollCallBackTeste);
2906
- this._scrollCallBackTeste = window.setTimeout(() => {
2907
- const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
2908
- console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
2909
- console.log('tabtoscroll', tabtoscroll);
2910
- tabtoscroll.scrollIntoView();
2911
- }, 200);
2912
- }
2913
- getTextWidth(text) {
2914
- if (this._textMesurement === undefined) {
2915
- this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
2916
- }
2917
- const context = this._textMesurement.getContext("2d");
2918
- context.font = '14px Sora, Algerian';
2919
- return Math.min(220, 24 + context.measureText(text).width) + 'px';
2920
- }
2921
- ;
2922
- setFoucusedBtn(visible, paramater) {
2923
- const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
2924
- tabsButtons.forEach((el) => {
2925
- el.classList.remove('is-focused');
2926
- if (el.id === 'tab' + paramater && visible) {
2927
- el.classList.add('is-focused');
2928
- }
2929
- });
2930
- }
2931
- render() {
2932
- 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,
2933
- // onScroll={() => this.domScrollHandler()}
2934
- onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index$1) => {
2935
- const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
2936
- const tabId = "tab" + index$1;
2937
- const isSelected = index$1 === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
2938
- if (isSelected) {
2939
- this.selectedtab = tab.tabKey;
2940
- this.selectedindex = index$1.toString();
2941
- }
2942
- 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); } }));
2943
- })), index.h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
2944
- }
2945
- get _hostElem() { return index.getElement(this); }
2946
- };
2947
- class Tab {
2948
- constructor(label, tabKey) {
2949
- this.label = label;
2950
- this.tabKey = tabKey;
2951
- }
2952
- }
2838
+ const EzTabselector = class {
2839
+ constructor(hostRef) {
2840
+ index.registerInstance(this, hostRef);
2841
+ this.change = index.createEvent(this, "change", 7);
2842
+ this.setFoucusedParam = (ev) => {
2843
+ if (ev.key === 'Enter') {
2844
+ this.selectedindex = this.foucusedindex;
2845
+ this.foucusedindex = undefined;
2846
+ this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2847
+ this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2848
+ ev.preventDefault();
2849
+ this.setFocusedTab(this.selectedindex);
2850
+ }
2851
+ else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
2852
+ let operator = undefined;
2853
+ if (ev.key === 'ArrowLeft') {
2854
+ operator = false;
2855
+ }
2856
+ else if (ev.key === 'ArrowRight') {
2857
+ operator = true;
2858
+ }
2859
+ else {
2860
+ return;
2861
+ }
2862
+ if (this.foucusedindex === undefined) {
2863
+ if (operator === false) {
2864
+ this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
2865
+ }
2866
+ else {
2867
+ this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
2868
+ }
2869
+ }
2870
+ else {
2871
+ if (operator === false) {
2872
+ this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
2873
+ }
2874
+ else {
2875
+ this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
2876
+ }
2877
+ }
2878
+ if (parseInt(this.foucusedindex) < 0) {
2879
+ this.foucusedindex = '0';
2880
+ }
2881
+ else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
2882
+ this.foucusedindex = (this._processedTabs.length - 1).toString();
2883
+ }
2884
+ this.setFoucusedBtn(true, this.foucusedindex);
2885
+ this.setFocusedTab(this.foucusedindex);
2886
+ this.change.emit();
2887
+ }
2888
+ else if (ev.key === 'Tab' || ev.key === 'Escape') {
2889
+ this.foucusedindex = undefined;
2890
+ this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2891
+ this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2892
+ ev.preventDefault();
2893
+ this.setFocusedTab(this.selectedindex);
2894
+ }
2895
+ // this.setFocusedTab();
2896
+ };
2897
+ }
2898
+ handleTabClick(tab, index) {
2899
+ this.selectedindex = index.toString();
2900
+ this.foucusedindex = undefined;
2901
+ this.selectedtab = tab;
2902
+ this.change.emit();
2903
+ this.setFoucusedBtn(false, this.selectedindex);
2904
+ }
2905
+ componentWillRender() {
2906
+ if (!this._processedTabs) {
2907
+ this._processedTabs = [];
2908
+ if (this.tabs) {
2909
+ this.tabs.split(',').forEach((label) => {
2910
+ label = label.trim();
2911
+ this._processedTabs.push(new Tab(label, label));
2912
+ });
2913
+ }
2914
+ this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
2915
+ const tabKey = elem.getAttribute('tabKey');
2916
+ const label = elem.getAttribute('label');
2917
+ const t = new Tab(label, tabKey);
2918
+ const content = elem.firstChild;
2919
+ if (content) {
2920
+ content.setAttribute('slot', 'tab' + this._processedTabs.length);
2921
+ this._hostElem.appendChild(content);
2922
+ }
2923
+ this._processedTabs.push(t);
2924
+ });
2925
+ }
2926
+ }
2927
+ handleSlotChange(ev) {
2928
+ const slot = ev.target;
2929
+ const content = slot.assignedElements()[0];
2930
+ if (content) {
2931
+ content.style.marginLeft = "6px";
2932
+ }
2933
+ }
2934
+ scrollBackward() {
2935
+ const container = this._scrollContainer;
2936
+ if (container) {
2937
+ container.scrollLeft -= container.clientWidth;
2938
+ }
2939
+ }
2940
+ scrollFoward() {
2941
+ const container = this._scrollContainer;
2942
+ if (container) {
2943
+ let lastTab = null;
2944
+ container.querySelectorAll('.tab').forEach((tab) => {
2945
+ if (tab.getBoundingClientRect().right < container.clientWidth) {
2946
+ lastTab = tab;
2947
+ }
2948
+ });
2949
+ container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
2950
+ }
2951
+ }
2952
+ componentDidRender() {
2953
+ this.updateScroll();
2954
+ }
2955
+ updateScroll() {
2956
+ const container = this._scrollContainer;
2957
+ if (container) {
2958
+ const { scrollWidth, clientWidth, scrollLeft } = container;
2959
+ const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
2960
+ this._startHidden = container.scrollLeft > 0;
2961
+ this._endHidden = remainingScroll > 0;
2962
+ if (this._startHidden) {
2963
+ this._backwardButton.classList.remove('hidden');
2964
+ }
2965
+ else {
2966
+ this._backwardButton.classList.add('hidden');
2967
+ }
2968
+ if (this._endHidden) {
2969
+ this._forwardButton.classList.remove('hidden');
2970
+ }
2971
+ else {
2972
+ this._forwardButton.classList.add('hidden');
2973
+ }
2974
+ const classNames = ['', 'startHidden', 'endHidden', 'midle'];
2975
+ const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
2976
+ classNames.forEach((name) => {
2977
+ if (name !== currentClass && container.classList.contains(name)) {
2978
+ container.classList.remove(name);
2979
+ }
2980
+ });
2981
+ if (currentClass && !container.classList.contains(currentClass)) {
2982
+ container.classList.add(currentClass);
2983
+ }
2984
+ }
2985
+ }
2986
+ domScrollHandler() {
2987
+ window.clearTimeout(this._scrollCallBack);
2988
+ this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
2989
+ }
2990
+ setFocusedTab(index) {
2991
+ window.clearTimeout(this._scrollCallBackTeste);
2992
+ this._scrollCallBackTeste = window.setTimeout(() => {
2993
+ const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
2994
+ console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
2995
+ console.log('tabtoscroll', tabtoscroll);
2996
+ tabtoscroll.scrollIntoView();
2997
+ }, 200);
2998
+ }
2999
+ getTextWidth(text) {
3000
+ if (this._textMesurement === undefined) {
3001
+ this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
3002
+ }
3003
+ const context = this._textMesurement.getContext("2d");
3004
+ context.font = '14px Sora, Algerian';
3005
+ return Math.min(220, 24 + context.measureText(text).width) + 'px';
3006
+ }
3007
+ ;
3008
+ setFoucusedBtn(visible, paramater) {
3009
+ const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
3010
+ tabsButtons.forEach((el) => {
3011
+ el.classList.remove('is-focused');
3012
+ if (el.id === 'tab' + paramater && visible) {
3013
+ el.classList.add('is-focused');
3014
+ }
3015
+ });
3016
+ }
3017
+ render() {
3018
+ 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,
3019
+ // onScroll={() => this.domScrollHandler()}
3020
+ onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index$1) => {
3021
+ const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
3022
+ const tabId = "tab" + index$1;
3023
+ const isSelected = index$1 === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
3024
+ if (isSelected) {
3025
+ this.selectedtab = tab.tabKey;
3026
+ this.selectedindex = index$1.toString();
3027
+ }
3028
+ 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); } }));
3029
+ })), index.h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
3030
+ }
3031
+ get _hostElem() { return index.getElement(this); }
3032
+ };
3033
+ class Tab {
3034
+ constructor(label, tabKey) {
3035
+ this.label = label;
3036
+ this.tabKey = tabKey;
3037
+ }
3038
+ }
2953
3039
  EzTabselector.style = ezTabselectorCss;
2954
3040
 
2955
3041
  const ezTextAreaCss = ":host{--ta--width:100%;--ta--border-radius:var(--border--radius-medium, 12px);--ta--font-size:var(--text--medium, 14px);--ta--font-family:var(--font-pattern, Arial);--ta--font-weight:var(--text-weight--large, 500);--ta--color:var(--title--primary, #000);--ta__input--background-color:var(--background--medium, #e0e0e0);--ta__input--border:var(--border--medium, 2px solid);--ta__input--border-color:var(--ta__input--background-color);--ta__input--focus--border-color:var(--color--primary, #008561);--ta__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ta__input--disabled--color:var(--text--disable, #AFB6C0);--ta__input--error--border-color:#CC2936;--ta__input--floating--padding-top:16px;--ta__message_box--font-size:var(--text--small, 12px);--ta__message_box--info--color:var(--color--success, #22085d);--ta__message_box--error--color:var(--color--error, #FF0000);--ta__label--floating--top:6px;--ta__label--padding-top:12px;--ta__label--padding-left:14px;--ta__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--ta--width)}textarea{width:100%;box-sizing:border-box;padding:var(--space--medium, 6px);font-weight:var(--text-weight--large, 600);resize:none;border-radius:var(--ta--border-radius);font-family:var(--ta--font-family);font-size:var(--ta--font-size);border:var(--ta__input--border);border-color:var(--ta__input--border-color);background-color:var(--ta__input--background-color);color:var(--ta--color)}textarea:disabled{background-color:var(--ta__input--disabled--background-color);color:var(--ta__input--disabled--color)}textarea:focus{outline:none;border-color:var(--ta__input--focus--border-color)}textarea.hasError{color:var(--ta--color);border-color:var(--ta__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(--ta--font-family);font-size:var(--ta__message_box--font-size);color:var(--ta__message_box--info--color)}.hasError{color:var(--ta__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(--ta__label--padding-right));left:var(--ta--space--medium);font-family:var(--ta--font-family);font-size:var(--ta--font-size);font-weight:var(--ta--font-weight);color:var(--ta--color);top:var(--ta__label--padding-top);left:var(--ta__label--padding-left);padding-right:var(--ta__label--padding-right)}.textarea__label--floated{font-family:var(--ta--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--ta__label--floating--top)}.textarea__label--disabled{color:var(--ta__input--disabled--color)}.input--with--label{padding-bottom:0;padding-top:var(--ta__input--floating--padding-top)}";
2956
3042
 
2957
- const EzTextArea = class {
2958
- constructor(hostRef) {
2959
- index.registerInstance(this, hostRef);
2960
- this.ezChange = index.createEvent(this, "ezChange", 7);
2961
- /**
2962
- * Deixa o campo disponível ou não para digitação.
2963
- */
2964
- this.enabled = true;
2965
- /**
2966
- * Ajusta o numero de linhas e consequentemente o height do textarea. Valor default: 4
2967
- */
2968
- this.rows = 4;
2969
- }
2970
- showError() {
2971
- const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
2972
- if (hasError) {
2973
- this._inputElem.classList.add('hasError');
2974
- this._messageBoxElem.classList.add('hasError');
2975
- }
2976
- else {
2977
- this._inputElem.classList.remove('hasError');
2978
- this._messageBoxElem.classList.remove('hasError');
2979
- }
2980
- }
2981
- updateInputValue() {
2982
- this._inputElem.value = this.value;
2983
- this.handleChange();
2984
- this.adjustFloatingLabel();
2985
- }
2986
- adjustFloatingLabel() {
2987
- if (this.label) {
2988
- if (!this._inputElem.classList.contains("input--with--label")) {
2989
- this._inputElem.classList.add("input--with--label");
2990
- }
2991
- const hasValue = this.value && this.value.toString().length > 0;
2992
- const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
2993
- if (hasValue || this.isFocused()) {
2994
- if (!containsFloatedClass) {
2995
- this._labelElem.classList.add("textarea__label--floated");
2996
- }
2997
- }
2998
- else {
2999
- if (containsFloatedClass) {
3000
- this._labelElem.classList.remove("textarea__label--floated");
3001
- }
3002
- }
3003
- }
3004
- }
3005
- isFocused() {
3006
- return this._hostElement.shadowRoot.activeElement !== null;
3007
- }
3008
- //---------------------------------------------
3009
- // Public methods
3010
- //---------------------------------------------
3011
- /**
3012
- * Faz o foco no componente de input
3013
- */
3014
- async setFocus() {
3015
- this._inputElem.focus();
3016
- }
3017
- /**
3018
- * Remove o foco no componente de input
3019
- */
3020
- async setBlur() {
3021
- this._inputElem.blur();
3022
- }
3023
- //---------------------------------------------
3024
- // Event handlers
3025
- //---------------------------------------------
3026
- handleFocusout() {
3027
- this.adjustFloatingLabel();
3028
- }
3029
- handleChange() {
3030
- this.value = this._inputElem.value;
3031
- }
3032
- handleFocus() {
3033
- if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
3034
- this._labelElem.classList.add("textarea__label--floated");
3035
- }
3036
- }
3037
- //---------------------------------------------
3038
- // Lifecycle web component
3039
- //---------------------------------------------
3040
- componentDidLoad() {
3041
- this.showError();
3042
- this.adjustFloatingLabel();
3043
- }
3044
- render() {
3045
- return (index.h(index.Host, null, this.label ?
3046
- 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)
3047
- : 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)));
3048
- }
3049
- get _hostElement() { return index.getElement(this); }
3050
- static get watchers() { return {
3051
- "errormessage": ["showError"],
3052
- "value": ["updateInputValue"]
3053
- }; }
3054
- };
3043
+ const EzTextArea = class {
3044
+ constructor(hostRef) {
3045
+ index.registerInstance(this, hostRef);
3046
+ this.ezChange = index.createEvent(this, "ezChange", 7);
3047
+ /**
3048
+ * Deixa o campo disponível ou não para digitação.
3049
+ */
3050
+ this.enabled = true;
3051
+ /**
3052
+ * Ajusta o numero de linhas e consequentemente o height do textarea. Valor default: 4
3053
+ */
3054
+ this.rows = 4;
3055
+ }
3056
+ showError() {
3057
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3058
+ if (hasError) {
3059
+ this._inputElem.classList.add('hasError');
3060
+ this._messageBoxElem.classList.add('hasError');
3061
+ }
3062
+ else {
3063
+ this._inputElem.classList.remove('hasError');
3064
+ this._messageBoxElem.classList.remove('hasError');
3065
+ }
3066
+ }
3067
+ updateInputValue() {
3068
+ this._inputElem.value = this.value;
3069
+ this.handleChange();
3070
+ this.adjustFloatingLabel();
3071
+ }
3072
+ adjustFloatingLabel() {
3073
+ if (this.label) {
3074
+ if (!this._inputElem.classList.contains("input--with--label")) {
3075
+ this._inputElem.classList.add("input--with--label");
3076
+ }
3077
+ const hasValue = this.value && this.value.toString().length > 0;
3078
+ const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
3079
+ if (hasValue || this.isFocused()) {
3080
+ if (!containsFloatedClass) {
3081
+ this._labelElem.classList.add("textarea__label--floated");
3082
+ }
3083
+ }
3084
+ else {
3085
+ if (containsFloatedClass) {
3086
+ this._labelElem.classList.remove("textarea__label--floated");
3087
+ }
3088
+ }
3089
+ }
3090
+ }
3091
+ isFocused() {
3092
+ return this._hostElement.shadowRoot.activeElement !== null;
3093
+ }
3094
+ //---------------------------------------------
3095
+ // Public methods
3096
+ //---------------------------------------------
3097
+ /**
3098
+ * Faz o foco no componente de input
3099
+ */
3100
+ async setFocus() {
3101
+ this._inputElem.focus();
3102
+ }
3103
+ /**
3104
+ * Remove o foco no componente de input
3105
+ */
3106
+ async setBlur() {
3107
+ this._inputElem.blur();
3108
+ }
3109
+ //---------------------------------------------
3110
+ // Event handlers
3111
+ //---------------------------------------------
3112
+ handleFocusout() {
3113
+ this.adjustFloatingLabel();
3114
+ }
3115
+ handleChange() {
3116
+ this.value = this._inputElem.value;
3117
+ }
3118
+ handleFocus() {
3119
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
3120
+ this._labelElem.classList.add("textarea__label--floated");
3121
+ }
3122
+ }
3123
+ //---------------------------------------------
3124
+ // Lifecycle web component
3125
+ //---------------------------------------------
3126
+ componentDidLoad() {
3127
+ this.showError();
3128
+ this.adjustFloatingLabel();
3129
+ }
3130
+ render() {
3131
+ return (index.h(index.Host, null, this.label ?
3132
+ 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)
3133
+ : 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)));
3134
+ }
3135
+ get _hostElement() { return index.getElement(this); }
3136
+ static get watchers() { return {
3137
+ "errormessage": ["showError"],
3138
+ "value": ["updateInputValue"]
3139
+ }; }
3140
+ };
3055
3141
  EzTextArea.style = ezTextAreaCss;
3056
3142
 
3057
- function isValidNumber(strValue) {
3058
- return strValue && /^-?\d*[.,]?\d*$/.test(strValue);
3143
+ function isValidNumber(strValue) {
3144
+ return strValue && /^-?\d*[.,]?\d*$/.test(strValue);
3059
3145
  }
3060
3146
 
3061
3147
  const ezTextInputCss = ":host{--it--height:42px;--it--width:100%;--it__icon--width:48px;--it--border-radius:var(--border--radius-medium, 12px);--it--font-size:var(--text--medium, 14px);--it--font-family:var(--font-pattern, Arial);--it--font-weight:var(--text-weight--large, 500);--it--color:var(--title--primary, #000);--it__input--background-color:var(--background--medium, #e0e0e0);--it__input--border:var(--border--medium, 2px solid);--it__input--border-color:var(--it__input--background-color);--it__input--focus--border-color:var(--color--primary, #008561);--it__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--it__input--disabled--color:var(--text--disable, #AFB6C0);--it__input--error--border-color:#CC2936;--it__message_box--font-size:var(--text--small, 12px);--it__message_box--info--color:var(--color--success, #22085d);--it__message_box--error--color:var(--color--error, #FF0000);--it__label--floating--top:6px;--it__label--padding-top:12px;--it__label--padding-left:14px;--it__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--it--width)}input{width:100%;box-sizing:border-box;padding:var(--space--medium, 6px);font-weight:var(--text-weight--large, 600);height:var(--it--height);border-radius:var(--it--border-radius);font-family:var(--it--font-family);font-size:var(--it--font-size);border:var(--it__input--border);border-color:var(--it__input--border-color);background-color:var(--it__input--background-color);color:var(--it--color)}input:disabled{background-color:var(--it__input--disabled--background-color);color:var(--it__input--disabled--color)}input:focus{outline:none;border-color:var(--it__input--focus--border-color)}input.icon--left{padding-left:var(--it__icon--width)}input.icon--right{padding-right:var(--it__icon--width)}input.hasError{color:var(--it--color);border-color:var(--it__input--error--border-color)}input.text--right{text-align:right}.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(--it--font-family);font-size:var(--it__message_box--font-size);color:var(--it__message_box--info--color)}.hasError{color:var(--it__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(--it__label--padding-right));left:var(--it--space--medium);font-family:var(--it--font-family);font-size:var(--it--font-size);font-weight:var(--it--font-weight);color:var(--it--color);top:var(--it__label--padding-top);left:var(--it__label--padding-left);padding-right:var(--it__label--padding-right)}.input__label--floated{font-family:var(--it--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--it__label--floating--top)}.input__label--disabled{color:var(--it__input--disabled--color)}.input__label--left{left:calc(var(--it__icon--width) + 2px);width:calc(100% - var(--it__icon--width))}.input__label--right{right:var(--it__icon--width);width:calc(100% - var(--it__icon--width))}.input__label--left.input__label--right{left:calc(var(--it__icon--width) + 2px);width:calc(100% - var(--it__icon--width) * 2)}.input--with--label{padding-bottom:0}";
3062
3148
 
3063
- const EzTextInput = class {
3064
- constructor(hostRef) {
3065
- index.registerInstance(this, hostRef);
3066
- this.ezChange = index.createEvent(this, "ezChange", 7);
3067
- /**
3068
- * Deixa o campo disponível ou não para digitação.
3069
- */
3070
- this.enabled = true;
3071
- }
3072
- showError() {
3073
- const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3074
- if (hasError) {
3075
- this._inputElem.classList.add('hasError');
3076
- this._messageBoxElem.classList.add('hasError');
3077
- }
3078
- else {
3079
- this._inputElem.classList.remove('hasError');
3080
- this._messageBoxElem.classList.remove('hasError');
3081
- }
3082
- }
3083
- prepareMask() {
3084
- if (this.mask) {
3085
- if (this._maskFormatter == undefined) {
3086
- this._maskFormatter = new RequestMetadata.MaskFormatter(this.mask);
3087
- }
3088
- else {
3089
- this._maskFormatter.mask = this.mask;
3090
- }
3091
- }
3092
- }
3093
- updateInputValue() {
3094
- this._inputElem.value = this.value;
3095
- this.handleChange();
3096
- this.ezChange.emit();
3097
- this.adjustFloatingLabel();
3098
- }
3099
- adjustFloatingLabel() {
3100
- if (this.label) {
3101
- if (!this._inputElem.classList.contains("input--with--label")) {
3102
- this._inputElem.classList.add("input--with--label");
3103
- }
3104
- const hasValue = this.value && this.value.toString().length > 0;
3105
- const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
3106
- if (hasValue || this.isFocused()) {
3107
- if (!containsFloatedClass) {
3108
- this._labelElem.classList.add("input__label--floated");
3109
- }
3110
- }
3111
- else {
3112
- if (containsFloatedClass) {
3113
- this._labelElem.classList.remove("input__label--floated");
3114
- }
3115
- }
3116
- }
3117
- }
3118
- isFocused() {
3119
- return this._hostElement.shadowRoot.activeElement !== null;
3120
- }
3121
- //---------------------------------------------
3122
- // Public methods
3123
- //---------------------------------------------
3124
- /**
3125
- * Faz o foco no componente de input
3126
- */
3127
- async setFocus() {
3128
- this._inputElem.focus();
3129
- }
3130
- /**
3131
- * Remove o foco no componente de input
3132
- */
3133
- async setBlur() {
3134
- this._inputElem.blur();
3135
- }
3136
- //---------------------------------------------
3137
- // Event handlers
3138
- //---------------------------------------------
3139
- handleFocusout() {
3140
- const value = this._inputElem.value;
3141
- if (value && this._maskFormatter) {
3142
- try {
3143
- this._inputElem.value = this._maskFormatter.format(value);
3144
- }
3145
- catch (e) {
3146
- this.errormessage = e.message;
3147
- }
3148
- }
3149
- this.value = this._inputElem.value;
3150
- this.adjustFloatingLabel();
3151
- }
3152
- isValidValue(value) {
3153
- if (this.onlynumber) {
3154
- return value == "" || isValidNumber(value);
3155
- }
3156
- if (this.restrict) {
3157
- return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
3158
- }
3159
- return true;
3160
- }
3161
- handleChange() {
3162
- if (!this._inputElem) {
3163
- return;
3164
- }
3165
- const value = this._inputElem.value;
3166
- if (this.isValidValue(value)) {
3167
- this._lastValidValue = value;
3168
- }
3169
- else {
3170
- this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
3171
- }
3172
- this.value = this._inputElem.value;
3173
- }
3174
- handleSlotChange(ev) {
3175
- const slot = ev.target;
3176
- const content = slot.assignedElements()[0];
3177
- if (content) {
3178
- content.style.position = "absolute";
3179
- content.style.display = "flex";
3180
- content.style.alignItems = "center";
3181
- content.style.justifyContent = "center";
3182
- content.style.overflow = "hidden";
3183
- content.style.top = "0px";
3184
- content.style.width = "var(--it__icon--width)";
3185
- content.style.height = "var(--it--height)";
3186
- if (slot.name == "leftIcon") {
3187
- content.style.left = "0px";
3188
- content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
3189
- this._inputElem.classList.add('icon--left');
3190
- if (this._labelElem) {
3191
- this._labelElem.classList.add('input__label--left');
3192
- }
3193
- }
3194
- else if (slot.name == "rightIcon") {
3195
- content.style.right = "0px";
3196
- content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
3197
- this._inputElem.classList.add('icon--right');
3198
- if (this._labelElem) {
3199
- this._labelElem.classList.add('input__label--right');
3200
- }
3201
- }
3202
- }
3203
- this.showError();
3204
- }
3205
- doFocus() {
3206
- if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
3207
- this._labelElem.classList.add("input__label--floated");
3208
- }
3209
- }
3210
- //---------------------------------------------
3211
- // Lifecycle web component
3212
- //---------------------------------------------
3213
- componentDidLoad() {
3214
- if (this.onlynumber) {
3215
- this._inputElem.classList.add('text--right');
3216
- }
3217
- this.showError();
3218
- this.prepareMask();
3219
- this.adjustFloatingLabel();
3220
- }
3221
- componentWillLoad() {
3222
- this.prepareMask();
3223
- if (this.value) {
3224
- if (this._maskFormatter) {
3225
- try {
3226
- this.value = this._maskFormatter.format(this.value);
3227
- }
3228
- catch (e) {
3229
- this.errormessage = e.message;
3230
- }
3231
- }
3232
- if (!this.isValidValue(this.value)) {
3233
- this._lastValidValue = "";
3234
- this.value = "";
3235
- }
3236
- }
3237
- }
3238
- render() {
3239
- return (index.h(index.Host, null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
3240
- 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)
3241
- : 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)));
3242
- }
3243
- get _hostElement() { return index.getElement(this); }
3244
- static get watchers() { return {
3245
- "errormessage": ["showError"],
3246
- "mask": ["prepareMask"],
3247
- "value": ["updateInputValue"]
3248
- }; }
3249
- };
3149
+ const EzTextInput = class {
3150
+ constructor(hostRef) {
3151
+ index.registerInstance(this, hostRef);
3152
+ this.ezChange = index.createEvent(this, "ezChange", 7);
3153
+ /**
3154
+ * Deixa o campo disponível ou não para digitação.
3155
+ */
3156
+ this.enabled = true;
3157
+ }
3158
+ showError() {
3159
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3160
+ if (hasError) {
3161
+ this._inputElem.classList.add('hasError');
3162
+ this._messageBoxElem.classList.add('hasError');
3163
+ }
3164
+ else {
3165
+ this._inputElem.classList.remove('hasError');
3166
+ this._messageBoxElem.classList.remove('hasError');
3167
+ }
3168
+ }
3169
+ prepareMask() {
3170
+ if (this.mask) {
3171
+ if (this._maskFormatter == undefined) {
3172
+ this._maskFormatter = new RequestMetadata.MaskFormatter(this.mask);
3173
+ }
3174
+ else {
3175
+ this._maskFormatter.mask = this.mask;
3176
+ }
3177
+ }
3178
+ }
3179
+ updateInputValue() {
3180
+ this._inputElem.value = this.value;
3181
+ this.handleChange();
3182
+ this.ezChange.emit();
3183
+ this.adjustFloatingLabel();
3184
+ }
3185
+ adjustFloatingLabel() {
3186
+ if (this.label) {
3187
+ if (!this._inputElem.classList.contains("input--with--label")) {
3188
+ this._inputElem.classList.add("input--with--label");
3189
+ }
3190
+ const hasValue = this.value && this.value.toString().length > 0;
3191
+ const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
3192
+ if (hasValue || this.isFocused()) {
3193
+ if (!containsFloatedClass) {
3194
+ this._labelElem.classList.add("input__label--floated");
3195
+ }
3196
+ }
3197
+ else {
3198
+ if (containsFloatedClass) {
3199
+ this._labelElem.classList.remove("input__label--floated");
3200
+ }
3201
+ }
3202
+ }
3203
+ }
3204
+ isFocused() {
3205
+ return this._hostElement.shadowRoot.activeElement !== null;
3206
+ }
3207
+ //---------------------------------------------
3208
+ // Public methods
3209
+ //---------------------------------------------
3210
+ /**
3211
+ * Faz o foco no componente de input
3212
+ */
3213
+ async setFocus() {
3214
+ this._inputElem.focus();
3215
+ }
3216
+ /**
3217
+ * Remove o foco no componente de input
3218
+ */
3219
+ async setBlur() {
3220
+ this._inputElem.blur();
3221
+ }
3222
+ //---------------------------------------------
3223
+ // Event handlers
3224
+ //---------------------------------------------
3225
+ handleFocusout() {
3226
+ const value = this._inputElem.value;
3227
+ if (value && this._maskFormatter) {
3228
+ try {
3229
+ this._inputElem.value = this._maskFormatter.format(value);
3230
+ }
3231
+ catch (e) {
3232
+ this.errormessage = e.message;
3233
+ }
3234
+ }
3235
+ this.value = this._inputElem.value;
3236
+ this.adjustFloatingLabel();
3237
+ }
3238
+ isValidValue(value) {
3239
+ if (this.onlynumber) {
3240
+ return value == "" || isValidNumber(value);
3241
+ }
3242
+ if (this.restrict) {
3243
+ return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
3244
+ }
3245
+ return true;
3246
+ }
3247
+ handleChange() {
3248
+ if (!this._inputElem) {
3249
+ return;
3250
+ }
3251
+ const value = this._inputElem.value;
3252
+ if (this.isValidValue(value)) {
3253
+ this._lastValidValue = value;
3254
+ }
3255
+ else {
3256
+ this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
3257
+ }
3258
+ this.value = this._inputElem.value;
3259
+ }
3260
+ handleSlotChange(ev) {
3261
+ const slot = ev.target;
3262
+ const content = slot.assignedElements()[0];
3263
+ if (content) {
3264
+ content.style.position = "absolute";
3265
+ content.style.display = "flex";
3266
+ content.style.alignItems = "center";
3267
+ content.style.justifyContent = "center";
3268
+ content.style.overflow = "hidden";
3269
+ content.style.top = "0px";
3270
+ content.style.width = "var(--it__icon--width)";
3271
+ content.style.height = "var(--it--height)";
3272
+ if (slot.name == "leftIcon") {
3273
+ content.style.left = "0px";
3274
+ content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
3275
+ this._inputElem.classList.add('icon--left');
3276
+ if (this._labelElem) {
3277
+ this._labelElem.classList.add('input__label--left');
3278
+ }
3279
+ }
3280
+ else if (slot.name == "rightIcon") {
3281
+ content.style.right = "0px";
3282
+ content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
3283
+ this._inputElem.classList.add('icon--right');
3284
+ if (this._labelElem) {
3285
+ this._labelElem.classList.add('input__label--right');
3286
+ }
3287
+ }
3288
+ }
3289
+ this.showError();
3290
+ }
3291
+ doFocus() {
3292
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
3293
+ this._labelElem.classList.add("input__label--floated");
3294
+ }
3295
+ }
3296
+ //---------------------------------------------
3297
+ // Lifecycle web component
3298
+ //---------------------------------------------
3299
+ componentDidLoad() {
3300
+ if (this.onlynumber) {
3301
+ this._inputElem.classList.add('text--right');
3302
+ }
3303
+ this.showError();
3304
+ this.prepareMask();
3305
+ this.adjustFloatingLabel();
3306
+ }
3307
+ componentWillLoad() {
3308
+ this.prepareMask();
3309
+ if (this.value) {
3310
+ if (this._maskFormatter) {
3311
+ try {
3312
+ this.value = this._maskFormatter.format(this.value);
3313
+ }
3314
+ catch (e) {
3315
+ this.errormessage = e.message;
3316
+ }
3317
+ }
3318
+ if (!this.isValidValue(this.value)) {
3319
+ this._lastValidValue = "";
3320
+ this.value = "";
3321
+ }
3322
+ }
3323
+ }
3324
+ render() {
3325
+ return (index.h(index.Host, null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
3326
+ 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)
3327
+ : 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)));
3328
+ }
3329
+ get _hostElement() { return index.getElement(this); }
3330
+ static get watchers() { return {
3331
+ "errormessage": ["showError"],
3332
+ "mask": ["prepareMask"],
3333
+ "value": ["updateInputValue"]
3334
+ }; }
3335
+ };
3250
3336
  EzTextInput.style = ezTextInputCss;
3251
3337
 
3252
3338
  const placeHolderCss = ":host{display:flex;width:100%;height:42px;border-radius:12px;background:var(--background--medium);background-image:linear-gradient(to right, var(--background--medium) 0%, var(--background--strong) 20%, var(--background--medium) 40%, var(--background--medium) 100%);background-repeat:no-repeat;background-size:800px 1000px;animation-duration:1s;animation-fill-mode:forwards;animation-iteration-count:infinite;animation-name:placeholderShimmer;animation-timing-function:linear}@keyframes placeholderShimmer{0%{background-position:-800px 0}100%{background-position:800px 0}}";
3253
3339
 
3254
- const PlaceHolder = class {
3255
- constructor(hostRef) {
3256
- index.registerInstance(this, hostRef);
3257
- }
3258
- render() {
3259
- return index.h(index.Host, null);
3260
- }
3261
- };
3340
+ const PlaceHolder = class {
3341
+ constructor(hostRef) {
3342
+ index.registerInstance(this, hostRef);
3343
+ }
3344
+ render() {
3345
+ return index.h(index.Host, null);
3346
+ }
3347
+ };
3262
3348
  PlaceHolder.style = placeHolderCss;
3263
3349
 
3264
3350
  exports.ez_button = EzButton;