mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
* dbeaver/dbeaver-vscode#83 refactor: data grid * chore: try to fix build scripts * chore: commit artifacts * chore: update yarn.lock * fix: adjust grid auto-sizing * chore: fix prettier * chore: add documentation about typescript crashes * fix: cell menu * fix: grid inline editor styles * fix: cell menu styles * fix: cell items alignment * fix: data sync * feat: support reactive values in grid * chore: try to fix strange build bug * chore: restore original file name * fix: add specific to inline editor styles * fix: remove delete row shortcut (not working) * chore: enable common cache
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
/*
|
|
* CloudBeaver - Cloud Database Manager
|
|
* Copyright (C) 2020-2025 DBeaver Corp and others
|
|
*
|
|
* Licensed under the Apache License, Version 2.0.
|
|
* you may not use this file except in compliance with the License.
|
|
*/
|
|
|
|
import { use } from 'react';
|
|
import classes from './TextEditor.module.css';
|
|
import { DataGridCellContext } from '../DataGridCellContext.js';
|
|
import { useGridReactiveValue } from '../useGridReactiveValue.js';
|
|
|
|
function autoFocusAndSelect(input: HTMLInputElement | null) {
|
|
input?.focus();
|
|
input?.select();
|
|
}
|
|
|
|
export interface IProps {
|
|
rowIdx: number;
|
|
colIdx: number;
|
|
onClose: () => void;
|
|
}
|
|
|
|
export function TextEditor({ rowIdx, colIdx, onClose }: IProps) {
|
|
const cellContext = use(DataGridCellContext);
|
|
|
|
const value = useGridReactiveValue(cellContext?.cellText, rowIdx, colIdx) ?? '';
|
|
|
|
return (
|
|
<input
|
|
className={classes['editor']}
|
|
ref={autoFocusAndSelect}
|
|
value={value}
|
|
onChange={event => cellContext?.onCellChange?.(rowIdx, colIdx, event.target.value)}
|
|
onBlur={() => onClose()}
|
|
/>
|
|
);
|
|
}
|