@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,30 @@
|
|
1
|
+
import { CSSResult, PropertyValues } from 'lit';
|
2
|
+
import Chip from '../chip/chip.component';
|
3
|
+
/**
|
4
|
+
* mdc-filterchip component is an interactive chip that consumers can use to select or deselect.
|
5
|
+
* They can be found with lists or tables as quick filters.
|
6
|
+
*
|
7
|
+
* This component is built on top of the mdc-chip component.
|
8
|
+
*
|
9
|
+
* @tagname mdc-filterchip
|
10
|
+
*
|
11
|
+
*/
|
12
|
+
declare class FilterChip extends Chip {
|
13
|
+
/**
|
14
|
+
* The selected state of the filterchip.
|
15
|
+
*
|
16
|
+
* @default false
|
17
|
+
*/
|
18
|
+
selected: boolean;
|
19
|
+
constructor();
|
20
|
+
/**
|
21
|
+
* Sets the selected state of the filterchip along with the icon.
|
22
|
+
* aria-pressed attribute is also set to true or false.
|
23
|
+
* @param selected - The selected state of the filterchip.
|
24
|
+
*/
|
25
|
+
private setSelected;
|
26
|
+
protected executeAction(): void;
|
27
|
+
update(changedProperties: PropertyValues): void;
|
28
|
+
static styles: Array<CSSResult>;
|
29
|
+
}
|
30
|
+
export default FilterChip;
|
@@ -0,0 +1,64 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { property } from 'lit/decorators.js';
|
11
|
+
import Chip from '../chip/chip.component';
|
12
|
+
import styles from './filterchip.styles';
|
13
|
+
import { DEFAULTS } from './filterchip.constants';
|
14
|
+
/**
|
15
|
+
* mdc-filterchip component is an interactive chip that consumers can use to select or deselect.
|
16
|
+
* They can be found with lists or tables as quick filters.
|
17
|
+
*
|
18
|
+
* This component is built on top of the mdc-chip component.
|
19
|
+
*
|
20
|
+
* @tagname mdc-filterchip
|
21
|
+
*
|
22
|
+
*/
|
23
|
+
class FilterChip extends Chip {
|
24
|
+
constructor() {
|
25
|
+
super();
|
26
|
+
/**
|
27
|
+
* The selected state of the filterchip.
|
28
|
+
*
|
29
|
+
* @default false
|
30
|
+
*/
|
31
|
+
this.selected = false;
|
32
|
+
this.color = DEFAULTS.COLOR;
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* Sets the selected state of the filterchip along with the icon.
|
36
|
+
* aria-pressed attribute is also set to true or false.
|
37
|
+
* @param selected - The selected state of the filterchip.
|
38
|
+
*/
|
39
|
+
setSelected(selected) {
|
40
|
+
if (selected) {
|
41
|
+
this.iconName = DEFAULTS.ICON_NAME;
|
42
|
+
this.setAttribute('aria-pressed', 'true');
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
this.iconName = undefined;
|
46
|
+
this.setAttribute('aria-pressed', 'false');
|
47
|
+
}
|
48
|
+
}
|
49
|
+
executeAction() {
|
50
|
+
this.selected = !this.selected;
|
51
|
+
}
|
52
|
+
update(changedProperties) {
|
53
|
+
super.update(changedProperties);
|
54
|
+
if (changedProperties.has('selected')) {
|
55
|
+
this.setSelected(this.selected);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
FilterChip.styles = [...Chip.styles, ...styles];
|
60
|
+
__decorate([
|
61
|
+
property({ type: Boolean, reflect: true }),
|
62
|
+
__metadata("design:type", Object)
|
63
|
+
], FilterChip.prototype, "selected", void 0);
|
64
|
+
export default FilterChip;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = css `
|
3
|
+
:host([selected]){
|
4
|
+
border: 2px solid;
|
5
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-default-active);
|
6
|
+
}
|
7
|
+
|
8
|
+
:host([selected]:active) {
|
9
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-default-normal);
|
10
|
+
}
|
11
|
+
|
12
|
+
:host([selected]:focus) {
|
13
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-default-active);
|
14
|
+
}
|
15
|
+
|
16
|
+
:host([disabled]), :host([disabled]:hover), :host([disabled]:active) {
|
17
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-primary-disabled);
|
18
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-primary-disabled);
|
19
|
+
--mdc-chip-color: var(--mds-color-theme-text-primary-disabled);
|
20
|
+
cursor: auto;
|
21
|
+
}
|
22
|
+
`;
|
23
|
+
export default [styles];
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { CSSResult } from 'lit';
|
2
|
+
import { Component } from '../../models';
|
3
|
+
declare const InputChip_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/IconNameMixin").IconNameMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
|
4
|
+
/**
|
5
|
+
* mdc-inputchip component is an interactive chip that consumers can use to represent an input.
|
6
|
+
*
|
7
|
+
* - It supports a leading icon along with label.
|
8
|
+
* - It supports an error state for validation.
|
9
|
+
* - It supports a close button to remove the chip.
|
10
|
+
*
|
11
|
+
* @tagname mdc-inputchip
|
12
|
+
*
|
13
|
+
* @dependency mdc-button
|
14
|
+
* @dependency mdc-icon
|
15
|
+
* @dependency mdc-text
|
16
|
+
*
|
17
|
+
* @event click - (React: onClick) This event is dispatched when the close button is clicked.
|
18
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the close button.
|
19
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the close button.
|
20
|
+
* @event focus - (React: onFocus) This event is dispatched when the close button receives focus.
|
21
|
+
*
|
22
|
+
* @cssproperty --mdc-chip-color - The color of the chip.
|
23
|
+
* @cssproperty --mdc-chip-border-color - The border color of the chip.
|
24
|
+
* @cssproperty --mdc-chip-background-color - The background color of the chip.
|
25
|
+
*
|
26
|
+
*/
|
27
|
+
declare class InputChip extends InputChip_base {
|
28
|
+
/**
|
29
|
+
* The label of the inputchip.
|
30
|
+
*
|
31
|
+
* We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
32
|
+
* including empty spaces to split words.
|
33
|
+
*/
|
34
|
+
label: string;
|
35
|
+
/**
|
36
|
+
* The error state of the inputchip.
|
37
|
+
*
|
38
|
+
* @default false
|
39
|
+
*/
|
40
|
+
error: boolean;
|
41
|
+
/**
|
42
|
+
* The aria-label of the close button.
|
43
|
+
*/
|
44
|
+
clearAriaLabel: string;
|
45
|
+
/**
|
46
|
+
* Renders the icon element if available.
|
47
|
+
* @returns The icon element if available, otherwise nothing.
|
48
|
+
*/
|
49
|
+
private renderIcon;
|
50
|
+
/**
|
51
|
+
* Handles the behavior of the close button on click event.
|
52
|
+
* @param event - The event object.
|
53
|
+
*/
|
54
|
+
private handleClose;
|
55
|
+
render(): import("lit-html").TemplateResult<1>;
|
56
|
+
static styles: Array<CSSResult>;
|
57
|
+
}
|
58
|
+
export default InputChip;
|
@@ -0,0 +1,113 @@
|
|
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 './inputchip.styles';
|
13
|
+
import { Component } from '../../models';
|
14
|
+
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
15
|
+
import { IconNameMixin } from '../../utils/mixins/IconNameMixin';
|
16
|
+
import { DEFAULTS } from './inputchip.constants';
|
17
|
+
/**
|
18
|
+
* mdc-inputchip component is an interactive chip that consumers can use to represent an input.
|
19
|
+
*
|
20
|
+
* - It supports a leading icon along with label.
|
21
|
+
* - It supports an error state for validation.
|
22
|
+
* - It supports a close button to remove the chip.
|
23
|
+
*
|
24
|
+
* @tagname mdc-inputchip
|
25
|
+
*
|
26
|
+
* @dependency mdc-button
|
27
|
+
* @dependency mdc-icon
|
28
|
+
* @dependency mdc-text
|
29
|
+
*
|
30
|
+
* @event click - (React: onClick) This event is dispatched when the close button is clicked.
|
31
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the close button.
|
32
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the close button.
|
33
|
+
* @event focus - (React: onFocus) This event is dispatched when the close button receives focus.
|
34
|
+
*
|
35
|
+
* @cssproperty --mdc-chip-color - The color of the chip.
|
36
|
+
* @cssproperty --mdc-chip-border-color - The border color of the chip.
|
37
|
+
* @cssproperty --mdc-chip-background-color - The background color of the chip.
|
38
|
+
*
|
39
|
+
*/
|
40
|
+
class InputChip extends IconNameMixin(DisabledMixin(Component)) {
|
41
|
+
constructor() {
|
42
|
+
super(...arguments);
|
43
|
+
/**
|
44
|
+
* The label of the inputchip.
|
45
|
+
*
|
46
|
+
* We recommend limiting the <b>maximum length of the label text to 20 characters</b>,
|
47
|
+
* including empty spaces to split words.
|
48
|
+
*/
|
49
|
+
this.label = '';
|
50
|
+
/**
|
51
|
+
* The error state of the inputchip.
|
52
|
+
*
|
53
|
+
* @default false
|
54
|
+
*/
|
55
|
+
this.error = false;
|
56
|
+
/**
|
57
|
+
* The aria-label of the close button.
|
58
|
+
*/
|
59
|
+
this.clearAriaLabel = '';
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Renders the icon element if available.
|
63
|
+
* @returns The icon element if available, otherwise nothing.
|
64
|
+
*/
|
65
|
+
renderIcon() {
|
66
|
+
if (!this.iconName)
|
67
|
+
return nothing;
|
68
|
+
return html `
|
69
|
+
<mdc-icon
|
70
|
+
name="${this.iconName}"
|
71
|
+
length-unit="rem"
|
72
|
+
size="1"></mdc-icon>
|
73
|
+
`;
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* Handles the behavior of the close button on click event.
|
77
|
+
* @param event - The event object.
|
78
|
+
*/
|
79
|
+
handleClose(event) {
|
80
|
+
event.stopPropagation(); // Prevents triggering click event twice
|
81
|
+
const EventConstructor = event.constructor;
|
82
|
+
this.dispatchEvent(new EventConstructor(event.type, event));
|
83
|
+
}
|
84
|
+
render() {
|
85
|
+
return html `
|
86
|
+
${this.renderIcon()}
|
87
|
+
<mdc-text type="${DEFAULTS.TEXT_TYPE}" tagname="${DEFAULTS.TAG_NAME}">${this.label}</mdc-text>
|
88
|
+
<mdc-button
|
89
|
+
?disabled="${this.disabled}"
|
90
|
+
variant="tertiary"
|
91
|
+
part="close-icon"
|
92
|
+
aria-label="${this.clearAriaLabel}"
|
93
|
+
prefix-icon="${DEFAULTS.CLOSE_ICON}"
|
94
|
+
size="20"
|
95
|
+
@click="${this.handleClose}"
|
96
|
+
></mdc-button>
|
97
|
+
`;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
InputChip.styles = [...Component.styles, ...styles];
|
101
|
+
__decorate([
|
102
|
+
property({ type: String }),
|
103
|
+
__metadata("design:type", Object)
|
104
|
+
], InputChip.prototype, "label", void 0);
|
105
|
+
__decorate([
|
106
|
+
property({ type: Boolean }),
|
107
|
+
__metadata("design:type", Object)
|
108
|
+
], InputChip.prototype, "error", void 0);
|
109
|
+
__decorate([
|
110
|
+
property({ type: String, attribute: 'clear-aria-label' }),
|
111
|
+
__metadata("design:type", Object)
|
112
|
+
], InputChip.prototype, "clearAriaLabel", void 0);
|
113
|
+
export default InputChip;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import utils from '../../utils/tag-name';
|
2
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
3
|
+
const TAG_NAME = utils.constructTagName('inputchip');
|
4
|
+
const DEFAULTS = {
|
5
|
+
TEXT_TYPE: TYPE.BODY_MIDSIZE_REGULAR,
|
6
|
+
TAG_NAME: VALID_TEXT_TAGS.SPAN,
|
7
|
+
CLOSE_ICON: 'cancel-bold',
|
8
|
+
};
|
9
|
+
export { TAG_NAME, DEFAULTS };
|
@@ -0,0 +1,53 @@
|
|
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.25rem 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(:hover) {
|
22
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-default-hover);
|
23
|
+
}
|
24
|
+
|
25
|
+
:host(:active) {
|
26
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-default-active);
|
27
|
+
}
|
28
|
+
|
29
|
+
:host([error]){
|
30
|
+
--mdc-chip-border-color: var(--mds-color-theme-outline-cancel-normal);
|
31
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-error-normal);
|
32
|
+
}
|
33
|
+
|
34
|
+
:host([error]:hover) {
|
35
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-error-hover);
|
36
|
+
}
|
37
|
+
|
38
|
+
:host([error]:active) {
|
39
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-label-error-active);
|
40
|
+
}
|
41
|
+
|
42
|
+
:host([disabled]), :host([disabled]:hover), :host([disabled]:active) {
|
43
|
+
--mdc-chip-border-color: var(--mds-color-theme-common-outline-primary-disabled);
|
44
|
+
--mdc-chip-background-color: var(--mds-color-theme-background-primary-disabled);
|
45
|
+
--mdc-chip-color: var(--mds-color-theme-text-primary-disabled);
|
46
|
+
cursor: auto;
|
47
|
+
}
|
48
|
+
|
49
|
+
:host::part(close-icon){
|
50
|
+
border-radius: 0.25rem;
|
51
|
+
}
|
52
|
+
`;
|
53
|
+
export default [hostFitContentStyles, styles];
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { CSSResult, PropertyValues } from 'lit';
|
2
|
-
import { TemplateResult } from 'lit';
|
2
|
+
import { nothing, TemplateResult } from 'lit';
|
3
3
|
import { Component } from '../../models';
|
4
|
+
import type { TextType } from '../text/text.types';
|
4
5
|
import type { ListItemVariants } from './listitem.types';
|
5
6
|
declare const ListItem_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/TabIndexMixin").TabIndexMixinInterface> & typeof Component;
|
6
7
|
/**
|
@@ -84,7 +85,7 @@ declare class ListItem extends ListItem_base {
|
|
84
85
|
* @param content - The text content to be displayed within the slot.
|
85
86
|
* @returns A TemplateResult containing a slot with an `mdc-text` element of type BODY_SMALL_REGULAR.
|
86
87
|
*/
|
87
|
-
|
88
|
+
protected getText(slotName: string, type: TextType, content?: string): TemplateResult | typeof nothing;
|
88
89
|
/**
|
89
90
|
* Disable or enable all slotted elements in the leading and trailing slots.
|
90
91
|
* This is useful when the list item is disabled, to prevent the user from interacting with the controls.
|
@@ -61,7 +61,7 @@ class ListItem extends DataAriaLabelMixin(DisabledMixin(TabIndexMixin(Component)
|
|
61
61
|
* @default 'full-width'
|
62
62
|
*/
|
63
63
|
this.variant = DEFAULTS.VARIANT;
|
64
|
-
this.role = 'listitem';
|
64
|
+
this.role = this.role || 'listitem';
|
65
65
|
}
|
66
66
|
/**
|
67
67
|
* Generates a template for a text slot with the specified content.
|
@@ -25,11 +25,14 @@ const styles = css `
|
|
25
25
|
border-radius: 3.125rem;
|
26
26
|
}
|
27
27
|
:host([disabled]),
|
28
|
+
:host([disabled]:hover),
|
29
|
+
:host([disabled]:active),
|
28
30
|
:host([disabled])::part(leading-text-secondary-label),
|
29
31
|
:host([disabled])::part(leading-text-tertiary-label),
|
30
32
|
:host([disabled])::part(leading-text-primary-label),
|
31
33
|
:host([disabled])::part(trailing-text-side-header),
|
32
34
|
:host([disabled])::part(trailing-text-subline) {
|
35
|
+
background-color: unset;
|
33
36
|
color: var(--mdc-listitem-disabled-color);
|
34
37
|
cursor: default;
|
35
38
|
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import type { PropertyValues } from 'lit';
|
2
|
+
import { CSSResult } from 'lit';
|
3
|
+
import { Component } from '../../models';
|
4
|
+
declare const OptGroup_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
|
5
|
+
/**
|
6
|
+
* optgroup component, which creates a grouping of mdc-option within a listbox element.
|
7
|
+
*
|
8
|
+
* @dependency mdc-text
|
9
|
+
*
|
10
|
+
* @tagname mdc-optgroup
|
11
|
+
*
|
12
|
+
* @slot default - This is a default slot for mdc-option elements.
|
13
|
+
*
|
14
|
+
* @cssproperty --mdc-optgroup-disabled-color - Allows customization of the disabled option color.
|
15
|
+
*/
|
16
|
+
declare class OptGroup extends OptGroup_base {
|
17
|
+
/**
|
18
|
+
* The header text to be displayed on the top of the options list.
|
19
|
+
*/
|
20
|
+
label?: string;
|
21
|
+
/** @internal */
|
22
|
+
options: Array<HTMLElement>;
|
23
|
+
private setDisabledForAllOptions;
|
24
|
+
updated(changedProperties: PropertyValues): void;
|
25
|
+
render(): import("lit-html").TemplateResult<1>;
|
26
|
+
static styles: Array<CSSResult>;
|
27
|
+
}
|
28
|
+
export default OptGroup;
|
@@ -0,0 +1,77 @@
|
|
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, queryAssignedElements } from 'lit/decorators.js';
|
12
|
+
import { Component } from '../../models';
|
13
|
+
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
14
|
+
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
15
|
+
import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
|
16
|
+
import { HEADER_ID } from './optgroup.constants';
|
17
|
+
import styles from './optgroup.styles';
|
18
|
+
/**
|
19
|
+
* optgroup component, which creates a grouping of mdc-option within a listbox element.
|
20
|
+
*
|
21
|
+
* @dependency mdc-text
|
22
|
+
*
|
23
|
+
* @tagname mdc-optgroup
|
24
|
+
*
|
25
|
+
* @slot default - This is a default slot for mdc-option elements.
|
26
|
+
*
|
27
|
+
* @cssproperty --mdc-optgroup-disabled-color - Allows customization of the disabled option color.
|
28
|
+
*/
|
29
|
+
class OptGroup extends DataAriaLabelMixin(DisabledMixin(Component)) {
|
30
|
+
setDisabledForAllOptions() {
|
31
|
+
this.options.forEach((element) => {
|
32
|
+
if (this.disabled) {
|
33
|
+
element.setAttribute('disabled', '');
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
element.removeAttribute('disabled');
|
37
|
+
}
|
38
|
+
});
|
39
|
+
}
|
40
|
+
updated(changedProperties) {
|
41
|
+
super.updated(changedProperties);
|
42
|
+
if (changedProperties.has('disabled')) {
|
43
|
+
this.setDisabledForAllOptions();
|
44
|
+
}
|
45
|
+
}
|
46
|
+
render() {
|
47
|
+
var _a;
|
48
|
+
const headerText = this.label ? html `
|
49
|
+
<mdc-text
|
50
|
+
id="${HEADER_ID}"
|
51
|
+
part="header-text"
|
52
|
+
type="${TYPE.BODY_MIDSIZE_BOLD}"
|
53
|
+
tagname="${VALID_TEXT_TAGS.SPAN}"
|
54
|
+
>${this.label}</mdc-text>
|
55
|
+
` : nothing;
|
56
|
+
return html `
|
57
|
+
<div
|
58
|
+
role="group"
|
59
|
+
aria-labelledby="${this.label ? HEADER_ID : ''}"
|
60
|
+
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
61
|
+
>
|
62
|
+
${headerText}
|
63
|
+
<slot role="presentation"></slot>
|
64
|
+
</div>
|
65
|
+
`;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
OptGroup.styles = [...Component.styles, ...styles];
|
69
|
+
__decorate([
|
70
|
+
property({ type: String, reflect: true }),
|
71
|
+
__metadata("design:type", String)
|
72
|
+
], OptGroup.prototype, "label", void 0);
|
73
|
+
__decorate([
|
74
|
+
queryAssignedElements({ selector: 'mdc-option' }),
|
75
|
+
__metadata("design:type", Array)
|
76
|
+
], OptGroup.prototype, "options", void 0);
|
77
|
+
export default OptGroup;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { css } from 'lit';
|
2
|
+
const styles = css `
|
3
|
+
:host {
|
4
|
+
--mdc-optgroup-disabled-color: var(--mds-color-theme-text-primary-disabled);
|
5
|
+
}
|
6
|
+
:host::part(header-text) {
|
7
|
+
padding: 0.5rem 0.75rem;
|
8
|
+
height: 2.25rem;
|
9
|
+
}
|
10
|
+
:host([disabled]),
|
11
|
+
:host([disabled])::part(header-text) {
|
12
|
+
color: var(--mdc-optgroup-disabled-color);
|
13
|
+
cursor: default;
|
14
|
+
}
|
15
|
+
`;
|
16
|
+
export default [styles];
|