Skip to content

Commit 788eda4

Browse files
committed
release 0.12.0
1 parent 1fcecbd commit 788eda4

File tree

5 files changed

+101
-46
lines changed

5 files changed

+101
-46
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.12.0] - 2024-08-14
4+
5+
### Breaking Change 🛠️
6+
7+
- Updated dependency leptos-use to version 0.12 which supports web-sys 0.3.70 which introduced breaking changes. (thanks
8+
to @frnsys)
9+
310
## [0.11.0] - 2024-08-05
411

512
### Features 🚀

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "leptos-struct-table"
3-
version = "0.11.0"
3+
version = "0.12.0"
44
edition = "2021"
55
authors = ["Marc-Stefan Cassola"]
66
categories = ["gui", "web-programming"]

README.md

Lines changed: 91 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@ Easily create Leptos table components from structs.
1515
## Features
1616

1717
- **Easy to use** - yet powerful.
18-
- **Async data loading** - The data is loaded asynchronously. This allows to load data from a REST API or a database etc.
18+
- **Async data loading** - The data is loaded asynchronously. This allows to load data from a REST API or a database
19+
etc.
1920
- **Selection** - Can be turned off or single/multi select
20-
- **Customization** - You can customize every aspect of the table by plugging in your own components for rendering rows, cells, headers. See [Custom Renderers](#custom-renderers) for more information.
21-
- **Headless** - No default styling is applied to the table. You can fully customize the classes that are applied to the table. See [Classes customization](#classes-customization) for more information.
22-
- **Sorting** - Optional. If turned on: Click on a column header to sort the table by that column. You can even sort by multiple columns.
21+
- **Customization** - You can customize every aspect of the table by plugging in your own components for rendering rows,
22+
cells, headers. See [Custom Renderers](#custom-renderers) for more information.
23+
- **Headless** - No default styling is applied to the table. You can fully customize the classes that are applied to the
24+
table. See [Classes customization](#classes-customization) for more information.
25+
- **Sorting** - Optional. If turned on: Click on a column header to sort the table by that column. You can even sort by
26+
multiple columns.
2327
- **Virtualization** - Only the visible rows are rendered. This allows for very large tables.
2428
- **Pagination** - Instead of virtualization you can paginate the table.
2529
- **Caching** - Only visible rows are loaded and cached.
26-
- **Editing** - Optional. You can provide custom renderers for editable cells. See [Editable Cells](#editable-cells) for more information.
30+
- **Editing** - Optional. You can provide custom renderers for editable cells. See [Editable Cells](#editable-cells) for
31+
more information.
2732

2833
## Usage
2934

@@ -58,7 +63,8 @@ fn main() {
5863

5964
## Server-Side Rendering
6065

61-
To use this with Leptos' server-side rendering, you can have to add `leptos-use` as a dependency to your `Cargo.toml` and
66+
To use this with Leptos' server-side rendering, you can have to add `leptos-use` as a dependency to your `Cargo.toml`
67+
and
6268
then configure it for SSR like the following.
6369

6470
```toml
@@ -78,7 +84,8 @@ ssr = [
7884
]
7985
```
8086

81-
Please see the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/Cargo.toml)
87+
Please see
88+
the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/Cargo.toml)
8289
for a working project with SSR.
8390

8491
## Data Providers
@@ -93,8 +100,10 @@ Which of the two traits you choose depends on your data source. If your data sou
93100
paginated data, as is the case for many REST APIs, you should implement [`PaginatedTableDataProvider`].
94101
Otherwise you should probably implement [`TableDataProvider`].
95102

96-
See the [paginated_rest_datasource example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/paginated_rest_datasource/src/data_provider.rs)
97-
and the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/src/data_provider.rs)
103+
See
104+
the [paginated_rest_datasource example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/paginated_rest_datasource/src/data_provider.rs)
105+
and
106+
the [serverfn_sqlx example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/serverfn_sqlx/src/data_provider.rs)
98107
for working demo projects that implement these traits.
99108

100109
## Macro options
@@ -105,44 +114,71 @@ The `#[table(...)]` attribute can be used to customize the generated component.
105114

106115
These attributes can be applied to the struct itself.
107116

108-
- **`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control sorting.
109-
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
110-
- `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by priority.
111-
- `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another column will simply replace the sorting column.
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.
114-
- **`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that are applied to the table.
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.
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.
117-
- **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>` to allow
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.
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.
117+
- **`sortable`** - Specifies that the table should be sortable. This makes the header titles clickable to control
118+
sorting.
119+
You can specify two sorting modes with the prop `sorting_mode` on the `TableContent` component:
120+
- `sorting_mode=SortingMode::MultiColumn` (the default) allows the table to be sorted by multiple columns ordered by
121+
priority.
122+
- `sorting_mode=SortingMode::SingleColumn"` allows the table to be sorted by a single column. Clicking on another
123+
column will simply replace the sorting column.
124+
See
125+
the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs)
126+
and the
127+
[selectable example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/selectable/src/main.rs)
128+
for more information.
129+
- **`classes_provider`** - Specifies the name of the class provider. Used to quickly customize all of the classes that
130+
are applied to the table.
131+
For convenience sensible presets for major CSS frameworks are provided. See [`TableClassesProvider`]
132+
and [tailwind example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/tailwind/src/main.rs)
133+
for more information.
134+
- **`head_cell_renderer`** - Specifies the name of the header cell renderer component. Used to customize the rendering
135+
of header cells. Defaults to [`DefaultTableHeaderRenderer`]. See
136+
the [custom_renderers_svg example](https://github.com/Synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs)
137+
for more information.
138+
- **`impl_vec_data_provider`** - If given, then [`TableDataProvider`] is automatically implemented for `Vec<ThisStruct>`
139+
to allow
140+
for easy local data use. See
141+
the [simple example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/simple/src/main.rs) for
142+
more information.
143+
- **`row_type`** - Specifies the type of the rows in the table. Defaults to the struct that this is applied to. See
144+
the [custom_type example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_type/src/main.rs)
145+
for more information.
120146

121147
### Field attributes
122148

123149
These attributes can be applied to any field in the struct.
124150

125-
- **`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.
126-
- **`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.
127-
- **`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.
128-
- **`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the table.
129-
- **`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.
151+
- **`class`** - Specifies the classes that are applied to each cell (head and body) in the field's column. Can be used
152+
in conjuction with `classes_provider` to customize the classes.
153+
- **`head_class`** - Specifies the classes that are applied to the header cell in the field's column. Can be used in
154+
conjuction with `classes_provider` to customize the classes.
155+
- **`cell_class`** - Specifies the classes that are applied to the body cells in the field's column. Can be used in
156+
conjuction with `classes_provider` to customize the classes.
157+
- **`skip`** - Specifies that the field should be skipped. This is useful for fields that are not displayed in the
158+
table.
159+
- **`skip_sort`** - Only applies if `sortable` is set on the struct. Specifies that the field should not be used for
160+
sorting. Clicking it's header will not do anything.
130161
- **`skip_header`** - Makes the title of the field not be displayed in the head row.
131-
- **`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"`).
162+
- **`title`** - Specifies the title that is displayed in the header cell. Defaults to the field name converted to title
163+
case (`this_field` becomes `"This Field"`).
132164
- **`renderer`** - Specifies the name of the cell renderer component. Used to customize the rendering of cells.
133-
Defaults to [`DefaultTableCellRenderer`].
134-
- **`format`** - Quick way to customize the formatting of cells without having to create a custom renderer. See [Formatting](#formatting) below for more information.
135-
- **`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when rendering.
165+
Defaults to [`DefaultTableCellRenderer`].
166+
- **`format`** - Quick way to customize the formatting of cells without having to create a custom renderer.
167+
See [Formatting](#formatting) below for more information.
168+
- **`getter`** - Specifies a method that returns the value of the field instead of accessing the field directly when
169+
rendering.
136170
- **`none_value`** - Specifies a display value for `Option` types when they are `None`. Defaults to empty string
137171

138172
#### Formatting
139173

140-
The `format` attribute can be used to customize the formatting of cells. It is an easier alternative to creating a custom renderer when you just want to customize some basic formatting.
141-
It is type safe and tied to the type the formatting is applied on. see [`CellValue`] and the associated type for the type you are rendering to see a list of options
174+
The `format` attribute can be used to customize the formatting of cells. It is an easier alternative to creating a
175+
custom renderer when you just want to customize some basic formatting.
176+
It is type safe and tied to the type the formatting is applied on. see [`CellValue`] and the associated type for the
177+
type you are rendering to see a list of options
142178

143179
See:
144-
- [`cell_value::NumberRenderOptions`]
145180

181+
- [`cell_value::NumberRenderOptions`]
146182

147183
## Features
148184

@@ -154,7 +190,8 @@ See:
154190
## Classes Customization
155191

156192
Classes can be easily customized by using the `classes_provider` attribute on the struct.
157-
You can specify any type that implementats the trait [`TableClassesProvider`]. Please see the documentation for that trait for more information.
193+
You can specify any type that implementats the trait [`TableClassesProvider`]. Please see the documentation for that
194+
trait for more information.
158195
You can also look at [`TailwindClassesPreset`] for an example how this can be implemented.
159196

160197
Example:
@@ -226,14 +263,17 @@ value you want to modify before it's rendered.
226263
## Custom Renderers
227264

228265
Custom renderers can be used to customize almost every aspect of the table.
229-
They are specified by using the various `...renderer` attributes on the struct or fields or props of the [`TableContent`] component.
266+
They are specified by using the various `...renderer` attributes on the struct or fields or props of the [
267+
`TableContent`] component.
230268
To implement a custom renderer please have a look at the default renderers listed below.
231269

232270
On the struct level you can use this attribute:
271+
233272
- **`thead_cell_renderer`** - Defaults to [`DefaultTableHeaderCellRenderer`] which renders `<th><span>Title</span></th>`
234-
together with sorting functionality (if enabled).
273+
together with sorting functionality (if enabled).
235274

236275
As props of the [`TableContent`] component you can use the following:
276+
237277
- **`thead_renderer`** - Defaults to [`DefaultTableHeadRenderer`] which just renders the tag `thead`.
238278
- **`thead_row_renderer`** - Defaults to [`DefaultTableHeadRowRenderer`] which just renders the tag `tr`.
239279
- **`tbody_renderer`** - Defaults to the tag `tbody`. Takes no attributes.
@@ -245,7 +285,8 @@ As props of the [`TableContent`] component you can use the following:
245285
On the field level you can use the **`renderer`** attribute.
246286

247287
It defaults to [`DefaultTableCellRenderer`]
248-
Works for any type that implements the [`CellValue`] trait that is implemented for types in the standard library, popular crates with feature flags and for your own type if you implement this trait for them.
288+
Works for any type that implements the [`CellValue`] trait that is implemented for types in the standard library,
289+
popular crates with feature flags and for your own type if you implement this trait for them.
249290

250291
Example:
251292

@@ -276,8 +317,9 @@ where
276317
}
277318
```
278319

279-
For more detailed information please have a look at the [custom_renderers_svg example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs) for a complete customization.
280-
320+
For more detailed information please have a look at
321+
the [custom_renderers_svg example](https://github.com/synphonyte/leptos-struct-table/blob/master/examples/custom_renderers_svg/src/main.rs)
322+
for a complete customization.
281323

282324
### Editable Cells
283325

@@ -330,19 +372,25 @@ pub fn App() -> impl IntoView {
330372
}
331373
```
332374

333-
Please have a look at the [editable example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/editable/src/main.rs) for fully working example.
375+
Please have a look at
376+
the [editable example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/editable/src/main.rs) for
377+
fully working example.
334378

335379
## Pagination / Virtualization / InfiniteScroll
336380

337-
This table component supports different display acceleration strategies. You can set them through the `display_strategy` prop of
381+
This table component supports different display acceleration strategies. You can set them through the `display_strategy`
382+
prop of
338383
the [`TableContent`] component.
339384

340385
The following options are available. Check their docs for more details.
386+
341387
- [`DisplayStrategy::Virtualization`] (default)
342388
- [`DisplayStrategy::InfiniteScroll`]
343389
- [`DisplayStrategy::Pagination`]
344390

345-
Please have a look at the [pagination example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/pagination/src/main.rs) for more information on how to use pagination.
391+
Please have a look at
392+
the [pagination example](https://github.com/Synphonyte/leptos-struct-table/tree/master/examples/pagination/src/main.rs)
393+
for more information on how to use pagination.
346394

347395
## I18n
348396

@@ -365,4 +413,4 @@ All contributions are welcome. Please open an issue or a pull request if you hav
365413
| <= 0.2 | 0.3 |
366414
| 0.3 | 0.4 |
367415
| 0.4, 0.5, 0.6 | 0.5 |
368-
| 0.7 – 0.11 | 0.6 |
416+
| 0.7 – 0.12 | 0.6 |

examples/paginated_rest_datasource/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
leptos = { version = "0.6", features = ["csr"] }
8-
leptos-use = "0.10"
8+
leptos-use = "0.12"
99
leptos-struct-table = { path = "../.." }
1010
console_error_panic_hook = "0.1"
1111
console_log = "1"

examples/serverfn_sqlx/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ console_error_panic_hook = "0.1"
1212
http = "1"
1313
leptos = { version = "0.6" }
1414
leptos-struct-table = { path = "../.." }
15-
leptos-use = "0.11"
15+
leptos-use = "0.12"
1616
leptos_axum = { version = "0.6", optional = true }
1717
leptos_meta = { version = "0.6" }
1818
leptos_router = { version = "0.6" }

0 commit comments

Comments
 (0)