* Add inplace date input component * Add inplace phone input component * Add inplace double text input component * Add inplace chip input component * Remove useless styled component * Reduce code through props destructuring
26 lines
789 B
TypeScript
26 lines
789 B
TypeScript
import { ReactElement } from 'react';
|
|
|
|
import { InplaceInput } from '../inplace-input/InplaceInput';
|
|
|
|
import { useIsSoftFocusOnCurrentCell } from './hooks/useIsSoftFocusOnCurrentCell';
|
|
import { useSetSoftFocusOnCurrentCell } from './hooks/useSetSoftFocusOnCurrentCell';
|
|
|
|
type OwnProps = {
|
|
editModeContent: ReactElement;
|
|
nonEditModeContent: ReactElement;
|
|
editModeHorizontalAlign?: 'left' | 'right';
|
|
editModeVerticalPosition?: 'over' | 'below';
|
|
};
|
|
|
|
export function EditableCell(props: OwnProps) {
|
|
const setSoftFocusOnCurrentCell = useSetSoftFocusOnCurrentCell();
|
|
const hasSoftFocus = useIsSoftFocusOnCurrentCell();
|
|
return (
|
|
<InplaceInput
|
|
{...props}
|
|
setSoftFocusOnCurrentInplaceInput={setSoftFocusOnCurrentCell}
|
|
hasSoftFocus={!!hasSoftFocus}
|
|
/>
|
|
);
|
|
}
|