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