Drive NumberField root attrs from Soma runtime

active-uix
dev 5 months ago
parent 89243e2f52
commit c72ce793b0

@ -15,12 +15,12 @@ export const numberFieldMorfo = {
defaultElement: 'div',
optional: false,
data: [
{ attr: 'data-disabled', severity: 'optional' },
{ attr: 'data-readonly', severity: 'optional' },
{ attr: 'data-required', severity: 'optional' },
{ attr: 'data-invalid', severity: 'optional' },
{ attr: 'data-focused', severity: 'optional' },
{ attr: 'data-scrubbing', severity: 'optional' }
{ attr: 'data-disabled', value: v.propRef('disabled'), severity: 'optional' },
{ attr: 'data-readonly', value: v.propRef('readonly'), severity: 'optional' },
{ attr: 'data-required', value: v.propRef('required'), severity: 'optional' },
{ attr: 'data-invalid', value: v.propRef('invalid'), severity: 'optional' },
{ attr: 'data-focused', value: v.propRef('focused'), severity: 'optional' },
{ attr: 'data-scrubbing', value: v.propRef('scrubbing'), severity: 'optional' }
],
aria: []
},

@ -117,12 +117,22 @@ export class NumberFieldProvider {
private constructor(opts: NumberFieldOpts) {
this.opts = opts;
this.soma = Soma.require();
this.runtime = this.soma.runtime(numberFieldMorfo, {});
this.runtime = this.soma.runtime(numberFieldMorfo, {
props: {
disabled: () => this.isDisabled,
readonly: () => this.isReadonly,
required: () => this.isRequired,
invalid: () => this.isInvalid,
focused: () => this.focused,
scrubbing: () => this.scrubbing
}
});
this.runtimePart = this.runtime.part('provider', {
id: opts.id,
ref: opts.ref,
owner: this,
context: NumberFieldProvider.ctx
context: NumberFieldProvider.ctx,
syncAttrs: true
});
this.locale = readableActive(() => opts.locale.current ?? this.soma.langs.getLocale() ?? 'en');
@ -424,13 +434,7 @@ export class NumberFieldProvider {
readonly props = $derived.by(() =>
this.runtimePart.assert({
...this.runtimePart.props,
dir: this.opts.dir.current,
'data-disabled': boolToEmptyStrOrUndef(this.isDisabled),
'data-readonly': boolToEmptyStrOrUndef(this.isReadonly),
'data-required': boolToEmptyStrOrUndef(this.isRequired),
'data-invalid': boolToEmptyStrOrUndef(this.isInvalid),
'data-focused': boolToEmptyStrOrUndef(this.focused),
'data-scrubbing': boolToEmptyStrOrUndef(this.scrubbing)
dir: this.opts.dir.current
} as const)
);
}

Loading…
Cancel
Save

Powered by TurnKey Linux.