Elements

UI element definitions for the UI Generator system.

This module provides the core building blocks for constructing user interfaces, including base classes, containers, and interactive elements. All elements support state management, data binding, and event handling.

Main Components

Configuration Enums:

Visual and behavioural configuration options for UI elements:

  • ElementSize: Predefined size options (EXTRA_SMALL to THREE_EXTRA_LARGE)

  • ActionType: Element behaviour (VALUE for data updates, EVENTS for triggers)

  • TextVariant: Text presentation styles (SPAN for inline, PARAGRAPH for block)

  • FontWeight: Text thickness (REGULAR, SEMI_BOLD, BOLD)

  • BadgeVariant: Badge visual styles (DEFAULT, UPDATED)

  • ContainerType: Layout models (FLEX, GRID)

  • LayoutStyle: Card layout modes (LIST, GRID)

  • GridOrder: Grid element arrangement (ROW, COLUMN)

  • RowSpacing: Vertical spacing options (NONE, TIGHT, RELAXED)

  • AlignContent: Alignment options (CENTER, SPACE_BETWEEN)

  • LayoutDirection: List layout direction (ROW, COLUMN)

  • OverflowStrategy: Overflow handling for list containers (CLIP, SCROLL, SUMMARISE)

Base Classes:

Foundation classes providing common functionality:

  • BaseElement: Abstract base with state management (disabled, required, hidden, etc.)

  • Element: Base for all UI elements with property mapping and sizing

  • ElementContainer: Base for elements that contain child elements

Container Elements:

Layout components for grouping and organizing UI elements:

  • Container: Flexible layout container with flex/grid display modes

  • Card: Rich container with customizable layout, styling, and interaction

  • Badge: Compact label for status or metadata display

  • OverflowElement: Replacement element shown for overflowing items in a ListElement

Interactive Elements:

User input and interaction components:

  • Button: Clickable button with text, icons, and event handling

  • Checkbox: Standard checkbox with check/uncheck events

  • IconCheckbox: Checkbox using custom icons for on/off states

  • Slider: Toggle slider for boolean values or event triggers

  • ReviewRating: Star rating or similar review component

Display Elements:

Components for presenting information:

  • Text: Text display with styling, variants, and tooltips

  • IconElement: Icon display with click handling and tooltips

  • ListElement: Renders all rows of a table using a reusable element template

Link Elements:

Navigation components:

  • ModelEditorLink: Hyperlink that opens the Daitum model editor

Helper Functions:
  • get_boolean_variable(): Converts Field/Parameter/Calculation/bool to ModelVariable

  • get_model_variable(): Converts model objects to ModelVariable descriptors

Element Hierarchy

All UI elements inherit from BaseElement or Element:

BaseElement (ABC)
└── Element
    ├── ElementContainer
    │   ├── Container
    │   ├── Card
    │   ├── Badge
    │   └── OverflowElement
    ├── Button
    ├── Checkbox
    ├── IconElement
    ├── IconCheckbox
    ├── ListElement
    ├── ModelEditorLink
    ├── ReviewRating
    ├── Slider
    └── Text

State Management

Elements support dynamic state configuration through BaseElement methods:

  • add_conditional_disabled(): Make element non-interactive

  • add_conditional_required(): Mark as required for form validation

  • add_conditional_read_only(): Prevent editing

  • add_conditional_error/warning/success/info(): Visual feedback states

  • add_conditional_hidden(): Hide element (optionally reserving space)

Each state can be bound to a Field, Parameter, Calculation, or boolean value.

Data Binding

Elements can bind to data sources using:

  • Field: Direct table field reference

  • Parameter: Named parameter value

  • Calculation: Computed value

  • ContextVariable: Runtime context variable

  • TemplateBindingKey: Template-based dynamic binding

Event Handling

Interactive elements support ModelEvent binding for user actions:

  • on_click: Button and icon click events

  • on_check/on_uncheck: Checkbox state changes

  • toggle_on/toggle_off: Slider state changes

Elements can operate in two action modes:

  • ActionType.VALUE: Updates bound data source

  • ActionType.EVENTS: Triggers events without updating values

Examples

Creating a text element:

# Static text
label = Text(value="Hello World", font_weight=FontWeight.BOLD)

# Dynamic text bound to a field
user_name = Text(value=user_table.name_field, color="#333333")

Creating an interactive button:

save_button = Button(
    text_value="Save",
    background_color="#007bff",
    on_click=save_event
)

Creating a checkbox with state management:

agree_checkbox = Checkbox(data_source=agreement_field)
agree_checkbox.add_conditional_required(True)
agree_checkbox.add_conditional_disabled(is_locked_field)

Creating a card container:

user_card = Card(
    layout_style=LayoutStyle.GRID,
    row_spacing=RowSpacing.RELAXED,
    border_radius="8px"
)
user_card.add_element(Text(value="Name:"))
user_card.add_element(Text(value=user_table.name_field))

Creating elements with events:

# Checkbox that triggers events instead of updating values
notify_checkbox = Checkbox(data_source=notification_field)
notify_checkbox.set_on_event(enable_notifications_event)
notify_checkbox.set_off_event(disable_notifications_event)

Creating a list element:

# Render every row of employees_table using a card template.
# TemplateBindingKey declares a placeholder inside the template;
# add_template_field_mapping connects each placeholder to a real field.
name_key = TemplateBindingKey("name")
role_key = TemplateBindingKey("role")

template_card = Card(layout_style=LayoutStyle.LIST)
template_card.add_element(Text(value=name_key, font_weight=FontWeight.BOLD))
template_card.add_element(Text(value=role_key))

employee_list = ListElement(
    data_source=employees_table,
    template=template_card,
    layout_direction=LayoutDirection.COLUMN,
)
employee_list.add_template_field_mapping(name_key, name_field)
employee_list.add_template_field_mapping(role_key, role_field)

Creating a list element with a summarise overflow:

overflow = OverflowElement()
overflow.add_element(Text(value="More items..."))

employee_list = ListElement(
    data_source=employees_table,
    template=template_card,
    overflow_strategy=OverflowStrategy.SUMMARISE,
    overflow_element=overflow,  # Required when strategy is SUMMARISE
)
class ElementSize(*values)[source]

Bases: Enum

Represents predefined size options for UI elements.

EXTRA_SMALL = 'EXTRA_SMALL'
SMALL = 'SMALL'
MEDIUM = 'MEDIUM'
LARGE = 'LARGE'
EXTRA_LARGE = 'EXTRA_LARGE'
TWO_EXTRA_LARGE = 'TWO_EXTRA_LARGE'
THREE_EXTRA_LARGE = 'THREE_EXTRA_LARGE'
class ActionType(*values)[source]

Bases: Enum

Defines how an element should behave when interacted with.

VALUE

Element updates a value.

EVENTS

Element triggers associated events instead of—or in addition to— updating a value.

VALUE = 'VALUE'
EVENTS = 'EVENTS'
class TextVariant(*values)[source]

Bases: Enum

Defines how text should be semantically or visually presented.

SPAN

Inline text (e.g., for labels or short phrases).

PARAGRAPH

Block-level text intended to occupy its own paragraph.

SPAN = 'SPAN'
PARAGRAPH = 'PARAGRAPH'
class FontWeight(*values)[source]

Bases: Enum

Represents the thickness or boldness of the text.

REGULAR

Standard body-weight text.

SEMI_BOLD

A slightly heavier weight, often used for emphasis.

BOLD

Strong emphasis or headings.

REGULAR = 'REGULAR'
SEMI_BOLD = 'SEMI_BOLD'
BOLD = 'BOLD'
class BadgeVariant(*values)[source]

Bases: Enum

The display variant of the badge.

DEFAULT

Standard visual appearance.

UPDATED

Indicates a visually updated or emphasised state.

DEFAULT = 'DEFAULT'
UPDATED = 'UPDATED'
class ContainerType(*values)[source]

Bases: Enum

The layout type for arranging child elements within a container.

Options:
FLEX:

Uses a flexible box layout model for responsive design.

GRID:

Uses a grid layout model for structured arrangement.

FLEX = 'flex'
GRID = 'grid'
class LayoutStyle(*values)[source]

Bases: Enum

Defines the layout style used when rendering elements inside the card.

LIST = 'LIST'
GRID = 'GRID'
class GridOrder(*values)[source]

Bases: Enum

Defines how elements are arranged in GRID layout mode.

ROW:

Every second element is placed in the second column.

COLUMN:

The first column is filled up to row_count items before placing additional items in the second column.

ROW = 'ROW'
COLUMN = 'COLUMN'
class RowSpacing(*values)[source]

Bases: Enum

Controls vertical spacing between elements within the card.

NONE = 'NONE'
TIGHT = 'TIGHT'
RELAXED = 'RELAXED'
class AlignContent(*values)[source]

Bases: Enum

Controls how elements are aligned within the card’s container.

CENTER = 'CENTER'
SPACE_BETWEEN = 'SPACE_BETWEEN'
class LayoutDirection(*values)[source]

Bases: Enum

Defines the direction in which items are laid out.

ROW:

Items are laid out horizontally.

COLUMN:

Items are laid out vertically.

ROW = 'ROW'
COLUMN = 'COLUMN'
class OverflowStrategy(*values)[source]

Bases: Enum

Defines how content that exceeds its container bounds should be handled.

CLIP

Truncates (clips) the overflowing content so that only the visible portion within the container is shown.

SCROLL

Enables scrolling, allowing users to access overflowing content via scroll interaction.

SUMMARISE

Condenses or summarises the overflowing content into a shorter representation (e.g., “…” or aggregated view).

CLIP = 'CLIP'
SCROLL = 'SCROLL'
SUMMARISE = 'SUMMARISE'
class ElementStates(is_disabled=None, is_required=None, is_read_only=None, is_error=None, is_warning=None, is_success=None, is_hidden=None, is_info=None, reserve_space=None)[source]

Bases: Buildable

Holds the conditional state flags for a UI element. Each flag is a list of Condition instances; the element enters that state when any condition evaluates to true.

is_disabled: list[Condition] | None = None
is_required: list[Condition] | None = None
is_read_only: list[Condition] | None = None
is_error: list[Condition] | None = None
is_warning: list[Condition] | None = None
is_success: list[Condition] | None = None
is_hidden: list[Condition] | None = None
is_info: list[Condition] | None = None
reserve_space: list[Condition] | None = None
get_boolean_variable(variable)[source]

Converts a boolean-like input into a ModelVariable representing a boolean value within the model.

Parameters:

variable (Field | Parameter | Calculation | bool) – The source of the boolean value. Must resolve to DataType.BOOLEAN when a Field, Parameter, or Calculation is provided.

Returns:

A model variable referencing the appropriate underlying boolean source.

Return type:

ModelVariable

Raises:

ValueError – If the provided Field, Parameter, or Calculation does not represent a boolean data type.

class BaseElement[source]

Bases: ABC, Buildable

Base class for all UI elements that support state management.

This class provides helper methods for configuring an element’s interactive properties.

element_states

Holds state flags for the element. Created only when a state-setting method is invoked.

Type:

Optional[ElementStates]

element_states: ElementStates | None
add_conditional_disabled(is_disabled)[source]

Sets whether the element is disabled (non-interactive).

Parameters:

is_disabled (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element should be disabled.

add_permission_disabled(is_base_user)[source]

Adds a permission-based condition controlling whether the element is disabled.

Parameters:

is_base_user (bool) – If True, the element is disabled for base users (non-advanced users). If False, the element is disabled for advanced users only.

add_conditional_required(is_required)[source]

Sets whether the element is required for valid form submission.

Parameters:

is_required (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element is required.

add_permission_required(is_base_user)[source]

Adds a permission-based condition controlling whether the element is required.

Parameters:

is_base_user (bool) – If True, the element is required for base users (non-advanced users). If False, the element is required for advanced users only.

add_conditional_read_only(is_read_only)[source]

Sets whether the element is read-only (not editable).

Parameters:

is_read_only (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element should be read-only.

add_permission_read_only(is_base_user)[source]

Adds a permission-based condition controlling whether the element is read-only.

Parameters:

is_base_user (bool) – If True, the element is read-only for base users (non-advanced users). If False, the element is read-only for advanced users only.

add_conditional_error(is_error)[source]

Sets whether the element is in an error state.

Parameters:

is_error (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element should show an error state.

add_permission_error(is_base_user)[source]

Adds a permission-based condition controlling whether the element is in an error state.

Parameters:

is_base_user (bool) – If True, the element shows an error state for base users (non-advanced users). If False, the element shows an error state for advanced users only.

add_conditional_warning(is_warning)[source]

Sets whether the element is in a warning state.

Parameters:

is_warning (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element should show a warning state.

add_permission_warning(is_base_user)[source]

Adds a permission-based condition controlling whether the element is in a warning state.

Parameters:

is_base_user (bool) – If True, the element shows a warning state for base users (non-advanced users). If False, the element shows a warning state for advanced users only.

add_conditional_success(is_success)[source]

Sets whether the element is in a success state.

Parameters:

is_success (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element should show a success state.

add_permission_success(is_base_user)[source]

Adds a permission-based condition controlling whether the element is in a success state.

Parameters:

is_base_user (bool) – If True, the element shows a success state for base users (non-advanced users). If False, the element shows a success state for advanced users only.

add_conditional_hidden(is_hidden)[source]

Sets whether the element is hidden in the UI.

Parameters:

is_hidden (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element should be hidden.

add_permission_hidden(is_base_user)[source]

Adds a permission-based condition controlling whether the element is hidden.

Parameters:

is_base_user (bool) – If True, the element is hidden from base users (non-advanced users). If False, the element is hidden from advanced users only.

add_conditional_info(is_info)[source]

Sets whether the element is in an info state.

Parameters:

is_info (Field | Parameter | Calculation | bool) – Condition that evaluates to True when the element should show an info state.

add_permission_info(is_base_user)[source]

Adds a permission-based condition controlling whether the element is in an info state.

Parameters:

is_base_user (bool) – If True, the element shows an info state for base users (non-advanced users). If False, the element shows an info state for advanced users only.

add_conditional_reserve_space(reserve_space)[source]

Sets whether space is reserved in the layout when the element is hidden.

Parameters:

reserve_space (Field | Parameter | Calculation | bool) – Condition that evaluates to True when space should be reserved.

add_permission_reserve_space(is_base_user)[source]

Adds a permission-based condition controlling whether space is reserved when the element is hidden.

Parameters:

is_base_user (bool) – If True, space is reserved for base users (non-advanced users). If False, space is reserved for advanced users only.

class Element(hidden=None, size=None)[source]

Bases: BaseElement

Base class for all UI elements.

property_field_mapping

Mapping between UI element properties and the underlying model or data field names that supply their values.

hidden

Indicates whether the element should be initially hidden.

size

Optional hint for how large the UI element should appear.

property_field_mapping: dict[str, str]
add_property_field_mapping(property_name, value)[source]

Adds a mapping from a UI property to a model field.

Parameters:
  • property_name (str) – The UI element property key.

  • value (Field | Parameter | Calculation | TemplateBindingKey) – The model/data name.

Return type:

None

class ElementContainer(elements=<factory>)[source]

Bases: Element

A UI element that groups and contains one or more child UI elements. Containers allow hierarchical UI layouts where multiple elements are visually or logically grouped together.

elements

The list of child UI elements contained within this container.

elements: list[Element]
add_element(element)[source]

Adds a child UI element to the container.

Parameters:

element (Element) – The UI element to add as a child of this container.

Return type:

None

class Container(elements=<factory>, display=ContainerType.FLEX, gap=None, horizontal_alignment=None)[source]

Bases: ElementContainer

A layout container used to group UI elements together.

display

CSS display property for this container, either flex or grid.

gap

Spacing between child elements. Applies to both row and column gaps for flex-based layouts.

horizontal_alignment

Determines how child elements are aligned horizontally within the container.

display: ContainerType = 'flex'
gap: str | None = None
horizontal_alignment: HorizontalAlignment | None = None
class Card(elements=<factory>, layout_style=None, row_count=None, grid_ordering=None, column_ratio=None, row_spacing=None, align_content=None, compact=None, on_click=None, on_click_key=None, border_color=None, border_left=None, border_radius=None, background_color=None, left_accent=None, right_accent=None, hover_background_color=None, hover_border_color=None, column_background_color=None, padding=None, footer=None)[source]

Bases: ElementContainer

A UI card element that displays its child elements in either a list layout or a grid layout. Cards may have customizable styling, spacing, and interaction behavior.

layout_style: LayoutStyle | None = None
row_count: int | None = None
grid_ordering: GridOrder | None = None
column_ratio: str | None = None
row_spacing: RowSpacing | None = None
align_content: AlignContent | None = None
compact: bool | None = None
on_click: ModelEvent | None = None
on_click_key: TemplateBindingKey | None = None
border_color: str | None = None
border_left: str | None = None
border_radius: str | None = None
background_color: str | None = None
left_accent: str | None = None
right_accent: str | None = None
hover_background_color: str | None = None
hover_border_color: str | None = None
column_background_color: str | None = None
padding: str | None = None
footer: Element | None = None
class Badge(elements=<factory>, variant=None, background_color=None, on_click=None, minimum_width=None)[source]

Bases: ElementContainer

A small visual label used to display short status or metadata.

variant

Determines the visual style variant of the badge.

background_color

CSS-compatible string specifying the badge’s background color.

on_click

Action to perform when the badge is clicked.

minimum_width

Minimum width for the badge, expressed in CSS-compatible units.

variant: BadgeVariant | None = None
background_color: str | None = None
on_click: ModelEvent | None = None
minimum_width: str | None = None
class OverflowElement(elements=<factory>)[source]

Bases: ElementContainer

A container element that replaces overflowing items in a ListElement when its overflow_strategy is set to OverflowStrategy.SUMMARISE.

Instead of clipping or scrolling, the list renders this element once in place of all items that did not fit within the container’s bounds. Populate it with any child elements to create a custom overflow summary — for example, a Text label such as “+5 more” or an icon paired with a count.

Example:

overflow = OverflowElement()
overflow.add_element(Text(value=overflow_count_field))

employee_list = ListElement(
    data_source=employees_table,
    template=template_card,
    overflow_strategy=OverflowStrategy.SUMMARISE,
    overflow_element=overflow,  # Required when strategy is SUMMARISE
)
property overflow_count
class Button(text_value=None, on_click=None, on_click_key=None, icon_source=None)[source]

Bases: Element

A clickable button UI element.

text_value

The text displayed on the button.

text_color

CSS-compatible string specifying the button’s text color.

background_color

CSS-compatible string specifying the button’s background color.

icon_source

Identifier for the icon to display, in DaitumIcon format.

icon_color

CSS-compatible string specifying the color of the icon.

on_click_key

Optional key used for click event routing or analytics.

on_click

The action to perform when the button is clicked.

text_value: str | None
text_color: str | None
background_color: str | None
icon_color: str | None
set_text_color(text_color)[source]

Sets the CSS text colour of the button.

Return type:

Button

set_background_color(background_color)[source]

Sets the CSS background colour of the button.

Return type:

Button

set_icon_color(icon_color)[source]

Sets the CSS colour of the button icon.

Return type:

Button

get_model_variable(variable)[source]

Converts a model-related object into a ModelVariable descriptor.

Parameters:

variable (Field | Parameter | Calculation | ContextVariable) – A Field, Parameter, Calculation, or ContextVariable instance representing a model value used by UI elements.

Returns:

A standardized wrapper describing the variable type (FIELD, NAMED_VALUE, or CONTEXT_VARIABLE) and its identifier.

Return type:

ModelVariable | None

Notes

  • Field → ModelVariableType.FIELD (uses field_id)

  • Parameter or Calculation → ModelVariableType.NAMED_VALUE (uses named_value_id)

  • ContextVariable → ModelVariableType.CONTEXT_VARIABLE (uses id)

class Checkbox(data_source)[source]

Bases: Element

A standard checkbox UI element.

on_check

Event triggered when the checkbox transitions to the checked state.

on_uncheck

Event triggered when the checkbox transitions to the unchecked state.

checkbox_data_source_id

Model variable that stores the current value of the checkbox.

on_click_key

Optional interaction key used for analytics or routing click events.

action_type

Determines the checkbox’s behavior when interacted with, such as updating a value or emitting a custom event.

on_check: ModelEvent | None
on_uncheck: ModelEvent | None
on_click_key: TemplateBindingKey | None
set_on_event(event)[source]

Assigns an event to be fired when the checkbox transitions into the “check” state.

Parameters:

event (ModelEvent) – The event to trigger when the checkbox becomes checked.

Return type:

Checkbox

Notes

Setting an on-event automatically changes the action_type to ActionType.EVENTS, indicating the checkbox now emits events rather than updating a value.

set_off_event(event)[source]

Assigns an event to be fired when the checkbox transitions into the “uncheck” state.

Parameters:

event (ModelEvent) – The event to trigger when the checkbox becomes unchecked.

Return type:

Checkbox

Notes

Setting an off-event automatically changes the action_type to ActionType.EVENTS, indicating the checkbox now emits events rather than updating a value.

class IconElement(icon_source=None, color=None, on_click=None, tooltip=None)[source]

Bases: Element

Represents an icon UI element.

icon_source

The icon to display. The string uses the DaitumIcon format, which is a string of the form “iconFamily.ICON”.

color

The CSS-compatible colour to render the icon.

on_click

Event triggered when the icon is clicked.

tooltip

Optional tooltip displayed when the user hovers over the icon.

icon_source: str | None = None
color: str | None = None
on_click: ModelEvent | None = None
tooltip: str | None = None
class IconCheckbox(data_source, off_icon=None, on_icon=None)[source]

Bases: Element

A checkbox UI element that uses icons to represent checked and unchecked states.

on_check

Event triggered when the checkbox transitions to the checked state.

on_uncheck

Event triggered when the checkbox transitions to the unchecked state.

icon_checkbox_data_source_id

Model variable storing the current checkbox value.

on_click_key

Optional key used to route click-based interactions such as analytics.

action_type

Specifies how the checkbox should behave when interacted with, such as updating a value or emitting an event.

off_icon

Icon displayed when the checkbox is unchecked.

on_icon

Icon displayed when the checkbox is checked.

on_check: ModelEvent | None
on_uncheck: ModelEvent | None
on_click_key: TemplateBindingKey | None
set_on_event(event)[source]

Assigns an event to be fired when the icon checkbox transitions into the “on” state.

Parameters:

event (ModelEvent) – The event to trigger when the icon checkbox turns on.

Return type:

IconCheckbox

Notes

Setting an on-event automatically changes the action_type to ActionType.EVENTS, indicating the checkbox now emits events rather than updating a value.

set_off_event(event)[source]

Assigns an event to be fired when the icon checkbox transitions into the “off” state.

Parameters:

event (ModelEvent) – The event to trigger when the icon checkbox turns off.

Return type:

IconCheckbox

Notes

Setting an off-event automatically changes the action_type to ActionType.EVENTS, indicating the checkbox now emits events rather than updating a value.

class ReviewRating(data_source)[source]

Bases: Element

A UI element representing a review rating component, consisting of filled and empty icons. It supports binding to a model variable and tracking rating state.

fill_icon

Icon configuration used to display the “filled” (selected) rating value.

empty_icon

Icon configuration used to display the “empty” (unselected) rating value.

review_rating_data_source_id

Model variable storing the current rating value (e.g., 1–5 stars).

fill_color

Optional color override for the filled icons.

fill_icon: IconConfig | None
empty_icon: IconConfig | None
fill_color: str | None
set_fill_icon(icon)[source]

Sets the icon used for filled (selected) rating values.

Return type:

ReviewRating

set_empty_icon(icon)[source]

Sets the icon used for empty (unselected) rating values.

Return type:

ReviewRating

set_fill_color(color)[source]

Sets the colour override for filled rating icons.

Return type:

ReviewRating

class Slider(data_source)[source]

Bases: Element

A slider UI element used for selecting values or triggering events.

toggle_on

Event triggered when the slider moves into an “on” state.

toggle_off

Event triggered when the slider moves into an “off” state.

slider_data_source_id

Reference to a model variable that stores the slider’s current value.

on_click_key

An optional interaction key used to associate click behaviour (e.g., analytics or event routing).

action_type

Determines whether the slider updates a value or emits events when interacted with.

toggle_on: ModelEvent | None
toggle_off: ModelEvent | None
on_click_key: TemplateBindingKey | None
set_on_event(event)[source]

Assigns an event to be fired when the slider transitions into the “on” state.

Parameters:

event (ModelEvent) – The event to trigger when the slider switches from off to on.

Return type:

Slider

Notes

Setting an on-event automatically changes the slider’s action_type to ActionType.EVENTS, indicating the slider now emits events rather than updating a value.

set_off_event(event)[source]

Assigns an event to be fired when the slider transitions into the “off” state.

Parameters:

event (ModelEvent) – The event to trigger when the slider switches from on to off.

Return type:

Slider

Notes

Setting an off-event automatically changes the slider’s action_type to ActionType.EVENTS, indicating the slider now emits events rather than updating a value.

class Text(value, color=None, font_weight=None, variant=None, show_tool_tip=False)[source]

Bases: Element

A text UI element used for displaying static or dynamic textual content.

value

The string content to be displayed.

color

Optional CSS-compatible colour for the text.

font_weight

The thickness of the displayed text.

variant

The presentation style of the text (inline or paragraph).

show_tool_tip

Whether the text should display a tooltip containing its full value. Useful when the displayed text is too long and may be truncated, but the user still needs access to the complete, non-truncated content.

set_color(color)[source]

Sets the CSS colour for this text element.

Return type:

Text

set_font_weight(weight)[source]

Sets the font weight for this text element.

Return type:

Text

set_variant(variant)[source]

Sets the presentation variant (inline or paragraph) for this text element.

Return type:

Text

class ListElement(data_source, template, layout_direction=LayoutDirection.COLUMN, overflow_strategy=OverflowStrategy.SCROLL, overflow_element=None)[source]

Bases: Element

A display element that renders every row of a data table using a reusable element template.

For each row in the source table, the template is instantiated and its placeholder values are resolved via field bindings. Placeholders are declared inside the template using TemplateBindingKey; bindings are registered with add_template_field_mapping(), which maps each placeholder key to the corresponding field in the source table.

data_source

Model variable referencing the data source. Set when a Field or NamedValue is provided; None when a Table is provided directly.

Type:

ModelVariable | None

source_table

ID of the source table. Set when a Table is provided; None when a Field or NamedValue is provided instead.

Type:

str | None

template

The element used as a template for each row.

Type:

Optional[Element]

field_bindings

Resolved mapping from placeholder names to source table field IDs. Populated by add_template_field_mapping(); do not set directly.

Type:

dict[str, str]

layout_direction

The direction in which rendered items are arranged. COLUMN stacks items vertically (default); ROW places them horizontally.

Type:

LayoutDirection

wrap

When True, items wrap onto new lines when the container width is exceeded. When False or None, items are clipped or scrollable depending on the container.

Type:

Optional[bool]

overflow_strategy

Defines strategies for handling content that exceeds the bounds of its container.

Type:

OverflowStrategy

width

Defines width of the list element.

Type:

Optional[str]

height

Defines height of the list element.

Type:

Optional[str]

overflow_element

Element rendered in place of overflowing items when overflow_strategy is OverflowStrategy.SUMMARISE. Required when strategy is SUMMARISE; may also be supplied via set_overflow_element().

Type:

Optional[OverflowElement]

row_gap

Vertical spacing between rows.

Type:

Optional[str]

column_gap

Horizontal spacing between columns.

Type:

Optional[str]

data_source: ModelVariable | None
source_table: str | None
field_bindings: dict[str, str]
wrap: bool
height: str | None
width: str | None
overflow_element: OverflowElement | None
row_gap: str | None
column_gap: str | None
set_wrap(wrap)[source]

Sets whether items wrap onto multiple lines.

Return type:

ListElement

set_size(height=None, width=None)[source]

Sets the height and/or width of the list element.

Return type:

ListElement

set_overflow_element(overflow_element)[source]

Sets the element rendered in place of overflowing items when strategy is SUMMARISE.

Return type:

ListElement

set_gap(gap=None, cross_axis_gap=None)[source]

Sets the gap between items in the list.

Parameters:
  • gap (str | None) – Spacing along the main axis direction.

  • cross_axis_gap (str | None) – Spacing along the cross axis direction.

Return type:

ListElement

add_template_field_mapping(key, field)[source]

Registers a binding between a template placeholder and a source table field.

Each call adds one entry to field_bindings. The placeholder declared by key inside the template will be substituted with the value of field for each rendered row.

Parameters:
  • key (TemplateBindingKey) – The placeholder key referenced inside the template via TemplateBindingKey. Must match exactly the key used when constructing the template elements.

  • field (Field) – The source table field whose value replaces the placeholder at render time.

Return type:

None

Example::

name_key = TemplateBindingKey(“name”) employee_list.add_template_field_mapping(name_key, name_field)

class ModelEditorLink(model_id, scenario_id=None, text_value='Open Model', open_new_tab=False)[source]

Bases: Element

A hyperlink element that opens the Daitum model editor.

Renders as a clickable text link. The model and scenario to open can be bound to Field, Parameter, Calculation, or ContextVariable values so they are resolved at runtime.

text_value

The visible label of the link. Accepts a static string or a model-variable reference rendered as ${...}. Defaults to "Open Model".

Type:

str

destination

The model-editor destination built from the provided model_id, scenario_id, and open_new_tab arguments.

Type:

ModelEditorLinkDestination

text_value: str