@momentum-design/components 0.112.1 → 0.112.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/dist/browser/index.js +525 -360
- package/dist/browser/index.js.map +4 -4
- package/dist/components/buttonlink/buttonlink.component.d.ts +5 -0
- package/dist/components/buttonlink/buttonlink.component.js +37 -6
- package/dist/components/buttonlink/buttonlink.styles.d.ts +2 -0
- package/dist/components/buttonlink/buttonlink.styles.js +58 -0
- package/dist/components/link/link.component.d.ts +3 -0
- package/dist/components/link/link.component.js +28 -3
- package/dist/components/link/link.styles.js +15 -13
- package/dist/components/linkbutton/linkbutton.component.js +2 -2
- package/dist/components/linkbutton/linkbutton.styles.js +39 -2
- package/dist/components/linksimple/linksimple.component.d.ts +24 -6
- package/dist/components/linksimple/linksimple.component.js +49 -19
- package/dist/components/linksimple/linksimple.styles.js +41 -28
- package/dist/custom-elements.json +2130 -1738
- package/dist/react/buttonlink/index.d.ts +5 -0
- package/dist/react/buttonlink/index.js +5 -0
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +3 -3
- package/dist/react/link/index.d.ts +3 -0
- package/dist/react/link/index.js +3 -0
- package/dist/react/linksimple/index.d.ts +2 -0
- package/dist/react/linksimple/index.js +2 -0
- package/package.json +1 -1
@@ -22,6 +22,11 @@ declare const ButtonLink_base: import("../../utils/mixins/index.types").Construc
|
|
22
22
|
* @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
|
23
23
|
* @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
|
24
24
|
*
|
25
|
+
* @csspart anchor - The anchor element that wraps the buttonlink content.
|
26
|
+
* @csspart prefix-icon - The prefix icon element.
|
27
|
+
* @csspart button-text - The slot containing the buttonlink text.
|
28
|
+
* @csspart postfix-icon - The postfix icon element.
|
29
|
+
*
|
25
30
|
*/
|
26
31
|
declare class ButtonLink extends ButtonLink_base {
|
27
32
|
/**
|
@@ -9,10 +9,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
};
|
10
10
|
import { html } from 'lit';
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
12
13
|
import Button from '../button/button.component';
|
13
14
|
import { ButtonComponentMixin } from '../../utils/mixins/ButtonComponentMixin';
|
14
15
|
import { DEFAULTS } from '../button/button.constants';
|
15
16
|
import Linksimple from '../linksimple/linksimple.component';
|
17
|
+
import styles from './buttonlink.styles';
|
16
18
|
/**
|
17
19
|
* `mdc-buttonlink` combines the functional behavior of `mdc-linksimple` with the visual and structural
|
18
20
|
* features of `mdc-button`. This includes support for variants, sizing, and optional
|
@@ -33,6 +35,11 @@ import Linksimple from '../linksimple/linksimple.component';
|
|
33
35
|
* @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
|
34
36
|
* @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
|
35
37
|
*
|
38
|
+
* @csspart anchor - The anchor element that wraps the buttonlink content.
|
39
|
+
* @csspart prefix-icon - The prefix icon element.
|
40
|
+
* @csspart button-text - The slot containing the buttonlink text.
|
41
|
+
* @csspart postfix-icon - The postfix icon element.
|
42
|
+
*
|
36
43
|
*/
|
37
44
|
class ButtonLink extends ButtonComponentMixin(Linksimple) {
|
38
45
|
constructor() {
|
@@ -85,18 +92,42 @@ class ButtonLink extends ButtonComponentMixin(Linksimple) {
|
|
85
92
|
}
|
86
93
|
}
|
87
94
|
render() {
|
95
|
+
var _a;
|
88
96
|
return html `
|
89
|
-
|
90
|
-
|
97
|
+
<a
|
98
|
+
class="mdc-focus-ring"
|
99
|
+
part="anchor"
|
100
|
+
href="${this.href}"
|
101
|
+
target="${this.target}"
|
102
|
+
rel="${ifDefined(this.rel)}"
|
103
|
+
download="${ifDefined(this.download)}"
|
104
|
+
ping="${ifDefined(this.ping)}"
|
105
|
+
hreflang="${ifDefined(this.hreflang)}"
|
106
|
+
type="${ifDefined(this.type)}"
|
107
|
+
referrerpolicy="${ifDefined(this.referrerpolicy)}"
|
108
|
+
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
109
|
+
tabindex="${this.disabled ? -1 : 0}"
|
110
|
+
>
|
111
|
+
${this.prefixIcon
|
112
|
+
? html `<mdc-icon
|
113
|
+
name="${this.prefixIcon}"
|
114
|
+
part="prefix-icon"
|
115
|
+
length-unit="rem"
|
116
|
+
></mdc-icon>`
|
91
117
|
: ''}
|
92
|
-
|
93
|
-
|
94
|
-
? html
|
118
|
+
<slot @slotchange="${this.inferButtonType}" part="button-text"></slot>
|
119
|
+
${this.postfixIcon
|
120
|
+
? html `<mdc-icon
|
121
|
+
name="${this.postfixIcon}"
|
122
|
+
part="postfix-icon"
|
123
|
+
length-unit="rem"
|
124
|
+
></mdc-icon>`
|
95
125
|
: ''}
|
126
|
+
</a>
|
96
127
|
`;
|
97
128
|
}
|
98
129
|
}
|
99
|
-
ButtonLink.styles = [...Button.styles];
|
130
|
+
ButtonLink.styles = [...Button.styles, ...styles];
|
100
131
|
__decorate([
|
101
132
|
property({ type: Number, reflect: true }),
|
102
133
|
__metadata("design:type", Number)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFocusRingStyles } from '../../utils/styles';
|
3
|
+
const styles = css `
|
4
|
+
:host {
|
5
|
+
border: unset;
|
6
|
+
}
|
7
|
+
|
8
|
+
:host([data-btn-type='pill']),
|
9
|
+
:host([data-btn-type='pill-with-icon']) {
|
10
|
+
padding: unset;
|
11
|
+
}
|
12
|
+
|
13
|
+
:host([data-btn-type='pill'][size='24'])::part(anchor),
|
14
|
+
:host([data-btn-type='pill-with-icon'][size='24'])::part(anchor) {
|
15
|
+
padding: 0 0.625rem;
|
16
|
+
}
|
17
|
+
|
18
|
+
:host([data-btn-type='pill'][size='32'])::part(anchor),
|
19
|
+
:host([data-btn-type='pill-with-icon'][size='32'])::part(anchor),
|
20
|
+
:host([data-btn-type='pill'][size='28'])::part(anchor),
|
21
|
+
:host([data-btn-type='pill-with-icon'][size='28'])::part(anchor) {
|
22
|
+
padding: 0 0.75rem;
|
23
|
+
}
|
24
|
+
|
25
|
+
:host([data-btn-type='pill'][size='40'])::part(anchor),
|
26
|
+
:host([data-btn-type='pill-with-icon'][size='40'])::part(anchor) {
|
27
|
+
padding: 0 1rem;
|
28
|
+
}
|
29
|
+
|
30
|
+
:host([disabled]) {
|
31
|
+
cursor: auto;
|
32
|
+
pointer-events: none;
|
33
|
+
}
|
34
|
+
|
35
|
+
/* Anchor inside ButtonLink */
|
36
|
+
:host::part(anchor) {
|
37
|
+
color: inherit;
|
38
|
+
text-decoration: none;
|
39
|
+
display: inline-flex;
|
40
|
+
align-items: center;
|
41
|
+
justify-content: center;
|
42
|
+
gap: inherit;
|
43
|
+
height: 100%;
|
44
|
+
width: 100%;
|
45
|
+
border-radius: inherit;
|
46
|
+
border: 1px solid transparent;
|
47
|
+
}
|
48
|
+
|
49
|
+
:host([variant='secondary'])::part(anchor) {
|
50
|
+
border-color: var(--mdc-button-secondary-border-color);
|
51
|
+
}
|
52
|
+
|
53
|
+
:host([variant='secondary'][disabled])::part(anchor),
|
54
|
+
:host([variant='secondary'][soft-disabled])::part(anchor) {
|
55
|
+
border-color: var(--mdc-button-secondary-disabled-border-color);
|
56
|
+
}
|
57
|
+
`;
|
58
|
+
export default [styles, ...hostFocusRingStyles(true)];
|
@@ -19,6 +19,9 @@ declare const Link_base: import("../../utils/mixins/index.types").Constructor<im
|
|
19
19
|
* @event keydown - (React: onKeyDown) Fired when the user presses a key while the Link has focus.
|
20
20
|
* @event focus - (React: onFocus) Fired when the Link receives keyboard or mouse focus.
|
21
21
|
* @event blur - (React: onBlur) Fired when the Link loses keyboard or mouse focus.
|
22
|
+
*
|
23
|
+
* @csspart anchor - The anchor element that wraps the link content.
|
24
|
+
* @csspart icon - The icon element.
|
22
25
|
*/
|
23
26
|
declare class Link extends Link_base {
|
24
27
|
/**
|
@@ -9,6 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
};
|
10
10
|
import { html, nothing } from 'lit';
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
12
13
|
import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
13
14
|
import Linksimple from '../linksimple/linksimple.component';
|
14
15
|
import { DEFAULTS, LINK_ICON_SIZES, LINK_SIZES } from './link.constants';
|
@@ -30,6 +31,9 @@ import styles from './link.styles';
|
|
30
31
|
* @event keydown - (React: onKeyDown) Fired when the user presses a key while the Link has focus.
|
31
32
|
* @event focus - (React: onFocus) Fired when the Link receives keyboard or mouse focus.
|
32
33
|
* @event blur - (React: onBlur) Fired when the Link loses keyboard or mouse focus.
|
34
|
+
*
|
35
|
+
* @csspart anchor - The anchor element that wraps the link content.
|
36
|
+
* @csspart icon - The icon element.
|
33
37
|
*/
|
34
38
|
class Link extends IconNameMixin(Linksimple) {
|
35
39
|
constructor() {
|
@@ -61,11 +65,32 @@ class Link extends IconNameMixin(Linksimple) {
|
|
61
65
|
}
|
62
66
|
}
|
63
67
|
render() {
|
68
|
+
var _a;
|
64
69
|
return html `
|
65
|
-
<
|
66
|
-
|
67
|
-
|
70
|
+
<a
|
71
|
+
class="mdc-focus-ring"
|
72
|
+
part="anchor"
|
73
|
+
href="${this.href}"
|
74
|
+
target="${this.target}"
|
75
|
+
rel="${ifDefined(this.rel)}"
|
76
|
+
download="${ifDefined(this.download)}"
|
77
|
+
ping="${ifDefined(this.ping)}"
|
78
|
+
hreflang="${ifDefined(this.hreflang)}"
|
79
|
+
type="${ifDefined(this.type)}"
|
80
|
+
referrerpolicy="${ifDefined(this.referrerpolicy)}"
|
81
|
+
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
82
|
+
tabindex="${this.disabled ? -1 : 0}"
|
83
|
+
>
|
84
|
+
<slot></slot>
|
85
|
+
${this.iconName
|
86
|
+
? html `<mdc-icon
|
87
|
+
part="icon"
|
88
|
+
name="${this.iconName}"
|
89
|
+
size="${this.getIconSize()}"
|
90
|
+
length-unit="rem"
|
91
|
+
></mdc-icon>`
|
68
92
|
: nothing}
|
93
|
+
</a>
|
69
94
|
`;
|
70
95
|
}
|
71
96
|
}
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { css } from 'lit';
|
2
2
|
const styles = css `
|
3
|
-
:host {
|
3
|
+
:host::part(anchor) {
|
4
|
+
display: flex;
|
5
|
+
align-items: center;
|
4
6
|
gap: 0.25rem;
|
5
7
|
}
|
6
8
|
|
7
|
-
:host([size='large']) {
|
9
|
+
:host([size='large'])::part(anchor) {
|
8
10
|
font-size: var(--mds-font-apps-body-large-regular-font-size);
|
9
11
|
font-weight: var(--mds-font-apps-body-large-regular-font-weight);
|
10
12
|
line-height: var(--mds-font-apps-body-large-regular-line-height);
|
@@ -12,7 +14,7 @@ const styles = css `
|
|
12
14
|
text-transform: var(--mds-font-apps-body-large-regular-text-case);
|
13
15
|
}
|
14
16
|
|
15
|
-
:host([size='midsize']) {
|
17
|
+
:host([size='midsize'])::part(anchor) {
|
16
18
|
font-size: var(--mds-font-apps-body-midsize-regular-font-size);
|
17
19
|
font-weight: var(--mds-font-apps-body-midsize-regular-font-weight);
|
18
20
|
line-height: var(--mds-font-apps-body-midsize-regular-line-height);
|
@@ -20,7 +22,7 @@ const styles = css `
|
|
20
22
|
text-transform: var(--mds-font-apps-body-midsize-regular-text-case);
|
21
23
|
}
|
22
24
|
|
23
|
-
:host([size='small']) {
|
25
|
+
:host([size='small'])::part(anchor) {
|
24
26
|
font-size: var(--mds-font-apps-body-small-regular-font-size);
|
25
27
|
font-weight: var(--mds-font-apps-body-small-regular-font-weight);
|
26
28
|
line-height: var(--mds-font-apps-body-small-regular-line-height);
|
@@ -28,9 +30,9 @@ const styles = css `
|
|
28
30
|
text-transform: var(--mds-font-apps-body-small-regular-text-case);
|
29
31
|
}
|
30
32
|
|
31
|
-
:host([size='large']:hover),
|
32
|
-
:host([size='large']:active),
|
33
|
-
:host([size='large'][inline]) {
|
33
|
+
:host([size='large']:hover)::part(anchor),
|
34
|
+
:host([size='large']:active)::part(anchor),
|
35
|
+
:host([size='large'][inline])::part(anchor) {
|
34
36
|
font-size: var(--mds-font-apps-body-large-regular-underline-font-size);
|
35
37
|
font-weight: var(--mds-font-apps-body-large-regular-underline-font-weight);
|
36
38
|
line-height: var(--mds-font-apps-body-large-regular-underline-line-height);
|
@@ -38,9 +40,9 @@ const styles = css `
|
|
38
40
|
text-transform: var(--mds-font-apps-body-large-regular-underline-text-case);
|
39
41
|
}
|
40
42
|
|
41
|
-
:host([size='midsize']:hover),
|
42
|
-
:host([size='midsize']:active),
|
43
|
-
:host([size='midsize'][inline]) {
|
43
|
+
:host([size='midsize']:hover)::part(anchor),
|
44
|
+
:host([size='midsize']:active)::part(anchor),
|
45
|
+
:host([size='midsize'][inline])::part(anchor) {
|
44
46
|
font-size: var(--mds-font-apps-body-midsize-regular-underline-font-size);
|
45
47
|
font-weight: var(--mds-font-apps-body-midsize-regular-underline-font-weight);
|
46
48
|
line-height: var(--mds-font-apps-body-midsize-regular-underline-line-height);
|
@@ -48,9 +50,9 @@ const styles = css `
|
|
48
50
|
text-transform: var(--mds-font-apps-body-midsize-regular-underline-text-case);
|
49
51
|
}
|
50
52
|
|
51
|
-
:host([size='small']:hover),
|
52
|
-
:host([size='small']:active),
|
53
|
-
:host([size='small'][inline]) {
|
53
|
+
:host([size='small']:hover)::part(anchor),
|
54
|
+
:host([size='small']:active)::part(anchor),
|
55
|
+
:host([size='small'][inline])::part(anchor) {
|
54
56
|
font-size: var(--mds-font-apps-body-small-regular-underline-font-size);
|
55
57
|
font-weight: var(--mds-font-apps-body-small-regular-underline-font-weight);
|
56
58
|
line-height: var(--mds-font-apps-body-small-regular-underline-line-height);
|
@@ -11,7 +11,7 @@ import { html, nothing } from 'lit';
|
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
13
13
|
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
14
|
-
import
|
14
|
+
import Linksimple from '../linksimple/linksimple.component';
|
15
15
|
import { DEFAULTS, LINKBUTTON_SIZES } from './linkbutton.constants';
|
16
16
|
import { getIconSize } from './linkbutton.utils';
|
17
17
|
import styles from './linkbutton.styles';
|
@@ -95,7 +95,7 @@ class LinkButton extends IconNameMixin(Buttonsimple) {
|
|
95
95
|
`;
|
96
96
|
}
|
97
97
|
}
|
98
|
-
LinkButton.styles = [...
|
98
|
+
LinkButton.styles = [...Linksimple.styles, ...styles];
|
99
99
|
__decorate([
|
100
100
|
property({ type: Number, reflect: true }),
|
101
101
|
__metadata("design:type", Number)
|
@@ -1,8 +1,18 @@
|
|
1
1
|
import { css } from 'lit';
|
2
|
+
import { hostFocusRingStyles } from '../../utils/styles';
|
2
3
|
const styles = css `
|
3
4
|
:host {
|
4
|
-
--mdc-link-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
5
5
|
gap: 0.25rem;
|
6
|
+
cursor: pointer;
|
7
|
+
text-decoration: none;
|
8
|
+
outline: none;
|
9
|
+
display: inline-flex;
|
10
|
+
align-items: center;
|
11
|
+
color: var(--mdc-link-color-normal);
|
12
|
+
}
|
13
|
+
|
14
|
+
:host([inverted]) {
|
15
|
+
color: var(--mdc-link-inverted-color-normal);
|
6
16
|
}
|
7
17
|
|
8
18
|
:host([size='16']) {
|
@@ -59,8 +69,35 @@ const styles = css `
|
|
59
69
|
text-transform: var(--mds-font-apps-body-small-regular-underline-text-case);
|
60
70
|
}
|
61
71
|
|
72
|
+
:host(:not([disabled]):hover) {
|
73
|
+
color: var(--mdc-link-color-hover);
|
74
|
+
}
|
75
|
+
|
76
|
+
:host(:not([disabled]):active) {
|
77
|
+
color: var(--mdc-link-color-active);
|
78
|
+
}
|
79
|
+
|
80
|
+
:host([inverted]:not([disabled]):hover) {
|
81
|
+
color: var(--mdc-link-inverted-color-hover);
|
82
|
+
}
|
83
|
+
|
84
|
+
:host([inverted]:not([disabled]):active) {
|
85
|
+
color: var(--mdc-link-inverted-color-active);
|
86
|
+
}
|
87
|
+
|
88
|
+
:host([disabled]) {
|
89
|
+
color: var(--mdc-link-color-disabled);
|
90
|
+
pointer-events: none;
|
91
|
+
text-decoration: none;
|
92
|
+
}
|
93
|
+
|
94
|
+
:host([inverted][disabled]) {
|
95
|
+
color: var(--mdc-link-inverted-color-disabled);
|
96
|
+
}
|
97
|
+
|
62
98
|
:host([soft-disabled]) {
|
63
99
|
color: var(--mdc-link-color-disabled);
|
100
|
+
pointer-events: none;
|
64
101
|
}
|
65
102
|
`;
|
66
|
-
export default [styles];
|
103
|
+
export default [styles, ...hostFocusRingStyles()];
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { PropertyValues, CSSResult } from 'lit';
|
2
2
|
import { Component } from '../../models';
|
3
|
-
declare const Linksimple_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/
|
3
|
+
declare const Linksimple_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
|
4
4
|
/**
|
5
5
|
* `mdc-linksimple` is a lightweight link component that can be used to navigate
|
6
6
|
* within the application or to an external URL. It does not have any predefined default size.
|
@@ -25,6 +25,8 @@ declare const Linksimple_base: import("../../utils/mixins/index.types").Construc
|
|
25
25
|
* @cssproperty --mdc-link-inverted-color-disabled - Color of the inverted link’s child content in the disabled state.
|
26
26
|
* @cssproperty --mdc-link-inverted-color-hover - Color of the inverted link’s child content in the hover state.
|
27
27
|
* @cssproperty --mdc-link-inverted-color-normal - Color of the inverted link’s child content in the normal state.
|
28
|
+
*
|
29
|
+
* @csspart anchor - The anchor element that wraps the linksimple content.
|
28
30
|
*/
|
29
31
|
declare class Linksimple extends Linksimple_base {
|
30
32
|
/**
|
@@ -39,10 +41,12 @@ declare class Linksimple extends Linksimple_base {
|
|
39
41
|
inverted: boolean;
|
40
42
|
/**
|
41
43
|
* Href for navigation. The URL that the hyperlink points to
|
44
|
+
* @default #
|
42
45
|
*/
|
43
46
|
href: string;
|
44
47
|
/**
|
45
48
|
* Optional target: _blank, _self, _parent, _top and _unfencedTop
|
49
|
+
* @default _self
|
46
50
|
*/
|
47
51
|
target: string;
|
48
52
|
/**
|
@@ -50,14 +54,28 @@ declare class Linksimple extends Linksimple_base {
|
|
50
54
|
*/
|
51
55
|
rel?: string;
|
52
56
|
/**
|
53
|
-
*
|
54
|
-
|
55
|
-
|
57
|
+
* Optional download attribute to instruct browsers to download the linked resource.
|
58
|
+
*/
|
59
|
+
download?: string;
|
60
|
+
/**
|
61
|
+
* Optional ping attribute that defines a space-separated list of URLs to be notified if the link is followed.
|
62
|
+
*/
|
63
|
+
ping?: string;
|
64
|
+
/**
|
65
|
+
* Optional hreflang attribute specifying the language of the linked resource.
|
66
|
+
*/
|
67
|
+
hreflang?: string;
|
68
|
+
/**
|
69
|
+
* Optional type attribute indicating the MIME type of the linked resource.
|
70
|
+
*/
|
71
|
+
type?: string;
|
72
|
+
/**
|
73
|
+
* Optional referrerpolicy attribute specifying how much referrer information to send.
|
56
74
|
*/
|
57
|
-
|
75
|
+
referrerpolicy?: string;
|
58
76
|
connectedCallback(): void;
|
59
77
|
disconnectedCallback(): void;
|
60
|
-
|
78
|
+
protected handleNavigation(e: MouseEvent | KeyboardEvent): void;
|
61
79
|
/**
|
62
80
|
* Sets or removes `aria-disabled` and updates `tabIndex` to reflect
|
63
81
|
* the disabled state. When disabled, the element becomes unfocusable;
|
@@ -9,9 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
};
|
10
10
|
import { html } from 'lit';
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
12
13
|
import { Component } from '../../models';
|
14
|
+
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
13
15
|
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
14
|
-
import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
|
15
16
|
import { DEFAULTS } from './linksimple.constants';
|
16
17
|
import styles from './linksimple.styles';
|
17
18
|
/**
|
@@ -38,8 +39,10 @@ import styles from './linksimple.styles';
|
|
38
39
|
* @cssproperty --mdc-link-inverted-color-disabled - Color of the inverted link’s child content in the disabled state.
|
39
40
|
* @cssproperty --mdc-link-inverted-color-hover - Color of the inverted link’s child content in the hover state.
|
40
41
|
* @cssproperty --mdc-link-inverted-color-normal - Color of the inverted link’s child content in the normal state.
|
42
|
+
*
|
43
|
+
* @csspart anchor - The anchor element that wraps the linksimple content.
|
41
44
|
*/
|
42
|
-
class Linksimple extends DisabledMixin(
|
45
|
+
class Linksimple extends DataAriaLabelMixin(DisabledMixin(Component)) {
|
43
46
|
constructor() {
|
44
47
|
super(...arguments);
|
45
48
|
/**
|
@@ -54,22 +57,17 @@ class Linksimple extends DisabledMixin(TabIndexMixin(Component)) {
|
|
54
57
|
this.inverted = DEFAULTS.INVERTED;
|
55
58
|
/**
|
56
59
|
* Href for navigation. The URL that the hyperlink points to
|
60
|
+
* @default #
|
57
61
|
*/
|
58
62
|
this.href = '#';
|
59
63
|
/**
|
60
64
|
* Optional target: _blank, _self, _parent, _top and _unfencedTop
|
65
|
+
* @default _self
|
61
66
|
*/
|
62
67
|
this.target = '_self';
|
63
|
-
/**
|
64
|
-
* Stores the previous tabindex if set by user
|
65
|
-
* so it can be restored after disabling
|
66
|
-
* @internal
|
67
|
-
*/
|
68
|
-
this.prevTabindex = 0;
|
69
68
|
}
|
70
69
|
connectedCallback() {
|
71
70
|
super.connectedCallback();
|
72
|
-
this.setAttribute('role', 'link');
|
73
71
|
this.addEventListener('click', this.handleNavigation.bind(this));
|
74
72
|
this.addEventListener('keydown', this.handleNavigation.bind(this));
|
75
73
|
}
|
@@ -79,10 +77,9 @@ class Linksimple extends DisabledMixin(TabIndexMixin(Component)) {
|
|
79
77
|
this.removeEventListener('keydown', this.handleNavigation.bind(this));
|
80
78
|
}
|
81
79
|
handleNavigation(e) {
|
82
|
-
if (
|
83
|
-
|
84
|
-
|
85
|
-
window.open(this.href, this.target, this.rel);
|
80
|
+
if (this.disabled) {
|
81
|
+
e.preventDefault();
|
82
|
+
e.stopImmediatePropagation();
|
86
83
|
}
|
87
84
|
}
|
88
85
|
/**
|
@@ -95,13 +92,8 @@ class Linksimple extends DisabledMixin(TabIndexMixin(Component)) {
|
|
95
92
|
setDisabled(disabled) {
|
96
93
|
if (disabled) {
|
97
94
|
this.setAttribute('aria-disabled', 'true');
|
98
|
-
this.prevTabindex = this.tabIndex;
|
99
|
-
this.tabIndex = -1;
|
100
95
|
}
|
101
96
|
else {
|
102
|
-
if (this.tabIndex === -1) {
|
103
|
-
this.tabIndex = this.prevTabindex;
|
104
|
-
}
|
105
97
|
this.removeAttribute('aria-disabled');
|
106
98
|
}
|
107
99
|
}
|
@@ -112,7 +104,25 @@ class Linksimple extends DisabledMixin(TabIndexMixin(Component)) {
|
|
112
104
|
}
|
113
105
|
}
|
114
106
|
render() {
|
115
|
-
|
107
|
+
var _a;
|
108
|
+
return html `
|
109
|
+
<a
|
110
|
+
class='mdc-focus-ring'
|
111
|
+
part="anchor"
|
112
|
+
href="${this.href}"
|
113
|
+
target="${this.target}"
|
114
|
+
rel="${ifDefined(this.rel)}"
|
115
|
+
download="${ifDefined(this.download)}"
|
116
|
+
ping="${ifDefined(this.ping)}"
|
117
|
+
hreflang="${ifDefined(this.hreflang)}"
|
118
|
+
type="${ifDefined(this.type)}"
|
119
|
+
referrerpolicy="${ifDefined(this.referrerpolicy)}"
|
120
|
+
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
121
|
+
tabindex="${this.disabled ? -1 : 0}"
|
122
|
+
>
|
123
|
+
<slot></slot>
|
124
|
+
</a>
|
125
|
+
`;
|
116
126
|
}
|
117
127
|
}
|
118
128
|
Linksimple.styles = [...Component.styles, ...styles];
|
@@ -136,4 +146,24 @@ __decorate([
|
|
136
146
|
property({ type: String, reflect: true }),
|
137
147
|
__metadata("design:type", String)
|
138
148
|
], Linksimple.prototype, "rel", void 0);
|
149
|
+
__decorate([
|
150
|
+
property({ type: String, reflect: true }),
|
151
|
+
__metadata("design:type", String)
|
152
|
+
], Linksimple.prototype, "download", void 0);
|
153
|
+
__decorate([
|
154
|
+
property({ type: String, reflect: true }),
|
155
|
+
__metadata("design:type", String)
|
156
|
+
], Linksimple.prototype, "ping", void 0);
|
157
|
+
__decorate([
|
158
|
+
property({ type: String, reflect: true }),
|
159
|
+
__metadata("design:type", String)
|
160
|
+
], Linksimple.prototype, "hreflang", void 0);
|
161
|
+
__decorate([
|
162
|
+
property({ type: String, reflect: true }),
|
163
|
+
__metadata("design:type", String)
|
164
|
+
], Linksimple.prototype, "type", void 0);
|
165
|
+
__decorate([
|
166
|
+
property({ type: String, reflect: true }),
|
167
|
+
__metadata("design:type", String)
|
168
|
+
], Linksimple.prototype, "referrerpolicy", void 0);
|
139
169
|
export default Linksimple;
|
@@ -15,60 +15,73 @@ const styles = [
|
|
15
15
|
--mdc-link-inverted-color-normal: var(--mds-color-theme-inverted-text-accent-normal);
|
16
16
|
|
17
17
|
border-radius: var(--mdc-link-border-radius);
|
18
|
-
color: var(--mdc-link-color-normal);
|
19
|
-
text-underline-offset: auto;
|
20
|
-
text-underline-position: from-font;
|
21
18
|
cursor: pointer;
|
22
|
-
|
23
|
-
/* based on default linksimple size (large) */
|
24
19
|
line-height: var(--mds-font-apps-body-large-regular-line-height);
|
20
|
+
text-underline-offset: auto;
|
21
|
+
text-underline-position: from-font;
|
25
22
|
}
|
26
23
|
|
27
24
|
:host([inline]) {
|
28
25
|
display: inline-flex;
|
29
26
|
}
|
30
27
|
|
31
|
-
|
28
|
+
/* Base anchor styles */
|
29
|
+
:host::part(anchor) {
|
30
|
+
color: var(--mdc-link-color-normal);
|
31
|
+
font-size: var(--mds-font-apps-body-large-regular-underline-font-size);
|
32
|
+
font-weight: var(--mds-font-apps-body-large-regular-underline-font-weight);
|
33
|
+
line-height: var(--mds-font-apps-body-large-regular-underline-line-height);
|
34
|
+
text-transform: var(--mds-font-apps-body-large-regular-underline-text-case);
|
35
|
+
border-radius: var(--mdc-link-border-radius);
|
36
|
+
outline: none;
|
37
|
+
text-decoration: none; /* Prevent default underline */
|
38
|
+
}
|
39
|
+
|
40
|
+
/* Inverted color base */
|
41
|
+
:host([inverted])::part(anchor) {
|
32
42
|
color: var(--mdc-link-inverted-color-normal);
|
33
43
|
}
|
34
44
|
|
35
|
-
|
45
|
+
/* Disabled state */
|
46
|
+
:host([disabled])::part(anchor),
|
47
|
+
:host([disabled]) {
|
48
|
+
color: var(--mdc-link-color-disabled);
|
49
|
+
pointer-events: none;
|
50
|
+
text-decoration: none;
|
51
|
+
}
|
52
|
+
|
53
|
+
:host([inverted][disabled])::part(anchor) {
|
54
|
+
color: var(--mdc-link-inverted-color-disabled);
|
55
|
+
}
|
56
|
+
|
57
|
+
/* Hover and active states for enabled links */
|
58
|
+
:host(:not([disabled]):hover)::part(anchor) {
|
36
59
|
color: var(--mdc-link-color-hover);
|
60
|
+
text-decoration: var(--mds-font-apps-body-large-regular-underline-text-decoration);
|
37
61
|
}
|
38
62
|
|
39
|
-
:host(:active) {
|
63
|
+
:host(:not([disabled]):active)::part(anchor) {
|
40
64
|
color: var(--mdc-link-color-active);
|
41
65
|
box-shadow: none;
|
66
|
+
text-decoration: var(--mds-font-apps-body-large-regular-underline-text-decoration);
|
42
67
|
}
|
43
68
|
|
44
|
-
|
69
|
+
/* Inverted variants hover & active */
|
70
|
+
:host([inverted]:not([disabled]):hover)::part(anchor) {
|
45
71
|
color: var(--mdc-link-inverted-color-hover);
|
72
|
+
text-decoration: var(--mds-font-apps-body-large-regular-underline-text-decoration);
|
46
73
|
}
|
47
74
|
|
48
|
-
:host([inverted]:active) {
|
75
|
+
:host([inverted]:not([disabled]):active)::part(anchor) {
|
49
76
|
color: var(--mdc-link-inverted-color-active);
|
77
|
+
text-decoration: var(--mds-font-apps-body-large-regular-underline-text-decoration);
|
50
78
|
}
|
51
79
|
|
52
|
-
|
53
|
-
|
54
|
-
pointer-events: none;
|
55
|
-
}
|
56
|
-
|
57
|
-
:host([inverted][disabled]) {
|
58
|
-
color: var(--mdc-link-inverted-color-disabled);
|
59
|
-
}
|
60
|
-
|
61
|
-
/* based on default linksimple size (large) */
|
62
|
-
:host(:hover),
|
63
|
-
:host(:active),
|
64
|
-
:host([inline]) {
|
65
|
-
font-size: var(--mds-font-apps-body-large-regular-underline-font-size);
|
66
|
-
font-weight: var(--mds-font-apps-body-large-regular-underline-font-weight);
|
67
|
-
line-height: var(--mds-font-apps-body-large-regular-underline-line-height);
|
80
|
+
/* Inline variant always shows underline */
|
81
|
+
:host([inline])::part(anchor) {
|
68
82
|
text-decoration: var(--mds-font-apps-body-large-regular-underline-text-decoration);
|
69
|
-
text-transform: var(--mds-font-apps-body-large-regular-underline-text-case);
|
70
83
|
}
|
71
84
|
`,
|
72
|
-
...hostFocusRingStyles(),
|
85
|
+
...hostFocusRingStyles(true),
|
73
86
|
];
|
74
87
|
export default styles;
|