Files
react-jsonschema-form/packages/core/playground/samples/customArray.js
Jason Ritchie ef8b7fce19 Monorepo with Lerna (#1501)
Use Lerna to maintain core and themes as a monorepo. This should streamline creation of new themes and maintenance of existing theme(s).
2019-11-10 08:26:01 -08:00

59 lines
1.4 KiB
JavaScript

import React from "react";
function ArrayFieldTemplate(props) {
return (
<div className={props.className}>
{props.items &&
props.items.map(element => (
<div key={element.key} className={element.className}>
<div>{element.children}</div>
{element.hasMoveDown && (
<button
onClick={element.onReorderClick(
element.index,
element.index + 1
)}>
Down
</button>
)}
{element.hasMoveUp && (
<button
onClick={element.onReorderClick(
element.index,
element.index - 1
)}>
Up
</button>
)}
<button onClick={element.onDropIndexClick(element.index)}>
Delete
</button>
<hr />
</div>
))}
{props.canAdd && (
<div className="row">
<p className="col-xs-3 col-xs-offset-9 array-item-add text-right">
<button onClick={props.onAddClick} type="button">
Custom +
</button>
</p>
</div>
)}
</div>
);
}
export default {
schema: {
title: "Custom array of strings",
type: "array",
items: {
type: "string",
},
},
formData: ["react", "jsonschema", "form"],
ArrayFieldTemplate,
};