UNPKG

prisme-components-svelte

Version:

Svelte components for the Prisme Design System

2 lines (1 loc) 10.7 kB
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((o=o||self).PrismeComponentsSvelte={})}(this,(function(o){"use strict";function t(){}function n(o){return o()}function e(){return Object.create(null)}function r(o){o.forEach(n)}function c(o){return"function"==typeof o}function l(o,t){return o!=o?t==t:o!==t||o&&"object"==typeof o||"function"==typeof o}function i(o,t,n,e){if(o){const r=s(o,t,n,e);return o[0](r)}}function s(o,t,n,e){return o[1]&&e?function(o,t){for(const n in t)o[n]=t[n];return o}(n.ctx.slice(),o[1](e(t))):n.ctx}function a(o,t,n,e){if(o[2]&&e){const r=o[2](e(n));if("object"==typeof t.dirty){const o=[],n=Math.max(t.dirty.length,r.length);for(let e=0;e<n;e+=1)o[e]=t.dirty[e]|r[e];return o}return t.dirty|r}return t.dirty}function u(o,t,n){o.insertBefore(t,n||null)}function d(o){o.parentNode.removeChild(o)}function f(o){return document.createElement(o)}function p(){return o="",document.createTextNode(o);var o}function h(o,t,n,e){return o.addEventListener(t,n,e),()=>o.removeEventListener(t,n,e)}function m(o,t,n){null==n?o.removeAttribute(t):o.getAttribute(t)!==n&&o.setAttribute(t,n)}function g(o,t){(null!=t||o.value)&&(o.value=t)}function b(o,t,n,e){o.style.setProperty(t,n,e?"important":"")}let $;function y(o){$=o}function x(){const o=function(){if(!$)throw new Error("Function called outside component initialization");return $}();return(t,n)=>{const e=o.$$.callbacks[t];if(e){const r=function(o,t){const n=document.createEvent("CustomEvent");return n.initCustomEvent(o,!1,!1,t),n}(t,n);e.slice().forEach(t=>{t.call(o,r)})}}}const v=[],w=[],k=[],_=[],S=Promise.resolve();let E=!1;function C(o){k.push(o)}let F=!1;const A=new Set;function z(){if(!F){F=!0;do{for(let o=0;o<v.length;o+=1){const t=v[o];y(t),j(t.$$)}for(v.length=0;w.length;)w.pop()();for(let o=0;o<k.length;o+=1){const t=k[o];A.has(t)||(A.add(t),t())}k.length=0}while(v.length);for(;_.length;)_.pop()();E=!1,F=!1,A.clear()}}function j(o){if(null!==o.fragment){o.update(),r(o.before_update);const t=o.dirty;o.dirty=[-1],o.fragment&&o.fragment.p(o.ctx,t),o.after_update.forEach(C)}}const B=new Set;function H(o,t){o&&o.i&&(B.delete(o),o.i(t))}function N(o,t,n,e){if(o&&o.o){if(B.has(o))return;B.add(o),(void 0).c.push(()=>{B.delete(o),e&&(n&&o.d(1),e())}),o.o(t)}}function P(o,t){-1===o.$$.dirty[0]&&(v.push(o),E||(E=!0,S.then(z)),o.$$.dirty.fill(0)),o.$$.dirty[t/31|0]|=1<<t%31}function q(o,l,i,s,a,u,d=[-1]){const f=$;y(o);const p=l.props||{},h=o.$$={fragment:null,ctx:null,props:u,update:t,not_equal:a,bound:e(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(f?f.$$.context:[]),callbacks:e(),dirty:d};let m=!1;h.ctx=i?i(o,p,(t,n,...e)=>{const r=e.length?e[0]:n;return h.ctx&&a(h.ctx[t],h.ctx[t]=r)&&(h.bound[t]&&h.bound[t](r),m&&P(o,t)),n}):[],h.update(),m=!0,r(h.before_update),h.fragment=!!s&&s(h.ctx),l.target&&(l.hydrate?h.fragment&&h.fragment.l(function(o){return Array.from(o.childNodes)}(l.target)):h.fragment&&h.fragment.c(),l.intro&&H(o.$$.fragment),function(o,t,e){const{fragment:l,on_mount:i,on_destroy:s,after_update:a}=o.$$;l&&l.m(t,e),C(()=>{const t=i.map(n).filter(c);s?s.push(...t):r(t),o.$$.on_mount=[]}),a.forEach(C)}(o,l.target,l.anchor),z()),y(f)}class L{$destroy(){!function(o,t){const n=o.$$;null!==n.fragment&&(r(n.on_destroy),n.fragment&&n.fragment.d(t),n.on_destroy=n.fragment=null,n.ctx=[])}(this,1),this.$destroy=t}$on(o,t){const n=this.$$.callbacks[o]||(this.$$.callbacks[o]=[]);return n.push(t),()=>{const o=n.indexOf(t);-1!==o&&n.splice(o,1)}}$set(){}}function M(o){let t,n;const e=o[7].default,r=i(e,o,o[6],null);return{c(){t=f("div"),r&&r.c(),b(t,"background-color",o[0]),b(t,"color",o[1]),b(t,"padding",o[3]),b(t,"margin",o[2]),b(t,"width",o[4]),b(t,"height",o[5])},m(o,e){u(o,t,e),r&&r.m(t,null),n=!0},p(o,[c]){r&&r.p&&64&c&&r.p(s(e,o,o[6],null),a(e,o[6],c,null)),(!n||1&c)&&b(t,"background-color",o[0]),(!n||2&c)&&b(t,"color",o[1]),(!n||8&c)&&b(t,"padding",o[3]),(!n||4&c)&&b(t,"margin",o[2]),(!n||16&c)&&b(t,"width",o[4]),(!n||32&c)&&b(t,"height",o[5])},i(o){n||(H(r,o),n=!0)},o(o){N(r,o),n=!1},d(o){o&&d(t),r&&r.d(o)}}}function O(o,t,n){let{bg:e=""}=t,{color:r=""}=t,{m:c=""}=t,{p:l=""}=t,{w:i=""}=t,{h:s=""}=t,{$$slots:a={},$$scope:u}=t;return o.$set=o=>{"bg"in o&&n(0,e=o.bg),"color"in o&&n(1,r=o.color),"m"in o&&n(2,c=o.m),"p"in o&&n(3,l=o.p),"w"in o&&n(4,i=o.w),"h"in o&&n(5,s=o.h),"$$scope"in o&&n(6,u=o.$$scope)},[e,r,c,l,i,s,u,a]}const R={breakpoints:[32,40,48,64].map(o=>`${o}em`),primary:{color:"#eeeeee",light:"#ffffff",dark:"#bcbcbc"},secondary:{color:"#212121",light:"#484848",dark:"#bcbcbc"},error:"#dd2c00",boxShadows:["0 0 2px 0 rgba(0,0,0,.08),0 1px 4px 0 rgba(0,0,0,.16)","0 0 2px 0 rgba(0,0,0,.08),0 2px 8px 0 rgba(0,0,0,.16)","0 0 2px 0 rgba(0,0,0,.08),0 4px 16px 0 rgba(0,0,0,.16)","0 0 2px 0 rgba(0,0,0,.08),0 8px 32px 0 rgba(0,0,0,.16)"],font:"Roboto",headline:{fontFamily:"'Fira Sans', Arial, Helvetica, sans-serif",fontSize:"58px"},title:{fontFamily:"'Fira Sans', Arial, Helvetica, sans-serif",fontSize:"36px"},text:{fontFamily:"Roboto, Arial, Helvetica, sans-serif",fontSize:"22px"},sub:{fontFamily:"Roboto, Arial, Helvetica, sans-serif",fontSize:"14px"}};function T(o){let t,n,e;const r=o[9].default,c=i(r,o,o[8],null);return{c(){t=f("div"),c&&c.c(),m(t,"style",n="background-color: "+o[0]+"; color: "+o[1]+"; padding: "+o[3]+"; margin: "+o[2]+";\n width: "+o[4]+"; height: "+o[5]+"; "+o[7][o[6]])},m(o,n){u(o,t,n),c&&c.m(t,null),e=!0},p(o,[l]){c&&c.p&&256&l&&c.p(s(r,o,o[8],null),a(r,o[8],l,null)),(!e||127&l&&n!==(n="background-color: "+o[0]+"; color: "+o[1]+"; padding: "+o[3]+"; margin: "+o[2]+";\n width: "+o[4]+"; height: "+o[5]+"; "+o[7][o[6]]))&&m(t,"style",n)},i(o){e||(H(c,o),e=!0)},o(o){N(c,o),e=!1},d(o){o&&d(t),c&&c.d(o)}}}function D(o,t,n){let{bg:e=""}=t,{color:r=""}=t,{m:c=""}=t,{p:l=""}=t,{w:i=""}=t,{h:s=""}=t,{bs:a="sm"}=t;const u={sm:`box-shadow: ${R.boxShadows[0]}`,md:`box-shadow: ${R.boxShadows[1]}`,lg:`box-shadow: ${R.boxShadows[2]}`,xl:`box-shadow: ${R.boxShadows[3]}`};let{$$slots:d={},$$scope:f}=t;return o.$set=o=>{"bg"in o&&n(0,e=o.bg),"color"in o&&n(1,r=o.color),"m"in o&&n(2,c=o.m),"p"in o&&n(3,l=o.p),"w"in o&&n(4,i=o.w),"h"in o&&n(5,s=o.h),"bs"in o&&n(6,a=o.bs),"$$scope"in o&&n(8,f=o.$$scope)},[e,r,c,l,i,s,a,u,f,d]}function G(o){let t,n,e;const c=o[6].default,l=i(c,o,o[5],null);return{c(){t=f("button"),l&&l.c(),b(t,"color",R.primary.color),b(t,"background-color",o[2]?R.secondary.light:R.secondary.color),b(t,"width",o[0]),b(t,"height",o[1]),m(t,"class","svelte-irnq8f")},m(r,c){u(r,t,c),l&&l.m(t,null),n=!0,e=[h(t,"click",o[3]),h(t,"mouseover",o[7]),h(t,"mouseout",o[8])]},p(o,[e]){l&&l.p&&32&e&&l.p(s(c,o,o[5],null),a(c,o[5],e,null)),(!n||4&e)&&b(t,"background-color",o[2]?R.secondary.light:R.secondary.color),(!n||1&e)&&b(t,"width",o[0]),(!n||2&e)&&b(t,"height",o[1])},i(o){n||(H(l,o),n=!0)},o(o){N(l,o),n=!1},d(o){o&&d(t),l&&l.d(o),r(e)}}}function I(o,t,n){let{w:e=""}=t,{h:r=""}=t,c=!1;const l=x();let{$$slots:i={},$$scope:s}=t;return o.$set=o=>{"w"in o&&n(0,e=o.w),"h"in o&&n(1,r=o.h),"$$scope"in o&&n(5,s=o.$$scope)},[e,r,c,function(o){l("click",o)},l,s,i,o=>{n(2,c=!0)},o=>n(2,c=!1)]}function J(o){let t,n;const e=o[3].default,r=i(e,o,o[2],null);return{c(){t=f("div"),r&&r.c(),b(t,"font-family",R.sub.fontFamily),b(t,"font-size",R.sub.fontSize),b(t,"background-color",o[1][o[0]].backgroundColor),b(t,"color",o[1][o[0]].color),m(t,"class","svelte-s9qmf4")},m(o,e){u(o,t,e),r&&r.m(t,null),n=!0},p(o,[c]){r&&r.p&&4&c&&r.p(s(e,o,o[2],null),a(e,o[2],c,null)),(!n||1&c)&&b(t,"background-color",o[1][o[0]].backgroundColor),(!n||1&c)&&b(t,"color",o[1][o[0]].color)},i(o){n||(H(r,o),n=!0)},o(o){N(r,o),n=!1},d(o){o&&d(t),r&&r.d(o)}}}function K(o,t,n){let{bg:e="black"}=t;const r={red:{backgroundColor:R.error,color:R.primary.color},black:{backgroundColor:R.secondary.color,color:R.primary.color},white:{backgroundColor:R.primary.dark,color:R.secondary.color}};let{$$slots:c={},$$scope:l}=t;return o.$set=o=>{"bg"in o&&n(0,e=o.bg),"$$scope"in o&&n(2,l=o.$$scope)},[e,r,l,c]}function Q(o){let t,n,e;const c=o[3].default,l=i(c,o,o[2],null);return{c(){t=f("a"),l&&l.c(),m(t,"href",o[0]),b(t,"color",o[1]?R.secondary.light:R.secondary.color),b(t,"background-color",o[1]?R.primary.color:""),m(t,"class","svelte-rai5ec")},m(r,c){u(r,t,c),l&&l.m(t,null),n=!0,e=[h(t,"mouseover",o[4]),h(t,"mouseout",o[5])]},p(o,[e]){l&&l.p&&4&e&&l.p(s(c,o,o[2],null),a(c,o[2],e,null)),(!n||1&e)&&m(t,"href",o[0]),(!n||2&e)&&b(t,"color",o[1]?R.secondary.light:R.secondary.color),(!n||2&e)&&b(t,"background-color",o[1]?R.primary.color:"")},i(o){n||(H(l,o),n=!0)},o(o){N(l,o),n=!1},d(o){o&&d(t),l&&l.d(o),r(e)}}}function U(o,t,n){let e=!1,{href:r=""}=t,{$$slots:c={},$$scope:l}=t;return o.$set=o=>{"href"in o&&n(0,r=o.href),"$$scope"in o&&n(2,l=o.$$scope)},[r,e,l,c,o=>n(1,e=!0),o=>n(1,e=!1)]}function V(o){let t,n;return{c(){t=f("input"),m(t,"name",o[1]),m(t,"placeholder",o[2]),b(t,"color",R.secondary.color),b(t,"border-color",R.secondary.color),m(t,"class","svelte-14ma3kv")},m(e,r){u(e,t,r),g(t,o[0]),n=h(t,"input",o[5])},p(o,n){2&n&&m(t,"name",o[1]),4&n&&m(t,"placeholder",o[2]),1&n&&t.value!==o[0]&&g(t,o[0])},d(o){o&&d(t),n()}}}function W(o){let t,n;return{c(){t=f("textarea"),m(t,"name",o[1]),m(t,"placeholder",o[2]),b(t,"color",R.secondary.color),b(t,"border-color",R.secondary.color),m(t,"class","svelte-14ma3kv")},m(e,r){u(e,t,r),g(t,o[0]),n=h(t,"input",o[4])},p(o,n){2&n&&m(t,"name",o[1]),4&n&&m(t,"placeholder",o[2]),1&n&&g(t,o[0])},d(o){o&&d(t),n()}}}function X(o){let n;function e(o,t){return o[3]?W:V}let r=e(o),c=r(o);return{c(){c.c(),n=p()},m(o,t){c.m(o,t),u(o,n,t)},p(o,[t]){r===(r=e(o))&&c?c.p(o,t):(c.d(1),c=r(o),c&&(c.c(),c.m(n.parentNode,n)))},i:t,o:t,d(o){c.d(o),o&&d(n)}}}function Y(o,t,n){let{value:e}=t,{name:r=""}=t,{placeholder:c=""}=t,{textarea:l=!1}=t;return o.$set=o=>{"value"in o&&n(0,e=o.value),"name"in o&&n(1,r=o.name),"placeholder"in o&&n(2,c=o.placeholder),"textarea"in o&&n(3,l=o.textarea)},[e,r,c,l,function(){e=this.value,n(0,e)},function(){e=this.value,n(0,e)}]}o.Badge=class extends L{constructor(o){super(),q(this,o,K,J,l,{bg:0})}},o.Box=class extends L{constructor(o){super(),q(this,o,O,M,l,{bg:0,color:1,m:2,p:3,w:4,h:5})}},o.Button=class extends L{constructor(o){super(),q(this,o,I,G,l,{w:0,h:1})}},o.Card=class extends L{constructor(o){super(),q(this,o,D,T,l,{bg:0,color:1,m:2,p:3,w:4,h:5,bs:6})}},o.FormField=class extends L{constructor(o){super(),q(this,o,Y,X,l,{value:0,name:1,placeholder:2,textarea:3})}},o.Link=class extends L{constructor(o){super(),q(this,o,U,Q,l,{href:0})}},Object.defineProperty(o,"__esModule",{value:!0})}));