@@ -35,6 +35,7 @@ class DashDependency: # pylint: disable=too-few-public-methods
35
35
allow_duplicate : bool
36
36
component_property : str
37
37
allowed_wildcards : Sequence [_Wildcard ]
38
+ allow_optional : bool
38
39
39
40
def __init__ (self , component_id : ComponentIdType , component_property : str ):
40
41
@@ -45,6 +46,7 @@ def __init__(self, component_id: ComponentIdType, component_property: str):
45
46
46
47
self .component_property = component_property
47
48
self .allow_duplicate = False
49
+ self .allow_optional = False
48
50
49
51
def __str__ (self ):
50
52
return f"{ self .component_id_str ()} .{ self .component_property } "
@@ -56,7 +58,8 @@ def component_id_str(self) -> str:
56
58
return stringify_id (self .component_id )
57
59
58
60
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
60
63
61
64
def __eq__ (self , other ):
62
65
"""
@@ -133,14 +136,29 @@ def __init__(
133
136
134
137
class Input (DashDependency ): # pylint: disable=too-few-public-methods
135
138
"""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 )
138
148
139
149
140
150
class State (DashDependency ): # pylint: disable=too-few-public-methods
141
151
"""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)
144
162
145
163
146
164
class ClientsideFunction : # pylint: disable=too-few-public-methods
0 commit comments