@mobilestock-native/drawer 0.1.0 → 0.2.1

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.
Files changed (3) hide show
  1. package/index.d.ts +22 -3
  2. package/index.js +8 -7
  3. package/package.json +5 -5
package/index.d.ts CHANGED
@@ -69,6 +69,7 @@ interface DrawerCompactItemProps extends Omit<ClickableProps, 'children' | 'acce
69
69
  */
70
70
  declare function CompactItem({ icon, accessibilityLabel, label, active, color, badge, size, onHoverIn, onHoverOut, onFocus, onBlur, onPressIn, onLongPress, ...props }: DrawerCompactItemProps): react_jsx_runtime.JSX.Element;
71
71
 
72
+ type DrawerFooterSize = 'MD' | 'SM';
72
73
  interface DrawerFooterProps {
73
74
  children: ReactNode;
74
75
  /**
@@ -77,12 +78,19 @@ interface DrawerFooterProps {
77
78
  * @example compact
78
79
  */
79
80
  compact?: boolean;
81
+ /**
82
+ * @description Vertical padding for the size of the items inside: `MD` for the 48px compact item or the 44px row,
83
+ * `SM` for the 40px compact item or the 36px row, which lines the footer up with a 49px bottom tab bar.
84
+ * Default: 'MD'
85
+ * @example size="SM"
86
+ */
87
+ size?: DrawerFooterSize;
80
88
  }
81
89
  /**
82
90
  * @description Bottom area of the side menu, under the scrolling entries: a hairline on top, in the divider color of
83
91
  * the drawer, and the padding of the menu. Holds the logout (and the login of a visitor).
84
92
  */
85
- declare function Footer({ children, compact }: DrawerFooterProps): react_jsx_runtime.JSX.Element;
93
+ declare function Footer({ children, compact, size }: DrawerFooterProps): react_jsx_runtime.JSX.Element;
86
94
 
87
95
  /**
88
96
  * @description Color of the icon and the label of an item: `DEFAULT` is the text color, `SELECTED` is the active
@@ -90,6 +98,10 @@ declare function Footer({ children, compact }: DrawerFooterProps): react_jsx_run
90
98
  */
91
99
  type DrawerItemColor = 'DEFAULT' | 'SELECTED' | 'DANGER';
92
100
 
101
+ /**
102
+ * @description Size of the item: `MD` the 44px row, `SM` the 36px row with a smaller label.
103
+ */
104
+ type DrawerItemSize = 'MD' | 'SM';
93
105
  interface DrawerItemProps extends Omit<ClickableProps, 'children'> {
94
106
  /**
95
107
  * @description Text of the item. It is also the accessibility label, unless `accessibilityLabel` is given.
@@ -130,12 +142,19 @@ interface DrawerItemProps extends Omit<ClickableProps, 'children'> {
130
142
  * @example href="https://necso.com.br/conta"
131
143
  */
132
144
  href?: string;
145
+ /**
146
+ * @description `MD` is the 44px row with the small label; `SM` the 36px row with the extra-small label, for a
147
+ * denser menu (a phone).
148
+ * Default: 'MD'
149
+ * @example size="SM"
150
+ */
151
+ size?: DrawerItemSize;
133
152
  }
134
153
  /**
135
154
  * @description One row of the expanded side menu: icon, label and an optional trailing element, with a touch height
136
155
  * of at least 44px and the radius of the theme. `active` tints the row with the active colors of the drawer.
137
156
  */
138
- declare function Item({ label, icon, color, active, trailing, href, accessibilityLabel, ...props }: DrawerItemProps): react_jsx_runtime.JSX.Element;
157
+ declare function Item({ label, icon, color, active, trailing, href, accessibilityLabel, size, ...props }: DrawerItemProps): react_jsx_runtime.JSX.Element;
139
158
 
140
159
  /**
141
160
  * @description Box of the item (or divider) a floating label names, in window coordinates.
@@ -244,4 +263,4 @@ declare const Drawer: {
244
263
  Footer: typeof Footer;
245
264
  };
246
265
 
247
- export { Drawer, type DrawerCompactItemColor, type DrawerCompactItemProps, type DrawerCompactItemSize, type DrawerFooterProps, type DrawerItemColor, type DrawerItemProps, type DrawerRootProps, type DrawerSectionTitleProps, type DrawerSide, type FloatingLabelRequest, HOVER_EXPAND_DELAY_IN_MILLISECONDS };
266
+ export { Drawer, type DrawerCompactItemColor, type DrawerCompactItemProps, type DrawerCompactItemSize, type DrawerFooterProps, type DrawerFooterSize, type DrawerItemColor, type DrawerItemProps, type DrawerItemSize, type DrawerRootProps, type DrawerSectionTitleProps, type DrawerSide, type FloatingLabelRequest, HOVER_EXPAND_DELAY_IN_MILLISECONDS };
package/index.js CHANGED
@@ -1,20 +1,21 @@
1
- "use strict";var Ye=Object.create;var _=Object.defineProperty,qe=Object.defineProperties,Ze=Object.getOwnPropertyDescriptor,Je=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertyNames,V=Object.getOwnPropertySymbols,je=Object.getPrototypeOf,Q=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var le=(e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,N=(e,t)=>{for(var r in t||(t={}))Q.call(t,r)&&le(e,r,t[r]);if(V)for(var r of V(t))ce.call(t,r)&&le(e,r,t[r]);return e},X=(e,t)=>qe(e,Je(t));var H=(e,t)=>{var r={};for(var o in e)Q.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&V)for(var o of V(e))t.indexOf(o)<0&&ce.call(e,o)&&(r[o]=e[o]);return r};var et=(e,t)=>{for(var r in t)_(e,r,{get:t[r],enumerable:!0})},se=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qe(t))!Q.call(e,n)&&n!==r&&_(e,n,{get:()=>t[n],enumerable:!(o=Ze(t,n))||o.enumerable});return e};var $=(e,t,r)=>(r=e!=null?Ye(je(e)):{},se(t||!e||!e.__esModule?_(r,"default",{value:e,enumerable:!0}):r,e)),tt=e=>se(_({},"__esModule",{value:!0}),e);var gt={};et(gt,{Drawer:()=>wt,HOVER_EXPAND_DELAY_IN_MILLISECONDS:()=>te});module.exports=tt(gt);var L=require("react"),y=require("react-native"),Ee=require("styled-components/native"),Le=require("@mobilestock-native/badge"),De=require("@mobilestock-native/clickable"),Se=require("@mobilestock-native/icons");function U(e,t,r){return r||t==="SELECTED"?e.colors.drawer.activeForeground:t==="DANGER"?e.colors.text.danger:e.colors.text.default}function z(e){var t;return(t=e.colors.listItem)==null?void 0:t.hover}var de=require("react-native");function C(e,t){if(!e)return;let r=e;if(de.Platform.OS==="web"&&typeof r.getBoundingClientRect=="function"){let o=r.getBoundingClientRect();t(o.left,o.top,o.width,o.height);return}e.measureInWindow(t)}var ue=require("react-native"),ee=$(require("styled-components/native")),me=require("@mobilestock-native/typography"),j=require("react/jsx-runtime"),P=28,A=12;function W({text:e,visible:t,top:r,left:o,right:n}){if(!t)return null;let l={position:ue.Platform.OS==="web"?"fixed":"absolute",top:r,left:o,right:n};return(0,j.jsx)(rt,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:l,testID:"drawer-floating-label",children:(0,j.jsx)(ot,{size:"XS",weight:"MEDIUM",withEllipsis:!0,children:e})})}var rt=ee.default.View`
1
+ "use strict";var Ye=Object.create;var N=Object.defineProperty,Ze=Object.defineProperties,qe=Object.getOwnPropertyDescriptor,Je=Object.getOwnPropertyDescriptors,Qe=Object.getOwnPropertyNames,V=Object.getOwnPropertySymbols,je=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable;var le=(e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,F=(e,t)=>{for(var r in t||(t={}))j.call(t,r)&&le(e,r,t[r]);if(V)for(var r of V(t))ce.call(t,r)&&le(e,r,t[r]);return e},X=(e,t)=>Ze(e,Je(t));var z=(e,t)=>{var r={};for(var o in e)j.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&V)for(var o of V(e))t.indexOf(o)<0&&ce.call(e,o)&&(r[o]=e[o]);return r};var et=(e,t)=>{for(var r in t)N(e,r,{get:t[r],enumerable:!0})},se=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qe(t))!j.call(e,n)&&n!==r&&N(e,n,{get:()=>t[n],enumerable:!(o=qe(t,n))||o.enumerable});return e};var $=(e,t,r)=>(r=e!=null?Ye(je(e)):{},se(t||!e||!e.__esModule?N(r,"default",{value:e,enumerable:!0}):r,e)),tt=e=>se(N({},"__esModule",{value:!0}),e);var Dt={};et(Dt,{Drawer:()=>It,HOVER_EXPAND_DELAY_IN_MILLISECONDS:()=>re});module.exports=tt(Dt);var S=require("react"),x=require("react-native"),De=require("styled-components/native"),Se=require("@mobilestock-native/badge"),Ee=require("@mobilestock-native/clickable"),Le=require("@mobilestock-native/icons");function U(e,t,r){return r||t==="SELECTED"?e.colors.drawer.activeForeground:t==="DANGER"?e.colors.text.danger:e.colors.text.default}function W(e){var t;return(t=e.colors.listItem)==null?void 0:t.hover}var de=require("react-native");function T(e,t){if(!e)return;let r=e;if(de.Platform.OS==="web"&&typeof r.getBoundingClientRect=="function"){let o=r.getBoundingClientRect();t(o.left,o.top,o.width,o.height);return}e.measureInWindow(t)}var ue=require("react-native"),te=$(require("styled-components/native")),me=require("@mobilestock-native/typography"),ee=require("react/jsx-runtime"),A=28,P=12;function K({text:e,visible:t,top:r,left:o,right:n}){if(!t)return null;let c={position:ue.Platform.OS==="web"?"fixed":"absolute",top:r,left:o,right:n};return(0,ee.jsx)(rt,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",style:c,testID:"drawer-floating-label",children:(0,ee.jsx)(ot,{size:"XS",weight:"MEDIUM",withEllipsis:!0,children:e})})}var rt=te.default.View`
2
2
  z-index: 1000;
3
- height: ${P}px;
3
+ height: ${A}px;
4
4
  justify-content: center;
5
5
  padding: 0 ${({theme:e})=>e.spacing.xs};
6
6
  border-radius: ${({theme:e})=>e.borderRadius.default};
7
7
  background-color: ${({theme:e})=>e.colors.drawer.labelBackground};
8
- `,ot=(0,ee.default)(me.Typography)`
8
+ `,ot=(0,te.default)(me.Typography)`
9
9
  color: ${({theme:e})=>e.colors.drawer.labelText};
10
- `;var c=require("react"),E=require("react-native"),pe=require("styled-components/native");var F=require("react/jsx-runtime"),be=(0,c.createContext)(null);function K(){return(0,c.useContext)(be)}var te=400,nt='[data-testid="drawer-compact-item"], [data-testid="drawer-item"]';function it(e,t){var n;if(e.key==="Escape"){t.hideLabel(),(n=t.onEscape)==null||n.call(t);return}if(e.key!=="ArrowDown"&&e.key!=="ArrowUp"||t.activeIndex===-1||t.entries.length===0)return;e.preventDefault();let r=e.key==="ArrowDown"?1:-1,o=(t.activeIndex+r+t.entries.length)%t.entries.length;t.entries[o].focus()}function fe(e,t,r){let{anchor:o}=e,n=o.top+(o.height-P)/2-r.top;return t==="right"?{text:e.text,top:n,right:r.left+r.width-o.left+A}:{text:e.text,top:n,left:o.left+o.width+A-r.left}}function at(){var t;return(typeof document=="undefined"?0:(t=document.documentElement)==null?void 0:t.clientWidth)||E.Dimensions.get("window").width}function lt(e){return typeof(e==null?void 0:e.addEventListener)=="function"}function we({children:e,side:t="left",onEscape:r,onHoverIn:o,onHoverOut:n,hoverDelayInMilliseconds:l=te}){var v,w;let p=(0,pe.useTheme)(),b=(0,c.useRef)(null),s=(0,c.useRef)(null),d=(0,c.useRef)(!1),[i,u]=(0,c.useState)(null);(0,c.useEffect)(()=>m,[]);function m(){s.current&&(clearTimeout(s.current),s.current=null)}function R(){o&&(m(),s.current=setTimeout(()=>{s.current=null,d.current=!0,u(null),o()},l))}function re(){m(),d.current&&(d.current=!1,n==null||n())}let O={side:t,show(D){if(E.Platform.OS==="web"){u(fe(D,t,{left:0,top:0,width:at()}));return}C(b.current,(f,I,h)=>{u(fe(D,t,{left:f,top:I,width:h}))})},hide:()=>u(null)};return(0,c.useEffect)(()=>{let D=b.current,f=typeof document=="undefined"?void 0:document;if(E.Platform.OS!=="web"||!lt(D)||!f)return;let I=D,h=f;function g(){u(null)}function T(Z){let x=Array.from(I.querySelectorAll(nt));it(Z,{entries:x,activeIndex:x.indexOf(h.activeElement),hideLabel:g,onEscape:r})}return I.addEventListener("keydown",T),h.addEventListener("scroll",g,!0),()=>{I.removeEventListener("keydown",T),h.removeEventListener("scroll",g,!0)}},[r]),(0,F.jsx)(be.Provider,{value:O,children:(0,F.jsxs)(E.View,{ref:b,collapsable:!1,style:[ct.root,{backgroundColor:p.colors.drawer.background}],onPointerEnter:R,onPointerLeave:re,testID:"drawer-root",children:[e,(0,F.jsx)(W,{text:(v=i==null?void 0:i.text)!=null?v:"",visible:i!==null,top:(w=i==null?void 0:i.top)!=null?w:0,left:i==null?void 0:i.left,right:i==null?void 0:i.right})]})})}var ct=E.StyleSheet.create({root:{flex:1}});var S=require("react/jsx-runtime"),st=250,dt=1500,ge={MD:"3rem",SM:"2.5rem"},ut={MD:"MD",SM:"SM"};function ye(re){var O=re,{icon:e,accessibilityLabel:t,label:r=t,active:o=!1,color:n="DEFAULT",badge:l,size:p="MD",onHoverIn:b,onHoverOut:s,onFocus:d,onBlur:i,onPressIn:u,onLongPress:m}=O,R=H(O,["icon","accessibilityLabel","label","active","color","badge","size","onHoverIn","onHoverOut","onFocus","onBlur","onPressIn","onLongPress"]);var oe;let v=(0,Ee.useTheme)(),w=K(),D=(0,L.useRef)(null),f=(0,L.useRef)(null),I=(0,L.useRef)(!1),h=(0,L.useRef)(!1),[g,T]=(0,L.useState)(null),Z=U(v,n,o),x=z(v),Oe=v.colors.drawer.activeBackground,Ge=l?`${t}, ${l}`:t;(0,L.useEffect)(()=>()=>{k(),I.current&&(w==null||w.hide())},[]);function k(){f.current&&(clearTimeout(f.current),f.current=null)}function J(){C(D.current,(a,ne,ie,ae)=>{if(w){I.current=!0,w.show({text:r,anchor:{left:a,top:ne,width:ie,height:ae}});return}y.Platform.OS==="web"&&T({top:ne+(ae-P)/2,left:a+ie+A})})}function G(){if(k(),w){I.current=!1,w.hide();return}T(null)}function Ve(){k(),J(),f.current=setTimeout(()=>{f.current=null,G()},dt)}function Xe(a){k(),f.current=setTimeout(()=>{f.current=null,J()},a)}function He(a){Xe(st),b==null||b(a)}function $e(a){G(),s==null||s(a)}function Ue(a){h.current?h.current=!1:(k(),J()),d==null||d(a)}function ze(a){h.current=!1,G(),i==null||i(a)}function We(a){h.current=!0,G(),u==null||u(a)}function Ke(a){y.Platform.OS!=="web"&&w&&Ve(),m==null||m(a)}return(0,S.jsxs)(y.View,{ref:D,collapsable:!1,style:Ie.anchor,testID:"drawer-compact-item-anchor",children:[(0,S.jsx)(De.Clickable,X(N({accessibilityRole:"button",accessibilityLabel:Ge,accessibilityState:{selected:o},width:ge[p],height:ge[p],align:"CENTER_CENTER",borderRadius:"MEDIUM",backgroundColor:o?Oe:void 0,whenHovered:x?{backgroundColor:x}:void 0,whenPressed:x?{backgroundColor:x}:void 0,onHoverIn:He,onHoverOut:$e,onFocus:Ue,onBlur:ze,onPressIn:We,onLongPress:Ke},R),{testID:"drawer-compact-item",children:(0,S.jsx)(Se.Icon,{name:e,size:ut[p],color:Z})})),l&&(0,S.jsx)(y.View,{style:Ie.badge,pointerEvents:"none",testID:"drawer-compact-item-badge",children:(0,S.jsx)(Le.Badge,{text:l,type:"DANGER",size:"2XS",isRounded:!0})}),(0,S.jsx)(W,{text:r,visible:g!==null,top:(oe=g==null?void 0:g.top)!=null?oe:0,left:g==null?void 0:g.left})]})}var he=2,Ie=y.StyleSheet.create({anchor:{alignSelf:"center"},badge:{position:"absolute",top:he,right:he}});var xe=$(require("styled-components/native")),ve=require("@mobilestock-native/container"),Re=require("react/jsx-runtime");function Ce({children:e,compact:t=!1}){return(0,Re.jsx)(mt,{padding:t?"XS_NONE":"XS_SM",testID:"drawer-footer",children:e})}var mt=(0,xe.default)(ve.Container)`
10
+ `;var d=require("react"),D=require("react-native"),pe=require("styled-components/native");var M=require("react/jsx-runtime"),be=(0,d.createContext)(null);function Y(){return(0,d.useContext)(be)}var re=400,nt='[data-testid="drawer-compact-item"], [data-testid="drawer-item"]';function it(e,t){var n;if(e.key==="Escape"){t.hideLabel(),(n=t.onEscape)==null||n.call(t);return}if(e.key!=="ArrowDown"&&e.key!=="ArrowUp"||t.activeIndex===-1||t.entries.length===0)return;e.preventDefault();let r=e.key==="ArrowDown"?1:-1,o=(t.activeIndex+r+t.entries.length)%t.entries.length;t.entries[o].focus()}function fe(e,t,r){let{anchor:o}=e,n=o.top+(o.height-A)/2-r.top;return t==="right"?{text:e.text,top:n,right:r.left+r.width-o.left+P}:{text:e.text,top:n,left:o.left+o.width+P-r.left}}function at(){var t;return(typeof document=="undefined"?0:(t=document.documentElement)==null?void 0:t.clientWidth)||D.Dimensions.get("window").width}function lt(e){return typeof(e==null?void 0:e.addEventListener)=="function"}function we({children:e,side:t="left",onEscape:r,onHoverIn:o,onHoverOut:n,hoverDelayInMilliseconds:c=re}){var C,p;let f=(0,pe.useTheme)(),u=(0,d.useRef)(null),s=(0,d.useRef)(null),w=(0,d.useRef)(!1),[i,l]=(0,d.useState)(null);(0,d.useEffect)(()=>g,[]);function g(){s.current&&(clearTimeout(s.current),s.current=null)}function E(){o&&(g(),s.current=setTimeout(()=>{s.current=null,w.current=!0,l(null),o()},c))}function G(){g(),w.current&&(w.current=!1,n==null||n())}let R={side:t,show(L){if(D.Platform.OS==="web"){l(fe(L,t,{left:0,top:0,width:at()}));return}T(u.current,(m,I,h)=>{l(fe(L,t,{left:m,top:I,width:h}))})},hide:()=>l(null)};return(0,d.useEffect)(()=>{let L=u.current,m=typeof document=="undefined"?void 0:document;if(D.Platform.OS!=="web"||!lt(L)||!m)return;let I=L,h=m;function b(){l(null)}function _(J){let v=Array.from(I.querySelectorAll(nt));it(J,{entries:v,activeIndex:v.indexOf(h.activeElement),hideLabel:b,onEscape:r})}return I.addEventListener("keydown",_),h.addEventListener("scroll",b,!0),()=>{I.removeEventListener("keydown",_),h.removeEventListener("scroll",b,!0)}},[r]),(0,M.jsx)(be.Provider,{value:R,children:(0,M.jsxs)(D.View,{ref:u,collapsable:!1,style:[ct.root,{backgroundColor:f.colors.drawer.background}],onPointerEnter:E,onPointerLeave:G,testID:"drawer-root",children:[e,(0,M.jsx)(K,{text:(C=i==null?void 0:i.text)!=null?C:"",visible:i!==null,top:(p=i==null?void 0:i.top)!=null?p:0,left:i==null?void 0:i.left,right:i==null?void 0:i.right})]})})}var ct=D.StyleSheet.create({root:{flex:1}});var y=require("react/jsx-runtime"),st=250,dt=1500,ge={MD:"3rem",SM:"2.5rem"},ut={MD:"MD",SM:"SM"};function ye(G){var R=G,{icon:e,accessibilityLabel:t,label:r=t,active:o=!1,color:n="DEFAULT",badge:c,size:f="MD",onHoverIn:u,onHoverOut:s,onFocus:w,onBlur:i,onPressIn:l,onLongPress:g}=R,E=z(R,["icon","accessibilityLabel","label","active","color","badge","size","onHoverIn","onHoverOut","onFocus","onBlur","onPressIn","onLongPress"]);var oe;let C=(0,De.useTheme)(),p=Y(),L=(0,S.useRef)(null),m=(0,S.useRef)(null),I=(0,S.useRef)(!1),h=(0,S.useRef)(!1),[b,_]=(0,S.useState)(null),J=U(C,n,o),v=W(C),Oe=C.colors.drawer.activeBackground,Ge=c?`${t}, ${c}`:t;(0,S.useEffect)(()=>()=>{k(),I.current&&(p==null||p.hide())},[]);function k(){m.current&&(clearTimeout(m.current),m.current=null)}function Q(){T(L.current,(a,ne,ie,ae)=>{if(p){I.current=!0,p.show({text:r,anchor:{left:a,top:ne,width:ie,height:ae}});return}x.Platform.OS==="web"&&_({top:ne+(ae-A)/2,left:a+ie+P})})}function H(){if(k(),p){I.current=!1,p.hide();return}_(null)}function He(){k(),Q(),m.current=setTimeout(()=>{m.current=null,H()},dt)}function Ve(a){k(),m.current=setTimeout(()=>{m.current=null,Q()},a)}function Xe(a){Ve(st),u==null||u(a)}function ze(a){H(),s==null||s(a)}function $e(a){h.current?h.current=!1:(k(),Q()),w==null||w(a)}function Ue(a){h.current=!1,H(),i==null||i(a)}function We(a){h.current=!0,H(),l==null||l(a)}function Ke(a){x.Platform.OS!=="web"&&p&&He(),g==null||g(a)}return(0,y.jsxs)(x.View,{ref:L,collapsable:!1,style:Ie.anchor,testID:"drawer-compact-item-anchor",children:[(0,y.jsx)(Ee.Clickable,X(F({accessibilityRole:"button",accessibilityLabel:Ge,accessibilityState:{selected:o},width:ge[f],height:ge[f],align:"CENTER_CENTER",borderRadius:"MEDIUM",backgroundColor:o?Oe:void 0,whenHovered:v?{backgroundColor:v}:void 0,whenPressed:v?{backgroundColor:v}:void 0,onHoverIn:Xe,onHoverOut:ze,onFocus:$e,onBlur:Ue,onPressIn:We,onLongPress:Ke},E),{testID:"drawer-compact-item",children:(0,y.jsx)(Le.Icon,{name:e,size:ut[f],color:J})})),c&&(0,y.jsx)(x.View,{style:Ie.badge,pointerEvents:"none",testID:"drawer-compact-item-badge",children:(0,y.jsx)(Se.Badge,{text:c,type:"DANGER",size:"2XS",isRounded:!0})}),(0,y.jsx)(K,{text:r,visible:b!==null,top:(oe=b==null?void 0:b.top)!=null?oe:0,left:b==null?void 0:b.left})]})}var he=2,Ie=x.StyleSheet.create({anchor:{alignSelf:"center"},badge:{position:"absolute",top:he,right:he}});var xe=$(require("styled-components/native")),ve=require("@mobilestock-native/container"),Ce=require("react/jsx-runtime"),mt={MD:"XS",SM:"2XS"};function Re({children:e,compact:t=!1,size:r="MD"}){let o=`${mt[r]}_${t?"NONE":"SM"}`;return(0,Ce.jsx)(ft,{padding:o,testID:"drawer-footer",children:e})}var ft=(0,xe.default)(ve.Container)`
11
11
  border-top-width: 1px;
12
12
  border-top-color: ${({theme:e})=>e.colors.drawer.divider};
13
- `;var Y=$(require("styled-components/native")),Te=require("@mobilestock-native/clickable"),ke=require("@mobilestock-native/icons"),_e=require("@mobilestock-native/typography");var B=require("react/jsx-runtime");function Ne(s){var d=s,{label:e,icon:t,color:r="DEFAULT",active:o=!1,trailing:n,href:l,accessibilityLabel:p}=d,b=H(d,["label","icon","color","active","trailing","href","accessibilityLabel"]);let i=(0,Y.useTheme)(),u=U(i,r,o),m=z(i),R=i.colors.drawer.activeBackground;return(0,B.jsxs)(Te.Clickable,X(N(N({accessibilityRole:l?"link":"button",accessibilityLabel:p!=null?p:e,accessibilityState:{selected:o},direction:"ROW",align:"START_CENTER",gap:"SM",padding:"2XS_XS",minHeight:"2.75rem",borderRadius:"DEFAULT",backgroundColor:o?R:void 0,whenHovered:m?{backgroundColor:m}:void 0,whenPressed:m?{backgroundColor:m}:void 0},l?{href:l}:null),b),{testID:"drawer-item",children:[(0,B.jsx)(ke.Icon,{name:t,size:"SM",color:u}),(0,B.jsx)(ft,{size:"SM",$color:u,withEllipsis:!0,testID:"drawer-item-label",children:e}),n]}))}var ft=(0,Y.default)(_e.Typography)`
13
+ `;var Z=$(require("styled-components/native")),Te=require("@mobilestock-native/clickable"),_e=require("@mobilestock-native/icons"),ke=require("@mobilestock-native/typography");var B=require("react/jsx-runtime"),pt={MD:"2.75rem",SM:"2.25rem"},bt={MD:"SM",SM:"XS"};function Ne(w){var i=w,{label:e,icon:t,color:r="DEFAULT",active:o=!1,trailing:n,href:c,accessibilityLabel:f,size:u="MD"}=i,s=z(i,["label","icon","color","active","trailing","href","accessibilityLabel","size"]);let l=(0,Z.useTheme)(),g=U(l,r,o),E=W(l),G=l.colors.drawer.activeBackground,R=Math.round(Number(l.font.size.sm)*l.font.lineHeight);return(0,B.jsxs)(Te.Clickable,X(F(F({accessibilityRole:c?"link":"button",accessibilityLabel:f!=null?f:e,accessibilityState:{selected:o},direction:"ROW",align:"START_CENTER",gap:"SM",padding:"2XS_XS",minHeight:pt[u],borderRadius:"DEFAULT",backgroundColor:o?G:void 0,whenHovered:E?{backgroundColor:E}:void 0,whenPressed:E?{backgroundColor:E}:void 0},c?{href:c}:null),s),{testID:"drawer-item",children:[(0,B.jsx)(_e.Icon,{name:t,size:"SM",color:g}),(0,B.jsx)(wt,{size:bt[u],$color:g,$lineHeight:R,withEllipsis:!0,testID:"drawer-item-label",children:e}),n]}))}var wt=(0,Z.default)(ke.Typography)`
14
14
  flex-shrink: 1;
15
+ line-height: ${({$lineHeight:e})=>e}px;
15
16
  color: ${({$color:e})=>e};
16
- `;var Pe=require("react"),q=require("react-native"),Ae=$(require("styled-components/native")),Fe=require("@mobilestock-native/container"),Be=require("@mobilestock-native/typography");var M=require("react/jsx-runtime");function Me({title:e,compact:t=!1}){let r=K(),o=(0,Pe.useRef)(null);function n(){r&&C(o.current,(p,b,s,d)=>{r.show({text:e,anchor:{left:p,top:b,width:s,height:d}})})}function l(){r==null||r.hide()}return t?(0,M.jsx)(q.View,{ref:o,collapsable:!1,style:bt.dividerRow,accessible:!0,accessibilityRole:"header",accessibilityLabel:e,onPointerEnter:n,onPointerLeave:l,testID:"drawer-section-divider",children:(0,M.jsx)(pt,{testID:"drawer-section-divider-line"})}):(0,M.jsx)(Fe.Container,{padding:"SM_XS_2XS_XS",testID:"drawer-section-title",children:(0,M.jsx)(Be.Typography,{size:"XS",weight:"BOLD",color:"DEFAULT_200",transform:"UPPERCASE",accessibilityRole:"header",children:e})})}var pt=Ae.default.View`
17
+ `;var Fe=require("react"),q=require("react-native"),Ae=$(require("styled-components/native")),Pe=require("@mobilestock-native/container"),Me=require("@mobilestock-native/typography");var O=require("react/jsx-runtime");function Be({title:e,compact:t=!1}){let r=Y(),o=(0,Fe.useRef)(null);function n(){r&&T(o.current,(f,u,s,w)=>{r.show({text:e,anchor:{left:f,top:u,width:s,height:w}})})}function c(){r==null||r.hide()}return t?(0,O.jsx)(q.View,{ref:o,collapsable:!1,style:ht.dividerRow,accessible:!0,accessibilityRole:"header",accessibilityLabel:e,onPointerEnter:n,onPointerLeave:c,testID:"drawer-section-divider",children:(0,O.jsx)(gt,{testID:"drawer-section-divider-line"})}):(0,O.jsx)(Pe.Container,{padding:"SM_XS_2XS_XS",testID:"drawer-section-title",children:(0,O.jsx)(Me.Typography,{size:"XS",weight:"BOLD",color:"DEFAULT_200",transform:"UPPERCASE",accessibilityRole:"header",children:e})})}var gt=Ae.default.View`
17
18
  width: 32px;
18
19
  height: 1px;
19
20
  background-color: ${({theme:e})=>e.colors.drawer.divider};
20
- `,bt=q.StyleSheet.create({dividerRow:{alignItems:"center",paddingVertical:4}});var wt={Root:we,Item:Ne,CompactItem:ye,SectionTitle:Me,Footer:Ce};0&&(module.exports={Drawer,HOVER_EXPAND_DELAY_IN_MILLISECONDS});
21
+ `,ht=q.StyleSheet.create({dividerRow:{alignItems:"center",paddingVertical:4}});var It={Root:we,Item:Ne,CompactItem:ye,SectionTitle:Be,Footer:Re};0&&(module.exports={Drawer,HOVER_EXPAND_DELAY_IN_MILLISECONDS});
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mobilestock-native/drawer",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
- "@mobilestock-native/badge": "^0.1.5",
7
- "@mobilestock-native/clickable": "^1.1.2",
6
+ "@mobilestock-native/clickable": "^1.1.3",
8
7
  "@mobilestock-native/container": "^1.4.0",
9
- "@mobilestock-native/icons": "^0.10.0",
10
- "@mobilestock-native/typography": "^0.1.3"
8
+ "@mobilestock-native/icons": "^0.10.1",
9
+ "@mobilestock-native/typography": "^0.1.3",
10
+ "@mobilestock-native/badge": "^0.1.5"
11
11
  },
12
12
  "peerDependencies": {
13
13
  "react": "18.2.0",