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 = void 0;
|
9 |
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 |
|
12 | var _index = require("../block/index.js");
|
13 |
|
14 | var _overrides = require("../helpers/overrides.js");
|
15 |
|
16 | function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
17 |
|
18 | 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; }
|
19 |
|
20 | 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); }
|
21 |
|
22 | 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; }
|
23 |
|
24 | 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; }
|
25 |
|
26 | var aspectRatioBoxStyle = function aspectRatioBoxStyle(_ref) {
|
27 | var $aspectRatio = _ref.$aspectRatio;
|
28 | return {
|
29 | position: 'relative',
|
30 | '::before': {
|
31 | content: '""',
|
32 | width: '1px',
|
33 | marginLeft: '-1px',
|
34 | float: 'left',
|
35 | height: 0,
|
36 | paddingTop: "".concat(100 / $aspectRatio, "%"),
|
37 | pointerEvents: 'none'
|
38 | },
|
39 | '::after': {
|
40 | content: '""',
|
41 | display: 'table',
|
42 | clear: 'both'
|
43 | }
|
44 | };
|
45 | };
|
46 |
|
47 | var AspectRatioBox = function AspectRatioBox(_ref2) {
|
48 | var forwardedRef = _ref2.forwardedRef,
|
49 | _ref2$aspectRatio = _ref2.aspectRatio,
|
50 | aspectRatio = _ref2$aspectRatio === void 0 ? 1 : _ref2$aspectRatio,
|
51 | _ref2$overrides = _ref2.overrides,
|
52 | overrides = _ref2$overrides === void 0 ? {} : _ref2$overrides,
|
53 | restProps = _objectWithoutProperties(_ref2, ["forwardedRef", "aspectRatio", "overrides"]);
|
54 |
|
55 | var aspectRatioBoxOverrides = {
|
56 | Block: {
|
57 | style: aspectRatioBoxStyle
|
58 | }
|
59 | };
|
60 | var blockOverrides = (0, _overrides.mergeOverrides)(aspectRatioBoxOverrides, overrides);
|
61 | return React.createElement(_index.Block
|
62 |
|
63 |
|
64 | , _extends({
|
65 | ref: forwardedRef,
|
66 | overrides: blockOverrides,
|
67 | $aspectRatio: aspectRatio,
|
68 | "data-baseweb": "aspect-ratio-box"
|
69 | }, restProps));
|
70 | };
|
71 |
|
72 | var AspectRatioBoxComponent = React.forwardRef(function (props, ref) {
|
73 | return React.createElement(AspectRatioBox, _extends({}, props, {
|
74 | forwardedRef: ref
|
75 | }));
|
76 | });
|
77 | AspectRatioBoxComponent.displayName = 'AspectRatioBox';
|
78 | var _default = AspectRatioBoxComponent;
|
79 | exports.default = _default; |
\ | No newline at end of file |