@talend/react-components
Version:
Set of react components.
32 lines • 1.01 kB
JavaScript
import PropTypes from 'prop-types';
import JSONLike from '../JSONLike';
import theme from './List.module.scss';
import { jsx as _jsx } from "react/jsx-runtime";
function List({
data,
...props
}) {
if (!Array.isArray(data) && !Array.isArray(data.dataset)) {
return null;
}
// The datas can be an array or an array in an object. We assign the value correctly here.
const dataset = Array.isArray(data) ? data : data.dataset;
return /*#__PURE__*/_jsx("ul", {
className: `${theme.container} tc-object-viewer list-unstyled`,
id: props.id,
children: dataset.map((obj, index) => /*#__PURE__*/_jsx("li", {
children: /*#__PURE__*/_jsx(JSONLike, {
data: obj,
...props,
jsonpath: `$[${index}]`
})
}, index))
});
}
List.displayName = 'List';
List.propTypes = {
data: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).isRequired,
id: PropTypes.string
};
export default List;
//# sourceMappingURL=List.component.js.map