@pallasoft/ps-core-components 2.44.2 → 2.45.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/ps-drag-overlay.js +4 -4
- package/dist/components/ps-draggable-grid.js +3 -1
- package/dist/components/ps-sortable-list.js +5 -5
- package/dist/constants/ps-drag-config.d.ts +3 -0
- package/dist/constants/ps-drag-config.js +10 -4
- package/dist/constants/ps-draggable-grid.d.ts +2 -0
- package/dist/esm/components/ps-drag-overlay.js +5 -5
- package/dist/esm/components/ps-draggable-grid.js +3 -1
- package/dist/esm/components/ps-sortable-list.js +6 -6
- package/dist/esm/constants/ps-drag-config.js +9 -3
- package/dist/esm/hooks/use-ps-drag-sensors.js +2 -2
- package/dist/esm/hooks/use-ps-drag-transition.js +10 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/models/ps-drag-transition.js +1 -0
- package/dist/hooks/use-ps-drag-sensors.d.ts +2 -2
- package/dist/hooks/use-ps-drag-sensors.js +2 -2
- package/dist/hooks/use-ps-drag-transition.d.ts +2 -0
- package/dist/hooks/use-ps-drag-transition.js +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/models/ps-drag-transition.d.ts +4 -0
- package/dist/models/ps-drag-transition.js +2 -0
- package/package.json +1 -1
|
@@ -21,9 +21,7 @@ const PsDragOverlay = ({ children, className, frames, isDropAnimated, }) => {
|
|
|
21
21
|
const isReduced = (0, use_ps_reduced_motion_1.usePsReducedMotion)();
|
|
22
22
|
const zIndex = (0, use_ps_layer_z_index_1.usePsLayerZIndex)(ps_design_system_1.PallasoftZIndex.Popover);
|
|
23
23
|
(0, react_1.useEffect)(() => setIsMounted(true), []);
|
|
24
|
-
|
|
25
|
-
return null;
|
|
26
|
-
const lift = (element) => {
|
|
24
|
+
const lift = (0, react_1.useCallback)((element) => {
|
|
27
25
|
if (element === null || isReduced || typeof element.animate !== 'function')
|
|
28
26
|
return;
|
|
29
27
|
element.animate(frames, {
|
|
@@ -31,7 +29,9 @@ const PsDragOverlay = ({ children, className, frames, isDropAnimated, }) => {
|
|
|
31
29
|
easing: ps_drag_config_1.PsDragConfig.liftEasing,
|
|
32
30
|
fill: 'forwards',
|
|
33
31
|
});
|
|
34
|
-
};
|
|
32
|
+
}, [frames, isReduced]);
|
|
33
|
+
if (!isMounted)
|
|
34
|
+
return null;
|
|
35
35
|
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(core_1.DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, zIndex: zIndex, children: children === null ? null : ((0, jsx_runtime_1.jsx)("div", { className: className, ref: lift, children: children })) }), document.body);
|
|
36
36
|
};
|
|
37
37
|
exports.PsDragOverlay = PsDragOverlay;
|
|
@@ -9,11 +9,13 @@ const utilities_1 = require("@dnd-kit/utilities");
|
|
|
9
9
|
const ps_drag_config_1 = require("../constants/ps-drag-config");
|
|
10
10
|
const ps_draggable_grid_1 = require("../constants/ps-draggable-grid");
|
|
11
11
|
const use_ps_drag_sensors_1 = require("../hooks/use-ps-drag-sensors");
|
|
12
|
+
const use_ps_drag_transition_1 = require("../hooks/use-ps-drag-transition");
|
|
12
13
|
const ps_drag_grip_1 = require("./ps-drag-grip");
|
|
13
14
|
const ps_drag_overlay_1 = require("./ps-drag-overlay");
|
|
14
15
|
const PsDraggableGridHandle = ({ attributes, label, listeners, setActivatorNodeRef, }) => ((0, jsx_runtime_1.jsx)("button", { ...attributes, ...listeners, "aria-label": `Move ${label}`, className: ps_draggable_grid_1.PsDraggableGridClasses.handle, ref: setActivatorNodeRef, title: `Move ${label}`, type: 'button', children: (0, jsx_runtime_1.jsx)(ps_drag_grip_1.PsDragGrip, {}) }));
|
|
15
16
|
const PsSortableGridItem = ({ className, index, item, renderItem, }) => {
|
|
16
|
-
const
|
|
17
|
+
const dragTransition = (0, use_ps_drag_transition_1.usePsDragTransition)();
|
|
18
|
+
const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef, transform, transition, } = (0, sortable_1.useSortable)({ id: item.id, transition: dragTransition });
|
|
17
19
|
const rendered = renderItem({
|
|
18
20
|
handle: ((0, jsx_runtime_1.jsx)(PsDraggableGridHandle, { attributes: attributes, label: item.label, listeners: listeners, setActivatorNodeRef: setActivatorNodeRef })),
|
|
19
21
|
index,
|
|
@@ -8,13 +8,13 @@ const sortable_1 = require("@dnd-kit/sortable");
|
|
|
8
8
|
const utilities_1 = require("@dnd-kit/utilities");
|
|
9
9
|
const ps_drag_config_1 = require("../constants/ps-drag-config");
|
|
10
10
|
const use_ps_drag_sensors_1 = require("../hooks/use-ps-drag-sensors");
|
|
11
|
-
const
|
|
11
|
+
const use_ps_drag_transition_1 = require("../hooks/use-ps-drag-transition");
|
|
12
12
|
const ps_drag_grip_1 = require("./ps-drag-grip");
|
|
13
13
|
const ps_drag_overlay_1 = require("./ps-drag-overlay");
|
|
14
14
|
const PsSortableListHandle = ({ attributes, className, icon, label, listeners, setActivatorNodeRef, }) => ((0, jsx_runtime_1.jsx)("button", { ...attributes, ...listeners, "aria-label": label, className: className === undefined ? ps_drag_config_1.PsDragClasses.handle : className, ref: setActivatorNodeRef, title: label, type: 'button', children: icon === undefined ? (0, jsx_runtime_1.jsx)(ps_drag_grip_1.PsDragGrip, {}) : icon }));
|
|
15
15
|
const PsSortableListRow = ({ className, handleClassName, handleIcon, getHandleLabel, index, isDisabled, item, renderItem, }) => {
|
|
16
|
-
const
|
|
17
|
-
const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef, transform, transition, } = (0, sortable_1.useSortable)({ disabled: isDisabled, id: item.id });
|
|
16
|
+
const dragTransition = (0, use_ps_drag_transition_1.usePsDragTransition)();
|
|
17
|
+
const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef, transform, transition, } = (0, sortable_1.useSortable)({ disabled: isDisabled, id: item.id, transition: dragTransition });
|
|
18
18
|
const rendered = renderItem({
|
|
19
19
|
handle: ((0, jsx_runtime_1.jsx)(PsSortableListHandle, { attributes: attributes, className: handleClassName, icon: handleIcon, label: getHandleLabel(item.label), listeners: listeners, setActivatorNodeRef: setActivatorNodeRef })),
|
|
20
20
|
index,
|
|
@@ -27,7 +27,7 @@ const PsSortableListRow = ({ className, handleClassName, handleIcon, getHandleLa
|
|
|
27
27
|
return ((0, jsx_runtime_1.jsx)("div", { className: `${ps_drag_config_1.PsDragClasses.listItem} ${className} ${isDragging ? ps_drag_config_1.PsDragClasses.placeholder : ''}`, ref: setNodeRef, style: {
|
|
28
28
|
opacity: isDragging ? ps_drag_config_1.PsDragConfig.placeholderOpacity : undefined,
|
|
29
29
|
transform: utilities_1.CSS.Translate.toString(transform),
|
|
30
|
-
transition
|
|
30
|
+
transition,
|
|
31
31
|
}, children: rendered }));
|
|
32
32
|
};
|
|
33
33
|
const PsSortableList = ({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, isHorizontal = false, role, items, onMove, renderItem, }) => {
|
|
@@ -66,7 +66,7 @@ const PsSortableList = ({ announcements: texts, className, getHandleLabel, getIt
|
|
|
66
66
|
onMove(String(active.id), from, to);
|
|
67
67
|
};
|
|
68
68
|
const activeGroup = activeItem === null ? undefined : activeItem.groupKey;
|
|
69
|
-
return ((0, jsx_runtime_1.jsxs)(core_1.DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: core_1.closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [(0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: items.map((item) => item.id), strategy: isHorizontal ? sortable_1.horizontalListSortingStrategy : sortable_1.verticalListSortingStrategy, children: (0, jsx_runtime_1.jsx)("div", { className: className, role: role, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), (0, jsx_runtime_1.jsx)(ps_drag_overlay_1.PsDragOverlay, { className: ps_drag_config_1.PsDragClasses.lifted, frames: ps_drag_config_1.
|
|
69
|
+
return ((0, jsx_runtime_1.jsxs)(core_1.DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: core_1.closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [(0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: items.map((item) => item.id), strategy: isHorizontal ? sortable_1.horizontalListSortingStrategy : sortable_1.verticalListSortingStrategy, children: (0, jsx_runtime_1.jsx)("div", { className: className, role: role, children: items.map((item, index) => ((0, jsx_runtime_1.jsx)(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), (0, jsx_runtime_1.jsx)(ps_drag_overlay_1.PsDragOverlay, { className: ps_drag_config_1.PsDragClasses.lifted, frames: ps_drag_config_1.PsDragRowLiftFrames, children: activeItem !== null
|
|
70
70
|
? renderItem({
|
|
71
71
|
handle: ((0, jsx_runtime_1.jsx)(PsSortableListHandle, { className: handleClassName, icon: handleIcon, label: getHandleLabel(activeItem.label) })),
|
|
72
72
|
index: activeIndex,
|
|
@@ -5,6 +5,8 @@ export declare const PsDragConfig: {
|
|
|
5
5
|
readonly liftDuration: 200;
|
|
6
6
|
readonly liftEasing: "cubic-bezier(0.2, 0.9, 0.3, 1.2)";
|
|
7
7
|
readonly placeholderOpacity: "0.4";
|
|
8
|
+
readonly sortDuration: 250;
|
|
9
|
+
readonly sortEasing: "ease";
|
|
8
10
|
readonly touchDelay: 180;
|
|
9
11
|
readonly touchTolerance: 6;
|
|
10
12
|
};
|
|
@@ -15,4 +17,5 @@ export declare const PsDragClasses: {
|
|
|
15
17
|
readonly placeholder: "outline-dashed outline-2 outline-offset-[-2px] outline-primary/35";
|
|
16
18
|
};
|
|
17
19
|
export declare const PsDragLiftFrames: Keyframe[];
|
|
20
|
+
export declare const PsDragRowLiftFrames: Keyframe[];
|
|
18
21
|
export declare const PsDragListLiftFrames: Keyframe[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PsDragListLiftFrames = exports.PsDragLiftFrames = exports.PsDragClasses = exports.PsDragConfig = void 0;
|
|
3
|
+
exports.PsDragListLiftFrames = exports.PsDragRowLiftFrames = exports.PsDragLiftFrames = exports.PsDragClasses = exports.PsDragConfig = void 0;
|
|
4
4
|
exports.PsDragConfig = {
|
|
5
5
|
activationDistance: 6,
|
|
6
6
|
dropDuration: 220,
|
|
@@ -8,6 +8,8 @@ exports.PsDragConfig = {
|
|
|
8
8
|
liftDuration: 200,
|
|
9
9
|
liftEasing: 'cubic-bezier(0.2, 0.9, 0.3, 1.2)',
|
|
10
10
|
placeholderOpacity: '0.4',
|
|
11
|
+
sortDuration: 250,
|
|
12
|
+
sortEasing: 'ease',
|
|
11
13
|
touchDelay: 180,
|
|
12
14
|
touchTolerance: 6,
|
|
13
15
|
};
|
|
@@ -24,7 +26,11 @@ exports.PsDragLiftFrames = [
|
|
|
24
26
|
transform: 'scale(1.035) rotate(-1.2deg)',
|
|
25
27
|
},
|
|
26
28
|
];
|
|
27
|
-
exports.
|
|
28
|
-
{ boxShadow: '0 0 0 0 rgb(15 23 42 / 0)', transform: 'scale(1)' },
|
|
29
|
-
{
|
|
29
|
+
exports.PsDragRowLiftFrames = [
|
|
30
|
+
{ boxShadow: '0 0 0 0 rgb(15 23 42 / 0)', transform: 'scale(1) rotate(0deg)' },
|
|
31
|
+
{
|
|
32
|
+
boxShadow: '0 28px 64px -18px rgb(15 23 42 / 0.5)',
|
|
33
|
+
transform: 'scale(1.035) rotate(-0.25deg)',
|
|
34
|
+
},
|
|
30
35
|
];
|
|
36
|
+
exports.PsDragListLiftFrames = exports.PsDragRowLiftFrames;
|
|
@@ -5,6 +5,8 @@ export declare const PsDraggableGridConfig: {
|
|
|
5
5
|
readonly liftDuration: 200;
|
|
6
6
|
readonly liftEasing: "cubic-bezier(0.2, 0.9, 0.3, 1.2)";
|
|
7
7
|
readonly placeholderOpacity: "0.4";
|
|
8
|
+
readonly sortDuration: 250;
|
|
9
|
+
readonly sortEasing: "ease";
|
|
8
10
|
readonly touchDelay: 180;
|
|
9
11
|
readonly touchTolerance: 6;
|
|
10
12
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { DragOverlay, defaultDropAnimationSideEffects } from '@dnd-kit/core';
|
|
4
4
|
import { PallasoftZIndex } from '@pallasoft/ps-design-system';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
@@ -18,9 +18,7 @@ export const PsDragOverlay = ({ children, className, frames, isDropAnimated, })
|
|
|
18
18
|
const isReduced = usePsReducedMotion();
|
|
19
19
|
const zIndex = usePsLayerZIndex(PallasoftZIndex.Popover);
|
|
20
20
|
useEffect(() => setIsMounted(true), []);
|
|
21
|
-
|
|
22
|
-
return null;
|
|
23
|
-
const lift = (element) => {
|
|
21
|
+
const lift = useCallback((element) => {
|
|
24
22
|
if (element === null || isReduced || typeof element.animate !== 'function')
|
|
25
23
|
return;
|
|
26
24
|
element.animate(frames, {
|
|
@@ -28,6 +26,8 @@ export const PsDragOverlay = ({ children, className, frames, isDropAnimated, })
|
|
|
28
26
|
easing: PsDragConfig.liftEasing,
|
|
29
27
|
fill: 'forwards',
|
|
30
28
|
});
|
|
31
|
-
};
|
|
29
|
+
}, [frames, isReduced]);
|
|
30
|
+
if (!isMounted)
|
|
31
|
+
return null;
|
|
32
32
|
return createPortal(_jsx(DragOverlay, { dropAnimation: isReduced || isDropAnimated === false ? null : dropAnimation, zIndex: zIndex, children: children === null ? null : (_jsx("div", { className: className, ref: lift, children: children })) }), document.body);
|
|
33
33
|
};
|
|
@@ -6,11 +6,13 @@ import { CSS } from '@dnd-kit/utilities';
|
|
|
6
6
|
import { PsDragConfig } from '../constants/ps-drag-config.js';
|
|
7
7
|
import { PsDraggableGridClasses, PsDraggableGridLiftFrames } from '../constants/ps-draggable-grid.js';
|
|
8
8
|
import { usePsDragSensors } from '../hooks/use-ps-drag-sensors.js';
|
|
9
|
+
import { usePsDragTransition } from '../hooks/use-ps-drag-transition.js';
|
|
9
10
|
import { PsDragGrip } from './ps-drag-grip.js';
|
|
10
11
|
import { PsDragOverlay } from './ps-drag-overlay.js';
|
|
11
12
|
const PsDraggableGridHandle = ({ attributes, label, listeners, setActivatorNodeRef, }) => (_jsx("button", { ...attributes, ...listeners, "aria-label": `Move ${label}`, className: PsDraggableGridClasses.handle, ref: setActivatorNodeRef, title: `Move ${label}`, type: 'button', children: _jsx(PsDragGrip, {}) }));
|
|
12
13
|
const PsSortableGridItem = ({ className, index, item, renderItem, }) => {
|
|
13
|
-
const
|
|
14
|
+
const dragTransition = usePsDragTransition();
|
|
15
|
+
const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef, transform, transition, } = useSortable({ id: item.id, transition: dragTransition });
|
|
14
16
|
const rendered = renderItem({
|
|
15
17
|
handle: (_jsx(PsDraggableGridHandle, { attributes: attributes, label: item.label, listeners: listeners, setActivatorNodeRef: setActivatorNodeRef })),
|
|
16
18
|
index,
|
|
@@ -3,15 +3,15 @@ import { useState } from 'react';
|
|
|
3
3
|
import { DndContext, closestCenter, } from '@dnd-kit/core';
|
|
4
4
|
import { SortableContext, horizontalListSortingStrategy, useSortable, verticalListSortingStrategy, } from '@dnd-kit/sortable';
|
|
5
5
|
import { CSS } from '@dnd-kit/utilities';
|
|
6
|
-
import { PsDragClasses, PsDragConfig,
|
|
6
|
+
import { PsDragClasses, PsDragConfig, PsDragRowLiftFrames } from '../constants/ps-drag-config.js';
|
|
7
7
|
import { usePsDragSensors } from '../hooks/use-ps-drag-sensors.js';
|
|
8
|
-
import {
|
|
8
|
+
import { usePsDragTransition } from '../hooks/use-ps-drag-transition.js';
|
|
9
9
|
import { PsDragGrip } from './ps-drag-grip.js';
|
|
10
10
|
import { PsDragOverlay } from './ps-drag-overlay.js';
|
|
11
11
|
const PsSortableListHandle = ({ attributes, className, icon, label, listeners, setActivatorNodeRef, }) => (_jsx("button", { ...attributes, ...listeners, "aria-label": label, className: className === undefined ? PsDragClasses.handle : className, ref: setActivatorNodeRef, title: label, type: 'button', children: icon === undefined ? _jsx(PsDragGrip, {}) : icon }));
|
|
12
12
|
const PsSortableListRow = ({ className, handleClassName, handleIcon, getHandleLabel, index, isDisabled, item, renderItem, }) => {
|
|
13
|
-
const
|
|
14
|
-
const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef, transform, transition, } = useSortable({ disabled: isDisabled, id: item.id });
|
|
13
|
+
const dragTransition = usePsDragTransition();
|
|
14
|
+
const { attributes, isDragging, listeners, setActivatorNodeRef, setNodeRef, transform, transition, } = useSortable({ disabled: isDisabled, id: item.id, transition: dragTransition });
|
|
15
15
|
const rendered = renderItem({
|
|
16
16
|
handle: (_jsx(PsSortableListHandle, { attributes: attributes, className: handleClassName, icon: handleIcon, label: getHandleLabel(item.label), listeners: listeners, setActivatorNodeRef: setActivatorNodeRef })),
|
|
17
17
|
index,
|
|
@@ -24,7 +24,7 @@ const PsSortableListRow = ({ className, handleClassName, handleIcon, getHandleLa
|
|
|
24
24
|
return (_jsx("div", { className: `${PsDragClasses.listItem} ${className} ${isDragging ? PsDragClasses.placeholder : ''}`, ref: setNodeRef, style: {
|
|
25
25
|
opacity: isDragging ? PsDragConfig.placeholderOpacity : undefined,
|
|
26
26
|
transform: CSS.Translate.toString(transform),
|
|
27
|
-
transition
|
|
27
|
+
transition,
|
|
28
28
|
}, children: rendered }));
|
|
29
29
|
};
|
|
30
30
|
export const PsSortableList = ({ announcements: texts, className, getHandleLabel, getItemClassName, handleClassName, handleIcon, instructions, isHorizontal = false, role, items, onMove, renderItem, }) => {
|
|
@@ -63,7 +63,7 @@ export const PsSortableList = ({ announcements: texts, className, getHandleLabel
|
|
|
63
63
|
onMove(String(active.id), from, to);
|
|
64
64
|
};
|
|
65
65
|
const activeGroup = activeItem === null ? undefined : activeItem.groupKey;
|
|
66
|
-
return (_jsxs(DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [_jsx(SortableContext, { items: items.map((item) => item.id), strategy: isHorizontal ? horizontalListSortingStrategy : verticalListSortingStrategy, children: _jsx("div", { className: className, role: role, children: items.map((item, index) => (_jsx(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), _jsx(PsDragOverlay, { className: PsDragClasses.lifted, frames:
|
|
66
|
+
return (_jsxs(DndContext, { accessibility: { announcements, screenReaderInstructions: { draggable: instructions } }, collisionDetection: closestCenter, onDragCancel: () => setActiveId(null), onDragEnd: handleDragEnd, onDragStart: ({ active }) => setActiveId(String(active.id)), sensors: sensors, children: [_jsx(SortableContext, { items: items.map((item) => item.id), strategy: isHorizontal ? horizontalListSortingStrategy : verticalListSortingStrategy, children: _jsx("div", { className: className, role: role, children: items.map((item, index) => (_jsx(PsSortableListRow, { className: itemClassName(item), getHandleLabel: getHandleLabel, handleClassName: handleClassName, handleIcon: handleIcon, index: index, isDisabled: activeItem !== null && item.groupKey !== activeGroup, item: item, renderItem: renderItem }, item.id))) }) }), _jsx(PsDragOverlay, { className: PsDragClasses.lifted, frames: PsDragRowLiftFrames, children: activeItem !== null
|
|
67
67
|
? renderItem({
|
|
68
68
|
handle: (_jsx(PsSortableListHandle, { className: handleClassName, icon: handleIcon, label: getHandleLabel(activeItem.label) })),
|
|
69
69
|
index: activeIndex,
|
|
@@ -5,6 +5,8 @@ export const PsDragConfig = {
|
|
|
5
5
|
liftDuration: 200,
|
|
6
6
|
liftEasing: 'cubic-bezier(0.2, 0.9, 0.3, 1.2)',
|
|
7
7
|
placeholderOpacity: '0.4',
|
|
8
|
+
sortDuration: 250,
|
|
9
|
+
sortEasing: 'ease',
|
|
8
10
|
touchDelay: 180,
|
|
9
11
|
touchTolerance: 6,
|
|
10
12
|
};
|
|
@@ -21,7 +23,11 @@ export const PsDragLiftFrames = [
|
|
|
21
23
|
transform: 'scale(1.035) rotate(-1.2deg)',
|
|
22
24
|
},
|
|
23
25
|
];
|
|
24
|
-
export const
|
|
25
|
-
{ boxShadow: '0 0 0 0 rgb(15 23 42 / 0)', transform: 'scale(1)' },
|
|
26
|
-
{
|
|
26
|
+
export const PsDragRowLiftFrames = [
|
|
27
|
+
{ boxShadow: '0 0 0 0 rgb(15 23 42 / 0)', transform: 'scale(1) rotate(0deg)' },
|
|
28
|
+
{
|
|
29
|
+
boxShadow: '0 28px 64px -18px rgb(15 23 42 / 0.5)',
|
|
30
|
+
transform: 'scale(1.035) rotate(-0.25deg)',
|
|
31
|
+
},
|
|
27
32
|
];
|
|
33
|
+
export const PsDragListLiftFrames = PsDragRowLiftFrames;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { KeyboardSensor, MouseSensor, TouchSensor, useSensor, useSensors, } from '@dnd-kit/core';
|
|
2
2
|
import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';
|
|
3
3
|
import { PsDragConfig } from '../constants/ps-drag-config.js';
|
|
4
|
-
export const usePsDragSensors = () => useSensors(useSensor(MouseSensor, {
|
|
4
|
+
export const usePsDragSensors = (coordinateGetter = sortableKeyboardCoordinates) => useSensors(useSensor(MouseSensor, {
|
|
5
5
|
activationConstraint: { distance: PsDragConfig.activationDistance },
|
|
6
6
|
}), useSensor(TouchSensor, {
|
|
7
7
|
activationConstraint: {
|
|
8
8
|
delay: PsDragConfig.touchDelay,
|
|
9
9
|
tolerance: PsDragConfig.touchTolerance,
|
|
10
10
|
},
|
|
11
|
-
}), useSensor(KeyboardSensor, { coordinateGetter
|
|
11
|
+
}), useSensor(KeyboardSensor, { coordinateGetter }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PsDragConfig } from '../constants/ps-drag-config.js';
|
|
2
|
+
import { usePsReducedMotion } from './use-ps-reduced-motion.js';
|
|
3
|
+
const transition = {
|
|
4
|
+
duration: PsDragConfig.sortDuration,
|
|
5
|
+
easing: PsDragConfig.sortEasing,
|
|
6
|
+
};
|
|
7
|
+
export const usePsDragTransition = () => {
|
|
8
|
+
const isReduced = usePsReducedMotion();
|
|
9
|
+
return isReduced ? null : transition;
|
|
10
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -188,6 +188,8 @@ export * from './models/ps-summary-item.js';
|
|
|
188
188
|
export * from './components/ps-drag-grip.js';
|
|
189
189
|
export * from './components/ps-drag-overlay.js';
|
|
190
190
|
export * from './hooks/use-ps-drag-sensors.js';
|
|
191
|
+
export * from './hooks/use-ps-drag-transition.js';
|
|
192
|
+
export * from './models/ps-drag-transition.js';
|
|
191
193
|
export * from './hooks/use-ps-list-keys.js';
|
|
192
194
|
export * from './interfaces/ps-list-keys-result.js';
|
|
193
195
|
export * from './services/ps-list-key-service.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type SensorDescriptor, type SensorOptions } from '@dnd-kit/core';
|
|
2
|
-
export declare const usePsDragSensors: () => SensorDescriptor<SensorOptions>[];
|
|
1
|
+
import { type KeyboardCoordinateGetter, type SensorDescriptor, type SensorOptions } from '@dnd-kit/core';
|
|
2
|
+
export declare const usePsDragSensors: (coordinateGetter?: KeyboardCoordinateGetter) => SensorDescriptor<SensorOptions>[];
|
|
@@ -4,12 +4,12 @@ exports.usePsDragSensors = void 0;
|
|
|
4
4
|
const core_1 = require("@dnd-kit/core");
|
|
5
5
|
const sortable_1 = require("@dnd-kit/sortable");
|
|
6
6
|
const ps_drag_config_1 = require("../constants/ps-drag-config");
|
|
7
|
-
const usePsDragSensors = () => (0, core_1.useSensors)((0, core_1.useSensor)(core_1.MouseSensor, {
|
|
7
|
+
const usePsDragSensors = (coordinateGetter = sortable_1.sortableKeyboardCoordinates) => (0, core_1.useSensors)((0, core_1.useSensor)(core_1.MouseSensor, {
|
|
8
8
|
activationConstraint: { distance: ps_drag_config_1.PsDragConfig.activationDistance },
|
|
9
9
|
}), (0, core_1.useSensor)(core_1.TouchSensor, {
|
|
10
10
|
activationConstraint: {
|
|
11
11
|
delay: ps_drag_config_1.PsDragConfig.touchDelay,
|
|
12
12
|
tolerance: ps_drag_config_1.PsDragConfig.touchTolerance,
|
|
13
13
|
},
|
|
14
|
-
}), (0, core_1.useSensor)(core_1.KeyboardSensor, { coordinateGetter
|
|
14
|
+
}), (0, core_1.useSensor)(core_1.KeyboardSensor, { coordinateGetter }));
|
|
15
15
|
exports.usePsDragSensors = usePsDragSensors;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePsDragTransition = void 0;
|
|
4
|
+
const ps_drag_config_1 = require("../constants/ps-drag-config");
|
|
5
|
+
const use_ps_reduced_motion_1 = require("./use-ps-reduced-motion");
|
|
6
|
+
const transition = {
|
|
7
|
+
duration: ps_drag_config_1.PsDragConfig.sortDuration,
|
|
8
|
+
easing: ps_drag_config_1.PsDragConfig.sortEasing,
|
|
9
|
+
};
|
|
10
|
+
const usePsDragTransition = () => {
|
|
11
|
+
const isReduced = (0, use_ps_reduced_motion_1.usePsReducedMotion)();
|
|
12
|
+
return isReduced ? null : transition;
|
|
13
|
+
};
|
|
14
|
+
exports.usePsDragTransition = usePsDragTransition;
|
package/dist/index.d.ts
CHANGED
|
@@ -188,6 +188,8 @@ export * from './models/ps-summary-item';
|
|
|
188
188
|
export * from './components/ps-drag-grip';
|
|
189
189
|
export * from './components/ps-drag-overlay';
|
|
190
190
|
export * from './hooks/use-ps-drag-sensors';
|
|
191
|
+
export * from './hooks/use-ps-drag-transition';
|
|
192
|
+
export * from './models/ps-drag-transition';
|
|
191
193
|
export * from './hooks/use-ps-list-keys';
|
|
192
194
|
export * from './interfaces/ps-list-keys-result';
|
|
193
195
|
export * from './services/ps-list-key-service';
|
package/dist/index.js
CHANGED
|
@@ -204,6 +204,8 @@ __exportStar(require("./models/ps-summary-item"), exports);
|
|
|
204
204
|
__exportStar(require("./components/ps-drag-grip"), exports);
|
|
205
205
|
__exportStar(require("./components/ps-drag-overlay"), exports);
|
|
206
206
|
__exportStar(require("./hooks/use-ps-drag-sensors"), exports);
|
|
207
|
+
__exportStar(require("./hooks/use-ps-drag-transition"), exports);
|
|
208
|
+
__exportStar(require("./models/ps-drag-transition"), exports);
|
|
207
209
|
__exportStar(require("./hooks/use-ps-list-keys"), exports);
|
|
208
210
|
__exportStar(require("./interfaces/ps-list-keys-result"), exports);
|
|
209
211
|
__exportStar(require("./services/ps-list-key-service"), exports);
|