react-native-accordion-list-view
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -84,3 +84,3 @@ "use strict"; | ||
*/ | ||
const renderItem = ({ item, index }) => (react_1.default.createElement(AccordionItem_1.default, { containerStyle: containerItemStyle, customTitle: () => customTitle(item), customBody: () => customBody(item), customIcon: customIcon, animationDuration: animationDuration, isRTL: isRTL, isOpen: checkIfOpen(item, index), onPress: (status) => { | ||
const renderItem = ({ item, index }) => (react_1.default.createElement(AccordionItem_1.default, { containerStyle: containerItemStyle, customTitle: () => customTitle(item, index), customBody: () => customBody(item, index), animationDuration: animationDuration, isRTL: isRTL, isOpen: checkIfOpen(item, index), onPress: (status) => { | ||
if (status && !expandMultiple) { | ||
@@ -90,3 +90,3 @@ setDefaultOpen([]); | ||
} | ||
}, pressableProps: pressableProps })); | ||
}, pressableProps: pressableProps, customIcon: customIcon ? () => customIcon(index) : undefined })); | ||
return react_1.default.createElement(react_native_1.FlatList, { data: data, renderItem: renderItem, keyExtractor: (item, index) => index.toString(), ...props }); | ||
@@ -93,0 +93,0 @@ }; |
@@ -19,5 +19,6 @@ import { FlatListProps, ViewStyle } from 'react-native'; | ||
* @param {any} item - The data item for the Accordion. | ||
* @param {number} [index] - The index of the item in the data array. | ||
* @returns {JSX.Element} - The React element for the title. | ||
*/ | ||
customTitle: (item: any) => JSX.Element; | ||
customTitle: (item: any, index: number) => JSX.Element; | ||
/** | ||
@@ -27,5 +28,6 @@ * Function that returns a React element to display as Accordion body. | ||
* @param {any} item - The data item for the Accordion. | ||
* @param {number} [index] - The index of the item in the data array. | ||
* @returns {JSX.Element} - The React element for the body. | ||
*/ | ||
customBody: (item: any) => JSX.Element; | ||
customBody: (item: any, index: number) => JSX.Element; | ||
/** | ||
@@ -35,5 +37,6 @@ * An optional function that returns a React element to display as Accordion icon. | ||
* @function | ||
* @param {number} [index] - The index of the item in the data array. | ||
* @returns {JSX.Element} - The React element for the icon. | ||
*/ | ||
customIcon?: () => JSX.Element; | ||
customIcon?: (index: number) => JSX.Element; | ||
/** | ||
@@ -40,0 +43,0 @@ * An optional parameter to add custom container item style. |
{ | ||
"name": "react-native-accordion-list-view", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Animated accordion collapsable List for react native.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -63,3 +63,4 @@ ## react-native-accordion-list-view | ||
### Breaking History: | ||
- [2.0.3](https://www.npmjs.com/package/react-native-accordion-list-view/v/2.0.3) - New Features | ||
We've enhanced the Accordion list by adding support for the index parameter in the customTitle, customBody, and customIcon functions. This enables greater customization possibilities, allowing you to dynamically adjust the rendering of elements based on the index of each accordion item. Explore these new parameters to tailor your accordion items more precisely to your application's requirements. | ||
- [2.0.2](https://www.npmjs.com/package/react-native-accordion-list-view/v/2.0.2) - New Features | ||
@@ -83,5 +84,5 @@ | ||
| data | Array | Yes | | For simplicity, data is a plain array. If you want to use something else, like an immutable list | | ||
| customTitle | (item) => JSX.Element | Yes | | Function that returns a React element to display as Accordion title | | ||
| customBody | (item) => JSX.Element | Yes | | Function that returns a React element to display as Accordion body | | ||
| customIcon | () => JSX.Element | No | keyboard-arrow-left | Function that returns a React element to display as Accordion icon | | ||
| customTitle | (item, index) => JSX.Element | Yes | | Function that returns a React element to display as Accordion title | | ||
| customBody | (item, index) => JSX.Element | Yes | | Function that returns a React element to display as Accordion body | | ||
| customIcon | (index) => JSX.Element | No | keyboard-arrow-left | Function that returns a React element to display as Accordion icon | | ||
| containerItemStyle | ViewStyle | No | {} | Styling for Accordion item container view | | ||
@@ -196,4 +197,4 @@ | style | ViewStyle | No | {} | Styling for container view | | ||
data={data} | ||
customTitle={item => <Text>{item.title}</Text>} | ||
customBody={item => <Text>{item.body}</Text>} | ||
customTitle={(item, index) => <Text>{item.title}</Text>} | ||
customBody={(item, index) => <Text>{item.body}</Text>} | ||
animationDuration={400} | ||
@@ -200,0 +201,0 @@ defaultOpenIndices={[0, 2]} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55310
603
317