♻️ (pagetop): setup() recibe &mut Context
Antes sólo mutaba el propio componente; ahora también puede aplicar ajustes síncronos sobre el Context, visibles para las extensiones que intercepten BeforeRender. La frontera con prepare() pasa a ser de sincronía, no de qué puede mutar cada uno.
This commit is contained in:
parent
f2a7507317
commit
1e2d171805
31 changed files with 71 additions and 59 deletions
|
|
@ -33,7 +33,7 @@ impl Component for Badge {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes(util::join!(
|
||||
"badge badge-",
|
||||
self.intent().color(cx)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ impl Component for Block {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
// Asegura que el bloque tiene un identificador único.
|
||||
self.alter_prop(PropsOp::ensure_id(cx.build_id::<Self>(1)));
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ impl Component for Brand {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes("brand"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ impl Component for Breadcrumb {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
for crumb in self.crumbs.iter_mut() {
|
||||
crumb.setup(cx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ impl Crumb {
|
|||
}
|
||||
|
||||
// Normaliza la clase base según el papel del elemento. Sólo lo usa `Breadcrumb`.
|
||||
pub(super) fn setup(&mut self, _cx: &Context) {
|
||||
pub(super) fn setup(&mut self, _cx: &mut Context) {
|
||||
if *self.is_current() {
|
||||
self.alter_prop(PropsOp::prepend_classes("active"))
|
||||
.alter_prop(PropsOp::set("aria-current", "page"));
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ impl Component for Button {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
use button::{Size, Style};
|
||||
|
||||
self.alter_prop(PropsOp::prepend_classes(match self.size() {
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl Component for Container {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
if let Some(flex) = self.flex() {
|
||||
flex.apply_to(&mut self.props);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ impl Component for Dialog {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
// Asegura que el diálogo tiene un identificador único con el que abrirlo.
|
||||
self.alter_prop(PropsOp::ensure_id(cx.build_id::<Self>(1)));
|
||||
self.alter_prop(PropsOp::prepend_classes("dialog"));
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl Component for Dropdown {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes("dropdown"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ impl Component for Field {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
// Asegura `name` e `id`.
|
||||
// Si falta uno se deriva del otro; si faltan ambos se genera un valor único.
|
||||
let name = self
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ impl Component for Checkbox {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
// Asegura `name` e `id`.
|
||||
// Si falta uno se deriva del otro; si faltan ambos se genera un valor único.
|
||||
let name = self
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ impl Component for Form {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes("form"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ impl Component for Field {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
if let Some(container_id) = self
|
||||
.id()
|
||||
.or_else(|| self.name().as_deref().map(|n| util::join!("edit-", n)))
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ impl Component for Number {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
if let Some(container_id) = self
|
||||
.id()
|
||||
.or_else(|| self.name().as_deref().map(|n| util::join!("edit-", n)))
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ impl Component for Field {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
// Asegura `name` e `id`.
|
||||
// Si falta uno se deriva del otro; si faltan ambos se genera un valor único.
|
||||
let name = self
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ impl Component for Range {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
if let Some(container_id) = self
|
||||
.id()
|
||||
.or_else(|| self.name().as_deref().map(|n| util::join!("edit-", n)))
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ impl Component for Field {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
if let Some(container_id) = self
|
||||
.id()
|
||||
.or_else(|| self.name().as_deref().map(|n| util::join!("edit-", n)))
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl Component for Textarea {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
if let Some(container_id) = self
|
||||
.id()
|
||||
.or_else(|| self.name().as_deref().map(|n| util::join!("edit-", n)))
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ impl Component for Image {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes(match self.source() {
|
||||
image::Source::Logo(_) => "image image-fluid",
|
||||
image::Source::Responsive(_) => "image image-fluid",
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl Component for Messages {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes("messages"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ impl Component for Nav {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes(match self.nav_layout() {
|
||||
nav::Layout::Default => "nav",
|
||||
nav::Layout::Start => "nav nav-start",
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ impl Component for Item {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes(self.item_kind().as_str()));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl Component for Navbar {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
// Asegura que la barra de navegación tiene un identificador único: lo necesita el botón de
|
||||
// despliegue para referenciar el contenido colapsable con `aria-controls`.
|
||||
self.alter_prop(PropsOp::ensure_id(cx.build_id::<Self>(1)));
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl Component for Item {
|
|||
}
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
if let Self::Nav(nav) = self
|
||||
&& let Some(nav) = nav.get_mut()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ impl Component for Pager {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, cx: &Context) {
|
||||
fn setup(&mut self, cx: &mut Context) {
|
||||
// Asegura un `id` propio si no está definido. El formulario de salto a página deriva sus
|
||||
// identificadores de éste para no colisionar si hay varios paginadores en la misma página.
|
||||
let id = cx.required_id::<Self>(self.id(), 1);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ impl Component for Table {
|
|||
self.props.get_id()
|
||||
}
|
||||
|
||||
fn setup(&mut self, _cx: &Context) {
|
||||
fn setup(&mut self, _cx: &mut Context) {
|
||||
self.alter_prop(PropsOp::prepend_classes("table"));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue