fix(web): type-erase component views to fix compiler recursion limit

This commit is contained in:
Kristofers Solo 2025-12-30 15:38:58 +02:00
parent 02ab1d119c
commit c3f39cedc9
Signed by: kristoferssolo
GPG Key ID: 8687F2D3EEE6F0ED

View File

@ -91,7 +91,7 @@ fn RadioButton(
value: OperationMode, value: OperationMode,
current: ReadSignal<OperationMode>, current: ReadSignal<OperationMode>,
set_current: WriteSignal<OperationMode>, set_current: WriteSignal<OperationMode>,
) -> impl IntoView { ) -> AnyView {
view! { view! {
<div class="radio-button"> <div class="radio-button">
<label> <label>
@ -106,6 +106,7 @@ fn RadioButton(
</label> </label>
</div> </div>
} }
.into_any()
} }
#[component] #[component]
@ -114,7 +115,7 @@ fn ConfigurationSection(
set_mode: WriteSignal<OperationMode>, set_mode: WriteSignal<OperationMode>,
output_fmt: ReadSignal<OutputFormat>, output_fmt: ReadSignal<OutputFormat>,
update_output: impl Fn(OutputFormat) + Copy + Send + 'static, update_output: impl Fn(OutputFormat) + Copy + Send + 'static,
) -> impl IntoView { ) -> AnyView {
let handle_format_change = move |ev| { let handle_format_change = move |ev| {
let val = event_target_value(&ev); let val = event_target_value(&ev);
let fmt = OutputFormat::from_str(&val).unwrap_or_default(); let fmt = OutputFormat::from_str(&val).unwrap_or_default();
@ -176,7 +177,7 @@ fn ConfigurationSection(
}} }}
</div> </div>
</div> </div>
} }.into_any()
} }
fn clean_hex_input(input: String) -> String { fn clean_hex_input(input: String) -> String {
@ -187,7 +188,7 @@ fn clean_hex_input(input: String) -> String {
} }
#[component] #[component]
fn KeyInput(set_key_input: WriteSignal<String>) -> impl IntoView { fn KeyInput(set_key_input: WriteSignal<String>) -> AnyView {
view! { view! {
<div class="form-group"> <div class="form-group">
<div class="lable-header"> <div class="lable-header">
@ -201,6 +202,7 @@ fn KeyInput(set_key_input: WriteSignal<String>) -> impl IntoView {
/> />
</div> </div>
} }
.into_any()
} }
#[component] #[component]
@ -208,7 +210,7 @@ fn TextInput(
mode: ReadSignal<OperationMode>, mode: ReadSignal<OperationMode>,
text_input: ReadSignal<String>, text_input: ReadSignal<String>,
set_text_input: WriteSignal<String>, set_text_input: WriteSignal<String>,
) -> impl IntoView { ) -> AnyView {
let handle_hex_input = move |ev| { let handle_hex_input = move |ev| {
let val = event_target_value(&ev); let val = event_target_value(&ev);
let cleaned = clean_hex_input(val); let cleaned = clean_hex_input(val);
@ -264,6 +266,7 @@ fn TextInput(
}} }}
</div> </div>
} }
.into_any()
} }
#[component] #[component]
@ -272,7 +275,7 @@ fn OutputBox(
output_fmt: ReadSignal<OutputFormat>, output_fmt: ReadSignal<OutputFormat>,
copy_to_clipboard: impl Fn(String) + Copy + Send + 'static, copy_to_clipboard: impl Fn(String) + Copy + Send + 'static,
copy_feedback: ReadSignal<bool>, copy_feedback: ReadSignal<bool>,
) -> impl IntoView { ) -> AnyView {
view! { view! {
{move || { {move || {
if output.get().is_empty() { if output.get().is_empty() {
@ -294,10 +297,11 @@ fn OutputBox(
.into_any() .into_any()
}} }}
} }
.into_any()
} }
#[component] #[component]
fn ErrorBox(error_msg: ReadSignal<String>) -> impl IntoView { fn ErrorBox(error_msg: ReadSignal<String>) -> AnyView {
view! { view! {
{move || { {move || {
if error_msg.get().is_empty() { if error_msg.get().is_empty() {
@ -306,4 +310,5 @@ fn ErrorBox(error_msg: ReadSignal<String>) -> impl IntoView {
view! { <div class="error-box">{error_msg.get()}</div> }.into_any() view! { <div class="error-box">{error_msg.get()}</div> }.into_any()
}} }}
} }
.into_any()
} }