@momentum-design/components 0.53.0 → 0.53.2
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.
- package/dist/browser/index.js +145 -140
- package/dist/browser/index.js.map +4 -4
- package/dist/components/filterchip/index.d.ts +2 -0
- package/dist/components/filterchip/index.js +2 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +6 -2
- package/dist/components/input/input.component.d.ts +4 -4
- package/dist/components/input/input.component.js +8 -6
- package/dist/components/input/input.styles.js +8 -8
- package/dist/components/option/option.component.js +3 -2
- package/dist/components/progressbar/progressbar.styles.js +1 -0
- package/dist/components/searchfield/searchfield.component.d.ts +12 -0
- package/dist/components/searchfield/searchfield.component.js +34 -4
- package/dist/components/searchfield/searchfield.constants.d.ts +1 -0
- package/dist/components/searchfield/searchfield.constants.js +2 -0
- package/dist/components/searchfield/searchfield.styles.js +2 -2
- package/dist/components/textarea/textarea.styles.js +4 -4
- package/dist/custom-elements.json +149 -143
- package/dist/utils/mixins/FormInternalsMixin.js +16 -12
- package/package.json +1 -1
@@ -20,14 +20,18 @@ const styles = [
|
|
20
20
|
|
21
21
|
.mdc-label-text,
|
22
22
|
.mdc-help-text {
|
23
|
-
font-size: var(--mds-font-size-body-midsize);
|
24
|
-
line-height: var(--mds-font-lineheight-body-midsize);
|
25
23
|
display: flex;
|
26
24
|
align-items: center;
|
27
25
|
gap: 0.5rem;
|
28
26
|
width: 100%;
|
29
27
|
}
|
30
28
|
|
29
|
+
.mdc-label, .mdc-help-text{
|
30
|
+
font-size: var(--mds-font-apps-body-midsize-regular-font-size);
|
31
|
+
font-weight: var(--mds-font-apps-body-midsize-regular-font-weight);
|
32
|
+
line-height: var(--mds-font-apps-body-midsize-regular-line-height);
|
33
|
+
}
|
34
|
+
|
31
35
|
.mdc-label {
|
32
36
|
color: var(--mds-color-theme-text-primary-normal);
|
33
37
|
overflow: hidden;
|
@@ -167,7 +167,7 @@ declare class Input extends Input_base implements AssociatedFormControl {
|
|
167
167
|
* If the key pressed is 'Enter', it submits the form.
|
168
168
|
* @param event - Keyboard event
|
169
169
|
*/
|
170
|
-
|
170
|
+
protected handleKeyDown(event: KeyboardEvent): void;
|
171
171
|
/**
|
172
172
|
* Renders the leading icon before the input field.
|
173
173
|
* If the leading icon is not set, it will not be displayed.
|
@@ -189,13 +189,13 @@ declare class Input extends Input_base implements AssociatedFormControl {
|
|
189
189
|
/**
|
190
190
|
* Clears the input field.
|
191
191
|
*/
|
192
|
-
|
192
|
+
protected clearInputText(): void;
|
193
193
|
/**
|
194
194
|
* Renders the trailing button to clear the input field if the trailingButton is set to true.
|
195
195
|
* @returns void
|
196
196
|
*/
|
197
|
-
protected renderTrailingButton(): import("lit-html").TemplateResult<1> | typeof nothing;
|
198
|
-
protected renderInputElement(type: InputType): import("lit-html").TemplateResult<1>;
|
197
|
+
protected renderTrailingButton(show?: boolean): import("lit-html").TemplateResult<1> | typeof nothing;
|
198
|
+
protected renderInputElement(type: InputType, hidePlaceholder?: boolean): import("lit-html").TemplateResult<1>;
|
199
199
|
render(): import("lit-html").TemplateResult<1>;
|
200
200
|
static styles: Array<CSSResult>;
|
201
201
|
}
|
@@ -275,25 +275,27 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
275
275
|
* Renders the trailing button to clear the input field if the trailingButton is set to true.
|
276
276
|
* @returns void
|
277
277
|
*/
|
278
|
-
renderTrailingButton() {
|
279
|
-
|
278
|
+
renderTrailingButton(show = false) {
|
279
|
+
const showBtn = show || (this.value && this.trailingButton);
|
280
|
+
if (!showBtn) {
|
280
281
|
return nothing;
|
281
282
|
}
|
282
283
|
return html `
|
283
284
|
<mdc-button
|
284
285
|
part='trailing-button'
|
285
|
-
class='own-focus-ring ${!
|
286
|
+
class='own-focus-ring ${!showBtn ? 'hidden' : ''}'
|
286
287
|
prefix-icon='${DEFAULTS.CLEAR_BUTTON_ICON}'
|
287
288
|
variant='${DEFAULTS.CLEAR_BUTTON_VARIANT}'
|
288
289
|
size="${DEFAULTS.CLEAR_BUTTON_SIZE}"
|
289
290
|
aria-label="${this.clearAriaLabel}"
|
290
291
|
@click=${this.clearInputText}
|
291
|
-
?disabled=${this.disabled || this.readonly || !
|
292
|
+
?disabled=${this.disabled || this.readonly || !showBtn}
|
292
293
|
></mdc-button>
|
293
294
|
`;
|
294
295
|
}
|
295
|
-
renderInputElement(type) {
|
296
|
+
renderInputElement(type, hidePlaceholder = false) {
|
296
297
|
var _a;
|
298
|
+
const placeholderText = hidePlaceholder ? '' : this.placeholder;
|
297
299
|
return html `<input
|
298
300
|
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
299
301
|
class='input'
|
@@ -307,7 +309,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
307
309
|
type="${type}"
|
308
310
|
aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : '')}"
|
309
311
|
aria-invalid="${this.helpTextType === 'error' ? 'true' : 'false'}"
|
310
|
-
placeholder=${ifDefined(
|
312
|
+
placeholder=${ifDefined(placeholderText)}
|
311
313
|
minlength=${ifDefined(this.minlength)}
|
312
314
|
maxlength=${ifDefined(this.maxlength)}
|
313
315
|
autocapitalize=${this.autocapitalize}
|
@@ -4,7 +4,7 @@ const styles = [css `
|
|
4
4
|
:host{
|
5
5
|
--mdc-input-disabled-border-color: var(--mds-color-theme-outline-primary-disabled);
|
6
6
|
--mdc-input-disabled-text-color: var(--mds-color-theme-text-primary-disabled);
|
7
|
-
--mdc-input-disabled-background-color: var(--mds-color-theme-background-
|
7
|
+
--mdc-input-disabled-background-color: var(--mds-color-theme-background-input-disabled);
|
8
8
|
--mdc-input-border-color: var(--mds-color-theme-outline-input-normal);
|
9
9
|
--mdc-input-text-color: var(--mds-color-theme-text-primary-normal);
|
10
10
|
--mdc-input-background-color: var(--mds-color-theme-background-primary-ghost);
|
@@ -12,7 +12,7 @@ const styles = [css `
|
|
12
12
|
--mdc-input-selection-text-color: var(--mds-color-theme-inverted-text-primary-normal);
|
13
13
|
--mdc-input-support-text-color: var(--mds-color-theme-text-secondary-normal);
|
14
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-
|
15
|
+
--mdc-input-focused-background-color: var(--mds-color-theme-background-primary-ghost);
|
16
16
|
--mdc-input-focused-border-color: var(--mds-color-theme-outline-input-active);
|
17
17
|
--mdc-input-error-border-color: var(--mds-color-theme-text-error-normal);
|
18
18
|
--mdc-input-warning-border-color: var(--mds-color-theme-text-warning-normal);
|
@@ -24,6 +24,10 @@ const styles = [css `
|
|
24
24
|
width: 100%;
|
25
25
|
}
|
26
26
|
|
27
|
+
input{
|
28
|
+
font-family: inherit;
|
29
|
+
}
|
30
|
+
|
27
31
|
:host([readonly]) .leading-icon {
|
28
32
|
color: var(--mdc-input-support-text-color);
|
29
33
|
}
|
@@ -34,19 +38,15 @@ const styles = [css `
|
|
34
38
|
color: var(--mdc-input-disabled-text-color);
|
35
39
|
}
|
36
40
|
|
37
|
-
:host([disabled]) .input,
|
38
|
-
:host([readonly]) .input{
|
39
|
-
border-color: var(--mdc-input-disabled-border-color);
|
40
|
-
background: var(--mdc-input-disabled-background-color);
|
41
|
-
}
|
42
|
-
|
43
41
|
:host([disabled]) .input-container,
|
42
|
+
:host([readonly]) .input-container,
|
44
43
|
:host([disabled][help-text-type="default"]) .input-container,
|
45
44
|
:host([disabled][help-text-type="success"]) .input-container,
|
46
45
|
:host([disabled][help-text-type="warning"]) .input-container,
|
47
46
|
:host([disabled][help-text-type="error"]) .input-container,
|
48
47
|
:host([disabled][help-text-type="priority"]) .input-container{
|
49
48
|
border-color: var(--mdc-input-disabled-border-color);
|
49
|
+
background: var(--mdc-input-disabled-background-color);
|
50
50
|
}
|
51
51
|
|
52
52
|
.leading-icon{
|
@@ -11,10 +11,11 @@ import { html, nothing } from 'lit';
|
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
13
|
import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
14
|
-
import { TAG_NAME as TOOLTIP_TAG_NAME } from '../tooltip/tooltip.constants';
|
15
14
|
import ListItem from '../listitem/listitem.component';
|
16
15
|
import { LISTITEM_VARIANTS } from '../listitem/listitem.constants';
|
16
|
+
import { TAG_NAME as SELECT_TAG_NAME } from '../select/select.constants';
|
17
17
|
import { TYPE } from '../text/text.constants';
|
18
|
+
import { TAG_NAME as TOOLTIP_TAG_NAME } from '../tooltip/tooltip.constants';
|
18
19
|
import { SELECTED_ICON_NAME, TOOLTIP_ID } from './option.constants';
|
19
20
|
import styles from './option.styles';
|
20
21
|
/**
|
@@ -98,7 +99,7 @@ class Option extends FormInternalsMixin(ListItem) {
|
|
98
99
|
tooltip.setAttribute('triggerid', this.id);
|
99
100
|
tooltip.setAttribute('visible', '');
|
100
101
|
// Add tooltip programmatically after the nearest select component or the parent element.
|
101
|
-
const parent = this.closest(
|
102
|
+
const parent = this.closest(SELECT_TAG_NAME) || this.parentElement;
|
102
103
|
parent === null || parent === void 0 ? void 0 : parent.after(tooltip);
|
103
104
|
}
|
104
105
|
/**
|
@@ -18,6 +18,17 @@ declare class Searchfield extends Input {
|
|
18
18
|
* @internal
|
19
19
|
*/
|
20
20
|
isInputFocused: boolean;
|
21
|
+
/**
|
22
|
+
* @internal
|
23
|
+
*/
|
24
|
+
hasInputChips: boolean;
|
25
|
+
/**
|
26
|
+
* Handles the keydown event of the search field.
|
27
|
+
* If the key pressed is 'Enter', it submits the form.
|
28
|
+
* If the key pressed is 'Escape', it clears the input text.
|
29
|
+
* @param event - Keyboard event
|
30
|
+
*/
|
31
|
+
handleKeyDown(event: KeyboardEvent): void;
|
21
32
|
connectedCallback(): void;
|
22
33
|
/**
|
23
34
|
* This method is used to render the input chips inside filters slot.
|
@@ -30,6 +41,7 @@ declare class Searchfield extends Input {
|
|
30
41
|
* @override
|
31
42
|
*/
|
32
43
|
firstUpdated(): void;
|
44
|
+
clearInputText(): void;
|
33
45
|
render(): import("lit-html").TemplateResult<1>;
|
34
46
|
static styles: Array<CSSResult>;
|
35
47
|
}
|
@@ -32,6 +32,22 @@ class Searchfield extends Input {
|
|
32
32
|
* @internal
|
33
33
|
*/
|
34
34
|
this.isInputFocused = false;
|
35
|
+
/**
|
36
|
+
* @internal
|
37
|
+
*/
|
38
|
+
this.hasInputChips = false;
|
39
|
+
}
|
40
|
+
/**
|
41
|
+
* Handles the keydown event of the search field.
|
42
|
+
* If the key pressed is 'Enter', it submits the form.
|
43
|
+
* If the key pressed is 'Escape', it clears the input text.
|
44
|
+
* @param event - Keyboard event
|
45
|
+
*/
|
46
|
+
handleKeyDown(event) {
|
47
|
+
super.handleKeyDown(event);
|
48
|
+
if (event.key === 'Escape') {
|
49
|
+
this.clearInputText();
|
50
|
+
}
|
35
51
|
}
|
36
52
|
connectedCallback() {
|
37
53
|
super.connectedCallback();
|
@@ -48,9 +64,11 @@ class Searchfield extends Input {
|
|
48
64
|
* It will remove any elements that are not input chips.
|
49
65
|
*/
|
50
66
|
renderInputChips() {
|
67
|
+
var _a;
|
68
|
+
this.hasInputChips = !!((_a = this.inputChips) === null || _a === void 0 ? void 0 : _a.length);
|
51
69
|
if (this.inputChips) {
|
52
70
|
this.inputChips.forEach((element) => {
|
53
|
-
if (!element.matches(
|
71
|
+
if (!element.matches(DEFAULTS.INPUT_CHIP_TAG)) {
|
54
72
|
element.remove();
|
55
73
|
}
|
56
74
|
});
|
@@ -69,6 +87,14 @@ class Searchfield extends Input {
|
|
69
87
|
this.isInputFocused = false;
|
70
88
|
};
|
71
89
|
}
|
90
|
+
clearInputText() {
|
91
|
+
var _a;
|
92
|
+
super.clearInputText();
|
93
|
+
(_a = this.inputChips) === null || _a === void 0 ? void 0 : _a.forEach((element) => {
|
94
|
+
// Dispatch the custom 'remove' event from inputChip
|
95
|
+
element.dispatchEvent(new CustomEvent('remove', { bubbles: true, composed: true }));
|
96
|
+
});
|
97
|
+
}
|
72
98
|
render() {
|
73
99
|
return html `
|
74
100
|
${this.renderLabelElement()}
|
@@ -77,15 +103,15 @@ class Searchfield extends Input {
|
|
77
103
|
'mdc-focus-ring': this.isInputFocused,
|
78
104
|
})}" part="input-container">
|
79
105
|
${this.renderLeadingIcon()}
|
80
|
-
<div part='scrollable-container'>
|
106
|
+
<div part='scrollable-container' tabindex='-1'>
|
81
107
|
<div part="filters-container"
|
82
108
|
@click=${() => this.inputElement.focus()}
|
83
109
|
@keydown=${(e) => e.key === 'Enter' ? this.inputElement.focus() : null}
|
84
110
|
@keyup=${(e) => e.key === ' ' ? this.inputElement.focus() : null}>
|
85
111
|
<slot name="filters" @slotchange=${this.renderInputChips}></slot></div>
|
86
|
-
${this.renderInputElement(DEFAULTS.TYPE)}
|
112
|
+
${this.renderInputElement(DEFAULTS.TYPE, this.hasInputChips)}
|
87
113
|
</div>
|
88
|
-
${this.renderTrailingButton()}
|
114
|
+
${this.renderTrailingButton(this.hasInputChips)}
|
89
115
|
</div>
|
90
116
|
`;
|
91
117
|
}
|
@@ -99,4 +125,8 @@ __decorate([
|
|
99
125
|
state(),
|
100
126
|
__metadata("design:type", Object)
|
101
127
|
], Searchfield.prototype, "isInputFocused", void 0);
|
128
|
+
__decorate([
|
129
|
+
state(),
|
130
|
+
__metadata("design:type", Object)
|
131
|
+
], Searchfield.prototype, "hasInputChips", void 0);
|
102
132
|
export default Searchfield;
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import utils from '../../utils/tag-name';
|
2
2
|
import { INPUT_TYPE } from '../input/input.constants';
|
3
|
+
import { TAG_NAME as INPUT_CHIP_TAG } from '../inputchip/inputchip.constants';
|
3
4
|
const TAG_NAME = utils.constructTagName('searchfield');
|
4
5
|
const DEFAULTS = {
|
5
6
|
TYPE: INPUT_TYPE.SEARCH,
|
6
7
|
ICON: 'search-bold',
|
7
8
|
CLOSE_BTN: true,
|
9
|
+
INPUT_CHIP_TAG,
|
8
10
|
};
|
9
11
|
export { TAG_NAME, DEFAULTS };
|
@@ -4,12 +4,12 @@ const styles = css `
|
|
4
4
|
:host::part(filters-container){
|
5
5
|
display: flex;
|
6
6
|
gap: 0.25rem;
|
7
|
-
margin: 0.25rem;
|
7
|
+
margin: 0.25rem 0;
|
8
8
|
}
|
9
9
|
|
10
10
|
.input {
|
11
11
|
white-space: nowrap;
|
12
|
-
min-width:
|
12
|
+
min-width: 90%;
|
13
13
|
}
|
14
14
|
|
15
15
|
.input::-webkit-search-cancel-button {
|
@@ -4,7 +4,7 @@ const styles = [css `
|
|
4
4
|
:host {
|
5
5
|
--mdc-textarea-disabled-border-color: var(--mds-color-theme-outline-primary-disabled);
|
6
6
|
--mdc-textarea-disabled-text-color: var(--mds-color-theme-text-primary-disabled);
|
7
|
-
--mdc-textarea-disabled-background-color: var(--mds-color-theme-background-
|
7
|
+
--mdc-textarea-disabled-background-color: var(--mds-color-theme-background-input-disabled);
|
8
8
|
--mdc-textarea-text-color: var(--mds-color-theme-text-primary-normal);
|
9
9
|
--mdc-textarea-background-color: var(--mds-color-theme-background-primary-ghost);
|
10
10
|
--mdc-textarea-border-color: var(--mds-color-theme-outline-input-normal);
|
@@ -14,7 +14,7 @@ const styles = [css `
|
|
14
14
|
--mdc-textarea-success-border-color: var(--mds-color-theme-text-success-normal);
|
15
15
|
--mdc-textarea-primary-border-color: var(--mds-color-theme-text-accent-normal);
|
16
16
|
--mdc-textarea-hover-background-color: var(--mds-color-theme-background-primary-hover);
|
17
|
-
--mdc-textarea-focused-background-color: var(--mds-color-theme-background-primary-
|
17
|
+
--mdc-textarea-focused-background-color: var(--mds-color-theme-background-primary-ghost);
|
18
18
|
--mdc-textarea-focused-border-color: var(--mds-color-theme-outline-input-active);
|
19
19
|
--mdc-textarea-text-font-size: var(--mds-font-size-body-midsize);
|
20
20
|
--mdc-textarea-text-line-height: var(--mds-font-lineheight-body-midsize);
|
@@ -25,8 +25,8 @@ const styles = [css `
|
|
25
25
|
color: var(--mdc-input-disabled-text-color);
|
26
26
|
}
|
27
27
|
|
28
|
-
:host([disabled])::part(textarea),
|
29
|
-
:host([readonly])::part(textarea){
|
28
|
+
:host([disabled])::part(textarea-container),
|
29
|
+
:host([readonly])::part(textarea-container){
|
30
30
|
border-color: var(--mdc-textarea-disabled-border-color);
|
31
31
|
background: var(--mdc-textarea-disabled-background-color);
|
32
32
|
}
|