UNPKG

baseui

Version:

A React Component library implementing the Base design language

67 lines (64 loc) 2.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var React = _interopRequireWildcard(require("react")); var _block = require("../block"); var _overrides = require("../helpers/overrides"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); } /* Copyright (c) Uber Technologies, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. */ // @ts-ignore const aspectRatioBoxStyle = ({ $aspectRatio }) => ({ position: 'relative', '::before': { content: '""', width: '1px', marginLeft: '-1px', float: 'left', height: 0, paddingTop: `${100 / $aspectRatio}%`, pointerEvents: 'none' }, '::after': { content: '""', display: 'table', clear: 'both' } }); // eslint-disable-next-line @typescript-eslint/no-explicit-any const AspectRatioBox = ({ forwardedRef, aspectRatio = 1, overrides = {}, ...restProps }) => { const aspectRatioBoxOverrides = { Block: { style: aspectRatioBoxStyle } }; const blockOverrides = (0, _overrides.mergeOverrides)(aspectRatioBoxOverrides, overrides); return /*#__PURE__*/React.createElement(_block.Block // coerced to any because of how react components are typed. // cannot guarantee an html element // eslint-disable-next-line @typescript-eslint/no-explicit-any , _extends({ ref: forwardedRef, overrides: blockOverrides, $aspectRatio: aspectRatio, "data-baseweb": "aspect-ratio-box" }, restProps)); }; const AspectRatioBoxComponent = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(AspectRatioBox, _extends({}, props, { forwardedRef: ref }))); AspectRatioBoxComponent.displayName = 'AspectRatioBox'; var _default = exports.default = AspectRatioBoxComponent;