polen 0.11.0-next.25 → 0.11.0-next.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api/config/input.d.ts +183 -0
- package/build/api/config/input.d.ts.map +1 -1
- package/build/api/config/input.js +2 -0
- package/build/api/config/input.js.map +1 -1
- package/build/api/config/normalized.d.ts +297 -0
- package/build/api/config/normalized.d.ts.map +1 -1
- package/build/api/config/normalized.js +47 -0
- package/build/api/config/normalized.js.map +1 -1
- package/build/api/config-template/template.d.ts +81 -0
- package/build/api/config-template/template.d.ts.map +1 -1
- package/build/api/config-template/template.js +18 -1
- package/build/api/config-template/template.js.map +1 -1
- package/build/api/examples/scanner.d.ts.map +1 -1
- package/build/api/examples/scanner.js +11 -0
- package/build/api/examples/scanner.js.map +1 -1
- package/build/api/examples/schemas/catalog.d.ts +36 -0
- package/build/api/examples/schemas/catalog.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.d.ts +37 -0
- package/build/api/examples/schemas/example/example.d.ts.map +1 -1
- package/build/api/examples/schemas/example/example.js +5 -0
- package/build/api/examples/schemas/example/example.js.map +1 -1
- package/build/api/reference/$.d.ts +4 -0
- package/build/api/reference/$.d.ts.map +1 -0
- package/build/api/reference/$.js +4 -0
- package/build/api/reference/$.js.map +1 -0
- package/build/api/reference/catalog.d.ts +69 -0
- package/build/api/reference/catalog.d.ts.map +1 -0
- package/build/api/reference/catalog.js +44 -0
- package/build/api/reference/catalog.js.map +1 -0
- package/build/api/reference/config.d.ts +616 -0
- package/build/api/reference/config.d.ts.map +1 -0
- package/build/api/reference/config.js +162 -0
- package/build/api/reference/config.js.map +1 -0
- package/build/api/reference/scanner.d.ts +26 -0
- package/build/api/reference/scanner.d.ts.map +1 -0
- package/build/api/reference/scanner.js +27 -0
- package/build/api/reference/scanner.js.map +1 -0
- package/build/lib/grafaid/schema/format-default-value.d.ts +11 -0
- package/build/lib/grafaid/schema/format-default-value.d.ts.map +1 -0
- package/build/lib/grafaid/schema/format-default-value.js +20 -0
- package/build/lib/grafaid/schema/format-default-value.js.map +1 -0
- package/build/lib/grafaid/schema/schema.d.ts +1 -0
- package/build/lib/grafaid/schema/schema.d.ts.map +1 -1
- package/build/lib/grafaid/schema/schema.js +1 -0
- package/build/lib/grafaid/schema/schema.js.map +1 -1
- package/build/template/components/ArgumentAnnotation.d.ts +2 -1
- package/build/template/components/ArgumentAnnotation.d.ts.map +1 -1
- package/build/template/components/ArgumentAnnotation.js +14 -4
- package/build/template/components/ArgumentAnnotation.js.map +1 -1
- package/build/template/components/ArgumentListAnnotation.d.ts +1 -0
- package/build/template/components/ArgumentListAnnotation.d.ts.map +1 -1
- package/build/template/components/ArgumentListAnnotation.js +21 -8
- package/build/template/components/ArgumentListAnnotation.js.map +1 -1
- package/build/template/components/Changelog/groups/FieldArgument.d.ts.map +1 -1
- package/build/template/components/Changelog/groups/FieldArgument.js +0 -1
- package/build/template/components/Changelog/groups/FieldArgument.js.map +1 -1
- package/build/template/components/CodeBlock.d.ts.map +1 -1
- package/build/template/components/CodeBlock.js +1 -1
- package/build/template/components/CodeBlock.js.map +1 -1
- package/build/template/components/Description.js +1 -1
- package/build/template/components/Description.js.map +1 -1
- package/build/template/components/ExampleLink.d.ts.map +1 -1
- package/build/template/components/ExampleLink.js +2 -1
- package/build/template/components/ExampleLink.js.map +1 -1
- package/build/template/components/Field.d.ts +2 -0
- package/build/template/components/Field.d.ts.map +1 -1
- package/build/template/components/Field.js +42 -4
- package/build/template/components/Field.js.map +1 -1
- package/build/template/components/FieldList.d.ts +2 -1
- package/build/template/components/FieldList.d.ts.map +1 -1
- package/build/template/components/FieldList.js +14 -3
- package/build/template/components/FieldList.js.map +1 -1
- package/build/template/components/FieldListSection.d.ts.map +1 -1
- package/build/template/components/FieldListSection.js +6 -1
- package/build/template/components/FieldListSection.js.map +1 -1
- package/build/template/components/GraphQLDocument.d.ts.map +1 -1
- package/build/template/components/GraphQLDocument.js +2 -1
- package/build/template/components/GraphQLDocument.js.map +1 -1
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts +2 -0
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js +4 -3
- package/build/template/components/GraphQLInteractive/GraphQLInteractive.js.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts +2 -2
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.js +17 -12
- package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -1
- package/build/template/components/IAPIndicator.d.ts +12 -0
- package/build/template/components/IAPIndicator.d.ts.map +1 -0
- package/build/template/components/IAPIndicator.js +21 -0
- package/build/template/components/IAPIndicator.js.map +1 -0
- package/build/template/components/Link.d.ts +1 -2
- package/build/template/components/Link.d.ts.map +1 -1
- package/build/template/components/Link.js +5 -2
- package/build/template/components/Link.js.map +1 -1
- package/build/template/components/NamedType.d.ts.map +1 -1
- package/build/template/components/NamedType.js +9 -5
- package/build/template/components/NamedType.js.map +1 -1
- package/build/template/components/ReferenceLink.d.ts +3 -2
- package/build/template/components/ReferenceLink.d.ts.map +1 -1
- package/build/template/components/ReferenceLink.js +5 -3
- package/build/template/components/ReferenceLink.js.map +1 -1
- package/build/template/components/TypeAnnotation.d.ts +2 -0
- package/build/template/components/TypeAnnotation.d.ts.map +1 -1
- package/build/template/components/TypeAnnotation.js +4 -4
- package/build/template/components/TypeAnnotation.js.map +1 -1
- package/build/template/components/ViewModeToggle.d.ts +3 -0
- package/build/template/components/ViewModeToggle.d.ts.map +1 -0
- package/build/template/components/ViewModeToggle.js +9 -0
- package/build/template/components/ViewModeToggle.js.map +1 -0
- package/build/template/components/graphql/type-link.d.ts +2 -0
- package/build/template/components/graphql/type-link.d.ts.map +1 -1
- package/build/template/components/graphql/type-link.js +17 -4
- package/build/template/components/graphql/type-link.js.map +1 -1
- package/build/template/components/home/PlaygroundPreview.d.ts.map +1 -1
- package/build/template/components/home/PlaygroundPreview.js +3 -2
- package/build/template/components/home/PlaygroundPreview.js.map +1 -1
- package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
- package/build/template/components/sidebar/SidebarItem.js +18 -5
- package/build/template/components/sidebar/SidebarItem.js.map +1 -1
- package/build/template/contexts/ReferenceConfigContext.d.ts +16 -0
- package/build/template/contexts/ReferenceConfigContext.d.ts.map +1 -0
- package/build/template/contexts/ReferenceConfigContext.js +14 -0
- package/build/template/contexts/ReferenceConfigContext.js.map +1 -0
- package/build/template/contexts/ViewModeContext.d.ts +14 -0
- package/build/template/contexts/ViewModeContext.d.ts.map +1 -0
- package/build/template/contexts/ViewModeContext.js +40 -0
- package/build/template/contexts/ViewModeContext.js.map +1 -0
- package/build/template/hooks/use-examples.d.ts +3 -0
- package/build/template/hooks/use-examples.d.ts.map +1 -1
- package/build/template/hooks/useAlignedColumns.d.ts +10 -0
- package/build/template/hooks/useAlignedColumns.d.ts.map +1 -0
- package/build/template/hooks/useAlignedColumns.js +17 -0
- package/build/template/hooks/useAlignedColumns.js.map +1 -0
- package/build/template/routes/examples/_.d.ts +9 -0
- package/build/template/routes/examples/_.d.ts.map +1 -1
- package/build/template/routes/examples/_index.d.ts +6 -0
- package/build/template/routes/examples/_index.d.ts.map +1 -1
- package/build/template/routes/examples/name.d.ts +9 -0
- package/build/template/routes/examples/name.d.ts.map +1 -1
- package/build/template/routes/examples/name.js +6 -2
- package/build/template/routes/examples/name.js.map +1 -1
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +37 -10
- package/build/template/routes/reference.js.map +1 -1
- package/build/vite/plugins/core.d.ts.map +1 -1
- package/build/vite/plugins/core.js +6 -0
- package/build/vite/plugins/core.js.map +1 -1
- package/build/vite/plugins/examples.d.ts.map +1 -1
- package/build/vite/plugins/examples.js +10 -1
- package/build/vite/plugins/examples.js.map +1 -1
- package/build/vite/plugins/index.d.ts +1 -0
- package/build/vite/plugins/index.d.ts.map +1 -1
- package/build/vite/plugins/index.js +1 -0
- package/build/vite/plugins/index.js.map +1 -1
- package/build/vite/plugins/navbar.d.ts.map +1 -1
- package/build/vite/plugins/navbar.js +3 -1
- package/build/vite/plugins/navbar.js.map +1 -1
- package/build/vite/plugins/reference.d.ts +19 -0
- package/build/vite/plugins/reference.d.ts.map +1 -0
- package/build/vite/plugins/reference.js +96 -0
- package/build/vite/plugins/reference.js.map +1 -0
- package/package.json +1 -7
- package/src/api/config/input.ts +2 -0
- package/src/api/config/normalized.ts +54 -0
- package/src/api/config-template/template.ts +18 -1
- package/src/api/examples/scanner.ts +14 -0
- package/src/api/examples/schemas/example/example.ts +6 -0
- package/src/api/reference/$.ts +3 -0
- package/src/api/reference/catalog.ts +55 -0
- package/src/api/reference/config.ts +193 -0
- package/src/api/reference/scanner.ts +53 -0
- package/src/lib/grafaid/schema/format-default-value.ts +22 -0
- package/src/lib/grafaid/schema/schema.ts +2 -0
- package/src/template/components/ArgumentAnnotation.tsx +58 -9
- package/src/template/components/ArgumentListAnnotation.tsx +50 -17
- package/src/template/components/Changelog/groups/FieldArgument.tsx +0 -1
- package/src/template/components/CodeBlock.tsx +1 -0
- package/src/template/components/Description.tsx +1 -1
- package/src/template/components/ExampleLink.tsx +2 -1
- package/src/template/components/Field.tsx +148 -20
- package/src/template/components/FieldList.tsx +28 -13
- package/src/template/components/FieldListSection.tsx +12 -2
- package/src/template/components/GraphQLDocument.tsx +2 -0
- package/src/template/components/GraphQLInteractive/GraphQLInteractive.tsx +6 -1
- package/src/template/components/GraphQLInteractive/lib/parser.ts +16 -3
- package/src/template/components/IAPIndicator.tsx +73 -0
- package/src/template/components/Link.tsx +9 -3
- package/src/template/components/NamedType.tsx +54 -28
- package/src/template/components/ReferenceLink.tsx +17 -10
- package/src/template/components/TypeAnnotation.tsx +17 -5
- package/src/template/components/ViewModeToggle.tsx +27 -0
- package/src/template/components/graphql/type-link.tsx +52 -9
- package/src/template/components/home/PlaygroundPreview.tsx +3 -0
- package/src/template/components/sidebar/SidebarItem.tsx +21 -5
- package/src/template/contexts/ReferenceConfigContext.tsx +37 -0
- package/src/template/contexts/ViewModeContext.tsx +64 -0
- package/src/template/hooks/useAlignedColumns.ts +19 -0
- package/src/template/routes/examples/name.tsx +13 -1
- package/src/template/routes/reference.tsx +67 -23
- package/src/types/virtual-modules.d.ts +5 -0
- package/src/vite/plugins/core.ts +6 -0
- package/src/vite/plugins/examples.ts +12 -0
- package/src/vite/plugins/index.ts +1 -0
- package/src/vite/plugins/navbar.ts +4 -1
- package/src/vite/plugins/reference.ts +130 -0
- package/build/lib/extensible-data/$.d.ts +0 -2
- package/build/lib/extensible-data/$.d.ts.map +0 -1
- package/build/lib/extensible-data/$.js +0 -2
- package/build/lib/extensible-data/$.js.map +0 -1
- package/build/lib/extensible-data/extensible-data.d.ts +0 -17
- package/build/lib/extensible-data/extensible-data.d.ts.map +0 -1
- package/build/lib/extensible-data/extensible-data.js +0 -24
- package/build/lib/extensible-data/extensible-data.js.map +0 -1
- package/build/lib/vite-plugin-reactive-data/$.d.ts +0 -2
- package/build/lib/vite-plugin-reactive-data/$.d.ts.map +0 -1
- package/build/lib/vite-plugin-reactive-data/$.js +0 -2
- package/build/lib/vite-plugin-reactive-data/$.js.map +0 -1
- package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.d.ts +0 -32
- package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.d.ts.map +0 -1
- package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.js +0 -85
- package/build/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.js.map +0 -1
- package/build/template/components/ArgumentList.d.ts +0 -6
- package/build/template/components/ArgumentList.d.ts.map +0 -1
- package/build/template/components/ArgumentList.js +0 -9
- package/build/template/components/ArgumentList.js.map +0 -1
- package/src/lib/extensible-data/$.ts +0 -1
- package/src/lib/extensible-data/extensible-data.ts +0 -38
- package/src/lib/vite-plugin-reactive-data/$.ts +0 -1
- package/src/lib/vite-plugin-reactive-data/vite-plugin-reactive-data.ts +0 -124
- package/src/template/components/ArgumentList.tsx +0 -22
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import { forwardRef } from 'react'
|
2
2
|
import type { LinkProps as LinkPropsReactRouter } from 'react-router'
|
3
3
|
import { Link as LinkReactRouter, useLocation } from 'react-router'
|
4
4
|
// todo: #lib/kit-temp does not work as import
|
@@ -20,7 +20,10 @@ const reactRouterPropKeys = [
|
|
20
20
|
`children`,
|
21
21
|
] as const
|
22
22
|
|
23
|
-
export const Link
|
23
|
+
export const Link = forwardRef<
|
24
|
+
HTMLAnchorElement,
|
25
|
+
LinkPropsReactRouter & Omit<LinkPropsRadix, `asChild`>
|
26
|
+
>((props, ref) => {
|
24
27
|
const location = useLocation()
|
25
28
|
const toPathExp = typeof props.to === `string` ? props.to : props.to.pathname || ``
|
26
29
|
|
@@ -34,6 +37,7 @@ export const Link: FC<LinkPropsReactRouter & Omit<LinkPropsRadix, `asChild`>> =
|
|
34
37
|
// Only add data attributes if they're true
|
35
38
|
const linkRadixProps = {
|
36
39
|
...radixProps,
|
40
|
+
ref,
|
37
41
|
asChild: true,
|
38
42
|
...(active.is && { 'data-active': true }),
|
39
43
|
...(active.isDirect && { 'data-active-direct': true }),
|
@@ -45,7 +49,9 @@ export const Link: FC<LinkPropsReactRouter & Omit<LinkPropsRadix, `asChild`>> =
|
|
45
49
|
<LinkReactRouter {...reactRouterProps} />
|
46
50
|
</LinkRadix>
|
47
51
|
)
|
48
|
-
}
|
52
|
+
})
|
53
|
+
|
54
|
+
Link.displayName = 'Link'
|
49
55
|
|
50
56
|
export interface PathActiveReport {
|
51
57
|
is: boolean
|
@@ -2,11 +2,12 @@ import { Api } from '#api/iso'
|
|
2
2
|
import { Lifecycles } from '#lib/lifecycles/$'
|
3
3
|
import { Schema } from '#lib/schema/$'
|
4
4
|
import { Version } from '#lib/version/$'
|
5
|
-
import { Badge, Box, Heading, Text } from '@radix-ui/themes'
|
5
|
+
import { Badge, Box, Card, Heading, Section, Separator, Text } from '@radix-ui/themes'
|
6
6
|
import { HashSet } from 'effect'
|
7
7
|
import { type GraphQLNamedType } from 'graphql'
|
8
8
|
import type { FC } from 'react'
|
9
9
|
import { useSchema } from '../contexts/GraphqlLifecycleContext.js'
|
10
|
+
import { useViewMode } from '../contexts/ViewModeContext.js'
|
10
11
|
import { useExamplesForType } from '../hooks/use-examples.js'
|
11
12
|
import { ExampleLink } from './ExampleLink.js'
|
12
13
|
import { FieldListSection } from './FieldListSection.js'
|
@@ -20,10 +21,11 @@ export interface Props {
|
|
20
21
|
|
21
22
|
export const NamedType: FC<Props> = ({ data }) => {
|
22
23
|
const { schema, lifecycles } = useSchema()
|
24
|
+
const { viewMode } = useViewMode()
|
23
25
|
|
24
|
-
const description = data.description
|
26
|
+
const description = data.description && viewMode === 'expanded'
|
25
27
|
? (
|
26
|
-
<Text as='div' color='gray'>
|
28
|
+
<Text as='div' size='2' color='gray'>
|
27
29
|
<Markdown>{data.description}</Markdown>
|
28
30
|
</Text>
|
29
31
|
)
|
@@ -33,6 +35,9 @@ export const NamedType: FC<Props> = ({ data }) => {
|
|
33
35
|
const since = Lifecycles.getTypeSince(lifecycles, data.name, schema)
|
34
36
|
const removedDate = Lifecycles.getTypeRemovedDate(lifecycles, data.name, schema)
|
35
37
|
|
38
|
+
// Only show since badge if it's NOT the initial version
|
39
|
+
const showSinceBadge = since && since._tag !== 'initial'
|
40
|
+
|
36
41
|
// Get examples that use this type
|
37
42
|
const currentVersion = Schema.Versioned.is(schema)
|
38
43
|
? schema.version
|
@@ -41,34 +46,55 @@ export const NamedType: FC<Props> = ({ data }) => {
|
|
41
46
|
|
42
47
|
return (
|
43
48
|
<Box>
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
<
|
51
|
-
|
52
|
-
|
49
|
+
{/* Type header section */}
|
50
|
+
<Section size='1'>
|
51
|
+
<Box style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
52
|
+
<Heading size='7' weight='bold'>
|
53
|
+
<TypeLink type={data} />
|
54
|
+
</Heading>
|
55
|
+
{showSinceBadge && <SinceBadge since={since} />}
|
56
|
+
{removedDate && (
|
57
|
+
<Badge color='red' variant='soft' size='1'>
|
58
|
+
Removed {Api.Schema.dateToVersionString(removedDate)}
|
59
|
+
</Badge>
|
60
|
+
)}
|
61
|
+
</Box>
|
62
|
+
|
63
|
+
{/* Description section */}
|
64
|
+
{description && (
|
65
|
+
<Box mt='3'>
|
66
|
+
{description}
|
67
|
+
</Box>
|
53
68
|
)}
|
54
|
-
</
|
55
|
-
|
69
|
+
</Section>
|
70
|
+
|
71
|
+
{/* Examples section with separator */}
|
56
72
|
{HashSet.size(examples) > 0 && (
|
57
|
-
|
58
|
-
<
|
59
|
-
<
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
73
|
+
<>
|
74
|
+
<Separator size='4' my='4' />
|
75
|
+
<Section size='1'>
|
76
|
+
<Heading size='5' mb='3' weight='medium'>Used in Examples</Heading>
|
77
|
+
<Card variant='surface'>
|
78
|
+
<Box style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
79
|
+
{[...examples].map((exampleRef) => (
|
80
|
+
<ExampleLink
|
81
|
+
key={`${exampleRef.name}-${
|
82
|
+
exampleRef.version ? Version.encodeSync(exampleRef.version) : 'unversioned'
|
83
|
+
}`}
|
84
|
+
exampleRef={exampleRef}
|
85
|
+
/>
|
86
|
+
))}
|
87
|
+
</Box>
|
88
|
+
</Card>
|
89
|
+
</Section>
|
90
|
+
</>
|
70
91
|
)}
|
71
|
-
|
92
|
+
|
93
|
+
{/* Fields section with separator */}
|
94
|
+
<Separator size='4' my='4' />
|
95
|
+
<Section size='1'>
|
96
|
+
<FieldListSection data={data} />
|
97
|
+
</Section>
|
72
98
|
</Box>
|
73
99
|
)
|
74
100
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Api } from '#api/iso'
|
2
2
|
import type { React } from '#dep/react/index'
|
3
|
+
import { forwardRef } from 'react'
|
3
4
|
import { useVersionPath } from '../hooks/useVersionPath.js'
|
4
5
|
import { Link } from './Link.js'
|
5
6
|
|
@@ -10,14 +11,18 @@ import { Link } from './Link.js'
|
|
10
11
|
* <ReferenceLink type="User">User</ReferenceLink>
|
11
12
|
* <ReferenceLink type="User" field="name">User.name</ReferenceLink>
|
12
13
|
*/
|
13
|
-
export const ReferenceLink
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
export const ReferenceLink = forwardRef<
|
15
|
+
HTMLAnchorElement,
|
16
|
+
{
|
17
|
+
className?: string
|
18
|
+
/** The GraphQL type name */
|
19
|
+
type: string
|
20
|
+
/** Optional field name for field-specific links */
|
21
|
+
field?: string
|
22
|
+
/** Link content */
|
23
|
+
children: React.ReactNode
|
24
|
+
}
|
25
|
+
>(({ type, field, children, ...props }, ref) => {
|
21
26
|
const versionPath = useVersionPath()
|
22
27
|
|
23
28
|
const path = Api.Schema.Routing.joinSegmentsAndPaths(
|
@@ -28,8 +33,10 @@ export const ReferenceLink: React.FC<{
|
|
28
33
|
)
|
29
34
|
|
30
35
|
return (
|
31
|
-
<Link to={path}>
|
36
|
+
<Link to={path} ref={ref} {...props}>
|
32
37
|
{children}
|
33
38
|
</Link>
|
34
39
|
)
|
35
|
-
}
|
40
|
+
})
|
41
|
+
|
42
|
+
ReferenceLink.displayName = 'ReferenceLink'
|
@@ -7,13 +7,21 @@ import { TypeLink } from './graphql/graphql.js'
|
|
7
7
|
/**
|
8
8
|
* Renders a GraphQL type recursively, with links for named types
|
9
9
|
*/
|
10
|
-
export const TypeAnnotation: React.FC<{
|
10
|
+
export const TypeAnnotation: React.FC<{
|
11
|
+
type: GraphQLType
|
12
|
+
showDescription?: boolean
|
13
|
+
nullabilityRendering?: 'questionMark' | 'bangMark'
|
14
|
+
}> = ({ type, showDescription = false, nullabilityRendering = 'bangMark' }) => {
|
11
15
|
// Handle NonNull type wrapper
|
12
16
|
if (isNonNullType(type)) {
|
13
17
|
return (
|
14
18
|
<>
|
15
|
-
<TypeAnnotation
|
16
|
-
|
19
|
+
<TypeAnnotation
|
20
|
+
type={type.ofType}
|
21
|
+
showDescription={showDescription}
|
22
|
+
nullabilityRendering={nullabilityRendering}
|
23
|
+
/>
|
24
|
+
{nullabilityRendering === 'bangMark' && <Text color='gray'>!</Text>}
|
17
25
|
</>
|
18
26
|
)
|
19
27
|
}
|
@@ -23,7 +31,11 @@ export const TypeAnnotation: React.FC<{ type: GraphQLType }> = ({ type }) => {
|
|
23
31
|
return (
|
24
32
|
<>
|
25
33
|
<Text color='gray'>[</Text>
|
26
|
-
<TypeAnnotation
|
34
|
+
<TypeAnnotation
|
35
|
+
type={type.ofType}
|
36
|
+
showDescription={showDescription}
|
37
|
+
nullabilityRendering={nullabilityRendering}
|
38
|
+
/>
|
27
39
|
<Text color='gray'>]</Text>
|
28
40
|
</>
|
29
41
|
)
|
@@ -31,7 +43,7 @@ export const TypeAnnotation: React.FC<{ type: GraphQLType }> = ({ type }) => {
|
|
31
43
|
|
32
44
|
// Handle named types - use TypeLink which already has icon support
|
33
45
|
if (isNamedType(type)) {
|
34
|
-
return <TypeLink type={type} />
|
46
|
+
return <TypeLink type={type} showDescription={showDescription} />
|
35
47
|
}
|
36
48
|
|
37
49
|
// TypeScript exhaustiveness check - this should be unreachable
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { React } from '#dep/react/index'
|
2
|
+
import { ReaderIcon, RowsIcon } from '@radix-ui/react-icons'
|
3
|
+
import { Flex, SegmentedControl } from '@radix-ui/themes'
|
4
|
+
import { useViewMode } from '../contexts/ViewModeContext.js'
|
5
|
+
|
6
|
+
export const ViewModeToggle: React.FC = () => {
|
7
|
+
const { viewMode, setViewMode } = useViewMode()
|
8
|
+
|
9
|
+
return (
|
10
|
+
<SegmentedControl.Root
|
11
|
+
value={viewMode}
|
12
|
+
onValueChange={(value) => setViewMode(value as 'compact' | 'expanded')}
|
13
|
+
size='1'
|
14
|
+
>
|
15
|
+
<SegmentedControl.Item value='expanded'>
|
16
|
+
<Flex align='center' gap='2'>
|
17
|
+
<ReaderIcon />
|
18
|
+
</Flex>
|
19
|
+
</SegmentedControl.Item>
|
20
|
+
<SegmentedControl.Item value='compact'>
|
21
|
+
<Flex align='center' gap='2'>
|
22
|
+
<RowsIcon />
|
23
|
+
</Flex>
|
24
|
+
</SegmentedControl.Item>
|
25
|
+
</SegmentedControl.Root>
|
26
|
+
)
|
27
|
+
}
|
@@ -1,19 +1,62 @@
|
|
1
1
|
import { Grafaid } from '#lib/grafaid'
|
2
|
-
import { Code, Flex } from '@radix-ui/themes'
|
2
|
+
import { Code, Flex, HoverCard, Text } from '@radix-ui/themes'
|
3
|
+
import React from 'react'
|
4
|
+
import { Description } from '../Description.js'
|
3
5
|
import { ReferenceLink } from '../ReferenceLink.js'
|
4
6
|
import { TypeKindIcon } from './graphql.js'
|
5
7
|
import { typeKindTokensIndex } from './type-kind-tokens.js'
|
6
8
|
|
7
|
-
export const TypeLink: React.FC<{
|
9
|
+
export const TypeLink: React.FC<{
|
10
|
+
type: Grafaid.Schema.TypesLike.Named
|
11
|
+
showDescription?: boolean
|
12
|
+
}> = ({ type, showDescription = false }) => {
|
8
13
|
const kind = Grafaid.Schema.typeKindFromClass(type)
|
14
|
+
const hasDescription = type.description && type.description.trim() !== ''
|
15
|
+
|
16
|
+
const linkContent = (
|
17
|
+
<>
|
18
|
+
<style>
|
19
|
+
{`
|
20
|
+
.type-link-content:hover code:not(:first-child) {
|
21
|
+
text-decoration: underline;
|
22
|
+
text-underline-offset: 2px;
|
23
|
+
}
|
24
|
+
`}
|
25
|
+
</style>
|
26
|
+
<ReferenceLink type={type.name} className='type-link-content'>
|
27
|
+
<Flex
|
28
|
+
align='center'
|
29
|
+
gap='1'
|
30
|
+
display='inline-flex'
|
31
|
+
>
|
32
|
+
<TypeKindIcon kind={kind} />
|
33
|
+
{` `}
|
34
|
+
<Code color={typeKindTokensIndex[kind].color} variant='ghost'>{type.name}</Code>
|
35
|
+
</Flex>
|
36
|
+
</ReferenceLink>
|
37
|
+
</>
|
38
|
+
)
|
39
|
+
|
40
|
+
// Only show HoverCard if showDescription is true AND description exists
|
41
|
+
if (!showDescription || !hasDescription) {
|
42
|
+
return linkContent
|
43
|
+
}
|
9
44
|
|
10
45
|
return (
|
11
|
-
<
|
12
|
-
<
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
46
|
+
<HoverCard.Root>
|
47
|
+
<HoverCard.Trigger>
|
48
|
+
{linkContent}
|
49
|
+
</HoverCard.Trigger>
|
50
|
+
<HoverCard.Content
|
51
|
+
size='2'
|
52
|
+
maxWidth='400px'
|
53
|
+
side='top'
|
54
|
+
align='center'
|
55
|
+
>
|
56
|
+
<Text size='2' color='gray'>
|
57
|
+
<Description data={type} />
|
58
|
+
</Text>
|
59
|
+
</HoverCard.Content>
|
60
|
+
</HoverCard.Root>
|
18
61
|
)
|
19
62
|
}
|
@@ -3,6 +3,7 @@ import { highlight } from 'codehike/code'
|
|
3
3
|
import type { GraphQLSchema } from 'graphql'
|
4
4
|
import * as React from 'react'
|
5
5
|
import { Link } from 'react-router'
|
6
|
+
import { templateConfig } from 'virtual:polen/project/config'
|
6
7
|
import { GraphQLInteractive } from '../GraphQLInteractive/GraphQLInteractive.js'
|
7
8
|
|
8
9
|
interface PlaygroundPreviewProps {
|
@@ -68,12 +69,14 @@ export const PlaygroundPreviewSection: React.FC<PlaygroundPreviewProps> = ({
|
|
68
69
|
codeblock={highlightedCode}
|
69
70
|
schema={schema}
|
70
71
|
showWarningIfNoSchema={false}
|
72
|
+
referenceEnabled={templateConfig.reference.enabled}
|
71
73
|
/>
|
72
74
|
)
|
73
75
|
: (
|
74
76
|
<GraphQLInteractive
|
75
77
|
codeblock={highlightedCode}
|
76
78
|
showWarningIfNoSchema={false}
|
79
|
+
referenceEnabled={templateConfig.reference.enabled}
|
77
80
|
/>
|
78
81
|
)}
|
79
82
|
</Box>
|
@@ -3,6 +3,7 @@ import { Api } from '#api/iso'
|
|
3
3
|
import type { React } from '#dep/react/index'
|
4
4
|
import { Texts } from '#template/components/Texts/index'
|
5
5
|
import { Box, Flex } from '@radix-ui/themes'
|
6
|
+
import { Str } from '@wollybeard/kit'
|
6
7
|
import { useContext } from 'react'
|
7
8
|
import { useLocation } from 'react-router'
|
8
9
|
import { getPathActiveReport, Link } from '../Link.js'
|
@@ -70,6 +71,11 @@ const SBLink: React.FC<{
|
|
70
71
|
const href = Api.Schema.Routing.joinSegmentsAndPaths(basePath, link.pathExp)
|
71
72
|
const active = getPathActiveReport(href, currentPathExp)
|
72
73
|
|
74
|
+
// Apply title case transformation to string titles for better readability
|
75
|
+
const displayTitle = typeof link.title === 'string'
|
76
|
+
? Str.Case.title(link.title)
|
77
|
+
: link.title
|
78
|
+
|
73
79
|
return (
|
74
80
|
<Link
|
75
81
|
role='Sidebar Link'
|
@@ -80,11 +86,11 @@ const SBLink: React.FC<{
|
|
80
86
|
display: `block`,
|
81
87
|
textDecoration: `none`,
|
82
88
|
color: active.is ? `var(--accent-12)` : undefined,
|
83
|
-
backgroundColor: active.isDirect ? `var(--accent-
|
89
|
+
backgroundColor: active.isDirect ? `var(--accent-3)` : active.isDescendant ? `var(--gray-2)` : `transparent`,
|
84
90
|
borderRadius: `var(--radius-2)`,
|
85
91
|
}}
|
86
92
|
>
|
87
|
-
<Box py='2' px='4'>{
|
93
|
+
<Box py='2' px='4'>{displayTitle}</Box>
|
88
94
|
</Link>
|
89
95
|
)
|
90
96
|
}
|
@@ -100,11 +106,16 @@ const SBLink: React.FC<{
|
|
100
106
|
const Section: React.FC<{
|
101
107
|
section: TemplateItemSection
|
102
108
|
}> = ({ section }) => {
|
109
|
+
// Apply title case transformation to string titles for better readability
|
110
|
+
const displayTitle = typeof section.title === 'string'
|
111
|
+
? Str.Case.title(section.title)
|
112
|
+
: section.title
|
113
|
+
|
103
114
|
return (
|
104
115
|
<Box mt='8'>
|
105
116
|
<Box ml='4' mb='2'>
|
106
117
|
<Texts.MinorHeading color='gray'>
|
107
|
-
{
|
118
|
+
{displayTitle}
|
108
119
|
</Texts.MinorHeading>
|
109
120
|
</Box>
|
110
121
|
<Items items={section.links} />
|
@@ -156,6 +167,11 @@ const SectionLink: React.FC<{ link: TemplateItemLink }> = ({ link }) => {
|
|
156
167
|
const href = Api.Schema.Routing.joinSegmentsAndPaths(basePath, link.pathExp)
|
157
168
|
const active = getPathActiveReport(href, location.pathname)
|
158
169
|
|
170
|
+
// Apply title case transformation to string titles for better readability
|
171
|
+
const displayTitle = typeof link.title === 'string'
|
172
|
+
? Str.Case.title(link.title)
|
173
|
+
: link.title
|
174
|
+
|
159
175
|
return (
|
160
176
|
<Link
|
161
177
|
role='Sidebar Link'
|
@@ -164,12 +180,12 @@ const SectionLink: React.FC<{ link: TemplateItemLink }> = ({ link }) => {
|
|
164
180
|
style={{
|
165
181
|
textDecoration: `none`,
|
166
182
|
color: active.is ? `var(--accent-12)` : undefined,
|
167
|
-
backgroundColor: active.isDirect ? `var(--accent-
|
183
|
+
backgroundColor: active.isDirect ? `var(--accent-3)` : active.isDescendant ? `var(--gray-2)` : `transparent`,
|
168
184
|
borderBottomRightRadius: `var(--radius-2)`,
|
169
185
|
borderTopRightRadius: `var(--radius-2)`,
|
170
186
|
}}
|
171
187
|
>
|
172
|
-
<Box py='2' px='4'>{
|
188
|
+
<Box py='2' px='4'>{displayTitle}</Box>
|
173
189
|
</Link>
|
174
190
|
)
|
175
191
|
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import type { React } from '#dep/react/index'
|
2
|
+
import { createContext, useContext } from 'react'
|
3
|
+
|
4
|
+
export interface ReferenceConfig {
|
5
|
+
descriptionsView: {
|
6
|
+
defaultMode: 'compact' | 'expanded'
|
7
|
+
showControl: boolean
|
8
|
+
}
|
9
|
+
nullabilityRendering: 'questionMark' | 'bangMark'
|
10
|
+
}
|
11
|
+
|
12
|
+
interface ReferenceConfigContextValue {
|
13
|
+
config: ReferenceConfig
|
14
|
+
}
|
15
|
+
|
16
|
+
const ReferenceConfigContext = createContext<ReferenceConfigContextValue | undefined>(undefined)
|
17
|
+
|
18
|
+
interface ReferenceConfigProviderProps {
|
19
|
+
children: React.ReactNode
|
20
|
+
config: ReferenceConfig
|
21
|
+
}
|
22
|
+
|
23
|
+
export const ReferenceConfigProvider: React.FC<ReferenceConfigProviderProps> = ({ children, config }) => {
|
24
|
+
return (
|
25
|
+
<ReferenceConfigContext.Provider value={{ config }}>
|
26
|
+
{children}
|
27
|
+
</ReferenceConfigContext.Provider>
|
28
|
+
)
|
29
|
+
}
|
30
|
+
|
31
|
+
export const useReferenceConfig = () => {
|
32
|
+
const context = useContext(ReferenceConfigContext)
|
33
|
+
if (!context) {
|
34
|
+
throw new Error('useReferenceConfig must be used within ReferenceConfigProvider')
|
35
|
+
}
|
36
|
+
return context.config
|
37
|
+
}
|
@@ -0,0 +1,64 @@
|
|
1
|
+
import type { React } from '#dep/react/index'
|
2
|
+
import { createContext, useContext, useEffect, useState } from 'react'
|
3
|
+
|
4
|
+
export type ViewMode = 'compact' | 'expanded'
|
5
|
+
|
6
|
+
interface ViewModeContextValue {
|
7
|
+
viewMode: ViewMode
|
8
|
+
setViewMode: (mode: ViewMode) => void
|
9
|
+
}
|
10
|
+
|
11
|
+
const ViewModeContext = createContext<ViewModeContextValue | undefined>(undefined)
|
12
|
+
|
13
|
+
const STORAGE_KEY = 'polen-view-mode'
|
14
|
+
|
15
|
+
interface ViewModeProviderProps {
|
16
|
+
children: React.ReactNode
|
17
|
+
defaultMode?: ViewMode
|
18
|
+
}
|
19
|
+
|
20
|
+
export const ViewModeProvider: React.FC<ViewModeProviderProps> = ({ children, defaultMode = 'expanded' }) => {
|
21
|
+
const [viewMode, setViewModeState] = useState<ViewMode>(defaultMode)
|
22
|
+
|
23
|
+
// Load from localStorage after mount to avoid hydration mismatch
|
24
|
+
useEffect(() => {
|
25
|
+
const saved = localStorage.getItem(STORAGE_KEY)
|
26
|
+
if (saved === 'compact' || saved === 'expanded') {
|
27
|
+
setViewModeState(saved)
|
28
|
+
}
|
29
|
+
}, [])
|
30
|
+
|
31
|
+
const setViewMode = (mode: ViewMode) => {
|
32
|
+
setViewModeState(mode)
|
33
|
+
// Save to localStorage
|
34
|
+
if (typeof window !== 'undefined') {
|
35
|
+
localStorage.setItem(STORAGE_KEY, mode)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
useEffect(() => {
|
40
|
+
// Sync with localStorage changes from other tabs
|
41
|
+
const handleStorageChange = (e: StorageEvent) => {
|
42
|
+
if (e.key === STORAGE_KEY && (e.newValue === 'compact' || e.newValue === 'expanded')) {
|
43
|
+
setViewModeState(e.newValue as ViewMode)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
window.addEventListener('storage', handleStorageChange)
|
48
|
+
return () => window.removeEventListener('storage', handleStorageChange)
|
49
|
+
}, [])
|
50
|
+
|
51
|
+
return (
|
52
|
+
<ViewModeContext.Provider value={{ viewMode, setViewMode }}>
|
53
|
+
{children}
|
54
|
+
</ViewModeContext.Provider>
|
55
|
+
)
|
56
|
+
}
|
57
|
+
|
58
|
+
export const useViewMode = () => {
|
59
|
+
const context = useContext(ViewModeContext)
|
60
|
+
if (!context) {
|
61
|
+
throw new Error('useViewMode must be used within ViewModeProvider')
|
62
|
+
}
|
63
|
+
return context
|
64
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { useMemo } from 'react'
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Generic hook for calculating the maximum character width of names in a list.
|
5
|
+
* Used to align columns in lists like fields, arguments, etc.
|
6
|
+
*
|
7
|
+
* @param items - Array of items to measure
|
8
|
+
* @param getName - Function to extract the name from each item
|
9
|
+
* @returns Maximum character width across all names
|
10
|
+
*/
|
11
|
+
export const useAlignedColumns = <T>(
|
12
|
+
items: T[],
|
13
|
+
getName: (item: T) => string,
|
14
|
+
): number => {
|
15
|
+
return useMemo(() => {
|
16
|
+
if (items.length === 0) return 0
|
17
|
+
return Math.max(...items.map(item => getName(item).length))
|
18
|
+
}, [items])
|
19
|
+
}
|
@@ -1,14 +1,17 @@
|
|
1
1
|
import { Example } from '#api/examples/schemas/example/example'
|
2
|
+
import { Catalog } from '#lib/catalog/$'
|
2
3
|
import { route } from '#lib/react-router-effect/route'
|
3
4
|
import { useLoaderData } from '#lib/react-router-effect/use-loader-data'
|
4
5
|
import { Version } from '#lib/version/$'
|
5
|
-
import { Heading } from '@radix-ui/themes'
|
6
|
+
import { Box, Heading } from '@radix-ui/themes'
|
6
7
|
import { Str } from '@wollybeard/kit'
|
7
8
|
import { Array, Option } from 'effect'
|
8
9
|
import { useSearchParams } from 'react-router'
|
10
|
+
import * as ExamplesModule from 'virtual:polen/project/examples'
|
9
11
|
import { examplesCatalog } from 'virtual:polen/project/examples'
|
10
12
|
import { schemasCatalog } from 'virtual:polen/project/schemas'
|
11
13
|
import { GraphQLDocument } from '../../components/GraphQLDocument.js'
|
14
|
+
import { MdxProvider } from '../../providers/mdx.js'
|
12
15
|
|
13
16
|
export const NameSchema = Example
|
14
17
|
|
@@ -47,9 +50,18 @@ const Component = () => {
|
|
47
50
|
? Version.decodeSync(versionParam)
|
48
51
|
: undefined
|
49
52
|
|
53
|
+
const DescriptionComponent = (ExamplesModule as any)[`DescriptionComponent_${example.name.replace(/-/g, '_')}`]
|
54
|
+
|
50
55
|
return (
|
51
56
|
<>
|
52
57
|
<Heading size='6' mb='4'>{Str.Case.title(example.name)}</Heading>
|
58
|
+
{DescriptionComponent && (
|
59
|
+
<Box mb='4'>
|
60
|
+
<MdxProvider schema={schemasCatalog && Catalog.getLatest(schemasCatalog).definition}>
|
61
|
+
<DescriptionComponent />
|
62
|
+
</MdxProvider>
|
63
|
+
</Box>
|
64
|
+
)}
|
53
65
|
<GraphQLDocument
|
54
66
|
document={example.document}
|
55
67
|
schemaCatalog={schemasCatalog ?? undefined}
|