@momentum-design/components 0.58.0 → 0.58.1

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/index.d.ts CHANGED
@@ -44,6 +44,7 @@ import Tooltip from './components/tooltip';
44
44
  import ToggleTip from './components/toggletip';
45
45
  import VirtualizedList from './components/virtualizedlist';
46
46
  import TabList from './components/tablist';
47
+ import ButtonLink from './components/buttonlink';
47
48
  import Linksimple from './components/linksimple';
48
49
  import type { BadgeType } from './components/badge/badge.types';
49
50
  import type { ButtonColor, ButtonVariant, IconButtonSize, PillButtonSize } from './components/button/button.types';
@@ -52,6 +53,6 @@ import type { SpinnerSize, SpinnerVariant } from './components/spinner/spinner.t
52
53
  import type { TextType } from './components/text/text.types';
53
54
  import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
54
55
  import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from './components/button/button.constants';
55
- export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, StaticToggle, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, Linksimple, };
56
+ export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, StaticToggle, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, ButtonLink, Linksimple, };
56
57
  export type { TextType, SpinnerSize, SpinnerVariant, PopoverPlacement, BadgeType, IconButtonSize, PillButtonSize, ButtonVariant, ButtonColor, };
57
58
  export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES };
package/dist/index.js CHANGED
@@ -45,11 +45,12 @@ import Tooltip from './components/tooltip';
45
45
  import ToggleTip from './components/toggletip';
46
46
  import VirtualizedList from './components/virtualizedlist';
47
47
  import TabList from './components/tablist';
48
+ import ButtonLink from './components/buttonlink';
48
49
  import Linksimple from './components/linksimple';
49
50
  import { inMemoryCache, webAPIIconsCache } from './utils/icon-cache';
50
51
  // Constants / Utils Imports
51
52
  import { BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from './components/button/button.constants';
52
53
  // Components Exports
53
- export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, StaticToggle, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, Linksimple, };
54
+ export { AlertChip, Avatar, AvatarButton, Badge, Bullet, Button, Checkbox, Chip, Coachmark, Divider, FilterChip, FormfieldGroup, Icon, IconProvider, Input, InputChip, Link, List, ListItem, Marker, Popover, Presence, Radio, RadioGroup, Spinner, Tab, Text, ThemeProvider, Toggle, VirtualizedList, Option, OptGroup, Progressbar, ScreenreaderAnnouncer, StaticCheckbox, StaticRadio, StaticToggle, Textarea, ToggleTip, Tooltip, Searchfield, Brandvisual, Appheader, Select, TabList, Progressspinner, ButtonLink, Linksimple, };
54
55
  // Constants / Utils Exports
55
56
  export { inMemoryCache, webAPIIconsCache, BUTTON_COLORS, BUTTON_VARIANTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES };
@@ -0,0 +1,30 @@
1
+ import { type EventName } from '@lit/react';
2
+ import Component from '../../components/buttonlink';
3
+ /**
4
+ * `mdc-buttonlink` combines the functional behavior of `mdc-linksimple` with the visual and structural
5
+ * features of `mdc-button`. This includes support for variants, sizing, and optional
6
+ * prefix and postfix icons via slots.
7
+ *
8
+ * ### Features:
9
+ * - Behaves like an link while visually resembling a button.
10
+ * - Supports slots for `prefix-icon` and `postfix-icon`.
11
+ * - Customizable size, color, and variant through attributes.
12
+ * - Inherits accessibility and keyboard interaction support from `mdc-linksimple`.
13
+ *
14
+ * @dependency mdc-icon
15
+ *
16
+ * @tagname mdc-buttonlink
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
+ */
24
+ declare const reactWrapper: import("@lit/react").ReactWebComponent<Component, {
25
+ onClick: EventName<MouseEvent>;
26
+ onKeyDown: EventName<KeyboardEvent>;
27
+ onFocus: EventName<FocusEvent>;
28
+ onBlur: EventName<Event>;
29
+ }>;
30
+ export default reactWrapper;
@@ -0,0 +1,38 @@
1
+ import * as React from 'react';
2
+ import { createComponent } from '@lit/react';
3
+ import Component from '../../components/buttonlink';
4
+ import { TAG_NAME } from '../../components/buttonlink/buttonlink.constants';
5
+ /**
6
+ * `mdc-buttonlink` combines the functional behavior of `mdc-linksimple` with the visual and structural
7
+ * features of `mdc-button`. This includes support for variants, sizing, and optional
8
+ * prefix and postfix icons via slots.
9
+ *
10
+ * ### Features:
11
+ * - Behaves like an link while visually resembling a button.
12
+ * - Supports slots for `prefix-icon` and `postfix-icon`.
13
+ * - Customizable size, color, and variant through attributes.
14
+ * - Inherits accessibility and keyboard interaction support from `mdc-linksimple`.
15
+ *
16
+ * @dependency mdc-icon
17
+ *
18
+ * @tagname mdc-buttonlink
19
+ *
20
+ * @event click - (React: onClick) Fired when the user activates the buttonLink using a mouse or assistive technology.
21
+ * @event keydown - (React: onKeyDown) Fired when the user presses a key while the buttonLink has focus.
22
+ * @event focus - (React: onFocus) Fired when the buttonLink receives keyboard or mouse focus.
23
+ * @event blur - (React: onBlur) Fired when the buttonLink loses keyboard or mouse focus.
24
+ *
25
+ */
26
+ const reactWrapper = createComponent({
27
+ tagName: TAG_NAME,
28
+ elementClass: Component,
29
+ react: React,
30
+ events: {
31
+ onClick: 'click',
32
+ onKeyDown: 'keydown',
33
+ onFocus: 'focus',
34
+ onBlur: 'blur',
35
+ },
36
+ displayName: 'ButtonLink',
37
+ });
38
+ export default reactWrapper;
@@ -6,6 +6,7 @@ export { default as Badge } from './badge';
6
6
  export { default as Brandvisual } from './brandvisual';
7
7
  export { default as Bullet } from './bullet';
8
8
  export { default as Button } from './button';
9
+ export { default as ButtonLink } from './buttonlink';
9
10
  export { default as Buttonsimple } from './buttonsimple';
10
11
  export { default as Checkbox } from './checkbox';
11
12
  export { default as Chip } from './chip';
@@ -6,6 +6,7 @@ export { default as Badge } from './badge';
6
6
  export { default as Brandvisual } from './brandvisual';
7
7
  export { default as Bullet } from './bullet';
8
8
  export { default as Button } from './button';
9
+ export { default as ButtonLink } from './buttonlink';
9
10
  export { default as Buttonsimple } from './buttonsimple';
10
11
  export { default as Checkbox } from './checkbox';
11
12
  export { default as Chip } from './chip';
@@ -0,0 +1,16 @@
1
+ import type { ButtonColor, ButtonTypeInternal, ButtonVariant, IconButtonSize, PillButtonSize } from '../../components/button/button.types';
2
+ import type { IconNames } from '../../components/icon/icon.types';
3
+ import type { Component } from '../../models';
4
+ import type { Constructor } from './index.types';
5
+ export interface ButtonComponentMixinInterface {
6
+ prefixIcon?: IconNames;
7
+ postfixIcon?: IconNames;
8
+ variant: ButtonVariant;
9
+ color: ButtonColor;
10
+ typeInternal: ButtonTypeInternal;
11
+ setSize(size: PillButtonSize | IconButtonSize): void;
12
+ setVariant(variant: ButtonVariant): void;
13
+ setColor(color: ButtonColor): void;
14
+ inferButtonType(): void;
15
+ }
16
+ export declare const ButtonComponentMixin: <T extends Constructor<Component>>(superClass: T) => Constructor<ButtonComponentMixinInterface> & T;
@@ -0,0 +1,114 @@
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 { property, state } from 'lit/decorators.js';
11
+ import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, DEFAULTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES } from '../../components/button/button.constants';
12
+ export const ButtonComponentMixin = (superClass) => {
13
+ class InnerMixinClass extends superClass {
14
+ constructor() {
15
+ super(...arguments);
16
+ /**
17
+ * There are 3 variants of button: primary, secondary, tertiary. They are styled differently.
18
+ * - **Primary**: Solid background color.
19
+ * - **Secondary**: Transparent background with a solid border.
20
+ * - **Tertiary**: No background or border, appears as plain text but retains all button functionalities.
21
+ * @default primary
22
+ */
23
+ this.variant = DEFAULTS.VARIANT;
24
+ /**
25
+ * There are 5 colors for button: positive, negative, accent, promotional, default.
26
+ * @default default
27
+ */
28
+ this.color = DEFAULTS.COLOR;
29
+ /** @internal */
30
+ this.typeInternal = DEFAULTS.TYPE_INTERNAL;
31
+ }
32
+ /**
33
+ * Sets the variant attribute for the button component.
34
+ * If the provided variant is not included in the BUTTON_VARIANTS,
35
+ * it defaults to the value specified in DEFAULTS.VARIANT.
36
+ *
37
+ * @param variant - The variant to set.
38
+ */
39
+ setVariant(variant) {
40
+ this.setAttribute('variant', Object.values(BUTTON_VARIANTS).includes(variant) ? variant : DEFAULTS.VARIANT);
41
+ }
42
+ /**
43
+ * Sets the color attribute for the button.
44
+ * Defaults to DEFAULTS.COLOR if invalid or for tertiary button.
45
+ *
46
+ * @param color - The color to set.
47
+ */
48
+ setColor(color) {
49
+ if (!Object.values(BUTTON_COLORS).includes(color) || this.variant === BUTTON_VARIANTS.TERTIARY) {
50
+ this.setAttribute('color', `${DEFAULTS.COLOR}`);
51
+ }
52
+ else {
53
+ this.setAttribute('color', color);
54
+ }
55
+ }
56
+ /**
57
+ * Sets the size attribute for the button component.
58
+ * Validates the size based on the button type (icon, pill, or tertiary).
59
+ * Defaults to DEFAULTS.SIZE if invalid.
60
+ *
61
+ * @param size - The size to set.
62
+ */
63
+ setSize(size) {
64
+ const isIconType = this.typeInternal === BUTTON_TYPE_INTERNAL.ICON;
65
+ const isValidSize = isIconType
66
+ ? Object.values(ICON_BUTTON_SIZES).includes(size)
67
+ && !(size === ICON_BUTTON_SIZES[20] && this.variant !== BUTTON_VARIANTS.TERTIARY)
68
+ : Object.values(PILL_BUTTON_SIZES).includes(size);
69
+ this.setAttribute('size', isValidSize ? `${size}` : `${DEFAULTS.SIZE}`);
70
+ }
71
+ /**
72
+ * Infers the type of button based on the presence of slot and/or prefix and postfix icons.
73
+ * @param slot - default slot of button
74
+ */
75
+ inferButtonType() {
76
+ var _a, _b;
77
+ const slot = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot')) === null || _b === void 0 ? void 0 : _b.assignedNodes().filter((node) => { var _a; return node.nodeType !== Node.TEXT_NODE || ((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim()); }).length;
78
+ if (slot && (this.prefixIcon || this.postfixIcon)) {
79
+ this.typeInternal = BUTTON_TYPE_INTERNAL.PILL_WITH_ICON;
80
+ this.setAttribute('data-btn-type', 'pill-with-icon');
81
+ }
82
+ else if (!slot && (this.prefixIcon || this.postfixIcon)) {
83
+ this.typeInternal = BUTTON_TYPE_INTERNAL.ICON;
84
+ this.setAttribute('data-btn-type', 'icon');
85
+ }
86
+ else {
87
+ this.typeInternal = BUTTON_TYPE_INTERNAL.PILL;
88
+ this.setAttribute('data-btn-type', 'pill');
89
+ }
90
+ }
91
+ }
92
+ __decorate([
93
+ property({ type: String, attribute: 'prefix-icon', reflect: true }),
94
+ __metadata("design:type", String)
95
+ ], InnerMixinClass.prototype, "prefixIcon", void 0);
96
+ __decorate([
97
+ property({ type: String, attribute: 'postfix-icon', reflect: true }),
98
+ __metadata("design:type", String)
99
+ ], InnerMixinClass.prototype, "postfixIcon", void 0);
100
+ __decorate([
101
+ property({ type: String }),
102
+ __metadata("design:type", String)
103
+ ], InnerMixinClass.prototype, "variant", void 0);
104
+ __decorate([
105
+ property({ type: String }),
106
+ __metadata("design:type", String)
107
+ ], InnerMixinClass.prototype, "color", void 0);
108
+ __decorate([
109
+ state(),
110
+ __metadata("design:type", String)
111
+ ], InnerMixinClass.prototype, "typeInternal", void 0);
112
+ // Cast return type to your mixin's interface intersected with the superClass type
113
+ return InnerMixinClass;
114
+ };
package/package.json CHANGED
@@ -39,5 +39,5 @@
39
39
  "lit": "^3.2.0",
40
40
  "uuid": "^11.0.5"
41
41
  },
42
- "version": "0.58.0"
42
+ "version": "0.58.1"
43
43
  }