UNPKG

1 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/extends";
2import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3var _excluded = ["data"];
4import React from 'react';
5import PropTypes from 'prop-types';
6import JSONNestedNode from './JSONNestedNode';
7
8// Returns the "n Items" string for this node,
9// generating and caching it if it hasn't been created yet.
10function createItemString(data) {
11 return "".concat(data.length, " ").concat(data.length !== 1 ? 'items' : 'item');
12}
13
14// Configures <JSONNestedNode> to render an Array
15var JSONArrayNode = function JSONArrayNode(_ref) {
16 var data = _ref.data,
17 props = _objectWithoutProperties(_ref, _excluded);
18
19 return /*#__PURE__*/React.createElement(JSONNestedNode, _extends({}, props, {
20 data: data,
21 nodeType: "Array",
22 nodeTypeIndicator: "[]",
23 createItemString: createItemString,
24 expandable: data.length > 0
25 }));
26};
27
28JSONArrayNode.propTypes = {
29 data: PropTypes.array
30};
31export default JSONArrayNode;
\No newline at end of file