@sankhyalabs/ezui 1.1.4 → 1.1.8

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 (186) hide show
  1. package/README.md +72 -72
  2. package/dist/{ezui/DataUnit-285bec19.js → cjs/DataUnit-28b290cb.js} +382 -369
  3. package/dist/{ezui/index-919090de.js → cjs/RequestMetadata-2cd01e8a.js} +4 -383
  4. package/dist/cjs/ez-action-chip.cjs.entry.js +52 -0
  5. package/dist/cjs/ez-button_14.cjs.entry.js +3341 -0
  6. package/dist/cjs/ez-label-chip.cjs.entry.js +131 -0
  7. package/dist/cjs/ez-modal.cjs.entry.js +115 -0
  8. package/dist/cjs/ez-number-input.cjs.entry.js +248 -0
  9. package/dist/cjs/ez-time-input.cjs.entry.js +180 -0
  10. package/dist/cjs/ezui.cjs.js +19 -0
  11. package/dist/cjs/form-metadata.cjs.entry.js +74 -0
  12. package/dist/cjs/index-9403fe8f.js +1322 -0
  13. package/dist/cjs/index.cjs.js +2 -0
  14. package/dist/cjs/loader.cjs.js +21 -0
  15. package/dist/collection/collection-manifest.json +31 -0
  16. package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -0
  17. package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -0
  18. package/dist/collection/components/ez-button/ez-button.css +94 -0
  19. package/dist/collection/components/ez-button/ez-button.js +125 -0
  20. package/dist/collection/components/ez-calendar/ez-calendar.css +210 -0
  21. package/dist/collection/components/ez-calendar/ez-calendar.js +215 -0
  22. package/dist/collection/components/ez-check/ez-check.css +266 -0
  23. package/dist/collection/components/ez-check/ez-check.js +168 -0
  24. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +68 -0
  25. package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -0
  26. package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -0
  27. package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -0
  28. package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -0
  29. package/dist/collection/components/ez-date-input/ez-date-input.css +39 -0
  30. package/dist/collection/components/ez-date-input/ez-date-input.js +172 -0
  31. package/dist/collection/components/ez-form/ez-form.css +19 -0
  32. package/dist/collection/components/ez-form/ez-form.js +368 -0
  33. package/dist/collection/components/ez-form/store/Form.actions.js +132 -0
  34. package/dist/collection/components/ez-form/store/Form.reducer.js +194 -0
  35. package/dist/collection/components/ez-form/store/Form.selectors.js +44 -0
  36. package/dist/collection/components/ez-form/subcomponents/DataUnit.js +207 -0
  37. package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -0
  38. package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +24 -0
  39. package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -0
  40. package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -0
  41. package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -0
  42. package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -0
  43. package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -0
  44. package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -0
  45. package/dist/collection/components/ez-icon/ez-icon.css +37 -0
  46. package/dist/collection/components/ez-icon/ez-icon.js +56 -0
  47. package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -0
  48. package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -0
  49. package/dist/collection/components/ez-modal/ez-modal.css +87 -0
  50. package/dist/collection/components/ez-modal/ez-modal.js +224 -0
  51. package/dist/collection/components/ez-number-input/ez-number-input.css +144 -0
  52. package/dist/collection/components/ez-number-input/ez-number-input.js +465 -0
  53. package/dist/collection/components/ez-popover/ez-popover.css +39 -0
  54. package/dist/collection/components/ez-popover/ez-popover.js +323 -0
  55. package/dist/collection/components/ez-search/ez-search.css +296 -0
  56. package/dist/{ezui/ez-search.entry.js → collection/components/ez-search/ez-search.js} +527 -334
  57. package/dist/collection/components/ez-tabselector/ez-tabselector.css +126 -0
  58. package/dist/{ezui/ez-tabselector.entry.js → collection/components/ez-tabselector/ez-tabselector.js} +283 -209
  59. package/dist/collection/components/ez-text-area/ez-text-area.css +140 -0
  60. package/dist/collection/components/ez-text-area/ez-text-area.js +267 -0
  61. package/dist/collection/components/ez-text-input/ez-text-input.css +170 -0
  62. package/dist/collection/components/ez-text-input/ez-text-input.js +395 -0
  63. package/dist/collection/components/ez-time-input/ez-time-input.css +155 -0
  64. package/dist/collection/components/ez-time-input/ez-time-input.js +326 -0
  65. package/dist/collection/index.js +1 -0
  66. package/dist/collection/servidor.js +101 -0
  67. package/dist/collection/utils/FloatingManager.js +16 -0
  68. package/dist/collection/utils/utils.js +6 -0
  69. package/dist/custom-elements/index.js +5071 -0
  70. package/dist/esm/DataUnit-69e518fa.js +378 -0
  71. package/dist/esm/RequestMetadata-c265c9d5.js +527 -0
  72. package/dist/{ezui → esm}/ez-action-chip.entry.js +42 -42
  73. package/dist/esm/ez-button_14.entry.js +3324 -0
  74. package/dist/{ezui → esm}/ez-label-chip.entry.js +121 -121
  75. package/dist/{ezui → esm}/ez-modal.entry.js +105 -96
  76. package/dist/{ezui → esm}/ez-number-input.entry.js +238 -238
  77. package/dist/{ezui → esm}/ez-time-input.entry.js +170 -170
  78. package/dist/esm/ezui.js +17 -0
  79. package/dist/{ezui → esm}/form-metadata.entry.js +66 -66
  80. package/dist/esm/index-95bb3fd9.js +1293 -0
  81. package/dist/esm/index.js +1 -0
  82. package/dist/esm/loader.js +17 -0
  83. package/dist/esm/polyfills/core-js.js +11 -0
  84. package/dist/esm/polyfills/css-shim.js +1 -0
  85. package/dist/esm/polyfills/dom.js +79 -0
  86. package/dist/esm/polyfills/es5-html-element.js +1 -0
  87. package/dist/esm/polyfills/index.js +34 -0
  88. package/dist/esm/polyfills/system.js +6 -0
  89. package/dist/ezui/ezui.esm.js +1 -122
  90. package/dist/ezui/index.esm.js +0 -1
  91. package/dist/ezui/p-10ef58b3.js +1 -0
  92. package/dist/ezui/p-185c57f4.js +1 -0
  93. package/dist/ezui/p-22b82efb.entry.js +1 -0
  94. package/dist/ezui/p-77fdb4fd.entry.js +1 -0
  95. package/dist/ezui/p-9dfccb16.js +1 -0
  96. package/dist/ezui/p-b0974f4f.entry.js +1 -0
  97. package/dist/ezui/p-db11c600.entry.js +1 -0
  98. package/dist/ezui/p-dd4331b7.entry.js +1 -0
  99. package/dist/ezui/p-f6fd31ab.entry.js +1 -0
  100. package/dist/ezui/p-fa260f22.entry.js +1 -0
  101. package/dist/index.cjs.js +1 -0
  102. package/dist/index.js +1 -0
  103. package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
  104. package/dist/types/components/ez-button/ez-button.d.ts +20 -20
  105. package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
  106. package/dist/types/components/ez-check/ez-check.d.ts +32 -32
  107. package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
  108. package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
  109. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
  110. package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
  111. package/dist/types/components/ez-form/ez-form.d.ts +31 -27
  112. package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -104
  113. package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -11
  114. package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -13
  115. package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +55 -48
  116. package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
  117. package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
  118. package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
  119. package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
  120. package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
  121. package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
  122. package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -7
  123. package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
  124. package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
  125. package/dist/types/components/ez-modal/ez-modal.d.ts +32 -26
  126. package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
  127. package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
  128. package/dist/types/components/ez-search/ez-search.d.ts +95 -95
  129. package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
  130. package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
  131. package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
  132. package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
  133. package/dist/types/components.d.ts +8 -0
  134. package/dist/types/index.d.ts +1 -1
  135. package/dist/types/utils/utils.d.ts +2 -2
  136. package/loader/cdn.js +3 -0
  137. package/loader/index.cjs.js +3 -0
  138. package/loader/index.d.ts +13 -0
  139. package/loader/index.es2017.js +3 -0
  140. package/loader/index.js +4 -0
  141. package/loader/package.json +10 -0
  142. package/package.json +114 -114
  143. package/react/components.d.ts +22 -0
  144. package/react/components.js +25 -0
  145. package/react/components.js.map +1 -0
  146. package/react/react-component-lib/createComponent.d.ts +10 -0
  147. package/react/react-component-lib/createComponent.js +59 -0
  148. package/react/react-component-lib/createComponent.js.map +1 -0
  149. package/react/react-component-lib/createOverlayComponent.d.ts +20 -0
  150. package/react/react-component-lib/createOverlayComponent.js +89 -0
  151. package/react/react-component-lib/createOverlayComponent.js.map +1 -0
  152. package/react/react-component-lib/index.d.ts +2 -0
  153. package/react/react-component-lib/index.js +3 -0
  154. package/react/react-component-lib/index.js.map +1 -0
  155. package/react/react-component-lib/interfaces.d.ts +29 -0
  156. package/react/react-component-lib/interfaces.js +1 -0
  157. package/react/react-component-lib/interfaces.js.map +1 -0
  158. package/react/react-component-lib/utils/attachProps.d.ts +12 -0
  159. package/react/react-component-lib/utils/attachProps.js +96 -0
  160. package/react/react-component-lib/utils/attachProps.js.map +1 -0
  161. package/react/react-component-lib/utils/case.d.ts +2 -0
  162. package/react/react-component-lib/utils/case.js +7 -0
  163. package/react/react-component-lib/utils/case.js.map +1 -0
  164. package/react/react-component-lib/utils/dev.d.ts +2 -0
  165. package/react/react-component-lib/utils/dev.js +13 -0
  166. package/react/react-component-lib/utils/dev.js.map +1 -0
  167. package/react/react-component-lib/utils/index.d.ts +7 -0
  168. package/react/react-component-lib/utils/index.js +21 -0
  169. package/react/react-component-lib/utils/index.js.map +1 -0
  170. package/dist/ezui/app-globals-0f993ce5.js +0 -3
  171. package/dist/ezui/css-shim-003e9264.js +0 -4
  172. package/dist/ezui/dom-1b195079.js +0 -73
  173. package/dist/ezui/ez-button.entry.js +0 -47
  174. package/dist/ezui/ez-calendar.entry.js +0 -102
  175. package/dist/ezui/ez-check.entry.js +0 -62
  176. package/dist/ezui/ez-collapsable-box.entry.js +0 -32
  177. package/dist/ezui/ez-combo-box.entry.js +0 -181
  178. package/dist/ezui/ez-date-input.entry.js +0 -77
  179. package/dist/ezui/ez-form.entry.js +0 -1907
  180. package/dist/ezui/ez-icon.entry.js +0 -17
  181. package/dist/ezui/ez-popover.entry.js +0 -112
  182. package/dist/ezui/ez-text-area.entry.js +0 -105
  183. package/dist/ezui/ez-text-input.entry.js +0 -202
  184. package/dist/ezui/index-39044be2.js +0 -2832
  185. package/dist/ezui/place-holder.entry.js +0 -15
  186. package/dist/ezui/shadow-css-c1ad5fdc.js +0 -383
@@ -0,0 +1,3341 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-9403fe8f.js');
6
+ const RequestMetadata = require('./RequestMetadata-2cd01e8a.js');
7
+ const DataUnit = require('./DataUnit-28b290cb.js');
8
+
9
+ const ezButtonCss = ":host{--bt--min-width:100px;--bt--height:42px;--bt__icon--width:18px;--bt__inline__icon--padding:12px;--bt--padding-top:var(--space--medium, 12px);--bt--padding-bottom:var(--space--medium, 12px);--bt--padding-right:var(--space--large, 24px);--bt--padding-left:var(--space--large, 24px);--bt--color:var(--text--inverted, #FFF);--bt--font-size:var(--text--medium, 14px);--bt--font-family:var(--font-pattern, Arial);--bt--font-weight:var(--text-weight--large);--bt--background-color:var(--color--primary, #c0c0c0);--bt--border-radius:var(--border--radius-large, 12px);--bt--border:none;--bt--hover--background-color:var(--color--primary-700, var(--bt--background-color));--bt--disabled--color:var(--color--disable-primary, var(--bt--color));--bt--disabled--background-color:var(--color--disabled, var(--bt--background-color));--bt--focus--border:var(--bt--border);--bt--focus--box-shadow:none}button{display:flex;align-items:center;justify-content:center;margin:0;cursor:pointer;transition:background-color 0.2s linear;min-width:var(--bt--min-width);height:var(--bt--height);font-family:var(--bt--font-family);font-size:var(--bt--font-size);font-weight:var(--bt--font-weight);padding:var(--bt--padding-top) var(--bt--padding-right) var(--bt--padding-bottom) var(--bt--padding-left);border-radius:var(--bt--border-radius);background-color:var(--bt--background-color);color:var(--bt--color);fill:var(--bt--color);border:var(--bt--border)}button:hover{background-color:var(--bt--hover--background-color)}button:focus{outline:none;border:var(--bt--focus--border);box-shadow:var(--bt--focus--box-shadow)}button:disabled{background-color:var(--bt--disabled--background-color);color:var(--bt--disabled--color);fill:var(--bt--disabled--color);border:none;cursor:no-drop}button.icon{width:42px;min-width:42px;height:42px;padding:0px}a{font-family:var(--bt--font-family);font-size:var(--bt--font-size);font-weight:var(--bt--font-weight);cursor:pointer;display:flex;align-items:center;justify-content:center}";
10
+
11
+ const EzButton = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ /**
15
+ * Deixa o botão disponível ou não para interação com o usuário.
16
+ */
17
+ this.enabled = true;
18
+ /**
19
+ * Define o modo de uso do botão; opções: icon, link e regular
20
+ */
21
+ this.mode = "regular";
22
+ }
23
+ handleSlotChange(ev) {
24
+ const slot = ev.target;
25
+ const content = slot.assignedElements()[0];
26
+ if (this.mode == "link") {
27
+ content.style.display = "inline";
28
+ if (slot.name == "leftIcon") {
29
+ content.style.paddingRight = "var(--bt__inline__icon--padding)";
30
+ }
31
+ else if (slot.name == "rightIcon") {
32
+ content.style.paddingLeft = "var(--bt__inline__icon--padding)";
33
+ }
34
+ }
35
+ }
36
+ render() {
37
+ if (this.mode == "icon") {
38
+ return (index.h("button", { class: "icon", type: "button", disabled: !this.enabled }, index.h("ez-icon", { class: "icon", href: this.image, size: "large", onClick: evt => {
39
+ if (!this.enabled)
40
+ evt.stopPropagation();
41
+ } })));
42
+ }
43
+ else if (this.mode == "link") {
44
+ return (index.h("a", null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
45
+ }
46
+ else {
47
+ return (index.h("button", { type: "button", disabled: !this.enabled }, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label, index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } })));
48
+ }
49
+ }
50
+ };
51
+ EzButton.style = ezButtonCss;
52
+
53
+ class FloatingEntry {
54
+ constructor(parent, content, opts) {
55
+ this.parent = new WeakRef(parent);
56
+ this.content = new WeakRef(content);
57
+ this.options = opts;
58
+ }
59
+ }
60
+ class FloatingManager {
61
+ static init() {
62
+ FloatingManager.entries = [];
63
+ document.addEventListener('mousedown', FloatingManager.handleDocumentEvent);
64
+ document.addEventListener('keydown', FloatingManager.handleKeyboardEvent);
65
+ FloatingManager.initialized = true;
66
+ }
67
+ static innerClick(container, node) {
68
+ if (container.contains(node)) {
69
+ return true;
70
+ }
71
+ if (container.shadowRoot && container.shadowRoot.contains(node)) {
72
+ return true;
73
+ }
74
+ return false;
75
+ }
76
+ static doClose(id, entry, target) {
77
+ if (!target || entry.options.autoClose) {
78
+ const parent = entry.parent.deref();
79
+ const content = entry.content.deref();
80
+ if (parent && content) {
81
+ const innerClickFunction = entry.options.innerClickTest ? entry.options.innerClickTest : FloatingManager.innerClick;
82
+ if (!target || !innerClickFunction(content, target)) {
83
+ content.remove();
84
+ delete FloatingManager.entries[id];
85
+ }
86
+ }
87
+ else {
88
+ delete FloatingManager.entries[id];
89
+ }
90
+ }
91
+ }
92
+ static handleDocumentEvent(event) {
93
+ FloatingManager.entries.forEach((entry, index) => {
94
+ FloatingManager.doClose(index, entry, event.composedPath()[0]);
95
+ });
96
+ }
97
+ static handleKeyboardEvent(event) {
98
+ if (event.key === 'Escape') {
99
+ for (let index = FloatingManager.entries.length; index >= 0; index--) {
100
+ const entry = FloatingManager.entries[index];
101
+ if (entry) {
102
+ FloatingManager.close(index);
103
+ break;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ static applyStyle(element, propertyName, value) {
109
+ if (value) {
110
+ element.style.setProperty(propertyName, value);
111
+ }
112
+ }
113
+ static getFloatIndex(content, parent) {
114
+ for (let index = 0; index < FloatingManager.entries.length; index++) {
115
+ const entry = FloatingManager.entries[index];
116
+ if (entry && content === entry.content.deref() && parent === entry.parent.deref()) {
117
+ return index;
118
+ }
119
+ }
120
+ return -1;
121
+ }
122
+ static float(content, parent, options = { autoClose: true }) {
123
+ if (!FloatingManager.initialized) {
124
+ FloatingManager.init();
125
+ }
126
+ const alreadyFloatingIndex = FloatingManager.getFloatIndex(content, parent);
127
+ if (alreadyFloatingIndex > -1) {
128
+ return alreadyFloatingIndex;
129
+ }
130
+ content.style.position = 'absolute';
131
+ FloatingManager.applyStyle(content, "top", options.top);
132
+ FloatingManager.applyStyle(content, "left", options.left);
133
+ FloatingManager.applyStyle(content, "right", options.right);
134
+ FloatingManager.applyStyle(content, "bottom", options.bottom);
135
+ parent.appendChild(content);
136
+ FloatingManager.entries.push(new FloatingEntry(parent, content, options));
137
+ return FloatingManager.entries.length - 1;
138
+ }
139
+ static updateFloatPosition(content, parent, options = { autoClose: true }) {
140
+ const alreadyFloatingIndex = FloatingManager.getFloatIndex(content, parent);
141
+ if (alreadyFloatingIndex > -1) {
142
+ FloatingManager.applyStyle(content, "top", options.top);
143
+ FloatingManager.applyStyle(content, "left", options.left);
144
+ FloatingManager.applyStyle(content, "right", options.right);
145
+ FloatingManager.applyStyle(content, "bottom", options.bottom);
146
+ }
147
+ }
148
+ static close(id) {
149
+ if (FloatingManager.entries[id]) {
150
+ FloatingManager.doClose(id, FloatingManager.entries[id], undefined);
151
+ }
152
+ }
153
+ }
154
+
155
+ class DateUtils {
156
+ static clearTime(date, adjustDayLightSavingTime = true) {
157
+ const newDate = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
158
+ return adjustDayLightSavingTime ? DateUtils.adjustDLST(newDate) : newDate;
159
+ }
160
+ static strToDate(strValue, adjustDayLightSavingTime = true, monthYearMode = false) {
161
+ /** monthYearMode é um booleano para usar o formato MM/YYYY.
162
+ * Quando ativado, é retornado o primeiro dia do mês apenas para construir a data.
163
+ * Não há necessidade de verificar o horário de verão quando utilizado esse modo. */
164
+ let parts;
165
+ if (monthYearMode) {
166
+ parts = /^(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
167
+ }
168
+ else {
169
+ parts = /^(3[01]|[1-2]\d|0[1-9]|[1-9])[^\d]?(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
170
+ }
171
+ if (!parts) {
172
+ return undefined;
173
+ }
174
+ var day = monthYearMode ? 1 : Number(parts[1]);
175
+ var month = Number(parts[(monthYearMode ? 1 : 2)]);
176
+ var year = Number(parts[(monthYearMode ? 2 : 3)]);
177
+ var hour = Number(parts[(monthYearMode ? 3 : 4)] || 0);
178
+ var min = Number(parts[(monthYearMode ? 4 : 5)] || 0);
179
+ var sec = Number(parts[(monthYearMode ? 5 : 6)] || 0);
180
+ if (year < 100) {
181
+ year += year < 30 ? 2000 : 1900;
182
+ }
183
+ let date = new Date(year, month - 1, day, hour, min, sec, 0);
184
+ if (adjustDayLightSavingTime === true && !monthYearMode && hour == 0) {
185
+ date = DateUtils.adjustDLST(date);
186
+ }
187
+ return date;
188
+ }
189
+ static adjustDLST(date) {
190
+ //Work around para corrigir o Bug do horário de verão.
191
+ if (date.getHours() == 23) {
192
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 1, 0, 0, 0);
193
+ }
194
+ return date;
195
+ }
196
+ }
197
+
198
+ const ezCalendarCss = ":host{--cal--font-family:var(--font-pattern, Arial);--cal--color:var(--title--primary, #626e82);--cal--text-shadow:var(--text-shadow, 0 0 0 #353535,0 0 1px transparent);--cal__body--background-color:var(--background--xlight, #FFF);--cal__body--padding:var(--space--medium, 12px);--cal__body--border-radius:var(--border--radius-medium, 12px);--cal__body--shadow:var(--shadow, 0px 0px 16px 0px #000);--cal__header-line--stroke:2px;--cal__header-line--color:var(--color--strokes, #C0C0C0);--cal__nav-btn--fill:var(--text--primary, #008561);--cal__nav-btn--over--fill:var(--color--primary, #350404);--cal__nav-btn--width:10px;--cal__nav-btn--height:16px;--cal__nav-btn--previous-path:path(\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\");--cal__nav-btn--next-path:path(\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\");--cal__cell--margin:0px var(--space--small, 12px);--cal__cell--width:var(--space--large, 24px);--cal__cell--padding:var(--space--extra-small, 3px) 0px;--cal__cell--border-radius:var(--border--radius-small, 6px);--cal__cell--over--background-color:var(--color--strokes, #C0C0C0);--cal__cell--outset--color:var(--color--strokes, #C0C0C0);--cal__cell--selected--background-color:var(--color--primary, #008561);--cal__cell--selected--color:var(--color--inverted, #FFF);--cal__btn-today--color:var(--color--primary);--cal__btn-today--hover--background-color:var(--color--strokes, #C0C0C0);--cal__btn-today--border-radius:var(--border--radius-small, 6px);position:relative;display:flex;user-select:none}.calendar{z-index:var(--more-visible, 2);display:flex;flex-direction:column;background-color:var(--cal__body--background-color);padding:var(--cal__body--padding);border-radius:var(--cal__body--border-radius);box-shadow:var(--cal__body--shadow)}.calendar__header{display:flex;justify-content:space-between;padding-bottom:var(--space--medium, 12px);margin:var(--space--small, 6px) var(--space--, 12px);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow);border-bottom:solid var(--cal__header-line--stroke) var(--cal__header-line--color)}.calendar__btn-next,.calendar__btn-previous{outline:none;border:none;background-color:unset;cursor:pointer;padding:0px}.calendar__btn-next::after,.calendar__btn-previous::after{content:'';display:flex;background-color:var(--cal__nav-btn--fill);width:var(--cal__nav-btn--width);height:var(--cal__nav-btn--height)}.calendar__btn-previous::after{clip-path:var(--cal__nav-btn--previous-path)}.calendar__btn-next::after{clip-path:var(--cal__nav-btn--next-path)}.calendar__btn-next:hover::after,.calendar__btn-previous:hover::after{background-color:var(--cal__nav-btn--over--fill)}.calendar__lbl-month{font-weight:var(--text-weight--large, 600);font-size:var(--title--medium, 16px);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow)}.calendar__line{display:flex;padding:0px;margin:0px}.calendar__cell{display:flex;justify-content:center;align-content:center;cursor:pointer;font-size:var(--text--small, 12px);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow);padding:var(--cal__cell--padding);margin:var(--cal__cell--margin);min-width:var(--cal__cell--width);border-radius:var(--cal__cell--border-radius)}.calendar__cell:hover{background-color:var(--cal__cell--over--background-color)}.calendar__cell--secondary{color:var(--cal__cell--outset--color)}.calendar__cell--unselectable:hover{background-color:unset;border-radius:unset;cursor:unset}.calendar__cell--unselectable{font-weight:var(--text-weight--large, 600);font-family:var(--cal--font-family);color:var(--cal--color);text-shadow:var(--cal--text-shadow)}.calendar__cell--selected,.calendar__cell--selected:hover{background-color:var(--cal__cell--selected--background-color);color:var(--cal__cell--selected--color)}.calendar__body{padding:var(--space--small, 6px) 0px}.calendar__footer{display:flex;flex-direction:column}.calendar__btn-today{border:none;background-color:unset;cursor:pointer;font-weight:var(--text-weight--large, 600);font-size:var(--title--small);padding:var(--space--extra-small, 6px);font-family:var(--cal--font-family);text-shadow:var(--cal--text-shadow);color:var(--cal__btn-today--color);border-radius:var(--cal__btn-today--border-radius)}.calendar__btn-today:hover{background-color:var(--cal__btn-today--hover--background-color)}";
199
+
200
+ const EzCalendar = class {
201
+ constructor(hostRef) {
202
+ index.registerInstance(this, hostRef);
203
+ this.ezChange = index.createEvent(this, "ezChange", 7);
204
+ this._firstRender = true;
205
+ this._todayLabel = 'Hoje';
206
+ this._weekDayLabels = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];
207
+ this._monthLabels = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'];
208
+ /**
209
+ * A data selecionada no calendário
210
+ */
211
+ this.value = new Date();
212
+ /**
213
+ * No modo floating o calendário só se tornará visível
214
+ * quando o método show() for acionado.
215
+ */
216
+ this.floating = false;
217
+ }
218
+ /**
219
+ * Usado no modo floating. Faz com que o componente seja exibido.
220
+ * É possível determinar ajustes de posicionamento através dos parâmetros
221
+ * top, left, bottom e right. Esses parâmetros devem ser informados como
222
+ * strings no formato css.
223
+ */
224
+ async show(top, left, bottom, right) {
225
+ if (this.floating) {
226
+ this._floatingID = FloatingManager.float(this._box, this._container, { autoClose: true, top, left, bottom, right });
227
+ }
228
+ }
229
+ /**
230
+ * Usado no modo floating. Faz com que o componente seja ocultado.
231
+ */
232
+ async hide() {
233
+ if (this._floatingID !== undefined) {
234
+ FloatingManager.close(this._floatingID);
235
+ this._floatingID = undefined;
236
+ }
237
+ }
238
+ valueChanged() {
239
+ if (this.value) {
240
+ this._currentPosition.setTime(this.value.getTime());
241
+ this._currentPosition.setDate(1);
242
+ }
243
+ }
244
+ getMonthLabel() {
245
+ return this._monthLabels[this._currentPosition.getMonth()] + " " + this._currentPosition.getFullYear();
246
+ }
247
+ isSelectedDate(d) {
248
+ if (this.value) {
249
+ return this.value.getDate() == d.getDate() && this.value.getMonth() == d.getMonth() && this.value.getFullYear() == d.getFullYear();
250
+ }
251
+ return false;
252
+ }
253
+ changeMonth(offset) {
254
+ this._currentPosition.setMonth(this._currentPosition.getMonth() + offset);
255
+ index.forceUpdate(this);
256
+ }
257
+ selectDate(d) {
258
+ this.value = d;
259
+ this.ezChange.emit();
260
+ }
261
+ componentDidRender() {
262
+ if (this.floating && this._firstRender) {
263
+ this._box.remove();
264
+ this._firstRender = false;
265
+ }
266
+ }
267
+ render() {
268
+ if (this._currentPosition == null) {
269
+ this._currentPosition = new Date();
270
+ this._currentPosition.setTime(this.value.getTime());
271
+ this._currentPosition.setDate(1);
272
+ }
273
+ const firstDate = new Date();
274
+ firstDate.setTime(this._currentPosition.getTime());
275
+ firstDate.setDate(1 - firstDate.getDay());
276
+ return (index.h("section", { ref: elem => this._container = elem }, index.h("div", { class: "calendar", ref: elem => this._box = elem }, index.h("div", { class: "calendar__header" }, index.h("button", { class: "calendar__btn-previous", onClick: () => this.changeMonth(-1) }), index.h("label", { class: "calendar__lbl-month" }, this.getMonthLabel()), index.h("button", { class: "calendar__btn-next", onClick: () => this.changeMonth(1) })), index.h("div", { class: "calendar__body" }, index.h("div", { class: "calendar__line" }, this._weekDayLabels.map(day => index.h("div", { class: "calendar__cell calendar__cell--unselectable" }, day))), [0, 7, 14, 21, 28, 35].map(offset => index.h("div", { class: "calendar__line" }, [0, 1, 2, 3, 4, 5, 6].map(index$1 => {
277
+ const date = new Date();
278
+ date.setTime(firstDate.getTime());
279
+ date.setDate(date.getDate() + offset + index$1);
280
+ let classNames = "calendar__cell";
281
+ if (this._currentPosition.getMonth() != date.getMonth()) {
282
+ classNames += " calendar__cell--secondary";
283
+ }
284
+ else if (this.isSelectedDate(date)) {
285
+ classNames += " calendar__cell--selected";
286
+ }
287
+ return index.h("div", { class: classNames, onClick: () => this.selectDate(date) }, date.getDate());
288
+ })))), index.h("div", { class: "calendar__footer" }, index.h("button", { class: "calendar__btn-today", onClick: () => this.selectDate(new Date()) }, this._todayLabel)))));
289
+ }
290
+ static get watchers() { return {
291
+ "value": ["valueChanged"]
292
+ }; }
293
+ };
294
+ EzCalendar.style = ezCalendarCss;
295
+
296
+ const ezCheckCss = ":host{--chk--box--width:18px;--chk--box--height:18px;--chk--width:calc(var(--chk--box--width) + 14px);--chk--height:calc(var(--chk--box--width) + 14px);--chk--border-radius:var(--border--radius-small);--chk--checked--background-color:var(--color--primary-200);--chk--focus--background-color:var(--color--strokes, #FFFFFF);--chk--hover--background-color:var(--background--medium);--chk--checked--disabled--background-color:var(--color--disable-secondary);--chk--border:var(--border--medium) var(--title--primary);--chk--disabled--border:var(--border--medium) var(--color--strokes);--chk--checked--border:var(--border--medium) var(--color--primary);--chk--checked--hover--background-color:var(--color--primary-200);--chk--checked--focus--background-color:var(--color--primary-300, #FFFFFF);--chk--check--clip-path:polygon(40% 70%, 46% 73%, 51% 71%, 93% 21%, 93% 16%, 83% 8%, 76% 9%, 47% 45%, 43% 44%, 38% 39%, 30% 37%, 22% 47%, 23% 54%, 40% 70%);--chk--check--background-color:var(--color--primary);--chk--check--disabled--background-color:var(--color--strokes);--swt--slider--width:34px;--swt--slider--height:14px;--swt--pin--width:20px;--swt--pin--height:20px;--swt--focus--width:32px;--swt--focus--height:32px;--swt--background-color:var(--color--strokes);--swt--disabled--background-color:var(--color--disable-secondary);--swt--checked--background-color:var(--color--primary-300);--swt--pin--background-color:var(--background--xlight);--swt--pin--disabled--background-color:var(--color--disable-secondary);--swt--pin--checked--background-color:var(--color--primary);--swt--pin--checked--disabled--background-color:#E8F7F4;--swt--pin--focus--background-color:var(--text--disable);--swt--pin--checked--focus--background-color:var(--color--primary);width:100%}input.regularMode{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;box-sizing:border-box;-webkit-appearance:none;cursor:pointer;border-radius:50%;width:var(--chk--width);height:var(--chk--height)}input.regularMode:enabled:hover{background-color:var(--chk--hover--background-color)}input.regularMode:enabled:focus{outline:none;background-color:var(--chk--focus--background-color)}input.regularMode:disabled{cursor:auto;background:none}input.regularMode::before{box-sizing:border-box;content:\"\";display:block;width:var(--chk--box--width);height:var(--chk--box--height);border-radius:var(--chk--border-radius);border:var(--chk--border)}input.regularMode:disabled::before{border:var(--chk--disabled--border)}input.regularMode:checked:enabled:hover{background-color:var(--chk--checked--hover--background-color)}input.regularMode:checked:enabled:focus{background-color:var(--chk--checked--focus--background-color)}input.regularMode:checked::before{border:var(--chk--checked--border);background-color:var(--chk--checked--background-color)}input.regularMode:checked:disabled:before{border:var(--chk--disabled--border);background-color:var(--chk--checked--disabled--background-color)}input.regularMode:checked::after{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;content:\"\";position:absolute;margin-top:3px;margin-left:-1px;width:12px;height:12px;background-color:var(--chk--check--background-color);clip-path:var(--chk--check--clip-path)}input.regularMode:checked:disabled::after{background-color:var(--chk--check--disabled--background-color)}input.switchMode{appearance:none;position:relative;outline:none;cursor:pointer;border-radius:20px;border:none;transition:background-color var(--transition);width:var(--swt--slider--width);height:var(--swt--slider--height);background-color:var(--swt--background-color)}input.switchMode:disabled{background-color:var(--swt--disabled--background-color)}input.switchMode::after{content:\"\";display:block;position:absolute;box-shadow:var(--shadow);transition:transform var(--transition);transition:background-color var(--transition);transform:translateY(-3px);border-radius:50%;width:var(--swt--pin--width);height:var(--swt--pin--height);background-color:var(--swt--pin--background-color)}input.switchMode:disabled::after{background-color:var(--swt--pin--disabled--background-color)}input.switchMode:checked{transition:background-color var(--transition);background-color:var(--swt--checked--background-color)}input.switchMode::before{display:block;content:\"\";display:block;position:absolute;border-radius:50%;opacity:0;width:var(--swt--focus--width);height:var(--swt--focus--height);top:calc((var(--swt--slider--height) - var(--swt--focus--height)) / 2);left:calc((var(--swt--pin--width) - var(--swt--focus--width))/2);background-color:var(--swt--pin--focus--background-color)}input.switchMode:focus::before{opacity:0.24;transition:opacity var(--transition)}input.switchMode:checked:focus::before{background-color:var(--swt--pin--checked--focus--background-color);transform:translateX(calc(var(--swt--slider--width) - var(--swt--pin--width)))}input.switchMode:checked::after{transition:transform var(--transition);transition:background-color var(--transition);transform:translateX(calc(var(--swt--slider--width) - var(--swt--pin--width))) translateY(-3px);box-shadow:var(--shadow);background-color:var(--swt--pin--checked--background-color)}input.switchMode:checked:disabled::after{background-color:var(--swt--pin--checked--disabled--background-color)}";
297
+
298
+ const EzCheck = class {
299
+ constructor(hostRef) {
300
+ index.registerInstance(this, hostRef);
301
+ this.valueChange = index.createEvent(this, "valueChange", 7);
302
+ /**
303
+ * Deixa o campo disponível ou não interagir com o usuário.
304
+ */
305
+ this.enabled = true;
306
+ /**
307
+ * Existem dois modos de visualização: regular e switch.
308
+ * Se esta propriedade for omitida, o componete assume o formato "regular";
309
+ * No modo "regular" a visualização é a tradicional de uma caixinha marcada/desmarcada.
310
+ * No modo "switch" o campo tem uma interface em formato de um pino liga/desliga.
311
+ */
312
+ this.mode = "regular";
313
+ }
314
+ adjustMode() {
315
+ if (this.mode === "switch") {
316
+ this._inputElem.classList.remove("regularMode");
317
+ this._inputElem.classList.add("switchMode");
318
+ }
319
+ else {
320
+ this._inputElem.classList.remove("switchMode");
321
+ this._inputElem.classList.add("regularMode");
322
+ }
323
+ }
324
+ //---------------------------------------------
325
+ // Public methods
326
+ //---------------------------------------------
327
+ /**
328
+ * Devolve o modo escolhido para o componente
329
+ */
330
+ async getMode() {
331
+ return this.mode;
332
+ }
333
+ /**
334
+ * Faz o foco no componente de input
335
+ */
336
+ async setFocus() {
337
+ this._inputElem.focus();
338
+ }
339
+ componentDidLoad() {
340
+ this.adjustMode();
341
+ }
342
+ changeValue() {
343
+ this.value = !this.value;
344
+ this.valueChange.emit();
345
+ }
346
+ render() {
347
+ return (index.h("input", { type: "checkbox", class: "regularMode", checked: this.value === true, onChange: () => { this.changeValue(); }, disabled: !this.enabled, ref: (el) => this._inputElem = el }));
348
+ }
349
+ static get watchers() { return {
350
+ "mode": ["adjustMode"]
351
+ }; }
352
+ };
353
+ EzCheck.style = ezCheckCss;
354
+
355
+ const ezCollapsableBoxCss = ":host{--collapsable-box--height:42px;--collapsable-box--font-size:var(--title--medium, 14px);--collapsable-box--font-family:var(--font-pattern, Arial);--collapsable-box--font-weight:var(--text-weight--large, 600);--collapsable-box--color:var(--title--primary);--collapsable-box__btn--path:path(\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\");--collapsable-box__btn--fill:var(--collapsable-box--color);--collapsable-box__btn--width:10px;--collapsable-box__btn--height:16px;display:flex;flex-wrap:wrap;width:100%}.collapsable-box__title{width:100%;display:flex;box-sizing:border-box}.collapsable-box__label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%;font-family:var(--collapsable-box--font-family);font-size:var(--collapsable-box--font-size);font-weight:var(--collapsable-box--font-weight);color:var(--collapsable-box--color)}.collapsable-box__btn{outline:none;border:none;background-color:unset;cursor:pointer;padding:1px 6px}.collapsable-box__btn::after{content:'';display:flex;clip-path:var(--collapsable-box__btn--path);background-color:var( --collapsable-box__btn--fill);width:var(--collapsable-box__btn--width);height:var(--collapsable-box__btn--height);transition:transform var(--transition);transform:rotate(90deg)}.collapsable-box__btn--collapsed::after{transform:rotate(0deg)}";
356
+
357
+ const EzCollapsableBox = class {
358
+ constructor(hostRef) {
359
+ index.registerInstance(this, hostRef);
360
+ this.ezChange = index.createEvent(this, "ezChange", 7);
361
+ /**
362
+ * Valor externalizado que garante a exibição ou não do componente
363
+ */
364
+ this.value = false;
365
+ }
366
+ observeValue() {
367
+ this.ezChange.emit();
368
+ }
369
+ /**
370
+ * Esconde ou revela o conteúdo do componente
371
+ */
372
+ async showHide() {
373
+ this.value = !this.value;
374
+ }
375
+ render() {
376
+ return (index.h(index.Host, null, index.h("div", { class: "collapsable-box__title" }, index.h("button", { class: this.value ? "collapsable-box__btn collapsable-box__btn--collapsed" : "collapsable-box__btn", onClick: () => this.showHide() }), index.h("label", { class: "collapsable-box__label", title: this.label }, this.label)), !this.value ? index.h("slot", null) : null));
377
+ }
378
+ static get watchers() { return {
379
+ "value": ["observeValue"]
380
+ }; }
381
+ };
382
+ EzCollapsableBox.style = ezCollapsableBoxCss;
383
+
384
+ const ezComboBoxCss = ":host{--cx--height:42px;--cx--width:100%;--cx__icon--width:48px;--cx--border-radius:var(--border--radius-medium, 12px);--cx--border-radius-small:var(--border--radius-small, 6px);--cx--font-size:var(--text--medium, 14px);--cx--font-family:var(--font-pattern, Arial);--cx--font-weight--large:var(--text-weight--large, 500);--cx--font-weight--medium:var(--text-weight--medium, 400);--cx--space--medium:var(--space--medium, 12px);--cx--space--small:var(--space--small, 6px);--cx--shadow:var(--shadow, 0px 0px 16px 0px rgba(0, 38, 111, .12));--cx--background-color--xlight:var(--background--xlight,#fff);--cx__input--background-color:var(--background--medium, #e0e0e0);--cx__input--border:var(--border--medium, 2px solid);--cx__input--border-color:var(--cx__input--background-color);--cx__input--focus--border-color:var(--color--primary, #008561);--cx__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--cx__input--disabled--color:var(--text--disable, #AFB6C0);--cx__input--error--border-color:#CC2936;--cx__label--color:var(--title--primary, #919191);--cx__message_box--font-size:var(--text--small, 12px);--cx__message_box--info--color:var(--color--success, #22085d);--cx__message_box--error--color:var(--color--error, #FF0000);--cx__list-text--primary:var(--text--primary,#626e82);--cx__list-text--secondary:var(--text--secondary,#a2abb9);--cx__list-height:calc(var(--cx--font-size) + var(--cx--space--medium));display:flex;flex-wrap:wrap;position:relative;width:var(--cx--width)}ez-text-input{--it__input--background-color:var(--cx__input--background-color, #FFFFFF);--it__input--border-color:var(--cx__input--border-color, #DCE0E8)}.invisible{visibility:hidden}.list-container{scroll-behavior:smooth;z-index:var(--cx__list-z-index);padding:var(--cx--space--small);background:var(--cx--background-color--xlight);border-radius:var(--cx--border-radius);width:100%;overflow:auto;box-sizing:border-box;max-height:calc(4*var(--cx__list-height) + 2*var(--cx--space--small))}li{list-style-type:none;border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);display:flex;justify-content:space-between;align-items:center}li:hover{background-color:var(--background--medium)}.--li--preselected{background-color:var(--background--strong)}.--li__spanlabel{color:var(--cx__list-text--primary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--large);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:80%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanlabel--full-width{color:var(--cx__list-text--primary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--large);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:100%;min-width:30px;overflow-x:hidden;text-align:left}.--li__spanvalue{color:var(--cx__list-text--secondary);border-radius:var(--cx--border-radius-small);padding:0 var(--cx--space--small);height:var(--cx__list-height);font-weight:var(--cx--font-weight--medium);font-family:var(--cx--font-family);line-height:var(--cx__list-height);vertical-align:middle;text-overflow:ellipsis;width:20%;min-width:20px;overflow-x:hidden;text-align:left}.btn-open-options{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-options:disabled{cursor:unset}.btn-open-options::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:16px;height:16px;clip-path:path(\"M 1.8585859,3.0707069 7.9999998,9.2121212 14.141414,3.0707069 16,5.0101006 7.9999998,12.929293 0,4.9292932 Z\")}.btn-open-options:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-options:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}";
385
+
386
+ const EzComboBox = class {
387
+ constructor(hostRef) {
388
+ index.registerInstance(this, hostRef);
389
+ this.ezChange = index.createEvent(this, "ezChange", 7);
390
+ this._inputLabelValue = '';
391
+ /**
392
+ * Valor associado ao componente. Este é o valor que o componente recebe ao selecionar uma opção do combobox.
393
+ * Pode ser Label ou Value de acordo com a opção "labelasindex"
394
+ * Caso seja atribuído um valor ao componente que não esteja na relação das options, este vai lançar msg de erro
395
+ * (executo pala valor undefined)
396
+ */
397
+ this.value = undefined;
398
+ /**
399
+ * Label é o título do campo
400
+ */
401
+ this.label = undefined;
402
+ /**
403
+ * Deixa o campo disponível ou não para digitação.
404
+ */
405
+ this.enabled = true;
406
+ /**
407
+ * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
408
+ */
409
+ this.showvalue = false;
410
+ }
411
+ //---------------------------------------------
412
+ // Public methods
413
+ //---------------------------------------------
414
+ /**
415
+ * Faz o foco no componente de textarea
416
+ */
417
+ async setFocus() {
418
+ this._textInput.setFocus();
419
+ }
420
+ /**
421
+ * Remove o foco no componente de textarea
422
+ */
423
+ async setBlur() {
424
+ this._textInput.setBlur();
425
+ }
426
+ updateValue() {
427
+ const selectedOption = this.options.filter(opt => opt.value === this.value);
428
+ if (selectedOption && selectedOption.length > 0) {
429
+ this._textInput.value = selectedOption[0].label;
430
+ }
431
+ else {
432
+ this.value = null;
433
+ this._textInput.value = '';
434
+ }
435
+ }
436
+ setErrorMessage() {
437
+ this._textInput.errormessage = this.errormessage;
438
+ }
439
+ showOptions() {
440
+ if (this.enabled) {
441
+ this._criteria = undefined;
442
+ const top = this._textInput.errormessage ? '0px' : '-17px';
443
+ this._popover.show(top);
444
+ }
445
+ }
446
+ updateSelection() {
447
+ const selectedOption = this.options.filter(opt => opt.label === this._textInput.value);
448
+ this.selectOption((selectedOption && selectedOption.length > 0) ? selectedOption[0] : null);
449
+ }
450
+ selectOption(opt) {
451
+ this._popover.hide();
452
+ this.value = opt ? opt.value : null;
453
+ this.ezChange.emit();
454
+ }
455
+ buildItem(opt, index$1) {
456
+ const className = index$1 === this._preSelection ? "--li--preselected" : "";
457
+ return index.h("li", { class: className, key: opt.value, id: 'item_' + opt.value, onMouseDown: () => this.selectOption(opt) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { class: '--li__spanvalue' }, opt.value) : null);
458
+ }
459
+ highlightMatch(label) {
460
+ const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
461
+ if (this._criteria) {
462
+ const criteriaLength = this._criteria.length;
463
+ const matchStart = label.toUpperCase().indexOf(this._criteria);
464
+ if (matchStart > -1) {
465
+ const strLabelStart = label.substr(0, matchStart);
466
+ const strLabelEnd = label.substr(matchStart + criteriaLength);
467
+ const strMatch = label.substr(matchStart, criteriaLength);
468
+ return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
469
+ }
470
+ }
471
+ return (index.h("span", { class: spanClassName }, label));
472
+ }
473
+ matchOptions() {
474
+ this.showOptions();
475
+ this._criteria = this._textInput.value.toLocaleUpperCase();
476
+ this.filterOptions();
477
+ }
478
+ filterOptions() {
479
+ this._preSelection = undefined;
480
+ let opts = (this.options || []);
481
+ if (this._criteria) {
482
+ opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(this._criteria) > -1);
483
+ }
484
+ this._visibleOptions = [{ value: '', label: '' }].concat(opts);
485
+ }
486
+ nextOption() {
487
+ this.showOptions();
488
+ this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
489
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
490
+ }
491
+ previousOption() {
492
+ this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
493
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
494
+ }
495
+ scrollToOption(opt) {
496
+ const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
497
+ if (liElem) {
498
+ const parent = liElem.parentElement;
499
+ const parentRect = parent.getBoundingClientRect();
500
+ const itemRect = liElem.getBoundingClientRect();
501
+ if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
502
+ liElem.scrollIntoView();
503
+ }
504
+ }
505
+ }
506
+ selectCurrentOption() {
507
+ if (this._preSelection !== undefined) {
508
+ this.selectOption(this._visibleOptions[this._preSelection]);
509
+ this._preSelection = undefined;
510
+ }
511
+ }
512
+ keyDownHandler(event) {
513
+ switch (event.key) {
514
+ case "ArrowDown":
515
+ this.nextOption();
516
+ break;
517
+ case "ArrowUp":
518
+ this.previousOption();
519
+ break;
520
+ case "Enter":
521
+ this.selectCurrentOption();
522
+ break;
523
+ }
524
+ event.stopPropagation();
525
+ }
526
+ //---------------------------------------------
527
+ // Lifecycle web component
528
+ //---------------------------------------------
529
+ componentWillLoad() {
530
+ if (this.options === undefined) {
531
+ this.options = [];
532
+ const optionsTags = this.el.querySelectorAll('option');
533
+ if (optionsTags) {
534
+ optionsTags.forEach(e => {
535
+ let label = e.innerText;
536
+ let value = e.getAttribute('value');
537
+ if (!value) {
538
+ value = label;
539
+ }
540
+ this.options.push({ label, value });
541
+ e.hidden = true;
542
+ });
543
+ }
544
+ }
545
+ this.filterOptions();
546
+ }
547
+ componentDidLoad() {
548
+ this.updateValue();
549
+ }
550
+ render() {
551
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => this._textInput = el, value: this._inputLabelValue, enabled: this.enabled, onInput: () => this.matchOptions(), onClick: () => this.showOptions(), onFocusout: () => this.updateSelection(), onEzChange: event => event.stopPropagation(), onKeyDown: event => this.keyDownHandler(event), label: this.label, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-options", slot: "rightIcon", onClick: () => this.showOptions() })), index.h("ez-popover", { boxwidth: "100%", ref: el => this._popover = el, autoclose: true }, index.h("div", { class: "list-container" }, this._visibleOptions.map((opt, index) => this.buildItem(opt, index))))));
552
+ }
553
+ ;
554
+ get el() { return index.getElement(this); }
555
+ static get watchers() { return {
556
+ "value": ["updateValue"],
557
+ "errormessage": ["setErrorMessage"]
558
+ }; }
559
+ };
560
+ EzComboBox.style = ezComboBoxCss;
561
+
562
+ const ezDateInputCss = ":host{display:block;width:100%;--it__input--background-color:var(--background--medium, #e0e0e0);--it__input--border-color:var(--it__input--background-color)}.text-input{--it__input--background-color:inherit;--it__input--border-color:inherit}.btn-open-cal{outline:none;border:none;background-color:unset;cursor:pointer}.btn-open-cal:disabled{cursor:unset}.btn-open-cal::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:15px;height:16px;clip-path:path(\"M 3.171875,5.25 C 2.6485088,5.25 2.21875,5.6797588 2.21875,6.203125 2.21875,6.7264912 2.6485088,7.15625 3.171875,7.15625 3.6952412,7.15625 4.125,6.7264912 4.125,6.203125 4.125,5.6797588 3.6952412,5.25 3.171875,5.25 Z m 2.875,0 C 5.5235088,5.25 5.09375,5.6797588 5.09375,6.203125 5.09375,6.7264912 5.5235088,7.15625 6.046875,7.15625 6.5702412,7.15625 7,6.7264912 7,6.203125 7,5.6797588 6.5702412,5.25 6.046875,5.25 Z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.9511719,-0.4297588 0.9511719,-0.953125 C 9.8730469,5.6797588 9.4452412,5.25 8.921875,5.25 Z m 2.873047,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.953125 0.953125,0.953125 0.523366,0 0.953125,-0.4297588 0.953125,-0.953125 C 12.748047,5.6797588 12.318288,5.25 11.794922,5.25 Z M 3.171875,8.1230469 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 0.5233662,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297588,0.9531251 0.953125,0.9531251 C 6.5702412,10.029297 7,9.5995381 7,9.0761719 7,8.5528057 6.5702412,8.1230469 6.046875,8.1230469 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.4297587,0.9531251 0.953125,0.9531251 0.5233661,0 0.9531249,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.4297588 -0.953125,0.953125 0,0.5233662 0.429759,0.9531251 0.953125,0.9531251 0.523367,0 0.953125,-0.4297589 0.953125,-0.9531251 0,-0.5233662 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.171875,10.998047 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 0.5233662,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.875,0 c -0.5233662,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297588,0.953125 0.953125,0.953125 C 6.5702412,12.904297 7,12.474538 7,11.951172 7,11.427806 6.5702412,10.998047 6.046875,10.998047 Z m 2.8554688,0 c -0.5233663,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.4297587,0.953125 0.953125,0.953125 0.5233661,0 0.9531249,-0.429759 0.953125,-0.953125 0,-0.523366 -0.4297588,-0.953125 -0.953125,-0.953125 z m 2.9003902,0 c -0.523366,0 -0.953125,0.429759 -0.953125,0.953125 0,0.523366 0.429759,0.953125 0.953125,0.953125 0.523367,0 0.953125,-0.429759 0.953125,-0.953125 0,-0.523366 -0.429758,-0.953125 -0.953125,-0.953125 z M 3.5,0 c -0.554,0 -1,0.446 -1,1 v 0.050781 C 1.0853217,1.2909766 0,2.5186658 0,4 v 9 c 0,1.652487 1.3475134,3 3,3 h 9 c 1.652487,0 3,-1.347513 3,-3 V 4 C 15,2.5186658 13.914678,1.2909766 12.5,1.0507812 V 1 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 c 0,-0.554 -0.446,-1 -1,-1 -0.554,0 -1,0.446 -1,1 h -2 C 4.5,0.446 4.054,0 3.5,0 Z m 1,2.0996094 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 v -0.640625 h 2 v 0.640625 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 V 2.1738281 C 13.311725,2.3905225 13.900391,3.11278 13.900391,4 v 9 c 0,1.062113 -0.838278,1.900391 -1.900391,1.900391 H 3 C 1.9378864,14.900391 1.0996094,14.062113 1.0996094,13 V 4 C 1.0996094,3.11278 1.6882747,2.3905225 2.5,2.1738281 v 0.5664063 c 0,0.554 0.446,1 1,1 0.554,0 1,-0.446 1,-1 z\")}.btn-open-cal:disabled:after{background-color:var(--text--disable, #AFB6C0)}.btn-open-cal:enabled:hover::after{background-color:var(--color--primary, #4e4e4e)}";
563
+
564
+ const EzDateInput = class {
565
+ constructor(hostRef) {
566
+ index.registerInstance(this, hostRef);
567
+ this.ezChange = index.createEvent(this, "ezChange", 7);
568
+ /**
569
+ * Deixa o campo disponível ou não para uso.
570
+ */
571
+ this.enabled = true;
572
+ }
573
+ setLabel() {
574
+ this._textInput.label = this.label;
575
+ }
576
+ setErrorMessage() {
577
+ this._textInput.errormessage = this.errormessage;
578
+ }
579
+ applyValueToInput() {
580
+ this._textInput.value = this.getTextValue(this.value);
581
+ }
582
+ changeValue(newValue) {
583
+ newValue = newValue == null ? null : DateUtils.clearTime(newValue);
584
+ this._textInput.errormessage = "";
585
+ if (this.getTextValue(newValue) !== this.getTextValue(this.value)) {
586
+ this.value = newValue;
587
+ this.ezChange.emit();
588
+ }
589
+ }
590
+ showCalendar() {
591
+ this.parseDate();
592
+ this._calendar.value = this.value;
593
+ //FIXME: Provavelmente isso fará com que o popup abra em uma
594
+ //posição errada no futuro. Preferi fazer simples no começo,
595
+ //porque não quis onerar o text input com essa funcionalidade...
596
+ const top = this._textInput.errormessage ? '0px' : '-17px';
597
+ this._calendar.show(top);
598
+ }
599
+ hideCalendar() {
600
+ this.changeValue(this._calendar.value);
601
+ this._calendar.hide();
602
+ }
603
+ parseDate() {
604
+ const strValue = this._textInput.value;
605
+ const parsedDate = DateUtils.strToDate(strValue);
606
+ if (parsedDate || !strValue) {
607
+ if (this.value === parsedDate) {
608
+ this.changeValue(this.value);
609
+ }
610
+ else {
611
+ this.changeValue(parsedDate);
612
+ }
613
+ }
614
+ else {
615
+ this._textInput.errormessage = "O valor digitado não é uma data válida";
616
+ }
617
+ }
618
+ getTextValue(d) {
619
+ return d ? new Intl.DateTimeFormat('pt-BR').format(d) : null;
620
+ }
621
+ render() {
622
+ return (index.h(index.Host, null, index.h("ez-text-input", { class: "text-input", ref: elem => this._textInput = elem, onBlur: () => this.parseDate(), onKeyDown: event => {
623
+ if (event.key === 'H' || event.key === 'h')
624
+ this.changeValue(new Date());
625
+ }, label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: "0123456789/", enabled: this.enabled, errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-cal", onClick: () => this.showCalendar(), slot: "leftIcon" })), index.h("ez-calendar", { onEzChange: (event) => { this.hideCalendar(); event.stopPropagation(); }, floating: true, ref: elem => this._calendar = elem })));
626
+ }
627
+ static get watchers() { return {
628
+ "label": ["setLabel"],
629
+ "errormessage": ["setErrorMessage"],
630
+ "value": ["applyValueToInput"]
631
+ }; }
632
+ };
633
+ EzDateInput.style = ezDateInputCss;
634
+
635
+ function _defineProperty(obj, key, value) {
636
+ if (key in obj) {
637
+ Object.defineProperty(obj, key, {
638
+ value: value,
639
+ enumerable: true,
640
+ configurable: true,
641
+ writable: true
642
+ });
643
+ } else {
644
+ obj[key] = value;
645
+ }
646
+
647
+ return obj;
648
+ }
649
+
650
+ function ownKeys(object, enumerableOnly) {
651
+ var keys = Object.keys(object);
652
+
653
+ if (Object.getOwnPropertySymbols) {
654
+ var symbols = Object.getOwnPropertySymbols(object);
655
+
656
+ if (enumerableOnly) {
657
+ symbols = symbols.filter(function (sym) {
658
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
659
+ });
660
+ }
661
+
662
+ keys.push.apply(keys, symbols);
663
+ }
664
+
665
+ return keys;
666
+ }
667
+
668
+ function _objectSpread2(target) {
669
+ for (var i = 1; i < arguments.length; i++) {
670
+ var source = arguments[i] != null ? arguments[i] : {};
671
+
672
+ if (i % 2) {
673
+ ownKeys(Object(source), true).forEach(function (key) {
674
+ _defineProperty(target, key, source[key]);
675
+ });
676
+ } else if (Object.getOwnPropertyDescriptors) {
677
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
678
+ } else {
679
+ ownKeys(Object(source)).forEach(function (key) {
680
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
681
+ });
682
+ }
683
+ }
684
+
685
+ return target;
686
+ }
687
+
688
+ /**
689
+ * Adapted from React: https://github.com/facebook/react/blob/master/packages/shared/formatProdErrorMessage.js
690
+ *
691
+ * Do not require this module directly! Use normal throw error calls. These messages will be replaced with error codes
692
+ * during build.
693
+ * @param {number} code
694
+ */
695
+ function formatProdErrorMessage(code) {
696
+ return "Minified Redux error #" + code + "; visit https://redux.js.org/Errors?code=" + code + " for the full message or " + 'use the non-minified dev environment for full errors. ';
697
+ }
698
+
699
+ // Inlined version of the `symbol-observable` polyfill
700
+ var $$observable = (function () {
701
+ return typeof Symbol === 'function' && Symbol.observable || '@@observable';
702
+ })();
703
+
704
+ /**
705
+ * These are private action types reserved by Redux.
706
+ * For any unknown actions, you must return the current state.
707
+ * If the current state is undefined, you must return the initial state.
708
+ * Do not reference these action types directly in your code.
709
+ */
710
+ var randomString = function randomString() {
711
+ return Math.random().toString(36).substring(7).split('').join('.');
712
+ };
713
+
714
+ var ActionTypes = {
715
+ INIT: "@@redux/INIT" + randomString(),
716
+ REPLACE: "@@redux/REPLACE" + randomString(),
717
+ PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
718
+ return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
719
+ }
720
+ };
721
+
722
+ /**
723
+ * @param {any} obj The object to inspect.
724
+ * @returns {boolean} True if the argument appears to be a plain object.
725
+ */
726
+ function isPlainObject(obj) {
727
+ if (typeof obj !== 'object' || obj === null) return false;
728
+ var proto = obj;
729
+
730
+ while (Object.getPrototypeOf(proto) !== null) {
731
+ proto = Object.getPrototypeOf(proto);
732
+ }
733
+
734
+ return Object.getPrototypeOf(obj) === proto;
735
+ }
736
+
737
+ /**
738
+ * Creates a Redux store that holds the state tree.
739
+ * The only way to change the data in the store is to call `dispatch()` on it.
740
+ *
741
+ * There should only be a single store in your app. To specify how different
742
+ * parts of the state tree respond to actions, you may combine several reducers
743
+ * into a single reducer function by using `combineReducers`.
744
+ *
745
+ * @param {Function} reducer A function that returns the next state tree, given
746
+ * the current state tree and the action to handle.
747
+ *
748
+ * @param {any} [preloadedState] The initial state. You may optionally specify it
749
+ * to hydrate the state from the server in universal apps, or to restore a
750
+ * previously serialized user session.
751
+ * If you use `combineReducers` to produce the root reducer function, this must be
752
+ * an object with the same shape as `combineReducers` keys.
753
+ *
754
+ * @param {Function} [enhancer] The store enhancer. You may optionally specify it
755
+ * to enhance the store with third-party capabilities such as middleware,
756
+ * time travel, persistence, etc. The only store enhancer that ships with Redux
757
+ * is `applyMiddleware()`.
758
+ *
759
+ * @returns {Store} A Redux store that lets you read the state, dispatch actions
760
+ * and subscribe to changes.
761
+ */
762
+
763
+ function createStore(reducer, preloadedState, enhancer) {
764
+ var _ref2;
765
+
766
+ if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
767
+ throw new Error(formatProdErrorMessage(0) );
768
+ }
769
+
770
+ if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
771
+ enhancer = preloadedState;
772
+ preloadedState = undefined;
773
+ }
774
+
775
+ if (typeof enhancer !== 'undefined') {
776
+ if (typeof enhancer !== 'function') {
777
+ throw new Error(formatProdErrorMessage(1) );
778
+ }
779
+
780
+ return enhancer(createStore)(reducer, preloadedState);
781
+ }
782
+
783
+ if (typeof reducer !== 'function') {
784
+ throw new Error(formatProdErrorMessage(2) );
785
+ }
786
+
787
+ var currentReducer = reducer;
788
+ var currentState = preloadedState;
789
+ var currentListeners = [];
790
+ var nextListeners = currentListeners;
791
+ var isDispatching = false;
792
+ /**
793
+ * This makes a shallow copy of currentListeners so we can use
794
+ * nextListeners as a temporary list while dispatching.
795
+ *
796
+ * This prevents any bugs around consumers calling
797
+ * subscribe/unsubscribe in the middle of a dispatch.
798
+ */
799
+
800
+ function ensureCanMutateNextListeners() {
801
+ if (nextListeners === currentListeners) {
802
+ nextListeners = currentListeners.slice();
803
+ }
804
+ }
805
+ /**
806
+ * Reads the state tree managed by the store.
807
+ *
808
+ * @returns {any} The current state tree of your application.
809
+ */
810
+
811
+
812
+ function getState() {
813
+ if (isDispatching) {
814
+ throw new Error(formatProdErrorMessage(3) );
815
+ }
816
+
817
+ return currentState;
818
+ }
819
+ /**
820
+ * Adds a change listener. It will be called any time an action is dispatched,
821
+ * and some part of the state tree may potentially have changed. You may then
822
+ * call `getState()` to read the current state tree inside the callback.
823
+ *
824
+ * You may call `dispatch()` from a change listener, with the following
825
+ * caveats:
826
+ *
827
+ * 1. The subscriptions are snapshotted just before every `dispatch()` call.
828
+ * If you subscribe or unsubscribe while the listeners are being invoked, this
829
+ * will not have any effect on the `dispatch()` that is currently in progress.
830
+ * However, the next `dispatch()` call, whether nested or not, will use a more
831
+ * recent snapshot of the subscription list.
832
+ *
833
+ * 2. The listener should not expect to see all state changes, as the state
834
+ * might have been updated multiple times during a nested `dispatch()` before
835
+ * the listener is called. It is, however, guaranteed that all subscribers
836
+ * registered before the `dispatch()` started will be called with the latest
837
+ * state by the time it exits.
838
+ *
839
+ * @param {Function} listener A callback to be invoked on every dispatch.
840
+ * @returns {Function} A function to remove this change listener.
841
+ */
842
+
843
+
844
+ function subscribe(listener) {
845
+ if (typeof listener !== 'function') {
846
+ throw new Error(formatProdErrorMessage(4) );
847
+ }
848
+
849
+ if (isDispatching) {
850
+ throw new Error(formatProdErrorMessage(5) );
851
+ }
852
+
853
+ var isSubscribed = true;
854
+ ensureCanMutateNextListeners();
855
+ nextListeners.push(listener);
856
+ return function unsubscribe() {
857
+ if (!isSubscribed) {
858
+ return;
859
+ }
860
+
861
+ if (isDispatching) {
862
+ throw new Error(formatProdErrorMessage(6) );
863
+ }
864
+
865
+ isSubscribed = false;
866
+ ensureCanMutateNextListeners();
867
+ var index = nextListeners.indexOf(listener);
868
+ nextListeners.splice(index, 1);
869
+ currentListeners = null;
870
+ };
871
+ }
872
+ /**
873
+ * Dispatches an action. It is the only way to trigger a state change.
874
+ *
875
+ * The `reducer` function, used to create the store, will be called with the
876
+ * current state tree and the given `action`. Its return value will
877
+ * be considered the **next** state of the tree, and the change listeners
878
+ * will be notified.
879
+ *
880
+ * The base implementation only supports plain object actions. If you want to
881
+ * dispatch a Promise, an Observable, a thunk, or something else, you need to
882
+ * wrap your store creating function into the corresponding middleware. For
883
+ * example, see the documentation for the `redux-thunk` package. Even the
884
+ * middleware will eventually dispatch plain object actions using this method.
885
+ *
886
+ * @param {Object} action A plain object representing “what changed”. It is
887
+ * a good idea to keep actions serializable so you can record and replay user
888
+ * sessions, or use the time travelling `redux-devtools`. An action must have
889
+ * a `type` property which may not be `undefined`. It is a good idea to use
890
+ * string constants for action types.
891
+ *
892
+ * @returns {Object} For convenience, the same action object you dispatched.
893
+ *
894
+ * Note that, if you use a custom middleware, it may wrap `dispatch()` to
895
+ * return something else (for example, a Promise you can await).
896
+ */
897
+
898
+
899
+ function dispatch(action) {
900
+ if (!isPlainObject(action)) {
901
+ throw new Error(formatProdErrorMessage(7) );
902
+ }
903
+
904
+ if (typeof action.type === 'undefined') {
905
+ throw new Error(formatProdErrorMessage(8) );
906
+ }
907
+
908
+ if (isDispatching) {
909
+ throw new Error(formatProdErrorMessage(9) );
910
+ }
911
+
912
+ try {
913
+ isDispatching = true;
914
+ currentState = currentReducer(currentState, action);
915
+ } finally {
916
+ isDispatching = false;
917
+ }
918
+
919
+ var listeners = currentListeners = nextListeners;
920
+
921
+ for (var i = 0; i < listeners.length; i++) {
922
+ var listener = listeners[i];
923
+ listener();
924
+ }
925
+
926
+ return action;
927
+ }
928
+ /**
929
+ * Replaces the reducer currently used by the store to calculate the state.
930
+ *
931
+ * You might need this if your app implements code splitting and you want to
932
+ * load some of the reducers dynamically. You might also need this if you
933
+ * implement a hot reloading mechanism for Redux.
934
+ *
935
+ * @param {Function} nextReducer The reducer for the store to use instead.
936
+ * @returns {void}
937
+ */
938
+
939
+
940
+ function replaceReducer(nextReducer) {
941
+ if (typeof nextReducer !== 'function') {
942
+ throw new Error(formatProdErrorMessage(10) );
943
+ }
944
+
945
+ currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
946
+ // Any reducers that existed in both the new and old rootReducer
947
+ // will receive the previous state. This effectively populates
948
+ // the new state tree with any relevant data from the old one.
949
+
950
+ dispatch({
951
+ type: ActionTypes.REPLACE
952
+ });
953
+ }
954
+ /**
955
+ * Interoperability point for observable/reactive libraries.
956
+ * @returns {observable} A minimal observable of state changes.
957
+ * For more information, see the observable proposal:
958
+ * https://github.com/tc39/proposal-observable
959
+ */
960
+
961
+
962
+ function observable() {
963
+ var _ref;
964
+
965
+ var outerSubscribe = subscribe;
966
+ return _ref = {
967
+ /**
968
+ * The minimal observable subscription method.
969
+ * @param {Object} observer Any object that can be used as an observer.
970
+ * The observer object should have a `next` method.
971
+ * @returns {subscription} An object with an `unsubscribe` method that can
972
+ * be used to unsubscribe the observable from the store, and prevent further
973
+ * emission of values from the observable.
974
+ */
975
+ subscribe: function subscribe(observer) {
976
+ if (typeof observer !== 'object' || observer === null) {
977
+ throw new Error(formatProdErrorMessage(11) );
978
+ }
979
+
980
+ function observeState() {
981
+ if (observer.next) {
982
+ observer.next(getState());
983
+ }
984
+ }
985
+
986
+ observeState();
987
+ var unsubscribe = outerSubscribe(observeState);
988
+ return {
989
+ unsubscribe: unsubscribe
990
+ };
991
+ }
992
+ }, _ref[$$observable] = function () {
993
+ return this;
994
+ }, _ref;
995
+ } // When a store is created, an "INIT" action is dispatched so that every
996
+ // reducer returns their initial state. This effectively populates
997
+ // the initial state tree.
998
+
999
+
1000
+ dispatch({
1001
+ type: ActionTypes.INIT
1002
+ });
1003
+ return _ref2 = {
1004
+ dispatch: dispatch,
1005
+ subscribe: subscribe,
1006
+ getState: getState,
1007
+ replaceReducer: replaceReducer
1008
+ }, _ref2[$$observable] = observable, _ref2;
1009
+ }
1010
+
1011
+ function assertReducerShape(reducers) {
1012
+ Object.keys(reducers).forEach(function (key) {
1013
+ var reducer = reducers[key];
1014
+ var initialState = reducer(undefined, {
1015
+ type: ActionTypes.INIT
1016
+ });
1017
+
1018
+ if (typeof initialState === 'undefined') {
1019
+ throw new Error(formatProdErrorMessage(12) );
1020
+ }
1021
+
1022
+ if (typeof reducer(undefined, {
1023
+ type: ActionTypes.PROBE_UNKNOWN_ACTION()
1024
+ }) === 'undefined') {
1025
+ throw new Error(formatProdErrorMessage(13) );
1026
+ }
1027
+ });
1028
+ }
1029
+ /**
1030
+ * Turns an object whose values are different reducer functions, into a single
1031
+ * reducer function. It will call every child reducer, and gather their results
1032
+ * into a single state object, whose keys correspond to the keys of the passed
1033
+ * reducer functions.
1034
+ *
1035
+ * @param {Object} reducers An object whose values correspond to different
1036
+ * reducer functions that need to be combined into one. One handy way to obtain
1037
+ * it is to use ES6 `import * as reducers` syntax. The reducers may never return
1038
+ * undefined for any action. Instead, they should return their initial state
1039
+ * if the state passed to them was undefined, and the current state for any
1040
+ * unrecognized action.
1041
+ *
1042
+ * @returns {Function} A reducer function that invokes every reducer inside the
1043
+ * passed object, and builds a state object with the same shape.
1044
+ */
1045
+
1046
+
1047
+ function combineReducers(reducers) {
1048
+ var reducerKeys = Object.keys(reducers);
1049
+ var finalReducers = {};
1050
+
1051
+ for (var i = 0; i < reducerKeys.length; i++) {
1052
+ var key = reducerKeys[i];
1053
+
1054
+ if (typeof reducers[key] === 'function') {
1055
+ finalReducers[key] = reducers[key];
1056
+ }
1057
+ }
1058
+
1059
+ var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
1060
+
1061
+ var shapeAssertionError;
1062
+
1063
+ try {
1064
+ assertReducerShape(finalReducers);
1065
+ } catch (e) {
1066
+ shapeAssertionError = e;
1067
+ }
1068
+
1069
+ return function combination(state, action) {
1070
+ if (state === void 0) {
1071
+ state = {};
1072
+ }
1073
+
1074
+ if (shapeAssertionError) {
1075
+ throw shapeAssertionError;
1076
+ }
1077
+
1078
+ var hasChanged = false;
1079
+ var nextState = {};
1080
+
1081
+ for (var _i = 0; _i < finalReducerKeys.length; _i++) {
1082
+ var _key = finalReducerKeys[_i];
1083
+ var reducer = finalReducers[_key];
1084
+ var previousStateForKey = state[_key];
1085
+ var nextStateForKey = reducer(previousStateForKey, action);
1086
+
1087
+ if (typeof nextStateForKey === 'undefined') {
1088
+ throw new Error(formatProdErrorMessage(14) );
1089
+ }
1090
+
1091
+ nextState[_key] = nextStateForKey;
1092
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
1093
+ }
1094
+
1095
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
1096
+ return hasChanged ? nextState : state;
1097
+ };
1098
+ }
1099
+
1100
+ /**
1101
+ * Composes single-argument functions from right to left. The rightmost
1102
+ * function can take multiple arguments as it provides the signature for
1103
+ * the resulting composite function.
1104
+ *
1105
+ * @param {...Function} funcs The functions to compose.
1106
+ * @returns {Function} A function obtained by composing the argument functions
1107
+ * from right to left. For example, compose(f, g, h) is identical to doing
1108
+ * (...args) => f(g(h(...args))).
1109
+ */
1110
+ function compose() {
1111
+ for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
1112
+ funcs[_key] = arguments[_key];
1113
+ }
1114
+
1115
+ if (funcs.length === 0) {
1116
+ return function (arg) {
1117
+ return arg;
1118
+ };
1119
+ }
1120
+
1121
+ if (funcs.length === 1) {
1122
+ return funcs[0];
1123
+ }
1124
+
1125
+ return funcs.reduce(function (a, b) {
1126
+ return function () {
1127
+ return a(b.apply(void 0, arguments));
1128
+ };
1129
+ });
1130
+ }
1131
+
1132
+ /**
1133
+ * Creates a store enhancer that applies middleware to the dispatch method
1134
+ * of the Redux store. This is handy for a variety of tasks, such as expressing
1135
+ * asynchronous actions in a concise manner, or logging every action payload.
1136
+ *
1137
+ * See `redux-thunk` package as an example of the Redux middleware.
1138
+ *
1139
+ * Because middleware is potentially asynchronous, this should be the first
1140
+ * store enhancer in the composition chain.
1141
+ *
1142
+ * Note that each middleware will be given the `dispatch` and `getState` functions
1143
+ * as named arguments.
1144
+ *
1145
+ * @param {...Function} middlewares The middleware chain to be applied.
1146
+ * @returns {Function} A store enhancer applying the middleware.
1147
+ */
1148
+
1149
+ function applyMiddleware() {
1150
+ for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
1151
+ middlewares[_key] = arguments[_key];
1152
+ }
1153
+
1154
+ return function (createStore) {
1155
+ return function () {
1156
+ var store = createStore.apply(void 0, arguments);
1157
+
1158
+ var _dispatch = function dispatch() {
1159
+ throw new Error(formatProdErrorMessage(15) );
1160
+ };
1161
+
1162
+ var middlewareAPI = {
1163
+ getState: store.getState,
1164
+ dispatch: function dispatch() {
1165
+ return _dispatch.apply(void 0, arguments);
1166
+ }
1167
+ };
1168
+ var chain = middlewares.map(function (middleware) {
1169
+ return middleware(middlewareAPI);
1170
+ });
1171
+ _dispatch = compose.apply(void 0, chain)(store.dispatch);
1172
+ return _objectSpread2(_objectSpread2({}, store), {}, {
1173
+ dispatch: _dispatch
1174
+ });
1175
+ };
1176
+ };
1177
+ }
1178
+
1179
+ function createThunkMiddleware(extraArgument) {
1180
+ return function (_ref) {
1181
+ var dispatch = _ref.dispatch,
1182
+ getState = _ref.getState;
1183
+ return function (next) {
1184
+ return function (action) {
1185
+ if (typeof action === 'function') {
1186
+ return action(dispatch, getState, extraArgument);
1187
+ }
1188
+
1189
+ return next(action);
1190
+ };
1191
+ };
1192
+ };
1193
+ }
1194
+
1195
+ var thunk = createThunkMiddleware();
1196
+ thunk.withExtraArgument = createThunkMiddleware;
1197
+
1198
+ function getDefaultExportFromCjs (x) {
1199
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1200
+ }
1201
+
1202
+ function createCommonjsModule(fn, basedir, module) {
1203
+ return module = {
1204
+ path: basedir,
1205
+ exports: {},
1206
+ require: function (path, base) {
1207
+ return commonjsRequire();
1208
+ }
1209
+ }, fn(module, module.exports), module.exports;
1210
+ }
1211
+
1212
+ function commonjsRequire () {
1213
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
1214
+ }
1215
+
1216
+ var actions = createCommonjsModule(function (module, exports) {
1217
+
1218
+ Object.defineProperty(exports, "__esModule", {
1219
+ value: true
1220
+ });
1221
+ exports.ActionCreators = exports.ActionTypes = void 0;
1222
+ var ActionTypes = {
1223
+ UNDO: '@@redux-undo/UNDO',
1224
+ REDO: '@@redux-undo/REDO',
1225
+ JUMP_TO_FUTURE: '@@redux-undo/JUMP_TO_FUTURE',
1226
+ JUMP_TO_PAST: '@@redux-undo/JUMP_TO_PAST',
1227
+ JUMP: '@@redux-undo/JUMP',
1228
+ CLEAR_HISTORY: '@@redux-undo/CLEAR_HISTORY'
1229
+ };
1230
+ exports.ActionTypes = ActionTypes;
1231
+ var ActionCreators = {
1232
+ undo: function undo() {
1233
+ return {
1234
+ type: ActionTypes.UNDO
1235
+ };
1236
+ },
1237
+ redo: function redo() {
1238
+ return {
1239
+ type: ActionTypes.REDO
1240
+ };
1241
+ },
1242
+ jumpToFuture: function jumpToFuture(index) {
1243
+ return {
1244
+ type: ActionTypes.JUMP_TO_FUTURE,
1245
+ index: index
1246
+ };
1247
+ },
1248
+ jumpToPast: function jumpToPast(index) {
1249
+ return {
1250
+ type: ActionTypes.JUMP_TO_PAST,
1251
+ index: index
1252
+ };
1253
+ },
1254
+ jump: function jump(index) {
1255
+ return {
1256
+ type: ActionTypes.JUMP,
1257
+ index: index
1258
+ };
1259
+ },
1260
+ clearHistory: function clearHistory() {
1261
+ return {
1262
+ type: ActionTypes.CLEAR_HISTORY
1263
+ };
1264
+ }
1265
+ };
1266
+ exports.ActionCreators = ActionCreators;
1267
+ });
1268
+
1269
+ var helpers = createCommonjsModule(function (module, exports) {
1270
+
1271
+ Object.defineProperty(exports, "__esModule", {
1272
+ value: true
1273
+ });
1274
+ exports.parseActions = parseActions;
1275
+ exports.isHistory = isHistory;
1276
+ exports.includeAction = includeAction;
1277
+ exports.excludeAction = excludeAction;
1278
+ exports.combineFilters = combineFilters;
1279
+ exports.groupByActionTypes = groupByActionTypes;
1280
+ exports.newHistory = newHistory;
1281
+
1282
+ // parseActions helper: takes a string (or array)
1283
+ // and makes it an array if it isn't yet
1284
+ function parseActions(rawActions) {
1285
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
1286
+
1287
+ if (Array.isArray(rawActions)) {
1288
+ return rawActions;
1289
+ } else if (typeof rawActions === 'string') {
1290
+ return [rawActions];
1291
+ }
1292
+
1293
+ return defaultValue;
1294
+ } // isHistory helper: check for a valid history object
1295
+
1296
+
1297
+ function isHistory(history) {
1298
+ return typeof history.present !== 'undefined' && typeof history.future !== 'undefined' && typeof history.past !== 'undefined' && Array.isArray(history.future) && Array.isArray(history.past);
1299
+ } // includeAction helper: whitelist actions to be added to the history
1300
+
1301
+
1302
+ function includeAction(rawActions) {
1303
+ var actions = parseActions(rawActions);
1304
+ return function (action) {
1305
+ return actions.indexOf(action.type) >= 0;
1306
+ };
1307
+ } // excludeAction helper: blacklist actions from being added to the history
1308
+
1309
+
1310
+ function excludeAction(rawActions) {
1311
+ var actions = parseActions(rawActions);
1312
+ return function (action) {
1313
+ return actions.indexOf(action.type) < 0;
1314
+ };
1315
+ } // combineFilters helper: combine multiple filters to one
1316
+
1317
+
1318
+ function combineFilters() {
1319
+ for (var _len = arguments.length, filters = new Array(_len), _key = 0; _key < _len; _key++) {
1320
+ filters[_key] = arguments[_key];
1321
+ }
1322
+
1323
+ return filters.reduce(function (prev, curr) {
1324
+ return function (action, currentState, previousHistory) {
1325
+ return prev(action, currentState, previousHistory) && curr(action, currentState, previousHistory);
1326
+ };
1327
+ }, function () {
1328
+ return true;
1329
+ });
1330
+ }
1331
+
1332
+ function groupByActionTypes(rawActions) {
1333
+ var actions = parseActions(rawActions);
1334
+ return function (action) {
1335
+ return actions.indexOf(action.type) >= 0 ? action.type : null;
1336
+ };
1337
+ }
1338
+
1339
+ function newHistory(past, present, future) {
1340
+ var group = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1341
+ return {
1342
+ past: past,
1343
+ present: present,
1344
+ future: future,
1345
+ group: group,
1346
+ _latestUnfiltered: present,
1347
+ index: past.length,
1348
+ limit: past.length + future.length + 1
1349
+ };
1350
+ }
1351
+ });
1352
+
1353
+ var debug = createCommonjsModule(function (module, exports) {
1354
+
1355
+ Object.defineProperty(exports, "__esModule", {
1356
+ value: true
1357
+ });
1358
+ exports.set = set;
1359
+ exports.start = start;
1360
+ exports.end = end;
1361
+ exports.log = log;
1362
+
1363
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1364
+
1365
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
1366
+
1367
+ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
1368
+
1369
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
1370
+
1371
+ var __DEBUG__;
1372
+
1373
+ var displayBuffer;
1374
+ var colors = {
1375
+ prevState: '#9E9E9E',
1376
+ action: '#03A9F4',
1377
+ nextState: '#4CAF50'
1378
+ };
1379
+ /* istanbul ignore next: debug messaging is not tested */
1380
+
1381
+ function initBuffer() {
1382
+ displayBuffer = {
1383
+ header: [],
1384
+ prev: [],
1385
+ action: [],
1386
+ next: [],
1387
+ msgs: []
1388
+ };
1389
+ }
1390
+ /* istanbul ignore next: debug messaging is not tested */
1391
+
1392
+
1393
+ function printBuffer() {
1394
+ var _displayBuffer = displayBuffer,
1395
+ header = _displayBuffer.header,
1396
+ prev = _displayBuffer.prev,
1397
+ next = _displayBuffer.next,
1398
+ action = _displayBuffer.action,
1399
+ msgs = _displayBuffer.msgs;
1400
+
1401
+ if (console.group) {
1402
+ var _console, _console2, _console3, _console4, _console5;
1403
+
1404
+ (_console = console).groupCollapsed.apply(_console, _toConsumableArray(header));
1405
+
1406
+ (_console2 = console).log.apply(_console2, _toConsumableArray(prev));
1407
+
1408
+ (_console3 = console).log.apply(_console3, _toConsumableArray(action));
1409
+
1410
+ (_console4 = console).log.apply(_console4, _toConsumableArray(next));
1411
+
1412
+ (_console5 = console).log.apply(_console5, _toConsumableArray(msgs));
1413
+
1414
+ console.groupEnd();
1415
+ } else {
1416
+ var _console6, _console7, _console8, _console9, _console10;
1417
+
1418
+ (_console6 = console).log.apply(_console6, _toConsumableArray(header));
1419
+
1420
+ (_console7 = console).log.apply(_console7, _toConsumableArray(prev));
1421
+
1422
+ (_console8 = console).log.apply(_console8, _toConsumableArray(action));
1423
+
1424
+ (_console9 = console).log.apply(_console9, _toConsumableArray(next));
1425
+
1426
+ (_console10 = console).log.apply(_console10, _toConsumableArray(msgs));
1427
+ }
1428
+ }
1429
+ /* istanbul ignore next: debug messaging is not tested */
1430
+
1431
+
1432
+ function colorFormat(text, color, obj) {
1433
+ return ["%c".concat(text), "color: ".concat(color, "; font-weight: bold"), obj];
1434
+ }
1435
+ /* istanbul ignore next: debug messaging is not tested */
1436
+
1437
+
1438
+ function start(action, state) {
1439
+ initBuffer();
1440
+
1441
+ if (__DEBUG__) {
1442
+ if (console.group) {
1443
+ displayBuffer.header = ['%credux-undo', 'font-style: italic', 'action', action.type];
1444
+ displayBuffer.action = colorFormat('action', colors.action, action);
1445
+ displayBuffer.prev = colorFormat('prev history', colors.prevState, state);
1446
+ } else {
1447
+ displayBuffer.header = ['redux-undo action', action.type];
1448
+ displayBuffer.action = ['action', action];
1449
+ displayBuffer.prev = ['prev history', state];
1450
+ }
1451
+ }
1452
+ }
1453
+ /* istanbul ignore next: debug messaging is not tested */
1454
+
1455
+
1456
+ function end(nextState) {
1457
+ if (__DEBUG__) {
1458
+ if (console.group) {
1459
+ displayBuffer.next = colorFormat('next history', colors.nextState, nextState);
1460
+ } else {
1461
+ displayBuffer.next = ['next history', nextState];
1462
+ }
1463
+
1464
+ printBuffer();
1465
+ }
1466
+ }
1467
+ /* istanbul ignore next: debug messaging is not tested */
1468
+
1469
+
1470
+ function log() {
1471
+ if (__DEBUG__) {
1472
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1473
+ args[_key] = arguments[_key];
1474
+ }
1475
+
1476
+ displayBuffer.msgs = displayBuffer.msgs.concat([].concat(args, ['\n']));
1477
+ }
1478
+ }
1479
+ /* istanbul ignore next: debug messaging is not tested */
1480
+
1481
+
1482
+ function set(debug) {
1483
+ __DEBUG__ = debug;
1484
+ }
1485
+ });
1486
+
1487
+ var reducer = createCommonjsModule(function (module, exports) {
1488
+
1489
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1490
+
1491
+ Object.defineProperty(exports, "__esModule", {
1492
+ value: true
1493
+ });
1494
+ exports["default"] = undoable;
1495
+
1496
+ var debug$1 = _interopRequireWildcard(debug);
1497
+
1498
+
1499
+
1500
+
1501
+
1502
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
1503
+
1504
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1505
+
1506
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
1507
+
1508
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
1509
+
1510
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1511
+
1512
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
1513
+
1514
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
1515
+
1516
+ function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
1517
+
1518
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
1519
+
1520
+ function createHistory(state, ignoreInitialState) {
1521
+ // ignoreInitialState essentially prevents the user from undoing to the
1522
+ // beginning, in the case that the undoable reducer handles initialization
1523
+ // in a way that can't be redone simply
1524
+ var history = (0, helpers.newHistory)([], state, []);
1525
+
1526
+ if (ignoreInitialState) {
1527
+ history._latestUnfiltered = null;
1528
+ }
1529
+
1530
+ return history;
1531
+ } // insert: insert `state` into history, which means adding the current state
1532
+ // into `past`, setting the new `state` as `present` and erasing
1533
+ // the `future`.
1534
+
1535
+
1536
+ function insert(history, state, limit, group) {
1537
+ var lengthWithoutFuture = history.past.length + 1;
1538
+ debug$1.log('inserting', state);
1539
+ debug$1.log('new free: ', limit - lengthWithoutFuture);
1540
+ var past = history.past,
1541
+ _latestUnfiltered = history._latestUnfiltered;
1542
+ var isHistoryOverflow = limit && limit <= lengthWithoutFuture;
1543
+ var pastSliced = past.slice(isHistoryOverflow ? 1 : 0);
1544
+ var newPast = _latestUnfiltered != null ? [].concat(_toConsumableArray(pastSliced), [_latestUnfiltered]) : pastSliced;
1545
+ return (0, helpers.newHistory)(newPast, state, [], group);
1546
+ } // jumpToFuture: jump to requested index in future history
1547
+
1548
+
1549
+ function jumpToFuture(history, index) {
1550
+ if (index < 0 || index >= history.future.length) return history;
1551
+ var past = history.past,
1552
+ future = history.future,
1553
+ _latestUnfiltered = history._latestUnfiltered;
1554
+ var newPast = [].concat(_toConsumableArray(past), [_latestUnfiltered], _toConsumableArray(future.slice(0, index)));
1555
+ var newPresent = future[index];
1556
+ var newFuture = future.slice(index + 1);
1557
+ return (0, helpers.newHistory)(newPast, newPresent, newFuture);
1558
+ } // jumpToPast: jump to requested index in past history
1559
+
1560
+
1561
+ function jumpToPast(history, index) {
1562
+ if (index < 0 || index >= history.past.length) return history;
1563
+ var past = history.past,
1564
+ future = history.future,
1565
+ _latestUnfiltered = history._latestUnfiltered;
1566
+ var newPast = past.slice(0, index);
1567
+ var newFuture = [].concat(_toConsumableArray(past.slice(index + 1)), [_latestUnfiltered], _toConsumableArray(future));
1568
+ var newPresent = past[index];
1569
+ return (0, helpers.newHistory)(newPast, newPresent, newFuture);
1570
+ } // jump: jump n steps in the past or forward
1571
+
1572
+
1573
+ function jump(history, n) {
1574
+ if (n > 0) return jumpToFuture(history, n - 1);
1575
+ if (n < 0) return jumpToPast(history, history.past.length + n);
1576
+ return history;
1577
+ } // helper to dynamically match in the reducer's switch-case
1578
+
1579
+
1580
+ function actionTypeAmongClearHistoryType(actionType, clearHistoryType) {
1581
+ return clearHistoryType.indexOf(actionType) > -1 ? actionType : !actionType;
1582
+ } // redux-undo higher order reducer
1583
+
1584
+
1585
+ function undoable(reducer) {
1586
+ var rawConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1587
+ debug$1.set(rawConfig.debug);
1588
+
1589
+ var config = _objectSpread({
1590
+ limit: undefined,
1591
+ filter: function filter() {
1592
+ return true;
1593
+ },
1594
+ groupBy: function groupBy() {
1595
+ return null;
1596
+ },
1597
+ undoType: actions.ActionTypes.UNDO,
1598
+ redoType: actions.ActionTypes.REDO,
1599
+ jumpToPastType: actions.ActionTypes.JUMP_TO_PAST,
1600
+ jumpToFutureType: actions.ActionTypes.JUMP_TO_FUTURE,
1601
+ jumpType: actions.ActionTypes.JUMP,
1602
+ neverSkipReducer: false,
1603
+ ignoreInitialState: false,
1604
+ syncFilter: false
1605
+ }, rawConfig, {
1606
+ initTypes: (0, helpers.parseActions)(rawConfig.initTypes, ['@@redux-undo/INIT']),
1607
+ clearHistoryType: (0, helpers.parseActions)(rawConfig.clearHistoryType, [actions.ActionTypes.CLEAR_HISTORY])
1608
+ }); // Allows the user to call the reducer with redux-undo specific actions
1609
+
1610
+
1611
+ var skipReducer = config.neverSkipReducer ? function (res, action) {
1612
+ for (var _len = arguments.length, slices = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1613
+ slices[_key - 2] = arguments[_key];
1614
+ }
1615
+
1616
+ return _objectSpread({}, res, {
1617
+ present: reducer.apply(void 0, [res.present, action].concat(slices))
1618
+ });
1619
+ } : function (res) {
1620
+ return res;
1621
+ };
1622
+ var initialState;
1623
+ return function () {
1624
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
1625
+ var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1626
+ debug$1.start(action, state);
1627
+ var history = state;
1628
+
1629
+ for (var _len2 = arguments.length, slices = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
1630
+ slices[_key2 - 2] = arguments[_key2];
1631
+ }
1632
+
1633
+ if (!initialState) {
1634
+ debug$1.log('history is uninitialized');
1635
+
1636
+ if (state === undefined) {
1637
+ var createHistoryAction = {
1638
+ type: '@@redux-undo/CREATE_HISTORY'
1639
+ };
1640
+ var start = reducer.apply(void 0, [state, createHistoryAction].concat(slices));
1641
+ history = createHistory(start, config.ignoreInitialState);
1642
+ debug$1.log('do not set initialState on probe actions');
1643
+ debug$1.end(history);
1644
+ return history;
1645
+ } else if ((0, helpers.isHistory)(state)) {
1646
+ history = initialState = config.ignoreInitialState ? state : (0, helpers.newHistory)(state.past, state.present, state.future);
1647
+ debug$1.log('initialHistory initialized: initialState is a history', initialState);
1648
+ } else {
1649
+ history = initialState = createHistory(state, config.ignoreInitialState);
1650
+ debug$1.log('initialHistory initialized: initialState is not a history', initialState);
1651
+ }
1652
+ }
1653
+
1654
+ var res;
1655
+
1656
+ switch (action.type) {
1657
+ case undefined:
1658
+ return history;
1659
+
1660
+ case config.undoType:
1661
+ res = jump(history, -1);
1662
+ debug$1.log('perform undo');
1663
+ debug$1.end(res);
1664
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1665
+
1666
+ case config.redoType:
1667
+ res = jump(history, 1);
1668
+ debug$1.log('perform redo');
1669
+ debug$1.end(res);
1670
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1671
+
1672
+ case config.jumpToPastType:
1673
+ res = jumpToPast(history, action.index);
1674
+ debug$1.log("perform jumpToPast to ".concat(action.index));
1675
+ debug$1.end(res);
1676
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1677
+
1678
+ case config.jumpToFutureType:
1679
+ res = jumpToFuture(history, action.index);
1680
+ debug$1.log("perform jumpToFuture to ".concat(action.index));
1681
+ debug$1.end(res);
1682
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1683
+
1684
+ case config.jumpType:
1685
+ res = jump(history, action.index);
1686
+ debug$1.log("perform jump to ".concat(action.index));
1687
+ debug$1.end(res);
1688
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1689
+
1690
+ case actionTypeAmongClearHistoryType(action.type, config.clearHistoryType):
1691
+ res = createHistory(history.present, config.ignoreInitialState);
1692
+ debug$1.log('perform clearHistory');
1693
+ debug$1.end(res);
1694
+ return skipReducer.apply(void 0, [res, action].concat(slices));
1695
+
1696
+ default:
1697
+ res = reducer.apply(void 0, [history.present, action].concat(slices));
1698
+
1699
+ if (config.initTypes.some(function (actionType) {
1700
+ return actionType === action.type;
1701
+ })) {
1702
+ debug$1.log('reset history due to init action');
1703
+ debug$1.end(initialState);
1704
+ return initialState;
1705
+ }
1706
+
1707
+ if (history._latestUnfiltered === res) {
1708
+ // Don't handle this action. Do not call debug.end here,
1709
+ // because this action should not produce side effects to the console
1710
+ return history;
1711
+ }
1712
+ /* eslint-disable-next-line no-case-declarations */
1713
+
1714
+
1715
+ var filtered = typeof config.filter === 'function' && !config.filter(action, res, history);
1716
+
1717
+ if (filtered) {
1718
+ // if filtering an action, merely update the present
1719
+ var filteredState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
1720
+
1721
+ if (!config.syncFilter) {
1722
+ filteredState._latestUnfiltered = history._latestUnfiltered;
1723
+ }
1724
+
1725
+ debug$1.log('filter ignored action, not storing it in past');
1726
+ debug$1.end(filteredState);
1727
+ return filteredState;
1728
+ }
1729
+ /* eslint-disable-next-line no-case-declarations */
1730
+
1731
+
1732
+ var group = config.groupBy(action, res, history);
1733
+
1734
+ if (group != null && group === history.group) {
1735
+ // if grouping with the previous action, only update the present
1736
+ var groupedState = (0, helpers.newHistory)(history.past, res, history.future, history.group);
1737
+ debug$1.log('groupBy grouped the action with the previous action');
1738
+ debug$1.end(groupedState);
1739
+ return groupedState;
1740
+ } // If the action wasn't filtered or grouped, insert normally
1741
+
1742
+
1743
+ history = insert(history, res, config.limit, group);
1744
+ debug$1.log('inserted new state into history');
1745
+ debug$1.end(history);
1746
+ return history;
1747
+ }
1748
+ };
1749
+ }
1750
+ });
1751
+
1752
+ var lib = createCommonjsModule(function (module, exports) {
1753
+
1754
+ Object.defineProperty(exports, "__esModule", {
1755
+ value: true
1756
+ });
1757
+ Object.defineProperty(exports, "ActionTypes", {
1758
+ enumerable: true,
1759
+ get: function get() {
1760
+ return actions.ActionTypes;
1761
+ }
1762
+ });
1763
+ Object.defineProperty(exports, "ActionCreators", {
1764
+ enumerable: true,
1765
+ get: function get() {
1766
+ return actions.ActionCreators;
1767
+ }
1768
+ });
1769
+ Object.defineProperty(exports, "parseActions", {
1770
+ enumerable: true,
1771
+ get: function get() {
1772
+ return helpers.parseActions;
1773
+ }
1774
+ });
1775
+ Object.defineProperty(exports, "isHistory", {
1776
+ enumerable: true,
1777
+ get: function get() {
1778
+ return helpers.isHistory;
1779
+ }
1780
+ });
1781
+ Object.defineProperty(exports, "includeAction", {
1782
+ enumerable: true,
1783
+ get: function get() {
1784
+ return helpers.includeAction;
1785
+ }
1786
+ });
1787
+ Object.defineProperty(exports, "excludeAction", {
1788
+ enumerable: true,
1789
+ get: function get() {
1790
+ return helpers.excludeAction;
1791
+ }
1792
+ });
1793
+ Object.defineProperty(exports, "combineFilters", {
1794
+ enumerable: true,
1795
+ get: function get() {
1796
+ return helpers.combineFilters;
1797
+ }
1798
+ });
1799
+ Object.defineProperty(exports, "groupByActionTypes", {
1800
+ enumerable: true,
1801
+ get: function get() {
1802
+ return helpers.groupByActionTypes;
1803
+ }
1804
+ });
1805
+ Object.defineProperty(exports, "newHistory", {
1806
+ enumerable: true,
1807
+ get: function get() {
1808
+ return helpers.newHistory;
1809
+ }
1810
+ });
1811
+ Object.defineProperty(exports, "default", {
1812
+ enumerable: true,
1813
+ get: function get() {
1814
+ return _reducer["default"];
1815
+ }
1816
+ });
1817
+
1818
+
1819
+
1820
+
1821
+
1822
+ var _reducer = _interopRequireDefault(reducer);
1823
+
1824
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
1825
+ });
1826
+
1827
+ const undoable = /*@__PURE__*/getDefaultExportFromCjs(lib);
1828
+
1829
+ const inicialHistState = {
1830
+ currentTabIndex: {},
1831
+ currentRecordIndex: {},
1832
+ changes: {},
1833
+ collapsedGroups: {},
1834
+ newRecordIndex: {}
1835
+ };
1836
+ const inicialNonHistState = {
1837
+ dataLoading: {},
1838
+ invalidFields: {},
1839
+ visibleButtons: {
1840
+ previousVisible: true,
1841
+ nextVisible: true,
1842
+ addVisible: true,
1843
+ removeVisible: true,
1844
+ saveVisible: true,
1845
+ cancelVisible: true,
1846
+ reloadVisible: true
1847
+ }
1848
+ };
1849
+ function formReducer(state = inicialHistState, action) {
1850
+ switch (action.type) {
1851
+ case 'FORM/COLLAPSEGROUP':
1852
+ return collapseGroup(state, action.payload);
1853
+ case 'FORM/CHANGETAB':
1854
+ return changeTab(state, action.payload.formId, action.payload.index);
1855
+ case 'FORM/NAVIGATE':
1856
+ return navigate(state, action.payload);
1857
+ case 'FORM/INSERT':
1858
+ return insertRecord(state, action.payload);
1859
+ case 'FORM/CHANGEFIELD':
1860
+ return changeFieldValue(state, action.payload);
1861
+ case 'FORM/CLEAREDITION':
1862
+ return clearEdition(state, action.payload);
1863
+ case 'FORM/INVALIDFIELD':
1864
+ return navigateToInvalid(state, action.payload);
1865
+ default:
1866
+ return state;
1867
+ }
1868
+ }
1869
+ function formNonHistoricReducer(state = inicialNonHistState, action) {
1870
+ switch (action.type) {
1871
+ case 'FORM/DATALOADING':
1872
+ return dataLoading(state, action.payload);
1873
+ case 'FORM/DATALOADED':
1874
+ return dataLoaded(state, action.payload);
1875
+ case 'FORM/SAVINGCHANGES':
1876
+ return savingChanges(state, action.payload);
1877
+ case 'FORM/CHANGESSAVED':
1878
+ return changesSaved(state, action.payload);
1879
+ case 'FORM/REMOVINGRECORD':
1880
+ return removingRecord(state, action.payload);
1881
+ case 'FORM/RECORDREMOVED':
1882
+ return recordRemoved(state, action.payload);
1883
+ case 'FORM/INVALIDFIELD':
1884
+ return invalidField(state, action.payload);
1885
+ case 'FORM/CLEAREDITION':
1886
+ return clearAllInvalidFields(state, action.payload);
1887
+ case 'FORM/CHANGEFIELD':
1888
+ return clearInvalidField(state, action.payload);
1889
+ case 'FORM/SHOWHIDENAVBTN':
1890
+ return showHideNavBtn(state, action.payload);
1891
+ default:
1892
+ return state;
1893
+ }
1894
+ }
1895
+ function collapseGroup(state, { collapseId, collapsed }) {
1896
+ const currentCollapsed = Object.assign({}, state.collapsedGroups);
1897
+ if (collapsed) {
1898
+ currentCollapsed[collapseId] = true;
1899
+ }
1900
+ else {
1901
+ delete currentCollapsed[collapseId];
1902
+ }
1903
+ return Object.assign(Object.assign({}, state), { collapsedGroups: currentCollapsed });
1904
+ }
1905
+ function changeTab(state, formId, index) {
1906
+ const currentTabIndex = Object.assign({}, state.currentTabIndex);
1907
+ currentTabIndex[formId] = index;
1908
+ return Object.assign(Object.assign({}, state), { currentTabIndex });
1909
+ }
1910
+ function navigate(state, { dataUnit, limit, backward }) {
1911
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1912
+ const recIndex = currentRecordIndex[dataUnit] || 0;
1913
+ return gotoIndex(state, dataUnit, backward ? Math.max(limit, recIndex - 1) : Math.min(limit, recIndex + 1));
1914
+ }
1915
+ function gotoIndex(state, dataUnit, index) {
1916
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1917
+ currentRecordIndex[dataUnit] = index;
1918
+ return Object.assign(Object.assign({}, state), { currentRecordIndex });
1919
+ }
1920
+ function insertRecord(state, { dataUnit, insertionIndex }) {
1921
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1922
+ const newRecordIndex = Object.assign({}, state.newRecordIndex);
1923
+ currentRecordIndex[dataUnit] = insertionIndex;
1924
+ newRecordIndex[dataUnit] = (state.newRecordIndex[dataUnit] || 0) + 1;
1925
+ return Object.assign(Object.assign({}, state), { currentRecordIndex,
1926
+ newRecordIndex });
1927
+ }
1928
+ function changeFieldValue(state, { dataUnit, recordId, fieldName, value }) {
1929
+ const changes = Object.assign({}, state.changes);
1930
+ const dataUnitChanges = Object.assign({}, changes[dataUnit]);
1931
+ const recordChanges = Object.assign({}, dataUnitChanges[recordId]);
1932
+ recordChanges[fieldName] = value;
1933
+ dataUnitChanges[recordId] = recordChanges;
1934
+ changes[dataUnit] = dataUnitChanges;
1935
+ const invalidFields = Object.assign({}, state.invalidFields);
1936
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1937
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1938
+ delete errorMessages[fieldName];
1939
+ dataUnitInvalidRecords[recordId] = errorMessages;
1940
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
1941
+ return Object.assign(Object.assign({}, state), { changes,
1942
+ invalidFields, invalidFieldSelected: undefined });
1943
+ }
1944
+ function clearEdition(state, { dataUnit, recordsLimit }) {
1945
+ const changes = Object.assign({}, state.changes);
1946
+ const newRecordIndex = Object.assign({}, state.newRecordIndex);
1947
+ const currentRecordIndex = Object.assign({}, state.currentRecordIndex);
1948
+ delete changes[dataUnit];
1949
+ delete newRecordIndex[dataUnit];
1950
+ const recIndex = currentRecordIndex[dataUnit] || 0;
1951
+ currentRecordIndex[dataUnit] = Math.min(recordsLimit, recIndex);
1952
+ return Object.assign(Object.assign({}, state), { changes,
1953
+ newRecordIndex,
1954
+ currentRecordIndex });
1955
+ }
1956
+ function navigateToInvalid(state, payload) {
1957
+ let newState = Object.assign({}, state);
1958
+ if (newState.invalidFieldSelected === undefined) {
1959
+ newState.invalidFieldSelected = true;
1960
+ newState = gotoIndex(newState, payload.dataUnit, payload.recordIndex);
1961
+ newState = changeTab(newState, payload.tabController, payload.tabIndex);
1962
+ }
1963
+ return newState;
1964
+ }
1965
+ function dataLoading(state, { dataUnit }) {
1966
+ const dataLoading = Object.assign({}, state.dataLoading);
1967
+ dataLoading[dataUnit] = true;
1968
+ return Object.assign(Object.assign({}, state), { dataLoading });
1969
+ }
1970
+ function dataLoaded(state, { dataUnit }) {
1971
+ const dataLoading = Object.assign({}, state.dataLoading);
1972
+ delete dataLoading[dataUnit];
1973
+ return Object.assign(Object.assign({}, state), { dataLoading });
1974
+ }
1975
+ function savingChanges(state, { dataUnit }) {
1976
+ const dataLoading = Object.assign({}, state.dataLoading);
1977
+ dataLoading[dataUnit] = true;
1978
+ return Object.assign(Object.assign({}, state), { dataLoading });
1979
+ }
1980
+ function changesSaved(state, { dataUnit }) {
1981
+ const dataLoading = Object.assign({}, state.dataLoading);
1982
+ delete dataLoading[dataUnit];
1983
+ return Object.assign(Object.assign({}, state), { dataLoading });
1984
+ }
1985
+ function removingRecord(state, { dataUnit }) {
1986
+ const dataLoading = Object.assign({}, state.dataLoading);
1987
+ dataLoading[dataUnit] = true;
1988
+ return Object.assign(Object.assign({}, state), { dataLoading });
1989
+ }
1990
+ function recordRemoved(state, { dataUnit }) {
1991
+ const dataLoading = Object.assign({}, state.dataLoading);
1992
+ delete dataLoading[dataUnit];
1993
+ return Object.assign(Object.assign({}, state), { dataLoading });
1994
+ }
1995
+ function invalidField(state, { dataUnit, recordId, fieldName, errorMessage }) {
1996
+ const invalidFields = Object.assign({}, state.invalidFields);
1997
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
1998
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
1999
+ errorMessages[fieldName] = errorMessage;
2000
+ dataUnitInvalidRecords[recordId] = errorMessages;
2001
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
2002
+ return Object.assign(Object.assign({}, state), { invalidFields });
2003
+ }
2004
+ function clearAllInvalidFields(state, { dataUnit }) {
2005
+ const invalidFields = Object.assign({}, state.invalidFields);
2006
+ delete invalidFields[dataUnit];
2007
+ return Object.assign(Object.assign({}, state), { invalidFields });
2008
+ }
2009
+ function clearInvalidField(state, { dataUnit, recordId, fieldName }) {
2010
+ const invalidFields = Object.assign({}, state.invalidFields);
2011
+ const dataUnitInvalidRecords = Object.assign({}, invalidFields[dataUnit]);
2012
+ const errorMessages = Object.assign({}, dataUnitInvalidRecords[recordId]);
2013
+ delete errorMessages[fieldName];
2014
+ dataUnitInvalidRecords[recordId] = errorMessages;
2015
+ invalidFields[dataUnit] = dataUnitInvalidRecords;
2016
+ return Object.assign(Object.assign({}, state), { invalidFields });
2017
+ }
2018
+ function showHideNavBtn(state, { buttonName, status }) {
2019
+ const visibleButtons = Object.assign({}, state.visibleButtons);
2020
+ visibleButtons[buttonName] = status;
2021
+ return Object.assign(Object.assign({}, state), { visibleButtons });
2022
+ }
2023
+
2024
+ function removeHandler(dataUnit) {
2025
+ if (confirm("Tem certeza que deseja Remover?")) {
2026
+ dataUnit.remove();
2027
+ }
2028
+ }
2029
+ const NavigationBar = ({ dataUnit: du, buttonProps }) => {
2030
+ if (buttonProps.previousVisible
2031
+ || buttonProps.nextVisible
2032
+ || buttonProps.addVisible
2033
+ || buttonProps.removeVisible
2034
+ || buttonProps.saveVisible
2035
+ || buttonProps.cancelVisible
2036
+ || buttonProps.reloadVisible) {
2037
+ return index.h("div", { class: "col col--sd-12 align--right" },
2038
+ buttonProps.previousVisible ? index.h("ez-button", { title: "Registro anterior", mode: "icon", enabled: du.hasPrevious(), onClick: () => du.previous(), image: "/themes/default/images/icons/actions-sprite.svg#previous-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2039
+ buttonProps.nextVisible ? index.h("ez-button", { title: "Pr\u00F3ximo registro", mode: "icon", enabled: du.hasNext(), onClick: () => du.next(), image: "/themes/default/images/icons/actions-sprite.svg#next-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2040
+ buttonProps.removeVisible ? index.h("ez-button", { title: "Remover " + du.unitLabel, mode: "icon", enabled: du.hasCurrentRecord(), onClick: () => removeHandler(du), image: "/themes/default/images/icons/actions-sprite.svg#minus-circle-inverted", class: "button--secondary margin-right--medium" }) : null,
2041
+ buttonProps.addVisible ? index.h("ez-button", { label: "Criar " + du.unitLabel, onClick: () => du.insert(), class: "button--secondary margin-right--medium" }) : null,
2042
+ buttonProps.reloadVisible ? index.h("ez-button", { title: "Recarregar", mode: "icon", onClick: () => du.load(), image: "/themes/default/images/icons/actions-sprite.svg#rotate", class: "button--secondary margin-right--medium" }) : null,
2043
+ buttonProps.cancelVisible ? index.h("ez-button", { label: "Cancelar", enabled: du.hasChanges(), onClick: () => du.cancel(), class: "button--secondary margin-right--medium" }) : null,
2044
+ buttonProps.saveVisible ? index.h("ez-button", { label: "Salvar", enabled: du.hasChanges(), onClick: () => du.save(), class: "button--primary margin-right--medium" }) : null);
2045
+ }
2046
+ else {
2047
+ return null;
2048
+ }
2049
+ };
2050
+
2051
+ var DependencyType;
2052
+ (function (DependencyType) {
2053
+ DependencyType["SEARCHING"] = "SEARCHING";
2054
+ DependencyType["REQUIREMENT"] = "REQUIREMENT";
2055
+ DependencyType["VISIBILITY"] = "REQUIREMENT";
2056
+ })(DependencyType || (DependencyType = {}));
2057
+
2058
+ function scrollToView(forceScroll, elem) {
2059
+ if (forceScroll) {
2060
+ window.requestAnimationFrame(() => elem.scrollIntoView());
2061
+ }
2062
+ }
2063
+ const Field = ({ dataUnit, source, forceScroll }) => {
2064
+ const { name, label, userInterface, properties, required, dependencies } = source;
2065
+ const value = dataUnit.getValue(name) || null;
2066
+ const loadingData = dataUnit.isLoading();
2067
+ const formattedLabel = required ? `* ${label} (obrigatório)` : label;
2068
+ const errorMessage = dataUnit.getErrorMessage(name);
2069
+ const changeFieldHandler = (newValue) => {
2070
+ dataUnit.changeValue(name, newValue);
2071
+ };
2072
+ switch (userInterface) {
2073
+ case 'LONGTEXT':
2074
+ return index.h("div", { class: "col col--sd-12 padding--small" },
2075
+ index.h("ez-text-area", { label: formattedLabel, onInput: evt => changeFieldHandler(evt.target['value']), value: value || '', errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2076
+ case 'CHECKBOX':
2077
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2078
+ index.h("ez-check", { onInput: evt => changeFieldHandler(evt.target['value']), ref: elem => scrollToView(forceScroll, elem) }));
2079
+ case 'SWITCH':
2080
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2081
+ index.h("div", { class: "row" },
2082
+ index.h("div", { class: "col col--sd-2" },
2083
+ index.h("ez-check", { mode: "switch", value: value === "S", ref: elem => scrollToView(forceScroll, elem) })),
2084
+ index.h("div", { class: "col col--sd-10" },
2085
+ index.h("label", { class: "text text--primary text--medium" }, label))));
2086
+ case 'OPTIONSELECTOR':
2087
+ const optsObj = JSON.parse(properties.find(prop => prop.name === 'options').value);
2088
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2089
+ index.h("ez-combo-box", { value: value, label: formattedLabel, onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }, Object.keys(optsObj).map(key => index.h("option", { value: key }, optsObj[key]))));
2090
+ case 'SEARCH':
2091
+ const context = {};
2092
+ properties.forEach(({ name, value }) => {
2093
+ context[name] = value;
2094
+ });
2095
+ let criteriaList = [];
2096
+ dependencies === null || dependencies === void 0 ? void 0 : dependencies.forEach(dependency => {
2097
+ var _a;
2098
+ if (dependency.type === DependencyType.SEARCHING) {
2099
+ if (((_a = dependency.masterFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
2100
+ let criteria = {
2101
+ expression: dependency.expression,
2102
+ paramNames: [...dependency.masterFields],
2103
+ paramResolver: name => dataUnit.getValue(name)
2104
+ };
2105
+ criteriaList.push(criteria);
2106
+ }
2107
+ }
2108
+ });
2109
+ if (criteriaList.length > 0) {
2110
+ context['CRITERIA'] = criteriaList;
2111
+ }
2112
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2113
+ index.h("ez-search", { label: label, onEzChange: (event) => changeFieldHandler(event.target['value']), showvalue: true, value: value, loadexecutor: (argument, callback) => dataUnit.fieldSearchExecutor(argument, context, callback) }));
2114
+ case 'DATE':
2115
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" },
2116
+ index.h("ez-date-input", { label: formattedLabel, enabled: true, value: !value ? null : DateUtils.clearTime(value), onEzChange: (event) => changeFieldHandler(event.target['value']), errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2117
+ //IMAGE, FILE, DATE, DATETIME, ELAPSEDTIME, DECIMALNUMBER, INTEGERNUMBER, PASSWORD, MASKEDTEXT, HTML
2118
+ default:
2119
+ return index.h("div", { class: "col col--sd-12 col--tb-3 padding--small" }, loadingData
2120
+ ?
2121
+ index.h("place-holder", null)
2122
+ :
2123
+ index.h("ez-text-input", { loading: loadingData, label: formattedLabel, onInput: (event) => changeFieldHandler(event.target['value']), value: value, errormessage: errorMessage, ref: elem => scrollToView(forceScroll, elem) }));
2124
+ }
2125
+ };
2126
+
2127
+ const FieldSet = ({ store, formName, source, dataUnit }) => {
2128
+ const { label, fields } = source;
2129
+ const fieldSetName = formName + label;
2130
+ let isCollapsed = DataUnit.selectIsCollapsedFieldSet(store.getState(), formName + label);
2131
+ let fieldToScroll;
2132
+ source.fields.forEach((field) => {
2133
+ if (fieldToScroll === undefined) {
2134
+ const fieldError = dataUnit.getErrorMessage(field.name);
2135
+ if (fieldError !== undefined && fieldError !== null && fieldError !== "") {
2136
+ fieldToScroll = field.name;
2137
+ }
2138
+ }
2139
+ });
2140
+ if (fieldToScroll) {
2141
+ isCollapsed = false;
2142
+ }
2143
+ return index.h("div", { class: "col col--sd-12 padding--small" },
2144
+ index.h("div", { class: "row margin-top--large" },
2145
+ index.h("div", { class: "col col--sd-12 align--middle padding-horizontal--medium" },
2146
+ index.h("ez-collapsable-box", { value: isCollapsed, label: label, onEzChange: () => store.dispatch(DataUnit.collapseExpandGroup(fieldSetName, !isCollapsed)) }),
2147
+ isCollapsed ? null :
2148
+ index.h("div", { class: "col col--sd-12" }, fields.map(field => index.h(Field, { source: field, dataUnit: dataUnit, forceScroll: fieldToScroll === field.name }))))));
2149
+ };
2150
+
2151
+ function buildFormItem(source, formName, store, dataUnit) {
2152
+ if ("fields" in source) {
2153
+ return index.h(FieldSet, { source: source, store: store, formName: formName, dataUnit: dataUnit });
2154
+ }
2155
+ const errorMsg = dataUnit.getErrorMessage(source.name);
2156
+ const forceScroll = errorMsg === undefined || errorMsg === null || errorMsg === "" ? false : true;
2157
+ return index.h(Field, { source: source, dataUnit: dataUnit, forceScroll: forceScroll });
2158
+ }
2159
+ const FormSheet = ({ store, parentName, source, parentDataUnit, dataUnitBuilder }) => {
2160
+ const selectedTab = DataUnit.selectCurrentTab(store.getState(), parentName);
2161
+ const tabs = source.length > 1 ? source.map(form => index.h("ez-tab", { label: form.label, tabKey: form.name })) : null;
2162
+ const { subForms, items, name } = source[selectedTab];
2163
+ const dataUnit = dataUnitBuilder(source[selectedTab].dataUnit);
2164
+ source[selectedTab].dataUnit = dataUnit;
2165
+ const hasSubForms = subForms && subForms.length > 0;
2166
+ const changeTabHandler = (index) => {
2167
+ store.dispatch(DataUnit.changeTab(parentName, index));
2168
+ };
2169
+ //todos os campos e subformulários precisam estar ligados a um DU
2170
+ const currentDU = dataUnit || parentDataUnit;
2171
+ let buttons = DataUnit.selectVisibleButtons(store.getState());
2172
+ if (currentDU.cardinality === "1") {
2173
+ buttons.addVisible = false;
2174
+ buttons.removeVisible = false;
2175
+ buttons.nextVisible = false;
2176
+ buttons.previousVisible = false;
2177
+ }
2178
+ return index.h("div", { class: "form-sheet" },
2179
+ tabs ? index.h("ez-tabselector", { selectedindex: selectedTab, selectedtab: name, onChange: (evt) => changeTabHandler(evt.target.selectedindex) }, tabs) : null,
2180
+ dataUnit ? index.h(NavigationBar, { dataUnit: dataUnit, buttonProps: buttons }) : null,
2181
+ index.h("div", { class: "tab__container" },
2182
+ items ? items.map(item => buildFormItem(item, name, store, currentDU)) : null,
2183
+ hasSubForms ? index.h(FormSheet, { store: store, source: subForms, parentName: name, parentDataUnit: currentDU, dataUnitBuilder: dataUnitBuilder }) : null));
2184
+ };
2185
+
2186
+ const ezFormCss = "ez-form{display:flex;flex-direction:column;width:100%}.form-sheet{display:flex;width:100%;flex-wrap:wrap;position:relative}.tab__container{display:flex;width:100%;flex-wrap:wrap;position:relative}";
2187
+
2188
+ const EzForm = class {
2189
+ constructor(hostRef) {
2190
+ index.registerInstance(this, hostRef);
2191
+ this._dataUnits = [];
2192
+ this._requiredFieldsByDU = {};
2193
+ }
2194
+ async validate() {
2195
+ for (let i = 0; i < this._dataUnits.length; i++) {
2196
+ if (!this._dataUnits[i].validateRecords()) {
2197
+ return false;
2198
+ }
2199
+ }
2200
+ }
2201
+ async getChanges() {
2202
+ let allChanges = [];
2203
+ for (let i = 0; i < this._dataUnits.length; i++) {
2204
+ const duChanges = this._dataUnits[i].getChangesToSave();
2205
+ if (duChanges) {
2206
+ allChanges = allChanges.concat(duChanges);
2207
+ }
2208
+ }
2209
+ return allChanges;
2210
+ }
2211
+ validateRecords(dataUnit, records) {
2212
+ const result = { isValid: true, message: '' };
2213
+ const reqFields = this._requiredFieldsByDU[dataUnit.name];
2214
+ const recordValidator = record => {
2215
+ reqFields.forEach(field => {
2216
+ const recordIndex = record["record__index"];
2217
+ const fieldName = field.name;
2218
+ const fieldValue = record[fieldName];
2219
+ if (fieldValue === null || fieldValue === undefined || fieldValue === '') {
2220
+ this._store.dispatch(DataUnit.invalidField(field.tabControler, field.tabIndex, dataUnit.name, recordIndex, record.record__id, field.name, "Essa informação é obrigatória"));
2221
+ result.isValid = false;
2222
+ result.message = "Há pelo menos um campo obrigatório não preenchido.";
2223
+ }
2224
+ });
2225
+ };
2226
+ if (records.length == 0) {
2227
+ recordValidator({});
2228
+ }
2229
+ else {
2230
+ records.forEach(recordValidator);
2231
+ }
2232
+ return result;
2233
+ }
2234
+ componentWillRender() {
2235
+ if (this._store === undefined) {
2236
+ const rootReducer = combineReducers({
2237
+ "hist": undoable(formReducer),
2238
+ "nonhist": formNonHistoricReducer
2239
+ });
2240
+ this._store = createStore(rootReducer, applyMiddleware(thunk));
2241
+ this._store.subscribe(() => { index.forceUpdate(this); });
2242
+ if (this.slavemode) {
2243
+ this._store.dispatch(DataUnit.showHideNavigationButtons("saveVisible", false));
2244
+ this._store.dispatch(DataUnit.showHideNavigationButtons("cancelVisible", false));
2245
+ this._store.dispatch(DataUnit.showHideNavigationButtons("reloadVisible", false));
2246
+ }
2247
+ }
2248
+ }
2249
+ loadMDFromExecutor(callBack) {
2250
+ if (this._loadMetadataFunction) {
2251
+ const result = this._loadMetadataFunction();
2252
+ if (result) {
2253
+ if (result instanceof Promise) {
2254
+ result.then(md => {
2255
+ callBack(md);
2256
+ });
2257
+ }
2258
+ else {
2259
+ callBack(result);
2260
+ }
2261
+ }
2262
+ }
2263
+ }
2264
+ loadMDFromElement(callBack) {
2265
+ const metadata = [];
2266
+ Array.from(this._host.children).forEach(elem => {
2267
+ if (elem.tagName === "FORM-METADATA") {
2268
+ const formMetadata = elem;
2269
+ metadata.push(formMetadata.metadata);
2270
+ }
2271
+ });
2272
+ callBack(metadata.length > 0 ? metadata : null);
2273
+ }
2274
+ updateMetadata(metadata) {
2275
+ if (metadata) {
2276
+ const processFields = (duName, form, tabController, tabIndex) => {
2277
+ var _a;
2278
+ let requiredFields = this._requiredFieldsByDU[duName];
2279
+ if (requiredFields === undefined) {
2280
+ requiredFields = [];
2281
+ this._requiredFieldsByDU[duName] = requiredFields;
2282
+ }
2283
+ form.items.forEach(item => {
2284
+ if ("fields" in item) {
2285
+ const fSet = item;
2286
+ fSet.fields.forEach(f => {
2287
+ f.tabControler = tabController;
2288
+ f.tabIndex = tabIndex;
2289
+ if (f.required) {
2290
+ requiredFields.push(f);
2291
+ }
2292
+ });
2293
+ }
2294
+ else {
2295
+ const f = item;
2296
+ f.tabControler = tabController;
2297
+ f.tabIndex = tabIndex;
2298
+ if (f.required) {
2299
+ requiredFields.push(f);
2300
+ }
2301
+ }
2302
+ });
2303
+ (_a = form.subForms) === null || _a === void 0 ? void 0 : _a.forEach((subForm, index) => {
2304
+ const subDU = subForm.dataUnit ? subForm.dataUnit.name : duName;
2305
+ processFields(subDU, subForm, form.name, index);
2306
+ });
2307
+ };
2308
+ this.metadata = metadata;
2309
+ metadata.map((form, index) => {
2310
+ processFields(form.dataUnit.name, form, "__MAIN__FORM__", index);
2311
+ });
2312
+ this._store.dispatch(DataUnit.formLoad());
2313
+ }
2314
+ }
2315
+ parseExecutor(executor) {
2316
+ if (executor) {
2317
+ return executor instanceof Function ? executor : eval(executor);
2318
+ }
2319
+ return null;
2320
+ }
2321
+ componentDidLoad() {
2322
+ this._loadMetadataFunction = this.parseExecutor(this.metadataexecutor);
2323
+ this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2324
+ this._saveFunction = this.parseExecutor(this.saveexecutor);
2325
+ this._removeFunction = this.parseExecutor(this.removeexecutor);
2326
+ this._fieldSearchFunction = this.parseExecutor(this.fieldsearchexecutor);
2327
+ if (this.metadata) {
2328
+ this.updateMetadata(this.metadata);
2329
+ }
2330
+ else {
2331
+ this.loadMDFromElement((md) => this.updateMetadata(md));
2332
+ if (!this.metadata) {
2333
+ this.loadMDFromExecutor((md) => this.updateMetadata(md));
2334
+ }
2335
+ }
2336
+ }
2337
+ buildDataUnit(dataUnit) {
2338
+ if (dataUnit) {
2339
+ const { name, unitLabel, records, cardinality } = dataUnit;
2340
+ if (!(dataUnit instanceof DataUnit.DataUnit)) {
2341
+ dataUnit = new DataUnit.DataUnit(name, unitLabel, cardinality);
2342
+ this._dataUnits.push(dataUnit);
2343
+ if (records) {
2344
+ dataUnit.records = records;
2345
+ }
2346
+ dataUnit.store = this._store;
2347
+ dataUnit.loadExecutor = this._loadDataFunction;
2348
+ dataUnit.saveExecutor = this._saveFunction;
2349
+ dataUnit.removeExecutor = this._removeFunction;
2350
+ dataUnit.recordsValidator = this;
2351
+ dataUnit.fieldSearchExecutor = this._fieldSearchFunction;
2352
+ }
2353
+ }
2354
+ return dataUnit;
2355
+ }
2356
+ render() {
2357
+ return this.metadata ? index.h(FormSheet, { store: this._store, source: this.metadata, parentName: "__MAIN__FORM__", dataUnitBuilder: (du) => this.buildDataUnit(du) }) : null;
2358
+ }
2359
+ get _host() { return index.getElement(this); }
2360
+ };
2361
+ EzForm.style = ezFormCss;
2362
+
2363
+ 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}";
2364
+
2365
+ const EzIcon = class {
2366
+ constructor(hostRef) {
2367
+ index.registerInstance(this, hostRef);
2368
+ /*Tamanho do icone*/
2369
+ this.size = 'medium';
2370
+ }
2371
+ render() {
2372
+ return (index.h("svg", { class: this.size, role: "img" }, index.h("use", { xlinkHref: this.href })));
2373
+ }
2374
+ };
2375
+ EzIcon.style = ezIconCss;
2376
+
2377
+ 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%}";
2378
+
2379
+ const EzPopover = class {
2380
+ constructor(hostRef) {
2381
+ index.registerInstance(this, hostRef);
2382
+ this._firstRender = true;
2383
+ /**
2384
+ * No modo floating = false o popover só se tornará visível
2385
+ * quando o método show() for acionado.
2386
+ */
2387
+ this.autoclose = true;
2388
+ /**
2389
+ * Offset top do popover em relação ao componente pai
2390
+ */
2391
+ this.top = '0px';
2392
+ /**
2393
+ * Offset left do popover em relação ao componente pai
2394
+ */
2395
+ this.left = '0px';
2396
+ /**
2397
+ * Offset bottom do popover em relação ao componente pai
2398
+ */
2399
+ this.bottom = '0px';
2400
+ /**
2401
+ * Offset right do popover em relação ao componente pai
2402
+ */
2403
+ this.right = '0px';
2404
+ /**
2405
+ * Ajusta o comportamento da largura do popover.
2406
+ * Opções: "100% e "fit-content" (default)
2407
+ */
2408
+ this.boxwidth = 'fit-content';
2409
+ }
2410
+ /**
2411
+ * Atualiza a posição do popover em relação ao componente pai.
2412
+ */
2413
+ async updatePosition(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2414
+ const floatingOptions = {
2415
+ autoClose: this.autoclose,
2416
+ top,
2417
+ left,
2418
+ bottom,
2419
+ right,
2420
+ innerClickTest: (_container, node) => {
2421
+ if (_container.contains(node)) {
2422
+ return true;
2423
+ }
2424
+ if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2425
+ return true;
2426
+ }
2427
+ //Here: we pass this._box as parameter but we need to change to _host
2428
+ //because we need to get the lasChild (inner content to put in slot)
2429
+ _container = this._host;
2430
+ return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2431
+ }
2432
+ };
2433
+ FloatingManager.updateFloatPosition(this._box, this._container, floatingOptions);
2434
+ }
2435
+ /**
2436
+ * Faz com que o popover seja renderizado na DOM.
2437
+ *
2438
+ */
2439
+ async show(top = this.top, left = this.left, bottom = this.bottom, right = this.right) {
2440
+ const floatingOptions = {
2441
+ autoClose: this.autoclose,
2442
+ top,
2443
+ left,
2444
+ bottom,
2445
+ right,
2446
+ innerClickTest: (_container, node) => {
2447
+ if (_container.contains(node)) {
2448
+ return true;
2449
+ }
2450
+ if (_container.shadowRoot && _container.shadowRoot.contains(node)) {
2451
+ return true;
2452
+ }
2453
+ // Here: we pass this._box as parameter but we need to change to _host
2454
+ // because we need to get the lasChild (inner content to put in slot)
2455
+ _container = this._host;
2456
+ return !_container.lastElementChild.shadowRoot ? _container.contains(node) : _container.lastElementChild.shadowRoot.contains(node);
2457
+ }
2458
+ };
2459
+ this._floatingID = FloatingManager.float(this._box, this._container, floatingOptions);
2460
+ this.isOpened = true;
2461
+ }
2462
+ /**
2463
+ * Usado no modo floating. Faz com que o componente seja ocultado.
2464
+ */
2465
+ async hide() {
2466
+ if (this._floatingID !== undefined) {
2467
+ FloatingManager.close(this._floatingID);
2468
+ this._floatingID = undefined;
2469
+ this.isOpened = false;
2470
+ }
2471
+ }
2472
+ componentDidRender() {
2473
+ if (this._firstRender) {
2474
+ this._box.remove();
2475
+ this._firstRender = false;
2476
+ }
2477
+ }
2478
+ render() {
2479
+ return (index.h(index.Host, null, index.h("section", { ref: el => this._container = el }, index.h("div", { class: `box ${this.boxwidth === 'fit-content' ? 'box--fit-content' : 'box--full-width'}`, ref: el => this._box = el }, index.h("slot", null)))));
2480
+ }
2481
+ get _host() { return index.getElement(this); }
2482
+ };
2483
+ EzPopover.style = ezPopoverCss;
2484
+
2485
+ 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)}";
2486
+
2487
+ const EzSearch = class {
2488
+ constructor(hostRef) {
2489
+ index.registerInstance(this, hostRef);
2490
+ this.ezChange = index.createEvent(this, "ezChange", 7);
2491
+ this._options = [];
2492
+ this._classSelect = 'list-container--4row';
2493
+ /**
2494
+ * Deixa o campo disponível ou não para digitação.
2495
+ */
2496
+ this.enabled = true;
2497
+ /**
2498
+ * Quantidade máxima de itens guardados no localstorage
2499
+ */
2500
+ this.qtdHotItems = 6;
2501
+ /**
2502
+ * Ajusta a opção de mostrar o "value" para cada "label". Como default "value" não está presente (showvalue = false)
2503
+ */
2504
+ this.showvalue = false;
2505
+ ///// HOTSEARCH /////
2506
+ this.buildId = () => {
2507
+ return btoa(`${this.hotsearchid}:${location.pathname}`);
2508
+ };
2509
+ this.getStorageItems = (key) => {
2510
+ let storageValueStr = localStorage.getItem('hotSearch-ez-search:' + key);
2511
+ let storageItems = [];
2512
+ if (storageValueStr !== null) {
2513
+ storageItems = JSON.parse(storageValueStr);
2514
+ }
2515
+ return storageItems;
2516
+ };
2517
+ this.orderHotList = (list) => {
2518
+ return list.sort((a, b) => {
2519
+ let time1 = new Date(a.dtRecent).getTime();
2520
+ let time2 = new Date(b.dtRecent).getTime();
2521
+ let qtd1 = a.qtd;
2522
+ let qtd2 = b.qtd;
2523
+ if (time1 < time2)
2524
+ return -1;
2525
+ if (time1 > time2)
2526
+ return 1;
2527
+ if (qtd1 > qtd2)
2528
+ return -1;
2529
+ if (qtd1 < qtd2)
2530
+ return 1;
2531
+ return 0;
2532
+ });
2533
+ };
2534
+ this.saveStorageItem = (key, value) => {
2535
+ if (value == '' || value == undefined)
2536
+ return;
2537
+ let storageItem = this.getStorageItems(key);
2538
+ let element = this.getElement(storageItem, value);
2539
+ if (element) {
2540
+ element.qtd++;
2541
+ element.dtRecent = this.getOnlyDate();
2542
+ }
2543
+ else {
2544
+ if (storageItem.length >= this.qtdHotItems) {
2545
+ storageItem = this.orderHotList(storageItem);
2546
+ storageItem.splice(-1, 1);
2547
+ }
2548
+ storageItem.push({
2549
+ description: value,
2550
+ qtd: 1,
2551
+ dtRecent: this.getOnlyDate()
2552
+ });
2553
+ }
2554
+ localStorage.setItem('hotSearch-ez-search:' + key, JSON.stringify(storageItem));
2555
+ return storageItem;
2556
+ };
2557
+ this.adjustOptions = (arrayOptions) => {
2558
+ let optionsTemp = [];
2559
+ arrayOptions.map(el => {
2560
+ optionsTemp.push({
2561
+ value: el.value,
2562
+ label: el.label,
2563
+ ajustedValue: el.value === null || el.value === undefined || el.value === '' ? el.label : el.value,
2564
+ });
2565
+ });
2566
+ return optionsTemp;
2567
+ };
2568
+ this.sortArrayOptions = (array, propname) => {
2569
+ const sortedArray = array.sort(function (a, b) {
2570
+ if (a[propname] < b[propname]) {
2571
+ return -1;
2572
+ }
2573
+ if (a[propname] > b[propname]) {
2574
+ return 1;
2575
+ }
2576
+ return 0;
2577
+ });
2578
+ return sortedArray;
2579
+ };
2580
+ }
2581
+ valueChanged() {
2582
+ var _a;
2583
+ if (this.value) {
2584
+ this.ezChange.emit({ value: this.value, label: (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value });
2585
+ let key = this.buildId();
2586
+ this.saveStorageItem(key, this.value);
2587
+ }
2588
+ }
2589
+ //ajustar ao fim do teste
2590
+ onInputTeste() {
2591
+ if (this._inputElem) {
2592
+ this.handleChange();
2593
+ }
2594
+ }
2595
+ getElement(storageItem, value) {
2596
+ return storageItem.find(e => e.description === value);
2597
+ }
2598
+ getOnlyDate() {
2599
+ let dt = new Date();
2600
+ dt.setHours(0);
2601
+ dt.setMinutes(0);
2602
+ dt.setSeconds(0);
2603
+ dt.setUTCMilliseconds(0);
2604
+ return dt.toString();
2605
+ }
2606
+ onInputChange(ev) {
2607
+ const el = ev.target;
2608
+ let key = this.buildId();
2609
+ this.saveStorageItem(key, el.value);
2610
+ }
2611
+ buildDataList() {
2612
+ try {
2613
+ if (this.hotsearchid === undefined) {
2614
+ return;
2615
+ }
2616
+ let key = this.buildId();
2617
+ let optionsArray = [];
2618
+ this._options = [];
2619
+ if (this.getStorageItems(key).length > 0) {
2620
+ this.orderHotList(this.getStorageItems(key))
2621
+ .forEach((el) => {
2622
+ optionsArray.push({
2623
+ value: el.description,
2624
+ label: el.description,
2625
+ });
2626
+ });
2627
+ this._options = [{ value: '', label: '' }].concat(optionsArray);
2628
+ this.buildOptions();
2629
+ }
2630
+ }
2631
+ catch (err) {
2632
+ this.errormessage = err;
2633
+ }
2634
+ }
2635
+ ///// EVENT HANDLERS
2636
+ buildItem(opt, index$1) {
2637
+ const className = index$1 === this._preSelection ? "--li--preselected" : "";
2638
+ return index.h("li", { class: className, key: opt.ajustedValue, accessKey: opt.label.toString(), id: 'item_' + opt.ajustedValue, onMouseDown: (ev) => this.handleSetValueByOption(ev) }, this.highlightMatch(opt.label), this.showvalue ? index.h("span", { title: opt.ajustedValue, class: '--li__spanvalue' }, opt.ajustedValue) : null);
2639
+ }
2640
+ highlightMatch(label) {
2641
+ var _a;
2642
+ const spanClassName = this.showvalue ? '--li__spanlabel' : '--li__spanlabel--full-width';
2643
+ if ((_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) {
2644
+ const criteriaLength = this._inputElem.value.length;
2645
+ const matchStart = label.toUpperCase().indexOf(this._inputElem.value);
2646
+ if (matchStart > -1) {
2647
+ const strLabelStart = label.substr(0, matchStart);
2648
+ const strLabelEnd = label.substr(matchStart + criteriaLength);
2649
+ const strMatch = label.substr(matchStart, criteriaLength);
2650
+ return (index.h("span", { class: spanClassName }, strLabelStart, index.h("strong", null, strMatch), strLabelEnd));
2651
+ }
2652
+ }
2653
+ return (index.h("span", { class: spanClassName }, label));
2654
+ }
2655
+ showOptions() {
2656
+ if (this.enabled) {
2657
+ const top = this._inputElem.errormessage ? '0px' : '-17px';
2658
+ this._popover.show(top);
2659
+ }
2660
+ }
2661
+ nextOption() {
2662
+ this.showOptions();
2663
+ this._preSelection = this._preSelection === undefined ? 0 : Math.min(this._preSelection + 1, this._visibleOptions.length - 1);
2664
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
2665
+ }
2666
+ previousOption() {
2667
+ this._preSelection = this._preSelection === undefined ? 0 : Math.max(this._preSelection - 1, 0);
2668
+ this.scrollToOption(this._visibleOptions[this._preSelection]);
2669
+ }
2670
+ scrollToOption(opt) {
2671
+ const liElem = this.el.shadowRoot.querySelector(`li#item_${opt.value}`);
2672
+ if (liElem) {
2673
+ const parent = liElem.parentElement;
2674
+ const parentRect = parent.getBoundingClientRect();
2675
+ const itemRect = liElem.getBoundingClientRect();
2676
+ if (itemRect.bottom > parentRect.bottom || itemRect.top < parentRect.top) {
2677
+ liElem.scrollIntoView();
2678
+ }
2679
+ }
2680
+ }
2681
+ selectCurrentOption() {
2682
+ if (this._preSelection !== undefined) {
2683
+ this.selectOption(this._visibleOptions[this._preSelection]);
2684
+ this._preSelection = undefined;
2685
+ }
2686
+ }
2687
+ selectOption(opt) {
2688
+ this._popover.hide();
2689
+ this.value = opt === null || opt === void 0 ? void 0 : opt.ajustedValue;
2690
+ this._inputElem.value = opt.value;
2691
+ //Definir com a equipe de design se vai ser utilizado dessa forma.
2692
+ // this._inputElem.value = opt.value? opt.value + " - "+ opt?.label: '';
2693
+ }
2694
+ keyDownHandler(event) {
2695
+ switch (event.key) {
2696
+ case "ArrowDown":
2697
+ this.nextOption();
2698
+ break;
2699
+ case "ArrowUp":
2700
+ this.previousOption();
2701
+ break;
2702
+ case "Enter":
2703
+ this.selectCurrentOption();
2704
+ break;
2705
+ }
2706
+ event.stopPropagation();
2707
+ }
2708
+ handleSetValueByOption(ev) {
2709
+ this._popover.hide();
2710
+ const spanEl = ev.target;
2711
+ const sourceElement = ev.composedPath()[0];
2712
+ let li;
2713
+ if (sourceElement.tagName === 'SPAN') {
2714
+ li = spanEl.parentNode;
2715
+ }
2716
+ else {
2717
+ li = spanEl.parentNode.parentNode;
2718
+ }
2719
+ this.value = li.id.split('_')[1];
2720
+ this._inputElem.value = li.accessKey;
2721
+ this.ezChange.emit();
2722
+ }
2723
+ handleChange() {
2724
+ if (this._changeDeboucing) {
2725
+ window.clearTimeout(this._changeDeboucing);
2726
+ }
2727
+ this._changeDeboucing = window.setTimeout(() => {
2728
+ var _a, _b;
2729
+ if (((_b = (_a = this._inputElem) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.length) <= 0) {
2730
+ return;
2731
+ }
2732
+ /* save tip on localStorage */
2733
+ let key = this.buildId();
2734
+ this.saveStorageItem(key, this._inputElem.value);
2735
+ /* load data */
2736
+ if (this.loadexecutor) {
2737
+ this._loadDataFunction(this._inputElem.value, (serverData) => { this.populateOptions(serverData); });
2738
+ }
2739
+ }, 200);
2740
+ }
2741
+ normalizeResult(data) {
2742
+ let options = [];
2743
+ if (data instanceof Array) {
2744
+ options = data;
2745
+ }
2746
+ else {
2747
+ if (data instanceof Object) {
2748
+ for (var key in data) {
2749
+ let newOption = { value: '', label: '' };
2750
+ newOption.value = key;
2751
+ newOption.label = data[key];
2752
+ options.push(newOption);
2753
+ }
2754
+ }
2755
+ }
2756
+ this._options = [{ value: '', label: '' }].concat(options);
2757
+ this.buildOptions();
2758
+ }
2759
+ populateOptions(serverData) {
2760
+ if (serverData instanceof Promise) {
2761
+ serverData.then(this.normalizeResult);
2762
+ }
2763
+ else {
2764
+ this.normalizeResult(serverData);
2765
+ }
2766
+ }
2767
+ buildOptions() {
2768
+ var _a;
2769
+ this._visibleOptions = [];
2770
+ this._visibleOptions = this.adjustOptions(this._options);
2771
+ this._visibleOptions = this.sortArrayOptions(this._visibleOptions, 'label');
2772
+ if (this._visibleOptions.length > 0) {
2773
+ (_a = this._divElem) === null || _a === void 0 ? void 0 : _a.classList.add(this._classSelect);
2774
+ this.showOptions();
2775
+ }
2776
+ }
2777
+ setClassForSpanLabel() {
2778
+ if (!this.showvalue) {
2779
+ return '--li__spanlabel--full-width';
2780
+ }
2781
+ else {
2782
+ return '--li__spanlabel';
2783
+ }
2784
+ }
2785
+ handleFocus() {
2786
+ if (this._inputElem && (!this._inputElem.value || this._inputElem.value.length === 0)) {
2787
+ this.buildDataList();
2788
+ }
2789
+ }
2790
+ parseExecutor(executor) {
2791
+ if (executor) {
2792
+ return executor instanceof Function ? executor : eval(executor);
2793
+ }
2794
+ return null;
2795
+ }
2796
+ componentDidLoad() {
2797
+ if (this.value && this.value.length > 0) {
2798
+ this._inputElem.value = this.value;
2799
+ }
2800
+ this._loadDataFunction = this.parseExecutor(this.loadexecutor);
2801
+ }
2802
+ render() {
2803
+ var _a;
2804
+ return (index.h(index.Host, null, index.h("ez-text-input", { ref: (el) => { this._inputElem = el; }, label: this.label, enabled: this.enabled, onFocus: () => { this.handleFocus(); }, onInput: () => { this.handleChange(); }, onKeyDown: event => this.keyDownHandler(event), errormessage: this.errormessage }, index.h("button", { disabled: !this.enabled, tabindex: -1, class: "btn-open-search", onClick: () => { alert("Esta ação irá abrir o PopUp!"); }, slot: "leftIcon" })), index.h("ez-popover", { boxwidth: '100%', ref: el => this._popover = el }, index.h("div", { class: 'list-container', ref: (el) => this._divElem = el }, (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.map((opt, index) => this.buildItem(opt, index))))));
2805
+ }
2806
+ ;
2807
+ get el() { return index.getElement(this); }
2808
+ static get watchers() { return {
2809
+ "value": ["valueChanged"]
2810
+ }; }
2811
+ };
2812
+ EzSearch.style = ezSearchCss;
2813
+
2814
+ 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}";
2815
+
2816
+ const EzTabselector = class {
2817
+ constructor(hostRef) {
2818
+ index.registerInstance(this, hostRef);
2819
+ this.change = index.createEvent(this, "change", 7);
2820
+ this.setFoucusedParam = (ev) => {
2821
+ if (ev.key === 'Enter') {
2822
+ this.selectedindex = this.foucusedindex;
2823
+ this.foucusedindex = undefined;
2824
+ this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2825
+ this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2826
+ ev.preventDefault();
2827
+ this.setFocusedTab(this.selectedindex);
2828
+ }
2829
+ else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
2830
+ let operator = undefined;
2831
+ if (ev.key === 'ArrowLeft') {
2832
+ operator = false;
2833
+ }
2834
+ else if (ev.key === 'ArrowRight') {
2835
+ operator = true;
2836
+ }
2837
+ else {
2838
+ return;
2839
+ }
2840
+ if (this.foucusedindex === undefined) {
2841
+ if (operator === false) {
2842
+ this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
2843
+ }
2844
+ else {
2845
+ this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
2846
+ }
2847
+ }
2848
+ else {
2849
+ if (operator === false) {
2850
+ this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
2851
+ }
2852
+ else {
2853
+ this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
2854
+ }
2855
+ }
2856
+ if (parseInt(this.foucusedindex) < 0) {
2857
+ this.foucusedindex = '0';
2858
+ }
2859
+ else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
2860
+ this.foucusedindex = (this._processedTabs.length - 1).toString();
2861
+ }
2862
+ this.setFoucusedBtn(true, this.foucusedindex);
2863
+ this.setFocusedTab(this.foucusedindex);
2864
+ this.change.emit();
2865
+ }
2866
+ else if (ev.key === 'Tab' || ev.key === 'Escape') {
2867
+ this.foucusedindex = undefined;
2868
+ this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
2869
+ this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
2870
+ ev.preventDefault();
2871
+ this.setFocusedTab(this.selectedindex);
2872
+ }
2873
+ // this.setFocusedTab();
2874
+ };
2875
+ }
2876
+ handleTabClick(tab, index) {
2877
+ this.selectedindex = index.toString();
2878
+ this.foucusedindex = undefined;
2879
+ this.selectedtab = tab;
2880
+ this.change.emit();
2881
+ this.setFoucusedBtn(false, this.selectedindex);
2882
+ }
2883
+ componentWillRender() {
2884
+ if (!this._processedTabs) {
2885
+ this._processedTabs = [];
2886
+ if (this.tabs) {
2887
+ this.tabs.split(',').forEach((label) => {
2888
+ label = label.trim();
2889
+ this._processedTabs.push(new Tab(label, label));
2890
+ });
2891
+ }
2892
+ this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
2893
+ const tabKey = elem.getAttribute('tabKey');
2894
+ const label = elem.getAttribute('label');
2895
+ const t = new Tab(label, tabKey);
2896
+ const content = elem.firstChild;
2897
+ if (content) {
2898
+ content.setAttribute('slot', 'tab' + this._processedTabs.length);
2899
+ this._hostElem.appendChild(content);
2900
+ }
2901
+ this._processedTabs.push(t);
2902
+ });
2903
+ }
2904
+ }
2905
+ handleSlotChange(ev) {
2906
+ const slot = ev.target;
2907
+ const content = slot.assignedElements()[0];
2908
+ if (content) {
2909
+ content.style.marginLeft = "6px";
2910
+ }
2911
+ }
2912
+ scrollBackward() {
2913
+ const container = this._scrollContainer;
2914
+ if (container) {
2915
+ container.scrollLeft -= container.clientWidth;
2916
+ }
2917
+ }
2918
+ scrollFoward() {
2919
+ const container = this._scrollContainer;
2920
+ if (container) {
2921
+ let lastTab = null;
2922
+ container.querySelectorAll('.tab').forEach((tab) => {
2923
+ if (tab.getBoundingClientRect().right < container.clientWidth) {
2924
+ lastTab = tab;
2925
+ }
2926
+ });
2927
+ container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
2928
+ }
2929
+ }
2930
+ componentDidRender() {
2931
+ this.updateScroll();
2932
+ }
2933
+ updateScroll() {
2934
+ const container = this._scrollContainer;
2935
+ if (container) {
2936
+ const { scrollWidth, clientWidth, scrollLeft } = container;
2937
+ const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
2938
+ this._startHidden = container.scrollLeft > 0;
2939
+ this._endHidden = remainingScroll > 0;
2940
+ if (this._startHidden) {
2941
+ this._backwardButton.classList.remove('hidden');
2942
+ }
2943
+ else {
2944
+ this._backwardButton.classList.add('hidden');
2945
+ }
2946
+ if (this._endHidden) {
2947
+ this._forwardButton.classList.remove('hidden');
2948
+ }
2949
+ else {
2950
+ this._forwardButton.classList.add('hidden');
2951
+ }
2952
+ const classNames = ['', 'startHidden', 'endHidden', 'midle'];
2953
+ const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
2954
+ classNames.forEach((name) => {
2955
+ if (name !== currentClass && container.classList.contains(name)) {
2956
+ container.classList.remove(name);
2957
+ }
2958
+ });
2959
+ if (currentClass && !container.classList.contains(currentClass)) {
2960
+ container.classList.add(currentClass);
2961
+ }
2962
+ }
2963
+ }
2964
+ domScrollHandler() {
2965
+ window.clearTimeout(this._scrollCallBack);
2966
+ this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
2967
+ }
2968
+ setFocusedTab(index) {
2969
+ window.clearTimeout(this._scrollCallBackTeste);
2970
+ this._scrollCallBackTeste = window.setTimeout(() => {
2971
+ const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
2972
+ console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
2973
+ console.log('tabtoscroll', tabtoscroll);
2974
+ tabtoscroll.scrollIntoView();
2975
+ }, 200);
2976
+ }
2977
+ getTextWidth(text) {
2978
+ if (this._textMesurement === undefined) {
2979
+ this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
2980
+ }
2981
+ const context = this._textMesurement.getContext("2d");
2982
+ context.font = '14px Sora, Algerian';
2983
+ return Math.min(220, 24 + context.measureText(text).width) + 'px';
2984
+ }
2985
+ ;
2986
+ setFoucusedBtn(visible, paramater) {
2987
+ const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
2988
+ tabsButtons.forEach((el) => {
2989
+ el.classList.remove('is-focused');
2990
+ if (el.id === 'tab' + paramater && visible) {
2991
+ el.classList.add('is-focused');
2992
+ }
2993
+ });
2994
+ }
2995
+ render() {
2996
+ return (index.h(index.Host, null, index.h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }), index.h("div", { class: "scroll", ref: (el) => this._scrollContainer = el,
2997
+ // onScroll={() => this.domScrollHandler()}
2998
+ onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index$1) => {
2999
+ const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
3000
+ const tabId = "tab" + index$1;
3001
+ const isSelected = index$1 === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
3002
+ if (isSelected) {
3003
+ this.selectedtab = tab.tabKey;
3004
+ this.selectedindex = index$1.toString();
3005
+ }
3006
+ return index.h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab.tabKey, index$1), style: labelStyle }, index.h("span", { class: "tab-label", title: tab.label }, tab.label), index.h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
3007
+ })), index.h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
3008
+ }
3009
+ get _hostElem() { return index.getElement(this); }
3010
+ };
3011
+ class Tab {
3012
+ constructor(label, tabKey) {
3013
+ this.label = label;
3014
+ this.tabKey = tabKey;
3015
+ }
3016
+ }
3017
+ EzTabselector.style = ezTabselectorCss;
3018
+
3019
+ 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)}";
3020
+
3021
+ const EzTextArea = class {
3022
+ constructor(hostRef) {
3023
+ index.registerInstance(this, hostRef);
3024
+ this.ezChange = index.createEvent(this, "ezChange", 7);
3025
+ /**
3026
+ * Deixa o campo disponível ou não para digitação.
3027
+ */
3028
+ this.enabled = true;
3029
+ /**
3030
+ * Ajusta o numero de linhas e consequentemente o height do textarea. Valor default: 4
3031
+ */
3032
+ this.rows = 4;
3033
+ }
3034
+ showError() {
3035
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3036
+ if (hasError) {
3037
+ this._inputElem.classList.add('hasError');
3038
+ this._messageBoxElem.classList.add('hasError');
3039
+ }
3040
+ else {
3041
+ this._inputElem.classList.remove('hasError');
3042
+ this._messageBoxElem.classList.remove('hasError');
3043
+ }
3044
+ }
3045
+ updateInputValue() {
3046
+ this._inputElem.value = this.value;
3047
+ this.handleChange();
3048
+ this.adjustFloatingLabel();
3049
+ }
3050
+ adjustFloatingLabel() {
3051
+ if (this.label) {
3052
+ if (!this._inputElem.classList.contains("input--with--label")) {
3053
+ this._inputElem.classList.add("input--with--label");
3054
+ }
3055
+ const hasValue = this.value && this.value.toString().length > 0;
3056
+ const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
3057
+ if (hasValue || this.isFocused()) {
3058
+ if (!containsFloatedClass) {
3059
+ this._labelElem.classList.add("textarea__label--floated");
3060
+ }
3061
+ }
3062
+ else {
3063
+ if (containsFloatedClass) {
3064
+ this._labelElem.classList.remove("textarea__label--floated");
3065
+ }
3066
+ }
3067
+ }
3068
+ }
3069
+ isFocused() {
3070
+ return this._hostElement.shadowRoot.activeElement !== null;
3071
+ }
3072
+ //---------------------------------------------
3073
+ // Public methods
3074
+ //---------------------------------------------
3075
+ /**
3076
+ * Faz o foco no componente de input
3077
+ */
3078
+ async setFocus() {
3079
+ this._inputElem.focus();
3080
+ }
3081
+ /**
3082
+ * Remove o foco no componente de input
3083
+ */
3084
+ async setBlur() {
3085
+ this._inputElem.blur();
3086
+ }
3087
+ //---------------------------------------------
3088
+ // Event handlers
3089
+ //---------------------------------------------
3090
+ handleFocusout() {
3091
+ this.adjustFloatingLabel();
3092
+ }
3093
+ handleChange() {
3094
+ this.value = this._inputElem.value;
3095
+ }
3096
+ handleFocus() {
3097
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
3098
+ this._labelElem.classList.add("textarea__label--floated");
3099
+ }
3100
+ }
3101
+ //---------------------------------------------
3102
+ // Lifecycle web component
3103
+ //---------------------------------------------
3104
+ componentDidLoad() {
3105
+ this.showError();
3106
+ this.adjustFloatingLabel();
3107
+ }
3108
+ render() {
3109
+ return (index.h(index.Host, null, this.label ?
3110
+ index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "textarea__label" : "textarea__label textarea__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
3111
+ : null, index.h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows }), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
3112
+ }
3113
+ get _hostElement() { return index.getElement(this); }
3114
+ static get watchers() { return {
3115
+ "errormessage": ["showError"],
3116
+ "value": ["updateInputValue"]
3117
+ }; }
3118
+ };
3119
+ EzTextArea.style = ezTextAreaCss;
3120
+
3121
+ function isValidNumber(strValue) {
3122
+ return strValue && /^-?\d*[.,]?\d*$/.test(strValue);
3123
+ }
3124
+
3125
+ 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}";
3126
+
3127
+ const EzTextInput = class {
3128
+ constructor(hostRef) {
3129
+ index.registerInstance(this, hostRef);
3130
+ this.ezChange = index.createEvent(this, "ezChange", 7);
3131
+ /**
3132
+ * Deixa o campo disponível ou não para digitação.
3133
+ */
3134
+ this.enabled = true;
3135
+ }
3136
+ showError() {
3137
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
3138
+ if (hasError) {
3139
+ this._inputElem.classList.add('hasError');
3140
+ this._messageBoxElem.classList.add('hasError');
3141
+ }
3142
+ else {
3143
+ this._inputElem.classList.remove('hasError');
3144
+ this._messageBoxElem.classList.remove('hasError');
3145
+ }
3146
+ }
3147
+ prepareMask() {
3148
+ if (this.mask) {
3149
+ if (this._maskFormatter == undefined) {
3150
+ this._maskFormatter = new RequestMetadata.MaskFormatter(this.mask);
3151
+ }
3152
+ else {
3153
+ this._maskFormatter.mask = this.mask;
3154
+ }
3155
+ }
3156
+ }
3157
+ updateInputValue() {
3158
+ this._inputElem.value = this.value;
3159
+ this.handleChange();
3160
+ this.ezChange.emit();
3161
+ this.adjustFloatingLabel();
3162
+ }
3163
+ adjustFloatingLabel() {
3164
+ if (this.label) {
3165
+ if (!this._inputElem.classList.contains("input--with--label")) {
3166
+ this._inputElem.classList.add("input--with--label");
3167
+ }
3168
+ const hasValue = this.value && this.value.toString().length > 0;
3169
+ const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
3170
+ if (hasValue || this.isFocused()) {
3171
+ if (!containsFloatedClass) {
3172
+ this._labelElem.classList.add("input__label--floated");
3173
+ }
3174
+ }
3175
+ else {
3176
+ if (containsFloatedClass) {
3177
+ this._labelElem.classList.remove("input__label--floated");
3178
+ }
3179
+ }
3180
+ }
3181
+ }
3182
+ isFocused() {
3183
+ return this._hostElement.shadowRoot.activeElement !== null;
3184
+ }
3185
+ //---------------------------------------------
3186
+ // Public methods
3187
+ //---------------------------------------------
3188
+ /**
3189
+ * Faz o foco no componente de input
3190
+ */
3191
+ async setFocus() {
3192
+ this._inputElem.focus();
3193
+ }
3194
+ /**
3195
+ * Remove o foco no componente de input
3196
+ */
3197
+ async setBlur() {
3198
+ this._inputElem.blur();
3199
+ }
3200
+ //---------------------------------------------
3201
+ // Event handlers
3202
+ //---------------------------------------------
3203
+ handleFocusout() {
3204
+ const value = this._inputElem.value;
3205
+ if (value && this._maskFormatter) {
3206
+ try {
3207
+ this._inputElem.value = this._maskFormatter.format(value);
3208
+ }
3209
+ catch (e) {
3210
+ this.errormessage = e.message;
3211
+ }
3212
+ }
3213
+ this.value = this._inputElem.value;
3214
+ this.adjustFloatingLabel();
3215
+ }
3216
+ isValidValue(value) {
3217
+ if (this.onlynumber) {
3218
+ return value == "" || isValidNumber(value);
3219
+ }
3220
+ if (this.restrict) {
3221
+ return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
3222
+ }
3223
+ return true;
3224
+ }
3225
+ handleChange() {
3226
+ if (!this._inputElem) {
3227
+ return;
3228
+ }
3229
+ const value = this._inputElem.value;
3230
+ if (this.isValidValue(value)) {
3231
+ this._lastValidValue = value;
3232
+ }
3233
+ else {
3234
+ this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
3235
+ }
3236
+ this.value = this._inputElem.value;
3237
+ }
3238
+ handleSlotChange(ev) {
3239
+ const slot = ev.target;
3240
+ const content = slot.assignedElements()[0];
3241
+ if (content) {
3242
+ content.style.position = "absolute";
3243
+ content.style.display = "flex";
3244
+ content.style.alignItems = "center";
3245
+ content.style.justifyContent = "center";
3246
+ content.style.overflow = "hidden";
3247
+ content.style.top = "0px";
3248
+ content.style.width = "var(--it__icon--width)";
3249
+ content.style.height = "var(--it--height)";
3250
+ if (slot.name == "leftIcon") {
3251
+ content.style.left = "0px";
3252
+ content.style.borderRadius = "var(--it--border-radius) 0 0 var(--it--border-radius)";
3253
+ this._inputElem.classList.add('icon--left');
3254
+ if (this._labelElem) {
3255
+ this._labelElem.classList.add('input__label--left');
3256
+ }
3257
+ }
3258
+ else if (slot.name == "rightIcon") {
3259
+ content.style.right = "0px";
3260
+ content.style.borderRadius = "0 var(--it--border-radius) var(--it--border-radius) 0";
3261
+ this._inputElem.classList.add('icon--right');
3262
+ if (this._labelElem) {
3263
+ this._labelElem.classList.add('input__label--right');
3264
+ }
3265
+ }
3266
+ }
3267
+ this.showError();
3268
+ }
3269
+ doFocus() {
3270
+ if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
3271
+ this._labelElem.classList.add("input__label--floated");
3272
+ }
3273
+ }
3274
+ //---------------------------------------------
3275
+ // Lifecycle web component
3276
+ //---------------------------------------------
3277
+ componentDidLoad() {
3278
+ if (this.onlynumber) {
3279
+ this._inputElem.classList.add('text--right');
3280
+ }
3281
+ this.showError();
3282
+ this.prepareMask();
3283
+ this.adjustFloatingLabel();
3284
+ }
3285
+ componentWillLoad() {
3286
+ this.prepareMask();
3287
+ if (this.value) {
3288
+ if (this._maskFormatter) {
3289
+ try {
3290
+ this.value = this._maskFormatter.format(this.value);
3291
+ }
3292
+ catch (e) {
3293
+ this.errormessage = e.message;
3294
+ }
3295
+ }
3296
+ if (!this.isValidValue(this.value)) {
3297
+ this._lastValidValue = "";
3298
+ this.value = "";
3299
+ }
3300
+ }
3301
+ }
3302
+ render() {
3303
+ return (index.h(index.Host, null, index.h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label ?
3304
+ index.h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
3305
+ : null, index.h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), index.h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), index.h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errormessage }, this.errormessage)));
3306
+ }
3307
+ get _hostElement() { return index.getElement(this); }
3308
+ static get watchers() { return {
3309
+ "errormessage": ["showError"],
3310
+ "mask": ["prepareMask"],
3311
+ "value": ["updateInputValue"]
3312
+ }; }
3313
+ };
3314
+ EzTextInput.style = ezTextInputCss;
3315
+
3316
+ 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}}";
3317
+
3318
+ const PlaceHolder = class {
3319
+ constructor(hostRef) {
3320
+ index.registerInstance(this, hostRef);
3321
+ }
3322
+ render() {
3323
+ return index.h(index.Host, null);
3324
+ }
3325
+ };
3326
+ PlaceHolder.style = placeHolderCss;
3327
+
3328
+ exports.ez_button = EzButton;
3329
+ exports.ez_calendar = EzCalendar;
3330
+ exports.ez_check = EzCheck;
3331
+ exports.ez_collapsable_box = EzCollapsableBox;
3332
+ exports.ez_combo_box = EzComboBox;
3333
+ exports.ez_date_input = EzDateInput;
3334
+ exports.ez_form = EzForm;
3335
+ exports.ez_icon = EzIcon;
3336
+ exports.ez_popover = EzPopover;
3337
+ exports.ez_search = EzSearch;
3338
+ exports.ez_tabselector = EzTabselector;
3339
+ exports.ez_text_area = EzTextArea;
3340
+ exports.ez_text_input = EzTextInput;
3341
+ exports.place_holder = PlaceHolder;