Merge pull request #1313 from TuSimple/main

sync main
This commit is contained in:
07akioni 2021-10-10 19:44:01 +08:00 committed by GitHub
commit dcc650dae9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 106 additions and 59 deletions

View File

@ -1,14 +1,17 @@
# CHANGELOG
## Pending
### Feats
- `n-layout` and `n-layout-sider` add `on-scroll` propcloses [#1232](https://github.com/TuSimple/naive-ui/issues/1232).
## 2.19.6 (2021-10-10)
### Fixes
- Fix `n-menu`'s incorrect warning on `default-expanded-keys`.
- Fix `useThemeVars` is sometimes unusable, closes [#1309](https://github.com/TuSimple/naive-ui/issues/1309).
- Fix the `list-style` style of the `<ul>` element.
### Feats
- `n-cascader` provide all options paths in `update:value` callback function, closes [#1235](https://github.com/TuSimple/naive-ui/issues/1235).
- `n-layout` and `n-layout-sider` add `on-scroll` prop, closes [#1232](https://github.com/TuSimple/naive-ui/issues/1232).
## 2.19.5 (2021-10-07)
@ -16,7 +19,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-upload`'s `show-preview-button` prop not working, closes [#1238](https://github.com/TuSimple/naive-ui/issues/1238).
- Fix `n-date-picker`'s `date` type of `action` validate error.
- Fix `n-data-table` throws error when using `selection` and `summary` together, closes [#1276](https://github.com/TuSimple/naive-ui/issues/1276).
- Fix `n-data-table` selection column's width is collapsed when it is set to fixed, closes [#1283](https://github.com/TuSimple/naive-ui/issues/1283).
@ -27,7 +30,7 @@
### Feats
- `n-breadcrumb-item` add `href` prop.
- `n-descriptions` add `separator` propcloses [#1263](https://github.com/TuSimple/naive-ui/issues/1263).
- `n-descriptions` add `separator` prop, closes [#1263](https://github.com/TuSimple/naive-ui/issues/1263).
- `n-dropdown` add `key-field` prop.
- `n-dropdown` add `label-field` prop.
- `n-dropdown` add `children-field` prop.
@ -658,7 +661,7 @@
### Feats
- `n-form`, `n-form-item` enhance `show-require-mark` propcloses [#171](https://github.com/TuSimple/naive-ui/issues/171)
- `n-form`, `n-form-item` enhance `show-require-mark` prop, closes [#171](https://github.com/TuSimple/naive-ui/issues/171)
- `n-dropdown` support class attr, closes [#180](https://github.com/TuSimple/naive-ui/issues/180).
- `n-input` add `show-password-toggle` prop.
- `n-popselect` support class attr.

View File

@ -1,14 +1,17 @@
# CHANGELOG
## Pending
### Feats
- `n-layout``n-layout-sider` 增加 `on-scroll` 属性,关闭 [#1232](https://github.com/TuSimple/naive-ui/issues/1232)
## 2.19.6 (2021-10-10)
### Fixes
- 修复 `n-menu` 对于 `default-expanded-keys` 的错误警报
- 修复 `useThemeVars` 有时无法使用,关闭 [#1309](https://github.com/TuSimple/naive-ui/issues/1309)
- 修复 `<ul>` 元素的 `list-style` 样式
### Feats
- `n-cascader` 值改变时回调函数提供上层节点的全部 options 值,关闭 [#1235](https://github.com/TuSimple/naive-ui/issues/1235)
- `n-layout``n-layout-sider` 增加 `on-scroll` 属性,关闭 [#1232](https://github.com/TuSimple/naive-ui/issues/1232)
## 2.19.5 (2021-10-07)
@ -124,7 +127,7 @@
- 修复 `n-select` `filterable` 下关闭标签 input 光标聚焦问题,关闭 [#1170](https://github.com/TuSimple/naive-ui/issues/1170)
- 修复 `n-button` 在 hover 状态下边框与 `n-badge` 冲突,关闭 [#1195](https://github.com/TuSimple/naive-ui/issues/1195)
- 修复 `n-upload``v-model:file-list` 属性在 `multiple` 属性设为 `true` 的时候没有正确更新,关闭 [#418](https://github.com/TuSimple/naive-ui/issues/418)
- 修复 `useThemeVars` 未应用覆盖的变量值,关闭 [#1194](https://github.com/TuSimple/naive-ui/issues/1194), [#1176](https://github.com/TuSimple/naive-ui/issues/1176)
- 修复 `useThemeVars` 未应用覆盖的变量值,关闭 [#1194](https://github.com/TuSimple/naive-ui/issues/1194)、[#1176](https://github.com/TuSimple/naive-ui/issues/1176)
- Fix `n-tabs` 在 card 类型时左侧滚动的阴影不显示
## 2.18.2 (2021-09-14)
@ -161,7 +164,7 @@
### Feats
- `useDialog` 选项新增 `style` 属性,关闭 [#1054](https://github.com/TuSimple/naive-ui/issues/1054)
- `n-timeline` 新增 `icon` slot, 关闭 [#1096](https://github.com/TuSimple/naive-ui/issues/1096)
- `n-timeline` 新增 `icon` slot关闭 [#1096](https://github.com/TuSimple/naive-ui/issues/1096)
- `n-timeline` 新增 `icon-size` 属性
### Fixes
@ -243,7 +246,7 @@
- `n-transfer` 导出 `TransferOption` 类型
- `n-pagination` 导出 `PaginationInfo` 类型
- `n-data-table` 导出 `DataTableCreateSummary` 类型
- `n-code` 新增 `inline` 属性, 关闭 [#834](https://github.com/TuSimple/naive-ui/issues/834)
- `n-code` 新增 `inline` 属性关闭 [#834](https://github.com/TuSimple/naive-ui/issues/834)
- `n-collapse` 新增 `header-extra` slot关闭 [#1046](https://github.com/TuSimple/naive-ui/issues/1046)
- `n-input` 新增 `show-password-on` 属性
- `n-upload` 增加 `list-type``show-preview-button``on-preview``create-thumbnail-url` 属性
@ -391,7 +394,7 @@
- 修复 `n-message``destroyAll` 方法不生效
- 修复 `n-timeline` 的 header slot 单独使用无效的问题
- 修复 `n-select` 当属性是 `disabled``filterable` 时样式错误, 关闭 [#698](https://github.com/TuSimple/naive-ui/issues/698)
- 修复 `n-select` 当属性是 `disabled``filterable` 时样式错误关闭 [#698](https://github.com/TuSimple/naive-ui/issues/698)
- 修复 `n-upload` 拥有 `file-list` & `disabled` 属性时操作按钮仍然显示,关闭 [#668](https://github.com/TuSimple/naive-ui/issues/668)
## 2.15.9 (2021-07-28)
@ -399,7 +402,7 @@
### Feats
- `n-message` 增加 `destroyAll` 方法
- `n-input-number` 增加 `prefix`、`suffix` slots, 关闭 [#609](https://github.com/TuSimple/naive-ui/issues/609)
- `n-input-number` 增加 `prefix`、`suffix` slots关闭 [#609](https://github.com/TuSimple/naive-ui/issues/609)
### Fixes
@ -409,7 +412,7 @@
### Feats
- `n-menu` 新增 `expand-icon` 属性, 关闭 [#414](https://github.com/TuSimple/naive-ui/issues/414)
- `n-menu` 新增 `expand-icon` 属性关闭 [#414](https://github.com/TuSimple/naive-ui/issues/414)
- `n-descriptions``n-descriptions-item` 增加 `label-style``content-style` 属性,关闭 [#536](https://github.com/TuSimple/naive-ui/issues/536)
### Fixes
@ -421,7 +424,7 @@
### Feats
- `n-dropdown` 选项新增 `show-arrow`属性,关闭 [#647](https://github.com/TuSimple/naive-ui/issues/647)
- `n-time-picker` 增加 `actions` 属性, 关闭 [#401](https://github.com/TuSimple/naive-ui/issues/401)
- `n-time-picker` 增加 `actions` 属性关闭 [#401](https://github.com/TuSimple/naive-ui/issues/401)
- `n-mention` 新增 `render-label` 属性
- `n-switch` 增加 `checked`、`unchecked` 插槽
- `n-switch` 增加 `loading` 属性,关闭 [#301](https://github.com/TuSimple/naive-ui/issues/301)
@ -451,9 +454,9 @@
- `n-dropdown` 新增 `render-icon` 属性
- `n-checkbox-group` 新增 `min``max` 属性
- `n-mention` 新增 `empty` slot
- `useDialog` 选项新增 `on-mask-click`属性, 关闭 [#419](https://github.com/TuSimple/naive-ui/issues/419)
- `useDialog` 选项新增 `on-mask-click`属性关闭 [#419](https://github.com/TuSimple/naive-ui/issues/419)
- `n-space` `justify` 属性支持 `center`、`space-around` 和 `space-between`
- `n-date-picker` 新增 `close-on-select` 属性, 关闭 [#541](https://github.com/TuSimple/naive-ui/issues/541)
- `n-date-picker` 新增 `close-on-select` 属性关闭 [#541](https://github.com/TuSimple/naive-ui/issues/541)
- `n-dialog` 新增 `action` 属性,关闭 [#550](https://github.com/TuSimple/naive-ui/issues/550)
- `n-mention``option.label` 支持使用渲染函数
- `n-color-picker` 新增 `actions` 属性,关闭 [#319](https://github.com/TuSimple/naive-ui/issues/319)
@ -479,7 +482,7 @@
- `n-upload``on-finish` 回调参数中新增 `event`
- `n-rate` 新增 `readonly` 属性
- `n-time-picker` 新增 `seconds`、`minutes`、`hours`属性
- `n-notification` 导出 `NotificationApi`, `NotificationOptions` and `NotificationReactive` 类型
- `n-notification` 导出 `NotificationApi`、`NotificationOptions` 和 `NotificationReactive` 类型
- `n-avatar` 新增 `on-error` 属性,关闭[#394](https://github.com/TuSimple/naive-ui/issues/394)
- `n-image` 新增 `on-error` 属性,关闭[#394](https://github.com/TuSimple/naive-ui/issues/394)
- `n-image` 新增 `object-fit` 属性,关闭[#394](https://github.com/TuSimple/naive-ui/issues/394)
@ -657,7 +660,7 @@
### Feats
- `n-form`, `n-form-item` 增强 `show-require-mark` 属性,关闭 [#171](https://github.com/TuSimple/naive-ui/issues/171)
- `n-form`、`n-form-item` 增强 `show-require-mark` 属性,关闭 [#171](https://github.com/TuSimple/naive-ui/issues/171)
- `n-dropdown` 支持 class 属性,关闭 [#180](https://github.com/TuSimple/naive-ui/issues/180)
- `n-input` 新增 `show-password-toggle` 属性
- `n-popselect` 支持 class 属性
@ -739,7 +742,7 @@
- 修复 `n-calendar``on-update:value` 属性类型
- 修复 `n-form-item``grid-template-columns` 样式属性对子元素布局的影响 [#93](https://github.com/TuSimple/naive-ui/pull/93)
- 修复 `n-data-table``rowKey`, `rowClassName`, `rowProps`, `summary` 属性类型和期望值不兼容
- 修复 `n-data-table``rowKey`、`rowClassName`、`rowProps`、`summary` 属性类型和期望值不兼容
## 2.11.7 (2021-06-12)
@ -1515,7 +1518,7 @@
### Feats
- `$NMessage`, `$NNotification`, `$NConfirm` 的获取到的主题会应用到他们的内部组件
- `$NMessage`、`$NNotification`、`$NConfirm` 的获取到的主题会应用到他们的内部组件
### Fixes

View File

@ -1,6 +1,6 @@
{
"name": "naive-ui",
"version": "2.19.5",
"version": "2.19.6",
"description": "A Vue 3 Component Library. Fairly Complete, Customizable Themes, Uses TypeScript, Not Too Slow",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -22,14 +22,5 @@ export default c('body', `
c('input', `
font-family: inherit;
font-size: inherit;
`),
c('ul', `
list-style: none;
padding: 0;
margin: 0;
`),
c('a', `
color: inherit;
text-decoration: inherit;
`)
])

View File

@ -12,6 +12,15 @@ import { c, cB, cE } from '../../../_utils/cssr'
export default cB('breadcrumb', `
white-space: nowrap;
`, [
c('ul', `
list-style: none;
padding: 0;
margin: 0;
`),
c('a', `
color: inherit;
text-decoration: inherit;
`),
cB('breadcrumb-item', {
fontSize: 'var(--font-size)',
transition: 'color .3s var(--bezier)',

View File

@ -47,7 +47,7 @@ custom-field
| on-blur | `() => void` | `undefined` | Callback on blurred. |
| on-focus | `() => void` | `undefined` | Callback on focused. |
| on-load | `(option: CascaderOption) => Promise<void>` | `undefined` | Callback when a node is loaded. Set `option.children` in the returned promise. Loading will stop after the promise is resolved or rejected. |
| on-update:value | `(value: string \| number \| Array<string \| number> \| null, option: CascaderOption \| Array<CascaderOption \| null> \| null) => void` | `undefined` | Callback executed when the value changes. |
| on-update:value | `(value: string \| number \| Array<string \| number> \| null, option: CascaderOption \| Array<CascaderOption \| null> \| null, pathValues: Array<CascaderOption \| null> \| Array<CascaderOption[] \| null> \| null) => void` | `undefined` | Callback executed when the value changes. |
#### CascaderOption Properties

View File

@ -47,7 +47,7 @@ custom-field
| on-blur | `() => void` | `undefined` | 用户 blur 时执行的回调 |
| on-focus | `() => void` | `undefined` | 用户 focus 时执行的回调 |
| on-load | `(option: CascaderOption) => Promise<void>` | `undefined` | 在点击未加载完成节点时的回调,在返回的 promise 中设定 `option.children`,在返回的 promise resolve 或 reject 之后完成加载 |
| on-update:value | `(value: string \| number \| Array<string \| number> \| null, option: CascaderOption \| Array<CascaderOption \| null> \| null) => void` | `undefined` | 值改变时执行的回调 |
| on-update:value | `(value: string \| number \| Array<string \| number> \| null, option: CascaderOption \| Array<CascaderOption \| null> \| null, pathValues: Array<CascaderOption \| null> \| Array<CascaderOption[] \| null> \| null) => void` | `undefined` | 值改变时执行的回调 |
#### CascaderOption Properties

View File

@ -29,7 +29,7 @@ import { call, useAdjustedTo, warnOnce } from '../../_utils'
import type { ExtractPublicPropTypes, MaybeArray } from '../../_utils'
import { cascaderLight } from '../styles'
import type { CascaderTheme } from '../styles'
import { getPathLabel } from './utils'
import { getPathLabel, getRawNodePath } from './utils'
import CascaderMenu from './CascaderMenu'
import CascaderSelectMenu from './CascaderSelectMenu'
import {
@ -255,7 +255,8 @@ export default defineComponent({
}
function doUpdateValue (
value: Value | null,
option: CascaderOption | null | Array<CascaderOption | null>
option: CascaderOption | null | Array<CascaderOption | null>,
optionPath: null | CascaderOption[] | Array<CascaderOption[] | null>
): void {
const {
onUpdateValue,
@ -263,11 +264,15 @@ export default defineComponent({
onChange
} = props
const { nTriggerFormInput, nTriggerFormChange } = formItem
if (onUpdateValue) call(onUpdateValue as OnUpdateValueImpl, value, option)
if (_onUpdateValue) {
call(_onUpdateValue as OnUpdateValueImpl, value, option)
if (onUpdateValue) {
call(onUpdateValue as OnUpdateValueImpl, value, option, optionPath)
}
if (_onUpdateValue) {
call(_onUpdateValue as OnUpdateValueImpl, value, option, optionPath)
}
if (onChange) {
call(onChange as OnUpdateValueImpl, value, option, optionPath)
}
if (onChange) call(onChange as OnUpdateValueImpl, value, option)
uncontrolledValueRef.value = value
nTriggerFormInput()
nTriggerFormChange()
@ -281,7 +286,7 @@ export default defineComponent({
function doCheck (key: Key): boolean {
const { cascade, multiple, filterable } = props
const {
value: { check, getNode }
value: { check, getNode, getPath }
} = treeMateRef
if (multiple) {
try {
@ -293,6 +298,9 @@ export default defineComponent({
checkedKeys,
checkedKeys.map(
(checkedKey) => getNode(checkedKey)?.rawNode || null
),
checkedKeys.map((checkedKey) =>
getRawNodePath(getPath(checkedKey)?.treeNodePath)
)
)
if (filterable) focusSelectionInput()
@ -314,13 +322,21 @@ export default defineComponent({
if (mergedCheckStrategyRef.value === 'child') {
const tmNode = getNode(key)
if (tmNode?.isLeaf) {
doUpdateValue(key, tmNode.rawNode)
doUpdateValue(
key,
tmNode.rawNode,
getRawNodePath(getPath(key).treeNodePath)
)
} else {
return false
}
} else {
const tmNode = getNode(key)
doUpdateValue(key, tmNode?.rawNode || null)
doUpdateValue(
key,
tmNode?.rawNode || null,
getRawNodePath(getPath(key)?.treeNodePath)
)
}
}
return true
@ -329,7 +345,7 @@ export default defineComponent({
const { cascade, multiple } = props
if (multiple) {
const {
value: { uncheck, getNode }
value: { uncheck, getNode, getPath }
} = treeMateRef
const { checkedKeys } = uncheck(key, mergedKeysRef.value.checkedKeys, {
cascade,
@ -337,7 +353,10 @@ export default defineComponent({
})
doUpdateValue(
checkedKeys,
checkedKeys.map((checkedKey) => getNode(checkedKey)?.rawNode || null)
checkedKeys.map((checkedKey) => getNode(checkedKey)?.rawNode || null),
checkedKeys.map((checkedKey) =>
getRawNodePath(getPath(checkedKey)?.treeNodePath)
)
)
}
}
@ -617,9 +636,9 @@ export default defineComponent({
function handleClear (e: MouseEvent): void {
e.stopPropagation()
if (props.multiple) {
doUpdateValue([], [])
doUpdateValue([], [], [])
} else {
doUpdateValue(null, null)
doUpdateValue(null, null, null)
}
}
function handleTriggerFocus (e: FocusEvent): void {
@ -678,7 +697,7 @@ export default defineComponent({
if (multiple && Array.isArray(mergedValue)) {
doUncheck((option as any)[valueField])
} else {
doUpdateValue(null, null)
doUpdateValue(null, null, null)
}
}
function handleKeyDown (e: KeyboardEvent): void {

View File

@ -40,15 +40,17 @@ export type OnUpdateValue = (
(string[] | null) &
(number[] | null) &
(Array<string | number> | null),
option: CascaderOption &
null &
option: null &
CascaderOption &
CascaderOption[] &
Array<CascaderOption | null>
Array<CascaderOption | null>,
path: null & CascaderOption[] & Array<CascaderOption[] | null>
) => void
export type OnUpdateValueImpl = (
value: Value | null,
option: CascaderOption | null | Array<CascaderOption | null>
option: CascaderOption | null | Array<CascaderOption | null>,
path: Array<CascaderOption[] | null> | CascaderOption[] | null
) => void
export type MenuModel = TmNode[][]

View File

@ -1,6 +1,15 @@
import type { TmNode, CascaderOption } from './interface'
import type { SelectBaseOption } from '../../select/src/interface'
function getRawNodePath (tmNodes: TmNode[]): CascaderOption[]
function getRawNodePath (tmNodes: TmNode[] | undefined): CascaderOption[] | null
function getRawNodePath (
tmNodes: TmNode[] | undefined
): CascaderOption[] | null {
if (!tmNodes) return null
return tmNodes.map((tmNode) => tmNode.rawNode)
}
function traverseWithCallback<T extends { children?: T[] }> (
options: T[],
beforeCallback: (node: T) => void,
@ -17,6 +26,8 @@ function traverseWithCallback<T extends { children?: T[] }> (
}
}
export { getRawNodePath }
function createSelectOptions (
tmNodes: TmNode[],
checkStrategyIsChild: boolean

View File

@ -4,8 +4,8 @@ import { commonLight } from '../_styles/common'
import type { ThemeCommonVars } from '../_styles/common'
export function useThemeVars (): ComputedRef<ThemeCommonVars> {
const configProviderInjection = inject(configProviderInjectionKey, null)
return computed(() => {
const configProviderInjection = inject(configProviderInjectionKey, null)
if (configProviderInjection === null) return commonLight
const {
mergedThemeRef: { value: mergedTheme },

View File

@ -81,6 +81,9 @@ export default defineComponent({
case 'ArrowRight':
props.onNext?.()
break
case 'Escape':
toggleShow()
break
}
}
@ -149,6 +152,10 @@ export default defineComponent({
on('mousemove', document, handleMouseMove)
on('mouseup', document, handleMouseUp)
}
function handlePreviewDblclick (): void {
scale = scale === 1 ? 2 : 1
derivePreviewStyle()
}
let scale = 1
let rotate = 0
@ -230,6 +237,7 @@ export default defineComponent({
appear: useIsMounted(),
displayed: displayedRef,
handlePreviewMousedown,
handlePreviewDblclick,
syncTransformOrigin,
handleAfterLeave: () => {
rotate = 0
@ -363,6 +371,7 @@ export default defineComponent({
<img
draggable={false}
onMousedown={this.handlePreviewMousedown}
onDblclick={this.handlePreviewDblclick}
class={`${clsPrefix}-image-preview`}
key={this.previewSrc}
src={this.previewSrc}

View File

@ -10,7 +10,7 @@ export default c([
cB('image-container', 'position: fixed;')
]),
cB('image-preview-container', `
position: absolute;
position: fixed;
left: 0;
right: 0;
top: 0;

View File

@ -1 +1 @@
export default '2.19.5'
export default '2.19.6'