refactor(types): mark internal API exports and exclude from d.ts
BREAKING CHANGE: Internal APIs are now excluded from type decalrations.
This commit is contained in:
@@ -2,6 +2,6 @@
|
||||
"extends": "../../api-extractor.json",
|
||||
"mainEntryPointFilePath": "./dist/packages/<unscopedPackageName>/src/index.d.ts",
|
||||
"dtsRollup": {
|
||||
"untrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
|
||||
"publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,11 @@ function toNumber(val: string): number | 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.
|
||||
// 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
|
||||
*/
|
||||
export const vModelText: ModelDirective<
|
||||
HTMLInputElement | HTMLTextAreaElement
|
||||
> = {
|
||||
@@ -90,6 +94,9 @@ export const vModelText: ModelDirective<
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
|
||||
beforeMount(el, binding, vnode) {
|
||||
setChecked(el, binding, vnode)
|
||||
@@ -135,6 +142,9 @@ function setChecked(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const vModelRadio: ModelDirective<HTMLInputElement> = {
|
||||
beforeMount(el, { value }, vnode) {
|
||||
el.checked = looseEqual(value, vnode.props!.value)
|
||||
@@ -151,6 +161,9 @@ 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) {
|
||||
@@ -212,6 +225,9 @@ function getCheckboxValue(
|
||||
return key in el ? el[key] : checked
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const vModelDynamic: ObjectDirective<
|
||||
HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement
|
||||
> = {
|
||||
|
||||
@@ -22,6 +22,9 @@ const modifierGuards: Record<
|
||||
systemModifiers.some(m => (e as any)[`${m}Key`] && !modifiers.includes(m))
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const withModifiers = (fn: Function, modifiers: string[]) => {
|
||||
return (event: Event) => {
|
||||
for (let i = 0; i < modifiers.length; i++) {
|
||||
@@ -44,6 +47,9 @@ const keyNames: Record<string, string | string[]> = {
|
||||
delete: 'backspace'
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const withKeys = (fn: Function, modifiers: string[]) => {
|
||||
return (event: KeyboardEvent) => {
|
||||
if (!('key' in event)) return
|
||||
|
||||
@@ -5,6 +5,9 @@ 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
|
||||
|
||||
@@ -109,7 +109,14 @@ function normalizeContainer(container: Element | string): Element | null {
|
||||
return container
|
||||
}
|
||||
|
||||
// DOM-only runtime directive helpers
|
||||
// DOM-only components
|
||||
export { Transition, TransitionProps } from './components/Transition'
|
||||
export {
|
||||
TransitionGroup,
|
||||
TransitionGroupProps
|
||||
} from './components/TransitionGroup'
|
||||
|
||||
// **Internal** DOM-only runtime directive helpers
|
||||
export {
|
||||
vModelText,
|
||||
vModelCheckbox,
|
||||
@@ -120,13 +127,6 @@ export {
|
||||
export { withModifiers, withKeys } from './directives/vOn'
|
||||
export { vShow } from './directives/vShow'
|
||||
|
||||
// DOM-only components
|
||||
export { Transition, TransitionProps } from './components/Transition'
|
||||
export {
|
||||
TransitionGroup,
|
||||
TransitionGroupProps
|
||||
} from './components/TransitionGroup'
|
||||
|
||||
// re-export everything from core
|
||||
// h, Component, reactivity API, nextTick, flags & types
|
||||
export * from '@vue/runtime-core'
|
||||
|
||||
Reference in New Issue
Block a user