UNPKG

6.91 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = void 0;
9
10var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
12var _reactBase16Styling = require("react-base16-styling");
13
14var _solarized = _interopRequireDefault(require("./themes/solarized"));
15
16function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
18function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
20var colorMap = function colorMap(theme) {
21 return {
22 BACKGROUND_COLOR: theme.base00,
23 TEXT_COLOR: theme.base07,
24 STRING_COLOR: theme.base0B,
25 DATE_COLOR: theme.base0B,
26 NUMBER_COLOR: theme.base09,
27 BOOLEAN_COLOR: theme.base09,
28 NULL_COLOR: theme.base08,
29 UNDEFINED_COLOR: theme.base08,
30 FUNCTION_COLOR: theme.base08,
31 SYMBOL_COLOR: theme.base08,
32 LABEL_COLOR: theme.base0D,
33 ARROW_COLOR: theme.base0D,
34 ITEM_STRING_COLOR: theme.base0B,
35 ITEM_STRING_EXPANDED_COLOR: theme.base03
36 };
37};
38
39var valueColorMap = function valueColorMap(colors) {
40 return {
41 String: colors.STRING_COLOR,
42 Date: colors.DATE_COLOR,
43 Number: colors.NUMBER_COLOR,
44 Boolean: colors.BOOLEAN_COLOR,
45 Null: colors.NULL_COLOR,
46 Undefined: colors.UNDEFINED_COLOR,
47 Function: colors.FUNCTION_COLOR,
48 Symbol: colors.SYMBOL_COLOR
49 };
50};
51
52var getDefaultThemeStyling = function getDefaultThemeStyling(theme) {
53 var colors = colorMap(theme);
54 return {
55 tree: {
56 border: 0,
57 padding: 0,
58 marginTop: '0.5em',
59 marginBottom: '0.5em',
60 marginLeft: '0.125em',
61 marginRight: 0,
62 listStyle: 'none',
63 MozUserSelect: 'none',
64 WebkitUserSelect: 'none',
65 backgroundColor: colors.BACKGROUND_COLOR
66 },
67 value: function value(_ref, nodeType, keyPath) {
68 var style = _ref.style;
69 return {
70 style: _objectSpread(_objectSpread({}, style), {}, {
71 paddingTop: '0.25em',
72 paddingRight: 0,
73 marginLeft: '0.875em',
74 WebkitUserSelect: 'text',
75 MozUserSelect: 'text',
76 wordWrap: 'break-word',
77 paddingLeft: keyPath.length > 1 ? '2.125em' : '1.25em',
78 textIndent: '-0.5em',
79 wordBreak: 'break-all'
80 })
81 };
82 },
83 label: {
84 display: 'inline-block',
85 color: colors.LABEL_COLOR
86 },
87 valueLabel: {
88 margin: '0 0.5em 0 0'
89 },
90 valueText: function valueText(_ref2, nodeType) {
91 var style = _ref2.style;
92 return {
93 style: _objectSpread(_objectSpread({}, style), {}, {
94 color: valueColorMap(colors)[nodeType]
95 })
96 };
97 },
98 itemRange: function itemRange(styling, expanded) {
99 return {
100 style: {
101 paddingTop: expanded ? 0 : '0.25em',
102 cursor: 'pointer',
103 color: colors.LABEL_COLOR
104 }
105 };
106 },
107 arrow: function arrow(_ref3, nodeType, expanded) {
108 var style = _ref3.style;
109 return {
110 style: _objectSpread(_objectSpread({}, style), {}, {
111 marginLeft: 0,
112 transition: '150ms',
113 WebkitTransition: '150ms',
114 MozTransition: '150ms',
115 WebkitTransform: expanded ? 'rotateZ(90deg)' : 'rotateZ(0deg)',
116 MozTransform: expanded ? 'rotateZ(90deg)' : 'rotateZ(0deg)',
117 transform: expanded ? 'rotateZ(90deg)' : 'rotateZ(0deg)',
118 transformOrigin: '45% 50%',
119 WebkitTransformOrigin: '45% 50%',
120 MozTransformOrigin: '45% 50%',
121 position: 'relative',
122 lineHeight: '1.1em',
123 fontSize: '0.75em'
124 })
125 };
126 },
127 arrowContainer: function arrowContainer(_ref4, arrowStyle) {
128 var style = _ref4.style;
129 return {
130 style: _objectSpread(_objectSpread({}, style), {}, {
131 display: 'inline-block',
132 paddingRight: '0.5em',
133 paddingLeft: arrowStyle === 'double' ? '1em' : 0,
134 cursor: 'pointer'
135 })
136 };
137 },
138 arrowSign: {
139 color: colors.ARROW_COLOR
140 },
141 arrowSignInner: {
142 position: 'absolute',
143 top: 0,
144 left: '-0.4em'
145 },
146 nestedNode: function nestedNode(_ref5, keyPath, nodeType, expanded, expandable) {
147 var style = _ref5.style;
148 return {
149 style: _objectSpread(_objectSpread({}, style), {}, {
150 position: 'relative',
151 paddingTop: '0.25em',
152 marginLeft: keyPath.length > 1 ? '0.875em' : 0,
153 paddingLeft: !expandable ? '1.125em' : 0
154 })
155 };
156 },
157 rootNode: {
158 padding: 0,
159 margin: 0
160 },
161 nestedNodeLabel: function nestedNodeLabel(_ref6, keyPath, nodeType, expanded, expandable) {
162 var style = _ref6.style;
163 return {
164 style: _objectSpread(_objectSpread({}, style), {}, {
165 margin: 0,
166 padding: 0,
167 WebkitUserSelect: expandable ? 'inherit' : 'text',
168 MozUserSelect: expandable ? 'inherit' : 'text',
169 cursor: expandable ? 'pointer' : 'default'
170 })
171 };
172 },
173 nestedNodeItemString: function nestedNodeItemString(_ref7, keyPath, nodeType, expanded) {
174 var style = _ref7.style;
175 return {
176 style: _objectSpread(_objectSpread({}, style), {}, {
177 paddingLeft: '0.5em',
178 cursor: 'default',
179 color: expanded ? colors.ITEM_STRING_EXPANDED_COLOR : colors.ITEM_STRING_COLOR
180 })
181 };
182 },
183 nestedNodeItemType: {
184 marginLeft: '0.3em',
185 marginRight: '0.3em'
186 },
187 nestedNodeChildren: function nestedNodeChildren(_ref8, nodeType, expanded) {
188 var style = _ref8.style;
189 return {
190 style: _objectSpread(_objectSpread({}, style), {}, {
191 padding: 0,
192 margin: 0,
193 listStyle: 'none',
194 display: expanded ? 'block' : 'none'
195 })
196 };
197 },
198 rootNodeChildren: {
199 padding: 0,
200 margin: 0,
201 listStyle: 'none'
202 }
203 };
204};
205
206var createStylingFromTheme = (0, _reactBase16Styling.createStyling)(getDefaultThemeStyling, {
207 defaultBase16: _solarized.default
208});
209var _default = createStylingFromTheme;
210exports.default = _default;
\No newline at end of file