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.mjs
CHANGED
|
@@ -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)
|
|
@@ -3363,7 +3385,9 @@ const CustomDropdown = (props) => {
|
|
|
3363
3385
|
onValueChange,
|
|
3364
3386
|
itemContainerStyle,
|
|
3365
3387
|
menuContainerStyle,
|
|
3366
|
-
activeColor
|
|
3388
|
+
activeColor,
|
|
3389
|
+
keepPlaceholderOnFocus = false,
|
|
3390
|
+
selectedItemTextStyle
|
|
3367
3391
|
} = props;
|
|
3368
3392
|
const [value, setValue] = useState(defaultValue);
|
|
3369
3393
|
const [isFocus, setIsFocus] = useState(false);
|
|
@@ -3391,6 +3415,22 @@ const CustomDropdown = (props) => {
|
|
|
3391
3415
|
onValueChange(newValue);
|
|
3392
3416
|
}
|
|
3393
3417
|
};
|
|
3418
|
+
const renderItem = (item) => {
|
|
3419
|
+
const isSelected = item[valueField] === value;
|
|
3420
|
+
return /* @__PURE__ */ React.createElement(View, { style: [styles$7.itemContainer, itemContainerStyle] }, /* @__PURE__ */ React.createElement(
|
|
3421
|
+
Text,
|
|
3422
|
+
{
|
|
3423
|
+
style: [
|
|
3424
|
+
styles$7.itemText,
|
|
3425
|
+
itemTextStyle,
|
|
3426
|
+
// Apply itemTextStyle to all items
|
|
3427
|
+
isSelected && selectedItemTextStyle
|
|
3428
|
+
// Apply selectedItemTextStyle to the selected item
|
|
3429
|
+
]
|
|
3430
|
+
},
|
|
3431
|
+
item[labelField]
|
|
3432
|
+
));
|
|
3433
|
+
};
|
|
3394
3434
|
return /* @__PURE__ */ React.createElement(View, { style: [styles$7.container, containerStyle] }, label && renderLabel(), /* @__PURE__ */ React.createElement(
|
|
3395
3435
|
Dropdown,
|
|
3396
3436
|
{
|
|
@@ -3406,13 +3446,14 @@ const CustomDropdown = (props) => {
|
|
|
3406
3446
|
data: data ?? [],
|
|
3407
3447
|
labelField,
|
|
3408
3448
|
valueField,
|
|
3409
|
-
placeholder: !isFocus ? placeholder : "",
|
|
3449
|
+
placeholder: keepPlaceholderOnFocus || !isFocus ? placeholder : "",
|
|
3410
3450
|
value,
|
|
3411
3451
|
onFocus: () => setIsFocus(true),
|
|
3412
3452
|
onBlur: () => setIsFocus(false),
|
|
3413
3453
|
onChange: handleValueChange,
|
|
3414
3454
|
iconColor,
|
|
3415
3455
|
dropdownPosition: "bottom",
|
|
3456
|
+
renderItem,
|
|
3416
3457
|
itemTextStyle,
|
|
3417
3458
|
containerStyle: menuContainerStyle,
|
|
3418
3459
|
activeColor,
|
|
@@ -3455,6 +3496,13 @@ const styles$7 = StyleSheet.create({
|
|
|
3455
3496
|
},
|
|
3456
3497
|
itemListStyle: {
|
|
3457
3498
|
maxHeight: verticalScale(150)
|
|
3499
|
+
},
|
|
3500
|
+
itemContainer: {
|
|
3501
|
+
paddingVertical: verticalScale(8),
|
|
3502
|
+
paddingHorizontal: horizontalScale(12)
|
|
3503
|
+
},
|
|
3504
|
+
itemText: {
|
|
3505
|
+
fontSize: verticalScale(14)
|
|
3458
3506
|
}
|
|
3459
3507
|
});
|
|
3460
3508
|
|