import { h } from './index-8b335bbb.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 }) => (h("label", { class: classNames, htmlFor: htmlFor }, text));

export { PdsLabel as P, assignDescription as a, isRequired as i, messageId as m };

//# sourceMappingURL=pds-label-1f80d632.js.map