-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 1. 新增Icon组件。 2.增加FormAction。3. 优化代码。
- Loading branch information
Showing
15 changed files
with
241 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/editor/src/components/EventConfig/ActionModal/FormAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Form, Select, Divider } from 'antd'; | ||
import { usePageStore } from '@/stores/pageStore'; | ||
import styles from './index.module.less'; | ||
const FormAction = () => { | ||
// 页面组件 | ||
const { modals } = usePageStore((state) => { | ||
const modals: { id: string }[] = []; | ||
Object.values(state.page.elementsMap).forEach((item) => { | ||
if (item.type === 'SearchForm' || item.type === 'Form') { | ||
modals.push({ | ||
id: item.id, | ||
}); | ||
} | ||
}); | ||
return { | ||
modals, | ||
}; | ||
}); | ||
|
||
return ( | ||
<> | ||
<div className={styles.desc}> | ||
<h3 className={styles.descTitle}>说明</h3> | ||
<p className={styles.descInfo}>触发一个事件动作后,可以选择目标表单,调用该表单方法。</p> | ||
<Divider /> | ||
</div> | ||
<Form.Item label="选择表单" name={'target'} rules={[{ required: true, message: '请选择表单组件' }]}> | ||
<Select> | ||
{modals.map((item) => ( | ||
<Select.Option key={item.id} value={item.id}> | ||
{`${item.id}`} | ||
</Select.Option> | ||
))} | ||
</Select> | ||
</Form.Item> | ||
</> | ||
); | ||
}; | ||
export default FormAction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useState, useImperativeHandle, forwardRef } from 'react'; | ||
import Icon, * as Icons from '@ant-design/icons'; | ||
import { ComponentType } from '@/packages/types'; | ||
/** | ||
* | ||
* @param props 组件本身属性 | ||
* @param style 组件样式 | ||
* @returns | ||
*/ | ||
const MImage = ( | ||
{ | ||
id, | ||
type, | ||
config, | ||
}: ComponentType<{ | ||
icon: string; | ||
style?: React.CSSProperties; | ||
}>, | ||
ref: any, | ||
) => { | ||
const [visible, setVisible] = useState(true); | ||
// 对外暴露方法 | ||
useImperativeHandle(ref, () => { | ||
return { | ||
show() { | ||
setVisible(true); | ||
}, | ||
hide() { | ||
setVisible(false); | ||
}, | ||
}; | ||
}); | ||
const iconComp = Icons[config.props.icon as keyof typeof Icons]; | ||
return ( | ||
visible && ( | ||
<Icon component={iconComp as React.ForwardRefExoticComponent<any>} style={config.style} {...config.props} data-id={id} data-type={type} /> | ||
) | ||
); | ||
}; | ||
export default forwardRef(MImage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 组件配置和属性值 | ||
*/ | ||
|
||
export default { | ||
// 组件属性配置JSON | ||
attrs: [ | ||
{ | ||
type: 'Title', | ||
label: '基础配置', | ||
key: 'basic', | ||
tooltip: '图标大小和颜色可在样式中修改字体颜色和大小', | ||
}, | ||
{ | ||
type: 'Icons', | ||
label: '图标', | ||
name: 'icon', | ||
}, | ||
{ | ||
type: 'InputNumber', | ||
label: '旋转角度', | ||
name: 'rotate', | ||
}, | ||
{ | ||
type: 'Switch', | ||
label: '旋转动画', | ||
name: 'spin', | ||
}, | ||
], | ||
config: { | ||
// 组件默认属性值 | ||
props: { | ||
icon: 'GithubOutlined', | ||
rotate: 0, | ||
spin: false, | ||
}, | ||
// 组件样式 | ||
style: {}, | ||
}, | ||
// 组件事件 | ||
events: [ | ||
{ | ||
value: 'handleClick', | ||
name: '点击事件', | ||
}, | ||
], | ||
// 组件接口 | ||
api: {}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as Icon } from './Icon'; | ||
export { default as IconConfig } from './Schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { useState, useImperativeHandle, forwardRef } from 'react'; | ||
import Icon, * as Icons from '@ant-design/icons'; | ||
import { ComponentType } from '../../types'; | ||
/** | ||
* | ||
* @param props 组件本身属性 | ||
* @param style 组件样式 | ||
* @returns | ||
*/ | ||
const MIcon = ( | ||
{ | ||
id, | ||
type, | ||
config, | ||
}: ComponentType<{ | ||
icon: string; | ||
style?: React.CSSProperties; | ||
}>, | ||
ref: any, | ||
) => { | ||
const [visible, setVisible] = useState(true); | ||
// 对外暴露方法 | ||
useImperativeHandle(ref, () => { | ||
return { | ||
show() { | ||
setVisible(true); | ||
}, | ||
hide() { | ||
setVisible(false); | ||
}, | ||
}; | ||
}); | ||
const iconComp = Icons[config.props.icon as keyof typeof Icons]; | ||
return visible && <Icon component={iconComp as React.ForwardRefExoticComponent<any>} style={config.style} {...config.props} />; | ||
}; | ||
export default forwardRef(MIcon); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Icon } from './Icon'; |