@momentum-design/components 0.23.0 → 0.23.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 +60 -46
- package/dist/browser/index.js.map +3 -3
- package/dist/components/formfieldwrapper/formfieldwrapper.component.d.ts +7 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.component.js +19 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +4 -0
- package/dist/components/input/input.component.d.ts +0 -5
- package/dist/components/input/input.component.js +1 -10
- package/dist/components/input/input.styles.js +1 -0
- package/dist/custom-elements.json +1199 -1055
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +3 -3
- package/package.json +1 -1
@@ -17,6 +17,12 @@ declare class FormfieldWrapper extends FormfieldWrapper_base {
|
|
17
17
|
* The label of the input field. It is linked to the input field using the `for` attribute.
|
18
18
|
*/
|
19
19
|
label?: string;
|
20
|
+
/**
|
21
|
+
* The required label of the input field.
|
22
|
+
* When an appropriate string value is set,
|
23
|
+
* the input field is marked as required and the label is appended with this text.
|
24
|
+
*/
|
25
|
+
requiredLabel?: string;
|
20
26
|
/**
|
21
27
|
* The unique id of the input field. It is used to link the input field with the label.
|
22
28
|
* @default `mdc-input-${uuidv4()}`
|
@@ -36,6 +42,7 @@ declare class FormfieldWrapper extends FormfieldWrapper_base {
|
|
36
42
|
* @returns void
|
37
43
|
*/
|
38
44
|
protected renderLabelElement(): import("lit-html").TemplateResult<1> | typeof nothing;
|
45
|
+
protected renderRequiredLabel(): import("lit-html").TemplateResult<1> | typeof nothing;
|
39
46
|
/**
|
40
47
|
* creates the helpertext icon based on the helpTextType for validation.
|
41
48
|
* If the helpTextType is not set, it defaults to 'default' and it doesn't display any icon.
|
@@ -49,6 +49,20 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
49
49
|
}
|
50
50
|
return html `<label for="${this.id}" class="mdc-label" part="label">${this.label}</label>`;
|
51
51
|
}
|
52
|
+
renderRequiredLabel() {
|
53
|
+
if (!this.requiredLabel) {
|
54
|
+
return nothing;
|
55
|
+
}
|
56
|
+
return html `
|
57
|
+
<mdc-text
|
58
|
+
part="required-label"
|
59
|
+
tagname=${MDC_TEXT_OPTIONS.TAGNAME}
|
60
|
+
type=${MDC_TEXT_OPTIONS.TYPE}
|
61
|
+
>
|
62
|
+
(${this.requiredLabel})
|
63
|
+
</mdc-text>
|
64
|
+
`;
|
65
|
+
}
|
52
66
|
/**
|
53
67
|
* creates the helpertext icon based on the helpTextType for validation.
|
54
68
|
* If the helpTextType is not set, it defaults to 'default' and it doesn't display any icon.
|
@@ -90,6 +104,7 @@ class FormfieldWrapper extends DisabledMixin(Component) {
|
|
90
104
|
renderLabel() {
|
91
105
|
return html `<div class="mdc-label-text" part="label-text">
|
92
106
|
<slot name="label">${this.renderLabelElement()}</slot>
|
107
|
+
<slot name="required-label">${this.renderRequiredLabel()}</slot>
|
93
108
|
<slot name="label-info"></slot>
|
94
109
|
</div>`;
|
95
110
|
}
|
@@ -109,6 +124,10 @@ __decorate([
|
|
109
124
|
property({ reflect: true, type: String }),
|
110
125
|
__metadata("design:type", String)
|
111
126
|
], FormfieldWrapper.prototype, "label", void 0);
|
127
|
+
__decorate([
|
128
|
+
property({ type: String, reflect: true, attribute: 'required-label' }),
|
129
|
+
__metadata("design:type", String)
|
130
|
+
], FormfieldWrapper.prototype, "requiredLabel", void 0);
|
112
131
|
__decorate([
|
113
132
|
property({ type: String }),
|
114
133
|
__metadata("design:type", Object)
|
@@ -25,10 +25,14 @@ const styles = [
|
|
25
25
|
display: flex;
|
26
26
|
align-items: center;
|
27
27
|
gap: 0.5rem;
|
28
|
+
width: 100%;
|
28
29
|
}
|
29
30
|
|
30
31
|
.mdc-label {
|
31
32
|
color: var(--mds-color-theme-text-primary-normal);
|
33
|
+
overflow: hidden;
|
34
|
+
text-overflow: ellipsis;
|
35
|
+
white-space: nowrap;
|
32
36
|
}
|
33
37
|
|
34
38
|
.mdc-help-text {
|
@@ -44,11 +44,6 @@ declare class Input extends Input_base {
|
|
44
44
|
* The placeholder text that is displayed when the input field is empty.
|
45
45
|
*/
|
46
46
|
placeholder: string;
|
47
|
-
/**
|
48
|
-
* required attribute of the input field.
|
49
|
-
* If true, the consumer should indicate it on the label that the input field is required.
|
50
|
-
*/
|
51
|
-
required: boolean;
|
52
47
|
/**
|
53
48
|
* readonly attribute of the input field. If true, the input field is read-only.
|
54
49
|
*/
|
@@ -71,11 +71,6 @@ class Input extends DataAriaLabelMixin(ValueMixin(NameMixin(FormfieldWrapper)))
|
|
71
71
|
* The placeholder text that is displayed when the input field is empty.
|
72
72
|
*/
|
73
73
|
this.placeholder = '';
|
74
|
-
/**
|
75
|
-
* required attribute of the input field.
|
76
|
-
* If true, the consumer should indicate it on the label that the input field is required.
|
77
|
-
*/
|
78
|
-
this.required = false;
|
79
74
|
/**
|
80
75
|
* readonly attribute of the input field. If true, the input field is read-only.
|
81
76
|
*/
|
@@ -316,7 +311,7 @@ class Input extends DataAriaLabelMixin(ValueMixin(NameMixin(FormfieldWrapper)))
|
|
316
311
|
.value="${this.value}"
|
317
312
|
?disabled="${this.disabled}"
|
318
313
|
?readonly="${this.readonly}"
|
319
|
-
?required="${this.
|
314
|
+
?required="${!!this.requiredLabel}"
|
320
315
|
type="text"
|
321
316
|
placeholder=${ifDefined(this.placeholder)}
|
322
317
|
minlength=${ifDefined(this.minlength)}
|
@@ -347,10 +342,6 @@ __decorate([
|
|
347
342
|
property({ type: String }),
|
348
343
|
__metadata("design:type", Object)
|
349
344
|
], Input.prototype, "placeholder", void 0);
|
350
|
-
__decorate([
|
351
|
-
property({ type: Boolean }),
|
352
|
-
__metadata("design:type", Object)
|
353
|
-
], Input.prototype, "required", void 0);
|
354
345
|
__decorate([
|
355
346
|
property({ type: Boolean }),
|
356
347
|
__metadata("design:type", Object)
|