@sjsf/form
TypeScript icon, indicating that this package has built-in type declarations

1.9.2 • Public • Published

@sjsf/form

Svelte 5 library for creating forms based on JSON schema. Unofficial port of react-jsonschema-form.

Installation

Install the library and ajv for validation.

npm install @sjsf/form @sjsf/ajv8-validator ajv@8

Usage

<script lang="ts">
  import { createForm3, RawForm, type Schema } from '@sjsf/form';
  import { translation } from '@sjsf/form/translations/en';
  import { theme } from '@sjsf/form/basic-theme';
  import { createValidator2 } from "@sjsf/ajv8-validator";

  const validator = createValidator2();

  const schema: Schema = {
    title: 'Tasks',
    type: 'array',
    items: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          title: 'Name',
        },
        description: {
          type: 'string',
          title: 'Description',
        },
      },
      required: ["name"]
    },
  }

  const form = createForm3({
    ...theme,
    schema,
    validator,
    translation,
    onSubmit: console.log
  })
</script>

<RawForm {form} />

License

This project includes modifications of code from react-jsonschema-form, which is licensed under the Apache License, Version 2.0. The rest of the project is under the MIT license.

See LICENSE-MIT and LICENSE-APACHE for details.

See also

Readme

Keywords

Package Sidebar

Install

npm i @sjsf/form

Weekly Downloads

219

Version

1.9.2

License

(MIT AND Apache-2.0)

Unpacked Size

408 kB

Total Files

314

Last publish

Collaborators

  • x0k