@momentum-design/components 0.28.4 → 0.28.6

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.
@@ -282,7 +282,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
282
282
  return html `
283
283
  <mdc-button
284
284
  part='trailing-button'
285
- class='${!this.value ? 'hidden' : ''}'
285
+ class='own-focus-ring ${!this.value ? 'hidden' : ''}'
286
286
  prefix-icon='${DEFAULTS.CLEAR_BUTTON_ICON}'
287
287
  variant='${DEFAULTS.CLEAR_BUTTON_VARIANT}'
288
288
  size="${DEFAULTS.CLEAR_BUTTON_SIZE}"
@@ -82,7 +82,7 @@ const styles = [css `
82
82
 
83
83
  .prefix-text{
84
84
  color: var(--mdc-input-support-text-color);
85
- white-space: nowrap; // restirct prefix text to be in one line
85
+ white-space: nowrap; // restrict prefix text to be in one line
86
86
  }
87
87
 
88
88
  :host(:not([disabled])) .input-container:hover{
@@ -91,7 +91,7 @@ const styles = [css `
91
91
 
92
92
  :host(:not([disabled])) .input-container:active, :host(:not([disabled])) .input-container:focus-within{
93
93
  background-color: var(--mdc-input-focused-background-color);
94
- border-color: var(--mdc-input-focused-border-color);
94
+ border-color: var(--mdc-input-focused-border-color);
95
95
  }
96
96
 
97
97
  .input::placeholder{
@@ -115,5 +115,5 @@ const styles = [css `
115
115
  opacity: 0;
116
116
  pointer-events: none;
117
117
  }
118
- `, ...hostFocusRingStyles(true)];
118
+ `, ...hostFocusRingStyles(true)];
119
119
  export default styles;
@@ -132,7 +132,11 @@ class Link extends DisabledMixin(IconNameMixin(Component)) {
132
132
  }
133
133
  }
134
134
  render() {
135
- return html `<slot @slotchange=${this.updateTrailingIcon}></slot>`;
135
+ return html `
136
+ <div part='link-container' class='mdc-focus-ring'>
137
+ <slot @slotchange=${this.updateTrailingIcon}></slot>
138
+ </div>
139
+ `;
136
140
  }
137
141
  }
138
142
  Link.styles = [...Component.styles, ...styles];
@@ -15,7 +15,9 @@ const styles = [hostFitContentStyles, css `
15
15
  --mdc-link-inverted-color-hover: var(--mds-color-theme-inverted-text-accent-hover);
16
16
  --mdc-link-inverted-color-normal: var(--mds-color-theme-inverted-text-accent-normal);
17
17
  --mdc-link-text-decoration-disabled: underline;
18
+ }
18
19
 
20
+ :host::part(link-container){
19
21
  border-radius: var(--mdc-link-border-radius);
20
22
  color: var(--mdc-link-color-normal);
21
23
  }
@@ -31,11 +33,11 @@ const styles = [hostFitContentStyles, css `
31
33
  text-underline-position: from-font;
32
34
  }
33
35
 
34
- :host(:hover) {
36
+ :host(:hover)::part(link-container) {
35
37
  color: var(--mdc-link-color-hover);
36
38
  }
37
39
 
38
- :host(:active) {
40
+ :host(:active)::part(link-container) {
39
41
  color: var(--mdc-link-color-active);
40
42
  }
41
43
 
@@ -43,19 +45,19 @@ const styles = [hostFitContentStyles, css `
43
45
  display: inline-flex;
44
46
  }
45
47
 
46
- :host([inverted]) {
48
+ :host([inverted])::part(link-container) {
47
49
  color: var(--mdc-link-inverted-color-normal);
48
50
  }
49
51
 
50
- :host([inverted]:hover) {
52
+ :host([inverted]:hover)::part(link-container) {
51
53
  color: var(--mdc-link-inverted-color-hover);
52
54
  }
53
55
 
54
- :host([inverted]:active) {
56
+ :host([inverted]:active)::part(link-container) {
55
57
  color: var(--mdc-link-inverted-color-active);
56
58
  }
57
59
 
58
- :host([size="large"]) {
60
+ :host([size="large"])::part(link-container) {
59
61
  font-size: var(--mds-font-apps-body-large-regular-font-size);
60
62
  font-weight: var(--mds-font-apps-body-large-regular-font-weight);
61
63
  line-height: var(--mds-font-apps-body-large-regular-line-height);
@@ -63,7 +65,7 @@ const styles = [hostFitContentStyles, css `
63
65
  text-transform: var(--mds-font-apps-body-large-regular-text-case);
64
66
  }
65
67
 
66
- :host([size="midsize"]) {
68
+ :host([size="midsize"])::part(link-container) {
67
69
  font-size: var(--mds-font-apps-body-midsize-regular-font-size);
68
70
  font-weight: var(--mds-font-apps-body-midsize-regular-font-weight);
69
71
  line-height: var(--mds-font-apps-body-midsize-regular-line-height);
@@ -71,7 +73,7 @@ const styles = [hostFitContentStyles, css `
71
73
  text-transform: var(--mds-font-apps-body-midsize-regular-text-case);
72
74
  }
73
75
 
74
- :host([size="small"]) {
76
+ :host([size="small"])::part(link-container) {
75
77
  font-size: var(--mds-font-apps-body-small-regular-font-size);
76
78
  font-weight: var(--mds-font-apps-body-small-regular-font-weight);
77
79
  line-height: var(--mds-font-apps-body-small-regular-line-height);
@@ -79,7 +81,9 @@ const styles = [hostFitContentStyles, css `
79
81
  text-transform: var(--mds-font-apps-body-small-regular-text-case);
80
82
  }
81
83
 
82
- :host([size="large"]:hover), :host([size="large"]:active), :host([size="large"][inline]) {
84
+ :host([size="large"]:hover)::part(link-container),
85
+ :host([size="large"]:active)::part(link-container),
86
+ :host([size="large"][inline])::part(link-container) {
83
87
  font-size: var(--mds-font-apps-body-large-regular-underline-font-size);
84
88
  font-weight: var(--mds-font-apps-body-large-regular-underline-font-weight);
85
89
  line-height: var(--mds-font-apps-body-large-regular-underline-line-height);
@@ -87,7 +91,9 @@ const styles = [hostFitContentStyles, css `
87
91
  text-transform: var(--mds-font-apps-body-large-regular-underline-text-case);
88
92
  }
89
93
 
90
- :host([size="midsize"]:hover), :host([size="midsize"]:active), :host([size="midsize"][inline]) {
94
+ :host([size="midsize"]:hover)::part(link-container),
95
+ :host([size="midsize"]:active)::part(link-container),
96
+ :host([size="midsize"][inline])::part(link-container) {
91
97
  font-size: var(--mds-font-apps-body-midsize-regular-underline-font-size);
92
98
  font-weight: var(--mds-font-apps-body-midsize-regular-underline-font-weight);
93
99
  line-height: var(--mds-font-apps-body-midsize-regular-underline-line-height);
@@ -95,7 +101,9 @@ const styles = [hostFitContentStyles, css `
95
101
  text-transform: var(--mds-font-apps-body-midsize-regular-underline-text-case);
96
102
  }
97
103
 
98
- :host([size="small"]:hover), :host([size="small"]:active), :host([size="small"][inline]) {
104
+ :host([size="small"]:hover)::part(link-container),
105
+ :host([size="small"]:active)::part(link-container),
106
+ :host([size="small"][inline])::part(link-container) {
99
107
  font-size: var(--mds-font-apps-body-small-regular-underline-font-size);
100
108
  font-weight: var(--mds-font-apps-body-small-regular-underline-font-weight);
101
109
  line-height: var(--mds-font-apps-body-small-regular-underline-line-height);
@@ -103,17 +111,17 @@ const styles = [hostFitContentStyles, css `
103
111
  text-transform: var(--mds-font-apps-body-small-regular-underline-text-case);
104
112
  }
105
113
 
106
- :host([disabled]) {
114
+ :host([disabled])::part(link-container) {
107
115
  color: var(--mdc-link-color-disabled);
108
116
  pointer-events: none;
109
117
  }
110
118
 
111
- :host([inverted][disabled]) {
119
+ :host([inverted][disabled])::part(link-container) {
112
120
  color: var(--mdc-link-inverted-color-disabled);
113
121
  }
114
- `, ...hostFocusRingStyles(),
122
+ `, ...hostFocusRingStyles(true),
115
123
  css `
116
- :host(:active) {
124
+ :host(:active)::part(link-container) {
117
125
  box-shadow: none;
118
126
  }
119
127
  `];
@@ -1,5 +1,5 @@
1
1
  import { CSSResult, PropertyValues, TemplateResult } from 'lit';
2
- import { Virtualizer } from '@tanstack/virtual-core';
2
+ import { Virtualizer, VirtualItem } from '@tanstack/virtual-core';
3
3
  import { Ref } from 'lit/directives/ref.js';
4
4
  import { Component } from '../../models';
5
5
  import { SetListDataProps, VirtualizerProps } from './virtualizedlist.types';
@@ -24,7 +24,7 @@ declare class VirtualizedList extends Component {
24
24
  * handling logic related when the user scrolls to the top or bottom of a list.
25
25
  * @default undefined
26
26
  */
27
- onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
27
+ onscroll: ((this: GlobalEventHandlers, ev: Event) => void) | null;
28
28
  /**
29
29
  * Object that sets and updates the virtualizer with any relevant props.
30
30
  * There are two required object props in order to get virtualization to work properly.
@@ -39,7 +39,7 @@ declare class VirtualizedList extends Component {
39
39
  * [Tanstack Virtualizer API Docs](https://tanstack.com/virtual/latest/docs/api/virtualizer)
40
40
  *
41
41
  */
42
- virtualizerprops: VirtualizerProps;
42
+ virtualizerProps: VirtualizerProps;
43
43
  /**
44
44
  * Callback that gets envoked when updates to the virtualizer interally occur.
45
45
  * This must be implemented in such a way that this function will trigger update to parent.
@@ -57,6 +57,7 @@ declare class VirtualizedList extends Component {
57
57
  private virtualizerController;
58
58
  scrollElementRef: Ref<HTMLDivElement>;
59
59
  virtualizer: Virtualizer<Element, Element> | null;
60
+ virtualItems: Array<VirtualItem>;
60
61
  constructor();
61
62
  /**
62
63
  * This override is necessary to update the virtualizer with relevant props
@@ -64,6 +65,15 @@ declare class VirtualizedList extends Component {
64
65
  * this way ensures we don't initialize a new virtualizer upon very prop change.
65
66
  */
66
67
  update(changedProperties: PropertyValues): void;
68
+ /**
69
+ * This is needed in order to ensure the initial render happens
70
+ */
71
+ firstUpdated(changedProperties: PropertyValues): void;
72
+ /**
73
+ * @internal
74
+ * Update virtuailzer with the union of the two virtualizer options (current, passed in).
75
+ */
76
+ private setVirtualizerOptions;
67
77
  connectedCallback(): void;
68
78
  /**
69
79
  * @internal
@@ -45,8 +45,9 @@ class VirtualizedList extends Component {
45
45
  * [Tanstack Virtualizer API Docs](https://tanstack.com/virtual/latest/docs/api/virtualizer)
46
46
  *
47
47
  */
48
- this.virtualizerprops = DEFAULTS.VIRTUALIZER_PROPS;
48
+ this.virtualizerProps = DEFAULTS.VIRTUALIZER_PROPS;
49
49
  this.scrollElementRef = createRef();
50
+ this.virtualItems = [];
50
51
  this.virtualizerController = null;
51
52
  this.virtualizer = null;
52
53
  this.setlistdata = null;
@@ -58,22 +59,34 @@ class VirtualizedList extends Component {
58
59
  * this way ensures we don't initialize a new virtualizer upon very prop change.
59
60
  */
60
61
  update(changedProperties) {
61
- var _a;
62
62
  super.update(changedProperties);
63
- // if the virtuailzer props change at all,
64
- // update virtuailzer with the union of the two virtualizer options (current, passed in).
65
- if (changedProperties.get('virtualizerprops')) {
66
- (_a = this.virtualizer) === null || _a === void 0 ? void 0 : _a.setOptions({ ...this.virtualizer.options, ...this.virtualizerprops });
67
- this.requestUpdate();
63
+ if (changedProperties.get('virtualizerProps')) {
64
+ this.setVirtualizerOptions();
68
65
  }
69
66
  }
67
+ /**
68
+ * This is needed in order to ensure the initial render happens
69
+ */
70
+ firstUpdated(changedProperties) {
71
+ super.firstUpdated(changedProperties);
72
+ this.setVirtualizerOptions();
73
+ }
74
+ /**
75
+ * @internal
76
+ * Update virtuailzer with the union of the two virtualizer options (current, passed in).
77
+ */
78
+ setVirtualizerOptions() {
79
+ var _a;
80
+ (_a = this.virtualizer) === null || _a === void 0 ? void 0 : _a.setOptions({ ...this.virtualizer.options, ...this.virtualizerProps });
81
+ this.requestUpdate();
82
+ }
70
83
  connectedCallback() {
71
84
  var _a;
72
85
  this.virtualizerController = new VirtualizerController(this, {
73
- count: this.virtualizerprops.count,
74
- estimateSize: (_a = this.virtualizerprops) === null || _a === void 0 ? void 0 : _a.estimateSize,
86
+ count: this.virtualizerProps.count,
87
+ estimateSize: (_a = this.virtualizerProps) === null || _a === void 0 ? void 0 : _a.estimateSize,
75
88
  getScrollElement: () => this.scrollElementRef.value || null,
76
- ...this.virtualizerprops,
89
+ ...this.virtualizerProps,
77
90
  });
78
91
  super.connectedCallback();
79
92
  }
@@ -89,19 +102,24 @@ class VirtualizedList extends Component {
89
102
  getVirtualizedListWrapper(virtualizerController) {
90
103
  var _a, _b;
91
104
  this.virtualizer = virtualizerController.getVirtualizer();
92
- const { getVirtualItems, measureElement, getTotalSize } = this.virtualizer;
93
- const virtualItems = getVirtualItems();
94
- // this style is required to be rendered by the client side list in order to handle scrolling properly
95
- const listStyle = {
96
- position: 'absolute',
97
- top: 0,
98
- left: 0,
99
- width: '100%',
100
- transform: `translateY(${(_b = (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0}px)`,
101
- };
102
- // pass back data to client for rendering
103
- if (this.setlistdata) {
104
- this.setlistdata({ virtualItems, measureElement, listStyle });
105
+ const { getTotalSize, getVirtualItems, measureElement } = this.virtualizer;
106
+ const newVirtualItems = getVirtualItems();
107
+ // Only update client if there's a difference in virtual items
108
+ if (newVirtualItems !== this.virtualItems) {
109
+ this.virtualItems = newVirtualItems;
110
+ const virtualItems = getVirtualItems();
111
+ // this style is required to be rendered by the client side list in order to handle scrolling properly
112
+ const listStyle = {
113
+ position: 'absolute',
114
+ top: 0,
115
+ left: 0,
116
+ width: '100%',
117
+ transform: `translateY(${(_b = (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0}px)`,
118
+ };
119
+ // pass back data to client for rendering
120
+ if (this.setlistdata) {
121
+ this.setlistdata({ virtualItems, measureElement, listStyle });
122
+ }
105
123
  }
106
124
  return html `<div
107
125
  part="container"
@@ -129,7 +147,7 @@ __decorate([
129
147
  __decorate([
130
148
  property({ type: Object, attribute: 'virtualizerprops' }),
131
149
  __metadata("design:type", Object)
132
- ], VirtualizedList.prototype, "virtualizerprops", void 0);
150
+ ], VirtualizedList.prototype, "virtualizerProps", void 0);
133
151
  __decorate([
134
152
  property({ type: Function, attribute: 'setlistdata' }),
135
153
  __metadata("design:type", Object)
@@ -2,8 +2,8 @@ import { CSSResult, PropertyValues, TemplateResult } from 'lit';
2
2
  import { VirtualizerProps } from './virtualizedlist.types';
3
3
  import { Component } from '../../models';
4
4
  declare class VirtualizedWrapper extends Component {
5
- onscroll: ((this: GlobalEventHandlers, ev: Event) => any) | null;
6
- virtualizerprops: VirtualizerProps;
5
+ onscroll: ((this: GlobalEventHandlers, ev: Event) => void) | null;
6
+ virtualizerProps: VirtualizerProps;
7
7
  list: TemplateResult<1>;
8
8
  listItemTexts: string[];
9
9
  constructor();
@@ -15,9 +15,9 @@ import { Component } from '../../models';
15
15
  class VirtualizedWrapper extends Component {
16
16
  constructor() {
17
17
  super();
18
- this.virtualizerprops = { count: 100, estimateSize: () => 100, overscan: 60 };
18
+ this.virtualizerProps = { count: 100, estimateSize: () => 100, overscan: 60 };
19
19
  this.list = html ``;
20
- this.listItemTexts = new Array(this.virtualizerprops.count)
20
+ this.listItemTexts = new Array(this.virtualizerProps.count)
21
21
  .fill(true)
22
22
  .map((_, index) => `list item number ${index}`);
23
23
  this.onscroll = null;
@@ -25,20 +25,20 @@ class VirtualizedWrapper extends Component {
25
25
  }
26
26
  update(changedProperties) {
27
27
  super.update(changedProperties);
28
- if (changedProperties.get('virtualizerprops')) {
28
+ if (changedProperties.get('virtualizerProps')) {
29
29
  this.updateListItemTextArray();
30
30
  }
31
31
  }
32
32
  connectedCallback() {
33
33
  var _a;
34
34
  super.connectedCallback();
35
- if ((_a = this.virtualizerprops) === null || _a === void 0 ? void 0 : _a.count) {
35
+ if ((_a = this.virtualizerProps) === null || _a === void 0 ? void 0 : _a.count) {
36
36
  this.updateListItemTextArray();
37
37
  }
38
38
  }
39
39
  updateListItemTextArray() {
40
40
  var _a;
41
- this.listItemTexts = new Array((_a = this.virtualizerprops) === null || _a === void 0 ? void 0 : _a.count)
41
+ this.listItemTexts = new Array((_a = this.virtualizerProps) === null || _a === void 0 ? void 0 : _a.count)
42
42
  .fill(true)
43
43
  .map((_, index) => `list item number ${index}`);
44
44
  }
@@ -53,7 +53,7 @@ class VirtualizedWrapper extends Component {
53
53
  <div style="height: 500px; width: 500px;">
54
54
  <mdc-virtualizedlist
55
55
  .onscroll=${this.onscroll}
56
- .virtualizerprops=${this.virtualizerprops}
56
+ .virtualizerProps=${this.virtualizerProps}
57
57
  .setlistdata=${this.setListData}
58
58
  >${this.list}</mdc-virtualizedlist></div>
59
59
  `;
@@ -67,7 +67,7 @@ __decorate([
67
67
  __decorate([
68
68
  property({ type: Object, attribute: 'virtualizerprops' }),
69
69
  __metadata("design:type", Object)
70
- ], VirtualizedWrapper.prototype, "virtualizerprops", void 0);
70
+ ], VirtualizedWrapper.prototype, "virtualizerProps", void 0);
71
71
  __decorate([
72
72
  state(),
73
73
  __metadata("design:type", Object)