Skip to content

Commit 405f42f

Browse files
authored
feat: DH-14538: Export InputEditor and added options (#1398)
- Exporting InputEditor from @deephaven/iris-grid - Added optional properties `className` and `placeholder` resolves #1397 Supporting DH-14538
1 parent 154ccfc commit 405f42f

3 files changed

Lines changed: 18 additions & 11 deletions

File tree

packages/iris-grid/src/sidebar/CustomColumnInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ function CustomColumnInput({
111111
<InputEditor
112112
editorSettings={{ language: 'deephavenDb' }}
113113
editorIndex={inputIndex}
114+
placeholder="Column Formula"
114115
value={formula}
115116
onContentChanged={handleFormulaEditorContentChanged}
116117
onTab={onTabInEditor}

packages/iris-grid/src/sidebar/InputEditor.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import classNames from 'classnames';
44
import './InputEditor.scss';
55

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

23-
export default class InputEditor extends Component<
24-
InputEditorProps,
25-
InputEditorState
26-
> {
25+
export class InputEditor extends Component<InputEditorProps, InputEditorState> {
2726
static defaultProps = {
2827
value: '',
2928
onContentChanged: (): void => undefined,
@@ -156,14 +155,18 @@ export default class InputEditor extends Component<
156155
}
157156

158157
render(): ReactElement {
159-
const { value, invalid } = this.props;
158+
const { className, invalid, placeholder = '', value } = this.props;
160159
const { isEditorFocused, isEditorEmpty } = this.state;
161160
return (
162161
<div
163-
className={classNames('input-editor-wrapper', {
164-
focused: isEditorFocused,
165-
invalid,
166-
})}
162+
className={classNames(
163+
'input-editor-wrapper',
164+
{
165+
focused: isEditorFocused,
166+
invalid,
167+
},
168+
className
169+
)}
167170
role="presentation"
168171
onClick={this.handleContainerClick}
169172
>
@@ -174,10 +177,12 @@ export default class InputEditor extends Component<
174177
}}
175178
data-testid="custom-column-formula"
176179
/>
177-
{isEditorEmpty && !value && (
178-
<div className="editor-placeholder text-muted">Column Formula</div>
180+
{isEditorEmpty && !value && placeholder.length > 0 && (
181+
<div className="editor-placeholder text-muted">{placeholder}</div>
179182
)}
180183
</div>
181184
);
182185
}
183186
}
187+
188+
export default InputEditor;

packages/iris-grid/src/sidebar/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ export type { FormattingRule as SidebarFormattingRule };
3131
export * from './aggregations';
3232
export * from './RollupRows';
3333
export * from './ChartBuilder';
34+
export * from './InputEditor';
3435
export * from './icons';

0 commit comments

Comments
 (0)