Skip to content

Commit

Permalink
Refactor component exports and remove unused event types
Browse files Browse the repository at this point in the history
  • Loading branch information
jeannemas committed Apr 22, 2024
1 parent 984d935 commit 9d0a8df
Show file tree
Hide file tree
Showing 62 changed files with 84 additions and 339 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-moose-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@jeanne-mas/svelte-ui': minor
---

Simplified exports by removing Events types
6 changes: 1 addition & 5 deletions src/lib/components/button/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
* The attributes of the button component.
*/
export type Attributes = ButtonPrimitive.Props;
/**
* The Svelte 5 like events of the button component.
*/
export type Events = Record<never, never>;
/**
* The props of the button component.
*/
Expand Down Expand Up @@ -96,7 +92,7 @@

<script lang="ts">
type $$Events = ButtonPrimitive.Events;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let size: Props['size'] = undefined;
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export {
styles,
variants,
type Attributes,
type Events,
type Props,
type Size,
type Slots,
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/Cell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the cell component.
*/
export type Attributes = SvelteHTMLElements['td'];
/**
* The Svelte 5 like events of the cell component.
*/
export type Events = Record<never, never>;
/**
* The props of the cell component.
*/
Expand All @@ -39,7 +35,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/Day.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
* The attributes of the day component.
*/
export type Attributes = SvelteHTMLElements['div'];
/**
* The Svelte 5 like events of the day component.
*/
export type Events = Record<never, never>;
/**
* The props of the day component.
*/
Expand Down Expand Up @@ -49,7 +45,7 @@

<script lang="ts">
type $$Events = CalendarPrimitive.DayEvents;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/Grid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the grid component.
*/
export type Attributes = SvelteHTMLElements['table'];
/**
* The Svelte 5 like events of the grid component.
*/
export type Events = Record<never, never>;
/**
* The props of the grid component.
*/
Expand All @@ -32,7 +28,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/GridBody.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the grid body component.
*/
export type Attributes = SvelteHTMLElements['tbody'];
/**
* The Svelte 5 like events of the grid body component.
*/
export type Events = Record<never, never>;
/**
* The props of the grid body component.
*/
Expand All @@ -32,7 +28,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/GridHead.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the grid head component.
*/
export type Attributes = SvelteHTMLElements['thead'];
/**
* The Svelte 5 like events of the grid head component.
*/
export type Events = Record<never, never>;
/**
* The props of the grid head component.
*/
Expand All @@ -32,7 +28,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/GridRow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the grid row component.
*/
export type Attributes = SvelteHTMLElements['tr'];
/**
* The Svelte 5 like events of the grid row component.
*/
export type Events = Record<never, never>;
/**
* The props of the grid row component.
*/
Expand All @@ -32,7 +28,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/HeadCell.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the head cell component.
*/
export type Attributes = SvelteHTMLElements['th'];
/**
* The Svelte 5 like events of the head cell component.
*/
export type Events = Record<never, never>;
/**
* The props of the head cell component.
*/
Expand All @@ -32,7 +28,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the header component.
*/
export type Attributes = SvelteHTMLElements['div'];
/**
* The Svelte 5 like events of the header component.
*/
export type Events = Record<never, never>;
/**
* The props of the header component.
*/
Expand All @@ -32,7 +28,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/Heading.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* The attributes of the heading component.
*/
export type Attributes = SvelteHTMLElements['div'];
/**
* The Svelte 5 like events of the heading component.
*/
export type Events = Record<never, never>;
/**
* The props of the heading component.
*/
Expand All @@ -32,7 +28,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/Months.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
* The attributes of the months component.
*/
export type Attributes = SvelteHTMLElements['div'];
/**
* The Svelte 5 like events of the months component.
*/
export type Events = Record<never, never>;
/**
* The props of the months component.
*/
Expand All @@ -31,7 +27,7 @@

<script lang="ts">
type $$Events = Record<never, never>;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
$: attributes = $$restProps as Attributes;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/NextButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
* The attributes of the next button component.
*/
export type Attributes = SvelteHTMLElements['button'];
/**
* The Svelte 5 like events of the next button component.
*/
export type Events = Record<never, never>;
/**
* The props of the next button component.
*/
Expand All @@ -39,7 +35,7 @@

<script lang="ts">
type $$Events = CalendarPrimitive.NextButtonEvents;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
6 changes: 1 addition & 5 deletions src/lib/components/calendar/PreviousButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
* The attributes of the previous button component.
*/
export type Attributes = SvelteHTMLElements['button'];
/**
* The Svelte 5 like events of the previous button component.
*/
export type Events = Record<never, never>;
/**
* The props of the previous button component.
*/
Expand All @@ -39,7 +35,7 @@

<script lang="ts">
type $$Events = CalendarPrimitive.PrevButtonEvents;
type $$Props = Attributes & Events & Props;
type $$Props = Attributes & Props;
type $$Slots = Slots;
export let asChild: Props['asChild'] = undefined;
Expand Down
25 changes: 10 additions & 15 deletions src/lib/components/calendar/Root.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,19 @@
*/
export type Attributes = Omit<SvelteHTMLElements['div'], 'placeholder'>;
/**
* The Svelte 5 like events of the calendar component.
* The props of the calendar component.
*/
export type Events<TMultiple extends boolean = false> = {
export type Props<TMultiple extends boolean = false> = Omit<
CalendarPrimitive.Props<TMultiple>,
keyof Attributes
> & {
/**
* Callback to be called when a day is clicked.
*
* @param day The clicked day.
*/
onDayClick?: (day: { date: DateValue; month: Month<DateValue> }) => unknown;
} & Pick<CalendarPrimitive.Props<TMultiple>, 'onPlaceholderChange' | 'onValueChange'>;
/**
* The props of the calendar component.
*/
export type Props<TMultiple extends boolean = false> = Omit<
CalendarPrimitive.Props<TMultiple>,
keyof Attributes | keyof Events<TMultiple>
>;
};
/**
* The slots of the calendar component.
*/
Expand Down Expand Up @@ -59,9 +55,8 @@

<script generics="TMultiple extends boolean = false" lang="ts">
type $$Events = CalendarPrimitive.Events;
type $$Props = Attributes & TypedEvents & TypedProps;
type $$Props = Attributes & TypedProps;
type $$Slots = TypedSlots;
type TypedEvents = Events<TMultiple>;
type TypedProps = Props<TMultiple>;
type TypedSlots = Slots<TMultiple>;
Expand All @@ -78,9 +73,9 @@
export let minValue: TypedProps['minValue'] = undefined;
export let multiple: TypedProps['multiple'] = undefined;
export let numberOfMonths: TypedProps['numberOfMonths'] = undefined;
export let onDayClick: TypedEvents['onDayClick'] = undefined;
export let onPlaceholderChange: TypedEvents['onPlaceholderChange'] = undefined;
export let onValueChange: TypedEvents['onValueChange'] = undefined;
export let onDayClick: TypedProps['onDayClick'] = undefined;
export let onPlaceholderChange: TypedProps['onPlaceholderChange'] = undefined;
export let onValueChange: TypedProps['onValueChange'] = undefined;
export let pagedNavigation: TypedProps['pagedNavigation'] = undefined;
export let placeholder: TypedProps['placeholder'] = undefined;
export let preventDeselect: TypedProps['preventDeselect'] = undefined;
Expand Down
Loading

0 comments on commit 9d0a8df

Please sign in to comment.