0.26.8 • Published 1 year ago

@metablock/react v0.26.8

Weekly downloads
79
License
ISC
Repository
github
Last release
1 year ago

Metablock React

React components, views and utilities for building metablocks.

Components

NoSsr

Disable server-side rendering

import { NoSsr } from "@metablock/react";
<NoSsr>...</NoSsr>;

This is useful for private/login-protected pages for example.

Header

import {Header} from "@metablock/react";
<Header paddingTop={1}, paddingBottom={1}/>

Image

Progressively load background images

Hooks

useIntersectionObserver

Originally from montezume/medium-style-progressively-loaded-images repo. This hook allows to progressively load images.

useWindowSize

useForm

A hook for managing Form submission workflow and optionally for rendering form fields

import { useForm } from "@metablock/react";

const form = useForm(
  {
    handleSubmit,
    defaultValues,
    fieldCallback,
  },
  []
);

The handleSubmit function is an async function for handling form submissions, defaultValues are the initial/default values of the form and fieldCallback is an optional function for customizing props of form fields.

The optional callback function can be used to further customize the UI. The signature is

const fieldCallback = (
  name: str,
  extraProps: Record<string, any>
): Record<string, any> => {
  return extraProps;
};

where name is the input name and extraProps are the additional props passed to the original FormFromSchema component. If the function returns nothing for a given field name, the field is not displayed in the form.

Forms

The library has a tooling for rending Forms specified via JSON schema.

FormFromSchema

The entry-point component for rendering forms from JSON schema

import {FormFromSchema, useForm} from "@metablock/react";

const MyForm = () => {
  const form = useForm({...});

  return <FormFromSchema form={form} schema={...} data={...} {...extraProps}/>
};

The schema is a valid subset of the JSON schema. For example a simple name input can be defined as:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 3,
      "description": "Please enter your name",
      "format": "optional format"
    }
  }
}

SchemaRegistry

This is a global object which controls how form fields are rendered. By defaults it provide the basic input fields, but it can be extended or overwritten if required.

import { SchemaRegistry } from "@metablock/react";

SchemaRegistry.set("string", StringSchema);
SchemaRegistry.set("boolean", BooleanSchema);
SchemaRegistry.set("integer", NumberSchema);
SchemaRegistry.set("number", NumberSchema);
SchemaRegistry.set("object", ObjectSchema);

CrudForm

This is a higher level component to render Forms with side actions. It uses the FormFromSchema component in conjunction with the useForm hook.

ApiDataGrid

A Component for rendering tabular data, it allows to fetch server side data via the ApiData interface.

0.26.3

1 year ago

0.26.8

1 year ago

0.26.7

1 year ago

0.26.6

1 year ago

0.26.5

1 year ago

0.26.4

1 year ago

0.26.2

1 year ago

0.26.1

1 year ago

0.25.4

1 year ago

0.25.2

1 year ago

0.25.1

1 year ago

0.25.0

1 year ago

0.25.6

1 year ago

0.25.5

1 year ago

0.26.0

1 year ago

0.23.6

1 year ago

0.23.5

1 year ago

0.23.4

1 year ago

0.23.3

1 year ago

0.23.7

1 year ago

0.24.2

1 year ago

0.24.1

1 year ago

0.24.0

1 year ago

0.23.2

1 year ago

0.23.0

1 year ago

0.22.6

2 years ago

0.20.0

2 years ago

0.21.7

2 years ago

0.21.6

2 years ago

0.21.5

2 years ago

0.21.4

2 years ago

0.21.3

2 years ago

0.21.2

2 years ago

0.21.1

2 years ago

0.21.0

2 years ago

0.22.5

2 years ago

0.22.4

2 years ago

0.22.3

2 years ago

0.22.2

2 years ago

0.22.1

2 years ago

0.17.0

2 years ago

0.18.9

2 years ago

0.18.1

2 years ago

0.18.2

2 years ago

0.18.3

2 years ago

0.18.4

2 years ago

0.18.5

2 years ago

0.18.6

2 years ago

0.18.7

2 years ago

0.18.8

2 years ago

0.18.0

2 years ago

0.19.0

2 years ago

0.19.1

2 years ago

0.19.2

2 years ago

0.16.0

2 years ago

0.13.0

2 years ago

0.15.0

2 years ago

0.14.0

2 years ago

0.12.0

3 years ago

0.11.0

3 years ago

0.10.0

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

4 years ago

0.8.0

4 years ago

0.7.8

4 years ago

0.7.7

4 years ago

0.7.6

4 years ago

0.7.5

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.6

4 years ago

0.6.5

4 years ago

0.6.4

4 years ago

0.6.3

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.5

4 years ago

0.4.6

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.24

4 years ago

0.3.0

4 years ago

0.2.23

4 years ago

0.2.22

4 years ago

0.2.20

4 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago

0.2.13

4 years ago

0.2.11

4 years ago

0.2.10

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.5

4 years ago

0.2.3

4 years ago

0.2.4

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.12

4 years ago

0.1.10

4 years ago

0.1.11

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.9

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.2

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago