@pie-lib/plot 4.0.4-next.30 → 4.0.4-next.34

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.
Files changed (59) hide show
  1. package/CHANGELOG.json +17 -0
  2. package/CHANGELOG.md +838 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/draggable.js +44 -0
  5. package/lib/draggable.js.map +1 -0
  6. package/lib/graph-props.js +46 -0
  7. package/lib/graph-props.js.map +1 -0
  8. package/lib/grid-draggable.js +361 -0
  9. package/lib/grid-draggable.js.map +1 -0
  10. package/lib/index.js +44 -0
  11. package/lib/index.js.map +1 -0
  12. package/lib/label.js +173 -0
  13. package/lib/label.js.map +1 -0
  14. package/lib/root.js +474 -0
  15. package/lib/root.js.map +1 -0
  16. package/lib/trig.js +149 -0
  17. package/lib/trig.js.map +1 -0
  18. package/lib/types.js +40 -0
  19. package/lib/types.js.map +1 -0
  20. package/lib/utils.js +165 -0
  21. package/lib/utils.js.map +1 -0
  22. package/package.json +25 -35
  23. package/src/__tests__/draggable.test.jsx +41 -0
  24. package/src/__tests__/grid-draggable.test.jsx +487 -0
  25. package/src/__tests__/root.test.jsx +277 -0
  26. package/src/__tests__/trig.test.js +163 -0
  27. package/src/__tests__/utils.test.js +229 -0
  28. package/src/draggable.jsx +11 -0
  29. package/src/graph-props.js +34 -0
  30. package/src/grid-draggable.jsx +332 -0
  31. package/src/index.js +9 -0
  32. package/src/label.jsx +199 -0
  33. package/src/root.jsx +485 -0
  34. package/src/trig.js +151 -0
  35. package/src/types.js +41 -0
  36. package/src/utils.js +167 -0
  37. package/dist/_virtual/_rolldown/runtime.js +0 -20
  38. package/dist/draggable.d.ts +0 -13
  39. package/dist/draggable.js +0 -13
  40. package/dist/graph-props.d.ts +0 -22
  41. package/dist/graph-props.js +0 -29
  42. package/dist/grid-draggable.d.ts +0 -91
  43. package/dist/grid-draggable.js +0 -168
  44. package/dist/index.d.ts +0 -16
  45. package/dist/index.js +0 -8
  46. package/dist/label.d.ts +0 -30
  47. package/dist/label.js +0 -132
  48. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  49. package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +0 -28
  50. package/dist/node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/chunk-D5BXCJ5G.js +0 -503
  51. package/dist/node_modules/.bun/react-draggable@4.6.0_6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.js +0 -5
  52. package/dist/root.d.ts +0 -68
  53. package/dist/root.js +0 -302
  54. package/dist/trig.d.ts +0 -41
  55. package/dist/trig.js +0 -47
  56. package/dist/types.d.ts +0 -125
  57. package/dist/types.js +0 -46
  58. package/dist/utils.d.ts +0 -44
  59. package/dist/utils.js +0 -82
package/dist/label.js DELETED
@@ -1,132 +0,0 @@
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 };
@@ -1,16 +0,0 @@
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 };
@@ -1,28 +0,0 @@
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 };
@@ -1,503 +0,0 @@
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 };
@@ -1,5 +0,0 @@
1
- import { Draggable as e } from "./chunk-D5BXCJ5G.js";
2
- //#region ../../../node_modules/.bun/react-draggable@4.6.0+6dbf9a050bc9aadb/node_modules/react-draggable/build/cjs/cjs.mjs
3
- var t = e;
4
- //#endregion
5
- export { t as cjs_default };