@sankhyalabs/sankhyablocks 1.3.30 → 1.3.31-beta.3
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/{index-1133bc2a.js → index-e42cb45d.js} +448 -9
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/sankhyablocks.cjs.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +105 -79
- package/dist/cjs/snk-data-unit.cjs.entry.js +144 -0
- package/dist/cjs/snk-form.cjs.entry.js +95 -0
- package/dist/cjs/snk-grid.cjs.entry.js +64 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +159 -0
- package/dist/cjs/taskbar-elements-bfa647c7.js +68 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +4 -0
- package/dist/collection/components/snk-application/snk-application.js +52 -5
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +325 -0
- package/dist/collection/components/snk-form/snk-form.css +3 -0
- package/dist/collection/components/snk-form/snk-form.js +194 -0
- package/dist/collection/components/snk-grid/snk-grid.css +5 -0
- package/dist/collection/components/snk-grid/snk-grid.js +128 -0
- package/dist/collection/components/snk-taskbar/component/snk-popup-button.js +7 -0
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +63 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +268 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +32 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/components/snk-application2.js +105 -78
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +165 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +121 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +88 -0
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +239 -0
- package/dist/esm/{index-ffda6382.js → index-02c04e0f.js} +448 -10
- package/dist/esm/loader.js +2 -2
- package/dist/esm/sankhyablocks.js +2 -2
- package/dist/esm/snk-application.entry.js +105 -79
- package/dist/esm/snk-data-unit.entry.js +140 -0
- package/dist/esm/snk-form.entry.js +91 -0
- package/dist/esm/snk-grid.entry.js +60 -0
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +155 -0
- package/dist/esm/taskbar-elements-fe7cbf0e.js +66 -0
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-09e48ff8.entry.js +1 -0
- package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-376004ef.entry.js} +1 -1
- package/dist/sankhyablocks/p-37b06977.entry.js +1 -0
- package/dist/sankhyablocks/p-64e2471c.js +1 -0
- package/dist/sankhyablocks/p-b80352ac.entry.js +69 -0
- package/dist/sankhyablocks/p-c156b1da.entry.js +1 -0
- package/dist/sankhyablocks/p-cc9c348a.entry.js +1 -0
- package/dist/sankhyablocks/p-db215c74.js +2 -0
- package/dist/sankhyablocks/{p-d62412bb.entry.js → p-e38386b1.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +3 -1
- package/dist/types/components/snk-taskbar/component/snk-popup-button.d.ts +12 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +24 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +28 -0
- package/dist/types/components.d.ts +112 -1
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
- package/package.json +5 -5
- package/react/components.d.ts +4 -0
- package/react/components.js +4 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-e6e91d5f.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { d as defineCustomElement$2 } from './snk-taskbar2.js';
|
|
4
|
+
|
|
5
|
+
const snkFormCss = ".sc-snk-form-h{display:block}";
|
|
6
|
+
|
|
7
|
+
const SnkForm$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.__registerHost();
|
|
11
|
+
this.exit = createEvent(this, "exit", 7);
|
|
12
|
+
this.actionClick = createEvent(this, "actionClick", 7);
|
|
13
|
+
}
|
|
14
|
+
getFormConfig() {
|
|
15
|
+
return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
|
|
16
|
+
}
|
|
17
|
+
getInsertionHiddenFields(formConfig) {
|
|
18
|
+
const hiddenFields = [];
|
|
19
|
+
formConfig === null || formConfig === void 0 ? void 0 : formConfig.forEach(cfg => {
|
|
20
|
+
const def = this._dataUnit.getField(cfg.name);
|
|
21
|
+
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
22
|
+
hiddenFields.push(cfg.name);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return hiddenFields;
|
|
26
|
+
}
|
|
27
|
+
exitForm() {
|
|
28
|
+
if (this._dataUnit.isDirty()) {
|
|
29
|
+
this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.exit.emit();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
getDisabledButtons() {
|
|
36
|
+
const disabled = [];
|
|
37
|
+
if (!this._dataState.hasPrevious) {
|
|
38
|
+
disabled.push("PREVIOUS");
|
|
39
|
+
}
|
|
40
|
+
if (!this._dataState.hasNext) {
|
|
41
|
+
disabled.push("NEXT");
|
|
42
|
+
}
|
|
43
|
+
return disabled;
|
|
44
|
+
}
|
|
45
|
+
componentWillLoad() {
|
|
46
|
+
let parent = this._element.parentElement;
|
|
47
|
+
while (parent) {
|
|
48
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
49
|
+
this._snkDataUnit = parent;
|
|
50
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
51
|
+
this._dataState = this._snkDataUnit.dataState;
|
|
52
|
+
if (!this._dataUnit) {
|
|
53
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
54
|
+
this._dataUnit = evt.detail;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
58
|
+
this._dataState = evt.detail;
|
|
59
|
+
});
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
parent = parent.parentElement;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
componentWillRender() {
|
|
66
|
+
if (this._dataUnit && !this._configLoaded) {
|
|
67
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
68
|
+
if (snkApplication) {
|
|
69
|
+
snkApplication.loadFormConfig(this.configName).then(cfg => {
|
|
70
|
+
this._configLoaded = true;
|
|
71
|
+
this._editionFormConfig = cfg;
|
|
72
|
+
this._insertionFormConfig = cfg.filter(fieldCfg => {
|
|
73
|
+
const def = this._dataUnit.getField(fieldCfg.name);
|
|
74
|
+
if (def === null || def === void 0 ? void 0 : def.readOnly) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
if (!this._configLoaded || !this._dataUnit || !this._dataState) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
return (h("section", { class: "ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6", key: "formHeader" }, h("ez-button", { mode: "icon", iconName: "arrow_back", class: "ez-padding-right--medium", size: "small", onClick: () => this.exitForm() }), h("h1", { class: "ez-title ez-title--primary ez-title--xlarge ez-align--middle" }, this.formTitle)), h("div", { class: "ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right" }, h("snk-taskbar", { key: "formTaskbar", buttons: this._dataState.isDirty ? "CANCEL,SAVE" : "PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,INSERT", primaryButton: this._dataState.isDirty ? "SAVE" : "INSERT", disabledButtons: this.getDisabledButtons(), actionsList: this.actionsList, dataUnit: this._dataUnit }))), h("div", { class: "ez-padding--small" }), h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, dataUnit: this._dataUnit, config: this.getFormConfig() }))))));
|
|
88
|
+
}
|
|
89
|
+
get _element() { return this; }
|
|
90
|
+
static get style() { return snkFormCss; }
|
|
91
|
+
}, [2, "snk-form", {
|
|
92
|
+
"formTitle": [1, "form-title"],
|
|
93
|
+
"configName": [1, "config-name"],
|
|
94
|
+
"actionsList": [16],
|
|
95
|
+
"_dataUnit": [32],
|
|
96
|
+
"_configLoaded": [32],
|
|
97
|
+
"_dataState": [32]
|
|
98
|
+
}]);
|
|
99
|
+
function defineCustomElement$1() {
|
|
100
|
+
if (typeof customElements === "undefined") {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const components = ["snk-form", "snk-taskbar"];
|
|
104
|
+
components.forEach(tagName => { switch (tagName) {
|
|
105
|
+
case "snk-form":
|
|
106
|
+
if (!customElements.get(tagName)) {
|
|
107
|
+
customElements.define(tagName, SnkForm$1);
|
|
108
|
+
}
|
|
109
|
+
break;
|
|
110
|
+
case "snk-taskbar":
|
|
111
|
+
if (!customElements.get(tagName)) {
|
|
112
|
+
defineCustomElement$2();
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
} });
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const SnkForm = SnkForm$1;
|
|
119
|
+
const defineCustomElement = defineCustomElement$1;
|
|
120
|
+
|
|
121
|
+
export { SnkForm, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkGrid extends Components.SnkGrid, HTMLElement {}
|
|
4
|
+
export const SnkGrid: {
|
|
5
|
+
prototype: SnkGrid;
|
|
6
|
+
new (): SnkGrid;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
|
4
|
+
|
|
5
|
+
const snkGridCss = ".sc-snk-grid-h{display:flex;height:100%;width:100%}";
|
|
6
|
+
|
|
7
|
+
const SnkGrid$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this.__registerHost();
|
|
11
|
+
this.actionClick = createEvent(this, "actionClick", 7);
|
|
12
|
+
}
|
|
13
|
+
getHeaderButtons() {
|
|
14
|
+
return this._dataState && this._dataState.selectedRecords.length > 0 ? "UPDATE,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,REFRESH" : "REFRESH";
|
|
15
|
+
}
|
|
16
|
+
actionClickHandler(evt) {
|
|
17
|
+
if (evt.detail === TaskbarElement.CONFIG_GRID && this._grid) {
|
|
18
|
+
this._grid.openGridConfig();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
componentWillLoad() {
|
|
22
|
+
let parent = this._element.parentElement;
|
|
23
|
+
while (parent) {
|
|
24
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
25
|
+
this._snkDataUnit = parent;
|
|
26
|
+
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
27
|
+
if (!this._dataUnit) {
|
|
28
|
+
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
29
|
+
this._dataUnit = evt.detail;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
this._snkDataUnit.addEventListener("dataStateChange", (evt) => {
|
|
33
|
+
this._dataState = evt.detail;
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
parent = parent.parentElement;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
componentWillRender() {
|
|
41
|
+
if (this._dataUnit && !this._configLoaded) {
|
|
42
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
43
|
+
if (snkApplication) {
|
|
44
|
+
snkApplication.loadGridConfig(this.configName).then(cfg => {
|
|
45
|
+
this._gridConfig = cfg;
|
|
46
|
+
this._configLoaded = true;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
if (!this._configLoaded || !this._dataUnit) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
return (h("div", { class: "ez-flex ez-flex--column ez-flex-item--auto ez-padding--large" }, h("div", { class: "ez-row ez-padding-bottom--medium ez-margin-bottom--medium" }, h("div", { class: "ez-col ez-col--sd-9 ez-col--tb-9 ez-align--bottom" }, h("slot", null)), h("div", { class: "ez-col ez-col--sd-3 ez-col--tb-3 ez-align--right" }, h("snk-taskbar", { onActionClick: evt => this.actionClickHandler(evt), key: "topTaskbar", dataUnit: this._dataUnit, buttons: "FORM_MODE,CONFIG_GRID,INSERT", primaryButton: "INSERT" }))), h("ez-grid", { ref: ref => this._grid = ref, dataUnit: this._dataUnit, key: "grid-" + this._snkDataUnit.entityName, config: this._gridConfig }, h("snk-taskbar", { dataUnit: this._dataUnit, buttons: this.getHeaderButtons(), slot: "leftButtons", actionsList: this.actionsList }))));
|
|
56
|
+
}
|
|
57
|
+
get _element() { return this; }
|
|
58
|
+
static get style() { return snkGridCss; }
|
|
59
|
+
}, [6, "snk-grid", {
|
|
60
|
+
"configName": [1, "config-name"],
|
|
61
|
+
"actionsList": [16],
|
|
62
|
+
"_dataUnit": [32],
|
|
63
|
+
"_configLoaded": [32],
|
|
64
|
+
"_dataState": [32]
|
|
65
|
+
}]);
|
|
66
|
+
function defineCustomElement$1() {
|
|
67
|
+
if (typeof customElements === "undefined") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const components = ["snk-grid", "snk-taskbar"];
|
|
71
|
+
components.forEach(tagName => { switch (tagName) {
|
|
72
|
+
case "snk-grid":
|
|
73
|
+
if (!customElements.get(tagName)) {
|
|
74
|
+
customElements.define(tagName, SnkGrid$1);
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
case "snk-taskbar":
|
|
78
|
+
if (!customElements.get(tagName)) {
|
|
79
|
+
defineCustomElement$2();
|
|
80
|
+
}
|
|
81
|
+
break;
|
|
82
|
+
} });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const SnkGrid = SnkGrid$1;
|
|
86
|
+
const defineCustomElement = defineCustomElement$1;
|
|
87
|
+
|
|
88
|
+
export { SnkGrid, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface SnkTaskbar extends Components.SnkTaskbar, HTMLElement {}
|
|
4
|
+
export const SnkTaskbar: {
|
|
5
|
+
prototype: SnkTaskbar;
|
|
6
|
+
new (): SnkTaskbar;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { h, proxyCustomElement, HTMLElement, createEvent, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
|
|
4
|
+
const SnkPopupButton = ({ className, title, source, opened, setOpened, actionClick }) => {
|
|
5
|
+
return (h("div", { class: "ez-flex " + className },
|
|
6
|
+
h("ez-button", { id: "moreOptionsButton", title: title, mode: "icon", iconName: "dots-vertical", size: "small", onClick: () => setOpened(true) }),
|
|
7
|
+
h("ez-popover", { opened: opened, autoClose: true, innerElement: ["moreOptionsButton", "moreOptionsDiv"], onEzVisibilityChange: (event) => setOpened(event.detail) },
|
|
8
|
+
h("div", { id: "moreOptionsDiv", class: "ez-padding--small" }, source.map((option, index) => h("ez-button", { className: "btn-options", size: "small", label: option.label, key: index, onClick: () => actionClick(option) }))))));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
var TaskbarElement;
|
|
12
|
+
(function (TaskbarElement) {
|
|
13
|
+
TaskbarElement["PREVIOUS"] = "PREVIOUS";
|
|
14
|
+
TaskbarElement["NEXT"] = "NEXT";
|
|
15
|
+
TaskbarElement["REFRESH"] = "REFRESH";
|
|
16
|
+
TaskbarElement["UPDATE"] = "UPDATE";
|
|
17
|
+
TaskbarElement["CLONE"] = "CLONE";
|
|
18
|
+
TaskbarElement["REMOVE"] = "REMOVE";
|
|
19
|
+
TaskbarElement["INSERT"] = "INSERT";
|
|
20
|
+
TaskbarElement["CANCEL"] = "CANCEL";
|
|
21
|
+
TaskbarElement["SAVE"] = "SAVE";
|
|
22
|
+
TaskbarElement["GRID_MODE"] = "GRID_MODE";
|
|
23
|
+
TaskbarElement["FORM_MODE"] = "FORM_MODE";
|
|
24
|
+
TaskbarElement["CONFIG_GRID"] = "CONFIG_GRID";
|
|
25
|
+
TaskbarElement["MORE_OPTIONS"] = "MORE_OPTIONS";
|
|
26
|
+
TaskbarElement["DIVIDER"] = "DIVIDER";
|
|
27
|
+
})(TaskbarElement || (TaskbarElement = {}));
|
|
28
|
+
var AuthorizationElements;
|
|
29
|
+
(function (AuthorizationElements) {
|
|
30
|
+
AuthorizationElements["UPDATE"] = "UPDATE";
|
|
31
|
+
AuthorizationElements["CLONE"] = "CLONE";
|
|
32
|
+
AuthorizationElements["REMOVE"] = "REMOVE";
|
|
33
|
+
AuthorizationElements["INSERT"] = "INSERT";
|
|
34
|
+
AuthorizationElements["CONFIG_GRID"] = "CONFIG_GRID";
|
|
35
|
+
})(AuthorizationElements || (AuthorizationElements = {}));
|
|
36
|
+
const buildElem = (element, className, getTitle, action, isEnabled) => {
|
|
37
|
+
switch (element) {
|
|
38
|
+
case TaskbarElement.PREVIOUS:
|
|
39
|
+
return iconButton("chevron-left", element, className, getTitle, action, isEnabled);
|
|
40
|
+
case TaskbarElement.NEXT:
|
|
41
|
+
return iconButton("chevron-right", element, className, getTitle, action, isEnabled);
|
|
42
|
+
case TaskbarElement.REFRESH:
|
|
43
|
+
return iconButton("sync", element, className, getTitle, action, isEnabled);
|
|
44
|
+
case TaskbarElement.UPDATE:
|
|
45
|
+
return iconButton("edit", element, className, getTitle, action, isEnabled);
|
|
46
|
+
case TaskbarElement.CLONE:
|
|
47
|
+
return iconButton("copy", element, className, getTitle, action, isEnabled);
|
|
48
|
+
case TaskbarElement.REMOVE:
|
|
49
|
+
return iconButton("delete", element, className, getTitle, action, isEnabled);
|
|
50
|
+
case TaskbarElement.INSERT:
|
|
51
|
+
return iconTextButton("plus", element, className, getTitle, action, isEnabled);
|
|
52
|
+
case TaskbarElement.CANCEL:
|
|
53
|
+
return h("ez-button", { label: getTitle(element), size: "small", enabled: isEnabled(element), onClick: () => action(element) });
|
|
54
|
+
case TaskbarElement.SAVE:
|
|
55
|
+
return iconTextButton("save", element, className, getTitle, action, isEnabled);
|
|
56
|
+
case TaskbarElement.GRID_MODE:
|
|
57
|
+
return iconButton("table", element, className, getTitle, action, isEnabled);
|
|
58
|
+
case TaskbarElement.FORM_MODE:
|
|
59
|
+
return iconButton("list", element, className, getTitle, action, isEnabled);
|
|
60
|
+
case TaskbarElement.CONFIG_GRID:
|
|
61
|
+
return iconButton("settings-inverted", element, className, getTitle, action, isEnabled);
|
|
62
|
+
case TaskbarElement.DIVIDER:
|
|
63
|
+
return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-horizontal--medium" });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
function iconButton(iconName, element, className, getTitle, action, isEnabled) {
|
|
67
|
+
return h("ez-button", { key: iconName, title: getTitle(element), mode: "icon", size: "small", class: className, iconName: iconName, enabled: isEnabled(element), onClick: () => action(element) });
|
|
68
|
+
}
|
|
69
|
+
function iconTextButton(iconName, element, className, getTitle, action, isEnabled) {
|
|
70
|
+
return h("ez-button", { key: iconName, title: getTitle(element), label: getTitle(element), size: "small", class: className, enabled: isEnabled(element), onClick: () => action(element) },
|
|
71
|
+
h("ez-icon", { class: "ez-padding-right--small", slot: "leftIcon", iconName: iconName }));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex}";
|
|
75
|
+
|
|
76
|
+
const SnkTaskbar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
77
|
+
constructor() {
|
|
78
|
+
super();
|
|
79
|
+
this.__registerHost();
|
|
80
|
+
this.actionClick = createEvent(this, "actionClick", 7);
|
|
81
|
+
this._moreOptionsOpened = false;
|
|
82
|
+
}
|
|
83
|
+
observeButtons() {
|
|
84
|
+
this._definitions = undefined;
|
|
85
|
+
}
|
|
86
|
+
// Internal methods
|
|
87
|
+
elementsFromString(strButtons) {
|
|
88
|
+
const elements = [];
|
|
89
|
+
if (strButtons) {
|
|
90
|
+
strButtons.split(",").forEach(buttonName => {
|
|
91
|
+
buttonName = buttonName.trim();
|
|
92
|
+
if (this.isAllowed(buttonName)) {
|
|
93
|
+
elements.push(buttonName.trim());
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return elements;
|
|
98
|
+
}
|
|
99
|
+
isAllowed(buttonName) {
|
|
100
|
+
if (AuthorizationElements[buttonName]) {
|
|
101
|
+
return this._permissions ? this._permissions.isSup || this._permissions[buttonName] : false;
|
|
102
|
+
}
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
getTitle(element) {
|
|
106
|
+
const pt_br = {
|
|
107
|
+
[TaskbarElement.UPDATE]: "Editar",
|
|
108
|
+
[TaskbarElement.PREVIOUS]: "Anterior",
|
|
109
|
+
[TaskbarElement.NEXT]: "Próximo",
|
|
110
|
+
[TaskbarElement.REFRESH]: "Atualizar",
|
|
111
|
+
[TaskbarElement.CLONE]: "Duplicar",
|
|
112
|
+
[TaskbarElement.REMOVE]: "Excluir",
|
|
113
|
+
[TaskbarElement.MORE_OPTIONS]: "Mais Opções",
|
|
114
|
+
[TaskbarElement.INSERT]: "Cadastrar",
|
|
115
|
+
[TaskbarElement.CANCEL]: "Cancelar",
|
|
116
|
+
[TaskbarElement.SAVE]: "Salvar",
|
|
117
|
+
[TaskbarElement.GRID_MODE]: "Modo Grade",
|
|
118
|
+
[TaskbarElement.CONFIG_GRID]: "Configuração da grade",
|
|
119
|
+
[TaskbarElement.FORM_MODE]: "Modo Formulário"
|
|
120
|
+
};
|
|
121
|
+
return pt_br[element] ? pt_br[element] : "";
|
|
122
|
+
}
|
|
123
|
+
elementClick(elem) {
|
|
124
|
+
if (this.dataUnit) {
|
|
125
|
+
switch (elem) {
|
|
126
|
+
case TaskbarElement.PREVIOUS:
|
|
127
|
+
this.dataUnit.previousRecord();
|
|
128
|
+
break;
|
|
129
|
+
case TaskbarElement.NEXT:
|
|
130
|
+
this.dataUnit.nextRecord();
|
|
131
|
+
break;
|
|
132
|
+
case TaskbarElement.REFRESH:
|
|
133
|
+
this.dataUnit.loadData();
|
|
134
|
+
break;
|
|
135
|
+
case TaskbarElement.CLONE:
|
|
136
|
+
this.dataUnit.copySelected();
|
|
137
|
+
break;
|
|
138
|
+
case TaskbarElement.REMOVE:
|
|
139
|
+
this.dataUnit.removeSelectedRecords();
|
|
140
|
+
break;
|
|
141
|
+
case TaskbarElement.INSERT:
|
|
142
|
+
this.dataUnit.addRecord();
|
|
143
|
+
break;
|
|
144
|
+
case TaskbarElement.CANCEL:
|
|
145
|
+
this.dataUnit.cancelEdition();
|
|
146
|
+
break;
|
|
147
|
+
case TaskbarElement.SAVE:
|
|
148
|
+
this.dataUnit.saveData();
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.actionClick.emit(elem);
|
|
153
|
+
}
|
|
154
|
+
actionClickHandler(act) {
|
|
155
|
+
this._moreOptionsOpened = false;
|
|
156
|
+
this.actionClick.emit(act.key);
|
|
157
|
+
}
|
|
158
|
+
isEnabled(elem) {
|
|
159
|
+
return !(this.disabledButtons && this.disabledButtons.includes(elem));
|
|
160
|
+
}
|
|
161
|
+
getElement(index, def) {
|
|
162
|
+
let element;
|
|
163
|
+
let className = def === this.primaryButton ? "ez-button--primary " : "";
|
|
164
|
+
if (index > 1) {
|
|
165
|
+
className += "ez-padding-left--medium";
|
|
166
|
+
}
|
|
167
|
+
if (def === TaskbarElement.MORE_OPTIONS) {
|
|
168
|
+
element = this.actionsList ? h(SnkPopupButton, { className: className, title: this.getTitle(def), source: this.actionsList, opened: this._moreOptionsOpened, setOpened: opened => this._moreOptionsOpened = opened, actionClick: act => this.actionClickHandler(act) }) : undefined;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
element = buildElem(def, className, elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem));
|
|
172
|
+
}
|
|
173
|
+
return element;
|
|
174
|
+
}
|
|
175
|
+
// Lifecycle
|
|
176
|
+
componentWillRender() {
|
|
177
|
+
if (this._permissions === undefined) {
|
|
178
|
+
const snkApplication = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
179
|
+
if (snkApplication) {
|
|
180
|
+
snkApplication.getAllAccess().then(access => this._permissions = access);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this._permissions = {};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (this._definitions == undefined) {
|
|
188
|
+
this._definitions = this.elementsFromString(this.buttons);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
render() {
|
|
193
|
+
if (this._definitions === undefined) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
let index = 0;
|
|
197
|
+
return (h(Host, null, this._definitions.map((btn) => {
|
|
198
|
+
if (btn === TaskbarElement.DIVIDER) {
|
|
199
|
+
index = 0;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
index++;
|
|
203
|
+
}
|
|
204
|
+
if (TaskbarElement[btn]) {
|
|
205
|
+
return this.getElement(index, TaskbarElement[btn]);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return h("slot", { name: btn });
|
|
209
|
+
}
|
|
210
|
+
})));
|
|
211
|
+
}
|
|
212
|
+
static get watchers() { return {
|
|
213
|
+
"buttons": ["observeButtons"]
|
|
214
|
+
}; }
|
|
215
|
+
static get style() { return snkTaskbarCss; }
|
|
216
|
+
}, [6, "snk-taskbar", {
|
|
217
|
+
"buttons": [1],
|
|
218
|
+
"actionsList": [16],
|
|
219
|
+
"primaryButton": [1, "primary-button"],
|
|
220
|
+
"disabledButtons": [16],
|
|
221
|
+
"dataUnit": [16],
|
|
222
|
+
"_moreOptionsOpened": [32],
|
|
223
|
+
"_permissions": [32]
|
|
224
|
+
}]);
|
|
225
|
+
function defineCustomElement() {
|
|
226
|
+
if (typeof customElements === "undefined") {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const components = ["snk-taskbar"];
|
|
230
|
+
components.forEach(tagName => { switch (tagName) {
|
|
231
|
+
case "snk-taskbar":
|
|
232
|
+
if (!customElements.get(tagName)) {
|
|
233
|
+
customElements.define(tagName, SnkTaskbar);
|
|
234
|
+
}
|
|
235
|
+
break;
|
|
236
|
+
} });
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export { SnkTaskbar as S, TaskbarElement as T, defineCustomElement as d };
|