Merge branch 'main' of github.com:TuSimple/naive-ui into main

This commit is contained in:
caoyugang 2021-06-20 14:52:24 +08:00
commit 8cbee0d1eb
11 changed files with 130 additions and 20 deletions

View File

@ -1,6 +1,18 @@
# CHANGELOG # CHANGELOG
## 2.12.1 ## Pending
### Fixes
- Fix `n-tree` drag over leaf node causes error, closes [#200](https://github.com/TuSimple/naive-ui/issues/200).
## 2.12.2 (2021-06-19)
### Fixes
- Fix `n-form-item` always show require mark.
## 2.12.1 (2021-06-19)
### Feats ### Feats
@ -13,7 +25,7 @@
### Fixes ### Fixes
- Fix `n-input` jitter when Chinese and English characters switch input, closes [#174](https://github.com/TuSimple/naive-ui/issues/174). - Fix `n-input` baseline shifts when mix Chinese and English characters in input, closes [#174](https://github.com/TuSimple/naive-ui/issues/174).
- Fix `n-icon` use setup script, `$parent` is an empty object by default, and access `$parent.$options` will be `undefined`. - Fix `n-icon` use setup script, `$parent` is an empty object by default, and access `$parent.$options` will be `undefined`.
- Fix `n-notification` position not correct. - Fix `n-notification` position not correct.
- Fix `n-message` content & option type not correct. - Fix `n-message` content & option type not correct.

View File

@ -1,6 +1,18 @@
# CHANGELOG # CHANGELOG
## 2.12.1 ## Pending
### Fixes
- 修复 `n-tree` 拖拽悬浮叶节点报错,关闭 [#200](https://github.com/TuSimple/naive-ui/issues/200)
## 2.12.2 (2021-06-19)
### Fixes
- 修复 `n-form-item` 始终展示必需的星号
## 2.12.1 (2021-06-19)
### Feats ### Feats

View File

@ -34,8 +34,10 @@
- 新增属性 - 新增属性
``` ```
- `n-xxx` add xxx prop. - `n-xxx` add `xxx` prop.
- `n-xxx` 新增 xxx 属性 - `n-xxx` 新增 `xxx` 属性
注意 `xxx` 属性必须是 kebab-case不能是 camelCase。
``` ```
- 修复 Bug - 修复 Bug

View File

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

View File

@ -41,7 +41,7 @@ const formProps = {
size: String as PropType<'small' | 'medium' | 'large'>, size: String as PropType<'small' | 'medium' | 'large'>,
showRequireMark: { showRequireMark: {
type: [Boolean, String] as PropType<'left' | 'right' | boolean>, type: [Boolean, String] as PropType<'left' | 'right' | boolean>,
default: 'right' default: undefined
}, },
showFeedback: { showFeedback: {
type: Boolean, type: Boolean,

View File

@ -401,6 +401,7 @@ export default defineComponent({
class={`${mergedClsPrefix}-form-item-label`} class={`${mergedClsPrefix}-form-item-label`}
style={this.mergedLabelStyle as any} style={this.mergedLabelStyle as any}
> >
{/* undefined || 'right' || true || false */}
{this.mergedShowRequireMark !== 'left' {this.mergedShowRequireMark !== 'left'
? renderSlot($slots, 'label', undefined, () => [this.label]) ? renderSlot($slots, 'label', undefined, () => [this.label])
: null} : null}

View File

@ -57,10 +57,7 @@ export function formItemMisc (props: FormItemSetupProps) {
const mergedShowRequireMarkRef = computed(() => { const mergedShowRequireMarkRef = computed(() => {
const { showRequireMark } = props const { showRequireMark } = props
if (showRequireMark !== undefined) return showRequireMark if (showRequireMark !== undefined) return showRequireMark
if (NForm?.showRequireMark !== undefined) { return NForm?.showRequireMark
return NForm.showRequireMark
}
return undefined
}) })
const validationErroredRef = ref(false) const validationErroredRef = ref(false)
const mergedValidationStatusRef = computed(() => { const mergedValidationStatusRef = computed(() => {

View File

@ -1,8 +0,0 @@
import { mount } from '@vue/test-utils'
import { NForm } from '../index'
describe('n-form', () => {
it('should work with import on demand', () => {
mount(NForm)
})
})

View File

@ -0,0 +1,92 @@
import { mount } from '@vue/test-utils'
import { h } from 'vue'
import { NInput } from '../../input'
import { NForm, NFormItem } from '../index'
describe('n-form', () => {
it('should work with import on demand', () => {
mount(NForm)
})
describe('require mark', () => {
it("doesn't show by default", () => {
const wrapper = mount(() => (
<NForm>
{{
default: () => {
return (
<NFormItem label="star kirby">
{{
default: () => <NInput />
}}
</NFormItem>
)
}
}}
</NForm>
))
expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
false
)
})
it('shows when props.showRequireMark is set', () => {
const wrapper = mount(() => (
<NForm>
{{
default: () => {
return (
<NFormItem showRequireMark label="star kirby">
{{
default: () => <NInput />
}}
</NFormItem>
)
}
}}
</NForm>
))
expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
true
)
})
it('shows when required rule is set in form', () => {
const wrapper = mount(() => (
<NForm rules={{ starKirby: { required: true } }}>
{{
default: () => {
return (
<NFormItem label="star kirby" path="starKirby">
{{
default: () => <NInput />
}}
</NFormItem>
)
}
}}
</NForm>
))
expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
true
)
})
it('shows when required rule is set in form item', () => {
const wrapper = mount(() => (
<NForm>
{{
default: () => {
return (
<NFormItem label="star kirby" rule={{ required: true }}>
{{
default: () => <NInput />
}}
</NFormItem>
)
}
}}
</NForm>
))
expect(wrapper.find('.n-form-item-label__asterisk').exists()).toEqual(
true
)
})
})
})

View File

@ -521,6 +521,8 @@ export default defineComponent({
window.clearTimeout(expandTimerId) window.clearTimeout(expandTimerId)
expandTimerId = null expandTimerId = null
} }
// Don't expand leaf node.
if (node.isLeaf) return
nodeKeyToBeExpanded = node.key nodeKeyToBeExpanded = node.key
const expand = (): void => { const expand = (): void => {
if (nodeKeyToBeExpanded !== node.key) return if (nodeKeyToBeExpanded !== node.key) return

View File

@ -1 +1 @@
export default '2.12.1' export default '2.12.2'