@pie-lib/graphing 2.14.22-next.0 → 2.15.1-beta.0
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 +16 -75
- package/NEXT.CHANGELOG.json +1 -0
- package/package.json +14 -7
- package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +237 -0
- package/src/__tests__/__snapshots__/graph.test.jsx.snap +211 -0
- package/src/__tests__/__snapshots__/grid.test.jsx.snap +54 -0
- package/src/__tests__/__snapshots__/labels.test.jsx.snap +30 -0
- package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +45 -0
- package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +7 -0
- package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +13 -0
- package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +14 -0
- package/src/__tests__/graph-with-controls.test.jsx +147 -0
- package/src/__tests__/graph.test.jsx +230 -0
- package/src/__tests__/grid.test.jsx +20 -0
- package/src/__tests__/labels.test.jsx +38 -0
- package/src/__tests__/mark-label.test.jsx +68 -0
- package/src/__tests__/toggle-bar.test.jsx +36 -0
- package/src/__tests__/tool-menu.test.jsx +29 -0
- package/src/__tests__/undo-redo.test.jsx +25 -0
- package/src/__tests__/use-debounce.test.js +21 -0
- package/src/__tests__/utils.js +38 -0
- package/src/__tests__/utils.test.js +151 -0
- package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +33 -0
- package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +122 -0
- package/src/axis/__tests__/arrow.test.jsx +39 -0
- package/src/axis/__tests__/axes.test.jsx +220 -0
- package/src/axis/axes.jsx +5 -5
- package/src/container/index.jsx +2 -4
- package/src/coordinates-label.jsx +4 -3
- package/src/graph-with-controls.jsx +8 -10
- package/src/graph.jsx +22 -10
- package/src/grid.jsx +8 -10
- package/src/index.js +2 -2
- package/src/key-legend.jsx +145 -0
- package/src/label-svg-icon.jsx +39 -0
- package/src/labels.jsx +2 -1
- package/src/mark-label.jsx +149 -52
- package/src/toggle-bar.jsx +1 -2
- package/src/tool-menu.jsx +3 -26
- package/src/tools/absolute/__tests__/component.test.jsx +54 -0
- package/src/tools/absolute/component.jsx +23 -0
- package/src/tools/absolute/index.js +31 -0
- package/src/tools/circle/__tests__/__snapshots__/bg-circle.test.jsx.snap +46 -0
- package/src/tools/circle/__tests__/__snapshots__/component.test.jsx.snap +293 -0
- package/src/tools/circle/__tests__/bg-circle.test.jsx +28 -0
- package/src/tools/circle/__tests__/component.test.jsx +228 -0
- package/src/tools/circle/bg-circle.jsx +5 -4
- package/src/tools/circle/component.jsx +22 -8
- package/src/tools/exponential/__tests__/component.test.jsx +54 -0
- package/src/tools/exponential/component.jsx +23 -0
- package/src/tools/exponential/index.js +39 -0
- package/src/tools/index.js +38 -5
- package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +20 -0
- package/src/tools/line/__tests__/component.test.jsx +36 -0
- package/src/tools/line/component.jsx +2 -1
- package/src/tools/parabola/__tests__/component.test.jsx +49 -0
- package/src/tools/parabola/component.jsx +7 -6
- package/src/tools/point/__tests__/__snapshots__/component.test.jsx.snap +40 -0
- package/src/tools/point/__tests__/component.test.jsx +66 -0
- package/src/tools/point/component.jsx +12 -6
- package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +415 -0
- package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +45 -0
- package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +52 -0
- package/src/tools/polygon/__tests__/component.test.jsx +226 -0
- package/src/tools/polygon/__tests__/index.test.js +65 -0
- package/src/tools/polygon/__tests__/line.test.jsx +25 -0
- package/src/tools/polygon/__tests__/polygon.test.jsx +44 -0
- package/src/tools/polygon/component.jsx +39 -11
- package/src/tools/polygon/line.jsx +15 -7
- package/src/tools/polygon/polygon.jsx +7 -3
- package/src/tools/ray/__tests__/__snapshots__/component.test.jsx.snap +23 -0
- package/src/tools/ray/__tests__/component.test.jsx +29 -0
- package/src/tools/ray/component.jsx +2 -1
- package/src/tools/segment/__tests__/__snapshots__/component.test.jsx.snap +14 -0
- package/src/tools/segment/__tests__/component.test.jsx +28 -0
- package/src/tools/segment/component.jsx +2 -1
- package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +27 -0
- package/src/tools/shared/__tests__/arrow-head.test.jsx +34 -0
- package/src/tools/shared/icons/CorrectSVG.jsx +22 -0
- package/src/tools/shared/icons/IncorrectSVG.jsx +20 -0
- package/src/tools/shared/icons/MissingSVG.jsx +21 -0
- package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +360 -0
- package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +58 -0
- package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +63 -0
- package/src/tools/shared/line/__tests__/index.test.jsx +255 -0
- package/src/tools/shared/line/__tests__/line-path.test.jsx +53 -0
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +73 -0
- package/src/tools/shared/line/index.jsx +39 -13
- package/src/tools/shared/line/line-path.jsx +18 -7
- package/src/tools/shared/line/with-root-edge.jsx +10 -3
- package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +56 -0
- package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +44 -0
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +87 -0
- package/src/tools/shared/point/__tests__/base-point.test.jsx +84 -0
- package/src/tools/shared/point/arrow-point.jsx +4 -1
- package/src/tools/shared/point/arrow.jsx +4 -1
- package/src/tools/shared/point/base-point.jsx +28 -3
- package/src/tools/shared/point/index.jsx +7 -2
- package/src/tools/shared/styles.js +8 -3
- package/src/tools/sine/__tests__/component.test.jsx +51 -0
- package/src/tools/sine/component.jsx +7 -7
- package/src/tools/vector/__tests__/__snapshots__/component.test.jsx.snap +12 -0
- package/src/tools/vector/__tests__/component.test.jsx +26 -0
- package/src/tools/vector/component.jsx +2 -1
- package/src/undo-redo.jsx +0 -1
- package/src/utils.js +1 -1
- package/legacy.png +0 -0
- package/lib/axis/arrow.js +0 -115
- package/lib/axis/arrow.js.map +0 -1
- package/lib/axis/axes.js +0 -415
- package/lib/axis/axes.js.map +0 -1
- package/lib/axis/index.js +0 -26
- package/lib/axis/index.js.map +0 -1
- package/lib/bg.js +0 -139
- package/lib/bg.js.map +0 -1
- package/lib/container/actions.js +0 -24
- package/lib/container/actions.js.map +0 -1
- package/lib/container/index.js +0 -166
- package/lib/container/index.js.map +0 -1
- package/lib/container/marks.js +0 -27
- package/lib/container/marks.js.map +0 -1
- package/lib/container/middleware.js +0 -25
- package/lib/container/middleware.js.map +0 -1
- package/lib/container/reducer.js +0 -25
- package/lib/container/reducer.js.map +0 -1
- package/lib/coordinates-label.js +0 -107
- package/lib/coordinates-label.js.map +0 -1
- package/lib/graph-with-controls.js +0 -366
- package/lib/graph-with-controls.js.map +0 -1
- package/lib/graph.js +0 -354
- package/lib/graph.js.map +0 -1
- package/lib/grid-setup.js +0 -462
- package/lib/grid-setup.js.map +0 -1
- package/lib/grid.js +0 -184
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -51
- package/lib/index.js.map +0 -1
- package/lib/labels.js +0 -298
- package/lib/labels.js.map +0 -1
- package/lib/mark-label.js +0 -210
- package/lib/mark-label.js.map +0 -1
- package/lib/toggle-bar.js +0 -337
- package/lib/toggle-bar.js.map +0 -1
- package/lib/tool-menu.js +0 -132
- package/lib/tool-menu.js.map +0 -1
- package/lib/tools/circle/bg-circle.js +0 -172
- package/lib/tools/circle/bg-circle.js.map +0 -1
- package/lib/tools/circle/component.js +0 -387
- package/lib/tools/circle/component.js.map +0 -1
- package/lib/tools/circle/index.js +0 -51
- package/lib/tools/circle/index.js.map +0 -1
- package/lib/tools/index.js +0 -79
- package/lib/tools/index.js.map +0 -1
- package/lib/tools/line/component.js +0 -102
- package/lib/tools/line/component.js.map +0 -1
- package/lib/tools/line/index.js +0 -16
- package/lib/tools/line/index.js.map +0 -1
- package/lib/tools/parabola/component.js +0 -33
- package/lib/tools/parabola/component.js.map +0 -1
- package/lib/tools/parabola/index.js +0 -63
- package/lib/tools/parabola/index.js.map +0 -1
- package/lib/tools/point/component.js +0 -181
- package/lib/tools/point/component.js.map +0 -1
- package/lib/tools/point/index.js +0 -32
- package/lib/tools/point/index.js.map +0 -1
- package/lib/tools/polygon/component.js +0 -505
- package/lib/tools/polygon/component.js.map +0 -1
- package/lib/tools/polygon/index.js +0 -106
- package/lib/tools/polygon/index.js.map +0 -1
- package/lib/tools/polygon/line.js +0 -151
- package/lib/tools/polygon/line.js.map +0 -1
- package/lib/tools/polygon/polygon.js +0 -162
- package/lib/tools/polygon/polygon.js.map +0 -1
- package/lib/tools/ray/component.js +0 -101
- package/lib/tools/ray/component.js.map +0 -1
- package/lib/tools/ray/index.js +0 -16
- package/lib/tools/ray/index.js.map +0 -1
- package/lib/tools/segment/component.js +0 -74
- package/lib/tools/segment/component.js.map +0 -1
- package/lib/tools/segment/index.js +0 -16
- package/lib/tools/segment/index.js.map +0 -1
- package/lib/tools/shared/arrow-head.js +0 -70
- package/lib/tools/shared/arrow-head.js.map +0 -1
- package/lib/tools/shared/line/index.js +0 -567
- package/lib/tools/shared/line/index.js.map +0 -1
- package/lib/tools/shared/line/line-path.js +0 -145
- package/lib/tools/shared/line/line-path.js.map +0 -1
- package/lib/tools/shared/line/with-root-edge.js +0 -144
- package/lib/tools/shared/line/with-root-edge.js.map +0 -1
- package/lib/tools/shared/point/arrow-point.js +0 -113
- package/lib/tools/shared/point/arrow-point.js.map +0 -1
- package/lib/tools/shared/point/arrow.js +0 -96
- package/lib/tools/shared/point/arrow.js.map +0 -1
- package/lib/tools/shared/point/base-point.js +0 -139
- package/lib/tools/shared/point/base-point.js.map +0 -1
- package/lib/tools/shared/point/index.js +0 -94
- package/lib/tools/shared/point/index.js.map +0 -1
- package/lib/tools/shared/styles.js +0 -49
- package/lib/tools/shared/styles.js.map +0 -1
- package/lib/tools/shared/types.js +0 -23
- package/lib/tools/shared/types.js.map +0 -1
- package/lib/tools/sine/component.js +0 -42
- package/lib/tools/sine/component.js.map +0 -1
- package/lib/tools/sine/index.js +0 -63
- package/lib/tools/sine/index.js.map +0 -1
- package/lib/tools/vector/component.js +0 -87
- package/lib/tools/vector/component.js.map +0 -1
- package/lib/tools/vector/index.js +0 -16
- package/lib/tools/vector/index.js.map +0 -1
- package/lib/undo-redo.js +0 -124
- package/lib/undo-redo.js.map +0 -1
- package/lib/use-debounce.js +0 -32
- package/lib/use-debounce.js.map +0 -1
- package/lib/utils.js +0 -307
- package/lib/utils.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/container/actions.js"],"names":["addMark","type","changeMarks","marks"],"mappings":";;;;;;;AAAO,IAAMA,OAAO,GAAG,SAAVA,OAAU;AAAA,SAAO;AAC5BC,IAAAA,IAAI,EAAE;AADsB,GAAP;AAAA,CAAhB;;;;AAIA,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD;AAAA,SAAY;AACrCF,IAAAA,IAAI,EAAE,cAD+B;AAErCE,IAAAA,KAAK,EAALA;AAFqC,GAAZ;AAAA,CAApB","sourcesContent":["export const addMark = () => ({\n type: 'ADD_MARK',\n});\n\nexport const changeMarks = (marks) => ({\n type: 'CHANGE_MARKS',\n marks,\n});\n"],"file":"actions.js"}
|
package/lib/container/index.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = exports.GraphContainer = void 0;
|
|
9
|
-
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
|
-
|
|
14
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
-
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
|
|
22
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
-
|
|
24
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
-
|
|
26
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
-
|
|
28
|
-
var _reactRedux = require("react-redux");
|
|
29
|
-
|
|
30
|
-
var _react = _interopRequireDefault(require("react"));
|
|
31
|
-
|
|
32
|
-
var _redux = require("redux");
|
|
33
|
-
|
|
34
|
-
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
35
|
-
|
|
36
|
-
var _actions = require("./actions");
|
|
37
|
-
|
|
38
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
39
|
-
|
|
40
|
-
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
41
|
-
|
|
42
|
-
var _reduxUndo = require("redux-undo");
|
|
43
|
-
|
|
44
|
-
var _graphWithControls = _interopRequireDefault(require("../graph-with-controls"));
|
|
45
|
-
|
|
46
|
-
var _middleware = require("./middleware");
|
|
47
|
-
|
|
48
|
-
var _excluded = ["onChangeMarks", "marks"];
|
|
49
|
-
|
|
50
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
51
|
-
|
|
52
|
-
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; } }
|
|
53
|
-
|
|
54
|
-
var mapStateToProps = function mapStateToProps(s) {
|
|
55
|
-
return {
|
|
56
|
-
marks: s.marks.present
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var mapDispatchToProps = function mapDispatchToProps(dispatch) {
|
|
61
|
-
return {
|
|
62
|
-
onChangeMarks: function onChangeMarks(m) {
|
|
63
|
-
return dispatch((0, _actions.changeMarks)(m));
|
|
64
|
-
},
|
|
65
|
-
onUndo: function onUndo() {
|
|
66
|
-
return dispatch(_reduxUndo.ActionCreators.undo());
|
|
67
|
-
},
|
|
68
|
-
onRedo: function onRedo() {
|
|
69
|
-
return dispatch(_reduxUndo.ActionCreators.redo());
|
|
70
|
-
},
|
|
71
|
-
onReset: function onReset() {
|
|
72
|
-
return dispatch((0, _actions.changeMarks)([]));
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var GraphContainer = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(_graphWithControls["default"]);
|
|
78
|
-
/**
|
|
79
|
-
* The graph component entry point with undo/redo
|
|
80
|
-
* Redux is an implementation detail, hide it in the react component.
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
exports.GraphContainer = GraphContainer;
|
|
84
|
-
|
|
85
|
-
var Root = /*#__PURE__*/function (_React$Component) {
|
|
86
|
-
(0, _inherits2["default"])(Root, _React$Component);
|
|
87
|
-
|
|
88
|
-
var _super = _createSuper(Root);
|
|
89
|
-
|
|
90
|
-
function Root(props) {
|
|
91
|
-
var _this;
|
|
92
|
-
|
|
93
|
-
(0, _classCallCheck2["default"])(this, Root);
|
|
94
|
-
_this = _super.call(this, props);
|
|
95
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onStoreChange", function () {
|
|
96
|
-
var _this$props = _this.props,
|
|
97
|
-
marks = _this$props.marks,
|
|
98
|
-
onChangeMarks = _this$props.onChangeMarks;
|
|
99
|
-
|
|
100
|
-
var storeState = _this.store.getState();
|
|
101
|
-
|
|
102
|
-
var lastAction = (0, _middleware.getLastAction)();
|
|
103
|
-
var isUndoOperation = lastAction.type.includes('UNDO') || lastAction.type.includes('REDO');
|
|
104
|
-
|
|
105
|
-
if (!(0, _isEqual["default"])(storeState.marks.present, marks)) {
|
|
106
|
-
onChangeMarks(storeState.marks.present, isUndoOperation);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
var r = (0, _reducer["default"])();
|
|
110
|
-
_this.store = (0, _redux.createStore)(r, {
|
|
111
|
-
marks: props.marks
|
|
112
|
-
}, (0, _redux.applyMiddleware)(_middleware.lastActionMiddleware));
|
|
113
|
-
|
|
114
|
-
_this.store.subscribe(_this.onStoreChange);
|
|
115
|
-
|
|
116
|
-
return _this;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
(0, _createClass2["default"])(Root, [{
|
|
120
|
-
key: "componentDidUpdate",
|
|
121
|
-
value: function componentDidUpdate(prevProps) {
|
|
122
|
-
var marks = this.props.marks;
|
|
123
|
-
var storeState = this.store.getState();
|
|
124
|
-
|
|
125
|
-
if ((0, _isEqual["default"])(storeState.marks.present, marks)) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (!(0, _isEqual["default"])(prevProps.marks, marks)) {
|
|
130
|
-
this.store.dispatch((0, _actions.changeMarks)(marks));
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
key: "render",
|
|
135
|
-
value: function render() {
|
|
136
|
-
// eslint-disable-next-line no-unused-vars
|
|
137
|
-
var _this$props2 = this.props,
|
|
138
|
-
onChangeMarks = _this$props2.onChangeMarks,
|
|
139
|
-
marks = _this$props2.marks,
|
|
140
|
-
rest = (0, _objectWithoutProperties2["default"])(_this$props2, _excluded);
|
|
141
|
-
var correctnessSet = marks && marks.find(function (m) {
|
|
142
|
-
return m.correctness;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
if (correctnessSet) {
|
|
146
|
-
return /*#__PURE__*/_react["default"].createElement(_graphWithControls["default"], (0, _extends2["default"])({}, rest, {
|
|
147
|
-
marks: marks,
|
|
148
|
-
disabled: correctnessSet
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return /*#__PURE__*/_react["default"].createElement(_reactRedux.Provider, {
|
|
153
|
-
store: this.store
|
|
154
|
-
}, /*#__PURE__*/_react["default"].createElement(GraphContainer, rest));
|
|
155
|
-
}
|
|
156
|
-
}]);
|
|
157
|
-
return Root;
|
|
158
|
-
}(_react["default"].Component);
|
|
159
|
-
|
|
160
|
-
(0, _defineProperty2["default"])(Root, "propTypes", {
|
|
161
|
-
onChangeMarks: _propTypes["default"].func,
|
|
162
|
-
marks: _propTypes["default"].array
|
|
163
|
-
});
|
|
164
|
-
var _default = Root;
|
|
165
|
-
exports["default"] = _default;
|
|
166
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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","lastAction","isUndoOperation","type","includes","r","lastActionMiddleware","subscribe","onStoreChange","prevProps","rest","correctnessSet","find","correctness","React","Component","PropTypes","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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ArD,WAAP;AACD;;AAED,0BACE,gCAAC,oBAAD;AAAU,QAAA,KAAK,EAAE,KAAKZ;AAAtB,sBACE,gCAAC,cAAD,EAAoBW,IAApB,CADF,CADF;AAKD;;;EArDgBI,kBAAMC,S;;iCAAnBnB,I,eACe;AACjBV,EAAAA,aAAa,EAAE8B,sBAAUC,IADR;AAEjBnC,EAAAA,KAAK,EAAEkC,sBAAUE;AAFA,C;eAuDNtB,I","sourcesContent":["import { connect } from 'react-redux';\nimport React from 'react';\nimport { Provider } from 'react-redux';\nimport { applyMiddleware, 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';\nimport { lastActionMiddleware, getLastAction } from './middleware';\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(mapStateToProps, mapDispatchToProps)(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 }, applyMiddleware(lastActionMiddleware));\n\n this.store.subscribe(this.onStoreChange);\n }\n\n componentDidUpdate(prevProps) {\n const { marks } = this.props;\n const storeState = this.store.getState();\n\n if (isEqual(storeState.marks.present, marks)) {\n return;\n }\n\n if (!isEqual(prevProps.marks, marks)) {\n this.store.dispatch(changeMarks(marks));\n }\n }\n\n onStoreChange = () => {\n const { marks, onChangeMarks } = this.props;\n const storeState = this.store.getState();\n const lastAction = getLastAction();\n const isUndoOperation = lastAction.type.includes('UNDO') || lastAction.type.includes('REDO');\n\n if (!isEqual(storeState.marks.present, marks)) {\n onChangeMarks(storeState.marks.present, isUndoOperation);\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/container/marks.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var marks = function marks() {
|
|
9
|
-
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
10
|
-
var action = arguments.length > 1 ? arguments[1] : undefined;
|
|
11
|
-
|
|
12
|
-
switch (action.type) {
|
|
13
|
-
case 'CHANGE_MARKS':
|
|
14
|
-
if (Array.isArray(action.marks)) {
|
|
15
|
-
return action.marks;
|
|
16
|
-
} else {
|
|
17
|
-
throw new Error('marks must be an array');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
default:
|
|
21
|
-
return state;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var _default = marks;
|
|
26
|
-
exports["default"] = _default;
|
|
27
|
-
//# sourceMappingURL=marks.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/container/marks.js"],"names":["marks","state","action","type","Array","isArray","Error"],"mappings":";;;;;;;AAAA,IAAMA,KAAK,GAAG,SAARA,KAAQ,GAAwB;AAAA,MAAvBC,KAAuB,uEAAf,EAAe;AAAA,MAAXC,MAAW;;AACpC,UAAQA,MAAM,CAACC,IAAf;AACE,SAAK,cAAL;AACE,UAAIC,KAAK,CAACC,OAAN,CAAcH,MAAM,CAACF,KAArB,CAAJ,EAAiC;AAC/B,eAAOE,MAAM,CAACF,KAAd;AACD,OAFD,MAEO;AACL,cAAM,IAAIM,KAAJ,CAAU,wBAAV,CAAN;AACD;;AACH;AACE,aAAOL,KAAP;AARJ;AAUD,CAXD;;eAaeD,K","sourcesContent":["const marks = (state = [], action) => {\n switch (action.type) {\n case 'CHANGE_MARKS':\n if (Array.isArray(action.marks)) {\n return action.marks;\n } else {\n throw new Error('marks must be an array');\n }\n default:\n return state;\n }\n};\n\nexport default marks;\n"],"file":"marks.js"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.lastActionMiddleware = exports.getLastAction = void 0;
|
|
7
|
-
var lastAction = null;
|
|
8
|
-
|
|
9
|
-
var getLastAction = function getLastAction() {
|
|
10
|
-
return lastAction;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.getLastAction = getLastAction;
|
|
14
|
-
|
|
15
|
-
var lastActionMiddleware = function lastActionMiddleware() {
|
|
16
|
-
return function (next) {
|
|
17
|
-
return function (action) {
|
|
18
|
-
lastAction = action;
|
|
19
|
-
return next(action);
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports.lastActionMiddleware = lastActionMiddleware;
|
|
25
|
-
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/container/middleware.js"],"names":["lastAction","getLastAction","lastActionMiddleware","next","action"],"mappings":";;;;;;AAAA,IAAIA,UAAU,GAAG,IAAjB;;AACO,IAAMC,aAAa,GAAG,SAAhBA,aAAgB;AAAA,SAAMD,UAAN;AAAA,CAAtB;;;;AAEA,IAAME,oBAAoB,GAAG,SAAvBA,oBAAuB;AAAA,SAAM,UAACC,IAAD;AAAA,WAAU,UAACC,MAAD,EAAY;AAC9DJ,MAAAA,UAAU,GAAGI,MAAb;AACA,aAAOD,IAAI,CAACC,MAAD,CAAX;AACD,KAHyC;AAAA,GAAN;AAAA,CAA7B","sourcesContent":["let lastAction = null;\nexport const getLastAction = () => lastAction;\n\nexport const lastActionMiddleware = () => (next) => (action) => {\n lastAction = action;\n return next(action);\n};\n"],"file":"middleware.js"}
|
package/lib/container/reducer.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _redux = require("redux");
|
|
11
|
-
|
|
12
|
-
var _marks = _interopRequireDefault(require("./marks"));
|
|
13
|
-
|
|
14
|
-
var _reduxUndo = _interopRequireDefault(require("redux-undo"));
|
|
15
|
-
|
|
16
|
-
var _default = function _default() {
|
|
17
|
-
return (0, _redux.combineReducers)({
|
|
18
|
-
marks: (0, _reduxUndo["default"])(_marks["default"], {
|
|
19
|
-
debug: false
|
|
20
|
-
})
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
exports["default"] = _default;
|
|
25
|
-
//# sourceMappingURL=reducer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/container/reducer.js"],"names":["marks","debug"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;eAEe;AAAA,SAAM,4BAAgB;AAAEA,IAAAA,KAAK,EAAE,2BAASA,iBAAT,EAAgB;AAAEC,MAAAA,KAAK,EAAE;AAAT,KAAhB;AAAT,GAAhB,CAAN;AAAA,C","sourcesContent":["import { combineReducers } from 'redux';\nimport marks from './marks';\nimport undoable from 'redux-undo';\n\nexport default () => combineReducers({ marks: undoable(marks, { debug: false }) });\n"],"file":"reducer.js"}
|
package/lib/coordinates-label.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.getLabelPosition = exports["default"] = exports.CoordinatesLabel = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
|
-
var _plot = require("@pie-lib/plot");
|
|
17
|
-
|
|
18
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
19
|
-
|
|
20
|
-
var _styles = require("@material-ui/core/styles");
|
|
21
|
-
|
|
22
|
-
var _InputBase = _interopRequireDefault(require("@material-ui/core/InputBase"));
|
|
23
|
-
|
|
24
|
-
var _utils = require("./utils");
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
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) { (0, _defineProperty2["default"])(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; }
|
|
29
|
-
|
|
30
|
-
var styles = function styles(theme) {
|
|
31
|
-
return {
|
|
32
|
-
input: {
|
|
33
|
-
fontFamily: theme.typography.fontFamily,
|
|
34
|
-
fontSize: theme.typography.fontSize,
|
|
35
|
-
borderRadius: '8px',
|
|
36
|
-
background: theme.palette.common.white,
|
|
37
|
-
color: _renderUi.color.primaryDark()
|
|
38
|
-
},
|
|
39
|
-
inputLabel: {
|
|
40
|
-
padding: 0
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
var getLabelPosition = function getLabelPosition(graphProps, x, y, labelLength) {
|
|
46
|
-
var scale = graphProps.scale,
|
|
47
|
-
domain = graphProps.domain;
|
|
48
|
-
var topShift = 8;
|
|
49
|
-
var leftShift = 10;
|
|
50
|
-
var rightEdge = scale.x(x) + labelLength + leftShift;
|
|
51
|
-
|
|
52
|
-
if (rightEdge >= scale.x(domain.max)) {
|
|
53
|
-
return {
|
|
54
|
-
left: scale.x(x) - leftShift - labelLength,
|
|
55
|
-
top: scale.y(y) - topShift
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
left: scale.x(x) + leftShift,
|
|
61
|
-
top: scale.y(y) - topShift
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
exports.getLabelPosition = getLabelPosition;
|
|
66
|
-
|
|
67
|
-
var CoordinatesLabel = function CoordinatesLabel(_ref) {
|
|
68
|
-
var x = _ref.x,
|
|
69
|
-
y = _ref.y,
|
|
70
|
-
graphProps = _ref.graphProps,
|
|
71
|
-
classes = _ref.classes;
|
|
72
|
-
var label = "(".concat((0, _utils.roundNumber)(x), ", ").concat((0, _utils.roundNumber)(y), ")");
|
|
73
|
-
var labelLength = (label.length || 0) * 6;
|
|
74
|
-
var labelPosition = getLabelPosition(graphProps, x, y, labelLength);
|
|
75
|
-
|
|
76
|
-
var style = _objectSpread({
|
|
77
|
-
position: 'absolute',
|
|
78
|
-
pointerEvents: 'auto',
|
|
79
|
-
width: labelLength,
|
|
80
|
-
padding: 0
|
|
81
|
-
}, labelPosition);
|
|
82
|
-
|
|
83
|
-
return /*#__PURE__*/_react["default"].createElement(_InputBase["default"], {
|
|
84
|
-
style: style,
|
|
85
|
-
classes: {
|
|
86
|
-
input: classes.inputLabel
|
|
87
|
-
},
|
|
88
|
-
className: classes.input,
|
|
89
|
-
value: label,
|
|
90
|
-
inputProps: {
|
|
91
|
-
ariaLabel: 'naked'
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
exports.CoordinatesLabel = CoordinatesLabel;
|
|
97
|
-
CoordinatesLabel.propTypes = {
|
|
98
|
-
graphProps: _plot.types.GraphPropsType,
|
|
99
|
-
classes: _propTypes["default"].object,
|
|
100
|
-
x: _propTypes["default"].number,
|
|
101
|
-
y: _propTypes["default"].number
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
var _default = (0, _styles.withStyles)(styles)(CoordinatesLabel);
|
|
105
|
-
|
|
106
|
-
exports["default"] = _default;
|
|
107
|
-
//# sourceMappingURL=coordinates-label.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/coordinates-label.jsx"],"names":["styles","theme","input","fontFamily","typography","fontSize","borderRadius","background","palette","common","white","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,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,KAAK,EAAE;AACLC,MAAAA,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A,CAAgC;AAAA,MAA7BC,CAA6B,QAA7BA,CAA6B;AAAA,MAA1BF,UAA0B,QAA1BA,UAA0B;AAAA,MAAda,OAAc,QAAdA,OAAc;AACjE,MAAMC,KAAK,cAAO,wBAAYb,CAAZ,CAAP,eAA0B,wBAAYC,CAAZ,CAA1B,MAAX;AACA,MAAMC,WAAW,GAAG,CAACW,KAAK,CAACC,MAAN,IAAgB,CAAjB,IAAsB,CAA1C;AACA,MAAMC,aAAa,GAAGjB,gBAAgB,CAACC,UAAD,EAAaC,CAAb,EAAgBC,CAAhB,EAAmBC,WAAnB,CAAtC;;AAEA,MAAMc,KAAK;AACTC,IAAAA,QAAQ,EAAE,UADD;AAETC,IAAAA,aAAa,EAAE,MAFN;AAGTC,IAAAA,KAAK,EAAEjB,WAHE;AAITL,IAAAA,OAAO,EAAE;AAJA,KAKNkB,aALM,CAAX;;AAQA,sBACE,gCAAC,qBAAD;AACE,IAAA,KAAK,EAAEC,KADT;AAEE,IAAA,OAAO,EAAE;AAAE/B,MAAAA,KAAK,EAAE2B,OAAO,CAAChB;AAAjB,KAFX;AAGE,IAAA,SAAS,EAAEgB,OAAO,CAAC3B,KAHrB;AAIE,IAAA,KAAK,EAAE4B,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,wBAAW3C,MAAX,EAAmB4B,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: theme.palette.common.white,\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"}
|