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 / inputs / TextBox / deps / toAttributes.ts
Size: Mime:
/* eslint-disable max-statements */
/* @lint - is a bunch of getters */
import { TextBoxProps, TextBoxState, TextBoxComponent } from '../typings'
import { toErrorProps } from './toErrorProps'
import { toClassList } from './toClassList'
import { toPassThroughProps } from './toPassThroughProps'
import { toValidationProps } from './toValidationProps'
import { toType } from './toType'
import { createGetFromPropsOrState } from './createGetFromPropsOrState'
import { toPlaceholder } from './toPlaceholder'
import { toAccessibleAttributes } from './toAccessibleProps'
import { toAriaLabel } from './toAriaLabel'

export function toAttributes(instance: TextBoxComponent) {
  const { props, state } = instance
  const classList = toClassList(props, state)
  const passthroughProps = toPassThroughProps(props, state)
  const validationProps = toValidationProps(props, state)
  const type = toType(props, state)
  const get = createGetFromPropsOrState(instance)
  const placeholderText = toPlaceholder(props, state)
  const accessibleProps = toAccessibleAttributes(props, state)
  const { hasError } = toErrorProps(props, state)
  const animatePlaceholder = get('animatePlaceholder')
  const name = get('name')
  const isDisabled = get('isDisabled')
  // @todo should not come like this, should go as passthroughProps
  const dataQa = get('dataQa')
  const qa = get('qa')
  const wrapperProps = { ...accessibleProps, hasError }
  const labelText = get('labelText')
  const ariaLabel = toAriaLabel(props, state)
  const inputIcon = get('icon')

  return {
    passthroughProps,
    wrapperProps,
    validationProps,
    classList,
    placeholderText,
    animatePlaceholder,
    name,
    isDisabled,
    type,
    dataQa,
    qa,
    labelText,
    ariaLabel,
    inputIcon,
  }
}