2
2
3
3
import streamlit as st
4
4
import streamlit .components .v1 as components
5
- from streamlit .components .v1 .custom_component import MarshallComponentException
6
5
7
6
_RELEASE = False
8
7
35
34
# Thanks andfanilo
36
35
class JsCode :
37
36
def __init__ (self , js_code : str ):
38
- """Wrapper around a js function to be injected on gridOptions.
39
- code is not checked at all.
40
- set allow_unsafe_jscode=True on AgGrid call to use it.
37
+ """Wrapper around a js function to be injected on config.
38
+ Code is not checked at all.
41
39
Code is rebuilt on client using new Function Syntax (https://javascript.info/new-function)
42
40
43
41
Args:
@@ -108,7 +106,7 @@ def condition_tree(config: dict,
108
106
placeholder : str = '' ,
109
107
always_show_buttons : bool = False ,
110
108
key : str = None ,
111
- allow_unsafe_jscode : bool = False , ):
109
+ ):
112
110
"""Create a new instance of condition_tree.
113
111
114
112
Parameters
@@ -138,9 +136,6 @@ def condition_tree(config: dict,
138
136
None, and the component's arguments are changed, the component will
139
137
be re-mounted in the Streamlit frontend and lose its current state.
140
138
Can also be used to access the condition tree through st.session_state.
141
- allow_unsafe_jscode: bool
142
- Allows jsCode to be injected in gridOptions.
143
- Defaults to False.
144
139
145
140
Returns
146
141
-------
@@ -159,28 +154,18 @@ def condition_tree(config: dict,
159
154
160
155
config ['fields' ] = fields
161
156
162
- if allow_unsafe_jscode :
163
- walk_config (config , lambda v : v .js_code if isinstance (v , JsCode ) else v )
164
-
165
- try :
166
- output_tree , component_value = _component_func (
167
- config = config ,
168
- return_type = return_type ,
169
- tree = tree ,
170
- key = '_' + key if key else None ,
171
- min_height = min_height ,
172
- placeholder = placeholder ,
173
- always_show_buttons = always_show_buttons ,
174
- default = ['' , '' ],
175
- allow_unsafe_jscode = allow_unsafe_jscode ,
176
- )
177
-
178
- except MarshallComponentException as e :
179
- # Uses a more complete error message.
180
- args = list (e .args )
181
- args [0 ] += ". If you're using custom JsCode objects on config, ensure that allow_unsafe_jscode is True."
182
- e = MarshallComponentException (* args )
183
- raise (e )
157
+ walk_config (config , lambda v : v .js_code if isinstance (v , JsCode ) else v )
158
+
159
+ output_tree , component_value = _component_func (
160
+ config = config ,
161
+ return_type = return_type ,
162
+ tree = tree ,
163
+ key = '_' + key if key else None ,
164
+ min_height = min_height ,
165
+ placeholder = placeholder ,
166
+ always_show_buttons = always_show_buttons ,
167
+ default = ['' , '' ],
168
+ )
184
169
185
170
if return_type == 'queryString' and not component_value :
186
171
# Default string that applies no filter in DataFrame.query
0 commit comments