-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feat(date picker) support month type #1202
Feat(date picker) support month type #1202
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1202 +/- ##
==========================================
- Coverage 50.39% 50.09% -0.31%
==========================================
Files 518 519 +1
Lines 12834 12919 +85
Branches 3649 3675 +26
==========================================
+ Hits 6468 6472 +4
- Misses 5270 5349 +79
- Partials 1096 1098 +2
Continue to review full report at Codecov.
|
f0f491c
to
b388449
Compare
src/date-picker/src/panel/month.tsx
Outdated
{{ | ||
default: () => [ | ||
...this.monthArray.map((monthItem, i) => ( | ||
<div |
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.
我感觉 item render 的重复好像比较多,月份和年份有很多重复代码。把公共的部分抽象一下。
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.
Validate 相关的事情也可以在 month 面板上考虑一下,is-date-disabled
应该要想办法作用上去。
dc23e55
to
fac9c2d
Compare
src/date-picker/src/DatePicker.tsx
Outdated
@@ -448,6 +469,7 @@ export default defineComponent({ | |||
function openCalendar (): void { | |||
if (mergedDisabledRef.value || mergedShowRef.value) return | |||
doUpdateShow(true) | |||
void nextTick(scrollTimer) |
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.
if (props.type === 'month')
src/date-picker/src/DatePicker.tsx
Outdated
) : ( | ||
<DatePanel {...commonPanelProps} /> | ||
), | ||
|
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.
src/date-picker/src/interface.ts
Outdated
monthScrollRef?: ScrollbarInst | ||
yearScrollRef?: VirtualListInst |
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.
monthScrollRef?: ScrollbarInst | |
yearScrollRef?: VirtualListInst | |
monthScrollRef: ScrollbarInst | null | |
yearScrollRef: VirtualListInst | null |
类型表现要尽量和 runtime 一致
src/date-picker/src/panel/month.tsx
Outdated
}, | ||
render () { | ||
const { mergedClsPrefix, mergedTheme, shortcuts } = this | ||
const itemRenderer = (item: YearItem | MonthItem, i: number): VNode => { |
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.
这个看看能不提到 setup 里面,在 render 里面不好看
src/date-picker/src/utils.ts
Outdated
@@ -59,6 +85,28 @@ export interface DateItem { | |||
ts: number | |||
} | |||
|
|||
export interface MonthItem { | |||
type: string |
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.
type: 'month'
这种地方要精确,type guard 才会生效,不然 if else 分支都拿不到正确的类型
src/date-picker/src/utils.ts
Outdated
inCurrentMonth: boolean | ||
selected: boolean | ||
ts: number | ||
showText?: string |
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.
showText?: string | |
formattedText?: string |
d0c70dc
to
9e8d7b8
Compare
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.
整体看着还行,十一我调整一下。
给这个 month 的写俩测试吧。
主要是确保数据层面可以发出来对的数据,还有确保 disabled date 是可以生效的。
No description provided.