@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
@@ -1,244 +1,244 @@
1
- import { r as registerInstance, h, i as Host, g as getElement } from './index-39044be2.js';
2
- import { N as NumberUtils } from './index-919090de.js';
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-95bb3fd9.js';
2
+ import { N as NumberUtils } from './RequestMetadata-c265c9d5.js';
3
3
 
4
4
  const ezNumberInputCss = ":host{--ni--height:42px;--ni--width:100%;--ni__icon--width:48px;--ni--border-radius:var(--border--radius-medium, 12px);--ni--font-size:var(--text--medium, 14px);--ni--font-family:var(--font-pattern, Arial);--ni__input--background-color:var(--background--medium, #e0e0e0);--ni__input--border:var(--border--medium, 2px solid);--ni__input--border-color:var(--ni__input--background-color);--ni__input--focus--border-color:var(--color--primary, #008561);--ni__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ni__input--disabled--color:var(--text--disable, #AFB6C0);--ni__input--error--border-color:#CC2936;--ni__placeholder--disabled--color:var(--text--disable, #AFB6C0);--ni__placeholder--color:var(--title--primary, #919191);--ni__placeholder--font-weight:var(--text-weight--large, 500);--ni__message_box--font-size:var(--text--small, 12px);--ni__message_box--info--color:var(--color--success, #22085d);--ni__message_box--error--color:var(--color--error, #FF0000);display:flex;flex-wrap:wrap;position:relative;width:var(--ni--width)}.invisible{visibility:hidden}input{width:100%;box-sizing:border-box;padding:var(--space--medium);height:var(--ni--height);border-radius:var(--ni--border-radius);font-family:var(--ni--font-family);font-size:var(--ni--font-size);border:var(--ni__input--border);border-color:var(--ni__input--border-color);background-color:var(--ni__input--background-color);font-weight:var(--text-weight--large)}input:disabled{background-color:var(--ni__input--disabled--background-color);color:var(--ni__input--disabled--color)}input:focus{outline:none;border-color:var(--ni__input--focus--border-color)}input.icon--left{padding-left:var(--ni__icon--width)}input.icon--right{padding-right:var(--ni__icon--width)}input::placeholder{color:var(--ni__placeholder--color);font-weight:var(--ni__placeholder--font-weight)}input:disabled::placeholder{color:var(--ni__placeholder--disabled--color)}input.hasError{color:inherit;border-color:var(--ni__input--error--border-color)}input.text--right{text-align:right}.message-box{min-height:16px;min-width:100%;margin-top:2px;line-height:12px;font-family:var(--ni--font-family);font-size:var(--ni__message_box--font-size);color:var(--ni__message_box--info--color)}.hasError{color:var(--ni__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(--ni--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(--ni--font-family);font-size:var(--text--extra-small);top:var(--space--small);color:var(--text--primary)}.input__label--left{left:var(--ni__icon--width)}.input--with--label{padding-bottom:0}";
5
5
 
6
- const NumberInput = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- /**
10
- * Deixa o campo disponível ou não para digitação.
11
- */
12
- this.enabled = true;
13
- /**
14
- * Deixa o campo disponível ou não para digitação.
15
- */
16
- this.textleft = false;
17
- /**
18
- * Opção de configurar a transformação de string to number entre formatação pt-BR e en-US
19
- * (formatação de ENTRADA e SAÍDA do componente: pt-BR="###.###,##" en-US="###,###.##"; Default: "pt-BR")
20
- * Qualquer outro valor que não seja "en-US", adotará a formatação "pt-BR"
21
- * Não é case sensitive
22
- */
23
- this.formatnumber = "PT-BR";
24
- //---------------------------------------------
25
- // Private Methods
26
- //---------------------------------------------
27
- this.settingStrValueIntNumber = (strvalue) => {
28
- if (this.precision === 0 && strvalue) {
29
- return strvalue = strvalue.replace(/\./g, '').replace(/\,/g, '');
30
- }
31
- else {
32
- return strvalue;
33
- }
34
- };
35
- this.checkNumberValidation = (valuePtBRorNumber) => {
36
- try {
37
- if (valuePtBRorNumber != "" && NumberUtils.format(valuePtBRorNumber, this.precision, this.prettyprecision) === "NaN") {
38
- this.errormessage = `Valor não é um número válido`;
39
- this.value = undefined;
40
- this.strvalue = undefined;
41
- if (this._inputElem) {
42
- this._inputElem.value = "";
43
- }
44
- return false;
45
- }
46
- }
47
- catch (err) {
48
- this.errormessage = err.message;
49
- return false;
50
- }
51
- return true;
52
- };
53
- }
54
- showError() {
55
- const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
56
- if (this._inputElem) {
57
- if (hasError) {
58
- this._inputElem.classList.add('hasError');
59
- this._messageBoxElem.classList.add('hasError');
60
- }
61
- else {
62
- this._inputElem.classList.remove('hasError');
63
- this._messageBoxElem.classList.remove('hasError');
64
- }
65
- }
66
- }
67
- onPrecisionChanged(newPrecision) {
68
- if (isNaN(newPrecision)) {
69
- this.precision = 0;
70
- }
71
- this.handleFocusout();
72
- }
73
- onPrettyPrecisionChanged(newPrettyPrecision) {
74
- if (isNaN(newPrettyPrecision)) {
75
- this.prettyprecision = 0;
76
- }
77
- this.handleFocusout();
78
- }
79
- onValueChanged(newValue) {
80
- if (isNaN(newValue) && newValue !== undefined) {
81
- this.value = undefined;
82
- this.strvalue = "";
83
- this.errormessage = `Valor não é um número válido`;
84
- this.adjustFloatingLabel();
85
- }
86
- else {
87
- this.settingComponent();
88
- }
89
- }
90
- adjustFloatingLabel() {
91
- if (this._labelElem) {
92
- if (this.label && this._inputElem.value && this._inputElem.value.toString().length > 0) {
93
- if (!this._labelElem.classList.contains("input__label--floated")) {
94
- this._labelElem.classList.add("input__label--floated");
95
- }
96
- if (!this._inputElem.classList.contains("input--with--label")) {
97
- this._inputElem.classList.add("input--with--label");
98
- }
99
- }
100
- else {
101
- this._labelElem.classList.remove("input__label--floated");
102
- }
103
- }
104
- }
105
- //---------------------------------------------
106
- // Public methods
107
- //---------------------------------------------
108
- /**
109
- * Faz o foco no componente de input
110
- */
111
- async setFocus() {
112
- this._inputElem.focus();
113
- }
114
- /**
115
- * Remove o foco no componente de input
116
- */
117
- async setBlur() {
118
- this._inputElem.blur();
119
- }
120
- //---------------------------------------------
121
- // Event handlers
122
- //---------------------------------------------
123
- /**
124
- * Promove a atualização do componente
125
- */
126
- async handleFocusout() {
127
- //Setting value and strvalue by stringinput
128
- if (this._inputElem) {
129
- this.errormessage = "";
130
- if (this._inputElem.value !== "") {
131
- this._inputElem.value = this.settingStrValueIntNumber(this._inputElem.value);
132
- const value = NumberUtils.keepOnlyDecimalSeparator(this._inputElem.value, this.formatnumber.toUpperCase());
133
- if (!this.checkNumberValidation(value)) {
134
- return;
135
- }
136
- if (value) {
137
- try {
138
- this._inputElem.value = this.formatnumber.toUpperCase() !== "EN-US" ? NumberUtils.format(value, this.precision, this.prettyprecision) : NumberUtils.changeFormat(NumberUtils.format(value, this.precision, this.prettyprecision));
139
- }
140
- catch (e) {
141
- this.errormessage = e.message;
142
- return;
143
- }
144
- }
145
- this.strvalue = this._inputElem.value;
146
- this.value = NumberUtils.stringToNumber(value);
147
- }
148
- else {
149
- this.strvalue = undefined;
150
- this.value = undefined;
151
- }
152
- this.adjustFloatingLabel();
153
- }
154
- }
155
- handleChange() {
156
- this._inputElem.value = this.settingStrValueIntNumber(this._inputElem.value);
157
- }
158
- handleSlotChange(ev) {
159
- const slot = ev.target;
160
- const content = slot.assignedElements()[0];
161
- content.style.position = "absolute";
162
- content.style.display = "flex";
163
- content.style.alignItems = "center";
164
- content.style.justifyContent = "center";
165
- content.style.overflow = "hidden";
166
- content.style.top = "0px";
167
- content.style.width = "var(--ni__icon--width)";
168
- content.style.height = "var(--ni--height)";
169
- if (slot.name == "leftIcon") {
170
- content.style.left = "0px";
171
- content.style.borderRadius = "var(--ni--border-radius) 0 0 var(--ni--border-radius)";
172
- this._inputElem.classList.add('icon--left');
173
- if (this._labelElem) {
174
- this._labelElem.classList.add("input__label--left");
175
- }
176
- }
177
- else if (slot.name == "rightIcon") {
178
- content.style.right = "0px";
179
- content.style.borderRadius = "0 var(--ni--border-radius) var(--ni--border-radius) 0";
180
- this._inputElem.classList.add('icon--right');
181
- }
182
- this.showError();
183
- }
184
- doFocus() {
185
- if (this.label && this._labelElem) {
186
- this._labelElem.classList.contains("input__label--floated") ? undefined : this._labelElem.classList.add("input__label--floated");
187
- }
188
- }
189
- settingComponent() {
190
- const value = '' + this.value;
191
- if (this.value !== undefined) {
192
- try {
193
- this._inputElem.value = this.formatnumber.toUpperCase() !== "EN-US" ? NumberUtils.format(value, this.precision, this.prettyprecision) : NumberUtils.changeFormat(NumberUtils.format(value, this.precision, this.prettyprecision));
194
- }
195
- catch (e) {
196
- this.errormessage = e.message;
197
- return;
198
- }
199
- this.strvalue = this._inputElem.value;
200
- }
201
- this.adjustFloatingLabel();
202
- }
203
- settingValue() {
204
- //this.value: en-US format => Need to convert
205
- const value = !isNaN(this.value) ? '' + this.value : 'NaN';
206
- if (!this.checkNumberValidation(value)) {
207
- return;
208
- }
209
- //output default from ".format": pt-BR
210
- const tempStrValue = NumberUtils.format(value, this.precision, this.prettyprecision);
211
- //output => depends to formatnumber
212
- this.strvalue = this.formatnumber.toUpperCase() !== 'EN-US' ? tempStrValue : NumberUtils.changeFormat(tempStrValue);
213
- NumberUtils.format(this.value.toString(), this.precision, this.prettyprecision);
214
- }
215
- //---------------------------------------------
216
- // Lifecycle web component
217
- //---------------------------------------------
218
- componentDidLoad() {
219
- if (!this.textleft) {
220
- this._inputElem.classList.add('text--right');
221
- }
222
- this.showError();
223
- this.adjustFloatingLabel();
224
- }
225
- componentWillLoad() {
226
- this.onPrecisionChanged(this.precision);
227
- this.onPrettyPrecisionChanged(this.prettyprecision);
228
- this.settingValue();
229
- }
230
- render() {
231
- const labelInput = this.label ? h("label", { onClick: () => this._inputElem.focus(), class: "input__label", ref: (el) => this._labelElem = el }, this.label) : null;
232
- return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), labelInput, h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.strvalue, disabled: !this.enabled, onInput: this.handleChange.bind(this), onFocusout: this.handleFocusout.bind(this) }), h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el }, this.errormessage)));
233
- }
234
- get el() { return getElement(this); }
235
- static get watchers() { return {
236
- "errormessage": ["showError"],
237
- "precision": ["onPrecisionChanged"],
238
- "prettyprecision": ["onPrettyPrecisionChanged"],
239
- "value": ["onValueChanged"]
240
- }; }
241
- };
6
+ const NumberInput = class {
7
+ constructor(hostRef) {
8
+ registerInstance(this, hostRef);
9
+ /**
10
+ * Deixa o campo disponível ou não para digitação.
11
+ */
12
+ this.enabled = true;
13
+ /**
14
+ * Deixa o campo disponível ou não para digitação.
15
+ */
16
+ this.textleft = false;
17
+ /**
18
+ * Opção de configurar a transformação de string to number entre formatação pt-BR e en-US
19
+ * (formatação de ENTRADA e SAÍDA do componente: pt-BR="###.###,##" en-US="###,###.##"; Default: "pt-BR")
20
+ * Qualquer outro valor que não seja "en-US", adotará a formatação "pt-BR"
21
+ * Não é case sensitive
22
+ */
23
+ this.formatnumber = "PT-BR";
24
+ //---------------------------------------------
25
+ // Private Methods
26
+ //---------------------------------------------
27
+ this.settingStrValueIntNumber = (strvalue) => {
28
+ if (this.precision === 0 && strvalue) {
29
+ return strvalue = strvalue.replace(/\./g, '').replace(/\,/g, '');
30
+ }
31
+ else {
32
+ return strvalue;
33
+ }
34
+ };
35
+ this.checkNumberValidation = (valuePtBRorNumber) => {
36
+ try {
37
+ if (valuePtBRorNumber != "" && NumberUtils.format(valuePtBRorNumber, this.precision, this.prettyprecision) === "NaN") {
38
+ this.errormessage = `Valor não é um número válido`;
39
+ this.value = undefined;
40
+ this.strvalue = undefined;
41
+ if (this._inputElem) {
42
+ this._inputElem.value = "";
43
+ }
44
+ return false;
45
+ }
46
+ }
47
+ catch (err) {
48
+ this.errormessage = err.message;
49
+ return false;
50
+ }
51
+ return true;
52
+ };
53
+ }
54
+ showError() {
55
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
56
+ if (this._inputElem) {
57
+ if (hasError) {
58
+ this._inputElem.classList.add('hasError');
59
+ this._messageBoxElem.classList.add('hasError');
60
+ }
61
+ else {
62
+ this._inputElem.classList.remove('hasError');
63
+ this._messageBoxElem.classList.remove('hasError');
64
+ }
65
+ }
66
+ }
67
+ onPrecisionChanged(newPrecision) {
68
+ if (isNaN(newPrecision)) {
69
+ this.precision = 0;
70
+ }
71
+ this.handleFocusout();
72
+ }
73
+ onPrettyPrecisionChanged(newPrettyPrecision) {
74
+ if (isNaN(newPrettyPrecision)) {
75
+ this.prettyprecision = 0;
76
+ }
77
+ this.handleFocusout();
78
+ }
79
+ onValueChanged(newValue) {
80
+ if (isNaN(newValue) && newValue !== undefined) {
81
+ this.value = undefined;
82
+ this.strvalue = "";
83
+ this.errormessage = `Valor não é um número válido`;
84
+ this.adjustFloatingLabel();
85
+ }
86
+ else {
87
+ this.settingComponent();
88
+ }
89
+ }
90
+ adjustFloatingLabel() {
91
+ if (this._labelElem) {
92
+ if (this.label && this._inputElem.value && this._inputElem.value.toString().length > 0) {
93
+ if (!this._labelElem.classList.contains("input__label--floated")) {
94
+ this._labelElem.classList.add("input__label--floated");
95
+ }
96
+ if (!this._inputElem.classList.contains("input--with--label")) {
97
+ this._inputElem.classList.add("input--with--label");
98
+ }
99
+ }
100
+ else {
101
+ this._labelElem.classList.remove("input__label--floated");
102
+ }
103
+ }
104
+ }
105
+ //---------------------------------------------
106
+ // Public methods
107
+ //---------------------------------------------
108
+ /**
109
+ * Faz o foco no componente de input
110
+ */
111
+ async setFocus() {
112
+ this._inputElem.focus();
113
+ }
114
+ /**
115
+ * Remove o foco no componente de input
116
+ */
117
+ async setBlur() {
118
+ this._inputElem.blur();
119
+ }
120
+ //---------------------------------------------
121
+ // Event handlers
122
+ //---------------------------------------------
123
+ /**
124
+ * Promove a atualização do componente
125
+ */
126
+ async handleFocusout() {
127
+ //Setting value and strvalue by stringinput
128
+ if (this._inputElem) {
129
+ this.errormessage = "";
130
+ if (this._inputElem.value !== "") {
131
+ this._inputElem.value = this.settingStrValueIntNumber(this._inputElem.value);
132
+ const value = NumberUtils.keepOnlyDecimalSeparator(this._inputElem.value, this.formatnumber.toUpperCase());
133
+ if (!this.checkNumberValidation(value)) {
134
+ return;
135
+ }
136
+ if (value) {
137
+ try {
138
+ this._inputElem.value = this.formatnumber.toUpperCase() !== "EN-US" ? NumberUtils.format(value, this.precision, this.prettyprecision) : NumberUtils.changeFormat(NumberUtils.format(value, this.precision, this.prettyprecision));
139
+ }
140
+ catch (e) {
141
+ this.errormessage = e.message;
142
+ return;
143
+ }
144
+ }
145
+ this.strvalue = this._inputElem.value;
146
+ this.value = NumberUtils.stringToNumber(value);
147
+ }
148
+ else {
149
+ this.strvalue = undefined;
150
+ this.value = undefined;
151
+ }
152
+ this.adjustFloatingLabel();
153
+ }
154
+ }
155
+ handleChange() {
156
+ this._inputElem.value = this.settingStrValueIntNumber(this._inputElem.value);
157
+ }
158
+ handleSlotChange(ev) {
159
+ const slot = ev.target;
160
+ const content = slot.assignedElements()[0];
161
+ content.style.position = "absolute";
162
+ content.style.display = "flex";
163
+ content.style.alignItems = "center";
164
+ content.style.justifyContent = "center";
165
+ content.style.overflow = "hidden";
166
+ content.style.top = "0px";
167
+ content.style.width = "var(--ni__icon--width)";
168
+ content.style.height = "var(--ni--height)";
169
+ if (slot.name == "leftIcon") {
170
+ content.style.left = "0px";
171
+ content.style.borderRadius = "var(--ni--border-radius) 0 0 var(--ni--border-radius)";
172
+ this._inputElem.classList.add('icon--left');
173
+ if (this._labelElem) {
174
+ this._labelElem.classList.add("input__label--left");
175
+ }
176
+ }
177
+ else if (slot.name == "rightIcon") {
178
+ content.style.right = "0px";
179
+ content.style.borderRadius = "0 var(--ni--border-radius) var(--ni--border-radius) 0";
180
+ this._inputElem.classList.add('icon--right');
181
+ }
182
+ this.showError();
183
+ }
184
+ doFocus() {
185
+ if (this.label && this._labelElem) {
186
+ this._labelElem.classList.contains("input__label--floated") ? undefined : this._labelElem.classList.add("input__label--floated");
187
+ }
188
+ }
189
+ settingComponent() {
190
+ const value = '' + this.value;
191
+ if (this.value !== undefined) {
192
+ try {
193
+ this._inputElem.value = this.formatnumber.toUpperCase() !== "EN-US" ? NumberUtils.format(value, this.precision, this.prettyprecision) : NumberUtils.changeFormat(NumberUtils.format(value, this.precision, this.prettyprecision));
194
+ }
195
+ catch (e) {
196
+ this.errormessage = e.message;
197
+ return;
198
+ }
199
+ this.strvalue = this._inputElem.value;
200
+ }
201
+ this.adjustFloatingLabel();
202
+ }
203
+ settingValue() {
204
+ //this.value: en-US format => Need to convert
205
+ const value = !isNaN(this.value) ? '' + this.value : 'NaN';
206
+ if (!this.checkNumberValidation(value)) {
207
+ return;
208
+ }
209
+ //output default from ".format": pt-BR
210
+ const tempStrValue = NumberUtils.format(value, this.precision, this.prettyprecision);
211
+ //output => depends to formatnumber
212
+ this.strvalue = this.formatnumber.toUpperCase() !== 'EN-US' ? tempStrValue : NumberUtils.changeFormat(tempStrValue);
213
+ NumberUtils.format(this.value.toString(), this.precision, this.prettyprecision);
214
+ }
215
+ //---------------------------------------------
216
+ // Lifecycle web component
217
+ //---------------------------------------------
218
+ componentDidLoad() {
219
+ if (!this.textleft) {
220
+ this._inputElem.classList.add('text--right');
221
+ }
222
+ this.showError();
223
+ this.adjustFloatingLabel();
224
+ }
225
+ componentWillLoad() {
226
+ this.onPrecisionChanged(this.precision);
227
+ this.onPrettyPrecisionChanged(this.prettyprecision);
228
+ this.settingValue();
229
+ }
230
+ render() {
231
+ const labelInput = this.label ? h("label", { onClick: () => this._inputElem.focus(), class: "input__label", ref: (el) => this._labelElem = el }, this.label) : null;
232
+ return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), labelInput, h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", value: this.strvalue, disabled: !this.enabled, onInput: this.handleChange.bind(this), onFocusout: this.handleFocusout.bind(this) }), h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el }, this.errormessage)));
233
+ }
234
+ get el() { return getElement(this); }
235
+ static get watchers() { return {
236
+ "errormessage": ["showError"],
237
+ "precision": ["onPrecisionChanged"],
238
+ "prettyprecision": ["onPrettyPrecisionChanged"],
239
+ "value": ["onValueChanged"]
240
+ }; }
241
+ };
242
242
  NumberInput.style = ezNumberInputCss;
243
243
 
244
244
  export { NumberInput as ez_number_input };