@momentum-design/components 0.84.3 → 0.84.5

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 (185) hide show
  1. package/README.md +8 -3
  2. package/dist/browser/index.js +2241 -2299
  3. package/dist/browser/index.js.map +4 -4
  4. package/dist/components/alertchip/alertchip.component.d.ts +1 -1
  5. package/dist/components/alertchip/alertchip.component.js +2 -2
  6. package/dist/components/alertchip/alertchip.styles.js +22 -23
  7. package/dist/components/alertchip/alertchip.types.d.ts +1 -1
  8. package/dist/components/animation/animation.component.js +1 -1
  9. package/dist/components/animation/animation.styles.js +8 -5
  10. package/dist/components/appheader/appheader.component.js +12 -13
  11. package/dist/components/appheader/appheader.styles.js +0 -1
  12. package/dist/components/avatar/avatar.component.js +3 -16
  13. package/dist/components/avatar/avatar.constants.d.ts +1 -1
  14. package/dist/components/avatar/avatar.constants.js +1 -1
  15. package/dist/components/avatar/avatar.styles.js +129 -122
  16. package/dist/components/avatar/avatar.types.d.ts +1 -1
  17. package/dist/components/avatar/avatar.utils.d.ts +1 -1
  18. package/dist/components/avatar/avatar.utils.js +1 -1
  19. package/dist/components/avatarbutton/avatarbutton.component.d.ts +2 -2
  20. package/dist/components/avatarbutton/avatarbutton.component.js +2 -2
  21. package/dist/components/avatarbutton/avatarbutton.styles.js +34 -30
  22. package/dist/components/badge/badge.styles.js +9 -7
  23. package/dist/components/brandvisual/brandvisual.component.js +4 -4
  24. package/dist/components/bullet/bullet.component.d.ts +1 -1
  25. package/dist/components/bullet/bullet.component.js +2 -2
  26. package/dist/components/bullet/bullet.styles.js +3 -3
  27. package/dist/components/button/button.component.js +10 -4
  28. package/dist/components/button/button.utils.js +1 -1
  29. package/dist/components/buttongroup/buttongroup.component.js +1 -1
  30. package/dist/components/buttongroup/buttongroup.styles.js +68 -68
  31. package/dist/components/buttonlink/buttonlink.component.d.ts +5 -5
  32. package/dist/components/buttonlink/buttonlink.component.js +9 -9
  33. package/dist/components/buttonsimple/buttonsimple.component.js +2 -2
  34. package/dist/components/buttonsimple/buttonsimple.constants.d.ts +1 -1
  35. package/dist/components/buttonsimple/buttonsimple.constants.js +1 -1
  36. package/dist/components/buttonsimple/buttonsimple.styles.js +62 -57
  37. package/dist/components/card/card.component.d.ts +6 -6
  38. package/dist/components/card/card.component.js +15 -16
  39. package/dist/components/card/card.styles.js +24 -22
  40. package/dist/components/cardbutton/cardbutton.component.js +9 -12
  41. package/dist/components/cardbutton/cardbutton.styles.js +1 -1
  42. package/dist/components/cardcheckbox/cardcheckbox.component.d.ts +6 -6
  43. package/dist/components/cardcheckbox/cardcheckbox.component.js +30 -29
  44. package/dist/components/cardcheckbox/cardcheckbox.styles.js +10 -10
  45. package/dist/components/cardradio/cardradio.component.d.ts +12 -12
  46. package/dist/components/cardradio/cardradio.component.js +27 -30
  47. package/dist/components/cardradio/cardradio.styles.js +8 -8
  48. package/dist/components/checkbox/checkbox.component.js +7 -9
  49. package/dist/components/checkbox/checkbox.styles.js +62 -60
  50. package/dist/components/chip/chip.component.d.ts +1 -1
  51. package/dist/components/chip/chip.component.js +6 -11
  52. package/dist/components/chip/chip.styles.js +4 -2
  53. package/dist/components/dialog/dialog.component.d.ts +7 -2
  54. package/dist/components/dialog/dialog.component.js +43 -33
  55. package/dist/components/dialog/dialog.constants.d.ts +1 -0
  56. package/dist/components/dialog/dialog.constants.js +1 -0
  57. package/dist/components/dialog/dialog.styles.js +10 -12
  58. package/dist/components/divider/divider.component.js +6 -8
  59. package/dist/components/divider/divider.constants.d.ts +1 -1
  60. package/dist/components/divider/divider.constants.js +1 -1
  61. package/dist/components/divider/divider.styles.js +5 -20
  62. package/dist/components/filterchip/filterchip.styles.js +4 -2
  63. package/dist/components/formfieldgroup/formfieldgroup.component.js +1 -4
  64. package/dist/components/formfieldgroup/formfieldgroup.styles.js +1 -2
  65. package/dist/components/formfieldwrapper/formfieldwrapper.component.js +19 -17
  66. package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +2 -1
  67. package/dist/components/formfieldwrapper/formfieldwrapper.subcomponent.js +4 -4
  68. package/dist/components/icon/icon.component.js +7 -7
  69. package/dist/components/icon/icon.utils.d.ts +1 -1
  70. package/dist/components/icon/icon.utils.js +7 -7
  71. package/dist/components/iconprovider/iconprovider.component.js +7 -7
  72. package/dist/components/input/input.component.d.ts +5 -5
  73. package/dist/components/input/input.component.js +64 -62
  74. package/dist/components/input/input.styles.js +128 -117
  75. package/dist/components/inputchip/inputchip.component.js +14 -19
  76. package/dist/components/inputchip/inputchip.styles.js +5 -3
  77. package/dist/components/link/link.component.d.ts +1 -1
  78. package/dist/components/link/link.component.js +4 -8
  79. package/dist/components/link/link.constants.d.ts +1 -1
  80. package/dist/components/link/link.constants.js +1 -1
  81. package/dist/components/link/link.styles.js +12 -12
  82. package/dist/components/linksimple/linksimple.component.js +2 -4
  83. package/dist/components/linksimple/linksimple.styles.js +59 -57
  84. package/dist/components/list/list.component.js +12 -9
  85. package/dist/components/listitem/listitem.component.js +15 -11
  86. package/dist/components/listitem/listitem.styles.js +11 -6
  87. package/dist/components/marker/marker.component.js +1 -1
  88. package/dist/components/marker/marker.styles.js +2 -2
  89. package/dist/components/menubar/menubar.component.d.ts +19 -19
  90. package/dist/components/menubar/menubar.component.js +19 -19
  91. package/dist/components/menuitem/menuitem.component.js +15 -15
  92. package/dist/components/menuitem/menuitem.styles.js +3 -2
  93. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.d.ts +1 -1
  94. package/dist/components/menuitemcheckbox/menuitemcheckbox.component.js +4 -11
  95. package/dist/components/menuitemradio/menuitemradio.component.js +1 -1
  96. package/dist/components/menupopover/menupopover.component.js +11 -11
  97. package/dist/components/menupopover/menupopover.utils.d.ts +1 -1
  98. package/dist/components/menupopover/menupopover.utils.js +3 -8
  99. package/dist/components/navitem/navitem.component.js +11 -19
  100. package/dist/components/navitem/navitem.styles.js +147 -143
  101. package/dist/components/navitemlist/navitemlist.component.js +2 -2
  102. package/dist/components/optgroup/optgroup.component.js +12 -9
  103. package/dist/components/option/option.component.js +11 -11
  104. package/dist/components/option/option.styles.js +1 -1
  105. package/dist/components/popover/popover.component.js +4 -4
  106. package/dist/components/popover/popover.stack.js +1 -1
  107. package/dist/components/popover/popover.styles.js +0 -1
  108. package/dist/components/popover/popover.utils.js +3 -4
  109. package/dist/components/presence/presence.component.d.ts +4 -4
  110. package/dist/components/presence/presence.component.js +4 -4
  111. package/dist/components/progressbar/progressbar.component.js +3 -4
  112. package/dist/components/progressbar/progressbar.styles.js +77 -71
  113. package/dist/components/progressspinner/progressspiner.utils.js +4 -4
  114. package/dist/components/progressspinner/progressspinner.component.js +38 -37
  115. package/dist/components/progressspinner/progressspinner.styles.js +1 -1
  116. package/dist/components/radio/radio.component.d.ts +41 -41
  117. package/dist/components/radio/radio.component.js +84 -83
  118. package/dist/components/radio/radio.styles.js +77 -75
  119. package/dist/components/radiogroup/radiogroup.component.js +1 -1
  120. package/dist/components/screenreaderannouncer/screenreaderannouncer.component.js +2 -2
  121. package/dist/components/screenreaderannouncer/screenreaderannouncer.styles.js +8 -6
  122. package/dist/components/searchfield/searchfield.component.js +23 -17
  123. package/dist/components/searchfield/searchfield.styles.js +11 -13
  124. package/dist/components/select/select.component.js +20 -23
  125. package/dist/components/select/select.styles.js +9 -9
  126. package/dist/components/sidenavigation/sidenavigation.component.d.ts +6 -6
  127. package/dist/components/sidenavigation/sidenavigation.component.js +39 -29
  128. package/dist/components/sidenavigation/sidenavigation.context.js +5 -5
  129. package/dist/components/sidenavigation/sidenavigation.styles.js +53 -53
  130. package/dist/components/skeleton/skeleton.component.js +1 -4
  131. package/dist/components/skeleton/skeleton.constants.d.ts +1 -1
  132. package/dist/components/skeleton/skeleton.constants.js +1 -1
  133. package/dist/components/skeleton/skeleton.styles.js +4 -4
  134. package/dist/components/spinner/spinner.component.d.ts +7 -7
  135. package/dist/components/spinner/spinner.component.js +9 -9
  136. package/dist/components/spinner/spinner.styles.js +58 -53
  137. package/dist/components/staticcheckbox/staticcheckbox.component.js +10 -8
  138. package/dist/components/staticcheckbox/staticcheckbox.styles.js +52 -51
  139. package/dist/components/staticradio/staticradio.component.d.ts +8 -8
  140. package/dist/components/staticradio/staticradio.component.js +10 -11
  141. package/dist/components/staticradio/staticradio.styles.js +77 -75
  142. package/dist/components/statictoggle/statictoggle.component.d.ts +3 -3
  143. package/dist/components/statictoggle/statictoggle.component.js +3 -3
  144. package/dist/components/statictoggle/statictoggle.styles.js +71 -68
  145. package/dist/components/tab/tab.component.d.ts +1 -1
  146. package/dist/components/tab/tab.component.js +2 -2
  147. package/dist/components/tab/tab.styles.js +247 -245
  148. package/dist/components/tablist/tablist.component.js +11 -15
  149. package/dist/components/tablist/tablist.styles.js +27 -25
  150. package/dist/components/tablist/tablist.types.d.ts +1 -1
  151. package/dist/components/tablist/tablist.utils.js +4 -4
  152. package/dist/components/text/fonts.styles.js +49 -49
  153. package/dist/components/text/text.component.js +21 -11
  154. package/dist/components/text/text.types.d.ts +1 -1
  155. package/dist/components/textarea/textarea.component.d.ts +31 -31
  156. package/dist/components/textarea/textarea.component.js +54 -61
  157. package/dist/components/textarea/textarea.styles.js +123 -122
  158. package/dist/components/themeprovider/themeprovider.component.js +1 -1
  159. package/dist/components/themeprovider/themeprovider.styles.js +4 -4
  160. package/dist/components/toggle/toggle.component.d.ts +35 -35
  161. package/dist/components/toggle/toggle.component.js +62 -63
  162. package/dist/components/toggle/toggle.styles.js +77 -69
  163. package/dist/components/toggletip/toggletip.component.d.ts +7 -7
  164. package/dist/components/toggletip/toggletip.component.js +3 -2
  165. package/dist/components/tooltip/tooltip.component.js +1 -1
  166. package/dist/components/tooltip/tooltip.styles.js +0 -1
  167. package/dist/components/virtualizedlist/virtualizedlist.component.js +6 -14
  168. package/dist/components/virtualizedlist/virtualizedlist.helper.test.d.ts +1 -1
  169. package/dist/components/virtualizedlist/virtualizedlist.helper.test.js +14 -11
  170. package/dist/components/virtualizedlist/virtualizedlist.styles.js +4 -4
  171. package/dist/custom-elements.json +239 -228
  172. package/dist/index.js +1 -0
  173. package/dist/models/component/index.d.ts +1 -1
  174. package/dist/models/index.d.ts +2 -2
  175. package/dist/models/index.js +1 -1
  176. package/dist/react/index.d.ts +3 -3
  177. package/dist/react/index.js +3 -3
  178. package/dist/utils/mixins/ButtonComponentMixin.js +10 -10
  179. package/dist/utils/mixins/CardAndDialogFooterMixin.js +21 -22
  180. package/dist/utils/mixins/FocusTrapMixin.js +15 -12
  181. package/dist/utils/mixins/IconNameMixin.d.ts +1 -1
  182. package/dist/utils/mixins/MenuMixin.js +23 -23
  183. package/dist/utils/mixins/PreventScrollMixin.d.ts +1 -1
  184. package/dist/utils/styles/index.js +12 -12
  185. package/package.json +1 -1
@@ -6,10 +6,10 @@ import FormfieldWrapper from './formfieldwrapper.component';
6
6
  class SubComponentFormFieldWrapper extends FormfieldWrapper {
7
7
  render() {
8
8
  return html `
9
- ${this.renderLabel()}
10
- <slot></slot>
11
- ${this.renderHelperText()}
12
- `;
9
+ ${this.renderLabel()}
10
+ <slot></slot>
11
+ ${this.renderHelperText()}
12
+ `;
13
13
  }
14
14
  }
15
15
  SubComponentFormFieldWrapper.register('mdc-subcomponent-formfieldwrapper');
@@ -9,10 +9,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { html } from 'lit';
11
11
  import { property, state } from 'lit/decorators.js';
12
- import styles from './icon.styles';
13
12
  import { Component } from '../../models';
14
13
  import providerUtils from '../../utils/provider';
15
14
  import IconProvider from '../iconprovider/iconprovider.component';
15
+ import styles from './icon.styles';
16
16
  import { svgFetch } from './icon.utils';
17
17
  import { DEFAULTS } from './icon.constants';
18
18
  /**
@@ -124,22 +124,22 @@ class Icon extends Component {
124
124
  cacheStrategy,
125
125
  renewSignal,
126
126
  })
127
- .then((iconData) => {
127
+ .then(iconData => {
128
128
  // parse the fetched icon string to an html element and set the attributes
129
129
  const iconElement = this.prepareIconElement(iconData);
130
130
  this.handleIconLoadedSuccess(iconElement);
131
131
  })
132
- .catch((error) => {
132
+ .catch(error => {
133
133
  this.handleIconLoadedFailure(error);
134
134
  });
135
135
  }
136
136
  if (iconSet === 'momentum-icons' && this.name) {
137
137
  // dynamic import of the lit template from the momentum icons package
138
138
  return import(`@momentum-design/icons/dist/ts/${this.name}.ts`)
139
- .then((module) => {
139
+ .then(module => {
140
140
  this.handleIconLoadedSuccess(module.default());
141
141
  })
142
- .catch((error) => {
142
+ .catch(error => {
143
143
  this.handleIconLoadedFailure(error);
144
144
  });
145
145
  }
@@ -196,14 +196,14 @@ class Icon extends Component {
196
196
  super.updated(changedProperties);
197
197
  if (changedProperties.has('name')) {
198
198
  // fetch icon data if name changes:
199
- this.getIconData().catch((err) => {
199
+ this.getIconData().catch(err => {
200
200
  if (err.name !== 'AbortError' && this.onerror) {
201
201
  this.onerror(err);
202
202
  }
203
203
  });
204
204
  }
205
205
  if (changedProperties.has('ariaLabel') || changedProperties.has('ariaLabelledBy')) {
206
- this.role = (this.ariaLabel || this.ariaLabelledBy) ? 'img' : null;
206
+ this.role = this.ariaLabel || this.ariaLabelledBy ? 'img' : null;
207
207
  }
208
208
  if (changedProperties.has('size') || changedProperties.has('lengthUnit')) {
209
209
  this.updateSize();
@@ -28,5 +28,5 @@ interface Args {
28
28
  * @returns Response string from the fetch
29
29
  * @throws Error if the response is not ok
30
30
  */
31
- declare const svgFetch: ({ url, name, fileExtension, cacheStrategy, cacheName, renewSignal, }: Args) => Promise<string>;
31
+ declare const svgFetch: ({ url, name, fileExtension, cacheStrategy, cacheName, renewSignal }: Args) => Promise<string>;
32
32
  export { svgFetch };
@@ -6,7 +6,7 @@ import { iconsCache } from '../../utils/icon-cache';
6
6
  * @returns Promise<Response> - The response from the fetch
7
7
  * @throws Error if the response is not ok
8
8
  */
9
- const fetchIcon = async (request) => fetch(request).then((response) => {
9
+ const fetchIcon = async (request) => fetch(request).then(response => {
10
10
  if (!response.ok) {
11
11
  throw new Error('There was a problem while fetching the icon!');
12
12
  }
@@ -33,7 +33,7 @@ const fetchIcon = async (request) => fetch(request).then((response) => {
33
33
  * @returns Response string from the fetch
34
34
  * @throws Error if the response is not ok
35
35
  */
36
- const svgFetch = async ({ url, name, fileExtension, cacheStrategy, cacheName, renewSignal, }) => {
36
+ const svgFetch = async ({ url, name, fileExtension, cacheStrategy, cacheName, renewSignal }) => {
37
37
  // abort the previous fetch request if it is still pending
38
38
  // and create a new signal
39
39
  const signal = renewSignal();
@@ -43,11 +43,11 @@ const svgFetch = async ({ url, name, fileExtension, cacheStrategy, cacheName, re
43
43
  // if there is no cache defined (cacheName and cacheStrategy properly set),
44
44
  // fetch the icon and return the response
45
45
  if (!cacheName || !cacheStrategy || !['in-memory-cache', 'web-cache-api'].includes(cacheStrategy)) {
46
- return fetchIcon(request).then((response) => response.text());
46
+ return fetchIcon(request).then(response => response.text());
47
47
  }
48
- return iconsCache(cacheName, cacheStrategy).then((iconsCache) => iconsCache
48
+ return iconsCache(cacheName, cacheStrategy).then(iconsCache => iconsCache
49
49
  .get(request)
50
- .then((responseFromCache) => {
50
+ .then(responseFromCache => {
51
51
  // **If entry in cache, return**
52
52
  if (responseFromCache) {
53
53
  return responseFromCache;
@@ -56,7 +56,7 @@ const svgFetch = async ({ url, name, fileExtension, cacheStrategy, cacheName, re
56
56
  // Both fetchIcon() and iconsCache.set() "consume" the request,
57
57
  // so we need to make a copy.
58
58
  // (see https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
59
- return fetchIcon(request.clone()).then((response) => {
59
+ return fetchIcon(request.clone()).then(response => {
60
60
  var _a;
61
61
  // This avoids caching responses that we know are errors
62
62
  // (i.e. HTTP status code of 4xx or 5xx).
@@ -68,7 +68,7 @@ const svgFetch = async ({ url, name, fileExtension, cacheStrategy, cacheName, re
68
68
  return response.text();
69
69
  });
70
70
  })
71
- .catch((error) => {
71
+ .catch(error => {
72
72
  // Note that a HTTP error response (e.g. 404) will NOT trigger
73
73
  // an exception.
74
74
  // It will return a normal response object that has the appropriate
@@ -110,13 +110,13 @@ class IconProvider extends Provider {
110
110
  }
111
111
  }
112
112
  updateContext() {
113
- if (this.context.value.fileExtension !== this.fileExtension
114
- || this.context.value.iconSet !== this.iconSet
115
- || this.context.value.url !== this.url
116
- || this.context.value.lengthUnit !== this.lengthUnit
117
- || this.context.value.size !== this.size
118
- || this.context.value.cacheName !== this.cacheName
119
- || this.context.value.cacheStrategy !== this.cacheStrategy) {
113
+ if (this.context.value.fileExtension !== this.fileExtension ||
114
+ this.context.value.iconSet !== this.iconSet ||
115
+ this.context.value.url !== this.url ||
116
+ this.context.value.lengthUnit !== this.lengthUnit ||
117
+ this.context.value.size !== this.size ||
118
+ this.context.value.cacheName !== this.cacheName ||
119
+ this.context.value.cacheStrategy !== this.cacheStrategy) {
120
120
  this.updateValuesInContext();
121
121
  this.context.updateObservers();
122
122
  }
@@ -1,8 +1,8 @@
1
1
  import { CSSResult, nothing, PropertyValueMap } from 'lit';
2
2
  import FormfieldWrapper from '../formfieldwrapper';
3
3
  import type { IconNames } from '../icon/icon.types';
4
- import type { AutoCapitalizeType, AutoCompleteType, InputType } from './input.types';
5
4
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
5
+ import type { AutoCapitalizeType, AutoCompleteType, InputType } from './input.types';
6
6
  declare const Input_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
7
7
  /**
8
8
  * mdc-input is a component that allows users to input text.
@@ -164,10 +164,10 @@ declare class Input extends Input_base implements AssociatedFormControl {
164
164
  */
165
165
  private onChange;
166
166
  /**
167
- * Handles the keydown event of the input field.
168
- * If the key pressed is 'Enter', it submits the form.
169
- * @param event - Keyboard event
170
- */
167
+ * Handles the keydown event of the input field.
168
+ * If the key pressed is 'Enter', it submits the form.
169
+ * @param event - Keyboard event
170
+ */
171
171
  protected handleKeyDown(event: KeyboardEvent): void;
172
172
  /**
173
173
  * Renders the leading icon before the input field.
@@ -10,12 +10,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  import { html, nothing } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
- import styles from './input.styles';
14
13
  import FormfieldWrapper from '../formfieldwrapper';
15
- import { AUTO_CAPITALIZE, AUTO_COMPLETE, DEFAULTS, PREFIX_TEXT_OPTIONS } from './input.constants';
16
14
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
17
15
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
18
16
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
17
+ import { AUTO_CAPITALIZE, AUTO_COMPLETE, DEFAULTS, PREFIX_TEXT_OPTIONS } from './input.constants';
18
+ import styles from './input.styles';
19
19
  /**
20
20
  * mdc-input is a component that allows users to input text.
21
21
  * It contains:
@@ -97,13 +97,15 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
97
97
  }
98
98
  connectedCallback() {
99
99
  super.connectedCallback();
100
- this.updateComplete.then(() => {
100
+ this.updateComplete
101
+ .then(() => {
101
102
  if (this.inputElement) {
102
103
  this.inputElement.checkValidity();
103
104
  this.setInputValidity();
104
105
  this.internals.setFormValue(this.inputElement.value);
105
106
  }
106
- }).catch((error) => {
107
+ })
108
+ .catch(error => {
107
109
  if (this.onerror) {
108
110
  this.onerror(error);
109
111
  }
@@ -124,9 +126,11 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
124
126
  * @returns void
125
127
  */
126
128
  handleValueChange() {
127
- this.updateComplete.then(() => {
129
+ this.updateComplete
130
+ .then(() => {
128
131
  this.setInputValidity();
129
- }).catch((error) => {
132
+ })
133
+ .catch(error => {
130
134
  if (this.onerror) {
131
135
  this.onerror(error);
132
136
  }
@@ -157,16 +161,13 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
157
161
  */
158
162
  attributeChangedCallback(name, old, value) {
159
163
  super.attributeChangedCallback(name, old, value);
160
- const validationRelatedAttributes = [
161
- 'maxlength',
162
- 'minlength',
163
- 'pattern',
164
- 'required',
165
- ];
164
+ const validationRelatedAttributes = ['maxlength', 'minlength', 'pattern', 'required'];
166
165
  if (validationRelatedAttributes.includes(name)) {
167
- this.updateComplete.then(() => {
166
+ this.updateComplete
167
+ .then(() => {
168
168
  this.setInputValidity();
169
- }).catch((error) => {
169
+ })
170
+ .catch(error => {
170
171
  if (this.onerror) {
171
172
  this.onerror(error);
172
173
  }
@@ -208,10 +209,10 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
208
209
  this.dispatchEvent(new EventConstructor(event.type, event));
209
210
  }
210
211
  /**
211
- * Handles the keydown event of the input field.
212
- * If the key pressed is 'Enter', it submits the form.
213
- * @param event - Keyboard event
214
- */
212
+ * Handles the keydown event of the input field.
213
+ * If the key pressed is 'Enter', it submits the form.
214
+ * @param event - Keyboard event
215
+ */
215
216
  handleKeyDown(event) {
216
217
  var _a;
217
218
  if (event.key === 'Enter') {
@@ -229,12 +230,13 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
229
230
  return nothing;
230
231
  }
231
232
  return html `
232
- <mdc-icon
233
- class="leading-icon"
233
+ <mdc-icon
234
+ class="leading-icon"
234
235
  part="leading-icon"
235
- name=${this.leadingIcon}
236
- size="${DEFAULTS.ICON_SIZE_VALUE}"
237
- length-unit="${DEFAULTS.ICON_SIZE_UNIT}">
236
+ name=${this.leadingIcon}
237
+ size="${DEFAULTS.ICON_SIZE_VALUE}"
238
+ length-unit="${DEFAULTS.ICON_SIZE_UNIT}"
239
+ >
238
240
  </mdc-icon>
239
241
  `;
240
242
  }
@@ -253,9 +255,9 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
253
255
  return nothing;
254
256
  }
255
257
  return html `
256
- <mdc-text
257
- class="prefix-text"
258
- tagname="${DEFAULTS.PREFIX_TEXT_TAG}"
258
+ <mdc-text
259
+ class="prefix-text"
260
+ tagname="${DEFAULTS.PREFIX_TEXT_TAG}"
259
261
  type="${DEFAULTS.PREFIX_TEXT_TYPE}"
260
262
  aria-hidden="true"
261
263
  >
@@ -282,11 +284,11 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
282
284
  return nothing;
283
285
  }
284
286
  return html `
285
- <mdc-button
286
- part='trailing-button'
287
- class='own-focus-ring ${!showBtn ? 'hidden' : ''}'
288
- prefix-icon='${DEFAULTS.CLEAR_BUTTON_ICON}'
289
- variant='${DEFAULTS.CLEAR_BUTTON_VARIANT}'
287
+ <mdc-button
288
+ part="trailing-button"
289
+ class="own-focus-ring ${!showBtn ? 'hidden' : ''}"
290
+ prefix-icon="${DEFAULTS.CLEAR_BUTTON_ICON}"
291
+ variant="${DEFAULTS.CLEAR_BUTTON_VARIANT}"
290
292
  size="${DEFAULTS.CLEAR_BUTTON_SIZE}"
291
293
  aria-label="${this.clearAriaLabel}"
292
294
  @click=${this.clearInputText}
@@ -297,43 +299,43 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
297
299
  renderInputElement(type, hidePlaceholder = false) {
298
300
  var _a;
299
301
  const placeholderText = hidePlaceholder ? '' : this.placeholder;
300
- return html `<input
301
- aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
302
- class='input'
303
- part='input'
304
- id="${this.id}"
305
- name="${this.name}"
306
- .value="${this.value}"
307
- ?disabled="${this.disabled}"
308
- ?readonly="${this.readonly}"
309
- ?required="${this.required}"
310
- type="${type}"
311
- aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : '')}"
312
- aria-invalid="${this.helpTextType === 'error' ? 'true' : 'false'}"
313
- placeholder=${ifDefined(placeholderText)}
314
- minlength=${ifDefined(this.minlength)}
315
- maxlength=${ifDefined(this.maxlength)}
316
- autocapitalize=${this.autocapitalize}
317
- autocomplete=${this.autocomplete}
318
- ?autofocus="${this.autofocus}"
319
- dirname=${ifDefined(this.dirname)}
320
- pattern=${ifDefined(this.pattern)}
321
- list=${ifDefined(this.list)}
322
- size=${ifDefined(this.size)}
323
- @input=${this.onInput}
324
- @change=${this.onChange}
325
- @keydown=${this.handleKeyDown}
326
- />`;
302
+ return html `<input
303
+ aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
304
+ class="input"
305
+ part="input"
306
+ id="${this.id}"
307
+ name="${this.name}"
308
+ .value="${this.value}"
309
+ ?disabled="${this.disabled}"
310
+ ?readonly="${this.readonly}"
311
+ ?required="${this.required}"
312
+ type="${type}"
313
+ aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : '')}"
314
+ aria-invalid="${this.helpTextType === 'error' ? 'true' : 'false'}"
315
+ placeholder=${ifDefined(placeholderText)}
316
+ minlength=${ifDefined(this.minlength)}
317
+ maxlength=${ifDefined(this.maxlength)}
318
+ autocapitalize=${this.autocapitalize}
319
+ autocomplete=${this.autocomplete}
320
+ ?autofocus="${this.autofocus}"
321
+ dirname=${ifDefined(this.dirname)}
322
+ pattern=${ifDefined(this.pattern)}
323
+ list=${ifDefined(this.list)}
324
+ size=${ifDefined(this.size)}
325
+ @input=${this.onInput}
326
+ @change=${this.onChange}
327
+ @keydown=${this.handleKeyDown}
328
+ />`;
327
329
  }
328
330
  render() {
329
331
  return html `
330
332
  ${this.renderLabel()}
331
333
  <div class="input-container mdc-focus-ring" part="input-container">
332
334
  <slot name="input-leading-icon">${this.renderLeadingIcon()}</slot>
333
- <div class="input-section" part="input-section">
334
- <slot name="input-prefix-text">${this.renderPrefixText()}</slot>
335
- <slot name="input">${this.renderInputElement(DEFAULTS.INPUT_TYPE)}</slot>
336
- </div>
335
+ <div class="input-section" part="input-section">
336
+ <slot name="input-prefix-text">${this.renderPrefixText()}</slot>
337
+ <slot name="input">${this.renderInputElement(DEFAULTS.INPUT_TYPE)}</slot>
338
+ </div>
337
339
  <slot name="trailing-button">${this.renderTrailingButton()}</slot>
338
340
  </div>
339
341
  ${this.helpText ? this.renderHelperText() : nothing}
@@ -1,120 +1,131 @@
1
1
  import { css } from 'lit';
2
2
  import { hostFocusRingStyles } from '../../utils/styles';
3
- const styles = [css `
4
- :host{
5
- --mdc-input-disabled-border-color: var(--mds-color-theme-outline-primary-disabled);
6
- --mdc-input-disabled-text-color: var(--mds-color-theme-text-primary-disabled);
7
- --mdc-input-disabled-background-color: var(--mds-color-theme-background-input-disabled);
8
- --mdc-input-border-color: var(--mds-color-theme-outline-input-normal);
9
- --mdc-input-text-color: var(--mds-color-theme-text-primary-normal);
10
- --mdc-input-background-color: var(--mds-color-theme-background-primary-ghost);
11
- --mdc-input-selection-background-color: var(--mds-color-theme-background-accent-active);
12
- --mdc-input-selection-text-color: var(--mds-color-theme-inverted-text-primary-normal);
13
- --mdc-input-support-text-color: var(--mds-color-theme-text-secondary-normal);
14
- --mdc-input-hover-background-color: var(--mds-color-theme-background-primary-hover);
15
- --mdc-input-focused-background-color: var(--mds-color-theme-background-primary-ghost);
16
- --mdc-input-focused-border-color: var(--mds-color-theme-outline-input-active);
17
- --mdc-input-error-border-color: var(--mds-color-theme-text-error-normal);
18
- --mdc-input-warning-border-color: var(--mds-color-theme-text-warning-normal);
19
- --mdc-input-success-border-color: var(--mds-color-theme-text-success-normal);
20
- --mdc-input-primary-border-color: var(--mds-color-theme-text-accent-normal);
21
- }
22
-
23
- :host, .input-container, .input-section, .input{
24
- width: 100%;
25
- }
26
-
27
- input{
28
- font-family: inherit;
29
- }
30
-
31
- :host([readonly]) .leading-icon {
32
- color: var(--mdc-input-support-text-color);
33
- }
34
-
35
- :host([disabled]) .input,
36
- :host([disabled]) .input::placeholder,
37
- :host([disabled]) .prefix-text{
38
- color: var(--mdc-input-disabled-text-color);
39
- }
40
-
41
- :host([disabled]) .input-container,
42
- :host([readonly]) .input-container,
43
- :host([disabled][help-text-type="default"]) .input-container,
44
- :host([disabled][help-text-type="success"]) .input-container,
45
- :host([disabled][help-text-type="warning"]) .input-container,
46
- :host([disabled][help-text-type="error"]) .input-container,
47
- :host([disabled][help-text-type="priority"]) .input-container{
48
- border-color: var(--mdc-input-disabled-border-color);
49
- background: var(--mdc-input-disabled-background-color);
50
- }
51
-
52
- .leading-icon{
53
- aspect-ratio: 1;
54
- }
55
-
56
- .input-container{
57
- height: 2rem;
58
- border-radius: 0.5rem;
59
- border: 0.0625rem solid var(--mdc-input-border-color);
60
- display: flex;
61
- align-items: center;
62
- gap: 0.375rem;
63
- padding: 0.34375rem 0.375rem 0.34375rem 0.75rem;
64
- min-width: 3.25rem;
65
- }
66
-
67
- .input-section{
68
- display: flex;
69
- gap: 0.25rem;
70
- }
71
-
72
- .input {
73
- border: none;
74
- color: var(--mdc-input-text-color);
75
- background-color: var(--mdc-input-background-color);
76
- outline: none;
77
- }
78
-
79
- .input::selection {
80
- background-color: var(--mdc-input-selection-background-color);
81
- color: var(--mdc-input-selection-text-color);
82
- }
83
-
84
- .prefix-text{
85
- color: var(--mdc-input-support-text-color);
86
- white-space: nowrap; // restrict prefix text to be in one line
87
- }
88
-
89
- :host(:not([disabled])) .input-container:hover{
90
- background-color: var(--mdc-input-hover-background-color);
91
- }
92
-
93
- :host(:not([disabled])) .input-container:active, :host(:not([disabled])) .input-container:focus-within{
94
- background-color: var(--mdc-input-focused-background-color);
95
- border-color: var(--mdc-input-focused-border-color);
96
- }
97
-
98
- .input::placeholder{
99
- color: var(--mdc-input-support-text-color);
100
- }
101
-
102
- :host([help-text-type="error"]) .input-container, :host([help-text-type="error"]) .input-container:focus-within {
103
- border-color: var(--mdc-input-error-border-color);
104
- }
105
- :host([help-text-type="warning"]) .input-container, :host([help-text-type="warning"]) .input-container:focus-within {
106
- border-color: var(--mdc-input-warning-border-color);
107
- }
108
- :host([help-text-type="success"]) .input-container, :host([help-text-type="success"]) .input-container:focus-within {
109
- border-color: var(--mdc-input-success-border-color);
110
- }
111
- :host([help-text-type="priority"]) .input-container, :host([help-text-type="priority"]) input-container:focus-within {
112
- border-color: var(--mdc-input-primary-border-color);
113
- }
114
-
115
- .hidden{
116
- opacity: 0;
117
- pointer-events: none;
118
- }
119
- `, ...hostFocusRingStyles(true)];
3
+ const styles = [
4
+ css `
5
+ :host {
6
+ --mdc-input-disabled-border-color: var(--mds-color-theme-outline-primary-disabled);
7
+ --mdc-input-disabled-text-color: var(--mds-color-theme-text-primary-disabled);
8
+ --mdc-input-disabled-background-color: var(--mds-color-theme-background-input-disabled);
9
+ --mdc-input-border-color: var(--mds-color-theme-outline-input-normal);
10
+ --mdc-input-text-color: var(--mds-color-theme-text-primary-normal);
11
+ --mdc-input-background-color: var(--mds-color-theme-background-primary-ghost);
12
+ --mdc-input-selection-background-color: var(--mds-color-theme-background-accent-active);
13
+ --mdc-input-selection-text-color: var(--mds-color-theme-inverted-text-primary-normal);
14
+ --mdc-input-support-text-color: var(--mds-color-theme-text-secondary-normal);
15
+ --mdc-input-hover-background-color: var(--mds-color-theme-background-primary-hover);
16
+ --mdc-input-focused-background-color: var(--mds-color-theme-background-primary-ghost);
17
+ --mdc-input-focused-border-color: var(--mds-color-theme-outline-input-active);
18
+ --mdc-input-error-border-color: var(--mds-color-theme-text-error-normal);
19
+ --mdc-input-warning-border-color: var(--mds-color-theme-text-warning-normal);
20
+ --mdc-input-success-border-color: var(--mds-color-theme-text-success-normal);
21
+ --mdc-input-primary-border-color: var(--mds-color-theme-text-accent-normal);
22
+ }
23
+
24
+ :host,
25
+ .input-container,
26
+ .input-section,
27
+ .input {
28
+ width: 100%;
29
+ }
30
+
31
+ input {
32
+ font-family: inherit;
33
+ }
34
+
35
+ :host([readonly]) .leading-icon {
36
+ color: var(--mdc-input-support-text-color);
37
+ }
38
+
39
+ :host([disabled]) .input,
40
+ :host([disabled]) .input::placeholder,
41
+ :host([disabled]) .prefix-text {
42
+ color: var(--mdc-input-disabled-text-color);
43
+ }
44
+
45
+ :host([disabled]) .input-container,
46
+ :host([readonly]) .input-container,
47
+ :host([disabled][help-text-type='default']) .input-container,
48
+ :host([disabled][help-text-type='success']) .input-container,
49
+ :host([disabled][help-text-type='warning']) .input-container,
50
+ :host([disabled][help-text-type='error']) .input-container,
51
+ :host([disabled][help-text-type='priority']) .input-container {
52
+ border-color: var(--mdc-input-disabled-border-color);
53
+ background: var(--mdc-input-disabled-background-color);
54
+ }
55
+
56
+ .leading-icon {
57
+ aspect-ratio: 1;
58
+ }
59
+
60
+ .input-container {
61
+ height: 2rem;
62
+ border-radius: 0.5rem;
63
+ border: 0.0625rem solid var(--mdc-input-border-color);
64
+ display: flex;
65
+ align-items: center;
66
+ gap: 0.375rem;
67
+ padding: 0.34375rem 0.375rem 0.34375rem 0.75rem;
68
+ min-width: 3.25rem;
69
+ }
70
+
71
+ .input-section {
72
+ display: flex;
73
+ gap: 0.25rem;
74
+ }
75
+
76
+ .input {
77
+ border: none;
78
+ color: var(--mdc-input-text-color);
79
+ background-color: var(--mdc-input-background-color);
80
+ outline: none;
81
+ }
82
+
83
+ .input::selection {
84
+ background-color: var(--mdc-input-selection-background-color);
85
+ color: var(--mdc-input-selection-text-color);
86
+ }
87
+
88
+ .prefix-text {
89
+ color: var(--mdc-input-support-text-color);
90
+ white-space: nowrap; // restrict prefix text to be in one line
91
+ }
92
+
93
+ :host(:not([disabled])) .input-container:hover {
94
+ background-color: var(--mdc-input-hover-background-color);
95
+ }
96
+
97
+ :host(:not([disabled])) .input-container:active,
98
+ :host(:not([disabled])) .input-container:focus-within {
99
+ background-color: var(--mdc-input-focused-background-color);
100
+ border-color: var(--mdc-input-focused-border-color);
101
+ }
102
+
103
+ .input::placeholder {
104
+ color: var(--mdc-input-support-text-color);
105
+ }
106
+
107
+ :host([help-text-type='error']) .input-container,
108
+ :host([help-text-type='error']) .input-container:focus-within {
109
+ border-color: var(--mdc-input-error-border-color);
110
+ }
111
+ :host([help-text-type='warning']) .input-container,
112
+ :host([help-text-type='warning']) .input-container:focus-within {
113
+ border-color: var(--mdc-input-warning-border-color);
114
+ }
115
+ :host([help-text-type='success']) .input-container,
116
+ :host([help-text-type='success']) .input-container:focus-within {
117
+ border-color: var(--mdc-input-success-border-color);
118
+ }
119
+ :host([help-text-type='priority']) .input-container,
120
+ :host([help-text-type='priority']) input-container:focus-within {
121
+ border-color: var(--mdc-input-primary-border-color);
122
+ }
123
+
124
+ .hidden {
125
+ opacity: 0;
126
+ pointer-events: none;
127
+ }
128
+ `,
129
+ ...hostFocusRingStyles(true),
130
+ ];
120
131
  export default styles;