@pie-lib/charting 5.34.0 → 5.36.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 +19 -4
- package/lib/actions-button.js +49 -88
- package/lib/actions-button.js.map +1 -1
- package/lib/axes.js +175 -233
- package/lib/axes.js.map +1 -1
- package/lib/bars/bar.js +13 -41
- package/lib/bars/bar.js.map +1 -1
- package/lib/bars/common/bars.js +55 -126
- package/lib/bars/common/bars.js.map +1 -1
- package/lib/bars/common/correct-check-icon.js +1 -6
- package/lib/bars/common/correct-check-icon.js.map +1 -1
- package/lib/bars/histogram.js +13 -41
- package/lib/bars/histogram.js.map +1 -1
- package/lib/chart-setup.js +110 -184
- package/lib/chart-setup.js.map +1 -1
- package/lib/chart-type.js +29 -38
- package/lib/chart-type.js.map +1 -1
- package/lib/chart-types.js +1 -10
- package/lib/chart-types.js.map +1 -1
- package/lib/chart.js +74 -146
- package/lib/chart.js.map +1 -1
- package/lib/common/correctness-indicators.js +74 -52
- package/lib/common/correctness-indicators.js.map +1 -1
- package/lib/common/drag-handle.js +67 -105
- package/lib/common/drag-handle.js.map +1 -1
- package/lib/common/drag-icon.js +6 -12
- package/lib/common/drag-icon.js.map +1 -1
- package/lib/common/styles.js +6 -24
- package/lib/common/styles.js.map +1 -1
- package/lib/grid.js +44 -81
- package/lib/grid.js.map +1 -1
- package/lib/index.js +0 -6
- package/lib/index.js.map +1 -1
- package/lib/key-legend.js +63 -87
- package/lib/key-legend.js.map +1 -1
- package/lib/line/common/drag-handle.js +69 -100
- package/lib/line/common/drag-handle.js.map +1 -1
- package/lib/line/common/line.js +44 -92
- package/lib/line/common/line.js.map +1 -1
- package/lib/line/line-cross.js +77 -87
- package/lib/line/line-cross.js.map +1 -1
- package/lib/line/line-dot.js +66 -78
- package/lib/line/line-dot.js.map +1 -1
- package/lib/mark-label.js +75 -117
- package/lib/mark-label.js.map +1 -1
- package/lib/plot/common/plot.js +76 -144
- package/lib/plot/common/plot.js.map +1 -1
- package/lib/plot/dot.js +31 -57
- package/lib/plot/dot.js.map +1 -1
- package/lib/plot/line.js +37 -62
- package/lib/plot/line.js.map +1 -1
- package/lib/tool-menu.js +48 -80
- package/lib/tool-menu.js.map +1 -1
- package/lib/utils.js +20 -77
- package/lib/utils.js.map +1 -1
- package/package.json +12 -9
- package/src/actions-button.jsx +36 -37
- package/src/axes.jsx +80 -75
- package/src/bars/common/bars.jsx +8 -23
- package/src/chart-setup.jsx +68 -78
- package/src/chart-type.js +26 -21
- package/src/chart.jsx +8 -20
- package/src/common/correctness-indicators.jsx +51 -13
- package/src/common/drag-handle.jsx +44 -59
- package/src/common/drag-icon.jsx +2 -2
- package/src/common/styles.js +1 -1
- package/src/grid.jsx +9 -13
- package/src/key-legend.jsx +62 -60
- package/src/line/common/drag-handle.jsx +57 -55
- package/src/line/common/line.jsx +17 -8
- package/src/line/line-cross.js +37 -12
- package/src/line/line-dot.js +30 -11
- package/src/mark-label.jsx +43 -44
- package/src/plot/common/plot.jsx +17 -22
- package/src/plot/dot.js +10 -3
- package/src/plot/line.js +14 -6
- package/src/tool-menu.jsx +20 -23
|
@@ -1,19 +1,62 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
5
|
|
|
6
6
|
import { gridDraggable, utils, types } from '@pie-lib/plot';
|
|
7
7
|
import { color } from '@pie-lib/render-ui';
|
|
8
8
|
import { disabled } from '../../common/styles';
|
|
9
9
|
|
|
10
|
+
const StyledDragHandle = styled('g')(({ theme }) => ({
|
|
11
|
+
color: 'black',
|
|
12
|
+
'& .handle': {
|
|
13
|
+
transition: 'fill 200ms linear, height 200ms linear',
|
|
14
|
+
'&.non-interactive': disabled('fill'),
|
|
15
|
+
},
|
|
16
|
+
'& .transparentHandle': {
|
|
17
|
+
height: '20px',
|
|
18
|
+
fill: 'transparent',
|
|
19
|
+
stroke: 'transparent',
|
|
20
|
+
},
|
|
21
|
+
'& .line': {
|
|
22
|
+
stroke: color.defaults.TEXT,
|
|
23
|
+
transition: 'fill 200ms linear, height 200ms linear',
|
|
24
|
+
'&.non-interactive': disabled('stroke'),
|
|
25
|
+
},
|
|
26
|
+
'& .disabledPoint': {
|
|
27
|
+
fill: color.defaults.BLACK + ' !important',
|
|
28
|
+
stroke: color.defaults.BLACK + ' !important',
|
|
29
|
+
},
|
|
30
|
+
'& .correctIcon': {
|
|
31
|
+
backgroundColor: color.correct(),
|
|
32
|
+
},
|
|
33
|
+
'& .incorrectIcon': {
|
|
34
|
+
backgroundColor: color.incorrectWithIcon(),
|
|
35
|
+
},
|
|
36
|
+
'& .correctnessIcon': {
|
|
37
|
+
borderRadius: theme.spacing(2),
|
|
38
|
+
color: color.defaults.WHITE,
|
|
39
|
+
fontSize: '16px',
|
|
40
|
+
width: '16px',
|
|
41
|
+
height: '16px',
|
|
42
|
+
padding: '2px',
|
|
43
|
+
border: `1px solid ${color.defaults.WHITE}`,
|
|
44
|
+
stroke: 'initial',
|
|
45
|
+
boxSizing: 'unset', // to override the default border-box in IBX
|
|
46
|
+
},
|
|
47
|
+
'& .smallIcon': {
|
|
48
|
+
fontSize: '10px',
|
|
49
|
+
width: '10px',
|
|
50
|
+
height: '10px',
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
|
|
10
54
|
class RawDragHandle extends React.Component {
|
|
11
55
|
static propTypes = {
|
|
12
56
|
x: PropTypes.number.isRequired,
|
|
13
57
|
y: PropTypes.number.isRequired,
|
|
14
58
|
width: PropTypes.number,
|
|
15
59
|
graphProps: types.GraphPropsType.isRequired,
|
|
16
|
-
classes: PropTypes.object.isRequired,
|
|
17
60
|
className: PropTypes.string,
|
|
18
61
|
interactive: PropTypes.bool,
|
|
19
62
|
CustomDraggableComponent: PropTypes.func,
|
|
@@ -28,7 +71,6 @@ class RawDragHandle extends React.Component {
|
|
|
28
71
|
x,
|
|
29
72
|
y,
|
|
30
73
|
graphProps,
|
|
31
|
-
classes,
|
|
32
74
|
className,
|
|
33
75
|
interactive,
|
|
34
76
|
CustomDraggableComponent,
|
|
@@ -38,62 +80,22 @@ class RawDragHandle extends React.Component {
|
|
|
38
80
|
const { scale } = graphProps;
|
|
39
81
|
|
|
40
82
|
return (
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
83
|
+
<StyledDragHandle>
|
|
84
|
+
<CustomDraggableComponent
|
|
85
|
+
scale={scale}
|
|
86
|
+
x={x}
|
|
87
|
+
y={y}
|
|
88
|
+
className={classNames(className, !interactive && 'non-interactive')}
|
|
89
|
+
correctness={correctness}
|
|
90
|
+
interactive={interactive}
|
|
91
|
+
{...rest}
|
|
92
|
+
/>
|
|
93
|
+
</StyledDragHandle>
|
|
51
94
|
);
|
|
52
95
|
}
|
|
53
96
|
}
|
|
54
97
|
|
|
55
|
-
export const DragHandle =
|
|
56
|
-
handle: {
|
|
57
|
-
transition: 'fill 200ms linear, height 200ms linear',
|
|
58
|
-
'&.non-interactive': disabled('fill'),
|
|
59
|
-
},
|
|
60
|
-
transparentHandle: {
|
|
61
|
-
height: '20px',
|
|
62
|
-
fill: 'transparent',
|
|
63
|
-
stroke: 'transparent',
|
|
64
|
-
},
|
|
65
|
-
line: {
|
|
66
|
-
stroke: color.defaults.TEXT,
|
|
67
|
-
transition: 'fill 200ms linear, height 200ms linear',
|
|
68
|
-
'&.non-interactive': disabled('stroke'),
|
|
69
|
-
},
|
|
70
|
-
disabledPoint: {
|
|
71
|
-
fill: color.defaults.BLACK + ' !important',
|
|
72
|
-
stroke: color.defaults.BLACK + ' !important',
|
|
73
|
-
},
|
|
74
|
-
correctIcon: {
|
|
75
|
-
backgroundColor: color.correct(),
|
|
76
|
-
},
|
|
77
|
-
incorrectIcon: {
|
|
78
|
-
backgroundColor: color.incorrectWithIcon(),
|
|
79
|
-
},
|
|
80
|
-
correctnessIcon: {
|
|
81
|
-
borderRadius: theme.spacing.unit * 2,
|
|
82
|
-
color: color.defaults.WHITE,
|
|
83
|
-
fontSize: '16px',
|
|
84
|
-
width: '16px',
|
|
85
|
-
height: '16px',
|
|
86
|
-
padding: '2px',
|
|
87
|
-
border: `1px solid ${color.defaults.WHITE}`,
|
|
88
|
-
stroke: 'initial',
|
|
89
|
-
boxSizing: 'unset', // to override the default border-box in IBX
|
|
90
|
-
},
|
|
91
|
-
smallIcon: {
|
|
92
|
-
fontSize: '10px',
|
|
93
|
-
width: '10px',
|
|
94
|
-
height: '10px',
|
|
95
|
-
},
|
|
96
|
-
}))(RawDragHandle);
|
|
98
|
+
export const DragHandle = RawDragHandle;
|
|
97
99
|
|
|
98
100
|
const DraggableHandle = gridDraggable({
|
|
99
101
|
axis: 'y',
|
package/src/line/common/line.jsx
CHANGED
|
@@ -4,7 +4,7 @@ import { LinePath } from '@vx/shape';
|
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { types } from '@pie-lib/plot';
|
|
6
6
|
import DraggableHandle, { DragHandle } from './drag-handle';
|
|
7
|
-
import {
|
|
7
|
+
import { styled } from '@mui/material/styles';
|
|
8
8
|
import isEqual from 'lodash/isEqual';
|
|
9
9
|
import { color } from '@pie-lib/render-ui';
|
|
10
10
|
|
|
@@ -23,11 +23,17 @@ const getData = (data, domain) => {
|
|
|
23
23
|
}));
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
const StyledLinePath = styled(LinePath)(() => ({
|
|
27
|
+
fill: 'transparent',
|
|
28
|
+
stroke: color.defaults.TERTIARY,
|
|
29
|
+
strokeWidth: 3,
|
|
30
|
+
transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
|
|
31
|
+
}));
|
|
32
|
+
|
|
26
33
|
export class RawLine extends React.Component {
|
|
27
34
|
static propTypes = {
|
|
28
35
|
onChange: PropTypes.func,
|
|
29
36
|
value: PropTypes.number,
|
|
30
|
-
classes: PropTypes.object,
|
|
31
37
|
label: PropTypes.string,
|
|
32
38
|
xBand: PropTypes.func,
|
|
33
39
|
index: PropTypes.number.isRequired,
|
|
@@ -78,18 +84,19 @@ export class RawLine extends React.Component {
|
|
|
78
84
|
};
|
|
79
85
|
|
|
80
86
|
render() {
|
|
81
|
-
const { graphProps, data,
|
|
87
|
+
const { graphProps, data, CustomDraggableComponent, defineChart, correctData } = this.props;
|
|
82
88
|
const { line: lineState, dragging } = this.state;
|
|
83
89
|
const { scale } = graphProps;
|
|
84
90
|
const lineToUse = dragging ? lineState : getData(data, graphProps.domain);
|
|
85
91
|
|
|
92
|
+
console.log('defineChart', lineToUse);
|
|
86
93
|
return (
|
|
87
94
|
<React.Fragment>
|
|
88
|
-
<
|
|
95
|
+
<StyledLinePath
|
|
89
96
|
data={lineToUse}
|
|
90
97
|
x={(d) => scale.x(d.x)}
|
|
91
98
|
y={(d) => scale.y(d.dragValue !== undefined ? d.dragValue : d.y)}
|
|
92
|
-
className=
|
|
99
|
+
className="line"
|
|
93
100
|
/>
|
|
94
101
|
{lineToUse &&
|
|
95
102
|
lineToUse.map((point, i) => {
|
|
@@ -97,6 +104,8 @@ export class RawLine extends React.Component {
|
|
|
97
104
|
const enableDraggable = defineChart || point.interactive;
|
|
98
105
|
const Component = enableDraggable ? DraggableHandle : DragHandle;
|
|
99
106
|
|
|
107
|
+
console.log('point', point);
|
|
108
|
+
|
|
100
109
|
return (
|
|
101
110
|
<Component
|
|
102
111
|
key={`point-${point.x}-${i}`}
|
|
@@ -120,14 +129,14 @@ export class RawLine extends React.Component {
|
|
|
120
129
|
}
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
const StyledLine =
|
|
124
|
-
line: {
|
|
132
|
+
const StyledLine = styled(RawLine)(() => ({
|
|
133
|
+
'& .line': {
|
|
125
134
|
fill: 'transparent',
|
|
126
135
|
stroke: color.defaults.TERTIARY,
|
|
127
136
|
strokeWidth: 3,
|
|
128
137
|
transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
|
|
129
138
|
},
|
|
130
|
-
}))
|
|
139
|
+
}));
|
|
131
140
|
|
|
132
141
|
export class Line extends React.Component {
|
|
133
142
|
static propTypes = {
|
package/src/line/line-cross.js
CHANGED
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { LinePath } from '@vx/shape';
|
|
4
4
|
import { Group } from '@vx/group';
|
|
5
|
-
import
|
|
5
|
+
import { styled } from '@mui/material/styles';
|
|
6
6
|
|
|
7
7
|
import { color } from '@pie-lib/render-ui';
|
|
8
8
|
import { dataToXBand } from '../utils';
|
|
@@ -10,18 +10,44 @@ import { types } from '@pie-lib/plot';
|
|
|
10
10
|
import RawLine from './common/line';
|
|
11
11
|
import { CorrectnessIndicator, SmallCorrectPointIndicator } from '../common/correctness-indicators';
|
|
12
12
|
|
|
13
|
+
const StyledLinePath = styled(LinePath)(() => ({
|
|
14
|
+
stroke: color.defaults.TEXT,
|
|
15
|
+
transition: 'fill 200ms linear, height 200ms linear',
|
|
16
|
+
'&.non-interactive': {
|
|
17
|
+
stroke: color.disabled?.() || '#ccc',
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const StyledGroup = styled(Group)(({ correctness, interactive }) => ({
|
|
22
|
+
stroke: color.defaults.TEXT,
|
|
23
|
+
transition: 'fill 200ms linear, height 200ms linear',
|
|
24
|
+
...(correctness && !interactive && {
|
|
25
|
+
fill: `${color.defaults.BLACK} !important`,
|
|
26
|
+
stroke: `${color.defaults.BLACK} !important`,
|
|
27
|
+
}),
|
|
28
|
+
'&.non-interactive': {
|
|
29
|
+
stroke: color.disabled?.() || '#ccc',
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
const StyledTransparentHandle = styled('circle')(() => ({
|
|
34
|
+
height: '20px',
|
|
35
|
+
fill: 'transparent',
|
|
36
|
+
stroke: 'transparent',
|
|
37
|
+
}));
|
|
38
|
+
|
|
13
39
|
const DraggableComponent = (props) => {
|
|
14
|
-
const {
|
|
40
|
+
const { className, scale, x, y, r, correctness, interactive, correctData, label, ...rest } = props;
|
|
15
41
|
const [hover, setHover] = useState(false);
|
|
16
42
|
|
|
17
43
|
const squareSize = r * 4;
|
|
18
44
|
const squareHalf = squareSize / 2;
|
|
19
45
|
const cx = scale.x(x);
|
|
20
46
|
const cy = scale.y(y);
|
|
21
|
-
|
|
47
|
+
|
|
22
48
|
return (
|
|
23
|
-
<
|
|
24
|
-
<
|
|
49
|
+
<StyledGroup className={className} correctness={correctness} interactive={interactive}>
|
|
50
|
+
<StyledLinePath
|
|
25
51
|
data={[
|
|
26
52
|
{ x: scale.x(x) - r, y: scale.y(y) + r },
|
|
27
53
|
{ x: scale.x(x) + r, y: scale.y(y) - r },
|
|
@@ -32,7 +58,7 @@ const DraggableComponent = (props) => {
|
|
|
32
58
|
strokeWidth={5}
|
|
33
59
|
style={{ pointerEvents: 'none' }}
|
|
34
60
|
/>
|
|
35
|
-
<
|
|
61
|
+
<StyledLinePath
|
|
36
62
|
data={[
|
|
37
63
|
{ x: scale.x(x) - r, y: scale.y(y) - r },
|
|
38
64
|
{ x: scale.x(x) + r, y: scale.y(y) + r },
|
|
@@ -55,11 +81,10 @@ const DraggableComponent = (props) => {
|
|
|
55
81
|
pointerEvents="none"
|
|
56
82
|
/>
|
|
57
83
|
)}
|
|
58
|
-
<
|
|
84
|
+
<StyledTransparentHandle
|
|
59
85
|
cx={cx}
|
|
60
86
|
cy={cy}
|
|
61
87
|
r={r * 2}
|
|
62
|
-
className={classNames(classes.transparentHandle)}
|
|
63
88
|
onMouseEnter={() => setHover(true)}
|
|
64
89
|
onMouseLeave={() => setHover(false)}
|
|
65
90
|
{...rest}
|
|
@@ -69,7 +94,6 @@ const DraggableComponent = (props) => {
|
|
|
69
94
|
scale={scale}
|
|
70
95
|
x={x}
|
|
71
96
|
y={y}
|
|
72
|
-
classes={classes}
|
|
73
97
|
r={r}
|
|
74
98
|
correctness={correctness}
|
|
75
99
|
interactive={interactive}
|
|
@@ -80,11 +104,10 @@ const DraggableComponent = (props) => {
|
|
|
80
104
|
x={x}
|
|
81
105
|
r={r}
|
|
82
106
|
correctness={correctness}
|
|
83
|
-
classes={classes}
|
|
84
107
|
correctData={correctData}
|
|
85
108
|
label={label}
|
|
86
109
|
/>
|
|
87
|
-
</
|
|
110
|
+
</StyledGroup>
|
|
88
111
|
);
|
|
89
112
|
};
|
|
90
113
|
|
|
@@ -94,11 +117,13 @@ DraggableComponent.propTypes = {
|
|
|
94
117
|
y: PropTypes.number,
|
|
95
118
|
r: PropTypes.number,
|
|
96
119
|
className: PropTypes.string,
|
|
97
|
-
classes: PropTypes.object,
|
|
98
120
|
correctness: PropTypes.shape({
|
|
99
121
|
value: PropTypes.string,
|
|
100
122
|
label: PropTypes.string,
|
|
101
123
|
}),
|
|
124
|
+
interactive: PropTypes.bool,
|
|
125
|
+
correctData: PropTypes.array,
|
|
126
|
+
label: PropTypes.string,
|
|
102
127
|
};
|
|
103
128
|
|
|
104
129
|
export class LineCross extends React.Component {
|
package/src/line/line-dot.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
|
|
5
5
|
import { types } from '@pie-lib/plot';
|
|
6
6
|
import { color } from '@pie-lib/render-ui';
|
|
@@ -8,12 +8,23 @@ import { dataToXBand } from '../utils';
|
|
|
8
8
|
import RawLine from './common/line';
|
|
9
9
|
import { CorrectnessIndicator, SmallCorrectPointIndicator } from '../common/correctness-indicators';
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
const StyledHandle = styled('circle')(({ correctness, interactive }) => ({
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const StyledTransparentHandle = styled('circle')(() => ({
|
|
17
|
+
height: '20px',
|
|
18
|
+
fill: 'transparent', // keep it invisible
|
|
19
|
+
stroke: 'none',
|
|
20
|
+
pointerEvents: 'auto', // allow drag events
|
|
21
|
+
}));
|
|
22
|
+
|
|
11
23
|
const DraggableComponent = ({
|
|
12
24
|
scale,
|
|
13
25
|
x,
|
|
14
26
|
y,
|
|
15
27
|
className,
|
|
16
|
-
classes,
|
|
17
28
|
r,
|
|
18
29
|
correctness,
|
|
19
30
|
interactive,
|
|
@@ -25,20 +36,28 @@ const DraggableComponent = ({
|
|
|
25
36
|
const allowRolloverEvent = !correctness && interactive;
|
|
26
37
|
|
|
27
38
|
return (
|
|
28
|
-
<g
|
|
29
|
-
|
|
39
|
+
<g
|
|
40
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
41
|
+
onMouseLeave={() => setIsHovered(false)}
|
|
42
|
+
onTouchStart={() => setIsHovered(true)}
|
|
43
|
+
onTouchEnd={() => setIsHovered(false)}
|
|
44
|
+
>
|
|
45
|
+
<StyledTransparentHandle
|
|
30
46
|
cx={scale.x(x)}
|
|
31
47
|
cy={scale.y(y)}
|
|
32
48
|
r={r * 3}
|
|
33
|
-
className={
|
|
34
|
-
|
|
49
|
+
className={className}
|
|
50
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
51
|
+
onMouseLeave={() => setIsHovered(false)}
|
|
35
52
|
{...rest}
|
|
36
53
|
/>
|
|
37
|
-
<
|
|
54
|
+
<StyledHandle
|
|
38
55
|
cx={scale.x(x)}
|
|
39
56
|
cy={scale.y(y)}
|
|
40
57
|
r={r}
|
|
41
|
-
className={
|
|
58
|
+
className={className}
|
|
59
|
+
correctness={correctness}
|
|
60
|
+
interactive={interactive}
|
|
42
61
|
{...rest}
|
|
43
62
|
/>
|
|
44
63
|
{/* show correctness indicators */}
|
|
@@ -46,7 +65,6 @@ const DraggableComponent = ({
|
|
|
46
65
|
scale={scale}
|
|
47
66
|
x={x}
|
|
48
67
|
y={y}
|
|
49
|
-
classes={classes}
|
|
50
68
|
r={r}
|
|
51
69
|
correctness={correctness}
|
|
52
70
|
interactive={interactive}
|
|
@@ -58,7 +76,6 @@ const DraggableComponent = ({
|
|
|
58
76
|
x={x}
|
|
59
77
|
r={r}
|
|
60
78
|
correctness={correctness}
|
|
61
|
-
classes={classes}
|
|
62
79
|
correctData={correctData}
|
|
63
80
|
label={label}
|
|
64
81
|
/>
|
|
@@ -85,11 +102,13 @@ DraggableComponent.propTypes = {
|
|
|
85
102
|
y: PropTypes.number,
|
|
86
103
|
r: PropTypes.number,
|
|
87
104
|
className: PropTypes.string,
|
|
88
|
-
classes: PropTypes.object,
|
|
89
105
|
correctness: PropTypes.shape({
|
|
90
106
|
value: PropTypes.string,
|
|
91
107
|
label: PropTypes.string,
|
|
92
108
|
}),
|
|
109
|
+
interactive: PropTypes.bool,
|
|
110
|
+
correctData: PropTypes.array,
|
|
111
|
+
label: PropTypes.string,
|
|
93
112
|
};
|
|
94
113
|
|
|
95
114
|
export class LineDot extends React.Component {
|
package/src/mark-label.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import {
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
import AutosizeInput from 'react-input-autosize';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
|
|
@@ -9,46 +9,46 @@ import { correct, incorrect, disabled } from './common/styles';
|
|
|
9
9
|
import { color } from '@pie-lib/render-ui';
|
|
10
10
|
import { renderMath } from '@pie-lib/math-rendering';
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
textAlign: 'center',
|
|
28
|
-
fontSize: theme.typography.fontSize + 2,
|
|
29
|
-
fontFamily: theme.typography.fontFamily,
|
|
30
|
-
color: color.primaryDark(),
|
|
31
|
-
paddingTop: theme.typography.fontSize / 2,
|
|
12
|
+
const StyledContainer = styled('div')({
|
|
13
|
+
display: 'flex',
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const StyledInput = styled('input')(({ theme }) => ({
|
|
19
|
+
float: 'right',
|
|
20
|
+
fontFamily: theme.typography.fontFamily,
|
|
21
|
+
fontSize: theme.typography.fontSize,
|
|
22
|
+
border: 'none',
|
|
23
|
+
'&.correct': correct('color'),
|
|
24
|
+
'&.incorrect': incorrect('color'),
|
|
25
|
+
'&.disabled': {
|
|
26
|
+
backgroundColor: 'transparent !important',
|
|
32
27
|
},
|
|
33
|
-
|
|
28
|
+
'&.error': { border: `2px solid ${theme.palette.error.main}` },
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
const StyledMathInput = styled('div')(({ theme }) => ({
|
|
32
|
+
pointerEvents: 'auto',
|
|
33
|
+
textAlign: 'center',
|
|
34
|
+
fontSize: theme.typography.fontSize + 2,
|
|
35
|
+
fontFamily: theme.typography.fontFamily,
|
|
36
|
+
color: color.primaryDark(),
|
|
37
|
+
paddingTop: theme.typography.fontSize / 2,
|
|
38
|
+
'&.disabled': {
|
|
34
39
|
...disabled('color'),
|
|
35
40
|
backgroundColor: 'transparent !important',
|
|
36
41
|
},
|
|
37
|
-
error: {
|
|
42
|
+
'&.error': {
|
|
38
43
|
border: `2px solid ${theme.palette.error.main}`,
|
|
39
44
|
},
|
|
40
|
-
correct: {
|
|
45
|
+
'&.correct': {
|
|
41
46
|
...correct('color'),
|
|
42
47
|
},
|
|
43
|
-
incorrect: {
|
|
48
|
+
'&.incorrect': {
|
|
44
49
|
...incorrect('color'),
|
|
45
50
|
},
|
|
46
|
-
|
|
47
|
-
display: 'flex',
|
|
48
|
-
flexDirection: 'column',
|
|
49
|
-
alignItems: 'center',
|
|
50
|
-
},
|
|
51
|
-
});
|
|
51
|
+
}));
|
|
52
52
|
|
|
53
53
|
function isFractionFormat(label) {
|
|
54
54
|
const trimmedLabel = label?.trim() || '';
|
|
@@ -85,7 +85,6 @@ export const MarkLabel = (props) => {
|
|
|
85
85
|
|
|
86
86
|
const {
|
|
87
87
|
mark,
|
|
88
|
-
classes,
|
|
89
88
|
disabled,
|
|
90
89
|
inputRef: externalInputRef,
|
|
91
90
|
barWidth,
|
|
@@ -139,20 +138,20 @@ export const MarkLabel = (props) => {
|
|
|
139
138
|
}, []);
|
|
140
139
|
|
|
141
140
|
return (
|
|
142
|
-
<
|
|
141
|
+
<StyledContainer>
|
|
143
142
|
{correctnessIndicator}
|
|
144
143
|
{isMathRendering() ? (
|
|
145
|
-
<
|
|
144
|
+
<StyledMathInput
|
|
146
145
|
ref={(r) => {
|
|
147
146
|
root = r;
|
|
148
147
|
externalInputRef(r);
|
|
149
148
|
}}
|
|
150
149
|
dangerouslySetInnerHTML={{ __html: getLabelMathFormat(label) }}
|
|
151
|
-
className={classNames(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
className={classNames({
|
|
151
|
+
disabled: disabled,
|
|
152
|
+
error: error,
|
|
153
|
+
correct: mark.editable && correctness?.label === 'correct',
|
|
154
|
+
incorrect: mark.editable && correctness?.label === 'incorrect',
|
|
156
155
|
})}
|
|
157
156
|
onClick={() => setIsEditing(true)}
|
|
158
157
|
style={{
|
|
@@ -163,17 +162,17 @@ export const MarkLabel = (props) => {
|
|
|
163
162
|
visibility: isHiddenLabel ? 'hidden' : 'unset',
|
|
164
163
|
marginTop: correctnessIndicator ? '24px' : '0',
|
|
165
164
|
}}
|
|
166
|
-
></
|
|
165
|
+
></StyledMathInput>
|
|
167
166
|
) : (
|
|
168
167
|
<AutosizeInput
|
|
169
168
|
inputRef={(r) => {
|
|
170
169
|
_ref(r);
|
|
171
170
|
externalInputRef(r);
|
|
172
171
|
}}
|
|
172
|
+
name='mark-label-input'
|
|
173
173
|
autoFocus={isEditing || autoFocus}
|
|
174
174
|
disabled={disabled}
|
|
175
175
|
inputClassName={classNames(
|
|
176
|
-
classes.input,
|
|
177
176
|
correctness && mark.editable ? correctness.label : null,
|
|
178
177
|
disabled && 'disabled',
|
|
179
178
|
error && 'error',
|
|
@@ -185,6 +184,7 @@ export const MarkLabel = (props) => {
|
|
|
185
184
|
boxSizing: 'border-box',
|
|
186
185
|
paddingLeft: 0,
|
|
187
186
|
paddingRight: 0,
|
|
187
|
+
border: 'none',
|
|
188
188
|
...extraStyle,
|
|
189
189
|
}}
|
|
190
190
|
value={label}
|
|
@@ -203,7 +203,7 @@ export const MarkLabel = (props) => {
|
|
|
203
203
|
onBlur={onChangeProp}
|
|
204
204
|
/>
|
|
205
205
|
)}
|
|
206
|
-
</
|
|
206
|
+
</StyledContainer>
|
|
207
207
|
);
|
|
208
208
|
};
|
|
209
209
|
|
|
@@ -213,7 +213,6 @@ MarkLabel.propTypes = {
|
|
|
213
213
|
error: PropTypes.any,
|
|
214
214
|
onChange: PropTypes.func,
|
|
215
215
|
graphProps: types.GraphPropsType,
|
|
216
|
-
classes: PropTypes.object,
|
|
217
216
|
inputRef: PropTypes.func,
|
|
218
217
|
mark: PropTypes.object,
|
|
219
218
|
barWidth: PropTypes.number,
|
|
@@ -227,4 +226,4 @@ MarkLabel.propTypes = {
|
|
|
227
226
|
correctnessIndicator: PropTypes.node,
|
|
228
227
|
};
|
|
229
228
|
|
|
230
|
-
export default
|
|
229
|
+
export default MarkLabel;
|