@luciodale/swipe-bar 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +298 -0
- package/dist/SwipeBarProvider.d.ts +29 -0
- package/dist/SwipeBarProvider.d.ts.map +1 -0
- package/dist/ToggleLeft.d.ts +11 -0
- package/dist/ToggleLeft.d.ts.map +1 -0
- package/dist/ToggleRight.d.ts +11 -0
- package/dist/ToggleRight.d.ts.map +1 -0
- package/dist/components/Overlay.d.ts +10 -0
- package/dist/components/Overlay.d.ts.map +1 -0
- package/dist/components/SwipeBarLeft.d.ts +4 -0
- package/dist/components/SwipeBarLeft.d.ts.map +1 -0
- package/dist/components/SwipeBarRight.d.ts +4 -0
- package/dist/components/SwipeBarRight.d.ts.map +1 -0
- package/dist/components/ToggleIcon.d.ts +5 -0
- package/dist/components/ToggleIcon.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/swipe-bar.es.js +1101 -0
- package/dist/swipe-bar.umd.js +22 -0
- package/dist/swipeSidebarShared.d.ts +170 -0
- package/dist/swipeSidebarShared.d.ts.map +1 -0
- package/dist/useMediaQuery.d.ts +2 -0
- package/dist/useMediaQuery.d.ts.map +1 -0
- package/dist/useSwipeBarContext.d.ts +20 -0
- package/dist/useSwipeBarContext.d.ts.map +1 -0
- package/dist/useSwipeLeftSidebar.d.ts +4 -0
- package/dist/useSwipeLeftSidebar.d.ts.map +1 -0
- package/dist/useSwipeRightSidebar.d.ts +4 -0
- package/dist/useSwipeRightSidebar.d.ts.map +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(function(_,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],f):(_=typeof globalThis<"u"?globalThis:_||self,f(_.LucioDaleSwipeBar={},_.React))})(this,function(_,f){"use strict";var K={exports:{}},Y={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var re;function Ee(){if(re)return Y;re=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(o,a,i){var l=null;if(i!==void 0&&(l=""+i),a.key!==void 0&&(l=""+a.key),"key"in a){i={};for(var s in a)s!=="key"&&(i[s]=a[s])}else i=a;return a=i.ref,{$$typeof:e,type:o,key:l,ref:a!==void 0?a:null,props:i}}return Y.Fragment=n,Y.jsx=r,Y.jsxs=r,Y}var B={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var ne;function ye(){return ne||(ne=1,process.env.NODE_ENV!=="production"&&function(){function e(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===W?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case A:return"Fragment";case P:return"Profiler";case L:return"StrictMode";case T:return"Suspense";case u:return"SuspenseList";case D:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case I:return"Portal";case x:return t.displayName||"Context";case M:return(t._context.displayName||"Context")+".Consumer";case X:var d=t.render;return t=t.displayName,t||(t=d.displayName||d.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case v:return d=t.displayName||null,d!==null?d:e(t.type)||"Memo";case y:d=t._payload,t=t._init;try{return e(t(d))}catch{}}return null}function n(t){return""+t}function r(t){try{n(t);var d=!1}catch{d=!0}if(d){d=console;var w=d.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return w.call(d,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),n(t)}}function o(t){if(t===A)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===y)return"<...>";try{var d=e(t);return d?"<"+d+">":"<...>"}catch{return"<...>"}}function a(){var t=G.A;return t===null?null:t.getOwner()}function i(){return Error("react-stack-top-frame")}function l(t){if(Q.call(t,"key")){var d=Object.getOwnPropertyDescriptor(t,"key").get;if(d&&d.isReactWarning)return!1}return t.key!==void 0}function s(t,d){function w(){H||(H=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",d))}w.isReactWarning=!0,Object.defineProperty(t,"key",{get:w,configurable:!0})}function m(){var t=e(this.type);return J[t]||(J[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function c(t,d,w,b,Z,ee){var E=w.ref;return t={$$typeof:C,type:t,key:d,props:w,_owner:b},(E!==void 0?E:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:m}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function R(t,d,w,b,Z,ee){var E=d.children;if(E!==void 0)if(b)if($(E)){for(b=0;b<E.length;b++)O(E[b]);Object.freeze&&Object.freeze(E)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else O(E);if(Q.call(d,"key")){E=e(t);var N=Object.keys(d).filter(function(He){return He!=="key"});b=0<N.length?"{key: someKey, "+N.join(": ..., ")+": ...}":"{key: someKey}",be[E+b]||(N=0<N.length?"{"+N.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,b,E,N,E),be[E+b]=!0)}if(E=null,w!==void 0&&(r(w),E=""+w),l(d)&&(r(d.key),E=""+d.key),"key"in d){w={};for(var te in d)te!=="key"&&(w[te]=d[te])}else w=d;return E&&s(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),c(t,E,w,a(),Z,ee)}function O(t){h(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===y&&(t._payload.status==="fulfilled"?h(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function h(t){return typeof t=="object"&&t!==null&&t.$$typeof===C}var g=f,C=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),L=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),M=Symbol.for("react.consumer"),x=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),W=Symbol.for("react.client.reference"),G=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=Object.prototype.hasOwnProperty,$=Array.isArray,U=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(t){return t()}};var H,J={},S=g.react_stack_bottom_frame.bind(g,i)(),j=U(o(i)),be={};B.Fragment=A,B.jsx=function(t,d,w){var b=1e4>G.recentlyCreatedOwnerStacks++;return R(t,d,w,!1,b?Error("react-stack-top-frame"):S,b?U(o(t)):j)},B.jsxs=function(t,d,w){var b=1e4>G.recentlyCreatedOwnerStacks++;return R(t,d,w,!0,b?Error("react-stack-top-frame"):S,b?U(o(t)):j)}}()),B}process.env.NODE_ENV==="production"?K.exports=Ee():K.exports=ye();var p=K.exports;const ie=f.createContext(null),Oe=({children:e,sidebarWidthPx:n,transitionMs:r,edgeActivationWidthPx:o,dragActivationDeltaPx:a,showOverlay:i,closeSidebarOnOverlayClick:l,isAbsolute:s,overlayBackgroundColor:m,toggleIconColor:c,toggleIconSizePx:R,toggleIconEdgeDistancePx:O,showToggle:h,mediaQueryWidth:g})=>{const[C,I]=f.useState(null),[A,L]=f.useState(!1),[P,M]=f.useState(!1),[x,X]=f.useState({}),[T,u]=f.useState({}),v=f.useRef(null),y=f.useRef(null),D=f.useRef(null),W=f.useRef(null),[G,Q]=f.useState({sidebarWidthPx:n??Ae,transitionMs:r??xe,edgeActivationWidthPx:o??Te,dragActivationDeltaPx:a??_e,showOverlay:i??Pe,closeSidebarOnOverlayClick:l??Ce,isAbsolute:s??Le,overlayBackgroundColor:m??oe,toggleIconColor:c??Ie,toggleIconSizePx:R??Me,toggleIconEdgeDistancePx:O??Xe,showToggle:h??ke,mediaQueryWidth:g??se}),$=f.useCallback(S=>{Q(j=>({...j,...S}))},[]),U=f.useCallback(S=>{Be({side:S,ref:S==="left"?v:y,options:S==="left"?x:T,toggleRef:S==="left"?D:W,afterApply:()=>{S==="left"?L(!0):M(!0),I(S)}})},[x,T]),H=f.useCallback(S=>{Fe({ref:S==="left"?v:y,options:S==="left"?x:T,toggleRef:S==="left"?D:W,side:S,afterApply:()=>{S==="left"?L(!1):M(!1),I(null)}})},[x,T]),J=f.useCallback((S,j)=>{Ge({ref:S==="left"?v:y,toggleRef:S==="left"?D:W,options:S==="left"?x:T,translateX:j})},[x,T]);return p.jsx(ie.Provider,{value:{lockedSidebar:C,setLockedSidebar:I,isLeftOpen:A,isRightOpen:P,leftSidebarRef:v,rightSidebarRef:y,openSidebar:U,closeSidebar:H,dragSidebar:J,globalOptions:G,setGlobalOptions:$,leftSidebarOptions:x,rightSidebarOptions:T,setLeftSidebarOptions:X,setRightSidebarOptions:u,leftToggleRef:D,rightToggleRef:W},children:e})},k=()=>{const e=f.useContext(ie);if(!e)throw new Error("useSwipeBarContext must be used within SwipeBarProvider");return e},xe=200,Te=40,_e=20,Ae=320,Pe=!0,Ce=!0,Le=!1,oe="rgba(0, 0, 0, 0.5)",ae="rgb(36,36,36)",Ie="white",Me=40,Xe=40,ke=!0,se=640,ce={zIndex:30,width:0,top:0,bottom:0,flexShrink:0,overflowX:"hidden",willChange:"transform"},De={position:"fixed",left:0,top:0,bottom:0},We={position:"fixed",right:0,top:0,bottom:0},je={position:"fixed",zIndex:15,top:0,left:0,width:"100%",height:"100%",backgroundColor:oe,transitionProperty:"opacity",pointerEvents:"none",opacity:0},Ne={opacity:1,pointerEvents:"auto"},ue={position:"fixed",zIndex:20,top:"50%",transform:"translateY(-50%)",width:"1px",display:"flex",justifyContent:"center"},Ye={position:"relative",cursor:"pointer",display:"flex",height:"72px",alignItems:"center",justifyContent:"center"},Be=({ref:e,side:n,options:r,toggleRef:o,afterApply:a})=>{requestAnimationFrame(()=>{e.current&&(e.current.style.transition=`transform ${r.transitionMs}ms ease, width ${r.transitionMs}ms ease`,requestAnimationFrame(()=>{e.current&&(e.current.style.transform="",e.current.style.width=`${r.sidebarWidthPx}px`,o.current&&r.sidebarWidthPx&&(o.current.style.opacity="1",o.current.style.transform=`translateY(-50%) translateX(${n==="left"?r.sidebarWidthPx:-r.sidebarWidthPx}px)`),a())}))}),setTimeout(()=>{},0)},Fe=({ref:e,options:n,side:r,toggleRef:o,afterApply:a})=>{requestAnimationFrame(()=>{e.current&&(e.current.style.transition=`transform ${n.transitionMs}ms ease, width ${n.transitionMs}ms ease`,requestAnimationFrame(()=>{e.current&&(e.current.style.transform=r==="left"?"translateX(-100%)":"translateX(100%)",e.current.style.width="0px",o.current&&(o.current.style.opacity="1",o.current.style.transform="translateY(-50%)"),a())}))})},Ge=({ref:e,toggleRef:n,options:r,translateX:o})=>{!e.current||o===null||(e.current.style.transition="none",requestAnimationFrame(()=>{if(!e.current)return;const a=`${r.sidebarWidthPx}px`;e.current.style.width!==a&&(e.current.style.width=a),e.current.style.transform=`translateX(${o}px)`,n.current&&(n.current.style.opacity="0",n.current.style.transform=`translateY(-50%) translateX(${o}px)`)}))},z=({refs:e,clientX:n,clientY:r,touchId:o,isMouse:a})=>{e.draggingRef.current={startX:n,startY:r,activeTouchId:o,isMouse:a,isActivated:!1},e.currentXRef.current=n,e.prevXRef.current=n},le=({refs:e,dragSidebar:n,onDeactivate:r})=>{e.draggingRef.current=null,e.currentXRef.current=null,e.prevXRef.current=null,n(null),r()},V=e=>e instanceof Element?!!e.closest("input, textarea, [contenteditable='true']"):!1,de=(e,n)=>{for(let r=0;r<e.length;r++){const o=e[r];if(n==null||o.identifier===n)return o}return null},fe=(e,n)=>{for(let r=0;r<e.length;r++)if(e[r].identifier===n)return!0;return!1},ge=(e,n)=>{const{globalOptions:r,setLeftSidebarOptions:o,setRightSidebarOptions:a}=k(),{sidebarWidthPx:i,transitionMs:l,edgeActivationWidthPx:s,dragActivationDeltaPx:m,showOverlay:c,closeSidebarOnOverlayClick:R,isAbsolute:O,overlayBackgroundColor:h,toggleIconColor:g,toggleIconSizePx:C,toggleIconEdgeDistancePx:I,showToggle:A,mediaQueryWidth:L}=n,P=f.useMemo(()=>({sidebarWidthPx:i??r.sidebarWidthPx,transitionMs:l??r.transitionMs,edgeActivationWidthPx:s??r.edgeActivationWidthPx,dragActivationDeltaPx:m??r.dragActivationDeltaPx,showOverlay:c??r.showOverlay,closeSidebarOnOverlayClick:R??r.closeSidebarOnOverlayClick,isAbsolute:O??r.isAbsolute,overlayBackgroundColor:h??r.overlayBackgroundColor,toggleIconColor:g??r.toggleIconColor,toggleIconSizePx:C??r.toggleIconSizePx,toggleIconEdgeDistancePx:I??r.toggleIconEdgeDistancePx,showToggle:A??r.showToggle,mediaQueryWidth:L??r.mediaQueryWidth}),[i,l,s,m,c,R,O,h,g,C,I,A,r,L]);return f.useEffect(()=>{e==="left"?o(P):a(P)},[e,P,o,a]),P};function q({isCollapsed:e,setCollapsed:n,closeSidebarOnClick:r=!0,transitionMs:o,overlayBackgroundColor:a}){return p.jsx("div",{style:{transitionDuration:`${o}ms`,...je,...e?{}:Ne,...a?{backgroundColor:a}:{}},onMouseDown:i=>{r&&(i.stopPropagation(),n())}})}function he({size:e,color:n}){const r=f.useRef(null);return f.useEffect(()=>{const o=()=>{r.current&&(r.current.style.opacity="1")},a=()=>{r.current&&(r.current.style.opacity="0.5")};r.current&&(r.current.addEventListener("mouseenter",o),r.current.addEventListener("mouseleave",a))},[]),p.jsx("div",{style:{...Ye},children:p.jsxs("svg",{ref:r,"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:e,children:[p.jsx("g",{strokeWidth:"0"}),p.jsx("g",{strokeLinecap:"round",strokeLinejoin:"round",children:p.jsx("g",{children:p.jsx("path",{clipRule:"evenodd",d:"m9.46967 5.46967c.29289-.29289.76773-.29289 1.06063 0l2.6286 2.62858c.5748.57477 1.0384 1.03835 1.3831 1.44443.355.41812.6278.82432.7818 1.29852.2447.7531.2447 1.5645 0 2.3176-.154.4742-.4268.8804-.7818 1.2985-.3447.4061-.8083.8697-1.3831 1.4444l-2.6286 2.6286c-.2929.2929-.76774.2929-1.06063 0s-.29289-.7677 0-1.0606l2.60593-2.6059c.6027-.6028 1.0225-1.0234 1.3229-1.3773.2947-.3471.4302-.5804.4987-.7912.1469-.4519.1469-.9387 0-1.3906-.0685-.2108-.204-.4441-.4987-.7912-.3004-.3539-.7202-.77451-1.3229-1.37728l-2.60593-2.60589c-.29289-.29289-.29289-.76777 0-1.06066z",fill:n,fillRule:"evenodd"})})})]})})}function ve({options:e,showToggle:n=!0,ToggleComponent:r}){const{openSidebar:o,leftToggleRef:a,isLeftOpen:i,closeSidebar:l}=k();return n?p.jsx("div",{ref:a,style:{...ue,transition:`transform ${e.transitionMs}ms ease, opacity ${e.transitionMs}ms ease`,left:0},children:(!i||i&&!e.showOverlay||i&&!e.closeSidebarOnOverlayClick)&&p.jsx("button",{type:"button",onClick:()=>i?l("left"):o("left"),style:{marginLeft:`${e.toggleIconEdgeDistancePx}px`,...i?{transform:"rotate(180deg)"}:{}},children:r??p.jsx(he,{size:e.toggleIconSizePx,color:e.toggleIconColor})})}):null}function F(e=se){const n=`(max-width: ${e}px)`,r=()=>typeof window>"u"||typeof window.matchMedia>"u"?!1:window.matchMedia(n).matches,[o,a]=f.useState(r);return f.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia>"u")return;const i=window.matchMedia(n),l=()=>a(i.matches);return l(),i.addEventListener("change",l),()=>i.removeEventListener("change",l)},[n]),o}const pe=({refs:e,callbacks:n,currentX:r,preventDefault:o,lockPane:a,options:i})=>{if(!e.draggingRef.current)return;const l=r-e.draggingRef.current.startX;if(!e.draggingRef.current.isActivated&&Math.abs(l)>=i.dragActivationDeltaPx&&(e.draggingRef.current.isActivated=!0,a()),!e.draggingRef.current.isActivated)return;e.prevXRef.current=e.currentXRef.current,e.currentXRef.current=r;const s=n.getIsOpen();let m=!1;if((s||e.draggingRef.current.startX<=i.edgeActivationWidthPx)&&(m=!0),!m){e.draggingRef.current=null,n.dragSidebar(null);return}o();const c=i.sidebarWidthPx;if(s){const R=Math.min(0,Math.max(-c,l+i.dragActivationDeltaPx));n.dragSidebar(R)}else if(e.draggingRef.current.startX<=i.edgeActivationWidthPx){const R=Math.min(0,Math.max(-c,-c+l-i.dragActivationDeltaPx));n.dragSidebar(R)}},me=({refs:e,callbacks:n,options:r})=>{if(!e.draggingRef.current)return;if(!e.draggingRef.current.isActivated){e.draggingRef.current=null,e.currentXRef.current=null,e.prevXRef.current=null;return}const o=e.currentXRef.current??e.draggingRef.current.startX,a=e.prevXRef.current??e.draggingRef.current.startX,i=e.draggingRef.current.startX,l=n.getIsOpen();e.draggingRef.current=null,e.currentXRef.current=null,e.prevXRef.current=null;const s=o>=a,m=o<a,c=i<=r.edgeActivationWidthPx;l?(m?n.closeSidebar():n.openSidebar(),n.dragSidebar(null)):c&&s?(n.openSidebar(),n.dragSidebar(null)):(n.closeSidebar(),n.dragSidebar(null))};function Ue(e){const n=F(e.mediaQueryWidth),{lockedSidebar:r,setLockedSidebar:o,isLeftOpen:a,openSidebar:i,closeSidebar:l,dragSidebar:s,leftSidebarRef:m}=k(),c=f.useRef(null),R=f.useRef(null),O=f.useRef(null);f.useEffect(()=>{if(!n||r==="right")return;const h={getIsOpen:()=>a,openSidebar:()=>i("left"),closeSidebar:()=>l("left"),dragSidebar:u=>s("left",u)},g={draggingRef:c,currentXRef:R,prevXRef:O},C=()=>o("left"),I=()=>o(null);function A(u){if(r==="right"||V(u.target)||u.changedTouches.length===0)return;const v=u.changedTouches[0];(h.getIsOpen()||v.clientX<=e.edgeActivationWidthPx)&&z({refs:g,clientX:v.clientX,clientY:v.clientY,touchId:v.identifier,isMouse:!1})}function L(u){if(r==="right"||!c.current||c.current.isMouse)return;const v=c.current.activeTouchId,y=de(u.changedTouches,v);y&&pe({refs:g,callbacks:h,currentX:y.clientX,preventDefault:()=>u.preventDefault(),lockPane:C,options:e})}function P(u){if(r==="right"||!c.current||c.current.isMouse)return;const v=c.current.activeTouchId;fe(u.changedTouches,v)&&me({refs:g,callbacks:h,options:e})}function M(){r!=="right"&&(!c.current||c.current.isMouse||le({refs:g,dragSidebar:h.dragSidebar,onDeactivate:I}))}function x(u){r!=="right"&&(V(u.target)||u.button===0&&(h.getIsOpen()||u.clientX<=e.edgeActivationWidthPx)&&z({refs:g,clientX:u.clientX,clientY:u.clientY,touchId:null,isMouse:!0}))}function X(u){r!=="right"&&(!c.current||!c.current.isMouse||pe({refs:g,callbacks:h,currentX:u.clientX,preventDefault:()=>u.preventDefault(),lockPane:C,options:e}))}function T(){r!=="right"&&(!c.current||!c.current.isMouse||me({refs:g,callbacks:h,options:e}))}return window.addEventListener("touchstart",A,{passive:!0}),window.addEventListener("touchmove",L,{passive:!1}),window.addEventListener("touchend",P,{passive:!0}),window.addEventListener("touchcancel",M,{passive:!0}),window.addEventListener("mousedown",x,{passive:!0}),window.addEventListener("mousemove",X,{passive:!1}),window.addEventListener("mouseup",T,{passive:!0}),()=>{window.removeEventListener("touchstart",A),window.removeEventListener("touchmove",L),window.removeEventListener("touchend",P),window.removeEventListener("touchcancel",M),window.removeEventListener("mousedown",x),window.removeEventListener("mousemove",X),window.removeEventListener("mouseup",T)}},[n,a,i,l,s,r,o,m,e])}function ze({className:e,children:n,ToggleComponent:r,...o}){const{isLeftOpen:a,closeSidebar:i,leftSidebarRef:l}=k(),s=ge("left",o),m=F(s.mediaQueryWidth);return Ue(s),p.jsxs(p.Fragment,{children:[s.showOverlay&&p.jsx(q,{isCollapsed:!a,setCollapsed:()=>i("left"),closeSidebarOnClick:s.closeSidebarOnOverlayClick,transitionMs:s.transitionMs,overlayBackgroundColor:s.overlayBackgroundColor}),p.jsx(ve,{options:s,showToggle:s.showToggle,ToggleComponent:r}),p.jsx("div",{ref:l,style:{...ce,...s.isAbsolute||m?De:{},...e?{}:{backgroundColor:ae}},className:e,children:n})]})}function we({options:e,showToggle:n=!0,ToggleComponent:r}){const{openSidebar:o,rightToggleRef:a,isRightOpen:i,closeSidebar:l}=k();return n?p.jsx("div",{ref:a,style:{...ue,transition:`transform ${e.transitionMs}ms ease, opacity ${e.transitionMs}ms ease`,right:0},children:(!i||i&&!e.showOverlay||i&&!e.closeSidebarOnOverlayClick)&&p.jsx("button",{type:"button",onClick:()=>i?l("right"):o("right"),style:{marginRight:`${e.toggleIconEdgeDistancePx}px`,...i?{}:{transform:"rotate(180deg)"}},children:r??p.jsx(he,{size:e.toggleIconSizePx,color:e.toggleIconColor})})}):null}const Se=({refs:e,callbacks:n,currentX:r,preventDefault:o,lockPane:a,options:i})=>{if(!e.draggingRef.current)return;const l=window.innerWidth,s=r-e.draggingRef.current.startX,m=e.draggingRef.current.startX>=l-i.edgeActivationWidthPx,c=e.draggingRef.current.isActivated;if(!c&&Math.abs(s)>=i.dragActivationDeltaPx&&(e.draggingRef.current.isActivated=!0,a()),!c)return;e.prevXRef.current=e.currentXRef.current,e.currentXRef.current=r;const R=n.getIsOpen();let O=!1;if((R||m)&&(O=!0),!O){e.draggingRef.current=null,n.dragSidebar(null);return}o();const h=i.sidebarWidthPx;if(R){const g=Math.max(0,Math.min(h,s-i.dragActivationDeltaPx));n.dragSidebar(g)}else{const g=Math.max(0,Math.min(h,h+s+i.dragActivationDeltaPx));n.dragSidebar(g)}},Re=({refs:e,callbacks:n,options:r})=>{if(!e.draggingRef.current)return;if(!e.draggingRef.current.isActivated){e.draggingRef.current=null,e.currentXRef.current=null,e.prevXRef.current=null;return}const o=e.currentXRef.current??e.draggingRef.current.startX,a=e.prevXRef.current??e.draggingRef.current.startX,i=e.draggingRef.current.startX,l=n.getIsOpen(),s=window.innerWidth;e.draggingRef.current=null,e.currentXRef.current=null,e.prevXRef.current=null;const m=o>a,c=o<a,R=i>=s-r.edgeActivationWidthPx;l?(m?n.closeSidebar():n.openSidebar(),n.dragSidebar(null)):R&&c?(n.openSidebar(),n.dragSidebar(null)):(n.closeSidebar(),n.dragSidebar(null))};function Ve(e){const n=F(e.mediaQueryWidth),{lockedSidebar:r,setLockedSidebar:o,isRightOpen:a,openSidebar:i,closeSidebar:l,dragSidebar:s,rightSidebarRef:m}=k(),c=f.useRef(null),R=f.useRef(null),O=f.useRef(null);f.useEffect(()=>{if(!n||r==="left")return;const h={getIsOpen:()=>a,openSidebar:()=>i("right"),closeSidebar:()=>l("right"),dragSidebar:u=>s("right",u)},g={draggingRef:c,currentXRef:R,prevXRef:O},C=()=>o("right"),I=()=>o(null);function A(u){if(r==="left"||V(u.target)||u.changedTouches.length===0)return;const v=u.changedTouches[0],y=window.innerWidth;(h.getIsOpen()||v.clientX>=y-e.edgeActivationWidthPx)&&z({refs:g,clientX:v.clientX,clientY:v.clientY,touchId:v.identifier,isMouse:!1})}function L(u){if(r==="left"||!c.current||c.current.isMouse)return;const v=c.current.activeTouchId,y=de(u.changedTouches,v);y&&Se({refs:g,callbacks:h,currentX:y.clientX,preventDefault:()=>u.preventDefault(),lockPane:C,options:e})}function P(u){if(r==="left"||!c.current||c.current.isMouse)return;const v=c.current.activeTouchId;fe(u.changedTouches,v)&&Re({refs:g,callbacks:h,options:e})}function M(){r!=="left"&&(!c.current||c.current.isMouse||le({refs:g,dragSidebar:h.dragSidebar,onDeactivate:I}))}function x(u){if(r==="left"||V(u.target)||u.button!==0)return;const v=window.innerWidth;(h.getIsOpen()||u.clientX>=v-e.edgeActivationWidthPx)&&z({refs:g,clientX:u.clientX,clientY:u.clientY,touchId:null,isMouse:!0})}function X(u){r!=="left"&&(!c.current||!c.current.isMouse||Se({refs:g,callbacks:h,currentX:u.clientX,preventDefault:()=>u.preventDefault(),lockPane:C,options:e}))}function T(){r!=="left"&&(!c.current||!c.current.isMouse||Re({refs:g,callbacks:h,options:e}))}return window.addEventListener("touchstart",A,{passive:!0}),window.addEventListener("touchmove",L,{passive:!1}),window.addEventListener("touchend",P,{passive:!0}),window.addEventListener("touchcancel",M,{passive:!0}),window.addEventListener("mousedown",x,{passive:!0}),window.addEventListener("mousemove",X,{passive:!1}),window.addEventListener("mouseup",T,{passive:!0}),()=>{window.removeEventListener("touchstart",A),window.removeEventListener("touchmove",L),window.removeEventListener("touchend",P),window.removeEventListener("touchcancel",M),window.removeEventListener("mousedown",x),window.removeEventListener("mousemove",X),window.removeEventListener("mouseup",T)}},[n,a,i,l,s,r,o,m,e])}function Qe({className:e,children:n,ToggleComponent:r,...o}){const{isRightOpen:a,closeSidebar:i,rightSidebarRef:l}=k(),s=ge("right",o),m=F(s.mediaQueryWidth);return Ve(s),p.jsxs(p.Fragment,{children:[s.showOverlay&&p.jsx(q,{isCollapsed:!a,setCollapsed:()=>i("right"),closeSidebarOnClick:s.closeSidebarOnOverlayClick,transitionMs:s.transitionMs,overlayBackgroundColor:s.overlayBackgroundColor}),p.jsx(we,{options:s,showToggle:s.showToggle,ToggleComponent:r}),p.jsx("div",{ref:l,style:{...ce,...s.isAbsolute||m?We:{},...e?{}:{backgroundColor:ae}},className:e,children:n})]})}_.Overlay=q,_.SwipeBarLeft=ze,_.SwipeBarProvider=Oe,_.SwipeBarRight=Qe,_.ToggleLeft=ve,_.ToggleRight=we,_.useMediaQuery=F,_.useSwipeBarContext=k,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
export type TSidebarCallbacks = {
|
|
4
|
+
getIsOpen: () => boolean;
|
|
5
|
+
openSidebar: () => void;
|
|
6
|
+
closeSidebar: () => void;
|
|
7
|
+
dragSidebar: (translateX: number | null) => void;
|
|
8
|
+
};
|
|
9
|
+
export type TDragState = {
|
|
10
|
+
startX: number;
|
|
11
|
+
startY: number;
|
|
12
|
+
activeTouchId: number | null;
|
|
13
|
+
isMouse: boolean;
|
|
14
|
+
isActivated: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type TDragRefs = {
|
|
17
|
+
draggingRef: RefObject<TDragState | null>;
|
|
18
|
+
currentXRef: RefObject<number | null>;
|
|
19
|
+
prevXRef: RefObject<number | null>;
|
|
20
|
+
};
|
|
21
|
+
export type TSwipeBarOptions = {
|
|
22
|
+
transitionMs?: number;
|
|
23
|
+
sidebarWidthPx?: number;
|
|
24
|
+
isAbsolute?: boolean;
|
|
25
|
+
edgeActivationWidthPx?: number;
|
|
26
|
+
dragActivationDeltaPx?: number;
|
|
27
|
+
showOverlay?: boolean;
|
|
28
|
+
closeSidebarOnOverlayClick?: boolean;
|
|
29
|
+
overlayBackgroundColor?: string;
|
|
30
|
+
toggleIconSizePx?: number;
|
|
31
|
+
toggleIconColor?: string;
|
|
32
|
+
toggleIconEdgeDistancePx?: number;
|
|
33
|
+
showToggle?: boolean;
|
|
34
|
+
mediaQueryWidth?: number;
|
|
35
|
+
};
|
|
36
|
+
export type TSwipeSidebar = TSwipeBarOptions & {
|
|
37
|
+
className?: string;
|
|
38
|
+
ToggleComponent?: ReactNode;
|
|
39
|
+
children?: ReactNode;
|
|
40
|
+
};
|
|
41
|
+
export type TToggle = {
|
|
42
|
+
side: TSidebarSide;
|
|
43
|
+
className?: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const TRANSITION_MS = 200;
|
|
46
|
+
export declare const EDGE_ACTIVATION_REGION_PX = 40;
|
|
47
|
+
export declare const DRAG_ACTIVATION_DELTA_PX = 20;
|
|
48
|
+
export declare const PANE_WIDTH_PX = 320;
|
|
49
|
+
export declare const SHOW_OVERLAY = true;
|
|
50
|
+
export declare const CLOSE_SIDEBAR_ON_OVERLAY_CLICK = true;
|
|
51
|
+
export declare const IS_ABSOLUTE = false;
|
|
52
|
+
export declare const DEFAULT_OVERLAY_BACKGROUND_COLOR = "rgba(0, 0, 0, 0.5)";
|
|
53
|
+
export declare const DEFAULT_SIDEBAR_BACKGROUND_COLOR = "rgb(36,36,36)";
|
|
54
|
+
export declare const DEFAULT_TOGGLE_ICON_COLOR = "white";
|
|
55
|
+
export declare const DEFAULT_TOGGLE_ICON_SIZE_PX = 40;
|
|
56
|
+
export declare const DEFAULT_TOGGLE_ICON_EDGE_DISTANCE_PX = 40;
|
|
57
|
+
export declare const SHOW_TOGGLE = true;
|
|
58
|
+
export declare const MEDIA_QUERY_WIDTH = 640;
|
|
59
|
+
export declare const swipeBarStyle: {
|
|
60
|
+
zIndex: number;
|
|
61
|
+
width: number;
|
|
62
|
+
top: number;
|
|
63
|
+
bottom: number;
|
|
64
|
+
flexShrink: number;
|
|
65
|
+
overflowX: "hidden";
|
|
66
|
+
willChange: "transform";
|
|
67
|
+
};
|
|
68
|
+
export declare const leftSwipeBarAbsoluteStyle: {
|
|
69
|
+
position: "fixed";
|
|
70
|
+
left: number;
|
|
71
|
+
top: number;
|
|
72
|
+
bottom: number;
|
|
73
|
+
};
|
|
74
|
+
export declare const rightSwipeBarAbsoluteStyle: {
|
|
75
|
+
position: "fixed";
|
|
76
|
+
right: number;
|
|
77
|
+
top: number;
|
|
78
|
+
bottom: number;
|
|
79
|
+
};
|
|
80
|
+
export declare const overlayStyle: {
|
|
81
|
+
position: "fixed";
|
|
82
|
+
zIndex: number;
|
|
83
|
+
top: number;
|
|
84
|
+
left: number;
|
|
85
|
+
width: string;
|
|
86
|
+
height: string;
|
|
87
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)";
|
|
88
|
+
transitionProperty: "opacity";
|
|
89
|
+
pointerEvents: "none";
|
|
90
|
+
opacity: number;
|
|
91
|
+
};
|
|
92
|
+
export declare const overlayIsOpenStyle: {
|
|
93
|
+
opacity: number;
|
|
94
|
+
pointerEvents: "auto";
|
|
95
|
+
};
|
|
96
|
+
export declare const toggleWrapperStyle: {
|
|
97
|
+
position: "fixed";
|
|
98
|
+
zIndex: number;
|
|
99
|
+
top: string;
|
|
100
|
+
transform: "translateY(-50%)";
|
|
101
|
+
width: string;
|
|
102
|
+
display: "flex";
|
|
103
|
+
justifyContent: "center";
|
|
104
|
+
};
|
|
105
|
+
export declare const toggleIconWrapperStyle: {
|
|
106
|
+
position: "relative";
|
|
107
|
+
cursor: "pointer";
|
|
108
|
+
display: "flex";
|
|
109
|
+
height: string;
|
|
110
|
+
alignItems: "center";
|
|
111
|
+
justifyContent: "center";
|
|
112
|
+
};
|
|
113
|
+
export type TSidebarSide = "left" | "right";
|
|
114
|
+
type TApplyOpenPaneStyles = {
|
|
115
|
+
ref: RefObject<HTMLDivElement | null>;
|
|
116
|
+
side: TSidebarSide;
|
|
117
|
+
options: TSwipeBarOptions;
|
|
118
|
+
toggleRef: RefObject<HTMLDivElement | null>;
|
|
119
|
+
afterApply: () => void;
|
|
120
|
+
};
|
|
121
|
+
export declare const applyOpenPaneStyles: ({ ref, side, options, toggleRef, afterApply, }: TApplyOpenPaneStyles) => void;
|
|
122
|
+
type TApplyClosePaneStyles = {
|
|
123
|
+
ref: RefObject<HTMLDivElement | null>;
|
|
124
|
+
side: TSidebarSide;
|
|
125
|
+
options: TSwipeBarOptions;
|
|
126
|
+
toggleRef: RefObject<HTMLDivElement | null>;
|
|
127
|
+
afterApply: () => void;
|
|
128
|
+
};
|
|
129
|
+
export declare const applyClosePaneStyles: ({ ref, options, side, toggleRef, afterApply, }: TApplyClosePaneStyles) => void;
|
|
130
|
+
type TApplyDragPaneStyles = {
|
|
131
|
+
ref: RefObject<HTMLDivElement | null>;
|
|
132
|
+
toggleRef: RefObject<HTMLDivElement | null>;
|
|
133
|
+
options: TSwipeBarOptions;
|
|
134
|
+
translateX: number | null;
|
|
135
|
+
};
|
|
136
|
+
export declare const applyDragPaneStyles: ({ ref, toggleRef, options, translateX, }: TApplyDragPaneStyles) => void;
|
|
137
|
+
type THandleDragStart = {
|
|
138
|
+
refs: TDragRefs;
|
|
139
|
+
clientX: number;
|
|
140
|
+
clientY: number;
|
|
141
|
+
touchId: number | null;
|
|
142
|
+
isMouse: boolean;
|
|
143
|
+
};
|
|
144
|
+
export declare const handleDragStart: ({ refs, clientX, clientY, touchId, isMouse, }: THandleDragStart) => void;
|
|
145
|
+
type THandleDragCancel = {
|
|
146
|
+
refs: TDragRefs;
|
|
147
|
+
dragSidebar: (translateX: number | null) => void;
|
|
148
|
+
onDeactivate: () => void;
|
|
149
|
+
};
|
|
150
|
+
export declare const handleDragCancel: ({ refs, dragSidebar, onDeactivate, }: THandleDragCancel) => void;
|
|
151
|
+
export declare const isEditableTarget: (el: EventTarget | null) => boolean;
|
|
152
|
+
export declare const findChangedTouch: (changedTouches: TouchList, trackedId: number | null) => Touch | null;
|
|
153
|
+
export declare const hasTrackedTouchEnded: (changedTouches: TouchList, trackedId: number | null) => boolean;
|
|
154
|
+
export declare const useSetMergedOptions: (side: TSidebarSide, options: TSwipeBarOptions) => {
|
|
155
|
+
sidebarWidthPx: number;
|
|
156
|
+
transitionMs: number;
|
|
157
|
+
edgeActivationWidthPx: number;
|
|
158
|
+
dragActivationDeltaPx: number;
|
|
159
|
+
showOverlay: boolean;
|
|
160
|
+
closeSidebarOnOverlayClick: boolean;
|
|
161
|
+
isAbsolute: boolean;
|
|
162
|
+
overlayBackgroundColor: string;
|
|
163
|
+
toggleIconColor: string;
|
|
164
|
+
toggleIconSizePx: number;
|
|
165
|
+
toggleIconEdgeDistancePx: number;
|
|
166
|
+
showToggle: boolean;
|
|
167
|
+
mediaQueryWidth: number;
|
|
168
|
+
};
|
|
169
|
+
export {};
|
|
170
|
+
//# sourceMappingURL=swipeSidebarShared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipeSidebarShared.d.ts","sourceRoot":"","sources":["../src/swipeSidebarShared.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAGf,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;IAC1C,WAAW,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACtC,QAAQ,EAAE,SAAS,CAAC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],"names":[],"mappings":"AAGA,wBAAgB,aAAa,CAAC,KAAK,SAAoB,GAAG,OAAO,CA8BhE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const useSwipeBarContext: () => {
|
|
2
|
+
lockedSidebar: import('./swipeSidebarShared').TSidebarSide | null;
|
|
3
|
+
setLockedSidebar: (side: import('./swipeSidebarShared').TSidebarSide | null) => void;
|
|
4
|
+
leftSidebarRef: React.RefObject<HTMLDivElement | null>;
|
|
5
|
+
rightSidebarRef: React.RefObject<HTMLDivElement | null>;
|
|
6
|
+
isLeftOpen: boolean;
|
|
7
|
+
isRightOpen: boolean;
|
|
8
|
+
openSidebar: (side: import('./swipeSidebarShared').TSidebarSide) => void;
|
|
9
|
+
closeSidebar: (side: import('./swipeSidebarShared').TSidebarSide) => void;
|
|
10
|
+
dragSidebar: (side: import('./swipeSidebarShared').TSidebarSide, translateX: number | null) => void;
|
|
11
|
+
globalOptions: Required<import('./swipeSidebarShared').TSwipeBarOptions>;
|
|
12
|
+
setGlobalOptions: (options: Partial<Required<import('./swipeSidebarShared').TSwipeBarOptions>>) => void;
|
|
13
|
+
leftSidebarOptions: import('./swipeSidebarShared').TSwipeBarOptions;
|
|
14
|
+
rightSidebarOptions: import('./swipeSidebarShared').TSwipeBarOptions;
|
|
15
|
+
setLeftSidebarOptions: (options: import('./swipeSidebarShared').TSwipeBarOptions) => void;
|
|
16
|
+
setRightSidebarOptions: (options: import('./swipeSidebarShared').TSwipeBarOptions) => void;
|
|
17
|
+
leftToggleRef: React.RefObject<HTMLDivElement | null>;
|
|
18
|
+
rightToggleRef: React.RefObject<HTMLDivElement | null>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useSwipeBarContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwipeBarContext.d.ts","sourceRoot":"","sources":["../src/useSwipeBarContext.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;CAM9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwipeLeftSidebar.d.ts","sourceRoot":"","sources":["../src/useSwipeLeftSidebar.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,gBAAgB,EAMtB,MAAM,sBAAsB,CAAC;AAuI9B,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,QA6KtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSwipeRightSidebar.d.ts","sourceRoot":"","sources":["../src/useSwipeRightSidebar.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,gBAAgB,EAMtB,MAAM,sBAAsB,CAAC;AAkK9B,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,gBAAgB,CAAC,QAkLvE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luciodale/swipe-bar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "Lucio D'Alessandro",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/luciodale/swipe-bar"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/swipe-bar.umd.js",
|
|
10
|
+
"module": "dist/swipe-bar.es.js",
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"react": ">=16 || >=17 || >= 18 || >= 19",
|
|
13
|
+
"react-dom": ">=16 || >=17 || >= 18 || >=19"
|
|
14
|
+
},
|
|
15
|
+
"description": "Sliding barls like in a native app, built with React.",
|
|
16
|
+
"files": ["dist", "README.md"],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"react",
|
|
19
|
+
"sliding",
|
|
20
|
+
"swipe sidebar",
|
|
21
|
+
"swipe bar",
|
|
22
|
+
"sliding bar",
|
|
23
|
+
"swipe",
|
|
24
|
+
"menu",
|
|
25
|
+
"sliding menu",
|
|
26
|
+
"swiping menu",
|
|
27
|
+
"native swiping"
|
|
28
|
+
],
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"types": "dist/index.d.ts"
|
|
31
|
+
}
|