@pie-lib/plot 3.0.0-next.0 → 3.1.0-next.2
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 +32 -0
- package/package.json +5 -13
- package/src/label.jsx +11 -38
- package/src/root.jsx +6 -4
- package/lib/draggable.js +0 -44
- package/lib/draggable.js.map +0 -1
- package/lib/graph-props.js +0 -46
- package/lib/graph-props.js.map +0 -1
- package/lib/grid-draggable.js +0 -307
- package/lib/grid-draggable.js.map +0 -1
- package/lib/index.js +0 -44
- package/lib/index.js.map +0 -1
- package/lib/label.js +0 -150
- package/lib/label.js.map +0 -1
- package/lib/root.js +0 -455
- package/lib/root.js.map +0 -1
- package/lib/trig.js +0 -149
- package/lib/trig.js.map +0 -1
- package/lib/types.js +0 -40
- package/lib/types.js.map +0 -1
- package/lib/utils.js +0 -168
- package/lib/utils.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
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
|
+
# [3.1.0-next.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@3.1.0-next.1...@pie-lib/plot@3.1.0-next.2) (2026-01-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-lib/plot
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [3.1.0-next.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.27.2...@pie-lib/plot@3.1.0-next.1) (2026-01-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* remove carets from [@pie-lib](https://github.com/pie-lib) dependencies and configure lerna to use exact versions ([c9cd800](https://github.com/pie-framework/pie-lib/commit/c9cd800844abca09e7acf1fd35b2ddf51a6d86df))
|
|
20
|
+
* remove carret, point to specific libs version ([09939a5](https://github.com/pie-framework/pie-lib/commit/09939a5aca19d7dda03d62c93d4d524f98dd69da))
|
|
21
|
+
* remove exports and publish ([#2068](https://github.com/pie-framework/pie-lib/issues/2068)) ([60a96cd](https://github.com/pie-framework/pie-lib/commit/60a96cde0ec65f6b1cac0ae329aa33a0abc50d05))
|
|
22
|
+
* updated tip-tap with mui instead of material-ui [PD-5141] ([880d3ab](https://github.com/pie-framework/pie-lib/commit/880d3ab1d63aa12c7e975c882f50624200565737))
|
|
23
|
+
* **plot:** fix focus PD-5452 ([882207c](https://github.com/pie-framework/pie-lib/commit/882207c6a1155a8e5818f5c7966239f8f341a0a6))
|
|
24
|
+
* use fixed lib deps ([de7c64d](https://github.com/pie-framework/pie-lib/commit/de7c64d14f13259fe44d47405e4421baef21e24e))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
* bump react and react-dom ([01dc19e](https://github.com/pie-framework/pie-lib/commit/01dc19e88bbc8d372c561d1511df1a82937d45af))
|
|
30
|
+
* migrate from [@vx](https://github.com/vx) library to [@visx](https://github.com/visx) ([135bf60](https://github.com/pie-framework/pie-lib/commit/135bf605161bfbd0070ac181892df20931691ce3))
|
|
31
|
+
* packages/plot mui update PD-5268 ([6456853](https://github.com/pie-framework/pie-lib/commit/645685333cb277208ca197b2853a3780edc92b15))
|
|
32
|
+
* sync latest changes from dev ([c936e9c](https://github.com/pie-framework/pie-lib/commit/c936e9c7f9e095e7d9b9805ac2bf72bd271e05f1))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
# [3.0.0-next.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/plot@2.27.3-next.0...@pie-lib/plot@3.0.0-next.0) (2026-01-19)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @pie-lib/plot
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "3.
|
|
6
|
+
"version": "3.1.0-next.2",
|
|
7
7
|
"description": "Some underlying components for building charts/graphs",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"react",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@mapbox/point-geometry": "^0.1.0",
|
|
22
22
|
"@mui/icons-material": "^7.3.4",
|
|
23
23
|
"@mui/material": "^7.3.4",
|
|
24
|
-
"@pie-lib/editable-html": "
|
|
25
|
-
"@pie-lib/render-ui": "
|
|
24
|
+
"@pie-lib/editable-html-tip-tap": "1.1.0-next.2",
|
|
25
|
+
"@pie-lib/render-ui": "5.1.0-next.2",
|
|
26
26
|
"assert": "^1.4.1",
|
|
27
27
|
"d3-scale": "^2.1.2",
|
|
28
28
|
"d3-selection": "^1.3.2",
|
|
@@ -38,14 +38,6 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "^18.2.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
-
"scripts": {}
|
|
43
|
-
"exports": {
|
|
44
|
-
".": {
|
|
45
|
-
"require": "./lib/index.js",
|
|
46
|
-
"import": "./src/index.js",
|
|
47
|
-
"default": "./lib/index.js"
|
|
48
|
-
},
|
|
49
|
-
"./esm": "./esm/index.js"
|
|
50
|
-
}
|
|
41
|
+
"gitHead": "04c639af6e49d1881bf3244ebb3940171c26bd3e",
|
|
42
|
+
"scripts": {}
|
|
51
43
|
}
|
package/src/label.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { Readable } from '@pie-lib/render-ui';
|
|
3
|
-
import EditableHtml from '@pie-lib/editable-html';
|
|
3
|
+
import EditableHtml from '@pie-lib/editable-html-tip-tap';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { extractTextFromHTML, isEmptyString } from './utils';
|
|
6
6
|
|
|
@@ -64,31 +64,16 @@ const LabelComponent = (props) => {
|
|
|
64
64
|
titleHeight,
|
|
65
65
|
} = props;
|
|
66
66
|
|
|
67
|
-
const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);
|
|
67
|
+
const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);
|
|
68
68
|
|
|
69
|
-
const activePlugins = [
|
|
70
|
-
'bold',
|
|
71
|
-
'italic',
|
|
72
|
-
'underline',
|
|
73
|
-
'strikethrough',
|
|
74
|
-
'math',
|
|
75
|
-
];
|
|
69
|
+
const activePlugins = ['bold', 'italic', 'underline', 'strikethrough', 'math'];
|
|
76
70
|
|
|
77
|
-
const isChart =
|
|
78
|
-
isChartBottomLabel ||
|
|
79
|
-
isChartLeftLabel ||
|
|
80
|
-
isDefineChartBottomLabel ||
|
|
81
|
-
isDefineChartLeftLabel;
|
|
71
|
+
const isChart = isChartBottomLabel || isChartLeftLabel || isDefineChartBottomLabel || isDefineChartLeftLabel;
|
|
82
72
|
|
|
83
|
-
const chartValue =
|
|
84
|
-
side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
|
|
73
|
+
const chartValue = side === 'left' && isDefineChartLeftLabel && graphHeight - 220;
|
|
85
74
|
|
|
86
75
|
const defaultStyle = {
|
|
87
|
-
width:
|
|
88
|
-
chartValue ||
|
|
89
|
-
(side === 'left' || side === 'right'
|
|
90
|
-
? graphHeight - 8
|
|
91
|
-
: graphWidth - 8),
|
|
76
|
+
width: chartValue || (side === 'left' || side === 'right' ? graphHeight - 8 : graphWidth - 8),
|
|
92
77
|
top:
|
|
93
78
|
chartValue ||
|
|
94
79
|
(isChartLeftLabel && `${graphHeight - 70}px`) ||
|
|
@@ -131,27 +116,15 @@ const [rotatedToHorizontal, setRotatedToHorizontal] = useState(false);
|
|
|
131
116
|
style={{
|
|
132
117
|
...(rotatedToHorizontal ? rotatedStyle : defaultStyle),
|
|
133
118
|
...(isChart ? styles.chartLabel : styles.axisLabel),
|
|
134
|
-
...(side === 'left' && !rotatedToHorizontal
|
|
135
|
-
|
|
136
|
-
: {}),
|
|
137
|
-
...(side === 'right' && !rotatedToHorizontal
|
|
138
|
-
? styles.rotateRightLabel
|
|
139
|
-
: {}),
|
|
119
|
+
...(side === 'left' && !rotatedToHorizontal ? styles.rotateLeftLabel : {}),
|
|
120
|
+
...(side === 'right' && !rotatedToHorizontal ? styles.rotateRightLabel : {}),
|
|
140
121
|
...(rotatedToHorizontal ? styles.editLabel : {}),
|
|
141
|
-
...(
|
|
142
|
-
|
|
143
|
-
: {}),
|
|
144
|
-
...((disabledLabel &&
|
|
145
|
-
!isChart &&
|
|
146
|
-
isEmptyString(extractTextFromHTML(text))) &&
|
|
147
|
-
styles.displayNone),
|
|
122
|
+
...(isChartBottomLabel || isDefineChartBottomLabel ? styles.customBottom : {}),
|
|
123
|
+
...(disabledLabel && !isChart && isEmptyString(extractTextFromHTML(text)) && styles.displayNone),
|
|
148
124
|
}}
|
|
149
125
|
>
|
|
150
126
|
{disabledLabel ? (
|
|
151
|
-
<div
|
|
152
|
-
style={styles.disabledLabel}
|
|
153
|
-
dangerouslySetInnerHTML={{ __html: text || '' }}
|
|
154
|
-
/>
|
|
127
|
+
<div style={styles.disabledLabel} dangerouslySetInnerHTML={{ __html: text || '' }} />
|
|
155
128
|
) : (
|
|
156
129
|
<EditableHtml
|
|
157
130
|
markup={text || ''}
|
package/src/root.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { select, mouse } from 'd3-selection';
|
|
5
5
|
|
|
6
6
|
import { color, Readable } from '@pie-lib/render-ui';
|
|
7
|
-
import EditableHtml from '@pie-lib/editable-html';
|
|
7
|
+
import EditableHtml from '@pie-lib/editable-html-tip-tap';
|
|
8
8
|
import { ChildrenType } from './types';
|
|
9
9
|
import { GraphPropsType } from './types';
|
|
10
10
|
import Label from './label';
|
|
@@ -282,7 +282,7 @@ export class Root extends React.Component {
|
|
|
282
282
|
const nbOfHorizontalLines = parseInt(actualHeight / 100);
|
|
283
283
|
const sideGridlinesPadding = parseInt(actualHeight % 100);
|
|
284
284
|
const { titleHeight } = this.state;
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
return (
|
|
287
287
|
<StyledRoot>
|
|
288
288
|
{showPixelGuides && (
|
|
@@ -325,7 +325,8 @@ export class Root extends React.Component {
|
|
|
325
325
|
markup={title || ''}
|
|
326
326
|
onChange={onChangeTitle}
|
|
327
327
|
placeholder={
|
|
328
|
-
(defineChart && titlePlaceholder) ||
|
|
328
|
+
(defineChart && titlePlaceholder) ||
|
|
329
|
+
(!disabledTitle && 'Click here to add a title for this graph')
|
|
329
330
|
}
|
|
330
331
|
toolbarOpts={{ noPadding: true, noBorder: true }}
|
|
331
332
|
activePlugins={activeTitlePlugins}
|
|
@@ -344,7 +345,8 @@ export class Root extends React.Component {
|
|
|
344
345
|
markup={title || ''}
|
|
345
346
|
onChange={onChangeTitle}
|
|
346
347
|
placeholder={
|
|
347
|
-
(defineChart && titlePlaceholder) ||
|
|
348
|
+
(defineChart && titlePlaceholder) ||
|
|
349
|
+
(!disabledTitle && 'Click here to add a title for this graph')
|
|
348
350
|
}
|
|
349
351
|
toolbarOpts={{ noPadding: true, noBorder: true }}
|
|
350
352
|
activePlugins={activeTitlePlugins}
|
package/lib/draggable.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports, "DraggableCore", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _reactDraggable.DraggableCore;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
exports["default"] = void 0;
|
|
15
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
16
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
18
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
var _reactDraggable = _interopRequireWildcard(require("react-draggable"));
|
|
22
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
23
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
24
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
25
|
-
function _superPropGet(t, o, e, r) { var p = (0, _get2["default"])((0, _getPrototypeOf2["default"])(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
26
|
-
var LocalDraggable = exports["default"] = /*#__PURE__*/function (_Draggable) {
|
|
27
|
-
function LocalDraggable() {
|
|
28
|
-
(0, _classCallCheck2["default"])(this, LocalDraggable);
|
|
29
|
-
return _callSuper(this, LocalDraggable, arguments);
|
|
30
|
-
}
|
|
31
|
-
(0, _inherits2["default"])(LocalDraggable, _Draggable);
|
|
32
|
-
return (0, _createClass2["default"])(LocalDraggable, [{
|
|
33
|
-
key: "componentWillReceiveProps",
|
|
34
|
-
value: function componentWillReceiveProps(next) {
|
|
35
|
-
_superPropGet(LocalDraggable, "componentWillReceiveProps", this, 3)([next]);
|
|
36
|
-
//Remove the x/y state as these values have now been updated and will come through as props.
|
|
37
|
-
this.setState({
|
|
38
|
-
x: 0,
|
|
39
|
-
y: 0
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
}]);
|
|
43
|
-
}(_reactDraggable["default"]);
|
|
44
|
-
//# sourceMappingURL=draggable.js.map
|
package/lib/draggable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"draggable.js","names":["_reactDraggable","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","_typeof","has","get","set","_t","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_callSuper","_getPrototypeOf2","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","_superPropGet","p","_get2","LocalDraggable","exports","_Draggable","_classCallCheck2","arguments","_inherits2","_createClass2","key","value","componentWillReceiveProps","next","setState","x","y","Draggable"],"sources":["../src/draggable.jsx"],"sourcesContent":["import Draggable, { DraggableCore } from 'react-draggable';\n\nexport default class LocalDraggable extends Draggable {\n componentWillReceiveProps(next) {\n super.componentWillReceiveProps(next);\n //Remove the x/y state as these values have now been updated and will come through as props.\n this.setState({ x: 0, y: 0 });\n }\n}\n\nexport { DraggableCore };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA2D,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,wBAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,mBAAAT,CAAA,iBAAAA,CAAA,gBAAAU,OAAA,CAAAV,CAAA,0BAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,cAAAM,EAAA,IAAAd,CAAA,gBAAAc,EAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,EAAA,OAAAP,CAAA,IAAAD,CAAA,GAAAW,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAnB,CAAA,EAAAc,EAAA,OAAAP,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAM,EAAA,EAAAP,CAAA,IAAAC,CAAA,CAAAM,EAAA,IAAAd,CAAA,CAAAc,EAAA,WAAAN,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAAA,SAAAmB,WAAAnB,CAAA,EAAAK,CAAA,EAAAN,CAAA,WAAAM,CAAA,OAAAe,gBAAA,aAAAf,CAAA,OAAAgB,2BAAA,aAAArB,CAAA,EAAAsB,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAnB,CAAA,EAAAN,CAAA,YAAAqB,gBAAA,aAAApB,CAAA,EAAAyB,WAAA,IAAApB,CAAA,CAAAqB,KAAA,CAAA1B,CAAA,EAAAD,CAAA;AAAA,SAAAuB,0BAAA,cAAAtB,CAAA,IAAA2B,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAd,IAAA,CAAAQ,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAA3B,CAAA,aAAAsB,yBAAA,YAAAA,0BAAA,aAAAtB,CAAA;AAAA,SAAA8B,cAAA9B,CAAA,EAAAK,CAAA,EAAAN,CAAA,EAAAG,CAAA,QAAA6B,CAAA,OAAAC,KAAA,iBAAAZ,gBAAA,iBAAAlB,CAAA,GAAAF,CAAA,CAAA4B,SAAA,GAAA5B,CAAA,GAAAK,CAAA,EAAAN,CAAA,cAAAG,CAAA,yBAAA6B,CAAA,aAAA/B,CAAA,WAAA+B,CAAA,CAAAL,KAAA,CAAA3B,CAAA,EAAAC,CAAA,OAAA+B,CAAA;AAAA,IAEtCE,cAAc,GAAAC,OAAA,qCAAAC,UAAA;EAAA,SAAAF,eAAA;IAAA,IAAAG,gBAAA,mBAAAH,cAAA;IAAA,OAAAd,UAAA,OAAAc,cAAA,EAAAI,SAAA;EAAA;EAAA,IAAAC,UAAA,aAAAL,cAAA,EAAAE,UAAA;EAAA,WAAAI,aAAA,aAAAN,cAAA;IAAAO,GAAA;IAAAC,KAAA,EACjC,SAAAC,yBAAyBA,CAACC,IAAI,EAAE;MAC9Bb,aAAA,CAAAG,cAAA,yCAAgCU,IAAI;MACpC;MACA,IAAI,CAACC,QAAQ,CAAC;QAAEC,CAAC,EAAE,CAAC;QAAEC,CAAC,EAAE;MAAE,CAAC,CAAC;IAC/B;EAAC;AAAA,EALyCC,0BAAS","ignoreList":[]}
|
package/lib/graph-props.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.create = void 0;
|
|
8
|
-
var _invariant = _interopRequireDefault(require("invariant"));
|
|
9
|
-
var _utils = require("./utils");
|
|
10
|
-
var _d3Scale = require("d3-scale");
|
|
11
|
-
var createSnapMinAndMax = function createSnapMinAndMax(_ref) {
|
|
12
|
-
var min = _ref.min,
|
|
13
|
-
max = _ref.max,
|
|
14
|
-
step = _ref.step;
|
|
15
|
-
// for graphing, if step is a value with decimals, we have to calculate the min & max for the grid taking in consideration that 0 has to be exactly in the middle
|
|
16
|
-
// for example, if min: -5 & max: 5 & step: 0.75, in order to keep 0 in the middle we have to set min: -4.5 & max: 4.5
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
step: step,
|
|
20
|
-
min: parseInt(min / step) * step,
|
|
21
|
-
max: parseInt(max / step) * step
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
var create = exports.create = function create(domain, range, size, getRootNode) {
|
|
25
|
-
(0, _invariant["default"])(domain.min < domain.max, 'domain: min must be less than max');
|
|
26
|
-
(0, _invariant["default"])(range.min < range.max, 'range: min must be less than max');
|
|
27
|
-
var domainMinMax = createSnapMinAndMax(domain);
|
|
28
|
-
var rangeMinMax = createSnapMinAndMax(range);
|
|
29
|
-
var scale = {
|
|
30
|
-
x: (0, _d3Scale.scaleLinear)().domain([domain.min, domain.max]).range([0, size.width]),
|
|
31
|
-
y: (0, _d3Scale.scaleLinear)().domain([range.max, range.min]).range([0, size.height])
|
|
32
|
-
};
|
|
33
|
-
var snap = {
|
|
34
|
-
x: _utils.snapTo.bind(null, domainMinMax.min, domainMinMax.max, domainMinMax.step),
|
|
35
|
-
y: _utils.snapTo.bind(null, rangeMinMax.min, rangeMinMax.max, rangeMinMax.step)
|
|
36
|
-
};
|
|
37
|
-
return {
|
|
38
|
-
scale: scale,
|
|
39
|
-
snap: snap,
|
|
40
|
-
domain: domain,
|
|
41
|
-
range: range,
|
|
42
|
-
size: size,
|
|
43
|
-
getRootNode: getRootNode
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=graph-props.js.map
|
package/lib/graph-props.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph-props.js","names":["_invariant","_interopRequireDefault","require","_utils","_d3Scale","createSnapMinAndMax","_ref","min","max","step","parseInt","create","exports","domain","range","size","getRootNode","invariant","domainMinMax","rangeMinMax","scale","x","scaleLinear","width","y","height","snap","snapTo","bind"],"sources":["../src/graph-props.js"],"sourcesContent":["import invariant from 'invariant';\nimport { snapTo } from './utils';\nimport { scaleLinear } from 'd3-scale';\n\nconst createSnapMinAndMax = ({ min, max, step }) => {\n // for graphing, if step is a value with decimals, we have to calculate the min & max for the grid taking in consideration that 0 has to be exactly in the middle\n // for example, if min: -5 & max: 5 & step: 0.75, in order to keep 0 in the middle we have to set min: -4.5 & max: 4.5\n\n return {\n step,\n min: parseInt(min / step) * step,\n max: parseInt(max / step) * step,\n };\n};\n\nexport const create = (domain, range, size, getRootNode) => {\n invariant(domain.min < domain.max, 'domain: min must be less than max');\n invariant(range.min < range.max, 'range: min must be less than max');\n\n const domainMinMax = createSnapMinAndMax(domain);\n const rangeMinMax = createSnapMinAndMax(range);\n\n const scale = {\n x: scaleLinear()\n .domain([domain.min, domain.max])\n .range([0, size.width]),\n y: scaleLinear()\n .domain([range.max, range.min])\n .range([0, size.height]),\n };\n\n const snap = {\n x: snapTo.bind(null, domainMinMax.min, domainMinMax.max, domainMinMax.step),\n y: snapTo.bind(null, rangeMinMax.min, rangeMinMax.max, rangeMinMax.step),\n };\n\n return { scale, snap, domain, range, size, getRootNode };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAMG,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAAC,IAAA,EAA2B;EAAA,IAArBC,GAAG,GAAAD,IAAA,CAAHC,GAAG;IAAEC,GAAG,GAAAF,IAAA,CAAHE,GAAG;IAAEC,IAAI,GAAAH,IAAA,CAAJG,IAAI;EAC3C;EACA;;EAEA,OAAO;IACLA,IAAI,EAAJA,IAAI;IACJF,GAAG,EAAEG,QAAQ,CAACH,GAAG,GAAGE,IAAI,CAAC,GAAGA,IAAI;IAChCD,GAAG,EAAEE,QAAQ,CAACF,GAAG,GAAGC,IAAI,CAAC,GAAGA;EAC9B,CAAC;AACH,CAAC;AAEM,IAAME,MAAM,GAAAC,OAAA,CAAAD,MAAA,GAAG,SAATA,MAAMA,CAAIE,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAK;EAC1D,IAAAC,qBAAS,EAACJ,MAAM,CAACN,GAAG,GAAGM,MAAM,CAACL,GAAG,EAAE,mCAAmC,CAAC;EACvE,IAAAS,qBAAS,EAACH,KAAK,CAACP,GAAG,GAAGO,KAAK,CAACN,GAAG,EAAE,kCAAkC,CAAC;EAEpE,IAAMU,YAAY,GAAGb,mBAAmB,CAACQ,MAAM,CAAC;EAChD,IAAMM,WAAW,GAAGd,mBAAmB,CAACS,KAAK,CAAC;EAE9C,IAAMM,KAAK,GAAG;IACZC,CAAC,EAAE,IAAAC,oBAAW,EAAC,CAAC,CACbT,MAAM,CAAC,CAACA,MAAM,CAACN,GAAG,EAAEM,MAAM,CAACL,GAAG,CAAC,CAAC,CAChCM,KAAK,CAAC,CAAC,CAAC,EAAEC,IAAI,CAACQ,KAAK,CAAC,CAAC;IACzBC,CAAC,EAAE,IAAAF,oBAAW,EAAC,CAAC,CACbT,MAAM,CAAC,CAACC,KAAK,CAACN,GAAG,EAAEM,KAAK,CAACP,GAAG,CAAC,CAAC,CAC9BO,KAAK,CAAC,CAAC,CAAC,EAAEC,IAAI,CAACU,MAAM,CAAC;EAC3B,CAAC;EAED,IAAMC,IAAI,GAAG;IACXL,CAAC,EAAEM,aAAM,CAACC,IAAI,CAAC,IAAI,EAAEV,YAAY,CAACX,GAAG,EAAEW,YAAY,CAACV,GAAG,EAAEU,YAAY,CAACT,IAAI,CAAC;IAC3Ee,CAAC,EAAEG,aAAM,CAACC,IAAI,CAAC,IAAI,EAAET,WAAW,CAACZ,GAAG,EAAEY,WAAW,CAACX,GAAG,EAAEW,WAAW,CAACV,IAAI;EACzE,CAAC;EAED,OAAO;IAAEW,KAAK,EAALA,KAAK;IAAEM,IAAI,EAAJA,IAAI;IAAEb,MAAM,EAANA,MAAM;IAAEC,KAAK,EAALA,KAAK;IAAEC,IAAI,EAAJA,IAAI;IAAEC,WAAW,EAAXA;EAAY,CAAC;AAC1D,CAAC","ignoreList":[]}
|
package/lib/grid-draggable.js
DELETED
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.gridDraggable = exports.deltaFn = void 0;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
15
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
16
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
-
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
20
|
-
var _types = require("./types");
|
|
21
|
-
var _draggable = require("./draggable");
|
|
22
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
23
|
-
var utils = _interopRequireWildcard(require("./utils"));
|
|
24
|
-
var _isFunction = _interopRequireDefault(require("lodash/isFunction"));
|
|
25
|
-
var _invariant = _interopRequireDefault(require("invariant"));
|
|
26
|
-
var _d3Selection = require("d3-selection");
|
|
27
|
-
var _excluded = ["disabled"];
|
|
28
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
29
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
|
|
30
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
31
|
-
var log = (0, _debug["default"])('pie-lib:plot:grid-draggable');
|
|
32
|
-
var deltaFn = exports.deltaFn = function deltaFn(scale, snap, val) {
|
|
33
|
-
return function (delta) {
|
|
34
|
-
var normalized = delta + scale(0);
|
|
35
|
-
var inverted = scale.invert(normalized);
|
|
36
|
-
var fixDecimalsArithmetic = snap(val + inverted).toFixed(4) * 1000 / 1000;
|
|
37
|
-
return fixDecimalsArithmetic;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates a Component that is draggable, within a bounded grid.
|
|
43
|
-
* @param {*} opts
|
|
44
|
-
*/
|
|
45
|
-
var gridDraggable = exports.gridDraggable = function gridDraggable(opts) {
|
|
46
|
-
return function (Comp) {
|
|
47
|
-
var _GridDraggable;
|
|
48
|
-
(0, _invariant["default"])(!!opts && (0, _isFunction["default"])(opts.fromDelta) && (0, _isFunction["default"])(opts.bounds) && (0, _isFunction["default"])(opts.anchorPoint), 'You must supply an object with: { anchorPoint: Function, fromDelta: Function, bounds: Function }');
|
|
49
|
-
return _GridDraggable = /*#__PURE__*/function (_React$Component) {
|
|
50
|
-
function GridDraggable(props) {
|
|
51
|
-
var _this;
|
|
52
|
-
(0, _classCallCheck2["default"])(this, GridDraggable);
|
|
53
|
-
_this = _callSuper(this, GridDraggable, [props]);
|
|
54
|
-
(0, _defineProperty2["default"])(_this, "grid", function () {
|
|
55
|
-
var graphProps = _this.props.graphProps;
|
|
56
|
-
var scale = graphProps.scale,
|
|
57
|
-
domain = graphProps.domain,
|
|
58
|
-
range = graphProps.range;
|
|
59
|
-
return {
|
|
60
|
-
x: scale.x(domain.step) - scale.x(0),
|
|
61
|
-
y: scale.y(range.step) - scale.y(0)
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
(0, _defineProperty2["default"])(_this, "onStart", function (e) {
|
|
65
|
-
var onDragStart = _this.props.onDragStart;
|
|
66
|
-
if (document.activeElement) {
|
|
67
|
-
document.activeElement.blur();
|
|
68
|
-
}
|
|
69
|
-
_this.setState({
|
|
70
|
-
startX: e.clientX,
|
|
71
|
-
startY: e.clientY
|
|
72
|
-
});
|
|
73
|
-
if (onDragStart) {
|
|
74
|
-
onDragStart();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
(0, _defineProperty2["default"])(_this, "position", function () {
|
|
78
|
-
var _opts$anchorPoint = opts.anchorPoint(_this.props),
|
|
79
|
-
x = _opts$anchorPoint.x,
|
|
80
|
-
y = _opts$anchorPoint.y;
|
|
81
|
-
var graphProps = _this.props.graphProps;
|
|
82
|
-
var scale = graphProps.scale,
|
|
83
|
-
snap = graphProps.snap;
|
|
84
|
-
return {
|
|
85
|
-
anchorPoint: {
|
|
86
|
-
x: x,
|
|
87
|
-
y: y
|
|
88
|
-
},
|
|
89
|
-
x: deltaFn(scale.x, snap.x, x),
|
|
90
|
-
y: deltaFn(scale.y, snap.y, y)
|
|
91
|
-
};
|
|
92
|
-
});
|
|
93
|
-
(0, _defineProperty2["default"])(_this, "tiny", function (key, event) {
|
|
94
|
-
var K = key.toUpperCase();
|
|
95
|
-
var end = event["client".concat(K)];
|
|
96
|
-
var start = _this.state["start".concat(K)];
|
|
97
|
-
var delta = Math.abs(end - start);
|
|
98
|
-
var out = delta < Math.abs(_this.grid()[key]) / 10;
|
|
99
|
-
log('[tiny] key: ', key, 'delta: ', delta, 'out: ', out);
|
|
100
|
-
return out;
|
|
101
|
-
});
|
|
102
|
-
(0, _defineProperty2["default"])(_this, "getScaledBounds", function () {
|
|
103
|
-
var bounds = opts.bounds(_this.props, _this.props.graphProps);
|
|
104
|
-
log('bounds: ', bounds);
|
|
105
|
-
var grid = _this.grid();
|
|
106
|
-
var scaled = {
|
|
107
|
-
left: bounds.left * grid.x,
|
|
108
|
-
right: bounds.right * grid.x,
|
|
109
|
-
top: bounds.top * grid.y,
|
|
110
|
-
bottom: bounds.bottom * grid.y
|
|
111
|
-
};
|
|
112
|
-
log('[getScaledBounds]: ', scaled);
|
|
113
|
-
return scaled;
|
|
114
|
-
});
|
|
115
|
-
/**
|
|
116
|
-
* Retrieves the coordinates of a mouse or touch event relative to an SVG element.
|
|
117
|
-
* This method has been overwritten from the d3-selection library's clientPoint to handle touch events and improve clarity.
|
|
118
|
-
* @param {Element} node - The SVG element.
|
|
119
|
-
* @param {Event} event - The mouse or touch event.
|
|
120
|
-
* @returns {Array} - An array containing the coordinates [x, y] relative to the SVG element.
|
|
121
|
-
*/
|
|
122
|
-
(0, _defineProperty2["default"])(_this, "getClientPoint", function (node, event) {
|
|
123
|
-
if (!node || !event) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
var svg = node.ownerSVGElement || node;
|
|
127
|
-
if (svg && svg.createSVGPoint) {
|
|
128
|
-
var point = svg.createSVGPoint();
|
|
129
|
-
// Check if it's a touch event and use the first touch point
|
|
130
|
-
if (event.touches && event.touches.length > 0) {
|
|
131
|
-
var touch = event.touches[0];
|
|
132
|
-
point.x = touch.clientX;
|
|
133
|
-
point.y = touch.clientY;
|
|
134
|
-
} else {
|
|
135
|
-
// Fall back to mouse event properties
|
|
136
|
-
point.x = event.clientX;
|
|
137
|
-
point.y = event.clientY;
|
|
138
|
-
}
|
|
139
|
-
if (node.getScreenCTM) {
|
|
140
|
-
point = point.matrixTransform(node.getScreenCTM().inverse());
|
|
141
|
-
return [point.x, point.y];
|
|
142
|
-
} else {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
var rect = node.getBoundingClientRect();
|
|
147
|
-
if (rect) {
|
|
148
|
-
return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
|
|
149
|
-
} else {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
(0, _defineProperty2["default"])(_this, "skipDragOutsideOfBounds", function (dd, e, graphProps) {
|
|
154
|
-
// Ignore drag movement outside of the domain and range.
|
|
155
|
-
var rootNode = graphProps.getRootNode();
|
|
156
|
-
var clientPoint = _this.getClientPoint(rootNode, e);
|
|
157
|
-
if (clientPoint === null) {
|
|
158
|
-
return true; // Indicate that the drag is outside of bounds
|
|
159
|
-
}
|
|
160
|
-
var _clientPoint = (0, _slicedToArray2["default"])(clientPoint, 2),
|
|
161
|
-
rawX = _clientPoint[0],
|
|
162
|
-
rawY = _clientPoint[1];
|
|
163
|
-
var scale = graphProps.scale,
|
|
164
|
-
domain = graphProps.domain,
|
|
165
|
-
range = graphProps.range;
|
|
166
|
-
var x = scale.x.invert(rawX);
|
|
167
|
-
var y = scale.y.invert(rawY);
|
|
168
|
-
var xOutside = dd.deltaX > 0 && x < domain.min || dd.deltaX < 0 && x > domain.max;
|
|
169
|
-
var yOutside = dd.deltaY > 0 && y > range.max || dd.deltaY < 0 && y < range.min;
|
|
170
|
-
return xOutside || yOutside;
|
|
171
|
-
});
|
|
172
|
-
(0, _defineProperty2["default"])(_this, "onDrag", function (e, dd) {
|
|
173
|
-
var _this$props = _this.props,
|
|
174
|
-
onDrag = _this$props.onDrag,
|
|
175
|
-
graphProps = _this$props.graphProps;
|
|
176
|
-
if (!onDrag) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
var bounds = _this.getScaledBounds();
|
|
180
|
-
if (dd.deltaX < 0 && dd.deltaX < bounds.left) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
if (dd.deltaX > 0 && dd.deltaX > bounds.right) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (dd.deltaY < 0 && dd.deltaY < bounds.top) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
if (dd.deltaY > 0 && dd.deltaY > bounds.bottom) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if (_this.skipDragOutsideOfBounds(dd, e, graphProps)) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
var dragArg = _this.applyDelta({
|
|
196
|
-
x: dd.deltaX,
|
|
197
|
-
y: dd.deltaY
|
|
198
|
-
});
|
|
199
|
-
if (dragArg !== undefined || dragArg !== null) {
|
|
200
|
-
onDrag(dragArg);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
(0, _defineProperty2["default"])(_this, "getDelta", function (point) {
|
|
204
|
-
var pos = _this.position();
|
|
205
|
-
var p = {
|
|
206
|
-
x: pos.x(point.x),
|
|
207
|
-
y: pos.y(point.y)
|
|
208
|
-
};
|
|
209
|
-
return utils.getDelta(pos.anchorPoint, p);
|
|
210
|
-
});
|
|
211
|
-
(0, _defineProperty2["default"])(_this, "applyDelta", function (point) {
|
|
212
|
-
var delta = _this.getDelta(point);
|
|
213
|
-
log('[applyDelta] delta:', delta);
|
|
214
|
-
return opts.fromDelta(_this.props, delta);
|
|
215
|
-
});
|
|
216
|
-
(0, _defineProperty2["default"])(_this, "onStop", function (e, dd) {
|
|
217
|
-
log('[onStop] dd:', dd);
|
|
218
|
-
var _this$props2 = _this.props,
|
|
219
|
-
onDragStop = _this$props2.onDragStop,
|
|
220
|
-
onClick = _this$props2.onClick;
|
|
221
|
-
if (onDragStop) {
|
|
222
|
-
onDragStop();
|
|
223
|
-
}
|
|
224
|
-
log('[onStop] lastX/Y: ', dd.lastX, dd.lastY);
|
|
225
|
-
var isClick = _this.tiny('x', e) && _this.tiny('y', e);
|
|
226
|
-
if (isClick) {
|
|
227
|
-
if (onClick) {
|
|
228
|
-
log('call onClick');
|
|
229
|
-
_this.setState({
|
|
230
|
-
startX: null
|
|
231
|
-
});
|
|
232
|
-
var graphProps = _this.props.graphProps;
|
|
233
|
-
var scale = graphProps.scale,
|
|
234
|
-
snap = graphProps.snap;
|
|
235
|
-
var _clientPoint2 = (0, _d3Selection.clientPoint)(e.target, e),
|
|
236
|
-
_clientPoint3 = (0, _slicedToArray2["default"])(_clientPoint2, 2),
|
|
237
|
-
rawX = _clientPoint3[0],
|
|
238
|
-
rawY = _clientPoint3[1];
|
|
239
|
-
var x = scale.x.invert(rawX);
|
|
240
|
-
var y = scale.y.invert(rawY);
|
|
241
|
-
x = snap.x(x);
|
|
242
|
-
y = snap.y(y);
|
|
243
|
-
onClick({
|
|
244
|
-
x: x,
|
|
245
|
-
y: y
|
|
246
|
-
});
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
_this.setState({
|
|
251
|
-
startX: null,
|
|
252
|
-
startY: null
|
|
253
|
-
});
|
|
254
|
-
// return false to prevent state updates in the underlying draggable - a move will have triggered an update already.
|
|
255
|
-
return false;
|
|
256
|
-
});
|
|
257
|
-
_this.state = {
|
|
258
|
-
startX: null,
|
|
259
|
-
startY: null
|
|
260
|
-
};
|
|
261
|
-
return _this;
|
|
262
|
-
}
|
|
263
|
-
(0, _inherits2["default"])(GridDraggable, _React$Component);
|
|
264
|
-
return (0, _createClass2["default"])(GridDraggable, [{
|
|
265
|
-
key: "render",
|
|
266
|
-
value: function render() {
|
|
267
|
-
var _this$props3 = this.props,
|
|
268
|
-
disabled = _this$props3.disabled,
|
|
269
|
-
rest = (0, _objectWithoutProperties2["default"])(_this$props3, _excluded);
|
|
270
|
-
var grid = this.grid();
|
|
271
|
-
|
|
272
|
-
// prevent the text select icon from rendering.
|
|
273
|
-
var onMouseDown = function onMouseDown(e) {
|
|
274
|
-
return e.nativeEvent.preventDefault();
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* TODO: This shouldnt be necessary, we should be able to use the r-d classnames.
|
|
279
|
-
* But they aren't being unset. If we continue with this lib, we'll have to fix this.
|
|
280
|
-
*/
|
|
281
|
-
var isDragging = this.state ? !!this.state.startX : false;
|
|
282
|
-
return /*#__PURE__*/_react["default"].createElement(_draggable.DraggableCore, {
|
|
283
|
-
disabled: disabled,
|
|
284
|
-
onMouseDown: onMouseDown,
|
|
285
|
-
onStart: this.onStart,
|
|
286
|
-
onDrag: this.onDrag,
|
|
287
|
-
onStop: this.onStop,
|
|
288
|
-
axis: opts.axis || 'both',
|
|
289
|
-
grid: [grid.x, grid.y]
|
|
290
|
-
}, /*#__PURE__*/_react["default"].createElement(Comp, (0, _extends2["default"])({}, rest, {
|
|
291
|
-
disabled: disabled,
|
|
292
|
-
isDragging: isDragging
|
|
293
|
-
})));
|
|
294
|
-
}
|
|
295
|
-
}]);
|
|
296
|
-
}(_react["default"].Component), (0, _defineProperty2["default"])(_GridDraggable, "propTypes", {
|
|
297
|
-
disabled: _propTypes["default"].bool,
|
|
298
|
-
onDragStart: _propTypes["default"].func,
|
|
299
|
-
onDrag: _propTypes["default"].func,
|
|
300
|
-
onDragStop: _propTypes["default"].func,
|
|
301
|
-
onClick: _propTypes["default"].func,
|
|
302
|
-
onMove: _propTypes["default"].func,
|
|
303
|
-
graphProps: _types.GraphPropsType.isRequired
|
|
304
|
-
}), _GridDraggable;
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
|
-
//# sourceMappingURL=grid-draggable.js.map
|