@mobilestock-native/drawer 0.0.0-stage → 0.1.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/index.d.ts +247 -0
- package/index.js +20 -0
- package/package.json +14 -3
- package/README.md +0 -3
package/index.d.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ClickableProps } from '@mobilestock-native/clickable';
|
|
3
|
+
import { IconName } from '@mobilestock-native/icons';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description Color of the icon of a compact item: `DEFAULT` the text color, `DANGER` the danger color (logout).
|
|
8
|
+
*/
|
|
9
|
+
type DrawerCompactItemColor = 'DEFAULT' | 'DANGER';
|
|
10
|
+
/**
|
|
11
|
+
* @description Size of the compact item: `MD` the 48×48 item of the 72px bar (tablet and desktop), `SM` the 40×40 item
|
|
12
|
+
* with a smaller icon for the 56px bar of a phone.
|
|
13
|
+
*/
|
|
14
|
+
type DrawerCompactItemSize = 'MD' | 'SM';
|
|
15
|
+
interface DrawerCompactItemProps extends Omit<ClickableProps, 'children' | 'accessibilityLabel'> {
|
|
16
|
+
/**
|
|
17
|
+
* @description Icon of the item, from `@mobilestock-native/icons`.
|
|
18
|
+
* Default: required
|
|
19
|
+
* @example icon="ReceiptLong"
|
|
20
|
+
*/
|
|
21
|
+
icon: IconName;
|
|
22
|
+
/**
|
|
23
|
+
* @description Name of the item for screen readers. Required: the icon is the only thing drawn.
|
|
24
|
+
* Default: required
|
|
25
|
+
* @example accessibilityLabel="Pedidos da loja"
|
|
26
|
+
*/
|
|
27
|
+
accessibilityLabel: string;
|
|
28
|
+
/**
|
|
29
|
+
* @description Text of the floating label shown beside the item while the pointer rests on it or the item has the
|
|
30
|
+
* keyboard focus (web), or after a long press (native, inside a `Drawer.Root`).
|
|
31
|
+
* Default: the `accessibilityLabel`
|
|
32
|
+
* @example label="Pedidos"
|
|
33
|
+
*/
|
|
34
|
+
label?: string;
|
|
35
|
+
/**
|
|
36
|
+
* @description Marks the item of the current screen: the background takes `theme.colors.drawer.activeBackground`
|
|
37
|
+
* and the icon takes `theme.colors.drawer.activeForeground`.
|
|
38
|
+
* Default: false
|
|
39
|
+
* @example active
|
|
40
|
+
*/
|
|
41
|
+
active?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @description Color of the icon: `DEFAULT` the text color, `DANGER` the danger color (logout).
|
|
44
|
+
* Default: 'DEFAULT'
|
|
45
|
+
* @example color="DANGER"
|
|
46
|
+
*/
|
|
47
|
+
color?: DrawerCompactItemColor;
|
|
48
|
+
/**
|
|
49
|
+
* @description Short text drawn as a badge over the top right corner of the icon: a count of pending orders, a
|
|
50
|
+
* "new" mark. It is read after the accessibility label.
|
|
51
|
+
* Default: undefined
|
|
52
|
+
* @example badge="3"
|
|
53
|
+
*/
|
|
54
|
+
badge?: string;
|
|
55
|
+
/**
|
|
56
|
+
* @description `MD` is the 48×48 item of the 72px bar; `SM` the 40×40 item with a smaller icon, for the 56px bar of
|
|
57
|
+
* a phone (`theme.drawer.compactSmall`).
|
|
58
|
+
* Default: 'MD'
|
|
59
|
+
* @example size="SM"
|
|
60
|
+
*/
|
|
61
|
+
size?: DrawerCompactItemSize;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @description The icon-only item of the compact side menu: a 48×48 touch area (40×40 with `size="SM"`), centered,
|
|
65
|
+
* with the medium radius of the theme. `active` tints it with the active colors of the drawer; the hover and the
|
|
66
|
+
* press take the hover color of the list items. On web, the item name floats beside it while the pointer rests on it
|
|
67
|
+
* or while it has the keyboard focus, never on a click; on native, after a long press, when the menu is wrapped in a
|
|
68
|
+
* `Drawer.Root`.
|
|
69
|
+
*/
|
|
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
|
+
|
|
72
|
+
interface DrawerFooterProps {
|
|
73
|
+
children: ReactNode;
|
|
74
|
+
/**
|
|
75
|
+
* @description Drops the side padding, so a 48px compact item fits the 72px bar.
|
|
76
|
+
* Default: false
|
|
77
|
+
* @example compact
|
|
78
|
+
*/
|
|
79
|
+
compact?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @description Bottom area of the side menu, under the scrolling entries: a hairline on top, in the divider color of
|
|
83
|
+
* the drawer, and the padding of the menu. Holds the logout (and the login of a visitor).
|
|
84
|
+
*/
|
|
85
|
+
declare function Footer({ children, compact }: DrawerFooterProps): react_jsx_runtime.JSX.Element;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @description Color of the icon and the label of an item: `DEFAULT` is the text color, `SELECTED` is the active
|
|
89
|
+
* color of the drawer (the brand color) and `DANGER` is the danger color, for the logout.
|
|
90
|
+
*/
|
|
91
|
+
type DrawerItemColor = 'DEFAULT' | 'SELECTED' | 'DANGER';
|
|
92
|
+
|
|
93
|
+
interface DrawerItemProps extends Omit<ClickableProps, 'children'> {
|
|
94
|
+
/**
|
|
95
|
+
* @description Text of the item. It is also the accessibility label, unless `accessibilityLabel` is given.
|
|
96
|
+
* Default: required
|
|
97
|
+
* @example label="Pedidos da loja"
|
|
98
|
+
*/
|
|
99
|
+
label: string;
|
|
100
|
+
/**
|
|
101
|
+
* @description Icon drawn before the label, from `@mobilestock-native/icons`.
|
|
102
|
+
* Default: required
|
|
103
|
+
* @example icon="ReceiptLong"
|
|
104
|
+
*/
|
|
105
|
+
icon: IconName;
|
|
106
|
+
/**
|
|
107
|
+
* @description Color of the icon and the label: `DEFAULT` the text color, `SELECTED` the active color of the
|
|
108
|
+
* drawer (the brand color), `DANGER` the danger color (logout).
|
|
109
|
+
* Default: 'DEFAULT'
|
|
110
|
+
* @example color="DANGER"
|
|
111
|
+
*/
|
|
112
|
+
color?: DrawerItemColor;
|
|
113
|
+
/**
|
|
114
|
+
* @description Marks the item of the current screen: the background takes `theme.colors.drawer.activeBackground`
|
|
115
|
+
* and the icon and the label take `theme.colors.drawer.activeForeground`.
|
|
116
|
+
* Default: false
|
|
117
|
+
* @example active
|
|
118
|
+
*/
|
|
119
|
+
active?: boolean;
|
|
120
|
+
/**
|
|
121
|
+
* @description Element drawn after the label, on the same row: a balance, a badge, a counter.
|
|
122
|
+
* Default: undefined
|
|
123
|
+
* @example trailing={<Typography size="XS" color="DEFAULT_200">R$ 0,00</Typography>}
|
|
124
|
+
*/
|
|
125
|
+
trailing?: ReactNode;
|
|
126
|
+
/**
|
|
127
|
+
* @description URL of the item on web, so the row is a real link (middle click, open in a new tab). Ignored on
|
|
128
|
+
* native.
|
|
129
|
+
* Default: undefined
|
|
130
|
+
* @example href="https://necso.com.br/conta"
|
|
131
|
+
*/
|
|
132
|
+
href?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @description One row of the expanded side menu: icon, label and an optional trailing element, with a touch height
|
|
136
|
+
* of at least 44px and the radius of the theme. `active` tints the row with the active colors of the drawer.
|
|
137
|
+
*/
|
|
138
|
+
declare function Item({ label, icon, color, active, trailing, href, accessibilityLabel, ...props }: DrawerItemProps): react_jsx_runtime.JSX.Element;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @description Box of the item (or divider) a floating label names, in window coordinates.
|
|
142
|
+
*/
|
|
143
|
+
interface FloatingLabelAnchor {
|
|
144
|
+
left: number;
|
|
145
|
+
top: number;
|
|
146
|
+
width: number;
|
|
147
|
+
height: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @description Side of the screen the menu is attached to. The floating labels open towards the other side.
|
|
152
|
+
*/
|
|
153
|
+
type DrawerSide = 'left' | 'right';
|
|
154
|
+
interface FloatingLabelRequest {
|
|
155
|
+
text: string;
|
|
156
|
+
anchor: FloatingLabelAnchor;
|
|
157
|
+
}
|
|
158
|
+
interface DrawerRootProps {
|
|
159
|
+
children: ReactNode;
|
|
160
|
+
/**
|
|
161
|
+
* @description Side of the screen the menu is attached to: the floating labels open to the right of a left menu
|
|
162
|
+
* and to the left of a right menu.
|
|
163
|
+
* Default: 'left'
|
|
164
|
+
* @example side="right"
|
|
165
|
+
*/
|
|
166
|
+
side?: DrawerSide;
|
|
167
|
+
/**
|
|
168
|
+
* @description Called on web when `Escape` is pressed with the keyboard focus inside the menu: the place to collapse
|
|
169
|
+
* an expanded permanent menu or close the overlay.
|
|
170
|
+
* Default: undefined
|
|
171
|
+
* @example onEscape={collapseMenu}
|
|
172
|
+
*/
|
|
173
|
+
onEscape?(): void;
|
|
174
|
+
/**
|
|
175
|
+
* @description Called on web once the pointer rested over the menu for `hoverDelayInMilliseconds`: the place to
|
|
176
|
+
* expand a compact permanent menu while the mouse is on it. The floating label leaves at the same time, since the
|
|
177
|
+
* menu is about to change shape.
|
|
178
|
+
* Default: undefined
|
|
179
|
+
* @example onHoverIn={expandMenu}
|
|
180
|
+
*/
|
|
181
|
+
onHoverIn?(): void;
|
|
182
|
+
/**
|
|
183
|
+
* @description Called on web when the pointer leaves the menu after `onHoverIn` fired: the place to collapse the
|
|
184
|
+
* menu again. Leaving before the delay only cancels the pending `onHoverIn`.
|
|
185
|
+
* Default: undefined
|
|
186
|
+
* @example onHoverOut={collapseMenu}
|
|
187
|
+
*/
|
|
188
|
+
onHoverOut?(): void;
|
|
189
|
+
/**
|
|
190
|
+
* @description How long the pointer has to rest over the menu before `onHoverIn` fires, so crossing the menu on the
|
|
191
|
+
* way to the screen does not expand it.
|
|
192
|
+
* Default: 400
|
|
193
|
+
* @example hoverDelayInMilliseconds={600}
|
|
194
|
+
*/
|
|
195
|
+
hoverDelayInMilliseconds?: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* @description Default rest of the pointer over the menu before `onHoverIn` fires.
|
|
199
|
+
*/
|
|
200
|
+
declare const HOVER_EXPAND_DELAY_IN_MILLISECONDS = 400;
|
|
201
|
+
/**
|
|
202
|
+
* @description Wrapper of the whole content of a side menu. It fills its parent, painted with
|
|
203
|
+
* `theme.colors.drawer.background`, and draws the floating label of the
|
|
204
|
+
* compact item under the pointer here, outside the scroll area of the menu: inside a ScrollView the label would be
|
|
205
|
+
* positioned against the scroll container (react-native-web transforms it) and clipped by its overflow. On web it also
|
|
206
|
+
* hides the label when anything scrolls and moves the keyboard focus between the entries with the arrow keys.
|
|
207
|
+
*/
|
|
208
|
+
declare function Root({ children, side, onEscape, onHoverIn, onHoverOut, hoverDelayInMilliseconds }: DrawerRootProps): react_jsx_runtime.JSX.Element;
|
|
209
|
+
|
|
210
|
+
interface DrawerSectionTitleProps {
|
|
211
|
+
/**
|
|
212
|
+
* @description Name of the section, shown in upper case. In the compact menu it is the accessibility label of the
|
|
213
|
+
* divider and the floating label shown when the pointer rests on it.
|
|
214
|
+
* Default: required
|
|
215
|
+
* @example title="Minha loja"
|
|
216
|
+
*/
|
|
217
|
+
title: string;
|
|
218
|
+
/**
|
|
219
|
+
* @description Draws a 32px hairline divider instead of the text, for the compact menu. The title stays as the
|
|
220
|
+
* accessibility label, so screen readers still announce the section.
|
|
221
|
+
* Default: false
|
|
222
|
+
* @example compact
|
|
223
|
+
*/
|
|
224
|
+
compact?: boolean;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* @description Title of a group of items of the side menu: small bold upper-case text with the section padding. With
|
|
228
|
+
* `compact` the same component becomes the hairline divider that separates the groups of the compact menu; inside a
|
|
229
|
+
* `Drawer.Root`, on web, the pointer resting on the divider floats the name of the section beside it.
|
|
230
|
+
*/
|
|
231
|
+
declare function SectionTitle({ title, compact }: DrawerSectionTitleProps): react_jsx_runtime.JSX.Element;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* @description Pieces of a side menu: `Item` (icon, label and an optional trailing element), `CompactItem` (the
|
|
235
|
+
* icon-only item of the compact menu, with a floating label on web), `SectionTitle` (the title of a group of
|
|
236
|
+
* items, a hairline divider when `compact`) and `Root`, the wrapper of the menu that hosts the floating label
|
|
237
|
+
* outside the scroll area.
|
|
238
|
+
*/
|
|
239
|
+
declare const Drawer: {
|
|
240
|
+
Root: typeof Root;
|
|
241
|
+
Item: typeof Item;
|
|
242
|
+
CompactItem: typeof CompactItem;
|
|
243
|
+
SectionTitle: typeof SectionTitle;
|
|
244
|
+
Footer: typeof Footer;
|
|
245
|
+
};
|
|
246
|
+
|
|
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 };
|
package/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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`
|
|
2
|
+
z-index: 1000;
|
|
3
|
+
height: ${P}px;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
padding: 0 ${({theme:e})=>e.spacing.xs};
|
|
6
|
+
border-radius: ${({theme:e})=>e.borderRadius.default};
|
|
7
|
+
background-color: ${({theme:e})=>e.colors.drawer.labelBackground};
|
|
8
|
+
`,ot=(0,ee.default)(me.Typography)`
|
|
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)`
|
|
11
|
+
border-top-width: 1px;
|
|
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)`
|
|
14
|
+
flex-shrink: 1;
|
|
15
|
+
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
|
+
width: 32px;
|
|
18
|
+
height: 1px;
|
|
19
|
+
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});
|
package/package.json
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mobilestock-native/drawer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@mobilestock-native/badge": "^0.1.5",
|
|
7
|
+
"@mobilestock-native/clickable": "^1.1.2",
|
|
8
|
+
"@mobilestock-native/container": "^1.4.0",
|
|
9
|
+
"@mobilestock-native/icons": "^0.10.0",
|
|
10
|
+
"@mobilestock-native/typography": "^0.1.3"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"react": "18.2.0",
|
|
14
|
+
"react-native": "0.74.5",
|
|
15
|
+
"styled-components": "^6.1.8"
|
|
16
|
+
}
|
|
6
17
|
}
|
package/README.md
DELETED