Repository URL to install this package:
|
Version:
4.1.0-ulta.3 ▾
|
/* 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,
}
}