@momentum-design/components 0.56.1 → 0.57.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.
Files changed (30) hide show
  1. package/dist/browser/index.js +201 -179
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/link/link.component.d.ts +7 -59
  4. package/dist/components/link/link.component.js +7 -109
  5. package/dist/components/link/link.constants.d.ts +0 -2
  6. package/dist/components/link/link.constants.js +0 -2
  7. package/dist/components/link/link.styles.d.ts +2 -2
  8. package/dist/components/link/link.styles.js +4 -57
  9. package/dist/components/linksimple/index.d.ts +7 -0
  10. package/dist/components/linksimple/index.js +4 -0
  11. package/dist/components/linksimple/linksimple.component.d.ts +73 -0
  12. package/dist/components/linksimple/linksimple.component.js +141 -0
  13. package/dist/components/linksimple/linksimple.constants.d.ts +6 -0
  14. package/dist/components/linksimple/linksimple.constants.js +7 -0
  15. package/dist/components/linksimple/linksimple.styles.d.ts +2 -0
  16. package/dist/components/linksimple/linksimple.styles.js +72 -0
  17. package/dist/components/linksimple/linksimple.types.d.ts +7 -0
  18. package/dist/components/linksimple/linksimple.types.js +1 -0
  19. package/dist/components/popover/popover.styles.js +4 -1
  20. package/dist/components/select/select.styles.js +1 -0
  21. package/dist/custom-elements.json +1241 -881
  22. package/dist/index.d.ts +2 -1
  23. package/dist/index.js +2 -1
  24. package/dist/react/index.d.ts +2 -1
  25. package/dist/react/index.js +2 -1
  26. package/dist/react/link/index.d.ts +4 -16
  27. package/dist/react/link/index.js +4 -16
  28. package/dist/react/linksimple/index.d.ts +34 -0
  29. package/dist/react/linksimple/index.js +42 -0
  30. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- import { PropertyValues, CSSResult } from 'lit';
2
- import { Component } from '../../models';
1
+ import { CSSResult } from 'lit';
3
2
  import type { LinkSize } from './link.types';
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;
3
+ import Linksimple from '../linksimple/linksimple.component';
4
+ declare const Link_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof Linksimple;
5
5
  /**
6
6
  * `mdc-link` component can be used to navigate to a different page
7
7
  * within the application or to an external site. It can be used to link to
@@ -15,34 +15,12 @@ declare const Link_base: import("../../utils/mixins/index.types").Constructor<im
15
15
  *
16
16
  * @tagname mdc-link
17
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
- *
23
- * @cssproperty --mdc-link-border-radius - Border radius of the link
24
- * @cssproperty --mdc-link-color-active - Text and icon color of the link in active state
25
- * @cssproperty --mdc-link-color-disabled - Text and icon color of the link in disabled state
26
- * @cssproperty --mdc-link-color-hover - Text and icon color of the link in hover state
27
- * @cssproperty --mdc-link-color-normal - Text and icon color of the link in normal state
28
- * @cssproperty --mdc-link-icon-margin-left - Gap between the text and icon (only applicable when an icon is set)
29
- * @cssproperty --mdc-link-inverted-color-active - Text and icon color of the inverted link in active state
30
- * @cssproperty --mdc-link-inverted-color-disabled - Text and icon color of the inverted link in disabled state
31
- * @cssproperty --mdc-link-inverted-color-hover - Text and icon color of the inverted link in hover state
32
- * @cssproperty --mdc-link-inverted-color-normal - Text and icon color of the inverted link in normal state
33
- * @cssproperty --mdc-link-text-decoration-disabled - Text decoration of the link in disabled state for all variants
18
+ * @event click - (React: onClick) Fired when the user activates the Link using a mouse or assistive technology.
19
+ * @event keydown - (React: onKeyDown) Fired when the user presses a key while the Link has focus.
20
+ * @event focus - (React: onFocus) Fired when the Link receives keyboard or mouse focus.
21
+ * @event blur - (React: onBlur) Fired when the Link loses keyboard or mouse focus.
34
22
  */
35
23
  declare class Link extends Link_base {
36
- /**
37
- * The link can be inline or standalone.
38
- * @default false
39
- */
40
- inline: boolean;
41
- /**
42
- * The link color can be inverted by setting the inverted attribute to true.
43
- * @default false
44
- */
45
- inverted: boolean;
46
24
  /**
47
25
  * Size of the link.
48
26
  * Acceptable values include:
@@ -54,41 +32,11 @@ declare class Link extends Link_base {
54
32
  * @default large
55
33
  */
56
34
  size: LinkSize;
57
- /**
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
72
- * @internal
73
- */
74
- private prevTabindex;
75
- connectedCallback(): void;
76
- disconnectedCallback(): void;
77
- private handleNavigation;
78
35
  /**
79
36
  * Method to get the size of the trailing icon based on the link size.
80
37
  * @returns The icon size value and units.
81
38
  */
82
39
  private getIconSize;
83
- /**
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.
87
- *
88
- * @param disabled - Whether the element should be disabled
89
- */
90
- private setDisabled;
91
- update(changedProperties: PropertyValues): void;
92
40
  render(): import("lit-html").TemplateResult<1>;
93
41
  static styles: Array<CSSResult>;
94
42
  }
@@ -9,12 +9,10 @@ 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 { Component } from '../../models';
13
- import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
14
12
  import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
15
13
  import { DEFAULTS, LINK_ICON_SIZES, LINK_SIZES } from './link.constants';
16
14
  import styles from './link.styles';
17
- import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
15
+ import Linksimple from '../linksimple/linksimple.component';
18
16
  /**
19
17
  * `mdc-link` component can be used to navigate to a different page
20
18
  * within the application or to an external site. It can be used to link to
@@ -28,36 +26,14 @@ import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
28
26
  *
29
27
  * @tagname mdc-link
30
28
  *
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
- *
36
- * @cssproperty --mdc-link-border-radius - Border radius of the link
37
- * @cssproperty --mdc-link-color-active - Text and icon color of the link in active state
38
- * @cssproperty --mdc-link-color-disabled - Text and icon color of the link in disabled state
39
- * @cssproperty --mdc-link-color-hover - Text and icon color of the link in hover state
40
- * @cssproperty --mdc-link-color-normal - Text and icon color of the link in normal state
41
- * @cssproperty --mdc-link-icon-margin-left - Gap between the text and icon (only applicable when an icon is set)
42
- * @cssproperty --mdc-link-inverted-color-active - Text and icon color of the inverted link in active state
43
- * @cssproperty --mdc-link-inverted-color-disabled - Text and icon color of the inverted link in disabled state
44
- * @cssproperty --mdc-link-inverted-color-hover - Text and icon color of the inverted link in hover state
45
- * @cssproperty --mdc-link-inverted-color-normal - Text and icon color of the inverted link in normal state
46
- * @cssproperty --mdc-link-text-decoration-disabled - Text decoration of the link in disabled state for all variants
29
+ * @event click - (React: onClick) Fired when the user activates the Link using a mouse or assistive technology.
30
+ * @event keydown - (React: onKeyDown) Fired when the user presses a key while the Link has focus.
31
+ * @event focus - (React: onFocus) Fired when the Link receives keyboard or mouse focus.
32
+ * @event blur - (React: onBlur) Fired when the Link loses keyboard or mouse focus.
47
33
  */
48
- class Link extends DisabledMixin(TabIndexMixin(IconNameMixin(Component))) {
34
+ class Link extends IconNameMixin(Linksimple) {
49
35
  constructor() {
50
36
  super(...arguments);
51
- /**
52
- * The link can be inline or standalone.
53
- * @default false
54
- */
55
- this.inline = DEFAULTS.INLINE;
56
- /**
57
- * The link color can be inverted by setting the inverted attribute to true.
58
- * @default false
59
- */
60
- this.inverted = DEFAULTS.INVERTED;
61
37
  /**
62
38
  * Size of the link.
63
39
  * Acceptable values include:
@@ -69,38 +45,6 @@ class Link extends DisabledMixin(TabIndexMixin(IconNameMixin(Component))) {
69
45
  * @default large
70
46
  */
71
47
  this.size = DEFAULTS.LINK_SIZE;
72
- /**
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
83
- * @internal
84
- */
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);
104
48
  }
105
49
  /**
106
50
  * Method to get the size of the trailing icon based on the link size.
@@ -116,32 +60,6 @@ class Link extends DisabledMixin(TabIndexMixin(IconNameMixin(Component))) {
116
60
  return LINK_ICON_SIZES.LARGE;
117
61
  }
118
62
  }
119
- /**
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.
123
- *
124
- * @param disabled - Whether the element should be disabled
125
- */
126
- setDisabled(disabled) {
127
- if (disabled) {
128
- this.setAttribute('aria-disabled', 'true');
129
- this.prevTabindex = this.tabIndex;
130
- this.tabIndex = -1;
131
- }
132
- else {
133
- if (this.tabIndex === -1) {
134
- this.tabIndex = this.prevTabindex;
135
- }
136
- this.removeAttribute('aria-disabled');
137
- }
138
- }
139
- update(changedProperties) {
140
- super.update(changedProperties);
141
- if (changedProperties.has('disabled')) {
142
- this.setDisabled(this.disabled);
143
- }
144
- }
145
63
  render() {
146
64
  return html `
147
65
  <slot></slot>
@@ -155,29 +73,9 @@ class Link extends DisabledMixin(TabIndexMixin(IconNameMixin(Component))) {
155
73
  `;
156
74
  }
157
75
  }
158
- Link.styles = [...Component.styles, ...styles];
159
- __decorate([
160
- property({ type: Boolean, reflect: true }),
161
- __metadata("design:type", Boolean)
162
- ], Link.prototype, "inline", void 0);
163
- __decorate([
164
- property({ type: Boolean, reflect: true }),
165
- __metadata("design:type", Boolean)
166
- ], Link.prototype, "inverted", void 0);
76
+ Link.styles = [...Linksimple.styles, ...styles];
167
77
  __decorate([
168
78
  property({ type: String, reflect: true }),
169
79
  __metadata("design:type", String)
170
80
  ], 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);
183
81
  export default Link;
@@ -10,8 +10,6 @@ declare const LINK_ICON_SIZES: {
10
10
  readonly SMALL: 0.75;
11
11
  };
12
12
  declare const DEFAULTS: {
13
- INLINE: boolean;
14
- INVERTED: boolean;
15
13
  LINK_SIZE: "large";
16
14
  };
17
15
  export { DEFAULTS, LINK_ICON_SIZES, LINK_SIZES, TAG_NAME, };
@@ -11,8 +11,6 @@ const LINK_ICON_SIZES = {
11
11
  SMALL: 0.75,
12
12
  };
13
13
  const DEFAULTS = {
14
- INLINE: false,
15
- INVERTED: false,
16
14
  LINK_SIZE: LINK_SIZES.LARGE,
17
15
  };
18
16
  export { DEFAULTS, LINK_ICON_SIZES, LINK_SIZES, TAG_NAME, };
@@ -1,2 +1,2 @@
1
- declare const styles: import("lit").CSSResult[];
2
- export default styles;
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -1,59 +1,7 @@
1
1
  import { css } from 'lit';
2
- import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
3
- const styles = [hostFitContentStyles, css `
2
+ const styles = css `
4
3
  :host {
5
- --mdc-link-border-radius: 0.25rem;
6
- --mdc-link-color-active: var(--mds-color-theme-text-accent-active);
7
- --mdc-link-color-disabled: var(--mds-color-theme-text-primary-disabled);
8
- --mdc-link-color-hover: var(--mds-color-theme-text-accent-hover);
9
- --mdc-link-color-normal: var(--mds-color-theme-text-accent-normal);
10
- --mdc-link-icon-margin-left: 0.25rem;
11
- --mdc-link-inverted-color-active: var(--mds-color-theme-inverted-text-accent-active);
12
- --mdc-link-inverted-color-disabled: var(--mds-color-theme-inverted-text-primary-disabled);
13
- --mdc-link-inverted-color-hover: var(--mds-color-theme-inverted-text-accent-hover);
14
- --mdc-link-inverted-color-normal: var(--mds-color-theme-inverted-text-accent-normal);
15
- --mdc-link-text-decoration-disabled: underline;
16
-
17
- border-radius: var(--mdc-link-border-radius);
18
- color: var(--mdc-link-color-normal);
19
- gap: var(--mdc-link-icon-margin-left);
20
- text-underline-offset: auto;
21
- text-underline-position: from-font;
22
- cursor: pointer;
23
- }
24
-
25
- :host([inline]) {
26
- display: inline-flex;
27
- }
28
-
29
- :host(:hover) {
30
- color: var(--mdc-link-color-hover);
31
- }
32
-
33
- :host(:active) {
34
- color: var(--mdc-link-color-active);
35
- box-shadow: none;
36
- }
37
-
38
- :host([inverted]) {
39
- color: var(--mdc-link-inverted-color-normal);
40
- }
41
-
42
- :host([inverted]:hover) {
43
- color: var(--mdc-link-inverted-color-hover);
44
- }
45
-
46
- :host([inverted]:active) {
47
- color: var(--mdc-link-inverted-color-active);
48
- }
49
-
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);
4
+ gap: 0.25rem;
57
5
  }
58
6
 
59
7
  :host([size="large"]) {
@@ -109,6 +57,5 @@ const styles = [hostFitContentStyles, css `
109
57
  text-decoration: var(--mds-font-apps-body-small-regular-underline-text-decoration);
110
58
  text-transform: var(--mds-font-apps-body-small-regular-underline-text-case);
111
59
  }
112
- `, ...hostFocusRingStyles(),
113
- ];
114
- export default styles;
60
+ `;
61
+ export default [styles];
@@ -0,0 +1,7 @@
1
+ import Linksimple from './linksimple.component';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ ['mdc-linksimple']: Linksimple;
5
+ }
6
+ }
7
+ export default Linksimple;
@@ -0,0 +1,4 @@
1
+ import Linksimple from './linksimple.component';
2
+ import { TAG_NAME } from './linksimple.constants';
3
+ Linksimple.register(TAG_NAME);
4
+ export default Linksimple;
@@ -0,0 +1,73 @@
1
+ import { PropertyValues, CSSResult } from 'lit';
2
+ import { Component } from '../../models';
3
+ declare const Linksimple_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Component;
4
+ /**
5
+ * `mdc-linksimple` is a lightweight link component that can be used to navigate
6
+ * within the application or to an external URL. It does not have any predefined default size.
7
+ *
8
+ * The `children` of the `mdc-linksimple` component can be customized to suit
9
+ * different use cases, including text, icons, or other inline content. For the child to be an icon,
10
+ * the `mdc-icon` component should be used to render.
11
+ *
12
+ * @tagname mdc-linksimple
13
+ *
14
+ * @event click - (React: onClick) Fired when the user activates the buttonLink using a mouse or assistive technology.
15
+ * @event keydown - (React: onKeyDown) Fired when the user presses a key while the buttonLink has focus.
16
+ * @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
17
+ * @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
18
+ *
19
+ * @cssproperty --mdc-link-border-radius - Border radius of the link.
20
+ * @cssproperty --mdc-link-color-active - Color of the link’s child content in the active state.
21
+ * @cssproperty --mdc-link-color-disabled - Color of the link’s child content in the disabled state.
22
+ * @cssproperty --mdc-link-color-hover - Color of the link’s child content in the hover state.
23
+ * @cssproperty --mdc-link-color-normal - Color of the link’s child content in the normal state.
24
+ * @cssproperty --mdc-link-inverted-color-active - Color of the inverted link’s child content in the active state.
25
+ * @cssproperty --mdc-link-inverted-color-disabled - Color of the inverted link’s child content in the disabled state.
26
+ * @cssproperty --mdc-link-inverted-color-hover - Color of the inverted link’s child content in the hover state.
27
+ * @cssproperty --mdc-link-inverted-color-normal - Color of the inverted link’s child content in the normal state.
28
+ */
29
+ declare class Linksimple extends Linksimple_base {
30
+ /**
31
+ * The link can be inline or standalone.
32
+ * @default false
33
+ */
34
+ inline: boolean;
35
+ /**
36
+ * The link color can be inverted by setting the inverted attribute to true.
37
+ * @default false
38
+ */
39
+ inverted: boolean;
40
+ /**
41
+ * Href for navigation. The URL that the hyperlink points to
42
+ */
43
+ href: string;
44
+ /**
45
+ * Optional target: _blank, _self, _parent, _top and _unfencedTop
46
+ */
47
+ target: string;
48
+ /**
49
+ * Optional rel attribute that defines the relationship of the linked URL as space-separated link types.
50
+ */
51
+ rel?: string;
52
+ /**
53
+ * Stores the previous tabindex if set by user
54
+ * so it can be restored after disabling
55
+ * @internal
56
+ */
57
+ private prevTabindex;
58
+ connectedCallback(): void;
59
+ disconnectedCallback(): void;
60
+ private handleNavigation;
61
+ /**
62
+ * Sets or removes `aria-disabled` and updates `tabIndex` to reflect
63
+ * the disabled state. When disabled, the element becomes unfocusable;
64
+ * when enabled, the previous `tabIndex` is restored.
65
+ *
66
+ * @param disabled - Whether the element should be disabled
67
+ */
68
+ private setDisabled;
69
+ update(changedProperties: PropertyValues): void;
70
+ render(): import("lit-html").TemplateResult<1>;
71
+ static styles: Array<CSSResult>;
72
+ }
73
+ export default Linksimple;
@@ -0,0 +1,141 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { html } from 'lit';
11
+ import { property } from 'lit/decorators.js';
12
+ import { Component } from '../../models';
13
+ import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
14
+ import { DEFAULTS } from './linksimple.constants';
15
+ import styles from './linksimple.styles';
16
+ import { TabIndexMixin } from '../../utils/mixins/TabIndexMixin';
17
+ /**
18
+ * `mdc-linksimple` is a lightweight link component that can be used to navigate
19
+ * within the application or to an external URL. It does not have any predefined default size.
20
+ *
21
+ * The `children` of the `mdc-linksimple` component can be customized to suit
22
+ * different use cases, including text, icons, or other inline content. For the child to be an icon,
23
+ * the `mdc-icon` component should be used to render.
24
+ *
25
+ * @tagname mdc-linksimple
26
+ *
27
+ * @event click - (React: onClick) Fired when the user activates the buttonLink using a mouse or assistive technology.
28
+ * @event keydown - (React: onKeyDown) Fired when the user presses a key while the buttonLink has focus.
29
+ * @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
30
+ * @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
31
+ *
32
+ * @cssproperty --mdc-link-border-radius - Border radius of the link.
33
+ * @cssproperty --mdc-link-color-active - Color of the link’s child content in the active state.
34
+ * @cssproperty --mdc-link-color-disabled - Color of the link’s child content in the disabled state.
35
+ * @cssproperty --mdc-link-color-hover - Color of the link’s child content in the hover state.
36
+ * @cssproperty --mdc-link-color-normal - Color of the link’s child content in the normal state.
37
+ * @cssproperty --mdc-link-inverted-color-active - Color of the inverted link’s child content in the active state.
38
+ * @cssproperty --mdc-link-inverted-color-disabled - Color of the inverted link’s child content in the disabled state.
39
+ * @cssproperty --mdc-link-inverted-color-hover - Color of the inverted link’s child content in the hover state.
40
+ * @cssproperty --mdc-link-inverted-color-normal - Color of the inverted link’s child content in the normal state.
41
+ */
42
+ class Linksimple extends DisabledMixin(TabIndexMixin(Component)) {
43
+ constructor() {
44
+ super(...arguments);
45
+ /**
46
+ * The link can be inline or standalone.
47
+ * @default false
48
+ */
49
+ this.inline = DEFAULTS.INLINE;
50
+ /**
51
+ * The link color can be inverted by setting the inverted attribute to true.
52
+ * @default false
53
+ */
54
+ this.inverted = DEFAULTS.INVERTED;
55
+ /**
56
+ * Href for navigation. The URL that the hyperlink points to
57
+ */
58
+ this.href = '#';
59
+ /**
60
+ * Optional target: _blank, _self, _parent, _top and _unfencedTop
61
+ */
62
+ 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
+ this.handleNavigation = (e) => {
70
+ if ((e.type === 'click' || (e instanceof KeyboardEvent && e.key === 'Enter')) && this.href) {
71
+ if (this.disabled)
72
+ return;
73
+ window.open(this.href, this.target, this.rel);
74
+ }
75
+ };
76
+ }
77
+ connectedCallback() {
78
+ super.connectedCallback();
79
+ this.setAttribute('role', 'link');
80
+ this.addEventListener('click', this.handleNavigation);
81
+ this.addEventListener('keydown', this.handleNavigation);
82
+ }
83
+ disconnectedCallback() {
84
+ super.disconnectedCallback();
85
+ this.removeEventListener('click', this.handleNavigation);
86
+ this.removeEventListener('keydown', this.handleNavigation);
87
+ }
88
+ /**
89
+ * Sets or removes `aria-disabled` and updates `tabIndex` to reflect
90
+ * the disabled state. When disabled, the element becomes unfocusable;
91
+ * when enabled, the previous `tabIndex` is restored.
92
+ *
93
+ * @param disabled - Whether the element should be disabled
94
+ */
95
+ setDisabled(disabled) {
96
+ if (disabled) {
97
+ this.setAttribute('aria-disabled', 'true');
98
+ this.prevTabindex = this.tabIndex;
99
+ this.tabIndex = -1;
100
+ }
101
+ else {
102
+ if (this.tabIndex === -1) {
103
+ this.tabIndex = this.prevTabindex;
104
+ }
105
+ this.removeAttribute('aria-disabled');
106
+ }
107
+ }
108
+ update(changedProperties) {
109
+ super.update(changedProperties);
110
+ if (changedProperties.has('disabled')) {
111
+ this.setDisabled(this.disabled);
112
+ }
113
+ }
114
+ render() {
115
+ return html `
116
+ <slot></slot>
117
+ `;
118
+ }
119
+ }
120
+ Linksimple.styles = [...Component.styles, ...styles];
121
+ __decorate([
122
+ property({ type: Boolean, reflect: true }),
123
+ __metadata("design:type", Boolean)
124
+ ], Linksimple.prototype, "inline", void 0);
125
+ __decorate([
126
+ property({ type: Boolean, reflect: true }),
127
+ __metadata("design:type", Boolean)
128
+ ], Linksimple.prototype, "inverted", void 0);
129
+ __decorate([
130
+ property({ type: String, reflect: true }),
131
+ __metadata("design:type", Object)
132
+ ], Linksimple.prototype, "href", void 0);
133
+ __decorate([
134
+ property({ type: String, reflect: true }),
135
+ __metadata("design:type", Object)
136
+ ], Linksimple.prototype, "target", void 0);
137
+ __decorate([
138
+ property({ type: String, reflect: true }),
139
+ __metadata("design:type", String)
140
+ ], Linksimple.prototype, "rel", void 0);
141
+ export default Linksimple;
@@ -0,0 +1,6 @@
1
+ declare const TAG_NAME: "mdc-linksimple";
2
+ declare const DEFAULTS: {
3
+ INLINE: boolean;
4
+ INVERTED: boolean;
5
+ };
6
+ export { DEFAULTS, TAG_NAME };
@@ -0,0 +1,7 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('linksimple');
3
+ const DEFAULTS = {
4
+ INLINE: false,
5
+ INVERTED: false,
6
+ };
7
+ export { DEFAULTS, TAG_NAME };
@@ -0,0 +1,2 @@
1
+ declare const styles: import("lit").CSSResult[];
2
+ export default styles;
@@ -0,0 +1,72 @@
1
+ import { css } from 'lit';
2
+ import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
3
+ const styles = [hostFitContentStyles, css `
4
+ :host {
5
+ --mdc-link-border-radius: 0.25rem;
6
+ --mdc-link-color-active: var(--mds-color-theme-text-accent-active);
7
+ --mdc-link-color-disabled: var(--mds-color-theme-text-primary-disabled);
8
+ --mdc-link-color-hover: var(--mds-color-theme-text-accent-hover);
9
+ --mdc-link-color-normal: var(--mds-color-theme-text-accent-normal);
10
+ --mdc-link-inverted-color-active: var(--mds-color-theme-inverted-text-accent-active);
11
+ --mdc-link-inverted-color-disabled: var(--mds-color-theme-inverted-text-primary-disabled);
12
+ --mdc-link-inverted-color-hover: var(--mds-color-theme-inverted-text-accent-hover);
13
+ --mdc-link-inverted-color-normal: var(--mds-color-theme-inverted-text-accent-normal);
14
+
15
+ border-radius: var(--mdc-link-border-radius);
16
+ color: var(--mdc-link-color-normal);
17
+ text-underline-offset: auto;
18
+ text-underline-position: from-font;
19
+ cursor: pointer;
20
+
21
+ /* based on default linksimple size (large) */
22
+ line-height: var(--mds-font-apps-body-large-regular-line-height);
23
+ }
24
+
25
+ :host([inline]) {
26
+ display: inline-flex;
27
+ }
28
+
29
+ :host([inverted]) {
30
+ color: var(--mdc-link-inverted-color-normal);
31
+ }
32
+
33
+ :host(:hover) {
34
+ color: var(--mdc-link-color-hover);
35
+ }
36
+
37
+ :host(:active) {
38
+ color: var(--mdc-link-color-active);
39
+ box-shadow: none;
40
+ }
41
+
42
+ :host([inverted]:hover) {
43
+ color: var(--mdc-link-inverted-color-hover);
44
+ }
45
+
46
+ :host([inverted]:active) {
47
+ color: var(--mdc-link-inverted-color-active);
48
+ }
49
+
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
+ /* based on default linksimple size (large) */
60
+ :host(:hover),
61
+ :host(:active),
62
+ :host([inline]) {
63
+ font-size: var(--mds-font-apps-body-large-regular-underline-font-size);
64
+ font-weight: var(--mds-font-apps-body-large-regular-underline-font-weight);
65
+ line-height: var(--mds-font-apps-body-large-regular-underline-line-height);
66
+ text-decoration: var(--mds-font-apps-body-large-regular-underline-text-decoration);
67
+ text-transform: var(--mds-font-apps-body-large-regular-underline-text-case);
68
+ }
69
+
70
+ `, ...hostFocusRingStyles(),
71
+ ];
72
+ export default styles;