refactor(editor): Port more components over to composition API (no-changelog) (#8794)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-03-14 09:19:28 +01:00
committed by GitHub
parent edce632ee6
commit e2131b9ab6
48 changed files with 1115 additions and 1630 deletions

View File

@@ -143,7 +143,7 @@ const props = withDefaults(defineProps<Props>(), {
tagSize: 'small',
});
const emit = defineEmits<{
const $emit = defineEmits<{
(event: 'validate', shouldValidate: boolean): void;
(event: 'update:modelValue', value: unknown): void;
(event: 'focus'): void;
@@ -203,22 +203,22 @@ function getInputValidationError(): ReturnType<IValidator['validate']> {
function onBlur() {
state.hasBlurred = true;
state.isTyping = false;
emit('blur');
$emit('blur');
}
function onUpdateModelValue(value: FormState) {
state.isTyping = true;
emit('update:modelValue', value);
$emit('update:modelValue', value);
}
function onFocus() {
emit('focus');
$emit('focus');
}
function onEnter(event: Event) {
event.stopPropagation();
event.preventDefault();
emit('enter');
$emit('enter');
}
const validationError = computed<string | null>(() => {
@@ -244,14 +244,14 @@ const showErrors = computed(
);
onMounted(() => {
emit('validate', !validationError.value);
$emit('validate', !validationError.value);
if (props.focusInitially && inputRef.value) inputRef.value.focus();
});
watch(
() => validationError.value,
(error) => emit('validate', !error),
(error) => $emit('validate', !error),
);
defineExpose({ inputRef });