UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 1.44 kB
import{jsx as t,jsxs as n}from"react/jsx-runtime";import{useState as i}from"react";import{useThemeHooks as c}from"@redocly/theme";import{HiddenNavigationAnchor as T}from"../../../shared/index.js";import{useIsFieldExpandable as w,useShowExpandableBorder as y}from"../utils/is-field-expandable.js";import{ViewNested as m}from"../../common/components/ViewNested.js";import{getNavigationIdProp as f}from"../../navigation/index.js";import{TypeView as F}from"./TypeView.js";import{Arguments as j}from"./Arguments.js";import{FieldRow as q}from"./FieldRow.js";import{ExpandableFieldBody as v,FieldWrapper as A}from"./styled.js";function l({field:e,contrast:a,key:g,fieldExpandLevel:r}){const p=r+1,[s,h]=i(!1),[d,x]=i(!1),{useTranslate:u}=c(),{translate:o}=u();return n("div",{children:[t(T,{...f("")}),n(A,{showBorder:y(e,r,{expandedTypes:s}),children:[t(q,{fieldExpandLevel:r,field:e}),w(e,r)?n(v,{contrast:!a,children:[!!e.args?.length&&t(m,{expanded:d,level:r,expandText:o("graphql.arguments.show","Show arguments"),collapseText:o("graphql.arguments.hide","Hide arguments"),args:e.args,onClick:()=>x(!d),children:t(j,{args:e.args,fieldExpandLevel:p,renderField:l})}),t(m,{expanded:s,level:r,expandText:o("graphql.returnTypes.show","Show return type"),collapseText:o("graphql.returnTypes.hide","Hide return type"),onClick:()=>h(!s),children:t(F,{type:e.type,contrast:!a,fieldExpandLevel:p,renderField:l})})]}):null]})]},g)}export{l as FieldView};