ReactMaterial3/dist/validator-DUxooTr6.js

10 lines
2.1 KiB
JavaScript

"use strict";require("./class-map-DV5418hw.js");const s=require("./element-internals-OOm6rgx-.js");/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/const d=Symbol("createValidator"),h=Symbol("getValidityAnchor"),l=Symbol("privateValidator"),a=Symbol("privateSyncValidity"),r=Symbol("privateCustomValidationMessage");function V(c){var e;class u extends c{constructor(){super(...arguments),this[e]=""}get validity(){return this[a](),this[s.internals].validity}get validationMessage(){return this[a](),this[s.internals].validationMessage}get willValidate(){return this[a](),this[s.internals].willValidate}checkValidity(){return this[a](),this[s.internals].checkValidity()}reportValidity(){return this[a](),this[s.internals].reportValidity()}setCustomValidity(i){this[r]=i,this[a]()}requestUpdate(i,n,o){super.requestUpdate(i,n,o),this[a]()}firstUpdated(i){super.firstUpdated(i),this[a]()}[(e=r,a)](){this[l]||(this[l]=this[d]());const{validity:i,validationMessage:n}=this[l].getValidity(),o=!!this[r],y=this[r]||n;this[s.internals].setValidity({...i,customError:o},y,this[h]()??void 0)}[d](){throw new Error("Implement [createValidator]")}[h](){throw new Error("Implement [getValidityAnchor]")}}return u}/**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/class g{constructor(e){this.getCurrentState=e,this.currentValidity={validity:{},validationMessage:""}}getValidity(){const e=this.getCurrentState();if(!(!this.prevState||!this.equals(this.prevState,e)))return this.currentValidity;const{validity:t,validationMessage:i}=this.computeValidity(e);return this.prevState=this.copy(e),this.currentValidity={validationMessage:i,validity:{badInput:t.badInput,customError:t.customError,patternMismatch:t.patternMismatch,rangeOverflow:t.rangeOverflow,rangeUnderflow:t.rangeUnderflow,stepMismatch:t.stepMismatch,tooLong:t.tooLong,tooShort:t.tooShort,typeMismatch:t.typeMismatch,valueMissing:t.valueMissing}},this.currentValidity}}exports.Validator=g;exports.createValidator=d;exports.getValidityAnchor=h;exports.mixinConstraintValidation=V;