-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui.combo_box ## Testing ```python from deephaven import ui @ui.component def ui_combo_box(): value, set_value = ui.use_state("") combo = ui.combo_box( "Text 1", "Text 2", "Text 3", label="Text", on_selection_change=set_value, selected_key=value, ) text = ui.text("Selection: " + str(value)) return combo, text my_combo_box = ui_combo_box() ``` ```python import deephaven.ui as ui from deephaven import time_table import datetime # Ticking table with initial row count of 200 that adds a row every second initial_row_count = 200 _table = time_table( "PT1S", start_time=datetime.datetime.now() - datetime.timedelta(seconds=initial_row_count), ).update( [ "Id=new Integer(i)", "Display=new String(`Display `+i)", ] ) @ui.component def ui_combo_box_item_table_source(table): value, set_value = ui.use_state("") combo = ui.combo_box( ui.item_table_source(table, key_column="Id", label_column="Display"), label="Text", on_change=set_value, selected_key=value, ) text = ui.text(f"Selection: {value}") return combo, text my_combo_box_item_table_source = ui_combo_box_item_table_source(_table) ``` resolves #201 --------- Co-authored-by: Mike Bender <mikebender@deephaven.io>
- Loading branch information
Showing
11 changed files
with
178 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useSelector } from 'react-redux'; | ||
import { | ||
ComboBox as DHComboBox, | ||
ComboBoxProps as DHComboBoxProps, | ||
} from '@deephaven/components'; | ||
import { | ||
ComboBox as DHComboBoxJSApi, | ||
ComboBoxProps as DHComboBoxJSApiProps, | ||
} from '@deephaven/jsapi-components'; | ||
import { isElementOfType } from '@deephaven/react-hooks'; | ||
import { getSettings, RootState } from '@deephaven/redux'; | ||
import { | ||
SerializedPickerProps, | ||
usePickerProps, | ||
WrappedDHPickerJSApiProps, | ||
} from './hooks/usePickerProps'; | ||
import ObjectView from './ObjectView'; | ||
import { useReExportedTable } from './hooks/useReExportedTable'; | ||
|
||
export function ComboBox( | ||
props: SerializedPickerProps< | ||
DHComboBoxProps | WrappedDHPickerJSApiProps<DHComboBoxJSApiProps> | ||
> | ||
): JSX.Element | null { | ||
const settings = useSelector(getSettings<RootState>); | ||
const { children, ...pickerProps } = usePickerProps(props); | ||
|
||
const isObjectView = isElementOfType(children, ObjectView); | ||
const table = useReExportedTable(children); | ||
|
||
if (isObjectView) { | ||
return ( | ||
table && ( | ||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
<DHComboBoxJSApi {...pickerProps} table={table} settings={settings} /> | ||
) | ||
); | ||
} | ||
|
||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return <DHComboBox {...pickerProps}>{children}</DHComboBox>; | ||
} | ||
|
||
export default ComboBox; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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