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: DH-14538: Export InputEditor and added options #1398

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/iris-grid/src/sidebar/CustomColumnInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ function CustomColumnInput({
<InputEditor
editorSettings={{ language: 'deephavenDb' }}
editorIndex={inputIndex}
placeholder="Column Formula"
value={formula}
onContentChanged={handleFormulaEditorContentChanged}
onTab={onTabInEditor}
Expand Down
27 changes: 16 additions & 11 deletions packages/iris-grid/src/sidebar/InputEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import classNames from 'classnames';
import './InputEditor.scss';

interface InputEditorProps {
className?: string;
placeholder?: string;
value: string;
onContentChanged: (value?: string) => void;
editorSettings: Partial<monaco.editor.IStandaloneEditorConstructionOptions>;
Expand All @@ -20,10 +22,7 @@ interface InputEditorState {
* A monaco editor that looks like an general input
*/

export default class InputEditor extends Component<
InputEditorProps,
InputEditorState
> {
export class InputEditor extends Component<InputEditorProps, InputEditorState> {
static defaultProps = {
value: '',
onContentChanged: (): void => undefined,
Expand Down Expand Up @@ -156,14 +155,18 @@ export default class InputEditor extends Component<
}

render(): ReactElement {
const { value, invalid } = this.props;
const { className, invalid, placeholder = '', value } = this.props;
const { isEditorFocused, isEditorEmpty } = this.state;
return (
<div
className={classNames('input-editor-wrapper', {
focused: isEditorFocused,
invalid,
})}
className={classNames(
'input-editor-wrapper',
{
focused: isEditorFocused,
invalid,
},
className
)}
role="presentation"
onClick={this.handleContainerClick}
>
Expand All @@ -174,10 +177,12 @@ export default class InputEditor extends Component<
}}
data-testid="custom-column-formula"
/>
{isEditorEmpty && !value && (
<div className="editor-placeholder text-muted">Column Formula</div>
{isEditorEmpty && !value && placeholder.length > 0 && (
<div className="editor-placeholder text-muted">{placeholder}</div>
)}
</div>
);
}
}

export default InputEditor;
1 change: 1 addition & 0 deletions packages/iris-grid/src/sidebar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ export type { FormattingRule as SidebarFormattingRule };
export * from './aggregations';
export * from './RollupRows';
export * from './ChartBuilder';
export * from './InputEditor';
export * from './icons';