Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/renderless/src/input/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()

Expand Down
11 changes: 7 additions & 4 deletions packages/renderless/src/input/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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 }),
Expand Down Expand Up @@ -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 })

Expand Down