|
@@ -1,51 +1,83 @@
|
|
use dioxus::core_macro::render;
|
|
use dioxus::core_macro::render;
|
|
use dioxus::prelude::rsx;
|
|
use dioxus::prelude::rsx;
|
|
-use dioxus_core::{AttributeBox, Element, HasAttributesBox, Scope};
|
|
|
|
|
|
+use dioxus_core::{Attribute, Element, HasAttributesBox, Scope};
|
|
use dioxus_html::{ExtendedAudioMarker, ExtendedGlobalAttributesMarker};
|
|
use dioxus_html::{ExtendedAudioMarker, ExtendedGlobalAttributesMarker};
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
fn props_spread() {
|
|
fn props_spread() {
|
|
pub struct FooProps<'a> {
|
|
pub struct FooProps<'a> {
|
|
pub open: Option<&'a str>,
|
|
pub open: Option<&'a str>,
|
|
- attributes: Vec<AttributeBox<'a>>,
|
|
|
|
|
|
+ attributes: Vec<Attribute<'a>>,
|
|
}
|
|
}
|
|
|
|
|
|
// -----
|
|
// -----
|
|
impl<'a> FooProps<'a> {
|
|
impl<'a> FooProps<'a> {
|
|
#[doc = "\nCreate a builder for building `FooProps`.\nOn the builder, call `.open(...)`(optional) to set the values of the fields.\nFinally, call `.build()` to create the instance of `FooProps`.\n "]
|
|
#[doc = "\nCreate a builder for building `FooProps`.\nOn the builder, call `.open(...)`(optional) to set the values of the fields.\nFinally, call `.build()` to create the instance of `FooProps`.\n "]
|
|
#[allow(dead_code)]
|
|
#[allow(dead_code)]
|
|
- pub fn builder() -> FooPropsBuilder<'a, ((), ), > {
|
|
|
|
- FooPropsBuilder { fields: ((), ), attributes: Vec::new(), _phantom: core::default::Default::default() }
|
|
|
|
|
|
+ pub fn builder(cx: &ScopeState) -> FooPropsBuilder<'a, ((),)> {
|
|
|
|
+ FooPropsBuilder {
|
|
|
|
+ bump: cx.bump(),
|
|
|
|
+ fields: ((),),
|
|
|
|
+ attributes: Vec::new(),
|
|
|
|
+ _phantom: core::default::Default::default(),
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#[must_use]
|
|
#[must_use]
|
|
#[doc(hidden)]
|
|
#[doc(hidden)]
|
|
#[allow(dead_code, non_camel_case_types, non_snake_case)]
|
|
#[allow(dead_code, non_camel_case_types, non_snake_case)]
|
|
- pub struct FooPropsBuilder<'a, TypedBuilderFields, > {
|
|
|
|
|
|
+ pub struct FooPropsBuilder<'a, TypedBuilderFields> {
|
|
|
|
+ bump: &'a ::dioxus::core::exports::bumpalo::Bump,
|
|
fields: TypedBuilderFields,
|
|
fields: TypedBuilderFields,
|
|
- attributes: Vec<AttributeBox<'a>>,
|
|
|
|
- _phantom: ( core::marker::PhantomData<&'a ()> ),
|
|
|
|
|
|
+ attributes: Vec<Attribute<'a>>,
|
|
|
|
+ _phantom: (core::marker::PhantomData<&'a ()>),
|
|
}
|
|
}
|
|
//impl<'a, TypedBuilderFields, > Clone for FooPropsBuilder<'a, TypedBuilderFields, > where TypedBuilderFields: Clone { fn clone(&self) -> Self { Self { fields: self.fields.clone(), attributes: self.attributes, _phantom: Default::default() } } }
|
|
//impl<'a, TypedBuilderFields, > Clone for FooPropsBuilder<'a, TypedBuilderFields, > where TypedBuilderFields: Clone { fn clone(&self) -> Self { Self { fields: self.fields.clone(), attributes: self.attributes, _phantom: Default::default() } } }
|
|
impl<'a> dioxus::prelude::Properties for FooProps<'a> {
|
|
impl<'a> dioxus::prelude::Properties for FooProps<'a> {
|
|
- type Builder = FooPropsBuilder<'a, ((), ), >;
|
|
|
|
|
|
+ type Builder = FooPropsBuilder<'a, ((),)>;
|
|
const IS_STATIC: bool = false;
|
|
const IS_STATIC: bool = false;
|
|
- fn builder() -> Self::Builder { FooProps::builder() }
|
|
|
|
- unsafe fn memoize(&self, other: &Self) -> bool { false }
|
|
|
|
|
|
+ fn builder(cx: &ScopeState) -> Self::Builder {
|
|
|
|
+ FooProps::builder(cx)
|
|
|
|
+ }
|
|
|
|
+ unsafe fn memoize(&self, other: &Self) -> bool {
|
|
|
|
+ false
|
|
|
|
+ }
|
|
}
|
|
}
|
|
#[doc(hidden)]
|
|
#[doc(hidden)]
|
|
#[allow(dead_code, non_camel_case_types, non_snake_case)]
|
|
#[allow(dead_code, non_camel_case_types, non_snake_case)]
|
|
- pub trait FooPropsBuilder_Optional<T> { fn into_value<F: FnOnce() -> T>(self, default: F) -> T; }
|
|
|
|
- impl<T> FooPropsBuilder_Optional<T> for () { fn into_value<F: FnOnce() -> T>(self, default: F) -> T { default() } }
|
|
|
|
- impl<T> FooPropsBuilder_Optional<T> for (T, ) { fn into_value<F: FnOnce() -> T>(self, _: F) -> T { self.0 } }
|
|
|
|
|
|
+ pub trait FooPropsBuilder_Optional<T> {
|
|
|
|
+ fn into_value<F: FnOnce() -> T>(self, default: F) -> T;
|
|
|
|
+ }
|
|
|
|
+ impl<T> FooPropsBuilder_Optional<T> for () {
|
|
|
|
+ fn into_value<F: FnOnce() -> T>(self, default: F) -> T {
|
|
|
|
+ default()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ impl<T> FooPropsBuilder_Optional<T> for (T,) {
|
|
|
|
+ fn into_value<F: FnOnce() -> T>(self, _: F) -> T {
|
|
|
|
+ self.0
|
|
|
|
+ }
|
|
|
|
+ }
|
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
|
- impl<'a> FooPropsBuilder<'a, ((), )> {
|
|
|
|
- pub fn open(self, open: &'a str) -> FooPropsBuilder<'a, ((Option<&'a str>,
|
|
|
|
- // pub attributes: Vec<Attribute<'a>>,
|
|
|
|
- ), )> {
|
|
|
|
- let open = (Some(open), );
|
|
|
|
- let (_, ) = self.fields;
|
|
|
|
- FooPropsBuilder { fields: (open, ), attributes: self.attributes, _phantom: self._phantom }
|
|
|
|
|
|
+ impl<'a> FooPropsBuilder<'a, ((),)> {
|
|
|
|
+ pub fn open(
|
|
|
|
+ self,
|
|
|
|
+ open: &'a str,
|
|
|
|
+ ) -> FooPropsBuilder<
|
|
|
|
+ 'a,
|
|
|
|
+ ((
|
|
|
|
+ Option<&'a str>,
|
|
|
|
+ // pub attributes: Vec<Attribute<'a>>,
|
|
|
|
+ ),),
|
|
|
|
+ > {
|
|
|
|
+ let open = (Some(open),);
|
|
|
|
+ let (_,) = self.fields;
|
|
|
|
+ FooPropsBuilder {
|
|
|
|
+ bump: self.bump,
|
|
|
|
+ fields: (open,),
|
|
|
|
+ attributes: self.attributes,
|
|
|
|
+ _phantom: self._phantom,
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#[doc(hidden)]
|
|
#[doc(hidden)]
|
|
@@ -53,33 +85,67 @@ fn props_spread() {
|
|
pub enum FooPropsBuilder_Error_Repeated_field_open {}
|
|
pub enum FooPropsBuilder_Error_Repeated_field_open {}
|
|
#[doc(hidden)]
|
|
#[doc(hidden)]
|
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
|
- impl<'a> FooPropsBuilder<'a, ((Option<&'a str>,
|
|
|
|
- // pub attributes: Vec<Attribute<'a>>,
|
|
|
|
- ), )> {
|
|
|
|
|
|
+ impl<'a>
|
|
|
|
+ FooPropsBuilder<
|
|
|
|
+ 'a,
|
|
|
|
+ ((
|
|
|
|
+ Option<&'a str>,
|
|
|
|
+ // pub attributes: Vec<Attribute<'a>>,
|
|
|
|
+ ),),
|
|
|
|
+ >
|
|
|
|
+ {
|
|
#[deprecated(note = "Repeated field open")]
|
|
#[deprecated(note = "Repeated field open")]
|
|
- pub fn open(self, _: FooPropsBuilder_Error_Repeated_field_open) -> FooPropsBuilder<'a, ((Option<&'a str>,
|
|
|
|
- // pub attributes: Vec<Attribute<'a>>,
|
|
|
|
- ), )> { self }
|
|
|
|
|
|
+ pub fn open(
|
|
|
|
+ self,
|
|
|
|
+ _: FooPropsBuilder_Error_Repeated_field_open,
|
|
|
|
+ ) -> FooPropsBuilder<
|
|
|
|
+ 'a,
|
|
|
|
+ ((
|
|
|
|
+ Option<&'a str>,
|
|
|
|
+ // pub attributes: Vec<Attribute<'a>>,
|
|
|
|
+ ),),
|
|
|
|
+ > {
|
|
|
|
+ self
|
|
|
|
+ }
|
|
}
|
|
}
|
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
|
- impl<'a, __open: FooPropsBuilder_Optional<Option<&'a str>>> FooPropsBuilder<'a, (__open, ), > {
|
|
|
|
|
|
+ impl<'a, __open: FooPropsBuilder_Optional<Option<&'a str>>> FooPropsBuilder<'a, (__open,)> {
|
|
pub fn build(self) -> FooProps<'a> {
|
|
pub fn build(self) -> FooProps<'a> {
|
|
- let (open, ) = self.fields;
|
|
|
|
|
|
+ let (open,) = self.fields;
|
|
let open = FooPropsBuilder_Optional::into_value(open, || Default::default());
|
|
let open = FooPropsBuilder_Optional::into_value(open, || Default::default());
|
|
- FooProps { open, attributes: self.attributes }
|
|
|
|
|
|
+ FooProps {
|
|
|
|
+ open,
|
|
|
|
+ attributes: self.attributes,
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// -----
|
|
// -----
|
|
|
|
|
|
- impl<'a, A> HasAttributesBox<'a, FooPropsBuilder<'a, (A, )>> for FooPropsBuilder<'a, (A, )> {
|
|
|
|
- fn push_attribute(self, attr: AttributeBox<'a>) -> FooPropsBuilder<'a, (A, )> {
|
|
|
|
|
|
+ impl<'a, A> HasAttributesBox<'a, FooPropsBuilder<'a, (A,)>> for FooPropsBuilder<'a, (A,)> {
|
|
|
|
+ fn push_attribute(
|
|
|
|
+ self,
|
|
|
|
+ name: &str,
|
|
|
|
+ ns: Option<&str>,
|
|
|
|
+ attr: impl IntoAttributeValue<'a>,
|
|
|
|
+ volatile: bool,
|
|
|
|
+ ) -> Self {
|
|
let mut attrs = Vec::from(self.attributes);
|
|
let mut attrs = Vec::from(self.attributes);
|
|
- attrs.push(attr);
|
|
|
|
- FooPropsBuilder { fields: self.fields, attributes: attrs, _phantom: self._phantom }
|
|
|
|
|
|
+ attrs.push(Attribute::new(
|
|
|
|
+ name,
|
|
|
|
+ attr.into_value(self.bump),
|
|
|
|
+ ns,
|
|
|
|
+ volatile,
|
|
|
|
+ ));
|
|
|
|
+ FooPropsBuilder {
|
|
|
|
+ bump: self.bump,
|
|
|
|
+ fields: self.fields,
|
|
|
|
+ attributes: attrs,
|
|
|
|
+ _phantom: self._phantom,
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- impl<A,> ExtendedGlobalAttributesMarker for FooPropsBuilder<'_, (A,)> {}
|
|
|
|
- impl<A,> ExtendedAudioMarker for FooPropsBuilder<'_, (A,)> {}
|
|
|
|
|
|
+ impl<A> ExtendedGlobalAttributesMarker for FooPropsBuilder<'_, (A,)> {}
|
|
|
|
+ impl<A> ExtendedAudioMarker for FooPropsBuilder<'_, (A,)> {}
|
|
|
|
|
|
use dioxus::prelude::*;
|
|
use dioxus::prelude::*;
|
|
use dioxus_html::AudioExtension;
|
|
use dioxus_html::AudioExtension;
|
|
@@ -87,7 +153,7 @@ fn props_spread() {
|
|
#[allow(non_snake_case)]
|
|
#[allow(non_snake_case)]
|
|
pub fn Foo<'a>(cx: Scope<'a, FooProps<'a>>) -> Element<'a> {
|
|
pub fn Foo<'a>(cx: Scope<'a, FooProps<'a>>) -> Element<'a> {
|
|
let muted = false;
|
|
let muted = false;
|
|
- let attributes = cx.props.attributes;
|
|
|
|
|
|
+ let attributes = &cx.props.attributes;
|
|
render! {
|
|
render! {
|
|
// rsx! {
|
|
// rsx! {
|
|
// audio {
|
|
// audio {
|
|
@@ -99,7 +165,7 @@ fn props_spread() {
|
|
let mut attrs = vec![__cx.attr(dioxus_elements::audio::muted.0, muted, dioxus_elements::audio::muted.1, dioxus_elements::audio::muted.2)];
|
|
let mut attrs = vec![__cx.attr(dioxus_elements::audio::muted.0, muted, dioxus_elements::audio::muted.1, dioxus_elements::audio::muted.2)];
|
|
for attr in attributes {
|
|
for attr in attributes {
|
|
attrs.push(__cx.attr(attr.name, attr.value.into_value(__cx.bump()), attr.namespace, attr.volatile));
|
|
attrs.push(__cx.attr(attr.name, attr.value.into_value(__cx.bump()), attr.namespace, attr.volatile));
|
|
- };
|
|
|
|
|
|
+ }
|
|
::dioxus::core::VNode {
|
|
::dioxus::core::VNode {
|
|
parent: None,
|
|
parent: None,
|
|
key: None,
|
|
key: None,
|
|
@@ -118,4 +184,4 @@ fn props_spread() {
|
|
controls: true,
|
|
controls: true,
|
|
}
|
|
}
|
|
};
|
|
};
|
|
-}
|
|
|
|
|
|
+}
|