dhre-ui-kit 0.0.189 → 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 CHANGED
@@ -2342,6 +2342,17 @@ const SwipableList = (props) => {
2342
2342
  titleStyle
2343
2343
  } = props;
2344
2344
  const { theme } = useTheme();
2345
+ const [currentOpenId, setCurrentOpenId] = React.useState(null);
2346
+ const swipeableRefs = React.useRef({});
2347
+ const closeSwipeable = (id) => {
2348
+ swipeableRefs.current[id]?.close();
2349
+ };
2350
+ const handleSwipeStart = (id) => {
2351
+ if (currentOpenId && currentOpenId !== id) {
2352
+ closeSwipeable(currentOpenId);
2353
+ }
2354
+ setCurrentOpenId(id);
2355
+ };
2345
2356
  const ActionButton = ({
2346
2357
  icon,
2347
2358
  title,
@@ -2370,7 +2381,10 @@ const SwipableList = (props) => {
2370
2381
  {
2371
2382
  icon: leftPrimaryActionIcon,
2372
2383
  title: leftPrimaryActionTitle,
2373
- onPress: () => leftPrimaryActionHandler?.(item),
2384
+ onPress: () => {
2385
+ leftPrimaryActionHandler?.(item);
2386
+ closeSwipeable(item.id);
2387
+ },
2374
2388
  style: leftPrimaryActionStyle,
2375
2389
  testID: `${testId}-LEFT-PRIMARY-${item.id}`
2376
2390
  }
@@ -2379,7 +2393,10 @@ const SwipableList = (props) => {
2379
2393
  {
2380
2394
  icon: leftSecondaryActionIcon,
2381
2395
  title: leftSecondaryActionTitle,
2382
- onPress: () => leftSecondaryActionHandler?.(item),
2396
+ onPress: () => {
2397
+ leftSecondaryActionHandler?.(item);
2398
+ closeSwipeable(item.id);
2399
+ },
2383
2400
  style: leftSecondaryActionStyle,
2384
2401
  testID: `${testId}-LEFT-SECONDARY-${item.id}`
2385
2402
  }
@@ -2389,7 +2406,10 @@ const SwipableList = (props) => {
2389
2406
  {
2390
2407
  icon: rightPrimaryActionIcon,
2391
2408
  title: rightPrimaryActionTitle || "",
2392
- onPress: () => rightPrimaryActionHandler?.(item),
2409
+ onPress: () => {
2410
+ rightPrimaryActionHandler?.(item);
2411
+ closeSwipeable(item.id);
2412
+ },
2393
2413
  style: rightPrimaryActionStyle,
2394
2414
  testID: `${testId}-RIGHT-PRIMARY-${item.id}`
2395
2415
  }
@@ -2397,6 +2417,7 @@ const SwipableList = (props) => {
2397
2417
  const renderItem = ({ item }) => /* @__PURE__ */ React__default["default"].createElement(reactNativeGestureHandler.GestureHandlerRootView, { testID: `${testId}-LIST`, style: styles$h.container }, /* @__PURE__ */ React__default["default"].createElement(
2398
2418
  reactNativeGestureHandler.Swipeable,
2399
2419
  {
2420
+ ref: (ref) => swipeableRefs.current[item.id] = ref,
2400
2421
  renderLeftActions: () => leftActionHandle(
2401
2422
  item,
2402
2423
  item.isPinned ? leftPrimaryActionInActiveIcon : leftPrimaryActionActiveIcon,
@@ -2404,6 +2425,7 @@ const SwipableList = (props) => {
2404
2425
  item.isRead ? leftSecondaryActionInActiveIcon : leftSecondaryActionActiveIcon,
2405
2426
  item.isRead ? leftSecondaryActionInActiveTitle : leftSecondaryActionActiveTitle
2406
2427
  ),
2428
+ onSwipeableWillOpen: () => handleSwipeStart(item.id),
2407
2429
  renderRightActions: () => rightActionHandle(item)
2408
2430
  },
2409
2431
  props?.renderItem(item)