From 695a757e1d5d3469a9871b0760c9dedeb073a489 Mon Sep 17 00:00:00 2001 From: bobzel Date: Fri, 4 Oct 2024 21:45:42 -0400 Subject: from last --- src/client/views/EditableView.tsx | 57 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'src/client/views/EditableView.tsx') diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx index 9722b2d4b..612ecee62 100644 --- a/src/client/views/EditableView.tsx +++ b/src/client/views/EditableView.tsx @@ -7,7 +7,6 @@ import { DocumentIconContainer } from './nodes/DocumentIcon'; import { FieldView, FieldViewProps } from './nodes/FieldView'; import { ObservableReactComponent } from './ObservableReactComponent'; import { OverlayView } from './OverlayView'; -import { Padding } from 'browndash-components'; import { SchemaFieldType } from './collections/collectionSchema/SchemaColumnHeader'; export interface EditableProps { @@ -90,7 +89,7 @@ export class EditableView extends ObservableReactComponent { this._overlayDisposer?.(); this._overlayDisposer = OverlayView.Instance.addElement(, { x: 0, y: 0 }); this._props.highlightCells?.(this._props.GetValue() ?? ''); - } + } }); } else { this._overlayDisposer?.(); @@ -200,7 +199,7 @@ export class EditableView extends ObservableReactComponent { } } }; - + @action finalizeEdit(value: string, shiftDown: boolean, lostFocus: boolean, enterKey: boolean) { if (this._props.SetValue(value, shiftDown, enterKey)) { @@ -235,7 +234,7 @@ export class EditableView extends ObservableReactComponent { setIsEditing = (value: boolean) => { this._editing = value; return this._editing; - } + }; renderEditor() { return this._props.autosuggestProps ? ( @@ -254,11 +253,11 @@ export class EditableView extends ObservableReactComponent { onChange: this._props.autosuggestProps.onChange, }} /> - ) : ( this._props.oneLine !== false && this._props.GetValue()?.toString().indexOf('\n') === -1 ? ( + ) : this._props.oneLine !== false && this._props.GetValue()?.toString().indexOf('\n') === -1 ? ( { this._inputref = r; }} // prettier-ignore - style={{ display: this._props.display, overflow: 'auto', fontSize: this._props.fontSize, minWidth: 20, background: this._props.background}} + style={{ display: this._props.display, overflow: 'auto', fontSize: this._props.fontSize, minWidth: 20, background: this._props.background }} placeholder={this._props.placeholder} onBlur={e => this.finalizeEdit(e.currentTarget.value, false, true, false)} defaultValue={this._props.GetValue()} @@ -284,39 +283,41 @@ export class EditableView extends ObservableReactComponent { onClick={this.stopPropagation} onPointerUp={this.stopPropagation} /> - )); + ); } staticDisplay = () => { let toDisplay; const gval = this._props.GetValue()?.replace(/\n/g, '\\r\\n'); - if (this._props.schemaFieldType === SchemaFieldType.Header){ - toDisplay = + if (this._props.schemaFieldType === SchemaFieldType.Header) { + toDisplay = ( + + ); } else { - toDisplay = ( - { - // eslint-disable-next-line react/jsx-props-no-spreading - this._props.fieldContents ? : this.props.contents ? this._props.contents?.valueOf() : '' as any - } - ) + toDisplay = ( + + {this._props.fieldContents ? : (this.props.contents ?? '')} + + ); } return toDisplay; - } + }; render() { const gval = this._props.GetValue()?.replace(/\n/g, '\\r\\n'); - if ((this._editing && gval !== undefined)) { + if (this._editing && gval !== undefined) { return this._props.sizeToContent ? (
{this.renderEditor()}
-- cgit v1.2.3-70-g09d2