@umbraco-ui/uui-tabs 1.0.0-alpha.0 → 1.0.0-rc.0

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.
@@ -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.",
@@ -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",
@@ -69,6 +95,18 @@
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.",
@@ -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",
@@ -148,6 +212,18 @@
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,28 @@ let UUITabElement = class extends ActiveMixin(LabelMixin("", LitElement)) {
28
29
  }
29
30
  }
30
31
  render() {
31
- return html`
32
- <button type="button" ?disabled=${this.disabled} role="tab">
33
- ${this.renderLabel()}
34
- </button>
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(this.target === "_blank" ? "noopener noreferrer" : void 0)}
38
+ role="tab">
39
+ <slot name="icon"></slot>
40
+ ${this.renderLabel()}
41
+ <slot name="extra"></slot>
42
+ </a>
43
+ ` : html`
44
+ <button
45
+ type="button"
46
+ id="button"
47
+ ?disabled=${this.disabled}
48
+ role="tab">
49
+ <slot name="icon"></slot>
50
+ ${this.renderLabel()}
51
+ <slot name="extra"></slot>
52
+ </button>
53
+ `;
36
54
  }
37
55
  };
38
56
  UUITabElement.styles = [
@@ -42,7 +60,7 @@ UUITabElement.styles = [
42
60
  font-family: inherit;
43
61
  }
44
62
 
45
- button {
63
+ #button {
46
64
  position: relative;
47
65
  display: flex;
48
66
  flex-direction: column;
@@ -55,38 +73,35 @@ UUITabElement.styles = [
55
73
  min-height: 32px;
56
74
  font-size: inherit;
57
75
  height: 100%;
58
- min-width: 75px;
76
+ min-width: 70px;
59
77
  background: none;
60
78
  color: inherit;
61
79
  cursor: pointer;
62
80
  font-family: inherit;
81
+
82
+ /* for anchor tag: */
83
+ text-decoration: none;
84
+ line-height: normal;
63
85
  }
64
86
 
65
- :host(:not([active]):not([disabled])) button:hover {
66
- color: var(
67
- --uui-tab-text-hover,
68
- var(--uui-color-default-emphasis, white)
69
- );
87
+ :host(:not([active]):not([disabled])) #button:hover {
88
+ color: var(--uui-tab-text-hover, var(--uui-color-default-emphasis,#3544b1));
70
89
  }
71
90
 
72
- :host(:not([active]):not([disabled])) button:active {
91
+ :host(:not([active]):not([disabled])) #button:active {
73
92
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),
74
93
  0 1px 2px rgba(0, 0, 0, 0.05);
75
94
  }
76
95
 
77
- :host([active]) button {
78
- color: var(
79
- --uui-tab-text-active,
80
- var(--uui-color-default-emphasis, white)
81
- );
96
+ :host([active]) #button {
82
97
  cursor: default;
83
98
  }
84
- :host([disabled]) button {
99
+ :host([disabled]) #button {
85
100
  color: var(--uui-color-disabled-contrast,#c4c4c4);
86
101
  cursor: default;
87
102
  }
88
103
 
89
- button::before {
104
+ #button::before {
90
105
  content: '';
91
106
  position: absolute;
92
107
  height: 0px;
@@ -100,20 +115,21 @@ UUITabElement.styles = [
100
115
  opacity: 0;
101
116
  transition: opacity ease-in 120ms, height ease-in 120ms;
102
117
  }
103
- button:hover::before {
118
+ #button:hover::before {
104
119
  background-color: var(--uui-color-current-emphasis,rgb(248, 214, 211));
105
120
  }
106
- :host([active]) button::before {
121
+ :host([active]) #button::before {
107
122
  opacity: 1;
108
123
  height: 4px;
109
124
  transition: opacity 120ms, height ease-out 120ms;
110
125
  }
111
126
 
112
- :host([disabled]) button::before {
127
+ :host([disabled]) #button::before {
113
128
  background-color: var(--uui-color-disabled-standalone,rgb(226, 226, 226));
114
129
  }
115
130
 
116
- ::slotted(uui-icon) {
131
+ slot[name='icon']::slotted(*) {
132
+ font-size: 20px;
117
133
  margin-bottom: var(--uui-size-2,6px);
118
134
  }
119
135
  `
@@ -121,6 +137,12 @@ UUITabElement.styles = [
121
137
  __decorateClass$1([
122
138
  property({ type: Boolean, reflect: true })
123
139
  ], UUITabElement.prototype, "disabled", 2);
140
+ __decorateClass$1([
141
+ property({ type: String })
142
+ ], UUITabElement.prototype, "href", 2);
143
+ __decorateClass$1([
144
+ property({ type: String })
145
+ ], UUITabElement.prototype, "target", 2);
124
146
  UUITabElement = __decorateClass$1([
125
147
  defineElement("uui-tab")
126
148
  ], UUITabElement);
@@ -139,33 +161,33 @@ var __decorateClass = (decorators, target, key, kind) => {
139
161
  let UUITabGroupElement = class extends LitElement {
140
162
  constructor() {
141
163
  super(...arguments);
142
- this.tabElements = [];
143
- this.onTabActive = (e) => {
164
+ this._tabElements = [];
165
+ this._onTabActive = (e) => {
144
166
  const selectedElement = e.currentTarget;
145
- if (this.elementIsTabLike(selectedElement)) {
167
+ if (this._elementIsTabLike(selectedElement)) {
146
168
  selectedElement.active = true;
147
169
  }
148
- const filtered = this.tabElements.filter((el) => el !== selectedElement);
170
+ const filtered = this._tabElements.filter((el) => el !== selectedElement);
149
171
  filtered.forEach((el) => {
150
- if (this.elementIsTabLike(el)) {
172
+ if (this._elementIsTabLike(el)) {
151
173
  el.active = false;
152
174
  }
153
175
  });
154
176
  };
155
177
  }
156
- setTabArray() {
157
- this.tabElements = this.slotNodes ? this.slotNodes : [];
178
+ _setTabArray() {
179
+ this._tabElements = this._slottedNodes ? this._slottedNodes : [];
158
180
  }
159
- onSlotChange() {
160
- this.tabElements.forEach((el) => {
161
- el.removeEventListener("click", this.onTabActive);
181
+ _onSlotChange() {
182
+ this._tabElements.forEach((el) => {
183
+ el.removeEventListener("click", this._onTabActive);
162
184
  });
163
- this.setTabArray();
164
- this.tabElements.forEach((el) => {
165
- el.addEventListener("click", this.onTabActive);
185
+ this._setTabArray();
186
+ this._tabElements.forEach((el) => {
187
+ el.addEventListener("click", this._onTabActive);
166
188
  });
167
189
  }
168
- elementIsTabLike(el) {
190
+ _elementIsTabLike(el) {
169
191
  return el instanceof UUITabElement || "active" in el;
170
192
  }
171
193
  connectedCallback() {
@@ -174,7 +196,7 @@ let UUITabGroupElement = class extends LitElement {
174
196
  this.setAttribute("role", "tablist");
175
197
  }
176
198
  render() {
177
- return html` <slot @slotchange=${this.onSlotChange}></slot> `;
199
+ return html` <slot @slotchange=${this._onSlotChange}></slot> `;
178
200
  }
179
201
  };
180
202
  UUITabGroupElement.styles = [
@@ -198,7 +220,7 @@ __decorateClass([
198
220
  flatten: true,
199
221
  selector: "uui-tab, [uui-tab], [role=tab]"
200
222
  })
201
- ], UUITabGroupElement.prototype, "slotNodes", 2);
223
+ ], UUITabGroupElement.prototype, "_slottedNodes", 2);
202
224
  UUITabGroupElement = __decorateClass([
203
225
  defineElement("uui-tab-group")
204
226
  ], 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 slotNodes?;
9
- private tabElements;
10
- private setTabArray;
11
- private onSlotChange;
12
- private onTabActive;
13
- private elementIsTabLike;
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
  }
@@ -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-alpha.0",
3
+ "version": "1.0.0-rc.0",
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-alpha.0"
33
+ "@umbraco-ui/uui-base": "1.0.0-rc.0"
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": "7d7608bf2fb63a8a077fcd8f0346dea73584b878"
44
+ "gitHead": "b03d833ef438156f3e87d3ffa29a4dcca7d560cd"
45
45
  }