@youversion/platform-react-hooks 1.7.0 → 1.8.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @youversion/platform-react-hooks@1.7.0 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
2
+ > @youversion/platform-react-hooks@1.8.0 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
3
3
  > tsc -p tsconfig.build.json
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @youversion/platform-react-hooks
2
2
 
3
+ ## 1.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 45516c2: Add recently used versions to the Bible Version Picker
8
+ - Display up to 3 recently selected Bible versions at the top of the picker
9
+ - Persist recent version selections in localStorage
10
+ - Recent versions are searchable and excluded from the main "All Versions" list
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [45516c2]
15
+ - @youversion/platform-core@1.8.0
16
+
3
17
  ## 1.7.0
4
18
 
5
19
  ### Minor Changes
@@ -2,5 +2,5 @@ import type { BibleVersion } from '@youversion/platform-core';
2
2
  /**
3
3
  * Custom hook to filter versions based on search term
4
4
  */
5
- export declare function useFilteredVersions(versions: BibleVersion[], searchTerm: string, selectedLanguage: string): BibleVersion[];
5
+ export declare function useFilteredVersions(versions: BibleVersion[], searchTerm: string, selectedLanguage: string, recentVersions?: Pick<BibleVersion, 'id' | 'title' | 'localized_abbreviation'>[]): BibleVersion[];
6
6
  //# sourceMappingURL=useFilteredVersions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFilteredVersions.d.ts","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EAAE,EACxB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,GACvB,YAAY,EAAE,CAwBhB"}
1
+ {"version":3,"file":"useFilteredVersions.d.ts","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EAAE,EACxB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,OAAO,GAAG,wBAAwB,CAAC,EAAE,GAC/E,YAAY,EAAE,CA8BhB"}
@@ -4,7 +4,7 @@ import { getISOFromVersion } from './utility/version';
4
4
  /**
5
5
  * Custom hook to filter versions based on search term
6
6
  */
7
- export function useFilteredVersions(versions, searchTerm, selectedLanguage) {
7
+ export function useFilteredVersions(versions, searchTerm, selectedLanguage, recentVersions) {
8
8
  return useMemo(() => {
9
9
  let result = [...versions];
10
10
  // Language filter
@@ -18,7 +18,12 @@ export function useFilteredVersions(versions, searchTerm, selectedLanguage) {
18
18
  version.abbreviation.toLowerCase().includes(searchLower) ||
19
19
  getISOFromVersion(version).toLowerCase().includes(searchLower));
20
20
  }
21
+ // Recently Used Filter
22
+ if (recentVersions) {
23
+ const recentVersionIds = recentVersions.map((version) => version.id);
24
+ result = result.filter((version) => !recentVersionIds.includes(version.id));
25
+ }
21
26
  return result;
22
- }, [versions, searchTerm, selectedLanguage]);
27
+ }, [versions, recentVersions, searchTerm, selectedLanguage]);
23
28
  }
24
29
  //# sourceMappingURL=useFilteredVersions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFilteredVersions.js","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB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C;AAC/D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youversion/platform-react-hooks",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -22,7 +22,7 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@youversion/platform-core": "1.7.0"
25
+ "@youversion/platform-core": "1.8.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=19.1.0 <20.0.0"
@@ -198,6 +198,64 @@ describe('useFilteredVersions', () => {
198
198
  });
199
199
  });
200
200
 
201
+ describe('recent versions exclusion', () => {
202
+ it('should not exclude any versions when recentVersions is undefined', () => {
203
+ const { result } = renderHook(() => useFilteredVersions(mockVersions, '', '*', undefined));
204
+
205
+ expect(result.current).toEqual(mockVersions);
206
+ expect(result.current).toHaveLength(5);
207
+ });
208
+
209
+ it('should exclude recent versions from the results', () => {
210
+ const recentVersions = [
211
+ { id: 1, title: 'King James Version', localized_abbreviation: 'KJV' },
212
+ ];
213
+
214
+ const { result } = renderHook(() =>
215
+ useFilteredVersions(mockVersions, '', '*', recentVersions),
216
+ );
217
+
218
+ expect(result.current).toHaveLength(4);
219
+ expect(result.current.find((v) => v.id === 1)).toBeUndefined();
220
+ });
221
+
222
+ it('should exclude multiple recent versions from the results', () => {
223
+ const recentVersions = [
224
+ { id: 1, title: 'King James Version', localized_abbreviation: 'KJV' },
225
+ { id: 2, title: 'New International Version', localized_abbreviation: 'NIV' },
226
+ ];
227
+
228
+ const { result } = renderHook(() =>
229
+ useFilteredVersions(mockVersions, '', '*', recentVersions),
230
+ );
231
+
232
+ expect(result.current).toHaveLength(3);
233
+ expect(result.current.find((v) => v.id === 1)).toBeUndefined();
234
+ expect(result.current.find((v) => v.id === 2)).toBeUndefined();
235
+ });
236
+
237
+ it('should not exclude any versions when recentVersions is empty array', () => {
238
+ const { result } = renderHook(() => useFilteredVersions(mockVersions, '', '*', []));
239
+
240
+ expect(result.current).toEqual(mockVersions);
241
+ expect(result.current).toHaveLength(5);
242
+ });
243
+
244
+ it('should exclude recent versions even when they match search term', () => {
245
+ const recentVersions = [
246
+ { id: 2, title: 'New International Version', localized_abbreviation: 'NIV' },
247
+ ];
248
+
249
+ const { result } = renderHook(() =>
250
+ useFilteredVersions(mockVersions, 'Version', '*', recentVersions),
251
+ );
252
+
253
+ // "Version" matches KJV and NIV, but NIV is excluded as a recent version
254
+ expect(result.current).toHaveLength(1);
255
+ expect(result.current[0]?.title).toBe('King James Version');
256
+ });
257
+ });
258
+
201
259
  describe('memoization', () => {
202
260
  it('should return the same reference when inputs do not change', () => {
203
261
  const { result, rerender } = renderHook(
@@ -11,6 +11,7 @@ export function useFilteredVersions(
11
11
  versions: BibleVersion[],
12
12
  searchTerm: string,
13
13
  selectedLanguage: string,
14
+ recentVersions?: Pick<BibleVersion, 'id' | 'title' | 'localized_abbreviation'>[],
14
15
  ): BibleVersion[] {
15
16
  return useMemo(() => {
16
17
  let result = [...versions];
@@ -33,6 +34,12 @@ export function useFilteredVersions(
33
34
  );
34
35
  }
35
36
 
37
+ // Recently Used Filter
38
+ if (recentVersions) {
39
+ const recentVersionIds = recentVersions.map((version) => version.id);
40
+ result = result.filter((version) => !recentVersionIds.includes(version.id));
41
+ }
42
+
36
43
  return result;
37
- }, [versions, searchTerm, selectedLanguage]);
44
+ }, [versions, recentVersions, searchTerm, selectedLanguage]);
38
45
  }