@sankhyalabs/ezui 1.1.6 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +72 -72
  2. package/dist/cjs/{DataUnit-09a6e7be.js → DataUnit-95368a67.js} +418 -361
  3. package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
  4. package/dist/cjs/ez-button_14.cjs.entry.js +1933 -1847
  5. package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
  6. package/dist/cjs/ez-modal.cjs.entry.js +102 -95
  7. package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
  8. package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
  9. package/dist/cjs/ezui.cjs.js +1 -1
  10. package/dist/cjs/form-metadata.cjs.entry.js +65 -65
  11. package/dist/cjs/loader.cjs.js +1 -1
  12. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
  13. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
  14. package/dist/collection/components/ez-button/ez-button.css +94 -94
  15. package/dist/collection/components/ez-button/ez-button.js +125 -125
  16. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
  17. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
  18. package/dist/collection/components/ez-check/ez-check.css +265 -265
  19. package/dist/collection/components/ez-check/ez-check.js +168 -168
  20. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
  21. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
  22. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
  23. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
  24. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
  25. package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
  26. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
  27. package/dist/collection/components/ez-form/ez-form.css +19 -19
  28. package/dist/collection/components/ez-form/ez-form.js +390 -289
  29. package/dist/collection/components/ez-form/store/Form.actions.js +132 -123
  30. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -174
  31. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -43
  32. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +252 -207
  33. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
  34. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
  35. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
  36. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
  37. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
  38. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
  39. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -33
  40. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -18
  41. package/dist/collection/components/ez-icon/ez-icon.css +36 -36
  42. package/dist/collection/components/ez-icon/ez-icon.js +56 -56
  43. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
  44. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
  45. package/dist/collection/components/ez-modal/ez-modal.css +86 -86
  46. package/dist/collection/components/ez-modal/ez-modal.js +222 -200
  47. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
  48. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
  49. package/dist/collection/components/ez-popover/ez-popover.css +38 -38
  50. package/dist/collection/components/ez-popover/ez-popover.js +323 -323
  51. package/dist/collection/components/ez-search/ez-search.css +295 -295
  52. package/dist/collection/components/ez-search/ez-search.js +527 -527
  53. package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
  54. package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
  55. package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
  56. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
  57. package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
  58. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
  59. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
  60. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
  61. package/dist/collection/index.js +1 -1
  62. package/dist/collection/servidor.js +100 -100
  63. package/dist/collection/utils/FloatingManager.js +15 -15
  64. package/dist/collection/utils/utils.js +6 -6
  65. package/dist/custom-elements/index.js +3146 -2998
  66. package/dist/esm/{DataUnit-7a983910.js → DataUnit-4bb6a396.js} +417 -362
  67. package/dist/esm/ez-action-chip.entry.js +41 -41
  68. package/dist/esm/ez-button_14.entry.js +1933 -1847
  69. package/dist/esm/ez-label-chip.entry.js +120 -120
  70. package/dist/esm/ez-modal.entry.js +103 -96
  71. package/dist/esm/ez-number-input.entry.js +236 -236
  72. package/dist/esm/ez-time-input.entry.js +168 -168
  73. package/dist/esm/ezui.js +1 -1
  74. package/dist/esm/form-metadata.entry.js +65 -65
  75. package/dist/esm/loader.js +1 -1
  76. package/dist/esm/polyfills/core-js.js +0 -0
  77. package/dist/esm/polyfills/dom.js +0 -0
  78. package/dist/esm/polyfills/es5-html-element.js +0 -0
  79. package/dist/esm/polyfills/index.js +0 -0
  80. package/dist/esm/polyfills/system.js +0 -0
  81. package/dist/ezui/ezui.esm.js +1 -1
  82. package/dist/ezui/p-11d20338.js +1 -0
  83. package/dist/ezui/{p-3c3a43aa.entry.js → p-5d30e51c.entry.js} +1 -1
  84. package/dist/ezui/p-77fdb4fd.entry.js +1 -0
  85. package/dist/ezui/p-e056fb23.entry.js +1 -0
  86. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  87. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  88. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  89. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  90. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  91. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  92. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  93. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  94. package/dist/types/components/ez-form/ez-form.d.ts +27 -27
  95. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -104
  96. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -11
  97. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -13
  98. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +61 -48
  99. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  100. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  101. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  102. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  103. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  104. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  105. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -7
  106. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  107. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  108. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -26
  109. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  110. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  111. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  112. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  113. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  114. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  115. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  116. package/dist/types/components.d.ts +8 -0
  117. package/dist/types/index.d.ts +1 -1
  118. package/dist/types/utils/utils.d.ts +2 -2
  119. package/package.json +114 -114
  120. package/react/components.d.ts +22 -0
  121. package/react/components.js +25 -0
  122. package/react/components.js.map +1 -0
  123. package/react/react-component-lib/createComponent.d.ts +10 -0
  124. package/react/react-component-lib/createComponent.js +59 -0
  125. package/react/react-component-lib/createComponent.js.map +1 -0
  126. package/react/react-component-lib/createOverlayComponent.d.ts +20 -0
  127. package/react/react-component-lib/createOverlayComponent.js +89 -0
  128. package/react/react-component-lib/createOverlayComponent.js.map +1 -0
  129. package/react/react-component-lib/index.d.ts +2 -0
  130. package/react/react-component-lib/index.js +3 -0
  131. package/react/react-component-lib/index.js.map +1 -0
  132. package/react/react-component-lib/interfaces.d.ts +29 -0
  133. package/react/react-component-lib/interfaces.js +1 -0
  134. package/react/react-component-lib/interfaces.js.map +1 -0
  135. package/react/react-component-lib/utils/attachProps.d.ts +12 -0
  136. package/react/react-component-lib/utils/attachProps.js +96 -0
  137. package/react/react-component-lib/utils/attachProps.js.map +1 -0
  138. package/react/react-component-lib/utils/case.d.ts +2 -0
  139. package/react/react-component-lib/utils/case.js +7 -0
  140. package/react/react-component-lib/utils/case.js.map +1 -0
  141. package/react/react-component-lib/utils/dev.d.ts +2 -0
  142. package/react/react-component-lib/utils/dev.js +13 -0
  143. package/react/react-component-lib/utils/dev.js.map +1 -0
  144. package/react/react-component-lib/utils/index.d.ts +7 -0
  145. package/react/react-component-lib/utils/index.js +21 -0
  146. package/react/react-component-lib/utils/index.js.map +1 -0
  147. package/dist/ezui/p-5185cbf1.entry.js +0 -1
  148. package/dist/ezui/p-5d600057.entry.js +0 -1
  149. package/dist/ezui/p-9f819174.js +0 -1
@@ -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 changeTab$1, i as invalidField$1, f as formLoad, D as DataUnit } from './DataUnit-7a983910.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-4bb6a396.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,1439 +1822,1525 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
1822
1822
 
1823
1823
  const undoable = /*@__PURE__*/getDefaultExportFromCjs(lib);
1824
1824
 
1825
- const inicialState = {
1826
- currentTabIndex: {},
1827
- currentRecordIndex: {},
1828
- changes: {},
1829
- collapsedGroups: {},
1830
- newRecordIndex: {}
1831
- };
1832
- function formReducer(state = inicialState, action) {
1833
- switch (action.type) {
1834
- case 'FORM/COLLAPSEGROUP':
1835
- return collapseGroup(state, action.payload);
1836
- case 'FORM/CHANGETAB':
1837
- return changeTab(state, action.payload.formId, action.payload.index);
1838
- case 'FORM/NAVIGATE':
1839
- return navigate(state, action.payload);
1840
- case 'FORM/INSERT':
1841
- return insertRecord(state, action.payload);
1842
- case 'FORM/CHANGEFIELD':
1843
- return changeFieldValue(state, action.payload);
1844
- case 'FORM/CLEAREDITION':
1845
- return clearEdition(state, action.payload);
1846
- case 'FORM/INVALIDFIELD':
1847
- return navigateToInvalid(state, action.payload);
1848
- default:
1849
- return state;
1850
- }
1851
- }
1852
- function formNonHistoricReducer(state = { dataLoading: {}, invalidFields: {} }, action) {
1853
- switch (action.type) {
1854
- case 'FORM/DATALOADING':
1855
- return dataLoading(state, action.payload);
1856
- case 'FORM/DATALOADED':
1857
- return dataLoaded(state, action.payload);
1858
- case 'FORM/SAVINGCHANGES':
1859
- return savingChanges(state, action.payload);
1860
- case 'FORM/CHANGESSAVED':
1861
- return changesSaved(state, action.payload);
1862
- case 'FORM/REMOVINGRECORD':
1863
- return removingRecord(state, action.payload);
1864
- case 'FORM/RECORDREMOVED':
1865
- return recordRemoved(state, action.payload);
1866
- case 'FORM/INVALIDFIELD':
1867
- return invalidField(state, action.payload);
1868
- case 'FORM/CLEAREDITION':
1869
- return clearAllInvalidFields(state, action.payload);
1870
- case 'FORM/CHANGEFIELD':
1871
- return clearInvalidField(state, action.payload);
1872
- default:
1873
- return state;
1874
- }
1875
- }
1876
- function collapseGroup(state, { collapseId, collapsed }) {
1877
- const currentCollapsed = Object.assign({}, state.collapsedGroups);
1878
- if (collapsed) {
1879
- currentCollapsed[collapseId] = true;
1880
- }
1881
- else {
1882
- delete currentCollapsed[collapseId];
1883
- }
1884
- return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
1885
- }
1886
- function changeTab(state, formId, index) {
1887
- const currentTabIndex = Object.assign({}, state.currentTabIndex);
1888
- currentTabIndex[formId] = index;
1889
- return Object.assign(Object.assign({}, state), { currentTabIndex });
1890
- }
1891
- function navigate(state, { dataUnit, limit, backward }) {
1892
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1893
- const recIndex = currentRecordIndex[dataUnit] || 0;
1894
- return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
1895
- }
1896
- function gotoIndex(state, dataUnit, index) {
1897
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1898
- currentRecordIndex[dataUnit] = index;
1899
- return Object.assign(Object.assign({}, state), { currentRecordIndex });
1900
- }
1901
- function insertRecord(state, { dataUnit, insertionIndex }) {
1902
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1903
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
1904
- currentRecordIndex[dataUnit] = insertionIndex;
1905
- newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
1906
- return Object.assign(Object.assign({}, state), { currentRecordIndex,
1907
- newRecordIndex });
1908
- }
1909
- function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
1910
- const changes = Object.assign({}, state.changes);
1911
- const dataUnitChanges = Object.assign({}, changes[dataUnit]);
1912
- const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
1913
- recordChanges[fieldName] = value;
1914
- dataUnitChanges[recordId] = recordChanges;
1915
- changes[dataUnit] = dataUnitChanges;
1916
- const invalidFields = Object.assign({}, state.invalidFields);
1917
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1918
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1919
- delete errorMessages[fieldName];
1920
- dataUnitInvalidRecords[recordId] = errorMessages;
1921
- invalidFields[dataUnit] = dataUnitInvalidRecords;
1922
- return Object.assign(Object.assign({}, state), { changes,
1923
- invalidFields, invalidFieldSelected: undefined });
1924
- }
1925
- function clearEdition(state, { dataUnit, recordsLimit }) {
1926
- const changes = Object.assign({}, state.changes);
1927
- const newRecordIndex = Object.assign({}, state.newRecordIndex);
1928
- const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1929
- delete changes[dataUnit];
1930
- delete newRecordIndex[dataUnit];
1931
- const recIndex = currentRecordIndex[dataUnit] || 0;
1932
- currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
1933
- return Object.assign(Object.assign({}, state), { changes,
1934
- newRecordIndex,
1935
- currentRecordIndex });
1936
- }
1937
- function navigateToInvalid(state, payload) {
1938
- let newState = Object.assign({}, state);
1939
- if (newState.invalidFieldSelected === undefined) {
1940
- newState.invalidFieldSelected = true;
1941
- newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
1942
- newState = changeTab(newState, payload.tabController, payload.tabIndex);
1943
- }
1944
- return newState;
1945
- }
1946
- function dataLoading(state, { dataUnit }) {
1947
- const dataLoading = Object.assign({}, state.dataLoading);
1948
- dataLoading[dataUnit] = true;
1949
- return Object.assign(Object.assign({}, state), { dataLoading });
1950
- }
1951
- function dataLoaded(state, { dataUnit }) {
1952
- const dataLoading = Object.assign({}, state.dataLoading);
1953
- delete dataLoading[dataUnit];
1954
- return Object.assign(Object.assign({}, state), { dataLoading });
1955
- }
1956
- function savingChanges(state, { dataUnit }) {
1957
- const dataLoading = Object.assign({}, state.dataLoading);
1958
- dataLoading[dataUnit] = true;
1959
- return Object.assign(Object.assign({}, state), { dataLoading });
1960
- }
1961
- function changesSaved(state, { dataUnit }) {
1962
- const dataLoading = Object.assign({}, state.dataLoading);
1963
- delete dataLoading[dataUnit];
1964
- return Object.assign(Object.assign({}, state), { dataLoading });
1965
- }
1966
- function removingRecord(state, { dataUnit }) {
1967
- const dataLoading = Object.assign({}, state.dataLoading);
1968
- dataLoading[dataUnit] = true;
1969
- return Object.assign(Object.assign({}, state), { dataLoading });
1970
- }
1971
- function recordRemoved(state, { dataUnit }) {
1972
- const dataLoading = Object.assign({}, state.dataLoading);
1973
- delete dataLoading[dataUnit];
1974
- return Object.assign(Object.assign({}, state), { dataLoading });
1975
- }
1976
- function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
1977
- const invalidFields = Object.assign({}, state.invalidFields);
1978
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1979
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1980
- errorMessages[fieldName] = errorMessage;
1981
- dataUnitInvalidRecords[recordId] = errorMessages;
1982
- invalidFields[dataUnit] = dataUnitInvalidRecords;
1983
- return Object.assign(Object.assign({}, state), { invalidFields });
1984
- }
1985
- function clearAllInvalidFields(state, { dataUnit }) {
1986
- const invalidFields = Object.assign({}, state.invalidFields);
1987
- delete invalidFields[dataUnit];
1988
- return Object.assign(Object.assign({}, state), { invalidFields });
1989
- }
1990
- function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
1991
- const invalidFields = Object.assign({}, state.invalidFields);
1992
- const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1993
- const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1994
- delete errorMessages[fieldName];
1995
- dataUnitInvalidRecords[recordId] = errorMessages;
1996
- invalidFields[dataUnit] = dataUnitInvalidRecords;
1997
- return Object.assign(Object.assign({}, state), { invalidFields });
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 });
1998
2018
  }
1999
2019
 
2000
- function removeHandler(dataUnit) {
2001
- if (confirm("Tem certeza que deseja Remover?")) {
2002
- dataUnit.remove();
2003
- }
2004
- }
2005
- const NavigationBar = ({ dataUnit: du }) => {
2006
- return h("div", { class: "col col--sd-12 align--right" },
2007
- du.cardinality !== '1' ? [
2008
- 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" }),
2009
- 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" }),
2010
- h("ez-button", { title: "Incluir registro", mode: "icon", onClick: () => du.insert(), image: "/themes/default/images/icons/actions-sprite.svg#plus-circle-inverted", class: "button--secondary margin-right--medium" }),
2011
- h("ez-button", { title: "Remover registro", mode: "icon", enabled: du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" })
2012
- ] : null,
2013
- h("ez-button", { title: "Salvar altera\u00E7\u00F5es", mode: "icon", enabled: du.hasChanges(), onClick: () => du.save(), image: "/themes/default/images/icons/actions-sprite.svg#check-circle-inverted", class: "button--secondary margin-right--medium" }),
2014
- h("ez-button", { title: "Descartar altera\u00E7\u00F5es", mode: "icon", enabled: du.hasChanges(), onClick: () => du.cancel(), image: "/themes/default/images/icons/actions-sprite.svg#close-circle-inverted", class: "button--secondary margin-right--medium" }),
2015
- h("ez-button", { title: "Carregar registros", mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }));
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", { label: "Remover", enabled: du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2037
+ buttonProps.addVisible ? h("ez-button", { label: "Adicionar", 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
+ }
2016
2045
  };
2017
2046
 
2018
- var DependencyType;
2019
- (function (DependencyType) {
2020
- DependencyType["SEARCHING"] = "SEARCHING";
2021
- DependencyType["REQUIREMENT"] = "REQUIREMENT";
2022
- DependencyType["VISIBILITY"] = "REQUIREMENT";
2047
+ var DependencyType;
2048
+ (function (DependencyType) {
2049
+ DependencyType["SEARCHING"] = "SEARCHING";
2050
+ DependencyType["REQUIREMENT"] = "REQUIREMENT";
2051
+ DependencyType["VISIBILITY"] = "REQUIREMENT";
2023
2052
  })(DependencyType || (DependencyType = {}));
2024
2053
 
2025
- function scrollToView(forceScroll, elem) {
2026
- if (forceScroll) {
2027
- window.requestAnimationFrame(() => elem.scrollIntoView());
2028
- }
2029
- }
2030
- const Field = ({ dataUnit, source, forceScroll }) => {
2031
- const { name, label, userInterface, properties, required, dependencies } = source;
2032
- const value = dataUnit.getValue(name) || null;
2033
- const loadingData = dataUnit.isLoading();
2034
- const formattedLabel = required ? `* ${label} (obrigatório)` : label;
2035
- const errorMessage = dataUnit.getErrorMessage(name);
2036
- const changeFieldHandler = (newValue) => {
2037
- dataUnit.changeValue(name, newValue);
2038
- };
2039
- switch (userInterface) {
2040
- case 'LONGTEXT':
2041
- return h("div", { class: "col col--sd-12 padding--small" },
2042
- h("ez-text-area", { label: formattedLabel, onInput: evt => changeFieldHandler(evt.target['value']), value: value || '', errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2043
- case 'CHECKBOX':
2044
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2045
- h("ez-check", { onInput: evt => changeFieldHandler(evt.target['value']), ref: elem => scrollToView(forceScroll, elem) }));
2046
- case 'SWITCH':
2047
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2048
- h("div", { class: "row" },
2049
- h("div", { class: "col col--sd-2" },
2050
- h("ez-check", { mode: "switch", value: value === "S", ref: elem => scrollToView(forceScroll, elem) })),
2051
- h("div", { class: "col col--sd-10" },
2052
- h("label", { class: "text text--primary text--medium" }, label))));
2053
- case 'OPTIONSELECTOR':
2054
- const optsObj = JSON.parse(properties.find(prop => prop.name === 'options').value);
2055
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2056
- 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]))));
2057
- case 'SEARCH':
2058
- const context = {};
2059
- properties.forEach(({ name, value }) => {
2060
- context[name] = value;
2061
- });
2062
- let criteriaList = [];
2063
- dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
2064
- var _a;
2065
- if (dependency.type === DependencyType.SEARCHING) {
2066
- if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
2067
- let criteria = {
2068
- expression: dependency.expression,
2069
- paramNames: [...dependency.masterFields],
2070
- paramResolver: name => dataUnit.getValue(name)
2071
- };
2072
- criteriaList.push(criteria);
2073
- }
2074
- }
2075
- });
2076
- if (criteriaList.length > 0) {
2077
- context['CRITERIA'] = criteriaList;
2078
- }
2079
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2080
- h("ez-search", { label: label, onEzChange: (event) => changeFieldHandler(event.target['value']), showvalue: true, value: value, loadexecutor: (argument, callback) => dataUnit.fieldSearchExecutor(argument, context, callback) }));
2081
- case 'DATE':
2082
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2083
- 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) }));
2084
- //IMAGE, FILE, DATE, DATETIME, ELAPSEDTIME, DECIMALNUMBER, INTEGERNUMBER, PASSWORD, MASKEDTEXT, HTML
2085
- default:
2086
- return h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData
2087
- ?
2088
- h("place-holder", null)
2089
- :
2090
- h("ez-text-input", { loading: loadingData, label: formattedLabel, onInput: (event) => changeFieldHandler(event.target['value']), value: value, errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2091
- }
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
+ }
2092
2121
  };
2093
2122
 
2094
- const FieldSet = ({ store, formName, source, dataUnit }) => {
2095
- const { label, fields } = source;
2096
- const fieldSetName = formName + label;
2097
- let isCollapsed = selectIsCollapsedFieldSet(store.getState(), formName + label);
2098
- let fieldToScroll;
2099
- source.fields.forEach((field) => {
2100
- if (fieldToScroll === undefined) {
2101
- const fieldError = dataUnit.getErrorMessage(field.name);
2102
- if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
2103
- fieldToScroll = field.name;
2104
- }
2105
- }
2106
- });
2107
- if (fieldToScroll) {
2108
- isCollapsed = false;
2109
- }
2110
- return h("div", { class: "col col--sd-12 padding--small" },
2111
- h("div", { class: "row margin-top--large" },
2112
- h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
2113
- h("ez-collapsable-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(collapseExpandGroup(fieldSetName, !isCollapsed)) }),
2114
- isCollapsed ? null :
2115
- 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 }))))));
2116
2145
  };
2117
2146
 
2118
- function buildFormItem(source, formName, store, dataUnit) {
2119
- if ("fields" in source) {
2120
- return h(FieldSet, { source: source, store: store, formName: formName, dataUnit: dataUnit });
2121
- }
2122
- const errorMsg = dataUnit.getErrorMessage(source.name);
2123
- const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
2124
- return h(Field, { source: source, dataUnit: dataUnit, forceScroll: forceScroll });
2125
- }
2126
- const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder }) => {
2127
- const selectedTab = selectCurrentTab(store.getState(), parentName);
2128
- const tabs = source.length > 1 ? source.map(form => h("ez-tab", { label: form.label, tabKey: form.name })) : null;
2129
- const { subForms, items, name } = source[selectedTab];
2130
- const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit);
2131
- source[selectedTab].dataUnit = dataUnit;
2132
- const hasSubForms = subForms && subForms.length > 0;
2133
- const changeTabHandler = (index) => {
2134
- store.dispatch(changeTab$1(parentName, index));
2135
- };
2136
- //todos os campos e subformulários precisam estar ligados a um DU
2137
- const currentDU = dataUnit || parentDataUnit;
2138
- return h("div", { class: "form-sheet" },
2139
- tabs ? h("ez-tabselector", { selectedindex: selectedTab, selectedtab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
2140
- dataUnit ? h(NavigationBar, { dataUnit: dataUnit }) : null,
2141
- h("div", { class: "tab__container" },
2142
- items ? items.map(item => buildFormItem(item, name, store, currentDU)) : null,
2143
- 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));
2144
2180
  };
2145
2181
 
2146
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}";
2147
2183
 
2148
- const EzForm = class {
2149
- constructor(hostRef) {
2150
- registerInstance(this, hostRef);
2151
- this._requiredFieldsByDU = {};
2152
- }
2153
- validateRecords(dataUnit, records) {
2154
- const result = { isValid: true, message: '' };
2155
- const reqFields = this._requiredFieldsByDU[dataUnit.name];
2156
- records.forEach(record => {
2157
- reqFields.forEach(field => {
2158
- const recordIndex = record["record__index"];
2159
- const fieldName = field.name;
2160
- const fieldValue = record[fieldName];
2161
- if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
2162
- this._store.dispatch(invalidField$1(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
2163
- result.isValid = false;
2164
- }
2165
- });
2166
- });
2167
- if (!result.isValid) {
2168
- result.message = "Há pelo menos um campo obrigatório não preenchido.";
2169
- }
2170
- return result;
2171
- }
2172
- componentWillRender() {
2173
- if (this._store === undefined) {
2174
- const rootReducer = combineReducers({
2175
- "hist": undoable(formReducer),
2176
- "nonhist": formNonHistoricReducer
2177
- });
2178
- this._store = createStore(rootReducer, applyMiddleware(thunk));
2179
- this._store.subscribe(() => { forceUpdate(this); });
2180
- }
2181
- }
2182
- loadMDFromExecutor(callBack) {
2183
- if (this._loadMetadataFunction) {
2184
- const result = this._loadMetadataFunction();
2185
- if (result) {
2186
- if (result instanceof Promise) {
2187
- result.then(md => {
2188
- callBack(md);
2189
- });
2190
- }
2191
- else {
2192
- callBack(result);
2193
- }
2194
- }
2195
- }
2196
- }
2197
- loadMDFromElement(callBack) {
2198
- const metadata = [];
2199
- Array.from(this._host.children).forEach(elem => {
2200
- if (elem.tagName === "FORM-METADATA") {
2201
- const formMetadata = elem;
2202
- metadata.push(formMetadata.metadata);
2203
- }
2204
- });
2205
- callBack(metadata.length > 0 ? metadata : null);
2206
- }
2207
- updateMetadata(metadata) {
2208
- if (metadata) {
2209
- const processFields = (duName, form, tabController, tabIndex) => {
2210
- var _a;
2211
- let requiredFields = this._requiredFieldsByDU[duName];
2212
- if (requiredFields === undefined) {
2213
- requiredFields = [];
2214
- this._requiredFieldsByDU[duName] = requiredFields;
2215
- }
2216
- form.items.forEach(item => {
2217
- if ("fields" in item) {
2218
- const fSet = item;
2219
- fSet.fields.forEach(f => {
2220
- f.tabControler = tabController;
2221
- f.tabIndex = tabIndex;
2222
- if (f.required) {
2223
- requiredFields.push(f);
2224
- }
2225
- });
2226
- }
2227
- else {
2228
- const f = item;
2229
- f.tabControler = tabController;
2230
- f.tabIndex = tabIndex;
2231
- if (f.required) {
2232
- requiredFields.push(f);
2233
- }
2234
- }
2235
- });
2236
- (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
2237
- const subDU = subForm.dataUnit ? subForm.dataUnit.name : duName;
2238
- processFields(subDU, subForm, form.name, index);
2239
- });
2240
- };
2241
- this.metadata = metadata;
2242
- metadata.map((form, index) => {
2243
- processFields(form.dataUnit.name, form, "__MAIN__FORM__", index);
2244
- });
2245
- this._store.dispatch(formLoad());
2246
- }
2247
- }
2248
- parseExecutor(executor) {
2249
- if (executor) {
2250
- return executor instanceof Function ? executor : eval(executor);
2251
- }
2252
- return null;
2253
- }
2254
- componentDidLoad() {
2255
- this._loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
2256
- this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2257
- this._saveFunction = this.parseExecutor(this.saveexecutor);
2258
- this._removeFunction = this.parseExecutor(this.removeexecutor);
2259
- this._fieldSearchFunction = this.parseExecutor(this.fieldsearchexecutor);
2260
- if (this.metadata) {
2261
- this.updateMetadata(this.metadata);
2262
- }
2263
- else {
2264
- this.loadMDFromElement((md) => this.updateMetadata(md));
2265
- if (!this.metadata) {
2266
- this.loadMDFromExecutor((md) => this.updateMetadata(md));
2267
- }
2268
- }
2269
- }
2270
- buildDataUnit(dataUnit) {
2271
- if (dataUnit) {
2272
- const { name, records, cardinality } = dataUnit;
2273
- if (!(dataUnit instanceof DataUnit)) {
2274
- dataUnit = new DataUnit(name, cardinality);
2275
- if (records) {
2276
- dataUnit.records = records;
2277
- }
2278
- dataUnit.store = this._store;
2279
- dataUnit.loadExecutor = this._loadDataFunction;
2280
- dataUnit.saveExecutor = this._saveFunction;
2281
- dataUnit.removeExecutor = this._removeFunction;
2282
- dataUnit.recordsValidator = this;
2283
- dataUnit.fieldSearchExecutor = this._fieldSearchFunction;
2284
- }
2285
- }
2286
- return dataUnit;
2287
- }
2288
- render() {
2289
- return this.metadata ? h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du) => this.buildDataUnit(du) }) : null;
2290
- }
2291
- get _host() { return getElement(this); }
2292
- };
2184
+ const EzForm = class {
2185
+ constructor(hostRef) {
2186
+ registerInstance(this, hostRef);
2187
+ this._dataUnits = new Map();
2188
+ this._duSources = new Map();
2189
+ this._requiredFieldsByDU = {};
2190
+ }
2191
+ async validate() {
2192
+ for (let i = 0; i < this._duSources.size; i++) {
2193
+ const duName = Array.from(this._duSources.keys())[i];
2194
+ let du = this._dataUnits.get(duName);
2195
+ if (du === undefined) {
2196
+ const source = this._duSources.get(duName);
2197
+ du = this.buildDataUnit(source, source.parentDUName);
2198
+ }
2199
+ if (!du.validateRecords()) {
2200
+ return false;
2201
+ }
2202
+ }
2203
+ return true;
2204
+ }
2205
+ async getChanges() {
2206
+ let allChanges = [];
2207
+ for (let i = 0; i < this._dataUnits.size; i++) {
2208
+ const du = Array.from(this._dataUnits.values())[i];
2209
+ //Só devemos buscar as alterações de DU raiz, pois os sub DUs serão enviados junto.
2210
+ if (!du.parentDU) {
2211
+ const duChanges = du.getChangesToSave();
2212
+ if (duChanges) {
2213
+ allChanges = allChanges.concat(duChanges);
2214
+ }
2215
+ }
2216
+ }
2217
+ return allChanges;
2218
+ }
2219
+ validateRecords(dataUnit, records) {
2220
+ const result = { isValid: true, message: '' };
2221
+ const reqFields = this._requiredFieldsByDU[dataUnit.name];
2222
+ const recordValidator = record => {
2223
+ reqFields.forEach(field => {
2224
+ const recordIndex = record["record__index"];
2225
+ const fieldName = field.name;
2226
+ const fieldValue = record[fieldName];
2227
+ if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
2228
+ this._store.dispatch(invalidField$1(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
2229
+ result.isValid = false;
2230
+ result.message = "Há pelo menos um campo obrigatório não preenchido.";
2231
+ }
2232
+ });
2233
+ };
2234
+ if (records.length == 0) {
2235
+ recordValidator({});
2236
+ }
2237
+ else {
2238
+ records.forEach(recordValidator);
2239
+ }
2240
+ return result;
2241
+ }
2242
+ componentWillRender() {
2243
+ if (this._store === undefined) {
2244
+ const rootReducer = combineReducers({
2245
+ "hist": undoable(formReducer),
2246
+ "nonhist": formNonHistoricReducer
2247
+ });
2248
+ this._store = createStore(rootReducer, applyMiddleware(thunk));
2249
+ this._store.subscribe(() => { forceUpdate(this); });
2250
+ if (this.slavemode) {
2251
+ this._store.dispatch(showHideNavigationButtons("saveVisible", false));
2252
+ this._store.dispatch(showHideNavigationButtons("cancelVisible", false));
2253
+ this._store.dispatch(showHideNavigationButtons("reloadVisible", false));
2254
+ }
2255
+ }
2256
+ }
2257
+ loadMDFromExecutor(callBack) {
2258
+ const loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
2259
+ if (loadMetadataFunction) {
2260
+ const result = loadMetadataFunction();
2261
+ if (result) {
2262
+ if (result instanceof Promise) {
2263
+ result.then(md => {
2264
+ callBack(md);
2265
+ });
2266
+ }
2267
+ else {
2268
+ callBack(result);
2269
+ }
2270
+ }
2271
+ }
2272
+ }
2273
+ loadMDFromElement(callBack) {
2274
+ const metadata = [];
2275
+ Array.from(this._host.children).forEach(elem => {
2276
+ if (elem.tagName === "FORM-METADATA") {
2277
+ const formMetadata = elem;
2278
+ metadata.push(formMetadata.metadata);
2279
+ }
2280
+ });
2281
+ callBack(metadata.length > 0 ? metadata : null);
2282
+ }
2283
+ updateMetadata(metadata) {
2284
+ if (metadata) {
2285
+ const processFields = (duName, form, tabController, tabIndex) => {
2286
+ var _a;
2287
+ let requiredFields = this._requiredFieldsByDU[duName];
2288
+ if (requiredFields === undefined) {
2289
+ requiredFields = [];
2290
+ this._requiredFieldsByDU[duName] = requiredFields;
2291
+ }
2292
+ form.items.forEach(item => {
2293
+ if ("fields" in item) {
2294
+ const fSet = item;
2295
+ fSet.fields.forEach(f => {
2296
+ f.tabControler = tabController;
2297
+ f.tabIndex = tabIndex;
2298
+ if (f.required) {
2299
+ requiredFields.push(f);
2300
+ }
2301
+ });
2302
+ }
2303
+ else {
2304
+ const f = item;
2305
+ f.tabControler = tabController;
2306
+ f.tabIndex = tabIndex;
2307
+ if (f.required) {
2308
+ requiredFields.push(f);
2309
+ }
2310
+ }
2311
+ });
2312
+ (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
2313
+ const subDu = subForm.dataUnit;
2314
+ if (subDu) {
2315
+ this._duSources.set(subDu.name, subDu);
2316
+ subDu.parentDUName = duName;
2317
+ }
2318
+ processFields(subDu ? subDu.name : duName, subForm, form.name, index);
2319
+ });
2320
+ };
2321
+ this.metadata = metadata;
2322
+ metadata.map((form, index) => {
2323
+ const du = form.dataUnit;
2324
+ const duName = du.name;
2325
+ this._duSources.set(duName, du);
2326
+ processFields(duName, form, "__MAIN__FORM__", index);
2327
+ });
2328
+ this._store.dispatch(formLoad());
2329
+ }
2330
+ }
2331
+ parseExecutor(executor) {
2332
+ if (executor) {
2333
+ return executor instanceof Function ? executor : eval(executor);
2334
+ }
2335
+ return null;
2336
+ }
2337
+ componentDidLoad() {
2338
+ if (this.metadata) {
2339
+ this.updateMetadata(this.metadata);
2340
+ }
2341
+ else {
2342
+ this.loadMDFromElement((md) => this.updateMetadata(md));
2343
+ if (!this.metadata) {
2344
+ this.loadMDFromExecutor((md) => this.updateMetadata(md));
2345
+ }
2346
+ }
2347
+ }
2348
+ buildDataUnit(dataUnit, parentDataUnit) {
2349
+ if (dataUnit) {
2350
+ const { name, unitLabel, records, cardinality } = dataUnit;
2351
+ if (!(dataUnit instanceof DataUnit)) {
2352
+ let parent;
2353
+ if (parentDataUnit instanceof DataUnit) {
2354
+ parent = parentDataUnit;
2355
+ }
2356
+ else {
2357
+ parent = this._dataUnits.get(parentDataUnit);
2358
+ }
2359
+ dataUnit = new DataUnit(name, unitLabel, cardinality, parent);
2360
+ this._dataUnits.set(dataUnit.name, dataUnit);
2361
+ if (records) {
2362
+ dataUnit.records = records;
2363
+ }
2364
+ dataUnit.store = this._store;
2365
+ dataUnit.loadExecutor = this.parseExecutor(this.loadexecutor);
2366
+ dataUnit.saveExecutor = this.parseExecutor(this.saveexecutor);
2367
+ dataUnit.removeExecutor = this.parseExecutor(this.removeexecutor);
2368
+ dataUnit.recordsValidator = this;
2369
+ dataUnit.fieldSearchExecutor = this.parseExecutor(this.fieldsearchexecutor);
2370
+ }
2371
+ }
2372
+ return dataUnit;
2373
+ }
2374
+ render() {
2375
+ return this.metadata ? h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du, parentDataUnit) => this.buildDataUnit(du, parentDataUnit) }) : null;
2376
+ }
2377
+ get _host() { return getElement(this); }
2378
+ };
2293
2379
  EzForm.style = ezFormCss;
2294
2380
 
2295
2381
  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}";
2296
2382
 
2297
- const EzIcon = class {
2298
- constructor(hostRef) {
2299
- registerInstance(this, hostRef);
2300
- /*Tamanho do icone*/
2301
- this.size = 'medium';
2302
- }
2303
- render() {
2304
- return (h("svg", { class: this.size, role: "img" }, h("use", { xlinkHref: this.href })));
2305
- }
2306
- };
2383
+ const EzIcon = class {
2384
+ constructor(hostRef) {
2385
+ registerInstance(this, hostRef);
2386
+ /*Tamanho do icone*/
2387
+ this.size = 'medium';
2388
+ }
2389
+ render() {
2390
+ return (h("svg", { class: this.size, role: "img" }, h("use", { xlinkHref: this.href })));
2391
+ }
2392
+ };
2307
2393
  EzIcon.style = ezIconCss;
2308
2394
 
2309
2395
  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%}";
2310
2396
 
2311
- const EzPopover = class {
2312
- constructor(hostRef) {
2313
- registerInstance(this, hostRef);
2314
- this._firstRender = true;
2315
- /**
2316
- * No modo floating = false o popover só se tornará visível
2317
- * quando o método show() for acionado.
2318
- */
2319
- this.autoclose = true;
2320
- /**
2321
- * Offset top do popover em relação ao componente pai
2322
- */
2323
- this.top = '0px';
2324
- /**
2325
- * Offset left do popover em relação ao componente pai
2326
- */
2327
- this.left = '0px';
2328
- /**
2329
- * Offset bottom do popover em relação ao componente pai
2330
- */
2331
- this.bottom = '0px';
2332
- /**
2333
- * Offset right do popover em relação ao componente pai
2334
- */
2335
- this.right = '0px';
2336
- /**
2337
- * Ajusta o comportamento da largura do popover.
2338
- * Opções: "100% e "fit-content" (default)
2339
- */
2340
- this.boxwidth = 'fit-content';
2341
- }
2342
- /**
2343
- * Atualiza a posição do popover em relação ao componente pai.
2344
- */
2345
- async updatePosition(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2346
- const floatingOptions = {
2347
- autoClose: this.autoclose,
2348
- top,
2349
- left,
2350
- bottom,
2351
- right,
2352
- innerClickTest: (_container, node) => {
2353
- if (_container.contains(node)) {
2354
- return true;
2355
- }
2356
- if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2357
- return true;
2358
- }
2359
- //Here: we pass this._box as parameter but we need to change to _host
2360
- //because we need to get the lasChild (inner content to put in slot)
2361
- _container = this._host;
2362
- return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2363
- }
2364
- };
2365
- FloatingManager.updateFloatPosition(this._box, this._container, floatingOptions);
2366
- }
2367
- /**
2368
- * Faz com que o popover seja renderizado na DOM.
2369
- *
2370
- */
2371
- async show(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2372
- const floatingOptions = {
2373
- autoClose: this.autoclose,
2374
- top,
2375
- left,
2376
- bottom,
2377
- right,
2378
- innerClickTest: (_container, node) => {
2379
- if (_container.contains(node)) {
2380
- return true;
2381
- }
2382
- if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2383
- return true;
2384
- }
2385
- // Here: we pass this._box as parameter but we need to change to _host
2386
- // because we need to get the lasChild (inner content to put in slot)
2387
- _container = this._host;
2388
- return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2389
- }
2390
- };
2391
- this._floatingID = FloatingManager.float(this._box, this._container, floatingOptions);
2392
- this.isOpened = true;
2393
- }
2394
- /**
2395
- * Usado no modo floating. Faz com que o componente seja ocultado.
2396
- */
2397
- async hide() {
2398
- if (this._floatingID !== undefined) {
2399
- FloatingManager.close(this._floatingID);
2400
- this._floatingID = undefined;
2401
- this.isOpened = false;
2402
- }
2403
- }
2404
- componentDidRender() {
2405
- if (this._firstRender) {
2406
- this._box.remove();
2407
- this._firstRender = false;
2408
- }
2409
- }
2410
- render() {
2411
- 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)))));
2412
- }
2413
- get _host() { return getElement(this); }
2414
- };
2397
+ const EzPopover = class {
2398
+ constructor(hostRef) {
2399
+ registerInstance(this, hostRef);
2400
+ this._firstRender = true;
2401
+ /**
2402
+ * No modo floating = false o popover só se tornará visível
2403
+ * quando o método show() for acionado.
2404
+ */
2405
+ this.autoclose = true;
2406
+ /**
2407
+ * Offset top do popover em relação ao componente pai
2408
+ */
2409
+ this.top = '0px';
2410
+ /**
2411
+ * Offset left do popover em relação ao componente pai
2412
+ */
2413
+ this.left = '0px';
2414
+ /**
2415
+ * Offset bottom do popover em relação ao componente pai
2416
+ */
2417
+ this.bottom = '0px';
2418
+ /**
2419
+ * Offset right do popover em relação ao componente pai
2420
+ */
2421
+ this.right = '0px';
2422
+ /**
2423
+ * Ajusta o comportamento da largura do popover.
2424
+ * Opções: "100% e "fit-content" (default)
2425
+ */
2426
+ this.boxwidth = 'fit-content';
2427
+ }
2428
+ /**
2429
+ * Atualiza a posição do popover em relação ao componente pai.
2430
+ */
2431
+ async updatePosition(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2432
+ const floatingOptions = {
2433
+ autoClose: this.autoclose,
2434
+ top,
2435
+ left,
2436
+ bottom,
2437
+ right,
2438
+ innerClickTest: (_container, node) => {
2439
+ if (_container.contains(node)) {
2440
+ return true;
2441
+ }
2442
+ if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2443
+ return true;
2444
+ }
2445
+ //Here: we pass this._box as parameter but we need to change to _host
2446
+ //because we need to get the lasChild (inner content to put in slot)
2447
+ _container = this._host;
2448
+ return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2449
+ }
2450
+ };
2451
+ FloatingManager.updateFloatPosition(this._box, this._container, floatingOptions);
2452
+ }
2453
+ /**
2454
+ * Faz com que o popover seja renderizado na DOM.
2455
+ *
2456
+ */
2457
+ async show(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2458
+ const floatingOptions = {
2459
+ autoClose: this.autoclose,
2460
+ top,
2461
+ left,
2462
+ bottom,
2463
+ right,
2464
+ innerClickTest: (_container, node) => {
2465
+ if (_container.contains(node)) {
2466
+ return true;
2467
+ }
2468
+ if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2469
+ return true;
2470
+ }
2471
+ // Here: we pass this._box as parameter but we need to change to _host
2472
+ // because we need to get the lasChild (inner content to put in slot)
2473
+ _container = this._host;
2474
+ return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2475
+ }
2476
+ };
2477
+ this._floatingID = FloatingManager.float(this._box, this._container, floatingOptions);
2478
+ this.isOpened = true;
2479
+ }
2480
+ /**
2481
+ * Usado no modo floating. Faz com que o componente seja ocultado.
2482
+ */
2483
+ async hide() {
2484
+ if (this._floatingID !== undefined) {
2485
+ FloatingManager.close(this._floatingID);
2486
+ this._floatingID = undefined;
2487
+ this.isOpened = false;
2488
+ }
2489
+ }
2490
+ componentDidRender() {
2491
+ if (this._firstRender) {
2492
+ this._box.remove();
2493
+ this._firstRender = false;
2494
+ }
2495
+ }
2496
+ render() {
2497
+ 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)))));
2498
+ }
2499
+ get _host() { return getElement(this); }
2500
+ };
2415
2501
  EzPopover.style = ezPopoverCss;
2416
2502
 
2417
2503
  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)}";
2418
2504
 
2419
- const EzSearch = class {
2420
- constructor(hostRef) {
2421
- registerInstance(this, hostRef);
2422
- this.ezChange = createEvent(this, "ezChange", 7);
2423
- this._options = [];
2424
- this._classSelect = 'list-container--4row';
2425
- /**
2426
- * Deixa o campo disponível ou não para digitação.
2427
- */
2428
- this.enabled = true;
2429
- /**
2430
- * Quantidade máxima de itens guardados no localstorage
2431
- */
2432
- this.qtdHotItems = 6;
2433
- /**
2434
- * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
2435
- */
2436
- this.showvalue = false;
2437
- ///// HOTSEARCH /////
2438
- this.buildId = () => {
2439
- return btoa(`${this.hotsearchid}:${location.pathname}`);
2440
- };
2441
- this.getStorageItems = (key) => {
2442
- let storageValueStr = localStorage.getItem('hotSearch-ez-search:' + key);
2443
- let storageItems = [];
2444
- if (storageValueStr !== null) {
2445
- storageItems = JSON.parse(storageValueStr);
2446
- }
2447
- return storageItems;
2448
- };
2449
- this.orderHotList = (list) => {
2450
- return list.sort((a, b) => {
2451
- let time1 = new Date(a.dtRecent).getTime();
2452
- let time2 = new Date(b.dtRecent).getTime();
2453
- let qtd1 = a.qtd;
2454
- let qtd2 = b.qtd;
2455
- if (time1 < time2)
2456
- return -1;
2457
- if (time1 > time2)
2458
- return 1;
2459
- if (qtd1 > qtd2)
2460
- return -1;
2461
- if (qtd1 < qtd2)
2462
- return 1;
2463
- return 0;
2464
- });
2465
- };
2466
- this.saveStorageItem = (key, value) => {
2467
- if (value == '' || value == undefined)
2468
- return;
2469
- let storageItem = this.getStorageItems(key);
2470
- let element = this.getElement(storageItem, value);
2471
- if (element) {
2472
- element.qtd++;
2473
- element.dtRecent = this.getOnlyDate();
2474
- }
2475
- else {
2476
- if (storageItem.length >= this.qtdHotItems) {
2477
- storageItem = this.orderHotList(storageItem);
2478
- storageItem.splice(-1, 1);
2479
- }
2480
- storageItem.push({
2481
- description: value,
2482
- qtd: 1,
2483
- dtRecent: this.getOnlyDate()
2484
- });
2485
- }
2486
- localStorage.setItem('hotSearch-ez-search:' + key, JSON.stringify(storageItem));
2487
- return storageItem;
2488
- };
2489
- this.adjustOptions = (arrayOptions) => {
2490
- let optionsTemp = [];
2491
- arrayOptions.map(el => {
2492
- optionsTemp.push({
2493
- value: el.value,
2494
- label: el.label,
2495
- ajustedValue: el.value === null || el.value === undefined || el.value === '' ? el.label : el.value,
2496
- });
2497
- });
2498
- return optionsTemp;
2499
- };
2500
- this.sortArrayOptions = (array, propname) => {
2501
- const sortedArray = array.sort(function (a, b) {
2502
- if (a[propname] < b[propname]) {
2503
- return -1;
2504
- }
2505
- if (a[propname] > b[propname]) {
2506
- return 1;
2507
- }
2508
- return 0;
2509
- });
2510
- return sortedArray;
2511
- };
2512
- }
2513
- valueChanged() {
2514
- var _a;
2515
- if (this.value) {
2516
- this.ezChange.emit({ value: this.value, label: (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value });
2517
- let key = this.buildId();
2518
- this.saveStorageItem(key, this.value);
2519
- }
2520
- }
2521
- //ajustar ao fim do teste
2522
- onInputTeste() {
2523
- if (this._inputElem) {
2524
- this.handleChange();
2525
- }
2526
- }
2527
- getElement(storageItem, value) {
2528
- return storageItem.find(e => e.description === value);
2529
- }
2530
- getOnlyDate() {
2531
- let dt = new Date();
2532
- dt.setHours(0);
2533
- dt.setMinutes(0);
2534
- dt.setSeconds(0);
2535
- dt.setUTCMilliseconds(0);
2536
- return dt.toString();
2537
- }
2538
- onInputChange(ev) {
2539
- const el = ev.target;
2540
- let key = this.buildId();
2541
- this.saveStorageItem(key, el.value);
2542
- }
2543
- buildDataList() {
2544
- try {
2545
- if (this.hotsearchid === undefined) {
2546
- return;
2547
- }
2548
- let key = this.buildId();
2549
- let optionsArray = [];
2550
- this._options = [];
2551
- if (this.getStorageItems(key).length > 0) {
2552
- this.orderHotList(this.getStorageItems(key))
2553
- .forEach((el) => {
2554
- optionsArray.push({
2555
- value: el.description,
2556
- label: el.description,
2557
- });
2558
- });
2559
- this._options = [{ value: '', label: '' }].concat(optionsArray);
2560
- this.buildOptions();
2561
- }
2562
- }
2563
- catch (err) {
2564
- this.errormessage = err;
2565
- }
2566
- }
2567
- ///// EVENT HANDLERS
2568
- buildItem(opt, index) {
2569
- const className = index === this._preSelection ? "--li--preselected" : "";
2570
- 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);
2571
- }
2572
- highlightMatch(label) {
2573
- var _a;
2574
- const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
2575
- if ((_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) {
2576
- const criteriaLength = this._inputElem.value.length;
2577
- const matchStart = label.toUpperCase().indexOf(this._inputElem.value);
2578
- if (matchStart > -1) {
2579
- const strLabelStart = label.substr(0, matchStart);
2580
- const strLabelEnd = label.substr(matchStart + criteriaLength);
2581
- const strMatch = label.substr(matchStart, criteriaLength);
2582
- return (h("span", { class: spanClassName }, strLabelStart, h("strong", null, strMatch), strLabelEnd));
2583
- }
2584
- }
2585
- return (h("span", { class: spanClassName }, label));
2586
- }
2587
- showOptions() {
2588
- if (this.enabled) {
2589
- const top = this._inputElem.errormessage ? '0px' : '-17px';
2590
- this._popover.show(top);
2591
- }
2592
- }
2593
- nextOption() {
2594
- this.showOptions();
2595
- this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
2596
- this.scrollToOption(this._visibleOptions[this._preSelection]);
2597
- }
2598
- previousOption() {
2599
- this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
2600
- this.scrollToOption(this._visibleOptions[this._preSelection]);
2601
- }
2602
- scrollToOption(opt) {
2603
- const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
2604
- if (liElem) {
2605
- const parent = liElem.parentElement;
2606
- const parentRect = parent.getBoundingClientRect();
2607
- const itemRect = liElem.getBoundingClientRect();
2608
- if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
2609
- liElem.scrollIntoView();
2610
- }
2611
- }
2612
- }
2613
- selectCurrentOption() {
2614
- if (this._preSelection !== undefined) {
2615
- this.selectOption(this._visibleOptions[this._preSelection]);
2616
- this._preSelection = undefined;
2617
- }
2618
- }
2619
- selectOption(opt) {
2620
- this._popover.hide();
2621
- this.value = opt === null || opt === void 0 ? void 0 : opt.ajustedValue;
2622
- this._inputElem.value = opt.value;
2623
- //Definir com a equipe de design se vai ser utilizado dessa forma.
2624
- // this._inputElem.value = opt.value? opt.value + " - "+ opt?.label: '';
2625
- }
2626
- keyDownHandler(event) {
2627
- switch (event.key) {
2628
- case "ArrowDown":
2629
- this.nextOption();
2630
- break;
2631
- case "ArrowUp":
2632
- this.previousOption();
2633
- break;
2634
- case "Enter":
2635
- this.selectCurrentOption();
2636
- break;
2637
- }
2638
- event.stopPropagation();
2639
- }
2640
- handleSetValueByOption(ev) {
2641
- this._popover.hide();
2642
- const spanEl = ev.target;
2643
- const sourceElement = ev.composedPath()[0];
2644
- let li;
2645
- if (sourceElement.tagName === 'SPAN') {
2646
- li = spanEl.parentNode;
2647
- }
2648
- else {
2649
- li = spanEl.parentNode.parentNode;
2650
- }
2651
- this.value = li.id.split('_')[1];
2652
- this._inputElem.value = li.accessKey;
2653
- this.ezChange.emit();
2654
- }
2655
- handleChange() {
2656
- if (this._changeDeboucing) {
2657
- window.clearTimeout(this._changeDeboucing);
2658
- }
2659
- this._changeDeboucing = window.setTimeout(() => {
2660
- var _a, _b;
2661
- if (((_b = (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) <= 0) {
2662
- return;
2663
- }
2664
- /* save tip on localStorage */
2665
- let key = this.buildId();
2666
- this.saveStorageItem(key, this._inputElem.value);
2667
- /* load data */
2668
- if (this.loadexecutor) {
2669
- this._loadDataFunction(this._inputElem.value, (serverData) => { this.populateOptions(serverData); });
2670
- }
2671
- }, 200);
2672
- }
2673
- normalizeResult(data) {
2674
- let options = [];
2675
- if (data instanceof Array) {
2676
- options = data;
2677
- }
2678
- else {
2679
- if (data instanceof Object) {
2680
- for (var key in data) {
2681
- let newOption = { value: '', label: '' };
2682
- newOption.value = key;
2683
- newOption.label = data[key];
2684
- options.push(newOption);
2685
- }
2686
- }
2687
- }
2688
- this._options = [{ value: '', label: '' }].concat(options);
2689
- this.buildOptions();
2690
- }
2691
- populateOptions(serverData) {
2692
- if (serverData instanceof Promise) {
2693
- serverData.then(this.normalizeResult);
2694
- }
2695
- else {
2696
- this.normalizeResult(serverData);
2697
- }
2698
- }
2699
- buildOptions() {
2700
- var _a;
2701
- this._visibleOptions = [];
2702
- this._visibleOptions = this.adjustOptions(this._options);
2703
- this._visibleOptions = this.sortArrayOptions(this._visibleOptions, 'label');
2704
- if (this._visibleOptions.length > 0) {
2705
- (_a = this._divElem) === null || _a === void 0 ? void 0 : _a.classList.add(this._classSelect);
2706
- this.showOptions();
2707
- }
2708
- }
2709
- setClassForSpanLabel() {
2710
- if (!this.showvalue) {
2711
- return '--li__spanlabel--full-width';
2712
- }
2713
- else {
2714
- return '--li__spanlabel';
2715
- }
2716
- }
2717
- handleFocus() {
2718
- if (this._inputElem && (!this._inputElem.value || this._inputElem.value.length === 0)) {
2719
- this.buildDataList();
2720
- }
2721
- }
2722
- parseExecutor(executor) {
2723
- if (executor) {
2724
- return executor instanceof Function ? executor : eval(executor);
2725
- }
2726
- return null;
2727
- }
2728
- componentDidLoad() {
2729
- if (this.value && this.value.length > 0) {
2730
- this._inputElem.value = this.value;
2731
- }
2732
- this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2733
- }
2734
- render() {
2735
- var _a;
2736
- 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))))));
2737
- }
2738
- ;
2739
- get el() { return getElement(this); }
2740
- static get watchers() { return {
2741
- "value": ["valueChanged"]
2742
- }; }
2743
- };
2505
+ const EzSearch = class {
2506
+ constructor(hostRef) {
2507
+ registerInstance(this, hostRef);
2508
+ this.ezChange = createEvent(this, "ezChange", 7);
2509
+ this._options = [];
2510
+ this._classSelect = 'list-container--4row';
2511
+ /**
2512
+ * Deixa o campo disponível ou não para digitação.
2513
+ */
2514
+ this.enabled = true;
2515
+ /**
2516
+ * Quantidade máxima de itens guardados no localstorage
2517
+ */
2518
+ this.qtdHotItems = 6;
2519
+ /**
2520
+ * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
2521
+ */
2522
+ this.showvalue = false;
2523
+ ///// HOTSEARCH /////
2524
+ this.buildId = () => {
2525
+ return btoa(`${this.hotsearchid}:${location.pathname}`);
2526
+ };
2527
+ this.getStorageItems = (key) => {
2528
+ let storageValueStr = localStorage.getItem('hotSearch-ez-search:' + key);
2529
+ let storageItems = [];
2530
+ if (storageValueStr !== null) {
2531
+ storageItems = JSON.parse(storageValueStr);
2532
+ }
2533
+ return storageItems;
2534
+ };
2535
+ this.orderHotList = (list) => {
2536
+ return list.sort((a, b) => {
2537
+ let time1 = new Date(a.dtRecent).getTime();
2538
+ let time2 = new Date(b.dtRecent).getTime();
2539
+ let qtd1 = a.qtd;
2540
+ let qtd2 = b.qtd;
2541
+ if (time1 < time2)
2542
+ return -1;
2543
+ if (time1 > time2)
2544
+ return 1;
2545
+ if (qtd1 > qtd2)
2546
+ return -1;
2547
+ if (qtd1 < qtd2)
2548
+ return 1;
2549
+ return 0;
2550
+ });
2551
+ };
2552
+ this.saveStorageItem = (key, value) => {
2553
+ if (value == '' || value == undefined)
2554
+ return;
2555
+ let storageItem = this.getStorageItems(key);
2556
+ let element = this.getElement(storageItem, value);
2557
+ if (element) {
2558
+ element.qtd++;
2559
+ element.dtRecent = this.getOnlyDate();
2560
+ }
2561
+ else {
2562
+ if (storageItem.length >= this.qtdHotItems) {
2563
+ storageItem = this.orderHotList(storageItem);
2564
+ storageItem.splice(-1, 1);
2565
+ }
2566
+ storageItem.push({
2567
+ description: value,
2568
+ qtd: 1,
2569
+ dtRecent: this.getOnlyDate()
2570
+ });
2571
+ }
2572
+ localStorage.setItem('hotSearch-ez-search:' + key, JSON.stringify(storageItem));
2573
+ return storageItem;
2574
+ };
2575
+ this.adjustOptions = (arrayOptions) => {
2576
+ let optionsTemp = [];
2577
+ arrayOptions.map(el => {
2578
+ optionsTemp.push({
2579
+ value: el.value,
2580
+ label: el.label,
2581
+ ajustedValue: el.value === null || el.value === undefined || el.value === '' ? el.label : el.value,
2582
+ });
2583
+ });
2584
+ return optionsTemp;
2585
+ };
2586
+ this.sortArrayOptions = (array, propname) => {
2587
+ const sortedArray = array.sort(function (a, b) {
2588
+ if (a[propname] < b[propname]) {
2589
+ return -1;
2590
+ }
2591
+ if (a[propname] > b[propname]) {
2592
+ return 1;
2593
+ }
2594
+ return 0;
2595
+ });
2596
+ return sortedArray;
2597
+ };
2598
+ }
2599
+ valueChanged() {
2600
+ var _a;
2601
+ if (this.value) {
2602
+ this.ezChange.emit({ value: this.value, label: (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value });
2603
+ let key = this.buildId();
2604
+ this.saveStorageItem(key, this.value);
2605
+ }
2606
+ }
2607
+ //ajustar ao fim do teste
2608
+ onInputTeste() {
2609
+ if (this._inputElem) {
2610
+ this.handleChange();
2611
+ }
2612
+ }
2613
+ getElement(storageItem, value) {
2614
+ return storageItem.find(e => e.description === value);
2615
+ }
2616
+ getOnlyDate() {
2617
+ let dt = new Date();
2618
+ dt.setHours(0);
2619
+ dt.setMinutes(0);
2620
+ dt.setSeconds(0);
2621
+ dt.setUTCMilliseconds(0);
2622
+ return dt.toString();
2623
+ }
2624
+ onInputChange(ev) {
2625
+ const el = ev.target;
2626
+ let key = this.buildId();
2627
+ this.saveStorageItem(key, el.value);
2628
+ }
2629
+ buildDataList() {
2630
+ try {
2631
+ if (this.hotsearchid === undefined) {
2632
+ return;
2633
+ }
2634
+ let key = this.buildId();
2635
+ let optionsArray = [];
2636
+ this._options = [];
2637
+ if (this.getStorageItems(key).length > 0) {
2638
+ this.orderHotList(this.getStorageItems(key))
2639
+ .forEach((el) => {
2640
+ optionsArray.push({
2641
+ value: el.description,
2642
+ label: el.description,
2643
+ });
2644
+ });
2645
+ this._options = [{ value: '', label: '' }].concat(optionsArray);
2646
+ this.buildOptions();
2647
+ }
2648
+ }
2649
+ catch (err) {
2650
+ this.errormessage = err;
2651
+ }
2652
+ }
2653
+ ///// EVENT HANDLERS
2654
+ buildItem(opt, index) {
2655
+ const className = index === this._preSelection ? "--li--preselected" : "";
2656
+ 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);
2657
+ }
2658
+ highlightMatch(label) {
2659
+ var _a;
2660
+ const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
2661
+ if ((_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) {
2662
+ const criteriaLength = this._inputElem.value.length;
2663
+ const matchStart = label.toUpperCase().indexOf(this._inputElem.value);
2664
+ if (matchStart > -1) {
2665
+ const strLabelStart = label.substr(0, matchStart);
2666
+ const strLabelEnd = label.substr(matchStart + criteriaLength);
2667
+ const strMatch = label.substr(matchStart, criteriaLength);
2668
+ return (h("span", { class: spanClassName }, strLabelStart, h("strong", null, strMatch), strLabelEnd));
2669
+ }
2670
+ }
2671
+ return (h("span", { class: spanClassName }, label));
2672
+ }
2673
+ showOptions() {
2674
+ if (this.enabled) {
2675
+ const top = this._inputElem.errormessage ? '0px' : '-17px';
2676
+ this._popover.show(top);
2677
+ }
2678
+ }
2679
+ nextOption() {
2680
+ this.showOptions();
2681
+ this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
2682
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
2683
+ }
2684
+ previousOption() {
2685
+ this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
2686
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
2687
+ }
2688
+ scrollToOption(opt) {
2689
+ const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
2690
+ if (liElem) {
2691
+ const parent = liElem.parentElement;
2692
+ const parentRect = parent.getBoundingClientRect();
2693
+ const itemRect = liElem.getBoundingClientRect();
2694
+ if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
2695
+ liElem.scrollIntoView();
2696
+ }
2697
+ }
2698
+ }
2699
+ selectCurrentOption() {
2700
+ if (this._preSelection !== undefined) {
2701
+ this.selectOption(this._visibleOptions[this._preSelection]);
2702
+ this._preSelection = undefined;
2703
+ }
2704
+ }
2705
+ selectOption(opt) {
2706
+ this._popover.hide();
2707
+ this.value = opt === null || opt === void 0 ? void 0 : opt.ajustedValue;
2708
+ this._inputElem.value = opt.value;
2709
+ //Definir com a equipe de design se vai ser utilizado dessa forma.
2710
+ // this._inputElem.value = opt.value? opt.value + " - "+ opt?.label: '';
2711
+ }
2712
+ keyDownHandler(event) {
2713
+ switch (event.key) {
2714
+ case "ArrowDown":
2715
+ this.nextOption();
2716
+ break;
2717
+ case "ArrowUp":
2718
+ this.previousOption();
2719
+ break;
2720
+ case "Enter":
2721
+ this.selectCurrentOption();
2722
+ break;
2723
+ }
2724
+ event.stopPropagation();
2725
+ }
2726
+ handleSetValueByOption(ev) {
2727
+ this._popover.hide();
2728
+ const spanEl = ev.target;
2729
+ const sourceElement = ev.composedPath()[0];
2730
+ let li;
2731
+ if (sourceElement.tagName === 'SPAN') {
2732
+ li = spanEl.parentNode;
2733
+ }
2734
+ else {
2735
+ li = spanEl.parentNode.parentNode;
2736
+ }
2737
+ this.value = li.id.split('_')[1];
2738
+ this._inputElem.value = li.accessKey;
2739
+ this.ezChange.emit();
2740
+ }
2741
+ handleChange() {
2742
+ if (this._changeDeboucing) {
2743
+ window.clearTimeout(this._changeDeboucing);
2744
+ }
2745
+ this._changeDeboucing = window.setTimeout(() => {
2746
+ var _a, _b;
2747
+ if (((_b = (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) <= 0) {
2748
+ return;
2749
+ }
2750
+ /* save tip on localStorage */
2751
+ let key = this.buildId();
2752
+ this.saveStorageItem(key, this._inputElem.value);
2753
+ /* load data */
2754
+ if (this.loadexecutor) {
2755
+ this._loadDataFunction(this._inputElem.value, (serverData) => { this.populateOptions(serverData); });
2756
+ }
2757
+ }, 200);
2758
+ }
2759
+ normalizeResult(data) {
2760
+ let options = [];
2761
+ if (data instanceof Array) {
2762
+ options = data;
2763
+ }
2764
+ else {
2765
+ if (data instanceof Object) {
2766
+ for (var key in data) {
2767
+ let newOption = { value: '', label: '' };
2768
+ newOption.value = key;
2769
+ newOption.label = data[key];
2770
+ options.push(newOption);
2771
+ }
2772
+ }
2773
+ }
2774
+ this._options = [{ value: '', label: '' }].concat(options);
2775
+ this.buildOptions();
2776
+ }
2777
+ populateOptions(serverData) {
2778
+ if (serverData instanceof Promise) {
2779
+ serverData.then(this.normalizeResult);
2780
+ }
2781
+ else {
2782
+ this.normalizeResult(serverData);
2783
+ }
2784
+ }
2785
+ buildOptions() {
2786
+ var _a;
2787
+ this._visibleOptions = [];
2788
+ this._visibleOptions = this.adjustOptions(this._options);
2789
+ this._visibleOptions = this.sortArrayOptions(this._visibleOptions, 'label');
2790
+ if (this._visibleOptions.length > 0) {
2791
+ (_a = this._divElem) === null || _a === void 0 ? void 0 : _a.classList.add(this._classSelect);
2792
+ this.showOptions();
2793
+ }
2794
+ }
2795
+ setClassForSpanLabel() {
2796
+ if (!this.showvalue) {
2797
+ return '--li__spanlabel--full-width';
2798
+ }
2799
+ else {
2800
+ return '--li__spanlabel';
2801
+ }
2802
+ }
2803
+ handleFocus() {
2804
+ if (this._inputElem && (!this._inputElem.value || this._inputElem.value.length === 0)) {
2805
+ this.buildDataList();
2806
+ }
2807
+ }
2808
+ parseExecutor(executor) {
2809
+ if (executor) {
2810
+ return executor instanceof Function ? executor : eval(executor);
2811
+ }
2812
+ return null;
2813
+ }
2814
+ componentDidLoad() {
2815
+ if (this.value && this.value.length > 0) {
2816
+ this._inputElem.value = this.value;
2817
+ }
2818
+ this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2819
+ }
2820
+ render() {
2821
+ var _a;
2822
+ 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))))));
2823
+ }
2824
+ ;
2825
+ get el() { return getElement(this); }
2826
+ static get watchers() { return {
2827
+ "value": ["valueChanged"]
2828
+ }; }
2829
+ };
2744
2830
  EzSearch.style = ezSearchCss;
2745
2831
 
2746
2832
  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}";
2747
2833
 
2748
- const EzTabselector = class {
2749
- constructor(hostRef) {
2750
- registerInstance(this, hostRef);
2751
- this.change = createEvent(this, "change", 7);
2752
- this.setFoucusedParam = (ev) => {
2753
- if (ev.key === 'Enter') {
2754
- this.selectedindex = this.foucusedindex;
2755
- this.foucusedindex = undefined;
2756
- this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2757
- this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2758
- ev.preventDefault();
2759
- this.setFocusedTab(this.selectedindex);
2760
- }
2761
- else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
2762
- let operator = undefined;
2763
- if (ev.key === 'ArrowLeft') {
2764
- operator = false;
2765
- }
2766
- else if (ev.key === 'ArrowRight') {
2767
- operator = true;
2768
- }
2769
- else {
2770
- return;
2771
- }
2772
- if (this.foucusedindex === undefined) {
2773
- if (operator === false) {
2774
- this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
2775
- }
2776
- else {
2777
- this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
2778
- }
2779
- }
2780
- else {
2781
- if (operator === false) {
2782
- this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
2783
- }
2784
- else {
2785
- this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
2786
- }
2787
- }
2788
- if (parseInt(this.foucusedindex) < 0) {
2789
- this.foucusedindex = '0';
2790
- }
2791
- else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
2792
- this.foucusedindex = (this._processedTabs.length - 1).toString();
2793
- }
2794
- this.setFoucusedBtn(true, this.foucusedindex);
2795
- this.setFocusedTab(this.foucusedindex);
2796
- this.change.emit();
2797
- }
2798
- else if (ev.key === 'Tab' || ev.key === 'Escape') {
2799
- this.foucusedindex = undefined;
2800
- this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2801
- this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2802
- ev.preventDefault();
2803
- this.setFocusedTab(this.selectedindex);
2804
- }
2805
- // this.setFocusedTab();
2806
- };
2807
- }
2808
- handleTabClick(tab, index) {
2809
- this.selectedindex = index.toString();
2810
- this.foucusedindex = undefined;
2811
- this.selectedtab = tab;
2812
- this.change.emit();
2813
- this.setFoucusedBtn(false, this.selectedindex);
2814
- }
2815
- componentWillRender() {
2816
- if (!this._processedTabs) {
2817
- this._processedTabs = [];
2818
- if (this.tabs) {
2819
- this.tabs.split(',').forEach((label) => {
2820
- label = label.trim();
2821
- this._processedTabs.push(new Tab(label, label));
2822
- });
2823
- }
2824
- this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
2825
- const tabKey = elem.getAttribute('tabKey');
2826
- const label = elem.getAttribute('label');
2827
- const t = new Tab(label, tabKey);
2828
- const content = elem.firstChild;
2829
- if (content) {
2830
- content.setAttribute('slot', 'tab' + this._processedTabs.length);
2831
- this._hostElem.appendChild(content);
2832
- }
2833
- this._processedTabs.push(t);
2834
- });
2835
- }
2836
- }
2837
- handleSlotChange(ev) {
2838
- const slot = ev.target;
2839
- const content = slot.assignedElements()[0];
2840
- if (content) {
2841
- content.style.marginLeft = "6px";
2842
- }
2843
- }
2844
- scrollBackward() {
2845
- const container = this._scrollContainer;
2846
- if (container) {
2847
- container.scrollLeft -= container.clientWidth;
2848
- }
2849
- }
2850
- scrollFoward() {
2851
- const container = this._scrollContainer;
2852
- if (container) {
2853
- let lastTab = null;
2854
- container.querySelectorAll('.tab').forEach((tab) => {
2855
- if (tab.getBoundingClientRect().right < container.clientWidth) {
2856
- lastTab = tab;
2857
- }
2858
- });
2859
- container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
2860
- }
2861
- }
2862
- componentDidRender() {
2863
- this.updateScroll();
2864
- }
2865
- updateScroll() {
2866
- const container = this._scrollContainer;
2867
- if (container) {
2868
- const { scrollWidth, clientWidth, scrollLeft } = container;
2869
- const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
2870
- this._startHidden = container.scrollLeft > 0;
2871
- this._endHidden = remainingScroll > 0;
2872
- if (this._startHidden) {
2873
- this._backwardButton.classList.remove('hidden');
2874
- }
2875
- else {
2876
- this._backwardButton.classList.add('hidden');
2877
- }
2878
- if (this._endHidden) {
2879
- this._forwardButton.classList.remove('hidden');
2880
- }
2881
- else {
2882
- this._forwardButton.classList.add('hidden');
2883
- }
2884
- const classNames = ['', 'startHidden', 'endHidden', 'midle'];
2885
- const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
2886
- classNames.forEach((name) => {
2887
- if (name !== currentClass && container.classList.contains(name)) {
2888
- container.classList.remove(name);
2889
- }
2890
- });
2891
- if (currentClass && !container.classList.contains(currentClass)) {
2892
- container.classList.add(currentClass);
2893
- }
2894
- }
2895
- }
2896
- domScrollHandler() {
2897
- window.clearTimeout(this._scrollCallBack);
2898
- this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
2899
- }
2900
- setFocusedTab(index) {
2901
- window.clearTimeout(this._scrollCallBackTeste);
2902
- this._scrollCallBackTeste = window.setTimeout(() => {
2903
- const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
2904
- console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
2905
- console.log('tabtoscroll', tabtoscroll);
2906
- tabtoscroll.scrollIntoView();
2907
- }, 200);
2908
- }
2909
- getTextWidth(text) {
2910
- if (this._textMesurement === undefined) {
2911
- this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
2912
- }
2913
- const context = this._textMesurement.getContext("2d");
2914
- context.font = '14px Sora, Algerian';
2915
- return Math.min(220, 24 + context.measureText(text).width) + 'px';
2916
- }
2917
- ;
2918
- setFoucusedBtn(visible, paramater) {
2919
- const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
2920
- tabsButtons.forEach((el) => {
2921
- el.classList.remove('is-focused');
2922
- if (el.id === 'tab' + paramater && visible) {
2923
- el.classList.add('is-focused');
2924
- }
2925
- });
2926
- }
2927
- render() {
2928
- 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,
2929
- // onScroll={() => this.domScrollHandler()}
2930
- onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index) => {
2931
- const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
2932
- const tabId = "tab" + index;
2933
- const isSelected = index === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
2934
- if (isSelected) {
2935
- this.selectedtab = tab.tabKey;
2936
- this.selectedindex = index.toString();
2937
- }
2938
- 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); } }));
2939
- })), h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
2940
- }
2941
- get _hostElem() { return getElement(this); }
2942
- };
2943
- class Tab {
2944
- constructor(label, tabKey) {
2945
- this.label = label;
2946
- this.tabKey = tabKey;
2947
- }
2948
- }
2834
+ const EzTabselector = class {
2835
+ constructor(hostRef) {
2836
+ registerInstance(this, hostRef);
2837
+ this.change = createEvent(this, "change", 7);
2838
+ this.setFoucusedParam = (ev) => {
2839
+ if (ev.key === 'Enter') {
2840
+ this.selectedindex = this.foucusedindex;
2841
+ this.foucusedindex = undefined;
2842
+ this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2843
+ this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2844
+ ev.preventDefault();
2845
+ this.setFocusedTab(this.selectedindex);
2846
+ }
2847
+ else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
2848
+ let operator = undefined;
2849
+ if (ev.key === 'ArrowLeft') {
2850
+ operator = false;
2851
+ }
2852
+ else if (ev.key === 'ArrowRight') {
2853
+ operator = true;
2854
+ }
2855
+ else {
2856
+ return;
2857
+ }
2858
+ if (this.foucusedindex === undefined) {
2859
+ if (operator === false) {
2860
+ this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
2861
+ }
2862
+ else {
2863
+ this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
2864
+ }
2865
+ }
2866
+ else {
2867
+ if (operator === false) {
2868
+ this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
2869
+ }
2870
+ else {
2871
+ this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
2872
+ }
2873
+ }
2874
+ if (parseInt(this.foucusedindex) < 0) {
2875
+ this.foucusedindex = '0';
2876
+ }
2877
+ else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
2878
+ this.foucusedindex = (this._processedTabs.length - 1).toString();
2879
+ }
2880
+ this.setFoucusedBtn(true, this.foucusedindex);
2881
+ this.setFocusedTab(this.foucusedindex);
2882
+ this.change.emit();
2883
+ }
2884
+ else if (ev.key === 'Tab' || ev.key === 'Escape') {
2885
+ this.foucusedindex = undefined;
2886
+ this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2887
+ this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2888
+ ev.preventDefault();
2889
+ this.setFocusedTab(this.selectedindex);
2890
+ }
2891
+ // this.setFocusedTab();
2892
+ };
2893
+ }
2894
+ handleTabClick(tab, index) {
2895
+ this.selectedindex = index.toString();
2896
+ this.foucusedindex = undefined;
2897
+ this.selectedtab = tab;
2898
+ this.change.emit();
2899
+ this.setFoucusedBtn(false, this.selectedindex);
2900
+ }
2901
+ componentWillRender() {
2902
+ if (!this._processedTabs) {
2903
+ this._processedTabs = [];
2904
+ if (this.tabs) {
2905
+ this.tabs.split(',').forEach((label) => {
2906
+ label = label.trim();
2907
+ this._processedTabs.push(new Tab(label, label));
2908
+ });
2909
+ }
2910
+ this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
2911
+ const tabKey = elem.getAttribute('tabKey');
2912
+ const label = elem.getAttribute('label');
2913
+ const t = new Tab(label, tabKey);
2914
+ const content = elem.firstChild;
2915
+ if (content) {
2916
+ content.setAttribute('slot', 'tab' + this._processedTabs.length);
2917
+ this._hostElem.appendChild(content);
2918
+ }
2919
+ this._processedTabs.push(t);
2920
+ });
2921
+ }
2922
+ }
2923
+ handleSlotChange(ev) {
2924
+ const slot = ev.target;
2925
+ const content = slot.assignedElements()[0];
2926
+ if (content) {
2927
+ content.style.marginLeft = "6px";
2928
+ }
2929
+ }
2930
+ scrollBackward() {
2931
+ const container = this._scrollContainer;
2932
+ if (container) {
2933
+ container.scrollLeft -= container.clientWidth;
2934
+ }
2935
+ }
2936
+ scrollFoward() {
2937
+ const container = this._scrollContainer;
2938
+ if (container) {
2939
+ let lastTab = null;
2940
+ container.querySelectorAll('.tab').forEach((tab) => {
2941
+ if (tab.getBoundingClientRect().right < container.clientWidth) {
2942
+ lastTab = tab;
2943
+ }
2944
+ });
2945
+ container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
2946
+ }
2947
+ }
2948
+ componentDidRender() {
2949
+ this.updateScroll();
2950
+ }
2951
+ updateScroll() {
2952
+ const container = this._scrollContainer;
2953
+ if (container) {
2954
+ const { scrollWidth, clientWidth, scrollLeft } = container;
2955
+ const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
2956
+ this._startHidden = container.scrollLeft > 0;
2957
+ this._endHidden = remainingScroll > 0;
2958
+ if (this._startHidden) {
2959
+ this._backwardButton.classList.remove('hidden');
2960
+ }
2961
+ else {
2962
+ this._backwardButton.classList.add('hidden');
2963
+ }
2964
+ if (this._endHidden) {
2965
+ this._forwardButton.classList.remove('hidden');
2966
+ }
2967
+ else {
2968
+ this._forwardButton.classList.add('hidden');
2969
+ }
2970
+ const classNames = ['', 'startHidden', 'endHidden', 'midle'];
2971
+ const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
2972
+ classNames.forEach((name) => {
2973
+ if (name !== currentClass && container.classList.contains(name)) {
2974
+ container.classList.remove(name);
2975
+ }
2976
+ });
2977
+ if (currentClass && !container.classList.contains(currentClass)) {
2978
+ container.classList.add(currentClass);
2979
+ }
2980
+ }
2981
+ }
2982
+ domScrollHandler() {
2983
+ window.clearTimeout(this._scrollCallBack);
2984
+ this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
2985
+ }
2986
+ setFocusedTab(index) {
2987
+ window.clearTimeout(this._scrollCallBackTeste);
2988
+ this._scrollCallBackTeste = window.setTimeout(() => {
2989
+ const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
2990
+ console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
2991
+ console.log('tabtoscroll', tabtoscroll);
2992
+ tabtoscroll.scrollIntoView();
2993
+ }, 200);
2994
+ }
2995
+ getTextWidth(text) {
2996
+ if (this._textMesurement === undefined) {
2997
+ this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
2998
+ }
2999
+ const context = this._textMesurement.getContext("2d");
3000
+ context.font = '14px Sora, Algerian';
3001
+ return Math.min(220, 24 + context.measureText(text).width) + 'px';
3002
+ }
3003
+ ;
3004
+ setFoucusedBtn(visible, paramater) {
3005
+ const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
3006
+ tabsButtons.forEach((el) => {
3007
+ el.classList.remove('is-focused');
3008
+ if (el.id === 'tab' + paramater && visible) {
3009
+ el.classList.add('is-focused');
3010
+ }
3011
+ });
3012
+ }
3013
+ render() {
3014
+ 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,
3015
+ // onScroll={() => this.domScrollHandler()}
3016
+ onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index) => {
3017
+ const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
3018
+ const tabId = "tab" + index;
3019
+ const isSelected = index === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
3020
+ if (isSelected) {
3021
+ this.selectedtab = tab.tabKey;
3022
+ this.selectedindex = index.toString();
3023
+ }
3024
+ 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); } }));
3025
+ })), h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
3026
+ }
3027
+ get _hostElem() { return getElement(this); }
3028
+ };
3029
+ class Tab {
3030
+ constructor(label, tabKey) {
3031
+ this.label = label;
3032
+ this.tabKey = tabKey;
3033
+ }
3034
+ }
2949
3035
  EzTabselector.style = ezTabselectorCss;
2950
3036
 
2951
3037
  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)}";
2952
3038
 
2953
- const EzTextArea = class {
2954
- constructor(hostRef) {
2955
- registerInstance(this, hostRef);
2956
- this.ezChange = createEvent(this, "ezChange", 7);
2957
- /**
2958
- * Deixa o campo disponível ou não para digitação.
2959
- */
2960
- this.enabled = true;
2961
- /**
2962
- * Ajusta o numero de linhas e consequentemente o height do textarea. Valor default: 4
2963
- */
2964
- this.rows = 4;
2965
- }
2966
- showError() {
2967
- const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
2968
- if (hasError) {
2969
- this._inputElem.classList.add('hasError');
2970
- this._messageBoxElem.classList.add('hasError');
2971
- }
2972
- else {
2973
- this._inputElem.classList.remove('hasError');
2974
- this._messageBoxElem.classList.remove('hasError');
2975
- }
2976
- }
2977
- updateInputValue() {
2978
- this._inputElem.value = this.value;
2979
- this.handleChange();
2980
- this.adjustFloatingLabel();
2981
- }
2982
- adjustFloatingLabel() {
2983
- if (this.label) {
2984
- if (!this._inputElem.classList.contains("input--with--label")) {
2985
- this._inputElem.classList.add("input--with--label");
2986
- }
2987
- const hasValue = this.value && this.value.toString().length > 0;
2988
- const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
2989
- if (hasValue || this.isFocused()) {
2990
- if (!containsFloatedClass) {
2991
- this._labelElem.classList.add("textarea__label--floated");
2992
- }
2993
- }
2994
- else {
2995
- if (containsFloatedClass) {
2996
- this._labelElem.classList.remove("textarea__label--floated");
2997
- }
2998
- }
2999
- }
3000
- }
3001
- isFocused() {
3002
- return this._hostElement.shadowRoot.activeElement !== null;
3003
- }
3004
- //---------------------------------------------
3005
- // Public methods
3006
- //---------------------------------------------
3007
- /**
3008
- * Faz o foco no componente de input
3009
- */
3010
- async setFocus() {
3011
- this._inputElem.focus();
3012
- }
3013
- /**
3014
- * Remove o foco no componente de input
3015
- */
3016
- async setBlur() {
3017
- this._inputElem.blur();
3018
- }
3019
- //---------------------------------------------
3020
- // Event handlers
3021
- //---------------------------------------------
3022
- handleFocusout() {
3023
- this.adjustFloatingLabel();
3024
- }
3025
- handleChange() {
3026
- this.value = this._inputElem.value;
3027
- }
3028
- handleFocus() {
3029
- if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
3030
- this._labelElem.classList.add("textarea__label--floated");
3031
- }
3032
- }
3033
- //---------------------------------------------
3034
- // Lifecycle web component
3035
- //---------------------------------------------
3036
- componentDidLoad() {
3037
- this.showError();
3038
- this.adjustFloatingLabel();
3039
- }
3040
- render() {
3041
- return (h(Host, null, this.label ?
3042
- 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)
3043
- : 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)));
3044
- }
3045
- get _hostElement() { return getElement(this); }
3046
- static get watchers() { return {
3047
- "errormessage": ["showError"],
3048
- "value": ["updateInputValue"]
3049
- }; }
3050
- };
3039
+ const EzTextArea = class {
3040
+ constructor(hostRef) {
3041
+ registerInstance(this, hostRef);
3042
+ this.ezChange = createEvent(this, "ezChange", 7);
3043
+ /**
3044
+ * Deixa o campo disponível ou não para digitação.
3045
+ */
3046
+ this.enabled = true;
3047
+ /**
3048
+ * Ajusta o numero de linhas e consequentemente o height do textarea. Valor default: 4
3049
+ */
3050
+ this.rows = 4;
3051
+ }
3052
+ showError() {
3053
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3054
+ if (hasError) {
3055
+ this._inputElem.classList.add('hasError');
3056
+ this._messageBoxElem.classList.add('hasError');
3057
+ }
3058
+ else {
3059
+ this._inputElem.classList.remove('hasError');
3060
+ this._messageBoxElem.classList.remove('hasError');
3061
+ }
3062
+ }
3063
+ updateInputValue() {
3064
+ this._inputElem.value = this.value;
3065
+ this.handleChange();
3066
+ this.adjustFloatingLabel();
3067
+ }
3068
+ adjustFloatingLabel() {
3069
+ if (this.label) {
3070
+ if (!this._inputElem.classList.contains("input--with--label")) {
3071
+ this._inputElem.classList.add("input--with--label");
3072
+ }
3073
+ const hasValue = this.value && this.value.toString().length > 0;
3074
+ const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
3075
+ if (hasValue || this.isFocused()) {
3076
+ if (!containsFloatedClass) {
3077
+ this._labelElem.classList.add("textarea__label--floated");
3078
+ }
3079
+ }
3080
+ else {
3081
+ if (containsFloatedClass) {
3082
+ this._labelElem.classList.remove("textarea__label--floated");
3083
+ }
3084
+ }
3085
+ }
3086
+ }
3087
+ isFocused() {
3088
+ return this._hostElement.shadowRoot.activeElement !== null;
3089
+ }
3090
+ //---------------------------------------------
3091
+ // Public methods
3092
+ //---------------------------------------------
3093
+ /**
3094
+ * Faz o foco no componente de input
3095
+ */
3096
+ async setFocus() {
3097
+ this._inputElem.focus();
3098
+ }
3099
+ /**
3100
+ * Remove o foco no componente de input
3101
+ */
3102
+ async setBlur() {
3103
+ this._inputElem.blur();
3104
+ }
3105
+ //---------------------------------------------
3106
+ // Event handlers
3107
+ //---------------------------------------------
3108
+ handleFocusout() {
3109
+ this.adjustFloatingLabel();
3110
+ }
3111
+ handleChange() {
3112
+ this.value = this._inputElem.value;
3113
+ }
3114
+ handleFocus() {
3115
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
3116
+ this._labelElem.classList.add("textarea__label--floated");
3117
+ }
3118
+ }
3119
+ //---------------------------------------------
3120
+ // Lifecycle web component
3121
+ //---------------------------------------------
3122
+ componentDidLoad() {
3123
+ this.showError();
3124
+ this.adjustFloatingLabel();
3125
+ }
3126
+ render() {
3127
+ return (h(Host, null, this.label ?
3128
+ 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)
3129
+ : 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)));
3130
+ }
3131
+ get _hostElement() { return getElement(this); }
3132
+ static get watchers() { return {
3133
+ "errormessage": ["showError"],
3134
+ "value": ["updateInputValue"]
3135
+ }; }
3136
+ };
3051
3137
  EzTextArea.style = ezTextAreaCss;
3052
3138
 
3053
- function isValidNumber(strValue) {
3054
- return strValue && /^-?\d*[.,]?\d*$/.test(strValue);
3139
+ function isValidNumber(strValue) {
3140
+ return strValue && /^-?\d*[.,]?\d*$/.test(strValue);
3055
3141
  }
3056
3142
 
3057
3143
  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}";
3058
3144
 
3059
- const EzTextInput = class {
3060
- constructor(hostRef) {
3061
- registerInstance(this, hostRef);
3062
- this.ezChange = createEvent(this, "ezChange", 7);
3063
- /**
3064
- * Deixa o campo disponível ou não para digitação.
3065
- */
3066
- this.enabled = true;
3067
- }
3068
- showError() {
3069
- const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3070
- if (hasError) {
3071
- this._inputElem.classList.add('hasError');
3072
- this._messageBoxElem.classList.add('hasError');
3073
- }
3074
- else {
3075
- this._inputElem.classList.remove('hasError');
3076
- this._messageBoxElem.classList.remove('hasError');
3077
- }
3078
- }
3079
- prepareMask() {
3080
- if (this.mask) {
3081
- if (this._maskFormatter == undefined) {
3082
- this._maskFormatter = new MaskFormatter(this.mask);
3083
- }
3084
- else {
3085
- this._maskFormatter.mask = this.mask;
3086
- }
3087
- }
3088
- }
3089
- updateInputValue() {
3090
- this._inputElem.value = this.value;
3091
- this.handleChange();
3092
- this.ezChange.emit();
3093
- this.adjustFloatingLabel();
3094
- }
3095
- adjustFloatingLabel() {
3096
- if (this.label) {
3097
- if (!this._inputElem.classList.contains("input--with--label")) {
3098
- this._inputElem.classList.add("input--with--label");
3099
- }
3100
- const hasValue = this.value && this.value.toString().length > 0;
3101
- const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
3102
- if (hasValue || this.isFocused()) {
3103
- if (!containsFloatedClass) {
3104
- this._labelElem.classList.add("input__label--floated");
3105
- }
3106
- }
3107
- else {
3108
- if (containsFloatedClass) {
3109
- this._labelElem.classList.remove("input__label--floated");
3110
- }
3111
- }
3112
- }
3113
- }
3114
- isFocused() {
3115
- return this._hostElement.shadowRoot.activeElement !== null;
3116
- }
3117
- //---------------------------------------------
3118
- // Public methods
3119
- //---------------------------------------------
3120
- /**
3121
- * Faz o foco no componente de input
3122
- */
3123
- async setFocus() {
3124
- this._inputElem.focus();
3125
- }
3126
- /**
3127
- * Remove o foco no componente de input
3128
- */
3129
- async setBlur() {
3130
- this._inputElem.blur();
3131
- }
3132
- //---------------------------------------------
3133
- // Event handlers
3134
- //---------------------------------------------
3135
- handleFocusout() {
3136
- const value = this._inputElem.value;
3137
- if (value && this._maskFormatter) {
3138
- try {
3139
- this._inputElem.value = this._maskFormatter.format(value);
3140
- }
3141
- catch (e) {
3142
- this.errormessage = e.message;
3143
- }
3144
- }
3145
- this.value = this._inputElem.value;
3146
- this.adjustFloatingLabel();
3147
- }
3148
- isValidValue(value) {
3149
- if (this.onlynumber) {
3150
- return value == "" || isValidNumber(value);
3151
- }
3152
- if (this.restrict) {
3153
- return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
3154
- }
3155
- return true;
3156
- }
3157
- handleChange() {
3158
- if (!this._inputElem) {
3159
- return;
3160
- }
3161
- const value = this._inputElem.value;
3162
- if (this.isValidValue(value)) {
3163
- this._lastValidValue = value;
3164
- }
3165
- else {
3166
- this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
3167
- }
3168
- this.value = this._inputElem.value;
3169
- }
3170
- handleSlotChange(ev) {
3171
- const slot = ev.target;
3172
- const content = slot.assignedElements()[0];
3173
- if (content) {
3174
- content.style.position = "absolute";
3175
- content.style.display = "flex";
3176
- content.style.alignItems = "center";
3177
- content.style.justifyContent = "center";
3178
- content.style.overflow = "hidden";
3179
- content.style.top = "0px";
3180
- content.style.width = "var(--it__icon--width)";
3181
- content.style.height = "var(--it--height)";
3182
- if (slot.name == "leftIcon") {
3183
- content.style.left = "0px";
3184
- content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
3185
- this._inputElem.classList.add('icon--left');
3186
- if (this._labelElem) {
3187
- this._labelElem.classList.add('input__label--left');
3188
- }
3189
- }
3190
- else if (slot.name == "rightIcon") {
3191
- content.style.right = "0px";
3192
- content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
3193
- this._inputElem.classList.add('icon--right');
3194
- if (this._labelElem) {
3195
- this._labelElem.classList.add('input__label--right');
3196
- }
3197
- }
3198
- }
3199
- this.showError();
3200
- }
3201
- doFocus() {
3202
- if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
3203
- this._labelElem.classList.add("input__label--floated");
3204
- }
3205
- }
3206
- //---------------------------------------------
3207
- // Lifecycle web component
3208
- //---------------------------------------------
3209
- componentDidLoad() {
3210
- if (this.onlynumber) {
3211
- this._inputElem.classList.add('text--right');
3212
- }
3213
- this.showError();
3214
- this.prepareMask();
3215
- this.adjustFloatingLabel();
3216
- }
3217
- componentWillLoad() {
3218
- this.prepareMask();
3219
- if (this.value) {
3220
- if (this._maskFormatter) {
3221
- try {
3222
- this.value = this._maskFormatter.format(this.value);
3223
- }
3224
- catch (e) {
3225
- this.errormessage = e.message;
3226
- }
3227
- }
3228
- if (!this.isValidValue(this.value)) {
3229
- this._lastValidValue = "";
3230
- this.value = "";
3231
- }
3232
- }
3233
- }
3234
- render() {
3235
- return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
3236
- 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)
3237
- : 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)));
3238
- }
3239
- get _hostElement() { return getElement(this); }
3240
- static get watchers() { return {
3241
- "errormessage": ["showError"],
3242
- "mask": ["prepareMask"],
3243
- "value": ["updateInputValue"]
3244
- }; }
3245
- };
3145
+ const EzTextInput = class {
3146
+ constructor(hostRef) {
3147
+ registerInstance(this, hostRef);
3148
+ this.ezChange = createEvent(this, "ezChange", 7);
3149
+ /**
3150
+ * Deixa o campo disponível ou não para digitação.
3151
+ */
3152
+ this.enabled = true;
3153
+ }
3154
+ showError() {
3155
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3156
+ if (hasError) {
3157
+ this._inputElem.classList.add('hasError');
3158
+ this._messageBoxElem.classList.add('hasError');
3159
+ }
3160
+ else {
3161
+ this._inputElem.classList.remove('hasError');
3162
+ this._messageBoxElem.classList.remove('hasError');
3163
+ }
3164
+ }
3165
+ prepareMask() {
3166
+ if (this.mask) {
3167
+ if (this._maskFormatter == undefined) {
3168
+ this._maskFormatter = new MaskFormatter(this.mask);
3169
+ }
3170
+ else {
3171
+ this._maskFormatter.mask = this.mask;
3172
+ }
3173
+ }
3174
+ }
3175
+ updateInputValue() {
3176
+ this._inputElem.value = this.value;
3177
+ this.handleChange();
3178
+ this.ezChange.emit();
3179
+ this.adjustFloatingLabel();
3180
+ }
3181
+ adjustFloatingLabel() {
3182
+ if (this.label) {
3183
+ if (!this._inputElem.classList.contains("input--with--label")) {
3184
+ this._inputElem.classList.add("input--with--label");
3185
+ }
3186
+ const hasValue = this.value && this.value.toString().length > 0;
3187
+ const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
3188
+ if (hasValue || this.isFocused()) {
3189
+ if (!containsFloatedClass) {
3190
+ this._labelElem.classList.add("input__label--floated");
3191
+ }
3192
+ }
3193
+ else {
3194
+ if (containsFloatedClass) {
3195
+ this._labelElem.classList.remove("input__label--floated");
3196
+ }
3197
+ }
3198
+ }
3199
+ }
3200
+ isFocused() {
3201
+ return this._hostElement.shadowRoot.activeElement !== null;
3202
+ }
3203
+ //---------------------------------------------
3204
+ // Public methods
3205
+ //---------------------------------------------
3206
+ /**
3207
+ * Faz o foco no componente de input
3208
+ */
3209
+ async setFocus() {
3210
+ this._inputElem.focus();
3211
+ }
3212
+ /**
3213
+ * Remove o foco no componente de input
3214
+ */
3215
+ async setBlur() {
3216
+ this._inputElem.blur();
3217
+ }
3218
+ //---------------------------------------------
3219
+ // Event handlers
3220
+ //---------------------------------------------
3221
+ handleFocusout() {
3222
+ const value = this._inputElem.value;
3223
+ if (value && this._maskFormatter) {
3224
+ try {
3225
+ this._inputElem.value = this._maskFormatter.format(value);
3226
+ }
3227
+ catch (e) {
3228
+ this.errormessage = e.message;
3229
+ }
3230
+ }
3231
+ this.value = this._inputElem.value;
3232
+ this.adjustFloatingLabel();
3233
+ }
3234
+ isValidValue(value) {
3235
+ if (this.onlynumber) {
3236
+ return value == "" || isValidNumber(value);
3237
+ }
3238
+ if (this.restrict) {
3239
+ return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
3240
+ }
3241
+ return true;
3242
+ }
3243
+ handleChange() {
3244
+ if (!this._inputElem) {
3245
+ return;
3246
+ }
3247
+ const value = this._inputElem.value;
3248
+ if (this.isValidValue(value)) {
3249
+ this._lastValidValue = value;
3250
+ }
3251
+ else {
3252
+ this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
3253
+ }
3254
+ this.value = this._inputElem.value;
3255
+ }
3256
+ handleSlotChange(ev) {
3257
+ const slot = ev.target;
3258
+ const content = slot.assignedElements()[0];
3259
+ if (content) {
3260
+ content.style.position = "absolute";
3261
+ content.style.display = "flex";
3262
+ content.style.alignItems = "center";
3263
+ content.style.justifyContent = "center";
3264
+ content.style.overflow = "hidden";
3265
+ content.style.top = "0px";
3266
+ content.style.width = "var(--it__icon--width)";
3267
+ content.style.height = "var(--it--height)";
3268
+ if (slot.name == "leftIcon") {
3269
+ content.style.left = "0px";
3270
+ content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
3271
+ this._inputElem.classList.add('icon--left');
3272
+ if (this._labelElem) {
3273
+ this._labelElem.classList.add('input__label--left');
3274
+ }
3275
+ }
3276
+ else if (slot.name == "rightIcon") {
3277
+ content.style.right = "0px";
3278
+ content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
3279
+ this._inputElem.classList.add('icon--right');
3280
+ if (this._labelElem) {
3281
+ this._labelElem.classList.add('input__label--right');
3282
+ }
3283
+ }
3284
+ }
3285
+ this.showError();
3286
+ }
3287
+ doFocus() {
3288
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
3289
+ this._labelElem.classList.add("input__label--floated");
3290
+ }
3291
+ }
3292
+ //---------------------------------------------
3293
+ // Lifecycle web component
3294
+ //---------------------------------------------
3295
+ componentDidLoad() {
3296
+ if (this.onlynumber) {
3297
+ this._inputElem.classList.add('text--right');
3298
+ }
3299
+ this.showError();
3300
+ this.prepareMask();
3301
+ this.adjustFloatingLabel();
3302
+ }
3303
+ componentWillLoad() {
3304
+ this.prepareMask();
3305
+ if (this.value) {
3306
+ if (this._maskFormatter) {
3307
+ try {
3308
+ this.value = this._maskFormatter.format(this.value);
3309
+ }
3310
+ catch (e) {
3311
+ this.errormessage = e.message;
3312
+ }
3313
+ }
3314
+ if (!this.isValidValue(this.value)) {
3315
+ this._lastValidValue = "";
3316
+ this.value = "";
3317
+ }
3318
+ }
3319
+ }
3320
+ render() {
3321
+ return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
3322
+ 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)
3323
+ : 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)));
3324
+ }
3325
+ get _hostElement() { return getElement(this); }
3326
+ static get watchers() { return {
3327
+ "errormessage": ["showError"],
3328
+ "mask": ["prepareMask"],
3329
+ "value": ["updateInputValue"]
3330
+ }; }
3331
+ };
3246
3332
  EzTextInput.style = ezTextInputCss;
3247
3333
 
3248
3334
  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}}";
3249
3335
 
3250
- const PlaceHolder = class {
3251
- constructor(hostRef) {
3252
- registerInstance(this, hostRef);
3253
- }
3254
- render() {
3255
- return h(Host, null);
3256
- }
3257
- };
3336
+ const PlaceHolder = class {
3337
+ constructor(hostRef) {
3338
+ registerInstance(this, hostRef);
3339
+ }
3340
+ render() {
3341
+ return h(Host, null);
3342
+ }
3343
+ };
3258
3344
  PlaceHolder.style = placeHolderCss;
3259
3345
 
3260
3346
  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 };