UNPKG

@public-ui/components

Version:

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

4 lines 1.74 kB
/*! * KoliBri - The accessible HTML-Standard */ "use strict";const prop_validators=require("./prop.validators-888c8338.js"),common=require("./common-1ab929ac.js"),mapCustomIcon=(o,t,n)=>{common.isObject(n)?o[t]=n:common.isString(n,1)&&(o[t]={icon:n})},mapIconProp2State=o=>{let t={};return common.isString(o,1)?t={left:{icon:o}}:"object"==typeof o&&null!==o&&(mapCustomIcon(t,"top",o.top),mapCustomIcon(t,"right",o.right),mapCustomIcon(t,"bottom",o.bottom),mapCustomIcon(t,"left",o.left)),t},beforePatchIcon=o=>{var t,n,e;if(null===(t=o.nextState)||void 0===t?void 0:t.has("_icons")){const t=null===(n=o.nextState)||void 0===n?void 0:n.get("_icons");null===(e=o.nextState)||void 0===e||e.set("_icons",mapIconProp2State(t))}},isIcon=o=>"object"==typeof o&&null!==o&&(void 0===o.style||common.isStyle(o.style))&&(void 0===o.label||common.isString(o.label))&&common.isString(o.icon,1),validateIcons=(o,t,n={})=>{prop_validators.objectObjectHandler(t,(()=>{var e;try{t=prop_validators.parseJson(t)}catch(o){}prop_validators.watchValidator(o,"_icons",(o=>{const t="object"==typeof o&&null!==o&&0===Object.keys(o).length;return null===o||t||common.isString(o,1)||"object"==typeof o&&null!==o&&(common.isString(o.left,1)||isIcon(o.left)||common.isString(o.right,1)||isIcon(o.right)||common.isString(o.top,1)||isIcon(o.top)||common.isString(o.bottom,1)||isIcon(o.bottom))}),new Set(["KoliBriIcon"]),t,Object.assign(Object.assign({},n),{defaultValue:{},hooks:{afterPatch:null===(e=n.hooks)||void 0===e?void 0:e.afterPatch,beforePatch:(o,t,e,i)=>{var c,s;"function"==typeof(null===(c=n.hooks)||void 0===c?void 0:c.beforePatch)&&(null===(s=n.hooks)||void 0===s||s.beforePatch(o,t,e,i)),beforePatchIcon(e)}}}))}))};exports.validateIcons=validateIcons;