@umbraco-ui/uui-tabs 1.4.0 → 1.5.0-rc.1
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 +1 -1
- package/custom-elements.json +59 -10
- package/lib/index.js +285 -41
- package/lib/uui-tab-group.element.d.ts +14 -6
- package/lib/uui-tab.element.d.ts +9 -1
- package/package.json +6 -3
package/README.md
CHANGED
package/custom-elements.json
CHANGED
|
@@ -4,7 +4,22 @@
|
|
|
4
4
|
{
|
|
5
5
|
"name": "uui-tab-group",
|
|
6
6
|
"path": "./lib/uui-tab-group.element.ts",
|
|
7
|
+
"attributes": [
|
|
8
|
+
{
|
|
9
|
+
"name": "dropdown-content-direction",
|
|
10
|
+
"description": "Set the flex direction of the content of the dropdown.",
|
|
11
|
+
"type": "string",
|
|
12
|
+
"default": "\"vertical\""
|
|
13
|
+
}
|
|
14
|
+
],
|
|
7
15
|
"properties": [
|
|
16
|
+
{
|
|
17
|
+
"name": "dropdownContentDirection",
|
|
18
|
+
"attribute": "dropdown-content-direction",
|
|
19
|
+
"description": "Set the flex direction of the content of the dropdown.",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"default": "\"vertical\""
|
|
22
|
+
},
|
|
8
23
|
{
|
|
9
24
|
"name": "styles",
|
|
10
25
|
"type": "CSSResult[]",
|
|
@@ -41,6 +56,12 @@
|
|
|
41
56
|
"type": "string",
|
|
42
57
|
"default": "\"undefined\""
|
|
43
58
|
},
|
|
59
|
+
{
|
|
60
|
+
"name": "orientation",
|
|
61
|
+
"description": "Set the visual orientation of this tab, this changes the look and placement of the active indication.",
|
|
62
|
+
"type": "string",
|
|
63
|
+
"default": "\"horizontal\""
|
|
64
|
+
},
|
|
44
65
|
{
|
|
45
66
|
"name": "active",
|
|
46
67
|
"description": "Set this boolean to true for then the related composition is sorted.",
|
|
@@ -54,11 +75,6 @@
|
|
|
54
75
|
}
|
|
55
76
|
],
|
|
56
77
|
"properties": [
|
|
57
|
-
{
|
|
58
|
-
"name": "styles",
|
|
59
|
-
"type": "CSSResult[]",
|
|
60
|
-
"default": "[null]"
|
|
61
|
-
},
|
|
62
78
|
{
|
|
63
79
|
"name": "disabled",
|
|
64
80
|
"attribute": "disabled",
|
|
@@ -80,6 +96,18 @@
|
|
|
80
96
|
"type": "string",
|
|
81
97
|
"default": "\"undefined\""
|
|
82
98
|
},
|
|
99
|
+
{
|
|
100
|
+
"name": "orientation",
|
|
101
|
+
"attribute": "orientation",
|
|
102
|
+
"description": "Set the visual orientation of this tab, this changes the look and placement of the active indication.",
|
|
103
|
+
"type": "string",
|
|
104
|
+
"default": "\"horizontal\""
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "styles",
|
|
108
|
+
"type": "CSSResult[]",
|
|
109
|
+
"default": "[null]"
|
|
110
|
+
},
|
|
83
111
|
{
|
|
84
112
|
"name": "active",
|
|
85
113
|
"attribute": "active",
|
|
@@ -128,6 +156,10 @@
|
|
|
128
156
|
{
|
|
129
157
|
"name": "--uui-tab-divider",
|
|
130
158
|
"description": "Define the tab dividers color"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "--uui-tab-padding-horizontal",
|
|
162
|
+
"description": "Define the tab horizontal padding"
|
|
131
163
|
}
|
|
132
164
|
]
|
|
133
165
|
},
|
|
@@ -154,6 +186,12 @@
|
|
|
154
186
|
"type": "string",
|
|
155
187
|
"default": "\"undefined\""
|
|
156
188
|
},
|
|
189
|
+
{
|
|
190
|
+
"name": "orientation",
|
|
191
|
+
"description": "Set the visual orientation of this tab, this changes the look and placement of the active indication.",
|
|
192
|
+
"type": "string",
|
|
193
|
+
"default": "\"horizontal\""
|
|
194
|
+
},
|
|
157
195
|
{
|
|
158
196
|
"name": "active",
|
|
159
197
|
"description": "Set this boolean to true for then the related composition is sorted.",
|
|
@@ -167,11 +205,6 @@
|
|
|
167
205
|
}
|
|
168
206
|
],
|
|
169
207
|
"properties": [
|
|
170
|
-
{
|
|
171
|
-
"name": "styles",
|
|
172
|
-
"type": "CSSResult[]",
|
|
173
|
-
"default": "[null]"
|
|
174
|
-
},
|
|
175
208
|
{
|
|
176
209
|
"name": "disabled",
|
|
177
210
|
"attribute": "disabled",
|
|
@@ -193,6 +226,18 @@
|
|
|
193
226
|
"type": "string",
|
|
194
227
|
"default": "\"undefined\""
|
|
195
228
|
},
|
|
229
|
+
{
|
|
230
|
+
"name": "orientation",
|
|
231
|
+
"attribute": "orientation",
|
|
232
|
+
"description": "Set the visual orientation of this tab, this changes the look and placement of the active indication.",
|
|
233
|
+
"type": "string",
|
|
234
|
+
"default": "\"horizontal\""
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"name": "styles",
|
|
238
|
+
"type": "CSSResult[]",
|
|
239
|
+
"default": "[null]"
|
|
240
|
+
},
|
|
196
241
|
{
|
|
197
242
|
"name": "active",
|
|
198
243
|
"attribute": "active",
|
|
@@ -241,6 +286,10 @@
|
|
|
241
286
|
{
|
|
242
287
|
"name": "--uui-tab-divider",
|
|
243
288
|
"description": "Define the tab dividers color"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"name": "--uui-tab-padding-horizontal",
|
|
292
|
+
"description": "Define the tab horizontal padding"
|
|
244
293
|
}
|
|
245
294
|
]
|
|
246
295
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { ActiveMixin, LabelMixin } from '@umbraco-ui/uui-base/lib/mixins';
|
|
2
2
|
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
|
|
3
3
|
import { LitElement, html, css } from 'lit';
|
|
4
|
-
import { property, queryAssignedElements } from 'lit/decorators.js';
|
|
4
|
+
import { property, query, queryAssignedElements } from 'lit/decorators.js';
|
|
5
5
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
6
|
+
import { repeat } from 'lit/directives/repeat.js';
|
|
7
|
+
import '@umbraco-ui/uui-button/lib';
|
|
8
|
+
import '@umbraco-ui/uui-popover-container/lib';
|
|
9
|
+
import '@umbraco-ui/uui-symbol-more/lib';
|
|
6
10
|
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
7
11
|
|
|
8
12
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -20,6 +24,7 @@ let UUITabElement = class extends ActiveMixin(LabelMixin("", LitElement)) {
|
|
|
20
24
|
constructor() {
|
|
21
25
|
super();
|
|
22
26
|
this.disabled = false;
|
|
27
|
+
this.orientation = "horizontal";
|
|
23
28
|
this.addEventListener("click", this.onHostClick);
|
|
24
29
|
}
|
|
25
30
|
onHostClick(e) {
|
|
@@ -60,22 +65,24 @@ UUITabElement.styles = [
|
|
|
60
65
|
:host {
|
|
61
66
|
color: var(--uui-tab-text, var(--uui-color-interactive,#1b264f));
|
|
62
67
|
font-family: inherit;
|
|
68
|
+
width: fit-content;
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
#button {
|
|
66
72
|
position: relative;
|
|
73
|
+
box-sizing: border-box;
|
|
67
74
|
display: flex;
|
|
68
75
|
flex-direction: column;
|
|
69
76
|
align-items: center;
|
|
70
77
|
justify-content: center;
|
|
71
|
-
|
|
72
|
-
padding: var(--uui-size-2,6px) var(--uui-size-4,12px);
|
|
73
|
-
border: none;
|
|
74
|
-
box-sizing: border-box;
|
|
75
|
-
min-height: 32px;
|
|
76
|
-
font-size: inherit;
|
|
78
|
+
width: 100%;
|
|
77
79
|
height: 100%;
|
|
80
|
+
min-height: var(--uui-size-12,36px);
|
|
78
81
|
min-width: 70px;
|
|
82
|
+
padding: var(--uui-size-2,6px)
|
|
83
|
+
var(--uui-tab-padding-horizontal, var(--uui-size-5,15px));
|
|
84
|
+
border: none;
|
|
85
|
+
font-size: inherit;
|
|
79
86
|
background: none;
|
|
80
87
|
color: inherit;
|
|
81
88
|
cursor: pointer;
|
|
@@ -86,6 +93,12 @@ UUITabElement.styles = [
|
|
|
86
93
|
line-height: normal;
|
|
87
94
|
}
|
|
88
95
|
|
|
96
|
+
:host([orientation='vertical']) #button {
|
|
97
|
+
min-height: var(--uui-size-14,42px);
|
|
98
|
+
padding: var(--uui-size-2,6px)
|
|
99
|
+
var(--uui-tab-padding-horizontal, var(--uui-size-5,15px));
|
|
100
|
+
}
|
|
101
|
+
|
|
89
102
|
:host(:not([active]):not([disabled])) #button:hover {
|
|
90
103
|
color: var(--uui-tab-text-hover, var(--uui-color-default-emphasis,#3544b1));
|
|
91
104
|
}
|
|
@@ -106,26 +119,49 @@ UUITabElement.styles = [
|
|
|
106
119
|
#button::before {
|
|
107
120
|
content: '';
|
|
108
121
|
position: absolute;
|
|
109
|
-
height: 0px;
|
|
110
|
-
/* max-width: 50px; */
|
|
111
|
-
width: calc(100% - 16px);
|
|
112
|
-
left: auto;
|
|
113
|
-
right: auto;
|
|
114
122
|
background-color: var(--uui-color-current,#f5c1bc);
|
|
115
|
-
bottom: 0;
|
|
116
|
-
border-radius: 3px 3px 0 0;
|
|
117
123
|
opacity: 0;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
background-color: var(--uui-color-current-emphasis,rgb(248, 214, 211));
|
|
124
|
+
--transitionDuration: 120ms;
|
|
125
|
+
--barWidth: 4px;
|
|
126
|
+
--borderRadius: 3px;
|
|
122
127
|
}
|
|
123
128
|
:host([active]) #button::before {
|
|
124
129
|
opacity: 1;
|
|
125
|
-
height: 4px;
|
|
126
|
-
transition: opacity 120ms, height ease-out 120ms;
|
|
127
130
|
}
|
|
128
131
|
|
|
132
|
+
/* HORIZONTAL */
|
|
133
|
+
:host([orientation='horizontal']) #button::before {
|
|
134
|
+
left: auto;
|
|
135
|
+
right: auto;
|
|
136
|
+
border-radius: var(--borderRadius) var(--borderRadius) 0 0;
|
|
137
|
+
height: 0px;
|
|
138
|
+
width: calc(100% - 15px);
|
|
139
|
+
bottom: 0;
|
|
140
|
+
transition: opacity ease-in-out var(--transitionDuration),
|
|
141
|
+
height ease-in-out var(--transitionDuration);
|
|
142
|
+
}
|
|
143
|
+
:host([active][orientation='horizontal']) #button::before {
|
|
144
|
+
height: var(--barWidth);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* VERTICAL */
|
|
148
|
+
:host([orientation='vertical']) #button::before {
|
|
149
|
+
top: auto;
|
|
150
|
+
bottom: auto;
|
|
151
|
+
border-radius: 0 var(--borderRadius) var(--borderRadius) 0;
|
|
152
|
+
height: calc(100% - 12px);
|
|
153
|
+
width: 0px;
|
|
154
|
+
left: 0;
|
|
155
|
+
transition: opacity ease-in-out var(--transitionDuration),
|
|
156
|
+
width ease-in-out var(--transitionDuration);
|
|
157
|
+
}
|
|
158
|
+
:host([active][orientation='vertical']) #button::before {
|
|
159
|
+
width: var(--barWidth);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#button:hover::before {
|
|
163
|
+
background-color: var(--uui-color-current-emphasis,rgb(248, 214, 211));
|
|
164
|
+
}
|
|
129
165
|
:host([disabled]) #button::before {
|
|
130
166
|
background-color: var(--uui-color-disabled-standalone,rgb(226, 226, 226));
|
|
131
167
|
}
|
|
@@ -134,6 +170,18 @@ UUITabElement.styles = [
|
|
|
134
170
|
font-size: 20px;
|
|
135
171
|
margin-bottom: var(--uui-size-2,6px);
|
|
136
172
|
}
|
|
173
|
+
|
|
174
|
+
slot.label {
|
|
175
|
+
/* TODO: Find a better selector */
|
|
176
|
+
text-align: center;
|
|
177
|
+
display: flex;
|
|
178
|
+
width: 100%;
|
|
179
|
+
flex-direction: column;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
:host([orientation='vertical']) slot.label {
|
|
183
|
+
text-align: left;
|
|
184
|
+
}
|
|
137
185
|
`
|
|
138
186
|
];
|
|
139
187
|
__decorateClass$1([
|
|
@@ -145,6 +193,9 @@ __decorateClass$1([
|
|
|
145
193
|
__decorateClass$1([
|
|
146
194
|
property({ type: String })
|
|
147
195
|
], UUITabElement.prototype, "target", 2);
|
|
196
|
+
__decorateClass$1([
|
|
197
|
+
property({ type: String, reflect: true })
|
|
198
|
+
], UUITabElement.prototype, "orientation", 2);
|
|
148
199
|
UUITabElement = __decorateClass$1([
|
|
149
200
|
defineElement("uui-tab")
|
|
150
201
|
], UUITabElement);
|
|
@@ -160,46 +211,191 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
160
211
|
__defProp(target, key, result);
|
|
161
212
|
return result;
|
|
162
213
|
};
|
|
214
|
+
var __accessCheck = (obj, member, msg) => {
|
|
215
|
+
if (!member.has(obj))
|
|
216
|
+
throw TypeError("Cannot " + msg);
|
|
217
|
+
};
|
|
218
|
+
var __privateGet = (obj, member, getter) => {
|
|
219
|
+
__accessCheck(obj, member, "read from private field");
|
|
220
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
221
|
+
};
|
|
222
|
+
var __privateAdd = (obj, member, value) => {
|
|
223
|
+
if (member.has(obj))
|
|
224
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
225
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
226
|
+
};
|
|
227
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
228
|
+
__accessCheck(obj, member, "write to private field");
|
|
229
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
230
|
+
return value;
|
|
231
|
+
};
|
|
232
|
+
var __privateMethod = (obj, member, method) => {
|
|
233
|
+
__accessCheck(obj, member, "access private method");
|
|
234
|
+
return method;
|
|
235
|
+
};
|
|
236
|
+
var _tabElements, _hiddenTabElements, _hiddenTabElementsMap, _visibilityBreakpoints, _oldBreakpoint, _resizeObserver, _onResize, onResize_fn, _onSlotChange, onSlotChange_fn, _onTabClicked, _updateCollapsibleTabs, updateCollapsibleTabs_fn, _calculateBreakPoints, calculateBreakPoints_fn, _setTabArray, setTabArray_fn, _isElementTabLike, isElementTabLike_fn;
|
|
163
237
|
let UUITabGroupElement = class extends LitElement {
|
|
164
238
|
constructor() {
|
|
165
239
|
super(...arguments);
|
|
166
|
-
this
|
|
167
|
-
this
|
|
240
|
+
__privateAdd(this, _onResize);
|
|
241
|
+
__privateAdd(this, _onSlotChange);
|
|
242
|
+
__privateAdd(this, _updateCollapsibleTabs);
|
|
243
|
+
__privateAdd(this, _calculateBreakPoints);
|
|
244
|
+
__privateAdd(this, _setTabArray);
|
|
245
|
+
__privateAdd(this, _isElementTabLike);
|
|
246
|
+
this.dropdownContentDirection = "vertical";
|
|
247
|
+
__privateAdd(this, _tabElements, []);
|
|
248
|
+
__privateAdd(this, _hiddenTabElements, []);
|
|
249
|
+
__privateAdd(this, _hiddenTabElementsMap, /* @__PURE__ */ new Map());
|
|
250
|
+
__privateAdd(this, _visibilityBreakpoints, []);
|
|
251
|
+
__privateAdd(this, _oldBreakpoint, 0);
|
|
252
|
+
__privateAdd(this, _resizeObserver, new ResizeObserver(
|
|
253
|
+
__privateMethod(this, _onResize, onResize_fn).bind(this)
|
|
254
|
+
));
|
|
255
|
+
__privateAdd(this, _onTabClicked, (e) => {
|
|
168
256
|
const selectedElement = e.currentTarget;
|
|
169
|
-
if (this.
|
|
257
|
+
if (__privateMethod(this, _isElementTabLike, isElementTabLike_fn).call(this, selectedElement)) {
|
|
170
258
|
selectedElement.active = true;
|
|
171
|
-
const
|
|
259
|
+
const linkedElement = __privateGet(this, _hiddenTabElementsMap).get(selectedElement);
|
|
260
|
+
if (linkedElement) {
|
|
261
|
+
linkedElement.active = true;
|
|
262
|
+
}
|
|
263
|
+
const filtered = [
|
|
264
|
+
...__privateGet(this, _tabElements),
|
|
265
|
+
...__privateGet(this, _hiddenTabElements)
|
|
266
|
+
].filter((el) => el !== selectedElement && el !== linkedElement);
|
|
172
267
|
filtered.forEach((el) => {
|
|
173
|
-
if (this.
|
|
268
|
+
if (__privateMethod(this, _isElementTabLike, isElementTabLike_fn).call(this, el)) {
|
|
174
269
|
el.active = false;
|
|
175
270
|
}
|
|
176
271
|
});
|
|
272
|
+
const hasActiveHidden = __privateGet(this, _hiddenTabElements).some(
|
|
273
|
+
(el) => el.active && el !== linkedElement
|
|
274
|
+
);
|
|
275
|
+
hasActiveHidden ? this._moreButtonElement.classList.add("active-inside") : this._moreButtonElement.classList.remove("active-inside");
|
|
177
276
|
}
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
_setTabArray() {
|
|
181
|
-
this._tabElements = this._slottedNodes ? this._slottedNodes : [];
|
|
182
|
-
}
|
|
183
|
-
_onSlotChange() {
|
|
184
|
-
this._tabElements.forEach((el) => {
|
|
185
|
-
el.removeEventListener("click", this._onTabClicked);
|
|
186
277
|
});
|
|
187
|
-
this._setTabArray();
|
|
188
|
-
this._tabElements.forEach((el) => {
|
|
189
|
-
el.addEventListener("click", this._onTabClicked);
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
_elementIsTabLike(el) {
|
|
193
|
-
return el instanceof UUITabElement || "active" in el;
|
|
194
278
|
}
|
|
195
279
|
connectedCallback() {
|
|
196
280
|
super.connectedCallback();
|
|
281
|
+
__privateGet(this, _resizeObserver).observe(this);
|
|
197
282
|
if (!this.hasAttribute("role"))
|
|
198
283
|
this.setAttribute("role", "tablist");
|
|
199
284
|
}
|
|
285
|
+
disconnectedCallback() {
|
|
286
|
+
super.disconnectedCallback();
|
|
287
|
+
__privateGet(this, _resizeObserver).unobserve(this);
|
|
288
|
+
}
|
|
200
289
|
render() {
|
|
201
|
-
return html`
|
|
290
|
+
return html`
|
|
291
|
+
<slot @slotchange=${__privateMethod(this, _onSlotChange, onSlotChange_fn)}></slot>
|
|
292
|
+
<uui-button
|
|
293
|
+
popovertarget="popover-container"
|
|
294
|
+
style="display: none"
|
|
295
|
+
id="more-button"
|
|
296
|
+
label="More"
|
|
297
|
+
compact>
|
|
298
|
+
<uui-symbol-more></uui-symbol-more>
|
|
299
|
+
</uui-button>
|
|
300
|
+
<uui-popover-container
|
|
301
|
+
id="popover-container"
|
|
302
|
+
popover
|
|
303
|
+
margin="10"
|
|
304
|
+
placement="bottom-end">
|
|
305
|
+
<div id="hidden-tabs-container">
|
|
306
|
+
${repeat(__privateGet(this, _hiddenTabElements), (el) => html`${el}`)}
|
|
307
|
+
</div>
|
|
308
|
+
</uui-popover-container>
|
|
309
|
+
`;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
_tabElements = new WeakMap();
|
|
313
|
+
_hiddenTabElements = new WeakMap();
|
|
314
|
+
_hiddenTabElementsMap = new WeakMap();
|
|
315
|
+
_visibilityBreakpoints = new WeakMap();
|
|
316
|
+
_oldBreakpoint = new WeakMap();
|
|
317
|
+
_resizeObserver = new WeakMap();
|
|
318
|
+
_onResize = new WeakSet();
|
|
319
|
+
onResize_fn = function(entries) {
|
|
320
|
+
__privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, entries[0].contentBoxSize[0].inlineSize);
|
|
321
|
+
};
|
|
322
|
+
_onSlotChange = new WeakSet();
|
|
323
|
+
onSlotChange_fn = function() {
|
|
324
|
+
__privateGet(this, _tabElements).forEach((el) => {
|
|
325
|
+
el.removeEventListener("click", __privateGet(this, _onTabClicked));
|
|
326
|
+
});
|
|
327
|
+
__privateMethod(this, _setTabArray, setTabArray_fn).call(this);
|
|
328
|
+
__privateGet(this, _tabElements).forEach((el) => {
|
|
329
|
+
el.addEventListener("click", __privateGet(this, _onTabClicked));
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
_onTabClicked = new WeakMap();
|
|
333
|
+
_updateCollapsibleTabs = new WeakSet();
|
|
334
|
+
updateCollapsibleTabs_fn = function(containerWidth) {
|
|
335
|
+
const buttonWidth = this._moreButtonElement.offsetWidth;
|
|
336
|
+
if (__privateGet(this, _visibilityBreakpoints).slice(-1)[0] < containerWidth && __privateGet(this, _hiddenTabElements).length === 0)
|
|
337
|
+
return;
|
|
338
|
+
let newBreakpoint = Number.MAX_VALUE;
|
|
339
|
+
for (let i = __privateGet(this, _visibilityBreakpoints).length - 1; i > -1; i--) {
|
|
340
|
+
const breakpoint = __privateGet(this, _visibilityBreakpoints)[i];
|
|
341
|
+
const containerWidthButtonWidth = containerWidth - (i !== __privateGet(this, _visibilityBreakpoints).length - 1 ? buttonWidth : 0);
|
|
342
|
+
if (breakpoint < containerWidthButtonWidth) {
|
|
343
|
+
newBreakpoint = i;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
202
346
|
}
|
|
347
|
+
if (newBreakpoint === __privateGet(this, _oldBreakpoint))
|
|
348
|
+
return;
|
|
349
|
+
__privateSet(this, _oldBreakpoint, newBreakpoint);
|
|
350
|
+
__privateGet(this, _hiddenTabElements).forEach((el) => {
|
|
351
|
+
el.removeEventListener("click", __privateGet(this, _onTabClicked));
|
|
352
|
+
});
|
|
353
|
+
__privateSet(this, _hiddenTabElements, []);
|
|
354
|
+
__privateGet(this, _hiddenTabElementsMap).clear();
|
|
355
|
+
let hasActiveTabInDropdown = false;
|
|
356
|
+
for (let i = 0; i < __privateGet(this, _visibilityBreakpoints).length; i++) {
|
|
357
|
+
const breakpoint = __privateGet(this, _visibilityBreakpoints)[i];
|
|
358
|
+
const tab = __privateGet(this, _tabElements)[i];
|
|
359
|
+
const containerWidthButtonWidth = containerWidth - (i !== __privateGet(this, _visibilityBreakpoints).length - 1 ? buttonWidth : 0);
|
|
360
|
+
if (breakpoint < containerWidthButtonWidth) {
|
|
361
|
+
tab.style.display = "";
|
|
362
|
+
this._moreButtonElement.style.display = "none";
|
|
363
|
+
} else {
|
|
364
|
+
const proxyTab = tab.cloneNode(true);
|
|
365
|
+
proxyTab.addEventListener("click", __privateGet(this, _onTabClicked));
|
|
366
|
+
proxyTab.classList.add("hidden-tab");
|
|
367
|
+
proxyTab.style.display = "";
|
|
368
|
+
proxyTab.orientation = this.dropdownContentDirection;
|
|
369
|
+
__privateGet(this, _hiddenTabElementsMap).set(proxyTab, tab);
|
|
370
|
+
__privateGet(this, _hiddenTabElementsMap).set(tab, proxyTab);
|
|
371
|
+
__privateGet(this, _hiddenTabElements).push(proxyTab);
|
|
372
|
+
tab.style.display = "none";
|
|
373
|
+
this._moreButtonElement.style.display = "";
|
|
374
|
+
if (tab.active) {
|
|
375
|
+
hasActiveTabInDropdown = true;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
hasActiveTabInDropdown ? this._moreButtonElement.classList.add("active-inside") : this._moreButtonElement.classList.remove("active-inside");
|
|
380
|
+
this.requestUpdate();
|
|
381
|
+
};
|
|
382
|
+
_calculateBreakPoints = new WeakSet();
|
|
383
|
+
calculateBreakPoints_fn = function() {
|
|
384
|
+
let childrenWidth = 0;
|
|
385
|
+
for (let i = 0; i < __privateGet(this, _tabElements).length; i++) {
|
|
386
|
+
childrenWidth += __privateGet(this, _tabElements)[i].offsetWidth;
|
|
387
|
+
__privateGet(this, _visibilityBreakpoints)[i] = childrenWidth;
|
|
388
|
+
}
|
|
389
|
+
__privateMethod(this, _updateCollapsibleTabs, updateCollapsibleTabs_fn).call(this, this.offsetWidth);
|
|
390
|
+
};
|
|
391
|
+
_setTabArray = new WeakSet();
|
|
392
|
+
setTabArray_fn = function() {
|
|
393
|
+
__privateSet(this, _tabElements, this._slottedNodes ? this._slottedNodes : []);
|
|
394
|
+
__privateMethod(this, _calculateBreakPoints, calculateBreakPoints_fn).call(this);
|
|
395
|
+
};
|
|
396
|
+
_isElementTabLike = new WeakSet();
|
|
397
|
+
isElementTabLike_fn = function(el) {
|
|
398
|
+
return el instanceof UUITabElement || "active" in el;
|
|
203
399
|
};
|
|
204
400
|
UUITabGroupElement.styles = [
|
|
205
401
|
css`
|
|
@@ -215,14 +411,62 @@ UUITabGroupElement.styles = [
|
|
|
215
411
|
::slotted(*:not(:last-of-type)) {
|
|
216
412
|
border-right: 1px solid var(--uui-tab-divider, none);
|
|
217
413
|
}
|
|
414
|
+
|
|
415
|
+
.hidden-tab {
|
|
416
|
+
width: 100%;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
#hidden-tabs-container {
|
|
420
|
+
width: fit-content;
|
|
421
|
+
display: flex;
|
|
422
|
+
flex-direction: column;
|
|
423
|
+
background: var(--uui-color-surface,#fff);
|
|
424
|
+
border-radius: var(--uui-border-radius,3px);
|
|
425
|
+
box-shadow: var(--uui-shadow-depth-3,0 10px 20px rgba(0,0,0,0.19) , 0 6px 6px rgba(0,0,0,0.23));
|
|
426
|
+
overflow: hidden;
|
|
427
|
+
}
|
|
428
|
+
:host([dropdown-direction='horizontal']) #hidden-tabs-container {
|
|
429
|
+
flex-direction: row;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
#more-button {
|
|
433
|
+
margin-left: auto;
|
|
434
|
+
position: relative;
|
|
435
|
+
}
|
|
436
|
+
#more-button::before {
|
|
437
|
+
content: '';
|
|
438
|
+
position: absolute;
|
|
439
|
+
bottom: 0;
|
|
440
|
+
width: 100%;
|
|
441
|
+
background-color: var(--uui-color-current,#f5c1bc);
|
|
442
|
+
height: 0px;
|
|
443
|
+
border-radius: 3px 3px 0 0;
|
|
444
|
+
opacity: 0;
|
|
445
|
+
transition: opacity ease-in 120ms, height ease-in 120ms;
|
|
446
|
+
}
|
|
447
|
+
#more-button.active-inside::before {
|
|
448
|
+
opacity: 1;
|
|
449
|
+
height: 4px;
|
|
450
|
+
transition: opacity 120ms, height ease-out 120ms;
|
|
451
|
+
}
|
|
218
452
|
`
|
|
219
453
|
];
|
|
454
|
+
__decorateClass([
|
|
455
|
+
query("#more-button")
|
|
456
|
+
], UUITabGroupElement.prototype, "_moreButtonElement", 2);
|
|
220
457
|
__decorateClass([
|
|
221
458
|
queryAssignedElements({
|
|
222
459
|
flatten: true,
|
|
223
460
|
selector: "uui-tab, [uui-tab], [role=tab]"
|
|
224
461
|
})
|
|
225
462
|
], UUITabGroupElement.prototype, "_slottedNodes", 2);
|
|
463
|
+
__decorateClass([
|
|
464
|
+
property({
|
|
465
|
+
type: String,
|
|
466
|
+
reflect: true,
|
|
467
|
+
attribute: "dropdown-content-direction"
|
|
468
|
+
})
|
|
469
|
+
], UUITabGroupElement.prototype, "dropdownContentDirection", 2);
|
|
226
470
|
UUITabGroupElement = __decorateClass([
|
|
227
471
|
defineElement("uui-tab-group")
|
|
228
472
|
], UUITabGroupElement);
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
+
import '@umbraco-ui/uui-button/lib';
|
|
3
|
+
import '@umbraco-ui/uui-popover-container/lib';
|
|
4
|
+
import '@umbraco-ui/uui-symbol-more/lib';
|
|
2
5
|
/**
|
|
3
6
|
* @element uui-tab-group
|
|
4
7
|
* @slot - Default slot for the tab group
|
|
5
8
|
*/
|
|
6
9
|
export declare class UUITabGroupElement extends LitElement {
|
|
7
|
-
|
|
10
|
+
#private;
|
|
11
|
+
private _moreButtonElement;
|
|
8
12
|
private _slottedNodes?;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Set the flex direction of the content of the dropdown.
|
|
15
|
+
* @type {string}
|
|
16
|
+
* @attr
|
|
17
|
+
* @default vertical
|
|
18
|
+
*/
|
|
19
|
+
dropdownContentDirection: 'vertical' | 'horizontal';
|
|
14
20
|
connectedCallback(): void;
|
|
21
|
+
disconnectedCallback(): void;
|
|
15
22
|
render(): import("lit-html").TemplateResult<1>;
|
|
23
|
+
static styles: import("lit").CSSResult[];
|
|
16
24
|
}
|
|
17
25
|
declare global {
|
|
18
26
|
interface HTMLElementTagNameMap {
|
package/lib/uui-tab.element.d.ts
CHANGED
|
@@ -12,9 +12,9 @@ declare const UUITabElement_base: (new (...args: any[]) => import("@umbraco-ui/u
|
|
|
12
12
|
* @cssprop --uui-tab-text-active - Define the tab text active color
|
|
13
13
|
* @cssprop --uui-tab-background - Define the tab group background color
|
|
14
14
|
* @cssprop --uui-tab-divider - Define the tab dividers color
|
|
15
|
+
* @cssprop --uui-tab-padding-horizontal - Define the tab horizontal padding
|
|
15
16
|
*/
|
|
16
17
|
export declare class UUITabElement extends UUITabElement_base {
|
|
17
|
-
static styles: import("lit").CSSResult[];
|
|
18
18
|
/**
|
|
19
19
|
* Reflects the disabled state of the element. True if tab is disabled. Change this to switch the state programmatically.
|
|
20
20
|
* @type {boolean}
|
|
@@ -36,9 +36,17 @@ export declare class UUITabElement extends UUITabElement_base {
|
|
|
36
36
|
* @default undefined
|
|
37
37
|
*/
|
|
38
38
|
target?: '_blank' | '_parent' | '_self' | '_top';
|
|
39
|
+
/**
|
|
40
|
+
* Set the visual orientation of this tab, this changes the look and placement of the active indication.
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @attr
|
|
43
|
+
* @default horizontal
|
|
44
|
+
*/
|
|
45
|
+
orientation?: 'horizontal' | 'vertical';
|
|
39
46
|
constructor();
|
|
40
47
|
private onHostClick;
|
|
41
48
|
render(): import("lit-html").TemplateResult<1>;
|
|
49
|
+
static styles: import("lit").CSSResult[];
|
|
42
50
|
}
|
|
43
51
|
declare global {
|
|
44
52
|
interface HTMLElementTagNameMap {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-tabs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-rc.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,7 +30,10 @@
|
|
|
30
30
|
"custom-elements.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@umbraco-ui/uui-base": "1.
|
|
33
|
+
"@umbraco-ui/uui-base": "1.5.0-rc.1",
|
|
34
|
+
"@umbraco-ui/uui-button": "1.5.0-rc.1",
|
|
35
|
+
"@umbraco-ui/uui-popover-container": "1.5.0-rc.1",
|
|
36
|
+
"@umbraco-ui/uui-symbol-more": "1.5.0-rc.1"
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
39
|
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
|
|
@@ -41,5 +44,5 @@
|
|
|
41
44
|
"access": "public"
|
|
42
45
|
},
|
|
43
46
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-tabs",
|
|
44
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "2ff35a098ed8a3feb8ebed1bf43b4fbb75950d65"
|
|
45
48
|
}
|