UNPKG

@sandlada/mdc

Version:

@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.

7 lines (6 loc) 1.29 kB
import"../../lit-element-Ho-VPzO1.js";import"../../tslib.es6-CmLYFWVC.js";import{internals as t}from"./element-internals.js"; /** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */const i=Symbol("createValidator"),e=Symbol("getValidityAnchor"),s=Symbol("privateValidator"),r=Symbol("privateSyncValidity"),a=Symbol("privateCustomValidationMessage");function l(l){var o;class d extends l{constructor(){super(...arguments),this[o]=""}get validity(){return this[r](),this[t].validity}get validationMessage(){return this[r](),this[t].validationMessage}get willValidate(){return this[r](),this[t].willValidate}checkValidity(){return this[r](),this[t].checkValidity()}reportValidity(){return this[r](),this[t].reportValidity()}setCustomValidity(t){this[a]=t,this[r]()}requestUpdate(t,i,e){super.requestUpdate(t,i,e),this[r]()}firstUpdated(t){super.firstUpdated(t),this[r]()}[(o=a,r)](){this[s]||(this[s]=this[i]());const{validity:r,validationMessage:l}=this[s].getValidity(),o=!!this[a],d=this[a]||l;this[t].setValidity({...r,customError:o},d,this[e]()??void 0)}[i](){throw new Error("Implement [createValidator]")}[e](){throw new Error("Implement [getValidityAnchor]")}}return d}export{i as createValidator,e as getValidityAnchor,l as mixinConstraintValidation};