src/datastar_gleam@lustre.erl

-module(datastar_gleam@lustre).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/datastar_gleam/lustre.gleam").
-export([on_get/1, on_post/1, signal/2, bind/1, text/1, attr/2, class/1]).

-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.

-file("src/datastar_gleam/lustre.gleam", 11).
?DOC(
    " `data-on:click=\"@get('/path')\"`\n"
    "\n"
    " Trigger a GET request to `path` when the element is clicked.\n"
).
-spec on_get(binary()) -> lustre@vdom@vattr:attribute(any()).
on_get(Path) ->
    lustre@attribute:attribute(
        <<"data-on:click"/utf8>>,
        <<<<"@get('"/utf8, Path/binary>>/binary, "')"/utf8>>
    ).

-file("src/datastar_gleam/lustre.gleam", 18).
?DOC(
    " `data-on:click=\"@post('/path')\"`\n"
    "\n"
    " Trigger a POST request to `path` when the element is clicked.\n"
).
-spec on_post(binary()) -> lustre@vdom@vattr:attribute(any()).
on_post(Path) ->
    lustre@attribute:attribute(
        <<"data-on:click"/utf8>>,
        <<<<"@post('"/utf8, Path/binary>>/binary, "')"/utf8>>
    ).

-file("src/datastar_gleam/lustre.gleam", 25).
?DOC(
    " `data-signals:key=\"value\"`\n"
    "\n"
    " Initialise a reactive signal with the given key and value.\n"
).
-spec signal(binary(), binary()) -> lustre@vdom@vattr:attribute(any()).
signal(Key, Value) ->
    lustre@attribute:attribute(<<"data-signals:"/utf8, Key/binary>>, Value).

-file("src/datastar_gleam/lustre.gleam", 32).
?DOC(
    " `data-bind:key`\n"
    "\n"
    " Two-way bind the element's value to the signal named `key`.\n"
).
-spec bind(binary()) -> lustre@vdom@vattr:attribute(any()).
bind(Key) ->
    lustre@attribute:attribute(<<"data-bind:"/utf8, Key/binary>>, <<""/utf8>>).

-file("src/datastar_gleam/lustre.gleam", 39).
?DOC(
    " `data-text=\"$key\"`\n"
    "\n"
    " Set the element's text content to the value of the signal `key`.\n"
).
-spec text(binary()) -> lustre@vdom@vattr:attribute(any()).
text(Key) ->
    lustre@attribute:attribute(<<"data-text"/utf8>>, <<"$"/utf8, Key/binary>>).

-file("src/datastar_gleam/lustre.gleam", 46).
?DOC(
    " `data-attr:disabled=\"$condition\"`\n"
    "\n"
    " Toggle an HTML attribute based on a signal expression.\n"
).
-spec attr(binary(), binary()) -> lustre@vdom@vattr:attribute(any()).
attr(Name, Expression) ->
    lustre@attribute:attribute(<<"data-attr:"/utf8, Name/binary>>, Expression).

-file("src/datastar_gleam/lustre.gleam", 53).
?DOC(
    " `data-class=\"{ 'class-name': $condition }\"`\n"
    "\n"
    " Toggle CSS classes based on a signal expression.\n"
).
-spec class(binary()) -> lustre@vdom@vattr:attribute(any()).
class(Expression) ->
    lustre@attribute:attribute(<<"data-class"/utf8>>, Expression).