20 template <
template <
typename...>
typename ContainerT,
typename ElementT,
typename... OtherArgs>
27 std::variant<std::monostate, std::string, Nui::Observed<std::string>
const*>
caption = std::monostate{};
59 template <
typename ModelT>
64 template <
template <
typename...>
typename ContainerT,
typename ElementT,
typename... OtherArgs>
65 class Table<ContainerT<ElementT, OtherArgs...>>
69 : tableParams_{std::move(args)}
74 using namespace Elements;
77 return table{tableParams_.tableAttributes}(
79 [cap = std::move(tableParams_.caption), capAttributes = std::move(tableParams_.captionAttributes)]() ->
Nui::ElementRenderer {
85 return caption{capAttributes}(content);
88 return caption{capAttributes}(*model);
93 [headerRenderer = std::move(tableParams_.headerRenderer), headerAttributes = std::move(tableParams_.headerAttributes)]() ->
Nui::ElementRenderer {
95 return thead{headerAttributes}(headerRenderer());
100 tbody{tableParams_.bodyAttributes}(
101 range(tableParams_.tableModel),
102 [renderer = std::move(tableParams_.rowRenderer)](
long i,
auto const& row) ->
Nui::ElementRenderer {
103 using namespace std::string_literals;
106 return renderer(i, row);
112 [footerRenderer = std::move(tableParams_.footerRenderer), footerAttributes = std::move(tableParams_.footerAttributes)]() ->
Nui::ElementRenderer {
115 tfoot{footerAttributes}(footerRenderer());
127 template <
template <
typename...>
typename ContainerT,
typename ElementT,
typename... OtherArgs>
constexpr Table(TableArguments< ContainerT, ElementT, OtherArgs... > &&args)
Definition: table.hpp:68
Nui::ElementRenderer operator()() &&
Definition: table.hpp:72
A wrapper around the html table elements.
Definition: table.hpp:61
Definition: observed_value.hpp:1202
Definition: dialog.hpp:11
Table(TableArguments< ContainerT, ElementT, OtherArgs... > &&args) -> Table< ContainerT< ElementT, OtherArgs... >>
UnoptimizedRange< IteratorAccessor< ContainerT const >, std::decay_t< Detail::ObservedAddReference_t< Observed > >... > range(ContainerT const &container, Observed &&... observed)
Definition: range.hpp:97
static auto nil()
Definition: nil.hpp:7
auto visitOverloaded(std::variant< VariantTypes... > const &variant, VisitFunctionTypes &&... visitFunctions)
Definition: visit_overloaded.hpp:10
std::function< std::shared_ptr< Dom::Element >(Dom::Element &, Renderer const &)> ElementRenderer
Definition: element_renderer.hpp:11
std::vector< Attribute > tableAttributes
Attributes to be forwarded to the table element.
Definition: table.hpp:39
std::function< Nui::ElementRenderer()> footerRenderer
The renderer for the footer. Can be empty.
Definition: table.hpp:36
std::vector< Attribute > footerAttributes
Attributes to be forwarded to the footer element.
Definition: table.hpp:51
std::vector< Attribute > bodyAttributes
Attributes to be forwarded to the body element.
Definition: table.hpp:48
std::function< Nui::ElementRenderer()> headerRenderer
The renderer for the header. Can be empty.
Definition: table.hpp:30
std::vector< Attribute > captionAttributes
Attributes to be forwarded to the caption element.
Definition: table.hpp:42
Nui::Observed< ContainerT< ElementT, OtherArgs... > > & tableModel
Contains the data to be displayed in the table.
Definition: table.hpp:24
std::function< Nui::ElementRenderer(long long i, ElementT const &)> rowRenderer
The renderer for each row.
Definition: table.hpp:33
std::variant< std::monostate, std::string, Nui::Observed< std::string > const * > caption
The caption of the table. Can be static, observed or off.
Definition: table.hpp:27
std::vector< Attribute > headerAttributes
Attributes to be forwarded to the header element.
Definition: table.hpp:45