Skip to content

Commit 560c7f1

Browse files
committed
work on type exports
1 parent 4444c77 commit 560c7f1

25 files changed

+402
-32
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type {
2+
Props,
3+
ItemProps,
4+
HeaderProps,
5+
TriggerProps,
6+
ContentProps,
7+
//
8+
// Events
9+
//
10+
TriggerEvents
11+
} from "./types.js";
12+
13+
export type {
14+
Props as AccordionProps,
15+
ItemProps as AccordionItemProps,
16+
HeaderProps as AccordionHeaderProps,
17+
TriggerProps as AccordionTriggerProps,
18+
ContentProps as AccordionContentProps,
19+
//
20+
// Events
21+
//
22+
TriggerEvents as AccordionTriggerEvents
23+
};
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type {
2+
Props,
3+
TriggerProps,
4+
ActionProps,
5+
CancelProps,
6+
ContentProps,
7+
DescriptionProps,
8+
PortalProps,
9+
OverlayProps,
10+
TitleProps,
11+
//
12+
// Events
13+
//
14+
TriggerEvents,
15+
CancelEvents,
16+
ActionEvents
17+
} from "./types.js";
18+
19+
export type {
20+
Props as AlertDialogProps,
21+
TriggerProps as AlertDialogTriggerProps,
22+
ActionProps as AlertDialogActionProps,
23+
CancelProps as AlertDialogCancelProps,
24+
ContentProps as AlertDialogContentProps,
25+
DescriptionProps as AlertDialogDescriptionProps,
26+
PortalProps as AlertDialogPortalProps,
27+
OverlayProps as AlertDialogOverlayProps,
28+
TitleProps as AlertDialogTitleProps,
29+
//
30+
// Events
31+
//
32+
TriggerEvents as AlertDialogTriggerEvents,
33+
CancelEvents as AlertDialogCancelEvents,
34+
ActionEvents as AlertDialogActionEvents
35+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { Props } from "./types.js";
2+
3+
export type { Props as AspectRatioProps };

src/lib/bits/avatar/_export.types.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { Props, ImageProps, FallbackProps } from "./types.js";
2+
3+
export type {
4+
Props as AvatarProps,
5+
ImageProps as AvatarImageProps,
6+
FallbackProps as AvatarFallbackProps
7+
};

src/lib/bits/button/_export.types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import type { Props, Events } from "./types.js";
2+
3+
export type { Props as ButtonProps, Events as ButtonEvents };
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type {
2+
Props,
3+
PrevButtonProps,
4+
NextButtonProps,
5+
HeadingProps,
6+
GridProps,
7+
CellProps,
8+
GridRowProps,
9+
GridBodyProps,
10+
HeadCellProps,
11+
GridHeadProps,
12+
HeaderProps,
13+
DateProps,
14+
//
15+
// Events
16+
//
17+
Events,
18+
PrevButtonEvents,
19+
NextButtonEvents,
20+
DateEvents
21+
} from "./types.js";
22+
23+
export type {
24+
Props as CalendarProps,
25+
PrevButtonProps as CalendarPrevButtonProps,
26+
NextButtonProps as CalendarNextButtonProps,
27+
HeadingProps as CalendarHeadingProps,
28+
GridProps as CalendarGridProps,
29+
CellProps as CalendarCellProps,
30+
GridRowProps as CalendarGridRowProps,
31+
GridBodyProps as CalendarGridBodyProps,
32+
HeadCellProps as CalendarHeadCellProps,
33+
GridHeadProps as CalendarGridHeadProps,
34+
HeaderProps as CalendarHeaderProps,
35+
DateProps as CalendarDateProps,
36+
//
37+
// Events
38+
//
39+
Events as CalendarEvents,
40+
PrevButtonEvents as CalendarPrevButtonEvents,
41+
NextButtonEvents as CalendarNextButtonEvents,
42+
DateEvents as CalendarDateEvents
43+
};

src/lib/bits/calendar/components/calendar-date.svelte

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<script lang="ts">
22
import { melt } from "@melt-ui/svelte";
33
import { getCtx, getAttrs } from "../ctx.js";
4-
import type { DateProps } from "../types.js";
4+
import type { DateEvents, DateProps } from "../types.js";
5+
import { createDispatcher } from "$lib/internal/events.js";
56
67
type $$Props = DateProps;
8+
type $$Events = DateEvents;
79
810
export let date: $$Props["date"];
911
export let month: $$Props["month"];
@@ -15,7 +17,9 @@
1517
} = getCtx();
1618
1719
$: builder = $cell(date, month);
20+
1821
const attrs = getAttrs("date");
22+
const dispatch = createDispatcher();
1923
2024
$: slotProps = {
2125
builder,
@@ -29,7 +33,7 @@
2933
{#if asChild}
3034
<slot {...slotProps} />
3135
{:else}
32-
<div use:melt={builder} {...attrs} {...$$restProps}>
36+
<div use:melt={builder} {...attrs} {...$$restProps} on:m-click={dispatch}>
3337
<slot {...slotProps}>
3438
{date.day}
3539
</slot>

src/lib/bits/calendar/components/calendar-next-button.svelte

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<script lang="ts">
22
import { melt } from "@melt-ui/svelte";
33
import { getAttrs, getCtx } from "../ctx.js";
4-
import type { NextButtonProps } from "../types.js";
4+
import type { NextButtonEvents, NextButtonProps } from "../types.js";
5+
import { createDispatcher } from "$lib/internal/events.js";
56
67
type $$Props = NextButtonProps;
8+
type $$Events = NextButtonEvents;
79
810
export let asChild: $$Props["asChild"] = false;
911
@@ -12,7 +14,9 @@
1214
} = getCtx();
1315
1416
$: builder = $nextButton;
17+
1518
const attrs = getAttrs("next-button");
19+
const dispatch = createDispatcher();
1620
1721
$: slotProps = {
1822
builder,
@@ -23,7 +27,13 @@
2327
{#if asChild}
2428
<slot {...slotProps} />
2529
{:else}
26-
<button use:melt={builder} type="button" {...$$restProps} {...attrs}>
30+
<button
31+
use:melt={builder}
32+
type="button"
33+
{...$$restProps}
34+
{...attrs}
35+
on:m-click={dispatch}
36+
>
2737
<slot {...slotProps} />
2838
</button>
2939
{/if}

src/lib/bits/calendar/components/calendar-prev-button.svelte

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<script lang="ts">
22
import { melt } from "@melt-ui/svelte";
33
import { getAttrs, getCtx } from "../ctx.js";
4-
import type { PrevButtonProps } from "../types.js";
4+
import type { PrevButtonEvents, PrevButtonProps } from "../types.js";
5+
import { createDispatcher } from "$lib/internal/events.js";
56
67
type $$Props = PrevButtonProps;
8+
type $$Events = PrevButtonEvents;
79
810
export let asChild: $$Props["asChild"] = false;
911
@@ -12,7 +14,9 @@
1214
} = getCtx();
1315
1416
$: builder = $prevButton;
17+
1518
const attrs = getAttrs("prev-button");
19+
const dispatch = createDispatcher();
1620
1721
$: slotProps = {
1822
builder,
@@ -23,7 +27,13 @@
2327
{#if asChild}
2428
<slot {...slotProps} />
2529
{:else}
26-
<button use:melt={builder} type="button" {...$$restProps} {...attrs}>
30+
<button
31+
use:melt={builder}
32+
type="button"
33+
{...$$restProps}
34+
{...attrs}
35+
on:m-click={dispatch}
36+
>
2737
<slot {...slotProps} />
2838
</button>
2939
{/if}

src/lib/bits/calendar/components/calendar.svelte

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import { createDispatcher } from "$lib/internal/events.js";
3+
24
import { melt } from "@melt-ui/svelte";
35
import { setCtx, getAttrs } from "../ctx.js";
46
import type { Props } from "../types.js";
@@ -95,7 +97,9 @@
9597
$: updateOption("numberOfMonths", numberOfMonths);
9698
9799
$: builder = $calendar;
100+
98101
const attrs = getAttrs("root");
102+
const dispatch = createDispatcher();
99103
100104
$: slotProps = {
101105
builder,
@@ -108,7 +112,7 @@
108112
{#if asChild}
109113
<slot {...slotProps} />
110114
{:else}
111-
<div use:melt={builder} {...$$restProps} {...attrs}>
115+
<div use:melt={builder} {...$$restProps} {...attrs} on:m-keydown={dispatch}>
112116
<slot {...slotProps} />
113117
</div>
114118
{/if}

src/lib/bits/calendar/types.ts

+34-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
HTMLThAttributes
88
} from "svelte/elements";
99
import type * as I from "./_types.js";
10+
import type { CustomEventHandler } from "$lib";
1011

1112
type Props<Multiple extends boolean = false> = I.Props<Multiple> &
1213
Omit<HTMLDivAttributes, "placeholder">;
@@ -33,6 +34,26 @@ type CellProps = I.CellProps & HTMLTdAttributes;
3334

3435
type DateProps = I.DateProps & HTMLDivAttributes;
3536

37+
/**
38+
* Events
39+
*/
40+
41+
type ButtonEvents = {
42+
click: CustomEventHandler<MouseEvent, HTMLButtonElement>;
43+
};
44+
45+
type PrevButtonEvents = ButtonEvents;
46+
47+
type NextButtonEvents = ButtonEvents;
48+
49+
type DateEvents = {
50+
click: CustomEventHandler<MouseEvent, HTMLDivElement>;
51+
};
52+
53+
type Events = {
54+
keydown: CustomEventHandler<KeyboardEvent, HTMLDivElement>;
55+
};
56+
3657
export type {
3758
Props,
3859
PrevButtonProps,
@@ -58,5 +79,17 @@ export type {
5879
GridBodyProps as CalendarGridBodyProps,
5980
CellProps as CalendarCellProps,
6081
GridRowProps as CalendarGridRowProps,
61-
DateProps as CalendarDateProps
82+
DateProps as CalendarDateProps,
83+
//
84+
// Events
85+
//
86+
Events,
87+
PrevButtonEvents,
88+
NextButtonEvents,
89+
DateEvents,
90+
//
91+
Events as CalendarEvents,
92+
PrevButtonEvents as CalendarPrevButtonEvents,
93+
NextButtonEvents as CalendarNextButtonEvents,
94+
DateEvents as CalendarDateEvents
6295
};
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type {
2+
Props,
3+
IndicatorProps,
4+
InputProps,
5+
//
6+
// Events
7+
//
8+
Events
9+
} from "./types.js";
10+
11+
export type {
12+
Props as CheckboxProps,
13+
IndicatorProps as CheckboxIndicatorProps,
14+
InputProps as CheckboxInputProps,
15+
//
16+
// Events
17+
//
18+
Events as CheckboxEvents
19+
};
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type {
2+
Props,
3+
ContentProps,
4+
TriggerProps,
5+
//
6+
// Events
7+
//
8+
TriggerEvents
9+
} from "./types.js";
10+
11+
export type {
12+
Props as CollapsibleProps,
13+
ContentProps as CollapsibleContentProps,
14+
TriggerProps as CollapsibleTriggerProps,
15+
//
16+
// Events
17+
//
18+
TriggerEvents as CollapsibleTriggerEvents
19+
};

0 commit comments

Comments
 (0)