# indexed-section-list

> A simple modular section list with index

Latest version **1.1.0** (published 2020-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install indexed-section-list
pnpm add indexed-section-list
yarn add indexed-section-list
bun add indexed-section-list
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-12-14 |
| First published | 2020-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 130 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Kfir Nissim |
| Maintainers | kfiri |
| Keywords | react-native, ios, android |

## Links

- npm: https://www.npmjs.com/package/indexed-section-list
- Repository: https://github.com/kfiri/indexed-section-list
- Homepage: https://github.com/kfiri/indexed-section-list#readme
- Issues: https://github.com/kfiri/indexed-section-list/issues
- npm.io page: https://npm.io/package/indexed-section-list

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2020-12-14
- 1.0.0 — 2020-10-06
- 0.2.2 — 2020-09-22
- 0.2.1 — 2020-09-09
- 0.2.0 — 2020-09-08
- 0.1.0 — 2020-09-07

## README

# indexed-section-list

A simple modular section list with an index.

![CountriesList](https://user-images.githubusercontent.com/31252902/92656462-c429ac80-f2fb-11ea-8db6-f0615380992e.gif)

## Installation

```sh
npm install --save indexed-section-list
```

## Usage

```js
import react from 'React';
import IndexedSectionList from 'indexed-section-list';

// See all props options in https://github.com/kfiri/indexed-section-list#props
function App() {
  return (
    <IndexedSectionList
      items={countryItems}
      indexItemHeight={20}
      style={styles.sectionList}
      wrapperStyle={styles.wrapper}
      indexWrapperStyle={styles.indexWrapper}
      showsVerticalScrollIndicator={false}
    />
  );
}
```

# Props

Inherits [SectionList props](https://reactnative.dev/docs/sectionlist#props) (omits `sections`, `keyExtractor` and `onScrollToIndexFailed`).  
For implementing `keyExtractor`, see `getSectionProps` below.

| Name                 | Description                                                                                                                                                                                                                                  | Type                                                     | Required |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | -------- |
| items                | The items of the list, either strings or objects with titles.                                                                                                                                                                                | (string \| { title: string; key?: string \| number; })[] | yes      |
| indexItemHeight      | The height if an item in the index list (must be a constant). defaults to 25px.                                                                                                                                                              | number                                                   | no       |
| indexWrapperStyle    | The style of the view that contains the index list.                                                                                                                                                                                          | ViewStyle                                                | no       |
| indexTextStyle       | The style of the view that contains the index text.                                                                                                                                                                                          | TextStyle                                                | no       |
| scrollEfficiency     | The method of the scroll (see Scroll Efficiency Functions). default is "revered".                                                                                                                                                            | "reversed" \| "initial" \| Function                      | no       |
| scrollOnSelect       | Should the section list scroll to an index when `onSelectIndex` is fired? (default true). Set to false if you want to manually scroll the section list using `onSelectIndex`.                                                                | boolean                                                  | no       |
| titleKey             | The title property name of the items. If the items are strings, this will be ignored.                                                                                                                                                        | string                                                   | no       |
| uniqueKey            | The unique key property name of the items. If the items are strings, this will be ignored.                                                                                                                                                   | string                                                   | no       |
| wrapperStyle         | The style of the view that contains both the section list and the index.                                                                                                                                                                     | ViewStyle                                                | no       |
| **Functional Props** |
| onSelectIndex        | A callback that is fired when the user selects an index.                                                                                                                                                                                     | Function                                                 | no       |
| getSectionProps      | A methods that returns a section's properties (see [Section Properties](https://reactnative.dev/docs/sectionlist#type-definitions)). Any change in this prop would cause the whole component to rerender (React.useCallback is recommended). | Function                                                 | no       |

### Ref

The `ref` prop behave exactly the same as the prop `ref` in [SectionList props](https://reactnative.dev/docs/sectionlist#props).

### Scroll Efficiency Functions

Given the height of the index container and the height of the index list, return a number that resembles the correlation between the movement of the user's touch on the list and the scroll of the list.  
Signature `(containerHeight: number, listHeight: number) => number`.

Built in methods-

**reversed** - Set the scroll of the indexes list to the opposite of the user's scroll direction,
so when the user scroll from one edge of the container to the other, the list would complete a full scroll within the container in the opposite direction.

**initial** - The normal scroll. Scroll the indexes list with the user's scroll. simply returns 1.

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT

---
_Source: https://npm.io/package/indexed-section-list · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
