mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
commit
1662605688
@ -1,6 +1,12 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.12.1
|
||||
## 2.12.2 (2021-06-19)
|
||||
|
||||
### Fixes
|
||||
|
||||
- Fix `n-form-item` always show require mark.
|
||||
|
||||
## 2.12.1 (2021-06-19)
|
||||
|
||||
### Feats
|
||||
|
||||
|
@ -1,6 +1,12 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.12.1
|
||||
## 2.12.2 (2021-06-19)
|
||||
|
||||
### Fixes
|
||||
|
||||
- 修复 `n-form-item` 始终展示必需的星号
|
||||
|
||||
## 2.12.1 (2021-06-19)
|
||||
|
||||
### Feats
|
||||
|
||||
|
@ -34,8 +34,10 @@
|
||||
- 新增属性
|
||||
|
||||
```
|
||||
- `n-xxx` add xxx prop.
|
||||
- `n-xxx` 新增 xxx 属性
|
||||
- `n-xxx` add `xxx` prop.
|
||||
- `n-xxx` 新增 `xxx` 属性
|
||||
|
||||
注意 `xxx` 属性必须是 kebab-case,不能是 camelCase。
|
||||
```
|
||||
|
||||
- 修复 Bug
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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",
|
||||
"main": "lib/index.js",
|
||||
"module": "es/index.js",
|
||||
|
@ -41,7 +41,7 @@ const formProps = {
|
||||
size: String as PropType<'small' | 'medium' | 'large'>,
|
||||
showRequireMark: {
|
||||
type: [Boolean, String] as PropType<'left' | 'right' | boolean>,
|
||||
default: 'right'
|
||||
default: undefined
|
||||
},
|
||||
showFeedback: {
|
||||
type: Boolean,
|
||||
|
@ -401,6 +401,7 @@ export default defineComponent({
|
||||
class={`${mergedClsPrefix}-form-item-label`}
|
||||
style={this.mergedLabelStyle as any}
|
||||
>
|
||||
{/* undefined || 'right' || true || false */}
|
||||
{this.mergedShowRequireMark !== 'left'
|
||||
? renderSlot($slots, 'label', undefined, () => [this.label])
|
||||
: null}
|
||||
|
@ -57,10 +57,7 @@ export function formItemMisc (props: FormItemSetupProps) {
|
||||
const mergedShowRequireMarkRef = computed(() => {
|
||||
const { showRequireMark } = props
|
||||
if (showRequireMark !== undefined) return showRequireMark
|
||||
if (NForm?.showRequireMark !== undefined) {
|
||||
return NForm.showRequireMark
|
||||
}
|
||||
return undefined
|
||||
return NForm?.showRequireMark
|
||||
})
|
||||
const validationErroredRef = ref(false)
|
||||
const mergedValidationStatusRef = computed(() => {
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
92
src/form/tests/Form.spec.tsx
Normal file
92
src/form/tests/Form.spec.tsx
Normal 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
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
@ -1 +1 @@
|
||||
export default '2.12.1'
|
||||
export default '2.12.2'
|
||||
|
Loading…
Reference in New Issue
Block a user