@momentum-design/components 0.74.4 → 0.75.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.
@@ -0,0 +1,53 @@
1
+ import { CSSResult, PropertyValues } from 'lit';
2
+ import { Component } from '../../models';
3
+ import type { ButtonGroupOrientation, ButtonGroupSize, ButtonGroupVariant } from './buttongroup.types';
4
+ /**
5
+ * buttongroup component, is a styled wrapper for multiple buttons.
6
+ * It can support icon buttons, combination of icon and pill buttons, and text buttons.
7
+ * They are available in horizontal and vertical orientation.
8
+ *
9
+ * @tagname mdc-buttongroup
10
+ *
11
+ * @slot default - This is a default/unnamed slot, which contains the buttons
12
+ *
13
+ * @cssproperty --mdc-buttongroup-border-radius - The border radius of the buttongroup
14
+ * @cssproperty --mdc-buttongroup-border-color - The border color of the buttongroup
15
+ * @cssproperty --mdc-buttongroup-divider-color - The color of the divider between buttons within the buttongroup
16
+ */
17
+ declare class ButtonGroup extends Component {
18
+ /**
19
+ * Orientation of the buttongroup.
20
+ * @default 'horizontal'
21
+ */
22
+ orientation: ButtonGroupOrientation;
23
+ /**
24
+ * Variant of the buttons within the buttongroup.
25
+ * @default 'primary'
26
+ */
27
+ variant: ButtonGroupVariant;
28
+ /**
29
+ * Size of the buttons within the buttongroup.
30
+ * @default '28'
31
+ */
32
+ size: ButtonGroupSize;
33
+ /**
34
+ * When this is true, the buttons within the buttongroup will be compact.
35
+ * i.e. Irrespective of the size of the buttons, they will have a height of 24px.
36
+ * @default false
37
+ */
38
+ compact: boolean;
39
+ /**
40
+ * List of buttons passed into the slot
41
+ * @internal
42
+ */
43
+ private buttons;
44
+ /**
45
+ * Handles the slotchange event, setting the size and variant of the buttons
46
+ * @internal
47
+ */
48
+ private handleSlotChange;
49
+ updated(changedProperties: PropertyValues<ButtonGroup>): void;
50
+ render(): import("lit-html").TemplateResult<1>;
51
+ static styles: Array<CSSResult>;
52
+ }
53
+ export default ButtonGroup;
@@ -0,0 +1,94 @@
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, queryAssignedElements } from 'lit/decorators.js';
12
+ import { Component } from '../../models';
13
+ import { DEFAULTS } from './buttongroup.constants';
14
+ import styles from './buttongroup.styles';
15
+ /**
16
+ * buttongroup component, is a styled wrapper for multiple buttons.
17
+ * It can support icon buttons, combination of icon and pill buttons, and text buttons.
18
+ * They are available in horizontal and vertical orientation.
19
+ *
20
+ * @tagname mdc-buttongroup
21
+ *
22
+ * @slot default - This is a default/unnamed slot, which contains the buttons
23
+ *
24
+ * @cssproperty --mdc-buttongroup-border-radius - The border radius of the buttongroup
25
+ * @cssproperty --mdc-buttongroup-border-color - The border color of the buttongroup
26
+ * @cssproperty --mdc-buttongroup-divider-color - The color of the divider between buttons within the buttongroup
27
+ */
28
+ class ButtonGroup extends Component {
29
+ constructor() {
30
+ super(...arguments);
31
+ /**
32
+ * Orientation of the buttongroup.
33
+ * @default 'horizontal'
34
+ */
35
+ this.orientation = DEFAULTS.ORIENTATION;
36
+ /**
37
+ * Variant of the buttons within the buttongroup.
38
+ * @default 'primary'
39
+ */
40
+ this.variant = DEFAULTS.VARIANT;
41
+ /**
42
+ * Size of the buttons within the buttongroup.
43
+ * @default '28'
44
+ */
45
+ this.size = DEFAULTS.SIZE;
46
+ /**
47
+ * When this is true, the buttons within the buttongroup will be compact.
48
+ * i.e. Irrespective of the size of the buttons, they will have a height of 24px.
49
+ * @default false
50
+ */
51
+ this.compact = false;
52
+ }
53
+ /**
54
+ * Handles the slotchange event, setting the size and variant of the buttons
55
+ * @internal
56
+ */
57
+ handleSlotChange() {
58
+ this.buttons.forEach((button) => {
59
+ button.setAttribute('size', this.size.toString());
60
+ button.setAttribute('variant', this.variant);
61
+ });
62
+ }
63
+ updated(changedProperties) {
64
+ super.updated(changedProperties);
65
+ if (changedProperties.has('size') || changedProperties.has('variant')) {
66
+ this.handleSlotChange();
67
+ }
68
+ }
69
+ render() {
70
+ return html `<slot @slotchange=${this.handleSlotChange}></slot>`;
71
+ }
72
+ }
73
+ ButtonGroup.styles = [...Component.styles, ...styles];
74
+ __decorate([
75
+ property({ type: String, reflect: true }),
76
+ __metadata("design:type", String)
77
+ ], ButtonGroup.prototype, "orientation", void 0);
78
+ __decorate([
79
+ property({ type: String, reflect: true }),
80
+ __metadata("design:type", String)
81
+ ], ButtonGroup.prototype, "variant", void 0);
82
+ __decorate([
83
+ property({ type: Number, reflect: true }),
84
+ __metadata("design:type", Number)
85
+ ], ButtonGroup.prototype, "size", void 0);
86
+ __decorate([
87
+ property({ type: Boolean, reflect: true }),
88
+ __metadata("design:type", Object)
89
+ ], ButtonGroup.prototype, "compact", void 0);
90
+ __decorate([
91
+ queryAssignedElements({ selector: 'mdc-button' }),
92
+ __metadata("design:type", Array)
93
+ ], ButtonGroup.prototype, "buttons", void 0);
94
+ export default ButtonGroup;
@@ -0,0 +1,21 @@
1
+ declare const TAG_NAME: "mdc-buttongroup";
2
+ declare const BUTTON_GROUP_SIZE: {
3
+ readonly 40: 40;
4
+ readonly 32: 32;
5
+ readonly 28: 28;
6
+ readonly 24: 24;
7
+ };
8
+ declare const BUTTON_GROUP_ORIENTATION: {
9
+ readonly HORIZONTAL: "horizontal";
10
+ readonly VERTICAL: "vertical";
11
+ };
12
+ declare const BUTTON_GROUP_VARIANT: {
13
+ readonly PRIMARY: "primary";
14
+ readonly SECONDARY: "secondary";
15
+ };
16
+ declare const DEFAULTS: {
17
+ SIZE: 28;
18
+ VARIANT: "primary";
19
+ ORIENTATION: "horizontal";
20
+ };
21
+ export { TAG_NAME, DEFAULTS, BUTTON_GROUP_SIZE, BUTTON_GROUP_ORIENTATION, BUTTON_GROUP_VARIANT };
@@ -0,0 +1,22 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('buttongroup');
3
+ const BUTTON_GROUP_SIZE = {
4
+ 40: 40,
5
+ 32: 32,
6
+ 28: 28,
7
+ 24: 24,
8
+ };
9
+ const BUTTON_GROUP_ORIENTATION = {
10
+ HORIZONTAL: 'horizontal',
11
+ VERTICAL: 'vertical',
12
+ };
13
+ const BUTTON_GROUP_VARIANT = {
14
+ PRIMARY: 'primary',
15
+ SECONDARY: 'secondary',
16
+ };
17
+ const DEFAULTS = {
18
+ SIZE: BUTTON_GROUP_SIZE[28],
19
+ VARIANT: BUTTON_GROUP_VARIANT.PRIMARY,
20
+ ORIENTATION: BUTTON_GROUP_ORIENTATION.HORIZONTAL,
21
+ };
22
+ export { TAG_NAME, DEFAULTS, BUTTON_GROUP_SIZE, BUTTON_GROUP_ORIENTATION, BUTTON_GROUP_VARIANT };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,81 @@
1
+ import { css } from 'lit';
2
+ import { hostFitContentStyles } from '../../utils/styles';
3
+ const styles = css `
4
+ :host{
5
+ --mdc-buttongroup-border-radius: 1.25rem;
6
+ --mdc-buttongroup-border-color: var(--mds-color-theme-outline-button-normal);
7
+ --mdc-buttongroup-divider-color: var(--mds-color-theme-outline-secondary-normal);
8
+
9
+ border-radius: var(--mdc-buttongroup-border-radius);
10
+ border: 1px solid var(--mdc-buttongroup-border-color);
11
+ }
12
+
13
+ :host([variant='primary']){
14
+ border: none;
15
+ background-color: var(--mds-color-theme-outline-primary-normal);
16
+ gap: 1px;
17
+ }
18
+
19
+ ::slotted(mdc-button){
20
+ border-radius: 0;
21
+ border: none;
22
+ box-sizing: content-box;
23
+ }
24
+
25
+ :host([orientation="vertical"]){
26
+ flex-direction: column;
27
+ }
28
+
29
+ :host([orientation="horizontal"][variant="secondary"]:dir(ltr)) ::slotted(mdc-button:not(:last-child)){
30
+ border-right: 1px solid var(--mdc-buttongroup-divider-color);
31
+ }
32
+ :host([orientation="horizontal"][variant="secondary"]:dir(rtl)) ::slotted(mdc-button:not(:last-child)){
33
+ border-left: 1px solid var(--mdc-buttongroup-divider-color);
34
+ }
35
+ :host([orientation="vertical"][variant="secondary"]) ::slotted(mdc-button:not(:last-child)){
36
+ border-bottom: 1px solid var(--mdc-buttongroup-divider-color);
37
+ }
38
+
39
+ :host([orientation="vertical"]) ::slotted(mdc-button:first-child){
40
+ border-top-left-radius: var(--mdc-buttongroup-border-radius);
41
+ border-top-right-radius: var(--mdc-buttongroup-border-radius);
42
+ }
43
+ :host([orientation="vertical"]) ::slotted(mdc-button:last-child){
44
+ border-bottom-left-radius: var(--mdc-buttongroup-border-radius);
45
+ border-bottom-right-radius: var(--mdc-buttongroup-border-radius);
46
+ }
47
+
48
+ :host([orientation="horizontal"]:dir(ltr)) ::slotted(mdc-button:first-child){
49
+ border-top-left-radius: var(--mdc-buttongroup-border-radius);
50
+ border-bottom-left-radius: var(--mdc-buttongroup-border-radius);
51
+ }
52
+ :host([orientation="horizontal"]:dir(rtl)) ::slotted(mdc-button:first-child){
53
+ border-top-right-radius: var(--mdc-buttongroup-border-radius);
54
+ border-bottom-right-radius: var(--mdc-buttongroup-border-radius);
55
+ }
56
+ :host([orientation="horizontal"]:dir(ltr)) ::slotted(mdc-button:last-child){
57
+ border-top-right-radius: var(--mdc-buttongroup-border-radius);
58
+ border-bottom-right-radius: var(--mdc-buttongroup-border-radius);
59
+ }
60
+ :host([orientation="horizontal"]:dir(rtl)) ::slotted(mdc-button:last-child){
61
+ border-top-left-radius: var(--mdc-buttongroup-border-radius);
62
+ border-bottom-left-radius: var(--mdc-buttongroup-border-radius);
63
+ }
64
+
65
+ :host([compact][orientation="horizontal"]) ::slotted(mdc-button){
66
+ height: 1.5rem;
67
+ }
68
+ :host([compact][orientation="horizontal"][size="24"]) ::slotted(mdc-button){
69
+ width: 1.5rem;
70
+ }
71
+ :host([compact][orientation="horizontal"][size="28"]) ::slotted(mdc-button){
72
+ width: 1.75rem;
73
+ }
74
+ :host([compact][orientation="horizontal"][size="32"]) ::slotted(mdc-button){
75
+ width: 2rem;
76
+ }
77
+ :host([compact][orientation="horizontal"][size="40"]) ::slotted(mdc-button){
78
+ width: 2.5rem;
79
+ }
80
+ `;
81
+ export default [hostFitContentStyles, styles];
@@ -0,0 +1,6 @@
1
+ import type { ValueOf } from '../../utils/types';
2
+ import { BUTTON_GROUP_ORIENTATION, BUTTON_GROUP_SIZE, BUTTON_GROUP_VARIANT } from './buttongroup.constants';
3
+ type ButtonGroupSize = ValueOf<typeof BUTTON_GROUP_SIZE>;
4
+ type ButtonGroupOrientation = ValueOf<typeof BUTTON_GROUP_ORIENTATION>;
5
+ type ButtonGroupVariant = ValueOf<typeof BUTTON_GROUP_VARIANT>;
6
+ export type { ButtonGroupSize, ButtonGroupOrientation, ButtonGroupVariant };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import ButtonGroup from './buttongroup.component';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ ['mdc-buttongroup']: ButtonGroup;
5
+ }
6
+ }
7
+ export default ButtonGroup;
@@ -0,0 +1,4 @@
1
+ import ButtonGroup from './buttongroup.component';
2
+ import { TAG_NAME } from './buttongroup.constants';
3
+ ButtonGroup.register(TAG_NAME);
4
+ export default ButtonGroup;