|
| 1 | +import{j as n}from"./iframe-CMOSZBev.js";import{useMDXComponents as i}from"./index-BTwv99x0.js";import{M as p,C as c}from"./blocks-C7uNs7TS.js";import"./Tag-CqfvYh1K.js";import"./index-SUBNzPDi.js";import{C as a}from"./ControlsWithNote-BpW64yfj.js";import{D as m}from"./DocsHeader-G6_xaaS-.js";import{F as h}from"./CommandsAndQueries-BBxM4nbH.js";import{C as o,D as r}from"./ActionSheet.stories-Qqnbooky.js";import"./preload-helper-PPVm8Dsz.js";import"./information-D_sfcND0.js";import"./sys-enter-2-D7lHEvN4.js";import"./alert-CMJogacJ.js";import"./index-B2Bp115n.js";import"./index-CKeepgUa.js";import"./Link-D-jONPM3.js";import"./copy-C95MyXMx.js";import"./copy-CxpwRqG0.js";import"./GitHub-Mark-BaY2R9rx.js";import"./TableOfContent--rxK582K.js";import"./index-BcSeOVwt.js";import"./index-_PRo-73t.js";import"./index-kRKXYALW.js";import"./index-BG7mFBoF.js";import"./index-DnIJB1t0.js";import"./AvatarSize-BtKTMFJ5.js";import"./employee-DkqbRy7L.js";import"./addCustomCSSWithScoping-CCFGNXq3.js";import"./delete-jqJpTe2L.js";import"./utils-CJbFgKgb.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