Skip to content</> asasvirtuais
Docs menuAPI reference
Docs/Reference

API reference

ImportExports
asasvirtuais/formForm, useForm
asasvirtuais/fieldsFieldsProvider, useFields, useField
asasvirtuais/actionActionProvider, useAction
asasvirtuais/formsCreateForm, UpdateForm, FilterForm, useCreateForm, useUpdateForm, useFilterForm
asasvirtuais/contextInterfaceProvider, TablesProvider, useTable, useInterface
asasvirtuais/registryTableProvider, SingleProvider, useSingle(schema, table)
asasvirtuais/singleSingleProvider, useSingle(schema)
asasvirtuais/interfaceasasvirtuaisInterface, TableInterface, Query, TableSchema, DatabaseSchema, FindProps, ListProps, CreateProps, UpdateProps, RemoveProps
asasvirtuais/hooksuseAction, useIndex

Form#

tsx
<Form defaults={...} action={async fields => result} onResult={result => ...} onError={error => ...} autoTrigger>
  {form => ...}
</Form>

Render props and useForm(): fields, setField, setFields, submit, callback(params), loading, result, error, errors.

FieldsProvider#

<FieldsProvider defaults={...}>. useFields() returns fields, setField, setFields, defaults. useField(key) returns { value, setValue }.

ActionProvider#

<ActionProvider action={...} params={...} onResult onError autoTrigger>. useAction() returns loading, result, error, errors, submit, callback, params.

Table forms#

ComponentProps
CreateFormtable, schema, defaults?, onSuccess?(row)
UpdateFormtable, schema, id, defaults?, onSuccess?(row)
FilterFormtable, schema, defaults? ({ query }), autoTrigger?, onSuccess?(rows)

Providers#

ComponentProps
InterfaceProviderfind, list, create, update, remove
TableProvidertable, schema, asAbove? (rows keyed by id)
TablesProvidertables (schemas by table name), mounted without rows
SingleProviderid, table, schema; children or a render prop ({ single }) => ...

useTable(table, schema) returns the table's index (array, index, set, unset, setIndex) and the operations find, list, create, update, remove, each with .trigger(props).

Interface#

ts
interface TableInterface<Readable, Writable = Readable> {
  find(props: FindProps): Promise<Readable>
  list(props: ListProps<Readable>): Promise<Readable[]>
  create(props: CreateProps<Writable>): Promise<Readable>
  update(props: UpdateProps<Writable>): Promise<Readable>
  remove(props: RemoveProps): Promise<Readable>
}

interface FindProps   { table?: string, id: string }
interface ListProps   { table?: string, query?: Query }
interface CreateProps { table?: string, data: Writable }
interface UpdateProps { table?: string, id: string, data: Partial<Writable> }
interface RemoveProps { table?: string, id: string }

asasvirtuaisInterface(schema, implementation) types an implementation by one table's schema or by the whole database schema.