@sia.soul/sia-react-ui 0.1.147 → 0.1.148
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/core.css +5 -0
- package/dist/game.css +5 -0
- package/dist/index.cjs +66 -10
- package/dist/index.css +5 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +66 -10
- package/package.json +1 -1
package/dist/core.css
CHANGED
|
@@ -5576,6 +5576,11 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
5576
5576
|
.sia-sortable-list--vertical {
|
|
5577
5577
|
flex-direction: column;
|
|
5578
5578
|
}
|
|
5579
|
+
.sia-sortable-list--wrap {
|
|
5580
|
+
flex-wrap: wrap;
|
|
5581
|
+
align-items: flex-start;
|
|
5582
|
+
align-content: flex-start;
|
|
5583
|
+
}
|
|
5579
5584
|
.sia-sortable-list__item {
|
|
5580
5585
|
position: relative;
|
|
5581
5586
|
flex-shrink: 0;
|
package/dist/game.css
CHANGED
|
@@ -5627,6 +5627,11 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
5627
5627
|
.sia-sortable-list--vertical {
|
|
5628
5628
|
flex-direction: column;
|
|
5629
5629
|
}
|
|
5630
|
+
.sia-sortable-list--wrap {
|
|
5631
|
+
flex-wrap: wrap;
|
|
5632
|
+
align-items: flex-start;
|
|
5633
|
+
align-content: flex-start;
|
|
5634
|
+
}
|
|
5630
5635
|
.sia-sortable-list__item {
|
|
5631
5636
|
position: relative;
|
|
5632
5637
|
flex-shrink: 0;
|
package/dist/index.cjs
CHANGED
|
@@ -3123,7 +3123,7 @@ function FloatingPanel({ open, title, children, placement = "bottomRight" }) {
|
|
|
3123
3123
|
children
|
|
3124
3124
|
] }), document.body);
|
|
3125
3125
|
}
|
|
3126
|
-
function SortableList({ items, renderItem, onOrderChange, direction = "horizontal", disabled = false, handlePlacement = "before", handleContent }) {
|
|
3126
|
+
function SortableList({ items, renderItem, onOrderChange, direction = "horizontal", wrap = false, disabled = false, handlePlacement = "before", handleContent }) {
|
|
3127
3127
|
const rootRef = (0, import_react12.useRef)(null);
|
|
3128
3128
|
const placeholderRef = (0, import_react12.useRef)(null);
|
|
3129
3129
|
const latest = (0, import_react12.useRef)({ items, onOrderChange });
|
|
@@ -3135,6 +3135,7 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3135
3135
|
const root = rootRef.current;
|
|
3136
3136
|
if (!root) return;
|
|
3137
3137
|
const horizontal = direction === "horizontal";
|
|
3138
|
+
const wrapping = horizontal && wrap;
|
|
3138
3139
|
let session = null;
|
|
3139
3140
|
let frame = 0;
|
|
3140
3141
|
let settling = null;
|
|
@@ -3170,6 +3171,30 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3170
3171
|
return offsets;
|
|
3171
3172
|
};
|
|
3172
3173
|
const transform = (offset) => horizontal ? `translate3d(${offset}px, 0, 0)` : `translate3d(0, ${offset}px, 0)`;
|
|
3174
|
+
const wrappedOffsets = (s) => {
|
|
3175
|
+
const indices = s.keys.map((_, index) => index);
|
|
3176
|
+
indices.splice(s.from, 1);
|
|
3177
|
+
indices.splice(s.to, 0, s.from);
|
|
3178
|
+
const style = getComputedStyle(root);
|
|
3179
|
+
const gapX = parseFloat(style.columnGap) || 0, gapY = parseFloat(style.rowGap) || 0;
|
|
3180
|
+
const width = root.clientWidth - (parseFloat(style.paddingLeft) || 0) - (parseFloat(style.paddingRight) || 0);
|
|
3181
|
+
const first = s.rects[0];
|
|
3182
|
+
let x = 0, y = 0, height = 0;
|
|
3183
|
+
const offsets = s.rects.map(() => ({ x: 0, y: 0 }));
|
|
3184
|
+
indices.forEach((index) => {
|
|
3185
|
+
const rect = s.rects[index];
|
|
3186
|
+
if (x > 0 && x + rect.width > width + 0.5) {
|
|
3187
|
+
x = 0;
|
|
3188
|
+
y += height + gapY;
|
|
3189
|
+
height = 0;
|
|
3190
|
+
}
|
|
3191
|
+
offsets[index] = { x: first.left + x - rect.left, y: first.top + y - rect.top };
|
|
3192
|
+
x += rect.width + gapX;
|
|
3193
|
+
height = Math.max(height, rect.height);
|
|
3194
|
+
});
|
|
3195
|
+
return offsets;
|
|
3196
|
+
};
|
|
3197
|
+
const vectorTransform = (point) => `translate3d(${point.x}px, ${point.y}px, 0)`;
|
|
3173
3198
|
const paint = () => {
|
|
3174
3199
|
const s = session;
|
|
3175
3200
|
if (!s || !s.active || settling) return;
|
|
@@ -3177,6 +3202,32 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3177
3202
|
const coordinate = horizontal ? s.clientX : s.clientY;
|
|
3178
3203
|
const scroll = horizontal ? root.scrollLeft : root.scrollTop;
|
|
3179
3204
|
const origin = s.rects[s.from];
|
|
3205
|
+
if (wrapping) {
|
|
3206
|
+
const dx = Math.max(Math.min(...s.rects.map((r) => r.left)) - origin.left, Math.min(Math.max(...s.rects.map((r) => r.right)) - origin.right, s.clientX - s.startX + root.scrollLeft - s.scrollX));
|
|
3207
|
+
const dy = Math.max(Math.min(...s.rects.map((r) => r.top)) - origin.top, Math.min(Math.max(...s.rects.map((r) => r.bottom)) - origin.bottom, s.clientY - s.startY + root.scrollTop - s.scrollY));
|
|
3208
|
+
const cx = origin.left + origin.width / 2 + dx, cy = origin.top + origin.height / 2 + dy;
|
|
3209
|
+
let distance3 = Infinity;
|
|
3210
|
+
s.rects.forEach((rect, index) => {
|
|
3211
|
+
const next = Math.pow(cx - rect.left - rect.width / 2, 2) + Math.pow(cy - rect.top - rect.height / 2, 2);
|
|
3212
|
+
if (next < distance3) {
|
|
3213
|
+
distance3 = next;
|
|
3214
|
+
s.to = index;
|
|
3215
|
+
}
|
|
3216
|
+
});
|
|
3217
|
+
const offsets2 = wrappedOffsets(s);
|
|
3218
|
+
s.nodes.forEach((node, index) => {
|
|
3219
|
+
node.style.transform = vectorTransform(index === s.from ? { x: dx, y: dy } : offsets2[index]);
|
|
3220
|
+
});
|
|
3221
|
+
const preview2 = placeholderRef.current;
|
|
3222
|
+
if (preview2) {
|
|
3223
|
+
preview2.hidden = false;
|
|
3224
|
+
preview2.style.width = `${origin.width}px`;
|
|
3225
|
+
preview2.style.height = `${origin.height}px`;
|
|
3226
|
+
preview2.style.left = `${origin.left - bounds.left + s.scrollX + offsets2[s.from].x}px`;
|
|
3227
|
+
preview2.style.top = `${origin.top - bounds.top + s.scrollY + offsets2[s.from].y}px`;
|
|
3228
|
+
}
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
3180
3231
|
const first = s.rects[0];
|
|
3181
3232
|
const last = s.rects[s.rects.length - 1];
|
|
3182
3233
|
const minimum = horizontal ? first.left - origin.left : first.top - origin.top;
|
|
@@ -3202,15 +3253,16 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3202
3253
|
const s = session;
|
|
3203
3254
|
if (!s || !s.active || settling) return;
|
|
3204
3255
|
const bounds = root.getBoundingClientRect();
|
|
3205
|
-
const
|
|
3206
|
-
const
|
|
3207
|
-
const
|
|
3208
|
-
const
|
|
3256
|
+
const scrollHorizontal = horizontal && !wrapping;
|
|
3257
|
+
const point = scrollHorizontal ? s.clientX : s.clientY;
|
|
3258
|
+
const start = scrollHorizontal ? bounds.left : bounds.top;
|
|
3259
|
+
const end = scrollHorizontal ? bounds.right : bounds.bottom;
|
|
3260
|
+
const crossInside = scrollHorizontal ? s.clientY >= bounds.top && s.clientY <= bounds.bottom : s.clientX >= bounds.left && s.clientX <= bounds.right;
|
|
3209
3261
|
const edge = 44;
|
|
3210
3262
|
const speed = !crossInside || point < start || point > end ? 0 : point < start + edge ? -Math.min(1, (start + edge - point) / edge) : point > end - edge ? Math.min(1, (point - end + edge) / edge) : 0;
|
|
3211
3263
|
const distance3 = speed * Math.min(32, time - (lastTime || time)) * 0.65;
|
|
3212
3264
|
lastTime = time;
|
|
3213
|
-
if (
|
|
3265
|
+
if (scrollHorizontal) root.scrollLeft += distance3;
|
|
3214
3266
|
else root.scrollTop += distance3;
|
|
3215
3267
|
paint();
|
|
3216
3268
|
frame = requestAnimationFrame(tick);
|
|
@@ -3233,6 +3285,10 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3233
3285
|
start: horizontal ? event.clientX : event.clientY,
|
|
3234
3286
|
clientX: event.clientX,
|
|
3235
3287
|
clientY: event.clientY,
|
|
3288
|
+
startX: event.clientX,
|
|
3289
|
+
startY: event.clientY,
|
|
3290
|
+
scrollX: root.scrollLeft,
|
|
3291
|
+
scrollY: root.scrollTop,
|
|
3236
3292
|
scroll: horizontal ? root.scrollLeft : root.scrollTop,
|
|
3237
3293
|
active: false
|
|
3238
3294
|
};
|
|
@@ -3243,7 +3299,7 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3243
3299
|
if (!s || settling || event.pointerId !== s.pointer) return;
|
|
3244
3300
|
s.clientX = event.clientX;
|
|
3245
3301
|
s.clientY = event.clientY;
|
|
3246
|
-
if (!s.active && Math.abs((horizontal ? event.clientX : event.clientY) - s.start) >= 4) {
|
|
3302
|
+
if (!s.active && (wrapping ? Math.hypot(event.clientX - s.startX, event.clientY - s.startY) : Math.abs((horizontal ? event.clientX : event.clientY) - s.start)) >= 4) {
|
|
3247
3303
|
s.active = true;
|
|
3248
3304
|
root.classList.add("is-sorting");
|
|
3249
3305
|
s.nodes[s.from].classList.add("is-dragging");
|
|
@@ -3284,7 +3340,7 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3284
3340
|
return;
|
|
3285
3341
|
}
|
|
3286
3342
|
const node = s.nodes[s.from];
|
|
3287
|
-
settling = node.animate([{ transform: node.style.transform }, { transform: transform(displacement(s)[s.from]) }], { duration: 160, easing: "cubic-bezier(.2,.8,.2,1)", fill: "forwards" });
|
|
3343
|
+
settling = node.animate([{ transform: node.style.transform }, { transform: wrapping ? vectorTransform(wrappedOffsets(s)[s.from]) : transform(displacement(s)[s.from]) }], { duration: 160, easing: "cubic-bezier(.2,.8,.2,1)", fill: "forwards" });
|
|
3288
3344
|
settling.finished.then(finish, () => {
|
|
3289
3345
|
});
|
|
3290
3346
|
};
|
|
@@ -3325,8 +3381,8 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
3325
3381
|
root.removeEventListener("lostpointercapture", cancelPointer);
|
|
3326
3382
|
root.removeEventListener("click", cancelClick, true);
|
|
3327
3383
|
};
|
|
3328
|
-
}, [disabled, direction, signature]);
|
|
3329
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: rootRef, className: `sia-sortable-list sia-sortable-list--${direction}`, role: "list", children: [
|
|
3384
|
+
}, [disabled, direction, wrap, signature]);
|
|
3385
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { ref: rootRef, className: `sia-sortable-list sia-sortable-list--${direction}${wrap && direction === "horizontal" ? " sia-sortable-list--wrap" : ""}`, role: "list", children: [
|
|
3330
3386
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: placeholderRef, className: "sia-sortable-list__placeholder", "aria-hidden": "true", hidden: true }),
|
|
3331
3387
|
items.map((key, index) => {
|
|
3332
3388
|
const handle = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
package/dist/index.css
CHANGED
|
@@ -5576,6 +5576,11 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
5576
5576
|
.sia-sortable-list--vertical {
|
|
5577
5577
|
flex-direction: column;
|
|
5578
5578
|
}
|
|
5579
|
+
.sia-sortable-list--wrap {
|
|
5580
|
+
flex-wrap: wrap;
|
|
5581
|
+
align-items: flex-start;
|
|
5582
|
+
align-content: flex-start;
|
|
5583
|
+
}
|
|
5579
5584
|
.sia-sortable-list__item {
|
|
5580
5585
|
position: relative;
|
|
5581
5586
|
flex-shrink: 0;
|
package/dist/index.d.cts
CHANGED
|
@@ -92,11 +92,13 @@ interface SortableListProps {
|
|
|
92
92
|
onOrderChange: (items: SortableKey[]) => void;
|
|
93
93
|
/** 排列及拖动轴;按轴移动至少 4px 开始预览,相邻项以 180ms 让位,靠近列表滚动边缘自动滚动。仅由手柄发起,不影响内部输入;减少动态效果时相邻项直接定位。@defaultValue "horizontal" */
|
|
94
94
|
direction?: "horizontal" | "vertical";
|
|
95
|
+
/** 横向列表按容器宽度自动换行,拖动时同时预览横纵位置;方向键左右移动一项。vertical 时忽略。@defaultValue false */
|
|
96
|
+
wrap?: boolean;
|
|
95
97
|
/** 禁止拖放和键盘排序,不禁用条目内部业务控件。@defaultValue false */
|
|
96
98
|
disabled?: boolean;
|
|
97
99
|
}
|
|
98
100
|
/** 拖放与键盘共用受控顺序;指针预览不重挂载内容,也不改变 renderItem 的业务索引。 */
|
|
99
|
-
declare function SortableList({ items, renderItem, onOrderChange, direction, disabled, handlePlacement, handleContent }: SortableListProps): react.JSX.Element;
|
|
101
|
+
declare function SortableList({ items, renderItem, onOrderChange, direction, wrap, disabled, handlePlacement, handleContent }: SortableListProps): react.JSX.Element;
|
|
100
102
|
|
|
101
103
|
/** 警告提示的状态类型。 */
|
|
102
104
|
type AlertStatus = "info" | "success" | "warning" | "error";
|
package/dist/index.d.ts
CHANGED
|
@@ -92,11 +92,13 @@ interface SortableListProps {
|
|
|
92
92
|
onOrderChange: (items: SortableKey[]) => void;
|
|
93
93
|
/** 排列及拖动轴;按轴移动至少 4px 开始预览,相邻项以 180ms 让位,靠近列表滚动边缘自动滚动。仅由手柄发起,不影响内部输入;减少动态效果时相邻项直接定位。@defaultValue "horizontal" */
|
|
94
94
|
direction?: "horizontal" | "vertical";
|
|
95
|
+
/** 横向列表按容器宽度自动换行,拖动时同时预览横纵位置;方向键左右移动一项。vertical 时忽略。@defaultValue false */
|
|
96
|
+
wrap?: boolean;
|
|
95
97
|
/** 禁止拖放和键盘排序,不禁用条目内部业务控件。@defaultValue false */
|
|
96
98
|
disabled?: boolean;
|
|
97
99
|
}
|
|
98
100
|
/** 拖放与键盘共用受控顺序;指针预览不重挂载内容,也不改变 renderItem 的业务索引。 */
|
|
99
|
-
declare function SortableList({ items, renderItem, onOrderChange, direction, disabled, handlePlacement, handleContent }: SortableListProps): react.JSX.Element;
|
|
101
|
+
declare function SortableList({ items, renderItem, onOrderChange, direction, wrap, disabled, handlePlacement, handleContent }: SortableListProps): react.JSX.Element;
|
|
100
102
|
|
|
101
103
|
/** 警告提示的状态类型。 */
|
|
102
104
|
type AlertStatus = "info" | "success" | "warning" | "error";
|
package/dist/index.js
CHANGED
|
@@ -309,7 +309,7 @@ function FloatingPanel({ open, title, children, placement = "bottomRight" }) {
|
|
|
309
309
|
children
|
|
310
310
|
] }), document.body);
|
|
311
311
|
}
|
|
312
|
-
function SortableList({ items, renderItem, onOrderChange, direction = "horizontal", disabled = false, handlePlacement = "before", handleContent }) {
|
|
312
|
+
function SortableList({ items, renderItem, onOrderChange, direction = "horizontal", wrap = false, disabled = false, handlePlacement = "before", handleContent }) {
|
|
313
313
|
const rootRef = useRef2(null);
|
|
314
314
|
const placeholderRef = useRef2(null);
|
|
315
315
|
const latest = useRef2({ items, onOrderChange });
|
|
@@ -321,6 +321,7 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
321
321
|
const root = rootRef.current;
|
|
322
322
|
if (!root) return;
|
|
323
323
|
const horizontal = direction === "horizontal";
|
|
324
|
+
const wrapping = horizontal && wrap;
|
|
324
325
|
let session = null;
|
|
325
326
|
let frame = 0;
|
|
326
327
|
let settling = null;
|
|
@@ -356,6 +357,30 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
356
357
|
return offsets;
|
|
357
358
|
};
|
|
358
359
|
const transform = (offset) => horizontal ? `translate3d(${offset}px, 0, 0)` : `translate3d(0, ${offset}px, 0)`;
|
|
360
|
+
const wrappedOffsets = (s) => {
|
|
361
|
+
const indices = s.keys.map((_, index) => index);
|
|
362
|
+
indices.splice(s.from, 1);
|
|
363
|
+
indices.splice(s.to, 0, s.from);
|
|
364
|
+
const style = getComputedStyle(root);
|
|
365
|
+
const gapX = parseFloat(style.columnGap) || 0, gapY = parseFloat(style.rowGap) || 0;
|
|
366
|
+
const width = root.clientWidth - (parseFloat(style.paddingLeft) || 0) - (parseFloat(style.paddingRight) || 0);
|
|
367
|
+
const first = s.rects[0];
|
|
368
|
+
let x = 0, y = 0, height = 0;
|
|
369
|
+
const offsets = s.rects.map(() => ({ x: 0, y: 0 }));
|
|
370
|
+
indices.forEach((index) => {
|
|
371
|
+
const rect = s.rects[index];
|
|
372
|
+
if (x > 0 && x + rect.width > width + 0.5) {
|
|
373
|
+
x = 0;
|
|
374
|
+
y += height + gapY;
|
|
375
|
+
height = 0;
|
|
376
|
+
}
|
|
377
|
+
offsets[index] = { x: first.left + x - rect.left, y: first.top + y - rect.top };
|
|
378
|
+
x += rect.width + gapX;
|
|
379
|
+
height = Math.max(height, rect.height);
|
|
380
|
+
});
|
|
381
|
+
return offsets;
|
|
382
|
+
};
|
|
383
|
+
const vectorTransform = (point) => `translate3d(${point.x}px, ${point.y}px, 0)`;
|
|
359
384
|
const paint = () => {
|
|
360
385
|
const s = session;
|
|
361
386
|
if (!s || !s.active || settling) return;
|
|
@@ -363,6 +388,32 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
363
388
|
const coordinate = horizontal ? s.clientX : s.clientY;
|
|
364
389
|
const scroll = horizontal ? root.scrollLeft : root.scrollTop;
|
|
365
390
|
const origin = s.rects[s.from];
|
|
391
|
+
if (wrapping) {
|
|
392
|
+
const dx = Math.max(Math.min(...s.rects.map((r) => r.left)) - origin.left, Math.min(Math.max(...s.rects.map((r) => r.right)) - origin.right, s.clientX - s.startX + root.scrollLeft - s.scrollX));
|
|
393
|
+
const dy = Math.max(Math.min(...s.rects.map((r) => r.top)) - origin.top, Math.min(Math.max(...s.rects.map((r) => r.bottom)) - origin.bottom, s.clientY - s.startY + root.scrollTop - s.scrollY));
|
|
394
|
+
const cx = origin.left + origin.width / 2 + dx, cy = origin.top + origin.height / 2 + dy;
|
|
395
|
+
let distance = Infinity;
|
|
396
|
+
s.rects.forEach((rect, index) => {
|
|
397
|
+
const next = Math.pow(cx - rect.left - rect.width / 2, 2) + Math.pow(cy - rect.top - rect.height / 2, 2);
|
|
398
|
+
if (next < distance) {
|
|
399
|
+
distance = next;
|
|
400
|
+
s.to = index;
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
const offsets2 = wrappedOffsets(s);
|
|
404
|
+
s.nodes.forEach((node, index) => {
|
|
405
|
+
node.style.transform = vectorTransform(index === s.from ? { x: dx, y: dy } : offsets2[index]);
|
|
406
|
+
});
|
|
407
|
+
const preview2 = placeholderRef.current;
|
|
408
|
+
if (preview2) {
|
|
409
|
+
preview2.hidden = false;
|
|
410
|
+
preview2.style.width = `${origin.width}px`;
|
|
411
|
+
preview2.style.height = `${origin.height}px`;
|
|
412
|
+
preview2.style.left = `${origin.left - bounds.left + s.scrollX + offsets2[s.from].x}px`;
|
|
413
|
+
preview2.style.top = `${origin.top - bounds.top + s.scrollY + offsets2[s.from].y}px`;
|
|
414
|
+
}
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
366
417
|
const first = s.rects[0];
|
|
367
418
|
const last = s.rects[s.rects.length - 1];
|
|
368
419
|
const minimum = horizontal ? first.left - origin.left : first.top - origin.top;
|
|
@@ -388,15 +439,16 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
388
439
|
const s = session;
|
|
389
440
|
if (!s || !s.active || settling) return;
|
|
390
441
|
const bounds = root.getBoundingClientRect();
|
|
391
|
-
const
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
const
|
|
442
|
+
const scrollHorizontal = horizontal && !wrapping;
|
|
443
|
+
const point = scrollHorizontal ? s.clientX : s.clientY;
|
|
444
|
+
const start = scrollHorizontal ? bounds.left : bounds.top;
|
|
445
|
+
const end = scrollHorizontal ? bounds.right : bounds.bottom;
|
|
446
|
+
const crossInside = scrollHorizontal ? s.clientY >= bounds.top && s.clientY <= bounds.bottom : s.clientX >= bounds.left && s.clientX <= bounds.right;
|
|
395
447
|
const edge = 44;
|
|
396
448
|
const speed = !crossInside || point < start || point > end ? 0 : point < start + edge ? -Math.min(1, (start + edge - point) / edge) : point > end - edge ? Math.min(1, (point - end + edge) / edge) : 0;
|
|
397
449
|
const distance = speed * Math.min(32, time - (lastTime || time)) * 0.65;
|
|
398
450
|
lastTime = time;
|
|
399
|
-
if (
|
|
451
|
+
if (scrollHorizontal) root.scrollLeft += distance;
|
|
400
452
|
else root.scrollTop += distance;
|
|
401
453
|
paint();
|
|
402
454
|
frame = requestAnimationFrame(tick);
|
|
@@ -419,6 +471,10 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
419
471
|
start: horizontal ? event.clientX : event.clientY,
|
|
420
472
|
clientX: event.clientX,
|
|
421
473
|
clientY: event.clientY,
|
|
474
|
+
startX: event.clientX,
|
|
475
|
+
startY: event.clientY,
|
|
476
|
+
scrollX: root.scrollLeft,
|
|
477
|
+
scrollY: root.scrollTop,
|
|
422
478
|
scroll: horizontal ? root.scrollLeft : root.scrollTop,
|
|
423
479
|
active: false
|
|
424
480
|
};
|
|
@@ -429,7 +485,7 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
429
485
|
if (!s || settling || event.pointerId !== s.pointer) return;
|
|
430
486
|
s.clientX = event.clientX;
|
|
431
487
|
s.clientY = event.clientY;
|
|
432
|
-
if (!s.active && Math.abs((horizontal ? event.clientX : event.clientY) - s.start) >= 4) {
|
|
488
|
+
if (!s.active && (wrapping ? Math.hypot(event.clientX - s.startX, event.clientY - s.startY) : Math.abs((horizontal ? event.clientX : event.clientY) - s.start)) >= 4) {
|
|
433
489
|
s.active = true;
|
|
434
490
|
root.classList.add("is-sorting");
|
|
435
491
|
s.nodes[s.from].classList.add("is-dragging");
|
|
@@ -470,7 +526,7 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
470
526
|
return;
|
|
471
527
|
}
|
|
472
528
|
const node = s.nodes[s.from];
|
|
473
|
-
settling = node.animate([{ transform: node.style.transform }, { transform: transform(displacement(s)[s.from]) }], { duration: 160, easing: "cubic-bezier(.2,.8,.2,1)", fill: "forwards" });
|
|
529
|
+
settling = node.animate([{ transform: node.style.transform }, { transform: wrapping ? vectorTransform(wrappedOffsets(s)[s.from]) : transform(displacement(s)[s.from]) }], { duration: 160, easing: "cubic-bezier(.2,.8,.2,1)", fill: "forwards" });
|
|
474
530
|
settling.finished.then(finish, () => {
|
|
475
531
|
});
|
|
476
532
|
};
|
|
@@ -511,8 +567,8 @@ function SortableList({ items, renderItem, onOrderChange, direction = "horizonta
|
|
|
511
567
|
root.removeEventListener("lostpointercapture", cancelPointer);
|
|
512
568
|
root.removeEventListener("click", cancelClick, true);
|
|
513
569
|
};
|
|
514
|
-
}, [disabled, direction, signature]);
|
|
515
|
-
return /* @__PURE__ */ jsxs2("div", { ref: rootRef, className: `sia-sortable-list sia-sortable-list--${direction}`, role: "list", children: [
|
|
570
|
+
}, [disabled, direction, wrap, signature]);
|
|
571
|
+
return /* @__PURE__ */ jsxs2("div", { ref: rootRef, className: `sia-sortable-list sia-sortable-list--${direction}${wrap && direction === "horizontal" ? " sia-sortable-list--wrap" : ""}`, role: "list", children: [
|
|
516
572
|
/* @__PURE__ */ jsx2("div", { ref: placeholderRef, className: "sia-sortable-list__placeholder", "aria-hidden": "true", hidden: true }),
|
|
517
573
|
items.map((key, index) => {
|
|
518
574
|
const handle = /* @__PURE__ */ jsx2(
|