2.0.2 • Published 22 days ago

@undermuz/react-json-form v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
22 days ago

@undermuz/react-json-form

(⚠️⚠️⚠️ THIS PACKAGE IS UNDER DEVELOPING ⚠️⚠️⚠️)

React library for generate JSON-based form

Install

npm i @undermuz/react-json-form

Basic usage

  1. Import JsonForm component
import JsonForm from "@undermuz/react-json-form"
  1. Import UiContext for apply theme
import JsonForm, {
    UiContext,
} from "@undermuz/react-json-form"
  1. Import theme
import ChakraUiTheme from "@undermuz/react-json-form/themes/chakra"
  1. Create form component
const YourForm = () => {
    const [value, setValue] = useState({})

    return (
        <>
            <UiContext.Provider value={ChakraUiTheme}>
                <JsonForm value={value} onChange={setValue} />
            </UiContext.Provider>
        </>
    )
}
  1. Add form's scheme
const scheme: IScheme = {
    id: "login-form-v1",
    single: true,
    multiple: false,
    title: "Login",
    name: "login-form-v1",
    scheme: [
        {
            name: "email",
            title: "E-mail",
            placeholder: "ex: youremail@mail.com",
            type: EnumSchemeItemType.Input,
            settings: {
                inputType: "email",
            },
            def_value: "",
            rules: [
                [["Boolean"], "Required"],
                [["isEmail"], "Incorrect e-mail"],
            ],
        },
        {
            name: "password",
            title: "Password",
            type: EnumSchemeItemType.Input,
            settings: {
                inputType: "password",
            },
            def_value: "",
            rules: [
                [["Boolean"], "Required"],
                [
                    ["isStringMinMaxLength:[6,18]"],
                    "Min length: 6; Max length: 18",
                ],
            ],
        },
        {
            name: "remember",
            title: "Remember?",
            type: EnumSchemeItemType.Checkbox,
            def_value: true,
        },
    ],
}
  1. Apply the scheme to JsonForm
const YourForm = () => {
    const [value, setValue] = useState({})

    return (
        <>
            <UiContext.Provider value={ChakraUiTheme}>
                <JsonForm {...scheme} value={value} onChange={setValue} />
            </UiContext.Provider>
        </>
    )
}
  1. Get result

Result

Built-in themes

Storybook: ChakraUi

Storybook: Rsuite

Storybook: Grommet

Examples

Forms

Storybook: Login form

Storybook: Signup form

Custom layout

Storybook: Wrapp form

Storybook: Wrapp fields block

Storybook: Wrapp each field

Storybook: Vertical stack

Storybook: Horizontal stack

Storybook: Grid layout

2.0.2

22 days ago

2.0.1

22 days ago

2.0.0

22 days ago

1.1.19

2 months ago

1.1.20

2 months ago

1.1.18

2 months ago

1.1.17

2 months ago

1.1.16

3 months ago

1.1.15

3 months ago

1.1.14

3 months ago

1.1.13

3 months ago

1.1.12

3 months ago

1.1.11

3 months ago

1.1.1

9 months ago

1.1.0

10 months ago

1.1.9

7 months ago

1.1.8

7 months ago

1.1.7

8 months ago

1.1.6

8 months ago

1.1.5

8 months ago

1.1.4

8 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.10

7 months ago

1.0.48

10 months ago

1.0.47

10 months ago

1.0.46

10 months ago

1.0.49

10 months ago

1.0.39

12 months ago

1.0.38

12 months ago

1.0.40

12 months ago

1.0.44

11 months ago

1.0.43

11 months ago

1.0.42

11 months ago

1.0.41

11 months ago

1.0.45

11 months ago

1.0.37

12 months ago

1.0.36

12 months ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.22

1 year ago

1.0.20

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago