@storefront-ui/shared
Advanced tools
Comparing version 2.0.0-alpha.0 to 2.0.0-alpha.1
@@ -0,3 +1,4 @@ | ||
export * from './progress'; | ||
export * from './slider'; | ||
export * from './utils'; | ||
export * from './types'; |
@@ -1,2 +0,2 @@ | ||
const t={reduceMotion:!1,snap:!1,drag:void 0},e="vsf-slider__container--dragging";let o=-1;var i,s,n,r,l,c;exports.VsfAlertVariants=void 0,(i=exports.VsfAlertVariants||(exports.VsfAlertVariants={})).gray="gray",i.secondary="secondary",i.positive="positive",i.warning="warning",i.error="error",exports.VsfAlertTypes=void 0,(s=exports.VsfAlertTypes||(exports.VsfAlertTypes={})).temporary="temporary",s.persistent="persistent",exports.VsfFooterColumnType=void 0,(n=exports.VsfFooterColumnType||(exports.VsfFooterColumnType={})).top="top",n.middle="middle",exports.VsfFooterSectionType=void 0,(r=exports.VsfFooterSectionType||(exports.VsfFooterSectionType={})).top="top",r.middle="middle",r.bottom="bottom",exports.VsfFooterLabelType=void 0,(l=exports.VsfFooterLabelType||(exports.VsfFooterLabelType={})).category="category",l.subcategory="subcategory",l.contact="contact",l.contactDescription="contact-description",l.socialMedia="social-media",l.bottomLinks="bottom-links",l.companyName="company-name",exports.VsfLoaderSizes=void 0,(c=exports.VsfLoaderSizes||(exports.VsfLoaderSizes={})).xs="xs",c.sm="sm",c.base="base",c.lg="lg",c.xl="xl",c["2xl"]="2xl",c["3xl"]="3xl",c["4xl"]="4xl",exports.VSFSlider=class{constructor(e,o){if(this.container=void 0,this.options=void 0,this.delta=void 0,this.debounceId=void 0,this.pagewidth=void 0,this.dragDown=void 0,this.dragScrollX=void 0,this.dragScrollLeft=void 0,!(e instanceof HTMLElement))throw new Error(`VSFSlider: Container is not a HTMLElement! Received: ${e}`);this.container=e,this.options={...t,...o},this.delta=2.5,this.pagewidth=1,this.dragScrollX=0,this.dragScrollLeft=0,this.init()}init(){this.addListeners(),this.onScrollHandler()}update(e){this.removeListeners(),this.options={...t,...e},this.init()}destroy(){this.removeListeners()}prev(){const{container:t,delta:e}=this,o=this.offset(),{left:i}=t.getBoundingClientRect(),s=this.findPrevSlot(i+t.clientWidth*-this.pagewidth+o-e);if(s){const e=s.getBoundingClientRect().left-i;this.scrollToLeft(t.scrollLeft+e)}else this.scrollToLeft(t.scrollLeft-t.clientWidth*this.pagewidth)}next(){const{container:t,delta:e}=this,{left:o}=t.getBoundingClientRect(),i=this.findNextSlot(o+t.clientWidth*this.pagewidth+e);if(i){const s=i.getBoundingClientRect().left-o;if(s>e)return void this.scrollToLeft(t.scrollLeft+s)}this.scrollToLeft(t.scrollLeft+t.clientWidth*this.pagewidth)}scrollToIndex(t){const e=this.children();if(e[t]){const{container:o}=this,i=e[t].getBoundingClientRect().left-o.getBoundingClientRect().left;this.scrollToLeft(o.scrollLeft+i)}}refresh(t){requestAnimationFrame(()=>{const e=this.calculate();t?.(e)})}onMouseUp(){this.dragDown=!1,setTimeout(()=>{this.container.classList.remove(e)},50)}onMouseLeave(){this.dragDown=!1,this.container.classList.remove(e)}onMouseDown(t){t.preventDefault();const{container:o}=this;this.dragDown=!0,this.dragScrollX=t.pageX-o.offsetLeft,this.dragScrollLeft=o.scrollLeft,o.classList.add(e)}onMouseMove(t){if(!this.dragDown)return;t.preventDefault();const e=this.options.drag?.sensitivity??4,{container:o}=this;o.scrollLeft=this.dragScrollLeft-(t.pageX-o.offsetLeft-this.dragScrollX)*e}addListeners(){this.container.addEventListener("scroll",this.onScroll.bind(this),{passive:!0}),this.options.drag&&(this.container.addEventListener("mousedown",this.onMouseDown.bind(this),{passive:!1}),this.container.addEventListener("mouseup",this.onMouseUp.bind(this),{passive:!0}),this.container.addEventListener("mousemove",this.onMouseMove.bind(this),{passive:!1}),this.container.addEventListener("mouseleave",this.onMouseLeave.bind(this),{passive:!0}))}removeListeners(){this.container.removeEventListener("scroll",this.onScroll.bind(this)),this.options.drag&&(this.container.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.container.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.container.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.container.removeEventListener("mouseleave",this.onMouseLeave.bind(this)))}children(){return this.container.children}offset(){return parseInt(window.getComputedStyle(this.container).scrollPaddingLeft,10)}findPrevSlot(t){const e=this.children(),o=this.offset();for(let i=0;i<e.length;i++){const s=e[i].getBoundingClientRect();if(s.left-o>=t&&t<=s.right+o)return e[i];if(s.left-o>=t)return e[i]}}findNextSlot(t){const e=this.children();for(let o=0;o<e.length;o++){const i=e[o].getBoundingClientRect();if(i.right>t){if(i.left<=t)return e[o];if(t<=i.left)return e[o]}}}scrollToLeft(t){const{container:e}=this;e.scrollTo({left:t,behavior:this.options.reduceMotion?"auto":"smooth"})}onScroll(){this.container&&(clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onScrollHandler(){this.refresh(t=>this.options.onScroll?.(t))}calculate(){const{container:t,delta:e}=this,o=this.children()[0];return{left:t.scrollLeft,width:t.clientWidth,scrollWidth:t.scrollWidth,hasPrev:function(){if(0===t.scrollLeft)return!1;const i=t.getBoundingClientRect().left,s=o?.getBoundingClientRect()?.left??0;return Math.abs(i-s)>=e}(),hasNext:t.scrollWidth>t.scrollLeft+t.clientWidth+e}}},exports.clamp=function(t,e,o){return Math.min(Math.max(t,e),o)},exports.equal=function t(e,o){if(e===o)return!0;const i=typeof e;if(i!==typeof o)return!1;if("object"!==i||null===e||null===o)return"function"===i&&e.toString()===o.toString();if(e.length!==o.length||Object.getOwnPropertyNames(e).length!==Object.getOwnPropertyNames(o).length)return!1;for(const i in e)if(!t(e[i],o[i]))return!1;return!0},exports.generateId=t=>`${t}--${++o}`,exports.noop=()=>{},exports.roundToNearest=function(t,e){return Math.round(t/e)*e}; | ||
const t={reduceMotion:!1,snap:!1,drag:void 0},e="vsf-slider__container--dragging";let o=-1;var i,s,n,r,l,c;exports.VsfAlertVariants=void 0,(i=exports.VsfAlertVariants||(exports.VsfAlertVariants={})).gray="gray",i.secondary="secondary",i.positive="positive",i.warning="warning",i.error="error",exports.VsfAlertTypes=void 0,(s=exports.VsfAlertTypes||(exports.VsfAlertTypes={})).temporary="temporary",s.persistent="persistent",exports.VsfFooterColumnType=void 0,(n=exports.VsfFooterColumnType||(exports.VsfFooterColumnType={})).top="top",n.middle="middle",exports.VsfFooterSectionType=void 0,(r=exports.VsfFooterSectionType||(exports.VsfFooterSectionType={})).top="top",r.middle="middle",r.bottom="bottom",exports.VsfFooterLabelType=void 0,(l=exports.VsfFooterLabelType||(exports.VsfFooterLabelType={})).category="category",l.subcategory="subcategory",l.contact="contact",l.contactDescription="contact-description",l.socialMedia="social-media",l.bottomLinks="bottom-links",l.companyName="company-name",exports.VsfLoaderSizes=void 0,(c=exports.VsfLoaderSizes||(exports.VsfLoaderSizes={})).xs="xs",c.sm="sm",c.base="base",c.lg="lg",c.xl="xl",c["2xl"]="2xl",c["3xl"]="3xl",c["4xl"]="4xl",exports.VSFSlider=class{constructor(e,o){if(this.container=void 0,this.options=void 0,this.delta=void 0,this.debounceId=void 0,this.pagewidth=void 0,this.dragDown=void 0,this.dragScrollX=void 0,this.dragScrollLeft=void 0,!(e instanceof HTMLElement))throw new Error(`VSFSlider: Container is not a HTMLElement! Received: ${e}`);this.container=e,this.options={...t,...o},this.delta=2.5,this.pagewidth=1,this.dragScrollX=0,this.dragScrollLeft=0,this.init()}init(){this.addListeners(),this.onScrollHandler()}update(e){this.removeListeners(),this.options={...t,...e},this.init()}destroy(){this.removeListeners()}prev(){const{container:t,delta:e}=this,o=this.offset(),{left:i}=t.getBoundingClientRect(),s=this.findPrevSlot(i+t.clientWidth*-this.pagewidth+o-e);if(s){const e=s.getBoundingClientRect().left-i;this.scrollToLeft(t.scrollLeft+e)}else this.scrollToLeft(t.scrollLeft-t.clientWidth*this.pagewidth)}next(){const{container:t,delta:e}=this,{left:o}=t.getBoundingClientRect(),i=this.findNextSlot(o+t.clientWidth*this.pagewidth+e);if(i){const s=i.getBoundingClientRect().left-o;if(s>e)return void this.scrollToLeft(t.scrollLeft+s)}this.scrollToLeft(t.scrollLeft+t.clientWidth*this.pagewidth)}scrollToIndex(t){const e=this.children();if(e[t]){const{container:o}=this,i=e[t].getBoundingClientRect().left-o.getBoundingClientRect().left;this.scrollToLeft(o.scrollLeft+i)}}refresh(t){requestAnimationFrame(()=>{const e=this.calculate();t?.(e)})}onMouseUp(){this.dragDown=!1,setTimeout(()=>{this.container.classList.remove(e)},50)}onMouseLeave(){this.dragDown=!1,this.container.classList.remove(e)}onMouseDown(t){t.preventDefault();const{container:o}=this;this.dragDown=!0,this.dragScrollX=t.pageX-o.offsetLeft,this.dragScrollLeft=o.scrollLeft,o.classList.add(e)}onMouseMove(t){if(!this.dragDown)return;t.preventDefault();const e=this.options.drag?.sensitivity??4,{container:o}=this;o.scrollLeft=this.dragScrollLeft-(t.pageX-o.offsetLeft-this.dragScrollX)*e}addListeners(){this.container.addEventListener("scroll",this.onScroll.bind(this),{passive:!0}),this.options.drag&&(this.container.addEventListener("mousedown",this.onMouseDown.bind(this),{passive:!1}),this.container.addEventListener("mouseup",this.onMouseUp.bind(this),{passive:!0}),this.container.addEventListener("mousemove",this.onMouseMove.bind(this),{passive:!1}),this.container.addEventListener("mouseleave",this.onMouseLeave.bind(this),{passive:!0}))}removeListeners(){this.container.removeEventListener("scroll",this.onScroll.bind(this)),this.options.drag&&(this.container.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.container.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.container.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.container.removeEventListener("mouseleave",this.onMouseLeave.bind(this)))}children(){return this.container.children}offset(){return parseInt(window.getComputedStyle(this.container).scrollPaddingLeft,10)}findPrevSlot(t){const e=this.children(),o=this.offset();for(let i=0;i<e.length;i++){const s=e[i].getBoundingClientRect();if(s.left-o>=t&&t<=s.right+o)return e[i];if(s.left-o>=t)return e[i]}}findNextSlot(t){const e=this.children();for(let o=0;o<e.length;o++){const i=e[o].getBoundingClientRect();if(i.right>t){if(i.left<=t)return e[o];if(t<=i.left)return e[o]}}}scrollToLeft(t){const{container:e}=this;e.scrollTo({left:t,behavior:this.options.reduceMotion?"auto":"smooth"})}onScroll(){this.container&&(clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onScrollHandler(){this.refresh(t=>this.options.onScroll?.(t))}calculate(){const{container:t,delta:e}=this,o=this.children()[0];return{left:t.scrollLeft,width:t.clientWidth,scrollWidth:t.scrollWidth,hasPrev:function(){if(0===t.scrollLeft)return!1;const i=t.getBoundingClientRect().left,s=o?.getBoundingClientRect()?.left??0;return Math.abs(i-s)>=e}(),hasNext:t.scrollWidth>t.scrollLeft+t.clientWidth+e}}},exports.clamp=function(t,e,o){return Math.min(Math.max(t,e),o)},exports.equal=function t(e,o){if(e===o)return!0;const i=typeof e;if(i!==typeof o)return!1;if("object"!==i||null===e||null===o)return"function"===i&&e.toString()===o.toString();if(e.length!==o.length||Object.getOwnPropertyNames(e).length!==Object.getOwnPropertyNames(o).length)return!1;for(const i in e)if(!t(e[i],o[i]))return!1;return!0},exports.generateId=t=>`vsf-${t}--${++o}`,exports.noop=()=>{},exports.progressSvgSizes={xs:{icon:16,r:7.2,dash:45.216},sm:{icon:20,r:9,dash:56.52},base:{icon:24,r:11,dash:69.08},lg:{icon:32,r:14.67,dash:92.127},xl:{icon:40,r:19,dash:119.32},"2xl":{icon:56,r:26,dash:163.28},"3xl":{icon:96,r:44,dash:276.32},"4xl":{icon:192,r:88,dash:552.64}},exports.roundToNearest=function(t,e){return Math.round(t/e)*e}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).shared={})}(this,function(t){const e={reduceMotion:!1,snap:!1,drag:void 0},i="vsf-slider__container--dragging";let o=-1;var n,s,r,l,c,a;t.VsfAlertVariants=void 0,(n=t.VsfAlertVariants||(t.VsfAlertVariants={})).gray="gray",n.secondary="secondary",n.positive="positive",n.warning="warning",n.error="error",t.VsfAlertTypes=void 0,(s=t.VsfAlertTypes||(t.VsfAlertTypes={})).temporary="temporary",s.persistent="persistent",t.VsfFooterColumnType=void 0,(r=t.VsfFooterColumnType||(t.VsfFooterColumnType={})).top="top",r.middle="middle",t.VsfFooterSectionType=void 0,(l=t.VsfFooterSectionType||(t.VsfFooterSectionType={})).top="top",l.middle="middle",l.bottom="bottom",t.VsfFooterLabelType=void 0,(c=t.VsfFooterLabelType||(t.VsfFooterLabelType={})).category="category",c.subcategory="subcategory",c.contact="contact",c.contactDescription="contact-description",c.socialMedia="social-media",c.bottomLinks="bottom-links",c.companyName="company-name",t.VsfLoaderSizes=void 0,(a=t.VsfLoaderSizes||(t.VsfLoaderSizes={})).xs="xs",a.sm="sm",a.base="base",a.lg="lg",a.xl="xl",a["2xl"]="2xl",a["3xl"]="3xl",a["4xl"]="4xl",t.VSFSlider=class{constructor(t,i){if(this.container=void 0,this.options=void 0,this.delta=void 0,this.debounceId=void 0,this.pagewidth=void 0,this.dragDown=void 0,this.dragScrollX=void 0,this.dragScrollLeft=void 0,!(t instanceof HTMLElement))throw new Error(`VSFSlider: Container is not a HTMLElement! Received: ${t}`);this.container=t,this.options={...e,...i},this.delta=2.5,this.pagewidth=1,this.dragScrollX=0,this.dragScrollLeft=0,this.init()}init(){this.addListeners(),this.onScrollHandler()}update(t){this.removeListeners(),this.options={...e,...t},this.init()}destroy(){this.removeListeners()}prev(){const{container:t,delta:e}=this,i=this.offset(),{left:o}=t.getBoundingClientRect(),n=this.findPrevSlot(o+t.clientWidth*-this.pagewidth+i-e);if(n){const e=n.getBoundingClientRect().left-o;this.scrollToLeft(t.scrollLeft+e)}else this.scrollToLeft(t.scrollLeft-t.clientWidth*this.pagewidth)}next(){const{container:t,delta:e}=this,{left:i}=t.getBoundingClientRect(),o=this.findNextSlot(i+t.clientWidth*this.pagewidth+e);if(o){const n=o.getBoundingClientRect().left-i;if(n>e)return void this.scrollToLeft(t.scrollLeft+n)}this.scrollToLeft(t.scrollLeft+t.clientWidth*this.pagewidth)}scrollToIndex(t){const e=this.children();if(e[t]){const{container:i}=this,o=e[t].getBoundingClientRect().left-i.getBoundingClientRect().left;this.scrollToLeft(i.scrollLeft+o)}}refresh(t){requestAnimationFrame(()=>{const e=this.calculate();t?.(e)})}onMouseUp(){this.dragDown=!1,setTimeout(()=>{this.container.classList.remove(i)},50)}onMouseLeave(){this.dragDown=!1,this.container.classList.remove(i)}onMouseDown(t){t.preventDefault();const{container:e}=this;this.dragDown=!0,this.dragScrollX=t.pageX-e.offsetLeft,this.dragScrollLeft=e.scrollLeft,e.classList.add(i)}onMouseMove(t){if(!this.dragDown)return;t.preventDefault();const e=this.options.drag?.sensitivity??4,{container:i}=this;i.scrollLeft=this.dragScrollLeft-(t.pageX-i.offsetLeft-this.dragScrollX)*e}addListeners(){this.container.addEventListener("scroll",this.onScroll.bind(this),{passive:!0}),this.options.drag&&(this.container.addEventListener("mousedown",this.onMouseDown.bind(this),{passive:!1}),this.container.addEventListener("mouseup",this.onMouseUp.bind(this),{passive:!0}),this.container.addEventListener("mousemove",this.onMouseMove.bind(this),{passive:!1}),this.container.addEventListener("mouseleave",this.onMouseLeave.bind(this),{passive:!0}))}removeListeners(){this.container.removeEventListener("scroll",this.onScroll.bind(this)),this.options.drag&&(this.container.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.container.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.container.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.container.removeEventListener("mouseleave",this.onMouseLeave.bind(this)))}children(){return this.container.children}offset(){return parseInt(window.getComputedStyle(this.container).scrollPaddingLeft,10)}findPrevSlot(t){const e=this.children(),i=this.offset();for(let o=0;o<e.length;o++){const n=e[o].getBoundingClientRect();if(n.left-i>=t&&t<=n.right+i)return e[o];if(n.left-i>=t)return e[o]}}findNextSlot(t){const e=this.children();for(let i=0;i<e.length;i++){const o=e[i].getBoundingClientRect();if(o.right>t){if(o.left<=t)return e[i];if(t<=o.left)return e[i]}}}scrollToLeft(t){const{container:e}=this;e.scrollTo({left:t,behavior:this.options.reduceMotion?"auto":"smooth"})}onScroll(){this.container&&(clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onScrollHandler(){this.refresh(t=>this.options.onScroll?.(t))}calculate(){const{container:t,delta:e}=this,i=this.children()[0];return{left:t.scrollLeft,width:t.clientWidth,scrollWidth:t.scrollWidth,hasPrev:function(){if(0===t.scrollLeft)return!1;const o=t.getBoundingClientRect().left,n=i?.getBoundingClientRect()?.left??0;return Math.abs(o-n)>=e}(),hasNext:t.scrollWidth>t.scrollLeft+t.clientWidth+e}}},t.clamp=function(t,e,i){return Math.min(Math.max(t,e),i)},t.equal=function t(e,i){if(e===i)return!0;const o=typeof e;if(o!==typeof i)return!1;if("object"!==o||null===e||null===i)return"function"===o&&e.toString()===i.toString();if(e.length!==i.length||Object.getOwnPropertyNames(e).length!==Object.getOwnPropertyNames(i).length)return!1;for(const o in e)if(!t(e[o],i[o]))return!1;return!0},t.generateId=t=>`${t}--${++o}`,t.noop=()=>{},t.roundToNearest=function(t,e){return Math.round(t/e)*e}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).shared={})}(this,function(t){const e={reduceMotion:!1,snap:!1,drag:void 0},i="vsf-slider__container--dragging";let o=-1;var n,s,r,l,c,a;t.VsfAlertVariants=void 0,(n=t.VsfAlertVariants||(t.VsfAlertVariants={})).gray="gray",n.secondary="secondary",n.positive="positive",n.warning="warning",n.error="error",t.VsfAlertTypes=void 0,(s=t.VsfAlertTypes||(t.VsfAlertTypes={})).temporary="temporary",s.persistent="persistent",t.VsfFooterColumnType=void 0,(r=t.VsfFooterColumnType||(t.VsfFooterColumnType={})).top="top",r.middle="middle",t.VsfFooterSectionType=void 0,(l=t.VsfFooterSectionType||(t.VsfFooterSectionType={})).top="top",l.middle="middle",l.bottom="bottom",t.VsfFooterLabelType=void 0,(c=t.VsfFooterLabelType||(t.VsfFooterLabelType={})).category="category",c.subcategory="subcategory",c.contact="contact",c.contactDescription="contact-description",c.socialMedia="social-media",c.bottomLinks="bottom-links",c.companyName="company-name",t.VsfLoaderSizes=void 0,(a=t.VsfLoaderSizes||(t.VsfLoaderSizes={})).xs="xs",a.sm="sm",a.base="base",a.lg="lg",a.xl="xl",a["2xl"]="2xl",a["3xl"]="3xl",a["4xl"]="4xl",t.VSFSlider=class{constructor(t,i){if(this.container=void 0,this.options=void 0,this.delta=void 0,this.debounceId=void 0,this.pagewidth=void 0,this.dragDown=void 0,this.dragScrollX=void 0,this.dragScrollLeft=void 0,!(t instanceof HTMLElement))throw new Error(`VSFSlider: Container is not a HTMLElement! Received: ${t}`);this.container=t,this.options={...e,...i},this.delta=2.5,this.pagewidth=1,this.dragScrollX=0,this.dragScrollLeft=0,this.init()}init(){this.addListeners(),this.onScrollHandler()}update(t){this.removeListeners(),this.options={...e,...t},this.init()}destroy(){this.removeListeners()}prev(){const{container:t,delta:e}=this,i=this.offset(),{left:o}=t.getBoundingClientRect(),n=this.findPrevSlot(o+t.clientWidth*-this.pagewidth+i-e);if(n){const e=n.getBoundingClientRect().left-o;this.scrollToLeft(t.scrollLeft+e)}else this.scrollToLeft(t.scrollLeft-t.clientWidth*this.pagewidth)}next(){const{container:t,delta:e}=this,{left:i}=t.getBoundingClientRect(),o=this.findNextSlot(i+t.clientWidth*this.pagewidth+e);if(o){const n=o.getBoundingClientRect().left-i;if(n>e)return void this.scrollToLeft(t.scrollLeft+n)}this.scrollToLeft(t.scrollLeft+t.clientWidth*this.pagewidth)}scrollToIndex(t){const e=this.children();if(e[t]){const{container:i}=this,o=e[t].getBoundingClientRect().left-i.getBoundingClientRect().left;this.scrollToLeft(i.scrollLeft+o)}}refresh(t){requestAnimationFrame(()=>{const e=this.calculate();t?.(e)})}onMouseUp(){this.dragDown=!1,setTimeout(()=>{this.container.classList.remove(i)},50)}onMouseLeave(){this.dragDown=!1,this.container.classList.remove(i)}onMouseDown(t){t.preventDefault();const{container:e}=this;this.dragDown=!0,this.dragScrollX=t.pageX-e.offsetLeft,this.dragScrollLeft=e.scrollLeft,e.classList.add(i)}onMouseMove(t){if(!this.dragDown)return;t.preventDefault();const e=this.options.drag?.sensitivity??4,{container:i}=this;i.scrollLeft=this.dragScrollLeft-(t.pageX-i.offsetLeft-this.dragScrollX)*e}addListeners(){this.container.addEventListener("scroll",this.onScroll.bind(this),{passive:!0}),this.options.drag&&(this.container.addEventListener("mousedown",this.onMouseDown.bind(this),{passive:!1}),this.container.addEventListener("mouseup",this.onMouseUp.bind(this),{passive:!0}),this.container.addEventListener("mousemove",this.onMouseMove.bind(this),{passive:!1}),this.container.addEventListener("mouseleave",this.onMouseLeave.bind(this),{passive:!0}))}removeListeners(){this.container.removeEventListener("scroll",this.onScroll.bind(this)),this.options.drag&&(this.container.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.container.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.container.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.container.removeEventListener("mouseleave",this.onMouseLeave.bind(this)))}children(){return this.container.children}offset(){return parseInt(window.getComputedStyle(this.container).scrollPaddingLeft,10)}findPrevSlot(t){const e=this.children(),i=this.offset();for(let o=0;o<e.length;o++){const n=e[o].getBoundingClientRect();if(n.left-i>=t&&t<=n.right+i)return e[o];if(n.left-i>=t)return e[o]}}findNextSlot(t){const e=this.children();for(let i=0;i<e.length;i++){const o=e[i].getBoundingClientRect();if(o.right>t){if(o.left<=t)return e[i];if(t<=o.left)return e[i]}}}scrollToLeft(t){const{container:e}=this;e.scrollTo({left:t,behavior:this.options.reduceMotion?"auto":"smooth"})}onScroll(){this.container&&(clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onScrollHandler(){this.refresh(t=>this.options.onScroll?.(t))}calculate(){const{container:t,delta:e}=this,i=this.children()[0];return{left:t.scrollLeft,width:t.clientWidth,scrollWidth:t.scrollWidth,hasPrev:function(){if(0===t.scrollLeft)return!1;const o=t.getBoundingClientRect().left,n=i?.getBoundingClientRect()?.left??0;return Math.abs(o-n)>=e}(),hasNext:t.scrollWidth>t.scrollLeft+t.clientWidth+e}}},t.clamp=function(t,e,i){return Math.min(Math.max(t,e),i)},t.equal=function t(e,i){if(e===i)return!0;const o=typeof e;if(o!==typeof i)return!1;if("object"!==o||null===e||null===i)return"function"===o&&e.toString()===i.toString();if(e.length!==i.length||Object.getOwnPropertyNames(e).length!==Object.getOwnPropertyNames(i).length)return!1;for(const o in e)if(!t(e[o],i[o]))return!1;return!0},t.generateId=t=>`vsf-${t}--${++o}`,t.noop=()=>{},t.progressSvgSizes={xs:{icon:16,r:7.2,dash:45.216},sm:{icon:20,r:9,dash:56.52},base:{icon:24,r:11,dash:69.08},lg:{icon:32,r:14.67,dash:92.127},xl:{icon:40,r:19,dash:119.32},"2xl":{icon:56,r:26,dash:163.28},"3xl":{icon:96,r:44,dash:276.32},"4xl":{icon:192,r:88,dash:552.64}},t.roundToNearest=function(t,e){return Math.round(t/e)*e}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@storefront-ui/shared", | ||
"description": "Shared set of utils and typings used by `@storefront-ui/*` packages", | ||
"version": "2.0.0-alpha.0", | ||
"version": "2.0.0-alpha.1", | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"import": "./dist/index.modern.js", | ||
"import": "./dist/index.esm.mjs", | ||
"require": "./dist/index.js" | ||
@@ -14,8 +14,7 @@ }, | ||
"source": "index.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.es.js", | ||
"unpkg": "./dist/index.umd.js", | ||
"types": "./dist/index.d.ts", | ||
"main": "dist/index.js", | ||
"unpkg": "dist/index.umd.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"start:shared": "microbundle watch", | ||
"dev": "microbundle watch", | ||
"build:shared": "microbundle --compress" | ||
@@ -22,0 +21,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
254
0
76400
19
1