feat: Picker table support#382
Merged
bmingles merged 10 commits intodeephaven:mainfrom Apr 3, 2024
Merged
Conversation
3c86c7d to
23813db
Compare
1f098e7 to
6051fff
Compare
bmingles
added a commit
to deephaven/web-client-ui
that referenced
this pull request
Mar 27, 2024
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 #1858
mofojed
requested changes
Apr 3, 2024
| maybeExportedObject, | ||
| ]); | ||
|
|
||
| if (isElementOfType(children, ObjectView)) { |
Member
There was a problem hiding this comment.
I'd extract this logic to a boolean to make it clear and use it above as well, e.g.
const isTableSource = isElementOfType(children, ObjectView) && children.props.object.type === 'Table';`
const maybeExportedObject = isTableSource ? ... : ...
Something like that.
Contributor
Author
There was a problem hiding this comment.
I had to tweak this slightly to deal with the case where it is an ObjectView but not a Table
mofojed
approved these changes
Apr 3, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #293