@caspeco/casper-ui-library 8.2.2 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/modal/modal.spec.d.ts +0 -1
- package/dist/components/modal/modal.spec.d.ts.map +1 -1
- package/dist/components/paginator/paginator.composition.d.ts +1 -0
- package/dist/components/paginator/paginator.composition.d.ts.map +1 -1
- package/dist/components/paginator/paginator.d.ts +3 -1
- package/dist/components/paginator/paginator.d.ts.map +1 -1
- package/dist/components/paginator/paginator.js +12 -11
- package/dist/components/table/helper.d.ts +2 -0
- package/dist/components/table/helper.d.ts.map +1 -0
- package/dist/components/table/helper.js +7 -0
- package/dist/components/table/table-content.d.ts.map +1 -1
- package/dist/components/table/table-content.js +93 -80
- package/dist/components/table/table-context-provider.d.ts +10 -2
- package/dist/components/table/table-context-provider.d.ts.map +1 -1
- package/dist/components/table/table-context-provider.js +149 -110
- package/dist/components/table/table-header-row.d.ts.map +1 -1
- package/dist/components/table/table-header-row.js +170 -121
- package/dist/components/table/table-row.js +11 -11
- package/dist/components/table/table.d.ts +1 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +16 -8
- package/dist/components/table/table.spec.d.ts +0 -1
- package/dist/components/table/table.spec.d.ts.map +1 -1
- package/dist/components/table/types.d.ts +21 -0
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/components/toggle-button/toggle-button.spec.d.ts +0 -1
- package/dist/components/toggle-button/toggle-button.spec.d.ts.map +1 -1
- package/dist/node_modules/@dnd-kit/abstract/index.js +1142 -0
- package/dist/node_modules/@dnd-kit/collision/dist/index.js +91 -0
- package/dist/node_modules/@dnd-kit/dom/index.js +1554 -0
- package/dist/node_modules/@dnd-kit/dom/sortable.js +631 -0
- package/dist/node_modules/@dnd-kit/dom/utilities.js +943 -0
- package/dist/node_modules/@dnd-kit/geometry/dist/index.js +200 -0
- package/dist/node_modules/@dnd-kit/react/hooks.js +69 -0
- package/dist/node_modules/@dnd-kit/react/index.js +235 -0
- package/dist/node_modules/@dnd-kit/react/sortable.js +129 -0
- package/dist/node_modules/@dnd-kit/react/utilities.js +11 -0
- package/dist/node_modules/@dnd-kit/state/dist/index.js +181 -0
- package/dist/node_modules/@preact/signals-core/dist/signals-core.module.js +265 -0
- package/dist/test-utils/hooks/setup-mock-resize-observer.d.ts +1 -1
- package/dist/test-utils/hooks/setup-mock-resize-observer.d.ts.map +1 -1
- package/dist/theme/theme-config/components/paginator-theme.d.ts +5 -19
- package/dist/theme/theme-config/components/paginator-theme.d.ts.map +1 -1
- package/dist/theme/theme-config/components/paginator-theme.js +34 -18
- package/package.json +3 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { ValueHistory as W, derived as S } from "../../state/dist/index.js";
|
|
2
|
+
import { batch as G } from "../../../@preact/signals-core/dist/signals-core.module.js";
|
|
3
|
+
var N = Object.create, z = Object.defineProperty, T = Object.getOwnPropertyDescriptor, R = Object.getOwnPropertySymbols, B = Object.prototype.hasOwnProperty, J = Object.prototype.propertyIsEnumerable, I = (r, t) => (t = Symbol[r]) ? t : /* @__PURE__ */ Symbol.for("Symbol." + r), p = (r) => {
|
|
4
|
+
throw TypeError(r);
|
|
5
|
+
}, A = Math.pow, g = (r, t, e) => t in r ? z(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, K = (r, t) => {
|
|
6
|
+
for (var e in t || (t = {}))
|
|
7
|
+
B.call(t, e) && g(r, e, t[e]);
|
|
8
|
+
if (R)
|
|
9
|
+
for (var e of R(t))
|
|
10
|
+
J.call(t, e) && g(r, e, t[e]);
|
|
11
|
+
return r;
|
|
12
|
+
}, L = (r) => {
|
|
13
|
+
var t;
|
|
14
|
+
return [, , , N((t = r?.[I("metadata")]) != null ? t : null)];
|
|
15
|
+
}, k = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], C = (r) => r !== void 0 && typeof r != "function" ? p("Function expected") : r, Q = (r, t, e, i, n) => ({ kind: k[r], name: t, metadata: i, addInitializer: (o) => e._ ? p("Already initialized") : n.push(C(o || null)) }), U = (r, t) => g(t, I("metadata"), r[3]), X = (r, t, e, i) => {
|
|
16
|
+
for (var n = 0, o = r[t >> 1], s = o && o.length; n < s; n++) o[n].call(e);
|
|
17
|
+
return i;
|
|
18
|
+
}, D = (r, t, e, i, n, o) => {
|
|
19
|
+
for (var s, c, a, u, M = t & 7, j = !1, F = !1, O = 2, P = k[M + 5], H = r[O] || (r[O] = []), d = (n = n.prototype, T(n, e)), v = i.length - 1; v >= 0; v--)
|
|
20
|
+
a = Q(M, e, c = {}, r[3], H), a.static = j, a.private = F, u = a.access = { has: (x) => e in x }, u.get = (x) => x[e], s = (0, i[v])(d[P], a), c._ = 1, C(s) && (d[P] = s);
|
|
21
|
+
return d && z(n, e, d), n;
|
|
22
|
+
}, E = (r, t, e) => t.has(r) || p("Cannot " + e), Y = (r, t, e) => (E(r, t, "read from private field"), t.get(r)), Z = (r, t, e) => t.has(r) ? p("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), $ = (r, t, e, i) => (E(r, t, "write to private field"), t.set(r, e), e), l = class _ {
|
|
23
|
+
/**
|
|
24
|
+
* @param {number} Coordinate of the point on the horizontal axis
|
|
25
|
+
* @param {number} Coordinate of the point on the vertical axis
|
|
26
|
+
*/
|
|
27
|
+
constructor(t, e) {
|
|
28
|
+
this.x = t, this.y = e;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Returns the delta between this point and another point.
|
|
32
|
+
*
|
|
33
|
+
* @param {Point} a - A point
|
|
34
|
+
* @param {Point} b - Another point
|
|
35
|
+
*/
|
|
36
|
+
static delta(t, e) {
|
|
37
|
+
return new _(t.x - e.x, t.y - e.y);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the distance (hypotenuse) between this point and another point.
|
|
41
|
+
*
|
|
42
|
+
* @param {Point} a - A point
|
|
43
|
+
* @param {Point} b - Another point
|
|
44
|
+
*/
|
|
45
|
+
static distance(t, e) {
|
|
46
|
+
return Math.hypot(t.x - e.x, t.y - e.y);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns true if both points are equal.
|
|
50
|
+
*
|
|
51
|
+
* @param {Point} a - A point
|
|
52
|
+
* @param {Point} b - Another point
|
|
53
|
+
*/
|
|
54
|
+
static equals(t, e) {
|
|
55
|
+
return t.x === e.x && t.y === e.y;
|
|
56
|
+
}
|
|
57
|
+
static from({ x: t, y: e }) {
|
|
58
|
+
return new _(t, e);
|
|
59
|
+
}
|
|
60
|
+
}, nt = class h {
|
|
61
|
+
constructor(t, e, i, n) {
|
|
62
|
+
this.left = t, this.top = e, this.width = i, this.height = n, this.scale = {
|
|
63
|
+
x: 1,
|
|
64
|
+
y: 1
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
get inverseScale() {
|
|
68
|
+
return {
|
|
69
|
+
x: 1 / this.scale.x,
|
|
70
|
+
y: 1 / this.scale.y
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
translate(t, e) {
|
|
74
|
+
const { top: i, left: n, width: o, height: s, scale: c } = this, a = new h(n + t, i + e, o, s);
|
|
75
|
+
return a.scale = K({}, c), a;
|
|
76
|
+
}
|
|
77
|
+
get boundingRectangle() {
|
|
78
|
+
const { width: t, height: e, left: i, top: n, right: o, bottom: s } = this;
|
|
79
|
+
return { width: t, height: e, left: i, top: n, right: o, bottom: s };
|
|
80
|
+
}
|
|
81
|
+
get center() {
|
|
82
|
+
const { left: t, top: e, right: i, bottom: n } = this;
|
|
83
|
+
return new l((t + i) / 2, (e + n) / 2);
|
|
84
|
+
}
|
|
85
|
+
get area() {
|
|
86
|
+
const { width: t, height: e } = this;
|
|
87
|
+
return t * e;
|
|
88
|
+
}
|
|
89
|
+
equals(t) {
|
|
90
|
+
if (!(t instanceof h))
|
|
91
|
+
return !1;
|
|
92
|
+
const { left: e, top: i, width: n, height: o } = this;
|
|
93
|
+
return e === t.left && i === t.top && n === t.width && o === t.height;
|
|
94
|
+
}
|
|
95
|
+
containsPoint(t) {
|
|
96
|
+
const { top: e, left: i, bottom: n, right: o } = this;
|
|
97
|
+
return e <= t.y && t.y <= n && i <= t.x && t.x <= o;
|
|
98
|
+
}
|
|
99
|
+
intersectionArea(t) {
|
|
100
|
+
return t instanceof h ? tt(this, t) : 0;
|
|
101
|
+
}
|
|
102
|
+
intersectionRatio(t) {
|
|
103
|
+
const { area: e } = this, i = this.intersectionArea(t);
|
|
104
|
+
return i / (t.area + e - i);
|
|
105
|
+
}
|
|
106
|
+
get bottom() {
|
|
107
|
+
const { top: t, height: e } = this;
|
|
108
|
+
return t + e;
|
|
109
|
+
}
|
|
110
|
+
get right() {
|
|
111
|
+
const { left: t, width: e } = this;
|
|
112
|
+
return t + e;
|
|
113
|
+
}
|
|
114
|
+
get aspectRatio() {
|
|
115
|
+
const { width: t, height: e } = this;
|
|
116
|
+
return t / e;
|
|
117
|
+
}
|
|
118
|
+
get corners() {
|
|
119
|
+
return [
|
|
120
|
+
{ x: this.left, y: this.top },
|
|
121
|
+
{ x: this.right, y: this.top },
|
|
122
|
+
{ x: this.left, y: this.bottom },
|
|
123
|
+
{ x: this.right, y: this.bottom }
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
static from({ top: t, left: e, width: i, height: n }) {
|
|
127
|
+
return new h(e, t, i, n);
|
|
128
|
+
}
|
|
129
|
+
static delta(t, e, i = { x: "center", y: "center" }) {
|
|
130
|
+
const n = (o, s) => {
|
|
131
|
+
const c = i[s], a = s === "x" ? o.left : o.top, u = s === "x" ? o.width : o.height;
|
|
132
|
+
return c == "start" ? a : c == "end" ? a + u : a + u / 2;
|
|
133
|
+
};
|
|
134
|
+
return l.delta(
|
|
135
|
+
{ x: n(t, "x"), y: n(t, "y") },
|
|
136
|
+
{ x: n(e, "x"), y: n(e, "y") }
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
static intersectionRatio(t, e) {
|
|
140
|
+
return h.from(t).intersectionRatio(h.from(e));
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
function tt(r, t) {
|
|
144
|
+
const e = Math.max(t.top, r.top), i = Math.max(t.left, r.left), n = Math.min(t.left + t.width, r.left + r.width), o = Math.min(t.top + t.height, r.top + r.height), s = n - i, c = o - e;
|
|
145
|
+
return i < n && e < o ? s * c : 0;
|
|
146
|
+
}
|
|
147
|
+
var b, q, w, y, f, m = class extends (w = W, q = [S], b = [S], w) {
|
|
148
|
+
constructor(r) {
|
|
149
|
+
const t = l.from(r);
|
|
150
|
+
super(t, (e, i) => l.equals(e, i)), X(f, 5, this), Z(this, y, 0), this.velocity = { x: 0, y: 0 };
|
|
151
|
+
}
|
|
152
|
+
get delta() {
|
|
153
|
+
return l.delta(this.current, this.initial);
|
|
154
|
+
}
|
|
155
|
+
get direction() {
|
|
156
|
+
const { current: r, previous: t } = this;
|
|
157
|
+
if (!t) return null;
|
|
158
|
+
const e = {
|
|
159
|
+
x: r.x - t.x,
|
|
160
|
+
y: r.y - t.y
|
|
161
|
+
};
|
|
162
|
+
return !e.x && !e.y ? null : Math.abs(e.x) > Math.abs(e.y) ? e.x > 0 ? "right" : "left" : e.y > 0 ? "down" : "up";
|
|
163
|
+
}
|
|
164
|
+
get current() {
|
|
165
|
+
return super.current;
|
|
166
|
+
}
|
|
167
|
+
set current(r) {
|
|
168
|
+
const { current: t } = this, e = l.from(r), i = {
|
|
169
|
+
x: e.x - t.x,
|
|
170
|
+
y: e.y - t.y
|
|
171
|
+
}, n = Date.now(), o = n - Y(this, y), s = (c) => Math.round(c / o * 100);
|
|
172
|
+
G(() => {
|
|
173
|
+
$(this, y, n), this.velocity = {
|
|
174
|
+
x: s(i.x),
|
|
175
|
+
y: s(i.y)
|
|
176
|
+
}, super.current = e;
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
reset(r = this.defaultValue) {
|
|
180
|
+
super.reset(l.from(r)), this.velocity = { x: 0, y: 0 };
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
f = L(w);
|
|
184
|
+
y = /* @__PURE__ */ new WeakMap();
|
|
185
|
+
D(f, 2, "delta", q, m);
|
|
186
|
+
D(f, 2, "direction", b, m);
|
|
187
|
+
U(f, m);
|
|
188
|
+
function it({ x: r, y: t }, e) {
|
|
189
|
+
const i = Math.abs(r), n = Math.abs(t);
|
|
190
|
+
return typeof e == "number" ? Math.sqrt(A(i, 2) + A(n, 2)) > e : "x" in e && "y" in e ? i > e.x && n > e.y : "x" in e ? i > e.x : "y" in e ? n > e.y : !1;
|
|
191
|
+
}
|
|
192
|
+
var V = /* @__PURE__ */ ((r) => (r.Horizontal = "x", r.Vertical = "y", r))(V || {}), ot = Object.values(V);
|
|
193
|
+
export {
|
|
194
|
+
ot as Axes,
|
|
195
|
+
V as Axis,
|
|
196
|
+
l as Point,
|
|
197
|
+
m as Position,
|
|
198
|
+
nt as Rectangle,
|
|
199
|
+
it as exceedsDistance
|
|
200
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { useEffect as p, useRef as s, useLayoutEffect as w, useMemo as y, useState as E, useCallback as k } from "react";
|
|
2
|
+
import "../state/dist/index.js";
|
|
3
|
+
import { flushSync as O } from "react-dom";
|
|
4
|
+
import { currentValue as m } from "./utilities.js";
|
|
5
|
+
import { effect as S, untracked as V } from "../../@preact/signals-core/dist/signals-core.module.js";
|
|
6
|
+
var C = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", a = C ? w : p;
|
|
7
|
+
function L() {
|
|
8
|
+
const e = E(0)[1];
|
|
9
|
+
return k(() => {
|
|
10
|
+
e((t) => t + 1);
|
|
11
|
+
}, [e]);
|
|
12
|
+
}
|
|
13
|
+
function D(e, t) {
|
|
14
|
+
const n = s(/* @__PURE__ */ new Map()), r = L();
|
|
15
|
+
return a(() => {
|
|
16
|
+
if (!e) {
|
|
17
|
+
n.current.clear();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
return S(() => {
|
|
21
|
+
var o;
|
|
22
|
+
let c = !1, u = !1;
|
|
23
|
+
for (const d of n.current) {
|
|
24
|
+
const [f] = d, l = V(() => d[1]), i = e[f];
|
|
25
|
+
l !== i && (c = !0, n.current.set(f, i), u = (o = t?.(f, l, i)) != null ? o : !1);
|
|
26
|
+
}
|
|
27
|
+
c && (u ? O(r) : r());
|
|
28
|
+
});
|
|
29
|
+
}, [e]), y(
|
|
30
|
+
() => e && new Proxy(e, {
|
|
31
|
+
get(o, c) {
|
|
32
|
+
const u = o[c];
|
|
33
|
+
return n.current.set(c, u), u;
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
[e]
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function I(e, t) {
|
|
40
|
+
e();
|
|
41
|
+
}
|
|
42
|
+
function R(e) {
|
|
43
|
+
const t = s(e);
|
|
44
|
+
return a(() => {
|
|
45
|
+
t.current = e;
|
|
46
|
+
}, [e]), t;
|
|
47
|
+
}
|
|
48
|
+
function _(e, t, n = p, r = Object.is) {
|
|
49
|
+
const o = s(e);
|
|
50
|
+
n(() => {
|
|
51
|
+
const c = o.current;
|
|
52
|
+
r(e, c) || (o.current = e, t(e, c));
|
|
53
|
+
}, [t, e]);
|
|
54
|
+
}
|
|
55
|
+
function j(e, t) {
|
|
56
|
+
const n = s(m(e));
|
|
57
|
+
a(() => {
|
|
58
|
+
const r = m(e);
|
|
59
|
+
r !== n.current && (n.current = r, t(r));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
D as useDeepSignal,
|
|
64
|
+
I as useImmediateEffect,
|
|
65
|
+
a as useIsomorphicLayoutEffect,
|
|
66
|
+
R as useLatest,
|
|
67
|
+
j as useOnElementChange,
|
|
68
|
+
_ as useOnValueChange
|
|
69
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { useRef as b, useEffect as ar, createContext as or, memo as sr, useInsertionEffect as ir, forwardRef as cr, useState as F, useMemo as lr, startTransition as ur, useImperativeHandle as dr, useContext as vr } from "react";
|
|
2
|
+
import { DragDropManager as W, defaultPreset as k } from "../dom/index.js";
|
|
3
|
+
import { KeyboardSensor as Nr, PointerSensor as Jr } from "../dom/index.js";
|
|
4
|
+
import { useLatest as h, useOnValueChange as L, useIsomorphicLayoutEffect as A } from "./hooks.js";
|
|
5
|
+
import { deepEqual as fr, ValueHistory as pr, derived as H } from "../state/dist/index.js";
|
|
6
|
+
import { jsxs as _r, jsx as gr } from "react/jsx-runtime";
|
|
7
|
+
import { resolveCustomizable as R } from "../abstract/index.js";
|
|
8
|
+
import { batch as hr } from "../../@preact/signals-core/dist/signals-core.module.js";
|
|
9
|
+
var T = Object.getOwnPropertySymbols, mr = Object.prototype.hasOwnProperty, yr = Object.prototype.propertyIsEnumerable, xr = (e, r) => {
|
|
10
|
+
var t = {};
|
|
11
|
+
for (var n in e)
|
|
12
|
+
mr.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
|
|
13
|
+
if (e != null && T)
|
|
14
|
+
for (var n of T(e))
|
|
15
|
+
r.indexOf(n) < 0 && yr.call(e, n) && (t[n] = e[n]);
|
|
16
|
+
return t;
|
|
17
|
+
}, Dr = new W(), G = or(
|
|
18
|
+
Dr
|
|
19
|
+
), wr = sr(
|
|
20
|
+
cr(({ children: e }, r) => {
|
|
21
|
+
const [t, n] = F(0), a = b(null), i = b(null), u = lr(
|
|
22
|
+
() => ({
|
|
23
|
+
renderer: {
|
|
24
|
+
get rendering() {
|
|
25
|
+
var c;
|
|
26
|
+
return (c = a.current) != null ? c : Promise.resolve();
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
trackRendering(c) {
|
|
30
|
+
a.current || (a.current = new Promise((d) => {
|
|
31
|
+
i.current = d;
|
|
32
|
+
})), ur(() => {
|
|
33
|
+
c(), n((d) => d + 1);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}),
|
|
37
|
+
[]
|
|
38
|
+
);
|
|
39
|
+
return A(() => {
|
|
40
|
+
var c;
|
|
41
|
+
(c = i.current) == null || c.call(i), a.current = null;
|
|
42
|
+
}, [e, t]), dr(r, () => u), null;
|
|
43
|
+
})
|
|
44
|
+
), z = [void 0, fr];
|
|
45
|
+
function Wr(e) {
|
|
46
|
+
var r = e, {
|
|
47
|
+
children: t,
|
|
48
|
+
onCollision: n,
|
|
49
|
+
onBeforeDragStart: a,
|
|
50
|
+
onDragStart: i,
|
|
51
|
+
onDragMove: u,
|
|
52
|
+
onDragOver: c,
|
|
53
|
+
onDragEnd: d
|
|
54
|
+
} = r, f = xr(r, [
|
|
55
|
+
"children",
|
|
56
|
+
"onCollision",
|
|
57
|
+
"onBeforeDragStart",
|
|
58
|
+
"onDragStart",
|
|
59
|
+
"onDragMove",
|
|
60
|
+
"onDragOver",
|
|
61
|
+
"onDragEnd"
|
|
62
|
+
]);
|
|
63
|
+
const p = b(null), { plugins: I, modifiers: M, sensors: w } = f, m = R(I, k.plugins), E = R(w, k.sensors), v = R(M, k.modifiers), y = h(a), _ = h(i), rr = h(c), er = h(u), tr = h(d), B = h(n), s = Er(() => {
|
|
64
|
+
var S;
|
|
65
|
+
return (S = f.manager) != null ? S : new W(f);
|
|
66
|
+
});
|
|
67
|
+
return ar(() => {
|
|
68
|
+
if (!p.current) throw new Error("Renderer not found");
|
|
69
|
+
const { renderer: S, trackRendering: O } = p.current, { monitor: g } = s;
|
|
70
|
+
s.renderer = S;
|
|
71
|
+
const nr = [
|
|
72
|
+
g.addEventListener("beforedragstart", (l) => {
|
|
73
|
+
const o = y.current;
|
|
74
|
+
o && O(() => o(l, s));
|
|
75
|
+
}),
|
|
76
|
+
g.addEventListener(
|
|
77
|
+
"dragstart",
|
|
78
|
+
(l) => {
|
|
79
|
+
var o;
|
|
80
|
+
return (o = _.current) == null ? void 0 : o.call(_, l, s);
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
g.addEventListener("dragover", (l) => {
|
|
84
|
+
const o = rr.current;
|
|
85
|
+
o && O(() => o(l, s));
|
|
86
|
+
}),
|
|
87
|
+
g.addEventListener("dragmove", (l) => {
|
|
88
|
+
const o = er.current;
|
|
89
|
+
o && O(() => o(l, s));
|
|
90
|
+
}),
|
|
91
|
+
g.addEventListener("dragend", (l) => {
|
|
92
|
+
const o = tr.current;
|
|
93
|
+
o && O(() => o(l, s));
|
|
94
|
+
}),
|
|
95
|
+
g.addEventListener(
|
|
96
|
+
"collision",
|
|
97
|
+
(l) => {
|
|
98
|
+
var o;
|
|
99
|
+
return (o = B.current) == null ? void 0 : o.call(B, l, s);
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
];
|
|
103
|
+
return () => nr.forEach((l) => l());
|
|
104
|
+
}, [s]), L(
|
|
105
|
+
m,
|
|
106
|
+
() => s && (s.plugins = m),
|
|
107
|
+
...z
|
|
108
|
+
), L(
|
|
109
|
+
E,
|
|
110
|
+
() => s && (s.sensors = E),
|
|
111
|
+
...z
|
|
112
|
+
), L(
|
|
113
|
+
v,
|
|
114
|
+
() => s && (s.modifiers = v),
|
|
115
|
+
...z
|
|
116
|
+
), /* @__PURE__ */ _r(G.Provider, { value: s, children: [
|
|
117
|
+
/* @__PURE__ */ gr(wr, { ref: p, children: t }),
|
|
118
|
+
t
|
|
119
|
+
] });
|
|
120
|
+
}
|
|
121
|
+
function Er(e) {
|
|
122
|
+
const r = b(null);
|
|
123
|
+
return r.current || (r.current = e()), ir(() => () => {
|
|
124
|
+
var t;
|
|
125
|
+
return (t = r.current) == null ? void 0 : t.destroy();
|
|
126
|
+
}, []), r.current;
|
|
127
|
+
}
|
|
128
|
+
function Sr() {
|
|
129
|
+
return vr(G);
|
|
130
|
+
}
|
|
131
|
+
function Ar(e) {
|
|
132
|
+
var r;
|
|
133
|
+
const t = (r = Sr()) != null ? r : void 0, [n] = F(() => e(t));
|
|
134
|
+
return n.manager !== t && (n.manager = t), A(n.register, [t, n]), n;
|
|
135
|
+
}
|
|
136
|
+
var Or = Object.create, K = Object.defineProperty, Pr = Object.getOwnPropertyDescriptor, N = (e, r) => (r = Symbol[e]) ? r : /* @__PURE__ */ Symbol.for("Symbol." + e), C = (e) => {
|
|
137
|
+
throw TypeError(e);
|
|
138
|
+
}, br = (e, r, t) => r in e ? K(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, Cr = (e) => {
|
|
139
|
+
var r;
|
|
140
|
+
return [, , , Or((r = e?.[N("metadata")]) != null ? r : null)];
|
|
141
|
+
}, J = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], Q = (e) => e !== void 0 && typeof e != "function" ? C("Function expected") : e, Ir = (e, r, t, n, a) => ({ kind: J[e], name: r, metadata: n, addInitializer: (i) => t._ ? C("Already initialized") : a.push(Q(i || null)) }), Mr = (e, r) => br(r, N("metadata"), e[3]), kr = (e, r, t, n) => {
|
|
142
|
+
for (var a = 0, i = e[r >> 1], u = i && i.length; a < u; a++) i[a].call(t);
|
|
143
|
+
return n;
|
|
144
|
+
}, U = (e, r, t, n, a, i) => {
|
|
145
|
+
for (var u, c, d, f, p = r & 7, I = !1, M = !1, w = 2, m = J[p + 5], E = e[w] || (e[w] = []), v = (a = a.prototype, Pr(a, t)), y = n.length - 1; y >= 0; y--)
|
|
146
|
+
d = Ir(p, t, c = {}, e[3], E), d.static = I, d.private = M, f = d.access = { has: (_) => t in _ }, f.get = (_) => _[t], u = (0, n[y])(v[m], d), c._ = 1, Q(u) && (v[m] = u);
|
|
147
|
+
return v && K(a, t, v), a;
|
|
148
|
+
}, X = (e, r, t) => r.has(e) || C("Cannot " + t), Lr = (e, r, t) => (X(e, r, "read from private field"), r.get(e)), Rr = (e, r, t) => r.has(e) ? C("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(e) : r.set(e, t), zr = (e, r, t, n) => (X(e, r, "write to private field"), r.set(e, t), t), x = class j {
|
|
149
|
+
/**
|
|
150
|
+
* @param {number} Coordinate of the point on the horizontal axis
|
|
151
|
+
* @param {number} Coordinate of the point on the vertical axis
|
|
152
|
+
*/
|
|
153
|
+
constructor(r, t) {
|
|
154
|
+
this.x = r, this.y = t;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Returns the delta between this point and another point.
|
|
158
|
+
*
|
|
159
|
+
* @param {Point} a - A point
|
|
160
|
+
* @param {Point} b - Another point
|
|
161
|
+
*/
|
|
162
|
+
static delta(r, t) {
|
|
163
|
+
return new j(r.x - t.x, r.y - t.y);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Returns the distance (hypotenuse) between this point and another point.
|
|
167
|
+
*
|
|
168
|
+
* @param {Point} a - A point
|
|
169
|
+
* @param {Point} b - Another point
|
|
170
|
+
*/
|
|
171
|
+
static distance(r, t) {
|
|
172
|
+
return Math.hypot(r.x - t.x, r.y - t.y);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Returns true if both points are equal.
|
|
176
|
+
*
|
|
177
|
+
* @param {Point} a - A point
|
|
178
|
+
* @param {Point} b - Another point
|
|
179
|
+
*/
|
|
180
|
+
static equals(r, t) {
|
|
181
|
+
return r.x === t.x && r.y === t.y;
|
|
182
|
+
}
|
|
183
|
+
static from({ x: r, y: t }) {
|
|
184
|
+
return new j(r, t);
|
|
185
|
+
}
|
|
186
|
+
}, Y, Z, V, P, D, q = class extends (V = pr, Z = [H], Y = [H], V) {
|
|
187
|
+
constructor(e) {
|
|
188
|
+
const r = x.from(e);
|
|
189
|
+
super(r, (t, n) => x.equals(t, n)), kr(D, 5, this), Rr(this, P, 0), this.velocity = { x: 0, y: 0 };
|
|
190
|
+
}
|
|
191
|
+
get delta() {
|
|
192
|
+
return x.delta(this.current, this.initial);
|
|
193
|
+
}
|
|
194
|
+
get direction() {
|
|
195
|
+
const { current: e, previous: r } = this;
|
|
196
|
+
if (!r) return null;
|
|
197
|
+
const t = {
|
|
198
|
+
x: e.x - r.x,
|
|
199
|
+
y: e.y - r.y
|
|
200
|
+
};
|
|
201
|
+
return !t.x && !t.y ? null : Math.abs(t.x) > Math.abs(t.y) ? t.x > 0 ? "right" : "left" : t.y > 0 ? "down" : "up";
|
|
202
|
+
}
|
|
203
|
+
get current() {
|
|
204
|
+
return super.current;
|
|
205
|
+
}
|
|
206
|
+
set current(e) {
|
|
207
|
+
const { current: r } = this, t = x.from(e), n = {
|
|
208
|
+
x: t.x - r.x,
|
|
209
|
+
y: t.y - r.y
|
|
210
|
+
}, a = Date.now(), i = a - Lr(this, P), u = (c) => Math.round(c / i * 100);
|
|
211
|
+
hr(() => {
|
|
212
|
+
zr(this, P, a), this.velocity = {
|
|
213
|
+
x: u(n.x),
|
|
214
|
+
y: u(n.y)
|
|
215
|
+
}, super.current = t;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
reset(e = this.defaultValue) {
|
|
219
|
+
super.reset(x.from(e)), this.velocity = { x: 0, y: 0 };
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
D = Cr(V);
|
|
223
|
+
P = /* @__PURE__ */ new WeakMap();
|
|
224
|
+
U(D, 2, "delta", Z, q);
|
|
225
|
+
U(D, 2, "direction", Y, q);
|
|
226
|
+
Mr(D, q);
|
|
227
|
+
var $ = /* @__PURE__ */ ((e) => (e.Horizontal = "x", e.Vertical = "y", e))($ || {});
|
|
228
|
+
Object.values($);
|
|
229
|
+
export {
|
|
230
|
+
Wr as DragDropProvider,
|
|
231
|
+
Nr as KeyboardSensor,
|
|
232
|
+
Jr as PointerSensor,
|
|
233
|
+
Sr as useDragDropManager,
|
|
234
|
+
Ar as useInstance
|
|
235
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useCallback as c } from "react";
|
|
2
|
+
import { deepEqual as f } from "../state/dist/index.js";
|
|
3
|
+
import { defaultSortableTransition as x, Sortable as R } from "../dom/sortable.js";
|
|
4
|
+
import { isSortable as rr } from "../dom/sortable.js";
|
|
5
|
+
import { useInstance as T } from "./index.js";
|
|
6
|
+
import { useDeepSignal as V, useOnValueChange as i, useIsomorphicLayoutEffect as k, useImmediateEffect as q, useOnElementChange as m } from "./hooks.js";
|
|
7
|
+
import { currentValue as v } from "./utilities.js";
|
|
8
|
+
import { batch as L } from "../../@preact/signals-core/dist/signals-core.module.js";
|
|
9
|
+
var N = Object.defineProperty, U = Object.defineProperties, z = Object.getOwnPropertyDescriptors, I = Object.getOwnPropertySymbols, A = Object.prototype.hasOwnProperty, B = Object.prototype.propertyIsEnumerable, j = (o, t, a) => t in o ? N(o, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[t] = a, _ = (o, t) => {
|
|
10
|
+
for (var a in t || (t = {}))
|
|
11
|
+
A.call(t, a) && j(o, a, t[a]);
|
|
12
|
+
if (I)
|
|
13
|
+
for (var a of I(t))
|
|
14
|
+
B.call(t, a) && j(o, a, t[a]);
|
|
15
|
+
return o;
|
|
16
|
+
}, F = (o, t) => U(o, z(t));
|
|
17
|
+
function Y(o) {
|
|
18
|
+
const {
|
|
19
|
+
accept: t,
|
|
20
|
+
collisionDetector: a,
|
|
21
|
+
collisionPriority: b,
|
|
22
|
+
id: O,
|
|
23
|
+
data: p,
|
|
24
|
+
element: h,
|
|
25
|
+
handle: y,
|
|
26
|
+
index: g,
|
|
27
|
+
group: D,
|
|
28
|
+
disabled: P,
|
|
29
|
+
feedback: d,
|
|
30
|
+
modifiers: S,
|
|
31
|
+
sensors: w,
|
|
32
|
+
target: C,
|
|
33
|
+
type: E
|
|
34
|
+
} = o, l = _(_({}, x), o.transition), r = T((e) => new R(
|
|
35
|
+
F(_({}, o), {
|
|
36
|
+
transition: l,
|
|
37
|
+
register: !1,
|
|
38
|
+
handle: v(y),
|
|
39
|
+
element: v(h),
|
|
40
|
+
target: v(C),
|
|
41
|
+
feedback: d
|
|
42
|
+
}),
|
|
43
|
+
e
|
|
44
|
+
)), u = V(r, G);
|
|
45
|
+
return i(O, () => r.id = O), k(() => {
|
|
46
|
+
L(() => {
|
|
47
|
+
r.group = D, r.index = g;
|
|
48
|
+
});
|
|
49
|
+
}, [r, D, g]), i(E, () => r.type = E), i(
|
|
50
|
+
t,
|
|
51
|
+
() => r.accept = t,
|
|
52
|
+
void 0,
|
|
53
|
+
f
|
|
54
|
+
), i(p, () => p && (r.data = p)), i(
|
|
55
|
+
g,
|
|
56
|
+
() => {
|
|
57
|
+
var e;
|
|
58
|
+
(e = r.manager) != null && e.dragOperation.status.idle && l?.idle && r.refreshShape();
|
|
59
|
+
},
|
|
60
|
+
q
|
|
61
|
+
), m(y, (e) => r.handle = e), m(h, (e) => r.element = e), m(C, (e) => r.target = e), i(P, () => r.disabled = P === !0), i(w, () => r.sensors = w), i(
|
|
62
|
+
a,
|
|
63
|
+
() => r.collisionDetector = a
|
|
64
|
+
), i(
|
|
65
|
+
b,
|
|
66
|
+
() => r.collisionPriority = b
|
|
67
|
+
), i(d, () => r.feedback = d ?? "default"), i(
|
|
68
|
+
l,
|
|
69
|
+
() => r.transition = l,
|
|
70
|
+
void 0,
|
|
71
|
+
f
|
|
72
|
+
), i(
|
|
73
|
+
S,
|
|
74
|
+
() => r.modifiers = S,
|
|
75
|
+
void 0,
|
|
76
|
+
f
|
|
77
|
+
), i(
|
|
78
|
+
o.alignment,
|
|
79
|
+
() => r.alignment = o.alignment
|
|
80
|
+
), {
|
|
81
|
+
sortable: u,
|
|
82
|
+
get isDragging() {
|
|
83
|
+
return u.isDragging;
|
|
84
|
+
},
|
|
85
|
+
get isDropping() {
|
|
86
|
+
return u.isDropping;
|
|
87
|
+
},
|
|
88
|
+
get isDragSource() {
|
|
89
|
+
return u.isDragSource;
|
|
90
|
+
},
|
|
91
|
+
get isDropTarget() {
|
|
92
|
+
return u.isDropTarget;
|
|
93
|
+
},
|
|
94
|
+
handleRef: c(
|
|
95
|
+
(e) => {
|
|
96
|
+
r.handle = e ?? void 0;
|
|
97
|
+
},
|
|
98
|
+
[r]
|
|
99
|
+
),
|
|
100
|
+
ref: c(
|
|
101
|
+
(e) => {
|
|
102
|
+
var n, s;
|
|
103
|
+
!e && ((n = r.element) != null && n.isConnected) && !((s = r.manager) != null && s.dragOperation.status.idle) || (r.element = e ?? void 0);
|
|
104
|
+
},
|
|
105
|
+
[r]
|
|
106
|
+
),
|
|
107
|
+
sourceRef: c(
|
|
108
|
+
(e) => {
|
|
109
|
+
var n, s;
|
|
110
|
+
!e && ((n = r.source) != null && n.isConnected) && !((s = r.manager) != null && s.dragOperation.status.idle) || (r.source = e ?? void 0);
|
|
111
|
+
},
|
|
112
|
+
[r]
|
|
113
|
+
),
|
|
114
|
+
targetRef: c(
|
|
115
|
+
(e) => {
|
|
116
|
+
var n, s;
|
|
117
|
+
!e && ((n = r.target) != null && n.isConnected) && !((s = r.manager) != null && s.dragOperation.status.idle) || (r.target = e ?? void 0);
|
|
118
|
+
},
|
|
119
|
+
[r]
|
|
120
|
+
)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function G(o, t, a) {
|
|
124
|
+
return !!(o === "isDragSource" && !a && t);
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
rr as isSortable,
|
|
128
|
+
Y as useSortable
|
|
129
|
+
};
|