@sankhyalabs/ezui 1.2.0-beta.4 → 1.2.0-beta.7
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-483c0a9e.js → ApplicationUtils-2ac1b73e.js} +2 -1
- package/dist/cjs/ApplicationUtils-475b50d9.js +63 -0
- package/dist/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/css-shim-3bfdba4f.js +6 -0
- package/dist/cjs/dom-8ac1ad03.js +75 -0
- package/dist/cjs/ez-actions-button.cjs.entry.js +7 -6
- package/dist/cjs/ez-application.cjs.entry.js +1 -1
- package/dist/cjs/ez-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-calendar.cjs.entry.js +4 -4
- package/dist/cjs/ez-card-item.cjs.entry.js +1 -1
- package/dist/cjs/ez-check.cjs.entry.js +1 -1
- package/dist/cjs/ez-chip.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 +7 -6
- package/dist/cjs/ez-date-input.cjs.entry.js +6 -6
- package/dist/cjs/ez-date-time-input.cjs.entry.js +4 -4
- package/dist/cjs/ez-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ez-filter-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-form.cjs.entry.js +460 -49
- package/dist/cjs/ez-grid-config.cjs.entry.js +5 -5
- package/dist/cjs/ez-grid.cjs.entry.js +1167 -985
- package/dist/cjs/ez-icon.cjs.entry.js +3 -3
- package/dist/cjs/ez-list.cjs.entry.js +3 -1
- package/dist/cjs/ez-loading-bar.cjs.entry.js +1 -1
- package/dist/cjs/ez-modal.cjs.entry.js +1 -1
- package/dist/cjs/ez-number-input.cjs.entry.js +4 -4
- package/dist/cjs/ez-popover.cjs.entry.js +5 -5
- package/dist/cjs/ez-popup.cjs.entry.js +1 -1
- package/dist/cjs/ez-radio-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-scroller.cjs.entry.js +1 -1
- package/dist/cjs/ez-search.cjs.entry.js +1 -1
- package/dist/cjs/ez-select-box.cjs.entry.js +1 -1
- package/dist/cjs/ez-tabselector.cjs.entry.js +2 -1
- package/dist/cjs/ez-text-area.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-input.cjs.entry.js +3 -3
- package/dist/cjs/ez-time-input.cjs.entry.js +7 -7
- package/dist/cjs/ez-toast.cjs.entry.js +1 -1
- package/dist/cjs/ez-upload.cjs.entry.js +2 -2
- package/dist/cjs/ez-view-stack.cjs.entry.js +2 -1
- package/dist/cjs/ezui.cjs.js +112 -4
- package/dist/cjs/index-0ad7c3e4.js +6 -0
- package/dist/cjs/index-2ec1da82.js +2307 -0
- package/dist/cjs/index-d9c5cb88.js +3068 -0
- package/dist/cjs/loader.cjs.js +18 -2
- package/dist/cjs/shadow-css-41d9783d.js +390 -0
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +19 -1
- package/dist/collection/utils/ApplicationUtils.js +2 -1
- package/dist/custom-elements/index.js +3863 -968
- package/dist/esm/ApplicationUtils-30a69eb0.js +61 -0
- package/dist/esm/{ApplicationUtils-5f87ae60.js → ApplicationUtils-a4a76132.js} +2 -1
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/css-shim-20dbffa5.js +4 -0
- package/dist/esm/dom-c5ed0ba5.js +73 -0
- package/dist/esm/ez-actions-button.entry.js +4 -3
- package/dist/esm/ez-application.entry.js +1 -1
- package/dist/esm/ez-button.entry.js +1 -1
- package/dist/esm/ez-calendar.entry.js +2 -2
- package/dist/esm/ez-card-item.entry.js +1 -1
- package/dist/esm/ez-check.entry.js +1 -1
- package/dist/esm/ez-chip.entry.js +1 -1
- package/dist/esm/ez-collapsible-box.entry.js +1 -1
- package/dist/esm/ez-combo-box.entry.js +4 -3
- package/dist/esm/ez-date-input.entry.js +2 -2
- package/dist/esm/ez-date-time-input.entry.js +2 -2
- package/dist/esm/ez-dialog.entry.js +1 -1
- package/dist/esm/ez-filter-input.entry.js +1 -1
- package/dist/esm/ez-form.entry.js +426 -15
- package/dist/esm/ez-grid-config.entry.js +3 -3
- package/dist/esm/ez-grid.entry.js +1138 -956
- package/dist/esm/ez-icon.entry.js +2 -2
- package/dist/esm/ez-list.entry.js +3 -1
- package/dist/esm/ez-loading-bar.entry.js +1 -1
- package/dist/esm/ez-modal.entry.js +1 -1
- package/dist/esm/ez-number-input.entry.js +2 -2
- package/dist/esm/ez-popover.entry.js +2 -2
- package/dist/esm/ez-popup.entry.js +1 -1
- package/dist/esm/ez-radio-button.entry.js +1 -1
- package/dist/esm/ez-scroller.entry.js +1 -1
- package/dist/esm/ez-search.entry.js +1 -1
- package/dist/esm/ez-select-box.entry.js +1 -1
- package/dist/esm/ez-tabselector.entry.js +2 -1
- package/dist/esm/ez-text-area.entry.js +1 -1
- package/dist/esm/ez-text-input.entry.js +2 -2
- package/dist/esm/ez-time-input.entry.js +2 -2
- package/dist/esm/ez-toast.entry.js +1 -1
- package/dist/esm/ez-upload.entry.js +2 -2
- package/dist/esm/ez-view-stack.entry.js +2 -1
- package/dist/esm/ezui.js +112 -4
- package/dist/esm/index-12b43518.js +3 -0
- package/dist/esm/index-1e9d524f.js +3031 -0
- package/dist/esm/index-b96183c8.js +2295 -0
- package/dist/esm/loader.js +18 -2
- package/dist/esm/shadow-css-8c625855.js +388 -0
- package/dist/ezui/ApplicationUtils-30a69eb0.js +61 -0
- package/dist/ezui/CSSVarsUtils-499b75c2.js +53 -0
- package/dist/ezui/DialogType-72afa679.js +8 -0
- package/dist/ezui/app-globals-0f993ce5.js +3 -0
- package/dist/ezui/css-shim-20dbffa5.js +4 -0
- package/dist/ezui/dom-c5ed0ba5.js +73 -0
- package/dist/ezui/ez-actions-button.entry.js +98 -0
- package/dist/ezui/ez-application.entry.js +22 -0
- package/dist/ezui/ez-button.entry.js +73 -0
- package/dist/ezui/ez-calendar.entry.js +219 -0
- package/dist/ezui/ez-card-item.entry.js +40 -0
- package/dist/ezui/ez-check.entry.js +72 -0
- package/dist/ezui/ez-chip.entry.js +97 -0
- package/dist/ezui/ez-collapsible-box.entry.js +57 -0
- package/dist/ezui/ez-combo-box.entry.js +439 -0
- package/dist/ezui/ez-date-input.entry.js +159 -0
- package/dist/ezui/ez-date-time-input.entry.js +214 -0
- package/dist/ezui/ez-dialog.entry.js +108 -0
- package/dist/ezui/ez-filter-input.entry.js +75 -0
- package/dist/ezui/ez-form.entry.js +1395 -0
- package/dist/ezui/ez-grid-config.entry.js +433 -0
- package/dist/ezui/ez-grid.entry.js +115419 -0
- package/dist/ezui/ez-icon.entry.js +37 -0
- package/dist/ezui/ez-list.entry.js +516 -0
- package/dist/ezui/ez-loading-bar.entry.js +24 -0
- package/dist/ezui/ez-modal.entry.js +67 -0
- package/dist/ezui/ez-number-input.entry.js +148 -0
- package/dist/ezui/ez-popover.entry.js +141 -0
- package/dist/ezui/ez-popup.entry.js +49 -0
- package/dist/ezui/ez-radio-button.entry.js +45 -0
- package/dist/ezui/ez-scroller.entry.js +101 -0
- package/dist/ezui/ez-search.entry.js +83 -0
- package/dist/ezui/ez-select-box.entry.js +18 -0
- package/dist/ezui/ez-tabselector.entry.js +195 -0
- package/dist/ezui/ez-text-area.entry.js +158 -0
- package/dist/ezui/ez-text-input.entry.js +235 -0
- package/dist/ezui/ez-time-input.entry.js +164 -0
- package/dist/ezui/ez-toast.entry.js +84 -0
- package/dist/ezui/ez-upload.entry.js +379 -0
- package/dist/ezui/ez-view-stack.entry.js +74 -0
- package/dist/ezui/ezui.esm.js +125 -1
- package/dist/ezui/index-12b43518.js +3 -0
- package/dist/ezui/index-1e9d524f.js +3031 -0
- package/dist/ezui/index-b96183c8.js +2295 -0
- package/dist/ezui/index.esm.js +1 -0
- package/dist/ezui/{p-72ab066f.entry.js → p-4eb273f8.entry.js} +1 -1
- package/dist/ezui/{p-d9c72ff7.entry.js → p-88bfdea4.entry.js} +1 -1
- package/dist/ezui/p-adbe4188.js +1 -0
- package/dist/ezui/{p-6cfe20a0.entry.js → p-af43be42.entry.js} +1 -1
- package/dist/ezui/{p-47e06040.entry.js → p-c9d2060e.entry.js} +1 -1
- package/dist/ezui/{p-3ae441ec.entry.js → p-d836f546.entry.js} +1 -1
- package/dist/ezui/{p-7fe1ac9a.entry.js → p-e55fc20f.entry.js} +1 -1
- package/dist/ezui/shadow-css-8c625855.js +388 -0
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +1 -0
- package/package.json +2 -2
- package/dist/ezui/p-898b9906.js +0 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, f as Host, g as getElement } from './index-1e9d524f.js';
|
|
2
|
+
|
|
3
|
+
const ezTabselectorCss = "@keyframes activate{0%{clip-path:inset(calc(100% - 3px) 50% 0px 50%)}100%{clip-path:inset(calc(100% - 3px) 0px 0px 0px)}}:host{display:flex;position:relative;width:100%;overflow:hidden;--tabselector--backward-icon:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 9.7808475,13.860393 3.9204526,8.0000004 9.7808475,2.0624965 7.9301965,0.28895552 0.21915255,8.0000004 7.9301965,15.711044 Z\"/></svg>');--tabselector--forward-icon:url('data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" height=\"16px\" width=\"10px\"><path d=\"M 0.21915251,13.860393 6.0795475,8.0000007 0.21915251,2.0624968 2.0698036,0.28895588 9.7808475,8.0000007 2.0698036,15.711044 Z\"/></svg>')}.scroll{display:flex;width:100%;scroll-behavior:smooth;overflow-x:auto;scrollbar-width:none}.scroll.startHidden{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px)}.scroll.middle{-webkit-mask-image:linear-gradient(90deg, transparent 20px, #000 48px, #000 calc(100% - 48px), transparent calc(100% - 20px))}.scroll.endHidden{-webkit-mask-image:linear-gradient(90deg, #000 calc(100% - 48px), transparent calc(100% - 20px))}.tab{display:flex;border:none;min-width:100px;background-color:unset;cursor:pointer;padding:6px 12px;align-items:center;justify-content:center;color:var(--text--primary, #626e82);font-family:var(--font-pattern, \"Sora, Algerian\");font-size:var(--title--small, 14px)}.tab:focus,.forward-button,.backward-button{outline:none}.is-active{position:relative;color:var(--color--primary, #008561)}.is-active::after{content:\"\";position:absolute;width:100%;height:100%;background-color:var(--color--primary, #008561);clip-path:inset(calc(100% - 3px) 0px 0px 0px);animation:activate 0.25s ease-in-out}.is-focused{border:1px dashed var(--color--primary, #000000c5)}.tab-label{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-shadow:var(--text-shadow);margin-bottom:var(--space--extra-small, 3px)}.forward-button,.backward-button{position:absolute;z-index:1;display:flex;box-sizing:border-box;padding:0px;top:0px;right:0px;width:16px;height:100%;border:none;background-color:unset;cursor:pointer;justify-content:center;align-items:center}.backward-button{left:0px}.forward-button::after,.backward-button::after{content:'';display:flex;background-color:var(--text--primary, #008561);width:10px;height:16px}.forward-button::after{-webkit-mask-image:var(--tabselector--forward-icon);mask-image:var(--tabselector--forward-icon)}.backward-button::after{-webkit-mask-image:var(--tabselector--backward-icon);mask-image:var(--tabselector--backward-icon)}.forward-button:hover::after,.backward-button:hover::after{background-color:var(--color--primary, #4e4e4e)}.hidden{display:none}.scroll::-webkit-scrollbar{display:none}";
|
|
4
|
+
|
|
5
|
+
let EzTabselector = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
8
|
+
this.ezChange = createEvent(this, "ezChange", 7);
|
|
9
|
+
this.setFocusedParam = (ev) => {
|
|
10
|
+
if (ev.key === "Enter") {
|
|
11
|
+
const selectedTab = this._processedTabs[this._focusedIndex];
|
|
12
|
+
this.handleTabClick(selectedTab);
|
|
13
|
+
ev.preventDefault();
|
|
14
|
+
this.setFocusedTab(selectedTab.index);
|
|
15
|
+
}
|
|
16
|
+
else if (ev.key === "ArrowLeft" || ev.key === "ArrowRight") {
|
|
17
|
+
let operator = undefined;
|
|
18
|
+
if (ev.key === "ArrowLeft") {
|
|
19
|
+
operator = false;
|
|
20
|
+
}
|
|
21
|
+
else if (ev.key === "ArrowRight") {
|
|
22
|
+
operator = true;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (this._focusedIndex === undefined) {
|
|
28
|
+
if (operator === false) {
|
|
29
|
+
this._focusedIndex = this.selectedIndex !== undefined ? this.selectedIndex - 1 : undefined;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this._focusedIndex = this.selectedIndex !== undefined ? this.selectedIndex + 1 : undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
if (operator === false) {
|
|
37
|
+
this._focusedIndex = this._focusedIndex - 1;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this._focusedIndex = this._focusedIndex + 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (this._focusedIndex < 0) {
|
|
44
|
+
this._focusedIndex = 0;
|
|
45
|
+
}
|
|
46
|
+
else if (this._focusedIndex > this._processedTabs.length - 1) {
|
|
47
|
+
this._focusedIndex = this._processedTabs.length - 1;
|
|
48
|
+
}
|
|
49
|
+
this.setFocusedBtn(true, this._focusedIndex);
|
|
50
|
+
this.setFocusedTab(this._focusedIndex);
|
|
51
|
+
}
|
|
52
|
+
else if (ev.key === "Tab" || ev.key === "Escape") {
|
|
53
|
+
const currentTab = this._processedTabs[this.selectedIndex];
|
|
54
|
+
this._focusedIndex = undefined;
|
|
55
|
+
this.handleTabClick(currentTab);
|
|
56
|
+
ev.preventDefault();
|
|
57
|
+
this.setFocusedTab(this.selectedIndex);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
handleTabClick(tab) {
|
|
62
|
+
this.selectedIndex = tab.index;
|
|
63
|
+
this._focusedIndex = undefined;
|
|
64
|
+
this.selectedTab = tab.tabKey;
|
|
65
|
+
this.ezChange.emit(tab);
|
|
66
|
+
this.setFocusedBtn(false, tab.index);
|
|
67
|
+
}
|
|
68
|
+
componentWillRender() {
|
|
69
|
+
if (!this._processedTabs) {
|
|
70
|
+
this._processedTabs = [];
|
|
71
|
+
if (this.tabs) {
|
|
72
|
+
this.tabs.split(",").forEach((label) => {
|
|
73
|
+
label = label.trim();
|
|
74
|
+
this._processedTabs.push({ label, tabKey: label, index: this._processedTabs.length });
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
this._hostElem.querySelectorAll("ez-tab").forEach((elem) => {
|
|
78
|
+
const tabKey = elem.getAttribute("tabKey");
|
|
79
|
+
const label = elem.getAttribute("label");
|
|
80
|
+
const t = { label, tabKey, index: this._processedTabs.length };
|
|
81
|
+
const content = elem.firstChild;
|
|
82
|
+
if (content) {
|
|
83
|
+
content.setAttribute("slot", "tab" + t.index);
|
|
84
|
+
this._hostElem.appendChild(content);
|
|
85
|
+
}
|
|
86
|
+
this._processedTabs.push(t);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
handleSlotChange(ev) {
|
|
91
|
+
const slot = ev.target;
|
|
92
|
+
const content = slot.assignedElements()[0];
|
|
93
|
+
if (content) {
|
|
94
|
+
content.style.marginLeft = "6px";
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
scrollBackward() {
|
|
98
|
+
const container = this._scrollContainer;
|
|
99
|
+
if (container) {
|
|
100
|
+
container.scrollLeft -= container.clientWidth;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
scrollFoward() {
|
|
104
|
+
const container = this._scrollContainer;
|
|
105
|
+
if (container) {
|
|
106
|
+
let lastTab = null;
|
|
107
|
+
container.querySelectorAll(".tab").forEach((tab) => {
|
|
108
|
+
if (tab.getBoundingClientRect().right < container.clientWidth) {
|
|
109
|
+
lastTab = tab;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
componentDidRender() {
|
|
116
|
+
this.updateScroll();
|
|
117
|
+
}
|
|
118
|
+
updateScroll() {
|
|
119
|
+
const container = this._scrollContainer;
|
|
120
|
+
if (container) {
|
|
121
|
+
const { scrollWidth, clientWidth, scrollLeft } = container;
|
|
122
|
+
const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
|
|
123
|
+
this._startHidden = container.scrollLeft > 0;
|
|
124
|
+
this._endHidden = remainingScroll > 0;
|
|
125
|
+
if (this._startHidden) {
|
|
126
|
+
this._backwardButton.classList.remove("hidden");
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
this._backwardButton.classList.add("hidden");
|
|
130
|
+
}
|
|
131
|
+
if (this._endHidden) {
|
|
132
|
+
this._forwardButton.classList.remove("hidden");
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this._forwardButton.classList.add("hidden");
|
|
136
|
+
}
|
|
137
|
+
const classNames = ["", "startHidden", "endHidden", "middle"];
|
|
138
|
+
const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
|
|
139
|
+
classNames.forEach((name) => {
|
|
140
|
+
if (name !== currentClass && container.classList.contains(name)) {
|
|
141
|
+
container.classList.remove(name);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
if (currentClass && !container.classList.contains(currentClass)) {
|
|
145
|
+
container.classList.add(currentClass);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
domScrollHandler() {
|
|
150
|
+
window.clearTimeout(this._scrollCallBack);
|
|
151
|
+
this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
|
|
152
|
+
}
|
|
153
|
+
setFocusedTab(index) {
|
|
154
|
+
window.clearTimeout(this._scrollCallBackTest);
|
|
155
|
+
this._scrollCallBackTest = window.setTimeout(() => {
|
|
156
|
+
const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
|
|
157
|
+
tabtoscroll.scrollIntoView();
|
|
158
|
+
}, 200);
|
|
159
|
+
}
|
|
160
|
+
getTextWidth(text) {
|
|
161
|
+
if (this._textMesurement === undefined) {
|
|
162
|
+
this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
|
|
163
|
+
}
|
|
164
|
+
const context = this._textMesurement.getContext("2d");
|
|
165
|
+
context.font = "14px Sora, Algerian";
|
|
166
|
+
return Math.min(220, 24 + context.measureText(text).width) + "px";
|
|
167
|
+
}
|
|
168
|
+
;
|
|
169
|
+
setFocusedBtn(visible, parameter) {
|
|
170
|
+
const tabsButtons = this._scrollContainer.querySelectorAll(".tab");
|
|
171
|
+
tabsButtons.forEach((el) => {
|
|
172
|
+
el.classList.remove("is-focused");
|
|
173
|
+
if (el.id === "tab" + parameter && visible) {
|
|
174
|
+
el.classList.add("is-focused");
|
|
175
|
+
}
|
|
176
|
+
;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
render() {
|
|
180
|
+
return (h(Host, null, h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }), h("div", { class: "scroll", ref: (el) => this._scrollContainer = el, onScroll: () => this.domScrollHandler(), onKeyDown: (ev) => this.setFocusedParam(ev) }, this._processedTabs.map((tab, index) => {
|
|
181
|
+
const labelStyle = { "min-width": this.getTextWidth(tab.label) };
|
|
182
|
+
const tabId = "tab" + index;
|
|
183
|
+
const isSelected = index === this.selectedIndex || (this.selectedTab && tab.tabKey === this.selectedTab);
|
|
184
|
+
if (isSelected) {
|
|
185
|
+
this.selectedTab = tab.tabKey;
|
|
186
|
+
this.selectedIndex = index;
|
|
187
|
+
}
|
|
188
|
+
return h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab), style: labelStyle }, h("span", { class: "tab-label", title: tab.label }, tab.label), h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
|
|
189
|
+
})), h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
|
|
190
|
+
}
|
|
191
|
+
get _hostElem() { return getElement(this); }
|
|
192
|
+
};
|
|
193
|
+
EzTabselector.style = ezTabselectorCss;
|
|
194
|
+
|
|
195
|
+
export { EzTabselector as ez_tabselector };
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, f as Host, g as getElement } from './index-1e9d524f.js';
|
|
2
|
+
|
|
3
|
+
const ezTextAreaCss = ":host{--text-area--width:100%;--text-area--border-radius:var(--border--radius-medium, 12px);--text-area--font-size:var(--text--medium, 14px);--text-area--font-family:var(--font-pattern, Arial);--text-area--font-weight:var(--text-weight--medium, 400);--text-area--color:var(--title--primary, #000);--text-area__input--background-color:var(--background--medium, #e0e0e0);--text-area__input--border:var(--border--medium, 2px solid);--text-area__input--border-color:var(--text-area__input--background-color);--text-area__input--focus--border-color:var(--color--primary, #008561);--text-area__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--text-area__input--disabled--color:var(--text--disable, #AFB6C0);--text-area__input--error--border-color:#CC2936;--text-area__message_box--font-size:var(--text--small, 12px);--text-area__message_box--info--color:var(--color--success, #22085d);--text-area__message_box--error--color:var(--color--error, #FF0000);--text-area__label--floating--top:6px;--text-area__label--padding-top:12px;--text-area__label--padding-left:14px;--text-area__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--text-area--width)}textarea{box-sizing:border-box;border:none;resize:none;margin-top:calc(var(--space--medium, 12px) + 4px);width:100%;font-weight:var(--text-area--font-weight);font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);color:var(--text-area--color);padding:0;background:none}textarea:focus{outline:none}textarea:disabled{background-color:transparent;color:var(--text-area__input--disabled--color)}.textarea{width:100%;box-sizing:border-box;padding-left:var(--space--medium);padding-right:var(--space--extra-small);border-radius:var(--text-area--border-radius);border:var(--text-area__input--border);border-color:var(--text-area__input--border-color);background-color:var(--text-area__input--background-color)}.textarea--focus{border-color:var(--text-area__input--focus--border-color)}.textarea.hasError{color:var(--text-area--color);border-color:var(--text-area__input--error--border-color)}.message-box{min-height:16px;min-width:100%;margin-top:3px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--text-area--font-family);font-size:var(--text-area__message_box--font-size);color:var(--text-area__message_box--info--color)}.hasError{color:var(--text-area__message_box--error--color)}.textarea__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--text-area__label--padding-right));left:var(--text-area--space--medium);font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color);top:var(--text-area__label--padding-top);left:var(--text-area__label--padding-left);padding-right:var(--text-area__label--padding-right)}.textarea__label--floated{font-family:var(--text-area--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--text-area__label--floating--top)}.textarea__label--disabled{color:var(--text-area__input--disabled--color)}.textarea--slim{margin-top:var(--space--small, 6px)}.textarea--slim::-webkit-input-placeholder{font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color)}.textarea--slim:-moz-placeholder{font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color)}.textarea--slim::-moz-placeholder{font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color)}.textarea--slim:-ms-input-placeholder{font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color)}.textarea--slim::placeholder{font-family:var(--text-area--font-family);font-size:var(--text-area--font-size);font-weight:var(--text-area--font-weight);color:var(--text-area--color)}.textarea--slim:disabled::-webkit-input-placeholder{color:var(--text-area__input--disabled--color)}.textarea--slim:disabled:-moz-placeholder{color:var(--text-area__input--disabled--color)}.textarea--slim:disabled::-moz-placeholder{color:var(--text-area__input--disabled--color)}.textarea--slim:disabled:-ms-input-placeholder{color:var(--text-area__input--disabled--color)}.textarea--slim:disabled::placeholder{color:var(--text-area__input--disabled--color)}";
|
|
4
|
+
|
|
5
|
+
let EzTextArea = class {
|
|
6
|
+
constructor(hostRef) {
|
|
7
|
+
registerInstance(this, hostRef);
|
|
8
|
+
this.ezChange = createEvent(this, "ezChange", 7);
|
|
9
|
+
/**
|
|
10
|
+
* Deixa o campo disponível ou não para digitação.
|
|
11
|
+
*/
|
|
12
|
+
this.enabled = true;
|
|
13
|
+
/**
|
|
14
|
+
* Ajusta o número de linhas e consequentemente o height do textarea. Valor default: 4
|
|
15
|
+
*/
|
|
16
|
+
this.rows = 4;
|
|
17
|
+
/**
|
|
18
|
+
* Permite exibir a mensagem de erro.
|
|
19
|
+
*/
|
|
20
|
+
this.canShowError = true;
|
|
21
|
+
/**
|
|
22
|
+
* Define o modo do tamanho do campo; opções: slim e regular.
|
|
23
|
+
*/
|
|
24
|
+
this.mode = "regular";
|
|
25
|
+
}
|
|
26
|
+
observeErrorMessage() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
const hasError = typeof this.errorMessage === 'string' && this.errorMessage !== '';
|
|
29
|
+
if (hasError) {
|
|
30
|
+
this._container.classList.add('hasError');
|
|
31
|
+
(_a = this._messageBoxElem) === null || _a === void 0 ? void 0 : _a.classList.add('hasError');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this._container.classList.remove('hasError');
|
|
35
|
+
(_b = this._messageBoxElem) === null || _b === void 0 ? void 0 : _b.classList.remove('hasError');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
observeValue(newValue, oldValue) {
|
|
39
|
+
if (this._inputElem) {
|
|
40
|
+
if (newValue != oldValue) {
|
|
41
|
+
if (this.canChangeValue()) {
|
|
42
|
+
this._inputElem.value = this.value || "";
|
|
43
|
+
}
|
|
44
|
+
this.adjustFloatingLabel();
|
|
45
|
+
this.errorMessage = "";
|
|
46
|
+
this.ezChange.emit(this.value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
observeMode() {
|
|
51
|
+
if (this._initialRows == undefined) {
|
|
52
|
+
this._initialRows = this.rows > 0 ? this.rows : undefined;
|
|
53
|
+
}
|
|
54
|
+
const rows = this._initialRows > 0 ? this._initialRows : this.mode != "slim" ? 4 : 2;
|
|
55
|
+
if (rows !== this.rows) {
|
|
56
|
+
this.rows = rows;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
observeRows() {
|
|
60
|
+
const rows = this.rows > 0 ? this.rows : this.mode != "slim" ? 4 : 2;
|
|
61
|
+
if (rows !== this.rows) {
|
|
62
|
+
this.rows = rows;
|
|
63
|
+
this._initialRows = rows;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//---------------------------------------------
|
|
67
|
+
// Public methods
|
|
68
|
+
//---------------------------------------------
|
|
69
|
+
/**
|
|
70
|
+
* Faz o foco no componente de input
|
|
71
|
+
*/
|
|
72
|
+
async setFocus() {
|
|
73
|
+
this._inputElem.focus();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Remove o foco no componente de input
|
|
77
|
+
*/
|
|
78
|
+
async setBlur() {
|
|
79
|
+
this._inputElem.blur();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
83
|
+
*/
|
|
84
|
+
async isInvalid() {
|
|
85
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
86
|
+
}
|
|
87
|
+
//---------------------------------------------
|
|
88
|
+
// Private methods
|
|
89
|
+
//---------------------------------------------
|
|
90
|
+
canChangeValue() {
|
|
91
|
+
return this._inputElem && (this.value || "") !== this._inputElem.value;
|
|
92
|
+
}
|
|
93
|
+
adjustFloatingLabel() {
|
|
94
|
+
if (this.label && this._labelElem) {
|
|
95
|
+
const hasValue = this.value && this.value.toString().length > 0;
|
|
96
|
+
const containsFloatedClass = this._labelElem.classList.contains("textarea__label--floated");
|
|
97
|
+
if (hasValue || this.isFocused()) {
|
|
98
|
+
if (!containsFloatedClass) {
|
|
99
|
+
this._labelElem.classList.add("textarea__label--floated");
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (containsFloatedClass) {
|
|
104
|
+
this._labelElem.classList.remove("textarea__label--floated");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
isFocused() {
|
|
110
|
+
return this._hostElement.shadowRoot.activeElement !== null;
|
|
111
|
+
}
|
|
112
|
+
//---------------------------------------------
|
|
113
|
+
// Event handlers
|
|
114
|
+
//---------------------------------------------
|
|
115
|
+
handleFocusout() {
|
|
116
|
+
this.adjustFloatingLabel();
|
|
117
|
+
if (this._container && this._container.classList.contains("textarea--focus")) {
|
|
118
|
+
this._container.classList.remove("textarea--focus");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
handleChange() {
|
|
122
|
+
if (this.canChangeValue()) {
|
|
123
|
+
this.value = this._inputElem.value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
handleFocus() {
|
|
127
|
+
if (this.label && this._labelElem && !this._labelElem.classList.contains("textarea__label--floated")) {
|
|
128
|
+
this._labelElem.classList.add("textarea__label--floated");
|
|
129
|
+
}
|
|
130
|
+
if (this._container && !this._container.classList.contains("textarea--focus")) {
|
|
131
|
+
this._container.classList.add("textarea--focus");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//---------------------------------------------
|
|
135
|
+
// Lifecycle web component
|
|
136
|
+
//---------------------------------------------
|
|
137
|
+
componentDidLoad() {
|
|
138
|
+
this.observeErrorMessage();
|
|
139
|
+
this.adjustFloatingLabel();
|
|
140
|
+
this.observeMode();
|
|
141
|
+
}
|
|
142
|
+
render() {
|
|
143
|
+
return (h(Host, null, h("div", { class: "textarea", ref: (el) => this._container = el }, this.label && this.mode != "slim" ?
|
|
144
|
+
h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "textarea__label" : "textarea__label textarea__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
|
|
145
|
+
: null, h("textarea", { onFocus: () => this.handleFocus(), ref: (el) => this._inputElem = el, value: this.value, disabled: !this.enabled, class: this.mode === "slim" ? "textarea--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); }, onKeyDown: event => event.stopPropagation(), rows: this.rows })), this.canShowError && this.mode != "slim" &&
|
|
146
|
+
h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
|
|
147
|
+
}
|
|
148
|
+
get _hostElement() { return getElement(this); }
|
|
149
|
+
static get watchers() { return {
|
|
150
|
+
"errorMessage": ["observeErrorMessage"],
|
|
151
|
+
"value": ["observeValue"],
|
|
152
|
+
"mode": ["observeMode"],
|
|
153
|
+
"rows": ["observeRows"]
|
|
154
|
+
}; }
|
|
155
|
+
};
|
|
156
|
+
EzTextArea.style = ezTextAreaCss;
|
|
157
|
+
|
|
158
|
+
export { EzTextArea as ez_text_area };
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { r as registerInstance, e as createEvent, h, f as Host, g as getElement } from './index-1e9d524f.js';
|
|
2
|
+
import { M as MaskFormatter } from './index-b96183c8.js';
|
|
3
|
+
|
|
4
|
+
const ezTextInputCss = ":host{--ez-text-input--height:42px;--ez-text-input--width:100%;--ez-text-input__icon--width:48px;--ez-text-input--height--slim:32px;--ez-text-input--border-radius:var(--border--radius-medium, 12px);--ez-text-input--font-size:var(--text--medium, 14px);--ez-text-input--font-family:var(--font-pattern, Arial);--ez-text-input--font-weight:var(--text-weight--medium, 400);--ez-text-input--color:var(--title--primary, #2B3A54);--ez-text-input__input--background-color:var(--background--medium, #e0e0e0);--ez-text-input__input--border:var(--border--medium, 2px solid);--ez-text-input__input--border-color:var(--ez-text-input__input--background-color);--ez-text-input__input--focus--border-color:var(--color--primary, #008561);--ez-text-input__input--disabled--background-color:var(--color--disable-secondary, #F2F5F8);--ez-text-input__input--disabled--color:var(--text--disable, #AFB6C0);--ez-text-input__input--error--border-color:#CC2936;--ez-text-input__message_box--font-size:var(--text--small, 12px);--ez-text-input__message_box--info--color:var(--color--success, #22085d);--ez-text-input__message_box--error--color:var(--color--error, #FF0000);--ez-text-input__label--floating--top:6px;--ez-text-input__label--padding-top:12px;--ez-text-input__label--padding-left:14px;--ez-text-input__label--padding-right:12px;display:flex;flex-wrap:wrap;position:relative;width:var(--ez-text-input--width)}input{width:100%;box-sizing:border-box;padding:var(--space--medium, 6px);height:var(--ez-text-input--height);border-radius:var(--ez-text-input--border-radius);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);border:var(--ez-text-input__input--border);border-color:var(--ez-text-input__input--border-color);background-color:var(--ez-text-input__input--background-color);color:var(--ez-text-input--color);font-weight:var(--ez-text-input--font-weight)}input:disabled{background-color:var(--ez-text-input__input--disabled--background-color);color:var(--ez-text-input__input--disabled--color)}input:focus{outline:none;border-color:var(--ez-text-input__input--focus--border-color)}input.icon--left{padding-left:var(--ez-text-input__icon--width)}input.icon--right{padding-right:var(--ez-text-input__icon--width)}input.hasError{color:var(--ez-text-input--color);border-color:var(--ez-text-input__input--error--border-color)}input:disabled.hasError{color:var(--ez-text-input__input--disabled--color)}input.text--right{text-align:right}input:read-only{cursor:default}.message-box{min-height:16px;min-width:100%;margin-top:3px;line-height:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input__message_box--font-size);color:var(--ez-text-input__message_box--info--color)}.hasError{color:var(--ez-text-input__message_box--error--color)}.input__label{box-sizing:border-box;position:absolute;z-index:var(--visible);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;-webkit-transition:font-size .05s, top .05s;transition:font-size .05s, top .05s;width:calc(100% - var(--ez-text-input__label--padding-right));left:var(--ez-text-input--space--medium);font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color);top:var(--ez-text-input__label--padding-top);left:var(--ez-text-input__label--padding-left);padding-right:var(--ez-text-input__label--padding-right)}.input__label--floated{font-family:var(--ez-text-input--font-family);font-size:var(--text--extra-small);color:var(--text--primary);top:var(--ez-text-input__label--floating--top)}.input__label--disabled{color:var(--ez-text-input__input--disabled--color)}.input__label--left{text-align:left;left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--right{right:var(--ez-text-input__icon--width);width:calc(100% - var(--ez-text-input__icon--width))}.input__label--left.input__label--right{left:calc(var(--ez-text-input__icon--width) + 2px);width:calc(100% - var(--ez-text-input__icon--width) * 2)}.input--with--label{padding-bottom:0}.input--slim{padding-top:var(--space--small, 3px);padding-bottom:var(--space--small, 3px);height:var(--ez-text-input--height--slim)}.input--slim::-webkit-input-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:-moz-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim::-moz-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:-ms-input-placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim::placeholder{font-family:var(--ez-text-input--font-family);font-size:var(--ez-text-input--font-size);font-weight:var(--ez-text-input--font-weight);color:var(--ez-text-input--color)}.input--slim:disabled::-webkit-input-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled:-moz-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled::-moz-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled:-ms-input-placeholder{color:var(--ez-text-input__input--disabled--color)}.input--slim:disabled::placeholder{color:var(--ez-text-input__input--disabled--color)}";
|
|
5
|
+
|
|
6
|
+
let EzTextInput = class {
|
|
7
|
+
constructor(hostRef) {
|
|
8
|
+
registerInstance(this, hostRef);
|
|
9
|
+
this.ezChange = createEvent(this, "ezChange", 7);
|
|
10
|
+
/**
|
|
11
|
+
* Deixa o campo disponível ou não para digitação.
|
|
12
|
+
*/
|
|
13
|
+
this.enabled = true;
|
|
14
|
+
/**
|
|
15
|
+
* Permite exibir a mensagem de erro.
|
|
16
|
+
*/
|
|
17
|
+
this.canShowError = true;
|
|
18
|
+
/**
|
|
19
|
+
* Define o modo do tamanho do campo; opções: slim e regular.
|
|
20
|
+
*/
|
|
21
|
+
this.mode = "regular";
|
|
22
|
+
}
|
|
23
|
+
observeErrorMessage() {
|
|
24
|
+
if (this._inputElem) {
|
|
25
|
+
this.isInvalid().then((hasError) => {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
if (hasError) {
|
|
28
|
+
this._inputElem.classList.add("hasError");
|
|
29
|
+
(_a = this._messageBoxElem) === null || _a === void 0 ? void 0 : _a.classList.add("hasError");
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this._inputElem.classList.remove("hasError");
|
|
33
|
+
(_b = this._messageBoxElem) === null || _b === void 0 ? void 0 : _b.classList.remove("hasError");
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
observeMask() {
|
|
39
|
+
if (this.mask) {
|
|
40
|
+
if (this._maskFormatter == undefined) {
|
|
41
|
+
this._maskFormatter = new MaskFormatter(this.mask);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this._maskFormatter.mask = this.mask;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
observeValue(newValue, oldValue) {
|
|
49
|
+
if (this._inputElem) {
|
|
50
|
+
if (newValue != oldValue) {
|
|
51
|
+
this._inputElem.value = this.value || "";
|
|
52
|
+
this.handleChange();
|
|
53
|
+
this.adjustFloatingLabel();
|
|
54
|
+
if (!this.isSlaveMode()) {
|
|
55
|
+
this.errorMessage = "";
|
|
56
|
+
this.ezChange.emit(this.value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//---------------------------------------------
|
|
62
|
+
// Private methods
|
|
63
|
+
//---------------------------------------------
|
|
64
|
+
adjustFloatingLabel() {
|
|
65
|
+
if (this.label && this._labelElem) {
|
|
66
|
+
if (this._inputElem && !this._inputElem.classList.contains("input--with--label")) {
|
|
67
|
+
this._inputElem.classList.add("input--with--label");
|
|
68
|
+
}
|
|
69
|
+
const hasValue = this.value && this.value.toString().length > 0;
|
|
70
|
+
const containsFloatedClass = this._labelElem.classList.contains("input__label--floated");
|
|
71
|
+
if (hasValue || this.isFocused()) {
|
|
72
|
+
if (!containsFloatedClass) {
|
|
73
|
+
this._labelElem.classList.add("input__label--floated");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
if (containsFloatedClass) {
|
|
78
|
+
this._labelElem.classList.remove("input__label--floated");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
isFocused() {
|
|
84
|
+
return this._hostElement.shadowRoot.activeElement !== null;
|
|
85
|
+
}
|
|
86
|
+
isSlaveMode() {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
return ((_b = (_a = this._hostElement) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.slaveMode) === "true";
|
|
89
|
+
}
|
|
90
|
+
adjustColorContentSlot(color = "") {
|
|
91
|
+
if (this._contentLeftSlot) {
|
|
92
|
+
this._contentLeftSlot.style.color = color;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//---------------------------------------------
|
|
96
|
+
// Public methods
|
|
97
|
+
//---------------------------------------------
|
|
98
|
+
/**
|
|
99
|
+
* Faz o foco no componente de input
|
|
100
|
+
*/
|
|
101
|
+
async setFocus() {
|
|
102
|
+
this._inputElem.focus();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Remove o foco no componente de input
|
|
106
|
+
*/
|
|
107
|
+
async setBlur() {
|
|
108
|
+
this._inputElem.blur();
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Retorna informando se o campo está inválido (true | false)
|
|
112
|
+
*/
|
|
113
|
+
async isInvalid() {
|
|
114
|
+
return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
|
|
115
|
+
}
|
|
116
|
+
//---------------------------------------------
|
|
117
|
+
// Event handlers
|
|
118
|
+
//---------------------------------------------
|
|
119
|
+
handleFocusout() {
|
|
120
|
+
const value = this._inputElem.value;
|
|
121
|
+
if (value && this._maskFormatter) {
|
|
122
|
+
try {
|
|
123
|
+
this._inputElem.value = this._maskFormatter.format(value);
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
this.errorMessage = e.message;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
this.controlChangeValue();
|
|
130
|
+
this.adjustFloatingLabel();
|
|
131
|
+
this.adjustColorContentSlot();
|
|
132
|
+
}
|
|
133
|
+
isValidValue(value) {
|
|
134
|
+
if (this.restrict) {
|
|
135
|
+
return Array.from(value).reduce((valid, c) => valid && this.restrict.indexOf(c) > -1, true);
|
|
136
|
+
}
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
controlChangeValue() {
|
|
140
|
+
if (this._inputElem && (this.value || '') !== this._inputElem.value) {
|
|
141
|
+
this.value = this._inputElem.value;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
handleChange() {
|
|
145
|
+
if (!this._inputElem) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const value = this._inputElem.value;
|
|
149
|
+
if (this.isValidValue(value)) {
|
|
150
|
+
this._lastValidValue = value;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this._inputElem.value = this._lastValidValue == undefined ? "" : this._lastValidValue;
|
|
154
|
+
}
|
|
155
|
+
this.controlChangeValue();
|
|
156
|
+
}
|
|
157
|
+
handleSlotChange(ev) {
|
|
158
|
+
const slot = ev.target;
|
|
159
|
+
const content = slot.assignedElements()[0];
|
|
160
|
+
if (content) {
|
|
161
|
+
content.style.position = "absolute";
|
|
162
|
+
content.style.display = "flex";
|
|
163
|
+
content.style.alignItems = "center";
|
|
164
|
+
content.style.justifyContent = "center";
|
|
165
|
+
content.style.overflow = "hidden";
|
|
166
|
+
content.style.top = "0px";
|
|
167
|
+
content.style.width = "var(--ez-text-input__icon--width)";
|
|
168
|
+
content.style.height = this.mode != "slim" ? "var(--ez-text-input--height)" : "var(--ez-text-input--height--slim)";
|
|
169
|
+
if (slot.name == "leftIcon") {
|
|
170
|
+
content.style.left = "0px";
|
|
171
|
+
content.style.borderRadius = "var(--ez-text-input--border-radius) 0 0 var(--ez-text-input--border-radius)";
|
|
172
|
+
this._inputElem.classList.add("icon--left");
|
|
173
|
+
if (this._labelElem) {
|
|
174
|
+
this._labelElem.classList.add("input__label--left");
|
|
175
|
+
}
|
|
176
|
+
this._contentLeftSlot = content;
|
|
177
|
+
}
|
|
178
|
+
else if (slot.name == "rightIcon") {
|
|
179
|
+
content.style.right = "0px";
|
|
180
|
+
content.style.borderRadius = "0 var(--ez-text-input--border-radius) var(--ez-text-input--border-radius) 0";
|
|
181
|
+
this._inputElem.classList.add("icon--right");
|
|
182
|
+
if (this._labelElem) {
|
|
183
|
+
this._labelElem.classList.add("input__label--right");
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
this.observeErrorMessage();
|
|
188
|
+
}
|
|
189
|
+
doFocus() {
|
|
190
|
+
if (this.label && this._labelElem && !this._labelElem.classList.contains("input__label--floated")) {
|
|
191
|
+
this._labelElem.classList.add("input__label--floated");
|
|
192
|
+
}
|
|
193
|
+
this.adjustColorContentSlot("var(--ez-text-input__input--focus--border-color)");
|
|
194
|
+
}
|
|
195
|
+
//---------------------------------------------
|
|
196
|
+
// Lifecycle web component
|
|
197
|
+
//---------------------------------------------
|
|
198
|
+
componentDidLoad() {
|
|
199
|
+
this.observeErrorMessage();
|
|
200
|
+
this.observeMask();
|
|
201
|
+
this.adjustFloatingLabel();
|
|
202
|
+
}
|
|
203
|
+
componentWillLoad() {
|
|
204
|
+
this.observeMask();
|
|
205
|
+
if (this.value) {
|
|
206
|
+
if (this._maskFormatter) {
|
|
207
|
+
try {
|
|
208
|
+
this.value = this._maskFormatter.format(this.value);
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
this.errorMessage = e.message;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (!this.isValidValue(this.value)) {
|
|
215
|
+
this._lastValidValue = "";
|
|
216
|
+
this.value = "";
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
render() {
|
|
221
|
+
return (h(Host, null, h("slot", { name: "leftIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.label && this.mode != "slim" ?
|
|
222
|
+
h("label", { ref: (el) => this._labelElem = el, class: this.enabled ? "input__label" : "input__label input__label--disabled", onClick: () => this._inputElem.focus(), title: this.label }, this.label)
|
|
223
|
+
: null, h("input", { onFocus: () => this.doFocus(), ref: (el) => this._inputElem = el, type: "text", class: this.mode === "slim" ? "input--slim" : "", placeholder: this.mode === "slim" && this.label ? this.label : "", value: this.value, disabled: !this.enabled, onInput: () => { this.handleChange(); }, onFocusout: () => { this.handleFocusout(); } }), h("slot", { name: "rightIcon", onSlotchange: (ev) => { this.handleSlotChange(ev); } }), this.canShowError && this.mode != "slim" &&
|
|
224
|
+
h("span", { class: "message-box", ref: (el) => this._messageBoxElem = el, title: this.errorMessage }, this.errorMessage)));
|
|
225
|
+
}
|
|
226
|
+
get _hostElement() { return getElement(this); }
|
|
227
|
+
static get watchers() { return {
|
|
228
|
+
"errorMessage": ["observeErrorMessage"],
|
|
229
|
+
"mask": ["observeMask"],
|
|
230
|
+
"value": ["observeValue"]
|
|
231
|
+
}; }
|
|
232
|
+
};
|
|
233
|
+
EzTextInput.style = ezTextInputCss;
|
|
234
|
+
|
|
235
|
+
export { EzTextInput as ez_text_input };
|