UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

23 lines 4.03 kB
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import React from 'react'; import { Button } from '../../components/button/button'; import { IconPositionType } from '../../components/button/types/buttonIconPosition'; import { Text } from '../../components/text/text'; import { TextComponentType } from '../../components/text/types/component'; import { AriaLiveOptionType } from '../../types/ariaLiveOption/ariaLiveOption'; import { ElementOrIcon } from '../elementOrIcon/elementOrIcon'; import { InputDigit } from './components/inputDigit'; import { InputDigitSequenceHelpText } from './components/inputDigitSequenceHelpText'; import { InputDigitSequenceTooltip } from './components/inputDigitSquenceTooltip'; import { AnimationInputsContainer, ButtonContainer, IconAndErrorTextContainer, InputDigitsContainer, InputDigitsContainerAnimated, ParentContainer, TitleTooltipContainer, } from './inputDigitSequence.styled'; const InputDigitSequenceStandAloneComponent = ({ error = false, inputMode = 'numeric', dataTestId = 'input-digit-sequence', ...props }, ref) => { const stateStyles = props.styles?.[props.state]; return (_jsxs(ParentContainer, { ref: ref, "data-testid": dataTestId, styles: stateStyles, children: [_jsxs(TitleTooltipContainer, { styles: stateStyles, children: [_jsx(Text, { component: TextComponentType.PARAGRAPH, customTypography: stateStyles?.title, ...props.title, children: props.title?.content }), _jsx(InputDigitSequenceTooltip, { stateStyles: stateStyles, tooltip: props.tooltip, tooltipIcon: props.tooltipIcon })] }), _jsxs(AnimationInputsContainer, { styles: stateStyles, children: [props.animated && !props.labelAnimationDone && (_jsx(InputDigitsContainerAnimated, { animated: props.animated, "aria-hidden": true, boxesAnimationDone: props.boxesAnimationDone, "data-id": "input-container-animated", styles: stateStyles, children: props.inputDigits.map((_, index) => { return (_jsx(InputDigit, { animated: props.animated, ariaHidden: true, boxesAnimationDone: props.boxesAnimationDone, disabled: true, label: index + 1, state: props.state, styles: props.styles, tabIndex: -1 }, index)); }) })), _jsx(InputDigitsContainer, { animated: props.animated, boxesAnimationDone: props.boxesAnimationDone, "data-id": "input-container", labelAnimationDone: props.labelAnimationDone, styles: stateStyles, children: props.inputDigits.map((inputDigit, index) => { return (_jsx(InputDigit, { animated: props.animated, boxesAnimationDone: props.boxesAnimationDone, disabled: props.disabled, error: error, inputDigit: inputDigit, inputId: `${props.digitId}-${index}`, inputMode: inputMode, label: index + 1, showPassword: props.showPassword || props.passwordIndex === index, state: props.state, styles: props.styles, onChange: props.onInputChange(index) }, index)); }) })] }), _jsx(IconAndErrorTextContainer, { "aria-live": AriaLiveOptionType.POLITE, styles: stateStyles, children: error && !!props.errorText && (_jsxs(_Fragment, { children: [_jsx(ElementOrIcon, { customIconStyles: stateStyles?.errorIcon, ...props.errorIcon }), _jsx(Text, { component: TextComponentType.PARAGRAPH, customTypography: stateStyles?.errorText, ...props.errorText, children: props.errorText.content })] })) }), _jsx(InputDigitSequenceHelpText, { dataTestId: `${dataTestId}-help-text`, helpText: props.helpText, styles: stateStyles }), props.actionButton?.content && (stateStyles?.actionButtonSize || props.actionButton?.size) && (_jsx(ButtonContainer, { styles: stateStyles, children: _jsx(Button, { disabled: props.disabled, iconPosition: IconPositionType.LEFT, size: stateStyles?.actionButtonSize, ...props.actionButton, onClick: props.onActionButtonClick, children: props.actionButton?.content }) }))] })); }; export const InputDigitSequenceStandAlone = React.forwardRef(InputDigitSequenceStandAloneComponent); //# sourceMappingURL=inputDigitSequenceStandAlone.js.map