/* @oracle/oraclejet-preact: undefined */
import { jsx, jsxs } from 'preact/jsx-runtime';
import { useCallback } from 'preact/hooks';
import { c as classNames } from './classNames-4e12b00d.js';
import { u as usePress } from './usePress-051f5adb.js';
import './FormFieldContext-68eb5946.js';
import { u as useFormFieldContext } from './useFormFieldContext-626574fd.js';
import './MaxLengthCounterStyles.styles.css';

var hide = 'MaxLengthCounterStyles_hide__7dy9j71';
var maxLengthCounterBase = 'MaxLengthCounterStyles_maxLengthCounterBase__7dy9j70';
var spanStyles = 'MaxLengthCounterStyles_spanStyles__7dy9j72';

const noop = () => { };
function MaxLengthCounter({ maxLength, valueLength = 0, onClick }) {
    const { isFocused } = useFormFieldContext();
    // We don't want mousedown on this component to do anything, so prevent the default behavior.
    const killEvent = useCallback((event) => event.preventDefault(), []);
    const textClasses = classNames([!isFocused && hide]);
    const { pressProps } = usePress(onClick ?? noop);
    return (jsx("div", { class: maxLengthCounterBase, onMouseDown: killEvent, ...pressProps, children: jsxs("span", { class: textClasses, children: [jsx("span", { class: spanStyles, children: valueLength }), jsx("span", { class: spanStyles, children: "/" }), jsx("span", { class: spanStyles, children: maxLength })] }) }));
}

export { MaxLengthCounter as M };
//# sourceMappingURL=MaxLengthCounter-181b4fc9.js.map
