UNPKG

mic-inspector

Version:

A react inspector which a most similar of Chorme DevTools inspector

47 lines (46 loc) 2.05 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from 'react'; import { PropertyValue } from '../property-value'; import { useStyles } from './use-styles'; import { isObjectOrFunction } from '../property-value/locale'; import { NumberValue } from '../number-value'; import { ObjectValue } from '../object-value'; import { StringValue } from '../string-value'; import { ObjectValue as ReactInspectorObjectValue } from 'react-inspector'; /** * Unknown value * @param param0 UnknownValueProps */ export function UnknownValue(_a) { var { className, value } = _a, props = __rest(_a, ["className", "value"]); const type = typeof value; const title = type === 'symbol' ? Symbol.prototype.toString.call(value) : `${value}`; const ps = Object.assign(Object.assign({ className: useStyles(className) }, (isObjectOrFunction(value) ? {} : { title })), props); switch (type) { case 'number': return React.createElement(NumberValue, Object.assign({ value: value }, ps)); case 'symbol': return React.createElement(StringValue, Object.assign({ value: title, before: '', after: '' }, ps)); case 'string': return React.createElement(StringValue, Object.assign({ value: value }, ps)); case 'object': if (value) { return React.createElement(ObjectValue, Object.assign({ value: value }, ps)); } break; } return (React.createElement(PropertyValue, Object.assign({}, ps), React.createElement(ReactInspectorObjectValue, { object: value }))); }