Repository URL to install this package:
|
Version:
2.1.12 ▾
|
/* eslint-disable max-statements */
import makeSelectState from './makeMultiState'
const fromSelectionToAttributes = (props, name) => {
let {
/**
* @todo @fixme - does not need to be like this!!!
* @description defaults
*/
list = [],
type,
} = props
/**
* @fixme - should be done in data later
*/
if (type === 'fit' || type === 'style1') {
type = 'style'
}
const state = makeSelectState(name)
// selectableOptions.fit
const selectedForType = list[type]
const shouldBeSelected = selectedForType === name
// selectedForType.includes(name)
const shouldBeDisabled = false
if (shouldBeSelected) {
state.select()
} else if (shouldBeDisabled) {
state.disable()
}
/**
* @todo this logic is very confusing
* @todo @deepak #help
*/
return state
}
export { fromSelectionToAttributes }
export default fromSelectionToAttributes