Shared rendering functions used by all templates.
These provide default implementations for common UI elements like filters, bulk actions, pagination, and template switcher.
Performance Optimization
All functions expect two key assigns:
@static- Same reference always (columns, filters, ui_adapter, etc.)@state- Changes trigger re-render (page, filter_values, etc.)
This separation allows LiveView to skip re-rendering static parts.
See MishkaGervaz.Table.Behaviours.Template,
MishkaGervaz.Table.Templates.Table,
MishkaGervaz.Table.Templates.MediaGallery, and
MishkaGervaz.Table.Web.Renderer.
Summary
Functions
Checks if a filter group is visible and accessible for the current state.
Checks if a row action is visible for a given record and state.
Builds active filter chip data for custom templates.
Checks all media gallery checkboxes.
Checks all table row checkboxes and adds selection highlighting.
Format a filter value for display in a chip.
Returns the Tailwind grid-cols class for a given column count.
Returns the column count from a filter group's UI config, or nil if not set.
Pass the result to grid_cols/1 for the Tailwind class.
Returns the icon name for a filter group, falling back to "hero-funnel". Useful for custom templates rendering their own filter group UI.
Returns the resolved label for a filter group, falling back to humanized group name. Useful for custom templates rendering their own filter group UI.
Returns the CSS class for a collapsible filter group panel wrapper. Falls back to a default rounded panel style if not set in DSL.
Check if a filter value is meaningful (non-nil, non-empty).
Checks if any row actions or dropdowns are potentially visible for the current user.
Check if any bulk actions are visible for the given archive status.
Returns a CSS class for inline (non-collapsible) filters based on filter type.
Text filters get a flexible width, relation filters a minimum width, others a smaller minimum.
Only used when the group has no custom class (i.e., wrapper is "contents").
Custom templates can override this if they need different sizing.
Returns the CSS class for an inline (non-collapsible) group wrapper.
If the group has ui do class "..." end, uses that. Otherwise defaults to
"contents" which makes the wrapper transparent so filters participate
directly in the parent flex layout.
Merges dynamic relation filter state (options, loading, etc.) into filter configs.
Prepares all filter groups for rendering by custom templates.
Renders the empty state with configurable message, icon, and action.
Renders the error state with configurable message, icon, and retry button.
Renders the loading state with spinner and configurable text.
Resolve a filter chip's display value, using relation labels when available.
Sorts filter groups by their position attribute.
Unchecks all selection checkboxes and removes selection highlighting.
Functions
Checks if a filter group is visible and accessible for the current state.
Checks if a row action is visible for a given record and state.
Used by templates to filter visible row actions.
Builds active filter chip data for custom templates.
Returns {visible_chips, has_any_active_filters} where:
visible_chipsexcludesvisible: falsefilters (hidden from UI but still active in state)has_any_active_filtersis true if any filter has a value (including hidden ones)
Use has_any_active_filters for the "Clear all" button visibility so users can always
clear hidden filters (e.g., id filter from URL).
@spec check_all_gallery(Phoenix.LiveView.JS.t()) :: Phoenix.LiveView.JS.t()
Checks all media gallery checkboxes.
@spec check_all_table(Phoenix.LiveView.JS.t()) :: Phoenix.LiveView.JS.t()
Checks all table row checkboxes and adds selection highlighting.
Format a filter value for display in a chip.
Returns the Tailwind grid-cols class for a given column count.
@spec group_columns(map()) :: pos_integer() | nil
Returns the column count from a filter group's UI config, or nil if not set.
Pass the result to grid_cols/1 for the Tailwind class.
Returns the icon name for a filter group, falling back to "hero-funnel". Useful for custom templates rendering their own filter group UI.
Returns the resolved label for a filter group, falling back to humanized group name. Useful for custom templates rendering their own filter group UI.
Returns the CSS class for a collapsible filter group panel wrapper. Falls back to a default rounded panel style if not set in DSL.
Check if a filter value is meaningful (non-nil, non-empty).
Checks if any row actions or dropdowns are potentially visible for the current user.
Used by templates to decide whether to render the Actions column header.
Does not evaluate per-record visibility functions — only checks restricted and
boolean/atom visible values.
Check if any bulk actions are visible for the given archive status.
Returns true if there is at least one bulk action that should be shown for the current mode (active or archived).
Returns a CSS class for inline (non-collapsible) filters based on filter type.
Text filters get a flexible width, relation filters a minimum width, others a smaller minimum.
Only used when the group has no custom class (i.e., wrapper is "contents").
Custom templates can override this if they need different sizing.
Returns the CSS class for an inline (non-collapsible) group wrapper.
If the group has ui do class "..." end, uses that. Otherwise defaults to
"contents" which makes the wrapper transparent so filters participate
directly in the parent flex layout.
Merges dynamic relation filter state (options, loading, etc.) into filter configs.
Prepares all filter groups for rendering by custom templates.
Resolves accessible filters, splits them into visible groups (sorted by position), and identifies ungrouped filters. Each group entry includes the resolved filter structs (not just names).
Returns a map:
%{
all_filters: [filter_struct],
visible_groups: [%{group | resolved_filters: [filter_struct]}],
ungrouped_filters: [filter_struct],
inline_groups: [group], # non-collapsible
collapsible_groups: [group] # collapsible
}
@spec render_empty_state(map()) :: Phoenix.LiveView.Rendered.t()
Renders the empty state with configurable message, icon, and action.
@spec render_error_state(map()) :: Phoenix.LiveView.Rendered.t()
Renders the error state with configurable message, icon, and retry button.
@spec render_loading(map()) :: Phoenix.LiveView.Rendered.t()
Renders the loading state with spinner and configurable text.
Resolve a filter chip's display value, using relation labels when available.
Sorts filter groups by their position attribute.
@spec uncheck_all(Phoenix.LiveView.JS.t()) :: Phoenix.LiveView.JS.t()
Unchecks all selection checkboxes and removes selection highlighting.