@storefront-ui/shared
Advanced tools
Comparing version 2.4.0-929888b to 2.4.0-9f3c87d
@@ -1,1 +0,1 @@ | ||
(function(r,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(r=typeof globalThis<"u"?globalThis:r||self,a(r["storefront-ui-shared"]={}))})(this,function(r){"use strict";var Dt=Object.defineProperty;var Tt=(r,a,g)=>a in r?Dt(r,a,{enumerable:!0,configurable:!0,writable:!0,value:g}):r[a]=g;var d=(r,a,g)=>(Tt(r,typeof a!="symbol"?a+"":a,g),g);var a=(t=>(t.vertical="vertical",t.horizontal="horizontal",t))(a||{}),g=(t=>(t.none="none",t.floating="floating",t.block="block",t))(g||{});const T=typeof window<"u",E=T&&(window==null?void 0:window.matchMedia("(prefers-reduced-motion: reduce)").matches);function st(t){var e;return typeof window<"u"&&window.navigator!=null?t.test(((e=window.navigator.userAgentData)==null?void 0:e.platform)||window.navigator.platform):!1}function M(t){var e;return typeof window>"u"||window.navigator==null?!1:((e=window.navigator.userAgentData)==null?void 0:e.brands.some(n=>t.test(n.brand)))||t.test(window.navigator.userAgent)}const x=st(/^Mac/i),F=M(/Android/i),m=M(/^((?!chrome|android).)*safari/i);let it=-1;const ot=t=>`sf-${t}--${++it}`,at=t=>t.key==="Tab"&&t.shiftKey,lt=t=>t.key==="Tab"&&!t.shiftKey,ct=()=>{};function dt(t,e,n){return Math.min(Math.max(t,e),n)}function ut(t,e){return Math.round(t/e)*e}function H(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(!H(t[i],e[i]))return!1}else return n==="function"?t.toString()===e.toString():!1;return!0}const N={reduceMotion:E,direction:a.horizontal};class ht{constructor(e,n){d(this,"container");d(this,"options");d(this,"debounceId");d(this,"dragScrollX");d(this,"dragScrollLeft");d(this,"dragScrollY");d(this,"dragScrollTop");d(this,"pointerDownOffsetLeft");d(this,"pointerDownOffsetTop");d(this,"dragDistance");d(this,"isDraggedPreviously",!1);d(this,"resizeObserver",new ResizeObserver(()=>{this.container&&this.refresh(this.options.onScroll)}));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)??N.reduceMotion,direction:(n==null?void 0:n.direction)??N.direction},this.dragScrollX=0,this.dragScrollLeft=0,this.dragScrollY=0,this.dragScrollTop=0,this.pointerDownOffsetLeft=0,this.pointerDownOffsetTop=0,this.dragDistance=0}get isDragged(){return this.isDraggedPreviously}set isDragged(e){var n,s;e!==this.isDraggedPreviously&&(this.isDraggedPreviously=e,(s=(n=this.options).onDragStart)==null||s.call(n,{isDragged:this.isDraggedPreviously}))}register(){const e=this.addListeners();return this.onScrollHandler(),e}addListeners(){const e=this.onScroll.bind(this);if(this.container.addEventListener("scroll",e,{passive:!this.options.drag}),this.resizeObserver.observe(this.container),this.options.drag){const n=this.onMouseDown.bind(this),s=this.onMouseUp.bind(this),i=this.onMouseMove.bind(this),o=this.onMouseLeave.bind(this);return this.container.addEventListener("mousedown",n,{passive:!1}),this.container.addEventListener("mouseup",s,{passive:!0}),this.container.addEventListener("mousemove",i,{passive:!1}),this.container.addEventListener("mouseleave",o,{passive:!0}),()=>{this.container.removeEventListener("scroll",e),this.container.removeEventListener("mousedown",n),this.container.removeEventListener("mouseup",s),this.container.removeEventListener("mousemove",i),this.container.removeEventListener("mouseleave",o),this.resizeObserver.unobserve(this.container)}}return()=>{this.container.removeEventListener("scroll",e),this.resizeObserver.unobserve(this.container)}}prev(){var i,o;let e=!1;if((o=(i=this.options)==null?void 0:i.onPrev)==null||o.call(i,{preventDefault:()=>e=!0}),e)return;const{container:n,options:s}=this;s.direction===a.vertical?this.scrollTo({top:n.scrollTop-n.clientHeight}):this.scrollTo({left:n.scrollLeft-n.clientWidth})}next(){var i,o;let e=!1;if((o=(i=this.options)==null?void 0:i.onNext)==null||o.call(i,{preventDefault:()=>e=!0}),e)return;const{container:n,options:s}=this;s.direction===a.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:o}=s.getBoundingClientRect(),{top:c,left:h,width:u,height:y}=n[e].getBoundingClientRect();if(this.options.direction===a.vertical){const f=c-i,b=(s.clientHeight-y)/2;this.scrollTo({top:s.scrollTop+f-b})}else{const f=h-o,b=(s.clientWidth-u)/2;this.scrollTo({left:s.scrollLeft+f-b})}}}refresh(e){e&&requestAnimationFrame(()=>{e(this.calculate())})}onMouseUp(e){var h,u;const{container:n,options:s}=this;this.isDragged=!1;const i=typeof this.options.drag=="object"&&this.options.drag.sensitivity?this.options.drag.sensitivity:4,o=typeof this.options.drag=="object"?this.options.drag.containerWidth:!1,c=10;if(s.direction===a.vertical){const f=(e.pageY-n.offsetTop-this.dragScrollY)*i;if(o){if(Math.abs(this.dragDistance)<10)return;n.scrollLeft=this.dragScrollLeft-(this.dragDistance<0?n.clientHeight-c:-n.clientHeight+c)}else n.scrollTop=this.dragScrollTop-f}else{const f=(e.pageX-n.offsetLeft-this.dragScrollX)*i;if(o){if(Math.abs(this.dragDistance)<10)return;n.scrollLeft=this.dragScrollLeft-(this.dragDistance<0?n.clientWidth-c:-n.clientWidth+c)}else n.scrollLeft=this.dragScrollLeft-f}(u=(h=this.options).onDragEnd)==null||u.call(h,{isDragged:!1,swipeLeft:this.dragDistance>-10,swipeRight:this.dragDistance<10})}onMouseLeave(){this.isDragged=!1}onMouseDown(e){e.preventDefault();const{container:n,options:s}=this;this.isDragged=!0,this.pointerDownOffsetLeft=e.offsetX,this.pointerDownOffsetTop=e.offsetY,s.direction===a.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{options:n}=this;n.direction===a.vertical?this.dragDistance=this.pointerDownOffsetTop-e.offsetY:this.dragDistance=this.pointerDownOffsetLeft-e.offsetX}scrollTo({left:e,top:n}){const s=this.options.reduceMotion?"auto":"smooth";this.container.scrollTo({left:e,top:n,behavior:s})}onScroll(e){this.container&&(this.options.drag&&e.preventDefault(),clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onScrollHandler(){this.refresh(this.options.onScroll)}get hasNext(){return this.options.direction===a.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===a.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 k=(t=>(t.neutral="neutral",t.secondary="secondary",t.positive="positive",t.warning="warning",t.error="error",t))(k||{}),O=(t=>(t.temporary="temporary",t.persistent="persistent",t))(O||{}),W=(t=>(t.standard="standard",t.dot="dot",t))(W||{}),I=(t=>(t["top-right"]="top-right",t["top-left"]="top-left",t["bottom-right"]="bottom-right",t["bottom-left"]="bottom-left",t))(I||{}),K=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(K||{}),C=(t=>(t.primary="primary",t.secondary="secondary",t.tertiary="tertiary",t))(C||{}),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||{}),j=(t=>(t.top="top",t.bottom="bottom",t.left="left",t.right="right",t))(j||{}),A=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(A||{}),G=(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))(G||{}),R=(t=>(t.primary="primary",t.secondary="secondary",t))(R||{}),U=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(U||{}),q=(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))(q||{}),B=(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))(B||{}),$=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))($||{}),V=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(V||{}),J=(t=>(t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))(J||{}),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||{}),Z=(t=>(t.fixed="fixed",t.absolute="absolute",t))(Z||{});const v=(t,e)=>e.findIndex(n=>n===t),_=(t,e)=>{const n=v(t,e);return e[n+1]},P=(t,e)=>{const n=v(t,e);return e[n-1]},p=({focusables:t,event:e})=>{e==null||e.preventDefault();const n=t[0];return n==null||n.focus(),n},L=({focusables:t,event:e})=>{e==null||e.preventDefault();const n=t[t.length-1];return n==null||n.focus(),n},z=(t,e)=>{const n=_(t,e);return n==null||n.focus(),n},S=(t,e)=>{const n=P(t,e);return n==null||n.focus(),n},tt=(t,e)=>v(t,e)===0,et=(t,e)=>v(t,e)===e.length-1,ft=(t,e,n)=>{const s=[...n].reverse(),i=s.findIndex(o=>o===t);return s.find((o,c)=>{var h;if(c>i&&o.closest(e)&&t.closest(e)!==o.closest(e)&&((h=s[c+1])==null?void 0:h.closest(e))!==o.closest(e))return o})},gt=(t,e,n)=>{const s=n.findIndex(i=>i===t);return n.find((i,o)=>{if(o>s&&i.closest(e)&&t.closest(e)!==i.closest(e))return i})},pt=({current:t,focusables:e,arrowFocusGroupSelector:n})=>{if(!t)return p({focusables:e});const s=gt(t,n,e);return t&&s?(s==null||s.focus(),s):p({focusables:e})},mt=({current:t,focusables:e,arrowFocusGroupSelector:n})=>{if(!t)return p({focusables:e});const s=ft(t,n,e);return t&&s?(s==null||s.focus(),s):L({focusables:e})},nt=({current:t,focusables:e,event:n})=>{if(m&&(n==null||n.preventDefault()),t){if(et(t,e))return p({focusables:e,event:n});if(m||!n)return z(t,e)}else return p({focusables:e,event:n})},rt=({current:t,focusables:e,event:n})=>{if(m&&(n==null||n.preventDefault()),t){if(tt(t,e))return L({focusables:e,event:n});if(m||!n)return S(t,e)}else return L({focusables:e,event:n})},vt=({current:t,event:e,focusables:n,arrowFocusGroupSelector:s})=>s?pt({current:t,focusables:n,arrowFocusGroupSelector:s}):nt({current:t,focusables:n,event:e}),yt=({current:t,focusables:e,event:n,arrowFocusGroupSelector:s})=>s?mt({current:t,focusables:e,arrowFocusGroupSelector:s}):rt({current:t,focusables:e,event:n});function bt(t){return t.mozInputSource===0&&t.isTrusted?!0:F&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}function Lt(t){return!(t.metaKey||!x&&t.altKey||t.ctrlKey||t.key==="Control"||t.key==="Shift"||t.key==="Meta")}const wt=()=>{let t=null;const e=new Set;let n=!1,s=!1,i=!1;const o=()=>t!=="pointer",c=(l,D)=>{for(const w of e)w(l,D)},h=l=>{s=!0,Lt(l)&&(t="keyboard",c("keyboard",l))},u=l=>{t="pointer",(l.type==="mousedown"||l.type==="pointerdown")&&(s=!0,c("pointer",l))},y=l=>{bt(l)&&(s=!0,t="virtual")},f=l=>{l.target===window||l.target===document||(!s&&!i&&(t="virtual",c("virtual",l)),s=!1,i=!1)},b=()=>{s=!1,i=!0};return{isFocusVisible:o,changeHandlers:e,setupGlobalFocusEvents:()=>{if(typeof window>"u"||n)return;const l=HTMLElement.prototype.focus;HTMLElement.prototype.focus=function(){s=!0,l.apply(this,arguments)},document.addEventListener("keydown",h,!0),document.addEventListener("keyup",h,!0),document.addEventListener("click",y,!0),window.addEventListener("focus",f,!0),window.addEventListener("blur",b,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",u,!0),document.addEventListener("pointermove",u,!0),document.addEventListener("pointerup",u,!0)):(document.addEventListener("mousedown",u,!0),document.addEventListener("mousemove",u,!0),document.addEventListener("mouseup",u,!0)),n=!0},isKeyboardFocusEvent:(l,D,w)=>!(l&&D==="keyboard"&&w instanceof KeyboardEvent&&!["Tab","Escape"].includes(w.key))}};r.Scrollable=ht,r.SfAlertType=O,r.SfAlertVariant=k,r.SfBadgePlacement=I,r.SfBadgeVariant=W,r.SfButtonSize=K,r.SfButtonVariant=C,r.SfChipSize=X,r.SfCounterSize=Y,r.SfDrawerPlacement=j,r.SfIconSize=G,r.SfInputSize=A,r.SfLinkVariant=R,r.SfListItemSize=U,r.SfLoaderSize=q,r.SfPopoverPlacement=Q,r.SfPopoverStrategy=Z,r.SfProgressSize=B,r.SfRatingSize=$,r.SfScrollableButtonsPlacement=g,r.SfScrollableDirection=a,r.SfSelectSize=V,r.SfThumbnailSize=J,r.clamp=dt,r.equal=H,r.findCurrentFocusableIndex=v,r.findNextFocusable=_,r.findPrevFocusable=P,r.focusFirstElement=p,r.focusLastElement=L,r.focusNext=vt,r.focusNextElement=z,r.focusNextOrFirst=nt,r.focusPrev=yt,r.focusPrevElement=S,r.focusPrevOrLast=rt,r.focusVisibleManager=wt,r.generateId=ot,r.isAndroid=F,r.isBrowser=T,r.isCurrentFirstElement=tt,r.isCurrentLastElement=et,r.isMac=x,r.isReduceMotionEnabled=E,r.isSafari=m,r.isTab=lt,r.isTabAndShift=at,r.noop=ct,r.roundToNearest=ut,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}); | ||
(function(r,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(r=typeof globalThis<"u"?globalThis:r||self,a(r["storefront-ui-shared"]={}))})(this,function(r){"use strict";var Tt=Object.defineProperty;var Et=(r,a,g)=>a in r?Tt(r,a,{enumerable:!0,configurable:!0,writable:!0,value:g}):r[a]=g;var d=(r,a,g)=>(Et(r,typeof a!="symbol"?a+"":a,g),g);var a=(t=>(t.vertical="vertical",t.horizontal="horizontal",t))(a||{}),g=(t=>(t.none="none",t.floating="floating",t.block="block",t))(g||{});const T=typeof window<"u",E=T&&(window==null?void 0:window.matchMedia("(prefers-reduced-motion: reduce)").matches);function it(t){var e;return typeof window<"u"&&window.navigator!=null?t.test(((e=window.navigator.userAgentData)==null?void 0:e.platform)||window.navigator.platform):!1}function M(t){var e;return typeof window>"u"||window.navigator==null?!1:((e=window.navigator.userAgentData)==null?void 0:e.brands.some(n=>t.test(n.brand)))||t.test(window.navigator.userAgent)}const x=it(/^Mac/i),F=M(/Android/i),p=M(/^((?!chrome|android).)*safari/i);let ot=-1;const at=t=>`sf-${t}--${++ot}`,lt=t=>t.key==="Tab"&&t.shiftKey,ct=t=>t.key==="Tab"&&!t.shiftKey,dt=()=>{};function ut(t,e,n){return Math.min(Math.max(t,e),n)}function ht(t,e){return Math.round(t/e)*e}function H(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(!H(t[i],e[i]))return!1}else return n==="function"?t.toString()===e.toString():!1;return!0}const N={reduceMotion:E,direction:a.horizontal};class ft{constructor(e,n){d(this,"container");d(this,"options");d(this,"debounceId");d(this,"dragScrollX");d(this,"dragScrollLeft");d(this,"dragScrollY");d(this,"dragScrollTop");d(this,"pointerDownOffsetLeft");d(this,"pointerDownOffsetTop");d(this,"dragDistance");d(this,"isDraggedPreviously",!1);d(this,"resizeObserver",new ResizeObserver(()=>{this.container&&this.refresh(this.options.onScroll)}));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)??N.reduceMotion,direction:(n==null?void 0:n.direction)??N.direction},this.dragScrollX=0,this.dragScrollLeft=0,this.dragScrollY=0,this.dragScrollTop=0,this.pointerDownOffsetLeft=0,this.pointerDownOffsetTop=0,this.dragDistance=0}get isDragged(){return this.isDraggedPreviously}set isDragged(e){var n,s;e!==this.isDraggedPreviously&&(this.isDraggedPreviously=e,(s=(n=this.options).onDragStart)==null||s.call(n,{isDragged:this.isDraggedPreviously}))}register(){const e=this.addListeners();return this.onScrollHandler(),e}addListeners(){const e=this.onScroll.bind(this);if(this.container.addEventListener("scroll",e,{passive:!this.options.drag}),this.resizeObserver.observe(this.container),this.options.drag){const n=this.onMouseDown.bind(this),s=this.onMouseUp.bind(this),i=this.onMouseMove.bind(this),o=this.onMouseLeave.bind(this);return this.container.addEventListener("mousedown",n,{passive:!1}),this.container.addEventListener("mouseup",s,{passive:!0}),this.container.addEventListener("mousemove",i,{passive:!1}),this.container.addEventListener("mouseleave",o,{passive:!0}),()=>{this.container.removeEventListener("scroll",e),this.container.removeEventListener("mousedown",n),this.container.removeEventListener("mouseup",s),this.container.removeEventListener("mousemove",i),this.container.removeEventListener("mouseleave",o),this.resizeObserver.unobserve(this.container)}}return()=>{this.container.removeEventListener("scroll",e),this.resizeObserver.unobserve(this.container)}}prev(){var i,o;let e=!1;if((o=(i=this.options)==null?void 0:i.onPrev)==null||o.call(i,{preventDefault:()=>e=!0}),e)return;const{container:n,options:s}=this;s.direction===a.vertical?this.scrollTo({top:n.scrollTop-n.clientHeight}):this.scrollTo({left:n.scrollLeft-n.clientWidth})}next(){var i,o;let e=!1;if((o=(i=this.options)==null?void 0:i.onNext)==null||o.call(i,{preventDefault:()=>e=!0}),e)return;const{container:n,options:s}=this;s.direction===a.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:o}=s.getBoundingClientRect(),{top:c,left:h,width:u,height:b}=n[e].getBoundingClientRect();if(this.options.direction===a.vertical){const f=c-i,y=(s.clientHeight-b)/2;this.scrollTo({top:s.scrollTop+f-y})}else{const f=h-o,y=(s.clientWidth-u)/2;this.scrollTo({left:s.scrollLeft+f-y})}}}refresh(e){e&&requestAnimationFrame(()=>{e(this.calculate())})}onMouseUp(e){var h,u;const{container:n,options:s}=this;this.isDragged=!1;const i=typeof this.options.drag=="object"&&this.options.drag.sensitivity?this.options.drag.sensitivity:4,o=typeof this.options.drag=="object"?this.options.drag.containerWidth:!1,c=10;if(s.direction===a.vertical){const f=(e.pageY-n.offsetTop-this.dragScrollY)*i;if(o){if(Math.abs(this.dragDistance)<10)return;n.scrollLeft=this.dragScrollLeft-(this.dragDistance<0?n.clientHeight-c:-n.clientHeight+c)}else n.scrollTop=this.dragScrollTop-f}else{const f=(e.pageX-n.offsetLeft-this.dragScrollX)*i;if(o){if(Math.abs(this.dragDistance)<10)return;n.scrollLeft=this.dragScrollLeft-(this.dragDistance<0?n.clientWidth-c:-n.clientWidth+c)}else n.scrollLeft=this.dragScrollLeft-f}(u=(h=this.options).onDragEnd)==null||u.call(h,{isDragged:!1,swipeLeft:this.dragDistance>-10,swipeRight:this.dragDistance<10})}onMouseLeave(){this.isDragged=!1}onMouseDown(e){e.preventDefault();const{container:n,options:s}=this;this.isDragged=!0,this.pointerDownOffsetLeft=e.offsetX,this.pointerDownOffsetTop=e.offsetY,s.direction===a.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{options:n}=this;n.direction===a.vertical?this.dragDistance=this.pointerDownOffsetTop-e.offsetY:this.dragDistance=this.pointerDownOffsetLeft-e.offsetX}scrollTo({left:e,top:n}){const s=this.options.reduceMotion?"auto":"smooth";this.container.scrollTo({left:e,top:n,behavior:s})}onScroll(e){this.container&&(this.options.drag&&e.preventDefault(),clearTimeout(this.debounceId),this.debounceId=setTimeout(this.onScrollHandler.bind(this),50))}onScrollHandler(){this.refresh(this.options.onScroll)}get hasNext(){return this.options.direction===a.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===a.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 k=(t=>(t.neutral="neutral",t.secondary="secondary",t.positive="positive",t.warning="warning",t.error="error",t))(k||{}),O=(t=>(t.temporary="temporary",t.persistent="persistent",t))(O||{}),W=(t=>(t.standard="standard",t.dot="dot",t))(W||{}),I=(t=>(t["top-right"]="top-right",t["top-left"]="top-left",t["bottom-right"]="bottom-right",t["bottom-left"]="bottom-left",t))(I||{}),K=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(K||{}),C=(t=>(t.primary="primary",t.secondary="secondary",t.tertiary="tertiary",t))(C||{}),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||{}),j=(t=>(t.top="top",t.bottom="bottom",t.left="left",t.right="right",t))(j||{}),A=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(A||{}),G=(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))(G||{}),R=(t=>(t.primary="primary",t.secondary="secondary",t))(R||{}),U=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(U||{}),q=(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))(q||{}),$=(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))($||{}),B=(t=>(t.xs="xs",t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))(B||{}),V=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(V||{}),J=(t=>(t.sm="sm",t.base="base",t.lg="lg",t))(J||{}),Q=(t=>(t.sm="sm",t.base="base",t.lg="lg",t.xl="xl",t))(Q||{}),Z=(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))(Z||{}),_=(t=>(t.fixed="fixed",t.absolute="absolute",t))(_||{});const v=(t,e)=>e.findIndex(n=>n===t),P=(t,e)=>{const n=v(t,e);return e[n+1]},z=(t,e)=>{const n=v(t,e);return e[n-1]},m=({focusables:t,event:e})=>{e==null||e.preventDefault();const n=t[0];return n==null||n.focus(),n},L=({focusables:t,event:e})=>{e==null||e.preventDefault();const n=t[t.length-1];return n==null||n.focus(),n},S=(t,e)=>{const n=P(t,e);return n==null||n.focus(),n},tt=(t,e)=>{const n=z(t,e);return n==null||n.focus(),n},et=(t,e)=>v(t,e)===0,nt=(t,e)=>v(t,e)===e.length-1,gt=(t,e,n)=>{const s=[...n].reverse(),i=s.findIndex(o=>o===t);return s.find((o,c)=>{var h;if(c>i&&o.closest(e)&&t.closest(e)!==o.closest(e)&&((h=s[c+1])==null?void 0:h.closest(e))!==o.closest(e))return o})},mt=(t,e,n)=>{const s=n.findIndex(i=>i===t);return n.find((i,o)=>{if(o>s&&i.closest(e)&&t.closest(e)!==i.closest(e))return i})},pt=({current:t,focusables:e,arrowFocusGroupSelector:n})=>{if(!t)return m({focusables:e});const s=mt(t,n,e);return t&&s?(s==null||s.focus(),s):m({focusables:e})},vt=({current:t,focusables:e,arrowFocusGroupSelector:n})=>{if(!t)return m({focusables:e});const s=gt(t,n,e);return t&&s?(s==null||s.focus(),s):L({focusables:e})},rt=({current:t,focusables:e,event:n})=>{if(p&&(n==null||n.preventDefault()),t){if(nt(t,e))return m({focusables:e,event:n});if(p||!n)return S(t,e)}else return m({focusables:e,event:n})},st=({current:t,focusables:e,event:n})=>{if(p&&(n==null||n.preventDefault()),t){if(et(t,e))return L({focusables:e,event:n});if(p||!n)return tt(t,e)}else return L({focusables:e,event:n})},bt=({current:t,event:e,focusables:n,arrowFocusGroupSelector:s})=>s?pt({current:t,focusables:n,arrowFocusGroupSelector:s}):rt({current:t,focusables:n,event:e}),yt=({current:t,focusables:e,event:n,arrowFocusGroupSelector:s})=>s?vt({current:t,focusables:e,arrowFocusGroupSelector:s}):st({current:t,focusables:e,event:n});function Lt(t){return t.mozInputSource===0&&t.isTrusted?!0:F&&t.pointerType?t.type==="click"&&t.buttons===1:t.detail===0&&!t.pointerType}function wt(t){return!(t.metaKey||!x&&t.altKey||t.ctrlKey||t.key==="Control"||t.key==="Shift"||t.key==="Meta")}const Dt=()=>{let t=null;const e=new Set;let n=!1,s=!1,i=!1;const o=()=>t!=="pointer",c=(l,D)=>{for(const w of e)w(l,D)},h=l=>{s=!0,wt(l)&&(t="keyboard",c("keyboard",l))},u=l=>{t="pointer",(l.type==="mousedown"||l.type==="pointerdown")&&(s=!0,c("pointer",l))},b=l=>{Lt(l)&&(s=!0,t="virtual")},f=l=>{l.target===window||l.target===document||(!s&&!i&&(t="virtual",c("virtual",l)),s=!1,i=!1)},y=()=>{s=!1,i=!0};return{isFocusVisible:o,changeHandlers:e,setupGlobalFocusEvents:()=>{if(typeof window>"u"||n)return;const l=HTMLElement.prototype.focus;HTMLElement.prototype.focus=function(){s=!0,l.apply(this,arguments)},document.addEventListener("keydown",h,!0),document.addEventListener("keyup",h,!0),document.addEventListener("click",b,!0),window.addEventListener("focus",f,!0),window.addEventListener("blur",y,!1),typeof PointerEvent<"u"?(document.addEventListener("pointerdown",u,!0),document.addEventListener("pointermove",u,!0),document.addEventListener("pointerup",u,!0)):(document.addEventListener("mousedown",u,!0),document.addEventListener("mousemove",u,!0),document.addEventListener("mouseup",u,!0)),n=!0},isKeyboardFocusEvent:(l,D,w)=>!(l&&D==="keyboard"&&w instanceof KeyboardEvent&&!["Tab","Escape"].includes(w.key))}};r.Scrollable=ft,r.SfAlertType=O,r.SfAlertVariant=k,r.SfBadgePlacement=I,r.SfBadgeVariant=W,r.SfButtonSize=K,r.SfButtonVariant=C,r.SfChipSize=X,r.SfCounterSize=Y,r.SfDrawerPlacement=j,r.SfIconSize=G,r.SfInputSize=A,r.SfLinkVariant=R,r.SfListItemSize=U,r.SfLoaderSize=q,r.SfPopoverPlacement=Z,r.SfPopoverStrategy=_,r.SfProgressSize=$,r.SfRatingButtonSize=V,r.SfRatingSize=B,r.SfScrollableButtonsPlacement=g,r.SfScrollableDirection=a,r.SfSelectSize=J,r.SfThumbnailSize=Q,r.clamp=ut,r.equal=H,r.findCurrentFocusableIndex=v,r.findNextFocusable=P,r.findPrevFocusable=z,r.focusFirstElement=m,r.focusLastElement=L,r.focusNext=bt,r.focusNextElement=S,r.focusNextOrFirst=rt,r.focusPrev=yt,r.focusPrevElement=tt,r.focusPrevOrLast=st,r.focusVisibleManager=Dt,r.generateId=at,r.isAndroid=F,r.isBrowser=T,r.isCurrentFirstElement=et,r.isCurrentLastElement=nt,r.isMac=x,r.isReduceMotionEnabled=E,r.isSafari=p,r.isTab=ct,r.isTabAndShift=lt,r.noop=dt,r.roundToNearest=ht,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}); |
@@ -14,2 +14,3 @@ export * from './SfAlert'; | ||
export * from './SfRating'; | ||
export * from './SfRatingButton'; | ||
export * from './SfSelect'; | ||
@@ -16,0 +17,0 @@ export * from './SfThumbnail'; |
{ | ||
"name": "@storefront-ui/shared", | ||
"description": "Shared set of utils and typings used by `@storefront-ui/*` packages", | ||
"version": "2.4.0-929888b", | ||
"version": "2.4.0-9f3c87d", | ||
"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
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
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
56690
73
775