mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types: ComponentInstance (#8154)
This commit is contained in:
parent
0fb0186fad
commit
4cb974ab02
@ -7,12 +7,11 @@ import {
|
||||
nextTick,
|
||||
PropType,
|
||||
onMounted,
|
||||
ComponentPublicInstance,
|
||||
} from 'vue';
|
||||
|
||||
// Utils
|
||||
import { deepClone } from '../utils/deep-clone';
|
||||
import { createNamespace, pick } from '../utils';
|
||||
import { pick, createNamespace, ComponentInstance } from '../utils';
|
||||
|
||||
// Composition
|
||||
import { useExpose } from '../composables/use-expose';
|
||||
@ -66,8 +65,7 @@ export default createComponent({
|
||||
emits: ['change', 'confirm'],
|
||||
|
||||
setup(props, { emit, slots }) {
|
||||
// eslint-disable-next-line
|
||||
const pickerRef = ref<ComponentPublicInstance<{}, any>>();
|
||||
const pickerRef = ref<ComponentInstance>();
|
||||
|
||||
const state = reactive({
|
||||
code: props.value,
|
||||
|
@ -1,10 +1,5 @@
|
||||
import {
|
||||
App,
|
||||
CSSProperties,
|
||||
TeleportProps,
|
||||
ComponentPublicInstance,
|
||||
} from 'vue';
|
||||
import { inBrowser } from '../utils';
|
||||
import { App, CSSProperties, TeleportProps } from 'vue';
|
||||
import { inBrowser, ComponentInstance } from '../utils';
|
||||
import { Interceptor } from '../utils/interceptor';
|
||||
import { mountComponent, usePopupState } from '../utils/mount-component';
|
||||
import VanDialog, {
|
||||
@ -38,8 +33,7 @@ export type DialogOptions = {
|
||||
closeOnClickOverlay?: boolean;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line
|
||||
let instance: ComponentPublicInstance<{}, any>;
|
||||
let instance: ComponentInstance;
|
||||
|
||||
function initInstance() {
|
||||
const Wrapper = {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ComponentPublicInstance, PropType } from 'vue';
|
||||
import { PropType } from 'vue';
|
||||
|
||||
// Utils
|
||||
import { createNamespace } from '../utils';
|
||||
import { createNamespace, ComponentInstance } from '../utils';
|
||||
|
||||
// Composition
|
||||
import { useChildren } from '@vant/use';
|
||||
@ -46,10 +46,7 @@ export default createComponent({
|
||||
emits: ['submit', 'failed'],
|
||||
|
||||
setup(props, { emit, slots }) {
|
||||
const { children, linkChildren } = useChildren<
|
||||
// eslint-disable-next-line
|
||||
ComponentPublicInstance<{}, any>
|
||||
>(FORM_KEY);
|
||||
const { children, linkChildren } = useChildren<ComponentInstance>(FORM_KEY);
|
||||
|
||||
const getFieldsByNames = (names?: string[]) => {
|
||||
if (names) {
|
||||
|
@ -53,7 +53,8 @@
|
||||
</template>
|
||||
|
||||
<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';
|
||||
|
||||
const i18n = {
|
||||
@ -87,11 +88,11 @@ export default {
|
||||
};
|
||||
|
||||
const refMap = {
|
||||
showInfo: ref<ComponentPublicInstance>(),
|
||||
addGutter: ref<ComponentPublicInstance>(),
|
||||
basicUsage: ref<ComponentPublicInstance>(),
|
||||
removeMask: ref<ComponentPublicInstance>(),
|
||||
customLength: ref<ComponentPublicInstance>(),
|
||||
showInfo: ref<ComponentInstance>(),
|
||||
addGutter: ref<ComponentInstance>(),
|
||||
basicUsage: ref<ComponentInstance>(),
|
||||
removeMask: ref<ComponentInstance>(),
|
||||
customLength: ref<ComponentInstance>(),
|
||||
};
|
||||
|
||||
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
|
||||
import { unitToPx, preventDefault, createNamespace } from '../utils';
|
||||
import {
|
||||
unitToPx,
|
||||
preventDefault,
|
||||
createNamespace,
|
||||
ComponentInstance,
|
||||
} from '../utils';
|
||||
import { BORDER_UNSET_TOP_BOTTOM } from '../utils/constant';
|
||||
|
||||
// Composition
|
||||
@ -97,10 +102,9 @@ export default createComponent({
|
||||
...props.columnsFieldNames,
|
||||
};
|
||||
|
||||
const { children, linkChildren } = useChildren<
|
||||
// eslint-disable-next-line
|
||||
ComponentPublicInstance<{}, any>
|
||||
>(PICKER_KEY);
|
||||
const { children, linkChildren } = useChildren<ComponentInstance>(
|
||||
PICKER_KEY
|
||||
);
|
||||
|
||||
linkChildren();
|
||||
|
||||
|
@ -6,14 +6,19 @@ import {
|
||||
onMounted,
|
||||
ComputedRef,
|
||||
onActivated,
|
||||
CSSProperties,
|
||||
onDeactivated,
|
||||
onBeforeUnmount,
|
||||
CSSProperties,
|
||||
ComponentPublicInstance,
|
||||
} from 'vue';
|
||||
|
||||
// Utils
|
||||
import { range, isHidden, preventDefault, createNamespace } from '../utils';
|
||||
import {
|
||||
range,
|
||||
isHidden,
|
||||
preventDefault,
|
||||
createNamespace,
|
||||
ComponentInstance,
|
||||
} from '../utils';
|
||||
|
||||
// Composition
|
||||
import {
|
||||
@ -97,10 +102,9 @@ export default createComponent({
|
||||
|
||||
const touch = useTouch();
|
||||
const windowSize = useWindowSize();
|
||||
const { children, linkChildren } = useChildren<
|
||||
// eslint-disable-next-line
|
||||
ComponentPublicInstance<{}, any>
|
||||
>(SWIPE_KEY);
|
||||
const { children, linkChildren } = useChildren<ComponentInstance>(
|
||||
SWIPE_KEY
|
||||
);
|
||||
|
||||
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 const inBrowser = typeof window !== 'undefined';
|
||||
@ -8,6 +7,8 @@ export const inBrowser = typeof window !== 'undefined';
|
||||
// unknown type for Vue prop
|
||||
export const UnknownProp = (null as unknown) as PropType<unknown>;
|
||||
|
||||
export type ComponentInstance = ComponentPublicInstance<any>;
|
||||
|
||||
export function isDef<T>(val: T): val is NonNullable<T> {
|
||||
return val !== undefined && val !== null;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* eslint-disable */
|
||||
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;
|
||||
return reg.test(value);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user