Current section
Files
Jump to
Current section
Files
src/hx.erl
-module(hx).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/hx.gleam").
-export([get/1, post/1, put/1, patch/1, delete/1, select/1, select_oob/1, push_url/1, confirm/1, boost/1, vals/2, disable/0, disinherit/1, disinherit_all/0, encoding/1, ext/1, headers/2, history/1, history_elt/0, inherit/1, inherit_all/0, params/1, preserve/0, prompt/1, replace_url/0, no_replace_url/0, replace_url_with/1, request/1, validate/1, hyper_script/1, on/2, load/0, dom_content_loaded/0, click/0, change/0, submit/0, keyup/0, keydown/0, focus/0, blur/0, mouseover/0, mouseout/0, input/0, scroll/0, resize/0, htmx_before_request/0, htmx_after_request/0, htmx_before_swap/0, htmx_after_swap/0, htmx_before_settle/0, htmx_after_settle/0, htmx_load/0, htmx_config_request/0, htmx_response_error/0, htmx_send_error/0, htmx_timeout/0, htmx_confirm/0, htmx_before_send/0, htmx_validate_url/0, htmx_before_on_load/0, htmx_after_on_load/0, htmx_send_abort/0, htmx_abort/0, htmx_validation_validate/0, htmx_validation_failed/0, htmx_validation_halted/0, htmx_xhr_abort/0, htmx_xhr_loadend/0, htmx_xhr_loadstart/0, htmx_xhr_progress/0, htmx_before_process_node/0, htmx_after_process_node/0, htmx_before_cleanup_element/0, htmx_before_transition/0, htmx_trigger/0, htmx_oob_before_swap/0, htmx_oob_after_swap/0, htmx_oob_error_no_target/0, htmx_swap_error/0, htmx_error/0, htmx_history_item_created/0, htmx_history_cache_error/0, htmx_before_history_save/0, htmx_before_history_update/0, htmx_history_restore/0, htmx_pushed_into_history/0, htmx_replaced_in_history/0, htmx_restored/0, htmx_history_cache_hit/0, htmx_history_cache_miss/0, htmx_history_cache_miss_load/0, htmx_history_cache_miss_load_error/0, htmx_event_filter_error/0, htmx_syntax_error/0, htmx_bad_response_url/0, htmx_invalid_path/0, htmx_on_load_error/0, htmx_target_error/0, htmx_eval_disallowed_error/0, htmx_prompt/0, htmx_session_storage_test/0, revealed/0, intersect/1, intersect_once/1, custom/1, with_delay/2, with_throttle/2, with_once/1, with_changed/1, with_from/2, with_target/2, with_consume/1, with_queue/2, indicator/1, target/1, disable_elt/1, include/1, duration_to_string/1, trigger_polling/3, trigger/1, swap/1, swap_with/2, swap_oob/2, swap_oob_with/3, sync_option_to_string/1, sync/1]).
-export_type([event/0, event_modifier/0, intersect_config/0, queue/0, selector/0, sync/0, swap/0, scroll_position/0, scroll_target/0, show_target/0, swap_config/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" # hx - Gleam HTMX Bindings\n"
"\n"
" Type-safe Gleam bindings for HTMX attributes and events.\n"
"\n"
" ## Links\n"
" - [HTMX Documentation](https://htmx.org/)\n"
" - [HTMX Attributes Reference](https://htmx.org/reference/#attributes)\n"
" - [HTMX Events Reference](https://htmx.org/reference/#events)\n"
"\n"
" ## Basic Usage\n"
"\n"
" ```gleam\n"
" import hx\n"
" import lustre/element/html\n"
"\n"
" html.button([\n"
" hx.get(\"/api/users\"),\n"
" hx.target(hx.CssSelector(\"#results\")),\n"
" hx.swap(hx.InnerHTML),\n"
" ], [html.text(\"Load Users\")])\n"
" ```\n"
).
-opaque event() :: {event, binary(), list(event_modifier())}.
-opaque event_modifier() :: once |
changed |
{delay, gleam@time@duration:duration()} |
{throttle, gleam@time@duration:duration()} |
{from, selector()} |
{target, binary()} |
consume |
{queue_event, gleam@option:option(queue())}.
-type intersect_config() :: {root, binary()} | {threshold, float()}.
-type queue() :: first | last | all.
-type selector() :: {selector, binary()} |
document |
window |
{closest, binary()} |
{find, binary()} |
{next, binary()} |
{previous, binary()} |
this.
-type sync() :: {default, selector()} |
{drop, selector()} |
{abort, selector()} |
{replace, selector()} |
{queue, selector(), queue()}.
-type swap() :: inner_h_t_m_l |
outer_h_t_m_l |
text_content |
afterbegin |
beforebegin |
beforeend |
afterend |
delete |
swap_none.
-type scroll_position() :: top | bottom.
-type scroll_target() :: {target_scroll, scroll_position()} |
{element_scroll, binary(), scroll_position()} |
{window_scroll, scroll_position()}.
-type show_target() :: {target_show, scroll_position()} |
{element_show, binary(), scroll_position()} |
{window_show, scroll_position()}.
-type swap_config() :: {transition, boolean()} |
{swap_timing, gleam@time@duration:duration()} |
{settle, gleam@time@duration:duration()} |
{ignore_title, boolean()} |
{scroll_to, scroll_target()} |
{show, show_target()} |
{focus_scroll, boolean()}.
-file("src/hx.gleam", 96).
?DOC(
" Issues a GET request to the given URL when the element is triggered.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-get/)\n"
).
-spec get(binary()) -> lustre@vdom@vattr:attribute(any()).
get(Url) ->
lustre@attribute:attribute(<<"hx-get"/utf8>>, Url).
-file("src/hx.gleam", 103).
?DOC(
" Issues a POST request to the given URL when the element is triggered.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-post/)\n"
).
-spec post(binary()) -> lustre@vdom@vattr:attribute(any()).
post(Url) ->
lustre@attribute:attribute(<<"hx-post"/utf8>>, Url).
-file("src/hx.gleam", 110).
?DOC(
" Issues a PUT request to the given URL when the element is triggered.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-put/)\n"
).
-spec put(binary()) -> lustre@vdom@vattr:attribute(any()).
put(Url) ->
lustre@attribute:attribute(<<"hx-put"/utf8>>, Url).
-file("src/hx.gleam", 117).
?DOC(
" Issues a PATCH request to the given URL when the element is triggered.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-patch/)\n"
).
-spec patch(binary()) -> lustre@vdom@vattr:attribute(any()).
patch(Url) ->
lustre@attribute:attribute(<<"hx-patch"/utf8>>, Url).
-file("src/hx.gleam", 124).
?DOC(
" Issues a DELETE request to the given URL when the element is triggered.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-delete/)\n"
).
-spec delete(binary()) -> lustre@vdom@vattr:attribute(any()).
delete(Url) ->
lustre@attribute:attribute(<<"hx-delete"/utf8>>, Url).
-file("src/hx.gleam", 259).
?DOC(
" Selects a subset of the server response to process.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-select/)\n"
).
-spec select(binary()) -> lustre@vdom@vattr:attribute(any()).
select(Css_selector) ->
lustre@attribute:attribute(<<"hx-select"/utf8>>, Css_selector).
-file("src/hx.gleam", 268).
?DOC(
" Selects content from a response to be swapped in out-of-band.\n"
"\n"
" Accepts a comma-separated list of CSS selectors for elements to swap out-of-band.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-select-oob/)\n"
).
-spec select_oob(list(binary())) -> lustre@vdom@vattr:attribute(any()).
select_oob(Css_selectors) ->
Selectors = begin
_pipe = Css_selectors,
gleam@string:join(_pipe, <<","/utf8>>)
end,
lustre@attribute:attribute(<<"hx-select-oob"/utf8>>, Selectors).
-file("src/hx.gleam", 276).
?DOC(
" Pushes a URL into the browser's location bar and history.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-push-url/)\n"
).
-spec push_url(boolean()) -> lustre@vdom@vattr:attribute(any()).
push_url(Bool) ->
case Bool of
true ->
lustre@attribute:attribute(<<"hx-push-url"/utf8>>, <<"true"/utf8>>);
false ->
lustre@attribute:attribute(<<"hx-push-url"/utf8>>, <<"false"/utf8>>)
end.
-file("src/hx.gleam", 286).
?DOC(
" Shows a confirmation dialog before making a request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-confirm/)\n"
).
-spec confirm(binary()) -> lustre@vdom@vattr:attribute(any()).
confirm(Confirm_text) ->
lustre@attribute:attribute(<<"hx-confirm"/utf8>>, Confirm_text).
-file("src/hx.gleam", 293).
?DOC(
" Progressive enhancement for links and forms using AJAX.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-boost/)\n"
).
-spec boost(boolean()) -> lustre@vdom@vattr:attribute(any()).
boost(Set) ->
case Set of
true ->
lustre@attribute:attribute(<<"hx-boost"/utf8>>, <<"true"/utf8>>);
false ->
lustre@attribute:attribute(<<"hx-boost"/utf8>>, <<"false"/utf8>>)
end.
-file("src/hx.gleam", 303).
?DOC(
" Adds values to be submitted with the request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-vals/)\n"
).
-spec vals(gleam@json:json(), boolean()) -> lustre@vdom@vattr:attribute(any()).
vals(Json, Compute_value) ->
case Compute_value of
true ->
lustre@attribute:attribute(
<<"hx-vals"/utf8>>,
<<"js:"/utf8, (gleam@json:to_string(Json))/binary>>
);
false ->
lustre@attribute:attribute(
<<"hx-vals"/utf8>>,
gleam@json:to_string(Json)
)
end.
-file("src/hx.gleam", 313).
?DOC(
" Disables HTMX processing for an element and its children.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-disable/)\n"
).
-spec disable() -> lustre@vdom@vattr:attribute(any()).
disable() ->
lustre@attribute:attribute(<<"hx-disable"/utf8>>, <<""/utf8>>).
-file("src/hx.gleam", 343).
?DOC(
" Controls which attributes are not inherited from parent elements.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-disinherit/)\n"
).
-spec disinherit(list(binary())) -> lustre@vdom@vattr:attribute(any()).
disinherit(Attributes) ->
Attributes@1 = begin
_pipe = Attributes,
gleam@string:join(_pipe, <<" "/utf8>>)
end,
lustre@attribute:attribute(<<"hx-disinherit"/utf8>>, Attributes@1).
-file("src/hx.gleam", 351).
?DOC(
" Prevents inheritance of all HTMX attributes from ancestors.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-disinherit/)\n"
).
-spec disinherit_all() -> lustre@vdom@vattr:attribute(any()).
disinherit_all() ->
lustre@attribute:attribute(<<"hx-disinherit"/utf8>>, <<"*"/utf8>>).
-file("src/hx.gleam", 358).
?DOC(
" Sets the encoding type for the request (e.g., \"multipart/form-data\").\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-encoding/)\n"
).
-spec encoding(binary()) -> lustre@vdom@vattr:attribute(any()).
encoding(Encoding) ->
lustre@attribute:attribute(<<"hx-encoding"/utf8>>, Encoding).
-file("src/hx.gleam", 365).
?DOC(
" Enables HTMX extensions for an element.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-ext/)\n"
).
-spec ext(list(binary())) -> lustre@vdom@vattr:attribute(any()).
ext(Ext) ->
Ext@1 = begin
_pipe = Ext,
gleam@string:join(_pipe, <<","/utf8>>)
end,
lustre@attribute:attribute(<<"hx-ext"/utf8>>, Ext@1).
-file("src/hx.gleam", 373).
?DOC(
" Adds custom headers to the AJAX request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-headers/)\n"
).
-spec headers(gleam@json:json(), boolean()) -> lustre@vdom@vattr:attribute(any()).
headers(Headers, Compute_value) ->
case Compute_value of
true ->
lustre@attribute:attribute(
<<"hx-headers"/utf8>>,
<<"js:"/utf8, (gleam@json:to_string(Headers))/binary>>
);
false ->
lustre@attribute:attribute(
<<"hx-headers"/utf8>>,
gleam@json:to_string(Headers)
)
end.
-file("src/hx.gleam", 383).
?DOC(
" Controls if requests from this element update browser history.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-history/)\n"
).
-spec history(boolean()) -> lustre@vdom@vattr:attribute(any()).
history(Should_be_saved) ->
case Should_be_saved of
true ->
lustre@attribute:attribute(<<"hx-history"/utf8>>, <<"true"/utf8>>);
false ->
lustre@attribute:attribute(<<"hx-history"/utf8>>, <<"false"/utf8>>)
end.
-file("src/hx.gleam", 393).
?DOC(
" Marks the element to snapshot for history restoration.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-history-elt/)\n"
).
-spec history_elt() -> lustre@vdom@vattr:attribute(any()).
history_elt() ->
lustre@attribute:attribute(<<"hx-history-elt"/utf8>>, <<""/utf8>>).
-file("src/hx.gleam", 407).
?DOC(
" Explicitly inherits specific attributes from parent elements.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-inherit/)\n"
).
-spec inherit(list(binary())) -> lustre@vdom@vattr:attribute(any()).
inherit(Attributes) ->
Attributes@1 = begin
_pipe = Attributes,
gleam@string:join(_pipe, <<" "/utf8>>)
end,
lustre@attribute:attribute(<<"hx-inherit"/utf8>>, Attributes@1).
-file("src/hx.gleam", 415).
?DOC(
" Inherits all HTMX attributes from parent elements.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-inherit/)\n"
).
-spec inherit_all() -> lustre@vdom@vattr:attribute(any()).
inherit_all() ->
lustre@attribute:attribute(<<"hx-inherit"/utf8>>, <<"*"/utf8>>).
-file("src/hx.gleam", 422).
?DOC(
" Filters which parameters are included in the request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-params/)\n"
).
-spec params(binary()) -> lustre@vdom@vattr:attribute(any()).
params(Params) ->
lustre@attribute:attribute(<<"hx-params"/utf8>>, Params).
-file("src/hx.gleam", 429).
?DOC(
" Preserves element state between requests (e.g., iframes, videos).\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-preserve/)\n"
).
-spec preserve() -> lustre@vdom@vattr:attribute(any()).
preserve() ->
lustre@attribute:attribute(<<"hx-preserve"/utf8>>, <<""/utf8>>).
-file("src/hx.gleam", 436).
?DOC(
" Shows an input prompt before submitting the request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-prompt/)\n"
).
-spec prompt(binary()) -> lustre@vdom@vattr:attribute(any()).
prompt(Prompt_text) ->
lustre@attribute:attribute(<<"hx-prompt"/utf8>>, Prompt_text).
-file("src/hx.gleam", 443).
?DOC(
" Replaces the current URL in the browser history.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-replace-url/)\n"
).
-spec replace_url() -> lustre@vdom@vattr:attribute(any()).
replace_url() ->
lustre@attribute:attribute(<<"hx-replace-url"/utf8>>, <<"true"/utf8>>).
-file("src/hx.gleam", 450).
?DOC(
" Prevents URL replacement in the browser history.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-replace-url/)\n"
).
-spec no_replace_url() -> lustre@vdom@vattr:attribute(any()).
no_replace_url() ->
lustre@attribute:attribute(<<"hx-replace-url"/utf8>>, <<"false"/utf8>>).
-file("src/hx.gleam", 457).
?DOC(
" Replaces the current URL with the specified URL.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-replace-url/)\n"
).
-spec replace_url_with(binary()) -> lustre@vdom@vattr:attribute(any()).
replace_url_with(Url) ->
lustre@attribute:attribute(<<"hx-replace-url"/utf8>>, Url).
-file("src/hx.gleam", 464).
?DOC(
" Configures the AJAX request (timeout, credentials, etc.).\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-request/)\n"
).
-spec request(binary()) -> lustre@vdom@vattr:attribute(any()).
request(Request) ->
lustre@attribute:attribute(<<"hx-request"/utf8>>, Request).
-file("src/hx.gleam", 471).
?DOC(
" Forces validation before making a request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-validate/)\n"
).
-spec validate(boolean()) -> lustre@vdom@vattr:attribute(any()).
validate(Bool) ->
case Bool of
true ->
lustre@attribute:attribute(<<"hx-validate"/utf8>>, <<"true"/utf8>>);
false ->
lustre@attribute:attribute(<<"hx-validate"/utf8>>, <<"false"/utf8>>)
end.
-file("src/hx.gleam", 481).
?DOC(
" Adds hyperscript behavior to an element using the \"_\" attribute.\n"
"\n"
" [Official Hyperscript Documentation](https://hyperscript.org/)\n"
).
-spec hyper_script(binary()) -> lustre@vdom@vattr:attribute(any()).
hyper_script(Script) ->
lustre@attribute:attribute(<<"_"/utf8>>, Script).
-file("src/hx.gleam", 496).
?DOC(
" Handles events with inline scripts on elements using the hx-on attribute.\n"
"\n"
" This is an HTMX 2.x feature that allows inline event handling.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-on/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" hx.on(\"click\", \"alert('Clicked!')\")\n"
" hx.on(\"htmx:afterSwap\", \"console.log('Swapped')\")\n"
" ```\n"
).
-spec on(binary(), binary()) -> lustre@vdom@vattr:attribute(any()).
on(Event_name, Script) ->
lustre@attribute:attribute(<<"hx-on:"/utf8, Event_name/binary>>, Script).
-file("src/hx.gleam", 530).
?DOC(
" Creates a load event that fires when the element loads.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)\n"
).
-spec load() -> event().
load() ->
{event, <<"load"/utf8>>, []}.
-file("src/hx.gleam", 537).
?DOC(
" Creates a DOMContentLoaded event that fires when the initial HTML document is loaded.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Document/DOMContentLoaded_event)\n"
).
-spec dom_content_loaded() -> event().
dom_content_loaded() ->
{event, <<"DOMContentLoaded"/utf8>>, []}.
-file("src/hx.gleam", 544).
?DOC(
" Creates a click event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event)\n"
).
-spec click() -> event().
click() ->
{event, <<"click"/utf8>>, []}.
-file("src/hx.gleam", 551).
?DOC(
" Creates a change event (fires when an input value changes).\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event)\n"
).
-spec change() -> event().
change() ->
{event, <<"change"/utf8>>, []}.
-file("src/hx.gleam", 558).
?DOC(
" Creates a submit event (fires when a form is submitted).\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit_event)\n"
).
-spec submit() -> event().
submit() ->
{event, <<"submit"/utf8>>, []}.
-file("src/hx.gleam", 565).
?DOC(
" Creates a keyup event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event)\n"
).
-spec keyup() -> event().
keyup() ->
{event, <<"keyup"/utf8>>, []}.
-file("src/hx.gleam", 572).
?DOC(
" Creates a keydown event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event)\n"
).
-spec keydown() -> event().
keydown() ->
{event, <<"keydown"/utf8>>, []}.
-file("src/hx.gleam", 579).
?DOC(
" Creates a focus event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/focus_event)\n"
).
-spec focus() -> event().
focus() ->
{event, <<"focus"/utf8>>, []}.
-file("src/hx.gleam", 586).
?DOC(
" Creates a blur event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/blur_event)\n"
).
-spec blur() -> event().
blur() ->
{event, <<"blur"/utf8>>, []}.
-file("src/hx.gleam", 593).
?DOC(
" Creates a mouseover event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseover_event)\n"
).
-spec mouseover() -> event().
mouseover() ->
{event, <<"mouseover"/utf8>>, []}.
-file("src/hx.gleam", 600).
?DOC(
" Creates a mouseout event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseout_event)\n"
).
-spec mouseout() -> event().
mouseout() ->
{event, <<"mouseout"/utf8>>, []}.
-file("src/hx.gleam", 607).
?DOC(
" Creates an input event (fires on every character typed).\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event)\n"
).
-spec input() -> event().
input() ->
{event, <<"input"/utf8>>, []}.
-file("src/hx.gleam", 614).
?DOC(
" Creates a scroll event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Element/scroll_event)\n"
).
-spec scroll() -> event().
scroll() ->
{event, <<"scroll"/utf8>>, []}.
-file("src/hx.gleam", 621).
?DOC(
" Creates a resize event.\n"
"\n"
" [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Window/resize_event)\n"
).
-spec resize() -> event().
resize() ->
{event, <<"resize"/utf8>>, []}.
-file("src/hx.gleam", 630).
?DOC(
" Triggered before an AJAX request is made.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeRequest)\n"
).
-spec htmx_before_request() -> event().
htmx_before_request() ->
{event, <<"htmx:beforeRequest"/utf8>>, []}.
-file("src/hx.gleam", 637).
?DOC(
" Triggered after an AJAX request completes.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:afterRequest)\n"
).
-spec htmx_after_request() -> event().
htmx_after_request() ->
{event, <<"htmx:afterRequest"/utf8>>, []}.
-file("src/hx.gleam", 644).
?DOC(
" Triggered before content is swapped into the DOM.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeSwap)\n"
).
-spec htmx_before_swap() -> event().
htmx_before_swap() ->
{event, <<"htmx:beforeSwap"/utf8>>, []}.
-file("src/hx.gleam", 651).
?DOC(
" Triggered after content is swapped into the DOM.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:afterSwap)\n"
).
-spec htmx_after_swap() -> event().
htmx_after_swap() ->
{event, <<"htmx:afterSwap"/utf8>>, []}.
-file("src/hx.gleam", 658).
?DOC(
" Triggered before the settling phase begins.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeSettle)\n"
).
-spec htmx_before_settle() -> event().
htmx_before_settle() ->
{event, <<"htmx:beforeSettle"/utf8>>, []}.
-file("src/hx.gleam", 665).
?DOC(
" Triggered after the settling phase completes.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:afterSettle)\n"
).
-spec htmx_after_settle() -> event().
htmx_after_settle() ->
{event, <<"htmx:afterSettle"/utf8>>, []}.
-file("src/hx.gleam", 672).
?DOC(
" Triggered when new content is loaded into the DOM.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:load)\n"
).
-spec htmx_load() -> event().
htmx_load() ->
{event, <<"htmx:load"/utf8>>, []}.
-file("src/hx.gleam", 679).
?DOC(
" Triggered before a request is configured.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:configRequest)\n"
).
-spec htmx_config_request() -> event().
htmx_config_request() ->
{event, <<"htmx:configRequest"/utf8>>, []}.
-file("src/hx.gleam", 686).
?DOC(
" Triggered when an HTTP error response is received.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:responseError)\n"
).
-spec htmx_response_error() -> event().
htmx_response_error() ->
{event, <<"htmx:responseError"/utf8>>, []}.
-file("src/hx.gleam", 693).
?DOC(
" Triggered when a network error occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:sendError)\n"
).
-spec htmx_send_error() -> event().
htmx_send_error() ->
{event, <<"htmx:sendError"/utf8>>, []}.
-file("src/hx.gleam", 700).
?DOC(
" Triggered when a request times out.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:timeout)\n"
).
-spec htmx_timeout() -> event().
htmx_timeout() ->
{event, <<"htmx:timeout"/utf8>>, []}.
-file("src/hx.gleam", 707).
?DOC(
" Triggered before every request trigger, allowing cancellation or async confirmation.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:confirm)\n"
).
-spec htmx_confirm() -> event().
htmx_confirm() ->
{event, <<"htmx:confirm"/utf8>>, []}.
-file("src/hx.gleam", 714).
?DOC(
" Triggered right before sending the request.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeSend)\n"
).
-spec htmx_before_send() -> event().
htmx_before_send() ->
{event, <<"htmx:beforeSend"/utf8>>, []}.
-file("src/hx.gleam", 721).
?DOC(
" Validates the URL before making the request.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:validateUrl)\n"
).
-spec htmx_validate_url() -> event().
htmx_validate_url() ->
{event, <<"htmx:validateUrl"/utf8>>, []}.
-file("src/hx.gleam", 728).
?DOC(
" Triggered before any response processing.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeOnLoad)\n"
).
-spec htmx_before_on_load() -> event().
htmx_before_on_load() ->
{event, <<"htmx:beforeOnLoad"/utf8>>, []}.
-file("src/hx.gleam", 735).
?DOC(
" Triggered after an AJAX onload has finished.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:afterOnLoad)\n"
).
-spec htmx_after_on_load() -> event().
htmx_after_on_load() ->
{event, <<"htmx:afterOnLoad"/utf8>>, []}.
-file("src/hx.gleam", 742).
?DOC(
" Triggered when a request is aborted.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:sendAbort)\n"
).
-spec htmx_send_abort() -> event().
htmx_send_abort() ->
{event, <<"htmx:sendAbort"/utf8>>, []}.
-file("src/hx.gleam", 749).
?DOC(
" Listener event to cancel ongoing requests.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:abort)\n"
).
-spec htmx_abort() -> event().
htmx_abort() ->
{event, <<"htmx:abort"/utf8>>, []}.
-file("src/hx.gleam", 756).
?DOC(
" Triggered before validation runs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:validation:validate)\n"
).
-spec htmx_validation_validate() -> event().
htmx_validation_validate() ->
{event, <<"htmx:validation:validate"/utf8>>, []}.
-file("src/hx.gleam", 763).
?DOC(
" Triggered when validation fails.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:validation:failed)\n"
).
-spec htmx_validation_failed() -> event().
htmx_validation_failed() ->
{event, <<"htmx:validation:failed"/utf8>>, []}.
-file("src/hx.gleam", 770).
?DOC(
" Triggered when validation is halted.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:validation:halted)\n"
).
-spec htmx_validation_halted() -> event().
htmx_validation_halted() ->
{event, <<"htmx:validation:halted"/utf8>>, []}.
-file("src/hx.gleam", 777).
?DOC(
" Triggered when an XHR request is aborted.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:xhr:abort)\n"
).
-spec htmx_xhr_abort() -> event().
htmx_xhr_abort() ->
{event, <<"htmx:xhr:abort"/utf8>>, []}.
-file("src/hx.gleam", 784).
?DOC(
" Triggered when an XHR request ends.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:xhr:loadend)\n"
).
-spec htmx_xhr_loadend() -> event().
htmx_xhr_loadend() ->
{event, <<"htmx:xhr:loadend"/utf8>>, []}.
-file("src/hx.gleam", 791).
?DOC(
" Triggered when an XHR request starts.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:xhr:loadstart)\n"
).
-spec htmx_xhr_loadstart() -> event().
htmx_xhr_loadstart() ->
{event, <<"htmx:xhr:loadstart"/utf8>>, []}.
-file("src/hx.gleam", 798).
?DOC(
" Triggered during XHR request progress.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:xhr:progress)\n"
).
-spec htmx_xhr_progress() -> event().
htmx_xhr_progress() ->
{event, <<"htmx:xhr:progress"/utf8>>, []}.
-file("src/hx.gleam", 805).
?DOC(
" Triggered before processing a DOM node.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeProcessNode)\n"
).
-spec htmx_before_process_node() -> event().
htmx_before_process_node() ->
{event, <<"htmx:beforeProcessNode"/utf8>>, []}.
-file("src/hx.gleam", 812).
?DOC(
" Triggered after processing a DOM node.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:afterProcessNode)\n"
).
-spec htmx_after_process_node() -> event().
htmx_after_process_node() ->
{event, <<"htmx:afterProcessNode"/utf8>>, []}.
-file("src/hx.gleam", 819).
?DOC(
" Triggered before cleaning up an element.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeCleanupElement)\n"
).
-spec htmx_before_cleanup_element() -> event().
htmx_before_cleanup_element() ->
{event, <<"htmx:beforeCleanupElement"/utf8>>, []}.
-file("src/hx.gleam", 826).
?DOC(
" Triggered before View Transition API wraps a swap.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeTransition)\n"
).
-spec htmx_before_transition() -> event().
htmx_before_transition() ->
{event, <<"htmx:beforeTransition"/utf8>>, []}.
-file("src/hx.gleam", 833).
?DOC(
" Triggered when a trigger is activated.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:trigger)\n"
).
-spec htmx_trigger() -> event().
htmx_trigger() ->
{event, <<"htmx:trigger"/utf8>>, []}.
-file("src/hx.gleam", 840).
?DOC(
" Triggered before an out-of-band swap.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:oobBeforeSwap)\n"
).
-spec htmx_oob_before_swap() -> event().
htmx_oob_before_swap() ->
{event, <<"htmx:oobBeforeSwap"/utf8>>, []}.
-file("src/hx.gleam", 847).
?DOC(
" Triggered after an out-of-band swap.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:oobAfterSwap)\n"
).
-spec htmx_oob_after_swap() -> event().
htmx_oob_after_swap() ->
{event, <<"htmx:oobAfterSwap"/utf8>>, []}.
-file("src/hx.gleam", 854).
?DOC(
" Triggered when an OOB swap target is not found.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:oobErrorNoTarget)\n"
).
-spec htmx_oob_error_no_target() -> event().
htmx_oob_error_no_target() ->
{event, <<"htmx:oobErrorNoTarget"/utf8>>, []}.
-file("src/hx.gleam", 861).
?DOC(
" Triggered when an error occurs during swap.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:swapError)\n"
).
-spec htmx_swap_error() -> event().
htmx_swap_error() ->
{event, <<"htmx:swapError"/utf8>>, []}.
-file("src/hx.gleam", 868).
?DOC(
" Triggered on general errors.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:error)\n"
).
-spec htmx_error() -> event().
htmx_error() ->
{event, <<"htmx:error"/utf8>>, []}.
-file("src/hx.gleam", 875).
?DOC(
" Triggered when a history item is created.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:historyItemCreated)\n"
).
-spec htmx_history_item_created() -> event().
htmx_history_item_created() ->
{event, <<"htmx:historyItemCreated"/utf8>>, []}.
-file("src/hx.gleam", 882).
?DOC(
" Triggered when a history cache error occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:historyCacheError)\n"
).
-spec htmx_history_cache_error() -> event().
htmx_history_cache_error() ->
{event, <<"htmx:historyCacheError"/utf8>>, []}.
-file("src/hx.gleam", 889).
?DOC(
" Triggered before a history save occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeHistorySave)\n"
).
-spec htmx_before_history_save() -> event().
htmx_before_history_save() ->
{event, <<"htmx:beforeHistorySave"/utf8>>, []}.
-file("src/hx.gleam", 896).
?DOC(
" Triggered before a history update occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:beforeHistoryUpdate)\n"
).
-spec htmx_before_history_update() -> event().
htmx_before_history_update() ->
{event, <<"htmx:beforeHistoryUpdate"/utf8>>, []}.
-file("src/hx.gleam", 903).
?DOC(
" Triggered when history is restored.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:historyRestore)\n"
).
-spec htmx_history_restore() -> event().
htmx_history_restore() ->
{event, <<"htmx:historyRestore"/utf8>>, []}.
-file("src/hx.gleam", 910).
?DOC(
" Triggered when an element is pushed into history.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:pushedIntoHistory)\n"
).
-spec htmx_pushed_into_history() -> event().
htmx_pushed_into_history() ->
{event, <<"htmx:pushedIntoHistory"/utf8>>, []}.
-file("src/hx.gleam", 917).
?DOC(
" Triggered when an element is replaced in history.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:replacedInHistory)\n"
).
-spec htmx_replaced_in_history() -> event().
htmx_replaced_in_history() ->
{event, <<"htmx:replacedInHistory"/utf8>>, []}.
-file("src/hx.gleam", 924).
?DOC(
" Triggered when the page is restored from history.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:restored)\n"
).
-spec htmx_restored() -> event().
htmx_restored() ->
{event, <<"htmx:restored"/utf8>>, []}.
-file("src/hx.gleam", 931).
?DOC(
" Triggered when a history cache hit occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:historyCacheHit)\n"
).
-spec htmx_history_cache_hit() -> event().
htmx_history_cache_hit() ->
{event, <<"htmx:historyCacheHit"/utf8>>, []}.
-file("src/hx.gleam", 938).
?DOC(
" Triggered when a history cache miss occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:historyCacheMiss)\n"
).
-spec htmx_history_cache_miss() -> event().
htmx_history_cache_miss() ->
{event, <<"htmx:historyCacheMiss"/utf8>>, []}.
-file("src/hx.gleam", 945).
?DOC(
" Triggered when loading after a history cache miss.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:historyCacheMissLoad)\n"
).
-spec htmx_history_cache_miss_load() -> event().
htmx_history_cache_miss_load() ->
{event, <<"htmx:historyCacheMissLoad"/utf8>>, []}.
-file("src/hx.gleam", 952).
?DOC(
" Triggered when a history cache miss load error occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:historyCacheMissLoadError)\n"
).
-spec htmx_history_cache_miss_load_error() -> event().
htmx_history_cache_miss_load_error() ->
{event, <<"htmx:historyCacheMissLoadError"/utf8>>, []}.
-file("src/hx.gleam", 959).
?DOC(
" Triggered when an event filter error occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:eventFilter:error)\n"
).
-spec htmx_event_filter_error() -> event().
htmx_event_filter_error() ->
{event, <<"htmx:eventFilter:error"/utf8>>, []}.
-file("src/hx.gleam", 966).
?DOC(
" Triggered when a syntax error occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:syntax:error)\n"
).
-spec htmx_syntax_error() -> event().
htmx_syntax_error() ->
{event, <<"htmx:syntax:error"/utf8>>, []}.
-file("src/hx.gleam", 973).
?DOC(
" Triggered when a bad response URL is encountered.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:badResponseUrl)\n"
).
-spec htmx_bad_response_url() -> event().
htmx_bad_response_url() ->
{event, <<"htmx:badResponseUrl"/utf8>>, []}.
-file("src/hx.gleam", 980).
?DOC(
" Triggered when an invalid path is encountered.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:invalidPath)\n"
).
-spec htmx_invalid_path() -> event().
htmx_invalid_path() ->
{event, <<"htmx:invalidPath"/utf8>>, []}.
-file("src/hx.gleam", 987).
?DOC(
" Triggered when an onload error occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:onLoadError)\n"
).
-spec htmx_on_load_error() -> event().
htmx_on_load_error() ->
{event, <<"htmx:onLoadError"/utf8>>, []}.
-file("src/hx.gleam", 994).
?DOC(
" Triggered when a target error occurs.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:targetError)\n"
).
-spec htmx_target_error() -> event().
htmx_target_error() ->
{event, <<"htmx:targetError"/utf8>>, []}.
-file("src/hx.gleam", 1001).
?DOC(
" Triggered when eval is disallowed.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:evalDisallowedError)\n"
).
-spec htmx_eval_disallowed_error() -> event().
htmx_eval_disallowed_error() ->
{event, <<"htmx:evalDisallowedError"/utf8>>, []}.
-file("src/hx.gleam", 1008).
?DOC(
" Triggered when a prompt is shown.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:prompt)\n"
).
-spec htmx_prompt() -> event().
htmx_prompt() ->
{event, <<"htmx:prompt"/utf8>>, []}.
-file("src/hx.gleam", 1015).
?DOC(
" Triggered during session storage test.\n"
"\n"
" [Official Events Reference](https://htmx.org/events/#htmx:sessionStorageTest)\n"
).
-spec htmx_session_storage_test() -> event().
htmx_session_storage_test() ->
{event, <<"htmx:sessionStorageTest"/utf8>>, []}.
-file("src/hx.gleam", 1031).
-spec intersect_config_to_string(intersect_config()) -> binary().
intersect_config_to_string(Config) ->
case Config of
{root, Selector} ->
<<"root:"/utf8, Selector/binary>>;
{threshold, Value} ->
<<"threshold:"/utf8, (gleam_stdlib:float_to_string(Value))/binary>>
end.
-file("src/hx.gleam", 1041).
?DOC(
" Creates a revealed event that triggers when the element is scrolled into the viewport.\n"
"\n"
" [Official Revealed Documentation](https://htmx.org/docs/#revealed)\n"
).
-spec revealed() -> event().
revealed() ->
{event, <<"revealed"/utf8>>, []}.
-file("src/hx.gleam", 1062).
?DOC(
" Creates an intersect event that triggers when the element enters the viewport.\n"
"\n"
" Supports configuration options for root element, threshold, and root margin.\n"
"\n"
" [Official Intersect Documentation](https://htmx.org/docs/#intersect)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Basic intersect\n"
" hx.intersect([])\n"
"\n"
" // With threshold\n"
" hx.intersect([hx.Threshold(0.5)])\n"
"\n"
" // With root element and threshold\n"
" hx.intersect([hx.Root(\"#container\"), hx.Threshold(0.75)])\n"
" ```\n"
).
-spec intersect(list(intersect_config())) -> event().
intersect(Config) ->
case Config of
[] ->
{event, <<"intersect"/utf8>>, []};
Configs ->
Config_str = begin
_pipe = Configs,
_pipe@1 = gleam@list:map(
_pipe,
fun intersect_config_to_string/1
),
gleam@string:join(_pipe@1, <<" "/utf8>>)
end,
{event, <<"intersect "/utf8, Config_str/binary>>, []}
end.
-file("src/hx.gleam", 1087).
?DOC(
" Creates an intersect event that fires only once when entering the viewport.\n"
"\n"
" [Official Intersect Documentation](https://htmx.org/docs/#intersect)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Basic intersect once\n"
" hx.intersect_once([])\n"
"\n"
" // With threshold, fires once\n"
" hx.intersect_once([hx.Threshold(0.5)])\n"
" ```\n"
).
-spec intersect_once(list(intersect_config())) -> event().
intersect_once(Config) ->
case Config of
[] ->
{event, <<"intersect"/utf8>>, [once]};
Configs ->
Config_str = begin
_pipe = Configs,
_pipe@1 = gleam@list:map(
_pipe,
fun intersect_config_to_string/1
),
gleam@string:join(_pipe@1, <<" "/utf8>>)
end,
{event, <<"intersect "/utf8, Config_str/binary>>, [once]}
end.
-file("src/hx.gleam", 1103).
?DOC(" Creates a custom event with the given name.\n").
-spec custom(binary()) -> event().
custom(Event_name) ->
{event, Event_name, []}.
-file("src/hx.gleam", 1110).
?DOC(
" Adds a delay before the event triggers.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_delay(event(), gleam@time@duration:duration()) -> event().
with_delay(Event, Timing) ->
{event,
erlang:element(2, Event),
[{delay, Timing} | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1117).
?DOC(
" Throttles the event to fire at most once per duration.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_throttle(event(), gleam@time@duration:duration()) -> event().
with_throttle(Event, Timing) ->
{event,
erlang:element(2, Event),
[{throttle, Timing} | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1124).
?DOC(
" Makes the event fire only once.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_once(event()) -> event().
with_once(Event) ->
{event, erlang:element(2, Event), [once | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1131).
?DOC(
" Only triggers if the element's value has changed.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_changed(event()) -> event().
with_changed(Event) ->
{event, erlang:element(2, Event), [changed | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1138).
?DOC(
" Listens for the event on a different element.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_from(event(), selector()) -> event().
with_from(Event, Extended_css_selector) ->
{event,
erlang:element(2, Event),
[{from, Extended_css_selector} | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1148).
?DOC(
" Filters the event to only trigger when it targets a specific element.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_target(event(), binary()) -> event().
with_target(Event, Css_selector) ->
{event,
erlang:element(2, Event),
[{target, Css_selector} | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1155).
?DOC(
" Prevents the event from bubbling up the DOM.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_consume(event()) -> event().
with_consume(Event) ->
{event, erlang:element(2, Event), [consume | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1162).
?DOC(
" Queues the event with a specific strategy.\n"
"\n"
" [Official Trigger Modifiers](https://htmx.org/attributes/hx-trigger/#standard-event-modifiers)\n"
).
-spec with_queue(event(), gleam@option:option(queue())) -> event().
with_queue(Event, Queue) ->
{event,
erlang:element(2, Event),
[{queue_event, Queue} | erlang:element(3, Event)]}.
-file("src/hx.gleam", 1203).
-spec queue_to_string(queue()) -> binary().
queue_to_string(Queue) ->
case Queue of
first ->
<<"first"/utf8>>;
last ->
<<"last"/utf8>>;
all ->
<<"all"/utf8>>
end.
-file("src/hx.gleam", 1235).
-spec selector_to_string(selector()) -> binary().
selector_to_string(Extended_css_selector) ->
case Extended_css_selector of
{selector, Css_selector} ->
Css_selector;
document ->
<<"document"/utf8>>;
window ->
<<"window"/utf8>>;
{closest, Css_selector@1} ->
<<"closest "/utf8, Css_selector@1/binary>>;
{find, Css_selector@2} ->
<<"find "/utf8, Css_selector@2/binary>>;
{next, Css_selector@3} ->
<<"next "/utf8, Css_selector@3/binary>>;
{previous, Css_selector@4} ->
<<"previous "/utf8, Css_selector@4/binary>>;
this ->
<<"this"/utf8>>
end.
-file("src/hx.gleam", 133).
?DOC(
" Shows loading indicators during AJAX requests.\n"
"\n"
" Supports extended CSS selectors including `closest`, `this`, etc.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-indicator/)\n"
).
-spec indicator(selector()) -> lustre@vdom@vattr:attribute(any()).
indicator(Selector) ->
lustre@attribute:attribute(
<<"hx-indicator"/utf8>>,
selector_to_string(Selector)
).
-file("src/hx.gleam", 152).
?DOC(
" Specifies the target element to swap content into.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-target/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Target specific element\n"
" hx.target(hx.Selector(\"#results\"))\n"
"\n"
" // Target parent element\n"
" hx.target(hx.Closest(\".card\"))\n"
"\n"
" // Target the element itself\n"
" hx.target(hx.This)\n"
" ```\n"
).
-spec target(selector()) -> lustre@vdom@vattr:attribute(any()).
target(Extended_css_selector) ->
lustre@attribute:attribute(
<<"hx-target"/utf8>>,
selector_to_string(Extended_css_selector)
).
-file("src/hx.gleam", 332).
?DOC(
" Disables elements during AJAX requests.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-disabled-elt/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Disable specific buttons\n"
" hx.disable_elt([hx.Selector(\"button\")])\n"
"\n"
" // Disable multiple element types\n"
" hx.disable_elt([\n"
" hx.Selector(\"input[type='submit']\"),\n"
" hx.Selector(\"button\")\n"
" ])\n"
" ```\n"
).
-spec disable_elt(list(selector())) -> lustre@vdom@vattr:attribute(any()).
disable_elt(Extended_css_selectors) ->
Selectors = begin
_pipe = Extended_css_selectors,
_pipe@1 = gleam@list:map(_pipe, fun selector_to_string/1),
gleam@string:join(_pipe@1, <<","/utf8>>)
end,
lustre@attribute:attribute(<<"hx-disable-elt"/utf8>>, Selectors).
-file("src/hx.gleam", 400).
?DOC(
" Includes additional element values in the request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-include/)\n"
).
-spec include(selector()) -> lustre@vdom@vattr:attribute(any()).
include(Extended_css_selector) ->
lustre@attribute:attribute(
<<"hx-include"/utf8>>,
selector_to_string(Extended_css_selector)
).
-file("src/hx.gleam", 1250).
?DOC(false).
-spec duration_to_string(gleam@time@duration:duration()) -> binary().
duration_to_string(D) ->
_pipe = gleam@time@duration:to_milliseconds(D),
_pipe@1 = erlang:integer_to_binary(_pipe),
gleam@string:append(_pipe@1, <<"ms"/utf8>>).
-file("src/hx.gleam", 70).
?DOC(
" Creates a polling trigger that fires at regular intervals.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-trigger/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Poll every 5 seconds\n"
" hx.trigger_polling(timing: duration.seconds(5), filters: None, on_load: False)\n"
"\n"
" // Poll with filters\n"
" hx.trigger_polling(timing: duration.seconds(10), filters: Some(\"visible\"), on_load: False)\n"
"\n"
" // Start polling immediately and on load\n"
" hx.trigger_polling(timing: duration.seconds(2), filters: None, on_load: True)\n"
" ```\n"
).
-spec trigger_polling(
gleam@time@duration:duration(),
gleam@option:option(binary()),
boolean()
) -> lustre@vdom@vattr:attribute(any()).
trigger_polling(Timing, Filters, On_load) ->
case {Filters, On_load} of
{{some, Filters@1}, false} ->
lustre@attribute:attribute(
<<"hx-trigger"/utf8>>,
<<<<<<<<"every "/utf8, (duration_to_string(Timing))/binary>>/binary,
" ["/utf8>>/binary,
Filters@1/binary>>/binary,
"]"/utf8>>
);
{none, false} ->
lustre@attribute:attribute(
<<"hx-trigger"/utf8>>,
<<"every "/utf8, (duration_to_string(Timing))/binary>>
);
{none, true} ->
lustre@attribute:attribute(
<<"hx-trigger"/utf8>>,
<<"load every "/utf8, (duration_to_string(Timing))/binary>>
);
{{some, Filters@2}, true} ->
lustre@attribute:attribute(
<<"hx-trigger"/utf8>>,
<<<<<<<<"load every "/utf8,
(duration_to_string(Timing))/binary>>/binary,
" ["/utf8>>/binary,
Filters@2/binary>>/binary,
"]"/utf8>>
)
end.
-file("src/hx.gleam", 1166).
-spec modifier_to_string(event_modifier()) -> binary().
modifier_to_string(Event_modifier) ->
case Event_modifier of
once ->
<<"once"/utf8>>;
changed ->
<<"changed"/utf8>>;
{delay, T} ->
<<"delay:"/utf8, (duration_to_string(T))/binary>>;
{throttle, T@1} ->
<<"throttle:"/utf8, (duration_to_string(T@1))/binary>>;
{from, Extended_css_selector} ->
<<"from:"/utf8, (selector_to_string(Extended_css_selector))/binary>>;
{target, Css_selector} ->
<<"target:"/utf8, Css_selector/binary>>;
consume ->
<<"consume"/utf8>>;
{queue_event, {some, Queue}} ->
<<"queue:"/utf8, (queue_to_string(Queue))/binary>>;
{queue_event, none} ->
<<"queue:none"/utf8>>
end.
-file("src/hx.gleam", 1181).
-spec event_to_string(event()) -> binary().
event_to_string(Event) ->
<<(erlang:element(2, Event))/binary,
(begin
_pipe = gleam@list:map(
erlang:element(3, Event),
fun(E) -> <<" "/utf8, (modifier_to_string(E))/binary>> end
),
gleam@string:join(_pipe, <<""/utf8>>)
end)/binary>>.
-file("src/hx.gleam", 47).
?DOC(
" Specifies which events will cause an HTMX request.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-trigger/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Single event\n"
" hx.trigger([hx.click()])\n"
"\n"
" // Multiple events\n"
" hx.trigger([hx.click(), hx.keyup()])\n"
"\n"
" // Event with modifiers\n"
" hx.trigger([hx.with_delay(hx.click(), duration.seconds(2))])\n"
" ```\n"
).
-spec trigger(list(event())) -> lustre@vdom@vattr:attribute(any()).
trigger(Events) ->
Events@1 = begin
_pipe = Events,
_pipe@1 = gleam@list:map(_pipe, fun event_to_string/1),
gleam@string:join(_pipe@1, <<", "/utf8>>)
end,
lustre@attribute:attribute(<<"hx-trigger"/utf8>>, Events@1).
-file("src/hx.gleam", 1350).
-spec scroll_position_to_string(scroll_position()) -> binary().
scroll_position_to_string(Pos) ->
case Pos of
top ->
<<"top"/utf8>>;
bottom ->
<<"bottom"/utf8>>
end.
-file("src/hx.gleam", 1357).
-spec scroll_target_to_string(scroll_target()) -> binary().
scroll_target_to_string(Target) ->
case Target of
{target_scroll, Pos} ->
<<"scroll:"/utf8, (scroll_position_to_string(Pos))/binary>>;
{element_scroll, Selector, Pos@1} ->
<<<<<<"scroll:"/utf8, Selector/binary>>/binary, ":"/utf8>>/binary,
(scroll_position_to_string(Pos@1))/binary>>;
{window_scroll, Pos@2} ->
<<"scroll:window:"/utf8, (scroll_position_to_string(Pos@2))/binary>>
end.
-file("src/hx.gleam", 1366).
-spec show_target_to_string(show_target()) -> binary().
show_target_to_string(Target) ->
case Target of
{target_show, Pos} ->
<<"show:"/utf8, (scroll_position_to_string(Pos))/binary>>;
{element_show, Selector, Pos@1} ->
<<<<<<"show:"/utf8, Selector/binary>>/binary, ":"/utf8>>/binary,
(scroll_position_to_string(Pos@1))/binary>>;
{window_show, Pos@2} ->
<<"show:window:"/utf8, (scroll_position_to_string(Pos@2))/binary>>
end.
-file("src/hx.gleam", 1375).
-spec swap_option_to_string(swap_config()) -> binary().
swap_option_to_string(Swap_option) ->
case Swap_option of
{transition, true} ->
<<"transition:true"/utf8>>;
{transition, false} ->
<<"transition:false"/utf8>>;
{swap_timing, Timing_declaration} ->
<<"swap:"/utf8, (duration_to_string(Timing_declaration))/binary>>;
{settle, Timing_declaration@1} ->
<<"settle:"/utf8,
(duration_to_string(Timing_declaration@1))/binary>>;
{ignore_title, true} ->
<<"ignoreTitle:true"/utf8>>;
{ignore_title, false} ->
<<"ignoreTitle:false"/utf8>>;
{scroll_to, Target} ->
scroll_target_to_string(Target);
{show, Target@1} ->
show_target_to_string(Target@1);
{focus_scroll, true} ->
<<"focus-scroll:true"/utf8>>;
{focus_scroll, false} ->
<<"focus-scroll:false"/utf8>>
end.
-file("src/hx.gleam", 1392).
-spec swap_to_string(swap()) -> binary().
swap_to_string(Swap) ->
case Swap of
inner_h_t_m_l ->
<<"innerHTML"/utf8>>;
outer_h_t_m_l ->
<<"outerHTML"/utf8>>;
text_content ->
<<"textContent"/utf8>>;
afterbegin ->
<<"afterbegin"/utf8>>;
beforebegin ->
<<"beforebegin"/utf8>>;
beforeend ->
<<"beforeend"/utf8>>;
afterend ->
<<"afterend"/utf8>>;
delete ->
<<"delete"/utf8>>;
swap_none ->
<<"none"/utf8>>
end.
-file("src/hx.gleam", 167).
?DOC(
" Controls how content is swapped into the DOM.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-swap/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Basic swap strategies\n"
" hx.swap(hx.InnerHTML)\n"
" hx.swap(hx.OuterHTML)\n"
" hx.swap(hx.Afterend)\n"
" ```\n"
).
-spec swap(swap()) -> lustre@vdom@vattr:attribute(any()).
swap(Swap) ->
_pipe = Swap,
_pipe@1 = swap_to_string(_pipe),
lustre@attribute:attribute(<<"hx-swap"/utf8>>, _pipe@1).
-file("src/hx.gleam", 185).
?DOC(
" Controls how content is swapped into the DOM with additional configuration options.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-swap/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Swap with transition\n"
" hx.swap_with(hx.InnerHTML, hx.Transition(True))\n"
"\n"
" // Swap with timing\n"
" hx.swap_with(hx.OuterHTML, hx.SwapTiming(duration.milliseconds(500)))\n"
" ```\n"
).
-spec swap_with(swap(), swap_config()) -> lustre@vdom@vattr:attribute(any()).
swap_with(Swap, Config) ->
_pipe = Swap,
_pipe@1 = swap_to_string(_pipe),
_pipe@2 = gleam@string:append(
_pipe@1,
<<" "/utf8, (swap_option_to_string(Config))/binary>>
),
lustre@attribute:attribute(<<"hx-swap"/utf8>>, _pipe@2).
-file("src/hx.gleam", 195).
?DOC(
" Allows you to swap content \"out of band\" - updating other elements in the response.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-swap-oob/)\n"
).
-spec swap_oob(swap(), gleam@option:option(binary())) -> lustre@vdom@vattr:attribute(any()).
swap_oob(Swap, Css_selector) ->
case Css_selector of
{some, Css_selector@1} ->
_pipe = Swap,
_pipe@1 = swap_to_string(_pipe),
_pipe@2 = gleam@string:append(
_pipe@1,
<<":"/utf8, Css_selector@1/binary>>
),
lustre@attribute:attribute(<<"hx-swap-oob"/utf8>>, _pipe@2);
none ->
_pipe@3 = Swap,
_pipe@4 = swap_to_string(_pipe@3),
lustre@attribute:attribute(<<"hx-swap-oob"/utf8>>, _pipe@4)
end.
-file("src/hx.gleam", 212).
?DOC(
" Allows you to swap content \"out of band\" with configuration options.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-swap-oob/)\n"
).
-spec swap_oob_with(swap(), gleam@option:option(binary()), swap_config()) -> lustre@vdom@vattr:attribute(any()).
swap_oob_with(Swap, Css_selector, Modifier) ->
case Css_selector of
{some, Css_selector@1} ->
_pipe = Swap,
_pipe@1 = swap_to_string(_pipe),
_pipe@2 = gleam@string:append(
_pipe@1,
<<":"/utf8, Css_selector@1/binary>>
),
_pipe@3 = gleam@string:append(
_pipe@2,
<<" "/utf8, (swap_option_to_string(Modifier))/binary>>
),
lustre@attribute:attribute(<<"hx-swap-oob"/utf8>>, _pipe@3);
none ->
_pipe@4 = Swap,
_pipe@5 = swap_to_string(_pipe@4),
_pipe@6 = gleam@string:append(
_pipe@5,
<<" "/utf8, (swap_option_to_string(Modifier))/binary>>
),
lustre@attribute:attribute(<<"hx-swap-oob"/utf8>>, _pipe@6)
end.
-file("src/hx.gleam", 1406).
-spec sync_option_to_string(sync()) -> binary().
sync_option_to_string(Sync_option) ->
case Sync_option of
{default, Selector} ->
selector_to_string(Selector);
{drop, Selector@1} ->
<<(selector_to_string(Selector@1))/binary, ":drop"/utf8>>;
{abort, Selector@2} ->
<<(selector_to_string(Selector@2))/binary, ":abort"/utf8>>;
{replace, Selector@3} ->
<<(selector_to_string(Selector@3))/binary, ":replace"/utf8>>;
{queue, Selector@4, Queue} ->
<<<<(selector_to_string(Selector@4))/binary, ":queue "/utf8>>/binary,
(queue_to_string(Queue))/binary>>
end.
-file("src/hx.gleam", 252).
?DOC(
" Synchronizes AJAX requests between elements.\n"
"\n"
" [Official Documentation](https://htmx.org/attributes/hx-sync/)\n"
"\n"
" ## Examples\n"
" ```gleam\n"
" // Use default drop behavior (strategy is optional)\n"
" hx.sync(hx.Default(hx.Closest(\"form\")))\n"
"\n"
" // Explicitly drop conflicting requests\n"
" hx.sync(hx.Drop(hx.Closest(\"form\")))\n"
"\n"
" // Abort current request if new one comes in\n"
" hx.sync(hx.Abort(hx.This))\n"
"\n"
" // Queue requests, keeping only the last\n"
" hx.sync(hx.Queue(hx.Selector(\"#form\"), hx.Last))\n"
" ```\n"
).
-spec sync(sync()) -> lustre@vdom@vattr:attribute(any()).
sync(Strategy) ->
lustre@attribute:attribute(
<<"hx-sync"/utf8>>,
sync_option_to_string(Strategy)
).