-module(lily@component). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/lily/component.gleam"). -export([mount/3, simple/4, structural_compare/2, live/4, each/4, on_click/3, on_context_menu/3, on_drag/3, on_drag_over/3, on_drag_start/3, on_drop/3, on_mouse_down/3, on_mouse_move/3, on_mouse_up/3, on_pointer_down/3, on_pointer_move/3, on_pointer_up/3, on_touch_move/3, on_touch_start/3, on_key_down/3, on_key_up/3, on_blur/3, on_copy/3, on_cut/3, on_double_click/3, on_drag_end/3, on_focus/3, on_mouse_enter/3, on_mouse_leave/3, on_paste/3, on_resize/3, on_scroll/3, on_submit/3, on_touch_end/3, on_change/3, on_input/3, on_wheel/3]). -export_type([patch/0]). -type patch() :: {remove_attribute, binary(), binary()} | {set_attribute, binary(), binary(), binary()} | {set_style, binary(), binary(), binary()} | {set_text, binary(), binary()}. -file("src/lily/component.gleam", 50). -spec mount(lily@store:store(GDF, GDG), binary(), binary()) -> lily@store:store(GDF, GDG). mount(Store, Selector, Html) -> nil = lily@client:mount(Selector, Html), Store. -file("src/lily/component.gleam", 446). -spec simple( lily@store:store(GKX, GKY), binary(), fun((GKX) -> GLB), fun((GLB) -> binary()) ) -> lily@store:store(GKX, GKY). simple(Store, Selector, Slice, Render) -> Handler = lily@client:selective( Selector, Slice, fun lily@client:reference_equal/2, fun(Current) -> lily@client:set_inner_html(Selector, Render(Current)) end ), {Updated_store, _} = lily@store:subscribe(Store, Handler), Updated_store. -file("src/lily/component.gleam", 461). -spec structural_compare(lily@store:store(GLE, GLF), binary()) -> lily@store:store(GLE, GLF). structural_compare(Store, Selector) -> nil = lily@client:set_compare_strategy( Selector, fun lily@client:structural_equal/2 ), Store. -file("src/lily/component.gleam", 471). -spec patch_to_tuple(patch()) -> {binary(), binary(), binary(), binary()}. patch_to_tuple(Patch) -> case Patch of {set_text, Selector, Value} -> {<<"text"/utf8>>, Selector, <<""/utf8>>, Value}; {set_attribute, Selector@1, Name, Value@1} -> {<<"attribute"/utf8>>, Selector@1, Name, Value@1}; {set_style, Selector@2, Property, Value@2} -> {<<"style"/utf8>>, Selector@2, Property, Value@2}; {remove_attribute, Selector@3, Name@1} -> {<<"remove_attribute"/utf8>>, Selector@3, Name@1, <<""/utf8>>} end. -file("src/lily/component.gleam", 31). -spec live( lily@store:store(GCX, GCY), binary(), fun((GCX) -> GDB), fun((GDB) -> list(patch())) ) -> lily@store:store(GCX, GCY). live(Store, Selector, Slice, Patch) -> Handler = lily@client:selective( Selector, Slice, fun lily@client:reference_equal/2, fun(Current) -> Patches = begin _pipe = Patch(Current), gleam@list:map(_pipe, fun patch_to_tuple/1) end, lily@client:apply_patches(Selector, Patches) end ), {Updated_store, _} = lily@store:subscribe(Store, Handler), Updated_store. -file("src/lily/component.gleam", 483). -spec create_each_handler( binary(), fun((GLK) -> list(GLL)), fun((GLL) -> {fun((GLK) -> GLN), fun((GLN) -> binary())}), fun((GLN, GLN) -> boolean()) ) -> fun((GLK) -> nil). create_each_handler(_, _, _, _) -> fun(_) -> nil end. -file("src/lily/component.gleam", 18). -spec each( lily@store:store(GCO, GCP), binary(), fun((GCO) -> list(GCS)), fun((GCS) -> {fun((GCO) -> GCU), fun((GCU) -> binary())}) ) -> lily@store:store(GCO, GCP). each(Store, Container, Items, Create) -> Handler = create_each_handler( Container, Items, Create, fun lily@client:reference_equal/2 ), {Updated_store, _} = lily@store:subscribe(Store, Handler), Updated_store. -file("src/lily/component.gleam", 495). -spec setup_click_event(binary(), fun((binary()) -> nil)) -> nil. setup_click_event(_, _) -> nil. -file("src/lily/component.gleam", 83). -spec on_click( lily@store:store(GDX, GDY), binary(), fun((binary()) -> {ok, GDY} | {error, nil}) ) -> lily@store:store(GDX, GDY). on_click(Store, Selector, Decoder) -> nil = setup_click_event(Selector, fun(Msg_name) -> case Decoder(Msg_name) of {ok, Msg} -> lily@client:send_msg(Msg); {error, nil} -> nil end end), Store. -file("src/lily/component.gleam", 503). -spec setup_coordinate_event( binary(), binary(), fun((integer(), integer()) -> nil) ) -> nil. setup_coordinate_event(_, _, _) -> nil. -file("src/lily/component.gleam", 98). -spec on_context_menu( lily@store:store(GEF, GEG), binary(), fun((integer(), integer()) -> GEG) ) -> lily@store:store(GEF, GEG). on_context_menu(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"contextmenu"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 146). -spec on_drag( lily@store:store(GFD, GFE), binary(), fun((integer(), integer()) -> GFE) ) -> lily@store:store(GFD, GFE). on_drag(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"drag"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 170). -spec on_drag_over( lily@store:store(GFP, GFQ), binary(), fun((integer(), integer()) -> GFQ) ) -> lily@store:store(GFP, GFQ). on_drag_over(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"dragover"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 182). -spec on_drag_start( lily@store:store(GFV, GFW), binary(), fun((integer(), integer()) -> GFW) ) -> lily@store:store(GFV, GFW). on_drag_start(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"dragstart"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 194). -spec on_drop( lily@store:store(GGB, GGC), binary(), fun((integer(), integer()) -> GGC) ) -> lily@store:store(GGB, GGC). on_drop(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"drop"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 254). -spec on_mouse_down( lily@store:store(GHF, GHG), binary(), fun((integer(), integer()) -> GHG) ) -> lily@store:store(GHF, GHG). on_mouse_down(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"mousedown"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 290). -spec on_mouse_move( lily@store:store(GHX, GHY), binary(), fun((integer(), integer()) -> GHY) ) -> lily@store:store(GHX, GHY). on_mouse_move(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"mousemove"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 302). -spec on_mouse_up( lily@store:store(GID, GIE), binary(), fun((integer(), integer()) -> GIE) ) -> lily@store:store(GID, GIE). on_mouse_up(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"mouseup"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 326). -spec on_pointer_down( lily@store:store(GIP, GIQ), binary(), fun((integer(), integer()) -> GIQ) ) -> lily@store:store(GIP, GIQ). on_pointer_down(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"pointerdown"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 338). -spec on_pointer_move( lily@store:store(GIV, GIW), binary(), fun((integer(), integer()) -> GIW) ) -> lily@store:store(GIV, GIW). on_pointer_move(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"pointermove"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 350). -spec on_pointer_up( lily@store:store(GJB, GJC), binary(), fun((integer(), integer()) -> GJC) ) -> lily@store:store(GJB, GJC). on_pointer_up(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"pointerup"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 410). -spec on_touch_move( lily@store:store(GKF, GKG), binary(), fun((integer(), integer()) -> GKG) ) -> lily@store:store(GKF, GKG). on_touch_move(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"touchmove"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 422). -spec on_touch_start( lily@store:store(GKL, GKM), binary(), fun((integer(), integer()) -> GKM) ) -> lily@store:store(GKL, GKM). on_touch_start(Store, Selector, Handler) -> nil = setup_coordinate_event( Selector, <<"touchstart"/utf8>>, fun(X, Y) -> lily@client:send_msg(Handler(X, Y)) end ), Store. -file("src/lily/component.gleam", 512). -spec setup_key_event(binary(), binary(), fun((binary()) -> nil)) -> nil. setup_key_event(_, _, _) -> nil. -file("src/lily/component.gleam", 230). -spec on_key_down(lily@store:store(GGT, GGU), binary(), fun((binary()) -> GGU)) -> lily@store:store(GGT, GGU). on_key_down(Store, Selector, Handler) -> nil = setup_key_event( Selector, <<"keydown"/utf8>>, fun(Key) -> lily@client:send_msg(Handler(Key)) end ), Store. -file("src/lily/component.gleam", 242). -spec on_key_up(lily@store:store(GGZ, GHA), binary(), fun((binary()) -> GHA)) -> lily@store:store(GGZ, GHA). on_key_up(Store, Selector, Handler) -> nil = setup_key_event( Selector, <<"keyup"/utf8>>, fun(Key) -> lily@client:send_msg(Handler(Key)) end ), Store. -file("src/lily/component.gleam", 521). -spec setup_simple_event(binary(), binary(), fun(() -> nil)) -> nil. setup_simple_event(_, _, _) -> nil. -file("src/lily/component.gleam", 59). -spec on_blur(lily@store:store(GDL, GDM), binary(), fun(() -> GDM)) -> lily@store:store(GDL, GDM). on_blur(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"blur"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 110). -spec on_copy(lily@store:store(GEL, GEM), binary(), fun(() -> GEM)) -> lily@store:store(GEL, GEM). on_copy(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"copy"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 122). -spec on_cut(lily@store:store(GER, GES), binary(), fun(() -> GES)) -> lily@store:store(GER, GES). on_cut(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"cut"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 134). -spec on_double_click(lily@store:store(GEX, GEY), binary(), fun(() -> GEY)) -> lily@store:store(GEX, GEY). on_double_click(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"dblclick"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 158). -spec on_drag_end(lily@store:store(GFJ, GFK), binary(), fun(() -> GFK)) -> lily@store:store(GFJ, GFK). on_drag_end(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"dragend"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 206). -spec on_focus(lily@store:store(GGH, GGI), binary(), fun(() -> GGI)) -> lily@store:store(GGH, GGI). on_focus(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"focus"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 266). -spec on_mouse_enter(lily@store:store(GHL, GHM), binary(), fun(() -> GHM)) -> lily@store:store(GHL, GHM). on_mouse_enter(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"mouseenter"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 278). -spec on_mouse_leave(lily@store:store(GHR, GHS), binary(), fun(() -> GHS)) -> lily@store:store(GHR, GHS). on_mouse_leave(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"mouseleave"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 314). -spec on_paste(lily@store:store(GIJ, GIK), binary(), fun(() -> GIK)) -> lily@store:store(GIJ, GIK). on_paste(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"paste"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 362). -spec on_resize(lily@store:store(GJH, GJI), binary(), fun(() -> GJI)) -> lily@store:store(GJH, GJI). on_resize(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"resize"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 374). -spec on_scroll(lily@store:store(GJN, GJO), binary(), fun(() -> GJO)) -> lily@store:store(GJN, GJO). on_scroll(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"scroll"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 386). -spec on_submit(lily@store:store(GJT, GJU), binary(), fun(() -> GJU)) -> lily@store:store(GJT, GJU). on_submit(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"submit"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 398). -spec on_touch_end(lily@store:store(GJZ, GKA), binary(), fun(() -> GKA)) -> lily@store:store(GJZ, GKA). on_touch_end(Store, Selector, Handler) -> nil = setup_simple_event( Selector, <<"touchend"/utf8>>, fun() -> lily@client:send_msg(Handler()) end ), Store. -file("src/lily/component.gleam", 530). -spec setup_value_event(binary(), binary(), fun((binary()) -> nil)) -> nil. setup_value_event(_, _, _) -> nil. -file("src/lily/component.gleam", 71). -spec on_change(lily@store:store(GDR, GDS), binary(), fun((binary()) -> GDS)) -> lily@store:store(GDR, GDS). on_change(Store, Selector, Handler) -> nil = setup_value_event( Selector, <<"change"/utf8>>, fun(Value) -> lily@client:send_msg(Handler(Value)) end ), Store. -file("src/lily/component.gleam", 218). -spec on_input(lily@store:store(GGN, GGO), binary(), fun((binary()) -> GGO)) -> lily@store:store(GGN, GGO). on_input(Store, Selector, Handler) -> nil = setup_value_event( Selector, <<"input"/utf8>>, fun(Value) -> lily@client:send_msg(Handler(Value)) end ), Store. -file("src/lily/component.gleam", 539). -spec setup_wheel_event(binary(), fun((float(), float()) -> nil)) -> nil. setup_wheel_event(_, _) -> nil. -file("src/lily/component.gleam", 434). -spec on_wheel( lily@store:store(GKR, GKS), binary(), fun((float(), float()) -> GKS) ) -> lily@store:store(GKR, GKS). on_wheel(Store, Selector, Handler) -> nil = setup_wheel_event( Selector, fun(Delta_x, Delta_y) -> lily@client:send_msg(Handler(Delta_x, Delta_y)) end ), Store.