Skip to content

Commit eab0351

Browse files
committed
ported all examples and some fixes for leptos 0.7
1 parent 30f61ff commit eab0351

45 files changed

Lines changed: 257 additions & 348 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/leptos-struct-table.iml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ repository = "https://github.com/Synphonyte/leptos-struct-table"
1313

1414
[dependencies]
1515
leptos = { version = "0.7.0" }
16-
leptos-struct-table-macro = { version = "0.12" }
17-
leptos-use = "0.15.0"
16+
leptos-struct-table-macro = { version = "0.12.0", path = "../leptos-struct-table-macro" }
17+
leptos-use = { version = "0.15.0", path = "../leptos-use" }
1818
rust_decimal = { version = "1.35", optional = true }
1919
chrono = { version = "0.4", optional = true }
2020
send_wrapper = "0.6"

examples/bootstrap/Cargo.toml

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

66
[dependencies]
7-
leptos = { version = "0.6", features = ["csr"]}
7+
leptos = { version = "0.7", features = ["csr"]}
88
leptos-struct-table = { path = "../..", features = ["chrono"] }
99
chrono = { version = "0.4" }
1010
console_error_panic_hook = "0.1"

examples/bootstrap/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn main() {
5151
view! {
5252
<div class="container".to_string()>
5353
<table class="table-hover">
54-
<TableContent rows />
54+
<TableContent rows scroll_container="html" />
5555
</table>
5656
</div>
5757
}

examples/custom_renderers_svg/Cargo.toml

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

66
[dependencies]
7-
leptos = { version = "0.6", features = ["csr"]}
7+
leptos = { version = "0.7", features = ["csr"]}
88
leptos-struct-table = { path = "../.." }
99
console_error_panic_hook = "0.1"
1010
console_log = "1"

examples/custom_renderers_svg/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ fn main() {
4545
thead_row_renderer=GRenderer
4646
thead_renderer=GRenderer
4747
tbody_renderer=SvgTbodyRenderer
48+
scroll_container="html"
4849
/>
4950
</svg>
5051
}

examples/custom_renderers_svg/src/renderers.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use leptos::html::AnyElement;
21
use leptos::prelude::*;
3-
use leptos::svg::G;
2+
use leptos::web_sys;
43
use leptos_struct_table::*;
54

65
const ROW_HEIGHT: usize = 30;
@@ -14,14 +13,11 @@ wrapper_render_fn!(
1413

1514
#[allow(non_snake_case)]
1615
pub fn SvgTbodyRenderer(
17-
content: Fragment,
16+
content: impl IntoView,
1817
class: Signal<String>,
19-
node_ref: NodeRef<AnyElement>,
18+
body_ref: BodyRef,
2019
) -> impl IntoView {
21-
let tbody_ref = create_node_ref::<G>();
22-
tbody_ref.on_load(move |e| node_ref.load(&e.into_any()));
23-
24-
view! { <g class=class node_ref=tbody_ref>{content}</g> }
20+
view! { <g class=class use:body_ref>{content}</g> }
2521
}
2622

2723
#[allow(unused_variables, non_snake_case)]
@@ -78,16 +74,16 @@ pub fn SvgErrorRowRenderer(err: String, index: usize, _col_count: usize) -> impl
7874
#[allow(non_snake_case, unstable_name_collisions)]
7975
pub fn SvgLoadingRowRenderer(
8076
class: Signal<String>,
81-
_get_cell_class: Callback<usize, String>,
82-
get_inner_cell_class: Callback<usize, String>,
77+
_get_cell_class: Callback<(usize,), String>,
78+
get_inner_cell_class: Callback<(usize,), String>,
8379
index: usize,
8480
_col_count: usize,
8581
) -> impl IntoView {
8682
let transform = y_transform_from_index(index);
8783

8884
view! {
8985
<g class=class transform=transform>
90-
<text x="0" y=ROW_HEIGHT_HALF class=get_inner_cell_class.call(0) dominant-baseline="central">
86+
<text x="0" y=ROW_HEIGHT_HALF class=get_inner_cell_class.run((0,)) dominant-baseline="central">
9187
Loading...
9288
</text>
9389
</g>
@@ -143,12 +139,12 @@ where
143139
#[allow(unused_variables)]
144140
pub fn SvgTextCellRenderer<T, F>(
145141
class: String,
146-
#[prop(into)] value: MaybeSignal<T>,
142+
#[prop(into)] value: Signal<T>,
147143
on_change: F,
148144
index: usize,
149145
) -> impl IntoView
150146
where
151-
T: IntoView + Clone + 'static,
147+
T: IntoView + Clone + Send + Sync + 'static,
152148
F: Fn(T) + 'static,
153149
{
154150
let x = x_from_index(index);
@@ -164,7 +160,7 @@ where
164160
#[allow(unused_variables)]
165161
pub fn SvgPathCellRenderer<F>(
166162
#[prop(into)] class: String,
167-
#[prop(into)] value: MaybeSignal<String>,
163+
#[prop(into)] value: Signal<String>,
168164
on_change: F,
169165
index: usize,
170166
) -> impl IntoView

examples/custom_row_renderer/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
leptos = { version = "0.6", features = ["csr"] }
7+
leptos = { version = "0.7", features = ["csr"] }
88
leptos-struct-table = { path = "../..", features = ["chrono", "uuid"] }
99
chrono = { version = "0.4" }
1010
uuid = { version = "1.8", features= ["v4"]}
1111
console_error_panic_hook = "0.1"
1212
console_log = "1"
1313
log = "0.4"
14+
getrandom = { version = "0.2", features = ["js"] }
1415

1516
[dev-dependencies]
1617
wasm-bindgen = "0.2"

examples/custom_row_renderer/src/main.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use ::chrono::NaiveDate;
55
use ::uuid::Uuid;
66
use leptos::prelude::*;
7+
use leptos::web_sys;
78
use leptos_struct_table::*;
89

910
/// Custom row renderer that adds a link to the end of the row
@@ -22,10 +23,14 @@ pub fn CustomTableRowRenderer(
2223
// Event handler callback for changes
2324
on_change: EventHandler<ChangeEvent<Book>>,
2425
) -> impl IntoView {
26+
let id = row.id.to_string();
27+
2528
view! {
2629
<tr class=class on:click=move |mouse_event| on_select.run(mouse_event)>
2730
{row.render_row(index, on_change)}
28-
<td><a href=move || format!("/some-path/{}", row.id.to_string())>"Some link"</a></td>
31+
<td>
32+
<a href=move || format!("/some-path/{}", id)>"Some link"</a>
33+
</td>
2934
</tr>
3035
}
3136
}
@@ -101,7 +106,11 @@ fn main() {
101106

102107
view! {
103108
<table>
104-
<TableContent rows=rows row_renderer=CustomTableRowRenderer/>
109+
<TableContent
110+
rows=rows
111+
row_renderer=CustomTableRowRenderer
112+
scroll_container="html"
113+
/>
105114
</table>
106115
}
107116
})

examples/custom_type/Cargo.toml

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

66
[dependencies]
7-
leptos = { version = "0.6", features = ["csr"] }
7+
leptos = { version = "0.7", features = ["csr"] }
88
leptos-struct-table = { path = "../..", features = ["chrono"] }
99
chrono = { version = "0.4" }
1010
console_error_panic_hook = "0.1"

0 commit comments

Comments
 (0)