2020-07-08 07:04:54 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as System from "~/components/system";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
|
|
|
|
import Group from "~/components/system/Group";
|
|
|
|
import SystemPage from "~/components/system/SystemPage";
|
|
|
|
import ViewSourceLink from "~/components/system/ViewSourceLink";
|
|
|
|
|
|
|
|
export default class SystemPageListEditor extends React.Component {
|
|
|
|
state = {
|
|
|
|
flavors: [
|
|
|
|
"Chocolate",
|
|
|
|
"Vanilla",
|
|
|
|
"Mint Chip",
|
|
|
|
"Pistachio",
|
|
|
|
"Neapolitan",
|
|
|
|
"Toffee",
|
|
|
|
"Rocky Road",
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleListChange = ({ name, value }) => {
|
|
|
|
this.setState({ [name]: value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<SystemPage
|
|
|
|
title="SDS: List Editor"
|
|
|
|
description="..."
|
|
|
|
url="https://fps.onrender.com/system/list-editor"
|
|
|
|
>
|
|
|
|
<System.H1>
|
|
|
|
List Editor <ViewSourceLink file="system/listeditor.js" />
|
|
|
|
</System.H1>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
The List Editor component allows the user to add to, delete from, and
|
|
|
|
reorder a list of strings.
|
|
|
|
</System.P>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Imports</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.P>Import React and the ListEditor Component.</System.P>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
|
|
|
{`import * as React from 'react';
|
2020-07-09 10:10:06 +03:00
|
|
|
import { ListEditor } from 'slate-react-system';`}
|
2020-07-08 07:04:54 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>List Editor</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<System.ListEditor
|
|
|
|
name="flavors"
|
|
|
|
options={this.state.flavors}
|
|
|
|
onChange={this._handleListChange}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<System.P>
|
|
|
|
Define the List Editor component. Note that the _handleListChange
|
|
|
|
takes a different shape than the other onChange functions in this
|
|
|
|
design system.
|
|
|
|
</System.P>
|
|
|
|
<br />
|
|
|
|
<System.CodeBlock>
|
|
|
|
{`class ExampleOne extends React.Component {
|
2020-07-09 10:10:06 +03:00
|
|
|
state = {
|
|
|
|
flavors: [
|
|
|
|
"Chocolate",
|
|
|
|
"Vanilla",
|
|
|
|
"Mint Chip",
|
|
|
|
"Pistachio",
|
|
|
|
"Neapolitan",
|
|
|
|
"Toffee",
|
|
|
|
"Rocky Road"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
_handleListChange = ({ name, value }) => {
|
|
|
|
this.setState({ [name]: value });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return(
|
|
|
|
<ListEditor
|
|
|
|
name="flavors"
|
|
|
|
options={this.state.flavors}
|
|
|
|
onChange={this._handleListChange}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}`}
|
2020-07-08 07:04:54 +03:00
|
|
|
</System.CodeBlock>
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<br />
|
|
|
|
<System.H2>Accepted React Properties</System.H2>
|
|
|
|
<hr />
|
|
|
|
<br />
|
|
|
|
<Group title="List Editor">
|
|
|
|
<System.Table
|
|
|
|
data={{
|
|
|
|
columns: [
|
|
|
|
{ key: "a", name: "Name", width: "128px" },
|
2020-07-19 07:47:19 +03:00
|
|
|
{ key: "b", name: "Type", width: "88px", type: "OBJECT_TYPE" },
|
2020-07-08 07:04:54 +03:00
|
|
|
{ key: "c", name: "Default", width: "88px" },
|
|
|
|
{ key: "d", name: "Description", width: "100%" },
|
|
|
|
],
|
|
|
|
rows: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
onChange
|
|
|
|
</span>
|
|
|
|
),
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "function",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Function called upon an onChange event",
|
|
|
|
},
|
|
|
|
{
|
2020-07-19 07:47:19 +03:00
|
|
|
id: 2,
|
2020-07-08 07:04:54 +03:00
|
|
|
a: (
|
|
|
|
<span style={{ fontFamily: Constants.font.semiBold }}>
|
|
|
|
options
|
|
|
|
</span>
|
|
|
|
),
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "Array",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d:
|
|
|
|
"Values to choose from and reorder. Can be used to specify the default value. An array of strings.",
|
|
|
|
},
|
|
|
|
{
|
2020-07-19 07:47:19 +03:00
|
|
|
id: 3,
|
2020-07-08 07:04:54 +03:00
|
|
|
a: "name",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Input name",
|
|
|
|
},
|
|
|
|
{
|
2020-07-19 07:47:19 +03:00
|
|
|
id: 4,
|
2020-07-08 07:04:54 +03:00
|
|
|
a: "label",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Label text",
|
|
|
|
},
|
|
|
|
{
|
2020-07-19 07:47:19 +03:00
|
|
|
id: 5,
|
2020-07-08 07:04:54 +03:00
|
|
|
a: "description",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Description text",
|
|
|
|
},
|
|
|
|
{
|
2020-07-19 07:47:19 +03:00
|
|
|
id: 6,
|
2020-07-08 07:04:54 +03:00
|
|
|
a: "tooltip",
|
2020-07-14 07:28:18 +03:00
|
|
|
b: "string",
|
2020-07-08 07:04:54 +03:00
|
|
|
c: "null",
|
|
|
|
d: "Tooltip text",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Group>
|
|
|
|
</SystemPage>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|