@pie-lib/graphing 2.12.29-next.0 → 2.12.29-next.4
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/lib/container/index.js +7 -2
- package/lib/container/index.js.map +1 -1
- package/lib/container/middleware.js +25 -0
- package/lib/container/middleware.js.map +1 -0
- package/lib/undo-redo.js +9 -3
- package/lib/undo-redo.js.map +1 -1
- package/package.json +3 -3
- package/src/container/index.jsx +6 -3
- package/src/container/middleware.js +7 -0
- package/src/undo-redo.jsx +3 -3
package/lib/container/index.js
CHANGED
|
@@ -43,6 +43,8 @@ var _reduxUndo = require("redux-undo");
|
|
|
43
43
|
|
|
44
44
|
var _graphWithControls = _interopRequireDefault(require("../graph-with-controls"));
|
|
45
45
|
|
|
46
|
+
var _middleware = require("./middleware");
|
|
47
|
+
|
|
46
48
|
var _excluded = ["onChangeMarks", "marks"];
|
|
47
49
|
|
|
48
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); }; }
|
|
@@ -97,14 +99,17 @@ var Root = /*#__PURE__*/function (_React$Component) {
|
|
|
97
99
|
|
|
98
100
|
var storeState = _this.store.getState();
|
|
99
101
|
|
|
102
|
+
var lastAction = (0, _middleware.getLastAction)();
|
|
103
|
+
var isUndoOperation = lastAction.type.includes('UNDO') || lastAction.type.includes('REDO');
|
|
104
|
+
|
|
100
105
|
if (!(0, _isEqual["default"])(storeState.marks.present, marks)) {
|
|
101
|
-
onChangeMarks(storeState.marks.present);
|
|
106
|
+
onChangeMarks(storeState.marks.present, isUndoOperation);
|
|
102
107
|
}
|
|
103
108
|
});
|
|
104
109
|
var r = (0, _reducer["default"])();
|
|
105
110
|
_this.store = (0, _redux.createStore)(r, {
|
|
106
111
|
marks: props.marks
|
|
107
|
-
});
|
|
112
|
+
}, (0, _redux.applyMiddleware)(_middleware.lastActionMiddleware));
|
|
108
113
|
|
|
109
114
|
_this.store.subscribe(_this.onStoreChange);
|
|
110
115
|
|
|
@@ -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","prevProps","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,CAACC,CAAD;AAAA,SAAQ;AAC9BC,IAAAA,KAAK,EAAED,CAAC,CAACC,KAAF,CAAQC;AADe,GAAR;AAAA,CAAxB;;AAIA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,QAAD;AAAA,SAAe;AACxCC,IAAAA,aAAa,EAAE,uBAACC,CAAD;AAAA,aAAOF,QAAQ,CAAC,0BAAYE,CAAZ,CAAD,CAAf;AAAA,KADyB;AAExCC,IAAAA,MAAM,EAAE;AAAA,aAAMH,QAAQ,CAACI,0BAAeC,IAAf,EAAD,CAAd;AAAA,KAFgC;AAGxCC,IAAAA,MAAM,EAAE;AAAA,aAAMN,QAAQ,CAACI,0BAAeG,IAAf,EAAD,CAAd;AAAA,KAHgC;AAIxCC,IAAAA,OAAO,EAAE;AAAA,aAAMR,QAAQ,CAAC,0BAAY,EAAZ,CAAD,CAAd;AAAA;AAJ+B,GAAf;AAAA,CAA3B;;AAOO,IAAMS,cAAc,GAAG,yBAAQd,eAAR,EAAyBI,kBAAzB,EAA6CW,6BAA7C,CAAvB;AAEP;AACA;AACA;AACA;;;;IACMC,I;;;;;AAMJ,gBAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,sGAsBH,YAAM;AACpB,wBAAiC,MAAKA,KAAtC;AAAA,UAAQf,KAAR,eAAQA,KAAR;AAAA,UAAeI,aAAf,eAAeA,aAAf;;AACA,UAAMY,UAAU,GAAG,MAAKC,KAAL,CAAWC,QAAX,EAAnB;;AAEA,UAAI,CAAC,
|
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,CAAD;AAAA,SAAQ;AAC9BC,IAAAA,KAAK,EAAED,CAAC,CAACC,KAAF,CAAQC;AADe,GAAR;AAAA,CAAxB;;AAIA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,QAAD;AAAA,SAAe;AACxCC,IAAAA,aAAa,EAAE,uBAACC,CAAD;AAAA,aAAOF,QAAQ,CAAC,0BAAYE,CAAZ,CAAD,CAAf;AAAA,KADyB;AAExCC,IAAAA,MAAM,EAAE;AAAA,aAAMH,QAAQ,CAACI,0BAAeC,IAAf,EAAD,CAAd;AAAA,KAFgC;AAGxCC,IAAAA,MAAM,EAAE;AAAA,aAAMN,QAAQ,CAACI,0BAAeG,IAAf,EAAD,CAAd;AAAA,KAHgC;AAIxCC,IAAAA,OAAO,EAAE;AAAA,aAAMR,QAAQ,CAAC,0BAAY,EAAZ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,CAAJ,EAA8C;AAC5C;AACD;;AAED,UAAI,CAAC,yBAAQ2B,SAAS,CAAC3B,KAAlB,EAAyBA,KAAzB,CAAL,EAAsC;AACpC,aAAKiB,KAAL,CAAWd,QAAX,CAAoB,0BAAYH,KAAZ,CAApB;AACD;AACF;;;WAaD,kBAAS;AACP;AACA,yBAA0C,KAAKe,KAA/C;AAAA,UAAQX,aAAR,gBAAQA,aAAR;AAAA,UAAuBJ,KAAvB,gBAAuBA,KAAvB;AAAA,UAAiC4B,IAAjC;AACA,UAAMC,cAAc,GAAG7B,KAAK,IAAIA,KAAK,CAAC8B,IAAN,CAAW,UAACzB,CAAD;AAAA,eAAOA,CAAC,CAAC0B,WAAT;AAAA,OAAX,CAAhC;;AAEA,UAAIF,cAAJ,EAAoB;AAClB,4BAAO,gCAAC,6BAAD,gCAAuBD,IAAvB;AAA6B,UAAA,KAAK,EAAE5B,KAApC;AAA2C,UAAA,QAAQ,EAAE6B;AAArD,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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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/undo-redo.js
CHANGED
|
@@ -60,17 +60,23 @@ var UndoRedo = /*#__PURE__*/function (_React$Component) {
|
|
|
60
60
|
classes: {
|
|
61
61
|
root: classes.button
|
|
62
62
|
},
|
|
63
|
-
onClick:
|
|
63
|
+
onClick: function onClick() {
|
|
64
|
+
return onUndo(true);
|
|
65
|
+
}
|
|
64
66
|
}, "Undo"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
65
67
|
classes: {
|
|
66
68
|
root: classes.button
|
|
67
69
|
},
|
|
68
|
-
onClick:
|
|
70
|
+
onClick: function onClick() {
|
|
71
|
+
return onRedo(true);
|
|
72
|
+
}
|
|
69
73
|
}, "Redo"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
70
74
|
classes: {
|
|
71
75
|
root: classes.button
|
|
72
76
|
},
|
|
73
|
-
onClick:
|
|
77
|
+
onClick: function onClick() {
|
|
78
|
+
return onReset();
|
|
79
|
+
}
|
|
74
80
|
}, "Reset"));
|
|
75
81
|
}
|
|
76
82
|
}]);
|
package/lib/undo-redo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/undo-redo.jsx"],"names":["UndoRedo","props","classes","className","onUndo","onRedo","onReset","root","button","React","Component","PropTypes","object","string","func","isRequired","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","marginRight","primary"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,Q;;;;;;;;;;;;WASX,kBAAS;AACP,wBAAwD,KAAKC,KAA7D;AAAA,UAAQC,OAAR,eAAQA,OAAR;AAAA,UAAiBC,SAAjB,eAAiBA,SAAjB;AAAA,UAA4BC,MAA5B,eAA4BA,MAA5B;AAAA,UAAoCC,MAApC,eAAoCA,MAApC;AAAA,UAA4CC,OAA5C,eAA4CA,OAA5C;AACA,0BACE;AAAK,QAAA,SAAS,EAAE,4BAAWH,SAAX;AAAhB,sBACE,gCAAC,kBAAD;AAAQ,QAAA,OAAO,EAAE;AAAEI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAAhB,SAAjB;AAA2C,QAAA,OAAO,
|
|
1
|
+
{"version":3,"sources":["../src/undo-redo.jsx"],"names":["UndoRedo","props","classes","className","onUndo","onRedo","onReset","root","button","React","Component","PropTypes","object","string","func","isRequired","styles","theme","color","text","backgroundColor","background","marginBottom","spacing","unit","marginRight","primary"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,Q;;;;;;;;;;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AM,EAAE;AACNU,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADD;AAENC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFX;AAGNC,MAAAA,YAAY,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB,CAH7B;AAIN,8BAAwB;AACtBC,QAAAA,WAAW,EAAER,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AADZ,OAJlB;AAON,iBAAW;AACTJ,QAAAA,eAAe,EAAEF,gBAAMQ,OAAN;AADR;AAPL;AADiB,GAAZ;AAAA,CAAf;;eAce,sBAAWV,MAAX,EAAmBhB,QAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport Button from '@material-ui/core/Button';\nimport { withStyles } from '@material-ui/core';\nimport { color } from '@pie-lib/render-ui';\n\nexport class UndoRedo extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n className: PropTypes.string,\n onUndo: PropTypes.func.isRequired,\n onRedo: PropTypes.func.isRequired,\n onReset: PropTypes.func.isRequired,\n };\n static defaultProps = {};\n render() {\n const { classes, className, onUndo, onRedo, onReset } = this.props;\n return (\n <div className={classNames(className)}>\n <Button classes={{ root: classes.button }} onClick={() => onUndo(true)}>\n Undo\n </Button>\n <Button classes={{ root: classes.button }} onClick={() => onRedo(true)}>\n Redo\n </Button>\n <Button classes={{ root: classes.button }} onClick={() => onReset()}>\n Reset\n </Button>\n </div>\n );\n }\n}\n\nconst styles = (theme) => ({\n button: {\n color: color.text(),\n backgroundColor: color.background(),\n marginBottom: theme.spacing.unit / 2,\n '&:not(:last-of-type)': {\n marginRight: theme.spacing.unit / 2,\n },\n '&:hover': {\n backgroundColor: color.primary(),\n },\n },\n});\n\nexport default withStyles(styles)(UndoRedo);\n"],"file":"undo-redo.js"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.12.29-next.
|
|
6
|
+
"version": "2.12.29-next.4+8a15ca7f",
|
|
7
7
|
"description": "Graphing components",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@pie-lib/drag": "^2.1.18",
|
|
22
22
|
"@pie-lib/graphing-utils": "^1.1.32",
|
|
23
23
|
"@pie-lib/plot": "^2.6.13",
|
|
24
|
-
"@pie-lib/render-ui": "^4.14.
|
|
24
|
+
"@pie-lib/render-ui": "^4.14.24",
|
|
25
25
|
"@vx/axis": "^0.0.189",
|
|
26
26
|
"@vx/clip-path": "^0.0.189",
|
|
27
27
|
"@vx/event": "^0.0.189",
|
|
@@ -44,6 +44,6 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "^16.8.1"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "8a15ca7ff6af7aa924e4120aae9a75aa89830f4c",
|
|
48
48
|
"scripts": {}
|
|
49
49
|
}
|
package/src/container/index.jsx
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { connect } from 'react-redux';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Provider } from 'react-redux';
|
|
4
|
-
import { createStore } from 'redux';
|
|
4
|
+
import { applyMiddleware, createStore } from 'redux';
|
|
5
5
|
import reducer from './reducer';
|
|
6
6
|
import { changeMarks } from './actions';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import isEqual from 'lodash/isEqual';
|
|
9
9
|
import { ActionCreators } from 'redux-undo';
|
|
10
10
|
import GraphWithControls from '../graph-with-controls';
|
|
11
|
+
import { lastActionMiddleware, getLastAction } from './middleware';
|
|
11
12
|
|
|
12
13
|
const mapStateToProps = (s) => ({
|
|
13
14
|
marks: s.marks.present,
|
|
@@ -36,7 +37,7 @@ class Root extends React.Component {
|
|
|
36
37
|
super(props);
|
|
37
38
|
|
|
38
39
|
const r = reducer();
|
|
39
|
-
this.store = createStore(r, { marks: props.marks });
|
|
40
|
+
this.store = createStore(r, { marks: props.marks }, applyMiddleware(lastActionMiddleware));
|
|
40
41
|
|
|
41
42
|
this.store.subscribe(this.onStoreChange);
|
|
42
43
|
}
|
|
@@ -57,9 +58,11 @@ class Root extends React.Component {
|
|
|
57
58
|
onStoreChange = () => {
|
|
58
59
|
const { marks, onChangeMarks } = this.props;
|
|
59
60
|
const storeState = this.store.getState();
|
|
61
|
+
const lastAction = getLastAction();
|
|
62
|
+
const isUndoOperation = lastAction.type.includes('UNDO') || lastAction.type.includes('REDO');
|
|
60
63
|
|
|
61
64
|
if (!isEqual(storeState.marks.present, marks)) {
|
|
62
|
-
onChangeMarks(storeState.marks.present);
|
|
65
|
+
onChangeMarks(storeState.marks.present, isUndoOperation);
|
|
63
66
|
}
|
|
64
67
|
};
|
|
65
68
|
|
package/src/undo-redo.jsx
CHANGED
|
@@ -18,13 +18,13 @@ export class UndoRedo extends React.Component {
|
|
|
18
18
|
const { classes, className, onUndo, onRedo, onReset } = this.props;
|
|
19
19
|
return (
|
|
20
20
|
<div className={classNames(className)}>
|
|
21
|
-
<Button classes={{ root: classes.button }} onClick={onUndo}>
|
|
21
|
+
<Button classes={{ root: classes.button }} onClick={() => onUndo(true)}>
|
|
22
22
|
Undo
|
|
23
23
|
</Button>
|
|
24
|
-
<Button classes={{ root: classes.button }} onClick={onRedo}>
|
|
24
|
+
<Button classes={{ root: classes.button }} onClick={() => onRedo(true)}>
|
|
25
25
|
Redo
|
|
26
26
|
</Button>
|
|
27
|
-
<Button classes={{ root: classes.button }} onClick={onReset}>
|
|
27
|
+
<Button classes={{ root: classes.button }} onClick={() => onReset()}>
|
|
28
28
|
Reset
|
|
29
29
|
</Button>
|
|
30
30
|
</div>
|