fix(date-picker): date action validate error (#1259)

* fix: date-picker date action validate error

* fix: update

* fix: validate error

Co-authored-by: yugang.cao <yugang.cao@tusimple.ai>
This commit is contained in:
Yugang Cao 2021-10-02 00:15:08 +08:00 committed by GitHub
parent b6ebd7614f
commit b688493c8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 0 deletions

View File

@ -10,6 +10,7 @@
- Fix `n-form-item`'s content is too long and the width is incorrect
- Fix `n-layout-sider`'s `arrow-circle`'s icon style.
- Fix `n-upload`'s `show-preview-button` prop not workingcloses [#1238](https://github.com/TuSimple/naive-ui/issues/1238).
- Fix `n-date-picker`s `date` type of `action` validate error.
## 2.19.3 (2021-09-28)

View File

@ -6,6 +6,7 @@
- 修复 `n-form-item` 中组件内容过长影响 `n-form-item` 宽度
- 修复 `n-layout-sider``arrow-circle` 的 icon 样式
- 修复 `n-upload``show-preview-button` 属性失效,关闭 [#1238](https://github.com/TuSimple/naive-ui/issues/1238)
- 修复 `n-date-picker``date` 类型的 `action` 验证错误
## 2.19.3 (2021-09-28)

View File

@ -234,6 +234,32 @@ export default defineComponent({
const mergedFormatRef = computed(() => {
return props.format || DATE_FORMAT[props.type]
})
const mergedActionsRef = computed(() => {
const { actions, type } = props
if (actions !== undefined) return actions
switch (type) {
case 'date': {
return ['clear', 'now']
}
case 'datetime': {
return ['clear', 'now', 'confirm']
}
case 'daterange': {
return ['clear', 'confirm']
}
case 'datetimerange': {
return ['clear', 'confirm']
}
default: {
warn(
'data-picker',
"The type is wrong, n-date-picker's type only supports `date`, `datetime`, `daterange` and `datetimerange`."
)
break
}
}
})
function doUpdatePendingValue (value: Value | null): void {
pendingValueRef.value = value
}
@ -544,6 +570,7 @@ export default defineComponent({
handlePanelUpdateValue,
handlePanelConfirm,
mergedTheme: themeRef,
actions: mergedActionsRef,
triggerCssVars: computed(() => {
const {
common: { cubicBezierEaseInOut },