mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-28 12:26:35 +08:00
types: ComponentInstance (#8154)
This commit is contained in:
parent
0fb0186fad
commit
4cb974ab02
@ -7,12 +7,11 @@ import {
|
|||||||
nextTick,
|
nextTick,
|
||||||
PropType,
|
PropType,
|
||||||
onMounted,
|
onMounted,
|
||||||
ComponentPublicInstance,
|
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { deepClone } from '../utils/deep-clone';
|
import { deepClone } from '../utils/deep-clone';
|
||||||
import { createNamespace, pick } from '../utils';
|
import { pick, createNamespace, ComponentInstance } from '../utils';
|
||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
import { useExpose } from '../composables/use-expose';
|
import { useExpose } from '../composables/use-expose';
|
||||||
@ -66,8 +65,7 @@ export default createComponent({
|
|||||||
emits: ['change', 'confirm'],
|
emits: ['change', 'confirm'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
// eslint-disable-next-line
|
const pickerRef = ref<ComponentInstance>();
|
||||||
const pickerRef = ref<ComponentPublicInstance<{}, any>>();
|
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
code: props.value,
|
code: props.value,
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
import {
|
import { App, CSSProperties, TeleportProps } from 'vue';
|
||||||
App,
|
import { inBrowser, ComponentInstance } from '../utils';
|
||||||
CSSProperties,
|
|
||||||
TeleportProps,
|
|
||||||
ComponentPublicInstance,
|
|
||||||
} from 'vue';
|
|
||||||
import { inBrowser } from '../utils';
|
|
||||||
import { Interceptor } from '../utils/interceptor';
|
import { Interceptor } from '../utils/interceptor';
|
||||||
import { mountComponent, usePopupState } from '../utils/mount-component';
|
import { mountComponent, usePopupState } from '../utils/mount-component';
|
||||||
import VanDialog, {
|
import VanDialog, {
|
||||||
@ -38,8 +33,7 @@ export type DialogOptions = {
|
|||||||
closeOnClickOverlay?: boolean;
|
closeOnClickOverlay?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line
|
let instance: ComponentInstance;
|
||||||
let instance: ComponentPublicInstance<{}, any>;
|
|
||||||
|
|
||||||
function initInstance() {
|
function initInstance() {
|
||||||
const Wrapper = {
|
const Wrapper = {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ComponentPublicInstance, PropType } from 'vue';
|
import { PropType } from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { createNamespace } from '../utils';
|
import { createNamespace, ComponentInstance } from '../utils';
|
||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
import { useChildren } from '@vant/use';
|
import { useChildren } from '@vant/use';
|
||||||
@ -46,10 +46,7 @@ export default createComponent({
|
|||||||
emits: ['submit', 'failed'],
|
emits: ['submit', 'failed'],
|
||||||
|
|
||||||
setup(props, { emit, slots }) {
|
setup(props, { emit, slots }) {
|
||||||
const { children, linkChildren } = useChildren<
|
const { children, linkChildren } = useChildren<ComponentInstance>(FORM_KEY);
|
||||||
// eslint-disable-next-line
|
|
||||||
ComponentPublicInstance<{}, any>
|
|
||||||
>(FORM_KEY);
|
|
||||||
|
|
||||||
const getFieldsByNames = (names?: string[]) => {
|
const getFieldsByNames = (names?: string[]) => {
|
||||||
if (names) {
|
if (names) {
|
||||||
|
@ -53,7 +53,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ComponentPublicInstance, reactive, ref, toRefs, watch } from 'vue';
|
import { reactive, ref, toRefs, watch } from 'vue';
|
||||||
|
import { ComponentInstance } from '../../utils';
|
||||||
import { useTranslate } from '@demo/use-translate';
|
import { useTranslate } from '@demo/use-translate';
|
||||||
|
|
||||||
const i18n = {
|
const i18n = {
|
||||||
@ -87,11 +88,11 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const refMap = {
|
const refMap = {
|
||||||
showInfo: ref<ComponentPublicInstance>(),
|
showInfo: ref<ComponentInstance>(),
|
||||||
addGutter: ref<ComponentPublicInstance>(),
|
addGutter: ref<ComponentInstance>(),
|
||||||
basicUsage: ref<ComponentPublicInstance>(),
|
basicUsage: ref<ComponentInstance>(),
|
||||||
removeMask: ref<ComponentPublicInstance>(),
|
removeMask: ref<ComponentInstance>(),
|
||||||
customLength: ref<ComponentPublicInstance>(),
|
customLength: ref<ComponentInstance>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
type ValueKeys = keyof typeof initialValue;
|
type ValueKeys = keyof typeof initialValue;
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import { ref, watch, computed, PropType, ComponentPublicInstance } from 'vue';
|
import { ref, watch, computed, PropType } from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { unitToPx, preventDefault, createNamespace } from '../utils';
|
import {
|
||||||
|
unitToPx,
|
||||||
|
preventDefault,
|
||||||
|
createNamespace,
|
||||||
|
ComponentInstance,
|
||||||
|
} from '../utils';
|
||||||
import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant';
|
import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant';
|
||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
@ -97,10 +102,9 @@ export default createComponent({
|
|||||||
...props.columnsFieldNames,
|
...props.columnsFieldNames,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { children, linkChildren } = useChildren<
|
const { children, linkChildren } = useChildren<ComponentInstance>(
|
||||||
// eslint-disable-next-line
|
PICKER_KEY
|
||||||
ComponentPublicInstance<{}, any>
|
);
|
||||||
>(PICKER_KEY);
|
|
||||||
|
|
||||||
linkChildren();
|
linkChildren();
|
||||||
|
|
||||||
|
@ -6,14 +6,19 @@ import {
|
|||||||
onMounted,
|
onMounted,
|
||||||
ComputedRef,
|
ComputedRef,
|
||||||
onActivated,
|
onActivated,
|
||||||
|
CSSProperties,
|
||||||
onDeactivated,
|
onDeactivated,
|
||||||
onBeforeUnmount,
|
onBeforeUnmount,
|
||||||
CSSProperties,
|
|
||||||
ComponentPublicInstance,
|
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { range, isHidden, preventDefault, createNamespace } from '../utils';
|
import {
|
||||||
|
range,
|
||||||
|
isHidden,
|
||||||
|
preventDefault,
|
||||||
|
createNamespace,
|
||||||
|
ComponentInstance,
|
||||||
|
} from '../utils';
|
||||||
|
|
||||||
// Composition
|
// Composition
|
||||||
import {
|
import {
|
||||||
@ -97,10 +102,9 @@ export default createComponent({
|
|||||||
|
|
||||||
const touch = useTouch();
|
const touch = useTouch();
|
||||||
const windowSize = useWindowSize();
|
const windowSize = useWindowSize();
|
||||||
const { children, linkChildren } = useChildren<
|
const { children, linkChildren } = useChildren<ComponentInstance>(
|
||||||
// eslint-disable-next-line
|
SWIPE_KEY
|
||||||
ComponentPublicInstance<{}, any>
|
);
|
||||||
>(SWIPE_KEY);
|
|
||||||
|
|
||||||
const count = computed(() => children.length);
|
const count = computed(() => children.length);
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { PropType } from 'vue';
|
import { PropType, ComponentPublicInstance } from 'vue';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
||||||
export function noop() {}
|
export function noop() {}
|
||||||
|
|
||||||
export const inBrowser = typeof window !== 'undefined';
|
export const inBrowser = typeof window !== 'undefined';
|
||||||
@ -8,6 +7,8 @@ export const inBrowser = typeof window !== 'undefined';
|
|||||||
// unknown type for Vue prop
|
// unknown type for Vue prop
|
||||||
export const UnknownProp = (null as unknown) as PropType<unknown>;
|
export const UnknownProp = (null as unknown) as PropType<unknown>;
|
||||||
|
|
||||||
|
export type ComponentInstance = ComponentPublicInstance<any>;
|
||||||
|
|
||||||
export function isDef<T>(val: T): val is NonNullable<T> {
|
export function isDef<T>(val: T): val is NonNullable<T> {
|
||||||
return val !== undefined && val !== null;
|
return val !== undefined && val !== null;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable */
|
|
||||||
export function isEmail(value: string): boolean {
|
export function isEmail(value: string): boolean {
|
||||||
|
// eslint-disable-next-line
|
||||||
const reg = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
|
const reg = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
|
||||||
return reg.test(value);
|
return reg.test(value);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user