11from __future__ import annotations
22
33from base64 import b64encode
4- from typing import Any , Callable , Dict , List , Optional , Sequence , Tuple , TypeVar , Union
4+ from typing import Any , Callable , Iterable , Tuple , TypeVar , Union
55
66from typing_extensions import Protocol
77
1616def image (
1717 format : str ,
1818 value : Union [str , bytes ] = "" ,
19- attributes : Optional [ Dict [ str , Any ]] = None ,
19+ ** attributes : Any ,
2020) -> VdomDict :
2121 """Utility for constructing an image from a string or bytes
2222
@@ -33,19 +33,19 @@ def image(
3333 base64_value = b64encode (bytes_value ).decode ()
3434 src = f"data:image/{ format } ;base64,{ base64_value } "
3535
36- return {"tagName" : "img" , "attributes" : {"src" : src , ** ( attributes or {}) }}
36+ return {"tagName" : "img" , "attributes" : {"src" : src , ** attributes }}
3737
3838
3939_Value = TypeVar ("_Value" )
4040
4141
4242def use_linked_inputs (
43- attributes : Sequence [ Dict [str , Any ]],
43+ attributes : Iterable [ dict [str , Any ]],
4444 on_change : Callable [[_Value ], None ] = lambda value : None ,
4545 cast : _CastFunc [_Value ] = lambda value : value ,
4646 initial_value : str = "" ,
4747 ignore_empty : bool = True ,
48- ) -> List [VdomDict ]:
48+ ) -> list [VdomDict ]:
4949 """Return a list of linked inputs equal to the number of given attributes.
5050
5151 Parameters:
@@ -67,7 +67,7 @@ def use_linked_inputs(
6767 """
6868 value , set_value = idom .hooks .use_state (initial_value )
6969
70- def sync_inputs (event : Dict [str , Any ]) -> None :
70+ def sync_inputs (event : dict [str , Any ]) -> None :
7171 new_value = event ["target" ]["value" ]
7272 set_value (new_value )
7373 if not new_value and ignore_empty :
@@ -82,7 +82,7 @@ def sync_inputs(event: Dict[str, Any]) -> None:
8282 key = attrs .pop ("key" , None )
8383 attrs .update ({"onChange" : sync_inputs , "value" : value })
8484
85- inputs .append (html .input (attrs , key = key ))
85+ inputs .append (html .input (key = key , ** attrs ))
8686
8787 return inputs
8888
0 commit comments