@momentum-design/components 0.105.3 → 0.106.0

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.
@@ -13,18 +13,11 @@ import { SetListDataProps, VirtualizerProps } from './virtualizedlist.types';
13
13
  *
14
14
  * @tagname mdc-virtualizedlist
15
15
  *
16
- * @event onscroll - (React: onScroll) Event that gets called when user scrolls inside of list.
16
+ * @event scroll - (React: onScroll) Event that gets called when user scrolls inside of list.
17
17
  *
18
18
  * @slot - Client side List with nested list items.
19
19
  */
20
20
  declare class VirtualizedList extends Component {
21
- /**
22
- * Callback that gets called when user scrolls inside of list. This gives access to the scroll container element
23
- * as well via the event. Particularly useful for
24
- * handling logic related when the user scrolls to the top or bottom of a list.
25
- * @default undefined
26
- */
27
- onscroll: ((this: GlobalEventHandlers, ev: Event) => void) | null;
28
21
  /**
29
22
  * Object that sets and updates the virtualizer with any relevant props.
30
23
  * There are two required object props in order to get virtualization to work properly.
@@ -85,6 +78,10 @@ declare class VirtualizedList extends Component {
85
78
  * @returns The template result containing the list wrapper.
86
79
  */
87
80
  private getVirtualizedListWrapper;
81
+ /**
82
+ * Refires the scroll event from the internal scroll container to the host element
83
+ */
84
+ private handleScroll;
88
85
  render(): TemplateResult<1>;
89
86
  static styles: Array<CSSResult>;
90
87
  }
@@ -24,7 +24,7 @@ import { DEFAULTS } from './virtualizedlist.constants';
24
24
  *
25
25
  * @tagname mdc-virtualizedlist
26
26
  *
27
- * @event onscroll - (React: onScroll) Event that gets called when user scrolls inside of list.
27
+ * @event scroll - (React: onScroll) Event that gets called when user scrolls inside of list.
28
28
  *
29
29
  * @slot - Client side List with nested list items.
30
30
  */
@@ -125,17 +125,20 @@ class VirtualizedList extends Component {
125
125
  <slot></slot>
126
126
  </div>`;
127
127
  }
128
+ /**
129
+ * Refires the scroll event from the internal scroll container to the host element
130
+ */
131
+ handleScroll(event) {
132
+ const EventConstructor = event.constructor;
133
+ this.dispatchEvent(new EventConstructor(event.type, event));
134
+ }
128
135
  render() {
129
- return html `<div ${ref(this.scrollElementRef)} part="scroll" @scroll=${this.onscroll && this.onscroll}>
136
+ return html `<div ${ref(this.scrollElementRef)} part="scroll" @scroll=${this.handleScroll}>
130
137
  ${this.virtualizerController ? this.getVirtualizedListWrapper(this.virtualizerController) : html ``}
131
- </div> `;
138
+ </div>`;
132
139
  }
133
140
  }
134
141
  VirtualizedList.styles = [...Component.styles, ...styles];
135
- __decorate([
136
- property({ type: Function, attribute: 'onscroll' }),
137
- __metadata("design:type", Object)
138
- ], VirtualizedList.prototype, "onscroll", void 0);
139
142
  __decorate([
140
143
  property({ type: Object, attribute: 'virtualizerprops' }),
141
144
  __metadata("design:type", Object)
@@ -53,7 +53,7 @@ class VirtualizedWrapper extends Component {
53
53
  return html `
54
54
  <div style="height: 500px; width: 500px;">
55
55
  <mdc-virtualizedlist
56
- .onscroll=${this.onscroll}
56
+ @scroll=${this.onscroll}
57
57
  .virtualizerProps=${this.virtualizerProps}
58
58
  .setlistdata=${this.setListData}
59
59
  >${this.list}</mdc-virtualizedlist
@@ -7,8 +7,9 @@ interface SetListDataProps {
7
7
  measureElement: (node: Element | null | undefined) => void;
8
8
  listStyle: Readonly<StyleInfo>;
9
9
  }
10
+ type VirtualizedListScrollEvent = TypedCustomEvent<VirtualizedList>;
10
11
  interface Events {
11
- onScrollEvent: TypedCustomEvent<VirtualizedList>;
12
+ onScrollEvent: VirtualizedListScrollEvent;
12
13
  }
13
14
  type VirtualizerProps = Partial<VirtualizerOptions<Element, Element>>;
14
- export type { Events, VirtualizerProps, SetListDataProps };
15
+ export type { Events, VirtualizedListScrollEvent, VirtualizerProps, SetListDataProps };