@vue/runtime-core 3.3.0-alpha.8 → 3.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/runtime-core.cjs.js +771 -669
- package/dist/runtime-core.cjs.prod.js +398 -322
- package/dist/runtime-core.d.ts +102 -22
- package/dist/runtime-core.esm-bundler.js +774 -663
- package/package.json +3 -3
package/dist/runtime-core.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ type EmitFn<Options = ObjectEmitsOptions, Event extends keyof Options = keyof Op
|
|
|
95
95
|
export interface ComponentCustomProperties {
|
|
96
96
|
}
|
|
97
97
|
type IsDefaultMixinComponent<T> = T extends ComponentOptionsMixin ? ComponentOptionsMixin extends T ? true : false : false;
|
|
98
|
-
type MixinToOptionTypes<T> = T extends ComponentOptionsBase<infer P, infer B, infer D, infer C, infer M, infer Mixin, infer Extends, any, any, any,
|
|
98
|
+
type MixinToOptionTypes<T> = T extends ComponentOptionsBase<infer P, infer B, infer D, infer C, infer M, infer Mixin, infer Extends, any, any, infer Defaults, any, any, any> ? OptionTypesType<P & {}, B & {}, D & {}, C & {}, M & {}, Defaults & {}> & IntersectionMixin<Mixin> & IntersectionMixin<Extends> : never;
|
|
99
99
|
type ExtractMixin<T> = {
|
|
100
100
|
Mixin: MixinToOptionTypes<T>;
|
|
101
101
|
}[T extends ComponentOptionsMixin ? 'Mixin' : never];
|
|
@@ -108,11 +108,11 @@ type ComponentPublicInstanceConstructor<T extends ComponentPublicInstance<Props,
|
|
|
108
108
|
__isSuspense?: never;
|
|
109
109
|
new (...args: any[]): T;
|
|
110
110
|
};
|
|
111
|
-
export type CreateComponentPublicInstance<P = {}, B = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {},
|
|
111
|
+
export type CreateComponentPublicInstance<P = {}, B = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, I extends ComponentInjectOptions = {}, S extends SlotsType = {}, PublicMixin = IntersectionMixin<Mixin> & IntersectionMixin<Extends>, PublicP = UnwrapMixinsType<PublicMixin, 'P'> & EnsureNonVoid<P>, PublicB = UnwrapMixinsType<PublicMixin, 'B'> & EnsureNonVoid<B>, PublicD = UnwrapMixinsType<PublicMixin, 'D'> & EnsureNonVoid<D>, PublicC extends ComputedOptions = UnwrapMixinsType<PublicMixin, 'C'> & EnsureNonVoid<C>, PublicM extends MethodOptions = UnwrapMixinsType<PublicMixin, 'M'> & EnsureNonVoid<M>, PublicDefaults = UnwrapMixinsType<PublicMixin, 'Defaults'> & EnsureNonVoid<Defaults>> = ComponentPublicInstance<PublicP, PublicB, PublicD, PublicC, PublicM, E, PublicProps, PublicDefaults, MakeDefaultsOptional, ComponentOptionsBase<P, B, D, C, M, Mixin, Extends, E, string, Defaults, {}, string, S>, I, S>;
|
|
112
112
|
export type ComponentPublicInstance<P = {}, // props type extracted from props option
|
|
113
113
|
B = {}, // raw bindings returned from setup()
|
|
114
114
|
D = {}, // return from data()
|
|
115
|
-
C extends ComputedOptions = {}, M extends MethodOptions = {}, E extends EmitsOptions = {},
|
|
115
|
+
C extends ComputedOptions = {}, M extends MethodOptions = {}, E extends EmitsOptions = {}, PublicProps = P, Defaults = {}, MakeDefaultsOptional extends boolean = false, Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>, I extends ComponentInjectOptions = {}, S extends SlotsType = {}> = {
|
|
116
116
|
$: ComponentInternalInstance;
|
|
117
117
|
$data: D;
|
|
118
118
|
$props: Prettify<MakeDefaultsOptional extends true ? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults> : P & PublicProps>;
|
|
@@ -151,6 +151,12 @@ export interface SuspenseProps {
|
|
|
151
151
|
onPending?: () => void;
|
|
152
152
|
onFallback?: () => void;
|
|
153
153
|
timeout?: string | number;
|
|
154
|
+
/**
|
|
155
|
+
* Allow suspense to be captured by parent suspense
|
|
156
|
+
*
|
|
157
|
+
* @default false
|
|
158
|
+
*/
|
|
159
|
+
suspensible?: boolean;
|
|
154
160
|
}
|
|
155
161
|
declare const SuspenseImpl: {
|
|
156
162
|
name: string;
|
|
@@ -190,7 +196,7 @@ export interface SuspenseBoundary {
|
|
|
190
196
|
registerDep(instance: ComponentInternalInstance, setupRenderEffect: SetupRenderEffectFn): void;
|
|
191
197
|
unmount(parentSuspense: SuspenseBoundary | null, doRemove?: boolean): void;
|
|
192
198
|
}
|
|
193
|
-
declare function createSuspenseBoundary(vnode: VNode,
|
|
199
|
+
declare function createSuspenseBoundary(vnode: VNode, parentSuspense: SuspenseBoundary | null, parentComponent: ComponentInternalInstance | null, container: RendererElement, hiddenContainer: RendererElement, anchor: RendererNode | null, isSVG: boolean, slotScopeIds: string[] | null, optimized: boolean, rendererInternals: RendererInternals, isHydrating?: boolean): SuspenseBoundary;
|
|
194
200
|
declare function hydrateSuspense(node: Node, vnode: VNode, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, isSVG: boolean, slotScopeIds: string[] | null, optimized: boolean, rendererInternals: RendererInternals, hydrateNode: (node: Node, vnode: VNode, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, slotScopeIds: string[] | null, optimized: boolean) => Node | null): Node | null;
|
|
195
201
|
declare function normalizeSuspenseChildren(vnode: VNode): void;
|
|
196
202
|
|
|
@@ -507,7 +513,7 @@ declare function checkCompatEnabled(key: DeprecationTypes, instance: ComponentIn
|
|
|
507
513
|
export interface ComponentCustomOptions {
|
|
508
514
|
}
|
|
509
515
|
export type RenderFunction = () => VNodeChild;
|
|
510
|
-
export interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string,
|
|
516
|
+
export interface ComponentOptionsBase<Props, RawBindings, D, C extends ComputedOptions, M extends MethodOptions, Mixin extends ComponentOptionsMixin, Extends extends ComponentOptionsMixin, E extends EmitsOptions, EE extends string = string, Defaults = {}, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}> extends LegacyOptions<Props, D, C, M, Mixin, Extends, I, II>, ComponentInternalOptions, ComponentCustomOptions {
|
|
511
517
|
setup?: (this: void, props: LooseRequired<Props & Prettify<UnwrapMixinsType<IntersectionMixin<Mixin> & IntersectionMixin<Extends>, 'P'>>>, ctx: SetupContext<E, S>) => Promise<RawBindings> | RawBindings | RenderFunction | void;
|
|
512
518
|
name?: string;
|
|
513
519
|
template?: string | object;
|
|
@@ -539,17 +545,17 @@ export interface RuntimeCompilerOptions {
|
|
|
539
545
|
comments?: boolean;
|
|
540
546
|
delimiters?: [string, string];
|
|
541
547
|
}
|
|
542
|
-
export type ComponentOptionsWithoutProps<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string,
|
|
548
|
+
export type ComponentOptionsWithoutProps<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, PE = Props & EmitsToProps<E>> = ComponentOptionsBase<PE, RawBindings, D, C, M, Mixin, Extends, E, EE, {}, I, II, S> & {
|
|
543
549
|
props?: undefined;
|
|
544
|
-
} & ThisType<CreateComponentPublicInstance<PE, RawBindings, D, C, M, Mixin, Extends, E,
|
|
545
|
-
export type ComponentOptionsWithArrayProps<PropNames extends string = string, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string,
|
|
550
|
+
} & ThisType<CreateComponentPublicInstance<PE, RawBindings, D, C, M, Mixin, Extends, E, PE, {}, false, I, S>>;
|
|
551
|
+
export type ComponentOptionsWithArrayProps<PropNames extends string = string, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, Props = Prettify<Readonly<{
|
|
546
552
|
[key in PropNames]?: any;
|
|
547
|
-
} & EmitsToProps<E>>>> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE,
|
|
553
|
+
} & EmitsToProps<E>>>> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, {}, I, II, S> & {
|
|
548
554
|
props: PropNames[];
|
|
549
|
-
} & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E,
|
|
550
|
-
export type ComponentOptionsWithObjectProps<PropsOptions = ComponentObjectPropsOptions, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string,
|
|
555
|
+
} & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, Props, {}, false, I, S>>;
|
|
556
|
+
export type ComponentOptionsWithObjectProps<PropsOptions = ComponentObjectPropsOptions, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string, S extends SlotsType = {}, Props = Prettify<Readonly<ExtractPropTypes<PropsOptions> & EmitsToProps<E>>>, Defaults = ExtractDefaultPropTypes<PropsOptions>> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, Defaults, I, II, S> & {
|
|
551
557
|
props: PropsOptions & ThisType<void>;
|
|
552
|
-
} & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E,
|
|
558
|
+
} & ThisType<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, Props, Defaults, false, I, S>>;
|
|
553
559
|
export type ComponentOptions<Props = {}, RawBindings = any, D = any, C extends ComputedOptions = any, M extends MethodOptions = any, Mixin extends ComponentOptionsMixin = any, Extends extends ComponentOptionsMixin = any, E extends EmitsOptions = any, S extends SlotsType = any> = ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, string, S> & ThisType<CreateComponentPublicInstance<{}, RawBindings, D, C, M, Mixin, Extends, E, Readonly<Props>>>;
|
|
554
560
|
export type ComponentOptionsMixin = ComponentOptionsBase<any, any, any, any, any, any, any, any, any, any, any>;
|
|
555
561
|
export type ComputedOptions = Record<string, ComputedGetter<any> | WritableComputedOptions<any>>;
|
|
@@ -660,6 +666,12 @@ export declare function provide<T>(key: InjectionKey<T> | string | number, value
|
|
|
660
666
|
export declare function inject<T>(key: InjectionKey<T> | string): T | undefined;
|
|
661
667
|
export declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T, treatDefaultAsFactory?: false): T;
|
|
662
668
|
export declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T | (() => T), treatDefaultAsFactory: true): T;
|
|
669
|
+
/**
|
|
670
|
+
* Returns true if `inject()` can be used without warning about being called in the wrong place (e.g. outside of
|
|
671
|
+
* setup()). This is used by libraries that want to use `inject()` internally without triggering a warning to the end
|
|
672
|
+
* user. One example is `useRoute()` in `vue-router`.
|
|
673
|
+
*/
|
|
674
|
+
export declare function hasInjectionContext(): boolean;
|
|
663
675
|
|
|
664
676
|
export interface App<HostElement = any> {
|
|
665
677
|
version: string;
|
|
@@ -674,6 +686,13 @@ export interface App<HostElement = any> {
|
|
|
674
686
|
mount(rootContainer: HostElement | string, isHydrate?: boolean, isSVG?: boolean): ComponentPublicInstance;
|
|
675
687
|
unmount(): void;
|
|
676
688
|
provide<T>(key: InjectionKey<T> | string, value: T): this;
|
|
689
|
+
/**
|
|
690
|
+
* Runs a function with the app as active instance. This allows using of `inject()` within the function to get access
|
|
691
|
+
* to variables provided via `app.provide()`.
|
|
692
|
+
*
|
|
693
|
+
* @param fn - function to run with the app as active instance
|
|
694
|
+
*/
|
|
695
|
+
runWithContext<T>(fn: () => T): T;
|
|
677
696
|
_uid: number;
|
|
678
697
|
_component: ConcreteComponent;
|
|
679
698
|
_props: Data | null;
|
|
@@ -706,7 +725,7 @@ export interface AppConfig {
|
|
|
706
725
|
isCustomElement?: (tag: string) => boolean;
|
|
707
726
|
/**
|
|
708
727
|
* Temporary config for opt-in to unwrap injected refs.
|
|
709
|
-
*
|
|
728
|
+
* @deprecated this no longer has effect. 3.3 always unwraps injected refs.
|
|
710
729
|
*/
|
|
711
730
|
unwrapInjectedRef?: boolean;
|
|
712
731
|
}
|
|
@@ -1101,6 +1120,8 @@ export interface ComponentInternalInstance {
|
|
|
1101
1120
|
slots: InternalSlots;
|
|
1102
1121
|
refs: Data;
|
|
1103
1122
|
emit: EmitFn;
|
|
1123
|
+
attrsProxy: Data | null;
|
|
1124
|
+
slotsProxy: Slots | null;
|
|
1104
1125
|
/* removed internal: emitted */
|
|
1105
1126
|
/* removed internal: propsDefaults */
|
|
1106
1127
|
/* removed internal: setupState */
|
|
@@ -1166,7 +1187,8 @@ export declare function watch<T, Immediate extends Readonly<boolean> = false>(so
|
|
|
1166
1187
|
export declare function watch<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle;
|
|
1167
1188
|
|
|
1168
1189
|
type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps;
|
|
1169
|
-
|
|
1190
|
+
type ResolveProps<PropsOrPropOptions, E extends EmitsOptions> = Readonly<PropsOrPropOptions extends ComponentPropsOptions ? ExtractPropTypes<PropsOrPropOptions> : PropsOrPropOptions> & ({} extends E ? {} : EmitsToProps<E>);
|
|
1191
|
+
export type DefineComponent<PropsOrPropOptions = {}, RawBindings = {}, D = {}, C extends ComputedOptions = ComputedOptions, M extends MethodOptions = MethodOptions, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, PP = PublicProps, Props = ResolveProps<PropsOrPropOptions, E>, Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>, S extends SlotsType = {}> = ComponentPublicInstanceConstructor<CreateComponentPublicInstance<Props, RawBindings, D, C, M, Mixin, Extends, E, PP & Props, Defaults, true, {}, S> & Props> & ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, Defaults, {}, string, S> & PP;
|
|
1170
1192
|
export declare function defineComponent<Props extends Record<string, any>, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}>(setup: (props: Props, ctx: SetupContext<E, S>) => RenderFunction | Promise<RenderFunction>, options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
|
|
1171
1193
|
props?: (keyof Props)[];
|
|
1172
1194
|
emits?: E | EE[];
|
|
@@ -1177,11 +1199,11 @@ export declare function defineComponent<Props extends Record<string, any>, E ext
|
|
|
1177
1199
|
emits?: E | EE[];
|
|
1178
1200
|
slots?: S;
|
|
1179
1201
|
}): (props: Props & EmitsToProps<E>) => any;
|
|
1180
|
-
export declare function defineComponent<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE,
|
|
1181
|
-
export declare function defineComponent<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string
|
|
1202
|
+
export declare function defineComponent<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II, S>): DefineComponent<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, PublicProps, ResolveProps<Props, E>, ExtractDefaultPropTypes<Props>, S>;
|
|
1203
|
+
export declare function defineComponent<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string, Props = Readonly<{
|
|
1182
1204
|
[key in PropNames]?: any;
|
|
1183
|
-
}
|
|
1184
|
-
export declare function defineComponent<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE,
|
|
1205
|
+
}>>(options: ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II, S>): DefineComponent<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, PublicProps, ResolveProps<Props, E>, ExtractDefaultPropTypes<Props>, S>;
|
|
1206
|
+
export declare function defineComponent<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II, S>): DefineComponent<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, PublicProps, ResolveProps<PropsOptions, E>, ExtractDefaultPropTypes<PropsOptions>, S>;
|
|
1185
1207
|
|
|
1186
1208
|
type AsyncComponentResolveResult<T = Component> = T | {
|
|
1187
1209
|
default: T;
|
|
@@ -1236,10 +1258,10 @@ export declare function defineProps<PropNames extends string = string>(props: Pr
|
|
|
1236
1258
|
[key in PropNames]?: any;
|
|
1237
1259
|
}>>;
|
|
1238
1260
|
export declare function defineProps<PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions>(props: PP): Prettify<Readonly<ExtractPropTypes<PP>>>;
|
|
1239
|
-
export declare function defineProps<TypeProps>():
|
|
1240
|
-
type
|
|
1241
|
-
[K in
|
|
1242
|
-
}
|
|
1261
|
+
export declare function defineProps<TypeProps>(): DefineProps<TypeProps>;
|
|
1262
|
+
type DefineProps<T> = Readonly<T> & {
|
|
1263
|
+
readonly [K in BooleanKey<T>]-?: boolean;
|
|
1264
|
+
};
|
|
1243
1265
|
type BooleanKey<T, K extends keyof T = keyof T> = K extends any ? [T[K]] extends [boolean | undefined] ? K : never : never;
|
|
1244
1266
|
/**
|
|
1245
1267
|
* Vue `<script setup>` compiler macro for declaring a component's emitted
|
|
@@ -1301,6 +1323,58 @@ export declare function defineOptions<RawBindings = {}, D = {}, C extends Comput
|
|
|
1301
1323
|
slots?: undefined;
|
|
1302
1324
|
}): void;
|
|
1303
1325
|
export declare function defineSlots<S extends Record<string, any> = Record<string, any>>(): TypedSlots<SlotsType<S>>;
|
|
1326
|
+
/**
|
|
1327
|
+
* (**Experimental**) Vue `<script setup>` compiler macro for declaring a
|
|
1328
|
+
* two-way binding prop that can be consumed via `v-model` from the parent
|
|
1329
|
+
* component. This will declare a prop with the same name and a corresponding
|
|
1330
|
+
* `update:propName` event.
|
|
1331
|
+
*
|
|
1332
|
+
* If the first argument is a string, it will be used as the prop name;
|
|
1333
|
+
* Otherwise the prop name will default to "modelValue". In both cases, you
|
|
1334
|
+
* can also pass an additional object which will be used as the prop's options.
|
|
1335
|
+
*
|
|
1336
|
+
* The options object can also specify an additional option, `local`. When set
|
|
1337
|
+
* to `true`, the ref can be locally mutated even if the parent did not pass
|
|
1338
|
+
* the matching `v-model`.
|
|
1339
|
+
*
|
|
1340
|
+
* @example
|
|
1341
|
+
* ```ts
|
|
1342
|
+
* // default model (consumed via `v-model`)
|
|
1343
|
+
* const modelValue = defineModel<string>()
|
|
1344
|
+
* modelValue.value = "hello"
|
|
1345
|
+
*
|
|
1346
|
+
* // default model with options
|
|
1347
|
+
* const modelValue = defineModel<stirng>({ required: true })
|
|
1348
|
+
*
|
|
1349
|
+
* // with specified name (consumed via `v-model:count`)
|
|
1350
|
+
* const count = defineModel<number>('count')
|
|
1351
|
+
* count.value++
|
|
1352
|
+
*
|
|
1353
|
+
* // with specified name and default value
|
|
1354
|
+
* const count = defineModel<number>('count', { default: 0 })
|
|
1355
|
+
*
|
|
1356
|
+
* // local mutable model, can be mutated locally
|
|
1357
|
+
* // even if the parent did not pass the matching `v-model`.
|
|
1358
|
+
* const count = defineModel<number>('count', { local: true, default: 0 })
|
|
1359
|
+
* ```
|
|
1360
|
+
*/
|
|
1361
|
+
export declare function defineModel<T>(options: {
|
|
1362
|
+
required: true;
|
|
1363
|
+
} & PropOptions<T> & DefineModelOptions): Ref<T>;
|
|
1364
|
+
export declare function defineModel<T>(options: {
|
|
1365
|
+
default: any;
|
|
1366
|
+
} & PropOptions<T> & DefineModelOptions): Ref<T>;
|
|
1367
|
+
export declare function defineModel<T>(options?: PropOptions<T> & DefineModelOptions): Ref<T | undefined>;
|
|
1368
|
+
export declare function defineModel<T>(name: string, options: {
|
|
1369
|
+
required: true;
|
|
1370
|
+
} & PropOptions<T> & DefineModelOptions): Ref<T>;
|
|
1371
|
+
export declare function defineModel<T>(name: string, options: {
|
|
1372
|
+
default: any;
|
|
1373
|
+
} & PropOptions<T> & DefineModelOptions): Ref<T>;
|
|
1374
|
+
export declare function defineModel<T>(name: string, options?: PropOptions<T> & DefineModelOptions): Ref<T | undefined>;
|
|
1375
|
+
interface DefineModelOptions {
|
|
1376
|
+
local?: boolean;
|
|
1377
|
+
}
|
|
1304
1378
|
type NotUndefined<T> = T extends undefined ? never : T;
|
|
1305
1379
|
type InferDefaults<T> = {
|
|
1306
1380
|
[K in keyof T]?: InferDefault<T, NotUndefined<T[K]>>;
|
|
@@ -1332,7 +1406,11 @@ type PropsWithDefaults<Base, Defaults> = Base & {
|
|
|
1332
1406
|
export declare function withDefaults<Props, Defaults extends InferDefaults<Props>>(props: Props, defaults: Defaults): PropsWithDefaults<Props, Defaults>;
|
|
1333
1407
|
export declare function useSlots(): SetupContext['slots'];
|
|
1334
1408
|
export declare function useAttrs(): SetupContext['attrs'];
|
|
1409
|
+
export declare function useModel<T extends Record<string, any>, K extends keyof T>(props: T, name: K, options?: {
|
|
1410
|
+
local?: boolean;
|
|
1411
|
+
}): Ref<T[K]>;
|
|
1335
1412
|
/* removed internal: mergeDefaults */
|
|
1413
|
+
/* removed internal: mergeModels */
|
|
1336
1414
|
/* removed internal: createPropsRestProxy */
|
|
1337
1415
|
/* removed internal: withAsyncContext */
|
|
1338
1416
|
|
|
@@ -1626,6 +1704,7 @@ type _defineEmits = typeof defineEmits
|
|
|
1626
1704
|
type _defineExpose = typeof defineExpose
|
|
1627
1705
|
type _defineOptions = typeof defineOptions
|
|
1628
1706
|
type _defineSlots = typeof defineSlots
|
|
1707
|
+
type _defineModel = typeof defineModel
|
|
1629
1708
|
type _withDefaults = typeof withDefaults
|
|
1630
1709
|
|
|
1631
1710
|
declare global {
|
|
@@ -1634,5 +1713,6 @@ declare global {
|
|
|
1634
1713
|
const defineExpose: _defineExpose
|
|
1635
1714
|
const defineOptions: _defineOptions
|
|
1636
1715
|
const defineSlots: _defineSlots
|
|
1716
|
+
const defineModel: _defineModel
|
|
1637
1717
|
const withDefaults: _withDefaults
|
|
1638
1718
|
}
|