Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compatibility with exactOptionalPropertyTypes #621

Merged
merged 5 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/bits-ui/src/lib/bits/accordion/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export type AccordionPropsWithoutHTML<Multiple extends boolean> = Expand<
* The value of the accordion.
* You can bind this to a value to programmatically control the open state.
*/
value?: MeltAccordionProps<Multiple>["defaultValue"];
value?: MeltAccordionProps<Multiple>["defaultValue"] | undefined;

/**
* A callback function called when the value changes.
*/
onValueChange?: OnChangeFn<MeltAccordionProps<Multiple>["defaultValue"]>;
onValueChange?: OnChangeFn<MeltAccordionProps<Multiple>["defaultValue"]> | undefined;
} & DOMElement
>;

Expand All @@ -41,7 +41,7 @@ export type AccordionHeaderPropsWithoutHTML = Expand<
/**
* The heading level of the accordion header.
*/
level?: ObjectVariation<MeltAccordionHeadingProps>["level"];
level?: ObjectVariation<MeltAccordionHeadingProps>["level"] | undefined;
} & DOMElement
>;

Expand Down
6 changes: 3 additions & 3 deletions packages/bits-ui/src/lib/bits/alert-dialog/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export type AlertDialogPropsWithoutHTML = Expand<
*
* @defaultValue false
*/
open?: boolean;
open?: boolean | undefined;

/**
* A callback function called when the open state changes.
*/
onOpenChange?: OnChangeFn<boolean>;
onOpenChange?: OnChangeFn<boolean> | undefined;
}
>;

Expand Down Expand Up @@ -54,7 +54,7 @@ export type AlertDialogPortalPropsWithoutHTML = DOMElement;

export type AlertDialogTitlePropsWithoutHTML = Expand<
{
level?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
level?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | undefined;
} & DOMElement<HTMLHeadingElement>
>;

Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/aspect-ratio/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { DOMEl, HTMLDivAttributes } from "$lib/internal/index.js";

export type AspectRatioPropsWithoutHTML = Expand<
{
ratio?: number;
ratio?: number | undefined;
} & DOMEl
>;

Expand Down
4 changes: 2 additions & 2 deletions packages/bits-ui/src/lib/bits/avatar/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export type AvatarPropsWithoutHTML = Expand<
* The loading state of the image.
* You can bind this to a boolean value to programmatically control the loading state.
*/
loadingStatus?: "loading" | "loaded" | "error";
loadingStatus?: "loading" | "loaded" | "error" | undefined;

/**
* A callback function called when the loading state changes.
*/
onLoadingStatusChange?: OnChangeFn<"loading" | "loaded" | "error">;
onLoadingStatusChange?: OnChangeFn<"loading" | "loaded" | "error"> | undefined;
} & DOMElement
>;

Expand Down
10 changes: 5 additions & 5 deletions packages/bits-ui/src/lib/bits/button/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ export type ButtonPropsWithoutHTML = {
/**
* Melt UI builders to apply to the button component.
*/
builders?: Builder[];
builders?: Builder[] | undefined;
};

type AnchorElement = ButtonPropsWithoutHTML &
HTMLAnchorAttributes & {
href?: HTMLAnchorAttributes["href"];
type?: never;
href?: HTMLAnchorAttributes["href"] | undefined;
type?: never | undefined;
} & DOMEl<HTMLAnchorElement>;

type ButtonElement = ButtonPropsWithoutHTML &
HTMLButtonAttributes & {
type?: HTMLButtonAttributes["type"];
href?: never;
type?: HTMLButtonAttributes["type"] | undefined;
href?: never | undefined;
} & DOMEl<HTMLButtonElement>;

export type ButtonProps = AnchorElement | ButtonElement;
Expand Down
10 changes: 5 additions & 5 deletions packages/bits-ui/src/lib/bits/calendar/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export type CalendarPropsWithoutHTML<Multiple extends boolean = false> = Expand<
* You can bind this to a value to programmatically control the
* value state.
*/
value?: MeltCalendarProps<Multiple>["defaultValue"];
value?: MeltCalendarProps<Multiple>["defaultValue"] | undefined;

/**
* A callback function called when the value changes.
*/
onValueChange?: OnChangeFn<MeltCalendarProps<Multiple>["defaultValue"]>;
onValueChange?: OnChangeFn<MeltCalendarProps<Multiple>["defaultValue"]> | undefined;

/**
* The placeholder date, used to display the calendar when no
Expand All @@ -45,12 +45,12 @@ export type CalendarPropsWithoutHTML<Multiple extends boolean = false> = Expand<
* You can bind this to a value to programmatically control the
* placeholder state.
*/
placeholder?: DateValue;
placeholder?: DateValue | undefined;

/**
* A callback function called when the placeholder changes.
*/
onPlaceholderChange?: OnChangeFn<DateValue>;
onPlaceholderChange?: OnChangeFn<DateValue> | undefined;

/**
* If `true`, the calendar will focus the selected day,
Expand All @@ -59,7 +59,7 @@ export type CalendarPropsWithoutHTML<Multiple extends boolean = false> = Expand<
*
* @default false
*/
initialFocus?: boolean;
initialFocus?: boolean | undefined;
} & DOMElement
>;

Expand Down
4 changes: 2 additions & 2 deletions packages/bits-ui/src/lib/bits/checkbox/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export type CheckboxPropsWithoutHTML = Expand<
*
* @defaultValue false
*/
checked?: boolean | "indeterminate";
checked?: boolean | "indeterminate" | undefined;

/**
* A callback function called when the checked state changes.
*/
onCheckedChange?: OnChangeFn<boolean | "indeterminate">;
onCheckedChange?: OnChangeFn<boolean | "indeterminate"> | undefined;
} & DOMElement<HTMLButtonElement>
>;

Expand Down
4 changes: 2 additions & 2 deletions packages/bits-ui/src/lib/bits/collapsible/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export type CollapsiblePropsWithoutHTML = Expand<
*
* @defaultValue false
*/
open?: boolean;
open?: boolean | undefined;

/**
* A callback function called when the open state changes.
*/
onOpenChange?: OnChangeFn<boolean>;
onOpenChange?: OnChangeFn<boolean> | undefined;
} & DOMElement
>;

Expand Down
4 changes: 2 additions & 2 deletions packages/bits-ui/src/lib/bits/combobox/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export function getCtx() {

type Items<T> = {
value: T;
label?: string;
label?: string | undefined;
};

type Props<T = unknown, M extends boolean = false> = CreateComboboxProps<T, M> & {
items?: Items<T>[];
items?: Items<T>[] | undefined;
};

export function setCtx<T = unknown, M extends boolean = false>(props: Props<T, M>) {
Expand Down
14 changes: 7 additions & 7 deletions packages/bits-ui/src/lib/bits/combobox/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,47 @@ export type ComboboxPropsWithoutHTML<T = unknown, Multiple extends boolean = fal
/**
* A callback function called when the selected value changes.
*/
onSelectedChange?: OnChangeFn<SelectValue<Selected<T>, Multiple>>;
onSelectedChange?: OnChangeFn<SelectValue<Selected<T>, Multiple>> | undefined;

/**
* The open state of the combobox menu.
* You can bind this to a boolean value to programmatically control the open state.
*
* @defaultValue false
*/
open?: boolean;
open?: boolean | undefined;

/**
* A callback function called when the open state changes.
*/
onOpenChange?: OnChangeFn<boolean>;
onOpenChange?: OnChangeFn<boolean> | undefined;

/**
* Whether or not multiple values can be selected.
*/
multiple?: Multiple;
multiple?: Multiple | undefined;

/**
* The value of the input.
* You can bind this to a value to programmatically control the input value.
*
* @defaultValue ""
*/
inputValue?: string;
inputValue?: string | undefined;

/**
* Optionally provide an array of `Selected<T>` objects to
* type the `selected` and `onSelectedChange` props.
*/
items?: Selected<T>[];
items?: Selected<T>[] | undefined;

/**
* Whether the input has been touched or not. You can bind to this to
* handle filtering the items only when the input has been touched.
*
* @defaultValue false
*/
touchedInput?: boolean;
touchedInput?: boolean | undefined;
}
>;

Expand Down
12 changes: 6 additions & 6 deletions packages/bits-ui/src/lib/bits/date-field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@ export type DateFieldPropsWithoutHTML = Expand<
* The value of the date field.
* You can bind this to a `DateValue` object to programmatically control the value.
*/
value?: DateValue;
value?: DateValue | undefined;

/**
* A callback function called when the value changes.
*/
onValueChange?: OnChangeFn<DateValue | undefined>;
onValueChange?: OnChangeFn<DateValue | undefined> | undefined;

/**
* The placeholder date used to start the field.
*/
placeholder?: DateValue;
placeholder?: DateValue | undefined;

/**
* A callback function called when the placeholder changes.
*/
onPlaceholderChange?: OnChangeFn<DateValue>;
onPlaceholderChange?: OnChangeFn<DateValue> | undefined;

/**
* The id of the validation message element which is used to apply the
* appropriate `aria-describedby` attribute to the input.
*/
validationId?: string;
validationId?: string | undefined;

/**
* The id of the description element which is used to describe the input.
* This is used to apply the appropriate `aria-describedby` attribute to the input.
*/
descriptionId?: string;
descriptionId?: string | undefined;
}
>;

Expand Down
16 changes: 8 additions & 8 deletions packages/bits-ui/src/lib/bits/date-picker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,45 +51,45 @@ export type DatePickerPropsWithoutHTML = Expand<
*
* @default false
*/
open?: boolean;
open?: boolean | undefined;

/**
* A callback function called when the open state changes.
*/
onOpenChange?: OnChangeFn<boolean>;
onOpenChange?: OnChangeFn<boolean> | undefined;

/**
* The value of the date field.
* You can bind this to a `DateValue` object to programmatically control the value.
*/
value?: DateValue;
value?: DateValue | undefined;

/**
* A callback function called when the value changes.
*/
onValueChange?: OnChangeFn<DateValue | undefined>;
onValueChange?: OnChangeFn<DateValue | undefined> | undefined;

/**
* The placeholder date used to start the field.
*/
placeholder?: DateValue;
placeholder?: DateValue | undefined;

/**
* A callback function called when the placeholder changes.
*/
onPlaceholderChange?: OnChangeFn<DateValue>;
onPlaceholderChange?: OnChangeFn<DateValue> | undefined;

/**
* The id of the validation message element which is used to apply the
* appropriate `aria-describedby` attribute to the input.
*/
validationId?: string;
validationId?: string | undefined;

/**
* The id of the description element which is used to describe the input.
* This is used to apply the appropriate `aria-describedby` attribute to the input.
*/
descriptionId?: string;
descriptionId?: string | undefined;
}
>;

Expand Down
12 changes: 6 additions & 6 deletions packages/bits-ui/src/lib/bits/date-range-field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,34 @@ export type DateRangeFieldPropsWithoutHTML = Expand<
* The value of the date field.
* You can bind this to a `DateValue` object to programmatically control the value.
*/
value?: DateRange;
value?: DateRange | undefined;

/**
* A callback function called when the value changes.
*/
onValueChange?: OnChangeFn<DateRange | undefined>;
onValueChange?: OnChangeFn<DateRange | undefined> | undefined;

/**
* The placeholder date used to start the field.
*/
placeholder?: DateValue;
placeholder?: DateValue | undefined;

/**
* A callback function called when the placeholder changes.
*/
onPlaceholderChange?: OnChangeFn<DateValue>;
onPlaceholderChange?: OnChangeFn<DateValue> | undefined;

/**
* The id of the validation message element which is used to apply the
* appropriate `aria-describedby` attribute to the input.
*/
validationId?: string;
validationId?: string | undefined;

/**
* The id of the description element which is used to describe the input.
* This is used to apply the appropriate `aria-describedby` attribute to the input.
*/
descriptionId?: string;
descriptionId?: string | undefined;
}
>;

Expand Down
Loading