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:
@@ -9,13 +9,13 @@ import { useId } from '../config-provider';
|
||||
import { Primitive } from '../primitive';
|
||||
import { provideMenuGroupContext } from './context';
|
||||
|
||||
const { as = 'div', asChild } = defineProps<MenuGroupProps>();
|
||||
const { as = 'div' } = defineProps<MenuGroupProps>();
|
||||
const id = useId(undefined, 'menu-group');
|
||||
provideMenuGroupContext({ id: id.value });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive :as="as" :as-child="asChild" role="group" :id="id">
|
||||
<Primitive :as="as" role="group" :id="id">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
|
||||
@@ -21,7 +21,6 @@ const {
|
||||
disabled = false,
|
||||
textValue: textValueProp,
|
||||
as = 'div',
|
||||
asChild,
|
||||
} = defineProps<MenuItemImplProps>();
|
||||
|
||||
const emit = defineEmits<MenuItemImplEmits>();
|
||||
@@ -71,11 +70,10 @@ function handleKeyDown(event: KeyboardEvent) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RovingFocusItem as-child :focusable="!disabled" :active="isHighlighted">
|
||||
<RovingFocusItem :focusable="!disabled" :active="isHighlighted">
|
||||
<Primitive
|
||||
:ref="(el: unknown) => { itemRef = el as HTMLElement | null }"
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
role="menuitem"
|
||||
data-primitives-menu-item=""
|
||||
:data-primitive-menu-item-text-value="textValue"
|
||||
|
||||
@@ -14,7 +14,7 @@ import { Primitive } from '../primitive';
|
||||
import { useMenuItemIndicatorContext } from './context';
|
||||
import { getCheckedState, isIndeterminate } from './utils';
|
||||
|
||||
const { as = 'span', asChild, forceMount = false } = defineProps<MenuItemIndicatorProps>();
|
||||
const { as = 'span', forceMount = false } = defineProps<MenuItemIndicatorProps>();
|
||||
const ctx = useMenuItemIndicatorContext();
|
||||
const isPresent = computed(() => ctx.checkedState.value === true || isIndeterminate(ctx.checkedState.value));
|
||||
</script>
|
||||
@@ -23,7 +23,6 @@ const isPresent = computed(() => ctx.checkedState.value === true || isIndetermin
|
||||
<Presence :present="forceMount || isPresent">
|
||||
<Primitive
|
||||
:as="as"
|
||||
:as-child="asChild"
|
||||
:data-state="getCheckedState(ctx.checkedState.value)"
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -7,11 +7,11 @@ export interface MenuLabelProps extends PrimitiveProps {}
|
||||
<script setup lang="ts">
|
||||
import { Primitive } from '../primitive';
|
||||
|
||||
const { as = 'div', asChild } = defineProps<MenuLabelProps>();
|
||||
const { as = 'div' } = defineProps<MenuLabelProps>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive :as="as" :as-child="asChild">
|
||||
<Primitive :as="as">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
|
||||
@@ -16,7 +16,7 @@ import { computed, ref } from 'vue';
|
||||
import { Primitive } from '../primitive';
|
||||
import { provideMenuRadioGroupContext } from './context';
|
||||
|
||||
const { modelValue, defaultValue, as = 'div', asChild } = defineProps<MenuRadioGroupProps>();
|
||||
const { modelValue, defaultValue, as = 'div' } = defineProps<MenuRadioGroupProps>();
|
||||
const emit = defineEmits<MenuRadioGroupEmits>();
|
||||
|
||||
const local = ref(defaultValue);
|
||||
@@ -32,7 +32,7 @@ provideMenuRadioGroupContext({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive :as="as" :as-child="asChild" role="group">
|
||||
<Primitive :as="as" role="group">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
|
||||
@@ -7,11 +7,11 @@ export interface MenuSeparatorProps extends PrimitiveProps {}
|
||||
<script setup lang="ts">
|
||||
import { Primitive } from '../primitive';
|
||||
|
||||
const { as = 'div', asChild } = defineProps<MenuSeparatorProps>();
|
||||
const { as = 'div' } = defineProps<MenuSeparatorProps>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Primitive :as="as" :as-child="asChild" role="separator" aria-orientation="horizontal">
|
||||
<Primitive :as="as" role="separator" aria-orientation="horizontal">
|
||||
<slot />
|
||||
</Primitive>
|
||||
</template>
|
||||
|
||||
@@ -26,7 +26,7 @@ const triggerId = useId(undefined, 'menu-sub-trigger');
|
||||
provideMenuContext({
|
||||
open: openRef,
|
||||
onOpenChange: v => emit('update:open', v),
|
||||
content: shallowRef(null),
|
||||
content: shallowRef<HTMLElement | null>(null),
|
||||
onContentChange: () => {},
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ export interface MenuSubTriggerProps extends MenuItemImplProps {}
|
||||
import { PopperAnchor } from '../popper';
|
||||
import { useMenuContentContext, useMenuContext, useMenuRootContext, useMenuSubContext } from './context';
|
||||
import MenuItemImpl from './MenuItemImpl.vue';
|
||||
import { SUB_CLOSE_KEYS, SUB_OPEN_KEYS, getOpenState, isPointerInGraceArea } from './utils';
|
||||
import { SUB_CLOSE_KEYS, SUB_OPEN_KEYS, getOpenState } from './utils';
|
||||
|
||||
const props = defineProps<MenuSubTriggerProps>();
|
||||
|
||||
@@ -62,7 +62,7 @@ function handleKeyDown(event: KeyboardEvent) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<PopperAnchor as-child>
|
||||
<PopperAnchor>
|
||||
<MenuItemImpl
|
||||
v-bind="props"
|
||||
:id="subCtx.triggerId.value"
|
||||
|
||||
Reference in New Issue
Block a user