Use root Soma services in overlay providers

active-uix
dev 5 months ago
parent 0c37c7783f
commit f652f54d5b

@ -64,6 +64,7 @@ export class DialogProvider {
}
readonly opts: DialogOpts;
readonly soma: Soma;
readonly runtime: SomaRuntime;
readonly runtimePart: SomaRuntimePart;
@ -128,8 +129,8 @@ export class DialogProvider {
const onOpen = () => this.handleOpen();
const onClose = () => this.handleClose();
const soma = Soma.require();
this.runtime = soma.runtime(dialogMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(dialogMorfo, {
states: { open: () => opts.open.current },
props: {
disabled: () => opts.disabled.current,
@ -350,7 +351,7 @@ export class DialogContentProvider {
this.textSelection = TextSelection.use({
ref: readableActive(() => opts.ref.current),
dom: Soma.require().dom,
dom: this.provider.soma.dom,
enabled: readableActive(() => this.provider.opts.open.current),
onPointerDown: readableActive(() => () => {}),
onPointerUp: readableActive(() => () => {})

@ -113,7 +113,7 @@ export class DrawerProvider {
}
readonly opts: DrawerOpts;
readonly soma = Soma.get();
readonly soma: Soma;
readonly runtime: SomaRuntime;
readonly runtimePart: SomaRuntimePart;
@ -138,7 +138,7 @@ export class DrawerProvider {
private overlayRef = state<HTMLElement | null>(null);
readonly resolvedSide = $derived.by((): DrawerSide => {
const dir = this.soma?.prefs.getDir() ?? 'ltr';
const dir = this.soma.prefs.getDir();
return resolveDirection(this.opts.direction.current, dir);
});
@ -195,8 +195,8 @@ export class DrawerProvider {
// `data-dragging` on Content props.
const noop = () => {};
const soma = Soma.require();
this.runtime = soma.runtime(drawerMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(drawerMorfo, {
// 'persistent' forces open=true so eidos can render the layout
// drawer without the consumer needing to bind `open`. The morfo
// state is read once per tick so the override is reactive.
@ -480,7 +480,7 @@ export class DrawerContentProvider {
// ── Text selection ───────────────────────────────────────────────────
this.textSelection = TextSelection.use({
ref: readableActive(() => opts.ref.current),
dom: Soma.require().dom,
dom: this.provider.soma.dom,
enabled: readableActive(() => this.provider.opts.open.current),
onPointerDown: readableActive(() => () => {}),
onPointerUp: readableActive(() => () => {})

@ -483,7 +483,7 @@ export class PopoverContentProvider {
// Text selection
this.textSelection = TextSelection.use({
ref: readableActive(() => opts.ref.current),
dom: Soma.require().dom,
dom: this.provider.soma.dom,
enabled: readableActive(() => this.provider.opts.open.current),
onPointerDown: readableActive(() => () => {}),
onPointerUp: readableActive(() => () => {})

@ -46,7 +46,7 @@ export class ToastProvider {
}
readonly opts: ToastProviderOpts;
readonly soma = Soma.get();
readonly soma: Soma;
readonly runtime: SomaRuntime;
private constructor(opts: ToastProviderOpts) {
@ -55,8 +55,8 @@ export class ToastProvider {
// Root-scope runtime — only the Viewport part registers here. Item and
// its children get their own runtime per-instance (see ToastItemProvider).
const soma = Soma.require();
this.runtime = soma.runtime(toastMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(toastMorfo, {
props: {
label: () => opts.label.current
}
@ -229,7 +229,7 @@ export class ToastItemProvider {
// `events.dismiss` is the WHEN — runtime.trigger('dismiss') runs the
// perceptual signal first, then this callback mutates state, then the
// item's effect re-derives data-state etc. via dom.apply.
const soma = Soma.require();
const soma = this.provider.soma;
this.runtime = soma.runtime(toastMorfo, {
states: {
open: () => this.isOpen
@ -326,8 +326,7 @@ export class ToastItemProvider {
if (!isBrowser) return;
this.clearTimer();
this.startTime = Date.now();
const soma = Soma.require();
this.autoDismissTimer = soma.uix.timers.schedule(
this.autoDismissTimer = this.provider.soma.uix.timers.schedule(
this.autoDismissKey,
this.remaining,
() => {

Loading…
Cancel
Save

Powered by TurnKey Linux.