nice-avatar-svg
Version:
Library to generate SVG avatar
2 lines (1 loc) • 2.7 kB
JavaScript
"use strict";const l=require("./NiceAvatar-CSMiVu6M.cjs");function h(){return(h=Object.assign?Object.assign.bind():function(n){for(var s=1;s<arguments.length;s++){var t=arguments[s];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n}).apply(this,arguments)}var m=["context","children"];function b(n){this.getChildContext=function(){return n.context};var s=n.children,t=function(r,i){if(r==null)return{};var o,e,a={},c=Object.keys(r);for(e=0;e<c.length;e++)i.indexOf(o=c[e])>=0||(a[o]=r[o]);return a}(n,m);return l.E(s,t)}function y(){var n=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(n),this._vdom=l.g(b,h({},this._props,{context:n.detail.context}),function s(t,r){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var i=[],o={},e=0,a=t.attributes,c=t.childNodes;for(e=a.length;e--;)a[e].name!=="slot"&&(o[a[e].name]=a[e].value,o[f(a[e].name)]=a[e].value);for(e=c.length;e--;){var p=s(c[e],null),u=c[e].slot;u?o[u]=l.g(d,{name:u},p):i[e]=p}var v=r?l.g(d,null,i):i;return l.g(r||t.nodeName.toLowerCase(),o,v)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?l.D:l.B)(this._vdom,this._root)}function f(n){return n.replace(/-(\w)/g,function(s,t){return t?t.toUpperCase():""})}function _(n,s,t){if(this._vdom){var r={};r[n]=t=t??void 0,r[f(n)]=t,this._vdom=l.E(this._vdom,r),l.B(this._vdom,this._root)}}function g(){l.B(this._vdom=null,this._root)}function d(n,s){var t=this;return l.g("slot",h({},n,{ref:function(r){r?(t.ref=r,t._listener||(t._listener=function(i){i.stopPropagation(),i.detail.context=s},r.addEventListener("_preact",t._listener))):t.ref.removeEventListener("_preact",t._listener)}}))}function C(n,s,t,r){function i(){var o=Reflect.construct(HTMLElement,[],i);return o._vdomComponent=n,o._root=r&&r.shadow?o.attachShadow({mode:r.mode||"open"}):o,o}return(i.prototype=Object.create(HTMLElement.prototype)).constructor=i,i.prototype.connectedCallback=y,i.prototype.attributeChangedCallback=_,i.prototype.disconnectedCallback=g,t=t||n.observedAttributes||Object.keys(n.propTypes||{}),i.observedAttributes=t,t.forEach(function(o){Object.defineProperty(i.prototype,o,{get:function(){return this._vdom.props[o]},set:function(e){this._vdom?this.attributeChangedCallback(o,null,e):(this._props||(this._props={}),this._props[o]=e,this.connectedCallback());var a=typeof e;e!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(o,e)}})}),customElements.define(s,i)}C(l.NiceAvatar,"nice-avatar",["bgColor","earSize","eyesStyle","facialHairStyle,","hairColor","hairStyle","mouthStyle","noseStyle","shirtColor","shirtStyle","skinColor","earRing","eyebrowsStyle","glassesStyle","shape"],{shadow:!1});