@pie-lib/graphing 2.31.6-esmbeta.2 → 2.32.0-mui-update.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 +42 -0
- package/lib/axis/arrow.js +19 -55
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +104 -186
- package/lib/axis/axes.js.map +1 -1
- package/lib/axis/index.js +1 -6
- package/lib/axis/index.js.map +1 -1
- package/lib/bg.js +21 -49
- package/lib/bg.js.map +1 -1
- package/lib/container/actions.js +2 -8
- package/lib/container/actions.js.map +1 -1
- package/lib/container/index.js +14 -59
- package/lib/container/index.js.map +1 -1
- package/lib/container/marks.js +1 -6
- package/lib/container/marks.js.map +1 -1
- package/lib/container/middleware.js +2 -8
- package/lib/container/middleware.js.map +1 -1
- package/lib/container/reducer.js +1 -8
- package/lib/container/reducer.js.map +1 -1
- package/lib/coordinates-label.js +23 -55
- package/lib/coordinates-label.js.map +1 -1
- package/lib/graph-with-controls.js +113 -183
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +59 -116
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js +161 -223
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js +28 -73
- package/lib/grid.js.map +1 -1
- package/lib/index.js +1 -13
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +41 -85
- package/lib/key-legend.js.map +1 -1
- package/lib/label-svg-icon.js +1 -7
- package/lib/label-svg-icon.js.map +1 -1
- package/lib/labels.js +61 -119
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +113 -163
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +158 -242
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +16 -48
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/absolute/component.js +4 -10
- package/lib/tools/absolute/component.js.map +1 -1
- package/lib/tools/absolute/index.js +3 -16
- package/lib/tools/absolute/index.js.map +1 -1
- package/lib/tools/circle/bg-circle.js +42 -92
- package/lib/tools/circle/bg-circle.js.map +1 -1
- package/lib/tools/circle/component.js +79 -165
- package/lib/tools/circle/component.js.map +1 -1
- package/lib/tools/circle/index.js +3 -13
- package/lib/tools/circle/index.js.map +1 -1
- package/lib/tools/exponential/component.js +4 -10
- package/lib/tools/exponential/component.js.map +1 -1
- package/lib/tools/exponential/index.js +3 -18
- package/lib/tools/exponential/index.js.map +1 -1
- package/lib/tools/index.js +3 -16
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +27 -48
- package/lib/tools/line/component.js.map +1 -1
- package/lib/tools/line/index.js +1 -6
- package/lib/tools/line/index.js.map +1 -1
- package/lib/tools/parabola/component.js +4 -10
- package/lib/tools/parabola/component.js.map +1 -1
- package/lib/tools/parabola/index.js +3 -16
- package/lib/tools/parabola/index.js.map +1 -1
- package/lib/tools/point/component.js +24 -71
- package/lib/tools/point/component.js.map +1 -1
- package/lib/tools/point/index.js +3 -11
- package/lib/tools/point/index.js.map +1 -1
- package/lib/tools/polygon/component.js +82 -183
- package/lib/tools/polygon/component.js.map +1 -1
- package/lib/tools/polygon/index.js +6 -23
- package/lib/tools/polygon/index.js.map +1 -1
- package/lib/tools/polygon/line.js +48 -91
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +65 -98
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/ray/component.js +41 -60
- package/lib/tools/ray/component.js.map +1 -1
- package/lib/tools/ray/index.js +1 -6
- package/lib/tools/ray/index.js.map +1 -1
- package/lib/tools/segment/component.js +25 -43
- package/lib/tools/segment/component.js.map +1 -1
- package/lib/tools/segment/index.js +1 -6
- package/lib/tools/segment/index.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +69 -28
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/icons/CorrectSVG.js +3 -8
- package/lib/tools/shared/icons/CorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/IncorrectSVG.js +3 -8
- package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -1
- package/lib/tools/shared/icons/MissingSVG.js +3 -8
- package/lib/tools/shared/icons/MissingSVG.js.map +1 -1
- package/lib/tools/shared/line/index.js +126 -187
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +70 -100
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +21 -55
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +23 -62
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +24 -52
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +54 -72
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +22 -57
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +10 -38
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js +2 -9
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/tools/sine/component.js +8 -19
- package/lib/tools/sine/component.js.map +1 -1
- package/lib/tools/sine/index.js +3 -16
- package/lib/tools/sine/index.js.map +1 -1
- package/lib/tools/vector/component.js +24 -44
- package/lib/tools/vector/component.js.map +1 -1
- package/lib/tools/vector/index.js +1 -6
- package/lib/tools/vector/index.js.map +1 -1
- package/lib/undo-redo.js +29 -69
- package/lib/undo-redo.js.map +1 -1
- package/lib/use-debounce.js +4 -11
- package/lib/use-debounce.js.map +1 -1
- package/lib/utils.js +51 -128
- package/lib/utils.js.map +1 -1
- package/package.json +16 -21
- package/src/axis/arrow.jsx +7 -12
- package/src/axis/axes.jsx +40 -45
- package/src/coordinates-label.jsx +13 -18
- package/src/graph-with-controls.jsx +52 -59
- package/src/grid-setup.jsx +204 -206
- package/src/grid.jsx +1 -3
- package/src/key-legend.jsx +52 -56
- package/src/labels.jsx +21 -30
- package/src/mark-label.jsx +83 -81
- package/src/toggle-bar.jsx +155 -166
- package/src/tools/circle/bg-circle.jsx +20 -28
- package/src/tools/circle/component.jsx +28 -63
- package/src/tools/line/component.jsx +22 -15
- package/src/tools/polygon/component.jsx +1 -2
- package/src/tools/polygon/line.jsx +28 -32
- package/src/tools/polygon/polygon.jsx +52 -45
- package/src/tools/ray/component.jsx +38 -25
- package/src/tools/segment/component.jsx +19 -18
- package/src/tools/shared/arrow-head.jsx +60 -7
- package/src/tools/shared/line/index.jsx +39 -2
- package/src/tools/shared/line/line-path.jsx +54 -58
- package/src/tools/shared/point/arrow-point.jsx +10 -24
- package/src/tools/shared/point/arrow.jsx +5 -11
- package/src/tools/shared/point/base-point.jsx +42 -19
- package/src/tools/shared/point/index.jsx +27 -44
- package/src/tools/vector/component.jsx +11 -16
- package/src/undo-redo.jsx +19 -21
- package/esm/index.js +0 -62821
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
3
|
+
import classNames from 'classnames';
|
|
4
4
|
import { BasePoint } from '../shared/point';
|
|
5
5
|
import BgCircle from './bg-circle';
|
|
6
6
|
import { getMiddleOfTwoPoints, point, equalPoints } from '../../utils';
|
|
7
|
-
import classNames from 'classnames';
|
|
8
7
|
import { types } from '@pie-lib/plot';
|
|
9
8
|
import { rootEdgeComponent } from '../shared/line/with-root-edge';
|
|
10
9
|
import ReactDOM from 'react-dom';
|
|
11
10
|
import MarkLabel from '../../mark-label';
|
|
12
11
|
import isEmpty from 'lodash/isEmpty';
|
|
13
12
|
import { color } from '@pie-lib/render-ui';
|
|
13
|
+
import { styled, keyframes } from '@mui/material/styles';
|
|
14
14
|
|
|
15
|
-
const opacityPulsate = (opacity) => ({
|
|
15
|
+
const opacityPulsate = (opacity) => keyframes({
|
|
16
16
|
'0%': { opacity: '0.0' },
|
|
17
17
|
'50%': { opacity },
|
|
18
18
|
'100%': { opacity: '0.0' },
|
|
@@ -26,7 +26,6 @@ const getRadius = (from, outer) => {
|
|
|
26
26
|
export class RawBaseCircle extends React.Component {
|
|
27
27
|
static propTypes = {
|
|
28
28
|
building: PropTypes.bool,
|
|
29
|
-
classes: PropTypes.object.isRequired,
|
|
30
29
|
className: PropTypes.string,
|
|
31
30
|
coordinatesOnHover: PropTypes.bool,
|
|
32
31
|
correctness: PropTypes.string,
|
|
@@ -53,12 +52,10 @@ export class RawBaseCircle extends React.Component {
|
|
|
53
52
|
const { middle, onChange } = this.props;
|
|
54
53
|
const { from, to } = point;
|
|
55
54
|
|
|
56
|
-
// because point.from.label and point.to.label can be different
|
|
57
55
|
if (!equalPoints(from, to)) {
|
|
58
56
|
if (middle) {
|
|
59
57
|
point.middle = { ...middle, ...getMiddleOfTwoPoints(from, to) };
|
|
60
58
|
}
|
|
61
|
-
|
|
62
59
|
onChange(point);
|
|
63
60
|
}
|
|
64
61
|
};
|
|
@@ -66,10 +63,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
66
63
|
dragFrom = (draggedFrom) => {
|
|
67
64
|
const { from, to } = this.props;
|
|
68
65
|
|
|
69
|
-
if (from.label)
|
|
70
|
-
draggedFrom.label = from.label;
|
|
71
|
-
}
|
|
72
|
-
|
|
66
|
+
if (from.label) draggedFrom.label = from.label;
|
|
73
67
|
if (!equalPoints(draggedFrom, to)) {
|
|
74
68
|
this.onChangePoint({ from: draggedFrom, to });
|
|
75
69
|
}
|
|
@@ -78,10 +72,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
78
72
|
dragTo = (draggedTo) => {
|
|
79
73
|
const { from, to } = this.props;
|
|
80
74
|
|
|
81
|
-
if (to.label)
|
|
82
|
-
draggedTo.label = to.label;
|
|
83
|
-
}
|
|
84
|
-
|
|
75
|
+
if (to.label) draggedTo.label = to.label;
|
|
85
76
|
if (!equalPoints(from, draggedTo)) {
|
|
86
77
|
this.onChangePoint({ from, to: draggedTo });
|
|
87
78
|
}
|
|
@@ -92,58 +83,36 @@ export class RawBaseCircle extends React.Component {
|
|
|
92
83
|
const diff = point(from).sub(point(draggedFrom));
|
|
93
84
|
const draggedTo = point(to).sub(diff);
|
|
94
85
|
|
|
95
|
-
if (from.label)
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (to.label) {
|
|
100
|
-
draggedTo.label = to.label;
|
|
101
|
-
}
|
|
86
|
+
if (from.label) draggedFrom.label = from.label;
|
|
87
|
+
if (to.label) draggedTo.label = to.label;
|
|
102
88
|
|
|
103
89
|
const updated = { from: draggedFrom, to: draggedTo };
|
|
104
|
-
|
|
105
90
|
if (middle) {
|
|
106
91
|
updated.middle = { ...middle, ...getMiddleOfTwoPoints(draggedFrom, draggedTo) };
|
|
107
92
|
}
|
|
108
93
|
|
|
109
94
|
this.setState(
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
draggedOuter: undefined,
|
|
113
|
-
isCircleDrag: false,
|
|
114
|
-
},
|
|
115
|
-
() => {
|
|
116
|
-
onChange(updated);
|
|
117
|
-
},
|
|
95
|
+
{ draggedroot: undefined, draggedOuter: undefined, isCircleDrag: false },
|
|
96
|
+
() => onChange(updated),
|
|
118
97
|
);
|
|
119
98
|
};
|
|
120
99
|
|
|
121
100
|
labelChange = (point, type) => {
|
|
122
101
|
const { changeMarkProps } = this.props;
|
|
123
102
|
const update = { ...point };
|
|
124
|
-
|
|
125
|
-
if (!point.label || isEmpty(point.label)) {
|
|
126
|
-
delete update.label;
|
|
127
|
-
}
|
|
128
|
-
|
|
103
|
+
if (!point.label || isEmpty(point.label)) delete update.label;
|
|
129
104
|
changeMarkProps({ [type]: update });
|
|
130
105
|
};
|
|
131
106
|
|
|
132
107
|
clickPoint = (point, type, data) => {
|
|
133
108
|
const { changeMarkProps, disabled, from, to, labelModeEnabled, limitLabeling, onClick } = this.props;
|
|
109
|
+
|
|
134
110
|
if (!labelModeEnabled) {
|
|
135
111
|
onClick(point || data);
|
|
136
112
|
return;
|
|
137
113
|
}
|
|
138
114
|
|
|
139
|
-
if (disabled)
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// limit labeling the points of the circle
|
|
144
|
-
if (limitLabeling) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
115
|
+
if (disabled || limitLabeling) return;
|
|
147
116
|
|
|
148
117
|
if (type === 'middle' && !point && from && to) {
|
|
149
118
|
point = { ...point, ...getMiddleOfTwoPoints(from, to) };
|
|
@@ -156,7 +125,6 @@ export class RawBaseCircle extends React.Component {
|
|
|
156
125
|
}
|
|
157
126
|
};
|
|
158
127
|
|
|
159
|
-
// IMPORTANT, do not remove
|
|
160
128
|
input = {};
|
|
161
129
|
|
|
162
130
|
render() {
|
|
@@ -165,9 +133,8 @@ export class RawBaseCircle extends React.Component {
|
|
|
165
133
|
to,
|
|
166
134
|
middle,
|
|
167
135
|
disabled,
|
|
168
|
-
classes,
|
|
169
|
-
coordinatesOnHover,
|
|
170
136
|
building,
|
|
137
|
+
coordinatesOnHover,
|
|
171
138
|
onDragStart,
|
|
172
139
|
onDragStop,
|
|
173
140
|
onClick,
|
|
@@ -176,10 +143,9 @@ export class RawBaseCircle extends React.Component {
|
|
|
176
143
|
labelNode,
|
|
177
144
|
labelModeEnabled,
|
|
178
145
|
} = this.props;
|
|
179
|
-
const common = { onDragStart, onDragStop, graphProps, onClick };
|
|
180
146
|
|
|
147
|
+
const common = { onDragStart, onDragStop, graphProps, onClick };
|
|
181
148
|
to = to || from;
|
|
182
|
-
|
|
183
149
|
const radius = getRadius(from, to);
|
|
184
150
|
|
|
185
151
|
let fromLabelNode = null;
|
|
@@ -187,7 +153,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
187
153
|
let circleLabelNode = null;
|
|
188
154
|
|
|
189
155
|
if (labelNode) {
|
|
190
|
-
if (from
|
|
156
|
+
if (from?.label !== undefined) {
|
|
191
157
|
fromLabelNode = ReactDOM.createPortal(
|
|
192
158
|
<MarkLabel
|
|
193
159
|
inputRef={(r) => (this.input.from = r)}
|
|
@@ -200,7 +166,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
200
166
|
);
|
|
201
167
|
}
|
|
202
168
|
|
|
203
|
-
if (to
|
|
169
|
+
if (to?.label !== undefined) {
|
|
204
170
|
toLabelNode = ReactDOM.createPortal(
|
|
205
171
|
<MarkLabel
|
|
206
172
|
inputRef={(r) => (this.input.to = r)}
|
|
@@ -213,7 +179,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
213
179
|
);
|
|
214
180
|
}
|
|
215
181
|
|
|
216
|
-
if (middle
|
|
182
|
+
if (middle?.label !== undefined) {
|
|
217
183
|
circleLabelNode = ReactDOM.createPortal(
|
|
218
184
|
<MarkLabel
|
|
219
185
|
inputRef={(r) => (this.input.middle = r)}
|
|
@@ -229,10 +195,10 @@ export class RawBaseCircle extends React.Component {
|
|
|
229
195
|
|
|
230
196
|
return (
|
|
231
197
|
<g>
|
|
232
|
-
<
|
|
198
|
+
<StyledBgCircle
|
|
233
199
|
disabled={building || disabled}
|
|
234
200
|
correctness={correctness}
|
|
235
|
-
className={classNames(building &&
|
|
201
|
+
className={classNames(building && 'bgCircleBuilding')}
|
|
236
202
|
x={from.x}
|
|
237
203
|
y={from.y}
|
|
238
204
|
radius={radius}
|
|
@@ -262,7 +228,7 @@ export class RawBaseCircle extends React.Component {
|
|
|
262
228
|
labelNode={labelNode}
|
|
263
229
|
x={from.x}
|
|
264
230
|
y={from.y}
|
|
265
|
-
className=
|
|
231
|
+
className="from"
|
|
266
232
|
onDrag={this.dragFrom}
|
|
267
233
|
{...common}
|
|
268
234
|
onClick={(data) => this.clickPoint(from, 'from', data)}
|
|
@@ -273,9 +239,10 @@ export class RawBaseCircle extends React.Component {
|
|
|
273
239
|
}
|
|
274
240
|
}
|
|
275
241
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
242
|
+
// MUI v5 styled() replaces withStyles
|
|
243
|
+
const StyledBgCircle = styled(BgCircle)(({ theme }) => ({
|
|
244
|
+
'&.outerLine': {
|
|
245
|
+
fill: 'rgba(0,0,0,0)',
|
|
279
246
|
stroke: color.defaults.BLACK,
|
|
280
247
|
strokeWidth: 4,
|
|
281
248
|
'&:hover': {
|
|
@@ -283,15 +250,13 @@ export const BaseCircle = withStyles(() => ({
|
|
|
283
250
|
stroke: color.defaults.PRIMARY_DARK,
|
|
284
251
|
},
|
|
285
252
|
},
|
|
286
|
-
|
|
287
|
-
bgCircleBuilding: {
|
|
253
|
+
'&.bgCircleBuilding': {
|
|
288
254
|
stroke: color.defaults.BLACK,
|
|
289
|
-
animation: '
|
|
290
|
-
animationIterationCount: 'infinite',
|
|
255
|
+
animation: `${opacityPulsate('0.3')} 2s ease-out infinite`,
|
|
291
256
|
opacity: 1,
|
|
292
257
|
},
|
|
293
|
-
|
|
294
|
-
}))(RawBaseCircle);
|
|
258
|
+
}));
|
|
295
259
|
|
|
260
|
+
export const BaseCircle = RawBaseCircle;
|
|
296
261
|
const Component = rootEdgeComponent(BaseCircle);
|
|
297
262
|
export default Component;
|
|
@@ -3,11 +3,11 @@ import React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { trig, types } from '@pie-lib/plot';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
7
6
|
import { ArrowMarker, genUid } from '../shared/arrow-head';
|
|
8
7
|
import { thinnerShapesNeeded, getAdjustedGraphLimits } from '../../utils';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const StyledArrowedLineRoot = styled('g')(({ theme }) => ({
|
|
11
11
|
line: styles.line(theme),
|
|
12
12
|
enabledArrow: styles.arrow(theme),
|
|
13
13
|
disabledArrow: styles.disabledArrow(theme),
|
|
@@ -19,23 +19,28 @@ const lineStyles = (theme) => ({
|
|
|
19
19
|
incorrectArrow: styles.incorrect(theme),
|
|
20
20
|
missing: styles.missing(theme, 'stroke'),
|
|
21
21
|
missingArrow: styles.missing(theme),
|
|
22
|
-
});
|
|
22
|
+
}));
|
|
23
23
|
|
|
24
24
|
export const ArrowedLine = (props) => {
|
|
25
25
|
const markerId = genUid();
|
|
26
|
-
const { className,
|
|
26
|
+
const { className, correctness, disabled, graphProps, from, to, markerId: propMarkerId, ...rest } = props;
|
|
27
27
|
const { scale } = graphProps;
|
|
28
28
|
const { domain, range } = getAdjustedGraphLimits(graphProps);
|
|
29
29
|
const [eFrom, eTo] = trig.edges(domain, range)(from, to);
|
|
30
30
|
const suffix = correctness || (disabled && 'disabled') || 'enabled';
|
|
31
|
+
const finalMarkerId = propMarkerId || markerId;
|
|
31
32
|
|
|
32
33
|
return (
|
|
33
|
-
<
|
|
34
|
+
<StyledArrowedLineRoot>
|
|
34
35
|
<defs>
|
|
35
36
|
<ArrowMarker
|
|
36
37
|
size={thinnerShapesNeeded(graphProps) ? 4 : 5}
|
|
37
|
-
id={`${
|
|
38
|
-
className={classNames(
|
|
38
|
+
id={`${finalMarkerId}-${suffix}`}
|
|
39
|
+
className={classNames(
|
|
40
|
+
suffix === 'enabled' ? 'enabledArrow' :
|
|
41
|
+
suffix === 'disabled' ? 'disabledArrow' :
|
|
42
|
+
`${suffix}Arrow`
|
|
43
|
+
)}
|
|
39
44
|
/>
|
|
40
45
|
</defs>
|
|
41
46
|
<line
|
|
@@ -43,18 +48,22 @@ export const ArrowedLine = (props) => {
|
|
|
43
48
|
y1={scale.y(eFrom.y)}
|
|
44
49
|
x2={scale.x(eTo.x)}
|
|
45
50
|
y2={scale.y(eTo.y)}
|
|
46
|
-
className={classNames(
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
className={classNames(
|
|
52
|
+
'line',
|
|
53
|
+
disabled && 'disabledSecondary',
|
|
54
|
+
correctness,
|
|
55
|
+
className
|
|
56
|
+
)}
|
|
57
|
+
markerEnd={`url(#${finalMarkerId}-${suffix})`}
|
|
58
|
+
markerStart={`url(#${finalMarkerId}-${suffix})`}
|
|
49
59
|
{...rest}
|
|
50
60
|
/>
|
|
51
|
-
</
|
|
61
|
+
</StyledArrowedLineRoot>
|
|
52
62
|
);
|
|
53
63
|
};
|
|
54
64
|
|
|
55
65
|
ArrowedLine.propTypes = {
|
|
56
66
|
className: PropTypes.string,
|
|
57
|
-
classes: PropTypes.object,
|
|
58
67
|
correctness: PropTypes.string,
|
|
59
68
|
disabled: PropTypes.bool,
|
|
60
69
|
graphProps: types.GraphPropsType,
|
|
@@ -63,9 +72,7 @@ ArrowedLine.propTypes = {
|
|
|
63
72
|
markerId: PropTypes.string,
|
|
64
73
|
};
|
|
65
74
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const Line = lineBase(StyledArrowedLine);
|
|
75
|
+
const Line = lineBase(ArrowedLine);
|
|
69
76
|
const Component = lineToolComponent(Line);
|
|
70
77
|
|
|
71
78
|
export default Component;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
4
3
|
import { ToolPropTypeFields } from '../shared/types';
|
|
5
4
|
import { BasePoint } from '../shared/point';
|
|
6
5
|
import chunk from 'lodash/chunk';
|
|
@@ -304,7 +303,7 @@ export class RawBaseComponent extends React.Component {
|
|
|
304
303
|
}
|
|
305
304
|
}
|
|
306
305
|
|
|
307
|
-
export const BaseComponent =
|
|
306
|
+
export const BaseComponent = RawBaseComponent;
|
|
308
307
|
|
|
309
308
|
export default class Component extends React.Component {
|
|
310
309
|
static propTypes = {
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { types, gridDraggable } from '@pie-lib/plot';
|
|
5
5
|
import { color } from '@pie-lib/render-ui';
|
|
6
6
|
import * as utils from '../../utils';
|
|
7
|
-
import classNames from 'classnames';
|
|
8
7
|
import { correct, disabled, disabledSecondary, incorrect, missing } from '../shared/styles';
|
|
9
8
|
|
|
9
|
+
const StyledLine = styled('line')(({ theme, disabled: isDisabled, correctness }) => ({
|
|
10
|
+
strokeWidth: 3,
|
|
11
|
+
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
12
|
+
stroke: 'transparent',
|
|
13
|
+
'&:hover': {
|
|
14
|
+
strokeWidth: 4,
|
|
15
|
+
stroke: color.defaults.BLACK,
|
|
16
|
+
},
|
|
17
|
+
...(isDisabled && {
|
|
18
|
+
...disabled('stroke'),
|
|
19
|
+
strokeWidth: 2,
|
|
20
|
+
}),
|
|
21
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
22
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
23
|
+
...(correctness === 'missing' && {
|
|
24
|
+
...missing('stroke'),
|
|
25
|
+
strokeWidth: 1,
|
|
26
|
+
strokeDasharray: '4 3',
|
|
27
|
+
}),
|
|
28
|
+
}));
|
|
29
|
+
|
|
10
30
|
class RawLine extends React.Component {
|
|
11
31
|
static propTypes = {
|
|
12
32
|
className: PropTypes.string,
|
|
13
|
-
classes: PropTypes.object,
|
|
14
33
|
from: types.PointType,
|
|
15
34
|
to: types.PointType,
|
|
16
35
|
graphProps: types.GraphPropsType.isRequired,
|
|
@@ -24,47 +43,24 @@ class RawLine extends React.Component {
|
|
|
24
43
|
};
|
|
25
44
|
|
|
26
45
|
render() {
|
|
27
|
-
const { graphProps,
|
|
46
|
+
const { graphProps, from, to, className, disabled, correctness, ...rest } = this.props;
|
|
28
47
|
const { scale } = graphProps;
|
|
29
48
|
return (
|
|
30
|
-
<
|
|
49
|
+
<StyledLine
|
|
31
50
|
x1={scale.x(from.x)}
|
|
32
51
|
y1={scale.y(from.y)}
|
|
33
52
|
x2={scale.x(to.x)}
|
|
34
53
|
y2={scale.y(to.y)}
|
|
35
|
-
className={
|
|
54
|
+
className={className}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
correctness={correctness}
|
|
36
57
|
{...rest}
|
|
37
58
|
/>
|
|
38
59
|
);
|
|
39
60
|
}
|
|
40
61
|
}
|
|
41
62
|
|
|
42
|
-
export const Line =
|
|
43
|
-
line: {
|
|
44
|
-
strokeWidth: 3,
|
|
45
|
-
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
46
|
-
stroke: 'transparent',
|
|
47
|
-
'&:hover': {
|
|
48
|
-
strokeWidth: 4,
|
|
49
|
-
stroke: color.defaults.BLACK,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
disabled: {
|
|
53
|
-
...disabled('stroke'),
|
|
54
|
-
strokeWidth: 2,
|
|
55
|
-
},
|
|
56
|
-
disabledSecondary: {
|
|
57
|
-
...disabledSecondary('stroke'),
|
|
58
|
-
strokeWidth: 2,
|
|
59
|
-
},
|
|
60
|
-
correct: correct('stroke'),
|
|
61
|
-
incorrect: incorrect('stroke'),
|
|
62
|
-
missing: {
|
|
63
|
-
...missing('stroke'),
|
|
64
|
-
strokeWidth: 1,
|
|
65
|
-
strokeDasharray: '4 3',
|
|
66
|
-
},
|
|
67
|
-
}))(RawLine);
|
|
63
|
+
export const Line = RawLine;
|
|
68
64
|
|
|
69
65
|
export default gridDraggable({
|
|
70
66
|
bounds: (props, { domain, range }) => {
|
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
3
|
+
import { alpha, styled } from '@mui/material/styles';
|
|
4
4
|
import { gridDraggable, types } from '@pie-lib/plot';
|
|
5
5
|
import * as utils from '../../utils';
|
|
6
|
-
import classNames from 'classnames';
|
|
7
6
|
import { color } from '@pie-lib/render-ui';
|
|
8
|
-
import { fade } from '@material-ui/core/styles/colorManipulator';
|
|
9
7
|
import { correct, disabled, incorrect, missing } from '../shared/styles';
|
|
10
8
|
|
|
9
|
+
const StyledPolygon = styled('polygon')(({ theme, disabled: isDisabled, correctness }) => ({
|
|
10
|
+
fill: alpha(theme.palette.primary.light, 0.2),
|
|
11
|
+
strokeWidth: 2,
|
|
12
|
+
stroke: color.defaults.BLACK,
|
|
13
|
+
...(isDisabled && disabled('stroke')),
|
|
14
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
15
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
16
|
+
...(correctness === 'missing' && {
|
|
17
|
+
...missing('stroke'),
|
|
18
|
+
stroke: 'inherit',
|
|
19
|
+
}),
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const StyledPolyline = styled('polyline')(({ theme, disabled: isDisabled, correctness }) => ({
|
|
23
|
+
fill: alpha(theme.palette.primary.light, 0.0),
|
|
24
|
+
strokeWidth: 2,
|
|
25
|
+
stroke: color.defaults.BLACK,
|
|
26
|
+
pointerEvents: 'none',
|
|
27
|
+
...(isDisabled && disabled('stroke')),
|
|
28
|
+
...(correctness === 'correct' && correct('stroke')),
|
|
29
|
+
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
30
|
+
...(correctness === 'missing' && {
|
|
31
|
+
...missing('stroke'),
|
|
32
|
+
stroke: 'inherit',
|
|
33
|
+
}),
|
|
34
|
+
}));
|
|
35
|
+
|
|
11
36
|
export const getPointString = (points, scale) => {
|
|
12
37
|
return (points || [])
|
|
13
38
|
.map((p) => {
|
|
@@ -22,7 +47,6 @@ export const getPointString = (points, scale) => {
|
|
|
22
47
|
|
|
23
48
|
export class RawPolygon extends React.Component {
|
|
24
49
|
static propTypes = {
|
|
25
|
-
classes: PropTypes.object,
|
|
26
50
|
className: PropTypes.string,
|
|
27
51
|
disabled: PropTypes.bool,
|
|
28
52
|
points: PropTypes.arrayOf(types.PointType),
|
|
@@ -36,53 +60,36 @@ export class RawPolygon extends React.Component {
|
|
|
36
60
|
};
|
|
37
61
|
|
|
38
62
|
render() {
|
|
39
|
-
const { points,
|
|
63
|
+
const { points, className, disabled, correctness, graphProps, closed, ...rest } = this.props;
|
|
40
64
|
const { scale } = graphProps;
|
|
41
65
|
|
|
42
66
|
const pointString = getPointString(points, scale);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
|
|
68
|
+
if (closed) {
|
|
69
|
+
return (
|
|
70
|
+
<StyledPolygon
|
|
71
|
+
points={pointString}
|
|
72
|
+
className={className}
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
correctness={correctness}
|
|
75
|
+
{...rest}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
} else {
|
|
79
|
+
return (
|
|
80
|
+
<StyledPolyline
|
|
81
|
+
points={pointString}
|
|
82
|
+
className={className}
|
|
83
|
+
disabled={disabled}
|
|
84
|
+
correctness={correctness}
|
|
85
|
+
{...rest}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
57
89
|
}
|
|
58
90
|
}
|
|
59
91
|
|
|
60
|
-
export const Polygon =
|
|
61
|
-
closed: {
|
|
62
|
-
fill: fade(theme.palette.primary.light, 0.2), // TODO hardcoded color
|
|
63
|
-
strokeWidth: 2,
|
|
64
|
-
stroke: color.defaults.BLACK,
|
|
65
|
-
},
|
|
66
|
-
open: {
|
|
67
|
-
fill: fade(theme.palette.primary.light, 0.0), // TODO hardcoded color
|
|
68
|
-
strokeWidth: 2,
|
|
69
|
-
stroke: color.defaults.BLACK,
|
|
70
|
-
pointerEvents: 'none',
|
|
71
|
-
},
|
|
72
|
-
disabled: {
|
|
73
|
-
...disabled('stroke'),
|
|
74
|
-
},
|
|
75
|
-
correct: {
|
|
76
|
-
...correct('stroke'),
|
|
77
|
-
},
|
|
78
|
-
incorrect: {
|
|
79
|
-
...incorrect('stroke'),
|
|
80
|
-
},
|
|
81
|
-
missing: {
|
|
82
|
-
...missing('stroke'),
|
|
83
|
-
stroke: 'inherit',
|
|
84
|
-
},
|
|
85
|
-
}))(RawPolygon);
|
|
92
|
+
export const Polygon = RawPolygon;
|
|
86
93
|
|
|
87
94
|
export default gridDraggable({
|
|
88
95
|
bounds: (props, { domain, range }) => {
|
|
@@ -3,39 +3,55 @@ import React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { ArrowMarker, genUid } from '../shared/arrow-head';
|
|
5
5
|
import { trig, types } from '@pie-lib/plot';
|
|
6
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
7
6
|
import classNames from 'classnames';
|
|
8
7
|
import { thinnerShapesNeeded, getAdjustedGraphLimits } from '../../utils';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
line:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
const StyledRayRoot = styled('g')(({ theme, disabled, correctness }) => ({
|
|
11
|
+
'& line': {
|
|
12
|
+
...styles.line(theme),
|
|
13
|
+
...(disabled && styles.disabledSecondary(theme)),
|
|
14
|
+
...(correctness === 'correct' && styles.correct(theme, 'stroke')),
|
|
15
|
+
...(correctness === 'incorrect' && styles.incorrect(theme, 'stroke')),
|
|
16
|
+
...(correctness === 'missing' && styles.missing(theme, 'stroke')),
|
|
17
|
+
},
|
|
18
|
+
'& .enabledArrow': {
|
|
19
|
+
...styles.arrow(theme),
|
|
20
|
+
},
|
|
21
|
+
'& .disabledArrow': {
|
|
22
|
+
...styles.disabledArrow(theme),
|
|
23
|
+
},
|
|
24
|
+
'& .correctArrow': {
|
|
25
|
+
...styles.correct(theme),
|
|
26
|
+
},
|
|
27
|
+
'& .incorrectArrow': {
|
|
28
|
+
...styles.incorrect(theme),
|
|
29
|
+
},
|
|
30
|
+
'& .missingArrow': {
|
|
31
|
+
...styles.missing(theme),
|
|
32
|
+
},
|
|
33
|
+
}));
|
|
23
34
|
|
|
24
35
|
export const RayLine = (props) => {
|
|
25
36
|
const markerId = genUid();
|
|
26
|
-
const { graphProps, from, to,
|
|
37
|
+
const { graphProps, from, to, disabled, correctness, className, markerId: propMarkerId, ...rest } = props;
|
|
27
38
|
const { scale } = graphProps;
|
|
28
39
|
const { domain, range } = getAdjustedGraphLimits(graphProps);
|
|
29
40
|
const [aToB] = trig.edges(domain, range)(from, to);
|
|
30
41
|
const suffix = correctness || (disabled && 'disabled') || 'enabled';
|
|
42
|
+
const finalMarkerId = propMarkerId || markerId;
|
|
31
43
|
|
|
32
44
|
return (
|
|
33
|
-
<
|
|
45
|
+
<StyledRayRoot disabled={disabled} correctness={correctness}>
|
|
34
46
|
<defs>
|
|
35
47
|
<ArrowMarker
|
|
36
48
|
size={thinnerShapesNeeded(graphProps) ? 4 : 5}
|
|
37
|
-
id={`${
|
|
38
|
-
className={classNames(
|
|
49
|
+
id={`${finalMarkerId}-${suffix}`}
|
|
50
|
+
className={classNames(
|
|
51
|
+
suffix === 'enabled' ? 'enabledArrow' :
|
|
52
|
+
suffix === 'disabled' ? 'disabledArrow' :
|
|
53
|
+
`${suffix}Arrow`
|
|
54
|
+
)}
|
|
39
55
|
/>
|
|
40
56
|
</defs>
|
|
41
57
|
<line
|
|
@@ -43,16 +59,15 @@ export const RayLine = (props) => {
|
|
|
43
59
|
y1={scale.y(from.y)}
|
|
44
60
|
x2={scale.x(aToB.x)}
|
|
45
61
|
y2={scale.y(aToB.y)}
|
|
62
|
+
className={className}
|
|
63
|
+
markerEnd={`url(#${finalMarkerId}-${suffix})`}
|
|
46
64
|
{...rest}
|
|
47
|
-
className={classNames(classes.line, disabled && classes.disabledSecondary, classes[correctness], className)}
|
|
48
|
-
markerEnd={`url(#${props.markerId || markerId}-${suffix})`}
|
|
49
65
|
/>
|
|
50
|
-
</
|
|
66
|
+
</StyledRayRoot>
|
|
51
67
|
);
|
|
52
68
|
};
|
|
53
69
|
|
|
54
70
|
RayLine.propTypes = {
|
|
55
|
-
classes: PropTypes.object,
|
|
56
71
|
className: PropTypes.string,
|
|
57
72
|
disabled: PropTypes.bool,
|
|
58
73
|
correctness: PropTypes.string,
|
|
@@ -62,9 +77,7 @@ RayLine.propTypes = {
|
|
|
62
77
|
markerId: PropTypes.string,
|
|
63
78
|
};
|
|
64
79
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const Ray = lineBase(StyledRay);
|
|
80
|
+
const Ray = lineBase(RayLine);
|
|
68
81
|
const Component = lineToolComponent(Ray);
|
|
69
82
|
|
|
70
83
|
export default Component;
|