feat(types): adjust type exports for manual render function and tooling usage

- v-model and v-show directives are now exposed as public
- compiler-used runtime helpers are now exposed for TS tooling, but marked as @private

close #1329
This commit is contained in:
Evan You
2020-06-10 14:57:21 -04:00
parent 9b5d13e598
commit e4dc03a8b1
13 changed files with 40 additions and 45 deletions

View File

@@ -42,11 +42,7 @@ function trigger(el: HTMLElement, type: string) {
type ModelDirective<T> = ObjectDirective<T & { _assign: AssignerFn }>
// We are exporting the v-model runtime directly as vnode hooks so that it can
// be tree-shaken in case v-model is never used. These are used by compilers
// only and userland code should avoid relying on them.
/**
* @internal
*/
// be tree-shaken in case v-model is never used.
export const vModelText: ModelDirective<
HTMLInputElement | HTMLTextAreaElement
> = {
@@ -96,9 +92,6 @@ export const vModelText: ModelDirective<
}
}
/**
* @internal
*/
export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
beforeMount(el, binding, vnode) {
setChecked(el, binding, vnode)
@@ -144,9 +137,6 @@ function setChecked(
}
}
/**
* @internal
*/
export const vModelRadio: ModelDirective<HTMLInputElement> = {
beforeMount(el, { value }, vnode) {
el.checked = looseEqual(value, vnode.props!.value)
@@ -163,9 +153,6 @@ export const vModelRadio: ModelDirective<HTMLInputElement> = {
}
}
/**
* @internal
*/
export const vModelSelect: ModelDirective<HTMLSelectElement> = {
// use mounted & updated because <select> relies on its children <option>s.
mounted(el, { value }, vnode) {
@@ -227,9 +214,6 @@ function getCheckboxValue(
return key in el ? el[key] : checked
}
/**
* @internal
*/
export const vModelDynamic: ObjectDirective<
HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
> = {

View File

@@ -23,7 +23,7 @@ const modifierGuards: Record<
}
/**
* @internal
* @private
*/
export const withModifiers = (fn: Function, modifiers: string[]) => {
return (event: Event, ...args: unknown[]) => {
@@ -48,7 +48,7 @@ const keyNames: Record<string, string | string[]> = {
}
/**
* @internal
* @private
*/
export const withKeys = (fn: Function, modifiers: string[]) => {
return (event: KeyboardEvent) => {

View File

@@ -5,9 +5,6 @@ interface VShowElement extends HTMLElement {
_vod: string
}
/**
* @internal
*/
export const vShow: ObjectDirective<VShowElement> = {
beforeMount(el, { value }, { transition }) {
el._vod = el.style.display === 'none' ? '' : el.style.display