diff --git a/.changeset/itchy-wolves-refuse.md b/.changeset/itchy-wolves-refuse.md new file mode 100644 index 000000000..91efa2bf5 --- /dev/null +++ b/.changeset/itchy-wolves-refuse.md @@ -0,0 +1,5 @@ +--- +'svelte-ux': patch +--- + +[Month] Add `hideControls` prop diff --git a/packages/svelte-ux/src/lib/components/Month.svelte b/packages/svelte-ux/src/lib/components/Month.svelte index a21dfa013..1348874f9 100644 --- a/packages/svelte-ux/src/lib/components/Month.svelte +++ b/packages/svelte-ux/src/lib/components/Month.svelte @@ -8,7 +8,6 @@ endOfMonth as endOfMonthFunc, format, addMonths, - subMonths, isSameDay, isWithinInterval, } from 'date-fns'; @@ -33,10 +32,14 @@ startOfMonthFunc(selected.from)) || startOfMonthFunc(new Date()); - // TODO: Variable shows error if set to `endOfMonth` maybe due to import - $: endOfMonth2 = endOfMonthFunc(startOfMonth); + $: endOfMonth = endOfMonthFunc(startOfMonth); $: monthDaysByWeek = getMonthDaysByWeek(startOfMonth); + /** + * Hide controls and date. Useful to control externally + */ + export let hideControls = false; + /** * Show days before and after selected month */ @@ -65,7 +68,7 @@ $: isDayHidden = (day: Date) => { const isCurrentMonth = isWithinInterval(day, { start: startOfMonth, - end: endOfMonth2, + end: endOfMonth, }); return !isCurrentMonth && !showOutsideDays; }; @@ -73,27 +76,31 @@ $: isDayFaded = (day: Date) => { const isCurrentMonth = isWithinInterval(day, { start: startOfMonth, - end: endOfMonth2, + end: endOfMonth, }); return !isCurrentMonth && showOutsideDays; }; -
-
-