@momentum-design/components 0.95.8 → 0.96.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.
@@ -1,5 +1,8 @@
1
1
  declare const TAG_NAME: "mdc-buttonsimple";
2
2
  declare const BUTTON_SIZES: {
3
+ readonly 12: 12;
4
+ readonly 14: 14;
5
+ readonly 16: 16;
3
6
  readonly 20: 20;
4
7
  readonly 24: 24;
5
8
  readonly 28: 28;
@@ -1,6 +1,9 @@
1
1
  import utils from '../../utils/tag-name';
2
2
  const TAG_NAME = utils.constructTagName('buttonsimple');
3
3
  const BUTTON_SIZES = {
4
+ 12: 12,
5
+ 14: 14,
6
+ 16: 16,
4
7
  20: 20,
5
8
  24: 24,
6
9
  28: 28,
@@ -0,0 +1,8 @@
1
+ import LinkButton from './linkbutton.component';
2
+ import '../icon';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ ['mdc-linkbutton']: LinkButton;
6
+ }
7
+ }
8
+ export default LinkButton;
@@ -0,0 +1,5 @@
1
+ import LinkButton from './linkbutton.component';
2
+ import { TAG_NAME } from './linkbutton.constants';
3
+ import '../icon';
4
+ LinkButton.register(TAG_NAME);
5
+ export default LinkButton;
@@ -0,0 +1,65 @@
1
+ import { CSSResult, PropertyValues } from 'lit';
2
+ import Buttonsimple from '../buttonsimple/buttonsimple.component';
3
+ import type { LinkButtonSize } from './linkbutton.types';
4
+ declare const LinkButton_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof Buttonsimple;
5
+ /**
6
+ * `mdc-linkbutton` visually mimics a hyperlink while functioning as a button. It blends the appearance of `mdc-link` with the accessibility and interaction capabilities of `mdc-button`.
7
+ *
8
+ * ### Features:
9
+ * - Looks like a link, behaves like a button.
10
+ * - Supports slots for a text label and an optional trailing icon.
11
+ * - Inherits accessibility and keyboard interaction behavior from `mdc-buttonsimple`.
12
+ *
13
+ * @dependency mdc-icon
14
+ *
15
+ * @tagname mdc-linkbutton
16
+ *
17
+ * @slot - Text label of the linkbutton.
18
+ *
19
+ * @event click - (React: onClick) This event is dispatched when the linkbutton is clicked.
20
+ * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the linkbutton.
21
+ * @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the linkbutton.
22
+ * @event focus - (React: onFocus) This event is dispatched when the linkbutton receives focus.
23
+ *
24
+ * @cssproperty --mdc-link-border-radius - Border radius of the linkbutton.
25
+ * @cssproperty --mdc-link-color-active - Color of the linkbutton’s child content in the active state.
26
+ * @cssproperty --mdc-link-color-disabled - Color of the linkbutton’s child content in the disabled state.
27
+ * @cssproperty --mdc-link-color-hover - Color of the linkbutton’s child content in the hover state.
28
+ * @cssproperty --mdc-link-color-normal - Color of the linkbutton’s child content in the normal state.
29
+ * @cssproperty --mdc-link-inverted-color-active - Color of the inverted linkbutton’s child content in the active state.
30
+ * @cssproperty --mdc-link-inverted-color-disabled - Color of the inverted linkbutton’s child content in the disabled state.
31
+ * @cssproperty --mdc-link-inverted-color-hover - Color of the inverted linkbutton’s child content in the hover state.
32
+ * @cssproperty --mdc-link-inverted-color-normal - Color of the inverted linkbutton’s child content in the normal state.
33
+ */
34
+ declare class LinkButton extends LinkButton_base {
35
+ /**
36
+ * Sets the size of the linkbutton.
37
+ * Acceptable values:
38
+ * - 12
39
+ * - 14
40
+ * - 16
41
+ * @default 16
42
+ */
43
+ size: LinkButtonSize;
44
+ /**
45
+ * The linkbutton can be inline or standalone.
46
+ * @default false
47
+ */
48
+ inline: boolean;
49
+ /**
50
+ * The linkbutton color can be inverted by setting the inverted attribute to true.
51
+ * @default false
52
+ */
53
+ inverted: boolean;
54
+ connectedCallback(): void;
55
+ update(changedProperties: PropertyValues): void;
56
+ /**
57
+ * Sets the `size` attribute for the linkbutton, falling back to the default if the value is invalid.
58
+ *
59
+ * @param size - The desired link size.
60
+ */
61
+ private setSize;
62
+ render(): import("lit-html").TemplateResult<1>;
63
+ static styles: Array<CSSResult>;
64
+ }
65
+ export default LinkButton;
@@ -0,0 +1,111 @@
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, nothing } from 'lit';
11
+ import { property } from 'lit/decorators.js';
12
+ import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
13
+ import Buttonsimple from '../buttonsimple/buttonsimple.component';
14
+ import Link from '../link/link.component';
15
+ import { DEFAULTS, LINKBUTTON_SIZES } from './linkbutton.constants';
16
+ import { getIconSize } from './linkbutton.utils';
17
+ import styles from './linkbutton.styles';
18
+ /**
19
+ * `mdc-linkbutton` visually mimics a hyperlink while functioning as a button. It blends the appearance of `mdc-link` with the accessibility and interaction capabilities of `mdc-button`.
20
+ *
21
+ * ### Features:
22
+ * - Looks like a link, behaves like a button.
23
+ * - Supports slots for a text label and an optional trailing icon.
24
+ * - Inherits accessibility and keyboard interaction behavior from `mdc-buttonsimple`.
25
+ *
26
+ * @dependency mdc-icon
27
+ *
28
+ * @tagname mdc-linkbutton
29
+ *
30
+ * @slot - Text label of the linkbutton.
31
+ *
32
+ * @event click - (React: onClick) This event is dispatched when the linkbutton is clicked.
33
+ * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the linkbutton.
34
+ * @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the linkbutton.
35
+ * @event focus - (React: onFocus) This event is dispatched when the linkbutton receives focus.
36
+ *
37
+ * @cssproperty --mdc-link-border-radius - Border radius of the linkbutton.
38
+ * @cssproperty --mdc-link-color-active - Color of the linkbutton’s child content in the active state.
39
+ * @cssproperty --mdc-link-color-disabled - Color of the linkbutton’s child content in the disabled state.
40
+ * @cssproperty --mdc-link-color-hover - Color of the linkbutton’s child content in the hover state.
41
+ * @cssproperty --mdc-link-color-normal - Color of the linkbutton’s child content in the normal state.
42
+ * @cssproperty --mdc-link-inverted-color-active - Color of the inverted linkbutton’s child content in the active state.
43
+ * @cssproperty --mdc-link-inverted-color-disabled - Color of the inverted linkbutton’s child content in the disabled state.
44
+ * @cssproperty --mdc-link-inverted-color-hover - Color of the inverted linkbutton’s child content in the hover state.
45
+ * @cssproperty --mdc-link-inverted-color-normal - Color of the inverted linkbutton’s child content in the normal state.
46
+ */
47
+ class LinkButton extends IconNameMixin(Buttonsimple) {
48
+ constructor() {
49
+ super(...arguments);
50
+ /**
51
+ * Sets the size of the linkbutton.
52
+ * Acceptable values:
53
+ * - 12
54
+ * - 14
55
+ * - 16
56
+ * @default 16
57
+ */
58
+ this.size = DEFAULTS.SIZE;
59
+ /**
60
+ * The linkbutton can be inline or standalone.
61
+ * @default false
62
+ */
63
+ this.inline = DEFAULTS.INLINE;
64
+ /**
65
+ * The linkbutton color can be inverted by setting the inverted attribute to true.
66
+ * @default false
67
+ */
68
+ this.inverted = DEFAULTS.INVERTED;
69
+ }
70
+ connectedCallback() {
71
+ super.connectedCallback();
72
+ this.active = undefined;
73
+ this.role = DEFAULTS.ROLE;
74
+ }
75
+ update(changedProperties) {
76
+ super.update(changedProperties);
77
+ if (changedProperties.has('size')) {
78
+ this.setSize(this.size);
79
+ }
80
+ }
81
+ /**
82
+ * Sets the `size` attribute for the linkbutton, falling back to the default if the value is invalid.
83
+ *
84
+ * @param size - The desired link size.
85
+ */
86
+ setSize(size) {
87
+ this.setAttribute('size', Object.values(LINKBUTTON_SIZES).includes(size) ? `${size}` : DEFAULTS.SIZE.toString());
88
+ }
89
+ render() {
90
+ return html `
91
+ <slot></slot>
92
+ ${this.iconName
93
+ ? html ` <mdc-icon name=${this.iconName} size=${getIconSize(this.size)} length-unit="rem"></mdc-icon> `
94
+ : nothing}
95
+ `;
96
+ }
97
+ }
98
+ LinkButton.styles = [...Link.styles, ...styles];
99
+ __decorate([
100
+ property({ type: Number, reflect: true }),
101
+ __metadata("design:type", Number)
102
+ ], LinkButton.prototype, "size", void 0);
103
+ __decorate([
104
+ property({ type: Boolean, reflect: true }),
105
+ __metadata("design:type", Boolean)
106
+ ], LinkButton.prototype, "inline", void 0);
107
+ __decorate([
108
+ property({ type: Boolean, reflect: true }),
109
+ __metadata("design:type", Boolean)
110
+ ], LinkButton.prototype, "inverted", void 0);
111
+ export default LinkButton;
@@ -0,0 +1,13 @@
1
+ declare const TAG_NAME: "mdc-linkbutton";
2
+ declare const LINKBUTTON_SIZES: {
3
+ readonly 12: 12;
4
+ readonly 14: 14;
5
+ readonly 16: 16;
6
+ };
7
+ declare const DEFAULTS: {
8
+ SIZE: 16;
9
+ ROLE: "button";
10
+ INLINE: boolean;
11
+ INVERTED: boolean;
12
+ };
13
+ export { TAG_NAME, LINKBUTTON_SIZES, DEFAULTS };
@@ -0,0 +1,16 @@
1
+ import { ROLE } from '../../utils/roles';
2
+ import utils from '../../utils/tag-name';
3
+ import { DEFAULTS as LINKSIMPLE_DEFAULTS } from '../linksimple/linksimple.constants';
4
+ const TAG_NAME = utils.constructTagName('linkbutton');
5
+ const LINKBUTTON_SIZES = {
6
+ 12: 12,
7
+ 14: 14,
8
+ 16: 16,
9
+ };
10
+ const DEFAULTS = {
11
+ SIZE: LINKBUTTON_SIZES[16],
12
+ ROLE: ROLE.BUTTON,
13
+ INLINE: LINKSIMPLE_DEFAULTS.INLINE,
14
+ INVERTED: LINKSIMPLE_DEFAULTS.INVERTED,
15
+ };
16
+ export { TAG_NAME, LINKBUTTON_SIZES, DEFAULTS };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,66 @@
1
+ import { css } from 'lit';
2
+ const styles = css `
3
+ :host {
4
+ --mdc-link-color-disabled: var(--mds-color-theme-text-primary-disabled);
5
+ gap: 0.25rem;
6
+ }
7
+
8
+ :host([size='16']) {
9
+ font-size: var(--mds-font-apps-body-large-regular-font-size);
10
+ font-weight: var(--mds-font-apps-body-large-regular-font-weight);
11
+ line-height: var(--mds-font-apps-body-large-regular-line-height);
12
+ text-decoration: var(--mds-font-apps-body-large-regular-text-decoration);
13
+ text-transform: var(--mds-font-apps-body-large-regular-text-case);
14
+ }
15
+
16
+ :host([size='14']) {
17
+ font-size: var(--mds-font-apps-body-midsize-regular-font-size);
18
+ font-weight: var(--mds-font-apps-body-midsize-regular-font-weight);
19
+ line-height: var(--mds-font-apps-body-midsize-regular-line-height);
20
+ text-decoration: var(--mds-font-apps-body-midsize-regular-text-decoration);
21
+ text-transform: var(--mds-font-apps-body-midsize-regular-text-case);
22
+ }
23
+
24
+ :host([size='12']) {
25
+ font-size: var(--mds-font-apps-body-small-regular-font-size);
26
+ font-weight: var(--mds-font-apps-body-small-regular-font-weight);
27
+ line-height: var(--mds-font-apps-body-small-regular-line-height);
28
+ text-decoration: var(--mds-font-apps-body-small-regular-text-decoration);
29
+ text-transform: var(--mds-font-apps-body-small-regular-text-case);
30
+ }
31
+
32
+ :host([size='16']:hover),
33
+ :host([size='16']:active),
34
+ :host([size='16'][inline]) {
35
+ font-size: var(--mds-font-apps-body-large-regular-underline-font-size);
36
+ font-weight: var(--mds-font-apps-body-large-regular-underline-font-weight);
37
+ line-height: var(--mds-font-apps-body-large-regular-underline-line-height);
38
+ text-decoration: var(--mds-font-apps-body-large-regular-underline-text-decoration);
39
+ text-transform: var(--mds-font-apps-body-large-regular-underline-text-case);
40
+ }
41
+
42
+ :host([size='14']:hover),
43
+ :host([size='14']:active),
44
+ :host([size='14'][inline]) {
45
+ font-size: var(--mds-font-apps-body-midsize-regular-underline-font-size);
46
+ font-weight: var(--mds-font-apps-body-midsize-regular-underline-font-weight);
47
+ line-height: var(--mds-font-apps-body-midsize-regular-underline-line-height);
48
+ text-decoration: var(--mds-font-apps-body-midsize-regular-underline-text-decoration);
49
+ text-transform: var(--mds-font-apps-body-midsize-regular-underline-text-case);
50
+ }
51
+
52
+ :host([size='12']:hover),
53
+ :host([size='12']:active),
54
+ :host([size='12'][inline]) {
55
+ font-size: var(--mds-font-apps-body-small-regular-underline-font-size);
56
+ font-weight: var(--mds-font-apps-body-small-regular-underline-font-weight);
57
+ line-height: var(--mds-font-apps-body-small-regular-underline-line-height);
58
+ text-decoration: var(--mds-font-apps-body-small-regular-underline-text-decoration);
59
+ text-transform: var(--mds-font-apps-body-small-regular-underline-text-case);
60
+ }
61
+
62
+ :host([soft-disabled]) {
63
+ color: var(--mdc-link-color-disabled);
64
+ }
65
+ `;
66
+ export default [styles];
@@ -0,0 +1,10 @@
1
+ import type { ValueOf } from '../../utils/types';
2
+ import { LINKBUTTON_SIZES } from './linkbutton.constants';
3
+ type LinkButtonSize = ValueOf<typeof LINKBUTTON_SIZES>;
4
+ interface Events {
5
+ onClickEvent: MouseEvent;
6
+ onKeyDownEvent: KeyboardEvent;
7
+ onFocusEvent: FocusEvent;
8
+ onBlurEvent: Event;
9
+ }
10
+ export type { Events, LinkButtonSize };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { LinkButtonSize } from "./linkbutton.types";
2
+ declare const getIconSize: (size: LinkButtonSize) => number;
3
+ export { getIconSize };
@@ -0,0 +1,12 @@
1
+ import { LINKBUTTON_SIZES } from "./linkbutton.constants";
2
+ const getIconSize = (size) => {
3
+ switch (size) {
4
+ case LINKBUTTON_SIZES[12]:
5
+ return 0.75;
6
+ case LINKBUTTON_SIZES[14]:
7
+ return 0.875;
8
+ default:
9
+ return 1;
10
+ }
11
+ };
12
+ export { getIconSize };