deepsea-components 5.16.4 → 5.16.6
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/AutoFit.cjs +20 -15
- package/dist/components/AutoFit.js +20 -15
- package/dist/components/AutoScroll.cjs +12 -9
- package/dist/components/AutoScroll.js +12 -9
- package/dist/components/AutoSizeTextarea.cjs +81 -23
- package/dist/components/AutoSizeTextarea.js +81 -23
- package/dist/components/CircleText.cjs +120 -24
- package/dist/components/CircleText.js +120 -24
- package/dist/components/CopyButton.cjs +8 -2
- package/dist/components/CopyButton.js +8 -2
- package/dist/components/DraggableGrid.cjs +155 -104
- package/dist/components/DraggableGrid.d.ts +25 -23
- package/dist/components/DraggableGrid.js +155 -104
- package/dist/components/Echart.cjs +95 -21
- package/dist/components/Echart.js +95 -21
- package/dist/components/Flow.cjs +10 -10
- package/dist/components/Flow.js +10 -10
- package/dist/components/FormLabel.cjs +92 -27
- package/dist/components/FormLabel.js +92 -27
- package/dist/components/HlsPlayer.cjs +65 -24
- package/dist/components/HlsPlayer.js +65 -24
- package/dist/components/IconFileType.cjs +14 -4
- package/dist/components/IconFileType.js +14 -4
- package/dist/components/InfiniteScroll.cjs +17 -10
- package/dist/components/InfiniteScroll.js +17 -10
- package/dist/components/InputFile.cjs +5 -5
- package/dist/components/InputFile.js +5 -5
- package/dist/components/InputFileButton.cjs +14 -13
- package/dist/components/InputFileButton.js +14 -13
- package/dist/components/ReadSheet.cjs +32 -7
- package/dist/components/ReadSheet.js +32 -7
- package/dist/components/Ring.cjs +48 -10
- package/dist/components/Ring.js +48 -10
- package/dist/components/Scroll.cjs +10 -3
- package/dist/components/Scroll.js +10 -3
- package/dist/components/ScrollMask.cjs +97 -11
- package/dist/components/ScrollMask.js +97 -11
- package/dist/components/SectionRing.cjs +60 -15
- package/dist/components/SectionRing.js +60 -15
- package/dist/components/TransitionBox.cjs +120 -30
- package/dist/components/TransitionBox.js +120 -30
- package/dist/components/TransitionNum.cjs +8 -8
- package/dist/components/TransitionNum.js +8 -8
- package/dist/components/Trapezium.cjs +68 -9
- package/dist/components/Trapezium.js +68 -9
- package/dist/components/Unify.cjs +79 -19
- package/dist/components/Unify.js +79 -19
- package/dist/components/WriteSheet.cjs +1 -1
- package/dist/components/WriteSheet.js +1 -1
- package/package.json +3 -3
- package/src/components/DraggableGrid.tsx +510 -506
|
@@ -25,6 +25,30 @@ export interface DraggableGridItemStatus {
|
|
|
25
25
|
export type DraggableGridKeyToOrder<K extends Key> = Map<K, number>;
|
|
26
26
|
/** 次序到元素的 key 的映射 */
|
|
27
27
|
export type DraggableGridOrderToKey<K extends Key> = Map<number, K>;
|
|
28
|
+
export type DraggableGridPropsCore<T, K extends Key = T extends Key ? T : never> = {
|
|
29
|
+
/** 数据源 */
|
|
30
|
+
items?: T[];
|
|
31
|
+
/** 元素的 key 到次序的映射 */
|
|
32
|
+
orderMap?: DraggableGridKeyToOrder<K>;
|
|
33
|
+
/** 次序变化时回调 */
|
|
34
|
+
onOrderMapChange?: (orderMap: DraggableGridKeyToOrder<K>) => void;
|
|
35
|
+
/** 禁用的元素 */
|
|
36
|
+
isItemDisabled?: K[] | ((item: T, key: K) => boolean);
|
|
37
|
+
/** 触发移动的元素 */
|
|
38
|
+
handle?: string | HTMLElement | ((item: T, key: K, element: HTMLDivElement) => HTMLElement | undefined | null) | undefined | null;
|
|
39
|
+
} & (MustBeReactNode<T> extends true ? {
|
|
40
|
+
/** 渲染函数,当 T 为 ReactNode 时,render 为可选 */
|
|
41
|
+
render?: (item: T, status: DraggableGridItemStatus) => ReactNode;
|
|
42
|
+
} : {
|
|
43
|
+
/** 渲染函数,当 T 为 ReactNode 时,render 为可选 */
|
|
44
|
+
render: (item: T, status: DraggableGridItemStatus) => ReactNode;
|
|
45
|
+
}) & (MustBeReactKey<T> extends true ? {
|
|
46
|
+
/** 获取 key 的函数,当 T 为 Key 时,keyExtractor 为可选 */
|
|
47
|
+
keyExtractor?: (item: T) => K;
|
|
48
|
+
} : {
|
|
49
|
+
/** 获取 key 的函数,当 T 为 Key 时,keyExtractor 为可选 */
|
|
50
|
+
keyExtractor: (item: T) => K;
|
|
51
|
+
});
|
|
28
52
|
export type DraggableGridProps<T, K extends Key = T extends Key ? T : never> = Omit<ComponentProps<"div">, "className" | "children"> & DragMoveEvents<HTMLDivElement> & {
|
|
29
53
|
/** 类名 */
|
|
30
54
|
className?: DraggableGridClassName;
|
|
@@ -32,8 +56,6 @@ export type DraggableGridProps<T, K extends Key = T extends Key ? T : never> = O
|
|
|
32
56
|
classNames?: DraggableGridClassNames;
|
|
33
57
|
/** 样式 */
|
|
34
58
|
style?: DraggableGridStyle;
|
|
35
|
-
/** 数据源 */
|
|
36
|
-
items?: T[];
|
|
37
59
|
/** 是否禁用拖拽 */
|
|
38
60
|
disabled?: boolean;
|
|
39
61
|
/** 列数 */
|
|
@@ -59,29 +81,9 @@ export type DraggableGridProps<T, K extends Key = T extends Key ? T : never> = O
|
|
|
59
81
|
itemWidth: number;
|
|
60
82
|
/** 元素高度 */
|
|
61
83
|
itemHeight: number;
|
|
62
|
-
/** 元素的 key 到次序的映射 */
|
|
63
|
-
orderMap?: DraggableGridKeyToOrder<K>;
|
|
64
|
-
/** 次序变化时回调 */
|
|
65
|
-
onOrderMapChange?: (orderMap: DraggableGridKeyToOrder<K>) => void;
|
|
66
|
-
/** 禁用的元素 */
|
|
67
|
-
isItemDisabled?: K[] | ((item: T, key: K) => boolean);
|
|
68
84
|
/** 禁用的次序 */
|
|
69
85
|
isOrderDisabled?: number[] | ((order: number) => boolean);
|
|
70
86
|
/** 次序的优先级,可以通过此函数调整元素的优先放置的方向,左上,右上,左下,右下,中心,顺时针,逆时针等等 */
|
|
71
87
|
orderPriority?: (a: number, b: number) => number;
|
|
72
|
-
|
|
73
|
-
handle?: string | HTMLElement | ((item: T, key: K, element: HTMLDivElement) => HTMLElement | undefined | null) | undefined | null;
|
|
74
|
-
} & (MustBeReactNode<T> extends true ? {
|
|
75
|
-
/** 渲染函数,当 T 为 ReactNode 时,render 为可选 */
|
|
76
|
-
render?: (item: T, status: DraggableGridItemStatus) => ReactNode;
|
|
77
|
-
} : {
|
|
78
|
-
/** 渲染函数,当 T 为 ReactNode 时,render 为可选 */
|
|
79
|
-
render: (item: T, status: DraggableGridItemStatus) => ReactNode;
|
|
80
|
-
}) & (MustBeReactKey<T> extends true ? {
|
|
81
|
-
/** 获取 key 的函数,当 T 为 Key 时,keyExtractor 为可选 */
|
|
82
|
-
keyExtractor?: (item: T) => K;
|
|
83
|
-
} : {
|
|
84
|
-
/** 获取 key 的函数,当 T 为 Key 时,keyExtractor 为可选 */
|
|
85
|
-
keyExtractor: (item: T) => K;
|
|
86
|
-
});
|
|
88
|
+
} & DraggableGridPropsCore<T, K>;
|
|
87
89
|
export declare function DraggableGrid<T, K extends Key = T extends Key ? T : never>({ className, classNames, style, items, disabled, columns, rows, gap, gapX, gapY, itemWidth, itemHeight, orderMap, onOrderMapChange, render, keyExtractor, isItemDisabled: _isItemDisabled, isOrderDisabled, orderPriority, handle, onDragMoveStart: _onDragMoveStart, onDragMove: _onDragMove, onDragMoveEnd: _onDragMoveEnd, ...rest }: DraggableGridProps<T, K>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
2
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
4
|
import { clsx, getArray, isNullable } from "deepsea-tools";
|
|
4
5
|
import { useDragMove } from "soda-hooks";
|
|
@@ -45,21 +46,71 @@ function getOrderToKey(keyToOrder) {
|
|
|
45
46
|
key
|
|
46
47
|
]));
|
|
47
48
|
}
|
|
48
|
-
function DraggableGridItem(
|
|
49
|
+
function DraggableGridItem(t0) {
|
|
50
|
+
const $ = c(19);
|
|
51
|
+
let handle;
|
|
52
|
+
let item;
|
|
53
|
+
let itemKey;
|
|
54
|
+
let onDragMove;
|
|
55
|
+
let onDragMoveEnd;
|
|
56
|
+
let onDragMoveStart;
|
|
57
|
+
let rest;
|
|
58
|
+
if ($[0] !== t0) {
|
|
59
|
+
({ item, itemKey, handle, onDragMoveStart, onDragMove, onDragMoveEnd, ...rest } = t0);
|
|
60
|
+
$[0] = t0;
|
|
61
|
+
$[1] = handle;
|
|
62
|
+
$[2] = item;
|
|
63
|
+
$[3] = itemKey;
|
|
64
|
+
$[4] = onDragMove;
|
|
65
|
+
$[5] = onDragMoveEnd;
|
|
66
|
+
$[6] = onDragMoveStart;
|
|
67
|
+
$[7] = rest;
|
|
68
|
+
} else {
|
|
69
|
+
handle = $[1];
|
|
70
|
+
item = $[2];
|
|
71
|
+
itemKey = $[3];
|
|
72
|
+
onDragMove = $[4];
|
|
73
|
+
onDragMoveEnd = $[5];
|
|
74
|
+
onDragMoveStart = $[6];
|
|
75
|
+
rest = $[7];
|
|
76
|
+
}
|
|
49
77
|
const element = useRef(null);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
78
|
+
let t1;
|
|
79
|
+
if ($[8] !== handle || $[9] !== item || $[10] !== itemKey) {
|
|
80
|
+
t1 = isNullable(handle) ? element : ()=>element.current && ("string" == typeof handle ? element.current.querySelector(handle) : "function" == typeof handle ? handle(item, itemKey, element.current) : handle);
|
|
81
|
+
$[8] = handle;
|
|
82
|
+
$[9] = item;
|
|
83
|
+
$[10] = itemKey;
|
|
84
|
+
$[11] = t1;
|
|
85
|
+
} else t1 = $[11];
|
|
86
|
+
let t2;
|
|
87
|
+
if ($[12] !== onDragMove || $[13] !== onDragMoveEnd || $[14] !== onDragMoveStart || $[15] !== t1) {
|
|
88
|
+
t2 = {
|
|
89
|
+
element: t1,
|
|
90
|
+
onDragMoveStart,
|
|
91
|
+
onDragMove,
|
|
92
|
+
onDragMoveEnd
|
|
93
|
+
};
|
|
94
|
+
$[12] = onDragMove;
|
|
95
|
+
$[13] = onDragMoveEnd;
|
|
96
|
+
$[14] = onDragMoveStart;
|
|
97
|
+
$[15] = t1;
|
|
98
|
+
$[16] = t2;
|
|
99
|
+
} else t2 = $[16];
|
|
100
|
+
useDragMove(t2);
|
|
101
|
+
let t3;
|
|
102
|
+
if ($[17] !== rest) {
|
|
103
|
+
t3 = /*#__PURE__*/ jsx("div", {
|
|
104
|
+
ref: element,
|
|
105
|
+
...rest
|
|
106
|
+
});
|
|
107
|
+
$[17] = rest;
|
|
108
|
+
$[18] = t3;
|
|
109
|
+
} else t3 = $[18];
|
|
110
|
+
return t3;
|
|
60
111
|
}
|
|
61
112
|
function DraggableGrid({ className, classNames, style, items = [], disabled, columns, rows, gap = 0, gapX = gap, gapY = gap, itemWidth, itemHeight, orderMap, onOrderMapChange, render, keyExtractor, isItemDisabled: _isItemDisabled, isOrderDisabled, orderPriority, handle, onDragMoveStart: _onDragMoveStart, onDragMove: _onDragMove, onDragMoveEnd: _onDragMoveEnd, ...rest }) {
|
|
62
|
-
const
|
|
113
|
+
const keyToItem_0 = useMemo(()=>{
|
|
63
114
|
const keyToItem = new Map();
|
|
64
115
|
items.forEach((item)=>{
|
|
65
116
|
const key = keyExtractor ? keyExtractor(item) : item;
|
|
@@ -70,8 +121,8 @@ function DraggableGrid({ className, classNames, style, items = [], disabled, col
|
|
|
70
121
|
items,
|
|
71
122
|
keyExtractor
|
|
72
123
|
]);
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
124
|
+
if (keyToItem_0.size !== items.length) throw new Error("there are duplicate keys in the items");
|
|
125
|
+
const orders_0 = useMemo(()=>{
|
|
75
126
|
let orders = getArray(columns * rows);
|
|
76
127
|
if (isOrderDisabled) orders = orders.filter((order)=>Array.isArray(isOrderDisabled) ? !isOrderDisabled.includes(order) : !isOrderDisabled(order));
|
|
77
128
|
if (orderPriority) orders = orders.toSorted(orderPriority);
|
|
@@ -86,89 +137,89 @@ function DraggableGrid({ className, classNames, style, items = [], disabled, col
|
|
|
86
137
|
if (orderMap) return orderMap;
|
|
87
138
|
const newOrderMap = getOrderMap({
|
|
88
139
|
prev: void 0,
|
|
89
|
-
orders,
|
|
90
|
-
keys: Array.from(
|
|
140
|
+
orders: orders_0,
|
|
141
|
+
keys: Array.from(keyToItem_0.keys())
|
|
91
142
|
});
|
|
92
|
-
onOrderMapChange
|
|
143
|
+
null == onOrderMapChange || onOrderMapChange(newOrderMap);
|
|
93
144
|
return newOrderMap;
|
|
94
145
|
});
|
|
95
146
|
const [dragging, setDragging] = useState(void 0);
|
|
96
147
|
const { current: cache } = useRef({
|
|
97
|
-
orders,
|
|
98
|
-
keys: Array.from(
|
|
148
|
+
orders: orders_0,
|
|
149
|
+
keys: Array.from(keyToItem_0.keys())
|
|
99
150
|
});
|
|
100
151
|
useEffect(()=>{
|
|
101
|
-
if (!isTheSameArray(dragging
|
|
102
|
-
cache.orders =
|
|
103
|
-
cache.keys = Array.from((dragging
|
|
104
|
-
const
|
|
105
|
-
prev: dragging
|
|
106
|
-
orders,
|
|
152
|
+
if (!isTheSameArray((null == dragging ? void 0 : dragging.orders) ?? cache.orders, orders_0) || !isTheSameIterable((null == dragging ? void 0 : dragging.keyToOrder.keys()) ?? cache.keys, keyToItem_0.keys())) {
|
|
153
|
+
cache.orders = orders_0;
|
|
154
|
+
cache.keys = Array.from(((null == dragging ? void 0 : dragging.keyToOrder) ?? keyToItem_0).keys());
|
|
155
|
+
const newOrderMap_0 = getOrderMap({
|
|
156
|
+
prev: (null == dragging ? void 0 : dragging.keyToOrder) ?? keyToOrder,
|
|
157
|
+
orders: orders_0,
|
|
107
158
|
keys: cache.keys
|
|
108
159
|
});
|
|
109
|
-
setKeyToOrder(
|
|
110
|
-
onOrderMapChange
|
|
111
|
-
const newRenderKeys = new Set(
|
|
160
|
+
setKeyToOrder(newOrderMap_0);
|
|
161
|
+
null == onOrderMapChange || onOrderMapChange(newOrderMap_0);
|
|
162
|
+
const newRenderKeys = new Set(newOrderMap_0.keys());
|
|
112
163
|
setRenderKeys((prev)=>prev.intersection(newRenderKeys).union(newRenderKeys.difference(prev)));
|
|
113
164
|
}
|
|
114
165
|
}, [
|
|
115
166
|
dragging,
|
|
116
167
|
cache,
|
|
117
|
-
|
|
118
|
-
|
|
168
|
+
orders_0,
|
|
169
|
+
keyToItem_0,
|
|
119
170
|
keyToOrder,
|
|
120
171
|
onOrderMapChange
|
|
121
172
|
]);
|
|
122
173
|
const [renderKeys, setRenderKeys] = useState(()=>new Set(keyToOrder.keys()));
|
|
123
174
|
const recent = useRef(void 0);
|
|
124
175
|
useEffect(()=>{
|
|
125
|
-
if (!!dragging && (!isTheSameArray(dragging.orders,
|
|
176
|
+
if (!!dragging && (!isTheSameArray(dragging.orders, orders_0) || dragging.columns !== columns || dragging.rows !== rows || dragging.gapX !== gapX || dragging.gapY !== gapY || dragging.itemWidth !== itemWidth || dragging.itemHeight !== itemHeight || !isTheSameIterable(dragging.keyToOrder.keys(), keyToItem_0.keys()))) {
|
|
126
177
|
setDragging(void 0);
|
|
127
|
-
if (isTheSameArray(dragging.orders,
|
|
178
|
+
if (isTheSameArray(dragging.orders, orders_0) && isTheSameIterable(dragging.keyToOrder.keys(), keyToItem_0.keys())) {
|
|
128
179
|
setKeyToOrder(dragging.keyToOrder);
|
|
129
|
-
onOrderMapChange
|
|
180
|
+
null == onOrderMapChange || onOrderMapChange(dragging.keyToOrder);
|
|
130
181
|
}
|
|
131
182
|
}
|
|
132
183
|
}, [
|
|
133
184
|
dragging,
|
|
134
|
-
|
|
185
|
+
orders_0,
|
|
135
186
|
columns,
|
|
136
187
|
rows,
|
|
137
188
|
gapX,
|
|
138
189
|
gapY,
|
|
139
190
|
itemWidth,
|
|
140
191
|
itemHeight,
|
|
141
|
-
|
|
192
|
+
keyToItem_0,
|
|
142
193
|
keyToOrder,
|
|
143
194
|
onOrderMapChange
|
|
144
195
|
]);
|
|
145
196
|
useEffect(()=>{
|
|
146
197
|
if (orderMap === keyToOrder) return;
|
|
147
198
|
if (orderMap) setKeyToOrder(orderMap);
|
|
148
|
-
else onOrderMapChange
|
|
199
|
+
else null == onOrderMapChange || onOrderMapChange(keyToOrder);
|
|
149
200
|
}, [
|
|
150
201
|
orderMap,
|
|
151
202
|
keyToOrder,
|
|
152
203
|
onOrderMapChange
|
|
153
204
|
]);
|
|
154
|
-
function onDragMoveStart(
|
|
155
|
-
_onDragMoveStart
|
|
205
|
+
function onDragMoveStart(key_0, event) {
|
|
206
|
+
null == _onDragMoveStart || _onDragMoveStart(event);
|
|
156
207
|
const position = getPosition({
|
|
157
|
-
order: keyToOrder.get(
|
|
208
|
+
order: keyToOrder.get(key_0),
|
|
158
209
|
columns,
|
|
159
210
|
gapX,
|
|
160
211
|
gapY,
|
|
161
212
|
itemWidth,
|
|
162
213
|
itemHeight
|
|
163
214
|
});
|
|
164
|
-
recent.current =
|
|
215
|
+
recent.current = key_0;
|
|
165
216
|
setDragging({
|
|
166
|
-
key,
|
|
217
|
+
key: key_0,
|
|
167
218
|
startX: position.x,
|
|
168
219
|
startY: position.y,
|
|
169
220
|
deltaX: event.deltaX,
|
|
170
221
|
deltaY: event.deltaY,
|
|
171
|
-
orders,
|
|
222
|
+
orders: orders_0,
|
|
172
223
|
columns,
|
|
173
224
|
rows,
|
|
174
225
|
gapX,
|
|
@@ -178,89 +229,89 @@ function DraggableGrid({ className, classNames, style, items = [], disabled, col
|
|
|
178
229
|
keyToOrder: keyToOrder
|
|
179
230
|
});
|
|
180
231
|
}
|
|
181
|
-
function onDragMove(
|
|
182
|
-
_onDragMove
|
|
232
|
+
function onDragMove(event_0) {
|
|
233
|
+
null == _onDragMove || _onDragMove(event_0);
|
|
183
234
|
if (!dragging) return;
|
|
184
|
-
const { deltaX, deltaY } =
|
|
185
|
-
const { key, orders, keyToOrder, startX, startY, columns, gapX, gapY, itemWidth, itemHeight } = dragging;
|
|
186
|
-
setDragging((
|
|
187
|
-
...
|
|
235
|
+
const { deltaX, deltaY } = event_0;
|
|
236
|
+
const { key: key_1, orders: orders_1, keyToOrder: keyToOrder_0, startX, startY, columns: columns_0, gapX: gapX_0, gapY: gapY_0, itemWidth: itemWidth_0, itemHeight: itemHeight_0 } = dragging;
|
|
237
|
+
setDragging((prev_0)=>({
|
|
238
|
+
...prev_0,
|
|
188
239
|
deltaX,
|
|
189
240
|
deltaY
|
|
190
241
|
}));
|
|
191
242
|
const x = startX + deltaX;
|
|
192
243
|
const y = startY + deltaY;
|
|
193
|
-
const currentOrder =
|
|
194
|
-
const currentOrderIndex =
|
|
195
|
-
const nearestOrder =
|
|
244
|
+
const currentOrder = keyToOrder_0.get(key_1);
|
|
245
|
+
const currentOrderIndex = orders_1.indexOf(currentOrder);
|
|
246
|
+
const nearestOrder = orders_1.toSorted((a, b)=>{
|
|
196
247
|
const aPosition = getPosition({
|
|
197
248
|
order: a,
|
|
198
|
-
columns,
|
|
199
|
-
gapX,
|
|
200
|
-
gapY,
|
|
201
|
-
itemWidth,
|
|
202
|
-
itemHeight
|
|
249
|
+
columns: columns_0,
|
|
250
|
+
gapX: gapX_0,
|
|
251
|
+
gapY: gapY_0,
|
|
252
|
+
itemWidth: itemWidth_0,
|
|
253
|
+
itemHeight: itemHeight_0
|
|
203
254
|
});
|
|
204
255
|
const bPosition = getPosition({
|
|
205
256
|
order: b,
|
|
206
|
-
columns,
|
|
207
|
-
gapX,
|
|
208
|
-
gapY,
|
|
209
|
-
itemWidth,
|
|
210
|
-
itemHeight
|
|
257
|
+
columns: columns_0,
|
|
258
|
+
gapX: gapX_0,
|
|
259
|
+
gapY: gapY_0,
|
|
260
|
+
itemWidth: itemWidth_0,
|
|
261
|
+
itemHeight: itemHeight_0
|
|
211
262
|
});
|
|
212
263
|
const aDistance = (x - aPosition.x) ** 2 + (y - aPosition.y) ** 2;
|
|
213
264
|
const bDistance = (x - bPosition.x) ** 2 + (y - bPosition.y) ** 2;
|
|
214
265
|
if (aDistance - bDistance !== 0) return aDistance - bDistance;
|
|
215
|
-
const aIndex =
|
|
216
|
-
const bIndex =
|
|
266
|
+
const aIndex = orders_1.indexOf(a);
|
|
267
|
+
const bIndex = orders_1.indexOf(b);
|
|
217
268
|
return Math.abs(aIndex - currentOrderIndex) - Math.abs(bIndex - currentOrderIndex);
|
|
218
269
|
})[0];
|
|
219
270
|
if (nearestOrder === currentOrder) {
|
|
220
|
-
setKeyToOrder(
|
|
221
|
-
onOrderMapChange
|
|
271
|
+
setKeyToOrder(keyToOrder_0);
|
|
272
|
+
null == onOrderMapChange || onOrderMapChange(keyToOrder_0);
|
|
222
273
|
return;
|
|
223
274
|
}
|
|
224
|
-
const newKeyToOrder = new Map(
|
|
225
|
-
newKeyToOrder.set(
|
|
226
|
-
const orderToKey = getOrderToKey(
|
|
275
|
+
const newKeyToOrder = new Map(keyToOrder_0);
|
|
276
|
+
newKeyToOrder.set(key_1, nearestOrder);
|
|
277
|
+
const orderToKey = getOrderToKey(keyToOrder_0);
|
|
227
278
|
if (!orderToKey.has(nearestOrder)) {
|
|
228
279
|
setKeyToOrder(newKeyToOrder);
|
|
229
|
-
onOrderMapChange
|
|
280
|
+
null == onOrderMapChange || onOrderMapChange(newKeyToOrder);
|
|
230
281
|
return;
|
|
231
282
|
}
|
|
232
|
-
const nearestOrderIndex =
|
|
283
|
+
const nearestOrderIndex = orders_1.indexOf(nearestOrder);
|
|
233
284
|
const itemDirection = currentOrderIndex > nearestOrderIndex ? "decrease" : "increase";
|
|
234
|
-
const targetDirection = "decrease" === itemDirection &&
|
|
285
|
+
const targetDirection = "decrease" === itemDirection && orders_1.slice(0, nearestOrderIndex).some((order_1)=>!orderToKey.has(order_1)) || "increase" === itemDirection && orders_1.slice(nearestOrderIndex + 1).every((order_0)=>orderToKey.has(order_0)) ? "decrease" : "increase";
|
|
235
286
|
function moveTargetOrder(targetOrder) {
|
|
236
287
|
const targetKey = orderToKey.get(targetOrder);
|
|
237
|
-
const targetOrderIndex =
|
|
288
|
+
const targetOrderIndex = orders_1.indexOf(targetOrder);
|
|
238
289
|
const nextOrderIndex = targetOrderIndex + ("decrease" === targetDirection ? -1 : 1);
|
|
239
|
-
const nextOrder =
|
|
290
|
+
const nextOrder = orders_1[nextOrderIndex];
|
|
240
291
|
newKeyToOrder.set(targetKey, nextOrder);
|
|
241
292
|
if (nextOrder === currentOrder || !orderToKey.has(nextOrder)) return;
|
|
242
293
|
moveTargetOrder(nextOrder);
|
|
243
294
|
}
|
|
244
295
|
moveTargetOrder(nearestOrder);
|
|
245
296
|
setKeyToOrder(newKeyToOrder);
|
|
246
|
-
onOrderMapChange
|
|
297
|
+
null == onOrderMapChange || onOrderMapChange(newKeyToOrder);
|
|
247
298
|
}
|
|
248
|
-
function onDragMoveEnd(
|
|
249
|
-
_onDragMoveEnd
|
|
299
|
+
function onDragMoveEnd(event_1) {
|
|
300
|
+
null == _onDragMoveEnd || _onDragMoveEnd(event_1);
|
|
250
301
|
if (!dragging) return;
|
|
251
302
|
setDragging(void 0);
|
|
252
303
|
}
|
|
253
|
-
function isItemDisabled(
|
|
304
|
+
function isItemDisabled(key_2) {
|
|
254
305
|
if (!_isItemDisabled) return false;
|
|
255
|
-
if (Array.isArray(_isItemDisabled)) return _isItemDisabled.includes(
|
|
256
|
-
return _isItemDisabled(
|
|
306
|
+
if (Array.isArray(_isItemDisabled)) return _isItemDisabled.includes(key_2);
|
|
307
|
+
return _isItemDisabled(keyToItem_0.get(key_2), key_2);
|
|
257
308
|
}
|
|
258
309
|
return /*#__PURE__*/ jsx("div", {
|
|
259
310
|
className: clsx(DraggableGrid_module.draggableGrid, "function" == typeof className ? className({
|
|
260
311
|
isDragging: !!dragging
|
|
261
|
-
}) : className, "function" == typeof classNames
|
|
312
|
+
}) : className, "function" == typeof (null == classNames ? void 0 : classNames.container) ? classNames.container({
|
|
262
313
|
isDragging: !!dragging
|
|
263
|
-
}) : classNames
|
|
314
|
+
}) : null == classNames ? void 0 : classNames.container),
|
|
264
315
|
style: {
|
|
265
316
|
"--width": `${columns * (itemWidth + gapX) - gapX}px`,
|
|
266
317
|
"--height": `${rows * (itemHeight + gapY) - gapY}px`,
|
|
@@ -269,19 +320,19 @@ function DraggableGrid({ className, classNames, style, items = [], disabled, col
|
|
|
269
320
|
}) : style
|
|
270
321
|
},
|
|
271
322
|
...rest,
|
|
272
|
-
children: Array.from(renderKeys).map((
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
const isDragging = dragging
|
|
276
|
-
const
|
|
277
|
-
order,
|
|
323
|
+
children: Array.from(renderKeys).map((key_3)=>{
|
|
324
|
+
const item_0 = keyToItem_0.get(key_3);
|
|
325
|
+
const order_2 = keyToOrder.get(key_3);
|
|
326
|
+
const isDragging = (null == dragging ? void 0 : dragging.key) === key_3;
|
|
327
|
+
const position_0 = getPosition({
|
|
328
|
+
order: order_2,
|
|
278
329
|
columns,
|
|
279
330
|
gapX,
|
|
280
331
|
gapY,
|
|
281
332
|
itemWidth,
|
|
282
333
|
itemHeight
|
|
283
334
|
});
|
|
284
|
-
const
|
|
335
|
+
const style_0 = isDragging ? {
|
|
285
336
|
"--width": `${itemWidth}px`,
|
|
286
337
|
"--height": `${itemHeight}px`,
|
|
287
338
|
"--translate-x": `${dragging.startX + dragging.deltaX}px`,
|
|
@@ -291,29 +342,29 @@ function DraggableGrid({ className, classNames, style, items = [], disabled, col
|
|
|
291
342
|
} : {
|
|
292
343
|
"--width": `${itemWidth}px`,
|
|
293
344
|
"--height": `${itemHeight}px`,
|
|
294
|
-
"--translate-x": `${
|
|
295
|
-
"--translate-y": `${
|
|
345
|
+
"--translate-x": `${position_0.x}px`,
|
|
346
|
+
"--translate-y": `${position_0.y}px`,
|
|
296
347
|
"--transition-property": "transform",
|
|
297
|
-
"--z-index": recent.current ===
|
|
348
|
+
"--z-index": recent.current === key_3 ? 999999 : keyToOrder.get(key_3)
|
|
298
349
|
};
|
|
299
|
-
const children = render ? render(
|
|
300
|
-
order,
|
|
350
|
+
const children = render ? render(item_0, {
|
|
351
|
+
order: order_2,
|
|
301
352
|
isDragging: isDragging
|
|
302
|
-
}) :
|
|
353
|
+
}) : item_0;
|
|
303
354
|
return /*#__PURE__*/ jsx(DraggableGridItem, {
|
|
304
|
-
item:
|
|
305
|
-
itemKey:
|
|
355
|
+
item: item_0,
|
|
356
|
+
itemKey: key_3,
|
|
306
357
|
handle: handle,
|
|
307
|
-
className: clsx(DraggableGrid_module.draggableGridItem, "function" == typeof classNames
|
|
308
|
-
order,
|
|
358
|
+
className: clsx(DraggableGrid_module.draggableGridItem, "function" == typeof (null == classNames ? void 0 : classNames.item) ? classNames.item({
|
|
359
|
+
order: order_2,
|
|
309
360
|
isDragging: isDragging
|
|
310
|
-
}) : classNames
|
|
311
|
-
style:
|
|
312
|
-
onDragMoveStart: disabled || isItemDisabled(
|
|
313
|
-
onDragMove: disabled || isItemDisabled(
|
|
314
|
-
onDragMoveEnd: disabled || isItemDisabled(
|
|
361
|
+
}) : null == classNames ? void 0 : classNames.item),
|
|
362
|
+
style: style_0,
|
|
363
|
+
onDragMoveStart: disabled || isItemDisabled(key_3) ? void 0 : (event_2)=>onDragMoveStart(key_3, event_2),
|
|
364
|
+
onDragMove: disabled || isItemDisabled(key_3) ? void 0 : onDragMove,
|
|
365
|
+
onDragMoveEnd: disabled || isItemDisabled(key_3) ? void 0 : onDragMoveEnd,
|
|
315
366
|
children: children
|
|
316
|
-
},
|
|
367
|
+
}, key_3);
|
|
317
368
|
})
|
|
318
369
|
});
|
|
319
370
|
}
|
|
@@ -30,33 +30,107 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
30
30
|
Bar: ()=>Bar
|
|
31
31
|
});
|
|
32
32
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
|
+
const compiler_runtime_namespaceObject = require("react/compiler-runtime");
|
|
33
34
|
const external_echarts_namespaceObject = require("echarts");
|
|
34
35
|
const external_react_namespaceObject = require("react");
|
|
35
36
|
const Echart = /*#__PURE__*/ (0, external_react_namespaceObject.forwardRef)((props, ref)=>{
|
|
36
|
-
const
|
|
37
|
+
const $ = (0, compiler_runtime_namespaceObject.c)(21);
|
|
38
|
+
let chart;
|
|
39
|
+
let height;
|
|
40
|
+
let option;
|
|
41
|
+
let rest;
|
|
42
|
+
let width;
|
|
43
|
+
if ($[0] !== props) {
|
|
44
|
+
({ width, height, option, chart, ...rest } = props);
|
|
45
|
+
$[0] = props;
|
|
46
|
+
$[1] = chart;
|
|
47
|
+
$[2] = height;
|
|
48
|
+
$[3] = option;
|
|
49
|
+
$[4] = rest;
|
|
50
|
+
$[5] = width;
|
|
51
|
+
} else {
|
|
52
|
+
chart = $[1];
|
|
53
|
+
height = $[2];
|
|
54
|
+
option = $[3];
|
|
55
|
+
rest = $[4];
|
|
56
|
+
width = $[5];
|
|
57
|
+
}
|
|
37
58
|
const container = (0, external_react_namespaceObject.useRef)(null);
|
|
38
59
|
const chartRef = (0, external_react_namespaceObject.useRef)(null);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
let t0;
|
|
61
|
+
if ($[6] !== height || $[7] !== option || $[8] !== width) {
|
|
62
|
+
t0 = ()=>{
|
|
63
|
+
const ele = container.current;
|
|
64
|
+
chartRef.current = (0, external_echarts_namespaceObject.init)(ele, option, {
|
|
65
|
+
width,
|
|
66
|
+
height
|
|
67
|
+
});
|
|
68
|
+
return ()=>{
|
|
69
|
+
var _chartRef_current;
|
|
70
|
+
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.dispose();
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
$[6] = height;
|
|
74
|
+
$[7] = option;
|
|
75
|
+
$[8] = width;
|
|
76
|
+
$[9] = t0;
|
|
77
|
+
} else t0 = $[9];
|
|
78
|
+
let t1;
|
|
79
|
+
if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
|
|
80
|
+
t1 = [];
|
|
81
|
+
$[10] = t1;
|
|
82
|
+
} else t1 = $[10];
|
|
83
|
+
(0, external_react_namespaceObject.useLayoutEffect)(t0, t1);
|
|
84
|
+
let t2;
|
|
85
|
+
let t3;
|
|
86
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
87
|
+
t2 = ()=>container.current;
|
|
88
|
+
t3 = [];
|
|
89
|
+
$[11] = t2;
|
|
90
|
+
$[12] = t3;
|
|
91
|
+
} else {
|
|
92
|
+
t2 = $[11];
|
|
93
|
+
t3 = $[12];
|
|
94
|
+
}
|
|
95
|
+
(0, external_react_namespaceObject.useImperativeHandle)(ref, t2, t3);
|
|
96
|
+
let t4;
|
|
97
|
+
let t5;
|
|
98
|
+
if ($[13] === Symbol.for("react.memo_cache_sentinel")) {
|
|
99
|
+
t4 = ()=>chartRef.current;
|
|
100
|
+
t5 = [];
|
|
101
|
+
$[13] = t4;
|
|
102
|
+
$[14] = t5;
|
|
103
|
+
} else {
|
|
104
|
+
t4 = $[13];
|
|
105
|
+
t5 = $[14];
|
|
106
|
+
}
|
|
107
|
+
(0, external_react_namespaceObject.useImperativeHandle)(chart, t4, t5);
|
|
108
|
+
let t6;
|
|
109
|
+
if ($[15] !== height || $[16] !== option || $[17] !== width) {
|
|
110
|
+
t6 = ()=>{
|
|
111
|
+
var _chartRef_current, _chartRef_current1;
|
|
112
|
+
null == (_chartRef_current = chartRef.current) || _chartRef_current.setOption(option);
|
|
113
|
+
null == (_chartRef_current1 = chartRef.current) || _chartRef_current1.resize({
|
|
114
|
+
width,
|
|
115
|
+
height
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
$[15] = height;
|
|
119
|
+
$[16] = option;
|
|
120
|
+
$[17] = width;
|
|
121
|
+
$[18] = t6;
|
|
122
|
+
} else t6 = $[18];
|
|
123
|
+
(0, external_react_namespaceObject.useEffect)(t6);
|
|
124
|
+
let t7;
|
|
125
|
+
if ($[19] !== rest) {
|
|
126
|
+
t7 = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
127
|
+
ref: container,
|
|
128
|
+
...rest
|
|
44
129
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
50
|
-
chartRef.current?.setOption(option);
|
|
51
|
-
chartRef.current?.resize({
|
|
52
|
-
width,
|
|
53
|
-
height
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
57
|
-
ref: container,
|
|
58
|
-
...rest
|
|
59
|
-
});
|
|
130
|
+
$[19] = rest;
|
|
131
|
+
$[20] = t7;
|
|
132
|
+
} else t7 = $[20];
|
|
133
|
+
return t7;
|
|
60
134
|
});
|
|
61
135
|
const Pie = Echart;
|
|
62
136
|
const Bar = Echart;
|