@sankhyalabs/ezui 1.1.8 → 1.1.9
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/README.md +72 -72
- package/dist/cjs/{DataUnit-28b290cb.js → DataUnit-9a4a35ca.js} +415 -371
- package/dist/cjs/ez-action-chip.cjs.entry.js +41 -41
- package/dist/cjs/ez-button_14.cjs.entry.js +1911 -1911
- package/dist/cjs/ez-label-chip.cjs.entry.js +120 -120
- package/dist/cjs/ez-modal.cjs.entry.js +104 -104
- package/dist/cjs/ez-number-input.cjs.entry.js +236 -236
- package/dist/cjs/ez-time-input.cjs.entry.js +168 -168
- package/dist/cjs/form-metadata.cjs.entry.js +65 -65
- package/dist/collection/components/ez-action-chip/ez-action-chip.css +82 -82
- package/dist/collection/components/ez-action-chip/ez-action-chip.js +109 -109
- package/dist/collection/components/ez-button/ez-button.css +94 -94
- package/dist/collection/components/ez-button/ez-button.js +125 -125
- package/dist/collection/components/ez-calendar/ez-calendar.css +210 -210
- package/dist/collection/components/ez-calendar/ez-calendar.js +215 -215
- package/dist/collection/components/ez-check/ez-check.css +265 -265
- package/dist/collection/components/ez-check/ez-check.js +168 -168
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.css +67 -67
- package/dist/collection/components/ez-collapsable-box/ez-collapsable-box.js +108 -108
- package/dist/collection/components/ez-combo-box/ez-combo-box-interfaces.js +2 -2
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +167 -167
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +363 -363
- package/dist/collection/components/ez-date-input/ez-date-input.css +38 -38
- package/dist/collection/components/ez-date-input/ez-date-input.js +172 -172
- package/dist/collection/components/ez-form/ez-form.css +19 -19
- package/dist/collection/components/ez-form/ez-form.js +368 -368
- package/dist/collection/components/ez-form/store/Form.actions.js +132 -132
- package/dist/collection/components/ez-form/store/Form.reducer.js +194 -194
- package/dist/collection/components/ez-form/store/Form.selectors.js +44 -44
- package/dist/collection/components/ez-form/subcomponents/DataUnit.js +251 -207
- package/dist/collection/components/ez-form/subcomponents/FormMetadata.js +16 -16
- package/dist/collection/components/ez-form/subcomponents/css/place-holder.css +23 -23
- package/dist/collection/components/ez-form/subcomponents/form-metadata.js +173 -173
- package/dist/collection/components/ez-form/subcomponents/place-holder.js +14 -14
- package/dist/collection/components/ez-form/subcomponents/structure/Field.js +71 -71
- package/dist/collection/components/ez-form/subcomponents/structure/FieldSet.js +27 -27
- package/dist/collection/components/ez-form/subcomponents/structure/FormSheet.js +40 -40
- package/dist/collection/components/ez-form/subcomponents/structure/NavigationBar.js +27 -27
- package/dist/collection/components/ez-icon/ez-icon.css +36 -36
- package/dist/collection/components/ez-icon/ez-icon.js +56 -56
- package/dist/collection/components/ez-label-chip/ez-label-chip.css +117 -117
- package/dist/collection/components/ez-label-chip/ez-label-chip.js +276 -276
- package/dist/collection/components/ez-modal/ez-modal.css +86 -86
- package/dist/collection/components/ez-modal/ez-modal.js +224 -224
- package/dist/collection/components/ez-number-input/ez-number-input.css +144 -144
- package/dist/collection/components/ez-number-input/ez-number-input.js +465 -465
- package/dist/collection/components/ez-popover/ez-popover.css +38 -38
- package/dist/collection/components/ez-popover/ez-popover.js +323 -323
- package/dist/collection/components/ez-search/ez-search.css +295 -295
- package/dist/collection/components/ez-search/ez-search.js +527 -527
- package/dist/collection/components/ez-tabselector/ez-tabselector.css +125 -125
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +283 -283
- package/dist/collection/components/ez-text-area/ez-text-area.css +139 -139
- package/dist/collection/components/ez-text-area/ez-text-area.js +267 -267
- package/dist/collection/components/ez-text-input/ez-text-input.css +169 -169
- package/dist/collection/components/ez-text-input/ez-text-input.js +395 -395
- package/dist/collection/components/ez-time-input/ez-time-input.css +155 -155
- package/dist/collection/components/ez-time-input/ez-time-input.js +326 -326
- package/dist/collection/index.js +1 -1
- package/dist/collection/servidor.js +100 -100
- package/dist/collection/utils/FloatingManager.js +15 -15
- package/dist/collection/utils/utils.js +6 -6
- package/dist/custom-elements/index.js +3125 -3081
- package/dist/esm/{DataUnit-69e518fa.js → DataUnit-d5d4c9a3.js} +415 -371
- package/dist/esm/ez-action-chip.entry.js +41 -41
- package/dist/esm/ez-button_14.entry.js +1911 -1911
- package/dist/esm/ez-label-chip.entry.js +120 -120
- package/dist/esm/ez-modal.entry.js +104 -104
- package/dist/esm/ez-number-input.entry.js +236 -236
- package/dist/esm/ez-time-input.entry.js +168 -168
- package/dist/esm/form-metadata.entry.js +65 -65
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-b0974f4f.entry.js → p-0fcdfb51.entry.js} +1 -1
- package/dist/ezui/p-dac7a6c2.js +1 -0
- package/dist/ezui/{p-db11c600.entry.js → p-dbef7060.entry.js} +1 -1
- package/dist/types/components/ez-action-chip/ez-action-chip.d.ts +16 -16
- package/dist/types/components/ez-button/ez-button.d.ts +20 -20
- package/dist/types/components/ez-calendar/ez-calendar.d.ts +42 -42
- package/dist/types/components/ez-check/ez-check.d.ts +32 -32
- package/dist/types/components/ez-collapsable-box/ez-collapsable-box.d.ts +18 -18
- package/dist/types/components/ez-combo-box/ez-combo-box-interfaces.d.ts +4 -4
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +68 -68
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +31 -31
- package/dist/types/components/ez-form/ez-form.d.ts +26 -31
- package/dist/types/components/ez-form/store/Form.actions.d.ts +111 -111
- package/dist/types/components/ez-form/store/Form.reducer.d.ts +20 -20
- package/dist/types/components/ez-form/store/Form.selectors.d.ts +14 -14
- package/dist/types/components/ez-form/subcomponents/DataUnit.d.ts +60 -55
- package/dist/types/components/ez-form/subcomponents/FormMetadata.d.ts +41 -41
- package/dist/types/components/ez-form/subcomponents/form-metadata.d.ts +15 -15
- package/dist/types/components/ez-form/subcomponents/place-holder.d.ts +3 -3
- package/dist/types/components/ez-form/subcomponents/structure/Field.d.ts +10 -10
- package/dist/types/components/ez-form/subcomponents/structure/FieldSet.d.ts +12 -12
- package/dist/types/components/ez-form/subcomponents/structure/FormSheet.d.ts +13 -13
- package/dist/types/components/ez-form/subcomponents/structure/NavigationBar.d.ts +17 -17
- package/dist/types/components/ez-icon/ez-icon.d.ts +5 -5
- package/dist/types/components/ez-label-chip/ez-label-chip.d.ts +40 -40
- package/dist/types/components/ez-modal/ez-modal.d.ts +32 -32
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +73 -73
- package/dist/types/components/ez-popover/ez-popover.d.ts +52 -52
- package/dist/types/components/ez-search/ez-search.d.ts +95 -95
- package/dist/types/components/ez-tabselector/ez-tabselector.d.ts +31 -31
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +49 -49
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +64 -64
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +53 -53
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +2 -2
- package/package.json +114 -114
- package/dist/ezui/p-10ef58b3.js +0 -1
- package/react/components.d.ts +0 -22
- package/react/components.js +0 -25
- package/react/components.js.map +0 -1
- package/react/react-component-lib/createComponent.d.ts +0 -10
- package/react/react-component-lib/createComponent.js +0 -59
- package/react/react-component-lib/createComponent.js.map +0 -1
- package/react/react-component-lib/createOverlayComponent.d.ts +0 -20
- package/react/react-component-lib/createOverlayComponent.js +0 -89
- package/react/react-component-lib/createOverlayComponent.js.map +0 -1
- package/react/react-component-lib/index.d.ts +0 -2
- package/react/react-component-lib/index.js +0 -3
- package/react/react-component-lib/index.js.map +0 -1
- package/react/react-component-lib/interfaces.d.ts +0 -29
- package/react/react-component-lib/interfaces.js +0 -1
- package/react/react-component-lib/interfaces.js.map +0 -1
- package/react/react-component-lib/utils/attachProps.d.ts +0 -12
- package/react/react-component-lib/utils/attachProps.js +0 -96
- package/react/react-component-lib/utils/attachProps.js.map +0 -1
- package/react/react-component-lib/utils/case.d.ts +0 -2
- package/react/react-component-lib/utils/case.js +0 -7
- package/react/react-component-lib/utils/case.js.map +0 -1
- package/react/react-component-lib/utils/dev.d.ts +0 -2
- package/react/react-component-lib/utils/dev.js +0 -13
- package/react/react-component-lib/utils/dev.js.map +0 -1
- package/react/react-component-lib/utils/index.d.ts +0 -7
- package/react/react-component-lib/utils/index.js +0 -21
- package/react/react-component-lib/utils/index.js.map +0 -1
|
@@ -1,283 +1,283 @@
|
|
|
1
|
-
import { Component, Event, Element, h, Prop, Host } from '@stencil/core';
|
|
2
|
-
export class EzTabselector {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.setFoucusedParam = (ev) => {
|
|
5
|
-
if (ev.key === 'Enter') {
|
|
6
|
-
this.selectedindex = this.foucusedindex;
|
|
7
|
-
this.foucusedindex = undefined;
|
|
8
|
-
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
9
|
-
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
10
|
-
ev.preventDefault();
|
|
11
|
-
this.setFocusedTab(this.selectedindex);
|
|
12
|
-
}
|
|
13
|
-
else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
|
|
14
|
-
let operator = undefined;
|
|
15
|
-
if (ev.key === 'ArrowLeft') {
|
|
16
|
-
operator = false;
|
|
17
|
-
}
|
|
18
|
-
else if (ev.key === 'ArrowRight') {
|
|
19
|
-
operator = true;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
if (this.foucusedindex === undefined) {
|
|
25
|
-
if (operator === false) {
|
|
26
|
-
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
if (operator === false) {
|
|
34
|
-
this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
if (parseInt(this.foucusedindex) < 0) {
|
|
41
|
-
this.foucusedindex = '0';
|
|
42
|
-
}
|
|
43
|
-
else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
|
|
44
|
-
this.foucusedindex = (this._processedTabs.length - 1).toString();
|
|
45
|
-
}
|
|
46
|
-
this.setFoucusedBtn(true, this.foucusedindex);
|
|
47
|
-
this.setFocusedTab(this.foucusedindex);
|
|
48
|
-
this.change.emit();
|
|
49
|
-
}
|
|
50
|
-
else if (ev.key === 'Tab' || ev.key === 'Escape') {
|
|
51
|
-
this.foucusedindex = undefined;
|
|
52
|
-
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
53
|
-
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
54
|
-
ev.preventDefault();
|
|
55
|
-
this.setFocusedTab(this.selectedindex);
|
|
56
|
-
}
|
|
57
|
-
// this.setFocusedTab();
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
handleTabClick(tab, index) {
|
|
61
|
-
this.selectedindex = index.toString();
|
|
62
|
-
this.foucusedindex = undefined;
|
|
63
|
-
this.selectedtab = tab;
|
|
64
|
-
this.change.emit();
|
|
65
|
-
this.setFoucusedBtn(false, this.selectedindex);
|
|
66
|
-
}
|
|
67
|
-
componentWillRender() {
|
|
68
|
-
if (!this._processedTabs) {
|
|
69
|
-
this._processedTabs = [];
|
|
70
|
-
if (this.tabs) {
|
|
71
|
-
this.tabs.split(',').forEach((label) => {
|
|
72
|
-
label = label.trim();
|
|
73
|
-
this._processedTabs.push(new Tab(label, label));
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
|
|
77
|
-
const tabKey = elem.getAttribute('tabKey');
|
|
78
|
-
const label = elem.getAttribute('label');
|
|
79
|
-
const t = new Tab(label, tabKey);
|
|
80
|
-
const content = elem.firstChild;
|
|
81
|
-
if (content) {
|
|
82
|
-
content.setAttribute('slot', 'tab' + this._processedTabs.length);
|
|
83
|
-
this._hostElem.appendChild(content);
|
|
84
|
-
}
|
|
85
|
-
this._processedTabs.push(t);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
handleSlotChange(ev) {
|
|
90
|
-
const slot = ev.target;
|
|
91
|
-
const content = slot.assignedElements()[0];
|
|
92
|
-
if (content) {
|
|
93
|
-
content.style.marginLeft = "6px";
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
scrollBackward() {
|
|
97
|
-
const container = this._scrollContainer;
|
|
98
|
-
if (container) {
|
|
99
|
-
container.scrollLeft -= container.clientWidth;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
scrollFoward() {
|
|
103
|
-
const container = this._scrollContainer;
|
|
104
|
-
if (container) {
|
|
105
|
-
let lastTab = null;
|
|
106
|
-
container.querySelectorAll('.tab').forEach((tab) => {
|
|
107
|
-
if (tab.getBoundingClientRect().right < container.clientWidth) {
|
|
108
|
-
lastTab = tab;
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
componentDidRender() {
|
|
115
|
-
this.updateScroll();
|
|
116
|
-
}
|
|
117
|
-
updateScroll() {
|
|
118
|
-
const container = this._scrollContainer;
|
|
119
|
-
if (container) {
|
|
120
|
-
const { scrollWidth, clientWidth, scrollLeft } = container;
|
|
121
|
-
const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
|
|
122
|
-
this._startHidden = container.scrollLeft > 0;
|
|
123
|
-
this._endHidden = remainingScroll > 0;
|
|
124
|
-
if (this._startHidden) {
|
|
125
|
-
this._backwardButton.classList.remove('hidden');
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
this._backwardButton.classList.add('hidden');
|
|
129
|
-
}
|
|
130
|
-
if (this._endHidden) {
|
|
131
|
-
this._forwardButton.classList.remove('hidden');
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this._forwardButton.classList.add('hidden');
|
|
135
|
-
}
|
|
136
|
-
const classNames = ['', 'startHidden', 'endHidden', 'midle'];
|
|
137
|
-
const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
|
|
138
|
-
classNames.forEach((name) => {
|
|
139
|
-
if (name !== currentClass && container.classList.contains(name)) {
|
|
140
|
-
container.classList.remove(name);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
if (currentClass && !container.classList.contains(currentClass)) {
|
|
144
|
-
container.classList.add(currentClass);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
domScrollHandler() {
|
|
149
|
-
window.clearTimeout(this._scrollCallBack);
|
|
150
|
-
this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
|
|
151
|
-
}
|
|
152
|
-
setFocusedTab(index) {
|
|
153
|
-
window.clearTimeout(this._scrollCallBackTeste);
|
|
154
|
-
this._scrollCallBackTeste = window.setTimeout(() => {
|
|
155
|
-
const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
|
|
156
|
-
console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
|
|
157
|
-
console.log('tabtoscroll', tabtoscroll);
|
|
158
|
-
tabtoscroll.scrollIntoView();
|
|
159
|
-
}, 200);
|
|
160
|
-
}
|
|
161
|
-
getTextWidth(text) {
|
|
162
|
-
if (this._textMesurement === undefined) {
|
|
163
|
-
this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
|
|
164
|
-
}
|
|
165
|
-
const context = this._textMesurement.getContext("2d");
|
|
166
|
-
context.font = '14px Sora, Algerian';
|
|
167
|
-
return Math.min(220, 24 + context.measureText(text).width) + 'px';
|
|
168
|
-
}
|
|
169
|
-
;
|
|
170
|
-
setFoucusedBtn(visible, paramater) {
|
|
171
|
-
const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
|
|
172
|
-
tabsButtons.forEach((el) => {
|
|
173
|
-
el.classList.remove('is-focused');
|
|
174
|
-
if (el.id === 'tab' + paramater && visible) {
|
|
175
|
-
el.classList.add('is-focused');
|
|
176
|
-
}
|
|
177
|
-
;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
render() {
|
|
181
|
-
return (h(Host, null,
|
|
182
|
-
h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }),
|
|
183
|
-
h("div", { class: "scroll", ref: (el) => this._scrollContainer = el,
|
|
184
|
-
// onScroll={() => this.domScrollHandler()}
|
|
185
|
-
onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index) => {
|
|
186
|
-
const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
|
|
187
|
-
const tabId = "tab" + index;
|
|
188
|
-
const isSelected = index === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
|
|
189
|
-
if (isSelected) {
|
|
190
|
-
this.selectedtab = tab.tabKey;
|
|
191
|
-
this.selectedindex = index.toString();
|
|
192
|
-
}
|
|
193
|
-
return h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab.tabKey, index), style: labelStyle },
|
|
194
|
-
h("span", { class: "tab-label", title: tab.label }, tab.label),
|
|
195
|
-
h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
|
|
196
|
-
})),
|
|
197
|
-
h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
|
|
198
|
-
}
|
|
199
|
-
static get is() { return "ez-tabselector"; }
|
|
200
|
-
static get encapsulation() { return "shadow"; }
|
|
201
|
-
static get originalStyleUrls() { return {
|
|
202
|
-
"$": ["ez-tabselector.css"]
|
|
203
|
-
}; }
|
|
204
|
-
static get styleUrls() { return {
|
|
205
|
-
"$": ["ez-tabselector.css"]
|
|
206
|
-
}; }
|
|
207
|
-
static get properties() { return {
|
|
208
|
-
"selectedindex": {
|
|
209
|
-
"type": "string",
|
|
210
|
-
"mutable": true,
|
|
211
|
-
"complexType": {
|
|
212
|
-
"original": "string",
|
|
213
|
-
"resolved": "string",
|
|
214
|
-
"references": {}
|
|
215
|
-
},
|
|
216
|
-
"required": false,
|
|
217
|
-
"optional": false,
|
|
218
|
-
"docs": {
|
|
219
|
-
"tags": [],
|
|
220
|
-
"text": ""
|
|
221
|
-
},
|
|
222
|
-
"attribute": "selectedindex",
|
|
223
|
-
"reflect": true
|
|
224
|
-
},
|
|
225
|
-
"selectedtab": {
|
|
226
|
-
"type": "string",
|
|
227
|
-
"mutable": true,
|
|
228
|
-
"complexType": {
|
|
229
|
-
"original": "string",
|
|
230
|
-
"resolved": "string",
|
|
231
|
-
"references": {}
|
|
232
|
-
},
|
|
233
|
-
"required": false,
|
|
234
|
-
"optional": false,
|
|
235
|
-
"docs": {
|
|
236
|
-
"tags": [],
|
|
237
|
-
"text": ""
|
|
238
|
-
},
|
|
239
|
-
"attribute": "selectedtab",
|
|
240
|
-
"reflect": true
|
|
241
|
-
},
|
|
242
|
-
"tabs": {
|
|
243
|
-
"type": "string",
|
|
244
|
-
"mutable": false,
|
|
245
|
-
"complexType": {
|
|
246
|
-
"original": "string",
|
|
247
|
-
"resolved": "string",
|
|
248
|
-
"references": {}
|
|
249
|
-
},
|
|
250
|
-
"required": false,
|
|
251
|
-
"optional": false,
|
|
252
|
-
"docs": {
|
|
253
|
-
"tags": [],
|
|
254
|
-
"text": ""
|
|
255
|
-
},
|
|
256
|
-
"attribute": "tabs",
|
|
257
|
-
"reflect": false
|
|
258
|
-
}
|
|
259
|
-
}; }
|
|
260
|
-
static get events() { return [{
|
|
261
|
-
"method": "change",
|
|
262
|
-
"name": "change",
|
|
263
|
-
"bubbles": true,
|
|
264
|
-
"cancelable": true,
|
|
265
|
-
"composed": true,
|
|
266
|
-
"docs": {
|
|
267
|
-
"tags": [],
|
|
268
|
-
"text": ""
|
|
269
|
-
},
|
|
270
|
-
"complexType": {
|
|
271
|
-
"original": "string",
|
|
272
|
-
"resolved": "string",
|
|
273
|
-
"references": {}
|
|
274
|
-
}
|
|
275
|
-
}]; }
|
|
276
|
-
static get elementRef() { return "_hostElem"; }
|
|
277
|
-
}
|
|
278
|
-
class Tab {
|
|
279
|
-
constructor(label, tabKey) {
|
|
280
|
-
this.label = label;
|
|
281
|
-
this.tabKey = tabKey;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
1
|
+
import { Component, Event, Element, h, Prop, Host } from '@stencil/core';
|
|
2
|
+
export class EzTabselector {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.setFoucusedParam = (ev) => {
|
|
5
|
+
if (ev.key === 'Enter') {
|
|
6
|
+
this.selectedindex = this.foucusedindex;
|
|
7
|
+
this.foucusedindex = undefined;
|
|
8
|
+
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
9
|
+
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
10
|
+
ev.preventDefault();
|
|
11
|
+
this.setFocusedTab(this.selectedindex);
|
|
12
|
+
}
|
|
13
|
+
else if (ev.key === 'ArrowLeft' || ev.key === 'ArrowRight') {
|
|
14
|
+
let operator = undefined;
|
|
15
|
+
if (ev.key === 'ArrowLeft') {
|
|
16
|
+
operator = false;
|
|
17
|
+
}
|
|
18
|
+
else if (ev.key === 'ArrowRight') {
|
|
19
|
+
operator = true;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (this.foucusedindex === undefined) {
|
|
25
|
+
if (operator === false) {
|
|
26
|
+
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) - 1).toString() : undefined;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
this.foucusedindex = this.selectedindex !== undefined ? (parseInt(this.selectedindex) + 1).toString() : undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (operator === false) {
|
|
34
|
+
this.foucusedindex = (parseInt(this.foucusedindex) - 1).toString();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.foucusedindex = (parseInt(this.foucusedindex) + 1).toString();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (parseInt(this.foucusedindex) < 0) {
|
|
41
|
+
this.foucusedindex = '0';
|
|
42
|
+
}
|
|
43
|
+
else if (parseInt(this.foucusedindex) > this._processedTabs.length - 1) {
|
|
44
|
+
this.foucusedindex = (this._processedTabs.length - 1).toString();
|
|
45
|
+
}
|
|
46
|
+
this.setFoucusedBtn(true, this.foucusedindex);
|
|
47
|
+
this.setFocusedTab(this.foucusedindex);
|
|
48
|
+
this.change.emit();
|
|
49
|
+
}
|
|
50
|
+
else if (ev.key === 'Tab' || ev.key === 'Escape') {
|
|
51
|
+
this.foucusedindex = undefined;
|
|
52
|
+
this.selectedtab = this._processedTabs[this.selectedindex]['tabKey'];
|
|
53
|
+
this.handleTabClick(this.selectedtab, parseInt(this.selectedindex));
|
|
54
|
+
ev.preventDefault();
|
|
55
|
+
this.setFocusedTab(this.selectedindex);
|
|
56
|
+
}
|
|
57
|
+
// this.setFocusedTab();
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
handleTabClick(tab, index) {
|
|
61
|
+
this.selectedindex = index.toString();
|
|
62
|
+
this.foucusedindex = undefined;
|
|
63
|
+
this.selectedtab = tab;
|
|
64
|
+
this.change.emit();
|
|
65
|
+
this.setFoucusedBtn(false, this.selectedindex);
|
|
66
|
+
}
|
|
67
|
+
componentWillRender() {
|
|
68
|
+
if (!this._processedTabs) {
|
|
69
|
+
this._processedTabs = [];
|
|
70
|
+
if (this.tabs) {
|
|
71
|
+
this.tabs.split(',').forEach((label) => {
|
|
72
|
+
label = label.trim();
|
|
73
|
+
this._processedTabs.push(new Tab(label, label));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
this._hostElem.querySelectorAll('ez-tab').forEach((elem) => {
|
|
77
|
+
const tabKey = elem.getAttribute('tabKey');
|
|
78
|
+
const label = elem.getAttribute('label');
|
|
79
|
+
const t = new Tab(label, tabKey);
|
|
80
|
+
const content = elem.firstChild;
|
|
81
|
+
if (content) {
|
|
82
|
+
content.setAttribute('slot', 'tab' + this._processedTabs.length);
|
|
83
|
+
this._hostElem.appendChild(content);
|
|
84
|
+
}
|
|
85
|
+
this._processedTabs.push(t);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
handleSlotChange(ev) {
|
|
90
|
+
const slot = ev.target;
|
|
91
|
+
const content = slot.assignedElements()[0];
|
|
92
|
+
if (content) {
|
|
93
|
+
content.style.marginLeft = "6px";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
scrollBackward() {
|
|
97
|
+
const container = this._scrollContainer;
|
|
98
|
+
if (container) {
|
|
99
|
+
container.scrollLeft -= container.clientWidth;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
scrollFoward() {
|
|
103
|
+
const container = this._scrollContainer;
|
|
104
|
+
if (container) {
|
|
105
|
+
let lastTab = null;
|
|
106
|
+
container.querySelectorAll('.tab').forEach((tab) => {
|
|
107
|
+
if (tab.getBoundingClientRect().right < container.clientWidth) {
|
|
108
|
+
lastTab = tab;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
container.scrollLeft = lastTab.offsetLeft + lastTab.offsetWidth;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
componentDidRender() {
|
|
115
|
+
this.updateScroll();
|
|
116
|
+
}
|
|
117
|
+
updateScroll() {
|
|
118
|
+
const container = this._scrollContainer;
|
|
119
|
+
if (container) {
|
|
120
|
+
const { scrollWidth, clientWidth, scrollLeft } = container;
|
|
121
|
+
const remainingScroll = scrollWidth - clientWidth - Math.ceil(scrollLeft);
|
|
122
|
+
this._startHidden = container.scrollLeft > 0;
|
|
123
|
+
this._endHidden = remainingScroll > 0;
|
|
124
|
+
if (this._startHidden) {
|
|
125
|
+
this._backwardButton.classList.remove('hidden');
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
this._backwardButton.classList.add('hidden');
|
|
129
|
+
}
|
|
130
|
+
if (this._endHidden) {
|
|
131
|
+
this._forwardButton.classList.remove('hidden');
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this._forwardButton.classList.add('hidden');
|
|
135
|
+
}
|
|
136
|
+
const classNames = ['', 'startHidden', 'endHidden', 'midle'];
|
|
137
|
+
const currentClass = classNames[Number(this._startHidden) | Number(this._endHidden) << 1];
|
|
138
|
+
classNames.forEach((name) => {
|
|
139
|
+
if (name !== currentClass && container.classList.contains(name)) {
|
|
140
|
+
container.classList.remove(name);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
if (currentClass && !container.classList.contains(currentClass)) {
|
|
144
|
+
container.classList.add(currentClass);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
domScrollHandler() {
|
|
149
|
+
window.clearTimeout(this._scrollCallBack);
|
|
150
|
+
this._scrollCallBack = window.setTimeout(() => { this.updateScroll(); }, 200);
|
|
151
|
+
}
|
|
152
|
+
setFocusedTab(index) {
|
|
153
|
+
window.clearTimeout(this._scrollCallBackTeste);
|
|
154
|
+
this._scrollCallBackTeste = window.setTimeout(() => {
|
|
155
|
+
const tabtoscroll = this._scrollContainer.querySelector(`#tab${index}`);
|
|
156
|
+
console.log('tabtoscroll => ID', `#tab${this.selectedindex}`);
|
|
157
|
+
console.log('tabtoscroll', tabtoscroll);
|
|
158
|
+
tabtoscroll.scrollIntoView();
|
|
159
|
+
}, 200);
|
|
160
|
+
}
|
|
161
|
+
getTextWidth(text) {
|
|
162
|
+
if (this._textMesurement === undefined) {
|
|
163
|
+
this._textMesurement = this._hostElem.shadowRoot.ownerDocument.createElement("canvas");
|
|
164
|
+
}
|
|
165
|
+
const context = this._textMesurement.getContext("2d");
|
|
166
|
+
context.font = '14px Sora, Algerian';
|
|
167
|
+
return Math.min(220, 24 + context.measureText(text).width) + 'px';
|
|
168
|
+
}
|
|
169
|
+
;
|
|
170
|
+
setFoucusedBtn(visible, paramater) {
|
|
171
|
+
const tabsButtons = this._scrollContainer.querySelectorAll('.tab');
|
|
172
|
+
tabsButtons.forEach((el) => {
|
|
173
|
+
el.classList.remove('is-focused');
|
|
174
|
+
if (el.id === 'tab' + paramater && visible) {
|
|
175
|
+
el.classList.add('is-focused');
|
|
176
|
+
}
|
|
177
|
+
;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
render() {
|
|
181
|
+
return (h(Host, null,
|
|
182
|
+
h("button", { class: "backward-button", ref: (el) => this._backwardButton = el, onClick: () => this.scrollBackward() }),
|
|
183
|
+
h("div", { class: "scroll", ref: (el) => this._scrollContainer = el,
|
|
184
|
+
// onScroll={() => this.domScrollHandler()}
|
|
185
|
+
onKeyDown: (ev) => this.setFoucusedParam(ev) }, this._processedTabs.map((tab, index) => {
|
|
186
|
+
const labelStyle = { 'min-width': this.getTextWidth(tab.label) };
|
|
187
|
+
const tabId = "tab" + index;
|
|
188
|
+
const isSelected = index === parseInt(this.selectedindex) || (this.selectedtab && tab.tabKey === this.selectedtab);
|
|
189
|
+
if (isSelected) {
|
|
190
|
+
this.selectedtab = tab.tabKey;
|
|
191
|
+
this.selectedindex = index.toString();
|
|
192
|
+
}
|
|
193
|
+
return h("button", { id: tabId, class: `tab${isSelected ? " is-active" : ""}`, onClick: () => this.handleTabClick(tab.tabKey, index), style: labelStyle },
|
|
194
|
+
h("span", { class: "tab-label", title: tab.label }, tab.label),
|
|
195
|
+
h("slot", { name: tabId, onSlotchange: (ev) => { this.handleSlotChange(ev); } }));
|
|
196
|
+
})),
|
|
197
|
+
h("button", { class: "forward-button", ref: (el) => this._forwardButton = el, onClick: () => this.scrollFoward() })));
|
|
198
|
+
}
|
|
199
|
+
static get is() { return "ez-tabselector"; }
|
|
200
|
+
static get encapsulation() { return "shadow"; }
|
|
201
|
+
static get originalStyleUrls() { return {
|
|
202
|
+
"$": ["ez-tabselector.css"]
|
|
203
|
+
}; }
|
|
204
|
+
static get styleUrls() { return {
|
|
205
|
+
"$": ["ez-tabselector.css"]
|
|
206
|
+
}; }
|
|
207
|
+
static get properties() { return {
|
|
208
|
+
"selectedindex": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"mutable": true,
|
|
211
|
+
"complexType": {
|
|
212
|
+
"original": "string",
|
|
213
|
+
"resolved": "string",
|
|
214
|
+
"references": {}
|
|
215
|
+
},
|
|
216
|
+
"required": false,
|
|
217
|
+
"optional": false,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [],
|
|
220
|
+
"text": ""
|
|
221
|
+
},
|
|
222
|
+
"attribute": "selectedindex",
|
|
223
|
+
"reflect": true
|
|
224
|
+
},
|
|
225
|
+
"selectedtab": {
|
|
226
|
+
"type": "string",
|
|
227
|
+
"mutable": true,
|
|
228
|
+
"complexType": {
|
|
229
|
+
"original": "string",
|
|
230
|
+
"resolved": "string",
|
|
231
|
+
"references": {}
|
|
232
|
+
},
|
|
233
|
+
"required": false,
|
|
234
|
+
"optional": false,
|
|
235
|
+
"docs": {
|
|
236
|
+
"tags": [],
|
|
237
|
+
"text": ""
|
|
238
|
+
},
|
|
239
|
+
"attribute": "selectedtab",
|
|
240
|
+
"reflect": true
|
|
241
|
+
},
|
|
242
|
+
"tabs": {
|
|
243
|
+
"type": "string",
|
|
244
|
+
"mutable": false,
|
|
245
|
+
"complexType": {
|
|
246
|
+
"original": "string",
|
|
247
|
+
"resolved": "string",
|
|
248
|
+
"references": {}
|
|
249
|
+
},
|
|
250
|
+
"required": false,
|
|
251
|
+
"optional": false,
|
|
252
|
+
"docs": {
|
|
253
|
+
"tags": [],
|
|
254
|
+
"text": ""
|
|
255
|
+
},
|
|
256
|
+
"attribute": "tabs",
|
|
257
|
+
"reflect": false
|
|
258
|
+
}
|
|
259
|
+
}; }
|
|
260
|
+
static get events() { return [{
|
|
261
|
+
"method": "change",
|
|
262
|
+
"name": "change",
|
|
263
|
+
"bubbles": true,
|
|
264
|
+
"cancelable": true,
|
|
265
|
+
"composed": true,
|
|
266
|
+
"docs": {
|
|
267
|
+
"tags": [],
|
|
268
|
+
"text": ""
|
|
269
|
+
},
|
|
270
|
+
"complexType": {
|
|
271
|
+
"original": "string",
|
|
272
|
+
"resolved": "string",
|
|
273
|
+
"references": {}
|
|
274
|
+
}
|
|
275
|
+
}]; }
|
|
276
|
+
static get elementRef() { return "_hostElem"; }
|
|
277
|
+
}
|
|
278
|
+
class Tab {
|
|
279
|
+
constructor(label, tabKey) {
|
|
280
|
+
this.label = label;
|
|
281
|
+
this.tabKey = tabKey;
|
|
282
|
+
}
|
|
283
|
+
}
|