@lynx-js/lynx-ui-sortable 3.133.1 → 3.135.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.
@@ -1,7 +1,7 @@
1
1
  import { runOnBackground, useCallback, useMainThreadRef, useMemo } from "@lynx-js/react";
2
2
  import { mtsLog } from "@lynx-js/lynx-ui-common";
3
3
  function useSortable(useSortableOptions) {
4
- const { data, sizeMap, itemMTSRefMap, onDragEnd, onDragStart, debugLog = false } = useSortableOptions;
4
+ const { data, sizeMap, itemMTSRefMap, dirtyKeysRef, disabledKeysRef, onDragEnd, onDragStart, debugLog = false } = useSortableOptions;
5
5
  const safeData = Array.isArray(data) ? data : [];
6
6
  const keyArray = useMemo(()=>safeData.map((item)=>item.getSortingKey()), [
7
7
  safeData
@@ -13,6 +13,7 @@ function useSortable(useSortableOptions) {
13
13
  });
14
14
  const lastSwappingKey = useMainThreadRef('');
15
15
  const swappingItemTranslation = useMainThreadRef(0);
16
+ const lastCrossedDisabledSize = useMainThreadRef(0);
16
17
  const changedKey = useMainThreadRef([]);
17
18
  const lastSwappedKey = useMainThreadRef('');
18
19
  const changeItemZIndex = useCallback((zIndex, sortingKey)=>{
@@ -21,8 +22,10 @@ function useSortable(useSortableOptions) {
21
22
  item?.MTSSetOtherStyles({
22
23
  'z-index': `${zIndex}`
23
24
  });
25
+ dirtyKeysRef.current[sortingKey] = true;
24
26
  }, [
25
- itemMTSRefMap
27
+ itemMTSRefMap,
28
+ dirtyKeysRef
26
29
  ]);
27
30
  const handleDragStartJS = useCallback(()=>{
28
31
  onDragStart?.();
@@ -49,50 +52,85 @@ function useSortable(useSortableOptions) {
49
52
  mtsLog(debugLog, '[swappingIndexAndDistance] invalid index', index);
50
53
  return {
51
54
  index: -1,
52
- distance: 0
55
+ distance: 0,
56
+ crossedDisabledSize: 0
53
57
  };
54
58
  }
55
59
  const absDistance = Math.abs(movingDistance);
56
60
  const direction = movingDistance > 0 ? 1 : -1;
57
61
  let currentIndex = index + direction;
58
62
  let accumulatedDistance = 0;
63
+ let disabledGap = 0;
59
64
  while(true){
60
65
  if (currentIndex < 0 || currentIndex >= keyArray.length) return {
61
66
  index: -1,
62
- distance: (movingDistance > 0 ? 1 : -1) * (absDistance - accumulatedDistance)
67
+ distance: (movingDistance > 0 ? 1 : -1) * (absDistance - accumulatedDistance),
68
+ crossedDisabledSize: disabledGap
63
69
  };
64
- const size = sizeMap.current[keyArray[currentIndex]];
70
+ const currentKey = keyArray[currentIndex];
71
+ if (disabledKeysRef.current[currentKey]) {
72
+ const disabledSize = sizeMap.current[currentKey];
73
+ if ('number' != typeof disabledSize) {
74
+ mtsLog(debugLog, `[swappingIndexAndDistance] disabled item size not found for key ${currentKey}, stopping at index ${currentIndex}.`);
75
+ return {
76
+ index: -1,
77
+ distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance,
78
+ crossedDisabledSize: disabledGap
79
+ };
80
+ }
81
+ if (accumulatedDistance + disabledSize >= absDistance) {
82
+ mtsLog(debugLog, `[swappingIndexAndDistance] still over disabled item ${currentKey} at index ${currentIndex}.`);
83
+ return {
84
+ index: -1,
85
+ distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance,
86
+ crossedDisabledSize: disabledGap
87
+ };
88
+ }
89
+ mtsLog(debugLog, `[swappingIndexAndDistance] cross disabled item ${currentKey} at index ${currentIndex}.`);
90
+ accumulatedDistance += disabledSize;
91
+ disabledGap += disabledSize;
92
+ currentIndex += direction;
93
+ continue;
94
+ }
95
+ const size = sizeMap.current[currentKey];
65
96
  if ('number' != typeof size) {
66
97
  mtsLog(debugLog, `[swappingIndexAndDistance] item size not found for key ${sortingKey}, stopping at index ${currentIndex}.`);
67
98
  return {
68
99
  index: -1,
69
- distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance
100
+ distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance,
101
+ crossedDisabledSize: disabledGap
70
102
  };
71
103
  }
72
104
  accumulatedDistance += size;
73
105
  if (accumulatedDistance >= absDistance) return {
74
106
  index: currentIndex,
75
- distance: (movingDistance > 0 ? 1 : -1) * (accumulatedDistance - size)
107
+ distance: (movingDistance > 0 ? 1 : -1) * (accumulatedDistance - size),
108
+ crossedDisabledSize: disabledGap
76
109
  };
110
+ disabledGap = 0;
77
111
  currentIndex += direction;
78
112
  }
79
113
  }, [
80
114
  keyArray,
81
- sizeMap
115
+ sizeMap,
116
+ disabledKeysRef
82
117
  ]);
83
- const setTransform = useCallback((item, translate)=>{
118
+ const setTransform = useCallback((key, translate)=>{
84
119
  'main thread';
85
- item?.MTSSetOtherStyles({
86
- transform: `translateY(${translate}px)`
87
- });
88
- }, []);
120
+ const item = key ? itemMTSRefMap.current[key] : null;
121
+ item?.MTSSetTransform(0, translate);
122
+ if (key) dirtyKeysRef.current[key] = true;
123
+ }, [
124
+ itemMTSRefMap,
125
+ dirtyKeysRef
126
+ ]);
89
127
  const clampPreviousItem = (movingDistance, sortingKey)=>{
90
128
  'main thread';
91
129
  mtsLog(debugLog, `clamp ${lastSwappingKey.current} to grid`);
92
130
  const draggingItemSize = sizeMap.current[sortingKey];
93
131
  if (null !== lastSwappingKey.current) {
94
- const lastSwappingItem = lastSwappingKey.current ? itemMTSRefMap.current[lastSwappingKey.current] : null;
95
- Math.abs(swappingItemTranslation.current) > draggingItemSize * swapConfirmedPercentage.current ? setTransform(lastSwappingItem, (movingDistance < 0 ? 1 : -1) * draggingItemSize) : setTransform(lastSwappingItem, 0);
132
+ const lastSwappingItemKey = lastSwappingKey.current;
133
+ Math.abs(swappingItemTranslation.current) > draggingItemSize * swapConfirmedPercentage.current ? setTransform(lastSwappingItemKey, (movingDistance < 0 ? 1 : -1) * (draggingItemSize + lastCrossedDisabledSize.current)) : setTransform(lastSwappingItemKey, 0);
96
134
  }
97
135
  };
98
136
  const updateLastSwappingItem = (movingDistance, sortingKey, swappingKey)=>{
@@ -124,18 +162,20 @@ function useSortable(useSortableOptions) {
124
162
  };
125
163
  const switchHandler = useCallback((movingDistance, sortingKey)=>{
126
164
  'main thread';
127
- const { index: swappingIndex, distance: consumedDistance } = swappingIndexAndDistance(movingDistance, sortingKey);
128
- mtsLog(debugLog, 'swappingIndexAndDistance', swappingIndex, consumedDistance);
165
+ const { index: swappingIndex, distance: consumedDistance, crossedDisabledSize = 0 } = swappingIndexAndDistance(movingDistance, sortingKey);
166
+ mtsLog(debugLog, 'swappingIndexAndDistance', swappingIndex, consumedDistance, crossedDisabledSize);
129
167
  if (swappingIndex < 0) return void clampPreviousItem(consumedDistance, sortingKey);
130
168
  const swappingKey = keyArray[swappingIndex];
131
- const swappingItem = itemMTSRefMap.current[swappingKey];
132
169
  if (swappingKey !== lastSwappingKey.current) {
133
170
  updateLastSwappingItem(movingDistance, sortingKey, swappingKey);
134
171
  changedKey.current.push(swappingKey);
135
172
  }
136
173
  const unconsumedDistance = movingDistance - consumedDistance;
137
174
  updateConfirmedInteractedID(unconsumedDistance, sortingKey);
138
- setTransform(swappingItem, -unconsumedDistance);
175
+ const swappingItemSize = sizeMap.current[swappingKey] ?? 0;
176
+ const speedMultiplier = swappingItemSize > 0 ? (swappingItemSize + crossedDisabledSize) / swappingItemSize : 1;
177
+ setTransform(swappingKey, -unconsumedDistance * speedMultiplier);
178
+ lastCrossedDisabledSize.current = crossedDisabledSize;
139
179
  }, [
140
180
  changedKey,
141
181
  itemMTSRefMap,
@@ -159,32 +199,64 @@ function useSortable(useSortableOptions) {
159
199
  'main thread';
160
200
  const draggingIndex = keyArray.indexOf(sortingKey);
161
201
  const swappedIndex = keyArray.indexOf(lastSwappedKey.current);
162
- const swappedKeyArray = [
202
+ mtsLog(debugLog, 'sortArray with lastSwappedKey ', lastSwappedKey.current);
203
+ if (-1 === draggingIndex || -1 === swappedIndex || draggingIndex === swappedIndex) return [
163
204
  ...keyArray
164
205
  ];
165
- mtsLog(debugLog, 'sortArray with lastSwappedKey ', lastSwappedKey.current);
166
- if (-1 === draggingIndex || -1 === swappedIndex || draggingIndex === swappedIndex) return swappedKeyArray;
167
- const [draggedItem] = swappedKeyArray.splice(draggingIndex, 1);
168
- swappedKeyArray.splice(swappedIndex, 0, draggedItem);
169
- return swappedKeyArray;
206
+ const disabledIndices = {};
207
+ const movableKeys = [];
208
+ for(let i = 0; i < keyArray.length; i++){
209
+ const k = keyArray[i];
210
+ if (disabledKeysRef.current[k]) disabledIndices[i] = k;
211
+ else movableKeys.push(k);
212
+ }
213
+ const movableDraggingIdx = movableKeys.indexOf(sortingKey);
214
+ const movableSwappedIdx = movableKeys.indexOf(lastSwappedKey.current);
215
+ if (-1 === movableDraggingIdx || -1 === movableSwappedIdx) return [
216
+ ...keyArray
217
+ ];
218
+ const [draggedItem] = movableKeys.splice(movableDraggingIdx, 1);
219
+ movableKeys.splice(movableSwappedIdx, 0, draggedItem);
220
+ const result = [];
221
+ let cursor = 0;
222
+ for(let i = 0; i < keyArray.length; i++)if (void 0 === disabledIndices[i]) {
223
+ result.push(movableKeys[cursor]);
224
+ cursor++;
225
+ } else result.push(disabledIndices[i]);
226
+ return result;
170
227
  }, [
171
228
  keyArray,
172
- lastSwappedKey
229
+ lastSwappedKey,
230
+ disabledKeysRef
173
231
  ]);
174
- const resetStatus = useCallback(()=>{
232
+ const resetSwapTrackingRefs = useCallback(()=>{
175
233
  'main thread';
176
- changedKey.current.map((key)=>{
177
- const item = itemMTSRefMap?.current?.[key];
178
- if (item && 'function' == typeof item.MTSResetInternalTranslateValues) item?.MTSResetInternalTranslateValues();
179
- });
180
234
  lastSwappedKey.current = '';
181
235
  lastSwappingKey.current = '';
236
+ swappingItemTranslation.current = 0;
237
+ lastCrossedDisabledSize.current = 0;
182
238
  changedKey.current = [];
183
239
  }, [
184
240
  changedKey,
185
- itemMTSRefMap,
186
241
  lastSwappedKey,
187
- lastSwappingKey
242
+ lastSwappingKey,
243
+ swappingItemTranslation,
244
+ lastCrossedDisabledSize
245
+ ]);
246
+ const resetStatus = useCallback((draggingKey)=>{
247
+ 'main thread';
248
+ changedKey.current.map((key)=>{
249
+ if (key === draggingKey) return;
250
+ const item = itemMTSRefMap?.current?.[key];
251
+ if (!item) return;
252
+ if ('function' == typeof item.MTSSetTransform) item.MTSSetTransform(0, 0);
253
+ if ('function' == typeof item.MTSResetInternalTranslateValues) item.MTSResetInternalTranslateValues();
254
+ });
255
+ resetSwapTrackingRefs();
256
+ }, [
257
+ changedKey,
258
+ itemMTSRefMap,
259
+ resetSwapTrackingRefs
188
260
  ]);
189
261
  const rootDragEnd = useCallback((sortedKey)=>{
190
262
  const keyToItemMap = new Map(data.map((item, index)=>[
@@ -202,10 +274,25 @@ function useSortable(useSortableOptions) {
202
274
  'main thread';
203
275
  mtsLog(debugLog, '[event drag end]', event);
204
276
  const sortedKey = sortArray(sortingKey);
205
- runOnBackground(rootDragEnd)(sortedKey);
206
- resetStatus();
277
+ let orderChanged = sortedKey.length !== keyArray.length;
278
+ if (!orderChanged) {
279
+ for(let i = 0; i < sortedKey.length; i++)if (sortedKey[i] !== keyArray[i]) {
280
+ orderChanged = true;
281
+ break;
282
+ }
283
+ }
284
+ if (orderChanged) {
285
+ runOnBackground(rootDragEnd)(sortedKey);
286
+ resetSwapTrackingRefs();
287
+ } else {
288
+ resetStatus(sortingKey);
289
+ runOnBackground(rootDragEnd)(sortedKey);
290
+ }
291
+ return orderChanged;
207
292
  }, [
293
+ keyArray,
208
294
  resetStatus,
295
+ resetSwapTrackingRefs,
209
296
  rootDragEnd,
210
297
  sortArray
211
298
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"useSortable.jsx","sources":["webpack://@lynx-js/lynx-ui-sortable/./src/useSortable.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n runOnBackground,\n useCallback,\n useMainThreadRef,\n useMemo,\n} from '@lynx-js/react'\nimport type { MainThreadRef, RefObject } from '@lynx-js/react'\n\nimport { mtsLog } from '@lynx-js/lynx-ui-common'\nimport type { Point } from '@lynx-js/lynx-ui-common'\nimport type { DraggableRef } from '@lynx-js/lynx-ui-draggable'\nimport type { MainThread } from '@lynx-js/types'\n\nimport type { SortableData } from './types'\n\ninterface SortableOptionsType<T> {\n data: SortableData<T>[] // sorting key array\n sizeMap: MainThreadRef<Record<string, number>> // sorting key -> size\n itemRefMap: RefObject<Record<string, DraggableRef | null>>\n itemMTSRefMap: MainThreadRef<Record<string, DraggableRef | null>> // sortingKey -> element Ref\n onDragEnd?: (sortedKeyArray: SortableData<T>[]) => void\n onDragStart?: () => void\n debugLog?: boolean\n}\n\nexport function useSortable<T>(\n useSortableOptions: SortableOptionsType<T>,\n) {\n const {\n data,\n sizeMap,\n itemMTSRefMap,\n onDragEnd,\n onDragStart,\n debugLog = false,\n } = useSortableOptions\n\n const safeData = Array.isArray(data) ? data : []\n const keyArray = useMemo(() => safeData.map(item => item.getSortingKey()), [\n safeData,\n ])\n const swapConfirmedPercentage = useMainThreadRef<number>(0.5)\n const touchStartPoint = useMainThreadRef<Point>({ x: 0, y: 0 })\n const lastSwappingKey = useMainThreadRef<string>('')\n const swappingItemTranslation = useMainThreadRef<number>(0)\n const changedKey = useMainThreadRef<string[]>([]) // Store all the moved item. Remember to reset them\n const lastSwappedKey = useMainThreadRef<string>('') // Store the last swapped item. Use it to do the sorting.\n\n const changeItemZIndex = useCallback((zIndex: number, sortingKey: string) => {\n 'main thread'\n const item = itemMTSRefMap.current[sortingKey]\n\n item?.MTSSetOtherStyles({\n 'z-index': `${zIndex}`,\n })\n }, [itemMTSRefMap])\n\n const handleDragStartJS = useCallback(() => {\n onDragStart?.()\n }, [onDragStart])\n\n const handleDragStart = useCallback(\n (\n pagePoint: Point,\n sortingKey: string,\n event: MainThread.MouseEvent | MainThread.TouchEvent,\n ) => {\n 'main thread'\n runOnBackground(handleDragStartJS)()\n touchStartPoint.current = pagePoint\n changedKey.current.push(sortingKey)\n changeItemZIndex(10000, sortingKey)\n mtsLog(debugLog, '[event drag start]', event)\n },\n [handleDragStartJS, touchStartPoint, changedKey, changeItemZIndex],\n )\n\n const swappingIndexAndDistance: (\n movingDistance: number,\n sortingKey: string,\n ) => { index: number, distance: number } = useCallback(\n (movingDistance, sortingKey) => {\n 'main thread'\n const index = keyArray.indexOf(sortingKey)\n if (keyArray.length === 0 || index < 0 || index >= keyArray.length) {\n mtsLog(debugLog, '[swappingIndexAndDistance] invalid index', index)\n return { index: -1, distance: 0 }\n }\n\n const absDistance = Math.abs(movingDistance)\n const direction = movingDistance > 0 ? 1 : -1\n let currentIndex = index + direction\n let accumulatedDistance = 0\n while (true) {\n if (currentIndex < 0 || currentIndex >= keyArray.length) {\n return {\n index: -1,\n distance: (movingDistance > 0 ? 1 : -1)\n * (absDistance - accumulatedDistance),\n }\n }\n const size = sizeMap.current[keyArray[currentIndex]]\n if (typeof size !== 'number') {\n mtsLog(\n debugLog,\n `[swappingIndexAndDistance] item size not found for key ${sortingKey}, stopping at index ${currentIndex}.`,\n )\n return {\n index: -1,\n distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance,\n }\n }\n accumulatedDistance += size\n\n if (accumulatedDistance >= absDistance) {\n return {\n index: currentIndex,\n // This distance is the remained dragging distance needs to be consumed by current interacting item.\n // E.g.: the total delta is 458 and all item is all 100px tall. Then the first 400 will be consumed the previous clamped items. And the 58 is current interacting item.\n distance: (movingDistance > 0 ? 1 : -1)\n * (accumulatedDistance - size),\n }\n }\n currentIndex += direction\n }\n },\n [keyArray, sizeMap],\n )\n\n const setTransform = useCallback(\n (item: DraggableRef | null, translate: number) => {\n 'main thread'\n\n item?.MTSSetOtherStyles({ 'transform': `translateY(${translate}px)` })\n },\n [],\n )\n\n // Clamp the previous interacting item to the grid\n const clampPreviousItem = (movingDistance: number, sortingKey: string) => {\n 'main thread'\n mtsLog(\n debugLog,\n `clamp ${lastSwappingKey.current} to grid`,\n )\n const draggingItemSize = sizeMap.current[sortingKey]\n if (lastSwappingKey.current !== null) {\n const lastSwappingItem = lastSwappingKey.current\n ? itemMTSRefMap.current[lastSwappingKey.current]\n : null\n if (\n Math.abs(swappingItemTranslation.current)\n > draggingItemSize * swapConfirmedPercentage.current\n ) {\n setTransform(\n lastSwappingItem,\n (movingDistance < 0 ? 1 : -1) * draggingItemSize,\n )\n } else {\n setTransform(lastSwappingItem, 0)\n }\n }\n }\n\n const updateLastSwappingItem = (\n movingDistance: number,\n sortingKey: string,\n swappingKey: string,\n ) => {\n 'main thread'\n mtsLog(\n debugLog,\n `interact item from ${lastSwappingKey.current} to ${swappingKey}`,\n )\n clampPreviousItem(movingDistance, sortingKey)\n lastSwappingKey.current = swappingKey\n }\n\n // Update the confirmed interacting ID if the condition is met\n const updateConfirmedInteractedID = (\n unconsumedDistance: number,\n sortingKey: string,\n ) => {\n 'main thread'\n mtsLog(\n debugLog,\n `swapping with ${lastSwappingKey.current} at ${unconsumedDistance}`,\n )\n const draggingItemSize = sizeMap.current[sortingKey]\n if (\n Math.abs(unconsumedDistance)\n > draggingItemSize * swapConfirmedPercentage.current\n ) {\n lastSwappedKey.current = lastSwappingKey.current\n mtsLog(\n debugLog,\n `confirmed swapping with ${lastSwappedKey.current} at cross ${unconsumedDistance}`,\n )\n } else if (lastSwappedKey.current === lastSwappingKey.current) {\n // Handle case when dragging back over a previously swapped item\n const swappingIndex = keyArray.indexOf(lastSwappingKey.current)\n const draggedItemIndex = keyArray.indexOf(sortingKey)\n\n // Get new swap candidate index based on drag direction reversal\n // Drag down → reverse up: `swappingIndex - 1`\n // Drag up → reverse down: `swappingIndex + 1`\n const indexModifier = swappingIndex > draggedItemIndex ? -1 : 1\n const newSwappedKeyIndex = swappingIndex + indexModifier\n\n // The logic should prevent out-of-bounds access, but as a safeguard:\n if (newSwappedKeyIndex >= 0 && newSwappedKeyIndex < keyArray.length) {\n const newSwappedKey = keyArray[newSwappedKeyIndex]\n\n // If new candidate's index matches dragged item's index, item returned to original position; no swap confirmed.\n if (newSwappedKeyIndex === draggedItemIndex) {\n lastSwappedKey.current = ''\n } else {\n lastSwappedKey.current = newSwappedKey\n }\n } else {\n // Item is returning to original position when reverting swap at list start/end.\n lastSwappedKey.current = ''\n }\n\n mtsLog(\n debugLog,\n `Reverted swap with ${lastSwappingKey.current}. New confirmed swap is with ${\n lastSwappedKey.current || 'none'\n }.`,\n )\n }\n swappingItemTranslation.current = unconsumedDistance\n }\n\n const switchHandler = useCallback(\n (movingDistance: number, sortingKey: string) => {\n 'main thread'\n const { index: swappingIndex, distance: consumedDistance } =\n swappingIndexAndDistance(movingDistance, sortingKey)\n mtsLog(\n debugLog,\n 'swappingIndexAndDistance',\n swappingIndex,\n consumedDistance,\n )\n if (swappingIndex < 0) {\n clampPreviousItem(consumedDistance, sortingKey)\n return\n }\n const swappingKey = keyArray[swappingIndex]\n const swappingItem = itemMTSRefMap.current[swappingKey]\n\n if (swappingKey !== lastSwappingKey.current) {\n updateLastSwappingItem(movingDistance, sortingKey, swappingKey)\n changedKey.current.push(swappingKey)\n }\n\n const unconsumedDistance = movingDistance - consumedDistance\n updateConfirmedInteractedID(unconsumedDistance, sortingKey)\n setTransform(swappingItem, -unconsumedDistance)\n },\n [\n changedKey,\n itemMTSRefMap,\n keyArray,\n lastSwappingKey,\n setTransform,\n swappingIndexAndDistance,\n updateConfirmedInteractedID,\n updateLastSwappingItem,\n ],\n )\n\n const handleDragMove = useCallback(\n (\n delta: Point,\n sortingKey: string,\n event: MainThread.MouseEvent | MainThread.TouchEvent,\n ) => {\n 'main thread'\n switchHandler(delta.y, sortingKey)\n changeItemZIndex(10000, sortingKey)\n mtsLog(debugLog, '[event drag move]', event)\n },\n [switchHandler, changeItemZIndex],\n )\n\n const sortArray = useCallback((sortingKey: string) => {\n 'main thread'\n const draggingIndex = keyArray.indexOf(sortingKey)\n const swappedIndex = keyArray.indexOf(lastSwappedKey.current)\n const swappedKeyArray = [...keyArray]\n\n mtsLog(debugLog, 'sortArray with lastSwappedKey ', lastSwappedKey.current)\n\n if (\n draggingIndex === -1 || swappedIndex === -1\n || draggingIndex === swappedIndex\n ) {\n return swappedKeyArray\n }\n\n const [draggedItem] = swappedKeyArray.splice(draggingIndex, 1)\n swappedKeyArray.splice(swappedIndex, 0, draggedItem)\n return swappedKeyArray\n }, [keyArray, lastSwappedKey])\n\n const resetStatus = useCallback(() => {\n 'main thread'\n changedKey.current.map((key: string) => {\n const item = itemMTSRefMap?.current?.[key]\n if (item && typeof item.MTSResetInternalTranslateValues === 'function') {\n item?.MTSResetInternalTranslateValues()\n }\n })\n lastSwappedKey.current = ''\n lastSwappingKey.current = ''\n changedKey.current = []\n }, [changedKey, itemMTSRefMap, lastSwappedKey, lastSwappingKey])\n\n const rootDragEnd = useCallback((sortedKey: string[]) => {\n const keyToItemMap = new Map(data.map((item, index) => {\n return [keyArray[index], item]\n }))\n const sortedData = sortedKey\n .map(key => keyToItemMap.get(key))\n .filter((item): item is NonNullable<typeof item> => !!item)\n onDragEnd?.(sortedData)\n }, [data, keyArray, onDragEnd])\n\n const handleDragEnd = useCallback(\n (\n sortingKey: string,\n event: MainThread.MouseEvent | MainThread.TouchEvent,\n ) => {\n 'main thread'\n mtsLog(debugLog, '[event drag end]', event)\n const sortedKey = sortArray(sortingKey)\n runOnBackground(rootDragEnd)(sortedKey)\n resetStatus()\n },\n [resetStatus, rootDragEnd, sortArray],\n )\n\n return {\n handleDragStart,\n handleDragMove,\n handleDragEnd,\n }\n}\n"],"names":["useSortable","useSortableOptions","data","sizeMap","itemMTSRefMap","onDragEnd","onDragStart","debugLog","safeData","Array","keyArray","useMemo","item","swapConfirmedPercentage","useMainThreadRef","touchStartPoint","lastSwappingKey","swappingItemTranslation","changedKey","lastSwappedKey","changeItemZIndex","useCallback","zIndex","sortingKey","handleDragStartJS","handleDragStart","pagePoint","event","runOnBackground","mtsLog","swappingIndexAndDistance","movingDistance","index","absDistance","Math","direction","currentIndex","accumulatedDistance","size","setTransform","translate","clampPreviousItem","draggingItemSize","lastSwappingItem","updateLastSwappingItem","swappingKey","updateConfirmedInteractedID","unconsumedDistance","swappingIndex","draggedItemIndex","indexModifier","newSwappedKeyIndex","newSwappedKey","switchHandler","consumedDistance","swappingItem","handleDragMove","delta","sortArray","draggingIndex","swappedIndex","swappedKeyArray","draggedItem","resetStatus","key","rootDragEnd","sortedKey","keyToItemMap","Map","sortedData","handleDragEnd"],"mappings":";;AA6BO,SAASA,YACdC,kBAA0C;IAE1C,MAAM,EACJC,IAAI,EACJC,OAAO,EACPC,aAAa,EACbC,SAAS,EACTC,WAAW,EACXC,WAAW,KAAK,EACjB,GAAGN;IAEJ,MAAMO,WAAWC,MAAM,OAAO,CAACP,QAAQA,OAAO,EAAE;IAChD,MAAMQ,WAAWC,QAAQ,IAAMH,SAAS,GAAG,CAACI,CAAAA,OAAQA,KAAK,aAAa,KAAK;QACzEJ;KACD;IACD,MAAMK,0BAA0BC,iBAAyB;IACzD,MAAMC,kBAAkBD,iBAAwB;QAAE,GAAG;QAAG,GAAG;IAAE;IAC7D,MAAME,kBAAkBF,iBAAyB;IACjD,MAAMG,0BAA0BH,iBAAyB;IACzD,MAAMI,aAAaJ,iBAA2B,EAAE;IAChD,MAAMK,iBAAiBL,iBAAyB;IAEhD,MAAMM,mBAAmBC,YAAY,CAACC,QAAgBC;QACpD;QACA,MAAMX,OAAOR,cAAc,OAAO,CAACmB,WAAW;QAE9CX,MAAM,kBAAkB;YACtB,WAAW,GAAGU,QAAQ;QACxB;IACF,GAAG;QAAClB;KAAc;IAElB,MAAMoB,oBAAoBH,YAAY;QACpCf;IACF,GAAG;QAACA;KAAY;IAEhB,MAAMmB,kBAAkBJ,YACtB,CACEK,WACAH,YACAI;QAEA;QACAC,gBAAgBJ;QAChBT,gBAAgB,OAAO,GAAGW;QAC1BR,WAAW,OAAO,CAAC,IAAI,CAACK;QACxBH,iBAAiB,OAAOG;QACxBM,OAAOtB,UAAU,sBAAsBoB;IACzC,GACA;QAACH;QAAmBT;QAAiBG;QAAYE;KAAiB;IAGpE,MAAMU,2BAGqCT,YACzC,CAACU,gBAAgBR;QACf;Q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GACA;QAACA;QAAaE;QAAaP;KAAU;IAGvC,OAAO;QACLjC;QACA+B;QACAc;IACF;AACF"}
1
+ {"version":3,"file":"useSortable.jsx","sources":["webpack://@lynx-js/lynx-ui-sortable/./src/useSortable.tsx"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport {\n runOnBackground,\n useCallback,\n useMainThreadRef,\n useMemo,\n} from '@lynx-js/react'\nimport type { MainThreadRef, RefObject } from '@lynx-js/react'\n\nimport { mtsLog } from '@lynx-js/lynx-ui-common'\nimport type { Point } from '@lynx-js/lynx-ui-common'\nimport type { DraggableRef } from '@lynx-js/lynx-ui-draggable'\nimport type { MainThread } from '@lynx-js/types'\n\nimport type { SortableData } from './types'\n\ninterface SortableOptionsType<T> {\n data: SortableData<T>[] // sorting key array\n sizeMap: MainThreadRef<Record<string, number>> // sorting key -> size\n itemRefMap: RefObject<Record<string, DraggableRef | null>>\n itemMTSRefMap: MainThreadRef<Record<string, DraggableRef | null>> // sortingKey -> element Ref\n dirtyKeysRef: MainThreadRef<Record<string, boolean>>\n disabledKeysRef: MainThreadRef<Record<string, boolean>>\n onDragEnd?: (sortedKeyArray: SortableData<T>[]) => void\n onDragStart?: () => void\n debugLog?: boolean\n}\n\nexport function useSortable<T>(\n useSortableOptions: SortableOptionsType<T>,\n) {\n const {\n data,\n sizeMap,\n itemMTSRefMap,\n dirtyKeysRef,\n disabledKeysRef,\n onDragEnd,\n onDragStart,\n debugLog = false,\n } = useSortableOptions\n\n const safeData = Array.isArray(data) ? data : []\n const keyArray = useMemo(() => safeData.map(item => item.getSortingKey()), [\n safeData,\n ])\n const swapConfirmedPercentage = useMainThreadRef<number>(0.5)\n const touchStartPoint = useMainThreadRef<Point>({ x: 0, y: 0 })\n const lastSwappingKey = useMainThreadRef<string>('')\n const swappingItemTranslation = useMainThreadRef<number>(0)\n const lastCrossedDisabledSize = useMainThreadRef<number>(0)\n const changedKey = useMainThreadRef<string[]>([]) // Store all the moved item. Remember to reset them\n const lastSwappedKey = useMainThreadRef<string>('') // Store the last swapped item. Use it to do the sorting.\n\n const changeItemZIndex = useCallback((zIndex: number, sortingKey: string) => {\n 'main thread'\n const item = itemMTSRefMap.current[sortingKey]\n\n item?.MTSSetOtherStyles({\n 'z-index': `${zIndex}`,\n })\n dirtyKeysRef.current[sortingKey] = true\n }, [itemMTSRefMap, dirtyKeysRef])\n\n const handleDragStartJS = useCallback(() => {\n onDragStart?.()\n }, [onDragStart])\n\n const handleDragStart = useCallback(\n (\n pagePoint: Point,\n sortingKey: string,\n event: MainThread.MouseEvent | MainThread.TouchEvent,\n ) => {\n 'main thread'\n runOnBackground(handleDragStartJS)()\n touchStartPoint.current = pagePoint\n changedKey.current.push(sortingKey)\n changeItemZIndex(10000, sortingKey)\n mtsLog(debugLog, '[event drag start]', event)\n },\n [handleDragStartJS, touchStartPoint, changedKey, changeItemZIndex],\n )\n\n const swappingIndexAndDistance: (\n movingDistance: number,\n sortingKey: string,\n ) => { index: number, distance: number, crossedDisabledSize: number } =\n useCallback(\n (movingDistance, sortingKey) => {\n 'main thread'\n const index = keyArray.indexOf(sortingKey)\n if (keyArray.length === 0 || index < 0 || index >= keyArray.length) {\n mtsLog(debugLog, '[swappingIndexAndDistance] invalid index', index)\n return { index: -1, distance: 0, crossedDisabledSize: 0 }\n }\n\n const absDistance = Math.abs(movingDistance)\n const direction = movingDistance > 0 ? 1 : -1\n let currentIndex = index + direction\n let accumulatedDistance = 0\n // The total size of the contiguous disabled (locked) items immediately\n // preceding the current candidate movable, i.e. the disabled gap\n // between the previous movable neighbor (or the drag start) and the\n // movable we are about to evaluate. Every time we pass a movable\n // without picking it as the swap target, this gap resets to 0, so\n // each potential swap target only sees the locked items strictly\n // between it and its previous movable neighbor — never a cumulative\n // total from the drag origin.\n let disabledGap = 0\n while (true) {\n if (currentIndex < 0 || currentIndex >= keyArray.length) {\n return {\n index: -1,\n distance: (movingDistance > 0 ? 1 : -1)\n * (absDistance - accumulatedDistance),\n crossedDisabledSize: disabledGap,\n }\n }\n const currentKey = keyArray[currentIndex]\n // Disabled (locked) items are never picked as a swap candidate and\n // never displaced. The dragged item is allowed to cross over them by\n // skipping past while still consuming their height, so the dragged\n // item's physical displacement keeps in sync with `accumulatedDistance`\n // and the disabled item's absolute position is preserved.\n if (disabledKeysRef.current[currentKey]) {\n const disabledSize = sizeMap.current[currentKey]\n if (typeof disabledSize !== 'number') {\n mtsLog(\n debugLog,\n `[swappingIndexAndDistance] disabled item size not found for key ${currentKey}, stopping at index ${currentIndex}.`,\n )\n return {\n index: -1,\n distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance,\n crossedDisabledSize: disabledGap,\n }\n }\n // The dragged item is still physically over this disabled item,\n // so no swap target should be produced yet.\n if (accumulatedDistance + disabledSize >= absDistance) {\n mtsLog(\n debugLog,\n `[swappingIndexAndDistance] still over disabled item ${currentKey} at index ${currentIndex}.`,\n )\n return {\n index: -1,\n distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance,\n crossedDisabledSize: disabledGap,\n }\n }\n mtsLog(\n debugLog,\n `[swappingIndexAndDistance] cross disabled item ${currentKey} at index ${currentIndex}.`,\n )\n accumulatedDistance += disabledSize\n disabledGap += disabledSize\n currentIndex += direction\n continue\n }\n const size = sizeMap.current[currentKey]\n if (typeof size !== 'number') {\n mtsLog(\n debugLog,\n `[swappingIndexAndDistance] item size not found for key ${sortingKey}, stopping at index ${currentIndex}.`,\n )\n return {\n index: -1,\n distance: (movingDistance > 0 ? 1 : -1) * accumulatedDistance,\n crossedDisabledSize: disabledGap,\n }\n }\n accumulatedDistance += size\n\n if (accumulatedDistance >= absDistance) {\n return {\n index: currentIndex,\n // This distance is the remained dragging distance needs to be consumed by current interacting item.\n // E.g.: the total delta is 458 and all item is all 100px tall. Then the first 400 will be consumed the previous clamped items. And the 58 is current interacting item.\n distance: (movingDistance > 0 ? 1 : -1)\n * (accumulatedDistance - size),\n // Only the disabled items strictly between the previous movable\n // neighbor and this swap target. Locked items further back have\n // already been accounted for when their own following movable\n // became (and was clamped as) a swap target.\n crossedDisabledSize: disabledGap,\n }\n }\n // We just passed this movable without choosing it as the swap target,\n // so the disabled gap \"in front of\" the next candidate restarts here.\n disabledGap = 0\n currentIndex += direction\n }\n },\n [keyArray, sizeMap, disabledKeysRef],\n )\n\n const setTransform = useCallback(\n (key: string, translate: number) => {\n 'main thread'\n\n const item = key ? itemMTSRefMap.current[key] : null\n item?.MTSSetTransform(0, translate)\n if (key) {\n dirtyKeysRef.current[key] = true\n }\n },\n [itemMTSRefMap, dirtyKeysRef],\n )\n\n // Clamp the previous interacting item to the grid\n const clampPreviousItem = (movingDistance: number, sortingKey: string) => {\n 'main thread'\n mtsLog(\n debugLog,\n `clamp ${lastSwappingKey.current} to grid`,\n )\n const draggingItemSize = sizeMap.current[sortingKey]\n if (lastSwappingKey.current !== null) {\n const lastSwappingItemKey = lastSwappingKey.current\n if (\n Math.abs(swappingItemTranslation.current)\n > draggingItemSize * swapConfirmedPercentage.current\n ) {\n // The previous swap target's \"swapped\" position must include the\n // height of any disabled items the dragged item had crossed over to\n // reach it; otherwise it would visually overlap with the (still\n // in-place) disabled items after we leave it behind.\n setTransform(\n lastSwappingItemKey,\n (movingDistance < 0 ? 1 : -1)\n * (draggingItemSize + lastCrossedDisabledSize.current),\n )\n } else {\n setTransform(lastSwappingItemKey, 0)\n }\n }\n }\n\n const updateLastSwappingItem = (\n movingDistance: number,\n sortingKey: string,\n swappingKey: string,\n ) => {\n 'main thread'\n mtsLog(\n debugLog,\n `interact item from ${lastSwappingKey.current} to ${swappingKey}`,\n )\n clampPreviousItem(movingDistance, sortingKey)\n lastSwappingKey.current = swappingKey\n }\n\n // Update the confirmed interacting ID if the condition is met\n const updateConfirmedInteractedID = (\n unconsumedDistance: number,\n sortingKey: string,\n ) => {\n 'main thread'\n mtsLog(\n debugLog,\n `swapping with ${lastSwappingKey.current} at ${unconsumedDistance}`,\n )\n const draggingItemSize = sizeMap.current[sortingKey]\n if (\n Math.abs(unconsumedDistance)\n > draggingItemSize * swapConfirmedPercentage.current\n ) {\n lastSwappedKey.current = lastSwappingKey.current\n mtsLog(\n debugLog,\n `confirmed swapping with ${lastSwappedKey.current} at cross ${unconsumedDistance}`,\n )\n } else if (lastSwappedKey.current === lastSwappingKey.current) {\n // Handle case when dragging back over a previously swapped item\n const swappingIndex = keyArray.indexOf(lastSwappingKey.current)\n const draggedItemIndex = keyArray.indexOf(sortingKey)\n\n // Get new swap candidate index based on drag direction reversal\n // Drag down → reverse up: `swappingIndex - 1`\n // Drag up → reverse down: `swappingIndex + 1`\n const indexModifier = swappingIndex > draggedItemIndex ? -1 : 1\n const newSwappedKeyIndex = swappingIndex + indexModifier\n\n // The logic should prevent out-of-bounds access, but as a safeguard:\n if (newSwappedKeyIndex >= 0 && newSwappedKeyIndex < keyArray.length) {\n const newSwappedKey = keyArray[newSwappedKeyIndex]\n\n // If new candidate's index matches dragged item's index, item returned to original position; no swap confirmed.\n if (newSwappedKeyIndex === draggedItemIndex) {\n lastSwappedKey.current = ''\n } else {\n lastSwappedKey.current = newSwappedKey\n }\n } else {\n // Item is returning to original position when reverting swap at list start/end.\n lastSwappedKey.current = ''\n }\n\n mtsLog(\n debugLog,\n `Reverted swap with ${lastSwappingKey.current}. New confirmed swap is with ${\n lastSwappedKey.current || 'none'\n }.`,\n )\n }\n swappingItemTranslation.current = unconsumedDistance\n }\n\n const switchHandler = useCallback(\n (movingDistance: number, sortingKey: string) => {\n 'main thread'\n const {\n index: swappingIndex,\n distance: consumedDistance,\n crossedDisabledSize = 0,\n } = swappingIndexAndDistance(movingDistance, sortingKey)\n mtsLog(\n debugLog,\n 'swappingIndexAndDistance',\n swappingIndex,\n consumedDistance,\n crossedDisabledSize,\n )\n if (swappingIndex < 0) {\n clampPreviousItem(consumedDistance, sortingKey)\n return\n }\n const swappingKey = keyArray[swappingIndex]\n\n if (swappingKey !== lastSwappingKey.current) {\n updateLastSwappingItem(movingDistance, sortingKey, swappingKey)\n changedKey.current.push(swappingKey)\n }\n\n const unconsumedDistance = movingDistance - consumedDistance\n updateConfirmedInteractedID(unconsumedDistance, sortingKey)\n // When the dragged item has crossed over disabled items, those items do\n // not translate. To avoid the swap target jumping, scale its translate\n // proportionally as the dragged item progresses over it: while the\n // dragged item moves `swappingItemSize` over the swap target, the swap\n // target translates `swappingItemSize + crossedDisabledSize`, ending\n // exactly at the dragged item's original slot without any jump.\n const swappingItemSize = sizeMap.current[swappingKey] ?? 0\n const speedMultiplier = swappingItemSize > 0\n ? (swappingItemSize + crossedDisabledSize) / swappingItemSize\n : 1\n setTransform(swappingKey, -unconsumedDistance * speedMultiplier)\n lastCrossedDisabledSize.current = crossedDisabledSize\n },\n [\n changedKey,\n itemMTSRefMap,\n keyArray,\n lastSwappingKey,\n setTransform,\n swappingIndexAndDistance,\n updateConfirmedInteractedID,\n updateLastSwappingItem,\n ],\n )\n\n const handleDragMove = useCallback(\n (\n delta: Point,\n sortingKey: string,\n event: MainThread.MouseEvent | MainThread.TouchEvent,\n ) => {\n 'main thread'\n switchHandler(delta.y, sortingKey)\n changeItemZIndex(10000, sortingKey)\n mtsLog(debugLog, '[event drag move]', event)\n },\n [switchHandler, changeItemZIndex],\n )\n\n const sortArray = useCallback((sortingKey: string) => {\n 'main thread'\n const draggingIndex = keyArray.indexOf(sortingKey)\n const swappedIndex = keyArray.indexOf(lastSwappedKey.current)\n\n mtsLog(debugLog, 'sortArray with lastSwappedKey ', lastSwappedKey.current)\n\n if (\n draggingIndex === -1 || swappedIndex === -1\n || draggingIndex === swappedIndex\n ) {\n return [...keyArray]\n }\n\n // Disabled items must keep their absolute positions in the result. We\n // splice only the movable (non-disabled) sequence and then reinsert\n // disabled items at their original indices.\n const disabledIndices: Record<number, string> = {}\n const movableKeys: string[] = []\n for (let i = 0; i < keyArray.length; i++) {\n const k = keyArray[i]\n if (disabledKeysRef.current[k]) {\n disabledIndices[i] = k\n } else {\n movableKeys.push(k)\n }\n }\n const movableDraggingIdx = movableKeys.indexOf(sortingKey)\n const movableSwappedIdx = movableKeys.indexOf(lastSwappedKey.current)\n if (movableDraggingIdx === -1 || movableSwappedIdx === -1) {\n return [...keyArray]\n }\n const [draggedItem] = movableKeys.splice(movableDraggingIdx, 1)\n movableKeys.splice(movableSwappedIdx, 0, draggedItem)\n const result: string[] = []\n let cursor = 0\n for (let i = 0; i < keyArray.length; i++) {\n if (disabledIndices[i] === undefined) {\n result.push(movableKeys[cursor])\n cursor++\n } else {\n result.push(disabledIndices[i])\n }\n }\n return result\n }, [keyArray, lastSwappedKey, disabledKeysRef])\n\n const resetSwapTrackingRefs = useCallback(() => {\n 'main thread'\n lastSwappedKey.current = ''\n lastSwappingKey.current = ''\n swappingItemTranslation.current = 0\n lastCrossedDisabledSize.current = 0\n changedKey.current = []\n }, [\n changedKey,\n lastSwappedKey,\n lastSwappingKey,\n swappingItemTranslation,\n lastCrossedDisabledSize,\n ])\n\n const resetStatus = useCallback((draggingKey?: string) => {\n 'main thread'\n changedKey.current.map((key: string) => {\n if (key === draggingKey) {\n return\n }\n const item = itemMTSRefMap?.current?.[key]\n if (!item) {\n return\n }\n if (typeof item.MTSSetTransform === 'function') {\n item.MTSSetTransform(0, 0)\n }\n if (typeof item.MTSResetInternalTranslateValues === 'function') {\n item.MTSResetInternalTranslateValues()\n }\n })\n resetSwapTrackingRefs()\n }, [changedKey, itemMTSRefMap, resetSwapTrackingRefs])\n\n const rootDragEnd = useCallback((sortedKey: string[]) => {\n const keyToItemMap = new Map(data.map((item, index) => {\n return [keyArray[index], item]\n }))\n const sortedData = sortedKey\n .map(key => keyToItemMap.get(key))\n .filter((item): item is NonNullable<typeof item> => !!item)\n onDragEnd?.(sortedData)\n }, [data, keyArray, onDragEnd])\n\n const handleDragEnd = useCallback(\n (\n sortingKey: string,\n event: MainThread.MouseEvent | MainThread.TouchEvent,\n ): boolean => {\n 'main thread'\n mtsLog(debugLog, '[event drag end]', event)\n const sortedKey = sortArray(sortingKey)\n let orderChanged = sortedKey.length !== keyArray.length\n if (!orderChanged) {\n for (let i = 0; i < sortedKey.length; i++) {\n if (sortedKey[i] !== keyArray[i]) {\n orderChanged = true\n break\n }\n }\n }\n if (orderChanged) {\n // data will be updated by consumer -> usePreCommit will reset dirty items\n runOnBackground(rootDragEnd)(sortedKey)\n // dom transforms are reset by usePreCommit, but swap tracking refs\n // must be cleared synchronously to avoid stale state on next drag\n resetSwapTrackingRefs()\n } else {\n // no data update -> no precommit -> reset dirty items synchronously here\n resetStatus(sortingKey)\n runOnBackground(rootDragEnd)(sortedKey)\n }\n return orderChanged\n },\n [keyArray, resetStatus, resetSwapTrackingRefs, rootDragEnd, sortArray],\n )\n\n return {\n handleDragStart,\n handleDragMove,\n handleDragEnd,\n }\n}\n"],"names":["useSortable","useSortableOptions","data","sizeMap","itemMTSRefMap","dirtyKeysRef","disabledKeysRef","onDragEnd","onDragStart","debugLog","safeData","Array","keyArray","useMemo","item","swapConfirmedPercentage","useMainThreadRef","touchStartPoint","lastSwappingKey","swappingItemTranslation","lastCrossedDisabledSize","changedKey","lastSwappedKey","changeItemZIndex","useCallback","zIndex","sortingKey","handleDragStartJS","handleDragStart","pagePoint","event","runOnBackground","mtsLog","swappingIndexAndDistance","movingDistance","index","absDistance","Math","direction","currentIndex","accumulatedDistance","disabledGap","currentKey","disabledSize","size","setTransform","key","translate","clampPreviousItem","draggingItemSize","lastSwappingItemKey","updateLastSwappingItem","swappingKey","updateConfirmedInteractedID","unconsumedDistance","swappingIndex","draggedItemIndex","indexModifier","newSwappedKeyIndex","newSwappedKey","switchHandler","consumedDistance","crossedDisabledSize","swappingItemSize","speedMultiplier","handleDragMove","delta","sortArray","draggingIndex","swappedIndex","disabledIndices","movableKeys","i","k","movableDraggingIdx","movableSwappedIdx","draggedItem","result","cursor","undefined","resetSwapTrackingRefs","resetStatus","draggingKey","rootDragEnd","sortedKey","keyToItemMap","Map","sortedData","handleDragEnd","orderChanged"],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
1
1
  {
2
2
  "name": "@lynx-js/lynx-ui-sortable",
3
- "version": "3.133.1",
3
+ "version": "3.135.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lynx-family/lynx-ui.git",