@momentum-design/components 0.106.8 → 0.107.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 (33) hide show
  1. package/dist/browser/index.js +359 -350
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/chip/chip.component.js +2 -2
  4. package/dist/components/chip/chip.constants.d.ts +1 -12
  5. package/dist/components/chip/chip.constants.js +1 -12
  6. package/dist/components/chip/chip.styles.js +1 -59
  7. package/dist/components/menupopover/menupopover.component.js +0 -2
  8. package/dist/components/popover/popover.component.d.ts +12 -9
  9. package/dist/components/popover/popover.component.js +12 -23
  10. package/dist/components/popover/popover.constants.d.ts +0 -1
  11. package/dist/components/popover/popover.constants.js +0 -1
  12. package/dist/components/popover/popover.utils.d.ts +0 -4
  13. package/dist/components/popover/popover.utils.js +4 -18
  14. package/dist/components/staticchip/index.d.ts +9 -0
  15. package/dist/components/staticchip/index.js +6 -0
  16. package/dist/components/staticchip/staticchip.component.d.ts +54 -0
  17. package/dist/components/staticchip/staticchip.component.js +89 -0
  18. package/dist/components/staticchip/staticchip.constants.d.ts +19 -0
  19. package/dist/components/staticchip/staticchip.constants.js +21 -0
  20. package/dist/components/staticchip/staticchip.styles.d.ts +2 -0
  21. package/dist/components/staticchip/staticchip.styles.js +66 -0
  22. package/dist/components/staticchip/staticchip.types.d.ts +4 -0
  23. package/dist/components/staticchip/staticchip.types.js +1 -0
  24. package/dist/custom-elements.json +216 -221
  25. package/dist/index.d.ts +2 -1
  26. package/dist/index.js +2 -1
  27. package/dist/react/index.d.ts +2 -1
  28. package/dist/react/index.js +2 -1
  29. package/dist/react/popover/index.d.ts +4 -0
  30. package/dist/react/popover/index.js +4 -0
  31. package/dist/react/staticchip/index.d.ts +20 -0
  32. package/dist/react/staticchip/index.js +29 -0
  33. package/package.json +1 -1
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { html, nothing } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
12
  import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
13
- import { Component } from '../../models';
14
13
  import Buttonsimple from '../buttonsimple/buttonsimple.component';
14
+ import StaticChip from '../staticchip/staticchip.component';
15
15
  import { DEFAULTS } from './chip.constants';
16
16
  import styles from './chip.styles';
17
17
  /**
@@ -95,7 +95,7 @@ class Chip extends IconNameMixin(Buttonsimple) {
95
95
  `;
96
96
  }
97
97
  }
98
- Chip.styles = [...Component.styles, ...styles];
98
+ Chip.styles = [...StaticChip.styles, ...styles];
99
99
  __decorate([
100
100
  property({ type: String, reflect: true }),
101
101
  __metadata("design:type", String)
@@ -1,16 +1,5 @@
1
+ import { COLOR } from '../staticchip/staticchip.constants';
1
2
  declare const TAG_NAME: "mdc-chip";
2
- declare const COLOR: {
3
- readonly DEFAULT: "default";
4
- readonly COBALT: "cobalt";
5
- readonly GOLD: "gold";
6
- readonly LIME: "lime";
7
- readonly MINT: "mint";
8
- readonly ORANGE: "orange";
9
- readonly PINK: "pink";
10
- readonly PURPLE: "purple";
11
- readonly SLATE: "slate";
12
- readonly VIOLET: "violet";
13
- };
14
3
  declare const DEFAULTS: {
15
4
  readonly COLOR: "default";
16
5
  readonly TEXT_TYPE: "body-midsize-regular";
@@ -1,20 +1,9 @@
1
1
  import { ROLE } from '../../utils/roles';
2
2
  import utils from '../../utils/tag-name';
3
3
  import { BUTTON_SIZES } from '../buttonsimple/buttonsimple.constants';
4
+ import { COLOR } from '../staticchip/staticchip.constants';
4
5
  import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
5
6
  const TAG_NAME = utils.constructTagName('chip');
6
- const COLOR = {
7
- DEFAULT: 'default',
8
- COBALT: 'cobalt',
9
- GOLD: 'gold',
10
- LIME: 'lime',
11
- MINT: 'mint',
12
- ORANGE: 'orange',
13
- PINK: 'pink',
14
- PURPLE: 'purple',
15
- SLATE: 'slate',
16
- VIOLET: 'violet',
17
- };
18
7
  const DEFAULTS = {
19
8
  COLOR: COLOR.DEFAULT,
20
9
  TEXT_TYPE: TYPE.BODY_MIDSIZE_REGULAR,
@@ -2,21 +2,8 @@ import { css } from 'lit';
2
2
  import { hostFitContentStyles, hostFocusRingStyles } from '../../utils/styles';
3
3
  const styles = css `
4
4
  :host {
5
- height: 1.5rem;
6
- gap: 0.25rem;
7
- padding: 0 0.5rem;
8
- border-radius: 0.25rem;
9
- border: 1px solid;
10
5
  cursor: pointer;
11
- white-space: nowrap;
12
-
13
- --mdc-chip-color: var(--mds-color-theme-text-primary-normal);
14
- --mdc-chip-border-color: var(--mds-color-theme-outline-button-normal);
15
- --mdc-chip-background-color: var(--mds-color-theme-background-label-default-normal);
16
-
17
- color: var(--mdc-chip-color);
18
- border-color: var(--mdc-chip-border-color);
19
- background-color: var(--mdc-chip-background-color);
6
+ height: 1.5rem;
20
7
  }
21
8
 
22
9
  :host([color='default']:hover) {
@@ -27,11 +14,6 @@ const styles = css `
27
14
  --mdc-chip-background-color: var(--mds-color-theme-background-label-default-active);
28
15
  }
29
16
 
30
- :host([color='cobalt']) {
31
- --mdc-chip-border-color: var(--mds-color-theme-outline-theme-normal);
32
- --mdc-chip-background-color: var(--mds-color-theme-background-label-cobalt-normal);
33
- }
34
-
35
17
  :host([color='cobalt']:hover) {
36
18
  --mdc-chip-background-color: var(--mds-color-theme-background-label-cobalt-hover);
37
19
  }
@@ -40,11 +22,6 @@ const styles = css `
40
22
  --mdc-chip-background-color: var(--mds-color-theme-background-label-cobalt-active);
41
23
  }
42
24
 
43
- :host([color='gold']) {
44
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-gold);
45
- --mdc-chip-background-color: var(--mds-color-theme-background-label-gold-normal);
46
- }
47
-
48
25
  :host([color='gold']:hover) {
49
26
  --mdc-chip-background-color: var(--mds-color-theme-background-label-gold-hover);
50
27
  }
@@ -53,11 +30,6 @@ const styles = css `
53
30
  --mdc-chip-background-color: var(--mds-color-theme-background-label-gold-active);
54
31
  }
55
32
 
56
- :host([color='lime']) {
57
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-lime);
58
- --mdc-chip-background-color: var(--mds-color-theme-background-label-lime-normal);
59
- }
60
-
61
33
  :host([color='lime']:hover) {
62
34
  --mdc-chip-background-color: var(--mds-color-theme-background-label-lime-hover);
63
35
  }
@@ -66,11 +38,6 @@ const styles = css `
66
38
  --mdc-chip-background-color: var(--mds-color-theme-background-label-lime-active);
67
39
  }
68
40
 
69
- :host([color='mint']) {
70
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-mint);
71
- --mdc-chip-background-color: var(--mds-color-theme-background-label-mint-normal);
72
- }
73
-
74
41
  :host([color='mint']:hover) {
75
42
  --mdc-chip-background-color: var(--mds-color-theme-background-label-mint-hover);
76
43
  }
@@ -79,11 +46,6 @@ const styles = css `
79
46
  --mdc-chip-background-color: var(--mds-color-theme-background-label-mint-active);
80
47
  }
81
48
 
82
- :host([color='pink']) {
83
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-pink);
84
- --mdc-chip-background-color: var(--mds-color-theme-background-label-pink-normal);
85
- }
86
-
87
49
  :host([color='pink']:hover) {
88
50
  --mdc-chip-background-color: var(--mds-color-theme-background-label-pink-hover);
89
51
  }
@@ -92,11 +54,6 @@ const styles = css `
92
54
  --mdc-chip-background-color: var(--mds-color-theme-background-label-pink-active);
93
55
  }
94
56
 
95
- :host([color='purple']) {
96
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-purple);
97
- --mdc-chip-background-color: var(--mds-color-theme-background-label-purple-normal);
98
- }
99
-
100
57
  :host([color='purple']:hover) {
101
58
  --mdc-chip-background-color: var(--mds-color-theme-background-label-purple-hover);
102
59
  }
@@ -105,11 +62,6 @@ const styles = css `
105
62
  --mdc-chip-background-color: var(--mds-color-theme-background-label-purple-active);
106
63
  }
107
64
 
108
- :host([color='orange']) {
109
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-orange);
110
- --mdc-chip-background-color: var(--mds-color-theme-background-label-orange-normal);
111
- }
112
-
113
65
  :host([color='orange']:hover) {
114
66
  --mdc-chip-background-color: var(--mds-color-theme-background-label-orange-hover);
115
67
  }
@@ -118,11 +70,6 @@ const styles = css `
118
70
  --mdc-chip-background-color: var(--mds-color-theme-background-label-orange-active);
119
71
  }
120
72
 
121
- :host([color='slate']) {
122
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-slate);
123
- --mdc-chip-background-color: var(--mds-color-theme-background-label-slate-normal);
124
- }
125
-
126
73
  :host([color='slate']:hover) {
127
74
  --mdc-chip-background-color: var(--mds-color-theme-background-label-slate-hover);
128
75
  }
@@ -131,11 +78,6 @@ const styles = css `
131
78
  --mdc-chip-background-color: var(--mds-color-theme-background-label-slate-active);
132
79
  }
133
80
 
134
- :host([color='violet']) {
135
- --mdc-chip-border-color: var(--mds-color-theme-outline-label-violet);
136
- --mdc-chip-background-color: var(--mds-color-theme-background-label-violet-normal);
137
- }
138
-
139
81
  :host([color='violet']:hover) {
140
82
  --mdc-chip-background-color: var(--mds-color-theme-background-label-violet-hover);
141
83
  }
@@ -374,11 +374,9 @@ class MenuPopover extends Popover {
374
374
  return super.isOpenUpdated(oldValue, newValue);
375
375
  }
376
376
  async firstUpdated(changedProperties) {
377
- var _a;
378
377
  await super.firstUpdated(changedProperties);
379
378
  this.collectMenuItems();
380
379
  this.resetTabIndexes(0);
381
- (_a = this.triggerElement) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', ROLE.MENU);
382
380
  }
383
381
  /**
384
382
  * Reset all tabindex to -1 and set the tabindex of the current menu item to 0
@@ -8,6 +8,10 @@ declare const Popover_base: import("../../utils/mixins/index.types").Constructor
8
8
  * The popover automatically positions itself based on available space and
9
9
  * supports dynamic height adjustments with scrollable content when needed。
10
10
  *
11
+ * Note:
12
+ * - A component (button) can trigger more than one popover, but only one of them should change the
13
+ * aria-expanded and aria-haspopup, the rest of the popovers must have `disable-aria-expanded` attribute.
14
+ *
11
15
  * @dependency mdc-button
12
16
  *
13
17
  * @tagname mdc-popover
@@ -261,18 +265,17 @@ declare class Popover extends Popover_base {
261
265
  */
262
266
  ariaDescribedby: string | null;
263
267
  /**
264
- * Disable setting the aria-expanded attribute on trigger element.
265
- * Make sure to set this to false when the popover is interactive.
268
+ * Disable setting the `aria-expanded` attribute on trigger element.
269
+ *
270
+ * Note, when `disable-aria-expanded` is true
271
+ * - when its value change after first update to
272
+ * - `true`: popover will not remove the `aria-expanded` to avoid conflicts when there are more than one popover
273
+ * registered to the same trigger
274
+ * - `false`: check `aria-expanded` value and update it if necessary.
275
+ * - aria-haspopup will be disabled as well
266
276
  * @default false
267
277
  */
268
278
  disableAriaExpanded: boolean;
269
- /**
270
- * Disable setting the aria-haspopup attribute on trigger element.
271
- * Make sure to set this to true when the popover is extended and its role
272
- * is not 'dialog' or 'alertdialog' i.e. listbox, menu, etc.
273
- * @default false
274
- */
275
- disableAriaHasPopup: boolean;
276
279
  /**
277
280
  * If a tooltip is connected to the same trigger element,
278
281
  * this property will keep the connected tooltip closed if this popover is open.
@@ -27,6 +27,10 @@ import { PopoverUtils } from './popover.utils';
27
27
  * The popover automatically positions itself based on available space and
28
28
  * supports dynamic height adjustments with scrollable content when needed。
29
29
  *
30
+ * Note:
31
+ * - A component (button) can trigger more than one popover, but only one of them should change the
32
+ * aria-expanded and aria-haspopup, the rest of the popovers must have `disable-aria-expanded` attribute.
33
+ *
30
34
  * @dependency mdc-button
31
35
  *
32
36
  * @tagname mdc-popover
@@ -261,18 +265,17 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
261
265
  */
262
266
  this.ariaDescribedby = null;
263
267
  /**
264
- * Disable setting the aria-expanded attribute on trigger element.
265
- * Make sure to set this to false when the popover is interactive.
268
+ * Disable setting the `aria-expanded` attribute on trigger element.
269
+ *
270
+ * Note, when `disable-aria-expanded` is true
271
+ * - when its value change after first update to
272
+ * - `true`: popover will not remove the `aria-expanded` to avoid conflicts when there are more than one popover
273
+ * registered to the same trigger
274
+ * - `false`: check `aria-expanded` value and update it if necessary.
275
+ * - aria-haspopup will be disabled as well
266
276
  * @default false
267
277
  */
268
278
  this.disableAriaExpanded = DEFAULTS.DISABLE_ARIA_EXPANDED;
269
- /**
270
- * Disable setting the aria-haspopup attribute on trigger element.
271
- * Make sure to set this to true when the popover is extended and its role
272
- * is not 'dialog' or 'alertdialog' i.e. listbox, menu, etc.
273
- * @default false
274
- */
275
- this.disableAriaHasPopup = DEFAULTS.DISABLE_ARIA_HAS_POPUP;
276
279
  /**
277
280
  * If a tooltip is connected to the same trigger element,
278
281
  * this property will keep the connected tooltip closed if this popover is open.
@@ -699,9 +702,6 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
699
702
  if (changedProperties.has('disableAriaExpanded')) {
700
703
  this.utils.updateAriaExpandedAttribute();
701
704
  }
702
- if (changedProperties.has('interactive') || changedProperties.has('disableAriaHasPopup')) {
703
- this.utils.updateAriaHasPopupAttribute();
704
- }
705
705
  if (changedProperties.has('focusTrap')) {
706
706
  // if focusTrap turned false and the popover is visible, deactivate the focus trap
707
707
  if (!this.focusTrap && this.visible) {
@@ -795,13 +795,6 @@ class Popover extends BackdropMixin(PreventScrollMixin(FocusTrapMixin(Component)
795
795
  this.removeEventListener('keydown', this.onEscapeKeydown);
796
796
  (_c = this.triggerElement) === null || _c === void 0 ? void 0 : _c.removeEventListener('keydown', this.onEscapeKeydown);
797
797
  }
798
- if (this.disableAriaExpanded) {
799
- this.triggerElement.removeAttribute('aria-expanded');
800
- }
801
- // Remove aria-haspopup if the popover is not interactive
802
- if (!this.interactive) {
803
- this.triggerElement.removeAttribute('aria-haspopup');
804
- }
805
798
  this.deactivatePreventScroll();
806
799
  (_d = this.deactivateFocusTrap) === null || _d === void 0 ? void 0 : _d.call(this);
807
800
  if (this.focusBackToTrigger) {
@@ -972,10 +965,6 @@ __decorate([
972
965
  property({ type: Boolean, reflect: true, attribute: 'disable-aria-expanded' }),
973
966
  __metadata("design:type", Boolean)
974
967
  ], Popover.prototype, "disableAriaExpanded", void 0);
975
- __decorate([
976
- property({ type: Boolean, reflect: true, attribute: 'disable-aria-haspopup' }),
977
- __metadata("design:type", Boolean)
978
- ], Popover.prototype, "disableAriaHasPopup", void 0);
979
968
  __decorate([
980
969
  property({ type: Boolean, reflect: true, attribute: 'keep-connected-tooltip-closed' }),
981
970
  __metadata("design:type", Boolean)
@@ -48,7 +48,6 @@ declare const DEFAULTS: {
48
48
  readonly ROLE: "dialog";
49
49
  readonly Z_INDEX: 1000;
50
50
  readonly DISABLE_ARIA_EXPANDED: false;
51
- readonly DISABLE_ARIA_HAS_POPUP: false;
52
51
  readonly PROPAGATE_EVENT_ON_ESCAPE: false;
53
52
  readonly KEEP_CONNECTED_TOOLTIP_CLOSED: true;
54
53
  readonly STRATEGY: "absolute";
@@ -49,7 +49,6 @@ const DEFAULTS = {
49
49
  ROLE: 'dialog',
50
50
  Z_INDEX: 1000,
51
51
  DISABLE_ARIA_EXPANDED: false,
52
- DISABLE_ARIA_HAS_POPUP: false,
53
52
  PROPAGATE_EVENT_ON_ESCAPE: false,
54
53
  KEEP_CONNECTED_TOOLTIP_CLOSED: true,
55
54
  STRATEGY: 'absolute',
@@ -32,10 +32,6 @@ export declare class PopoverUtils {
32
32
  * Updates the aria-modal attribute based on the popover's role.
33
33
  */
34
34
  updateAriaModal(): void;
35
- /**
36
- * Updates the aria-haspopup attribute on the trigger element.
37
- */
38
- updateAriaHasPopupAttribute(): void;
39
35
  /**
40
36
  * Updates the aria-expanded attribute on the trigger element.
41
37
  */
@@ -111,28 +111,14 @@ export class PopoverUtils {
111
111
  this.popover.removeAttribute('aria-modal');
112
112
  }
113
113
  }
114
- /**
115
- * Updates the aria-haspopup attribute on the trigger element.
116
- */
117
- updateAriaHasPopupAttribute() {
118
- var _a, _b, _c;
119
- if (this.popover.interactive && !this.popover.disableAriaHasPopup) {
120
- (_a = this.popover.triggerElement) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', ((_b = this.popover.triggerElement) === null || _b === void 0 ? void 0 : _b.getAttribute('aria-haspopup')) || 'dialog');
121
- }
122
- else {
123
- (_c = this.popover.triggerElement) === null || _c === void 0 ? void 0 : _c.removeAttribute('aria-haspopup');
124
- }
125
- }
126
114
  /**
127
115
  * Updates the aria-expanded attribute on the trigger element.
128
116
  */
129
117
  updateAriaExpandedAttribute() {
130
- var _a, _b;
131
- if (this.popover.disableAriaExpanded) {
132
- (_a = this.popover.triggerElement) === null || _a === void 0 ? void 0 : _a.removeAttribute('aria-expanded');
133
- }
134
- else {
135
- (_b = this.popover.triggerElement) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', `${this.popover.visible}`);
118
+ var _a, _b, _c;
119
+ if (!this.popover.disableAriaExpanded) {
120
+ (_a = this.popover.triggerElement) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', `${this.popover.visible}`);
121
+ (_b = this.popover.triggerElement) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-haspopup', ((_c = this.popover.triggerElement) === null || _c === void 0 ? void 0 : _c.getAttribute('aria-haspopup')) || this.popover.role || 'dialog');
136
122
  }
137
123
  }
138
124
  /**
@@ -0,0 +1,9 @@
1
+ import StaticChip from './staticchip.component';
2
+ import '../text';
3
+ import '../icon';
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ ['mdc-staticchip']: StaticChip;
7
+ }
8
+ }
9
+ export default StaticChip;
@@ -0,0 +1,6 @@
1
+ import StaticChip from './staticchip.component';
2
+ import { TAG_NAME } from './staticchip.constants';
3
+ import '../text';
4
+ import '../icon';
5
+ StaticChip.register(TAG_NAME);
6
+ export default StaticChip;
@@ -0,0 +1,54 @@
1
+ import { CSSResult } from 'lit';
2
+ import { Component } from '../../models';
3
+ import type { ColorType } from './staticchip.types';
4
+ declare const StaticChip_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof Component;
5
+ /**
6
+ * mdc-staticchip is an static element that can be used to represent a chip. It supports a leading icon along with label.
7
+ *
8
+ * It is recommended to keep the label text for the chip component concise and compact.
9
+ * For best results, we recommend limiting the <b>maximum length of the label text to 20 characters</b>, including empty spaces to split words.
10
+ *
11
+ *
12
+ * @tagname mdc-staticchip
13
+ *
14
+ * @dependency mdc-icon
15
+ * @dependency mdc-text
16
+ *
17
+ * @cssproperty --mdc-chip-color - The color of the static chip.
18
+ * @cssproperty --mdc-chip-border-color - The border color of the static chip.
19
+ * @cssproperty --mdc-chip-background-color - The background color of the static chip.
20
+ *
21
+ */
22
+ declare class StaticChip extends StaticChip_base {
23
+ /**
24
+ * The color of the chip. It supports the following colors
25
+ * - default
26
+ * - cobalt
27
+ * - gold
28
+ * - lime
29
+ * - mint
30
+ * - orange
31
+ * - pink
32
+ * - purple
33
+ * - slate
34
+ * - violet
35
+ *
36
+ * @default default
37
+ */
38
+ color: ColorType;
39
+ /**
40
+ * The visible label text of the chip.
41
+ *
42
+ * We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
43
+ * including empty spaces to split words.
44
+ */
45
+ label: string;
46
+ /**
47
+ * Renders the icon element if available.
48
+ * @returns The icon element if available, otherwise nothing.
49
+ */
50
+ private renderIcon;
51
+ render(): import("lit-html").TemplateResult<1>;
52
+ static styles: Array<CSSResult>;
53
+ }
54
+ export default StaticChip;
@@ -0,0 +1,89 @@
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 { Component } from '../../models';
14
+ import { DEFAULTS } from './staticchip.constants';
15
+ import styles from './staticchip.styles';
16
+ /**
17
+ * mdc-staticchip is an static element that can be used to represent a chip. It supports a leading icon along with label.
18
+ *
19
+ * It is recommended to keep the label text for the chip component concise and compact.
20
+ * For best results, we recommend limiting the <b>maximum length of the label text to 20 characters</b>, including empty spaces to split words.
21
+ *
22
+ *
23
+ * @tagname mdc-staticchip
24
+ *
25
+ * @dependency mdc-icon
26
+ * @dependency mdc-text
27
+ *
28
+ * @cssproperty --mdc-chip-color - The color of the static chip.
29
+ * @cssproperty --mdc-chip-border-color - The border color of the static chip.
30
+ * @cssproperty --mdc-chip-background-color - The background color of the static chip.
31
+ *
32
+ */
33
+ class StaticChip extends IconNameMixin(Component) {
34
+ constructor() {
35
+ super(...arguments);
36
+ /**
37
+ * The color of the chip. It supports the following colors
38
+ * - default
39
+ * - cobalt
40
+ * - gold
41
+ * - lime
42
+ * - mint
43
+ * - orange
44
+ * - pink
45
+ * - purple
46
+ * - slate
47
+ * - violet
48
+ *
49
+ * @default default
50
+ */
51
+ this.color = DEFAULTS.COLOR;
52
+ /**
53
+ * The visible label text of the chip.
54
+ *
55
+ * We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
56
+ * including empty spaces to split words.
57
+ */
58
+ this.label = '';
59
+ }
60
+ /**
61
+ * Renders the icon element if available.
62
+ * @returns The icon element if available, otherwise nothing.
63
+ */
64
+ renderIcon() {
65
+ if (!this.iconName)
66
+ return nothing;
67
+ return html ` <mdc-icon name="${this.iconName}" length-unit="rem" size="1"></mdc-icon> `;
68
+ }
69
+ render() {
70
+ return html `
71
+ ${this.renderIcon()}
72
+ ${this.label
73
+ ? html `<mdc-text part="label" type="${DEFAULTS.TEXT_TYPE}" tagname="${DEFAULTS.TAG_NAME}"
74
+ >${this.label}</mdc-text
75
+ >`
76
+ : nothing}
77
+ `;
78
+ }
79
+ }
80
+ StaticChip.styles = [...Component.styles, ...styles];
81
+ __decorate([
82
+ property({ type: String, reflect: true }),
83
+ __metadata("design:type", String)
84
+ ], StaticChip.prototype, "color", void 0);
85
+ __decorate([
86
+ property({ type: String }),
87
+ __metadata("design:type", Object)
88
+ ], StaticChip.prototype, "label", void 0);
89
+ export default StaticChip;
@@ -0,0 +1,19 @@
1
+ declare const TAG_NAME: "mdc-staticchip";
2
+ declare const COLOR: {
3
+ readonly DEFAULT: "default";
4
+ readonly COBALT: "cobalt";
5
+ readonly GOLD: "gold";
6
+ readonly LIME: "lime";
7
+ readonly MINT: "mint";
8
+ readonly ORANGE: "orange";
9
+ readonly PINK: "pink";
10
+ readonly PURPLE: "purple";
11
+ readonly SLATE: "slate";
12
+ readonly VIOLET: "violet";
13
+ };
14
+ declare const DEFAULTS: {
15
+ readonly COLOR: "default";
16
+ readonly TEXT_TYPE: "body-midsize-regular";
17
+ readonly TAG_NAME: "span";
18
+ };
19
+ export { TAG_NAME, COLOR, DEFAULTS };
@@ -0,0 +1,21 @@
1
+ import utils from '../../utils/tag-name';
2
+ import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
3
+ const TAG_NAME = utils.constructTagName('staticchip');
4
+ const COLOR = {
5
+ DEFAULT: 'default',
6
+ COBALT: 'cobalt',
7
+ GOLD: 'gold',
8
+ LIME: 'lime',
9
+ MINT: 'mint',
10
+ ORANGE: 'orange',
11
+ PINK: 'pink',
12
+ PURPLE: 'purple',
13
+ SLATE: 'slate',
14
+ VIOLET: 'violet',
15
+ };
16
+ const DEFAULTS = {
17
+ COLOR: COLOR.DEFAULT,
18
+ TEXT_TYPE: TYPE.BODY_MIDSIZE_REGULAR,
19
+ TAG_NAME: VALID_TEXT_TAGS.SPAN,
20
+ };
21
+ export { TAG_NAME, COLOR, 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
+ import { hostFitContentStyles } from '../../utils/styles';
3
+ const styles = css `
4
+ :host {
5
+ height: 1.5rem;
6
+ gap: 0.25rem;
7
+ padding: 0 0.5rem;
8
+ border-radius: 0.25rem;
9
+ border: 1px solid;
10
+ white-space: nowrap;
11
+
12
+ --mdc-chip-color: var(--mds-color-theme-text-primary-normal);
13
+ --mdc-chip-border-color: var(--mds-color-theme-outline-button-normal);
14
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-default-normal);
15
+
16
+ color: var(--mdc-chip-color);
17
+ border-color: var(--mdc-chip-border-color);
18
+ background-color: var(--mdc-chip-background-color);
19
+ }
20
+
21
+ :host([color='cobalt']) {
22
+ --mdc-chip-border-color: var(--mds-color-theme-outline-theme-normal);
23
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-cobalt-normal);
24
+ }
25
+
26
+ :host([color='gold']) {
27
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-gold);
28
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-gold-normal);
29
+ }
30
+
31
+ :host([color='lime']) {
32
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-lime);
33
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-lime-normal);
34
+ }
35
+
36
+ :host([color='mint']) {
37
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-mint);
38
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-mint-normal);
39
+ }
40
+
41
+ :host([color='pink']) {
42
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-pink);
43
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-pink-normal);
44
+ }
45
+
46
+ :host([color='purple']) {
47
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-purple);
48
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-purple-normal);
49
+ }
50
+
51
+ :host([color='orange']) {
52
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-orange);
53
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-orange-normal);
54
+ }
55
+
56
+ :host([color='slate']) {
57
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-slate);
58
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-slate-normal);
59
+ }
60
+
61
+ :host([color='violet']) {
62
+ --mdc-chip-border-color: var(--mds-color-theme-outline-label-violet);
63
+ --mdc-chip-background-color: var(--mds-color-theme-background-label-violet-normal);
64
+ }
65
+ `;
66
+ export default [hostFitContentStyles, styles];
@@ -0,0 +1,4 @@
1
+ import type { ValueOf } from '../../utils/types';
2
+ import { COLOR } from './staticchip.constants';
3
+ type ColorType = ValueOf<typeof COLOR>;
4
+ export type { ColorType };
@@ -0,0 +1 @@
1
+ export {};