Skip to content

Commit d2ccfda

Browse files
authored
Merge branch 'next' into @akwasniewski/examples
2 parents 1679ca6 + b2d6281 commit d2ccfda

118 files changed

Lines changed: 5355 additions & 410 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs-check.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
uses: actions/setup-node@v6
2626
with:
2727
node-version: 24
28-
cache: yarn
2928

3029
- name: Install node dependencies
3130
working-directory: ${{ env.WORKING_DIRECTORY }}

apps/basic-example/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"../../packages/react-native-gesture-handler/src/jestUtils/index.ts"
1818
]
1919
},
20-
"types": ["jest"]
20+
"types": ["jest","../../packages/react-native-gesture-handler/src/global.d.ts"]
21+
2122
},
2223
"include": ["src/**/*.ts", "src/**/*.tsx"]
2324
}

apps/common-app/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"react-native-gesture-handler/jest-utils": [
1919
"../../packages/react-native-gesture-handler/src/jestUtils/index.ts"
2020
]
21-
}
21+
},
22+
"types": ["../../packages/react-native-gesture-handler/src/global.d.ts"]
2223
},
2324
"include": ["src/**/*.ts", "src/**/*.tsx", "index.ts"]
2425
}

apps/expo-example/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"react-native-gesture-handler/jest-utils": [
1818
"../../packages/react-native-gesture-handler/src/jestUtils/index.ts"
1919
]
20-
}
20+
},
21+
"types": ["../../packages/react-native-gesture-handler/src/global.d.ts"]
22+
2123
},
2224
"include": ["src/**/*.ts", "src/**/*.tsx", "App.tsx"],
2325
"exclude": ["metro.config.js", "android", "ios", ".bundle", "node_modules"]

apps/macos-example/tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"react-native-gesture-handler/jest-utils": [
1818
"../../packages/react-native-gesture-handler/src/jestUtils/index.ts"
1919
]
20-
}
20+
},
21+
"types": ["../../packages/react-native-gesture-handler/src/global.d.ts"]
22+
2123
},
2224
"include": ["src/**/*.ts", "src/**/*.tsx", "index.ts"],
2325
"exclude": ["metro.config.js", "macos", ".bundle", "node_modules"]
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
import { useDocsVersion } from '@docusaurus/plugin-content-docs/client';
2+
import React from 'react';
3+
4+
// It would be great to import from package, but unfortunately it does not work on CI :c
5+
// eslint-disable-next-line import-x/no-relative-packages
6+
import untypedCompatibilityData from '../../../react-native-gesture-handler/compatibility.json';
7+
import styles from './styles.module.css';
8+
9+
interface CompatibilityEntry {
10+
'react-native': string[];
11+
}
12+
13+
type CompatibilityData = Record<string, CompatibilityEntry>;
14+
15+
const compatibilityData = untypedCompatibilityData as CompatibilityData;
16+
17+
export function Yes() {
18+
return <div className={styles.supported}>yes</div>;
19+
}
20+
21+
export function No() {
22+
return <div className={styles.notSupported}>no</div>;
23+
}
24+
25+
interface VersionProps {
26+
version: string;
27+
}
28+
29+
export function Version({ version }: VersionProps) {
30+
return <div className={styles.version}>{version}</div>;
31+
}
32+
33+
export function Spacer() {
34+
return <div className={styles.spacer}></div>;
35+
}
36+
37+
interface CompatibilityItem {
38+
version: string;
39+
isSpacer: boolean;
40+
compatibility: Record<string, boolean>;
41+
}
42+
43+
type GestureHandlerCompatibilityProps = {
44+
spacerAfterIndex?: number;
45+
};
46+
47+
const getCompatibilityEntriesForVersion = (
48+
version: string,
49+
shouldInclude: (data: CompatibilityEntry) => boolean = () => true
50+
) => {
51+
if (version === 'current') {
52+
// For current version, find the highest major version and include nightly
53+
const highestMajorVersion = Math.max(
54+
...Object.keys(compatibilityData).map((key) => {
55+
const num = key.split('.')[0];
56+
return isNaN(+num) ? 0 : +num;
57+
})
58+
);
59+
60+
return Object.entries(compatibilityData).filter(
61+
([key, data]) =>
62+
(key === 'nightly' || key.startsWith(`${highestMajorVersion}.`)) &&
63+
shouldInclude(data)
64+
);
65+
}
66+
67+
// For versioned docs (e.g. "3.x", "2.x", "1.x"), extract the major version number
68+
const majorVersion = version.replace('.x', '');
69+
return Object.entries(compatibilityData).filter(
70+
([key, data]) => key.startsWith(`${majorVersion}.`) && shouldInclude(data)
71+
);
72+
};
73+
74+
const extractVersions = (
75+
data: [string, CompatibilityEntry][],
76+
getVersions: (entry: CompatibilityEntry) => string[]
77+
): string[] =>
78+
Array.from(new Set(data.flatMap(([, entry]) => getVersions(entry)))).sort();
79+
80+
const createCompatibilityItems = (
81+
filteredData: [string, CompatibilityEntry][],
82+
versions: string[],
83+
getSupportedVersions: (data: CompatibilityEntry) => Set<string>,
84+
spacerAfterIndex?: number
85+
): CompatibilityItem[] =>
86+
filteredData.map(([version, data], index) => {
87+
const supportedVersions = getSupportedVersions(data);
88+
const compatibility = Object.fromEntries(
89+
versions.map((versionNumber) => [
90+
versionNumber,
91+
supportedVersions.has(versionNumber),
92+
])
93+
);
94+
95+
return {
96+
version,
97+
isSpacer: index === spacerAfterIndex,
98+
compatibility,
99+
};
100+
});
101+
102+
interface CompatibilityTableProps {
103+
versions: string[];
104+
items: CompatibilityItem[];
105+
}
106+
107+
function CompatibilityTable({ versions, items }: CompatibilityTableProps) {
108+
return (
109+
<div className="compatibility">
110+
<table className={styles.table}>
111+
<thead>
112+
<tr>
113+
<th></th>
114+
{versions.map((version) => (
115+
<th key={version}>{version}</th>
116+
))}
117+
</tr>
118+
</thead>
119+
<tbody>
120+
{items.map((item, index) => (
121+
<React.Fragment key={index}>
122+
<tr>
123+
<td>
124+
<Version version={item.version} />
125+
</td>
126+
{versions.map((version) => (
127+
<td key={version}>
128+
{item.compatibility[version] ? <Yes /> : <No />}
129+
</td>
130+
))}
131+
</tr>
132+
{item.isSpacer && <Spacer />}
133+
</React.Fragment>
134+
))}
135+
</tbody>
136+
</table>
137+
</div>
138+
);
139+
}
140+
141+
export function GestureHandlerCompatibility({
142+
spacerAfterIndex,
143+
}: GestureHandlerCompatibilityProps) {
144+
const docsVersion = useDocsVersion();
145+
const filteredCompatibilityData = getCompatibilityEntriesForVersion(
146+
docsVersion.version
147+
);
148+
149+
const reactNativeVersions = extractVersions(
150+
filteredCompatibilityData,
151+
(data) => data['react-native']
152+
);
153+
154+
const compatibilityItems = createCompatibilityItems(
155+
filteredCompatibilityData,
156+
reactNativeVersions,
157+
(data) => new Set(data['react-native']),
158+
spacerAfterIndex
159+
);
160+
161+
return (
162+
<CompatibilityTable
163+
versions={reactNativeVersions}
164+
items={compatibilityItems}
165+
/>
166+
);
167+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.supported {
2+
color: var(--swm-compatibility-text-color);
3+
background-color: var(--swm-compatibility-supported-background);
4+
text-align: center;
5+
text-transform: capitalize;
6+
padding: 12px;
7+
}
8+
9+
.notSupported {
10+
color: var(--swm-compatibility-text-color);
11+
background-color: var(--swm-compatibility-not-supported-background);
12+
text-align: center;
13+
text-transform: capitalize;
14+
padding: 12px;
15+
}
16+
17+
.version {
18+
font-weight: bold;
19+
text-align: center;
20+
padding: 12px;
21+
}
22+
23+
.spacer {
24+
padding-top: 10px;
25+
}

packages/docs-gesture-handler/docs/components/buttons.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Currently Gesture handler library exposes three components that render native to
1919
- [`RectButton`](/docs/components/buttons/#rectbutton)
2020
- [`BorderlessButton`](/docs/components/buttons/#borderlessbutton)
2121

22-
On top of that all the buttons are wrapped with `NativeViewGestureHandler` and therefore allow for all the [common gesture handler properties](/docs/gesture-handlers/common-gh/) and `NativeViewGestureHandler`'s [extra properties](/docs/gesture-handlers/nativeview-gh#properties) to be applied to them.
22+
On top of that all the buttons are wrapped with `NativeViewGestureHandler` and therefore allow for all the [common gesture handler properties](/docs/gestures/use-native-gesture#properties-common-to-all-gestures) and `NativeViewGestureHandler`'s [extra properties](/docs/gestures/use-native-gesture#properties-specific-to-nativegesture) to be applied to them.
2323

2424
**IMPORTANT**: In order to make buttons accessible, you have to wrap your children in a `View` with `accessible` and `accessibilityRole="button"` props.
2525
Example:

0 commit comments

Comments
 (0)