import { Component, inject } from '@angular/core';
import { YelonFormModule, SFSchema } from '@yelon/form';
import type { SFRateWidgetSchema } from '@yelon/form/widgets/rate';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'form-rate-simple',
template: ` <sf [schema]="schema" (formSubmit)="submit($event)" /> `,
standalone: true,
imports: [YelonFormModule]
})
export class FormRateSimpleComponent {
private readonly msg = inject(NzMessageService);
schema: SFSchema = {
properties: {
rate: {
type: 'number',
title: '评级',
default: 4.5,
ui: {
widget: 'rate'
} as SFRateWidgetSchema
},
// 允许半选
rate2: {
type: 'number',
title: '评级',
maximum: 5,
multipleOf: 0.5,
default: 4.5,
ui: {
widget: 'rate',
text: '{{value}} starts'
} as SFRateWidgetSchema
}
}
};
submit(value: {}): void {
this.msg.success(JSON.stringify(value));
}
}