|
1 | 1 |
|
2 | 2 | Based on [react-awesome-query-builder](https://github.com/ukrbublik/react-awesome-query-builder)
|
3 | 3 |
|
4 |
| -Check out [live demo](https://app-condition-tree-demo-dkclrsnqxpcgzkjzlv3mqu.streamlit.app/) ! |
| 4 | +Check out [live demo](https://condition-tree-demo.streamlit.app/) ! |
| 5 | + |
| 6 | +This component allows users to build complex condition trees that can be used, for example, to filter a dataframe or build a query. |
5 | 7 |
|
6 | 8 | <img src="preview.jpg" width="500" alt="preview">
|
7 | 9 |
|
@@ -43,17 +45,15 @@ config = {
|
43 | 45 | 'type': 'text',
|
44 | 46 | },
|
45 | 47 | 'qty': {
|
46 |
| - 'label': "Age", |
47 |
| - 'type': "number", |
| 48 | + 'label': 'Age', |
| 49 | + 'type': 'number', |
48 | 50 | 'fieldSettings': {
|
49 | 51 | 'min': 0
|
50 | 52 | },
|
51 |
| - 'preferWidgets': ['number'] |
52 | 53 | },
|
53 | 54 | 'like_tomatoes': {
|
54 | 55 | 'label': 'Likes tomatoes',
|
55 |
| - 'type': "boolean", |
56 |
| - 'operators': ["equal"], |
| 56 | + 'type': 'boolean', |
57 | 57 | }
|
58 | 58 | }
|
59 | 59 | }
|
@@ -93,22 +93,37 @@ def condition_tree(
|
93 | 93 | - spel
|
94 | 94 | - elasticSearch
|
95 | 95 | - jsonLogic
|
| 96 | + |
| 97 | + Default : queryString |
96 | 98 |
|
97 | 99 |
|
98 | 100 | - **tree**: Input condition tree (see section below)
|
| 101 | + |
| 102 | + Default : None |
99 | 103 |
|
100 | 104 |
|
101 | 105 | - **min_height**: Minimum height of the component frame
|
| 106 | + |
| 107 | + Default : 400 |
102 | 108 |
|
103 | 109 |
|
104 | 110 | - **placeholder**: Text displayed when the condition tree is empty
|
| 111 | + |
| 112 | + Default : None |
105 | 113 |
|
106 | 114 |
|
107 | 115 | - **key**: Fixed identity if you want to change its arguments over time and not have it be re-created.
|
108 | 116 | Can also be used to access the generated condition tree (see section below).
|
109 | 117 |
|
| 118 | + Default : None |
| 119 | + |
110 | 120 |
|
111 | 121 | ### Export & import a condition tree
|
112 | 122 |
|
113 | 123 | When a key is defined for the component, the condition tree generated is accessible through `st.session_state[key]` as a dictionary.
|
114 | 124 | It can be loaded as an input tree through the `tree` parameter.
|
| 125 | + |
| 126 | + |
| 127 | +## Potential future improvements |
| 128 | +- **Dataframe filtering support**: automatically build config from dataframe and return a query string adapted to `pandas.DataFrame.query` |
| 129 | +- **Javascript support**: allow injection of javascript code in the configuration (e.g. validators) |
0 commit comments