@pie-lib/plot 4.0.4-next.29 → 4.0.4-next.30
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/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/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/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-D5BXCJ5G.js +503 -0
- package/dist/node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.js +5 -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 +44 -0
- package/dist/utils.js +82 -0
- package/package.json +35 -25
- 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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in e) t(r, i, {
|
|
5
|
+
get: e[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, c = (e, i, o, s) => {
|
|
10
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
+
get: ((e) => i[e]).bind(null, d),
|
|
12
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
+
});
|
|
14
|
+
return e;
|
|
15
|
+
}, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
|
|
16
|
+
value: n,
|
|
17
|
+
enumerable: !0
|
|
18
|
+
}) : a, n));
|
|
19
|
+
//#endregion
|
|
20
|
+
export { o as __commonJSMin, s as __exportAll, l as __toESM };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/draggable.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 Draggable, { DraggableCore } from 'react-draggable';
|
|
10
|
+
export default class LocalDraggable extends Draggable {
|
|
11
|
+
componentWillReceiveProps(next: any): void;
|
|
12
|
+
}
|
|
13
|
+
export { DraggableCore };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "./node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-D5BXCJ5G.js";
|
|
2
|
+
import { cjs_default as e } from "./node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.js";
|
|
3
|
+
//#region src/draggable.tsx
|
|
4
|
+
var t = class extends e {
|
|
5
|
+
componentWillReceiveProps(e) {
|
|
6
|
+
super.componentWillReceiveProps(e), this.setState({
|
|
7
|
+
x: 0,
|
|
8
|
+
y: 0
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/graph-props.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
|
+
export declare const create: (domain: any, range: any, size: any, getRootNode: any) => {
|
|
10
|
+
scale: {
|
|
11
|
+
x: any;
|
|
12
|
+
y: any;
|
|
13
|
+
};
|
|
14
|
+
snap: {
|
|
15
|
+
x: (value: any) => any;
|
|
16
|
+
y: (value: any) => any;
|
|
17
|
+
};
|
|
18
|
+
domain: any;
|
|
19
|
+
range: any;
|
|
20
|
+
size: any;
|
|
21
|
+
getRootNode: any;
|
|
22
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { __toESM as e } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { require_browser as t } from "./node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js";
|
|
3
|
+
import { snapTo as n } from "./utils.js";
|
|
4
|
+
import { scaleLinear as r } from "d3-scale";
|
|
5
|
+
//#region src/graph-props.ts
|
|
6
|
+
var i = /* @__PURE__ */ e(t(), 1), a = ({ min: e, max: t, step: n }) => ({
|
|
7
|
+
step: n,
|
|
8
|
+
min: parseInt(e / n) * n,
|
|
9
|
+
max: parseInt(t / n) * n
|
|
10
|
+
}), o = (e, t, o, s) => {
|
|
11
|
+
(0, i.default)(e.min < e.max, "domain: min must be less than max"), (0, i.default)(t.min < t.max, "range: min must be less than max");
|
|
12
|
+
let c = a(e), l = a(t);
|
|
13
|
+
return {
|
|
14
|
+
scale: {
|
|
15
|
+
x: r().domain([e.min, e.max]).range([0, o.width]),
|
|
16
|
+
y: r().domain([t.max, t.min]).range([0, o.height])
|
|
17
|
+
},
|
|
18
|
+
snap: {
|
|
19
|
+
x: n.bind(null, c.min, c.max, c.step),
|
|
20
|
+
y: n.bind(null, l.min, l.max, l.step)
|
|
21
|
+
},
|
|
22
|
+
domain: e,
|
|
23
|
+
range: t,
|
|
24
|
+
size: o,
|
|
25
|
+
getRootNode: s
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { o as create };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/grid-draggable.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 const deltaFn: (scale: any, snap: any, val: any) => (delta: any) => number;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Component that is draggable, within a bounded grid.
|
|
14
|
+
* @param {*} opts
|
|
15
|
+
*/
|
|
16
|
+
export declare const gridDraggable: (opts: any) => (Comp: any) => {
|
|
17
|
+
new (props: any): {
|
|
18
|
+
grid: any;
|
|
19
|
+
onStart: any;
|
|
20
|
+
position: any;
|
|
21
|
+
tiny: any;
|
|
22
|
+
getScaledBounds: any;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves the coordinates of a mouse or touch event relative to an SVG element.
|
|
25
|
+
* This method has been overwritten from the d3-selection library's clientPoint to handle touch events and improve clarity.
|
|
26
|
+
* @param {Element} node - The SVG element.
|
|
27
|
+
* @param {Event} event - The mouse or touch event.
|
|
28
|
+
* @returns {Array} - An array containing the coordinates [x, y] relative to the SVG element.
|
|
29
|
+
*/
|
|
30
|
+
getClientPoint: any;
|
|
31
|
+
skipDragOutsideOfBounds: any;
|
|
32
|
+
onDrag: any;
|
|
33
|
+
getDelta: any;
|
|
34
|
+
applyDelta: any;
|
|
35
|
+
onStop: any;
|
|
36
|
+
render(): React.JSX.Element;
|
|
37
|
+
context: unknown;
|
|
38
|
+
setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<{}>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
|
|
39
|
+
forceUpdate(callback?: (() => void) | undefined): void;
|
|
40
|
+
readonly props: Readonly<{}>;
|
|
41
|
+
state: Readonly<{}>;
|
|
42
|
+
refs: {
|
|
43
|
+
[key: string]: React.ReactInstance;
|
|
44
|
+
};
|
|
45
|
+
componentDidMount?(): void;
|
|
46
|
+
shouldComponentUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): boolean;
|
|
47
|
+
componentWillUnmount?(): void;
|
|
48
|
+
componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
|
|
49
|
+
getSnapshotBeforeUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>): any;
|
|
50
|
+
componentDidUpdate?(prevProps: Readonly<{}>, prevState: Readonly<{}>, snapshot?: any): void;
|
|
51
|
+
componentWillMount?(): void;
|
|
52
|
+
UNSAFE_componentWillMount?(): void;
|
|
53
|
+
componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
54
|
+
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
|
|
55
|
+
componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
56
|
+
UNSAFE_componentWillUpdate?(nextProps: Readonly<{}>, nextState: Readonly<{}>, nextContext: any): void;
|
|
57
|
+
};
|
|
58
|
+
propTypes: {
|
|
59
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
60
|
+
onDragStart: PropTypes.Requireable<(...args: any[]) => any>;
|
|
61
|
+
onDrag: PropTypes.Requireable<(...args: any[]) => any>;
|
|
62
|
+
onDragStop: PropTypes.Requireable<(...args: any[]) => any>;
|
|
63
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
64
|
+
onMove: PropTypes.Requireable<(...args: any[]) => any>;
|
|
65
|
+
graphProps: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
66
|
+
scale: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
67
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
68
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
69
|
+
}>>>;
|
|
70
|
+
snap: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
71
|
+
x: PropTypes.Validator<(...args: any[]) => any>;
|
|
72
|
+
y: PropTypes.Validator<(...args: any[]) => any>;
|
|
73
|
+
}>>>;
|
|
74
|
+
domain: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
75
|
+
min: PropTypes.Validator<number>;
|
|
76
|
+
max: PropTypes.Validator<number>;
|
|
77
|
+
step: PropTypes.Requireable<number>;
|
|
78
|
+
}>>>;
|
|
79
|
+
range: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
80
|
+
min: PropTypes.Validator<number>;
|
|
81
|
+
max: PropTypes.Validator<number>;
|
|
82
|
+
step: PropTypes.Requireable<number>;
|
|
83
|
+
}>>>;
|
|
84
|
+
size: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
85
|
+
width: PropTypes.Validator<number>;
|
|
86
|
+
height: PropTypes.Validator<number>;
|
|
87
|
+
}>>>;
|
|
88
|
+
}>>>;
|
|
89
|
+
};
|
|
90
|
+
contextType?: React.Context<any> | undefined;
|
|
91
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { __toESM as e } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { GraphPropsType as t } from "./types.js";
|
|
3
|
+
import { require_browser as n } from "./node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js";
|
|
4
|
+
import { getDelta as r } from "./utils.js";
|
|
5
|
+
import { DraggableCore as i } from "./node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-D5BXCJ5G.js";
|
|
6
|
+
import a from "react";
|
|
7
|
+
import o from "prop-types";
|
|
8
|
+
import { pointer as s } from "d3-selection";
|
|
9
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
10
|
+
import { isFunction as l } from "@pie-element/shared-lodash";
|
|
11
|
+
import u from "debug";
|
|
12
|
+
//#region src/grid-draggable.tsx
|
|
13
|
+
var d = /* @__PURE__ */ e(n(), 1), f = u("pie-lib:plot:grid-draggable"), p = (e, t, n) => (r) => {
|
|
14
|
+
let i = r + e(0);
|
|
15
|
+
return t(n + e.invert(i)).toFixed(4) * 1e3 / 1e3;
|
|
16
|
+
}, m = (e) => (n) => ((0, d.default)(!!e && l(e.fromDelta) && l(e.bounds) && l(e.anchorPoint), "You must supply an object with: { anchorPoint: Function, fromDelta: Function, bounds: Function }"), class extends a.Component {
|
|
17
|
+
static propTypes = {
|
|
18
|
+
disabled: o.bool,
|
|
19
|
+
onDragStart: o.func,
|
|
20
|
+
onDrag: o.func,
|
|
21
|
+
onDragStop: o.func,
|
|
22
|
+
onClick: o.func,
|
|
23
|
+
onMove: o.func,
|
|
24
|
+
graphProps: t.isRequired
|
|
25
|
+
};
|
|
26
|
+
constructor(e) {
|
|
27
|
+
super(e), this.state = {
|
|
28
|
+
startX: null,
|
|
29
|
+
startY: null
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
grid = () => {
|
|
33
|
+
let { graphProps: e } = this.props, { scale: t, domain: n, range: r } = e;
|
|
34
|
+
return {
|
|
35
|
+
x: t.x(n.step) - t.x(0),
|
|
36
|
+
y: t.y(r.step) - t.y(0)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
onStart = (e) => {
|
|
40
|
+
let { onDragStart: t } = this.props;
|
|
41
|
+
document.activeElement && document.activeElement.blur(), this._didDrag = !1, this.setState({
|
|
42
|
+
startX: e.clientX,
|
|
43
|
+
startY: e.clientY
|
|
44
|
+
});
|
|
45
|
+
let n = e.target, r = (e) => {
|
|
46
|
+
n.removeEventListener("click", r, !0), this._didDrag && (e.stopPropagation(), e.preventDefault());
|
|
47
|
+
};
|
|
48
|
+
n.addEventListener("click", r, !0), t && t();
|
|
49
|
+
};
|
|
50
|
+
position = () => {
|
|
51
|
+
let { x: t, y: n } = e.anchorPoint(this.props), { graphProps: r } = this.props, { scale: i, snap: a } = r;
|
|
52
|
+
return {
|
|
53
|
+
anchorPoint: {
|
|
54
|
+
x: t,
|
|
55
|
+
y: n
|
|
56
|
+
},
|
|
57
|
+
x: p(i.x, a.x, t),
|
|
58
|
+
y: p(i.y, a.y, n)
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
tiny = (e, t) => {
|
|
62
|
+
let n = e.toUpperCase(), r = Math.abs(t[`client${n}`] - this.state[`start${n}`]), i = r < Math.abs(this.grid()[e]) / 10;
|
|
63
|
+
return f("[tiny] key: ", e, "delta: ", r, "out: ", i), i;
|
|
64
|
+
};
|
|
65
|
+
getScaledBounds = () => {
|
|
66
|
+
let t = e.bounds(this.props, this.props.graphProps);
|
|
67
|
+
f("bounds: ", t);
|
|
68
|
+
let n = this.grid(), r = {
|
|
69
|
+
left: t.left * n.x,
|
|
70
|
+
right: t.right * n.x,
|
|
71
|
+
top: t.top * n.y,
|
|
72
|
+
bottom: t.bottom * n.y
|
|
73
|
+
}, i = Math.abs(n.y);
|
|
74
|
+
return r = {
|
|
75
|
+
...r,
|
|
76
|
+
top: Math.min(0, r.top) - i,
|
|
77
|
+
bottom: Math.abs(r.bottom) + i
|
|
78
|
+
}, f("[getScaledBounds]: ", r), r;
|
|
79
|
+
};
|
|
80
|
+
getClientPoint = (e, t) => {
|
|
81
|
+
if (!e || !t) return null;
|
|
82
|
+
let n = e.ownerSVGElement || e;
|
|
83
|
+
if (n && n.createSVGPoint) {
|
|
84
|
+
let r = n.createSVGPoint();
|
|
85
|
+
if (t.touches && t.touches.length > 0) {
|
|
86
|
+
let e = t.touches[0];
|
|
87
|
+
r.x = e.clientX, r.y = e.clientY;
|
|
88
|
+
} else r.x = t.clientX, r.y = t.clientY;
|
|
89
|
+
return e.getScreenCTM ? (r = r.matrixTransform(e.getScreenCTM().inverse()), [r.x, r.y]) : null;
|
|
90
|
+
}
|
|
91
|
+
let r = e.getBoundingClientRect();
|
|
92
|
+
return r ? [t.clientX - r.left - e.clientLeft, t.clientY - r.top - e.clientTop] : null;
|
|
93
|
+
};
|
|
94
|
+
skipDragOutsideOfBounds = (e, t, n) => {
|
|
95
|
+
let r = n.getRootNode(), i = this.getClientPoint(r, t);
|
|
96
|
+
if (i === null) return !0;
|
|
97
|
+
let [a, o] = i, { scale: s, domain: c, range: l } = n, u = s.x.invert(a), d = s.y.invert(o), f = e.deltaX > 0 && u < c.min || e.deltaX < 0 && u > c.max, p = e.deltaY > 0 && d > l.max || e.deltaY < 0 && d < l.min;
|
|
98
|
+
return f || p;
|
|
99
|
+
};
|
|
100
|
+
onDrag = (e, t) => {
|
|
101
|
+
let { onDrag: n, graphProps: r, disabled: i } = this.props;
|
|
102
|
+
if ((Math.abs(t.deltaX) > 1 || Math.abs(t.deltaY) > 1) && (this._didDrag = !0), !n || i) return;
|
|
103
|
+
let a = this.getScaledBounds();
|
|
104
|
+
if (t.deltaX < 0 && t.deltaX < a.left || t.deltaX > 0 && t.deltaX > a.right || t.deltaY < 0 && t.deltaY < a.top || t.deltaY > 0 && t.deltaY > a.bottom || this.skipDragOutsideOfBounds(t, e, r)) return;
|
|
105
|
+
let o = this.applyDelta({
|
|
106
|
+
x: t.deltaX,
|
|
107
|
+
y: t.deltaY
|
|
108
|
+
});
|
|
109
|
+
(o !== void 0 || o !== null) && n(o);
|
|
110
|
+
};
|
|
111
|
+
getDelta = (e) => {
|
|
112
|
+
let t = this.position(), n = {
|
|
113
|
+
x: t.x(e.x),
|
|
114
|
+
y: t.y(e.y)
|
|
115
|
+
};
|
|
116
|
+
return r(t.anchorPoint, n);
|
|
117
|
+
};
|
|
118
|
+
applyDelta = (t) => {
|
|
119
|
+
let n = this.getDelta(t);
|
|
120
|
+
return f("[applyDelta] delta:", n), e.fromDelta(this.props, n);
|
|
121
|
+
};
|
|
122
|
+
onStop = (e, t) => {
|
|
123
|
+
f("[onStop] dd:", t);
|
|
124
|
+
let { onDragStop: n, onClick: r, disabled: i } = this.props;
|
|
125
|
+
if (n && !i && n(), f("[onStop] lastX/Y: ", t.lastX, t.lastY), !this._didDrag) {
|
|
126
|
+
if (!i && typeof e?.stopPropagation == "function" && e.stopPropagation(), r) {
|
|
127
|
+
f("call onClick"), this.setState({
|
|
128
|
+
startX: null,
|
|
129
|
+
startY: null
|
|
130
|
+
});
|
|
131
|
+
let { graphProps: t } = this.props, { scale: n, snap: i } = t;
|
|
132
|
+
try {
|
|
133
|
+
let [t, a] = s(e, e.target), o = n.x.invert(t), c = n.y.invert(a);
|
|
134
|
+
o = i.x(o), c = i.y(c), r({
|
|
135
|
+
x: o,
|
|
136
|
+
y: c
|
|
137
|
+
});
|
|
138
|
+
} catch {
|
|
139
|
+
r({});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return !1;
|
|
143
|
+
}
|
|
144
|
+
return this.setState({
|
|
145
|
+
startX: null,
|
|
146
|
+
startY: null
|
|
147
|
+
}), !1;
|
|
148
|
+
};
|
|
149
|
+
render() {
|
|
150
|
+
let { disabled: t, onClick: r, ...a } = this.props, o = this.grid(), s = (e) => e.nativeEvent.preventDefault(), l = this.state ? !!this.state.startX : !1;
|
|
151
|
+
return /* @__PURE__ */ c(i, {
|
|
152
|
+
onMouseDown: s,
|
|
153
|
+
onStart: this.onStart,
|
|
154
|
+
onDrag: this.onDrag,
|
|
155
|
+
onStop: this.onStop,
|
|
156
|
+
axis: e.axis || "both",
|
|
157
|
+
grid: [o.x, o.y],
|
|
158
|
+
children: /* @__PURE__ */ c(n, {
|
|
159
|
+
...a,
|
|
160
|
+
disabled: t,
|
|
161
|
+
isDragging: l,
|
|
162
|
+
onClick: l ? void 0 : r
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
//#endregion
|
|
168
|
+
export { m as gridDraggable };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/index.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 Root from './root.js';
|
|
10
|
+
import Draggable from './draggable.js';
|
|
11
|
+
import { gridDraggable } from './grid-draggable.js';
|
|
12
|
+
import * as utils from './utils.js';
|
|
13
|
+
import * as trig from './trig.js';
|
|
14
|
+
import * as types from './types.js';
|
|
15
|
+
import { create as createGraphProps } from './graph-props.js';
|
|
16
|
+
export { Root, Draggable, gridDraggable, utils, trig, types, createGraphProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { types_exports as e } from "./types.js";
|
|
2
|
+
import { utils_exports as t } from "./utils.js";
|
|
3
|
+
import n from "./root.js";
|
|
4
|
+
import r from "./draggable.js";
|
|
5
|
+
import { gridDraggable as i } from "./grid-draggable.js";
|
|
6
|
+
import { trig_exports as a } from "./trig.js";
|
|
7
|
+
import { create as o } from "./graph-props.js";
|
|
8
|
+
export { r as Draggable, n as Root, o as createGraphProps, i as gridDraggable, a as trig, e as types, t as utils };
|
package/dist/label.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @synced-from pie-lib/packages/plot/src/label.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
|
+
declare const LabelComponent: {
|
|
12
|
+
(props: any): React.JSX.Element;
|
|
13
|
+
propTypes: {
|
|
14
|
+
disabledLabel: PropTypes.Requireable<boolean>;
|
|
15
|
+
graphHeight: PropTypes.Requireable<number>;
|
|
16
|
+
graphWidth: PropTypes.Requireable<number>;
|
|
17
|
+
isChartBottomLabel: PropTypes.Requireable<boolean>;
|
|
18
|
+
isDefineChartBottomLabel: PropTypes.Requireable<boolean>;
|
|
19
|
+
isChartLeftLabel: PropTypes.Requireable<boolean>;
|
|
20
|
+
isDefineChartLeftLabel: PropTypes.Requireable<boolean>;
|
|
21
|
+
placeholder: PropTypes.Requireable<string>;
|
|
22
|
+
text: PropTypes.Requireable<string>;
|
|
23
|
+
side: PropTypes.Requireable<string>;
|
|
24
|
+
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
+
mathMlOptions: PropTypes.Requireable<object>;
|
|
26
|
+
charactersLimit: PropTypes.Requireable<number>;
|
|
27
|
+
titleHeight: PropTypes.Requireable<number>;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export default LabelComponent;
|
package/dist/label.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { extractTextFromHTML as e, isEmptyString as t } from "./utils.js";
|
|
2
|
+
import { useState as n } from "react";
|
|
3
|
+
import { styled as r } from "@mui/material/styles";
|
|
4
|
+
import i from "prop-types";
|
|
5
|
+
import * as a from "@pie-lib/render-ui";
|
|
6
|
+
import { Readable as o } from "@pie-lib/render-ui";
|
|
7
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
8
|
+
import c from "@pie-lib/editable-html-tip-tap";
|
|
9
|
+
//#region src/label.tsx
|
|
10
|
+
function l(e) {
|
|
11
|
+
return typeof e == "function" || typeof e == "object" && !!e && typeof e.$$typeof == "symbol";
|
|
12
|
+
}
|
|
13
|
+
function u(e, t) {
|
|
14
|
+
return !e || l(e) ? e : l(e.default) ? e.default : t && l(e[t]) ? e[t] : t && l(e[t]?.default) ? e[t].default : e;
|
|
15
|
+
}
|
|
16
|
+
var d = u(o, "Readable") || u(m.Readable, "Readable"), f = a, p = f.default, m = p && typeof p == "object" ? p : f, h = {
|
|
17
|
+
axisLabel: {
|
|
18
|
+
fontSize: 12,
|
|
19
|
+
textAlign: "center",
|
|
20
|
+
margin: 4,
|
|
21
|
+
padding: "4px 0"
|
|
22
|
+
},
|
|
23
|
+
chartLabel: {
|
|
24
|
+
fontSize: 16,
|
|
25
|
+
textAlign: "center",
|
|
26
|
+
margin: 4,
|
|
27
|
+
padding: "4px 0"
|
|
28
|
+
},
|
|
29
|
+
disabledLabel: {
|
|
30
|
+
pointerEvents: "none",
|
|
31
|
+
width: "100%"
|
|
32
|
+
},
|
|
33
|
+
editLabel: {
|
|
34
|
+
position: "absolute",
|
|
35
|
+
backgroundColor: "white",
|
|
36
|
+
borderRadius: 4,
|
|
37
|
+
boxShadow: "0px 5px 8px rgba(0,0,0,0.15)",
|
|
38
|
+
zIndex: 10
|
|
39
|
+
},
|
|
40
|
+
rotateLeftLabel: {
|
|
41
|
+
transform: "rotate(-90deg)",
|
|
42
|
+
transformOrigin: "0 0",
|
|
43
|
+
position: "absolute"
|
|
44
|
+
},
|
|
45
|
+
rotateRightLabel: {
|
|
46
|
+
transform: "rotate(90deg)",
|
|
47
|
+
transformOrigin: "0 0",
|
|
48
|
+
position: "absolute"
|
|
49
|
+
},
|
|
50
|
+
customBottom: { position: "absolute" },
|
|
51
|
+
displayNone: { display: "none" },
|
|
52
|
+
centerPlaceholder: { "& .ProseMirror p.is-editor-empty::before, & .ProseMirror div.is-editor-empty::before": {
|
|
53
|
+
left: 0,
|
|
54
|
+
right: 0,
|
|
55
|
+
width: "100%",
|
|
56
|
+
textAlign: "center"
|
|
57
|
+
} }
|
|
58
|
+
}, g = r("div")({ ...h.centerPlaceholder }), _ = r("div")({
|
|
59
|
+
...h.disabledLabel,
|
|
60
|
+
"& p": { margin: 0 }
|
|
61
|
+
}), v = (r) => {
|
|
62
|
+
let { disabledLabel: i, graphHeight: a, graphWidth: o, isChartBottomLabel: l, isDefineChartBottomLabel: u, isChartLeftLabel: f, isDefineChartLeftLabel: p, placeholder: m, text: v, side: y, onChange: b, mathMlOptions: x = {}, charactersLimit: S, titleHeight: C, preventNewLines: w } = r, [T, E] = n(!1), D = [
|
|
63
|
+
"bold",
|
|
64
|
+
"italic",
|
|
65
|
+
"underline",
|
|
66
|
+
"strikethrough",
|
|
67
|
+
"math"
|
|
68
|
+
], O = l || f || u || p, k = y === "left" && p && a - 220, A = {
|
|
69
|
+
width: k || (y === "left" || y === "right" ? a - 8 : o - 8),
|
|
70
|
+
top: k || f && `${a - 70}px` || y === "left" && `${a - 8}px` || l && `${a - 60 + C}px` || y === "bottom" && `${a - 120 + C}px` || 0,
|
|
71
|
+
left: y === "right" && `${o - 8}px` || (p || u) && "40px" || l && "-10px" || 0
|
|
72
|
+
}, j = {
|
|
73
|
+
width: o - 8,
|
|
74
|
+
top: y === "right" ? `${a - 22}px` : 0,
|
|
75
|
+
left: 0
|
|
76
|
+
}, M = () => {
|
|
77
|
+
!i && (y === "left" || y === "right") && E(!0);
|
|
78
|
+
}, N = () => {
|
|
79
|
+
E(!1), requestAnimationFrame(() => {
|
|
80
|
+
document.activeElement?.blur?.();
|
|
81
|
+
});
|
|
82
|
+
}, P = (e) => !!(w && e.key === "Enter");
|
|
83
|
+
return /* @__PURE__ */ s(d, {
|
|
84
|
+
false: !0,
|
|
85
|
+
children: /* @__PURE__ */ s(g, {
|
|
86
|
+
onClick: M,
|
|
87
|
+
style: {
|
|
88
|
+
...T ? j : A,
|
|
89
|
+
...O ? h.chartLabel : h.axisLabel,
|
|
90
|
+
...y === "left" && !T ? h.rotateLeftLabel : {},
|
|
91
|
+
...y === "right" && !T ? h.rotateRightLabel : {},
|
|
92
|
+
...T ? h.editLabel : {},
|
|
93
|
+
...l || u ? h.customBottom : {},
|
|
94
|
+
...i && !O && t(e(v)) && h.displayNone
|
|
95
|
+
},
|
|
96
|
+
children: i ? /* @__PURE__ */ s(_, { dangerouslySetInnerHTML: { __html: v || "" } }) : /* @__PURE__ */ s(c, {
|
|
97
|
+
markup: v || "",
|
|
98
|
+
onChange: b,
|
|
99
|
+
placeholder: !i && m,
|
|
100
|
+
toolbarOpts: {
|
|
101
|
+
position: y === "bottom" ? "top" : "bottom",
|
|
102
|
+
noPadding: !0,
|
|
103
|
+
noBorder: !0
|
|
104
|
+
},
|
|
105
|
+
disableScrollbar: !0,
|
|
106
|
+
activePlugins: D,
|
|
107
|
+
onDone: N,
|
|
108
|
+
onKeyDown: P,
|
|
109
|
+
mathMlOptions: x,
|
|
110
|
+
charactersLimit: S
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
v.propTypes = {
|
|
116
|
+
disabledLabel: i.bool,
|
|
117
|
+
graphHeight: i.number,
|
|
118
|
+
graphWidth: i.number,
|
|
119
|
+
isChartBottomLabel: i.bool,
|
|
120
|
+
isDefineChartBottomLabel: i.bool,
|
|
121
|
+
isChartLeftLabel: i.bool,
|
|
122
|
+
isDefineChartLeftLabel: i.bool,
|
|
123
|
+
placeholder: i.string,
|
|
124
|
+
text: i.string,
|
|
125
|
+
side: i.string,
|
|
126
|
+
onChange: i.func,
|
|
127
|
+
mathMlOptions: i.object,
|
|
128
|
+
charactersLimit: i.number,
|
|
129
|
+
titleHeight: i.number
|
|
130
|
+
};
|
|
131
|
+
//#endregion
|
|
132
|
+
export { v as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region ../../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
2
|
+
function e(t) {
|
|
3
|
+
var n, r, i = "";
|
|
4
|
+
if (typeof t == "string" || typeof t == "number") i += t;
|
|
5
|
+
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
6
|
+
var a = t.length;
|
|
7
|
+
for (n = 0; n < a; n++) t[n] && (r = e(t[n])) && (i && (i += " "), i += r);
|
|
8
|
+
} else for (r in t) t[r] && (i && (i += " "), i += r);
|
|
9
|
+
return i;
|
|
10
|
+
}
|
|
11
|
+
function t() {
|
|
12
|
+
for (var t, n, r = 0, i = "", a = arguments.length; r < a; r++) (t = arguments[r]) && (n = e(t)) && (i && (i += " "), i += n);
|
|
13
|
+
return i;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { t as default };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __commonJSMin as e } from "../../../../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region ../../../node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js
|
|
3
|
+
var t = /* @__PURE__ */ e(((e, t) => {
|
|
4
|
+
t.exports = function(e, t, n, r, i, a, o, s) {
|
|
5
|
+
if (process.env.NODE_ENV !== "production" && t === void 0) throw Error("invariant requires an error message argument");
|
|
6
|
+
if (!e) {
|
|
7
|
+
var c;
|
|
8
|
+
if (t === void 0) c = /* @__PURE__ */ Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");
|
|
9
|
+
else {
|
|
10
|
+
var l = [
|
|
11
|
+
n,
|
|
12
|
+
r,
|
|
13
|
+
i,
|
|
14
|
+
a,
|
|
15
|
+
o,
|
|
16
|
+
s
|
|
17
|
+
], u = 0;
|
|
18
|
+
c = Error(t.replace(/%s/g, function() {
|
|
19
|
+
return l[u++];
|
|
20
|
+
})), c.name = "Invariant Violation";
|
|
21
|
+
}
|
|
22
|
+
throw c.framesToPop = 1, c;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}));
|
|
26
|
+
//#endregion
|
|
27
|
+
export default t();
|
|
28
|
+
export { t as require_browser };
|