Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add python picker #311

Merged
merged 8 commits into from
Feb 27, 2024
Merged

Conversation

jnumainville
Copy link
Collaborator

@jnumainville jnumainville commented Feb 23, 2024

Fixes #294
Creates python side of picker component along with section and items.

Props that are not currently supported:
items - we don't support passing in a callback as a child and we support passing in lists in children, so this will not be supported
validate - is a callback we don't support
errorMessage - specifically a callback
onLoadMore - irrelevant due to supporting a table source

@jnumainville jnumainville marked this pull request as ready for review February 26, 2024 15:50
@mofojed
Copy link
Member

mofojed commented Feb 26, 2024

We can totally wire up the onOpenChange, onFocusChange, onLoadMore callbacks. Note the onLoadMore we should have a note that it's irrelevant when using a table as a data source, but no technical reasons why we can't wire these up.

@dsmmcken
Copy link
Contributor

I would just skip onloadmore, not worth it, table source is strictly better.

@jnumainville
Copy link
Collaborator Author

jnumainville commented Feb 26, 2024

Ok, I wasn't sure of what I should list here in terms of if they must be supported now or not but I removed onOpenChange and onFocusChange as they will be supported.

@@ -47,3 +47,6 @@
TransformedData = Any
StringSortDirection = Literal["ASC", "DESC"]
TableSortDirection = Union[StringSortDirection, SortDirection]
# Stringable is a type that is naturally convertible to a string
Stringable = Union[str, int, float, bool]
Key = Any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can be a little more specific here. In the React typings, the keys allowed are: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/eaba7f4fb1a43d69a4e06084e530db36da0b63cd/types/react/index.d.ts#L233
Key could just be the same as Stringable and we should be fine (str, number, bool types). @bmingles also has a comment about how boolean is supported as a key on his PR.
We certainly do not want to allow non-serializable objects to be passed in as the key, so Any is not really appropriate.

Copy link
Contributor

@bmingles bmingles Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should clarify that React's Key type is restricted to number | string only. Spectrum's Picker is just incorrectly declaring that as the type for selection keys.

For this particular case, we should be able to use Stringable so that we get support for bool included, but there are likely other cases where the Key type would actually be correct, so the type may still be useful. In such case it should probably be defined as Key = Union[str, int, float]

@bmingles bmingles merged commit 05d1c4a into deephaven:main Feb 27, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ui.picker implementation in Python passing props through
4 participants