@pie-lib/graphing 4.0.5-next.30 → 4.0.5-next.32
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 +3 -3
- package/dist/axis/arrow.js +1 -1
- package/dist/axis/axes.js +6 -6
- package/dist/container/index.js +4 -4
- package/dist/container/reducer.js +1 -1
- package/dist/coordinates-label.js +1 -1
- package/dist/graph-with-controls.js +4 -4
- package/dist/graph.js +2 -2
- package/dist/grid-setup.js +8 -8
- package/dist/grid.js +1 -1
- package/dist/index.js +2 -2
- package/dist/labels.js +1 -1
- package/dist/mark-label.d.ts +2 -0
- package/dist/mark-label.js +99 -69
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +1 -1
- package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +1 -1
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +1 -1
- package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +1 -1
- package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +1 -1
- package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +1 -1
- package/dist/node_modules/.bun/@visx_vendor@4.0.0/node_modules/@visx/vendor/esm/d3-shape.js +8 -0
- package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +1 -1
- package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +7 -7
- package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +1 -1
- package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +2 -2
- package/dist/toggle-bar.js +1 -1
- package/dist/tool-menu.js +3 -3
- package/dist/tools/circle/bg-circle.js +2 -2
- package/dist/tools/circle/component.d.ts +5 -0
- package/dist/tools/circle/component.js +30 -17
- package/dist/tools/index.js +1 -1
- package/dist/tools/line/component.js +2 -2
- package/dist/tools/point/component.d.ts +2 -0
- package/dist/tools/point/component.js +16 -10
- package/dist/tools/point/index.js +1 -1
- package/dist/tools/polygon/component.d.ts +5 -0
- package/dist/tools/polygon/component.js +27 -18
- package/dist/tools/polygon/index.js +1 -1
- package/dist/tools/polygon/line.js +1 -1
- package/dist/tools/polygon/polygon.js +3 -3
- package/dist/tools/ray/component.js +2 -2
- package/dist/tools/segment/component.js +1 -1
- package/dist/tools/shared/line/index.d.ts +10 -4
- package/dist/tools/shared/line/index.js +27 -14
- package/dist/tools/shared/line/line-path.js +2 -2
- package/dist/tools/shared/line/with-root-edge.d.ts +10 -4
- package/dist/tools/shared/line/with-root-edge.js +3 -3
- package/dist/tools/shared/point/base-point.js +1 -1
- package/dist/tools/vector/component.js +1 -1
- package/dist/undo-redo.js +2 -2
- package/dist/utils.js +1 -1
- package/package.json +16 -11
- package/dist/node_modules/.bun/@visx_curve@3.12.0/node_modules/@visx/curve/esm/index.js +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { equalPoints as e, getMiddleOfTwoPoints as t, point as n, stripEmptyLabel as r } from "../../utils.js";
|
|
2
|
-
import i from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
2
|
+
import { clsx as i } from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
3
3
|
import { BasePoint as a } from "../shared/point/index.js";
|
|
4
|
-
import o from "../../mark-label.js";
|
|
4
|
+
import { MarkLabel as o } from "../../mark-label.js";
|
|
5
5
|
import s from "./bg-circle.js";
|
|
6
6
|
import { rootEdgeComponent as c } from "../shared/line/with-root-edge.js";
|
|
7
7
|
import l from "react";
|
|
@@ -38,6 +38,10 @@ var y = (e) => p({
|
|
|
38
38
|
limitLabeling: u.bool
|
|
39
39
|
};
|
|
40
40
|
static defaultProps = { onClick: () => ({}) };
|
|
41
|
+
state = { editingLabel: null };
|
|
42
|
+
componentDidUpdate(e) {
|
|
43
|
+
e.labelModeEnabled && !this.props.labelModeEnabled && this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
44
|
+
}
|
|
41
45
|
onChangePoint = (n) => {
|
|
42
46
|
let { middle: r, onChange: i } = this.props, { from: a, to: o } = n;
|
|
43
47
|
e(a, o) || (r && (n.middle = {
|
|
@@ -79,6 +83,9 @@ var y = (e) => p({
|
|
|
79
83
|
let { changeMarkProps: n } = this.props, r = { ...e };
|
|
80
84
|
(!e.label || d(e.label)) && delete r.label, n({ [t]: r });
|
|
81
85
|
};
|
|
86
|
+
stopEditingLabel = () => {
|
|
87
|
+
this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
88
|
+
};
|
|
82
89
|
clickPoint = (e, n, i) => {
|
|
83
90
|
let { changeMarkProps: a, disabled: o, from: s, to: c, middle: l, labelModeEnabled: u, limitLabeling: d, onClick: f } = this.props;
|
|
84
91
|
if (!u) {
|
|
@@ -96,41 +103,47 @@ var y = (e) => p({
|
|
|
96
103
|
label: "",
|
|
97
104
|
...e
|
|
98
105
|
}
|
|
99
|
-
}), this.
|
|
106
|
+
}), this.setState({ editingLabel: n }));
|
|
100
107
|
};
|
|
101
108
|
input = {};
|
|
102
109
|
render() {
|
|
103
|
-
let { from: e, to: t, middle: n, disabled: r, building: s, coordinatesOnHover: c, onDragStart: l, onDragStop: u, onClick: d, correctness: f, graphProps: p, labelNode: m, labelModeEnabled: _ } = this.props, y = {
|
|
110
|
+
let { from: e, to: t, middle: n, disabled: r, building: s, coordinatesOnHover: c, onDragStart: l, onDragStop: u, onClick: d, correctness: f, graphProps: p, labelNode: m, labelModeEnabled: _ } = this.props, { editingLabel: y } = this.state, x = {
|
|
104
111
|
onDragStart: l,
|
|
105
112
|
onDragStop: u,
|
|
106
113
|
graphProps: p,
|
|
107
114
|
onClick: d
|
|
108
115
|
};
|
|
109
116
|
t ||= e;
|
|
110
|
-
let
|
|
111
|
-
return m && (e?.label !== void 0 && (
|
|
117
|
+
let C = b(e, t), w = null, T = null, E = null;
|
|
118
|
+
return m && (e?.label !== void 0 && (w = v.createPortal(/* @__PURE__ */ h(o, {
|
|
112
119
|
inputRef: (e) => this.input.from = e,
|
|
120
|
+
autoFocus: y === "from",
|
|
113
121
|
disabled: !_,
|
|
114
122
|
mark: e,
|
|
115
123
|
graphProps: p,
|
|
124
|
+
onBlur: this.stopEditingLabel,
|
|
116
125
|
onChange: (t) => this.labelChange({
|
|
117
126
|
...e,
|
|
118
127
|
label: t
|
|
119
128
|
}, "from")
|
|
120
|
-
}), m)), t?.label !== void 0 && (
|
|
129
|
+
}), m)), t?.label !== void 0 && (T = v.createPortal(/* @__PURE__ */ h(o, {
|
|
121
130
|
inputRef: (e) => this.input.to = e,
|
|
131
|
+
autoFocus: y === "to",
|
|
122
132
|
disabled: !_,
|
|
123
133
|
mark: t,
|
|
124
134
|
graphProps: p,
|
|
135
|
+
onBlur: this.stopEditingLabel,
|
|
125
136
|
onChange: (e) => this.labelChange({
|
|
126
137
|
...t,
|
|
127
138
|
label: e
|
|
128
139
|
}, "to")
|
|
129
|
-
}), m)), n?.label !== void 0 && (
|
|
140
|
+
}), m)), n?.label !== void 0 && (E = v.createPortal(/* @__PURE__ */ h(o, {
|
|
130
141
|
inputRef: (e) => this.input.middle = e,
|
|
142
|
+
autoFocus: y === "middle",
|
|
131
143
|
disabled: !_,
|
|
132
144
|
mark: n,
|
|
133
145
|
graphProps: p,
|
|
146
|
+
onBlur: this.stopEditingLabel,
|
|
134
147
|
onChange: (e) => this.labelChange({
|
|
135
148
|
...n,
|
|
136
149
|
label: e
|
|
@@ -142,12 +155,12 @@ var y = (e) => p({
|
|
|
142
155
|
className: i(s && "bgCircleBuilding"),
|
|
143
156
|
x: e.x,
|
|
144
157
|
y: e.y,
|
|
145
|
-
radius:
|
|
158
|
+
radius: C,
|
|
146
159
|
onDrag: this.dragCircle,
|
|
147
|
-
...
|
|
160
|
+
...x,
|
|
148
161
|
onClick: (e) => this.clickPoint(n, "middle", e)
|
|
149
162
|
}),
|
|
150
|
-
|
|
163
|
+
E,
|
|
151
164
|
/* @__PURE__ */ h(a, {
|
|
152
165
|
disabled: s || r,
|
|
153
166
|
coordinatesOnHover: c,
|
|
@@ -156,10 +169,10 @@ var y = (e) => p({
|
|
|
156
169
|
x: t.x,
|
|
157
170
|
y: t.y,
|
|
158
171
|
onDrag: this.dragTo,
|
|
159
|
-
...
|
|
172
|
+
...x,
|
|
160
173
|
onClick: (e) => this.clickPoint(t, "to", e)
|
|
161
174
|
}),
|
|
162
|
-
|
|
175
|
+
T,
|
|
163
176
|
/* @__PURE__ */ h(a, {
|
|
164
177
|
disabled: s || r,
|
|
165
178
|
coordinatesOnHover: c,
|
|
@@ -169,10 +182,10 @@ var y = (e) => p({
|
|
|
169
182
|
y: e.y,
|
|
170
183
|
className: "from",
|
|
171
184
|
onDrag: this.dragFrom,
|
|
172
|
-
...
|
|
185
|
+
...x,
|
|
173
186
|
onClick: (t) => this.clickPoint(e, "from", t)
|
|
174
187
|
}),
|
|
175
|
-
|
|
188
|
+
w
|
|
176
189
|
] });
|
|
177
190
|
}
|
|
178
191
|
}, S = m(s)(() => ({
|
|
@@ -190,6 +203,6 @@ var y = (e) => p({
|
|
|
190
203
|
animation: `${y("0.3")} 2s ease-out infinite`,
|
|
191
204
|
opacity: 1
|
|
192
205
|
}
|
|
193
|
-
})), C = c(
|
|
206
|
+
})), C = x, w = c(C);
|
|
194
207
|
//#endregion
|
|
195
|
-
export { C as default };
|
|
208
|
+
export { C as BaseCircle, x as RawBaseCircle, w as default };
|
package/dist/tools/index.js
CHANGED
|
@@ -52,4 +52,4 @@ var f = /* @__PURE__ */ e({
|
|
|
52
52
|
{ type: "label" }
|
|
53
53
|
];
|
|
54
54
|
//#endregion
|
|
55
|
-
export { p as allTools, m as toolsArr, f as tools_exports };
|
|
55
|
+
export { u as absolute, p as allTools, n as circle, d as exponential, o as line, a as parabola, t as point, r as polygon, c as ray, i as sine, m as toolsArr, f as tools_exports, l as vector };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getAdjustedGraphLimits as e, thinnerShapesNeeded as t } from "../../utils.js";
|
|
2
|
-
import n from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
2
|
+
import { clsx as n } from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
3
3
|
import { ArrowMarker as r, genUid as i } from "../shared/arrow-head.js";
|
|
4
4
|
import { lineBase as a, lineToolComponent as o, styles as s } from "../shared/line/index.js";
|
|
5
5
|
import "react";
|
|
@@ -69,4 +69,4 @@ h.propTypes = {
|
|
|
69
69
|
};
|
|
70
70
|
var g = o(a(h));
|
|
71
71
|
//#endregion
|
|
72
|
-
export { g as default };
|
|
72
|
+
export { h as ArrowedLine, g as default };
|
|
@@ -40,10 +40,12 @@ export declare class Point extends React.Component {
|
|
|
40
40
|
};
|
|
41
41
|
static defaultProps: {};
|
|
42
42
|
constructor(props: any);
|
|
43
|
+
componentDidUpdate(prevProps: any): void;
|
|
43
44
|
move: any;
|
|
44
45
|
startDrag: any;
|
|
45
46
|
stopDrag: any;
|
|
46
47
|
labelChange: any;
|
|
48
|
+
stopEditingLabel: any;
|
|
47
49
|
clickPoint: any;
|
|
48
50
|
render(): React.JSX.Element;
|
|
49
51
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BasePoint as e } from "../shared/point/index.js";
|
|
2
2
|
import { ToolPropTypeFields as t } from "../shared/types.js";
|
|
3
|
-
import n from "../../mark-label.js";
|
|
3
|
+
import { MarkLabel as n } from "../../mark-label.js";
|
|
4
4
|
import r from "react";
|
|
5
5
|
import { isEmpty as i, isEqual as a } from "@pie-element/shared-lodash";
|
|
6
6
|
import { types as o } from "@pie-lib/plot";
|
|
@@ -14,7 +14,10 @@ var u = class extends r.Component {
|
|
|
14
14
|
};
|
|
15
15
|
static defaultProps = {};
|
|
16
16
|
constructor(e) {
|
|
17
|
-
super(e), this.state = {};
|
|
17
|
+
super(e), this.state = { editingLabel: null };
|
|
18
|
+
}
|
|
19
|
+
componentDidUpdate(e) {
|
|
20
|
+
e.labelModeEnabled && !this.props.labelModeEnabled && this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
18
21
|
}
|
|
19
22
|
move = (e) => {
|
|
20
23
|
let t = {
|
|
@@ -42,6 +45,9 @@ var u = class extends r.Component {
|
|
|
42
45
|
t(this.props.mark, n);
|
|
43
46
|
});
|
|
44
47
|
};
|
|
48
|
+
stopEditingLabel = () => {
|
|
49
|
+
this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
50
|
+
};
|
|
45
51
|
clickPoint = () => {
|
|
46
52
|
let { labelModeEnabled: e, onChange: t, onClick: n, mark: r } = this.props;
|
|
47
53
|
if (!e) {
|
|
@@ -51,14 +57,12 @@ var u = class extends r.Component {
|
|
|
51
57
|
r.disabled || (t(r, {
|
|
52
58
|
label: "",
|
|
53
59
|
...r
|
|
54
|
-
}),
|
|
55
|
-
this.input && this.input.focus();
|
|
56
|
-
}, 0));
|
|
60
|
+
}), this.setState({ editingLabel: "label" }));
|
|
57
61
|
};
|
|
58
62
|
render() {
|
|
59
|
-
let { coordinatesOnHover: t, graphProps: i, labelNode: a, labelModeEnabled: o } = this.props, u = this.state.mark ? this.state.mark : this.props.mark;
|
|
63
|
+
let { coordinatesOnHover: t, graphProps: i, labelNode: a, labelModeEnabled: o } = this.props, { editingLabel: u } = this.state, d = this.state.mark ? this.state.mark : this.props.mark;
|
|
60
64
|
return /* @__PURE__ */ c(r.Fragment, { children: [/* @__PURE__ */ s(e, {
|
|
61
|
-
...
|
|
65
|
+
...d,
|
|
62
66
|
coordinatesOnHover: t,
|
|
63
67
|
graphProps: i,
|
|
64
68
|
labelNode: a,
|
|
@@ -72,14 +76,16 @@ var u = class extends r.Component {
|
|
|
72
76
|
onTouchEnd: (e) => {
|
|
73
77
|
e.stopPropagation(), this.clickPoint();
|
|
74
78
|
}
|
|
75
|
-
}), a && Object.prototype.hasOwnProperty.call(
|
|
79
|
+
}), a && Object.prototype.hasOwnProperty.call(d, "label") && l.createPortal(/* @__PURE__ */ s(n, {
|
|
76
80
|
inputRef: (e) => this.input = e,
|
|
81
|
+
autoFocus: u === "label",
|
|
77
82
|
disabled: !o,
|
|
78
|
-
mark:
|
|
83
|
+
mark: d,
|
|
79
84
|
graphProps: i,
|
|
85
|
+
onBlur: this.stopEditingLabel,
|
|
80
86
|
onChange: this.labelChange
|
|
81
87
|
}), a)] });
|
|
82
88
|
}
|
|
83
89
|
};
|
|
84
90
|
//#endregion
|
|
85
|
-
export { u as default };
|
|
91
|
+
export { u as Point, u as default };
|
|
@@ -66,11 +66,16 @@ export declare class RawBaseComponent extends React.Component {
|
|
|
66
66
|
static defaultProps: {
|
|
67
67
|
points: never[];
|
|
68
68
|
};
|
|
69
|
+
state: {
|
|
70
|
+
editingLabel: null;
|
|
71
|
+
};
|
|
72
|
+
componentDidUpdate(prevProps: any): void;
|
|
69
73
|
dragPoint: any;
|
|
70
74
|
dragLine: any;
|
|
71
75
|
dragPoly: any;
|
|
72
76
|
close: any;
|
|
73
77
|
labelChange: any;
|
|
78
|
+
stopEditingLabel: any;
|
|
74
79
|
clickPoint: any;
|
|
75
80
|
input: {};
|
|
76
81
|
render(): React.JSX.Element;
|
|
@@ -3,7 +3,7 @@ import { require_browser as t } from "../../node_modules/.bun/invariant@2.2.4/no
|
|
|
3
3
|
import { equalPoints as n, getMiddleOfTwoPoints as r, getRightestPoints as i, stripEmptyLabel as a } from "../../utils.js";
|
|
4
4
|
import { BasePoint as o } from "../shared/point/index.js";
|
|
5
5
|
import { ToolPropTypeFields as s } from "../shared/types.js";
|
|
6
|
-
import c from "../../mark-label.js";
|
|
6
|
+
import { MarkLabel as c } from "../../mark-label.js";
|
|
7
7
|
import l from "./line.js";
|
|
8
8
|
import u, { Polygon as d } from "./polygon.js";
|
|
9
9
|
import f from "react";
|
|
@@ -62,6 +62,10 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
62
62
|
onChangeProps: p.func
|
|
63
63
|
};
|
|
64
64
|
static defaultProps = { points: [] };
|
|
65
|
+
state = { editingLabel: null };
|
|
66
|
+
componentDidUpdate(e) {
|
|
67
|
+
e.labelModeEnabled && !this.props.labelModeEnabled && this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
68
|
+
}
|
|
65
69
|
dragPoint = (e, t, r) => {
|
|
66
70
|
C("[dragPoint] from, to:", t, r);
|
|
67
71
|
let { onChange: i, points: a } = this.props, o = [...a], s = !!(a || []).find((e) => n(e, r));
|
|
@@ -89,6 +93,9 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
89
93
|
let a = [...n];
|
|
90
94
|
a.splice(t, 1, i), r(a);
|
|
91
95
|
};
|
|
96
|
+
stopEditingLabel = () => {
|
|
97
|
+
this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
98
|
+
};
|
|
92
99
|
clickPoint = (e, t, n) => {
|
|
93
100
|
let { closed: o, disabled: s, middle: c, onClick: l, isToolActive: u, labelModeEnabled: d, limitLabeling: f, onSetMiddleLabel: p, points: m } = this.props;
|
|
94
101
|
if (d) {
|
|
@@ -107,9 +114,7 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
107
114
|
...e
|
|
108
115
|
}), p(c && a(c), n);
|
|
109
116
|
}
|
|
110
|
-
|
|
111
|
-
this.input[t] && this.input[t].focus();
|
|
112
|
-
}, 0);
|
|
117
|
+
this.setState({ editingLabel: t });
|
|
113
118
|
return;
|
|
114
119
|
}
|
|
115
120
|
if (u && !o && t === 0) {
|
|
@@ -120,18 +125,20 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
120
125
|
};
|
|
121
126
|
input = {};
|
|
122
127
|
render() {
|
|
123
|
-
let { closed: e, coordinatesOnHover: t, correctness: n, disabled: r, graphProps: i, onChangeLabelProps: a, onDragStart: s, onDragStop: p, points: m, middle: h, labelNode: g, labelModeEnabled: _ } = this.props, v = w(m, e),
|
|
128
|
+
let { closed: e, coordinatesOnHover: t, correctness: n, disabled: r, graphProps: i, onChangeLabelProps: a, onDragStart: s, onDragStop: p, points: m, middle: h, labelNode: g, labelModeEnabled: _ } = this.props, { editingLabel: v } = this.state, S = w(m, e), C = {
|
|
124
129
|
onDragStart: s,
|
|
125
130
|
onDragStop: p,
|
|
126
131
|
graphProps: i,
|
|
127
132
|
disabled: r,
|
|
128
133
|
correctness: n
|
|
129
|
-
},
|
|
130
|
-
return g && h && Object.prototype.hasOwnProperty.call(h, "label") && (
|
|
131
|
-
inputRef: (e) => this.input[
|
|
134
|
+
}, T = m && m.length || 0, E = null;
|
|
135
|
+
return g && h && Object.prototype.hasOwnProperty.call(h, "label") && (E = x.createPortal(/* @__PURE__ */ y(c, {
|
|
136
|
+
inputRef: (e) => this.input[T] = e,
|
|
137
|
+
autoFocus: v === T,
|
|
132
138
|
disabled: r || !_,
|
|
133
139
|
mark: h,
|
|
134
140
|
graphProps: i,
|
|
141
|
+
onBlur: this.stopEditingLabel,
|
|
135
142
|
onChange: (e) => a({
|
|
136
143
|
...h,
|
|
137
144
|
label: e
|
|
@@ -141,19 +148,19 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
141
148
|
points: m,
|
|
142
149
|
onDrag: this.dragPoly.bind(this, m),
|
|
143
150
|
closed: e,
|
|
144
|
-
...
|
|
145
|
-
onClick: this.clickPoint.bind(this, h,
|
|
146
|
-
}),
|
|
151
|
+
...C,
|
|
152
|
+
onClick: this.clickPoint.bind(this, h, T)
|
|
153
|
+
}), E] }) : /* @__PURE__ */ y(d, {
|
|
147
154
|
points: m,
|
|
148
155
|
graphProps: i,
|
|
149
156
|
closed: e
|
|
150
157
|
}),
|
|
151
|
-
(
|
|
158
|
+
(S || []).map((e, t) => /* @__PURE__ */ y(l, {
|
|
152
159
|
from: e.from,
|
|
153
160
|
to: e.to,
|
|
154
161
|
onDrag: this.dragLine.bind(this, e),
|
|
155
|
-
...
|
|
156
|
-
onClick: this.clickPoint.bind(this, h,
|
|
162
|
+
...C,
|
|
163
|
+
onClick: this.clickPoint.bind(this, h, T)
|
|
157
164
|
}, `line-${t}`)),
|
|
158
165
|
(m || []).map((e, n) => [/* @__PURE__ */ y(o, {
|
|
159
166
|
coordinatesOnHover: t,
|
|
@@ -161,13 +168,15 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
161
168
|
x: e.x,
|
|
162
169
|
y: e.y,
|
|
163
170
|
onDrag: this.dragPoint.bind(this, n, e),
|
|
164
|
-
...
|
|
171
|
+
...C,
|
|
165
172
|
onClick: this.clickPoint.bind(this, e, n)
|
|
166
173
|
}, `point-${n}`), g && Object.prototype.hasOwnProperty.call(e, "label") ? x.createPortal(/* @__PURE__ */ y(c, {
|
|
167
174
|
inputRef: (e) => this.input[n] = e,
|
|
175
|
+
autoFocus: v === n,
|
|
168
176
|
disabled: r || !_,
|
|
169
177
|
mark: e,
|
|
170
178
|
graphProps: i,
|
|
179
|
+
onBlur: this.stopEditingLabel,
|
|
171
180
|
onChange: (t) => this.labelChange({
|
|
172
181
|
...e,
|
|
173
182
|
label: t
|
|
@@ -175,7 +184,7 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
175
184
|
}), g) : null])
|
|
176
185
|
] });
|
|
177
186
|
}
|
|
178
|
-
}, D = class extends f.Component {
|
|
187
|
+
}, D = E, O = class extends f.Component {
|
|
179
188
|
static propTypes = {
|
|
180
189
|
...s,
|
|
181
190
|
graphProps: _.GraphPropsType.isRequired
|
|
@@ -239,7 +248,7 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
239
248
|
};
|
|
240
249
|
render() {
|
|
241
250
|
let { coordinatesOnHover: e, mark: t, graphProps: n, onClick: r, isToolActive: i, labelNode: a, labelModeEnabled: o, limitLabeling: s } = this.props, { mark: c } = this.state;
|
|
242
|
-
return /* @__PURE__ */ y(
|
|
251
|
+
return /* @__PURE__ */ y(D, {
|
|
243
252
|
...c || t,
|
|
244
253
|
coordinatesOnHover: e,
|
|
245
254
|
onChange: this.change,
|
|
@@ -259,4 +268,4 @@ var S = /* @__PURE__ */ e(t(), 1), C = v("pie-lib:graphing:polygon"), w = (e, t)
|
|
|
259
268
|
}
|
|
260
269
|
};
|
|
261
270
|
//#endregion
|
|
262
|
-
export { D as default };
|
|
271
|
+
export { D as BaseComponent, E as RawBaseComponent, w as buildLines, O as default, T as swap };
|
|
@@ -56,7 +56,7 @@ var g = p("polygon")(({ disabled: e, correctness: t }) => ({
|
|
|
56
56
|
...o
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
}, b = u({
|
|
59
|
+
}, b = y, x = u({
|
|
60
60
|
bounds: (t, { domain: r, range: i }) => {
|
|
61
61
|
let { points: a } = t;
|
|
62
62
|
return e(n(a), r, i);
|
|
@@ -69,6 +69,6 @@ var g = p("polygon")(({ disabled: e, correctness: t }) => ({
|
|
|
69
69
|
let { points: r } = e;
|
|
70
70
|
return r.map((e) => t(e).add(t(n)));
|
|
71
71
|
}
|
|
72
|
-
})(
|
|
72
|
+
})(b);
|
|
73
73
|
//#endregion
|
|
74
|
-
export {
|
|
74
|
+
export { b as Polygon, y as RawPolygon, x as default, v as getPointString };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getAdjustedGraphLimits as e, thinnerShapesNeeded as t } from "../../utils.js";
|
|
2
|
-
import n from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
2
|
+
import { clsx as n } from "../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
3
3
|
import { ArrowMarker as r, genUid as i } from "../shared/arrow-head.js";
|
|
4
4
|
import { lineBase as a, lineToolComponent as o, styles as s } from "../shared/line/index.js";
|
|
5
5
|
import "react";
|
|
@@ -68,4 +68,4 @@ h.propTypes = {
|
|
|
68
68
|
};
|
|
69
69
|
var g = o(a(h));
|
|
70
70
|
//#endregion
|
|
71
|
-
export { g as default };
|
|
71
|
+
export { h as RayLine, g as default };
|
|
@@ -87,6 +87,10 @@ export declare const lineToolComponent: (Component: any) => {
|
|
|
87
87
|
};
|
|
88
88
|
export declare const lineBase: (Comp: any, opts: any) => {
|
|
89
89
|
new (props: {}): {
|
|
90
|
+
state: {
|
|
91
|
+
editingLabel: null;
|
|
92
|
+
};
|
|
93
|
+
componentDidUpdate(prevProps: any): void;
|
|
90
94
|
onChangePoint: any;
|
|
91
95
|
dragComp: ({ from: draggedFrom, to: draggedTo }: {
|
|
92
96
|
from: any;
|
|
@@ -95,6 +99,7 @@ export declare const lineBase: (Comp: any, opts: any) => {
|
|
|
95
99
|
dragFrom: any;
|
|
96
100
|
dragTo: any;
|
|
97
101
|
labelChange: any;
|
|
102
|
+
stopEditingLabel: any;
|
|
98
103
|
clickPoint: any;
|
|
99
104
|
input: {};
|
|
100
105
|
render(): React.JSX.Element;
|
|
@@ -102,7 +107,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
|
|
|
102
107
|
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
103
108
|
forceUpdate(callback?: (() => void) | undefined): void;
|
|
104
109
|
readonly props: Readonly<{}>;
|
|
105
|
-
state: Readonly<{}>;
|
|
106
110
|
refs: {
|
|
107
111
|
[key: string]: React.ReactInstance;
|
|
108
112
|
};
|
|
@@ -111,7 +115,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
|
|
|
111
115
|
componentWillUnmount?(): void;
|
|
112
116
|
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
113
117
|
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
114
|
-
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
115
118
|
componentWillMount?(): void;
|
|
116
119
|
UNSAFE_componentWillMount?(): void;
|
|
117
120
|
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
@@ -120,6 +123,10 @@ export declare const lineBase: (Comp: any, opts: any) => {
|
|
|
120
123
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
121
124
|
};
|
|
122
125
|
new (props: {}, context: any): {
|
|
126
|
+
state: {
|
|
127
|
+
editingLabel: null;
|
|
128
|
+
};
|
|
129
|
+
componentDidUpdate(prevProps: any): void;
|
|
123
130
|
onChangePoint: any;
|
|
124
131
|
dragComp: ({ from: draggedFrom, to: draggedTo }: {
|
|
125
132
|
from: any;
|
|
@@ -128,6 +135,7 @@ export declare const lineBase: (Comp: any, opts: any) => {
|
|
|
128
135
|
dragFrom: any;
|
|
129
136
|
dragTo: any;
|
|
130
137
|
labelChange: any;
|
|
138
|
+
stopEditingLabel: any;
|
|
131
139
|
clickPoint: any;
|
|
132
140
|
input: {};
|
|
133
141
|
render(): React.JSX.Element;
|
|
@@ -135,7 +143,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
|
|
|
135
143
|
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
136
144
|
forceUpdate(callback?: (() => void) | undefined): void;
|
|
137
145
|
readonly props: Readonly<{}>;
|
|
138
|
-
state: Readonly<{}>;
|
|
139
146
|
refs: {
|
|
140
147
|
[key: string]: React.ReactInstance;
|
|
141
148
|
};
|
|
@@ -144,7 +151,6 @@ export declare const lineBase: (Comp: any, opts: any) => {
|
|
|
144
151
|
componentWillUnmount?(): void;
|
|
145
152
|
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
146
153
|
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
147
|
-
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
148
154
|
componentWillMount?(): void;
|
|
149
155
|
UNSAFE_componentWillMount?(): void;
|
|
150
156
|
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { equalPoints as e, getMiddleOfTwoPoints as t, sameAxes as n, stripEmptyLabel as r } from "../../../utils.js";
|
|
2
2
|
import { correct as i, disabled as a, disabledSecondary as o, incorrect as s, missing as c } from "../styles.js";
|
|
3
3
|
import { BasePoint as l } from "../point/index.js";
|
|
4
|
-
import u from "../../../mark-label.js";
|
|
4
|
+
import { MarkLabel as u } from "../../../mark-label.js";
|
|
5
5
|
import d from "react";
|
|
6
6
|
import f from "prop-types";
|
|
7
7
|
import { cloneDeep as p, isEmpty as m, isEqual as h } from "@pie-element/shared-lodash";
|
|
@@ -154,6 +154,10 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
|
|
|
154
154
|
labelModeEnabled: f.bool,
|
|
155
155
|
labelNode: f.object
|
|
156
156
|
};
|
|
157
|
+
state = { editingLabel: null };
|
|
158
|
+
componentDidUpdate(e) {
|
|
159
|
+
e.labelModeEnabled && !this.props.labelModeEnabled && this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
160
|
+
}
|
|
157
161
|
onChangePoint = (n) => {
|
|
158
162
|
let { middle: r, onChange: i } = this.props, { from: a, to: o } = n;
|
|
159
163
|
e(a, o) || (r && (n.middle = {
|
|
@@ -191,6 +195,9 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
|
|
|
191
195
|
let { changeMarkProps: n } = this.props, r = { ...e };
|
|
192
196
|
(!e.label || m(e.label)) && delete r.label, n({ [t]: r });
|
|
193
197
|
};
|
|
198
|
+
stopEditingLabel = () => {
|
|
199
|
+
this.state.editingLabel !== null && this.setState({ editingLabel: null });
|
|
200
|
+
};
|
|
194
201
|
clickPoint = (e, n, i) => {
|
|
195
202
|
let { changeMarkProps: a, disabled: o, from: s, to: c, middle: l, labelModeEnabled: u, limitLabeling: d, onClick: f } = this.props;
|
|
196
203
|
if (!u) {
|
|
@@ -208,41 +215,47 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
|
|
|
208
215
|
label: "",
|
|
209
216
|
...e
|
|
210
217
|
}
|
|
211
|
-
}), this.
|
|
218
|
+
}), this.setState({ editingLabel: n }));
|
|
212
219
|
};
|
|
213
220
|
input = {};
|
|
214
221
|
render() {
|
|
215
|
-
let { coordinatesOnHover: e, graphProps: t, onDragStart: n, onDragStop: r, from: i, to: c, middle: l, disabled: d, correctness: f, onClick: p, labelNode: m, labelModeEnabled: h } = this.props, g = {
|
|
222
|
+
let { coordinatesOnHover: e, graphProps: t, onDragStart: n, onDragStop: r, from: i, to: c, middle: l, disabled: d, correctness: f, onClick: p, labelNode: m, labelModeEnabled: h } = this.props, { editingLabel: g } = this.state, v = {
|
|
216
223
|
graphProps: t,
|
|
217
224
|
onDragStart: n,
|
|
218
225
|
onDragStop: r,
|
|
219
226
|
disabled: d,
|
|
220
227
|
correctness: f,
|
|
221
228
|
onClick: p
|
|
222
|
-
},
|
|
223
|
-
return m && (i && Object.prototype.hasOwnProperty.call(i, "label") && (
|
|
229
|
+
}, y = c ? _.toDegrees(_.angle(i, c)) : 0, b = null, C = null, E = null;
|
|
230
|
+
return m && (i && Object.prototype.hasOwnProperty.call(i, "label") && (b = w.createPortal(/* @__PURE__ */ x(u, {
|
|
224
231
|
inputRef: (e) => this.input.from = e,
|
|
232
|
+
autoFocus: g === "from",
|
|
225
233
|
disabled: !h,
|
|
226
234
|
mark: i,
|
|
227
235
|
graphProps: t,
|
|
236
|
+
onBlur: this.stopEditingLabel,
|
|
228
237
|
onChange: (e) => this.labelChange({
|
|
229
238
|
...i,
|
|
230
239
|
label: e
|
|
231
240
|
}, "from")
|
|
232
|
-
}), m)), c && Object.prototype.hasOwnProperty.call(c, "label") && (
|
|
241
|
+
}), m)), c && Object.prototype.hasOwnProperty.call(c, "label") && (C = w.createPortal(/* @__PURE__ */ x(u, {
|
|
233
242
|
inputRef: (e) => this.input.to = e,
|
|
243
|
+
autoFocus: g === "to",
|
|
234
244
|
disabled: !h,
|
|
235
245
|
mark: c,
|
|
236
246
|
graphProps: t,
|
|
247
|
+
onBlur: this.stopEditingLabel,
|
|
237
248
|
onChange: (e) => this.labelChange({
|
|
238
249
|
...c,
|
|
239
250
|
label: e
|
|
240
251
|
}, "to")
|
|
241
|
-
}), m)), l && Object.prototype.hasOwnProperty.call(l, "label") && (
|
|
252
|
+
}), m)), l && Object.prototype.hasOwnProperty.call(l, "label") && (E = w.createPortal(/* @__PURE__ */ x(u, {
|
|
242
253
|
inputRef: (e) => this.input.middle = e,
|
|
254
|
+
autoFocus: g === "middle",
|
|
243
255
|
disabled: !h,
|
|
244
256
|
mark: l,
|
|
245
257
|
graphProps: t,
|
|
258
|
+
onBlur: this.stopEditingLabel,
|
|
246
259
|
onChange: (e) => this.labelChange({
|
|
247
260
|
...l,
|
|
248
261
|
label: e
|
|
@@ -256,31 +269,31 @@ var T = b("g")(({ disabled: e, correctness: t }) => ({
|
|
|
256
269
|
to: c,
|
|
257
270
|
middle: l,
|
|
258
271
|
onDrag: this.dragComp,
|
|
259
|
-
...
|
|
272
|
+
...v,
|
|
260
273
|
onClick: (e) => this.clickPoint(l, "middle", e)
|
|
261
274
|
}),
|
|
262
|
-
|
|
275
|
+
E,
|
|
263
276
|
/* @__PURE__ */ x(o, {
|
|
264
277
|
x: i.x,
|
|
265
278
|
y: i.y,
|
|
266
279
|
labelNode: m,
|
|
267
280
|
coordinatesOnHover: e,
|
|
268
281
|
onDrag: this.dragFrom,
|
|
269
|
-
...
|
|
282
|
+
...v,
|
|
270
283
|
onClick: (e) => this.clickPoint(i, "from", e)
|
|
271
284
|
}),
|
|
272
|
-
|
|
285
|
+
b,
|
|
273
286
|
c && /* @__PURE__ */ x(s, {
|
|
274
287
|
x: c.x,
|
|
275
288
|
y: c.y,
|
|
276
|
-
angle:
|
|
289
|
+
angle: y,
|
|
277
290
|
labelNode: m,
|
|
278
291
|
coordinatesOnHover: e,
|
|
279
292
|
onDrag: this.dragTo,
|
|
280
|
-
...
|
|
293
|
+
...v,
|
|
281
294
|
onClick: (e) => this.clickPoint(c, "to", e)
|
|
282
295
|
}),
|
|
283
|
-
|
|
296
|
+
C
|
|
284
297
|
]
|
|
285
298
|
});
|
|
286
299
|
}
|