@blaze/atoms
Version:
Open Source UI Toolkit - Atoms
1 lines • 37.3 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function a(t){try{c(i.next(t))}catch(t){o(t)}}function s(t){try{c(i["throw"](t))}catch(t){o(t)}}function c(t){t.done?n(t.value):r(t.value).then(a,s)}c((i=i.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,a;return a={next:s(0),throw:s(1),return:s(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(t){return function(e){return c([t,e])}}function c(a){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,r&&(o=a[0]&2?r["return"]:a[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;if(r=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;r=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=e.call(t,n)}catch(t){a=[6,t];r=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var __spreadArray=this&&this.__spreadArray||function(t,e,n){if(n||arguments.length===2)for(var i=0,r=e.length,o;i<r;i++){if(o||!(i in e)){if(!o)o=Array.prototype.slice.call(e,0,i);o[i]=e[i]}}return t.concat(o||Array.prototype.slice.call(e))};System.register(["./p-3a6c5597.system.js"],(function(t){"use strict";var e,n,i,r;return{setters:[function(t){e=t.r;n=t.c;i=t.h;r=t.g}],execute:function(){var o=t("blaze_accordion",function(){function t(t){e(this,t);this.onToggle=n(this,"toggle",7)}t.prototype.onTogglePane=function(t){var e=this.element.children[0];var n=t.detail;var i=t.target;var r=[].indexOf.call(e.children,i);this.onToggle.emit({idx:r,open:n})};t.prototype.render=function(){return i("div",{class:"c-card c-card--accordion"},i("slot",null))};Object.defineProperty(t.prototype,"element",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var a=t("blaze_accordion_pane",function(){function t(t){e(this,t);this.onToggle=n(this,"togglepane",7);this._isOpen=false;this.open=false}t.prototype.componentWillLoad=function(){this._isOpen=this.open};t.prototype.show=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this._isOpen=true;return[2]}))}))};t.prototype.close=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this._isOpen=false;return[2]}))}))};t.prototype.toggle=function(){this._isOpen?this.close():this.show();this.onToggle.emit(this._isOpen)};t.prototype.isOpen=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this._isOpen]}))}))};t.prototype.render=function(){var t=this;var e=this._isOpen?"c-card__control--active":"";return[i("button",{role:"heading","aria-expanded":this._isOpen.toString(),class:"c-card__control ".concat(e),onClick:function(){return t.toggle()}},this.header),i("section",{"aria-hidden":!this._isOpen,class:"c-card__item c-card__item--pane"},i("slot",null))]};return t}());var s=t("blaze_address",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("address",{class:"c-address"},i("slot",null))};return t}());var c=t("blaze_address_heading",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("span",{class:"c-address__heading"},i("slot",null))};return t}());var u=t("blaze_alert",function(){function t(t){e(this,t);this.onClose=n(this,"close",7);this.type="";this.dismissible=false;this.open=false;this._isOpen=false}t.prototype.close=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this._isOpen=false;this.onClose.emit();return[2]}))}))};t.prototype.show=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this._isOpen=true;return[2]}))}))};t.prototype.isOpen=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this._isOpen]}))}))};t.prototype.componentWillLoad=function(){this._isOpen=this.open};t.prototype.render=function(){var t=this;var e=!this._isOpen?"u-display-none":"";var n=this.type?"c-alert--".concat(this.type):"";return i("div",{role:"alert",hidden:!this._isOpen,class:"c-alert ".concat(n," ").concat(e)},this.dismissible&&i("button",{class:"c-button c-button--close",onClick:function(){return t.close()}},"×"),i("slot",null))};return t}());var l=t("blaze_alerts",function(){function t(t){e(this,t)}t.prototype.render=function(){var t=this.position?"c-alerts--".concat(this.position):"";return i("div",{role:"presentation",class:"c-alerts ".concat(t)},i("slot",null))};return t}());var h=t("blaze_autocomplete",function(){function t(t){e(this,t);this.onSelected=n(this,"selected",7);this.onFilter=n(this,"filter",7);this.items=[]}t.prototype.componentDidLoad=function(){var t=this;document.addEventListener("click",(function(e){e.target!==t.el&&!t.el.contains(e.target)&&t.close()}))};t.prototype.setItems=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.items=t;this.value?this.open():this.close();return[2]}))}))};t.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.items=[];this.value=null;this.close();return[2]}))}))};t.prototype.select=function(t){if(t.disabled)return;this.activeItem=t;this.selectedItem=t;this.value=t.text;this.onSelected.emit(t);this.close()};t.prototype.filter=function(t){this.activeItem=null;this.value=t.target.value;var e=this.value;this.onFilter.emit(e)};t.prototype.open=function(){if(this.items&&this.items.length){this._isOpen=true}};t.prototype.close=function(){this._isOpen=false};t.prototype.handleKeyDown=function(t){var e=this.items.indexOf(this.activeItem);switch(t.key){case"ArrowDown":{t.preventDefault();this.open();if(e<this.items.length-1){this.activeItem=this.items[e+1]}break}case"ArrowUp":{t.preventDefault();this.open();if(e>0&&this._isOpen){this.activeItem=this.items[e-1]}break}case"Enter":{if(this.activeItem){t.preventDefault();this.select(this.activeItem)}}case"Escape":{this.close()}}};t.prototype.render=function(){var t=this;return i("div",{class:"o-field o-field--autocomplete"},i("input",{type:"search",class:"c-field",placeholder:this.placeholder,autocomplete:"off",value:this.value,onInput:function(e){return t.filter(e)},onFocus:function(){return t.open()},onClick:function(){return t.open()}}),this._isOpen&&i("div",{role:"menu",class:"c-card c-card--menu",style:{width:"320px"}},this.items.map((function(e){var n=t.activeItem===e?"c-card__control--active":"";return i("button",{role:"menuitem",class:"c-card__control ".concat(n),onClick:function(){return t.select(e)}},e.text)}))))};Object.defineProperty(t.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var p=t("blaze_avatar",function(){function t(t){e(this,t);this.size=""}t.prototype.render=function(){if(!this.src&&!this.text)return;var t=this.size.length>0?"u-".concat(this.size):"";return i("div",{class:"c-avatar ".concat(t),"data-text":this.text},this.src&&i("img",{class:"c-avatar__img",alt:this.alt,src:this.src}),this.src2&&i("img",{class:"c-avatar__img",alt:this.alt2,src:this.src2}))};return t}());var d=t("blaze_back_to_top",function(){function t(t){e(this,t);this.onBackToTop=n(this,"backtotop",7)}t.prototype.enable=function(){this._isOpen=window.scrollY>window.innerHeight};t.prototype.goUp=function(){window.scrollTo({top:0,behavior:"smooth"});this.onBackToTop.emit()};t.prototype.render=function(){var t=this;var e=!this._isOpen?"u-display-none":"";var n=this.position?"c-back-to-top--".concat(this.position):"";return i("div",{class:"c-back-to-top ".concat(n," ").concat(e)},i("button",{class:"c-button c-button--nude",onClick:function(){t.goUp()}},i("slot",null)))};return t}());var f=t("blaze_badge",function(){function t(t){e(this,t)}t.prototype.render=function(){var t=this.type?"c-badge--".concat(this.type):"";var e=this.rounded?"c-badge--rounded":"";var n=this.ghost?"c-badge--ghost":"";return i("span",{class:"c-badge ".concat(t," ").concat(e," ").concat(n)},i("slot",null))};return t}());var _=t("blaze_calendar",function(){function t(t){e(this,t);this.onSelected=n(this,"selected",7);this.multiple=false;this._date=new Date;this._selectedDates=[];this.days=["Su","Mo","Tu","We","Th","Fr","Sa"];this.months=["January","February","March","April","May","June","July","August","September","October","November","December"];this.buttonType=""}t.prototype.componentWillLoad=function(){var t=this.date||new Date;this._date=new Date(t);this._selectedDates=__spreadArray(__spreadArray([],this._selectedDates,true),[this._date],false);this.buttonType=this.type?"c-button--".concat(this.type):""};t.prototype.getMonthName=function(){return this.months[this._date.getMonth()]};t.prototype.getFirstDay=function(){return new Date(this._date.getFullYear(),this._date.getMonth(),1).getDay()};t.prototype.getLastDay=function(){return new Date(this._date.getFullYear(),this._date.getMonth()+1,0).getDay()};t.prototype.getTotalDaysInMonth=function(t){if(t===void 0){t=0}return new Date(this._date.getFullYear(),this._date.getMonth()+1+t,0).getDate()};t.prototype.selectDate=function(t){if(this._selectedDates.filter((function(e){return e.toDateString()===t.toDateString()})).length){this._selectedDates=this._selectedDates.filter((function(e){return e.toDateString()!==t.toDateString()}))}else{if(this.multiple){this._selectedDates=__spreadArray(__spreadArray([],this._selectedDates,true),[t],false)}else{this._selectedDates=[t]}}this.onSelected.emit(this._selectedDates.map((function(t){return t.toDateString()})).toString())};t.prototype.renderDayButton=function(t){var e=this;var n=t.toDateString()===(new Date).toDateString();var r=!!this._selectedDates.filter((function(e){return e.toDateString()===t.toDateString()})).length;var o=t.getMonth()===this._date.getMonth()?"c-calendar__date--in-month":"";var a=r?"c-calendar__date--selected ".concat(this.buttonType):"";return i("button",{class:"c-calendar__date ".concat(o," c-button ").concat(a),"aria-current":n&&"date","aria-selected":r.toString(),onClick:function(){return e.selectDate(t)}},t.getDate())};t.prototype.populateDaysPreviousMonth=function(){var t=[];var e=this.getTotalDaysInMonth(-1);for(var n=e;n>e-this.getFirstDay();n--){var i=new Date(this._date);i.setMonth(this._date.getMonth()-1);i.setDate(n);var r=new Date(i);t.unshift(this.renderDayButton(r))}return t};t.prototype.populateDaysCurrentMonth=function(){var t=[];var e=new Date(this._date.getFullYear(),this._date.getMonth()+1,0).getDate();for(var n=1;n<=e;n++){var i=new Date(this._date);i.setDate(n);var r=new Date(i);t.push(this.renderDayButton(r))}return t};t.prototype.populateDaysNextMonth=function(){var t=[];for(var e=1;e<7-this.getLastDay();e++){var n=new Date(this._date);n.setDate(e);n.setMonth(this._date.getMonth()+1);var i=new Date(n);t.push(this.renderDayButton(i))}return t};t.prototype.navYear=function(t){var e=new Date(this._date);e.setFullYear(this._date.getFullYear()+t);this._date=new Date(e)};t.prototype.navMonth=function(t){var e=new Date(this._date);e.setMonth(this._date.getMonth()+t);this._date=new Date(e)};t.prototype.today=function(){this.selectDate(new Date);this._date=new Date};t.prototype.render=function(){var t=this;return i("div",{class:"c-calendar"},i("button",{class:"c-calendar__control c-calendar__control--prev-year",onClick:function(){return t.navYear(-1)}},"‹"),i("div",{class:"c-calendar__header c-calendar__header--year"},this._date.getFullYear()),i("button",{class:"c-calendar__control c-calendar__control--next-year",onClick:function(){return t.navYear(1)}},"›"),i("button",{class:"c-calendar__control c-calendar__control--prev-month",onClick:function(){return t.navMonth(-1)}},"‹"),i("div",{class:"c-calendar__header c-calendar__header--month"},this.getMonthName()),i("button",{class:"c-calendar__control c-calendar__control--next-month",onClick:function(){return t.navMonth(1)}},"›"),this.days.map((function(t){return i("div",{class:"c-calendar__day"},t)})),this.populateDaysPreviousMonth(),this.populateDaysCurrentMonth(),this.populateDaysNextMonth(),i("div",{class:"c-calendar__footer"},i("button",{class:"c-calendar__today c-button c-button--block ".concat(this.buttonType),onClick:function(){return t.today()}},"Today")))};return t}());var g=t("blaze_card",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("div",{class:"c-card"},i("slot",null))};return t}());var m=t("blaze_card_body",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("div",{class:"c-card__body"},i("slot",null))};return t}());var v=t("blaze_card_footer",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("footer",{class:"c-card__footer"},i("slot",null))};return t}());var y=t("blaze_card_header",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("header",{class:"c-card__header"},i("slot",null))};return t}());var b=function(t,e,n,i,r,o){var a=this;a.version=function(){return"1.9.3"};a.options={useEasing:true,useGrouping:true,separator:",",decimal:".",easingFn:p,formattingFn:h,prefix:"",suffix:"",numerals:[]};if(o&&typeof o==="object"){for(var s in a.options){if(o.hasOwnProperty(s)&&o[s]!==null){a.options[s]=o[s]}}}if(a.options.separator===""){a.options.useGrouping=false}else{a.options.separator=""+a.options.separator}var c=0;var u=["webkit","moz","ms","o"];for(var l=0;l<u.length&&!window.requestAnimationFrame;++l){window.requestAnimationFrame=window[u[l]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[u[l]+"CancelAnimationFrame"]||window[u[l]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(t){var e=(new Date).getTime();var n=Math.max(0,16-(e-c));var i=window.setTimeout((function(){t(e+n)}),n);c=e+n;return i}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(t){clearTimeout(t)}}function h(t){var e=t<0,n,i,r,o,s,c;t=Math.abs(t).toFixed(a.decimals);t+="";n=t.split(".");i=n[0];r=n.length>1?a.options.decimal+n[1]:"";if(a.options.useGrouping){o="";for(s=0,c=i.length;s<c;++s){if(s!==0&&s%3===0){o=a.options.separator+o}o=i[c-s-1]+o}i=o}if(a.options.numerals.length){i=i.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]}));r=r.replace(/[0-9]/g,(function(t){return a.options.numerals[+t]}))}return(e?"-":"")+a.options.prefix+i+r+a.options.suffix}function p(t,e,n,i){return n*(-Math.pow(2,-10*t/i)+1)*1024/1023+e}function d(t){return typeof t==="number"&&!isNaN(t)}a.initialize=function(){if(a.initialized)return true;a.error="";a.d=typeof t==="string"?document.getElementById(t):t;if(!a.d){a.error="[CountUp] target is null or undefined";return false}a.startVal=Number(e);a.endVal=Number(n);if(d(a.startVal)&&d(a.endVal)){a.decimals=Math.max(0,i||0);a.dec=Math.pow(10,a.decimals);a.duration=Number(r)*1e3||2e3;a.countDown=a.startVal>a.endVal;a.frameVal=a.startVal;a.initialized=true;return true}else{a.error="[CountUp] startVal ("+e+") or endVal ("+n+") is not a number";return false}};a.printValue=function(t){var e=a.options.formattingFn(t);if(a.d.tagName==="INPUT"){this.d.value=e}else if(a.d.tagName==="text"||a.d.tagName==="tspan"){this.d.textContent=e}else{this.d.innerHTML=e}};a.count=function(t){if(!a.startTime){a.startTime=t}a.timestamp=t;var e=t-a.startTime;a.remaining=a.duration-e;if(a.options.useEasing){if(a.countDown){a.frameVal=a.startVal-a.options.easingFn(e,0,a.startVal-a.endVal,a.duration)}else{a.frameVal=a.options.easingFn(e,a.startVal,a.endVal-a.startVal,a.duration)}}else{if(a.countDown){a.frameVal=a.startVal-(a.startVal-a.endVal)*(e/a.duration)}else{a.frameVal=a.startVal+(a.endVal-a.startVal)*(e/a.duration)}}if(a.countDown){a.frameVal=a.frameVal<a.endVal?a.endVal:a.frameVal}else{a.frameVal=a.frameVal>a.endVal?a.endVal:a.frameVal}a.frameVal=Math.round(a.frameVal*a.dec)/a.dec;a.printValue(a.frameVal);if(e<a.duration){a.rAF=requestAnimationFrame(a.count)}else{if(a.callback)a.callback()}};a.start=function(t){if(!a.initialize())return;a.callback=t;a.rAF=requestAnimationFrame(a.count)};a.pauseResume=function(){if(!a.paused){a.paused=true;cancelAnimationFrame(a.rAF)}else{a.paused=false;delete a.startTime;a.duration=a.remaining;a.startVal=a.frameVal;requestAnimationFrame(a.count)}};a.reset=function(){a.paused=false;delete a.startTime;a.initialized=false;if(a.initialize()){cancelAnimationFrame(a.rAF);a.printValue(a.startVal)}};a.update=function(t){if(!a.initialize())return;t=Number(t);if(!d(t)){a.error="[CountUp] update() - new endVal is not a number: "+t;return}a.error="";if(t===a.frameVal)return;cancelAnimationFrame(a.rAF);a.paused=false;delete a.startTime;a.startVal=a.frameVal;a.endVal=t;a.countDown=a.startVal>a.endVal;a.rAF=requestAnimationFrame(a.count)};if(a.initialize())a.printValue(a.startVal)};var w=t("blaze_counter",function(){function t(t){e(this,t);this.onFinish=n(this,"finish",7);this.startValue=0;this.decimals=0;this.duration=4;this.delay=500;this.easing=true;this.grouping=true;this.separator=",";this.decimal="."}t.prototype.componentDidLoad=function(){var t=this.el.querySelector(".c-counter__amount");this.animation=new b(t,this.startValue,this.endValue,this.decimals,this.duration,{useEasing:this.easing,useGrouping:this.grouping,separator:this.separator,decimal:this.decimal});if(this.autoStart){this.start()}};t.prototype.start=function(){return __awaiter(this,void 0,void 0,(function(){var t=this;return __generator(this,(function(e){this.timer=setTimeout((function(){t.animation.start((function(){t.onFinish.emit()}))}),this.delay);return[2]}))}))};t.prototype.disconnectedCallback=function(){clearTimeout(this.timer)};t.prototype.reset=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.animation.reset();return[2]}))}))};t.prototype.update=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.animation.update(t);return[2]}))}))};t.prototype.restart=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.animation.reset();this.animation.start();return[2]}))}))};t.prototype.pauseResume=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.animation.pauseResume();return[2]}))}))};t.prototype.render=function(){return i("div",{class:"c-counter"},i("span",{class:"c-counter__prefix"},i("slot",{name:"prefix"})),i("span",{class:"c-counter__amount"}),i("span",{class:"c-counter__suffix"},i("slot",{name:"suffix"})))};Object.defineProperty(t.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var D=t("blaze_demo",function(){function t(t){e(this,t);this.classes="";this.language="";this.demo=true}t.prototype.componentWillLoad=function(){this.markup=this.code};t.prototype.updateDemo=function(t){this.markup=t.target.innerText};t.prototype.highlight=function(){if(typeof hljs!=="undefined"){hljs.highlightElement(this.codeRef)}};t.prototype.componentDidUpdate=function(){this.highlight()};t.prototype.componentDidLoad=function(){this.highlight()};t.prototype.render=function(){var t=this;return[this.demo&&i("div",{"aria-label":"Demo component",class:"demo-markup-source u-letter-box-small ".concat(this.classes),innerHTML:this.markup}),i("div",{class:"u-letter-box-small"},i("pre",{class:"u-pre"},i("code",{ref:function(e){return t.codeRef=e},"aria-hidden":true,tabindex:"-1",class:"u-code u-code--multiline ".concat(this.language),contenteditable:this.demo,onBlur:function(e){return t.updateDemo(e)}},this.markup)))]};return t}());var x=t("blaze_divider",function(){function t(t){e(this,t);this.type="solid"}t.prototype.componentWillLoad=function(){this.content=!!this.el.innerHTML};t.prototype.render=function(){var t=this.type?"c-divider--".concat(this.type):"";return i("div",{class:"c-divider ".concat(t)},this.content&&i("span",{class:"c-divider__content"},i("slot",null)))};Object.defineProperty(t.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var V=t("blaze_drawer",function(){function t(t){e(this,t);this.onClose=n(this,"close",7);this.open=false;this.dismissible=false;this.position="bottom";this._isOpen=false}t.prototype.close=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(!this.shouldClose||this.shouldClose()){this._isOpen=false;this.onClose.emit()}return[2]}))}))};t.prototype.show=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this._isOpen=true;return[2]}))}))};t.prototype.isOpen=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this._isOpen]}))}))};t.prototype.componentWillLoad=function(){this._isOpen=this.open};t.prototype.dismiss=function(){if(this.dismissible)this.close()};t.prototype.render=function(){var t=this;var e=this._isOpen?"o-drawer--visible":"";var n=this._isOpen?"c-overlay--visible":"";return[i("div",{"aria-hidden":"true",onClick:function(){return t.dismiss()},class:"c-overlay c-overlay--fullpage ".concat(n)}),i("aside",{"aria-expanded":this.isOpen.toString(),class:"o-drawer o-drawer--".concat(this.position," ").concat(e)},i("slot",null))]};return t}());var k=t("blaze_file_upload",function(){function t(t){e(this,t);this.onUploaded=n(this,"uploaded",7);this.onUploading=n(this,"uploading",7);this.url="/";this.files=[]}t.prototype.uploadFiles=function(t){return __awaiter(this,void 0,void 0,(function(){var e;var n=this;return __generator(this,(function(i){switch(i.label){case 0:this.files=Array.from(t.target.files);if(!this.drop)return[3,4];i.label=1;case 1:i.trys.push([1,3,,4]);this.onUploading.emit({files:this.files});return[4,Promise.all(this.files.map((function(t){return fetch(n.url,{method:"POST",body:t})})))];case 2:i.sent();this.onUploaded.emit({upload:true,files:this.files});return[3,4];case 3:e=i.sent();this.onUploaded.emit({upload:false,error:e});return[3,4];case 4:return[2]}}))}))};t.prototype.renderLabel=function(){if(!this.drop&&this.files.length>0){if(this.multiple)return i("span",null,this.files.length," files");return i("span",null,this.files[0].name)}};t.prototype.render=function(){var t=this;var e=this.drop?"c-file-upload--drop":"";return i("div",{class:"c-file-upload ".concat(e)},i("slot",null),this.renderLabel(),i("input",{type:"file",multiple:this.multiple,onChange:function(e){return t.uploadFiles(e)}}))};return t}());var O=t("blaze_image",function(){function t(t){e(this,t);this.filter=""}t.prototype.generateSrc=function(){if(this.src)return this.src;var t="";if(this.width&&this.height){t="".concat(this.width,"x").concat(this.height,"/")}var e="";if(this.filter){e="?".concat(this.filter)}if(this.photo){return"https://source.unsplash.com/".concat(this.photo,"/").concat(t)}if(this.user){return this.likes?"https://source.unsplash.com/user/".concat(this.user,"/likes/").concat(t).concat(e):"https://source.unsplash.com/user/".concat(this.user,"/").concat(t).concat(e)}if(this.collection){return"https://source.unsplash.com/collection/".concat(this.collection,"/").concat(t).concat(e)}return"https://source.unsplash.com/random/".concat(t).concat(e)};t.prototype.componentDidLoad=function(){var t=this;if("IntersectionObserver"in window){this.io=new IntersectionObserver((function(e){if(e[0].isIntersecting){t.loadImage();t.cleanup()}}));this.io.observe(this.el)}else{this.loadImage()}};t.prototype.disconnectedCallback=function(){this.cleanup()};t.prototype.loadImage=function(){this._src=this.generateSrc()};t.prototype.cleanup=function(){if(this.io){this.io.disconnect();this.io=null}};t.prototype.render=function(){return i("img",{class:"o-image",src:this._src,alt:this.alt})};Object.defineProperty(t.prototype,"el",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var C=t("blaze_media_body",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("div",{class:"o-media__body"},i("slot",null))};return t}());var z=t("blaze_media_image",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("div",{class:"o-media__image"},i("img",{class:"o-image",alt:this.alt,src:this.src}))};return t}());var T=t("blaze_media_item",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("div",{class:"c-card__item o-media"},i("slot",null))};return t}());var F=t("blaze_modal",function(){function t(t){e(this,t);this.onClose=n(this,"close",7);this.ghost=false;this.full=false;this.open=false;this.dismissible=false}t.prototype.close=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){if(!this.shouldClose||this.shouldClose()){this.open=false;this.onClose.emit()}return[2]}))}))};t.prototype.show=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.open=true;return[2]}))}))};t.prototype.isOpen=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.open]}))}))};t.prototype.dismiss=function(){if(this.dismissible)this.close()};t.prototype.render=function(){var t=this;var e=this.ghost?"o-modal--ghost":"";var n=this.full?"o-modal--full":"";var r=this.open?"o-modal--visible":"";var o=this.open?"c-overlay--visible":"";return[i("div",{"aria-hidden":true,onClick:function(){return t.dismiss()},class:"c-overlay c-overlay--fullpage ".concat(o)}),i("div",{role:"dialog",class:"o-modal ".concat(e," ").concat(n," ").concat(r)},this.dismissible&&i("button",{type:"button",class:"c-button c-button--close",onClick:function(){return t.close()}},"×"),i("slot",null))]};Object.defineProperty(t.prototype,"elem",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var A=t("blaze_pagination",function(){function t(t){e(this,t);this.onPage=n(this,"page",7);this.page=1;this.pages=1}t.prototype.goToPage=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(t>0&&t<=this.pages){this._currentPage=t;this.onPage.emit(this._currentPage)}return[2]}))}))};t.prototype.currentPage=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this._currentPage]}))}))};t.prototype.componentWillLoad=function(){this._currentPage=this.page};t.prototype.render=function(){var t=this;return i("nav",{class:"c-pagination"},i("button",{class:"c-pagination__control",onClick:function(){return t.goToPage(t._currentPage-1)},disabled:this._currentPage===1},"‹"),i("div",{class:"c-pagination__pages"},this._currentPage>1&&i("button",{onClick:function(){return t.goToPage(t._currentPage-1)},class:"c-pagination__control"},this._currentPage-1),i("button",{class:"c-pagination__control","aria-current":true},this._currentPage),this._currentPage<this.pages&&i("button",{onClick:function(){return t.goToPage(t._currentPage+1)},class:"c-pagination__control"},this._currentPage+1)),i("button",{class:"c-pagination__control",onClick:function(){return t.goToPage(t._currentPage+1)},disabled:this._currentPage===this.pages},"›"))};return t}());var P=t("blaze_panel",function(){function t(t){e(this,t);this.height=0}t.prototype.render=function(){return i("div",{class:"o-panel-container",style:{height:"".concat(this.height,"px")}},i("div",{class:"o-panel"},i("slot",null)))};return t}());var S=t("blaze_progress",function(){function t(t){e(this,t);this.onChanged=n(this,"changed",7)}t.prototype.onChangeBar=function(t){var e=this.element.children[0];var n=t.detail;var i=t.target;var r=[].indexOf.call(e.children,i);this.onChanged.emit(Object.assign({idx:r},n))};t.prototype.render=function(){var t=this.size?"u-".concat(this.size):"";var e=this.rounded?"c-progress--rounded":"";var n=this.timer?"c-progress--timer":"";return i("div",{class:"c-progress ".concat(e," ").concat(n," ").concat(t)},i("slot",null))};Object.defineProperty(t.prototype,"element",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var M=t("blaze_progress_bar",function(){function t(t){e(this,t);this.onChanged=n(this,"progressbar",7);this.min=0;this.max=100;this.duration=0}t.prototype.watchValue=function(t,e){this.onChanged.emit({value:t,oldValue:e})};t.prototype.render=function(){var t=this.type?"c-progress__bar--".concat(this.type):"";var e=(this.value-this.min)/(this.max-this.min)*100;var n=this.duration?{animationDuration:"".concat(this.duration,"s")}:{};return i("div",{role:"progressbar","aria-valuenow":this.value,"aria-valuemin":this.min,"aria-valuemax":this.max,style:Object.assign({width:"".concat(e,"%")},n),class:"c-progress__bar ".concat(t)},i("slot",null))};Object.defineProperty(t,"watchers",{get:function(){return{value:["watchValue"]}},enumerable:false,configurable:true});return t}());var I=t("blaze_sticky",function(){function t(t){e(this,t);this.top=0}t.prototype.componentWillUpdate=function(){this.positionElement()};t.prototype.positionElement=function(){this.dimensions=this.elem.children[0].getBoundingClientRect();this.offsetTop=this.dimensions.top+window.scrollY;if(this.offsetTop-window.scrollY-this.top<=0){this.staticStyles={width:"".concat(this.dimensions.width,"px"),height:"".concat(this.dimensions.height,"px")};this.stickyStyles={position:"fixed",top:"".concat(this.top,"px"),left:"".concat(this.dimensions.left,"px"),width:"".concat(this.dimensions.width,"px")}}else{this.staticStyles={};this.stickyStyles={}}};t.prototype.render=function(){return i("div",{style:this.staticStyles},i("div",{style:this.stickyStyles},i("slot",null)))};Object.defineProperty(t.prototype,"elem",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var L=t("blaze_tab",function(){function t(t){e(this,t)}t.prototype.render=function(){var t=this.type?"c-tabs__tab--".concat(this.type):"";return i("div",{role:"tabpanel",hidden:!this.open,class:"c-tabs__tab ".concat(t)},i("slot",null))};return t}());var E=t("blaze_tabs",function(){function t(t){e(this,t);this.onTab=n(this,"tab",7)}t.prototype.componentWillLoad=function(){this.tabs=Array.from(this.elem.querySelectorAll("blaze-tab"))};t.prototype.currentTab=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.tabs.findIndex((function(t){return t.open}))]}))}))};t.prototype.openTab=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(!this.tabs[t].disabled){this.tabs=this.tabs.map((function(t){t.open=false;return t}));this.tabs[t].open=true;this.onTab.emit({idx:t})}return[2]}))}))};t.prototype.render=function(){var t=this;return i("div",{class:"c-tabs"},i("div",{role:"tablist",class:"c-tabs"},i("div",{class:"c-tabs__nav"},i("div",{class:"c-tabs__headings"},this.tabs.map((function(e,n){var r=e.open?"c-tab-heading--active":"";var o=e.type?"c-tab-heading--".concat(e.type):"";return i("button",{role:"tab",disabled:e.disabled,class:"c-tab-heading ".concat(o," ").concat(r),onClick:function(){return t.openTab(n)}},e.header)})))),i("slot",null)))};Object.defineProperty(t.prototype,"elem",{get:function(){return r(this)},enumerable:false,configurable:true});return t}());var j=t("blaze_tags",function(){function t(t){e(this,t);this.onAdd=n(this,"add",7);this.onFilter=n(this,"filter",7);this.choices=[];this.inputValue=""}t.prototype.setOptions=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){if(t)this._options=t;else if(this.options)this._options=JSON.parse(this.options);if(this.autocompleteRef){return[2,this.autocompleteRef.setItems(this._options)]}return[2]}))}))};t.prototype.componentWillLoad=function(){this.setOptions();this._placeholder=this.placeholder;if(!this._placeholder)this._placeholder=this.options?"Select an option":"Add a tag"};t.prototype.addChoice=function(t){this.choices=__spreadArray(__spreadArray([],this.choices,true),[t],false);this.onAdd.emit(t);if(this.optionRef)this.optionRef.selected=true;this.inputValue=""};t.prototype.select=function(t){t.preventDefault();var e=t.target.value||t.detail.value;if(typeof e==="undefined")return;var n=this._options.find((function(t){return t.value===e}));if(n){this.addChoice(n)}if(this.autocompleteRef)this.autocompleteRef.reset()};t.prototype.handleInput=function(t){this.inputValue=t.target.value};t.prototype.handleEnter=function(t){if(t.key==="Enter"&&this.inputValue){t.preventDefault();var e={text:this.inputValue};this.addChoice(e)}};t.prototype.removeChoice=function(t){this.choices.splice(t,1);this.choices=__spreadArray([],this.choices,true)};t.prototype.filter=function(t){this.onFilter.emit(t.detail)};t.prototype.renderAutocomplete=function(){var t=this;return i("blaze-autocomplete",{ref:function(e){return t.autocompleteRef=e},onFilter:function(e){return t.filter(e)},placeholder:this._placeholder,onSelected:function(e){return t.select(e)}})};t.prototype.renderDropdown=function(){var t=this;return i("select",{class:"c-field",onChange:function(e){return t.select(e)}},i("option",{ref:function(e){return t.optionRef=e}},this._placeholder),this._options.map((function(t){return i("option",{value:t.value},t.text)})))};t.prototype.renderInput=function(){var t=this;return i("input",{type:"text",class:"c-field",placeholder:this._placeholder,value:this.inputValue,onInput:function(e){return t.handleInput(e)},onKeyDown:function(e){return t.handleEnter(e)}})};t.prototype.renderField=function(){if(this.autocomplete)return this.renderAutocomplete();if(this.options)return this.renderDropdown();return this.renderInput()};t.prototype.render=function(){var t=this;return i("div",{class:"c-tags"},i("div",{class:"c-tags__container"},this.choices.map((function(e,n){return i("button",{type:"button",class:"c-button c-tag",onClick:function(){return t.removeChoice(n)}},e.text)}))),i("div",{class:"c-tags__field-container"},this.renderField()))};return t}());var N=t("blaze_timeline",function(){function t(t){e(this,t)}t.prototype.render=function(){var t=this.alternate?"o-timeline--alternate":"";var e=this.loading?"o-timeline--loading":"";return i("ol",{class:"o-timeline ".concat(t," ").concat(e)},i("slot",null))};return t}());var R=t("blaze_timeline_item",function(){function t(t){e(this,t)}t.prototype.render=function(){var t=this.type?"c-timeline-item--".concat(this.type):"";var e=this.last?"c-timeline-item--last":"";var n=this.left?"c-timeline-item--left":"";var r=this.loading&&!this.last?"c-timeline-item--loading":"";return i("li",{class:"c-timeline-item ".concat(t," ").concat(n," ").concat(e," ").concat(r)},i("div",{class:"c-timeline-item__body"},i("slot",null)))};return t}());var U=t("blaze_toggle",function(){function t(t){e(this,t);this.onToggle=n(this,"toggle",7);this.toggled=false;this._toggled=false}t.prototype.componentWillLoad=function(){this._toggled=this.toggled};t.prototype.isToggled=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this._toggled]}))}))};t.prototype.toggle=function(){this._toggled=!this._toggled};t.prototype.handleToggle=function(t){t.preventDefault();this.toggle();this.onToggle.emit(this._toggled)};t.prototype.render=function(){var t=this;var e=this.type?"c-toggle--".concat(this.type):"";return i("label",{class:"c-toggle ".concat(e),onClick:function(e){return t.handleToggle(e)}},i("input",{type:"checkbox","aria-checked":this._toggled.toString(),checked:this._toggled}),i("div",{class:"c-toggle__track"},i("div",{class:"c-toggle__handle"})),i("slot",null))};Object.defineProperty(t,"watchers",{get:function(){return{toggled:["toggle"]}},enumerable:false,configurable:true});return t}());var Y=t("blaze_tree",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("div",{role:"tree",class:"c-tree"},i("slot",null))};return t}());var q=t("blaze_tree_branch",function(){function t(t){e(this,t);this.onExpand=n(this,"expand",7);this.onCollapse=n(this,"collapse",7);this.expanded=false}t.prototype.toggleExpanded=function(){this.expanded=!this.expanded;if(this.expanded)this.onExpand.emit();else this.onCollapse.emit()};t.prototype.expand=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.expanded=true;return[2]}))}))};t.prototype.collapse=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.expanded=false;return[2]}))}))};t.prototype.render=function(){var t=this;return[i("button",{role:"treeitem","aria-expanded":this.expanded.toString(),class:"c-tree__item",onClick:function(){return t.toggleExpanded()}},i("slot",{name:"branch"})),i("div",{role:"tree",class:"c-tree"},i("slot",{name:"leaf"}))]};return t}());var W=t("blaze_tree_leaf",function(){function t(t){e(this,t)}t.prototype.render=function(){return i("span",{role:"treeitem",class:"c-tree__item"},i("slot",null))};return t}())}}}));