mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
chore: fix eslint in blocksuite (#9232)
This commit is contained in:
@@ -150,7 +150,7 @@ class TagManager {
|
||||
return this.ops.value;
|
||||
}
|
||||
|
||||
constructor(private ops: TagManagerOptions) {}
|
||||
constructor(private readonly ops: TagManagerOptions) {}
|
||||
|
||||
deleteTag(id: string) {
|
||||
this.ops.onChange(this.value.value.filter(item => item !== id));
|
||||
@@ -180,7 +180,7 @@ export class MultiTagSelect extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private _clickItemOption = (e: MouseEvent, id: string) => {
|
||||
private readonly _clickItemOption = (e: MouseEvent, id: string) => {
|
||||
e.stopPropagation();
|
||||
const option = this.options.value.find(v => v.id === id);
|
||||
if (!option) {
|
||||
@@ -235,11 +235,11 @@ export class MultiTagSelect extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private _onInput = (event: KeyboardEvent) => {
|
||||
private readonly _onInput = (event: KeyboardEvent) => {
|
||||
this.tagManager.text.value = (event.target as HTMLInputElement).value;
|
||||
};
|
||||
|
||||
private _onInputKeydown = (event: KeyboardEvent) => {
|
||||
private readonly _onInputKeydown = (event: KeyboardEvent) => {
|
||||
event.stopPropagation();
|
||||
const inputValue = this.text.value.trim();
|
||||
if (event.key === 'Backspace' && inputValue === '') {
|
||||
@@ -257,9 +257,9 @@ export class MultiTagSelect extends SignalWatcher(
|
||||
}
|
||||
};
|
||||
|
||||
private tagManager = new TagManager(this);
|
||||
private readonly tagManager = new TagManager(this);
|
||||
|
||||
private selectedTag$ = computed(() => {
|
||||
private readonly selectedTag$ = computed(() => {
|
||||
return this.tagManager.filteredOptions$.value[this.selectedIndex];
|
||||
});
|
||||
|
||||
|
||||
@@ -63,14 +63,14 @@ export class DataViewRenderer extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _view = createRef<{
|
||||
private readonly _view = createRef<{
|
||||
expose: DataViewInstance;
|
||||
}>();
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor config!: DataViewRendererConfig;
|
||||
|
||||
private currentViewId$ = computed(() => {
|
||||
private readonly currentViewId$ = computed(() => {
|
||||
return this.config.dataSource.viewManager.currentViewId$.value;
|
||||
});
|
||||
|
||||
@@ -218,7 +218,7 @@ declare global {
|
||||
}
|
||||
|
||||
export class DataView {
|
||||
private _ref = createRef<DataViewRenderer>();
|
||||
private readonly _ref = createRef<DataViewRenderer>();
|
||||
|
||||
get expose() {
|
||||
return this._ref.value?.view?.expose;
|
||||
|
||||
@@ -109,7 +109,7 @@ export class RecordField extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _cell = createRef<DataViewCellLifeCycle>();
|
||||
private readonly _cell = createRef<DataViewCellLifeCycle>();
|
||||
|
||||
_click = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -49,7 +49,7 @@ export class DetailSelection {
|
||||
}
|
||||
}
|
||||
|
||||
constructor(private viewEle: RecordDetail) {}
|
||||
constructor(private readonly viewEle: RecordDetail) {}
|
||||
|
||||
blur(selection: DetailViewSelection) {
|
||||
const container = this.getFocusCellContainer(selection);
|
||||
|
||||
@@ -21,7 +21,7 @@ export class NumberGroupView extends BaseGroup<NonNullable<unknown>, number> {
|
||||
}
|
||||
`;
|
||||
|
||||
private _click = () => {
|
||||
private readonly _click = () => {
|
||||
if (this.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class SelectGroupView extends BaseGroup<
|
||||
}
|
||||
`;
|
||||
|
||||
private _click = (e: MouseEvent) => {
|
||||
private readonly _click = (e: MouseEvent) => {
|
||||
if (this.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class StringGroupView extends BaseGroup<NonNullable<unknown>, string> {
|
||||
}
|
||||
`;
|
||||
|
||||
private _click = () => {
|
||||
private readonly _click = () => {
|
||||
if (this.readonly) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export class GroupTrait {
|
||||
return groupMap;
|
||||
});
|
||||
|
||||
private _groupsDataList$ = computed(() => {
|
||||
private readonly _groupsDataList$ = computed(() => {
|
||||
const groupMap = this.groupDataMap$.value;
|
||||
if (!groupMap) {
|
||||
return;
|
||||
@@ -143,9 +143,9 @@ export class GroupTrait {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private groupBy$: ReadonlySignal<GroupBy | undefined>,
|
||||
private readonly groupBy$: ReadonlySignal<GroupBy | undefined>,
|
||||
public view: SingleView,
|
||||
private ops: {
|
||||
private readonly ops: {
|
||||
groupBySet: (groupBy: GroupBy | undefined) => void;
|
||||
sortGroup: (keys: string[]) => string[];
|
||||
sortRow: (groupKey: string, rowIds: string[]) => string[];
|
||||
|
||||
@@ -50,9 +50,9 @@ export class DataType<
|
||||
> implements TypeDefinition
|
||||
{
|
||||
constructor(
|
||||
private name: Name,
|
||||
private readonly name: Name,
|
||||
_dataSchema: DataSchema,
|
||||
private valueSchema: ValueSchema
|
||||
private readonly valueSchema: ValueSchema
|
||||
) {}
|
||||
|
||||
instance(literal?: Zod.TypeOf<DataSchema>) {
|
||||
|
||||
@@ -14,8 +14,8 @@ export class MatcherCreator<Data, Type extends TypeInstance = TypeInstance> {
|
||||
|
||||
export class Matcher<Data, Type extends TypeInstance = TypeInstance> {
|
||||
constructor(
|
||||
private list: MatcherData<Data, Type>[],
|
||||
private _match: (type: Type, target: TypeInstance) => boolean = (
|
||||
private readonly list: MatcherData<Data, Type>[],
|
||||
private readonly _match: (type: Type, target: TypeInstance) => boolean = (
|
||||
type,
|
||||
target
|
||||
) => typeSystem.unify(target, type)
|
||||
|
||||
@@ -32,7 +32,7 @@ const getMap2 = <T>(
|
||||
};
|
||||
|
||||
export class TypeSystem {
|
||||
private _unify: Unify = (
|
||||
private readonly _unify: Unify = (
|
||||
ctx: TypeVarContext,
|
||||
left: TypeInstance | undefined,
|
||||
right: TypeInstance | undefined
|
||||
|
||||
@@ -34,7 +34,7 @@ export class SortManager {
|
||||
constructor(
|
||||
readonly sort$: ReadonlySignal<Sort | undefined>,
|
||||
readonly view: SingleView,
|
||||
private ops: {
|
||||
private readonly ops: {
|
||||
setSortList: (sortList: Sort) => void;
|
||||
}
|
||||
) {}
|
||||
|
||||
@@ -56,20 +56,20 @@ const defaultCoordinates: Coordinates = {
|
||||
};
|
||||
|
||||
export class DndContext {
|
||||
private dragMove = (coordinates: Coordinates) => {
|
||||
private readonly dragMove = (coordinates: Coordinates) => {
|
||||
this.activationCoordinates$.value = coordinates;
|
||||
this.autoScroll();
|
||||
};
|
||||
|
||||
private droppableNodes$ = signal<DroppableNodes>(new Map());
|
||||
private readonly droppableNodes$ = signal<DroppableNodes>(new Map());
|
||||
|
||||
private initialCoordinates$ = signal<Coordinates>();
|
||||
private readonly initialCoordinates$ = signal<Coordinates>();
|
||||
|
||||
private initScrollOffset$ = signal(defaultCoordinates);
|
||||
private readonly initScrollOffset$ = signal(defaultCoordinates);
|
||||
|
||||
private session$ = signal<DndSession>();
|
||||
private readonly session$ = signal<DndSession>();
|
||||
|
||||
private startSession = (
|
||||
private readonly startSession = (
|
||||
id: UniqueIdentifier,
|
||||
activeNode: HTMLElement,
|
||||
sessionCreator: DndSessionCreator
|
||||
@@ -96,7 +96,7 @@ export class DndContext {
|
||||
|
||||
activationCoordinates$ = signal<Coordinates>();
|
||||
|
||||
private translate$ = computed(() => {
|
||||
private readonly translate$ = computed(() => {
|
||||
const init = this.initialCoordinates$.value;
|
||||
const current = this.activationCoordinates$.value;
|
||||
if (!init || !current) {
|
||||
|
||||
@@ -192,8 +192,8 @@ export class MouseSession implements DndSession {
|
||||
|
||||
constructor(
|
||||
event: Event,
|
||||
private sessionProps: DndSessionProps,
|
||||
private props: MouseSensorProps
|
||||
private readonly sessionProps: DndSessionProps,
|
||||
private readonly props: MouseSensorProps
|
||||
) {
|
||||
this.initialCoordinates = getEventCoordinates(event) ?? defaultCoordinates;
|
||||
this.attach();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export class Listeners<T extends EventTarget> {
|
||||
private listeners: [
|
||||
private readonly listeners: [
|
||||
string,
|
||||
EventListenerOrEventListenerObject | null,
|
||||
AddEventListenerOptions | boolean | undefined,
|
||||
|
||||
@@ -139,9 +139,9 @@ export abstract class SingleViewBase<
|
||||
ViewData extends DataViewDataType = DataViewDataType,
|
||||
> implements SingleView
|
||||
{
|
||||
private searchString = signal('');
|
||||
private readonly searchString = signal('');
|
||||
|
||||
private traitMap = new Map<symbol, unknown>();
|
||||
private readonly traitMap = new Map<symbol, unknown>();
|
||||
|
||||
data$ = computed(() => {
|
||||
return this.dataSource.viewDataGet(this.id) as ViewData | undefined;
|
||||
|
||||
@@ -66,7 +66,7 @@ export class DateCellEditing extends BaseCellRenderer<number> {
|
||||
|
||||
private _prevPortalAbortController: AbortController | null = null;
|
||||
|
||||
private openDatePicker = () => {
|
||||
private readonly openDatePicker = () => {
|
||||
if (
|
||||
this._prevPortalAbortController &&
|
||||
!this._prevPortalAbortController.signal.aborted
|
||||
@@ -168,7 +168,7 @@ height: 46px;
|
||||
}
|
||||
};
|
||||
|
||||
private updateValue = () => {
|
||||
private readonly updateValue = () => {
|
||||
const tempValue = this.tempValue$.value;
|
||||
const currentValue = this.value;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ export class MultiSelectCellEditing extends BaseCellRenderer<
|
||||
string[],
|
||||
SelectPropertyData
|
||||
> {
|
||||
private popTagSelect = () => {
|
||||
private readonly popTagSelect = () => {
|
||||
const value = signal(this._value);
|
||||
this._disposables.add({
|
||||
dispose: popTagSelect(
|
||||
|
||||
@@ -95,7 +95,7 @@ export class NumberCellEditing extends BaseCellRenderer<
|
||||
}
|
||||
`;
|
||||
|
||||
private _getFormattedString = (value: number) => {
|
||||
private readonly _getFormattedString = (value: number) => {
|
||||
const enableNewFormatting =
|
||||
this.view.featureFlags$.value.enable_number_formatting;
|
||||
const decimals = this.property.data$.value.decimal ?? 0;
|
||||
@@ -106,7 +106,7 @@ export class NumberCellEditing extends BaseCellRenderer<
|
||||
: value.toString();
|
||||
};
|
||||
|
||||
private _keydown = (e: KeyboardEvent) => {
|
||||
private readonly _keydown = (e: KeyboardEvent) => {
|
||||
const ctrlKey = IS_MAC ? e.metaKey : e.ctrlKey;
|
||||
|
||||
if (e.key.toLowerCase() === 'z' && ctrlKey) {
|
||||
@@ -121,7 +121,7 @@ export class NumberCellEditing extends BaseCellRenderer<
|
||||
}
|
||||
};
|
||||
|
||||
private _setValue = (str: string = this._inputEle.value) => {
|
||||
private readonly _setValue = (str: string = this._inputEle.value) => {
|
||||
if (!str) {
|
||||
this.onChange(undefined);
|
||||
return;
|
||||
|
||||
@@ -28,7 +28,7 @@ export class SelectCellEditing extends BaseCellRenderer<
|
||||
string,
|
||||
SelectPropertyData
|
||||
> {
|
||||
private popTagSelect = () => {
|
||||
private readonly popTagSelect = () => {
|
||||
const value = signal(this._value);
|
||||
this._disposables.add({
|
||||
dispose: popTagSelect(
|
||||
|
||||
@@ -70,7 +70,7 @@ export class TextCellEditing extends BaseCellRenderer<string> {
|
||||
}
|
||||
`;
|
||||
|
||||
private _keydown = (e: KeyboardEvent) => {
|
||||
private readonly _keydown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && !e.isComposing) {
|
||||
this._setValue();
|
||||
setTimeout(() => {
|
||||
@@ -79,7 +79,7 @@ export class TextCellEditing extends BaseCellRenderer<string> {
|
||||
}
|
||||
};
|
||||
|
||||
private _setValue = (str: string = this._inputEle.value) => {
|
||||
private readonly _setValue = (str: string = this._inputEle.value) => {
|
||||
this._inputEle.value = `${this.value ?? ''}`;
|
||||
this.onChange(str);
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ export class MobileKanbanCard extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private clickCenterPeek = (e: MouseEvent) => {
|
||||
private readonly clickCenterPeek = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
this.dataViewEle.openDetailPanel({
|
||||
view: this.view,
|
||||
@@ -99,7 +99,7 @@ export class MobileKanbanCard extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private clickMore = (e: MouseEvent) => {
|
||||
private readonly clickMore = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
popCardMenu(
|
||||
popupTargetFromElement(e.currentTarget as HTMLElement),
|
||||
|
||||
@@ -51,7 +51,7 @@ export class MobileKanbanCell extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private _cell = createRef<DataViewCellLifeCycle>();
|
||||
private readonly _cell = createRef<DataViewCellLifeCycle>();
|
||||
|
||||
isEditing$ = computed(() => {
|
||||
const selection = this.kanban?.props.selection$.value;
|
||||
|
||||
@@ -60,15 +60,15 @@ export class MobileKanbanGroup extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private clickAddCard = () => {
|
||||
private readonly clickAddCard = () => {
|
||||
this.view.addCard('end', this.group.key);
|
||||
};
|
||||
|
||||
private clickAddCardInStart = () => {
|
||||
private readonly clickAddCardInStart = () => {
|
||||
this.view.addCard('start', this.group.key);
|
||||
};
|
||||
|
||||
private clickGroupOptions = (e: MouseEvent) => {
|
||||
private readonly clickGroupOptions = (e: MouseEvent) => {
|
||||
const ele = e.currentTarget as HTMLElement;
|
||||
popFilterableSimpleMenu(popupTargetFromElement(ele), [
|
||||
menu.group({
|
||||
|
||||
@@ -125,7 +125,7 @@ export class KanbanCard extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private clickEdit = (e: MouseEvent) => {
|
||||
private readonly clickEdit = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
const selection = this.getSelection();
|
||||
if (selection) {
|
||||
@@ -133,7 +133,7 @@ export class KanbanCard extends SignalWatcher(
|
||||
}
|
||||
};
|
||||
|
||||
private clickMore = (e: MouseEvent) => {
|
||||
private readonly clickMore = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
const selection = this.getSelection();
|
||||
const ele = e.currentTarget as HTMLElement;
|
||||
@@ -156,7 +156,7 @@ export class KanbanCard extends SignalWatcher(
|
||||
}
|
||||
};
|
||||
|
||||
private contextMenu = (e: MouseEvent) => {
|
||||
private readonly contextMenu = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
const selection = this.getSelection();
|
||||
|
||||
@@ -59,7 +59,7 @@ export class KanbanCell extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private _cell = createRef<DataViewCellLifeCycle>();
|
||||
private readonly _cell = createRef<DataViewCellLifeCycle>();
|
||||
|
||||
selectCurrentCell = (editing: boolean) => {
|
||||
const selectionView = this.closest(
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { KanbanViewSelectionWithType } from '../../types.js';
|
||||
import type { DataViewKanban } from '../kanban-view.js';
|
||||
|
||||
export class KanbanClipboardController implements ReactiveController {
|
||||
private _onCopy = (
|
||||
private readonly _onCopy = (
|
||||
_context: UIEventStateContext,
|
||||
_kanbanSelection: KanbanViewSelectionWithType
|
||||
) => {
|
||||
@@ -13,7 +13,7 @@ export class KanbanClipboardController implements ReactiveController {
|
||||
return true;
|
||||
};
|
||||
|
||||
private _onPaste = (_context: UIEventStateContext) => {
|
||||
private readonly _onPaste = (_context: UIEventStateContext) => {
|
||||
// todo
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -140,7 +140,7 @@ export class KanbanDragController implements ReactiveController {
|
||||
return scrollContainer;
|
||||
}
|
||||
|
||||
constructor(private host: DataViewKanban) {
|
||||
constructor(private readonly host: DataViewKanban) {
|
||||
this.host.addController(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export class KanbanHotkeysController implements ReactiveController {
|
||||
return !!this.host.selectionController.selection;
|
||||
}
|
||||
|
||||
constructor(private host: DataViewKanban) {
|
||||
constructor(private readonly host: DataViewKanban) {
|
||||
this.host.addController(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ export class KanbanSelectionController implements ReactiveController {
|
||||
return this.host.props.view;
|
||||
}
|
||||
|
||||
constructor(private host: DataViewKanban) {
|
||||
constructor(private readonly host: DataViewKanban) {
|
||||
this.host.addController(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ export class KanbanGroup extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private clickAddCard = () => {
|
||||
private readonly clickAddCard = () => {
|
||||
const id = this.view.addCard('end', this.group.key);
|
||||
requestAnimationFrame(() => {
|
||||
const kanban = this.closest('affine-data-view-kanban');
|
||||
@@ -114,7 +114,7 @@ export class KanbanGroup extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private clickAddCardInStart = () => {
|
||||
private readonly clickAddCardInStart = () => {
|
||||
const id = this.view.addCard('start', this.group.key);
|
||||
requestAnimationFrame(() => {
|
||||
const kanban = this.closest('affine-data-view-kanban');
|
||||
@@ -132,7 +132,7 @@ export class KanbanGroup extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private clickGroupOptions = (e: MouseEvent) => {
|
||||
private readonly clickGroupOptions = (e: MouseEvent) => {
|
||||
const ele = e.currentTarget as HTMLElement;
|
||||
popFilterableSimpleMenu(popupTargetFromElement(ele), [
|
||||
menu.action({
|
||||
|
||||
@@ -35,7 +35,7 @@ export class KanbanHeader extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private clickGroup = (e: MouseEvent) => {
|
||||
private readonly clickGroup = (e: MouseEvent) => {
|
||||
const groupTrait = this.view.traitGet(groupTraitKey);
|
||||
if (!groupTrait) {
|
||||
return;
|
||||
|
||||
@@ -100,7 +100,7 @@ export class DataViewKanban extends DataViewBase<
|
||||
> {
|
||||
static override styles = styles;
|
||||
|
||||
private dragController = new KanbanDragController(this);
|
||||
private readonly dragController = new KanbanDragController(this);
|
||||
|
||||
clipboardController = new KanbanClipboardController(this);
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export class MobileTableCell extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _cell = createRef<DataViewCellLifeCycle>();
|
||||
private readonly _cell = createRef<DataViewCellLifeCycle>();
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor column!: TableColumn;
|
||||
|
||||
@@ -53,7 +53,7 @@ export class MobileTableColumnHeader extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _clickColumn = () => {
|
||||
private readonly _clickColumn = () => {
|
||||
if (this.tableViewManager.readonly$.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export class MobileTableGroup extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private clickAddRow = () => {
|
||||
private readonly clickAddRow = () => {
|
||||
this.view.rowAdd('end', this.group?.key);
|
||||
requestAnimationFrame(() => {
|
||||
const selectionController = this.viewEle.selectionController;
|
||||
@@ -68,7 +68,7 @@ export class MobileTableGroup extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private clickAddRowInStart = () => {
|
||||
private readonly clickAddRowInStart = () => {
|
||||
this.view.rowAdd('start', this.group?.key);
|
||||
requestAnimationFrame(() => {
|
||||
const selectionController = this.viewEle.selectionController;
|
||||
@@ -86,7 +86,7 @@ export class MobileTableGroup extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private clickGroupOptions = (e: MouseEvent) => {
|
||||
private readonly clickGroupOptions = (e: MouseEvent) => {
|
||||
const group = this.group;
|
||||
if (!group) {
|
||||
return;
|
||||
@@ -111,7 +111,7 @@ export class MobileTableGroup extends SignalWatcher(
|
||||
]);
|
||||
};
|
||||
|
||||
private renderGroupHeader = () => {
|
||||
private readonly renderGroupHeader = () => {
|
||||
if (!this.group) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export class MobileTableHeader extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _onAddColumn = () => {
|
||||
private readonly _onAddColumn = () => {
|
||||
if (this.readonly) return;
|
||||
this.tableViewManager.propertyAdd('end');
|
||||
this.editLastColumnTitle();
|
||||
|
||||
@@ -45,7 +45,7 @@ export class MobileDataViewTable extends DataViewBase<
|
||||
}
|
||||
`;
|
||||
|
||||
private _addRow = (
|
||||
private readonly _addRow = (
|
||||
tableViewManager: TableSingleView,
|
||||
position: InsertToPosition | number
|
||||
) => {
|
||||
|
||||
@@ -43,7 +43,7 @@ export class DatabaseCellContainer extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _cell = createRef<DataViewCellLifeCycle>();
|
||||
private readonly _cell = createRef<DataViewCellLifeCycle>();
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor column!: TableColumn;
|
||||
|
||||
@@ -16,7 +16,7 @@ type JsonAreaData = string[][];
|
||||
const TEXT = 'text/plain';
|
||||
|
||||
export class TableClipboardController implements ReactiveController {
|
||||
private _onCopy = (
|
||||
private readonly _onCopy = (
|
||||
tableSelection: TableViewSelectionWithType,
|
||||
isCut = false
|
||||
) => {
|
||||
@@ -72,11 +72,11 @@ export class TableClipboardController implements ReactiveController {
|
||||
return true;
|
||||
};
|
||||
|
||||
private _onCut = (tableSelection: TableViewSelectionWithType) => {
|
||||
private readonly _onCut = (tableSelection: TableViewSelectionWithType) => {
|
||||
this._onCopy(tableSelection, true);
|
||||
};
|
||||
|
||||
private _onPaste = async (_context: UIEventStateContext) => {
|
||||
private readonly _onPaste = async (_context: UIEventStateContext) => {
|
||||
const event = _context.get('clipboardState').raw;
|
||||
event.stopPropagation();
|
||||
const view = this.host;
|
||||
|
||||
@@ -128,7 +128,7 @@ export class TableDragController implements ReactiveController {
|
||||
return position;
|
||||
};
|
||||
|
||||
constructor(private host: DataViewTable) {
|
||||
constructor(private readonly host: DataViewTable) {
|
||||
this.host.addController(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export class TableHotkeysController implements ReactiveController {
|
||||
return this.host.selectionController;
|
||||
}
|
||||
|
||||
constructor(private host: DataViewTable) {
|
||||
constructor(private readonly host: DataViewTable) {
|
||||
this.host.addController(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
export class TableSelectionController implements ReactiveController {
|
||||
private _tableViewSelection?: TableViewSelectionWithType;
|
||||
|
||||
private getFocusCellContainer = () => {
|
||||
private readonly getFocusCellContainer = () => {
|
||||
if (
|
||||
!this._tableViewSelection ||
|
||||
this._tableViewSelection.selectionType !== 'area'
|
||||
|
||||
@@ -67,7 +67,7 @@ export class TableGroup extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private clickAddRow = () => {
|
||||
private readonly clickAddRow = () => {
|
||||
this.view.rowAdd('end', this.group?.key);
|
||||
requestAnimationFrame(() => {
|
||||
const selectionController = this.viewEle.selectionController;
|
||||
@@ -85,7 +85,7 @@ export class TableGroup extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private clickAddRowInStart = () => {
|
||||
private readonly clickAddRowInStart = () => {
|
||||
this.view.rowAdd('start', this.group?.key);
|
||||
requestAnimationFrame(() => {
|
||||
const selectionController = this.viewEle.selectionController;
|
||||
@@ -103,7 +103,7 @@ export class TableGroup extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private clickGroupOptions = (e: MouseEvent) => {
|
||||
private readonly clickGroupOptions = (e: MouseEvent) => {
|
||||
const group = this.group;
|
||||
if (!group) {
|
||||
return;
|
||||
@@ -128,7 +128,7 @@ export class TableGroup extends SignalWatcher(
|
||||
]);
|
||||
};
|
||||
|
||||
private renderGroupHeader = () => {
|
||||
private readonly renderGroupHeader = () => {
|
||||
if (!this.group) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export class DatabaseColumnHeader extends SignalWatcher(
|
||||
) {
|
||||
static override styles = styles;
|
||||
|
||||
private _onAddColumn = (e: MouseEvent) => {
|
||||
private readonly _onAddColumn = (e: MouseEvent) => {
|
||||
if (this.readonly) return;
|
||||
this.tableViewManager.propertyAdd('end');
|
||||
const ele = e.currentTarget as HTMLElement;
|
||||
|
||||
@@ -63,14 +63,14 @@ export class DatabaseHeaderColumn extends SignalWatcher(
|
||||
}
|
||||
`;
|
||||
|
||||
private _clickColumn = () => {
|
||||
private readonly _clickColumn = () => {
|
||||
if (this.tableViewManager.readonly$.value) {
|
||||
return;
|
||||
}
|
||||
this.popMenu();
|
||||
};
|
||||
|
||||
private _clickTypeIcon = (event: MouseEvent) => {
|
||||
private readonly _clickTypeIcon = (event: MouseEvent) => {
|
||||
if (this.tableViewManager.readonly$.value) {
|
||||
return;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
|
||||
});
|
||||
};
|
||||
|
||||
private _contextMenu = (e: MouseEvent) => {
|
||||
private readonly _contextMenu = (e: MouseEvent) => {
|
||||
if (this.tableViewManager.readonly$.value) {
|
||||
return;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
|
||||
this.popMenu(e.currentTarget as HTMLElement);
|
||||
};
|
||||
|
||||
private _enterWidthDragBar = () => {
|
||||
private readonly _enterWidthDragBar = () => {
|
||||
if (this.tableViewManager.readonly$.value) {
|
||||
return;
|
||||
}
|
||||
@@ -115,13 +115,13 @@ export class DatabaseHeaderColumn extends SignalWatcher(
|
||||
this.drawWidthDragBar();
|
||||
};
|
||||
|
||||
private _leaveWidthDragBar = () => {
|
||||
private readonly _leaveWidthDragBar = () => {
|
||||
cancelAnimationFrame(this.drawWidthDragBarTask);
|
||||
this.drawWidthDragBarTask = 0;
|
||||
getVerticalIndicator().remove();
|
||||
};
|
||||
|
||||
private drawWidthDragBar = () => {
|
||||
private readonly drawWidthDragBar = () => {
|
||||
const rect = getTableGroupRect(this);
|
||||
if (!rect) {
|
||||
return;
|
||||
@@ -136,7 +136,7 @@ export class DatabaseHeaderColumn extends SignalWatcher(
|
||||
|
||||
private drawWidthDragBarTask = 0;
|
||||
|
||||
private widthDragBar = createRef();
|
||||
private readonly widthDragBar = createRef();
|
||||
|
||||
editTitle = () => {
|
||||
this._clickColumn();
|
||||
|
||||
@@ -87,14 +87,14 @@ export class DatabaseNumberFormatBar extends WithDisposable(LitElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _decrementDecimalPlaces = () => {
|
||||
private readonly _decrementDecimalPlaces = () => {
|
||||
this.column.dataUpdate(data => ({
|
||||
decimal: Math.max(((data.decimal as number) ?? 0) - 1, 0),
|
||||
}));
|
||||
this.requestUpdate();
|
||||
};
|
||||
|
||||
private _incrementDecimalPlaces = () => {
|
||||
private readonly _incrementDecimalPlaces = () => {
|
||||
this.column.dataUpdate(data => ({
|
||||
decimal: Math.min(((data.decimal as number) ?? 0) + 1, 8),
|
||||
}));
|
||||
|
||||
@@ -114,7 +114,7 @@ export class TableRow extends SignalWatcher(WithDisposable(ShadowlessElement)) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _clickDragHandler = () => {
|
||||
private readonly _clickDragHandler = () => {
|
||||
if (this.view.readonly$.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
|
||||
return result;
|
||||
});
|
||||
|
||||
private computedColumns$ = computed(() => {
|
||||
private readonly computedColumns$ = computed(() => {
|
||||
return this.propertiesWithoutFilter$.value.map(id => {
|
||||
const column = this.propertyGet(id);
|
||||
return {
|
||||
@@ -51,19 +51,19 @@ export class TableSingleView extends SingleViewBase<TableViewData> {
|
||||
});
|
||||
});
|
||||
|
||||
private filter$ = computed(() => {
|
||||
private readonly filter$ = computed(() => {
|
||||
return this.data$.value?.filter ?? emptyFilterGroup;
|
||||
});
|
||||
|
||||
private groupBy$ = computed(() => {
|
||||
private readonly groupBy$ = computed(() => {
|
||||
return this.data$.value?.groupBy;
|
||||
});
|
||||
|
||||
private sortList$ = computed(() => {
|
||||
private readonly sortList$ = computed(() => {
|
||||
return this.data$.value?.sort;
|
||||
});
|
||||
|
||||
private sortManager = this.traitSet(
|
||||
private readonly sortManager = this.traitSet(
|
||||
sortTraitKey,
|
||||
new SortManager(this.sortList$, this, {
|
||||
setSortList: sortList => {
|
||||
@@ -385,7 +385,7 @@ export class TableColumn extends PropertyBase {
|
||||
}
|
||||
|
||||
constructor(
|
||||
private tableView: TableSingleView,
|
||||
private readonly tableView: TableSingleView,
|
||||
columnId: string
|
||||
) {
|
||||
super(tableView as SingleView, columnId);
|
||||
|
||||
@@ -82,13 +82,13 @@ export class FilterConditionView extends SignalWatcher(ShadowlessElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private onClickButton = (evt: Event) => {
|
||||
private readonly onClickButton = (evt: Event) => {
|
||||
this.popConditionEdit(
|
||||
popupTargetFromElement(evt.currentTarget as HTMLElement)
|
||||
);
|
||||
};
|
||||
|
||||
private popConditionEdit = (target: PopupTarget) => {
|
||||
private readonly popConditionEdit = (target: PopupTarget) => {
|
||||
const type = this.leftVar$.value?.type;
|
||||
if (!type) {
|
||||
return;
|
||||
|
||||
@@ -184,7 +184,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _addNew = (e: MouseEvent) => {
|
||||
private readonly _addNew = (e: MouseEvent) => {
|
||||
if (this.isMaxDepth) {
|
||||
this.onChange({
|
||||
...this.filterGroup.value,
|
||||
@@ -202,7 +202,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private _selectOp = (event: MouseEvent) => {
|
||||
private readonly _selectOp = (event: MouseEvent) => {
|
||||
popFilterableSimpleMenu(
|
||||
popupTargetFromElement(event.currentTarget as HTMLElement),
|
||||
[
|
||||
@@ -228,7 +228,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
|
||||
);
|
||||
};
|
||||
|
||||
private _setFilter = (index: number, filter: Filter) => {
|
||||
private readonly _setFilter = (index: number, filter: Filter) => {
|
||||
this.onChange({
|
||||
...this.filterGroup.value,
|
||||
conditions: this.filterGroup.value.conditions.map((v, i) =>
|
||||
@@ -237,7 +237,7 @@ export class FilterGroupView extends SignalWatcher(ShadowlessElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private opMap = {
|
||||
private readonly opMap = {
|
||||
and: 'And',
|
||||
or: 'Or',
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ export class FilterBar extends SignalWatcher(ShadowlessElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _setFilter = (index: number, filter: Filter) => {
|
||||
private readonly _setFilter = (index: number, filter: Filter) => {
|
||||
this.onChange({
|
||||
...this.filterGroup.value,
|
||||
conditions: this.filterGroup.value.conditions.map((v, i) =>
|
||||
@@ -86,7 +86,7 @@ export class FilterBar extends SignalWatcher(ShadowlessElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private addFilter = (e: MouseEvent) => {
|
||||
private readonly addFilter = (e: MouseEvent) => {
|
||||
const element = popupTargetFromElement(e.target as HTMLElement);
|
||||
popCreateFilter(element, {
|
||||
vars: this.vars,
|
||||
@@ -103,7 +103,7 @@ export class FilterBar extends SignalWatcher(ShadowlessElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private expandGroup = (position: PopupTarget, i: number) => {
|
||||
private readonly expandGroup = (position: PopupTarget, i: number) => {
|
||||
if (this.filterGroup.value.conditions[i]?.type !== 'group') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ export class FilterRootView extends SignalWatcher(ShadowlessElement) {
|
||||
}
|
||||
`;
|
||||
|
||||
private _setFilter = (index: number, filter: Filter) => {
|
||||
private readonly _setFilter = (index: number, filter: Filter) => {
|
||||
this.onChange({
|
||||
...this.filterGroup.value,
|
||||
conditions: this.filterGroup.value.conditions.map((v, i) =>
|
||||
@@ -167,7 +167,7 @@ export class FilterRootView extends SignalWatcher(ShadowlessElement) {
|
||||
});
|
||||
};
|
||||
|
||||
private expandGroup = (position: PopupTarget, i: number) => {
|
||||
private readonly expandGroup = (position: PopupTarget, i: number) => {
|
||||
if (this.filterGroup.value.conditions[i]?.type !== 'group') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ export class DataViewHeaderToolsSearch extends WidgetBase<
|
||||
> {
|
||||
static override styles = styles;
|
||||
|
||||
private _clearSearch = () => {
|
||||
private readonly _clearSearch = () => {
|
||||
this._searchInput.value = '';
|
||||
this.view.setSearch('');
|
||||
this.preventBlur = true;
|
||||
@@ -102,25 +102,25 @@ export class DataViewHeaderToolsSearch extends WidgetBase<
|
||||
});
|
||||
};
|
||||
|
||||
private _clickSearch = (e: MouseEvent) => {
|
||||
private readonly _clickSearch = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
this.showSearch = true;
|
||||
};
|
||||
|
||||
private _onSearch = (event: InputEvent) => {
|
||||
private readonly _onSearch = (event: InputEvent) => {
|
||||
const el = event.target as HTMLInputElement;
|
||||
const inputValue = el.value.trim();
|
||||
this.view.setSearch(inputValue);
|
||||
};
|
||||
|
||||
private _onSearchBlur = () => {
|
||||
private readonly _onSearchBlur = () => {
|
||||
if (this._searchInput.value || this.preventBlur) {
|
||||
return;
|
||||
}
|
||||
this.showSearch = false;
|
||||
};
|
||||
|
||||
private _onSearchKeydown = (event: KeyboardEvent) => {
|
||||
private readonly _onSearchKeydown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') {
|
||||
if (this._searchInput.value) {
|
||||
this._searchInput.value = '';
|
||||
|
||||
@@ -19,7 +19,7 @@ const styles = css`
|
||||
export class DataViewHeaderToolsAddRow extends WidgetBase {
|
||||
static override styles = styles;
|
||||
|
||||
private _onAddNewRecord = () => {
|
||||
private readonly _onAddNewRecord = () => {
|
||||
if (this.readonly) return;
|
||||
this.viewMethods.addRow?.('start');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user