@homecode/ui 4.19.2 → 4.19.4
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.
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Component } from 'react';
|
|
3
|
-
import { createStore } from 'justorm/react';
|
|
4
|
-
import cn from 'classnames';
|
|
5
|
-
import Time from 'timen';
|
|
6
2
|
import 'nanoid';
|
|
7
3
|
import '../../tools/dom.js';
|
|
8
|
-
import
|
|
4
|
+
import throttle from '../../tools/throttle.js';
|
|
5
|
+
import Time from 'timen';
|
|
9
6
|
import 'compareq';
|
|
10
7
|
import 'lodash.pick';
|
|
11
8
|
import '../../tools/queryParams.js';
|
|
9
|
+
import { Component } from 'react';
|
|
12
10
|
import S from './Draggable.styl.js';
|
|
11
|
+
import cn from 'classnames';
|
|
12
|
+
import { createStore } from 'justorm/react';
|
|
13
13
|
|
|
14
14
|
class Draggable extends Component {
|
|
15
15
|
store;
|
|
@@ -60,7 +60,7 @@ class Draggable extends Component {
|
|
|
60
60
|
this.transformInner(this.draggingElem, `translate(${dx}px, ${dy}px)`);
|
|
61
61
|
this.checkUnderElem(x, y);
|
|
62
62
|
};
|
|
63
|
-
checkUnderElem =
|
|
63
|
+
checkUnderElem = throttle((x, y) => {
|
|
64
64
|
const underItem = document.elementFromPoint(x, y)?.closest(`.${S.item}`);
|
|
65
65
|
if (!underItem) {
|
|
66
66
|
this.store.underOffset = '';
|
|
@@ -129,7 +129,7 @@ class Draggable extends Component {
|
|
|
129
129
|
render() {
|
|
130
130
|
const { items, className, itemClassName, renderItem, children } = this.props;
|
|
131
131
|
const { draggingId, underId, underOffset } = this.store;
|
|
132
|
-
return (jsxs("div", { className: cn(S.root, draggingId && S.dragging, className), children: [items.map(id => (jsx("div", { className: cn(S.item, itemClassName, id === draggingId && S.active), onPointerDown: this.onPointerDown, "data-id": id, children: jsx("div", { className: S.inner, style: underId === id ? { transform: underOffset } : null, children: renderItem(id, id === draggingId) }) }, id))), children] }));
|
|
132
|
+
return (jsxs("div", { className: cn(S.root, draggingId && S.dragging, className), children: [items.map((id, index) => (jsx("div", { className: cn(S.item, itemClassName, id === draggingId && S.active), onPointerDown: this.onPointerDown, "data-id": id, children: jsx("div", { className: S.inner, style: underId === id ? { transform: underOffset } : null, children: renderItem(id, index, id === draggingId) }) }, id))), children] }));
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -3,7 +3,7 @@ export type Props = {
|
|
|
3
3
|
items: string[];
|
|
4
4
|
className?: string;
|
|
5
5
|
itemClassName?: string;
|
|
6
|
-
renderItem: (id: string, isActive: boolean) => ReactNode;
|
|
6
|
+
renderItem: (id: string, index: number, isActive: boolean) => ReactNode;
|
|
7
7
|
onDragStart?: (id: string) => void;
|
|
8
8
|
onDragEnd?: (id: string) => void;
|
|
9
9
|
onChange: (items: string[]) => void;
|