UNPKG

@wordpress/components

Version:
49 lines (48 loc) 1.33 kB
// packages/components/src/text-control/index.tsx import { useInstanceId } from "@wordpress/compose"; import { forwardRef } from "@wordpress/element"; import BaseControl from "../base-control/index.mjs"; import { jsx as _jsx } from "react/jsx-runtime"; function UnforwardedTextControl(props, ref) { const { // Prevent passing legacy props to `input`. __nextHasNoMarginBottom: _, __next40pxDefaultSize: __, 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); return /* @__PURE__ */ _jsx(BaseControl, { label, hideLabelFromVision, id, help, className, children: /* @__PURE__ */ _jsx("input", { className: "components-text-control__input", type, id, value, onChange: onChangeValue, "aria-describedby": !!help ? id + "__help" : void 0, ref, ...additionalProps }) }); } var TextControl = forwardRef(UnforwardedTextControl); TextControl.displayName = "TextControl"; var text_control_default = TextControl; export { TextControl, text_control_default as default }; //# sourceMappingURL=index.mjs.map