Commit bfbf7b1
authored
feat: Picker - Table support for key + label columns (#1876)
Initial table support for Picker
- key and value column support
- Scroll to selected item when popover opens
- Viewport data now supports re-use of existing item objects via
`reuseItemsOnTableResize` flag
## Testing
### Scroll to item fix for non-table data (this should work without any
changes to plugins repo)
```python
import deephaven.ui as ui
from deephaven.ui import use_state
items = list("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
@ui.component
def picker():
value, set_value = use_state("M")
# Picker for selecting values
pick = ui.picker(
label="Text",
on_selection_change=set_value,
selected_key=value,
children=items
)
# Show current selection in a ui.text component
text = ui.text("Selection: " + value)
# Display picker and output in a flex column
return ui.flex(
pick,
text,
direction="column",
margin=10,
gap=10,
)
p = picker()
```
### Table support
There is a draft PR in the plugins repo that enables the table support
on the plugins side of things (note that it currently will have type
errors but should run)
deephaven/deephaven-plugins#382
Here's an example that demonstrates a large number of items that also
tick
```python
import deephaven.ui as ui
from deephaven.ui import use_state
from deephaven import time_table
import datetime
mylist = ["mars", "pluto", "saturn"]
simple_ticking = time_table("PT2S", start_time=datetime.datetime.now() - datetime.timedelta(seconds=2000)).update([
'Id=(new Integer(i * 100))',
"Planet=mylist[ (int) (3 * Math.random()) % 3 ]",
])
@ui.component
def picker():
value, set_value = use_state(13800)
print("Test", value)
# Picker for selecting values
pick = ui.picker(
simple_ticking,
key_column="Id",
label_column="Planet",
label="Text",
on_selection_change=set_value,
selected_key=value,
)
# Show current selection in a ui.text component
text = ui.text("Selection: " + str(value))
# Display picker and output in a flex column
return ui.flex(
pick,
text,
direction="column",
margin=10,
gap=10,
)
picker_table = picker()
```
resolves #18581 parent 96298f6 commit bfbf7b1
34 files changed
Lines changed: 1506 additions & 333 deletions
File tree
- __mocks__
- packages
- code-studio/src/styleguide
- components/src/spectrum/picker
- jsapi-components/src
- spectrum
- Picker
- jsapi-utils/src
- react-hooks/src
- utils/src
- tests/styleguide.spec.ts-snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1989 | 1989 | | |
1990 | 1990 | | |
1991 | 1991 | | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
1992 | 2001 | | |
1993 | 2002 | | |
1994 | 2003 | | |
| |||
2034 | 2043 | | |
2035 | 2044 | | |
2036 | 2045 | | |
| 2046 | + | |
2037 | 2047 | | |
2038 | 2048 | | |
2039 | 2049 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
| 1 | + | |
| 2 | + | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
8 | 16 | | |
9 | 17 | | |
10 | 18 | | |
| |||
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
17 | 31 | | |
18 | 32 | | |
19 | 33 | | |
| |||
24 | 38 | | |
25 | 39 | | |
26 | 40 | | |
27 | | - | |
| 41 | + | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
| |||
76 | 90 | | |
77 | 91 | | |
78 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
79 | 101 | | |
80 | 102 | | |
81 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
4 | 15 | | |
5 | 16 | | |
6 | 17 | | |
| 18 | + | |
7 | 19 | | |
8 | 20 | | |
9 | 21 | | |
| 22 | + | |
10 | 23 | | |
11 | | - | |
12 | 24 | | |
13 | | - | |
14 | | - | |
| 25 | + | |
| 26 | + | |
15 | 27 | | |
16 | 28 | | |
17 | 29 | | |
18 | 30 | | |
19 | 31 | | |
20 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
21 | 36 | | |
22 | 37 | | |
23 | 38 | | |
24 | 39 | | |
25 | 40 | | |
26 | 41 | | |
| 42 | + | |
| 43 | + | |
27 | 44 | | |
28 | 45 | | |
29 | 46 | | |
30 | 47 | | |
31 | 48 | | |
32 | 49 | | |
33 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
34 | 55 | | |
35 | 56 | | |
36 | 57 | | |
| |||
82 | 103 | | |
83 | 104 | | |
84 | 105 | | |
| 106 | + | |
85 | 107 | | |
| 108 | + | |
| 109 | + | |
86 | 110 | | |
87 | 111 | | |
88 | 112 | | |
| |||
99 | 123 | | |
100 | 124 | | |
101 | 125 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
119 | 158 | | |
120 | 159 | | |
121 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
122 | 209 | | |
123 | 210 | | |
124 | 211 | | |
125 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
126 | 216 | | |
127 | 217 | | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
135 | 224 | | |
136 | 225 | | |
137 | | - | |
138 | | - | |
| 226 | + | |
139 | 227 | | |
140 | 228 | | |
141 | 229 | | |
142 | 230 | | |
143 | 231 | | |
144 | 232 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
148 | 236 | | |
149 | 237 | | |
150 | 238 | | |
| |||
0 commit comments