|
|
|
|
@ -16,6 +16,7 @@ import type { TreeGridSelectionMode } from './types';
|
|
|
|
|
|
|
|
|
|
import { treeGridMorfo } from '../../../morfo/components/tree-grid';
|
|
|
|
|
import type { SomaRuntime, SomaRuntimePart } from '../../runtime.svelte';
|
|
|
|
|
import type { TimerHandle } from '$timer';
|
|
|
|
|
|
|
|
|
|
const attrs = createAttrs(treeGridMorfo);
|
|
|
|
|
|
|
|
|
|
@ -59,7 +60,7 @@ export class TreeGridProvider {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private typeaheadBuffer = '';
|
|
|
|
|
private typeaheadTimer: ReturnType<typeof setTimeout> | null = null;
|
|
|
|
|
private typeaheadTimer: TimerHandle | null = null;
|
|
|
|
|
private anchor: string | null = null;
|
|
|
|
|
|
|
|
|
|
private constructor(opts: TreeGridOpts) {
|
|
|
|
|
@ -73,9 +74,7 @@ export class TreeGridProvider {
|
|
|
|
|
context: TreeGridProvider.ctx
|
|
|
|
|
});
|
|
|
|
|
$effect(() => {
|
|
|
|
|
return () => {
|
|
|
|
|
if (this.typeaheadTimer) clearTimeout(this.typeaheadTimer);
|
|
|
|
|
};
|
|
|
|
|
return () => this.clearTypeaheadTimer();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -380,10 +379,16 @@ export class TreeGridProvider {
|
|
|
|
|
|
|
|
|
|
private handleTypeahead(char: string, fromIndex: number) {
|
|
|
|
|
this.typeaheadBuffer += char.toLowerCase();
|
|
|
|
|
if (this.typeaheadTimer) clearTimeout(this.typeaheadTimer);
|
|
|
|
|
this.typeaheadTimer = setTimeout(() => {
|
|
|
|
|
this.typeaheadBuffer = '';
|
|
|
|
|
}, this.opts.typeaheadTimeout.current);
|
|
|
|
|
this.clearTypeaheadTimer();
|
|
|
|
|
this.typeaheadTimer = this.soma.uix.timers.schedule(
|
|
|
|
|
this.typeaheadTimerKey,
|
|
|
|
|
this.opts.typeaheadTimeout.current,
|
|
|
|
|
() => {
|
|
|
|
|
this.typeaheadTimer = null;
|
|
|
|
|
this.typeaheadBuffer = '';
|
|
|
|
|
},
|
|
|
|
|
{ replace: true, meta: { component: 'tree-grid', action: 'typeahead-reset' } }
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const rows = this.getVisibleRows();
|
|
|
|
|
if (rows.length === 0) return;
|
|
|
|
|
@ -403,6 +408,17 @@ export class TreeGridProvider {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private clearTypeaheadTimer() {
|
|
|
|
|
if (this.typeaheadTimer) {
|
|
|
|
|
this.typeaheadTimer.cancel();
|
|
|
|
|
this.typeaheadTimer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private get typeaheadTimerKey() {
|
|
|
|
|
return `soma:tree-grid:${this.opts.id.current}:typeahead`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleRowClick(value: string, e: SomaMouseEvent<HTMLElement>) {
|
|
|
|
|
if (this.opts.disabled.current || this.opts.readonly.current) return;
|
|
|
|
|
const mode =
|
|
|
|
|
|