and-component-library
Version:
Distribution of AND Web Components
3 lines (2 loc) • 10.9 kB
JavaScript
function t(){}function e(t){return t()}function n(){return Object.create(null)}function o(t){t.forEach(e)}function r(t){return"function"==typeof t}function i(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function s(t){return 0===Object.keys(t).length}function c(t,e,n,o){if(t){const r=a(t,e,n,o);return t[0](r)}}function a(t,e,n,o){return t[1]&&o?function(t,e){for(const n in e)t[n]=e[n];return t}(n.ctx.slice(),t[1](o(e))):n.ctx}function d(t,e,n,o,r,i,s){const c=function(t,e,n,o){if(t[2]&&o){const r=t[2](o(n));if(void 0===e.dirty)return r;if("object"==typeof r){const t=[],n=Math.max(e.dirty.length,r.length);for(let o=0;o<n;o+=1)t[o]=e.dirty[o]|r[o];return t}return e.dirty|r}return e.dirty}(e,o,r,i);if(c){const r=a(e,n,o,s);t.p(r,c)}}function l(t,e){t.appendChild(e)}function u(t,e,n){t.insertBefore(e,n||null)}function p(t){t.parentNode.removeChild(t)}function f(t){return document.createElement(t)}function m(t){return document.createTextNode(t)}function h(){return m(" ")}function $(){return m("")}function b(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function x(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}let g;function y(t){g=t}function w(t){(function(){if(!g)throw new Error("Function called outside component initialization");return g})().$$.on_mount.push(t)}const v=[],k=[],_=[],z=[],E=Promise.resolve();let M=!1;function q(t){_.push(t)}let C=!1;const L=new Set;function N(){if(!C){C=!0;do{for(let t=0;t<v.length;t+=1){const e=v[t];y(e),T(e.$$)}for(y(null),v.length=0;k.length;)k.pop()();for(let t=0;t<_.length;t+=1){const e=_[t];L.has(e)||(L.add(e),e())}_.length=0}while(v.length);for(;z.length;)z.pop()();M=!1,C=!1,L.clear()}}function T(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(q)}}const A=new Set;let P,j;function H(){P={r:0,c:[],p:P}}function O(){P.r||o(P.c),P=P.p}function S(t,e){t&&t.i&&(A.delete(t),t.i(e))}function R(t,e,n,o){if(t&&t.o){if(A.has(t))return;A.add(t),P.c.push(()=>{A.delete(t),o&&(n&&t.d(1),o())}),t.o(e)}}function B(t){t&&t.c()}function F(t,n,i){const{fragment:s,on_mount:c,on_destroy:a,after_update:d}=t.$$;s&&s.m(n,i),q(()=>{const n=c.map(e).filter(r);a?a.push(...n):o(n),t.$$.on_mount=[]}),d.forEach(q)}function D(t,e){const n=t.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function G(t,e){-1===t.$$.dirty[0]&&(v.push(t),M||(M=!0,E.then(N)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function I(e,r,i,s,c,a,d=[-1]){const l=g;y(e);const u=r.props||{},f=e.$$={fragment:null,ctx:null,props:a,update:t,not_equal:c,bound:n(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(l?l.$$.context:[]),callbacks:n(),dirty:d,skip_bound:!1};let m=!1;if(f.ctx=i?i(e,u,(t,n,...o)=>{const r=o.length?o[0]:n;return f.ctx&&c(f.ctx[t],f.ctx[t]=r)&&(!f.skip_bound&&f.bound[t]&&f.bound[t](r),m&&G(e,t)),n}):[],f.update(),m=!0,o(f.before_update),f.fragment=!!s&&s(f.ctx),r.target){if(r.hydrate){const t=function(t){return Array.from(t.childNodes)}(r.target);f.fragment&&f.fragment.l(t),t.forEach(p)}else f.fragment&&f.fragment.c();r.intro&&S(e.$$.fragment),F(e,r.target,r.anchor),N()}y(l)}"function"==typeof HTMLElement&&(j=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"})}connectedCallback(){for(const t in this.$$.slotted)this.appendChild(this.$$.slotted[t])}attributeChangedCallback(t,e,n){this[t]=n}$destroy(){D(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!s(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}});class J{$destroy(){D(this,1),this.$destroy=t}$on(t,e){const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){this.$$set&&!s(t)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const K=t=>({matches:1&t}),Q=t=>({matches:t[0]});function U(t){let e;const n=t[3].default,o=c(n,t,t[2],Q);return{c(){o&&o.c()},m(t,n){o&&o.m(t,n),e=!0},p(t,[e]){o&&o.p&&5&e&&d(o,n,t,t[2],e,K,Q)},i(t){e||(S(o,t),e=!0)},o(t){R(o,t),e=!1},d(t){o&&o.d(t)}}}function V(t,e,n){let o,r,{$$slots:i={},$$scope:s}=e,{query:c}=e,a=!1,d=!1;function l(){o&&r&&o.removeListener(r)}return w(()=>(n(6,a=!0),()=>{l()})),t.$$set=t=>{"query"in t&&n(1,c=t.query),"$$scope"in t&&n(2,s=t.$$scope)},t.$$.update=()=>{66&t.$$.dirty&&a&&(l(),function(t){o=window.matchMedia(t),r=t=>n(0,d=t.matches),o.addListener(r),n(0,d=o.matches)}(c))},[d,c,s,i]}class W extends J{constructor(t){super(),I(this,t,V,U,i,{query:1})}}function X(t){let e;const n=t[1].default,o=c(n,t,t[2],null);return{c(){o&&o.c()},m(t,n){o&&o.m(t,n),e=!0},p(t,e){o&&o.p&&4&e&&d(o,n,t,t[2],e,null,null)},i(t){e||(S(o,t),e=!0)},o(t){R(o,t),e=!1},d(t){o&&o.d(t)}}}function Y(t){let e,n,o=t[3]&&X(t);return{c(){o&&o.c(),e=$()},m(t,r){o&&o.m(t,r),u(t,e,r),n=!0},p(t,n){t[3]?o?(o.p(t,n),8&n&&S(o,1)):(o=X(t),o.c(),S(o,1),o.m(e.parentNode,e)):o&&(H(),R(o,1,1,()=>{o=null}),O())},i(t){n||(S(o),n=!0)},o(t){R(o),n=!1},d(t){o&&o.d(t),t&&p(e)}}}function Z(t){let e,n;return e=new W({props:{query:t[0],$$slots:{default:[Y,({matches:t})=>({3:t}),({matches:t})=>t?8:0]},$$scope:{ctx:t}}}),{c(){B(e.$$.fragment)},m(t,o){F(e,t,o),n=!0},p(t,[n]){const o={};12&n&&(o.$$scope={dirty:n,ctx:t}),e.$set(o)},i(t){n||(S(e.$$.fragment,t),n=!0)},o(t){R(e.$$.fragment,t),n=!1},d(t){D(e,t)}}}function tt(t,e,n){let{$$slots:o={},$$scope:r}=e;return t.$$set=t=>{"$$scope"in t&&n(2,r=t.$$scope)},["(max-width: 991px)",o,r]}class et extends J{constructor(t){super(),I(this,t,tt,Z,i,{})}}function nt(t){let e,n,o,r,i,s,c,a,d,$;return d=new et({props:{$$slots:{default:[rt]},$$scope:{ctx:t}}}),{c(){e=f("div"),n=f("button"),o=m(t[0]),r=h(),i=f("i"),s=h(),c=f("div"),c.innerHTML="<slot><b>No Sub-Menu provided</b></slot>",a=h(),B(d.$$.fragment),b(n,"class","dropbtn"),b(c,"class","dropdown-content"),b(e,"id",t[2]),b(e,"class","dropdown")},m(p,f){u(p,e,f),l(e,n),l(n,o),l(n,r),l(n,i),l(e,s),l(e,c),t[6](c),l(e,a),F(d,e,null),$=!0},p(t,n){(!$||1&n)&&x(o,t[0]);const r={};144&n&&(r.$$scope={dirty:n,ctx:t}),d.$set(r),(!$||4&n)&&b(e,"id",t[2])},i(t){$||(S(d.$$.fragment,t),$=!0)},o(t){R(d.$$.fragment,t),$=!1},d(n){n&&p(e),t[6](null),D(d)}}}function ot(t){let e;return{c(){e=f("hr"),b(e,"class","menu-separator")},m(t,n){u(t,e,n)},d(t){t&&p(e)}}}function rt(t){let e,n=!0===t[4]&&ot();return{c(){n&&n.c(),e=$()},m(t,o){n&&n.m(t,o),u(t,e,o)},p(t,o){!0===t[4]?n||(n=ot(),n.c(),n.m(e.parentNode,e)):n&&(n.d(1),n=null)},d(t){n&&n.d(t),t&&p(e)}}}function it(t){let e,n;return{c(){e=f("a"),n=m(t[0]),b(e,"id",t[2]),b(e,"class","menu-item"),b(e,"target",t[3]),b(e,"href",t[1])},m(t,o){u(t,e,o),l(e,n)},p(t,o){1&o&&x(n,t[0]),4&o&&b(e,"id",t[2]),8&o&&b(e,"target",t[3]),2&o&&b(e,"href",t[1])},d(t){t&&p(e)}}}function st(e){let n,o,r,i=""==e[1]&&nt(e),s=""!=e[1]&&it(e);return{c(){n=f("div"),i&&i.c(),o=h(),s&&s.c(),this.c=t,b(n,"class","menu")},m(t,e){u(t,n,e),i&&i.m(n,null),l(n,o),s&&s.m(n,null),r=!0},p(t,[e]){""==t[1]?i?(i.p(t,e),2&e&&S(i,1)):(i=nt(t),i.c(),S(i,1),i.m(n,o)):i&&(H(),R(i,1,1,()=>{i=null}),O()),""!=t[1]?s?s.p(t,e):(s=it(t),s.c(),s.m(n,null)):s&&(s.d(1),s=null)},i(t){r||(S(i),r=!0)},o(t){R(i),r=!1},d(t){t&&p(n),i&&i.d(),s&&s.d()}}}function ct(t,e,n){let o,{text:r=""}=e,{href:i=""}=e,{id:s="and-menu-item"}=e,{target:c=""}=e,{menuseparator:a=!0}=e;return t.$$set=t=>{"text"in t&&n(0,r=t.text),"href"in t&&n(1,i=t.href),"id"in t&&n(2,s=t.id),"target"in t&&n(3,c=t.target),"menuseparator"in t&&n(4,a=t.menuseparator)},[r,i,s,c,a,o,function(t){k[t?"unshift":"push"](()=>{o=t,n(5,o)})}]}class at extends j{constructor(t){super(),this.shadowRoot.innerHTML='<style>@import url(https://fonts.googleapis.com/css2?family=Poppins);:root{--step:50}.menu-item{float:left;font-size:14px;font-size:torem(14px);font-family:"Poppins", sans-serif;color:#323232;text-align:center;padding:0.875rem 1rem 0 1rem;text-decoration:none}.menu-item:hover{font-weight:bold}.menu{display:flex;flex-direction:column;align-items:flex-start}@media(min-width: 992px){.menu{float:left;flex-direction:row}}.dropdown{font-family:"Poppins", sans-serif;display:flex;flex-direction:column;position:relative}.dropbtn{font-size:14px;font-size:torem(14px);font-family:"Poppins", sans-serif;border:none;outline:none;color:#323232;padding:0.875rem 1rem 0 1rem;background-color:inherit;font-family:inherit;margin:0;display:flex}.dropbtn i{box-sizing:border-box;position:relative;display:block;transform:scale(var(--ggs, 1));width:22px;height:22px}.dropbtn i::before{content:"";display:block;box-sizing:border-box;position:absolute;width:0;height:10px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:6px solid;top:6px;left:9px}@media(min-width: 992px){.dropbtn i{box-sizing:border-box;position:relative;display:block;transform:scale(var(--ggs, 1));width:22px;height:22px}.dropbtn i::before{content:"";display:block;box-sizing:border-box;position:absolute;width:0;height:10px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:6px solid;transform:rotate(90deg);top:6px;left:9px}}.dropbtn:hover i{box-sizing:border-box;position:relative;display:block;transform:scale(var(--ggs, 1));width:22px;height:22px}.dropbtn:hover i::before{content:"";display:block;box-sizing:border-box;position:absolute;width:0;height:10px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:6px solid;transform:rotate(90deg);top:6px;left:9px}@media(min-width: 992px){.dropbtn{padding-bottom:2.8125rem}}.dropbtn:hover{font-weight:bold}.dropdown-content{display:none;margin-left:1.5rem}@media(min-width: 992px){.dropdown-content{background-color:white;margin:0.5rem;box-shadow:0rem 0.5rem 1rem 0rem rgba(0, 0, 0, 0.2);position:absolute;width:100%;margin-top:2.8125rem;z-index:1}}.dropdown:hover .dropdown-content,.dropdown:hover .menu-separator{display:block}.menu-separator{display:none;width:82vw;border-width:0;margin-top:1rem;border-top:1px solid #323232;margin-left:0.875rem}</style>',I(this,{target:this.shadowRoot},ct,st,i,{text:0,href:1,id:2,target:3,menuseparator:4}),t&&(t.target&&u(t.target,this,t.anchor),t.props&&(this.$set(t.props),N()))}static get observedAttributes(){return["text","href","id","target","menuseparator"]}get text(){return this.$$.ctx[0]}set text(t){this.$set({text:t}),N()}get href(){return this.$$.ctx[1]}set href(t){this.$set({href:t}),N()}get id(){return this.$$.ctx[2]}set id(t){this.$set({id:t}),N()}get target(){return this.$$.ctx[3]}set target(t){this.$set({target:t}),N()}get menuseparator(){return this.$$.ctx[4]}set menuseparator(t){this.$set({menuseparator:t}),N()}}customElements.define("and-menu-item",at);export default at;
//# sourceMappingURL=MenuItem.js.map