@pie-lib/plot 4.0.4-next.3 → 4.0.4-next.31
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,503 @@
|
|
|
1
|
+
import e from "../../../../../clsx@2.1.1/node_modules/clsx/dist/clsx.js";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import n from "prop-types";
|
|
4
|
+
import r from "react-dom";
|
|
5
|
+
//#region ../../../node_modules/.bun/react-draggable@4.6.0+6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-D5BXCJ5G.mjs
|
|
6
|
+
function i(e, t) {
|
|
7
|
+
for (let n = 0, r = e.length; n < r; n++) if (t.apply(t, [
|
|
8
|
+
e[n],
|
|
9
|
+
n,
|
|
10
|
+
e
|
|
11
|
+
])) return e[n];
|
|
12
|
+
}
|
|
13
|
+
function a(e) {
|
|
14
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Function]";
|
|
15
|
+
}
|
|
16
|
+
function o(e) {
|
|
17
|
+
return typeof e == "number" && !isNaN(e);
|
|
18
|
+
}
|
|
19
|
+
function s(e) {
|
|
20
|
+
return parseInt(e, 10);
|
|
21
|
+
}
|
|
22
|
+
function c(e, t, n) {
|
|
23
|
+
if (e[t]) return /* @__PURE__ */ Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`);
|
|
24
|
+
}
|
|
25
|
+
var l = [
|
|
26
|
+
"Moz",
|
|
27
|
+
"Webkit",
|
|
28
|
+
"O",
|
|
29
|
+
"ms"
|
|
30
|
+
];
|
|
31
|
+
function u(e = "transform") {
|
|
32
|
+
if (typeof window > "u") return "";
|
|
33
|
+
let t = window.document?.documentElement?.style;
|
|
34
|
+
if (!t || e in t) return "";
|
|
35
|
+
for (let n = 0; n < l.length; n++) if (d(e, l[n]) in t) return l[n];
|
|
36
|
+
return "";
|
|
37
|
+
}
|
|
38
|
+
function d(e, t) {
|
|
39
|
+
return t ? `${t}${f(e)}` : e;
|
|
40
|
+
}
|
|
41
|
+
function f(e) {
|
|
42
|
+
let t = "", n = !0;
|
|
43
|
+
for (let r = 0; r < e.length; r++) n ? (t += e[r].toUpperCase(), n = !1) : e[r] === "-" ? n = !0 : t += e[r];
|
|
44
|
+
return t;
|
|
45
|
+
}
|
|
46
|
+
var p = u(), m = "";
|
|
47
|
+
function h(e, t) {
|
|
48
|
+
m ||= i([
|
|
49
|
+
"matches",
|
|
50
|
+
"webkitMatchesSelector",
|
|
51
|
+
"mozMatchesSelector",
|
|
52
|
+
"msMatchesSelector",
|
|
53
|
+
"oMatchesSelector"
|
|
54
|
+
], function(t) {
|
|
55
|
+
return a(e[t]);
|
|
56
|
+
}) ?? "";
|
|
57
|
+
let n = e[m];
|
|
58
|
+
return a(n) ? !!n.call(e, t) : !1;
|
|
59
|
+
}
|
|
60
|
+
function g(e, t, n) {
|
|
61
|
+
let r = e;
|
|
62
|
+
do {
|
|
63
|
+
if (h(r, t)) return !0;
|
|
64
|
+
if (r === n) return !1;
|
|
65
|
+
r = r.parentNode;
|
|
66
|
+
} while (r);
|
|
67
|
+
return !1;
|
|
68
|
+
}
|
|
69
|
+
function _(e, t, n, r) {
|
|
70
|
+
if (!e) return;
|
|
71
|
+
let i = {
|
|
72
|
+
capture: !0,
|
|
73
|
+
...r
|
|
74
|
+
}, a = n;
|
|
75
|
+
e.addEventListener ? e.addEventListener(t, a, i) : e.attachEvent ? e.attachEvent("on" + t, a) : e["on" + t] = a;
|
|
76
|
+
}
|
|
77
|
+
function v(e, t, n, r) {
|
|
78
|
+
if (!e) return;
|
|
79
|
+
let i = {
|
|
80
|
+
capture: !0,
|
|
81
|
+
...r
|
|
82
|
+
}, a = n;
|
|
83
|
+
e.removeEventListener ? e.removeEventListener(t, a, i) : e.detachEvent ? e.detachEvent("on" + t, a) : e["on" + t] = null;
|
|
84
|
+
}
|
|
85
|
+
function y(e) {
|
|
86
|
+
let t = e.clientHeight, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
87
|
+
return t += s(n.borderTopWidth), t += s(n.borderBottomWidth), t;
|
|
88
|
+
}
|
|
89
|
+
function b(e) {
|
|
90
|
+
let t = e.clientWidth, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
91
|
+
return t += s(n.borderLeftWidth), t += s(n.borderRightWidth), t;
|
|
92
|
+
}
|
|
93
|
+
function x(e) {
|
|
94
|
+
let t = e.clientHeight, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
95
|
+
return t -= s(n.paddingTop), t -= s(n.paddingBottom), t;
|
|
96
|
+
}
|
|
97
|
+
function S(e) {
|
|
98
|
+
let t = e.clientWidth, n = e.ownerDocument.defaultView.getComputedStyle(e);
|
|
99
|
+
return t -= s(n.paddingLeft), t -= s(n.paddingRight), t;
|
|
100
|
+
}
|
|
101
|
+
function C(e, t, n) {
|
|
102
|
+
let r = t === t.ownerDocument.body ? {
|
|
103
|
+
left: 0,
|
|
104
|
+
top: 0
|
|
105
|
+
} : t.getBoundingClientRect();
|
|
106
|
+
return {
|
|
107
|
+
x: (e.clientX + t.scrollLeft - r.left) / n,
|
|
108
|
+
y: (e.clientY + t.scrollTop - r.top) / n
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function w(e, t) {
|
|
112
|
+
let n = E(e, t, "px");
|
|
113
|
+
return { [d("transform", p)]: n };
|
|
114
|
+
}
|
|
115
|
+
function T(e, t) {
|
|
116
|
+
return E(e, t, "");
|
|
117
|
+
}
|
|
118
|
+
function E({ x: e, y: t }, n, r) {
|
|
119
|
+
let i = `translate(${e}${r},${t}${r})`;
|
|
120
|
+
return n && (i = `translate(${`${typeof n.x == "string" ? n.x : n.x + r}`}, ${`${typeof n.y == "string" ? n.y : n.y + r}`})` + i), i;
|
|
121
|
+
}
|
|
122
|
+
function D(e, t) {
|
|
123
|
+
return e.targetTouches && i(e.targetTouches, (e) => t === e.identifier) || e.changedTouches && i(e.changedTouches, (e) => t === e.identifier);
|
|
124
|
+
}
|
|
125
|
+
function O(e) {
|
|
126
|
+
if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
|
|
127
|
+
if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
|
|
128
|
+
}
|
|
129
|
+
function k(e) {
|
|
130
|
+
if (!e) return;
|
|
131
|
+
let t = e.getElementById("react-draggable-style-el");
|
|
132
|
+
t || (t = e.createElement("style"), t.type = "text/css", t.id = "react-draggable-style-el", t.innerHTML = ".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n", t.innerHTML += ".react-draggable-transparent-selection *::selection {all: inherit;}\n", e.getElementsByTagName("head")[0].appendChild(t)), e.body && M(e.body, "react-draggable-transparent-selection");
|
|
133
|
+
}
|
|
134
|
+
function A(e) {
|
|
135
|
+
window.requestAnimationFrame ? window.requestAnimationFrame(() => {
|
|
136
|
+
j(e);
|
|
137
|
+
}) : j(e);
|
|
138
|
+
}
|
|
139
|
+
function j(e) {
|
|
140
|
+
if (e) try {
|
|
141
|
+
e.body && N(e.body, "react-draggable-transparent-selection");
|
|
142
|
+
let t = e.selection;
|
|
143
|
+
if (t) t.empty();
|
|
144
|
+
else {
|
|
145
|
+
let t = (e.defaultView || window).getSelection();
|
|
146
|
+
t && t.type !== "Caret" && t.removeAllRanges();
|
|
147
|
+
}
|
|
148
|
+
} catch {}
|
|
149
|
+
}
|
|
150
|
+
function M(e, t) {
|
|
151
|
+
e.classList ? e.classList.add(t) : e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`)) || (e.className += ` ${t}`);
|
|
152
|
+
}
|
|
153
|
+
function N(e, t) {
|
|
154
|
+
e.classList ? e.classList.remove(t) : e.className = e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`, "g"), "");
|
|
155
|
+
}
|
|
156
|
+
function P(e, t, n) {
|
|
157
|
+
if (!e.props.bounds) return [t, n];
|
|
158
|
+
let { bounds: r } = e.props;
|
|
159
|
+
r = typeof r == "string" ? r : V(r);
|
|
160
|
+
let i = H(e);
|
|
161
|
+
if (typeof r == "string") {
|
|
162
|
+
let { ownerDocument: e } = i, t = e.defaultView;
|
|
163
|
+
if (!t) throw Error("Cannot resolve the owner window of the draggable node.");
|
|
164
|
+
let n;
|
|
165
|
+
if (n = r === "parent" ? i.parentNode : i.getRootNode().querySelector(r), !(n instanceof t.HTMLElement)) throw Error("Bounds selector \"" + r + "\" could not find an element.");
|
|
166
|
+
let a = n, o = t.getComputedStyle(i), c = t.getComputedStyle(a);
|
|
167
|
+
r = {
|
|
168
|
+
left: -i.offsetLeft + s(c.paddingLeft) + s(o.marginLeft),
|
|
169
|
+
top: -i.offsetTop + s(c.paddingTop) + s(o.marginTop),
|
|
170
|
+
right: S(a) - b(i) - i.offsetLeft + s(c.paddingRight) - s(o.marginRight),
|
|
171
|
+
bottom: x(a) - y(i) - i.offsetTop + s(c.paddingBottom) - s(o.marginBottom)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return o(r.right) && (t = Math.min(t, r.right)), o(r.bottom) && (n = Math.min(n, r.bottom)), o(r.left) && (t = Math.max(t, r.left)), o(r.top) && (n = Math.max(n, r.top)), [t, n];
|
|
175
|
+
}
|
|
176
|
+
function F(e, t, n) {
|
|
177
|
+
return [Math.round(t / e[0]) * e[0], Math.round(n / e[1]) * e[1]];
|
|
178
|
+
}
|
|
179
|
+
function I(e) {
|
|
180
|
+
return e.props.axis === "both" || e.props.axis === "x";
|
|
181
|
+
}
|
|
182
|
+
function L(e) {
|
|
183
|
+
return e.props.axis === "both" || e.props.axis === "y";
|
|
184
|
+
}
|
|
185
|
+
function R(e, t, n) {
|
|
186
|
+
let r = typeof t == "number" ? D(e, t) : null;
|
|
187
|
+
if (typeof t == "number" && !r) return null;
|
|
188
|
+
let i = H(n), a = n.props.offsetParent || i.offsetParent || i.ownerDocument.body;
|
|
189
|
+
return C(r || e, a, n.props.scale);
|
|
190
|
+
}
|
|
191
|
+
function z(e, t, n) {
|
|
192
|
+
let r = !o(e.lastX), i = H(e);
|
|
193
|
+
return r ? {
|
|
194
|
+
node: i,
|
|
195
|
+
deltaX: 0,
|
|
196
|
+
deltaY: 0,
|
|
197
|
+
lastX: t,
|
|
198
|
+
lastY: n,
|
|
199
|
+
x: t,
|
|
200
|
+
y: n
|
|
201
|
+
} : {
|
|
202
|
+
node: i,
|
|
203
|
+
deltaX: t - e.lastX,
|
|
204
|
+
deltaY: n - e.lastY,
|
|
205
|
+
lastX: e.lastX,
|
|
206
|
+
lastY: e.lastY,
|
|
207
|
+
x: t,
|
|
208
|
+
y: n
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function B(e, t) {
|
|
212
|
+
let n = e.props.scale;
|
|
213
|
+
return {
|
|
214
|
+
node: t.node,
|
|
215
|
+
x: e.state.x + t.deltaX / n,
|
|
216
|
+
y: e.state.y + t.deltaY / n,
|
|
217
|
+
deltaX: t.deltaX / n,
|
|
218
|
+
deltaY: t.deltaY / n,
|
|
219
|
+
lastX: e.state.x,
|
|
220
|
+
lastY: e.state.y
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function V(e) {
|
|
224
|
+
return {
|
|
225
|
+
left: e.left,
|
|
226
|
+
top: e.top,
|
|
227
|
+
right: e.right,
|
|
228
|
+
bottom: e.bottom
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function H(e) {
|
|
232
|
+
let t = e.findDOMNode();
|
|
233
|
+
if (!t) throw Error("<DraggableCore>: Unmounted during event!");
|
|
234
|
+
return t;
|
|
235
|
+
}
|
|
236
|
+
function U(...e) {
|
|
237
|
+
process.env.DRAGGABLE_DEBUG && console.log(...e);
|
|
238
|
+
}
|
|
239
|
+
var W = {
|
|
240
|
+
touch: {
|
|
241
|
+
start: "touchstart",
|
|
242
|
+
move: "touchmove",
|
|
243
|
+
stop: "touchend"
|
|
244
|
+
},
|
|
245
|
+
mouse: {
|
|
246
|
+
start: "mousedown",
|
|
247
|
+
move: "mousemove",
|
|
248
|
+
stop: "mouseup"
|
|
249
|
+
}
|
|
250
|
+
}, G = W.mouse, K = class extends t.Component {
|
|
251
|
+
constructor() {
|
|
252
|
+
super(...arguments), this.dragging = !1, this.lastX = NaN, this.lastY = NaN, this.touchIdentifier = null, this.mounted = !1, this.handleDragStart = (e) => {
|
|
253
|
+
if (this.props.onMouseDown(e), !this.props.allowAnyClick && (typeof e.button == "number" && e.button !== 0 || e.ctrlKey)) return !1;
|
|
254
|
+
let t = this.findDOMNode();
|
|
255
|
+
if (!t || !t.ownerDocument || !t.ownerDocument.body) throw Error("<DraggableCore> not mounted on DragStart!");
|
|
256
|
+
let { ownerDocument: n } = t;
|
|
257
|
+
if (this.props.disabled || !(e.target instanceof n.defaultView.Node) || this.props.handle && !g(e.target, this.props.handle, t) || this.props.cancel && g(e.target, this.props.cancel, t)) return;
|
|
258
|
+
e.type === "touchstart" && !this.props.allowMobileScroll && e.preventDefault();
|
|
259
|
+
let r = O(e);
|
|
260
|
+
this.touchIdentifier = r;
|
|
261
|
+
let i = R(e, r, this);
|
|
262
|
+
if (i == null) return;
|
|
263
|
+
let { x: a, y: o } = i, s = z(this, a, o);
|
|
264
|
+
U("DraggableCore: handleDragStart: %j", s), U("calling", this.props.onStart), !(this.props.onStart(e, s) === !1 || this.mounted === !1) && (this.props.enableUserSelectHack && k(n), this.dragging = !0, this.lastX = a, this.lastY = o, _(n, G.move, this.handleDrag), _(n, G.stop, this.handleDragStop));
|
|
265
|
+
}, this.handleDrag = (e) => {
|
|
266
|
+
let t = R(e, this.touchIdentifier, this);
|
|
267
|
+
if (t == null) return;
|
|
268
|
+
let { x: n, y: r } = t;
|
|
269
|
+
if (Array.isArray(this.props.grid)) {
|
|
270
|
+
let e = n - this.lastX, t = r - this.lastY;
|
|
271
|
+
if ([e, t] = F(this.props.grid, e, t), !e && !t) return;
|
|
272
|
+
n = this.lastX + e, r = this.lastY + t;
|
|
273
|
+
}
|
|
274
|
+
let i = z(this, n, r);
|
|
275
|
+
if (U("DraggableCore: handleDrag: %j", i), this.props.onDrag(e, i) === !1 || this.mounted === !1) {
|
|
276
|
+
try {
|
|
277
|
+
this.handleDragStop(new MouseEvent("mouseup"));
|
|
278
|
+
} catch {
|
|
279
|
+
let e = document.createEvent("MouseEvents");
|
|
280
|
+
e.initMouseEvent("mouseup", !0, !0, window, 0, 0, 0, 0, 0, !1, !1, !1, !1, 0, null), this.handleDragStop(e);
|
|
281
|
+
}
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
this.lastX = n, this.lastY = r;
|
|
285
|
+
}, this.handleDragStop = (e) => {
|
|
286
|
+
if (!this.dragging) return;
|
|
287
|
+
let t = R(e, this.touchIdentifier, this);
|
|
288
|
+
if (t == null) return;
|
|
289
|
+
let { x: n, y: r } = t;
|
|
290
|
+
if (Array.isArray(this.props.grid)) {
|
|
291
|
+
let e = n - this.lastX || 0, t = r - this.lastY || 0;
|
|
292
|
+
[e, t] = F(this.props.grid, e, t), n = this.lastX + e, r = this.lastY + t;
|
|
293
|
+
}
|
|
294
|
+
let i = z(this, n, r);
|
|
295
|
+
if (this.props.onStop(e, i) === !1 || this.mounted === !1) return !1;
|
|
296
|
+
let a = this.findDOMNode();
|
|
297
|
+
a && this.props.enableUserSelectHack && A(a.ownerDocument), U("DraggableCore: handleDragStop: %j", i), this.dragging = !1, this.lastX = NaN, this.lastY = NaN, a && (U("DraggableCore: Removing handlers"), v(a.ownerDocument, G.move, this.handleDrag), v(a.ownerDocument, G.stop, this.handleDragStop));
|
|
298
|
+
}, this.onMouseDown = (e) => (G = W.mouse, this.handleDragStart(e)), this.onMouseUp = (e) => (G = W.mouse, this.handleDragStop(e)), this.onTouchStart = (e) => (G = W.touch, this.handleDragStart(e)), this.onTouchEnd = (e) => (G = W.touch, this.handleDragStop(e));
|
|
299
|
+
}
|
|
300
|
+
componentDidMount() {
|
|
301
|
+
this.mounted = !0;
|
|
302
|
+
let e = this.findDOMNode();
|
|
303
|
+
e && _(e, W.touch.start, this.onTouchStart, { passive: !1 });
|
|
304
|
+
}
|
|
305
|
+
componentWillUnmount() {
|
|
306
|
+
this.mounted = !1;
|
|
307
|
+
let e = this.findDOMNode();
|
|
308
|
+
if (e) {
|
|
309
|
+
let { ownerDocument: t } = e;
|
|
310
|
+
v(t, W.mouse.move, this.handleDrag), v(t, W.touch.move, this.handleDrag), v(t, W.mouse.stop, this.handleDragStop), v(t, W.touch.stop, this.handleDragStop), v(e, W.touch.start, this.onTouchStart, { passive: !1 }), this.props.enableUserSelectHack && A(t);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
findDOMNode() {
|
|
314
|
+
if (this.props?.nodeRef) return this.props.nodeRef.current;
|
|
315
|
+
let e = r;
|
|
316
|
+
return typeof e.findDOMNode == "function" ? e.findDOMNode(this) : (U("react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef"), null);
|
|
317
|
+
}
|
|
318
|
+
render() {
|
|
319
|
+
return t.cloneElement(t.Children.only(this.props.children), {
|
|
320
|
+
onMouseDown: this.onMouseDown,
|
|
321
|
+
onMouseUp: this.onMouseUp,
|
|
322
|
+
onTouchEnd: this.onTouchEnd
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
K.displayName = "DraggableCore", K.propTypes = {
|
|
327
|
+
allowAnyClick: n.bool,
|
|
328
|
+
allowMobileScroll: n.bool,
|
|
329
|
+
children: n.node.isRequired,
|
|
330
|
+
disabled: n.bool,
|
|
331
|
+
enableUserSelectHack: n.bool,
|
|
332
|
+
offsetParent: function(e, t) {
|
|
333
|
+
if (e[t] && e[t].nodeType !== 1) throw Error("Draggable's offsetParent must be a DOM Node.");
|
|
334
|
+
},
|
|
335
|
+
grid: n.arrayOf(n.number),
|
|
336
|
+
handle: n.string,
|
|
337
|
+
cancel: n.string,
|
|
338
|
+
nodeRef: n.object,
|
|
339
|
+
onStart: n.func,
|
|
340
|
+
onDrag: n.func,
|
|
341
|
+
onStop: n.func,
|
|
342
|
+
onMouseDown: n.func,
|
|
343
|
+
scale: n.number,
|
|
344
|
+
className: c,
|
|
345
|
+
style: c,
|
|
346
|
+
transform: c
|
|
347
|
+
}, K.defaultProps = {
|
|
348
|
+
allowAnyClick: !1,
|
|
349
|
+
allowMobileScroll: !1,
|
|
350
|
+
disabled: !1,
|
|
351
|
+
enableUserSelectHack: !0,
|
|
352
|
+
onStart: function() {},
|
|
353
|
+
onDrag: function() {},
|
|
354
|
+
onStop: function() {},
|
|
355
|
+
onMouseDown: function() {},
|
|
356
|
+
scale: 1
|
|
357
|
+
};
|
|
358
|
+
var q = class extends t.Component {
|
|
359
|
+
constructor(e) {
|
|
360
|
+
super(e), this.onDragStart = (e, t) => {
|
|
361
|
+
if (U("Draggable: onDragStart: %j", t), this.props.onStart(e, B(this, t)) === !1) return !1;
|
|
362
|
+
this.setState({
|
|
363
|
+
dragging: !0,
|
|
364
|
+
dragged: !0
|
|
365
|
+
});
|
|
366
|
+
}, this.onDrag = (e, t) => {
|
|
367
|
+
if (!this.state.dragging) return !1;
|
|
368
|
+
U("Draggable: onDrag: %j", t);
|
|
369
|
+
let n = B(this, t), r = {
|
|
370
|
+
x: n.x,
|
|
371
|
+
y: n.y,
|
|
372
|
+
slackX: 0,
|
|
373
|
+
slackY: 0
|
|
374
|
+
};
|
|
375
|
+
if (this.props.bounds) {
|
|
376
|
+
let { x: e, y: t } = r;
|
|
377
|
+
r.x += this.state.slackX, r.y += this.state.slackY;
|
|
378
|
+
let [i, a] = P(this, r.x, r.y);
|
|
379
|
+
r.x = i, r.y = a, r.slackX = this.state.slackX + (e - r.x), r.slackY = this.state.slackY + (t - r.y), n.x = r.x, n.y = r.y, n.deltaX = r.x - this.state.x, n.deltaY = r.y - this.state.y;
|
|
380
|
+
}
|
|
381
|
+
if (this.props.onDrag(e, n) === !1) return !1;
|
|
382
|
+
this.setState(r);
|
|
383
|
+
}, this.onDragStop = (e, t) => {
|
|
384
|
+
if (!this.state.dragging || this.props.onStop(e, B(this, t)) === !1) return !1;
|
|
385
|
+
U("Draggable: onDragStop: %j", t);
|
|
386
|
+
let n = {
|
|
387
|
+
dragging: !1,
|
|
388
|
+
slackX: 0,
|
|
389
|
+
slackY: 0
|
|
390
|
+
};
|
|
391
|
+
if (this.props.position) {
|
|
392
|
+
let { x: e, y: t } = this.props.position;
|
|
393
|
+
n.x = e, n.y = t;
|
|
394
|
+
}
|
|
395
|
+
this.setState(n);
|
|
396
|
+
}, this.state = {
|
|
397
|
+
dragging: !1,
|
|
398
|
+
dragged: !1,
|
|
399
|
+
x: e.position ? e.position.x : e.defaultPosition.x,
|
|
400
|
+
y: e.position ? e.position.y : e.defaultPosition.y,
|
|
401
|
+
prevPropsPosition: { ...e.position },
|
|
402
|
+
slackX: 0,
|
|
403
|
+
slackY: 0,
|
|
404
|
+
isElementSVG: !1
|
|
405
|
+
}, e.position && !(e.onDrag || e.onStop) && console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.");
|
|
406
|
+
}
|
|
407
|
+
static getDerivedStateFromProps({ position: e }, { prevPropsPosition: t }) {
|
|
408
|
+
return e && (!t || e.x !== t.x || e.y !== t.y) ? (U("Draggable: getDerivedStateFromProps %j", {
|
|
409
|
+
position: e,
|
|
410
|
+
prevPropsPosition: t
|
|
411
|
+
}), {
|
|
412
|
+
x: e.x,
|
|
413
|
+
y: e.y,
|
|
414
|
+
prevPropsPosition: { ...e }
|
|
415
|
+
}) : null;
|
|
416
|
+
}
|
|
417
|
+
componentDidMount() {
|
|
418
|
+
window.SVGElement !== void 0 && this.findDOMNode() instanceof window.SVGElement && this.setState({ isElementSVG: !0 });
|
|
419
|
+
}
|
|
420
|
+
componentWillUnmount() {
|
|
421
|
+
this.state.dragging && this.setState({ dragging: !1 });
|
|
422
|
+
}
|
|
423
|
+
findDOMNode() {
|
|
424
|
+
if (this.props?.nodeRef) return this.props.nodeRef.current;
|
|
425
|
+
let e = r;
|
|
426
|
+
return typeof e.findDOMNode == "function" ? e.findDOMNode(this) : null;
|
|
427
|
+
}
|
|
428
|
+
render() {
|
|
429
|
+
let { axis: n, bounds: r, children: i, defaultPosition: a, defaultClassName: o, defaultClassNameDragging: s, defaultClassNameDragged: c, position: l, positionOffset: u, scale: d, ...f } = this.props, p = {}, m = null, h = !l || this.state.dragging, g = l || a, _ = {
|
|
430
|
+
x: I(this) && h ? this.state.x : g.x,
|
|
431
|
+
y: L(this) && h ? this.state.y : g.y
|
|
432
|
+
};
|
|
433
|
+
this.state.isElementSVG ? m = T(_, u) : p = w(_, u);
|
|
434
|
+
let v = t.Children.only(i), y = e(v.props.className || "", o, {
|
|
435
|
+
[s]: this.state.dragging,
|
|
436
|
+
[c]: this.state.dragged
|
|
437
|
+
});
|
|
438
|
+
return /* @__PURE__ */ t.createElement(K, {
|
|
439
|
+
...f,
|
|
440
|
+
onStart: this.onDragStart,
|
|
441
|
+
onDrag: this.onDrag,
|
|
442
|
+
onStop: this.onDragStop
|
|
443
|
+
}, t.cloneElement(v, {
|
|
444
|
+
className: y,
|
|
445
|
+
style: {
|
|
446
|
+
...v.props.style,
|
|
447
|
+
...p
|
|
448
|
+
},
|
|
449
|
+
transform: m
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
q.displayName = "Draggable", q.propTypes = {
|
|
454
|
+
...K.propTypes,
|
|
455
|
+
axis: n.oneOf([
|
|
456
|
+
"both",
|
|
457
|
+
"x",
|
|
458
|
+
"y",
|
|
459
|
+
"none"
|
|
460
|
+
]),
|
|
461
|
+
bounds: n.oneOfType([
|
|
462
|
+
n.shape({
|
|
463
|
+
left: n.number,
|
|
464
|
+
right: n.number,
|
|
465
|
+
top: n.number,
|
|
466
|
+
bottom: n.number
|
|
467
|
+
}),
|
|
468
|
+
n.string,
|
|
469
|
+
n.oneOf([!1])
|
|
470
|
+
]),
|
|
471
|
+
defaultClassName: n.string,
|
|
472
|
+
defaultClassNameDragging: n.string,
|
|
473
|
+
defaultClassNameDragged: n.string,
|
|
474
|
+
defaultPosition: n.shape({
|
|
475
|
+
x: n.number,
|
|
476
|
+
y: n.number
|
|
477
|
+
}),
|
|
478
|
+
positionOffset: n.shape({
|
|
479
|
+
x: n.oneOfType([n.number, n.string]),
|
|
480
|
+
y: n.oneOfType([n.number, n.string])
|
|
481
|
+
}),
|
|
482
|
+
position: n.shape({
|
|
483
|
+
x: n.number,
|
|
484
|
+
y: n.number
|
|
485
|
+
}),
|
|
486
|
+
className: c,
|
|
487
|
+
style: c,
|
|
488
|
+
transform: c
|
|
489
|
+
}, q.defaultProps = {
|
|
490
|
+
...K.defaultProps,
|
|
491
|
+
axis: "both",
|
|
492
|
+
bounds: !1,
|
|
493
|
+
defaultClassName: "react-draggable",
|
|
494
|
+
defaultClassNameDragging: "react-draggable-dragging",
|
|
495
|
+
defaultClassNameDragged: "react-draggable-dragged",
|
|
496
|
+
defaultPosition: {
|
|
497
|
+
x: 0,
|
|
498
|
+
y: 0
|
|
499
|
+
},
|
|
500
|
+
scale: 1
|
|
501
|
+
};
|
|
502
|
+
//#endregion
|
|
503
|
+
export { q as Draggable, K as DraggableCore };
|
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;
|