@wordpress/components
Version:
UI components for WordPress.
58 lines (57 loc) • 1.61 kB
JavaScript
// packages/components/src/text-control/index.tsx
import clsx from "clsx";
import { useInstanceId } from "@wordpress/compose";
import { forwardRef } from "@wordpress/element";
import BaseControl from "../base-control";
import { maybeWarnDeprecated36pxSize } from "../utils/deprecated-36px-size";
import { jsx as _jsx } from "react/jsx-runtime";
function UnforwardedTextControl(props, ref) {
const {
__nextHasNoMarginBottom,
__next40pxDefaultSize = false,
label,
hideLabelFromVision,
value,
help,
id: idProp,
className,
onChange,
type = "text",
...additionalProps
} = props;
const id = useInstanceId(TextControl, "inspector-text-control", idProp);
const onChangeValue = (event) => onChange(event.target.value);
maybeWarnDeprecated36pxSize({
componentName: "TextControl",
size: void 0,
__next40pxDefaultSize
});
return /* @__PURE__ */ _jsx(BaseControl, {
__nextHasNoMarginBottom,
__associatedWPComponentName: "TextControl",
label,
hideLabelFromVision,
id,
help,
className,
children: /* @__PURE__ */ _jsx("input", {
className: clsx("components-text-control__input", {
"is-next-40px-default-size": __next40pxDefaultSize
}),
type,
id,
value,
onChange: onChangeValue,
"aria-describedby": !!help ? id + "__help" : void 0,
ref,
...additionalProps
})
});
}
var TextControl = forwardRef(UnforwardedTextControl);
var text_control_default = TextControl;
export {
TextControl,
text_control_default as default
};
//# sourceMappingURL=index.js.map