-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Picker table support #382
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
Changes from 8 commits
6313bdf
8310594
2889589
56b1e27
6051fff
4ed93b2
4eae49d
3779429
43e5c7d
346f06a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,42 @@ | ||
| import React from 'react'; | ||
| import React, { ReactElement } from 'react'; | ||
| import { | ||
| Picker as DHPicker, | ||
| PickerProps as DHPickerProps, | ||
| } from '@deephaven/components'; | ||
| import { | ||
| Picker as DHPickerJSApi, | ||
| PickerProps as DHPickerJSApiProps, | ||
| } from '@deephaven/jsapi-components'; | ||
| import { isElementOfType, usePromiseFactory } from '@deephaven/react-hooks'; | ||
| import { SerializedPickerEventProps, usePickerProps } from './usePickerProps'; | ||
| import ObjectView, { ObjectViewProps } from './ObjectView'; | ||
| import { fetchReexportedTable } from './ElementUtils'; | ||
|
|
||
| type WrappedDHPickerJSApiProps = Omit<DHPickerJSApiProps, 'table'> & { | ||
| children: ReactElement<ObjectViewProps>; | ||
| }; | ||
|
|
||
| export type PickerProps = (DHPickerProps | WrappedDHPickerJSApiProps) & | ||
| SerializedPickerEventProps; | ||
|
|
||
| function Picker(props: DHPickerProps & SerializedPickerEventProps) { | ||
| function Picker({ children, ...props }: PickerProps) { | ||
| const pickerProps = usePickerProps(props); | ||
|
|
||
| const maybeExportedObject = isElementOfType(children, ObjectView) | ||
| ? children.props.object | ||
| : null; | ||
|
|
||
| const { data: table } = usePromiseFactory(fetchReexportedTable, [ | ||
| maybeExportedObject, | ||
| ]); | ||
|
bmingles marked this conversation as resolved.
|
||
|
|
||
| if (isElementOfType(children, ObjectView)) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd extract this logic to a boolean to make it clear and use it above as well, e.g. Something like that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to tweak this slightly to deal with the case where it is an ObjectView but not a Table |
||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| return table && <DHPickerJSApi {...pickerProps} table={table} />; | ||
| } | ||
|
|
||
| // eslint-disable-next-line react/jsx-props-no-spreading | ||
| return <DHPicker {...pickerProps} />; | ||
| return <DHPicker {...pickerProps}>{children}</DHPicker>; | ||
| } | ||
|
|
||
| export default Picker; | ||
Uh oh!
There was an error while loading. Please reload this page.