|
|
|
|
@ -7,7 +7,7 @@ import { Soma } from '../../core/soma.svelte';
|
|
|
|
|
import { SPLITTER_LANGS } from './langs';
|
|
|
|
|
|
|
|
|
|
import { splitterMorfo } from '../../../morfo/components/splitter';
|
|
|
|
|
import type { SomaRuntimePart } from '../../runtime.svelte';
|
|
|
|
|
import type { SomaRuntime, SomaRuntimePart } from '../../runtime.svelte';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ── Types ────────────────────────────────────────────────────────────────────
|
|
|
|
|
@ -57,6 +57,8 @@ interface SplitterOpts
|
|
|
|
|
export class SplitterProvider {
|
|
|
|
|
readonly opts: SplitterOpts;
|
|
|
|
|
readonly runtimePart: SomaRuntimePart;
|
|
|
|
|
readonly soma: Soma;
|
|
|
|
|
readonly runtime: SomaRuntime;
|
|
|
|
|
static readonly ctx = context<SplitterProvider>('Splitter');
|
|
|
|
|
static get(): SplitterProvider | undefined {
|
|
|
|
|
return this.ctx.getOr(undefined) as SplitterProvider | undefined;
|
|
|
|
|
@ -69,15 +71,19 @@ export class SplitterProvider {
|
|
|
|
|
return new SplitterProvider(opts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readonly soma = Soma.get();
|
|
|
|
|
private panels: PanelState[] = $state([]);
|
|
|
|
|
resizing = $state(false);
|
|
|
|
|
|
|
|
|
|
private constructor(opts: SplitterOpts) {
|
|
|
|
|
this.opts = opts;
|
|
|
|
|
this.runtimePart = Soma.require()
|
|
|
|
|
.runtime(splitterMorfo, {})
|
|
|
|
|
.part('provider', { id: opts.id, ref: opts.ref, owner: this, context: SplitterProvider.ctx });
|
|
|
|
|
this.soma = Soma.require();
|
|
|
|
|
this.runtime = this.soma.runtime(splitterMorfo, {});
|
|
|
|
|
this.runtimePart = this.runtime.part('provider', {
|
|
|
|
|
id: opts.id,
|
|
|
|
|
ref: opts.ref,
|
|
|
|
|
owner: this,
|
|
|
|
|
context: SplitterProvider.ctx
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ── Panel registration ───────────────────────────────────────────────────
|
|
|
|
|
@ -282,10 +288,12 @@ export class SplitterPanelProvider {
|
|
|
|
|
|
|
|
|
|
private constructor(opts: SplitterPanelOpts) {
|
|
|
|
|
this.opts = opts;
|
|
|
|
|
this.runtimePart = Soma.require()
|
|
|
|
|
.runtime(splitterMorfo, {})
|
|
|
|
|
.part('panel', { id: opts.id, ref: opts.ref, owner: this });
|
|
|
|
|
this.provider = SplitterProvider.require();
|
|
|
|
|
this.runtimePart = this.provider.runtime.part('panel', {
|
|
|
|
|
id: opts.id,
|
|
|
|
|
ref: opts.ref,
|
|
|
|
|
owner: this
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.cleanup = this.provider.registerPanel({
|
|
|
|
|
id: opts.panelId.current,
|
|
|
|
|
@ -356,10 +364,12 @@ export class SplitterResizeTriggerProvider {
|
|
|
|
|
|
|
|
|
|
private constructor(opts: SplitterResizeTriggerOpts) {
|
|
|
|
|
this.opts = opts;
|
|
|
|
|
this.runtimePart = Soma.require()
|
|
|
|
|
.runtime(splitterMorfo, {})
|
|
|
|
|
.part('resize-trigger', { id: opts.id, ref: opts.ref, owner: this });
|
|
|
|
|
this.provider = SplitterProvider.require();
|
|
|
|
|
this.runtimePart = this.provider.runtime.part('resize-trigger', {
|
|
|
|
|
id: opts.id,
|
|
|
|
|
ref: opts.ref,
|
|
|
|
|
owner: this
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Cleanup drag state on unmount
|
|
|
|
|
$effect(() => {
|
|
|
|
|
@ -545,7 +555,7 @@ export class SplitterResizeTriggerProvider {
|
|
|
|
|
this.runtimePart.assert({
|
|
|
|
|
...this.runtimePart.props,
|
|
|
|
|
role: 'separator' as const,
|
|
|
|
|
'aria-label': this.provider.soma?.langs.ts(SPLITTER_LANGS.RESIZE),
|
|
|
|
|
'aria-label': this.provider.soma.langs.ts(SPLITTER_LANGS.RESIZE),
|
|
|
|
|
'aria-orientation': this.provider.opts.orientation.current,
|
|
|
|
|
'aria-valuenow': this.ariaValueNow,
|
|
|
|
|
'aria-valuemin': this.ariaValueMin,
|
|
|
|
|
|