0.6.1 • Published 6 years ago

typed-ui v0.6.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

typed-ui

Build Status npm Package Coveralls Known Vulnerabilities License Contributors npm Downloads Commitizen Friendly Github Stars

Generic UI for the GraphQL Schema Language.

Install

$ yarn add typed-ui

Docs

https://typed-ui.js.org

Usage

import React from 'react';
import { render } from 'react-dom';
import {
  GraphQLObjectType,
  GraphQLInputObjectType,
  GraphQLString,
  GraphQLList,
  GraphQLNonNull
} from 'graphql';
import { Put } from '../../src';

const Demo = () => (
  <Put
    type={
      new GraphQLObjectType({
        name: 'typed-ui Demo',
        fields: {
          A: {
            args: {
              X: {
                type: new GraphQLInputObjectType({
                  name: 'X',
                  fields: {
                    xs: { type: GraphQLList(GraphQLNonNull(GraphQLString)) }
                  }
                })
              }
            },
            type: new GraphQLObjectType({
              name: 'This is what A returned',
              fields: {
                B: { type: GraphQLList(GraphQLString) }
              }
            })
          }
        }
      })
    }
    data={{
      A: { output: { B: { output: ['hew'] } } }
    }}
    onChange={console.log}
  />
);

render(<Demo />, document.querySelector('#demo'));

API

Members

Functions

ListInput ⇒ Component

Returns a list input component with change events handled by the given callback.

Kind: global variable
Returns: Component - A list input component.

ParamTypeDescription
propsObjectThe component props.
props.ofTypeGraphQLInputTypeThe type of items in the list.
props.onChangeonChangeThe handler for change events.

Example (Log list input to the console)

<ListInput ofType={GraphQLString} onChange={console.log} />

ListInput~onChange : function

This callback handles ListInput change events.

Kind: inner typedef of ListInput

ParamType
valueArray.<*>

ObjectInput ⇒ Component

Returns an object input component with change events handled by the given callback.

Kind: global variable
Returns: Component - An object input component.

ParamTypeDescription
propsObjectThe component props.
props.namestringThe name of the input object.
props.fieldsObjectThe input object fields.
props.onChangeonChangeThe handler for change events.

Example (Log object input to the console)

<ObjectInput
  name="This is the name of the input object."
  fields={{
    x: { type: GraphQLString }
  }}
  onChange={console.log}
/>

ObjectInput~onChange : function

This callback handles ObjectInput change events.

Kind: inner typedef of ObjectInput

ParamType
valueObject

NonNullInput

TODO A component for non null inputs. Bases component selection on name of type.

Kind: global variable

HigherOrderInput ⇒ React.Element

Component for displaying GraphQL input types of higher order.

Kind: global variable
Returns: React.Element - An element displaying the input.

ParamTypeDescription
ofTypeGraphQLInputTypeThe type of the input.
ofTypeObject.<GraphQLInputType, Component>Map from GraphQL input types to components.

ListOutput ⇒ Element

Component for displaying GraphQLObjectType input and output data.

Kind: global variable
Returns: Element - A object surrounding the object items.

ParamTypeDescription
propsObjectThe component props.
props.namestringThe name of the object.
props.fieldsObjectThe type of fields of the object.
props.dataObjectThe object field args and return data.
props.datafieldName.selectedBooleanWhether the field is selected.
props.datafieldName.inputObjectThe input data for object field arguments.
props.datafieldName.input[argNameGraphQLInputTypeThe input data for object field arguments.
props.datafieldName.outputGraphQLTypeThe output data for object field return types.
props.onChangeonChangeThe handler for change events.

Example (Display an object of one string)

<ObjectOutput
  name="This is the name of the object."
  fields={{
    hew: { type: GraphQLString }
  }}
  data={{ hew: 'This is a string field called hew.' }}
/>

ListOutput~onChange : function

This callback handles ListOutput change events.

Kind: inner typedef of ListOutput

ParamType
valueArray.<*>

NonNullOutput

TODO A component for non null inputs. Bases component selection on name of type.

Kind: global variable

HigherOrderOutput ⇒ React.Element

Component for displaying GraphQL output types of higher order.

Kind: global variable
Returns: React.Element - An element displaying the input.

ParamTypeDescription
ofTypeGraphQLOutputTypeThe type of the input.
ofTypeObject.<GraphQLOutputType, Component>Map from GraphQL input types to components.

StringInput ⇒ Component

Returns a text field with change events handled by the given callback.

Kind: global variable
Returns: Component - A text field component.

ParamTypeDescription
propsObjectThe component props.
props.onChangeonChangeThe handler for change events.

Example (Log string input to the console)

<StringInput onChange={console.log} />

StringInput~onChange : function

This callback handles StringInput change events.

Kind: inner typedef of StringInput

ParamType
valuestring

IntegerInput ⇒ Component

Returns an integer input component with change events handled by the given callback.

Kind: global variable
Returns: Component - An integer input component.

ParamTypeDescription
propsObjectThe component props.
props.onChangeonChangeThe handler for change events.

Example (Log integer input to the console)

<IntegerInput onChange={console.log} />

IntegerInput~onChange : function

This callback handles IntegerInput change events.

Kind: inner typedef of IntegerInput

ParamType
valueinteger

FloatInput ⇒ Component

Returns a float input component with change events handled by the given callback.

Kind: global variable
Returns: Component - A float input component.

ParamTypeDescription
propsObjectThe component props.
props.onChangeonChangeThe handler for change events.

Example (Log float input to the console)

<FloatInput onChange={console.log} />

FloatInput~onChange : function

This callback handles FloatInput change events.

Kind: inner typedef of FloatInput

ParamType
valuefloat

BooleanInput ⇒ Component

Returns a boolean input component with change events handled by the given callback.

Kind: global variable
Returns: Component - A boolean input component.

ParamTypeDescription
propsObjectThe component props.
props.onChangeonChangeThe handler for change events.

Example (Log boolean input to the console)

<BooleanInput onChange={console.log} />

BooleanInput~onChange : function

This callback handles BooleanInput change events.

Kind: inner typedef of BooleanInput

ParamType
valueboolean

EnumInput ⇒ Component

Returns a select component with change events handled by the given callback.

Kind: global variable
Returns: Component - A select component.

ParamTypeDescription
propsObjectThe component props.
props.optionsArray.<string>= The enum options.
props.datastring= The enum data.
props.onChangeonChangeThe handler for change events.

Example (Log enum input to the console)

<EnumInput options={['a', 'b', 'c']} data="b" onChange={console.log} />

EnumInput~onChange : function

This callback handles EnumInput change events.

Kind: inner typedef of EnumInput

ParamType
valuestring

StringOutput ⇒ Component

Returns a div surrounding the supplied data.

Kind: global variable
Returns: Component - A div surrounding the data.

ParamTypeDescription
propsObjectThe component props.
props.datastringThe string data.

Example (Display the string "abc")

<StringOutput data="abc" />

EnumOutput ⇒ Component

Returns a readonly component displaying the supplied data.

Kind: global variable
Returns: Component - A component displaying the enum.

ParamTypeDescription
propsObjectThe component props.
datastringThe enum data.

Example (Display an enum)

<EnumOutput data="ABC" />

BooleanOutput ⇒ Component

Returns a readonly checkbox displaying the value of the supplied boolean.

Kind: global variable
Returns: Component - A chechbox displaying the data.

ParamTypeDescription
propsObjectThe component props.
props.databooleanThe boolean data.

Example (Display true)

<BooleanOutput data={true} />

IntegerOutput ⇒ Component

Returns a readonly number input component displaying the integer.

Kind: global variable
Returns: Component - A number input displaying the data.

ParamTypeDescription
propsObjectThe component props.
props.dataintegerThe integer data.

Example (Display an integer)

<IntegerOutput data={true} />

FloatOutput ⇒ Component

Returns a readonly number input component displaying the float.

Kind: global variable
Returns: Component - A number input displaying the data.

ParamTypeDescription
propsObjectThe component props.
props.datafloatThe float data.

Example (Display an float)

<FloatOutput data={true} />

Put ⇒ Component

Component for displaying GraphQL data

Kind: global variable
Returns: Component - A component displaying the data.

ParamTypeDescription
propsObjectThe component props.
props.typeGraphQLTypeThe type of the data.
props.dataObjectThe initial data.
props.onChangeonChangeThe handler for changes in the data.
props.renderrenderThe custom GraphQL data renderer.

Example (Display a string)

<Put type={GraphQLString} data="abc" />

Example (Display an object)

<Put
  type={
    new GraphQLObjectType({
      name: 'abc',
      fields: { w: { type: GraphQLString } }
    })
  }
  data={{ w: 'xyz' }}
/>

Example (Log object input to the console)

<Put
  type={
    new GraphQLInputObjectType({
      name: 'abc',
      fields: { w: { type: GraphQLString } }
    })
  }
  data={{ w: '' }}
  onChange={console.log}
/>

Put~onChange : function

This callback handles Put change events.

Kind: inner typedef of Put

ParamType
valueObject

Put~render : function

This function renders GraphQL data.

Kind: inner typedef of Put

ParamType
typeGraphQLType
data*

ListOutput(props) ⇒ Component

Returns a list surrounding the supplied list data.

Kind: global function
Returns: Component - A list surrounding the list items.

ParamTypeDescription
propsObjectThe component props.
props.ofTypeGraphQLOutputTypeThe type of the list items.
props.dataArray.<*>The list data.
props.onChangeonChangeThe handler for change events.

Example (Display a list of strings)

<ListOutput ofType={GraphQLString} data={['abc', 'd', 'xyz']} />

Example (Display a list of list of integers)

<ListOutput
  ofType={new GraphQLList(GraphQLInt)}
  data={[[0, 1, 2], [10, 11, 12], [50, 100]]}
/>

ListOutput~onChange : function

This callback handles ListOutput change events.

Kind: inner typedef of ListOutput

ParamType
valueArray.<*>

Maintainers

License

MIT © Pi Cubed

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.2.7

6 years ago

0.3.3

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.3

6 years ago

0.3.1

6 years ago

0.3.2

6 years ago

0.3.0

6 years ago

0.2.4

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

1.0.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago