-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(checkboxGroup): add min max prop #491
Conversation
src/checkbox/src/CheckboxGroup.tsx
Outdated
const minRef = computed(() => { | ||
if (props.min && props.max) { | ||
return Math.floor(Math.min(props.min, props.max)) | ||
} else { | ||
return props.min ? Math.floor(props.min) : 0 | ||
} | ||
}) | ||
const maxRef = computed(() => { | ||
if (props.min && props.max) { | ||
return Math.floor(Math.max(props.min, props.max)) | ||
} else { | ||
return props.max ? Math.floor(props.max) : Infinity | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我感觉 min max 的 undefined 在 disabled 里面处理就好了,都转成数字反而很麻烦
src/checkbox/src/Checkbox.tsx
Outdated
disabledUptoNCheckboxGroupPropMin || | ||
disabledUptoNCheckboxGroupPropMax | ||
} | ||
return props.disabled || disabledUptoNCheckboxGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
props.disabled 放在最开始
if (props.disabled) return true
下面的判断走
if (min !== undefined) {
if () return true
}
if (max !== undefined) {
if () return true
}
return xxx
587d57a
to
b43d0d8
Compare
!renderedCheckedRef.value) | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
return false |
src/checkbox/src/Checkbox.tsx
Outdated
if (props.disabled) return true | ||
if (NCheckboxGroup) { | ||
if (NCheckboxGroup.disabledRef.value) return true | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ( | |
const { | |
maxRef: { value: max }, | |
minRef: { value: min } | |
} = NCheckboxGroup | |
if ( |
NCheckboxGroup.maxRef.value !== undefined && | ||
NCheckboxGroup.minRef.value !== undefined | ||
) { | ||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ( | |
const { checkedCountRef: { value: checkedCount } } = NCheckboxGroup | |
return ( |
src/checkbox/src/CheckboxGroup.tsx
Outdated
const minRef = computed(() => { | ||
if (props.min && props.max) { | ||
return Math.floor(Math.min(props.min, props.max)) | ||
} else { | ||
return props.min | ||
} | ||
}) | ||
const maxRef = computed(() => { | ||
if (props.min && props.max) { | ||
return Math.floor(Math.max(props.min, props.max)) | ||
} else { | ||
return props.max | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const minRef = computed(() => { | |
if (props.min && props.max) { | |
return Math.floor(Math.min(props.min, props.max)) | |
} else { | |
return props.min | |
} | |
}) | |
const maxRef = computed(() => { | |
if (props.min && props.max) { | |
return Math.floor(Math.max(props.min, props.max)) | |
} else { | |
return props.max | |
} | |
}) | |
const minRef = toRef(props, 'min') | |
const maxRef = toRef(props, 'max') |
95758a3
to
8460c28
Compare
No description provided.