You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ for a working project with SSR.
91
91
92
92
## Data Providers
93
93
94
-
As shown in the inital usage example, when you add `#[table(impl_vec_data_provider)]` to your struct,
94
+
As shown in the initial usage example, when you add `#[table(impl_vec_data_provider)]` to your struct,
95
95
the table will automatically generate a data provider for you. You can then directly pass a `Vec<T>` to the `rows` prop.
96
96
Internally this implements the trait [`TableDataProvider`] for `Vec<T>`.
97
97
@@ -114,33 +114,33 @@ The `#[table(...)]` attribute can be used to customize the generated component.
114
114
These attributes can be applied to the struct itself.
115
115
116
116
-**`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control sorting.
117
-
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
118
-
-`sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
119
-
-`sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
117
+
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
118
+
-`sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
119
+
-`sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
120
120
121
-
See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
122
-
[selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
121
+
See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
122
+
[selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
123
123
-**`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.
124
-
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
124
+
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
125
125
-**`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering of header cells. Defaults to [`DefaultTableHeaderRenderer`]. See the [custom_renderers_svg example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs) for more information.
126
126
-**`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
127
-
for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
127
+
for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
128
128
-**`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs) for more information.
129
129
-**`i18n`** - Allows to specify the i18n scope for all fields of the struct as well as the `i18n` module path which defaults to `crate::i18n`. See [I18n](#i18n) for more information.
130
130
131
131
### Field attributes
132
132
133
133
These attributes can be applied to any field in the struct.
134
134
135
-
-**`class`** - Specifies the classes that are applied to each cell (head and body) in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
136
-
-**`head_class`** - Specifies the classes that are applied to the header cell in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
137
-
-**`cell_class`** - Specifies the classes that are applied to the body cells in the field's column. Can be used in conjuction with `classes_provider` to customize the classes.
135
+
-**`class`** - Specifies the classes that are applied to each cell (head and body) in the field's column. Can be used in conjunction with `classes_provider` to customize the classes.
136
+
-**`head_class`** - Specifies the classes that are applied to the header cell in the field's column. Can be used in conjunction with `classes_provider` to customize the classes.
137
+
-**`cell_class`** - Specifies the classes that are applied to the body cells in the field's column. Can be used in conjunction with `classes_provider` to customize the classes.
138
138
-**`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the table.
139
139
-**`skip_sort`** - Only applies if `sortable` is set on the struct. Specifies that the field should not be used for sorting. Clicking it's header will not do anything.
140
140
-**`skip_header`** - Makes the title of the field not be displayed in the head row.
141
141
-**`title`** - Specifies the title that is displayed in the header cell. Defaults to the field name converted to title case (`this_field` becomes `"This Field"`).
142
142
-**`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
143
-
Defaults to [`DefaultTableCellRenderer`].
143
+
Defaults to [`DefaultTableCellRenderer`].
144
144
-**`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
145
145
-**`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
146
146
-**`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
@@ -165,7 +165,7 @@ See:
165
165
## Classes Customization
166
166
167
167
Classes can be easily customized by using the `classes_provider` attribute on the struct.
168
-
You can specify any type that implementats the trait [`TableClassesProvider`]. Please see the documentation for that trait for more information.
168
+
You can specify any type that implements the trait [`TableClassesProvider`]. Please see the documentation for that trait for more information.
169
169
You can also look at [`TailwindClassesPreset`] for an example how this can be implemented.
170
170
171
171
Example:
@@ -228,7 +228,7 @@ impl Book {
228
228
### When to use `FieldGetter` vs `getter` attribute
229
229
230
230
A field of type `FieldGetter<T>` is a virtual field that doesn't really exist on the struct.
231
-
Internally `FieldGetter` is just a new-typed `PhatomData` and thus is removed during compilation.
231
+
Internally `FieldGetter` is just a new-typed `PhantomData` and thus is removed during compilation.
232
232
Hence it doesn't increase memory usage. That means you should use it for purely derived data.
233
233
234
234
The `getter` attribute should be used on a field that actually exists on the struct but whose
@@ -242,7 +242,7 @@ To implement a custom renderer please have a look at the default renderers liste
242
242
243
243
On the struct level you can use this attribute:
244
244
-**`thead_cell_renderer`** - Defaults to [`DefaultTableHeaderCellRenderer`] which renders `<th><span>Title</span></th>`
245
-
together with sorting functionality (if enabled).
245
+
together with sorting functionality (if enabled).
246
246
247
247
As props of the [`TableContent`] component you can use the following:
248
248
-**`thead_renderer`** - Defaults to [`DefaultTableHeadRenderer`] which just renders the tag `thead`.
@@ -366,4 +366,4 @@ and at the sections [Struct attributes](#struct-attributes) and
366
366
367
367
All contributions are welcome. Please open an issue or a pull request if you have any ideas or problems.
Copy file name to clipboardExpand all lines: src/lib.rs
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -45,6 +45,16 @@
45
45
//! }
46
46
//! ```
47
47
//!
48
+
//! # Leptos Compatibility
49
+
//!
50
+
//! | Crate version | Compatible Leptos version |
51
+
//! |---------------|---------------------------|
52
+
//! | <= 0.2 | 0.3 |
53
+
//! | 0.3 | 0.4 |
54
+
//! | 0.4, 0.5, 0.6 | 0.5 |
55
+
//! | 0.7 – 0.12 | 0.6 |
56
+
//! | 0.14.0-beta2 | 0.7 |
57
+
//!
48
58
//! # Server-Side Rendering
49
59
//!
50
60
//! To use this with Leptos' server-side rendering, you can have to add `leptos-use` as a dependency to your `Cargo.toml` and
@@ -95,17 +105,17 @@
95
105
//! These attributes can be applied to the struct itself.
96
106
//!
97
107
//! - **`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control sorting.
98
-
//! You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
99
-
//! - `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
100
-
//! - `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
108
+
//! You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
109
+
//! - `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
110
+
//! - `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
101
111
//!
102
-
//! See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
103
-
//! [selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
112
+
//! See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) and the
113
+
//! [selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs) for more information.
104
114
//! - **`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.
105
-
//! For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
115
+
//! For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`] and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs) for more information.
106
116
//! - **`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering of header cells. Defaults to [`DefaultTableHeaderRenderer`]. See the [custom_renderers_svg example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs) for more information.
107
117
//! - **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
108
-
//! for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
118
+
//! for easy local data use. See the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for more information.
109
119
//! - **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs) for more information.
110
120
//! - **`i18n`** - Allows to specify the i18n scope for all fields of the struct as well as the `i18n` module path which defaults to `crate::i18n`. See [I18n](#i18n) for more information.
111
121
//!
@@ -121,7 +131,7 @@
121
131
//! - **`skip_header`** - Makes the title of the field not be displayed in the head row.
122
132
//! - **`title`** - Specifies the title that is displayed in the header cell. Defaults to the field name converted to title case (`this_field` becomes `"This Field"`).
123
133
//! - **`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
124
-
//! Defaults to [`DefaultTableCellRenderer`].
134
+
//! Defaults to [`DefaultTableCellRenderer`].
125
135
//! - **`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
126
136
//! - **`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
127
137
//! - **`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
0 commit comments