@momentum-design/components 0.18.1 → 0.18.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/components/formfieldwrapper/formfieldwrapper.component.d.ts +2 -2
- package/dist/components/formfieldwrapper/formfieldwrapper.component.js +7 -13
- package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +6 -2
- package/dist/components/formfieldwrapper/formfieldwrapper.subcomponent.d.ts +1 -0
- package/dist/components/formfieldwrapper/formfieldwrapper.subcomponent.js +15 -0
- package/dist/custom-elements.json +34 -0
- package/package.json +1 -1
@@ -1,6 +1,7 @@
|
|
1
1
|
import { CSSResult, nothing } from 'lit';
|
2
2
|
import { Component } from '../../models';
|
3
3
|
import type { ValidationType } from './formfieldwrapper.types';
|
4
|
+
declare const FormfieldWrapper_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DisabledMixin").DisabledMixinInterface> & typeof Component;
|
4
5
|
/**
|
5
6
|
* formfieldwrapper is a component that contains the label and helper/validation text
|
6
7
|
* that can be configured in various ways to suit different use cases (most of the input related components).
|
@@ -11,7 +12,7 @@ import type { ValidationType } from './formfieldwrapper.types';
|
|
11
12
|
* @slot label-info - slot to add the label info icon
|
12
13
|
*
|
13
14
|
*/
|
14
|
-
declare class FormfieldWrapper extends
|
15
|
+
declare class FormfieldWrapper extends FormfieldWrapper_base {
|
15
16
|
/**
|
16
17
|
* The label of the input field. It is linked to the input field using the `for` attribute.
|
17
18
|
*/
|
@@ -57,7 +58,6 @@ declare class FormfieldWrapper extends Component {
|
|
57
58
|
* @returns void
|
58
59
|
*/
|
59
60
|
protected renderHelperText(): import("lit-html").TemplateResult<1>;
|
60
|
-
render(): import("lit-html").TemplateResult<1>;
|
61
61
|
static styles: Array<CSSResult>;
|
62
62
|
}
|
63
63
|
export default FormfieldWrapper;
|
@@ -14,6 +14,7 @@ import styles from './formfieldwrapper.styles';
|
|
14
14
|
import { Component } from '../../models';
|
15
15
|
import { DEFAULTS, MDC_TEXT_OPTIONS } from './formfieldwrapper.constants';
|
16
16
|
import { getHelperIcon } from './formfieldwrapper.utils';
|
17
|
+
import { DisabledMixin } from '../../utils/mixins/DisabledMixin';
|
17
18
|
/**
|
18
19
|
* formfieldwrapper is a component that contains the label and helper/validation text
|
19
20
|
* that can be configured in various ways to suit different use cases (most of the input related components).
|
@@ -24,7 +25,7 @@ import { getHelperIcon } from './formfieldwrapper.utils';
|
|
24
25
|
* @slot label-info - slot to add the label info icon
|
25
26
|
*
|
26
27
|
*/
|
27
|
-
class FormfieldWrapper extends Component {
|
28
|
+
class FormfieldWrapper extends DisabledMixin(Component) {
|
28
29
|
constructor() {
|
29
30
|
super(...arguments);
|
30
31
|
/**
|
@@ -46,7 +47,7 @@ class FormfieldWrapper extends Component {
|
|
46
47
|
if (!this.label) {
|
47
48
|
return nothing;
|
48
49
|
}
|
49
|
-
return html `<label for="${this.id}" class="mdc-label" part="
|
50
|
+
return html `<label for="${this.id}" class="mdc-label" part="label">${this.label}</label>`;
|
50
51
|
}
|
51
52
|
/**
|
52
53
|
* creates the helpertext icon based on the helpTextType for validation.
|
@@ -58,8 +59,8 @@ class FormfieldWrapper extends Component {
|
|
58
59
|
return nothing;
|
59
60
|
}
|
60
61
|
const helperIcon = getHelperIcon(this.helpTextType || DEFAULTS.VALIDATION);
|
61
|
-
if (helperIcon) {
|
62
|
-
return html `<mdc-icon part="
|
62
|
+
if (helperIcon && !this.disabled) {
|
63
|
+
return html `<mdc-icon part="helper-icon" size="1" length-unit="rem" name=${helperIcon}></mdc-icon>`;
|
63
64
|
}
|
64
65
|
return nothing;
|
65
66
|
}
|
@@ -74,7 +75,7 @@ class FormfieldWrapper extends Component {
|
|
74
75
|
}
|
75
76
|
return html `
|
76
77
|
<mdc-text
|
77
|
-
part="
|
78
|
+
part="help-text"
|
78
79
|
tagname=${MDC_TEXT_OPTIONS.TAGNAME}
|
79
80
|
type=${MDC_TEXT_OPTIONS.TYPE}
|
80
81
|
>
|
@@ -87,7 +88,7 @@ class FormfieldWrapper extends Component {
|
|
87
88
|
* @returns void
|
88
89
|
*/
|
89
90
|
renderLabel() {
|
90
|
-
return html `<div class="mdc-label-text" part="
|
91
|
+
return html `<div class="mdc-label-text" part="label-text">
|
91
92
|
<slot name="label">${this.renderLabelElement()}</slot>
|
92
93
|
<slot name="label-info"></slot>
|
93
94
|
</div>`;
|
@@ -102,13 +103,6 @@ class FormfieldWrapper extends Component {
|
|
102
103
|
<slot name="help-text">${this.renderHelpText()}</slot>
|
103
104
|
</div>`;
|
104
105
|
}
|
105
|
-
render() {
|
106
|
-
return html `
|
107
|
-
${this.renderLabel()}
|
108
|
-
<slot></slot>
|
109
|
-
${this.renderHelperText()}
|
110
|
-
`;
|
111
|
-
}
|
112
106
|
}
|
113
107
|
FormfieldWrapper.styles = [...Component.styles, ...styles];
|
114
108
|
__decorate([
|
@@ -8,9 +8,13 @@ const styles = [
|
|
8
8
|
align-items: flex-start;
|
9
9
|
gap: 0.5rem;
|
10
10
|
}
|
11
|
-
|
11
|
+
:host([disabled]),
|
12
12
|
:host([disabled]) .mdc-label,
|
13
|
-
:host([disabled]) .mdc-help-text
|
13
|
+
:host([disabled]) .mdc-help-text,
|
14
|
+
:host([disabled][help-text-type='error']) .mdc-help-text,
|
15
|
+
:host([disabled][help-text-type='success']) .mdc-help-text,
|
16
|
+
:host([disabled][help-text-type='warning']) .mdc-help-text,
|
17
|
+
:host([disabled][help-text-type='priority']) .mdc-help-text {
|
14
18
|
color: var(--mds-color-theme-text-primary-disabled);
|
15
19
|
}
|
16
20
|
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { html } from 'lit';
|
2
|
+
import FormfieldWrapper from './formfieldwrapper.component';
|
3
|
+
// Subcomponent to be rendered in E2E Tests, to showcase that the
|
4
|
+
// theme can be consumed as a subcomponent
|
5
|
+
// (this file is imported in the esbuild config for e2e tests ('/config/esbuild/esbuild-e2e.config.js'))
|
6
|
+
class SubComponentFormFieldWrapper extends FormfieldWrapper {
|
7
|
+
render() {
|
8
|
+
return html `
|
9
|
+
${this.renderLabel()}
|
10
|
+
<slot></slot>
|
11
|
+
${this.renderHelperText()}
|
12
|
+
`;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
SubComponentFormFieldWrapper.register('mdc-subcomponent-formfieldwrapper');
|
@@ -2265,6 +2265,21 @@
|
|
2265
2265
|
"text": ""
|
2266
2266
|
}
|
2267
2267
|
}
|
2268
|
+
},
|
2269
|
+
{
|
2270
|
+
"kind": "field",
|
2271
|
+
"name": "disabled",
|
2272
|
+
"type": {
|
2273
|
+
"text": "boolean"
|
2274
|
+
},
|
2275
|
+
"default": "false",
|
2276
|
+
"description": "Indicates whether the component is disabled.\nWhen the component is disabled for user interaction; it is not focusable or clickable.",
|
2277
|
+
"attribute": "disabled",
|
2278
|
+
"reflects": true,
|
2279
|
+
"inheritedFrom": {
|
2280
|
+
"name": "DisabledMixin",
|
2281
|
+
"module": "utils/mixins/DisabledMixin.js"
|
2282
|
+
}
|
2268
2283
|
}
|
2269
2284
|
],
|
2270
2285
|
"attributes": [
|
@@ -2297,6 +2312,25 @@
|
|
2297
2312
|
},
|
2298
2313
|
"description": "The help text that is displayed below the input field.",
|
2299
2314
|
"fieldName": "helpText"
|
2315
|
+
},
|
2316
|
+
{
|
2317
|
+
"name": "disabled",
|
2318
|
+
"type": {
|
2319
|
+
"text": "boolean"
|
2320
|
+
},
|
2321
|
+
"default": "false",
|
2322
|
+
"description": "Indicates whether the component is disabled.\nWhen the component is disabled for user interaction; it is not focusable or clickable.",
|
2323
|
+
"fieldName": "disabled",
|
2324
|
+
"inheritedFrom": {
|
2325
|
+
"name": "DisabledMixin",
|
2326
|
+
"module": "src/utils/mixins/DisabledMixin.ts"
|
2327
|
+
}
|
2328
|
+
}
|
2329
|
+
],
|
2330
|
+
"mixins": [
|
2331
|
+
{
|
2332
|
+
"name": "DisabledMixin",
|
2333
|
+
"module": "/src/utils/mixins/DisabledMixin"
|
2300
2334
|
}
|
2301
2335
|
],
|
2302
2336
|
"superclass": {
|
package/package.json
CHANGED