aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/EditableView.tsx
diff options
context:
space:
mode:
authorNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-10-09 17:06:59 -0400
committerNathan-SR <144961007+Nathan-SR@users.noreply.github.com>2024-10-09 17:06:59 -0400
commit36735ff00a55ae587af5f69eef495533a1f35393 (patch)
tree9df8f19bdc1fd9137d024afb32603f02562aa70e /src/client/views/EditableView.tsx
parent6ae5bd63d5355a03dba099a149532e7c6b1fd74a (diff)
parent1b038112b37c02d81431bc7ff622b25bb42a0858 (diff)
Merge branch 'nathan-starter' of https://github.com/brown-dash/Dash-Web into nathan-starter
Diffstat (limited to 'src/client/views/EditableView.tsx')
-rw-r--r--src/client/views/EditableView.tsx40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 9974fc63b..898a98c98 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 {
@@ -91,7 +90,7 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
this._overlayDisposer?.();
this._overlayDisposer = OverlayView.Instance.addElement(<DocumentIconContainer />, { x: 0, y: 0 });
this._props.highlightCells?.(this._props.GetValue() ?? '');
- }
+ }
});
} else {
this._overlayDisposer?.();
@@ -201,7 +200,7 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
}
}
};
-
+
@action
finalizeEdit(value: string, shiftDown: boolean, lostFocus: boolean, enterKey: boolean) {
if (this._props.SetValue(value, shiftDown, enterKey)) {
@@ -236,12 +235,11 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
setIsEditing = (value: boolean) => {
this._editing = value;
return this._editing;
- }
+ };
renderEditor() {
return this._props.autosuggestProps ? (
<Autosuggest
- // eslint-disable-next-line react/jsx-props-no-spreading
{...this._props.autosuggestProps.autosuggestProps}
inputProps={{
className: 'editableView-input',
@@ -255,11 +253,11 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
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 ? (
<input
- className="editableView-input"
+ className="editableView-input"
ref={r => { 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()}
@@ -285,7 +283,7 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
onClick={this.stopPropagation}
onPointerUp={this.stopPropagation}
/>
- ));
+ );
}
staticDisplay = () => {
@@ -300,24 +298,24 @@ export class EditableView extends ObservableReactComponent<EditableProps> {
// eslint-disable-next-line jsx-a11y/no-autofocus
/>
} else {
- toDisplay = (<span className='editableView-static'
- style={{
- fontStyle: this._props.fontStyle,
- fontSize: this._props.fontSize
- }}>
- {
- // eslint-disable-next-line react/jsx-props-no-spreading
- this._props.fieldContents ? <FieldView {...this._props.fieldContents} /> : this.props.contents ? this._props.contents?.valueOf() : '' as any
- }
- </span>)
+ toDisplay = (
+ <span
+ className="editableView-static"
+ style={{
+ fontStyle: this._props.fontStyle,
+ fontSize: this._props.fontSize,
+ }}>
+ {this._props.fieldContents ? <FieldView {...this._props.fieldContents} /> : (this.props.contents ?? '')}
+ </span>
+ );
}
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 ? (
<div style={{ display: 'grid', minWidth: 100 }}>
<div style={{ display: 'inline-block', position: 'relative', height: 0, width: '100%', overflow: 'hidden' }}>{this.renderEditor()}</div>