@sankhyalabs/ezui 1.1.8 → 1.1.9

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