@pie-lib/graphing-solution-set 4.1.0-beta.9 → 5.0.0-next.36
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/dist/_virtual/_rolldown/runtime.js +20 -0
- package/dist/autosize-input.d.ts +10 -0
- package/dist/autosize-input.js +66 -0
- package/dist/axis/arrow.d.ts +13 -0
- package/dist/axis/arrow.js +34 -0
- package/dist/axis/axes.d.ts +132 -0
- package/dist/axis/axes.js +214 -0
- package/dist/axis/index.d.ts +10 -0
- package/dist/bg.d.ts +51 -0
- package/dist/bg.js +44 -0
- package/dist/container/actions.d.ts +15 -0
- package/dist/container/actions.js +7 -0
- package/dist/container/index.d.ts +58 -0
- package/dist/container/index.js +48 -0
- package/dist/container/marks.d.ts +10 -0
- package/dist/container/marks.js +11 -0
- package/dist/container/middleware.d.ts +10 -0
- package/dist/container/middleware.js +4 -0
- package/dist/container/reducer.d.ts +14 -0
- package/dist/container/reducer.js +7 -0
- package/dist/coordinates-label.d.ts +50 -0
- package/dist/coordinates-label.js +46 -0
- package/dist/graph-with-controls.d.ts +85 -0
- package/dist/graph-with-controls.js +155 -0
- package/dist/graph.d.ts +119 -0
- package/dist/graph.js +221 -0
- package/dist/grid-setup.d.ts +27 -0
- package/dist/grid-setup.js +307 -0
- package/dist/grid.d.ts +43 -0
- package/dist/grid.js +59 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +6 -0
- package/dist/labels.d.ts +73 -0
- package/dist/labels.js +134 -0
- package/dist/mark-label.d.ts +50 -0
- package/dist/mark-label.js +84 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Axis.js +67 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +66 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/axis/Ticks.js +39 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/constants/orientation.js +9 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/createPoint.js +14 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +13 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +16 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +8 -0
- package/dist/node_modules/.bun/@visx_axis@4.0.0_d84c32d47042070f/node_modules/@visx/axis/esm/utils/getTickPosition.js +14 -0
- package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/Grid.js +43 -0
- package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridColumns.js +46 -0
- package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/grids/GridRows.js +46 -0
- package/dist/node_modules/.bun/@visx_grid@4.0.0_d84c32d47042070f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +6 -0
- package/dist/node_modules/.bun/@visx_group@4.0.0_d84c32d47042070f/node_modules/@visx/group/esm/Group.js +17 -0
- package/dist/node_modules/.bun/@visx_point@4.0.0/node_modules/@visx/point/esm/Point.js +20 -0
- package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +10 -0
- package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/getTicks.js +7 -0
- package/dist/node_modules/.bun/@visx_scale@4.0.0/node_modules/@visx/scale/esm/utils/toString.js +6 -0
- package/dist/node_modules/.bun/@visx_shape@4.0.0_d84c32d47042070f/node_modules/@visx/shape/esm/shapes/Line.js +27 -0
- package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/Text.js +27 -0
- package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/hooks/useText.js +68 -0
- package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/getStringWidth.js +19 -0
- package/dist/node_modules/.bun/@visx_text@4.0.0_d84c32d47042070f/node_modules/@visx/text/esm/util/memoize.js +13 -0
- package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +32 -0
- package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +33 -0
- package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +32 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
- package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +37 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +509 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +108 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +31 -0
- package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +45 -0
- package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +49 -0
- package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +34 -0
- package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +185 -0
- package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +198 -0
- package/dist/toggle-bar.d.ts +40 -0
- package/dist/tool-menu.d.ts +21 -0
- package/dist/tool-menu.js +188 -0
- package/dist/tools/index.d.ts +17 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/line/component.d.ts +113 -0
- package/dist/tools/line/component.js +58 -0
- package/dist/tools/line/index.d.ts +13 -0
- package/dist/tools/line/index.js +6 -0
- package/dist/tools/polygon/component.d.ts +117 -0
- package/dist/tools/polygon/component.js +194 -0
- package/dist/tools/polygon/index.d.ts +19 -0
- package/dist/tools/polygon/index.js +55 -0
- package/dist/tools/polygon/line.d.ts +125 -0
- package/dist/tools/polygon/polygon.d.ts +122 -0
- package/dist/tools/polygon/polygon.js +62 -0
- package/dist/tools/shared/arrow-head.d.ts +43 -0
- package/dist/tools/shared/arrow-head.js +37 -0
- package/dist/tools/shared/line/index.d.ts +240 -0
- package/dist/tools/shared/line/index.js +320 -0
- package/dist/tools/shared/line/line-path.d.ts +57 -0
- package/dist/tools/shared/line/with-root-edge.d.ts +143 -0
- package/dist/tools/shared/point/arrow-point.d.ts +57 -0
- package/dist/tools/shared/point/arrow-point.js +47 -0
- package/dist/tools/shared/point/arrow.d.ts +46 -0
- package/dist/tools/shared/point/arrow.js +36 -0
- package/dist/tools/shared/point/base-point.d.ts +50 -0
- package/dist/tools/shared/point/base-point.js +88 -0
- package/dist/tools/shared/point/index.d.ts +217 -0
- package/dist/tools/shared/point/index.js +51 -0
- package/dist/tools/shared/styles.d.ts +24 -0
- package/dist/tools/shared/styles.js +17 -0
- package/dist/tools/shared/types.d.ts +15 -0
- package/dist/tools/shared/types.js +10 -0
- package/dist/undo-redo.d.ts +20 -0
- package/dist/undo-redo.js +33 -0
- package/dist/use-debounce.d.ts +9 -0
- package/dist/use-debounce.js +13 -0
- package/dist/utils.d.ts +58 -0
- package/dist/utils.js +72 -0
- package/package.json +52 -42
- package/CHANGELOG.json +0 -1
- package/CHANGELOG.md +0 -449
- package/lib/axis/arrow.js +0 -79
- package/lib/axis/arrow.js.map +0 -1
- package/lib/axis/axes.js +0 -327
- package/lib/axis/axes.js.map +0 -1
- package/lib/axis/index.js +0 -21
- package/lib/axis/index.js.map +0 -1
- package/lib/bg.js +0 -114
- package/lib/bg.js.map +0 -1
- package/lib/container/actions.js +0 -18
- package/lib/container/actions.js.map +0 -1
- package/lib/container/index.js +0 -129
- package/lib/container/index.js.map +0 -1
- package/lib/container/marks.js +0 -22
- package/lib/container/marks.js.map +0 -1
- package/lib/container/middleware.js +0 -19
- package/lib/container/middleware.js.map +0 -1
- package/lib/container/reducer.js +0 -18
- package/lib/container/reducer.js.map +0 -1
- package/lib/coordinates-label.js +0 -77
- package/lib/coordinates-label.js.map +0 -1
- package/lib/graph-with-controls.js +0 -297
- package/lib/graph-with-controls.js.map +0 -1
- package/lib/graph.js +0 -353
- package/lib/graph.js.map +0 -1
- package/lib/grid-setup.js +0 -414
- package/lib/grid-setup.js.map +0 -1
- package/lib/grid.js +0 -131
- package/lib/grid.js.map +0 -1
- package/lib/index.js +0 -40
- package/lib/index.js.map +0 -1
- package/lib/labels.js +0 -199
- package/lib/labels.js.map +0 -1
- package/lib/mark-label.js +0 -159
- package/lib/mark-label.js.map +0 -1
- package/lib/toggle-bar.js +0 -248
- package/lib/toggle-bar.js.map +0 -1
- package/lib/tool-menu.js +0 -218
- package/lib/tool-menu.js.map +0 -1
- package/lib/tools/index.js +0 -24
- package/lib/tools/index.js.map +0 -1
- package/lib/tools/line/component.js +0 -92
- package/lib/tools/line/component.js.map +0 -1
- package/lib/tools/line/index.js +0 -11
- package/lib/tools/line/index.js.map +0 -1
- package/lib/tools/polygon/component.js +0 -358
- package/lib/tools/polygon/component.js.map +0 -1
- package/lib/tools/polygon/index.js +0 -89
- package/lib/tools/polygon/index.js.map +0 -1
- package/lib/tools/polygon/line.js +0 -114
- package/lib/tools/polygon/line.js.map +0 -1
- package/lib/tools/polygon/polygon.js +0 -128
- package/lib/tools/polygon/polygon.js.map +0 -1
- package/lib/tools/shared/arrow-head.js +0 -62
- package/lib/tools/shared/arrow-head.js.map +0 -1
- package/lib/tools/shared/line/index.js +0 -539
- package/lib/tools/shared/line/index.js.map +0 -1
- package/lib/tools/shared/line/line-path.js +0 -121
- package/lib/tools/shared/line/line-path.js.map +0 -1
- package/lib/tools/shared/line/with-root-edge.js +0 -121
- package/lib/tools/shared/line/with-root-edge.js.map +0 -1
- package/lib/tools/shared/point/arrow-point.js +0 -86
- package/lib/tools/shared/point/arrow-point.js.map +0 -1
- package/lib/tools/shared/point/arrow.js +0 -70
- package/lib/tools/shared/point/arrow.js.map +0 -1
- package/lib/tools/shared/point/base-point.js +0 -137
- package/lib/tools/shared/point/base-point.js.map +0 -1
- package/lib/tools/shared/point/index.js +0 -80
- package/lib/tools/shared/point/index.js.map +0 -1
- package/lib/tools/shared/styles.js +0 -26
- package/lib/tools/shared/styles.js.map +0 -1
- package/lib/tools/shared/types.js +0 -15
- package/lib/tools/shared/types.js.map +0 -1
- package/lib/undo-redo.js +0 -67
- package/lib/undo-redo.js.map +0 -1
- package/lib/use-debounce.js +0 -25
- package/lib/use-debounce.js.map +0 -1
- package/lib/utils.js +0 -235
- package/lib/utils.js.map +0 -1
- package/src/axis/arrow.jsx +0 -57
- package/src/axis/axes.jsx +0 -284
- package/src/axis/index.js +0 -3
- package/src/bg.jsx +0 -96
- package/src/container/actions.js +0 -8
- package/src/container/index.jsx +0 -93
- package/src/container/marks.js +0 -14
- package/src/container/middleware.js +0 -7
- package/src/container/reducer.js +0 -5
- package/src/coordinates-label.jsx +0 -62
- package/src/graph-with-controls.jsx +0 -242
- package/src/graph.jsx +0 -333
- package/src/grid-setup.jsx +0 -432
- package/src/grid.jsx +0 -133
- package/src/index.js +0 -7
- package/src/labels.jsx +0 -173
- package/src/mark-label.jsx +0 -125
- package/src/toggle-bar.jsx +0 -221
- package/src/tool-menu.jsx +0 -235
- package/src/tools/index.js +0 -8
- package/src/tools/line/component.jsx +0 -77
- package/src/tools/line/index.js +0 -4
- package/src/tools/polygon/component.jsx +0 -324
- package/src/tools/polygon/index.js +0 -52
- package/src/tools/polygon/line.jsx +0 -80
- package/src/tools/polygon/polygon.jsx +0 -93
- package/src/tools/shared/arrow-head.jsx +0 -46
- package/src/tools/shared/line/index.jsx +0 -471
- package/src/tools/shared/line/line-path.jsx +0 -85
- package/src/tools/shared/line/with-root-edge.jsx +0 -97
- package/src/tools/shared/point/arrow-point.jsx +0 -60
- package/src/tools/shared/point/arrow.jsx +0 -40
- package/src/tools/shared/point/base-point.jsx +0 -113
- package/src/tools/shared/point/index.jsx +0 -58
- package/src/tools/shared/styles.js +0 -20
- package/src/tools/shared/types.js +0 -8
- package/src/undo-redo.jsx +0 -37
- package/src/use-debounce.js +0 -13
- package/src/utils.js +0 -230
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { types } from '@pie-lib/plot';
|
|
5
|
-
import { correct, disabled, incorrect, missing } from '../styles';
|
|
6
|
-
import * as vx from '@visx/shape';
|
|
7
|
-
import { color } from '@pie-lib/render-ui';
|
|
8
|
-
|
|
9
|
-
const dragging = () => ({
|
|
10
|
-
strokeWidth: 7,
|
|
11
|
-
stroke: color.defaults.BLACK,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const StyledDrawLine = styled(vx.LinePath, {
|
|
15
|
-
shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
|
|
16
|
-
})(({ disabled: isDisabled, correctness }) => ({
|
|
17
|
-
fill: 'none',
|
|
18
|
-
strokeWidth: 2,
|
|
19
|
-
stroke: color.secondaryLight(),
|
|
20
|
-
...(isDisabled && {
|
|
21
|
-
...disabled('stroke'),
|
|
22
|
-
strokeWidth: 2,
|
|
23
|
-
}),
|
|
24
|
-
...(correctness === 'correct' && correct('stroke')),
|
|
25
|
-
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
26
|
-
...(correctness === 'missing' && missing('stroke')),
|
|
27
|
-
}));
|
|
28
|
-
|
|
29
|
-
const StyledInteractionLine = styled(vx.LinePath, {
|
|
30
|
-
shouldForwardProp: (prop) => !['disabled', 'correctness', 'isDragging'].includes(prop),
|
|
31
|
-
})(({ disabled: isDisabled, correctness, isDragging }) => ({
|
|
32
|
-
strokeWidth: 6,
|
|
33
|
-
fill: 'none',
|
|
34
|
-
transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
|
|
35
|
-
stroke: 'transparent',
|
|
36
|
-
'&:hover': dragging(),
|
|
37
|
-
...(isDragging && dragging()),
|
|
38
|
-
...(isDisabled && {
|
|
39
|
-
...disabled('stroke'),
|
|
40
|
-
strokeWidth: 2,
|
|
41
|
-
}),
|
|
42
|
-
...(correctness === 'correct' && correct('stroke')),
|
|
43
|
-
...(correctness === 'incorrect' && incorrect('stroke')),
|
|
44
|
-
...(correctness === 'missing' && missing('stroke')),
|
|
45
|
-
}));
|
|
46
|
-
|
|
47
|
-
export class RawLinePath extends React.Component {
|
|
48
|
-
static propTypes = {
|
|
49
|
-
className: PropTypes.string,
|
|
50
|
-
data: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
|
|
51
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
52
|
-
disabled: PropTypes.bool,
|
|
53
|
-
correctness: PropTypes.string,
|
|
54
|
-
from: types.PointType,
|
|
55
|
-
to: types.PointType,
|
|
56
|
-
isDragging: PropTypes.bool,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
static defaultProps = {
|
|
60
|
-
from: {},
|
|
61
|
-
to: {},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
render() {
|
|
65
|
-
/* eslint-disable no-unused-vars */
|
|
66
|
-
const { data, className, disabled, correctness, from, to, graphProps, isDragging, ...rest } = this.props;
|
|
67
|
-
/* eslint-enable */
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<React.Fragment>
|
|
71
|
-
<StyledDrawLine data={data} disabled={disabled} correctness={correctness} className={className} {...rest} />
|
|
72
|
-
<StyledInteractionLine
|
|
73
|
-
data={data}
|
|
74
|
-
isDragging={isDragging}
|
|
75
|
-
disabled={disabled}
|
|
76
|
-
correctness={correctness}
|
|
77
|
-
className={className}
|
|
78
|
-
{...rest}
|
|
79
|
-
/>
|
|
80
|
-
</React.Fragment>
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export const LinePath = RawLinePath;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { types } from '@pie-lib/plot';
|
|
4
|
-
import { LinePath } from './line-path';
|
|
5
|
-
import { curveMonotoneX } from '@visx/curve';
|
|
6
|
-
import { lineBase, lineToolComponent } from './index';
|
|
7
|
-
|
|
8
|
-
const toRootEdge = (m) => {
|
|
9
|
-
const out = { ...m };
|
|
10
|
-
out.root = { ...m.from };
|
|
11
|
-
out.edge = m.to ? { ...m.to } : undefined;
|
|
12
|
-
delete out.from;
|
|
13
|
-
delete out.to;
|
|
14
|
-
return out;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const toFromTo = (m) => {
|
|
18
|
-
const out = { ...m };
|
|
19
|
-
out.from = { ...m.root };
|
|
20
|
-
out.to = m.edge ? { ...m.edge } : undefined;
|
|
21
|
-
delete out.root;
|
|
22
|
-
delete out.edge;
|
|
23
|
-
return out;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const rootEdgeToFromToWrapper = (BaseComp) => {
|
|
27
|
-
const Wrapper = (props) => {
|
|
28
|
-
const m = toFromTo(props.mark);
|
|
29
|
-
|
|
30
|
-
const onChange = (current, next) => {
|
|
31
|
-
props.onChange(toRootEdge(current), toRootEdge(next));
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return <BaseComp {...props} mark={m} onChange={onChange} />;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
Wrapper.propTypes = {
|
|
38
|
-
onChange: PropTypes.func,
|
|
39
|
-
mark: PropTypes.object,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
return Wrapper;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const rootEdgeComponent = (RootEdgeComp) => {
|
|
46
|
-
const BaseComponent = lineToolComponent(RootEdgeComp);
|
|
47
|
-
return rootEdgeToFromToWrapper(BaseComponent);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const withPointsGenerationLinePath = (getPoints) => {
|
|
51
|
-
const LinePathComponent = (props) => {
|
|
52
|
-
const { graphProps, from, to, onClick, onDragStart, onDragStop, onChange, disabled, correctness, ...rest } = props;
|
|
53
|
-
|
|
54
|
-
const { dataPoints, enableCurve = true } = getPoints({
|
|
55
|
-
graphProps: props.graphProps,
|
|
56
|
-
root: from,
|
|
57
|
-
edge: to,
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
const raw = dataPoints.map((d) => [graphProps.scale.x(d.x), graphProps.scale.y(d.y)]);
|
|
61
|
-
|
|
62
|
-
const common = {
|
|
63
|
-
onClick,
|
|
64
|
-
graphProps,
|
|
65
|
-
onDragStart,
|
|
66
|
-
onDragStop,
|
|
67
|
-
onChange,
|
|
68
|
-
disabled,
|
|
69
|
-
correctness,
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
if (!enableCurve) {
|
|
73
|
-
return <LinePath data={raw} from={from} to={to} {...common} {...rest} />;
|
|
74
|
-
} else {
|
|
75
|
-
return <LinePath data={raw} from={from} to={to} curve={curveMonotoneX} {...common} {...rest} />;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
LinePathComponent.propTypes = {
|
|
80
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
81
|
-
from: types.PointType.isRequired,
|
|
82
|
-
to: types.PointType,
|
|
83
|
-
onClick: PropTypes.func,
|
|
84
|
-
onDragStart: PropTypes.func,
|
|
85
|
-
onDragStop: PropTypes.func,
|
|
86
|
-
onChange: PropTypes.func,
|
|
87
|
-
disabled: PropTypes.bool,
|
|
88
|
-
correctness: PropTypes.string,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
return LinePathComponent;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const withRootEdge = (getPoints) => {
|
|
95
|
-
const LinePathComp = withPointsGenerationLinePath(getPoints);
|
|
96
|
-
return lineBase(LinePathComp);
|
|
97
|
-
};
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { types } from '@pie-lib/plot';
|
|
5
|
-
import { isEqual } from 'lodash-es';
|
|
6
|
-
import { arrowDimensions, getAngleDeg } from '../../../utils';
|
|
7
|
-
|
|
8
|
-
export class RawArrow extends React.Component {
|
|
9
|
-
static propTypes = {
|
|
10
|
-
classes: PropTypes.object,
|
|
11
|
-
className: PropTypes.string,
|
|
12
|
-
correctness: PropTypes.string,
|
|
13
|
-
disabled: PropTypes.bool,
|
|
14
|
-
x: PropTypes.number,
|
|
15
|
-
y: PropTypes.number,
|
|
16
|
-
from: PropTypes.shape({
|
|
17
|
-
x: PropTypes.number,
|
|
18
|
-
y: PropTypes.number,
|
|
19
|
-
}).isRequired,
|
|
20
|
-
to: PropTypes.shape({
|
|
21
|
-
x: PropTypes.number,
|
|
22
|
-
y: PropTypes.number,
|
|
23
|
-
}),
|
|
24
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
static defaultProps = {
|
|
28
|
-
from: {},
|
|
29
|
-
to: {},
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
render() {
|
|
33
|
-
const { classes, className, x, y, disabled, correctness, graphProps, from, to, ...rest } = this.props;
|
|
34
|
-
// x & y are the initial coordinates for the arrow
|
|
35
|
-
// from & to are used only to calculate the angle that the arrow should be rotated with
|
|
36
|
-
|
|
37
|
-
const { scale } = graphProps;
|
|
38
|
-
const angle = getAngleDeg(from.x, from.y, to.x, to.y);
|
|
39
|
-
|
|
40
|
-
let points = '';
|
|
41
|
-
|
|
42
|
-
if (isEqual(from, to)) {
|
|
43
|
-
points = '0,0 0,0 0,0';
|
|
44
|
-
} else {
|
|
45
|
-
points = `0,0 ${arrowDimensions.vector},${arrowDimensions.vector * 2}
|
|
46
|
-
-${arrowDimensions.vector},${arrowDimensions.vector * 2}`;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<g className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)} {...rest}>
|
|
51
|
-
<polygon
|
|
52
|
-
points={points}
|
|
53
|
-
transform={`
|
|
54
|
-
translate(${scale.x(x)}, ${scale.y(y)})
|
|
55
|
-
rotate(${angle} 0 0)`}
|
|
56
|
-
/>
|
|
57
|
-
</g>
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import classNames from 'classnames';
|
|
4
|
-
import { types } from '@pie-lib/plot';
|
|
5
|
-
import { ArrowHead } from '../arrow-head';
|
|
6
|
-
import { thinnerShapesNeeded } from '../../../utils';
|
|
7
|
-
|
|
8
|
-
export default class Arrow extends React.Component {
|
|
9
|
-
static propTypes = {
|
|
10
|
-
classes: PropTypes.object,
|
|
11
|
-
className: PropTypes.string,
|
|
12
|
-
correctness: PropTypes.string,
|
|
13
|
-
disabled: PropTypes.bool,
|
|
14
|
-
x: PropTypes.number.isRequired,
|
|
15
|
-
y: PropTypes.number.isRequired,
|
|
16
|
-
angle: PropTypes.number.isRequired,
|
|
17
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
render() {
|
|
21
|
-
const { classes, angle, className, x, y, disabled, correctness, graphProps, ...rest } = this.props;
|
|
22
|
-
|
|
23
|
-
const size = thinnerShapesNeeded(graphProps) ? 12 : 14;
|
|
24
|
-
const { scale } = graphProps;
|
|
25
|
-
|
|
26
|
-
const scaledX = scale.x(x);
|
|
27
|
-
const scaledY = scale.y(y);
|
|
28
|
-
|
|
29
|
-
const transform = `rotate(${-angle}, ${scaledX},${scaledY})`;
|
|
30
|
-
const points = `${scaledX},${scaledY}
|
|
31
|
-
${scaledX - size},${scaledY - size / 2}
|
|
32
|
-
${scaledX - size}, ${scaledY + size / 2}`;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<g className={classNames(classes.point, disabled && classes.disabled, classes[correctness], className)} {...rest}>
|
|
36
|
-
<ArrowHead size={size} transform={transform} points={points} />
|
|
37
|
-
</g>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { types } from '@pie-lib/plot';
|
|
4
|
-
import CoordinatesLabel from '../../../coordinates-label';
|
|
5
|
-
import ReactDOM from 'react-dom';
|
|
6
|
-
import { thinnerShapesNeeded } from '../../../utils';
|
|
7
|
-
import { color } from '@pie-lib/render-ui';
|
|
8
|
-
import { styled } from '@mui/material/styles';
|
|
9
|
-
import { correct, disabled as disabledStyle, incorrect, missing } from '../styles';
|
|
10
|
-
|
|
11
|
-
const StyledPointGroup = styled('g')(({ disabled, correctness }) => ({
|
|
12
|
-
cursor: 'pointer',
|
|
13
|
-
'& circle': {
|
|
14
|
-
fill: 'currentColor',
|
|
15
|
-
},
|
|
16
|
-
...(disabled && {
|
|
17
|
-
...disabledStyle('fill'),
|
|
18
|
-
...disabledStyle('color'),
|
|
19
|
-
}),
|
|
20
|
-
...(correctness === 'correct' && {
|
|
21
|
-
...correct('fill'),
|
|
22
|
-
...correct('color'),
|
|
23
|
-
}),
|
|
24
|
-
...(correctness === 'incorrect' && {
|
|
25
|
-
...incorrect('fill'),
|
|
26
|
-
...incorrect('color'),
|
|
27
|
-
}),
|
|
28
|
-
...(correctness === 'missing' && {
|
|
29
|
-
...missing('fill'),
|
|
30
|
-
...missing('color'),
|
|
31
|
-
}),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
export class RawBp extends React.Component {
|
|
35
|
-
static propTypes = {
|
|
36
|
-
className: PropTypes.string,
|
|
37
|
-
coordinatesOnHover: PropTypes.bool,
|
|
38
|
-
correctness: PropTypes.string,
|
|
39
|
-
disabled: PropTypes.bool,
|
|
40
|
-
labelNode: PropTypes.object,
|
|
41
|
-
x: PropTypes.number,
|
|
42
|
-
y: PropTypes.number,
|
|
43
|
-
graphProps: types.GraphPropsType.isRequired,
|
|
44
|
-
onClick: PropTypes.func,
|
|
45
|
-
onTouchStart: PropTypes.func,
|
|
46
|
-
onTouchEnd: PropTypes.func,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
constructor(props) {
|
|
50
|
-
super(props);
|
|
51
|
-
this.state = { showCoordinates: false };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
render() {
|
|
55
|
-
const {
|
|
56
|
-
className,
|
|
57
|
-
coordinatesOnHover,
|
|
58
|
-
x,
|
|
59
|
-
y,
|
|
60
|
-
disabled,
|
|
61
|
-
correctness,
|
|
62
|
-
graphProps,
|
|
63
|
-
labelNode,
|
|
64
|
-
// we need to remove style from props
|
|
65
|
-
// eslint-disable-next-line no-unused-vars,react/prop-types
|
|
66
|
-
style,
|
|
67
|
-
onClick,
|
|
68
|
-
// Refactored RawBp component by isolating onTouchStart and onTouchEnd handlers to the outer circle, resolving erratic touch event behavior.
|
|
69
|
-
// Remaining props are now applied only to the inner circle for improved event handling consistency.
|
|
70
|
-
onTouchStart,
|
|
71
|
-
onTouchEnd,
|
|
72
|
-
...rest
|
|
73
|
-
} = this.props;
|
|
74
|
-
const { showCoordinates } = this.state;
|
|
75
|
-
const { scale } = graphProps;
|
|
76
|
-
const r = thinnerShapesNeeded(graphProps) ? 5 : 7;
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<>
|
|
80
|
-
<circle
|
|
81
|
-
style={{ fill: 'transparent', cursor: 'pointer', pointerEvents: 'all' }}
|
|
82
|
-
r={r * 3}
|
|
83
|
-
cx={scale.x(x)}
|
|
84
|
-
cy={scale.y(y)}
|
|
85
|
-
onMouseEnter={() => this.setState({ showCoordinates: true })}
|
|
86
|
-
onMouseLeave={() => this.setState({ showCoordinates: false })}
|
|
87
|
-
onTouchStart={onTouchStart}
|
|
88
|
-
onTouchEnd={onTouchEnd}
|
|
89
|
-
onClick={onClick}
|
|
90
|
-
/>
|
|
91
|
-
<StyledPointGroup
|
|
92
|
-
disabled={disabled}
|
|
93
|
-
correctness={correctness}
|
|
94
|
-
className={className}
|
|
95
|
-
onMouseEnter={() => this.setState({ showCoordinates: true })}
|
|
96
|
-
onMouseLeave={() => this.setState({ showCoordinates: false })}
|
|
97
|
-
>
|
|
98
|
-
<circle
|
|
99
|
-
{...rest}
|
|
100
|
-
style={{ fill: color.defaults.BLACK, cursor: 'pointer' }}
|
|
101
|
-
r={r}
|
|
102
|
-
cx={scale.x(x)}
|
|
103
|
-
cy={scale.y(y)}
|
|
104
|
-
/>
|
|
105
|
-
{labelNode &&
|
|
106
|
-
coordinatesOnHover &&
|
|
107
|
-
showCoordinates &&
|
|
108
|
-
ReactDOM.createPortal(<CoordinatesLabel graphProps={graphProps} x={x} y={y} />, labelNode)}
|
|
109
|
-
</StyledPointGroup>
|
|
110
|
-
</>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { gridDraggable } from '@pie-lib/plot';
|
|
5
|
-
import * as utils from '../../../utils';
|
|
6
|
-
import { correct, disabled, incorrect, missing } from '../styles';
|
|
7
|
-
import { RawBp } from './base-point';
|
|
8
|
-
import { RawArrow } from './arrow-point';
|
|
9
|
-
import { color } from '@pie-lib/render-ui';
|
|
10
|
-
import BaseArrow from './arrow';
|
|
11
|
-
|
|
12
|
-
const opts = {
|
|
13
|
-
bounds: (props, { domain, range }) => {
|
|
14
|
-
const { x, y } = props;
|
|
15
|
-
const area = { left: x, top: y, bottom: y, right: x };
|
|
16
|
-
|
|
17
|
-
return utils.bounds(area, domain, range);
|
|
18
|
-
},
|
|
19
|
-
anchorPoint: (props) => {
|
|
20
|
-
const { x, y } = props;
|
|
21
|
-
|
|
22
|
-
return { x, y };
|
|
23
|
-
},
|
|
24
|
-
fromDelta: (props, delta) => {
|
|
25
|
-
return utils.point(props).add(utils.point(delta));
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const StyledPointWrapper = styled('g', {
|
|
30
|
-
shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
|
|
31
|
-
})(({ disabled: isDisabled, correctness }) => ({
|
|
32
|
-
'& circle, & polygon': {
|
|
33
|
-
cursor: 'pointer',
|
|
34
|
-
fill: color.defaults.SECONDARY,
|
|
35
|
-
...(isDisabled && disabled()),
|
|
36
|
-
...(correctness === 'correct' && correct()),
|
|
37
|
-
...(correctness === 'incorrect' && incorrect()),
|
|
38
|
-
...(correctness === 'missing' && missing()),
|
|
39
|
-
},
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
const withStyledWrapper = (WrappedComponent) => {
|
|
43
|
-
const WrappedComponentWithStyles = (props) => (
|
|
44
|
-
<StyledPointWrapper disabled={props.disabled} correctness={props.correctness}>
|
|
45
|
-
<WrappedComponent {...props} />
|
|
46
|
-
</StyledPointWrapper>
|
|
47
|
-
);
|
|
48
|
-
WrappedComponentWithStyles.displayName = `withStyledWrapper(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
|
|
49
|
-
WrappedComponentWithStyles.propTypes = {
|
|
50
|
-
disabled: PropTypes.bool,
|
|
51
|
-
correctness: PropTypes.string,
|
|
52
|
-
};
|
|
53
|
-
return WrappedComponentWithStyles;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const BasePoint = gridDraggable(opts)(withStyledWrapper(RawBp));
|
|
57
|
-
export const ArrowPoint = gridDraggable(opts)(withStyledWrapper(RawArrow));
|
|
58
|
-
export const Arrow = gridDraggable(opts)(withStyledWrapper(BaseArrow));
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { color } from '@pie-lib/render-ui';
|
|
2
|
-
|
|
3
|
-
export const disabled = (key = 'fill') => ({
|
|
4
|
-
[key]: color.disabled(),
|
|
5
|
-
pointerEvents: 'none',
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
export const correct = (key = 'fill') => ({
|
|
9
|
-
[key]: color.correct(),
|
|
10
|
-
pointerEvents: 'none',
|
|
11
|
-
});
|
|
12
|
-
export const incorrect = (key = 'fill') => ({
|
|
13
|
-
[key]: color.incorrect(),
|
|
14
|
-
pointerEvents: 'none',
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export const missing = (key = 'fill') => ({
|
|
18
|
-
[key]: color.missing(),
|
|
19
|
-
pointerEvents: 'none',
|
|
20
|
-
});
|
package/src/undo-redo.jsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { styled } from '@mui/material/styles';
|
|
4
|
-
import Button from '@mui/material/Button';
|
|
5
|
-
import { color } from '@pie-lib/render-ui';
|
|
6
|
-
import Translator from '@pie-lib/translator';
|
|
7
|
-
|
|
8
|
-
const { translator } = Translator;
|
|
9
|
-
|
|
10
|
-
const StyledButton = styled(Button)(({ theme }) => ({
|
|
11
|
-
color: color.text(),
|
|
12
|
-
fontWeight: 'bold',
|
|
13
|
-
marginBottom: theme.spacing(0.5),
|
|
14
|
-
'&:not(:last-of-type)': {
|
|
15
|
-
marginRight: theme.spacing(0.5),
|
|
16
|
-
},
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
export class UndoRedo extends React.Component {
|
|
20
|
-
static propTypes = {
|
|
21
|
-
className: PropTypes.string,
|
|
22
|
-
onReset: PropTypes.func.isRequired,
|
|
23
|
-
language: PropTypes.string,
|
|
24
|
-
};
|
|
25
|
-
static defaultProps = {};
|
|
26
|
-
|
|
27
|
-
render() {
|
|
28
|
-
const { className, onReset = false, language } = this.props;
|
|
29
|
-
return (
|
|
30
|
-
<div className={className}>
|
|
31
|
-
<StyledButton onClick={() => onReset()}>{translator.t('graphing.reset', { lng: language })}</StyledButton>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default UndoRedo;
|
package/src/use-debounce.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
export const useDebounce = (value, delay) => {
|
|
4
|
-
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
5
|
-
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const handler = setTimeout(() => {
|
|
8
|
-
setDebouncedValue(value);
|
|
9
|
-
}, delay);
|
|
10
|
-
return () => clearTimeout(handler);
|
|
11
|
-
}, [value]);
|
|
12
|
-
return debouncedValue;
|
|
13
|
-
};
|