@box-kite/react 2.2.7 → 2.2.8
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/BOX_AI_CONTEXT.md +76 -0
- package/BOX_KITE_AI_CONTEXT.md +76 -0
- package/analytics.cjs +1 -0
- package/analytics.d.ts +10 -0
- package/analytics.mjs +121 -0
- package/behavior.cjs +1 -1
- package/behavior.mjs +42 -38
- package/box.cjs +1 -1
- package/box.d.ts +9 -0
- package/box.mjs +17 -16
- package/catalog.cjs +1 -1
- package/catalog.mjs +8 -0
- package/client.cjs +1 -1
- package/client.mjs +120 -120
- package/components/accordion.cjs +1 -1
- package/components/accordion.mjs +19 -10
- package/components/agent.cjs +1 -1
- package/components/agent.mjs +21 -8
- package/components/calendar.cjs +1 -1
- package/components/calendar.d.ts +3 -1
- package/components/calendar.mjs +154 -142
- package/components/combobox.cjs +1 -1
- package/components/combobox.mjs +184 -174
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +183 -170
- package/components/dataGrid/models/columnModel.d.ts +1 -0
- package/components/dataGrid/models/gridModel.d.ts +18 -0
- package/components/dataGrid/models/rangeModel.d.ts +3 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +987 -896
- package/components/dateField.cjs +1 -1
- package/components/dateField.mjs +165 -159
- package/components/datePicker.cjs +1 -1
- package/components/datePicker.mjs +198 -183
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +38 -33
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.mjs +107 -93
- package/components/form.cjs +1 -1
- package/components/form.mjs +22 -18
- package/components/menu.cjs +1 -1
- package/components/menu.d.ts +2 -0
- package/components/menu.mjs +196 -175
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +7 -7
- package/components/popover.cjs +1 -1
- package/components/popover.mjs +4 -0
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +10 -5
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +84 -83
- package/components/sortableList.cjs +1 -1
- package/components/sortableList.mjs +158 -150
- package/components/swipeItem.cjs +1 -1
- package/components/swipeItem.mjs +92 -84
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +10 -5
- package/components/timeZoneSelect.cjs +1 -1
- package/components/timeZoneSelect.mjs +40 -35
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +151 -113
- package/dataGridDateParts.cjs +1 -1
- package/dataGridDateParts.mjs +56 -55
- package/dataGridList.cjs +1 -1
- package/dataGridList.mjs +430 -429
- package/effects.cjs +1 -1
- package/effects.mjs +1 -1
- package/interactionListening.cjs +1 -0
- package/interactionListening.mjs +117 -0
- package/interactions.cjs +1 -0
- package/interactions.mjs +25 -0
- package/layer.cjs +1 -1
- package/layer.mjs +68 -66
- package/package.json +132 -68
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +44 -25
- package/react/interactions/interactions.d.ts +30 -0
- package/react/popover/usePopoverLayer.d.ts +3 -0
- package/react/useStyles.d.ts +8 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +49 -48
- package/reporting.cjs +1 -0
- package/reporting.mjs +51 -0
- package/scrolling.cjs +1 -1
- package/scrolling.mjs +1 -1
- package/supabase/functions/collect/index.d.ts +30 -0
- package/supabase/functions/collect/index.test.d.ts +1 -0
- package/utils/analytics/analytics.d.ts +72 -0
- package/utils/analytics/analyticsIdentity.d.ts +13 -0
- package/utils/interactions/componentAttribute.d.ts +6 -0
- package/utils/interactions/interactionChannel.d.ts +35 -0
- package/utils/interactions/interactionJson.d.ts +6 -0
- package/utils/interactions/interactionListening.d.ts +6 -0
- package/utils/interactions/interactionTypes.d.ts +224 -0
|
@@ -3,14 +3,15 @@ import { f as e } from "../react-shared.mjs";
|
|
|
3
3
|
import { n as t } from "../effects.mjs";
|
|
4
4
|
import { useBoxElement as n } from "../box.mjs";
|
|
5
5
|
import { a as r, o as i } from "../behavior.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import s from "./
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
6
|
+
import { i as a, r as o } from "../reporting.mjs";
|
|
7
|
+
import { Circle as s, Svg as c } from "./svg.mjs";
|
|
8
|
+
import l from "./visuallyHidden.mjs";
|
|
9
|
+
import { t as u } from "../scrolling.mjs";
|
|
10
|
+
import d from "./list.mjs";
|
|
11
|
+
import { createContext as f, useCallback as ee, useContext as p, useEffect as m, useId as te, useMemo as h, useRef as g, useState as _ } from "react";
|
|
12
|
+
import { jsx as v, jsxs as ne } from "react/jsx-runtime";
|
|
12
13
|
//#region src/utils/sortable/sortableUtils.ts
|
|
13
|
-
var
|
|
14
|
+
var y;
|
|
14
15
|
(function(e) {
|
|
15
16
|
e.SLOP = 4;
|
|
16
17
|
function t(e) {
|
|
@@ -53,31 +54,31 @@ var v;
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
e.keyTarget = o;
|
|
56
|
-
})(
|
|
57
|
-
var
|
|
58
|
-
function w(e) {
|
|
59
|
-
return e ? Array.from(e.querySelectorAll(C)) : [];
|
|
60
|
-
}
|
|
57
|
+
})(y ||= {});
|
|
58
|
+
var b = y, x = f(null), S = f(null), C = 48, re = 12, w = ":scope > [data-sortable-value]";
|
|
61
59
|
function T(e) {
|
|
62
|
-
return
|
|
60
|
+
return e ? Array.from(e.querySelectorAll(w)) : [];
|
|
63
61
|
}
|
|
64
62
|
function E(e) {
|
|
65
|
-
return
|
|
63
|
+
return T(e).map((e) => e.dataset.sortableValue ?? "");
|
|
64
|
+
}
|
|
65
|
+
function D(e) {
|
|
66
|
+
return new Map(T(e).map((e) => [e.dataset.sortableValue ?? "", e.getBoundingClientRect().top]));
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
+
function ie(e, t) {
|
|
68
69
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
-
let { onOrderChange:
|
|
72
|
-
|
|
73
|
-
}, [n]),
|
|
74
|
-
|
|
71
|
+
function O(e, n) {
|
|
72
|
+
let { onOrderChange: s, onOrderCommit: c, children: f, variant: p, props: y, ...S } = e, w = g(null), O = g(null), k = g(null), [A, j] = _(null), [M, N] = _(0), [P, F] = _(!1), [ae, I] = _(""), L = `${te()}-sortable`, R = i(A), z = o(s, "sortableList", "orderChange"), B = o(c, "sortableList", "orderCommit"), V = a("sortableList"), oe = ee((e) => {
|
|
73
|
+
w.current = e, typeof n == "function" ? n(e) : n && (n.current = e);
|
|
74
|
+
}, [n]), H = (e, t) => `position ${e.indexOf(t) + 1} of ${e.length}`, U = (e, t) => {
|
|
75
|
+
k.current = D(w.current), z(e, t);
|
|
75
76
|
};
|
|
76
77
|
t(() => {
|
|
77
|
-
let e =
|
|
78
|
+
let e = k.current;
|
|
78
79
|
if (e) {
|
|
79
|
-
|
|
80
|
-
for (let t of w
|
|
80
|
+
k.current = null;
|
|
81
|
+
for (let t of T(w.current)) {
|
|
81
82
|
let n = e.get(t.dataset.sortableValue ?? ""), r = n === void 0 ? 0 : n - t.getBoundingClientRect().top, i = parseFloat(getComputedStyle(t).transitionDuration) * 1e3 || 0;
|
|
82
83
|
Math.abs(r) < 1 || i === 0 || typeof t.animate != "function" || t.animate([{ translate: `0 ${r}px` }, { translate: "0 0" }], {
|
|
83
84
|
duration: i,
|
|
@@ -85,25 +86,25 @@ function D(e, n) {
|
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
|
-
}),
|
|
89
|
-
if (!
|
|
90
|
-
let e = requestAnimationFrame(() =>
|
|
89
|
+
}), m(() => {
|
|
90
|
+
if (!P) return;
|
|
91
|
+
let e = requestAnimationFrame(() => F(!1));
|
|
91
92
|
return () => cancelAnimationFrame(e);
|
|
92
|
-
}, [
|
|
93
|
-
if (!
|
|
94
|
-
let e = w
|
|
93
|
+
}, [P]), t(() => {
|
|
94
|
+
if (!A || A.pointer) return;
|
|
95
|
+
let e = T(w.current).find((e) => e.dataset.sortableValue === A.value)?.querySelector("[data-sortable-handle]");
|
|
95
96
|
e && e.ownerDocument.activeElement !== e && e.focus();
|
|
96
97
|
});
|
|
97
|
-
let
|
|
98
|
-
let n = e.pointer, r =
|
|
98
|
+
let W = r((e, t) => {
|
|
99
|
+
let n = e.pointer, r = w.current;
|
|
99
100
|
if (!n || !r) return;
|
|
100
101
|
n.lastY = t;
|
|
101
102
|
let i = t - r.getBoundingClientRect().top - (n.startY - n.startTop), a = n.order.indexOf(e.value);
|
|
102
|
-
n.to =
|
|
103
|
-
}),
|
|
104
|
-
let n =
|
|
103
|
+
n.to = b.targetIndex(n.slots, a, i), N(i);
|
|
104
|
+
}), se = (e, t) => {
|
|
105
|
+
let n = w.current;
|
|
105
106
|
if (!n) return;
|
|
106
|
-
let r = n.getBoundingClientRect().top, i =
|
|
107
|
+
let r = n.getBoundingClientRect().top, i = T(n), a = i.map((e) => e.dataset.sortableValue ?? ""), o = i.map((e) => {
|
|
107
108
|
let t = e.getBoundingClientRect();
|
|
108
109
|
return {
|
|
109
110
|
top: t.top - r,
|
|
@@ -123,195 +124,202 @@ function D(e, n) {
|
|
|
123
124
|
to: a.indexOf(t.value)
|
|
124
125
|
}
|
|
125
126
|
};
|
|
126
|
-
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
if (!
|
|
130
|
-
let e =
|
|
131
|
-
let r =
|
|
127
|
+
j(s), W(s, e.clientY);
|
|
128
|
+
}, G = A?.pointer !== void 0;
|
|
129
|
+
m(() => {
|
|
130
|
+
if (!G) return;
|
|
131
|
+
let e = u(w.current), t = 0, n = () => {
|
|
132
|
+
let r = R.current;
|
|
132
133
|
if (r?.pointer) {
|
|
133
|
-
let t = r.pointer.lastY, n = e ? e.getBoundingClientRect().top : 0, i = e ? e.getBoundingClientRect().bottom : window.innerHeight, a = t < n +
|
|
134
|
-
a && ((e ?? window).scrollBy(0, a),
|
|
134
|
+
let t = r.pointer.lastY, n = e ? e.getBoundingClientRect().top : 0, i = e ? e.getBoundingClientRect().bottom : window.innerHeight, a = t < n + C ? -12 : t > i - C ? re : 0;
|
|
135
|
+
a && ((e ?? window).scrollBy(0, a), W(r, t));
|
|
135
136
|
}
|
|
136
137
|
t = requestAnimationFrame(n);
|
|
137
138
|
};
|
|
138
139
|
return t = requestAnimationFrame(n), () => cancelAnimationFrame(t);
|
|
139
140
|
}, [
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
G,
|
|
142
|
+
W,
|
|
143
|
+
R
|
|
143
144
|
]);
|
|
144
|
-
let
|
|
145
|
-
let r =
|
|
146
|
-
|
|
145
|
+
let K = (e, t, n) => {
|
|
146
|
+
let r = E(w.current);
|
|
147
|
+
j({
|
|
147
148
|
value: e,
|
|
148
149
|
name: t,
|
|
149
150
|
origin: r
|
|
150
|
-
}),
|
|
151
|
-
|
|
151
|
+
}), V("grab", e, {
|
|
152
|
+
reason: n.type === "keydown" ? "keyboard" : "pointer",
|
|
153
|
+
event: n,
|
|
154
|
+
from: r.indexOf(e)
|
|
155
|
+
}), I(`${t} picked up at ${H(r, e)}. Use the arrow keys to move it, Enter to drop it.`), n.preventDefault();
|
|
156
|
+
}, q = (e, t, n = E(w.current)) => {
|
|
152
157
|
let r = n.indexOf(e.value);
|
|
153
|
-
|
|
158
|
+
j(null), B(n, {
|
|
154
159
|
reason: "keyboard",
|
|
155
160
|
event: t,
|
|
156
161
|
value: e.value,
|
|
157
162
|
from: e.origin.indexOf(e.value),
|
|
158
163
|
to: r
|
|
159
|
-
}),
|
|
160
|
-
},
|
|
161
|
-
let n =
|
|
162
|
-
|
|
164
|
+
}), I(`${e.name} dropped at ${H(n, e.value)}.`);
|
|
165
|
+
}, J = r((e, t) => {
|
|
166
|
+
let n = E(w.current);
|
|
167
|
+
V("grabCancel", e.value, {
|
|
168
|
+
reason: t.type === "keydown" ? "escape" : t.type === "blur" ? "blur" : "pointercancel",
|
|
169
|
+
event: t
|
|
170
|
+
}), j(null), N(0), ie(n, e.origin) || U(e.origin, {
|
|
163
171
|
reason: e.pointer ? "pointer" : "keyboard",
|
|
164
172
|
event: t,
|
|
165
173
|
value: e.value,
|
|
166
174
|
from: n.indexOf(e.value),
|
|
167
175
|
to: e.origin.indexOf(e.value)
|
|
168
|
-
}),
|
|
169
|
-
}),
|
|
170
|
-
let r =
|
|
176
|
+
}), I(`${e.name} put back at ${H(e.origin, e.value)}.`);
|
|
177
|
+
}), Y = (e, t, n) => {
|
|
178
|
+
let r = E(w.current), i = r.indexOf(e.value);
|
|
171
179
|
if (i < 0 || t === i) return r;
|
|
172
|
-
let a =
|
|
173
|
-
return
|
|
180
|
+
let a = b.move(r, i, t);
|
|
181
|
+
return U(a, {
|
|
174
182
|
reason: "keyboard",
|
|
175
183
|
event: n,
|
|
176
184
|
value: e.value,
|
|
177
185
|
from: i,
|
|
178
186
|
to: t
|
|
179
|
-
}),
|
|
180
|
-
},
|
|
181
|
-
e.button !== 0 || e.defaultPrevented || (e.preventDefault(), e.currentTarget.focus(), e.currentTarget.setPointerCapture?.(e.pointerId),
|
|
187
|
+
}), I(`${e.name}, ${H(a, e.value)}.`), a;
|
|
188
|
+
}, X = r((e, t, n) => {
|
|
189
|
+
e.button !== 0 || e.defaultPrevented || (e.preventDefault(), e.currentTarget.focus(), e.currentTarget.setPointerCapture?.(e.pointerId), O.current = {
|
|
182
190
|
id: e.pointerId,
|
|
183
191
|
x: e.clientX,
|
|
184
192
|
y: e.clientY,
|
|
185
193
|
value: t,
|
|
186
194
|
name: n
|
|
187
195
|
});
|
|
188
|
-
}),
|
|
189
|
-
let t =
|
|
196
|
+
}), Z = r((e) => {
|
|
197
|
+
let t = R.current;
|
|
190
198
|
if (t?.pointer && t.pointer.id === e.pointerId) {
|
|
191
|
-
|
|
199
|
+
W(t, e.clientY);
|
|
192
200
|
return;
|
|
193
201
|
}
|
|
194
|
-
let n =
|
|
195
|
-
!n || n.id !== e.pointerId || Math.hypot(e.clientX - n.x, e.clientY - n.y) <
|
|
196
|
-
}),
|
|
197
|
-
let t =
|
|
198
|
-
|
|
199
|
-
let n =
|
|
202
|
+
let n = O.current;
|
|
203
|
+
!n || n.id !== e.pointerId || Math.hypot(e.clientX - n.x, e.clientY - n.y) < b.SLOP || (O.current = null, se(e, n));
|
|
204
|
+
}), Q = r((e) => {
|
|
205
|
+
let t = O.current;
|
|
206
|
+
O.current = null;
|
|
207
|
+
let n = R.current;
|
|
200
208
|
if (t && t.id === e.pointerId && e.type === "pointerup") {
|
|
201
|
-
n && !n.pointer ? n.value === t.value &&
|
|
209
|
+
n && !n.pointer ? n.value === t.value && q(n, e) : K(t.value, t.name, e);
|
|
202
210
|
return;
|
|
203
211
|
}
|
|
204
212
|
let r = n?.pointer;
|
|
205
213
|
if (!n || !r || r.id !== e.pointerId) return;
|
|
206
|
-
if (e.currentTarget.releasePointerCapture?.(e.pointerId),
|
|
207
|
-
|
|
214
|
+
if (e.currentTarget.releasePointerCapture?.(e.pointerId), F(!0), e.type === "pointercancel") {
|
|
215
|
+
k.current = D(w.current), J(n, e);
|
|
208
216
|
return;
|
|
209
217
|
}
|
|
210
|
-
let i = r.order.indexOf(n.value), a =
|
|
218
|
+
let i = r.order.indexOf(n.value), a = b.move(r.order, i, r.to), o = {
|
|
211
219
|
reason: "pointer",
|
|
212
220
|
event: e,
|
|
213
221
|
value: n.value,
|
|
214
222
|
from: i,
|
|
215
223
|
to: r.to
|
|
216
224
|
};
|
|
217
|
-
|
|
218
|
-
}),
|
|
225
|
+
k.current = D(w.current), j(null), N(0), r.to !== i && z(a, o), B(a, o), I(`${n.name} dropped at ${H(a, n.value)}.`);
|
|
226
|
+
}), $ = r((e, t, n) => {
|
|
219
227
|
if (e.defaultPrevented) return;
|
|
220
|
-
let r =
|
|
228
|
+
let r = R.current, i = r && r.value === t && !r.pointer ? r : void 0;
|
|
221
229
|
if (!i) {
|
|
222
|
-
(e.key === "Enter" || e.key === " ") &&
|
|
230
|
+
(e.key === "Enter" || e.key === " ") && K(t, n, e);
|
|
223
231
|
return;
|
|
224
232
|
}
|
|
225
233
|
if (e.key === "Escape") {
|
|
226
|
-
e.preventDefault(),
|
|
234
|
+
e.preventDefault(), J(i, e);
|
|
227
235
|
return;
|
|
228
236
|
}
|
|
229
237
|
if (e.key === "Enter" || e.key === " ") {
|
|
230
|
-
e.preventDefault(),
|
|
238
|
+
e.preventDefault(), q(i, e);
|
|
231
239
|
return;
|
|
232
240
|
}
|
|
233
|
-
let a =
|
|
234
|
-
o !== null && (e.preventDefault(),
|
|
235
|
-
}),
|
|
241
|
+
let a = E(w.current), o = b.keyTarget(e.key, a.indexOf(t), a.length);
|
|
242
|
+
o !== null && (e.preventDefault(), Y(i, o, e));
|
|
243
|
+
}), ce = r((e) => {
|
|
236
244
|
setTimeout(() => {
|
|
237
|
-
let t =
|
|
238
|
-
!t || t.pointer || t.value !== e || !n || n.ownerDocument.activeElement?.closest("[data-sortable-value]")?.getAttribute("data-sortable-value") !== e &&
|
|
245
|
+
let t = R.current, n = w.current;
|
|
246
|
+
!t || t.pointer || t.value !== e || !n || n.ownerDocument.activeElement?.closest("[data-sortable-value]")?.getAttribute("data-sortable-value") !== e && J(t, new Event("blur"));
|
|
239
247
|
});
|
|
240
|
-
}),
|
|
241
|
-
let t =
|
|
248
|
+
}), le = (e) => {
|
|
249
|
+
let t = R.current;
|
|
242
250
|
if (!t || t.pointer || !(e.target instanceof Element)) return null;
|
|
243
251
|
let n = e.target.closest("[data-sortable-value]");
|
|
244
|
-
return n && n.parentElement ===
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
let t =
|
|
249
|
-
!t || !n || (e.preventDefault(), e.stopPropagation(),
|
|
250
|
-
},
|
|
251
|
-
let e =
|
|
252
|
+
return n && n.parentElement === w.current && n.dataset.sortableValue !== t.value ? n : null;
|
|
253
|
+
}, ue = (e) => {
|
|
254
|
+
le(e) && e.preventDefault();
|
|
255
|
+
}, de = (e) => {
|
|
256
|
+
let t = le(e), n = R.current;
|
|
257
|
+
!t || !n || (e.preventDefault(), e.stopPropagation(), q(n, e, Y(n, E(w.current).indexOf(t.dataset.sortableValue ?? ""), e)));
|
|
258
|
+
}, fe = h(() => {
|
|
259
|
+
let e = A?.pointer, t = e ? e.order.indexOf(A.value) : -1;
|
|
252
260
|
return {
|
|
253
|
-
heldOf: (e) =>
|
|
261
|
+
heldOf: (e) => A && A.value === e ? A.pointer ? "pointer" : "keyboard" : void 0,
|
|
254
262
|
translateOf: (n) => {
|
|
255
263
|
if (!e) return;
|
|
256
|
-
if (n ===
|
|
257
|
-
let r =
|
|
264
|
+
if (n === A.value) return `0 ${Math.round(M)}px`;
|
|
265
|
+
let r = b.shiftOf(e.slots, t, e.to, e.order.indexOf(n));
|
|
258
266
|
return r ? `0 ${r}px` : void 0;
|
|
259
267
|
},
|
|
260
|
-
settling:
|
|
261
|
-
instructionsId:
|
|
268
|
+
settling: P,
|
|
269
|
+
instructionsId: L,
|
|
262
270
|
handleProps: (e, t) => ({
|
|
263
271
|
type: "button",
|
|
264
272
|
"data-sortable-handle": "",
|
|
265
273
|
"aria-label": `Move ${t}`,
|
|
266
|
-
"aria-pressed":
|
|
267
|
-
"aria-describedby":
|
|
268
|
-
onPointerDown: (n) =>
|
|
269
|
-
onPointerMove:
|
|
270
|
-
onPointerUp:
|
|
271
|
-
onPointerCancel:
|
|
272
|
-
onKeyDown: (n) =>
|
|
273
|
-
onBlur: () =>
|
|
274
|
+
"aria-pressed": A?.value === e,
|
|
275
|
+
"aria-describedby": L,
|
|
276
|
+
onPointerDown: (n) => X(n, e, t),
|
|
277
|
+
onPointerMove: Z,
|
|
278
|
+
onPointerUp: Q,
|
|
279
|
+
onPointerCancel: Q,
|
|
280
|
+
onKeyDown: (n) => $(n, e, t),
|
|
281
|
+
onBlur: () => ce(e)
|
|
274
282
|
})
|
|
275
283
|
};
|
|
276
284
|
}, [
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
J,
|
|
282
|
-
Y,
|
|
285
|
+
A,
|
|
286
|
+
M,
|
|
287
|
+
P,
|
|
288
|
+
L,
|
|
283
289
|
X,
|
|
284
290
|
Z,
|
|
285
|
-
Q
|
|
291
|
+
Q,
|
|
292
|
+
$,
|
|
293
|
+
ce
|
|
286
294
|
]);
|
|
287
|
-
return /* @__PURE__ */
|
|
288
|
-
value:
|
|
295
|
+
return /* @__PURE__ */ ne(x.Provider, {
|
|
296
|
+
value: fe,
|
|
289
297
|
children: [
|
|
290
|
-
/* @__PURE__ */
|
|
291
|
-
ref:
|
|
292
|
-
...
|
|
293
|
-
variant:
|
|
294
|
-
userSelect:
|
|
298
|
+
/* @__PURE__ */ v(d, {
|
|
299
|
+
ref: oe,
|
|
300
|
+
...S,
|
|
301
|
+
variant: p,
|
|
302
|
+
userSelect: G ? "none" : void 0,
|
|
295
303
|
props: {
|
|
296
|
-
...
|
|
297
|
-
onMouseDownCapture:
|
|
298
|
-
onClickCapture:
|
|
304
|
+
...y,
|
|
305
|
+
onMouseDownCapture: ue,
|
|
306
|
+
onClickCapture: de
|
|
299
307
|
},
|
|
300
|
-
children:
|
|
308
|
+
children: f
|
|
301
309
|
}),
|
|
302
|
-
/* @__PURE__ */
|
|
310
|
+
/* @__PURE__ */ v(l, {
|
|
303
311
|
props: { role: "status" },
|
|
304
|
-
children:
|
|
312
|
+
children: ae
|
|
305
313
|
}),
|
|
306
|
-
/* @__PURE__ */
|
|
307
|
-
id:
|
|
314
|
+
/* @__PURE__ */ v(l, {
|
|
315
|
+
id: L,
|
|
308
316
|
children: "Press Enter or Space to pick the item up, the arrow keys to move it, Enter to drop it and Escape to put it back."
|
|
309
317
|
})
|
|
310
318
|
]
|
|
311
319
|
});
|
|
312
320
|
}
|
|
313
|
-
function
|
|
314
|
-
let { value: n, label: r, disabled: i = !1, variant: a, props: o, ...s } = e, c =
|
|
321
|
+
function k(e, t) {
|
|
322
|
+
let { value: n, label: r, disabled: i = !1, variant: a, props: o, ...s } = e, c = p(x), l = c?.heldOf(n), u = c?.translateOf(n), f = h(() => ({
|
|
315
323
|
value: n,
|
|
316
324
|
name: r ?? n,
|
|
317
325
|
disabled: i
|
|
@@ -320,17 +328,17 @@ function O(e, t) {
|
|
|
320
328
|
r,
|
|
321
329
|
i
|
|
322
330
|
]);
|
|
323
|
-
return /* @__PURE__ */
|
|
324
|
-
value:
|
|
325
|
-
children: /* @__PURE__ */
|
|
331
|
+
return /* @__PURE__ */ v(S.Provider, {
|
|
332
|
+
value: f,
|
|
333
|
+
children: /* @__PURE__ */ v(d.Item, {
|
|
326
334
|
ref: t,
|
|
327
335
|
...s,
|
|
328
336
|
variant: [a, {
|
|
329
|
-
lifted:
|
|
330
|
-
grabbed:
|
|
337
|
+
lifted: l === "pointer",
|
|
338
|
+
grabbed: l === "keyboard",
|
|
331
339
|
settling: c?.settling ?? !1
|
|
332
340
|
}],
|
|
333
|
-
style:
|
|
341
|
+
style: u ? { translate: u } : void 0,
|
|
334
342
|
props: {
|
|
335
343
|
...o,
|
|
336
344
|
"data-sortable-value": n
|
|
@@ -338,8 +346,8 @@ function O(e, t) {
|
|
|
338
346
|
})
|
|
339
347
|
});
|
|
340
348
|
}
|
|
341
|
-
function
|
|
342
|
-
return /* @__PURE__ */
|
|
349
|
+
function A() {
|
|
350
|
+
return /* @__PURE__ */ v(c, {
|
|
343
351
|
viewBox: "0 0 16 16",
|
|
344
352
|
width: "1rem",
|
|
345
353
|
fill: "currentColor",
|
|
@@ -347,15 +355,15 @@ function k() {
|
|
|
347
355
|
3,
|
|
348
356
|
8,
|
|
349
357
|
13
|
|
350
|
-
].map((t) => /* @__PURE__ */
|
|
358
|
+
].map((t) => /* @__PURE__ */ v(s, {
|
|
351
359
|
cx: e,
|
|
352
360
|
cy: t,
|
|
353
361
|
r: 1.4
|
|
354
362
|
}, `${e}-${t}`)))
|
|
355
363
|
});
|
|
356
364
|
}
|
|
357
|
-
function
|
|
358
|
-
let { children: r, variant: i, props: a, ...o } = e, s =
|
|
365
|
+
function j(e, t) {
|
|
366
|
+
let { children: r, variant: i, props: a, ...o } = e, s = p(x), c = p(S), l = c && s ? s.handleProps(c.value, c.name) : {};
|
|
359
367
|
return n({
|
|
360
368
|
tag: "button",
|
|
361
369
|
component: "sortableList.handle",
|
|
@@ -375,10 +383,10 @@ function A(e, t) {
|
|
|
375
383
|
...c?.disabled ? { disabled: !0 } : {},
|
|
376
384
|
...a
|
|
377
385
|
},
|
|
378
|
-
children: r ?? /* @__PURE__ */
|
|
386
|
+
children: r ?? /* @__PURE__ */ v(A, {})
|
|
379
387
|
}, t);
|
|
380
388
|
}
|
|
381
|
-
var
|
|
382
|
-
|
|
389
|
+
var M = e(O, "SortableList");
|
|
390
|
+
M.Item = e(k, "SortableList.Item"), M.Handle = e(j, "SortableList.Handle");
|
|
383
391
|
//#endregion
|
|
384
|
-
export {
|
|
392
|
+
export { b as SortableUtils, M as default };
|
package/components/swipeItem.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../reporting.cjs"),o=require("../motion.cjs"),s=require("./list.cjs");let c=require("react"),l=require("react/jsx-runtime");var u;(function(e){let t=e.SLOP=8,n=e.FLICK=.4,r=e.FULL_RATIO=.6;function i(e,n){return Math.max(Math.abs(e),Math.abs(n))<t?null:Math.abs(e)>Math.abs(n)?`swipe`:`scroll`}e.intent=i;function a(e,t){return(1-1/(e*.55/t+1))*t}function o(e,t,n,r,i){let o=e+t,s=o<0?-1:1,c=o<0?n.end:n.start,l=Math.abs(o);return c===0?0:l<=c?o:i?s*Math.min(l,r):s*(c+a(l-c,Math.max(r,1)))}e.offsetFor=o;function s(e,n,i,a){if(!a||e===0)return null;let o=e>0?`start`:`end`,s=n[o];return s===0?null:Math.abs(e)>=Math.max(s+t*4,i*r)?o:null}e.armed=s;function c(e,t,r,i,a){let o=s(e,r,i,a);if(o)return{open:null,full:o};if(e===0)return{open:null,full:null};let c=e>0?`start`:`end`,l=r[c];return l===0?{open:null,full:null}:Math.abs(t)>=n?{open:Math.sign(t)===Math.sign(e)?c:null,full:null}:{open:Math.abs(e)>=l/2?c:null,full:null}}e.settle=c;let l=e.VELOCITY_WINDOW=100;function u(e,t){return[...e.filter(e=>t.t-e.t<=l),t]}e.track=u;function d(e){let t=e[0],n=e[e.length-1];return!t||!n||n.t-t.t<16?0:(n.x-t.x)/(n.t-t.t)}e.velocity=d;function f(e,t){return e===`start`?t.start:e===`end`?-t.end:0}e.restOffset=f})(u||={});var d=u,f=(0,c.createContext)(null),p={start:0,end:0};function m(e,u){let{size:m=`md`,wrap:h=!1,selected:g=!1,chevron:_=!1,startActions:v,endActions:y,fullSwipe:b=!1,open:ne,defaultOpen:x=null,onOpenChange:S,variant:C,children:w,props:T,...re}=e,E=(0,c.useRef)(null),D=(0,c.useRef)(null),O=(0,c.useRef)(null),k=(0,c.useRef)(null),A=(0,c.useRef)(!1),[j,M]=a.a({value:ne,defaultValue:x,onChange:S,interaction:{component:`swipeItem`,type:`openChange`}}),[N,P]=(0,c.useState)(null),[F,I]=(0,c.useState)(null),[L,ie]=(0,c.useState)({trays:p,width:0,rtl:!1}),R=i.o(L),z=(0,c.useCallback)(e=>{E.current=e,typeof u==`function`?u(e):u&&(u.current=e)},[u]),B=i.a(()=>{let e=e=>e?.firstElementChild?.offsetWidth??0,n={trays:{start:v?e(D.current):0,end:y?e(O.current):0},width:E.current?.offsetWidth??0,rtl:t.p(E.current)},r=R.current;return(r.trays.start!==n.trays.start||r.trays.end!==n.trays.end||r.width!==n.width||r.rtl!==n.rtl)&&ie(n),n});n.n(()=>{j&&B()},[j,B]);let V=i.a(e=>M(null,e)),H=a.i(`swipeItem`);(0,c.useEffect)(()=>{let e=t.t();if(!j||!e)return;let n=e=>{t.f(e,[E])||V({reason:`outside-pointer`,event:e})};return e.addEventListener(`pointerdown`,n,!0),()=>e.removeEventListener(`pointerdown`,n,!0)},[j,V]),(0,c.useEffect)(()=>{if(!F)return;let e=(F===`start`?D:O).current,t=E.current?.firstElementChild,n=t&&typeof getComputedStyle==`function`?o.n.activeDuration(getComputedStyle(t)):0,r=setTimeout(()=>{I(null),e?.querySelector(`[data-swipe-action]`)?.click()},n+o.n.SETTLE_FRAME);return()=>clearTimeout(r)},[F]);let U=i.a(e=>{if(A.current=!1,e.button!==0||F||!v&&!y)return;let{trays:t}=B();k.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,rest:d.restOffset(j,t),intent:null,samples:[{t:e.timeStamp,x:e.clientX}]}}),W=i.a(e=>{let n=k.current;if(!n||n.pointerId!==e.pointerId||n.intent===`scroll`)return;let r=e.clientX-n.x;if(!n.intent){if(n.intent=d.intent(r,e.clientY-n.y),n.intent!==`swipe`)return;e.currentTarget.setPointerCapture?.(e.pointerId),t.l(e.currentTarget)}let{trays:i,width:a,rtl:o}=R.current;n.samples=d.track(n.samples,{t:e.timeStamp,x:e.clientX}),P(d.offsetFor(n.rest,o?-r:r,i,a,b))}),G=i.a(e=>{let t=k.current;if(!t||t.pointerId!==e.pointerId||(k.current=null,t.intent!==`swipe`||N===null))return;e.currentTarget.releasePointerCapture?.(e.pointerId),A.current=!0;let{trays:n,width:r,rtl:i}=R.current,a=d.velocity(t.samples)*(i?-1:1),o=e.type===`pointercancel`?{open:j,full:null}:d.settle(N,a,n,r,b);P(null),o.full?(I(o.full),H(`fullSwipe`,o.full,{reason:`swipe`,event:e}),M(null,{reason:`swipe`,event:e})):M(o.open,{reason:`swipe`,event:e})}),K=i.a(e=>{if(A.current){A.current=!1,e.preventDefault(),e.stopPropagation();return}j&&(e.preventDefault(),e.stopPropagation(),V({reason:`outside-pointer`,event:e}))}),q=i.a(e=>{let t=D.current?.contains(e.target)?`start`:O.current?.contains(e.target)?`end`:null;t&&t!==j&&(B(),M(t,{reason:`focus`,event:e}))}),J=i.a(e=>{let t=e.relatedTarget;j&&(!t||!E.current?.contains(t))&&V({reason:`focus`,event:e})}),ae=i.a(e=>{e.key!==`Escape`||!j||e.defaultPrevented||(e.preventDefault(),V({reason:`escape`,event:e}),E.current?.querySelector(`[data-list-action]`)?.focus())}),{trays:Y,width:X,rtl:oe}=L,Z=N??(F?F===`start`?X:-X:d.restOffset(j,Y)),se=N===null?F:d.armed(N,Y,X,b),Q=N!==null,$=(e,t)=>(0,l.jsx)(te,{side:e,trayRef:e===`start`?D:O,width:e===`start`?Math.max(0,Z):Math.max(0,-Z),dragging:Q,children:(0,l.jsx)(f.Provider,{value:{side:e,armed:se===e,close:V},children:t})});return r.useBoxElement({tag:`li`,component:`list.item`,...s.i({...s.t,css:{...s.t.css,overflow:`clip`}},re),variant:[C,{selected:g}],props:{...T,onFocus:q,onBlur:J,onKeyDown:ae},children:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(ee,{size:m,wrap:h,dragging:Q,translate:Z===0?void 0:`${Math.round(oe?-Z:Z)}px`,handlers:{onPointerDown:U,onPointerMove:W,onPointerUp:G,onPointerCancel:G,onClickCapture:K,onDragStart:e=>e.preventDefault()},children:[w,_&&(0,l.jsx)(s.default.Chevron,{})]}),v?$(`start`,v):null,y?$(`end`,y):null]})},z)}function ee({size:e,wrap:t,dragging:n,translate:i,handlers:a,children:o}){return r.useBoxElement({component:`swipeItem.row`,...s.n,...s.r[e],...t?{flexWrap:`wrap`}:{},position:`relative`,css:{touchAction:`pan-y`},variant:{dragging:n},style:i?{translate:i}:void 0,props:a,children:o})}function te({side:e,trayRef:t,width:n,dragging:i,children:a}){let o=r.useBoxElement({display:`flex`,d:e===`end`?`row-reverse`:`row`,position:`absolute`,top:0,bottom:0,...e===`start`?{insetStart:0}:{insetEnd:0},minWidth:`fit`,css:{width:`max-content`},children:a});return r.useBoxElement({component:`swipeItem.tray`,position:`absolute`,top:0,bottom:0,...e===`start`?{insetStart:0}:{insetEnd:0},overflow:`hidden`,variant:{dragging:i},style:{width:`${Math.round(n)}px`},children:o},t)}function h(e,t){let{icon:n,onClick:i,closeOnSelect:a=!0,variant:o,children:s,props:u,...d}=e,p=(0,c.useContext)(f),m=e=>{i?.(e),a&&!e.defaultPrevented&&p?.close({reason:`action`,event:e})};return r.useBoxElement({tag:`button`,component:`swipeItem.action`,display:`flex`,d:`column`,ai:`center`,jc:`center`,gap:1,px:4,minWidth:18,flexGrow:1,flexShrink:0,fontSize:14,lineHeight:18,fontWeight:500,cursor:`pointer`,...d,variant:[o,{armed:p?.armed??!1}],props:{type:`button`,"data-swipe-action":``,...u,onClick:m},children:n?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(g,{children:n}),s]}):s},t)}function g({children:e}){return r.useBoxElement({tag:`span`,display:`flex`,props:{"aria-hidden":!0},children:e})}var _=e.f(m,`SwipeItem`);_.Action=e.f(h,`SwipeItem.Action`),exports.SwipeUtils=d,exports.default=_;
|