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/forms / build / dist / src / new-forms / inputs / renderProps.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const utils_1 = require("@skava/utils");
const styled_1 = require("./styled");
exports.defaultRender = (props) => {
    // console.debug('[1form] defaultRender Input')
    // console.log(props)
    return (React.createElement(styled_1.StyledInput
    // standard
    , { 
        // standard
        isValid: props.isValid, isActive: props.isActive, "data-qa": props['data-qa'], "aria-label": props['aria-label'] || props.label, "aria-invalid": props.isValid === false, 
        // events
        onChange: props.onChange, 
        // @note - these were in wrapper, which did not work well...
        onFocus: props.onFocus, onBlur: props.onBlur, 
        // browser
        id: props.identifier, value: props.value, type: props.type, 
        // need to manage spreading these...
        pattern: props.pattern, minLength: props.minLength, maxLength: props.maxLength, required: props.required, placeholder: props.placeholder, disabled: props.isDisabled, 
        // name
        name: props.propertyName }));
};
exports.renderLabelText = (props) => {
    // console.debug('[1form] renderLabelText')
    // console.log(props)
    return (React.createElement(styled_1.StyledLabelText, { htmlFor: props.identifier, isActive: props.isActive, isValid: props.isValid, hasValue: props.value !== '' }, props.label || props.labelText));
};
exports.renderError = (props) => {
    // console.debug('[1form] renderError')
    // console.log(props)
    return (React.createElement(styled_1.StyledError, { id: props.identifier + '-error', isValid: props.isValid, children: props.state.errorText }));
};
/**
 * @todo use this for documentation on hover or click to expand
 */
exports.defaultRenderAfterInput = (props) => {
    // @todo - description not added, was from codesandbox
    return React.createElement(styled_1.StyledTooltip, { isActive: props.isActive, children: props.tooltip });
};
exports.defaultRenderWrap = (props) => {
    // console.debug('[1form] defaultRenderWrap')
    // console.log(props)
    const remainingProps = utils_1.omit(props, [
        'isActive',
        'data-qa',
        'aria-label',
        'onChange',
        'onFocus',
        'onBlur',
        'identifier',
        'value',
        'label',
        'tooltip',
        'type',
        // isRequired?
        'required',
        'maxLength',
        'minLength',
        'placeholder',
        'pattern',
    ]);
    // @todo this just seems wrong... see the render of the class
    return (React.createElement(styled_1.StyledInputWrap, Object.assign({}, remainingProps),
        exports.renderLabelText(props),
        props.children,
        exports.defaultRenderAfterInput(props),
        exports.renderError(props)));
};
//# sourceMappingURL=renderProps.js.map