CinderUI.JS (cinder_ui v0.1.0)

Copy Markdown View Source

LiveView JS helpers for controlling interactive Cinder UI components.

These helpers dispatch the shared cinder-ui:command event used by commandable hooks such as dialogs, popovers, dropdown menus, selects, autocompletes, and comboboxes.

Example

<button phx-click={CinderUI.JS.open(to: "#account-dialog")}>
  Open dialog
</button>

<button phx-click={CinderUI.JS.clear(to: "#owner-autocomplete")}>
  Clear owner
</button>

Summary

Functions

Dispatches a clear command.

Dispatches a close command.

Dispatches a Cinder UI command event to the given selector.

Dispatches a focus command.

Dispatches an open command.

Dispatches a toggle command.

Types

command()

@type command() :: :open | :close | :toggle | :focus | :clear | String.t() | atom()

Functions

clear(opts)

@spec clear(keyword()) :: Phoenix.LiveView.JS.t()

Dispatches a clear command.

clear(js \\ %JS{}, opts \\ [])

close(opts)

@spec close(keyword()) :: Phoenix.LiveView.JS.t()

Dispatches a close command.

close(js \\ %JS{}, opts \\ [])

dispatch_command(command, opts)

@spec dispatch_command(
  command(),
  keyword()
) :: Phoenix.LiveView.JS.t()

Dispatches a Cinder UI command event to the given selector.

Options

  • :to - required DOM selector that identifies the component root.
  • :detail - additional event detail merged into the command payload.

dispatch_command(js \\ %JS{}, command, opts \\ [])

@spec dispatch_command(Phoenix.LiveView.JS.t(), command(), keyword()) ::
  Phoenix.LiveView.JS.t()

focus(opts)

@spec focus(keyword()) :: Phoenix.LiveView.JS.t()

Dispatches a focus command.

focus(js \\ %JS{}, opts \\ [])

open(opts)

@spec open(keyword()) :: Phoenix.LiveView.JS.t()

Dispatches an open command.

open(js \\ %JS{}, opts \\ [])

toggle(opts)

@spec toggle(keyword()) :: Phoenix.LiveView.JS.t()

Dispatches a toggle command.

toggle(js \\ %JS{}, opts \\ [])