@pie-lib/plot 5.0.7-next.20261019183544 → 5.0.7-next.20261020021947

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/draggable.js CHANGED
@@ -1,5 +1,5 @@
1
- import { DraggableCore as e } from "./node_modules/.bun/react-draggable@4.7.1_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-ACOTSM7X.js";
2
- import t from "./node_modules/.bun/react-draggable@4.7.1_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.js";
1
+ import { DraggableCore as e } from "./node_modules/.bun/react-draggable@4.7.2_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-ACOTSM7X.js";
2
+ import t from "./node_modules/.bun/react-draggable@4.7.2_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.js";
3
3
  //#region src/draggable.tsx
4
4
  var n = t;
5
5
  //#endregion
@@ -7,6 +7,7 @@ export declare const deltaFn: (scale: any, snap: any, val: any) => (delta: any)
7
7
  */
8
8
  export declare const gridDraggable: (opts: any) => (Comp: any) => {
9
9
  new (props: any): {
10
+ nodeRef: React.RefObject<unknown>;
10
11
  grid: any;
11
12
  onStart: any;
12
13
  position: any;
@@ -2,7 +2,7 @@ import { __toESM as e } from "./_virtual/_rolldown/runtime.js";
2
2
  import { GraphPropsType as t } from "./types.js";
3
3
  import { require_browser as n } from "./node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js";
4
4
  import { getDelta as r } from "./utils.js";
5
- import { DraggableCore as i } from "./node_modules/.bun/react-draggable@4.7.1_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-ACOTSM7X.js";
5
+ import { DraggableCore as i } from "./node_modules/.bun/react-draggable@4.7.2_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-ACOTSM7X.js";
6
6
  import a from "react";
7
7
  import o from "prop-types";
8
8
  import { pointer as s } from "d3-selection";
@@ -13,158 +13,168 @@ import u from "debug";
13
13
  var d = /* @__PURE__ */ e(n(), 1), f = u("pie-lib:plot:grid-draggable"), p = (e, t, n) => (r) => {
14
14
  let i = r + e(0);
15
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
16
+ }, m = (e) => (n) => {
17
+ (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 }");
18
+ let u = ({ dragNodeRef: e, ...t }) => /* @__PURE__ */ c("g", {
19
+ ref: e,
20
+ children: /* @__PURE__ */ c(n, { ...t })
21
+ });
22
+ return class extends a.Component {
23
+ static propTypes = {
24
+ disabled: o.bool,
25
+ onDragStart: o.func,
26
+ onDrag: o.func,
27
+ onDragStop: o.func,
28
+ onClick: o.func,
29
+ onMove: o.func,
30
+ graphProps: t.isRequired
30
31
  };
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)
32
+ nodeRef = a.createRef();
33
+ constructor(e) {
34
+ super(e), this.state = {
35
+ startX: null,
36
+ startY: null
37
+ };
38
+ }
39
+ grid = () => {
40
+ let { graphProps: e } = this.props, { scale: t, domain: n, range: r } = e;
41
+ return {
42
+ x: t.x(n.step) - t.x(0),
43
+ y: t.y(r.step) - t.y(0)
44
+ };
37
45
  };
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());
46
+ onStart = (e) => {
47
+ let { onDragStart: t } = this.props;
48
+ document.activeElement && document.activeElement.blur(), this._didDrag = !1, this.setState({
49
+ startX: e.clientX,
50
+ startY: e.clientY
51
+ });
52
+ let n = e.target, r = (e) => {
53
+ n.removeEventListener("click", r, !0), this._didDrag && (e.stopPropagation(), e.preventDefault());
54
+ };
55
+ n.addEventListener("click", r, !0), t && t();
47
56
  };
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)
57
+ position = () => {
58
+ let { x: t, y: n } = e.anchorPoint(this.props), { graphProps: r } = this.props, { scale: i, snap: a } = r;
59
+ return {
60
+ anchorPoint: {
61
+ x: t,
62
+ y: n
63
+ },
64
+ x: p(i.x, a.x, t),
65
+ y: p(i.y, a.y, n)
66
+ };
59
67
  };
60
- };
61
- tiny = (e, t) => {
62
- let n = e.toUpperCase(), r = t[`client${n}`], i = this.state[`start${n}`], a = Math.abs(r - i), o = a < Math.abs(this.grid()[e]) / 10;
63
- return f("[tiny] key: ", e, "delta: ", a, "out: ", o), o;
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)
68
+ tiny = (e, t) => {
69
+ let n = e.toUpperCase(), r = t[`client${n}`], i = this.state[`start${n}`], a = Math.abs(r - i), o = a < Math.abs(this.grid()[e]) / 10;
70
+ return f("[tiny] key: ", e, "delta: ", a, "out: ", o), o;
115
71
  };
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({
72
+ getScaledBounds = () => {
73
+ let t = e.bounds(this.props, this.props.graphProps);
74
+ f("bounds: ", t);
75
+ let n = this.grid(), r = {
76
+ left: t.left * n.x,
77
+ right: t.right * n.x,
78
+ top: t.top * n.y,
79
+ bottom: t.bottom * n.y
80
+ }, i = Math.abs(n.y);
81
+ return r = {
82
+ ...r,
83
+ top: Math.min(0, r.top) - i,
84
+ bottom: Math.abs(r.bottom) + i
85
+ }, f("[getScaledBounds]: ", r), r;
86
+ };
87
+ getClientPoint = (e, t) => {
88
+ if (!e || !t) return null;
89
+ let n = e.ownerSVGElement || e;
90
+ if (n && n.createSVGPoint) {
91
+ let r = n.createSVGPoint();
92
+ if (t.touches && t.touches.length > 0) {
93
+ let e = t.touches[0];
94
+ r.x = e.clientX, r.y = e.clientY;
95
+ } else r.x = t.clientX, r.y = t.clientY;
96
+ return e.getScreenCTM ? (r = r.matrixTransform(e.getScreenCTM().inverse()), [r.x, r.y]) : null;
97
+ }
98
+ let r = e.getBoundingClientRect();
99
+ return r ? [t.clientX - r.left - e.clientLeft, t.clientY - r.top - e.clientTop] : null;
100
+ };
101
+ skipDragOutsideOfBounds = (e, t, n) => {
102
+ let r = n.getRootNode(), i = this.getClientPoint(r, t);
103
+ if (i === null) return !0;
104
+ 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;
105
+ return f || p;
106
+ };
107
+ onDrag = (e, t) => {
108
+ let { onDrag: n, graphProps: r, disabled: i } = this.props;
109
+ if ((Math.abs(t.deltaX) > 1 || Math.abs(t.deltaY) > 1) && (this._didDrag = !0), !n || i) return;
110
+ let a = this.getScaledBounds();
111
+ 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;
112
+ let o = this.applyDelta({
113
+ x: t.deltaX,
114
+ y: t.deltaY
115
+ });
116
+ (o !== void 0 || o !== null) && n(o);
117
+ };
118
+ getDelta = (e) => {
119
+ let t = this.position(), n = {
120
+ x: t.x(e.x),
121
+ y: t.y(e.y)
122
+ };
123
+ return r(t.anchorPoint, n);
124
+ };
125
+ applyDelta = (t) => {
126
+ let n = this.getDelta(t);
127
+ return f("[applyDelta] delta:", n), e.fromDelta(this.props, n);
128
+ };
129
+ onStop = (e, t) => {
130
+ f("[onStop] dd:", t);
131
+ let { onDragStop: n, onClick: r, disabled: i } = this.props;
132
+ if (n && !i && n(), f("[onStop] lastX/Y: ", t.lastX, t.lastY), !this._didDrag) {
133
+ if (!i && typeof e?.stopPropagation == "function" && e.stopPropagation(), r) {
134
+ f("call onClick"), this.setState({
135
+ startX: null,
136
+ startY: null
137
+ });
138
+ let { graphProps: t } = this.props, { scale: n, snap: i } = t;
139
+ try {
140
+ let [t, a] = s(e, e.target), o = n.x.invert(t), c = n.y.invert(a);
141
+ o = i.x(o), c = i.y(c), r({
142
+ x: o,
143
+ y: c
144
+ });
145
+ } catch {
146
+ r({});
147
+ }
148
+ }
149
+ this.setState({
128
150
  startX: null,
129
151
  startY: null
130
152
  });
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
- this.setState({
153
+ } else this.setState({
143
154
  startX: null,
144
155
  startY: null
145
156
  });
146
- } else this.setState({
147
- startX: null,
148
- startY: null
149
- });
157
+ };
158
+ render() {
159
+ let { disabled: t, onClick: n, ...r } = this.props, a = this.grid(), o = (e) => (e.nativeEvent || e).preventDefault(), s = this.state ? !!this.state.startX : !1;
160
+ return /* @__PURE__ */ c(i, {
161
+ nodeRef: this.nodeRef,
162
+ onMouseDown: o,
163
+ onStart: this.onStart,
164
+ onDrag: this.onDrag,
165
+ onStop: this.onStop,
166
+ axis: e.axis || "both",
167
+ grid: [a.x, a.y],
168
+ children: /* @__PURE__ */ c(u, {
169
+ dragNodeRef: this.nodeRef,
170
+ ...r,
171
+ disabled: t,
172
+ isDragging: s,
173
+ onClick: s ? void 0 : n
174
+ })
175
+ });
176
+ }
150
177
  };
151
- render() {
152
- let { disabled: t, onClick: r, ...a } = this.props, o = this.grid(), s = (e) => (e.nativeEvent || e).preventDefault(), l = this.state ? !!this.state.startX : !1;
153
- return /* @__PURE__ */ c(i, {
154
- onMouseDown: s,
155
- onStart: this.onStart,
156
- onDrag: this.onDrag,
157
- onStop: this.onStop,
158
- axis: e.axis || "both",
159
- grid: [o.x, o.y],
160
- children: /* @__PURE__ */ c(n, {
161
- ...a,
162
- disabled: t,
163
- isDragging: l,
164
- onClick: l ? void 0 : r
165
- })
166
- });
167
- }
168
- });
178
+ };
169
179
  //#endregion
170
180
  export { p as deltaFn, m as gridDraggable };
@@ -2,7 +2,7 @@ import { clsx as e } from "../../../../../clsx@2.1.1/node_modules/clsx/dist/clsx
2
2
  import * as t from "react";
3
3
  import n from "prop-types";
4
4
  import r from "react-dom";
5
- //#region ../../../node_modules/.bun/react-draggable@4.7.1+6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-ACOTSM7X.mjs
5
+ //#region ../../../node_modules/.bun/react-draggable@4.7.2+6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-ACOTSM7X.mjs
6
6
  function i(e, t) {
7
7
  for (let n = 0, r = e.length; n < r; n++) if (t.apply(t, [
8
8
  e[n],
@@ -1,5 +1,5 @@
1
1
  import { Draggable as e, DraggableCore as t } from "./chunk-ACOTSM7X.js";
2
- //#region ../../../node_modules/.bun/react-draggable@4.7.1+6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.mjs
2
+ //#region ../../../node_modules/.bun/react-draggable@4.7.2+6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.mjs
3
3
  var n = e;
4
4
  //#endregion
5
5
  export { t as DraggableCore, n as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-lib/plot",
3
- "version": "5.0.7-next.20261019183544",
3
+ "version": "5.0.7-next.20261020021947",
4
4
  "description": "Some underlying components for building charts/graphs",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,15 +14,15 @@
14
14
  "@mui/icons-material": "^7.3.4",
15
15
  "@mui/material": "^7.3.4",
16
16
  "@pie-element/shared-utils": "0.1.6-next.20261019151920",
17
- "@pie-lib/editable-html-tip-tap": "3.1.2-next.20261019183544",
18
- "@pie-lib/render-ui": "8.0.7-next.20261019183544",
17
+ "@pie-lib/editable-html-tip-tap": "3.1.2-next.20261019223635",
18
+ "@pie-lib/render-ui": "8.0.7-next.20261019223635",
19
19
  "assert": "^2.1.0",
20
20
  "d3-scale": "^4.0.2",
21
21
  "d3-selection": "^3.0.0",
22
22
  "debug": "^4.1.1",
23
23
  "invariant": "^2.2.4",
24
24
  "prop-types": "^15.7.2",
25
- "react-draggable": "^4.7.1",
25
+ "react-draggable": "^4.7.2",
26
26
  "react-redux": "^9.3.0",
27
27
  "redux": "^5.0.1",
28
28
  "@pie-element/shared-lodash": "0.1.3-next.20261019151920"