ucsd-cse112/team13

View on GitHub
dist/core-slider.js

Summary

Maintainability
A
0 mins
Test Coverage
!function(t,e,n,o,r,i){if("customElements"in t)i();else{if(t.WC_ENV)return void t.WC_ENV.then(i);var a=function(t,n){var o=e.createElement("script");o.type="text/javascript",o.readyState?o.onreadystatechange=function(){"loaded"!=o.readyState&&"complete"!=o.readyState||(o.onreadystatechange=null,n())}:o.onload=function(){n()},o.src=t,e.getElementsByTagName("head")[0].appendChild(o)},u=t.WC_ENV=(d=function(t){try{t()}catch(t){console.error(t)}},(h=[]).isDone=!1,h.exec=function(){h.splice(0).forEach(d)},h.then=function(t){return h.isDone?t():h.push(t),h},h);u.then(i);var c=t.WC_POLYFILL||"//cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.0.2/webcomponents-bundle.js",s=0,l=function(){--s||(u.isDone=!0,u.exec())};"Reflect"in t||t.SKIP_ES_POLYFILL?(s++,a(c,l)):(s++,a(t.ES_POLYFILL||"//cdnjs.cloudflare.com/ajax/libs/core-js/2.5.3/core.min.js",function(){a(c,l)}),function(){try{new Function("function* test() {}")()}catch(t){return!1}return!0}()||t.regeneratorRuntime||(s++,a(window.GE_POLYFILL||o,l)))}var h,d}(window,document,0,"//unpkg.com/regenerator-runtime@0.12.1/runtime.js",0,function(){!function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=13)}([function(t,e,n){"use strict";function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{mode:"open"},o=t.attachShadow(n);return e&&o.appendChild(e.content.cloneNode(!0)),o}var r=Symbol("stopPropagateUpdate"),i=Symbol("ATTRIBUTE_SIDE"),a=Symbol("PROPERTY_SIDE");function u(t,e){switch(t||String){case Object:return JSON.parse(e);case Boolean:return null!==e||void 0!==e;default:return"function"==typeof t?t(e):e}}function c(t,e,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(n.type!==Boolean){var r=function(t,e){switch(t||String){case Object:return JSON.stringify(e);default:return e}}(n.type,o);t.setAttribute(e,r)}else o?t.setAttribute(e,""):t.removeAttribute(e)}function s(t,e,n,o,u,s){t[r]||(t[r]=!0,s===i?t[e]=u:s===a&&t.isConnected&&n.reflect&&c(t,n.attribute,n,u),"function"==typeof t.propertyChangedCallback&&t.propertyChangedCallback(e,o,u),t[r]=!1)}function l(t,e){var n="__".concat(t);return{get:function(){var t;return t=e.attributeOnly?function(t,e,n){var o=n.type;return o===Boolean?t.hasAttribute(e):u(o,t.getAttribute(e))}(this,e.attribute,e):this[n],e.get&&(t=e.get.call(this,t)),t},set:function(o){var r=this[t];e.set&&(o=e.set.call(this,o,r)),r!==o&&(e.attributeOnly?c(this,e.attribute,e,o):this[n]=o,s(this,t,e,r,o,a))},configurable:!0,enumerable:!0}}function h(t,e,n){var o=l(e,n);if(t.hasOwnProperty(e)){var r=t[e];delete t[e],o.set.call(t,r)}var i=Object.getOwnPropertyDescriptor(t,e);if(i){if("function"==typeof i.get)throw new Error("Found conflicting getter for instance.");if("function"==typeof i.set)throw new Error("Found conflicting setter for instance.")}Object.defineProperty(t,e,o)}function d(t){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function b(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function v(t,e,n){return e&&b(t.prototype,e),n&&b(t,n),t}function m(t,e){return(m=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function y(){return Reflect.construct(HTMLElement,[],this.__proto__.constructor)}function g(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],o=!0,r=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(o=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);o=!0);}catch(t){r=!0,i=t}finally{try{o||null==u.return||u.return()}finally{if(r)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}Object.setPrototypeOf(y.prototype,HTMLElement.prototype),Object.setPrototypeOf(y,HTMLElement);var w=Symbol("classProperties");function k(t){return t.hasOwnProperty(w)}function S(t,e,n){void 0===n.attribute&&(n.attribute=function(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}(e));var o=t[w];o.options.set(e,n),n.attribute&&o.attributes.set(n.attribute,e)}function O(t){if(!k(t)&&(function(t){var e,n,o=Object.getPrototypeOf(t);if("function"==typeof o.buildProperties&&o.buildProperties(),o&&k(o)){var r=o[w];e=new Map(r.options),n=new Map(r.attributes)}else e=new Map,n=new Map;t[w]={options:e,attributes:n}}(t),t.hasOwnProperty("properties"))){var e=!0,n=!1,o=void 0;try{for(var r,i=Object.getOwnPropertyNames(t.properties)[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var a=r.value;S(t,a,t.properties[a])}}catch(t){n=!0,o=t}finally{try{e||null==i.return||i.return()}finally{if(n)throw o}}}}var T=function(t){function e(){var t,n,r,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=this,t=!(r=f(e).call(this))||"object"!==d(r)&&"function"!=typeof r?p(n):r,o(p(t),i),function(t){var e=t.constructor[w],n=!0,o=!1,r=void 0;try{for(var i,a=e.options.entries()[Symbol.iterator]();!(n=(i=a.next()).done);n=!0){var u=g(i.value,2);h(t,u[0],u[1])}}catch(t){o=!0,r=t}finally{try{n||null==a.return||a.return()}finally{if(o)throw r}}}(p(t)),t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&m(t,e)}(e,y),v(e,null,[{key:"buildProperties",value:function(){O(this)}},{key:"observedAttributes",get:function(){return this.buildProperties(),Array.from(this[w].attributes.keys())}}]),v(e,[{key:"attributeChangedCallback",value:function(t,e,n){!function(t,e,n,o){if(n!==o){var r=t.constructor[w];if(r.attributes.has(e)){var a=r.attributes.get(e),c=r.options.get(a);s(t,a,c,c.attributeOnly?u(c.type,n):t[a],u(c.type,o),i)}}}(this,t,e,n)}},{key:"connectedCallback",value:function(){}},{key:"disconnectedCallback",value:function(){}},{key:"adoptedCallback",value:function(){}},{key:"propertyChangedCallback",value:function(){}}]),e}();T.templateNode=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n="<template><style>".concat(e.toString(),"</style>").concat(t,"</template>"),o=document.createRange().createContextualFragment(n),r=o.firstElementChild;return document.head.appendChild(o),r},T.customTag=function(t,e){window.customElements.get(t)||window.customElements.define(t,e)},T.shadowRoot=o;e.a=T},function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map(function(e){var n=function(t,e){var n=t[1]||"",o=t[3];if(!o)return n;if(e&&"function"==typeof btoa){var r=(a=o,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */"),i=o.sources.map(function(t){return"/*# sourceURL="+o.sourceRoot+t+" */"});return[n].concat(i).concat([r]).join("\n")}var a;return[n].join("\n")}(e,t);return e[2]?"@media "+e[2]+"{"+n+"}":n}).join("")},e.i=function(t,n){"string"==typeof t&&(t=[[null,t,""]]);for(var o={},r=0;r<this.length;r++){var i=this[r][0];null!=i&&(o[i]=!0)}for(r=0;r<t.length;r++){var a=t[r];null!=a[0]&&o[a[0]]||(n&&!a[2]?a[2]=n:n&&(a[2]="("+a[2]+") and ("+n+")"),e.push(a))}},e}},,,,function(t,e){t.exports=" <div id=slider role=slider> <span id=slider-bar> <span id=slider-progress></span> </span> <span id=slider-thumb></span> </div>"},function(t,e,n){(t.exports=n(1)(!1)).push([t.i,":host {\n    display: inline-block;\n    contain: content;\n    \n    width: 100%;\n    height: auto;\n    color: var(--primary, white);\n    \n    --thumb-color: currentColor;\n    --thumb-size: 1rem;\n    --thumb-border-width: 1px;\n\n    --track-color: var(--light, lightgray);\n    --track-height: 0.5rem;\n\n    --outline-color: var(--secondary, gray);\n    --progress-color: var(--thumb-color);\n}\n\n:host([disabled]) {\n    --thumb-color: var(--outline-color);\n    --progress-color: var(--track-color);\n    pointer-events: none;\n    cursor: default;\n}\n\n#slider {\n    position: relative;\n    margin: calc(var(--thumb-size) + var(--thumb-border-width));\n    width: calc(100% - (var(--thumb-size) + var(--thumb-border-width)) * 2 - 2px); /* 2px for border-width */\n    height: calc(var(--track-height) + 2px);/* 2px for border-width */\n}\n\n#slider-bar {\n    position: absolute;\n    top: 0px;\n    left: 0px;\n    width: 100%;\n    height: var(--track-height);\n    background-color: var(--track-color);\n    border: 1px solid var(--outline-color);\n    border-radius: var(--track-height);\n    cursor: pointer;\n}\n\n#slider-thumb {\n    display: block;\n    position: absolute;\n    top: 0px;/* Will be controlled in updateThumbPosition() */\n    left: 0px;/* Will be controlled in updateThumbPosition() */\n    cursor: pointer;\n\n    width: var(--thumb-size);\n    height: var(--thumb-size);\n    transform: translate(-50%, -50%);\n\n    background-color: var(--thumb-color);\n    border-color: var(--outline-color);\n    border-style: solid;\n    border-radius: 100%;\n    border-width: var(--thumb-border-width);\n\n    margin-top: calc(var(--track-height) / 2 + 1px);/* 1px for border-width */\n    margin-left: 0px;\n\n    transition: background-color 0.15s ease-in-out,\n        box-shadow 0.15s ease-in-out;\n}\n\n#slider-progress {\n    position: absolute;\n    display: block;\n    width: 100%;\n    height: 100%;\n    min-width: var(--track-height);\n    max-width: 100%;\n    min-height: var(--track-height);\n    max-height: 100%;\n    background: var(--progress-color);\n    border-radius: var(--track-height);\n}\n\n:host([vertical]) {\n    /* Same as default, but flipped width and height */\n    width: auto;\n    height: 100%;\n}\n:host([vertical]) div#slider {\n    /* Same as default, but flipped width and height */\n    width: calc(var(--track-height) + 2px);\n    height: calc(100% - (var(--thumb-size) + var(--thumb-border-width)) * 2 - 2px);\n}\n:host([vertical]) span#slider-bar {\n    /* Same as default, but flipped width and height */\n    width: var(--track-height);\n    height: 100%;\n}\n:host([vertical]) span#slider-thumb {\n    /* Same as default, but flipped width and height */\n    margin-top: 0px;\n    margin-left: calc(var(--track-height) / 2 + 1px);\n}\n:host([vertical]) span#slider-progress {\n    position: absolute;\n    bottom: 0px;\n}\n\n\n/* Bootstrap support for form-control-range */\n:host(.form-control-range) {\n    display: block;\n}\n/* Bootstrap support for custom-range */\n:host(.custom-range) {\n    --outline-color: transparent;\n\n    --thumb-border-width: 0.4rem;\n    --thumb-size: 0.6rem;\n\n    --track-color: #dee2e6;\n}\n:host(.custom-range[disabled]) {\n    --thumb-color: #adb5bd!important;\n}\n:host(.custom-range:not([color])) {\n    --thumb-color:#007bff;\n}\n:host(.custom-range[color]) {\n    --thumb-color: currentColor;\n    --progress-color: currentColor;\n    --track-color: #dee2e6;\n}\n:host(.custom-range) span#slider-thumb {\n    border-color: var(--thumb-color);\n    background: var(--white, white);\n}\n:host(.custom-range) span#slider-thumb.focus {\n    --thumb-color: #b3d7ff;\n    box-shadow: 0 0 0 1px #fff, 0 0 0 0.2rem rgba(0, 123, 255, 0.25);\n}\n@media (prefers-reduced-motion: reduce) {\n  :host(.custom-range) span#slider-thumb {\n    transition: none;\n  }\n}\n\n@keyframes rainbow {\n    0%  { color: var(--red, 'red'); }\n    15% { color: var(--orange, 'orange'); }\n    30% { color: var(--yellow, 'yellow'); }\n    45% { color: var(--green, 'green') }\n    60% { color: var(--blue, 'blue'); }\n    75% { color: var(--indigo, 'indigo'); }\n    90% { color: var(--pink, 'pink'); }\n    100%{ color: var(--red, 'red'); }\n}\n",""])},,,,,,,function(t,e,n){"use strict";n.r(e);var o=n(0),r=n(5),i=n.n(r),a=n(6),u=n.n(a);function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,e,n){return(l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var o=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=h(t)););return t}(t,e);if(o){var r=Object.getOwnPropertyDescriptor(o,e);return r.get?r.get.call(n):r.value}})(t,e,n||t)}function h(t){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function d(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function f(t,e,n){return e&&d(t.prototype,e),n&&d(t,n),t}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var b=o.a.templateNode(i.a,u.a);function v(t,e,n,o,r){document.addEventListener(e,n),document.addEventListener(o,r),t.preventDefault(),t.stopPropagation()}function m(t,e,n,o,r){document.removeEventListener(e,n),document.removeEventListener(o,r)}var y=function(t){function e(){var t,n,o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),n=this,(t=!(o=h(e).call(this,b))||"object"!==c(o)&&"function"!=typeof o?s(n):o).onMouseDown=t.onMouseDown.bind(s(t)),t.onMouseUp=t.onMouseUp.bind(s(t)),t.onMouseMove=t.onMouseMove.bind(s(t)),t.onTouchStart=t.onTouchStart.bind(s(t)),t.onTouchEnd=t.onTouchEnd.bind(s(t)),t.onTouchMove=t.onTouchMove.bind(s(t)),t.sliderThumb=t.shadowRoot.querySelector("#slider-thumb"),t.sliderThumb.addEventListener("mousedown",t.onMouseDown),t.sliderThumb.addEventListener("touchstart",t.onTouchStart),t.sliderBar=t.shadowRoot.querySelector("#slider-bar"),t.sliderBar.addEventListener("mousedown",t.onMouseDown),t.sliderBar.addEventListener("touchstart",t.onTouchStart),t.sliderProgress=t.shadowRoot.querySelector("#slider-progress"),t.slider=t.shadowRoot.querySelector("#slider"),t.step=1,t.min=0,t.max=100,t.value=0,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&p(t,e)}(e,o["a"]),f(e,null,[{key:"properties",get:function(){return{step:{type:Number},min:{type:Number},max:{type:Number},value:{type:Number,reflect:!0},disabled:{type:Boolean},vertical:{type:Boolean},rainbow:{type:Boolean},color:{type:String}}}}]),f(e,[{key:"propertyChangedCallback",value:function(t,e,n){switch(t){case"value":var o=this.min,r=this.max,i=this.step,a=Math.floor(n/i)*i;a<o&&(a=o),a>r&&(a=r),this.value=a,this.slider.setAttribute("aria-valuenow","".concat(this.value)),this.updateThumbPosition(a);break;case"color":this.slider.style.color=this.color;break;case"min":this.slider.setAttribute("aria-valuemin","".concat(this.min));break;case"max":this.slider.setAttribute("aria-valuemax","".concat(this.max))}}},{key:"connectedCallback",value:function(){l(h(e.prototype),"connectedCallback",this).call(this),this.updateThumbPosition(this.value)}},{key:"updateThumbPosition",value:function(t){var e=this.step,n=this.min,o=this.max,r=Math.floor(t/e)*e;r<n&&(r=n),r>o&&(r=o);var i=(r-n)/(o-n);i>1&&(i=1),i<0&&(i=0),this.vertical?(this.sliderThumb.style.left="0px",this.sliderThumb.style.top="calc(".concat(100*(1-i),"%)"),this.sliderProgress.style.width="100%",this.sliderProgress.style.height="".concat(100*i,"%")):(this.sliderThumb.style.left="calc(".concat(100*i,"%)"),this.sliderThumb.style.top="0px",this.sliderProgress.style.width="".concat(100*i,"%"),this.sliderProgress.style.height="100%")}},{key:"onMouseDown",value:function(t){v(t,"mouseup",this.onMouseUp,"mousemove",this.onMouseMove),this.onThumbStart(),this.onThumbMove(t)}},{key:"onMouseMove",value:function(t){this.onThumbMove(t)}},{key:"onMouseUp",value:function(t){m(0,"mouseup",this.onMouseUp,"mousemove",this.onMouseMove),this.onThumbStop(t)}},{key:"onTouchStart",value:function(t){v(t,"touchend",this.onTouchEnd,"touchmove",this.onTouchMove),this.onThumbStart(),this.onTouchMove(t)}},{key:"onTouchMove",value:function(t){var e=t.changedTouches[0];this.onThumbMove(e)}},{key:"onTouchEnd",value:function(t){m(0,"touchend",this.onTouchEnd,"touchmove",this.onTouchMove),this.onThumbStop(t)}},{key:"onThumbStart",value:function(){this.sliderThumb.classList.add("focus")}},{key:"getSliderProgressRatio",value:function(t){var e=this.slider.getBoundingClientRect();return this.vertical?1-(t.clientY-e.top)/this.slider.clientHeight:(t.clientX-e.left)/this.slider.clientWidth}},{key:"onThumbMove",value:function(t){var e=this.getSliderProgressRatio(t),n=this.min,o=(this.max-n)*e+n;this.value!==o&&(this.value=o,this.dispatchEvent(new CustomEvent("input",{bubbles:!0,composed:!0})))}},{key:"onThumbStop",value:function(){this.sliderThumb.classList.remove("focus")}}]),e}();o.a.customTag("core-slider",y),e.default=y}])});