@pie-lib/graphing 2.11.3-next.50 → 2.11.4
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
package/src/grid.jsx
CHANGED
|
@@ -11,7 +11,7 @@ export class Grid extends React.Component {
|
|
|
11
11
|
disabled: PropTypes.bool,
|
|
12
12
|
disabledAdditionalGrid: PropTypes.bool,
|
|
13
13
|
classes: PropTypes.object.isRequired,
|
|
14
|
-
graphProps: types.GraphPropsType.isRequired
|
|
14
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
getAdditionalGridProps = (rowTickValues, columnTickValues) => {
|
|
@@ -20,17 +20,17 @@ export class Grid extends React.Component {
|
|
|
20
20
|
scale,
|
|
21
21
|
size: { width, height },
|
|
22
22
|
domain,
|
|
23
|
-
range
|
|
24
|
-
}
|
|
23
|
+
range,
|
|
24
|
+
},
|
|
25
25
|
} = this.props;
|
|
26
26
|
const rowTickLabelValues = getTickValues({
|
|
27
27
|
...range,
|
|
28
|
-
step: range.labelStep
|
|
29
|
-
}).filter(value => rowTickValues.includes(value));
|
|
28
|
+
step: range.labelStep,
|
|
29
|
+
}).filter((value) => rowTickValues.includes(value));
|
|
30
30
|
const columnTickLabelValues = getTickValues({
|
|
31
31
|
...domain,
|
|
32
|
-
step: domain.labelStep
|
|
33
|
-
}).filter(value => columnTickValues.includes(value));
|
|
32
|
+
step: domain.labelStep,
|
|
33
|
+
}).filter((value) => columnTickValues.includes(value));
|
|
34
34
|
|
|
35
35
|
const minValueLength =
|
|
36
36
|
(rowTickLabelValues.length &&
|
|
@@ -49,8 +49,7 @@ export class Grid extends React.Component {
|
|
|
49
49
|
const horizontalDistanceToZero = scale.x(0);
|
|
50
50
|
const verticalDistanceToZero = scale.y(0);
|
|
51
51
|
const columnLabelLength = 28;
|
|
52
|
-
const rowStrokeDasharray = `${horizontalDistanceToZero -
|
|
53
|
-
rowLabelLength} ${rowLabelLength} ${width}`;
|
|
52
|
+
const rowStrokeDasharray = `${horizontalDistanceToZero - rowLabelLength} ${rowLabelLength} ${width}`;
|
|
54
53
|
const columnStrokeDasharray = `${verticalDistanceToZero} ${columnLabelLength} ${height}`;
|
|
55
54
|
|
|
56
55
|
const displayAdditionalGrid =
|
|
@@ -60,14 +59,13 @@ export class Grid extends React.Component {
|
|
|
60
59
|
columnTickLabelValues &&
|
|
61
60
|
rowTickLabelValues.length > 1 &&
|
|
62
61
|
columnTickLabelValues.length > 1 &&
|
|
63
|
-
(rowTickLabelValues.length !== rowTickValues.length ||
|
|
64
|
-
columnTickLabelValues.length !== columnTickValues.length);
|
|
62
|
+
(rowTickLabelValues.length !== rowTickValues.length || columnTickLabelValues.length !== columnTickValues.length);
|
|
65
63
|
|
|
66
64
|
const filteredColumnValues = columnTickLabelValues.filter(
|
|
67
|
-
value => value >= 0 || horizontalDistanceToZero - scale.x(value) > rowLabelLength
|
|
65
|
+
(value) => value >= 0 || horizontalDistanceToZero - scale.x(value) > rowLabelLength,
|
|
68
66
|
);
|
|
69
67
|
const filteredRowValues = rowTickLabelValues.filter(
|
|
70
|
-
value => value >= 0 || scale.y(value) - verticalDistanceToZero > columnLabelLength
|
|
68
|
+
(value) => value >= 0 || scale.y(value) - verticalDistanceToZero > columnLabelLength,
|
|
71
69
|
);
|
|
72
70
|
|
|
73
71
|
return {
|
|
@@ -75,7 +73,7 @@ export class Grid extends React.Component {
|
|
|
75
73
|
columnTickLabelValues: filteredColumnValues,
|
|
76
74
|
rowStrokeDasharray,
|
|
77
75
|
columnStrokeDasharray,
|
|
78
|
-
displayAdditionalGrid
|
|
76
|
+
displayAdditionalGrid,
|
|
79
77
|
};
|
|
80
78
|
};
|
|
81
79
|
|
|
@@ -85,7 +83,7 @@ export class Grid extends React.Component {
|
|
|
85
83
|
scale,
|
|
86
84
|
size: { height, width },
|
|
87
85
|
domain,
|
|
88
|
-
range
|
|
86
|
+
range,
|
|
89
87
|
} = graphProps;
|
|
90
88
|
const rowTickValues = getTickValues(range);
|
|
91
89
|
const columnTickValues = getTickValues(domain);
|
|
@@ -94,13 +92,13 @@ export class Grid extends React.Component {
|
|
|
94
92
|
columnTickLabelValues,
|
|
95
93
|
rowStrokeDasharray,
|
|
96
94
|
columnStrokeDasharray,
|
|
97
|
-
displayAdditionalGrid
|
|
95
|
+
displayAdditionalGrid,
|
|
98
96
|
} = this.getAdditionalGridProps(rowTickValues, columnTickValues);
|
|
99
97
|
|
|
100
98
|
return (
|
|
101
99
|
<>
|
|
102
100
|
<vx.Grid
|
|
103
|
-
innerRef={r => (this.grid = r)}
|
|
101
|
+
innerRef={(r) => (this.grid = r)}
|
|
104
102
|
xScale={scale.x}
|
|
105
103
|
yScale={scale.y}
|
|
106
104
|
width={width}
|
|
@@ -134,6 +132,6 @@ export class Grid extends React.Component {
|
|
|
134
132
|
|
|
135
133
|
export default withStyles(() => ({
|
|
136
134
|
grid: {
|
|
137
|
-
stroke: 'purple' // TODO hardcoded color
|
|
138
|
-
}
|
|
135
|
+
stroke: 'purple', // TODO hardcoded color
|
|
136
|
+
},
|
|
139
137
|
}))(Grid);
|
package/src/labels.jsx
CHANGED
|
@@ -10,7 +10,7 @@ const rotations = {
|
|
|
10
10
|
left: -90,
|
|
11
11
|
top: 0,
|
|
12
12
|
bottom: 0,
|
|
13
|
-
right: 90
|
|
13
|
+
right: 90,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export const getTransform = (side, width, height) => {
|
|
@@ -50,11 +50,11 @@ class RawLabel extends React.Component {
|
|
|
50
50
|
classes: PropTypes.object,
|
|
51
51
|
disabledLabel: PropTypes.bool,
|
|
52
52
|
placeholder: PropTypes.string,
|
|
53
|
-
graphProps: types.GraphPropsType.isRequired
|
|
53
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
static defaultProps = {
|
|
57
|
-
onChange: () => {}
|
|
57
|
+
onChange: () => {},
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
render() {
|
|
@@ -74,7 +74,7 @@ class RawLabel extends React.Component {
|
|
|
74
74
|
'italic',
|
|
75
75
|
'underline',
|
|
76
76
|
'strikethrough',
|
|
77
|
-
'math'
|
|
77
|
+
'math',
|
|
78
78
|
// 'languageCharacters'
|
|
79
79
|
];
|
|
80
80
|
|
|
@@ -92,16 +92,16 @@ class RawLabel extends React.Component {
|
|
|
92
92
|
className={cn(
|
|
93
93
|
{
|
|
94
94
|
[classes.bottomLabel]: side === 'bottom',
|
|
95
|
-
[classes.disabledAxisLabel]: disabledLabel
|
|
95
|
+
[classes.disabledAxisLabel]: disabledLabel,
|
|
96
96
|
},
|
|
97
|
-
classes.axisLabel
|
|
97
|
+
classes.axisLabel,
|
|
98
98
|
)}
|
|
99
99
|
markup={text || ''}
|
|
100
100
|
onChange={onChange}
|
|
101
101
|
placeholder={!disabledLabel && placeholder}
|
|
102
102
|
toolbarOpts={{
|
|
103
103
|
position: side === 'bottom' ? 'top' : 'bottom',
|
|
104
|
-
noBorder: true
|
|
104
|
+
noBorder: true,
|
|
105
105
|
}}
|
|
106
106
|
activePlugins={activePlugins}
|
|
107
107
|
/>
|
|
@@ -111,28 +111,28 @@ class RawLabel extends React.Component {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
const Label = withStyles(theme => ({
|
|
114
|
+
const Label = withStyles((theme) => ({
|
|
115
115
|
label: {
|
|
116
|
-
fill: color.secondary()
|
|
116
|
+
fill: color.secondary(),
|
|
117
117
|
},
|
|
118
118
|
axisLabel: {
|
|
119
119
|
fontSize: theme.typography.fontSize - 2,
|
|
120
120
|
textAlign: 'center',
|
|
121
|
-
padding: '0 4px'
|
|
121
|
+
padding: '0 4px',
|
|
122
122
|
},
|
|
123
123
|
disabledAxisLabel: {
|
|
124
|
-
pointerEvents: 'none'
|
|
124
|
+
pointerEvents: 'none',
|
|
125
125
|
},
|
|
126
126
|
bottomLabel: {
|
|
127
|
-
marginTop: '44px'
|
|
128
|
-
}
|
|
127
|
+
marginTop: '44px',
|
|
128
|
+
},
|
|
129
129
|
}))(RawLabel);
|
|
130
130
|
|
|
131
131
|
export const LabelType = {
|
|
132
132
|
left: PropTypes.string,
|
|
133
133
|
top: PropTypes.string,
|
|
134
134
|
bottom: PropTypes.string,
|
|
135
|
-
right: PropTypes.string
|
|
135
|
+
right: PropTypes.string,
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
export class Labels extends React.Component {
|
|
@@ -142,7 +142,7 @@ export class Labels extends React.Component {
|
|
|
142
142
|
disabledLabels: PropTypes.bool,
|
|
143
143
|
placeholders: PropTypes.object,
|
|
144
144
|
value: PropTypes.shape(LabelType),
|
|
145
|
-
graphProps: PropTypes.object
|
|
145
|
+
graphProps: PropTypes.object,
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
static defaultProps = {};
|
|
@@ -151,7 +151,7 @@ export class Labels extends React.Component {
|
|
|
151
151
|
const { value, onChange } = this.props;
|
|
152
152
|
const labels = {
|
|
153
153
|
...value,
|
|
154
|
-
[side]: newValue
|
|
154
|
+
[side]: newValue,
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
onChange(labels);
|
|
@@ -169,7 +169,7 @@ export class Labels extends React.Component {
|
|
|
169
169
|
disabledLabel={disabledLabels}
|
|
170
170
|
placeholder={placeholders.left}
|
|
171
171
|
graphProps={graphProps}
|
|
172
|
-
onChange={value => this.onChangeLabel(value, 'left')}
|
|
172
|
+
onChange={(value) => this.onChangeLabel(value, 'left')}
|
|
173
173
|
/>
|
|
174
174
|
<Label
|
|
175
175
|
key="top"
|
|
@@ -178,7 +178,7 @@ export class Labels extends React.Component {
|
|
|
178
178
|
disabledLabel={disabledLabels}
|
|
179
179
|
placeholder={placeholders.top}
|
|
180
180
|
graphProps={graphProps}
|
|
181
|
-
onChange={value => this.onChangeLabel(value, 'top')}
|
|
181
|
+
onChange={(value) => this.onChangeLabel(value, 'top')}
|
|
182
182
|
/>
|
|
183
183
|
<Label
|
|
184
184
|
key="bottom"
|
|
@@ -187,7 +187,7 @@ export class Labels extends React.Component {
|
|
|
187
187
|
disabledLabel={disabledLabels}
|
|
188
188
|
placeholder={placeholders.bottom}
|
|
189
189
|
graphProps={graphProps}
|
|
190
|
-
onChange={value => this.onChangeLabel(value, 'bottom')}
|
|
190
|
+
onChange={(value) => this.onChangeLabel(value, 'bottom')}
|
|
191
191
|
/>
|
|
192
192
|
<Label
|
|
193
193
|
key="right"
|
|
@@ -196,7 +196,7 @@ export class Labels extends React.Component {
|
|
|
196
196
|
disabledLabel={disabledLabels}
|
|
197
197
|
placeholder={placeholders.right}
|
|
198
198
|
graphProps={graphProps}
|
|
199
|
-
onChange={value => this.onChangeLabel(value, 'right')}
|
|
199
|
+
onChange={(value) => this.onChangeLabel(value, 'right')}
|
|
200
200
|
/>
|
|
201
201
|
</React.Fragment>
|
|
202
202
|
);
|
package/src/mark-label.jsx
CHANGED
|
@@ -7,7 +7,7 @@ import { types } from '@pie-lib/plot';
|
|
|
7
7
|
import { useDebounce } from './use-debounce';
|
|
8
8
|
import { color } from '@pie-lib/render-ui';
|
|
9
9
|
|
|
10
|
-
const styles = theme => ({
|
|
10
|
+
const styles = (theme) => ({
|
|
11
11
|
input: {
|
|
12
12
|
float: 'right',
|
|
13
13
|
padding: theme.spacing.unit * 0.5,
|
|
@@ -15,17 +15,17 @@ const styles = theme => ({
|
|
|
15
15
|
fontSize: theme.typography.fontSize,
|
|
16
16
|
border: `solid 1px ${color.secondary()}`,
|
|
17
17
|
borderRadius: '3px',
|
|
18
|
-
color: color.primaryDark()
|
|
18
|
+
color: color.primaryDark(),
|
|
19
19
|
},
|
|
20
20
|
disabled: {
|
|
21
21
|
border: `solid 1px ${color.primaryDark()}`,
|
|
22
|
-
background: color.background()
|
|
22
|
+
background: color.background(),
|
|
23
23
|
},
|
|
24
24
|
disabledMark: {
|
|
25
25
|
border: `solid 1px ${color.disabled()}`,
|
|
26
26
|
background: color.background(),
|
|
27
|
-
color: color.disabled()
|
|
28
|
-
}
|
|
27
|
+
color: color.disabled(),
|
|
28
|
+
},
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
export const position = (graphProps, mark, rect) => {
|
|
@@ -56,26 +56,26 @@ export const coordinates = (graphProps, mark, rect, position) => {
|
|
|
56
56
|
case 'top-left': {
|
|
57
57
|
return {
|
|
58
58
|
left: scale.x(mark.x) - shift - rect.width,
|
|
59
|
-
top: scale.y(mark.y) - shift - rect.height
|
|
59
|
+
top: scale.y(mark.y) - shift - rect.height,
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
case 'top-right': {
|
|
63
63
|
return {
|
|
64
64
|
left: scale.x(mark.x) + shift,
|
|
65
|
-
top: scale.y(mark.y) - shift - rect.height
|
|
65
|
+
top: scale.y(mark.y) - shift - rect.height,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
export const MarkLabel = props => {
|
|
71
|
+
export const MarkLabel = (props) => {
|
|
72
72
|
const [input, setInput] = useState(null);
|
|
73
|
-
const _ref = useCallback(node => setInput(node));
|
|
73
|
+
const _ref = useCallback((node) => setInput(node));
|
|
74
74
|
|
|
75
75
|
const { mark, graphProps, classes, disabled, inputRef: externalInputRef } = props;
|
|
76
76
|
const [label, setLabel] = useState(mark.label);
|
|
77
77
|
|
|
78
|
-
const onChange = e => setLabel(e.target.value);
|
|
78
|
+
const onChange = (e) => setLabel(e.target.value);
|
|
79
79
|
|
|
80
80
|
const debouncedLabel = useDebounce(label, 200);
|
|
81
81
|
|
|
@@ -98,14 +98,14 @@ export const MarkLabel = props => {
|
|
|
98
98
|
const style = {
|
|
99
99
|
position: 'absolute',
|
|
100
100
|
pointerEvents: 'auto',
|
|
101
|
-
...leftTop
|
|
101
|
+
...leftTop,
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
const disabledInput = disabled || mark.disabled;
|
|
105
105
|
|
|
106
106
|
return (
|
|
107
107
|
<AutosizeInput
|
|
108
|
-
inputRef={r => {
|
|
108
|
+
inputRef={(r) => {
|
|
109
109
|
_ref(r);
|
|
110
110
|
externalInputRef(r);
|
|
111
111
|
}}
|
|
@@ -124,7 +124,7 @@ MarkLabel.propTypes = {
|
|
|
124
124
|
graphProps: types.GraphPropsType,
|
|
125
125
|
classes: PropTypes.object,
|
|
126
126
|
inputRef: PropTypes.func,
|
|
127
|
-
mark: PropTypes.object
|
|
127
|
+
mark: PropTypes.object,
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
export default withStyles(styles)(MarkLabel);
|
package/src/toggle-bar.jsx
CHANGED
|
@@ -11,28 +11,28 @@ const buttonStyles = () => ({
|
|
|
11
11
|
root: {
|
|
12
12
|
color: color.text(),
|
|
13
13
|
'&:hover': {
|
|
14
|
-
backgroundColor: color.primary()
|
|
15
|
-
}
|
|
14
|
+
backgroundColor: color.primary(),
|
|
15
|
+
},
|
|
16
16
|
},
|
|
17
17
|
selected: {
|
|
18
18
|
backgroundColor: color.background(),
|
|
19
|
-
border: `1px solid ${color.secondary()}
|
|
19
|
+
border: `1px solid ${color.secondary()}`,
|
|
20
20
|
},
|
|
21
21
|
notSelected: {
|
|
22
22
|
'& span': {
|
|
23
|
-
color: color.primary()
|
|
23
|
+
color: color.primary(),
|
|
24
24
|
},
|
|
25
|
-
backgroundColor: color.background()
|
|
25
|
+
backgroundColor: color.background(),
|
|
26
26
|
},
|
|
27
27
|
disabled: {
|
|
28
28
|
'& span': {
|
|
29
|
-
color: color.primary()
|
|
29
|
+
color: color.primary(),
|
|
30
30
|
},
|
|
31
|
-
backgroundColor: color.disabled()
|
|
32
|
-
}
|
|
31
|
+
backgroundColor: color.disabled(),
|
|
32
|
+
},
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
export const MiniButton = withStyles(buttonStyles)(props => {
|
|
35
|
+
export const MiniButton = withStyles(buttonStyles)((props) => {
|
|
36
36
|
const { disabled, classes, className, selected, value, onClick } = props;
|
|
37
37
|
|
|
38
38
|
return (
|
|
@@ -58,7 +58,7 @@ MiniButton.propTypes = {
|
|
|
58
58
|
disabledClassName: PropTypes.string,
|
|
59
59
|
selected: PropTypes.bool,
|
|
60
60
|
value: PropTypes.string,
|
|
61
|
-
onClick: PropTypes.func
|
|
61
|
+
onClick: PropTypes.func,
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export class ToggleBar extends React.Component {
|
|
@@ -70,12 +70,12 @@ export class ToggleBar extends React.Component {
|
|
|
70
70
|
disabled: PropTypes.bool,
|
|
71
71
|
draggableTools: PropTypes.bool,
|
|
72
72
|
onChange: PropTypes.func,
|
|
73
|
-
onChangeToolsOrder: PropTypes.func
|
|
73
|
+
onChangeToolsOrder: PropTypes.func,
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
static defaultProps = {};
|
|
77
77
|
|
|
78
|
-
select = e => this.props.onChange(e.target.textContent);
|
|
78
|
+
select = (e) => this.props.onChange(e.target.textContent);
|
|
79
79
|
|
|
80
80
|
moveTool = (dragIndex, hoverIndex) => {
|
|
81
81
|
const { options, onChangeToolsOrder } = this.props;
|
|
@@ -123,30 +123,30 @@ export class ToggleBar extends React.Component {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
const styles = theme => ({
|
|
126
|
+
const styles = (theme) => ({
|
|
127
127
|
toolsContainer: {
|
|
128
128
|
display: 'flex',
|
|
129
|
-
flexWrap: 'wrap'
|
|
129
|
+
flexWrap: 'wrap',
|
|
130
130
|
},
|
|
131
131
|
button: {
|
|
132
132
|
marginRight: theme.spacing.unit / 2,
|
|
133
133
|
marginBottom: theme.spacing.unit / 2,
|
|
134
134
|
color: color.text(),
|
|
135
|
-
backgroundColor: color.background()
|
|
135
|
+
backgroundColor: color.background(),
|
|
136
136
|
},
|
|
137
137
|
under: {
|
|
138
138
|
position: 'absolute',
|
|
139
139
|
top: 0,
|
|
140
140
|
left: 0,
|
|
141
141
|
zIndex: -1,
|
|
142
|
-
pointerEvents: 'none'
|
|
142
|
+
pointerEvents: 'none',
|
|
143
143
|
},
|
|
144
144
|
wrapper: {
|
|
145
|
-
position: 'relative'
|
|
145
|
+
position: 'relative',
|
|
146
146
|
},
|
|
147
147
|
hidden: {
|
|
148
|
-
opacity: 0
|
|
149
|
-
}
|
|
148
|
+
opacity: 0,
|
|
149
|
+
},
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
export default withDragContext(withStyles(styles)(ToggleBar));
|
|
@@ -161,7 +161,7 @@ export class Item extends React.Component {
|
|
|
161
161
|
connectDragSource: PropTypes.func.isRequired,
|
|
162
162
|
connectDragPreview: PropTypes.func.isRequired,
|
|
163
163
|
connectDropTarget: PropTypes.func.isRequired,
|
|
164
|
-
isDragging: PropTypes.bool
|
|
164
|
+
isDragging: PropTypes.bool,
|
|
165
165
|
};
|
|
166
166
|
|
|
167
167
|
static defaultProps = {};
|
|
@@ -174,14 +174,12 @@ export class Item extends React.Component {
|
|
|
174
174
|
connectDropTarget,
|
|
175
175
|
connectDragPreview,
|
|
176
176
|
isDragging,
|
|
177
|
-
toolRef
|
|
177
|
+
toolRef,
|
|
178
178
|
} = this.props;
|
|
179
179
|
|
|
180
180
|
return (
|
|
181
181
|
<div className={classes.wrapper} ref={toolRef}>
|
|
182
|
-
{connectDragSource(
|
|
183
|
-
connectDropTarget(<div className={isDragging && classes.hidden}>{children}</div>)
|
|
184
|
-
)}
|
|
182
|
+
{connectDragSource(connectDropTarget(<div className={isDragging && classes.hidden}>{children}</div>))}
|
|
185
183
|
{connectDragPreview(<div className={classes.under}>{children}</div>)}
|
|
186
184
|
</div>
|
|
187
185
|
);
|
|
@@ -194,9 +192,9 @@ const itemSource = {
|
|
|
194
192
|
},
|
|
195
193
|
beginDrag(props) {
|
|
196
194
|
return {
|
|
197
|
-
index: props.index
|
|
195
|
+
index: props.index,
|
|
198
196
|
};
|
|
199
|
-
}
|
|
197
|
+
},
|
|
200
198
|
};
|
|
201
199
|
|
|
202
200
|
const itemTarget = {
|
|
@@ -223,19 +221,19 @@ const itemTarget = {
|
|
|
223
221
|
|
|
224
222
|
props.moveTool(dragIndex, hoverIndex);
|
|
225
223
|
monitor.getItem().index = hoverIndex;
|
|
226
|
-
}
|
|
224
|
+
},
|
|
227
225
|
};
|
|
228
226
|
|
|
229
|
-
const collectTarget = connect => ({ connectDropTarget: connect.dropTarget() });
|
|
227
|
+
const collectTarget = (connect) => ({ connectDropTarget: connect.dropTarget() });
|
|
230
228
|
|
|
231
229
|
const collectSource = (connect, monitor) => ({
|
|
232
230
|
connectDragSource: connect.dragSource(),
|
|
233
231
|
connectDragPreview: connect.dragPreview(),
|
|
234
|
-
isDragging: monitor.isDragging()
|
|
232
|
+
isDragging: monitor.isDragging(),
|
|
235
233
|
});
|
|
236
234
|
|
|
237
235
|
const DragTool = DropTarget(
|
|
238
236
|
DRAG_TYPE,
|
|
239
237
|
itemTarget,
|
|
240
|
-
collectTarget
|
|
238
|
+
collectTarget,
|
|
241
239
|
)(DragSource(DRAG_TYPE, itemSource, collectSource)(Item));
|
package/src/tool-menu.jsx
CHANGED
|
@@ -14,11 +14,11 @@ export class ToolMenu extends React.Component {
|
|
|
14
14
|
onChange: PropTypes.func,
|
|
15
15
|
onToggleLabelMode: PropTypes.func,
|
|
16
16
|
onChangeTools: PropTypes.func,
|
|
17
|
-
toolbarTools: PropTypes.arrayOf(PropTypes.string)
|
|
17
|
+
toolbarTools: PropTypes.arrayOf(PropTypes.string),
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
static defaultProps = {
|
|
21
|
-
toolbarTools: []
|
|
21
|
+
toolbarTools: [],
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
updateToolsOrder = (tools, showLabel) => {
|
|
@@ -39,13 +39,13 @@ export class ToolMenu extends React.Component {
|
|
|
39
39
|
draggableTools,
|
|
40
40
|
labelModeEnabled,
|
|
41
41
|
onToggleLabelMode,
|
|
42
|
-
onChange
|
|
42
|
+
onChange,
|
|
43
43
|
} = this.props;
|
|
44
44
|
let { toolbarTools } = this.props;
|
|
45
45
|
|
|
46
|
-
const showLabel = toolbarTools && toolbarTools.some(t => t === 'label');
|
|
46
|
+
const showLabel = toolbarTools && toolbarTools.some((t) => t === 'label');
|
|
47
47
|
|
|
48
|
-
toolbarTools = (toolbarTools || []).filter(tT => tT !== 'label');
|
|
48
|
+
toolbarTools = (toolbarTools || []).filter((tT) => tT !== 'label');
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
51
|
<div className={classNames(className)}>
|
|
@@ -55,16 +55,11 @@ export class ToolMenu extends React.Component {
|
|
|
55
55
|
options={toolbarTools}
|
|
56
56
|
selectedToolType={currentToolType}
|
|
57
57
|
onChange={onChange}
|
|
58
|
-
onChangeToolsOrder={tools => this.updateToolsOrder(tools, showLabel)}
|
|
58
|
+
onChangeToolsOrder={(tools) => this.updateToolsOrder(tools, showLabel)}
|
|
59
59
|
/>
|
|
60
60
|
|
|
61
61
|
{showLabel && (
|
|
62
|
-
<MiniButton
|
|
63
|
-
disabled={disabled}
|
|
64
|
-
value={'Label'}
|
|
65
|
-
onClick={onToggleLabelMode}
|
|
66
|
-
selected={labelModeEnabled}
|
|
67
|
-
/>
|
|
62
|
+
<MiniButton disabled={disabled} value={'Label'} onClick={onToggleLabelMode} selected={labelModeEnabled} />
|
|
68
63
|
)}
|
|
69
64
|
</div>
|
|
70
65
|
);
|
|
@@ -22,33 +22,18 @@ class RawCircle extends React.Component {
|
|
|
22
22
|
x: PropTypes.number.isRequired,
|
|
23
23
|
y: PropTypes.number.isRequired,
|
|
24
24
|
radius: PropTypes.number,
|
|
25
|
-
graphProps: types.GraphPropsType.isRequired
|
|
25
|
+
graphProps: types.GraphPropsType.isRequired,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
render() {
|
|
29
|
-
const {
|
|
30
|
-
classes,
|
|
31
|
-
disabled,
|
|
32
|
-
className,
|
|
33
|
-
correctness,
|
|
34
|
-
x,
|
|
35
|
-
y,
|
|
36
|
-
radius,
|
|
37
|
-
graphProps,
|
|
38
|
-
...rest
|
|
39
|
-
} = this.props;
|
|
29
|
+
const { classes, disabled, className, correctness, x, y, radius, graphProps, ...rest } = this.props;
|
|
40
30
|
const { scale } = graphProps;
|
|
41
31
|
const rx = Math.abs(scale.x(x + radius) - scale.x(x));
|
|
42
32
|
const ry = Math.abs(scale.y(y + radius) - scale.y(y));
|
|
43
33
|
|
|
44
34
|
return (
|
|
45
35
|
<ellipse
|
|
46
|
-
className={classNames(
|
|
47
|
-
classes.bgCircle,
|
|
48
|
-
disabled && classes.disabled,
|
|
49
|
-
classes[correctness],
|
|
50
|
-
className
|
|
51
|
-
)}
|
|
36
|
+
className={classNames(classes.bgCircle, disabled && classes.disabled, classes[correctness], className)}
|
|
52
37
|
cx={scale.x(x)}
|
|
53
38
|
cy={scale.y(y)}
|
|
54
39
|
rx={rx}
|
|
@@ -59,12 +44,12 @@ class RawCircle extends React.Component {
|
|
|
59
44
|
}
|
|
60
45
|
}
|
|
61
46
|
|
|
62
|
-
const applyStyle = fn => ({
|
|
47
|
+
const applyStyle = (fn) => ({
|
|
63
48
|
...fn('stroke'),
|
|
64
49
|
'&:hover': {
|
|
65
50
|
strokeWidth: 3,
|
|
66
|
-
...fn('stroke')
|
|
67
|
-
}
|
|
51
|
+
...fn('stroke'),
|
|
52
|
+
},
|
|
68
53
|
});
|
|
69
54
|
|
|
70
55
|
const styles = () => ({
|
|
@@ -75,12 +60,12 @@ const styles = () => ({
|
|
|
75
60
|
transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
|
|
76
61
|
'&:hover': {
|
|
77
62
|
strokeWidth: 6,
|
|
78
|
-
stroke: color.primaryDark()
|
|
79
|
-
}
|
|
63
|
+
stroke: color.primaryDark(),
|
|
64
|
+
},
|
|
80
65
|
},
|
|
81
66
|
disabled: applyStyle(disabled),
|
|
82
67
|
correct: applyStyle(correct),
|
|
83
|
-
incorrect: applyStyle(incorrect)
|
|
68
|
+
incorrect: applyStyle(incorrect),
|
|
84
69
|
});
|
|
85
70
|
|
|
86
71
|
export const BgCircle = withStyles(styles)(RawCircle);
|
|
@@ -91,12 +76,12 @@ export default gridDraggable({
|
|
|
91
76
|
const area = { left: x, top: y, bottom: y, right: x };
|
|
92
77
|
return utils.bounds(area, domain, range);
|
|
93
78
|
},
|
|
94
|
-
anchorPoint: props => {
|
|
79
|
+
anchorPoint: (props) => {
|
|
95
80
|
const { x, y } = props;
|
|
96
81
|
return { x, y };
|
|
97
82
|
},
|
|
98
83
|
fromDelta: (props, delta) => {
|
|
99
84
|
const newPoint = utils.point(props).add(utils.point(delta));
|
|
100
85
|
return newPoint;
|
|
101
|
-
}
|
|
86
|
+
},
|
|
102
87
|
})(BgCircle);
|