@sankhyalabs/ezui 1.1.4 → 1.1.5

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-6a98d9de.js} +379 -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 +3338 -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 +365 -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 +204 -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 +5065 -0
  70. package/dist/esm/DataUnit-ac4cc054.js +375 -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 +3321 -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-185c57f4.js +1 -0
  92. package/dist/ezui/p-22b82efb.entry.js +1 -0
  93. package/dist/ezui/p-346050cf.entry.js +1 -0
  94. package/dist/ezui/p-593c03ba.js +1 -0
  95. package/dist/ezui/p-77fdb4fd.entry.js +1 -0
  96. package/dist/ezui/p-9dfccb16.js +1 -0
  97. package/dist/ezui/p-dd4331b7.entry.js +1 -0
  98. package/dist/ezui/p-f6fd31ab.entry.js +1 -0
  99. package/dist/ezui/p-f95e3c71.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,224 @@
1
+ import { Component, Host, h, Prop, Watch, Event } from '@stencil/core';
2
+ export class EzModal {
3
+ constructor() {
4
+ /**
5
+ * Controle de exibição do Modal
6
+ */
7
+ this.oppened = true;
8
+ /**
9
+ * Define se o modal será fechado ao digitar ESC
10
+ */
11
+ this.closeesc = false;
12
+ /**
13
+ * Define se o modal será fechado ao clicar fora do conteúdo.
14
+ */
15
+ this.closeoutsideclick = false;
16
+ this.handleKeyboardEvent = (ev) => {
17
+ console.log(ev === null || ev === void 0 ? void 0 : ev.key);
18
+ if ((ev === null || ev === void 0 ? void 0 : ev.key) === 'Escape' && this.closeesc) {
19
+ this.oppened = false;
20
+ debugger;
21
+ this.ezChange.emit(this.oppened);
22
+ }
23
+ };
24
+ }
25
+ handleClickOverlay(ev) {
26
+ ev === null || ev === void 0 ? void 0 : ev.stopPropagation();
27
+ if (ev instanceof PointerEvent && this.closeoutsideclick) {
28
+ this.oppened = false;
29
+ debugger;
30
+ this.ezChange.emit(this.oppened);
31
+ }
32
+ }
33
+ handleOppenedChange() {
34
+ if (this.oppened) {
35
+ document.addEventListener('keydown', this.handleKeyboardEvent);
36
+ }
37
+ else {
38
+ document.removeEventListener('keydown', this.handleKeyboardEvent);
39
+ }
40
+ }
41
+ ///////
42
+ // trapTabKey(e) {
43
+ // // Check for TAB key press
44
+ // if (e.keyCode === 9) {
45
+ // // SHIFT + TAB
46
+ // if (e.shiftKey) {
47
+ // if (document.activeElement === this._firstTabStop) {
48
+ // e.preventDefault();
49
+ // this._lastTabStop.focus();
50
+ // }
51
+ // // TAB
52
+ // } else {
53
+ // if (document.activeElement === this._lastTabStop) {
54
+ // e.preventDefault();
55
+ // this._firstTabStop.focus();
56
+ // }
57
+ // }
58
+ // }
59
+ // if (e.keyCode === 27) {
60
+ // this.closeModal();
61
+ // }
62
+ // }
63
+ // closeModal() {
64
+ // this.oppened = false;
65
+ // this._focusedElementBeforeModal.focus();
66
+ // }
67
+ // componentDidLoad() {
68
+ // this._overlay.addEventListener('keydown', (ev) => { this.trapTabKey(ev) });
69
+ // // Save current focus
70
+ // this._focusedElementBeforeModal = document.activeElement;
71
+ // // Find all focusable children
72
+ // var focusableElementsString = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]';
73
+ // var focusableElements = this._modalContainer.querySelectorAll(focusableElementsString);
74
+ // // Convert NodeList to Array
75
+ // focusableElements = Array.prototype.slice.call(focusableElements);
76
+ // this._firstTabStop = focusableElements[0];
77
+ // this._lastTabStop = focusableElements[focusableElements.length - 1];
78
+ // // Focus first child
79
+ // this._firstTabStop.focus();
80
+ // }
81
+ // componentDidUpdate() {
82
+ // var focusableElementsString = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]';
83
+ // var focusableElements = this._modalContainer.querySelectorAll(focusableElementsString);
84
+ // }
85
+ /////
86
+ componentDidLoad() {
87
+ this.handleOppenedChange();
88
+ }
89
+ //Ainda teremos ajustes visuais
90
+ render() {
91
+ return (h(Host, null, this.oppened ?
92
+ h("div", { class: 'modal' /* ref={el => this._overlay = el} */, onClick: (ev) => this.handleClickOverlay(ev) },
93
+ this.align === 'left'
94
+ ?
95
+ h("div", { onClick: (ev) => this.handleClickOverlay(ev), class: "modal__container modal__container--left" },
96
+ h("div", { onClick: (ev) => ev.stopPropagation(), class: "modal__content modal__content--left " + this.modalsize },
97
+ h("slot", null)))
98
+ : undefined,
99
+ this.align === 'right' ?
100
+ h("div", { onClick: (ev) => this.handleClickOverlay(ev), class: "modal__container modal__container--right" },
101
+ h("div", { onClick: (ev) => ev.stopPropagation(), class: "modal__content modal__content--right " + this.modalsize },
102
+ h("slot", null)))
103
+ : undefined)
104
+ : undefined));
105
+ }
106
+ static get is() { return "ez-modal"; }
107
+ static get encapsulation() { return "shadow"; }
108
+ static get originalStyleUrls() { return {
109
+ "$": ["ez-modal.css"]
110
+ }; }
111
+ static get styleUrls() { return {
112
+ "$": ["ez-modal.css"]
113
+ }; }
114
+ static get properties() { return {
115
+ "modalsize": {
116
+ "type": "string",
117
+ "mutable": true,
118
+ "complexType": {
119
+ "original": "string",
120
+ "resolved": "string",
121
+ "references": {}
122
+ },
123
+ "required": false,
124
+ "optional": false,
125
+ "docs": {
126
+ "tags": [],
127
+ "text": "Define o tamanho do modal devem ser utilizados os tamanhos definidos de colunas como \"col-sd-3\""
128
+ },
129
+ "attribute": "modalsize",
130
+ "reflect": true
131
+ },
132
+ "align": {
133
+ "type": "string",
134
+ "mutable": true,
135
+ "complexType": {
136
+ "original": "string",
137
+ "resolved": "string",
138
+ "references": {}
139
+ },
140
+ "required": false,
141
+ "optional": false,
142
+ "docs": {
143
+ "tags": [],
144
+ "text": "Define o alinhamento do modal, seus valores podem ser 'right' ou 'left'"
145
+ },
146
+ "attribute": "align",
147
+ "reflect": true
148
+ },
149
+ "oppened": {
150
+ "type": "boolean",
151
+ "mutable": true,
152
+ "complexType": {
153
+ "original": "boolean",
154
+ "resolved": "boolean",
155
+ "references": {}
156
+ },
157
+ "required": false,
158
+ "optional": false,
159
+ "docs": {
160
+ "tags": [],
161
+ "text": "Controle de exibi\u00E7\u00E3o do Modal"
162
+ },
163
+ "attribute": "oppened",
164
+ "reflect": true,
165
+ "defaultValue": "true"
166
+ },
167
+ "closeesc": {
168
+ "type": "boolean",
169
+ "mutable": true,
170
+ "complexType": {
171
+ "original": "boolean",
172
+ "resolved": "boolean",
173
+ "references": {}
174
+ },
175
+ "required": false,
176
+ "optional": false,
177
+ "docs": {
178
+ "tags": [],
179
+ "text": "Define se o modal ser\u00E1 fechado ao digitar ESC"
180
+ },
181
+ "attribute": "closeesc",
182
+ "reflect": true,
183
+ "defaultValue": "false"
184
+ },
185
+ "closeoutsideclick": {
186
+ "type": "boolean",
187
+ "mutable": true,
188
+ "complexType": {
189
+ "original": "boolean",
190
+ "resolved": "boolean",
191
+ "references": {}
192
+ },
193
+ "required": false,
194
+ "optional": false,
195
+ "docs": {
196
+ "tags": [],
197
+ "text": "Define se o modal ser\u00E1 fechado ao clicar fora do conte\u00FAdo."
198
+ },
199
+ "attribute": "closeoutsideclick",
200
+ "reflect": true,
201
+ "defaultValue": "false"
202
+ }
203
+ }; }
204
+ static get events() { return [{
205
+ "method": "ezChange",
206
+ "name": "ezChange",
207
+ "bubbles": true,
208
+ "cancelable": true,
209
+ "composed": true,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": "Um evento disparado quando a propriedade oppened \u00E9 alterada."
213
+ },
214
+ "complexType": {
215
+ "original": "boolean",
216
+ "resolved": "boolean",
217
+ "references": {}
218
+ }
219
+ }]; }
220
+ static get watchers() { return [{
221
+ "propName": "oppened",
222
+ "methodName": "handleOppenedChange"
223
+ }]; }
224
+ }
@@ -0,0 +1,144 @@
1
+ :host {
2
+ /* dimensions */
3
+ --ni--height: 42px;
4
+ --ni--width: 100%;
5
+ --ni__icon--width: 48px;
6
+ /* general */
7
+ --ni--border-radius: var(--border--radius-medium, 12px);
8
+ --ni--font-size: var(--text--medium, 14px);
9
+ --ni--font-family: var(--font-pattern, Arial);
10
+ /* input */
11
+ --ni__input--background-color: var(--background--medium, #e0e0e0);
12
+ --ni__input--border: var(--border--medium, 2px solid);
13
+ --ni__input--border-color: var(--ni__input--background-color);
14
+ /*no modo normal usamos a borda com a mesma cor do bg*/
15
+ --ni__input--focus--border-color: var(--color--primary, #008561);
16
+ --ni__input--disabled--background-color: var(--color--disable-secondary, #F2F5F8);
17
+ --ni__input--disabled--color: var(--text--disable, #AFB6C0);
18
+ --ni__input--error--border-color: #CC2936;
19
+ /* placeholder */
20
+ --ni__placeholder--disabled--color: var(--text--disable, #AFB6C0);
21
+ --ni__placeholder--color: var(--title--primary, #919191);
22
+ --ni__placeholder--font-weight: var(--text-weight--large, 500);
23
+ /* message box */
24
+ --ni__message_box--font-size: var(--text--small, 12px);
25
+ --ni__message_box--info--color: var(--color--success, #22085d);
26
+ --ni__message_box--error--color: var(--color--error, #FF0000);
27
+ /***************
28
+ host style
29
+ ***************/
30
+ /*private*/
31
+ display: flex;
32
+ flex-wrap: wrap;
33
+ position: relative;
34
+ /*public*/
35
+ width: var(--ni--width);
36
+ }
37
+
38
+ .invisible {
39
+ visibility: hidden;
40
+ }
41
+
42
+ input {
43
+ /*private*/
44
+ width: 100%;
45
+ box-sizing: border-box;
46
+ padding: var(--space--medium);
47
+ /*public*/
48
+ height: var(--ni--height);
49
+ border-radius: var(--ni--border-radius);
50
+ font-family: var(--ni--font-family);
51
+ font-size: var(--ni--font-size);
52
+ border: var(--ni__input--border);
53
+ border-color: var(--ni__input--border-color);
54
+ background-color: var(--ni__input--background-color);
55
+ font-weight: var(--text-weight--large);
56
+ }
57
+
58
+ input:disabled {
59
+ /*public*/
60
+ background-color: var(--ni__input--disabled--background-color);
61
+ color: var(--ni__input--disabled--color);
62
+ }
63
+
64
+ input:focus {
65
+ /*private*/
66
+ outline: none;
67
+ /*public*/
68
+ border-color: var(--ni__input--focus--border-color);
69
+ }
70
+
71
+ input.icon--left {
72
+ padding-left: var(--ni__icon--width);
73
+ }
74
+
75
+ input.icon--right {
76
+ padding-right: var(--ni__icon--width);
77
+ }
78
+
79
+ input::placeholder {
80
+ color: var(--ni__placeholder--color);
81
+ font-weight: var(--ni__placeholder--font-weight);
82
+ }
83
+
84
+ input:disabled::placeholder {
85
+ color: var(--ni__placeholder--disabled--color);
86
+ }
87
+
88
+ input.hasError {
89
+ color: inherit;
90
+ border-color: var(--ni__input--error--border-color);
91
+ }
92
+
93
+ input.text--right {
94
+ text-align: right;
95
+ }
96
+
97
+ .message-box {
98
+ /*private*/
99
+ min-height: 16px;
100
+ min-width: 100%;
101
+ margin-top: 2px;
102
+ ;
103
+ line-height: 12px;
104
+ /*public*/
105
+ font-family: var(--ni--font-family);
106
+ font-size: var(--ni__message_box--font-size);
107
+ color: var(--ni__message_box--info--color);
108
+ }
109
+
110
+ .hasError {
111
+ /*public*/
112
+ color: var(--ni__message_box--error--color);
113
+ }
114
+
115
+ .input__label {
116
+ /*public*/
117
+ font-size: var(--text--medium);
118
+ font-weight: var(--text-weight--large);
119
+ left: var(--space--medium);
120
+ position: absolute;
121
+ color: var(--title--primary);
122
+ top: var(--space--medium);
123
+ font-family: var(--ni--font-family);
124
+ -webkit-transition: font-size .3s, top .3s;
125
+ transition: font-size .3s, top .3s;
126
+ z-index: var(--visible);
127
+ }
128
+
129
+ .input__label--floated {
130
+ font-family: var(--ni--font-family);
131
+ font-size: var(--text--extra-small);
132
+ top: var(--space--small);
133
+ color: var(--text--primary);
134
+ }
135
+
136
+ .input__label--left {
137
+ /*public*/
138
+ left: var(--ni__icon--width);
139
+ }
140
+
141
+ .input--with--label {
142
+ /*public*/
143
+ padding-bottom: 0;
144
+ }
@@ -0,0 +1,465 @@
1
+ import { Component, h, Host, Prop, Watch, Method, Element } from '@stencil/core';
2
+ import { NumberUtils } from '@sankhyalabs/core';
3
+ export class NumberInput {
4
+ constructor() {
5
+ /**
6
+ * Deixa o campo disponível ou não para digitação.
7
+ */
8
+ this.enabled = true;
9
+ /**
10
+ * Deixa o campo disponível ou não para digitação.
11
+ */
12
+ this.textleft = false;
13
+ /**
14
+ * Opção de configurar a transformação de string to number entre formatação pt-BR e en-US
15
+ * (formatação de ENTRADA e SAÍDA do componente: pt-BR="###.###,##" en-US="###,###.##"; Default: "pt-BR")
16
+ * Qualquer outro valor que não seja "en-US", adotará a formatação "pt-BR"
17
+ * Não é case sensitive
18
+ */
19
+ this.formatnumber = "PT-BR";
20
+ //---------------------------------------------
21
+ // Private Methods
22
+ //---------------------------------------------
23
+ this.settingStrValueIntNumber = (strvalue) => {
24
+ if (this.precision === 0 && strvalue) {
25
+ return strvalue = strvalue.replace(/\./g, '').replace(/\,/g, '');
26
+ }
27
+ else {
28
+ return strvalue;
29
+ }
30
+ };
31
+ this.checkNumberValidation = (valuePtBRorNumber) => {
32
+ try {
33
+ if (valuePtBRorNumber != "" && NumberUtils.format(valuePtBRorNumber, this.precision, this.prettyprecision) === "NaN") {
34
+ this.errormessage = `Valor não é um número válido`;
35
+ this.value = undefined;
36
+ this.strvalue = undefined;
37
+ if (this._inputElem) {
38
+ this._inputElem.value = "";
39
+ }
40
+ return false;
41
+ }
42
+ }
43
+ catch (err) {
44
+ this.errormessage = err.message;
45
+ return false;
46
+ }
47
+ return true;
48
+ };
49
+ }
50
+ showError() {
51
+ const hasError = typeof this.errormessage === 'string' && this.errormessage !== '';
52
+ if (this._inputElem) {
53
+ if (hasError) {
54
+ this._inputElem.classList.add('hasError');
55
+ this._messageBoxElem.classList.add('hasError');
56
+ }
57
+ else {
58
+ this._inputElem.classList.remove('hasError');
59
+ this._messageBoxElem.classList.remove('hasError');
60
+ }
61
+ }
62
+ }
63
+ onPrecisionChanged(newPrecision) {
64
+ if (isNaN(newPrecision)) {
65
+ this.precision = 0;
66
+ }
67
+ this.handleFocusout();
68
+ }
69
+ onPrettyPrecisionChanged(newPrettyPrecision) {
70
+ if (isNaN(newPrettyPrecision)) {
71
+ this.prettyprecision = 0;
72
+ }
73
+ this.handleFocusout();
74
+ }
75
+ onValueChanged(newValue) {
76
+ if (isNaN(newValue) && newValue !== undefined) {
77
+ this.value = undefined;
78
+ this.strvalue = "";
79
+ this.errormessage = `Valor não é um número válido`;
80
+ this.adjustFloatingLabel();
81
+ }
82
+ else {
83
+ this.settingComponent();
84
+ }
85
+ }
86
+ adjustFloatingLabel() {
87
+ if (this._labelElem) {
88
+ if (this.label && this._inputElem.value && this._inputElem.value.toString().length > 0) {
89
+ if (!this._labelElem.classList.contains("input__label--floated")) {
90
+ this._labelElem.classList.add("input__label--floated");
91
+ }
92
+ if (!this._inputElem.classList.contains("input--with--label")) {
93
+ this._inputElem.classList.add("input--with--label");
94
+ }
95
+ }
96
+ else {
97
+ this._labelElem.classList.remove("input__label--floated");
98
+ }
99
+ }
100
+ }
101
+ //---------------------------------------------
102
+ // Public methods
103
+ //---------------------------------------------
104
+ /**
105
+ * Faz o foco no componente de input
106
+ */
107
+ async setFocus() {
108
+ this._inputElem.focus();
109
+ }
110
+ /**
111
+ * Remove o foco no componente de input
112
+ */
113
+ async setBlur() {
114
+ this._inputElem.blur();
115
+ }
116
+ //---------------------------------------------
117
+ // Event handlers
118
+ //---------------------------------------------
119
+ /**
120
+ * Promove a atualização do componente
121
+ */
122
+ async handleFocusout() {
123
+ //Setting value and strvalue by stringinput
124
+ if (this._inputElem) {
125
+ this.errormessage = "";
126
+ if (this._inputElem.value !== "") {
127
+ this._inputElem.value = this.settingStrValueIntNumber(this._inputElem.value);
128
+ const value = NumberUtils.keepOnlyDecimalSeparator(this._inputElem.value, this.formatnumber.toUpperCase());
129
+ if (!this.checkNumberValidation(value)) {
130
+ return;
131
+ }
132
+ if (value) {
133
+ try {
134
+ this._inputElem.value = this.formatnumber.toUpperCase() !== "EN-US" ? NumberUtils.format(value, this.precision, this.prettyprecision) : NumberUtils.changeFormat(NumberUtils.format(value, this.precision, this.prettyprecision));
135
+ }
136
+ catch (e) {
137
+ this.errormessage = e.message;
138
+ return;
139
+ }
140
+ }
141
+ this.strvalue = this._inputElem.value;
142
+ this.value = NumberUtils.stringToNumber(value);
143
+ }
144
+ else {
145
+ this.strvalue = undefined;
146
+ this.value = undefined;
147
+ }
148
+ this.adjustFloatingLabel();
149
+ }
150
+ }
151
+ handleChange() {
152
+ this._inputElem.value = this.settingStrValueIntNumber(this._inputElem.value);
153
+ }
154
+ handleSlotChange(ev) {
155
+ const slot = ev.target;
156
+ const content = slot.assignedElements()[0];
157
+ content.style.position = "absolute";
158
+ content.style.display = "flex";
159
+ content.style.alignItems = "center";
160
+ content.style.justifyContent = "center";
161
+ content.style.overflow = "hidden";
162
+ content.style.top = "0px";
163
+ content.style.width = "var(--ni__icon--width)";
164
+ content.style.height = "var(--ni--height)";
165
+ if (slot.name == "leftIcon") {
166
+ content.style.left = "0px";
167
+ content.style.borderRadius = "var(--ni--border-radius) 0 0 var(--ni--border-radius)";
168
+ this._inputElem.classList.add('icon--left');
169
+ if (this._labelElem) {
170
+ this._labelElem.classList.add("input__label--left");
171
+ }
172
+ }
173
+ else if (slot.name == "rightIcon") {
174
+ content.style.right = "0px";
175
+ content.style.borderRadius = "0 var(--ni--border-radius) var(--ni--border-radius) 0";
176
+ this._inputElem.classList.add('icon--right');
177
+ }
178
+ this.showError();
179
+ }
180
+ doFocus() {
181
+ if (this.label && this._labelElem) {
182
+ this._labelElem.classList.contains("input__label--floated") ? undefined : this._labelElem.classList.add("input__label--floated");
183
+ }
184
+ }
185
+ settingComponent() {
186
+ const value = '' + this.value;
187
+ if (this.value !== undefined) {
188
+ try {
189
+ this._inputElem.value = this.formatnumber.toUpperCase() !== "EN-US" ? NumberUtils.format(value, this.precision, this.prettyprecision) : NumberUtils.changeFormat(NumberUtils.format(value, this.precision, this.prettyprecision));
190
+ }
191
+ catch (e) {
192
+ this.errormessage = e.message;
193
+ return;
194
+ }
195
+ this.strvalue = this._inputElem.value;
196
+ }
197
+ this.adjustFloatingLabel();
198
+ }
199
+ settingValue() {
200
+ //this.value: en-US format => Need to convert
201
+ const value = !isNaN(this.value) ? '' + this.value : 'NaN';
202
+ if (!this.checkNumberValidation(value)) {
203
+ return;
204
+ }
205
+ //output default from ".format": pt-BR
206
+ const tempStrValue = NumberUtils.format(value, this.precision, this.prettyprecision);
207
+ //output => depends to formatnumber
208
+ this.strvalue = this.formatnumber.toUpperCase() !== 'EN-US' ? tempStrValue : NumberUtils.changeFormat(tempStrValue);
209
+ NumberUtils.format(this.value.toString(), this.precision, this.prettyprecision);
210
+ }
211
+ //---------------------------------------------
212
+ // Lifecycle web component
213
+ //---------------------------------------------
214
+ componentDidLoad() {
215
+ if (!this.textleft) {
216
+ this._inputElem.classList.add('text--right');
217
+ }
218
+ this.showError();
219
+ this.adjustFloatingLabel();
220
+ }
221
+ componentWillLoad() {
222
+ this.onPrecisionChanged(this.precision);
223
+ this.onPrettyPrecisionChanged(this.prettyprecision);
224
+ this.settingValue();
225
+ }
226
+ render() {
227
+ const labelInput = this.label ? h("label", { onClick: () => this._inputElem.focus(), class: "input__label", ref: (el) => this._labelElem = el }, this.label) : null;
228
+ return (h(Host, null,
229
+ h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
230
+ labelInput,
231
+ 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) }),
232
+ h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }),
233
+ h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el }, this.errormessage)));
234
+ }
235
+ static get is() { return "ez-number-input"; }
236
+ static get encapsulation() { return "shadow"; }
237
+ static get originalStyleUrls() { return {
238
+ "$": ["ez-number-input.css"]
239
+ }; }
240
+ static get styleUrls() { return {
241
+ "$": ["ez-number-input.css"]
242
+ }; }
243
+ static get properties() { return {
244
+ "strvalue": {
245
+ "type": "string",
246
+ "mutable": true,
247
+ "complexType": {
248
+ "original": "string",
249
+ "resolved": "string",
250
+ "references": {}
251
+ },
252
+ "required": false,
253
+ "optional": false,
254
+ "docs": {
255
+ "tags": [],
256
+ "text": "Valor digitado pelo usu\u00E1rio. Este valor \u00E9 o que fica vis\u00EDvel no campo."
257
+ },
258
+ "attribute": "strvalue",
259
+ "reflect": false
260
+ },
261
+ "value": {
262
+ "type": "number",
263
+ "mutable": true,
264
+ "complexType": {
265
+ "original": "number",
266
+ "resolved": "number",
267
+ "references": {}
268
+ },
269
+ "required": false,
270
+ "optional": false,
271
+ "docs": {
272
+ "tags": [],
273
+ "text": "Valor guardado pelo componente. Este valor \u00E9 o que ira ser utilizado para alimentar o backend.\nEsta vari\u00E1vel pode ser setada para alimentar o componente."
274
+ },
275
+ "attribute": "value",
276
+ "reflect": false
277
+ },
278
+ "label": {
279
+ "type": "string",
280
+ "mutable": false,
281
+ "complexType": {
282
+ "original": "string",
283
+ "resolved": "string",
284
+ "references": {}
285
+ },
286
+ "required": false,
287
+ "optional": false,
288
+ "docs": {
289
+ "tags": [],
290
+ "text": "Label \u00E9 o t\u00EDtulo do campo"
291
+ },
292
+ "attribute": "label",
293
+ "reflect": true
294
+ },
295
+ "enabled": {
296
+ "type": "boolean",
297
+ "mutable": false,
298
+ "complexType": {
299
+ "original": "boolean",
300
+ "resolved": "boolean",
301
+ "references": {}
302
+ },
303
+ "required": false,
304
+ "optional": false,
305
+ "docs": {
306
+ "tags": [],
307
+ "text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para digita\u00E7\u00E3o."
308
+ },
309
+ "attribute": "enabled",
310
+ "reflect": true,
311
+ "defaultValue": "true"
312
+ },
313
+ "errormessage": {
314
+ "type": "string",
315
+ "mutable": true,
316
+ "complexType": {
317
+ "original": "string",
318
+ "resolved": "string",
319
+ "references": {}
320
+ },
321
+ "required": false,
322
+ "optional": false,
323
+ "docs": {
324
+ "tags": [],
325
+ "text": "Quando h\u00E1 um problema de valida\u00E7\u00E3o, serve como orienta\u00E7\u00E3o ao usu\u00E1rio"
326
+ },
327
+ "attribute": "errormessage",
328
+ "reflect": true
329
+ },
330
+ "precision": {
331
+ "type": "number",
332
+ "mutable": true,
333
+ "complexType": {
334
+ "original": "number",
335
+ "resolved": "number",
336
+ "references": {}
337
+ },
338
+ "required": false,
339
+ "optional": false,
340
+ "docs": {
341
+ "tags": [],
342
+ "text": "Precis\u00E3o de arredondamento do n\u00FAmero"
343
+ },
344
+ "attribute": "precision",
345
+ "reflect": true
346
+ },
347
+ "prettyprecision": {
348
+ "type": "number",
349
+ "mutable": true,
350
+ "complexType": {
351
+ "original": "number",
352
+ "resolved": "number",
353
+ "references": {}
354
+ },
355
+ "required": false,
356
+ "optional": false,
357
+ "docs": {
358
+ "tags": [],
359
+ "text": "N\u00FAmeros de zeros retirados ap\u00F3s arredondamento"
360
+ },
361
+ "attribute": "prettyprecision",
362
+ "reflect": true
363
+ },
364
+ "textleft": {
365
+ "type": "boolean",
366
+ "mutable": false,
367
+ "complexType": {
368
+ "original": "boolean",
369
+ "resolved": "boolean",
370
+ "references": {}
371
+ },
372
+ "required": false,
373
+ "optional": false,
374
+ "docs": {
375
+ "tags": [],
376
+ "text": "Deixa o campo dispon\u00EDvel ou n\u00E3o para digita\u00E7\u00E3o."
377
+ },
378
+ "attribute": "textleft",
379
+ "reflect": true,
380
+ "defaultValue": "false"
381
+ },
382
+ "formatnumber": {
383
+ "type": "string",
384
+ "mutable": false,
385
+ "complexType": {
386
+ "original": "string",
387
+ "resolved": "string",
388
+ "references": {}
389
+ },
390
+ "required": false,
391
+ "optional": false,
392
+ "docs": {
393
+ "tags": [],
394
+ "text": "Op\u00E7\u00E3o de configurar a transforma\u00E7\u00E3o de string to number entre formata\u00E7\u00E3o pt-BR e en-US\n(formata\u00E7\u00E3o de ENTRADA e SA\u00CDDA do componente: pt-BR=\"###.###,##\" en-US=\"###,###.##\"; Default: \"pt-BR\")\nQualquer outro valor que n\u00E3o seja \"en-US\", adotar\u00E1 a formata\u00E7\u00E3o \"pt-BR\"\nN\u00E3o \u00E9 case sensitive"
395
+ },
396
+ "attribute": "formatnumber",
397
+ "reflect": true,
398
+ "defaultValue": "\"PT-BR\""
399
+ }
400
+ }; }
401
+ static get methods() { return {
402
+ "setFocus": {
403
+ "complexType": {
404
+ "signature": "() => Promise<void>",
405
+ "parameters": [],
406
+ "references": {
407
+ "Promise": {
408
+ "location": "global"
409
+ }
410
+ },
411
+ "return": "Promise<void>"
412
+ },
413
+ "docs": {
414
+ "text": "Faz o foco no componente de input",
415
+ "tags": []
416
+ }
417
+ },
418
+ "setBlur": {
419
+ "complexType": {
420
+ "signature": "() => Promise<void>",
421
+ "parameters": [],
422
+ "references": {
423
+ "Promise": {
424
+ "location": "global"
425
+ }
426
+ },
427
+ "return": "Promise<void>"
428
+ },
429
+ "docs": {
430
+ "text": "Remove o foco no componente de input",
431
+ "tags": []
432
+ }
433
+ },
434
+ "handleFocusout": {
435
+ "complexType": {
436
+ "signature": "() => Promise<void>",
437
+ "parameters": [],
438
+ "references": {
439
+ "Promise": {
440
+ "location": "global"
441
+ }
442
+ },
443
+ "return": "Promise<void>"
444
+ },
445
+ "docs": {
446
+ "text": "Promove a atualiza\u00E7\u00E3o do componente",
447
+ "tags": []
448
+ }
449
+ }
450
+ }; }
451
+ static get elementRef() { return "el"; }
452
+ static get watchers() { return [{
453
+ "propName": "errormessage",
454
+ "methodName": "showError"
455
+ }, {
456
+ "propName": "precision",
457
+ "methodName": "onPrecisionChanged"
458
+ }, {
459
+ "propName": "prettyprecision",
460
+ "methodName": "onPrettyPrecisionChanged"
461
+ }, {
462
+ "propName": "value",
463
+ "methodName": "onValueChanged"
464
+ }]; }
465
+ }