-module(spectator@internal@views@table). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([heading/7, map_rows/2]). -file("/Users/jonas/Projects/spectator/src/spectator/internal/views/table.gleam", 11). -spec heading( binary(), binary(), ARCQ, ARCQ, spectator@internal@api:sort_direction(), fun((ARCQ) -> ARCR), boolean() ) -> lustre@internals@vdom:element(ARCR). 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("/Users/jonas/Projects/spectator/src/spectator/internal/views/table.gleam", 54). -spec map_and_append(list(ARCY), fun((ARCY) -> ARDA), list(ARDA), ARDA) -> list(ARDA). 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("/Users/jonas/Projects/spectator/src/spectator/internal/views/table.gleam", 45). -spec map_rows(list(ARCT), fun((ARCT) -> lustre@internals@vdom:element(ARCV))) -> list(lustre@internals@vdom:element(ARCV)). map_rows(List, Fun) -> map_and_append( List, Fun, [], lustre@element@html:tr( [lustre@attribute:class(<<"buffer-row"/utf8>>)], [lustre@element@html:td([], [])] ) ).