1 | "use strict";
|
2 |
|
3 | function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = exports.BaseFlexGrid = void 0;
|
9 |
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 |
|
12 | var _index = require("../block/index.js");
|
13 |
|
14 | var _reactHelpers = require("../helpers/react-helpers.js");
|
15 |
|
16 | var _overrides = require("../helpers/overrides.js");
|
17 |
|
18 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
19 |
|
20 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21 |
|
22 | function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
23 |
|
24 | function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
25 |
|
26 | function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
27 |
|
28 | function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
29 |
|
30 | function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
31 |
|
32 | function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
33 |
|
34 | function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
35 |
|
36 | var BaseFlexGrid = React.forwardRef(function (_ref, ref) {
|
37 | var display = _ref.display,
|
38 | flexWrap = _ref.flexWrap,
|
39 | restProps = _objectWithoutProperties(_ref, ["display", "flexWrap"]);
|
40 |
|
41 | return React.createElement(_index.Block, _extends({
|
42 | display: display || 'flex',
|
43 | flexWrap: flexWrap || flexWrap === false ? flexWrap : true,
|
44 | "data-baseweb": "flex-grid"
|
45 | }, restProps, {
|
46 | ref: ref
|
47 | }));
|
48 | });
|
49 | exports.BaseFlexGrid = BaseFlexGrid;
|
50 |
|
51 | var FlexGrid = function FlexGrid(_ref2) {
|
52 | var forwardedRef = _ref2.forwardedRef,
|
53 | children = _ref2.children,
|
54 | as = _ref2.as,
|
55 | overrides = _ref2.overrides,
|
56 | flexGridColumnCount = _ref2.flexGridColumnCount,
|
57 | flexGridColumnGap = _ref2.flexGridColumnGap,
|
58 | flexGridRowGap = _ref2.flexGridRowGap,
|
59 | restProps = _objectWithoutProperties(_ref2, ["forwardedRef", "children", "as", "overrides", "flexGridColumnCount", "flexGridColumnGap", "flexGridRowGap"]);
|
60 |
|
61 | var _getOverrides = (0, _overrides.getOverrides)(overrides && overrides.Block, BaseFlexGrid),
|
62 | _getOverrides2 = _slicedToArray(_getOverrides, 2),
|
63 | FlexGrid = _getOverrides2[0],
|
64 | flexGridProps = _getOverrides2[1];
|
65 |
|
66 | return React.createElement(FlexGrid
|
67 |
|
68 |
|
69 | , _extends({
|
70 | ref: forwardedRef,
|
71 | as: as
|
72 | }, restProps, flexGridProps),
|
73 | (0, _reactHelpers.flattenFragments)(children).map(function (child, flexGridItemIndex, _ref3) {
|
74 | var flexGridItemCount = _ref3.length;
|
75 |
|
76 | return React.cloneElement(child, {
|
77 | flexGridColumnCount: flexGridColumnCount,
|
78 | flexGridColumnGap: flexGridColumnGap,
|
79 | flexGridRowGap: flexGridRowGap,
|
80 | flexGridItemIndex: flexGridItemIndex,
|
81 | flexGridItemCount: flexGridItemCount
|
82 | });
|
83 | }));
|
84 | };
|
85 |
|
86 | var FlexGridComponent = React.forwardRef(function (props, ref) {
|
87 | return React.createElement(FlexGrid, _extends({}, props, {
|
88 | forwardedRef: ref
|
89 | }));
|
90 | });
|
91 | FlexGridComponent.displayName = 'FlexGrid';
|
92 | var _default = FlexGridComponent;
|
93 | exports.default = _default; |
\ | No newline at end of file |