@jpmorganchase/mosaic-store 0.1.0-beta.24 → 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.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-RK2QZ3ZO.js → chunk-6QFYSQKC.js} +1 -1
- package/dist/chunk-B2ENOVOY.js +1 -0
- package/dist/chunk-LAADEEXW.js +0 -0
- package/dist/chunk-LHWBY2OA.js +1 -0
- package/dist/{chunk-MSLRBBS3.js → chunk-O3KBYHXA.js} +1 -1
- package/dist/chunk-PK5C6TQI.js +1 -0
- package/dist/chunk-PZRAIZUK.js +1 -0
- package/dist/{chunk-MLBDLE43.js → chunk-R6L4QR2K.js} +1 -1
- package/dist/chunk-RGA5W3OD.js +1 -0
- package/dist/chunk-U6MP7RD5.js +1 -0
- package/dist/{chunk-SPCIWRRP.js → chunk-UWHTRXA5.js} +1 -1
- package/dist/chunk-V54ZUOLT.js +1 -0
- package/dist/{chunk-74B44ZUJ.js → chunk-VKGBN5I5.js} +1 -1
- package/dist/chunk-ZEATWUZ3.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/store.d.ts +2 -1
- package/dist/store.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -1
- package/dist/types/navigation.d.ts +21 -0
- package/dist/types/navigation.js +1 -0
- package/dist/useAppHeader.js +1 -1
- package/dist/useBreadcrumbs.js +1 -1
- package/dist/useColorMode.js +1 -1
- package/dist/useFooter.js +1 -1
- package/dist/useLayout.js +1 -1
- package/dist/useMeta.js +1 -1
- package/dist/useNavigation.d.ts +2 -0
- package/dist/useNavigation.js +1 -0
- package/dist/useRoute.js +1 -1
- package/dist/useSearchIndex.js +1 -1
- package/dist/useSidebar.js +1 -1
- package/dist/useStoreActions.js +1 -1
- package/dist/useTableOfContents.js +1 -1
- package/package.json +1 -1
- package/src/__tests__/store.test.ts +6 -0
- package/src/index.ts +1 -1
- package/src/store.ts +3 -0
- package/src/types/index.ts +1 -0
- package/src/types/navigation.ts +23 -0
- package/src/useNavigation.ts +10 -0
- package/dist/chunk-23H66E6E.js +0 -1
- package/dist/chunk-2G7SPWFY.js +0 -1
- package/dist/chunk-4GIIWZ26.js +0 -1
- package/dist/chunk-6B3RGLQ6.js +0 -1
- package/dist/chunk-CI2QHT55.js +0 -1
- package/dist/chunk-FC2ZNWAP.js +0 -1
- package/dist/chunk-LS443IBF.js +0 -1
- package/dist/chunk-W6IABN6M.js +0 -1
- package/dist/useNextPrev.d.ts +0 -9
- package/dist/useNextPrev.js +0 -1
- package/src/useNextPrev.ts +0 -47
- /package/dist/{chunk-WCQXIIQB.js → chunk-BHW7CEID.js} +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@jpmorganchase/mosaic-store:build: cache hit, replaying output
|
|
1
|
+
@jpmorganchase/mosaic-store:build: cache hit, replaying output aafdfdc702557658
|
|
2
2
|
@jpmorganchase/mosaic-store:build: $ npm-run-all --parallel build:*
|
|
3
|
-
@jpmorganchase/mosaic-store:build: $ tsc
|
|
4
3
|
@jpmorganchase/mosaic-store:build: $ node ../../scripts/bundle.js
|
|
4
|
+
@jpmorganchase/mosaic-store:build: $ tsc
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 0.1.0-beta.24
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as r}from"./chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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 './
|
|
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
|
|
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-
|
|
1
|
+
import{a,b,c,d}from"./chunk-ZEATWUZ3.js";export{a as StoreProvider,b as initializeStore,c as useCreateStore,d as useStore};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-
|
|
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";
|
package/dist/useAppHeader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
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};
|
package/dist/useBreadcrumbs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-UWHTRXA5.js";import"./chunk-ZEATWUZ3.js";export{a as useBreadcrumbs};
|
package/dist/useColorMode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
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-
|
|
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-
|
|
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-
|
|
1
|
+
import{a}from"./chunk-VKGBN5I5.js";import"./chunk-ZEATWUZ3.js";export{a as useMeta};
|
|
@@ -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-
|
|
1
|
+
import{a}from"./chunk-PZRAIZUK.js";import"./chunk-ZEATWUZ3.js";export{a as useRoute};
|
package/dist/useSearchIndex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-6QFYSQKC.js";import"./chunk-ZEATWUZ3.js";export{a as useSearchIndex};
|
package/dist/useSidebar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-R6L4QR2K.js";import"./chunk-PZRAIZUK.js";import"./chunk-UWHTRXA5.js";import"./chunk-ZEATWUZ3.js";export{a as useSidebar};
|
package/dist/useStoreActions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-U6MP7RD5.js";import"./chunk-ZEATWUZ3.js";export{a as useStoreActions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-PK5C6TQI.js";import"./chunk-ZEATWUZ3.js";export{a as useTableOfContents};
|
package/package.json
CHANGED
|
@@ -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 './
|
|
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,
|
package/src/types/index.ts
CHANGED
|
@@ -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
|
+
};
|
package/dist/chunk-23H66E6E.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./chunk-2G7SPWFY.js";var r=()=>o(t=>t.actions);export{r as a};
|
package/dist/chunk-2G7SPWFY.js
DELETED
|
@@ -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};
|
package/dist/chunk-4GIIWZ26.js
DELETED
|
@@ -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};
|
package/dist/chunk-6B3RGLQ6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./chunk-2G7SPWFY.js";function f(){return o(e=>e.sharedConfig?.footer)}export{f as a};
|
package/dist/chunk-CI2QHT55.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as t}from"./chunk-2G7SPWFY.js";function e(){return{layout:t(o=>o.layout)}}export{e as a};
|
package/dist/chunk-FC2ZNWAP.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as e}from"./chunk-2G7SPWFY.js";function u(){return{route:e(t=>t.route)}}export{u as a};
|
package/dist/chunk-LS443IBF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as t}from"./chunk-2G7SPWFY.js";function s(){return{tableOfContents:t(e=>e.tableOfContents)||[]}}export{s as a};
|
package/dist/chunk-W6IABN6M.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./chunk-2G7SPWFY.js";function d(){return o(r=>r.colorMode)}export{d as a};
|
package/dist/useNextPrev.d.ts
DELETED
package/dist/useNextPrev.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-4GIIWZ26.js";import"./chunk-FC2ZNWAP.js";import"./chunk-2G7SPWFY.js";export{a as useNextPrev};
|
package/src/useNextPrev.ts
DELETED
|
@@ -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
|