1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! Type-safe and composable table framework for Dioxus.
//!
//! `dioxus-tabular` provides a declarative, type-safe way to build reactive tables in Dioxus.
//! Instead of configuring tables with dynamic descriptors, you define columns as typed components
//! that own their rendering, filtering, and sorting logic.
//!
//! # Core Concepts
//!
//! - **[`Row`]**: Trait defining the unique key and identity of each row
//! - **[`GetRowData<T>`]**: Trait providing typed access to row data
//! - **[`TableColumn`]**: Trait describing how a column renders, filters, and sorts
//! - **[`Columns`]**: Automatically implemented for tuples of `TableColumn`s
//! - **[`use_tabular`]**: Hook to create a reactive table
//! - **[`TableHeaders`]** / **[`TableCells`]**: Components for rendering headers and cells
//!
//! # Quick Start
//!
//! ```rust
//! use dioxus::prelude::*;
//! use dioxus_tabular::*;
//!
//! // 1. Define your row type
//! #[derive(Clone, PartialEq)]
//! struct User {
//! id: u32,
//! name: String,
//! }
//!
//! // 2. Implement Row trait
//! impl Row for User {
//! fn key(&self) -> impl Into<String> {
//! self.id.to_string()
//! }
//! }
//!
//! // 3. Define data accessor types
//! #[derive(Clone, PartialEq)]
//! struct UserName(String);
//!
//! impl GetRowData<UserName> for User {
//! fn get(&self) -> UserName {
//! UserName(self.name.clone())
//! }
//! }
//!
//! // 4. Define a column
//! #[derive(Clone, PartialEq)]
//! struct NameColumn;
//!
//! impl<R: Row + GetRowData<UserName>> TableColumn<R> for NameColumn {
//! fn column_name(&self) -> String {
//! "name".into()
//! }
//!
//! fn render_header(&self, _context: ColumnContext, attributes: Vec<Attribute>) -> Element {
//! rsx! { th { ..attributes, "Name" } }
//! }
//!
//! fn render_cell(&self, _context: ColumnContext, row: &R, attributes: Vec<Attribute>) -> Element {
//! rsx! { td { ..attributes, "{row.get().0}" } }
//! }
//! }
//!
//! // 5. Use in your component
//! fn app() -> Element {
//! let users = use_signal(|| vec![
//! User { id: 1, name: "Alice".to_string() },
//! User { id: 2, name: "Bob".to_string() },
//! ]);
//!
//! let data = use_tabular((NameColumn,), users.into());
//!
//! rsx! {
//! table {
//! thead { tr { TableHeaders { data } } }
//! tbody {
//! for row in data.rows() {
//! tr { key: "{row.key()}", TableCells { row } }
//! }
//! }
//! }
//! }
//! }
//! ```
//!
//! # Features
//!
//! ## Multi-Column Sorting
//!
//! Columns can implement custom comparison logic via [`TableColumn::compare`].
//! Users can sort by multiple columns with priority control using [`ColumnContext::request_sort`].
//!
//! ## Row Filtering
//!
//! Columns can implement filtering logic via [`TableColumn::filter`].
//! Filters are automatically applied when rendering rows.
//!
//! ## Column Ordering and Visibility
//!
//! Control which columns are displayed and in what order using methods on [`ColumnContext`]:
//! - `hide()` / `show()` - Toggle column visibility
//! - `move_to()`, `move_forward()`, `move_backward()` - Reorder columns
//! - `reset_order()` - Restore default state
//!
//! ## Export (optional feature)
//!
//! Enable the `export` feature to serialize table data:
//!
//! ```toml
//! dioxus-tabular = { version = "0.1", features = ["export"] }
//! ```
//!
//! Implement [`SerializableColumn`] and use the [`Exporter`] trait to export to various formats.
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;