Coverage for src / lexigram / admin / ui / organisms / data_table / layout.py: 37%
19 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-13 22:14 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-13 22:14 +0800
1"""Layout composition logic for data table component."""
3from __future__ import annotations
5from typing import Any
7from lexigram.admin.config import TableConfiguration
8from lexigram.ui import TableState, el
11class LayoutComposer:
12 """Composes layout for data table component."""
14 def __init__(self, config: TableConfiguration, state: TableState):
15 self.config = config
16 self.state = state
18 def compose(
19 self,
20 search_section: Any,
21 filter_section: Any,
22 inner_form: Any,
23 ) -> Any:
24 """Compose the layout based on state and configuration."""
25 if self.state.layout == "sidebar" and self.config.resource_prefix:
26 aside_content = ""
27 if search_section:
28 aside_content += str(el("div", search_section, class_="mb-4"))
29 if filter_section:
30 aside_content += str(el("div", filter_section, class_=""))
31 left_sidebar = el(
32 "aside",
33 aside_content,
34 class_="w-full lg:w-72 lg:mr-6 flex-shrink-0 lg:sticky lg:top-4 lg:self-start",
35 )
36 main_content = el(
37 "div",
38 inner_form,
39 class_="flex-1 min-w-0",
40 )
41 return el(
42 "div",
43 left_sidebar,
44 main_content,
45 class_="flex flex-col lg:flex-row items-start lexigram-data-table-container",
46 )
47 return el(
48 "div",
49 el("div", search_section, class_="mb-4") if search_section else "",
50 el("div", filter_section, class_="mb-4") if filter_section else "",
51 inner_form,
52 class_="block lexigram-data-table-container",
53 )