1pub mod layout;
8pub mod components;
9pub mod icons;
10pub mod tokens;
11pub mod ferrox_datagrid;
12pub mod ferrox_kanban;
13pub mod ferrox_theme;
14pub mod ferrox_admin;
15pub mod ferrox_security_dashboard;
16pub mod json_dashboard_builder;
17pub mod form_engine;
18pub mod overlays;
19
20pub use components::*;
21pub use icons::*;
22pub use ferrox_datagrid::{
23 EnterpriseDataGrid, EnterpriseDataGridState, ColumnDef, SortDirection,
24 PinnedPosition, TextAlign, trigger_csv_download, generate_rfc4180_csv,
25 FerroxDataGridConfig, ferrox_datagrid,
26};
27pub use form_engine::{
28 FormField, RuleBuilder, ValidationRule, WizardStep, FormWizardState, form_wizard,
29};
30pub use overlays::{
31 CommandAction, CommandPaletteState, command_palette,
32 DatePickerSelection, DatePickerState, date_picker,
33 TreeNode, tree_view, modal_focus_trap,
34};
35
36use ferrox_front_core::dom::{div, span, DomBuilder};
37use ferrox_front_core::reactivity::Signal;
38
39pub struct DataGridState {
40 pub scroll_top: Signal<f64>,
41 pub row_height: f64,
42 pub visible_rows: usize,
43}
44
45impl DataGridState {
46 pub fn new(row_height: f64, visible_rows: usize) -> Self {
47 Self {
48 scroll_top: Signal::new(0.0),
49 row_height,
50 visible_rows,
51 }
52 }
53}
54
55pub fn virtual_data_grid(
56 columns: Vec<&str>,
57 rows: Vec<Vec<&str>>,
58 state: &DataGridState
59) -> DomBuilder {
60 let total_rows = rows.len();
61 let total_height = total_rows as f64 * state.row_height;
62
63 let start_idx = (state.scroll_top.get() / state.row_height).floor() as usize;
64 let end_idx = (start_idx + state.visible_rows).min(total_rows);
65
66 let mut container = div()
67 .attr("class", "ferrox-table-wrapper")
68 .attr("style", &format!("height: {}px; overflow-y: auto; position: relative;", state.row_height * state.visible_rows as f64));
69
70 let ghost = div()
71 .attr("style", &format!("height: {}px; width: 1px;", total_height));
72 container = container.child(ghost);
73
74 let mut content = div()
75 .attr("style", &format!("position: absolute; top: {}px; left: 0; width: 100%;", start_idx as f64 * state.row_height));
76
77 let mut thead = div().attr("class", "ferrox-thead").attr("style", "display: flex; background: rgba(0,0,0,0.4); font-weight: 700; border-bottom: var(--border-glass);");
78 for col in columns {
79 thead = thead.child(span().attr("style", "flex: 1; padding: 12px 16px;").text(col));
80 }
81 content = content.child(thead);
82
83 for i in start_idx..end_idx {
84 let mut tr = div().attr("class", "ferrox-tr").attr("style", &format!("display: flex; height: {}px; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.05);", state.row_height));
85 for cell in &rows[i] {
86 tr = tr.child(span().attr("style", "flex: 1; padding: 0 16px; font-size: 0.95rem;").text(cell));
87 }
88 content = content.child(tr);
89 }
90
91 container.child(content)
92}