import { RequiredSetter } from 'lowcode/_setters'; import { IPublicModelSettingField } from '@alilc/lowcode-types'; import { labelProps, stateProps, baseValidationSection, variantProp, selectModeProp, selectOptionsProp, } from '../_props'; import snippets from './snippets'; import { uuid } from '../_utils/utils'; import { checkParentWhitelist } from '../_utils/nestingRules'; const { version } = require('../../package.json'); export default { snippets, // 表单页显示组件 group: '基础组件', componentName: 'RsSelect', title: '下拉框', category: '表单元素', priority: 41, npm: { package: 'components-page', version, exportName: 'RsSelect', main: 'src\\index.tsx', destructuring: true, subName: '', }, props: [ { name: 'rs_id', title: { label: '组件ID' }, propType: 'string', setter: { componentName: RequiredSetter, initialValue: () => `select_${uuid()}`, }, extraProps: { setValue: (target: IPublicModelSettingField, value: any) => { if (!value) return; target.getProps().setPropValue('ref', value); }, }, }, ...labelProps, variantProp, { name: 'placeholder', title: { label: '占位提示', tip: '占位提示' }, propType: 'string', setter: 'StringSetter', }, stateProps, selectModeProp, { name: 'allowClear', title: { label: '清除按钮开关', tip: '默认打开' }, propType: 'bool', defaultValue: true, setter: 'BoolSetter', }, { name: 'showSearch', title: { label: '可搜索开关', tip: '默认打开' }, propType: 'bool', defaultValue: true, setter: 'BoolSetter', }, { ...selectOptionsProp, }, // 基础属性校验 baseValidationSection, { name: 'onClear', title: { label: '清除内容时回调', tip: '清除内容时回调', }, propType: 'func', }, { name: 'onDeselect', title: { label: '取消选中时回调', tip: '取消选中时调用,参数为选中项的 value (或 key) 值,仅在 multiple 或 tags 模式下生效', }, propType: 'func', }, { name: 'onFocus', title: { label: '获得焦点时回调', tip: '获得焦点时回调' }, propType: 'func', }, { name: 'onBlur', title: { label: '失去焦点时回调', tip: '失去焦点时回调' }, propType: 'func', }, { name: 'onSelect', title: { label: '被选中时回调', tip: '被选中时调用,参数为选中项的 value (或 key) 值', }, propType: 'func', }, ], configure: { component: { nestingRule: { parentWhitelist: (testNode: IPublicModelSettingField) => { return checkParentWhitelist(testNode); }, }, }, advanced: false, supports: { style: true, events: [ { name: 'onBlur', template: "onBlur(${extParams}){\n\t\t// 失去焦点时回调\n\t\tconsole.log('onBlur');\n\t}\n", }, { name: 'onClear', template: "onClear(${extParams}){\n\t\t// 清除内容时回调\n\t\tconsole.log('onClear');\n\t}\n", }, { name: 'onDeselect', template: "onDeselect(value,${extParams}){\n\t\t// 取消选中时调用, 仅在 multiple 或 tags 模式下生效\n\t\tconsole.log('onDeselect',value);\n\t}\n", }, { name: 'onFocus', template: "onFocus(${extParams}){\n\t\t// 获得焦点时回调\n\t\tconsole.log('onFocus');\n\t}\n", }, { name: 'onSelect', template: "onSelect(value,option,${extParams}){\n\t\t// 被选中时调用\n\t\tconsole.log('onSelect',value,option);\n\t}\n", }, ], }, }, };