Ƭ Flare<A
>: Object
The basic building block of a Flare UI, capable of providing a value when queried and invoking some upstream handler when the value changes
Name | Description |
---|---|
A | The value the Flare produces |
Name | Type | Description |
---|---|---|
_tag | "Flare" | Tags the object as a Flare. |
make | () => { query : () => A ; render : VoidFunctionComponent <{ onChange : () => void }> } | Initializes the Flare. |
Ƭ Unflare<F
>: F
extends Flare
<infer A> ? A
: never
A utility type that extracts the type parameter A
from a Flare<A>
Remarks
A Flare<A>
produces values of type A
. The A
type can sometimes be
useful, for example to annotate function parameters where TypeScript
struggles to infer types.
Name | Description |
---|---|
F | The Flare<A> from which to extract A |
▸ ap<A
, B
>(fa
): (fab
: Flare
<(a
: A
) => B
>) => Flare
<B
>
Applies a function to a value within a Flare
context.
Name | Description |
---|---|
A | The value to which to apply the function |
B | The return value of the function |
Name | Type | Description |
---|---|---|
fa | Flare <A > | The Flare that produces the original value |
fn
A Flare that produces the result of the function application
▸ (fab
): Flare
<B
>
Name | Type |
---|---|
fab | Flare <(a : A ) => B > |
Flare
<B
>
▸ chain<A
, B
>(afb
): (fa
: Flare
<A
>) => Flare
<B
>
Composes Flares in a sequence.
Name | Description |
---|---|
A | The value produced by the first Flare |
B | The value produced by the second Flare |
Name | Type | Description |
---|---|---|
afb | (a : A ) => Flare <B > | The function to apply to the output of the first Flare to produce the second Flare |
fn
The Flare resulting from the composition
▸ (fa
): Flare
<B
>
Name | Type |
---|---|
fa | Flare <A > |
Flare
<B
>
▸ checkbox(options
): Flare
<boolean
>
Creates a Flare that renders as a checkbox control.
Name | Type | Description |
---|---|---|
options | Object | Checkbox options |
options.initial | boolean | Initial checked state |
options.label? | string | Checkbox label |
Flare
<boolean
>
The Flare that was created
▸ comboBox<A
, C
>(options
): Flare
<A
>
Creates a Flare that renders as a combo box.
Name | Type | Description |
---|---|---|
A | A | The value that the combo box produces |
C | extends { optionToString? : undefined } | { optionToString : (option : A ) => string } | An additional optionToString option, required to convert A to string when it doesn't already extend string |
Name | Type | Description |
---|---|---|
options | { initial : A ; label? : string ; options : readonly A [] } & C | Combo box options |
Flare
<A
>
The Flare that was created
▸ ifElse<A
, B
>(a
, b
): (cond
: boolean
) => Flare
<A
| B
>
Combines two Flares into one, producing the value from the original Flare that corresponds to the boolean expression provided.
Name | Description |
---|---|
A | The value produced by the first Flare |
B | The value produced by the second Flare |
Name | Type | Description |
---|---|---|
a | Flare <A > | The value produced by the first Flare |
b | Flare <B > | The value produced by the second Flare |
fn
The first Flare when the boolean expession is true
; otherwise, the
second Flare
▸ (cond
): Flare
<A
| B
>
Name | Type |
---|---|
cond | boolean |
Flare
<A
| B
>
Remarks
This is typically used with chain.
▸ map<A
, B
>(ab
): (fa
: Flare
<A
>) => Flare
<B
>
Applies a function to a Flare to change its output.
Name | Description |
---|---|
A | The value produced by the original Flare |
B | The value produced by the modified Flare |
Name | Type | Description |
---|---|---|
ab | (a : A ) => B | The function to apply to the output of the original Flare |
fn
A Flare that produces the result of the function application
▸ (fa
): Flare
<B
>
Name | Type |
---|---|
fa | Flare <A > |
Flare
<B
>
▸ match<M
>(map
): M
extends Record
<string
| number
, Flare
<infer A>> ? (key
: keyof M
) => Flare
<A
> : never
Combines multiple Flares into one, producing the value from the original Flare that corresponds to the expression provided.
Name | Description |
---|---|
M | The map of Flares from which to select |
Name | Type | Description |
---|---|---|
map | M | The map of Flares from which to select |
M
extends Record
<string
| number
, Flare
<infer A>> ? (key
: keyof M
) => Flare
<A
> : never
A function that returns the Flare from the map
corresponding to the
specified key
Remarks
This is typically used with chain.
▸ of<A
>(a
): Flare
<A
>
Lifts a value into a Flare
context.
Name | Description |
---|---|
A | The value to lift |
Name | Type | Description |
---|---|---|
a | A | The value to lift |
Flare
<A
>
A Flare that produces the specified value a
▸ radioGroup<A
, C
>(options
): Flare
<A
>
Creates a Flare that renders as a group of radio buttons.
Name | Type | Description |
---|---|---|
A | A | The value that the radio button group produces |
C | extends { optionToString? : undefined } | { optionToString : (option : A ) => string } | An additional optionToString option, required to convert A to string when it doesn't already extend string |
Name | Type | Description |
---|---|---|
options | { initial : A ; label? : string ; options : readonly A [] } & C | Radio group options |
Flare
<A
>
The Flare that was created
▸ resizableList<A
>(options
): Flare
<A
[]>
Creates a Flare that renders as a resizable list of Flares.
Name |
---|
A |
Name | Type | Description |
---|---|---|
options | Object | Resizable list options |
options.initial? | Flare <A >[] | The initial list of Flares |
options.item | Flare <A > | The Flare used each time an item is added to the list |
options.maxLength? | number | The maximum length of the list |
options.minLength? | number | The minimum length of the list |
Flare
<A
[]>
The Flare that was created
▸ runFlare(controlsElementId
, targetElementId
, flare
): void
Runs the specified Flare, rendering its HTML output to the target element.
Name | Type | Description |
---|---|---|
controlsElementId | string | The id of the element in which to render the Flare controls |
targetElementId | string | The id of the element in which to render the HTML output |
flare | Flare <HTML > | The Flare to run |
void
▸ runFlareWith<A
>(controlsElementId
, handler
, flare
): void
Runs the specified Flare, invoking the handler on each change.
Name | Description |
---|---|
A | The value produced by the Flare |
Name | Type | Description |
---|---|---|
controlsElementId | string | The id of the element in which to render the Flare controls |
handler | (a : A ) => void | The callback function to invoke each time the value changes |
flare | Flare <A > | The Flare to run |
void
▸ slider(options
): Flare
<number
>
Creates a Flare that renders as a slider.
Name | Type | Description |
---|---|---|
options | Object | Slider options |
options.initial | number | Initial slider state |
options.label? | string | Slider label |
options.max? | number | Maximum selectable value |
options.min? | number | Minimum selectable value |
options.step? | number | The granularity of the slider value |
Flare
<number
>
The Flare that was created
▸ spinButton(options
): Flare
<number
>
Creates a Flare that renders as a spin button.
Name | Type | Description |
---|---|---|
options | Object | Spin button options |
options.initial | number | Initial spin button state |
options.label? | string | Spin button label |
options.max? | number | Maximum selectable value |
options.min? | number | Minimum selectable value |
options.step? | number | The granularity of the spin button value |
Flare
<number
>
The Flare that was created
▸ switch_(options
): Flare
<boolean
>
Creates a Flare that renders as a switch.
Name | Type | Description |
---|---|---|
options | Object | Switch options |
options.initial | boolean | Initial switch state |
options.label? | string | Switch label |
Flare
<boolean
>
The Flare that was created
▸ textBox(options
): Flare
<string
>
Creates a Flare that renders as a text box.
Name | Type | Description |
---|---|---|
options | Object | Text box options |
options.initial | string | Initial text box state |
options.label? | string | Text box label |
options.nonEmpty? | boolean | - |
Flare
<string
>
The Flare that was created