@@ -25,6 +25,7 @@ import CodeEditor from './code-editor';
2525import { headerToId } from '../helpers/list-of-contents' ;
2626import ShareButton from './mdx/share-button' ;
2727import { grey } from '@mui/material/colors' ;
28+ import ErrorBoundary from './error-boundary' ;
2829
2930const HeadingRoot = styled ( 'div' ) ( ( { theme } ) => ( {
3031 '& .anchor' : {
@@ -207,78 +208,82 @@ const CodeExample = ({ source, mode }) => {
207208 } , [ source ] ) ;
208209 if ( mode === 'preview' ) {
209210 return (
210- < ExampleRoot container spacing = { 0 } className = { clsx ( 'DocRawComponent' , 'container' ) } >
211- { Component && (
212- < Heading component = "h3" level = "5" >
213- { name }
214- </ Heading >
215- ) }
216- { Component && (
217- < Grid className = { 'formContainer' } item xs = { 12 } >
218- < Paper className = { 'componentPanel' } >
219- < Component />
220- </ Paper >
211+ < ErrorBoundary >
212+ < ExampleRoot container spacing = { 0 } className = { clsx ( 'DocRawComponent' , 'container' ) } >
213+ { Component && (
214+ < Heading component = "h3" level = "5" >
215+ { name }
216+ </ Heading >
217+ ) }
218+ { Component && (
219+ < Grid className = { 'formContainer' } item xs = { 12 } >
220+ < Paper className = { 'componentPanel' } >
221+ < Component />
222+ </ Paper >
223+ </ Grid >
224+ ) }
225+ < Grid item xs = { 12 } >
226+ < Accordion className = { 'accordion' } >
227+ < AccordionSummary className = { 'accordionSummary' } >
228+ < Box display = "flex" >
229+ < form action = "https://codesandbox.io/api/v1/sandboxes/define" method = "POST" target = "_blank" >
230+ < input type = "hidden" name = "parameters" value = { getPayload ( codeSource , sourceFiles ) } />
231+ < Tooltip title = "Edit in codesandbox" >
232+ < IconButton
233+ disableFocusRipple
234+ type = "submit"
235+ sx = { { pointerEvents : 'auto' } }
236+ onClick = { ( event ) => event . stopPropagation ( ) }
237+ size = "small"
238+ >
239+ < CodesandboxIcon />
240+ </ IconButton >
241+ </ Tooltip >
242+ </ form >
243+ < Link
244+ href = { `https://github.com/data-driven-forms/react-forms/tree/master/packages/react-renderer-demo/src/examples/${ source } .js` }
245+ target = "_blank"
246+ rel = "noopener noreferrer"
247+ onClick = { ( event ) => event . stopPropagation ( ) }
248+ >
249+ < Tooltip title = "View source on github" >
250+ < IconButton sx = { { pointerEvents : 'auto' } } size = "small" >
251+ < GhIcon style = { { color : grey [ 700 ] } } />
252+ </ IconButton >
253+ </ Tooltip >
254+ </ Link >
255+ </ Box >
256+ </ AccordionSummary >
257+ < AccordionDetails className = { clsx ( 'accordionDetail' , 'codeWrapper' ) } >
258+ < CodeEditor value = { codeSource } inExample />
259+ </ AccordionDetails >
260+ </ Accordion >
221261 </ Grid >
222- ) }
223- < Grid item xs = { 12 } >
224- < Accordion className = { 'accordion' } >
225- < AccordionSummary className = { 'accordionSummary' } >
226- < Box display = "flex" >
227- < form action = "https://codesandbox.io/api/v1/sandboxes/define" method = "POST" target = "_blank" >
228- < input type = "hidden" name = "parameters" value = { getPayload ( codeSource , sourceFiles ) } />
229- < Tooltip title = "Edit in codesandbox" >
230- < IconButton
231- disableFocusRipple
232- type = "submit"
233- sx = { { pointerEvents : 'auto' } }
234- onClick = { ( event ) => event . stopPropagation ( ) }
235- size = "small"
236- >
237- < CodesandboxIcon />
238- </ IconButton >
239- </ Tooltip >
240- </ form >
241- < Link
242- href = { `https://github.com/data-driven-forms/react-forms/tree/master/packages/react-renderer-demo/src/examples/${ source } .js` }
243- target = "_blank"
244- rel = "noopener noreferrer"
245- onClick = { ( event ) => event . stopPropagation ( ) }
246- >
247- < Tooltip title = "View source on github" >
248- < IconButton sx = { { pointerEvents : 'auto' } } size = "small" >
249- < GhIcon style = { { color : grey [ 700 ] } } />
250- </ IconButton >
251- </ Tooltip >
252- </ Link >
253- </ Box >
254- </ AccordionSummary >
255- < AccordionDetails className = { clsx ( 'accordionDetail' , 'codeWrapper' ) } >
256- < CodeEditor value = { codeSource } inExample />
257- </ AccordionDetails >
258- </ Accordion >
259- </ Grid >
260- </ ExampleRoot >
262+ </ ExampleRoot >
263+ </ ErrorBoundary >
261264 ) ;
262265 }
263266
264267 return (
265- < ExampleRoot container spacing = { 0 } className = "DocRawComponent" >
266- < Grid item xs = { 12 } >
267- < Box display = "flex" justifyContent = "flex-end" >
268- < Link
269- href = { `https://github.com/data-driven-forms/react-forms/tree/master/packages/react-renderer-demo/src/app/examples/${ source } .js` }
270- target = "_blank"
271- rel = "noopener noreferrer"
272- variant = "subtitle1"
273- >
274- View source on github
275- </ Link >
276- </ Box >
277- </ Grid >
278- < Grid item xs = { 12 } className = { 'codeWrapper' } >
279- < CodeEditor value = { codeSource } />
280- </ Grid >
281- </ ExampleRoot >
268+ < ErrorBoundary >
269+ < ExampleRoot container spacing = { 0 } className = "DocRawComponent" >
270+ < Grid item xs = { 12 } >
271+ < Box display = "flex" justifyContent = "flex-end" >
272+ < Link
273+ href = { `https://github.com/data-driven-forms/react-forms/tree/master/packages/react-renderer-demo/src/app/examples/${ source } .js` }
274+ target = "_blank"
275+ rel = "noopener noreferrer"
276+ variant = "subtitle1"
277+ >
278+ View source on github
279+ </ Link >
280+ </ Box >
281+ </ Grid >
282+ < Grid item xs = { 12 } className = { 'codeWrapper' } >
283+ < CodeEditor value = { codeSource } />
284+ </ Grid >
285+ </ ExampleRoot >
286+ </ ErrorBoundary >
282287 ) ;
283288} ;
284289
0 commit comments