UNPKG

react-spatial

Version:

Components to build React map apps.

50 lines (43 loc) 1.64 kB
import React from 'react'; import PropTypes from 'prop-types'; // Import default implementation from react-styleguidist using the full path import ComponentsListRenderer from 'react-styleguidist/lib/client/rsg-components/ComponentsList/ComponentsListRenderer'; import getUrl from 'react-styleguidist/lib/client/utils/getUrl'; var propTypes = { items: PropTypes.array.isRequired, classes: PropTypes.object, hashPath: PropTypes.array, useRouterLinks: PropTypes.bool, useHashId: PropTypes.bool, }; var defaultProps = { classes: null, hashPath: [], useRouterLinks: false, useHashId: true, }; function ComponentsList(ref) { var classes = ref.classes; var items = ref.items; var useRouterLinks = ref.useRouterLinks; if ( useRouterLinks === void 0 ) useRouterLinks = false; var useHashId = ref.useHashId; var hashPath = ref.hashPath; var mappedItems = items.map(function (item) { return (Object.assign({}, item, {href: item.href ? item.href : // Conflict with Permalink Component: Remove the first '/' to avoid page reload on click getUrl({ name: item.name, slug: item.slug, anchor: !useRouterLinks, hashPath: useRouterLinks ? hashPath : false, id: useRouterLinks ? useHashId : false, }) .replace(/^\/index.html+/g, '') .replace(/^\/+/g, '')})); }); return React.createElement( ComponentsListRenderer, { classes: classes, items: mappedItems }); } ComponentsList.propTypes = propTypes; ComponentsList.defaultProps = defaultProps; export default ComponentsList; //# sourceMappingURL=ComponentsList.js.map