UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

2 lines (1 loc) 1.12 kB
import{jsx as r,jsxs as c}from"react/jsx-runtime";import{memo as f,useState as y}from"react";import{useThemeHooks as h}from"@redocly/theme";import{useIsFieldExpandable as u}from"../utils/is-field-expandable.js";import{ViewNested as T}from"../../common/components/ViewNested.js";import{FieldRow as w}from"./FieldRow.js";import{TypeView as F}from"./TypeView.js";import{ExpandableFieldBody as g,FieldWrapper as j}from"./styled.js";function V({argument:e,contrast:n,renderField:d,fieldExpandLevel:t=0,firstOfType:i,parentName:o}){const a=t+1,[s,l]=y(!1),{useTranslate:m}=h(),{translate:p}=m(),x=o?`arg-${o}-${e.name}`:`arg-${e.name}`;return c(j,{id:x,firstOfType:i,showBorder:!s,"data-testid":"arg-type",children:[r(w,{isArgument:!0,parentName:o,fieldExpandLevel:t,"data-testid":e.name+"-data",field:e}),u(e,t)?r(g,{contrast:!n,children:r(T,{expanded:s,level:t,expandText:p("graphql.returnTypes.show","Show return type"),collapseText:p("graphql.returnTypes.hide","Hide return type"),onClick:()=>l(!s),children:r(F,{type:e.type,contrast:!n,fieldExpandLevel:a,renderField:d})})}):null]})}const H=f(V);export{H as ArgumentView};