Normalize Soma root service references

active-uix
dev 5 months ago
parent f652f54d5b
commit d5f96aedf9

@ -17,7 +17,7 @@ import { ALERT_DIALOG_LANGS } from './langs';
* differently, and they wire `onclick` to close the dialog.
*/
import { alertDialogMorfo } from '../../../morfo/components/alert-dialog';
import type { SomaRuntimePart } from '../../runtime.svelte';
import type { SomaRuntime, SomaRuntimePart } from '../../runtime.svelte';
// ── Action button (primary / destructive) ─────────────────────────────────
@ -33,22 +33,28 @@ export class AlertDialogActionProvider {
}
readonly dialog: DialogProvider;
readonly soma = Soma.get();
readonly soma: Soma;
readonly runtime: SomaRuntime;
private constructor(opts: AlertDialogActionOpts) {
this.opts = opts;
this.dialog = DialogProvider.require();
this.runtimePart = Soma.require()
.runtime(alertDialogMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(alertDialogMorfo, {
props: {
ariaLabel: () => this.resolvedAriaLabel
}
})
.part('action', { id: opts.id, ref: opts.ref, owner: this, syncAttrs: true });
});
this.runtimePart = this.runtime.part('action', {
id: opts.id,
ref: opts.ref,
owner: this,
syncAttrs: true
});
}
readonly resolvedAriaLabel = $derived.by(
() => this.opts.ariaLabel.current || this.soma?.langs.ts(ALERT_DIALOG_LANGS.ACTION)
() => this.opts.ariaLabel.current || this.soma.langs.ts(ALERT_DIALOG_LANGS.ACTION)
);
readonly onclick = (_e: SomaMouseEvent<HTMLButtonElement>) => {
@ -76,22 +82,28 @@ export class AlertDialogCancelProvider {
}
readonly dialog: DialogProvider;
readonly soma = Soma.get();
readonly soma: Soma;
readonly runtime: SomaRuntime;
private constructor(opts: AlertDialogCancelOpts) {
this.opts = opts;
this.dialog = DialogProvider.require();
this.runtimePart = Soma.require()
.runtime(alertDialogMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(alertDialogMorfo, {
props: {
ariaLabel: () => this.resolvedAriaLabel
}
})
.part('cancel', { id: opts.id, ref: opts.ref, owner: this, syncAttrs: true });
});
this.runtimePart = this.runtime.part('cancel', {
id: opts.id,
ref: opts.ref,
owner: this,
syncAttrs: true
});
}
readonly resolvedAriaLabel = $derived.by(
() => this.opts.ariaLabel.current || this.soma?.langs.ts(ALERT_DIALOG_LANGS.CANCEL)
() => this.opts.ariaLabel.current || this.soma.langs.ts(ALERT_DIALOG_LANGS.CANCEL)
);
readonly onclick = (_e: SomaMouseEvent<HTMLButtonElement>) => {

@ -35,6 +35,7 @@ export class CollapsibleProvider {
}
readonly opts: CollapsibleOpts;
readonly soma: Soma;
readonly runtime: SomaRuntime;
readonly runtimePart: SomaRuntimePart;
@ -47,8 +48,8 @@ export class CollapsibleProvider {
this.opts = opts;
CollapsibleProvider.ctx.set(this);
const soma = Soma.require();
this.runtime = soma.runtime(collapsibleMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(collapsibleMorfo, {
states: {
open: () => opts.open.current
},

@ -55,6 +55,7 @@ export class SwitchProvider {
readonly field = FieldProvider.get();
readonly runtime: SomaRuntime;
readonly runtimePart: SomaRuntimePart;
readonly soma: Soma;
private constructor(opts: SwitchOpts) {
this.opts = opts;
@ -64,8 +65,8 @@ export class SwitchProvider {
// attribute lands on this button. Direct assign — NOT $effect (A30).
if (this.field) this.field.inputId.current = opts.id.current;
const soma = Soma.require();
this.runtime = soma.runtime(switchMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(switchMorfo, {
states: {
checked: () => opts.checked.current
},

@ -58,6 +58,7 @@ export class ToggleProvider {
readonly field = FieldProvider.get();
readonly runtime: SomaRuntime;
readonly runtimePart: SomaRuntimePart;
readonly soma: Soma;
private constructor(opts: ToggleOpts) {
this.opts = opts;
@ -74,8 +75,8 @@ export class ToggleProvider {
// toggle. El handler flipea el estado bound. El gesto de contact
// está implícito en el botón nativo; no se descompone en dos
// eventos porque la operación es instantánea.
const soma = Soma.require();
this.runtime = soma.runtime(toggleMorfo, {
this.soma = Soma.require();
this.runtime = this.soma.runtime(toggleMorfo, {
states: {
on: () => opts.pressed.current
},

Loading…
Cancel
Save

Powered by TurnKey Linux.