@momentum-design/components 0.53.1 → 0.53.3
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 +179 -145
- package/dist/browser/index.js.map +3 -3
- package/dist/components/button/button.component.d.ts +0 -2
- package/dist/components/button/button.component.js +1 -10
- package/dist/components/button/button.styles.js +27 -0
- package/dist/components/button/button.utils.d.ts +1 -9
- package/dist/components/button/button.utils.js +1 -16
- 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 +5 -1
- 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 +1 -1
- package/dist/custom-elements.json +250 -230
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
@@ -12,7 +12,7 @@ import { property, state } from 'lit/decorators.js';
|
|
12
12
|
import Buttonsimple from '../buttonsimple/buttonsimple.component';
|
13
13
|
import { BUTTON_COLORS, BUTTON_TYPE_INTERNAL, BUTTON_VARIANTS, DEFAULTS, ICON_BUTTON_SIZES, PILL_BUTTON_SIZES, } from './button.constants';
|
14
14
|
import styles from './button.styles';
|
15
|
-
import { getIconNameWithoutStyle
|
15
|
+
import { getIconNameWithoutStyle } from './button.utils';
|
16
16
|
/**
|
17
17
|
* `mdc-button` is a component that can be configured in various ways to suit different use cases.
|
18
18
|
*
|
@@ -79,8 +79,6 @@ class Button extends Buttonsimple {
|
|
79
79
|
this.role = 'button';
|
80
80
|
/** @internal */
|
81
81
|
this.typeInternal = DEFAULTS.TYPE_INTERNAL;
|
82
|
-
/** @internal */
|
83
|
-
this.iconSize = 1;
|
84
82
|
}
|
85
83
|
update(changedProperties) {
|
86
84
|
super.update(changedProperties);
|
@@ -156,7 +154,6 @@ class Button extends Buttonsimple {
|
|
156
154
|
&& !(size === ICON_BUTTON_SIZES[20] && this.variant !== BUTTON_VARIANTS.TERTIARY)
|
157
155
|
: Object.values(PILL_BUTTON_SIZES).includes(size);
|
158
156
|
this.setAttribute('size', isValidSize ? `${size}` : `${DEFAULTS.SIZE}`);
|
159
|
-
this.iconSize = getIconSize(size);
|
160
157
|
}
|
161
158
|
/**
|
162
159
|
* Sets the color attribute for the button.
|
@@ -198,7 +195,6 @@ class Button extends Buttonsimple {
|
|
198
195
|
? html ` <mdc-icon
|
199
196
|
name="${this.prefixIcon}"
|
200
197
|
part="prefix-icon"
|
201
|
-
size=${this.iconSize}
|
202
198
|
length-unit="rem"
|
203
199
|
>
|
204
200
|
</mdc-icon>`
|
@@ -208,7 +204,6 @@ class Button extends Buttonsimple {
|
|
208
204
|
? html ` <mdc-icon
|
209
205
|
name="${this.postfixIcon}"
|
210
206
|
part="postfix-icon"
|
211
|
-
size=${this.iconSize}
|
212
207
|
length-unit="rem"
|
213
208
|
>
|
214
209
|
</mdc-icon>`
|
@@ -245,8 +240,4 @@ __decorate([
|
|
245
240
|
state(),
|
246
241
|
__metadata("design:type", String)
|
247
242
|
], Button.prototype, "typeInternal", void 0);
|
248
|
-
__decorate([
|
249
|
-
state(),
|
250
|
-
__metadata("design:type", Object)
|
251
|
-
], Button.prototype, "iconSize", void 0);
|
252
243
|
export default Button;
|
@@ -31,6 +31,33 @@ const styles = css `
|
|
31
31
|
--mdc-button-line-height-size-32: var(--mds-font-lineheight-body-large);
|
32
32
|
--mdc-button-line-height-size-28: var(--mds-font-lineheight-body-midsize);
|
33
33
|
--mdc-button-line-height-size-24: var(--mds-font-lineheight-body-small);
|
34
|
+
|
35
|
+
--mdc-button-prefix-icon-size: 1rem;
|
36
|
+
--mdc-button-postfix-icon-size: 1rem;
|
37
|
+
}
|
38
|
+
|
39
|
+
:host([size="64"]) {
|
40
|
+
--mdc-button-prefix-icon-size: 2rem;
|
41
|
+
--mdc-button-postfix-icon-size: 2rem;
|
42
|
+
}
|
43
|
+
|
44
|
+
:host([size="52"]) {
|
45
|
+
--mdc-button-prefix-icon-size: 1.75rem;
|
46
|
+
--mdc-button-postfix-icon-size: 1.75rem;
|
47
|
+
}
|
48
|
+
|
49
|
+
:host([size="40"]) {
|
50
|
+
--mdc-button-prefix-icon-size: 1.25rem;
|
51
|
+
--mdc-button-postfix-icon-size: 1.25rem;
|
52
|
+
}
|
53
|
+
|
54
|
+
/* Apply icon size for prefix and postfix icons */
|
55
|
+
:host::part(prefix-icon) {
|
56
|
+
--mdc-icon-size: var(--mdc-button-prefix-icon-size);
|
57
|
+
}
|
58
|
+
|
59
|
+
:host::part(postfix-icon) {
|
60
|
+
--mdc-icon-size: var(--mdc-button-postfix-icon-size);
|
34
61
|
}
|
35
62
|
|
36
63
|
:host([active]){
|
@@ -1,11 +1,3 @@
|
|
1
|
-
import { IconButtonSize } from './button.types';
|
2
|
-
/**
|
3
|
-
* Returns the icon size multiplier based on the provided button size.
|
4
|
-
*
|
5
|
-
* @param size - The size of the button.
|
6
|
-
* @returns The multiplier for the icon size.
|
7
|
-
*/
|
8
|
-
declare const getIconSize: (size: IconButtonSize) => number;
|
9
1
|
/**
|
10
2
|
* Returns the name of the icon without the style suffix.
|
11
3
|
*
|
@@ -13,4 +5,4 @@ declare const getIconSize: (size: IconButtonSize) => number;
|
|
13
5
|
* @returns The name of the icon without the suffix.
|
14
6
|
*/
|
15
7
|
declare const getIconNameWithoutStyle: (iconName: string) => string;
|
16
|
-
export {
|
8
|
+
export { getIconNameWithoutStyle };
|
@@ -1,18 +1,3 @@
|
|
1
|
-
import { ICON_BUTTON_SIZES } from './button.constants';
|
2
|
-
/**
|
3
|
-
* Returns the icon size multiplier based on the provided button size.
|
4
|
-
*
|
5
|
-
* @param size - The size of the button.
|
6
|
-
* @returns The multiplier for the icon size.
|
7
|
-
*/
|
8
|
-
const getIconSize = (size) => {
|
9
|
-
switch (size) {
|
10
|
-
case ICON_BUTTON_SIZES[64]: return 2;
|
11
|
-
case ICON_BUTTON_SIZES[52]: return 1.75;
|
12
|
-
case ICON_BUTTON_SIZES[40]: return 1.25;
|
13
|
-
default: return 1;
|
14
|
-
}
|
15
|
-
};
|
16
1
|
/**
|
17
2
|
* Returns the name of the icon without the style suffix.
|
18
3
|
*
|
@@ -24,4 +9,4 @@ const getIconNameWithoutStyle = (iconName) => {
|
|
24
9
|
const variants = ['bold', 'filled', 'regular', 'light'];
|
25
10
|
return iconParts.filter((part) => !variants.includes(part)).join('-');
|
26
11
|
};
|
27
|
-
export {
|
12
|
+
export { getIconNameWithoutStyle };
|
@@ -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}
|
@@ -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:
|
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
|
}
|
@@ -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 {
|
@@ -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:
|
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);
|