Type Dialog with $$Props
This commit is contained in:
@@ -37,6 +37,16 @@
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
type TDialogProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {
|
||||
open?: boolean;
|
||||
initialFocus?: HTMLElement | null;
|
||||
static?: boolean;
|
||||
unmount?: boolean;
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -60,20 +70,29 @@
|
||||
import { get_current_component } from "svelte/internal";
|
||||
import type { SupportedAs } from "$lib/internal/elements";
|
||||
import type { HTMLActionArray } from "$lib/hooks/use-actions";
|
||||
import Render, { Features } from "$lib/utils/Render.svelte";
|
||||
import Render, {
|
||||
Features,
|
||||
type TPassThroughProps,
|
||||
} from "$lib/utils/Render.svelte";
|
||||
|
||||
/***** Props *****/
|
||||
type TAsProp = $$Generic<SupportedAs>;
|
||||
type $$Props = TDialogProps<typeof slotProps, TAsProp>;
|
||||
|
||||
export let as: SupportedAs = "div";
|
||||
export let use: HTMLActionArray = [];
|
||||
export let open: boolean | undefined = undefined;
|
||||
export let initialFocus: HTMLElement | null = null;
|
||||
|
||||
/***** Events *****/
|
||||
const forwardEvents = forwardEventsBuilder(get_current_component(), [
|
||||
"close",
|
||||
]);
|
||||
export let as: SupportedAs = "div";
|
||||
export let use: HTMLActionArray = [];
|
||||
|
||||
export let open: Boolean | undefined = undefined;
|
||||
export let initialFocus: HTMLElement | null = null;
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
close: boolean;
|
||||
}>();
|
||||
|
||||
/***** Component *****/
|
||||
let containers: Set<HTMLElement> = new Set();
|
||||
let openClosedState = useOpenClosed();
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
<script lang="ts" context="module">
|
||||
type TDialogOverlayProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { DialogStates, useDialogContext } from "./Dialog.svelte";
|
||||
import { useId } from "$lib/hooks/use-id";
|
||||
@@ -5,12 +12,20 @@
|
||||
import { get_current_component } from "svelte/internal";
|
||||
import type { SupportedAs } from "$lib/internal/elements";
|
||||
import type { HTMLActionArray } from "$lib/hooks/use-actions";
|
||||
import Render from "$lib/utils/Render.svelte";
|
||||
const forwardEvents = forwardEventsBuilder(get_current_component());
|
||||
import Render, { type TPassThroughProps } from "$lib/utils/Render.svelte";
|
||||
|
||||
/***** Props *****/
|
||||
type TAsProp = $$Generic<SupportedAs>;
|
||||
type $$Props = TDialogOverlayProps<typeof slotProps, TAsProp>;
|
||||
|
||||
export let as: SupportedAs = "div";
|
||||
export let use: HTMLActionArray = [];
|
||||
|
||||
/***** Events *****/
|
||||
const forwardEvents = forwardEventsBuilder(get_current_component());
|
||||
|
||||
/***** Component *****/
|
||||
|
||||
let api = useDialogContext("DialogOverlay");
|
||||
let id = `headlessui-dialog-overlay-${useId()}`;
|
||||
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
<script lang="ts" context="module">
|
||||
type TDialogTitleProps<
|
||||
TSlotProps extends {},
|
||||
TAsProp extends SupportedAs
|
||||
> = TPassThroughProps<TSlotProps, TAsProp> & {};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { DialogStates, useDialogContext } from "./Dialog.svelte";
|
||||
import { useId } from "$lib/hooks/use-id";
|
||||
@@ -6,11 +13,19 @@
|
||||
import { get_current_component } from "svelte/internal";
|
||||
import type { SupportedAs } from "$lib/internal/elements";
|
||||
import type { HTMLActionArray } from "$lib/hooks/use-actions";
|
||||
import Render from "$lib/utils/Render.svelte";
|
||||
const forwardEvents = forwardEventsBuilder(get_current_component());
|
||||
import Render, { type TPassThroughProps } from "$lib/utils/Render.svelte";
|
||||
|
||||
/***** Props *****/
|
||||
type TAsProp = $$Generic<SupportedAs>;
|
||||
type $$Props = TDialogTitleProps<typeof slotProps, TAsProp>;
|
||||
|
||||
export let as: SupportedAs = "h2";
|
||||
export let use: HTMLActionArray = [];
|
||||
|
||||
/***** Events *****/
|
||||
const forwardEvents = forwardEventsBuilder(get_current_component());
|
||||
|
||||
/***** Component *****/
|
||||
let api = useDialogContext("DialogTitle");
|
||||
let id = `headlessui-dialog-title-${useId()}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user