odant-work 1.0.43 → 1.0.44
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/#system/package-manifest.json +22 -22
- package/$server/$folder/$class/$structure/handlers/pages/form/database/$handler/database.js +18 -43
- package/$server/$folder/$class/$structure/handlers/pages/form/search/$handler/search.js +21 -26
- package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +1 -1
- package/$server/$folder/$file/$office/handlers/pages/form/file/$handler/file.js +16 -8
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/dock.js +17 -26
- package/$server/$folder/handlers/pages/form/$handler/form.js +199 -129
- package/$server/$folder/lib/explorer/explorer.js +104 -11
- package/$server/$folder/lib/local-models-transfer/local-models-transfer.js +17 -37
- package/$server/$folder/lib/tools/tools.js +24 -6
- package/SERVICES/$service/$folder/$storage/$service/handlers/pages/form/mcp/$handler/mcp.js +18 -43
- package/oda/components/layouts/app-layout/app-layout.js +4 -1
- package/oda/components/layouts/tabs/tabs.js +784 -395
- package/oda/components/packets/packets.js +25 -20
- package/oda/components/table/row.js +6 -4
- package/oda/components/table/table.js +2 -2
- package/package.json +1 -1
- package/sources/data/progress.md +7 -0
- package/sources/modules/trainer/local-engine.js +38 -16
- package/sources/modules/trainer/worker/local_infer_worker.py +27 -6
|
@@ -1,552 +1,941 @@
|
|
|
1
|
-
ODA({is: 'oda-tabs', imports: 'oda//button',
|
|
1
|
+
ODA({is: 'oda-tabs', imports: 'oda//button, oda//icon, oda//menu-list',
|
|
2
2
|
template: /*html*/`
|
|
3
3
|
<style>
|
|
4
|
-
:host{
|
|
4
|
+
:host {
|
|
5
|
+
@apply --horizontal;
|
|
6
|
+
align-items: center;
|
|
5
7
|
overflow: hidden;
|
|
6
8
|
max-width: 100%;
|
|
7
9
|
max-height: 100%;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
gap: 6px;
|
|
12
|
+
user-select: none;
|
|
11
13
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@apply --shadow;
|
|
16
|
-
transform: scale(.7);
|
|
14
|
+
:host([direction="vertical"]) {
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: stretch;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
:host([variant="bar"]) {
|
|
19
|
+
background: var(--subtle-background);
|
|
20
|
+
color: var(--content-color);
|
|
21
|
+
border-bottom: 1px solid var(--subtle-border);
|
|
22
|
+
padding: 4px 8px;
|
|
23
|
+
min-height: 38px;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
:host([variant="rail"]) {
|
|
26
|
+
@apply --accent-invert;
|
|
27
|
+
padding: 4px 8px;
|
|
28
|
+
min-height: 38px;
|
|
29
|
+
}
|
|
30
|
+
:host([variant="pills"]) {
|
|
31
|
+
background: var(--subtle-background);
|
|
32
|
+
color: var(--content-color);
|
|
33
|
+
border: 1px solid var(--subtle-border);
|
|
34
|
+
border-radius: 10px;
|
|
35
|
+
padding: 3px;
|
|
36
|
+
gap: 3px;
|
|
37
|
+
width: fit-content;
|
|
38
|
+
min-height: 34px;
|
|
39
|
+
}
|
|
40
|
+
:host([variant="bar"][compact]),
|
|
41
|
+
:host([variant="rail"][compact]) {
|
|
42
|
+
padding: 3px 6px;
|
|
43
|
+
min-height: 32px;
|
|
44
|
+
}
|
|
45
|
+
:host([variant="pills"][compact]) {
|
|
46
|
+
padding: 2px;
|
|
47
|
+
min-height: 30px;
|
|
48
|
+
}
|
|
49
|
+
:host([hidden]) {
|
|
50
|
+
display: none !important;
|
|
27
51
|
}
|
|
28
52
|
:host([selected]) {
|
|
29
53
|
outline: 2px solid var(--accent-color);
|
|
30
54
|
}
|
|
31
|
-
|
|
32
|
-
|
|
55
|
+
.tablist-wrap {
|
|
56
|
+
@apply --horizontal;
|
|
57
|
+
align-items: center;
|
|
58
|
+
flex: 1 1 auto;
|
|
59
|
+
min-width: 0;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
outline: none;
|
|
62
|
+
}
|
|
63
|
+
:host([direction="vertical"]) .tablist-wrap {
|
|
64
|
+
flex-direction: column;
|
|
65
|
+
align-items: stretch;
|
|
66
|
+
}
|
|
67
|
+
#scroller {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: row;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
flex: 1 1 auto;
|
|
73
|
+
min-width: 0;
|
|
74
|
+
overflow-x: auto;
|
|
75
|
+
overflow-y: hidden;
|
|
76
|
+
scrollbar-width: none;
|
|
77
|
+
}
|
|
78
|
+
#scroller::-webkit-scrollbar {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
81
|
+
:host([direction="vertical"]) #scroller {
|
|
82
|
+
flex-direction: column;
|
|
83
|
+
align-items: stretch;
|
|
84
|
+
overflow-x: hidden;
|
|
85
|
+
overflow-y: auto;
|
|
86
|
+
}
|
|
87
|
+
:host([variant="pills"]) #scroller,
|
|
88
|
+
:host([no-shrink]) #scroller {
|
|
89
|
+
flex-wrap: wrap;
|
|
90
|
+
overflow: visible;
|
|
91
|
+
gap: 3px;
|
|
92
|
+
}
|
|
93
|
+
.extra-buttons {
|
|
94
|
+
display: inline-flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
gap: 4px;
|
|
97
|
+
flex-shrink: 0;
|
|
98
|
+
}
|
|
99
|
+
.list-btn {
|
|
100
|
+
border-radius: 8px !important;
|
|
101
|
+
min-width: 26px;
|
|
102
|
+
width: 26px;
|
|
103
|
+
height: 26px;
|
|
104
|
+
padding: 0 !important;
|
|
105
|
+
flex-shrink: 0;
|
|
106
|
+
opacity: 0.78;
|
|
107
|
+
transition: background-color var(--duration-fast) var(--easing), opacity var(--duration-fast) var(--easing);
|
|
108
|
+
}
|
|
109
|
+
.list-btn:hover {
|
|
110
|
+
opacity: 1;
|
|
111
|
+
}
|
|
112
|
+
:host([variant="rail"]) .list-btn {
|
|
113
|
+
color: var(--accent-back);
|
|
114
|
+
fill: var(--accent-back);
|
|
115
|
+
}
|
|
116
|
+
:host([variant="rail"]) .list-btn:hover {
|
|
117
|
+
background: color-mix(in oklch, var(--accent-back) 14%, transparent);
|
|
33
118
|
}
|
|
34
119
|
</style>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
aria-label="Tabs"
|
|
47
|
-
:direction="direction === 'vertical' ? 'horizontal' : 'vertical'"
|
|
48
|
-
style="overflow: hidden"
|
|
49
|
-
tabindex="0"
|
|
50
|
-
|
|
51
|
-
@keydown>
|
|
52
|
-
<div style="overflow-x: auto"></div>
|
|
53
|
-
<div id="scroller"
|
|
54
|
-
@resize="_onResize"
|
|
55
|
-
@scroll="_onScroll"
|
|
56
|
-
:direction
|
|
57
|
-
@mousewheel.passive
|
|
58
|
-
@dragover>
|
|
59
|
-
<oda-tabs-tab
|
|
60
|
-
role="tab"
|
|
61
|
-
:aria-selected="$for.index === focusedIndex"
|
|
120
|
+
<slot name="left" class="no-flex horizontal-center"></slot>
|
|
121
|
+
<div class="tablist-wrap" role="tablist" aria-label="Вкладки" tabindex="0" @keydown="_onKeydown">
|
|
122
|
+
<div id="scroller"
|
|
123
|
+
@resize="_onResize"
|
|
124
|
+
@scroll="_onScroll"
|
|
125
|
+
:direction
|
|
126
|
+
@mousewheel.passive="_onMousewheel"
|
|
127
|
+
@dragover="_onDragover">
|
|
128
|
+
<oda-tabs-tab
|
|
129
|
+
role="tab"
|
|
130
|
+
:aria-selected="$for.index === focusedIndex ? 'true' : 'false'"
|
|
62
131
|
:selected="$for.index === selectedIndex && selectedIndex !== focusedIndex"
|
|
63
|
-
:draggable="allowDrag"
|
|
64
|
-
~for="items"
|
|
65
|
-
:item="$for.item"
|
|
132
|
+
:draggable="allowDrag ? 'true' : 'false'"
|
|
133
|
+
~for="items"
|
|
134
|
+
:item="$for.item"
|
|
66
135
|
:index="$for.index">
|
|
67
|
-
</oda-tabs-tab>
|
|
68
|
-
<div flex></div>
|
|
69
|
-
<div style="overflow: hidden; justify-self: end;" :direction>
|
|
70
|
-
<oda-button :icon-size="iconSize * 1.2" style="margin: 8px;"
|
|
71
|
-
role="button"
|
|
72
|
-
~for="buttons"
|
|
73
|
-
~props="$for.item">
|
|
74
|
-
</oda-button>
|
|
75
|
-
</div>
|
|
136
|
+
</oda-tabs-tab>
|
|
76
137
|
</div>
|
|
77
|
-
|
|
78
138
|
</div>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
~if="items?.some(i => typeof i.close === 'function')"
|
|
96
|
-
icon="icons:close"
|
|
97
|
-
title="close all tabs"
|
|
98
|
-
@tap="closeAll">
|
|
139
|
+
<div class="extra-buttons" ~if="buttons?.length">
|
|
140
|
+
<oda-button :icon-size="16"
|
|
141
|
+
role="button"
|
|
142
|
+
~for="buttons"
|
|
143
|
+
~props="$for.item">
|
|
144
|
+
</oda-button>
|
|
145
|
+
</div>
|
|
146
|
+
<slot name="right" class="no-flex horizontal-center"></slot>
|
|
147
|
+
<oda-button
|
|
148
|
+
class="list-btn"
|
|
149
|
+
~if="showListBtn"
|
|
150
|
+
no-flex
|
|
151
|
+
icon="icons:expand-more"
|
|
152
|
+
:icon-size="18"
|
|
153
|
+
title="Список открытых вкладок"
|
|
154
|
+
@tap.stop="openTabsMenu($event)">
|
|
99
155
|
</oda-button>
|
|
100
156
|
`,
|
|
101
|
-
get _directionStyle() {
|
|
102
|
-
return `flex-direction: ${this.align === 'right' || this.align === 'bottom' ? 'row-reverse' : 'row'}`;
|
|
103
|
-
},
|
|
104
157
|
buttons: [],
|
|
158
|
+
items: [],
|
|
105
159
|
_onResize() {
|
|
106
160
|
this.__is_vertical = undefined;
|
|
107
161
|
},
|
|
108
|
-
|
|
109
162
|
_onScroll() {
|
|
110
163
|
this.__is_vertical = undefined;
|
|
111
164
|
},
|
|
112
|
-
|
|
113
165
|
attached() {
|
|
114
166
|
requestAnimationFrame(() => {
|
|
115
|
-
this.focusedTab?.scrollIntoView({
|
|
116
|
-
inline: '
|
|
117
|
-
block: '
|
|
167
|
+
this.focusedTab?.scrollIntoView({
|
|
168
|
+
inline: 'nearest',
|
|
169
|
+
block: 'nearest'
|
|
118
170
|
});
|
|
119
171
|
});
|
|
120
172
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
173
|
+
get showListBtn() {
|
|
174
|
+
if (!this.allowList || this.variant === 'pills')
|
|
175
|
+
return false;
|
|
176
|
+
return Array.isArray(this.items) && this.items.length > 1;
|
|
177
|
+
},
|
|
178
|
+
get hasAnyClosable() {
|
|
179
|
+
if (!Array.isArray(this.items))
|
|
180
|
+
return false;
|
|
181
|
+
return this.items.some(i => i?.closable !== false && (this.allowClose || i?.allowClose || i?.closable));
|
|
182
|
+
},
|
|
183
|
+
isTabClosable(item) {
|
|
184
|
+
if (!item || item.closable === false)
|
|
185
|
+
return false;
|
|
186
|
+
return Boolean(this.allowClose || item.allowClose || item.closable);
|
|
187
|
+
},
|
|
188
|
+
selectTab(index, event = null) {
|
|
189
|
+
const list = this.items || [];
|
|
190
|
+
if (index < 0 || index >= list.length)
|
|
191
|
+
return;
|
|
192
|
+
const item = list[index];
|
|
193
|
+
if (item?.disabled)
|
|
194
|
+
return;
|
|
195
|
+
this.dimmed = false;
|
|
196
|
+
this.focusedIndex = index;
|
|
197
|
+
this.dispatchEvent(new CustomEvent('tab-select', {
|
|
198
|
+
detail: { item, index, event },
|
|
199
|
+
bubbles: true,
|
|
200
|
+
composed: true,
|
|
201
|
+
}));
|
|
202
|
+
},
|
|
203
|
+
requestCloseTab(index, event = null) {
|
|
204
|
+
const list = this.items || [];
|
|
205
|
+
const item = list[index];
|
|
206
|
+
if (!this.isTabClosable(item))
|
|
207
|
+
return;
|
|
208
|
+
const closeEvt = new CustomEvent('tab-close', {
|
|
209
|
+
detail: { item, index, event },
|
|
210
|
+
bubbles: true,
|
|
211
|
+
composed: true,
|
|
212
|
+
cancelable: true,
|
|
213
|
+
});
|
|
214
|
+
this.dispatchEvent(closeEvt);
|
|
215
|
+
this.fire('close', item);
|
|
216
|
+
if (!closeEvt.defaultPrevented && typeof item.close === 'function')
|
|
217
|
+
item.close(item, index);
|
|
218
|
+
},
|
|
219
|
+
async closeOthers(keepIndex) {
|
|
220
|
+
const list = this.items || [];
|
|
221
|
+
const keepItem = list[keepIndex];
|
|
222
|
+
const evt = new CustomEvent('close-others', {
|
|
223
|
+
detail: { item: keepItem, index: keepIndex },
|
|
224
|
+
bubbles: true,
|
|
225
|
+
composed: true,
|
|
226
|
+
cancelable: true,
|
|
227
|
+
});
|
|
228
|
+
this.dispatchEvent(evt);
|
|
229
|
+
if (evt.defaultPrevented)
|
|
230
|
+
return;
|
|
231
|
+
const targets = list.filter((it, idx) => idx !== keepIndex && this.isTabClosable(it));
|
|
232
|
+
for (const it of targets.reverse()) {
|
|
233
|
+
const idx = (this.items || []).indexOf(it);
|
|
234
|
+
if (idx >= 0)
|
|
235
|
+
this.requestCloseTab(idx);
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
async closeRight(fromIndex) {
|
|
239
|
+
const list = this.items || [];
|
|
240
|
+
const fromItem = list[fromIndex];
|
|
241
|
+
const evt = new CustomEvent('close-right', {
|
|
242
|
+
detail: { item: fromItem, index: fromIndex },
|
|
243
|
+
bubbles: true,
|
|
244
|
+
composed: true,
|
|
245
|
+
cancelable: true,
|
|
246
|
+
});
|
|
247
|
+
this.dispatchEvent(evt);
|
|
248
|
+
if (evt.defaultPrevented)
|
|
249
|
+
return;
|
|
250
|
+
const targets = list.filter((it, idx) => idx > fromIndex && this.isTabClosable(it));
|
|
251
|
+
for (const it of targets.reverse()) {
|
|
252
|
+
const idx = (this.items || []).indexOf(it);
|
|
253
|
+
if (idx >= 0)
|
|
254
|
+
this.requestCloseTab(idx);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
async closeAll() {
|
|
258
|
+
const evt = new CustomEvent('close-all', {
|
|
259
|
+
detail: { items: this.items },
|
|
260
|
+
bubbles: true,
|
|
261
|
+
composed: true,
|
|
262
|
+
cancelable: true,
|
|
263
|
+
});
|
|
264
|
+
this.dispatchEvent(evt);
|
|
265
|
+
if (evt.defaultPrevented)
|
|
266
|
+
return;
|
|
267
|
+
const targets = (this.items || []).filter(it => this.isTabClosable(it));
|
|
268
|
+
for (const it of targets.reverse()) {
|
|
269
|
+
const idx = (this.items || []).indexOf(it);
|
|
270
|
+
if (idx >= 0)
|
|
271
|
+
this.requestCloseTab(idx);
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
async openTabsMenu(e) {
|
|
275
|
+
const list = this.items || [];
|
|
276
|
+
if (!list.length)
|
|
277
|
+
return;
|
|
278
|
+
const anchor = e?.currentTarget || e?.target || this;
|
|
279
|
+
const menuItems = list.map((item, idx) => ({
|
|
280
|
+
label: (item.dirty ? '● ' : '') + (item.label || item.title || `Вкладка ${idx + 1}`),
|
|
281
|
+
icon: item.icon || this.defaultIcon || 'icons:dashboard',
|
|
282
|
+
value: idx,
|
|
283
|
+
execute: () => this.selectTab(idx),
|
|
284
|
+
}));
|
|
285
|
+
const closables = list.filter(i => this.isTabClosable(i));
|
|
286
|
+
if (closables.length > 0 && list.length > 1) {
|
|
287
|
+
menuItems.push({
|
|
288
|
+
group: 'Действия',
|
|
289
|
+
label: this.closeAllLabel || 'Закрыть все',
|
|
290
|
+
icon: 'icons:close',
|
|
291
|
+
value: '__close_all__',
|
|
292
|
+
execute: () => this.closeAll(),
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
try {
|
|
296
|
+
await ODA.showMenu({ items: menuItems, value: this.focusedIndex }, anchor);
|
|
297
|
+
}
|
|
298
|
+
catch { /* отмена */ }
|
|
299
|
+
},
|
|
300
|
+
async _openTabContextMenu(index, e) {
|
|
301
|
+
if (!this.allowContextMenu)
|
|
302
|
+
return;
|
|
303
|
+
const list = this.items || [];
|
|
304
|
+
const item = list[index];
|
|
305
|
+
if (!item)
|
|
306
|
+
return;
|
|
307
|
+
if (!this.hasAnyClosable)
|
|
308
|
+
return;
|
|
309
|
+
e.preventDefault();
|
|
310
|
+
e.stopPropagation();
|
|
311
|
+
const canCloseThis = this.isTabClosable(item);
|
|
312
|
+
const hasOthers = list.some((it, idx) => idx !== index && this.isTabClosable(it));
|
|
313
|
+
const hasRight = list.some((it, idx) => idx > index && this.isTabClosable(it));
|
|
314
|
+
const hasAny = list.some(it => this.isTabClosable(it)) && list.length > 1;
|
|
315
|
+
const menuItems = [
|
|
316
|
+
{
|
|
317
|
+
label: 'Закрыть',
|
|
318
|
+
icon: 'icons:close',
|
|
319
|
+
disabled: !canCloseThis,
|
|
320
|
+
value: 'close',
|
|
321
|
+
execute: () => this.requestCloseTab(index, e),
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
label: 'Закрыть другие',
|
|
325
|
+
icon: 'icons:clear-all',
|
|
326
|
+
disabled: !hasOthers,
|
|
327
|
+
value: 'others',
|
|
328
|
+
execute: () => this.closeOthers(index),
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
label: 'Закрыть справа',
|
|
332
|
+
icon: 'icons:arrow-forward',
|
|
333
|
+
disabled: !hasRight,
|
|
334
|
+
value: 'right',
|
|
335
|
+
execute: () => this.closeRight(index),
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
group: 'Все вкладки',
|
|
339
|
+
label: this.closeAllLabel || 'Закрыть все',
|
|
340
|
+
icon: 'icons:delete-sweep',
|
|
341
|
+
disabled: !hasAny,
|
|
342
|
+
value: 'all',
|
|
343
|
+
execute: () => this.closeAll(),
|
|
344
|
+
},
|
|
345
|
+
];
|
|
346
|
+
try {
|
|
347
|
+
await ODA.showMenu({ items: menuItems }, e);
|
|
348
|
+
}
|
|
349
|
+
catch { /* отмена */ }
|
|
350
|
+
},
|
|
351
|
+
_onDragover(e) {
|
|
352
|
+
if (!this.allowDrag || !drag.item || drag.host !== this)
|
|
353
|
+
return;
|
|
354
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
355
|
+
e.preventDefault();
|
|
356
|
+
const pos = this.__is_vertical ? e.clientY : e.clientX;
|
|
357
|
+
const delta = pos - drag.start;
|
|
358
|
+
const scroller = this.__scroller;
|
|
359
|
+
if (!scroller)
|
|
360
|
+
return;
|
|
361
|
+
const rect = scroller.getBoundingClientRect();
|
|
362
|
+
const start = this.__is_vertical ? rect.top : rect.left;
|
|
363
|
+
const end = this.__is_vertical ? rect.bottom : rect.right;
|
|
364
|
+
if (pos < start + 24)
|
|
365
|
+
drag.start += this.__scroll(12);
|
|
366
|
+
else if (pos > end - 24)
|
|
367
|
+
drag.start += this.__scroll(-12);
|
|
130
368
|
|
|
131
|
-
|
|
132
|
-
|
|
369
|
+
const tr = 'translate' + (this.__is_vertical ? 'Y' : 'X');
|
|
370
|
+
const dragCenter = pos - drag.pointer + (drag.item[this.offsetSize] / 2);
|
|
371
|
+
let newIndex = drag.fromIndex;
|
|
372
|
+
const children = Array.from(scroller.children).filter(el => el.localName === 'oda-tabs-tab');
|
|
373
|
+
for (const el of children) {
|
|
374
|
+
if (el === drag.item) {
|
|
375
|
+
el.style.transform = `${tr}(${delta}px)`;
|
|
376
|
+
continue;
|
|
133
377
|
}
|
|
134
|
-
|
|
135
|
-
|
|
378
|
+
const r = el.getBoundingClientRect();
|
|
379
|
+
const center = this.__is_vertical ? (r.top + r.height / 2) : (r.left + r.width / 2);
|
|
380
|
+
if (el.index < drag.fromIndex && dragCenter < center) {
|
|
381
|
+
el.style.transform = `${tr}(${drag.item[this.offsetSize] + 4}px)`;
|
|
382
|
+
if (el.index < newIndex)
|
|
383
|
+
newIndex = el.index;
|
|
136
384
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
for (let el of drag.item.parentElement.children){
|
|
142
|
-
if (el[R].states.sleep) continue;
|
|
143
|
-
let el_pos = this.__is_vertical?el.offsetTop:el.offsetLeft - this.__scrollPos;
|
|
144
|
-
if (el === drag.item)
|
|
145
|
-
el.style.transform = tr + `(${delta}px)`;
|
|
146
|
-
else if (el_pos < drag.start && el_pos > drag_start - start - drag.item[this.offsetSize] / 2){
|
|
147
|
-
el.style.transform = tr + `(${drag.item[this.offsetSize]}px)`;
|
|
148
|
-
drag.index = el.index;
|
|
149
|
-
}
|
|
150
|
-
else if (el_pos > drag.start && el_pos + el[this.offsetSize] / 2 < drag_start - start + drag.item[this.offsetSize]){
|
|
151
|
-
el.style.transform = tr + `(${-drag.item[this.offsetSize]}px)`;
|
|
152
|
-
drag.index = el.index;
|
|
153
|
-
}
|
|
154
|
-
else{
|
|
155
|
-
el.style.transform = ''
|
|
156
|
-
}
|
|
385
|
+
else if (el.index > drag.fromIndex && dragCenter > center) {
|
|
386
|
+
el.style.transform = `${tr}(${-(drag.item[this.offsetSize] + 4)}px)`;
|
|
387
|
+
if (el.index > newIndex)
|
|
388
|
+
newIndex = el.index;
|
|
157
389
|
}
|
|
158
|
-
|
|
390
|
+
else {
|
|
391
|
+
el.style.transform = '';
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
drag.toIndex = newIndex;
|
|
159
395
|
},
|
|
160
|
-
get tabs(){
|
|
396
|
+
get tabs() {
|
|
161
397
|
return this;
|
|
162
398
|
},
|
|
163
|
-
_onMousewheel
|
|
164
|
-
this.
|
|
399
|
+
_onMousewheel(e) {
|
|
400
|
+
if (this.variant === 'pills' || this.noShrink)
|
|
401
|
+
return;
|
|
402
|
+
const delta = e.deltaY || -e.wheelDelta || 0;
|
|
403
|
+
if (delta && this.__scroller)
|
|
404
|
+
this.__scroller.scrollLeft += delta;
|
|
165
405
|
},
|
|
166
|
-
__scroll(step){
|
|
406
|
+
__scroll(step) {
|
|
407
|
+
if (!this.__scroller)
|
|
408
|
+
return 0;
|
|
167
409
|
let move = 0;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
move -= this.__scroller.scrollTop;
|
|
178
|
-
break;
|
|
410
|
+
if (this.direction === 'horizontal') {
|
|
411
|
+
move = this.__scroller.scrollLeft;
|
|
412
|
+
this.__scroller.scrollLeft -= step;
|
|
413
|
+
move -= this.__scroller.scrollLeft;
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
move = this.__scroller.scrollTop;
|
|
417
|
+
this.__scroller.scrollTop -= step;
|
|
418
|
+
move -= this.__scroller.scrollTop;
|
|
179
419
|
}
|
|
180
420
|
return move;
|
|
181
421
|
},
|
|
182
|
-
toHome(){
|
|
183
|
-
|
|
422
|
+
toHome() {
|
|
423
|
+
if (this.__scroller)
|
|
424
|
+
this.__scroller.scrollTop = this.__scroller.scrollLeft = 0;
|
|
184
425
|
},
|
|
185
|
-
toEnd(){
|
|
186
|
-
|
|
426
|
+
toEnd() {
|
|
427
|
+
if (this.__scroller)
|
|
428
|
+
this.__scroller.scrollTop = this.__scroller.scrollLeft = 100000000;
|
|
187
429
|
},
|
|
188
|
-
get __scroller(){
|
|
430
|
+
get __scroller() {
|
|
189
431
|
return this.$('#scroller') || undefined;
|
|
190
432
|
},
|
|
191
|
-
get __scrollSize(){
|
|
192
|
-
return this.__is_vertical?this.__scroller?.scrollHeight:this.__scroller?.scrollWidth;
|
|
193
|
-
},
|
|
194
|
-
get __scrollPos(){
|
|
195
|
-
return Math.round(this.__is_vertical?this.__scroller?.scrollTop:this.__scroller?.scrollLeft);
|
|
433
|
+
get __scrollSize() {
|
|
434
|
+
return this.__is_vertical ? this.__scroller?.scrollHeight : this.__scroller?.scrollWidth;
|
|
196
435
|
},
|
|
197
|
-
get
|
|
198
|
-
return this.__is_vertical?this.__scroller?.
|
|
436
|
+
get __scrollPos() {
|
|
437
|
+
return Math.round(this.__is_vertical ? (this.__scroller?.scrollTop || 0) : (this.__scroller?.scrollLeft || 0));
|
|
199
438
|
},
|
|
200
|
-
get
|
|
201
|
-
return this.
|
|
202
|
-
},
|
|
203
|
-
step(stepper = 0) {
|
|
204
|
-
if (!stepper) return;
|
|
205
|
-
this.__scrollPos = undefined; // сбрасываем кэш, что вызовет пересчет beforeTab/afterTab
|
|
206
|
-
const target = stepper < 0 ? this.beforeTab : this.afterTab;
|
|
207
|
-
target?.scrollIntoView({
|
|
208
|
-
inline: 'nearest',
|
|
209
|
-
block: 'nearest'
|
|
210
|
-
});
|
|
211
|
-
if (Math.abs(stepper) > 1) {
|
|
212
|
-
this.step(stepper + (stepper < 0 ? 1 : -1));
|
|
213
|
-
}
|
|
439
|
+
get __scrollerWidth() {
|
|
440
|
+
return this.__is_vertical ? this.__scroller?.offsetHeight : this.__scroller?.offsetWidth;
|
|
214
441
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
get(){
|
|
218
|
-
if (!this.__is_vertical)
|
|
219
|
-
return `height: fit-content`;
|
|
220
|
-
return `width: fit-content`;
|
|
221
|
-
}
|
|
442
|
+
get __buttonSize() {
|
|
443
|
+
return Math.round((this.iconSize || 16) * 0.85);
|
|
222
444
|
},
|
|
223
445
|
$public: {
|
|
446
|
+
variant: {
|
|
447
|
+
$def: 'bar',
|
|
448
|
+
$list: ['bar', 'rail', 'pills'],
|
|
449
|
+
$attr: true,
|
|
450
|
+
},
|
|
451
|
+
compact: {
|
|
452
|
+
$def: false,
|
|
453
|
+
$type: Boolean,
|
|
454
|
+
$attr: true,
|
|
455
|
+
},
|
|
456
|
+
noShrink: {
|
|
457
|
+
$def: false,
|
|
458
|
+
$type: Boolean,
|
|
459
|
+
$attr: true,
|
|
460
|
+
},
|
|
224
461
|
allowDrag: false,
|
|
462
|
+
allowClose: false,
|
|
463
|
+
allowList: true,
|
|
464
|
+
allowContextMenu: true,
|
|
465
|
+
closeAllLabel: 'Закрыть все',
|
|
225
466
|
align: {
|
|
226
467
|
$list: ['left', 'bottom', 'right', 'top'],
|
|
227
|
-
$def: '
|
|
228
|
-
set(
|
|
468
|
+
$def: 'top',
|
|
469
|
+
set() {
|
|
229
470
|
if (!this.__scroller) return;
|
|
230
471
|
requestAnimationFrame(() => {
|
|
231
|
-
for (const el of this.__scroller.children
|
|
232
|
-
el.render(true);
|
|
472
|
+
for (const el of this.__scroller.children) {
|
|
473
|
+
el.render?.(true);
|
|
233
474
|
}
|
|
234
475
|
});
|
|
235
476
|
}
|
|
236
477
|
},
|
|
237
|
-
focusedIndex: {
|
|
478
|
+
focusedIndex: {
|
|
238
479
|
$def: 0,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
this.selectedIndex = -1; // сбрасываем селектор при установке фокуса
|
|
480
|
+
set() {
|
|
481
|
+
this.selectedIndex = -1;
|
|
242
482
|
this.debounce('focusedIndex', () => {
|
|
243
483
|
this.focusedTab?.scrollIntoView({ inline: 'nearest', block: 'nearest' });
|
|
244
484
|
});
|
|
245
485
|
}
|
|
246
486
|
},
|
|
247
|
-
iconSize:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
dimmed: {
|
|
251
|
-
$def: false,
|
|
252
|
-
$save: true,
|
|
253
|
-
},
|
|
487
|
+
iconSize: 16,
|
|
488
|
+
maxWidth: 230,
|
|
489
|
+
dimmed: false,
|
|
254
490
|
defaultIcon: ''
|
|
255
491
|
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return this.items?.[this.focusedIndex]; // переименовано с index
|
|
259
|
-
},
|
|
260
|
-
get beforeTab(){
|
|
261
|
-
let item = this.__scroller?.firstChild?.firstChild;
|
|
262
|
-
let pos = this.__scrollPos - 1;
|
|
263
|
-
do{
|
|
264
|
-
let start = item[this.offsetStart]
|
|
265
|
-
if (start < pos && start + item[this.offsetSize] >= pos)
|
|
266
|
-
return item;
|
|
267
|
-
}
|
|
268
|
-
while(item = item.nextElementSibling)
|
|
269
|
-
},
|
|
270
|
-
get afterTab(){
|
|
271
|
-
let item = this.__scroller?.firstChild?.firstChild;
|
|
272
|
-
let pos = this.__scrollPos + this.__scrollerWidth + 1;
|
|
273
|
-
do{
|
|
274
|
-
let start = item[this.offsetStart]
|
|
275
|
-
if (start <= pos && start + item[this.offsetSize] > pos)
|
|
276
|
-
return item;
|
|
277
|
-
}
|
|
278
|
-
while(item = item.nextElementSibling)
|
|
279
|
-
},
|
|
280
|
-
get focusedTab(){
|
|
281
|
-
return this.__scroller?.firstChild?.children[this.focusedIndex] || null; // переименовано с index
|
|
282
|
-
},
|
|
283
|
-
get alignSelf() {
|
|
284
|
-
switch (this.align) {
|
|
285
|
-
case 'left':
|
|
286
|
-
case 'top':
|
|
287
|
-
return 'self-start';
|
|
288
|
-
case 'right':
|
|
289
|
-
case 'bottom':
|
|
290
|
-
return 'self-end';
|
|
291
|
-
}
|
|
492
|
+
get focused() {
|
|
493
|
+
return this.items?.[this.focusedIndex];
|
|
292
494
|
},
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
get() {
|
|
296
|
-
switch (this.align) {
|
|
297
|
-
case 'left':
|
|
298
|
-
return 270;
|
|
299
|
-
case 'right':
|
|
300
|
-
return 90;
|
|
301
|
-
case 'top':
|
|
302
|
-
return 0;
|
|
303
|
-
case 'bottom':
|
|
304
|
-
return 180;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
495
|
+
get focusedTab() {
|
|
496
|
+
return this.__scroller?.children?.[this.focusedIndex] || null;
|
|
307
497
|
},
|
|
308
|
-
get __is_vertical(){
|
|
309
|
-
|
|
310
|
-
case 'left':
|
|
311
|
-
case 'right':
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
return false;
|
|
498
|
+
get __is_vertical() {
|
|
499
|
+
return this.align === 'left' || this.align === 'right';
|
|
315
500
|
},
|
|
316
501
|
direction: {
|
|
317
502
|
$type: String,
|
|
318
503
|
$attr: true,
|
|
319
504
|
get() {
|
|
320
|
-
return this.__is_vertical?'vertical':'horizontal';
|
|
321
|
-
}
|
|
322
|
-
},
|
|
323
|
-
get iconRotate(){
|
|
324
|
-
return this.__is_vertical?90:0;
|
|
325
|
-
},
|
|
326
|
-
async closeAll() {
|
|
327
|
-
await ODA.showConfirm('Close all tabs?');
|
|
328
|
-
this.items.forEach(i => i.close?.());
|
|
329
|
-
},
|
|
330
|
-
get __shapeStyle(){
|
|
331
|
-
switch (this.align){
|
|
332
|
-
case 'top':
|
|
333
|
-
return `max-width: ${this.maxWidth}px;`
|
|
334
|
-
case 'right':
|
|
335
|
-
return `max-height: ${this.maxWidth}px;`
|
|
336
|
-
case 'bottom':
|
|
337
|
-
return `max-width: ${this.maxWidth}px;`
|
|
338
|
-
case 'left':
|
|
339
|
-
return `max-height: ${this.maxWidth}px;`
|
|
505
|
+
return this.__is_vertical ? 'vertical' : 'horizontal';
|
|
340
506
|
}
|
|
341
507
|
},
|
|
342
|
-
get
|
|
343
|
-
return this.__is_vertical?
|
|
508
|
+
get offsetSize() {
|
|
509
|
+
return this.__is_vertical ? 'offsetHeight' : 'offsetWidth';
|
|
344
510
|
},
|
|
345
|
-
get
|
|
346
|
-
return this.__is_vertical?'
|
|
347
|
-
},
|
|
348
|
-
get offsetStart(){
|
|
349
|
-
return this.__is_vertical?'offsetTop':'offsetLeft';
|
|
511
|
+
get offsetStart() {
|
|
512
|
+
return this.__is_vertical ? 'offsetTop' : 'offsetLeft';
|
|
350
513
|
},
|
|
351
514
|
selectedIndex: -1,
|
|
352
515
|
_onKeydown(e) {
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
516
|
+
const len = this.items?.length || 0;
|
|
517
|
+
if (!len)
|
|
518
|
+
return;
|
|
519
|
+
const currentIndex = this.selectedIndex === -1 ? Math.max(0, this.focusedIndex) : this.selectedIndex;
|
|
520
|
+
switch (e.key) {
|
|
356
521
|
case 'Escape':
|
|
357
522
|
this.selectedIndex = -1;
|
|
358
|
-
|
|
359
|
-
this.focusedTab?.scrollIntoView({
|
|
360
|
-
inline: 'center',
|
|
361
|
-
block: 'center'
|
|
362
|
-
});
|
|
363
|
-
});
|
|
523
|
+
this.focusedTab?.scrollIntoView({ inline: 'nearest', block: 'nearest' });
|
|
364
524
|
break;
|
|
365
|
-
|
|
366
|
-
case '':
|
|
525
|
+
case ' ':
|
|
367
526
|
case 'Enter':
|
|
368
527
|
e.preventDefault();
|
|
369
|
-
|
|
370
|
-
this.dimmed = !this.dimmed;
|
|
371
|
-
else
|
|
372
|
-
this.dimmed = false;
|
|
373
|
-
this.focusedIndex = currentIndex;
|
|
374
|
-
// сбрасываем dimmed при установке фокуса
|
|
528
|
+
this.selectTab(currentIndex, e);
|
|
375
529
|
break;
|
|
376
|
-
|
|
377
530
|
case 'ArrowLeft':
|
|
378
531
|
case 'ArrowUp':
|
|
379
532
|
e.preventDefault();
|
|
380
533
|
if (currentIndex > 0) {
|
|
381
|
-
const nextTab = this.__scroller?.firstChild?.children[currentIndex - 1];
|
|
382
|
-
const pos = nextTab[this.offsetStart];
|
|
383
|
-
if (pos <= this.__scrollPos) {
|
|
384
|
-
this.step(-1);
|
|
385
|
-
}
|
|
386
534
|
this.selectedIndex = currentIndex - 1;
|
|
535
|
+
this.__scroller?.children?.[this.selectedIndex]?.scrollIntoView({ inline: 'nearest', block: 'nearest' });
|
|
387
536
|
}
|
|
388
537
|
break;
|
|
389
|
-
|
|
390
538
|
case 'ArrowRight':
|
|
391
539
|
case 'ArrowDown':
|
|
392
540
|
e.preventDefault();
|
|
393
|
-
if (currentIndex <
|
|
394
|
-
const nextTab = this.__scroller?.firstChild?.children[currentIndex + 1];
|
|
395
|
-
const pos = nextTab[this.offsetStart] + nextTab[this.offsetSize];
|
|
396
|
-
if (pos >= this.__scrollPos + this.__scrollerWidth) {
|
|
397
|
-
this.step(1);
|
|
398
|
-
}
|
|
541
|
+
if (currentIndex < len - 1) {
|
|
399
542
|
this.selectedIndex = currentIndex + 1;
|
|
543
|
+
this.__scroller?.children?.[this.selectedIndex]?.scrollIntoView({ inline: 'nearest', block: 'nearest' });
|
|
400
544
|
}
|
|
401
545
|
break;
|
|
402
546
|
case 'Home':
|
|
403
547
|
e.preventDefault();
|
|
404
|
-
this.
|
|
548
|
+
this.selectTab(0, e);
|
|
405
549
|
break;
|
|
406
550
|
case 'End':
|
|
407
551
|
e.preventDefault();
|
|
408
|
-
this.
|
|
552
|
+
this.selectTab(len - 1, e);
|
|
409
553
|
break;
|
|
410
554
|
}
|
|
411
|
-
},
|
|
412
|
-
_onDragStart(e) {
|
|
413
|
-
const tab = e.target.closest('oda-tabs-tab');
|
|
414
|
-
if (!tab) return;
|
|
415
|
-
e.dataTransfer.setData('text/plain', '');
|
|
416
|
-
e.dataTransfer.setDragImage(document.createElement('img'), 0, 0);
|
|
417
|
-
this.dragTab = tab;
|
|
418
|
-
this.dragTab.$pdp.state = 'info';
|
|
419
|
-
},
|
|
420
|
-
_onDragEnd(e) {
|
|
421
|
-
if (this.dragTab) {
|
|
422
|
-
this.dragTab.$pdp.state = '';
|
|
423
|
-
this.dragTab = null;
|
|
424
|
-
}
|
|
425
555
|
}
|
|
426
|
-
})
|
|
427
|
-
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
const drag = {
|
|
559
|
+
item: null,
|
|
560
|
+
host: null,
|
|
561
|
+
fromIndex: -1,
|
|
562
|
+
toIndex: -1,
|
|
563
|
+
pointer: 0,
|
|
564
|
+
start: 0,
|
|
565
|
+
};
|
|
566
|
+
|
|
428
567
|
ODA({
|
|
429
568
|
is: 'oda-tabs-tab',
|
|
430
569
|
template: /*html*/`
|
|
431
570
|
<style>
|
|
432
|
-
:host{
|
|
433
|
-
|
|
434
|
-
|
|
571
|
+
:host {
|
|
572
|
+
display: flex;
|
|
573
|
+
flex: 0 1 auto;
|
|
574
|
+
min-width: 34px;
|
|
575
|
+
max-width: 230px;
|
|
576
|
+
height: 30px;
|
|
577
|
+
border-radius: 9px;
|
|
435
578
|
position: relative;
|
|
436
579
|
overflow: hidden;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
580
|
+
cursor: pointer;
|
|
581
|
+
user-select: none;
|
|
582
|
+
box-sizing: border-box;
|
|
583
|
+
transition: background-color var(--duration-fast) var(--easing),
|
|
584
|
+
box-shadow var(--duration-fast) var(--easing),
|
|
585
|
+
color var(--duration-fast) var(--easing),
|
|
586
|
+
opacity var(--duration-fast) var(--easing),
|
|
587
|
+
transform var(--duration-fast) var(--easing);
|
|
588
|
+
}
|
|
589
|
+
:host([no-icon]) {
|
|
590
|
+
min-width: 56px;
|
|
591
|
+
}
|
|
592
|
+
:host([aria-selected="true"]) {
|
|
593
|
+
flex: 0 0 auto;
|
|
594
|
+
min-width: 88px;
|
|
595
|
+
max-width: 270px;
|
|
596
|
+
z-index: 1;
|
|
597
|
+
}
|
|
598
|
+
:host([no-shrink]) {
|
|
599
|
+
flex: 0 0 auto;
|
|
600
|
+
min-width: max-content;
|
|
601
|
+
max-width: none;
|
|
602
|
+
}
|
|
603
|
+
:host([compact]) {
|
|
604
|
+
height: 26px;
|
|
605
|
+
border-radius: 7px;
|
|
606
|
+
}
|
|
607
|
+
:host([variant="pills"]) {
|
|
608
|
+
flex: 0 0 auto;
|
|
609
|
+
min-width: max-content;
|
|
610
|
+
max-width: none;
|
|
611
|
+
height: 28px;
|
|
612
|
+
border-radius: 7px;
|
|
613
|
+
}
|
|
614
|
+
:host([variant="bar"]) {
|
|
615
|
+
color: var(--content-color);
|
|
616
|
+
fill: var(--content-color);
|
|
617
|
+
opacity: 0.82;
|
|
618
|
+
}
|
|
619
|
+
:host([variant="bar"]:hover) {
|
|
620
|
+
opacity: 1;
|
|
621
|
+
background: color-mix(in oklch, var(--content-color) 6%, transparent);
|
|
622
|
+
}
|
|
623
|
+
:host([variant="bar"][aria-selected="true"]) {
|
|
624
|
+
opacity: 1;
|
|
625
|
+
background: var(--content-background);
|
|
626
|
+
color: var(--accent-color);
|
|
627
|
+
fill: var(--accent-color);
|
|
628
|
+
box-shadow: var(--elevation-2);
|
|
629
|
+
font-weight: 600;
|
|
630
|
+
}
|
|
631
|
+
:host([variant="rail"]) {
|
|
632
|
+
color: var(--accent-back);
|
|
633
|
+
fill: var(--accent-back);
|
|
634
|
+
opacity: 0.88;
|
|
635
|
+
}
|
|
636
|
+
:host([variant="rail"]:hover) {
|
|
637
|
+
opacity: 1;
|
|
638
|
+
background: color-mix(in oklch, var(--accent-back) 14%, transparent);
|
|
639
|
+
}
|
|
640
|
+
:host([variant="rail"][aria-selected="true"]) {
|
|
641
|
+
opacity: 1;
|
|
642
|
+
background: var(--light-background);
|
|
643
|
+
color: var(--light-color);
|
|
644
|
+
fill: var(--light-color);
|
|
645
|
+
box-shadow: 0 2px 6px var(--shadow-color);
|
|
646
|
+
font-weight: 700;
|
|
440
647
|
}
|
|
441
|
-
|
|
648
|
+
:host([variant="pills"]) {
|
|
649
|
+
color: var(--content-color);
|
|
650
|
+
fill: var(--content-color);
|
|
651
|
+
opacity: 0.78;
|
|
652
|
+
}
|
|
653
|
+
:host([variant="pills"]:hover) {
|
|
654
|
+
opacity: 1;
|
|
655
|
+
background: color-mix(in oklch, var(--content-color) 6%, transparent);
|
|
656
|
+
}
|
|
657
|
+
:host([variant="pills"][aria-selected="true"]) {
|
|
658
|
+
opacity: 1;
|
|
659
|
+
background: var(--content-background);
|
|
660
|
+
color: var(--accent-color);
|
|
661
|
+
fill: var(--accent-color);
|
|
662
|
+
box-shadow: var(--elevation-1);
|
|
663
|
+
font-weight: 600;
|
|
664
|
+
}
|
|
665
|
+
:host([selected]) {
|
|
666
|
+
outline: 2px solid var(--focus-ring-color);
|
|
667
|
+
outline-offset: -2px;
|
|
668
|
+
}
|
|
669
|
+
:host([disabled]) {
|
|
670
|
+
opacity: 0.45;
|
|
671
|
+
pointer-events: none;
|
|
672
|
+
}
|
|
673
|
+
.panel {
|
|
674
|
+
display: flex;
|
|
442
675
|
align-items: center;
|
|
443
|
-
|
|
676
|
+
width: 100%;
|
|
677
|
+
min-width: 0;
|
|
678
|
+
height: 100%;
|
|
679
|
+
padding: 0 9px;
|
|
680
|
+
box-sizing: border-box;
|
|
681
|
+
overflow: hidden;
|
|
682
|
+
}
|
|
683
|
+
:host([variant="pills"]) .panel {
|
|
684
|
+
padding: 0 11px;
|
|
685
|
+
}
|
|
686
|
+
.tab-icon {
|
|
687
|
+
flex-shrink: 0;
|
|
688
|
+
}
|
|
689
|
+
.tab-label {
|
|
690
|
+
flex: 1 1 0;
|
|
691
|
+
min-width: 0;
|
|
692
|
+
overflow: hidden;
|
|
693
|
+
text-overflow: ellipsis;
|
|
444
694
|
white-space: nowrap;
|
|
695
|
+
font-size: 13px;
|
|
696
|
+
line-height: 1.25;
|
|
697
|
+
margin-left: 6px;
|
|
698
|
+
}
|
|
699
|
+
:host([no-icon]) .tab-label {
|
|
700
|
+
margin-left: 0;
|
|
701
|
+
}
|
|
702
|
+
:host([variant="pills"]) .tab-label,
|
|
703
|
+
:host([compact]) .tab-label {
|
|
704
|
+
font-size: 12.5px;
|
|
705
|
+
}
|
|
706
|
+
.tab-badge {
|
|
707
|
+
flex-shrink: 0;
|
|
708
|
+
margin-left: 6px;
|
|
709
|
+
font-size: 11px;
|
|
710
|
+
font-weight: 600;
|
|
711
|
+
line-height: 16px;
|
|
712
|
+
min-width: 18px;
|
|
713
|
+
height: 16px;
|
|
714
|
+
padding: 0 5px;
|
|
715
|
+
border-radius: 999px;
|
|
716
|
+
text-align: center;
|
|
717
|
+
box-sizing: border-box;
|
|
718
|
+
background: color-mix(in oklch, currentColor 12%, transparent);
|
|
719
|
+
color: inherit;
|
|
720
|
+
}
|
|
721
|
+
:host([aria-selected="true"]) .tab-badge {
|
|
722
|
+
background: var(--accent-soft);
|
|
723
|
+
color: var(--accent-color);
|
|
724
|
+
}
|
|
725
|
+
:host([variant="rail"][aria-selected="true"]) .tab-badge {
|
|
726
|
+
background: color-mix(in oklch, var(--light-color) 14%, transparent);
|
|
727
|
+
color: var(--light-color);
|
|
728
|
+
}
|
|
729
|
+
.tab-tail {
|
|
730
|
+
display: inline-flex;
|
|
731
|
+
align-items: center;
|
|
732
|
+
justify-content: center;
|
|
733
|
+
flex-shrink: 0;
|
|
734
|
+
width: 0;
|
|
735
|
+
margin-left: 0;
|
|
736
|
+
opacity: 0;
|
|
445
737
|
overflow: hidden;
|
|
738
|
+
transition: width var(--duration-fast) var(--easing),
|
|
739
|
+
opacity var(--duration-fast) var(--easing),
|
|
740
|
+
margin-left var(--duration-fast) var(--easing);
|
|
741
|
+
}
|
|
742
|
+
:host([aria-selected="true"]) .tab-tail.has-tail,
|
|
743
|
+
:host(:hover) .tab-tail.has-tail,
|
|
744
|
+
.tab-tail.is-dirty {
|
|
745
|
+
width: 18px;
|
|
746
|
+
margin-left: 4px;
|
|
747
|
+
opacity: 1;
|
|
446
748
|
}
|
|
447
|
-
|
|
448
|
-
|
|
749
|
+
.dirty-dot {
|
|
750
|
+
width: 7px;
|
|
751
|
+
height: 7px;
|
|
752
|
+
border-radius: 50%;
|
|
753
|
+
background: var(--accent-color);
|
|
754
|
+
display: block;
|
|
449
755
|
}
|
|
450
|
-
:host(:
|
|
451
|
-
|
|
756
|
+
:host([variant="rail"]:not([aria-selected="true"])) .dirty-dot {
|
|
757
|
+
background: var(--accent-back);
|
|
452
758
|
}
|
|
453
|
-
.close{
|
|
454
|
-
|
|
759
|
+
:host(:hover) .tab-tail.can-close .dirty-dot {
|
|
760
|
+
display: none;
|
|
761
|
+
}
|
|
762
|
+
.close-btn {
|
|
763
|
+
display: none;
|
|
764
|
+
align-items: center;
|
|
765
|
+
justify-content: center;
|
|
766
|
+
width: 18px;
|
|
767
|
+
height: 18px;
|
|
455
768
|
border-radius: 50%;
|
|
456
769
|
cursor: pointer;
|
|
457
|
-
|
|
770
|
+
opacity: 0.72;
|
|
771
|
+
transition: background-color var(--duration-fast) var(--easing), opacity var(--duration-fast) var(--easing);
|
|
458
772
|
}
|
|
459
|
-
.close:
|
|
460
|
-
|
|
773
|
+
:host([aria-selected="true"]) .tab-tail.can-close:not(.is-dirty) .close-btn,
|
|
774
|
+
:host(:hover) .tab-tail.can-close .close-btn {
|
|
775
|
+
display: inline-flex;
|
|
461
776
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
oda-icon{
|
|
467
|
-
transition: scale .5s;
|
|
468
|
-
scale: .75;
|
|
469
|
-
margin: auto;
|
|
470
|
-
padding: 2px;
|
|
777
|
+
.close-btn:hover {
|
|
778
|
+
opacity: 1;
|
|
779
|
+
background: color-mix(in oklch, currentColor 14%, transparent);
|
|
471
780
|
}
|
|
472
781
|
</style>
|
|
473
|
-
<div class="panel"
|
|
474
|
-
<oda-icon
|
|
475
|
-
<
|
|
476
|
-
<
|
|
477
|
-
|
|
478
|
-
|
|
782
|
+
<div class="panel" :title="tooltip" @tap="focus($event)">
|
|
783
|
+
<oda-icon class="tab-icon" ~if="hasIcon" :icon="resolvedIcon" :icon-size="resolvedIconSize"></oda-icon>
|
|
784
|
+
<span class="tab-label" ~if="label">{{label}}</span>
|
|
785
|
+
<span class="tab-badge" ~if="showBadge">{{badgeText}}</span>
|
|
786
|
+
<span class="tab-tail" ~class="{ 'has-tail': canClose || isDirty, 'can-close': canClose, 'is-dirty': isDirty }" ~if="canClose || isDirty">
|
|
787
|
+
<span class="dirty-dot" ~if="isDirty" title="Есть несохранённые изменения"></span>
|
|
788
|
+
<span class="close-btn" ~if="canClose" title="Закрыть" @tap.stop="close($event)" @pointerdown.stop>
|
|
789
|
+
<oda-icon icon="icons:close" :icon-size="13"></oda-icon>
|
|
790
|
+
</span>
|
|
791
|
+
</span>
|
|
479
792
|
</div>
|
|
480
793
|
`,
|
|
481
|
-
|
|
482
|
-
|
|
794
|
+
variant: {
|
|
795
|
+
$attr: true,
|
|
796
|
+
get() {
|
|
797
|
+
return this.host?.variant || 'bar';
|
|
798
|
+
}
|
|
483
799
|
},
|
|
484
|
-
|
|
485
|
-
|
|
800
|
+
compact: {
|
|
801
|
+
$attr: true,
|
|
802
|
+
$type: Boolean,
|
|
803
|
+
get() {
|
|
804
|
+
return Boolean(this.host?.compact);
|
|
805
|
+
}
|
|
486
806
|
},
|
|
487
|
-
|
|
488
|
-
|
|
807
|
+
noShrink: {
|
|
808
|
+
$attr: true,
|
|
809
|
+
$type: Boolean,
|
|
810
|
+
get() {
|
|
811
|
+
return Boolean(this.host?.noShrink);
|
|
812
|
+
}
|
|
813
|
+
},
|
|
814
|
+
noIcon: {
|
|
815
|
+
$attr: true,
|
|
816
|
+
$type: Boolean,
|
|
817
|
+
get() {
|
|
818
|
+
return !this.hasIcon;
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
get hasIcon() {
|
|
822
|
+
return Boolean(this.resolvedIcon);
|
|
823
|
+
},
|
|
824
|
+
get resolvedIcon() {
|
|
825
|
+
return this.item?.icon || this.host?.defaultIcon || '';
|
|
826
|
+
},
|
|
827
|
+
get resolvedIconSize() {
|
|
828
|
+
return this.host?.compact ? 14 : (this.host?.iconSize || 16);
|
|
829
|
+
},
|
|
830
|
+
get canClose() {
|
|
831
|
+
return Boolean(this.host?.isTabClosable?.(this.item));
|
|
832
|
+
},
|
|
833
|
+
get isDirty() {
|
|
834
|
+
return Boolean(this.item?.dirty);
|
|
489
835
|
},
|
|
490
836
|
get label() {
|
|
491
837
|
return this.item?.label || '';
|
|
492
838
|
},
|
|
493
|
-
get
|
|
494
|
-
return this.
|
|
839
|
+
get tooltip() {
|
|
840
|
+
return this.item?.title || this.label || '';
|
|
841
|
+
},
|
|
842
|
+
get showBadge() {
|
|
843
|
+
const c = this.item?.count;
|
|
844
|
+
return c !== undefined && c !== null && c !== '' && c !== 0 && c !== '0' || Boolean(this.item?.showZeroCount && c === 0);
|
|
495
845
|
},
|
|
496
|
-
get
|
|
497
|
-
return this.
|
|
846
|
+
get badgeText() {
|
|
847
|
+
return String(this.item?.count ?? '');
|
|
848
|
+
},
|
|
849
|
+
get disabled() {
|
|
850
|
+
return Boolean(this.item?.disabled);
|
|
498
851
|
},
|
|
499
852
|
$listeners: {
|
|
853
|
+
mousedown(e) {
|
|
854
|
+
if (e.button === 1 && this.canClose)
|
|
855
|
+
e.preventDefault();
|
|
856
|
+
},
|
|
857
|
+
auxclick(e) {
|
|
858
|
+
if (e.button === 1 && this.canClose) {
|
|
859
|
+
e.preventDefault();
|
|
860
|
+
e.stopPropagation();
|
|
861
|
+
this.close(e);
|
|
862
|
+
}
|
|
863
|
+
},
|
|
864
|
+
contextmenu(e) {
|
|
865
|
+
this.host?._openTabContextMenu?.(this.index, e);
|
|
866
|
+
},
|
|
500
867
|
dragstart(e) {
|
|
868
|
+
if (!this.host?.allowDrag) {
|
|
869
|
+
e.preventDefault();
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
e.dataTransfer.setData('text/plain', String(this.index));
|
|
501
873
|
e.dataTransfer.setDragImage(document.createElement('img'), 0, 0);
|
|
502
|
-
e.dataTransfer.effectAllowed =
|
|
874
|
+
e.dataTransfer.effectAllowed = 'move';
|
|
503
875
|
drag.item = this;
|
|
504
|
-
drag.
|
|
505
|
-
drag.
|
|
506
|
-
drag.
|
|
876
|
+
drag.host = this.host;
|
|
877
|
+
drag.fromIndex = this.index;
|
|
878
|
+
drag.toIndex = this.index;
|
|
507
879
|
drag.pointer = this.host.__is_vertical ? e.offsetY : e.offsetX;
|
|
508
880
|
drag.start = this.host.__is_vertical ? e.clientY : e.clientX;
|
|
881
|
+
this.style.transition = 'none';
|
|
882
|
+
this.style.zIndex = 2;
|
|
883
|
+
this.style.opacity = '0.85';
|
|
509
884
|
},
|
|
510
|
-
dragend(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
el.style.transform = '';
|
|
885
|
+
dragend() {
|
|
886
|
+
const scroller = this.host?.__scroller;
|
|
887
|
+
if (scroller) {
|
|
888
|
+
for (const el of scroller.children) {
|
|
889
|
+
el.style.transform = '';
|
|
890
|
+
}
|
|
517
891
|
}
|
|
892
|
+
this.style.transform = '';
|
|
893
|
+
this.style.transition = '';
|
|
894
|
+
this.style.zIndex = '';
|
|
895
|
+
this.style.opacity = '';
|
|
896
|
+
drag.item = null;
|
|
897
|
+
drag.host = null;
|
|
898
|
+
drag.fromIndex = -1;
|
|
899
|
+
drag.toIndex = -1;
|
|
518
900
|
},
|
|
519
901
|
drop(e) {
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
902
|
+
e.preventDefault();
|
|
903
|
+
if (!drag.item || drag.host !== this.host)
|
|
904
|
+
return;
|
|
905
|
+
const fromIndex = drag.fromIndex;
|
|
906
|
+
const toIndex = drag.toIndex >= 0 ? drag.toIndex : this.index;
|
|
907
|
+
const scroller = this.host?.__scroller;
|
|
908
|
+
if (scroller) {
|
|
909
|
+
for (const el of scroller.children) {
|
|
910
|
+
el.style.transform = '';
|
|
911
|
+
}
|
|
527
912
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
913
|
+
if (fromIndex < 0 || toIndex < 0 || fromIndex === toIndex)
|
|
914
|
+
return;
|
|
915
|
+
const next = [...(this.host.items || [])];
|
|
916
|
+
const focusedItem = next[this.host.focusedIndex];
|
|
917
|
+
const [moved] = next.splice(fromIndex, 1);
|
|
918
|
+
next.splice(toIndex, 0, moved);
|
|
919
|
+
this.host.items = next;
|
|
920
|
+
if (focusedItem) {
|
|
921
|
+
const newFocused = next.indexOf(focusedItem);
|
|
922
|
+
if (newFocused >= 0)
|
|
923
|
+
this.host.focusedIndex = newFocused;
|
|
532
924
|
}
|
|
533
|
-
this.host.
|
|
925
|
+
this.host.dispatchEvent(new CustomEvent('reorder', {
|
|
926
|
+
detail: { items: next, fromIndex, toIndex },
|
|
927
|
+
bubbles: true,
|
|
928
|
+
composed: true,
|
|
929
|
+
}));
|
|
534
930
|
}
|
|
535
931
|
},
|
|
536
932
|
index: -1,
|
|
933
|
+
item: null,
|
|
537
934
|
focus(e) {
|
|
538
|
-
this.host
|
|
539
|
-
this.host.focusedIndex = this.index;
|
|
935
|
+
this.host?.selectTab?.(this.index, e);
|
|
540
936
|
},
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
545
|
-
},
|
|
546
|
-
item: null,
|
|
547
|
-
close(e){
|
|
548
|
-
this.$pdp.tabs.fire('close', this.item);
|
|
937
|
+
close(e) {
|
|
938
|
+
e?.stopPropagation?.();
|
|
939
|
+
this.host?.requestCloseTab?.(this.index, e);
|
|
549
940
|
}
|
|
550
|
-
})
|
|
551
|
-
|
|
552
|
-
|
|
941
|
+
});
|