1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | exports.__esModule = true;
|
6 | exports["default"] = exports.ListIcon = exports.ListItem = void 0;
|
7 |
|
8 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9 |
|
10 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
11 |
|
12 | var _core = require("@emotion/core");
|
13 |
|
14 | var _react = require("react");
|
15 |
|
16 | var _Box = _interopRequireDefault(require("../Box"));
|
17 |
|
18 | var _Icon = _interopRequireDefault(require("../Icon"));
|
19 |
|
20 | var _PseudoBox = _interopRequireDefault(require("../PseudoBox"));
|
21 |
|
22 | var _utils = require("../utils");
|
23 |
|
24 |
|
25 | var List = (0, _react.forwardRef)(function (_ref, ref) {
|
26 | var _ref$styleType = _ref.styleType,
|
27 | styleType = _ref$styleType === void 0 ? "none" : _ref$styleType,
|
28 | _ref$stylePos = _ref.stylePos,
|
29 | stylePos = _ref$stylePos === void 0 ? "inside" : _ref$stylePos,
|
30 | spacing = _ref.spacing,
|
31 | children = _ref.children,
|
32 | props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, ["styleType", "stylePos", "spacing", "children"]);
|
33 | var validChildren = (0, _utils.cleanChildren)(children);
|
34 | return (0, _core.jsx)(_Box["default"], (0, _extends2["default"])({
|
35 | ref: ref,
|
36 | as: "ul",
|
37 | listStyleType: styleType,
|
38 | listStylePosition: stylePos
|
39 | }, props), validChildren.map(function (child, index) {
|
40 | var isLast = index + 1 === _react.Children.count(children);
|
41 |
|
42 | if (isLast) {
|
43 | return child;
|
44 | }
|
45 |
|
46 | return (0, _react.cloneElement)(child, {
|
47 | spacing: spacing
|
48 | });
|
49 | }));
|
50 | });
|
51 | List.displayName = "List";
|
52 | var ListItem = (0, _react.forwardRef)(function (_ref2, ref) {
|
53 | var spacing = _ref2.spacing,
|
54 | props = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, ["spacing"]);
|
55 | return (0, _core.jsx)(_PseudoBox["default"], (0, _extends2["default"])({
|
56 | ref: ref,
|
57 | as: "li",
|
58 | mb: spacing
|
59 | }, props));
|
60 | });
|
61 | exports.ListItem = ListItem;
|
62 | ListItem.diplayName = "ListItem";
|
63 |
|
64 | var ListIcon = function ListIcon(_ref3) {
|
65 | var icon = _ref3.icon,
|
66 | props = (0, _objectWithoutPropertiesLoose2["default"])(_ref3, ["icon"]);
|
67 |
|
68 | if (typeof icon === "string") {
|
69 | return (0, _core.jsx)(_Icon["default"], (0, _extends2["default"])({
|
70 | name: icon,
|
71 | mr: 2
|
72 | }, props));
|
73 | }
|
74 |
|
75 | return (0, _core.jsx)(_Box["default"], (0, _extends2["default"])({
|
76 | as: icon,
|
77 | d: "inline",
|
78 | focusable: "false",
|
79 | size: "1em",
|
80 | color: "currentColor",
|
81 | mr: 2
|
82 | }, props));
|
83 | };
|
84 |
|
85 | exports.ListIcon = ListIcon;
|
86 | var _default = List;
|
87 | exports["default"] = _default; |
\ | No newline at end of file |