|
1 | | -import { createElement, FunctionComponent, useState, memo } from 'react' |
2 | | -import { isObject, isArray } from './utils' |
3 | | -import { isValidJson } from '../../overmind/utils' |
4 | | -import * as styles from './styles' |
5 | 1 | import { css } from 'emotion' |
6 | | -import { colors } from '../../theme' |
| 2 | +import { FunctionComponent, createElement, memo, useState } from 'react' |
7 | 3 | import { FaEdit } from 'react-icons/fa' |
8 | 4 |
|
| 5 | +import { isValidJson } from '../../overmind/utils' |
| 6 | +import { colors } from '../../theme' |
| 7 | +import * as styles from './styles' |
| 8 | +import { isArray, isObject } from './utils' |
| 9 | + |
9 | 10 | function renderValue({ |
10 | 11 | path, |
11 | 12 | value, |
@@ -215,7 +216,10 @@ const Nested: FunctionComponent<NestedProps> = memo( |
215 | 216 | <span className={styles.keyCount}> |
216 | 217 | {isArray |
217 | 218 | ? keys.length + ' items' |
218 | | - : keys.slice(0, 3).join(', ') + '...'} |
| 219 | + : keys |
| 220 | + .sort() |
| 221 | + .slice(0, 3) |
| 222 | + .join(', ') + '...'} |
219 | 223 | </span> |
220 | 224 | {endBracket} |
221 | 225 | </PathTools> |
@@ -257,18 +261,20 @@ const Nested: FunctionComponent<NestedProps> = memo( |
257 | 261 | selectedStatePath, |
258 | 262 | }) |
259 | 263 | ) |
260 | | - : Object.keys(value).map((key) => |
261 | | - renderValue({ |
262 | | - path: path.concat((path ? '.' : '') + key), |
263 | | - value: value[key], |
264 | | - renderPaths, |
265 | | - expandedPaths, |
266 | | - onClickPath, |
267 | | - onSubmitState, |
268 | | - onToggleExpand, |
269 | | - selectedStatePath, |
270 | | - }) |
271 | | - )} |
| 264 | + : Object.keys(value) |
| 265 | + .sort() |
| 266 | + .map((key) => |
| 267 | + renderValue({ |
| 268 | + path: path.concat((path ? '.' : '') + key), |
| 269 | + value: value[key], |
| 270 | + renderPaths, |
| 271 | + expandedPaths, |
| 272 | + onClickPath, |
| 273 | + onSubmitState, |
| 274 | + onToggleExpand, |
| 275 | + selectedStatePath, |
| 276 | + }) |
| 277 | + )} |
272 | 278 | </div> |
273 | 279 | <div className={styles.bracket(false)}>{endBracket}</div> |
274 | 280 | </div> |
|
0 commit comments