{"version":3,"file":"index.es.min.js","sources":["../../../packages/helpers/src/props.helpers.js","../../../packages/components/src/level/level.js"],"sourcesContent":["const getData = attributes => attributes.find(attribute => attribute.nodeName === 'data')\n\nconst createProps = attributes => {\n    const data = getData([...attributes])\n    const props = [...attributes]\n        .filter(attribute => attribute.nodeName !== 'data')\n        .reduce((all, attr) => {\n            return { ...all, [attr.nodeName]: attr.nodeValue }\n        }, {})\n\n    if (isNil(data)) {\n        return props\n    }\n\n    try {\n        return { ...props, ...JSON.parse(data.nodeValue) }\n    } catch (error) {\n        console.log('ERROR: No data', error, data?.nodeValue)\n    }\n}\n\nconst isNil = obj => obj === undefined || obj === null\n\nexport const parseBool = value => (!value || value === 'false' ? false : true)\n\nexport default createProps\n","import createProps from '@kissui/helpers/src/props.helpers'\n\nclass Level extends HTMLElement {\n    connectedCallback() {\n        this.props = createProps(this.attributes)\n        this.render()\n    }\n\n    render() {\n        const { value, a11y_level_of = 'of', max = '5' } = this.props\n\n        this.innerHTML = `\n            <p class=\"sr-only\">${value} ${a11y_level_of} ${max}</p>\n            <div>${this.renderLevels(value, max)}</div>\n            `\n    }\n\n    renderLevels(value, max) {\n        let l = ''\n        for (let i = 1; i <= max; i++) {\n            l = l + this.renderLevel(i, value)\n        }\n        return l\n    }\n\n    renderLevel(i, value) {\n        return `<span class=\"${i <= value ? 'selected' : ''}\"></span>`\n    }\n}\n\ncustomElements.get('nb-level') || customElements.define('nb-level', Level)\nexport default Level\n"],"names":["isNil","obj","Level","HTMLElement","connectedCallback","this","props","attributes","data","find","attribute","nodeName","getData","filter","reduce","all","attr","nodeValue","JSON","parse","error","console","log","createProps","render","value","a11y_level_of","max","innerHTML","renderLevels","l","i","renderLevel","customElements","get","define"],"mappings":"AAAA,MAqBMA,EAAQC,GAAoC,MAARA,ECnB1C,MAAMC,UAAcC,YAChBC,iBAAAA,GACIC,KAAKC,MDFOC,CAAAA,IACVC,MAAAA,EAHMD,CAAAA,GAAcA,EAAWE,MAAKC,GAAoC,SAAvBA,EAAUC,WAGpDC,CAAQ,IAAIL,IACnBD,EAAQ,IAAIC,GACbM,QAAOH,GAAoC,SAAvBA,EAAUC,WAC9BG,QAAO,CAACC,EAAKC,KACH,IAAKD,EAAK,CAACC,EAAKL,UAAWK,EAAKC,aACxC,CAAE,GAET,GAAIjB,EAAMQ,GACCF,OAAAA,EAGP,IACO,MAAA,IAAKA,KAAUY,KAAKC,MAAMX,EAAKS,WACzC,OAAQG,GACLC,QAAQC,IAAI,iBAAkBF,EAAOZ,GAAMS,UAC/C,GCdiBM,CAAYlB,KAAKE,YAC9BF,KAAKmB,QACT,CAEAA,MAAAA,GACU,MAAEC,MAAAA,EAAOC,cAAAA,EAAgB,KAAMC,IAAAA,EAAM,KAAQtB,KAAKC,MAExDD,KAAKuB,UAAY,oCACQH,KAASC,KAAiBC,2BACxCtB,KAAKwB,aAAaJ,EAAOE,wBAExC,CAEAE,YAAAA,CAAaJ,EAAOE,GAChB,IAAIG,EAAI,GACCC,IAAAA,IAAAA,EAAI,EAAGA,GAAKJ,EAAKI,IACtBD,GAAQzB,KAAK2B,YAAYD,EAAGN,GAEzBK,OAAAA,CACX,CAEAE,WAAAA,CAAYD,EAAGN,GACX,MAAO,gBAAgBM,GAAKN,EAAQ,WAAa,aACrD,EAGJQ,eAAeC,IAAI,aAAeD,eAAeE,OAAO,WAAYjC"}