@@ -35,6 +35,7 @@ class DashDependency: # pylint: disable=too-few-public-methods
3535 allow_duplicate : bool
3636 component_property : str
3737 allowed_wildcards : Sequence [_Wildcard ]
38+ allow_optional : bool
3839
3940 def __init__ (self , component_id : ComponentIdType , component_property : str ):
4041
@@ -45,6 +46,7 @@ def __init__(self, component_id: ComponentIdType, component_property: str):
4546
4647 self .component_property = component_property
4748 self .allow_duplicate = False
49+ self .allow_optional = False
4850
4951 def __str__ (self ):
5052 return f"{ self .component_id_str ()} .{ self .component_property } "
@@ -56,7 +58,8 @@ def component_id_str(self) -> str:
5658 return stringify_id (self .component_id )
5759
5860 def to_dict (self ) -> dict :
59- return {"id" : self .component_id_str (), "property" : self .component_property }
61+ specs = {"id" : self .component_id_str (), "property" : self .component_property }
62+ return {** specs , 'allow_optional' : True } if self .allow_optional else specs
6063
6164 def __eq__ (self , other ):
6265 """
@@ -133,14 +136,29 @@ def __init__(
133136
134137class Input (DashDependency ): # pylint: disable=too-few-public-methods
135138 """Input of callback: trigger an update when it is updated."""
136-
137- allowed_wildcards = (MATCH , ALL , ALLSMALLER )
139+ def __init__ (
140+ self ,
141+ component_id : ComponentIdType ,
142+ component_property : str ,
143+ allow_optional : bool = False ,
144+ ):
145+ super ().__init__ (component_id , component_property )
146+ self .allow_optional = allow_optional
147+ self .allowed_wildcards = (MATCH , ALL , ALLSMALLER )
138148
139149
140150class State (DashDependency ): # pylint: disable=too-few-public-methods
141151 """Use the value of a State in a callback but don't trigger updates."""
142-
143- allowed_wildcards = (MATCH , ALL , ALLSMALLER )
152+ def __init__ (
153+ self ,
154+ component_id : ComponentIdType ,
155+ component_property : str ,
156+ allow_optional : bool = False ,
157+ ):
158+ super ().__init__ (component_id , component_property )
159+ self .allow_optional = allow_optional
160+ self .allowed_wildcards = (MATCH , ALL , ALLSMALLER )
161+ # allowed_wildcards = (MATCH, ALL, ALLSMALLER)
144162
145163
146164class ClientsideFunction : # pylint: disable=too-few-public-methods
0 commit comments