Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/ui / src / forms / input / deps.ts
Size: Mime:
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