@freshworks/crayons
Version:
Crayons Web Components library
1 lines • 5.94 kB
JavaScript
import{c as n,a as r}from"./p-112455b1.js";var t=n((function(n){n.exports=function(){var n,r,t={version:"0.3.5"},e=t.settings={minimum:.08,easing:"linear",positionUsing:"",speed:200,trickle:!0,trickleSpeed:200,showSpinner:!0,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'};function o(n,r,t){return n<r?r:n>t?t:n}function i(n){return 100*(-1+n)}t.configure=function(n){var r,t;for(r in n)void 0!==(t=n[r])&&n.hasOwnProperty(r)&&(e[r]=t);return this},t.status=null,t.set=function(n){var r=t.isStarted();n=o(n,e.minimum,1),t.status=1===n?null:n;var a=t.render(!r),c=a.querySelector(e.barSelector),l=e.speed,f=e.easing;return s((function(r){""===e.positionUsing&&(e.positionUsing=t.getPositioningCSS()),u(c,function(n,r,t){var o;return(o="translate3d"===e.positionUsing?{transform:"translate3d("+i(n)+"%,0,0)"}:"translate"===e.positionUsing?{transform:"translate("+i(n)+"%,0)"}:{"margin-left":i(n)+"%"}).transition="all "+r+"ms "+t,o}(n,l,f)),1===n?(u(a,{transition:"none",opacity:1}),setTimeout((function(){u(a,{transition:"all "+l+"ms linear",opacity:0}),setTimeout((function(){t.remove(),r()}),l)}),l)):setTimeout(r,l)})),this},t.isStarted=function(){return"number"==typeof t.status},t.start=function(){t.status||t.set(0);var n=function(){setTimeout((function(){t.status&&(t.trickle(),n())}),e.trickleSpeed)};return e.trickle&&n(),this},t.done=function(n){return n||t.status?t.inc(.3+.5*Math.random()).set(1):this},t.inc=function(n){var r=t.status;return r?r>1?void 0:("number"!=typeof n&&(n=r>=0&&r<.2?.1:r>=.2&&r<.5?.04:r>=.5&&r<.8?.02:r>=.8&&r<.99?.005:0),r=o(r+n,0,.994),t.set(r)):t.start()},t.trickle=function(){return t.inc()},n=0,r=0,t.promise=function(e){return e&&"resolved"!==e.state()?(0===r&&t.start(),n++,r++,e.always((function(){0==--r?(n=0,t.done()):t.set((n-r)/n)})),this):this},t.getElement=function(){var n=t.getParent();if(n){var r=Array.prototype.slice.call(n.querySelectorAll(".nprogress")).filter((function(r){return r.parentElement===n}));if(r.length>0)return r[0]}return null},t.getParent=function(){return e.parent instanceof HTMLElement?e.parent:"string"==typeof e.parent?document.querySelector(e.parent):void 0},t.render=function(n){if(t.isRendered())return t.getElement();c(document.documentElement,"nprogress-busy");var r=document.createElement("div");r.id="nprogress",r.className="nprogress",r.innerHTML=e.template;var o,s=r.querySelector(e.barSelector),a=n?"-100":i(t.status||0),l=t.getParent();return u(s,{transition:"all 0 linear",transform:"translate3d("+a+"%,0,0)"}),e.showSpinner||(o=r.querySelector(e.spinnerSelector))&&d(o),l!=document.body&&c(l,"nprogress-custom-parent"),l.appendChild(r),r},t.remove=function(){t.status=null,l(document.documentElement,"nprogress-busy"),l(t.getParent(),"nprogress-custom-parent");var n=t.getElement();n&&d(n)},t.isRendered=function(){return!!t.getElement()},t.getPositioningCSS=function(){var n=document.body.style,r="WebkitTransform"in n?"Webkit":"MozTransform"in n?"Moz":"msTransform"in n?"ms":"OTransform"in n?"O":"";return r+"Perspective"in n?"translate3d":r+"Transform"in n?"translate":"margin"};var s=function(){var n=[];function r(){var t=n.shift();t&&t(r)}return function(t){n.push(t),1==n.length&&r()}}(),u=function(){var n=["Webkit","O","Moz","ms"],r={};function t(t){return t=t.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,(function(n,r){return r.toUpperCase()})),r[t]||(r[t]=function(r){var t=document.body.style;if(r in t)return r;for(var e,o=n.length,i=r.charAt(0).toUpperCase()+r.slice(1);o--;)if((e=n[o]+i)in t)return e;return r}(t))}function e(n,r,e){r=t(r),n.style[r]=e}return function(n,r){var t,o,i=arguments;if(2==i.length)for(t in r)void 0!==(o=r[t])&&r.hasOwnProperty(t)&&e(n,t,o);else e(n,i[1],i[2])}}();function a(n,r){return("string"==typeof n?n:f(n)).indexOf(" "+r+" ")>=0}function c(n,r){var t=f(n),e=t+r;a(t,r)||(n.className=e.substring(1))}function l(n,r){var t,e=f(n);a(n,r)&&(t=e.replace(" "+r+" "," "),n.className=t.substring(1,t.length-1))}function f(n){return(" "+(n&&n.className||"")+" ").replace(/\s+/gi," ")}function d(n){n&&n.parentNode&&n.parentNode.removeChild(n)}return t}}));function e(n={}){var r,t,e,o,i,s,u,a;return{parent:null!==(r=n.parent)&&void 0!==r?r:"body",minimum:null!==(t=n.minimum)&&void 0!==t?t:.08,easing:null!==(e=n.easing)&&void 0!==e?e:"ease",speed:null!==(o=n.speed)&&void 0!==o?o:200,trickle:null===(i=n.trickle)||void 0===i||i,trickleSpeed:null!==(s=n.trickleSpeed)&&void 0!==s?s:200,template:null!==(u=n.template)&&void 0!==u?u:'<div class="bar" role="progressbar" aria-valuemin="0" aria-valuemax="1"></div>',show:null!==(a=n.show)&&void 0!==a&&a}}function o(n){const r=Object.assign(Object.assign({},e(n)),{barSelector:'[role="progressbar"]'}),o=t().configure(r);if(!document.querySelector("#fw-progress-bar-style")){const n=document.createElement("style");n.id="fw-progress-bar-style",n.innerHTML="\n .nprogress .bar {\n background: var(--progress-loader-color,#2c5cc5);\n position: fixed;\n z-index: 1031;\n top: 0;\n left: 0;\n width: 100%;\n height: var(--progress-loader-height,2px);\n }\n .nprogress-custom-parent {\n overflow: hidden;\n position: relative;\n }\n .nprogress-custom-parent .nprogress .bar {\n position: absolute;\n }\n ",document.head.appendChild(n)}return{start:i(o.start,r),done:i(o.done,r),set:i(o.set,r),inc:i(o.inc,r)}}function i(n,r){return function(...t){try{if(r.parent&&!document.querySelector(r.parent))return void console.error(`Document Selector ${r.parent} not found`);n.apply(this,t)}catch(e){console.error("Error occurred in calling Progress Loader Functions",e)}}}export{o as c,e as g}