@pie-lib/graphing 2.11.3-next.52 → 2.11.5-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js.map +1 -1
- package/lib/bg.js.map +1 -1
- package/lib/container/actions.js.map +1 -1
- package/lib/container/index.js.map +1 -1
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js.map +1 -1
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js.map +1 -1
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/undo-redo.js.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/axis/arrow.jsx +4 -4
- package/src/axis/axes.jsx +34 -56
- package/src/bg.jsx +3 -11
- package/src/container/actions.js +3 -3
- package/src/container/index.jsx +7 -7
- package/src/coordinates-label.jsx +8 -8
- package/src/graph-with-controls.jsx +30 -41
- package/src/graph.jsx +20 -22
- package/src/grid-setup.jsx +37 -64
- package/src/grid.jsx +17 -19
- package/src/labels.jsx +20 -20
- package/src/mark-label.jsx +13 -13
- package/src/toggle-bar.jsx +28 -30
- package/src/tool-menu.jsx +7 -12
- package/src/tools/circle/bg-circle.jsx +11 -26
- package/src/tools/circle/component.jsx +25 -25
- package/src/tools/circle/index.js +2 -2
- package/src/tools/index.js +2 -23
- package/src/tools/line/component.jsx +5 -10
- package/src/tools/parabola/component.jsx +2 -9
- package/src/tools/parabola/index.js +2 -2
- package/src/tools/point/component.jsx +5 -5
- package/src/tools/point/index.js +3 -3
- package/src/tools/polygon/component.jsx +18 -34
- package/src/tools/polygon/index.js +3 -3
- package/src/tools/polygon/line.jsx +10 -15
- package/src/tools/polygon/polygon.jsx +16 -25
- package/src/tools/ray/component.jsx +5 -10
- package/src/tools/segment/component.jsx +5 -10
- package/src/tools/shared/arrow-head.jsx +4 -4
- package/src/tools/shared/line/index.jsx +30 -31
- package/src/tools/shared/line/line-path.jsx +13 -29
- package/src/tools/shared/line/with-root-edge.jsx +14 -25
- package/src/tools/shared/point/arrow-point.jsx +6 -25
- package/src/tools/shared/point/arrow.jsx +3 -21
- package/src/tools/shared/point/base-point.jsx +3 -11
- package/src/tools/shared/point/index.jsx +11 -11
- package/src/tools/shared/styles.js +3 -3
- package/src/tools/shared/types.js +1 -1
- package/src/tools/sine/component.jsx +2 -2
- package/src/tools/sine/index.js +2 -2
- package/src/tools/vector/component.jsx +5 -10
- package/src/undo-redo.jsx +6 -6
- package/src/utils.js +29 -38
|
@@ -12,10 +12,10 @@ import MarkLabel from '../../mark-label';
|
|
|
12
12
|
import isEmpty from 'lodash/isEmpty';
|
|
13
13
|
import { color } from '@pie-lib/render-ui';
|
|
14
14
|
|
|
15
|
-
const opacityPulsate = opacity => ({
|
|
15
|
+
const opacityPulsate = (opacity) => ({
|
|
16
16
|
'0%': { opacity: '0.0' },
|
|
17
17
|
'50%': { opacity },
|
|
18
|
-
'100%': { opacity: '0.0' }
|
|
18
|
+
'100%': { opacity: '0.0' },
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const getRadius = (from, outer) => {
|
|
@@ -41,14 +41,14 @@ export class RawBaseCircle extends React.Component {
|
|
|
41
41
|
onClick: PropTypes.func,
|
|
42
42
|
labelNode: PropTypes.object,
|
|
43
43
|
labelModeEnabled: PropTypes.bool,
|
|
44
|
-
changeMarkProps: PropTypes.func
|
|
44
|
+
changeMarkProps: PropTypes.func,
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
static defaultProps = {
|
|
48
|
-
onClick: () => ({})
|
|
48
|
+
onClick: () => ({}),
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
onChangePoint = point => {
|
|
51
|
+
onChangePoint = (point) => {
|
|
52
52
|
const { middle, onChange } = this.props;
|
|
53
53
|
const { from, to } = point;
|
|
54
54
|
|
|
@@ -62,7 +62,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
dragFrom = draggedFrom => {
|
|
65
|
+
dragFrom = (draggedFrom) => {
|
|
66
66
|
const { from, to } = this.props;
|
|
67
67
|
|
|
68
68
|
if (from.label) {
|
|
@@ -74,7 +74,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
dragTo = draggedTo => {
|
|
77
|
+
dragTo = (draggedTo) => {
|
|
78
78
|
const { from, to } = this.props;
|
|
79
79
|
|
|
80
80
|
if (to.label) {
|
|
@@ -86,7 +86,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
dragCircle = draggedFrom => {
|
|
89
|
+
dragCircle = (draggedFrom) => {
|
|
90
90
|
const { from, to, onChange, middle } = this.props;
|
|
91
91
|
const diff = point(from).sub(point(draggedFrom));
|
|
92
92
|
const draggedTo = point(to).sub(diff);
|
|
@@ -109,11 +109,11 @@ export class RawBaseCircle extends React.Component {
|
|
|
109
109
|
{
|
|
110
110
|
draggedroot: undefined,
|
|
111
111
|
draggedOuter: undefined,
|
|
112
|
-
isCircleDrag: false
|
|
112
|
+
isCircleDrag: false,
|
|
113
113
|
},
|
|
114
114
|
() => {
|
|
115
115
|
onChange(updated);
|
|
116
|
-
}
|
|
116
|
+
},
|
|
117
117
|
);
|
|
118
118
|
};
|
|
119
119
|
|
|
@@ -160,7 +160,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
160
160
|
correctness,
|
|
161
161
|
graphProps,
|
|
162
162
|
labelNode,
|
|
163
|
-
labelModeEnabled
|
|
163
|
+
labelModeEnabled,
|
|
164
164
|
} = this.props;
|
|
165
165
|
const common = { onDragStart, onDragStop, graphProps, onClick };
|
|
166
166
|
|
|
@@ -176,39 +176,39 @@ export class RawBaseCircle extends React.Component {
|
|
|
176
176
|
if (from && from.hasOwnProperty('label')) {
|
|
177
177
|
fromLabelNode = ReactDOM.createPortal(
|
|
178
178
|
<MarkLabel
|
|
179
|
-
inputRef={r => (this.input.from = r)}
|
|
179
|
+
inputRef={(r) => (this.input.from = r)}
|
|
180
180
|
disabled={!labelModeEnabled}
|
|
181
181
|
mark={from}
|
|
182
182
|
graphProps={graphProps}
|
|
183
|
-
onChange={label => this.labelChange({ ...from, label }, 'from')}
|
|
183
|
+
onChange={(label) => this.labelChange({ ...from, label }, 'from')}
|
|
184
184
|
/>,
|
|
185
|
-
labelNode
|
|
185
|
+
labelNode,
|
|
186
186
|
);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
if (to && to.hasOwnProperty('label')) {
|
|
190
190
|
toLabelNode = ReactDOM.createPortal(
|
|
191
191
|
<MarkLabel
|
|
192
|
-
inputRef={r => (this.input.to = r)}
|
|
192
|
+
inputRef={(r) => (this.input.to = r)}
|
|
193
193
|
disabled={!labelModeEnabled}
|
|
194
194
|
mark={to}
|
|
195
195
|
graphProps={graphProps}
|
|
196
|
-
onChange={label => this.labelChange({ ...to, label }, 'to')}
|
|
196
|
+
onChange={(label) => this.labelChange({ ...to, label }, 'to')}
|
|
197
197
|
/>,
|
|
198
|
-
labelNode
|
|
198
|
+
labelNode,
|
|
199
199
|
);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
if (middle && middle.hasOwnProperty('label')) {
|
|
203
203
|
circleLabelNode = ReactDOM.createPortal(
|
|
204
204
|
<MarkLabel
|
|
205
|
-
inputRef={r => (this.input.middle = r)}
|
|
205
|
+
inputRef={(r) => (this.input.middle = r)}
|
|
206
206
|
disabled={!labelModeEnabled}
|
|
207
207
|
mark={middle}
|
|
208
208
|
graphProps={graphProps}
|
|
209
|
-
onChange={label => this.labelChange({ ...middle, label }, 'middle')}
|
|
209
|
+
onChange={(label) => this.labelChange({ ...middle, label }, 'middle')}
|
|
210
210
|
/>,
|
|
211
|
-
labelNode
|
|
211
|
+
labelNode,
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
@@ -259,24 +259,24 @@ export class RawBaseCircle extends React.Component {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
export const BaseCircle = withStyles(theme => ({
|
|
262
|
+
export const BaseCircle = withStyles((theme) => ({
|
|
263
263
|
outerLine: {
|
|
264
264
|
fill: 'rgb(0,0,0,0)', // TODO hardcoded color
|
|
265
265
|
stroke: color.primaryLight(),
|
|
266
266
|
strokeWidth: 4,
|
|
267
267
|
'&:hover': {
|
|
268
268
|
strokeWidth: 6,
|
|
269
|
-
stroke: color.primaryDark()
|
|
270
|
-
}
|
|
269
|
+
stroke: color.primaryDark(),
|
|
270
|
+
},
|
|
271
271
|
},
|
|
272
272
|
root: {},
|
|
273
273
|
bgCircleBuilding: {
|
|
274
274
|
stroke: color.secondaryLight(),
|
|
275
275
|
animation: 'opacityPulse 2s ease-out',
|
|
276
276
|
animationIterationCount: 'infinite',
|
|
277
|
-
opacity: 1
|
|
277
|
+
opacity: 1,
|
|
278
278
|
},
|
|
279
|
-
'@keyframes opacityPulse': opacityPulsate('0.3')
|
|
279
|
+
'@keyframes opacityPulse': opacityPulsate('0.3'),
|
|
280
280
|
}))(RawBaseCircle);
|
|
281
281
|
|
|
282
282
|
const Component = rootEdgeComponent(BaseCircle);
|
package/src/tools/index.js
CHANGED
|
@@ -8,29 +8,8 @@ import { tool as segment } from './segment';
|
|
|
8
8
|
import { tool as ray } from './ray';
|
|
9
9
|
import { tool as vector } from './vector';
|
|
10
10
|
|
|
11
|
-
const allTools = [
|
|
12
|
-
'circle',
|
|
13
|
-
'line',
|
|
14
|
-
'label',
|
|
15
|
-
'parabola',
|
|
16
|
-
'point',
|
|
17
|
-
'polygon',
|
|
18
|
-
'ray',
|
|
19
|
-
'segment',
|
|
20
|
-
'sine',
|
|
21
|
-
'vector'
|
|
22
|
-
];
|
|
11
|
+
const allTools = ['circle', 'line', 'label', 'parabola', 'point', 'polygon', 'ray', 'segment', 'sine', 'vector'];
|
|
23
12
|
|
|
24
|
-
const toolsArr = [
|
|
25
|
-
circle(),
|
|
26
|
-
line(),
|
|
27
|
-
parabola(),
|
|
28
|
-
point(),
|
|
29
|
-
polygon(),
|
|
30
|
-
ray(),
|
|
31
|
-
segment(),
|
|
32
|
-
sine(),
|
|
33
|
-
vector()
|
|
34
|
-
];
|
|
13
|
+
const toolsArr = [circle(), line(), parabola(), point(), polygon(), ray(), segment(), sine(), vector()];
|
|
35
14
|
|
|
36
15
|
export { allTools, toolsArr, circle, line, point, parabola, polygon, ray, sine, vector };
|
|
@@ -9,7 +9,7 @@ import { thinnerShapesNeeded, getAdjustedGraphLimits } from '../../utils';
|
|
|
9
9
|
|
|
10
10
|
const markerId = genUid();
|
|
11
11
|
|
|
12
|
-
const lineStyles = theme => ({
|
|
12
|
+
const lineStyles = (theme) => ({
|
|
13
13
|
line: styles.line(theme),
|
|
14
14
|
enabledArrow: styles.arrow(theme),
|
|
15
15
|
disabledArrow: styles.disabledArrow(theme),
|
|
@@ -17,10 +17,10 @@ const lineStyles = theme => ({
|
|
|
17
17
|
correct: styles.correct(theme, 'stroke'),
|
|
18
18
|
correctArrow: styles.correct(theme),
|
|
19
19
|
incorrect: styles.incorrect(theme, 'stroke'),
|
|
20
|
-
incorrectArrow: styles.incorrect(theme)
|
|
20
|
+
incorrectArrow: styles.incorrect(theme),
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
export const ArrowedLine = props => {
|
|
23
|
+
export const ArrowedLine = (props) => {
|
|
24
24
|
const { className, classes, correctness, disabled, graphProps, from, to, ...rest } = props;
|
|
25
25
|
const { scale } = graphProps;
|
|
26
26
|
const { domain, range } = getAdjustedGraphLimits(graphProps);
|
|
@@ -41,12 +41,7 @@ export const ArrowedLine = props => {
|
|
|
41
41
|
y1={scale.y(eFrom.y)}
|
|
42
42
|
x2={scale.x(eTo.x)}
|
|
43
43
|
y2={scale.y(eTo.y)}
|
|
44
|
-
className={classNames(
|
|
45
|
-
classes.line,
|
|
46
|
-
disabled && classes.disabled,
|
|
47
|
-
classes[correctness],
|
|
48
|
-
className
|
|
49
|
-
)}
|
|
44
|
+
className={classNames(classes.line, disabled && classes.disabled, classes[correctness], className)}
|
|
50
45
|
markerEnd={`url(#${props.markerId || markerId}-${suffix})`}
|
|
51
46
|
markerStart={`url(#${props.markerId || markerId}-${suffix})`}
|
|
52
47
|
{...rest}
|
|
@@ -63,7 +58,7 @@ ArrowedLine.propTypes = {
|
|
|
63
58
|
graphProps: types.GraphPropsType,
|
|
64
59
|
from: types.PointType,
|
|
65
60
|
to: types.PointType,
|
|
66
|
-
markerId: PropTypes.string
|
|
61
|
+
markerId: PropTypes.string,
|
|
67
62
|
};
|
|
68
63
|
|
|
69
64
|
const StyledArrowedLine = withStyles(lineStyles)(ArrowedLine);
|
|
@@ -4,7 +4,7 @@ import { withRootEdge, rootEdgeComponent } from '../shared/line/with-root-edge';
|
|
|
4
4
|
|
|
5
5
|
const log = debug('pie-lib:graphing:sine');
|
|
6
6
|
|
|
7
|
-
const Parabola = withRootEdge(props => {
|
|
7
|
+
const Parabola = withRootEdge((props) => {
|
|
8
8
|
const { domain } = props.graphProps;
|
|
9
9
|
|
|
10
10
|
const { root, edge } = props;
|
|
@@ -13,14 +13,7 @@ const Parabola = withRootEdge(props => {
|
|
|
13
13
|
const dataPoints =
|
|
14
14
|
edge && edge.x === root.x
|
|
15
15
|
? []
|
|
16
|
-
: buildDataPoints(
|
|
17
|
-
domain.min,
|
|
18
|
-
domain.max,
|
|
19
|
-
root,
|
|
20
|
-
edge,
|
|
21
|
-
domain.step || interval,
|
|
22
|
-
parabolaFromTwoPoints(root, edge)
|
|
23
|
-
);
|
|
16
|
+
: buildDataPoints(domain.min, domain.max, root, edge, domain.step || interval, parabolaFromTwoPoints(root, edge));
|
|
24
17
|
log('dataPoints:', dataPoints);
|
|
25
18
|
return { root: props.root, edge: props.edge, dataPoints };
|
|
26
19
|
});
|
|
@@ -20,12 +20,12 @@ export const tool = () => ({
|
|
|
20
20
|
root: point,
|
|
21
21
|
edge: undefined,
|
|
22
22
|
closed: false,
|
|
23
|
-
building: true
|
|
23
|
+
building: true,
|
|
24
24
|
};
|
|
25
25
|
} else if (mark && !mark.root) {
|
|
26
26
|
throw new Error('no root - should never happen');
|
|
27
27
|
} else {
|
|
28
28
|
return { ...mark, edge: point, closed: true, building: false };
|
|
29
29
|
}
|
|
30
|
-
}
|
|
30
|
+
},
|
|
31
31
|
});
|
|
@@ -10,7 +10,7 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
10
10
|
export class Point extends React.Component {
|
|
11
11
|
static propTypes = {
|
|
12
12
|
graphProps: types.GraphPropsType.isRequired,
|
|
13
|
-
...ToolPropTypeFields
|
|
13
|
+
...ToolPropTypeFields,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
static defaultProps = {};
|
|
@@ -20,7 +20,7 @@ export class Point extends React.Component {
|
|
|
20
20
|
this.state = {};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
move = p => {
|
|
23
|
+
move = (p) => {
|
|
24
24
|
const mark = { ...this.state.mark, ...p };
|
|
25
25
|
this.setState({ mark });
|
|
26
26
|
};
|
|
@@ -44,7 +44,7 @@ export class Point extends React.Component {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
labelChange = label => {
|
|
47
|
+
labelChange = (label) => {
|
|
48
48
|
const { onChange } = this.props;
|
|
49
49
|
const update = { ...this.props.mark, label };
|
|
50
50
|
|
|
@@ -90,13 +90,13 @@ export class Point extends React.Component {
|
|
|
90
90
|
mark.hasOwnProperty('label') &&
|
|
91
91
|
ReactDOM.createPortal(
|
|
92
92
|
<MarkLabel
|
|
93
|
-
inputRef={r => (this.input = r)}
|
|
93
|
+
inputRef={(r) => (this.input = r)}
|
|
94
94
|
disabled={!labelModeEnabled}
|
|
95
95
|
mark={mark}
|
|
96
96
|
graphProps={graphProps}
|
|
97
97
|
onChange={this.labelChange}
|
|
98
98
|
/>,
|
|
99
|
-
labelNode
|
|
99
|
+
labelNode,
|
|
100
100
|
)}
|
|
101
101
|
</React.Fragment>
|
|
102
102
|
);
|
package/src/tools/point/index.js
CHANGED
|
@@ -53,7 +53,7 @@ export const swap = (arr, ...rest) => {
|
|
|
53
53
|
return acc;
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
[...arr]
|
|
56
|
+
[...arr],
|
|
57
57
|
);
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -76,18 +76,18 @@ export class RawBaseComponent extends React.Component {
|
|
|
76
76
|
labelNode: PropTypes.object,
|
|
77
77
|
labelModeEnabled: PropTypes.bool,
|
|
78
78
|
onChangeLabelProps: PropTypes.func,
|
|
79
|
-
onChangeProps: PropTypes.func
|
|
79
|
+
onChangeProps: PropTypes.func,
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
static defaultProps = {
|
|
83
|
-
points: []
|
|
83
|
+
points: [],
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
dragPoint = (index, from, to) => {
|
|
87
87
|
log('[dragPoint] from, to:', from, to);
|
|
88
88
|
const { onChange, points } = this.props;
|
|
89
89
|
const update = [...points];
|
|
90
|
-
const overlapPoint = !!(points || []).find(p => equalPoints(p, to));
|
|
90
|
+
const overlapPoint = !!(points || []).find((p) => equalPoints(p, to));
|
|
91
91
|
|
|
92
92
|
if (equalPoints(from, to) || overlapPoint) {
|
|
93
93
|
return;
|
|
@@ -155,15 +155,7 @@ export class RawBaseComponent extends React.Component {
|
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
clickPoint = (point, index, data) => {
|
|
158
|
-
const {
|
|
159
|
-
closed,
|
|
160
|
-
onClick,
|
|
161
|
-
isToolActive,
|
|
162
|
-
labelModeEnabled,
|
|
163
|
-
onChangeProps,
|
|
164
|
-
onChangeLabelProps,
|
|
165
|
-
points
|
|
166
|
-
} = this.props;
|
|
158
|
+
const { closed, onClick, isToolActive, labelModeEnabled, onChangeProps, onChangeLabelProps, points } = this.props;
|
|
167
159
|
|
|
168
160
|
if (labelModeEnabled) {
|
|
169
161
|
if (points && index === points.length) {
|
|
@@ -205,7 +197,7 @@ export class RawBaseComponent extends React.Component {
|
|
|
205
197
|
points,
|
|
206
198
|
middle,
|
|
207
199
|
labelNode,
|
|
208
|
-
labelModeEnabled
|
|
200
|
+
labelModeEnabled,
|
|
209
201
|
} = this.props;
|
|
210
202
|
const lines = buildLines(points, closed);
|
|
211
203
|
const common = { onDragStart, onDragStop, graphProps, disabled, correctness };
|
|
@@ -215,13 +207,13 @@ export class RawBaseComponent extends React.Component {
|
|
|
215
207
|
if (labelNode && middle && middle.hasOwnProperty('label')) {
|
|
216
208
|
polygonLabelNode = ReactDOM.createPortal(
|
|
217
209
|
<MarkLabel
|
|
218
|
-
inputRef={r => (this.input[polygonLabelIndex] = r)}
|
|
210
|
+
inputRef={(r) => (this.input[polygonLabelIndex] = r)}
|
|
219
211
|
disabled={!labelModeEnabled}
|
|
220
212
|
mark={middle}
|
|
221
213
|
graphProps={graphProps}
|
|
222
214
|
onChange={() => {}}
|
|
223
215
|
/>,
|
|
224
|
-
labelNode
|
|
216
|
+
labelNode,
|
|
225
217
|
);
|
|
226
218
|
}
|
|
227
219
|
|
|
@@ -267,15 +259,15 @@ export class RawBaseComponent extends React.Component {
|
|
|
267
259
|
labelNode && p.hasOwnProperty('label')
|
|
268
260
|
? ReactDOM.createPortal(
|
|
269
261
|
<MarkLabel
|
|
270
|
-
inputRef={r => (this.input[index] = r)}
|
|
262
|
+
inputRef={(r) => (this.input[index] = r)}
|
|
271
263
|
disabled={!labelModeEnabled}
|
|
272
264
|
mark={p}
|
|
273
265
|
graphProps={graphProps}
|
|
274
|
-
onChange={label => this.labelChange({ ...p, label }, index)}
|
|
266
|
+
onChange={(label) => this.labelChange({ ...p, label }, index)}
|
|
275
267
|
/>,
|
|
276
|
-
labelNode
|
|
268
|
+
labelNode,
|
|
277
269
|
)
|
|
278
|
-
: null
|
|
270
|
+
: null,
|
|
279
271
|
];
|
|
280
272
|
})}
|
|
281
273
|
</g>
|
|
@@ -288,7 +280,7 @@ export const BaseComponent = withStyles(() => ({}))(RawBaseComponent);
|
|
|
288
280
|
export default class Component extends React.Component {
|
|
289
281
|
static propTypes = {
|
|
290
282
|
...ToolPropTypeFields,
|
|
291
|
-
graphProps: types.GraphPropsType.isRequired
|
|
283
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
292
284
|
};
|
|
293
285
|
|
|
294
286
|
static defaultProps = {};
|
|
@@ -298,9 +290,9 @@ export default class Component extends React.Component {
|
|
|
298
290
|
this.state = {};
|
|
299
291
|
}
|
|
300
292
|
|
|
301
|
-
change = points => {
|
|
293
|
+
change = (points) => {
|
|
302
294
|
const {
|
|
303
|
-
mark: { middle }
|
|
295
|
+
mark: { middle },
|
|
304
296
|
} = this.props;
|
|
305
297
|
const mark = { ...this.state.mark, points };
|
|
306
298
|
|
|
@@ -312,13 +304,13 @@ export default class Component extends React.Component {
|
|
|
312
304
|
this.setState({ mark });
|
|
313
305
|
};
|
|
314
306
|
|
|
315
|
-
changeProps = points => {
|
|
307
|
+
changeProps = (points) => {
|
|
316
308
|
const mark = { ...this.props.mark, points };
|
|
317
309
|
|
|
318
310
|
this.props.onChange(this.props.mark, mark);
|
|
319
311
|
};
|
|
320
312
|
|
|
321
|
-
changeLabelProps = point => {
|
|
313
|
+
changeLabelProps = (point) => {
|
|
322
314
|
const { mark, onChange } = this.props;
|
|
323
315
|
const middle = { ...mark.middle, ...point };
|
|
324
316
|
|
|
@@ -356,15 +348,7 @@ export default class Component extends React.Component {
|
|
|
356
348
|
};
|
|
357
349
|
|
|
358
350
|
render() {
|
|
359
|
-
const {
|
|
360
|
-
coordinatesOnHover,
|
|
361
|
-
mark,
|
|
362
|
-
graphProps,
|
|
363
|
-
onClick,
|
|
364
|
-
isToolActive,
|
|
365
|
-
labelNode,
|
|
366
|
-
labelModeEnabled
|
|
367
|
-
} = this.props;
|
|
351
|
+
const { coordinatesOnHover, mark, graphProps, onClick, isToolActive, labelNode, labelModeEnabled } = this.props;
|
|
368
352
|
const { mark: stateMark } = this.state;
|
|
369
353
|
|
|
370
354
|
return (
|
|
@@ -18,7 +18,7 @@ export const addPointToArray = (point, arr) => {
|
|
|
18
18
|
if (closed) {
|
|
19
19
|
return { points: arr, closed };
|
|
20
20
|
} else {
|
|
21
|
-
const hasPoint = !!arr.find(p => equalPoints(p, point));
|
|
21
|
+
const hasPoint = !!arr.find((p) => equalPoints(p, point));
|
|
22
22
|
|
|
23
23
|
if (hasPoint) {
|
|
24
24
|
return { points: arr, closed: false };
|
|
@@ -41,12 +41,12 @@ export const tool = () => ({
|
|
|
41
41
|
type: 'polygon',
|
|
42
42
|
points: [point],
|
|
43
43
|
closed: false,
|
|
44
|
-
building: true
|
|
44
|
+
building: true,
|
|
45
45
|
};
|
|
46
46
|
} else {
|
|
47
47
|
const { closed, points } = addPointToArray(point, mark.points);
|
|
48
48
|
|
|
49
49
|
return { ...mark, closed, points, building: !closed };
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
52
|
});
|
|
@@ -15,12 +15,12 @@ class RawLine extends React.Component {
|
|
|
15
15
|
to: types.PointType,
|
|
16
16
|
graphProps: types.GraphPropsType.isRequired,
|
|
17
17
|
disabled: PropTypes.bool,
|
|
18
|
-
correctness: PropTypes.string
|
|
18
|
+
correctness: PropTypes.string,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
static defaultProps = {
|
|
22
22
|
from: {},
|
|
23
|
-
to: {}
|
|
23
|
+
to: {},
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
render() {
|
|
@@ -32,12 +32,7 @@ class RawLine extends React.Component {
|
|
|
32
32
|
y1={scale.y(from.y)}
|
|
33
33
|
x2={scale.x(to.x)}
|
|
34
34
|
y2={scale.y(to.y)}
|
|
35
|
-
className={classNames(
|
|
36
|
-
classes.line,
|
|
37
|
-
disabled && classes.disabled,
|
|
38
|
-
className,
|
|
39
|
-
classes[correctness]
|
|
40
|
-
)}
|
|
35
|
+
className={classNames(classes.line, disabled && classes.disabled, className, classes[correctness])}
|
|
41
36
|
{...rest}
|
|
42
37
|
/>
|
|
43
38
|
);
|
|
@@ -51,15 +46,15 @@ export const Line = withStyles(() => ({
|
|
|
51
46
|
stroke: 'transparent',
|
|
52
47
|
'&:hover': {
|
|
53
48
|
strokeWidth: 7,
|
|
54
|
-
stroke: color.secondary()
|
|
55
|
-
}
|
|
49
|
+
stroke: color.secondary(),
|
|
50
|
+
},
|
|
56
51
|
},
|
|
57
52
|
disabled: {
|
|
58
53
|
...disabled('stroke'),
|
|
59
|
-
strokeWidth: 2
|
|
54
|
+
strokeWidth: 2,
|
|
60
55
|
},
|
|
61
56
|
correct: correct('stoke'),
|
|
62
|
-
incorrect: incorrect('stroke')
|
|
57
|
+
incorrect: incorrect('stroke'),
|
|
63
58
|
}))(RawLine);
|
|
64
59
|
|
|
65
60
|
export default gridDraggable({
|
|
@@ -68,7 +63,7 @@ export default gridDraggable({
|
|
|
68
63
|
const area = utils.lineToArea(from, to);
|
|
69
64
|
return utils.bounds(area, domain, range);
|
|
70
65
|
},
|
|
71
|
-
anchorPoint: props => {
|
|
66
|
+
anchorPoint: (props) => {
|
|
72
67
|
const { from } = props;
|
|
73
68
|
return from;
|
|
74
69
|
},
|
|
@@ -76,7 +71,7 @@ export default gridDraggable({
|
|
|
76
71
|
const { from, to } = props;
|
|
77
72
|
return {
|
|
78
73
|
from: utils.point(from).add(utils.point(delta)),
|
|
79
|
-
to: utils.point(to).add(utils.point(delta))
|
|
74
|
+
to: utils.point(to).add(utils.point(delta)),
|
|
80
75
|
};
|
|
81
|
-
}
|
|
76
|
+
},
|
|
82
77
|
})(Line);
|
|
@@ -10,10 +10,10 @@ import { correct, disabled, incorrect } from '../shared/styles';
|
|
|
10
10
|
|
|
11
11
|
export const getPointString = (points, scale) => {
|
|
12
12
|
return (points || [])
|
|
13
|
-
.map(p => {
|
|
13
|
+
.map((p) => {
|
|
14
14
|
const scaledPoint = {
|
|
15
15
|
x: scale.x(p.x),
|
|
16
|
-
y: scale.y(p.y)
|
|
16
|
+
y: scale.y(p.y),
|
|
17
17
|
};
|
|
18
18
|
return `${scaledPoint.x},${scaledPoint.y}`;
|
|
19
19
|
})
|
|
@@ -28,24 +28,15 @@ export class RawPolygon extends React.Component {
|
|
|
28
28
|
points: PropTypes.arrayOf(types.PointType),
|
|
29
29
|
graphProps: types.GraphPropsType.isRequired,
|
|
30
30
|
closed: PropTypes.bool.isRequired,
|
|
31
|
-
correctness: PropTypes.string
|
|
31
|
+
correctness: PropTypes.string,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
static defaultProps = {
|
|
35
|
-
points: []
|
|
35
|
+
points: [],
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
render() {
|
|
39
|
-
const {
|
|
40
|
-
points,
|
|
41
|
-
classes,
|
|
42
|
-
className,
|
|
43
|
-
disabled,
|
|
44
|
-
correctness,
|
|
45
|
-
graphProps,
|
|
46
|
-
closed,
|
|
47
|
-
...rest
|
|
48
|
-
} = this.props;
|
|
39
|
+
const { points, classes, className, disabled, correctness, graphProps, closed, ...rest } = this.props;
|
|
49
40
|
const { scale } = graphProps;
|
|
50
41
|
|
|
51
42
|
const pointString = getPointString(points, scale);
|
|
@@ -58,7 +49,7 @@ export class RawPolygon extends React.Component {
|
|
|
58
49
|
!closed && classes.open,
|
|
59
50
|
disabled && classes.disabled,
|
|
60
51
|
classes[correctness],
|
|
61
|
-
className
|
|
52
|
+
className,
|
|
62
53
|
)}
|
|
63
54
|
{...rest}
|
|
64
55
|
/>
|
|
@@ -66,27 +57,27 @@ export class RawPolygon extends React.Component {
|
|
|
66
57
|
}
|
|
67
58
|
}
|
|
68
59
|
|
|
69
|
-
export const Polygon = withStyles(theme => ({
|
|
60
|
+
export const Polygon = withStyles((theme) => ({
|
|
70
61
|
closed: {
|
|
71
62
|
fill: fade(theme.palette.primary.light, 0.2), // TODO hardcoded color
|
|
72
63
|
strokeWidth: 2,
|
|
73
|
-
stroke: color.secondaryLight()
|
|
64
|
+
stroke: color.secondaryLight(),
|
|
74
65
|
},
|
|
75
66
|
open: {
|
|
76
67
|
fill: fade(theme.palette.primary.light, 0.0), // TODO hardcoded color
|
|
77
68
|
strokeWidth: 2,
|
|
78
69
|
stroke: color.secondaryLight(),
|
|
79
|
-
pointerEvents: 'none'
|
|
70
|
+
pointerEvents: 'none',
|
|
80
71
|
},
|
|
81
72
|
disabled: {
|
|
82
|
-
...disabled('stroke')
|
|
73
|
+
...disabled('stroke'),
|
|
83
74
|
},
|
|
84
75
|
correct: {
|
|
85
|
-
...correct('stroke')
|
|
76
|
+
...correct('stroke'),
|
|
86
77
|
},
|
|
87
78
|
incorrect: {
|
|
88
|
-
...incorrect('stroke')
|
|
89
|
-
}
|
|
79
|
+
...incorrect('stroke'),
|
|
80
|
+
},
|
|
90
81
|
}))(RawPolygon);
|
|
91
82
|
|
|
92
83
|
export default gridDraggable({
|
|
@@ -95,13 +86,13 @@ export default gridDraggable({
|
|
|
95
86
|
const area = utils.polygonToArea(points);
|
|
96
87
|
return utils.bounds(area, domain, range);
|
|
97
88
|
},
|
|
98
|
-
anchorPoint: props => {
|
|
89
|
+
anchorPoint: (props) => {
|
|
99
90
|
const { points } = props;
|
|
100
91
|
return points[0];
|
|
101
92
|
},
|
|
102
93
|
fromDelta: (props, delta) => {
|
|
103
94
|
const { points } = props;
|
|
104
95
|
|
|
105
|
-
return points.map(p => utils.point(p).add(utils.point(delta)));
|
|
106
|
-
}
|
|
96
|
+
return points.map((p) => utils.point(p).add(utils.point(delta)));
|
|
97
|
+
},
|
|
107
98
|
})(Polygon);
|