Add default as prop type for when as= is not provided
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
type TDialogProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
open?: boolean;
|
||||
initialFocus?: HTMLElement | null;
|
||||
static?: boolean;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TDialogOverlayProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TDialogTitleProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "h2"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
type TDisclosureProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
defaultOpen?: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TDisclosureButtonProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "button"> & {
|
||||
disabled?: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
type TDisclosurePanelProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
unmount?: boolean;
|
||||
static?: boolean;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
type TListboxProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
disabled?: boolean;
|
||||
horizontal?: boolean;
|
||||
value?: StateDefinition["value"];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TListboxButtonProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "button"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TListboxLabelProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "label"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TListboxOptionProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "li"> & {
|
||||
value: unknown;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TListboxOptionsProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "ul"> & {
|
||||
unmount?: boolean;
|
||||
static?: boolean;
|
||||
};
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
type TMenuProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TMenuButtonProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "button"> & {
|
||||
disabled?: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TMenuItemProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "a"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TMenuItemsProps<
|
||||
TSlotProp extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProp, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProp, TAsProp, "div"> & {
|
||||
static?: boolean;
|
||||
unmount?: boolean;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
type TPopoverProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TPopoverButtonProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "button"> & {
|
||||
disabled?: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
type TPopoverGroupProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TPopoverOverlayProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
type TPopoverPanelProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
focus?: boolean;
|
||||
static?: boolean;
|
||||
unmount?: boolean;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
type TRadioGroupProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
value: StateDefinition["value"];
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TRadioGroupOptionProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
value: unknown;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TSwitchProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "button"> & {
|
||||
checked: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
type TSwitchGroupProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TTabProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "button"> & {
|
||||
disabled?: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
type TTabGroupProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {
|
||||
defaultIndex?: number;
|
||||
vertical?: boolean;
|
||||
manual?: boolean;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TTabListProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TTabPanelProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
type TTabPanelsProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
> = TPassThroughProps<TSlotProps, TAsProp, "div"> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<script lang="ts" context="module">
|
||||
export type TTransitionChildProps<TAsProp extends SupportedAs> =
|
||||
TPassThroughProps<{}, TAsProp> & {
|
||||
enter?: string;
|
||||
enterFrom?: string;
|
||||
enterTo?: string;
|
||||
entered?: string;
|
||||
leave?: string;
|
||||
leaveFrom?: string;
|
||||
leaveTo?: string;
|
||||
unmount?: boolean;
|
||||
class?: string;
|
||||
};
|
||||
export type TTransitionChildProps<
|
||||
TAsProp extends SupportedAs,
|
||||
TDefaultAs
|
||||
> = TPassThroughProps<{}, TAsProp, TDefaultAs> & {
|
||||
enter?: string;
|
||||
enterFrom?: string;
|
||||
enterTo?: string;
|
||||
entered?: string;
|
||||
leave?: string;
|
||||
leaveFrom?: string;
|
||||
leaveTo?: string;
|
||||
unmount?: boolean;
|
||||
class?: string;
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -41,7 +43,7 @@
|
||||
|
||||
/***** Props *****/
|
||||
type TAsProp = $$Generic<SupportedAs>;
|
||||
type $$Props = TTransitionChildProps<TAsProp>;
|
||||
type $$Props = TTransitionChildProps<TAsProp, "div">;
|
||||
|
||||
export let as: SupportedAs = "div";
|
||||
export let use: HTMLActionArray = [];
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
/***** Props *****/
|
||||
|
||||
type TAsProp = $$Generic<SupportedAs>;
|
||||
type $$Props = TTransitionRootProps<TAsProp>;
|
||||
type $$Props = TTransitionRootProps<TAsProp, "div">;
|
||||
|
||||
export let as: SupportedAs = "div";
|
||||
export let use: HTMLActionArray = [];
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script lang="ts" context="module">
|
||||
export type TTransitionRootProps<TAsProp extends SupportedAs> =
|
||||
TTransitionChildProps<TAsProp> & {
|
||||
show?: boolean;
|
||||
appear?: boolean;
|
||||
};
|
||||
export type TTransitionRootProps<
|
||||
TAsProp extends SupportedAs,
|
||||
TDefaultAs
|
||||
> = TTransitionChildProps<TAsProp, TDefaultAs> & {
|
||||
show?: boolean;
|
||||
appear?: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -38,7 +40,7 @@
|
||||
|
||||
/***** Props *****/
|
||||
type TAsProp = $$Generic<SupportedAs>;
|
||||
type $$Props = TTransitionRootProps<TAsProp>;
|
||||
type $$Props = TTransitionRootProps<TAsProp, "div">;
|
||||
|
||||
export let as: SupportedAs = "div";
|
||||
export let use: HTMLActionArray = [];
|
||||
|
||||
@@ -35,10 +35,14 @@
|
||||
>
|
||||
: {};
|
||||
|
||||
type TResolveAs<TAsProp, TDefaultAs> = SupportedAs extends TAsProp
|
||||
? TDefaultAs
|
||||
: TAsProp;
|
||||
type TRenderProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TRestProps<TAsProp> & {
|
||||
TAsProp extends SupportedAs,
|
||||
TDefaultAs
|
||||
> = TRestProps<TResolveAs<TAsProp, TDefaultAs>> & {
|
||||
name: string;
|
||||
as: TAsProp;
|
||||
slotProps: TSlotProps;
|
||||
@@ -56,9 +60,10 @@
|
||||
|
||||
export type TPassThroughProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
TAsProp extends SupportedAs,
|
||||
TDefaultAs
|
||||
> = Omit<
|
||||
TRenderProps<TSlotProps, TAsProp>,
|
||||
TRenderProps<TSlotProps, TAsProp, TDefaultAs>,
|
||||
TInternalProps | "as" | "static" | "unmount"
|
||||
> & {
|
||||
as?: TAsProp;
|
||||
@@ -72,7 +77,7 @@
|
||||
|
||||
type TSlotProps = $$Generic<{}>;
|
||||
type TAsProp = $$Generic<SupportedAs>;
|
||||
type $$Props = TRenderProps<TSlotProps, TAsProp>;
|
||||
type $$Props = TRenderProps<TSlotProps, TAsProp, TAsProp>;
|
||||
|
||||
export let name: string;
|
||||
export let as: TAsProp;
|
||||
|
||||
Reference in New Issue
Block a user