import snippets from './snippets'; import { LayoutSetter, RequiredSetter } from 'lowcode/_setters'; import { IPublicModelSettingField } from '@alilc/lowcode-types'; import { uuid } from '../_utils/utils'; import { version } from '../../package.json'; const RsLayoutContainerMeta = { snippets, group: '基础组件', componentName: 'RsLayoutContainer', title: '布局容器', category: '容器元素', priority: 19, // 用于描述组件在统一category中的排序 npm: { package: 'components-page', version, exportName: 'RsLayoutContainer', 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: Component ID', }, }, propType: 'string', setter: { componentName: RequiredSetter, initialValue: () => 'layout_' + uuid(), }, supportVariable: true, }, { name: 'layoutConfig', title: { label: { type: 'i18n', zh_CN: '布局', en_US: 'layoutConfig', }, tip: { type: 'i18n', zh_CN: '属性: layoutConfig | 说明: 布局配置', en_US: 'prop: layoutConfig | description: Layout configuration', }, }, display: 'block', type: 'field', propType: 'object', setter: [ { componentName: LayoutSetter, props: { defaultValue: { rowGap: 16, columnGap: 16, rowPercent: '12:9:3', }, }, }, ], extraProps: { setValue( target: IPublicModelSettingField, value: { rowPercent?: string; rowGap?: number; columnGap?: number; }, ) { const { node } = target; let grids = value?.rowPercent?.split(':') || []; grids = grids.filter((item: string) => { return item && item.trim(); // 去除空数组项 }); node?.children?.mergeChildren( (child, index: number) => { return index >= grids.length; }, (children) => { let l = children.length - 1; const items = []; for (let i = l + 1; i < grids.length; i++) { items.push({ componentName: 'RsContainer', key: uuid(), props: { key: `node_ocm${Math.random()}`, }, }); } return items; }, (childA, childB) => { return 0; }, ); }, }, }, ], configure: { component: { // 是否是容器组件,如果是容器组件,别的组件可以放置内容 isContainer: true, nestingRule: { childWhitelist: ['RsLayoutContainer.Container'], }, }, advanced: { callbacks: { // onMouseDownHook: () => false, // onClickHook: () => false, }, }, supports: { style: true, events: [], }, }, }; export default RsLayoutContainerMeta;