@omegagrid/tabs 0.10.2 → 0.10.4
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/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +4 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/tabContainer.d.ts +59 -0
- package/dist/components/tabContainer.d.ts.map +1 -0
- package/dist/components/tabContainer.js +292 -0
- package/dist/components/tabContainer.js.map +1 -0
- package/dist/components/tabContainer.style.d.ts +2 -0
- package/dist/components/tabContainer.style.d.ts.map +1 -0
- package/dist/components/tabContainer.style.js +30 -0
- package/dist/components/tabContainer.style.js.map +1 -0
- package/dist/components/tabSplitContainer.d.ts +43 -0
- package/dist/components/tabSplitContainer.d.ts.map +1 -0
- package/dist/components/tabSplitContainer.js +291 -0
- package/dist/components/tabSplitContainer.js.map +1 -0
- package/dist/components/tabs.d.ts +66 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +360 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/tabs.style.d.ts +2 -0
- package/dist/components/tabs.style.d.ts.map +1 -0
- package/dist/components/tabs.style.js +191 -0
- package/dist/components/tabs.style.js.map +1 -0
- package/dist/constants.d.ts +49 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +7 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/model/index.d.ts +26 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/index.js +122 -0
- package/dist/model/index.js.map +1 -0
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var TabSplitContainer_1;
|
|
8
|
+
import { LitElement, html, css } from "lit";
|
|
9
|
+
import { customElement, property, query } from "lit/decorators.js";
|
|
10
|
+
import { dom } from "@omegagrid/core";
|
|
11
|
+
import { TabContainer } from "./tabContainer";
|
|
12
|
+
import { Tabs } from "./tabs";
|
|
13
|
+
import { TabSplitContainerModel } from "../model";
|
|
14
|
+
let TabSplitContainer = TabSplitContainer_1 = class TabSplitContainer extends LitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.addButton = false;
|
|
18
|
+
this.closable = false;
|
|
19
|
+
this.singleActive = false;
|
|
20
|
+
this.tabPosition = 'top';
|
|
21
|
+
this.scrollableTabs = false;
|
|
22
|
+
this.tabContainers = new Set();
|
|
23
|
+
this.loadState = 0;
|
|
24
|
+
this._createTabContainer = (containerIndex) => {
|
|
25
|
+
const component = dom.createElement('og-tabcontainer');
|
|
26
|
+
component.draggableTabs = true;
|
|
27
|
+
component.inactive = this.singleActive;
|
|
28
|
+
component.index = containerIndex;
|
|
29
|
+
component.parentContainer = this;
|
|
30
|
+
component.tabPosition = this.tabPosition;
|
|
31
|
+
this.model.items = this.model.items ?? [];
|
|
32
|
+
component.closable = this.closable;
|
|
33
|
+
component.addButton = this.addButton;
|
|
34
|
+
component.scrollableTabs = this.scrollableTabs;
|
|
35
|
+
component.style.height = '100%';
|
|
36
|
+
const item = this.model.items[containerIndex];
|
|
37
|
+
component.items = item?.tabs ?? [];
|
|
38
|
+
component.selectedIndex = item.selectedIndex;
|
|
39
|
+
component.topLevelComponent = this.topLevelComponent;
|
|
40
|
+
//component.actions = [{key: 'split', icon: 'table-columns'}];
|
|
41
|
+
// component.addEventListener('tabs.action.split', (e) => {
|
|
42
|
+
// e.stopPropagation();
|
|
43
|
+
// const newItem: TabSplitContainerItem = {size: null, tabs: []};
|
|
44
|
+
// this.model.items.splice(containerIndex + 1, 0, newItem);
|
|
45
|
+
// this.model.items.forEach(item => item.size = null);
|
|
46
|
+
// this.requestUpdate();
|
|
47
|
+
// });
|
|
48
|
+
component.addEventListener('tab.remove', () => {
|
|
49
|
+
if (component.tabs.items.length == 0) {
|
|
50
|
+
if (this.model.items.length > 1)
|
|
51
|
+
this.model.items.splice(containerIndex, 1);
|
|
52
|
+
this.model.items.forEach(item => item.size = null);
|
|
53
|
+
this.requestUpdate();
|
|
54
|
+
}
|
|
55
|
+
this.removeEmptyContainers();
|
|
56
|
+
});
|
|
57
|
+
component.addEventListener('tab.move', () => {
|
|
58
|
+
this.removeEmptyContainers();
|
|
59
|
+
});
|
|
60
|
+
component.addEventListener('tab.select', (e) => {
|
|
61
|
+
if (e.tabs.topLevelComponent == this.topLevelComponent && item) {
|
|
62
|
+
item.selectedIndex = e.tabs.selectedIndex;
|
|
63
|
+
if (this.singleActive) {
|
|
64
|
+
this._activeTabContainer = component;
|
|
65
|
+
this._activeTab = e.tab;
|
|
66
|
+
this.updateActiveTab();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
component.createComponent = this.createComponent;
|
|
71
|
+
return component;
|
|
72
|
+
};
|
|
73
|
+
this._createSplitContainer = (containerIndex) => {
|
|
74
|
+
const component = dom.createElement('og-tabsplitcontainer');
|
|
75
|
+
component.style.height = '100%';
|
|
76
|
+
component.addButton = this.addButton;
|
|
77
|
+
component.scrollableTabs = this.scrollableTabs;
|
|
78
|
+
component.tabPosition = this.tabPosition;
|
|
79
|
+
component.model = this.model.items[containerIndex].container;
|
|
80
|
+
component.createComponent = this.createComponent;
|
|
81
|
+
component.topLevelComponent = this.topLevelComponent;
|
|
82
|
+
component.closable = this.closable;
|
|
83
|
+
component.singleActive = this.singleActive;
|
|
84
|
+
return component;
|
|
85
|
+
};
|
|
86
|
+
this._createSplitContainerComponent = (id) => new Promise((resolve, reject) => {
|
|
87
|
+
const containerIndex = id;
|
|
88
|
+
const container = this.model.items ? this.model.items[containerIndex] : null;
|
|
89
|
+
if (container) {
|
|
90
|
+
const containerComponent = container.container
|
|
91
|
+
? this._createSplitContainer(containerIndex)
|
|
92
|
+
: this._createTabContainer(containerIndex);
|
|
93
|
+
containerComponent.addEventListener('load', () => {
|
|
94
|
+
this.loadState++;
|
|
95
|
+
if (this.loadState == this.splitContainer.items.length)
|
|
96
|
+
this.dispatchEvent(new Event('load'));
|
|
97
|
+
});
|
|
98
|
+
this.tabContainers.add(containerComponent);
|
|
99
|
+
resolve(containerComponent);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
reject();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
this._onDrop = (e) => {
|
|
106
|
+
if (!TabContainer.dragParent && !Tabs.dragParent)
|
|
107
|
+
return;
|
|
108
|
+
if (TabContainer.dragParent.topLevelComponent != this.topLevelComponent && Tabs.dragParent.topLevelComponent != this.topLevelComponent)
|
|
109
|
+
return;
|
|
110
|
+
e.stopImmediatePropagation();
|
|
111
|
+
const tabContainer1 = TabContainer.dragParent;
|
|
112
|
+
const tabContainer2 = TabContainer.dropTarget;
|
|
113
|
+
TabContainer.dragParent = null;
|
|
114
|
+
TabContainer.dropTarget = null;
|
|
115
|
+
if (!tabContainer1 || !tabContainer2) {
|
|
116
|
+
if (tabContainer1 && tabContainer1.parentContainer.model.items[tabContainer1.index].tabs.length == 0) {
|
|
117
|
+
tabContainer1.parentContainer.model.items.splice(tabContainer1.index, 1);
|
|
118
|
+
}
|
|
119
|
+
tabContainer1.parentContainer.splitContainer.requestUpdate();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const tab = tabContainer1.tabs.removeTab(Tabs.dragIndex, false);
|
|
123
|
+
const dropOrientation = TabContainer.dropPosition
|
|
124
|
+
? ['left', 'right'].includes(TabContainer.dropPosition) ? 'horizontal' : 'vertical'
|
|
125
|
+
: null;
|
|
126
|
+
const parentContainer2 = tabContainer2?.parentContainer;
|
|
127
|
+
if (parentContainer2) {
|
|
128
|
+
if (dropOrientation == null) {
|
|
129
|
+
const item = parentContainer2.model.items[tabContainer2.index];
|
|
130
|
+
item.tabs.push(tab);
|
|
131
|
+
}
|
|
132
|
+
else if (dropOrientation == parentContainer2.model.orientation) {
|
|
133
|
+
parentContainer2.model.items.splice(tabContainer2.index + (['right', 'bottom'].includes(TabContainer.dropPosition) ? 1 : 0), 0, { tabs: [tab] });
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const item = parentContainer2.model.items[tabContainer2.index];
|
|
137
|
+
item.container = new TabSplitContainerModel({
|
|
138
|
+
orientation: dropOrientation,
|
|
139
|
+
items: [{
|
|
140
|
+
tabs: item.tabs
|
|
141
|
+
}, {
|
|
142
|
+
tabs: [tab]
|
|
143
|
+
}]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
parentContainer2.splitContainer.resetContainerSizes();
|
|
147
|
+
parentContainer2.splitContainer.items = parentContainer2.model.items;
|
|
148
|
+
// parentContainer2.splitContainer.requestUpdate();
|
|
149
|
+
}
|
|
150
|
+
const parentContainer1 = tabContainer1?.parentContainer;
|
|
151
|
+
if (parentContainer1) {
|
|
152
|
+
for (let i = parentContainer1.model.items.length - 1; i >= 0; i--) {
|
|
153
|
+
const item = parentContainer1.model.items[i];
|
|
154
|
+
if ((!item.tabs || item.tabs.length == 0) && !item.container) {
|
|
155
|
+
parentContainer1.model.items.splice(i, 1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
parentContainer1.splitContainer.resetContainerSizes();
|
|
159
|
+
parentContainer1.splitContainer.requestUpdate();
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
this.render = () => this.model ? html `
|
|
163
|
+
<og-splitcontainer
|
|
164
|
+
orientation=${this.model?.orientation}
|
|
165
|
+
.items="${this.model.items ?? []}"
|
|
166
|
+
.createComponent="${this._createSplitContainerComponent}"
|
|
167
|
+
@drop="${this._onDrop}">
|
|
168
|
+
</og-splitcontainer>
|
|
169
|
+
` : '';
|
|
170
|
+
}
|
|
171
|
+
get activeTabContainer() { return this._activeTabContainer; }
|
|
172
|
+
get activeTab() { return this._activeTab; }
|
|
173
|
+
walk(cb) {
|
|
174
|
+
this.tabContainers.forEach(container => {
|
|
175
|
+
if (container instanceof TabSplitContainer_1)
|
|
176
|
+
container.walk(cb);
|
|
177
|
+
else {
|
|
178
|
+
const res = cb(this, container);
|
|
179
|
+
if (res === false)
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
willUpdate() {
|
|
185
|
+
if (!this.topLevelComponent)
|
|
186
|
+
this.topLevelComponent = this;
|
|
187
|
+
if (this.model && !this.model.orientation)
|
|
188
|
+
this.model.orientation = 'horizontal';
|
|
189
|
+
}
|
|
190
|
+
updateTabs() { this.tabContainers.forEach(tabContainer => tabContainer.updateTabs()); }
|
|
191
|
+
updateTab(id, tab) {
|
|
192
|
+
this.walk((_splitContainer, tabContainer) => {
|
|
193
|
+
const tabIndex = tabContainer.items.findIndex(item => item.id == id);
|
|
194
|
+
const currentTab = tabContainer.tabs.items[tabIndex];
|
|
195
|
+
if (currentTab) {
|
|
196
|
+
Object.assign(currentTab, tab);
|
|
197
|
+
if (tabContainer.selectedIndex == tabIndex && id != tab.id) {
|
|
198
|
+
// component is visible and id has changed
|
|
199
|
+
this.updateTabs();
|
|
200
|
+
tabContainer.loadComponent(currentTab.id);
|
|
201
|
+
tabContainer.components.delete(id);
|
|
202
|
+
this.updateActiveTab();
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async removeEmptyContainers() {
|
|
209
|
+
if (this.model.clean()) {
|
|
210
|
+
this.requestUpdate();
|
|
211
|
+
await this.updateComplete;
|
|
212
|
+
this.layout();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
updateActiveTab() {
|
|
216
|
+
if (!this.singleActive)
|
|
217
|
+
return;
|
|
218
|
+
this.topLevelComponent.walk((_splitContainer, tabContainer) => {
|
|
219
|
+
tabContainer.inactive = tabContainer != this.activeTabContainer;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
activate(id) {
|
|
223
|
+
this.open({ id });
|
|
224
|
+
}
|
|
225
|
+
open(item, containerIndex = 0) {
|
|
226
|
+
let container = this.splitContainer.getContainerComponent(containerIndex);
|
|
227
|
+
let model = this.model;
|
|
228
|
+
// prevent opening the same tab twice
|
|
229
|
+
this.walk((splitContainer, tabContainer) => {
|
|
230
|
+
for (let i = 0; i < tabContainer.items.length; i++) {
|
|
231
|
+
const tabItem = tabContainer.items[i];
|
|
232
|
+
if (tabItem.id == item.id) {
|
|
233
|
+
container = tabContainer;
|
|
234
|
+
model = splitContainer.model;
|
|
235
|
+
container.selectedIndex = i;
|
|
236
|
+
containerIndex = container.index;
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
container.open(item);
|
|
242
|
+
if (model.items[containerIndex]) {
|
|
243
|
+
model.items[containerIndex].tabs = container.items;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
layout() {
|
|
247
|
+
this.splitContainer?.layout();
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
TabSplitContainer.styles = css `
|
|
251
|
+
:host {
|
|
252
|
+
display: block;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
og-splitcontainer {
|
|
256
|
+
height: 100%;
|
|
257
|
+
}
|
|
258
|
+
`;
|
|
259
|
+
__decorate([
|
|
260
|
+
property({ type: Object })
|
|
261
|
+
], TabSplitContainer.prototype, "topLevelComponent", void 0);
|
|
262
|
+
__decorate([
|
|
263
|
+
property({ type: Object })
|
|
264
|
+
], TabSplitContainer.prototype, "model", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
property({ type: Boolean })
|
|
267
|
+
], TabSplitContainer.prototype, "addButton", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
property({ type: Boolean })
|
|
270
|
+
], TabSplitContainer.prototype, "closable", void 0);
|
|
271
|
+
__decorate([
|
|
272
|
+
property({ type: Boolean })
|
|
273
|
+
], TabSplitContainer.prototype, "singleActive", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
property({ type: String, reflect: true })
|
|
276
|
+
], TabSplitContainer.prototype, "tabPosition", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
property({ type: Boolean })
|
|
279
|
+
], TabSplitContainer.prototype, "scrollableTabs", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
property({ type: Object })
|
|
282
|
+
], TabSplitContainer.prototype, "createComponent", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
query('og-splitcontainer')
|
|
285
|
+
], TabSplitContainer.prototype, "splitContainer", void 0);
|
|
286
|
+
TabSplitContainer = TabSplitContainer_1 = __decorate([
|
|
287
|
+
customElement('og-tabsplitcontainer')
|
|
288
|
+
// @stylable({vars: ['tab-*']})
|
|
289
|
+
], TabSplitContainer);
|
|
290
|
+
export { TabSplitContainer };
|
|
291
|
+
//# sourceMappingURL=tabSplitContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabSplitContainer.js","sourceRoot":"","sources":["../../src/components/tabSplitContainer.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;A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;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4DACM;AAG/B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;gDACK;AAG9B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;oDACR;AAGlB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;mDACT;AAGjB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;uDACL;AAGrB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;sDACF;AAGtC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;yDACH;AAGvB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;0DACS;AAGlC;IADC,KAAK,CAAC,mBAAmB,CAAC;yDACI;AArCnB,iBAAiB;IAF7B,aAAa,CAAC,sBAAsB,CAAC;IACtC,+BAA+B;GAClB,iBAAiB,CAiS7B","sourcesContent":["import { LitElement, html, css } from \"lit\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { TabItem } from '../types';\nimport { dom, ComponentFactory, SplitContainer, Layout, ComponentId, Orientation, VerticalPosition } from \"@omegagrid/core\";\nimport { TabContainer } from \"./tabContainer\";\nimport { TabEvent, Tabs } from \"./tabs\";\nimport { TabSplitContainerModel } from \"../model\";\n\ntype TabSplitContainerTabContainer = TabContainer & {\n\tindex: number,\n\tparentContainer: TabSplitContainer\n};\n\n@customElement('og-tabsplitcontainer')\n// @stylable({vars: ['tab-*']})\nexport class TabSplitContainer extends LitElement implements Layout {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tdisplay: block;\n\t\t}\n\n\t\tog-splitcontainer {\n\t\t\theight: 100%;\n\t\t}\n\t`;\n\n\t@property({type: Object})\n\ttopLevelComponent: HTMLElement;\n\n\t@property({type: Object})\n\tmodel: TabSplitContainerModel;\n\n\t@property({type: Boolean})\n\taddButton = false;\n\n\t@property({type: Boolean})\n\tclosable = false;\n\n\t@property({type: Boolean})\n\tsingleActive = false;\n\t\n\t@property({type: String, reflect: true})\n\ttabPosition: VerticalPosition = 'top';\n\n\t@property({type: Boolean})\n\tscrollableTabs = false;\n\n\t@property({type: Object})\n\tcreateComponent: ComponentFactory;\n\n\t@query('og-splitcontainer')\n\tsplitContainer: SplitContainer;\n\n\ttabContainers = new Set<TabSplitContainerTabContainer|TabSplitContainer>();\n\t\n\tprivate _activeTabContainer: TabContainer;\n\tget activeTabContainer() { return this._activeTabContainer }\n\t\n\tprivate _activeTab: TabItem;\n\tget activeTab() { return this._activeTab }\n\n\tprivate loadState = 0;\n\n\twalk(cb: (splitContainer: TabSplitContainer, tabContainer: TabSplitContainerTabContainer) => boolean|void) {\n\t\tthis.tabContainers.forEach(container => {\n\t\t\tif (container instanceof TabSplitContainer) container.walk(cb);\n\t\t\telse {\n\t\t\t\tconst res = cb(this, container);\n\t\t\t\tif (res === false) return;\n\t\t\t}\n\t\t});\n\t}\n\t\n\twillUpdate() {\n\t\tif (!this.topLevelComponent) this.topLevelComponent = this;\n\t\tif (this.model && !this.model.orientation) this.model.orientation = 'horizontal';\n\t}\n\n\tupdateTabs() { this.tabContainers.forEach(tabContainer => tabContainer.updateTabs()) }\n\n\tupdateTab(id: ComponentId, tab: Partial<TabItem>) {\n\t\tthis.walk((_splitContainer, tabContainer) => {\n\t\t\tconst tabIndex = tabContainer.items.findIndex(item => item.id == id);\n\t\t\tconst currentTab = tabContainer.tabs.items[tabIndex];\n\t\t\tif (currentTab) {\n\t\t\t\tObject.assign(currentTab, tab);\n\t\t\t\tif (tabContainer.selectedIndex == tabIndex && id != tab.id) {\n\t\t\t\t\t// component is visible and id has changed\n\t\t\t\t\tthis.updateTabs();\n\t\t\t\t\ttabContainer.loadComponent(currentTab.id);\n\t\t\t\t\ttabContainer.components.delete(id);\n\t\t\t\t\tthis.updateActiveTab();\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t}\n\n\tasync removeEmptyContainers() {\n\t\tif (this.model.clean()) {\n\t\t\tthis.requestUpdate();\n\t\t\tawait this.updateComplete;\n\t\t\tthis.layout();\n\t\t}\n\t}\n\n\tupdateActiveTab() {\n\t\tif (!this.singleActive) return;\n\t\t(this.topLevelComponent as TabSplitContainer).walk((_splitContainer, tabContainer) => {\n\t\t\ttabContainer.inactive = tabContainer != this.activeTabContainer;\n\t\t});\n\t}\n\n\t_createTabContainer = (containerIndex: number) => {\n\t\tconst component = dom.createElement<TabSplitContainerTabContainer>('og-tabcontainer');\n\t\tcomponent.draggableTabs = true;\n\t\tcomponent.inactive = this.singleActive;\n\t\tcomponent.index = containerIndex;\n\t\tcomponent.parentContainer = this;\n\t\tcomponent.tabPosition = this.tabPosition;\n\t\tthis.model.items = this.model.items ?? [];\n\t\tcomponent.closable = this.closable;\n\t\tcomponent.addButton = this.addButton;\n\t\tcomponent.scrollableTabs = this.scrollableTabs;\n\t\tcomponent.style.height = '100%';\n\t\tconst item = this.model.items[containerIndex];\n\t\tcomponent.items = item?.tabs ?? [];\n\t\tcomponent.selectedIndex = item.selectedIndex;\n\t\tcomponent.topLevelComponent = this.topLevelComponent;\n\t\t\n\t\t//component.actions = [{key: 'split', icon: 'table-columns'}];\n\n\t\t// component.addEventListener('tabs.action.split', (e) => {\n\t\t// \te.stopPropagation();\n\t\t// \tconst newItem: TabSplitContainerItem = {size: null, tabs: []};\n\t\t// \tthis.model.items.splice(containerIndex + 1, 0, newItem);\n\t\t// \tthis.model.items.forEach(item => item.size = null);\n\t\t// \tthis.requestUpdate();\n\t\t// });\n\n\t\tcomponent.addEventListener('tab.remove', () => {\n\t\t\tif (component.tabs.items.length == 0) {\n\t\t\t\tif (this.model.items.length > 1) this.model.items.splice(containerIndex, 1);\n\t\t\t\tthis.model.items.forEach(item => item.size = null);\n\t\t\t\tthis.requestUpdate();\n\t\t\t}\n\t\t\tthis.removeEmptyContainers();\n\t\t});\n\n\t\tcomponent.addEventListener('tab.move', () => {\n\t\t\tthis.removeEmptyContainers();\n\t\t});\n\n\t\tcomponent.addEventListener('tab.select', (e: TabEvent) => {\n\t\t\tif (e.tabs.topLevelComponent == this.topLevelComponent && item) {\n\t\t\t\titem.selectedIndex = e.tabs.selectedIndex;\n\t\t\t\tif (this.singleActive) {\n\t\t\t\t\tthis._activeTabContainer = component;\n\t\t\t\t\tthis._activeTab = e.tab;\n\t\t\t\t\tthis.updateActiveTab();\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tcomponent.createComponent = this.createComponent;\n\t\treturn component;\n\t};\n\n\t_createSplitContainer = (containerIndex: number) => {\n\t\tconst component = dom.createElement<TabSplitContainer>('og-tabsplitcontainer');\n\t\tcomponent.style.height = '100%';\n\t\tcomponent.addButton = this.addButton;\n\t\tcomponent.scrollableTabs = this.scrollableTabs;\n\t\tcomponent.tabPosition = this.tabPosition;\n\t\tcomponent.model = this.model.items[containerIndex].container as TabSplitContainerModel;\n\t\tcomponent.createComponent = this.createComponent;\n\t\tcomponent.topLevelComponent = this.topLevelComponent;\n\t\tcomponent.closable = this.closable;\n\t\tcomponent.singleActive = this.singleActive;\n\t\treturn component;\n\t};\n\t\n\t_createSplitContainerComponent = (id: ComponentId) => new Promise<TabContainer|TabSplitContainer>((resolve, reject) => {\n\t\tconst containerIndex = id as number;\n\t\tconst container = this.model.items ? this.model.items[containerIndex] : null;\n\t\tif (container) {\n\t\t\tconst containerComponent = container.container\n\t\t\t\t? this._createSplitContainer(containerIndex)\n\t\t\t\t: this._createTabContainer(containerIndex);\n\t\t\tcontainerComponent.addEventListener('load', () => {\n\t\t\t\tthis.loadState++;\n\t\t\t\tif (this.loadState == this.splitContainer.items.length) this.dispatchEvent(new Event('load'));\n\t\t\t});\n\t\t\tthis.tabContainers.add(containerComponent);\n\t\t\tresolve(containerComponent);\n\t\t} else {\n\t\t\treject();\n\t\t}\n\t});\n\n\t_onDrop = (e: DragEvent) => {\n\t\tif (!TabContainer.dragParent && !Tabs.dragParent) return;\n\t\tif (TabContainer.dragParent.topLevelComponent != this.topLevelComponent && Tabs.dragParent.topLevelComponent != this.topLevelComponent) return;\n\t\t\n\t\te.stopImmediatePropagation();\n\t\tconst tabContainer1 = TabContainer.dragParent as TabSplitContainerTabContainer;\n\t\tconst tabContainer2 = TabContainer.dropTarget as TabSplitContainerTabContainer;\n\t\t\n\t\tTabContainer.dragParent = null;\n\t\tTabContainer.dropTarget = null;\n\t\t\n\t\tif (!tabContainer1 || !tabContainer2) {\n\t\t\tif (tabContainer1 && tabContainer1.parentContainer.model.items[tabContainer1.index].tabs.length == 0) {\n\t\t\t\ttabContainer1.parentContainer.model.items.splice(tabContainer1.index, 1);\n\t\t\t}\n\t\t\ttabContainer1.parentContainer.splitContainer.requestUpdate();\n\t\t\treturn;\n\t\t}\n\t\t\n\t\tconst tab = tabContainer1.tabs.removeTab(Tabs.dragIndex, false);\n\t\tconst dropOrientation: Orientation = TabContainer.dropPosition \n\t\t\t? ['left', 'right'].includes(TabContainer.dropPosition) ? 'horizontal' : 'vertical'\n\t\t\t: null;\n\n\t\tconst parentContainer2 = tabContainer2?.parentContainer;\n\t\tif (parentContainer2) {\n\t\t\tif (dropOrientation == null) {\n\t\t\t\tconst item = parentContainer2.model.items[tabContainer2.index];\n\t\t\t\titem.tabs.push(tab);\n\t\t\t} else if (dropOrientation == parentContainer2.model.orientation) {\n\t\t\t\tparentContainer2.model.items.splice(\n\t\t\t\t\ttabContainer2.index + (['right', 'bottom'].includes(TabContainer.dropPosition) ? 1 : 0), 0, {tabs: [tab]}\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tconst item = parentContainer2.model.items[tabContainer2.index];\n\t\t\t\titem.container = new TabSplitContainerModel({\n\t\t\t\t\torientation: dropOrientation,\n\t\t\t\t\titems: [{\n\t\t\t\t\t\ttabs: item.tabs\n\t\t\t\t\t}, {\n\t\t\t\t\t\ttabs: [tab]\n\t\t\t\t\t}]\n\t\t\t\t});\n\t\t\t}\n\t\t\tparentContainer2.splitContainer.resetContainerSizes();\n\t\t\tparentContainer2.splitContainer.items = parentContainer2.model.items;\n\t\t\t// parentContainer2.splitContainer.requestUpdate();\n\t\t}\n\n\t\tconst parentContainer1 = tabContainer1?.parentContainer;\n\t\tif (parentContainer1) {\n\t\t\tfor (let i = parentContainer1.model.items.length - 1; i >= 0; i--) {\n\t\t\t\tconst item = parentContainer1.model.items[i];\n\t\t\t\tif ((!item.tabs || item.tabs.length == 0) && !item.container) {\n\t\t\t\t\tparentContainer1.model.items.splice(i, 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tparentContainer1.splitContainer.resetContainerSizes();\n\t\t\tparentContainer1.splitContainer.requestUpdate();\n\t\t}\n\t}\n\n\tactivate(id: ComponentId) {\n\t\tthis.open({ id });\n\t}\n\n\topen(item: TabItem, containerIndex = 0) {\n\t\tlet container = this.splitContainer.getContainerComponent(containerIndex) as TabSplitContainerTabContainer;\n\t\tlet model = this.model;\n\n\t\t// prevent opening the same tab twice\n\t\tthis.walk((splitContainer, tabContainer) => {\n\t\t\tfor (let i = 0; i < tabContainer.items.length; i++) {\n\t\t\t\tconst tabItem = tabContainer.items[i];\n\t\t\t\tif (tabItem.id == item.id) {\n\t\t\t\t\tcontainer = tabContainer;\n\t\t\t\t\tmodel = splitContainer.model;\n\t\t\t\t\tcontainer.selectedIndex = i;\n\t\t\t\t\tcontainerIndex = container.index;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tcontainer.open(item);\n\t\tif (model.items[containerIndex]) {\n\t\t\tmodel.items[containerIndex].tabs = container.items;\n\t\t}\n\t}\n\n\trender = () => this.model ? html`\n\t\t<og-splitcontainer\n\t\t\torientation=${this.model?.orientation}\n\t\t\t.items=\"${this.model.items ?? []}\"\n\t\t\t.createComponent=\"${this._createSplitContainerComponent}\"\n\t\t\t@drop=\"${this._onDrop}\">\n\t\t</og-splitcontainer>\n\t` : '';\n\n\tlayout() {\n\t\tthis.splitContainer?.layout();\n\t}\n\n}"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LitElement } from "lit";
|
|
2
|
+
import { TabItem } from '../types';
|
|
3
|
+
import { ListSelectEvent, Menu, actions, ComponentId, VerticalPosition, HorizontalPosition } from "@omegagrid/core";
|
|
4
|
+
import { TabContainer } from "./tabContainer";
|
|
5
|
+
export declare class TabEvent extends Event {
|
|
6
|
+
index: number;
|
|
7
|
+
tabs: Tabs;
|
|
8
|
+
tab: TabItem;
|
|
9
|
+
uiEvent: UIEvent;
|
|
10
|
+
constructor(type: string, args: Partial<TabEvent>);
|
|
11
|
+
}
|
|
12
|
+
export type TabSize = 'auto' | 'stretch' | string | number;
|
|
13
|
+
export declare class Tabs extends LitElement {
|
|
14
|
+
static styles: import("lit").CSSResult[];
|
|
15
|
+
static dragParent: Tabs;
|
|
16
|
+
static dragIndex: number;
|
|
17
|
+
static dragTarget: Tabs;
|
|
18
|
+
static dropIndex: number;
|
|
19
|
+
topLevelComponent: HTMLElement;
|
|
20
|
+
items: TabItem[];
|
|
21
|
+
closable: boolean;
|
|
22
|
+
draggable: boolean;
|
|
23
|
+
scrollable: boolean;
|
|
24
|
+
addButton: boolean;
|
|
25
|
+
selectedIndex: number;
|
|
26
|
+
actions: actions.Action[];
|
|
27
|
+
position: VerticalPosition;
|
|
28
|
+
tabSize: TabSize;
|
|
29
|
+
tabAlign: HorizontalPosition;
|
|
30
|
+
empty: HTMLDivElement;
|
|
31
|
+
marker: HTMLDivElement;
|
|
32
|
+
overlay: HTMLDivElement;
|
|
33
|
+
tabs: HTMLDivElement[];
|
|
34
|
+
parentContainer: TabContainer;
|
|
35
|
+
menuRef: import("lit-html/directives/ref").Ref<Menu>;
|
|
36
|
+
get menu(): Menu;
|
|
37
|
+
private _contextMenuTabIndex;
|
|
38
|
+
private _contextMenuItems;
|
|
39
|
+
get selectedItem(): TabItem;
|
|
40
|
+
get selectedTab(): HTMLDivElement;
|
|
41
|
+
get container(): TabContainer;
|
|
42
|
+
updated(): Promise<void>;
|
|
43
|
+
positionOverlay(target?: HTMLElement): HTMLElement;
|
|
44
|
+
hideOverlay: () => HTMLElement;
|
|
45
|
+
selectTab(index: number, dispatchEvent?: boolean): void;
|
|
46
|
+
getIndexById(id: ComponentId): number;
|
|
47
|
+
selectTabById(id: ComponentId, dispatchEvent?: boolean): void;
|
|
48
|
+
addTab(item: TabItem, index?: number): void;
|
|
49
|
+
removeTab(index: number, dispatchEvent?: boolean): TabItem;
|
|
50
|
+
_onDragover(e: DragEvent, index: number): void;
|
|
51
|
+
_onDragStart(_e: DragEvent, index: number): void;
|
|
52
|
+
_onDragStop(): void;
|
|
53
|
+
_onDrop(): void;
|
|
54
|
+
moveTab(fromIndex: number, toIndex: number, dispatchEvent?: boolean): void;
|
|
55
|
+
_onMenuItemSelect(e: ListSelectEvent): void;
|
|
56
|
+
_onCrossClick(e: MouseEvent, index: number): void;
|
|
57
|
+
_onContextMenu(e: MouseEvent, index: number): void;
|
|
58
|
+
_onActionClick(action: actions.Action): void;
|
|
59
|
+
disconnectedCallback(): void;
|
|
60
|
+
_onContainerDragover(e: DragEvent): void;
|
|
61
|
+
getTabSize: (index: number) => string;
|
|
62
|
+
animateMarker(): void;
|
|
63
|
+
renderTabs: () => Generator<unknown, void, unknown>;
|
|
64
|
+
render: () => import("lit-html").TemplateResult<1>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/components/tabs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,KAAK,CAAC;AAKvC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAO,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAY,gBAAgB,EAAE,kB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