|
|
|
@ -1,6 +1,5 @@
|
|
|
|
import { context, type WithRefOpts } from '../../provider';
|
|
|
|
import { context, type WithRefOpts } from '../../provider';
|
|
|
|
import { createAttrs } from '$uix/morfo';
|
|
|
|
import { createAttrs } from '$uix/morfo';
|
|
|
|
import { boolToEmptyStrOrUndef } from '$adom';
|
|
|
|
|
|
|
|
import { state, type ActiveProps, type StateProps } from '$libs/reactive';
|
|
|
|
import { state, type ActiveProps, type StateProps } from '$libs/reactive';
|
|
|
|
import type { Direction } from '../../types';
|
|
|
|
import type { Direction } from '../../types';
|
|
|
|
import { Soma } from '../../core/soma.svelte';
|
|
|
|
import { Soma } from '../../core/soma.svelte';
|
|
|
|
@ -81,12 +80,23 @@ export class TimeRangeFieldProvider {
|
|
|
|
private constructor(opts: TimeRangeFieldOpts) {
|
|
|
|
private constructor(opts: TimeRangeFieldOpts) {
|
|
|
|
this.opts = opts;
|
|
|
|
this.opts = opts;
|
|
|
|
this.soma = Soma.require();
|
|
|
|
this.soma = Soma.require();
|
|
|
|
this.runtime = this.soma.runtime(timeRangeFieldMorfo, {});
|
|
|
|
this.runtime = this.soma.runtime(timeRangeFieldMorfo, {
|
|
|
|
|
|
|
|
props: {
|
|
|
|
|
|
|
|
disabled: () => this.isDisabled,
|
|
|
|
|
|
|
|
readonly: () => this.isReadonly,
|
|
|
|
|
|
|
|
required: () => this.isRequired,
|
|
|
|
|
|
|
|
invalid: () => this.isInvalid
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
parts: {
|
|
|
|
|
|
|
|
label: () => this.labelNode?.id || undefined
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
this.runtimePart = this.runtime.part('provider', {
|
|
|
|
this.runtimePart = this.runtime.part('provider', {
|
|
|
|
id: opts.id,
|
|
|
|
id: opts.id,
|
|
|
|
ref: opts.ref,
|
|
|
|
ref: opts.ref,
|
|
|
|
owner: this,
|
|
|
|
owner: this,
|
|
|
|
context: TimeRangeFieldProvider.ctx
|
|
|
|
context: TimeRangeFieldProvider.ctx,
|
|
|
|
|
|
|
|
syncAttrs: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -155,11 +165,7 @@ export class TimeRangeFieldProvider {
|
|
|
|
this.runtimePart.assert({
|
|
|
|
this.runtimePart.assert({
|
|
|
|
...this.runtimePart.props,
|
|
|
|
...this.runtimePart.props,
|
|
|
|
dir: this.opts.dir.current,
|
|
|
|
dir: this.opts.dir.current,
|
|
|
|
'aria-invalid': this.isInvalid || undefined,
|
|
|
|
'aria-invalid': this.isInvalid || undefined
|
|
|
|
'data-invalid': boolToEmptyStrOrUndef(this.isInvalid),
|
|
|
|
|
|
|
|
'data-disabled': boolToEmptyStrOrUndef(this.isDisabled),
|
|
|
|
|
|
|
|
'data-readonly': boolToEmptyStrOrUndef(this.isReadonly),
|
|
|
|
|
|
|
|
'data-required': boolToEmptyStrOrUndef(this.isRequired)
|
|
|
|
|
|
|
|
} as const)
|
|
|
|
} as const)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -186,7 +192,8 @@ export class TimeRangeFieldLabelProvider {
|
|
|
|
owner: this,
|
|
|
|
owner: this,
|
|
|
|
onRefChange: (v) => {
|
|
|
|
onRefChange: (v) => {
|
|
|
|
this.provider.labelNode = v;
|
|
|
|
this.provider.labelNode = v;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
syncAttrs: true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -203,8 +210,6 @@ export class TimeRangeFieldLabelProvider {
|
|
|
|
readonly props = $derived.by(() =>
|
|
|
|
readonly props = $derived.by(() =>
|
|
|
|
this.runtimePart.assert({
|
|
|
|
this.runtimePart.assert({
|
|
|
|
...this.runtimePart.props,
|
|
|
|
...this.runtimePart.props,
|
|
|
|
'data-invalid': boolToEmptyStrOrUndef(this.provider.isInvalid),
|
|
|
|
|
|
|
|
'data-disabled': boolToEmptyStrOrUndef(this.provider.isDisabled),
|
|
|
|
|
|
|
|
onclick: this.onclick
|
|
|
|
onclick: this.onclick
|
|
|
|
} as const)
|
|
|
|
} as const)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|