# `Dala.Spark.Dsl`
[🔗](https://github.com/manhvu/dala/blob/main/lib/dala/spark/dsl.ex#L1)

Spark DSL for declarative Dala screens.

Defines attributes for screen state and UI component entities that mirror
`Dala.Ui.Component` one-to-one. All entity structs and definitions are
auto-generated from the central component registry via `Dala.Spark.Dsl.Entities`.
Container entities support nested children via Spark's `entities` + `recursive_as`.

## Usage

    defmodule MyApp.CounterScreen do
      use Dala.Spark.Dsl

      dala do
        attribute :count, :integer, default: 0

        screen name: :counter do
          column padding: :space_md, gap: :space_sm do
            text "Count: @count", text_size: :xl
            button "Increment", on_tap: :increment
          end
        end
      end

      def handle_event(:increment, _params, socket) do
        {:noreply, Dala.Socket.assign(socket, :count, socket.assigns.count + 1)}
      end
    end

### Options

* `:extensions` (list of module that adopts `Spark.Dsl.Extension`) - A list of DSL extensions to add to the `Spark.Dsl`

* `:dala` (list of module that adopts `Spark.Dsl.Extension`) - dala extensions to add to the `Spark.Dsl` The default value is `[]`.

* `:otp_app` (`t:atom/0`) - The otp_app to use for any application configurable options

* `:fragments` (list of `t:module/0`) - Fragments to include in the `Spark.Dsl`. See the fragments guide for more.

# `attributes`
*macro* 

# `dala`
*macro* 

Legacy wrapper block — deprecated, kept for backward compatibility.

Write the sections flat at the module top level instead:

    attributes do
      attribute :count, :integer, default: 0
    end

    screen name: :counter do
      text "Count: @count"
    end

# `defui`
*macro* 

Define a reusable local UI fragment inside a screen module.

    defui card_header(title) do
      row gap: :space_sm do
        text title, variant: :title
        spacer()
      end
    end

    screen name: :settings do
      column do
        card_header("Settings")
        text "Body"
      end
    end

The body is parsed with the same rules as a `screen` block: `@ref`s,
`compute(fn assigns -> ... end)` and `for` loops all work. `@ref`s resolve
against the *caller's* assigns at render time. The function must be defined
above its first use in the screen block (the parser resolves call sites at
compile time). Event handlers referenced inside a `defui` body are not seen
by compile-time handler verification.

# `ensure_extensions`

# `pubsub`
*macro* 

# `screen`
*macro* 

# `screen`
*macro* 

# `verify`

```elixir
@spec verify(module()) :: [Dala.Spark.DslVerifier.warning()]
```

Verify the DSL definitions of a screen module.

Returns a list of warnings and errors found in the module's DSL.

    Dala.Spark.Dsl.verify(MyApp.HomeScreen)
    # => [%{type: :warning, module: MyApp.HomeScreen, line: 12, message: "..."}]

See `Dala.Spark.DslVerifier` for detailed verification logic.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
