This commit is contained in:
Niels Lyngsø
2024-04-15 13:19:27 +02:00
parent f280f779f5
commit fc96efe18a
2 changed files with 3 additions and 39 deletions

View File

@@ -104,7 +104,7 @@ export const UmbFormControlMixin = <
* @attr value
* @default ''
*/
@property({ reflect: false }) // Do not 'reflect' as the attribute is used as fallback.
@property({ reflect: false }) // Do not 'reflect' as the attribute value is used as fallback. [NL]
get value(): ValueType | DefaultValueType {
return this.#value;
}
@@ -127,9 +127,6 @@ export const UmbFormControlMixin = <
public set pristine(value: boolean) {
if (this._pristine !== value) {
this._pristine = value;
/*this.#formCtrlElements.forEach((el) => {
el.pristine = value;
});*/
this.#dispatchValidationState();
}
}
@@ -286,7 +283,6 @@ export const UmbFormControlMixin = <
* Such are mainly properties that are not declared as a Lit state and or Lit property.
*/
protected _runValidators() {
//this._validityState = new UmbValidityState();
this.#validity = {};
const messages: Set<string> = new Set();
let innerFormControlEl: UmbNativeFormControlElement | undefined = undefined;
@@ -299,10 +295,7 @@ export const UmbFormControlMixin = <
this.#validity[key] = true;
messages.add(formCtrlEl.validationMessage);
innerFormControlEl ??= formCtrlEl;
//this._internals.setValidity(this.#validity, formCtrlEl.validationMessage, formCtrlEl);
} //else {
//this.#validity[key] = false;
//}
}
}
});
@@ -311,9 +304,7 @@ export const UmbFormControlMixin = <
if (validator.checkMethod()) {
this.#validity[validator.flagKey] = true;
messages.add(validator.getMessageMethod());
} //else {
//this.#validity[validator.flagKey] = false;
//}
}
});
const hasError = Object.values(this.#validity).includes(true);
@@ -329,18 +320,6 @@ export const UmbFormControlMixin = <
innerFormControlEl ?? this.getFormElement() ?? undefined,
);
/*
this.#formCtrlElements.forEach((formCtrlEl) => {
formCtrlEl.setCustomValidity(this.validationMessage);
});
*/
/*
if (!hasError) {
this._internals.setValidity({});
}
*/
this.#dispatchValidationState();
}

View File

@@ -1,15 +0,0 @@
type Writeable<T> = { -readonly [P in keyof T]: T[P] };
export class UmbValidityState implements Writeable<ValidityState> {
badInput: boolean = true;
customError: boolean = true;
patternMismatch: boolean = true;
rangeOverflow: boolean = true;
rangeUnderflow: boolean = true;
stepMismatch: boolean = true;
tooLong: boolean = true;
tooShort: boolean = true;
typeMismatch: boolean = true;
valid: boolean = true;
valueMissing: boolean = true;
}