Commit ce5b5da 1 parent 55a8d2f commit ce5b5da Copy full SHA for ce5b5da
File tree 4 files changed +45
-204
lines changed
sandboxes/react/dockview/demo-dockview/src
4 files changed +45
-204
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ const components = {
28
28
position : 'relative' ,
29
29
} }
30
30
>
31
- < Table data = { metadata } />
31
+ { /* <Table data={metadata} /> */ }
32
32
< span
33
33
style = { {
34
34
position : 'absolute' ,
Original file line number Diff line number Diff line change @@ -43,25 +43,31 @@ type DocsJson = {
43
43
44
44
const newJson = docsJson_ as ExportedTypeFile ;
45
45
46
- console . log ( newJson ) ;
47
-
48
46
export const DocumentRef = ( props : { value : TypeSystem . Type } ) => {
49
- if ( ! props . value ) {
47
+ const code = React . useMemo ( ( ) => {
48
+ if ( ! props . value ) {
49
+ return null ;
50
+ }
51
+
52
+ switch ( props . value . kind ) {
53
+ case 'typeAlias' :
54
+ return codify ( props . value ) ;
55
+ case 'interface' :
56
+ return codify ( props . value ) ;
57
+ case 'class' :
58
+ return codify ( props . value ) ;
59
+ case 'function' :
60
+ return codify ( props . value ) ;
61
+ default :
62
+ return null ;
63
+ }
64
+ } , [ props . value ] ) ;
65
+
66
+ if ( ! code ) {
50
67
return null ;
51
68
}
52
69
53
- switch ( props . value . kind ) {
54
- case 'typealias' :
55
- return codify ( props . value ) ;
56
- case 'interface' :
57
- return codify ( props . value ) ;
58
- case 'class' :
59
- return codify ( props . value ) ;
60
- case 'function' :
61
- return codify ( props . value ) ;
62
- default :
63
- return < div > { 'error' } </ div > ;
64
- }
70
+ return < CodeBlock language = "tsx" > { code } </ CodeBlock > ;
65
71
} ;
66
72
67
73
export const Text = ( props : { content : DocsContent [ ] } ) => {
@@ -211,13 +217,13 @@ export const DocRef = (props: DocRefProps) => {
211
217
return (
212
218
< >
213
219
< Row key = { i } doc = { doc } />
214
- < div >
220
+ { /* <div>
215
221
{firstLevel(doc).map((x) => (
216
222
<span style={{ padding: '0px 2px' }}>
217
223
<DocumentRef value={newJson[x]} />
218
224
</span>
219
225
))}
220
- </ div >
226
+ </div> */ }
221
227
{ /* {doc.pieces?.map((piece) => (
222
228
<tr>
223
229
<th colSpan={2}>
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ export function codify(value: TypeSystem.Type | null) {
216
216
217
217
if ( value . kind === 'typeLiteral' ) {
218
218
if ( value . properties ) {
219
- return `{ ${ value . properties . map ( codify ) . join ( ', ' ) } }` ;
219
+ return `{\n ${ value . properties . map ( codify ) . join ( ',\n ' ) } \n }` ;
220
220
}
221
221
if ( value . signatures ) {
222
222
return value . signatures . map ( codify ) . join ( '\n' ) ;
@@ -228,15 +228,19 @@ export function codify(value: TypeSystem.Type | null) {
228
228
}
229
229
230
230
if ( value . kind === 'interface' ) {
231
- return `interface ${ value . name } { ${ value . children
231
+ return `interface ${ value . name } {\n ${ value . children
232
232
. map ( codify )
233
- . join ( ',' ) } }`;
233
+ . join ( ',\n ' ) } \n }`;
234
234
}
235
235
236
236
if ( value . kind === 'class' ) {
237
- return `interface ${ value . name } { ${ value . children
237
+ return `interface ${ value . name } {\n ${ value . children
238
238
. map ( codify )
239
- . join ( ',' ) } }`;
239
+ . join ( ',\n' ) } \n}`;
240
+ }
241
+
242
+ if ( value . kind === 'typeAlias' ) {
243
+ return `type ${ value . name } = ${ codifyType ( value . type ) } ` ;
240
244
}
241
245
242
246
console . log ( 'unreachable' , value ) ;
@@ -300,7 +304,7 @@ export namespace TypeSystem {
300
304
301
305
export type TypeAlias = {
302
306
name : string ;
303
- kind : 'typealias ' ;
307
+ kind : 'typeAlias ' ;
304
308
typeParameters : TypeSystem . TypeParameter [ ] ;
305
309
type : TypeDescriptor . Type ;
306
310
comment ?: Comment ;
You can’t perform that action at this time.
0 commit comments