react-native-swappable-grid 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -7,12 +7,18 @@ A powerful React Native component for creating draggable, swappable grid layouts
7
7
  - 🎯 **Drag & Drop**: Long press to drag and reorder items in a grid layout
8
8
  - 📐 **Flexible Layout**: Automatic column calculation or fixed number of columns
9
9
  - 🎨 **Smooth Animations**: Optional wiggle animation during drag mode
10
- - 🗑️ **Delete Support**: Built-in hold-to-delete or custom delete component
10
+ - 🗑️ **Delete Support**: Built-in hold-still-to-delete or custom delete component (trashcan)
11
11
  - ➕ **Trailing Components**: Support for additional components (e.g., "Add" button)
12
12
  - 📜 **Auto-scroll**: Automatic scrolling when dragging near edges
13
13
  - 🔄 **Order Tracking**: Callbacks for order changes and drag end events
14
14
  - ⚡ **Performance**: Built with React Native Reanimated and Gesture Handler for 60fps animations
15
15
 
16
+ ## Example Project
17
+
18
+ To see common usages and examples. Check out the example project 🚀
19
+
20
+ - [react-native-swappable-grid-example-app-repo](https://github.com/WilliamDanielsson/react-native-swappable-grid-example)
21
+
16
22
  ## Installation
17
23
 
18
24
  ```bash
@@ -33,8 +39,35 @@ yarn add react react-native react-native-gesture-handler react-native-reanimated
33
39
 
34
40
  **Important**: Make sure to follow the setup instructions for:
35
41
 
36
- - [react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/docs/installation)
37
- - [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/docs/installation)
42
+ - [react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation/)
43
+ - [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/)
44
+
45
+ **TLDR**: Wrap your app with the GestureHandlerRootView inside RootLayout in \_layout.tsx
46
+
47
+ Additional fix for now: Disable Strict Mode for Reanimated because of logger warnings did I did not manage to get rid of.
48
+
49
+ ```tsx
50
+ import { Slot } from "expo-router";
51
+ import { GestureHandlerRootView } from "react-native-gesture-handler";
52
+ import {
53
+ configureReanimatedLogger,
54
+ ReanimatedLogLevel,
55
+ } from "react-native-reanimated";
56
+
57
+ // Strict mode is disabled because it gave warnings in SwappableGrid with useSharedValue()
58
+ configureReanimatedLogger({
59
+ level: ReanimatedLogLevel.warn, // Only log warnings & errors
60
+ strict: false, // Disable strict mode warnings
61
+ });
62
+
63
+ export default function RootLayout() {
64
+ return (
65
+ <GestureHandlerRootView>
66
+ <Slot />
67
+ </GestureHandlerRootView>
68
+ );
69
+ }
70
+ ```
38
71
 
39
72
  ## Basic Usage
40
73
 
@@ -54,7 +87,7 @@ const MyComponent = () => {
54
87
  <SwappableGrid
55
88
  itemWidth={100}
56
89
  itemHeight={100}
57
- numColumns={3}
90
+ numColumns={3} /* leave excluded for dynamic columns */
58
91
  gap={8}
59
92
  onOrderChange={(keys) => {
60
93
  // Reorder items based on new key order
@@ -81,36 +114,55 @@ const MyComponent = () => {
81
114
 
82
115
  ### SwappableGrid Props
83
116
 
84
- | Prop | Type | Required | Default | Description |
85
- | ------------------------ | --------------------------------------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------- |
86
- | `children` | `ReactNode` | | - | The child components to render in the grid. Each child should have a unique key. |
87
- | `itemWidth` | `number` | | - | Width of each grid item in pixels |
88
- | `itemHeight` | `number` | | - | Height of each grid item in pixels |
89
- | `gap` | `number` | | `8` | Gap between grid items in pixels |
90
- | `containerPadding` | `number` | | `8` | Padding around the container in pixels |
91
- | `longPressMs` | `number` | | `300` | Duration in milliseconds to hold before drag starts |
92
- | `numColumns` | `number` | | Auto | Number of columns in the grid. If not provided, will be calculated automatically based on container width |
93
- | `wiggle` | `{ duration: number; degrees: number }` | | - | Wiggle animation configuration when items are in drag mode or delete mode |
94
- | `onDragEnd` | `(ordered: ChildNode[]) => void` | | - | Callback fired when drag ends, providing the ordered array of child nodes |
95
- | `onOrderChange` | `(keys: string[]) => void` | | - | Callback fired when the order changes, providing an array of keys in the new order |
96
- | `onDelete` | `(key: string) => void` | | - | Callback fired when an item is deleted, providing the key of the deleted item |
97
- | `dragSizeIncreaseFactor` | `number` | | `1.06` | Factor by which the dragged item scales up |
98
- | `scrollSpeed` | `number` | | `10` | Speed of auto-scrolling when dragging near edges |
99
- | `scrollThreshold` | `number` | | `100` | Distance from edge in pixels that triggers auto-scroll |
100
- | `style` | `StyleProp<ViewStyle>` | | - | Custom style for the ScrollView container |
101
- | `trailingComponent` | `ReactNode` | | - | Component to render after all grid items (e.g., an "Add" button) |
102
- | `deleteComponent` | `ReactNode` | | - | Component to render as a delete target (shown when dragging). If provided, disables hold-to-delete feature |
103
- | `deleteComponentStyle` | `StyleProp<ViewStyle>` | | - | Custom style for the delete component. If provided, allows custom positioning |
104
- | `reverse` | `boolean` | | `false` | If true, reverses the order of items (right-to-left, bottom-to-top) |
117
+ | Prop | Type | Usage | Default | Description |
118
+ | ------------------------ | --------------------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
119
+ | `children` | `ReactNode` | Required | - | The child components to render in the grid. Each child should have a unique key. |
120
+ | `itemWidth` | `number` | Required | - | Width of each grid item in pixels |
121
+ | `itemHeight` | `number` | Required | - | Height of each grid item in pixels |
122
+ | `gap` | `number` | Optional | `8` | Gap between grid items in pixels |
123
+ | `containerPadding` | `number` | Optional | `8` | Padding around the container in pixels |
124
+ | `holdToDragMs` | `number` | Optional | `300` | Duration in milliseconds to hold before drag starts |
125
+ | `numColumns` | `number` | Optional | Auto | Number of columns in the grid. If not provided, will be calculated automatically based on container width |
126
+ | `wiggle` | `{ duration: number; degrees: number }` | Optional | - | Wiggle animation configuration when items are in drag mode |
127
+ | `wiggleDeleteMode` | `{ duration: number; degrees: number }` | Optional | - | Wiggle animation configuration specifically for delete mode. If not provided, uses 2x degrees and 0.7x duration of `wiggle` prop |
128
+ | `holdStillToDeleteMs` | `number` | Optional | `1000` | Duration in milliseconds to hold an item still before entering delete mode |
129
+ | `onDragEnd` | `(ordered: ChildNode[]) => void` | Optional | - | Callback fired when drag ends, providing the ordered array of child nodes |
130
+ | `onOrderChange` | `(keys: string[]) => void` | Optional | - | Callback fired when the order changes, providing an array of keys in the new order |
131
+ | `onDelete` | `(key: string) => void` | Optional | - | Callback fired when an item is deleted, providing the key of the deleted item |
132
+ | `dragSizeIncreaseFactor` | `number` | Optional | `1.06` | Factor by which the dragged item scales up |
133
+ | `scrollSpeed` | `number` | Optional | `10` | Speed of auto-scrolling when dragging near edges |
134
+ | `scrollThreshold` | `number` | Optional | `100` | Distance from edge in pixels that triggers auto-scroll |
135
+ | `style` | `StyleProp<ViewStyle>` | Optional | - | Custom style for the ScrollView container |
136
+ | `trailingComponent` | `ReactNode` | Optional | - | Component to render after all grid items (e.g., an "Add" button) |
137
+ | `deleteComponent` | `ReactNode` | Optional | - | Component to render as a delete target (shown when dragging), kind of like a trashcan feature. If provided, disables hold-still-to-delete feature |
138
+ | `deleteComponentStyle` | `StyleProp<ViewStyle>` | Optional | - | Custom style for the delete component. If provided, allows custom positioning |
139
+ | `reverse` | `boolean` | Optional | `false` | If true, reverses the order of items (right-to-left, bottom-to-top) |
105
140
 
106
141
  ### SwappableGridRef
107
142
 
108
143
  The component can be used with a ref to access imperative methods:
109
144
 
145
+ Very useful interactive feature for canceling deleteMode when clicking outside the grid. See [example project](<https://github.com/WilliamDanielsson/react-native-swappable-grid-example/blob/main/app/(tabs)/holdToDelete/index.tsx>) for example usage.
146
+
110
147
  ```tsx
148
+ import { StyleSheet, Pressable} from "react-native";
149
+ import { SwappableGrid, SwappableGridRef } from "react-native-swappable-grid";
150
+
111
151
  const gridRef = useRef<SwappableGridRef>(null);
112
152
 
113
- <SwappableGrid ref={gridRef} ... />
153
+ return (
154
+ <Pressable
155
+ style={StyleSheet.absoluteFill}
156
+ onPress={() => {
157
+ // Cancel delete mode when user taps outside the grid
158
+ if (gridRef.current) {
159
+ gridRef.current.cancelDeleteMode();
160
+ }
161
+ }}
162
+ >
163
+ <SwappableGrid ref={gridRef} ... />
164
+ </Pressable>
165
+ )
114
166
 
115
167
  // Cancel delete mode programmatically
116
168
  gridRef.current?.cancelDeleteMode();
@@ -128,7 +180,7 @@ gridRef.current?.cancelDeleteMode();
128
180
  <SwappableGrid
129
181
  itemWidth={100}
130
182
  itemHeight={100}
131
- numColumns={3}
183
+ numColumns={3} /* leave excluded for dynamic columns */
132
184
  wiggle={{ duration: 200, degrees: 3 }}
133
185
  onOrderChange={(keys) => console.log("New order:", keys)}
134
186
  >
@@ -138,45 +190,16 @@ gridRef.current?.cancelDeleteMode();
138
190
  </SwappableGrid>
139
191
  ```
140
192
 
141
- ### With Delete Functionality (Hold-to-Delete)
142
-
143
- ```tsx
144
- <SwappableGrid
145
- itemWidth={100}
146
- itemHeight={100}
147
- numColumns={3}
148
- onDelete={(key) => {
149
- setItems(items.filter((item) => item.id !== key));
150
- }}
151
- >
152
- {items.map((item) => (
153
- <View key={item.id}>{item.content}</View>
154
- ))}
155
- </SwappableGrid>
156
- ```
157
-
158
- ### With Delete Component
193
+ ### Auto-calculated Columns
159
194
 
160
195
  ```tsx
161
196
  <SwappableGrid
162
197
  itemWidth={100}
163
198
  itemHeight={100}
164
- numColumns={3}
165
- deleteComponent={
166
- <View
167
- style={{
168
- backgroundColor: "red",
169
- borderRadius: 8,
170
- justifyContent: "center",
171
- alignItems: "center",
172
- }}
173
- >
174
- <Text style={{ color: "white" }}>Drop to Delete</Text>
175
- </View>
176
- }
177
- onDelete={(key) => {
178
- setItems(items.filter((item) => item.id !== key));
179
- }}
199
+ gap={12}
200
+ containerPadding={16}
201
+ // numColumns not provided - will be calculated automatically
202
+ onOrderChange={(keys) => console.log("New order:", keys)}
180
203
  >
181
204
  {items.map((item) => (
182
205
  <View key={item.id}>{item.content}</View>
@@ -192,6 +215,7 @@ gridRef.current?.cancelDeleteMode();
192
215
  itemHeight={100}
193
216
  numColumns={3}
194
217
  trailingComponent={
218
+ /* trailingComponent gets positioned at the end of the grid */
195
219
  <Pressable
196
220
  onPress={() => addNewItem()}
197
221
  style={{
@@ -211,16 +235,19 @@ gridRef.current?.cancelDeleteMode();
211
235
  </SwappableGrid>
212
236
  ```
213
237
 
214
- ### Auto-calculated Columns
238
+ ### With Delete Functionality (Hold-still-to-Delete)
239
+
240
+ **Note**: Hold-still-to-delete is only enabled when `onDelete` is provided. If you don't want deletion functionality, simply omit the `onDelete` prop.
215
241
 
216
242
  ```tsx
217
243
  <SwappableGrid
218
244
  itemWidth={100}
219
245
  itemHeight={100}
220
- gap={12}
221
- containerPadding={16}
222
- // numColumns not provided - will be calculated automatically
223
- onOrderChange={(keys) => console.log("New order:", keys)}
246
+ numColumns={3}
247
+ holdStillToDeleteMs={1500} // Hold for 1.5 seconds to enter delete mode
248
+ onDelete={(key) => {
249
+ setItems(items.filter((item) => item.id !== key));
250
+ }}
224
251
  >
225
252
  {items.map((item) => (
226
253
  <View key={item.id}>{item.content}</View>
@@ -228,7 +255,9 @@ gridRef.current?.cancelDeleteMode();
228
255
  </SwappableGrid>
229
256
  ```
230
257
 
231
- ### Custom Delete Component Position
258
+ ### With Delete Component (custom component where you can drag items into it to delete. Kind of like a trashcan)
259
+
260
+ **Note**: By default HoldToDelete is enabled if you have a onDelete prop. If you use DeleteComponent then only DeleteComponent is used as the way to delete. In other words. You can choose to either delete items by holding or by using DeleteComponent.
232
261
 
233
262
  ```tsx
234
263
  <SwappableGrid
@@ -236,11 +265,19 @@ gridRef.current?.cancelDeleteMode();
236
265
  itemHeight={100}
237
266
  numColumns={3}
238
267
  deleteComponent={
239
- <View style={{ backgroundColor: "red", borderRadius: 8 }}>
240
- <Text>Delete</Text>
268
+ <View
269
+ style={{
270
+ backgroundColor: "red",
271
+ borderRadius: 8,
272
+ justifyContent: "center",
273
+ alignItems: "center",
274
+ }}
275
+ >
276
+ <Text style={{ color: "white" }}>Drop to Delete</Text>
241
277
  </View>
242
278
  }
243
279
  deleteComponentStyle={{
280
+ /* By default DeleteComponent acts like the TrailingComponent. Positioning itself at the end of the grid. By using deleteComponentStyle you can change it to have a static position if you want it to be at a specific place */
244
281
  position: "absolute",
245
282
  top: 20,
246
283
  right: 20,
@@ -259,11 +296,11 @@ gridRef.current?.cancelDeleteMode();
259
296
 
260
297
  ## How It Works
261
298
 
262
- 1. **Long Press**: Hold an item for `longPressMs` milliseconds to enter drag mode
299
+ 1. **Long Press**: Hold an item for `holdToDragMs` milliseconds to enter drag mode
263
300
  2. **Drag**: Move the item to swap positions with other items
264
301
  3. **Auto-scroll**: When dragging near edges, the grid automatically scrolls
265
302
  4. **Delete**:
266
- - **Hold-to-delete**: Hold an item still for 1 second to enter delete mode (shows delete button)
303
+ - **Hold-Still-to-delete**: Hold an item still for `holdStillToDeleteMs` (default: 1000ms) to enter delete mode (shows delete button). Only enabled when `onDelete` is provided.
267
304
  - **Delete component**: Drag an item to the delete component to delete it
268
305
  5. **Order Change**: The `onOrderChange` callback fires whenever items are reordered
269
306
 
@@ -271,9 +308,10 @@ gridRef.current?.cancelDeleteMode();
271
308
 
272
309
  - Each child component **must** have a unique `key` prop
273
310
  - The component uses `react-native-reanimated` for smooth 60fps animations
274
- - When `deleteComponent` is provided, the hold-to-delete feature is automatically disabled
311
+ - Deletion is only enabled when `onDelete` is provided. By default hold-still-to-delete is selected delete method. If `deleteComponent` is provided, hold-still-to-delete is automatically disabled and `deleteComponent` is used as the way to delete.
275
312
  - The trailing component is positioned after all grid items
276
313
  - The delete component appears only when dragging (if provided)
314
+ - If `wiggleDeleteMode` is not provided, delete mode wiggle uses 2x degrees and 0.7x duration of the `wiggle` prop
277
315
 
278
316
  ## License
279
317
 
@@ -16,6 +16,8 @@ function ChildWrapper({
16
16
  anyItemInDeleteMode,
17
17
  children,
18
18
  wiggle,
19
+ wiggleDeleteMode,
20
+ holdStillToDeleteMs = 1000,
19
21
  dragSizeIncreaseFactor,
20
22
  onDelete,
21
23
  disableHoldToDelete = false
@@ -118,8 +120,8 @@ function ChildWrapper({
118
120
  // Increment by ~16ms per frame (assuming 60fps)
119
121
  stillTimer.value += 16;
120
122
 
121
- // Enter delete mode after 1 second (1000ms) of being held still
122
- if (stillTimer.value >= 1000) {
123
+ // Enter delete mode after holdStillToDeleteMs of being held still
124
+ if (stillTimer.value >= holdStillToDeleteMs) {
123
125
  deleteModeActive.value = true;
124
126
  anyItemInDeleteMode.value = true; // Set global delete mode
125
127
  showDelete.value = true;
@@ -165,7 +167,18 @@ function ChildWrapper({
165
167
  inDeleteMode,
166
168
  anyInDeleteMode
167
169
  }) => {
168
- if (!wiggle) {
170
+ // Determine the target wiggle mode
171
+ let targetMode = "none";
172
+ if (inDeleteMode && (wiggleDeleteMode || wiggle)) {
173
+ targetMode = "delete";
174
+ } else if (anyInDeleteMode && !isActive && wiggle) {
175
+ targetMode = "normal";
176
+ } else if (isEditMode && !isActive && wiggle) {
177
+ targetMode = "normal";
178
+ }
179
+
180
+ // If no wiggle is configured at all, stop animation
181
+ if (!wiggle && !wiggleDeleteMode) {
169
182
  if (currentWiggleMode.value !== "none") {
170
183
  (0, _reactNativeReanimated.cancelAnimation)(rotation);
171
184
  currentWiggleMode.value = "none";
@@ -176,14 +189,28 @@ function ChildWrapper({
176
189
  return;
177
190
  }
178
191
 
179
- // Determine the target wiggle mode
180
- let targetMode = "none";
181
- if (inDeleteMode) {
182
- targetMode = "delete";
183
- } else if (anyInDeleteMode && !isActive) {
184
- targetMode = "normal";
185
- } else if (isEditMode && !isActive) {
186
- targetMode = "normal";
192
+ // If in delete mode but no wiggleDeleteMode and no wiggle, stop animation
193
+ if (targetMode === "delete" && !wiggleDeleteMode && !wiggle) {
194
+ if (currentWiggleMode.value !== "none") {
195
+ (0, _reactNativeReanimated.cancelAnimation)(rotation);
196
+ currentWiggleMode.value = "none";
197
+ }
198
+ rotation.value = (0, _reactNativeReanimated.withTiming)(0, {
199
+ duration: 150
200
+ });
201
+ return;
202
+ }
203
+
204
+ // If normal mode but no wiggle, stop animation
205
+ if (targetMode === "normal" && !wiggle) {
206
+ if (currentWiggleMode.value !== "none") {
207
+ (0, _reactNativeReanimated.cancelAnimation)(rotation);
208
+ currentWiggleMode.value = "none";
209
+ }
210
+ rotation.value = (0, _reactNativeReanimated.withTiming)(0, {
211
+ duration: 150
212
+ });
213
+ return;
187
214
  }
188
215
 
189
216
  // Only restart animation if mode changed
@@ -196,13 +223,13 @@ function ChildWrapper({
196
223
  // Cancel current animation
197
224
  (0, _reactNativeReanimated.cancelAnimation)(rotation);
198
225
 
199
- // If this item is in delete mode, wiggle more (2x degrees, faster)
226
+ // If this item is in delete mode, use wiggleDeleteMode if provided, otherwise use 2x degrees and 0.7x duration
200
227
  if (targetMode === "delete") {
201
- const deleteWiggleDegrees = wiggle.degrees * 2;
202
- const deleteWiggleDuration = wiggle.duration * 0.7; // Faster wiggle
228
+ const deleteWiggleDegrees = wiggleDeleteMode ? wiggleDeleteMode.degrees : ((wiggle === null || wiggle === void 0 ? void 0 : wiggle.degrees) ?? 0) * 2;
229
+ const deleteWiggleDuration = wiggleDeleteMode ? wiggleDeleteMode.duration : ((wiggle === null || wiggle === void 0 ? void 0 : wiggle.duration) ?? 200) * 0.7; // Faster wiggle
203
230
 
204
231
  // If transitioning from normal wiggle, preserve the phase by scaling
205
- if (previousMode === "normal") {
232
+ if (previousMode === "normal" && wiggle) {
206
233
  const currentRot = rotation.value;
207
234
  const scaleFactor = deleteWiggleDegrees / wiggle.degrees;
208
235
  rotation.value = currentRot * scaleFactor;
@@ -241,7 +268,7 @@ function ChildWrapper({
241
268
  duration: 150
242
269
  });
243
270
  }
244
- }, [dragMode, position.active, deleteModeActive, anyItemInDeleteMode]);
271
+ }, [dragMode, position.active, deleteModeActive, anyItemInDeleteMode, wiggle, wiggleDeleteMode]);
245
272
  const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
246
273
  const scale = position.active.value ? (0, _reactNativeReanimated.withTiming)(dragSizeIncreaseFactor, {
247
274
  duration: 120
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ChildWrapper","position","itemWidth","itemHeight","dragMode","anyItemInDeleteMode","children","wiggle","dragSizeIncreaseFactor","onDelete","disableHoldToDelete","rotation","useSharedValue","currentWiggleMode","previousDragMode","showDelete","deleteModeActive","stillTimer","lastX","x","value","lastY","y","frameCounter","wasReleasedAfterDeleteMode","useDerivedValue","isDragging","isActive","active","dragModeJustEnded","moved","Math","abs","deleteButtonStyle","useAnimatedStyle","shouldShow","opacity","pointerEvents","transform","scale","withTiming","duration","useAnimatedReaction","current","previous","isEditMode","inDeleteMode","anyInDeleteMode","cancelAnimation","targetMode","previousMode","deleteWiggleDegrees","degrees","deleteWiggleDuration","currentRot","scaleFactor","withRepeat","withSequence","easing","Easing","linear","animatedStyle","width","height","translateX","translateY","rotate","zIndex","isInDeleteMode","setIsInDeleteMode","useState","runOnJS","handleDelete","createElement","View","style","Pressable","onPress","top","left","right","bottom","borderRadius","justifyContent","alignItems","Text","fontSize","color","fontWeight"],"sources":["ChildWrapper.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { Text, View, Pressable } from \"react-native\";\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useAnimatedReaction,\n useSharedValue,\n withRepeat,\n withSequence,\n withTiming,\n SharedValue,\n useDerivedValue,\n cancelAnimation,\n runOnJS,\n} from \"react-native-reanimated\";\n\ntype Props = {\n position: {\n x: SharedValue<number>;\n y: SharedValue<number>;\n active: SharedValue<number>;\n };\n itemWidth: number;\n itemHeight: number;\n dragMode: SharedValue<boolean>;\n anyItemInDeleteMode: SharedValue<boolean>;\n children: React.ReactNode;\n wiggle?: { duration: number; degrees: number };\n dragSizeIncreaseFactor: number;\n onDelete?: () => void;\n disableHoldToDelete?: boolean; // If true, disable the hold-to-delete feature\n};\n\nexport default function ChildWrapper({\n position,\n itemWidth,\n itemHeight,\n dragMode,\n anyItemInDeleteMode,\n children,\n wiggle,\n dragSizeIncreaseFactor,\n onDelete,\n disableHoldToDelete = false,\n}: Props) {\n const rotation = useSharedValue(0);\n const currentWiggleMode = useSharedValue<\"none\" | \"normal\" | \"delete\">(\n \"none\"\n );\n const previousDragMode = useSharedValue(false);\n\n const showDelete = useSharedValue(false);\n const deleteModeActive = useSharedValue(false); // Persistent delete mode state\n const stillTimer = useSharedValue(0);\n const lastX = useSharedValue(position.x.value);\n const lastY = useSharedValue(position.y.value);\n const frameCounter = useSharedValue(0);\n const wasReleasedAfterDeleteMode = useSharedValue(false); // Track if item was released after entering delete mode\n\n // Timer logic that runs every frame via useDerivedValue\n useDerivedValue(() => {\n \"worklet\";\n frameCounter.value = frameCounter.value + 1;\n\n // If hold-to-delete is disabled, skip all delete mode logic\n if (disableHoldToDelete) {\n deleteModeActive.value = false;\n showDelete.value = false;\n stillTimer.value = 0;\n anyItemInDeleteMode.value = false;\n return;\n }\n\n const isDragging = dragMode.value;\n const isActive = position.active.value > 0.5;\n const x = position.x.value;\n const y = position.y.value;\n\n // Track dragMode changes for detecting touches outside\n const dragModeJustEnded = previousDragMode.value && !isDragging;\n previousDragMode.value = isDragging;\n\n // If delete mode is active, keep it active unless:\n // 1. Another item becomes active (dragMode true but this item not active)\n // 2. This item becomes active again AFTER it was released (user starts dragging it again)\n // 3. User touches outside (dragMode becomes false and no item is active)\n if (deleteModeActive.value) {\n // Check if item was released (became inactive)\n if (!isActive && !wasReleasedAfterDeleteMode.value) {\n wasReleasedAfterDeleteMode.value = true;\n }\n\n if (isDragging && !isActive) {\n // Another item is being dragged, exit delete mode\n deleteModeActive.value = false;\n anyItemInDeleteMode.value = false; // Clear global delete mode\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n } else if (isActive && wasReleasedAfterDeleteMode.value) {\n // This item became active again AFTER it was released, exit delete mode\n deleteModeActive.value = false;\n anyItemInDeleteMode.value = false; // Clear global delete mode\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n } else if (!isDragging && !isActive) {\n // Keep delete mode active (waiting for user interaction)\n // The tap gesture handler in SwappableGrid will cancel it when user taps outside\n showDelete.value = true;\n } else {\n // Keep delete mode active (item can still be held or released)\n showDelete.value = true;\n }\n return;\n }\n\n // Reset release tracking when not in delete mode\n wasReleasedAfterDeleteMode.value = false;\n\n // If not in drag mode or not active, reset timer\n if (!isDragging || !isActive) {\n stillTimer.value = 0;\n return;\n }\n\n // Item is active (being held down) - check if it's still\n // Check if position has changed significantly (more than 10px threshold)\n const moved =\n Math.abs(x - lastX.value) > 10 || Math.abs(y - lastY.value) > 10;\n\n if (moved) {\n // Reset timer if item moved while being held\n stillTimer.value = 0;\n lastX.value = x;\n lastY.value = y;\n return;\n }\n\n // Initialize last position on first frame when active\n if (stillTimer.value === 0) {\n lastX.value = x;\n lastY.value = y;\n }\n\n // If the tile hasn't moved significantly while being held → increment timer\n // Increment by ~16ms per frame (assuming 60fps)\n stillTimer.value += 16;\n\n // Enter delete mode after 1 second (1000ms) of being held still\n if (stillTimer.value >= 1000) {\n deleteModeActive.value = true;\n anyItemInDeleteMode.value = true; // Set global delete mode\n showDelete.value = true;\n wasReleasedAfterDeleteMode.value = false; // Reset on entry\n }\n });\n\n const deleteButtonStyle = useAnimatedStyle(() => {\n // Show delete button when delete mode is active (persists after release)\n const shouldShow = showDelete.value;\n return {\n opacity: shouldShow ? 1 : 0,\n pointerEvents: shouldShow ? \"auto\" : \"none\",\n transform: [\n { scale: withTiming(shouldShow ? 1 : 0.6, { duration: 120 }) },\n ],\n };\n });\n\n // Watch for when global delete mode is cancelled (user tapped outside)\n useAnimatedReaction(\n () => anyItemInDeleteMode.value,\n (current, previous) => {\n \"worklet\";\n // If delete mode was cancelled globally (user tapped outside)\n if (previous && !current && deleteModeActive.value) {\n deleteModeActive.value = false;\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n }\n }\n );\n\n // Wiggle animation — triggers on editMode/active changes and delete mode\n useAnimatedReaction(\n () => ({\n isEditMode: dragMode.value,\n isActive: position.active.value > 0.5,\n inDeleteMode: deleteModeActive.value,\n anyInDeleteMode: anyItemInDeleteMode.value,\n }),\n ({ isEditMode, isActive, inDeleteMode, anyInDeleteMode }) => {\n if (!wiggle) {\n if (currentWiggleMode.value !== \"none\") {\n cancelAnimation(rotation);\n currentWiggleMode.value = \"none\";\n }\n rotation.value = withTiming(0, { duration: 150 });\n return;\n }\n\n // Determine the target wiggle mode\n let targetMode: \"none\" | \"normal\" | \"delete\" = \"none\";\n if (inDeleteMode) {\n targetMode = \"delete\";\n } else if (anyInDeleteMode && !isActive) {\n targetMode = \"normal\";\n } else if (isEditMode && !isActive) {\n targetMode = \"normal\";\n }\n\n // Only restart animation if mode changed\n if (currentWiggleMode.value === targetMode) {\n return; // Already in the correct mode, don't restart\n }\n\n const previousMode = currentWiggleMode.value;\n currentWiggleMode.value = targetMode;\n\n // Cancel current animation\n cancelAnimation(rotation);\n\n // If this item is in delete mode, wiggle more (2x degrees, faster)\n if (targetMode === \"delete\") {\n const deleteWiggleDegrees = wiggle.degrees * 2;\n const deleteWiggleDuration = wiggle.duration * 0.7; // Faster wiggle\n\n // If transitioning from normal wiggle, preserve the phase by scaling\n if (previousMode === \"normal\") {\n const currentRot = rotation.value;\n const scaleFactor = deleteWiggleDegrees / wiggle.degrees;\n rotation.value = currentRot * scaleFactor;\n }\n\n rotation.value = withRepeat(\n withSequence(\n withTiming(deleteWiggleDegrees, {\n duration: deleteWiggleDuration,\n easing: Easing.linear,\n }),\n withTiming(-deleteWiggleDegrees, {\n duration: deleteWiggleDuration,\n easing: Easing.linear,\n })\n ),\n -1, // infinite\n true\n );\n }\n // Normal wiggle (when dragging but not this item, or any item in delete mode)\n else if (targetMode === \"normal\") {\n // If transitioning from delete wiggle, preserve the phase by scaling\n if (previousMode === \"delete\") {\n const currentRot = rotation.value;\n const scaleFactor = wiggle.degrees / (wiggle.degrees * 2);\n rotation.value = currentRot * scaleFactor;\n }\n\n rotation.value = withRepeat(\n withSequence(\n withTiming(wiggle.degrees, {\n duration: wiggle.duration,\n easing: Easing.linear,\n }),\n withTiming(-wiggle.degrees, {\n duration: wiggle.duration,\n easing: Easing.linear,\n })\n ),\n -1, // infinite\n true\n );\n }\n // Stop wiggling\n else {\n rotation.value = withTiming(0, { duration: 150 });\n }\n },\n [dragMode, position.active, deleteModeActive, anyItemInDeleteMode]\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const scale = position.active.value\n ? withTiming(dragSizeIncreaseFactor, { duration: 120 })\n : withTiming(1, { duration: 120 });\n\n return {\n position: \"absolute\",\n width: itemWidth,\n height: itemHeight,\n transform: [\n { translateX: position.x.value as any },\n { translateY: position.y.value as any },\n { scale: scale as any },\n { rotate: `${rotation.value}deg` as any },\n ],\n zIndex: position.active.value ? 2 : 0,\n } as any;\n });\n\n // Track delete mode on JS thread for conditional rendering\n const [isInDeleteMode, setIsInDeleteMode] = useState(false);\n\n useAnimatedReaction(\n () => deleteModeActive.value,\n (current) => {\n runOnJS(setIsInDeleteMode)(current);\n }\n );\n\n const handleDelete = () => {\n // Exit delete mode when delete button is pressed\n deleteModeActive.value = false;\n anyItemInDeleteMode.value = false; // Clear global delete mode\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n if (onDelete) {\n onDelete();\n }\n };\n\n return (\n <Animated.View style={animatedStyle} pointerEvents=\"box-none\">\n {/* Full-item Pressable for delete - only active when in delete mode */}\n {isInDeleteMode && (\n <Pressable\n onPress={handleDelete}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n width: itemWidth,\n height: itemHeight,\n zIndex: 2,\n }}\n />\n )}\n\n {/* Delete button (×) - visual indicator only */}\n <Animated.View\n style={[\n {\n position: \"absolute\",\n top: itemHeight * 0.01,\n right: itemWidth * 0.04,\n width: itemWidth * 0.2,\n height: itemHeight * 0.2,\n borderRadius: 12,\n justifyContent: \"center\",\n alignItems: \"center\",\n zIndex: 3,\n },\n deleteButtonStyle,\n ]}\n pointerEvents=\"none\"\n >\n <Text\n style={{\n fontSize: itemWidth * 0.2,\n color: \"black\",\n fontWeight: 500,\n }}\n >\n ×\n </Text>\n </Animated.View>\n\n {children}\n </Animated.View>\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAYiC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CA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,EAAEL,YAAa;IACtBG,KAAK,EAAE;MACL1E,QAAQ,EAAE,UAAU;MACpB6E,GAAG,EAAE,CAAC;MACNC,IAAI,EAAE,CAAC;MACPC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;MACTnB,KAAK,EAAE5D,SAAS;MAChB6D,MAAM,EAAE5D,UAAU;MAClBgE,MAAM,EAAE;IACV;EAAE,CACH,CACF,eAGD3F,MAAA,CAAAe,OAAA,CAAAkF,aAAA,CAAC7F,sBAAA,CAAAW,OAAQ,CAACmF,IAAI;IACZC,KAAK,EAAE,CACL;MACE1E,QAAQ,EAAE,UAAU;MACpB6E,GAAG,EAAE3E,UAAU,GAAG,IAAI;MACtB6E,KAAK,EAAE9E,SAAS,GAAG,IAAI;MACvB4D,KAAK,EAAE5D,SAAS,GAAG,GAAG;MACtB6D,MAAM,EAAE5D,UAAU,GAAG,GAAG;MACxB+E,YAAY,EAAE,EAAE;MAChBC,cAAc,EAAE,QAAQ;MACxBC,UAAU,EAAE,QAAQ;MACpBjB,MAAM,EAAE;IACV,CAAC,EACDlC,iBAAiB,CACjB;IACFI,aAAa,EAAC;EAAM,gBAEpB7D,MAAA,CAAAe,OAAA,CAAAkF,aAAA,CAAC9F,YAAA,CAAA0G,IAAI;IACHV,KAAK,EAAE;MACLW,QAAQ,EAAEpF,SAAS,GAAG,GAAG;MACzBqF,KAAK,EAAE,OAAO;MACdC,UAAU,EAAE;IACd;EAAE,GACH,MAEK,CACO,CAAC,EAEflF,QACY,CAAC;AAEpB","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ChildWrapper","position","itemWidth","itemHeight","dragMode","anyItemInDeleteMode","children","wiggle","wiggleDeleteMode","holdStillToDeleteMs","dragSizeIncreaseFactor","onDelete","disableHoldToDelete","rotation","useSharedValue","currentWiggleMode","previousDragMode","showDelete","deleteModeActive","stillTimer","lastX","x","value","lastY","y","frameCounter","wasReleasedAfterDeleteMode","useDerivedValue","isDragging","isActive","active","dragModeJustEnded","moved","Math","abs","deleteButtonStyle","useAnimatedStyle","shouldShow","opacity","pointerEvents","transform","scale","withTiming","duration","useAnimatedReaction","current","previous","isEditMode","inDeleteMode","anyInDeleteMode","targetMode","cancelAnimation","previousMode","deleteWiggleDegrees","degrees","deleteWiggleDuration","currentRot","scaleFactor","withRepeat","withSequence","easing","Easing","linear","animatedStyle","width","height","translateX","translateY","rotate","zIndex","isInDeleteMode","setIsInDeleteMode","useState","runOnJS","handleDelete","createElement","View","style","Pressable","onPress","top","left","right","bottom","borderRadius","justifyContent","alignItems","Text","fontSize","color","fontWeight"],"sources":["ChildWrapper.tsx"],"sourcesContent":["import React, { useEffect, useState } from \"react\";\nimport { Text, View, Pressable } from \"react-native\";\nimport Animated, {\n Easing,\n useAnimatedStyle,\n useAnimatedReaction,\n useSharedValue,\n withRepeat,\n withSequence,\n withTiming,\n SharedValue,\n useDerivedValue,\n cancelAnimation,\n runOnJS,\n} from \"react-native-reanimated\";\n\ntype Props = {\n position: {\n x: SharedValue<number>;\n y: SharedValue<number>;\n active: SharedValue<number>;\n };\n itemWidth: number;\n itemHeight: number;\n dragMode: SharedValue<boolean>;\n anyItemInDeleteMode: SharedValue<boolean>;\n children: React.ReactNode;\n wiggle?: { duration: number; degrees: number };\n wiggleDeleteMode?: { duration: number; degrees: number };\n holdStillToDeleteMs?: number;\n dragSizeIncreaseFactor: number;\n onDelete?: () => void;\n disableHoldToDelete?: boolean; // If true, disable the hold-to-delete feature\n};\n\nexport default function ChildWrapper({\n position,\n itemWidth,\n itemHeight,\n dragMode,\n anyItemInDeleteMode,\n children,\n wiggle,\n wiggleDeleteMode,\n holdStillToDeleteMs = 1000,\n dragSizeIncreaseFactor,\n onDelete,\n disableHoldToDelete = false,\n}: Props) {\n const rotation = useSharedValue(0);\n const currentWiggleMode = useSharedValue<\"none\" | \"normal\" | \"delete\">(\n \"none\"\n );\n const previousDragMode = useSharedValue(false);\n\n const showDelete = useSharedValue(false);\n const deleteModeActive = useSharedValue(false); // Persistent delete mode state\n const stillTimer = useSharedValue(0);\n const lastX = useSharedValue(position.x.value);\n const lastY = useSharedValue(position.y.value);\n const frameCounter = useSharedValue(0);\n const wasReleasedAfterDeleteMode = useSharedValue(false); // Track if item was released after entering delete mode\n\n // Timer logic that runs every frame via useDerivedValue\n useDerivedValue(() => {\n \"worklet\";\n frameCounter.value = frameCounter.value + 1;\n\n // If hold-to-delete is disabled, skip all delete mode logic\n if (disableHoldToDelete) {\n deleteModeActive.value = false;\n showDelete.value = false;\n stillTimer.value = 0;\n anyItemInDeleteMode.value = false;\n return;\n }\n\n const isDragging = dragMode.value;\n const isActive = position.active.value > 0.5;\n const x = position.x.value;\n const y = position.y.value;\n\n // Track dragMode changes for detecting touches outside\n const dragModeJustEnded = previousDragMode.value && !isDragging;\n previousDragMode.value = isDragging;\n\n // If delete mode is active, keep it active unless:\n // 1. Another item becomes active (dragMode true but this item not active)\n // 2. This item becomes active again AFTER it was released (user starts dragging it again)\n // 3. User touches outside (dragMode becomes false and no item is active)\n if (deleteModeActive.value) {\n // Check if item was released (became inactive)\n if (!isActive && !wasReleasedAfterDeleteMode.value) {\n wasReleasedAfterDeleteMode.value = true;\n }\n\n if (isDragging && !isActive) {\n // Another item is being dragged, exit delete mode\n deleteModeActive.value = false;\n anyItemInDeleteMode.value = false; // Clear global delete mode\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n } else if (isActive && wasReleasedAfterDeleteMode.value) {\n // This item became active again AFTER it was released, exit delete mode\n deleteModeActive.value = false;\n anyItemInDeleteMode.value = false; // Clear global delete mode\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n } else if (!isDragging && !isActive) {\n // Keep delete mode active (waiting for user interaction)\n // The tap gesture handler in SwappableGrid will cancel it when user taps outside\n showDelete.value = true;\n } else {\n // Keep delete mode active (item can still be held or released)\n showDelete.value = true;\n }\n return;\n }\n\n // Reset release tracking when not in delete mode\n wasReleasedAfterDeleteMode.value = false;\n\n // If not in drag mode or not active, reset timer\n if (!isDragging || !isActive) {\n stillTimer.value = 0;\n return;\n }\n\n // Item is active (being held down) - check if it's still\n // Check if position has changed significantly (more than 10px threshold)\n const moved =\n Math.abs(x - lastX.value) > 10 || Math.abs(y - lastY.value) > 10;\n\n if (moved) {\n // Reset timer if item moved while being held\n stillTimer.value = 0;\n lastX.value = x;\n lastY.value = y;\n return;\n }\n\n // Initialize last position on first frame when active\n if (stillTimer.value === 0) {\n lastX.value = x;\n lastY.value = y;\n }\n\n // If the tile hasn't moved significantly while being held → increment timer\n // Increment by ~16ms per frame (assuming 60fps)\n stillTimer.value += 16;\n\n // Enter delete mode after holdStillToDeleteMs of being held still\n if (stillTimer.value >= holdStillToDeleteMs) {\n deleteModeActive.value = true;\n anyItemInDeleteMode.value = true; // Set global delete mode\n showDelete.value = true;\n wasReleasedAfterDeleteMode.value = false; // Reset on entry\n }\n });\n\n const deleteButtonStyle = useAnimatedStyle(() => {\n // Show delete button when delete mode is active (persists after release)\n const shouldShow = showDelete.value;\n return {\n opacity: shouldShow ? 1 : 0,\n pointerEvents: shouldShow ? \"auto\" : \"none\",\n transform: [\n { scale: withTiming(shouldShow ? 1 : 0.6, { duration: 120 }) },\n ],\n };\n });\n\n // Watch for when global delete mode is cancelled (user tapped outside)\n useAnimatedReaction(\n () => anyItemInDeleteMode.value,\n (current, previous) => {\n \"worklet\";\n // If delete mode was cancelled globally (user tapped outside)\n if (previous && !current && deleteModeActive.value) {\n deleteModeActive.value = false;\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n }\n }\n );\n\n // Wiggle animation — triggers on editMode/active changes and delete mode\n useAnimatedReaction(\n () => ({\n isEditMode: dragMode.value,\n isActive: position.active.value > 0.5,\n inDeleteMode: deleteModeActive.value,\n anyInDeleteMode: anyItemInDeleteMode.value,\n }),\n ({ isEditMode, isActive, inDeleteMode, anyInDeleteMode }) => {\n // Determine the target wiggle mode\n let targetMode: \"none\" | \"normal\" | \"delete\" = \"none\";\n if (inDeleteMode && (wiggleDeleteMode || wiggle)) {\n targetMode = \"delete\";\n } else if (anyInDeleteMode && !isActive && wiggle) {\n targetMode = \"normal\";\n } else if (isEditMode && !isActive && wiggle) {\n targetMode = \"normal\";\n }\n\n // If no wiggle is configured at all, stop animation\n if (!wiggle && !wiggleDeleteMode) {\n if (currentWiggleMode.value !== \"none\") {\n cancelAnimation(rotation);\n currentWiggleMode.value = \"none\";\n }\n rotation.value = withTiming(0, { duration: 150 });\n return;\n }\n\n // If in delete mode but no wiggleDeleteMode and no wiggle, stop animation\n if (targetMode === \"delete\" && !wiggleDeleteMode && !wiggle) {\n if (currentWiggleMode.value !== \"none\") {\n cancelAnimation(rotation);\n currentWiggleMode.value = \"none\";\n }\n rotation.value = withTiming(0, { duration: 150 });\n return;\n }\n\n // If normal mode but no wiggle, stop animation\n if (targetMode === \"normal\" && !wiggle) {\n if (currentWiggleMode.value !== \"none\") {\n cancelAnimation(rotation);\n currentWiggleMode.value = \"none\";\n }\n rotation.value = withTiming(0, { duration: 150 });\n return;\n }\n\n // Only restart animation if mode changed\n if (currentWiggleMode.value === targetMode) {\n return; // Already in the correct mode, don't restart\n }\n\n const previousMode = currentWiggleMode.value;\n currentWiggleMode.value = targetMode;\n\n // Cancel current animation\n cancelAnimation(rotation);\n\n // If this item is in delete mode, use wiggleDeleteMode if provided, otherwise use 2x degrees and 0.7x duration\n if (targetMode === \"delete\") {\n const deleteWiggleDegrees = wiggleDeleteMode\n ? wiggleDeleteMode.degrees\n : (wiggle?.degrees ?? 0) * 2;\n const deleteWiggleDuration = wiggleDeleteMode\n ? wiggleDeleteMode.duration\n : (wiggle?.duration ?? 200) * 0.7; // Faster wiggle\n\n // If transitioning from normal wiggle, preserve the phase by scaling\n if (previousMode === \"normal\" && wiggle) {\n const currentRot = rotation.value;\n const scaleFactor = deleteWiggleDegrees / wiggle.degrees;\n rotation.value = currentRot * scaleFactor;\n }\n\n rotation.value = withRepeat(\n withSequence(\n withTiming(deleteWiggleDegrees, {\n duration: deleteWiggleDuration,\n easing: Easing.linear,\n }),\n withTiming(-deleteWiggleDegrees, {\n duration: deleteWiggleDuration,\n easing: Easing.linear,\n })\n ),\n -1, // infinite\n true\n );\n }\n // Normal wiggle (when dragging but not this item, or any item in delete mode)\n else if (targetMode === \"normal\") {\n // If transitioning from delete wiggle, preserve the phase by scaling\n if (previousMode === \"delete\") {\n const currentRot = rotation.value;\n const scaleFactor = wiggle.degrees / (wiggle.degrees * 2);\n rotation.value = currentRot * scaleFactor;\n }\n\n rotation.value = withRepeat(\n withSequence(\n withTiming(wiggle.degrees, {\n duration: wiggle.duration,\n easing: Easing.linear,\n }),\n withTiming(-wiggle.degrees, {\n duration: wiggle.duration,\n easing: Easing.linear,\n })\n ),\n -1, // infinite\n true\n );\n }\n // Stop wiggling\n else {\n rotation.value = withTiming(0, { duration: 150 });\n }\n },\n [\n dragMode,\n position.active,\n deleteModeActive,\n anyItemInDeleteMode,\n wiggle,\n wiggleDeleteMode,\n ]\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n const scale = position.active.value\n ? withTiming(dragSizeIncreaseFactor, { duration: 120 })\n : withTiming(1, { duration: 120 });\n\n return {\n position: \"absolute\",\n width: itemWidth,\n height: itemHeight,\n transform: [\n { translateX: position.x.value as any },\n { translateY: position.y.value as any },\n { scale: scale as any },\n { rotate: `${rotation.value}deg` as any },\n ],\n zIndex: position.active.value ? 2 : 0,\n } as any;\n });\n\n // Track delete mode on JS thread for conditional rendering\n const [isInDeleteMode, setIsInDeleteMode] = useState(false);\n\n useAnimatedReaction(\n () => deleteModeActive.value,\n (current) => {\n runOnJS(setIsInDeleteMode)(current);\n }\n );\n\n const handleDelete = () => {\n // Exit delete mode when delete button is pressed\n deleteModeActive.value = false;\n anyItemInDeleteMode.value = false; // Clear global delete mode\n showDelete.value = false;\n stillTimer.value = 0;\n wasReleasedAfterDeleteMode.value = false;\n if (onDelete) {\n onDelete();\n }\n };\n\n return (\n <Animated.View style={animatedStyle} pointerEvents=\"box-none\">\n {/* Full-item Pressable for delete - only active when in delete mode */}\n {isInDeleteMode && (\n <Pressable\n onPress={handleDelete}\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n width: itemWidth,\n height: itemHeight,\n zIndex: 2,\n }}\n />\n )}\n\n {/* Delete button (×) - visual indicator only */}\n <Animated.View\n style={[\n {\n position: \"absolute\",\n top: itemHeight * 0.01,\n right: itemWidth * 0.04,\n width: itemWidth * 0.2,\n height: itemHeight * 0.2,\n borderRadius: 12,\n justifyContent: \"center\",\n alignItems: \"center\",\n zIndex: 3,\n },\n deleteButtonStyle,\n ]}\n pointerEvents=\"none\"\n >\n <Text\n style={{\n fontSize: itemWidth * 0.2,\n color: \"black\",\n fontWeight: 500,\n }}\n >\n ×\n </Text>\n </Animated.View>\n\n {children}\n </Animated.View>\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAYiC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,C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[]}
@@ -57,12 +57,14 @@ const SwappableGrid = /*#__PURE__*/(0, _react.forwardRef)(({
57
57
  itemHeight,
58
58
  gap = 8,
59
59
  containerPadding = 8,
60
- longPressMs = 300,
60
+ holdToDragMs = 300,
61
61
  numColumns,
62
62
  onDragEnd,
63
63
  onOrderChange,
64
64
  onDelete,
65
65
  wiggle,
66
+ wiggleDeleteMode,
67
+ holdStillToDeleteMs = 1000,
66
68
  style,
67
69
  dragSizeIncreaseFactor = 1.06,
68
70
  scrollThreshold = 100,
@@ -115,7 +117,7 @@ const SwappableGrid = /*#__PURE__*/(0, _react.forwardRef)(({
115
117
  } = (0, _useGridLayout.useGridLayout)({
116
118
  reverse,
117
119
  children,
118
- longPressMs,
120
+ holdToDragMs,
119
121
  itemWidth,
120
122
  itemHeight,
121
123
  gap,
@@ -316,8 +318,10 @@ const SwappableGrid = /*#__PURE__*/(0, _react.forwardRef)(({
316
318
  dragMode: dragMode,
317
319
  anyItemInDeleteMode: anyItemInDeleteMode,
318
320
  wiggle: wiggle,
321
+ wiggleDeleteMode: wiggleDeleteMode,
322
+ holdStillToDeleteMs: holdStillToDeleteMs,
319
323
  dragSizeIncreaseFactor: dragSizeIncreaseFactor,
320
- disableHoldToDelete: !!deleteComponent,
324
+ disableHoldToDelete: !onDelete || !!deleteComponent,
321
325
  onDelete: () => {
322
326
  deleteItem(key);
323
327
  if (onDelete) {