kopia lustrzana https://github.com/shoelace-style/shoelace
use public method for validity
rodzic
c216cfe0fd
commit
dcca64a986
|
|
@ -81,7 +81,7 @@ export default class SlCheckbox extends ShoelaceElement implements ShoelaceFormC
|
|||
@defaultValue('checked') defaultChecked = false;
|
||||
|
||||
firstUpdated() {
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
private handleClick() {
|
||||
|
|
@ -108,7 +108,7 @@ export default class SlCheckbox extends ShoelaceElement implements ShoelaceFormC
|
|||
handleDisabledChange() {
|
||||
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
||||
this.input.disabled = this.disabled;
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
@watch('checked', { waitUntilFirstUpdate: true })
|
||||
|
|
@ -116,7 +116,7 @@ export default class SlCheckbox extends ShoelaceElement implements ShoelaceFormC
|
|||
handleStateChange() {
|
||||
this.input.checked = this.checked; // force a sync update
|
||||
this.input.indeterminate = this.indeterminate; // force a sync update
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
/** Simulates a click on the checkbox. */
|
||||
|
|
@ -150,7 +150,7 @@ export default class SlCheckbox extends ShoelaceElement implements ShoelaceFormC
|
|||
*/
|
||||
setCustomValidity(message: string) {
|
||||
this.input.setCustomValidity(message);
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ export default class SlInput extends ShoelaceElement implements ShoelaceFormCont
|
|||
}
|
||||
|
||||
firstUpdated() {
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
private handleBlur() {
|
||||
|
|
@ -285,7 +285,7 @@ export default class SlInput extends ShoelaceElement implements ShoelaceFormCont
|
|||
handleDisabledChange() {
|
||||
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
||||
this.input.disabled = this.disabled;
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
@watch('step', { waitUntilFirstUpdate: true })
|
||||
|
|
@ -293,13 +293,13 @@ export default class SlInput extends ShoelaceElement implements ShoelaceFormCont
|
|||
// If step changes, the value may become invalid so we need to recheck after the update. We set the new step
|
||||
// imperatively so we don't have to wait for the next render to report the updated validity.
|
||||
this.input.step = String(this.step);
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
@watch('value', { waitUntilFirstUpdate: true })
|
||||
handleValueChange() {
|
||||
this.input.value = this.value; // force a sync update
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
/** Sets focus on the input. */
|
||||
|
|
@ -377,7 +377,7 @@ export default class SlInput extends ShoelaceElement implements ShoelaceFormCont
|
|||
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
|
||||
setCustomValidity(message: string) {
|
||||
this.input.setCustomValidity(message);
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ export default class SlRange extends ShoelaceElement implements ShoelaceFormCont
|
|||
|
||||
@watch('value', { waitUntilFirstUpdate: true })
|
||||
handleValueChange() {
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
|
||||
// The value may have constraints, so we set the native control's value and sync it back to ensure it adhere's to
|
||||
// min, max, and step properly
|
||||
|
|
@ -189,7 +189,7 @@ export default class SlRange extends ShoelaceElement implements ShoelaceFormCont
|
|||
handleDisabledChange() {
|
||||
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
||||
this.input.disabled = this.disabled;
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
@watch('hasTooltip', { waitUntilFirstUpdate: true })
|
||||
|
|
@ -242,7 +242,7 @@ export default class SlRange extends ShoelaceElement implements ShoelaceFormCont
|
|||
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
|
||||
setCustomValidity(message: string) {
|
||||
this.input.setCustomValidity(message);
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ export default class SlSwitch extends ShoelaceElement implements ShoelaceFormCon
|
|||
@defaultValue('checked') defaultChecked = false;
|
||||
|
||||
firstUpdated() {
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
private handleBlur() {
|
||||
|
|
@ -113,14 +113,14 @@ export default class SlSwitch extends ShoelaceElement implements ShoelaceFormCon
|
|||
@watch('checked', { waitUntilFirstUpdate: true })
|
||||
handleCheckedChange() {
|
||||
this.input.checked = this.checked; // force a sync update
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
@watch('disabled', { waitUntilFirstUpdate: true })
|
||||
handleDisabledChange() {
|
||||
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
||||
this.input.disabled = this.disabled;
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
/** Simulates a click on the switch. */
|
||||
|
|
@ -151,7 +151,7 @@ export default class SlSwitch extends ShoelaceElement implements ShoelaceFormCon
|
|||
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
|
||||
setCustomValidity(message: string) {
|
||||
this.input.setCustomValidity(message);
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ export default class SlTextarea extends ShoelaceElement implements ShoelaceFormC
|
|||
}
|
||||
|
||||
firstUpdated() {
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
|
|
@ -181,7 +181,7 @@ export default class SlTextarea extends ShoelaceElement implements ShoelaceFormC
|
|||
handleDisabledChange() {
|
||||
// Disabled form controls are always valid, so we need to recheck validity when the state changes
|
||||
this.input.disabled = this.disabled;
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
@watch('rows', { waitUntilFirstUpdate: true })
|
||||
|
|
@ -192,7 +192,7 @@ export default class SlTextarea extends ShoelaceElement implements ShoelaceFormC
|
|||
@watch('value', { waitUntilFirstUpdate: true })
|
||||
handleValueChange() {
|
||||
this.input.value = this.value; // force a sync update
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
this.updateComplete.then(() => this.setTextareaHeight());
|
||||
}
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ export default class SlTextarea extends ShoelaceElement implements ShoelaceFormC
|
|||
/** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
|
||||
setCustomValidity(message: string) {
|
||||
this.input.setCustomValidity(message);
|
||||
this.invalid = !this.input.checkValidity();
|
||||
this.invalid = !this.checkValidity();
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue