@momentum-design/components 0.36.1 → 0.36.3
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/browser/index.js +836 -447
- package/dist/browser/index.js.map +4 -4
- package/dist/components/alertchip/alertchip.component.d.ts +46 -0
- package/dist/components/alertchip/alertchip.component.js +79 -0
- package/dist/components/alertchip/alertchip.constants.d.ts +16 -0
- package/dist/components/alertchip/alertchip.constants.js +19 -0
- package/dist/components/alertchip/alertchip.styles.d.ts +2 -0
- package/dist/components/alertchip/alertchip.styles.js +106 -0
- package/dist/components/alertchip/alertchip.types.d.ts +6 -0
- package/dist/components/alertchip/alertchip.types.js +1 -0
- package/dist/components/alertchip/alertchip.utils.d.ts +3 -0
- package/dist/components/alertchip/alertchip.utils.js +12 -0
- package/dist/components/alertchip/index.d.ts +9 -0
- package/dist/components/alertchip/index.js +6 -0
- package/dist/components/chip/chip.component.d.ts +57 -0
- package/dist/components/chip/chip.component.js +97 -0
- package/dist/components/chip/chip.constants.d.ts +20 -0
- package/dist/components/chip/chip.constants.js +23 -0
- package/dist/components/chip/chip.styles.d.ts +2 -0
- package/dist/components/chip/chip.styles.js +140 -0
- package/dist/components/chip/chip.types.d.ts +4 -0
- package/dist/components/chip/chip.types.js +1 -0
- package/dist/components/chip/index.d.ts +9 -0
- package/dist/components/chip/index.js +6 -0
- package/dist/components/filterchip/filterchip.component.d.ts +30 -0
- package/dist/components/filterchip/filterchip.component.js +64 -0
- package/dist/components/filterchip/filterchip.constants.d.ts +6 -0
- package/dist/components/filterchip/filterchip.constants.js +7 -0
- package/dist/components/filterchip/filterchip.styles.d.ts +2 -0
- package/dist/components/filterchip/filterchip.styles.js +23 -0
- package/dist/components/filterchip/index.d.ts +7 -0
- package/dist/components/filterchip/index.js +4 -0
- package/dist/components/input/input.constants.d.ts +0 -1
- package/dist/components/input/input.constants.js +0 -1
- package/dist/components/inputchip/index.d.ts +10 -0
- package/dist/components/inputchip/index.js +7 -0
- package/dist/components/inputchip/inputchip.component.d.ts +58 -0
- package/dist/components/inputchip/inputchip.component.js +113 -0
- package/dist/components/inputchip/inputchip.constants.d.ts +7 -0
- package/dist/components/inputchip/inputchip.constants.js +9 -0
- package/dist/components/inputchip/inputchip.styles.d.ts +2 -0
- package/dist/components/inputchip/inputchip.styles.js +53 -0
- package/dist/components/listitem/listitem.component.d.ts +3 -2
- package/dist/components/listitem/listitem.component.js +1 -1
- package/dist/components/listitem/listitem.styles.js +3 -0
- package/dist/components/optgroup/index.d.ts +8 -0
- package/dist/components/optgroup/index.js +5 -0
- package/dist/components/optgroup/optgroup.component.d.ts +28 -0
- package/dist/components/optgroup/optgroup.component.js +77 -0
- package/dist/components/optgroup/optgroup.constants.d.ts +3 -0
- package/dist/components/optgroup/optgroup.constants.js +4 -0
- package/dist/components/optgroup/optgroup.styles.d.ts +2 -0
- package/dist/components/optgroup/optgroup.styles.js +16 -0
- package/dist/components/option/index.d.ts +8 -0
- package/dist/components/option/index.js +5 -0
- package/dist/components/option/option.component.d.ts +46 -0
- package/dist/components/option/option.component.js +115 -0
- package/dist/components/option/option.constants.d.ts +4 -0
- package/dist/components/option/option.constants.js +4 -0
- package/dist/components/option/option.styles.d.ts +2 -0
- package/dist/components/option/option.styles.js +10 -0
- package/dist/custom-elements.json +5641 -3003
- package/dist/index.d.ts +7 -1
- package/dist/index.js +7 -1
- package/dist/react/alertchip/index.d.ts +27 -0
- package/dist/react/alertchip/index.js +36 -0
- package/dist/react/chip/index.d.ts +28 -0
- package/dist/react/chip/index.js +37 -0
- package/dist/react/filterchip/index.d.ts +17 -0
- package/dist/react/filterchip/index.js +26 -0
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.js +7 -1
- package/dist/react/inputchip/index.d.ts +32 -0
- package/dist/react/inputchip/index.js +41 -0
- package/dist/react/optgroup/index.d.ts +14 -0
- package/dist/react/optgroup/index.js +23 -0
- package/dist/react/option/index.d.ts +21 -0
- package/dist/react/option/index.js +30 -0
- package/package.json +1 -1
@@ -0,0 +1,46 @@
|
|
1
|
+
import { CSSResult } from 'lit';
|
2
|
+
import type { VariantType } from './alertchip.types';
|
3
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
4
|
+
/**
|
5
|
+
* mdc-alertchip component is an interactive chip that consumers can use to represent an alert.
|
6
|
+
*
|
7
|
+
* - It supports a leading icon along with label.
|
8
|
+
* - It supports 5 variants of alerts - neutral, warning, error, success, and informational
|
9
|
+
*
|
10
|
+
* This component is built by extending Buttonsimple.
|
11
|
+
*
|
12
|
+
* @tagname mdc-alertchip
|
13
|
+
*
|
14
|
+
* @dependency mdc-icon
|
15
|
+
* @dependency mdc-text
|
16
|
+
*
|
17
|
+
* @cssproperty --mdc-chip-color - The color of the label text
|
18
|
+
* @cssproperty --mdc-chip-icon-color - The color of the icon
|
19
|
+
* @cssproperty --mdc-chip-border-color - The border color of the alertchip
|
20
|
+
* @cssproperty --mdc-chip-background-color - The background color of the alertchip
|
21
|
+
*
|
22
|
+
*/
|
23
|
+
declare class AlertChip extends Buttonsimple {
|
24
|
+
/**
|
25
|
+
* The variant of the alertchip. It supports 5 variants
|
26
|
+
* - neutral
|
27
|
+
* - warning
|
28
|
+
* - error
|
29
|
+
* - success
|
30
|
+
* - informational
|
31
|
+
*
|
32
|
+
* @default neutral
|
33
|
+
*/
|
34
|
+
variant: VariantType;
|
35
|
+
/**
|
36
|
+
* The visible label text of the alertchip.
|
37
|
+
*
|
38
|
+
* We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
39
|
+
* including empty spaces to split words.
|
40
|
+
*/
|
41
|
+
label: string;
|
42
|
+
constructor();
|
43
|
+
render(): import("lit-html").TemplateResult<1>;
|
44
|
+
static styles: Array<CSSResult>;
|
45
|
+
}
|
46
|
+
export default AlertChip;
|
@@ -0,0 +1,79 @@
|
|
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 styles from './alertchip.styles';
|
13
|
+
import { Component } from '../../models';
|
14
|
+
import { DEFAULTS } from './alertchip.constants';
|
15
|
+
import { getAlertIcon } from './alertchip.utils';
|
16
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
17
|
+
/**
|
18
|
+
* mdc-alertchip component is an interactive chip that consumers can use to represent an alert.
|
19
|
+
*
|
20
|
+
* - It supports a leading icon along with label.
|
21
|
+
* - It supports 5 variants of alerts - neutral, warning, error, success, and informational
|
22
|
+
*
|
23
|
+
* This component is built by extending Buttonsimple.
|
24
|
+
*
|
25
|
+
* @tagname mdc-alertchip
|
26
|
+
*
|
27
|
+
* @dependency mdc-icon
|
28
|
+
* @dependency mdc-text
|
29
|
+
*
|
30
|
+
* @cssproperty --mdc-chip-color - The color of the label text
|
31
|
+
* @cssproperty --mdc-chip-icon-color - The color of the icon
|
32
|
+
* @cssproperty --mdc-chip-border-color - The border color of the alertchip
|
33
|
+
* @cssproperty --mdc-chip-background-color - The background color of the alertchip
|
34
|
+
*
|
35
|
+
*/
|
36
|
+
class AlertChip extends Buttonsimple {
|
37
|
+
constructor() {
|
38
|
+
super();
|
39
|
+
/**
|
40
|
+
* The variant of the alertchip. It supports 5 variants
|
41
|
+
* - neutral
|
42
|
+
* - warning
|
43
|
+
* - error
|
44
|
+
* - success
|
45
|
+
* - informational
|
46
|
+
*
|
47
|
+
* @default neutral
|
48
|
+
*/
|
49
|
+
this.variant = DEFAULTS.VARIANT;
|
50
|
+
/**
|
51
|
+
* The visible label text of the alertchip.
|
52
|
+
*
|
53
|
+
* We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
54
|
+
* including empty spaces to split words.
|
55
|
+
*/
|
56
|
+
this.label = '';
|
57
|
+
this.disabled = undefined;
|
58
|
+
this.softDisabled = undefined;
|
59
|
+
this.active = undefined;
|
60
|
+
this.size = DEFAULTS.SIZE;
|
61
|
+
this.role = DEFAULTS.ROLE;
|
62
|
+
}
|
63
|
+
render() {
|
64
|
+
return html `
|
65
|
+
<mdc-icon part="icon" name="${getAlertIcon(this.variant)}" length-unit="rem" size="1"></mdc-icon>
|
66
|
+
<mdc-text part="label" type="${DEFAULTS.TEXT_TYPE}" tagname="${DEFAULTS.TAG_NAME}">${this.label}</mdc-text>
|
67
|
+
`;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
AlertChip.styles = [...Component.styles, ...styles];
|
71
|
+
__decorate([
|
72
|
+
property({ type: String }),
|
73
|
+
__metadata("design:type", String)
|
74
|
+
], AlertChip.prototype, "variant", void 0);
|
75
|
+
__decorate([
|
76
|
+
property({ type: String }),
|
77
|
+
__metadata("design:type", Object)
|
78
|
+
], AlertChip.prototype, "label", void 0);
|
79
|
+
export default AlertChip;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
declare const TAG_NAME: "mdc-alertchip";
|
2
|
+
declare const VARIANTS: {
|
3
|
+
readonly NEUTRAL: "neutral";
|
4
|
+
readonly ERROR: "error";
|
5
|
+
readonly SUCCESS: "success";
|
6
|
+
readonly WARNING: "warning";
|
7
|
+
readonly INFORMATIONAL: "informational";
|
8
|
+
};
|
9
|
+
declare const DEFAULTS: {
|
10
|
+
readonly VARIANT: "neutral";
|
11
|
+
readonly TEXT_TYPE: "body-midsize-regular";
|
12
|
+
readonly TAG_NAME: "span";
|
13
|
+
readonly SIZE: 24;
|
14
|
+
readonly ROLE: "button";
|
15
|
+
};
|
16
|
+
export { DEFAULTS, TAG_NAME, VARIANTS };
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { BUTTON_SIZES } from '../buttonsimple/buttonsimple.constants';
|
3
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
4
|
+
const TAG_NAME = utils.constructTagName('alertchip');
|
5
|
+
const VARIANTS = {
|
6
|
+
NEUTRAL: 'neutral',
|
7
|
+
ERROR: 'error',
|
8
|
+
SUCCESS: 'success',
|
9
|
+
WARNING: 'warning',
|
10
|
+
INFORMATIONAL: 'informational',
|
11
|
+
};
|
12
|
+
const DEFAULTS = {
|
13
|
+
VARIANT: VARIANTS.NEUTRAL,
|
14
|
+
TEXT_TYPE: TYPE.BODY_MIDSIZE_REGULAR,
|
15
|
+
TAG_NAME: VALID_TEXT_TAGS.SPAN,
|
16
|
+
SIZE: BUTTON_SIZES[24],
|
17
|
+
ROLE: 'button',
|
18
|
+
};
|
19
|
+
export { DEFAULTS, TAG_NAME, VARIANTS };
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFitContentStyles, hostFocusRingStyles } 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
|
+
cursor: pointer;
|
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-alert-default-normal);
|
15
|
+
--mdc-chip-icon-color: var(--mds-color-theme-text-secondary-normal);
|
16
|
+
|
17
|
+
border-color: var(--mdc-chip-border-color);
|
18
|
+
background: var(--mdc-chip-background-color);
|
19
|
+
}
|
20
|
+
|
21
|
+
:host::part(label){
|
22
|
+
color: var(--mdc-chip-color);
|
23
|
+
}
|
24
|
+
|
25
|
+
:host([variant="neutral"])::part(icon){
|
26
|
+
color: var(--mdc-chip-icon-color);
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
:host([variant="neutral"]:hover){
|
31
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-default-hover);
|
32
|
+
}
|
33
|
+
|
34
|
+
:host([variant="neutral"]:active){
|
35
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-default-active);
|
36
|
+
}
|
37
|
+
|
38
|
+
:host([variant="error"])::part(icon){
|
39
|
+
--mdc-chip-icon-color: var(--mds-color-theme-text-error-normal);
|
40
|
+
}
|
41
|
+
|
42
|
+
:host([variant="error"]){
|
43
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-cancel-normal);
|
44
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-error-normal);
|
45
|
+
}
|
46
|
+
|
47
|
+
:host([variant="error"]:hover){
|
48
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-error-hover);
|
49
|
+
}
|
50
|
+
|
51
|
+
:host([variant="error"]:active){
|
52
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-error-active);
|
53
|
+
}
|
54
|
+
|
55
|
+
:host([variant="warning"])::part(icon){
|
56
|
+
--mdc-chip-icon-color: var(--mds-color-theme-text-warning-normal);
|
57
|
+
}
|
58
|
+
|
59
|
+
:host([variant="warning"]){
|
60
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-warning-normal);
|
61
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-warning-normal);
|
62
|
+
}
|
63
|
+
|
64
|
+
:host([variant="warning"]:hover){
|
65
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-warning-hover);
|
66
|
+
}
|
67
|
+
|
68
|
+
:host([variant="warning"]:active){
|
69
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-warning-active);
|
70
|
+
}
|
71
|
+
|
72
|
+
:host([variant="success"])::part(icon){
|
73
|
+
--mdc-chip-icon-color: var(--mds-color-theme-text-success-normal);
|
74
|
+
}
|
75
|
+
|
76
|
+
:host([variant="success"]){
|
77
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-join-normal);
|
78
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-success-normal);
|
79
|
+
}
|
80
|
+
|
81
|
+
:host([variant="success"]:hover){
|
82
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-success-hover);
|
83
|
+
}
|
84
|
+
|
85
|
+
:host([variant="success"]:active){
|
86
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-success-active);
|
87
|
+
}
|
88
|
+
|
89
|
+
:host([variant="informational"])::part(icon){
|
90
|
+
--mdc-chip-icon-color: var(--mds-color-theme-text-accent-normal);
|
91
|
+
}
|
92
|
+
|
93
|
+
:host([variant="informational"]){
|
94
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-theme-normal);
|
95
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-theme-normal);
|
96
|
+
}
|
97
|
+
|
98
|
+
:host([variant="informational"]:hover){
|
99
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-theme-hover);
|
100
|
+
}
|
101
|
+
|
102
|
+
:host([variant="informational"]:active){
|
103
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-alert-theme-active);
|
104
|
+
}
|
105
|
+
`;
|
106
|
+
export default [hostFitContentStyles, styles, ...hostFocusRingStyles()];
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { ValueOf } from '../../utils/types';
|
2
|
+
import { VARIANTS } from './alertchip.constants';
|
3
|
+
import type { IconNames } from '../icon/icon.types';
|
4
|
+
type VariantType = ValueOf<typeof VARIANTS>;
|
5
|
+
type IconListType = Extract<IconNames, 'error-legacy-badge-filled' | 'warning-badge-filled' | 'check-circle-badge-filled' | 'dnd-presence-badge-filled' | 'info-badge-filled'>;
|
6
|
+
export { VariantType, IconListType };
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { VARIANTS } from './alertchip.constants';
|
2
|
+
const getAlertIcon = (type) => {
|
3
|
+
const alertIcon = {
|
4
|
+
[VARIANTS.ERROR]: 'error-legacy-badge-filled',
|
5
|
+
[VARIANTS.WARNING]: 'warning-badge-filled',
|
6
|
+
[VARIANTS.SUCCESS]: 'check-circle-badge-filled',
|
7
|
+
[VARIANTS.INFORMATIONAL]: 'info-badge-filled',
|
8
|
+
[VARIANTS.NEUTRAL]: 'dnd-presence-badge-filled',
|
9
|
+
};
|
10
|
+
return alertIcon[type];
|
11
|
+
};
|
12
|
+
export { getAlertIcon };
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { CSSResult } from 'lit';
|
2
|
+
import type { ColorType } from './chip.types';
|
3
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
4
|
+
declare const Chip_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & typeof Buttonsimple;
|
5
|
+
/**
|
6
|
+
* mdc-chip is an interactive element that can be used to represent a chip. It supports a leading icon along with label.
|
7
|
+
* Consumers can wrap this component around a tooltip to provide additional context.
|
8
|
+
*
|
9
|
+
* It is recommended to keep the label text for the chip component concise and compact.
|
10
|
+
* For best results, we recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
11
|
+
* including empty spaces to split words.
|
12
|
+
*
|
13
|
+
* This component is built by extending Buttonsimple.
|
14
|
+
*
|
15
|
+
* @tagname mdc-chip
|
16
|
+
*
|
17
|
+
* @dependency mdc-icon
|
18
|
+
* @dependency mdc-text
|
19
|
+
*
|
20
|
+
* @cssproperty --mdc-chip-color - The color of the chip.
|
21
|
+
* @cssproperty --mdc-chip-border-color - The border color of the chip.
|
22
|
+
* @cssproperty --mdc-chip-background-color - The background color of the chip.
|
23
|
+
*
|
24
|
+
*/
|
25
|
+
declare class Chip extends Chip_base {
|
26
|
+
/**
|
27
|
+
* The color of the chip. It supports the following colors
|
28
|
+
* - default
|
29
|
+
* - cobalt
|
30
|
+
* - gold
|
31
|
+
* - lime
|
32
|
+
* - mint
|
33
|
+
* - pink
|
34
|
+
* - purple
|
35
|
+
* - slate
|
36
|
+
* - violet
|
37
|
+
*
|
38
|
+
* @default default
|
39
|
+
*/
|
40
|
+
color: ColorType;
|
41
|
+
/**
|
42
|
+
* The visible label text of the chip.
|
43
|
+
*
|
44
|
+
* We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
45
|
+
* including empty spaces to split words.
|
46
|
+
*/
|
47
|
+
label: string;
|
48
|
+
constructor();
|
49
|
+
/**
|
50
|
+
* Renders the icon element if available.
|
51
|
+
* @returns The icon element if available, otherwise nothing.
|
52
|
+
*/
|
53
|
+
private renderIcon;
|
54
|
+
render(): import("lit-html").TemplateResult<1>;
|
55
|
+
static styles: Array<CSSResult>;
|
56
|
+
}
|
57
|
+
export default Chip;
|
@@ -0,0 +1,97 @@
|
|
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 styles from './chip.styles';
|
13
|
+
import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
14
|
+
import { Component } from '../../models';
|
15
|
+
import { DEFAULTS } from './chip.constants';
|
16
|
+
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
17
|
+
/**
|
18
|
+
* mdc-chip is an interactive element that can be used to represent a chip. It supports a leading icon along with label.
|
19
|
+
* Consumers can wrap this component around a tooltip to provide additional context.
|
20
|
+
*
|
21
|
+
* It is recommended to keep the label text for the chip component concise and compact.
|
22
|
+
* For best results, we recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
23
|
+
* including empty spaces to split words.
|
24
|
+
*
|
25
|
+
* This component is built by extending Buttonsimple.
|
26
|
+
*
|
27
|
+
* @tagname mdc-chip
|
28
|
+
*
|
29
|
+
* @dependency mdc-icon
|
30
|
+
* @dependency mdc-text
|
31
|
+
*
|
32
|
+
* @cssproperty --mdc-chip-color - The color of the chip.
|
33
|
+
* @cssproperty --mdc-chip-border-color - The border color of the chip.
|
34
|
+
* @cssproperty --mdc-chip-background-color - The background color of the chip.
|
35
|
+
*
|
36
|
+
*/
|
37
|
+
class Chip extends IconNameMixin(Buttonsimple) {
|
38
|
+
constructor() {
|
39
|
+
super();
|
40
|
+
/**
|
41
|
+
* The color of the chip. It supports the following colors
|
42
|
+
* - default
|
43
|
+
* - cobalt
|
44
|
+
* - gold
|
45
|
+
* - lime
|
46
|
+
* - mint
|
47
|
+
* - pink
|
48
|
+
* - purple
|
49
|
+
* - slate
|
50
|
+
* - violet
|
51
|
+
*
|
52
|
+
* @default default
|
53
|
+
*/
|
54
|
+
this.color = DEFAULTS.COLOR;
|
55
|
+
/**
|
56
|
+
* The visible label text of the chip.
|
57
|
+
*
|
58
|
+
* We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
59
|
+
* including empty spaces to split words.
|
60
|
+
*/
|
61
|
+
this.label = '';
|
62
|
+
this.role = DEFAULTS.ROLE;
|
63
|
+
this.size = DEFAULTS.SIZE;
|
64
|
+
this.active = undefined;
|
65
|
+
this.softDisabled = undefined;
|
66
|
+
}
|
67
|
+
/**
|
68
|
+
* Renders the icon element if available.
|
69
|
+
* @returns The icon element if available, otherwise nothing.
|
70
|
+
*/
|
71
|
+
renderIcon() {
|
72
|
+
if (!this.iconName)
|
73
|
+
return nothing;
|
74
|
+
return html `
|
75
|
+
<mdc-icon
|
76
|
+
name="${this.iconName}"
|
77
|
+
length-unit="rem"
|
78
|
+
size="1"></mdc-icon>
|
79
|
+
`;
|
80
|
+
}
|
81
|
+
render() {
|
82
|
+
return html `
|
83
|
+
${this.renderIcon()}
|
84
|
+
<mdc-text type="${DEFAULTS.TEXT_TYPE}" tagname="${DEFAULTS.TAG_NAME}">${this.label}</mdc-text>
|
85
|
+
`;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
Chip.styles = [...Component.styles, ...styles];
|
89
|
+
__decorate([
|
90
|
+
property({ type: String, reflect: true }),
|
91
|
+
__metadata("design:type", String)
|
92
|
+
], Chip.prototype, "color", void 0);
|
93
|
+
__decorate([
|
94
|
+
property({ type: String }),
|
95
|
+
__metadata("design:type", Object)
|
96
|
+
], Chip.prototype, "label", void 0);
|
97
|
+
export default Chip;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
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 PINK: "pink";
|
9
|
+
readonly PURPLE: "purple";
|
10
|
+
readonly SLATE: "slate";
|
11
|
+
readonly VIOLET: "violet";
|
12
|
+
};
|
13
|
+
declare const DEFAULTS: {
|
14
|
+
COLOR: "default";
|
15
|
+
TEXT_TYPE: "body-midsize-regular";
|
16
|
+
TAG_NAME: "span";
|
17
|
+
SIZE: 24;
|
18
|
+
ROLE: string;
|
19
|
+
};
|
20
|
+
export { TAG_NAME, COLOR, DEFAULTS };
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { BUTTON_SIZES } from '../buttonsimple/buttonsimple.constants';
|
3
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
4
|
+
const TAG_NAME = utils.constructTagName('chip');
|
5
|
+
const COLOR = {
|
6
|
+
DEFAULT: 'default',
|
7
|
+
COBALT: 'cobalt',
|
8
|
+
GOLD: 'gold',
|
9
|
+
LIME: 'lime',
|
10
|
+
MINT: 'mint',
|
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
|
+
SIZE: BUTTON_SIZES[24],
|
21
|
+
ROLE: 'button',
|
22
|
+
};
|
23
|
+
export { TAG_NAME, COLOR, DEFAULTS };
|
@@ -0,0 +1,140 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
import { hostFitContentStyles, hostFocusRingStyles } 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
|
+
cursor: pointer;
|
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='default']:hover) {
|
22
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-default-hover);
|
23
|
+
}
|
24
|
+
|
25
|
+
:host([color='default']:active) {
|
26
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-default-active);
|
27
|
+
}
|
28
|
+
|
29
|
+
:host([color='cobalt']) {
|
30
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-theme-normal);
|
31
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-cobalt-normal);
|
32
|
+
}
|
33
|
+
|
34
|
+
:host([color='cobalt']:hover) {
|
35
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-cobalt-hover);
|
36
|
+
}
|
37
|
+
|
38
|
+
:host([color='cobalt']:active) {
|
39
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-cobalt-active);
|
40
|
+
}
|
41
|
+
|
42
|
+
:host([color='gold']) {
|
43
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-label-gold);
|
44
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-gold-normal);
|
45
|
+
}
|
46
|
+
|
47
|
+
:host([color='gold']:hover) {
|
48
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-gold-hover);
|
49
|
+
}
|
50
|
+
|
51
|
+
:host([color='gold']:active) {
|
52
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-gold-active);
|
53
|
+
}
|
54
|
+
|
55
|
+
:host([color='lime']) {
|
56
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-label-lime);
|
57
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-lime-normal);
|
58
|
+
}
|
59
|
+
|
60
|
+
:host([color='lime']:hover) {
|
61
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-lime-hover);
|
62
|
+
}
|
63
|
+
|
64
|
+
:host([color='lime']:active) {
|
65
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-lime-active);
|
66
|
+
}
|
67
|
+
|
68
|
+
:host([color='mint']) {
|
69
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-label-mint);
|
70
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-mint-normal);
|
71
|
+
}
|
72
|
+
|
73
|
+
:host([color='mint']:hover) {
|
74
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-mint-hover);
|
75
|
+
}
|
76
|
+
|
77
|
+
:host([color='mint']:active) {
|
78
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-mint-active);
|
79
|
+
}
|
80
|
+
|
81
|
+
:host([color='pink']) {
|
82
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-label-pink);
|
83
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-pink-normal);
|
84
|
+
}
|
85
|
+
|
86
|
+
:host([color='pink']:hover) {
|
87
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-pink-hover);
|
88
|
+
}
|
89
|
+
|
90
|
+
:host([color='pink']:active) {
|
91
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-pink-active);
|
92
|
+
}
|
93
|
+
|
94
|
+
:host([color='purple']) {
|
95
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-label-purple);
|
96
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-purple-normal);
|
97
|
+
}
|
98
|
+
|
99
|
+
:host([color='purple']:hover) {
|
100
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-purple-hover);
|
101
|
+
}
|
102
|
+
|
103
|
+
:host([color='purple']:active) {
|
104
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-purple-active);
|
105
|
+
}
|
106
|
+
|
107
|
+
:host([color='slate']) {
|
108
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-label-slate);
|
109
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-slate-normal);
|
110
|
+
}
|
111
|
+
|
112
|
+
:host([color='slate']:hover) {
|
113
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-slate-hover);
|
114
|
+
}
|
115
|
+
|
116
|
+
:host([color='slate']:active) {
|
117
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-slate-active);
|
118
|
+
}
|
119
|
+
|
120
|
+
:host([color='violet']) {
|
121
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-label-violet);
|
122
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-violet-normal);
|
123
|
+
}
|
124
|
+
|
125
|
+
:host([color='violet']:hover) {
|
126
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-violet-hover);
|
127
|
+
}
|
128
|
+
|
129
|
+
:host([color='violet']:active) {
|
130
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-violet-active);
|
131
|
+
}
|
132
|
+
|
133
|
+
:host([disabled]), :host([disabled]:hover), :host([disabled]:active) {
|
134
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-primary-disabled);
|
135
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-primary-disabled);
|
136
|
+
--mdc-chip-color: var(--mds-color-theme-text-primary-disabled);
|
137
|
+
cursor: auto;
|
138
|
+
}
|
139
|
+
`;
|
140
|
+
export default [hostFitContentStyles, styles, ...hostFocusRingStyles()];
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|