feat(calendar): add function to support setting start or end of range separately#2347
Merged
uyarn merged 6 commits intoTencent:developfrom Dec 31, 2025
Merged
feat(calendar): add function to support setting start or end of range separately#2347uyarn merged 6 commits intoTencent:developfrom
uyarn merged 6 commits intoTencent:developfrom
Conversation
Merged
16 tasks
There was a problem hiding this comment.
Pull request overview
This PR adds support for setting calendar range boundaries independently by enhancing the range parameter handling in the calendar component. It allows users to specify only a start date (using a fallback for the end) or only an end date (using a fallback for the start), rather than requiring both boundaries to be valid dates.
Key changes:
- New utility function
handleRangeprocesses range inputs with flexible boundary validation, using fallback values (1970-01-01 for start, current date for end) when one boundary is invalid - New type definitions (
CalendarValue,CalendarRange) to support string or Date formats for calendar ranges - Comprehensive test suite with 100% coverage for the new utility functions
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| js/calendar/types.ts | Defines CalendarValue and CalendarRange types to support string or Date range boundaries |
| js/calendar/consts.ts | Exports MIN_YEAR constant (1970) used as fallback for undefined start boundary |
| js/calendar/utils.ts | Implements handleRange function with boundary validation, fallback logic, and automatic swapping for out-of-order dates |
| test/unit/calendar/utils.test.js | Adds comprehensive test coverage for createDefaultCurDate and handleRange functions across all scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
uyarn
approved these changes
Dec 31, 2025
Collaborator
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 这个 PR 的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
单独设置日历范围上/下限本质上为完善对
range参数传入值的数据处理,即处理以下情况:以上核心在于判断列表值的两项是否符合日期格式,故首先增加了一个日期格式校验逻辑
然后在解构出列表值的两项后先进行日期格式校验即可直接处理第一种情况。
随后添加
fallback逻辑,当出现第二种情况时,为空缺的另外一侧边界填充内置值;若为第三种情况则保持原逻辑不变📝 更新日志
feat(calendar): 新增
calendar组件的公用类型和公用常量feat(calendar): 新增
range参数处理函数以支持单独设置日历范围上限或下限test(calendar): 新增
createDefaultCurDate和handleRange的测试案例并提升覆盖率至100%本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单