-module(spectator@internal@views@table). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/spectator/internal/views/table.gleam"). -export([heading/7, map_rows/2]). -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(false). -file("src/spectator/internal/views/table.gleam", 11). ?DOC(false). -spec heading( binary(), binary(), ACZC, ACZC, spectator@internal@api:sort_direction(), fun((ACZC) -> ACZD), boolean() ) -> lustre@vdom@vnode:element(ACZD). heading( Name, Title, Sort_criteria, Current_sort_criteria, Current_sort_direction, Handle_heading_click, Align_right ) -> lustre@element@html:th( [lustre@attribute:title(Title), lustre@event:on_click(Handle_heading_click(Sort_criteria)), gleam@bool:guard( Align_right, lustre@attribute:class(<<"cell-right"/utf8>>), fun lustre@attribute:none/0 )], [case Current_sort_criteria =:= Sort_criteria of true -> case Current_sort_direction of ascending -> lustre@element@html:text(<<"⬆"/utf8>>); descending -> lustre@element@html:text(<<"⬇"/utf8>>) end; false -> lustre@element@html:text(<<""/utf8>>) end, lustre@element@html:text(Name)] ). -file("src/spectator/internal/views/table.gleam", 54). ?DOC(false). -spec map_and_append(list(ACZK), fun((ACZK) -> ACZM), list(ACZM), ACZM) -> list(ACZM). map_and_append(L, Fun, Acc, Item) -> case L of [] -> lists:reverse([Item | Acc]); [X | Xs] -> map_and_append(Xs, Fun, [Fun(X) | Acc], Item) end. -file("src/spectator/internal/views/table.gleam", 45). ?DOC(false). -spec map_rows(list(ACZF), fun((ACZF) -> lustre@vdom@vnode:element(ACZH))) -> list(lustre@vdom@vnode:element(ACZH)). map_rows(List, Fun) -> map_and_append( List, Fun, [], lustre@element@html:tr( [lustre@attribute:class(<<"buffer-row"/utf8>>)], [lustre@element@html:td([], [])] ) ).