@fluentui/react-northstar
Version:
A themable React component library.
79 lines (76 loc) • 3.78 kB
JavaScript
exports.__esModule = true;
exports.pillContentClassName = exports.PillContent = void 0;
var React = _interopRequireWildcard(require("react"));
var PropTypes = _interopRequireWildcard(require("prop-types"));
var _reactBindings = require("@fluentui/react-bindings");
var _utils = require("../../utils");
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var pillContentClassName = 'ui-pillcontent';
/**
* A PillContent allows user to classify content.
*/
exports.pillContentClassName = pillContentClassName;
var PillContent = /*#__PURE__*/React.forwardRef(function (props, ref) {
var context = (0, _reactBindings.useFluentContext)();
var _useTelemetry = (0, _reactBindings.useTelemetry)(PillContent.displayName, context.telemetry),
setStart = _useTelemetry.setStart,
setEnd = _useTelemetry.setEnd;
setStart();
var accessibility = props.accessibility,
children = props.children,
className = props.className,
content = props.content,
design = props.design,
styles = props.styles,
variables = props.variables,
size = props.size,
actionable = props.actionable;
var getA11Props = (0, _reactBindings.useAccessibility)(accessibility, {
debugName: PillContent.displayName,
rtl: context.rtl
});
var _useStyles = (0, _reactBindings.useStyles)(PillContent.displayName, {
className: pillContentClassName,
mapPropsToStyles: function mapPropsToStyles() {
return {
size: size,
actionable: actionable
};
},
mapPropsToInlineStyles: function mapPropsToInlineStyles() {
return {
className: className,
design: design,
styles: styles,
variables: variables
};
},
rtl: context.rtl
}),
classes = _useStyles.classes;
var ElementType = (0, _reactBindings.getElementType)(props);
var unhandledProps = (0, _reactBindings.useUnhandledProps)(PillContent.handledProps, props);
var element = /*#__PURE__*/React.createElement(ElementType, getA11Props('root', Object.assign({
className: classes.root,
ref: ref
}, _utils.rtlTextContainer.getAttributes({
forElements: [children]
}), unhandledProps)), (0, _utils.childrenExist)(children) ? children : content);
setEnd();
return element;
});
exports.PillContent = PillContent;
PillContent.displayName = 'PillContent';
PillContent.propTypes = Object.assign({}, _utils.commonPropTypes.createCommon(), {
actionable: PropTypes.bool
});
PillContent.handledProps = Object.keys(PillContent.propTypes);
PillContent.defaultProps = {
as: 'span'
};
PillContent.shorthandConfig = {
mappedProp: 'content'
};
//# sourceMappingURL=PillContent.js.map
;