@momentum-design/components 0.42.0 → 0.43.1

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 (31) hide show
  1. package/dist/browser/index.js +191 -153
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/alertchip/alertchip.styles.js +1 -0
  4. package/dist/components/chip/chip.styles.js +1 -0
  5. package/dist/components/input/input.component.d.ts +3 -2
  6. package/dist/components/input/input.component.js +35 -34
  7. package/dist/components/input/input.constants.d.ts +11 -1
  8. package/dist/components/input/input.constants.js +11 -1
  9. package/dist/components/input/input.styles.js +1 -0
  10. package/dist/components/input/input.types.d.ts +4 -2
  11. package/dist/components/inputchip/inputchip.component.d.ts +1 -4
  12. package/dist/components/inputchip/inputchip.component.js +3 -8
  13. package/dist/components/inputchip/inputchip.styles.js +1 -1
  14. package/dist/components/searchfield/index.d.ts +10 -0
  15. package/dist/components/searchfield/index.js +7 -0
  16. package/dist/components/searchfield/searchfield.component.d.ts +36 -0
  17. package/dist/components/searchfield/searchfield.component.js +98 -0
  18. package/dist/components/searchfield/searchfield.constants.d.ts +7 -0
  19. package/dist/components/searchfield/searchfield.constants.js +9 -0
  20. package/dist/components/searchfield/searchfield.styles.d.ts +2 -0
  21. package/dist/components/searchfield/searchfield.styles.js +30 -0
  22. package/dist/custom-elements.json +5768 -4580
  23. package/dist/index.d.ts +2 -1
  24. package/dist/index.js +2 -1
  25. package/dist/react/index.d.ts +2 -1
  26. package/dist/react/index.js +2 -1
  27. package/dist/react/inputchip/index.d.ts +2 -9
  28. package/dist/react/inputchip/index.js +2 -9
  29. package/dist/react/searchfield/index.d.ts +21 -0
  30. package/dist/react/searchfield/index.js +30 -0
  31. package/package.json +1 -1
@@ -8,6 +8,7 @@ const styles = css `
8
8
  border-radius: 0.25rem;
9
9
  border: 1px solid;
10
10
  cursor: pointer;
11
+ white-space: nowrap;
11
12
 
12
13
  --mdc-chip-color: var(--mds-color-theme-text-primary-normal);
13
14
  --mdc-chip-border-color: var(--mds-color-theme-outline-button-normal);
@@ -8,6 +8,7 @@ const styles = css `
8
8
  border-radius: 0.25rem;
9
9
  border: 1px solid;
10
10
  cursor: pointer;
11
+ white-space: nowrap;
11
12
 
12
13
  --mdc-chip-color: var(--mds-color-theme-text-primary-normal);
13
14
  --mdc-chip-border-color: var(--mds-color-theme-outline-button-normal);
@@ -1,7 +1,7 @@
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 } from './input.types';
4
+ import type { AutoCapitalizeType, AutoCompleteType, InputType } from './input.types';
5
5
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
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
  /**
@@ -86,7 +86,7 @@ declare class Input extends Input_base implements AssociatedFormControl {
86
86
  * The autocomplete attribute of the input field.
87
87
  * @default 'off'
88
88
  */
89
- autocomplete: any;
89
+ autocomplete: AutoCompleteType;
90
90
  /**
91
91
  * If true, the input field is focused when the component is rendered.
92
92
  * @default false
@@ -195,6 +195,7 @@ declare class Input extends Input_base implements AssociatedFormControl {
195
195
  * @returns void
196
196
  */
197
197
  protected renderTrailingButton(): import("lit-html").TemplateResult<1> | typeof nothing;
198
+ protected renderInputElement(type: InputType): import("lit-html").TemplateResult<1>;
198
199
  render(): import("lit-html").TemplateResult<1>;
199
200
  static styles: Array<CSSResult>;
200
201
  }
@@ -12,7 +12,7 @@ import { property } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
13
  import styles from './input.styles';
14
14
  import FormfieldWrapper from '../formfieldwrapper';
15
- import { AUTO_CAPITALIZE, DEFAULTS, PREFIX_TEXT_OPTIONS } from './input.constants';
15
+ import { AUTO_CAPITALIZE, AUTO_COMPLETE, DEFAULTS, PREFIX_TEXT_OPTIONS } from './input.constants';
16
16
  import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
17
17
  import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
18
18
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
@@ -82,7 +82,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
82
82
  * The autocomplete attribute of the input field.
83
83
  * @default 'off'
84
84
  */
85
- this.autocomplete = 'off';
85
+ this.autocomplete = AUTO_COMPLETE.OFF;
86
86
  /**
87
87
  * If true, the input field is focused when the component is rendered.
88
88
  * @default false
@@ -276,7 +276,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
276
276
  * @returns void
277
277
  */
278
278
  renderTrailingButton() {
279
- if (!this.trailingButton) {
279
+ if (!this.trailingButton || !this.value) {
280
280
  return nothing;
281
281
  }
282
282
  return html `
@@ -292,43 +292,44 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
292
292
  ></mdc-button>
293
293
  `;
294
294
  }
295
- render() {
295
+ renderInputElement(type) {
296
296
  var _a;
297
+ return html `<input
298
+ aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
299
+ class='input'
300
+ part='input'
301
+ id="${this.id}"
302
+ name="${this.name}"
303
+ .value="${this.value}"
304
+ ?disabled="${this.disabled}"
305
+ ?readonly="${this.readonly}"
306
+ ?required="${!!this.requiredLabel}"
307
+ type="${type}"
308
+ aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : '')}"
309
+ aria-invalid="${this.helpTextType === 'error' ? 'true' : 'false'}"
310
+ placeholder=${ifDefined(this.placeholder)}
311
+ minlength=${ifDefined(this.minlength)}
312
+ maxlength=${ifDefined(this.maxlength)}
313
+ autocapitalize=${this.autocapitalize}
314
+ autocomplete=${this.autocomplete}
315
+ ?autofocus="${this.autofocus}"
316
+ dirname=${ifDefined(this.dirname)}
317
+ pattern=${ifDefined(this.pattern)}
318
+ list=${ifDefined(this.list)}
319
+ size=${ifDefined(this.size)}
320
+ @input=${this.onInput}
321
+ @change=${this.onChange}
322
+ @keydown=${this.handleKeyDown}
323
+ />`;
324
+ }
325
+ render() {
297
326
  return html `
298
327
  ${this.renderLabel()}
299
328
  <div class="input-container mdc-focus-ring" part="input-container">
300
329
  <slot name="input-leading-icon">${this.renderLeadingIcon()}</slot>
301
330
  <div class="input-section" part="input-section">
302
331
  <slot name="input-prefix-text">${this.renderPrefixText()}</slot>
303
- <slot name="input">
304
- <input
305
- aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
306
- class='input'
307
- part='input'
308
- id="${this.id}"
309
- name="${this.name}"
310
- .value="${this.value}"
311
- ?disabled="${this.disabled}"
312
- ?readonly="${this.readonly}"
313
- ?required="${!!this.requiredLabel}"
314
- type="text"
315
- aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : '')}"
316
- aria-invalid="${this.helpTextType === 'error' ? 'true' : 'false'}"
317
- placeholder=${ifDefined(this.placeholder)}
318
- minlength=${ifDefined(this.minlength)}
319
- maxlength=${ifDefined(this.maxlength)}
320
- autocapitalize=${this.autocapitalize}
321
- autocomplete=${this.autocomplete}
322
- ?autofocus="${this.autofocus}"
323
- dirname=${ifDefined(this.dirname)}
324
- pattern=${ifDefined(this.pattern)}
325
- list=${ifDefined(this.list)}
326
- size=${ifDefined(this.size)}
327
- @input=${this.onInput}
328
- @change=${this.onChange}
329
- @keydown=${this.handleKeyDown}
330
- />
331
- </slot>
332
+ <slot name="input">${this.renderInputElement(DEFAULTS.INPUT_TYPE)}</slot>
332
333
  </div>
333
334
  <slot name="trailing-button">${this.renderTrailingButton()}</slot>
334
335
  </div>
@@ -371,7 +372,7 @@ __decorate([
371
372
  ], Input.prototype, "autocapitalize", void 0);
372
373
  __decorate([
373
374
  property({ type: String }),
374
- __metadata("design:type", Object)
375
+ __metadata("design:type", String)
375
376
  ], Input.prototype, "autocomplete", void 0);
376
377
  __decorate([
377
378
  property({ type: Boolean }),
@@ -7,6 +7,14 @@ declare const AUTO_CAPITALIZE: {
7
7
  readonly WORDS: "words";
8
8
  readonly CHARACTERS: "characters";
9
9
  };
10
+ declare const AUTO_COMPLETE: {
11
+ readonly OFF: "off";
12
+ readonly ON: "on";
13
+ };
14
+ declare const INPUT_TYPE: {
15
+ readonly TEXT: "text";
16
+ readonly SEARCH: "search";
17
+ };
10
18
  declare const PREFIX_TEXT_OPTIONS: {
11
19
  MAX_LENGTH: number;
12
20
  VALIDATION: "error";
@@ -20,5 +28,7 @@ declare const DEFAULTS: {
20
28
  CLEAR_BUTTON_SIZE: 20;
21
29
  PREFIX_TEXT_TYPE: "body-midsize-regular";
22
30
  PREFIX_TEXT_TAG: "span";
31
+ AUTO_COMPLETE: "off";
32
+ INPUT_TYPE: "text";
23
33
  };
24
- export { TAG_NAME, PREFIX_TEXT_OPTIONS, AUTO_CAPITALIZE, DEFAULTS };
34
+ export { TAG_NAME, PREFIX_TEXT_OPTIONS, AUTO_CAPITALIZE, AUTO_COMPLETE, INPUT_TYPE, DEFAULTS };
@@ -11,6 +11,14 @@ const AUTO_CAPITALIZE = {
11
11
  WORDS: 'words',
12
12
  CHARACTERS: 'characters',
13
13
  };
14
+ const AUTO_COMPLETE = {
15
+ OFF: 'off',
16
+ ON: 'on',
17
+ };
18
+ const INPUT_TYPE = {
19
+ TEXT: 'text',
20
+ SEARCH: 'search',
21
+ };
14
22
  const PREFIX_TEXT_OPTIONS = {
15
23
  MAX_LENGTH: 10,
16
24
  VALIDATION: VALIDATION.ERROR,
@@ -24,5 +32,7 @@ const DEFAULTS = {
24
32
  CLEAR_BUTTON_SIZE: ICON_BUTTON_SIZES[20],
25
33
  PREFIX_TEXT_TYPE: TYPE.BODY_MIDSIZE_REGULAR,
26
34
  PREFIX_TEXT_TAG: VALID_TEXT_TAGS.SPAN,
35
+ AUTO_COMPLETE: AUTO_COMPLETE.OFF,
36
+ INPUT_TYPE: INPUT_TYPE.TEXT,
27
37
  };
28
- export { TAG_NAME, PREFIX_TEXT_OPTIONS, AUTO_CAPITALIZE, DEFAULTS };
38
+ export { TAG_NAME, PREFIX_TEXT_OPTIONS, AUTO_CAPITALIZE, AUTO_COMPLETE, INPUT_TYPE, DEFAULTS };
@@ -40,6 +40,7 @@ const styles = [css `
40
40
  background: var(--mdc-input-disabled-background-color);
41
41
  }
42
42
 
43
+ :host([disabled]) .input-container,
43
44
  :host([disabled][help-text-type="default"]) .input-container,
44
45
  :host([disabled][help-text-type="success"]) .input-container,
45
46
  :host([disabled][help-text-type="warning"]) .input-container,
@@ -1,4 +1,6 @@
1
1
  import type { ValueOf } from '../../utils/types';
2
- import { AUTO_CAPITALIZE } from './input.constants';
2
+ import { AUTO_CAPITALIZE, AUTO_COMPLETE, INPUT_TYPE } from './input.constants';
3
3
  type AutoCapitalizeType = ValueOf<typeof AUTO_CAPITALIZE>;
4
- export { AutoCapitalizeType };
4
+ type AutoCompleteType = ValueOf<typeof AUTO_COMPLETE>;
5
+ type InputType = ValueOf<typeof INPUT_TYPE>;
6
+ export { AutoCapitalizeType, AutoCompleteType, InputType };
@@ -14,10 +14,7 @@ declare const InputChip_base: import("../../utils/mixins/index.types").Construct
14
14
  * @dependency mdc-icon
15
15
  * @dependency mdc-text
16
16
  *
17
- * @event click - (React: onClick) This event is dispatched when the close button is clicked.
18
- * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the close button.
19
- * @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the close button.
20
- * @event focus - (React: onFocus) This event is dispatched when the close button receives focus.
17
+ * @event remove - This event is dispatched when the close button is activated. It bubbles and is composed.
21
18
  *
22
19
  * @cssproperty --mdc-chip-color - The color of the chip.
23
20
  * @cssproperty --mdc-chip-border-color - The border color of the chip.
@@ -27,10 +27,7 @@ import { DEFAULTS } from './inputchip.constants';
27
27
  * @dependency mdc-icon
28
28
  * @dependency mdc-text
29
29
  *
30
- * @event click - (React: onClick) This event is dispatched when the close button is clicked.
31
- * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the close button.
32
- * @event keyup - (React: onKeyUp) This event is dispatched when a key is released on the close button.
33
- * @event focus - (React: onFocus) This event is dispatched when the close button receives focus.
30
+ * @event remove - This event is dispatched when the close button is activated. It bubbles and is composed.
34
31
  *
35
32
  * @cssproperty --mdc-chip-color - The color of the chip.
36
33
  * @cssproperty --mdc-chip-border-color - The border color of the chip.
@@ -76,10 +73,8 @@ class InputChip extends IconNameMixin(DisabledMixin(Component)) {
76
73
  * Handles the behavior of the close button on click event.
77
74
  * @param event - The event object.
78
75
  */
79
- handleClose(event) {
80
- event.stopPropagation(); // Prevents triggering click event twice
81
- const EventConstructor = event.constructor;
82
- this.dispatchEvent(new EventConstructor(event.type, event));
76
+ handleClose() {
77
+ this.dispatchEvent(new CustomEvent('remove', { bubbles: true, composed: true }));
83
78
  }
84
79
  render() {
85
80
  return html `
@@ -7,7 +7,7 @@ const styles = css `
7
7
  padding: 0 0.25rem 0 0.5rem;
8
8
  border-radius: 0.25rem;
9
9
  border: 1px solid;
10
- cursor: pointer;
10
+ white-space: nowrap;
11
11
 
12
12
  --mdc-chip-color: var(--mds-color-theme-text-primary-normal);
13
13
  --mdc-chip-border-color: var(--mds-color-theme-outline-button-normal);
@@ -0,0 +1,10 @@
1
+ import Searchfield from './searchfield.component';
2
+ import '../button';
3
+ import '../icon';
4
+ import '../text';
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ ['mdc-searchfield']: Searchfield;
8
+ }
9
+ }
10
+ export default Searchfield;
@@ -0,0 +1,7 @@
1
+ import Searchfield from './searchfield.component';
2
+ import { TAG_NAME } from './searchfield.constants';
3
+ import '../button';
4
+ import '../icon';
5
+ import '../text';
6
+ Searchfield.register(TAG_NAME);
7
+ export default Searchfield;
@@ -0,0 +1,36 @@
1
+ import { CSSResult } from 'lit';
2
+ import Input from '../input/input.component';
3
+ /**
4
+ * searchfield component is used as an input field for search functionality.
5
+ *
6
+ * It supports `mdc-inputchip` as filters.
7
+ *
8
+ * This component is built by extending the `mdc-input` component.
9
+ *
10
+ * @tagname mdc-searchfield
11
+ *
12
+ * @slot filters - Slot for input chips
13
+ *
14
+ */
15
+ declare class Searchfield extends Input {
16
+ inputChips?: Array<HTMLElement>;
17
+ /**
18
+ * @internal
19
+ */
20
+ isInputFocused: boolean;
21
+ connectedCallback(): void;
22
+ /**
23
+ * This method is used to render the input chips inside filters slot.
24
+ * It will remove any elements that are not input chips.
25
+ */
26
+ private renderInputChips;
27
+ /**
28
+ * This sets the focus ring state based on the input focus state.
29
+ * Eventually, this logic has to be omitted and achieved using CSS instead.
30
+ * @override
31
+ */
32
+ firstUpdated(): void;
33
+ render(): import("lit-html").TemplateResult<1>;
34
+ static styles: Array<CSSResult>;
35
+ }
36
+ export default Searchfield;
@@ -0,0 +1,98 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { html } from 'lit';
11
+ import { queryAssignedElements, state } from 'lit/decorators.js';
12
+ import { classMap } from 'lit-html/directives/class-map.js';
13
+ import styles from './searchfield.styles';
14
+ import Input from '../input/input.component';
15
+ import { DEFAULTS } from './searchfield.constants';
16
+ /**
17
+ * searchfield component is used as an input field for search functionality.
18
+ *
19
+ * It supports `mdc-inputchip` as filters.
20
+ *
21
+ * This component is built by extending the `mdc-input` component.
22
+ *
23
+ * @tagname mdc-searchfield
24
+ *
25
+ * @slot filters - Slot for input chips
26
+ *
27
+ */
28
+ class Searchfield extends Input {
29
+ constructor() {
30
+ super(...arguments);
31
+ /**
32
+ * @internal
33
+ */
34
+ this.isInputFocused = false;
35
+ }
36
+ connectedCallback() {
37
+ super.connectedCallback();
38
+ this.leadingIcon = DEFAULTS.ICON;
39
+ this.trailingButton = DEFAULTS.CLOSE_BTN;
40
+ this.helpText = undefined;
41
+ this.helpTextType = undefined;
42
+ this.requiredLabel = undefined;
43
+ this.validationMessage = undefined;
44
+ this.prefixText = undefined;
45
+ }
46
+ /**
47
+ * This method is used to render the input chips inside filters slot.
48
+ * It will remove any elements that are not input chips.
49
+ */
50
+ renderInputChips() {
51
+ if (this.inputChips) {
52
+ this.inputChips.forEach((element) => {
53
+ if (!element.matches('mdc-inputchip')) {
54
+ element.remove();
55
+ }
56
+ });
57
+ }
58
+ }
59
+ /**
60
+ * This sets the focus ring state based on the input focus state.
61
+ * Eventually, this logic has to be omitted and achieved using CSS instead.
62
+ * @override
63
+ */
64
+ firstUpdated() {
65
+ this.inputElement.onfocus = () => {
66
+ this.isInputFocused = true;
67
+ };
68
+ this.inputElement.onblur = () => {
69
+ this.isInputFocused = false;
70
+ };
71
+ }
72
+ render() {
73
+ return html `
74
+ ${this.renderLabelElement()}
75
+ <div class="${classMap({
76
+ 'input-container': true,
77
+ 'mdc-focus-ring': this.isInputFocused,
78
+ })}" part="input-container">
79
+ ${this.renderLeadingIcon()}
80
+ <div part='scrollable-container'>
81
+ <div part="filters-container"><slot name="filters" @slotchange=${this.renderInputChips}></slot></div>
82
+ ${this.renderInputElement(DEFAULTS.TYPE)}
83
+ </div>
84
+ ${this.renderTrailingButton()}
85
+ </div>
86
+ `;
87
+ }
88
+ }
89
+ Searchfield.styles = [...Input.styles, ...styles];
90
+ __decorate([
91
+ queryAssignedElements({ slot: 'filters' }),
92
+ __metadata("design:type", Array)
93
+ ], Searchfield.prototype, "inputChips", void 0);
94
+ __decorate([
95
+ state(),
96
+ __metadata("design:type", Object)
97
+ ], Searchfield.prototype, "isInputFocused", void 0);
98
+ export default Searchfield;
@@ -0,0 +1,7 @@
1
+ declare const TAG_NAME: "mdc-searchfield";
2
+ declare const DEFAULTS: {
3
+ TYPE: "search";
4
+ ICON: "search-bold";
5
+ CLOSE_BTN: boolean;
6
+ };
7
+ export { TAG_NAME, DEFAULTS };
@@ -0,0 +1,9 @@
1
+ import utils from '../../utils/tag-name';
2
+ import { INPUT_TYPE } from '../input/input.constants';
3
+ const TAG_NAME = utils.constructTagName('searchfield');
4
+ const DEFAULTS = {
5
+ TYPE: INPUT_TYPE.SEARCH,
6
+ ICON: 'search-bold',
7
+ CLOSE_BTN: true,
8
+ };
9
+ export { TAG_NAME, DEFAULTS };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,30 @@
1
+ import { css } from 'lit';
2
+ const styles = css `
3
+
4
+ :host::part(filters-container){
5
+ display: flex;
6
+ gap: 0.25rem;
7
+ margin: 0.25rem;
8
+ }
9
+
10
+ .input {
11
+ white-space: nowrap;
12
+ min-width: 50%;
13
+ }
14
+
15
+ .input::-webkit-search-cancel-button {
16
+ -webkit-appearance: none;
17
+ pointer-events: none;
18
+ }
19
+
20
+ :host::part(scrollable-container){
21
+ display: flex;
22
+ flex-grow: 1;
23
+ overflow-x: scroll;
24
+ overflow-y: hidden;
25
+ position: relative;
26
+ scrollbar-width: none;
27
+ }
28
+
29
+ `;
30
+ export default [styles];