@momentum-design/components 0.102.3 → 0.102.4

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.
@@ -1,5 +1,4 @@
1
1
  import List from './list.component';
2
- import '../text';
3
2
  declare global {
4
3
  interface HTMLElementTagNameMap {
5
4
  ['mdc-list']: List;
@@ -1,5 +1,4 @@
1
1
  import List from './list.component';
2
2
  import { TAG_NAME } from './list.constants';
3
- import '../text';
4
3
  List.register(TAG_NAME);
5
4
  export default List;
@@ -1,29 +1,26 @@
1
1
  import type { CSSResult } from 'lit';
2
2
  import { Component } from '../../models';
3
- import type { RoleType } from '../../utils/roles';
4
- declare const List_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof Component;
5
3
  /**
6
4
  * mdc-list component is used to display a group of list items. It is used as a container to wrap other list items.
7
5
  *
6
+ * To add a header to the list, use the `mdc-listheader` component and place it in the `list-header` slot.
7
+ * `mdc-listitem` components can be placed in the default slot.
8
+ *
8
9
  * @tagname mdc-list
9
10
  *
10
- * @dependency mdc-text
11
+ * @slot default - This is a default/unnamed slot, where listitems can be placed.
12
+ * @slot list-header - This slot is used to pass a header for the list, which can be a `mdc-listheader` component.
11
13
  *
12
- * @slot default - This is a default/unnamed slot
14
+ * @csspart container - The container slot around the list items
13
15
  */
14
- declare class List extends List_base {
16
+ declare class List extends Component {
15
17
  /**
16
18
  * @internal
17
19
  * Get all listitem elements which are not disabled in the list.
18
20
  */
19
- listItems: Array<HTMLElement>;
20
- /**
21
- * The header text of the list.
22
- */
23
- headerText?: string;
24
- /** @internal */
25
- protected dataRole: RoleType;
21
+ private listItems;
26
22
  constructor();
23
+ connectedCallback(): void;
27
24
  /**
28
25
  * Handles the keydown event on the list element.
29
26
  * If the key is 'ArrowUp' or 'ArrowDown', it focuses to the previous or next list item
@@ -7,32 +7,36 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { html, nothing } from 'lit';
11
- import { property, queryAssignedElements } from 'lit/decorators.js';
10
+ import { html } from 'lit';
11
+ import { queryAssignedElements } from 'lit/decorators.js';
12
12
  import { Component } from '../../models';
13
13
  import { KEYS } from '../../utils/keys';
14
- import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
15
14
  import { ROLE } from '../../utils/roles';
16
15
  import { TAG_NAME as LISTITEM_TAGNAME } from '../listitem/listitem.constants';
17
- import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
18
- import { HEADER_ID } from './list.constants';
19
16
  import styles from './list.styles';
20
17
  /**
21
18
  * mdc-list component is used to display a group of list items. It is used as a container to wrap other list items.
22
19
  *
20
+ * To add a header to the list, use the `mdc-listheader` component and place it in the `list-header` slot.
21
+ * `mdc-listitem` components can be placed in the default slot.
22
+ *
23
23
  * @tagname mdc-list
24
24
  *
25
- * @dependency mdc-text
25
+ * @slot default - This is a default/unnamed slot, where listitems can be placed.
26
+ * @slot list-header - This slot is used to pass a header for the list, which can be a `mdc-listheader` component.
26
27
  *
27
- * @slot default - This is a default/unnamed slot
28
+ * @csspart container - The container slot around the list items
28
29
  */
29
- class List extends DataAriaLabelMixin(Component) {
30
+ class List extends Component {
30
31
  constructor() {
31
32
  super();
32
- /** @internal */
33
- this.dataRole = ROLE.LIST;
34
33
  this.addEventListener('keydown', this.handleKeyDown);
35
34
  }
35
+ connectedCallback() {
36
+ super.connectedCallback();
37
+ // Set the role attribute for accessibility.
38
+ this.setAttribute('role', ROLE.LIST);
39
+ }
36
40
  /**
37
41
  * Handles the keydown event on the list element.
38
42
  * If the key is 'ArrowUp' or 'ArrowDown', it focuses to the previous or next list item
@@ -109,27 +113,10 @@ class List extends DataAriaLabelMixin(Component) {
109
113
  this.resetTabIndexAndSetActiveTabIndex(0);
110
114
  }
111
115
  render() {
112
- var _a;
113
- const headerText = this.headerText
114
- ? html `
115
- <mdc-text
116
- id="${HEADER_ID}"
117
- part="header-text"
118
- type="${TYPE.BODY_MIDSIZE_BOLD}"
119
- tagname="${VALID_TEXT_TAGS.SPAN}"
120
- >${this.headerText}</mdc-text
121
- >
122
- `
123
- : nothing;
124
116
  return html `
125
- <div
126
- role="${this.dataRole}"
127
- aria-labelledby="${this.headerText ? HEADER_ID : ''}"
128
- aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
129
- >
130
- ${headerText}
131
- <slot role="presentation" @click="${this.handleMouseClick}"></slot>
132
- </div>
117
+ <slot name="list-header"></slot>
118
+ <!-- make the container slot role presentation to keep it ignored in a11y tree -->
119
+ <slot part="container" @click="${this.handleMouseClick}" role="presentation"></slot>
133
120
  `;
134
121
  }
135
122
  }
@@ -138,8 +125,4 @@ __decorate([
138
125
  queryAssignedElements({ selector: `${LISTITEM_TAGNAME}:not([disabled])` }),
139
126
  __metadata("design:type", Array)
140
127
  ], List.prototype, "listItems", void 0);
141
- __decorate([
142
- property({ type: String, attribute: 'header-text', reflect: true }),
143
- __metadata("design:type", String)
144
- ], List.prototype, "headerText", void 0);
145
128
  export default List;
@@ -1,7 +1,14 @@
1
1
  import { css } from 'lit';
2
2
  const styles = css `
3
- :host::part(header-text) {
4
- padding: 0.5rem 0.75rem;
3
+ :host {
4
+ display: flex;
5
+ flex-direction: column;
6
+ }
7
+
8
+ :host::part(container) {
9
+ display: flex;
10
+ flex-direction: column;
11
+ gap: 0rem;
5
12
  }
6
13
  `;
7
14
  export default [styles];