From 4934146c7960c9ab2dfc6cc1a3a220212d3684f1 Mon Sep 17 00:00:00 2001 From: Vincenzo Guerrisi Date: Mon, 13 May 2024 09:50:01 +0200 Subject: [PATCH 1/3] Day hover style has priority over selected style --- packages/bento-design-system/src/DateField/Day.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/bento-design-system/src/DateField/Day.tsx b/packages/bento-design-system/src/DateField/Day.tsx index 3afdc5002..bd1693988 100644 --- a/packages/bento-design-system/src/DateField/Day.tsx +++ b/packages/bento-design-system/src/DateField/Day.tsx @@ -47,7 +47,9 @@ function computeStyle(props: { return "focused"; } else return "default"; } else { - if (props.isStartDate) { + if (props.isInHoverRange) { + return "inHoverRange"; + } else if (props.isStartDate) { if (props.isEndDate) { return "selected"; } @@ -56,8 +58,6 @@ function computeStyle(props: { return "selectedEnd"; } else if (props.isInRange) { return "selectedRange"; - } else if (props.isInHoverRange) { - return "inHoverRange"; } else if (props.isFocused) { return "focused"; } else { From d15b693f6c4dd3caf3e0631f2620cf1abf3067d4 Mon Sep 17 00:00:00 2001 From: Vincenzo Guerrisi Date: Tue, 14 May 2024 16:09:44 +0200 Subject: [PATCH 2/3] allow shortcuts with null value --- .../src/DateField/DateField.tsx | 5 +++-- .../bento-design-system/src/DateField/Input.tsx | 17 +++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/bento-design-system/src/DateField/DateField.tsx b/packages/bento-design-system/src/DateField/DateField.tsx index 6f5e4ce14..1148cba9a 100644 --- a/packages/bento-design-system/src/DateField/DateField.tsx +++ b/packages/bento-design-system/src/DateField/DateField.tsx @@ -18,11 +18,11 @@ export type ShortcutProps = { }; type SingleDateFieldProps = { type?: "single"; - shortcuts?: ShortcutProps[]; + shortcuts?: ShortcutProps[]; } & FieldProps; type RangeDateFieldProps = { type: "range"; - shortcuts?: ShortcutProps<[Date, Date]>[]; + shortcuts?: ShortcutProps<[Date, Date] | null>[]; } & FieldProps<[Date, Date] | null>; type Props = (SingleDateFieldProps | RangeDateFieldProps) & { minDate?: Date; @@ -138,6 +138,7 @@ function RangeDateField({ disabled, readOnly, ...props }: Extract } + | { type: "single"; fieldProps: AriaDatePickerProps } | { type: "range"; fieldProps: { - start: AriaDateFieldOptions; - end: AriaDateFieldOptions; + start: AriaDatePickerProps; + end: AriaDatePickerProps; }; } ) & { @@ -60,7 +65,7 @@ function DateSegment({ segment, state }: { segment: DateSegmentType; state: Date ); } -function DateField({ fieldProps }: { fieldProps: AriaDateFieldOptions }) { +function DateField({ fieldProps }: { fieldProps: AriaDatePickerProps }) { const { locale } = useLocale(); const ref = useRef(null); const state = useDateFieldState({ From 4a46df2ae161e074a0c5aaa3dccce556126364bb Mon Sep 17 00:00:00 2001 From: Vincenzo Guerrisi Date: Tue, 14 May 2024 16:17:08 +0200 Subject: [PATCH 3/3] add clear example to DateField stories --- .../stories/Components/DateField.stories.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/bento-design-system/stories/Components/DateField.stories.tsx b/packages/bento-design-system/stories/Components/DateField.stories.tsx index 71f86e5f4..7ffc99b7d 100644 --- a/packages/bento-design-system/stories/Components/DateField.stories.tsx +++ b/packages/bento-design-system/stories/Components/DateField.stories.tsx @@ -67,6 +67,7 @@ export const SingleWithShortcuts = { args: { value: null, shortcuts: [ + { label: "Clear", value: null }, { label: "Today", value: new Date(), @@ -132,6 +133,10 @@ export const RangeWithShortcuts = { value: null, type: "range", shortcuts: [ + { + label: "Clear all", + value: null, + }, { label: "This Week", value: [startOfWeek(today), endOfWeek(today)],