feat(arco): enable to customize button content of Dropdown component

This commit is contained in:
Yun Feng 2022-06-14 13:29:32 +10:00
parent d2daf17b13
commit 7dc33f0478
2 changed files with 17 additions and 8 deletions

View File

@ -15,6 +15,7 @@ const DropdownStateSpec = Type.Object({
});
const exampleProperties: Static<typeof DropdownPropsSpec> = {
text: 'Click',
dropdownType: 'default',
trigger: 'click',
position: 'bl',
@ -51,7 +52,7 @@ export const Dropdown = implementRuntimeComponent({
events: ['onClickMenuItem', 'onVisibleChange', 'onButtonClick'],
},
})(props => {
const { elementRef, slotsElements, callbackMap, mergeState } = props;
const { text, elementRef, slotsElements, callbackMap, mergeState } = props;
const cProps = getComponentProps(props);
const { list, dropdownType, autoAlignPopupWidth, ...restProps } = cProps;
const typeMap = {
@ -90,7 +91,11 @@ export const Dropdown = implementRuntimeComponent({
triggerProps={{ autoAlignPopupMinWidth: autoAlignPopupWidth }}
>
<div ref={elementRef}>
{slotsElements.trigger ? slotsElements.trigger({}) : <Button>Click</Button>}
{slotsElements.trigger ? (
slotsElements.trigger({})
) : (
<Button>{text || null}</Button>
)}
</div>
</Dropdown>
);

View File

@ -7,6 +7,10 @@ export const DropdownPropsSpec = {
title: 'Type',
category: Category.Basic,
}),
text: Type.String({
title: 'Text',
category: Category.Basic,
}),
position: StringUnion(['top', 'tl', 'tr', 'bottom', 'bl', 'br'], {
title: 'Position',
category: Category.Layout,
@ -23,13 +27,13 @@ export const DropdownPropsSpec = {
title: 'Default Visible',
category: Category.Basic,
}),
autoAlignPopupWidth:Type.Boolean({
title:'Auto Align Popup Width',
autoAlignPopupWidth: Type.Boolean({
title: 'Auto Align Popup Width',
category: Category.Basic,
}),
unmountOnExit:Type.Boolean({
title:'Destroy On Hide',
category: Category.Behavior
unmountOnExit: Type.Boolean({
title: 'Destroy On Hide',
category: Category.Behavior,
}),
list: Type.Array(
Type.Object({
@ -43,7 +47,7 @@ export const DropdownPropsSpec = {
{
title: 'List',
category: Category.Basic,
widget:'core/v1/expression',
widget: 'core/v1/expression',
weight: 10,
}
),