|
| 1 | +import{j as n}from"./iframe-BH4bVelf.js";import{useMDXComponents as i}from"./index-BZqT0YF1.js";import{M as p,C as c}from"./blocks-CeYDMKuM.js";import"./Tag-BXnIP2dS.js";import"./index-CJTqi7uU.js";import{C as a}from"./ControlsWithNote-DQQ69lO5.js";import{D as m}from"./DocsHeader-Chw2B0KH.js";import{F as h}from"./CommandsAndQueries-D9wpOiDr.js";import{C as o,D as r}from"./ActionSheet.stories-DngS3xws.js";import"./preload-helper-PPVm8Dsz.js";import"./information-BFXgiRFQ.js";import"./sys-enter-2-IrFhFhIl.js";import"./alert-2wR6R_Um.js";import"./index-AtaZxDlU.js";import"./index-CaNjf1Vn.js";import"./Link-CWmFbngj.js";import"./copy-r7oiWpAQ.js";import"./copy-Dqlw1cCi.js";import"./GitHub-Mark-D1C-ERE2.js";import"./TableOfContent-CmqsyGDI.js";import"./index-Clh4Efsf.js";import"./index-CF882nWm.js";import"./index-BD7TNiZv.js";import"./index-BoC02bGf.js";import"./index-DwqLEbZm.js";import"./AvatarSize-BtKTMFJ5.js";import"./employee-C83XHNHQ.js";import"./addCustomCSSWithScoping-BSRRxoii.js";import"./delete-D4wiFYB9.js";import"./utils-C0YjVaw1.js";function s(t){const e={code:"code",h2:"h2",p:"p",pre:"pre",strong:"strong",...i(),...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 P(t={}){const{wrapper:e}={...i(),...t.components};return e?n.jsx(e,{...t,children:n.jsx(s,{...t})}):s(t)}export{P as default}; |
0 commit comments