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

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

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

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

Loading…
Cancel
Save

Powered by TurnKey Linux.