import { Component, inject } from '@angular/core';
import { YelonFormModule, SFSchema } from '@yelon/form';
import type { SFTimeWidgetSchema } from '@yelon/form/widgets/time';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'form-time-simple',
template: ` <sf [schema]="schema" (formSubmit)="submit($event)" />`,
standalone: true,
imports: [YelonFormModule]
})
export class FormTimeSimpleComponent {
private readonly msg = inject(NzMessageService);
schema: SFSchema = {
properties: {
time: {
type: 'string',
ui: { widget: 'time' } as SFTimeWidgetSchema
},
time_number: {
type: 'number',
ui: { widget: 'time' } as SFTimeWidgetSchema
},
time_format: {
type: 'string',
format: 'time',
ui: {
format: `HH:mm:ss+00:00`
} as SFTimeWidgetSchema
},
'12hours': {
type: 'string',
ui: {
widget: 'time',
format: 'h:mm:ss a',
use12Hours: true
} as SFTimeWidgetSchema
}
}
};
submit(value: {}): void {
this.msg.success(JSON.stringify(value));
}
}