|
| 1 | +import{j as n}from"./iframe-CyQHbHxC.js";import{useMDXComponents as s}from"./index-CAqjzf3-.js";import{M as p,C as c}from"./blocks-B1BKQjJv.js";import"./Tag-CpzoOvR8.js";import"./index-DVtJUpci.js";import{C as a}from"./ControlsWithNote-BNokvIjE.js";import{D as m}from"./DocsHeader-D3sFB4u7.js";import{F as h}from"./Footer-B6F6QaBp.js";import"./CommandsAndQueries-CQRKG-No.js";import"./PageNotFound-BwogsJtD.js";import{C as o,D as r}from"./ActionSheet.stories-DDwlV7DO.js";import"./preload-helper-PPVm8Dsz.js";import"./information-DjNNiNHU.js";import"./sys-enter-2-BgUfXyT0.js";import"./alert-CTY_LxCJ.js";import"./index-1GAsnXVc.js";import"./index-DUAJQglC.js";import"./Link-8vAV1o0p.js";import"./copy-BMtlJq5M.js";import"./copy-DaAXI0wh.js";import"./GitHub-Mark-B7CobaJ5.js";import"./TableOfContent-5QHPn7EL.js";import"./index-DMBzjcEO.js";import"./index-hCRaM0Y7.js";import"./index-DdcJcuqo.js";import"./index-Dk8Vx9PA.js";import"./index-CyzsrkYQ.js";import"./AvatarSize-BtKTMFJ5.js";import"./employee-BPaLVEvo.js";import"./addCustomCSSWithScoping-iqlifjV6.js";import"./Illustrations-BxTCLiS4.js";import"./i18n-defaults-CFWtSmu6.js";import"./delete-BjTdR4Ty.js";import"./utils-ClisyTNb.js";function i(t){const e={code:"code",h2:"h2",p:"p",pre:"pre",strong:"strong",...s(),...t.components};return n.jsxs(n.Fragment,{children:[n.jsx(p,{of:o}),` |
| 2 | +`,n.jsx(m,{of:o,subComponents:["Button"]}),` |
| 3 | +`,n.jsx("br",{}),` |
| 4 | +`,n.jsx(e.h2,{id:"example",children:"Example"}),` |
| 5 | +`,n.jsx(c,{of:r}),` |
| 6 | +`,n.jsx(e.h2,{id:"properties",children:"Properties"}),` |
| 7 | +`,n.jsx(a,{of:r}),` |
| 8 | +`,n.jsx(e.h2,{id:"opening-actionsheets",children:"Opening ActionSheets"}),` |
| 9 | +`,n.jsx("br",{}),` |
| 10 | +`,n.jsxs(e.p,{children:["You can open and close the ",n.jsx(e.code,{children:"ActionSheet"})," component in a declarative way using the ",n.jsx(e.code,{children:"open"})," and ",n.jsx(e.code,{children:"opener"})," prop."]}),` |
| 11 | +`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-tsx",children:`const MyComponentWithActionSheet = () => { |
| 12 | + const [actionSheetIsOpen, setActionSheetIsOpen] = useState(false); |
| 13 | + return ( |
| 14 | + <> |
| 15 | + <Button |
| 16 | + id={'openActionSheetBtn'} |
| 17 | + onClick={() => { |
| 18 | + setActionSheetIsOpen(true); |
| 19 | + }} |
| 20 | + > |
| 21 | + Open Action Sheet |
| 22 | + </Button> |
| 23 | + <ActionSheet |
| 24 | + opener={'openActionSheetBtn'} |
| 25 | + open={actionSheetIsOpen} |
| 26 | + onClose={() => { |
| 27 | + setActionSheetIsOpen(false); |
| 28 | + }} |
| 29 | + /> |
| 30 | + </> |
| 31 | + ); |
| 32 | +}; |
| 33 | +`})}),` |
| 34 | +`,n.jsx(e.p,{children:n.jsxs(e.strong,{children:["Opening an ",n.jsx(e.code,{children:"ActionSheet"})," by reference"]})}),` |
| 35 | +`,n.jsxs(e.p,{children:["The ",n.jsx(e.code,{children:"ActionSheet"})," exposes a way to pass a reference of an element instead of an ",n.jsx(e.code,{children:"id"})," to the ",n.jsx(e.code,{children:"opener"}),` prop. |
| 36 | +You can do that by e.g. leveraging a React Ref.`]}),` |
| 37 | +`,n.jsx(e.pre,{children:n.jsx(e.code,{className:"language-jsx",children:`const ActionSheetComponent = () => { |
| 38 | + const buttonRef = useRef(null); |
| 39 | + const [open, setOpen] = useState(false); |
| 40 | + const handleOpenerClick = (e) => { |
| 41 | + setOpen((prev) => !prev); |
| 42 | + }; |
| 43 | + return ( |
| 44 | + <> |
| 45 | + <Button ref={buttonRef} onClick={handleOpenerClick}> |
| 46 | + Opener |
| 47 | + </Button> |
| 48 | + <ActionSheet opener={buttonRef.current} open={open}> |
| 49 | + {/* Content */} |
| 50 | + </ActionSheet> |
| 51 | + </> |
| 52 | + ); |
| 53 | +}; |
| 54 | +`})}),` |
| 55 | +`,n.jsx(h,{})]})}function G(t={}){const{wrapper:e}={...s(),...t.components};return e?n.jsx(e,{...t,children:n.jsx(i,{...t})}):i(t)}export{G as default}; |
0 commit comments