diff --git a/src-web/components/GraphQLDocsExplorer.tsx b/src-web/components/GraphQLDocsExplorer.tsx index 92195fb5..4306e5f1 100644 --- a/src-web/components/GraphQLDocsExplorer.tsx +++ b/src-web/components/GraphQLDocsExplorer.tsx @@ -1,24 +1,36 @@ -/* eslint-disable */ -import { Color } from '@yaakapp-internal/plugins'; +/* eslint-disable @typescript-eslint/no-explicit-any */ +import type { Color } from '@yaakapp-internal/plugins'; import classNames from 'classnames'; -import type { GraphQLField, GraphQLInputField, GraphQLSchema, GraphQLType } from 'graphql'; +import { fuzzyMatch } from 'fuzzbunny'; +import type { + GraphQLField, + GraphQLInputField, + GraphQLNamedType, + GraphQLSchema, + GraphQLType, +} from 'graphql'; import { getNamedType, isEnumType, isInputObjectType, isInterfaceType, isListType, + isNamedType, isNonNullType, isObjectType, isScalarType, isUnionType, } from 'graphql'; -import { CSSProperties, memo, ReactNode, useState } from 'react'; +import type { CSSProperties, HTMLAttributes, KeyboardEvent, ReactNode } from 'react'; +import { Fragment, memo, useCallback, useMemo, useRef, useState } from 'react'; import { showGraphQLDocExplorerAtom } from '../atoms/graphqlSchemaAtom'; +import { useDebouncedValue } from '../hooks/useDebouncedValue'; +import { useRandomKey } from '../hooks/useRandomKey'; import { jotaiStore } from '../lib/jotai'; import { CountBadge } from './core/CountBadge'; import { Icon } from './core/Icon'; import { IconButton } from './core/IconButton'; +import { PlainInput } from './core/PlainInput'; import { Markdown } from './Markdown'; interface Props { @@ -33,7 +45,11 @@ type ExplorerItem = | { kind: 'input_field'; type: GraphQLInputField; from: ExplorerItem } | null; -export const GraphQLDocsExplorer = memo(function ({ style, schema, className }: Props) { +export const GraphQLDocsExplorer = memo(function GraphQLDocsExplorer({ + style, + schema, + className, +}: Props) { const [activeItem, setActiveItem] = useState(null); const qryType = schema.getQueryType(); @@ -48,7 +64,7 @@ export const GraphQLDocsExplorer = memo(function ({ style, schema, className }: return (
- + {activeItem == null ? (
Root Types @@ -87,7 +103,10 @@ export const GraphQLDocsExplorer = memo(function ({ style, schema, className }:
) : ( -
+
)} @@ -99,36 +118,50 @@ export const GraphQLDocsExplorer = memo(function ({ style, schema, className }: function GraphQLExplorerHeader({ item, setItem, + schema, }: { item: ExplorerItem; setItem: (t: ExplorerItem) => void; + schema: GraphQLSchema; }) { + const findIt = (t: ExplorerItem): ExplorerItem[] => { + if (t == null) return [null]; + return [...findIt(t.from), t]; + }; + const crumbs = findIt(item); return ( -
); -} +}); function validateRequire(v: string) { return v.length > 0; diff --git a/src-web/hooks/useToggle.ts b/src-web/hooks/useToggle.ts index 33f5c589..af9d66c3 100644 --- a/src-web/hooks/useToggle.ts +++ b/src-web/hooks/useToggle.ts @@ -3,5 +3,5 @@ import { useCallback, useState } from 'react'; export function useToggle(initialValue = false) { const [value, setValue] = useState(initialValue); const toggle = useCallback(() => setValue((v) => !v), []); - return [value, toggle] as const; + return [value, toggle, setValue] as const; } diff --git a/src-web/tailwind.config.cjs b/src-web/tailwind.config.cjs index 173a5818..4d73b496 100644 --- a/src-web/tailwind.config.cjs +++ b/src-web/tailwind.config.cjs @@ -5,6 +5,7 @@ const sizes = { xs: '1.8rem', sm: '2.0rem', md: '2.3rem', + lg: '2.6rem', }; /** @type {import('tailwindcss').Config} */