@@ -42,8 +42,8 @@ npm install @reactleaf/modal@2
4242``` ts
4343// modals/register.ts
4444export const register = {
45- Alert : () => import (' ./Alert' ),
46- Confirm : () => import (' ./Confirm' ),
45+ Alert : () => import (" ./Alert" ),
46+ Confirm : () => import (" ./Confirm" ),
4747};
4848```
4949
@@ -58,8 +58,8 @@ export const register = {
5858** Before (v1.x):**
5959
6060``` tsx
61- import { ModalProvider } from ' @reactleaf/modal' ;
62- import register from ' ./modals/register' ;
61+ import { ModalProvider } from " @reactleaf/modal" ;
62+ import register from " ./modals/register" ;
6363
6464function App() {
6565 return (
@@ -73,7 +73,7 @@ function App() {
7373** After (v2.0):**
7474
7575``` tsx
76- import { ModalManager , ModalProvider } from ' @reactleaf/modal' ;
76+ import { ModalManager , ModalProvider } from " @reactleaf/modal" ;
7777
7878const modal = new ModalManager ();
7979
@@ -97,7 +97,7 @@ The `modal` instance passed to `ModalProvider` must be the same instance you cal
9797** Before (v1.x):**
9898
9999``` tsx
100- import { BasicModalProps } from ' @reactleaf/modal' ;
100+ import { BasicModalProps } from " @reactleaf/modal" ;
101101
102102interface AlertProps extends BasicModalProps {
103103 message: string ;
@@ -116,7 +116,7 @@ export default function Alert({ message, close }: AlertProps) {
116116** After (v2.0):**
117117
118118``` tsx
119- import { useModalInstance } from ' @reactleaf/modal' ;
119+ import { useModalInstance } from " @reactleaf/modal" ;
120120
121121interface AlertProps {
122122 message: string ;
@@ -126,9 +126,9 @@ const Alert = ({ message }: AlertProps) => {
126126 const { closeSelf, visible } = useModalInstance ();
127127
128128 return (
129- <div className = { visible ? ' visible' : undefined } >
129+ <div className = { visible ? " visible" : undefined } >
130130 <p >{ message } </p >
131- <button onClick = { () => closeSelf (' confirmed' )} >OK</button >
131+ <button onClick = { () => closeSelf (" confirmed" )} >OK</button >
132132 </div >
133133 );
134134};
@@ -145,27 +145,27 @@ export default Alert;
145145** Before (v1.x):**
146146
147147``` tsx
148- import { useModal } from ' @reactleaf/modal' ;
148+ import { useModal } from " @reactleaf/modal" ;
149149
150150function MyComponent() {
151151 const { openModal } = useModal ();
152152
153153 const handleShowAlert = () => {
154- openModal (' Alert' , { message: ' Hello!' });
154+ openModal (" Alert" , { message: " Hello!" });
155155 };
156156}
157157```
158158
159159** After (v2.0):**
160160
161161``` tsx
162- import { ModalManager } from ' @reactleaf/modal' ;
163- import Alert from ' ./modals/Alert' ;
162+ import { ModalManager } from " @reactleaf/modal" ;
163+ import Alert from " ./modals/Alert" ;
164164
165165const modal = new ModalManager ();
166166
167167async function handleShowAlert() {
168- const result = await modal .open (Alert , { message: ' Hello!' });
168+ const result = await modal .open (Alert , { message: " Hello!" });
169169 console .log (result ); // 'confirmed'
170170}
171171```
@@ -176,7 +176,7 @@ async function handleShowAlert() {
176176
177177``` tsx
178178const confirmed = await modal .open (Confirm , {
179- message: ' Are you sure you want to delete this item?' ,
179+ message: " Are you sure you want to delete this item?" ,
180180});
181181
182182if (confirmed ) {
@@ -187,20 +187,16 @@ if (confirmed) {
187187#### AbortController
188188
189189``` tsx
190- import { MODAL_ABORTED } from ' @reactleaf/modal' ;
190+ import { MODAL_ABORTED } from " @reactleaf/modal" ;
191191
192192const controller = new AbortController ();
193193
194194setTimeout (() => controller .abort (), 5000 );
195195
196- const result = await modal .open (
197- Alert ,
198- { message: ' This will auto-close...' },
199- { abortController: controller },
200- );
196+ const result = await modal .open (Alert , { message: " This will auto-close..." }, { abortController: controller });
201197
202198if (result === MODAL_ABORTED ) {
203- console .log (' Modal was aborted' );
199+ console .log (" Modal was aborted" );
204200}
205201```
206202
@@ -228,11 +224,11 @@ Options are merged in this order:
228224 rootOptions = { { preventScroll: true }}
229225>
230226 <App />
231- </ModalProvider >
227+ </ModalProvider >;
232228
233229Alert .layerOptions = { closeOnOutsideClick: false };
234230
235- await modal .open (Alert , { message: ' Hello' }, { className: ' alert-layer' });
231+ await modal .open (Alert , { message: " Hello" }, { className: " alert-layer" });
236232```
237233
238234### 2. Context-based modal props
@@ -244,10 +240,10 @@ const MyModal = ({ title, message }: { title: string; message: string }) => {
244240 const { closeSelf, visible } = useModalInstance ();
245241
246242 return (
247- <div className = { ` modal ${visible ? ' visible' : ' ' } ` } >
243+ <div className = { ` modal ${visible ? " visible" : " " } ` } >
248244 <h1 >{ title } </h1 >
249245 <p >{ message } </p >
250- <button onClick = { () => closeSelf (' success' )} >OK</button >
246+ <button onClick = { () => closeSelf (" success" )} >OK</button >
251247 </div >
252248 );
253249};
@@ -281,10 +277,10 @@ const unsubscribe = modal.subscribe((stack) => {
281277
282278``` tsx
283279// Old
284- import { useModal } from ' @reactleaf/modal' ;
280+ import { useModal } from " @reactleaf/modal" ;
285281
286282// New
287- import { ModalManager , ModalProvider , useModalInstance } from ' @reactleaf/modal' ;
283+ import { ModalManager , ModalProvider , useModalInstance } from " @reactleaf/modal" ;
288284```
289285
290286### Issue 2: ` BasicModalProps ` errors
0 commit comments