@storefront-ui/shared
Advanced tools
Comparing version 2.0.0-rc.7 to 2.0.0-rc.8
@@ -1,1 +0,1 @@ | ||
(function(n,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(n=typeof globalThis<"u"?globalThis:n||self,l(n["storefront-ui-shared"]={}))})(this,function(n){"use strict";var ot=Object.defineProperty;var lt=(n,l,a)=>l in n?ot(n,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[l]=a;var o=(n,l,a)=>(lt(n,typeof l!="symbol"?l+"":l,a),a);const l={reduceMotion:!1,snap:!1,drag:void 0,vertical:!1},a="sf-scrollable__container--dragging";class ${constructor(e,s){o(this,"container");o(this,"options");o(this,"debounceId");o(this,"isDragged");o(this,"dragScrollX");o(this,"dragScrollLeft");o(this,"dragScrollY");o(this,"dragScrollTop");o(this,"scrollListenerInstance",()=>{});o(this,"resizeListenerInstance",()=>{});o(this,"mouseDownListenerInstance",()=>{});o(this,"mouseUpListenerInstance",()=>{});o(this,"mouseMoveListenerInstance",()=>{});o(this,"mouseLeaveListenerInstance",()=>{});if(!(e instanceof HTMLElement))throw new Error(`SfScrollable: Container is not a HTMLElement! Received: ${e}`);this.container=e,this.options={...l,...s},this.dragScrollX=0,this.dragScrollLeft=0,this.dragScrollY=0,this.dragScrollTop=0,this.init()}init(){this.addListeners(),this.onScrollHandler()}update(e){this.options={...l,...e},this.removeListeners(),this.init()}destroy(){this.removeListeners()}prev(){const{container:e,options:s}=this;s.vertical?this.scrollTo({top:e.scrollTop-e.clientHeight}):this.scrollTo({left:e.scrollLeft-e.clientWidth})}next(){const{container:e,options:s}=this;s.vertical?this.scrollTo({top:e.scrollTop+e.clientHeight}):this.scrollTo({left:e.scrollLeft+e.clientWidth})}scrollToIndex(e){const s=this.children();if(s[e]){const{container:r}=this,i=s[e].getBoundingClientRect(),c=i.left-r.getBoundingClientRect().left,h=i.top-r.getBoundingClientRect().top,d=r.clientWidth/2-i.width/2,it=r.clientHeight/2-i.height/2;this.options.vertical?this.scrollTo({top:r.scrollTop+h-it}):this.scrollTo({left:r.scrollLeft+c-d})}}refresh(e){requestAnimationFrame(()=>{const s=this.calculate();e==null||e(s)})}onMouseUp(){this.isDragged=!1,setTimeout(()=>{this.container.classList.remove(a)},50)}onMouseLeave(){this.isDragged=!1,this.container.classList.remove(a)}onMouseDown(e){e.preventDefault();const{container:s,options:r}=this;this.isDragged=!0,s.classList.add(a),r.vertical?(this.dragScrollY=e.pageY-s.offsetTop,this.dragScrollTop=s.scrollTop):(this.dragScrollX=e.pageX-s.offsetLeft,this.dragScrollLeft=s.scrollLeft)}onMouseMove(e){var c;if(!this.isDragged)return;e.preventDefault();const s=((c=this.options.drag)==null?void 0:c.sensitivity)??4,{container:r,options:i}=this;if(i.vertical){const d=(e.pageY-r.offsetTop-this.dragScrollY)*s;r.scrollTop=this.dragScrollTop-d}else{const d=(e.pageX-r.offsetLeft-this.dragScrollX)*s;r.scrollLeft=this.dragScrollLeft-d}}addListeners(){this.scrollListenerInstance=this.onScroll.bind(this),this.resizeListenerInstance=this.onResize.bind(this),this.container.addEventListener("scroll",this.scrollListenerInstance,{passive:!0}),window.addEventListener("resize",this.resizeListenerInstance),this.options.drag&&(this.mouseDownListenerInstance=this.onMouseDown.bind(this),this.mouseUpListenerInstance=this.onMouseUp.bind(this),this.mouseMoveListenerInstance=this.onMouseMove.bind(this),this.mouseLeaveListenerInstance=this.onMouseLeave.bind(this),this.container.addEventListener("mousedown",this.mouseDownListenerInstance,{passive:!1}),this.container.addEventListener("mouseup",this.mouseUpListenerInstance,{passive:!0}),this.container.addEventListener("mousemove",this.mouseMoveListenerInstance,{passive:!1}),this.container.addEventListener("mouseleave",this.mouseLeaveListenerInstance,{passive:!0}))}removeListeners(){this.container.removeEventListener("scroll",this.scrollListenerInstance),window.removeEventListener("resize",this.resizeListenerInstance),this.options.drag||(this.container.removeEventListener("mousedown",this.mouseDownListenerInstance),this.container.removeEventListener("mouseup",this.mouseUpListenerInstance),this.container.removeEventListener("mousemove",this.mouseMoveListenerInstance),this.container.removeEventListener("mouseleave",this.mouseLeaveListenerInstance))}children(){return this.container.children}scrollTo({left:e,top:s}){const r=this.options.reduceMotion?"auto":"smooth";this.container.scrollTo({left:e,top:s,behavior:r})}onScroll(){this.container&&(clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onResize(){this.container&&this.refresh(s=>{var r,i;return(i=(r=this.options).onScroll)==null?void 0:i.call(r,s)})}onScrollHandler(){this.refresh(e=>{var s,r;return(r=(s=this.options).onScroll)==null?void 0:r.call(s,e)})}calculate(){const{container:e,options:s}=this;function r(){return s.vertical?e.scrollHeight>Math.ceil(e.scrollTop)+e.clientHeight:e.scrollWidth>Math.ceil(e.scrollLeft)+e.clientWidth}function i(){return s.vertical?!!e.scrollTop:!!e.scrollLeft}return{left:e.scrollLeft,width:e.clientWidth,scrollWidth:e.scrollWidth,hasPrev:i(),hasNext:r()}}}const L=typeof window<"u",K=L&&(window==null?void 0:window.matchMedia("(prefers-reduced-motion: reduce)").matches),f=L&&/^((?!chrome|android).)*safari/i.test(navigator==null?void 0:navigator.userAgent);let J=-1;const Q=t=>`sf-${t}--${++J}`,Z=t=>t.key==="Tab"&&t.shiftKey,k=t=>t.key==="Tab"&&!t.shiftKey,V=()=>{};function P(t,e,s){return Math.min(Math.max(t,e),s)}function z(t,e){return Math.round(t/e)*e}function v(t,e){if(t===e)return!0;const s=typeof t;if(s!==typeof e)return!1;if(s==="object"&&t!==null&&e!==null){if(t.length!==e.length||Object.getOwnPropertyNames(t).length!==Object.getOwnPropertyNames(e).length)return!1;for(const i in t)if(!v(t[i],e[i]))return!1}else return s==="function"?t.toString()===e.toString():!1;return!0}var b=(t=>(t.neutral="neutral",t.secondary="secondary",t.positive="positive",t.warning="warning",t.error="error",t))(b||{}),p=(t=>(t.temporary="temporary",t.persistent="persistent",t))(p||{}),I=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(I||{}),T=(t=>(t.primary="primary",t.secondary="secondary",t.tertiary="tertiary",t))(T||{}),x=(t=>(t.sm="sm",t.base="base",t))(x||{}),y=(t=>(t["3xs"]="3xs",t["2xs"]="2xs",t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t))(y||{}),M=(t=>(t.top="top",t.bottom="bottom",t.left="left",t.right="right",t))(M||{}),w=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(w||{}),E=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t["2xl"]="2xl",t["3xl"]="3xl",t["4xl"]="4xl",t))(E||{}),F=(t=>(t.primary="primary",t.secondary="secondary",t))(F||{}),N=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(N||{}),D=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t["2xl"]="2xl",t["3xl"]="3xl",t["4xl"]="4xl",t))(D||{}),O=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t["2xl"]="2xl",t["3xl"]="3xl",t["4xl"]="4xl",t))(O||{}),H=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))(H||{}),W=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(W||{}),C=(t=>(t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))(C||{}),R=(t=>(t["top-start"]="top-start",t.top="top",t["top-end"]="top-end",t["bottom-start"]="bottom-start",t.bottom="bottom",t["bottom-end"]="bottom-end",t["left-start"]="left-start",t.left="left",t["left-end"]="left-end",t["right-start"]="right-start",t.right="right",t["right-end"]="right-end",t))(R||{}),U=(t=>(t.fixed="fixed",t.absolute="absolute",t))(U||{});const m=(t,e)=>e.findIndex(s=>s===t),X=(t,e)=>{const s=m(t,e);return e[s+1]},Y=(t,e)=>{const s=m(t,e);return e[s-1]},u=({focusables:t,event:e})=>{e==null||e.preventDefault();const s=t[0];return s==null||s.focus(),s},g=({focusables:t,event:e})=>{e==null||e.preventDefault();const s=t[t.length-1];return s==null||s.focus(),s},j=(t,e)=>{const s=X(t,e);return s==null||s.focus(),s},G=(t,e)=>{const s=Y(t,e);return s==null||s.focus(),s},q=(t,e)=>m(t,e)===0,A=(t,e)=>m(t,e)===e.length-1,S=(t,e,s)=>{const r=[...s].reverse(),i=r.findIndex(c=>c===t);return r.find((c,h)=>{var d;if(h>i&&c.closest(e)&&t.closest(e)!==c.closest(e)&&((d=r[h+1])==null?void 0:d.closest(e))!==c.closest(e))return c})},tt=(t,e,s)=>{const r=s.findIndex(i=>i===t);return s.find((i,c)=>{if(c>r&&i.closest(e)&&t.closest(e)!==i.closest(e))return i})},et=({current:t,focusables:e,arrowFocusGroupSelector:s})=>{if(!t)return u({focusables:e});const r=tt(t,s,e);return t&&r?(r==null||r.focus(),r):u({focusables:e})},st=({current:t,focusables:e,arrowFocusGroupSelector:s})=>{if(!t)return u({focusables:e});const r=S(t,s,e);return t&&r?(r==null||r.focus(),r):g({focusables:e})},B=({current:t,focusables:e,event:s})=>{if(f&&(s==null||s.preventDefault()),t){if(A(t,e))return u({focusables:e,event:s});if(f||!s)return j(t,e)}else return u({focusables:e,event:s})},_=({current:t,focusables:e,event:s})=>{if(f&&(s==null||s.preventDefault()),t){if(q(t,e))return g({focusables:e,event:s});if(f||!s)return G(t,e)}else return g({focusables:e,event:s})},nt=({current:t,event:e,focusables:s,arrowFocusGroupSelector:r})=>r?et({current:t,focusables:s,arrowFocusGroupSelector:r}):B({current:t,focusables:s,event:e}),rt=({current:t,focusables:e,event:s,arrowFocusGroupSelector:r})=>r?st({current:t,focusables:e,arrowFocusGroupSelector:r}):_({current:t,focusables:e,event:s});n.SFScrollable=$,n.SfAlertType=p,n.SfAlertVariant=b,n.SfButtonSize=I,n.SfButtonVariant=T,n.SfChipSize=x,n.SfCounterSize=y,n.SfDrawerPlacement=M,n.SfIconSize=E,n.SfInputSize=w,n.SfLinkVariant=F,n.SfListItemSize=N,n.SfLoaderSize=D,n.SfPopoverPlacement=R,n.SfPopoverStrategy=U,n.SfProgressSize=O,n.SfRatingSize=H,n.SfSelectSize=W,n.SfThumbnailSize=C,n.clamp=P,n.equal=v,n.findCurrentFocusableIndex=m,n.findNextFocusable=X,n.findPrevFocusable=Y,n.focusFirstElement=u,n.focusLastElement=g,n.focusNext=nt,n.focusNextElement=j,n.focusNextOrFirst=B,n.focusPrev=rt,n.focusPrevElement=G,n.focusPrevOrLast=_,n.generateId=Q,n.isBrowser=L,n.isCurrentFirstElement=q,n.isCurrentLastElement=A,n.isReduceMotionEnabled=K,n.isSafari=f,n.isTab=k,n.isTabAndShift=Z,n.noop=V,n.roundToNearest=z,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}); | ||
(function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r["storefront-ui-shared"]={}))})(this,function(r){"use strict";var dt=Object.defineProperty;var ht=(r,o,d)=>o in r?dt(r,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):r[o]=d;var a=(r,o,d)=>(ht(r,typeof o!="symbol"?o+"":o,d),d);var o=(t=>(t.vertical="vertical",t.horizontal="horizontal",t))(o||{}),d=(t=>(t.none="none",t.floating="floating",t.block="block",t))(d||{});const v=typeof window<"u",b=v&&(window==null?void 0:window.matchMedia("(prefers-reduced-motion: reduce)").matches),u=v&&/^((?!chrome|android).)*safari/i.test(navigator==null?void 0:navigator.userAgent);let Z=-1;const _=t=>`sf-${t}--${++Z}`,V=t=>t.key==="Tab"&&t.shiftKey,P=t=>t.key==="Tab"&&!t.shiftKey,z=()=>{};function S(t,e,n){return Math.min(Math.max(t,e),n)}function tt(t,e){return Math.round(t/e)*e}function p(t,e){if(t===e)return!0;const n=typeof t;if(n!==typeof e)return!1;if(n==="object"&&t!==null&&e!==null){if(t.length!==e.length||Object.getOwnPropertyNames(t).length!==Object.getOwnPropertyNames(e).length)return!1;for(const i in t)if(!p(t[i],e[i]))return!1}else return n==="function"?t.toString()===e.toString():!1;return!0}const y={reduceMotion:b,direction:o.horizontal};class et{constructor(e,n){a(this,"container");a(this,"options");a(this,"debounceId");a(this,"dragScrollX");a(this,"dragScrollLeft");a(this,"dragScrollY");a(this,"dragScrollTop");a(this,"isDraggedPreviously",!1);if(!(e instanceof HTMLElement))throw new Error(`SfScrollable: Container is not a HTMLElement! Received: ${e}`);this.container=e,this.options={...n,reduceMotion:(n==null?void 0:n.reduceMotion)??y.reduceMotion,direction:(n==null?void 0:n.direction)??y.direction},this.dragScrollX=0,this.dragScrollLeft=0,this.dragScrollY=0,this.dragScrollTop=0}get isDragged(){return this.isDraggedPreviously}set isDragged(e){var n,s;e!==this.isDraggedPreviously&&(this.isDraggedPreviously=e,(s=(n=this.options).onDragChange)==null||s.call(n,{isDragged:this.isDraggedPreviously}))}register(){const e=this.addListeners();return this.onScrollHandler(),e}addListeners(){const e=this.onScroll.bind(this),n=this.onResize.bind(this);if(this.container.addEventListener("scroll",e,{passive:!0}),this.container.addEventListener("resize",n,{passive:!0}),this.options.drag){const s=this.onMouseDown.bind(this),i=this.onMouseUp.bind(this),l=this.onMouseMove.bind(this),c=this.onMouseLeave.bind(this);return this.container.addEventListener("mousedown",s,{passive:!1}),this.container.addEventListener("mouseup",i,{passive:!0}),this.container.addEventListener("mousemove",l,{passive:!1}),this.container.addEventListener("mouseleave",c,{passive:!0}),()=>{this.container.removeEventListener("scroll",e),this.container.removeEventListener("resize",n),this.container.removeEventListener("mousedown",s),this.container.removeEventListener("mouseup",i),this.container.removeEventListener("mousemove",l),this.container.removeEventListener("mouseleave",c)}}return()=>{this.container.removeEventListener("scroll",e),this.container.removeEventListener("resize",n)}}prev(){var i,l;let e=!1;if((l=(i=this.options)==null?void 0:i.onPrev)==null||l.call(i,{preventDefault:()=>e=!0}),e)return;const{container:n,options:s}=this;s.direction===o.vertical?this.scrollTo({top:n.scrollTop-n.clientHeight}):this.scrollTo({left:n.scrollLeft-n.clientWidth})}next(){var i,l;let e=!1;if((l=(i=this.options)==null?void 0:i.onNext)==null||l.call(i,{preventDefault:()=>e=!0}),e)return;const{container:n,options:s}=this;s.direction===o.vertical?this.scrollTo({top:n.scrollTop+n.clientHeight}):this.scrollTo({left:n.scrollLeft+n.clientWidth})}scrollToIndex(e){const n=this.container.children;if(n[e]){const{container:s}=this,{top:i,left:l}=s.getBoundingClientRect(),{top:c,left:m,width:ct,height:at}=n[e].getBoundingClientRect();if(this.options.direction===o.vertical){const L=c-i,T=(s.clientHeight-at)/2;this.scrollTo({top:s.scrollTop+L-T})}else{const L=m-l,T=(s.clientWidth-ct)/2;this.scrollTo({left:s.scrollLeft+L-T})}}}refresh(e){e&&requestAnimationFrame(()=>{e(this.calculate())})}onMouseUp(){this.isDragged=!1}onMouseLeave(){this.isDragged=!1}onMouseDown(e){e.preventDefault();const{container:n,options:s}=this;this.isDragged=!0,s.direction===o.vertical?(this.dragScrollY=e.pageY-n.offsetTop,this.dragScrollTop=n.scrollTop):(this.dragScrollX=e.pageX-n.offsetLeft,this.dragScrollLeft=n.scrollLeft)}onMouseMove(e){if(!this.isDragged)return;e.preventDefault();const n=typeof this.options.drag=="object"?this.options.drag.sensitivity:4,{container:s,options:i}=this;if(i.direction===o.vertical){const c=(e.pageY-s.offsetTop-this.dragScrollY)*n;s.scrollTop=this.dragScrollTop-c}else{const c=(e.pageX-s.offsetLeft-this.dragScrollX)*n;s.scrollLeft=this.dragScrollLeft-c}}scrollTo({left:e,top:n}){const s=this.options.reduceMotion?"auto":"smooth";this.container.scrollTo({left:e,top:n,behavior:s})}onScroll(){this.container&&(clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onResize(){this.container&&this.refresh(this.options.onScroll)}onScrollHandler(){this.refresh(this.options.onScroll)}get hasNext(){return this.options.direction===o.vertical?this.container.scrollHeight>this.container.scrollTop+this.container.clientHeight:this.container.scrollWidth>this.container.scrollLeft+this.container.clientWidth}get hasPrev(){return this.options.direction===o.vertical?!!this.container.scrollTop:!!this.container.scrollLeft}calculate(){return{left:this.container.scrollLeft,width:this.container.clientWidth,scrollWidth:this.container.scrollWidth,hasPrev:this.hasPrev,hasNext:this.hasNext}}}var x=(t=>(t.neutral="neutral",t.secondary="secondary",t.positive="positive",t.warning="warning",t.error="error",t))(x||{}),M=(t=>(t.temporary="temporary",t.persistent="persistent",t))(M||{}),D=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(D||{}),E=(t=>(t.primary="primary",t.secondary="secondary",t.tertiary="tertiary",t))(E||{}),N=(t=>(t.sm="sm",t.base="base",t))(N||{}),F=(t=>(t["3xs"]="3xs",t["2xs"]="2xs",t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t))(F||{}),w=(t=>(t.top="top",t.bottom="bottom",t.left="left",t.right="right",t))(w||{}),I=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(I||{}),H=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t["2xl"]="2xl",t["3xl"]="3xl",t["4xl"]="4xl",t))(H||{}),W=(t=>(t.primary="primary",t.secondary="secondary",t))(W||{}),j=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(j||{}),C=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t["2xl"]="2xl",t["3xl"]="3xl",t["4xl"]="4xl",t))(C||{}),X=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t["2xl"]="2xl",t["3xl"]="3xl",t["4xl"]="4xl",t))(X||{}),Y=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))(Y||{}),R=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(R||{}),k=(t=>(t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))(k||{}),q=(t=>(t["top-start"]="top-start",t.top="top",t["top-end"]="top-end",t["bottom-start"]="bottom-start",t.bottom="bottom",t["bottom-end"]="bottom-end",t["left-start"]="left-start",t.left="left",t["left-end"]="left-end",t["right-start"]="right-start",t.right="right",t["right-end"]="right-end",t))(q||{}),U=(t=>(t.fixed="fixed",t.absolute="absolute",t))(U||{});const f=(t,e)=>e.findIndex(n=>n===t),$=(t,e)=>{const n=f(t,e);return e[n+1]},G=(t,e)=>{const n=f(t,e);return e[n-1]},h=({focusables:t,event:e})=>{e==null||e.preventDefault();const n=t[0];return n==null||n.focus(),n},g=({focusables:t,event:e})=>{e==null||e.preventDefault();const n=t[t.length-1];return n==null||n.focus(),n},K=(t,e)=>{const n=$(t,e);return n==null||n.focus(),n},O=(t,e)=>{const n=G(t,e);return n==null||n.focus(),n},A=(t,e)=>f(t,e)===0,B=(t,e)=>f(t,e)===e.length-1,nt=(t,e,n)=>{const s=[...n].reverse(),i=s.findIndex(l=>l===t);return s.find((l,c)=>{var m;if(c>i&&l.closest(e)&&t.closest(e)!==l.closest(e)&&((m=s[c+1])==null?void 0:m.closest(e))!==l.closest(e))return l})},rt=(t,e,n)=>{const s=n.findIndex(i=>i===t);return n.find((i,l)=>{if(l>s&&i.closest(e)&&t.closest(e)!==i.closest(e))return i})},st=({current:t,focusables:e,arrowFocusGroupSelector:n})=>{if(!t)return h({focusables:e});const s=rt(t,n,e);return t&&s?(s==null||s.focus(),s):h({focusables:e})},it=({current:t,focusables:e,arrowFocusGroupSelector:n})=>{if(!t)return h({focusables:e});const s=nt(t,n,e);return t&&s?(s==null||s.focus(),s):g({focusables:e})},J=({current:t,focusables:e,event:n})=>{if(u&&(n==null||n.preventDefault()),t){if(B(t,e))return h({focusables:e,event:n});if(u||!n)return K(t,e)}else return h({focusables:e,event:n})},Q=({current:t,focusables:e,event:n})=>{if(u&&(n==null||n.preventDefault()),t){if(A(t,e))return g({focusables:e,event:n});if(u||!n)return O(t,e)}else return g({focusables:e,event:n})},ot=({current:t,event:e,focusables:n,arrowFocusGroupSelector:s})=>s?st({current:t,focusables:n,arrowFocusGroupSelector:s}):J({current:t,focusables:n,event:e}),lt=({current:t,focusables:e,event:n,arrowFocusGroupSelector:s})=>s?it({current:t,focusables:e,arrowFocusGroupSelector:s}):Q({current:t,focusables:e,event:n});r.Scrollable=et,r.SfAlertType=M,r.SfAlertVariant=x,r.SfButtonSize=D,r.SfButtonVariant=E,r.SfChipSize=N,r.SfCounterSize=F,r.SfDrawerPlacement=w,r.SfIconSize=H,r.SfInputSize=I,r.SfLinkVariant=W,r.SfListItemSize=j,r.SfLoaderSize=C,r.SfPopoverPlacement=q,r.SfPopoverStrategy=U,r.SfProgressSize=X,r.SfRatingSize=Y,r.SfScrollableButtonsPlacement=d,r.SfScrollableDirection=o,r.SfSelectSize=R,r.SfThumbnailSize=k,r.clamp=S,r.equal=p,r.findCurrentFocusableIndex=f,r.findNextFocusable=$,r.findPrevFocusable=G,r.focusFirstElement=h,r.focusLastElement=g,r.focusNext=ot,r.focusNextElement=K,r.focusNextOrFirst=J,r.focusPrev=lt,r.focusPrevElement=O,r.focusPrevOrLast=Q,r.generateId=_,r.isBrowser=v,r.isCurrentFirstElement=A,r.isCurrentLastElement=B,r.isReduceMotionEnabled=b,r.isSafari=u,r.isTab=P,r.isTabAndShift=V,r.noop=z,r.roundToNearest=tt,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}); |
@@ -1,4 +0,4 @@ | ||
import SFScrollable from './scrollable'; | ||
import Scrollable from './scrollable'; | ||
export * from './types'; | ||
export { SFScrollable }; | ||
export { Scrollable }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,7 +0,6 @@ | ||
import type { SfScrollableOptions, SfScrollableCallbackData } from './types'; | ||
export default class SFScrollable { | ||
import { type ScrollableOptions, type SfScrollableOnScrollData } from './types'; | ||
export default class Scrollable { | ||
container: HTMLElement; | ||
private options; | ||
private debounceId?; | ||
private isDragged?; | ||
private dragScrollX; | ||
@@ -11,16 +10,12 @@ private dragScrollLeft; | ||
private dragScrollTop; | ||
private scrollListenerInstance; | ||
private resizeListenerInstance; | ||
private mouseDownListenerInstance; | ||
private mouseUpListenerInstance; | ||
private mouseMoveListenerInstance; | ||
private mouseLeaveListenerInstance; | ||
constructor(container: Element, SfScrollableOptions?: Partial<SfScrollableOptions>); | ||
init(): void; | ||
update(SfScrollableOptions?: Partial<SfScrollableOptions>): void; | ||
destroy(): void; | ||
private isDraggedPreviously; | ||
get isDragged(): boolean; | ||
set isDragged(newValue: boolean); | ||
constructor(container: Element, ScrollableOptions?: Partial<ScrollableOptions>); | ||
register(): () => void; | ||
private addListeners; | ||
prev(): void; | ||
next(): void; | ||
scrollToIndex(index: number): void; | ||
refresh(callback?: (data: SfScrollableCallbackData) => void): void; | ||
refresh(callback?: (data: SfScrollableOnScrollData) => void): void; | ||
private onMouseUp; | ||
@@ -30,5 +25,2 @@ private onMouseLeave; | ||
private onMouseMove; | ||
private addListeners; | ||
private removeListeners; | ||
private children; | ||
private scrollTo; | ||
@@ -38,4 +30,6 @@ private onScroll; | ||
private onScrollHandler; | ||
private get hasNext(); | ||
private get hasPrev(); | ||
private calculate; | ||
} | ||
//# sourceMappingURL=scrollable.d.ts.map |
@@ -1,11 +0,14 @@ | ||
export type SfScrollableOptions = { | ||
reduceMotion?: boolean; | ||
snap?: boolean; | ||
drag?: { | ||
sensitivity: number; | ||
}; | ||
vertical?: boolean; | ||
onScroll?: (data: SfScrollableCallbackData) => void; | ||
export declare enum SfScrollableDirection { | ||
vertical = "vertical", | ||
horizontal = "horizontal" | ||
} | ||
export declare enum SfScrollableButtonsPlacement { | ||
none = "none", | ||
floating = "floating", | ||
block = "block" | ||
} | ||
export type SfScrollableOnDragChangeData = { | ||
isDragged: boolean; | ||
}; | ||
export type SfScrollableCallbackData = { | ||
export type SfScrollableOnScrollData = { | ||
left: number; | ||
@@ -17,2 +20,17 @@ width: number; | ||
}; | ||
export type SfScrollableOnPrevData = { | ||
preventDefault: () => void; | ||
}; | ||
export type SfScrollableOnNextData = SfScrollableOnPrevData; | ||
export type ScrollableOptions = { | ||
reduceMotion?: boolean; | ||
drag?: { | ||
sensitivity: number; | ||
} | boolean; | ||
direction?: `${SfScrollableDirection}`; | ||
onDragChange?: (data: SfScrollableOnDragChangeData) => void; | ||
onScroll?: (data: SfScrollableOnScrollData) => void; | ||
onPrev?: (data: SfScrollableOnPrevData) => void; | ||
onNext?: (data: SfScrollableOnNextData) => void; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@storefront-ui/shared", | ||
"description": "Shared set of utils and typings used by `@storefront-ui/*` packages", | ||
"version": "2.0.0-rc.7", | ||
"version": "2.0.0-rc.8", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
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
45166
627