@sankhyalabs/sankhyablocks 4.4.0 → 4.5.1
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/{constants-3d09ebea.js → constants-73803daf.js} +5 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-config-options.cjs.entry.js +1 -1
- package/dist/cjs/snk-configurator.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
- package/dist/cjs/snk-field-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-grid-config.cjs.entry.js +1 -1
- package/dist/cjs/{snk-guides-viewer-7c3686e5.js → snk-guides-viewer-5d3dca5d.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-select-box.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +259 -0
- package/dist/cjs/snk-tab-config.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +27 -0
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +391 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +112 -0
- package/dist/collection/lib/utils/constants.js +5 -0
- package/dist/components/constants.js +6 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/snk-detail-view2.js +2 -1
- package/dist/components/snk-grid2.js +2 -47
- package/dist/components/snk-simple-crud.d.ts +11 -0
- package/dist/components/snk-simple-crud.js +304 -0
- package/dist/components/taskbar-processor.js +47 -0
- package/dist/esm/{constants-fb9721cc.js → constants-9560e54f.js} +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-config-options.entry.js +1 -1
- package/dist/esm/snk-configurator.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +1 -1
- package/dist/esm/snk-data-unit.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +2 -2
- package/dist/esm/snk-field-config.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +1 -1
- package/dist/esm/snk-grid-config.entry.js +1 -1
- package/dist/esm/{snk-guides-viewer-3b3330a2.js → snk-guides-viewer-6bb54367.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-select-box.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +255 -0
- package/dist/esm/snk-tab-config.entry.js +1 -1
- package/dist/sankhyablocks/{p-d9444ca6.entry.js → p-2a3996b0.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8f41b2e1.entry.js → p-4bd183ba.entry.js} +1 -1
- package/dist/sankhyablocks/{p-25d181e7.entry.js → p-7889d481.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fc86a31e.entry.js → p-869d6616.entry.js} +1 -1
- package/dist/sankhyablocks/{p-99742169.entry.js → p-86efa17d.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c049c7b7.entry.js → p-8b0e8deb.entry.js} +1 -1
- package/dist/sankhyablocks/{p-dafbb972.js → p-9bf0319f.js} +1 -1
- package/dist/sankhyablocks/{p-43d8d388.entry.js → p-9f2306ba.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c1814395.entry.js → p-b318cec6.entry.js} +1 -1
- package/dist/sankhyablocks/p-b5ba7ee0.entry.js +1 -0
- package/dist/sankhyablocks/{p-f5bf4d8a.entry.js → p-c0bfafcb.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9036d360.entry.js → p-cf9d1b55.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9d62bbca.entry.js → p-dbeac5db.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f5d3ecb3.js → p-ecbfbb4a.js} +1 -1
- package/dist/sankhyablocks/{p-6e6ef989.entry.js → p-f83e3219.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +51 -0
- package/dist/types/components.d.ts +48 -2
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +21 -0
- package/dist/types/lib/utils/constants.d.ts +4 -0
- package/package.json +1 -1
- package/react/components.d.ts +1 -0
- package/react/components.js +1 -0
- package/react/components.js.map +1 -1
@@ -0,0 +1,391 @@
|
|
1
|
+
import { DataType, UserInterface } from '@sankhyalabs/core';
|
2
|
+
import { h } from '@stencil/core';
|
3
|
+
import { VIEW_MODE, SIMPLE_CRUD_MODE } from '../../lib/utils/constants';
|
4
|
+
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
5
|
+
import { PresentationMode } from '../../lib';
|
6
|
+
import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
|
7
|
+
import InMemoryLoader from '../../lib/dataUnit/InMemoryLoader';
|
8
|
+
export class SnkSimpleCrud {
|
9
|
+
constructor() {
|
10
|
+
this.REGULAR_DEFAULT_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER"];
|
11
|
+
this.REGULAR_SELECTED_BTNS = ["INSERT", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER"];
|
12
|
+
this._taskbarProcessor = new TaskbarProcessor({
|
13
|
+
"snkSimpleCrudTaskbar.form_regular": this.REGULAR_DEFAULT_BTNS.concat(TaskbarElement.GRID_MODE),
|
14
|
+
"snkSimpleCrudTaskbar.grid_regular": this.REGULAR_DEFAULT_BTNS.concat(TaskbarElement.FORM_MODE),
|
15
|
+
"snkSimpleCrudTaskbar.form_selected": this.REGULAR_SELECTED_BTNS.concat(TaskbarElement.GRID_MODE),
|
16
|
+
"snkSimpleCrudTaskbar.grid_selected": this.REGULAR_SELECTED_BTNS.concat(TaskbarElement.FORM_MODE),
|
17
|
+
"snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
|
18
|
+
});
|
19
|
+
this._currentViewMode = VIEW_MODE.GRID;
|
20
|
+
this._config = undefined;
|
21
|
+
this.dataState = undefined;
|
22
|
+
this.dataUnit = undefined;
|
23
|
+
this.mode = SIMPLE_CRUD_MODE.SERVER;
|
24
|
+
this.taskbarManager = undefined;
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* Usado para alternar a visão entre GRID e FORM externamente.
|
28
|
+
*/
|
29
|
+
async goToView(view) {
|
30
|
+
this._currentViewMode = view;
|
31
|
+
if (this._viewStack) {
|
32
|
+
this._viewStack.show(view);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
actionClickListener(evt) {
|
36
|
+
const act = evt.detail;
|
37
|
+
if (act === TaskbarElement.GRID_MODE) {
|
38
|
+
this.goToView(VIEW_MODE.GRID);
|
39
|
+
}
|
40
|
+
else if (act === TaskbarElement.FORM_MODE) {
|
41
|
+
this.goToView(VIEW_MODE.FORM);
|
42
|
+
}
|
43
|
+
evt.stopPropagation();
|
44
|
+
}
|
45
|
+
onModeChange() {
|
46
|
+
if (this.mode == SIMPLE_CRUD_MODE.IN_MEMORY) {
|
47
|
+
this.initInMemoryDataUnit();
|
48
|
+
}
|
49
|
+
}
|
50
|
+
componentWillRender() {
|
51
|
+
this._taskbarProcessor.process(this.getTaskBarId(), this.taskbarManager, this.dataState, undefined);
|
52
|
+
}
|
53
|
+
componentWillLoad() {
|
54
|
+
this.processMetadata();
|
55
|
+
this.onModeChange();
|
56
|
+
}
|
57
|
+
getTaskBarId() {
|
58
|
+
var _a, _b;
|
59
|
+
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
60
|
+
return "snkSimpleCrudTaskbar.finish_edition";
|
61
|
+
}
|
62
|
+
if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords.length) > 0) {
|
63
|
+
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
|
64
|
+
}
|
65
|
+
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
66
|
+
}
|
67
|
+
initInMemoryDataUnit() {
|
68
|
+
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
69
|
+
this.dataUnit = this._inMemoryLoader.dataUnit;
|
70
|
+
this.dataUnitReady.emit(this.dataUnit);
|
71
|
+
}
|
72
|
+
setMetadata(metadata) {
|
73
|
+
if (this._inMemoryLoader) {
|
74
|
+
this._inMemoryLoader.metadata = metadata;
|
75
|
+
}
|
76
|
+
else if (this.dataUnit) {
|
77
|
+
this.dataUnit.metadata = metadata;
|
78
|
+
}
|
79
|
+
return Promise.resolve();
|
80
|
+
}
|
81
|
+
setRecords(records) {
|
82
|
+
if (this._inMemoryLoader) {
|
83
|
+
this._inMemoryLoader.records = records;
|
84
|
+
}
|
85
|
+
else if (this.dataUnit) {
|
86
|
+
this.dataUnit.records = records;
|
87
|
+
}
|
88
|
+
return Promise.resolve();
|
89
|
+
}
|
90
|
+
getRecords() {
|
91
|
+
return Promise.resolve(this.dataUnit.records);
|
92
|
+
}
|
93
|
+
processMetadata() {
|
94
|
+
const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
|
95
|
+
const fieldMetadata = [];
|
96
|
+
const formConfig = { fields: [], emptyConfig: false };
|
97
|
+
fieldsMetadataElem.forEach(fieldElem => {
|
98
|
+
const field = {
|
99
|
+
name: fieldElem.getAttribute("name") || fieldElem.getAttribute("label"),
|
100
|
+
label: fieldElem.getAttribute("label"),
|
101
|
+
dataType: DataType[fieldElem.getAttribute("dataType")] || DataType.TEXT,
|
102
|
+
userInterface: UserInterface[fieldElem.getAttribute("userInterface")] || UserInterface.SHORTTEXT,
|
103
|
+
readOnly: fieldElem.getAttribute("readOnly") == "true",
|
104
|
+
required: fieldElem.getAttribute("required") == "true",
|
105
|
+
tab: fieldElem.getAttribute("tab") || undefined
|
106
|
+
};
|
107
|
+
const fieldConfig = { name: field.name, tab: field.tab };
|
108
|
+
formConfig.fields.push(fieldConfig);
|
109
|
+
fieldMetadata.push(field);
|
110
|
+
});
|
111
|
+
if (fieldMetadata.length > 0) {
|
112
|
+
this._config = formConfig;
|
113
|
+
this._metadata = {
|
114
|
+
name: "SimpleCrud",
|
115
|
+
label: "SimpleCrud",
|
116
|
+
fields: fieldMetadata
|
117
|
+
};
|
118
|
+
}
|
119
|
+
}
|
120
|
+
onDataStateChange(evt) {
|
121
|
+
this.dataStateChange.emit(evt.detail);
|
122
|
+
this.dataState = evt.detail;
|
123
|
+
}
|
124
|
+
render() {
|
125
|
+
var _a;
|
126
|
+
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, onDataStateChange: evt => this.onDataStateChange(evt), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail) }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-flex ez-box ez-box--shadow" }, h("snk-taskbar", { class: "simple-crud__taskbar ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", buttons: this._taskbarProcessor.buttons, disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }), h("ez-view-stack", { class: "ez-flex ez-flex--column", ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { dataUnit: this.dataUnit, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), "no-header": true }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { dataUnit: this.dataUnit, config: this._config }))))));
|
127
|
+
}
|
128
|
+
static get is() { return "snk-simple-crud"; }
|
129
|
+
static get encapsulation() { return "scoped"; }
|
130
|
+
static get originalStyleUrls() {
|
131
|
+
return {
|
132
|
+
"$": ["snk-simple-crud.css"]
|
133
|
+
};
|
134
|
+
}
|
135
|
+
static get styleUrls() {
|
136
|
+
return {
|
137
|
+
"$": ["snk-simple-crud.css"]
|
138
|
+
};
|
139
|
+
}
|
140
|
+
static get properties() {
|
141
|
+
return {
|
142
|
+
"dataState": {
|
143
|
+
"type": "unknown",
|
144
|
+
"mutable": false,
|
145
|
+
"complexType": {
|
146
|
+
"original": "DataState",
|
147
|
+
"resolved": "DataState",
|
148
|
+
"references": {
|
149
|
+
"DataState": {
|
150
|
+
"location": "import",
|
151
|
+
"path": "../snk-data-unit/snk-data-unit"
|
152
|
+
}
|
153
|
+
}
|
154
|
+
},
|
155
|
+
"required": false,
|
156
|
+
"optional": false,
|
157
|
+
"docs": {
|
158
|
+
"tags": [],
|
159
|
+
"text": ""
|
160
|
+
}
|
161
|
+
},
|
162
|
+
"dataUnit": {
|
163
|
+
"type": "unknown",
|
164
|
+
"mutable": false,
|
165
|
+
"complexType": {
|
166
|
+
"original": "DataUnit",
|
167
|
+
"resolved": "DataUnit",
|
168
|
+
"references": {
|
169
|
+
"DataUnit": {
|
170
|
+
"location": "import",
|
171
|
+
"path": "@sankhyalabs/core"
|
172
|
+
}
|
173
|
+
}
|
174
|
+
},
|
175
|
+
"required": false,
|
176
|
+
"optional": false,
|
177
|
+
"docs": {
|
178
|
+
"tags": [],
|
179
|
+
"text": ""
|
180
|
+
}
|
181
|
+
},
|
182
|
+
"mode": {
|
183
|
+
"type": "number",
|
184
|
+
"mutable": false,
|
185
|
+
"complexType": {
|
186
|
+
"original": "SIMPLE_CRUD_MODE",
|
187
|
+
"resolved": "SIMPLE_CRUD_MODE.IN_MEMORY | SIMPLE_CRUD_MODE.SERVER",
|
188
|
+
"references": {
|
189
|
+
"SIMPLE_CRUD_MODE": {
|
190
|
+
"location": "import",
|
191
|
+
"path": "../../lib/utils/constants"
|
192
|
+
}
|
193
|
+
}
|
194
|
+
},
|
195
|
+
"required": false,
|
196
|
+
"optional": false,
|
197
|
+
"docs": {
|
198
|
+
"tags": [],
|
199
|
+
"text": ""
|
200
|
+
},
|
201
|
+
"attribute": "mode",
|
202
|
+
"reflect": false,
|
203
|
+
"defaultValue": "SIMPLE_CRUD_MODE.SERVER"
|
204
|
+
},
|
205
|
+
"taskbarManager": {
|
206
|
+
"type": "unknown",
|
207
|
+
"mutable": false,
|
208
|
+
"complexType": {
|
209
|
+
"original": "TaskbarManager",
|
210
|
+
"resolved": "TaskbarManager",
|
211
|
+
"references": {
|
212
|
+
"TaskbarManager": {
|
213
|
+
"location": "import",
|
214
|
+
"path": "../snk-taskbar/snk-taskbar"
|
215
|
+
}
|
216
|
+
}
|
217
|
+
},
|
218
|
+
"required": false,
|
219
|
+
"optional": false,
|
220
|
+
"docs": {
|
221
|
+
"tags": [],
|
222
|
+
"text": "Gerenciador das barras de tarefas. \u00C9 poss\u00EDvel determinar bot\u00F5es espec\u00EDficos\nou mesmo gerenciar o estado dos bot\u00F5es."
|
223
|
+
}
|
224
|
+
}
|
225
|
+
};
|
226
|
+
}
|
227
|
+
static get states() {
|
228
|
+
return {
|
229
|
+
"_currentViewMode": {},
|
230
|
+
"_config": {}
|
231
|
+
};
|
232
|
+
}
|
233
|
+
static get events() {
|
234
|
+
return [{
|
235
|
+
"method": "dataStateChange",
|
236
|
+
"name": "dataStateChange",
|
237
|
+
"bubbles": false,
|
238
|
+
"cancelable": true,
|
239
|
+
"composed": true,
|
240
|
+
"docs": {
|
241
|
+
"tags": [],
|
242
|
+
"text": "Emitido quando h\u00E1 qualquer mudan\u00E7a de estado no DataUnit."
|
243
|
+
},
|
244
|
+
"complexType": {
|
245
|
+
"original": "DataState",
|
246
|
+
"resolved": "DataState",
|
247
|
+
"references": {
|
248
|
+
"DataState": {
|
249
|
+
"location": "import",
|
250
|
+
"path": "../snk-data-unit/snk-data-unit"
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}, {
|
255
|
+
"method": "dataUnitReady",
|
256
|
+
"name": "dataUnitReady",
|
257
|
+
"bubbles": false,
|
258
|
+
"cancelable": true,
|
259
|
+
"composed": true,
|
260
|
+
"docs": {
|
261
|
+
"tags": [],
|
262
|
+
"text": "Emitido quando o DataUnit est\u00E1 pronto."
|
263
|
+
},
|
264
|
+
"complexType": {
|
265
|
+
"original": "DataUnit",
|
266
|
+
"resolved": "DataUnit",
|
267
|
+
"references": {
|
268
|
+
"DataUnit": {
|
269
|
+
"location": "import",
|
270
|
+
"path": "@sankhyalabs/core"
|
271
|
+
}
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}];
|
275
|
+
}
|
276
|
+
static get methods() {
|
277
|
+
return {
|
278
|
+
"goToView": {
|
279
|
+
"complexType": {
|
280
|
+
"signature": "(view: VIEW_MODE) => Promise<void>",
|
281
|
+
"parameters": [{
|
282
|
+
"tags": [],
|
283
|
+
"text": ""
|
284
|
+
}],
|
285
|
+
"references": {
|
286
|
+
"Promise": {
|
287
|
+
"location": "global"
|
288
|
+
},
|
289
|
+
"VIEW_MODE": {
|
290
|
+
"location": "import",
|
291
|
+
"path": "../../lib/utils/constants"
|
292
|
+
}
|
293
|
+
},
|
294
|
+
"return": "Promise<void>"
|
295
|
+
},
|
296
|
+
"docs": {
|
297
|
+
"text": "Usado para alternar a vis\u00E3o entre GRID e FORM externamente.",
|
298
|
+
"tags": []
|
299
|
+
}
|
300
|
+
},
|
301
|
+
"setMetadata": {
|
302
|
+
"complexType": {
|
303
|
+
"signature": "(metadata: UnitMetadata) => Promise<void>",
|
304
|
+
"parameters": [{
|
305
|
+
"tags": [],
|
306
|
+
"text": ""
|
307
|
+
}],
|
308
|
+
"references": {
|
309
|
+
"Promise": {
|
310
|
+
"location": "global"
|
311
|
+
},
|
312
|
+
"UnitMetadata": {
|
313
|
+
"location": "import",
|
314
|
+
"path": "@sankhyalabs/core"
|
315
|
+
}
|
316
|
+
},
|
317
|
+
"return": "Promise<void>"
|
318
|
+
},
|
319
|
+
"docs": {
|
320
|
+
"text": "",
|
321
|
+
"tags": []
|
322
|
+
}
|
323
|
+
},
|
324
|
+
"setRecords": {
|
325
|
+
"complexType": {
|
326
|
+
"signature": "(records: Array<Record>) => Promise<void>",
|
327
|
+
"parameters": [{
|
328
|
+
"tags": [],
|
329
|
+
"text": ""
|
330
|
+
}],
|
331
|
+
"references": {
|
332
|
+
"Promise": {
|
333
|
+
"location": "global"
|
334
|
+
},
|
335
|
+
"Array": {
|
336
|
+
"location": "global"
|
337
|
+
},
|
338
|
+
"Record": {
|
339
|
+
"location": "import",
|
340
|
+
"path": "@sankhyalabs/core"
|
341
|
+
}
|
342
|
+
},
|
343
|
+
"return": "Promise<void>"
|
344
|
+
},
|
345
|
+
"docs": {
|
346
|
+
"text": "",
|
347
|
+
"tags": []
|
348
|
+
}
|
349
|
+
},
|
350
|
+
"getRecords": {
|
351
|
+
"complexType": {
|
352
|
+
"signature": "() => Promise<Array<Record>>",
|
353
|
+
"parameters": [],
|
354
|
+
"references": {
|
355
|
+
"Promise": {
|
356
|
+
"location": "global"
|
357
|
+
},
|
358
|
+
"Record": {
|
359
|
+
"location": "import",
|
360
|
+
"path": "@sankhyalabs/core"
|
361
|
+
},
|
362
|
+
"Array": {
|
363
|
+
"location": "global"
|
364
|
+
}
|
365
|
+
},
|
366
|
+
"return": "Promise<Record[]>"
|
367
|
+
},
|
368
|
+
"docs": {
|
369
|
+
"text": "",
|
370
|
+
"tags": []
|
371
|
+
}
|
372
|
+
}
|
373
|
+
};
|
374
|
+
}
|
375
|
+
static get elementRef() { return "_element"; }
|
376
|
+
static get watchers() {
|
377
|
+
return [{
|
378
|
+
"propName": "mode",
|
379
|
+
"methodName": "onModeChange"
|
380
|
+
}];
|
381
|
+
}
|
382
|
+
static get listeners() {
|
383
|
+
return [{
|
384
|
+
"name": "actionClick",
|
385
|
+
"method": "actionClickListener",
|
386
|
+
"target": undefined,
|
387
|
+
"capture": false,
|
388
|
+
"passive": false
|
389
|
+
}];
|
390
|
+
}
|
391
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
import { ChangeOperation, DataType, DataUnit, SortMode, StringUtils } from "@sankhyalabs/core";
|
2
|
+
export default class InMemoryLoader {
|
3
|
+
constructor(metadata, records) {
|
4
|
+
this.records = records || [];
|
5
|
+
this.metadata = metadata;
|
6
|
+
this._dataUnit = new DataUnit("InMemoryDataUnit");
|
7
|
+
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
8
|
+
this._dataUnit.dataLoader = (_dataUnit, request) => this.dataLoader(_dataUnit, request);
|
9
|
+
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
10
|
+
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
11
|
+
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
12
|
+
}
|
13
|
+
get dataUnit() {
|
14
|
+
return this._dataUnit;
|
15
|
+
}
|
16
|
+
get records() {
|
17
|
+
return this._records;
|
18
|
+
}
|
19
|
+
set records(records) {
|
20
|
+
this._records = records === null || records === void 0 ? void 0 : records.map(record => {
|
21
|
+
if (!record["__record__id__"]) {
|
22
|
+
record["__record__id__"] = this.generateUniqueId();
|
23
|
+
}
|
24
|
+
return record;
|
25
|
+
});
|
26
|
+
if (this._dataUnit) {
|
27
|
+
this._dataUnit.records = [...this._records];
|
28
|
+
}
|
29
|
+
}
|
30
|
+
get metadata() {
|
31
|
+
return this._metadata;
|
32
|
+
}
|
33
|
+
set metadata(metadata) {
|
34
|
+
this._metadata = metadata;
|
35
|
+
if (this._dataUnit) {
|
36
|
+
this._dataUnit.metadata = this._metadata;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
generateUniqueId() {
|
40
|
+
return StringUtils.generateUUID();
|
41
|
+
}
|
42
|
+
metadaLoader() {
|
43
|
+
return Promise.resolve(this._metadata);
|
44
|
+
}
|
45
|
+
dataLoader(_dataUnit, request) {
|
46
|
+
let records = [...this._records];
|
47
|
+
if (request.sort) {
|
48
|
+
request.sort.forEach(sort => {
|
49
|
+
records = records.sort((recordA, recordB) => {
|
50
|
+
const fieldA = recordA[sort.field];
|
51
|
+
const fieldB = recordB[sort.field];
|
52
|
+
const sortFn = this.getSortFn(sort.dataType);
|
53
|
+
return sortFn(fieldA, fieldB) * (sort.mode == SortMode.ASC ? 1 : -1);
|
54
|
+
});
|
55
|
+
});
|
56
|
+
}
|
57
|
+
return Promise.resolve({ records: records });
|
58
|
+
}
|
59
|
+
getSortFn(type) {
|
60
|
+
switch (type) {
|
61
|
+
case DataType.NUMBER:
|
62
|
+
return this.sortNumber;
|
63
|
+
case DataType.DATE:
|
64
|
+
return this.sortDate;
|
65
|
+
case DataType.OBJECT:
|
66
|
+
return this.sortObject;
|
67
|
+
default:
|
68
|
+
return StringUtils.compare;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
sortObject(a, b) {
|
72
|
+
return StringUtils.compare(a["label"], b["label"]);
|
73
|
+
}
|
74
|
+
sortNumber(a, b) {
|
75
|
+
return a - b;
|
76
|
+
}
|
77
|
+
sortDate(a, b) {
|
78
|
+
let timeA = a.getTime(), timeB = b.getTime();
|
79
|
+
return timeA === timeB ? 0 : (timeA < timeB ? -1 : 1);
|
80
|
+
}
|
81
|
+
saveLoader(_dataUnit, changes) {
|
82
|
+
return new Promise((resolve) => {
|
83
|
+
let dataUnitRecords = [];
|
84
|
+
changes.forEach(change => {
|
85
|
+
let { record, updatingFields, operation } = change;
|
86
|
+
let isAdd = false;
|
87
|
+
if (operation === ChangeOperation.INSERT ||
|
88
|
+
operation === ChangeOperation.COPY) {
|
89
|
+
record["__old__id__"] = record["__record__id__"];
|
90
|
+
record["__record__id__"] = this.generateUniqueId();
|
91
|
+
isAdd = true;
|
92
|
+
}
|
93
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
94
|
+
if (isAdd) {
|
95
|
+
this.records.push(changedRecord);
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
const recordIndex = this.records.findIndex(r => r["__record__id__"] == changedRecord["__record__id__"]);
|
99
|
+
this.records[recordIndex] = changedRecord;
|
100
|
+
}
|
101
|
+
dataUnitRecords.push(changedRecord);
|
102
|
+
});
|
103
|
+
resolve(dataUnitRecords);
|
104
|
+
});
|
105
|
+
}
|
106
|
+
removeLoader(_dataUnit, recordIds) {
|
107
|
+
return new Promise((resolve) => {
|
108
|
+
this._records = this._records.filter(record => !recordIds.includes(record["__record__id__"]));
|
109
|
+
resolve(recordIds);
|
110
|
+
});
|
111
|
+
}
|
112
|
+
}
|
@@ -94,3 +94,8 @@ export const WEB_CONNECTION = {
|
|
94
94
|
IMPORT_IMAGE: "importImage"
|
95
95
|
}
|
96
96
|
};
|
97
|
+
export var SIMPLE_CRUD_MODE;
|
98
|
+
(function (SIMPLE_CRUD_MODE) {
|
99
|
+
SIMPLE_CRUD_MODE[SIMPLE_CRUD_MODE["SERVER"] = 0] = "SERVER";
|
100
|
+
SIMPLE_CRUD_MODE[SIMPLE_CRUD_MODE["IN_MEMORY"] = 1] = "IN_MEMORY";
|
101
|
+
})(SIMPLE_CRUD_MODE || (SIMPLE_CRUD_MODE = {}));
|
@@ -93,5 +93,10 @@ const WEB_CONNECTION = {
|
|
93
93
|
IMPORT_IMAGE: "importImage"
|
94
94
|
}
|
95
95
|
};
|
96
|
+
var SIMPLE_CRUD_MODE;
|
97
|
+
(function (SIMPLE_CRUD_MODE) {
|
98
|
+
SIMPLE_CRUD_MODE[SIMPLE_CRUD_MODE["SERVER"] = 0] = "SERVER";
|
99
|
+
SIMPLE_CRUD_MODE[SIMPLE_CRUD_MODE["IN_MEMORY"] = 1] = "IN_MEMORY";
|
100
|
+
})(SIMPLE_CRUD_MODE || (SIMPLE_CRUD_MODE = {}));
|
96
101
|
|
97
|
-
export { ALL_RECORD as A, CONFIG_EVENTS as C, DEFAULT_TYPE as D, KEY_PORT_EXPORT as K, ORDER_VALUES as O, REPORT_LAUNCHER_RESOURCE_ID as R, TAGS_BY_TYPE as T, VIEW_MODE as V, WEB_CONNECTION as W, VARS_BY_TYPE as a, ACTION_CONFIG as b, TAB_NAMES as c, KEY_EVENTS as d, TYPE_ACTIONS as e };
|
102
|
+
export { ALL_RECORD as A, CONFIG_EVENTS as C, DEFAULT_TYPE as D, KEY_PORT_EXPORT as K, ORDER_VALUES as O, REPORT_LAUNCHER_RESOURCE_ID as R, SIMPLE_CRUD_MODE as S, TAGS_BY_TYPE as T, VIEW_MODE as V, WEB_CONNECTION as W, VARS_BY_TYPE as a, ACTION_CONFIG as b, TAB_NAMES as c, KEY_EVENTS as d, TYPE_ACTIONS as e };
|
@@ -31,6 +31,7 @@ export { SnkGridConfig as SnkGridConfig } from '../types/components/snk-grid/sub
|
|
31
31
|
export { SnkGuidesViewer as SnkGuidesViewer } from '../types/components/snk-crud/subcomponents/snk-guides-viewer';
|
32
32
|
export { SnkPesquisa as SnkPesquisa } from '../types/components/snk-pesquisa/snk-pesquisa';
|
33
33
|
export { SelectBox as SnkSelectBox } from '../types/components/snk-grid/subcomponents/snk-select-box/snk-select-box';
|
34
|
+
export { SnkSimpleCrud as SnkSimpleCrud } from '../types/components/snk-simple-crud/snk-simple-crud';
|
34
35
|
export { SnkTabConfig as SnkTabConfig } from '../types/components/snk-form/subcomponents/snk-tab-config/snk-tab-config';
|
35
36
|
export { SnkTaskbar as SnkTaskbar } from '../types/components/snk-taskbar/snk-taskbar';
|
36
37
|
export { TestePesquisa as TestePesquisa } from '../types/components/teste-pesquisa/teste-pesquisa';
|
package/dist/components/index.js
CHANGED
@@ -31,6 +31,7 @@ export { SnkGridConfig, defineCustomElement as defineCustomElementSnkGridConfig
|
|
31
31
|
export { SnkGuidesViewer, defineCustomElement as defineCustomElementSnkGuidesViewer } from './snk-guides-viewer.js';
|
32
32
|
export { SnkPesquisa, defineCustomElement as defineCustomElementSnkPesquisa } from './snk-pesquisa.js';
|
33
33
|
export { SnkSelectBox, defineCustomElement as defineCustomElementSnkSelectBox } from './snk-select-box.js';
|
34
|
+
export { SnkSimpleCrud, defineCustomElement as defineCustomElementSnkSimpleCrud } from './snk-simple-crud.js';
|
34
35
|
export { SnkTabConfig, defineCustomElement as defineCustomElementSnkTabConfig } from './snk-tab-config.js';
|
35
36
|
export { SnkTaskbar, defineCustomElement as defineCustomElementSnkTaskbar } from './snk-taskbar.js';
|
36
37
|
export { TestePesquisa, defineCustomElement as defineCustomElementTestePesquisa } from './teste-pesquisa.js';
|
@@ -6,7 +6,7 @@ import { ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
|
|
6
6
|
import { P as PresentationMode } from './index2.js';
|
7
7
|
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
8
8
|
import { V as VIEW_MODE } from './constants.js';
|
9
|
-
import { T as TaskbarProcessor
|
9
|
+
import { T as TaskbarProcessor } from './taskbar-processor.js';
|
10
10
|
import { d as defineCustomElement$k } from './snk-config-options2.js';
|
11
11
|
import { d as defineCustomElement$j } from './snk-configurator2.js';
|
12
12
|
import { d as defineCustomElement$i } from './snk-data-exporter2.js';
|
@@ -19,6 +19,7 @@ import { d as defineCustomElement$b } from './snk-filter-list2.js';
|
|
19
19
|
import { d as defineCustomElement$a } from './snk-filter-modal2.js';
|
20
20
|
import { d as defineCustomElement$8 } from './snk-form-summary2.js';
|
21
21
|
import { d as defineCustomElement$7 } from './snk-form-view2.js';
|
22
|
+
import { d as defineCustomElement$6 } from './snk-grid2.js';
|
22
23
|
import { d as defineCustomElement$5 } from './snk-grid-config2.js';
|
23
24
|
import { d as defineCustomElement$4 } from './snk-select-box2.js';
|
24
25
|
import { d as defineCustomElement$f } from './snk-field-config2.js';
|
@@ -3,6 +3,7 @@ import { ElementIDUtils, ApplicationContext, DataType } from '@sankhyalabs/core'
|
|
3
3
|
import { UserInterface } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage.js';
|
5
5
|
import { P as PresentationMode } from './index2.js';
|
6
|
+
import { T as TaskbarProcessor } from './taskbar-processor.js';
|
6
7
|
import { s as store, d as defineCustomElement$1 } from './snk-taskbar2.js';
|
7
8
|
import { d as defineCustomElement$a } from './snk-data-exporter2.js';
|
8
9
|
import { d as defineCustomElement$9 } from './snk-exporter-email-sender2.js';
|
@@ -14,52 +15,6 @@ import { d as defineCustomElement$4 } from './snk-filter-modal2.js';
|
|
14
15
|
import { d as defineCustomElement$3 } from './snk-grid-config2.js';
|
15
16
|
import { d as defineCustomElement$2 } from './snk-select-box2.js';
|
16
17
|
|
17
|
-
class TaskbarProcessor {
|
18
|
-
constructor(defaultButtons) {
|
19
|
-
this._defaultButtons = defaultButtons;
|
20
|
-
}
|
21
|
-
process(taskbarId, taskbarManager, dataState, disabledButtons = [], invisibleButtons = []) {
|
22
|
-
var _a;
|
23
|
-
this.customButtons = new Map();
|
24
|
-
this.buttons = "";
|
25
|
-
this.disabledButtons = [];
|
26
|
-
(_a = this.getButtonsArray(taskbarId, taskbarManager, dataState)) === null || _a === void 0 ? void 0 : _a.forEach(btnDef => {
|
27
|
-
let buttonName;
|
28
|
-
if (typeof btnDef === "string") {
|
29
|
-
buttonName = btnDef;
|
30
|
-
}
|
31
|
-
else {
|
32
|
-
const customBtn = btnDef;
|
33
|
-
this.customButtons.set(customBtn.name, customBtn);
|
34
|
-
buttonName = customBtn.name;
|
35
|
-
}
|
36
|
-
if (!invisibleButtons.includes(buttonName)) {
|
37
|
-
if (!this.isEnabled(taskbarId, taskbarManager, buttonName, dataState, disabledButtons)) {
|
38
|
-
this.disabledButtons.push(buttonName);
|
39
|
-
}
|
40
|
-
if (this.buttons.length > 0) {
|
41
|
-
this.buttons += ",";
|
42
|
-
}
|
43
|
-
this.buttons += buttonName;
|
44
|
-
}
|
45
|
-
});
|
46
|
-
}
|
47
|
-
getButtonsArray(taskbarId, taskbarManager, dataState) {
|
48
|
-
const defaults = this._defaultButtons[taskbarId];
|
49
|
-
if (taskbarManager) {
|
50
|
-
return taskbarManager.getButtons(taskbarId, dataState, [...defaults]);
|
51
|
-
}
|
52
|
-
return defaults;
|
53
|
-
}
|
54
|
-
isEnabled(taskbarId, taskbarManager, buttonName, dataState, disabled) {
|
55
|
-
const originalValue = disabled.includes(buttonName) ? false : true;
|
56
|
-
if (taskbarManager && taskbarManager.isEnabled) {
|
57
|
-
return taskbarManager.isEnabled(taskbarId, dataState, buttonName, originalValue);
|
58
|
-
}
|
59
|
-
return originalValue;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
18
|
const snkGridCss = ".snk-grid__container.sc-snk-grid{display:flex;height:100%;width:100%}.snk-grid__header.sc-snk-grid{display:flex;flex-wrap:nowrap;width:100%}.snk-grid__filter-bar.sc-snk-grid{width:100%}.snk-grid__header-divider.sc-snk-grid{margin-bottom:var(--space--medium)}.snk-grid__table.sc-snk-grid{min-height:300px}.snk-grid-container__without-shadow.sc-snk-grid{--ezgrid__container--shadow:unset}";
|
64
19
|
|
65
20
|
const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
@@ -384,4 +339,4 @@ function defineCustomElement() {
|
|
384
339
|
} });
|
385
340
|
}
|
386
341
|
|
387
|
-
export { SnkGrid as S,
|
342
|
+
export { SnkGrid as S, defineCustomElement as d };
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
2
|
+
|
3
|
+
interface SnkSimpleCrud extends Components.SnkSimpleCrud, HTMLElement {}
|
4
|
+
export const SnkSimpleCrud: {
|
5
|
+
prototype: SnkSimpleCrud;
|
6
|
+
new (): SnkSimpleCrud;
|
7
|
+
};
|
8
|
+
/**
|
9
|
+
* Used to define this component and all nested components recursively.
|
10
|
+
*/
|
11
|
+
export const defineCustomElement: () => void;
|