-
-
Notifications
You must be signed in to change notification settings - Fork 260
Add Mode parameter to BitDatePicker (#11889) #11907
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Mode parameter to BitDatePicker (#11889) #11907
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request implements a MonthPicker mode for BitDatePicker, enabling month-only selection with the day defaulted to the 1st. It introduces a new BitDatePickerMode enum, modifies the component to support mode-aware parsing, formatting, and rendering, makes the SelectMonth method asynchronous, and adds comprehensive demo examples. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor.cs (1)
1184-1193: Potential duplicate CSS class on highlighted selected month.When
HighlightSelectedMonthis true and the user is in MonthPicker mode viewing the selected month,bit-dtp-psmmay be appended twice (once at line 1181 and again at line 1191). Consider consolidating the logic to avoid duplicate class entries.🔎 Proposed fix to avoid duplicate class
if (HighlightSelectedMonth && _currentMonth == monthIndex) { className.Append(" bit-dtp-psm"); } - if (Mode == BitDatePickerMode.MonthPicker && CurrentValue.HasValue) + if (Mode == BitDatePickerMode.MonthPicker && CurrentValue.HasValue && HighlightSelectedMonth is false) { var selectedYear = _culture.Calendar.GetYear(CurrentValue.Value.DateTime); var selectedMonth = _culture.Calendar.GetMonth(CurrentValue.Value.DateTime); if (selectedYear == _currentYear && selectedMonth == monthIndex) { className.Append(" bit-dtp-psm"); } }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (6)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor(1 hunks)src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor.cs(9 hunks)src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePickerMode.cs(1 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DatePicker/BitDatePickerDemo.razor(7 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DatePicker/BitDatePickerDemo.razor.cs(3 hunks)src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DatePicker/BitDatePickerDemo.razor.samples.cs(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor.cs (3)
src/Websites/Platform/src/Bit.Websites.Platform.Client/Pages/Templates/Templates05CreateProjectPage.razor.cs (1)
Parameter(254-260)src/BlazorUI/Bit.BlazorUI/Components/Inputs/DateRangePicker/BitDateRangePicker.razor.cs (24)
DateTime(1510-1513)DateTime(1898-1901)DateTime(1903-1906)Task(541-544)Task(590-601)Task(640-685)Task(687-695)Task(697-705)Task(707-715)Task(717-723)Task(725-738)Task(822-888)Task(1515-1520)Task(1522-1527)Task(1580-1597)Task(1599-1609)Task(1611-1621)Task(1709-1718)Task(1917-1939)SelectMonth(890-903)DateTimeOffset(1429-1432)DateTimeOffset(1434-1438)DateTimeOffset(1497-1508)DateTimeOffset(1784-1793)src/BlazorUI/Bit.BlazorUI/Components/Inputs/BitInputBase.cs (1)
InvalidValueBinding(392-397)
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DatePicker/BitDatePickerDemo.razor.cs (3)
src/BlazorUI/Bit.BlazorUI.Assets/Components/Link.razor.cs (1)
Link(6-32)src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor.cs (2)
DateTimeOffset(1198-1201)DateTimeOffset(1203-1207)src/BlazorUI/Bit.BlazorUI/Components/Inputs/DateRangePicker/BitDateRangePicker.razor.cs (4)
DateTimeOffset(1429-1432)DateTimeOffset(1434-1438)DateTimeOffset(1497-1508)DateTimeOffset(1784-1793)
🔇 Additional comments (16)
src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePickerMode.cs (1)
1-19: Well-structured enum definition with clear documentation.The enum is cleanly defined with appropriate XML documentation explaining the behavior of each mode. The MonthPicker description correctly clarifies the day-defaulting behavior.
src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DatePicker/BitDatePickerDemo.razor.cs (3)
395-404: Demo parameter documentation is complete and consistent.The new
Modeparameter entry follows the established pattern with proper type, default value, description, and link to the enum section.
477-498: Enum documentation matches source definition.The
BitDatePickerModeenum section is correctly defined with matching descriptions and values.
950-950: Field follows existing naming conventions.The
monthPickerDatefield is appropriately named and typed for the MonthPicker demo binding.src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor (1)
384-384: Correct async handler pattern for the awaited method.The change to
async () => await SelectMonth(month)properly awaits the now-asyncSelectMonthmethod, ensuring correct async flow in the UI event handler.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DatePicker/BitDatePickerDemo.razor.samples.cs (2)
87-114: Comprehensive MonthPicker demo examples.The new example demonstrates various MonthPicker scenarios including basic usage, two-way binding, min/max constraints, highlighting, and standalone mode. The sample code correctly uses
Mode="BitDatePickerMode.MonthPicker"syntax.
116-122: Sample renumbering is consistent.The existing examples have been properly renumbered to accommodate the new MonthPicker demo.
src/BlazorUI/Bit.BlazorUI/Components/Inputs/DatePicker/BitDatePicker.razor.cs (7)
281-286: Mode parameter correctly defined with lifecycle hook.The
Modeparameter follows existing patterns with[CallOnSet(nameof(OnSetParameters))]to ensure proper re-initialization when the mode changes. Default value ofBitDatePickerMode.DatePickermaintains backward compatibility.
557-560: Mode-aware parsing uses appropriate date patterns.The parsing logic correctly selects
YearMonthPatternfor MonthPicker mode andShortDatePatternfor DatePicker mode, falling back toDateFormatif explicitly provided.
575-582: Formatting logic mirrors parsing for consistency.The
FormatValueAsStringmethod correctly applies the same pattern logic as parsing, ensuring round-trip consistency between displayed and parsed values.
766-794: Async SelectMonth with proper guard clauses and mode handling.The method correctly:
- Checks for
ReadOnlyandInvalidValueBinding()in MonthPicker mode- Respects
IsOpenHasBeenSetbinding constraints- Sets the date to the 1st of the selected month per the enum documentation
- Handles
AutoClosebehavior consistently withSelectDate
1392-1393: ShowDayPicker correctly hides day view in MonthPicker mode.Early return of
falseensures the day picker is never rendered when using MonthPicker mode.
1413-1414: ShowMonthPicker correctly forces month view in MonthPicker mode.Early return of
trueensures the month picker is always visible when using MonthPicker mode.
1435-1436: ResetPickersState initializes overlay correctly for MonthPicker mode.Setting
_isMonthPickerOverlayOnTopand_showMonthPickerAsOverlayInternalbased on Mode ensures the month picker is immediately visible and positioned correctly when the callout opens in MonthPicker mode.src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Pages/Components/Inputs/DatePicker/BitDatePickerDemo.razor (2)
215-356: Correct example renumbering.All subsequent examples have been properly renumbered from example11 through example16, with their corresponding
Id,RazorCode, andCsharpCodeattributes updated consistently.
182-213: Excellent MonthPicker demonstration!The new Mode example comprehensively demonstrates the MonthPicker functionality with multiple scenarios including basic usage, two-way binding, Min/Max constraints, highlighting, and standalone mode. The date format
"MMMM yyyy"correctly displays the selected month and year. ThemonthPickerDatefield is properly declared in the code-behind file.
closes #11889
Summary by CodeRabbit
New Features
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.