@momentum-design/components 0.120.34 → 0.120.36
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 -175
- package/dist/browser/index.js.map +4 -4
- package/dist/components/checkbox/checkbox.component.d.ts +6 -1
- package/dist/components/checkbox/checkbox.component.js +10 -5
- package/dist/components/checkbox/checkbox.constants.d.ts +5 -1
- package/dist/components/checkbox/checkbox.constants.js +6 -1
- package/dist/components/checkbox/checkbox.styles.js +4 -0
- package/dist/components/checkbox/checkbox.types.d.ts +5 -3
- package/dist/components/input/input.component.d.ts +6 -0
- package/dist/components/input/input.component.js +12 -2
- package/dist/custom-elements.json +506 -428
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CSSResult, PropertyValueMap, PropertyValues } from 'lit';
|
|
2
2
|
import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
|
|
3
3
|
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
|
4
|
+
import type { CheckboxValidationType } from './checkbox.types';
|
|
4
5
|
declare const Checkbox_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
|
|
5
6
|
/**
|
|
6
7
|
* Checkboxes allow users to select multiple options from a list or turn an item/feature on or off.
|
|
@@ -74,7 +75,11 @@ declare class Checkbox extends Checkbox_base implements AssociatedFormControl {
|
|
|
74
75
|
* @default false
|
|
75
76
|
*/
|
|
76
77
|
autofocus: boolean;
|
|
77
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The type of help text/validation. It can be 'default' or 'error'.
|
|
80
|
+
* @default 'default'
|
|
81
|
+
*/
|
|
82
|
+
helpTextType: CheckboxValidationType;
|
|
78
83
|
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
79
84
|
/**
|
|
80
85
|
* Updates the form value to reflect the current state of the checkbox.
|
|
@@ -17,6 +17,7 @@ import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
|
|
|
17
17
|
import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
|
|
18
18
|
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
|
19
19
|
import styles from './checkbox.styles';
|
|
20
|
+
import { CHECKBOX_VALIDATION } from './checkbox.constants';
|
|
20
21
|
/**
|
|
21
22
|
* Checkboxes allow users to select multiple options from a list or turn an item/feature on or off.
|
|
22
23
|
* These are often used in forms, settings, and selections in lists.
|
|
@@ -91,17 +92,17 @@ class Checkbox extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMix
|
|
|
91
92
|
* @default false
|
|
92
93
|
*/
|
|
93
94
|
this.autofocus = false;
|
|
95
|
+
/**
|
|
96
|
+
* The type of help text/validation. It can be 'default' or 'error'.
|
|
97
|
+
* @default 'default'
|
|
98
|
+
*/
|
|
99
|
+
this.helpTextType = CHECKBOX_VALIDATION.DEFAULT;
|
|
94
100
|
this.renderLabelAndHelperText = () => {
|
|
95
101
|
if (!this.label)
|
|
96
102
|
return nothing;
|
|
97
103
|
return html `<div part="text-container">${this.renderLabel()} ${this.renderHelperText()}</div>`;
|
|
98
104
|
};
|
|
99
105
|
}
|
|
100
|
-
connectedCallback() {
|
|
101
|
-
super.connectedCallback();
|
|
102
|
-
// Checkbox does not contain helpTextType property.
|
|
103
|
-
this.helpTextType = undefined;
|
|
104
|
-
}
|
|
105
106
|
firstUpdated(_changedProperties) {
|
|
106
107
|
// set the element to auto focus if autoFocusOnMount is set to true
|
|
107
108
|
// before running the super method, so that the AutoFocusOnMountMixin can use it
|
|
@@ -247,4 +248,8 @@ __decorate([
|
|
|
247
248
|
property({ type: Boolean, reflect: true }),
|
|
248
249
|
__metadata("design:type", Object)
|
|
249
250
|
], Checkbox.prototype, "autofocus", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
property({ type: String, reflect: true, attribute: 'help-text-type' }),
|
|
253
|
+
__metadata("design:type", String)
|
|
254
|
+
], Checkbox.prototype, "helpTextType", void 0);
|
|
250
255
|
export default Checkbox;
|
|
@@ -4,4 +4,8 @@ declare const ICON_NAME: {
|
|
|
4
4
|
readonly CHECKED: Extract<IconNames, "check-bold">;
|
|
5
5
|
readonly INDETERMINATE: Extract<IconNames, "minus-bold">;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
declare const CHECKBOX_VALIDATION: {
|
|
8
|
+
readonly ERROR: "error";
|
|
9
|
+
readonly DEFAULT: "default";
|
|
10
|
+
};
|
|
11
|
+
export { TAG_NAME, ICON_NAME, CHECKBOX_VALIDATION };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import utils from '../../utils/tag-name';
|
|
2
|
+
import { VALIDATION } from '../formfieldwrapper/formfieldwrapper.constants';
|
|
2
3
|
const TAG_NAME = utils.constructTagName('checkbox');
|
|
3
4
|
const ICON_NAME = {
|
|
4
5
|
CHECKED: 'check-bold',
|
|
5
6
|
INDETERMINATE: 'minus-bold',
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
+
const CHECKBOX_VALIDATION = {
|
|
9
|
+
ERROR: VALIDATION.ERROR,
|
|
10
|
+
DEFAULT: VALIDATION.DEFAULT,
|
|
11
|
+
};
|
|
12
|
+
export { TAG_NAME, ICON_NAME, CHECKBOX_VALIDATION };
|
|
@@ -62,6 +62,10 @@ const styles = [
|
|
|
62
62
|
--mdc-checkbox-background-color: var(--mds-color-theme-control-active-pressed);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
:host([help-text-type='error'])::part(static-checkbox) {
|
|
66
|
+
--mdc-checkbox-border-color: var(--mds-color-theme-outline-cancel-normal);
|
|
67
|
+
}
|
|
68
|
+
|
|
65
69
|
:host([readonly]),
|
|
66
70
|
:host([disabled]),
|
|
67
71
|
:host([soft-disabled]) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { OverrideEventTarget, TypedCustomEvent } from
|
|
2
|
-
import type Checkbox from
|
|
1
|
+
import type { OverrideEventTarget, TypedCustomEvent, ValueOf } from '../../utils/types';
|
|
2
|
+
import type Checkbox from './checkbox.component';
|
|
3
|
+
import { CHECKBOX_VALIDATION } from './checkbox.constants';
|
|
4
|
+
type CheckboxValidationType = ValueOf<typeof CHECKBOX_VALIDATION>;
|
|
3
5
|
interface Events {
|
|
4
6
|
onChangeEvent: TypedCustomEvent<Checkbox>;
|
|
5
7
|
onFocusEvent: OverrideEventTarget<FocusEvent, Checkbox>;
|
|
6
8
|
}
|
|
7
|
-
export type { Events };
|
|
9
|
+
export type { Events, CheckboxValidationType };
|
|
@@ -132,6 +132,12 @@ declare class Input extends Input_base implements AssociatedFormControl {
|
|
|
132
132
|
* @default ''
|
|
133
133
|
*/
|
|
134
134
|
clearAriaLabel: string;
|
|
135
|
+
/**
|
|
136
|
+
* Defines a id pointing to the element which describes the input element.
|
|
137
|
+
* The AriaDescribedby attribute to be set for accessibility.
|
|
138
|
+
* @default null
|
|
139
|
+
*/
|
|
140
|
+
dataAriaDescribedby: string | null;
|
|
135
141
|
connectedCallback(): void;
|
|
136
142
|
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
137
143
|
/** @internal */
|
|
@@ -111,6 +111,12 @@ class Input extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(
|
|
|
111
111
|
* @default ''
|
|
112
112
|
*/
|
|
113
113
|
this.clearAriaLabel = '';
|
|
114
|
+
/**
|
|
115
|
+
* Defines a id pointing to the element which describes the input element.
|
|
116
|
+
* The AriaDescribedby attribute to be set for accessibility.
|
|
117
|
+
* @default null
|
|
118
|
+
*/
|
|
119
|
+
this.dataAriaDescribedby = null;
|
|
114
120
|
}
|
|
115
121
|
connectedCallback() {
|
|
116
122
|
super.connectedCallback();
|
|
@@ -300,7 +306,7 @@ class Input extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(
|
|
|
300
306
|
`;
|
|
301
307
|
}
|
|
302
308
|
renderInputElement(type, hidePlaceholder = false) {
|
|
303
|
-
var _a;
|
|
309
|
+
var _a, _b;
|
|
304
310
|
const placeholderText = hidePlaceholder ? '' : this.placeholder;
|
|
305
311
|
return html `<input
|
|
306
312
|
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
|
@@ -312,7 +318,7 @@ class Input extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(
|
|
|
312
318
|
?readonly="${this.readonly}"
|
|
313
319
|
?required="${this.required}"
|
|
314
320
|
type="${type}"
|
|
315
|
-
aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : '')}"
|
|
321
|
+
aria-describedby="${ifDefined(this.helpText ? FORMFIELD_DEFAULTS.HELPER_TEXT_ID : ((_b = this.dataAriaDescribedby) !== null && _b !== void 0 ? _b : ''))}"
|
|
316
322
|
aria-invalid="${this.helpTextType === 'error' ? 'true' : 'false'}"
|
|
317
323
|
placeholder=${ifDefined(placeholderText)}
|
|
318
324
|
minlength=${ifDefined(this.minlength)}
|
|
@@ -396,4 +402,8 @@ __decorate([
|
|
|
396
402
|
property({ type: String, attribute: 'clear-aria-label' }),
|
|
397
403
|
__metadata("design:type", Object)
|
|
398
404
|
], Input.prototype, "clearAriaLabel", void 0);
|
|
405
|
+
__decorate([
|
|
406
|
+
property({ type: String, reflect: true, attribute: 'data-aria-describedby' }),
|
|
407
|
+
__metadata("design:type", Object)
|
|
408
|
+
], Input.prototype, "dataAriaDescribedby", void 0);
|
|
399
409
|
export default Input;
|