@momentum-design/components 0.122.5 → 0.122.7

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.
Files changed (36) hide show
  1. package/dist/browser/index.js +428 -409
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/list/list.component.d.ts +12 -17
  4. package/dist/components/list/list.component.js +29 -39
  5. package/dist/components/listitem/listitem.component.d.ts +10 -0
  6. package/dist/components/listitem/listitem.component.js +7 -0
  7. package/dist/components/popover/popover.component.d.ts +7 -0
  8. package/dist/components/popover/popover.component.js +13 -0
  9. package/dist/components/popover/popover.constants.d.ts +1 -0
  10. package/dist/components/popover/popover.constants.js +1 -0
  11. package/dist/components/virtualizedlist/virtualizedlist.component.d.ts +244 -41
  12. package/dist/components/virtualizedlist/virtualizedlist.component.js +597 -78
  13. package/dist/components/virtualizedlist/virtualizedlist.constants.d.ts +7 -4
  14. package/dist/components/virtualizedlist/virtualizedlist.constants.js +7 -4
  15. package/dist/components/virtualizedlist/virtualizedlist.styles.js +17 -3
  16. package/dist/components/virtualizedlist/virtualizedlist.types.d.ts +12 -10
  17. package/dist/components/virtualizedlist/virtualizedlist.utils.d.ts +11 -0
  18. package/dist/components/virtualizedlist/virtualizedlist.utils.js +23 -0
  19. package/dist/custom-elements.json +2778 -1975
  20. package/dist/react/index.d.ts +7 -7
  21. package/dist/react/index.js +7 -7
  22. package/dist/react/virtualizedlist/index.d.ts +44 -6
  23. package/dist/react/virtualizedlist/index.js +44 -6
  24. package/dist/utils/mixins/AutoFocusOnMountMixin.js +2 -2
  25. package/dist/utils/mixins/ListNavigationMixin.d.ts +5 -2
  26. package/dist/utils/mixins/ListNavigationMixin.js +77 -68
  27. package/dist/utils/mixins/lifecycle/LifeCycleMixin.js +4 -0
  28. package/dist/utils/mixins/lifecycle/lifecycle.contants.d.ts +1 -0
  29. package/dist/utils/mixins/lifecycle/lifecycle.contants.js +1 -0
  30. package/dist/utils/range.d.ts +40 -0
  31. package/dist/utils/range.js +66 -0
  32. package/dist/utils/virtualIndexArray.d.ts +27 -0
  33. package/dist/utils/virtualIndexArray.js +42 -0
  34. package/package.json +2 -2
  35. package/dist/components/virtualizedlist/virtualizedlist.helper.test.d.ts +0 -22
  36. package/dist/components/virtualizedlist/virtualizedlist.helper.test.js +0 -82
@@ -1,9 +1,12 @@
1
- declare const TAG_NAME: "mdc-virtualizedlist";
2
- declare const VIRTUALIZED_WRAPPER_TAG_NAME: "mdc-virtualizedwrapper";
3
- declare const DEFAULTS: {
1
+ export declare const TAG_NAME: "mdc-virtualizedlist";
2
+ export declare const VIRTUALIZED_WRAPPER_TAG_NAME: "mdc-virtualizedwrapper";
3
+ export declare const DEFAULTS: {
4
4
  readonly VIRTUALIZER_PROPS: {
5
5
  readonly count: 0;
6
6
  readonly estimateSize: () => number;
7
+ readonly getItemKey: (index: number) => number;
7
8
  };
9
+ readonly LOOP: "false";
10
+ readonly SCROLL_ANCHORING: false;
11
+ readonly IS_AT_BOTTOM_THRESHOLD: 16;
8
12
  };
9
- export { TAG_NAME, DEFAULTS, VIRTUALIZED_WRAPPER_TAG_NAME };
@@ -1,10 +1,13 @@
1
1
  import utils from '../../utils/tag-name';
2
- const TAG_NAME = utils.constructTagName('virtualizedlist');
3
- const VIRTUALIZED_WRAPPER_TAG_NAME = utils.constructTagName('virtualizedwrapper');
4
- const DEFAULTS = {
2
+ export const TAG_NAME = utils.constructTagName('virtualizedlist');
3
+ export const VIRTUALIZED_WRAPPER_TAG_NAME = utils.constructTagName('virtualizedwrapper');
4
+ export const DEFAULTS = {
5
5
  VIRTUALIZER_PROPS: {
6
6
  count: 0,
7
7
  estimateSize: () => 0,
8
+ getItemKey: (index) => index,
8
9
  },
10
+ LOOP: 'false',
11
+ SCROLL_ANCHORING: false,
12
+ IS_AT_BOTTOM_THRESHOLD: 16,
9
13
  };
10
- export { TAG_NAME, DEFAULTS, VIRTUALIZED_WRAPPER_TAG_NAME };
@@ -1,14 +1,28 @@
1
1
  import { css } from 'lit';
2
2
  const styles = [
3
3
  css `
4
+ :host {
5
+ height: 100%;
6
+ }
7
+
4
8
  :host::part(scroll) {
5
9
  height: 100%;
6
10
  width: 100%;
7
11
  overflow-y: auto;
12
+ scroll-padding: 0.25rem 0;
13
+ contain: strict;
14
+ overflow-anchor: none;
15
+ scrollbar-gutter: stable;
8
16
  }
9
- :host::part(container) {
10
- position: relative;
11
- width: 100%;
17
+
18
+ :host::part(wrapper) {
19
+ padding: 0 0.25rem;
20
+ }
21
+
22
+ ::slotted([data-virtualized-hidden]) {
23
+ position: absolute !important;
24
+ top: var(--mdc-virtualizedlist-hidden-top) !important;
25
+ left: 0 !important;
12
26
  }
13
27
  `,
14
28
  ];
@@ -1,15 +1,17 @@
1
- import { VirtualItem, VirtualizerOptions } from '@tanstack/virtual-core';
2
- import { StyleInfo } from 'lit/directives/style-map.js';
1
+ import type { VirtualItem as TanstackVirtualItem, Virtualizer as TanstackVirtualizer, VirtualizerOptions as TanstackVirtualizerOptions } from '@tanstack/virtual-core';
3
2
  import type { TypedCustomEvent } from '../../utils/types';
4
3
  import type VirtualizedList from './virtualizedlist.component';
5
- interface SetListDataProps {
4
+ export type VirtualItem = TanstackVirtualItem;
5
+ export type VirtualizedListScrollEvent = TypedCustomEvent<VirtualizedList>;
6
+ export type VirtualizedListVirtualItemsChangeEvent = TypedCustomEvent<VirtualizedList, {
6
7
  virtualItems: Array<VirtualItem>;
7
- measureElement: (node: Element | null | undefined) => void;
8
- listStyle: Readonly<StyleInfo>;
9
- }
10
- type VirtualizedListScrollEvent = TypedCustomEvent<VirtualizedList>;
11
- interface Events {
8
+ }>;
9
+ export type VirtualData = VirtualizedListVirtualItemsChangeEvent['detail'];
10
+ export interface Events {
12
11
  onScrollEvent: VirtualizedListScrollEvent;
12
+ onVirtualItemsChangeEvent: VirtualizedListVirtualItemsChangeEvent;
13
13
  }
14
- type VirtualizerProps = Partial<VirtualizerOptions<Element, Element>>;
15
- export type { Events, VirtualizedListScrollEvent, VirtualizerProps, SetListDataProps };
14
+ export type Virtualizer = TanstackVirtualizer<Element, Element>;
15
+ export type VirtualizerOptions = TanstackVirtualizerOptions<Element, Element>;
16
+ export type VirtualizerProps = Omit<Partial<VirtualizerOptions>, 'getScrollElement'> & Required<Pick<VirtualizerOptions, 'count' | 'estimateSize' | 'getItemKey'>>;
17
+ export type AtBottomValue = 'no' | 'yes' | 're-evaluate';
@@ -0,0 +1,11 @@
1
+ import { measureElement } from '@tanstack/virtual-core';
2
+ /**
3
+ * A custom measureElement function that uses cached measurements when scrolling up to prevent stuttering.
4
+ *
5
+ * Solve [Scrolling up with dynamic heights stutters and jumps](https://github.com/TanStack/virtual/issues/659#issuecomment-2915244925)
6
+ *
7
+ * @param element - The DOM element to measure.
8
+ * @param entry - The ResizeObserverEntry for the element.
9
+ * @param instance - The virtualizer instance.
10
+ */
11
+ export declare const defaultMeasureElement: typeof measureElement;
@@ -0,0 +1,23 @@
1
+ import { measureElement } from '@tanstack/virtual-core';
2
+ /**
3
+ * A custom measureElement function that uses cached measurements when scrolling up to prevent stuttering.
4
+ *
5
+ * Solve [Scrolling up with dynamic heights stutters and jumps](https://github.com/TanStack/virtual/issues/659#issuecomment-2915244925)
6
+ *
7
+ * @param element - The DOM element to measure.
8
+ * @param entry - The ResizeObserverEntry for the element.
9
+ * @param instance - The virtualizer instance.
10
+ */
11
+ export const defaultMeasureElement = (element, entry, instance) => {
12
+ var _a;
13
+ const direction = instance.scrollDirection;
14
+ if (!(direction === 'forward' || direction === null)) {
15
+ // When scrolling up, use cached measurement to prevent stuttering
16
+ const indexKey = Number(element.getAttribute('data-index'));
17
+ const cachedMeasurement = (_a = instance.measurementsCache[indexKey]) === null || _a === void 0 ? void 0 : _a.size;
18
+ if (cachedMeasurement) {
19
+ return cachedMeasurement;
20
+ }
21
+ }
22
+ return measureElement(element, entry, instance);
23
+ };