@pie-lib/graphing 2.34.3-next.2 → 2.34.3-next.205
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 +13 -67
- package/lib/axis/arrow.js +19 -55
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +106 -194
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +1 -6
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +21 -49
- package/lib/bg.js.map +1 -1
- package/lib/container/actions.js +2 -8
- package/lib/container/actions.js.map +1 -1
- package/lib/container/index.js +14 -59
- package/lib/container/index.js.map +1 -1
- package/lib/container/marks.js +1 -6
- package/lib/container/marks.js.map +1 -1
- package/lib/container/middleware.js +2 -8
- package/lib/container/middleware.js.map +1 -1
- package/lib/container/reducer.js +1 -8
- package/lib/container/reducer.js.map +1 -1
- package/lib/coordinates-label.js +24 -54
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +120 -184
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +59 -116
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js +169 -225
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js +29 -74
- package/lib/grid.js.map +1 -1
- package/lib/index.js +1 -13
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +40 -85
- package/lib/key-legend.js.map +1 -1
- package/lib/label-svg-icon.js +1 -7
- package/lib/label-svg-icon.js.map +1 -1
- package/lib/labels.js +66 -122
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +120 -163
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +155 -243
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +16 -50
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/absolute/component.js +4 -10
- package/lib/tools/absolute/component.js.map +1 -1
- package/lib/tools/absolute/index.js +3 -16
- package/lib/tools/absolute/index.js.map +1 -1
- package/lib/tools/circle/bg-circle.js +42 -92
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +78 -165
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +3 -13
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/exponential/component.js +4 -10
- package/lib/tools/exponential/component.js.map +1 -1
- package/lib/tools/exponential/index.js +3 -18
- package/lib/tools/exponential/index.js.map +1 -1
- package/lib/tools/index.js +3 -16
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +27 -48
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/line/index.js +1 -6
- package/lib/tools/line/index.js.map +1 -1
- package/lib/tools/parabola/component.js +4 -10
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +3 -16
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js +24 -71
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +3 -11
- package/lib/tools/point/index.js.map +1 -1
- package/lib/tools/polygon/component.js +83 -184
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +6 -23
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +48 -91
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +65 -98
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +41 -60
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/ray/index.js +1 -6
- package/lib/tools/ray/index.js.map +1 -1
- package/lib/tools/segment/component.js +25 -43
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/segment/index.js +1 -6
- package/lib/tools/segment/index.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +69 -28
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/icons/CorrectSVG.js +12 -8
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +12 -8
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/MissingSVG.js +12 -8
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
- package/lib/tools/shared/line/index.js +140 -193
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +70 -101
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +22 -56
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +21 -62
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +23 -52
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +54 -72
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +22 -57
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +10 -38
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js +2 -9
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/tools/sine/component.js +8 -19
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +3 -16
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js +24 -44
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/tools/vector/index.js +1 -6
- package/lib/tools/vector/index.js.map +1 -1
- package/lib/undo-redo.js +29 -69
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +4 -11
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +51 -128
- package/lib/utils.js.map +1 -1
- package/package.json +25 -29
- package/src/__tests__/graph-with-controls.test.jsx +28 -11
- package/src/__tests__/graph.test.jsx +104 -168
- package/src/__tests__/grid.test.jsx +8 -6
- package/src/__tests__/labels.test.jsx +25 -8
- package/src/__tests__/mark-label.test.jsx +12 -17
- package/src/__tests__/toggle-bar.test.jsx +92 -17
- package/src/__tests__/tool-menu.test.jsx +61 -12
- package/src/__tests__/undo-redo.test.jsx +7 -8
- package/src/__tests__/utils.js +3 -0
- package/src/axis/__tests__/arrow.test.jsx +16 -17
- package/src/axis/__tests__/axes.test.jsx +118 -122
- package/src/axis/arrow.jsx +7 -12
- package/src/axis/axes.jsx +45 -55
- package/src/coordinates-label.jsx +14 -18
- package/src/graph-with-controls.jsx +52 -59
- package/src/grid-setup.jsx +203 -205
- package/src/grid.jsx +2 -4
- package/src/key-legend.jsx +52 -56
- package/src/labels.jsx +24 -31
- package/src/mark-label.jsx +92 -81
- package/src/toggle-bar.jsx +135 -164
- package/src/tool-menu.jsx +1 -1
- package/src/tools/circle/__tests__/bg-circle.test.jsx +7 -9
- package/src/tools/circle/__tests__/component.test.jsx +17 -189
- package/src/tools/circle/bg-circle.jsx +20 -28
- package/src/tools/circle/component.jsx +28 -63
- package/src/tools/line/__tests__/component.test.jsx +7 -7
- package/src/tools/line/component.jsx +22 -15
- package/src/tools/point/__tests__/component.test.jsx +18 -43
- package/src/tools/point/component.jsx +1 -1
- package/src/tools/polygon/__tests__/component.test.jsx +18 -162
- package/src/tools/polygon/__tests__/line.test.jsx +7 -10
- package/src/tools/polygon/__tests__/polygon.test.jsx +7 -8
- package/src/tools/polygon/component.jsx +3 -4
- package/src/tools/polygon/line.jsx +30 -33
- package/src/tools/polygon/polygon.jsx +52 -45
- package/src/tools/ray/__tests__/component.test.jsx +7 -8
- package/src/tools/ray/component.jsx +38 -25
- package/src/tools/segment/__tests__/component.test.jsx +7 -8
- package/src/tools/segment/component.jsx +19 -18
- package/src/tools/shared/__tests__/arrow-head.test.jsx +14 -17
- package/src/tools/shared/arrow-head.jsx +60 -7
- package/src/tools/shared/icons/CorrectSVG.jsx +10 -0
- package/src/tools/shared/icons/IncorrectSVG.jsx +10 -0
- package/src/tools/shared/icons/MissingSVG.jsx +10 -0
- package/src/tools/shared/line/__tests__/index.test.jsx +19 -165
- package/src/tools/shared/line/__tests__/line-path.test.jsx +8 -8
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +22 -22
- package/src/tools/shared/line/index.jsx +52 -7
- package/src/tools/shared/line/line-path.jsx +55 -59
- package/src/tools/shared/line/with-root-edge.jsx +1 -1
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
- package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
- package/src/tools/shared/point/arrow-point.jsx +10 -24
- package/src/tools/shared/point/arrow.jsx +5 -11
- package/src/tools/shared/point/base-point.jsx +42 -19
- package/src/tools/shared/point/index.jsx +27 -44
- package/src/tools/vector/__tests__/component.test.jsx +7 -8
- package/src/tools/vector/component.jsx +11 -16
- package/src/undo-redo.jsx +19 -21
- package/esm/index.css +0 -847
- package/esm/index.js +0 -239949
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -3
- package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -237
- package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -211
- package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
- package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
- package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -45
- package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
- package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -13
- package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -14
- package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
- package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
- package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +0 -46
- package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +0 -293
- package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
- package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +0 -40
- package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -415
- package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -45
- package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -52
- package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +0 -23
- package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +0 -14
- package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -27
- package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
- package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -58
- package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
- package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -56
- package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -44
- package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +0 -12
|
@@ -1,61 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.styles = exports.lineToolComponent = exports.lineTool = exports.lineBase = void 0;
|
|
9
|
-
|
|
10
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
24
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
15
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
16
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
29
|
-
|
|
30
17
|
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
31
|
-
|
|
32
18
|
var _point = require("../point");
|
|
33
|
-
|
|
34
19
|
var _plot = require("@pie-lib/plot");
|
|
35
|
-
|
|
36
20
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
37
|
-
|
|
38
21
|
var _styles = require("../styles");
|
|
39
|
-
|
|
40
22
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
41
|
-
|
|
42
23
|
var _markLabel = _interopRequireDefault(require("../../../mark-label"));
|
|
43
|
-
|
|
44
24
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
45
|
-
|
|
46
25
|
var _renderUi = require("@pie-lib/render-ui");
|
|
47
|
-
|
|
48
26
|
var _utils = require("../../../utils");
|
|
49
|
-
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
27
|
+
var _styles2 = require("@mui/material/styles");
|
|
28
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
29
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
30
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
+
var StyledLineGroup = (0, _styles2.styled)('g')(function (_ref) {
|
|
33
|
+
var disabled = _ref.disabled,
|
|
34
|
+
correctness = _ref.correctness;
|
|
35
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
36
|
+
'& line': {
|
|
37
|
+
fill: 'transparent',
|
|
38
|
+
stroke: _renderUi.color.defaults.BLACK,
|
|
39
|
+
strokeWidth: 3,
|
|
40
|
+
transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
|
|
41
|
+
'&:hover': {
|
|
42
|
+
strokeWidth: 6,
|
|
43
|
+
stroke: _renderUi.color.defaults.PRIMARY_DARK
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}, disabled && {
|
|
47
|
+
'& line': _objectSpread(_objectSpread({}, (0, _styles.disabledSecondary)('stroke')), {}, {
|
|
48
|
+
strokeWidth: 2
|
|
49
|
+
})
|
|
50
|
+
}), correctness === 'correct' && {
|
|
51
|
+
'& line': _objectSpread({}, (0, _styles.correct)('stroke'))
|
|
52
|
+
}), correctness === 'incorrect' && {
|
|
53
|
+
'& line': _objectSpread({}, (0, _styles.incorrect)('stroke'))
|
|
54
|
+
}), correctness === 'missing' && {
|
|
55
|
+
'& line': _objectSpread(_objectSpread({}, (0, _styles.missing)('stroke')), {}, {
|
|
56
|
+
strokeWidth: 1,
|
|
57
|
+
strokeDasharray: '4 3'
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var lineTool = exports.lineTool = function lineTool(type, Component) {
|
|
59
62
|
return function () {
|
|
60
63
|
return {
|
|
61
64
|
type: type,
|
|
@@ -64,7 +67,6 @@ var lineTool = function lineTool(type, Component) {
|
|
|
64
67
|
if (mark && (0, _utils.equalPoints)(mark.root, point)) {
|
|
65
68
|
return mark;
|
|
66
69
|
}
|
|
67
|
-
|
|
68
70
|
if (!mark) {
|
|
69
71
|
return {
|
|
70
72
|
type: type,
|
|
@@ -72,11 +74,9 @@ var lineTool = function lineTool(type, Component) {
|
|
|
72
74
|
from: point
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
|
-
|
|
76
77
|
if ((0, _utils.equalPoints)(point, mark.from)) {
|
|
77
78
|
return _objectSpread({}, mark);
|
|
78
79
|
}
|
|
79
|
-
|
|
80
80
|
return _objectSpread(_objectSpread({}, mark), {}, {
|
|
81
81
|
building: false,
|
|
82
82
|
to: point
|
|
@@ -85,97 +85,76 @@ var lineTool = function lineTool(type, Component) {
|
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
var lineToolComponent = function lineToolComponent(Component) {
|
|
92
|
-
var _class;
|
|
93
|
-
|
|
94
|
-
return _class = /*#__PURE__*/function (_React$Component) {
|
|
95
|
-
(0, _inherits2["default"])(LineToolComponent, _React$Component);
|
|
96
|
-
|
|
97
|
-
var _super = _createSuper(LineToolComponent);
|
|
98
|
-
|
|
88
|
+
var lineToolComponent = exports.lineToolComponent = function lineToolComponent(Component) {
|
|
89
|
+
var _LineToolComponent;
|
|
90
|
+
return _LineToolComponent = /*#__PURE__*/function (_React$Component) {
|
|
99
91
|
function LineToolComponent(props) {
|
|
100
92
|
var _this;
|
|
101
|
-
|
|
102
93
|
(0, _classCallCheck2["default"])(this, LineToolComponent);
|
|
103
|
-
_this =
|
|
104
|
-
(0, _defineProperty2["default"])(
|
|
94
|
+
_this = _callSuper(this, LineToolComponent, [props]);
|
|
95
|
+
(0, _defineProperty2["default"])(_this, "startDrag", function () {
|
|
105
96
|
return _this.setState({
|
|
106
97
|
mark: _objectSpread({}, _this.props.mark)
|
|
107
98
|
});
|
|
108
99
|
});
|
|
109
|
-
(0, _defineProperty2["default"])(
|
|
100
|
+
(0, _defineProperty2["default"])(_this, "stopDrag", function () {
|
|
110
101
|
var _this$props = _this.props,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
102
|
+
onChange = _this$props.onChange,
|
|
103
|
+
mark = _this$props.mark;
|
|
114
104
|
var update = _objectSpread({}, _this.state.mark);
|
|
115
|
-
|
|
116
105
|
_this.setState({
|
|
117
106
|
mark: undefined
|
|
118
107
|
}, function () {
|
|
119
108
|
var type = update.type;
|
|
120
109
|
var shouldNotChange = type && (type === 'parabola' || type === 'sine' || type === 'absolute' || type === 'exponential') && (0, _utils.sameAxes)(update.from, update.to);
|
|
121
|
-
|
|
122
110
|
if (!shouldNotChange && type && type === 'exponential' && update.from && update.to) {
|
|
123
111
|
shouldNotChange = update.from.y === 0 || update.to.y === 0 || update.from.y * update.to.y < 0;
|
|
124
112
|
}
|
|
125
|
-
|
|
126
113
|
if (!(0, _isEqual["default"])(mark, update) && !shouldNotChange) {
|
|
127
114
|
onChange(mark, update);
|
|
128
115
|
}
|
|
129
116
|
});
|
|
130
117
|
});
|
|
131
|
-
(0, _defineProperty2["default"])(
|
|
132
|
-
var from =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
118
|
+
(0, _defineProperty2["default"])(_this, "changeMark", function (_ref2) {
|
|
119
|
+
var from = _ref2.from,
|
|
120
|
+
to = _ref2.to,
|
|
121
|
+
middle = _ref2.middle;
|
|
136
122
|
var mark = _objectSpread(_objectSpread({}, _this.state.mark), {}, {
|
|
137
123
|
from: from,
|
|
138
124
|
to: to
|
|
139
125
|
});
|
|
140
|
-
|
|
141
126
|
if (middle) {
|
|
142
127
|
mark = _objectSpread(_objectSpread({}, mark), {}, {
|
|
143
128
|
middle: middle
|
|
144
129
|
});
|
|
145
130
|
}
|
|
146
|
-
|
|
147
131
|
_this.setState({
|
|
148
132
|
mark: mark
|
|
149
133
|
});
|
|
150
134
|
});
|
|
151
|
-
(0, _defineProperty2["default"])(
|
|
152
|
-
var from =
|
|
153
|
-
|
|
154
|
-
|
|
135
|
+
(0, _defineProperty2["default"])(_this, "changeMarkProps", function (_ref3) {
|
|
136
|
+
var from = _ref3.from,
|
|
137
|
+
to = _ref3.to,
|
|
138
|
+
middle = _ref3.middle;
|
|
155
139
|
var _this$props2 = _this.props,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
140
|
+
onChange = _this$props2.onChange,
|
|
141
|
+
mark = _this$props2.mark;
|
|
159
142
|
var update = _objectSpread(_objectSpread({}, mark), _this.state.mark);
|
|
160
|
-
|
|
161
143
|
if (from) {
|
|
162
144
|
update = _objectSpread(_objectSpread({}, update), {}, {
|
|
163
145
|
from: from
|
|
164
146
|
});
|
|
165
147
|
}
|
|
166
|
-
|
|
167
148
|
if (to) {
|
|
168
149
|
update = _objectSpread(_objectSpread({}, update), {}, {
|
|
169
150
|
to: to
|
|
170
151
|
});
|
|
171
152
|
}
|
|
172
|
-
|
|
173
153
|
if (middle) {
|
|
174
154
|
update = _objectSpread(_objectSpread({}, update), {}, {
|
|
175
155
|
middle: middle
|
|
176
156
|
});
|
|
177
157
|
}
|
|
178
|
-
|
|
179
158
|
if (!(0, _isEqual["default"])(mark, update)) {
|
|
180
159
|
onChange(mark, update);
|
|
181
160
|
}
|
|
@@ -183,35 +162,33 @@ var lineToolComponent = function lineToolComponent(Component) {
|
|
|
183
162
|
_this.state = {};
|
|
184
163
|
return _this;
|
|
185
164
|
}
|
|
186
|
-
|
|
187
|
-
(0, _createClass2["default"])(LineToolComponent, [{
|
|
165
|
+
(0, _inherits2["default"])(LineToolComponent, _React$Component);
|
|
166
|
+
return (0, _createClass2["default"])(LineToolComponent, [{
|
|
188
167
|
key: "render",
|
|
189
168
|
value: function render() {
|
|
190
169
|
var _this$props3 = this.props,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
170
|
+
graphProps = _this$props3.graphProps,
|
|
171
|
+
onClick = _this$props3.onClick,
|
|
172
|
+
labelNode = _this$props3.labelNode,
|
|
173
|
+
labelModeEnabled = _this$props3.labelModeEnabled,
|
|
174
|
+
coordinatesOnHover = _this$props3.coordinatesOnHover,
|
|
175
|
+
limitLabeling = _this$props3.limitLabeling;
|
|
197
176
|
var mark = this.state.mark ? this.state.mark : this.props.mark;
|
|
198
177
|
var from = (0, _cloneDeep["default"])(mark.from);
|
|
199
178
|
var to = (0, _cloneDeep["default"])(mark.to);
|
|
200
|
-
var middle = (0, _cloneDeep["default"])(mark.middle);
|
|
201
|
-
// if it's a background mark, we need to force disable it
|
|
179
|
+
var middle = (0, _cloneDeep["default"])(mark.middle);
|
|
202
180
|
|
|
181
|
+
// SET DISABLED
|
|
182
|
+
// if it's a background mark, we need to force disable it
|
|
203
183
|
if (from && mark.isBackground) {
|
|
204
184
|
from.disabled = true;
|
|
205
185
|
}
|
|
206
|
-
|
|
207
186
|
if (to && mark.isBackground) {
|
|
208
187
|
to.disabled = true;
|
|
209
188
|
}
|
|
210
|
-
|
|
211
189
|
if (middle && mark.isBackground) {
|
|
212
190
|
middle.disabled = true;
|
|
213
191
|
}
|
|
214
|
-
|
|
215
192
|
return /*#__PURE__*/_react["default"].createElement(Component, {
|
|
216
193
|
disabled: mark.disabled,
|
|
217
194
|
coordinatesOnHover: coordinatesOnHover,
|
|
@@ -231,22 +208,23 @@ var lineToolComponent = function lineToolComponent(Component) {
|
|
|
231
208
|
});
|
|
232
209
|
}
|
|
233
210
|
}]);
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
211
|
+
}(_react["default"].Component), (0, _defineProperty2["default"])(_LineToolComponent, "propTypes", _objectSpread(_objectSpread({}, _plot.types.ToolPropTypeFields), {}, {
|
|
212
|
+
graphProps: _plot.types.GraphPropsType.isRequired,
|
|
213
|
+
limitLabeling: _propTypes["default"].bool,
|
|
214
|
+
changeMarkProps: _propTypes["default"].func,
|
|
215
|
+
disabled: _propTypes["default"].bool,
|
|
216
|
+
from: _plot.types.PointType,
|
|
217
|
+
to: _plot.types.PointType,
|
|
218
|
+
labelModeEnabled: _propTypes["default"].bool,
|
|
219
|
+
onClick: _propTypes["default"].func
|
|
220
|
+
})), _LineToolComponent;
|
|
238
221
|
};
|
|
239
|
-
|
|
240
|
-
exports.lineToolComponent = lineToolComponent;
|
|
241
|
-
|
|
242
222
|
var dragOpts = function dragOpts() {
|
|
243
223
|
return {
|
|
244
|
-
bounds: function bounds(props,
|
|
245
|
-
var domain =
|
|
246
|
-
|
|
247
|
-
|
|
224
|
+
bounds: function bounds(props, _ref4) {
|
|
225
|
+
var domain = _ref4.domain,
|
|
226
|
+
range = _ref4.range;
|
|
248
227
|
var area = _plot.utils.lineToArea(props.from, props.to);
|
|
249
|
-
|
|
250
228
|
return _plot.utils.bounds(area, domain, range);
|
|
251
229
|
},
|
|
252
230
|
anchorPoint: function anchorPoint(props) {
|
|
@@ -255,7 +233,7 @@ var dragOpts = function dragOpts() {
|
|
|
255
233
|
},
|
|
256
234
|
fromDelta: function fromDelta(props, delta) {
|
|
257
235
|
var from = props.from,
|
|
258
|
-
|
|
236
|
+
to = props.to;
|
|
259
237
|
return {
|
|
260
238
|
from: _plot.utils.point(from).add(_plot.utils.point(delta)),
|
|
261
239
|
to: _plot.utils.point(to).add(_plot.utils.point(delta))
|
|
@@ -263,79 +241,63 @@ var dragOpts = function dragOpts() {
|
|
|
263
241
|
}
|
|
264
242
|
};
|
|
265
243
|
};
|
|
266
|
-
|
|
267
|
-
var lineBase = function lineBase(Comp, opts) {
|
|
244
|
+
var lineBase = exports.lineBase = function lineBase(Comp, opts) {
|
|
268
245
|
var DraggableComp = (0, _plot.gridDraggable)(dragOpts())(Comp);
|
|
269
246
|
var FromPoint = opts && opts.from ? opts.from : _point.BasePoint;
|
|
270
247
|
var ToPoint = opts && opts.to ? opts.to : _point.BasePoint;
|
|
271
|
-
|
|
272
248
|
var LineBase = /*#__PURE__*/function (_React$Component2) {
|
|
273
|
-
(0, _inherits2["default"])(LineBase, _React$Component2);
|
|
274
|
-
|
|
275
|
-
var _super2 = _createSuper(LineBase);
|
|
276
|
-
|
|
277
249
|
function LineBase() {
|
|
278
250
|
var _this2;
|
|
279
|
-
|
|
280
251
|
(0, _classCallCheck2["default"])(this, LineBase);
|
|
281
|
-
|
|
282
252
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
283
253
|
args[_key] = arguments[_key];
|
|
284
254
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this2), "onChangePoint", function (point) {
|
|
255
|
+
_this2 = _callSuper(this, LineBase, [].concat(args));
|
|
256
|
+
(0, _defineProperty2["default"])(_this2, "onChangePoint", function (point) {
|
|
288
257
|
var _this2$props = _this2.props,
|
|
289
|
-
|
|
290
|
-
|
|
258
|
+
middle = _this2$props.middle,
|
|
259
|
+
onChange = _this2$props.onChange;
|
|
291
260
|
var from = point.from,
|
|
292
|
-
|
|
261
|
+
to = point.to;
|
|
293
262
|
|
|
263
|
+
// because point.from.label and point.to.label can be different
|
|
294
264
|
if (!(0, _utils.equalPoints)(from, to)) {
|
|
295
265
|
if (middle) {
|
|
296
266
|
point.middle = _objectSpread(_objectSpread({}, middle), (0, _utils.getMiddleOfTwoPoints)(from, to));
|
|
297
267
|
}
|
|
298
|
-
|
|
299
268
|
onChange(point);
|
|
300
269
|
}
|
|
301
270
|
});
|
|
302
|
-
(0, _defineProperty2["default"])(
|
|
303
|
-
var draggedFrom =
|
|
304
|
-
|
|
271
|
+
(0, _defineProperty2["default"])(_this2, "dragComp", function (_ref5) {
|
|
272
|
+
var draggedFrom = _ref5.from,
|
|
273
|
+
draggedTo = _ref5.to;
|
|
305
274
|
var _this2$props2 = _this2.props,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
275
|
+
from = _this2$props2.from,
|
|
276
|
+
to = _this2$props2.to,
|
|
277
|
+
onChange = _this2$props2.onChange,
|
|
278
|
+
middle = _this2$props2.middle;
|
|
311
279
|
if (from.label) {
|
|
312
280
|
draggedFrom.label = from.label;
|
|
313
281
|
}
|
|
314
|
-
|
|
315
282
|
if (to.label) {
|
|
316
283
|
draggedTo.label = to.label;
|
|
317
284
|
}
|
|
318
|
-
|
|
319
285
|
var updated = {
|
|
320
286
|
from: draggedFrom,
|
|
321
287
|
to: draggedTo
|
|
322
288
|
};
|
|
323
|
-
|
|
324
289
|
if (middle) {
|
|
325
290
|
updated.middle = _objectSpread(_objectSpread({}, middle), (0, _utils.getMiddleOfTwoPoints)(draggedFrom, draggedTo));
|
|
326
291
|
}
|
|
327
|
-
|
|
328
292
|
onChange(updated);
|
|
329
293
|
});
|
|
330
|
-
(0, _defineProperty2["default"])(
|
|
294
|
+
(0, _defineProperty2["default"])(_this2, "dragFrom", function (draggedFrom) {
|
|
331
295
|
var _this2$props3 = _this2.props,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
296
|
+
from = _this2$props3.from,
|
|
297
|
+
to = _this2$props3.to;
|
|
335
298
|
if (from.label) {
|
|
336
299
|
draggedFrom.label = from.label;
|
|
337
300
|
}
|
|
338
|
-
|
|
339
301
|
if (!(0, _utils.equalPoints)(draggedFrom, to)) {
|
|
340
302
|
_this2.onChangePoint({
|
|
341
303
|
from: draggedFrom,
|
|
@@ -343,15 +305,13 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
343
305
|
});
|
|
344
306
|
}
|
|
345
307
|
});
|
|
346
|
-
(0, _defineProperty2["default"])(
|
|
308
|
+
(0, _defineProperty2["default"])(_this2, "dragTo", function (draggedTo) {
|
|
347
309
|
var _this2$props4 = _this2.props,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
310
|
+
from = _this2$props4.from,
|
|
311
|
+
to = _this2$props4.to;
|
|
351
312
|
if (to.label) {
|
|
352
313
|
draggedTo.label = to.label;
|
|
353
314
|
}
|
|
354
|
-
|
|
355
315
|
if (!(0, _utils.equalPoints)(from, draggedTo)) {
|
|
356
316
|
_this2.onChangePoint({
|
|
357
317
|
from: from,
|
|
@@ -359,78 +319,70 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
359
319
|
});
|
|
360
320
|
}
|
|
361
321
|
});
|
|
362
|
-
(0, _defineProperty2["default"])(
|
|
322
|
+
(0, _defineProperty2["default"])(_this2, "labelChange", function (point, type) {
|
|
363
323
|
var changeMarkProps = _this2.props.changeMarkProps;
|
|
364
|
-
|
|
365
324
|
var update = _objectSpread({}, point);
|
|
366
|
-
|
|
367
325
|
if (!point.label || (0, _isEmpty["default"])(point.label)) {
|
|
368
326
|
delete update.label;
|
|
369
327
|
}
|
|
370
|
-
|
|
371
328
|
changeMarkProps((0, _defineProperty2["default"])({}, type, update));
|
|
372
329
|
});
|
|
373
|
-
(0, _defineProperty2["default"])(
|
|
330
|
+
(0, _defineProperty2["default"])(_this2, "clickPoint", function (point, type, data) {
|
|
374
331
|
var _this2$props5 = _this2.props,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
332
|
+
changeMarkProps = _this2$props5.changeMarkProps,
|
|
333
|
+
disabled = _this2$props5.disabled,
|
|
334
|
+
from = _this2$props5.from,
|
|
335
|
+
to = _this2$props5.to,
|
|
336
|
+
labelModeEnabled = _this2$props5.labelModeEnabled,
|
|
337
|
+
limitLabeling = _this2$props5.limitLabeling,
|
|
338
|
+
onClick = _this2$props5.onClick;
|
|
383
339
|
if (!labelModeEnabled) {
|
|
384
340
|
onClick(point || data);
|
|
385
341
|
return;
|
|
386
342
|
}
|
|
387
|
-
|
|
388
343
|
if (disabled) {
|
|
389
344
|
return;
|
|
390
|
-
}
|
|
391
|
-
|
|
345
|
+
}
|
|
392
346
|
|
|
347
|
+
// limit labeling the points of the line
|
|
393
348
|
if (limitLabeling) {
|
|
394
349
|
return;
|
|
395
350
|
}
|
|
396
|
-
|
|
397
351
|
if (type === 'middle' && !point && from && to) {
|
|
398
352
|
point = _objectSpread(_objectSpread({}, point), (0, _utils.getMiddleOfTwoPoints)(from, to));
|
|
399
353
|
}
|
|
400
|
-
|
|
401
354
|
changeMarkProps((0, _defineProperty2["default"])({
|
|
402
355
|
from: from,
|
|
403
356
|
to: to
|
|
404
357
|
}, type, _objectSpread({
|
|
405
358
|
label: ''
|
|
406
359
|
}, point)));
|
|
407
|
-
|
|
408
360
|
if (_this2.input[type]) {
|
|
409
361
|
_this2.input[type].focus();
|
|
410
362
|
}
|
|
411
363
|
});
|
|
412
|
-
|
|
364
|
+
// IMPORTANT, do not remove
|
|
365
|
+
(0, _defineProperty2["default"])(_this2, "input", {});
|
|
413
366
|
return _this2;
|
|
414
367
|
}
|
|
415
|
-
|
|
416
|
-
(0, _createClass2["default"])(LineBase, [{
|
|
368
|
+
(0, _inherits2["default"])(LineBase, _React$Component2);
|
|
369
|
+
return (0, _createClass2["default"])(LineBase, [{
|
|
417
370
|
key: "render",
|
|
418
371
|
value: function render() {
|
|
419
372
|
var _this3 = this;
|
|
420
|
-
|
|
421
373
|
var _this$props4 = this.props,
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
374
|
+
coordinatesOnHover = _this$props4.coordinatesOnHover,
|
|
375
|
+
graphProps = _this$props4.graphProps,
|
|
376
|
+
onDragStart = _this$props4.onDragStart,
|
|
377
|
+
onDragStop = _this$props4.onDragStop,
|
|
378
|
+
from = _this$props4.from,
|
|
379
|
+
to = _this$props4.to,
|
|
380
|
+
middle = _this$props4.middle,
|
|
381
|
+
disabled = _this$props4.disabled,
|
|
382
|
+
correctness = _this$props4.correctness,
|
|
383
|
+
onClick = _this$props4.onClick,
|
|
384
|
+
labelNode = _this$props4.labelNode,
|
|
385
|
+
labelModeEnabled = _this$props4.labelModeEnabled;
|
|
434
386
|
var common = {
|
|
435
387
|
graphProps: graphProps,
|
|
436
388
|
onDragStart: onDragStart,
|
|
@@ -443,10 +395,9 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
443
395
|
var fromLabelNode = null;
|
|
444
396
|
var toLabelNode = null;
|
|
445
397
|
var lineLabelNode = null;
|
|
446
|
-
|
|
447
398
|
if (labelNode) {
|
|
448
|
-
if (from &&
|
|
449
|
-
fromLabelNode = /*#__PURE__*/_reactDom["default"].createPortal(
|
|
399
|
+
if (from && Object.prototype.hasOwnProperty.call(from, 'label')) {
|
|
400
|
+
fromLabelNode = /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
|
|
450
401
|
inputRef: function inputRef(r) {
|
|
451
402
|
return _this3.input.from = r;
|
|
452
403
|
},
|
|
@@ -460,9 +411,8 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
460
411
|
}
|
|
461
412
|
}), labelNode);
|
|
462
413
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
toLabelNode = /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
|
|
414
|
+
if (to && Object.prototype.hasOwnProperty.call(to, 'label')) {
|
|
415
|
+
toLabelNode = /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
|
|
466
416
|
inputRef: function inputRef(r) {
|
|
467
417
|
return _this3.input.to = r;
|
|
468
418
|
},
|
|
@@ -476,9 +426,8 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
476
426
|
}
|
|
477
427
|
}), labelNode);
|
|
478
428
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
lineLabelNode = /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
|
|
429
|
+
if (middle && Object.prototype.hasOwnProperty.call(middle, 'label')) {
|
|
430
|
+
lineLabelNode = /*#__PURE__*/_reactDom["default"].createPortal(/*#__PURE__*/_react["default"].createElement(_markLabel["default"], {
|
|
482
431
|
inputRef: function inputRef(r) {
|
|
483
432
|
return _this3.input.middle = r;
|
|
484
433
|
},
|
|
@@ -493,8 +442,10 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
493
442
|
}), labelNode);
|
|
494
443
|
}
|
|
495
444
|
}
|
|
496
|
-
|
|
497
|
-
|
|
445
|
+
return /*#__PURE__*/_react["default"].createElement(StyledLineGroup, {
|
|
446
|
+
disabled: disabled,
|
|
447
|
+
correctness: correctness
|
|
448
|
+
}, to && /*#__PURE__*/_react["default"].createElement(DraggableComp, (0, _extends2["default"])({
|
|
498
449
|
from: from,
|
|
499
450
|
to: to,
|
|
500
451
|
middle: middle,
|
|
@@ -528,9 +479,7 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
528
479
|
})), toLabelNode);
|
|
529
480
|
}
|
|
530
481
|
}]);
|
|
531
|
-
return LineBase;
|
|
532
482
|
}(_react["default"].Component);
|
|
533
|
-
|
|
534
483
|
(0, _defineProperty2["default"])(LineBase, "propTypes", {
|
|
535
484
|
coordinatesOnHover: _propTypes["default"].bool,
|
|
536
485
|
graphProps: _plot.types.GraphPropsType,
|
|
@@ -543,15 +492,14 @@ var lineBase = function lineBase(Comp, opts) {
|
|
|
543
492
|
onClick: _propTypes["default"].func,
|
|
544
493
|
correctness: _propTypes["default"].string,
|
|
545
494
|
disabled: _propTypes["default"].bool,
|
|
546
|
-
|
|
495
|
+
limitLabeling: _propTypes["default"].bool,
|
|
496
|
+
changeMarkProps: _propTypes["default"].func,
|
|
547
497
|
labelModeEnabled: _propTypes["default"].bool,
|
|
548
|
-
|
|
498
|
+
labelNode: _propTypes["default"].object
|
|
549
499
|
});
|
|
550
500
|
return LineBase;
|
|
551
501
|
};
|
|
552
|
-
|
|
553
|
-
exports.lineBase = lineBase;
|
|
554
|
-
var styles = {
|
|
502
|
+
var styles = exports.styles = {
|
|
555
503
|
line: function line() {
|
|
556
504
|
return {
|
|
557
505
|
fill: 'transparent',
|
|
@@ -595,5 +543,4 @@ var styles = {
|
|
|
595
543
|
});
|
|
596
544
|
}
|
|
597
545
|
};
|
|
598
|
-
exports.styles = styles;
|
|
599
546
|
//# sourceMappingURL=index.js.map
|