dhre-ui-kit 0.0.189 → 0.0.191
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.d.ts +2 -0
- package/lib/index.js +53 -5
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +53 -5
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -629,6 +629,8 @@ interface CustomDropdownProps {
|
|
|
629
629
|
itemTextStyle?: TextStyle;
|
|
630
630
|
onValueChange?: (value: string) => void;
|
|
631
631
|
itemContainerStyle?: ViewStyle;
|
|
632
|
+
keepPlaceholderOnFocus?: boolean;
|
|
633
|
+
selectedItemTextStyle?: TextStyle;
|
|
632
634
|
menuContainerStyle?: ViewStyle;
|
|
633
635
|
activeColor?: string;
|
|
634
636
|
renderRightIcon?: (visible?: boolean) => JSX.Element | null | undefined;
|
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: () =>
|
|
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: () =>
|
|
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: () =>
|
|
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)
|
|
@@ -3396,7 +3418,9 @@ const CustomDropdown = (props) => {
|
|
|
3396
3418
|
onValueChange,
|
|
3397
3419
|
itemContainerStyle,
|
|
3398
3420
|
menuContainerStyle,
|
|
3399
|
-
activeColor
|
|
3421
|
+
activeColor,
|
|
3422
|
+
keepPlaceholderOnFocus = false,
|
|
3423
|
+
selectedItemTextStyle
|
|
3400
3424
|
} = props;
|
|
3401
3425
|
const [value, setValue] = React.useState(defaultValue);
|
|
3402
3426
|
const [isFocus, setIsFocus] = React.useState(false);
|
|
@@ -3424,6 +3448,22 @@ const CustomDropdown = (props) => {
|
|
|
3424
3448
|
onValueChange(newValue);
|
|
3425
3449
|
}
|
|
3426
3450
|
};
|
|
3451
|
+
const renderItem = (item) => {
|
|
3452
|
+
const isSelected = item[valueField] === value;
|
|
3453
|
+
return /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: [styles$7.itemContainer, itemContainerStyle] }, /* @__PURE__ */ React__default["default"].createElement(
|
|
3454
|
+
reactNative.Text,
|
|
3455
|
+
{
|
|
3456
|
+
style: [
|
|
3457
|
+
styles$7.itemText,
|
|
3458
|
+
itemTextStyle,
|
|
3459
|
+
// Apply itemTextStyle to all items
|
|
3460
|
+
isSelected && selectedItemTextStyle
|
|
3461
|
+
// Apply selectedItemTextStyle to the selected item
|
|
3462
|
+
]
|
|
3463
|
+
},
|
|
3464
|
+
item[labelField]
|
|
3465
|
+
));
|
|
3466
|
+
};
|
|
3427
3467
|
return /* @__PURE__ */ React__default["default"].createElement(reactNative.View, { style: [styles$7.container, containerStyle] }, label && renderLabel(), /* @__PURE__ */ React__default["default"].createElement(
|
|
3428
3468
|
reactNativeElementDropdown.Dropdown,
|
|
3429
3469
|
{
|
|
@@ -3439,13 +3479,14 @@ const CustomDropdown = (props) => {
|
|
|
3439
3479
|
data: data ?? [],
|
|
3440
3480
|
labelField,
|
|
3441
3481
|
valueField,
|
|
3442
|
-
placeholder: !isFocus ? placeholder : "",
|
|
3482
|
+
placeholder: keepPlaceholderOnFocus || !isFocus ? placeholder : "",
|
|
3443
3483
|
value,
|
|
3444
3484
|
onFocus: () => setIsFocus(true),
|
|
3445
3485
|
onBlur: () => setIsFocus(false),
|
|
3446
3486
|
onChange: handleValueChange,
|
|
3447
3487
|
iconColor,
|
|
3448
3488
|
dropdownPosition: "bottom",
|
|
3489
|
+
renderItem,
|
|
3449
3490
|
itemTextStyle,
|
|
3450
3491
|
containerStyle: menuContainerStyle,
|
|
3451
3492
|
activeColor,
|
|
@@ -3488,6 +3529,13 @@ const styles$7 = reactNative.StyleSheet.create({
|
|
|
3488
3529
|
},
|
|
3489
3530
|
itemListStyle: {
|
|
3490
3531
|
maxHeight: verticalScale(150)
|
|
3532
|
+
},
|
|
3533
|
+
itemContainer: {
|
|
3534
|
+
paddingVertical: verticalScale(8),
|
|
3535
|
+
paddingHorizontal: horizontalScale(12)
|
|
3536
|
+
},
|
|
3537
|
+
itemText: {
|
|
3538
|
+
fontSize: verticalScale(14)
|
|
3491
3539
|
}
|
|
3492
3540
|
});
|
|
3493
3541
|
|