UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

4 lines 2.24 kB
/*! * KoliBri - The accessible HTML-Standard */ import{c as t,z as s,i as e,l as i}from"./index-ebe5a881.js";import{I as a}from"./getRenderStates-c4b5c6cb.js";import{v as r}from"./orientation-409d844a.js";import{b as o,c as n}from"./label-bf9966d0.js";const f=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.label&&e.label.length>0)return e.disabled=!0===e.disabled,e.label=`${e.label}`.trim(),!1===o(e.label,3)&&!1===n(e.label)&&t(`A differing Aria-Label (${e.label}) is not accessible. A differing Aria-Label should consist of at least three readable characters.`),!Array.isArray(e.options)||void 0===e.options.find((t=>!1===f(t)));if("number"==typeof e.label)return!0}return!1},h=(t,e,o={})=>{s(t,"_options",(t=>"object"==typeof t&&null!==t&&"string"==typeof t.label&&t.label.length>0),e,void 0,o)},l=(t,e,o={})=>{s(t,"_options",f,e,void 0,o)},c=(t,o)=>{e(t,"_required",o)},u=(t,e,o="")=>{e.forEach(((e,a)=>{const i=`${o}-${a}`;"object"==typeof e&&null!==e&&"string"==typeof e.label&&e.label.length>0&&(Array.isArray(e.options)?u(t,e.options,i):t.set(i,e))}))};class d extends a{constructor(t,e,o){super(t,e,o),this.component=t}validateRequired(t){c(this.component,t)}componentWillLoad(){super.componentWillLoad(),this.validateRequired(this.component._required)}}class p extends d{constructor(t,e,o){super(t,e,o),this.keyOptionMap=new Map,this.getOptionByKey=t=>this.keyOptionMap.get(t),this.afterPatchOptions=(t,e,o,a)=>{"_value"===a&&this.setFormAssociatedValue(t)},this.beforePatchOptions=(t,e)=>{const o=e.has("_options")?e.get("_options"):this.component.state._options;Array.isArray(o)&&o.length>0&&(this.keyOptionMap.clear(),u(this.keyOptionMap,o))},this.component=t}validateOrientation(t){r(this.component,t,"vertical")}validateOptions(t){h(this.component,t,{hooks:{afterPatch:this.afterPatchOptions,beforePatch:this.beforePatchOptions}})}validateValue(t){t=Array.isArray(t)?t[0]:t,i(this.component,"_value",t,{afterPatch:this.afterPatchOptions,beforePatch:this.beforePatchOptions})}componentWillLoad(){super.componentWillLoad(),this.validateOrientation(this.component._orientation),this.validateOptions(this.component._options),this.validateValue(this.component._value)}}export{d as I,p as a,h as b,u as f,l as v};