From 7f94f4584e97e9000beb4c10ba78c570a793e9a1 Mon Sep 17 00:00:00 2001 From: Abdoulaye NDOYE <46305144+NDOY3M4N@users.noreply.github.com> Date: Mon, 16 Sep 2024 02:01:33 +0000 Subject: [PATCH] fix: add missing props for `DateRangePicker` (#651) Co-authored-by: Hunter Johnston <64506580+huntabyte@users.noreply.github.com> --- .changeset/unlucky-lemons-pump.md | 5 +++++ .../components/date-range-picker.svelte | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 .changeset/unlucky-lemons-pump.md diff --git a/.changeset/unlucky-lemons-pump.md b/.changeset/unlucky-lemons-pump.md new file mode 100644 index 000000000..ae3a69cf1 --- /dev/null +++ b/.changeset/unlucky-lemons-pump.md @@ -0,0 +1,5 @@ +--- +"bits-ui": patch +--- + +fix(Date Range Picker): expose missing props diff --git a/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte b/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte index db0a5bd3e..f65cdfd1b 100644 --- a/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte +++ b/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte @@ -5,6 +5,8 @@ type $$Props = Props; + export let open: $$Props["open"] = undefined; + export let onOpenChange: $$Props["onOpenChange"] = undefined; export let portal: $$Props["portal"] = undefined; export let value: $$Props["value"] = undefined; export let onValueChange: $$Props["onValueChange"] = undefined; @@ -34,6 +36,7 @@ const { states: { + open: localOpen, value: localValue, placeholder: localPlaceholder, isInvalid: localIsInvalid, @@ -43,6 +46,7 @@ updateOption, ids, } = setCtx({ + defaultOpen: open, defaultValue: value, defaultPlaceholder: placeholder, preventDeselect, @@ -78,6 +82,13 @@ } return next; }, + onOpenChange: ({ next }) => { + if (open !== next) { + onOpenChange?.(next); + open = next; + } + return next; + }, }); const startFieldIds = derived( @@ -199,6 +210,7 @@ localValue.set(nextValue); } $: placeholder !== undefined && localPlaceholder.set(placeholder); + $: open !== undefined && localOpen.set(open); $: updateOption("disabled", disabled); $: updateOption("isDateUnavailable", isDateUnavailable);