source: node_modules/recharts/lib/container/RootSurface.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 4.9 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.RootSurface = void 0;
7var _react = _interopRequireWildcard(require("react"));
8var React = _react;
9var _chartLayoutContext = require("../context/chartLayoutContext");
10var _accessibilityContext = require("../context/accessibilityContext");
11var _PanoramaContext = require("../context/PanoramaContext");
12var _Surface = require("./Surface");
13var _hooks = require("../state/hooks");
14var _brushSelectors = require("../state/selectors/brushSelectors");
15var _isWellBehavedNumber = require("../util/isWellBehavedNumber");
16var _ZIndexPortal = require("../zIndex/ZIndexPortal");
17var _excluded = ["children"];
18function _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); }
19function _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; }
20function _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; }
21function _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); }
22var 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};
36var 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});
73var 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};
94var 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});
Note: See TracBrowser for help on using the repository browser.