forked from opentiny/tiny-vue
fix(renderless/input): [input] fix value become empty when the input type changed (#1025)
This commit is contained in:
parent
44af3ea51d
commit
6ae405b20d
|
@ -10,7 +10,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import type { IInputApi, IInputClassPrefixConstants, IInputRenderlessParams, IInputState } from 'types/input.type'
|
||||
import type {
|
||||
IInputApi,
|
||||
IInputClassPrefixConstants,
|
||||
IInputRenderlessParamUtils,
|
||||
IInputRenderlessParams,
|
||||
IInputState
|
||||
} from 'types/input.type'
|
||||
|
||||
const HIDDEN_STYLE = `
|
||||
height:0 !important;visibility:hidden !important;overflow:hidden !important;
|
||||
|
@ -162,8 +168,8 @@ export const calcTextareaHeight =
|
|||
return textareaStyle
|
||||
}
|
||||
|
||||
export const getInput = (refs: IInputRenderlessParams['refs']) => (): HTMLTextAreaElement | HTMLInputElement =>
|
||||
refs.input || refs.textarea
|
||||
export const getInput = (vm: IInputRenderlessParamUtils['vm']) => (): HTMLTextAreaElement | HTMLInputElement =>
|
||||
vm.$refs.input || vm.$refs.textarea
|
||||
|
||||
export const blur = (api: IInputApi) => (): void => api.getInput().blur()
|
||||
|
||||
|
|
|
@ -161,11 +161,14 @@ const initApi = ({
|
|||
dispatch,
|
||||
broadcast,
|
||||
emit,
|
||||
refs,
|
||||
vm,
|
||||
props,
|
||||
CLASS_PREFIX,
|
||||
parent
|
||||
}: Pick<IInputRenderlessParams, 'api' | 'state' | 'dispatch' | 'broadcast' | 'emit' | 'refs' | 'props' | 'parent'> & {
|
||||
}: Pick<
|
||||
IInputRenderlessParams,
|
||||
'api' | 'state' | 'dispatch' | 'broadcast' | 'emit' | 'refs' | 'props' | 'parent' | 'vm'
|
||||
> & {
|
||||
CLASS_PREFIX: IInputClassPrefixConstants
|
||||
}) => {
|
||||
Object.assign(api, {
|
||||
|
@ -174,7 +177,7 @@ const initApi = ({
|
|||
broadcast,
|
||||
showBox: showBox(state),
|
||||
clear: clear(emit),
|
||||
getInput: getInput(refs),
|
||||
getInput: getInput(vm),
|
||||
handleChange: handleChange(emit),
|
||||
watchFormSelect: watchFormSelect({ emit, props, state }),
|
||||
calcIconOffset: calcIconOffset({ CLASS_PREFIX, parent }),
|
||||
|
@ -327,7 +330,7 @@ export const renderless = (
|
|||
}
|
||||
const state = initState({ reactive, computed, mode, props, parent, constants, api })
|
||||
|
||||
initApi({ api, state, dispatch, broadcast, emit, refs, props, CLASS_PREFIX, parent })
|
||||
initApi({ api, state, dispatch, broadcast, emit, refs, props, CLASS_PREFIX, parent, vm })
|
||||
|
||||
const storages = useStorageBox({ api, props, reactive, toRefs })
|
||||
|
||||
|
|
Loading…
Reference in New Issue