diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d6423..a7974c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Next +- Add `isDisabledDate` prop (@stinger567) + ## 2.15.2 - 2025 Mar 19 - Fix `timePrecision` not always setting unused values to 0 (@stinger567) diff --git a/src/lib/DateInput.svelte b/src/lib/DateInput.svelte index f91e050..d675fdd 100644 --- a/src/lib/DateInput.svelte +++ b/src/lib/DateInput.svelte @@ -1,7 +1,7 @@ + + { + return date.getDate() === 15 || date.getDate() === 16 + }} +/> + + +{value} diff --git a/src/routes/docs/+page.md b/src/routes/docs/+page.md index 0bbb12b..661b72c 100644 --- a/src/routes/docs/+page.md +++ b/src/routes/docs/+page.md @@ -46,6 +46,7 @@ The component will not assign a date value until a specific date is selected in | `browseWithoutSelecting` | bool | Wait with updating the date until a value is selected | | `dynamicPositioning` | bool | Dynamically postions the date popup to best fit on the screen | | `locale` | Locale | Locale object for internationalization | +| `isDisabledDate` | ((dateToCheck: Date) => boolean) \| null | Disallow specific dates |

Format string

@@ -76,6 +77,23 @@ The component will not assign a date value until a specific date is selected in | `timePrecision` | "minute" \| "second" \| "millisecond" \| null | Show a time picker with the specified precision | | `locale` | Locale | Locale object for internationalization | | `browseWithoutSelecting` | bool | Wait with updating the date until a date is selected | +| `isDisabledDate` | ((dateToCheck: Date) => boolean) \| null | Disallow specific dates | + +

Date disabling example

+ +Example usage of the `isDisabledDate` prop: + +```svelte + + + { + return isSameDate(dateToCheck, disabledDate) + }} +/> +```

Internationalization

@@ -91,7 +109,7 @@ Object to support internationalization. Properties (all are optional): If you use [date-fns](https://date-fns.org/), you can create a Locale object by passing a date-fns locale to this function: -```js +```svelte