@impulse-ui-native/flat-list 0.0.0-stage → 9.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ImpulseUI Native contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,44 @@
1
- # Temporary Holding Version
1
+ # @impulse-ui-native/flat-list
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Native React Native FlatList and a small hook for initial positioning with known row sizes.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add @impulse-ui-native/flat-list
9
+ ```
10
+
11
+ React and React Native are peer dependencies. No theme provider is required. The toolkit also exports this package.
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import {
17
+ FlatList,
18
+ useFlatListInitialScroll,
19
+ } from "@impulse-ui-native/flat-list";
20
+
21
+ function OptionsList({ options, selectedIndex, rowHeight, renderItem }) {
22
+ const initialScroll = useFlatListInitialScroll({
23
+ itemSize: rowHeight,
24
+ initialScrollIndex: selectedIndex,
25
+ });
26
+
27
+ return <FlatList {...initialScroll} data={options} renderItem={renderItem} />;
28
+ }
29
+ ```
30
+
31
+ The hook returns only native `initialScrollIndex` and a stable `getItemLayout`. FlatList itself performs initial scrolling and virtualization. `FlatList` is the native component, so all native props, callbacks, and refs work directly.
32
+
33
+ | Hook option | Meaning |
34
+ | -------------------- | ---------------------------------------------------------------------------------- |
35
+ | `itemSize` | Actual fixed row height, or item width for a horizontal list. Include row padding. |
36
+ | `initialScrollIndex` | Native initial row index. Omit when no target is selected. |
37
+ | `separatorSize` | Separator height/width, default 0. |
38
+ | `headerSize` | Known header height/width included in offsets, default 0. |
39
+
40
+ Use the same size for rendered rows and `itemSize`. For multiple columns, use the native row index, not an individual item index. For rows with different known sizes, provide your own accurate native `getItemLayout` instead of this fixed-size helper.
41
+
42
+ Initial positioning follows native FlatList's mount behavior. Remount the list when a fresh initial position is needed, and mount it after asynchronously loaded data is available. Changing the selected value after initialization does not scroll an existing list.
43
+
44
+ Exports: `FlatList`, `useFlatListInitialScroll`, `FlatListProps`, `FlatListRef`, and `UseFlatListInitialScrollOptions`.
@@ -0,0 +1 @@
1
+ export { FlatList } from 'react-native';
@@ -0,0 +1,5 @@
1
+ import { FlatList } from "react-native";
2
+ export {
3
+ FlatList
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["export { FlatList } from \"react-native\";\n"],"mappings":"AAAA,SAAS,gBAAgB;","names":[]}
@@ -0,0 +1,3 @@
1
+ export { useFlatListInitialScroll } from './use-flat-list-initial-scroll.hook.mjs';
2
+ import 'react-native';
3
+ import '../types/flat-list.types.mjs';
@@ -0,0 +1,5 @@
1
+ import { useFlatListInitialScroll } from "./use-flat-list-initial-scroll.hook";
2
+ export {
3
+ useFlatListInitialScroll
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export { useFlatListInitialScroll } from \"./use-flat-list-initial-scroll.hook\";\n"],"mappings":"AAAA,SAAS,gCAAgC;","names":[]}
@@ -0,0 +1,13 @@
1
+ import 'react-native';
2
+ import { UseFlatListInitialScrollOptions } from '../types/flat-list.types.mjs';
3
+
4
+ declare function useFlatListInitialScroll<Item>(options: UseFlatListInitialScrollOptions): {
5
+ initialScrollIndex: number | null | undefined;
6
+ getItemLayout: (data: ArrayLike<Item> | null | undefined, index: number) => {
7
+ length: number;
8
+ offset: number;
9
+ index: number;
10
+ };
11
+ };
12
+
13
+ export { useFlatListInitialScroll };
@@ -0,0 +1,22 @@
1
+ import { useCallback } from "react";
2
+ function useFlatListInitialScroll(options) {
3
+ const {
4
+ itemSize,
5
+ initialScrollIndex,
6
+ separatorSize = 0,
7
+ headerSize = 0
8
+ } = options;
9
+ const getItemLayout = useCallback(
10
+ (_, index) => ({
11
+ length: itemSize,
12
+ offset: headerSize + (itemSize + separatorSize) * index,
13
+ index
14
+ }),
15
+ [itemSize, separatorSize, headerSize]
16
+ );
17
+ return { initialScrollIndex, getItemLayout };
18
+ }
19
+ export {
20
+ useFlatListInitialScroll
21
+ };
22
+ //# sourceMappingURL=use-flat-list-initial-scroll.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-flat-list-initial-scroll.hook.ts"],"sourcesContent":["import type { FlatListProps } from \"react-native\";\nimport { useCallback } from \"react\";\n\nimport type { UseFlatListInitialScrollOptions } from \"../types\";\n\nexport function useFlatListInitialScroll<Item>(\n options: UseFlatListInitialScrollOptions,\n) {\n const {\n itemSize,\n initialScrollIndex,\n separatorSize = 0,\n headerSize = 0,\n } = options;\n\n const getItemLayout = useCallback<\n NonNullable<FlatListProps<Item>[\"getItemLayout\"]>\n >(\n (_, index) => ({\n length: itemSize,\n offset: headerSize + (itemSize + separatorSize) * index,\n index,\n }),\n [itemSize, separatorSize, headerSize],\n );\n\n return { initialScrollIndex, getItemLayout };\n}\n"],"mappings":"AACA,SAAS,mBAAmB;AAIrB,SAAS,yBACd,SACA;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,aAAa;AAAA,EACf,IAAI;AAEJ,QAAM,gBAAgB;AAAA,IAGpB,CAAC,GAAG,WAAW;AAAA,MACb,QAAQ;AAAA,MACR,QAAQ,cAAc,WAAW,iBAAiB;AAAA,MAClD;AAAA,IACF;AAAA,IACA,CAAC,UAAU,eAAe,UAAU;AAAA,EACtC;AAEA,SAAO,EAAE,oBAAoB,cAAc;AAC7C;","names":[]}
@@ -0,0 +1,3 @@
1
+ export { FlatList, FlatListProps } from 'react-native';
2
+ export { useFlatListInitialScroll } from './hooks/use-flat-list-initial-scroll.hook.mjs';
3
+ export { FlatListRef, UseFlatListInitialScrollOptions } from './types/flat-list.types.mjs';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./components";
2
+ export * from "./hooks";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./hooks\";\nexport type * from \"./types\";\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,13 @@
1
+ import { FlatList } from 'react-native';
2
+ export { FlatListProps } from 'react-native';
3
+
4
+ type FlatListRef<Item> = FlatList<Item>;
5
+ interface UseFlatListInitialScrollOptions {
6
+ /** Known row height for vertical lists, or width for horizontal lists. */
7
+ itemSize: number;
8
+ initialScrollIndex?: number | null;
9
+ separatorSize?: number;
10
+ headerSize?: number;
11
+ }
12
+
13
+ export type { FlatListRef, UseFlatListInitialScrollOptions };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=flat-list.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,2 @@
1
+ export { FlatListRef, UseFlatListInitialScrollOptions } from './flat-list.types.mjs';
2
+ export { FlatListProps } from 'react-native';
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "name": "@impulse-ui-native/flat-list",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "9.0.0",
4
+ "description": "Native FlatList and a small hook for initial positioning with known row sizes.",
5
+ "keywords": [
6
+ "react-native",
7
+ "flat-list",
8
+ "virtualization",
9
+ "scroll"
10
+ ],
11
+ "license": "MIT",
12
+ "source": "src/index.ts",
13
+ "module": "dist/index.js",
14
+ "types": "dist/index.d.mts",
15
+ "react-native": "src/index.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.mts",
19
+ "react-native": "./src/index.ts",
20
+ "import": "./dist/index.js"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "sideEffects": false,
29
+ "devDependencies": {
30
+ "@types/react": "~19.2.14",
31
+ "eslint": "^9.38.0",
32
+ "prettier": "^3.6.2",
33
+ "react": "19.2.3",
34
+ "react-native": "0.86.2",
35
+ "typescript": "~6.0.3",
36
+ "@impulse-ui-native/eslint-config": "1.0.0",
37
+ "@impulse-ui-native/tsconfig": "1.0.0",
38
+ "@impulse-ui-native/prettier-config": "1.0.0"
39
+ },
40
+ "peerDependencies": {
41
+ "react": ">=18",
42
+ "react-native": ">=0.73"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "prettier": "@impulse-ui-native/prettier-config",
48
+ "scripts": {
49
+ "build": "tsup --config tsup.config.ts",
50
+ "typecheck": "tsc -p tsconfig.json --noEmit",
51
+ "lint": "pnpm exec eslint . --fix",
52
+ "format": "prettier --write \"./**/*.{ts,tsx,js,jsx,json,md}\" --ignore-path ../../.prettierignore"
53
+ }
6
54
  }