11pub use value_kind:: InputValueKind ;
22
3- use async_str_iter:: IntoAsyncStrIterator ;
43use frender_common:: {
54 strings:: { CsrStr , SsrStr } ,
65 Empty , PrimarilyBorrow ,
@@ -10,10 +9,12 @@ use super::{
109 element:: FormControlElement ,
1110 value:: {
1211 FormControlValue , FormControlValueKind , MaybeProvideFormControlValue ,
13- ProvideFormControlValue , UncontrolledWithDefaultValue ,
12+ UncontrolledWithDefaultValue ,
1413 } ,
1514} ;
1615
16+ mod ssr;
17+
1718/// A trait alias
1819pub trait InputElement < Renderer : ?Sized > :
1920 FormControlElement < str , Renderer >
@@ -435,97 +436,3 @@ impl<
435436 self
436437 }
437438}
438-
439- mod ssr {
440- use async_str_iter:: { any_str:: IterAnyStr , chain:: Chain , option:: IterOption } ;
441- use frender_common:: IntoStaticStr ;
442- use frender_ssr:: html:: {
443- attr:: { AssertSpaceAndHtmlAttributeName , SpaceAndHtmlAttribute } ,
444- attr_value:: AttrEqValue ,
445- } ;
446-
447- use frender_dom:: component:: IntoSpaceAndHtmlAttributesOrEmpty ;
448-
449- use super :: * ;
450-
451- impl <
452- //
453- Type : InputType ,
454- Value : InputValue ,
455- Checked : InputChecked ,
456- > IntoSpaceAndHtmlAttributesOrEmpty for InputDataModel < Type , Value , Checked >
457- {
458- type SpaceAndHtmlAttributesOrEmpty = Chain <
459- // type
460- IterOption <
461- SpaceAndHtmlAttribute <
462- //
463- AssertSpaceAndHtmlAttributeName < & ' static str > ,
464- AttrEqValue < IterAnyStr <
465- <<Type as InputType >:: InputTypeStr as SsrStr >:: StaticStr
466- > > ,
467- > ,
468- > ,
469- Chain <
470- // value
471- IterOption <
472- SpaceAndHtmlAttribute <
473- //
474- AssertSpaceAndHtmlAttributeName < & ' static str > ,
475- <Value :: ValueKind as InputValueKind >:: IntoInputValueAttrValue <
476- //
477- <Value as MaybeProvideFormControlValue < Value :: ValueKind > >:: ProvideFormControlValue ,
478- > ,
479- > ,
480- > ,
481- // checked
482- IterOption < AssertSpaceAndHtmlAttributeName < & ' static str > > ,
483- > ,
484- > ;
485-
486- fn into_space_and_html_attributes_or_empty ( self ) -> Self :: SpaceAndHtmlAttributesOrEmpty {
487- const TYPE : AssertSpaceAndHtmlAttributeName < & ' static str > =
488- AssertSpaceAndHtmlAttributeName :: new_from_str ( " type" ) ;
489- const VALUE : AssertSpaceAndHtmlAttributeName < & ' static str > =
490- AssertSpaceAndHtmlAttributeName :: new_from_str ( " value" ) ;
491- const CHECKED : AssertSpaceAndHtmlAttributeName < & ' static str > =
492- AssertSpaceAndHtmlAttributeName :: new_from_str ( " checked" ) ;
493-
494- let Self {
495- r#type : input_type,
496- value,
497- checked,
498- } = self ;
499-
500- let input_type = Type :: maybe_into_input_type_str ( input_type)
501- . map ( |v| v. into_into_static_str ( ) . into_static_str ( ) ) ;
502-
503- let value_attr = Value :: maybe_into_provide_form_control_value ( value)
504- . map ( |value| {
505- let input_type = input_type. as_ref ( ) . map_or ( "" , |v| v. as_ref ( ) ) ;
506- Value :: ValueKind :: into_input_value_attr_value ( value, input_type)
507- } )
508- . map ( |eq_value| SpaceAndHtmlAttribute ( VALUE , eq_value) ) ;
509-
510- let checked_attr = {
511- let checked = Checked :: maybe_into_provide_form_control_value ( checked)
512- . map_or ( false , |checked| checked. provide_form_control_value ( |v| * v) ) ;
513- checked. then_some ( CHECKED )
514- } ;
515-
516- Chain :: new (
517- input_type
518- . map ( |input_type| {
519- let value = IterAnyStr :: new ( input_type) ;
520- let value = AttrEqValue ( value) ;
521- SpaceAndHtmlAttribute ( TYPE , value)
522- } )
523- . into_async_str_iterator ( ) ,
524- Chain :: new (
525- value_attr. into_async_str_iterator ( ) ,
526- checked_attr. into_async_str_iterator ( ) ,
527- ) ,
528- )
529- }
530- }
531- }
0 commit comments