@pie-lib/graphing 2.4.17 → 2.5.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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.5.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@2.4.17...@pie-lib/graphing@2.5.0) (2022-05-03)
7
+
8
+
9
+ ### Features
10
+
11
+ * **graphing:** updated store on model change PD-1608 ([a3744dd](https://github.com/pie-framework/pie-lib/commit/a3744dd74d90cca280b90657cbd558ce7ab9c288))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [2.4.17](https://github.com/pie-framework/pie-lib/compare/@pie-lib/graphing@2.4.16...@pie-lib/graphing@2.4.17) (2022-04-28)
7
18
 
8
19
  **Note:** Version bump only for package @pie-lib/graphing
@@ -123,6 +123,16 @@ var Root = /*#__PURE__*/function (_React$Component) {
123
123
  }
124
124
 
125
125
  _createClass(Root, [{
126
+ key: "componentDidUpdate",
127
+ value: function componentDidUpdate() {
128
+ var marks = this.props.marks;
129
+ var storeState = this.store.getState();
130
+
131
+ if (!(0, _isEqual["default"])(storeState.marks.present, marks)) {
132
+ this.store.dispatch((0, _actions.changeMarks)(marks));
133
+ }
134
+ }
135
+ }, {
126
136
  key: "render",
127
137
  value: function render() {
128
138
  // eslint-disable-next-line no-unused-vars
@@ -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":";;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;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UAAKF,KAAL,GAAa,wBAAYE,CAAZ,EAAe;AAAEnB,MAAAA,KAAK,EAAEe,KAAK,CAACf;AAAf,KAAf,CAAb;;AAEA,UAAKiB,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"}
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,IAAAA,KAAK,EAAED,CAAC,CAACC,KAAF,CAAQC;AADa,GAAL;AAAA,CAAzB;;AAIA,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAAAC,QAAQ;AAAA,SAAK;AACtCC,IAAAA,aAAa,EAAE,uBAAAC,CAAC;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,QAAX,EAAnB;;AAEA,UAAI,CAAC,yBAAQF,UAAU,CAAChB,KAAX,CAAiBC,OAAzB,EAAkCD,KAAlC,CAAL,EAA+C;AAC7C,aAAKiB,KAAL,CAAWd,QAAX,CAAoB,0BAAYH,KAAZ,CAApB;AACD;AACF;;;WAUD,kBAAS;AACP;AACA,yBAA0C,KAAKe,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;;;;EA9CgBI,kBAAMC,S;;gBAAnBb,I,eACe;AACjBV,EAAAA,aAAa,EAAEwB,sBAAUC,IADR;AAEjB7B,EAAAA,KAAK,EAAE4B,sBAAUE;AAFA,C;;eAgDNhB,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(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 });\n\n this.store.subscribe(this.onStoreChange);\n }\n\n componentDidUpdate() {\n const { marks } = this.props;\n const storeState = this.store.getState();\n\n if (!isEqual(storeState.marks.present, 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 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/undo-redo.js CHANGED
@@ -104,9 +104,9 @@ var styles = function styles(theme) {
104
104
  button: {
105
105
  color: _renderUi.color.text(),
106
106
  backgroundColor: _renderUi.color.background(),
107
+ marginBottom: theme.spacing.unit / 2,
107
108
  '&:not(:last-of-type)': {
108
- marginRight: theme.spacing.unit / 2,
109
- marginBottom: theme.spacing.unit / 2
109
+ marginRight: theme.spacing.unit / 2
110
110
  },
111
111
  '&:hover': {
112
112
  backgroundColor: _renderUi.color.primary()
@@ -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","marginRight","spacing","unit","marginBott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,EAAE;AACNU,MAAAA,KAAK,EAAEA,gBAAMC,IAAN,EADD;AAENC,MAAAA,eAAe,EAAEF,gBAAMG,UAAN,EAFX;AAGN,8BAAwB;AACtBC,QAAAA,WAAW,EAAEL,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB,CADZ;AAEtBC,QAAAA,YAAY,EAAER,KAAK,CAACM,OAAN,CAAcC,IAAd,GAAqB;AAFb,OAHlB;AAON,iBAAW;AACTJ,QAAAA,eAAe,EAAEF,gBAAMQ,OAAN;AADR;AAPL;AADe,GAAL;AAAA,CAApB;;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}>\n Undo\n </Button>\n <Button classes={{ root: classes.button }} onClick={onRedo}>\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 '&:not(:last-of-type)': {\n marginRight: theme.spacing.unit / 2,\n marginBottom: 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"}
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","marginB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BT,IAAAA,MAAM,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;AADe,GAAL;AAAA,CAApB;;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}>\n Undo\n </Button>\n <Button classes={{ root: classes.button }} onClick={onRedo}>\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.4.17",
6
+ "version": "2.5.0",
7
7
  "description": "Graphing components",
8
8
  "keywords": [
9
9
  "react",
@@ -43,6 +43,6 @@
43
43
  "peerDependencies": {
44
44
  "react": "^16.8.1"
45
45
  },
46
- "gitHead": "15c7a1364de782a095f8387f6be54af23e45fa10",
46
+ "gitHead": "087c2d35cb14814526bbaa0cf6744c02ae4b1c5e",
47
47
  "scripts": {}
48
48
  }
@@ -20,10 +20,7 @@ const mapDispatchToProps = dispatch => ({
20
20
  onReset: () => dispatch(changeMarks([]))
21
21
  });
22
22
 
23
- export const GraphContainer = connect(
24
- mapStateToProps,
25
- mapDispatchToProps
26
- )(GraphWithControls);
23
+ export const GraphContainer = connect(mapStateToProps, mapDispatchToProps)(GraphWithControls);
27
24
 
28
25
  /**
29
26
  * The graph component entry point with undo/redo
@@ -44,6 +41,15 @@ class Root extends React.Component {
44
41
  this.store.subscribe(this.onStoreChange);
45
42
  }
46
43
 
44
+ componentDidUpdate() {
45
+ const { marks } = this.props;
46
+ const storeState = this.store.getState();
47
+
48
+ if (!isEqual(storeState.marks.present, marks)) {
49
+ this.store.dispatch(changeMarks(marks));
50
+ }
51
+ }
52
+
47
53
  onStoreChange = () => {
48
54
  const { marks, onChangeMarks } = this.props;
49
55
  const storeState = this.store.getState();
package/src/undo-redo.jsx CHANGED
@@ -36,9 +36,9 @@ const styles = theme => ({
36
36
  button: {
37
37
  color: color.text(),
38
38
  backgroundColor: color.background(),
39
+ marginBottom: theme.spacing.unit / 2,
39
40
  '&:not(:last-of-type)': {
40
- marginRight: theme.spacing.unit / 2,
41
- marginBottom: theme.spacing.unit / 2
41
+ marginRight: theme.spacing.unit / 2
42
42
  },
43
43
  '&:hover': {
44
44
  backgroundColor: color.primary()