Files
EasyFlow/easyflow-ui-admin/app/src/adapter/form.ts
陈子默 7e7c236c2a fix: 修复管理端前端 lint 与构建问题
- 收敛 easyflow-ui-admin 的 lint、格式和类型问题

- 修正 demo 页面与管理端前端构建失败点

- 验证 pnpm lint 与 pnpm build 均已通过
2026-04-05 21:39:13 +08:00

46 lines
1.1 KiB
TypeScript

import type {
EasyFlowFormProps,
EasyFlowFormSchema as FormSchema,
} from '@easyflow/common-ui';
import type { ComponentType } from './component';
import {
setupEasyFlowForm,
useEasyFlowForm as useForm,
z,
} from '@easyflow/common-ui';
import { $t } from '@easyflow/locales';
async function initSetupEasyFlowForm() {
setupEasyFlowForm<ComponentType>({
config: {
modelPropNameMap: {
Upload: 'fileList',
CheckboxGroup: 'model-value',
},
},
defineRules: {
required: (value, _params, ctx) => {
if (value === undefined || value === null || value.length === 0) {
return $t('ui.formRules.required', [ctx.label]);
}
return true;
},
selectRequired: (value, _params, ctx) => {
if (value === undefined || value === null) {
return $t('ui.formRules.selectRequired', [ctx.label]);
}
return true;
},
},
});
}
const useEasyFlowForm = useForm<ComponentType>;
export { initSetupEasyFlowForm, useEasyFlowForm, z };
export type EasyFlowFormSchema = FormSchema<ComponentType>;
export type { EasyFlowFormProps };