2020-07-02 00:56:32 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as System from "~/components/system";
|
2020-07-07 04:14:30 +03:00
|
|
|
import * as Constants from "~/common/constants";
|
2020-07-08 07:04:54 +03:00
|
|
|
import * as SVG from "~/components/system/svg";
|
2020-06-22 14:00:51 +03:00
|
|
|
|
2020-07-02 00:56:32 +03:00
|
|
|
import Group from "~/components/system/Group";
|
|
|
|
import SystemPage from "~/components/system/SystemPage";
|
|
|
|
import ViewSourceLink from "~/components/system/ViewSourceLink";
|
2020-06-22 14:00:51 +03:00
|
|
|
|
|
|
|
export default class SystemPageInputs extends React.Component {
|
|
|
|
state = {
|
2020-07-05 07:33:08 +03:00
|
|
|
exampleOne: "Example text",
|
|
|
|
exampleTwo: "",
|
|
|
|
exampleThree: "",
|
|
|
|
exampleFour: "aaaaa-bbbbb-ccccc-ddddd-eeee",
|
2020-07-08 07:04:54 +03:00
|
|
|
exampleFive: "Click the 'x'",
|
2020-06-22 14:00:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
_handleChange = (e) => {
|
|
|
|
this.setState({ [e.target.name]: e.target.value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2020-07-02 00:56:32 +03:00
|
|
|
<SystemPage
|
2020-07-05 07:33:08 +03:00
|
|
|
title="SDS: Inputs"
|
|
|
|
description="..."
|
2020-07-02 00:56:32 +03:00
|
|
|
url="https://fps.onrender.com/system/inputs"
|
|
|
|
>
|
2020-06-22 14:15:04 +03:00
|
|
|
<System.H1>
|
2020-07-01 10:31:55 +03:00
|
|
|
Inputs <ViewSourceLink file="system/inputs.js" />
|
2020-06-22 14:15:04 +03:00
|
|
|
</System.H1>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<System.P>
|
|
|
|
The Input component is used to get a users input in a text field or a
|
|
|
|
textbox.
|
|
|
|
</System.P>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-03 19:38:44 +03:00
|
|
|
<br />
|
|
|
|
<System.H2>Imports</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
Import React and the Input and/or the Textarea Components.
|
|
|
|
</System.P>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-05 07:33:08 +03:00
|
|
|
{`import * as React from 'react';
|
2020-07-03 19:38:44 +03:00
|
|
|
import { Input, Textarea } from 'slate-react-system';`}
|
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.H2>Textarea</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>Declare the Textarea component.</System.P>
|
|
|
|
<br />
|
2020-07-05 07:33:08 +03:00
|
|
|
<System.Textarea
|
|
|
|
name="exampleOne"
|
|
|
|
value={this.state.exampleOne}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.CodeBlock>
|
2020-07-04 08:05:39 +03:00
|
|
|
{`class ExampleTextarea extends React.Component {
|
|
|
|
state = { exampleOne: 'Example text' }
|
|
|
|
|
2020-07-04 08:34:20 +03:00
|
|
|
_handleChange = e => this.setState(
|
2020-07-04 08:05:39 +03:00
|
|
|
{ [e.target.name]: e.target.value }
|
2020-07-04 08:34:20 +03:00
|
|
|
);
|
2020-07-04 08:05:39 +03:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Textarea
|
|
|
|
name="exampleOne"
|
|
|
|
value={this.state.exampleOne}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}`}
|
2020-06-24 05:02:55 +03:00
|
|
|
</System.CodeBlock>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.H2>Input with label and description</System.H2>
|
|
|
|
<hr />
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<System.P>
|
|
|
|
Declare the Input component with a label and description value.
|
|
|
|
</System.P>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<System.Input
|
|
|
|
label="Location of your pastries"
|
2020-07-03 19:38:44 +03:00
|
|
|
description="We need to know the location of your pastries."
|
2020-06-22 14:00:51 +03:00
|
|
|
tooltip="Hey friends."
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleTwo"
|
|
|
|
value={this.state.exampleTwo}
|
2020-06-22 14:00:51 +03:00
|
|
|
placeholder="Pastry Location"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.CodeBlock>
|
2020-07-04 08:05:39 +03:00
|
|
|
{`class ExampleLabel extends React.Component {
|
|
|
|
state = { exampleTwo: null }
|
|
|
|
|
2020-07-04 08:34:20 +03:00
|
|
|
_handleChange = e => this.setState(
|
2020-07-04 08:05:39 +03:00
|
|
|
{ [e.target.name]: e.target.value }
|
2020-07-04 08:34:20 +03:00
|
|
|
);
|
2020-07-04 08:05:39 +03:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Input
|
|
|
|
label="Location of your pastries"
|
|
|
|
description="We need to know the location of your pastries."
|
|
|
|
tooltip="Hey friends."
|
|
|
|
name="exampleTwo"
|
|
|
|
value={this.state.exampleTwo}
|
|
|
|
placeholder="Pastry Location"
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}`}
|
2020-06-24 05:02:55 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Input with max length</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<System.P>
|
|
|
|
Declare the Input component with the maximum number of characters
|
|
|
|
allowed.
|
|
|
|
</System.P>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<System.Input
|
|
|
|
label="Max length is 14"
|
|
|
|
max={14}
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleThree"
|
|
|
|
value={this.state.exampleThree}
|
2020-06-22 14:00:51 +03:00
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.CodeBlock>
|
2020-07-04 08:05:39 +03:00
|
|
|
{`class ExampleMax extends React.Component {
|
|
|
|
state = { exampleThree: null }
|
|
|
|
|
2020-07-04 08:34:20 +03:00
|
|
|
_handleChange = e => this.setState(
|
2020-07-04 08:05:39 +03:00
|
|
|
{ [e.target.name]: e.target.value }
|
2020-07-04 08:34:20 +03:00
|
|
|
);
|
2020-07-04 08:05:39 +03:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Input
|
|
|
|
label="Max length is 14"
|
|
|
|
max={14}
|
|
|
|
name="exampleThree"
|
|
|
|
value={this.state.exampleThree}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}`}
|
2020-06-24 05:02:55 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
2020-06-30 21:44:12 +03:00
|
|
|
<System.H2>Input with copy and paste</System.H2>
|
2020-06-24 05:02:55 +03:00
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>Declare the Input component with copyable.</System.P>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<System.Input
|
|
|
|
label="Copy and paste (read only)"
|
|
|
|
readOnly
|
2020-07-04 08:05:39 +03:00
|
|
|
name="exampleFour"
|
2020-06-22 14:00:51 +03:00
|
|
|
copyable
|
2020-07-04 08:05:39 +03:00
|
|
|
value={this.state.exampleFour}
|
2020-06-22 14:00:51 +03:00
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
<br />
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.CodeBlock>
|
2020-07-04 08:05:39 +03:00
|
|
|
{`class ExampleCopyPaste extends React.Component {
|
|
|
|
state = { exampleFour: 'aaaaa-bbbbb-ccccc-ddddd-eeee' }
|
|
|
|
|
2020-07-04 08:34:20 +03:00
|
|
|
_handleChange = e => this.setState(
|
2020-07-04 08:05:39 +03:00
|
|
|
{ [e.target.name]: e.target.value }
|
2020-07-04 08:34:20 +03:00
|
|
|
);
|
2020-07-04 08:05:39 +03:00
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Input
|
|
|
|
label="Copy and paste (read only)"
|
|
|
|
readOnly
|
|
|
|
name="exampleFour"
|
|
|
|
copyable
|
|
|
|
value={this.state.exampleFour}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}`}
|
2020-06-24 05:02:55 +03:00
|
|
|
</System.CodeBlock>
|
2020-07-08 07:04:54 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Input with icon and onSubmit</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
Declare the Input component with an icon and an onSubmit function.
|
|
|
|
onSubmit will be triggered upon click of the icon and upon key down of
|
|
|
|
the enter key.
|
|
|
|
</System.P>
|
|
|
|
<br />
|
|
|
|
<System.Input
|
|
|
|
label="Icon and submit function"
|
|
|
|
name="exampleFive"
|
2020-07-15 02:12:22 +03:00
|
|
|
icon={SVG.Close}
|
2020-07-08 07:04:54 +03:00
|
|
|
onSubmit={() => {
|
|
|
|
this.setState({ exampleFive: "" });
|
|
|
|
}}
|
|
|
|
value={this.state.exampleFive}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
|
|
|
{`class ExampleCopyPaste extends React.Component {
|
|
|
|
state = { exampleFive: "Click the 'x'" }
|
|
|
|
|
|
|
|
_handleChange = e => this.setState(
|
|
|
|
{ [e.target.name]: e.target.value }
|
|
|
|
);
|
2020-06-24 05:02:55 +03:00
|
|
|
|
2020-07-08 07:04:54 +03:00
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Input
|
|
|
|
label="Icon with submit function"
|
|
|
|
name="exampleFive"
|
2020-07-15 02:12:22 +03:00
|
|
|
icon={SVG.Close}
|
2020-07-08 07:04:54 +03:00
|
|
|
onSubmit={() => {
|
|
|
|
this.setState({ exampleFive: "" });
|
|
|
|
}}
|
|
|
|
value={this.state.exampleFive}
|
|
|
|
onChange={this._handleChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}`}
|
|
|
|
</System.CodeBlock>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Input with validation</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>Declare the Input component with validation.</System.P>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<System.Input
|
|
|
|
label="Success"
|
|
|
|
placeholder="This is an uncontrolled input for success."
|
|
|
|
validation="SUCCESS"
|
|
|
|
/>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<System.Input
|
|
|
|
label="Warning"
|
|
|
|
placeholder="This is an uncontrolled input for warning."
|
|
|
|
validation="WARNING"
|
|
|
|
/>
|
2020-06-22 14:00:51 +03:00
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-02 00:56:32 +03:00
|
|
|
<System.Input
|
|
|
|
label="Error"
|
|
|
|
placeholder="This is an uncontrolled input for error."
|
|
|
|
validation="ERROR"
|
|
|
|
/>
|
2020-06-24 05:02:55 +03:00
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
2020-07-04 08:05:39 +03:00
|
|
|
{`class ExampleSuccess extends React.Component {
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Input
|
|
|
|
label="Success"
|
|
|
|
placeholder="This is an uncontrolled input for success."
|
|
|
|
validation="SUCCESS"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}
|
2020-06-24 05:02:55 +03:00
|
|
|
|
2020-07-04 08:05:39 +03:00
|
|
|
class ExampleWarning extends React.Component {
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Input
|
|
|
|
label="Warning"
|
|
|
|
placeholder="This is an uncontrolled input for warning."
|
|
|
|
validation="WARNING"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}
|
2020-06-24 05:02:55 +03:00
|
|
|
|
2020-07-04 08:05:39 +03:00
|
|
|
class ExampleError extends React.Component {
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<Input
|
|
|
|
label="Error"
|
|
|
|
placeholder="This is an uncontrolled input for error."
|
|
|
|
validation="ERROR"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2020-07-03 19:38:44 +03:00
|
|
|
}`}
|
2020-06-24 05:02:55 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
2020-07-04 08:05:39 +03:00
|
|
|
<System.H2>Accepted React Properties</System.H2>
|
2020-06-24 05:02:55 +03:00
|
|
|
<hr />
|
|
|
|
<br />
|
2020-07-01 10:31:55 +03:00
|
|
|
<Group title="Inputs">
|
2020-06-24 05:02:55 +03:00
|
|
|
<System.Table
|
|
|
|
data={{
|
|
|
|
columns: [
|
2020-07-02 00:56:32 +03:00
|
|
|
{ key: "a", name: "Name", width: "128px" },
|
2020-07-14 07:28:18 +03:00
|
|
|
{ key: "b", name: "Type", width: "88px", type: "OBJECT_TYPE" },
|
2020-07-02 00:56:32 +03:00
|
|
|
{ key: "c", name: "Default", width: "88px" },
|
|
|
|
{ key: "d", name: "Description", width: "100%" },
|
|
|
|
],
|
|
|
|
rows: [
|
|
|
|
{
|
|
|
|
id: 1,
|
2020-07-07 04:14:30 +03:00
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
onChange
|
|
|
|
</span>
|
|
|
|
),
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "function",
|
2020-07-02 00:56:32 +03:00
|
|
|
c: "null",
|
2020-07-07 04:14:30 +03:00
|
|
|
d: "Function called upon an onChange event",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 2,
|
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
value
|
|
|
|
</span>
|
|
|
|
),
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d:
|
|
|
|
"The value that the dropdown takes. Can be used to assign default values as well.",
|
2020-07-02 00:56:32 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 3,
|
2020-07-07 04:14:30 +03:00
|
|
|
a: "name",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-02 00:56:32 +03:00
|
|
|
c: "null",
|
2020-07-07 04:14:30 +03:00
|
|
|
d: "Input name",
|
2020-07-02 00:56:32 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 4,
|
2020-07-07 04:14:30 +03:00
|
|
|
a: "label",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Label text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 5,
|
|
|
|
a: "description",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Description text",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 6,
|
2020-07-02 00:56:32 +03:00
|
|
|
a: "tooltip",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-02 00:56:32 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Tooltip text",
|
|
|
|
},
|
|
|
|
{
|
2020-07-07 04:14:30 +03:00
|
|
|
id: 7,
|
|
|
|
a: "max",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "int",
|
2020-07-07 04:14:30 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Max number of input characters",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 8,
|
2020-07-02 00:56:32 +03:00
|
|
|
a: "validation",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-02 00:56:32 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Validation style. Use: SUCCESS, WARNING or ERROR",
|
2020-07-01 10:31:55 +03:00
|
|
|
},
|
2020-07-08 07:04:54 +03:00
|
|
|
{
|
|
|
|
id: 9,
|
|
|
|
a: "icon",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "SVG",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d:
|
|
|
|
"Icon on the right side of the input box. If an onSubmit is specified, it will trigger on click. Specifying an icon overrides copyable",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 10,
|
|
|
|
a: "onSubmit",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "function",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d:
|
|
|
|
"Function called when the enter key is pressed and when the icon (if present) is clicked",
|
|
|
|
},
|
2020-06-24 05:02:55 +03:00
|
|
|
],
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Group>
|
2020-06-22 14:00:51 +03:00
|
|
|
</SystemPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|