@jpmorganchase/mosaic-store 0.1.0-beta.44 → 0.1.0-beta.46
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 +1 -1
- package/CHANGELOG.md +10 -0
- package/dist/chunk-2LDP6ZYH.js +1 -0
- package/dist/chunk-2NGTHKWE.js +1 -0
- package/dist/{chunk-BWQLFNPL.js → chunk-D3E7HZ32.js} +1 -1
- package/dist/chunk-EDMM5TSL.js +1 -0
- package/dist/chunk-EOCK5YS5.js +1 -0
- package/dist/{chunk-6PEKMIY4.js → chunk-GNWK3KEN.js} +1 -1
- package/dist/{chunk-THKJVARP.js → chunk-JDX7D2AR.js} +1 -1
- package/dist/chunk-KAG3ZTOY.js +1 -0
- package/dist/{chunk-SSINFAKX.js → chunk-MCTKSIA2.js} +1 -1
- package/dist/{chunk-OTD2Q7J6.js → chunk-SHXJLVWX.js} +1 -1
- package/dist/chunk-UWY445ZF.js +1 -0
- package/dist/chunk-X5BH4J65.js +1 -0
- package/dist/{chunk-5TVTLI2X.js → chunk-ZIZ7BMWA.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/store.js +1 -1
- 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.js +1 -1
- 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 +46 -0
- package/src/store.ts +8 -2
- package/dist/chunk-AEFS63H5.js +0 -1
- package/dist/chunk-DVDAL7JW.js +0 -1
- package/dist/chunk-OYLDWTGY.js +0 -1
- package/dist/chunk-QVHG25G2.js +0 -1
- package/dist/chunk-RHLTSSFF.js +0 -1
- package/dist/chunk-TCTIPP3K.js +0 -1
- package/dist/chunk-V2SJ6GGH.js +0 -1
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 29718120edbb0234
|
|
2
2
|
@jpmorganchase/mosaic-store:build: $ npm-run-all --parallel build:*
|
|
3
3
|
@jpmorganchase/mosaic-store:build: $ tsc
|
|
4
4
|
@jpmorganchase/mosaic-store:build: $ node ../../scripts/bundle.js
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @jpmorganchase/mosaic-store
|
|
2
2
|
|
|
3
|
+
## 0.1.0-beta.46
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 32e86cfd: ## Fix
|
|
8
|
+
|
|
9
|
+
When a page does not specify a property that is part of the store default props, we use what the default props specify and not what is currently in the store.
|
|
10
|
+
|
|
11
|
+
## 0.1.0-beta.45
|
|
12
|
+
|
|
3
13
|
## 0.1.0-beta.44
|
|
4
14
|
|
|
5
15
|
## 0.1.0-beta.43
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as o}from"./chunk-UWY445ZF.js";function d(){return o(r=>r.colorMode)}export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as e}from"./chunk-UWY445ZF.js";function u(){return{route:e(t=>t.route)}}export{u as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as c}from"./chunk-
|
|
1
|
+
import{d as c}from"./chunk-UWY445ZF.js";function t(){let e=c(r=>r.searchIndex),o=c(r=>r.searchConfig),n=o!==void 0&&e!==void 0&&e.length>0;return{searchEnabled:n,searchIndex:n?e:[],searchConfig:n?o:{}}}export{t as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t}from"./chunk-UWY445ZF.js";function s(){return{tableOfContents:t(e=>e.tableOfContents)||[]}}export{s as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as o}from"./chunk-UWY445ZF.js";function f(){return o(e=>e.sharedConfig?.footer)}export{f as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e}from"./chunk-
|
|
1
|
+
import{d as e}from"./chunk-UWY445ZF.js";function m(t=1){let r=e(b=>b.breadcrumbs);return{breadcrumbs:r||[],enabled:r?.length>t}}export{m as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as t}from"./chunk-
|
|
1
|
+
import{d as t}from"./chunk-UWY445ZF.js";function r(){let{next:o,prev:i}=t(n=>n.navigation)||{};return{next:o,prev:i}}export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t}from"./chunk-UWY445ZF.js";function e(){return{layout:t(o=>o.layout)}}export{e as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-2NGTHKWE.js";import{a as o}from"./chunk-GNWK3KEN.js";import{d as t}from"./chunk-UWY445ZF.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 +1 @@
|
|
|
1
|
-
import{d as t}from"./chunk-
|
|
1
|
+
import{d as t}from"./chunk-UWY445ZF.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{useLayoutEffect as l,createContext as f,useContext as p}from"react";import{createStore as u,useStore as m}from"zustand";import{devtools as y,persist as C}from"zustand/middleware";var r;function n(){return{breadcrumbs:[],sidebarData:[],tableOfContents:[],navigation:{},searchIndex:[],searchConfig:{},sharedConfig:{},description:void 0,layout:void 0,route:void 0,title:void 0,colorMode:"light"}}var s=f(void 0),P=s.Provider,g=e=>y(C(e,{name:"mosaic-theme-pref",partialize:t=>({colorMode:t.colorMode})})),a=(e={})=>u(g(o=>({...n(),...e,actions:{setColorMode:i=>o({colorMode:i})}})));function T(e,t=!1){if(typeof window>"u"||t)return()=>a(e);let o=Boolean(r);return r=r??a(e),l(()=>{if(e&&o){let i={...n(),...e},{colorMode:S,actions:d,...c}=r.getState();r.setState({...c,...i,colorMode:S,actions:d},!0)}}),()=>r}function v(e,t){let o=p(s);if(!o)throw new Error("Missing StoreProvider in the tree");return m(o,e,t)}export{P as a,a as b,T as c,v as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as o}from"./chunk-UWY445ZF.js";var r=()=>o(t=>t.actions);export{r as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as t}from"./chunk-
|
|
1
|
+
import{d as t}from"./chunk-UWY445ZF.js";function o(){return{meta:t(e=>({description:e.description,breadcrumbs:e.breadcrumbs,title:e.title}))}}export{o as a};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"./chunk-
|
|
1
|
+
import{a as c}from"./chunk-JDX7D2AR.js";import{a as g}from"./chunk-D3E7HZ32.js";import{a as h}from"./chunk-MCTKSIA2.js";import{a as d}from"./chunk-2NGTHKWE.js";import{a as k}from"./chunk-X5BH4J65.js";import{a as i}from"./chunk-EDMM5TSL.js";import{a as p}from"./chunk-SHXJLVWX.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-GNWK3KEN.js";import{a as x}from"./chunk-2LDP6ZYH.js";import{a as j}from"./chunk-EOCK5YS5.js";import{a}from"./chunk-KAG3ZTOY.js";import{a as b}from"./chunk-ZIZ7BMWA.js";import{a as o,b as r,c as e,d as f}from"./chunk-UWY445ZF.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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-
|
|
1
|
+
import{a,b,c,d}from"./chunk-UWY445ZF.js";export{a as StoreProvider,b as initializeStore,c as useCreateStore,d as useStore};
|
package/dist/useAppHeader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-SHXJLVWX.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-UWY445ZF.js";export{a as useAppHeader};
|
package/dist/useBreadcrumbs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-GNWK3KEN.js";import"./chunk-UWY445ZF.js";export{a as useBreadcrumbs};
|
package/dist/useColorMode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-2LDP6ZYH.js";import"./chunk-UWY445ZF.js";export{a as useColorMode};
|
package/dist/useFooter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-EOCK5YS5.js";import"./chunk-UWY445ZF.js";export{a as useFooter};
|
package/dist/useLayout.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-KAG3ZTOY.js";import"./chunk-UWY445ZF.js";export{a as useLayout};
|
package/dist/useMeta.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-ZIZ7BMWA.js";import"./chunk-UWY445ZF.js";export{a as useMeta};
|
package/dist/useNavigation.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-JDX7D2AR.js";import"./chunk-UWY445ZF.js";export{a as useNavigation};
|
package/dist/useRoute.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-2NGTHKWE.js";import"./chunk-UWY445ZF.js";export{a as useRoute};
|
package/dist/useSearchIndex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-D3E7HZ32.js";import"./chunk-UWY445ZF.js";export{a as useSearchIndex};
|
package/dist/useSidebar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-MCTKSIA2.js";import"./chunk-2NGTHKWE.js";import"./chunk-GNWK3KEN.js";import"./chunk-UWY445ZF.js";export{a as useSidebar};
|
package/dist/useStoreActions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-X5BH4J65.js";import"./chunk-UWY445ZF.js";export{a as useStoreActions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-EDMM5TSL.js";import"./chunk-UWY445ZF.js";export{a as useTableOfContents};
|
package/package.json
CHANGED
|
@@ -97,6 +97,52 @@ describe('GIVEN the `useCreateStore` hook', () => {
|
|
|
97
97
|
title: undefined
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
|
+
test('THEN defaults applied when page props do not include default state', () => {
|
|
101
|
+
const state: { layout?: string; description: string } = {
|
|
102
|
+
layout: 'layout',
|
|
103
|
+
description: 'des'
|
|
104
|
+
};
|
|
105
|
+
const { result, rerender } = renderHook(() => useCreateStore(state));
|
|
106
|
+
let currentState = result.current().getState();
|
|
107
|
+
|
|
108
|
+
expect(getStateToVerify(currentState)).toEqual({
|
|
109
|
+
breadcrumbs: [],
|
|
110
|
+
navigation: {},
|
|
111
|
+
searchIndex: [],
|
|
112
|
+
searchConfig: {},
|
|
113
|
+
sidebarData: [],
|
|
114
|
+
tableOfContents: [],
|
|
115
|
+
sharedConfig: {},
|
|
116
|
+
colorMode: 'light',
|
|
117
|
+
...state,
|
|
118
|
+
route: undefined,
|
|
119
|
+
title: undefined
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* we use delete here because the idea is that the page does not indicate a layout IN ANY WAY
|
|
124
|
+
* This is different from the page saying my layout is undefined
|
|
125
|
+
*/
|
|
126
|
+
delete state.layout;
|
|
127
|
+
state.description = 'description';
|
|
128
|
+
rerender();
|
|
129
|
+
|
|
130
|
+
currentState = result.current().getState();
|
|
131
|
+
expect(getStateToVerify(currentState)).toEqual({
|
|
132
|
+
breadcrumbs: [],
|
|
133
|
+
navigation: {},
|
|
134
|
+
sidebarData: [],
|
|
135
|
+
searchIndex: [],
|
|
136
|
+
searchConfig: {},
|
|
137
|
+
tableOfContents: [],
|
|
138
|
+
sharedConfig: {},
|
|
139
|
+
colorMode: 'light',
|
|
140
|
+
description: 'description',
|
|
141
|
+
layout: undefined,
|
|
142
|
+
route: undefined,
|
|
143
|
+
title: undefined
|
|
144
|
+
});
|
|
145
|
+
});
|
|
100
146
|
});
|
|
101
147
|
|
|
102
148
|
describe('WHEN executed on the server', () => {
|
package/src/store.ts
CHANGED
|
@@ -102,12 +102,18 @@ function useCreateStore(serverInitialState: Partial<SiteState>, isSSR = false) {
|
|
|
102
102
|
// states on CSR page navigation or not. I have chosen not to, but if you choose to,
|
|
103
103
|
// then add `serverInitialState = getDefaultInitialState()` here.
|
|
104
104
|
if (serverInitialState && isReusingStore) {
|
|
105
|
+
// recombine the page props with the initial state so that if page props are missing something then the default gets applied
|
|
106
|
+
const pageState = { ...getDefaultInitialState(), ...serverInitialState };
|
|
107
|
+
const { colorMode, actions, ...restStoreState } = store.getState();
|
|
108
|
+
|
|
105
109
|
store.setState(
|
|
106
110
|
{
|
|
107
111
|
// re-use functions from existing store
|
|
108
|
-
...
|
|
112
|
+
...restStoreState,
|
|
109
113
|
// but reset all other properties.
|
|
110
|
-
...
|
|
114
|
+
...pageState,
|
|
115
|
+
colorMode,
|
|
116
|
+
actions
|
|
111
117
|
},
|
|
112
118
|
true // replace states, rather than shallow merging
|
|
113
119
|
);
|
package/dist/chunk-AEFS63H5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as t}from"./chunk-QVHG25G2.js";function e(){return{layout:t(o=>o.layout)}}export{e as a};
|
package/dist/chunk-DVDAL7JW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./chunk-QVHG25G2.js";function f(){return o(e=>e.sharedConfig?.footer)}export{f as a};
|
package/dist/chunk-OYLDWTGY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./chunk-QVHG25G2.js";var r=()=>o(t=>t.actions);export{r as a};
|
package/dist/chunk-QVHG25G2.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:[],navigation:{},searchIndex:[],searchConfig:{},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/chunk-RHLTSSFF.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as o}from"./chunk-QVHG25G2.js";function d(){return o(r=>r.colorMode)}export{d as a};
|
package/dist/chunk-TCTIPP3K.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as e}from"./chunk-QVHG25G2.js";function u(){return{route:e(t=>t.route)}}export{u as a};
|
package/dist/chunk-V2SJ6GGH.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as t}from"./chunk-QVHG25G2.js";function s(){return{tableOfContents:t(e=>e.tableOfContents)||[]}}export{s as a};
|