Erabi (Erabi v0.1.0)

Copy Markdown View Source

Pickers for Phoenix LiveView: select, multi_select, combobox, tags, person_picker and color_picker, in Erabi.Components.

Each picker is a field of a form: it posts what the browser's own control would, works with Phoenix.HTML.FormField and changesets, and is the browser's own control until its hook mounts. Its options are the app's (see Erabi.Option), or come from a search on the server (Erabi.Live). Its rules (Erabi.Rules) hold in the browser, as people choose, and on the server, in Erabi.Changeset.

Summary

Functions

A picker as the editor of a grid's cells, for a column of Masu: the editor of the column, with its options, rules and words.

The options of anything a picker takes; see Erabi.Option.list/1.

Functions

cell_editor(kind, opts \\ [])

@spec cell_editor(atom(), keyword()) :: {String.t(), map()}

A picker as the editor of a grid's cells, for a column of Masu: the editor of the column, with its options, rules and words.

<:col field={:labels} editor={Erabi.cell_editor(:multi_select, options: @labels, max: 3)} />

The browser's half registers the editors once, in the app's JavaScript:

import { configure } from "masu"
import { erabiEditors } from "erabi"

configure({ editors: erabiEditors() })

The kinds are :select, :multi_select, :combobox, :tags, :person (with multiple: true for several people), :color and :emoji. The options are those of the components: options, rules and its shortcuts (min, max, create, required), filter, me, placeholder, locale and messages; for :color, palette, custom and contrast, as Erabi.Components.color_picker/1 takes them; and for :emoji, tones. A picker of one value saves it as it is chosen; one of several, when the editor closes, as the grid's own editors do; a color, when its popup closes, so that a drag in its area saves once.

The color and emoji editors are in their pickers' entries, which the app imports too (import "erabi/color", import "erabi/emoji"); without them, such a column is a select of its options.

options(options)

@spec options(term()) :: [Erabi.Option.t()]

The options of anything a picker takes; see Erabi.Option.list/1.