UNPKG

@retailmenot/anchor

Version:

A React UI Library by RetailMeNot

40 lines 1.6 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; // REACT import * as React from 'react'; // VENDOR import classNames from 'classnames'; import styled from '@xstyled/styled-components'; import { space as spaceStyles } from '@xstyled/system'; // COMPONENTS import { Item } from './Item'; import { Title } from './Title'; import { Divider } from './Divider'; const itemComponent = { item: Item, title: Title, divider: Divider, }; const StyledList = styled('div') ` box-sizing: border-box; ${spaceStyles} `; export const List = (_a) => { var { className, children = [], items } = _a, props = __rest(_a, ["className", "children", "items"]); return (React.createElement(StyledList, Object.assign({ className: classNames('anchor-list', className) }, props), items ? items.map((_a, index) => { var { label } = _a, _b = _a.value, { listItemType = 'item', key } = _b, r = __rest(_b, ["listItemType", "key"]); return React.createElement(itemComponent[listItemType], Object.assign({ label, key: key || `list-${index}` }, r), label); }) : children)); }; //# sourceMappingURL=List.component.js.map