♻️ Migra #[builder_fn] a #[builder_impl]
Sustituye las ~400 anotaciones `#[builder_fn]` método a método por un único `#[builder_impl]` por `impl`/`trait`, en 74 ficheros de pagetop y sus extensiones (admin, bootsier, menu, user).
This commit is contained in:
parent
c34dc02357
commit
1be3d88888
74 changed files with 104 additions and 394 deletions
|
|
@ -49,6 +49,7 @@ impl Component for Badge {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Badge {
|
||||
/// Crea un badge predeterminado (`Intent::default()`) con la etiqueta indicada.
|
||||
pub fn labeled(label: Lc) -> Self {
|
||||
|
|
@ -115,28 +116,24 @@ impl Badge {
|
|||
// **< Badge BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta del badge.
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la intención semántica del badge.
|
||||
#[builder_fn]
|
||||
pub fn with_intent(mut self, intent: Intent) -> Self {
|
||||
self.intent = intent;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -50,25 +50,23 @@ impl Component for Block {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Block {
|
||||
// **< Block BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el título del bloque.
|
||||
#[builder_fn]
|
||||
pub fn with_title(mut self, title: Lc) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
|
|
@ -76,7 +74,6 @@ impl Block {
|
|||
|
||||
/// Añade un nuevo componente al bloque o modifica la lista de componentes (`children`) con una
|
||||
/// operación [`ChildOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -77,39 +77,35 @@ impl Component for Brand {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Brand {
|
||||
// **< Brand BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Asigna o quita la imagen de marca. Si se pasa `None`, no se mostrará.
|
||||
#[builder_fn]
|
||||
pub fn with_image(mut self, image: impl Into<Option<Image>>) -> Self {
|
||||
self.image.alter_component(image);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el título de la identidad de marca.
|
||||
#[builder_fn]
|
||||
pub fn with_title(mut self, title: Lc) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
}
|
||||
|
||||
/// Define la ruta de destino. Si es `None`, la marca no será un enlace.
|
||||
#[builder_fn]
|
||||
pub fn with_route(mut self, route: impl Into<Option<Route>>) -> Self {
|
||||
self.route = route.into();
|
||||
self
|
||||
|
|
|
|||
|
|
@ -67,25 +67,23 @@ impl Component for Breadcrumb {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Breadcrumb {
|
||||
// **< Breadcrumb BUILDER >*********************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Añade un nuevo elemento al final del breadcrumb.
|
||||
#[builder_fn]
|
||||
pub fn with_crumb(mut self, crumb: breadcrumb::Crumb) -> Self {
|
||||
self.crumbs.push(crumb);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ pub struct Crumb {
|
|||
is_current: bool,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Crumb {
|
||||
/// Crea un elemento enlazado a la ruta indicada.
|
||||
pub fn new(label: Lc, route: impl Into<Route>) -> Self {
|
||||
|
|
@ -66,14 +67,12 @@ impl Crumb {
|
|||
// **< Crumb BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del elemento.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS o atributos HTML del elemento.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ impl Component for Button {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Button {
|
||||
/// Crea un botón de **envío** (`type="submit"`).
|
||||
///
|
||||
|
|
@ -186,35 +187,30 @@ impl Button {
|
|||
// **< Button BUILDER >*************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el comportamiento del botón al activarse.
|
||||
#[builder_fn]
|
||||
pub fn with_kind(mut self, kind: button::Kind) -> Self {
|
||||
self.kind = kind;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el tamaño visual del botón (usa [`button::Size::None`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_size(mut self, size: button::Size) -> Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el estilo visual del botón (usa [`button::Style::None`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_style(mut self, style: button::Style) -> Self {
|
||||
self.style = style;
|
||||
self
|
||||
|
|
@ -224,7 +220,6 @@ impl Button {
|
|||
///
|
||||
/// Cuando el formulario tiene varios botones de envío, el navegador incluye en el envío el par
|
||||
/// `name=value` sólo del botón que activó el formulario. Permite identificar cuál fue pulsado.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
|
|
@ -234,21 +229,18 @@ impl Button {
|
|||
///
|
||||
/// Es el dato que el navegador transmite al servidor junto con el `name` cuando este botón
|
||||
/// activa el envío. Útil para distinguir entre varios botones de envío en un mismo formulario.
|
||||
#[builder_fn]
|
||||
pub fn with_value(mut self, value: impl AsRef<str>) -> Self {
|
||||
self.value.alter_str(value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del botón (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto emergente del botón (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_title(mut self, title: Lc) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
|
|
@ -257,21 +249,18 @@ impl Button {
|
|||
/// Establece la ruta de destino y convierte el botón en enlace de navegación (`<a href=...>`).
|
||||
/// Puedes usar un [`Route`] vacío (por defecto) para que vuelva a renderizarse como `<button>`.
|
||||
/// Ver [`Button::anchor()`] para el constructor equivalente.
|
||||
#[builder_fn]
|
||||
pub fn with_href(mut self, route: impl Into<Route>) -> Self {
|
||||
self.href = route.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el botón recibe el foco automáticamente al cargar la página.
|
||||
#[builder_fn]
|
||||
pub fn with_autofocus(mut self, autofocus: bool) -> Self {
|
||||
self.autofocus = autofocus;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el botón está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -47,25 +47,23 @@ impl Component for ButtonSet {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl ButtonSet {
|
||||
// **< ButtonSet BUILDER >*************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Añade un botón al conjunto, o modifica su lista de botones con una operación [`TypedOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_button(mut self, op: impl Into<TypedOp<Button>>) -> Self {
|
||||
self.buttons.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ impl Component for Container {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Container {
|
||||
/// Crea un contenedor de tipo `Main` (`<main>`).
|
||||
pub fn main() -> Self {
|
||||
|
|
@ -122,14 +123,12 @@ impl Container {
|
|||
// **< Container BUILDER >**********************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -137,7 +136,6 @@ impl Container {
|
|||
|
||||
/// Añade un nuevo componente al contenedor o modifica la lista de componentes (`children`) con
|
||||
/// una operación [`ChildOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -103,25 +103,23 @@ impl Component for Dialog {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Dialog {
|
||||
// **< Dialog BUILDER >*************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el título del diálogo.
|
||||
#[builder_fn]
|
||||
pub fn with_title(mut self, title: Lc) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
|
|
@ -129,7 +127,6 @@ impl Dialog {
|
|||
|
||||
/// Añade un nuevo componente al cuerpo del diálogo o modifica la lista de componentes
|
||||
/// (`children`) del cuerpo con una operación [`ChildOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.body.alter_child(op.into());
|
||||
self
|
||||
|
|
@ -141,7 +138,6 @@ impl Dialog {
|
|||
/// El pie ya se maqueta en fila y alineado a la derecha por su propia clase CSS
|
||||
/// (`dialog-footer`); por lo que no requiere un [`ButtonSet`](super::ButtonSet) para alinear
|
||||
/// los botones, aunque puede usarse si se desea.
|
||||
#[builder_fn]
|
||||
pub fn with_footer(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.footer.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -130,46 +130,41 @@ impl Component for Dropdown {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Dropdown {
|
||||
// **< Dropdown BUILDER >***********************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el título del menú desplegable.
|
||||
#[builder_fn]
|
||||
pub fn with_title(mut self, title: Lc) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
}
|
||||
|
||||
/// Activa/desactiva el modo *split* (botón de acción más *toggle*).
|
||||
#[builder_fn]
|
||||
pub fn with_button_split(mut self, split: bool) -> Self {
|
||||
self.button_split = split;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el tamaño visual del botón (usa [`button::Size::None`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_button_size(mut self, size: button::Size) -> Self {
|
||||
self.button_size = size;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el estilo visual del botón (usa [`button::Style::None`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_button_style(mut self, style: button::Style) -> Self {
|
||||
self.button_style = style;
|
||||
self
|
||||
|
|
@ -191,7 +186,6 @@ impl Dropdown {
|
|||
/// dropdown::Item::link(Lc::n("Home"), "/"),
|
||||
/// ]));
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_item(mut self, op: impl Into<TypedOp<dropdown::Item>>) -> Self {
|
||||
self.items.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ impl Component for Item {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Item {
|
||||
/// Crea un elemento de tipo texto, mostrado sin interacción.
|
||||
pub fn label(label: Lc) -> Self {
|
||||
|
|
@ -257,14 +258,12 @@ impl Item {
|
|||
// **< Item BUILDER >***************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ pub struct Item {
|
|||
disabled: bool,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Item {
|
||||
/// Crea una nueva casilla con el valor y la etiqueta indicados.
|
||||
pub fn new(value: impl AsRef<str>, label: Lc) -> Self {
|
||||
|
|
@ -42,14 +43,12 @@ impl Item {
|
|||
// **< Item BUILDER >***************************************************************************
|
||||
|
||||
/// Establece si la casilla debe aparecer marcada por defecto.
|
||||
#[builder_fn]
|
||||
pub fn with_checked(mut self, checked: bool) -> Self {
|
||||
self.checked = checked;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si la casilla está deshabilitada.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -179,18 +178,17 @@ impl Component for Field {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Field {
|
||||
// **< Field BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -201,28 +199,24 @@ impl Field {
|
|||
/// Todas las casillas [`form::check::Item`](Item) del grupo llevarán este mismo `name`. Si se
|
||||
/// omite, se asigna un nombre generado automáticamente. Para deserializar los campos en el
|
||||
/// servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del grupo (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto de ayuda del grupo (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_help_text(mut self, help_text: Lc) -> Self {
|
||||
self.help_text = help_text;
|
||||
self
|
||||
}
|
||||
|
||||
/// Añade una casilla al grupo. Las casillas se muestran en el orden en que se añaden.
|
||||
#[builder_fn]
|
||||
pub fn with_item(mut self, item: Item) -> Self {
|
||||
self.items.push(item);
|
||||
self
|
||||
|
|
@ -231,7 +225,6 @@ impl Field {
|
|||
/// Establece si todo el grupo está deshabilitado.
|
||||
///
|
||||
/// Cuando está activo, se combina con el estado `disabled` de cada [`Item`].
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -240,7 +233,6 @@ impl Field {
|
|||
/// Establece si las casillas se muestran en línea horizontalmente.
|
||||
///
|
||||
/// Al activar este modo, se añade la clase `form-check-inline` al contenedor de cada casilla.
|
||||
#[builder_fn]
|
||||
pub fn with_inline(mut self, inline: bool) -> Self {
|
||||
self.inline = inline;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ impl Component for Checkbox {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Checkbox {
|
||||
/// Crea una casilla de verificación estándar.
|
||||
pub fn check() -> Self {
|
||||
|
|
@ -152,21 +153,18 @@ impl Checkbox {
|
|||
// **< Checkbox BUILDER >***********************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la variante visual del control.
|
||||
#[builder_fn]
|
||||
pub fn with_kind(mut self, kind: form::CheckboxKind) -> Self {
|
||||
self.checkbox_kind = kind;
|
||||
self
|
||||
|
|
@ -176,42 +174,36 @@ impl Checkbox {
|
|||
///
|
||||
/// Si se omite, se asigna un identificador generado automáticamente. Para deserializar el campo
|
||||
/// en el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del control (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el control debe aparecer marcado/activo por defecto.
|
||||
#[builder_fn]
|
||||
pub fn with_checked(mut self, checked: bool) -> Self {
|
||||
self.checked = checked;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el control recibe el foco automáticamente al cargar la página.
|
||||
#[builder_fn]
|
||||
pub fn with_autofocus(mut self, autofocus: bool) -> Self {
|
||||
self.autofocus = autofocus;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es obligatorio.
|
||||
#[builder_fn]
|
||||
pub fn with_required(mut self, required: bool) -> Self {
|
||||
self.required = required;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el control está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -221,7 +213,6 @@ impl Checkbox {
|
|||
///
|
||||
/// Al activar este modo, se añade la clase `form-check-inline` al contenedor, lo que permite
|
||||
/// alinear varios controles horizontalmente.
|
||||
#[builder_fn]
|
||||
pub fn with_inline(mut self, inline: bool) -> Self {
|
||||
self.inline = inline;
|
||||
self
|
||||
|
|
@ -230,7 +221,6 @@ impl Checkbox {
|
|||
/// Establece si el control y su etiqueta se justifican a la derecha del contenedor.
|
||||
///
|
||||
/// Al activar este modo, se añade la clase `form-check-reverse` al contenedor.
|
||||
#[builder_fn]
|
||||
pub fn with_reverse(mut self, reverse: bool) -> Self {
|
||||
self.reverse = reverse;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -89,18 +89,17 @@ impl Component for Form {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Form {
|
||||
// **< Form BUILDER >***************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -110,7 +109,6 @@ impl Form {
|
|||
///
|
||||
/// Acepta un literal, un `String`, o una [`Route`] explícita construida con [`Route::with()`]
|
||||
/// para rutas que dependan del contexto de renderizado.
|
||||
#[builder_fn]
|
||||
pub fn with_action(mut self, action: impl Into<Route>) -> Self {
|
||||
self.action = action.into();
|
||||
self
|
||||
|
|
@ -120,7 +118,6 @@ impl Form {
|
|||
///
|
||||
/// - `GET`: el atributo `method` se omite.
|
||||
/// - `POST`: se establece `method="post"`.
|
||||
#[builder_fn]
|
||||
pub fn with_method(mut self, method: form::Method) -> Self {
|
||||
self.method = method;
|
||||
self
|
||||
|
|
@ -129,7 +126,6 @@ impl Form {
|
|||
/// Establece el juego de caracteres aceptado por el formulario.
|
||||
///
|
||||
/// Por defecto se utiliza `"UTF-8"`.
|
||||
#[builder_fn]
|
||||
pub fn with_charset(mut self, charset: impl AsRef<str>) -> Self {
|
||||
self.charset.alter_str(charset);
|
||||
self
|
||||
|
|
@ -137,7 +133,6 @@ impl Form {
|
|||
|
||||
/// Añade un nuevo componente al formulario o modifica la lista de componentes (`children`) con
|
||||
/// una operación [`ChildOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -67,39 +67,35 @@ impl Component for Fieldset {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Fieldset {
|
||||
// **< Fieldset BUILDER >***********************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la leyenda del `fieldset` (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_legend(mut self, legend: Lc) -> Self {
|
||||
self.legend = legend;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la descripción del `fieldset` (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_description(mut self, description: Lc) -> Self {
|
||||
self.description = description;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el `fieldset` está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -107,7 +103,6 @@ impl Fieldset {
|
|||
|
||||
/// Añade un nuevo componente al `fieldset`, o aplica una operación [`ChildOp`] sobre la lista
|
||||
/// de componentes (`children`).
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ impl Component for Hidden {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Hidden {
|
||||
/// Crea un campo oculto con nombre y valor (atributos `name` y `value`) ya establecidos.
|
||||
///
|
||||
|
|
@ -68,14 +69,12 @@ impl Hidden {
|
|||
///
|
||||
/// Sin él, el valor del campo no se transmite al servidor al enviar el formulario. Para
|
||||
/// deserializar el campo en el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el valor del campo oculto (atributo `value`).
|
||||
#[builder_fn]
|
||||
pub fn with_value(mut self, value: impl AsRef<str>) -> Self {
|
||||
self.value.alter_str(value);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -275,6 +275,7 @@ impl Component for Field {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Field {
|
||||
/// Crea un campo de **texto genérico** (`type="text"`).
|
||||
///
|
||||
|
|
@ -391,14 +392,12 @@ impl Field {
|
|||
// **< Field BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -408,42 +407,36 @@ impl Field {
|
|||
///
|
||||
/// Sin él, el valor del campo no se transmite al servidor al enviar el formulario. Para
|
||||
/// deserializar el campo en el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el valor inicial del campo.
|
||||
#[builder_fn]
|
||||
pub fn with_value(mut self, value: impl AsRef<str>) -> Self {
|
||||
self.value.alter_str(value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del campo (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto de ayuda del campo (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_help_text(mut self, help_text: Lc) -> Self {
|
||||
self.help_text = help_text;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la longitud mínima permitida en caracteres (`None` para no imponer mínimo).
|
||||
#[builder_fn]
|
||||
pub fn with_minlength(mut self, minlength: impl Into<Option<u16>>) -> Self {
|
||||
self.minlength = minlength.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la longitud máxima permitida en caracteres (`None` para no imponer límite).
|
||||
#[builder_fn]
|
||||
pub fn with_maxlength(mut self, maxlength: impl Into<Option<u16>>) -> Self {
|
||||
self.maxlength = maxlength.into();
|
||||
self
|
||||
|
|
@ -453,7 +446,6 @@ impl Field {
|
|||
///
|
||||
/// Este texto aparece en el mismo campo y desaparece en cuanto el usuario empieza a escribir.
|
||||
/// Al ser texto visible para el usuario se acepta [`Lc`] para poder localizarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_placeholder(mut self, placeholder: Lc) -> Self {
|
||||
self.placeholder = placeholder;
|
||||
self
|
||||
|
|
@ -464,7 +456,6 @@ impl Field {
|
|||
/// Usar los métodos de [`form::Autocomplete`] para los valores más habituales (p. ej.
|
||||
/// [`Autocomplete::email()`](form::Autocomplete::email) o
|
||||
/// [`Autocomplete::current_password()`](form::Autocomplete::current_password)).
|
||||
#[builder_fn]
|
||||
pub fn with_autocomplete(
|
||||
mut self,
|
||||
autocomplete: impl Into<Option<form::Autocomplete>>,
|
||||
|
|
@ -474,28 +465,24 @@ impl Field {
|
|||
}
|
||||
|
||||
/// Establece si el campo recibe el foco automáticamente al cargar la página.
|
||||
#[builder_fn]
|
||||
pub fn with_autofocus(mut self, autofocus: bool) -> Self {
|
||||
self.autofocus = autofocus;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es de sólo lectura.
|
||||
#[builder_fn]
|
||||
pub fn with_readonly(mut self, readonly: bool) -> Self {
|
||||
self.readonly = readonly;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es obligatorio.
|
||||
#[builder_fn]
|
||||
pub fn with_required(mut self, required: bool) -> Self {
|
||||
self.required = required;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -505,7 +492,6 @@ impl Field {
|
|||
///
|
||||
/// Útil para mostrar un valor no editable en pantalla que sí se envía al servidor con el
|
||||
/// formulario. El efecto visual depende del tema activo.
|
||||
#[builder_fn]
|
||||
pub fn with_plaintext(mut self, plaintext: bool) -> Self {
|
||||
self.plaintext = plaintext;
|
||||
self
|
||||
|
|
@ -515,7 +501,6 @@ impl Field {
|
|||
///
|
||||
/// A diferencia del atributo `type` ([`form::input::Kind`]), no restringe los valores aceptados
|
||||
/// ni activa la validación del navegador; es sólo una sugerencia de presentación.
|
||||
#[builder_fn]
|
||||
pub fn with_inputmode(mut self, inputmode: impl Into<Option<Mode>>) -> Self {
|
||||
self.inputmode = inputmode.into();
|
||||
self
|
||||
|
|
|
|||
|
|
@ -121,18 +121,17 @@ impl Component for Number {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Number {
|
||||
// **< Number BUILDER >************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -142,42 +141,36 @@ impl Number {
|
|||
///
|
||||
/// Sin él, el valor del campo no se transmite al servidor al enviar el formulario. Para
|
||||
/// deserializar el campo en el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el valor inicial del campo.
|
||||
#[builder_fn]
|
||||
pub fn with_value(mut self, value: impl Into<Option<u64>>) -> Self {
|
||||
self.value = value.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del campo (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto de ayuda del campo (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_help_text(mut self, help_text: Lc) -> Self {
|
||||
self.help_text = help_text;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el valor mínimo permitido (`None` para no imponer mínimo).
|
||||
#[builder_fn]
|
||||
pub fn with_min(mut self, min: impl Into<Option<u64>>) -> Self {
|
||||
self.min = min.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el valor máximo permitido (`None` para no imponer máximo).
|
||||
#[builder_fn]
|
||||
pub fn with_max(mut self, max: impl Into<Option<u64>>) -> Self {
|
||||
self.max = max.into();
|
||||
self
|
||||
|
|
@ -187,35 +180,30 @@ impl Number {
|
|||
///
|
||||
/// Pasar `None` omite el atributo `step` y deja que el navegador aplique su valor por defecto
|
||||
/// (normalmente `1`).
|
||||
#[builder_fn]
|
||||
pub fn with_step(mut self, step: impl Into<Option<u64>>) -> Self {
|
||||
self.step = step.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo recibe el foco automáticamente al cargar la página.
|
||||
#[builder_fn]
|
||||
pub fn with_autofocus(mut self, autofocus: bool) -> Self {
|
||||
self.autofocus = autofocus;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es de sólo lectura.
|
||||
#[builder_fn]
|
||||
pub fn with_readonly(mut self, readonly: bool) -> Self {
|
||||
self.readonly = readonly;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es obligatorio.
|
||||
#[builder_fn]
|
||||
pub fn with_required(mut self, required: bool) -> Self {
|
||||
self.required = required;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ pub struct Item {
|
|||
disabled: bool,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Item {
|
||||
/// Crea una nueva opción con el valor y la etiqueta indicados.
|
||||
pub fn new(value: impl AsRef<str>, label: Lc) -> Self {
|
||||
|
|
@ -46,14 +47,12 @@ impl Item {
|
|||
///
|
||||
/// Si varias opciones del grupo tienen `checked` activo, sólo la primera se renderizará como
|
||||
/// seleccionada; las demás se ignorarán.
|
||||
#[builder_fn]
|
||||
pub fn with_checked(mut self, checked: bool) -> Self {
|
||||
self.checked = checked;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si la opción está inicialmente deshabilitada.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -196,18 +195,17 @@ impl Component for Field {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Field {
|
||||
// **< Field BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -221,28 +219,24 @@ impl Field {
|
|||
///
|
||||
/// Si se omite, se asigna un nombre generado automáticamente. Para deserializar los campos en
|
||||
/// el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del grupo (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto de ayuda del grupo (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_help_text(mut self, help_text: Lc) -> Self {
|
||||
self.help_text = help_text;
|
||||
self
|
||||
}
|
||||
|
||||
/// Añade una opción al grupo. Las opciones se muestran en el orden en que se añaden.
|
||||
#[builder_fn]
|
||||
pub fn with_item(mut self, item: Item) -> Self {
|
||||
self.items.push(item);
|
||||
self
|
||||
|
|
@ -252,7 +246,6 @@ impl Field {
|
|||
///
|
||||
/// El atributo `required` se propaga a todos los botones del grupo para cumplir con la
|
||||
/// especificación HTML.
|
||||
#[builder_fn]
|
||||
pub fn with_required(mut self, required: bool) -> Self {
|
||||
self.required = required;
|
||||
self
|
||||
|
|
@ -261,7 +254,6 @@ impl Field {
|
|||
/// Establece si todo el grupo está deshabilitado.
|
||||
///
|
||||
/// Cuando está activo, se combina con el estado `disabled` de cada [`Item`].
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -270,7 +262,6 @@ impl Field {
|
|||
/// Establece si los botones se muestran en línea horizontalmente.
|
||||
///
|
||||
/// Al activar este modo, se añade la clase `form-check-inline` al contenedor de cada opción.
|
||||
#[builder_fn]
|
||||
pub fn with_inline(mut self, inline: bool) -> Self {
|
||||
self.inline = inline;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -106,18 +106,17 @@ impl Component for Range {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Range {
|
||||
// **< Range BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -127,7 +126,6 @@ impl Range {
|
|||
///
|
||||
/// Sin él, el valor del campo no se transmite al servidor al enviar el formulario. Para
|
||||
/// deserializar el campo en el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
|
|
@ -137,21 +135,18 @@ impl Range {
|
|||
///
|
||||
/// Pasar `None` omite el atributo `value` y deja que el navegador aplique su valor por defecto
|
||||
/// (normalmente el punto medio del rango).
|
||||
#[builder_fn]
|
||||
pub fn with_value(mut self, value: impl Into<Option<f64>>) -> Self {
|
||||
self.value = value.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del campo (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto de ayuda del campo (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_help_text(mut self, help_text: Lc) -> Self {
|
||||
self.help_text = help_text;
|
||||
self
|
||||
|
|
@ -160,7 +155,6 @@ impl Range {
|
|||
/// Establece el valor mínimo del rango.
|
||||
///
|
||||
/// Pasar `None` omite el atributo `min` y deja que el navegador aplique su valor por defecto.
|
||||
#[builder_fn]
|
||||
pub fn with_min(mut self, min: impl Into<Option<f64>>) -> Self {
|
||||
self.min = min.into();
|
||||
self
|
||||
|
|
@ -169,7 +163,6 @@ impl Range {
|
|||
/// Establece el valor máximo del rango.
|
||||
///
|
||||
/// Pasar `None` omite el atributo `max` y deja que el navegador aplique su valor por defecto.
|
||||
#[builder_fn]
|
||||
pub fn with_max(mut self, max: impl Into<Option<f64>>) -> Self {
|
||||
self.max = max.into();
|
||||
self
|
||||
|
|
@ -179,21 +172,18 @@ impl Range {
|
|||
///
|
||||
/// Pasar `None` omite el atributo `step` y deja que el navegador aplique su valor por defecto
|
||||
/// (normalmente `1`).
|
||||
#[builder_fn]
|
||||
pub fn with_step(mut self, step: impl Into<Option<f64>>) -> Self {
|
||||
self.step = step.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el control recibe el foco automáticamente al cargar la página.
|
||||
#[builder_fn]
|
||||
pub fn with_autofocus(mut self, autofocus: bool) -> Self {
|
||||
self.autofocus = autofocus;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el control está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ pub struct Item {
|
|||
disabled: bool,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Item {
|
||||
/// Crea un nuevo elemento con el valor y la etiqueta indicados.
|
||||
pub fn new(value: impl AsRef<str>, label: Lc) -> Self {
|
||||
|
|
@ -50,14 +51,12 @@ impl Item {
|
|||
/// En una lista de selección única, el navegador aplica la selección al último elemento marcado
|
||||
/// si hay más de uno; mientras que en una lista múltiple se respetan todos los elementos
|
||||
/// marcados.
|
||||
#[builder_fn]
|
||||
pub fn with_selected(mut self, selected: bool) -> Self {
|
||||
self.selected = selected;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el elemento está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -90,6 +89,7 @@ pub struct Group {
|
|||
disabled: bool,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Group {
|
||||
/// Crea un nuevo grupo con la etiqueta indicada.
|
||||
pub fn new(label: Lc) -> Self {
|
||||
|
|
@ -102,14 +102,12 @@ impl Group {
|
|||
// **< Group BUILDER >**************************************************************************
|
||||
|
||||
/// Añade un elemento al grupo. Los elementos se muestran en el orden en que se añaden.
|
||||
#[builder_fn]
|
||||
pub fn with_item(mut self, item: Item) -> Self {
|
||||
self.items.push(item);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el grupo de elementos está deshabilitado en bloque.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
@ -307,18 +305,17 @@ impl Component for Field {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Field {
|
||||
// **< Field BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -328,21 +325,18 @@ impl Field {
|
|||
///
|
||||
/// Sin él, el valor seleccionado no se transmite al servidor al enviar el formulario. Para
|
||||
/// deserializar el campo en el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del campo (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto de ayuda del campo (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_help_text(mut self, help_text: Lc) -> Self {
|
||||
self.help_text = help_text;
|
||||
self
|
||||
|
|
@ -351,7 +345,6 @@ impl Field {
|
|||
/// Añade un elemento individual a la lista de selección.
|
||||
///
|
||||
/// Los elementos y grupos se muestran en el orden en que se añaden.
|
||||
#[builder_fn]
|
||||
pub fn with_item(mut self, item: Item) -> Self {
|
||||
self.entries.push(Entry::Item(item));
|
||||
self
|
||||
|
|
@ -360,7 +353,6 @@ impl Field {
|
|||
/// Añade un grupo de elementos a la lista de selección.
|
||||
///
|
||||
/// Los elementos y grupos se muestran en el orden en que se añaden.
|
||||
#[builder_fn]
|
||||
pub fn with_group(mut self, group: Group) -> Self {
|
||||
self.entries.push(Entry::Group(group));
|
||||
self
|
||||
|
|
@ -375,7 +367,6 @@ impl Field {
|
|||
/// Para un número reducido de elementos con etiquetas descriptivas considera usar
|
||||
/// [`form::check::Field`] en su lugar, ofrece una presentación más clara y es más accesible en
|
||||
/// pantallas pequeñas.
|
||||
#[builder_fn]
|
||||
pub fn with_multiple(mut self, multiple: bool) -> Self {
|
||||
self.multiple = multiple;
|
||||
self
|
||||
|
|
@ -389,7 +380,6 @@ impl Field {
|
|||
///
|
||||
/// Es especialmente útil con selección múltiple para controlar el número de filas visibles sin
|
||||
/// necesidad de recurrir al desplazamiento.
|
||||
#[builder_fn]
|
||||
pub fn with_rows(mut self, rows: impl Into<Option<u16>>) -> Self {
|
||||
self.rows = rows.into();
|
||||
self
|
||||
|
|
@ -404,7 +394,6 @@ impl Field {
|
|||
///
|
||||
/// Usa los métodos de [`form::Autocomplete`] para los valores más habituales. Pasa `None` para
|
||||
/// omitir el atributo.
|
||||
#[builder_fn]
|
||||
pub fn with_autocomplete(
|
||||
mut self,
|
||||
autocomplete: impl Into<Option<form::Autocomplete>>,
|
||||
|
|
@ -414,21 +403,18 @@ impl Field {
|
|||
}
|
||||
|
||||
/// Establece si el campo recibe el foco automáticamente al cargar la página.
|
||||
#[builder_fn]
|
||||
pub fn with_autofocus(mut self, autofocus: bool) -> Self {
|
||||
self.autofocus = autofocus;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es obligatorio.
|
||||
#[builder_fn]
|
||||
pub fn with_required(mut self, required: bool) -> Self {
|
||||
self.required = required;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -135,18 +135,17 @@ impl Component for Textarea {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Textarea {
|
||||
// **< Textarea BUILDER >***********************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -156,28 +155,24 @@ impl Textarea {
|
|||
///
|
||||
/// Sin él, el valor del campo no se transmite al servidor al enviar el formulario. Para
|
||||
/// deserializar el campo en el servidor es recomendable establecer un `name` explícito.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.name.alter_name(name);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el valor inicial del área de texto.
|
||||
#[builder_fn]
|
||||
pub fn with_value(mut self, value: impl AsRef<str>) -> Self {
|
||||
self.value.alter_str(value);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la etiqueta visible del campo (usa [`Lc::none()`] para quitarla).
|
||||
#[builder_fn]
|
||||
pub fn with_label(mut self, label: Lc) -> Self {
|
||||
self.label = label;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el texto de ayuda del campo (usa [`Lc::none()`] para quitarlo).
|
||||
#[builder_fn]
|
||||
pub fn with_help_text(mut self, help_text: Lc) -> Self {
|
||||
self.help_text = help_text;
|
||||
self
|
||||
|
|
@ -187,21 +182,18 @@ impl Textarea {
|
|||
///
|
||||
/// Sin valor o pasando `None`, el área muestra su altura predeterminada, dos filas según el
|
||||
/// estándar.
|
||||
#[builder_fn]
|
||||
pub fn with_rows(mut self, rows: impl Into<Option<u16>>) -> Self {
|
||||
self.rows = rows.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la longitud mínima permitida en caracteres.
|
||||
#[builder_fn]
|
||||
pub fn with_minlength(mut self, minlength: impl Into<Option<u16>>) -> Self {
|
||||
self.minlength = minlength.into();
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la longitud máxima permitida en caracteres.
|
||||
#[builder_fn]
|
||||
pub fn with_maxlength(mut self, maxlength: impl Into<Option<u16>>) -> Self {
|
||||
self.maxlength = maxlength.into();
|
||||
self
|
||||
|
|
@ -211,7 +203,6 @@ impl Textarea {
|
|||
///
|
||||
/// Este texto aparece en el área de texto y desaparece en cuanto el usuario empieza a escribir.
|
||||
/// Al ser texto visible para el usuario se acepta [`Lc`] para poder localizarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_placeholder(mut self, placeholder: Lc) -> Self {
|
||||
self.placeholder = placeholder;
|
||||
self
|
||||
|
|
@ -224,7 +215,6 @@ impl Textarea {
|
|||
///
|
||||
/// Usa los métodos de [`form::Autocomplete`] para los valores más habituales. Pasa `None` para
|
||||
/// omitir el atributo.
|
||||
#[builder_fn]
|
||||
pub fn with_autocomplete(
|
||||
mut self,
|
||||
autocomplete: impl Into<Option<form::Autocomplete>>,
|
||||
|
|
@ -234,28 +224,24 @@ impl Textarea {
|
|||
}
|
||||
|
||||
/// Establece si el campo recibe el foco automáticamente al cargar la página.
|
||||
#[builder_fn]
|
||||
pub fn with_autofocus(mut self, autofocus: bool) -> Self {
|
||||
self.autofocus = autofocus;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es de sólo lectura.
|
||||
#[builder_fn]
|
||||
pub fn with_readonly(mut self, readonly: bool) -> Self {
|
||||
self.readonly = readonly;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo es obligatorio.
|
||||
#[builder_fn]
|
||||
pub fn with_required(mut self, required: bool) -> Self {
|
||||
self.required = required;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece si el campo está deshabilitado.
|
||||
#[builder_fn]
|
||||
pub fn with_disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ impl Component for Html {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Html {
|
||||
// **< Html BUILDER >***************************************************************************
|
||||
|
||||
|
|
@ -79,7 +80,6 @@ impl Html {
|
|||
/// Permite a otras extensiones modificar la función de renderizado que se ejecutará cuando
|
||||
/// [`Self::prepare()`] invoque esta instancia. La nueva función también recibe una referencia
|
||||
/// mutable al [`Context`].
|
||||
#[builder_fn]
|
||||
pub fn with_fn<F>(mut self, f: F) -> Self
|
||||
where
|
||||
F: Fn(&mut Context) -> Markup + Send + Sync + 'static,
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ impl Component for Image {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Image {
|
||||
/// Crea rápidamente una imagen especificando su origen.
|
||||
pub fn with(source: image::Source) -> Self {
|
||||
|
|
@ -105,28 +106,24 @@ impl Image {
|
|||
// **< Image BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Define las dimensiones de la imagen (auto, ancho/alto, ambos).
|
||||
#[builder_fn]
|
||||
pub fn with_size(mut self, size: image::Size) -> Self {
|
||||
self.size = size;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el origen de la imagen, influyendo en su disposición en el contenido.
|
||||
#[builder_fn]
|
||||
pub fn with_source(mut self, source: image::Source) -> Self {
|
||||
self.source = source;
|
||||
self
|
||||
|
|
@ -136,7 +133,6 @@ impl Image {
|
|||
///
|
||||
/// Se recomienda siempre aportar un texto alternativo salvo que la imagen sea puramente
|
||||
/// decorativa.
|
||||
#[builder_fn]
|
||||
pub fn with_alternative(mut self, alt: Lc) -> Self {
|
||||
self.alternative = alt;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ impl Component for Intro {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Intro {
|
||||
// **< Intro BUILDER >**************************************************************************
|
||||
|
||||
|
|
@ -227,7 +228,6 @@ impl Intro {
|
|||
/// # use pagetop::prelude::*;
|
||||
/// let intro = Intro::default().with_title(Lc::n("Intro title"));
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_title(mut self, title: Lc) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
|
|
@ -241,7 +241,6 @@ impl Intro {
|
|||
/// # use pagetop::prelude::*;
|
||||
/// let intro = Intro::default().with_slogan(Lc::n("A short slogan"));
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_slogan(mut self, slogan: Lc) -> Self {
|
||||
self.slogan = slogan;
|
||||
self
|
||||
|
|
@ -262,7 +261,6 @@ impl Intro {
|
|||
/// // Descarta el botón de la intro.
|
||||
/// let intro_no_button = Intro::default().with_button(None);
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_button(mut self, button: impl Into<Option<(Lc, Route)>>) -> Self {
|
||||
self.button = button.into();
|
||||
self
|
||||
|
|
@ -280,7 +278,6 @@ impl Intro {
|
|||
/// # use pagetop::prelude::*;
|
||||
/// let intro = Intro::default().with_opening(IntroOpening::Custom);
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_opening(mut self, opening: IntroOpening) -> Self {
|
||||
self.opening = opening;
|
||||
self
|
||||
|
|
@ -290,7 +287,6 @@ impl Intro {
|
|||
/// operación [`ChildOp`].
|
||||
///
|
||||
/// Si se añade un bloque ([`Block`]) se aplicarán estilos específicos para destacarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -69,18 +69,17 @@ impl Component for Messages {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Messages {
|
||||
// **< Messages BUILDER >***********************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -69,25 +69,23 @@ impl Component for Nav {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Nav {
|
||||
// **< Nav BUILDER >****************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Selecciona la distribución y orientación del menú.
|
||||
#[builder_fn]
|
||||
pub fn with_layout(mut self, layout: nav::Layout) -> Self {
|
||||
self.nav_layout = layout;
|
||||
self
|
||||
|
|
@ -105,7 +103,6 @@ impl Nav {
|
|||
/// nav::Item::link_disabled(...),
|
||||
/// ]));
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_item(mut self, op: impl Into<TypedOp<nav::Item>>) -> Self {
|
||||
self.items.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ impl Component for Item {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Item {
|
||||
/// Crea un elemento de tipo texto, mostrado sin interacción.
|
||||
pub fn label(label: Lc) -> Self {
|
||||
|
|
@ -268,14 +269,12 @@ impl Item {
|
|||
// **< Item BUILDER >***************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -283,7 +282,6 @@ impl Item {
|
|||
|
||||
/// Fuerza si un [`ItemKind::Link`] se marca activo, o `None` para volver a la detección
|
||||
/// automática por coincidencia exacta de ruta.
|
||||
#[builder_fn]
|
||||
pub fn with_active(mut self, active: impl Into<Option<bool>>) -> Self {
|
||||
self.active_override = active.into();
|
||||
self
|
||||
|
|
|
|||
|
|
@ -167,6 +167,7 @@ impl Component for Navbar {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Navbar {
|
||||
/// Crea una barra de navegación **simple**, sin marca y sin botón.
|
||||
pub fn simple() -> Self {
|
||||
|
|
@ -198,21 +199,18 @@ impl Navbar {
|
|||
// **< Navbar BUILDER >*************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Define el tipo de disposición que tendrá la barra de navegación.
|
||||
#[builder_fn]
|
||||
pub fn with_layout(mut self, layout: navbar::Layout) -> Self {
|
||||
self.layout = layout;
|
||||
self
|
||||
|
|
@ -230,7 +228,6 @@ impl Navbar {
|
|||
/// navbar::Item::text(...),
|
||||
/// ]));
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_item(mut self, op: impl Into<TypedOp<navbar::Item>>) -> Self {
|
||||
self.items.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -335,25 +335,23 @@ impl Component for Pager {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Pager {
|
||||
// **< Pager BUILDER >*************************************************************************
|
||||
|
||||
/// Establece el identificador único del componente; igual a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS o atributos HTML del componente.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la ruta base sobre la que se construye el enlace de cada página.
|
||||
#[builder_fn]
|
||||
pub fn with_base_path(mut self, base_path: impl AsRef<str>) -> Self {
|
||||
self.base_path.alter_str(base_path);
|
||||
self
|
||||
|
|
@ -362,28 +360,24 @@ impl Pager {
|
|||
/// Añade un parámetro de consulta que debe viajar en el enlace de cada página, además de
|
||||
/// `page` (que `Pager` añade siempre al final). Llamar varias veces añade varios
|
||||
/// parámetros, en el orden en que se declaren.
|
||||
#[builder_fn]
|
||||
pub fn with_extra_query(mut self, key: impl Into<String>, value: impl Into<String>) -> Self {
|
||||
self.extra_query.push((key.into(), value.into()));
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la página actual (siendo 1 la primera página).
|
||||
#[builder_fn]
|
||||
pub fn with_current_page(mut self, current_page: u64) -> Self {
|
||||
self.current_page = current_page;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el número de elementos que se muestran por página.
|
||||
#[builder_fn]
|
||||
pub fn with_items_per_page(mut self, items_per_page: u64) -> Self {
|
||||
self.items_per_page = items_per_page;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece el número total de elementos del listado completo.
|
||||
#[builder_fn]
|
||||
pub fn with_total_items(mut self, total_items: u64) -> Self {
|
||||
self.total_items = total_items;
|
||||
self
|
||||
|
|
@ -394,7 +388,6 @@ impl Pager {
|
|||
///
|
||||
/// El valor `0` desactiva el truncado y muestra siempre todas las páginas. Usar cuando el
|
||||
/// número total de páginas sea pequeño y no haya riesgo de desbordar la interfaz.
|
||||
#[builder_fn]
|
||||
pub fn with_window(mut self, window: u64) -> Self {
|
||||
self.window = window;
|
||||
self
|
||||
|
|
@ -402,7 +395,6 @@ impl Pager {
|
|||
|
||||
/// Establece la alineación horizontal del paginador dentro de su contenedor. Por defecto es
|
||||
/// [`PagerAlign::Center`].
|
||||
#[builder_fn]
|
||||
pub fn with_align(mut self, align: PagerAlign) -> Self {
|
||||
self.align = align;
|
||||
self
|
||||
|
|
@ -415,7 +407,6 @@ impl Pager {
|
|||
///
|
||||
/// [`with_prev_next()`]: Self::with_prev_next
|
||||
/// [`with_jump()`]: Self::with_jump
|
||||
#[builder_fn]
|
||||
pub fn with_summary(mut self, summary: PagerVisibility) -> Self {
|
||||
self.summary = summary;
|
||||
self
|
||||
|
|
@ -425,7 +416,6 @@ impl Pager {
|
|||
/// `PagerVisibility::Auto`: sólo se muestran cuando el número total de páginas supera al
|
||||
/// número de páginas que se muestra en el paginador (con el extremo correspondiente
|
||||
/// desactivado en vez de oculto).
|
||||
#[builder_fn]
|
||||
pub fn with_prev_next(mut self, prev_next: PagerVisibility) -> Self {
|
||||
self.prev_next = prev_next;
|
||||
self
|
||||
|
|
@ -434,7 +424,6 @@ impl Pager {
|
|||
/// Establece la visibilidad del formulario para saltar directamente a una página. Por
|
||||
/// defecto es `PagerVisibility::Auto`: sólo se muestra cuando el número total de páginas
|
||||
/// supera al número de páginas que se muestra en el paginador.
|
||||
#[builder_fn]
|
||||
pub fn with_jump(mut self, jump: PagerVisibility) -> Self {
|
||||
self.jump = jump;
|
||||
self
|
||||
|
|
@ -442,7 +431,6 @@ impl Pager {
|
|||
|
||||
/// Establece la etiqueta de accesibilidad (`aria-label`) del elemento `<nav>`. Por defecto es
|
||||
/// "Page navigation" (clave `pager_aria_label`), igual que hace el paginador de Bootstrap.
|
||||
#[builder_fn]
|
||||
pub fn with_aria_label(mut self, aria_label: Lc) -> Self {
|
||||
self.aria_label = aria_label;
|
||||
self
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ impl Component for PoweredBy {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl PoweredBy {
|
||||
// **< PoweredBy BUILDER >**********************************************************************
|
||||
|
||||
|
|
@ -60,7 +61,6 @@ impl PoweredBy {
|
|||
/// let p1 = PoweredBy::default().with_copyright(Some("2001 © Foo Inc."));
|
||||
/// let p2 = PoweredBy::new().with_copyright(None::<String>);
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
pub fn with_copyright(mut self, copyright: Option<impl Into<String>>) -> Self {
|
||||
self.copyright = copyright.map(Into::into);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ pub struct Cell {
|
|||
children: Children,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Cell {
|
||||
/// Crea una celda a partir del componente o texto ([`Lc`]) indicado.
|
||||
///
|
||||
|
|
@ -44,14 +45,12 @@ impl Cell {
|
|||
// **< Cell BUILDER >***************************************************************************
|
||||
|
||||
/// Establece el identificador único de la celda.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS o atributos HTML de la celda.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -60,7 +59,6 @@ impl Cell {
|
|||
/// Establece el número de columnas que ocupa la celda (atributo `colspan`).
|
||||
///
|
||||
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_colspan(mut self, span: u8) -> Self {
|
||||
self.props.alter_prop(if span == 1 {
|
||||
PropsOp::remove("colspan")
|
||||
|
|
@ -73,7 +71,6 @@ impl Cell {
|
|||
/// Establece el número de filas que ocupa la celda (atributo `rowspan`).
|
||||
///
|
||||
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_rowspan(mut self, span: u8) -> Self {
|
||||
self.props.alter_prop(if span == 1 {
|
||||
PropsOp::remove("rowspan")
|
||||
|
|
@ -85,7 +82,6 @@ impl Cell {
|
|||
|
||||
/// Añade un nuevo componente a la celda o modifica la lista de componentes (`children`) con una
|
||||
/// operación [`ChildOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.children.alter_child(op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ pub struct Column {
|
|||
sort: Option<table::SortLink>,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Column {
|
||||
/// Crea una cabecera con el texto localizado indicado.
|
||||
pub fn new(label: Lc) -> Self {
|
||||
|
|
@ -39,14 +40,12 @@ impl Column {
|
|||
// **< Column BUILDER >*************************************************************************
|
||||
|
||||
/// Establece el identificador único de la celda de cabecera.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS o atributos HTML de la columna.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -55,7 +54,6 @@ impl Column {
|
|||
/// Establece el número de columnas que ocupa la cabecera (atributo `colspan`).
|
||||
///
|
||||
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_colspan(mut self, span: u8) -> Self {
|
||||
self.props.alter_prop(if span == 1 {
|
||||
PropsOp::remove("colspan")
|
||||
|
|
@ -68,7 +66,6 @@ impl Column {
|
|||
/// Establece el número de filas que ocupa la cabecera (atributo `rowspan`).
|
||||
///
|
||||
/// Con `1` (el valor por defecto de HTML) elimina el atributo en vez de fijarlo.
|
||||
#[builder_fn]
|
||||
pub fn with_rowspan(mut self, span: u8) -> Self {
|
||||
self.props.alter_prop(if span == 1 {
|
||||
PropsOp::remove("rowspan")
|
||||
|
|
@ -80,7 +77,6 @@ impl Column {
|
|||
|
||||
/// Convierte la columna en ordenable con el enlace indicado, o la vuelve no ordenable con
|
||||
/// `None`.
|
||||
#[builder_fn]
|
||||
pub fn with_sort(mut self, sort: impl Into<Option<table::SortLink>>) -> Self {
|
||||
self.sort = sort.into();
|
||||
self
|
||||
|
|
|
|||
|
|
@ -118,18 +118,17 @@ impl Component for Table {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Table {
|
||||
// **< Table BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador único de la tabla.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS o atributos HTML de la tabla.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -141,14 +140,12 @@ impl Table {
|
|||
/// `table::Column::new(...)` con el texto indicado), o un [`table::Column`] ya construido (por
|
||||
/// ejemplo para asignarle clases, atributos propios o un enlace de ordenación con
|
||||
/// `with_sort()`).
|
||||
#[builder_fn]
|
||||
pub fn with_column(mut self, column: impl Into<table::Column>) -> Self {
|
||||
self.columns.push(column.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Añade una fila de datos al final de la tabla.
|
||||
#[builder_fn]
|
||||
pub fn with_row(mut self, row: table::Row) -> Self {
|
||||
self.rows.push(row);
|
||||
self
|
||||
|
|
@ -160,7 +157,6 @@ impl Table {
|
|||
///
|
||||
/// Ese mismo resultado se obtiene también si la traducción no resuelve a ningún texto (por
|
||||
/// ejemplo, con `Lc::n("")`).
|
||||
#[builder_fn]
|
||||
pub fn with_empty(mut self, empty: impl Into<Option<Lc>>) -> Self {
|
||||
self.empty = empty.into();
|
||||
self
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ pub struct SortLink {
|
|||
dir: Option<SortDir>,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl SortLink {
|
||||
/// Crea un enlace de ordenación hacia la URL indicada, sin dirección activa.
|
||||
pub fn new(href: impl Into<RoutePath>) -> Self {
|
||||
|
|
@ -51,7 +52,6 @@ impl SortLink {
|
|||
// **< SortLink BUILDER >***********************************************************************
|
||||
|
||||
/// Establece el identificador único del enlace.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
|
|
@ -59,7 +59,6 @@ impl SortLink {
|
|||
|
||||
/// Establece la dirección de orden vigente, o `None` si esta columna no es la que ordena
|
||||
/// actualmente la tabla.
|
||||
#[builder_fn]
|
||||
pub fn with_dir(mut self, dir: impl Into<Option<SortDir>>) -> Self {
|
||||
self.dir = dir.into();
|
||||
self
|
||||
|
|
@ -67,7 +66,6 @@ impl SortLink {
|
|||
|
||||
/// Modifica los atributos HTML del enlace. Es el punto de extensión para añadir atributos de
|
||||
/// interactividad sin que `Table` necesite conocerlos.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ pub struct Row {
|
|||
cells: Vec<table::Cell>,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Row {
|
||||
/// Crea una fila vacía.
|
||||
pub fn new() -> Self {
|
||||
|
|
@ -28,14 +29,12 @@ impl Row {
|
|||
// **< Row BUILDER >****************************************************************************
|
||||
|
||||
/// Establece el identificador único de la fila.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.props.alter_id(id);
|
||||
self
|
||||
}
|
||||
|
||||
/// Modifica identificador, clases CSS o atributos HTML de la fila.
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
self.props.alter_prop(op);
|
||||
self
|
||||
|
|
@ -46,7 +45,6 @@ impl Row {
|
|||
/// Acepta directamente un `&str`, un `String` o un [`Lc`] (equivalen a `table::Cell::new(...)`
|
||||
/// con el contenido indicado), o un [`table::Cell`] ya construido (por ejemplo para asignarle
|
||||
/// clases o atributos propios, o para contener otros componentes).
|
||||
#[builder_fn]
|
||||
pub fn with_cell(mut self, cell: impl Into<table::Cell>) -> Self {
|
||||
self.cells.push(cell.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -55,10 +55,9 @@ pub use route::Route;
|
|||
/// Ok(html! { "Visible component" })
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[builder_impl]
|
||||
/// impl SampleComponent {
|
||||
/// /// Asigna una función que decidirá si el componente se renderiza o no.
|
||||
/// #[builder_fn]
|
||||
/// pub fn with_renderable(mut self, f: Option<FnIsRenderable>) -> Self {
|
||||
/// self.renderable = f;
|
||||
/// self
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::core::component::{Component, Context};
|
||||
use crate::html::{Markup, html};
|
||||
use crate::{AutoDefault, UniqueId, builder_fn};
|
||||
use crate::{AutoDefault, UniqueId, builder_impl};
|
||||
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
|
|
@ -26,6 +26,7 @@ impl fmt::Debug for Child {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Child {
|
||||
/// Crea un nuevo `Child` a partir de un componente.
|
||||
pub fn with(component: impl Component) -> Self {
|
||||
|
|
@ -44,7 +45,6 @@ impl Child {
|
|||
/// Establece un componente nuevo, o lo vacía.
|
||||
///
|
||||
/// Si se proporciona `Some(component)`, se encapsula como [`Child`]; y si es `None`, se limpia.
|
||||
#[builder_fn]
|
||||
pub fn with_component<C: Component>(mut self, component: impl Into<Option<C>>) -> Self {
|
||||
self.0 = component.into().map(|c| Arc::new(c) as Arc<dyn Component>);
|
||||
self
|
||||
|
|
@ -154,6 +154,7 @@ impl<C: Component> fmt::Debug for Embed<C> {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl<C: Component> Embed<C> {
|
||||
/// Crea un nuevo `Embed` a partir de un componente.
|
||||
pub fn with(component: C) -> Self {
|
||||
|
|
@ -165,7 +166,6 @@ impl<C: Component> Embed<C> {
|
|||
/// Establece un componente nuevo, o lo vacía.
|
||||
///
|
||||
/// Si se proporciona `Some(component)`, se encapsula como [`Embed`]; y si es `None`, se limpia.
|
||||
#[builder_fn]
|
||||
pub fn with_component(mut self, component: impl Into<Option<C>>) -> Self {
|
||||
self.0 = component.into().map(Arc::new);
|
||||
self
|
||||
|
|
@ -364,6 +364,7 @@ impl<C: Component> From<TypedOp<C>> for ChildOp {
|
|||
#[derive(AutoDefault, Clone, Debug)]
|
||||
pub struct Children(Vec<Child>);
|
||||
|
||||
#[builder_impl]
|
||||
impl Children {
|
||||
/// Crea una lista vacía.
|
||||
pub fn new() -> Self {
|
||||
|
|
@ -378,7 +379,6 @@ impl Children {
|
|||
// **< Children BUILDER >***********************************************************************
|
||||
|
||||
/// Añade un componente hijo o aplica una operación [`ChildOp`] sobre la lista.
|
||||
#[builder_fn]
|
||||
pub fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
match op.into() {
|
||||
ChildOp::Add(any) => self.add(any),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::html::{Markup, Props, PropsOp, RoutePath, html};
|
|||
use crate::locale::Lc;
|
||||
use crate::locale::{LangId, LanguageIdentifier, RequestLocale};
|
||||
use crate::web::HttpRequest;
|
||||
use crate::{builder_fn, util};
|
||||
use crate::{builder_impl, util};
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use thiserror::Error;
|
||||
|
|
@ -85,11 +85,11 @@ pub enum ContextError {
|
|||
/// .with_param("user_id", 42_i32)
|
||||
/// }
|
||||
/// ```
|
||||
#[builder_impl]
|
||||
pub trait Contextual: LangId {
|
||||
// **< Contextual BUILDER >*********************************************************************
|
||||
|
||||
/// Establece el idioma del documento.
|
||||
#[builder_fn]
|
||||
fn with_langid(self, language: &impl LangId) -> Self;
|
||||
|
||||
/// Almacena la petición HTTP de origen en el contexto.
|
||||
|
|
@ -99,15 +99,12 @@ pub trait Contextual: LangId {
|
|||
/// cualquier idioma forzado antes con [`with_langid()`](Self::with_langid) o el usuario ya
|
||||
/// resuelto. Si necesitas forzar el idioma o el usuario, llama a `with_request()` primero en
|
||||
/// la cadena de construcción, nunca después.
|
||||
#[builder_fn]
|
||||
fn with_request(self, request: Option<HttpRequest>) -> Self;
|
||||
|
||||
/// Especifica la plantilla para renderizar el documento.
|
||||
#[builder_fn]
|
||||
fn with_template(self, template: TemplateRef) -> Self;
|
||||
|
||||
/// Especifica el tema para renderizar el documento.
|
||||
#[builder_fn]
|
||||
fn with_theme(self, theme: ThemeRef) -> Self;
|
||||
|
||||
/// Añade o modifica un parámetro dinámico del contexto.
|
||||
|
|
@ -125,25 +122,20 @@ pub trait Contextual: LangId {
|
|||
/// .with_param("title", "Hello".to_string())
|
||||
/// .with_param("flags", vec!["a", "b"]);
|
||||
/// ```
|
||||
#[builder_fn]
|
||||
fn with_param<T: Send + Sync + 'static>(self, key: &'static str, value: T) -> Self;
|
||||
|
||||
/// Define los recursos del contexto usando [`AssetsOp`].
|
||||
#[builder_fn]
|
||||
fn with_assets(self, op: AssetsOp) -> Self;
|
||||
|
||||
/// Modifica identificador, clases CSS, atributos HTML o valores extra del elemento `<body>`.
|
||||
#[builder_fn]
|
||||
fn with_body_props(self, op: PropsOp) -> Self;
|
||||
|
||||
/// Añade un componente o aplica una operación [`ChildOp`] en la región por defecto del
|
||||
/// documento.
|
||||
#[builder_fn]
|
||||
fn with_child(self, op: impl Into<ChildOp>) -> Self;
|
||||
|
||||
/// Añade un componente o aplica una operación [`ChildOp`] en una región específica del
|
||||
/// documento.
|
||||
#[builder_fn]
|
||||
fn with_child_in(self, region: RegionRef, op: impl Into<ChildOp>) -> Self;
|
||||
|
||||
// **< Contextual GETTERS >*********************************************************************
|
||||
|
|
@ -546,10 +538,10 @@ impl LangId for Context {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Contextual for Context {
|
||||
// **< Contextual BUILDER >*********************************************************************
|
||||
|
||||
#[builder_fn]
|
||||
fn with_request(mut self, request: Option<HttpRequest>) -> Self {
|
||||
self.request = request;
|
||||
// Recalcula el *locale* y el usuario actual según la nueva petición y la política de
|
||||
|
|
@ -559,32 +551,27 @@ impl Contextual for Context {
|
|||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_langid(mut self, language: &impl LangId) -> Self {
|
||||
self.locale.with_langid(language);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_template(mut self, template: TemplateRef) -> Self {
|
||||
self.template = template;
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_theme(mut self, theme: ThemeRef) -> Self {
|
||||
self.theme = theme;
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_param<T: Send + Sync + 'static>(mut self, key: &'static str, value: T) -> Self {
|
||||
let type_name = TypeInfo::FullName.of::<T>();
|
||||
self.params.insert(key, (Box::new(value), type_name));
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_assets(mut self, op: AssetsOp) -> Self {
|
||||
match op {
|
||||
// Favicon.
|
||||
|
|
@ -621,20 +608,17 @@ impl Contextual for Context {
|
|||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_body_props(mut self, op: PropsOp) -> Self {
|
||||
self.body_props.alter_prop(op);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.regions
|
||||
.alter_child_in(&CoreRegions::Content, op.into());
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_child_in(mut self, region: RegionRef, op: impl Into<ChildOp>) -> Self {
|
||||
self.regions.alter_child_in(region, op.into());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::core::component::{Child, ChildOp, Children, Component};
|
||||
use crate::core::theme::{CoreRegions, RegionRef, ThemeRef};
|
||||
use crate::{AutoDefault, UniqueId, builder_fn};
|
||||
use crate::{AutoDefault, UniqueId, builder_impl};
|
||||
|
||||
use parking_lot::RwLock;
|
||||
|
||||
|
|
@ -55,12 +55,12 @@ static COMMON_REGIONS: LazyLock<RwLock<RegionComponents>> =
|
|||
#[derive(AutoDefault)]
|
||||
pub(crate) struct ChildrenInRegions(HashMap<&'static str, Children>);
|
||||
|
||||
#[builder_impl]
|
||||
impl ChildrenInRegions {
|
||||
pub fn with(region: RegionRef, child: Child) -> Self {
|
||||
Self::default().with_child_in(region, child)
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
pub fn with_child_in(mut self, region: RegionRef, op: impl Into<ChildOp>) -> Self {
|
||||
let child = op.into();
|
||||
let region_name = region.name();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{AutoDefault, builder_fn, util};
|
||||
use crate::{AutoDefault, builder_impl, util};
|
||||
|
||||
// **< AttrName >***********************************************************************************
|
||||
|
||||
|
|
@ -24,6 +24,7 @@ use crate::{AutoDefault, builder_fn, util};
|
|||
#[derive(AutoDefault, Clone, Debug)]
|
||||
pub struct AttrName(Option<String>);
|
||||
|
||||
#[builder_impl]
|
||||
impl AttrName {
|
||||
/// Crea un nuevo `AttrName` normalizando el valor.
|
||||
pub fn new(name: impl AsRef<str>) -> Self {
|
||||
|
|
@ -33,7 +34,6 @@ impl AttrName {
|
|||
// **< AttrName BUILDER >***********************************************************************
|
||||
|
||||
/// Establece un nombre nuevo normalizando el valor.
|
||||
#[builder_fn]
|
||||
pub fn with_name(mut self, name: impl AsRef<str>) -> Self {
|
||||
self.0 = util::normalize_token(name);
|
||||
self
|
||||
|
|
@ -79,6 +79,7 @@ impl AttrName {
|
|||
#[derive(AutoDefault, Clone, Debug)]
|
||||
pub struct AttrValue(Option<String>);
|
||||
|
||||
#[builder_impl]
|
||||
impl AttrValue {
|
||||
/// Crea un nuevo `AttrValue` normalizando el valor.
|
||||
pub fn new(value: impl AsRef<str>) -> Self {
|
||||
|
|
@ -88,7 +89,6 @@ impl AttrValue {
|
|||
// **< AttrValue BUILDER >**********************************************************************
|
||||
|
||||
/// Establece una cadena nueva normalizando el valor.
|
||||
#[builder_fn]
|
||||
pub fn with_str(mut self, value: impl AsRef<str>) -> Self {
|
||||
self.0 = util::non_blank(value.as_ref()).map(str::to_string);
|
||||
self
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::core::TypeInfo;
|
||||
use crate::html::maud::{Escaper, RenderAttrs};
|
||||
use crate::{AutoDefault, CowStr, builder_fn, trace, util};
|
||||
use crate::{AutoDefault, CowStr, builder_impl, trace, util};
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
|
|
@ -453,9 +453,9 @@ impl PropsOp {
|
|||
/// }
|
||||
/// }
|
||||
///
|
||||
/// #[builder_impl]
|
||||
/// impl MyButton {
|
||||
/// /// Modifica identificador, clases CSS, atributos HTML o valores extra del componente.
|
||||
/// #[builder_fn]
|
||||
/// pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
/// self.props.alter_prop(op);
|
||||
/// self
|
||||
|
|
@ -471,6 +471,7 @@ pub struct Props {
|
|||
extras: HashMap<&'static str, PropsExtra>,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Props {
|
||||
/// Crea una colección con un primer atributo ya establecido.
|
||||
pub fn new(name: impl Into<CowStr>, value: impl Into<CowStr>) -> Self {
|
||||
|
|
@ -485,7 +486,6 @@ impl Props {
|
|||
// **< Props BUILDER >**************************************************************************
|
||||
|
||||
/// Establece el identificador del componente; equivale a `with_prop(PropsOp::set_id(id))`.
|
||||
#[builder_fn]
|
||||
pub fn with_id(mut self, id: impl Into<CowStr>) -> Self {
|
||||
self.apply_id(id.into().as_ref());
|
||||
self
|
||||
|
|
@ -494,7 +494,6 @@ impl Props {
|
|||
/// Modifica el identificador, las clases, los atributos o los valores extra según la operación
|
||||
/// indicada. El método recomendado para construir cada operación es usar los constructores de
|
||||
/// [`PropsOp`].
|
||||
#[builder_fn]
|
||||
pub fn with_prop(mut self, op: PropsOp) -> Self {
|
||||
match op {
|
||||
PropsOp::SetId(value) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{AutoDefault, CowStr, builder_fn};
|
||||
use crate::{AutoDefault, CowStr, builder_impl};
|
||||
|
||||
use std::fmt::{self, Write as _};
|
||||
|
||||
|
|
@ -53,6 +53,7 @@ pub struct RoutePath {
|
|||
query: indexmap::IndexMap<String, String>,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl RoutePath {
|
||||
/// Crea un `RoutePath` a partir de un *path* inicial.
|
||||
///
|
||||
|
|
@ -72,7 +73,6 @@ impl RoutePath {
|
|||
///
|
||||
/// Un `value` vacío no se distingue de [`with_flag()`](Self::with_flag): ambos se renderizan
|
||||
/// como `?key`, sin `=`.
|
||||
#[builder_fn]
|
||||
pub fn with_param(mut self, key: impl Into<String>, value: impl AsRef<str>) -> Self {
|
||||
self.query
|
||||
.insert(key.into(), Self::encode_query_value(value.as_ref()));
|
||||
|
|
@ -80,7 +80,6 @@ impl RoutePath {
|
|||
}
|
||||
|
||||
/// Añade o sustituye un *flag* sin valor, por ejemplo `?debug`.
|
||||
#[builder_fn]
|
||||
pub fn with_flag(mut self, flag: impl Into<String>) -> Self {
|
||||
self.query.insert(flag.into(), String::new());
|
||||
self
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use crate::html::{DOCTYPE, Markup, html};
|
|||
use crate::html::{Props, PropsOp};
|
||||
use crate::locale::{CharacterDirection, LangId, LanguageIdentifier, Lc};
|
||||
use crate::web::HttpRequest;
|
||||
use crate::{AutoDefault, builder_fn};
|
||||
use crate::{AutoDefault, builder_impl};
|
||||
|
||||
// **< ReservedRegions >****************************************************************************
|
||||
|
||||
|
|
@ -95,6 +95,7 @@ pub struct Page {
|
|||
context : Context,
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Page {
|
||||
/// Crea una nueva instancia de página.
|
||||
///
|
||||
|
|
@ -126,28 +127,24 @@ impl Page {
|
|||
// **< Page BUILDER >***************************************************************************
|
||||
|
||||
/// Establece el título de la página como un valor traducible.
|
||||
#[builder_fn]
|
||||
pub fn with_title(mut self, title: Lc) -> Self {
|
||||
self.title = title;
|
||||
self
|
||||
}
|
||||
|
||||
/// Establece la descripción de la página como un valor traducible.
|
||||
#[builder_fn]
|
||||
pub fn with_description(mut self, description: Lc) -> Self {
|
||||
self.description = description;
|
||||
self
|
||||
}
|
||||
|
||||
/// Añade una entrada `<meta name="..." content="...">` al `<head>`.
|
||||
#[builder_fn]
|
||||
pub fn with_metadata(mut self, name: &'static str, content: &'static str) -> Self {
|
||||
self.metadata.push((name, content));
|
||||
self
|
||||
}
|
||||
|
||||
/// Añade una entrada `<meta property="..." content="...">` al `<head>`.
|
||||
#[builder_fn]
|
||||
pub fn with_property(mut self, property: &'static str, content: &'static str) -> Self {
|
||||
self.properties.push((property, content));
|
||||
self
|
||||
|
|
@ -267,59 +264,51 @@ impl LangId for Page {
|
|||
}
|
||||
}
|
||||
|
||||
#[builder_impl]
|
||||
impl Contextual for Page {
|
||||
// **< Contextual BUILDER >*********************************************************************
|
||||
|
||||
#[builder_fn]
|
||||
fn with_request(mut self, request: Option<HttpRequest>) -> Self {
|
||||
self.context.alter_request(request);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_langid(mut self, language: &impl LangId) -> Self {
|
||||
self.context.alter_langid(language);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_template(mut self, template: TemplateRef) -> Self {
|
||||
self.context.alter_template(template);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_theme(mut self, theme: ThemeRef) -> Self {
|
||||
self.context.alter_theme(theme);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_param<T: Send + Sync + 'static>(mut self, key: &'static str, value: T) -> Self {
|
||||
self.context.alter_param(key, value);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_assets(mut self, op: AssetsOp) -> Self {
|
||||
self.context.alter_assets(op);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_body_props(mut self, op: PropsOp) -> Self {
|
||||
self.context.alter_body_props(op);
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_child(mut self, op: impl Into<ChildOp>) -> Self {
|
||||
self.context
|
||||
.alter_child_in(&CoreRegions::Content, op.into());
|
||||
self
|
||||
}
|
||||
|
||||
#[builder_fn]
|
||||
fn with_child_in(mut self, region: RegionRef, op: impl Into<ChildOp>) -> Self {
|
||||
self.context.alter_child_in(region, op.into());
|
||||
self
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue