mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-30 12:52:43 +08:00
fix: some sonarcube's code fixes (some of them are not problems...)
This commit is contained in:
parent
431c82ca4e
commit
bd220dfa43
@ -51,7 +51,7 @@ export default {
|
||||
}, delay)
|
||||
}
|
||||
},
|
||||
updateLightBarTop (el, getLightBarTop = el => el.offsetTop) {
|
||||
updateLightBarTop (el, getLightBarTop = elm => elm.offsetTop) {
|
||||
if (!el) return
|
||||
this.vanishTimerId && window.clearTimeout(this.vanishTimerId)
|
||||
this.vanishTimerId = null
|
||||
|
@ -392,16 +392,20 @@ export default {
|
||||
*/
|
||||
const order = activeSorter.order
|
||||
if (order === false) console.error(['[naive-ui/data-table/sorted-data]: The order of activeSorter shouldn\'t be `false`'])
|
||||
const sorter = (activeSorter.sorter === 'default' && ((row1, row2) => {
|
||||
const value1 = row1[columnKey]
|
||||
const value2 = row2[columnKey]
|
||||
if (typeof value1 === 'number' && typeof value2 === 'number') {
|
||||
return value1 - value2
|
||||
} else if (typeof value1 === 'string' && typeof value2 === 'string') {
|
||||
return value1.localeCompare(value2)
|
||||
}
|
||||
return 0
|
||||
})) || activeSorter.sorter
|
||||
const sorter = (
|
||||
activeSorter.sorter === 'default'
|
||||
? (row1, row2) => {
|
||||
const value1 = row1[columnKey]
|
||||
const value2 = row2[columnKey]
|
||||
if (typeof value1 === 'number' && typeof value2 === 'number') {
|
||||
return value1 - value2
|
||||
} else if (typeof value1 === 'string' && typeof value2 === 'string') {
|
||||
return value1.localeCompare(value2)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
: activeSorter.sorter
|
||||
)
|
||||
return filteredData.sort((row1, row2) => getFlagOfOrder(order) * sorter(row1, row2))
|
||||
}
|
||||
return this.filteredData
|
||||
|
@ -274,7 +274,7 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
scrollToElement (el, getTop = el => el.offsetTop, getHeight = el => el.offsetHeight) {
|
||||
scrollToElement (el, getTop = elm => elm.offsetTop, getHeight = elm => elm.offsetHeight) {
|
||||
if (this.withoutScrollbar) return
|
||||
const top = getTop(el)
|
||||
const container = this._container()
|
||||
|
@ -340,21 +340,21 @@ export default {
|
||||
mapValuesToOptions (values) {
|
||||
if (!Array.isArray(values)) return []
|
||||
const remote = this.remote
|
||||
const valueToOptionMap = this.valueToOptionMap
|
||||
const valueOptionMap = this.valueToOptionMap
|
||||
const options = []
|
||||
if (remote) {
|
||||
const memorizedValueToOptionMap = this.memorizedValueToOptionMap
|
||||
values.forEach(value => {
|
||||
if (valueToOptionMap.has(value)) {
|
||||
options.push(valueToOptionMap.get(value))
|
||||
if (valueOptionMap.has(value)) {
|
||||
options.push(valueOptionMap.get(value))
|
||||
} else if (memorizedValueToOptionMap.has(value)) {
|
||||
options.push(memorizedValueToOptionMap.get(value))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
values.forEach(value => {
|
||||
if (valueToOptionMap.has(value)) {
|
||||
options.push(valueToOptionMap.get(value))
|
||||
if (valueOptionMap.has(value)) {
|
||||
options.push(valueOptionMap.get(value))
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -378,12 +378,12 @@ export default {
|
||||
clearMultipleSelectValue (value) {
|
||||
if (!Array.isArray(value)) return []
|
||||
const remote = this.remote
|
||||
const valueToOptionMap = this.valueToOptionMap
|
||||
const valueOptionMap = this.valueToOptionMap
|
||||
if (remote) {
|
||||
const memorizedValueToOptionMap = this.memorizedValueToOptionMap
|
||||
return value.filter(v => valueToOptionMap.has(v) || memorizedValueToOptionMap.has(v))
|
||||
return value.filter(v => valueOptionMap.has(v) || memorizedValueToOptionMap.has(v))
|
||||
} else {
|
||||
return value.filter(v => valueToOptionMap.has(v))
|
||||
return value.filter(v => valueOptionMap.has(v))
|
||||
}
|
||||
},
|
||||
handleToggleOption (option) {
|
||||
|
@ -428,15 +428,18 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
handleToTargetClickWhenVirtualScroll () {
|
||||
let nextValue = Array.isArray(this.value) ? this.value : []
|
||||
nextValue = this.sourceCheckedValues.concat(nextValue)
|
||||
const sourceCheckedValueSet = this.sourceCheckedValueSet
|
||||
this.memorizedSourceOptions = this.memorizedSourceOptions
|
||||
.filter(option => !sourceCheckedValueSet.has(option.value))
|
||||
this.$emit('change', nextValue)
|
||||
this.sourceCheckedValues = []
|
||||
},
|
||||
handleToTargetClick () {
|
||||
if (this.virtualScroll) {
|
||||
let newValue = Array.isArray(this.value) ? this.value : []
|
||||
newValue = this.sourceCheckedValues.concat(newValue)
|
||||
const sourceCheckedValueSet = this.sourceCheckedValueSet
|
||||
this.memorizedSourceOptions = this.memorizedSourceOptions
|
||||
.filter(option => !sourceCheckedValueSet.has(option.value))
|
||||
this.$emit('change', newValue)
|
||||
this.sourceCheckedValues = []
|
||||
this.handleToTargetClickWhenVirtualScroll()
|
||||
return
|
||||
}
|
||||
this.enableTargetEnterAnimation = true
|
||||
@ -470,16 +473,19 @@ export default {
|
||||
/** auto play target options enter animation */
|
||||
this.$emit('change', newValue)
|
||||
},
|
||||
handleToSourceClickWhenVirtualScroll () {
|
||||
let newValue = Array.isArray(this.value) ? this.value : []
|
||||
const targetValueSet = this.targetCheckedValueSet
|
||||
newValue = newValue.filter(value => !targetValueSet.has(value))
|
||||
const valueToOptionMap = this.valueToOptionMap
|
||||
const newSourceOptions = this.targetCheckedValues.map(value => valueToOptionMap.get(value))
|
||||
this.memorizedSourceOptions = newSourceOptions.concat(this.memorizedSourceOptions)
|
||||
this.$emit('change', newValue)
|
||||
this.targetCheckedValues = []
|
||||
},
|
||||
handleToSourceClick () {
|
||||
if (this.virtualScroll) {
|
||||
let newValue = Array.isArray(this.value) ? this.value : []
|
||||
const targetValueSet = this.targetCheckedValueSet
|
||||
newValue = newValue.filter(value => !targetValueSet.has(value))
|
||||
const valueToOptionMap = this.valueToOptionMap
|
||||
const newSourceOptions = this.targetCheckedValues.map(value => valueToOptionMap.get(value))
|
||||
this.memorizedSourceOptions = newSourceOptions.concat(this.memorizedSourceOptions)
|
||||
this.$emit('change', newValue)
|
||||
this.targetCheckedValues = []
|
||||
this.handleToSourceClickWhenVirtualScroll()
|
||||
return
|
||||
}
|
||||
this.enableSourceEnterAnimation = true
|
||||
|
@ -49,7 +49,7 @@ const oppositePosition = {
|
||||
'end': 'start'
|
||||
}
|
||||
|
||||
export function getAdjustedPlacementOfTrackingElement (placement = 'bottom-start', trackedRect, trackingRect, flip) {
|
||||
export function getAdjustedPlacementOfTrackingElement (placement, trackedRect, trackingRect, flip) {
|
||||
if (!flip) {
|
||||
return placement
|
||||
}
|
||||
@ -157,21 +157,3 @@ export function getPosition (placement, trackedRect, trackingRect) {
|
||||
if (position.bottom !== null) position.bottom = position.bottom + 'px'
|
||||
return position
|
||||
}
|
||||
|
||||
// function calcPlacementTransform (placement, activatorRect, contentRect, flip) {
|
||||
// const trackedRect = {
|
||||
// left: parseInt(activatorRect.left),
|
||||
// top: parseInt(activatorRect.top),
|
||||
// bottom: parseInt(window.innerHeight - activatorRect.bottom),
|
||||
// right: parseInt(window.innerWidth - activatorRect.right),
|
||||
// width: parseInt(activatorRect.width),
|
||||
// height: parseInt(activatorRect.height)
|
||||
// }
|
||||
// const trackingRect = contentRect
|
||||
// const adjustedPlacement = getAdjustedPlacementOfTrackingElement(placement, trackedRect, trackingRect, flip)
|
||||
// const suggesetedTransfromOrigin = getTransformOriginByPlacement(adjustedPlacement)
|
||||
// const position = getPosition(adjustedPlacement, trackedRect, trackingRect)
|
||||
// return [position, suggesetedTransfromOrigin, adjustedPlacement]
|
||||
// }
|
||||
|
||||
// export default calcPlacementTransform
|
||||
|
Loading…
Reference in New Issue
Block a user