UNPKG

@datalayer/primer-rjsf

Version:

React JSON Schema Form (RJSF) for Primer

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