fix(form): validation info

This commit is contained in:
07akioni 2021-01-29 17:33:09 +08:00
parent 550524fc04
commit d66197485d
4 changed files with 24 additions and 2 deletions

View File

@ -131,6 +131,7 @@ export default defineComponent({
const NForm = inject<FormInjection | null>('NForm', null)
const formItemSizeRefs = formItemSize(props)
const formItemMiscRefs = formItemMisc(props)
const { validationErrored: validationErroredRef } = formItemMiscRefs
const {
mergedRequired: mergedRequiredRef,
mergedRules: mergedRulesRef
@ -151,7 +152,10 @@ export default defineComponent({
})
function restoreValidation (): void {
explainsRef.value = []
feedbackIdRef.value = createId()
validationErroredRef.value = false
if (props.feedback) {
feedbackIdRef.value = createId()
}
}
function handleContentBlur (): void {
void internalValidate('blur')
@ -239,6 +243,7 @@ export default defineComponent({
const activeRules = (!trigger
? rules
: rules.filter((rule) => {
// if (rule.trigger === undefined) return true
if (Array.isArray(rule.trigger)) {
return rule.trigger.includes(trigger)
} else {
@ -274,6 +279,7 @@ export default defineComponent({
(errors, fields) => {
if (errors?.length) {
explainsRef.value = errors.map((error) => error.message)
validationErroredRef.value = true
resolve({
valid: false,
errors
@ -392,7 +398,7 @@ export default defineComponent({
</div>
{this.mergedShowFeedback ? (
<div key={this.feedbackId} class="n-form-item-feedback-wrapper">
<Transition name="n-fade-down-Transition" mode="out-in">
<Transition name="n-fade-down-transition" mode="out-in">
{{
default: () => {
const feedbacks = (

View File

@ -569,6 +569,8 @@ export default defineComponent({
paddingRight,
textColor,
caretColor,
caretColorError,
caretColorWarning,
textDecorationColor,
border,
borderDisabled,
@ -624,12 +626,14 @@ export default defineComponent({
'--text-color-disabled': textColorDisabled,
'--box-shadow-focus': boxShadowFocus,
// form warning
'--caret-color-warning': caretColorWarning,
'--color-focus-warning': colorFocusWarning,
'--box-shadow-focus-warning': boxShadowFocusWarning,
'--border-warning': borderWarning,
'--border-focus-warning': borderFocusWarning,
'--border-hover-warning': borderHoverWarning,
// form error
'--caret-color-error': caretColorError,
'--color-focus-error': colorFocusError,
'--box-shadow-focus-error': boxShadowFocusError,
'--border-error': borderError,

View File

@ -239,6 +239,9 @@ export default c([
['warning', 'error'].map(status => insideFormItem(status,
cB('input', [
cNotM('disabled', [
c('input', {
caretColor: `var(--caret-color-${status})`
}),
cE('state-border', {
border: `var(--border-${status})`
}),

View File

@ -406,6 +406,15 @@
- [x] form item default type explain
- [x] selection focus style
- [x] refactor site use store!!! singleton
- [ ] 文档网站主题切换
- [ ] 文档网站 demo 样式
- [ ] anchor bug
- [ ] getKey select & autocomplete type safe & input event interface? onInput value | null or value
- [ ] vshow
- [ ] jsx focusin out
- [ ] inject key & value in type
- [ ] form item no label css
- [ ] unify treemate ignored
## Info