chore: migrate to useCustomFieldValue (#9201)

This commit is contained in:
neverland
2021-08-07 16:22:02 +08:00
committed by GitHub
parent 6de05f45d2
commit 1bfcbab2fa
36 changed files with 113 additions and 103 deletions
+7 -7
View File
@@ -16,6 +16,7 @@ import {
isDef,
extend,
addUnit,
FORM_KEY,
unknownProp,
resetScroll,
formatNumber,
@@ -34,9 +35,8 @@ import {
import { cellProps } from '../cell/Cell';
// Composables
import { useParent } from '@vant/use';
import { CUSTOM_FIELD_INJECTION_KEY, useParent } from '@vant/use';
import { useExpose } from '../composables/use-expose';
import { FORM_KEY, FIELD_KEY } from '../composables/use-link-field';
// Components
import { Icon } from '../icon';
@@ -146,7 +146,7 @@ export default defineComponent({
});
const inputRef = ref<HTMLInputElement>();
const childFieldValue = ref<() => unknown>();
const customValue = ref<() => unknown>();
const { parent: form } = useParent(FORM_KEY);
@@ -176,8 +176,8 @@ export default defineComponent({
});
const formValue = computed(() => {
if (childFieldValue.value && slots.input) {
return childFieldValue.value();
if (customValue.value && slots.input) {
return customValue.value();
}
return props.modelValue;
});
@@ -522,8 +522,8 @@ export default defineComponent({
resetValidation,
});
provide(FIELD_KEY, {
childFieldValue,
provide(CUSTOM_FIELD_INJECTION_KEY, {
customValue,
resetValidation,
validateWithTrigger,
});
+1 -7
View File
@@ -1,4 +1,4 @@
import type { ComponentPublicInstance, ComputedRef, Ref } from 'vue';
import type { ComputedRef, ComponentPublicInstance } from 'vue';
import type { FieldProps } from './Field';
export type FieldType =
@@ -40,12 +40,6 @@ export type FieldRule = {
formatter?: (value: any, rule: FieldRule) => string;
};
export type FieldProvide = {
childFieldValue: Ref<(() => unknown) | undefined>;
resetValidation: () => void;
validateWithTrigger: (trigger: FieldValidateTrigger) => void;
};
// Shared props of Field and Form
export type FieldFormSharedProps =
| 'colon'