@pie-lib/graphing 2.4.9 → 2.4.12

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/lib/axis/arrow.js +17 -13
  3. package/lib/axis/arrow.js.map +1 -1
  4. package/lib/axis/axes.js +57 -51
  5. package/lib/axis/axes.js.map +1 -1
  6. package/lib/axis/index.js +5 -1
  7. package/lib/axis/index.js.map +1 -1
  8. package/lib/bg.js +16 -14
  9. package/lib/bg.js.map +1 -1
  10. package/lib/container/index.js +21 -15
  11. package/lib/container/index.js.map +1 -1
  12. package/lib/coordinates-label.js +4 -4
  13. package/lib/coordinates-label.js.map +1 -1
  14. package/lib/graph-with-controls.js +29 -25
  15. package/lib/graph-with-controls.js.map +1 -1
  16. package/lib/graph.js +56 -42
  17. package/lib/graph.js.map +1 -1
  18. package/lib/grid.js +20 -14
  19. package/lib/grid.js.map +1 -1
  20. package/lib/index.js +5 -1
  21. package/lib/index.js.map +1 -1
  22. package/lib/labels.js +28 -24
  23. package/lib/labels.js.map +1 -1
  24. package/lib/mark-label.js +16 -8
  25. package/lib/mark-label.js.map +1 -1
  26. package/lib/toggle-bar.js +18 -16
  27. package/lib/toggle-bar.js.map +1 -1
  28. package/lib/tool-menu.js +22 -16
  29. package/lib/tool-menu.js.map +1 -1
  30. package/lib/tools/circle/bg-circle.js +26 -18
  31. package/lib/tools/circle/bg-circle.js.map +1 -1
  32. package/lib/tools/circle/component.js +30 -28
  33. package/lib/tools/circle/component.js.map +1 -1
  34. package/lib/tools/circle/index.js +4 -4
  35. package/lib/tools/circle/index.js.map +1 -1
  36. package/lib/tools/index.js +16 -15
  37. package/lib/tools/index.js.map +1 -1
  38. package/lib/tools/line/component.js +12 -6
  39. package/lib/tools/line/component.js.map +1 -1
  40. package/lib/tools/parabola/component.js.map +1 -1
  41. package/lib/tools/parabola/index.js +4 -4
  42. package/lib/tools/parabola/index.js.map +1 -1
  43. package/lib/tools/point/component.js +21 -17
  44. package/lib/tools/point/component.js.map +1 -1
  45. package/lib/tools/point/index.js +2 -2
  46. package/lib/tools/polygon/component.js +55 -47
  47. package/lib/tools/polygon/component.js.map +1 -1
  48. package/lib/tools/polygon/index.js +12 -8
  49. package/lib/tools/polygon/index.js.map +1 -1
  50. package/lib/tools/polygon/line.js +26 -18
  51. package/lib/tools/polygon/line.js.map +1 -1
  52. package/lib/tools/polygon/polygon.js +26 -18
  53. package/lib/tools/polygon/polygon.js.map +1 -1
  54. package/lib/tools/ray/component.js +12 -6
  55. package/lib/tools/ray/component.js.map +1 -1
  56. package/lib/tools/segment/component.js +4 -2
  57. package/lib/tools/segment/component.js.map +1 -1
  58. package/lib/tools/shared/arrow-head.js +4 -4
  59. package/lib/tools/shared/arrow-head.js.map +1 -1
  60. package/lib/tools/shared/line/index.js +46 -44
  61. package/lib/tools/shared/line/index.js.map +1 -1
  62. package/lib/tools/shared/line/line-path.js +28 -20
  63. package/lib/tools/shared/line/line-path.js.map +1 -1
  64. package/lib/tools/shared/line/with-root-edge.js +8 -6
  65. package/lib/tools/shared/line/with-root-edge.js.map +1 -1
  66. package/lib/tools/shared/point/arrow-point.js +21 -15
  67. package/lib/tools/shared/point/arrow-point.js.map +1 -1
  68. package/lib/tools/shared/point/arrow.js +22 -50
  69. package/lib/tools/shared/point/arrow.js.map +1 -1
  70. package/lib/tools/shared/point/base-point.js +22 -16
  71. package/lib/tools/shared/point/base-point.js.map +1 -1
  72. package/lib/tools/shared/point/index.js +8 -4
  73. package/lib/tools/shared/point/index.js.map +1 -1
  74. package/lib/tools/shared/styles.js +1 -1
  75. package/lib/tools/shared/types.js +1 -1
  76. package/lib/tools/sine/component.js.map +1 -1
  77. package/lib/tools/sine/index.js +4 -4
  78. package/lib/tools/sine/index.js.map +1 -1
  79. package/lib/tools/vector/component.js +21 -8
  80. package/lib/tools/vector/component.js.map +1 -1
  81. package/lib/undo-redo.js +20 -16
  82. package/lib/undo-redo.js.map +1 -1
  83. package/lib/use-debounce.js +7 -3
  84. package/lib/use-debounce.js.map +1 -1
  85. package/lib/utils.js +70 -5
  86. package/lib/utils.js.map +1 -1
  87. package/package.json +4 -4
  88. package/src/axis/axes.jsx +1 -1
  89. package/src/graph.jsx +13 -6
  90. package/src/tools/shared/point/arrow.jsx +1 -30
  91. package/src/tools/vector/component.jsx +20 -6
  92. package/src/utils.js +62 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/tools/sine/component.jsx"],"names":["log","Sine","props","domain","graphProps","root","edge","amplitude","freq","interval","FREQ_DIVIDER","dataPoints","x","min","max","phase","vertical","y","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uBAAN,CAAZ;AAEAA,GAAG,CAAC,SAAD,CAAH;AAEA,IAAMC,IAAI,GAAG,gCAAa,UAAAC,KAAK,EAAI;AAAA,MACzBC,MADyB,GACdD,KAAK,CAACE,UADQ,CACzBD,MADyB;AAAA,MAGzBE,IAHyB,GAGVH,KAHU,CAGzBG,IAHyB;AAAA,MAGnBC,IAHmB,GAGVJ,KAHU,CAGnBI,IAHmB;;AAAA,6BAIL,wCAAoBD,IAApB,EAA0BC,IAA1B,CAJK;AAAA,MAIzBC,SAJyB,wBAIzBA,SAJyB;AAAA,MAIdC,IAJc,wBAIdA,IAJc;;AAKjC,MAAMC,QAAQ,GAAGD,IAAI,GAAGE,2BAAxB;AACAV,EAAAA,GAAG,CAAC,wBAAD,EAA2BO,SAA3B,EAAsC,OAAtC,EAA+CC,IAA/C,CAAH;AAEA,MAAMG,UAAU,GACdL,IAAI,IAAIA,IAAI,CAACM,CAAL,KAAWP,IAAI,CAACO,CAAxB,GACI,EADJ,GAEI,oCACET,MAAM,CAACU,GADT,EAEEV,MAAM,CAACW,GAFT,EAGET,IAHF,EAIEC,IAJF,EAKEG,QALF,EAME,yBAAKF,SAAL,EAAgBC,IAAhB,EAAsB;AAAEO,IAAAA,KAAK,EAAEV,IAAI,CAACO,CAAd;AAAiBI,IAAAA,QAAQ,EAAEX,IAAI,CAACY;AAAhC,GAAtB,CANF,CAHN;AAWA,SAAO;AAAEZ,IAAAA,IAAI,EAAEH,KAAK,CAACG,IAAd;AAAoBC,IAAAA,IAAI,EAAEJ,KAAK,CAACI,IAAhC;AAAsCK,IAAAA,UAAU,EAAVA;AAAtC,GAAP;AACD,CApBY,CAAb;AAsBA,IAAMO,SAAS,GAAG,qCAAkBjB,IAAlB,CAAlB;eACeiB,S","sourcesContent":["import debug from 'debug';\nimport { sinY, buildDataPoints, getAmplitudeAndFreq, FREQ_DIVIDER } from '@pie-lib/graphing-utils';\nimport { withRootEdge, rootEdgeComponent } from '../shared/line/with-root-edge';\n\nconst log = debug('pie-lib:graphing:sine');\n\nlog('sine...');\n\nconst Sine = withRootEdge(props => {\n const { domain } = props.graphProps;\n\n const { root, edge } = props;\n const { amplitude, freq } = getAmplitudeAndFreq(root, edge);\n const interval = freq / FREQ_DIVIDER;\n log('[getPoints] amplitude:', amplitude, 'freq:', freq);\n\n const dataPoints =\n edge && edge.x === root.x\n ? []\n : buildDataPoints(\n domain.min,\n domain.max,\n root,\n edge,\n interval,\n sinY(amplitude, freq, { phase: root.x, vertical: root.y })\n );\n return { root: props.root, edge: props.edge, dataPoints };\n});\n\nconst Component = rootEdgeComponent(Sine);\nexport default Component;\n"],"file":"component.js"}
1
+ {"version":3,"sources":["../../../src/tools/sine/component.jsx"],"names":["log","Sine","props","domain","graphProps","root","edge","amplitude","freq","interval","FREQ_DIVIDER","dataPoints","x","min","max","phase","vertical","y","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uBAAN,CAAZ;AAEAA,GAAG,CAAC,SAAD,CAAH;AAEA,IAAMC,IAAI,GAAG,gCAAa,UAAAC,KAAK,EAAI;AACjC,MAAQC,MAAR,GAAmBD,KAAK,CAACE,UAAzB,CAAQD,MAAR;AAEA,MAAQE,IAAR,GAAuBH,KAAvB,CAAQG,IAAR;AAAA,MAAcC,IAAd,GAAuBJ,KAAvB,CAAcI,IAAd;;AACA,6BAA4B,wCAAoBD,IAApB,EAA0BC,IAA1B,CAA5B;AAAA,MAAQC,SAAR,wBAAQA,SAAR;AAAA,MAAmBC,IAAnB,wBAAmBA,IAAnB;;AACA,MAAMC,QAAQ,GAAGD,IAAI,GAAGE,2BAAxB;AACAV,EAAAA,GAAG,CAAC,wBAAD,EAA2BO,SAA3B,EAAsC,OAAtC,EAA+CC,IAA/C,CAAH;AAEA,MAAMG,UAAU,GACdL,IAAI,IAAIA,IAAI,CAACM,CAAL,KAAWP,IAAI,CAACO,CAAxB,GACI,EADJ,GAEI,oCACET,MAAM,CAACU,GADT,EAEEV,MAAM,CAACW,GAFT,EAGET,IAHF,EAIEC,IAJF,EAKEG,QALF,EAME,yBAAKF,SAAL,EAAgBC,IAAhB,EAAsB;AAAEO,IAAAA,KAAK,EAAEV,IAAI,CAACO,CAAd;AAAiBI,IAAAA,QAAQ,EAAEX,IAAI,CAACY;AAAhC,GAAtB,CANF,CAHN;AAWA,SAAO;AAAEZ,IAAAA,IAAI,EAAEH,KAAK,CAACG,IAAd;AAAoBC,IAAAA,IAAI,EAAEJ,KAAK,CAACI,IAAhC;AAAsCK,IAAAA,UAAU,EAAVA;AAAtC,GAAP;AACD,CApBY,CAAb;AAsBA,IAAMO,SAAS,GAAG,qCAAkBjB,IAAlB,CAAlB;eACeiB,S","sourcesContent":["import debug from 'debug';\nimport { sinY, buildDataPoints, getAmplitudeAndFreq, FREQ_DIVIDER } from '@pie-lib/graphing-utils';\nimport { withRootEdge, rootEdgeComponent } from '../shared/line/with-root-edge';\n\nconst log = debug('pie-lib:graphing:sine');\n\nlog('sine...');\n\nconst Sine = withRootEdge(props => {\n const { domain } = props.graphProps;\n\n const { root, edge } = props;\n const { amplitude, freq } = getAmplitudeAndFreq(root, edge);\n const interval = freq / FREQ_DIVIDER;\n log('[getPoints] amplitude:', amplitude, 'freq:', freq);\n\n const dataPoints =\n edge && edge.x === root.x\n ? []\n : buildDataPoints(\n domain.min,\n domain.max,\n root,\n edge,\n interval,\n sinY(amplitude, freq, { phase: root.x, vertical: root.y })\n );\n return { root: props.root, edge: props.edge, dataPoints };\n});\n\nconst Component = rootEdgeComponent(Sine);\nexport default Component;\n"],"file":"component.js"}
@@ -13,9 +13,9 @@ var _utils = require("../../utils");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
15
 
16
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
16
+ 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; }
17
17
 
18
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
19
 
20
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
 
@@ -26,7 +26,7 @@ var tool = function tool() {
26
26
  type: 'sine',
27
27
  Component: _component["default"],
28
28
  complete: function complete(data, mark) {
29
- return _objectSpread({}, mark, {
29
+ return _objectSpread(_objectSpread({}, mark), {}, {
30
30
  building: false,
31
31
  closed: true
32
32
  });
@@ -49,7 +49,7 @@ var tool = function tool() {
49
49
  } else if (mark && !mark.root) {
50
50
  throw new Error('no root - should never happen');
51
51
  } else {
52
- return _objectSpread({}, mark, {
52
+ return _objectSpread(_objectSpread({}, mark), {}, {
53
53
  edge: point,
54
54
  closed: true,
55
55
  building: false
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/tools/sine/index.js"],"names":["log","tool","type","Component","Sine","complete","data","mark","building","closed","addPoint","point","root","edge","undefined","Error"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uBAAN,CAAZ;;AAEO,IAAMC,IAAI,GAAG,SAAPA,IAAO;AAAA,SAAO;AACzBC,IAAAA,IAAI,EAAE,MADmB;AAEzBC,IAAAA,SAAS,EAAEC,qBAFc;AAGzBC,IAAAA,QAAQ,EAAE,kBAACC,IAAD,EAAOC,IAAP,EAAgB;AACxB,+BAAYA,IAAZ;AAAkBC,QAAAA,QAAQ,EAAE,KAA5B;AAAmCC,QAAAA,MAAM,EAAE;AAA3C;AACD,KALwB;AAMzBC,IAAAA,QAAQ,EAAE,kBAACC,KAAD,EAAQJ,IAAR,EAAiB;AACzBP,MAAAA,GAAG,CAAC,2BAAD,EAA8BW,KAA9B,EAAqC,QAArC,EAA+CJ,IAA/C,CAAH;;AACA,UAAIA,IAAI,KAAK,wBAAYA,IAAI,CAACK,IAAjB,EAAuBD,KAAvB,KAAiC,qBAASJ,IAAI,CAACK,IAAd,EAAoBD,KAApB,CAAtC,CAAR,EAA2E;AACzE,eAAOJ,IAAP;AACD;;AAED,UAAI,CAACA,IAAL,EAAW;AACT,eAAO;AACLL,UAAAA,IAAI,EAAE,MADD;AAELU,UAAAA,IAAI,EAAED,KAFD;AAGLE,UAAAA,IAAI,EAAEC,SAHD;AAILL,UAAAA,MAAM,EAAE,KAJH;AAKLD,UAAAA,QAAQ,EAAE;AALL,SAAP;AAOD,OARD,MAQO,IAAID,IAAI,IAAI,CAACA,IAAI,CAACK,IAAlB,EAAwB;AAC7B,cAAM,IAAIG,KAAJ,CAAU,+BAAV,CAAN;AACD,OAFM,MAEA;AACL,iCAAYR,IAAZ;AAAkBM,UAAAA,IAAI,EAAEF,KAAxB;AAA+BF,UAAAA,MAAM,EAAE,IAAvC;AAA6CD,UAAAA,QAAQ,EAAE;AAAvD;AACD;AACF;AAzBwB,GAAP;AAAA,CAAb","sourcesContent":["import Sine from './component';\nimport debug from 'debug';\nimport { equalPoints, sameAxes } from '../../utils';\n\nconst log = debug('pie-lib:graphing:sine');\n\nexport const tool = () => ({\n type: 'sine',\n Component: Sine,\n complete: (data, mark) => {\n return { ...mark, building: false, closed: true };\n },\n addPoint: (point, mark) => {\n log('add point to sine model: ', point, 'mark: ', mark);\n if (mark && (equalPoints(mark.root, point) || sameAxes(mark.root, point))) {\n return mark;\n }\n\n if (!mark) {\n return {\n type: 'sine',\n root: point,\n edge: undefined,\n closed: false,\n building: true\n };\n } else if (mark && !mark.root) {\n throw new Error('no root - should never happen');\n } else {\n return { ...mark, edge: point, closed: true, building: false };\n }\n }\n});\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/tools/sine/index.js"],"names":["log","tool","type","Component","Sine","complete","data","mark","building","closed","addPoint","point","root","edge","undefined","Error"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uBAAN,CAAZ;;AAEO,IAAMC,IAAI,GAAG,SAAPA,IAAO;AAAA,SAAO;AACzBC,IAAAA,IAAI,EAAE,MADmB;AAEzBC,IAAAA,SAAS,EAAEC,qBAFc;AAGzBC,IAAAA,QAAQ,EAAE,kBAACC,IAAD,EAAOC,IAAP,EAAgB;AACxB,6CAAYA,IAAZ;AAAkBC,QAAAA,QAAQ,EAAE,KAA5B;AAAmCC,QAAAA,MAAM,EAAE;AAA3C;AACD,KALwB;AAMzBC,IAAAA,QAAQ,EAAE,kBAACC,KAAD,EAAQJ,IAAR,EAAiB;AACzBP,MAAAA,GAAG,CAAC,2BAAD,EAA8BW,KAA9B,EAAqC,QAArC,EAA+CJ,IAA/C,CAAH;;AACA,UAAIA,IAAI,KAAK,wBAAYA,IAAI,CAACK,IAAjB,EAAuBD,KAAvB,KAAiC,qBAASJ,IAAI,CAACK,IAAd,EAAoBD,KAApB,CAAtC,CAAR,EAA2E;AACzE,eAAOJ,IAAP;AACD;;AAED,UAAI,CAACA,IAAL,EAAW;AACT,eAAO;AACLL,UAAAA,IAAI,EAAE,MADD;AAELU,UAAAA,IAAI,EAAED,KAFD;AAGLE,UAAAA,IAAI,EAAEC,SAHD;AAILL,UAAAA,MAAM,EAAE,KAJH;AAKLD,UAAAA,QAAQ,EAAE;AALL,SAAP;AAOD,OARD,MAQO,IAAID,IAAI,IAAI,CAACA,IAAI,CAACK,IAAlB,EAAwB;AAC7B,cAAM,IAAIG,KAAJ,CAAU,+BAAV,CAAN;AACD,OAFM,MAEA;AACL,+CAAYR,IAAZ;AAAkBM,UAAAA,IAAI,EAAEF,KAAxB;AAA+BF,UAAAA,MAAM,EAAE,IAAvC;AAA6CD,UAAAA,QAAQ,EAAE;AAAvD;AACD;AACF;AAzBwB,GAAP;AAAA,CAAb","sourcesContent":["import Sine from './component';\nimport debug from 'debug';\nimport { equalPoints, sameAxes } from '../../utils';\n\nconst log = debug('pie-lib:graphing:sine');\n\nexport const tool = () => ({\n type: 'sine',\n Component: Sine,\n complete: (data, mark) => {\n return { ...mark, building: false, closed: true };\n },\n addPoint: (point, mark) => {\n log('add point to sine model: ', point, 'mark: ', mark);\n if (mark && (equalPoints(mark.root, point) || sameAxes(mark.root, point))) {\n return mark;\n }\n\n if (!mark) {\n return {\n type: 'sine',\n root: point,\n edge: undefined,\n closed: false,\n building: true\n };\n } else if (mark && !mark.root) {\n throw new Error('no root - should never happen');\n } else {\n return { ...mark, edge: point, closed: true, building: false };\n }\n }\n});\n"],"file":"index.js"}
@@ -19,6 +19,10 @@ var _classnames = _interopRequireDefault(require("classnames"));
19
19
 
20
20
  var _styles = require("@material-ui/core/styles");
21
21
 
22
+ var _utils = require("../../utils");
23
+
24
+ var _excluded = ["className", "classes", "disabled", "correctness", "graphProps", "from", "to"];
25
+
22
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
27
 
24
28
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -41,18 +45,27 @@ var Line = function Line(props) {
41
45
  classes = props.classes,
42
46
  disabled = props.disabled,
43
47
  correctness = props.correctness,
44
- graphProps = props.graphProps,
48
+ scale = props.graphProps.scale,
45
49
  from = props.from,
46
50
  to = props.to,
47
- rest = _objectWithoutProperties(props, ["className", "classes", "disabled", "correctness", "graphProps", "from", "to"]);
51
+ rest = _objectWithoutProperties(props, _excluded);
48
52
 
49
- var scale = graphProps.scale;
50
- return _react["default"].createElement("line", _extends({
53
+ var startPoint = {
54
+ x: scale.x(from.x),
55
+ y: scale.y(from.y)
56
+ };
57
+ var endPoint = {
58
+ x: scale.x(to.x),
59
+ y: scale.y(to.y)
60
+ };
61
+ var length = (0, _utils.getDistanceBetweenTwoPoints)(startPoint, endPoint);
62
+ return /*#__PURE__*/_react["default"].createElement("line", _extends({
51
63
  className: (0, _classnames["default"])(classes.line, disabled && classes.disabled, classes[correctness], className),
52
- x1: scale.x(from.x),
53
- y1: scale.y(from.y),
54
- x2: scale.x(to.x),
55
- y2: scale.y(to.y)
64
+ x1: startPoint.x,
65
+ y1: startPoint.y,
66
+ x2: endPoint.x,
67
+ y2: endPoint.y,
68
+ strokeDasharray: length - 7
56
69
  }, rest));
57
70
  };
58
71
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/tools/vector/component.jsx"],"names":["lineStyles","theme","line","styles","disabled","correct","incorrect","Line","props","className","classes","correctness","graphProps","from","to","rest","scale","x","y","propTypes","PropTypes","string","object","bool","any","types","PointType","StyledLine","Vector","Arrow","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAAAC,KAAK;AAAA,SAAK;AAC3BC,IAAAA,IAAI,EAAEC,aAAOD,IAAP,CAAYD,KAAZ,CADqB;AAE3BG,IAAAA,QAAQ,EAAED,aAAOC,QAAP,CAAgBH,KAAhB,CAFiB;AAG3BI,IAAAA,OAAO,EAAEF,aAAOE,OAAP,CAAeJ,KAAf,EAAsB,QAAtB,CAHkB;AAI3BK,IAAAA,SAAS,EAAEH,aAAOG,SAAP,CAAiBL,KAAjB,EAAwB,QAAxB;AAJgB,GAAL;AAAA,CAAxB;;AAOO,IAAMM,IAAI,GAAG,SAAPA,IAAO,CAAAC,KAAK,EAAI;AAAA,MACnBC,SADmB,GAC0DD,KAD1D,CACnBC,SADmB;AAAA,MACRC,OADQ,GAC0DF,KAD1D,CACRE,OADQ;AAAA,MACCN,QADD,GAC0DI,KAD1D,CACCJ,QADD;AAAA,MACWO,WADX,GAC0DH,KAD1D,CACWG,WADX;AAAA,MACwBC,UADxB,GAC0DJ,KAD1D,CACwBI,UADxB;AAAA,MACoCC,IADpC,GAC0DL,KAD1D,CACoCK,IADpC;AAAA,MAC0CC,EAD1C,GAC0DN,KAD1D,CAC0CM,EAD1C;AAAA,MACiDC,IADjD,4BAC0DP,KAD1D;;AAAA,MAEnBQ,KAFmB,GAETJ,UAFS,CAEnBI,KAFmB;AAG3B,SACE;AACE,IAAA,SAAS,EAAE,4BACTN,OAAO,CAACR,IADC,EAETE,QAAQ,IAAIM,OAAO,CAACN,QAFX,EAGTM,OAAO,CAACC,WAAD,CAHE,EAITF,SAJS,CADb;AAOE,IAAA,EAAE,EAAEO,KAAK,CAACC,CAAN,CAAQJ,IAAI,CAACI,CAAb,CAPN;AAQE,IAAA,EAAE,EAAED,KAAK,CAACE,CAAN,CAAQL,IAAI,CAACK,CAAb,CARN;AASE,IAAA,EAAE,EAAEF,KAAK,CAACC,CAAN,CAAQH,EAAE,CAACG,CAAX,CATN;AAUE,IAAA,EAAE,EAAED,KAAK,CAACE,CAAN,CAAQJ,EAAE,CAACI,CAAX;AAVN,KAWMH,IAXN,EADF;AAeD,CAlBM;;;AAoBPR,IAAI,CAACY,SAAL,GAAiB;AACfV,EAAAA,SAAS,EAAEW,sBAAUC,MADN;AAEfX,EAAAA,OAAO,EAAEU,sBAAUE,MAFJ;AAGflB,EAAAA,QAAQ,EAAEgB,sBAAUG,IAHL;AAIfZ,EAAAA,WAAW,EAAES,sBAAUC,MAJR;AAKfT,EAAAA,UAAU,EAAEQ,sBAAUI,GALP;AAMfX,EAAAA,IAAI,EAAEY,YAAMC,SANG;AAOfZ,EAAAA,EAAE,EAAEW,YAAMC;AAPK,CAAjB;AAUA,IAAMC,UAAU,GAAG,wBAAW3B,UAAX,EAAuBO,IAAvB,CAAnB;AACA,IAAMqB,MAAM,GAAG,oBAASD,UAAT,EAAqB;AAAEb,EAAAA,EAAE,EAAEe;AAAN,CAArB,CAAf;AACA,IAAMC,SAAS,GAAG,6BAAkBF,MAAlB,CAAlB;eAEeE,S","sourcesContent":["import { lineToolComponent, lineBase, styles } from '../shared/line';\nimport { Arrow } from '../shared/point';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst lineStyles = theme => ({\n line: styles.line(theme),\n disabled: styles.disabled(theme),\n correct: styles.correct(theme, 'stroke'),\n incorrect: styles.incorrect(theme, 'stroke')\n});\n\nexport const Line = props => {\n const { className, classes, disabled, correctness, graphProps, from, to, ...rest } = props;\n const { scale } = graphProps;\n return (\n <line\n className={classNames(\n classes.line,\n disabled && classes.disabled,\n classes[correctness],\n className\n )}\n x1={scale.x(from.x)}\n y1={scale.y(from.y)}\n x2={scale.x(to.x)}\n y2={scale.y(to.y)}\n {...rest}\n />\n );\n};\n\nLine.propTypes = {\n className: PropTypes.string,\n classes: PropTypes.object,\n disabled: PropTypes.bool,\n correctness: PropTypes.string,\n graphProps: PropTypes.any,\n from: types.PointType,\n to: types.PointType\n};\n\nconst StyledLine = withStyles(lineStyles)(Line);\nconst Vector = lineBase(StyledLine, { to: Arrow });\nconst Component = lineToolComponent(Vector);\n\nexport default Component;\n"],"file":"component.js"}
1
+ {"version":3,"sources":["../../../src/tools/vector/component.jsx"],"names":["lineStyles","theme","line","styles","disabled","correct","incorrect","Line","props","className","classes","correctness","scale","graphProps","from","to","rest","startPoint","x","y","endPoint","length","propTypes","PropTypes","string","object","bool","any","types","PointType","StyledLine","Vector","Arrow","Component"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA,IAAMA,UAAU,GAAG,SAAbA,UAAa,CAAAC,KAAK;AAAA,SAAK;AAC3BC,IAAAA,IAAI,EAAEC,aAAOD,IAAP,CAAYD,KAAZ,CADqB;AAE3BG,IAAAA,QAAQ,EAAED,aAAOC,QAAP,CAAgBH,KAAhB,CAFiB;AAG3BI,IAAAA,OAAO,EAAEF,aAAOE,OAAP,CAAeJ,KAAf,EAAsB,QAAtB,CAHkB;AAI3BK,IAAAA,SAAS,EAAEH,aAAOG,SAAP,CAAiBL,KAAjB,EAAwB,QAAxB;AAJgB,GAAL;AAAA,CAAxB;;AAOO,IAAMM,IAAI,GAAG,SAAPA,IAAO,CAA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AL,GAAiB;AACfb,EAAAA,SAAS,EAAEc,sBAAUC,MADN;AAEfd,EAAAA,OAAO,EAAEa,sBAAUE,MAFJ;AAGfrB,EAAAA,QAAQ,EAAEmB,sBAAUG,IAHL;AAIff,EAAAA,WAAW,EAAEY,sBAAUC,MAJR;AAKfX,EAAAA,UAAU,EAAEU,sBAAUI,GALP;AAMfb,EAAAA,IAAI,EAAEc,YAAMC,SANG;AAOfd,EAAAA,EAAE,EAAEa,YAAMC;AAPK,CAAjB;AAUA,IAAMC,UAAU,GAAG,wBAAW9B,UAAX,EAAuBO,IAAvB,CAAnB;AACA,IAAMwB,MAAM,GAAG,oBAASD,UAAT,EAAqB;AAAEf,EAAAA,EAAE,EAAEiB;AAAN,CAArB,CAAf;AACA,IAAMC,SAAS,GAAG,6BAAkBF,MAAlB,CAAlB;eAEeE,S","sourcesContent":["import { lineToolComponent, lineBase, styles } from '../shared/line';\nimport { Arrow } from '../shared/point';\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport { types } from '@pie-lib/plot';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport { getDistanceBetweenTwoPoints } from '../../utils';\n\nconst lineStyles = theme => ({\n line: styles.line(theme),\n disabled: styles.disabled(theme),\n correct: styles.correct(theme, 'stroke'),\n incorrect: styles.incorrect(theme, 'stroke')\n});\n\nexport const Line = props => {\n const {\n className,\n classes,\n disabled,\n correctness,\n graphProps: { scale },\n from,\n to,\n ...rest\n } = props;\n const startPoint = { x: scale.x(from.x), y: scale.y(from.y) };\n const endPoint = { x: scale.x(to.x), y: scale.y(to.y) };\n const length = getDistanceBetweenTwoPoints(startPoint, endPoint);\n\n return (\n <line\n className={classNames(\n classes.line,\n disabled && classes.disabled,\n classes[correctness],\n className\n )}\n x1={startPoint.x}\n y1={startPoint.y}\n x2={endPoint.x}\n y2={endPoint.y}\n strokeDasharray={length - 7}\n {...rest}\n />\n );\n};\n\nLine.propTypes = {\n className: PropTypes.string,\n classes: PropTypes.object,\n disabled: PropTypes.bool,\n correctness: PropTypes.string,\n graphProps: PropTypes.any,\n from: types.PointType,\n to: types.PointType\n};\n\nconst StyledLine = withStyles(lineStyles)(Line);\nconst Vector = lineBase(StyledLine, { to: Arrow });\nconst Component = lineToolComponent(Vector);\n\nexport default Component;\n"],"file":"component.js"}
package/lib/undo-redo.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -19,35 +21,37 @@ var _renderUi = require("@pie-lib/render-ui");
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
23
 
22
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
23
-
24
24
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
25
 
26
26
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
27
27
 
28
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
28
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
29
 
30
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
30
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
31
31
 
32
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
33
 
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
34
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
35
 
36
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
36
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
37
37
 
38
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
38
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
+
40
+ 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; } }
41
+
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
43
 
40
44
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
41
45
 
42
- var UndoRedo =
43
- /*#__PURE__*/
44
- function (_React$Component) {
46
+ var UndoRedo = /*#__PURE__*/function (_React$Component) {
45
47
  _inherits(UndoRedo, _React$Component);
46
48
 
49
+ var _super = _createSuper(UndoRedo);
50
+
47
51
  function UndoRedo() {
48
52
  _classCallCheck(this, UndoRedo);
49
53
 
50
- return _possibleConstructorReturn(this, _getPrototypeOf(UndoRedo).apply(this, arguments));
54
+ return _super.apply(this, arguments);
51
55
  }
52
56
 
53
57
  _createClass(UndoRedo, [{
@@ -59,19 +63,19 @@ function (_React$Component) {
59
63
  onUndo = _this$props.onUndo,
60
64
  onRedo = _this$props.onRedo,
61
65
  onReset = _this$props.onReset;
62
- return _react["default"].createElement("div", {
66
+ return /*#__PURE__*/_react["default"].createElement("div", {
63
67
  className: (0, _classnames["default"])(className)
64
- }, _react["default"].createElement(_Button["default"], {
68
+ }, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
65
69
  classes: {
66
70
  root: classes.button
67
71
  },
68
72
  onClick: onUndo
69
- }, "Undo"), _react["default"].createElement(_Button["default"], {
73
+ }, "Undo"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
70
74
  classes: {
71
75
  root: classes.button
72
76
  },
73
77
  onClick: onRedo
74
- }, "Redo"), _react["default"].createElement(_Button["default"], {
78
+ }, "Redo"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
75
79
  classes: {
76
80
  root: classes.button
77
81
  },
@@ -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","marginBottom","primary"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;IAEaA,Q;;;;;;;;;;;;;6BASF;AAAA,wBACiD,KAAKC,KADtD;AAAA,UACCC,OADD,eACCA,OADD;AAAA,UACUC,SADV,eACUA,SADV;AAAA,UACqBC,MADrB,eACqBA,MADrB;AAAA,UAC6BC,MAD7B,eAC6BA,MAD7B;AAAA,UACqCC,OADrC,eACqCA,OADrC;AAEP,aACE;AAAK,QAAA,SAAS,EAAE,4BAAWH,SAAX;AAAhB,SACE,gCAAC,kBAAD;AAAQ,QAAA,OAAO,EAAE;AAAEI,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAAhB,SAAjB;AAA2C,QAAA,OAAO,EAAEJ;AAApD,gBADF,EAIE,gCAAC,kBAAD;AAAQ,QAAA,OAAO,EAAE;AAAEG,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAAhB,SAAjB;AAA2C,QAAA,OAAO,EAAEH;AAApD,gBAJF,EAOE,gCAAC,kBAAD;AAAQ,QAAA,OAAO,EAAE;AAAEE,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAAhB,SAAjB;AAA2C,QAAA,OAAO,EAAEF;AAApD,iBAPF,CADF;AAaD;;;;EAxB2BG,kBAAMC,S;;;;gBAAvBV,Q,eACQ;AACjBE,EAAAA,OAAO,EAAES,sBAAUC,MADF;AAEjBT,EAAAA,SAAS,EAAEQ,sBAAUE,MAFJ;AAGjBT,EAAAA,MAAM,EAAEO,sBAAUG,IAAV,CAAeC,UAHN;AAIjBV,EAAAA,MAAM,EAAEM,sBAAUG,IAAV,CAAeC,UAJN;AAKjBT,EAAAA,OAAO,EAAEK,sBAAUG,IAAV,CAAeC;AALP,C;;gBADRf,Q,kBAQW,E;;AAmBxB,IAAMgB,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBT,IAAAA,MAAM,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","marginRight","spacing","unit","marginBottom","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,EAAEJ;AAApD,gBADF,eAIE,gCAAC,kBAAD;AAAQ,QAAA,OAAO,EAAE;AAAEG,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAAhB,SAAjB;AAA2C,QAAA,OAAO,EAAEH;AAApD,gBAJF,eAOE,gCAAC,kBAAD;AAAQ,QAAA,OAAO,EAAE;AAAEE,UAAAA,IAAI,EAAEL,OAAO,CAACM;AAAhB,SAAjB;AAA2C,QAAA,OAAO,EAAEF;AAApD,iBAPF,CADF;AAaD;;;;EAxB2BG,kBAAMC,S;;;;gBAAvBV,Q,eACQ;AACjBE,EAAAA,OAAO,EAAES,sBAAUC,MADF;AAEjBT,EAAAA,SAAS,EAAEQ,sBAAUE,MAFJ;AAGjBT,EAAAA,MAAM,EAAEO,sBAAUG,IAAV,CAAeC,UAHN;AAIjBV,EAAAA,MAAM,EAAEM,sBAAUG,IAAV,CAAeC,UAJN;AAKjBT,EAAAA,OAAO,EAAEK,sBAAUG,IAAV,CAAeC;AALP,C;;gBADRf,Q,kBAQW,E;;AAmBxB,IAAMgB,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBT,IAAAA,MAAM,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"}
@@ -7,11 +7,15 @@ exports.useDebounce = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
11
 
12
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
12
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
13
13
 
14
- function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
14
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
15
+
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
17
+
18
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
15
19
 
16
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
21
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-debounce.js"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","handler","setTimeout","clearTimeout"],"mappings":";;;;;;;AAAA;;;;;;;;;;AAEO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD,EAAQC,KAAR,EAAkB;AAAA,kBACC,qBAASD,KAAT,CADD;AAAA;AAAA,MACpCE,cADoC;AAAA,MACpBC,iBADoB;;AAG3C,wBAAU,YAAM;AACd,QAAMC,OAAO,GAAGC,UAAU,CAAC,YAAM;AAC/BF,MAAAA,iBAAiB,CAACH,KAAD,CAAjB;AACD,KAFyB,EAEvBC,KAFuB,CAA1B;AAGA,WAAO;AAAA,aAAMK,YAAY,CAACF,OAAD,CAAlB;AAAA,KAAP;AACD,GALD,EAKG,CAACJ,KAAD,CALH;AAMA,SAAOE,cAAP;AACD,CAVM","sourcesContent":["import { useState, useEffect } from 'react';\n\nexport const useDebounce = (value, delay) => {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n return () => clearTimeout(handler);\n }, [value]);\n return debouncedValue;\n};\n"],"file":"use-debounce.js"}
1
+ {"version":3,"sources":["../src/use-debounce.js"],"names":["useDebounce","value","delay","debouncedValue","setDebouncedValue","handler","setTimeout","clearTimeout"],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;AAEO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,KAAD,EAAQC,KAAR,EAAkB;AAC3C,kBAA4C,qBAASD,KAAT,CAA5C;AAAA;AAAA,MAAOE,cAAP;AAAA,MAAuBC,iBAAvB;;AAEA,wBAAU,YAAM;AACd,QAAMC,OAAO,GAAGC,UAAU,CAAC,YAAM;AAC/BF,MAAAA,iBAAiB,CAACH,KAAD,CAAjB;AACD,KAFyB,EAEvBC,KAFuB,CAA1B;AAGA,WAAO;AAAA,aAAMK,YAAY,CAACF,OAAD,CAAlB;AAAA,KAAP;AACD,GALD,EAKG,CAACJ,KAAD,CALH;AAMA,SAAOE,cAAP;AACD,CAVM","sourcesContent":["import { useState, useEffect } from 'react';\n\nexport const useDebounce = (value, delay) => {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n return () => clearTimeout(handler);\n }, [value]);\n return debouncedValue;\n};\n"],"file":"use-debounce.js"}
package/lib/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getAdjustedGraphLimits = exports.thinnerShapesNeeded = exports.equalPoints = exports.sameAxes = exports.roundNumber = exports.getMiddleOfTwoPoints = exports.getRightestPoints = exports.isDomainRangeEqual = exports.pointsToArea = exports.lineToArea = exports.polygonToArea = exports.amountToIncreaseWidth = exports.findLongestWord = exports.countWords = exports.getTickValues = exports.arrowDimensions = exports.getAngleDeg = exports.point = exports.bounds = exports.tickCount = void 0;
6
+ exports.tickCount = exports.thinnerShapesNeeded = exports.sameAxes = exports.roundNumber = exports.polygonToArea = exports.pointsToArea = exports.point = exports.lineToArea = exports.isDuplicatedMark = exports.isDomainRangeEqual = exports.getTickValues = exports.getRightestPoints = exports.getMiddleOfTwoPoints = exports.getDistanceBetweenTwoPoints = exports.getAngleDeg = exports.getAdjustedGraphLimits = exports.findLongestWord = exports.equalPoints = exports.countWords = exports.bounds = exports.arrowDimensions = exports.amountToIncreaseWidth = void 0;
7
7
 
8
8
  var _head = _interopRequireDefault(require("lodash/head"));
9
9
 
@@ -48,14 +48,14 @@ var getTickValues = function getTickValues(prop) {
48
48
 
49
49
  while (tickVal >= prop.min && tickValues.indexOf(tickVal) < 0) {
50
50
  tickValues.push(tickVal);
51
- tickVal = Math.round((tickVal - prop.step) * 1000) / 1000;
51
+ tickVal = Math.round((tickVal - prop.step) * 10000) / 10000;
52
52
  }
53
53
 
54
- tickVal = Math.round(prop.step * 1000) / 1000;
54
+ tickVal = Math.round(prop.step * 10000) / 10000;
55
55
 
56
56
  while (tickVal <= prop.max && tickValues.indexOf(tickVal) < 0) {
57
57
  tickValues.push(tickVal);
58
- tickVal = Math.round((tickVal + prop.step) * 1000) / 1000;
58
+ tickVal = Math.round((tickVal + prop.step) * 10000) / 10000;
59
59
  } // return only ticks that are inside the min-max interval
60
60
 
61
61
 
@@ -172,7 +172,7 @@ var getMiddleOfTwoPoints = function getMiddleOfTwoPoints(a, b) {
172
172
  exports.getMiddleOfTwoPoints = getMiddleOfTwoPoints;
173
173
 
174
174
  var roundNumber = function roundNumber(number) {
175
- return parseFloat(number.toFixed(3));
175
+ return parseFloat(number.toFixed(4));
176
176
  };
177
177
 
178
178
  exports.roundNumber = roundNumber;
@@ -239,4 +239,69 @@ var getAdjustedGraphLimits = function getAdjustedGraphLimits(graphProps) {
239
239
  };
240
240
 
241
241
  exports.getAdjustedGraphLimits = getAdjustedGraphLimits;
242
+
243
+ var getDistanceBetweenTwoPoints = function getDistanceBetweenTwoPoints(a, b) {
244
+ return Math.sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));
245
+ };
246
+
247
+ exports.getDistanceBetweenTwoPoints = getDistanceBetweenTwoPoints;
248
+
249
+ var sortPoints = function sortPoints(array) {
250
+ return (array || []).sort(function (a, b) {
251
+ return a.x - b.x || a.y - b.y;
252
+ });
253
+ }; // check colliniarity of 3 points (source: https://www.geeksforgeeks.org/program-check-three-points-collinear/)
254
+
255
+
256
+ var checkCollinearity = function checkCollinearity(a, b, c) {
257
+ return (a.x - b.x) * (c.y - b.y) === (c.x - b.x) * (a.y - b.y);
258
+ }; // 2 lines are overlapping if all 4 points are collinear
259
+
260
+
261
+ var isSameLine = function isSameLine(markA, markB) {
262
+ return checkCollinearity(markA.from, markB.from, markB.to) && checkCollinearity(markA.to, markB.from, markB.to);
263
+ };
264
+
265
+ var isSameCircle = function isSameCircle(markA, markB) {
266
+ return equalPoints(markA.root, markB.root) && getDistanceBetweenTwoPoints(markB.root, markB.edge) === getDistanceBetweenTwoPoints(markA.root, markA.edge);
267
+ };
268
+
269
+ var isDuplicatedMark = function isDuplicatedMark(mark, marks, oldMark) {
270
+ var type = mark.type,
271
+ building = mark.building;
272
+
273
+ if (building) {
274
+ return false;
275
+ }
276
+
277
+ var filteredMarks = (marks || []).filter(function (m) {
278
+ return m.type === type && !m.building;
279
+ });
280
+ var index = filteredMarks.findIndex(function (m) {
281
+ return (0, _isEqual["default"])(m, oldMark);
282
+ });
283
+
284
+ if (index !== -1) {
285
+ filteredMarks.splice(index, 1);
286
+ }
287
+
288
+ var duplicated = filteredMarks.find(function (m) {
289
+ if (type === 'circle' || type === 'parabola' || type === 'sine') {
290
+ var root = mark.root,
291
+ edge = mark.edge;
292
+ return equalPoints(root, m.root) && equalPoints(edge, m.edge) || type === 'circle' && isSameCircle(m, mark);
293
+ } else if (type === 'line' || type === 'ray' || type === 'segment' || type === 'vector') {
294
+ var from = mark.from,
295
+ to = mark.to;
296
+ return equalPoints(from, m.from) && equalPoints(to, m.to) || equalPoints(from, m.to) && equalPoints(to, m.from) || type === 'line' && isSameLine(m, mark);
297
+ } else if (type === 'polygon') {
298
+ return (0, _isEqual["default"])(sortPoints((0, _cloneDeep["default"])(mark.points)), sortPoints((0, _cloneDeep["default"])(m.points)));
299
+ } else if (type === 'point') {
300
+ return equalPoints(m, mark);
301
+ }
302
+ });
303
+ return !!duplicated;
304
+ };
305
+
306
+ exports.isDuplicatedMark = isDuplicatedMark;
242
307
  //# sourceMappingURL=utils.js.map
package/lib/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.js"],"names":["tickCount","utils","bounds","point","getAngleDeg","arrowDimensions","getTickValues","prop","tickValues","tickVal","min","indexOf","push","Math","round","step","max","filter","tV","countWords","label","words","split","length","findLongestWord","longestWord","replace","sort","a","b","amountToIncreaseWidth","polygonToArea","points","h","area","left","x","top","y","bottom","right","reduce","p","lineToArea","from","to","pointsToArea","isDomainRangeEqual","graphProps","nextGraphProps","domain","range","getRightestPoints","sortedPoints","getMiddleOfTwoPoints","roundNumber","number","parseFloat","toFixed","sameAxes","p1","p2","equalPoints","getDistanceBetweenTicks","axis","size","nbOfTicks","thinnerShapesNeeded","width","height","getAdjustedGraphLimits","domainTicksDistance","rangeTicksDistance","domainPadding","rangePadding"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,SAAS,GAAGC,YAAMD,SAAxB;;AACA,IAAME,MAAM,GAAGD,YAAMC,MAArB;;AACA,IAAMC,KAAK,GAAGF,YAAME,KAApB,C,CAEP;;;;AACO,IAAMC,WAAW,GAAG,SAAdA,WAAc;AAAA,SAAM,CAAN;AAAA,CAApB,C,CACP;;;;;AACO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB;AAAA,SAAM,CAAN;AAAA,CAAxB;;;;AAEA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,IAAI,EAAI;AACnC,MAAMC,UAAU,GAAG,EAAnB;AACA,MAAIC,OAAO,GAAG,CAAd;;AAEA,SAAOA,OAAO,IAAIF,IAAI,CAACG,GAAhB,IAAuBF,UAAU,CAACG,OAAX,CAAmBF,OAAnB,IAA8B,CAA5D,EAA+D;AAC7DD,IAAAA,UAAU,CAACI,IAAX,CAAgBH,OAAhB;AACAA,IAAAA,OAAO,GAAGI,IAAI,CAACC,KAAL,CAAW,CA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D;AACA,MAAMI,kBAAkB,GAAGT,uBAAuB,CAACZ,KAAD,EAAQkB,MAAR,CAAlD,CAPkD,CASlD;;AACA,MAAMI,aAAa,GAAGvB,MAAM,CAACnC,IAAP,IAAewD,mBAAmB,GAAG,EAArC,CAAtB;AACA,MAAMG,YAAY,GAAGvB,KAAK,CAACpC,IAAN,IAAcyD,kBAAkB,GAAG,EAAnC,CAArB;AAEA,SAAO;AACLtB,IAAAA,MAAM,EAAE;AACNxC,MAAAA,GAAG,EAAEwC,MAAM,CAACxC,GAAP,GAAa+D,aADZ;AAENzD,MAAAA,GAAG,EAAEkC,MAAM,CAAClC,GAAP,GAAayD;AAFZ,KADH;AAKLtB,IAAAA,KAAK,EAAE;AACLzC,MAAAA,GAAG,EAAEyC,KAAK,CAACzC,GAAN,GAAYgE,YADZ;AAEL1D,MAAAA,GAAG,EAAEmC,KAAK,CAACnC,GAAN,GAAY0D;AAFZ;AALF,GAAP;AAUD,CAvBM","sourcesContent":["import head from 'lodash/head';\nimport tail from 'lodash/tail';\nimport { utils } from '@pie-lib/plot';\nimport invariant from 'invariant';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport cloneDeep from 'lodash/cloneDeep';\n\nexport const tickCount = utils.tickCount;\nexport const bounds = utils.bounds;\nexport const point = utils.point;\n\n//TODO: This can be removed?\nexport const getAngleDeg = () => 0;\n//TODO: This can be removed?\nexport const arrowDimensions = () => 0;\n\nexport const getTickValues = prop => {\n const tickValues = [];\n let tickVal = 0;\n\n while (tickVal >= prop.min && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal - prop.step) * 1000) / 1000;\n }\n\n tickVal = Math.round(prop.step * 1000) / 1000;\n\n while (tickVal <= prop.max && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal + prop.step) * 1000) / 1000;\n }\n\n // return only ticks that are inside the min-max interval\n if (tickValues) {\n return tickValues.filter(tV => tV >= prop.min && tV <= prop.max);\n }\n\n return [];\n};\n\nexport const countWords = label => {\n if (label == null || isEmpty(label)) {\n return 1;\n }\n\n const words = label.split(' ');\n return words.length;\n};\n\n// findLongestWord is also used in plot\nexport const findLongestWord = label => {\n let longestWord = (label || '')\n .replace(/<[^>]+>/g, '')\n .split(' ')\n .sort((a, b) => b.length - a.length);\n\n return longestWord[0].length;\n};\n\n// amountToIncreaseWidth is also used in plot\nexport const amountToIncreaseWidth = longestWord => {\n if (!longestWord) {\n return 0;\n }\n\n return longestWord * 10;\n};\n\nexport const polygonToArea = points => {\n const h = head(points);\n const area = {\n left: h.x,\n top: h.y,\n bottom: h.y,\n right: h.x\n };\n return tail(points).reduce((a, p) => {\n a.left = Math.min(a.left, p.x);\n a.top = Math.max(a.top, p.y);\n a.bottom = Math.min(a.bottom, p.y);\n a.right = Math.max(a.right, p.x);\n return a;\n }, area);\n};\n\nexport const lineToArea = (from, to) => pointsToArea(from, to);\n\nexport const pointsToArea = (a, b) => {\n invariant(!!a && !!b, 'a or b is undefined');\n const left = Math.min(a.x, b.x);\n const top = Math.max(a.y, b.y);\n const bottom = Math.min(a.y, b.y);\n const right = Math.max(a.x, b.x);\n return { left, top, bottom, right };\n};\n\nexport const isDomainRangeEqual = (graphProps, nextGraphProps) => {\n return (\n isEqual(graphProps.domain, nextGraphProps.domain) &&\n isEqual(graphProps.range, nextGraphProps.range)\n );\n};\n\nexport const getRightestPoints = points => {\n const sortedPoints = cloneDeep(points);\n sortedPoints.sort((a, b) => b.x - a.x);\n\n return { a: sortedPoints[0], b: sortedPoints[1] };\n};\n\nexport const getMiddleOfTwoPoints = (a, b) => ({\n x: (a.x + b.x) / 2,\n y: (a.y + b.y) / 2\n});\n\nexport const roundNumber = number => parseFloat(number.toFixed(3));\n\nexport const sameAxes = (p1, p2) =>\n p1 && p2 && (roundNumber(p1.x) === roundNumber(p2.x) || roundNumber(p1.y) === roundNumber(p2.y));\n\nexport const equalPoints = (p1, p2) =>\n p1 &&\n p2 &&\n isEqual(\n {\n x: roundNumber(p1.x),\n y: roundNumber(p1.y)\n },\n {\n x: roundNumber(p2.x),\n y: roundNumber(p2.y)\n }\n );\n\nconst getDistanceBetweenTicks = (axis, size) => {\n const { min, max, step } = axis;\n const nbOfTicks = (max - min) / step;\n\n return size / nbOfTicks;\n};\n\nexport const thinnerShapesNeeded = graphProps => {\n const {\n domain,\n range,\n size: { width, height }\n } = graphProps;\n\n // 14 is the default width of a point\n return getDistanceBetweenTicks(domain, width) < 14 || getDistanceBetweenTicks(range, height) < 14;\n};\n\nexport const getAdjustedGraphLimits = graphProps => {\n const {\n domain,\n range,\n size: { width, height }\n } = graphProps;\n const domainTicksDistance = getDistanceBetweenTicks(domain, width);\n const rangeTicksDistance = getDistanceBetweenTicks(range, height);\n\n // 15 is the distance required for the arrow to extend the graph\n const domainPadding = domain.step / (domainTicksDistance / 15);\n const rangePadding = range.step / (rangeTicksDistance / 15);\n\n return {\n domain: {\n min: domain.min - domainPadding,\n max: domain.max + domainPadding\n },\n range: {\n min: range.min - rangePadding,\n max: range.max + rangePadding\n }\n };\n};\n"],"file":"utils.js"}
1
+ {"version":3,"sources":["../src/utils.js"],"names":["tickCount","utils","bounds","point","getAngleDeg","arrowDimensions","getTickValues","prop","tickValues","tickVal","min","indexOf","push","Math","round","step","max","filter","tV","countWords","label","words","split","length","findLongestWord","longestWord","replace","sort","a","b","amountToIncreaseWidth","polygonToArea","points","h","area","left","x","top","y","bottom","right","reduce","p","lineToArea","from","to","pointsToArea","isDomainRangeEqual","graphProps","nextGraphProps","domain","range","getRightestPoints","sortedPoints","getMiddleOfTwoPoints","roundNumber","number","parseFloat","toFixed","sameAxes","p1","p2","equalPoints","getDistanceBetweenTicks","axis","size","nbOfTicks","thinnerShapesNeeded","width","height","getAdjustedGraphLimits","domainTicksDistance","rangeTicksDistance","domainPadding","rangePadding","getDistanceBetweenTwoPoints","sqrt","sortPoints","array","checkCollinearity","c","isSameLine","markA","markB","isSameCircle","root","edge","isDuplicatedMark","mark","marks","oldMark","type","building","filteredMarks","m","index","findIndex","splice","duplicated","find"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,SAAS,GAAGC,YAAMD,SAAxB;;AACA,IAAME,MAAM,GAAGD,YAAMC,MAArB;;AACA,IAAMC,KAAK,GAAGF,YAAME,KAApB,C,CAEP;;;;AACO,IAAMC,WAAW,GAAG,SAAdA,WAAc;AAAA,SAAM,CAAN;AAAA,CAApB,C,CACP;;;;;AACO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB;AAAA,SAAM,CAAN;AAAA,CAAxB;;;;AAEA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAAAC,IAAI,EAAI;AACnC,MAAMC,UAAU,GAAG,EAAnB;AACA,MAAIC,OAAO,GAAG,CAAd;;AAEA,SAAOA,OAAO,IAAIF,IAAI,CAACG,GAAhB,IAAuBF,UAAU,CAACG,OAAX,CAAmBF,OAAnB,IAA8B,CAA5D,EAA+D;AAC7DD,IAAAA,UAAU,CAACI,IAAX,CAAgBH,OAAhB;AACAA,IAAAA,OAAO,GAAGI,IAAI,CAACC,KAAL,CAAW,CAACL,OAAO,GAAGF,IAAI,CAACQ,IAAhB,IAAwB,KAAnC,IAA4C,KAAtD;AACD;;AAEDN,EAAAA,OAAO,GAAGI,IAAI,CAACC,KAAL,CAAWP,IAAI,CAACQ,IAAL,GAAY,KAAvB,IAAgC,KAA1C;;AAEA,SAAON,OAAO,IAAIF,IAAI,CAACS,GAAhB,IAAuBR,UAAU,CAACG,OAAX,CAAmBF,OAAnB,IAA8B,CAA5D,EAA+D;AAC7DD,IAAAA,UAAU,CAACI,IAAX,CAAgBH,OAAhB;AACAA,IAAAA,OAAO,GAAGI,IAAI,CAACC,KAAL,CAAW,CAACL,OAAO,GAAGF,IAAI,CAACQ,IAAhB,IAAwB,KAAnC,IAA4C,KAAtD;AACD,GAdkC,CAgBnC;;;AACA,MAAIP,U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AAO,CAAC,CAACU,UAAT;AACD,CAtCM","sourcesContent":["import head from 'lodash/head';\nimport tail from 'lodash/tail';\nimport { utils } from '@pie-lib/plot';\nimport invariant from 'invariant';\nimport isEqual from 'lodash/isEqual';\nimport isEmpty from 'lodash/isEmpty';\nimport cloneDeep from 'lodash/cloneDeep';\n\nexport const tickCount = utils.tickCount;\nexport const bounds = utils.bounds;\nexport const point = utils.point;\n\n//TODO: This can be removed?\nexport const getAngleDeg = () => 0;\n//TODO: This can be removed?\nexport const arrowDimensions = () => 0;\n\nexport const getTickValues = prop => {\n const tickValues = [];\n let tickVal = 0;\n\n while (tickVal >= prop.min && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal - prop.step) * 10000) / 10000;\n }\n\n tickVal = Math.round(prop.step * 10000) / 10000;\n\n while (tickVal <= prop.max && tickValues.indexOf(tickVal) < 0) {\n tickValues.push(tickVal);\n tickVal = Math.round((tickVal + prop.step) * 10000) / 10000;\n }\n\n // return only ticks that are inside the min-max interval\n if (tickValues) {\n return tickValues.filter(tV => tV >= prop.min && tV <= prop.max);\n }\n\n return [];\n};\n\nexport const countWords = label => {\n if (label == null || isEmpty(label)) {\n return 1;\n }\n\n const words = label.split(' ');\n return words.length;\n};\n\n// findLongestWord is also used in plot\nexport const findLongestWord = label => {\n let longestWord = (label || '')\n .replace(/<[^>]+>/g, '')\n .split(' ')\n .sort((a, b) => b.length - a.length);\n\n return longestWord[0].length;\n};\n\n// amountToIncreaseWidth is also used in plot\nexport const amountToIncreaseWidth = longestWord => {\n if (!longestWord) {\n return 0;\n }\n\n return longestWord * 10;\n};\n\nexport const polygonToArea = points => {\n const h = head(points);\n const area = {\n left: h.x,\n top: h.y,\n bottom: h.y,\n right: h.x\n };\n return tail(points).reduce((a, p) => {\n a.left = Math.min(a.left, p.x);\n a.top = Math.max(a.top, p.y);\n a.bottom = Math.min(a.bottom, p.y);\n a.right = Math.max(a.right, p.x);\n return a;\n }, area);\n};\n\nexport const lineToArea = (from, to) => pointsToArea(from, to);\n\nexport const pointsToArea = (a, b) => {\n invariant(!!a && !!b, 'a or b is undefined');\n const left = Math.min(a.x, b.x);\n const top = Math.max(a.y, b.y);\n const bottom = Math.min(a.y, b.y);\n const right = Math.max(a.x, b.x);\n return { left, top, bottom, right };\n};\n\nexport const isDomainRangeEqual = (graphProps, nextGraphProps) => {\n return (\n isEqual(graphProps.domain, nextGraphProps.domain) &&\n isEqual(graphProps.range, nextGraphProps.range)\n );\n};\n\nexport const getRightestPoints = points => {\n const sortedPoints = cloneDeep(points);\n sortedPoints.sort((a, b) => b.x - a.x);\n\n return { a: sortedPoints[0], b: sortedPoints[1] };\n};\n\nexport const getMiddleOfTwoPoints = (a, b) => ({\n x: (a.x + b.x) / 2,\n y: (a.y + b.y) / 2\n});\n\nexport const roundNumber = number => parseFloat(number.toFixed(4));\n\nexport const sameAxes = (p1, p2) =>\n p1 && p2 && (roundNumber(p1.x) === roundNumber(p2.x) || roundNumber(p1.y) === roundNumber(p2.y));\n\nexport const equalPoints = (p1, p2) =>\n p1 &&\n p2 &&\n isEqual(\n {\n x: roundNumber(p1.x),\n y: roundNumber(p1.y)\n },\n {\n x: roundNumber(p2.x),\n y: roundNumber(p2.y)\n }\n );\n\nconst getDistanceBetweenTicks = (axis, size) => {\n const { min, max, step } = axis;\n const nbOfTicks = (max - min) / step;\n\n return size / nbOfTicks;\n};\n\nexport const thinnerShapesNeeded = graphProps => {\n const {\n domain,\n range,\n size: { width, height }\n } = graphProps;\n\n // 14 is the default width of a point\n return getDistanceBetweenTicks(domain, width) < 14 || getDistanceBetweenTicks(range, height) < 14;\n};\n\nexport const getAdjustedGraphLimits = graphProps => {\n const {\n domain,\n range,\n size: { width, height }\n } = graphProps;\n const domainTicksDistance = getDistanceBetweenTicks(domain, width);\n const rangeTicksDistance = getDistanceBetweenTicks(range, height);\n\n // 15 is the distance required for the arrow to extend the graph\n const domainPadding = domain.step / (domainTicksDistance / 15);\n const rangePadding = range.step / (rangeTicksDistance / 15);\n\n return {\n domain: {\n min: domain.min - domainPadding,\n max: domain.max + domainPadding\n },\n range: {\n min: range.min - rangePadding,\n max: range.max + rangePadding\n }\n };\n};\n\nexport const getDistanceBetweenTwoPoints = (a, b) =>\n Math.sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));\n\nconst sortPoints = array => (array || []).sort((a, b) => a.x - b.x || a.y - b.y);\n\n// check colliniarity of 3 points (source: https://www.geeksforgeeks.org/program-check-three-points-collinear/)\nconst checkCollinearity = (a, b, c) => (a.x - b.x) * (c.y - b.y) === (c.x - b.x) * (a.y - b.y);\n\n// 2 lines are overlapping if all 4 points are collinear\nconst isSameLine = (markA, markB) =>\n checkCollinearity(markA.from, markB.from, markB.to) &&\n checkCollinearity(markA.to, markB.from, markB.to);\n\nconst isSameCircle = (markA, markB) =>\n equalPoints(markA.root, markB.root) &&\n getDistanceBetweenTwoPoints(markB.root, markB.edge) ===\n getDistanceBetweenTwoPoints(markA.root, markA.edge);\n\nexport const isDuplicatedMark = (mark, marks, oldMark) => {\n const { type, building } = mark;\n\n if (building) {\n return false;\n }\n\n const filteredMarks = (marks || []).filter(m => m.type === type && !m.building);\n const index = filteredMarks.findIndex(m => isEqual(m, oldMark));\n\n if (index !== -1) {\n filteredMarks.splice(index, 1);\n }\n\n const duplicated = filteredMarks.find(m => {\n if (type === 'circle' || type === 'parabola' || type === 'sine') {\n const { root, edge } = mark;\n\n return (\n (equalPoints(root, m.root) && equalPoints(edge, m.edge)) ||\n (type === 'circle' && isSameCircle(m, mark))\n );\n } else if (type === 'line' || type === 'ray' || type === 'segment' || type === 'vector') {\n const { from, to } = mark;\n\n return (\n (equalPoints(from, m.from) && equalPoints(to, m.to)) ||\n (equalPoints(from, m.to) && equalPoints(to, m.from)) ||\n (type === 'line' && isSameLine(m, mark))\n );\n } else if (type === 'polygon') {\n return isEqual(sortPoints(cloneDeep(mark.points)), sortPoints(cloneDeep(m.points)));\n } else if (type === 'point') {\n return equalPoints(m, mark);\n }\n });\n\n return !!duplicated;\n};\n"],"file":"utils.js"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "2.4.9",
6
+ "version": "2.4.12",
7
7
  "description": "Graphing components",
8
8
  "keywords": [
9
9
  "react",
@@ -19,8 +19,8 @@
19
19
  "@mapbox/point-geometry": "^0.1.0",
20
20
  "@material-ui/core": "^3.8.3",
21
21
  "@pie-lib/graphing-utils": "^1.1.20",
22
- "@pie-lib/plot": "^2.1.9",
23
- "@pie-lib/render-ui": "^4.12.4",
22
+ "@pie-lib/plot": "^2.1.10",
23
+ "@pie-lib/render-ui": "^4.12.5",
24
24
  "@vx/axis": "^0.0.189",
25
25
  "@vx/clip-path": "^0.0.189",
26
26
  "@vx/event": "^0.0.189",
@@ -43,6 +43,6 @@
43
43
  "peerDependencies": {
44
44
  "react": "^16.8.1"
45
45
  },
46
- "gitHead": "8c254f4c516c9f4e67109accdb2ad415e1f6cea4",
46
+ "gitHead": "25a1b5ac55285b4c0e9458f5c120aedf7b935b98",
47
47
  "scripts": {}
48
48
  }
package/src/axis/axes.jsx CHANGED
@@ -200,7 +200,7 @@ export class RawYAxis extends React.Component {
200
200
  return {
201
201
  ...tickLabelStyles,
202
202
  dy: 4,
203
- dx: -8 - digits * 5,
203
+ dx: -4 - digits * 8,
204
204
  'data-pie-readable': false
205
205
  };
206
206
  }}
package/src/graph.jsx CHANGED
@@ -10,6 +10,7 @@ import { Axes, AxisPropTypes } from './axis';
10
10
  import Grid from './grid';
11
11
  import { LabelType } from './labels';
12
12
  import Bg from './bg';
13
+ import { isDuplicatedMark } from './utils';
13
14
 
14
15
  const log = debug('pie-lib:graphing:graph');
15
16
 
@@ -74,7 +75,7 @@ export class Graph extends React.Component {
74
75
 
75
76
  const index = newMarks.findIndex(m => isEqual(m, oldMark));
76
77
 
77
- if (index >= 0) {
78
+ if (index >= 0 && !isDuplicatedMark(newMark, marks, oldMark)) {
78
79
  newMarks.splice(index, 1, newMark);
79
80
 
80
81
  onChangeMarks(newMarks);
@@ -96,6 +97,10 @@ export class Graph extends React.Component {
96
97
  const { onChangeMarks, marks } = this.props;
97
98
  let newMarks = cloneDeep(marks);
98
99
 
100
+ if (!update.building && isDuplicatedMark(update, marks)) {
101
+ return;
102
+ }
103
+
99
104
  const index = newMarks.findIndex(m => isEqual(m, existing));
100
105
 
101
106
  if (index >= 0) {
@@ -115,12 +120,13 @@ export class Graph extends React.Component {
115
120
  return (tool && tool.Component) || null;
116
121
  };
117
122
 
118
- onBgClick = ({ x, y }, mark) => {
119
- log('[onBgClick] x,y: ', x, y);
120
-
123
+ onBgClick = point => {
124
+ const { x, y } = point;
121
125
  const { labelModeEnabled, currentTool, marks } = this.props;
122
126
 
123
- if (labelModeEnabled || !currentTool || mark) {
127
+ log('[onBgClick] x,y: ', x, y);
128
+
129
+ if (labelModeEnabled || !currentTool) {
124
130
  return;
125
131
  }
126
132
 
@@ -183,6 +189,7 @@ export class Graph extends React.Component {
183
189
  <Component
184
190
  key={`${markType}-${index}-bg`}
185
191
  mark={{ ...m, disabled: true }}
192
+ labelNode={this.state.labelNode}
186
193
  {...common}
187
194
  />
188
195
  );
@@ -199,7 +206,7 @@ export class Graph extends React.Component {
199
206
  coordinatesOnHover={coordinatesOnHover}
200
207
  onChange={this.changeMark}
201
208
  onComplete={this.completeMark}
202
- onClick={point => this.onBgClick(point, m)}
209
+ onClick={this.onBgClick}
203
210
  onDragStart={this.startDrag}
204
211
  onDragStop={this.stopDrag}
205
212
  labelNode={this.state.labelNode}
@@ -17,25 +17,6 @@ export default class Arrow extends React.Component {
17
17
  graphProps: types.GraphPropsType.isRequired
18
18
  };
19
19
 
20
- getRotation(currentAngle, referenceAngle, x, y) {
21
- const breakpoint = referenceAngle + 10;
22
- return `rotate(${-currentAngle - (currentAngle > breakpoint ? 15 : 0)}, ${x},${y})`;
23
- }
24
-
25
- getRotationWithBreakpoint(currentAngle, referenceAngle, x, y) {
26
- const firstBreakpoint = referenceAngle + 10;
27
- const secondBreakpoint = referenceAngle + 65;
28
- let t;
29
- if (currentAngle >= firstBreakpoint && currentAngle < secondBreakpoint) {
30
- t = 15;
31
- } else if (currentAngle > secondBreakpoint) {
32
- t = 7;
33
- } else {
34
- t = 0;
35
- }
36
- return `rotate(${-currentAngle + t}, ${x},${y})`;
37
- }
38
-
39
20
  render() {
40
21
  const {
41
22
  classes,
@@ -55,21 +36,11 @@ export default class Arrow extends React.Component {
55
36
  const scaledX = scale.x(x);
56
37
  const scaledY = scale.y(y);
57
38
 
58
- let transform;
39
+ const transform = `rotate(${-angle}, ${scaledX},${scaledY})`;
59
40
  const points = `${scaledX},${scaledY}
60
41
  ${scaledX - size},${scaledY - size / 2}
61
42
  ${scaledX - size}, ${scaledY + size / 2}`;
62
43
 
63
- if (angle >= 0 && angle < 90) {
64
- transform = this.getRotation(angle, 0, scaledX, scaledY);
65
- } else if (angle >= 90 && angle < 180) {
66
- transform = this.getRotationWithBreakpoint(angle, 90, scaledX, scaledY);
67
- } else if (angle >= 180 && angle < 270) {
68
- transform = this.getRotation(angle, 180, scaledX, scaledY);
69
- } else {
70
- transform = this.getRotationWithBreakpoint(angle, 280, scaledX, scaledY);
71
- }
72
-
73
44
  return (
74
45
  <g
75
46
  className={classNames(