diff --git a/README.md b/README.md index 426fc923..9bed5786 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Using Force UI as a dependency in package.json - ```json "dependencies": { - "@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.3.4" + "@bsf/force-ui": "git+https://github.com/brainstormforce/force-ui#1.3.5" } ``` @@ -28,7 +28,7 @@ npm install Or you can directly run the following command to install the package - ```bash -npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.3.4 +npm i -S @bsf/force-ui@git+https://github.com/brainstormforce/force-ui.git#1.3.5 ```
diff --git a/changelog.txt b/changelog.txt index 1052b23c..557363ee 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +Version 1.3.5 - 6th January, 2025 +- Improvement: Display a light blue color on hover when selecting a date range. + Version 1.3.4 - 31th December, 2024 - Improvement - Enhanced the UI of the Table and Line chart component for responsive design. - Improvement - Added option group to the Select component. diff --git a/package.json b/package.json index ca50f9b9..480f2431 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bsf/force-ui", - "version": "1.3.4", + "version": "1.3.5", "description": "Library of components for the BSF project", "main": "./dist/force-ui.js", "module": "./dist/force-ui.js", diff --git a/src/components/badge/badge.tsx b/src/components/badge/badge.tsx index fc5a02d3..1f070bff 100644 --- a/src/components/badge/badge.tsx +++ b/src/components/badge/badge.tsx @@ -159,7 +159,7 @@ const Badge = forwardRef( { icon } ) : null } - { label } + { label } { closable && ( void; + setSelectedDates: ( dates: Date | Date[] | TDateRange | undefined ) => void; /** Show or hide days outside of the current month. */ showOutsideDays?: boolean; /** Defines the selection selectionType of the date picker: single, range, or multiple dates. */ @@ -52,19 +52,12 @@ export interface DatePickerProps { variant?: 'normal' | 'dualdate' | 'presets'; /** Defines the alignment of the date picker: horizontal or vertical. */ alignment?: 'horizontal' | 'vertical'; - // /** Callback when the date picker loses focus. */ - // onBlur?: ( event: React.FocusEvent ) => void; - // /** Callback when the selected date changes. */ - // onChange?: ( date: Date | Date[] | { from: Date; to: Date } | null ) => void; /** The number of months to display. */ numberOfMonths?: number; /** Footer content to be displayed at the bottom of the date picker. */ footer?: ReactNode; -} - -interface CustomMonthsProps { - monthGridProps: React.ComponentProps<'table'>; - onSelect: ( date: Date ) => void; + /** Additional props to be passed to the date picker. */ + [key: string]: unknown; } interface CustomMonthCaptionProps { @@ -86,10 +79,13 @@ interface CustomDayButtonProps { range_end: boolean; }; onSelect: ( date: Date ) => void; -} - -interface DayProps extends CustomDayButtonProps { - className?: string; + onMouseEnter?: ( event: React.MouseEvent ) => void; + onMouseLeave?: ( event: React.MouseEvent ) => void; + onClick?: ( event: React.MouseEvent ) => void; + onKeyDown?: ( event: React.KeyboardEvent ) => void; + onFocus?: ( event: React.FocusEvent ) => void; + onBlur?: ( event: React.FocusEvent ) => void; + children: ReactNode; } const DatePickerComponent = ( { @@ -102,12 +98,11 @@ const DatePickerComponent = ( { mode = 'single', variant = 'normal', alignment = 'horizontal', - // onBlur, - // onChange, numberOfMonths, + disabled, ...props }: DatePickerProps ) => { - // check footer is a valide compoenent + // check footer is a valid component. const isFooter = React.isValidElement( props.footer ) || typeof props.footer === 'function'; @@ -118,13 +113,13 @@ const DatePickerComponent = ( { selectedYear - ( selectedYear % 24 ) ); - if ( selectedDates === null || selectedDates === undefined ) { + if ( selectedDates === undefined ) { if ( mode === 'multiple' ) { selectedDates = []; } else if ( mode === 'range' ) { - selectedDates = { from: null, to: null }; + selectedDates = { from: undefined, to: undefined }; } else { - selectedDates = null; + selectedDates = undefined; } } @@ -326,7 +321,7 @@ const DatePickerComponent = ( { const CustomDayButton = ( { day, modifiers, - onSelect, + ...customDayProps }: CustomDayButtonProps ) => { const { selected: isSelected, @@ -339,12 +334,9 @@ const DatePickerComponent = ( { } = modifiers; const isPartOfRange = isRangeStart || isRangeEnd || isRangeMiddle; - const handleClick = () => ! isDisabled && onSelect( day.date ); const today = new Date(); - const rangeEnd = ( - selectedDates as { from: Date | null; to: Date | null } - )?.to; + const rangeEnd = ( selectedDates as TDateRange )?.to; const isThisMonth = format( day.displayMonth, 'yyyy-MM' ) === format( today, 'yyyy-MM' ); @@ -366,10 +358,10 @@ const DatePickerComponent = ( { const buttonClasses = cn( 'h-10 w-10 flex items-center justify-center transition text-text-secondary relative text-sm', 'border-none rounded', - ( isSelected || isPartOfRange ) && ( ! isOutside || isPreviousMonth ) + ( isSelected || isPartOfRange ) && ! isOutside ? 'bg-background-brand text-text-on-color' : 'bg-transparent hover:bg-button-tertiary-hover', - isRangeMiddle && shouldShowDay && ( ! isOutside || isPartOfRange ) + isRangeMiddle && shouldShowDay && ! isOutside ? 'bg-brand-background-50 text-text-secondary rounded-none' : '', isDisabled @@ -377,20 +369,54 @@ const DatePickerComponent = ( { : 'cursor-pointer', ( isOutside && ! isPartOfRange ) || ( ! shouldShowDay && isOutside ) || - ( isOutside && ! isPreviousMonth ) + ( isOutside && ! isPreviousMonth ) || + isOutside ? disabledOutsideClass : '' ); + const handleHover = ( event: React.MouseEvent ) => { + if ( typeof customDayProps.onMouseEnter === 'function' ) { + customDayProps.onMouseEnter( event ); + } + event.currentTarget.setAttribute( 'data-hover', 'true' ); + }; + const handleLeave = ( event: React.MouseEvent ) => { + if ( typeof customDayProps.onMouseLeave === 'function' ) { + customDayProps.onMouseLeave( event ); + } + event.currentTarget.setAttribute( 'data-hover', 'false' ); + }; + const handleClick = ( event: React.MouseEvent ) => { + if ( typeof customDayProps.onClick === 'function' ) { + customDayProps.onClick( event ); + } + }; + return ( } + disabled={ disabled } { ...props } /> ); @@ -226,7 +243,7 @@ const DatePicker = ( { selectedDates={ selectedDates } setSelectedDates={ handleSelect as ( - dates: Date | Date[] | TDateRange | null + dates: Date | Date[] | TDateRange | undefined ) => void } variant={ variant } @@ -246,6 +263,7 @@ const DatePicker = ( { } + disabled={ disabled } /> ); diff --git a/src/components/datepicker/utils.tsx b/src/components/datepicker/utils.tsx index 9965e7f9..dcf04e0c 100644 --- a/src/components/datepicker/utils.tsx +++ b/src/components/datepicker/utils.tsx @@ -19,7 +19,7 @@ export const getDefaultSelectedValue = ( type: string ) => { return []; } if ( type === 'range' ) { - return { from: null, to: null }; + return { from: undefined, to: undefined }; } - return null; + return undefined; }; diff --git a/tsconfig.app.json b/tsconfig.app.json index a075de67..0080a32f 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -6,6 +6,7 @@ "lib": ["ESNext", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, + "noErrorTruncation": true, /* Bundler mode */ "moduleResolution": "bundler", diff --git a/tsconfig.node.json b/tsconfig.node.json index 567f1dcc..56e46c4e 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -5,6 +5,7 @@ "lib": ["ES2023"], "module": "ESNext", "skipLibCheck": true, + "noErrorTruncation": true, /* Bundler mode */ "moduleResolution": "bundler", diff --git a/version.json b/version.json index 3917e46c..7dd2216d 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "force-ui": "1.3.4" + "force-ui": "1.3.5" }