@sankhyalabs/ezui 0.0.0-bugfix-dev-59880.5 → 0.0.0-bugfix-dev-KB-59889.0
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.
- package/README.md +1 -1
- package/dist/cjs/ez-form-view.cjs.entry.js +3 -4
- package/dist/cjs/ez-form.cjs.entry.js +26 -0
- package/dist/cjs/ez-grid.cjs.entry.js +27 -4
- package/dist/cjs/ez-number-input.cjs.entry.js +27 -26
- package/dist/cjs/ez-tabselector.cjs.entry.js +34 -29
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ez-form-view/ez-form-view.js +1 -1
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +2 -3
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +17 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +2 -3
- package/dist/collection/components/ez-grid/ez-grid.css +1 -0
- package/dist/collection/components/ez-grid/ez-grid.js +22 -0
- package/dist/collection/components/ez-number-input/ez-number-input.js +27 -31
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +34 -29
- package/dist/collection/utils/form/DataBinder.js +26 -0
- package/dist/collection/utils/form/test/DataBinder.test.js +41 -4
- package/dist/collection/utils/form/test/resources/metadataTest.js +15 -0
- package/dist/custom-elements/index.js +119 -65
- package/dist/esm/ez-form-view.entry.js +3 -4
- package/dist/esm/ez-form.entry.js +27 -1
- package/dist/esm/ez-grid.entry.js +27 -4
- package/dist/esm/ez-number-input.entry.js +27 -26
- package/dist/esm/ez-tabselector.entry.js +34 -29
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-13727aec.entry.js +1 -0
- package/dist/ezui/p-1ee2479b.entry.js +1 -0
- package/dist/ezui/p-2dcb50d4.entry.js +1 -0
- package/dist/ezui/{p-34190f80.entry.js → p-362c3c80.entry.js} +1 -1
- package/dist/ezui/p-99f46950.entry.js +1 -0
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +1 -0
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +3 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +4 -0
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +0 -2
- package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +3 -2
- package/dist/types/components.d.ts +4 -0
- package/dist/types/utils/form/DataBinder.d.ts +3 -0
- package/dist/types/utils/form/test/resources/metadataTest.d.ts +2 -0
- package/package.json +1 -1
- package/dist/ezui/p-3b9e5664.entry.js +0 -1
- package/dist/ezui/p-6ca64193.entry.js +0 -1
- package/dist/ezui/p-77362d3a.entry.js +0 -1
- package/dist/ezui/p-cc2dc4f4.entry.js +0 -1
|
@@ -153,6 +153,12 @@ export class EzGrid {
|
|
|
153
153
|
async getCustomValueFormatter(columnName) {
|
|
154
154
|
return this._customFormatters.get(columnName);
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Atribui o foco para a grade.
|
|
158
|
+
*/
|
|
159
|
+
async setFocus() {
|
|
160
|
+
this._gridController.setFocus();
|
|
161
|
+
}
|
|
156
162
|
observeConfig(config) {
|
|
157
163
|
this._gridController.setColumnsState(config === null || config === void 0 ? void 0 : config.columns);
|
|
158
164
|
}
|
|
@@ -1150,6 +1156,22 @@ export class EzGrid {
|
|
|
1150
1156
|
"text": "Retorna o formatador customizado da coluna caso exista.",
|
|
1151
1157
|
"tags": []
|
|
1152
1158
|
}
|
|
1159
|
+
},
|
|
1160
|
+
"setFocus": {
|
|
1161
|
+
"complexType": {
|
|
1162
|
+
"signature": "() => Promise<void>",
|
|
1163
|
+
"parameters": [],
|
|
1164
|
+
"references": {
|
|
1165
|
+
"Promise": {
|
|
1166
|
+
"location": "global"
|
|
1167
|
+
}
|
|
1168
|
+
},
|
|
1169
|
+
"return": "Promise<void>"
|
|
1170
|
+
},
|
|
1171
|
+
"docs": {
|
|
1172
|
+
"text": "Atribui o foco para a grade.",
|
|
1173
|
+
"tags": []
|
|
1174
|
+
}
|
|
1153
1175
|
}
|
|
1154
1176
|
};
|
|
1155
1177
|
}
|
|
@@ -6,7 +6,6 @@ export class EzNumberInput {
|
|
|
6
6
|
this._focused = false;
|
|
7
7
|
this._changePending = false;
|
|
8
8
|
this._valuePromiseCallbacks = [];
|
|
9
|
-
this._value = undefined;
|
|
10
9
|
this.label = undefined;
|
|
11
10
|
this.value = undefined;
|
|
12
11
|
this.enabled = true;
|
|
@@ -62,7 +61,24 @@ export class EzNumberInput {
|
|
|
62
61
|
}
|
|
63
62
|
observeValue(newValue, oldValue) {
|
|
64
63
|
if (this._textInput && newValue != oldValue) {
|
|
65
|
-
this.
|
|
64
|
+
const newValueValidated = this.validateValue(newValue);
|
|
65
|
+
const oldValueValidated = this.validateValue(oldValue);
|
|
66
|
+
if (newValueValidated === null) {
|
|
67
|
+
this._textInput.value = '';
|
|
68
|
+
}
|
|
69
|
+
if (newValueValidated != oldValueValidated) {
|
|
70
|
+
const textValue = this.getTextValue(newValueValidated) || '';
|
|
71
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
72
|
+
const parsedNumber = this.getParsedNumber(textValue);
|
|
73
|
+
if (parsedNumber !== undefined || !this._focused) {
|
|
74
|
+
this._textInput.value = textValue;
|
|
75
|
+
this._focused = false;
|
|
76
|
+
this.errorMessage = "";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
|
|
80
|
+
this.ezChange.emit(valueEmitted);
|
|
81
|
+
}
|
|
66
82
|
}
|
|
67
83
|
this._changePending = false;
|
|
68
84
|
}
|
|
@@ -71,31 +87,12 @@ export class EzNumberInput {
|
|
|
71
87
|
this.setInputValue();
|
|
72
88
|
}
|
|
73
89
|
}
|
|
74
|
-
handleNewValue(newValue, oldValue) {
|
|
75
|
-
const newValueValidated = this.validateValue(newValue);
|
|
76
|
-
const oldValueValidated = this.validateValue(oldValue);
|
|
77
|
-
if (newValueValidated === null) {
|
|
78
|
-
this._value = '';
|
|
79
|
-
}
|
|
80
|
-
if (newValueValidated === oldValueValidated) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const textValue = this.getTextValue(newValueValidated) || '';
|
|
84
|
-
const parsedNumber = this.getParsedNumber(textValue);
|
|
85
|
-
if ((this._value || '') !== textValue && (parsedNumber !== undefined || !this._focused)) {
|
|
86
|
-
this._value = textValue;
|
|
87
|
-
this._focused = false;
|
|
88
|
-
this.errorMessage = "";
|
|
89
|
-
}
|
|
90
|
-
const valueEmitted = newValueValidated === null ? undefined : newValueValidated;
|
|
91
|
-
this.ezChange.emit(valueEmitted);
|
|
92
|
-
}
|
|
93
90
|
validateValue(value) {
|
|
94
91
|
return isNaN(value) || value === undefined ? null : value;
|
|
95
92
|
}
|
|
96
93
|
getTextValue(value) {
|
|
97
94
|
if (value != undefined) {
|
|
98
|
-
return this.precision
|
|
95
|
+
return this.precision > 0 ? NumberUtils.format(value.toString(), Number(this.precision), Number(this.prettyPrecision)) : value.toString();
|
|
99
96
|
}
|
|
100
97
|
return undefined;
|
|
101
98
|
}
|
|
@@ -148,13 +145,17 @@ export class EzNumberInput {
|
|
|
148
145
|
this.ezStartChange.emit({ waitmessage: "", blocking: false });
|
|
149
146
|
}
|
|
150
147
|
}
|
|
151
|
-
getParsedNumber(value
|
|
148
|
+
getParsedNumber(value) {
|
|
149
|
+
var _a;
|
|
150
|
+
if (value === void 0) {
|
|
151
|
+
value = (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.value;
|
|
152
|
+
}
|
|
152
153
|
return (value === null || value === void 0 ? void 0 : value.trim()) ? NumberUtils.stringToNumber(value) : undefined;
|
|
153
154
|
}
|
|
154
155
|
setInputValue() {
|
|
155
156
|
const textValue = this.getTextValue(this.value) || '';
|
|
156
|
-
if ((this.
|
|
157
|
-
this.
|
|
157
|
+
if ((this._textInput.value || '') !== textValue) {
|
|
158
|
+
this._textInput.value = textValue;
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
componentDidLoad() {
|
|
@@ -163,7 +164,7 @@ export class EzNumberInput {
|
|
|
163
164
|
}
|
|
164
165
|
render() {
|
|
165
166
|
ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
|
|
166
|
-
return (h("ez-text-input", { class: "number__input", "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError
|
|
167
|
+
return (h("ez-text-input", { class: "number__input", "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), ref: elem => this._textInput = elem, "data-slave-mode": "true", label: this.label, onBlur: () => this.handleBlur(), onInput: () => this.handleInput(), restrict: this.precision > 0 ? "0123456789-,." : "0123456789-", enabled: this.enabled, errorMessage: this.errorMessage, mode: this.mode, canShowError: this.canShowError }));
|
|
167
168
|
}
|
|
168
169
|
static get is() { return "ez-number-input"; }
|
|
169
170
|
static get encapsulation() { return "shadow"; }
|
|
@@ -320,11 +321,6 @@ export class EzNumberInput {
|
|
|
320
321
|
}
|
|
321
322
|
};
|
|
322
323
|
}
|
|
323
|
-
static get states() {
|
|
324
|
-
return {
|
|
325
|
-
"_value": {}
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
324
|
static get events() {
|
|
329
325
|
return [{
|
|
330
326
|
"method": "ezChange",
|
|
@@ -58,9 +58,13 @@ export class EzTabselector {
|
|
|
58
58
|
this.selectedTab = undefined;
|
|
59
59
|
this.tabs = undefined;
|
|
60
60
|
}
|
|
61
|
-
observeTabs(newValue) {
|
|
61
|
+
observeTabs(newValue, oldValue) {
|
|
62
62
|
if (newValue && typeof newValue !== "string") {
|
|
63
63
|
this._processedTabs = newValue;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (newValue !== oldValue) {
|
|
67
|
+
this.processesTabs();
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
handleTabClick(tab) {
|
|
@@ -70,36 +74,37 @@ export class EzTabselector {
|
|
|
70
74
|
this.ezChange.emit(tab);
|
|
71
75
|
this.setFocusedBtn(false, tab.index);
|
|
72
76
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
|
|
77
|
+
componentWillLoad() {
|
|
78
|
+
this.processesTabs();
|
|
79
|
+
}
|
|
80
|
+
processesTabs() {
|
|
81
|
+
if (this.tabs) {
|
|
82
|
+
if (Array.isArray(this.tabs)) {
|
|
83
|
+
this._processedTabs = [...this.tabs];
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this._processedTabs = [];
|
|
87
|
+
this.tabs.split(",").forEach((label) => {
|
|
88
|
+
label = label.trim();
|
|
89
|
+
this._processedTabs.push({ label, tabKey: label, index: this._processedTabs.length });
|
|
90
|
+
this.buildElementIdTab(this._processedTabs);
|
|
91
|
+
});
|
|
87
92
|
}
|
|
88
|
-
this._hostElem.querySelectorAll("ez-tab").forEach((elem) => {
|
|
89
|
-
const tabKey = elem.getAttribute("tabKey");
|
|
90
|
-
const label = elem.getAttribute("label");
|
|
91
|
-
const leftIcon = elem.getAttribute("leftIcon");
|
|
92
|
-
const rightIcon = elem.getAttribute("rightIcon");
|
|
93
|
-
const tab = { label, tabKey, leftIcon, rightIcon, index: this._processedTabs.length };
|
|
94
|
-
const content = elem.firstChild;
|
|
95
|
-
if (content) {
|
|
96
|
-
content.setAttribute("slot", "tab" + tab.index);
|
|
97
|
-
this._hostElem.appendChild(content);
|
|
98
|
-
}
|
|
99
|
-
this._processedTabs.push(tab);
|
|
100
|
-
this.buildElementIdTab(this._processedTabs);
|
|
101
|
-
});
|
|
102
93
|
}
|
|
94
|
+
this._hostElem.querySelectorAll("ez-tab").forEach((elem) => {
|
|
95
|
+
const tabKey = elem.getAttribute("tabKey");
|
|
96
|
+
const label = elem.getAttribute("label");
|
|
97
|
+
const leftIcon = elem.getAttribute("leftIcon");
|
|
98
|
+
const rightIcon = elem.getAttribute("rightIcon");
|
|
99
|
+
const tab = { label, tabKey, leftIcon, rightIcon, index: this._processedTabs.length };
|
|
100
|
+
const content = elem.firstChild;
|
|
101
|
+
if (content) {
|
|
102
|
+
content.setAttribute("slot", "tab" + tab.index);
|
|
103
|
+
this._hostElem.appendChild(content);
|
|
104
|
+
}
|
|
105
|
+
this._processedTabs.push(tab);
|
|
106
|
+
this.buildElementIdTab(this._processedTabs);
|
|
107
|
+
});
|
|
103
108
|
}
|
|
104
109
|
componentDidRender() {
|
|
105
110
|
this.updateScroll();
|
|
@@ -35,6 +35,13 @@ export default class DataBinder {
|
|
|
35
35
|
this.applyDefaultValues();
|
|
36
36
|
this._dataUnit.subscribe(this.onDataUnitEvent);
|
|
37
37
|
this._dataUnit.addInterceptor(this);
|
|
38
|
+
this.setContextDataBinder(dataUnit);
|
|
39
|
+
}
|
|
40
|
+
setContextDataBinder(dataUnit) {
|
|
41
|
+
const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
42
|
+
const dataBinders = [...(dataBindersByDataUnit.get(dataUnit.dataUnitId) || []), this];
|
|
43
|
+
dataBindersByDataUnit.set(dataUnit.dataUnitId, dataBinders);
|
|
44
|
+
ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
|
|
38
45
|
}
|
|
39
46
|
applyDefaultValues() {
|
|
40
47
|
const recordIds = (this._dataUnit.getAddedRecords() || []).map(r => r.__record__id__);
|
|
@@ -61,9 +68,17 @@ export default class DataBinder {
|
|
|
61
68
|
getMessageForField: field => this.getErrorMessage(field)
|
|
62
69
|
}, recordsValidator);
|
|
63
70
|
}
|
|
71
|
+
disconnectDataUnit() {
|
|
72
|
+
const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
73
|
+
const dataBinders = dataBindersByDataUnit.get(this._dataUnit.dataUnitId);
|
|
74
|
+
const dataBindersFiltered = dataBinders.filter((dataBinder) => JSON.stringify(dataBinder) !== JSON.stringify(this));
|
|
75
|
+
dataBindersByDataUnit.set(this._dataUnit.dataUnitId, dataBindersFiltered);
|
|
76
|
+
ApplicationContext.setContextValue("__DATABINDER_BY_DATAUNIT__", dataBindersByDataUnit);
|
|
77
|
+
}
|
|
64
78
|
onDisconnectedCallback() {
|
|
65
79
|
this._dataUnit.unsubscribe(this.onDataUnitEvent);
|
|
66
80
|
this._dataUnit.removeInterceptor(this);
|
|
81
|
+
this.disconnectDataUnit();
|
|
67
82
|
}
|
|
68
83
|
getCurrentRecordId() {
|
|
69
84
|
const record = this._dataUnit.getSelectedRecord();
|
|
@@ -110,6 +125,17 @@ export default class DataBinder {
|
|
|
110
125
|
validate() {
|
|
111
126
|
return this._recordValidatorProcessor.validate();
|
|
112
127
|
}
|
|
128
|
+
static async validateByDataunit(dataUnit) {
|
|
129
|
+
try {
|
|
130
|
+
const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__");
|
|
131
|
+
const dataBinders = dataBindersByDataUnit.get(dataUnit.dataUnitId) || [];
|
|
132
|
+
await Promise.all(dataBinders.map((dataBinder) => dataBinder.validate()));
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
catch (_a) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
113
139
|
updateErrorMessage(fieldName, field, message) {
|
|
114
140
|
if (message == undefined) {
|
|
115
141
|
message = this._dataUnit.getInvalidMessage(this.getCurrentRecordId(), fieldName);
|
|
@@ -1,9 +1,46 @@
|
|
|
1
|
-
import { DataUnit } from "@sankhyalabs/core";
|
|
1
|
+
import { ApplicationContext, DataUnit } from "@sankhyalabs/core";
|
|
2
2
|
import DataBinder from "../DataBinder";
|
|
3
|
+
import { metadataTest } from "./resources/metadataTest";
|
|
3
4
|
describe('DataBinder', () => {
|
|
5
|
+
let dataBinder;
|
|
6
|
+
let dataUnit;
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
dataUnit = new DataUnit();
|
|
9
|
+
dataUnit.metadata = metadataTest;
|
|
10
|
+
dataUnit.addRecord();
|
|
11
|
+
dataUnit.selectFirst();
|
|
12
|
+
dataBinder = new DataBinder(dataUnit);
|
|
13
|
+
});
|
|
4
14
|
it('constructor', async () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
expect(dataBinder).toBeTruthy();
|
|
16
|
+
});
|
|
17
|
+
it('ApplicationContext should be filled', () => {
|
|
18
|
+
const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
19
|
+
expect(dataBindersByDataUnit.get(dataUnit.dataUnitId).length).toBeGreaterThan(0);
|
|
20
|
+
});
|
|
21
|
+
it('ApplicationContext should be filled with two binders', () => {
|
|
22
|
+
new DataBinder(dataUnit);
|
|
23
|
+
const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
24
|
+
expect(dataBindersByDataUnit.get(dataUnit.dataUnitId).length).toBe(2);
|
|
25
|
+
});
|
|
26
|
+
it('should be invalid for empty fields', async () => {
|
|
27
|
+
const isValid = await DataBinder.validateByDataunit(dataUnit);
|
|
28
|
+
dataBinder['_recordValidatorProcessor'] = {
|
|
29
|
+
validate: () => Promise.reject(),
|
|
30
|
+
};
|
|
31
|
+
expect(isValid).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
it('should be valid for filled fields', async () => {
|
|
34
|
+
await dataUnit.setFieldValue('NAME', 'João');
|
|
35
|
+
dataBinder['_recordValidatorProcessor'] = {
|
|
36
|
+
validate: () => Promise.resolve(),
|
|
37
|
+
};
|
|
38
|
+
const isValid = await DataBinder.validateByDataunit(dataUnit);
|
|
39
|
+
expect(isValid).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
it('should be remove dataBinder on disconnected', async () => {
|
|
42
|
+
dataBinder.onDisconnectedCallback();
|
|
43
|
+
const dataBindersByDataUnit = ApplicationContext.getContextValue("__DATABINDER_BY_DATAUNIT__") || new Map();
|
|
44
|
+
expect(dataBindersByDataUnit.get(dataUnit.dataUnitId).length).toBe(0);
|
|
8
45
|
});
|
|
9
46
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DataType, UserInterface } from "@sankhyalabs/core";
|
|
2
|
+
export const metadataTest = {
|
|
3
|
+
"name": "clients",
|
|
4
|
+
"label": "clients",
|
|
5
|
+
"fields": [
|
|
6
|
+
{
|
|
7
|
+
"name": "NAME",
|
|
8
|
+
"label": "Nome",
|
|
9
|
+
"dataType": DataType.TEXT,
|
|
10
|
+
"userInterface": UserInterface.SHORTTEXT,
|
|
11
|
+
"readOnly": false,
|
|
12
|
+
"required": true
|
|
13
|
+
},
|
|
14
|
+
]
|
|
15
|
+
};
|