@pie-lib/graphing 2.4.9 → 2.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/lib/axis/arrow.js +17 -13
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +57 -51
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +5 -1
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +16 -14
- package/lib/bg.js.map +1 -1
- package/lib/container/index.js +21 -15
- package/lib/container/index.js.map +1 -1
- package/lib/coordinates-label.js +4 -4
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +29 -25
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +54 -41
- package/lib/graph.js.map +1 -1
- package/lib/grid.js +20 -14
- package/lib/grid.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/labels.js +28 -24
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +16 -8
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +18 -16
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +22 -16
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/circle/bg-circle.js +26 -18
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +30 -28
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +4 -4
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/index.js +16 -15
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +12 -6
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +4 -4
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js +21 -17
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +2 -2
- package/lib/tools/polygon/component.js +55 -47
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +12 -8
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +26 -18
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +26 -18
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +12 -6
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/segment/component.js +4 -2
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +4 -4
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/line/index.js +46 -44
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +28 -20
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +8 -6
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +21 -15
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +21 -15
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +22 -16
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +8 -4
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +1 -1
- package/lib/tools/shared/types.js +1 -1
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +4 -4
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js +4 -2
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/undo-redo.js +20 -16
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +7 -3
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +68 -5
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/axis/axes.jsx +1 -1
- package/src/graph.jsx +12 -6
- package/src/utils.js +62 -4
package/lib/bg.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -17,34 +19,34 @@ var _utils = require("./utils");
|
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
20
|
-
function _typeof(obj) { 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); }
|
|
21
|
-
|
|
22
22
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
23
23
|
|
|
24
24
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
25
25
|
|
|
26
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
26
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
29
29
|
|
|
30
|
-
function
|
|
30
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
31
|
+
|
|
32
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
33
|
+
|
|
34
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
31
35
|
|
|
32
36
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
37
|
|
|
34
|
-
function
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
35
39
|
|
|
36
|
-
function
|
|
40
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
37
41
|
|
|
38
42
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
39
43
|
|
|
40
|
-
var Bg =
|
|
41
|
-
/*#__PURE__*/
|
|
42
|
-
function (_React$Component) {
|
|
44
|
+
var Bg = /*#__PURE__*/function (_React$Component) {
|
|
43
45
|
_inherits(Bg, _React$Component);
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
var _getPrototypeOf2;
|
|
47
|
+
var _super = _createSuper(Bg);
|
|
47
48
|
|
|
49
|
+
function Bg() {
|
|
48
50
|
var _this;
|
|
49
51
|
|
|
50
52
|
_classCallCheck(this, Bg);
|
|
@@ -53,7 +55,7 @@ function (_React$Component) {
|
|
|
53
55
|
args[_key] = arguments[_key];
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
_this =
|
|
58
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
57
59
|
|
|
58
60
|
_defineProperty(_assertThisInitialized(_this), "onRectClick", function (rect) {
|
|
59
61
|
var _this$props = _this.props,
|
|
@@ -114,7 +116,7 @@ function (_React$Component) {
|
|
|
114
116
|
var _this$props2 = this.props,
|
|
115
117
|
width = _this$props2.width,
|
|
116
118
|
height = _this$props2.height;
|
|
117
|
-
return _react["default"].createElement("rect", {
|
|
119
|
+
return /*#__PURE__*/_react["default"].createElement("rect", {
|
|
118
120
|
ref: function ref(rect) {
|
|
119
121
|
return _this2.rect = rect;
|
|
120
122
|
},
|
package/lib/bg.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bg.jsx"],"names":["Bg","rect","props","onClick","graphProps","scale","coords","_groups","x","invert","y","rowTicks","range","columnTicks","domain","closest","ticks","value","length","reduce","prev","curr","currentDistance","Math","abs","previousDistance","snapped","indexOf","on","onRectClick","bind","nextProps","utils","isDomainRangeEqual","width","height","React","Component","PropTypes","number","isRequired","func","types","GraphPropsType"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/bg.jsx"],"names":["Bg","rect","props","onClick","graphProps","scale","coords","_groups","x","invert","y","rowTicks","range","columnTicks","domain","closest","ticks","value","length","reduce","prev","curr","currentDistance","Math","abs","previousDistance","snapped","indexOf","on","onRectClick","bind","nextProps","utils","isDomainRangeEqual","width","height","React","Component","PropTypes","number","isRequired","func","types","GraphPropsType"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;IAEqBA,E;;;;;;;;;;;;;;;;kEA0BL,UAAAC,IAAI,EAAI;AACpB,wBAAgC,MAAKC,KAArC;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,UAAjB,eAAiBA,UAAjB;AACA,UAAQC,KAAR,GAAkBD,UAAlB,CAAQC,KAAR;AACA,UAAMC,MAAM,GAAG,wBAAML,IAAI,CAACM,OAAL,CAAa,CAAb,EAAgB,CAAhB,CAAN,CAAf;AACA,UAAMC,CAAC,GAAGH,KAAK,CAACG,CAAN,CAAQC,MAAR,CAAeH,MAAM,CAAC,CAAD,CAArB,CAAV;AACA,UAAMI,CAAC,GAAGL,KAAK,CAACK,CAAN,CAAQD,MAAR,CAAeH,MAAM,CAAC,CAAD,CAArB,CAAV;AACA,UAAMK,QAAQ,GAAG,0BAAcP,UAAU,CAACQ,KAAzB,CAAjB;AACA,UAAMC,WAAW,GAAG,0BAAcT,UAAU,CAACU,MAAzB,CAApB;;AAEA,UAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,KAAR,EAAkB;AAChC,eACED,KAAK,CAACE,MAAN,IACAF,KAAK,CAACG,MAAN,CAAa,UAACC,IAAD,EAAOC,IAAP,EAAgB;AAC3B,cAAMC,eAAe,GAAGC,IAAI,CAACC,GAAL,CAASH,IAAI,GAAGJ,KAAhB,CAAxB;AACA,cAAMQ,gBAAgB,GAAGF,IAAI,CAACC,GAAL,CAASJ,IAAI,GAAGH,KAAhB,CAAzB;AACA,iBAAOK,eAAe,IAAIG,gBAAnB,GAAsCJ,IAAtC,GAA6CD,IAApD;AACD,SAJD,CAFF;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IAAI,EAAC,KAFP;AAGE,QAAA,WAAW,EAAC,KAHd;AAIE,QAAA,KAAK,EAAEiC,KAJT;AAKE,QAAA,MAAM,EAAEC;AALV,QADF;AASD;;;;EAtE6BC,kBAAMC,S;;;;gBAAjBrC,E,eACA;AACjBkC,EAAAA,KAAK,EAAEI,sBAAUC,MAAV,CAAiBC,UADP;AAEjBL,EAAAA,MAAM,EAAEG,sBAAUC,MAAV,CAAiBC,UAFR;AAGjBrC,EAAAA,OAAO,EAAEmC,sBAAUG,IAAV,CAAeD,UAHP;AAIjBpC,EAAAA,UAAU,EAAEsC,YAAMC,cAAN,CAAqBH;AAJhB,C;;gBADAxC,E,kBAQG,E","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { select, mouse } from 'd3-selection';\nimport { types, utils } from '@pie-lib/plot';\nimport { getTickValues } from './utils';\n\nexport default class Bg extends React.Component {\n static propTypes = {\n width: PropTypes.number.isRequired,\n height: PropTypes.number.isRequired,\n onClick: PropTypes.func.isRequired,\n graphProps: types.GraphPropsType.isRequired\n };\n\n static defaultProps = {};\n\n componentDidMount() {\n const rect = select(this.rect);\n rect.on('click', this.onRectClick.bind(this, rect));\n }\n\n shouldComponentUpdate(nextProps) {\n return (\n !utils.isDomainRangeEqual(this.props.graphProps, nextProps.graphProps) ||\n this.props.width !== nextProps.width ||\n this.props.height !== nextProps.height\n );\n }\n /**\n * Note: we use d3 click + mouse to give us domain values directly.\n * Saves us having to calculate them ourselves from a MouseEvent.\n */\n onRectClick = rect => {\n const { onClick, graphProps } = this.props;\n const { scale } = graphProps;\n const coords = mouse(rect._groups[0][0]);\n const x = scale.x.invert(coords[0]);\n const y = scale.y.invert(coords[1]);\n const rowTicks = getTickValues(graphProps.range);\n const columnTicks = getTickValues(graphProps.domain);\n\n const closest = (ticks, value) => {\n return (\n ticks.length &&\n ticks.reduce((prev, curr) => {\n const currentDistance = Math.abs(curr - value);\n const previousDistance = Math.abs(prev - value);\n return currentDistance <= previousDistance ? curr : prev;\n })\n );\n };\n\n let snapped = {};\n\n if (columnTicks.indexOf(x) >= 0 && rowTicks.indexOf(y) >= 0) {\n snapped.x = x;\n snapped.y = y;\n } else {\n snapped.x = closest(columnTicks, x);\n snapped.y = closest(rowTicks, y);\n }\n\n onClick(snapped);\n };\n\n render() {\n const { width, height } = this.props;\n return (\n <rect\n ref={rect => (this.rect = rect)}\n fill=\"red\"\n fillOpacity=\"0.0\"\n width={width}\n height={height}\n />\n );\n }\n}\n"],"file":"bg.js"}
|
package/lib/container/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -23,9 +25,9 @@ var _reduxUndo = require("redux-undo");
|
|
|
23
25
|
|
|
24
26
|
var _graphWithControls = _interopRequireDefault(require("../graph-with-controls"));
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
var _excluded = ["onChangeMarks", "marks"];
|
|
27
29
|
|
|
28
|
-
function
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
31
|
|
|
30
32
|
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
33
|
|
|
@@ -37,17 +39,21 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
37
39
|
|
|
38
40
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
39
41
|
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
42
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
41
43
|
|
|
42
|
-
function
|
|
44
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
43
45
|
|
|
44
|
-
function
|
|
46
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
47
|
+
|
|
48
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
49
|
+
|
|
50
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
45
51
|
|
|
46
52
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
47
53
|
|
|
48
|
-
function
|
|
54
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
55
|
|
|
50
|
-
function
|
|
56
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
51
57
|
|
|
52
58
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
53
59
|
|
|
@@ -82,17 +88,17 @@ var GraphContainer = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProp
|
|
|
82
88
|
|
|
83
89
|
exports.GraphContainer = GraphContainer;
|
|
84
90
|
|
|
85
|
-
var Root =
|
|
86
|
-
/*#__PURE__*/
|
|
87
|
-
function (_React$Component) {
|
|
91
|
+
var Root = /*#__PURE__*/function (_React$Component) {
|
|
88
92
|
_inherits(Root, _React$Component);
|
|
89
93
|
|
|
94
|
+
var _super = _createSuper(Root);
|
|
95
|
+
|
|
90
96
|
function Root(props) {
|
|
91
97
|
var _this;
|
|
92
98
|
|
|
93
99
|
_classCallCheck(this, Root);
|
|
94
100
|
|
|
95
|
-
_this =
|
|
101
|
+
_this = _super.call(this, props);
|
|
96
102
|
|
|
97
103
|
_defineProperty(_assertThisInitialized(_this), "onStoreChange", function () {
|
|
98
104
|
var _this$props = _this.props,
|
|
@@ -123,22 +129,22 @@ function (_React$Component) {
|
|
|
123
129
|
var _this$props2 = this.props,
|
|
124
130
|
onChangeMarks = _this$props2.onChangeMarks,
|
|
125
131
|
marks = _this$props2.marks,
|
|
126
|
-
rest = _objectWithoutProperties(_this$props2,
|
|
132
|
+
rest = _objectWithoutProperties(_this$props2, _excluded);
|
|
127
133
|
|
|
128
134
|
var correctnessSet = marks && marks.find(function (m) {
|
|
129
135
|
return m.correctness;
|
|
130
136
|
});
|
|
131
137
|
|
|
132
138
|
if (correctnessSet) {
|
|
133
|
-
return _react["default"].createElement(_graphWithControls["default"], _extends({}, rest, {
|
|
139
|
+
return /*#__PURE__*/_react["default"].createElement(_graphWithControls["default"], _extends({}, rest, {
|
|
134
140
|
marks: marks,
|
|
135
141
|
disabled: correctnessSet
|
|
136
142
|
}));
|
|
137
143
|
}
|
|
138
144
|
|
|
139
|
-
return _react["default"].createElement(_reactRedux.Provider, {
|
|
145
|
+
return /*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
140
146
|
store: this.store
|
|
141
|
-
}, _react["default"].createElement(GraphContainer, rest));
|
|
147
|
+
}, /*#__PURE__*/_react["default"].createElement(GraphContainer, rest));
|
|
142
148
|
}
|
|
143
149
|
}]);
|
|
144
150
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/container/index.jsx"],"names":["mapStateToProps","s","marks","present","mapDispatchToProps","dispatch","onChangeMarks","m","onUndo","ActionCreators","undo","onRedo","redo","onReset","GraphContainer","GraphWithControls","Root","props","storeState","store","getState","r","subscribe","onStoreChange","rest","correctnessSet","find","correctness","React","Component","PropTypes","func","array"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/container/index.jsx"],"names":["mapStateToProps","s","marks","present","mapDispatchToProps","dispatch","onChangeMarks","m","onUndo","ActionCreators","undo","onRedo","redo","onReset","GraphContainer","GraphWithControls","Root","props","storeState","store","getState","r","subscribe","onStoreChange","rest","correctnessSet","find","correctness","React","Component","PropTypes","func","array"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAAAC,CAAC;AAAA,SAAK;AAC5BC,IA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AKiB,KAAL,CAAWG,SAAX,CAAqB,MAAKC,aAA1B;;AANiB;AAOlB;;;;WAUD,kBAAS;AACP;AACA,yBAA0C,KAAKN,KAA/C;AAAA,UAAQX,aAAR,gBAAQA,aAAR;AAAA,UAAuBJ,KAAvB,gBAAuBA,KAAvB;AAAA,UAAiCsB,IAAjC;;AACA,UAAMC,cAAc,GAAGvB,KAAK,IAAIA,KAAK,CAACwB,IAAN,CAAW,UAAAnB,CAAC;AAAA,eAAIA,CAAC,CAACoB,WAAN;AAAA,OAAZ,CAAhC;;AAEA,UAAIF,cAAJ,EAAoB;AAClB,4BAAO,gCAAC,6BAAD,eAAuBD,IAAvB;AAA6B,UAAA,KAAK,EAAEtB,KAApC;AAA2C,UAAA,QAAQ,EAAEuB;AAArD,WAAP;AACD;;AAED,0BACE,gCAAC,oBAAD;AAAU,QAAA,KAAK,EAAE,KAAKN;AAAtB,sBACE,gCAAC,cAAD,EAAoBK,IAApB,CADF,CADF;AAKD;;;;EArCgBI,kBAAMC,S;;gBAAnBb,I,eACe;AACjBV,EAAAA,aAAa,EAAEwB,sBAAUC,IADR;AAEjB7B,EAAAA,KAAK,EAAE4B,sBAAUE;AAFA,C;;eAuCNhB,I","sourcesContent":["import { connect } from 'react-redux';\nimport React from 'react';\nimport { Provider } from 'react-redux';\nimport { createStore } from 'redux';\nimport reducer from './reducer';\nimport { changeMarks } from './actions';\nimport PropTypes from 'prop-types';\nimport isEqual from 'lodash/isEqual';\nimport { ActionCreators } from 'redux-undo';\nimport GraphWithControls from '../graph-with-controls';\n\nconst mapStateToProps = s => ({\n marks: s.marks.present\n});\n\nconst mapDispatchToProps = dispatch => ({\n onChangeMarks: m => dispatch(changeMarks(m)),\n onUndo: () => dispatch(ActionCreators.undo()),\n onRedo: () => dispatch(ActionCreators.redo()),\n onReset: () => dispatch(changeMarks([]))\n});\n\nexport const GraphContainer = connect(\n mapStateToProps,\n mapDispatchToProps\n)(GraphWithControls);\n\n/**\n * The graph component entry point with undo/redo\n * Redux is an implementation detail, hide it in the react component.\n */\nclass Root extends React.Component {\n static propTypes = {\n onChangeMarks: PropTypes.func,\n marks: PropTypes.array\n };\n\n constructor(props) {\n super(props);\n\n const r = reducer();\n this.store = createStore(r, { marks: props.marks });\n\n this.store.subscribe(this.onStoreChange);\n }\n\n onStoreChange = () => {\n const { marks, onChangeMarks } = this.props;\n const storeState = this.store.getState();\n if (!isEqual(storeState.marks.present, marks)) {\n onChangeMarks(storeState.marks.present);\n }\n };\n\n render() {\n // eslint-disable-next-line no-unused-vars\n const { onChangeMarks, marks, ...rest } = this.props;\n const correctnessSet = marks && marks.find(m => m.correctness);\n\n if (correctnessSet) {\n return <GraphWithControls {...rest} marks={marks} disabled={correctnessSet} />;\n }\n\n return (\n <Provider store={this.store}>\n <GraphContainer {...rest} />\n </Provider>\n );\n }\n}\n\nexport default Root;\n"],"file":"index.js"}
|
package/lib/coordinates-label.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] = exports.CoordinatesLabel =
|
|
6
|
+
exports.getLabelPosition = exports["default"] = exports.CoordinatesLabel = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -21,9 +21,9 @@ var _utils = require("./utils");
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
23
|
|
|
24
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
25
|
|
|
26
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
27
|
|
|
28
28
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
29
29
|
|
|
@@ -80,7 +80,7 @@ var CoordinatesLabel = function CoordinatesLabel(_ref) {
|
|
|
80
80
|
padding: 0
|
|
81
81
|
}, labelPosition);
|
|
82
82
|
|
|
83
|
-
return _react["default"].createElement(_InputBase["default"], {
|
|
83
|
+
return /*#__PURE__*/_react["default"].createElement(_InputBase["default"], {
|
|
84
84
|
style: style,
|
|
85
85
|
classes: {
|
|
86
86
|
input: classes.inputLabel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/coordinates-label.jsx"],"names":["styles","theme","input","fontFamily","typography","fontSize","borderRadius","background","color","primaryDark","inputLabel","padding","getLabelPosition","graphProps","x","y","labelLength","scale","domain","topShift","leftShift","rightEdge","max","left","top","CoordinatesLabel","classes","label","length","labelPosition","style","position","pointerEvents","width","ariaLabel","propTypes","types","GraphPropsType","PropTypes","object","number"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,KAAK,EAAE;AACLC,MAAAA,UAAU,EAAEF,KAAK,CAACG,UAAN,CAAiBD,UADxB;AAELE,MAAAA,QAAQ,EAAEJ,KAAK,CAACG,UAAN,CAAiBC,QAFtB;AAGLC,MAAAA,YAAY,EAAE,KAHT;AAILC,MAAAA,UAAU,EAAE,SAJP;AAKLC,MAAAA,KAAK,EAAEA,gBAAMC,WAAN;AALF,KADgB;AAQvBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,OAAO,EAAE;AADC;AARW,GAAL;AAAA,CAApB;;AAaO,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,UAAD,EAAaC,CAAb,EAAgBC,CAAhB,EAAmBC,WAAnB,EAAmC;
|
|
1
|
+
{"version":3,"sources":["../src/coordinates-label.jsx"],"names":["styles","theme","input","fontFamily","typography","fontSize","borderRadius","background","color","primaryDark","inputLabel","padding","getLabelPosition","graphProps","x","y","labelLength","scale","domain","topShift","leftShift","rightEdge","max","left","top","CoordinatesLabel","classes","label","length","labelPosition","style","position","pointerEvents","width","ariaLabel","propTypes","types","GraphPropsType","PropTypes","object","number"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,KAAK,EAAE;AACLC,MAAAA,UAAU,EAAEF,KAAK,CAACG,UAAN,CAAiBD,UADxB;AAELE,MAAAA,QAAQ,EAAEJ,KAAK,CAACG,UAAN,CAAiBC,QAFtB;AAGLC,MAAAA,YAAY,EAAE,KAHT;AAILC,MAAAA,UAAU,EAAE,SAJP;AAKLC,MAAAA,KAAK,EAAEA,gBAAMC,WAAN;AALF,KADgB;AAQvBC,IAAAA,UAAU,EAAE;AACVC,MAAAA,OAAO,EAAE;AADC;AARW,GAAL;AAAA,CAApB;;AAaO,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,UAAD,EAAaC,CAAb,EAAgBC,CAAhB,EAAmBC,WAAnB,EAAmC;AACjE,MAAQC,KAAR,GAA0BJ,UAA1B,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L,IAAAA,OAAO,EAAE;AAJA,KAKNkB,aALM,CAAX;;AAQA,sBACE,gCAAC,qBAAD;AACE,IAAA,KAAK,EAAEC,KADT;AAEE,IAAA,OAAO,EAAE;AAAE5B,MAAAA,KAAK,EAAEwB,OAAO,CAAChB;AAAjB,KAFX;AAGE,IAAA,SAAS,EAAEgB,OAAO,CAACxB,KAHrB;AAIE,IAAA,KAAK,EAAEyB,KAJT;AAKE,IAAA,UAAU,EAAE;AAAEO,MAAAA,SAAS,EAAE;AAAb;AALd,IADF;AASD,CAtBM;;;AAwBPT,gBAAgB,CAACU,SAAjB,GAA6B;AAC3BtB,EAAAA,UAAU,EAAEuB,YAAMC,cADS;AAE3BX,EAAAA,OAAO,EAAEY,sBAAUC,MAFQ;AAG3BzB,EAAAA,CAAC,EAAEwB,sBAAUE,MAHc;AAI3BzB,EAAAA,CAAC,EAAEuB,sBAAUE;AAJc,CAA7B;;eAOe,wBAAWxC,MAAX,EAAmByB,gBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport { color } from '@pie-lib/render-ui';\nimport { withStyles } from '@material-ui/core/styles';\nimport InputBase from '@material-ui/core/InputBase';\nimport { roundNumber } from './utils';\n\nconst styles = theme => ({\n input: {\n fontFamily: theme.typography.fontFamily,\n fontSize: theme.typography.fontSize,\n borderRadius: '8px',\n background: '#FFFFFF',\n color: color.primaryDark()\n },\n inputLabel: {\n padding: 0\n }\n});\n\nexport const getLabelPosition = (graphProps, x, y, labelLength) => {\n const { scale, domain } = graphProps;\n const topShift = 8;\n const leftShift = 10;\n const rightEdge = scale.x(x) + labelLength + leftShift;\n\n if (rightEdge >= scale.x(domain.max)) {\n return {\n left: scale.x(x) - leftShift - labelLength,\n top: scale.y(y) - topShift\n };\n }\n\n return {\n left: scale.x(x) + leftShift,\n top: scale.y(y) - topShift\n };\n};\n\nexport const CoordinatesLabel = ({ x, y, graphProps, classes }) => {\n const label = `(${roundNumber(x)}, ${roundNumber(y)})`;\n const labelLength = (label.length || 0) * 6;\n const labelPosition = getLabelPosition(graphProps, x, y, labelLength);\n\n const style = {\n position: 'absolute',\n pointerEvents: 'auto',\n width: labelLength,\n padding: 0,\n ...labelPosition\n };\n\n return (\n <InputBase\n style={style}\n classes={{ input: classes.inputLabel }}\n className={classes.input}\n value={label}\n inputProps={{ ariaLabel: 'naked' }}\n />\n );\n};\n\nCoordinatesLabel.propTypes = {\n graphProps: types.GraphPropsType,\n classes: PropTypes.object,\n x: PropTypes.number,\n y: PropTypes.number\n};\n\nexport default withStyles(styles)(CoordinatesLabel);\n"],"file":"coordinates-label.js"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
|
-
exports
|
|
8
|
+
exports.toolIsAvailable = exports.setToolbarAvailability = exports.getAvailableTool = exports.filterByVisibleToolTypes = exports.filterByValidToolTypes = exports["default"] = exports.GraphWithControls = void 0;
|
|
7
9
|
|
|
8
10
|
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
@@ -27,37 +29,41 @@ var _undoRedo = _interopRequireDefault(require("./undo-redo"));
|
|
|
27
29
|
|
|
28
30
|
var _tools = require("./tools");
|
|
29
31
|
|
|
30
|
-
function
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
33
|
|
|
32
|
-
function
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
33
35
|
|
|
34
|
-
function
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
35
37
|
|
|
36
38
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
39
|
|
|
38
40
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
39
41
|
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
42
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
41
43
|
|
|
42
|
-
function
|
|
44
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
43
45
|
|
|
44
|
-
function
|
|
46
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
47
|
+
|
|
48
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
49
|
+
|
|
50
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
45
51
|
|
|
46
52
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
47
53
|
|
|
48
|
-
function
|
|
54
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
49
55
|
|
|
50
|
-
function
|
|
56
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
51
57
|
|
|
52
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
58
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
53
59
|
|
|
54
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
60
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
55
61
|
|
|
56
62
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
63
|
|
|
58
64
|
var setToolbarAvailability = function setToolbarAvailability(toolbarTools) {
|
|
59
65
|
return _tools.toolsArr.map(function (tA) {
|
|
60
|
-
return _objectSpread({}, tA, {
|
|
66
|
+
return _objectSpread(_objectSpread({}, tA), {}, {
|
|
61
67
|
toolbar: !!toolbarTools.find(function (t) {
|
|
62
68
|
return t === tA.type;
|
|
63
69
|
})
|
|
@@ -103,14 +109,12 @@ var filterByVisibleToolTypes = function filterByVisibleToolTypes(toolbarTools, m
|
|
|
103
109
|
|
|
104
110
|
exports.filterByVisibleToolTypes = filterByVisibleToolTypes;
|
|
105
111
|
|
|
106
|
-
var GraphWithControls =
|
|
107
|
-
/*#__PURE__*/
|
|
108
|
-
function (_React$Component) {
|
|
112
|
+
var GraphWithControls = /*#__PURE__*/function (_React$Component) {
|
|
109
113
|
_inherits(GraphWithControls, _React$Component);
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
var _getPrototypeOf2;
|
|
115
|
+
var _super = _createSuper(GraphWithControls);
|
|
113
116
|
|
|
117
|
+
function GraphWithControls() {
|
|
114
118
|
var _this;
|
|
115
119
|
|
|
116
120
|
_classCallCheck(this, GraphWithControls);
|
|
@@ -119,7 +123,7 @@ function (_React$Component) {
|
|
|
119
123
|
args[_key] = arguments[_key];
|
|
120
124
|
}
|
|
121
125
|
|
|
122
|
-
_this =
|
|
126
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
123
127
|
|
|
124
128
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
125
129
|
currentTool: null,
|
|
@@ -186,11 +190,11 @@ function (_React$Component) {
|
|
|
186
190
|
currentTool = getAvailableTool(tools);
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
return _react["default"].createElement("div", {
|
|
193
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
190
194
|
className: (0, _classnames["default"])(classes.graphWithControls, className)
|
|
191
|
-
}, _react["default"].createElement("div", {
|
|
195
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
192
196
|
className: classes.controls
|
|
193
|
-
}, _react["default"].createElement(_toolMenu["default"], {
|
|
197
|
+
}, /*#__PURE__*/_react["default"].createElement(_toolMenu["default"], {
|
|
194
198
|
currentToolType: currentTool && currentTool.type,
|
|
195
199
|
disabled: !!disabled,
|
|
196
200
|
labelModeEnabled: labelModeEnabled,
|
|
@@ -199,15 +203,15 @@ function (_React$Component) {
|
|
|
199
203
|
},
|
|
200
204
|
onToggleLabelMode: this.toggleLabelMode,
|
|
201
205
|
toolbarTools: toolbarTools
|
|
202
|
-
}), !disabled && _react["default"].createElement(_undoRedo["default"], {
|
|
206
|
+
}), !disabled && /*#__PURE__*/_react["default"].createElement(_undoRedo["default"], {
|
|
203
207
|
onUndo: onUndo,
|
|
204
208
|
onRedo: onRedo,
|
|
205
209
|
onReset: onReset
|
|
206
|
-
})), _react["default"].createElement("div", {
|
|
210
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
207
211
|
ref: function ref(r) {
|
|
208
212
|
return _this2.labelNode = r;
|
|
209
213
|
}
|
|
210
|
-
}), _react["default"].createElement(_graph["default"], {
|
|
214
|
+
}), /*#__PURE__*/_react["default"].createElement(_graph["default"], {
|
|
211
215
|
axesSettings: axesSettings,
|
|
212
216
|
backgroundMarks: backgroundMarks,
|
|
213
217
|
coordinatesOnHover: coordinatesOnHover,
|
|
@@ -230,7 +234,7 @@ function (_React$Component) {
|
|
|
230
234
|
|
|
231
235
|
exports.GraphWithControls = GraphWithControls;
|
|
232
236
|
|
|
233
|
-
_defineProperty(GraphWithControls, "propTypes", _objectSpread({}, _graph.graphPropTypes, {
|
|
237
|
+
_defineProperty(GraphWithControls, "propTypes", _objectSpread(_objectSpread({}, _graph.graphPropTypes), {}, {
|
|
234
238
|
onUndo: _propTypes["default"].func,
|
|
235
239
|
onRedo: _propTypes["default"].func,
|
|
236
240
|
onReset: _propTypes["default"].func,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph-with-controls.jsx"],"names":["setToolbarAvailability","toolbarTools","toolsArr","map","tA","toolbar","find","t","type","toolIsAvailable","tools","currentTool","tool","getAvailableTool","filterByValidToolTypes","backgroundMarks","filter","bM","allTools","filterByVisibleToolTypes","marks","GraphWithControls","labelModeEnabled","setState","state","props","axesSettings","classes","className","coordinatesOnHover","disabled","domain","labels","onChangeMarks","onUndo","onRedo","onReset","range","size","title","tT","graphWithControls","controls","changeCurrentTool","toggleLabelMode","r","labelNode","undefined","React","Component","graphPropTypes","PropTypes","func","arrayOf","string","styles","theme","width","display","justifyContent","padding","spacing","unit","color","text","backgroundColor","primaryLight","borderTop","primaryDark","borderBottom","borderLeft","borderRight","fontSize","typography"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,CAAAC,YAAY;AAAA,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,eAAe,EAAEF,gBAAMG,YAAN,EANT;AAORC,MAAAA,SAAS,sBAAeJ,gBAAMK,WAAN,EAAf,CAPD;AAQRC,MAAAA,YAAY,sBAAeN,gBAAMK,WAAN,EAAf,CARJ;AASRE,MAAAA,UAAU,sBAAeP,gBAAMK,WAAN,EAAf,CATF;AAURG,MAAAA,WAAW,sBAAeR,gBAAMK,WAAN,EAAf,CAVH;AAWR,kBAAY;AACVI,QAAAA,QAAQ,EAAEhB,KAAK,CAACiB,UAAN,CAAiBD;AADjB;AAXJ;AAFa,GAAL;AAAA,CAApB;;eAmBe,wBAAWjB,MAAX,EAAmBlC,iBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport uniq from 'lodash/uniq';\nimport isString from 'lodash/isString';\nimport { color } from '@pie-lib/render-ui';\n\nimport ToolMenu from './tool-menu';\nimport Graph, { graphPropTypes } from './graph';\nimport UndoRedo from './undo-redo';\nimport { allTools, toolsArr } from './tools';\n\nexport const setToolbarAvailability = toolbarTools =>\n toolsArr.map(tA => ({ ...tA, toolbar: !!toolbarTools.find(t => t === tA.type) })) || [];\n\nexport const toolIsAvailable = (tools, currentTool) =>\n currentTool && tools && (tools.find(tool => tool.type === currentTool.type) || {}).toolbar;\n\nexport const getAvailableTool = tools => tools.find(tool => tool.toolbar);\n\nexport const filterByValidToolTypes = backgroundMarks =>\n backgroundMarks.filter(bM => !!allTools.find(tool => tool === bM.type));\n\nexport const filterByVisibleToolTypes = (toolbarTools, marks) =>\n marks.filter(bM => !!toolbarTools.find(tool => tool === bM.type));\n\nexport class GraphWithControls extends React.Component {\n static propTypes = {\n ...graphPropTypes,\n onUndo: PropTypes.func,\n onRedo: PropTypes.func,\n onReset: PropTypes.func,\n toolbarTools: PropTypes.arrayOf(PropTypes.string) // array of tool types that have to be displayed in the toolbar, same shape as 'allTools'\n };\n\n static defaultProps = { toolbarTools: [] };\n\n state = { currentTool: null, labelModeEnabled: false };\n\n changeCurrentTool = (tool, tools) =>\n this.setState({ currentTool: tools.find(t => t.type === tool) });\n\n toggleLabelMode = () => this.setState(state => ({ labelModeEnabled: !state.labelModeEnabled }));\n\n render() {\n let { currentTool, labelModeEnabled } = this.state;\n\n const {\n axesSettings,\n classes,\n className,\n coordinatesOnHover,\n disabled,\n domain,\n labels,\n onChangeMarks,\n onUndo,\n onRedo,\n onReset,\n range,\n size,\n title\n } = this.props;\n\n let { backgroundMarks, marks, toolbarTools } = this.props;\n\n // make sure only valid tool types are kept (string) and without duplicates\n toolbarTools = uniq(toolbarTools || []).filter(tT => !!isString(tT)) || [];\n\n // keep only the backgroundMarks that have valid types\n backgroundMarks = filterByValidToolTypes(backgroundMarks || []);\n\n // keep only the marks that have types which appear in toolbar\n marks = filterByVisibleToolTypes(toolbarTools, marks || []);\n\n const tools = setToolbarAvailability(toolbarTools);\n\n // set current tool if there's no current tool or if the existing one is no longer available\n if (!currentTool || !toolIsAvailable(tools, currentTool)) {\n currentTool = getAvailableTool(tools);\n }\n\n return (\n <div className={classNames(classes.graphWithControls, className)}>\n <div className={classes.controls}>\n <ToolMenu\n currentToolType={currentTool && currentTool.type}\n disabled={!!disabled}\n labelModeEnabled={labelModeEnabled}\n onChange={tool => this.changeCurrentTool(tool, tools)}\n onToggleLabelMode={this.toggleLabelMode}\n toolbarTools={toolbarTools}\n />\n\n {!disabled && <UndoRedo onUndo={onUndo} onRedo={onRedo} onReset={onReset} />}\n </div>\n\n <div ref={r => (this.labelNode = r)} />\n\n <Graph\n axesSettings={axesSettings}\n backgroundMarks={backgroundMarks}\n coordinatesOnHover={coordinatesOnHover}\n currentTool={currentTool}\n domain={domain}\n labels={labels}\n labelModeEnabled={labelModeEnabled}\n marks={marks}\n onChangeMarks={!disabled ? onChangeMarks : undefined}\n range={range}\n size={size}\n title={title}\n tools={tools}\n />\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n graphWithControls: {},\n controls: {\n width: 'inherit',\n display: 'flex',\n justifyContent: 'space-between',\n padding: theme.spacing.unit,\n color: color.text(),\n backgroundColor: color.primaryLight(),\n borderTop: `solid 1px ${color.primaryDark()}`,\n borderBottom: `solid 0px ${color.primaryDark()}`,\n borderLeft: `solid 1px ${color.primaryDark()}`,\n borderRight: `solid 1px ${color.primaryDark()}`,\n '& button': {\n fontSize: theme.typography.fontSize\n }\n }\n});\n\nexport default withStyles(styles)(GraphWithControls);\n"],"file":"graph-with-controls.js"}
|
|
1
|
+
{"version":3,"sources":["../src/graph-with-controls.jsx"],"names":["setToolbarAvailability","toolbarTools","toolsArr","map","tA","toolbar","find","t","type","toolIsAvailable","tools","currentTool","tool","getAvailableTool","filterByValidToolTypes","backgroundMarks","filter","bM","allTools","filterByVisibleToolTypes","marks","GraphWithControls","labelModeEnabled","setState","state","props","axesSettings","classes","className","coordinatesOnHover","disabled","domain","labels","onChangeMarks","onUndo","onRedo","onReset","range","size","title","tT","graphWithControls","controls","changeCurrentTool","toggleLabelMode","r","labelNode","undefined","React","Component","graphPropTypes","PropTypes","func","arrayOf","string","styles","theme","width","display","justifyContent","padding","spacing","unit","color","text","backgroundColor","primaryLight","borderTop","primaryDark","borderBottom","borderLeft","borderRight","fontSize","typography"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAMA,sBAAsB,GAAG,SAAzBA,sBAAyB,CAAAC,YAAY;AAAA,SAChDC,gBAASC,GAAT,CAAa,UAAAC,EAAE;AAAA,2CAAUA,EAAV;AAAcC,MAAAA,OAAO,EAAE,CAAC,CAACJ,YAAY,CAACK,IAAb,CAAkB,UAAAC,CAAC;AAAA,eAAIA,CAAC,KAAKH,EAAE,CAACI,IAAb;AAAA,OAAnB;AAAzB;AAAA,GAAf,KAAqF,EADrC;AAAA,CAA3C;;;;AAGA,IAAMC,eAAe,GAAG,SAAlBA,eAA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AA,QAAQ,EAAEhB,KAAK,CAACiB,UAAN,CAAiBD;AADjB;AAXJ;AAFa,GAAL;AAAA,CAApB;;eAmBe,wBAAWjB,MAAX,EAAmBlC,iBAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport uniq from 'lodash/uniq';\nimport isString from 'lodash/isString';\nimport { color } from '@pie-lib/render-ui';\n\nimport ToolMenu from './tool-menu';\nimport Graph, { graphPropTypes } from './graph';\nimport UndoRedo from './undo-redo';\nimport { allTools, toolsArr } from './tools';\n\nexport const setToolbarAvailability = toolbarTools =>\n toolsArr.map(tA => ({ ...tA, toolbar: !!toolbarTools.find(t => t === tA.type) })) || [];\n\nexport const toolIsAvailable = (tools, currentTool) =>\n currentTool && tools && (tools.find(tool => tool.type === currentTool.type) || {}).toolbar;\n\nexport const getAvailableTool = tools => tools.find(tool => tool.toolbar);\n\nexport const filterByValidToolTypes = backgroundMarks =>\n backgroundMarks.filter(bM => !!allTools.find(tool => tool === bM.type));\n\nexport const filterByVisibleToolTypes = (toolbarTools, marks) =>\n marks.filter(bM => !!toolbarTools.find(tool => tool === bM.type));\n\nexport class GraphWithControls extends React.Component {\n static propTypes = {\n ...graphPropTypes,\n onUndo: PropTypes.func,\n onRedo: PropTypes.func,\n onReset: PropTypes.func,\n toolbarTools: PropTypes.arrayOf(PropTypes.string) // array of tool types that have to be displayed in the toolbar, same shape as 'allTools'\n };\n\n static defaultProps = { toolbarTools: [] };\n\n state = { currentTool: null, labelModeEnabled: false };\n\n changeCurrentTool = (tool, tools) =>\n this.setState({ currentTool: tools.find(t => t.type === tool) });\n\n toggleLabelMode = () => this.setState(state => ({ labelModeEnabled: !state.labelModeEnabled }));\n\n render() {\n let { currentTool, labelModeEnabled } = this.state;\n\n const {\n axesSettings,\n classes,\n className,\n coordinatesOnHover,\n disabled,\n domain,\n labels,\n onChangeMarks,\n onUndo,\n onRedo,\n onReset,\n range,\n size,\n title\n } = this.props;\n\n let { backgroundMarks, marks, toolbarTools } = this.props;\n\n // make sure only valid tool types are kept (string) and without duplicates\n toolbarTools = uniq(toolbarTools || []).filter(tT => !!isString(tT)) || [];\n\n // keep only the backgroundMarks that have valid types\n backgroundMarks = filterByValidToolTypes(backgroundMarks || []);\n\n // keep only the marks that have types which appear in toolbar\n marks = filterByVisibleToolTypes(toolbarTools, marks || []);\n\n const tools = setToolbarAvailability(toolbarTools);\n\n // set current tool if there's no current tool or if the existing one is no longer available\n if (!currentTool || !toolIsAvailable(tools, currentTool)) {\n currentTool = getAvailableTool(tools);\n }\n\n return (\n <div className={classNames(classes.graphWithControls, className)}>\n <div className={classes.controls}>\n <ToolMenu\n currentToolType={currentTool && currentTool.type}\n disabled={!!disabled}\n labelModeEnabled={labelModeEnabled}\n onChange={tool => this.changeCurrentTool(tool, tools)}\n onToggleLabelMode={this.toggleLabelMode}\n toolbarTools={toolbarTools}\n />\n\n {!disabled && <UndoRedo onUndo={onUndo} onRedo={onRedo} onReset={onReset} />}\n </div>\n\n <div ref={r => (this.labelNode = r)} />\n\n <Graph\n axesSettings={axesSettings}\n backgroundMarks={backgroundMarks}\n coordinatesOnHover={coordinatesOnHover}\n currentTool={currentTool}\n domain={domain}\n labels={labels}\n labelModeEnabled={labelModeEnabled}\n marks={marks}\n onChangeMarks={!disabled ? onChangeMarks : undefined}\n range={range}\n size={size}\n title={title}\n tools={tools}\n />\n </div>\n );\n }\n}\n\nconst styles = theme => ({\n graphWithControls: {},\n controls: {\n width: 'inherit',\n display: 'flex',\n justifyContent: 'space-between',\n padding: theme.spacing.unit,\n color: color.text(),\n backgroundColor: color.primaryLight(),\n borderTop: `solid 1px ${color.primaryDark()}`,\n borderBottom: `solid 0px ${color.primaryDark()}`,\n borderLeft: `solid 1px ${color.primaryDark()}`,\n borderRight: `solid 1px ${color.primaryDark()}`,\n '& button': {\n fontSize: theme.typography.fontSize\n }\n }\n});\n\nexport default withStyles(styles)(GraphWithControls);\n"],"file":"graph-with-controls.js"}
|