@jpmorganchase/mosaic-store 0.1.0-beta.23 → 0.1.0-beta.25

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.
Files changed (57) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/CHANGELOG.md +17 -0
  3. package/README.md +2 -0
  4. package/dist/{chunk-RK2QZ3ZO.js → chunk-6QFYSQKC.js} +1 -1
  5. package/dist/chunk-B2ENOVOY.js +1 -0
  6. package/dist/chunk-LAADEEXW.js +0 -0
  7. package/dist/chunk-LHWBY2OA.js +1 -0
  8. package/dist/{chunk-MSLRBBS3.js → chunk-O3KBYHXA.js} +1 -1
  9. package/dist/chunk-PK5C6TQI.js +1 -0
  10. package/dist/chunk-PZRAIZUK.js +1 -0
  11. package/dist/{chunk-MLBDLE43.js → chunk-R6L4QR2K.js} +1 -1
  12. package/dist/chunk-RGA5W3OD.js +1 -0
  13. package/dist/chunk-U6MP7RD5.js +1 -0
  14. package/dist/{chunk-SPCIWRRP.js → chunk-UWHTRXA5.js} +1 -1
  15. package/dist/chunk-V54ZUOLT.js +1 -0
  16. package/dist/{chunk-74B44ZUJ.js → chunk-VKGBN5I5.js} +1 -1
  17. package/dist/chunk-ZEATWUZ3.js +1 -0
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/store.d.ts +2 -1
  21. package/dist/store.js +1 -1
  22. package/dist/types/index.d.ts +1 -0
  23. package/dist/types/index.js +1 -1
  24. package/dist/types/navigation.d.ts +21 -0
  25. package/dist/types/navigation.js +1 -0
  26. package/dist/useAppHeader.js +1 -1
  27. package/dist/useBreadcrumbs.js +1 -1
  28. package/dist/useColorMode.js +1 -1
  29. package/dist/useFooter.js +1 -1
  30. package/dist/useLayout.js +1 -1
  31. package/dist/useMeta.js +1 -1
  32. package/dist/useNavigation.d.ts +2 -0
  33. package/dist/useNavigation.js +1 -0
  34. package/dist/useRoute.js +1 -1
  35. package/dist/useSearchIndex.js +1 -1
  36. package/dist/useSidebar.js +1 -1
  37. package/dist/useStoreActions.js +1 -1
  38. package/dist/useTableOfContents.js +1 -1
  39. package/package.json +6 -1
  40. package/src/__tests__/store.test.ts +6 -0
  41. package/src/index.ts +1 -1
  42. package/src/store.ts +3 -0
  43. package/src/types/index.ts +1 -0
  44. package/src/types/navigation.ts +23 -0
  45. package/src/useNavigation.ts +10 -0
  46. package/dist/chunk-23H66E6E.js +0 -1
  47. package/dist/chunk-2G7SPWFY.js +0 -1
  48. package/dist/chunk-4GIIWZ26.js +0 -1
  49. package/dist/chunk-6B3RGLQ6.js +0 -1
  50. package/dist/chunk-CI2QHT55.js +0 -1
  51. package/dist/chunk-FC2ZNWAP.js +0 -1
  52. package/dist/chunk-LS443IBF.js +0 -1
  53. package/dist/chunk-W6IABN6M.js +0 -1
  54. package/dist/useNextPrev.d.ts +0 -9
  55. package/dist/useNextPrev.js +0 -1
  56. package/src/useNextPrev.ts +0 -47
  57. /package/dist/{chunk-WCQXIIQB.js → chunk-BHW7CEID.js} +0 -0
@@ -1,4 +1,4 @@
1
- @jpmorganchase/mosaic-store:build: cache hit, replaying output 92657758952da2fd
1
+ @jpmorganchase/mosaic-store:build: cache hit, replaying output aafdfdc702557658
2
2
  @jpmorganchase/mosaic-store:build: $ npm-run-all --parallel build:*
3
3
  @jpmorganchase/mosaic-store:build: $ node ../../scripts/bundle.js
4
4
  @jpmorganchase/mosaic-store:build: $ tsc
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @jpmorganchase/mosaic-store
2
2
 
3
+ ## 0.1.0-beta.25
4
+
5
+ ### Minor Changes
6
+
7
+ - 93e9b07: The theme contract provided by the `@jpmorganchase/mosaic-theme` package now uses locally scoped variable names via a Vanilla Extract [Theme Contract](https://vanilla-extract.style/documentation/api/create-theme-contract/). Previously the theme variables were globally scoped resulting in conflicts with other design systems.
8
+
9
+ ### Patch Changes
10
+
11
+ - a36219c: - Next/Prev page buttons were not appearing at the bottom of a page sequence
12
+ - Removed redundant snapshot page api
13
+
14
+ ## 0.1.0-beta.24
15
+
16
+ ### Patch Changes
17
+
18
+ - 049d9af: 1. Pip Salt version 2. Issues 155, make 500 error more specific 3. button and sidebar styles 4. search opt-out
19
+
3
20
  ## 0.1.0-beta.23
4
21
 
5
22
  ### Patch Changes
package/README.md CHANGED
@@ -7,3 +7,5 @@ The Mosaic store is based on [Zustand](https://zustand-demo.pmnd.rs/).
7
7
  ## Installation
8
8
 
9
9
  `yarn add @jpmorganchase/mosaic-store`
10
+
11
+ The Redux DevTools chrome extension can be used to view the contents of the store if required.
@@ -1 +1 @@
1
- import{d as r}from"./chunk-2G7SPWFY.js";function o(){let e=r(t=>t.searchIndex),n=e!==void 0&&e.length>0;return{searchEnabled:n,searchIndex:n?e:[]}}export{o as a};
1
+ import{d as r}from"./chunk-ZEATWUZ3.js";function o(){let e=r(t=>t.searchIndex),n=e!==void 0&&e.length>0;return{searchEnabled:n,searchIndex:n?e:[]}}export{o as a};
@@ -0,0 +1 @@
1
+ import{d as o}from"./chunk-ZEATWUZ3.js";function d(){return o(r=>r.colorMode)}export{d as a};
File without changes
@@ -0,0 +1 @@
1
+ import{d as t}from"./chunk-ZEATWUZ3.js";function e(){return{layout:t(o=>o.layout)}}export{e as a};
@@ -1 +1 @@
1
- import{d as t}from"./chunk-2G7SPWFY.js";function u(e){return e.links!==void 0}function d(e){return e.link!==void 0}function M(){let e=t(n=>n.sharedConfig?.header);if(!e)return;let i=e.menu.reduce((n,p)=>{if(u(p)){let r={...p,type:"menu"};return[...n,r]}if(d(p)){let r={...p,type:"link"};return[...n,r]}return console.error("Unknown menu type passed to useAppHeader, ignoring",p),n},[]);return{...e,menu:i}}export{M as a};
1
+ import{d as t}from"./chunk-ZEATWUZ3.js";function u(e){return e.links!==void 0}function d(e){return e.link!==void 0}function M(){let e=t(n=>n.sharedConfig?.header);if(!e)return;let i=e.menu.reduce((n,p)=>{if(u(p)){let r={...p,type:"menu"};return[...n,r]}if(d(p)){let r={...p,type:"link"};return[...n,r]}return console.error("Unknown menu type passed to useAppHeader, ignoring",p),n},[]);return{...e,menu:i}}export{M as a};
@@ -0,0 +1 @@
1
+ import{d as t}from"./chunk-ZEATWUZ3.js";function s(){return{tableOfContents:t(e=>e.tableOfContents)||[]}}export{s as a};
@@ -0,0 +1 @@
1
+ import{d as e}from"./chunk-ZEATWUZ3.js";function u(){return{route:e(t=>t.route)}}export{u as a};
@@ -1 +1 @@
1
- import{a as s}from"./chunk-FC2ZNWAP.js";import{a as o}from"./chunk-SPCIWRRP.js";import{d as t}from"./chunk-2G7SPWFY.js";function p(){let r=t(d=>d.sidebarData)||[],{route:e}=s(),{breadcrumbs:u}=o();return{menu:r,selectedNodeId:e,expandedNodeIds:m(u)}}function m(r){return new Set(r.map(({id:e})=>e.substr(0,e.lastIndexOf("."))))}export{p as a};
1
+ import{a as s}from"./chunk-PZRAIZUK.js";import{a as o}from"./chunk-UWHTRXA5.js";import{d as t}from"./chunk-ZEATWUZ3.js";function p(){let r=t(d=>d.sidebarData)||[],{route:e}=s(),{breadcrumbs:u}=o();return{menu:r,selectedNodeId:e,expandedNodeIds:m(u)}}function m(r){return new Set(r.map(({id:e})=>e.substr(0,e.lastIndexOf("."))))}export{p as a};
@@ -0,0 +1 @@
1
+ import{d as o}from"./chunk-ZEATWUZ3.js";function f(){return o(e=>e.sharedConfig?.footer)}export{f as a};
@@ -0,0 +1 @@
1
+ import{d as o}from"./chunk-ZEATWUZ3.js";var r=()=>o(t=>t.actions);export{r as a};
@@ -1 +1 @@
1
- import{d as e}from"./chunk-2G7SPWFY.js";function m(t=1){let r=e(b=>b.breadcrumbs);return{breadcrumbs:r||[],enabled:r?.length>t}}export{m as a};
1
+ import{d as e}from"./chunk-ZEATWUZ3.js";function m(t=1){let r=e(b=>b.breadcrumbs);return{breadcrumbs:r||[],enabled:r?.length>t}}export{m as a};
@@ -0,0 +1 @@
1
+ import{d as t}from"./chunk-ZEATWUZ3.js";function r(){let{next:o,prev:i}=t(n=>n.navigation)||{};return{next:o,prev:i}}export{r as a};
@@ -1 +1 @@
1
- import{d as t}from"./chunk-2G7SPWFY.js";function o(){return{meta:t(e=>({description:e.description,breadcrumbs:e.breadcrumbs,title:e.title}))}}export{o as a};
1
+ import{d as t}from"./chunk-ZEATWUZ3.js";function o(){return{meta:t(e=>({description:e.description,breadcrumbs:e.breadcrumbs,title:e.title}))}}export{o as a};
@@ -0,0 +1 @@
1
+ import{useLayoutEffect as s,createContext as S,useContext as d}from"react";import{createStore as c,useStore as l}from"zustand";import{devtools as f,persist as p}from"zustand/middleware";var r;function u(){return{breadcrumbs:[],sidebarData:[],tableOfContents:[],navigation:{},searchIndex:[],sharedConfig:{},description:void 0,layout:void 0,route:void 0,title:void 0,colorMode:"light"}}var n=S(void 0),M=n.Provider,m=e=>f(p(e,{name:"mosaic-theme-pref",partialize:t=>({colorMode:t.colorMode})})),i=(e={})=>c(m(o=>({...u(),...e,actions:{setColorMode:a=>o({colorMode:a})}})));function h(e,t=!1){if(typeof window>"u"||t)return()=>i(e);let o=Boolean(r);return r=r??i(e),s(()=>{e&&o&&r.setState({...r.getState(),...e},!0)}),()=>r}function x(e,t){let o=d(n);if(!o)throw new Error("Missing StoreProvider in the tree");return l(o,e,t)}export{M as a,i as b,h as c,x as d};
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export * from './useBreadcrumbs';
4
4
  export * from './useColorMode';
5
5
  export * from './useLayout';
6
6
  export * from './useMeta';
7
- export * from './useNextPrev';
7
+ export * from './useNavigation';
8
8
  export * from './useRoute';
9
9
  export * from './useSearchIndex';
10
10
  export * from './useSidebar';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d}from"./chunk-4GIIWZ26.js";import{a as g}from"./chunk-RK2QZ3ZO.js";import{a as h}from"./chunk-MLBDLE43.js";import{a as c}from"./chunk-FC2ZNWAP.js";import{a as k}from"./chunk-23H66E6E.js";import{a as i}from"./chunk-LS443IBF.js";import{a as p}from"./chunk-MSLRBBS3.js";import"./chunk-WCQXIIQB.js";import"./chunk-5L7EI47O.js";import"./chunk-MBLLQB7A.js";import"./chunk-ZJYDN5YH.js";import"./chunk-UK5NIPTI.js";import"./chunk-ZYJGHEAC.js";import"./chunk-BZYGOU7Y.js";import"./chunk-UGD4MMRB.js";import"./chunk-BHMVW2ZZ.js";import"./chunk-IS7TJ54I.js";import{a as m}from"./chunk-ZMWHBFUG.js";import"./chunk-VXYECVIB.js";import{a as t}from"./chunk-SPCIWRRP.js";import{a as x}from"./chunk-W6IABN6M.js";import{a as j}from"./chunk-6B3RGLQ6.js";import{a}from"./chunk-CI2QHT55.js";import{a as b}from"./chunk-74B44ZUJ.js";import{a as o,b as r,c as e,d as f}from"./chunk-2G7SPWFY.js";export{m as MenuItemType,o as StoreProvider,r as initializeStore,p as useAppHeader,t as useBreadcrumbs,x as useColorMode,e as useCreateStore,j as useFooter,a as useLayout,b as useMeta,d as useNextPrev,c as useRoute,g as useSearchIndex,h as useSidebar,f as useStore,k as useStoreActions,i as useTableOfContents};
1
+ import{a as c}from"./chunk-V54ZUOLT.js";import{a as g}from"./chunk-6QFYSQKC.js";import{a as h}from"./chunk-R6L4QR2K.js";import{a as d}from"./chunk-PZRAIZUK.js";import{a as k}from"./chunk-U6MP7RD5.js";import{a as i}from"./chunk-PK5C6TQI.js";import{a as p}from"./chunk-O3KBYHXA.js";import"./chunk-BHW7CEID.js";import"./chunk-IS7TJ54I.js";import"./chunk-5L7EI47O.js";import"./chunk-MBLLQB7A.js";import"./chunk-ZJYDN5YH.js";import"./chunk-UK5NIPTI.js";import"./chunk-ZYJGHEAC.js";import"./chunk-BZYGOU7Y.js";import"./chunk-UGD4MMRB.js";import"./chunk-LAADEEXW.js";import"./chunk-BHMVW2ZZ.js";import{a as m}from"./chunk-ZMWHBFUG.js";import"./chunk-VXYECVIB.js";import{a as t}from"./chunk-UWHTRXA5.js";import{a as x}from"./chunk-B2ENOVOY.js";import{a as j}from"./chunk-RGA5W3OD.js";import{a}from"./chunk-LHWBY2OA.js";import{a as b}from"./chunk-VKGBN5I5.js";import{a as o,b as r,c as e,d as f}from"./chunk-ZEATWUZ3.js";export{m as MenuItemType,o as StoreProvider,r as initializeStore,p as useAppHeader,t as useBreadcrumbs,x as useColorMode,e as useCreateStore,j as useFooter,a as useLayout,b as useMeta,c as useNavigation,d as useRoute,g as useSearchIndex,h as useSidebar,f as useStore,k as useStoreActions,i as useTableOfContents};
package/dist/store.d.ts CHANGED
@@ -4,10 +4,11 @@ import type { BreadcrumbsSlice } from './types/breadcrumbs';
4
4
  import type { SearchIndexSlice } from './types/searchIndex';
5
5
  import type { SharedConfigSlice } from './types/sharedConfig';
6
6
  import type { LayoutSlice } from './types/layout';
7
+ import type { NavigationSlice } from './types/navigation';
7
8
  import type { SidebarSlice } from './types/sidebar';
8
9
  import type { TableOfContentsSlice } from './types/tableOfContents';
9
10
  import type { ColorMode } from './types/colorMode';
10
- export declare type SiteState = BreadcrumbsSlice & LayoutSlice & SidebarSlice & TableOfContentsSlice & SearchIndexSlice & SharedConfigSlice & {
11
+ export declare type SiteState = BreadcrumbsSlice & LayoutSlice & SidebarSlice & TableOfContentsSlice & NavigationSlice & SearchIndexSlice & SharedConfigSlice & {
11
12
  /** Page metadata description, used by search */
12
13
  description?: string;
13
14
  /** Page route */
package/dist/store.js CHANGED
@@ -1 +1 @@
1
- import{a,b,c,d}from"./chunk-2G7SPWFY.js";export{a as StoreProvider,b as initializeStore,c as useCreateStore,d as useStore};
1
+ import{a,b,c,d}from"./chunk-ZEATWUZ3.js";export{a as StoreProvider,b as initializeStore,c as useCreateStore,d as useStore};
@@ -4,6 +4,7 @@ export * from './footer';
4
4
  export * from './helpLinks';
5
5
  export * from './layout';
6
6
  export * from './meta';
7
+ export * from './navigation';
7
8
  export * from './route';
8
9
  export * from './searchIndex';
9
10
  export * from './sharedConfig';
@@ -1 +1 @@
1
- import"../chunk-WCQXIIQB.js";import"../chunk-5L7EI47O.js";import"../chunk-MBLLQB7A.js";import"../chunk-ZJYDN5YH.js";import"../chunk-UK5NIPTI.js";import"../chunk-ZYJGHEAC.js";import"../chunk-BZYGOU7Y.js";import"../chunk-UGD4MMRB.js";import"../chunk-BHMVW2ZZ.js";import"../chunk-IS7TJ54I.js";import{a}from"../chunk-ZMWHBFUG.js";import"../chunk-VXYECVIB.js";export{a as MenuItemType};
1
+ import"../chunk-BHW7CEID.js";import"../chunk-IS7TJ54I.js";import"../chunk-5L7EI47O.js";import"../chunk-MBLLQB7A.js";import"../chunk-ZJYDN5YH.js";import"../chunk-UK5NIPTI.js";import"../chunk-ZYJGHEAC.js";import"../chunk-BZYGOU7Y.js";import"../chunk-UGD4MMRB.js";import"../chunk-LAADEEXW.js";import"../chunk-BHMVW2ZZ.js";import{a}from"../chunk-ZMWHBFUG.js";import"../chunk-VXYECVIB.js";export{a as MenuItemType};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Page within a sequence
3
+ */
4
+ export declare type NavigationLink = {
5
+ /** page title */
6
+ title: string;
7
+ /** page route */
8
+ route: string;
9
+ };
10
+ /**
11
+ * [[`Navigation`]] specifies page navigation such as next or previous pages
12
+ */
13
+ export declare type Navigation = {
14
+ /** next page in sequence */
15
+ next?: NavigationLink;
16
+ /** previous page in sequence */
17
+ prev?: NavigationLink;
18
+ };
19
+ export declare type NavigationSlice = {
20
+ navigation?: Navigation;
21
+ };
@@ -0,0 +1 @@
1
+ import"../chunk-LAADEEXW.js";
@@ -1 +1 @@
1
- import{a}from"./chunk-MSLRBBS3.js";import"./chunk-WCQXIIQB.js";import"./chunk-5L7EI47O.js";import"./chunk-MBLLQB7A.js";import"./chunk-ZJYDN5YH.js";import"./chunk-UK5NIPTI.js";import"./chunk-ZYJGHEAC.js";import"./chunk-BZYGOU7Y.js";import"./chunk-UGD4MMRB.js";import"./chunk-BHMVW2ZZ.js";import"./chunk-IS7TJ54I.js";import"./chunk-ZMWHBFUG.js";import"./chunk-VXYECVIB.js";import"./chunk-2G7SPWFY.js";export{a as useAppHeader};
1
+ import{a}from"./chunk-O3KBYHXA.js";import"./chunk-BHW7CEID.js";import"./chunk-IS7TJ54I.js";import"./chunk-5L7EI47O.js";import"./chunk-MBLLQB7A.js";import"./chunk-ZJYDN5YH.js";import"./chunk-UK5NIPTI.js";import"./chunk-ZYJGHEAC.js";import"./chunk-BZYGOU7Y.js";import"./chunk-UGD4MMRB.js";import"./chunk-LAADEEXW.js";import"./chunk-BHMVW2ZZ.js";import"./chunk-ZMWHBFUG.js";import"./chunk-VXYECVIB.js";import"./chunk-ZEATWUZ3.js";export{a as useAppHeader};
@@ -1 +1 @@
1
- import{a}from"./chunk-SPCIWRRP.js";import"./chunk-2G7SPWFY.js";export{a as useBreadcrumbs};
1
+ import{a}from"./chunk-UWHTRXA5.js";import"./chunk-ZEATWUZ3.js";export{a as useBreadcrumbs};
@@ -1 +1 @@
1
- import{a}from"./chunk-W6IABN6M.js";import"./chunk-2G7SPWFY.js";export{a as useColorMode};
1
+ import{a}from"./chunk-B2ENOVOY.js";import"./chunk-ZEATWUZ3.js";export{a as useColorMode};
package/dist/useFooter.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-6B3RGLQ6.js";import"./chunk-2G7SPWFY.js";export{a as useFooter};
1
+ import{a}from"./chunk-RGA5W3OD.js";import"./chunk-ZEATWUZ3.js";export{a as useFooter};
package/dist/useLayout.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-CI2QHT55.js";import"./chunk-2G7SPWFY.js";export{a as useLayout};
1
+ import{a}from"./chunk-LHWBY2OA.js";import"./chunk-ZEATWUZ3.js";export{a as useLayout};
package/dist/useMeta.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-74B44ZUJ.js";import"./chunk-2G7SPWFY.js";export{a as useMeta};
1
+ import{a}from"./chunk-VKGBN5I5.js";import"./chunk-ZEATWUZ3.js";export{a as useMeta};
@@ -0,0 +1,2 @@
1
+ import type { Navigation } from './types';
2
+ export declare function useNavigation(): Navigation;
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-V54ZUOLT.js";import"./chunk-ZEATWUZ3.js";export{a as useNavigation};
package/dist/useRoute.js CHANGED
@@ -1 +1 @@
1
- import{a}from"./chunk-FC2ZNWAP.js";import"./chunk-2G7SPWFY.js";export{a as useRoute};
1
+ import{a}from"./chunk-PZRAIZUK.js";import"./chunk-ZEATWUZ3.js";export{a as useRoute};
@@ -1 +1 @@
1
- import{a}from"./chunk-RK2QZ3ZO.js";import"./chunk-2G7SPWFY.js";export{a as useSearchIndex};
1
+ import{a}from"./chunk-6QFYSQKC.js";import"./chunk-ZEATWUZ3.js";export{a as useSearchIndex};
@@ -1 +1 @@
1
- import{a}from"./chunk-MLBDLE43.js";import"./chunk-FC2ZNWAP.js";import"./chunk-SPCIWRRP.js";import"./chunk-2G7SPWFY.js";export{a as useSidebar};
1
+ import{a}from"./chunk-R6L4QR2K.js";import"./chunk-PZRAIZUK.js";import"./chunk-UWHTRXA5.js";import"./chunk-ZEATWUZ3.js";export{a as useSidebar};
@@ -1 +1 @@
1
- import{a}from"./chunk-23H66E6E.js";import"./chunk-2G7SPWFY.js";export{a as useStoreActions};
1
+ import{a}from"./chunk-U6MP7RD5.js";import"./chunk-ZEATWUZ3.js";export{a as useStoreActions};
@@ -1 +1 @@
1
- import{a}from"./chunk-LS443IBF.js";import"./chunk-2G7SPWFY.js";export{a as useTableOfContents};
1
+ import{a}from"./chunk-PK5C6TQI.js";import"./chunk-ZEATWUZ3.js";export{a as useTableOfContents};
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@jpmorganchase/mosaic-store",
3
3
  "description": "Mosaic - Store for site configuration",
4
- "version": "0.1.0-beta.23",
4
+ "version": "0.1.0-beta.25",
5
5
  "license": "Apache-2.0",
6
6
  "author": "",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git@github.com:jpmorganchase/mosaic.git",
10
+ "directory": "packages/store"
11
+ },
7
12
  "type": "module",
8
13
  "main": "./dist/index.js",
9
14
  "types": "./dist/index.d.ts",
@@ -14,6 +14,7 @@ describe('GIVEN the store initializer', () => {
14
14
  const storeApi = initializeStore();
15
15
  expect(getStateToVerify(storeApi.getState())).toEqual({
16
16
  breadcrumbs: [],
17
+ navigation: {},
17
18
  sidebarData: [],
18
19
  tableOfContents: [],
19
20
  searchIndex: [],
@@ -39,6 +40,7 @@ describe('GIVEN the store initializer', () => {
39
40
  const storeApi = initializeStore(state);
40
41
  expect(getStateToVerify(storeApi.getState())).toEqual({
41
42
  breadcrumbs: [],
43
+ navigation: {},
42
44
  searchIndex: [],
43
45
  sidebarData: [],
44
46
  tableOfContents: [],
@@ -60,6 +62,7 @@ describe('GIVEN the `useCreateStore` hook', () => {
60
62
 
61
63
  expect(getStateToVerify(currentState)).toEqual({
62
64
  breadcrumbs: [],
65
+ navigation: {},
63
66
  searchIndex: [],
64
67
  sidebarData: [],
65
68
  tableOfContents: [],
@@ -78,6 +81,7 @@ describe('GIVEN the `useCreateStore` hook', () => {
78
81
  currentState = result.current().getState();
79
82
  expect(getStateToVerify(currentState)).toEqual({
80
83
  breadcrumbs: [],
84
+ navigation: {},
81
85
  sidebarData: [],
82
86
  searchIndex: [],
83
87
  tableOfContents: [],
@@ -99,6 +103,7 @@ describe('GIVEN the `useCreateStore` hook', () => {
99
103
 
100
104
  expect(getStateToVerify(currentState)).toEqual({
101
105
  breadcrumbs: [],
106
+ navigation: {},
102
107
  searchIndex: [],
103
108
  sidebarData: [],
104
109
  tableOfContents: [],
@@ -118,6 +123,7 @@ describe('GIVEN the `useCreateStore` hook', () => {
118
123
 
119
124
  expect(getStateToVerify(currentState)).toEqual({
120
125
  breadcrumbs: [],
126
+ navigation: {},
121
127
  sidebarData: [],
122
128
  searchIndex: [],
123
129
  tableOfContents: [],
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@ export * from './useBreadcrumbs';
4
4
  export * from './useColorMode';
5
5
  export * from './useLayout';
6
6
  export * from './useMeta';
7
- export * from './useNextPrev';
7
+ export * from './useNavigation';
8
8
  export * from './useRoute';
9
9
  export * from './useSearchIndex';
10
10
  export * from './useSidebar';
package/src/store.ts CHANGED
@@ -6,6 +6,7 @@ import type { BreadcrumbsSlice } from './types/breadcrumbs';
6
6
  import type { SearchIndexSlice } from './types/searchIndex';
7
7
  import type { SharedConfigSlice } from './types/sharedConfig';
8
8
  import type { LayoutSlice } from './types/layout';
9
+ import type { NavigationSlice } from './types/navigation';
9
10
  import type { SidebarSlice } from './types/sidebar';
10
11
  import type { TableOfContentsSlice } from './types/tableOfContents';
11
12
  import type { ColorMode } from './types/colorMode';
@@ -16,6 +17,7 @@ export type SiteState = BreadcrumbsSlice &
16
17
  LayoutSlice &
17
18
  SidebarSlice &
18
19
  TableOfContentsSlice &
20
+ NavigationSlice &
19
21
  SearchIndexSlice &
20
22
  SharedConfigSlice & {
21
23
  /** Page metadata description, used by search */
@@ -38,6 +40,7 @@ function getDefaultInitialState(): DefaultSiteState {
38
40
  breadcrumbs: [],
39
41
  sidebarData: [],
40
42
  tableOfContents: [],
43
+ navigation: {},
41
44
  searchIndex: [],
42
45
  sharedConfig: {},
43
46
  description: undefined,
@@ -4,6 +4,7 @@ export * from './footer';
4
4
  export * from './helpLinks';
5
5
  export * from './layout';
6
6
  export * from './meta';
7
+ export * from './navigation';
7
8
  export * from './route';
8
9
  export * from './searchIndex';
9
10
  export * from './sharedConfig';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Page within a sequence
3
+ */
4
+ export type NavigationLink = {
5
+ /** page title */
6
+ title: string;
7
+ /** page route */
8
+ route: string;
9
+ };
10
+
11
+ /**
12
+ * [[`Navigation`]] specifies page navigation such as next or previous pages
13
+ */
14
+ export type Navigation = {
15
+ /** next page in sequence */
16
+ next?: NavigationLink;
17
+ /** previous page in sequence */
18
+ prev?: NavigationLink;
19
+ };
20
+
21
+ export type NavigationSlice = {
22
+ navigation?: Navigation;
23
+ };
@@ -0,0 +1,10 @@
1
+ import { useStore } from './store';
2
+ import type { Navigation } from './types';
3
+
4
+ export function useNavigation(): Navigation {
5
+ const { next, prev } = useStore(state => state.navigation) || {};
6
+ return {
7
+ next,
8
+ prev
9
+ };
10
+ }
@@ -1 +0,0 @@
1
- import{d as o}from"./chunk-2G7SPWFY.js";var r=()=>o(t=>t.actions);export{r as a};
@@ -1 +0,0 @@
1
- import{useLayoutEffect as s,createContext as S,useContext as d}from"react";import{createStore as c,useStore as l}from"zustand";import{devtools as f,persist as p}from"zustand/middleware";var r;function u(){return{breadcrumbs:[],sidebarData:[],tableOfContents:[],searchIndex:[],sharedConfig:{},description:void 0,layout:void 0,route:void 0,title:void 0,colorMode:"light"}}var n=S(void 0),g=n.Provider,m=e=>f(p(e,{name:"mosaic-theme-pref",partialize:t=>({colorMode:t.colorMode})})),i=(e={})=>c(m(o=>({...u(),...e,actions:{setColorMode:a=>o({colorMode:a})}})));function h(e,t=!1){if(typeof window>"u"||t)return()=>i(e);let o=Boolean(r);return r=r??i(e),s(()=>{e&&o&&r.setState({...r.getState(),...e},!0)}),()=>r}function x(e,t){let o=d(n);if(!o)throw new Error("Missing StoreProvider in the tree");return l(o,e,t)}export{g as a,i as b,h as c,x as d};
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-FC2ZNWAP.js";import{d as i}from"./chunk-2G7SPWFY.js";function p(){let t=i(s=>s.sidebarData)||[],{route:r}=o(),{next:e,prev:n}=d(t,r||"");return{next:e,prev:n}}var m=t=>t.reduce((e,n)=>{if(!n)return e;let s=[...e,{link:n.data.link,text:n.name}];return n.childNodes&&(s=[...e,...m(n.childNodes)]),s},[]),c=(t,r)=>t>=0&&t<r-1,x=(t,r)=>t>0&&t<r,l=(t,r)=>{let e=t.map(a=>a.link).indexOf(r),{length:n}=t,s=c(e,n)?t[e+1]:null,u=x(e,n)?t[e-1]:null;return{next:s,prev:u}},d=(t,r)=>{let e=m(t);return l(e,r)};export{p as a};
@@ -1 +0,0 @@
1
- import{d as o}from"./chunk-2G7SPWFY.js";function f(){return o(e=>e.sharedConfig?.footer)}export{f as a};
@@ -1 +0,0 @@
1
- import{d as t}from"./chunk-2G7SPWFY.js";function e(){return{layout:t(o=>o.layout)}}export{e as a};
@@ -1 +0,0 @@
1
- import{d as e}from"./chunk-2G7SPWFY.js";function u(){return{route:e(t=>t.route)}}export{u as a};
@@ -1 +0,0 @@
1
- import{d as t}from"./chunk-2G7SPWFY.js";function s(){return{tableOfContents:t(e=>e.tableOfContents)||[]}}export{s as a};
@@ -1 +0,0 @@
1
- import{d as o}from"./chunk-2G7SPWFY.js";function d(){return o(r=>r.colorMode)}export{d as a};
@@ -1,9 +0,0 @@
1
- declare type NextPrevItem = {
2
- link: string;
3
- text: string;
4
- };
5
- export declare function useNextPrev(): {
6
- next: NextPrevItem | null;
7
- prev: NextPrevItem | null;
8
- };
9
- export {};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-4GIIWZ26.js";import"./chunk-FC2ZNWAP.js";import"./chunk-2G7SPWFY.js";export{a as useNextPrev};
@@ -1,47 +0,0 @@
1
- import { useStore } from './store';
2
- import { useRoute } from './useRoute';
3
- import type { SidebarItem } from './types/sidebar';
4
-
5
- type NextPrevItem = { link: string; text: string };
6
-
7
- export function useNextPrev() {
8
- const sidebarData = useStore(state => state.sidebarData) || [];
9
- const { route } = useRoute();
10
- const { next, prev } = findNextPrevForRoute(sidebarData, route || '');
11
-
12
- return {
13
- next,
14
- prev
15
- };
16
- }
17
-
18
- const flatten = (nodes: SidebarItem[]): NextPrevItem[] => {
19
- const flattenedNode = nodes.reduce<NextPrevItem[]>((result, node) => {
20
- if (!node) {
21
- return result;
22
- }
23
- let nextResult = [...result, { link: node.data.link, text: node.name }];
24
- if (node.childNodes) {
25
- nextResult = [...result, ...flatten(node.childNodes)];
26
- }
27
- return nextResult;
28
- }, []);
29
- return flattenedNode;
30
- };
31
-
32
- const nextExists = (index: number, length: number) => index >= 0 && index < length - 1;
33
-
34
- const prevExists = (index: number, length: number) => index > 0 && index < length;
35
-
36
- const findNextPrevNodes = (nodes: NextPrevItem[], route: string) => {
37
- const index = nodes.map(e => e.link).indexOf(route);
38
- const { length } = nodes;
39
- const next = nextExists(index, length) ? nodes[index + 1] : null;
40
- const prev = prevExists(index, length) ? nodes[index - 1] : null;
41
- return { next, prev };
42
- };
43
-
44
- const findNextPrevForRoute = (nodes: SidebarItem[], route: string) => {
45
- const flattenedNodes = flatten(nodes);
46
- return findNextPrevNodes(flattenedNodes, route);
47
- };
File without changes