mirror of
https://github.com/zhigang1992/react-jsonschema-form.git
synced 2026-01-12 17:33:12 +08:00
Use Lerna to maintain core and themes as a monorepo. This should streamline creation of new themes and maintenance of existing theme(s).
59 lines
1.4 KiB
JavaScript
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,
|
|
};
|