fix(primitives): eslint/tsconfig migration, asChild refactor, type fixes
- Migrate to eslint flat config + composite tsconfig. - Complete the asChild→as="template" refactor (remove asChild prop + :as-child bindings across components, matching Primitive's slot model). - Fix test type errors and source type-safety (useGraceArea hull/point math, FocusScope/util ref typing). Note: ~53 vue-tsc errors remain (HTML attr/event passthrough typing on transparent wrapper components + a couple of duplicate-export naming collisions) — not gated by CI (build/lint/test green); pending a component-attribute-typing design decision.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<script lang="ts">
|
||||
import type { DialogContentEmits, DialogContentProps } from '../dialog';
|
||||
|
||||
export interface AlertDialogContentProps extends Omit<DialogContentProps, 'role'> {}
|
||||
export type AlertDialogContentEmits = DialogContentEmits;
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DialogContent } from '../dialog';
|
||||
|
||||
const props = defineProps<AlertDialogContentProps>();
|
||||
const emit = defineEmits<AlertDialogContentEmits>();
|
||||
|
||||
function onOpenAutoFocus(event: Event) {
|
||||
emit('openAutoFocus', event);
|
||||
if (event.defaultPrevented) return;
|
||||
queueMicrotask(() => {
|
||||
const content = document.querySelector<HTMLElement>('[data-alert-dialog-content]');
|
||||
const cancel = content?.querySelector<HTMLElement>('[data-alert-dialog-cancel]');
|
||||
if (cancel) {
|
||||
event.preventDefault();
|
||||
cancel.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DialogContent
|
||||
v-bind="props"
|
||||
role="alertdialog"
|
||||
data-alert-dialog-content
|
||||
@open-auto-focus="onOpenAutoFocus"
|
||||
@close-auto-focus="emit('closeAutoFocus', $event)"
|
||||
@escape-key-down="emit('escapeKeyDown', $event)"
|
||||
@pointer-down-outside="(e: PointerEvent | MouseEvent) => { e.preventDefault(); emit('pointerDownOutside', e); }"
|
||||
@focus-outside="(e: FocusEvent) => { e.preventDefault(); emit('focusOutside', e); }"
|
||||
@interact-outside="emit('interactOutside', $event)"
|
||||
@dismiss="emit('dismiss')"
|
||||
>
|
||||
<slot />
|
||||
</DialogContent>
|
||||
</template>
|
||||
Reference in New Issue
Block a user