Repository URL to install this package:
|
Version:
1.3.3 ▾
|
import { isSafe, isUndefined } from 'exotic'
import { InputChain } from './InputChain'
import { inputChains } from './config'
import { toggleTypes, validTypes, types } from './_fixture'
// >>>>>>>>
// we were running this on every render
// now we run this 1x
export const fromPropsToInputChain = (props): InputChain => {
// console.log('fromPropsToInputChain', props)
const isSatisfiedByProps = chain => chain.isSatisfiedByProps(props)
const InputChainDecorator = inputChains.find(isSatisfiedByProps)
// console.log(InputChainDecorator)
// @todo pass in form
if (isSafe(InputChainDecorator)) {
const instance = new InputChainDecorator()
// console.log({ instance })
return instance
} else {
console.warn('[InputChain] fromPropsToInputChain COULD NOT FIND CHAIN')
console.dir(props)
}
return -0
}
export const isVisible = isHidden => isUndefined(isHidden) || (isSafe(isHidden) && !isHidden)
// @todo @fixme @exotic dunno why
// if (hasOwnProp(types, key) === true) {
export const hasType = key => Object.prototype.hasOwnProperty.call(types, key)
export const unknown = (key, value) => {
// unknown
const msg = 'unknown data ' + JSON.stringify({ [key]: value })
// @todo - but not on server
// const unknown = new Error(msg)
// console.error(unknown)
// console.warn(msg)
}
export const shouldRemap = key => {
return key === 'identifier'
}
// because nested will always be observable...
// types.dynamicState = types