@sankhyalabs/ezui 2.0.2 → 2.0.4
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/dist/cjs/ez-check.cjs.entry.js +6 -19
- package/dist/cjs/ez-combo-box.cjs.entry.js +4 -3
- package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ez-form.cjs.entry.js +26 -17
- package/dist/cjs/ez-grid.cjs.entry.js +87 -11
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/ez-check/ez-check.css +24 -8
- package/dist/collection/components/ez-check/ez-check.js +23 -20
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +4 -3
- package/dist/collection/components/ez-dialog/ez-dialog.css +2 -2
- package/dist/collection/components/ez-form/ez-form.js +1 -1
- package/dist/collection/components/ez-form/structure/FormSheetMetadata.js +25 -16
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +47 -11
- package/dist/collection/components/ez-grid/controller/ag-grid/components/selectionHeader.js +40 -0
- package/dist/custom-elements/index.js +125 -52
- package/dist/esm/ez-check.entry.js +6 -19
- package/dist/esm/ez-combo-box.entry.js +4 -3
- package/dist/esm/ez-dialog.entry.js +1 -1
- package/dist/esm/ez-form.entry.js +26 -17
- package/dist/esm/ez-grid.entry.js +87 -11
- 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-0bd0afcf.entry.js +1 -0
- package/dist/ezui/p-45d8634a.entry.js +1 -0
- package/dist/ezui/p-e0aa9cb1.entry.js +1 -0
- package/dist/ezui/{p-ae5af8f9.entry.js → p-e120b25a.entry.js} +1 -1
- package/dist/ezui/p-f6afdc4d.entry.js +1 -0
- package/dist/types/components/ez-check/ez-check.d.ts +5 -2
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +3 -0
- package/dist/types/components/ez-grid/controller/ag-grid/components/selectionHeader.d.ts +12 -0
- package/dist/types/components.d.ts +8 -0
- package/package.json +1 -1
- package/dist/ezui/p-2213da1f.entry.js +0 -1
- package/dist/ezui/p-3987f8d8.entry.js +0 -1
- package/dist/ezui/p-6608b9a5.entry.js +0 -1
- package/dist/ezui/p-9fc50d9a.entry.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Prop, h,
|
|
1
|
+
import { Component, Prop, h, Method, Event, Host } from '@stencil/core';
|
|
2
2
|
import { CheckMode } from './CheckMode';
|
|
3
3
|
export class EzCheck {
|
|
4
4
|
constructor() {
|
|
@@ -14,17 +14,6 @@ export class EzCheck {
|
|
|
14
14
|
*/
|
|
15
15
|
this.mode = CheckMode.REGULAR;
|
|
16
16
|
}
|
|
17
|
-
observeMode() {
|
|
18
|
-
var _a;
|
|
19
|
-
if (((_a = this.mode) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === CheckMode.SWITCH) {
|
|
20
|
-
this._inputElem.classList.remove("regular-mode");
|
|
21
|
-
this._inputElem.classList.add("switch-mode");
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this._inputElem.classList.remove("switch-mode");
|
|
25
|
-
this._inputElem.classList.add("regular-mode");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
17
|
//---------------------------------------------
|
|
29
18
|
// Public methods
|
|
30
19
|
//---------------------------------------------
|
|
@@ -40,9 +29,6 @@ export class EzCheck {
|
|
|
40
29
|
async setFocus() {
|
|
41
30
|
this._inputElem.focus();
|
|
42
31
|
}
|
|
43
|
-
componentDidLoad() {
|
|
44
|
-
this.observeMode();
|
|
45
|
-
}
|
|
46
32
|
changeValue() {
|
|
47
33
|
if (!this.enabled) {
|
|
48
34
|
return;
|
|
@@ -57,9 +43,13 @@ export class EzCheck {
|
|
|
57
43
|
}
|
|
58
44
|
return classes;
|
|
59
45
|
}
|
|
46
|
+
getInputClasses() {
|
|
47
|
+
var _a;
|
|
48
|
+
return ((_a = this.mode) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === CheckMode.SWITCH ? "switch-mode" : "regular-mode";
|
|
49
|
+
}
|
|
60
50
|
render() {
|
|
61
51
|
return (h(Host, null,
|
|
62
|
-
h("input", { type: "checkbox", class:
|
|
52
|
+
h("input", { type: "checkbox", ref: (el) => this._inputElem = el, class: this.getInputClasses(), checked: this.value === true, onChange: () => { this.changeValue(); }, indeterminate: this.indeterminate, disabled: !this.enabled }),
|
|
63
53
|
this.label ? h("label", { class: this.getLabelClasses(), onClick: () => { this.changeValue(); }, title: this.label }, this.label) : undefined));
|
|
64
54
|
}
|
|
65
55
|
static get is() { return "ez-check"; }
|
|
@@ -123,6 +113,23 @@ export class EzCheck {
|
|
|
123
113
|
"reflect": true,
|
|
124
114
|
"defaultValue": "true"
|
|
125
115
|
},
|
|
116
|
+
"indeterminate": {
|
|
117
|
+
"type": "boolean",
|
|
118
|
+
"mutable": false,
|
|
119
|
+
"complexType": {
|
|
120
|
+
"original": "boolean",
|
|
121
|
+
"resolved": "boolean",
|
|
122
|
+
"references": {}
|
|
123
|
+
},
|
|
124
|
+
"required": false,
|
|
125
|
+
"optional": false,
|
|
126
|
+
"docs": {
|
|
127
|
+
"tags": [],
|
|
128
|
+
"text": "Deixa o campo em um estado indeterminado, nem marcado nem desmarcado (n\u00E3o dispon\u00EDvel em modo \"switch\")."
|
|
129
|
+
},
|
|
130
|
+
"attribute": "indeterminate",
|
|
131
|
+
"reflect": false
|
|
132
|
+
},
|
|
126
133
|
"mode": {
|
|
127
134
|
"type": "string",
|
|
128
135
|
"mutable": false,
|
|
@@ -192,8 +199,4 @@ export class EzCheck {
|
|
|
192
199
|
}
|
|
193
200
|
}
|
|
194
201
|
}; }
|
|
195
|
-
static get watchers() { return [{
|
|
196
|
-
"propName": "mode",
|
|
197
|
-
"methodName": "observeMode"
|
|
198
|
-
}]; }
|
|
199
202
|
}
|
|
@@ -151,7 +151,7 @@ export class EzComboBox {
|
|
|
151
151
|
}
|
|
152
152
|
buildItem(opt, index) {
|
|
153
153
|
const widthValue = this.showOptionValue && this._maxWidthValue > 0 ? `${this._maxWidthValue}px` : '';
|
|
154
|
-
return h("li", { class: index === this._preSelection ? "item preselected" : "item", id: `item_${opt.value}`, onMouseDown: () => this.selectOption(opt), onMouseOver: () => this._preSelection =
|
|
154
|
+
return h("li", { class: index === this._preSelection ? "item preselected" : "item", id: `item_${opt.value}`, onMouseDown: () => this.selectOption(opt), onMouseOver: () => this._preSelection = index },
|
|
155
155
|
this.showOptionValue
|
|
156
156
|
? h("span", { class: "item__value", title: opt.value, style: { width: widthValue, minWidth: widthValue, maxWidth: widthValue } }, opt.value)
|
|
157
157
|
: undefined,
|
|
@@ -166,6 +166,7 @@ export class EzComboBox {
|
|
|
166
166
|
//porque não quis onerar o text input com essa funcionalidade...
|
|
167
167
|
const top = (this.errorMessage || !this.canShowError || this.mode === "slim") ? "0px" : "-19px";
|
|
168
168
|
this._floatingID = FloatingManager.float(this._listWrapper, this._listContainer, { autoClose: true, top });
|
|
169
|
+
this.setFocus();
|
|
169
170
|
window.requestAnimationFrame(() => {
|
|
170
171
|
this._listWrapper.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
171
172
|
});
|
|
@@ -199,10 +200,10 @@ export class EzComboBox {
|
|
|
199
200
|
const parentRect = parent.getBoundingClientRect();
|
|
200
201
|
const itemRect = liElem.getBoundingClientRect();
|
|
201
202
|
if (down && itemRect.bottom > parentRect.bottom) {
|
|
202
|
-
parent.scrollTop = itemRect.
|
|
203
|
+
parent.scrollTop = itemRect.height * (this._preSelection - 3);
|
|
203
204
|
}
|
|
204
205
|
else if (!down && itemRect.top < parentRect.top) {
|
|
205
|
-
parent.scrollTop =
|
|
206
|
+
parent.scrollTop = itemRect.height * this._preSelection;
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
});
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
/* Título */
|
|
16
16
|
/*@doc Define o estilo da mensagem exibida no título.*/
|
|
17
|
-
--dialog__title--font-pattern: var(--font-pattern, "
|
|
17
|
+
--dialog__title--font-pattern: var(--font-pattern, "Roboto");
|
|
18
18
|
/*@doc Define o espaçamento a esquerda do título.*/
|
|
19
19
|
--dialog__title--padding-left: var(--space--small, 6px);
|
|
20
20
|
/*@doc Define o espaçamento abaixo do container do título.*/
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
/* Corpo da Mensagem */
|
|
27
27
|
/*@doc Define o estilo do texto da mensagem.*/
|
|
28
|
-
--dialog__body--font-pattern: var(--font-pattern, "
|
|
28
|
+
--dialog__body--font-pattern: var(--font-pattern, "Roboto");
|
|
29
29
|
/*@doc Define a sombra do texto da mensagem.*/
|
|
30
30
|
--dialog__body--text-shadow: var(--text-shadow, "0 0 0 #353535, 0 0 1px transparent");
|
|
31
31
|
/*@doc Define o peso do texto da mensagem.*/
|
|
@@ -104,7 +104,7 @@ export class EzForm {
|
|
|
104
104
|
}
|
|
105
105
|
processMetadata() {
|
|
106
106
|
if (!this.isStatic() && this.dataUnit) {
|
|
107
|
-
const metadata = this.config != undefined ? buildFromConfig(this.config, this.dataUnit) : buildFromDataUnit(this.dataUnit);
|
|
107
|
+
const metadata = this.config != undefined && Object.values(this.config).length > 0 ? buildFromConfig(this.config, this.dataUnit) : buildFromDataUnit(this.dataUnit);
|
|
108
108
|
this._store.dispatch(loadMetadata(metadata));
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -28,11 +28,17 @@ export class FormMetadata {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
export const buildFromDataUnit = (dataUnit) => {
|
|
31
|
-
var _a;
|
|
31
|
+
var _a, _b;
|
|
32
32
|
const unitMD = dataUnit.metadata;
|
|
33
33
|
const metadata = new FormMetadata();
|
|
34
34
|
if (unitMD) {
|
|
35
35
|
const visibleFields = (_a = unitMD.fields) === null || _a === void 0 ? void 0 : _a.filter(descriptor => descriptor.visible !== false);
|
|
36
|
+
const items = new Map();
|
|
37
|
+
(_b = unitMD === null || unitMD === void 0 ? void 0 : unitMD.fields) === null || _b === void 0 ? void 0 : _b.forEach((descriptor) => {
|
|
38
|
+
if (descriptor.visible !== false) {
|
|
39
|
+
resolveFieldGroup(items, null, descriptor);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
let defaultValues = {};
|
|
37
43
|
visibleFields
|
|
38
44
|
.filter(descriptor => descriptor.defaultValue)
|
|
@@ -40,7 +46,7 @@ export const buildFromDataUnit = (dataUnit) => {
|
|
|
40
46
|
metadata.addSheet({
|
|
41
47
|
label: unitMD.label,
|
|
42
48
|
name: unitMD.name,
|
|
43
|
-
items:
|
|
49
|
+
items: Array.from(items.values()),
|
|
44
50
|
requiredFields: visibleFields
|
|
45
51
|
.filter(descriptor => descriptor.required)
|
|
46
52
|
.map(descriptor => descriptor.name),
|
|
@@ -59,6 +65,22 @@ function getTabConfig(tab, sheets) {
|
|
|
59
65
|
function sortTabs(a, b) {
|
|
60
66
|
return a[0].label == '__main' ? -1 : (a[0].order || 10000) - (b[0].order || 10000);
|
|
61
67
|
}
|
|
68
|
+
function resolveFieldGroup(items, field, descriptor) {
|
|
69
|
+
const fieldMD = { config: field, descriptor: descriptor };
|
|
70
|
+
let group = (field === null || field === void 0 ? void 0 : field.group) || descriptor.group;
|
|
71
|
+
if (group) {
|
|
72
|
+
const key = `group::${group}`;
|
|
73
|
+
if (!items.has(key)) {
|
|
74
|
+
items.set(key, { label: group, items: [fieldMD] });
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
items.get(key).items.push(fieldMD);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
items.set((field === null || field === void 0 ? void 0 : field.name) || descriptor.name, fieldMD);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
62
84
|
export const buildFromConfig = (config, dataUnit) => {
|
|
63
85
|
var _a, _b;
|
|
64
86
|
const sheets = new Map();
|
|
@@ -96,20 +118,7 @@ export const buildFromConfig = (config, dataUnit) => {
|
|
|
96
118
|
if (defaultValue) {
|
|
97
119
|
defaultValues[field.name] = field.defaultValue;
|
|
98
120
|
}
|
|
99
|
-
|
|
100
|
-
const group = field.group;
|
|
101
|
-
if (group) {
|
|
102
|
-
const key = `group::${group}`;
|
|
103
|
-
if (!tabItens.has(key)) {
|
|
104
|
-
tabItens.set(key, { label: group, items: [fieldMD] });
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
tabItens.get(key).items.push(fieldMD);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
tabItens.set(field.name, fieldMD);
|
|
112
|
-
}
|
|
121
|
+
resolveFieldGroup(tabItens, field, descriptor);
|
|
113
122
|
}
|
|
114
123
|
}
|
|
115
124
|
});
|
|
@@ -5,6 +5,7 @@ import gridTerms from "./i18n/pt-BR.js";
|
|
|
5
5
|
import getHeaderColumnTemplate from "./template/HeaderColumnTemplate.js";
|
|
6
6
|
import DataSource from "./DataSource";
|
|
7
7
|
import { CellRenderer } from "./components/cellRenderer";
|
|
8
|
+
import SelectionHeader from "./components/selectionHeader";
|
|
8
9
|
export default class AgGridController {
|
|
9
10
|
constructor(enterprise) {
|
|
10
11
|
this.DEFAULT_ROW_HEIGHT = 30;
|
|
@@ -67,6 +68,13 @@ export default class AgGridController {
|
|
|
67
68
|
defaultColDef: {
|
|
68
69
|
headerClass: "ez-grid__cell-header",
|
|
69
70
|
cellClass: "ez-grid__cell-body"
|
|
71
|
+
},
|
|
72
|
+
components: {
|
|
73
|
+
'ezGridHeaderComponent': SelectionHeader
|
|
74
|
+
},
|
|
75
|
+
context: {
|
|
76
|
+
headerCheckStatusGetter: () => this.getSelectionHeaderStatus(),
|
|
77
|
+
headerCheckStatusSetter: (selectAll) => this.updateSelectionForAll(selectAll)
|
|
70
78
|
}
|
|
71
79
|
};
|
|
72
80
|
this.setOptionsEvents(this._gridOptions);
|
|
@@ -99,6 +107,31 @@ export default class AgGridController {
|
|
|
99
107
|
opt.suppressDragLeaveHidesColumns = true;
|
|
100
108
|
opt.suppressMenuHide = true;
|
|
101
109
|
}
|
|
110
|
+
getSelectionHeaderStatus() {
|
|
111
|
+
const records = this._dataUnit.records;
|
|
112
|
+
if (records && records.length === 0) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
const selection = this._dataUnit.getSelection();
|
|
116
|
+
if (selection == undefined || selection.length === 0) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
if (selection.length != records.length) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
let status = undefined;
|
|
123
|
+
for (let i = 0; i < records.length; i++) {
|
|
124
|
+
const current = selection.includes(records[i].__record__id__);
|
|
125
|
+
if (status != undefined && current !== status) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
status = current;
|
|
129
|
+
}
|
|
130
|
+
return status;
|
|
131
|
+
}
|
|
132
|
+
updateSelectionForAll(selectAll) {
|
|
133
|
+
this._dataUnit.setSelection(selectAll ? this._dataUnit.records.map(r => r.__record__id__) : []);
|
|
134
|
+
}
|
|
102
135
|
setData(data) {
|
|
103
136
|
if (this._grid === undefined) {
|
|
104
137
|
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
@@ -119,13 +152,12 @@ export default class AgGridController {
|
|
|
119
152
|
if (this._grid === undefined) {
|
|
120
153
|
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
121
154
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
});
|
|
155
|
+
this._gridOptions.api.forEachNode(node => {
|
|
156
|
+
node.setSelected(rowIds && rowIds.includes(node.id));
|
|
157
|
+
});
|
|
158
|
+
const selectionHeader = this._gridOptions.context.selectionHeader;
|
|
159
|
+
if (selectionHeader) {
|
|
160
|
+
selectionHeader.updateCheckbox();
|
|
129
161
|
}
|
|
130
162
|
}
|
|
131
163
|
removeRows() {
|
|
@@ -174,7 +206,8 @@ export default class AgGridController {
|
|
|
174
206
|
colId: this.CHECK_BOX_COL_ID,
|
|
175
207
|
headerName: "",
|
|
176
208
|
checkboxSelection: true,
|
|
177
|
-
|
|
209
|
+
headerComponent: "ezGridHeaderComponent",
|
|
210
|
+
headerClass: "ag-column-select-header",
|
|
178
211
|
width: 28,
|
|
179
212
|
suppressMovable: true,
|
|
180
213
|
suppressAutoSize: true,
|
|
@@ -415,9 +448,12 @@ export default class AgGridController {
|
|
|
415
448
|
}
|
|
416
449
|
onSelectionChange() {
|
|
417
450
|
if (this._selectionChangeCallback) {
|
|
418
|
-
this.
|
|
419
|
-
|
|
420
|
-
|
|
451
|
+
clearTimeout(this._selectionChangeDeboucing);
|
|
452
|
+
this._selectionChangeDeboucing = window.setTimeout(() => {
|
|
453
|
+
this._selectionChangeCallback({
|
|
454
|
+
selection: this._gridOptions.api.getSelectedRows()
|
|
455
|
+
});
|
|
456
|
+
}, 0);
|
|
421
457
|
}
|
|
422
458
|
}
|
|
423
459
|
onRowDoubleClick(evt) {
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default class SelectionHeader {
|
|
2
|
+
updateCheckbox() {
|
|
3
|
+
this.updatingValue = true;
|
|
4
|
+
try {
|
|
5
|
+
const value = this.headerCheckStatusGetter();
|
|
6
|
+
this.checkBox.indeterminate = value == undefined;
|
|
7
|
+
this.checkBox.value = value;
|
|
8
|
+
}
|
|
9
|
+
finally {
|
|
10
|
+
this.updatingValue = false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
init(params) {
|
|
14
|
+
params.context.selectionHeader = this;
|
|
15
|
+
const valueSetter = params.context.headerCheckStatusSetter;
|
|
16
|
+
this.headerCheckStatusGetter = params.context.headerCheckStatusGetter;
|
|
17
|
+
this.element = document.createElement('div');
|
|
18
|
+
this.element.classList.add("ag-header__selection-checkbox");
|
|
19
|
+
this.checkBox = document.createElement('ez-check');
|
|
20
|
+
this.checkBox.style.setProperty("--ez-check--focus--background-color", "transparent");
|
|
21
|
+
this.checkBox.style.setProperty("--ez-check--hover--background-color", "transparent");
|
|
22
|
+
this.element.append(this.checkBox);
|
|
23
|
+
this.updateCheckbox();
|
|
24
|
+
this.element.addEventListener('ezChange', (evt) => {
|
|
25
|
+
if (!this.updatingValue) {
|
|
26
|
+
valueSetter(evt.detail);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getGui() {
|
|
31
|
+
return this.element;
|
|
32
|
+
}
|
|
33
|
+
destroy() {
|
|
34
|
+
this.element.remove();
|
|
35
|
+
this.element = null;
|
|
36
|
+
}
|
|
37
|
+
refresh(_params) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|