dhre-ui-kit 0.0.188 → 0.0.190
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/lib/index.js +27 -5
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +27 -5
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -1995,8 +1995,8 @@ const styles$k = StyleSheet.create({
|
|
|
1995
1995
|
messageText: {
|
|
1996
1996
|
flex: 1,
|
|
1997
1997
|
color: "#fff",
|
|
1998
|
-
textAlign: "
|
|
1999
|
-
marginLeft: horizontalScale(
|
|
1998
|
+
textAlign: "left",
|
|
1999
|
+
marginLeft: horizontalScale(8)
|
|
2000
2000
|
},
|
|
2001
2001
|
button: {
|
|
2002
2002
|
marginLeft: 9
|
|
@@ -2309,6 +2309,17 @@ const SwipableList = (props) => {
|
|
|
2309
2309
|
titleStyle
|
|
2310
2310
|
} = props;
|
|
2311
2311
|
const { theme } = useTheme();
|
|
2312
|
+
const [currentOpenId, setCurrentOpenId] = useState(null);
|
|
2313
|
+
const swipeableRefs = useRef({});
|
|
2314
|
+
const closeSwipeable = (id) => {
|
|
2315
|
+
swipeableRefs.current[id]?.close();
|
|
2316
|
+
};
|
|
2317
|
+
const handleSwipeStart = (id) => {
|
|
2318
|
+
if (currentOpenId && currentOpenId !== id) {
|
|
2319
|
+
closeSwipeable(currentOpenId);
|
|
2320
|
+
}
|
|
2321
|
+
setCurrentOpenId(id);
|
|
2322
|
+
};
|
|
2312
2323
|
const ActionButton = ({
|
|
2313
2324
|
icon,
|
|
2314
2325
|
title,
|
|
@@ -2337,7 +2348,10 @@ const SwipableList = (props) => {
|
|
|
2337
2348
|
{
|
|
2338
2349
|
icon: leftPrimaryActionIcon,
|
|
2339
2350
|
title: leftPrimaryActionTitle,
|
|
2340
|
-
onPress: () =>
|
|
2351
|
+
onPress: () => {
|
|
2352
|
+
leftPrimaryActionHandler?.(item);
|
|
2353
|
+
closeSwipeable(item.id);
|
|
2354
|
+
},
|
|
2341
2355
|
style: leftPrimaryActionStyle,
|
|
2342
2356
|
testID: `${testId}-LEFT-PRIMARY-${item.id}`
|
|
2343
2357
|
}
|
|
@@ -2346,7 +2360,10 @@ const SwipableList = (props) => {
|
|
|
2346
2360
|
{
|
|
2347
2361
|
icon: leftSecondaryActionIcon,
|
|
2348
2362
|
title: leftSecondaryActionTitle,
|
|
2349
|
-
onPress: () =>
|
|
2363
|
+
onPress: () => {
|
|
2364
|
+
leftSecondaryActionHandler?.(item);
|
|
2365
|
+
closeSwipeable(item.id);
|
|
2366
|
+
},
|
|
2350
2367
|
style: leftSecondaryActionStyle,
|
|
2351
2368
|
testID: `${testId}-LEFT-SECONDARY-${item.id}`
|
|
2352
2369
|
}
|
|
@@ -2356,7 +2373,10 @@ const SwipableList = (props) => {
|
|
|
2356
2373
|
{
|
|
2357
2374
|
icon: rightPrimaryActionIcon,
|
|
2358
2375
|
title: rightPrimaryActionTitle || "",
|
|
2359
|
-
onPress: () =>
|
|
2376
|
+
onPress: () => {
|
|
2377
|
+
rightPrimaryActionHandler?.(item);
|
|
2378
|
+
closeSwipeable(item.id);
|
|
2379
|
+
},
|
|
2360
2380
|
style: rightPrimaryActionStyle,
|
|
2361
2381
|
testID: `${testId}-RIGHT-PRIMARY-${item.id}`
|
|
2362
2382
|
}
|
|
@@ -2364,6 +2384,7 @@ const SwipableList = (props) => {
|
|
|
2364
2384
|
const renderItem = ({ item }) => /* @__PURE__ */ React.createElement(GestureHandlerRootView, { testID: `${testId}-LIST`, style: styles$h.container }, /* @__PURE__ */ React.createElement(
|
|
2365
2385
|
Swipeable,
|
|
2366
2386
|
{
|
|
2387
|
+
ref: (ref) => swipeableRefs.current[item.id] = ref,
|
|
2367
2388
|
renderLeftActions: () => leftActionHandle(
|
|
2368
2389
|
item,
|
|
2369
2390
|
item.isPinned ? leftPrimaryActionInActiveIcon : leftPrimaryActionActiveIcon,
|
|
@@ -2371,6 +2392,7 @@ const SwipableList = (props) => {
|
|
|
2371
2392
|
item.isRead ? leftSecondaryActionInActiveIcon : leftSecondaryActionActiveIcon,
|
|
2372
2393
|
item.isRead ? leftSecondaryActionInActiveTitle : leftSecondaryActionActiveTitle
|
|
2373
2394
|
),
|
|
2395
|
+
onSwipeableWillOpen: () => handleSwipeStart(item.id),
|
|
2374
2396
|
renderRightActions: () => rightActionHandle(item)
|
|
2375
2397
|
},
|
|
2376
2398
|
props?.renderItem(item)
|