@pie-lib/plot 4.0.3 → 4.0.4-next.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/dist/_virtual/_rolldown/runtime.js +23 -0
- package/dist/draggable.d.ts +13 -0
- package/dist/draggable.js +13 -0
- package/dist/graph-props.d.ts +22 -0
- package/dist/graph-props.js +29 -0
- package/dist/grid-draggable.d.ts +91 -0
- package/dist/grid-draggable.js +168 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +8 -0
- package/dist/label.d.ts +30 -0
- package/dist/label.js +132 -0
- package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +28 -0
- package/dist/node_modules/.bun/react-draggable@3.3.2/node_modules/react-draggable/dist/react-draggable.js +914 -0
- package/dist/root.d.ts +68 -0
- package/dist/root.js +302 -0
- package/dist/trig.d.ts +41 -0
- package/dist/trig.js +47 -0
- package/dist/types.d.ts +125 -0
- package/dist/types.js +46 -0
- package/dist/utils.d.ts +40 -0
- package/dist/utils.js +82 -0
- package/package.json +27 -20
- package/CHANGELOG.json +0 -17
- package/CHANGELOG.md +0 -838
- package/LICENSE.md +0 -5
- package/lib/draggable.js +0 -44
- package/lib/draggable.js.map +0 -1
- package/lib/graph-props.js +0 -46
- package/lib/graph-props.js.map +0 -1
- package/lib/grid-draggable.js +0 -361
- package/lib/grid-draggable.js.map +0 -1
- package/lib/index.js +0 -44
- package/lib/index.js.map +0 -1
- package/lib/label.js +0 -173
- package/lib/label.js.map +0 -1
- package/lib/root.js +0 -474
- package/lib/root.js.map +0 -1
- package/lib/trig.js +0 -149
- package/lib/trig.js.map +0 -1
- package/lib/types.js +0 -40
- package/lib/types.js.map +0 -1
- package/lib/utils.js +0 -165
- package/lib/utils.js.map +0 -1
- package/src/__tests__/draggable.test.jsx +0 -41
- package/src/__tests__/grid-draggable.test.jsx +0 -487
- package/src/__tests__/root.test.jsx +0 -277
- package/src/__tests__/trig.test.js +0 -163
- package/src/__tests__/utils.test.js +0 -229
- package/src/draggable.jsx +0 -11
- package/src/graph-props.js +0 -34
- package/src/grid-draggable.jsx +0 -332
- package/src/index.js +0 -9
- package/src/label.jsx +0 -199
- package/src/root.jsx +0 -485
- package/src/trig.js +0 -151
- package/src/types.js +0 -41
- package/src/utils.js +0 -167
package/dist/root.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/root.jsx
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
|
+
export declare class Root extends React.Component {
|
|
12
|
+
constructor(props: any);
|
|
13
|
+
static propTypes: {
|
|
14
|
+
title: PropTypes.Requireable<string>;
|
|
15
|
+
children: PropTypes.Validator<NonNullable<NonNullable<PropTypes.ReactNodeLike>>>;
|
|
16
|
+
defineChart: PropTypes.Requireable<boolean>;
|
|
17
|
+
disabledLabels: PropTypes.Requireable<boolean>;
|
|
18
|
+
disabledTitle: PropTypes.Requireable<boolean>;
|
|
19
|
+
graphProps: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
20
|
+
scale: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
21
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
22
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
23
|
+
}>>>;
|
|
24
|
+
snap: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
25
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
26
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
27
|
+
}>>>;
|
|
28
|
+
domain: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
29
|
+
min: PropTypes.Validator<number>;
|
|
30
|
+
max: PropTypes.Validator<number>;
|
|
31
|
+
step: PropTypes.Requireable<number>;
|
|
32
|
+
}>>>;
|
|
33
|
+
range: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
34
|
+
min: PropTypes.Validator<number>;
|
|
35
|
+
max: PropTypes.Validator<number>;
|
|
36
|
+
step: PropTypes.Requireable<number>;
|
|
37
|
+
}>>>;
|
|
38
|
+
size: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
39
|
+
width: PropTypes.Validator<number>;
|
|
40
|
+
height: PropTypes.Validator<number>;
|
|
41
|
+
}>>>;
|
|
42
|
+
}>>>;
|
|
43
|
+
isChart: PropTypes.Requireable<boolean>;
|
|
44
|
+
labels: PropTypes.Requireable<object>;
|
|
45
|
+
labelsPlaceholders: PropTypes.Requireable<object>;
|
|
46
|
+
onChangeTitle: PropTypes.Requireable<(...args: any[]) => any>;
|
|
47
|
+
onMouseMove: PropTypes.Requireable<(...args: any[]) => any>;
|
|
48
|
+
showLabels: PropTypes.Requireable<boolean>;
|
|
49
|
+
showTitle: PropTypes.Requireable<boolean>;
|
|
50
|
+
showPixelGuides: PropTypes.Requireable<boolean>;
|
|
51
|
+
rootRef: PropTypes.Requireable<(...args: any[]) => any>;
|
|
52
|
+
onChangeLabels: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
|
+
titlePlaceholder: PropTypes.Requireable<string>;
|
|
54
|
+
mathMlOptions: PropTypes.Requireable<object>;
|
|
55
|
+
labelsCharactersLimit: PropTypes.Requireable<number>;
|
|
56
|
+
};
|
|
57
|
+
mouseMove: any;
|
|
58
|
+
componentDidMount(): void;
|
|
59
|
+
componentWillUnmount(): void;
|
|
60
|
+
componentDidUpdate(prevProps: any): void;
|
|
61
|
+
onChangeLabel: any;
|
|
62
|
+
measureTitleHeight: any;
|
|
63
|
+
handleKeyDown: any;
|
|
64
|
+
setupVisibilityObserver: any;
|
|
65
|
+
cleanupVisibilityObserver: any;
|
|
66
|
+
render(): React.JSX.Element;
|
|
67
|
+
}
|
|
68
|
+
export default Root;
|
package/dist/root.js
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { ChildrenType as e, GraphPropsType as t } from "./types.js";
|
|
2
|
+
import { extractTextFromHTML as n, isEmptyObject as r, isEmptyString as i } from "./utils.js";
|
|
3
|
+
import a from "./label.js";
|
|
4
|
+
import o from "react";
|
|
5
|
+
import { styled as s } from "@mui/material/styles";
|
|
6
|
+
import c from "prop-types";
|
|
7
|
+
import { pointer as l, select as u } from "d3-selection";
|
|
8
|
+
import * as d from "@pie-lib/render-ui";
|
|
9
|
+
import { Readable as f, color as p } from "@pie-lib/render-ui";
|
|
10
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
11
|
+
import g from "@pie-lib/editable-html-tip-tap";
|
|
12
|
+
//#region src/root.tsx
|
|
13
|
+
function _(e) {
|
|
14
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
15
|
+
}
|
|
16
|
+
function v(e, t) {
|
|
17
|
+
return !e || _(e) ? e : _(e.default) ? e.default : t && _(e[t]) ? e[t] : t && _(e[t]?.default) ? e[t].default : e;
|
|
18
|
+
}
|
|
19
|
+
var y = v(f, "Readable") || v(S.Readable, "Readable"), b = d, x = b.default, S = x && typeof x == "object" ? x : b, C = { "& .ProseMirror p.is-editor-empty::before, & .ProseMirror div.is-editor-empty::before": {
|
|
20
|
+
left: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
width: "100%",
|
|
23
|
+
textAlign: "center"
|
|
24
|
+
} }, w = s("div")(({ theme: e }) => ({
|
|
25
|
+
border: `solid 1px ${p.primaryLight()}`,
|
|
26
|
+
color: p.defaults.TEXT,
|
|
27
|
+
backgroundColor: e.palette.common.white,
|
|
28
|
+
touchAction: "none",
|
|
29
|
+
position: "relative",
|
|
30
|
+
boxSizing: "unset"
|
|
31
|
+
})), T = s("div")({
|
|
32
|
+
display: "flex",
|
|
33
|
+
position: "relative"
|
|
34
|
+
}), E = s("svg")({
|
|
35
|
+
paddingLeft: "50px",
|
|
36
|
+
overflow: "visible",
|
|
37
|
+
boxSizing: "content-box"
|
|
38
|
+
}), D = s("svg")({
|
|
39
|
+
overflow: "visible",
|
|
40
|
+
boxSizing: "content-box"
|
|
41
|
+
}), O = s("g")({
|
|
42
|
+
cursor: "pointer",
|
|
43
|
+
userSelect: "none"
|
|
44
|
+
}), k = s("div")(({ theme: e }) => ({
|
|
45
|
+
color: p.defaults.TEXT,
|
|
46
|
+
fontSize: e.typography.fontSize + 2,
|
|
47
|
+
padding: `${e.spacing(1.5)} ${e.spacing(.5)} 0`,
|
|
48
|
+
textAlign: "center",
|
|
49
|
+
"&.disabled": { pointerEvents: "none" },
|
|
50
|
+
"&.rightMargin": { marginRight: "74px" },
|
|
51
|
+
"& p": { margin: 0 },
|
|
52
|
+
...C
|
|
53
|
+
})), A = s("div")(({ theme: e }) => ({
|
|
54
|
+
color: p.defaults.TEXT,
|
|
55
|
+
fontSize: e.typography.fontSize + 4,
|
|
56
|
+
padding: `${e.spacing(1.5)} ${e.spacing(.5)} 0`,
|
|
57
|
+
textAlign: "center",
|
|
58
|
+
"&.disabled": { pointerEvents: "none" },
|
|
59
|
+
"&.rightMargin": { marginRight: "74px" },
|
|
60
|
+
"& p": { margin: 0 },
|
|
61
|
+
...C
|
|
62
|
+
})), j = s("div")({
|
|
63
|
+
display: "flex",
|
|
64
|
+
paddingTop: "6px"
|
|
65
|
+
}), M = s("div")({
|
|
66
|
+
display: "flex",
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
width: "100px",
|
|
70
|
+
pointerEvents: "none",
|
|
71
|
+
userSelect: "none"
|
|
72
|
+
}), N = s("div")({
|
|
73
|
+
width: "70px",
|
|
74
|
+
display: "flex",
|
|
75
|
+
flexDirection: "column",
|
|
76
|
+
marginRight: "6px"
|
|
77
|
+
}), P = s("div")({
|
|
78
|
+
textAlign: "right",
|
|
79
|
+
height: "20px",
|
|
80
|
+
pointerEvents: "none",
|
|
81
|
+
userSelect: "none",
|
|
82
|
+
"&:not(:last-child)": { marginBottom: "80px" }
|
|
83
|
+
}), F = class extends o.Component {
|
|
84
|
+
constructor(e) {
|
|
85
|
+
super(e), this.state = { titleHeight: 0 }, this.resizeObserver = null;
|
|
86
|
+
}
|
|
87
|
+
static propTypes = {
|
|
88
|
+
title: c.string,
|
|
89
|
+
children: e,
|
|
90
|
+
defineChart: c.bool,
|
|
91
|
+
disabledLabels: c.bool,
|
|
92
|
+
disabledTitle: c.bool,
|
|
93
|
+
graphProps: t.isRequired,
|
|
94
|
+
isChart: c.bool,
|
|
95
|
+
labels: c.object,
|
|
96
|
+
labelsPlaceholders: c.object,
|
|
97
|
+
onChangeTitle: c.func,
|
|
98
|
+
onMouseMove: c.func,
|
|
99
|
+
showLabels: c.bool,
|
|
100
|
+
showTitle: c.bool,
|
|
101
|
+
showPixelGuides: c.bool,
|
|
102
|
+
rootRef: c.func,
|
|
103
|
+
onChangeLabels: c.func,
|
|
104
|
+
titlePlaceholder: c.string,
|
|
105
|
+
mathMlOptions: c.object,
|
|
106
|
+
labelsCharactersLimit: c.number
|
|
107
|
+
};
|
|
108
|
+
mouseMove = (e, t) => {
|
|
109
|
+
let { graphProps: n, onMouseMove: r } = this.props;
|
|
110
|
+
if (!r) return;
|
|
111
|
+
let { scale: i, snap: a } = n, o = l(t, e.node()), s = i.x.invert(o[0]), c = i.y.invert(o[1]);
|
|
112
|
+
r({
|
|
113
|
+
x: a.x(s),
|
|
114
|
+
y: a.y(c)
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
componentDidMount() {
|
|
118
|
+
let e = u(this.g);
|
|
119
|
+
e.on("mousemove", this.mouseMove.bind(this, e)), this.measureTitleHeight(), this.setupVisibilityObserver();
|
|
120
|
+
}
|
|
121
|
+
componentWillUnmount() {
|
|
122
|
+
u(this.g).on("mousemove", null), this.cleanupVisibilityObserver();
|
|
123
|
+
}
|
|
124
|
+
componentDidUpdate(e) {
|
|
125
|
+
e.title !== this.props.title && this.measureTitleHeight();
|
|
126
|
+
}
|
|
127
|
+
onChangeLabel = (e, t) => {
|
|
128
|
+
let { labels: n, onChangeLabels: r, isChart: i } = this.props;
|
|
129
|
+
if (r) {
|
|
130
|
+
if (i) {
|
|
131
|
+
r(t === "left" ? "range" : "domain", e);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
r({
|
|
135
|
+
...n,
|
|
136
|
+
[t]: e
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
measureTitleHeight = () => {
|
|
141
|
+
let e = this.titleRef;
|
|
142
|
+
if (e) {
|
|
143
|
+
let t = e.clientHeight;
|
|
144
|
+
this.setState({
|
|
145
|
+
titleHeight: t,
|
|
146
|
+
prevTitle: this.props.title
|
|
147
|
+
}), !this.resizeObserver && typeof ResizeObserver < "u" && this.setupVisibilityObserver();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
handleKeyDown = () => {
|
|
151
|
+
setTimeout(() => {
|
|
152
|
+
this.measureTitleHeight();
|
|
153
|
+
}, 0);
|
|
154
|
+
};
|
|
155
|
+
setupVisibilityObserver = () => {
|
|
156
|
+
typeof ResizeObserver < "u" && this.titleRef && (this.resizeObserver = new ResizeObserver((e) => {
|
|
157
|
+
for (let t of e) {
|
|
158
|
+
let { width: e, height: n } = t.contentRect;
|
|
159
|
+
if (e > 0 && n > 0) {
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
this.measureTitleHeight();
|
|
162
|
+
}, 10);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}), this.resizeObserver.observe(this.titleRef));
|
|
167
|
+
};
|
|
168
|
+
cleanupVisibilityObserver = () => {
|
|
169
|
+
this.resizeObserver &&= (this.resizeObserver.disconnect(), null);
|
|
170
|
+
};
|
|
171
|
+
render() {
|
|
172
|
+
let { disabledTitle: e, disabledLabels: t, labels: o, labelsPlaceholders: s, titlePlaceholder: c, graphProps: l, children: u, defineChart: d, onChangeTitle: f, isChart: p, showLabels: _, showPixelGuides: v, showTitle: b, title: x, rootRef: S, mathMlOptions: C = {}, labelsCharactersLimit: F } = this.props, { size: { width: I = 500, height: L = 500 }, domain: R, range: z } = l, B = i(n(o?.left)) && r(s) ? 48 : 70, V = i(n(o?.right)) && r(s) ? 48 : 70, H = I + B + V + (R.padding || 0) * 2, U = L + 80 + (z.padding || 0) * 2, W = [
|
|
173
|
+
"bold",
|
|
174
|
+
"italic",
|
|
175
|
+
"underline",
|
|
176
|
+
"superscript",
|
|
177
|
+
"subscript",
|
|
178
|
+
"strikethrough",
|
|
179
|
+
"math"
|
|
180
|
+
], G = d && v ? L - 160 : L, K = parseInt(I / 100), q = parseInt(G / 100), J = parseInt(G % 100), { titleHeight: Y } = this.state;
|
|
181
|
+
return /* @__PURE__ */ h(w, { children: [
|
|
182
|
+
v && /* @__PURE__ */ m(j, {
|
|
183
|
+
style: { marginLeft: p ? 80 : _ ? 30 : 10 },
|
|
184
|
+
children: [...Array(K + 1).keys()].map((e) => /* @__PURE__ */ m(y, {
|
|
185
|
+
false: !0,
|
|
186
|
+
children: /* @__PURE__ */ h(M, { children: [/* @__PURE__ */ h("div", { children: [e * 100, "px"] }), /* @__PURE__ */ m("div", { children: "|" })] })
|
|
187
|
+
}, `top-guide-${e}`))
|
|
188
|
+
}),
|
|
189
|
+
b && (e ? /* @__PURE__ */ m("div", {
|
|
190
|
+
ref: (e) => this.titleRef = e,
|
|
191
|
+
style: {
|
|
192
|
+
...p && { width: H },
|
|
193
|
+
...i(n(x)) && { display: "none" }
|
|
194
|
+
},
|
|
195
|
+
children: m(p ? A : k, {
|
|
196
|
+
className: "disabled",
|
|
197
|
+
dangerouslySetInnerHTML: { __html: x || "" }
|
|
198
|
+
})
|
|
199
|
+
}) : /* @__PURE__ */ m("div", {
|
|
200
|
+
ref: (e) => this.titleRef = e,
|
|
201
|
+
children: m(p ? A : k, {
|
|
202
|
+
className: v ? "rightMargin" : "",
|
|
203
|
+
children: /* @__PURE__ */ m(g, {
|
|
204
|
+
...p && { width: H },
|
|
205
|
+
markup: x || "",
|
|
206
|
+
onChange: f,
|
|
207
|
+
placeholder: d && c || !e && "Click here to add a title for this graph",
|
|
208
|
+
toolbarOpts: {
|
|
209
|
+
noPadding: !0,
|
|
210
|
+
noBorder: !0
|
|
211
|
+
},
|
|
212
|
+
activePlugins: W,
|
|
213
|
+
disableScrollbar: !0,
|
|
214
|
+
onKeyDown: this.handleKeyDown
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
})),
|
|
218
|
+
_ && !p && /* @__PURE__ */ m(a, {
|
|
219
|
+
side: "top",
|
|
220
|
+
text: o.top,
|
|
221
|
+
disabledLabel: t,
|
|
222
|
+
placeholder: s?.top,
|
|
223
|
+
graphHeight: U,
|
|
224
|
+
graphWidth: H,
|
|
225
|
+
onChange: (e) => this.onChangeLabel(e, "top"),
|
|
226
|
+
mathMlOptions: C,
|
|
227
|
+
preventNewLines: !0,
|
|
228
|
+
charactersLimit: F
|
|
229
|
+
}),
|
|
230
|
+
/* @__PURE__ */ h(T, { children: [
|
|
231
|
+
_ && /* @__PURE__ */ m(a, {
|
|
232
|
+
side: "left",
|
|
233
|
+
text: o.left,
|
|
234
|
+
disabledLabel: t,
|
|
235
|
+
placeholder: s?.left,
|
|
236
|
+
graphHeight: U,
|
|
237
|
+
graphWidth: H,
|
|
238
|
+
isChartLeftLabel: p && !d,
|
|
239
|
+
isDefineChartLeftLabel: p && d,
|
|
240
|
+
onChange: (e) => this.onChangeLabel(e, "left"),
|
|
241
|
+
mathMlOptions: C,
|
|
242
|
+
preventNewLines: !0,
|
|
243
|
+
charactersLimit: F
|
|
244
|
+
}),
|
|
245
|
+
m(d ? E : D, {
|
|
246
|
+
width: H,
|
|
247
|
+
height: U,
|
|
248
|
+
children: /* @__PURE__ */ m(O, {
|
|
249
|
+
ref: (e) => {
|
|
250
|
+
this.g = e, S && S(e);
|
|
251
|
+
},
|
|
252
|
+
transform: `translate(${B + (R.padding || 0)}, ${40 + (z.padding || 0)})`,
|
|
253
|
+
children: u
|
|
254
|
+
})
|
|
255
|
+
}),
|
|
256
|
+
_ && !p && /* @__PURE__ */ m(a, {
|
|
257
|
+
side: "right",
|
|
258
|
+
text: o.right,
|
|
259
|
+
disabledLabel: t,
|
|
260
|
+
placeholder: s?.right,
|
|
261
|
+
graphHeight: U,
|
|
262
|
+
graphWidth: H,
|
|
263
|
+
onChange: (e) => this.onChangeLabel(e, "right"),
|
|
264
|
+
mathMlOptions: C,
|
|
265
|
+
preventNewLines: !0,
|
|
266
|
+
charactersLimit: F
|
|
267
|
+
}),
|
|
268
|
+
v && /* @__PURE__ */ m(N, {
|
|
269
|
+
style: {
|
|
270
|
+
paddingTop: J,
|
|
271
|
+
marginTop: 31
|
|
272
|
+
},
|
|
273
|
+
children: [...Array(q + 1).keys()].reverse().map((e) => /* @__PURE__ */ m(y, {
|
|
274
|
+
false: !0,
|
|
275
|
+
children: /* @__PURE__ */ h(P, { children: [
|
|
276
|
+
"━ ",
|
|
277
|
+
e * 100,
|
|
278
|
+
"px"
|
|
279
|
+
] })
|
|
280
|
+
}, `top-guide-${e}`))
|
|
281
|
+
})
|
|
282
|
+
] }),
|
|
283
|
+
_ && /* @__PURE__ */ m(a, {
|
|
284
|
+
side: "bottom",
|
|
285
|
+
text: o.bottom,
|
|
286
|
+
disabledLabel: t,
|
|
287
|
+
placeholder: s?.bottom,
|
|
288
|
+
graphHeight: U,
|
|
289
|
+
graphWidth: H,
|
|
290
|
+
titleHeight: Y,
|
|
291
|
+
isChartBottomLabel: p && !d,
|
|
292
|
+
isDefineChartBottomLabel: p && d,
|
|
293
|
+
onChange: (e) => this.onChangeLabel(e, "bottom"),
|
|
294
|
+
mathMlOptions: C,
|
|
295
|
+
preventNewLines: !0,
|
|
296
|
+
charactersLimit: F
|
|
297
|
+
})
|
|
298
|
+
] });
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
//#endregion
|
|
302
|
+
export { F as default };
|
package/dist/trig.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/trig.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import Point from '@mapbox/point-geometry';
|
|
10
|
+
export declare const toDegrees: (radians: any) => number;
|
|
11
|
+
export declare const toRadians: (degrees: any) => number;
|
|
12
|
+
/**
|
|
13
|
+
* return angle in radians between 2 points using counting degrees counter clockwise
|
|
14
|
+
*
|
|
15
|
+
* 0,0 + 1,1 = 45 in radians
|
|
16
|
+
* 1,1 + 0,0 = 45?
|
|
17
|
+
* @param {Point} a
|
|
18
|
+
* @param {Point} b
|
|
19
|
+
*/
|
|
20
|
+
export declare const angle: (a: any, b: any) => number;
|
|
21
|
+
export declare const acuteXAngle: (a: any) => any;
|
|
22
|
+
export declare const acuteYAngle: (a: any) => number;
|
|
23
|
+
export declare const hypotenuse: (a: any, alpha: any) => number;
|
|
24
|
+
/**
|
|
25
|
+
* return 2 edge points for a,b within domain + range.
|
|
26
|
+
* - one edge is from following a -> b to the bounds
|
|
27
|
+
* - one edge is from following b -> a to the bounds
|
|
28
|
+
* @param {{min: number, max: number}} domain
|
|
29
|
+
* @param {{min: number, max: number}} range
|
|
30
|
+
* @param {{x: number, y: number}} a
|
|
31
|
+
* @param {{x: number, y: number}} b
|
|
32
|
+
* @returns [{x: number, y: number}, {x: number, y: number}]
|
|
33
|
+
*/
|
|
34
|
+
export declare const edges: (domain: any, range: any) => (a: any, b: any) => Point[];
|
|
35
|
+
/** get length of side A of a triangle from H and angle Alpha */
|
|
36
|
+
export declare const getOpposingSide: (hyp: any, angle: any) => number;
|
|
37
|
+
/**
|
|
38
|
+
* return the difference between bounds and a as a Point
|
|
39
|
+
* @param {*} bounds
|
|
40
|
+
*/
|
|
41
|
+
export declare const diffEdge: (bounds: any, a: any, b: any) => Point;
|
package/dist/trig.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { __exportAll as e } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { xy as t } from "./utils.js";
|
|
3
|
+
import n from "@mapbox/point-geometry";
|
|
4
|
+
import r from "debug";
|
|
5
|
+
//#region src/trig.ts
|
|
6
|
+
var i = /* @__PURE__ */ e({
|
|
7
|
+
acuteXAngle: () => f,
|
|
8
|
+
acuteYAngle: () => p,
|
|
9
|
+
angle: () => c,
|
|
10
|
+
diffEdge: () => v,
|
|
11
|
+
edges: () => h,
|
|
12
|
+
getOpposingSide: () => g,
|
|
13
|
+
hypotenuse: () => m,
|
|
14
|
+
toDegrees: () => o,
|
|
15
|
+
toRadians: () => s
|
|
16
|
+
}), a = r("pie-lib:plot:trig"), o = (e) => 180 / Math.PI * e, s = (e) => Math.PI / 180 * e, c = (e, t) => {
|
|
17
|
+
let n = t.y - e.y, r = t.x - e.x;
|
|
18
|
+
a(e, t, "vd: ", n, "hd: ", r);
|
|
19
|
+
let i = Math.atan2(n, r);
|
|
20
|
+
return i < 0 ? i + Math.PI * 2 : i;
|
|
21
|
+
}, l = Math.PI / 2, u = Math.PI, d = u + l, f = (e) => (a(o(e)), e < l ? e : Math.abs(e < u || e < d ? u - e : Math.PI * 2 - e)), p = (e) => l - f(e), m = (e, t) => Math.abs(e / Math.sin(t)), h = (e, n) => (r, i) => [v(t(r.x < i.x ? e.max : e.min, r.y < i.y ? n.max : n.min), r, i), v(t(i.x < r.x ? e.max : e.min, i.y < r.y ? n.max : n.min), i, r)], g = (e, t) => (a("[getOpposingSide] hyp: ", e, "angle:", t), Math.abs(e * Math.sin(t))), _ = (e, t) => {
|
|
22
|
+
if (Number.isFinite(e) && Number.isFinite(t)) return e === 0 && t > 0 ? "y" : t === 0 && e > 0 || e < t ? "x" : "y";
|
|
23
|
+
if (isNaN(e) && !isNaN(t)) return "y";
|
|
24
|
+
if (!isNaN(e) && isNaN(t)) return "x";
|
|
25
|
+
if (e === Infinity) return "y";
|
|
26
|
+
if (t === Infinity) return "x";
|
|
27
|
+
console.warn("hypotenuse - which is shorter? x:", e, "y:", t);
|
|
28
|
+
}, v = (e, t, r) => {
|
|
29
|
+
let i = a.enabled ? a.bind(a, `diffEdge: [${t.x},${t.y} -> ${r.x},${r.y}]`) : () => {}, l = c(t, r);
|
|
30
|
+
i("x angle", o(l));
|
|
31
|
+
let u = Math.abs(l - s(90));
|
|
32
|
+
i("y angle", o(u));
|
|
33
|
+
let d = Math.abs(t.x - e.x), f = m(d, u), p = Math.abs(t.y - e.y), h = m(p, l);
|
|
34
|
+
i("x: side", d, "h:", f), i("y: side", p, "h:", h);
|
|
35
|
+
let v = _(f, h);
|
|
36
|
+
if (v !== "x" && v !== "y") throw Error("Cant decide which hypotenuse to use");
|
|
37
|
+
let y = v === "x" ? new n(d, g(f, l)) : new n(g(h, u), p);
|
|
38
|
+
i("point:", y);
|
|
39
|
+
let b = new n(r.x < t.x ? -1 : 1, r.y < t.y ? -1 : 1);
|
|
40
|
+
i("multiplier:", b);
|
|
41
|
+
let x = y.multByPoint(b);
|
|
42
|
+
i("out:", x);
|
|
43
|
+
let S = x.add(new n(t.x, t.y));
|
|
44
|
+
return i("normalized:", S), S;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { i as trig_exports };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/types.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
export declare const BaseDomainRangeType: {
|
|
11
|
+
min: PropTypes.Validator<number>;
|
|
12
|
+
max: PropTypes.Validator<number>;
|
|
13
|
+
step: PropTypes.Requireable<number>;
|
|
14
|
+
};
|
|
15
|
+
export declare const DomainType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
16
|
+
min: PropTypes.Validator<number>;
|
|
17
|
+
max: PropTypes.Validator<number>;
|
|
18
|
+
step: PropTypes.Requireable<number>;
|
|
19
|
+
}>>;
|
|
20
|
+
export declare const RangeType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
21
|
+
min: PropTypes.Validator<number>;
|
|
22
|
+
max: PropTypes.Validator<number>;
|
|
23
|
+
step: PropTypes.Requireable<number>;
|
|
24
|
+
}>>;
|
|
25
|
+
export declare const SizeType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
26
|
+
width: PropTypes.Validator<number>;
|
|
27
|
+
height: PropTypes.Validator<number>;
|
|
28
|
+
}>>;
|
|
29
|
+
export declare const PointType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
30
|
+
x: PropTypes.Validator<number>;
|
|
31
|
+
y: PropTypes.Validator<number>;
|
|
32
|
+
}>>;
|
|
33
|
+
export declare const ChildrenType: PropTypes.Validator<NonNullable<NonNullable<PropTypes.ReactNodeLike>>>;
|
|
34
|
+
export declare const ScaleType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
35
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
36
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
37
|
+
}>>;
|
|
38
|
+
export declare const SnapType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
39
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
40
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
41
|
+
}>>;
|
|
42
|
+
export declare const GraphPropsType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
43
|
+
scale: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
44
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
45
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
46
|
+
}>>>;
|
|
47
|
+
snap: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
48
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
49
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
50
|
+
}>>>;
|
|
51
|
+
domain: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
52
|
+
min: PropTypes.Validator<number>;
|
|
53
|
+
max: PropTypes.Validator<number>;
|
|
54
|
+
step: PropTypes.Requireable<number>;
|
|
55
|
+
}>>>;
|
|
56
|
+
range: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
57
|
+
min: PropTypes.Validator<number>;
|
|
58
|
+
max: PropTypes.Validator<number>;
|
|
59
|
+
step: PropTypes.Requireable<number>;
|
|
60
|
+
}>>>;
|
|
61
|
+
size: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
62
|
+
width: PropTypes.Validator<number>;
|
|
63
|
+
height: PropTypes.Validator<number>;
|
|
64
|
+
}>>>;
|
|
65
|
+
}>>;
|
|
66
|
+
export declare const ToolPropTypeFields: {
|
|
67
|
+
graphProps: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
68
|
+
scale: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
69
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
70
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
71
|
+
}>>>;
|
|
72
|
+
snap: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
73
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
74
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
75
|
+
}>>>;
|
|
76
|
+
domain: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
77
|
+
min: PropTypes.Validator<number>;
|
|
78
|
+
max: PropTypes.Validator<number>;
|
|
79
|
+
step: PropTypes.Requireable<number>;
|
|
80
|
+
}>>>;
|
|
81
|
+
range: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
82
|
+
min: PropTypes.Validator<number>;
|
|
83
|
+
max: PropTypes.Validator<number>;
|
|
84
|
+
step: PropTypes.Requireable<number>;
|
|
85
|
+
}>>>;
|
|
86
|
+
size: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
87
|
+
width: PropTypes.Validator<number>;
|
|
88
|
+
height: PropTypes.Validator<number>;
|
|
89
|
+
}>>>;
|
|
90
|
+
}>>>;
|
|
91
|
+
mark: PropTypes.Requireable<object>;
|
|
92
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
93
|
+
onDelete: PropTypes.Requireable<(...args: any[]) => any>;
|
|
94
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
95
|
+
};
|
|
96
|
+
export declare const ToolPropType: PropTypes.Requireable<PropTypes.InferProps<{
|
|
97
|
+
graphProps: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
98
|
+
scale: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
99
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
100
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
101
|
+
}>>>;
|
|
102
|
+
snap: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
103
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
104
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
105
|
+
}>>>;
|
|
106
|
+
domain: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
107
|
+
min: PropTypes.Validator<number>;
|
|
108
|
+
max: PropTypes.Validator<number>;
|
|
109
|
+
step: PropTypes.Requireable<number>;
|
|
110
|
+
}>>>;
|
|
111
|
+
range: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
112
|
+
min: PropTypes.Validator<number>;
|
|
113
|
+
max: PropTypes.Validator<number>;
|
|
114
|
+
step: PropTypes.Requireable<number>;
|
|
115
|
+
}>>>;
|
|
116
|
+
size: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
117
|
+
width: PropTypes.Validator<number>;
|
|
118
|
+
height: PropTypes.Validator<number>;
|
|
119
|
+
}>>>;
|
|
120
|
+
}>>>;
|
|
121
|
+
mark: PropTypes.Requireable<object>;
|
|
122
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
123
|
+
onDelete: PropTypes.Requireable<(...args: any[]) => any>;
|
|
124
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
125
|
+
}>>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { __exportAll as e } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import t from "prop-types";
|
|
3
|
+
//#region src/types.ts
|
|
4
|
+
var n = /* @__PURE__ */ e({
|
|
5
|
+
BaseDomainRangeType: () => r,
|
|
6
|
+
ChildrenType: () => c,
|
|
7
|
+
DomainType: () => i,
|
|
8
|
+
GraphPropsType: () => d,
|
|
9
|
+
PointType: () => s,
|
|
10
|
+
RangeType: () => a,
|
|
11
|
+
ScaleType: () => l,
|
|
12
|
+
SizeType: () => o,
|
|
13
|
+
SnapType: () => u,
|
|
14
|
+
ToolPropType: () => p,
|
|
15
|
+
ToolPropTypeFields: () => f
|
|
16
|
+
}), r = {
|
|
17
|
+
min: t.number.isRequired,
|
|
18
|
+
max: t.number.isRequired,
|
|
19
|
+
step: t.number
|
|
20
|
+
}, i = t.shape(r), a = t.shape(r), o = t.shape({
|
|
21
|
+
width: t.number.isRequired,
|
|
22
|
+
height: t.number.isRequired
|
|
23
|
+
}), s = t.shape({
|
|
24
|
+
x: t.number.isRequired,
|
|
25
|
+
y: t.number.isRequired
|
|
26
|
+
}), c = t.oneOfType([t.arrayOf(t.node), t.node]).isRequired, l = t.shape({
|
|
27
|
+
x: t.func.isRequired,
|
|
28
|
+
y: t.func.isRequired
|
|
29
|
+
}), u = t.shape({
|
|
30
|
+
x: t.func.isRequired,
|
|
31
|
+
y: t.func.isRequired
|
|
32
|
+
}), d = t.shape({
|
|
33
|
+
scale: l.isRequired,
|
|
34
|
+
snap: u.isRequired,
|
|
35
|
+
domain: i.isRequired,
|
|
36
|
+
range: a.isRequired,
|
|
37
|
+
size: o.isRequired
|
|
38
|
+
}), f = {
|
|
39
|
+
graphProps: d.isRequired,
|
|
40
|
+
mark: t.object,
|
|
41
|
+
onChange: t.func,
|
|
42
|
+
onDelete: t.func,
|
|
43
|
+
onClick: t.func
|
|
44
|
+
}, p = t.shape(f);
|
|
45
|
+
//#endregion
|
|
46
|
+
export { c as ChildrenType, d as GraphPropsType, n as types_exports };
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/utils.js
|
|
3
|
+
* @auto-generated
|
|
4
|
+
*
|
|
5
|
+
* This file is automatically synced from pie-elements and converted to TypeScript.
|
|
6
|
+
* Manual edits will be overwritten on next sync.
|
|
7
|
+
* To make changes, edit the upstream JavaScript file and run sync again.
|
|
8
|
+
*/
|
|
9
|
+
import Point from '@mapbox/point-geometry';
|
|
10
|
+
export declare const xy: (x: any, y: any) => {
|
|
11
|
+
x: any;
|
|
12
|
+
y: any;
|
|
13
|
+
};
|
|
14
|
+
export declare const buildSizeArray: (size: any, padding: any) => number[];
|
|
15
|
+
export declare const tickCount: (min: any, max: any, step: any) => number;
|
|
16
|
+
export declare function getInterval(domain: any, ticks: any): number;
|
|
17
|
+
export declare function snapTo(min: any, max: any, interval: any, value: any): any;
|
|
18
|
+
export declare function buildTickModel(domain: any, ticks: any, interval: any, scaleFn: any): any;
|
|
19
|
+
export declare const polygonToArea: (points: any) => any;
|
|
20
|
+
export declare const lineToArea: (from: any, to: any) => {
|
|
21
|
+
left: number;
|
|
22
|
+
top: number;
|
|
23
|
+
bottom: number;
|
|
24
|
+
right: number;
|
|
25
|
+
};
|
|
26
|
+
export declare const bounds: (area: any, domain: any, range: any) => {
|
|
27
|
+
left: number;
|
|
28
|
+
right: number;
|
|
29
|
+
top: number;
|
|
30
|
+
bottom: number;
|
|
31
|
+
};
|
|
32
|
+
export declare const point: (o: any) => Point;
|
|
33
|
+
export declare const getDelta: (from: any, to: any) => Point;
|
|
34
|
+
export declare const bandKey: (d: any, index: any) => string;
|
|
35
|
+
export declare const isDomainRangeEqual: (graphProps: any, nextGraphProps: any) => any;
|
|
36
|
+
export declare const findLongestWord: (label: any) => any;
|
|
37
|
+
export declare const amountToIncreaseWidth: (longestWord: any) => number;
|
|
38
|
+
export declare const extractTextFromHTML: (htmlString: any) => string;
|
|
39
|
+
export declare const isEmptyObject: (obj: any) => any;
|
|
40
|
+
export declare const isEmptyString: (str: any) => boolean;
|