diff --git a/examples/form-controls.rs b/examples/form-controls.rs index 29010de6..3e9a3f3d 100644 --- a/examples/form-controls.rs +++ b/examples/form-controls.rs @@ -137,11 +137,7 @@ async fn form_controls(request: HttpRequest) -> Result { ), ) // Campo oculto (form::Hidden). - .with_child( - form::Hidden::new() - .with_name("origin") - .with_value("form-selections"), - ) + .with_child(form::Hidden::field("origin", "form-selections")) // Botones de acción. .with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop( PropsOp::add_classes(class::ButtonColor::solid( @@ -261,11 +257,7 @@ async fn form_controls(request: HttpRequest) -> Result { ), ) // Campo oculto (form::Hidden). - .with_child( - form::Hidden::new() - .with_name("origin") - .with_value("form-text"), - ) + .with_child(form::Hidden::field("origin", "form-text")) // Botones de acción. .with_child(Button::submit(L10n::t("btn_submit", &LOC)).with_prop( PropsOp::add_classes(class::ButtonColor::solid( @@ -415,11 +407,7 @@ fn form_lists() -> Form { form // Campo oculto (form::Hidden). - .with_child( - form::Hidden::new() - .with_name("origin") - .with_value("form-lists"), - ) + .with_child(form::Hidden::field("origin", "form-lists")) // Botones de acción. .with_child( Button::submit(L10n::t("btn_submit", &LOC)).with_prop(PropsOp::add_classes( diff --git a/extensions/pagetop-bootsier/src/theme/bs/navbar/item.rs b/extensions/pagetop-bootsier/src/theme/bs/navbar/item.rs index 27e785aa..721dae8c 100644 --- a/extensions/pagetop-bootsier/src/theme/bs/navbar/item.rs +++ b/extensions/pagetop-bootsier/src/theme/bs/navbar/item.rs @@ -42,10 +42,10 @@ impl Component for Item { } fn setup(&mut self, _cx: &Context) { - if let Self::Nav(nav) = self { - if let Some(nav) = nav.get_mut() { - nav.alter_prop(PropsOp::prepend_classes("navbar-nav")); - } + if let Self::Nav(nav) = self + && let Some(nav) = nav.get_mut() + { + nav.alter_prop(PropsOp::prepend_classes("navbar-nav")); } } diff --git a/extensions/pagetop-bootsier/src/theme/token/layout.rs b/extensions/pagetop-bootsier/src/theme/token/layout.rs index a5df6b7c..69401e5d 100644 --- a/extensions/pagetop-bootsier/src/theme/token/layout.rs +++ b/extensions/pagetop-bootsier/src/theme/token/layout.rs @@ -52,14 +52,14 @@ impl ScaleSize { // Añade el tamaño a la cadena de clases usando el prefijo dado. #[inline] pub(crate) fn push_to(self, classes: &mut String, prefix: &str) { - if !prefix.is_empty() { - if let Some(suffix) = self.suffix() { - if !classes.is_empty() { - classes.push(' '); - } - classes.push_str(prefix); - classes.push_str(suffix); + if !prefix.is_empty() + && let Some(suffix) = self.suffix() + { + if !classes.is_empty() { + classes.push(' '); } + classes.push_str(prefix); + classes.push_str(suffix); } } } diff --git a/extensions/pagetop-htmx/src/hx.rs b/extensions/pagetop-htmx/src/hx.rs index fb4ae54b..2b5c08dc 100644 --- a/extensions/pagetop-htmx/src/hx.rs +++ b/extensions/pagetop-htmx/src/hx.rs @@ -490,6 +490,13 @@ pub mod swap { pub const INNER_HTML: &str = "innerHTML"; /// Reemplaza el elemento objetivo completo. pub const OUTER_HTML: &str = "outerHTML"; + /// Reemplaza el elemento objetivo completo y desplaza la vista al borde superior tras el + /// intercambio (combina [`OUTER_HTML`] con el modificador `scroll:top`). + /// + /// Pensado para listados paginados/ordenables cuyo `hx-swap` sustituye un contenedor completo + /// (tabla + paginador) al variar el número de filas entre páginas. Sin este anclaje la posición + /// del scroll tras el intercambio queda desajustada. + pub const OUTER_HTML_SCROLL_TOP: &str = "outerHTML scroll:top"; /// Inserta la respuesta antes de la etiqueta de apertura del objetivo. pub const BEFORE_BEGIN: &str = "beforebegin"; /// Inserta la respuesta al inicio del contenido del objetivo. diff --git a/extensions/pagetop-htmx/src/hx_pager.rs b/extensions/pagetop-htmx/src/hx_pager.rs new file mode 100644 index 00000000..7a126d17 --- /dev/null +++ b/extensions/pagetop-htmx/src/hx_pager.rs @@ -0,0 +1,32 @@ +//! Soporte HTMX al componente [`Pager`]. +//! +//! [`Pager`] no conoce HTMX ni ninguna otra librería de interactividad. Cada enlace de página ya +//! funciona como una petición normal, y el elemento `