@datalayer/primer-rjsf
Version:
React JSON Schema Form (RJSF) for Primer
31 lines (30 loc) • 1.13 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import validator from "@rjsf/validator-ajv8";
import { ThemeProvider, Box } from "@primer/react";
import Form from "./../index";
const schema = {
title: "Todo Example",
type: "object",
required: [
"title"
],
properties: {
title: { type: "string", title: "Title", default: "A new task" },
hello: { type: "string", title: "Hello", default: "How are you?" },
details: { type: "string", title: "Details", default: "Roundhouse kicking asses since 1940" },
done: { type: "boolean", title: "Done?", default: false }
}
};
const uiSchema = {
bio: {
"ui:widget": "textarea"
}
};
const FormExample1 = () => {
return (_jsx(ThemeProvider, { children: _jsx(Box, { m: 5, children: _jsx(Form, { schema: schema, uiSchema: uiSchema, validator: validator, onSubmit: ({ formData }, e) => {
console.log("submitted formData", formData);
console.log("submit event", e);
window.alert("Form submitted");
} }) }) }));
};
export default FormExample1;