@momentum-design/components 0.86.0 → 0.87.1
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 +229 -211
- package/dist/browser/index.js.map +4 -4
- package/dist/components/input/input.component.d.ts +2 -9
- package/dist/components/input/input.component.js +14 -36
- package/dist/components/input/input.constants.d.ts +1 -0
- package/dist/components/input/input.constants.js +1 -0
- package/dist/components/password/index.d.ts +11 -0
- package/dist/components/password/index.js +8 -0
- package/dist/components/password/password.component.d.ts +75 -0
- package/dist/components/password/password.component.js +128 -0
- package/dist/components/password/password.constants.d.ts +5 -0
- package/dist/components/password/password.constants.js +6 -0
- package/dist/components/password/password.types.d.ts +7 -0
- package/dist/components/password/password.types.js +1 -0
- package/dist/components/select/select.component.d.ts +4 -1
- package/dist/components/select/select.component.js +15 -7
- package/dist/components/select/select.types.d.ts +1 -0
- package/dist/custom-elements.json +1906 -629
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/react/index.d.ts +3 -2
- package/dist/react/index.js +3 -2
- package/dist/react/password/index.d.ts +50 -0
- package/dist/react/password/index.js +58 -0
- package/dist/react/select/index.d.ts +4 -0
- package/dist/react/select/index.js +4 -0
- package/package.json +1 -1
@@ -1,4 +1,4 @@
|
|
1
|
-
import { CSSResult, nothing
|
1
|
+
import { CSSResult, nothing } from 'lit';
|
2
2
|
import FormfieldWrapper from '../formfieldwrapper';
|
3
3
|
import type { IconNames } from '../icon/icon.types';
|
4
4
|
import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
|
@@ -123,14 +123,6 @@ declare class Input extends Input_base implements AssociatedFormControl {
|
|
123
123
|
formResetCallback(): void;
|
124
124
|
/** @internal */
|
125
125
|
formStateRestoreCallback(state: string): void;
|
126
|
-
/**
|
127
|
-
* Handles the value change of the input field.
|
128
|
-
* Sets the form value and updates the validity of the input field.
|
129
|
-
* @returns void
|
130
|
-
*/
|
131
|
-
handleValueChange(): void;
|
132
|
-
protected updated(changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
133
|
-
private setInputValidity;
|
134
126
|
/**
|
135
127
|
* This function is called when the attribute changes.
|
136
128
|
* It updates the validity of the input field based on the input field's validity.
|
@@ -140,6 +132,7 @@ declare class Input extends Input_base implements AssociatedFormControl {
|
|
140
132
|
* @param value - new value
|
141
133
|
*/
|
142
134
|
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
135
|
+
private setInputValidity;
|
143
136
|
/**
|
144
137
|
* Updates the value of the input field.
|
145
138
|
* Sets the form value.
|
@@ -10,6 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
10
10
|
import { html, nothing } from 'lit';
|
11
11
|
import { property } from 'lit/decorators.js';
|
12
12
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
13
|
+
import { live } from 'lit/directives/live.js';
|
13
14
|
import FormfieldWrapper from '../formfieldwrapper';
|
14
15
|
import { DEFAULTS as FORMFIELD_DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
15
16
|
import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
|
@@ -100,7 +101,6 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
100
101
|
this.updateComplete
|
101
102
|
.then(() => {
|
102
103
|
if (this.inputElement) {
|
103
|
-
this.inputElement.checkValidity();
|
104
104
|
this.setInputValidity();
|
105
105
|
this.internals.setFormValue(this.inputElement.value);
|
106
106
|
}
|
@@ -114,43 +114,14 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
114
114
|
/** @internal */
|
115
115
|
formResetCallback() {
|
116
116
|
this.value = '';
|
117
|
+
this.inputElement.value = '';
|
118
|
+
this.setInputValidity();
|
117
119
|
this.requestUpdate();
|
118
120
|
}
|
119
121
|
/** @internal */
|
120
122
|
formStateRestoreCallback(state) {
|
121
123
|
this.value = state;
|
122
124
|
}
|
123
|
-
/**
|
124
|
-
* Handles the value change of the input field.
|
125
|
-
* Sets the form value and updates the validity of the input field.
|
126
|
-
* @returns void
|
127
|
-
*/
|
128
|
-
handleValueChange() {
|
129
|
-
this.updateComplete
|
130
|
-
.then(() => {
|
131
|
-
this.setInputValidity();
|
132
|
-
})
|
133
|
-
.catch(error => {
|
134
|
-
if (this.onerror) {
|
135
|
-
this.onerror(error);
|
136
|
-
}
|
137
|
-
});
|
138
|
-
}
|
139
|
-
updated(changedProperties) {
|
140
|
-
super.updated(changedProperties);
|
141
|
-
if (changedProperties.has('value')) {
|
142
|
-
this.handleValueChange();
|
143
|
-
}
|
144
|
-
}
|
145
|
-
setInputValidity() {
|
146
|
-
if (this.required && this.validationMessage && this.value === '') {
|
147
|
-
this.inputElement.setCustomValidity(this.validationMessage);
|
148
|
-
}
|
149
|
-
else {
|
150
|
-
this.inputElement.setCustomValidity('');
|
151
|
-
}
|
152
|
-
this.setValidity();
|
153
|
-
}
|
154
125
|
/**
|
155
126
|
* This function is called when the attribute changes.
|
156
127
|
* It updates the validity of the input field based on the input field's validity.
|
@@ -161,8 +132,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
161
132
|
*/
|
162
133
|
attributeChangedCallback(name, old, value) {
|
163
134
|
super.attributeChangedCallback(name, old, value);
|
164
|
-
|
165
|
-
if (validationRelatedAttributes.includes(name)) {
|
135
|
+
if (name === 'validation-message') {
|
166
136
|
this.updateComplete
|
167
137
|
.then(() => {
|
168
138
|
this.setInputValidity();
|
@@ -174,6 +144,13 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
174
144
|
});
|
175
145
|
}
|
176
146
|
}
|
147
|
+
setInputValidity() {
|
148
|
+
this.inputElement.setCustomValidity('');
|
149
|
+
if (!this.inputElement.validity.valid && this.validationMessage) {
|
150
|
+
this.inputElement.setCustomValidity(this.validationMessage);
|
151
|
+
}
|
152
|
+
this.setValidity();
|
153
|
+
}
|
177
154
|
/**
|
178
155
|
* Updates the value of the input field.
|
179
156
|
* Sets the form value.
|
@@ -191,6 +168,7 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
191
168
|
onInput() {
|
192
169
|
this.updateValue();
|
193
170
|
this.setInputValidity();
|
171
|
+
this.checkValidity();
|
194
172
|
}
|
195
173
|
/**
|
196
174
|
* Handles the change event of the input field.
|
@@ -302,10 +280,10 @@ class Input extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
302
280
|
return html `<input
|
303
281
|
aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
|
304
282
|
class="input"
|
305
|
-
part="input"
|
283
|
+
part="mdc-input"
|
306
284
|
id="${this.id}"
|
307
285
|
name="${this.name}"
|
308
|
-
.value="${this.value}"
|
286
|
+
.value="${live(this.value)}"
|
309
287
|
?disabled="${this.disabled}"
|
310
288
|
?readonly="${this.readonly}"
|
311
289
|
?required="${this.required}"
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { CSSResult, nothing } from 'lit';
|
2
|
+
import Input from '../input/input.component';
|
3
|
+
import type { InputType } from '../input/input.types';
|
4
|
+
import type { ValidationType } from '../formfieldwrapper/formfieldwrapper.types';
|
5
|
+
/**
|
6
|
+
* `mdc-password` is a component that allows users to input their password.
|
7
|
+
* It extends the `mdc-input` component and provides additional features specific to password fields.
|
8
|
+
* It contains:
|
9
|
+
* - `label` field - describe the password field.
|
10
|
+
* - `password` field - contains the value
|
11
|
+
* - `help-text` or `validation-message` - displayed below the password field.
|
12
|
+
* - `help-text-type` - type of the help text, can be 'default', 'error', 'warning', 'success', 'priority'.
|
13
|
+
* - `show-hide-button-aria-label` - aria label for the trailing show/hide button.
|
14
|
+
* - all the attributes of the native password field.
|
15
|
+
*
|
16
|
+
* @tagname mdc-password
|
17
|
+
*
|
18
|
+
* @event input - (React: onInput) This event is dispatched when the value of the password field changes (every press).
|
19
|
+
* @event change - (React: onChange) This event is dispatched when the value of the password field changes (on blur).
|
20
|
+
* @event focus - (React: onFocus) This event is dispatched when the password receives focus.
|
21
|
+
* @event blur - (React: onBlur) This event is dispatched when the password loses focus.
|
22
|
+
*
|
23
|
+
* @dependency mdc-icon
|
24
|
+
* @dependency mdc-text
|
25
|
+
* @dependency mdc-button
|
26
|
+
* @dependency mdc-toggletip
|
27
|
+
*
|
28
|
+
* @cssproperty --mdc-input-disabled-border-color - Border color for the password container when disabled
|
29
|
+
* @cssproperty --mdc-input-disabled-text-color - Text color for the password field when disabled
|
30
|
+
* @cssproperty --mdc-input-disabled-background-color - Background color for the password field when disabled
|
31
|
+
* @cssproperty --mdc-input-border-color - Border color for the password container
|
32
|
+
* @cssproperty --mdc-input-text-color - Text color for the password field
|
33
|
+
* @cssproperty --mdc-input-background-color - Background color for the password field
|
34
|
+
* @cssproperty --mdc-input-selection-background-color - Background color for the selected text
|
35
|
+
* @cssproperty --mdc-input-selection-text-color - Text color for the selected text
|
36
|
+
* @cssproperty --mdc-input-support-text-color - Text color for the help text
|
37
|
+
* @cssproperty --mdc-input-hover-background-color - Background color for the password field when hovered
|
38
|
+
* @cssproperty --mdc-input-focused-background-color - Background color for the password field when focused
|
39
|
+
* @cssproperty --mdc-input-focused-border-color - Border color for the password container when focused
|
40
|
+
* @cssproperty --mdc-input-error-border-color - Border color for the password container when error
|
41
|
+
* @cssproperty --mdc-input-warning-border-color - Border color for the password container when warning
|
42
|
+
* @cssproperty --mdc-input-success-border-color - Border color for the password container when success
|
43
|
+
* @cssproperty --mdc-input-primary-border-color - Border color for the password container when primary
|
44
|
+
*
|
45
|
+
*/
|
46
|
+
declare class Password extends Input {
|
47
|
+
/**
|
48
|
+
* Aria label for the show or hide password icon button.
|
49
|
+
*/
|
50
|
+
showHideButtonAriaLabel: string;
|
51
|
+
/**
|
52
|
+
* The type of help text. It can be 'default', 'error', 'warning', 'success', 'priority'.
|
53
|
+
* @override
|
54
|
+
*/
|
55
|
+
helpTextType: ValidationType;
|
56
|
+
connectedCallback(): void;
|
57
|
+
/**
|
58
|
+
* Internal state to track whether the password is visible (shown as text) or hidden (shown as password).
|
59
|
+
*/
|
60
|
+
private showPassword;
|
61
|
+
/**
|
62
|
+
* Toggles the visibility of the password.
|
63
|
+
*/
|
64
|
+
private toggleShowPassword;
|
65
|
+
/**
|
66
|
+
* Renders the trailing button for showing or hiding the password.
|
67
|
+
*/
|
68
|
+
protected renderTrailingButton(show?: boolean): import("lit-html").TemplateResult<1> | typeof nothing;
|
69
|
+
/**
|
70
|
+
* Renders the input element for the password field.
|
71
|
+
*/
|
72
|
+
protected renderInputElement(_: InputType, hidePlaceholder?: boolean): import("lit-html").TemplateResult<1>;
|
73
|
+
static styles: Array<CSSResult>;
|
74
|
+
}
|
75
|
+
export default Password;
|
@@ -0,0 +1,128 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
|
+
};
|
10
|
+
import { html, nothing } from 'lit';
|
11
|
+
import { property, state } from 'lit/decorators.js';
|
12
|
+
import Input from '../input/input.component';
|
13
|
+
import { INPUT_TYPE } from '../input/input.constants';
|
14
|
+
import { BUTTON_VARIANTS } from '../button/button.constants';
|
15
|
+
import { DEFAULTS } from '../formfieldwrapper/formfieldwrapper.constants';
|
16
|
+
import { PASSWORD_VISIBILITY_ICONS } from './password.constants';
|
17
|
+
/**
|
18
|
+
* `mdc-password` is a component that allows users to input their password.
|
19
|
+
* It extends the `mdc-input` component and provides additional features specific to password fields.
|
20
|
+
* It contains:
|
21
|
+
* - `label` field - describe the password field.
|
22
|
+
* - `password` field - contains the value
|
23
|
+
* - `help-text` or `validation-message` - displayed below the password field.
|
24
|
+
* - `help-text-type` - type of the help text, can be 'default', 'error', 'warning', 'success', 'priority'.
|
25
|
+
* - `show-hide-button-aria-label` - aria label for the trailing show/hide button.
|
26
|
+
* - all the attributes of the native password field.
|
27
|
+
*
|
28
|
+
* @tagname mdc-password
|
29
|
+
*
|
30
|
+
* @event input - (React: onInput) This event is dispatched when the value of the password field changes (every press).
|
31
|
+
* @event change - (React: onChange) This event is dispatched when the value of the password field changes (on blur).
|
32
|
+
* @event focus - (React: onFocus) This event is dispatched when the password receives focus.
|
33
|
+
* @event blur - (React: onBlur) This event is dispatched when the password loses focus.
|
34
|
+
*
|
35
|
+
* @dependency mdc-icon
|
36
|
+
* @dependency mdc-text
|
37
|
+
* @dependency mdc-button
|
38
|
+
* @dependency mdc-toggletip
|
39
|
+
*
|
40
|
+
* @cssproperty --mdc-input-disabled-border-color - Border color for the password container when disabled
|
41
|
+
* @cssproperty --mdc-input-disabled-text-color - Text color for the password field when disabled
|
42
|
+
* @cssproperty --mdc-input-disabled-background-color - Background color for the password field when disabled
|
43
|
+
* @cssproperty --mdc-input-border-color - Border color for the password container
|
44
|
+
* @cssproperty --mdc-input-text-color - Text color for the password field
|
45
|
+
* @cssproperty --mdc-input-background-color - Background color for the password field
|
46
|
+
* @cssproperty --mdc-input-selection-background-color - Background color for the selected text
|
47
|
+
* @cssproperty --mdc-input-selection-text-color - Text color for the selected text
|
48
|
+
* @cssproperty --mdc-input-support-text-color - Text color for the help text
|
49
|
+
* @cssproperty --mdc-input-hover-background-color - Background color for the password field when hovered
|
50
|
+
* @cssproperty --mdc-input-focused-background-color - Background color for the password field when focused
|
51
|
+
* @cssproperty --mdc-input-focused-border-color - Border color for the password container when focused
|
52
|
+
* @cssproperty --mdc-input-error-border-color - Border color for the password container when error
|
53
|
+
* @cssproperty --mdc-input-warning-border-color - Border color for the password container when warning
|
54
|
+
* @cssproperty --mdc-input-success-border-color - Border color for the password container when success
|
55
|
+
* @cssproperty --mdc-input-primary-border-color - Border color for the password container when primary
|
56
|
+
*
|
57
|
+
*/
|
58
|
+
class Password extends Input {
|
59
|
+
constructor() {
|
60
|
+
super(...arguments);
|
61
|
+
/**
|
62
|
+
* Aria label for the show or hide password icon button.
|
63
|
+
*/
|
64
|
+
this.showHideButtonAriaLabel = '';
|
65
|
+
/**
|
66
|
+
* The type of help text. It can be 'default', 'error', 'warning', 'success', 'priority'.
|
67
|
+
* @override
|
68
|
+
*/
|
69
|
+
this.helpTextType = DEFAULTS.VALIDATION;
|
70
|
+
/**
|
71
|
+
* Internal state to track whether the password is visible (shown as text) or hidden (shown as password).
|
72
|
+
*/
|
73
|
+
this.showPassword = false;
|
74
|
+
}
|
75
|
+
connectedCallback() {
|
76
|
+
super.connectedCallback();
|
77
|
+
// Ensure the trailing button is always true for password inputs
|
78
|
+
this.trailingButton = true;
|
79
|
+
}
|
80
|
+
/**
|
81
|
+
* Toggles the visibility of the password.
|
82
|
+
*/
|
83
|
+
toggleShowPassword() {
|
84
|
+
this.showPassword = !this.showPassword;
|
85
|
+
}
|
86
|
+
/**
|
87
|
+
* Renders the trailing button for showing or hiding the password.
|
88
|
+
*/
|
89
|
+
renderTrailingButton(show = false) {
|
90
|
+
const showBtn = show || this.value;
|
91
|
+
if (!showBtn) {
|
92
|
+
return nothing;
|
93
|
+
}
|
94
|
+
return html `
|
95
|
+
<mdc-button
|
96
|
+
part="trailing-button"
|
97
|
+
class="own-focus-ring ${!showBtn ? 'hidden' : ''}"
|
98
|
+
variant=${BUTTON_VARIANTS.TERTIARY}
|
99
|
+
?disabled=${this.disabled || this.readonly || !showBtn}
|
100
|
+
size="${DEFAULTS.ICON_SIZE}"
|
101
|
+
@click=${this.toggleShowPassword}
|
102
|
+
aria-label=${this.showHideButtonAriaLabel}
|
103
|
+
prefix-icon=${this.showPassword ? PASSWORD_VISIBILITY_ICONS.HIDE_BOLD : PASSWORD_VISIBILITY_ICONS.SHOW_BOLD}
|
104
|
+
></mdc-button>
|
105
|
+
`;
|
106
|
+
}
|
107
|
+
/**
|
108
|
+
* Renders the input element for the password field.
|
109
|
+
*/
|
110
|
+
renderInputElement(_, hidePlaceholder) {
|
111
|
+
const inputType = this.showPassword ? INPUT_TYPE.TEXT : INPUT_TYPE.PASSWORD;
|
112
|
+
return super.renderInputElement(inputType, hidePlaceholder);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
Password.styles = [...Input.styles];
|
116
|
+
__decorate([
|
117
|
+
property({ type: String, attribute: 'show-hide-button-aria-label' }),
|
118
|
+
__metadata("design:type", Object)
|
119
|
+
], Password.prototype, "showHideButtonAriaLabel", void 0);
|
120
|
+
__decorate([
|
121
|
+
property({ type: String, attribute: 'help-text-type' }),
|
122
|
+
__metadata("design:type", String)
|
123
|
+
], Password.prototype, "helpTextType", void 0);
|
124
|
+
__decorate([
|
125
|
+
state(),
|
126
|
+
__metadata("design:type", Object)
|
127
|
+
], Password.prototype, "showPassword", void 0);
|
128
|
+
export default Password;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -10,6 +10,8 @@ declare const Select_base: import("../../utils/mixins/index.types").Constructor<
|
|
10
10
|
* The component ensures accessibility and usability while handling various use cases,
|
11
11
|
* including long text truncation with tooltip support.
|
12
12
|
*
|
13
|
+
* To set a default option, use the `selected` attribute on the `mdc-option` element.
|
14
|
+
*
|
13
15
|
* @dependency mdc-button
|
14
16
|
* @dependency mdc-icon
|
15
17
|
* @dependency mdc-popover
|
@@ -22,6 +24,7 @@ declare const Select_base: import("../../utils/mixins/index.types").Constructor<
|
|
22
24
|
*
|
23
25
|
* @event click - (React: onClick) This event is dispatched when the select is clicked.
|
24
26
|
* @event change - (React: onChange) This event is dispatched when the select is changed.
|
27
|
+
* @event input - (React: onInput) This event is dispatched when the select is changed.
|
25
28
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the select.
|
26
29
|
* @event focus - (React: onFocus) This event is dispatched when the select receives focus.
|
27
30
|
*/
|
@@ -60,7 +63,6 @@ declare class Select extends Select_base implements AssociatedFormControl {
|
|
60
63
|
* The native select element
|
61
64
|
*/
|
62
65
|
inputElement: HTMLInputElement;
|
63
|
-
connectedCallback(): void;
|
64
66
|
/**
|
65
67
|
* A helper function which returns a flattened array of all valid options from the assigned slot.
|
66
68
|
* It takes care of the edge cases where the option is either a direct child or a
|
@@ -106,6 +108,7 @@ declare class Select extends Select_base implements AssociatedFormControl {
|
|
106
108
|
/** @internal */
|
107
109
|
formStateRestoreCallback(state: string): void;
|
108
110
|
private dispatchChange;
|
111
|
+
private dispatchInput;
|
109
112
|
/**
|
110
113
|
* Handles the keydown event on the select element when the popover is open.
|
111
114
|
* The options are as follows:
|
@@ -28,6 +28,8 @@ import styles from './select.styles';
|
|
28
28
|
* The component ensures accessibility and usability while handling various use cases,
|
29
29
|
* including long text truncation with tooltip support.
|
30
30
|
*
|
31
|
+
* To set a default option, use the `selected` attribute on the `mdc-option` element.
|
32
|
+
*
|
31
33
|
* @dependency mdc-button
|
32
34
|
* @dependency mdc-icon
|
33
35
|
* @dependency mdc-popover
|
@@ -40,6 +42,7 @@ import styles from './select.styles';
|
|
40
42
|
*
|
41
43
|
* @event click - (React: onClick) This event is dispatched when the select is clicked.
|
42
44
|
* @event change - (React: onChange) This event is dispatched when the select is changed.
|
45
|
+
* @event input - (React: onInput) This event is dispatched when the select is changed.
|
43
46
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the select.
|
44
47
|
* @event focus - (React: onFocus) This event is dispatched when the select receives focus.
|
45
48
|
*/
|
@@ -66,11 +69,6 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
66
69
|
/** @internal */
|
67
70
|
this.activeDescendant = '';
|
68
71
|
}
|
69
|
-
connectedCallback() {
|
70
|
-
super.connectedCallback();
|
71
|
-
// select will only contain name and value will be defined in the options.
|
72
|
-
this.value = undefined;
|
73
|
-
}
|
74
72
|
/**
|
75
73
|
* A helper function which returns a flattened array of all valid options from the assigned slot.
|
76
74
|
* It takes care of the edge cases where the option is either a direct child or a
|
@@ -142,10 +140,12 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
142
140
|
this.selectedValueText = (_b = (_a = option === null || option === void 0 ? void 0 : option.getAttribute('label')) !== null && _a !== void 0 ? _a : option === null || option === void 0 ? void 0 : option.textContent) !== null && _b !== void 0 ? _b : '';
|
143
141
|
this.selectedIcon = option === null || option === void 0 ? void 0 : option.getAttribute('prefix-icon');
|
144
142
|
this.selectedValue = (_d = (_c = option === null || option === void 0 ? void 0 : option.getAttribute('value')) !== null && _c !== void 0 ? _c : option === null || option === void 0 ? void 0 : option.textContent) !== null && _d !== void 0 ? _d : '';
|
143
|
+
this.value = this.selectedValue;
|
145
144
|
// Set form value
|
146
145
|
this.internals.setFormValue(this.selectedValue);
|
147
146
|
this.manageRequired();
|
148
147
|
// dispatch a change event when a value is selected
|
148
|
+
this.dispatchInput(this.selectedValue);
|
149
149
|
this.dispatchChange(this.selectedValue);
|
150
150
|
}
|
151
151
|
/**
|
@@ -196,6 +196,16 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
196
196
|
bubbles: true,
|
197
197
|
}));
|
198
198
|
}
|
199
|
+
dispatchInput(value) {
|
200
|
+
if (!value) {
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
this.dispatchEvent(new CustomEvent('input', {
|
204
|
+
detail: { value },
|
205
|
+
composed: true,
|
206
|
+
bubbles: true,
|
207
|
+
}));
|
208
|
+
}
|
199
209
|
/**
|
200
210
|
* Handles the keydown event on the select element when the popover is open.
|
201
211
|
* The options are as follows:
|
@@ -215,12 +225,10 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
215
225
|
break;
|
216
226
|
}
|
217
227
|
case KEYS.SPACE:
|
218
|
-
this.updateTabIndexForAllOptions(event.target);
|
219
228
|
this.closePopover();
|
220
229
|
event.preventDefault();
|
221
230
|
break;
|
222
231
|
case KEYS.ENTER:
|
223
|
-
this.updateTabIndexForAllOptions(event.target);
|
224
232
|
this.closePopover();
|
225
233
|
event.preventDefault();
|
226
234
|
// if the popover is closed, then we submit the form.
|