Skip to content

Commit 367a5ea

Browse files
authored
Merge pull request #60 from kstep/leptos-0.7
leptos 0.7 and leptos-use 0.15 compatibility
2 parents 23ca79b + d17b5bd commit 367a5ea

16 files changed

Lines changed: 117 additions & 134 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ readme = "README.md"
1212
repository = "https://github.com/Synphonyte/leptos-struct-table"
1313

1414
[dependencies]
15-
leptos = { version = "0.7.0-beta" }
15+
leptos = { version = "0.7.0" }
1616
leptos-struct-table-macro = { version = "0.11.2" }
17-
leptos-use = "0.14.0-beta"
17+
leptos-use = "0.15.0"
1818
rust_decimal = { version = "1.35", optional = true }
1919
chrono = { version = "0.4", optional = true }
2020
send_wrapper = "0.6"

examples/editable/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ fn main() {
6363
]);
6464

6565
let on_change = move |evt: ChangeEvent<Book>| {
66-
rows.update(|rows| {
67-
rows[evt.row_index] = evt.changed_row;
68-
});
66+
rows.write()[evt.row_index] = evt.changed_row;
6967
};
7068

7169
view! {

examples/selectable/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod tailwind;
22

3-
use ::chrono::NaiveDate;
3+
use chrono::NaiveDate;
44
use leptos::prelude::*;
55
use leptos_struct_table::*;
66
use tailwind::TailwindClassesPreset;
@@ -66,9 +66,7 @@ fn main() {
6666
selection=Selection::Single(selected_index)
6767
row_class="select-none"
6868
on_selection_change={move |evt: SelectionChangeEvent<Book>| {
69-
set_selected_row.update(|selected_row| {
70-
*selected_row = Some(evt.row);
71-
})
69+
set_selected_row.write().replace(evt.row);
7270
}}
7371
sorting_mode=SortingMode::SingleColumn
7472
/>

src/cell_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use leptos::prelude::*;
22

3-
#[derive(Default)]
3+
#[derive(Default, Clone, Copy)]
44
pub struct NumberRenderOptions {
55
/// Specifies the number of digits to display after the decimal point
66
pub precision: Option<usize>,

src/components/cell/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn DefaultTableCellRenderer<T, F, M>(
1212
class: String,
1313
/// The value to display.
1414
#[prop(into)]
15-
value: MaybeSignal<T>,
15+
value: Signal<T>,
1616
/// Event handler called when the cell is changed. In this default renderer this will never happen.
1717
on_change: F,
1818
/// The index of the column. Starts at 0.
@@ -23,6 +23,7 @@ pub fn DefaultTableCellRenderer<T, F, M>(
2323
where
2424
T: CellValue<M> + Send + Sync + Clone + 'static,
2525
F: Fn(T) + 'static,
26+
M: 'static,
2627
{
2728
view! {
2829
<td class=class>{move || value.get().render_value(options.clone())}</td>

src/components/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ macro_rules! wrapper_render_fn {
2929
/// * `class` - The class attribute that is passed to the root element
3030
$(#[$additional_doc])*
3131
#[allow(non_snake_case)]
32-
pub fn $name(content: View, class: Signal<String>) -> impl IntoView {
32+
pub fn $name(content: AnyView, class: Signal<String>) -> impl IntoView {
3333
view! {
3434
<$tag class=class>
3535
{content}

src/components/renderer_fn.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ macro_rules! renderer_fn {
55
) => {
66
#[derive(Clone)]
77
pub struct $name<$($ty),*> (
8-
Rc<dyn Fn($($arg_ty),*) -> AnyView<Dom>>,
8+
Arc<dyn Fn($($arg_ty),*) -> AnyView + Sync + Send + 'static>,
99
)
1010
where $($clause)*;
1111

1212
impl<F, Ret, $($ty),*> From<F> for $name<$($ty),*>
1313
where
14-
F: Fn($($arg_ty),*) -> Ret + 'static,
15-
Ret: IntoView,
14+
F: Fn($($arg_ty),*) -> Ret + Sync + Send + 'static,
15+
Ret: IntoView + 'static,
1616
$($clause)*
1717
{
1818
fn from(f: F) -> Self {
19-
Self(Rc::new(move |$($arg_name),*| {
20-
f($($arg_name),*).into_view()
19+
Self(Arc::new(move |$($arg_name),*| {
20+
f($($arg_name),*).into_any()
2121
}))
2222
}
2323
}
2424

2525
impl<$($ty),*> $name <$($ty),*>
2626
where $($clause)*
2727
{
28-
pub fn run(&self, $($arg_name: $arg_ty),*) -> AnyView<Dom> {
28+
pub fn run(&self, $($arg_name: $arg_ty),*) -> AnyView {
2929
(self.0)($($arg_name),*)
3030
}
3131
}
@@ -45,8 +45,8 @@ macro_rules! renderer_fn {
4545
where $($clause)*
4646
{
4747
fn default() -> Self {
48-
Self(Rc::new(move |$($arg_name),*| {
49-
$default($($arg_name),*).into_view()
48+
Self(Arc::new(move |$($arg_name),*| {
49+
$default($($arg_name),*).into_any()
5050
}))
5151
}
5252
}

src/components/row.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ pub fn DefaultLoadingRowRenderer(
5656
<tr class=class>
5757
{
5858
(0..col_count).map(|col_index| view! {
59-
<td class=get_cell_class.call(col_index)>
60-
<div class=get_inner_cell_class.call(col_index)></div>
59+
<td class=get_cell_class.run(col_index)>
60+
<div class=get_inner_cell_class.run(col_index)></div>
6161
" "
6262
</td>
6363
}).collect_view()

0 commit comments

Comments
 (0)