@fluentui/react-northstar
Version:
A themable React component library.
59 lines (57 loc) • 3.44 kB
JavaScript
exports.__esModule = true;
exports.DebugPanelData = void 0;
var React = _interopRequireWildcard(require("react"));
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 DebugPanelData = function DebugPanelData(props) {
var data = props.data,
_props$indent = props.indent,
indent = _props$indent === void 0 ? 2 : _props$indent,
highlightKey = props.highlightKey,
overrides = props.overrides,
comments = props.comments,
commentKeyPredicate = props.commentKeyPredicate;
var isValidComment = typeof comments === 'string' && commentKeyPredicate && commentKeyPredicate(comments);
if (typeof data === 'undefined') {
return isValidComment ? /*#__PURE__*/React.createElement("abbr", {
title: comments
}, "undefined") : /*#__PURE__*/React.createElement("span", null, "undefined");
}
if (data === null || typeof data !== 'object') {
return isValidComment ? /*#__PURE__*/React.createElement("abbr", {
title: comments
}, JSON.stringify(data)) : /*#__PURE__*/React.createElement("span", null, JSON.stringify(data));
}
return /*#__PURE__*/React.createElement(React.Fragment, null, '{', Object.keys(data).map(function (key, idx) {
var value = data[key];
var comment = comments && comments[key];
var highlight = (0, _utils.find)(data, key, highlightKey);
var overridden = (0, _utils.isOverridden)(data, key, overrides);
return /*#__PURE__*/React.createElement("div", {
key: key
}, /*#__PURE__*/React.createElement("span", {
style: {
background: highlight ? 'rgb(255,255,224)' : ''
}
}, ' '.repeat(indent), /*#__PURE__*/React.createElement("span", {
style: {
textDecoration: overridden ? 'line-through' : 'none'
}
}, /*#__PURE__*/React.createElement("span", {
style: {
color: typeof value === 'object' ? 'grey' : '#b82519'
}
}, key), ': ', /*#__PURE__*/React.createElement(DebugPanelData, {
data: value,
comments: comment,
commentKeyPredicate: commentKeyPredicate,
indent: indent + 2,
overrides: overrides ? overrides[key] : null,
highlightKey: highlightKey
})), ','));
}), (indent > 2 ? ' '.repeat(indent - 2) : '') + "}");
};
exports.DebugPanelData = DebugPanelData;
//# sourceMappingURL=DebugPanelData.js.map
;