@momentum-design/components 0.57.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.
Files changed (41) hide show
  1. package/dist/browser/index.js +304 -283
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/button/button.component.d.ts +3 -56
  4. package/dist/components/button/button.component.js +3 -96
  5. package/dist/components/buttonlink/buttonlink.component.d.ts +59 -0
  6. package/dist/components/buttonlink/buttonlink.component.js +106 -0
  7. package/dist/components/buttonlink/buttonlink.constants.d.ts +2 -0
  8. package/dist/components/buttonlink/buttonlink.constants.js +3 -0
  9. package/dist/components/buttonlink/buttonlink.types.d.ts +7 -0
  10. package/dist/components/buttonlink/buttonlink.types.js +1 -0
  11. package/dist/components/buttonlink/index.d.ts +8 -0
  12. package/dist/components/buttonlink/index.js +5 -0
  13. package/dist/components/statictoggle/index.d.ts +8 -0
  14. package/dist/components/statictoggle/index.js +5 -0
  15. package/dist/components/statictoggle/statictoggle.component.d.ts +48 -0
  16. package/dist/components/statictoggle/statictoggle.component.js +82 -0
  17. package/dist/components/statictoggle/statictoggle.constants.d.ts +17 -0
  18. package/dist/components/statictoggle/statictoggle.constants.js +18 -0
  19. package/dist/components/statictoggle/statictoggle.styles.d.ts +2 -0
  20. package/dist/components/statictoggle/statictoggle.styles.js +82 -0
  21. package/dist/components/statictoggle/statictoggle.types.d.ts +4 -0
  22. package/dist/components/statictoggle/statictoggle.types.js +1 -0
  23. package/dist/components/toggle/index.d.ts +2 -1
  24. package/dist/components/toggle/index.js +2 -1
  25. package/dist/components/toggle/toggle.component.d.ts +16 -20
  26. package/dist/components/toggle/toggle.component.js +27 -33
  27. package/dist/components/toggle/toggle.styles.js +26 -96
  28. package/dist/custom-elements.json +1806 -828
  29. package/dist/index.d.ts +3 -1
  30. package/dist/index.js +3 -1
  31. package/dist/react/buttonlink/index.d.ts +30 -0
  32. package/dist/react/buttonlink/index.js +38 -0
  33. package/dist/react/index.d.ts +3 -1
  34. package/dist/react/index.js +3 -1
  35. package/dist/react/statictoggle/index.d.ts +30 -0
  36. package/dist/react/statictoggle/index.js +39 -0
  37. package/dist/react/toggle/index.d.ts +14 -18
  38. package/dist/react/toggle/index.js +14 -18
  39. package/dist/utils/mixins/ButtonComponentMixin.d.ts +16 -0
  40. package/dist/utils/mixins/ButtonComponentMixin.js +114 -0
  41. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  import type { PropertyValues } from 'lit';
2
2
  import { CSSResult } from 'lit';
3
3
  import Buttonsimple from '../buttonsimple/buttonsimple.component';
4
- import type { IconNames } from '../icon/icon.types';
5
- import type { ButtonColor, ButtonVariant, IconButtonSize, PillButtonSize } from './button.types';
4
+ import type { IconButtonSize, PillButtonSize } from './button.types';
5
+ declare const Button_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ButtonComponentMixin").ButtonComponentMixinInterface> & typeof Buttonsimple;
6
6
  /**
7
7
  * `mdc-button` is a component that can be configured in various ways to suit different use cases.
8
8
  *
@@ -35,25 +35,7 @@ import type { ButtonColor, ButtonVariant, IconButtonSize, PillButtonSize } from
35
35
  *
36
36
  * @slot - Text label of the button.
37
37
  */
38
- declare class Button extends Buttonsimple {
39
- /**
40
- * The name of the icon to display as a prefix.
41
- * The icon is displayed on the left side of the button.
42
- */
43
- prefixIcon?: IconNames;
44
- /**
45
- * The name of the icon to display as a postfix.
46
- * The icon is displayed on the right side of the button.
47
- */
48
- postfixIcon?: IconNames;
49
- /**
50
- * There are 3 variants of button: primary, secondary, tertiary. They are styled differently.
51
- * - **Primary**: Solid background color.
52
- * - **Secondary**: Transparent background with a solid border.
53
- * - **Tertiary**: No background or border, appears as plain text but retains all button functionalities.
54
- * @default primary
55
- */
56
- variant: ButtonVariant;
38
+ declare class Button extends Button_base {
57
39
  /**
58
40
  * Button sizing is based on the button type.
59
41
  * - **Pill button**: 40, 32, 28, 24.
@@ -62,11 +44,6 @@ declare class Button extends Buttonsimple {
62
44
  * @default 32
63
45
  */
64
46
  size: PillButtonSize | IconButtonSize;
65
- /**
66
- * There are 5 colors for button: positive, negative, accent, promotional, default.
67
- * @default default
68
- */
69
- color: ButtonColor;
70
47
  /**
71
48
  * This property defines the ARIA role for the element. By default, it is set to 'button'.
72
49
  * Consumers should override this role when:
@@ -75,8 +52,6 @@ declare class Button extends Buttonsimple {
75
52
  * @default button
76
53
  */
77
54
  role: string;
78
- /** @internal */
79
- private typeInternal;
80
55
  /**
81
56
  * @internal
82
57
  */
@@ -95,34 +70,6 @@ declare class Button extends Buttonsimple {
95
70
  * @param active - The active state.
96
71
  */
97
72
  private inferFilledIconName;
98
- /**
99
- * Sets the variant attribute for the button component.
100
- * If the provided variant is not included in the BUTTON_VARIANTS,
101
- * it defaults to the value specified in DEFAULTS.VARIANT.
102
- *
103
- * @param variant - The variant to set.
104
- */
105
- private setVariant;
106
- /**
107
- * Sets the size attribute for the button component.
108
- * Validates the size based on the button type (icon, pill, or tertiary).
109
- * Defaults to DEFAULTS.SIZE if invalid.
110
- *
111
- * @param size - The size to set.
112
- */
113
- private setSize;
114
- /**
115
- * Sets the color attribute for the button.
116
- * Defaults to DEFAULTS.COLOR if invalid or for tertiary buttons.
117
- *
118
- * @param color - The color to set.
119
- */
120
- private setColor;
121
- /**
122
- * Infers the type of button based on the presence of slot and/or prefix and postfix icons.
123
- * @param slot - default slot of button
124
- */
125
- private inferButtonType;
126
73
  render(): import("lit-html").TemplateResult<1>;
127
74
  static styles: Array<CSSResult>;
128
75
  }
@@ -9,8 +9,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { html } from 'lit';
11
11
  import { property, state } from 'lit/decorators.js';
12
+ import { ButtonComponentMixin } from '../../utils/mixins/ButtonComponentMixin';
12
13
  import Buttonsimple from '../buttonsimple/buttonsimple.component';
13
- import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, DEFAULTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from './button.constants';
14
+ import { DEFAULTS } from './button.constants';
14
15
  import styles from './button.styles';
15
16
  import { getIconNameWithoutStyle } from './button.utils';
16
17
  /**
@@ -45,17 +46,9 @@ import { getIconNameWithoutStyle } from './button.utils';
45
46
  *
46
47
  * @slot - Text label of the button.
47
48
  */
48
- class Button extends Buttonsimple {
49
+ class Button extends ButtonComponentMixin(Buttonsimple) {
49
50
  constructor() {
50
51
  super(...arguments);
51
- /**
52
- * There are 3 variants of button: primary, secondary, tertiary. They are styled differently.
53
- * - **Primary**: Solid background color.
54
- * - **Secondary**: Transparent background with a solid border.
55
- * - **Tertiary**: No background or border, appears as plain text but retains all button functionalities.
56
- * @default primary
57
- */
58
- this.variant = DEFAULTS.VARIANT;
59
52
  /**
60
53
  * Button sizing is based on the button type.
61
54
  * - **Pill button**: 40, 32, 28, 24.
@@ -64,11 +57,6 @@ class Button extends Buttonsimple {
64
57
  * @default 32
65
58
  */
66
59
  this.size = DEFAULTS.SIZE;
67
- /**
68
- * There are 5 colors for button: positive, negative, accent, promotional, default.
69
- * @default default
70
- */
71
- this.color = DEFAULTS.COLOR;
72
60
  /**
73
61
  * This property defines the ARIA role for the element. By default, it is set to 'button'.
74
62
  * Consumers should override this role when:
@@ -77,8 +65,6 @@ class Button extends Buttonsimple {
77
65
  * @default button
78
66
  */
79
67
  this.role = 'button';
80
- /** @internal */
81
- this.typeInternal = DEFAULTS.TYPE_INTERNAL;
82
68
  }
83
69
  update(changedProperties) {
84
70
  super.update(changedProperties);
@@ -125,65 +111,6 @@ class Button extends Buttonsimple {
125
111
  this.postfixFilledIconName = this.postfixIcon;
126
112
  }
127
113
  }
128
- /**
129
- * Sets the variant attribute for the button component.
130
- * If the provided variant is not included in the BUTTON_VARIANTS,
131
- * it defaults to the value specified in DEFAULTS.VARIANT.
132
- *
133
- * @param variant - The variant to set.
134
- */
135
- setVariant(variant) {
136
- this.setAttribute('variant', Object.values(BUTTON_VARIANTS).includes(variant) ? variant : DEFAULTS.VARIANT);
137
- }
138
- /**
139
- * Sets the size attribute for the button component.
140
- * Validates the size based on the button type (icon, pill, or tertiary).
141
- * Defaults to DEFAULTS.SIZE if invalid.
142
- *
143
- * @param size - The size to set.
144
- */
145
- setSize(size) {
146
- const isIconType = this.typeInternal === BUTTON_TYPE_INTERNAL.ICON;
147
- const isValidSize = isIconType
148
- ? Object.values(ICON_BUTTON_SIZES).includes(size)
149
- && !(size === ICON_BUTTON_SIZES[20] && this.variant !== BUTTON_VARIANTS.TERTIARY)
150
- : Object.values(PILL_BUTTON_SIZES).includes(size);
151
- this.setAttribute('size', isValidSize ? `${size}` : `${DEFAULTS.SIZE}`);
152
- }
153
- /**
154
- * Sets the color attribute for the button.
155
- * Defaults to DEFAULTS.COLOR if invalid or for tertiary buttons.
156
- *
157
- * @param color - The color to set.
158
- */
159
- setColor(color) {
160
- if (!Object.values(BUTTON_COLORS).includes(color) || this.variant === BUTTON_VARIANTS.TERTIARY) {
161
- this.setAttribute('color', `${DEFAULTS.COLOR}`);
162
- }
163
- else {
164
- this.setAttribute('color', color);
165
- }
166
- }
167
- /**
168
- * Infers the type of button based on the presence of slot and/or prefix and postfix icons.
169
- * @param slot - default slot of button
170
- */
171
- inferButtonType() {
172
- var _a, _b;
173
- 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;
174
- if (slot && (this.prefixIcon || this.postfixIcon)) {
175
- this.typeInternal = BUTTON_TYPE_INTERNAL.PILL_WITH_ICON;
176
- this.setAttribute('data-btn-type', 'pill-with-icon');
177
- }
178
- else if (!slot && (this.prefixIcon || this.postfixIcon)) {
179
- this.typeInternal = BUTTON_TYPE_INTERNAL.ICON;
180
- this.setAttribute('data-btn-type', 'icon');
181
- }
182
- else {
183
- this.typeInternal = BUTTON_TYPE_INTERNAL.PILL;
184
- this.setAttribute('data-btn-type', 'pill');
185
- }
186
- }
187
114
  render() {
188
115
  return html `
189
116
  ${this.prefixFilledIconName
@@ -197,34 +124,14 @@ class Button extends Buttonsimple {
197
124
  }
198
125
  }
199
126
  Button.styles = [...Buttonsimple.styles, ...styles];
200
- __decorate([
201
- property({ type: String, attribute: 'prefix-icon', reflect: true }),
202
- __metadata("design:type", String)
203
- ], Button.prototype, "prefixIcon", void 0);
204
- __decorate([
205
- property({ type: String, attribute: 'postfix-icon', reflect: true }),
206
- __metadata("design:type", String)
207
- ], Button.prototype, "postfixIcon", void 0);
208
- __decorate([
209
- property({ type: String }),
210
- __metadata("design:type", String)
211
- ], Button.prototype, "variant", void 0);
212
127
  __decorate([
213
128
  property({ type: Number }),
214
129
  __metadata("design:type", Number)
215
130
  ], Button.prototype, "size", void 0);
216
- __decorate([
217
- property({ type: String }),
218
- __metadata("design:type", String)
219
- ], Button.prototype, "color", void 0);
220
131
  __decorate([
221
132
  property({ type: String, reflect: true }),
222
133
  __metadata("design:type", Object)
223
134
  ], Button.prototype, "role", void 0);
224
- __decorate([
225
- state(),
226
- __metadata("design:type", String)
227
- ], Button.prototype, "typeInternal", void 0);
228
135
  __decorate([
229
136
  state(),
230
137
  __metadata("design:type", String)
@@ -0,0 +1,59 @@
1
+ import { CSSResult, PropertyValues } from 'lit';
2
+ import Linksimple from '../linksimple/linksimple.component';
3
+ import type { IconButtonSize, PillButtonSize } from '../button/button.types';
4
+ declare const ButtonLink_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/ButtonComponentMixin").ButtonComponentMixinInterface> & typeof Linksimple;
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
+ declare class ButtonLink extends ButtonLink_base {
27
+ /**
28
+ * ButtonLink sizing is based on the buttonlink type.
29
+ * - **Pill buttonlink**: 40, 32, 28, 24.
30
+ * - **Icon buttonlink**: 64, 52, 40, 32, 28, 24.
31
+ * - Tertiary icon buttonlink can also be 20.
32
+ * @default 32
33
+ */
34
+ size: PillButtonSize | IconButtonSize;
35
+ /**
36
+ * Indicates whether the buttonlink is soft disabled.
37
+ * When set to `true`, the buttonlink appears visually disabled but still allows
38
+ * focus, click, and keyboard actions to be passed through.
39
+ *
40
+ * **Important:** When using soft disabled, consumers must ensure that
41
+ * the buttonlink behaves like a disabled buttonlink, allowing only focus and
42
+ * preventing any interactions (clicks or keyboard actions) from triggering unintended actions.
43
+ * @default undefined
44
+ */
45
+ softDisabled?: boolean;
46
+ /**
47
+ * Sets the soft-disabled attribute for the buttonlink.
48
+ * When soft-disabled, the buttonlink looks to be disabled but remains focusable and clickable.
49
+ * Also sets/removes aria-disabled attribute.
50
+ *
51
+ * @param element - The buttonlink element.
52
+ * @param softDisabled - The soft-disabled state.
53
+ */
54
+ private setSoftDisabled;
55
+ update(changedProperties: PropertyValues): void;
56
+ render(): import("lit-html").TemplateResult<1>;
57
+ static styles: Array<CSSResult>;
58
+ }
59
+ export default ButtonLink;
@@ -0,0 +1,106 @@
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 Button from '../button/button.component';
13
+ import { ButtonComponentMixin } from '../../utils/mixins/ButtonComponentMixin';
14
+ import { DEFAULTS } from '../button/button.constants';
15
+ import Linksimple from '../linksimple/linksimple.component';
16
+ /**
17
+ * `mdc-buttonlink` combines the functional behavior of `mdc-linksimple` with the visual and structural
18
+ * features of `mdc-button`. This includes support for variants, sizing, and optional
19
+ * prefix and postfix icons via slots.
20
+ *
21
+ * ### Features:
22
+ * - Behaves like an link while visually resembling a button.
23
+ * - Supports slots for `prefix-icon` and `postfix-icon`.
24
+ * - Customizable size, color, and variant through attributes.
25
+ * - Inherits accessibility and keyboard interaction support from `mdc-linksimple`.
26
+ *
27
+ * @dependency mdc-icon
28
+ *
29
+ * @tagname mdc-buttonlink
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
+ *
36
+ */
37
+ class ButtonLink extends ButtonComponentMixin(Linksimple) {
38
+ constructor() {
39
+ super(...arguments);
40
+ /**
41
+ * ButtonLink sizing is based on the buttonlink type.
42
+ * - **Pill buttonlink**: 40, 32, 28, 24.
43
+ * - **Icon buttonlink**: 64, 52, 40, 32, 28, 24.
44
+ * - Tertiary icon buttonlink can also be 20.
45
+ * @default 32
46
+ */
47
+ this.size = DEFAULTS.SIZE;
48
+ }
49
+ /**
50
+ * Sets the soft-disabled attribute for the buttonlink.
51
+ * When soft-disabled, the buttonlink looks to be disabled but remains focusable and clickable.
52
+ * Also sets/removes aria-disabled attribute.
53
+ *
54
+ * @param element - The buttonlink element.
55
+ * @param softDisabled - The soft-disabled state.
56
+ */
57
+ setSoftDisabled(element, softDisabled) {
58
+ if (softDisabled) {
59
+ element.setAttribute('aria-disabled', 'true');
60
+ }
61
+ else {
62
+ element.removeAttribute('aria-disabled');
63
+ }
64
+ }
65
+ update(changedProperties) {
66
+ super.update(changedProperties);
67
+ if (changedProperties.has('softDisabled')) {
68
+ this.setSoftDisabled(this, this.softDisabled);
69
+ }
70
+ if (changedProperties.has('size')) {
71
+ this.setSize(this.size);
72
+ }
73
+ if (changedProperties.has('variant')) {
74
+ this.setVariant(this.variant);
75
+ this.setSize(this.size);
76
+ }
77
+ if (changedProperties.has('color')) {
78
+ this.setColor(this.color);
79
+ }
80
+ if (changedProperties.has('typeInternal')) {
81
+ this.setSize(this.size);
82
+ }
83
+ if (changedProperties.has('prefixIcon') || changedProperties.has('postfixIcon')) {
84
+ this.inferButtonType();
85
+ }
86
+ }
87
+ render() {
88
+ return html `
89
+ ${this.prefixIcon ? html ` <mdc-icon name="${this.prefixIcon}" part="prefix-icon"></mdc-icon>` : ''}
90
+ <slot @slotchange=${this.inferButtonType}></slot>
91
+ ${this.postfixIcon
92
+ ? html ` <mdc-icon name="${this.postfixIcon}" part="postfix-icon"></mdc-icon>`
93
+ : ''}
94
+ `;
95
+ }
96
+ }
97
+ ButtonLink.styles = [...Button.styles];
98
+ __decorate([
99
+ property({ type: Number, reflect: true }),
100
+ __metadata("design:type", Number)
101
+ ], ButtonLink.prototype, "size", void 0);
102
+ __decorate([
103
+ property({ type: Boolean, attribute: 'soft-disabled', reflect: true }),
104
+ __metadata("design:type", Boolean)
105
+ ], ButtonLink.prototype, "softDisabled", void 0);
106
+ export default ButtonLink;
@@ -0,0 +1,2 @@
1
+ declare const TAG_NAME: "mdc-buttonlink";
2
+ export { TAG_NAME };
@@ -0,0 +1,3 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('buttonlink');
3
+ export { TAG_NAME };
@@ -0,0 +1,7 @@
1
+ interface Events {
2
+ onClickEvent: MouseEvent;
3
+ onKeyDownEvent: KeyboardEvent;
4
+ onFocusEvent: FocusEvent;
5
+ onBlurEvent: Event;
6
+ }
7
+ export type { Events };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import ButtonLink from './buttonlink.component';
2
+ import '../icon';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ ['mdc-buttonlink']: ButtonLink;
6
+ }
7
+ }
8
+ export default ButtonLink;
@@ -0,0 +1,5 @@
1
+ import ButtonLink from './buttonlink.component';
2
+ import { TAG_NAME } from './buttonlink.constants';
3
+ import '../icon';
4
+ ButtonLink.register(TAG_NAME);
5
+ export default ButtonLink;
@@ -0,0 +1,8 @@
1
+ import '../icon';
2
+ import StaticToggle from './statictoggle.component';
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ ['mdc-statictoggle']: StaticToggle;
6
+ }
7
+ }
8
+ export default StaticToggle;
@@ -0,0 +1,5 @@
1
+ import '../icon';
2
+ import StaticToggle from './statictoggle.component';
3
+ import { TAG_NAME } from './statictoggle.constants';
4
+ StaticToggle.register(TAG_NAME);
5
+ export default StaticToggle;
@@ -0,0 +1,48 @@
1
+ import type { CSSResult } from 'lit';
2
+ import { Component } from '../../models';
3
+ import type { ToggleSize } from './statictoggle.types';
4
+ declare const StaticToggle_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
5
+ /**
6
+ * This is a decorative component that is styled to look as a toggle. <br/>
7
+ * It has 3 properties - checked, size and disabled. <br/>
8
+ * We are using the same styling that has been created for the `mdc-toggle` component.
9
+ *
10
+ * @dependency mdc-icon
11
+ *
12
+ * @tagname mdc-statictoggle
13
+ *
14
+ * @slot default - This is a default/unnamed slot
15
+ *
16
+ * @cssproperty --mdc-statictoggle-width - Width of the toggle
17
+ * @cssproperty --mdc-statictoggle-height - Height of the toggle
18
+ * @cssproperty --mdc-statictoggle-width-compact - Width of the toggle when it's size is compact
19
+ * @cssproperty --mdc-statictoggle-height-compact - Height of the toggle when it's size is compact
20
+ * @cssproperty --mdc-statictoggle-border-radius - Border radius of the toggle
21
+ * @cssproperty --mdc-statictoggle-border-radius-compact - Border radius of the toggle when it's size is compact
22
+ * @cssproperty --mdc-statictoggle-border - Border of the toggle
23
+ * @cssproperty --mdc-statictoggle-inactive-rest-color - Background color of the inactive toggle in rest state
24
+ * @cssproperty --mdc-statictoggle-inactive-disabled-color - Background color of the inactive toggle in disabled state
25
+ * @cssproperty --mdc-statictoggle-active-rest-color - Background color of the active toggle in rest state
26
+ * @cssproperty --mdc-statictoggle-active-disabled-color - Background color of the active toggle in disabled state
27
+ * @cssproperty --mdc-statictoggle-icon-color-normal - Color of the icon in normal state
28
+ * @cssproperty --mdc-statictoggle-icon-color-disabled - Color of the icon in disabled state
29
+ * @cssproperty --mdc-statictoggle-icon-background-color-normal - Background color of the icon in normal state
30
+ * @cssproperty --mdc-statictoggle-icon-background-color-disabled - Background color of the icon in disabled state
31
+ */
32
+ declare class StaticToggle extends StaticToggle_base {
33
+ /**
34
+ * Determines whether the toggle is active or inactive.
35
+ * @default false
36
+ */
37
+ checked: boolean;
38
+ /**
39
+ * Determines toggle size in rem (height is specified here).
40
+ * - **Default**: 1.5
41
+ * - **Compact**: 1
42
+ * @default default
43
+ */
44
+ size: ToggleSize;
45
+ render(): import("lit-html").TemplateResult<1>;
46
+ static styles: Array<CSSResult>;
47
+ }
48
+ export default StaticToggle;
@@ -0,0 +1,82 @@
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, ICON_NAME, ICON_SIZE_IN_REM } from './statictoggle.constants';
15
+ import styles from './statictoggle.styles';
16
+ /**
17
+ * This is a decorative component that is styled to look as a toggle. <br/>
18
+ * It has 3 properties - checked, size and disabled. <br/>
19
+ * We are using the same styling that has been created for the `mdc-toggle` component.
20
+ *
21
+ * @dependency mdc-icon
22
+ *
23
+ * @tagname mdc-statictoggle
24
+ *
25
+ * @slot default - This is a default/unnamed slot
26
+ *
27
+ * @cssproperty --mdc-statictoggle-width - Width of the toggle
28
+ * @cssproperty --mdc-statictoggle-height - Height of the toggle
29
+ * @cssproperty --mdc-statictoggle-width-compact - Width of the toggle when it's size is compact
30
+ * @cssproperty --mdc-statictoggle-height-compact - Height of the toggle when it's size is compact
31
+ * @cssproperty --mdc-statictoggle-border-radius - Border radius of the toggle
32
+ * @cssproperty --mdc-statictoggle-border-radius-compact - Border radius of the toggle when it's size is compact
33
+ * @cssproperty --mdc-statictoggle-border - Border of the toggle
34
+ * @cssproperty --mdc-statictoggle-inactive-rest-color - Background color of the inactive toggle in rest state
35
+ * @cssproperty --mdc-statictoggle-inactive-disabled-color - Background color of the inactive toggle in disabled state
36
+ * @cssproperty --mdc-statictoggle-active-rest-color - Background color of the active toggle in rest state
37
+ * @cssproperty --mdc-statictoggle-active-disabled-color - Background color of the active toggle in disabled state
38
+ * @cssproperty --mdc-statictoggle-icon-color-normal - Color of the icon in normal state
39
+ * @cssproperty --mdc-statictoggle-icon-color-disabled - Color of the icon in disabled state
40
+ * @cssproperty --mdc-statictoggle-icon-background-color-normal - Background color of the icon in normal state
41
+ * @cssproperty --mdc-statictoggle-icon-background-color-disabled - Background color of the icon in disabled state
42
+ */
43
+ class StaticToggle extends DisabledMixin(Component) {
44
+ constructor() {
45
+ super(...arguments);
46
+ /**
47
+ * Determines whether the toggle is active or inactive.
48
+ * @default false
49
+ */
50
+ this.checked = false;
51
+ /**
52
+ * Determines toggle size in rem (height is specified here).
53
+ * - **Default**: 1.5
54
+ * - **Compact**: 1
55
+ * @default default
56
+ */
57
+ this.size = DEFAULTS.SIZE;
58
+ }
59
+ render() {
60
+ return html `
61
+ <slot></slot>
62
+ <div part="slider">
63
+ <mdc-icon
64
+ name="${this.checked ? ICON_NAME.CHECKED : ICON_NAME.UNCHECKED}"
65
+ class="icon"
66
+ length-unit="rem"
67
+ size="${ICON_SIZE_IN_REM[this.size]}"
68
+ ></mdc-icon>
69
+ </div>
70
+ `;
71
+ }
72
+ }
73
+ StaticToggle.styles = [...Component.styles, ...styles];
74
+ __decorate([
75
+ property({ type: Boolean, reflect: true }),
76
+ __metadata("design:type", Object)
77
+ ], StaticToggle.prototype, "checked", void 0);
78
+ __decorate([
79
+ property({ type: String, reflect: true }),
80
+ __metadata("design:type", String)
81
+ ], StaticToggle.prototype, "size", void 0);
82
+ export default StaticToggle;
@@ -0,0 +1,17 @@
1
+ declare const TAG_NAME: "mdc-statictoggle";
2
+ declare const TOGGLE_SIZE: {
3
+ readonly DEFAULT: "default";
4
+ readonly COMPACT: "compact";
5
+ };
6
+ declare const ICON_NAME: {
7
+ readonly CHECKED: "check-bold";
8
+ readonly UNCHECKED: "cancel-bold";
9
+ };
10
+ declare const ICON_SIZE_IN_REM: {
11
+ readonly compact: 0.75;
12
+ readonly default: 1.25;
13
+ };
14
+ declare const DEFAULTS: {
15
+ SIZE: "default";
16
+ };
17
+ export { TAG_NAME, ICON_SIZE_IN_REM, DEFAULTS, TOGGLE_SIZE, ICON_NAME };
@@ -0,0 +1,18 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('statictoggle');
3
+ const TOGGLE_SIZE = {
4
+ DEFAULT: 'default',
5
+ COMPACT: 'compact',
6
+ };
7
+ const ICON_NAME = {
8
+ CHECKED: 'check-bold',
9
+ UNCHECKED: 'cancel-bold',
10
+ };
11
+ const ICON_SIZE_IN_REM = {
12
+ compact: 0.75,
13
+ default: 1.25,
14
+ };
15
+ const DEFAULTS = {
16
+ SIZE: TOGGLE_SIZE.DEFAULT,
17
+ };
18
+ export { TAG_NAME, ICON_SIZE_IN_REM, DEFAULTS, TOGGLE_SIZE, ICON_NAME };
@@ -0,0 +1,2 @@
1
+ declare const styles: import("lit").CSSResult[];
2
+ export default styles;