@umbraco-ui/uui-tabs 1.0.0-alpha.0 → 1.0.0-rc.2
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/custom-elements.json +80 -4
- package/lib/index.js +64 -40
- package/lib/uui-tab-group.element.d.ts +6 -6
- package/lib/uui-tab.element.d.ts +18 -0
- package/package.json +3 -3
package/custom-elements.json
CHANGED
|
@@ -29,6 +29,18 @@
|
|
|
29
29
|
"type": "boolean",
|
|
30
30
|
"default": "\"false\""
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
"name": "href",
|
|
34
|
+
"description": "Set an href, this will turns the inner button into a anchor tag.",
|
|
35
|
+
"type": "string",
|
|
36
|
+
"default": "\"undefined\""
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "target",
|
|
40
|
+
"description": "Set an anchor tag target, only used when using href.",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"default": "\"undefined\""
|
|
43
|
+
},
|
|
32
44
|
{
|
|
33
45
|
"name": "active",
|
|
34
46
|
"description": "Set this boolean to true for then the related composition is sorted.",
|
|
@@ -37,7 +49,7 @@
|
|
|
37
49
|
},
|
|
38
50
|
{
|
|
39
51
|
"name": "label",
|
|
40
|
-
"description": "Label to be used for aria-label and
|
|
52
|
+
"description": "Label to be used for aria-label and potentially as visual label for some components",
|
|
41
53
|
"type": "string"
|
|
42
54
|
}
|
|
43
55
|
],
|
|
@@ -54,6 +66,20 @@
|
|
|
54
66
|
"type": "boolean",
|
|
55
67
|
"default": "\"false\""
|
|
56
68
|
},
|
|
69
|
+
{
|
|
70
|
+
"name": "href",
|
|
71
|
+
"attribute": "href",
|
|
72
|
+
"description": "Set an href, this will turns the inner button into a anchor tag.",
|
|
73
|
+
"type": "string",
|
|
74
|
+
"default": "\"undefined\""
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "target",
|
|
78
|
+
"attribute": "target",
|
|
79
|
+
"description": "Set an anchor tag target, only used when using href.",
|
|
80
|
+
"type": "string",
|
|
81
|
+
"default": "\"undefined\""
|
|
82
|
+
},
|
|
57
83
|
{
|
|
58
84
|
"name": "active",
|
|
59
85
|
"attribute": "active",
|
|
@@ -64,11 +90,23 @@
|
|
|
64
90
|
{
|
|
65
91
|
"name": "label",
|
|
66
92
|
"attribute": "label",
|
|
67
|
-
"description": "Label to be used for aria-label and
|
|
93
|
+
"description": "Label to be used for aria-label and potentially as visual label for some components",
|
|
68
94
|
"type": "string"
|
|
69
95
|
}
|
|
70
96
|
],
|
|
71
97
|
"slots": [
|
|
98
|
+
{
|
|
99
|
+
"name": "default",
|
|
100
|
+
"description": "for label"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "icon",
|
|
104
|
+
"description": "for icon"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "extra",
|
|
108
|
+
"description": "for extra"
|
|
109
|
+
},
|
|
72
110
|
{
|
|
73
111
|
"name": "",
|
|
74
112
|
"description": "Override the default label"
|
|
@@ -108,6 +146,18 @@
|
|
|
108
146
|
"type": "boolean",
|
|
109
147
|
"default": "\"false\""
|
|
110
148
|
},
|
|
149
|
+
{
|
|
150
|
+
"name": "href",
|
|
151
|
+
"description": "Set an href, this will turns the inner button into a anchor tag.",
|
|
152
|
+
"type": "string",
|
|
153
|
+
"default": "\"undefined\""
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "target",
|
|
157
|
+
"description": "Set an anchor tag target, only used when using href.",
|
|
158
|
+
"type": "string",
|
|
159
|
+
"default": "\"undefined\""
|
|
160
|
+
},
|
|
111
161
|
{
|
|
112
162
|
"name": "active",
|
|
113
163
|
"description": "Set this boolean to true for then the related composition is sorted.",
|
|
@@ -116,7 +166,7 @@
|
|
|
116
166
|
},
|
|
117
167
|
{
|
|
118
168
|
"name": "label",
|
|
119
|
-
"description": "Label to be used for aria-label and
|
|
169
|
+
"description": "Label to be used for aria-label and potentially as visual label for some components",
|
|
120
170
|
"type": "string"
|
|
121
171
|
}
|
|
122
172
|
],
|
|
@@ -133,6 +183,20 @@
|
|
|
133
183
|
"type": "boolean",
|
|
134
184
|
"default": "\"false\""
|
|
135
185
|
},
|
|
186
|
+
{
|
|
187
|
+
"name": "href",
|
|
188
|
+
"attribute": "href",
|
|
189
|
+
"description": "Set an href, this will turns the inner button into a anchor tag.",
|
|
190
|
+
"type": "string",
|
|
191
|
+
"default": "\"undefined\""
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "target",
|
|
195
|
+
"attribute": "target",
|
|
196
|
+
"description": "Set an anchor tag target, only used when using href.",
|
|
197
|
+
"type": "string",
|
|
198
|
+
"default": "\"undefined\""
|
|
199
|
+
},
|
|
136
200
|
{
|
|
137
201
|
"name": "active",
|
|
138
202
|
"attribute": "active",
|
|
@@ -143,11 +207,23 @@
|
|
|
143
207
|
{
|
|
144
208
|
"name": "label",
|
|
145
209
|
"attribute": "label",
|
|
146
|
-
"description": "Label to be used for aria-label and
|
|
210
|
+
"description": "Label to be used for aria-label and potentially as visual label for some components",
|
|
147
211
|
"type": "string"
|
|
148
212
|
}
|
|
149
213
|
],
|
|
150
214
|
"slots": [
|
|
215
|
+
{
|
|
216
|
+
"name": "default",
|
|
217
|
+
"description": "for label"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"name": "icon",
|
|
221
|
+
"description": "for icon"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "extra",
|
|
225
|
+
"description": "for extra"
|
|
226
|
+
},
|
|
151
227
|
{
|
|
152
228
|
"name": "",
|
|
153
229
|
"description": "Override the default label"
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@ 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
4
|
import { property, queryAssignedElements } from 'lit/decorators.js';
|
|
5
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
6
|
import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
|
|
6
7
|
|
|
7
8
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -28,11 +29,30 @@ let UUITabElement = class extends ActiveMixin(LabelMixin("", LitElement)) {
|
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
render() {
|
|
31
|
-
return html`
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
return this.href ? html`
|
|
33
|
+
<a
|
|
34
|
+
id="button"
|
|
35
|
+
href=${ifDefined(!this.disabled ? this.href : void 0)}
|
|
36
|
+
target=${ifDefined(this.target || void 0)}
|
|
37
|
+
rel=${ifDefined(
|
|
38
|
+
this.target === "_blank" ? "noopener noreferrer" : void 0
|
|
39
|
+
)}
|
|
40
|
+
role="tab">
|
|
41
|
+
<slot name="icon"></slot>
|
|
42
|
+
${this.renderLabel()}
|
|
43
|
+
<slot name="extra"></slot>
|
|
44
|
+
</a>
|
|
45
|
+
` : html`
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
id="button"
|
|
49
|
+
?disabled=${this.disabled}
|
|
50
|
+
role="tab">
|
|
51
|
+
<slot name="icon"></slot>
|
|
52
|
+
${this.renderLabel()}
|
|
53
|
+
<slot name="extra"></slot>
|
|
54
|
+
</button>
|
|
55
|
+
`;
|
|
36
56
|
}
|
|
37
57
|
};
|
|
38
58
|
UUITabElement.styles = [
|
|
@@ -42,7 +62,7 @@ UUITabElement.styles = [
|
|
|
42
62
|
font-family: inherit;
|
|
43
63
|
}
|
|
44
64
|
|
|
45
|
-
button {
|
|
65
|
+
#button {
|
|
46
66
|
position: relative;
|
|
47
67
|
display: flex;
|
|
48
68
|
flex-direction: column;
|
|
@@ -55,38 +75,35 @@ UUITabElement.styles = [
|
|
|
55
75
|
min-height: 32px;
|
|
56
76
|
font-size: inherit;
|
|
57
77
|
height: 100%;
|
|
58
|
-
min-width:
|
|
78
|
+
min-width: 70px;
|
|
59
79
|
background: none;
|
|
60
80
|
color: inherit;
|
|
61
81
|
cursor: pointer;
|
|
62
82
|
font-family: inherit;
|
|
83
|
+
|
|
84
|
+
/* for anchor tag: */
|
|
85
|
+
text-decoration: none;
|
|
86
|
+
line-height: normal;
|
|
63
87
|
}
|
|
64
88
|
|
|
65
|
-
:host(:not([active]):not([disabled])) button:hover {
|
|
66
|
-
color: var(
|
|
67
|
-
--uui-tab-text-hover,
|
|
68
|
-
var(--uui-color-default-emphasis, white)
|
|
69
|
-
);
|
|
89
|
+
:host(:not([active]):not([disabled])) #button:hover {
|
|
90
|
+
color: var(--uui-tab-text-hover, var(--uui-color-default-emphasis,#3544b1));
|
|
70
91
|
}
|
|
71
92
|
|
|
72
|
-
:host(:not([active]):not([disabled])) button:active {
|
|
93
|
+
:host(:not([active]):not([disabled])) #button:active {
|
|
73
94
|
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),
|
|
74
95
|
0 1px 2px rgba(0, 0, 0, 0.05);
|
|
75
96
|
}
|
|
76
97
|
|
|
77
|
-
:host([active]) button {
|
|
78
|
-
color: var(
|
|
79
|
-
--uui-tab-text-active,
|
|
80
|
-
var(--uui-color-default-emphasis, white)
|
|
81
|
-
);
|
|
98
|
+
:host([active]) #button {
|
|
82
99
|
cursor: default;
|
|
83
100
|
}
|
|
84
|
-
:host([disabled]) button {
|
|
101
|
+
:host([disabled]) #button {
|
|
85
102
|
color: var(--uui-color-disabled-contrast,#c4c4c4);
|
|
86
103
|
cursor: default;
|
|
87
104
|
}
|
|
88
105
|
|
|
89
|
-
button::before {
|
|
106
|
+
#button::before {
|
|
90
107
|
content: '';
|
|
91
108
|
position: absolute;
|
|
92
109
|
height: 0px;
|
|
@@ -100,20 +117,21 @@ UUITabElement.styles = [
|
|
|
100
117
|
opacity: 0;
|
|
101
118
|
transition: opacity ease-in 120ms, height ease-in 120ms;
|
|
102
119
|
}
|
|
103
|
-
button:hover::before {
|
|
120
|
+
#button:hover::before {
|
|
104
121
|
background-color: var(--uui-color-current-emphasis,rgb(248, 214, 211));
|
|
105
122
|
}
|
|
106
|
-
:host([active]) button::before {
|
|
123
|
+
:host([active]) #button::before {
|
|
107
124
|
opacity: 1;
|
|
108
125
|
height: 4px;
|
|
109
126
|
transition: opacity 120ms, height ease-out 120ms;
|
|
110
127
|
}
|
|
111
128
|
|
|
112
|
-
:host([disabled]) button::before {
|
|
129
|
+
:host([disabled]) #button::before {
|
|
113
130
|
background-color: var(--uui-color-disabled-standalone,rgb(226, 226, 226));
|
|
114
131
|
}
|
|
115
132
|
|
|
116
|
-
::slotted(
|
|
133
|
+
slot[name='icon']::slotted(*) {
|
|
134
|
+
font-size: 20px;
|
|
117
135
|
margin-bottom: var(--uui-size-2,6px);
|
|
118
136
|
}
|
|
119
137
|
`
|
|
@@ -121,6 +139,12 @@ UUITabElement.styles = [
|
|
|
121
139
|
__decorateClass$1([
|
|
122
140
|
property({ type: Boolean, reflect: true })
|
|
123
141
|
], UUITabElement.prototype, "disabled", 2);
|
|
142
|
+
__decorateClass$1([
|
|
143
|
+
property({ type: String })
|
|
144
|
+
], UUITabElement.prototype, "href", 2);
|
|
145
|
+
__decorateClass$1([
|
|
146
|
+
property({ type: String })
|
|
147
|
+
], UUITabElement.prototype, "target", 2);
|
|
124
148
|
UUITabElement = __decorateClass$1([
|
|
125
149
|
defineElement("uui-tab")
|
|
126
150
|
], UUITabElement);
|
|
@@ -139,33 +163,33 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
139
163
|
let UUITabGroupElement = class extends LitElement {
|
|
140
164
|
constructor() {
|
|
141
165
|
super(...arguments);
|
|
142
|
-
this.
|
|
143
|
-
this.
|
|
166
|
+
this._tabElements = [];
|
|
167
|
+
this._onTabActive = (e) => {
|
|
144
168
|
const selectedElement = e.currentTarget;
|
|
145
|
-
if (this.
|
|
169
|
+
if (this._elementIsTabLike(selectedElement)) {
|
|
146
170
|
selectedElement.active = true;
|
|
147
171
|
}
|
|
148
|
-
const filtered = this.
|
|
172
|
+
const filtered = this._tabElements.filter((el) => el !== selectedElement);
|
|
149
173
|
filtered.forEach((el) => {
|
|
150
|
-
if (this.
|
|
174
|
+
if (this._elementIsTabLike(el)) {
|
|
151
175
|
el.active = false;
|
|
152
176
|
}
|
|
153
177
|
});
|
|
154
178
|
};
|
|
155
179
|
}
|
|
156
|
-
|
|
157
|
-
this.
|
|
180
|
+
_setTabArray() {
|
|
181
|
+
this._tabElements = this._slottedNodes ? this._slottedNodes : [];
|
|
158
182
|
}
|
|
159
|
-
|
|
160
|
-
this.
|
|
161
|
-
el.removeEventListener("click", this.
|
|
183
|
+
_onSlotChange() {
|
|
184
|
+
this._tabElements.forEach((el) => {
|
|
185
|
+
el.removeEventListener("click", this._onTabActive);
|
|
162
186
|
});
|
|
163
|
-
this.
|
|
164
|
-
this.
|
|
165
|
-
el.addEventListener("click", this.
|
|
187
|
+
this._setTabArray();
|
|
188
|
+
this._tabElements.forEach((el) => {
|
|
189
|
+
el.addEventListener("click", this._onTabActive);
|
|
166
190
|
});
|
|
167
191
|
}
|
|
168
|
-
|
|
192
|
+
_elementIsTabLike(el) {
|
|
169
193
|
return el instanceof UUITabElement || "active" in el;
|
|
170
194
|
}
|
|
171
195
|
connectedCallback() {
|
|
@@ -174,7 +198,7 @@ let UUITabGroupElement = class extends LitElement {
|
|
|
174
198
|
this.setAttribute("role", "tablist");
|
|
175
199
|
}
|
|
176
200
|
render() {
|
|
177
|
-
return html` <slot @slotchange=${this.
|
|
201
|
+
return html` <slot @slotchange=${this._onSlotChange}></slot> `;
|
|
178
202
|
}
|
|
179
203
|
};
|
|
180
204
|
UUITabGroupElement.styles = [
|
|
@@ -198,7 +222,7 @@ __decorateClass([
|
|
|
198
222
|
flatten: true,
|
|
199
223
|
selector: "uui-tab, [uui-tab], [role=tab]"
|
|
200
224
|
})
|
|
201
|
-
], UUITabGroupElement.prototype, "
|
|
225
|
+
], UUITabGroupElement.prototype, "_slottedNodes", 2);
|
|
202
226
|
UUITabGroupElement = __decorateClass([
|
|
203
227
|
defineElement("uui-tab-group")
|
|
204
228
|
], UUITabGroupElement);
|
|
@@ -5,12 +5,12 @@ import { LitElement } from 'lit';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class UUITabGroupElement extends LitElement {
|
|
7
7
|
static styles: import("lit").CSSResult[];
|
|
8
|
-
private
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
private
|
|
8
|
+
private _slottedNodes?;
|
|
9
|
+
private _tabElements;
|
|
10
|
+
private _setTabArray;
|
|
11
|
+
private _onSlotChange;
|
|
12
|
+
private _onTabActive;
|
|
13
|
+
private _elementIsTabLike;
|
|
14
14
|
connectedCallback(): void;
|
|
15
15
|
render(): import("lit-html").TemplateResult<1>;
|
|
16
16
|
}
|
package/lib/uui-tab.element.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ declare const UUITabElement_base: (new (...args: any[]) => import("@umbraco-ui/u
|
|
|
3
3
|
/**
|
|
4
4
|
* A single tab. Should be put into `<uui-tab-group>`,
|
|
5
5
|
* @element uui-tabs
|
|
6
|
+
* @slot default - for label
|
|
7
|
+
* @slot icon - for icon
|
|
8
|
+
* @slot extra - for extra
|
|
9
|
+
* @description - All-round tab-button
|
|
6
10
|
* @cssprop --uui-tab-text - Define the tab text color
|
|
7
11
|
* @cssprop --uui-tab-text-hover - Define the tab text hover color
|
|
8
12
|
* @cssprop --uui-tab-text-active - Define the tab text active color
|
|
@@ -18,6 +22,20 @@ export declare class UUITabElement extends UUITabElement_base {
|
|
|
18
22
|
* @default false
|
|
19
23
|
*/
|
|
20
24
|
disabled: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Set an href, this will turns the inner button into a anchor tag.
|
|
27
|
+
* @type {string}
|
|
28
|
+
* @attr
|
|
29
|
+
* @default undefined
|
|
30
|
+
*/
|
|
31
|
+
href?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Set an anchor tag target, only used when using href.
|
|
34
|
+
* @type {string}
|
|
35
|
+
* @attr
|
|
36
|
+
* @default undefined
|
|
37
|
+
*/
|
|
38
|
+
target?: '_blank' | '_parent' | '_self' | '_top';
|
|
21
39
|
constructor();
|
|
22
40
|
private onHostClick;
|
|
23
41
|
render(): import("lit-html").TemplateResult<1>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umbraco-ui/uui-tabs",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Umbraco",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"custom-elements.json"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@umbraco-ui/uui-base": "1.0.0-
|
|
33
|
+
"@umbraco-ui/uui-base": "1.0.0-rc.2"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://uui.umbraco.com/?path=/story/uui-tabs",
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "436dd8d9fff81481feb88f06b461167c98dac91a"
|
|
45
45
|
}
|