Download playground/src/adapter/form.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 1.26 kB
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/playground/src/adapter/form.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/playground/src/adapter/form.ts
-
curl -L -o form.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/playground/src/adapter/form.ts
1.26 kB
| import type { | |
| VbenFormSchema as FormSchema, | |
| VbenFormProps, | |
| } from '@vben/common-ui'; | |
| import type { ComponentType } from './component'; | |
| import { setupVbenForm, useVbenForm as useForm, z } from '@vben/common-ui'; | |
| import { $t } from '@vben/locales'; | |
| setupVbenForm<ComponentType>({ | |
| config: { | |
| // ant design vue组件库默认都是 v-model:value | |
| baseModelPropName: 'value', | |
| // 一些组件是 v-model:checked 或者 v-model:fileList | |
| modelPropNameMap: { | |
| Checkbox: 'checked', | |
| Radio: 'checked', | |
| Switch: 'checked', | |
| Upload: 'fileList', | |
| }, | |
| }, | |
| 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 useVbenForm = useForm<ComponentType>; | |
| export { useVbenForm, z }; | |
| export type VbenFormSchema = FormSchema<ComponentType>; | |
| export type { VbenFormProps }; | |