1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
6 | var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
7 | var box = require('@spark-web/box');
|
8 | var divider = require('@spark-web/divider');
|
9 | var ts = require('@spark-web/utils/ts');
|
10 | var react = require('react');
|
11 | var theme = require('@spark-web/theme');
|
12 | var jsxRuntime = require('react/jsx-runtime');
|
13 |
|
14 | var alignLookup = {
|
15 | left: 'start',
|
16 | center: 'center',
|
17 | right: 'end',
|
18 | stretch: 'stretch'
|
19 | };
|
20 | var alignToAlignItems = theme.createResponsiveMapFn(alignLookup);
|
21 |
|
22 | var _excluded = ["align", "children", "data", "dividers"];
|
23 | var Stack = ts.forwardRefWithAs(function (_ref, forwardedRef) {
|
24 | var _ref$align = _ref.align,
|
25 | align = _ref$align === void 0 ? 'stretch' : _ref$align,
|
26 | children = _ref.children,
|
27 | data = _ref.data,
|
28 | dividers = _ref.dividers,
|
29 | props = _objectWithoutProperties(_ref, _excluded);
|
30 |
|
31 | var alignItems = alignToAlignItems(align);
|
32 |
|
33 | var rootProps = _objectSpread({
|
34 | ref: forwardedRef,
|
35 | alignItems: alignItems,
|
36 | data: data,
|
37 | display: 'flex',
|
38 | flexDirection: 'column'
|
39 | }, props);
|
40 |
|
41 |
|
42 | if (!dividers) {
|
43 | return jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
44 | children: children
|
45 | }));
|
46 | }
|
47 |
|
48 |
|
49 |
|
50 | var childArray = react.Children.toArray(children);
|
51 | return jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread({}, rootProps), {}, {
|
52 | children: childArray.map(function (child, idx) {
|
53 | return jsxRuntime.jsxs(react.Fragment, {
|
54 | children: [dividers && idx ? jsxRuntime.jsx(divider.Divider, {}) : null, child]
|
55 | }, child.key || idx);
|
56 | })
|
57 | }));
|
58 | });
|
59 |
|
60 | exports.Stack = Stack;
|