mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
feat(arco): expose 'setInputValue' method for TextArea component
This commit is contained in:
parent
130cce9532
commit
63d8c45c0c
@ -42,7 +42,11 @@ export const TextArea = implementRuntimeComponent({
|
||||
spec: {
|
||||
properties: TextAreaPropsSpec,
|
||||
state: TextAreaStateSpec,
|
||||
methods: {},
|
||||
methods: {
|
||||
setInputValue: Type.Object({
|
||||
value: Type.String(),
|
||||
}),
|
||||
},
|
||||
slots: {},
|
||||
styleSlots: ['TextArea'],
|
||||
events: ['onChange', 'onBlur', 'onFocus', 'onClear', 'onPressEnter'],
|
||||
@ -54,6 +58,7 @@ export const TextArea = implementRuntimeComponent({
|
||||
customStyle,
|
||||
callbackMap,
|
||||
mergeState,
|
||||
subscribeMethods,
|
||||
} = props;
|
||||
const { defaultValue, ...cProps } = getComponentProps(props);
|
||||
const [value, setValue] = useStateValue(
|
||||
@ -70,6 +75,16 @@ export const TextArea = implementRuntimeComponent({
|
||||
}
|
||||
}, [getElement, ref]);
|
||||
|
||||
useEffect(() => {
|
||||
subscribeMethods({
|
||||
setInputValue({ value }) {
|
||||
setValue(value);
|
||||
mergeState({ value });
|
||||
callbackMap?.onChange?.();
|
||||
},
|
||||
});
|
||||
}, [setValue, mergeState, callbackMap, subscribeMethods]);
|
||||
|
||||
return (
|
||||
<BaseTextArea
|
||||
ref={ref}
|
||||
|
Loading…
Reference in New Issue
Block a user