Dala.Ui.Component (dala v0.1.3)

Copy Markdown View Source

Central registry of all Dala UI components.

This is the SINGLE SOURCE OF TRUTH for:

  • Component names and type atoms
  • Allowed props per component
  • Default props
  • Component category (:leaf vs :container)
  • Human-readable documentation

All other modules (Widgets, DSL, Renderer, Diff, DevTools) derive their component knowledge from this module. To add a new component, define it here and all other modules pick it up automatically.

Summary

Functions

Get all components as a keyword list

Get container components as a keyword list

Get a single component by name

Get leaf components as a keyword list

Get the prop schema for a component by name

Get the props list for a component by name

Apply a component's transform function to props

Types

category()

@type category() :: :leaf | :container

t()

@type t() :: %Dala.Ui.Component{
  category: category(),
  children_key: atom() | nil,
  defaults: map(),
  doc: String.t(),
  examples: [String.t()],
  name: atom(),
  props: [atom()],
  transform: (map() -> map()) | nil,
  type: atom()
}

Functions

all()

@spec all() :: [{atom(), t()}]

Get all components as a keyword list

container_components()

@spec container_components() :: [{atom(), t()}]

Get container components as a keyword list

get(name)

@spec get(atom()) :: t() | nil

Get a single component by name

leaf_components()

@spec leaf_components() :: [{atom(), t()}]

Get leaf components as a keyword list

prop_schema(name)

@spec prop_schema(atom()) :: [{atom(), keyword()}]

Get the prop schema for a component by name

props(name)

@spec props(atom()) :: [atom()]

Get the props list for a component by name

transform_props(name, props)

@spec transform_props(atom(), map()) :: map()

Apply a component's transform function to props