API
Demo
@alinea/editor
export function
Fields
(
props
:
FieldsProps
)
:
Element
export type
FieldsProps
=
{
fields
:
Section.Fields
state
:
InputState
<
any
>
}
export class
FieldState
<
V
,
M
>
implements
InputState
<
readonly
[
V
,
M
]
>
{
constructor
<
V
,
M
>
(
shape
:
Shape
<
V
,
any
>
,
root
:
YMap
<
any
>
,
key
:
string
)
:
FieldState
<
V
,
M
>
child
(
field
:
string
)
:
FieldState
<
unknown
,
unknown
>
use
(
)
:
readonly
[
V
,
M
]
}
export function
Input
<
V
,
M
>
(
props
:
InputProps
<
V
,
M
>
)
:
Element
export function
InputForm
(
props
:
InputFormProps
)
:
Element
export type
InputFormProps
=
{
state
:
InputState
<
any
>
type
:
TypeConfig
}
/**
Label for an input
*/
export const
InputLabel
:
ForwardRefExoticComponent
<
{
asLabel
:
boolean
collection
:
boolean
empty
:
boolean
focused
:
boolean
help
:
Label
icon
:
ComponentType
<
{
}
>
inline
:
boolean
label
:
Label
optional
:
boolean
size
:
|
"small"
|
"medium"
|
"large"
width
:
number
}
&
{
children
:
ReactNode
}
&
RefAttributes
<
HTMLElement
>
>
export type
InputProps
<
V
,
M
>
=
{
field
:
Field
<
V
,
M
>
state
:
InputState
<
readonly
[
V
,
M
]
>
}
export namespace
InputState
{
export class
StatePair
<
V
,
M
>
implements
InputState
<
readonly
[
V
,
M
]
>
{
constructor
<
V
,
M
>
(
current
:
V
,
mutator
:
M
)
:
StatePair
<
V
,
M
>
current
:
V
mutator
:
M
child
(
field
:
string
)
:
StatePair
<
V
,
any
>
use
(
)
:
readonly
[
V
,
M
]
}
export type
List
<
T
>
=
readonly
[
Array
<
T
>
,
ListMutator
<
T
>
]
export type
Record
<
T
>
=
readonly
[
T
,
RecordMutator
<
T
>
]
export type
Scalar
<
T
>
=
readonly
[
T
,
{
}
]
export type
Text
<
T
>
=
readonly
[
TextDoc
<
T
>
,
RichTextMutator
<
T
>
]
}
export interface
InputState
<
T
=
any
>
{
child
(
field
:
string
)
:
InputState
<
any
>
use
(
)
:
T
}
export const
LabelHeader
:
NamedExoticComponent
<
LabelHeaderProps
>
export type
LabelHeaderProps
=
{
focused
:
boolean
help
:
Label
icon
:
ComponentType
label
:
Label
optional
:
boolean
size
:
|
"small"
|
"medium"
|
"large"
}
export type
LabelProps
=
PropsWithChildren
<
{
asLabel
:
boolean
collection
:
boolean
empty
:
boolean
focused
:
boolean
help
:
Label
icon
:
ComponentType
inline
:
boolean
label
:
Label
optional
:
boolean
size
:
|
"small"
|
"medium"
|
"large"
width
:
number
}
>
export function
useField
<
V
,
M
>
(
field
:
Field
<
V
,
M
,
V
>
,
initialValue
:
V
)
:
{
input
:
{
}
,
value
:
V
}
export function
useInput
<
T
>
(
path
:
InputState
<
T
>
)
:
T