UNPKG

@redocly/graphql-docs

Version:

Redocly GraphQL docs

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