import snippets from './snippets'; import { IPublicModelSettingField } from '@alilc/lowcode-types'; import { baseValidationSection, labelProps, radioGroupOptionsProp, stateProps } from '../_props'; import { LinkageSetter, RelateSetter, RequiredSetter } from '../_setters'; import { CompDefaultValueOptions, DefaultValueTypeKeys } from '@/constants'; import { uuid } from '../_utils/utils'; import { checkParentWhitelist } from '../_utils/nestingRules'; import { version } from '../../package.json'; export default { snippets: snippets, // 表单页显示组件 group: '基础组件', componentName: 'RsRadioGroup', title: '单选框组', category: '表单元素', priority: 39, npm: { package: 'components-page', version, exportName: 'RsRadioGroup', main: 'src\\index.tsx', destructuring: true, subName: '', }, props: [ { name: 'rs_id', title: { label: { type: 'i18n', zh_CN: '组件ID', en_US: 'ID', }, tip: { type: 'i18n', zh_CN: '属性: rs_id | 说明: id | 与数据库对应字段名', en_US: 'prop: rs_id | description: id | Corresponding field name in the database', }, }, propType: 'string', setter: { componentName: RequiredSetter, initialValue: () => 'radio_' + uuid(), }, supportVariable: true, extraProps: { setValue: (target: IPublicModelSettingField, value: any) => { if (!value) return; target.getProps().setPropValue('ref', value); }, }, }, ...labelProps, // { // name: 'size', // title: { // label: { // type: 'i18n', // zh_CN: '尺寸', // en_US: 'size', // }, // tip: { // type: 'i18n', // zh_CN: '属性: size | 说明: 开关大小', // en_US: 'prop: size | description: Switch size', // }, // }, // propType: { type: 'oneOf', value: ['large', 'middle', 'small'] }, // setter: { // componentName: 'RadioGroupSetter', // props: { // options: [ // { // title: '大', // value: 'large', // }, // { // title: '中', // value: 'middle', // }, // { // title: '小', // value: 'small', // }, // ], // }, // }, // defaultValue: 'middle', // }, stateProps, { name: 'layoutScheme', title: { label: { type: 'i18n', zh_CN: '选项排列方式', en_US: 'layoutScheme', }, tip: { type: 'i18n', zh_CN: '属性: layoutScheme | 说明: 选项排列方式', en_US: 'prop: layoutScheme | description: Option arrangement mode', }, }, propType: { type: 'oneOf', value: ['horizontal', 'vertical'], }, setter: [ { componentName: 'RadioGroupSetter', props: { options: [ { title: '垂直排列', value: 'vertical', }, { title: '水平排列', value: 'horizontal', }, ], }, }, 'VariableSetter', ], defaultValue: 'horizontal', }, { name: 'optionType', title: { label: { type: 'i18n', zh_CN: '选项类型', en_US: 'optionType', }, tip: { type: 'i18n', zh_CN: '属性: optionType | 说明: 选项类型', en_US: 'prop: optionType | description: Option type', }, }, display: 'block', type: 'field', propType: { type: 'oneOf', value: ['custom', 'linkedFormData', 'dataLinkage'], }, setter: [ { componentName: 'SelectSetter', props: { options: CompDefaultValueOptions['RsRadio'], defaultValue: 'custom', }, }, 'VariableSetter', ], setValue: (target: IPublicModelSettingField, node: any) => { console.log(target, node); }, condition: () => false, defaultValue: 'custom', }, { ...radioGroupOptionsProp, condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('optionType') === 'custom'; }, }, { name: DefaultValueTypeKeys.LINKAGE, title: { label: { type: 'i18n', zh_CN: '数据联动', en_US: 'linkedFormData', }, tip: { type: 'i18n', zh_CN: '属性: linkedFormData | 说明: 数据联动', en_US: 'prop: linkedFormData | description: Data linkage', }, }, display: 'block', type: 'field', propType: 'string', condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('optionType') === DefaultValueTypeKeys.LINKAGE; }, setter: [ { componentName: LinkageSetter, props: {}, }, ], defaultValue: '', }, { name: DefaultValueTypeKeys.RELATE, title: { label: { type: 'i18n', zh_CN: '关联其他表单数据', en_US: 'relateOptions', }, tip: { type: 'i18n', zh_CN: '属性: relateOptions | 说明: 关联其他表单数据', en_US: 'prop: relateOptions | description: Relate to other form data', }, }, display: 'accordion', condition: (target: IPublicModelSettingField) => { return target.getProps().getPropValue('optionType') === DefaultValueTypeKeys.RELATE; }, setter: (target: any) => { return { componentName: RelateSetter, props: { mode: 'single', placeholder: '请选择关联的表单', options: [], }, }; }, }, baseValidationSection, ], configure: { component: { nestingRule: { parentWhitelist: (testNode: IPublicModelSettingField) => { return checkParentWhitelist(testNode); }, }, }, supports: { style: true, events: [ { name: 'onChange', title: { label: { type: 'i18n', zh_CN: '变化时回调', en_US: 'onChange', }, tip: { type: 'i18n', zh_CN: '属性: onChange | 说明: 多选框状态变化时的回调函数', en_US: 'prop: onChange | description: Callback function when the checkbox state changes', }, }, template: "onChange(value,${extParams}){\n\t\t// 变化时回调函数\n\t\tconsole.log('onChange', value);\n\t}\n", }, { name: 'onBlur', title: { label: { type: 'i18n', zh_CN: '失去焦点回调', en_US: 'onBlur', }, tip: { type: 'i18n', zh_CN: '属性: onBlur | 说明: 失去焦点回调', en_US: 'prop: onBlur | description: onBlur', }, }, template: "onBlur(event,${extParams}){\n\t\t// 按键释放回调\n\t\tconsole.log('onBlur',event);\n\t}\n", }, { name: 'onFocus', title: { label: { type: 'i18n', zh_CN: '获取焦点回调', en_US: 'onFocus', }, tip: { type: 'i18n', zh_CN: '属性: onFocus | 说明: 获取焦点回调', en_US: 'prop: onFocus | description: onFocus', }, }, template: "onFocus(event,${extParams}){\n\t\t// 获取焦点回调\n\t\tconsole.log('onFocus',event);\n\t}\n", }, ], }, }, };