@sankhyalabs/ezui 4.11.4 → 4.12.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/dist/cjs/ApplicationUtils-8cc2f37b.js +161 -0
- package/dist/cjs/ez-actions-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +1 -1
- package/dist/cjs/ez-combo-box.cjs.entry.js +1 -1
- package/dist/cjs/ez-form.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-edit.cjs.entry.js +1 -1
- package/dist/cjs/ez-upload.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/utils/ApplicationUtils.js +28 -0
- package/dist/custom-elements/index.js +92 -0
- package/dist/esm/ApplicationUtils-19857f60.js +159 -0
- package/dist/esm/ez-actions-button.entry.js +1 -1
- package/dist/esm/ez-collapsible-box.entry.js +1 -1
- package/dist/esm/ez-combo-box.entry.js +1 -1
- package/dist/esm/ez-form.entry.js +1 -1
- package/dist/esm/ez-text-edit.entry.js +1 -1
- package/dist/esm/ez-upload.entry.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-4f9931d8.entry.js → p-22b106d7.entry.js} +1 -1
- package/dist/ezui/{p-5844ec15.entry.js → p-370ad5c9.entry.js} +1 -1
- package/dist/ezui/p-41ce6f98.js +1 -0
- package/dist/ezui/{p-b8281997.entry.js → p-60e30f92.entry.js} +1 -1
- package/dist/ezui/{p-a98176cb.entry.js → p-709067e4.entry.js} +1 -1
- package/dist/ezui/{p-9af6c6ac.entry.js → p-805ee4c2.entry.js} +1 -1
- package/dist/ezui/{p-be09b541.entry.js → p-ea5a5236.entry.js} +1 -1
- package/dist/types/utils/ApplicationUtils.d.ts +12 -1
- package/package.json +3 -1
- package/dist/cjs/ApplicationUtils-d71aed06.js +0 -69
- package/dist/esm/ApplicationUtils-3d870a53.js +0 -67
- package/dist/ezui/p-ab2a3006.js +0 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const DialogType = require('./DialogType-2114c337.js');
|
|
4
|
+
|
|
5
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
6
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
7
|
+
// generators (like Math.random()).
|
|
8
|
+
let getRandomValues;
|
|
9
|
+
const rnds8 = new Uint8Array(16);
|
|
10
|
+
function rng() {
|
|
11
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
12
|
+
if (!getRandomValues) {
|
|
13
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
14
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
15
|
+
|
|
16
|
+
if (!getRandomValues) {
|
|
17
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return getRandomValues(rnds8);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
26
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
const byteToHex = [];
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < 256; ++i) {
|
|
32
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function unsafeStringify(arr, offset = 0) {
|
|
36
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
37
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
38
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
42
|
+
const native = {
|
|
43
|
+
randomUUID
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function v4(options, buf, offset) {
|
|
47
|
+
if (native.randomUUID && !buf && !options) {
|
|
48
|
+
return native.randomUUID();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
options = options || {};
|
|
52
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
53
|
+
|
|
54
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
55
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
56
|
+
|
|
57
|
+
if (buf) {
|
|
58
|
+
offset = offset || 0;
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < 16; ++i) {
|
|
61
|
+
buf[offset + i] = rnds[i];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return buf;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return unsafeStringify(rnds);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
class ApplicationUtils {
|
|
71
|
+
static async showDialog(title, message, icon = null, confirm, dialogType = DialogType.DialogType.DEFAULT, options) {
|
|
72
|
+
if (options) {
|
|
73
|
+
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
74
|
+
}
|
|
75
|
+
return new Promise(resolve => {
|
|
76
|
+
let dialog = document.querySelector("ez-dialog");
|
|
77
|
+
if (!dialog) {
|
|
78
|
+
dialog = document.createElement("ez-dialog");
|
|
79
|
+
window.document.body.appendChild(dialog);
|
|
80
|
+
}
|
|
81
|
+
dialog.show(title, message, dialogType, confirm, icon, options.labelCancel, options.labelConfirm, options.btnConfirmDanger, options.beforeClose).then(ok => resolve(ok));
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
static async alert(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
85
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.WARN, options);
|
|
86
|
+
}
|
|
87
|
+
static async error(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
88
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.CRITICAL, options);
|
|
89
|
+
}
|
|
90
|
+
static async success(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
91
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.SUCCESS, options);
|
|
92
|
+
}
|
|
93
|
+
static async confirm(title, message, icon = null, dialogType = DialogType.DialogType.WARN, options = ApplicationUtils.defaultMessageOptions) {
|
|
94
|
+
return ApplicationUtils.showDialog(title, message, icon, true, dialogType, options);
|
|
95
|
+
}
|
|
96
|
+
static async message(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
97
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.DEFAULT, options);
|
|
98
|
+
}
|
|
99
|
+
static async info(message, options = ApplicationUtils.defaultMessageOptions) {
|
|
100
|
+
if (options !== ApplicationUtils.defaultMessageOptions) {
|
|
101
|
+
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
102
|
+
}
|
|
103
|
+
let useIcon = false;
|
|
104
|
+
let toast = document.querySelector("ez-toast");
|
|
105
|
+
if (!toast) {
|
|
106
|
+
toast = document.createElement("ez-toast");
|
|
107
|
+
const icon = document.createElement("ez-icon");
|
|
108
|
+
icon.className = "ez-margin-right--small";
|
|
109
|
+
icon.slot = "icon";
|
|
110
|
+
icon.style.setProperty("--ez-icon--color", "var(--color--success)");
|
|
111
|
+
toast.appendChild(icon);
|
|
112
|
+
window.document.body.appendChild(toast);
|
|
113
|
+
}
|
|
114
|
+
if (options.iconName) {
|
|
115
|
+
const iconElem = toast.querySelector("ez-icon");
|
|
116
|
+
if (iconElem) {
|
|
117
|
+
iconElem.iconName = options.iconName;
|
|
118
|
+
useIcon = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
useIcon = false;
|
|
123
|
+
}
|
|
124
|
+
toast.show(message, 5000, useIcon, options.canClose);
|
|
125
|
+
}
|
|
126
|
+
static async showModal(modalProps) {
|
|
127
|
+
modalProps = Object.assign(Object.assign({}, ApplicationUtils.defaultModalProps), modalProps);
|
|
128
|
+
const modal = document.createElement("ez-modal");
|
|
129
|
+
window.document.body.appendChild(modal);
|
|
130
|
+
modal.setAttribute('id', v4());
|
|
131
|
+
modal.modalSize = modalProps.size;
|
|
132
|
+
modal.align = modalProps.position;
|
|
133
|
+
modal.heightMode = modalProps.heightMode;
|
|
134
|
+
modal.closeEsc = modalProps.closeEsc;
|
|
135
|
+
modal.closeOutsideClick = modalProps.closeOutsideClick;
|
|
136
|
+
if (modalProps.content instanceof String || typeof modalProps.content === 'string') {
|
|
137
|
+
modal.innerHTML = modalProps.content;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
modal.appendChild(modalProps.content);
|
|
141
|
+
}
|
|
142
|
+
modal.opened = true;
|
|
143
|
+
return () => modal.remove();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
ApplicationUtils.defaultMessageOptions = {
|
|
147
|
+
canClose: true,
|
|
148
|
+
labelCancel: 'Não',
|
|
149
|
+
labelConfirm: 'Sim',
|
|
150
|
+
btnConfirmDanger: false
|
|
151
|
+
};
|
|
152
|
+
ApplicationUtils.defaultModalProps = {
|
|
153
|
+
content: null,
|
|
154
|
+
position: 'right',
|
|
155
|
+
size: 'small',
|
|
156
|
+
heightMode: 'regular',
|
|
157
|
+
closeOutsideClick: true,
|
|
158
|
+
closeEsc: true
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
exports.ApplicationUtils = ApplicationUtils;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-7854a33d.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
require('./ApplicationUtils-
|
|
7
|
+
require('./ApplicationUtils-8cc2f37b.js');
|
|
8
8
|
const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
|
|
9
9
|
require('./DialogType-2114c337.js');
|
|
10
10
|
require('./CheckMode-ecb90b87.js');
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-7854a33d.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const ApplicationUtils = require('./ApplicationUtils-
|
|
7
|
+
const ApplicationUtils = require('./ApplicationUtils-8cc2f37b.js');
|
|
8
8
|
require('./DialogType-2114c337.js');
|
|
9
9
|
require('./CheckMode-ecb90b87.js');
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-7854a33d.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const ApplicationUtils = require('./ApplicationUtils-
|
|
7
|
+
const ApplicationUtils = require('./ApplicationUtils-8cc2f37b.js');
|
|
8
8
|
const CSSVarsUtils = require('./CSSVarsUtils-af809e73.js');
|
|
9
9
|
require('./DialogType-2114c337.js');
|
|
10
10
|
require('./CheckMode-ecb90b87.js');
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-7854a33d.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const ApplicationUtils = require('./ApplicationUtils-
|
|
7
|
+
const ApplicationUtils = require('./ApplicationUtils-8cc2f37b.js');
|
|
8
8
|
require('./DialogType-2114c337.js');
|
|
9
9
|
|
|
10
10
|
const DETAIL_PATTERN = /child\[([^\]]+)\]/;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-7854a33d.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
|
-
const ApplicationUtils = require('./ApplicationUtils-
|
|
7
|
+
const ApplicationUtils = require('./ApplicationUtils-8cc2f37b.js');
|
|
8
8
|
require('./DialogType-2114c337.js');
|
|
9
9
|
require('./CheckMode-ecb90b87.js');
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-7854a33d.js');
|
|
6
|
-
const ApplicationUtils = require('./ApplicationUtils-
|
|
6
|
+
const ApplicationUtils = require('./ApplicationUtils-8cc2f37b.js');
|
|
7
7
|
const core = require('@sankhyalabs/core');
|
|
8
8
|
require('./DialogType-2114c337.js');
|
|
9
9
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"entries": [
|
|
3
|
+
"./components/ez-modal/ez-modal.js",
|
|
3
4
|
"./components/ez-actions-button/ez-actions-button.js",
|
|
4
5
|
"./components/ez-breadcrumb/ez-breadcrumb.js",
|
|
5
6
|
"./components/ez-card-item/ez-card-item.js",
|
|
@@ -29,7 +30,6 @@
|
|
|
29
30
|
"./components/ez-guide-navigator/ez-guide-navigator.js",
|
|
30
31
|
"./components/ez-icon/ez-icon.js",
|
|
31
32
|
"./components/ez-loading-bar/ez-loading-bar.js",
|
|
32
|
-
"./components/ez-modal/ez-modal.js",
|
|
33
33
|
"./components/ez-modal-container/ez-modal-container.js",
|
|
34
34
|
"./components/ez-number-input/ez-number-input.js",
|
|
35
35
|
"./components/ez-popover/ez-popover.js",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { v4 as uuid } from "uuid";
|
|
1
2
|
import { DialogType } from "../components/ez-dialog/DialogType";
|
|
2
3
|
export default class ApplicationUtils {
|
|
3
4
|
static async showDialog(title, message, icon = null, confirm, dialogType = DialogType.DEFAULT, options) {
|
|
@@ -55,6 +56,25 @@ export default class ApplicationUtils {
|
|
|
55
56
|
}
|
|
56
57
|
toast.show(message, 5000, useIcon, options.canClose);
|
|
57
58
|
}
|
|
59
|
+
static async showModal(modalProps) {
|
|
60
|
+
modalProps = Object.assign(Object.assign({}, ApplicationUtils.defaultModalProps), modalProps);
|
|
61
|
+
const modal = document.createElement("ez-modal");
|
|
62
|
+
window.document.body.appendChild(modal);
|
|
63
|
+
modal.setAttribute('id', uuid());
|
|
64
|
+
modal.modalSize = modalProps.size;
|
|
65
|
+
modal.align = modalProps.position;
|
|
66
|
+
modal.heightMode = modalProps.heightMode;
|
|
67
|
+
modal.closeEsc = modalProps.closeEsc;
|
|
68
|
+
modal.closeOutsideClick = modalProps.closeOutsideClick;
|
|
69
|
+
if (modalProps.content instanceof String || typeof modalProps.content === 'string') {
|
|
70
|
+
modal.innerHTML = modalProps.content;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
modal.appendChild(modalProps.content);
|
|
74
|
+
}
|
|
75
|
+
modal.opened = true;
|
|
76
|
+
return () => modal.remove();
|
|
77
|
+
}
|
|
58
78
|
}
|
|
59
79
|
ApplicationUtils.defaultMessageOptions = {
|
|
60
80
|
canClose: true,
|
|
@@ -62,4 +82,12 @@ ApplicationUtils.defaultMessageOptions = {
|
|
|
62
82
|
labelConfirm: 'Sim',
|
|
63
83
|
btnConfirmDanger: false
|
|
64
84
|
};
|
|
85
|
+
ApplicationUtils.defaultModalProps = {
|
|
86
|
+
content: null,
|
|
87
|
+
position: 'right',
|
|
88
|
+
size: 'small',
|
|
89
|
+
heightMode: 'regular',
|
|
90
|
+
closeOutsideClick: true,
|
|
91
|
+
closeEsc: true
|
|
92
|
+
};
|
|
65
93
|
;
|
|
@@ -3,6 +3,71 @@ export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client'
|
|
|
3
3
|
import { UserInterface, DateUtils as DateUtils$1, Action, WaitingChangeException, ApplicationContext, DataUnitAction, FloatingManager, ElementIDUtils, ObjectUtils as ObjectUtils$1, JSUtils, StringUtils as StringUtils$1, TimeFormatter, DataUnit, NumberUtils as NumberUtils$1, DataType, SortMode, MaskFormatter } from '@sankhyalabs/core';
|
|
4
4
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
|
5
5
|
|
|
6
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
7
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
8
|
+
// generators (like Math.random()).
|
|
9
|
+
let getRandomValues;
|
|
10
|
+
const rnds8 = new Uint8Array(16);
|
|
11
|
+
function rng() {
|
|
12
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
13
|
+
if (!getRandomValues) {
|
|
14
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
15
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
16
|
+
|
|
17
|
+
if (!getRandomValues) {
|
|
18
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return getRandomValues(rnds8);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
27
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
const byteToHex = [];
|
|
31
|
+
|
|
32
|
+
for (let i = 0; i < 256; ++i) {
|
|
33
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function unsafeStringify(arr, offset = 0) {
|
|
37
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
38
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
39
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
43
|
+
const native = {
|
|
44
|
+
randomUUID
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function v4(options, buf, offset) {
|
|
48
|
+
if (native.randomUUID && !buf && !options) {
|
|
49
|
+
return native.randomUUID();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
options = options || {};
|
|
53
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
54
|
+
|
|
55
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
56
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
57
|
+
|
|
58
|
+
if (buf) {
|
|
59
|
+
offset = offset || 0;
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < 16; ++i) {
|
|
62
|
+
buf[offset + i] = rnds[i];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return buf;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return unsafeStringify(rnds);
|
|
69
|
+
}
|
|
70
|
+
|
|
6
71
|
var DialogType;
|
|
7
72
|
(function (DialogType) {
|
|
8
73
|
DialogType["WARN"] = "warn";
|
|
@@ -67,6 +132,25 @@ class ApplicationUtils {
|
|
|
67
132
|
}
|
|
68
133
|
toast.show(message, 5000, useIcon, options.canClose);
|
|
69
134
|
}
|
|
135
|
+
static async showModal(modalProps) {
|
|
136
|
+
modalProps = Object.assign(Object.assign({}, ApplicationUtils.defaultModalProps), modalProps);
|
|
137
|
+
const modal = document.createElement("ez-modal");
|
|
138
|
+
window.document.body.appendChild(modal);
|
|
139
|
+
modal.setAttribute('id', v4());
|
|
140
|
+
modal.modalSize = modalProps.size;
|
|
141
|
+
modal.align = modalProps.position;
|
|
142
|
+
modal.heightMode = modalProps.heightMode;
|
|
143
|
+
modal.closeEsc = modalProps.closeEsc;
|
|
144
|
+
modal.closeOutsideClick = modalProps.closeOutsideClick;
|
|
145
|
+
if (modalProps.content instanceof String || typeof modalProps.content === 'string') {
|
|
146
|
+
modal.innerHTML = modalProps.content;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
modal.appendChild(modalProps.content);
|
|
150
|
+
}
|
|
151
|
+
modal.opened = true;
|
|
152
|
+
return () => modal.remove();
|
|
153
|
+
}
|
|
70
154
|
}
|
|
71
155
|
ApplicationUtils.defaultMessageOptions = {
|
|
72
156
|
canClose: true,
|
|
@@ -74,6 +158,14 @@ ApplicationUtils.defaultMessageOptions = {
|
|
|
74
158
|
labelConfirm: 'Sim',
|
|
75
159
|
btnConfirmDanger: false
|
|
76
160
|
};
|
|
161
|
+
ApplicationUtils.defaultModalProps = {
|
|
162
|
+
content: null,
|
|
163
|
+
position: 'right',
|
|
164
|
+
size: 'small',
|
|
165
|
+
heightMode: 'regular',
|
|
166
|
+
closeOutsideClick: true,
|
|
167
|
+
closeEsc: true
|
|
168
|
+
};
|
|
77
169
|
|
|
78
170
|
class CSSVarsUtils {
|
|
79
171
|
static applyCSSVars(document, host, child) {
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { D as DialogType } from './DialogType-54a62731.js';
|
|
2
|
+
|
|
3
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
4
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
5
|
+
// generators (like Math.random()).
|
|
6
|
+
let getRandomValues;
|
|
7
|
+
const rnds8 = new Uint8Array(16);
|
|
8
|
+
function rng() {
|
|
9
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
10
|
+
if (!getRandomValues) {
|
|
11
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
12
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
13
|
+
|
|
14
|
+
if (!getRandomValues) {
|
|
15
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return getRandomValues(rnds8);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
24
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const byteToHex = [];
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < 256; ++i) {
|
|
30
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function unsafeStringify(arr, offset = 0) {
|
|
34
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
35
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
36
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
40
|
+
const native = {
|
|
41
|
+
randomUUID
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function v4(options, buf, offset) {
|
|
45
|
+
if (native.randomUUID && !buf && !options) {
|
|
46
|
+
return native.randomUUID();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
options = options || {};
|
|
50
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
51
|
+
|
|
52
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
53
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
54
|
+
|
|
55
|
+
if (buf) {
|
|
56
|
+
offset = offset || 0;
|
|
57
|
+
|
|
58
|
+
for (let i = 0; i < 16; ++i) {
|
|
59
|
+
buf[offset + i] = rnds[i];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return buf;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return unsafeStringify(rnds);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class ApplicationUtils {
|
|
69
|
+
static async showDialog(title, message, icon = null, confirm, dialogType = DialogType.DEFAULT, options) {
|
|
70
|
+
if (options) {
|
|
71
|
+
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
72
|
+
}
|
|
73
|
+
return new Promise(resolve => {
|
|
74
|
+
let dialog = document.querySelector("ez-dialog");
|
|
75
|
+
if (!dialog) {
|
|
76
|
+
dialog = document.createElement("ez-dialog");
|
|
77
|
+
window.document.body.appendChild(dialog);
|
|
78
|
+
}
|
|
79
|
+
dialog.show(title, message, dialogType, confirm, icon, options.labelCancel, options.labelConfirm, options.btnConfirmDanger, options.beforeClose).then(ok => resolve(ok));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
static async alert(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
83
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.WARN, options);
|
|
84
|
+
}
|
|
85
|
+
static async error(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
86
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.CRITICAL, options);
|
|
87
|
+
}
|
|
88
|
+
static async success(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
89
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.SUCCESS, options);
|
|
90
|
+
}
|
|
91
|
+
static async confirm(title, message, icon = null, dialogType = DialogType.WARN, options = ApplicationUtils.defaultMessageOptions) {
|
|
92
|
+
return ApplicationUtils.showDialog(title, message, icon, true, dialogType, options);
|
|
93
|
+
}
|
|
94
|
+
static async message(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
95
|
+
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DEFAULT, options);
|
|
96
|
+
}
|
|
97
|
+
static async info(message, options = ApplicationUtils.defaultMessageOptions) {
|
|
98
|
+
if (options !== ApplicationUtils.defaultMessageOptions) {
|
|
99
|
+
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
100
|
+
}
|
|
101
|
+
let useIcon = false;
|
|
102
|
+
let toast = document.querySelector("ez-toast");
|
|
103
|
+
if (!toast) {
|
|
104
|
+
toast = document.createElement("ez-toast");
|
|
105
|
+
const icon = document.createElement("ez-icon");
|
|
106
|
+
icon.className = "ez-margin-right--small";
|
|
107
|
+
icon.slot = "icon";
|
|
108
|
+
icon.style.setProperty("--ez-icon--color", "var(--color--success)");
|
|
109
|
+
toast.appendChild(icon);
|
|
110
|
+
window.document.body.appendChild(toast);
|
|
111
|
+
}
|
|
112
|
+
if (options.iconName) {
|
|
113
|
+
const iconElem = toast.querySelector("ez-icon");
|
|
114
|
+
if (iconElem) {
|
|
115
|
+
iconElem.iconName = options.iconName;
|
|
116
|
+
useIcon = true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
useIcon = false;
|
|
121
|
+
}
|
|
122
|
+
toast.show(message, 5000, useIcon, options.canClose);
|
|
123
|
+
}
|
|
124
|
+
static async showModal(modalProps) {
|
|
125
|
+
modalProps = Object.assign(Object.assign({}, ApplicationUtils.defaultModalProps), modalProps);
|
|
126
|
+
const modal = document.createElement("ez-modal");
|
|
127
|
+
window.document.body.appendChild(modal);
|
|
128
|
+
modal.setAttribute('id', v4());
|
|
129
|
+
modal.modalSize = modalProps.size;
|
|
130
|
+
modal.align = modalProps.position;
|
|
131
|
+
modal.heightMode = modalProps.heightMode;
|
|
132
|
+
modal.closeEsc = modalProps.closeEsc;
|
|
133
|
+
modal.closeOutsideClick = modalProps.closeOutsideClick;
|
|
134
|
+
if (modalProps.content instanceof String || typeof modalProps.content === 'string') {
|
|
135
|
+
modal.innerHTML = modalProps.content;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
modal.appendChild(modalProps.content);
|
|
139
|
+
}
|
|
140
|
+
modal.opened = true;
|
|
141
|
+
return () => modal.remove();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
ApplicationUtils.defaultMessageOptions = {
|
|
145
|
+
canClose: true,
|
|
146
|
+
labelCancel: 'Não',
|
|
147
|
+
labelConfirm: 'Sim',
|
|
148
|
+
btnConfirmDanger: false
|
|
149
|
+
};
|
|
150
|
+
ApplicationUtils.defaultModalProps = {
|
|
151
|
+
content: null,
|
|
152
|
+
position: 'right',
|
|
153
|
+
size: 'small',
|
|
154
|
+
heightMode: 'regular',
|
|
155
|
+
closeOutsideClick: true,
|
|
156
|
+
closeEsc: true
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export { ApplicationUtils as A };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-6fbf1820.js';
|
|
2
2
|
import { FloatingManager, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
-
import './ApplicationUtils-
|
|
3
|
+
import './ApplicationUtils-19857f60.js';
|
|
4
4
|
import { C as CSSVarsUtils } from './CSSVarsUtils-00f67f32.js';
|
|
5
5
|
import './DialogType-54a62731.js';
|
|
6
6
|
import './CheckMode-bdb2ec19.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-6fbf1820.js';
|
|
2
2
|
import { ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
-
import { A as ApplicationUtils } from './ApplicationUtils-
|
|
3
|
+
import { A as ApplicationUtils } from './ApplicationUtils-19857f60.js';
|
|
4
4
|
import './DialogType-54a62731.js';
|
|
5
5
|
import './CheckMode-bdb2ec19.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-6fbf1820.js';
|
|
2
2
|
import { ObjectUtils, FloatingManager, StringUtils, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
-
import { A as ApplicationUtils } from './ApplicationUtils-
|
|
3
|
+
import { A as ApplicationUtils } from './ApplicationUtils-19857f60.js';
|
|
4
4
|
import { C as CSSVarsUtils } from './CSSVarsUtils-00f67f32.js';
|
|
5
5
|
import './DialogType-54a62731.js';
|
|
6
6
|
import './CheckMode-bdb2ec19.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, f as forceUpdate, H as Host, g as getElement } from './index-6fbf1820.js';
|
|
2
2
|
import { UserInterface, DateUtils, Action, WaitingChangeException, ApplicationContext, DataUnitAction, StringUtils, DataUnit, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
-
import { A as ApplicationUtils } from './ApplicationUtils-
|
|
3
|
+
import { A as ApplicationUtils } from './ApplicationUtils-19857f60.js';
|
|
4
4
|
import './DialogType-54a62731.js';
|
|
5
5
|
|
|
6
6
|
const DETAIL_PATTERN = /child\[([^\]]+)\]/;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-6fbf1820.js';
|
|
2
2
|
import { ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
-
import { A as ApplicationUtils } from './ApplicationUtils-
|
|
3
|
+
import { A as ApplicationUtils } from './ApplicationUtils-19857f60.js';
|
|
4
4
|
import './DialogType-54a62731.js';
|
|
5
5
|
import './CheckMode-bdb2ec19.js';
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, f as forceUpdate, h, g as getElement } from './index-6fbf1820.js';
|
|
2
|
-
import { A as ApplicationUtils } from './ApplicationUtils-
|
|
2
|
+
import { A as ApplicationUtils } from './ApplicationUtils-19857f60.js';
|
|
3
3
|
import { ElementIDUtils } from '@sankhyalabs/core';
|
|
4
4
|
import './DialogType-54a62731.js';
|
|
5
5
|
|
package/dist/ezui/ezui.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as o}from"./p-bfc7b8ca.js";export{s as setNonce}from"./p-bfc7b8ca.js";(()=>{const o=import.meta.url,t={};return""!==o&&(t.resourcesUrl=new URL(".",o).href),e(t)})().then((e=>o([["p-2756003d",[[1,"ez-guide-navigator",{open:[1540],selectedId:[1537,"selected-id"],items:[16],tooltipResolver:[16],filterText:[32],disableItem:[64],enableItem:[64],updateItem:[64],getItem:[64],getCurrentPath:[64],selectGuide:[64],getParent:[64]}]]],["p-
|
|
1
|
+
import{p as e,b as o}from"./p-bfc7b8ca.js";export{s as setNonce}from"./p-bfc7b8ca.js";(()=>{const o=import.meta.url,t={};return""!==o&&(t.resourcesUrl=new URL(".",o).href),e(t)})().then((e=>o([["p-2756003d",[[1,"ez-guide-navigator",{open:[1540],selectedId:[1537,"selected-id"],items:[16],tooltipResolver:[16],filterText:[32],disableItem:[64],enableItem:[64],updateItem:[64],getItem:[64],getCurrentPath:[64],selectGuide:[64],getParent:[64]}]]],["p-370ad5c9",[[1,"ez-actions-button",{enabled:[516],actions:[1040],size:[513],showLabel:[516,"show-label"],displayIcon:[513,"display-icon"],checkOption:[516,"check-option"],value:[513],isTransparent:[516,"is-transparent"],arrowActive:[516,"arrow-active"],_selectedAction:[32],hideActions:[64],isOpened:[64]}]]],["p-b01e05a1",[[1,"ez-breadcrumb",{items:[1040],fillMode:[1025,"fill-mode"],maxItems:[1026,"max-items"],positionEllipsis:[1026,"position-ellipsis"],visibleItems:[32],hiddenItems:[32],showDropdown:[32],collapseConfigPosition:[32]}]]],["p-fc2faf3a",[[1,"ez-dialog",{confirm:[1028],dialogType:[1025,"dialog-type"],message:[1025],opened:[1540],personalizedIconPath:[1025,"personalized-icon-path"],ezTitle:[1025,"ez-title"],beforeClose:[1040],show:[64]}]]],["p-3a41181c",[[6,"ez-grid",{multipleSelection:[4,"multiple-selection"],config:[1040],serverUrl:[1,"server-url"],dataUnit:[16],statusResolver:[16],_paginationInfo:[32],_paginationChangedByKeyboard:[32],_showSelectionCounter:[32],_isAllSelection:[32],_currentPageSelected:[32],_selectionCount:[32],setColumnsDef:[64],addColumnMenuItem:[64],setColumnsState:[64],setData:[64],getSelection:[64],getColumnsState:[64],getColumns:[64],quickFilter:[64]},[[0,"ezSelectionChange","onSelectionChange"]]]]],["p-f71f0aa2",[[6,"ez-modal-container",{modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],showTitleBar:[4,"show-title-bar"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],cancelButtonStatus:[1,"cancel-button-status"],okButtonStatus:[1,"ok-button-status"]}]]],["p-997b2df9",[[1,"ez-alert",{alertType:[513,"alert-type"]}]]],["p-6adf3791",[[1,"ez-badge",{size:[513],label:[513],iconLeft:[513,"icon-left"],iconRight:[513,"icon-right"],position:[1040],hasSlot:[32]}]]],["p-d892dc4f",[[1,"ez-chip",{label:[513],enabled:[516],removePosition:[513,"remove-position"],mode:[513],value:[1540],setFocus:[64],setBlur:[64]}]]],["p-2f80d68c",[[1,"ez-file-item",{canRemove:[4,"can-remove"],fileName:[1,"file-name"],iconName:[1,"icon-name"],fileSize:[2,"file-size"],progress:[2]}]]],["p-11431283",[[1,"ez-list",{dataSource:[1040],listMode:[1,"list-mode"],useGroups:[1540,"use-groups"],ezDraggable:[1028,"ez-draggable"],ezSelectable:[1028,"ez-selectable"],itemSlotBuilder:[1040],hoverFeedback:[1028,"hover-feedback"],_listItems:[32],_listGroupItems:[32],clearHistory:[64],scrollToTop:[64],setSelection:[64],getSelection:[64],getList:[64]}]]],["p-e8e7ec07",[[0,"ez-application"]]],["p-848bc350",[[1,"ez-card-item",{item:[16]}]]],["p-1ac06223",[[1,"ez-loading-bar",{_showLoading:[32],hide:[64],show:[64]}]]],["p-bef2df29",[[1,"ez-modal",{modalSize:[1,"modal-size"],align:[1],heightMode:[1,"height-mode"],opened:[1028],closeEsc:[4,"close-esc"],closeOutsideClick:[4,"close-outside-click"]}]]],["p-19995acb",[[1,"ez-popover",{autoClose:[516,"auto-close"],top:[1537],left:[1537],bottom:[1537],right:[1537],boxWidth:[513,"box-width"],opened:[1540],innerElement:[1537,"inner-element"],overlayType:[513,"overlay-type"],updatePosition:[64],show:[64],hide:[64]}]]],["p-82a60d38",[[1,"ez-popup",{size:[1],opened:[1540],useHeader:[516,"use-header"],heightMode:[513,"height-mode"],ezTitle:[1,"ez-title"]}]]],["p-6e453307",[[1,"ez-radio-button",{value:[1544],options:[1040],enabled:[516],label:[513],direction:[1537]}]]],["p-672c1fba",[[0,"ez-skeleton",{count:[2],variant:[1],width:[1],height:[1],marginBottom:[1,"margin-bottom"],animation:[1]}]]],["p-0c2187a1",[[1,"ez-toast",{message:[1025],fadeTime:[1026,"fade-time"],useIcon:[1028,"use-icon"],canClose:[1028,"can-close"],show:[64]}]]],["p-a279fbc2",[[0,"ez-view-stack",{show:[64],getSelectedIndex:[64]}]]],["p-41e82662",[[1,"ez-dropdown",{items:[1040],value:[1040],itemBuilder:[16]}]]],["p-fc71f135",[[1,"ez-tabselector",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32]}]]],["p-c00e734a",[[1,"ez-text-input",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],mask:[1],canShowError:[516,"can-show-error"],restrict:[1],mode:[513],noBorder:[516,"no-border"],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-805ee4c2",[[1,"ez-collapsible-box",{value:[1540],label:[513],subtitle:[513],headerSize:[513,"header-size"],iconPlacement:[513,"icon-placement"],headerAlign:[513,"header-align"],removable:[516],editable:[516],conditionalSave:[16],_activeEditText:[32],showHide:[64],applyFocusTextEdit:[64],cancelEdition:[64]}]]],["p-5d8d9a2e",[[1,"ez-search",{value:[1537],label:[1537],enabled:[1540],errorMessage:[1537,"error-message"],optionLoader:[16],showSelectedValue:[4,"show-selected-value"],showOptionValue:[4,"show-option-value"],suppressEmptyOption:[4,"suppress-empty-option"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-15e29287",[[1,"ez-date-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-751aa882",[[1,"ez-date-time-input",{label:[513],value:[1040],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-ff4141d8",[[1,"ez-time-input",{label:[513],value:[1026],enabled:[516],errorMessage:[1537,"error-message"],showSeconds:[516,"show-seconds"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-a9f0f910",[[1,"ez-number-input",{label:[1],value:[1538],enabled:[4],errorMessage:[1537,"error-message"],precision:[2],prettyPrecision:[2,"pretty-precision"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-6f11ddf8",[[1,"ez-text-area",{label:[513],value:[1537],enabled:[516],errorMessage:[1537,"error-message"],rows:[1538],canShowError:[516,"can-show-error"],mode:[513],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-60e30f92",[[1,"ez-upload",{label:[1],subtitle:[1],enabled:[4],maxFileSize:[2,"max-file-size"],maxFiles:[2,"max-files"],requestHeaders:[8,"request-headers"],urlUpload:[1,"url-upload"],urlDelete:[1,"url-delete"],value:[1040],addFiles:[64],setFocus:[64],setBlur:[64]}]]],["p-22b106d7",[[1,"ez-text-edit",{value:[1],styled:[16],_newValue:[32],applyFocusSelect:[64]}]]],["p-709067e4",[[1,"ez-combo-box",{value:[1537],label:[513],enabled:[516],options:[1040],errorMessage:[1537,"error-message"],searchMode:[4,"search-mode"],showSelectedValue:[4,"show-selected-value"],showOptionValue:[4,"show-option-value"],suppressSearch:[4,"suppress-search"],optionLoader:[16],suppressEmptyOption:[4,"suppress-empty-option"],canShowError:[516,"can-show-error"],mode:[513],_preSelection:[32],_visibleOptions:[32],_startLoading:[32],_showLoading:[32],_criteria:[32],setFocus:[64],setBlur:[64],isInvalid:[64]}]]],["p-c99bca75",[[1,"ez-check",{label:[513],value:[1540],enabled:[1540],indeterminate:[1540],mode:[513],getMode:[64],setFocus:[64]}]]],["p-55cd357c",[[2,"ez-form-view",{fields:[16],showUp:[64]}]]],["p-4ebb1d15",[[1,"ez-filter-input",{label:[1],value:[1537],enabled:[4],errorMessage:[1537,"error-message"],restrict:[1],mode:[513],asyncSearch:[516,"async-search"],canShowError:[516,"can-show-error"],setFocus:[64],setBlur:[64],isInvalid:[64],setValue:[64],endSearch:[64]}],[1,"ez-tree",{items:[1040],value:[1040],selectedId:[1537,"selected-id"],iconResolver:[16],tooltipResolver:[16],_tree:[32],_waintingForLoad:[32],selectItem:[64],openItem:[64],disableItem:[64],enableItem:[64],addChild:[64],applyFilter:[64],updateItem:[64],getItem:[64],getCurrentPath:[64],getParent:[64]},[[2,"keydown","onKeyDownListener"]]],[1,"ez-scroller",{direction:[1],locked:[4],activeShadow:[4,"active-shadow"],isActive:[32]},[[2,"click","clickListener"],[1,"mousedown","mouseDownHandler"],[1,"mouseup","mouseUpHandler"],[1,"mousemove","mouseMoveHandler"]]],[1,"ez-sidebar-button"]]],["p-994c4934",[[1,"ez-calendar",{value:[1040],floating:[516],time:[516],showSeconds:[516,"show-seconds"],show:[64],fitVertical:[64],hide:[64]}]]],["p-1a902d0e",[[1,"ez-icon",{size:[513],href:[513],iconName:[513,"icon-name"]}]]],["p-9a9cca48",[[1,"ez-button",{label:[513],enabled:[516],mode:[513],image:[513],iconName:[513,"icon-name"],size:[513],setFocus:[64],setBlur:[64]},[[2,"click","clickListener"]]]]],["p-ea5a5236",[[2,"ez-form",{dataUnit:[1040],config:[16],recordsValidator:[16],validate:[64]}]]]],e)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as s,H as e,g as n}from"./p-bfc7b8ca.js";import{ElementIDUtils as o}from"@sankhyalabs/core";import{A as l}from"./p-
|
|
1
|
+
import{r as t,c as i,h as s,H as e,g as n}from"./p-bfc7b8ca.js";import{ElementIDUtils as o}from"@sankhyalabs/core";import{A as l}from"./p-41ce6f98.js";import"./p-ab574d59.js";import"./p-b853763b.js";const h=class{constructor(s){t(this,s),this.saveEdition=i(this,"saveEdition",7),this.cancelEdition=i(this,"cancelEdition",7),this._newValue=void 0,this.value=void 0,this.styled=void 0}async applyFocusSelect(){this.calcSizeInput(this.value,!0)}calcSizeInput(t,i=!1){var s,e;const n=null===(e=null===(s=this._inputElement)||void 0===s?void 0:s.shadowRoot)||void 0===e?void 0:e.querySelector("input");if(null!=n){const s=this.getWidthValue(t);n.style.width=s+"px",i&&setTimeout((()=>n.select()),100)}}getWidthValue(t){if(null!=this._valueBasis){const i=this._valueBasis;if(null!=t){const s=2;return i.innerHTML=t,i.clientWidth>0?i.clientWidth+s:s}i.innerHTML=""}return 0}setStyledInput(){var t,i;let s="",e="",n="";null!=this.styled&&(s=this.styled.fontSize,e=this.styled.fontWeight,n=this.styled.fontFamily);const o=null===(i=null===(t=this._inputElement)||void 0===t?void 0:t.shadowRoot)||void 0===i?void 0:i.querySelector("input");null!=o&&(o.style.fontSize=s,o.style.fontWeight=e,o.style.fontFamily=n);const l=this._valueBasis;null!=l&&(l.style.fontSize=s,l.style.fontWeight=e,l.style.fontFamily=n)}handleSaveEdition(){this._newValue?this.saveEdition.emit({value:this.value,newValue:this._newValue}):l.alert("Aviso","Não é possível salvar um campo em branco.").then((()=>{this.setNewValue(this.value,!0)}))}handleCancelEdition(){this.cancelEdition.emit()}setNewValue(t,i=!1){this._newValue=t,this.calcSizeInput(this._newValue,i)}componentDidLoad(){this.applyFocusSelect(),this.setNewValue(this.value)}componentDidRender(){this.setStyledInput()}render(){return o.addIDInfoIfNotExists(this._element,"input"),s(e,null,s("span",{class:"text-edit__hidden-value",ref:t=>this._valueBasis=t}),s("ez-text-input",{"data-element-id":o.getInternalIDInfo("textInput"),onInput:()=>{this.calcSizeInput(this._newValue)},class:"text-edit__form-input",value:this._newValue,ref:t=>this._inputElement=t,mode:"slim",onEzChange:t=>this.setNewValue(null==t?void 0:t.detail),noBorder:!0}),s("ez-button",{class:"text-edit__icon-check",mode:"icon",iconName:"check",size:"small",onClick:()=>{this.handleSaveEdition()}}),s("ez-button",{class:"text-edit__icon-close",mode:"icon",iconName:"close",size:"small",onClick:()=>{this.handleCancelEdition()}}))}get _element(){return n(this)}};h.style=":host{display:flex;align-items:center;gap:5px}.text-edit__form-input{width:auto;--ez-text-input__input--padding:0px}.text-edit__hidden-value{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}";export{h as ez_text_edit}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as i,h as o,H as n,g as s}from"./p-bfc7b8ca.js";import{FloatingManager as a,ElementIDUtils as e}from"@sankhyalabs/core";import"./p-
|
|
1
|
+
import{r as t,c as i,h as o,H as n,g as s}from"./p-bfc7b8ca.js";import{FloatingManager as a,ElementIDUtils as e}from"@sankhyalabs/core";import"./p-41ce6f98.js";import{C as c}from"./p-4a5e37a7.js";import"./p-ab574d59.js";import"./p-b853763b.js";const r=class{constructor(o){t(this,o),this.ezAction=i(this,"ezAction",7),this._arrowOffset=5,this.innerClickCheck=(t,i)=>{var o;if(i&&t){if(i===t)return!0;const n=t.children;for(let t=0;t<n.length;t++)if(null===(o=n[t].shadowRoot)||void 0===o?void 0:o.contains(i))return!0}return!1},this._selectedAction=void 0,this.enabled=!0,this.actions=void 0,this.size="medium",this.showLabel=!1,this.displayIcon=void 0,this.checkOption=!1,this.value=void 0,this.isTransparent=!1,this.arrowActive=!1}async hideActions(){null!=this._floatingID&&a.close(this._floatingID),this._floatingID=void 0}async isOpened(){return null!=this._floatingID}getFloatOptions(){return{autoClose:!0,innerClickTest:this.innerClickCheck,isFixed:!0,top:this.getPositionTop(),left:this.getPositionLeft()}}getSideLimit(){var t;const i=document.body.clientWidth,o=null===(t=this._actionsList)||void 0===t?void 0:t.getBoundingClientRect();if((null==o?void 0:o.right)>i)return i-o.width+"px"}showActions(){if(!this.enabled)return;const t=this.getFloatOptions();this._floatingID=a.float(this._actionsList,this._listContainer,t);const i=this.getSideLimit();null!=i&&(t.left=i,a.updateFloatPosition(this._actionsList,this._listContainer,t)),window.requestAnimationFrame((()=>{this._actionsList.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}))}updatePosition(){if(!this.enabled||null==this._floatingID)return;const t=this.getFloatOptions(),i=this.getSideLimit();null!=i&&(t.left=i),a.updateFloatPosition(this._actionsList,this._listContainer,t)}getPositionTop(){var t;const i=null===(t=this._element)||void 0===t?void 0:t.getBoundingClientRect();return null==i?null:i.y+i.height+"px"}getBoundingLeft(){var t;const i=null===(t=this._element)||void 0===t?void 0:t.getBoundingClientRect();return null==i?null:i.x-(this.arrowActive?this._arrowOffset:0)+"px"}getPositionLeft(){return this.getBoundingLeft()||(this.arrowActive?`-${this._arrowOffset}px`:null)}hasLabelOrCheckOption(){var t;return(this.showLabel||this.checkOption)&&(null===(t=this.actions)||void 0===t?void 0:t.length)>0}hasIconName(){var t;return null===(t=this.actions)||void 0===t?void 0:t.some((t=>null!=t.iconName))}controlScrollPage(){window.removeEventListener("scroll",this.updatePosition.bind(this)),window.addEventListener("scroll",this.updatePosition.bind(this))}handlerButtonClick(){this.showActions()}actionClick(t){this._selectedAction=t,this.hideActions(),this.ezAction.emit(t)}componentWillLoad(){if(null==this.actions){this.actions=[];const t=this._element.querySelectorAll("action");t&&t.forEach((t=>{let i=t.innerText,o=t.getAttribute("value"),n=!("false"===t.getAttribute("enabled"));o||(o=i),this.actions.push({label:i,value:o,enabled:n}),t.hidden=!0}))}}componentDidLoad(){c.applyVarsButton(this._element,this._button),e.addIDInfo(this._element),this.controlScrollPage()}componentDidRender(){null==this._floatingID&&this._actionsList.remove(),this.hasLabelOrCheckOption()&&(this.value?this._selectedAction=this.actions.find((t=>t.value===this.value)):this._selectedAction||(this._selectedAction=this.actions[0]))}render(){var t;return o(n,null,o("ez-button",{ref:t=>this._button=t,class:(this.isTransparent?"ez-actions-button__btn-transparent":"")+(this.showLabel?" ez-actions-button__btn-label":""),label:this.showLabel&&(null===(t=this._selectedAction)||void 0===t?void 0:t.label),enabled:this.enabled,mode:this.showLabel?void 0:"icon",iconName:this.showLabel?"":this.displayIcon||"dots-vertical",size:this.size,onClick:()=>this.handlerButtonClick()},this.showLabel&&o("ez-icon",{class:"ez-actions-button__icon-right",slot:"rightIcon",iconName:this.displayIcon||"dots-vertical"})),o("section",{class:"ez-actions-button__list-container",ref:t=>this._listContainer=t},this.arrowActive&&o("div",{class:"ez-actions-button__arrow ez-actions-button__arrow--"+(this.size||"small")+(this.isTransparent?" ez-actions-button__arrow--upped":"")}),o("div",{ref:t=>this._actionsList=t,class:"ez-actions-button__actions-list"+(this.arrowActive&&!this.isTransparent?" ez-actions-button__actions-list--lowered":"")},this.actions.map((t=>{var i;return o("ez-button",{size:"small",label:t.label,onClick:()=>this.actionClick(t),enabled:t.enabled,class:"ez-actions-button__btn-action"+(this.checkOption||this.hasIconName()?" ez-actions-button__btn-action--spaced":"")},this.checkOption&&(null===(i=this._selectedAction)||void 0===i?void 0:i.value)===t.value&&o("ez-icon",{class:"ez-actions-button__icon-check",slot:"leftIcon",size:"small",iconName:"check"}),!this.checkOption&&t.iconName&&o("ez-icon",{class:"ez-actions-button__icon-item",slot:"leftIcon",size:"small",iconName:t.iconName}))})))))}get _element(){return s(this)}};r.style=":host{--ez-actions-button__actions-list--border-radius:var(--border--radius-medium, 12px);--ez-actions-button__actions-list--box-shadow:var(--shadow, 0px 0px 16px 0px #000);--ez-actions-button__actions-list--background-color:var(--background--xlight, #fff);--ez-actions-button__actions-list--padding:var(--space--small, 6px);--ez-actions-button__actions-list--top-margin:var(--space-small, 6px);--ez-actions-button__btn-action--min-width:'auto';--ez-actions-button__btn-action--background-color:var(--background--xlight, #fff);display:flex;flex-direction:column;height:fit-content;user-select:none}.ez-actions-button__actions-list{display:flex;flex-direction:column;position:fixed;width:fit-content;height:fit-content;z-index:var(--more-visible, 2);padding:var(--ez-actions-button__actions-list--padding);margin-top:var(--ez-actions-button__actions-list--top-margin);background-color:var(--ez-actions-button__actions-list--background-color);border-radius:var(--ez-actions-button__actions-list--border-radius);box-shadow:var(--ez-actions-button__actions-list--box-shadow)}.ez-actions-button__actions-list--lowered{margin-top:calc(var(--ez-actions-button__actions-list--top-margin) + 6px)}.ez-actions-button__btn-action{--ez-button--justify-content:flex-start;--ez-button--width:100%;--ez-button--min-width:var(--ez-actions-button__btn-action--min-width);--ez-button--background-color:var(--ez-actions-button__btn-action--background-color);--ez-button--font-weight:var(--text-weight--medium, 400);--ez-button--padding-left:var(--space--medium, 12px);--ez-button--padding-right:var(--space--medium, 12px)}.ez-actions-button__btn-action--spaced{--ez-button--padding-left:calc(var(--space--medium, 12px) + 24px)}.ez-actions-button__icon-right{margin-left:var(--space--small, 6px)}.ez-actions-button__icon-check,.ez-actions-button__icon-item{position:absolute;left:var(--space--medium, 12px)}.ez-actions-button__icon-check{color:var(--ez-button--hover-color)}.ez-actions-button__arrow{position:absolute;border-left:10px solid transparent;border-right:10px solid transparent;width:0;height:0;z-index:calc(var(--more-visible, 2) + 1);border-bottom:15px solid var(--ez-actions-button__btn-action--background-color)}.ez-actions-button__arrow--upped{margin-top:calc((var(--ez-actions-button__actions-list--top-margin) + 2px) * -1)}.ez-actions-button__arrow--small{margin-left:6px}.ez-actions-button__arrow--medium{margin-left:11px}.ez-actions-button__arrow--large{margin-left:13px}.ez-actions-button__arrow:only-child{display:none}.ez-actions-button__btn-transparent{--ez-button--background-color:transparent;--ez-button--hover--background-color:transparent;--ez-button--active--background-color:transparent;--ez-button--focus--border:none}.ez-actions-button__btn-label{--ez-button--padding-left:var(--space--medium, 12px);--ez-button--padding-right:var(--space--medium, 12px)}.ez-actions-button__list-container{position:relative}";export{r as ez_actions_button}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{D as t}from"./p-ab574d59.js";let n;const e=new Uint8Array(16);function o(){if(!n&&(n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(e)}const c=[];for(let t=0;t<256;++t)c.push((t+256).toString(16).slice(1));const r={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function s(t,n,e){if(r.randomUUID&&!n&&!t)return r.randomUUID();const s=(t=t||{}).random||(t.rng||o)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,n){e=e||0;for(let t=0;t<16;++t)n[e+t]=s[t];return n}return function(t,n=0){return(c[t[n+0]]+c[t[n+1]]+c[t[n+2]]+c[t[n+3]]+"-"+c[t[n+4]]+c[t[n+5]]+"-"+c[t[n+6]]+c[t[n+7]]+"-"+c[t[n+8]]+c[t[n+9]]+"-"+c[t[n+10]]+c[t[n+11]]+c[t[n+12]]+c[t[n+13]]+c[t[n+14]]+c[t[n+15]]).toLowerCase()}(s)}class i{static async showDialog(n,e,o=null,c,r=t.DEFAULT,s){return s&&(s=Object.assign(Object.assign({},i.defaultMessageOptions),s)),new Promise((t=>{let i=document.querySelector("ez-dialog");i||(i=document.createElement("ez-dialog"),window.document.body.appendChild(i)),i.show(n,e,r,c,o,s.labelCancel,s.labelConfirm,s.btnConfirmDanger,s.beforeClose).then((n=>t(n)))}))}static async alert(n,e,o=null,c=i.defaultMessageOptions){return i.showDialog(n,e,o,!1,t.WARN,c)}static async error(n,e,o=null,c=i.defaultMessageOptions){return i.showDialog(n,e,o,!1,t.CRITICAL,c)}static async success(n,e,o=null,c=i.defaultMessageOptions){return i.showDialog(n,e,o,!1,t.SUCCESS,c)}static async confirm(n,e,o=null,c=t.WARN,r=i.defaultMessageOptions){return i.showDialog(n,e,o,!0,c,r)}static async message(n,e,o=null,c=i.defaultMessageOptions){return i.showDialog(n,e,o,!1,t.DEFAULT,c)}static async info(t,n=i.defaultMessageOptions){n!==i.defaultMessageOptions&&(n=Object.assign(Object.assign({},i.defaultMessageOptions),n));let e=!1,o=document.querySelector("ez-toast");if(!o){o=document.createElement("ez-toast");const t=document.createElement("ez-icon");t.className="ez-margin-right--small",t.slot="icon",t.style.setProperty("--ez-icon--color","var(--color--success)"),o.appendChild(t),window.document.body.appendChild(o)}if(n.iconName){const t=o.querySelector("ez-icon");t&&(t.iconName=n.iconName,e=!0)}else e=!1;o.show(t,5e3,e,n.canClose)}static async showModal(t){t=Object.assign(Object.assign({},i.defaultModalProps),t);const n=document.createElement("ez-modal");return window.document.body.appendChild(n),n.setAttribute("id",s()),n.modalSize=t.size,n.align=t.position,n.heightMode=t.heightMode,n.closeEsc=t.closeEsc,n.closeOutsideClick=t.closeOutsideClick,t.content instanceof String||"string"==typeof t.content?n.innerHTML=t.content:n.appendChild(t.content),n.opened=!0,()=>n.remove()}}i.defaultMessageOptions={canClose:!0,labelCancel:"Não",labelConfirm:"Sim",btnConfirmDanger:!1},i.defaultModalProps={content:null,position:"right",size:"small",heightMode:"regular",closeOutsideClick:!0,closeEsc:!0};export{i as A}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i,c as t,f as e,h as o,g as a}from"./p-bfc7b8ca.js";import{A as s}from"./p-ab2a3006.js";import{ElementIDUtils as d}from"@sankhyalabs/core";import"./p-ab574d59.js";class r{constructor(i){this.file=i,this.size=i.size,this.name=i.name}abortUpload(){this._uploadingXhr&&(this._aborted=!0,this._uploadingXhr.abort(),this._uploadingXhr=void 0)}isUploading(){return void 0!==this._uploadingXhr}async upload(i,t,e){return new Promise(((o,a)=>{const s=new XMLHttpRequest;this._uploadingXhr=s,this._aborted=!1,this.progress=0,s.upload.onprogress=i=>{const t=i.loaded,o=i.total;this.progress=~~(t/o*100),e(this,t,o)},s.onreadystatechange=()=>{if(4==s.readyState){this._uploadingXhr=void 0;const i=s.status;this._aborted||(0===i?a("Servidor indisponível"):i>=500?a("Erro inesperado no servidor"):i>=400&&a("Operação não permitida"));const t=s.response;if(t)try{o(JSON.parse(t))}catch(i){a(`Servidor não retornou um objeto válido: ${t}.\n${i}`)}}},s.ontimeout=()=>{a("Tempo limite de transferência atingido.")};const d=new FormData;d.append("ARQUIVO",this.file,this.file.name),s.open("POST",i,!0),t&&t.forEach(((i,t)=>s.setRequestHeader(t,i))),s.send(d)}))}async delete(i,t,e){return new Promise(((o,a)=>{const s=new XMLHttpRequest;s.onreadystatechange=()=>{4==s.readyState&&(0===s.status?a("Servidor indisponível"):s.status>=500?a("Erro inesperado no servidor"):s.status>=400&&a("Operação não permitida"),o(!0))},s.ontimeout=()=>{a("Tempo limite de remoção atingido.")},s.open("DELETE",t,!0),e&&e.forEach(((i,t)=>s.setRequestHeader(t,i))),s.send(JSON.stringify(i))}))}}const l=class{constructor(e){i(this,e),this.ezChange=t(this,"ezChange",7),this.ezStartChange=t(this,"ezStartChange",7),this.ezCancelWaitingChange=t(this,"ezCancelWaitingChange",7),this._filePointers=new Map,this.label=void 0,this.subtitle=void 0,this.enabled=!0,this.maxFileSize=void 0,this.maxFiles=void 0,this.requestHeaders=void 0,this.urlUpload=void 0,this.urlDelete=void 0,this.value=void 0}observeValue(i,t){(i!==this._updatingValue||null==i&&null!=t)&&(this._filePointers.forEach((i=>{this.isRemoteFile(i)&&i.abortUpload()})),this._filePointers=new Map,this.updateFilePointers(),this._updatingValue=void 0)}updateFilePointers(){this.value&&this.value.forEach((i=>this._filePointers.set(i.name,i)))}observeRequestHeaders(){if(this._requestHeaders=new Map,"string"==typeof this.requestHeaders)try{this.requestHeaders=JSON.parse(this.requestHeaders)}catch(i){this.requestHeaders=void 0}for(var i in this.requestHeaders)this._requestHeaders.set(i,this.requestHeaders[i])}async addFiles(i){if(this.maxFiles>0){let t=this._filePointers.size;if(i.forEach((i=>{this._filePointers.has(i.name)||t++})),t>this.maxFiles)return void this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`)}Array.prototype.forEach.call(i,this.addFile.bind(this))}async setFocus(){this._fileInput.focus()}async setBlur(){this._fileInput.blur()}async addFile(i){const t=this._filePointers.get(i.name);t?s.confirm("Substituir arquivo",`Já existe um arquivo chamado "${i.name}". Deseja substituí-lo?`).then((e=>{e&&(this.isRemoteFile(t)&&t.abortUpload(),this.doAddFile(i))})):this.doAddFile(i)}async doAddFile(i){try{if(this.validateFile(i)){this.ezStartChange.emit({waitmessage:"Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio.",blocking:!0});const t=new r(i),o=this._filePointers.get(i.name);o&&this.isRemoteFile(o)&&o.abortUpload(),this._filePointers.set(i.name,t),t.upload(this.urlUpload,this._requestHeaders,(i=>this.updateFeedback(i))).then((i=>i.forEach((i=>this.finishUpload(t.name,i))))).catch((i=>{this.ezCancelWaitingChange.emit(),this.showError(i)})),e(this)}}catch(i){throw this.ezCancelWaitingChange.emit(),i}}finishUpload(i,t){this._filePointers.set(i,t),this.updateValue()}updateValue(){this._updatingValue=[],this._filePointers.forEach((i=>{this.isRemoteFile(i)||this._updatingValue.push(i)})),this._filePointers.size===this._updatingValue.length&&(this.value=this._updatingValue,this.ezChange.emit(this.value))}buildProgressId(i){return`PROGRESS_${i.name.replace(/[^a-z0-9_]/gi,"_")}_${i.file.lastModified}`}updateFeedback(i){window.requestAnimationFrame((()=>{if(this._host){const t=this._host.shadowRoot.querySelector("#"+this.buildProgressId(i));t&&(t.value=i.progress)}}))}validateFile(i){return!this._filePointers.has(i.name)&&this.maxFiles>0&&this._filePointers.size>=this.maxFiles?(this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`),!1):0===i.size?(this.showError(`Erro de permissão: O arquivo "${i.name}" não pode ser enviado.`),!1):this.urlUpload?!(this.maxFileSize>=0&&i.size>this.maxFileSize&&(this.showError("O tamanho máximo dos arquivos é de "+this.formatBytes(this.maxFileSize)),1)):(this.showError("Endereço de upload não informado"),!1)}showError(i){s.alert("Enviando arquivo",i)}formatBytes(i,t=1){if(0===i)return"0 Bytes";const e=t<0?0:t,o=Math.floor(Math.log(i)/Math.log(1024));return parseFloat((i/Math.pow(1024,o)).toFixed(e))+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][o]}onFileInputChange(i){this.addFiles(Array.from(i.target.files)),this._fileInput.value=""}isRemoteFile(i){return"file"in i}removeFromList(i){this._filePointers.delete(i),this.updateValue()}removeFile(i){const t=this._filePointers.get(i);if(this.isRemoteFile(t))t.abortUpload(),this.removeFromList(i);else if(this.urlDelete){const e=new r(null);this._filePointers.set(t.name,e),e.delete(t,this.urlDelete,null).then((()=>this.removeFromList(i))).catch((i=>this.showError(i)))}else this.removeFromList(i)}openFilesDialog(){this.enabled&&this._fileInput.click()}componentDidLoad(){this.enabled&&this._dropZone&&window.FileList&&window.File&&(this._dropZone.addEventListener("dragover",(i=>{i.stopPropagation(),i.preventDefault(),i.dataTransfer.dropEffect="copy",this._dropZone.style.background="#c2dbff"})),this._dropZone.addEventListener("drop",(i=>{i.stopPropagation(),i.preventDefault(),this.addFiles(Array.from(i.dataTransfer.files)),this._dropZone.style.background=""})),this._dropZone.addEventListener("dragleave",(()=>{this._dropZone.style.background=""}))),this._host&&d.addIDInfo(this._host,"input")}componentWillRender(){this.value&&this._filePointers.size<this.value.length&&this.updateFilePointers()}render(){return o("div",{ref:i=>this._dropZone=i,class:this.evalDisabledClass("iu","background--disabled")},o("div",{class:"iu__container",onClick:()=>this.openFilesDialog()},o("div",{class:"iu_header"},this.label?o("label",{class:this.evalDisabledClass("iu__label","text--disabled"),title:this.label},this.label):null,o("div",{class:"padding-large"},o("div",{class:this.evalDisabledClass("iu__icon-label","mouse-pointer--disabled")},o("button",{class:"iu__file-icon",disabled:!this.enabled}),o("div",{class:this.evalDisabledClass("text text--center text--medium text--primary","text--disabled")},this.enabled?"Arraste e solte ou clique para adicionar arquivos":"Somente leitura")),this.subtitle&&o("div",{class:this.evalDisabledClass("padding-extra-small text text--center text--small text--secondary","text--disabled")},this.subtitle))),this.buildFooter()),o("input",{ref:i=>this._fileInput=i,onChange:i=>this.onFileInputChange(i),type:"file",multiple:!0,class:"appearanceNone"}))}buildFooter(){if(0===this._filePointers.size)return null;const i=[];return this._filePointers.forEach((t=>i.push(this.buildFileItem(t)))),o("div",{class:"iu__footer"},i)}buildFileItem(i){const t=i.name,e=Number(i.progress),a=i.downloadURL,s=`${t} (${this.formatBytes(i.size)})`;return o("div",{class:"iu__item",key:t,onClick:i=>i.stopPropagation()},o("div",{class:"iu__item-label modificador"},o("div",{title:s,class:"col--stretch align--middle file__name text text--primary text--small text--ellipsis align--middle"},a?o("a",{href:a,download:!0},s):s)),isNaN(e)?null:o("div",{class:"col col--sd-4 col--stretch align--middle"},o("progress",{id:this.buildProgressId(i),value:e,max:"100"})),this.enabled?o("div",{class:"col col--stretch align--middle"},o("button",{class:"btn-cancel ",onClick:()=>this.removeFile(t)})):null)}evalDisabledClass(i,t){return this.enabled?i:`${i} ${t}`}get _host(){return a(this)}static get watchers(){return{value:["observeValue"],requestHeaders:["observeRequestHeaders"]}}};l.style=':host{--ez-upload--height:42px;--ez-upload--width:100%;--ez-upload__icon--width:48px;--ez-upload__container--background-color:var(--background--medium, #d2dce9);--ez-upload__color--primary:var(--color--primary, #008561);--ez-upload--padding--extra-small:var(--space--extra-small, 3px);--ez-upload--padding--small:var(--space--small, 6px);--ez-upload--padding--medium:var(--space--medium, 12px);--ez-upload--padding--large:var(--space--large, 24px);--ez-upload__border--color:var(--color-strokes, #DCE0E8);--ez-upload--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--ez-upload--text--primary:var(--text-primary, #626e82);--ez-upload--text--secondary:var(--text-secondary, #a2abb9);--ez-upload--font-size:var(--text--medium, 14px);--ez-upload--font-family:var(--font-pattern, Arial);--ez-upload--font-weight:var(--text-weight--large, 500);--ez-upload__btn__cancel-image:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="8x" width="8px"><path d="M 8,0.8 7.2,0 4,3.2 0.8,0 0,0.8 3.2,4 0,7.2 0.8,8 4,4.8 7.2,8 8,7.2 4.8,4 Z"/></svg>\');--ez-upload__file-icon-image:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="11x" width="9px"><path d="M 1.2272719,8.4999999 V 2.75 c 0,-1.1045695 1.4652499,-2 3.2727273,-2 1.8074777,0 3.2727281,0.8954305 3.2727281,2 V 8.9999999 C 7.7727273,9.690356 6.8569456,10.25 5.7272719,10.25 4.5975985,10.25 3.6818174,9.690356 3.6818174,8.9999999 V 3.75 c 0,-0.2761425 0.3663125,-0.5 0.8181818,-0.5 0.4518694,0 0.8181818,0.2238575 0.8181818,0.5 V 8.4999999 H 6.5454537 V 3.75 C 6.5454537,3.059644 5.6296725,2.5 4.4999992,2.5 3.3703258,2.5 2.4545446,3.059644 2.4545446,3.75 V 8.9999999 C 2.4545446,10.10457 3.9197945,11 5.7272719,11 7.5347496,11 9,10.10457 9,8.9999999 V 2.75 C 9,1.231217 6.9852809,0 4.4999992,0 2.0147181,5e-7 0,1.231217 0,2.75 v 5.7499999 z"/></svg>\');display:flex;flex-wrap:wrap;position:relative;padding-bottom:16px;font-family:var(--ez-upload--font-family);font-size:var(--ez-upload--font-size);width:var(--ez-upload--width);font-weight:var(--ez-upload--font-weight)}.iu{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:var(--ez-upload--padding--small);width:100%;border-radius:12px;box-sizing:border-box}.iu__container{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;border:2px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.iu__footer{display:flex;flex-wrap:wrap;justify-content:flex-start;width:100%;padding:0 var(--ez-upload--padding--medium) var(--ez-upload--padding--medium) var(--ez-upload--padding--medium);box-sizing:border-box}.iu__item{display:flex;width:100%;justify-content:flex-start;align-items:center;align-self:center;padding-bottom:var(--ez-upload--padding--extra-small);box-sizing:border-box;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.iu__item-label{display:flex;max-width:80%;align-self:stretch;align-items:center}.file__name{font-weight:200}.box__content{width:100%;justify-content:center;align-items:center;height:100%;border:1px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.box__container{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:6px;width:100%;border-radius:12px}a:-webkit-any-link{color:#008561;fill:#008561;cursor:pointer;text-decoration:none}progress[value]{display:flex;width:100%;appearance:none;border:1px solid var(--ez-upload__border--color);height:12px;justify-content:flex-start;align-items:center;border-radius:3px;position:relative}progress[value]::-webkit-progress-bar{display:flex;-webkit-appearance:none;width:100%;background-color:rgb(255, 255, 255);border-radius:2px;padding:2px}progress[value]::-webkit-progress-value{display:flex;width:100%;background-color:var(--ez-upload__color--primary)}.text--center{text-align:center}.align--middle{align-self:center;align-items:center}.padding-large{padding:var(--ez-upload--padding--large) 0px}.padding-extra-small{padding:var(--ez-upload--padding--extra-small) 0px}.text{font-family:var(--font-pattern, "Roboto");text-shadow:0 0 0 #353535, 0 0 1px transparent}.text--primary{color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.text--secondary{color:var(--ez-upload--text--secondary);text-shadow:var(--ez-upload--text-shadow)}.text--ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.text--medium{font-size:14px}.text--small{font-size:12px}.btn-cancel{outline:none;border:none;background-color:unset;cursor:pointer}.btn-cancel::after{content:\'\';display:flex;background-color:var(--text--primary, #008561);width:8px;height:8px;-webkit-mask-image:var(--ez-upload__btn__cancel-image);mask-image:var(--ez-upload__btn__cancel-image)}.iu_header{display:flex;flex-direction:column;width:100%}.iu__label{padding:var(--space--small);box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-upload--font-family);font-size:var(--text--extra-small);font-weight:var(--ez-upload--font-weight);color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.iu__file-icon{outline:none;border:none;background-color:unset;cursor:pointer}.iu__file-icon:disabled{cursor:unset}.iu__file-icon::after{content:\'\';display:flex;background-color:var(--text--primary, #626e82);width:9px;height:11px;-webkit-mask-image:var(--ez-upload__file-icon-image);mask-image:var(--ez-upload__file-icon-image)}.iu__file-icon:disabled::after{background-color:var(--text--disable, #AFB6C0)}.iu__icon-label{justify-content:center;display:flex;cursor:pointer;box-sizing:border-box}.background--disabled{background-color:var(--color--disable-secondary, #F2F5F8)}.text--disabled{color:var(--text--disable, #AFB6C0)}.mouse-pointer--disabled{cursor:unset}.appearanceNone{width:0px;height:0px}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}';export{l as ez_upload}
|
|
1
|
+
import{r as i,c as t,f as e,h as o,g as a}from"./p-bfc7b8ca.js";import{A as s}from"./p-41ce6f98.js";import{ElementIDUtils as d}from"@sankhyalabs/core";import"./p-ab574d59.js";class r{constructor(i){this.file=i,this.size=i.size,this.name=i.name}abortUpload(){this._uploadingXhr&&(this._aborted=!0,this._uploadingXhr.abort(),this._uploadingXhr=void 0)}isUploading(){return void 0!==this._uploadingXhr}async upload(i,t,e){return new Promise(((o,a)=>{const s=new XMLHttpRequest;this._uploadingXhr=s,this._aborted=!1,this.progress=0,s.upload.onprogress=i=>{const t=i.loaded,o=i.total;this.progress=~~(t/o*100),e(this,t,o)},s.onreadystatechange=()=>{if(4==s.readyState){this._uploadingXhr=void 0;const i=s.status;this._aborted||(0===i?a("Servidor indisponível"):i>=500?a("Erro inesperado no servidor"):i>=400&&a("Operação não permitida"));const t=s.response;if(t)try{o(JSON.parse(t))}catch(i){a(`Servidor não retornou um objeto válido: ${t}.\n${i}`)}}},s.ontimeout=()=>{a("Tempo limite de transferência atingido.")};const d=new FormData;d.append("ARQUIVO",this.file,this.file.name),s.open("POST",i,!0),t&&t.forEach(((i,t)=>s.setRequestHeader(t,i))),s.send(d)}))}async delete(i,t,e){return new Promise(((o,a)=>{const s=new XMLHttpRequest;s.onreadystatechange=()=>{4==s.readyState&&(0===s.status?a("Servidor indisponível"):s.status>=500?a("Erro inesperado no servidor"):s.status>=400&&a("Operação não permitida"),o(!0))},s.ontimeout=()=>{a("Tempo limite de remoção atingido.")},s.open("DELETE",t,!0),e&&e.forEach(((i,t)=>s.setRequestHeader(t,i))),s.send(JSON.stringify(i))}))}}const l=class{constructor(e){i(this,e),this.ezChange=t(this,"ezChange",7),this.ezStartChange=t(this,"ezStartChange",7),this.ezCancelWaitingChange=t(this,"ezCancelWaitingChange",7),this._filePointers=new Map,this.label=void 0,this.subtitle=void 0,this.enabled=!0,this.maxFileSize=void 0,this.maxFiles=void 0,this.requestHeaders=void 0,this.urlUpload=void 0,this.urlDelete=void 0,this.value=void 0}observeValue(i,t){(i!==this._updatingValue||null==i&&null!=t)&&(this._filePointers.forEach((i=>{this.isRemoteFile(i)&&i.abortUpload()})),this._filePointers=new Map,this.updateFilePointers(),this._updatingValue=void 0)}updateFilePointers(){this.value&&this.value.forEach((i=>this._filePointers.set(i.name,i)))}observeRequestHeaders(){if(this._requestHeaders=new Map,"string"==typeof this.requestHeaders)try{this.requestHeaders=JSON.parse(this.requestHeaders)}catch(i){this.requestHeaders=void 0}for(var i in this.requestHeaders)this._requestHeaders.set(i,this.requestHeaders[i])}async addFiles(i){if(this.maxFiles>0){let t=this._filePointers.size;if(i.forEach((i=>{this._filePointers.has(i.name)||t++})),t>this.maxFiles)return void this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`)}Array.prototype.forEach.call(i,this.addFile.bind(this))}async setFocus(){this._fileInput.focus()}async setBlur(){this._fileInput.blur()}async addFile(i){const t=this._filePointers.get(i.name);t?s.confirm("Substituir arquivo",`Já existe um arquivo chamado "${i.name}". Deseja substituí-lo?`).then((e=>{e&&(this.isRemoteFile(t)&&t.abortUpload(),this.doAddFile(i))})):this.doAddFile(i)}async doAddFile(i){try{if(this.validateFile(i)){this.ezStartChange.emit({waitmessage:"Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio.",blocking:!0});const t=new r(i),o=this._filePointers.get(i.name);o&&this.isRemoteFile(o)&&o.abortUpload(),this._filePointers.set(i.name,t),t.upload(this.urlUpload,this._requestHeaders,(i=>this.updateFeedback(i))).then((i=>i.forEach((i=>this.finishUpload(t.name,i))))).catch((i=>{this.ezCancelWaitingChange.emit(),this.showError(i)})),e(this)}}catch(i){throw this.ezCancelWaitingChange.emit(),i}}finishUpload(i,t){this._filePointers.set(i,t),this.updateValue()}updateValue(){this._updatingValue=[],this._filePointers.forEach((i=>{this.isRemoteFile(i)||this._updatingValue.push(i)})),this._filePointers.size===this._updatingValue.length&&(this.value=this._updatingValue,this.ezChange.emit(this.value))}buildProgressId(i){return`PROGRESS_${i.name.replace(/[^a-z0-9_]/gi,"_")}_${i.file.lastModified}`}updateFeedback(i){window.requestAnimationFrame((()=>{if(this._host){const t=this._host.shadowRoot.querySelector("#"+this.buildProgressId(i));t&&(t.value=i.progress)}}))}validateFile(i){return!this._filePointers.has(i.name)&&this.maxFiles>0&&this._filePointers.size>=this.maxFiles?(this.showError(`A quantidade máxima de arquivos é ${this.maxFiles}.`),!1):0===i.size?(this.showError(`Erro de permissão: O arquivo "${i.name}" não pode ser enviado.`),!1):this.urlUpload?!(this.maxFileSize>=0&&i.size>this.maxFileSize&&(this.showError("O tamanho máximo dos arquivos é de "+this.formatBytes(this.maxFileSize)),1)):(this.showError("Endereço de upload não informado"),!1)}showError(i){s.alert("Enviando arquivo",i)}formatBytes(i,t=1){if(0===i)return"0 Bytes";const e=t<0?0:t,o=Math.floor(Math.log(i)/Math.log(1024));return parseFloat((i/Math.pow(1024,o)).toFixed(e))+" "+["B","KB","MB","GB","TB","PB","EB","ZB","YB"][o]}onFileInputChange(i){this.addFiles(Array.from(i.target.files)),this._fileInput.value=""}isRemoteFile(i){return"file"in i}removeFromList(i){this._filePointers.delete(i),this.updateValue()}removeFile(i){const t=this._filePointers.get(i);if(this.isRemoteFile(t))t.abortUpload(),this.removeFromList(i);else if(this.urlDelete){const e=new r(null);this._filePointers.set(t.name,e),e.delete(t,this.urlDelete,null).then((()=>this.removeFromList(i))).catch((i=>this.showError(i)))}else this.removeFromList(i)}openFilesDialog(){this.enabled&&this._fileInput.click()}componentDidLoad(){this.enabled&&this._dropZone&&window.FileList&&window.File&&(this._dropZone.addEventListener("dragover",(i=>{i.stopPropagation(),i.preventDefault(),i.dataTransfer.dropEffect="copy",this._dropZone.style.background="#c2dbff"})),this._dropZone.addEventListener("drop",(i=>{i.stopPropagation(),i.preventDefault(),this.addFiles(Array.from(i.dataTransfer.files)),this._dropZone.style.background=""})),this._dropZone.addEventListener("dragleave",(()=>{this._dropZone.style.background=""}))),this._host&&d.addIDInfo(this._host,"input")}componentWillRender(){this.value&&this._filePointers.size<this.value.length&&this.updateFilePointers()}render(){return o("div",{ref:i=>this._dropZone=i,class:this.evalDisabledClass("iu","background--disabled")},o("div",{class:"iu__container",onClick:()=>this.openFilesDialog()},o("div",{class:"iu_header"},this.label?o("label",{class:this.evalDisabledClass("iu__label","text--disabled"),title:this.label},this.label):null,o("div",{class:"padding-large"},o("div",{class:this.evalDisabledClass("iu__icon-label","mouse-pointer--disabled")},o("button",{class:"iu__file-icon",disabled:!this.enabled}),o("div",{class:this.evalDisabledClass("text text--center text--medium text--primary","text--disabled")},this.enabled?"Arraste e solte ou clique para adicionar arquivos":"Somente leitura")),this.subtitle&&o("div",{class:this.evalDisabledClass("padding-extra-small text text--center text--small text--secondary","text--disabled")},this.subtitle))),this.buildFooter()),o("input",{ref:i=>this._fileInput=i,onChange:i=>this.onFileInputChange(i),type:"file",multiple:!0,class:"appearanceNone"}))}buildFooter(){if(0===this._filePointers.size)return null;const i=[];return this._filePointers.forEach((t=>i.push(this.buildFileItem(t)))),o("div",{class:"iu__footer"},i)}buildFileItem(i){const t=i.name,e=Number(i.progress),a=i.downloadURL,s=`${t} (${this.formatBytes(i.size)})`;return o("div",{class:"iu__item",key:t,onClick:i=>i.stopPropagation()},o("div",{class:"iu__item-label modificador"},o("div",{title:s,class:"col--stretch align--middle file__name text text--primary text--small text--ellipsis align--middle"},a?o("a",{href:a,download:!0},s):s)),isNaN(e)?null:o("div",{class:"col col--sd-4 col--stretch align--middle"},o("progress",{id:this.buildProgressId(i),value:e,max:"100"})),this.enabled?o("div",{class:"col col--stretch align--middle"},o("button",{class:"btn-cancel ",onClick:()=>this.removeFile(t)})):null)}evalDisabledClass(i,t){return this.enabled?i:`${i} ${t}`}get _host(){return a(this)}static get watchers(){return{value:["observeValue"],requestHeaders:["observeRequestHeaders"]}}};l.style=':host{--ez-upload--height:42px;--ez-upload--width:100%;--ez-upload__icon--width:48px;--ez-upload__container--background-color:var(--background--medium, #d2dce9);--ez-upload__color--primary:var(--color--primary, #008561);--ez-upload--padding--extra-small:var(--space--extra-small, 3px);--ez-upload--padding--small:var(--space--small, 6px);--ez-upload--padding--medium:var(--space--medium, 12px);--ez-upload--padding--large:var(--space--large, 24px);--ez-upload__border--color:var(--color-strokes, #DCE0E8);--ez-upload--text-shadow:var(--text-shadow, 0 0 0 #353535, 0 0 1px transparent);--ez-upload--text--primary:var(--text-primary, #626e82);--ez-upload--text--secondary:var(--text-secondary, #a2abb9);--ez-upload--font-size:var(--text--medium, 14px);--ez-upload--font-family:var(--font-pattern, Arial);--ez-upload--font-weight:var(--text-weight--large, 500);--ez-upload__btn__cancel-image:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="8x" width="8px"><path d="M 8,0.8 7.2,0 4,3.2 0.8,0 0,0.8 3.2,4 0,7.2 0.8,8 4,4.8 7.2,8 8,7.2 4.8,4 Z"/></svg>\');--ez-upload__file-icon-image:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="11x" width="9px"><path d="M 1.2272719,8.4999999 V 2.75 c 0,-1.1045695 1.4652499,-2 3.2727273,-2 1.8074777,0 3.2727281,0.8954305 3.2727281,2 V 8.9999999 C 7.7727273,9.690356 6.8569456,10.25 5.7272719,10.25 4.5975985,10.25 3.6818174,9.690356 3.6818174,8.9999999 V 3.75 c 0,-0.2761425 0.3663125,-0.5 0.8181818,-0.5 0.4518694,0 0.8181818,0.2238575 0.8181818,0.5 V 8.4999999 H 6.5454537 V 3.75 C 6.5454537,3.059644 5.6296725,2.5 4.4999992,2.5 3.3703258,2.5 2.4545446,3.059644 2.4545446,3.75 V 8.9999999 C 2.4545446,10.10457 3.9197945,11 5.7272719,11 7.5347496,11 9,10.10457 9,8.9999999 V 2.75 C 9,1.231217 6.9852809,0 4.4999992,0 2.0147181,5e-7 0,1.231217 0,2.75 v 5.7499999 z"/></svg>\');display:flex;flex-wrap:wrap;position:relative;padding-bottom:16px;font-family:var(--ez-upload--font-family);font-size:var(--ez-upload--font-size);width:var(--ez-upload--width);font-weight:var(--ez-upload--font-weight)}.iu{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:var(--ez-upload--padding--small);width:100%;border-radius:12px;box-sizing:border-box}.iu__container{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;border:2px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.iu__footer{display:flex;flex-wrap:wrap;justify-content:flex-start;width:100%;padding:0 var(--ez-upload--padding--medium) var(--ez-upload--padding--medium) var(--ez-upload--padding--medium);box-sizing:border-box}.iu__item{display:flex;width:100%;justify-content:flex-start;align-items:center;align-self:center;padding-bottom:var(--ez-upload--padding--extra-small);box-sizing:border-box;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.iu__item-label{display:flex;max-width:80%;align-self:stretch;align-items:center}.file__name{font-weight:200}.box__content{width:100%;justify-content:center;align-items:center;height:100%;border:1px dashed var(--ez-upload__border--color);border-radius:6px;box-sizing:border-box}.box__container{display:flex;flex-wrap:wrap;background-color:var(--ez-upload__container--background-color);padding:6px;width:100%;border-radius:12px}a:-webkit-any-link{color:#008561;fill:#008561;cursor:pointer;text-decoration:none}progress[value]{display:flex;width:100%;appearance:none;border:1px solid var(--ez-upload__border--color);height:12px;justify-content:flex-start;align-items:center;border-radius:3px;position:relative}progress[value]::-webkit-progress-bar{display:flex;-webkit-appearance:none;width:100%;background-color:rgb(255, 255, 255);border-radius:2px;padding:2px}progress[value]::-webkit-progress-value{display:flex;width:100%;background-color:var(--ez-upload__color--primary)}.text--center{text-align:center}.align--middle{align-self:center;align-items:center}.padding-large{padding:var(--ez-upload--padding--large) 0px}.padding-extra-small{padding:var(--ez-upload--padding--extra-small) 0px}.text{font-family:var(--font-pattern, "Roboto");text-shadow:0 0 0 #353535, 0 0 1px transparent}.text--primary{color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.text--secondary{color:var(--ez-upload--text--secondary);text-shadow:var(--ez-upload--text-shadow)}.text--ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.text--medium{font-size:14px}.text--small{font-size:12px}.btn-cancel{outline:none;border:none;background-color:unset;cursor:pointer}.btn-cancel::after{content:\'\';display:flex;background-color:var(--text--primary, #008561);width:8px;height:8px;-webkit-mask-image:var(--ez-upload__btn__cancel-image);mask-image:var(--ez-upload__btn__cancel-image)}.iu_header{display:flex;flex-direction:column;width:100%}.iu__label{padding:var(--space--small);box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-upload--font-family);font-size:var(--text--extra-small);font-weight:var(--ez-upload--font-weight);color:var(--ez-upload--text--primary);text-shadow:var(--ez-upload--text-shadow)}.iu__file-icon{outline:none;border:none;background-color:unset;cursor:pointer}.iu__file-icon:disabled{cursor:unset}.iu__file-icon::after{content:\'\';display:flex;background-color:var(--text--primary, #626e82);width:9px;height:11px;-webkit-mask-image:var(--ez-upload__file-icon-image);mask-image:var(--ez-upload__file-icon-image)}.iu__file-icon:disabled::after{background-color:var(--text--disable, #AFB6C0)}.iu__icon-label{justify-content:center;display:flex;cursor:pointer;box-sizing:border-box}.background--disabled{background-color:var(--color--disable-secondary, #F2F5F8)}.text--disabled{color:var(--text--disable, #AFB6C0)}.mouse-pointer--disabled{cursor:unset}.appearanceNone{width:0px;height:0px}.row{width:100%;display:flex;flex-wrap:wrap}.col{display:flex;flex-wrap:wrap;align-self:flex-start;box-sizing:border-box}.col--stretch{align-self:stretch}.col--undefined{width:unset}.col--nowrap{flex-wrap:nowrap}@media screen and (min-width: 320px){.col--sd-1{width:8.33333%}.col--sd-2{width:16.66667%}.col--sd-3{width:25%}.col--sd-4{width:33.33333%}.col--sd-5{width:41.66667%}.col--sd-6{width:50%}.col--sd-7{width:58.33333%}.col--sd-8{width:66.66667%}.col--sd-9{width:75%}.col--sd-10{width:83.33333%}.col--sd-11{width:91.66667%}.col--sd-12{width:100%}}@media screen and (min-width: 480px){.col--pn-1{width:8.33333%}.col--pn-2{width:16.66667%}.col--pn-3{width:25%}.col--pn-4{width:33.33333%}.col--pn-5{width:41.66667%}.col--pn-6{width:50%}.col--pn-7{width:58.33333%}.col--pn-8{width:66.66667%}.col--pn-9{width:75%}.col--pn-10{width:83.33333%}.col--pn-11{width:91.66667%}.col--pn-12{width:100%}}@media screen and (min-width: 768px){.col--tb-1{width:8.33333%}.col--tb-2{width:16.66667%}.col--tb-3{width:25%}.col--tb-4{width:33.33333%}.col--tb-5{width:41.66667%}.col--tb-6{width:50%}.col--tb-7{width:58.33333%}.col--tb-8{width:66.66667%}.col--tb-9{width:75%}.col--tb-10{width:83.33333%}.col--tb-11{width:91.66667%}.col--tb-12{width:100%}}@media screen and (min-width: 992px){.col--md-1{width:8.33333%}.col--md-2{width:16.66667%}.col--md-3{width:25%}.col--md-4{width:33.33333%}.col--md-5{width:41.66667%}.col--md-6{width:50%}.col--md-7{width:58.33333%}.col--md-8{width:66.66667%}.col--md-9{width:75%}.col--md-10{width:83.33333%}.col--md-11{width:91.66667%}.col--md-12{width:100%}}@media screen and (min-width: 1200px){.col--ld-1{width:8.33333%}.col--ld-2{width:16.66667%}.col--ld-3{width:25%}.col--ld-4{width:33.33333%}.col--ld-5{width:41.66667%}.col--ld-6{width:50%}.col--ld-7{width:58.33333%}.col--ld-8{width:66.66667%}.col--ld-9{width:75%}.col--ld-10{width:83.33333%}.col--ld-11{width:91.66667%}.col--ld-12{width:100%}}';export{l as ez_upload}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o,c as i,h as t,H as s,g as e}from"./p-bfc7b8ca.js";import{ObjectUtils as r,FloatingManager as l,StringUtils as a,ElementIDUtils as h}from"@sankhyalabs/core";import{A as n}from"./p-ab2a3006.js";import{C as c}from"./p-4a5e37a7.js";import"./p-ab574d59.js";import"./p-b853763b.js";import{R as b}from"./p-3f4ae3a3.js";const d=class{constructor(t){o(this,t),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._textEmptyList="Nenhum resultado encontrado",this._textEmptySearch="Nenhum resultado de {0} encontrado",this._preSelection=void 0,this._visibleOptions=void 0,this._startLoading=!1,this._showLoading=!0,this._criteria=void 0,this.value=void 0,this.label=void 0,this.enabled=!0,this.options=void 0,this.errorMessage=void 0,this.searchMode=void 0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.optionLoader=void 0,this.suppressEmptyOption=!1,this.canShowError=!0,this.mode="regular"}observeErrorMessage(){var o;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(o=this.errorMessage)||void 0===o?void 0:o.trim())||this.setInputValue())}observeValue(o,i){if(this._textInput&&o!=i){if(this.searchMode&&"string"==typeof o)return void this.setInputValue();const t=this.getSelectedOption(o),s=this.getSelectedOption(i),e=this.getSelectedOption(this.value);if(this.isDifferentValues(e,t)&&(this.value=t),this.isDifferentValues(t,s)){this.setInputValue();const s=null===t?void 0:t;this.isLookUpSearch(o,i)||this.ezChange.emit(s)}this.resetOptions()}}async setFocus(){this._textInput.setFocus()}async setBlur(){this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}isDifferentValues(o,i){return r.objectToString(o||{})!==r.objectToString(i||{})}getFormattedText(o){if(null!=o){if(!this.showSelectedValue||null==o.value)return o.label;if(o.label)return`${o.value} - ${o.label}`}}getText(){const o=this.getSelectedOption(this.value),i=this.getFormattedText(o);if(null!=i)return String(i).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"')}getSelectedOption(o){return"string"==typeof o||o instanceof String?this._visibleOptions.find((i=>i.value===o)):o}updateVisibleOptions(){let o=this._source||[];if(!this.searchMode&&this._criteria){const i=this._criteria.toUpperCase();o=o.filter((o=>o.label.toLocaleUpperCase().indexOf(i)>-1))}this._visibleOptions=this.suppressEmptyOption?o:[{value:void 0,label:""}].concat(o),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var o;if(this.showOptionValue){const i=[];return null===(o=this._visibleOptions)||void 0===o||o.forEach((o=>{const t=this.getWidthValue(o.value);i.includes(t)||i.push(t)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(o){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=o)return i.innerHTML=o,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}buildItem(o,i){const s=this.showOptionValue&&this._maxWidthValue>0?`${this._maxWidthValue}px`:"";return o.label=o.label||(o.value?`<SEM ${this.getFieldLabel()}>`:""),t("li",{class:i===this._preSelection?"item preselected":"item",id:`item_${o.value}`,onMouseDown:()=>this.selectOption(o),onMouseOver:()=>this._preSelection=i},this.showOptionValue?t("span",{class:"item__value",title:o.value,style:{width:s,minWidth:s,maxWidth:s}},o.value):void 0,t("span",{class:"item__label "+(this.showOptionValue?"item__label--bold":""),title:o.label},o.label))}showOptions(){this.enabled&&(this._floatingID=l.float(this._listWrapper,this._listContainer,{autoClose:!0,top:this.errorMessage||!this.canShowError||"slim"===this.mode?"6px":"-13px"}),this.setFocus(),window.requestAnimationFrame((()=>{this._listWrapper.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})})))}hideOptions(){void 0!==this._floatingID&&l.close(this._floatingID),this._floatingID=void 0}isOptionsVisible(){return void 0!==this._floatingID&&l.isFloating(this._floatingID)}nextOption(){this.searchMode&&!this.isOptionsVisible()||(this.showOptions(),this._preSelection=void 0===this._preSelection?0:Math.min(this._preSelection+1,this._visibleOptions.length-1),this.scrollToOption(this._visibleOptions[this._preSelection],!0))}previousOption(){this._preSelection=void 0===this._preSelection?0:Math.max(this._preSelection-1,0),this.scrollToOption(this._visibleOptions[this._preSelection],!1)}scrollToOption(o,i){window.requestAnimationFrame((()=>{const t=(null==o?void 0:o.value)?this._optionsList.querySelector(`li#item_${o.value}`):void 0;if(t){const o=t.parentElement,s=o.getBoundingClientRect(),e=t.getBoundingClientRect();i&&e.bottom>s.bottom?o.scrollTop=e.height*(this._preSelection-3):!i&&e.top<s.top&&(o.scrollTop=e.height*this._preSelection)}}))}selectCurrentOption(){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection]),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(o){this._startLoading=!1,o instanceof Promise?(this._showLoading=!0,o.then((o=>{this._showLoading=!1,this.updateSource(o)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(o)?(this._source=o,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch())):this.selectOption(o))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(o){var i,t;const s=this.getSelectedOption(this.value);(null===(i=null==s?void 0:s.value)||void 0===i?void 0:i.toString())!==(null===(t=null==o?void 0:o.value)||void 0===t?void 0:t.toString())||null==s&&null!=o&&"value"in o?this.value=(null==o?void 0:o.value)?o:void 0:this.resetOptions(),this.searchMode&&(this._visibleOptions=[],this.clearSource())}loadOptions(o,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:o,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.value?this.selectOption(void 0):window.setTimeout((()=>{this.setInputValue()}),this._deboucingTime),this.resetOptions()}setInputValue(o=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,o&&(this.errorMessage=null))}clearSearch(){this.value=null}controlListWithOnlyOne(){var o;if(this.searchMode){const i=null===(o=this._visibleOptions)||void 0===o?void 0:o.filter((o=>""!==o.label&&null!=o.value));1===(null==i?void 0:i.length)&&this.selectOption(i[0])}}controlEmptySearch(){var o;this.searchMode&&((null===(o=this._visibleOptions)||void 0===o?void 0:o.length)?this.controlListWithOnlyOne():(this.clearSearch(),n.info(this._textEmptyList)))}validateDescriptionValue(){if(!this.searchMode||a.isEmpty(this.value))return;let o=this.value;if("object"==typeof o){if(!a.isEmpty(o.label))return;o=o.value}a.isEmpty(o)||this.loadDescriptionValue(o)}async loadDescriptionValue(o){var i,t;if(null==o)return;if((null===(i=this.options)||void 0===i?void 0:i.length)>0)return void this.loadOptionValue(o);const s={mode:m.PREDICTIVE,argument:o},e=await(null===(t=this.optionLoader)||void 0===t?void 0:t.call(this,s));null!=e&&(e instanceof Promise?e.then((o=>{this.setDescriptionValue(o)})):this.setDescriptionValue(e))}setDescriptionValue(o){const i=(null==o?void 0:o[0])||o;null!=i&&Object.keys(i).length?(i.label||(i.label=`<SEM ${this.getFieldLabel()}>`),this.value=i):this.showNoResultMessage()}loadOptionValue(o){var i;const t=null===(i=this.options)||void 0===i?void 0:i.find((i=>i.value===o));null!=t?this.selectOption(t):this.showNoResultMessage()}async showNoResultMessage(){this.clearSearch(),n.info(this._textEmptySearch.replace("{0}",this.getFieldLabel()))}getFieldLabel(){var o;return null===(o=this.label)||void 0===o?void 0:o.replace(b,"").toUpperCase()}resetOptions(){this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}componentWillLoad(){if(void 0===this.options){this.options=[];const o=this.el.querySelectorAll("option");o&&o.forEach((o=>{let i=o.innerText,t=o.getAttribute("value");t||(t=i),this.options.push({label:i,value:t}),o.hidden=!0}))}this.searchMode?this.updateSource([]):this.loadOptions(m.PRELOAD)}componentDidRender(){var o;void 0===this._floatingID&&this._listWrapper.remove(),null===(o=this._optionsList)||void 0===o||o.querySelectorAll(".item").forEach((o=>{h.addIDInfoIfNotExists(o,"itemComboBox")})),this.validateDescriptionValue()}componentDidLoad(){c.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1)}handlerIconClick(){this.searchMode?this.loadOptions(m.ADVANCED):this.showOptions()}onTextInputChangeHandler(o){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(o)}),this._deboucingTime));const t=null===(i=o.target.value)||void 0===i?void 0:i.trim(),s=Number(t||void 0);this._criteria||(this._textInput.value=o.data||t),this._criteria=t,t?this.searchMode?(this._showLoading=!1,this.clearSource(),!isNaN(s)||t.length>=this._limitCharsToSearch?(this._showLoading=!0,this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions(m.PREDICTIVE,isNaN(s)?t:s.toString())}),this._deboucingTime),this.showOptions()):this.hideOptions()):(this.updateVisibleOptions(),this.showOptions()):(this.hideOptions(),this.searchMode?(this._showLoading=!1,this.clearSource()):this.updateVisibleOptions())}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=null)}onTextInputClickHandler(){this.searchMode||this.showOptions()}keyDownHandler(o){switch(this._tabPressed=!1,o.ctrlKey&&("f"!==o.key&&"F"!==o.key||(this.loadOptions(m.ADVANCED),o.stopPropagation(),o.stopImmediatePropagation(),o.preventDefault())),o.key){case"ArrowDown":this.nextOption();break;case"ArrowUp":this.previousOption();break;case"Enter":this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.controlListWithOnlyOne()}}onTextInputFocusOutHandler(){this.cancelPreselection()}isLookUpSearch(o,i){return this.searchMode&&"object"!=typeof i&&"object"==typeof o&&i==o.value}render(){var o;return h.addIDInfoIfNotExists(this.el,"input"),t(s,null,t("ez-text-input",{"data-element-id":h.getInternalIDInfo("textInput"),class:this.suppressSearch?"suppressed-search-input":"",ref:o=>this._textInput=o,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:o=>this.onTextInputChangeHandler(o),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:o=>this.keyDownHandler(o),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode},t("button",{class:"btn",slot:this.searchMode?"leftIcon":"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},t("ez-icon",{iconName:this.searchMode?"search":"chevron-down"})),this.searchMode&&(null===(o=this._textInput)||void 0===o?void 0:o.value)&&(this._criteria||this.value)?t("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},t("ez-icon",{iconName:"close"})):void 0),t("section",{class:"list-container",ref:o=>this._listContainer=o},t("div",{class:"list-wrapper",ref:o=>this._listWrapper=o},t("div",{class:"list-options",ref:o=>this._optionsList=o},!this._showLoading&&0===this._visibleOptions.length&&t("div",{class:"message"},t("span",{class:"message__no-result"},this._textEmptyList)),this._showLoading&&t("div",{class:"message"},t("div",{class:"message__loading"})),this.showOptionValue?t("span",{class:"item__value item__value--hidden",ref:o=>this._itemValueBasis=o}):void 0,!this._showLoading&&this._visibleOptions.length>0&&this._visibleOptions.map(((o,i)=>this.buildItem(o,i)))))))}get el(){return e(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"]}}};var m;!function(o){o.ADVANCED="ADVANCED",o.PRELOAD="PRELOAD",o.PREDICTIVE="PREDICTIVE"}(m||(m={})),d.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box--line-height:calc(var(--text--medium, 14px) + 4px);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium) + 4px);--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__scrollbar--color-default:var(--scrollbar--default, #626e82);--ez-combo-box__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--ez-combo-box__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--ez-combo-box__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--ez-combo-box__scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small) + 9px);background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;gap:3px;scrollbar-color:var(--ez-combo-box__scrollbar--color-clicked) var(--ez-combo-box__scrollbar--color-background)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__scrollbar--color-background);width:var(--ez-combo-box__scrollbar--width);max-width:var(--ez-combo-box__scrollbar--width);min-width:var(--ez-combo-box__scrollbar--width)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__scrollbar--color-background);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__scrollbar--color-default);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb:vertical:hover,.list-options::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--ez-combo-box__scrollbar--color-hover)}.list-options::-webkit-scrollbar-thumb:vertical:active,.list-options::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--ez-combo-box__scrollbar--color-clicked)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size);line-height:var(--ez-combo-box--line-height)}.item__label{font-weight:var(--ez-combo-box--font-weight--medium)}.item__label--bold{font-weight:var(--ez-combo-box--font-weight--large)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large)}.item__value--hidden{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:14px;height:14px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{d as ez_combo_box}
|
|
1
|
+
import{r as o,c as i,h as t,H as s,g as e}from"./p-bfc7b8ca.js";import{ObjectUtils as r,FloatingManager as l,StringUtils as a,ElementIDUtils as h}from"@sankhyalabs/core";import{A as n}from"./p-41ce6f98.js";import{C as c}from"./p-4a5e37a7.js";import"./p-ab574d59.js";import"./p-b853763b.js";import{R as b}from"./p-3f4ae3a3.js";const d=class{constructor(t){o(this,t),this.ezChange=i(this,"ezChange",7),this._changeDeboucingTimeout=null,this._limitCharsToSearch=3,this._deboucingTime=300,this._maxWidthValue=0,this._tabPressed=!1,this._textEmptyList="Nenhum resultado encontrado",this._textEmptySearch="Nenhum resultado de {0} encontrado",this._preSelection=void 0,this._visibleOptions=void 0,this._startLoading=!1,this._showLoading=!0,this._criteria=void 0,this.value=void 0,this.label=void 0,this.enabled=!0,this.options=void 0,this.errorMessage=void 0,this.searchMode=void 0,this.showSelectedValue=!1,this.showOptionValue=!1,this.suppressSearch=!1,this.optionLoader=void 0,this.suppressEmptyOption=!1,this.canShowError=!0,this.mode="regular"}observeErrorMessage(){var o;this._textInput&&(this._textInput.errorMessage=this.errorMessage,(null===(o=this.errorMessage)||void 0===o?void 0:o.trim())||this.setInputValue())}observeValue(o,i){if(this._textInput&&o!=i){if(this.searchMode&&"string"==typeof o)return void this.setInputValue();const t=this.getSelectedOption(o),s=this.getSelectedOption(i),e=this.getSelectedOption(this.value);if(this.isDifferentValues(e,t)&&(this.value=t),this.isDifferentValues(t,s)){this.setInputValue();const s=null===t?void 0:t;this.isLookUpSearch(o,i)||this.ezChange.emit(s)}this.resetOptions()}}async setFocus(){this._textInput.setFocus()}async setBlur(){this._textInput.setBlur()}async isInvalid(){return"string"==typeof this.errorMessage&&""!==this.errorMessage.trim()}isDifferentValues(o,i){return r.objectToString(o||{})!==r.objectToString(i||{})}getFormattedText(o){if(null!=o){if(!this.showSelectedValue||null==o.value)return o.label;if(o.label)return`${o.value} - ${o.label}`}}getText(){const o=this.getSelectedOption(this.value),i=this.getFormattedText(o);if(null!=i)return String(i).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"')}getSelectedOption(o){return"string"==typeof o||o instanceof String?this._visibleOptions.find((i=>i.value===o)):o}updateVisibleOptions(){let o=this._source||[];if(!this.searchMode&&this._criteria){const i=this._criteria.toUpperCase();o=o.filter((o=>o.label.toLocaleUpperCase().indexOf(i)>-1))}this._visibleOptions=this.suppressEmptyOption?o:[{value:void 0,label:""}].concat(o),this._maxWidthValue=this.getMaxWidthValue()}getMaxWidthValue(){var o;if(this.showOptionValue){const i=[];return null===(o=this._visibleOptions)||void 0===o||o.forEach((o=>{const t=this.getWidthValue(o.value);i.includes(t)||i.push(t)})),i.length>1?Math.max(...i):0}return 0}getWidthValue(o){if(null!=this._itemValueBasis){const i=this._itemValueBasis;if(null!=o)return i.innerHTML=o,i.clientWidth>0?i.clientWidth+2:0;i.innerHTML=""}return 0}buildItem(o,i){const s=this.showOptionValue&&this._maxWidthValue>0?`${this._maxWidthValue}px`:"";return o.label=o.label||(o.value?`<SEM ${this.getFieldLabel()}>`:""),t("li",{class:i===this._preSelection?"item preselected":"item",id:`item_${o.value}`,onMouseDown:()=>this.selectOption(o),onMouseOver:()=>this._preSelection=i},this.showOptionValue?t("span",{class:"item__value",title:o.value,style:{width:s,minWidth:s,maxWidth:s}},o.value):void 0,t("span",{class:"item__label "+(this.showOptionValue?"item__label--bold":""),title:o.label},o.label))}showOptions(){this.enabled&&(this._floatingID=l.float(this._listWrapper,this._listContainer,{autoClose:!0,top:this.errorMessage||!this.canShowError||"slim"===this.mode?"6px":"-13px"}),this.setFocus(),window.requestAnimationFrame((()=>{this._listWrapper.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})})))}hideOptions(){void 0!==this._floatingID&&l.close(this._floatingID),this._floatingID=void 0}isOptionsVisible(){return void 0!==this._floatingID&&l.isFloating(this._floatingID)}nextOption(){this.searchMode&&!this.isOptionsVisible()||(this.showOptions(),this._preSelection=void 0===this._preSelection?0:Math.min(this._preSelection+1,this._visibleOptions.length-1),this.scrollToOption(this._visibleOptions[this._preSelection],!0))}previousOption(){this._preSelection=void 0===this._preSelection?0:Math.max(this._preSelection-1,0),this.scrollToOption(this._visibleOptions[this._preSelection],!1)}scrollToOption(o,i){window.requestAnimationFrame((()=>{const t=(null==o?void 0:o.value)?this._optionsList.querySelector(`li#item_${o.value}`):void 0;if(t){const o=t.parentElement,s=o.getBoundingClientRect(),e=t.getBoundingClientRect();i&&e.bottom>s.bottom?o.scrollTop=e.height*(this._preSelection-3):!i&&e.top<s.top&&(o.scrollTop=e.height*this._preSelection)}}))}selectCurrentOption(){void 0!==this._preSelection?(this.selectOption(this._visibleOptions[this._preSelection]),this._preSelection=void 0):this.controlListWithOnlyOne()}updateSource(o){this._startLoading=!1,o instanceof Promise?(this._showLoading=!0,o.then((o=>{this._showLoading=!1,this.updateSource(o)})).catch((()=>this._showLoading=!1)),this.updateVisibleOptions()):(this._showLoading=!1,Array.isArray(o)?(this._source=o,this.updateVisibleOptions(),this._tabPressed&&(this._tabPressed=!1,this.controlEmptySearch())):this.selectOption(o))}clearSource(){this._source=[],this.updateVisibleOptions()}selectOption(o){var i,t;const s=this.getSelectedOption(this.value);(null===(i=null==s?void 0:s.value)||void 0===i?void 0:i.toString())!==(null===(t=null==o?void 0:o.value)||void 0===t?void 0:t.toString())||null==s&&null!=o&&"value"in o?this.value=(null==o?void 0:o.value)?o:void 0:this.resetOptions(),this.searchMode&&(this._visibleOptions=[],this.clearSource())}loadOptions(o,i=""){this._criteria=i,this._startLoading=!0,this.updateSource(this.optionLoader?this.optionLoader({mode:o,argument:i}):this.options)}cancelPreselection(){!this._textInput.value&&this.value?this.selectOption(void 0):window.setTimeout((()=>{this.setInputValue()}),this._deboucingTime),this.resetOptions()}setInputValue(o=!0){const i=this.getText();(this._textInput.value||"")!==i&&(this._textInput.value=i,o&&(this.errorMessage=null))}clearSearch(){this.value=null}controlListWithOnlyOne(){var o;if(this.searchMode){const i=null===(o=this._visibleOptions)||void 0===o?void 0:o.filter((o=>""!==o.label&&null!=o.value));1===(null==i?void 0:i.length)&&this.selectOption(i[0])}}controlEmptySearch(){var o;this.searchMode&&((null===(o=this._visibleOptions)||void 0===o?void 0:o.length)?this.controlListWithOnlyOne():(this.clearSearch(),n.info(this._textEmptyList)))}validateDescriptionValue(){if(!this.searchMode||a.isEmpty(this.value))return;let o=this.value;if("object"==typeof o){if(!a.isEmpty(o.label))return;o=o.value}a.isEmpty(o)||this.loadDescriptionValue(o)}async loadDescriptionValue(o){var i,t;if(null==o)return;if((null===(i=this.options)||void 0===i?void 0:i.length)>0)return void this.loadOptionValue(o);const s={mode:m.PREDICTIVE,argument:o},e=await(null===(t=this.optionLoader)||void 0===t?void 0:t.call(this,s));null!=e&&(e instanceof Promise?e.then((o=>{this.setDescriptionValue(o)})):this.setDescriptionValue(e))}setDescriptionValue(o){const i=(null==o?void 0:o[0])||o;null!=i&&Object.keys(i).length?(i.label||(i.label=`<SEM ${this.getFieldLabel()}>`),this.value=i):this.showNoResultMessage()}loadOptionValue(o){var i;const t=null===(i=this.options)||void 0===i?void 0:i.find((i=>i.value===o));null!=t?this.selectOption(t):this.showNoResultMessage()}async showNoResultMessage(){this.clearSearch(),n.info(this._textEmptySearch.replace("{0}",this.getFieldLabel()))}getFieldLabel(){var o;return null===(o=this.label)||void 0===o?void 0:o.replace(b,"").toUpperCase()}resetOptions(){this.hideOptions(),this._criteria=void 0,this._preSelection=void 0,this.updateVisibleOptions()}componentWillLoad(){if(void 0===this.options){this.options=[];const o=this.el.querySelectorAll("option");o&&o.forEach((o=>{let i=o.innerText,t=o.getAttribute("value");t||(t=i),this.options.push({label:i,value:t}),o.hidden=!0}))}this.searchMode?this.updateSource([]):this.loadOptions(m.PRELOAD)}componentDidRender(){var o;void 0===this._floatingID&&this._listWrapper.remove(),null===(o=this._optionsList)||void 0===o||o.querySelectorAll(".item").forEach((o=>{h.addIDInfoIfNotExists(o,"itemComboBox")})),this.validateDescriptionValue()}componentDidLoad(){c.applyVarsTextInput(this.el,this._textInput),this.setInputValue(!1)}handlerIconClick(){this.searchMode?this.loadOptions(m.ADVANCED):this.showOptions()}onTextInputChangeHandler(o){var i;if(this.clearDeboucingTimeout(),this._startLoading)return void(this._changeDeboucingTimeout=window.setTimeout((()=>{this.onTextInputChangeHandler(o)}),this._deboucingTime));const t=null===(i=o.target.value)||void 0===i?void 0:i.trim(),s=Number(t||void 0);this._criteria||(this._textInput.value=o.data||t),this._criteria=t,t?this.searchMode?(this._showLoading=!1,this.clearSource(),!isNaN(s)||t.length>=this._limitCharsToSearch?(this._showLoading=!0,this._changeDeboucingTimeout=window.setTimeout((()=>{this.loadOptions(m.PREDICTIVE,isNaN(s)?t:s.toString())}),this._deboucingTime),this.showOptions()):this.hideOptions()):(this.updateVisibleOptions(),this.showOptions()):(this.hideOptions(),this.searchMode?(this._showLoading=!1,this.clearSource()):this.updateVisibleOptions())}clearDeboucingTimeout(){this._changeDeboucingTimeout&&(window.clearTimeout(this._changeDeboucingTimeout),this._changeDeboucingTimeout=null)}onTextInputClickHandler(){this.searchMode||this.showOptions()}keyDownHandler(o){switch(this._tabPressed=!1,o.ctrlKey&&("f"!==o.key&&"F"!==o.key||(this.loadOptions(m.ADVANCED),o.stopPropagation(),o.stopImmediatePropagation(),o.preventDefault())),o.key){case"ArrowDown":this.nextOption();break;case"ArrowUp":this.previousOption();break;case"Enter":this.selectCurrentOption();break;case"Escape":this.cancelPreselection();break;case"Tab":this._tabPressed=!0,this.controlListWithOnlyOne()}}onTextInputFocusOutHandler(){this.cancelPreselection()}isLookUpSearch(o,i){return this.searchMode&&"object"!=typeof i&&"object"==typeof o&&i==o.value}render(){var o;return h.addIDInfoIfNotExists(this.el,"input"),t(s,null,t("ez-text-input",{"data-element-id":h.getInternalIDInfo("textInput"),class:this.suppressSearch?"suppressed-search-input":"",ref:o=>this._textInput=o,"data-slave-mode":"true",enabled:this.enabled&&!this.suppressSearch,onInput:o=>this.onTextInputChangeHandler(o),onClick:()=>this.onTextInputClickHandler(),onFocusout:()=>this.onTextInputFocusOutHandler(),onKeyDown:o=>this.keyDownHandler(o),label:this.label,canShowError:this.canShowError,errorMessage:this.errorMessage,mode:this.mode},t("button",{class:"btn",slot:this.searchMode?"leftIcon":"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.handlerIconClick()},t("ez-icon",{iconName:this.searchMode?"search":"chevron-down"})),this.searchMode&&(null===(o=this._textInput)||void 0===o?void 0:o.value)&&(this._criteria||this.value)?t("button",{class:"btn btn__close",slot:"rightIcon",disabled:!this.enabled,tabindex:-1,onClick:()=>this.clearSearch()},t("ez-icon",{iconName:"close"})):void 0),t("section",{class:"list-container",ref:o=>this._listContainer=o},t("div",{class:"list-wrapper",ref:o=>this._listWrapper=o},t("div",{class:"list-options",ref:o=>this._optionsList=o},!this._showLoading&&0===this._visibleOptions.length&&t("div",{class:"message"},t("span",{class:"message__no-result"},this._textEmptyList)),this._showLoading&&t("div",{class:"message"},t("div",{class:"message__loading"})),this.showOptionValue?t("span",{class:"item__value item__value--hidden",ref:o=>this._itemValueBasis=o}):void 0,!this._showLoading&&this._visibleOptions.length>0&&this._visibleOptions.map(((o,i)=>this.buildItem(o,i)))))))}get el(){return e(this)}static get watchers(){return{errorMessage:["observeErrorMessage"],value:["observeValue"]}}};var m;!function(o){o.ADVANCED="ADVANCED",o.PRELOAD="PRELOAD",o.PREDICTIVE="PREDICTIVE"}(m||(m={})),d.style=":host{--ez-combo-box--height:42px;--ez-combo-box--width:100%;--ez-combo-box__icon--width:48px;--ez-combo-box--border-radius:var(--border--radius-medium, 12px);--ez-combo-box--border-radius-small:var(--border--radius-small, 6px);--ez-combo-box--font-size:var(--text--medium, 14px);--ez-combo-box--font-family:var(--font-pattern, Arial);--ez-combo-box--font-weight--large:var(--text-weight--large, 500);--ez-combo-box--font-weight--medium:var(--text-weight--medium, 400);--ez-combo-box--background-color--xlight:var(--background--xlight, #fff);--ez-combo-box--background-medium:var(--background--medium, #f0f3f7);--ez-combo-box--line-height:calc(var(--text--medium, 14px) + 4px);--ez-combo-box__input--background-color:var(--background--medium, #e0e0e0);--ez-combo-box__input--border:var(--border--medium, 2px solid);--ez-combo-box__input--border-color:var(--ez-combo-box__input--background-color);--ez-combo-box__input--focus--border-color:var(--color--primary, #008561);--ez-combo-box__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-combo-box__input--disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__input--error--border-color:#CC2936;--ez-combo-box__btn--color:var(--title--primary, #2B3A54);--ez-combo-box__btn-disabled--color:var(--text--disable, #AFB6C0);--ez-combo-box__btn-hover--color:var(--color--primary, #4e4e4e);--ez-combo-box__label--color:var(--title--primary, #2B3A54);--ez-combo-box__list-title--primary:var(--title--primary, #2B3A54);--ez-combo-box__list-text--primary:var(--text--primary, #626e82);--ez-combo-box__list-height:calc(var(--ez-combo-box--font-size) + var(--ez-combo-box--space--medium) + 4px);--ez-combo-box--space--medium:var(--space--medium, 12px);--ez-combo-box--space--small:var(--space--small, 6px);--ez-combo-box__scrollbar--color-default:var(--scrollbar--default, #626e82);--ez-combo-box__scrollbar--color-background:var(--scrollbar--background, #E5EAF0);--ez-combo-box__scrollbar--color-hover:var(--scrollbar--hover, #2B3A54);--ez-combo-box__scrollbar--color-clicked:var(--scrollbar--clicked, #a2abb9);--ez-combo-box__scrollbar--border-radius:var(--border--radius-small, 6px);--ez-combo-box__scrollbar--width:var(--space--medium, 12px);display:flex;flex-wrap:wrap;position:relative;width:var(--ez-combo-box--width)}ez-icon{--ez-icon--color:inherit;font-weight:var(--text-weight--large, 600)}.suppressed-search-input{--ez-text-input__input--border-color:var(--color--strokes, #dce0e8);--ez-text-input__input--disabled--background-color:var(--background--xlight, #fff);--ez-text-input__input--disabled--color:var(--title--primary, #2B3A54)}.list-container{position:relative;width:100%}.list-wrapper{display:flex;flex-direction:column;box-sizing:border-box;width:100%;z-index:var(--more-visible, 2);max-height:calc(4*var(--ez-combo-box__list-height) + 2*var(--ez-combo-box--space--small) + 9px);background-color:var(--ez-combo-box--background-color--xlight);border-radius:var(--ez-combo-box--border-radius);box-shadow:var(--shadow, 0px 0px 16px 0px #000);padding:var(--ez-combo-box--space--small)}.list-options{box-sizing:border-box;width:100%;height:100%;display:flex;flex-direction:column;scroll-behavior:smooth;overflow:auto;scrollbar-width:thin;gap:3px;scrollbar-color:var(--ez-combo-box__scrollbar--color-clicked) var(--ez-combo-box__scrollbar--color-background)}.list-options::-webkit-scrollbar{background-color:var(--ez-combo-box__scrollbar--color-background);width:var(--ez-combo-box__scrollbar--width);max-width:var(--ez-combo-box__scrollbar--width);min-width:var(--ez-combo-box__scrollbar--width)}.list-options::-webkit-scrollbar-track{background-color:var(--ez-combo-box__scrollbar--color-background);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb{background-color:var(--ez-combo-box__scrollbar--color-default);border-radius:var(--ez-combo-box__scrollbar--border-radius)}.list-options::-webkit-scrollbar-thumb:vertical:hover,.list-options::-webkit-scrollbar-thumb:horizontal:hover{background-color:var(--ez-combo-box__scrollbar--color-hover)}.list-options::-webkit-scrollbar-thumb:vertical:active,.list-options::-webkit-scrollbar-thumb:horizontal:active{background-color:var(--ez-combo-box__scrollbar--color-clicked)}.item{display:flex;align-items:center;width:100%;box-sizing:border-box;list-style-type:none;cursor:pointer;border-radius:var(--ez-combo-box--border-radius-small);padding:var(--ez-combo-box--space--small);min-height:var(--ez-combo-box__list-height);gap:var(--space--small, 6px)}.item__value,.item__label{flex-basis:auto;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size);line-height:var(--ez-combo-box--line-height)}.item__label{font-weight:var(--ez-combo-box--font-weight--medium)}.item__label--bold{font-weight:var(--ez-combo-box--font-weight--large)}.item__value{text-align:center;color:var(--ez-combo-box__list-text--primary);font-weight:var(--ez-combo-box--font-weight--large)}.item__value--hidden{visibility:hidden;position:absolute;white-space:nowrap;z-index:-1;top:0;left:0}.item__label{text-align:left}.message{text-align:center;display:flex;justify-content:center;align-items:center;list-style-type:none;min-height:var(--ez-combo-box__list-height)}.message__no-result{color:var(--ez-combo-box__list-title--primary);font-family:var(--ez-combo-box--font-family);font-size:var(--ez-combo-box--font-size)}.message__loading{border-radius:50%;width:14px;height:14px;-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite;border:3px solid var(--ez-combo-box__list-title--primary);border-top:3px solid transparent}li:hover{background-color:var(--ez-combo-box--background-medium)}.preselected{background-color:var(--background--medium)}.btn{outline:none;border:none;background:none;cursor:pointer;color:var(--ez-combo-box__btn--color)}.btn:disabled{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:disabled:hover{cursor:unset;color:var(--ez-combo-box__btn-disabled--color)}.btn:hover{color:var(--ez-combo-box__btn-hover--color)}.btn__close{visibility:hidden}ez-text-input:hover .btn__close,ez-text-input:focus .btn__close{visibility:visible}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}";export{d as ez_combo_box}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,c as i,h as e,g as o}from"./p-bfc7b8ca.js";import{ElementIDUtils as t}from"@sankhyalabs/core";import{A as s}from"./p-
|
|
1
|
+
import{r as l,c as i,h as e,g as o}from"./p-bfc7b8ca.js";import{ElementIDUtils as t}from"@sankhyalabs/core";import{A as s}from"./p-41ce6f98.js";import"./p-ab574d59.js";import"./p-b853763b.js";const a=class{constructor(e){l(this,e),this.ezChange=i(this,"ezChange",7),this.ezRemove=i(this,"ezRemove",7),this.ezSaveEditLabel=i(this,"ezSaveEditLabel",7),this.ezEditLabelMode=i(this,"ezEditLabelMode",7),this._activeEditText=!1,this.value=!1,this.label=void 0,this.subtitle=void 0,this.headerSize="small",this.iconPlacement="left",this.headerAlign="left",this.removable=!1,this.editable=!1,this.conditionalSave=void 0}async showHide(){this.value=!this.value}async applyFocusTextEdit(){var l;null===(l=this._refTextEdit)||void 0===l||l.applyFocusSelect()}async cancelEdition(){this._activeEditText=!1,this.ezEditLabelMode.emit(this._activeEditText)}observeCollapsedValue(){this.ezChange.emit(this.value)}getHeaderSize(){const l=this.headerSize&&this.headerSize.toLowerCase(),i=["xsmall","xlarge"].includes(l)?l.replace("x","x-"):l;return["x-small","small","medium","large","x-large"].includes(i)?i:"small"}removeElement(){this._hostElement&&this._hostElement.remove(),this.ezRemove.emit(this)}editLabel(l){l.preventDefault(),l.stopPropagation(),this._activeEditText=!0,this.ezEditLabelMode.emit(this._activeEditText)}confirmRemove(l){l.preventDefault(),l.stopPropagation(),s.confirm("Aviso",`Deseja realmente remover o grupo <b>${this.label}</b>?`).then((l=>{l&&this.removeElement()}))}saveEditionText(l){const{value:i,newValue:e}=l.detail;if(i===e)return void this.cancelEdition();let o=!0;this.conditionalSave&&(o=this.conditionalSave(e)),this.label!==e&&o&&(this.label=e,this._activeEditText=!1,this.ezSaveEditLabel.emit(l.detail),this.ezEditLabelMode.emit(this._activeEditText))}getStyledLabel(){if(null!=this._refLabel)return{fontSize:window.getComputedStyle(this._refLabel).getPropertyValue("font-size"),fontWeight:window.getComputedStyle(this._refLabel).getPropertyValue("font-weight"),fontFamily:window.getComputedStyle(this._refLabel).getPropertyValue("font-family")}}componentDidLoad(){t.addIDInfo(this._hostElement)}render(){return e("div",{class:"collapsible-box"},e("div",{class:"collapsible-box__header"},e("button",Object.assign({},this._activeEditText?null:{onClick:()=>{this.showHide()}},{class:"collapsible-box__title collapsible-box__title--"+(this.headerAlign||"left")+("right"===this.iconPlacement?" collapsible-box__title--icon-right":"")+(this.value?" collapsible-box__title--no-margin":"")}),e("ez-icon",{slot:"icon","icon-name":"chevron-right",size:this.getHeaderSize(),class:"collapsible-box__icon collapsible-box__icon--"+this.getHeaderSize()+(this.value?" collapsible-box__icon--collapsed":""),id:"toggleCollapsible"}),this._activeEditText?e("ez-text-edit",{class:"collapsible-box__text-edit",ref:l=>this._refTextEdit=l,value:this.label,styled:this.getStyledLabel(),onSaveEdition:l=>this.saveEditionText(l),onCancelEdition:()=>this.cancelEdition()}):e("label",{class:"collapsible-box__label font--"+this.getHeaderSize(),title:this.label,ref:l=>this._refLabel=l},e("span",null,this.label),this.editable&&e("ez-icon",{slot:"icon","icon-name":"edit",onClick:l=>this.editLabel(l),title:"Editar"}),this.removable&&e("ez-icon",{slot:"icon","icon-name":"delete",onClick:l=>this.confirmRemove(l),title:"Remover"}))),e("slot",{name:"rightSlot"})),e("div",{class:"collapsible-box__content"+(this.value?"":" collapsible-box__content--show")},this.subtitle&&e("div",{class:"subtitle-box__content"},e("label",{class:"subtitle-box__label",title:this.subtitle},e("span",null,this.subtitle))),e("slot",null)))}get _hostElement(){return o(this)}static get watchers(){return{value:["observeCollapsedValue"]}}};a.style=":host{--ez-collapsible-box--font-size:var(--title--medium, 14px);--ez-collapsible-box--font-family:var(--font-pattern, Arial);--ez-collapsible-box--font-weight:var(--text-weight--large, 600);--ez-collapsible-box--color:var(--title--primary);--ez-collapsible-box--subtitle--font-size:var(--text--medium, 14px);--ez-collapsible-box--subtitle--font-family:var(--font-pattern, 'Roboto');--ez-collapsible-box--subtitle--font-weight:var(--text-weight--medium, 400);--ez-collapsible-box--subtitle--color:var(--text--primary);--ez-collapsible-box--subtitle--margin-bottom:var(--space--medium, 12px);--ez-collapsible-box--focus--color:var(--color--primary-600);--ez-collapsible-box__icon--color:var(--ez-collapsible-box--color);--ez-collapsible-box__header--padding-top:0px;--ez-collapsible-box__header--padding-bottom:0px;--ez-collapsible-box__header--padding-right:0px;--ez-collapsible-box__header--padding-left:0px;display:flex;flex-wrap:wrap;width:100%}ez-icon{--ez-icon--color:inherit}.collapsible-box{display:flex;flex-direction:column;width:100%}.collapsible-box__header{display:flex;box-sizing:border-box;padding-top:var(--ez-collapsible-box__header--padding-top);padding-bottom:var(--ez-collapsible-box__header--padding-bottom);padding-right:var(--ez-collapsible-box__header--padding-right);padding-left:var(--ez-collapsible-box__header--padding-left)}.collapsible-box__title{position:relative;width:auto;display:flex;box-sizing:border-box;align-items:center;outline:none;border:none;background-color:unset;cursor:pointer;padding:0px;text-align:left;color:var(--ez-collapsible-box--color);--ez-icon--color:var(--ez-collapsible-box__icon--color);margin-bottom:var(--space--medium, 12px)}.collapsible-box__title:focus{color:var(--ez-collapsible-box--focus--color);--ez-icon--color:var(--ez-collapsible-box--focus--color)}.collapsible-box__label{display:flex;white-space:nowrap;overflow:hidden;cursor:pointer;text-overflow:ellipsis;box-sizing:border-box;margin-left:6px;gap:6px;font-family:var(--ez-collapsible-box--font-family);font-size:var(--ez-collapsible-box--font-size);font-weight:var(--ez-collapsible-box--font-weight)}.subtitle-box__label{display:flex;overflow:hidden;text-overflow:ellipsis;box-sizing:border-box;font-family:var(--ez-collapsible-box--subtitle--font-family);font-size:var(--ez-collapsible-box--subtitle--font-size);font-weight:var(--ez-collapsible-box--subtitle--font-weight);color:var(--ez-collapsible-box--subtitle--color);margin-bottom:var(--ez-collapsible-box--subtitle--margin-bottom)}.subtitle-box__content{width:100%}.collapsible-box__label ez-icon{visibility:hidden;transition:0.25s linear}.collapsible-box__label:hover ez-icon{visibility:visible}.collapsible-box__text-edit{margin-left:6px}.collapsible-box__icon{transform:rotate(90deg) translate(0px, 14%);transition:transform var(--transition)}.collapsible-box__icon--collapsed{transform:rotate(0deg) translate(-14%, 0px)}.collapsible-box__title--icon-right{flex-direction:row-reverse}.collapsible-box__title--icon-right .collapsible-box__icon{transform:rotate(90deg) translate(0px, -14%)}.collapsible-box__title--icon-right .collapsible-box__icon--collapsed{transform:rotate(0deg) translate(14%, 0px)}.collapsible-box__title--icon-right .collapsible-box__label{margin-left:0px;margin-right:6px}.collapsible-box__title--left{margin-right:auto}.collapsible-box__title--right{margin-left:auto}.collapsible-box__title--center{margin-left:auto;margin-right:auto}.collapsible-box__title--stretch{justify-content:space-between;width:100%}.collapsible-box__title--no-margin{margin-bottom:0}.collapsible-box__content{display:flex;flex-wrap:wrap;width:100%;height:0px;max-height:0px;opacity:0;overflow:hidden;transition:all var(--transition, 0.5s)}.collapsible-box__content--show{height:100%;max-height:none;opacity:1;overflow:visible;transition:all var(--transition, 0.5s)}.font--x-small{font-size:10px}.font--small{font-size:12px}.font--medium{font-size:14px}.font--large{font-size:16px}.font--x-large{font-size:20px}";export{a as ez_collapsible_box}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,f as s,H as n,g as r}from"./p-bfc7b8ca.js";import{UserInterface as o,DateUtils as a,Action as l,WaitingChangeException as h,ApplicationContext as c,DataUnitAction as u,StringUtils as d,DataUnit as f,ElementIDUtils as v}from"@sankhyalabs/core";import{A as p}from"./p-ab2a3006.js";import"./p-ab574d59.js";const b=/child\[([^\]]+)\]/,m=/\$\{.+\}/;class g{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}static getDetailName(t){const e=b.exec(t);return e?e[1]:void 0}getSheet(t){return this._sheets.get(t)}getAllSheets(){return this._sheets}addSheet(t){this._sheets.set(t.name,t)}addRequiredFields(t){this._requiredFields=this._requiredFields.concat(t)}getRequiredFields(){return this._requiredFields}addCleanOnCopyFields(t){this._cleanOnCopyFields=this._cleanOnCopyFields.concat(t)}getCleanOnCopyFields(){return this._cleanOnCopyFields}addDefaultValues(t){return this._defaultValues=Object.assign(Object.assign({},this._defaultValues),t)}getDefaultValues(){const t={};return Object.entries(this._defaultValues).forEach((([e,i])=>{if("string"==typeof i){const t=m.exec(i);t&&(i=this.getDefaultVar(t[0]))}t[e]=i})),t}getDefaultVar(t){return"${data}"===t?a.getToday():"${datahora}"===t?a.getToday(!0):this._defaultVars?this._defaultVars.get(t):void 0}setDefaultVars(t){this._defaultVars=t}}const y=(t,e)=>"__main"==t[0].label?-1:(t[0].order||1e4)-(e[0].order||1e4);class _{constructor(t){this.onDataUnitEvent=t=>{var e,i;switch(t.type){case l.DATA_LOADED:case l.DATA_SAVED:case l.RECORDS_REMOVED:case l.RECORDS_ADDED:case l.RECORDS_COPIED:case l.EDITION_CANCELED:case l.SELECTION_CHANGED:case l.NEXT_SELECTED:case l.PREVIOUS_SELECTED:this.clearInvalid();case l.DATA_CHANGED:case l.CHANGE_UNDONE:case l.CHANGE_REDONE:case l.RECORD_LOADED:null===(e=this._fields)||void 0===e||e.forEach((t=>{this.updateValue(t.fieldName,t.field)}));break;case l.FIELD_INVALIDATED:null===(i=this._fields)||void 0===i||i.forEach((t=>{this.updateErrorMessage(t.fieldName,t.field)}))}},this._fields=new Map,this._dataUnit=t,this.applyDefaultValues(),this._dataUnit.subscribe(this.onDataUnitEvent),this._dataUnit.addInterceptor(this)}applyDefaultValues(){const t=(this._dataUnit.getAddedRecords()||[]).map((t=>t.__record__id__));if(t.length>0){const e=this.getDefaultValues();e&&Object.keys(e).forEach((i=>{this._dataUnit.setFieldValue(i,e[i],t)}))}}bind(t,e,i,s){t.forEach((t=>{const{fieldName:i,contextName:s}=t.dataset;null!=s&&s!==e||this.updateBind(i,t)})),this._formMetadata=i,this._recordsValidator=s}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent),this._dataUnit.removeInterceptor(this)}getCurrentRecordId(){const t=this._dataUnit.getSelectedRecord();return null==t?void 0:t.__record__id__}markInvalid(t){if(this._dataUnit.setInvalidField(t.name,t.message,this.getCurrentRecordId()),this._fields.has(t.name)){const e=this._fields.get(t.name).field;this.updateErrorMessage(t.name,e,t.message)}}clearInvalid(t){this._dataUnit.clearInvalid(t),this._fields.forEach((t=>{t.field.errorMessage=""}))}updateValue(t,e){const i=this._fields.get(t);try{i&&(i.listen=!1),e.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,e)}finally{i&&(i.listen=!0)}}validate(){return new Promise(((t,e)=>{var i;const s=this._dataUnit.getModifiedRecords();for(let t=0;t<s.length;t++){const n=s[t],r=[];let o=this.validateRequired(n);if(o&&!o.isValid&&r.push(o),o=null===(i=this._recordsValidator)||void 0===i?void 0:i.validateRecord(n),o&&!o.isValid&&r.push(o),r.length>0){this.processValidationResult(r),e();break}}return t()}))}validateRequired(t){const e=this._formMetadata.getRequiredFields(),i=[];if(new Set(e).forEach((e=>{const s=t[e];if(null==s||""===s){const t=this.getErrorMessage(e);i.push(t?{name:e,message:t}:{name:e,message:"Essa informação é obrigatória"})}})),i.length>0)return{isValid:!1,invalidFields:i,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(t){t.forEach((t=>{const e=t.invalidFields;if(e&&e.forEach((t=>{this.markInvalid(t)})),t.infoMessage&&p.info(t.infoMessage),t.errorMessage){const{errorTitle:e,errorMessage:i}=t;p.error(e,i)}}))}updateErrorMessage(t,e,i){null==i&&(i=this._dataUnit.getInvalidMessage(this.getCurrentRecordId(),t)),e.errorMessage||(e.errorMessage=i)}getErrorMessage(t){if(this._fields.has(t))return this._fields.get(t).field.errorMessage}updateBind(t,e){const i=this._fields.get(t);i&&i.destroy(),e.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,e),this._fields.set(t,w.create(t,e,((t,e)=>this.changeStarted(t,e)),(t=>this.cancelWaitingChange(t)),((t,e)=>this.setFieldValue(t,e)))),this.bindSearchOptionsLoader(t,e),this.applyEzUploadContext(t,e)}changeStarted(t,e){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!e.blocking&&null==e.promise){const i=this._fields.get(t);i&&(e.promise=new Promise(((t,e)=>{i.waitingChangePromiseResolve=t,i.waitingChangePromiseReject=e})))}this._dataUnit.startChange(t,e)}cancelWaitingChange(t){if(this._dataUnit.waitingForChange(t)){this._dataUnit.cancelWaitingChange(t);const e=this._fields.get(t);e&&e.rejectWaitingChange(new h("Change canceled",t))}}setFieldValue(t,e){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.clearInvalid(this.getCurrentRecordId(),t),this._dataUnit.setFieldValue(t,e),this._dataUnit.waitingForChange(t)){const e=this._fields.get(t);e&&e.acceptWaitingChange()}}bindSearchOptionsLoader(t,e){if("EZ-SEARCH"===e.nodeName&&null==e.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(e.optionLoader=e=>i(e,t,this._dataUnit))}}applyEzUploadContext(t,e){var i,s;if("EZ-UPLOAD"===e.nodeName){e.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),e.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const n=this._dataUnit.getField(t),r=null===(i=n.properties)||void 0===i?void 0:i.DESTINATION;r&&(e.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),e.maxFiles=(null===(s=n.properties)||void 0===s?void 0:s.MAX_FILES)||0}}interceptAction(t){if(t.type===l.RECORDS_COPIED){const e=this._formMetadata.getCleanOnCopyFields();if(e)return new u(l.RECORDS_COPIED,t.payload.map((t=>{const i=Object.assign({},t);return e.forEach((t=>delete i[t])),i})))}if(t.type===l.SAVING_DATA)return new Promise((e=>{this.validate().then((()=>e(t))).catch((()=>{}))}));if(t.type===l.RECORDS_ADDED){const e=this.getDefaultValues();if(e)return new u(l.RECORDS_ADDED,t.payload.map((t=>Object.assign(Object.assign({},t),e))))}return t}getDefaultValues(){var t;const e=null===(t=this._formMetadata)||void 0===t?void 0:t.getDefaultValues();if(e){const t={};for(const i in e)t[i]=this._dataUnit.valueFromString(i,e[i]);return t}}}class w{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(t){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(t),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(t,e,i,s,n){const r=new w;return r.field=e,r.fieldName=t,r.startChangeListener=e=>{r.listen&&i(t,e.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&s(t)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=e=>{r.listen&&n(t,e.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}function O(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var E="function"==typeof Symbol&&Symbol.observable||"@@observable",C=function(){return Math.random().toString(36).substring(7).split("").join(".")},A={INIT:"@@redux/INIT"+C(),REPLACE:"@@redux/REPLACE"+C(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+C()}};function j(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function R(t,e,i){var s;if("function"==typeof e&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(O(0));if("function"==typeof e&&void 0===i&&(i=e,e=void 0),void 0!==i){if("function"!=typeof i)throw new Error(O(1));return i(R)(t,e)}if("function"!=typeof t)throw new Error(O(2));var n=t,r=e,o=[],a=o,l=!1;function h(){a===o&&(a=o.slice())}function c(){if(l)throw new Error(O(3));return r}function u(t){if("function"!=typeof t)throw new Error(O(4));if(l)throw new Error(O(5));var e=!0;return h(),a.push(t),function(){if(e){if(l)throw new Error(O(6));e=!1,h();var i=a.indexOf(t);a.splice(i,1),o=null}}}function d(t){if(!j(t))throw new Error(O(7));if(void 0===t.type)throw new Error(O(8));if(l)throw new Error(O(9));try{l=!0,r=n(r,t)}finally{l=!1}for(var e=o=a,i=0;i<e.length;i++)(0,e[i])();return t}function f(t){if("function"!=typeof t)throw new Error(O(10));n=t,d({type:A.REPLACE})}function v(){var t,e=u;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(O(11));function i(){t.next&&t.next(c())}return i(),{unsubscribe:e(i)}}})[E]=function(){return this},t}return d({type:A.INIT}),(s={dispatch:d,subscribe:u,getState:c,replaceReducer:f})[E]=v,s}const D={};function z(t=D,e){switch(e.type){case S.METADATA_LOADED:return Object.assign(Object.assign({},t),{formMetadata:e.payload,currentSheet:void 0});case S.CHANGE_TAB:return Object.assign(Object.assign({},t),{currentSheet:e.payload});default:return t}}function N(t){return t.formMetadata}var S;!function(t){t.METADATA_LOADED="FORM/METADATA_LOADED",t.CHANGE_TAB="FORM/CHANGE_TAB"}(S||(S={}));const x=class{constructor(i){t(this,i),this.ezReady=e(this,"ezReady",7),this.onDataUnitAction=t=>{t.type===l.METADATA_LOADED&&this.processMetadata()},this.dataUnit=void 0,this.config=void 0,this.recordsValidator=void 0}validate(){return this._dataBinder.validate()}observeConfig(){this.processMetadata()}getDynamicContent(){var t;const e=N(this._store.getState());if(!e)return null;const s=Array.from(e.getAllSheets().values()),n=function(t){const e=function(t){return t.currentSheet}(t);return e?t.formMetadata.getSheet(e):Array.from(t.formMetadata.getAllSheets().values())[0]}(null===(t=this._store)||void 0===t?void 0:t.getState());let r=[];if(s.length>1){const t=s.map(((t,e)=>({tabKey:t.name,label:t.label,index:e}))),e="selector";r.push(i("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:t=>this._store.dispatch(function(t){return{type:S.CHANGE_TAB,payload:"string"==typeof t?t:t.tabKey}}(t.detail)),selectedTab:n.name,"data-element-id":e}))}return r=r.concat(this.buildFormContent(n)),r}buildFormContent(t){const e=null==t?void 0:t.fields;if(null==t)return;const s=`${d.replaceAccentuatedChars(d.toCamelCase(null==t?void 0:t.label),!1)}_selectorContainer`;return i("div",{class:"dynamic-content","data-element-id":s},i("ez-form-view",{class:"ez-row ez-padding-vertical--small",fields:e}))}processMetadata(){if(!this.isStatic()&&this.dataUnit&&this._store){const t=((t,e,i=!1)=>{var s,n;null!=t&&!0!==(null==t?void 0:t.emptyConfig)||(t=(t=>{const e=t.metadata;let i;return e&&(i=e.fields.filter((t=>!1!==t.visible)).map((t=>({name:t.name,defaultValue:t.defaultValue})))),{emptyConfig:!1,fields:i}})(e));const r=new Map,a=new Map,l=[],h=[],c={};null===(s=null==t?void 0:t.tabs)||void 0===s||s.forEach((t=>{a.has(t.label)||!1!==t.visible||a.set(t.label,t)})),null===(n=null==t?void 0:t.fields)||void 0===n||n.forEach((t=>{var i,s,n;if(!1!==t.visible){const u=((t,e)=>("string"==typeof t?Array.from(e.keys()).find((e=>e.label===t)):t)||{label:t,visible:!0})(t.tab||"__main",r);if(a.has(u.label))return;const d=e.getField(t.name);if(d&&u.visible){r.has(u)||r.set(u,[]);const e=((t,e)=>{let i,s,{name:n,label:r,group:a}=Object.assign({},e),{readOnly:l,required:h}=Object.assign({},e);return t&&(r=r||t.label,n=n||t.name,h=t.required||(null==e?void 0:e.required),l=t.readOnly||(null==e?void 0:e.readOnly),i=t.properties,s=t.userInterface),{name:n,label:r,group:a,readOnly:l,required:h,props:i,userInterface:s||o.SHORTTEXT}})(d,t);r.get(u).push(e),e.required&&l.push(t.name),((null==t.cleanOnCopy?null===(i=d.properties)||void 0===i?void 0:i.cleanOnCopy:t.cleanOnCopy)||(null===(s=d.properties)||void 0===s?void 0:s.cleanOnCopy))&&h.push(t.name);let a=null==t.defaultValue?null===(n=d.properties)||void 0===n?void 0:n.defaultValue:t.defaultValue;if(a){const{type:e,value:i}=a;if(e)if("V"===e)a=i;else try{const t=JSON.parse(i);a=t&&"value"in t?t:i}catch(t){}c[t.name]=a}}}}));const u=new g;if(u.setDefaultVars(t.defaultVars),i){const t=e.metadata;null!=t&&null!=t.children&&t.children.forEach((t=>{const{label:e,name:i,fields:s}=(t=>({name:`child[${t.name}]`,label:t.label,fields:[]}))(t);r.set({name:i,label:e},s)}))}return Array.from(r.entries()).sort(y).forEach((([t,e])=>{u.addSheet({label:"__main"===t.label?"Principal":t.label,name:t.name||t.label,fields:e})})),u.addRequiredFields(l),u.addCleanOnCopyFields(h),u.addDefaultValues(c),u})(this.config,this.dataUnit);this._store.dispatch({type:S.METADATA_LOADED,payload:t})}}isStatic(){var t;return(null===(t=this._staticFields)||void 0===t?void 0:t.length)>0}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new f("ez-form")),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new _(this.dataUnit),this._store=R(z),this._store.subscribe((()=>s(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),v.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){const t=N(this._store.getState());t.addRequiredFields(this._staticFields.filter((t=>t.dataset.required)).map((t=>t.dataset.fieldName))),this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")),this.dataUnit.dataUnitId,t,this.recordsValidator),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(t){return t&&t.forEach((t=>t[v.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=d.toCamelCase(t.label))),t}render(){return i(n,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};x.style=".sc-ez-form-h{display:flex;flex-direction:column;width:100%}.dynamic-content.sc-ez-form ez-collapsible-box.sc-ez-form{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{x as ez_form}
|
|
1
|
+
import{r as t,c as e,h as i,f as s,H as n,g as r}from"./p-bfc7b8ca.js";import{UserInterface as o,DateUtils as a,Action as l,WaitingChangeException as h,ApplicationContext as c,DataUnitAction as u,StringUtils as d,DataUnit as f,ElementIDUtils as v}from"@sankhyalabs/core";import{A as p}from"./p-41ce6f98.js";import"./p-ab574d59.js";const b=/child\[([^\]]+)\]/,m=/\$\{.+\}/;class g{constructor(){this._sheets=new Map,this._requiredFields=[],this._cleanOnCopyFields=[],this._defaultValues={}}static getDetailName(t){const e=b.exec(t);return e?e[1]:void 0}getSheet(t){return this._sheets.get(t)}getAllSheets(){return this._sheets}addSheet(t){this._sheets.set(t.name,t)}addRequiredFields(t){this._requiredFields=this._requiredFields.concat(t)}getRequiredFields(){return this._requiredFields}addCleanOnCopyFields(t){this._cleanOnCopyFields=this._cleanOnCopyFields.concat(t)}getCleanOnCopyFields(){return this._cleanOnCopyFields}addDefaultValues(t){return this._defaultValues=Object.assign(Object.assign({},this._defaultValues),t)}getDefaultValues(){const t={};return Object.entries(this._defaultValues).forEach((([e,i])=>{if("string"==typeof i){const t=m.exec(i);t&&(i=this.getDefaultVar(t[0]))}t[e]=i})),t}getDefaultVar(t){return"${data}"===t?a.getToday():"${datahora}"===t?a.getToday(!0):this._defaultVars?this._defaultVars.get(t):void 0}setDefaultVars(t){this._defaultVars=t}}const y=(t,e)=>"__main"==t[0].label?-1:(t[0].order||1e4)-(e[0].order||1e4);class _{constructor(t){this.onDataUnitEvent=t=>{var e,i;switch(t.type){case l.DATA_LOADED:case l.DATA_SAVED:case l.RECORDS_REMOVED:case l.RECORDS_ADDED:case l.RECORDS_COPIED:case l.EDITION_CANCELED:case l.SELECTION_CHANGED:case l.NEXT_SELECTED:case l.PREVIOUS_SELECTED:this.clearInvalid();case l.DATA_CHANGED:case l.CHANGE_UNDONE:case l.CHANGE_REDONE:case l.RECORD_LOADED:null===(e=this._fields)||void 0===e||e.forEach((t=>{this.updateValue(t.fieldName,t.field)}));break;case l.FIELD_INVALIDATED:null===(i=this._fields)||void 0===i||i.forEach((t=>{this.updateErrorMessage(t.fieldName,t.field)}))}},this._fields=new Map,this._dataUnit=t,this.applyDefaultValues(),this._dataUnit.subscribe(this.onDataUnitEvent),this._dataUnit.addInterceptor(this)}applyDefaultValues(){const t=(this._dataUnit.getAddedRecords()||[]).map((t=>t.__record__id__));if(t.length>0){const e=this.getDefaultValues();e&&Object.keys(e).forEach((i=>{this._dataUnit.setFieldValue(i,e[i],t)}))}}bind(t,e,i,s){t.forEach((t=>{const{fieldName:i,contextName:s}=t.dataset;null!=s&&s!==e||this.updateBind(i,t)})),this._formMetadata=i,this._recordsValidator=s}onDisconnectedCallback(){this._dataUnit.unsubscribe(this.onDataUnitEvent),this._dataUnit.removeInterceptor(this)}getCurrentRecordId(){const t=this._dataUnit.getSelectedRecord();return null==t?void 0:t.__record__id__}markInvalid(t){if(this._dataUnit.setInvalidField(t.name,t.message,this.getCurrentRecordId()),this._fields.has(t.name)){const e=this._fields.get(t.name).field;this.updateErrorMessage(t.name,e,t.message)}}clearInvalid(t){this._dataUnit.clearInvalid(t),this._fields.forEach((t=>{t.field.errorMessage=""}))}updateValue(t,e){const i=this._fields.get(t);try{i&&(i.listen=!1),e.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,e)}finally{i&&(i.listen=!0)}}validate(){return new Promise(((t,e)=>{var i;const s=this._dataUnit.getModifiedRecords();for(let t=0;t<s.length;t++){const n=s[t],r=[];let o=this.validateRequired(n);if(o&&!o.isValid&&r.push(o),o=null===(i=this._recordsValidator)||void 0===i?void 0:i.validateRecord(n),o&&!o.isValid&&r.push(o),r.length>0){this.processValidationResult(r),e();break}}return t()}))}validateRequired(t){const e=this._formMetadata.getRequiredFields(),i=[];if(new Set(e).forEach((e=>{const s=t[e];if(null==s||""===s){const t=this.getErrorMessage(e);i.push(t?{name:e,message:t}:{name:e,message:"Essa informação é obrigatória"})}})),i.length>0)return{isValid:!1,invalidFields:i,infoMessage:"Há pelo menos um campo obrigatório não preenchido."}}processValidationResult(t){t.forEach((t=>{const e=t.invalidFields;if(e&&e.forEach((t=>{this.markInvalid(t)})),t.infoMessage&&p.info(t.infoMessage),t.errorMessage){const{errorTitle:e,errorMessage:i}=t;p.error(e,i)}}))}updateErrorMessage(t,e,i){null==i&&(i=this._dataUnit.getInvalidMessage(this.getCurrentRecordId(),t)),e.errorMessage||(e.errorMessage=i)}getErrorMessage(t){if(this._fields.has(t))return this._fields.get(t).field.errorMessage}updateBind(t,e){const i=this._fields.get(t);i&&i.destroy(),e.value=this._dataUnit.getFieldValue(t),this.updateErrorMessage(t,e),this._fields.set(t,w.create(t,e,((t,e)=>this.changeStarted(t,e)),(t=>this.cancelWaitingChange(t)),((t,e)=>this.setFieldValue(t,e)))),this.bindSearchOptionsLoader(t,e),this.applyEzUploadContext(t,e)}changeStarted(t,e){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),!e.blocking&&null==e.promise){const i=this._fields.get(t);i&&(e.promise=new Promise(((t,e)=>{i.waitingChangePromiseResolve=t,i.waitingChangePromiseReject=e})))}this._dataUnit.startChange(t,e)}cancelWaitingChange(t){if(this._dataUnit.waitingForChange(t)){this._dataUnit.cancelWaitingChange(t);const e=this._fields.get(t);e&&e.rejectWaitingChange(new h("Change canceled",t))}}setFieldValue(t,e){if(0===this._dataUnit.records.length&&this._dataUnit.addRecord(),this._dataUnit.clearInvalid(this.getCurrentRecordId(),t),this._dataUnit.setFieldValue(t,e),this._dataUnit.waitingForChange(t)){const e=this._fields.get(t);e&&e.acceptWaitingChange()}}bindSearchOptionsLoader(t,e){if("EZ-SEARCH"===e.nodeName&&null==e.optionLoader){const i=c.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");i&&(e.optionLoader=e=>i(e,t,this._dataUnit))}}applyEzUploadContext(t,e){var i,s;if("EZ-UPLOAD"===e.nodeName){e.urlUpload=c.getContextValue("__EZUI__UPLOAD__ADD__URL__"),e.urlDelete=c.getContextValue("__EZUI__UPLOAD__DEL__URL__");const n=this._dataUnit.getField(t),r=null===(i=n.properties)||void 0===i?void 0:i.DESTINATION;r&&(e.requestHeaders={XTRAINF:`{"destination": "${r}"}`}),e.maxFiles=(null===(s=n.properties)||void 0===s?void 0:s.MAX_FILES)||0}}interceptAction(t){if(t.type===l.RECORDS_COPIED){const e=this._formMetadata.getCleanOnCopyFields();if(e)return new u(l.RECORDS_COPIED,t.payload.map((t=>{const i=Object.assign({},t);return e.forEach((t=>delete i[t])),i})))}if(t.type===l.SAVING_DATA)return new Promise((e=>{this.validate().then((()=>e(t))).catch((()=>{}))}));if(t.type===l.RECORDS_ADDED){const e=this.getDefaultValues();if(e)return new u(l.RECORDS_ADDED,t.payload.map((t=>Object.assign(Object.assign({},t),e))))}return t}getDefaultValues(){var t;const e=null===(t=this._formMetadata)||void 0===t?void 0:t.getDefaultValues();if(e){const t={};for(const i in e)t[i]=this._dataUnit.valueFromString(i,e[i]);return t}}}class w{constructor(){this.listen=!0,this.startChangeEventName="ezStartChange",this.cancelWaitingChangeEventName="ezCancelWaitingChange",this.changeEventName="ezChange"}destroy(){this.field.removeEventListener(this.startChangeEventName,this.startChangeListener),this.field.removeEventListener(this.cancelWaitingChangeEventName,this.cancelWaitingChangeListener),this.field.removeEventListener(this.changeEventName,this.changeListener)}acceptWaitingChange(){this.waitingChangePromiseResolve&&(this.waitingChangePromiseResolve(),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}rejectWaitingChange(t){this.waitingChangePromiseReject&&(this.waitingChangePromiseReject(t),this.waitingChangePromiseReject=void 0,this.waitingChangePromiseResolve=void 0)}static create(t,e,i,s,n){const r=new w;return r.field=e,r.fieldName=t,r.startChangeListener=e=>{r.listen&&i(t,e.detail)},r.field.addEventListener(r.startChangeEventName,r.startChangeListener),r.cancelWaitingChangeListener=()=>{r.listen&&s(t)},r.field.addEventListener(r.cancelWaitingChangeEventName,r.cancelWaitingChangeListener),r.changeListener=e=>{r.listen&&n(t,e.detail)},r.field.addEventListener(r.changeEventName,r.changeListener),r}}function O(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var E="function"==typeof Symbol&&Symbol.observable||"@@observable",C=function(){return Math.random().toString(36).substring(7).split("").join(".")},A={INIT:"@@redux/INIT"+C(),REPLACE:"@@redux/REPLACE"+C(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+C()}};function j(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function R(t,e,i){var s;if("function"==typeof e&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(O(0));if("function"==typeof e&&void 0===i&&(i=e,e=void 0),void 0!==i){if("function"!=typeof i)throw new Error(O(1));return i(R)(t,e)}if("function"!=typeof t)throw new Error(O(2));var n=t,r=e,o=[],a=o,l=!1;function h(){a===o&&(a=o.slice())}function c(){if(l)throw new Error(O(3));return r}function u(t){if("function"!=typeof t)throw new Error(O(4));if(l)throw new Error(O(5));var e=!0;return h(),a.push(t),function(){if(e){if(l)throw new Error(O(6));e=!1,h();var i=a.indexOf(t);a.splice(i,1),o=null}}}function d(t){if(!j(t))throw new Error(O(7));if(void 0===t.type)throw new Error(O(8));if(l)throw new Error(O(9));try{l=!0,r=n(r,t)}finally{l=!1}for(var e=o=a,i=0;i<e.length;i++)(0,e[i])();return t}function f(t){if("function"!=typeof t)throw new Error(O(10));n=t,d({type:A.REPLACE})}function v(){var t,e=u;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(O(11));function i(){t.next&&t.next(c())}return i(),{unsubscribe:e(i)}}})[E]=function(){return this},t}return d({type:A.INIT}),(s={dispatch:d,subscribe:u,getState:c,replaceReducer:f})[E]=v,s}const D={};function z(t=D,e){switch(e.type){case S.METADATA_LOADED:return Object.assign(Object.assign({},t),{formMetadata:e.payload,currentSheet:void 0});case S.CHANGE_TAB:return Object.assign(Object.assign({},t),{currentSheet:e.payload});default:return t}}function N(t){return t.formMetadata}var S;!function(t){t.METADATA_LOADED="FORM/METADATA_LOADED",t.CHANGE_TAB="FORM/CHANGE_TAB"}(S||(S={}));const x=class{constructor(i){t(this,i),this.ezReady=e(this,"ezReady",7),this.onDataUnitAction=t=>{t.type===l.METADATA_LOADED&&this.processMetadata()},this.dataUnit=void 0,this.config=void 0,this.recordsValidator=void 0}validate(){return this._dataBinder.validate()}observeConfig(){this.processMetadata()}getDynamicContent(){var t;const e=N(this._store.getState());if(!e)return null;const s=Array.from(e.getAllSheets().values()),n=function(t){const e=function(t){return t.currentSheet}(t);return e?t.formMetadata.getSheet(e):Array.from(t.formMetadata.getAllSheets().values())[0]}(null===(t=this._store)||void 0===t?void 0:t.getState());let r=[];if(s.length>1){const t=s.map(((t,e)=>({tabKey:t.name,label:t.label,index:e}))),e="selector";r.push(i("ez-tabselector",{tabs:this.buildIdTabSelector(t),onEzChange:t=>this._store.dispatch(function(t){return{type:S.CHANGE_TAB,payload:"string"==typeof t?t:t.tabKey}}(t.detail)),selectedTab:n.name,"data-element-id":e}))}return r=r.concat(this.buildFormContent(n)),r}buildFormContent(t){const e=null==t?void 0:t.fields;if(null==t)return;const s=`${d.replaceAccentuatedChars(d.toCamelCase(null==t?void 0:t.label),!1)}_selectorContainer`;return i("div",{class:"dynamic-content","data-element-id":s},i("ez-form-view",{class:"ez-row ez-padding-vertical--small",fields:e}))}processMetadata(){if(!this.isStatic()&&this.dataUnit&&this._store){const t=((t,e,i=!1)=>{var s,n;null!=t&&!0!==(null==t?void 0:t.emptyConfig)||(t=(t=>{const e=t.metadata;let i;return e&&(i=e.fields.filter((t=>!1!==t.visible)).map((t=>({name:t.name,defaultValue:t.defaultValue})))),{emptyConfig:!1,fields:i}})(e));const r=new Map,a=new Map,l=[],h=[],c={};null===(s=null==t?void 0:t.tabs)||void 0===s||s.forEach((t=>{a.has(t.label)||!1!==t.visible||a.set(t.label,t)})),null===(n=null==t?void 0:t.fields)||void 0===n||n.forEach((t=>{var i,s,n;if(!1!==t.visible){const u=((t,e)=>("string"==typeof t?Array.from(e.keys()).find((e=>e.label===t)):t)||{label:t,visible:!0})(t.tab||"__main",r);if(a.has(u.label))return;const d=e.getField(t.name);if(d&&u.visible){r.has(u)||r.set(u,[]);const e=((t,e)=>{let i,s,{name:n,label:r,group:a}=Object.assign({},e),{readOnly:l,required:h}=Object.assign({},e);return t&&(r=r||t.label,n=n||t.name,h=t.required||(null==e?void 0:e.required),l=t.readOnly||(null==e?void 0:e.readOnly),i=t.properties,s=t.userInterface),{name:n,label:r,group:a,readOnly:l,required:h,props:i,userInterface:s||o.SHORTTEXT}})(d,t);r.get(u).push(e),e.required&&l.push(t.name),((null==t.cleanOnCopy?null===(i=d.properties)||void 0===i?void 0:i.cleanOnCopy:t.cleanOnCopy)||(null===(s=d.properties)||void 0===s?void 0:s.cleanOnCopy))&&h.push(t.name);let a=null==t.defaultValue?null===(n=d.properties)||void 0===n?void 0:n.defaultValue:t.defaultValue;if(a){const{type:e,value:i}=a;if(e)if("V"===e)a=i;else try{const t=JSON.parse(i);a=t&&"value"in t?t:i}catch(t){}c[t.name]=a}}}}));const u=new g;if(u.setDefaultVars(t.defaultVars),i){const t=e.metadata;null!=t&&null!=t.children&&t.children.forEach((t=>{const{label:e,name:i,fields:s}=(t=>({name:`child[${t.name}]`,label:t.label,fields:[]}))(t);r.set({name:i,label:e},s)}))}return Array.from(r.entries()).sort(y).forEach((([t,e])=>{u.addSheet({label:"__main"===t.label?"Principal":t.label,name:t.name||t.label,fields:e})})),u.addRequiredFields(l),u.addCleanOnCopyFields(h),u.addDefaultValues(c),u})(this.config,this.dataUnit);this._store.dispatch({type:S.METADATA_LOADED,payload:t})}}isStatic(){var t;return(null===(t=this._staticFields)||void 0===t?void 0:t.length)>0}componentWillLoad(){void 0===this.dataUnit&&(this.dataUnit=new f("ez-form")),this.dataUnit.subscribe(this.onDataUnitAction),this._dataBinder=new _(this.dataUnit),this._store=R(z),this._store.subscribe((()=>s(this))),this._staticFields=Array.from(this._element.querySelectorAll("[data-field-name]")),this.processMetadata(),v.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}componentDidRender(){const t=N(this._store.getState());t.addRequiredFields(this._staticFields.filter((t=>t.dataset.required)).map((t=>t.dataset.fieldName))),this._dataBinder.bind(Array.from(this._element.querySelectorAll("[data-field-name]")),this.dataUnit.dataUnitId,t,this.recordsValidator),this.ezReady.emit()}disconnectedCallback(){this.dataUnit.unsubscribe(this.onDataUnitAction),this._dataBinder.onDisconnectedCallback()}buildIdTabSelector(t){return t&&t.forEach((t=>t[v.DATA_ELEMENT_ID_ATTRIBUTE_NAME]=d.toCamelCase(t.label))),t}render(){return i(n,null,this.isStatic()?null:this.getDynamicContent())}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};x.style=".sc-ez-form-h{display:flex;flex-direction:column;width:100%}.dynamic-content.sc-ez-form ez-collapsible-box.sc-ez-form{--ez-collapsible-box__header--padding-right:var(--space-small, 6px);--ez-collapsible-box__header--padding-left:var(--space-small, 6px)}";export{x as ez_form}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import { DialogType } from "../components/ez-dialog/DialogType";
|
|
2
|
+
import { THeightMode } from "../components/ez-modal/ez-modal";
|
|
2
3
|
export default class ApplicationUtils {
|
|
3
|
-
private static showDialog;
|
|
4
4
|
private static defaultMessageOptions;
|
|
5
|
+
private static defaultModalProps;
|
|
6
|
+
private static showDialog;
|
|
5
7
|
static alert(title: string, message: string, icon?: string, options?: MessageOptions): Promise<boolean>;
|
|
6
8
|
static error(title: string, message: string, icon?: string, options?: MessageOptions): Promise<boolean>;
|
|
7
9
|
static success(title: string, message: string, icon?: string, options?: MessageOptions): Promise<boolean>;
|
|
8
10
|
static confirm(title: string, message: string, icon?: string, dialogType?: DialogType, options?: MessageOptions): Promise<boolean>;
|
|
9
11
|
static message(title: string, message: string, icon?: string, options?: MessageOptions): Promise<boolean>;
|
|
10
12
|
static info(message: string, options?: MessageOptions): Promise<void>;
|
|
13
|
+
static showModal(modalProps: IModalProps): Promise<Function>;
|
|
14
|
+
}
|
|
15
|
+
export interface IModalProps {
|
|
16
|
+
content: HTMLElement | string;
|
|
17
|
+
position?: "left" | "right";
|
|
18
|
+
size?: string;
|
|
19
|
+
heightMode?: keyof THeightMode;
|
|
20
|
+
closeOutsideClick?: boolean;
|
|
21
|
+
closeEsc?: boolean;
|
|
11
22
|
}
|
|
12
23
|
export interface MessageOptions {
|
|
13
24
|
canClose?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sankhyalabs/ezui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.0",
|
|
4
4
|
"description": "Biblioteca de componentes Sankhya.",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/custom-elements/index.js",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"@storybook/html": "^6.4.17",
|
|
64
64
|
"@types/jest": "^26.0.20",
|
|
65
65
|
"@types/puppeteer": "^5.4.2",
|
|
66
|
+
"@types/uuid": "^9.0.2",
|
|
66
67
|
"ag-grid-community": "^28.1.1",
|
|
67
68
|
"ag-grid-enterprise": "^28.1.1",
|
|
68
69
|
"gulp": "^4.0.2",
|
|
@@ -79,6 +80,7 @@
|
|
|
79
80
|
"run-p": "0.0.0",
|
|
80
81
|
"semantic-release": "^17.4.3",
|
|
81
82
|
"storybook-addon-preview": "^2.2.0",
|
|
83
|
+
"uuid": "^9.0.0",
|
|
82
84
|
"ws": "^7.5.6"
|
|
83
85
|
},
|
|
84
86
|
"jest": {
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const DialogType = require('./DialogType-2114c337.js');
|
|
4
|
-
|
|
5
|
-
class ApplicationUtils {
|
|
6
|
-
static async showDialog(title, message, icon = null, confirm, dialogType = DialogType.DialogType.DEFAULT, options) {
|
|
7
|
-
if (options) {
|
|
8
|
-
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
9
|
-
}
|
|
10
|
-
return new Promise(resolve => {
|
|
11
|
-
let dialog = document.querySelector("ez-dialog");
|
|
12
|
-
if (!dialog) {
|
|
13
|
-
dialog = document.createElement("ez-dialog");
|
|
14
|
-
window.document.body.appendChild(dialog);
|
|
15
|
-
}
|
|
16
|
-
dialog.show(title, message, dialogType, confirm, icon, options.labelCancel, options.labelConfirm, options.btnConfirmDanger, options.beforeClose).then(ok => resolve(ok));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
static async alert(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
20
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.WARN, options);
|
|
21
|
-
}
|
|
22
|
-
static async error(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
23
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.CRITICAL, options);
|
|
24
|
-
}
|
|
25
|
-
static async success(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
26
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.SUCCESS, options);
|
|
27
|
-
}
|
|
28
|
-
static async confirm(title, message, icon = null, dialogType = DialogType.DialogType.WARN, options = ApplicationUtils.defaultMessageOptions) {
|
|
29
|
-
return ApplicationUtils.showDialog(title, message, icon, true, dialogType, options);
|
|
30
|
-
}
|
|
31
|
-
static async message(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
32
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DialogType.DEFAULT, options);
|
|
33
|
-
}
|
|
34
|
-
static async info(message, options = ApplicationUtils.defaultMessageOptions) {
|
|
35
|
-
if (options !== ApplicationUtils.defaultMessageOptions) {
|
|
36
|
-
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
37
|
-
}
|
|
38
|
-
let useIcon = false;
|
|
39
|
-
let toast = document.querySelector("ez-toast");
|
|
40
|
-
if (!toast) {
|
|
41
|
-
toast = document.createElement("ez-toast");
|
|
42
|
-
const icon = document.createElement("ez-icon");
|
|
43
|
-
icon.className = "ez-margin-right--small";
|
|
44
|
-
icon.slot = "icon";
|
|
45
|
-
icon.style.setProperty("--ez-icon--color", "var(--color--success)");
|
|
46
|
-
toast.appendChild(icon);
|
|
47
|
-
window.document.body.appendChild(toast);
|
|
48
|
-
}
|
|
49
|
-
if (options.iconName) {
|
|
50
|
-
const iconElem = toast.querySelector("ez-icon");
|
|
51
|
-
if (iconElem) {
|
|
52
|
-
iconElem.iconName = options.iconName;
|
|
53
|
-
useIcon = true;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
useIcon = false;
|
|
58
|
-
}
|
|
59
|
-
toast.show(message, 5000, useIcon, options.canClose);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
ApplicationUtils.defaultMessageOptions = {
|
|
63
|
-
canClose: true,
|
|
64
|
-
labelCancel: 'Não',
|
|
65
|
-
labelConfirm: 'Sim',
|
|
66
|
-
btnConfirmDanger: false
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.ApplicationUtils = ApplicationUtils;
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { D as DialogType } from './DialogType-54a62731.js';
|
|
2
|
-
|
|
3
|
-
class ApplicationUtils {
|
|
4
|
-
static async showDialog(title, message, icon = null, confirm, dialogType = DialogType.DEFAULT, options) {
|
|
5
|
-
if (options) {
|
|
6
|
-
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
7
|
-
}
|
|
8
|
-
return new Promise(resolve => {
|
|
9
|
-
let dialog = document.querySelector("ez-dialog");
|
|
10
|
-
if (!dialog) {
|
|
11
|
-
dialog = document.createElement("ez-dialog");
|
|
12
|
-
window.document.body.appendChild(dialog);
|
|
13
|
-
}
|
|
14
|
-
dialog.show(title, message, dialogType, confirm, icon, options.labelCancel, options.labelConfirm, options.btnConfirmDanger, options.beforeClose).then(ok => resolve(ok));
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
static async alert(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
18
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.WARN, options);
|
|
19
|
-
}
|
|
20
|
-
static async error(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
21
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.CRITICAL, options);
|
|
22
|
-
}
|
|
23
|
-
static async success(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
24
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.SUCCESS, options);
|
|
25
|
-
}
|
|
26
|
-
static async confirm(title, message, icon = null, dialogType = DialogType.WARN, options = ApplicationUtils.defaultMessageOptions) {
|
|
27
|
-
return ApplicationUtils.showDialog(title, message, icon, true, dialogType, options);
|
|
28
|
-
}
|
|
29
|
-
static async message(title, message, icon = null, options = ApplicationUtils.defaultMessageOptions) {
|
|
30
|
-
return ApplicationUtils.showDialog(title, message, icon, false, DialogType.DEFAULT, options);
|
|
31
|
-
}
|
|
32
|
-
static async info(message, options = ApplicationUtils.defaultMessageOptions) {
|
|
33
|
-
if (options !== ApplicationUtils.defaultMessageOptions) {
|
|
34
|
-
options = Object.assign(Object.assign({}, ApplicationUtils.defaultMessageOptions), options);
|
|
35
|
-
}
|
|
36
|
-
let useIcon = false;
|
|
37
|
-
let toast = document.querySelector("ez-toast");
|
|
38
|
-
if (!toast) {
|
|
39
|
-
toast = document.createElement("ez-toast");
|
|
40
|
-
const icon = document.createElement("ez-icon");
|
|
41
|
-
icon.className = "ez-margin-right--small";
|
|
42
|
-
icon.slot = "icon";
|
|
43
|
-
icon.style.setProperty("--ez-icon--color", "var(--color--success)");
|
|
44
|
-
toast.appendChild(icon);
|
|
45
|
-
window.document.body.appendChild(toast);
|
|
46
|
-
}
|
|
47
|
-
if (options.iconName) {
|
|
48
|
-
const iconElem = toast.querySelector("ez-icon");
|
|
49
|
-
if (iconElem) {
|
|
50
|
-
iconElem.iconName = options.iconName;
|
|
51
|
-
useIcon = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
useIcon = false;
|
|
56
|
-
}
|
|
57
|
-
toast.show(message, 5000, useIcon, options.canClose);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
ApplicationUtils.defaultMessageOptions = {
|
|
61
|
-
canClose: true,
|
|
62
|
-
labelCancel: 'Não',
|
|
63
|
-
labelConfirm: 'Sim',
|
|
64
|
-
btnConfirmDanger: false
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export { ApplicationUtils as A };
|
package/dist/ezui/p-ab2a3006.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{D as e}from"./p-ab574d59.js";class n{static async showDialog(t,c,s=null,o,a=e.DEFAULT,l){return l&&(l=Object.assign(Object.assign({},n.defaultMessageOptions),l)),new Promise((e=>{let n=document.querySelector("ez-dialog");n||(n=document.createElement("ez-dialog"),window.document.body.appendChild(n)),n.show(t,c,a,o,s,l.labelCancel,l.labelConfirm,l.btnConfirmDanger,l.beforeClose).then((n=>e(n)))}))}static async alert(t,c,s=null,o=n.defaultMessageOptions){return n.showDialog(t,c,s,!1,e.WARN,o)}static async error(t,c,s=null,o=n.defaultMessageOptions){return n.showDialog(t,c,s,!1,e.CRITICAL,o)}static async success(t,c,s=null,o=n.defaultMessageOptions){return n.showDialog(t,c,s,!1,e.SUCCESS,o)}static async confirm(t,c,s=null,o=e.WARN,a=n.defaultMessageOptions){return n.showDialog(t,c,s,!0,o,a)}static async message(t,c,s=null,o=n.defaultMessageOptions){return n.showDialog(t,c,s,!1,e.DEFAULT,o)}static async info(e,t=n.defaultMessageOptions){t!==n.defaultMessageOptions&&(t=Object.assign(Object.assign({},n.defaultMessageOptions),t));let c=!1,s=document.querySelector("ez-toast");if(!s){s=document.createElement("ez-toast");const e=document.createElement("ez-icon");e.className="ez-margin-right--small",e.slot="icon",e.style.setProperty("--ez-icon--color","var(--color--success)"),s.appendChild(e),window.document.body.appendChild(s)}if(t.iconName){const e=s.querySelector("ez-icon");e&&(e.iconName=t.iconName,c=!0)}else c=!1;s.show(e,5e3,c,t.canClose)}}n.defaultMessageOptions={canClose:!0,labelCancel:"Não",labelConfirm:"Sim",btnConfirmDanger:!1};export{n as A}
|