@sankhyalabs/ezui 1.1.136 → 1.1.137

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 (110) hide show
  1. package/dist/cjs/ez-calendar.cjs.entry.js +2 -2
  2. package/dist/cjs/ez-check.cjs.entry.js +3 -3
  3. package/dist/cjs/ez-combo-box.cjs.entry.js +5 -5
  4. package/dist/cjs/ez-date-input.cjs.entry.js +10 -10
  5. package/dist/cjs/ez-date-time-input.cjs.entry.js +8 -8
  6. package/dist/cjs/ez-filter-input.cjs.entry.js +6 -6
  7. package/dist/cjs/ez-form.cjs.entry.js +36 -5
  8. package/dist/cjs/ez-grid.cjs.entry.js +4 -4
  9. package/dist/cjs/ez-modal.cjs.entry.js +3 -3
  10. package/dist/cjs/ez-number-input.cjs.entry.js +25 -18
  11. package/dist/cjs/ez-popover.cjs.entry.js +2 -2
  12. package/dist/cjs/ez-search.cjs.entry.js +2 -2
  13. package/dist/cjs/ez-text-area.cjs.entry.js +11 -11
  14. package/dist/cjs/ez-text-input.cjs.entry.js +22 -15
  15. package/dist/cjs/ez-time-input.cjs.entry.js +36 -30
  16. package/dist/cjs/ez-upload.cjs.entry.js +4 -4
  17. package/dist/cjs/ezui.cjs.js +1 -1
  18. package/dist/cjs/loader.cjs.js +1 -1
  19. package/dist/cjs/test-du.cjs.entry.js +43 -10
  20. package/dist/collection/components/ez-calendar/ez-calendar.js +2 -2
  21. package/dist/collection/components/ez-check/ez-check.js +3 -3
  22. package/dist/collection/components/ez-combo-box/ez-combo-box.js +5 -5
  23. package/dist/collection/components/ez-date-input/ez-date-input.js +10 -10
  24. package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +8 -8
  25. package/dist/collection/components/ez-filter-input/ez-filter-input.js +6 -6
  26. package/dist/collection/components/ez-form/ez-form.js +17 -2
  27. package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +19 -3
  28. package/dist/collection/components/ez-grid/ez-grid.js +4 -4
  29. package/dist/collection/components/ez-modal/ez-modal.js +3 -3
  30. package/dist/collection/components/ez-number-input/ez-number-input.js +26 -19
  31. package/dist/collection/components/ez-popover/ez-popover.js +2 -2
  32. package/dist/collection/components/ez-search/ez-search.js +2 -2
  33. package/dist/collection/components/ez-text-area/ez-text-area.js +11 -11
  34. package/dist/collection/components/ez-text-input/ez-text-input.js +40 -15
  35. package/dist/collection/components/ez-time-input/ez-time-input.js +52 -31
  36. package/dist/collection/components/ez-upload/ez-upload.js +4 -4
  37. package/dist/collection/components/test-du/test-du.js +44 -10
  38. package/dist/custom-elements/index.js +223 -139
  39. package/dist/esm/ez-calendar.entry.js +2 -2
  40. package/dist/esm/ez-check.entry.js +3 -3
  41. package/dist/esm/ez-combo-box.entry.js +5 -5
  42. package/dist/esm/ez-date-input.entry.js +10 -10
  43. package/dist/esm/ez-date-time-input.entry.js +8 -8
  44. package/dist/esm/ez-filter-input.entry.js +6 -6
  45. package/dist/esm/ez-form.entry.js +36 -5
  46. package/dist/esm/ez-grid.entry.js +4 -4
  47. package/dist/esm/ez-modal.entry.js +3 -3
  48. package/dist/esm/ez-number-input.entry.js +25 -18
  49. package/dist/esm/ez-popover.entry.js +2 -2
  50. package/dist/esm/ez-search.entry.js +2 -2
  51. package/dist/esm/ez-text-area.entry.js +11 -11
  52. package/dist/esm/ez-text-input.entry.js +22 -15
  53. package/dist/esm/ez-time-input.entry.js +37 -31
  54. package/dist/esm/ez-upload.entry.js +4 -4
  55. package/dist/esm/ezui.js +1 -1
  56. package/dist/esm/loader.js +1 -1
  57. package/dist/esm/test-du.entry.js +43 -10
  58. package/dist/ezui/ezui.esm.js +1 -1
  59. package/dist/ezui/p-248361f5.entry.js +1 -0
  60. package/dist/ezui/p-30e3793f.entry.js +1 -0
  61. package/dist/ezui/p-4c3cd534.entry.js +1 -0
  62. package/dist/ezui/{p-5f2add6f.entry.js → p-51cdfa9e.entry.js} +1 -1
  63. package/dist/ezui/p-659df655.entry.js +1 -0
  64. package/dist/ezui/p-6d4b1628.entry.js +1 -0
  65. package/dist/ezui/p-8be1a4d6.entry.js +1 -0
  66. package/dist/ezui/p-b65e22a1.entry.js +1 -0
  67. package/dist/ezui/p-b8d64970.entry.js +1 -0
  68. package/dist/ezui/{p-c6c91589.entry.js → p-c246e251.entry.js} +1 -1
  69. package/dist/ezui/p-c2de757f.entry.js +1 -0
  70. package/dist/ezui/p-c620258b.entry.js +1 -0
  71. package/dist/ezui/p-cb73bee7.entry.js +1 -0
  72. package/dist/ezui/p-db0981c1.entry.js +1 -0
  73. package/dist/ezui/p-dd6f4872.entry.js +1 -0
  74. package/dist/ezui/p-ec8419f1.entry.js +1 -0
  75. package/dist/ezui/p-fc9b9487.entry.js +1 -0
  76. package/dist/types/components/ez-calendar/ez-calendar.d.ts +1 -1
  77. package/dist/types/components/ez-check/ez-check.d.ts +1 -1
  78. package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +1 -1
  79. package/dist/types/components/ez-date-input/ez-date-input.d.ts +3 -3
  80. package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +3 -3
  81. package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +3 -3
  82. package/dist/types/components/ez-form/ez-form.d.ts +1 -1
  83. package/dist/types/components/ez-form/structure/FormSheetMetadata.d.ts +3 -0
  84. package/dist/types/components/ez-grid/ez-grid.d.ts +1 -1
  85. package/dist/types/components/ez-modal/ez-modal.d.ts +1 -1
  86. package/dist/types/components/ez-number-input/ez-number-input.d.ts +3 -3
  87. package/dist/types/components/ez-popover/ez-popover.d.ts +1 -1
  88. package/dist/types/components/ez-search/ez-search.d.ts +1 -1
  89. package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -4
  90. package/dist/types/components/ez-text-input/ez-text-input.d.ts +8 -4
  91. package/dist/types/components/ez-time-input/ez-time-input.d.ts +9 -3
  92. package/dist/types/components/ez-upload/ez-upload.d.ts +2 -2
  93. package/dist/types/components/test-du/test-du.d.ts +1 -0
  94. package/dist/types/components.d.ts +12 -0
  95. package/package.json +1 -1
  96. package/dist/ezui/p-097d5dc6.entry.js +0 -1
  97. package/dist/ezui/p-0fd2624d.entry.js +0 -1
  98. package/dist/ezui/p-1587cbbc.entry.js +0 -1
  99. package/dist/ezui/p-18d67107.entry.js +0 -1
  100. package/dist/ezui/p-49f70be3.entry.js +0 -1
  101. package/dist/ezui/p-50038ae3.entry.js +0 -1
  102. package/dist/ezui/p-53110643.entry.js +0 -1
  103. package/dist/ezui/p-685a35b3.entry.js +0 -1
  104. package/dist/ezui/p-699c31d1.entry.js +0 -1
  105. package/dist/ezui/p-6c22c9f9.entry.js +0 -1
  106. package/dist/ezui/p-a1304302.entry.js +0 -1
  107. package/dist/ezui/p-b2cc27e5.entry.js +0 -1
  108. package/dist/ezui/p-b71d454d.entry.js +0 -1
  109. package/dist/ezui/p-cbb62e2c.entry.js +0 -1
  110. package/dist/ezui/p-dcf5f013.entry.js +0 -1
@@ -11,17 +11,17 @@ export class EzFilterInput {
11
11
  */
12
12
  this.mode = "regular";
13
13
  }
14
- setLabel() {
14
+ observeLabel() {
15
15
  if (this._textInput) {
16
16
  this._textInput.label = this.label;
17
17
  }
18
18
  }
19
- setErrorMessage() {
19
+ observeErrorMessage() {
20
20
  if (this._textInput) {
21
21
  this._textInput.errorMessage = this.errorMessage;
22
22
  }
23
23
  }
24
- applyValueToInput() {
24
+ observeValue() {
25
25
  if (this._textInput) {
26
26
  this._textInput.value = this.value;
27
27
  }
@@ -237,12 +237,12 @@ export class EzFilterInput {
237
237
  static get elementRef() { return "_elem"; }
238
238
  static get watchers() { return [{
239
239
  "propName": "label",
240
- "methodName": "setLabel"
240
+ "methodName": "observeLabel"
241
241
  }, {
242
242
  "propName": "errorMessage",
243
- "methodName": "setErrorMessage"
243
+ "methodName": "observeErrorMessage"
244
244
  }, {
245
245
  "propName": "value",
246
- "methodName": "applyValueToInput"
246
+ "methodName": "observeValue"
247
247
  }]; }
248
248
  }
@@ -37,7 +37,7 @@ export class EzForm {
37
37
  accept();
38
38
  });
39
39
  }
40
- configChanged() {
40
+ observeConfig() {
41
41
  this.processMetadata();
42
42
  }
43
43
  validateRequired(requiredFields, record) {
@@ -99,6 +99,21 @@ export class EzForm {
99
99
  }));
100
100
  }
101
101
  }
102
+ if (action.type === Action.RECORDS_ADDED) {
103
+ debugger;
104
+ const metadata = selectFormMetadata(this._store.getState());
105
+ const defaultValues = metadata.getDefaultValues();
106
+ if (defaultValues) {
107
+ const records = action.payload;
108
+ return new DataUnitAction(Action.RECORDS_ADDED, records.map(record => {
109
+ const newRecord = Object.assign({}, record);
110
+ for (const field in defaultValues) {
111
+ newRecord[field] = this.dataUnit.valueFromString(field, defaultValues[field]);
112
+ }
113
+ return newRecord;
114
+ }));
115
+ }
116
+ }
102
117
  return action;
103
118
  }
104
119
  componentWillLoad() {
@@ -252,6 +267,6 @@ export class EzForm {
252
267
  static get elementRef() { return "_element"; }
253
268
  static get watchers() { return [{
254
269
  "propName": "config",
255
- "methodName": "configChanged"
270
+ "methodName": "observeConfig"
256
271
  }]; }
257
272
  }
@@ -3,6 +3,7 @@ export class FormMetadata {
3
3
  this._sheets = new Map();
4
4
  this._requiredFields = [];
5
5
  this._cleanOnCopyFields = [];
6
+ this._defaultValues = {};
6
7
  }
7
8
  getSheet(name) {
8
9
  return this._sheets.get(name);
@@ -14,6 +15,7 @@ export class FormMetadata {
14
15
  this._sheets.set(sheet.name, sheet);
15
16
  this._requiredFields = this._requiredFields.concat(sheet.requiredFields);
16
17
  this._cleanOnCopyFields = this._cleanOnCopyFields.concat(sheet.cleanOnCopyFields);
18
+ this._defaultValues = sheet.defaultValues;
17
19
  }
18
20
  getRequiredFields() {
19
21
  return this._requiredFields;
@@ -21,6 +23,9 @@ export class FormMetadata {
21
23
  getCleanOnCopyFields() {
22
24
  return this._cleanOnCopyFields;
23
25
  }
26
+ getDefaultValues() {
27
+ return this._defaultValues;
28
+ }
24
29
  }
25
30
  export const buildFromDataUnit = (dataUnit) => {
26
31
  var _a;
@@ -28,6 +33,10 @@ export const buildFromDataUnit = (dataUnit) => {
28
33
  const metadata = new FormMetadata();
29
34
  if (unitMD) {
30
35
  const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
36
+ let defaultValues = {};
37
+ visibleFields
38
+ .filter(descriptor => descriptor.defaultValue)
39
+ .map((descriptor) => defaultValues[descriptor.name] = descriptor.defaultValue);
31
40
  metadata.addSheet({
32
41
  label: unitMD.label,
33
42
  name: unitMD.name,
@@ -37,7 +46,8 @@ export const buildFromDataUnit = (dataUnit) => {
37
46
  .map(descriptor => descriptor.name),
38
47
  cleanOnCopyFields: visibleFields
39
48
  .filter(descriptor => { var _a; return (_a = descriptor.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy; })
40
- .map(descriptor => descriptor.name)
49
+ .map(descriptor => descriptor.name),
50
+ defaultValues
41
51
  });
42
52
  }
43
53
  return metadata;
@@ -53,8 +63,9 @@ export const buildFromConfig = (fields, dataUnit) => {
53
63
  const sheets = new Map();
54
64
  const requiredFields = [];
55
65
  const cleanOnCopyFields = [];
66
+ const defaultValues = {};
56
67
  fields.forEach(config => {
57
- var _a;
68
+ var _a, _b;
58
69
  if (config.visible !== false) {
59
70
  const tabConfig = getTabConfig(config.tab || "Geral", sheets);
60
71
  const descriptor = dataUnit.getField(config.name);
@@ -71,6 +82,10 @@ export const buildFromConfig = (fields, dataUnit) => {
71
82
  if (clearOnCopy) {
72
83
  cleanOnCopyFields.push(config.name);
73
84
  }
85
+ const defaultValue = config.defaultValue === undefined ? (_b = descriptor.properties) === null || _b === void 0 ? void 0 : _b.defaultValue : config.defaultValue;
86
+ if (defaultValue) {
87
+ defaultValues[config.name] = config.defaultValue;
88
+ }
74
89
  const fieldMD = { config, descriptor };
75
90
  const group = config.group;
76
91
  if (group) {
@@ -97,7 +112,8 @@ export const buildFromConfig = (fields, dataUnit) => {
97
112
  name: key.label,
98
113
  items: Array.from(value.values()),
99
114
  requiredFields,
100
- cleanOnCopyFields
115
+ cleanOnCopyFields,
116
+ defaultValues
101
117
  });
102
118
  });
103
119
  return metadata;
@@ -226,7 +226,7 @@ export class EzGrid {
226
226
  this._gridController.setColumnsDef(this._dataUnitBridge.buildColumnDefs(), true);
227
227
  }
228
228
  if (this.config) {
229
- this.applyConfig(this.config);
229
+ this.observeConfig(this.config);
230
230
  }
231
231
  }
232
232
  disconnectedCallback() {
@@ -246,7 +246,7 @@ export class EzGrid {
246
246
  h("ez-button", { size: "small", iconName: "chevron-right", class: "ez-margin-right--medium", mode: "icon", enabled: this._navigationHasNext, onClick: () => this.nextPage(), label: "Pr\u00F3xima P\u00E1gina" })
247
247
  ];
248
248
  }
249
- applyConfig(config) {
249
+ observeConfig(config) {
250
250
  this._gridController.setColumnsState(config.columns);
251
251
  this.closeGridConfig();
252
252
  }
@@ -267,7 +267,7 @@ export class EzGrid {
267
267
  h("div", { class: "grid__container ez-grid", ref: elem => this._container = elem }),
268
268
  h("div", { class: "grid__footer" }),
269
269
  h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._popUpGridConfig, onEzCloseModal: () => this.closeGridConfig() },
270
- h("grid-config", { ref: ref => this._gridConfig = ref, config: this.config, selectedTab: "Colunas", onConfigFinish: evt => { this.applyConfig(evt.detail); this.configChange.emit(evt.detail); }, onConfigCancel: _evt => this.closeGridConfig() }))));
270
+ h("grid-config", { ref: ref => this._gridConfig = ref, config: this.config, selectedTab: "Colunas", onConfigFinish: evt => { this.observeConfig(evt.detail); this.configChange.emit(evt.detail); }, onConfigCancel: _evt => this.closeGridConfig() }))));
271
271
  }
272
272
  static get is() { return "ez-grid"; }
273
273
  static get encapsulation() { return "scoped"; }
@@ -833,6 +833,6 @@ export class EzGrid {
833
833
  }; }
834
834
  static get watchers() { return [{
835
835
  "propName": "config",
836
- "methodName": "applyConfig"
836
+ "methodName": "observeConfig"
837
837
  }]; }
838
838
  }
@@ -19,7 +19,7 @@ export class EzModal {
19
19
  }
20
20
  };
21
21
  }
22
- handleopenedChange() {
22
+ observeOpened() {
23
23
  if (this.opened) {
24
24
  document.addEventListener("keydown", this.handleKeyboardEvent);
25
25
  }
@@ -32,7 +32,7 @@ export class EzModal {
32
32
  this.ezCloseModal.emit(this.opened);
33
33
  }
34
34
  componentDidLoad() {
35
- this.handleopenedChange();
35
+ this.observeOpened();
36
36
  }
37
37
  componentDidRender() {
38
38
  if (this.opened) {
@@ -186,6 +186,6 @@ export class EzModal {
186
186
  }]; }
187
187
  static get watchers() { return [{
188
188
  "propName": "opened",
189
- "methodName": "handleopenedChange"
189
+ "methodName": "observeOpened"
190
190
  }]; }
191
191
  }
@@ -1,5 +1,5 @@
1
1
  import { NumberUtils } from "@sankhyalabs/core";
2
- import { Component, h, Event, Prop, Watch, Element, Method } from "@stencil/core";
2
+ import { Component, h, Event, Prop, Element, Method, Watch } from "@stencil/core";
3
3
  import CSSVarsUtils from "../../utils/CSSVarsUtils";
4
4
  export class EzNumberInput {
5
5
  constructor() {
@@ -12,17 +12,6 @@ export class EzNumberInput {
12
12
  */
13
13
  this.mode = "regular";
14
14
  }
15
- setLabel() {
16
- this._textInput.label = this.label;
17
- }
18
- setErrorMessage() {
19
- this._textInput.errorMessage = this.errorMessage;
20
- }
21
- applyValueToInput() {
22
- if (this._textInput) {
23
- this._textInput.value = this.getTextValue(this.value);
24
- }
25
- }
26
15
  /**
27
16
  * Realiza o foco no componente de input
28
17
  */
@@ -35,16 +24,34 @@ export class EzNumberInput {
35
24
  async setBlur() {
36
25
  this._textInput.setBlur();
37
26
  }
27
+ observeLabel() {
28
+ if (this._textInput) {
29
+ this._textInput.label = this.label;
30
+ }
31
+ }
32
+ observeErrorMessage() {
33
+ if (this._textInput) {
34
+ this._textInput.errorMessage = this.errorMessage;
35
+ }
36
+ }
37
+ observeValue() {
38
+ if (this._textInput) {
39
+ this._textInput.value = this.getTextValue(this.value) || '';
40
+ }
41
+ }
38
42
  changeValue(newValue) {
39
43
  this.errorMessage = "";
40
44
  if (newValue !== this.value) {
41
45
  this.value = newValue;
42
46
  this.ezChange.emit(this.value);
43
47
  }
48
+ else {
49
+ this.observeValue();
50
+ }
44
51
  }
45
52
  parseNumber() {
46
- const parsedNumber = this._textInput.value ? NumberUtils.stringToNumber(this._textInput.value) : null;
47
- if (parsedNumber != null && isNaN(parsedNumber)) {
53
+ const parsedNumber = this._textInput.value ? NumberUtils.stringToNumber(this._textInput.value) : undefined;
54
+ if (parsedNumber !== undefined && isNaN(parsedNumber)) {
48
55
  this.errorMessage = "O valor digitado não é um número válido";
49
56
  }
50
57
  else {
@@ -61,13 +68,13 @@ export class EzNumberInput {
61
68
  if (value) {
62
69
  return this.precision > 0 ? NumberUtils.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
63
70
  }
64
- return null;
71
+ return undefined;
65
72
  }
66
73
  componentDidLoad() {
67
74
  CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
68
75
  }
69
76
  render() {
70
- return (h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, onEzChange: event => event.stopPropagation(), value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode }));
77
+ return (h("ez-text-input", { ref: elem => this._textInput = elem, onBlur: () => this.parseNumber(), label: this.label, value: this.getTextValue(this.value), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, slaveMode: true }));
71
78
  }
72
79
  static get is() { return "ez-number-input"; }
73
80
  static get encapsulation() { return "shadow"; }
@@ -253,12 +260,12 @@ export class EzNumberInput {
253
260
  static get elementRef() { return "_elem"; }
254
261
  static get watchers() { return [{
255
262
  "propName": "label",
256
- "methodName": "setLabel"
263
+ "methodName": "observeLabel"
257
264
  }, {
258
265
  "propName": "errorMessage",
259
- "methodName": "setErrorMessage"
266
+ "methodName": "observeErrorMessage"
260
267
  }, {
261
268
  "propName": "value",
262
- "methodName": "applyValueToInput"
269
+ "methodName": "observeValue"
263
270
  }]; }
264
271
  }
@@ -65,7 +65,7 @@ export class EzPopover {
65
65
  this.ezVisibilityChange.emit(false);
66
66
  };
67
67
  }
68
- dispatchVisibilityChange(newValue, oldValue) {
68
+ observeOpened(newValue, oldValue) {
69
69
  if (newValue != oldValue) {
70
70
  this.ezVisibilityChange.emit(newValue);
71
71
  }
@@ -372,6 +372,6 @@ export class EzPopover {
372
372
  static get elementRef() { return "_host"; }
373
373
  static get watchers() { return [{
374
374
  "propName": "opened",
375
- "methodName": "dispatchVisibilityChange"
375
+ "methodName": "observeOpened"
376
376
  }]; }
377
377
  }
@@ -23,7 +23,7 @@ export class EzSearch {
23
23
  */
24
24
  this.mode = "regular";
25
25
  }
26
- updateValue() {
26
+ observeValue() {
27
27
  if (this._comboElement) {
28
28
  this._comboElement.value = this.value;
29
29
  }
@@ -300,6 +300,6 @@ export class EzSearch {
300
300
  static get elementRef() { return "_elem"; }
301
301
  static get watchers() { return [{
302
302
  "propName": "value",
303
- "methodName": "updateValue"
303
+ "methodName": "observeValue"
304
304
  }]; }
305
305
  }
@@ -18,7 +18,7 @@ export class EzTextArea {
18
18
  */
19
19
  this.mode = "regular";
20
20
  }
21
- showError() {
21
+ observeErrorMessage() {
22
22
  var _a, _b;
23
23
  const hasError = typeof this.errorMessage === 'string' && this.errorMessage !== '';
24
24
  if (hasError) {
@@ -30,13 +30,13 @@ export class EzTextArea {
30
30
  (_b = this._messageBoxElem) === null || _b === void 0 ? void 0 : _b.classList.remove('hasError');
31
31
  }
32
32
  }
33
- updateInputValue() {
34
- this._inputElem.value = this.value === undefined ? "" : this.value;
33
+ observeValue() {
34
+ this._inputElem.value = this.value == undefined ? "" : this.value;
35
35
  this.handleChange();
36
36
  this.adjustFloatingLabel();
37
37
  this.ezChange.emit(this.value);
38
38
  }
39
- adjustRowsForMode() {
39
+ observeMode() {
40
40
  if (this._initialRows == undefined) {
41
41
  this._initialRows = this.rows > 0 ? this.rows : undefined;
42
42
  }
@@ -45,7 +45,7 @@ export class EzTextArea {
45
45
  this.rows = rows;
46
46
  }
47
47
  }
48
- adjustRowsValue() {
48
+ observeRows() {
49
49
  const rows = this.rows > 0 ? this.rows : this.mode != "slim" ? 4 : 2;
50
50
  if (rows !== this.rows) {
51
51
  this.rows = rows;
@@ -111,9 +111,9 @@ export class EzTextArea {
111
111
  // Lifecycle web component
112
112
  //---------------------------------------------
113
113
  componentDidLoad() {
114
- this.showError();
114
+ this.observeErrorMessage();
115
115
  this.adjustFloatingLabel();
116
- this.adjustRowsForMode();
116
+ this.observeMode();
117
117
  }
118
118
  render() {
119
119
  return (h(Host, null,
@@ -328,15 +328,15 @@ export class EzTextArea {
328
328
  static get elementRef() { return "_hostElement"; }
329
329
  static get watchers() { return [{
330
330
  "propName": "errorMessage",
331
- "methodName": "showError"
331
+ "methodName": "observeErrorMessage"
332
332
  }, {
333
333
  "propName": "value",
334
- "methodName": "updateInputValue"
334
+ "methodName": "observeValue"
335
335
  }, {
336
336
  "propName": "mode",
337
- "methodName": "adjustRowsForMode"
337
+ "methodName": "observeMode"
338
338
  }, {
339
339
  "propName": "rows",
340
- "methodName": "adjustRowsValue"
340
+ "methodName": "observeRows"
341
341
  }]; }
342
342
  }
@@ -14,8 +14,12 @@ export class EzTextInput {
14
14
  * Define o modo do tamanho do campo; opções: slim e regular.
15
15
  */
16
16
  this.mode = "regular";
17
+ /**
18
+ * Define se o controle de change do value será controlado por um componente pai.
19
+ */
20
+ this.slaveMode = false;
17
21
  }
18
- showError() {
22
+ observeErrorMessage() {
19
23
  var _a, _b;
20
24
  if (this._inputElem) {
21
25
  const hasError = typeof this.errorMessage === "string" && this.errorMessage !== "";
@@ -29,7 +33,7 @@ export class EzTextInput {
29
33
  }
30
34
  }
31
35
  }
32
- prepareMask() {
36
+ observeMask() {
33
37
  if (this.mask) {
34
38
  if (this._maskFormatter == undefined) {
35
39
  this._maskFormatter = new MaskFormatter(this.mask);
@@ -39,14 +43,17 @@ export class EzTextInput {
39
43
  }
40
44
  }
41
45
  }
42
- updateInputValue() {
46
+ observeValue() {
43
47
  if (this._inputElem) {
44
48
  this._inputElem.value = this.value;
45
49
  }
46
50
  this.handleChange();
51
+ this.adjustFloatingLabel();
52
+ if (this.slaveMode) {
53
+ return;
54
+ }
47
55
  this.errorMessage = "";
48
56
  this.ezChange.emit(this.value);
49
- this.adjustFloatingLabel();
50
57
  }
51
58
  adjustFloatingLabel() {
52
59
  if (this.label && this._labelElem) {
@@ -98,7 +105,7 @@ export class EzTextInput {
98
105
  this.errorMessage = e.message;
99
106
  }
100
107
  }
101
- this.canChangeValue();
108
+ this.controlChangeValue();
102
109
  this.adjustFloatingLabel();
103
110
  }
104
111
  isValidValue(value) {
@@ -107,7 +114,7 @@ export class EzTextInput {
107
114
  }
108
115
  return true;
109
116
  }
110
- canChangeValue() {
117
+ controlChangeValue() {
111
118
  if ((this.value || '') !== this._inputElem.value) {
112
119
  this.value = this._inputElem.value;
113
120
  }
@@ -121,9 +128,9 @@ export class EzTextInput {
121
128
  this._lastValidValue = value;
122
129
  }
123
130
  else {
124
- this._inputElem.value = this._lastValidValue === undefined ? "" : this._lastValidValue;
131
+ this._inputElem.value = this._lastValidValue == undefined ? "" : this._lastValidValue;
125
132
  }
126
- this.canChangeValue();
133
+ this.controlChangeValue();
127
134
  }
128
135
  handleSlotChange(ev) {
129
136
  const slot = ev.target;
@@ -154,7 +161,7 @@ export class EzTextInput {
154
161
  }
155
162
  }
156
163
  }
157
- this.showError();
164
+ this.observeErrorMessage();
158
165
  }
159
166
  doFocus() {
160
167
  if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
@@ -165,12 +172,12 @@ export class EzTextInput {
165
172
  // Lifecycle web component
166
173
  //---------------------------------------------
167
174
  componentDidLoad() {
168
- this.showError();
169
- this.prepareMask();
175
+ this.observeErrorMessage();
176
+ this.observeMask();
170
177
  this.adjustFloatingLabel();
171
178
  }
172
179
  componentWillLoad() {
173
- this.prepareMask();
180
+ this.observeMask();
174
181
  if (this.value) {
175
182
  if (this._maskFormatter) {
176
183
  try {
@@ -361,6 +368,24 @@ export class EzTextInput {
361
368
  "attribute": "mode",
362
369
  "reflect": true,
363
370
  "defaultValue": "\"regular\""
371
+ },
372
+ "slaveMode": {
373
+ "type": "boolean",
374
+ "mutable": false,
375
+ "complexType": {
376
+ "original": "boolean",
377
+ "resolved": "boolean",
378
+ "references": {}
379
+ },
380
+ "required": false,
381
+ "optional": false,
382
+ "docs": {
383
+ "tags": [],
384
+ "text": "Define se o controle de change do value ser\u00E1 controlado por um componente pai."
385
+ },
386
+ "attribute": "slave-mode",
387
+ "reflect": true,
388
+ "defaultValue": "false"
364
389
  }
365
390
  }; }
366
391
  static get events() { return [{
@@ -416,12 +441,12 @@ export class EzTextInput {
416
441
  static get elementRef() { return "_hostElement"; }
417
442
  static get watchers() { return [{
418
443
  "propName": "errorMessage",
419
- "methodName": "showError"
444
+ "methodName": "observeErrorMessage"
420
445
  }, {
421
446
  "propName": "mask",
422
- "methodName": "prepareMask"
447
+ "methodName": "observeMask"
423
448
  }, {
424
449
  "propName": "value",
425
- "methodName": "updateInputValue"
450
+ "methodName": "observeValue"
426
451
  }]; }
427
452
  }