Flare

flare-core

npm install flare-core
yarn add flare-core

flare-core

Table of contents

Type Aliases

Functions

Type Aliases

Button

Ƭ Button: ComponentType<ButtonProps>

The React component used to render a button

Defined in

index.tsx:299


ButtonProps

Ƭ ButtonProps: Object

The props of the React component used to render a button

Type declaration

NameTypeDescription
childrenReactNodeThe content of the button *
disabled?booleanWhether the button should be disabled Remarks For example, this is used in resizable lists when adding or removing an item would exceed the minimum or maximum allowed list length.
onClick() => voidThe callback to invoke when the button is clicked *

Defined in

index.tsx:281


Checkbox

Ƭ Checkbox: ComponentType<CheckboxProps>

The React component used to render a checkbox

Defined in

index.tsx:314


CheckboxProps

Ƭ CheckboxProps: Object

The props of the React component used to render a checkbox

Type declaration

NameTypeDescription
checkedbooleanWhether the checkbox is checked
label?stringThe label to display next to the checkbox
onCheckedChange(checked: boolean) => voidThe callback to invoke when the checked state changes

Defined in

index.tsx:302


ComboBox

Ƭ ComboBox: ComponentType<ComboBoxProps>

The React component used to render a combo box

Defined in

index.tsx:332


ComboBoxProps

Ƭ ComboBoxProps: Object

The props of the React component used to render a combo box

Type declaration

NameTypeDescription
label?stringThe label to display next to the combo box
onValueChange(value: string) => voidThe callback to invoke when the selected value changes
optionsstring[]The list of available options
valuestringThe selected value

Defined in

index.tsx:317


ComponentType

Ƭ ComponentType<P>: ComponentClass<P> | VoidFunctionComponent<P>

A React component

Remarks

This varies from the ComponentType alias in the @types/react package in that it does not implicitly add a children prop.

Type parameters

NameTypeDescription
PRecord<string, unknown>Component props

Defined in

index.tsx:276


Components

Ƭ Components: Object

The React components used to render various Flares

Remarks

These can be customized through the components prop of the RunFlare component.

Type declaration

NameTypeDescription
ButtonButtonThe React component used to render a button
CheckboxCheckboxThe React component used to render a checkbox
ComboBoxComboBoxThe React component used to render a combo box
RadioGroupRadioGroupThe React component used to render a group of radio buttons
ResizableListResizableListThe React component used to render a resizable list
ResizableListItemResizableListItemThe React component used to render a resizable list item
SliderSliderThe React component used to render a slider
SpinButtonSpinButtonThe React component used to render a spin button
SwitchSwitchThe React component used to render a switch
TextBoxTextBoxThe React component used to render a text box

Defined in

index.tsx:658


Flare

Ƭ 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

Type parameters

NameDescription
AThe value the Flare produces

Type declaration

NameTypeDescription
_tag"Flare"Tags the object as a Flare.
make() => { query: () => A ; render: VoidFunctionComponent<{ onChange: () => void }> }Initializes the Flare.

Defined in

index.tsx:20


RadioGroup

Ƭ RadioGroup: ComponentType<RadioGroupProps>

The React component used to render a group of radio buttons

Defined in

index.tsx:377


RadioGroupProps

Ƭ RadioGroupProps: Object

The props of the React component used to render a group of radio buttons

Type declaration

NameTypeDescription
label?stringThe label to display next to the group of radio buttons
onValueChange(value: string) => voidThe callback to invoke when the selected value changes
optionsstring[]The list of available options
valuestringThe selected value

Defined in

index.tsx:362


ResizableList

Ƭ ResizableList: ComponentType<ResizableListProps>

The React component used to render a resizable list

Defined in

index.tsx:344


ResizableListItem

Ƭ ResizableListItem: ComponentType<ResizableListItemProps>

The React component used to render a resizable list item

Defined in

index.tsx:359


ResizableListItemProps

Ƭ ResizableListItemProps: Object

The props of the React component used to render a resizable list item

Type declaration

NameTypeDescription
addButtonReactNodeThe button used to add an item before the current item
childrenReactNodeThe main content of the item
removeButtonReactNodeThe button used to remove the item

Defined in

index.tsx:347


ResizableListProps

Ƭ ResizableListProps: Object

The props of the React component used to render a resizable list

Type declaration

NameTypeDescription
addButtonReactNodeThe button used to add an item to the end of the list
childrenReactNodeThe current list of items

Defined in

index.tsx:335


RunFlareProps

Ƭ RunFlareProps<A>: Object

RunFlare component props

Type parameters

NameDescription
AThe value produced by the Flare

Type declaration

NameTypeDescription
components?Partial<Components>Component overrides
flareFlare<A>The Flare to run
handler(a: A) => voidThe procedure to run when the value changes

Defined in

index.tsx:710


Slider

Ƭ Slider: ComponentType<SliderProps>

The React component used to render a slider

Defined in

index.tsx:401


SliderProps

Ƭ SliderProps: Object

The props of the React component used to render a slider

Type declaration

NameTypeDescription
label?stringThe label to display next to the slider
max?numberThe maximum value that can be selected
min?numberThe minimum value that can be selected
onValueChange(value: number) => voidThe callback to invoke when the selected value changes
step?numberThe granularity of the selected value
valuenumberThe selected value

Defined in

index.tsx:380


SpinButton

Ƭ SpinButton: ComponentType<SpinButtonProps>

The React component used to render a spin button

Defined in

index.tsx:425


SpinButtonProps

Ƭ SpinButtonProps: Object

The props of the React component used to render a spin button

Type declaration

NameTypeDescription
label?stringThe label to display next to the spin button
max?numberThe maximum value that can be selected
min?numberThe minimum value that can be selected
onValueChange(value: number) => voidThe callback to invoke when the selected value changes
step?numberThe granularity of the selected value
valuenumberThe selected value

Defined in

index.tsx:404


Switch

Ƭ Switch: ComponentType<SwitchProps>

The React component used to render a switch

Defined in

index.tsx:440


SwitchProps

Ƭ SwitchProps: Object

The props of the React component used to render a switch

Type declaration

NameTypeDescription
checkedbooleanWhether the switch is toggled on
label?stringThe label to display next to the switch
onCheckedChange(checked: boolean) => voidThe callback to invoke when the switch is toggled

Defined in

index.tsx:428


TextBox

Ƭ TextBox: ComponentType<TextBoxProps>

The React component used to render a text box

Defined in

index.tsx:455


TextBoxProps

Ƭ TextBoxProps: Object

The props of the React component used to render a text box

Type declaration

NameTypeDescription
label?stringThe label to display next to the text box
onValueChange(value: string) => voidThe callback to invoke when the value changes
valuestringThe value

Defined in

index.tsx:443


Unflare

Ƭ 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.

Type parameters

NameDescription
FThe Flare<A> from which to extract A

Defined in

index.tsx:56

Functions

RunFlare

RunFlare<A>(props): ReactElement

A React component that renders the specified Flare.

Type parameters

Name
A

Parameters

NameType
propsRunFlareProps<A>

Returns

ReactElement

Defined in

index.tsx:724


ap

ap<A, B>(fa): (fab: Flare<(a: A) => B>) => Flare<B>

Applies a function to a value within a Flare context.

Type parameters

NameDescription
AThe value to which to apply the function
BThe return value of the function

Parameters

NameTypeDescription
faFlare<A>The Flare that produces the original value

Returns

fn

A Flare that produces the result of the function application

▸ (fab): Flare<B>

Parameters
NameType
fabFlare<(a: A) => B>
Returns

Flare<B>

Defined in

index.tsx:69


chain

chain<A, B>(afb): (fa: Flare<A>) => Flare<B>

Composes Flares in a sequence.

Type parameters

NameDescription
AThe value produced by the first Flare
BThe value produced by the second Flare

Parameters

NameTypeDescription
afb(a: A) => Flare<B>The function to apply to the output of the first Flare to produce the second Flare

Returns

fn

The Flare resulting from the composition

▸ (fa): Flare<B>

Parameters
NameType
faFlare<A>
Returns

Flare<B>

Defined in

index.tsx:103


checkbox

checkbox(options): Flare<boolean>

Creates a Flare that renders as a checkbox control.

Parameters

NameTypeDescription
optionsObjectCheckbox options
options.initialbooleanInitial checked state
options.label?stringCheckbox label

Returns

Flare<boolean>

The Flare that was created

Defined in

index.tsx:239


comboBox

comboBox<A, C>(options): Flare<A>

Creates a Flare that renders as a combo box.

Type parameters

NameTypeDescription
AAThe value that the combo box produces
Cextends { optionToString?: undefined } | { optionToString: (option: A) => string }An additional optionToString option, required to convert A to string when it doesn't already extend string

Parameters

NameTypeDescription
options{ initial: A ; label?: string ; options: readonly A[] } & CCombo box options

Returns

Flare<A>

The Flare that was created

Defined in

index.tsx:779


ifElse

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.

Type parameters

NameDescription
AThe value produced by the first Flare
BThe value produced by the second Flare

Parameters

NameTypeDescription
aFlare<A>The value produced by the first Flare
bFlare<B>The value produced by the second Flare

Returns

fn

The first Flare when the boolean expession is true; otherwise, the second Flare

▸ (cond): Flare<A | B>

Parameters
NameType
condboolean
Returns

Flare<A | B>

Remarks

This is typically used with chain.

Defined in

index.tsx:190


makeFlare

makeFlare<O, A>(Component): (options: O extends { initial: A } ? O : never) => Flare<A>

Turns an ordinary React component into a function that produces a Flare.

Type parameters

NameTypeDescription
OOFlare options, forwarded to the component as props
AO extends { initial: X } ? X : neverThe value the Flare produces

Parameters

NameTypeDescription
Component(props: Omit<O, "initial"> & { onChange: (value: A) => void ; value: A }) => ElementThe React component to turn into a Flare

Returns

fn

A Flare that renders as the provided React component

▸ (options): Flare<A>

Parameters
NameType
optionsO extends { initial: A } ? O : never
Returns

Flare<A>

Remarks

This is primarily intended for internal use. Before creating custom Flares, consider using CSS to customize existing elements or using the components prop of RunFlare.

Defined in

index.tsx:234


map

map<A, B>(ab): (fa: Flare<A>) => Flare<B>

Applies a function to a Flare to change its output.

Type parameters

NameDescription
AThe value produced by the original Flare
BThe value produced by the modified Flare

Parameters

NameTypeDescription
ab(a: A) => BThe function to apply to the output of the original Flare

Returns

fn

A Flare that produces the result of the function application

▸ (fa): Flare<B>

Parameters
NameType
faFlare<A>
Returns

Flare<B>

Defined in

index.tsx:141


match

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.

Type parameters

NameDescription
MThe map of Flares from which to select

Parameters

NameTypeDescription
mapMThe map of Flares from which to select

Returns

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.

Defined in

index.tsx:210


of

of<A>(a): Flare<A>

Lifts a value into a Flare context.

Type parameters

NameDescription
AThe value to lift

Parameters

NameTypeDescription
aAThe value to lift

Returns

Flare<A>

A Flare that produces the specified value a

Defined in

index.tsx:163


radioGroup

radioGroup<A, C>(options): Flare<A>

Creates a Flare that renders as a group of radio buttons.

Type parameters

NameTypeDescription
AAThe value that the radio button group produces
Cextends { optionToString?: undefined } | { optionToString: (option: A) => string }An additional optionToString option, required to convert A to string when it doesn't already extend string

Parameters

NameTypeDescription
options{ initial: A ; label?: string ; options: readonly A[] } & CRadio group options

Returns

Flare<A>

The Flare that was created

Defined in

index.tsx:821


resizableList

resizableList<A>(options): Flare<A[]>

Creates a Flare that renders as a resizable list of Flares.

Type parameters

Name
A

Parameters

NameTypeDescription
optionsObjectResizable list options
options.initial?Flare<A>[]The initial list of Flares
options.itemFlare<A>The Flare used each time an item is added to the list
options.maxLength?numberThe maximum length of the list
options.minLength?numberThe minimum length of the list

Returns

Flare<A[]>

The Flare that was created

Defined in

index.tsx:994


slider

slider(options): Flare<number>

Creates a Flare that renders as a slider.

Parameters

NameTypeDescription
optionsObjectSlider options
options.initialnumberInitial slider state
options.label?stringSlider label
options.max?numberMaximum selectable value
options.min?numberMinimum selectable value
options.step?numberThe granularity of the slider value

Returns

Flare<number>

The Flare that was created

Defined in

index.tsx:239


spinButton

spinButton(options): Flare<number>

Creates a Flare that renders as a spin button.

Parameters

NameTypeDescription
optionsObjectSpin button options
options.initialnumberInitial spin button state
options.label?stringSpin button label
options.max?numberMaximum selectable value
options.min?numberMinimum selectable value
options.step?numberThe granularity of the spin button value

Returns

Flare<number>

The Flare that was created

Defined in

index.tsx:239


switch_

switch_(options): Flare<boolean>

Creates a Flare that renders as a switch.

Parameters

NameTypeDescription
optionsObjectSwitch options
options.initialbooleanInitial switch state
options.label?stringSwitch label

Returns

Flare<boolean>

The Flare that was created

Defined in

index.tsx:239


textBox

textBox(options): Flare<string>

Creates a Flare that renders as a text box.

Parameters

NameTypeDescription
optionsObjectText box options
options.initialstringInitial text box state
options.label?stringText box label
options.nonEmpty?boolean-

Returns

Flare<string>

The Flare that was created

Defined in

index.tsx:239

Flare

Applicative-style UIs in TypeScript

Get started
npm install flare
yarn add flare

Flare