@momentum-design/components 0.53.8 → 0.54.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.
- package/dist/browser/index.js +433 -406
- package/dist/browser/index.js.map +4 -4
- package/dist/components/checkbox/checkbox.component.d.ts +1 -9
- package/dist/components/checkbox/checkbox.component.js +7 -21
- package/dist/components/checkbox/checkbox.styles.js +30 -67
- package/dist/components/checkbox/index.d.ts +1 -0
- package/dist/components/checkbox/index.js +1 -0
- package/dist/components/link/link.component.d.ts +29 -18
- package/dist/components/link/link.component.js +67 -39
- package/dist/components/link/link.styles.js +34 -48
- package/dist/components/link/link.types.d.ts +7 -1
- package/dist/components/radio/index.d.ts +1 -0
- package/dist/components/radio/index.js +1 -0
- package/dist/components/radio/radio.component.d.ts +3 -11
- package/dist/components/radio/radio.component.js +10 -16
- package/dist/components/radio/radio.styles.js +36 -111
- package/dist/components/staticcheckbox/index.d.ts +8 -0
- package/dist/components/staticcheckbox/index.js +5 -0
- package/dist/components/staticcheckbox/staticcheckbox.component.d.ts +42 -0
- package/dist/components/staticcheckbox/staticcheckbox.component.js +76 -0
- package/dist/components/staticcheckbox/staticcheckbox.constants.d.ts +3 -0
- package/dist/components/staticcheckbox/staticcheckbox.constants.js +4 -0
- package/dist/components/staticcheckbox/staticcheckbox.styles.d.ts +2 -0
- package/dist/components/staticcheckbox/staticcheckbox.styles.js +60 -0
- package/dist/components/staticradio/index.d.ts +7 -0
- package/dist/components/staticradio/index.js +4 -0
- package/dist/components/staticradio/staticradio.component.d.ts +41 -0
- package/dist/components/staticradio/staticradio.component.js +67 -0
- package/dist/components/staticradio/staticradio.constants.d.ts +2 -0
- package/dist/components/staticradio/staticradio.constants.js +3 -0
- package/dist/components/staticradio/staticradio.styles.d.ts +2 -0
- package/dist/components/staticradio/staticradio.styles.js +86 -0
- package/dist/custom-elements.json +1838 -1491
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/react/checkbox/index.d.ts +1 -9
- package/dist/react/checkbox/index.js +1 -9
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.js +4 -2
- package/dist/react/link/index.d.ts +13 -3
- package/dist/react/link/index.js +12 -3
- package/dist/react/radio/index.d.ts +3 -11
- package/dist/react/radio/index.js +3 -11
- package/dist/react/staticcheckbox/index.d.ts +25 -0
- package/dist/react/staticcheckbox/index.js +34 -0
- package/dist/react/staticradio/index.d.ts +24 -0
- package/dist/react/staticradio/index.js +33 -0
- package/package.json +1 -1
@@ -18,18 +18,10 @@ declare const Checkbox_base: import("../../utils/mixins/index.types").Constructo
|
|
18
18
|
* @event focus - (React: onFocus) Event that gets dispatched when the checkbox receives focus.
|
19
19
|
*
|
20
20
|
* @cssproperty --mdc-checkbox-background-color-hover - Allows customization of the background color on hover.
|
21
|
-
* @cssproperty --mdc-checkbox-border-color - Border color in high contrast.
|
22
|
-
* @cssproperty --mdc-checkbox-checked-background-color - Background color for a selected checkbox.
|
23
21
|
* @cssproperty --mdc-checkbox-checked-background-color-hover - Background color for a selected checkbox when hovered.
|
24
22
|
* @cssproperty --mdc-checkbox-checked-pressed-icon-color - Background color for a selected checkbox when pressed.
|
25
|
-
* @cssproperty --mdc-checkbox-disabled-background-color - Background color for a disabled checkbox.
|
26
|
-
* @cssproperty --mdc-checkbox-disabled-border-color - Border color for a disabled checkbox.
|
27
|
-
* @cssproperty --mdc-checkbox-disabled-checked-icon-color - Background color for a disabled, selected checkbox.
|
28
|
-
* @cssproperty --mdc-checkbox-disabled-icon-color - Icon color for a disabled checkbox.
|
29
|
-
* @cssproperty --mdc-checkbox-icon-background-color - Background color for an unselected checkbox.
|
30
|
-
* @cssproperty --mdc-checkbox-icon-border-color - Default background color for an unselected checkbox.
|
31
|
-
* @cssproperty --mdc-checkbox-icon-color - Icon color for an unselected checkbox.
|
32
23
|
* @cssproperty --mdc-checkbox-pressed-icon-color - Background color for a selected checkbox when pressed.
|
24
|
+
* @cssproperty --mdc-checkbox-disabled-checked-icon-color - Background color for a selected checkbox when disabled.
|
33
25
|
*/
|
34
26
|
declare class Checkbox extends Checkbox_base implements AssociatedFormControl {
|
35
27
|
/**
|
@@ -14,7 +14,6 @@ import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
|
14
14
|
import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
15
15
|
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
16
16
|
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
17
|
-
import { ICON_NAME } from './checkbox.constants';
|
18
17
|
import styles from './checkbox.styles';
|
19
18
|
/**
|
20
19
|
* Checkboxes allow users to select multiple options from a list or turn an item/feature on or off.
|
@@ -32,18 +31,10 @@ import styles from './checkbox.styles';
|
|
32
31
|
* @event focus - (React: onFocus) Event that gets dispatched when the checkbox receives focus.
|
33
32
|
*
|
34
33
|
* @cssproperty --mdc-checkbox-background-color-hover - Allows customization of the background color on hover.
|
35
|
-
* @cssproperty --mdc-checkbox-border-color - Border color in high contrast.
|
36
|
-
* @cssproperty --mdc-checkbox-checked-background-color - Background color for a selected checkbox.
|
37
34
|
* @cssproperty --mdc-checkbox-checked-background-color-hover - Background color for a selected checkbox when hovered.
|
38
35
|
* @cssproperty --mdc-checkbox-checked-pressed-icon-color - Background color for a selected checkbox when pressed.
|
39
|
-
* @cssproperty --mdc-checkbox-disabled-background-color - Background color for a disabled checkbox.
|
40
|
-
* @cssproperty --mdc-checkbox-disabled-border-color - Border color for a disabled checkbox.
|
41
|
-
* @cssproperty --mdc-checkbox-disabled-checked-icon-color - Background color for a disabled, selected checkbox.
|
42
|
-
* @cssproperty --mdc-checkbox-disabled-icon-color - Icon color for a disabled checkbox.
|
43
|
-
* @cssproperty --mdc-checkbox-icon-background-color - Background color for an unselected checkbox.
|
44
|
-
* @cssproperty --mdc-checkbox-icon-border-color - Default background color for an unselected checkbox.
|
45
|
-
* @cssproperty --mdc-checkbox-icon-color - Icon color for an unselected checkbox.
|
46
36
|
* @cssproperty --mdc-checkbox-pressed-icon-color - Background color for a selected checkbox when pressed.
|
37
|
+
* @cssproperty --mdc-checkbox-disabled-checked-icon-color - Background color for a selected checkbox when disabled.
|
47
38
|
*/
|
48
39
|
class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
49
40
|
constructor() {
|
@@ -169,16 +160,12 @@ class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
|
|
169
160
|
}
|
170
161
|
render() {
|
171
162
|
var _a;
|
172
|
-
const checkboxIconContent = (this.checked || this.indeterminate) ? html `
|
173
|
-
<mdc-icon
|
174
|
-
class="icon"
|
175
|
-
name="${this.indeterminate ? ICON_NAME.INDETERMINATE : ICON_NAME.CHECKED}"
|
176
|
-
size="1"
|
177
|
-
length-unit="rem"
|
178
|
-
></mdc-icon>
|
179
|
-
` : nothing;
|
180
163
|
return html `
|
181
|
-
<
|
164
|
+
<mdc-staticcheckbox
|
165
|
+
class="mdc-focus-ring"
|
166
|
+
?checked="${this.checked}"
|
167
|
+
?indeterminate="${this.indeterminate}"
|
168
|
+
?disabled="${this.disabled}">
|
182
169
|
<input
|
183
170
|
id="${this.id}"
|
184
171
|
type="checkbox"
|
@@ -197,8 +184,7 @@ class Checkbox extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))
|
|
197
184
|
@change=${this.handleChange}
|
198
185
|
@keydown=${this.handleKeyDown}
|
199
186
|
/>
|
200
|
-
|
201
|
-
</div>
|
187
|
+
</mdc-staticcheckbox>
|
202
188
|
${this.renderLabelAndHelperText()}
|
203
189
|
`;
|
204
190
|
}
|
@@ -3,59 +3,48 @@ import { hostFocusRingStyles } from '../../utils/styles';
|
|
3
3
|
const styles = [css `
|
4
4
|
:host {
|
5
5
|
--mdc-checkbox-background-color-hover: var(--mds-color-theme-control-inactive-hover);
|
6
|
-
--mdc-checkbox-
|
7
|
-
--mdc-checkbox-checked-background-color-hover: var(--mds-color-theme-control-active-hover);
|
8
|
-
--mdc-checkbox-checked-background-color: var(--mds-color-theme-control-active-normal);
|
6
|
+
--mdc-checkbox-pressed-icon-color: var(--mds-color-theme-control-inactive-pressed);
|
9
7
|
--mdc-checkbox-checked-pressed-icon-color: var(--mds-color-theme-control-active-pressed);
|
10
|
-
--mdc-checkbox-
|
11
|
-
--mdc-checkbox-disabled-border-color: var(--mds-color-theme-outline-primary-disabled);
|
8
|
+
--mdc-checkbox-checked-background-color-hover: var(--mds-color-theme-control-active-hover);
|
12
9
|
--mdc-checkbox-disabled-checked-icon-color: var(--mds-color-theme-control-active-disabled);
|
13
|
-
|
14
|
-
--mdc-checkbox-icon-background-color: var(--mds-color-theme-control-inactive-normal);
|
15
|
-
--mdc-checkbox-icon-border-color: var(--mds-color-theme-outline-input-normal);
|
16
|
-
--mdc-checkbox-icon-color: var(--mds-color-theme-inverted-text-primary-normal);
|
17
|
-
--mdc-checkbox-pressed-icon-color: var(--mds-color-theme-control-inactive-pressed);
|
18
|
-
|
10
|
+
|
19
11
|
flex-direction: row;
|
20
12
|
align-items: flex-start;
|
21
13
|
}
|
22
14
|
.mdc-label, .input {
|
23
15
|
cursor: pointer;
|
24
16
|
}
|
25
|
-
|
26
|
-
:host([indeterminate]) .icon-container {
|
27
|
-
background: var(--mdc-checkbox-checked-background-color);
|
28
|
-
border: unset;
|
29
|
-
}
|
30
|
-
:host([checked]) .container:hover .icon-container,
|
31
|
-
:host([indeterminate]) .container:hover .icon-container {
|
32
|
-
background: var(--mdc-checkbox-checked-background-color-hover);
|
33
|
-
}
|
34
|
-
:host([checked]) .container:active .icon-container,
|
35
|
-
:host([indeterminate]) .container:active .icon-container {
|
36
|
-
background: var(--mdc-checkbox-checked-pressed-icon-color);
|
37
|
-
}
|
17
|
+
|
38
18
|
:host([disabled]) .mdc-label,
|
39
19
|
:host([disabled]) .input {
|
40
20
|
cursor: default;
|
41
21
|
}
|
42
|
-
|
43
|
-
|
22
|
+
|
23
|
+
:host(:hover) mdc-staticcheckbox{
|
24
|
+
background: var(--mdc-checkbox-background-color-hover);
|
44
25
|
}
|
45
|
-
:host(
|
46
|
-
|
47
|
-
background: var(--mdc-checkbox-disabled-background-color);
|
26
|
+
:host(:active) mdc-staticcheckbox{
|
27
|
+
background: var(--mdc-checkbox-pressed-icon-color);
|
48
28
|
}
|
49
|
-
|
50
|
-
|
29
|
+
|
30
|
+
:host([checked]:hover)::part(icon-container),
|
31
|
+
:host([indeterminate]:hover)::part(icon-container) {
|
32
|
+
background: var(--mdc-checkbox-checked-background-color-hover);
|
51
33
|
}
|
52
|
-
:host([
|
53
|
-
:host([
|
54
|
-
|
55
|
-
:host([disabled][indeterminate]) .container:hover .icon-container {
|
56
|
-
background: var(--mdc-checkbox-disabled-checked-icon-color);
|
57
|
-
border: 0.0625rem solid var(--mdc-checkbox-disabled-border-color);
|
34
|
+
:host([checked]:active)::part(icon-container),
|
35
|
+
:host([indeterminate]:active)::part(icon-container) {
|
36
|
+
background: var(--mdc-checkbox-checked-pressed-icon-color);
|
58
37
|
}
|
38
|
+
|
39
|
+
:host([disabled]) mdc-staticcheckbox {
|
40
|
+
background: unset;
|
41
|
+
}
|
42
|
+
|
43
|
+
:host([disabled][checked])::part(icon-container),
|
44
|
+
:host([disabled][indeterminate])::part(icon-container) {
|
45
|
+
background-color: var(--mdc-checkbox-disabled-checked-icon-color);
|
46
|
+
}
|
47
|
+
|
59
48
|
.input {
|
60
49
|
margin: 0;
|
61
50
|
padding: 0;
|
@@ -64,45 +53,19 @@ const styles = [css `
|
|
64
53
|
overflow: visible;
|
65
54
|
z-index: 1;
|
66
55
|
}
|
67
|
-
|
68
|
-
|
69
|
-
align-items: center;
|
70
|
-
border: 0.0625rem solid var(--mdc-checkbox-icon-border-color);
|
71
|
-
background: var(--mdc-checkbox-icon-background-color);
|
72
|
-
}
|
73
|
-
.container:hover {
|
74
|
-
background: var(--mdc-checkbox-background-color-hover);
|
75
|
-
}
|
76
|
-
.container:active {
|
77
|
-
background: var(--mdc-checkbox-pressed-icon-color);
|
78
|
-
}
|
79
|
-
.input, .icon-container {
|
56
|
+
|
57
|
+
.input {
|
80
58
|
width: 1rem;
|
81
59
|
height: 1rem;
|
82
|
-
}
|
83
|
-
.input,
|
84
|
-
.icon-container,
|
85
|
-
.container {
|
86
60
|
border-radius: 0.125rem;
|
87
61
|
}
|
88
|
-
|
89
|
-
--mdc-icon-fill-color: var(--mdc-checkbox-icon-color);
|
90
|
-
}
|
91
|
-
.container {
|
92
|
-
margin: 0.125rem 0;
|
93
|
-
}
|
62
|
+
|
94
63
|
.text-container {
|
95
64
|
display: flex;
|
96
65
|
flex-direction: column;
|
97
66
|
gap: 0.25rem;
|
98
67
|
}
|
99
68
|
|
100
|
-
|
101
|
-
@media (forced-colors: active) {
|
102
|
-
:host([checked]) .icon-container,
|
103
|
-
:host([indeterminate]) .icon-container {
|
104
|
-
border: 0.0625rem solid var(--mdc-checkbox-border-color);
|
105
|
-
}
|
106
|
-
}
|
69
|
+
|
107
70
|
`, ...hostFocusRingStyles(true)];
|
108
71
|
export default styles;
|
@@ -1,15 +1,13 @@
|
|
1
|
-
import
|
2
|
-
import { CSSResult } from 'lit';
|
1
|
+
import { PropertyValues, CSSResult } from 'lit';
|
3
2
|
import { Component } from '../../models';
|
4
3
|
import type { LinkSize } from './link.types';
|
5
|
-
declare const Link_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof Component;
|
4
|
+
declare const Link_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof Component;
|
6
5
|
/**
|
7
6
|
* `mdc-link` component can be used to navigate to a different page
|
8
7
|
* within the application or to an external site. It can be used to link to
|
9
8
|
* emails or phone numbers.
|
10
9
|
*
|
11
|
-
* The `children` of the link component is expected to be
|
12
|
-
* containing the text, href, and other attributes.
|
10
|
+
* The `children` of the link component is expected to be the text content.
|
13
11
|
*
|
14
12
|
* For `icon`, the `mdc-icon` component is used to render the icon.
|
15
13
|
*
|
@@ -17,6 +15,11 @@ declare const Link_base: import("../../utils/mixins/index.types").Constructor<im
|
|
17
15
|
*
|
18
16
|
* @tagname mdc-link
|
19
17
|
*
|
18
|
+
* @event click - (React: onClick) Fired when the user activates the buttonLink using a mouse or assistive technology.
|
19
|
+
* @event keydown - (React: onKeyDown) Fired when the user presses a key while the buttonLink has focus.
|
20
|
+
* @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
|
21
|
+
* @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
|
22
|
+
*
|
20
23
|
* @cssproperty --mdc-link-border-radius - Border radius of the link
|
21
24
|
* @cssproperty --mdc-link-color-active - Text and icon color of the link in active state
|
22
25
|
* @cssproperty --mdc-link-color-disabled - Text and icon color of the link in disabled state
|
@@ -52,31 +55,39 @@ declare class Link extends Link_base {
|
|
52
55
|
*/
|
53
56
|
size: LinkSize;
|
54
57
|
/**
|
55
|
-
*
|
56
|
-
|
58
|
+
* Href for navigation. The URL that the hyperlink points to
|
59
|
+
*/
|
60
|
+
href: string;
|
61
|
+
/**
|
62
|
+
* Optional target: _blank, _self, _parent, _top and _unfencedTop
|
63
|
+
*/
|
64
|
+
target: string;
|
65
|
+
/**
|
66
|
+
* Optional rel attribute that defines the relationship of the linked URL as space-separated link types.
|
67
|
+
*/
|
68
|
+
rel?: string;
|
69
|
+
/**
|
70
|
+
* Stores the previous tabindex if set by user
|
71
|
+
* so it can be restored after disabling
|
57
72
|
* @internal
|
58
73
|
*/
|
59
74
|
private prevTabindex;
|
75
|
+
connectedCallback(): void;
|
76
|
+
disconnectedCallback(): void;
|
77
|
+
private handleNavigation;
|
60
78
|
/**
|
61
79
|
* Method to get the size of the trailing icon based on the link size.
|
62
80
|
* @returns The icon size value and units.
|
63
81
|
*/
|
64
82
|
private getIconSize;
|
65
83
|
/**
|
66
|
-
*
|
67
|
-
*
|
68
|
-
*
|
69
|
-
* When link is not disabled, the previous tabindex of the host element is restored
|
70
|
-
* and aria-disabled attribute is removed.
|
84
|
+
* Sets or removes `aria-disabled` and updates `tabIndex` to reflect
|
85
|
+
* the disabled state. When disabled, the element becomes unfocusable;
|
86
|
+
* when enabled, the previous `tabIndex` is restored.
|
71
87
|
*
|
72
|
-
* @param disabled -
|
88
|
+
* @param disabled - Whether the element should be disabled
|
73
89
|
*/
|
74
90
|
private setDisabled;
|
75
|
-
/**
|
76
|
-
* Method to create and append trailing icon to the first anchor element in the slot.
|
77
|
-
* If no icon name is provided, no icon will be rendered.
|
78
|
-
*/
|
79
|
-
private updateTrailingIcon;
|
80
91
|
update(changedProperties: PropertyValues): void;
|
81
92
|
render(): import("lit-html").TemplateResult<1>;
|
82
93
|
static styles: Array<CSSResult>;
|
@@ -7,20 +7,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
9
|
};
|
10
|
-
import { html } from 'lit';
|
10
|
+
import { html, nothing } from 'lit';
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
import { Component } from '../../models';
|
13
13
|
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
14
14
|
import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
15
15
|
import { DEFAULTS, LINK_ICON_SIZES, LINK_SIZES } from './link.constants';
|
16
16
|
import styles from './link.styles';
|
17
|
+
import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
|
17
18
|
/**
|
18
19
|
* `mdc-link` component can be used to navigate to a different page
|
19
20
|
* within the application or to an external site. It can be used to link to
|
20
21
|
* emails or phone numbers.
|
21
22
|
*
|
22
|
-
* The `children` of the link component is expected to be
|
23
|
-
* containing the text, href, and other attributes.
|
23
|
+
* The `children` of the link component is expected to be the text content.
|
24
24
|
*
|
25
25
|
* For `icon`, the `mdc-icon` component is used to render the icon.
|
26
26
|
*
|
@@ -28,6 +28,11 @@ import styles from './link.styles';
|
|
28
28
|
*
|
29
29
|
* @tagname mdc-link
|
30
30
|
*
|
31
|
+
* @event click - (React: onClick) Fired when the user activates the buttonLink using a mouse or assistive technology.
|
32
|
+
* @event keydown - (React: onKeyDown) Fired when the user presses a key while the buttonLink has focus.
|
33
|
+
* @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
|
34
|
+
* @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
|
35
|
+
*
|
31
36
|
* @cssproperty --mdc-link-border-radius - Border radius of the link
|
32
37
|
* @cssproperty --mdc-link-color-active - Text and icon color of the link in active state
|
33
38
|
* @cssproperty --mdc-link-color-disabled - Text and icon color of the link in disabled state
|
@@ -40,7 +45,7 @@ import styles from './link.styles';
|
|
40
45
|
* @cssproperty --mdc-link-inverted-color-normal - Text and icon color of the inverted link in normal state
|
41
46
|
* @cssproperty --mdc-link-text-decoration-disabled - Text decoration of the link in disabled state for all variants
|
42
47
|
*/
|
43
|
-
class Link extends DisabledMixin(IconNameMixin(Component)) {
|
48
|
+
class Link extends DisabledMixin(TabIndexMixin(IconNameMixin(Component))) {
|
44
49
|
constructor() {
|
45
50
|
super(...arguments);
|
46
51
|
/**
|
@@ -65,11 +70,37 @@ class Link extends DisabledMixin(IconNameMixin(Component)) {
|
|
65
70
|
*/
|
66
71
|
this.size = DEFAULTS.LINK_SIZE;
|
67
72
|
/**
|
68
|
-
*
|
69
|
-
|
73
|
+
* Href for navigation. The URL that the hyperlink points to
|
74
|
+
*/
|
75
|
+
this.href = '#';
|
76
|
+
/**
|
77
|
+
* Optional target: _blank, _self, _parent, _top and _unfencedTop
|
78
|
+
*/
|
79
|
+
this.target = '_self';
|
80
|
+
/**
|
81
|
+
* Stores the previous tabindex if set by user
|
82
|
+
* so it can be restored after disabling
|
70
83
|
* @internal
|
71
84
|
*/
|
72
|
-
this.prevTabindex =
|
85
|
+
this.prevTabindex = 0;
|
86
|
+
this.handleNavigation = (e) => {
|
87
|
+
if ((e.type === 'click' || (e instanceof KeyboardEvent && e.key === 'Enter')) && this.href) {
|
88
|
+
if (this.disabled)
|
89
|
+
return;
|
90
|
+
window.open(this.href, this.target, this.rel);
|
91
|
+
}
|
92
|
+
};
|
93
|
+
}
|
94
|
+
connectedCallback() {
|
95
|
+
super.connectedCallback();
|
96
|
+
this.setAttribute('role', 'link');
|
97
|
+
this.addEventListener('click', this.handleNavigation);
|
98
|
+
this.addEventListener('keydown', this.handleNavigation);
|
99
|
+
}
|
100
|
+
disconnectedCallback() {
|
101
|
+
super.disconnectedCallback();
|
102
|
+
this.removeEventListener('click', this.handleNavigation);
|
103
|
+
this.removeEventListener('keydown', this.handleNavigation);
|
73
104
|
}
|
74
105
|
/**
|
75
106
|
* Method to get the size of the trailing icon based on the link size.
|
@@ -86,45 +117,25 @@ class Link extends DisabledMixin(IconNameMixin(Component)) {
|
|
86
117
|
}
|
87
118
|
}
|
88
119
|
/**
|
89
|
-
*
|
90
|
-
*
|
91
|
-
*
|
92
|
-
* When link is not disabled, the previous tabindex of the host element is restored
|
93
|
-
* and aria-disabled attribute is removed.
|
120
|
+
* Sets or removes `aria-disabled` and updates `tabIndex` to reflect
|
121
|
+
* the disabled state. When disabled, the element becomes unfocusable;
|
122
|
+
* when enabled, the previous `tabIndex` is restored.
|
94
123
|
*
|
95
|
-
* @param disabled -
|
124
|
+
* @param disabled - Whether the element should be disabled
|
96
125
|
*/
|
97
126
|
setDisabled(disabled) {
|
98
127
|
if (disabled) {
|
99
|
-
this.prevTabindex = this.hasAttribute('tabindex') ? this.tabIndex : null;
|
100
|
-
this.tabIndex = -1;
|
101
128
|
this.setAttribute('aria-disabled', 'true');
|
102
|
-
|
103
|
-
|
104
|
-
this.removeAttribute('tabindex');
|
105
|
-
this.removeAttribute('aria-disabled');
|
129
|
+
this.prevTabindex = this.tabIndex;
|
130
|
+
this.tabIndex = -1;
|
106
131
|
}
|
107
132
|
else {
|
108
|
-
this.tabIndex
|
133
|
+
if (this.tabIndex === -1) {
|
134
|
+
this.tabIndex = this.prevTabindex;
|
135
|
+
}
|
109
136
|
this.removeAttribute('aria-disabled');
|
110
137
|
}
|
111
138
|
}
|
112
|
-
/**
|
113
|
-
* Method to create and append trailing icon to the first anchor element in the slot.
|
114
|
-
* If no icon name is provided, no icon will be rendered.
|
115
|
-
*/
|
116
|
-
updateTrailingIcon() {
|
117
|
-
var _a, _b;
|
118
|
-
const anchorElement = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot')) === null || _b === void 0 ? void 0 : _b.assignedElements({ flatten: true }).find((element) => element.tagName === 'A');
|
119
|
-
const iconSize = this.getIconSize();
|
120
|
-
if (this.iconName && anchorElement) {
|
121
|
-
const trailingIcon = document.createElement('mdc-icon');
|
122
|
-
trailingIcon.setAttribute('name', this.iconName);
|
123
|
-
trailingIcon.setAttribute('size', `${iconSize}`);
|
124
|
-
trailingIcon.setAttribute('length-unit', 'rem');
|
125
|
-
anchorElement.appendChild(trailingIcon);
|
126
|
-
}
|
127
|
-
}
|
128
139
|
update(changedProperties) {
|
129
140
|
super.update(changedProperties);
|
130
141
|
if (changedProperties.has('disabled')) {
|
@@ -133,9 +144,14 @@ class Link extends DisabledMixin(IconNameMixin(Component)) {
|
|
133
144
|
}
|
134
145
|
render() {
|
135
146
|
return html `
|
136
|
-
<
|
137
|
-
|
138
|
-
|
147
|
+
<slot></slot>
|
148
|
+
${this.iconName ? html `
|
149
|
+
<mdc-icon
|
150
|
+
name=${this.iconName}
|
151
|
+
size=${this.getIconSize()}
|
152
|
+
length-unit="rem"
|
153
|
+
></mdc-icon>
|
154
|
+
` : nothing}
|
139
155
|
`;
|
140
156
|
}
|
141
157
|
}
|
@@ -152,4 +168,16 @@ __decorate([
|
|
152
168
|
property({ type: String, reflect: true }),
|
153
169
|
__metadata("design:type", String)
|
154
170
|
], Link.prototype, "size", void 0);
|
171
|
+
__decorate([
|
172
|
+
property({ type: String, reflect: true }),
|
173
|
+
__metadata("design:type", Object)
|
174
|
+
], Link.prototype, "href", void 0);
|
175
|
+
__decorate([
|
176
|
+
property({ type: String, reflect: true }),
|
177
|
+
__metadata("design:type", Object)
|
178
|
+
], Link.prototype, "target", void 0);
|
179
|
+
__decorate([
|
180
|
+
property({ type: String, reflect: true }),
|
181
|
+
__metadata("design:type", String)
|
182
|
+
], Link.prototype, "rel", void 0);
|
155
183
|
export default Link;
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import { css } from 'lit';
|
2
2
|
import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
|
3
3
|
const styles = [hostFitContentStyles, css `
|
4
|
-
|
5
4
|
:host {
|
6
|
-
|
7
5
|
--mdc-link-border-radius: 0.25rem;
|
8
6
|
--mdc-link-color-active: var(--mds-color-theme-text-accent-active);
|
9
7
|
--mdc-link-color-disabled: var(--mds-color-theme-text-primary-disabled);
|
@@ -15,49 +13,50 @@ const styles = [hostFitContentStyles, css `
|
|
15
13
|
--mdc-link-inverted-color-hover: var(--mds-color-theme-inverted-text-accent-hover);
|
16
14
|
--mdc-link-inverted-color-normal: var(--mds-color-theme-inverted-text-accent-normal);
|
17
15
|
--mdc-link-text-decoration-disabled: underline;
|
18
|
-
}
|
19
16
|
|
20
|
-
:host::part(link-container){
|
21
17
|
border-radius: var(--mdc-link-border-radius);
|
22
18
|
color: var(--mdc-link-color-normal);
|
23
|
-
}
|
24
|
-
|
25
|
-
::slotted(a) {
|
26
|
-
outline: none;
|
27
|
-
align-items: center;
|
28
|
-
color: inherit;
|
29
|
-
display: flex;
|
30
19
|
gap: var(--mdc-link-icon-margin-left);
|
31
|
-
text-decoration: inherit;
|
32
20
|
text-underline-offset: auto;
|
33
21
|
text-underline-position: from-font;
|
22
|
+
cursor: pointer;
|
34
23
|
}
|
35
24
|
|
36
|
-
:host(
|
37
|
-
|
25
|
+
:host([inline]) {
|
26
|
+
display: inline-flex;
|
38
27
|
}
|
39
28
|
|
40
|
-
:host(:
|
41
|
-
color: var(--mdc-link-color-
|
29
|
+
:host(:hover) {
|
30
|
+
color: var(--mdc-link-color-hover);
|
42
31
|
}
|
43
32
|
|
44
|
-
:host(
|
45
|
-
|
33
|
+
:host(:active) {
|
34
|
+
color: var(--mdc-link-color-active);
|
35
|
+
box-shadow: none;
|
46
36
|
}
|
47
37
|
|
48
|
-
:host([inverted])
|
38
|
+
:host([inverted]) {
|
49
39
|
color: var(--mdc-link-inverted-color-normal);
|
50
40
|
}
|
51
41
|
|
52
|
-
:host([inverted]:hover)
|
42
|
+
:host([inverted]:hover) {
|
53
43
|
color: var(--mdc-link-inverted-color-hover);
|
54
44
|
}
|
55
45
|
|
56
|
-
:host([inverted]:active)
|
46
|
+
:host([inverted]:active) {
|
57
47
|
color: var(--mdc-link-inverted-color-active);
|
58
48
|
}
|
59
49
|
|
60
|
-
:host([
|
50
|
+
:host([disabled]) {
|
51
|
+
color: var(--mdc-link-color-disabled);
|
52
|
+
pointer-events: none;
|
53
|
+
}
|
54
|
+
|
55
|
+
:host([inverted][disabled]) {
|
56
|
+
color: var(--mdc-link-inverted-color-disabled);
|
57
|
+
}
|
58
|
+
|
59
|
+
:host([size="large"]) {
|
61
60
|
font-size: var(--mds-font-apps-body-large-regular-font-size);
|
62
61
|
font-weight: var(--mds-font-apps-body-large-regular-font-weight);
|
63
62
|
line-height: var(--mds-font-apps-body-large-regular-line-height);
|
@@ -65,7 +64,7 @@ const styles = [hostFitContentStyles, css `
|
|
65
64
|
text-transform: var(--mds-font-apps-body-large-regular-text-case);
|
66
65
|
}
|
67
66
|
|
68
|
-
:host([size="midsize"])
|
67
|
+
:host([size="midsize"]) {
|
69
68
|
font-size: var(--mds-font-apps-body-midsize-regular-font-size);
|
70
69
|
font-weight: var(--mds-font-apps-body-midsize-regular-font-weight);
|
71
70
|
line-height: var(--mds-font-apps-body-midsize-regular-line-height);
|
@@ -73,7 +72,7 @@ const styles = [hostFitContentStyles, css `
|
|
73
72
|
text-transform: var(--mds-font-apps-body-midsize-regular-text-case);
|
74
73
|
}
|
75
74
|
|
76
|
-
:host([size="small"])
|
75
|
+
:host([size="small"]) {
|
77
76
|
font-size: var(--mds-font-apps-body-small-regular-font-size);
|
78
77
|
font-weight: var(--mds-font-apps-body-small-regular-font-weight);
|
79
78
|
line-height: var(--mds-font-apps-body-small-regular-line-height);
|
@@ -81,9 +80,9 @@ const styles = [hostFitContentStyles, css `
|
|
81
80
|
text-transform: var(--mds-font-apps-body-small-regular-text-case);
|
82
81
|
}
|
83
82
|
|
84
|
-
:host([size="large"]:hover)
|
85
|
-
:host([size="large"]:active)
|
86
|
-
:host([size="large"][inline])
|
83
|
+
:host([size="large"]:hover),
|
84
|
+
:host([size="large"]:active),
|
85
|
+
:host([size="large"][inline]) {
|
87
86
|
font-size: var(--mds-font-apps-body-large-regular-underline-font-size);
|
88
87
|
font-weight: var(--mds-font-apps-body-large-regular-underline-font-weight);
|
89
88
|
line-height: var(--mds-font-apps-body-large-regular-underline-line-height);
|
@@ -91,9 +90,9 @@ const styles = [hostFitContentStyles, css `
|
|
91
90
|
text-transform: var(--mds-font-apps-body-large-regular-underline-text-case);
|
92
91
|
}
|
93
92
|
|
94
|
-
:host([size="midsize"]:hover)
|
95
|
-
:host([size="midsize"]:active)
|
96
|
-
:host([size="midsize"][inline])
|
93
|
+
:host([size="midsize"]:hover),
|
94
|
+
:host([size="midsize"]:active),
|
95
|
+
:host([size="midsize"][inline]) {
|
97
96
|
font-size: var(--mds-font-apps-body-midsize-regular-underline-font-size);
|
98
97
|
font-weight: var(--mds-font-apps-body-midsize-regular-underline-font-weight);
|
99
98
|
line-height: var(--mds-font-apps-body-midsize-regular-underline-line-height);
|
@@ -101,28 +100,15 @@ const styles = [hostFitContentStyles, css `
|
|
101
100
|
text-transform: var(--mds-font-apps-body-midsize-regular-underline-text-case);
|
102
101
|
}
|
103
102
|
|
104
|
-
:host([size="small"]:hover)
|
105
|
-
:host([size="small"]:active)
|
106
|
-
:host([size="small"][inline])
|
103
|
+
:host([size="small"]:hover),
|
104
|
+
:host([size="small"]:active),
|
105
|
+
:host([size="small"][inline]) {
|
107
106
|
font-size: var(--mds-font-apps-body-small-regular-underline-font-size);
|
108
107
|
font-weight: var(--mds-font-apps-body-small-regular-underline-font-weight);
|
109
108
|
line-height: var(--mds-font-apps-body-small-regular-underline-line-height);
|
110
109
|
text-decoration: var(--mds-font-apps-body-small-regular-underline-text-decoration);
|
111
110
|
text-transform: var(--mds-font-apps-body-small-regular-underline-text-case);
|
112
111
|
}
|
113
|
-
|
114
|
-
|
115
|
-
color: var(--mdc-link-color-disabled);
|
116
|
-
pointer-events: none;
|
117
|
-
}
|
118
|
-
|
119
|
-
:host([inverted][disabled])::part(link-container) {
|
120
|
-
color: var(--mdc-link-inverted-color-disabled);
|
121
|
-
}
|
122
|
-
`, ...hostFocusRingStyles(true),
|
123
|
-
css `
|
124
|
-
:host(:active)::part(link-container) {
|
125
|
-
box-shadow: none;
|
126
|
-
}
|
127
|
-
`];
|
112
|
+
`, ...hostFocusRingStyles(),
|
113
|
+
];
|
128
114
|
export default styles;
|
@@ -1,4 +1,10 @@
|
|
1
1
|
import type { ValueOf } from '../../utils/types';
|
2
2
|
import { LINK_SIZES } from './link.constants';
|
3
3
|
type LinkSize = ValueOf<typeof LINK_SIZES>;
|
4
|
-
|
4
|
+
interface Events {
|
5
|
+
onClickEvent: MouseEvent;
|
6
|
+
onBlurEvent: Event;
|
7
|
+
onKeyDownEvent: KeyboardEvent;
|
8
|
+
onFocusEvent: FocusEvent;
|
9
|
+
}
|
10
|
+
export type { LinkSize, Events };
|