@primer/react
Version:
An implementation of GitHub's Primer Design System using React
34 lines (31 loc) • 1.25 kB
JavaScript
import React__default, { useContext } from 'react';
import InputLabel from '../../_InputLabel.js';
import { MarkdownEditorContext } from './_MarkdownEditorContext.js';
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
// ref is not forwarded because InputLabel does not (yet) support it
const Legend = ({
sx,
...props
}) => {
// using context and definining a Slot in the same component causes an infinite loop, so these must be separate
const {
disabled,
required
} = useContext(MarkdownEditorContext);
return /*#__PURE__*/React__default.createElement(InputLabel, _extends({
as: "legend",
disabled: disabled,
required: required
}, props, {
sx: {
cursor: 'default',
mb: 1,
...sx
}
}));
};
Legend.displayName = "Legend";
Legend.displayName = 'MarkdownEditor.Label';
const Label = props => /*#__PURE__*/React__default.createElement(Legend, props);
Label.displayName = "Label";
export { Label };