Skip to content

feat: add undefined type option#1026

Merged
wusteven815 merged 16 commits into
deephaven:mainfrom
wusteven815:549-python-undefined-v2
Dec 16, 2024
Merged

feat: add undefined type option#1026
wusteven815 merged 16 commits into
deephaven:mainfrom
wusteven815:549-python-undefined-v2

Conversation

@wusteven815
Copy link
Copy Markdown
Contributor

@wusteven815 wusteven815 commented Nov 18, 2024

  • Closes Python - Differentiate null from undefined #549
  • Add a new Undefined object for nullable props
    • Nullable props can be declared with _nullable_props passed to component_element/BaseElement
    • For these props, None will be translated to null and Undefined will not exist in the props object

@wusteven815 wusteven815 self-assigned this Nov 18, 2024
@wusteven815
Copy link
Copy Markdown
Contributor Author

wusteven815 commented Nov 18, 2024

Example:

from deephaven import ui


@ui.component
def nullish_calendar():
    return ui.flex(
        ui.calendar(value=ui.types.Undefined),
        ui.calendar(value=None),
    )


calendar_test = nullish_calendar()
  • For Undefined, the calendar can still be edited, while for None, the calendar can not be edited

@wusteven815 wusteven815 marked this pull request as ready for review November 18, 2024 23:09
Comment thread plugins/ui/src/deephaven/ui/components/date_field.py Outdated
Comment thread plugins/ui/src/deephaven/ui/_internal/utils.py Outdated
Comment thread plugins/ui/src/deephaven/ui/_internal/utils.py Outdated
Comment thread plugins/ui/src/deephaven/ui/elements/BaseElement.py
Comment thread plugins/ui/src/deephaven/ui/types/types.py Outdated
Comment thread plugins/ui/src/deephaven/ui/components/calendar.py Outdated
Comment thread plugins/ui/src/deephaven/ui/components/combo_box.py
Comment thread plugins/ui/src/deephaven/ui/_internal/utils.py
Copy link
Copy Markdown
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

Code changes look good to me. I like how this approach simplifies things. Left 1 comment to update comment block with new _nullable_props arg. Also would be good to put something about this in the UI docs.

Copy link
Copy Markdown
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

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

@wusteven815 as @bmingles suggested let's add a couple docs for this as well.

  • An example to picker.md showing the use of None vs Undefined
  • A subsection in architecture.md components, named "Props" where we detail how we're mapping React JS props to Python args in general (children are mapped to positional args, other props are mapped to keyword args, along with a couple small examples), then a subsection within that for "Handling null vs. undefined" and detail how the issue (JS has null/undefined, some components require that differentiation, Python only has None), and how we're addressing it.

Comment thread plugins/ui/docs/components/picker.md Outdated
Comment thread plugins/ui/docs/components/picker.md Outdated
Copy link
Copy Markdown
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

Suggested changes for controlled vs uncontrolled description / examples.

Co-authored-by: Brian Ingles <github@emeraldwalk.com>
Comment thread plugins/ui/docs/components/picker.md Outdated
Comment thread plugins/ui/docs/components/picker.md
Comment thread plugins/ui/docs/components/picker.md Outdated
@wusteven815 wusteven815 dismissed stale reviews from mofojed and bmingles December 9, 2024 18:54

Added

mofojed
mofojed previously approved these changes Dec 10, 2024
bmingles
bmingles previously approved these changes Dec 10, 2024
Copy link
Copy Markdown
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread plugins/ui/docs/architecture.md Outdated
Comment thread plugins/ui/docs/architecture.md Outdated
Comment thread plugins/ui/docs/components/picker.md Outdated
Co-authored-by: margaretkennedy <82049573+margaretkennedy@users.noreply.github.com>
@wusteven815 wusteven815 dismissed stale reviews from bmingles and mofojed via c789ba2 December 12, 2024 16:25
Comment thread plugins/ui/docs/architecture.md Outdated
@wusteven815 wusteven815 merged commit ef7e741 into deephaven:main Dec 16, 2024
@wusteven815 wusteven815 deleted the 549-python-undefined-v2 branch December 19, 2024 16:36
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.

Python - Differentiate null from undefined

5 participants