@momentum-design/components 0.36.0 → 0.36.2
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 +187 -133
- package/dist/browser/index.js.map +4 -4
- 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/components/popover/popover.component.js +2 -2
- package/dist/custom-elements.json +2195 -1307
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.js +3 -1
- 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
@@ -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];
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { CSSResult, PropertyValues } from 'lit';
|
2
|
+
import type { IconNames } from '../icon/icon.types';
|
3
|
+
import ListItem from '../listitem/listitem.component';
|
4
|
+
declare const Option_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & typeof ListItem;
|
5
|
+
/**
|
6
|
+
* option component, which is used as a list item in a select component.<br/>
|
7
|
+
* We can pass an icon which will be displayed in leading position of the option label text.
|
8
|
+
*
|
9
|
+
* @tagname mdc-option
|
10
|
+
*
|
11
|
+
* @slot default - This is a default/unnamed slot
|
12
|
+
*
|
13
|
+
* @event click - (React: onClick) This event is dispatched when the option is clicked.
|
14
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the option.
|
15
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the option.
|
16
|
+
* @event focus - (React: onFocus) This event is dispatched when the option receives focus.
|
17
|
+
*/
|
18
|
+
declare class Option extends Option_base {
|
19
|
+
/**
|
20
|
+
* The selected attribute is used to indicate that the option is selected.
|
21
|
+
*/
|
22
|
+
selected: boolean;
|
23
|
+
/**
|
24
|
+
* The prefix icon attribute is used to display the icon name on the left of the option label.
|
25
|
+
*/
|
26
|
+
prefixIcon?: IconNames;
|
27
|
+
/**
|
28
|
+
* Any additional description can be provided here for screen readers.
|
29
|
+
*/
|
30
|
+
ariaLabel: string | null;
|
31
|
+
constructor();
|
32
|
+
/**
|
33
|
+
* Listens to changes in the default slot and updates the label of the option accordingly.
|
34
|
+
* This is used to set the label of the option when it is not explicitly set.
|
35
|
+
* It is called internally when the slot is changed.
|
36
|
+
*/
|
37
|
+
private handleDefaultSlotChange;
|
38
|
+
/**
|
39
|
+
* Updates the attribute of the option to reflect the current state.
|
40
|
+
*/
|
41
|
+
private updateAttribute;
|
42
|
+
update(changedProperties: PropertyValues): void;
|
43
|
+
render(): import("lit-html").TemplateResult<1>;
|
44
|
+
static styles: Array<CSSResult>;
|
45
|
+
}
|
46
|
+
export default Option;
|
@@ -0,0 +1,115 @@
|
|
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 { ifDefined } from 'lit/directives/if-defined.js';
|
13
|
+
import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
14
|
+
import ListItem from '../listitem/listitem.component';
|
15
|
+
import { LISTITEM_VARIANTS } from '../listitem/listitem.constants';
|
16
|
+
import { TYPE } from '../text/text.constants';
|
17
|
+
import { SELECTED_ICON_NAME } from './option.constants';
|
18
|
+
import styles from './option.styles';
|
19
|
+
/**
|
20
|
+
* option component, which is used as a list item in a select component.<br/>
|
21
|
+
* We can pass an icon which will be displayed in leading position of the option label text.
|
22
|
+
*
|
23
|
+
* @tagname mdc-option
|
24
|
+
*
|
25
|
+
* @slot default - This is a default/unnamed slot
|
26
|
+
*
|
27
|
+
* @event click - (React: onClick) This event is dispatched when the option is clicked.
|
28
|
+
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the option.
|
29
|
+
* @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the option.
|
30
|
+
* @event focus - (React: onFocus) This event is dispatched when the option receives focus.
|
31
|
+
*/
|
32
|
+
class Option extends FormInternalsMixin(ListItem) {
|
33
|
+
constructor() {
|
34
|
+
super();
|
35
|
+
/**
|
36
|
+
* The selected attribute is used to indicate that the option is selected.
|
37
|
+
*/
|
38
|
+
this.selected = false;
|
39
|
+
/**
|
40
|
+
* Any additional description can be provided here for screen readers.
|
41
|
+
*/
|
42
|
+
this.ariaLabel = null;
|
43
|
+
this.role = 'option';
|
44
|
+
this.variant = LISTITEM_VARIANTS.INSET_RECTANGLE;
|
45
|
+
this.updateAttribute('aria-selected', `${this.selected}`);
|
46
|
+
this.updateAttribute('aria-disabled', `${this.disabled}`);
|
47
|
+
// Option will not contain below fields
|
48
|
+
this.name = undefined;
|
49
|
+
this.secondaryLabel = undefined;
|
50
|
+
this.sideHeaderText = undefined;
|
51
|
+
this.sublineText = undefined;
|
52
|
+
this.dataAriaLabel = undefined;
|
53
|
+
}
|
54
|
+
/**
|
55
|
+
* Listens to changes in the default slot and updates the label of the option accordingly.
|
56
|
+
* This is used to set the label of the option when it is not explicitly set.
|
57
|
+
* It is called internally when the slot is changed.
|
58
|
+
*/
|
59
|
+
handleDefaultSlotChange() {
|
60
|
+
var _a, _b, _c;
|
61
|
+
const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
|
62
|
+
if (slot && !this.label) {
|
63
|
+
this.label = (_c = (_b = slot.assignedNodes()[0]) === null || _b === void 0 ? void 0 : _b.textContent) === null || _c === void 0 ? void 0 : _c.trim();
|
64
|
+
}
|
65
|
+
}
|
66
|
+
/**
|
67
|
+
* Updates the attribute of the option to reflect the current state.
|
68
|
+
*/
|
69
|
+
updateAttribute(attributeName, value) {
|
70
|
+
this.setAttribute(attributeName, value);
|
71
|
+
}
|
72
|
+
update(changedProperties) {
|
73
|
+
super.update(changedProperties);
|
74
|
+
if (changedProperties.has('disabled')) {
|
75
|
+
this.updateAttribute('aria-disabled', `${this.disabled}`);
|
76
|
+
}
|
77
|
+
if (changedProperties.has('selected')) {
|
78
|
+
this.updateAttribute('aria-selected', `${this.selected}`);
|
79
|
+
}
|
80
|
+
}
|
81
|
+
render() {
|
82
|
+
const selectedIcon = this.selected ? html `
|
83
|
+
<mdc-icon slot="trailing-controls" name="${SELECTED_ICON_NAME}"></mdc-icon>
|
84
|
+
` : nothing;
|
85
|
+
const prefixIcon = this.prefixIcon ? html `
|
86
|
+
<mdc-icon slot="leading-controls" name="${ifDefined(this.prefixIcon)}"></mdc-icon>
|
87
|
+
` : nothing;
|
88
|
+
return html `
|
89
|
+
<div part="leading">
|
90
|
+
${prefixIcon}
|
91
|
+
<div part="leading-text">
|
92
|
+
${this.getText('leading-text-primary-label', TYPE.BODY_MIDSIZE_REGULAR, this.label)}
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
<div part="trailing">
|
96
|
+
${selectedIcon}
|
97
|
+
</div>
|
98
|
+
<slot part="default-slot" @slotchange="${this.handleDefaultSlotChange}"></slot>
|
99
|
+
`;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
Option.styles = [...ListItem.styles, ...styles];
|
103
|
+
__decorate([
|
104
|
+
property({ type: Boolean, reflect: true }),
|
105
|
+
__metadata("design:type", Object)
|
106
|
+
], Option.prototype, "selected", void 0);
|
107
|
+
__decorate([
|
108
|
+
property({ type: String, reflect: true, attribute: 'prefix-icon' }),
|
109
|
+
__metadata("design:type", String)
|
110
|
+
], Option.prototype, "prefixIcon", void 0);
|
111
|
+
__decorate([
|
112
|
+
property({ type: String, reflect: true, attribute: 'aria-label' }),
|
113
|
+
__metadata("design:type", Object)
|
114
|
+
], Option.prototype, "ariaLabel", void 0);
|
115
|
+
export default Option;
|
@@ -578,11 +578,11 @@ class Popover extends FocusTrapMixin(Component) {
|
|
578
578
|
}
|
579
579
|
Popover.styles = [...Component.styles, ...styles];
|
580
580
|
__decorate([
|
581
|
-
property({ type: String }),
|
581
|
+
property({ type: String, reflect: true }),
|
582
582
|
__metadata("design:type", String)
|
583
583
|
], Popover.prototype, "id", void 0);
|
584
584
|
__decorate([
|
585
|
-
property({ type: String }),
|
585
|
+
property({ type: String, reflect: true }),
|
586
586
|
__metadata("design:type", String)
|
587
587
|
], Popover.prototype, "triggerID", void 0);
|
588
588
|
__decorate([
|