| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.RootSurface = void 0;
|
|---|
| 7 | var _react = _interopRequireWildcard(require("react"));
|
|---|
| 8 | var React = _react;
|
|---|
| 9 | var _chartLayoutContext = require("../context/chartLayoutContext");
|
|---|
| 10 | var _accessibilityContext = require("../context/accessibilityContext");
|
|---|
| 11 | var _PanoramaContext = require("../context/PanoramaContext");
|
|---|
| 12 | var _Surface = require("./Surface");
|
|---|
| 13 | var _hooks = require("../state/hooks");
|
|---|
| 14 | var _brushSelectors = require("../state/selectors/brushSelectors");
|
|---|
| 15 | var _isWellBehavedNumber = require("../util/isWellBehavedNumber");
|
|---|
| 16 | var _ZIndexPortal = require("../zIndex/ZIndexPortal");
|
|---|
| 17 | var _excluded = ["children"];
|
|---|
| 18 | function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|---|
| 19 | function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|---|
| 20 | function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|---|
| 21 | function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|---|
| 22 | var FULL_WIDTH_AND_HEIGHT = {
|
|---|
| 23 | width: '100%',
|
|---|
| 24 | height: '100%',
|
|---|
| 25 | /*
|
|---|
| 26 | * display: block is necessary here because the default for an SVG is display: inline,
|
|---|
| 27 | * which in some browsers (Chrome) adds a little bit of extra space above and below the SVG
|
|---|
| 28 | * to make space for the descender of letters like "g" and "y". This throws off the height calculation
|
|---|
| 29 | * and causes the container to grow indefinitely on each render with responsive=true.
|
|---|
| 30 | * Display: block removes that extra space.
|
|---|
| 31 | *
|
|---|
| 32 | * Interestingly, Firefox does not have this problem, but it doesn't hurt to add the style anyway.
|
|---|
| 33 | */
|
|---|
| 34 | display: 'block'
|
|---|
| 35 | };
|
|---|
| 36 | var MainChartSurface = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|---|
| 37 | var width = (0, _chartLayoutContext.useChartWidth)();
|
|---|
| 38 | var height = (0, _chartLayoutContext.useChartHeight)();
|
|---|
| 39 | var hasAccessibilityLayer = (0, _accessibilityContext.useAccessibilityLayer)();
|
|---|
| 40 | if (!(0, _isWellBehavedNumber.isPositiveNumber)(width) || !(0, _isWellBehavedNumber.isPositiveNumber)(height)) {
|
|---|
| 41 | return null;
|
|---|
| 42 | }
|
|---|
| 43 | var {
|
|---|
| 44 | children,
|
|---|
| 45 | otherAttributes,
|
|---|
| 46 | title,
|
|---|
| 47 | desc
|
|---|
| 48 | } = props;
|
|---|
| 49 | var tabIndex, role;
|
|---|
| 50 | if (otherAttributes != null) {
|
|---|
| 51 | if (typeof otherAttributes.tabIndex === 'number') {
|
|---|
| 52 | tabIndex = otherAttributes.tabIndex;
|
|---|
| 53 | } else {
|
|---|
| 54 | tabIndex = hasAccessibilityLayer ? 0 : undefined;
|
|---|
| 55 | }
|
|---|
| 56 | if (typeof otherAttributes.role === 'string') {
|
|---|
| 57 | role = otherAttributes.role;
|
|---|
| 58 | } else {
|
|---|
| 59 | role = hasAccessibilityLayer ? 'application' : undefined;
|
|---|
| 60 | }
|
|---|
| 61 | }
|
|---|
| 62 | return /*#__PURE__*/React.createElement(_Surface.Surface, _extends({}, otherAttributes, {
|
|---|
| 63 | title: title,
|
|---|
| 64 | desc: desc,
|
|---|
| 65 | role: role,
|
|---|
| 66 | tabIndex: tabIndex,
|
|---|
| 67 | width: width,
|
|---|
| 68 | height: height,
|
|---|
| 69 | style: FULL_WIDTH_AND_HEIGHT,
|
|---|
| 70 | ref: ref
|
|---|
| 71 | }), children);
|
|---|
| 72 | });
|
|---|
| 73 | var BrushPanoramaSurface = _ref => {
|
|---|
| 74 | var {
|
|---|
| 75 | children
|
|---|
| 76 | } = _ref;
|
|---|
| 77 | var brushDimensions = (0, _hooks.useAppSelector)(_brushSelectors.selectBrushDimensions);
|
|---|
| 78 | if (!brushDimensions) {
|
|---|
| 79 | return null;
|
|---|
| 80 | }
|
|---|
| 81 | var {
|
|---|
| 82 | width,
|
|---|
| 83 | height,
|
|---|
| 84 | y,
|
|---|
| 85 | x
|
|---|
| 86 | } = brushDimensions;
|
|---|
| 87 | return /*#__PURE__*/React.createElement(_Surface.Surface, {
|
|---|
| 88 | width: width,
|
|---|
| 89 | height: height,
|
|---|
| 90 | x: x,
|
|---|
| 91 | y: y
|
|---|
| 92 | }, children);
|
|---|
| 93 | };
|
|---|
| 94 | var RootSurface = exports.RootSurface = /*#__PURE__*/(0, _react.forwardRef)((_ref2, ref) => {
|
|---|
| 95 | var {
|
|---|
| 96 | children
|
|---|
| 97 | } = _ref2,
|
|---|
| 98 | rest = _objectWithoutProperties(_ref2, _excluded);
|
|---|
| 99 | var isPanorama = (0, _PanoramaContext.useIsPanorama)();
|
|---|
| 100 | if (isPanorama) {
|
|---|
| 101 | return /*#__PURE__*/React.createElement(BrushPanoramaSurface, null, /*#__PURE__*/React.createElement(_ZIndexPortal.AllZIndexPortals, {
|
|---|
| 102 | isPanorama: true
|
|---|
| 103 | }, children));
|
|---|
| 104 | }
|
|---|
| 105 | return /*#__PURE__*/React.createElement(MainChartSurface, _extends({
|
|---|
| 106 | ref: ref
|
|---|
| 107 | }, rest), /*#__PURE__*/React.createElement(_ZIndexPortal.AllZIndexPortals, {
|
|---|
| 108 | isPanorama: false
|
|---|
| 109 | }, children));
|
|---|
| 110 | }); |
|---|