@_elcaten/expo-list-section-index 1.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/.prettierrc +8 -0
- package/LICENSE +21 -0
- package/README.md +66 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +2 -0
- package/build/index.js.map +1 -0
- package/build/modifiers.d.ts +5 -0
- package/build/modifiers.d.ts.map +1 -0
- package/build/modifiers.js +10 -0
- package/build/modifiers.js.map +1 -0
- package/eslint.config.cjs +5 -0
- package/expo-module.config.json +6 -0
- package/ios/ExpoListSectionIndex.podspec +25 -0
- package/ios/ExpoListSectionIndexModule.swift +26 -0
- package/ios/ExpoListSectionIndexSwiftUIModifier.swift +51 -0
- package/package.json +69 -0
- package/src/index.ts +5 -0
- package/src/modifiers.ts +16 -0
- package/tsconfig.json +28 -0
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present 650 Industries, Inc. (aka Expo)
|
|
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
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @_elcaten/expo-list-section-index
|
|
2
|
+
|
|
3
|
+
Adds native iOS 26 alphabetical section indexes to
|
|
4
|
+
[`@expo/ui`](https://docs.expo.dev/versions/v57.0.0/sdk/ui/swift-ui/) SwiftUI lists.
|
|
5
|
+
|
|
6
|
+
## Requirements
|
|
7
|
+
|
|
8
|
+
- Expo SDK 57 or newer
|
|
9
|
+
- `@expo/ui`
|
|
10
|
+
- iOS 26 or newer
|
|
11
|
+
- A development or production build; the native module is not included in Expo Go
|
|
12
|
+
|
|
13
|
+
The modifiers are no-ops on earlier iOS versions.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx expo install @expo/ui
|
|
19
|
+
npm install @_elcaten/expo-list-section-index
|
|
20
|
+
npx expo run:ios
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
You can also build the app with EAS Build.
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Apply `sectionIndexLabel` to every `Section` and
|
|
28
|
+
`listSectionIndexVisibility` to the containing `List`.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { listSectionIndexVisibility, sectionIndexLabel } from '@_elcaten/expo-list-section-index';
|
|
32
|
+
import { Host, List, Section, Text } from '@expo/ui/swift-ui';
|
|
33
|
+
import { listStyle } from '@expo/ui/swift-ui/modifiers';
|
|
34
|
+
|
|
35
|
+
const CONTACTS = [
|
|
36
|
+
'Ada Lovelace',
|
|
37
|
+
'Barbara Liskov',
|
|
38
|
+
'Charles Babbage',
|
|
39
|
+
'Dorothy Vaughan',
|
|
40
|
+
'Edsger Dijkstra',
|
|
41
|
+
'Frances Allen',
|
|
42
|
+
'Grace Hopper',
|
|
43
|
+
'Hedy Lamarr',
|
|
44
|
+
] as const;
|
|
45
|
+
|
|
46
|
+
export default function App() {
|
|
47
|
+
return (
|
|
48
|
+
<Host style={{ flex: 1 }}>
|
|
49
|
+
<List modifiers={[listStyle('plain'), listSectionIndexVisibility('visible')]}>
|
|
50
|
+
{CONTACTS.map((name) => {
|
|
51
|
+
const letter = name.charAt(0);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Section key={name} title={letter} modifiers={[sectionIndexLabel(letter)]}>
|
|
55
|
+
<Text>{name}</Text>
|
|
56
|
+
</Section>
|
|
57
|
+
);
|
|
58
|
+
})}
|
|
59
|
+
</List>
|
|
60
|
+
</Host>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`listSectionIndexVisibility` accepts `'automatic'`, `'visible'`, or `'hidden'`.
|
|
66
|
+
Pass `null` to `sectionIndexLabel` to omit a section from the index.
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,KAAK,0BAA0B,GAChC,MAAM,aAAa,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,GAElB,MAAM,aAAa,CAAC","sourcesContent":["export {\n listSectionIndexVisibility,\n sectionIndexLabel,\n type ListSectionIndexVisibility,\n} from './modifiers';\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ModifierConfig } from '@expo/ui/swift-ui/modifiers';
|
|
2
|
+
export type ListSectionIndexVisibility = 'automatic' | 'visible' | 'hidden';
|
|
3
|
+
export declare function sectionIndexLabel(label: string | null): ModifierConfig;
|
|
4
|
+
export declare function listSectionIndexVisibility(visibility?: ListSectionIndexVisibility): ModifierConfig;
|
|
5
|
+
//# sourceMappingURL=modifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifiers.d.ts","sourceRoot":"","sources":["../src/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAKlF,MAAM,MAAM,0BAA0B,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,cAAc,CAEtE;AAED,wBAAgB,0BAA0B,CACxC,UAAU,GAAE,0BAAwC,GACnD,cAAc,CAEhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createModifier } from '@expo/ui/swift-ui/modifiers';
|
|
2
|
+
const sectionIndexLabelModifier = 'expoListSectionIndex.sectionIndexLabel';
|
|
3
|
+
const listSectionIndexVisibilityModifier = 'expoListSectionIndex.listSectionIndexVisibility';
|
|
4
|
+
export function sectionIndexLabel(label) {
|
|
5
|
+
return createModifier(sectionIndexLabelModifier, { label });
|
|
6
|
+
}
|
|
7
|
+
export function listSectionIndexVisibility(visibility = 'automatic') {
|
|
8
|
+
return createModifier(listSectionIndexVisibilityModifier, { visibility });
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=modifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifiers.js","sourceRoot":"","sources":["../src/modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,6BAA6B,CAAC;AAElF,MAAM,yBAAyB,GAAG,wCAAwC,CAAC;AAC3E,MAAM,kCAAkC,GAAG,iDAAiD,CAAC;AAI7F,MAAM,UAAU,iBAAiB,CAAC,KAAoB;IACpD,OAAO,cAAc,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,aAAyC,WAAW;IAEpD,OAAO,cAAc,CAAC,kCAAkC,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AAC5E,CAAC","sourcesContent":["import { createModifier, type ModifierConfig } from '@expo/ui/swift-ui/modifiers';\n\nconst sectionIndexLabelModifier = 'expoListSectionIndex.sectionIndexLabel';\nconst listSectionIndexVisibilityModifier = 'expoListSectionIndex.listSectionIndexVisibility';\n\nexport type ListSectionIndexVisibility = 'automatic' | 'visible' | 'hidden';\n\nexport function sectionIndexLabel(label: string | null): ModifierConfig {\n return createModifier(sectionIndexLabelModifier, { label });\n}\n\nexport function listSectionIndexVisibility(\n visibility: ListSectionIndexVisibility = 'automatic'\n): ModifierConfig {\n return createModifier(listSectionIndexVisibilityModifier, { visibility });\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const { defineConfig } = require('eslint/config');
|
|
2
|
+
const universe = require('eslint-config-universe/flat/native');
|
|
3
|
+
const universeWeb = require('eslint-config-universe/flat/web');
|
|
4
|
+
|
|
5
|
+
module.exports = defineConfig([{ ignores: ['build'] }, ...universe, ...universeWeb]);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
Pod::Spec.new do |s|
|
|
2
|
+
s.name = 'ExpoListSectionIndex'
|
|
3
|
+
s.version = '1.0.0'
|
|
4
|
+
s.summary = 'Native iOS 26 alphabetical section indexes for Expo UI'
|
|
5
|
+
s.description = 'Adds SwiftUI sectionIndexLabel and listSectionIndexVisibility modifiers to Expo UI.'
|
|
6
|
+
s.author = 'Elcaten'
|
|
7
|
+
s.homepage = 'https://github.com/Elcaten/expo-list-section-index'
|
|
8
|
+
s.license = { :type => 'MIT', :file => '../LICENSE' }
|
|
9
|
+
s.platforms = { :ios => '16.4' }
|
|
10
|
+
s.swift_version = '5.9'
|
|
11
|
+
s.source = {
|
|
12
|
+
:git => 'https://github.com/Elcaten/expo-list-section-index.git',
|
|
13
|
+
:tag => s.version.to_s
|
|
14
|
+
}
|
|
15
|
+
s.static_framework = true
|
|
16
|
+
|
|
17
|
+
s.dependency 'ExpoModulesCore'
|
|
18
|
+
s.dependency 'ExpoUI'
|
|
19
|
+
|
|
20
|
+
s.pod_target_xcconfig = {
|
|
21
|
+
'DEFINES_MODULE' => 'YES'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
s.source_files = '**/*.{h,m,mm,swift,hpp,cpp}'
|
|
25
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import ExpoUI
|
|
3
|
+
|
|
4
|
+
private let sectionIndexLabelModifier = "expoListSectionIndex.sectionIndexLabel"
|
|
5
|
+
private let listSectionIndexVisibilityModifier =
|
|
6
|
+
"expoListSectionIndex.listSectionIndexVisibility"
|
|
7
|
+
|
|
8
|
+
public final class ExpoListSectionIndexModule: Module {
|
|
9
|
+
public func definition() -> ModuleDefinition {
|
|
10
|
+
Name("ExpoListSectionIndex")
|
|
11
|
+
|
|
12
|
+
OnCreate {
|
|
13
|
+
ViewModifierRegistry.register(sectionIndexLabelModifier) { params, appContext, _ in
|
|
14
|
+
try SectionIndexLabelModifier(from: params, appContext: appContext)
|
|
15
|
+
}
|
|
16
|
+
ViewModifierRegistry.register(listSectionIndexVisibilityModifier) { params, appContext, _ in
|
|
17
|
+
try ListSectionIndexVisibilityModifier(from: params, appContext: appContext)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
OnDestroy {
|
|
22
|
+
ViewModifierRegistry.unregister(sectionIndexLabelModifier)
|
|
23
|
+
ViewModifierRegistry.unregister(listSectionIndexVisibilityModifier)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import ExpoModulesCore
|
|
2
|
+
import SwiftUI
|
|
3
|
+
|
|
4
|
+
struct SectionIndexLabelModifier: ViewModifier, Record {
|
|
5
|
+
@Field var label: String?
|
|
6
|
+
|
|
7
|
+
func body(content: Content) -> some View {
|
|
8
|
+
#if compiler(>=6.2) && os(iOS)
|
|
9
|
+
if #available(iOS 26.0, *) {
|
|
10
|
+
content.sectionIndexLabel(label.map(Text.init))
|
|
11
|
+
} else {
|
|
12
|
+
content
|
|
13
|
+
}
|
|
14
|
+
#else
|
|
15
|
+
content
|
|
16
|
+
#endif
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
enum ListSectionIndexVisibilityOption: String, Enumerable {
|
|
21
|
+
case automatic
|
|
22
|
+
case visible
|
|
23
|
+
case hidden
|
|
24
|
+
|
|
25
|
+
var swiftUIVisibility: Visibility {
|
|
26
|
+
switch self {
|
|
27
|
+
case .automatic:
|
|
28
|
+
.automatic
|
|
29
|
+
case .visible:
|
|
30
|
+
.visible
|
|
31
|
+
case .hidden:
|
|
32
|
+
.hidden
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
struct ListSectionIndexVisibilityModifier: ViewModifier, Record {
|
|
38
|
+
@Field var visibility: ListSectionIndexVisibilityOption = .automatic
|
|
39
|
+
|
|
40
|
+
func body(content: Content) -> some View {
|
|
41
|
+
#if compiler(>=6.2) && os(iOS)
|
|
42
|
+
if #available(iOS 26.0, *) {
|
|
43
|
+
content.listSectionIndexVisibility(visibility.swiftUIVisibility)
|
|
44
|
+
} else {
|
|
45
|
+
content
|
|
46
|
+
}
|
|
47
|
+
#else
|
|
48
|
+
content
|
|
49
|
+
#endif
|
|
50
|
+
}
|
|
51
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@_elcaten/expo-list-section-index",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Adds native iOS 26 alphabetical section indexes to Expo UI SwiftUI lists.",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"types": "build/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "node internal/module_scripts/build.js",
|
|
9
|
+
"clean": "node internal/module_scripts/clean.js",
|
|
10
|
+
"lint": "eslint src/",
|
|
11
|
+
"test": "node internal/module_scripts/test.js",
|
|
12
|
+
"prepack": "node internal/module_scripts/prepare.js",
|
|
13
|
+
"open:ios": "node internal/module_scripts/open-ios.js",
|
|
14
|
+
"open:android": "node internal/module_scripts/open-android.js"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"react-native",
|
|
18
|
+
"expo",
|
|
19
|
+
"expo-ui",
|
|
20
|
+
"swiftui",
|
|
21
|
+
"section-index",
|
|
22
|
+
"alphabet-list",
|
|
23
|
+
"ios-26"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/Elcaten/expo-list-section-index.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/Elcaten/expo-list-section-index/issues"
|
|
31
|
+
},
|
|
32
|
+
"author": "Elcaten <sweet.bunch7296@fastmail.com> (https://github.com/Elcaten)",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"homepage": "https://github.com/Elcaten/expo-list-section-index#readme",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/core": "^7.26.0",
|
|
41
|
+
"@expo/ui": "~57.0.7",
|
|
42
|
+
"@types/jest": "^29.2.1",
|
|
43
|
+
"@types/react": "~19.2.2",
|
|
44
|
+
"babel-preset-expo": "~57.0.4",
|
|
45
|
+
"eslint": "~9.39.4",
|
|
46
|
+
"eslint-config-universe": "^15.0.3",
|
|
47
|
+
"expo": "^57.0.7",
|
|
48
|
+
"expo-modules-core": "~57.0.7",
|
|
49
|
+
"jest": "^29.7.0",
|
|
50
|
+
"jest-expo": "~57.0.2",
|
|
51
|
+
"prettier": "^3.0.0",
|
|
52
|
+
"react": "19.2.3",
|
|
53
|
+
"react-dom": "19.2.3",
|
|
54
|
+
"react-native": "0.86.0",
|
|
55
|
+
"typescript": "^5.9.2"
|
|
56
|
+
},
|
|
57
|
+
"jest": {
|
|
58
|
+
"preset": "jest-expo",
|
|
59
|
+
"roots": [
|
|
60
|
+
"<rootDir>/src"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@expo/ui": ">=57.0.0",
|
|
65
|
+
"expo": "*",
|
|
66
|
+
"react": "*",
|
|
67
|
+
"react-native": "*"
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/index.ts
ADDED
package/src/modifiers.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createModifier, type ModifierConfig } from '@expo/ui/swift-ui/modifiers';
|
|
2
|
+
|
|
3
|
+
const sectionIndexLabelModifier = 'expoListSectionIndex.sectionIndexLabel';
|
|
4
|
+
const listSectionIndexVisibilityModifier = 'expoListSectionIndex.listSectionIndexVisibility';
|
|
5
|
+
|
|
6
|
+
export type ListSectionIndexVisibility = 'automatic' | 'visible' | 'hidden';
|
|
7
|
+
|
|
8
|
+
export function sectionIndexLabel(label: string | null): ModifierConfig {
|
|
9
|
+
return createModifier(sectionIndexLabelModifier, { label });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function listSectionIndexVisibility(
|
|
13
|
+
visibility: ListSectionIndexVisibility = 'automatic'
|
|
14
|
+
): ModifierConfig {
|
|
15
|
+
return createModifier(listSectionIndexVisibilityModifier, { visibility });
|
|
16
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"lib": ["dom", "DOM.Iterable", "esnext"],
|
|
4
|
+
"types": ["jest"],
|
|
5
|
+
"typeRoots": ["./ts-declarations", "./node_modules/@types"],
|
|
6
|
+
"jsx": "react-native",
|
|
7
|
+
"target": "esnext",
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"module": "esnext",
|
|
10
|
+
"moduleDetection": "force",
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"inlineSources": true,
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noFallthroughCasesInSwitch": true,
|
|
19
|
+
"noPropertyAccessFromIndexSignature": false,
|
|
20
|
+
"noImplicitReturns": true,
|
|
21
|
+
"noUnusedLocals": true,
|
|
22
|
+
"noUnusedParameters": false,
|
|
23
|
+
"rootDir": "./src",
|
|
24
|
+
"outDir": "./build"
|
|
25
|
+
},
|
|
26
|
+
"include": ["./src"],
|
|
27
|
+
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
|
|
28
|
+
}
|