'use strict';

const index = require('./index-ed42e2ee.js');

/**
 * Create id for messaging
 */
const messageId = (id, messageType) => {
    return `${id}__${messageType}-message`;
};
/**
 * Assign aria-description id to relate messages with form element
 */
const assignDescription = (id, invalid, helperMessage) => {
    if (!helperMessage)
        return;
    let relatedId = messageId(id, 'helper');
    if (invalid)
        relatedId = messageId(id, 'error');
    return relatedId;
};
/**
 * Updates the `invalid` prop of a form element based on it's values validity
 */
const isRequired = (target, component) => {
    if (!target || !component)
        return;
    if (component.required === true) {
        (target.checkValidity() === false) ? component.invalid = true : component.invalid = false;
    }
};

/**
 * Returns markup for an input label.
 * @internal
 */
const PdsLabel = ({ classNames, htmlFor, text }) => (index.h("label", { class: classNames, htmlFor: htmlFor }, text));

exports.PdsLabel = PdsLabel;
exports.assignDescription = assignDescription;
exports.isRequired = isRequired;
exports.messageId = messageId;

//# sourceMappingURL=pds-label-15dd83ef.js.map