@pie-lib/graphing-solution-set 2.34.3-next.0 → 2.34.3-next.155
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 +7 -78
- package/esm/package.json +3 -0
- package/lib/axis/arrow.js +19 -55
- package/lib/axis/arrow.js.map +1 -1
- package/lib/axis/axes.js +103 -193
- 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 -60
- 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 +129 -203
- package/lib/graph-with-controls.js.map +1 -1
- package/lib/graph.js +61 -126
- package/lib/graph.js.map +1 -1
- package/lib/grid-setup.js +168 -224
- package/lib/grid-setup.js.map +1 -1
- package/lib/grid.js +29 -74
- package/lib/grid.js.map +1 -1
- package/lib/index.js +1 -12
- package/lib/index.js.map +1 -1
- package/lib/labels.js +84 -184
- package/lib/labels.js.map +1 -1
- package/lib/mark-label.js +39 -88
- package/lib/mark-label.js.map +1 -1
- package/lib/toggle-bar.js +155 -243
- package/lib/toggle-bar.js.map +1 -1
- package/lib/tool-menu.js +93 -200
- package/lib/tool-menu.js.map +1 -1
- package/lib/tools/index.js +2 -7
- package/lib/tools/index.js.map +1 -1
- package/lib/tools/line/component.js +48 -62
- 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/polygon/component.js +76 -173
- 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 -85
- package/lib/tools/polygon/line.js.map +1 -1
- package/lib/tools/polygon/polygon.js +62 -102
- package/lib/tools/polygon/polygon.js.map +1 -1
- package/lib/tools/shared/arrow-head.js +7 -20
- package/lib/tools/shared/arrow-head.js.map +1 -1
- package/lib/tools/shared/line/index.js +89 -185
- package/lib/tools/shared/line/index.js.map +1 -1
- package/lib/tools/shared/line/line-path.js +71 -95
- package/lib/tools/shared/line/line-path.js.map +1 -1
- package/lib/tools/shared/line/with-root-edge.js +22 -56
- package/lib/tools/shared/line/with-root-edge.js.map +1 -1
- package/lib/tools/shared/point/arrow-point.js +18 -45
- package/lib/tools/shared/point/arrow-point.js.map +1 -1
- package/lib/tools/shared/point/arrow.js +16 -42
- package/lib/tools/shared/point/arrow.js.map +1 -1
- package/lib/tools/shared/point/base-point.js +44 -58
- package/lib/tools/shared/point/base-point.js.map +1 -1
- package/lib/tools/shared/point/index.js +38 -52
- package/lib/tools/shared/point/index.js.map +1 -1
- package/lib/tools/shared/styles.js +8 -31
- package/lib/tools/shared/styles.js.map +1 -1
- package/lib/tools/shared/types.js +1 -5
- package/lib/tools/shared/types.js.map +1 -1
- package/lib/undo-redo.js +27 -67
- 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 +56 -131
- package/lib/utils.js.map +1 -1
- package/package.json +34 -23
- package/src/__tests__/graph-with-controls.test.jsx +23 -10
- package/src/__tests__/graph.test.jsx +36 -171
- package/src/__tests__/grid.test.jsx +9 -6
- package/src/__tests__/labels.test.jsx +11 -8
- package/src/__tests__/mark-label.test.jsx +15 -17
- package/src/__tests__/toggle-bar.test.jsx +46 -17
- package/src/__tests__/tool-menu.test.jsx +12 -8
- package/src/__tests__/undo-redo.test.jsx +9 -8
- package/src/__tests__/utils.js +3 -0
- package/src/axis/__tests__/arrow.test.jsx +21 -17
- package/src/axis/__tests__/axes.test.jsx +117 -155
- package/src/axis/arrow.jsx +7 -12
- package/src/axis/axes.jsx +41 -51
- package/src/coordinates-label.jsx +13 -18
- package/src/graph-with-controls.jsx +90 -93
- package/src/grid-setup.jsx +210 -206
- package/src/grid.jsx +2 -4
- package/src/labels.jsx +83 -124
- package/src/mark-label.jsx +14 -25
- package/src/toggle-bar.jsx +135 -163
- package/src/tool-menu.jsx +136 -195
- package/src/tools/line/__tests__/component.test.jsx +7 -7
- package/src/tools/line/component.jsx +29 -29
- package/src/tools/polygon/__tests__/component.test.jsx +13 -152
- package/src/tools/polygon/__tests__/line.test.jsx +7 -9
- package/src/tools/polygon/__tests__/polygon.test.jsx +8 -8
- package/src/tools/polygon/component.jsx +2 -4
- package/src/tools/polygon/line.jsx +26 -24
- package/src/tools/polygon/polygon.jsx +35 -40
- package/src/tools/shared/__tests__/arrow-head.test.jsx +16 -17
- package/src/tools/shared/line/__tests__/index.test.jsx +26 -163
- package/src/tools/shared/line/__tests__/line-path.test.jsx +9 -9
- package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +14 -24
- package/src/tools/shared/line/index.jsx +3 -3
- package/src/tools/shared/line/line-path.jsx +51 -48
- package/src/tools/shared/line/with-root-edge.jsx +1 -1
- package/src/tools/shared/point/__tests__/arrow-point.test.jsx +15 -11
- package/src/tools/shared/point/__tests__/base-point.test.jsx +14 -11
- package/src/tools/shared/point/base-point.jsx +33 -6
- package/src/tools/shared/point/index.jsx +30 -32
- package/src/undo-redo.jsx +16 -24
- package/src/__tests__/__snapshots__/graph-with-controls.test.jsx.snap +0 -114
- package/src/__tests__/__snapshots__/graph.test.jsx.snap +0 -213
- package/src/__tests__/__snapshots__/grid.test.jsx.snap +0 -54
- package/src/__tests__/__snapshots__/labels.test.jsx.snap +0 -30
- package/src/__tests__/__snapshots__/mark-label.test.jsx.snap +0 -37
- package/src/__tests__/__snapshots__/toggle-bar.test.jsx.snap +0 -7
- package/src/__tests__/__snapshots__/tool-menu.test.jsx.snap +0 -35
- package/src/__tests__/__snapshots__/undo-redo.test.jsx.snap +0 -15
- package/src/axis/__tests__/__snapshots__/arrow.test.jsx.snap +0 -33
- package/src/axis/__tests__/__snapshots__/axes.test.jsx.snap +0 -122
- package/src/tools/line/__tests__/__snapshots__/component.test.jsx.snap +0 -20
- package/src/tools/polygon/__tests__/__snapshots__/component.test.jsx.snap +0 -94
- package/src/tools/polygon/__tests__/__snapshots__/line.test.jsx.snap +0 -44
- package/src/tools/polygon/__tests__/__snapshots__/polygon.test.jsx.snap +0 -53
- package/src/tools/shared/__tests__/__snapshots__/arrow-head.test.jsx.snap +0 -32
- package/src/tools/shared/line/__tests__/__snapshots__/index.test.jsx.snap +0 -360
- package/src/tools/shared/line/__tests__/__snapshots__/line-path.test.jsx.snap +0 -57
- package/src/tools/shared/line/__tests__/__snapshots__/with-root-edge.test.jsx.snap +0 -63
- package/src/tools/shared/point/__tests__/__snapshots__/arrow-point.test.jsx.snap +0 -55
- package/src/tools/shared/point/__tests__/__snapshots__/base-point.test.jsx.snap +0 -43
|
@@ -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
|
import classNames from 'classnames';
|
|
5
5
|
import uniq from 'lodash/uniq';
|
|
6
6
|
import isString from 'lodash/isString';
|
|
@@ -9,11 +9,19 @@ import ToolMenu from './tool-menu';
|
|
|
9
9
|
import Graph, { graphPropTypes } from './graph';
|
|
10
10
|
import UndoRedo from './undo-redo';
|
|
11
11
|
import { allTools, toolsArr } from './tools';
|
|
12
|
-
import {
|
|
13
|
-
|
|
12
|
+
import {
|
|
13
|
+
Accordion,
|
|
14
|
+
AccordionDetails,
|
|
15
|
+
AccordionSummary,
|
|
16
|
+
Typography,
|
|
17
|
+
} from '@mui/material';
|
|
18
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
14
19
|
|
|
15
20
|
export const setToolbarAvailability = (toolbarTools) =>
|
|
16
|
-
toolsArr.map((tA) => ({
|
|
21
|
+
toolsArr.map((tA) => ({
|
|
22
|
+
...tA,
|
|
23
|
+
toolbar: !!toolbarTools.find((t) => t === tA.type),
|
|
24
|
+
})) || [];
|
|
17
25
|
|
|
18
26
|
export const toolIsAvailable = (tools, currentTool) =>
|
|
19
27
|
currentTool && tools && (tools.find((tool) => tool.type === currentTool.type) || {}).toolbar;
|
|
@@ -26,26 +34,66 @@ export const filterByValidToolTypes = (backgroundMarks) =>
|
|
|
26
34
|
export const filterByVisibleToolTypes = (toolbarTools, marks) =>
|
|
27
35
|
marks.filter((bM) => !!toolbarTools.find((tool) => tool === bM.type));
|
|
28
36
|
|
|
29
|
-
const getDefaultCurrentTool = (toolType) =>
|
|
37
|
+
const getDefaultCurrentTool = (toolType) =>
|
|
38
|
+
toolsArr.find((tool) => tool.type === toolType) || null;
|
|
30
39
|
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const GraphWithControlsRoot = styled('div')(() => ({
|
|
41
|
+
display: 'flex',
|
|
42
|
+
flexDirection: 'column',
|
|
43
|
+
width: 'min-content',
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
const Controls = styled('div')(() => ({
|
|
47
|
+
display: 'flex',
|
|
48
|
+
justifyContent: 'space-between',
|
|
49
|
+
padding: 'calc(1.25rem - 12px) calc(1.25rem - 12px) 1.25rem',
|
|
50
|
+
color: color.text(),
|
|
51
|
+
backgroundColor: '#9FA8DA',
|
|
52
|
+
'& button': {
|
|
53
|
+
fontSize: '0.875rem',
|
|
54
|
+
padding: '0.25rem .3rem',
|
|
55
|
+
width: '5rem',
|
|
56
|
+
},
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
const StyledAccordion = styled(Accordion)(() => ({
|
|
60
|
+
backgroundColor: color.primaryLight(),
|
|
61
|
+
width: '100%',
|
|
62
|
+
boxShadow: 'none',
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
const StyledAccordionSummary = styled(AccordionSummary)(({ theme }) => ({
|
|
66
|
+
padding: `0 ${theme.spacing(1)}`,
|
|
67
|
+
minHeight: '32px !important',
|
|
68
|
+
'& .MuiAccordionSummary-content': {
|
|
69
|
+
margin: '4px 0 !important',
|
|
70
|
+
},
|
|
71
|
+
}));
|
|
72
|
+
|
|
73
|
+
const StyledAccordionDetails = styled(AccordionDetails)(({ theme }) => ({
|
|
74
|
+
padding: 0,
|
|
75
|
+
marginTop: theme.spacing(1),
|
|
76
|
+
display: 'flex',
|
|
77
|
+
justifyContent: 'space-between',
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
const UndoRedoOuterDiv = styled('div')(() => ({
|
|
81
|
+
display: 'flex',
|
|
82
|
+
flexDirection: 'column',
|
|
83
|
+
marginTop: '.5rem',
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
const Collapsible = ({ children, title }) => (
|
|
87
|
+
<StyledAccordion square disableGutters>
|
|
88
|
+
<StyledAccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
89
|
+
<Typography variant="subtitle1">{title}</Typography>
|
|
90
|
+
</StyledAccordionSummary>
|
|
91
|
+
<StyledAccordionDetails>{children}</StyledAccordionDetails>
|
|
92
|
+
</StyledAccordion>
|
|
44
93
|
);
|
|
45
94
|
|
|
46
95
|
Collapsible.propTypes = {
|
|
47
|
-
|
|
48
|
-
children: PropTypes.array,
|
|
96
|
+
children: PropTypes.node,
|
|
49
97
|
title: PropTypes.string,
|
|
50
98
|
};
|
|
51
99
|
|
|
@@ -55,7 +103,7 @@ export class GraphWithControls extends React.Component {
|
|
|
55
103
|
onUndo: PropTypes.func,
|
|
56
104
|
onRedo: PropTypes.func,
|
|
57
105
|
onReset: PropTypes.func,
|
|
58
|
-
toolbarTools: PropTypes.arrayOf(PropTypes.string),
|
|
106
|
+
toolbarTools: PropTypes.arrayOf(PropTypes.string),
|
|
59
107
|
language: PropTypes.string,
|
|
60
108
|
};
|
|
61
109
|
|
|
@@ -71,7 +119,6 @@ export class GraphWithControls extends React.Component {
|
|
|
71
119
|
|
|
72
120
|
constructor(props) {
|
|
73
121
|
super(props);
|
|
74
|
-
|
|
75
122
|
this.state = {
|
|
76
123
|
currentTool: getDefaultCurrentTool(props.defaultTool),
|
|
77
124
|
labelModeEnabled: false,
|
|
@@ -80,23 +127,22 @@ export class GraphWithControls extends React.Component {
|
|
|
80
127
|
|
|
81
128
|
componentDidUpdate(prevProps) {
|
|
82
129
|
const { defaultTool } = this.props;
|
|
83
|
-
|
|
84
130
|
if (prevProps.defaultTool !== defaultTool) {
|
|
85
131
|
const currentTool = getDefaultCurrentTool(defaultTool);
|
|
86
|
-
|
|
87
132
|
this.setState({ currentTool });
|
|
88
133
|
}
|
|
89
134
|
}
|
|
90
135
|
|
|
91
|
-
changeCurrentTool = (tool, tools) =>
|
|
136
|
+
changeCurrentTool = (tool, tools) =>
|
|
137
|
+
this.setState({ currentTool: tools.find((t) => t.type === tool) });
|
|
92
138
|
|
|
93
|
-
toggleLabelMode = () =>
|
|
139
|
+
toggleLabelMode = () =>
|
|
140
|
+
this.setState((state) => ({ labelModeEnabled: !state.labelModeEnabled }));
|
|
94
141
|
|
|
95
142
|
render() {
|
|
96
143
|
let { currentTool, labelModeEnabled } = this.state;
|
|
97
144
|
const {
|
|
98
145
|
axesSettings,
|
|
99
|
-
classes,
|
|
100
146
|
className,
|
|
101
147
|
coordinatesOnHover,
|
|
102
148
|
collapsibleToolbar,
|
|
@@ -126,15 +172,11 @@ export class GraphWithControls extends React.Component {
|
|
|
126
172
|
onSolutionSetSelected,
|
|
127
173
|
onCustomReset,
|
|
128
174
|
} = this.props;
|
|
175
|
+
|
|
129
176
|
let { backgroundMarks, marks, toolbarTools } = this.props;
|
|
130
177
|
|
|
131
|
-
// make sure only valid tool types are kept (string) and without duplicates
|
|
132
178
|
toolbarTools = uniq(toolbarTools || []).filter((tT) => !!isString(tT)) || [];
|
|
133
|
-
|
|
134
|
-
// keep only the backgroundMarks that have valid types
|
|
135
179
|
backgroundMarks = filterByValidToolTypes(backgroundMarks || []);
|
|
136
|
-
|
|
137
|
-
// keep only the marks that have types which appear in toolbar
|
|
138
180
|
marks = filterByVisibleToolTypes(toolbarTools, marks || []);
|
|
139
181
|
|
|
140
182
|
if (gssLineData && gssLineData.lineA && marks[0] && marks[0].type === 'line')
|
|
@@ -143,14 +185,12 @@ export class GraphWithControls extends React.Component {
|
|
|
143
185
|
marks[1].fill = gssLineData.lineB.lineType;
|
|
144
186
|
|
|
145
187
|
const tools = setToolbarAvailability(toolbarTools);
|
|
146
|
-
|
|
147
|
-
// set current tool if there's no current tool or if the existing one is no longer available
|
|
148
188
|
if (!currentTool || !toolIsAvailable(tools, currentTool)) {
|
|
149
189
|
currentTool = getAvailableTool(tools);
|
|
150
190
|
}
|
|
151
191
|
|
|
152
192
|
const gssActions = gssLineData && (
|
|
153
|
-
|
|
193
|
+
<>
|
|
154
194
|
<ToolMenu
|
|
155
195
|
numberOfLines={gssLineData.numberOfLines}
|
|
156
196
|
gssLineData={gssLineData}
|
|
@@ -159,29 +199,28 @@ export class GraphWithControls extends React.Component {
|
|
|
159
199
|
language={language}
|
|
160
200
|
/>
|
|
161
201
|
{!disabled && (
|
|
162
|
-
<
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
202
|
+
<UndoRedoOuterDiv>
|
|
203
|
+
<UndoRedo
|
|
204
|
+
onUndo={onUndo}
|
|
205
|
+
onRedo={onRedo}
|
|
206
|
+
onReset={onCustomReset}
|
|
207
|
+
language={language}
|
|
208
|
+
/>
|
|
209
|
+
</UndoRedoOuterDiv>
|
|
169
210
|
)}
|
|
170
|
-
|
|
211
|
+
</>
|
|
171
212
|
);
|
|
172
213
|
|
|
173
214
|
return (
|
|
174
|
-
<
|
|
215
|
+
<GraphWithControlsRoot className={classNames(className)}>
|
|
175
216
|
{!disableToolbar && (
|
|
176
|
-
<
|
|
217
|
+
<Controls>
|
|
177
218
|
{collapsibleToolbar ? (
|
|
178
|
-
<Collapsible
|
|
179
|
-
{gssActions}
|
|
180
|
-
</Collapsible>
|
|
219
|
+
<Collapsible title={collapsibleToolbarTitle}>{gssActions}</Collapsible>
|
|
181
220
|
) : (
|
|
182
221
|
gssActions
|
|
183
222
|
)}
|
|
184
|
-
</
|
|
223
|
+
</Controls>
|
|
185
224
|
)}
|
|
186
225
|
|
|
187
226
|
<div ref={(r) => (this.labelNode = r)} />
|
|
@@ -213,51 +252,9 @@ export class GraphWithControls extends React.Component {
|
|
|
213
252
|
onSolutionSetSelected={onSolutionSetSelected}
|
|
214
253
|
disabled={!!disabled}
|
|
215
254
|
/>
|
|
216
|
-
</
|
|
255
|
+
</GraphWithControlsRoot>
|
|
217
256
|
);
|
|
218
257
|
}
|
|
219
258
|
}
|
|
220
259
|
|
|
221
|
-
|
|
222
|
-
graphWithControls: {
|
|
223
|
-
display: 'flex',
|
|
224
|
-
flexDirection: 'column',
|
|
225
|
-
width: 'min-content',
|
|
226
|
-
},
|
|
227
|
-
controls: {
|
|
228
|
-
display: 'flex',
|
|
229
|
-
justifyContent: 'space-between',
|
|
230
|
-
padding: 'calc(1.25rem - 12px) calc(1.25rem - 12px) 1.25rem',
|
|
231
|
-
color: color.text(),
|
|
232
|
-
backgroundColor: '#9FA8DA',
|
|
233
|
-
'& button': {
|
|
234
|
-
fontSize: '0.875rem',
|
|
235
|
-
padding: '0.25rem .3rem',
|
|
236
|
-
width: '5rem',
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
expansionPanel: {
|
|
240
|
-
backgroundColor: color.primaryLight(),
|
|
241
|
-
width: '100%',
|
|
242
|
-
},
|
|
243
|
-
summaryRoot: {
|
|
244
|
-
padding: `0 ${theme.spacing.unit}px`,
|
|
245
|
-
minHeight: '32px !important',
|
|
246
|
-
},
|
|
247
|
-
summaryContent: {
|
|
248
|
-
margin: '4px 0 !important',
|
|
249
|
-
},
|
|
250
|
-
details: {
|
|
251
|
-
padding: 0,
|
|
252
|
-
marginTop: theme.spacing.unit,
|
|
253
|
-
display: 'flex',
|
|
254
|
-
justifyContent: 'space-between',
|
|
255
|
-
},
|
|
256
|
-
undoRedoOuterDiv: {
|
|
257
|
-
display: 'flex',
|
|
258
|
-
flexDirection: 'column',
|
|
259
|
-
marginTop: '.5rem',
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
export default withStyles(styles)(GraphWithControls);
|
|
260
|
+
export default GraphWithControls;
|