Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Jan 9, 2024
1 parent 8d1756d commit 2a49deb
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-carrots-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

Date Range Field: add `readonlySegments` prop to specify certain segments as 'readonly' to the user
5 changes: 5 additions & 0 deletions .changeset/nice-bees-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": minor
---

Date Field: add `readonlySegments` prop to specify certain segments as readonly
7 changes: 7 additions & 0 deletions src/content/api-reference/date-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export const root: APISchema<DateField.Props> = {
type: C.BOOLEAN,
description: "Whether or not the field is readonly.",
default: C.FALSE
},
readonlySegments: {
type: {
type: C.ARRAY,
definition: "EditableSegmentPart[]"
},
description: "An array of segments that should be readonly, which prevent user input on them."
}
},
slotProps: {
Expand Down
8 changes: 8 additions & 0 deletions src/content/api-reference/date-range-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ export const root: APISchema<DateRangeField.Props> = {
type: C.BOOLEAN,
description: "Whether or not the field is readonly.",
default: C.FALSE
},
readonlySegments: {
type: {
type: C.OBJECT,
definition: "{ start: EditableSegmentPart[]; end: EditableSegmentPart[]; }"
},
description:
"The segments for the start and end fields that should be readonly, meaning users cannot edit them. This is useful for prepopulating fixed segments like years, months, or days."
}
},
slotProps: {
Expand Down
6 changes: 6 additions & 0 deletions src/content/api-reference/menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export const root: APISchema<Menubar.Props> = {
description:
"Whether or not to loop through the menubar menu triggers when navigating with the keyboard."
},
preventScroll: {
default: C.FALSE,
type: C.BOOLEAN,
description:
"Whether or not to prevent scrolling the body while a menu in the menubar is open."
},
...domElProps("HTMLDivElement")
},
slotProps: { ...builderAndAttrsSlotProps, ids: idsSlotProp }
Expand Down
12 changes: 10 additions & 2 deletions src/lib/bits/date-range-field/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
import type { Expand, OnChangeFn, OmitDates, DOMElement } from "$lib/internal/index.js";
import type { DateRange, SegmentPart } from "$lib/shared/index.js";
import type { DateValue } from "@internationalized/date";
import type { CreateDateRangeFieldProps } from "@melt-ui/svelte";
import type { CreateDateRangeFieldProps as ICreateDateRangeFieldProps } from "@melt-ui/svelte";

type CreateDateRangeFieldProps = Omit<
OmitDates<ICreateDateRangeFieldProps>,
"required" | "name" | "startIds" | "endIds" | "startName" | "endName"
>;

type Props = Expand<
Omit<OmitDates<CreateDateRangeFieldProps>, "required" | "name"> & {
Omit<
OmitDates<CreateDateRangeFieldProps>,
"required" | "name" | "startIds" | "endIds" | "startName" | "endName"
> & {
/**
* The value of the date field.
* You can bind this to a `DateValue` object to programmatically control the value.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/shared/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DateValue } from "@internationalized/date";
import type { Month, Page, PageItem, Ellipsis } from "@melt-ui/svelte";
import type { Month, Page, PageItem, Ellipsis, EditableSegmentPart } from "@melt-ui/svelte";

export type Selected<Value> = {
value: Value;
Expand All @@ -25,4 +25,4 @@ export type SegmentPart =
export type FocusTarget = string | HTMLElement | SVGElement | null;
export type FocusProp = FocusTarget | ((defaultEl?: HTMLElement | null) => FocusTarget);

export type { Month, Page, PageItem, Ellipsis };
export type { Month, Page, PageItem, Ellipsis, EditableSegmentPart };
2 changes: 1 addition & 1 deletion src/tests/progress/ProgressTest.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Progress } from "$lib";
type $$Props = Progress.Props;
export let value = 0;
export let value: $$Props["value"] = 0;
</script>

<main>
Expand Down

0 comments on commit 2a49deb

Please sign in to comment.