@chem-po/react-web 0.0.11 → 0.0.12
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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/box/MobileFrame/index.tsx +2 -1
- package/src/components/list/DataList.tsx +2 -2
- package/src/components/list/types.ts +1 -4
- package/src/components/nav/NavBar.tsx +2 -1
- package/src/contexts/index.ts +1 -0
- package/src/contexts/view.tsx +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chem-po/react-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"react-window-infinite-loader": "^1.0.9",
|
|
41
41
|
"@hello-pangea/dnd": "^18.0.1",
|
|
42
42
|
"zustand": "^4.3.3",
|
|
43
|
-
"@chem-po/
|
|
44
|
-
"@chem-po/
|
|
43
|
+
"@chem-po/core": "0.0.12",
|
|
44
|
+
"@chem-po/react": "0.0.12"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^19.0.0",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Box, Center, Flex, useColorModeValue } from '@chakra-ui/react'
|
|
2
2
|
import { cssGradients } from '@chem-po/core'
|
|
3
|
-
import { MobileFrameProvider, useScreen,
|
|
3
|
+
import { MobileFrameProvider, useScreen, View } from '@chem-po/react'
|
|
4
4
|
import { AnimatePresence, motion } from 'framer-motion'
|
|
5
5
|
import React, { PropsWithChildren, ReactNode, useMemo, useRef } from 'react'
|
|
6
6
|
import { ErrorBoundary } from 'react-error-boundary'
|
|
7
7
|
import { matchRoutes, useLocation, useOutlet } from 'react-router-dom'
|
|
8
8
|
import { CSSTransition, SwitchTransition } from 'react-transition-group'
|
|
9
|
+
import { useViews, ViewsProvider } from '../../../contexts/view'
|
|
9
10
|
import { ForceMobile } from '../../modal/ForceMobile'
|
|
10
11
|
import { NAV_BAR_HEIGHT, NavBar } from '../../nav/NavBar'
|
|
11
12
|
import { ErrorView } from '../../view/ErrorView'
|
|
@@ -12,7 +12,7 @@ import { ListViewProps } from './types'
|
|
|
12
12
|
|
|
13
13
|
export const DataList = <T extends AnyObject>({
|
|
14
14
|
list,
|
|
15
|
-
basePath,
|
|
15
|
+
// basePath,
|
|
16
16
|
flexProps,
|
|
17
17
|
infiniteScroll,
|
|
18
18
|
...rest
|
|
@@ -21,7 +21,7 @@ export const DataList = <T extends AnyObject>({
|
|
|
21
21
|
adapter: { db },
|
|
22
22
|
} = useBackendBase()
|
|
23
23
|
const { baseQuery } = list
|
|
24
|
-
const state = useDataListData(list, infiniteScroll
|
|
24
|
+
const state = useDataListData(list, infiniteScroll)
|
|
25
25
|
const data = usePaginatedQuery<T>(db, baseQuery, !!infiniteScroll)
|
|
26
26
|
return (
|
|
27
27
|
<PaginatedListProvider<T> state={state} data={data}>
|
|
@@ -23,7 +23,4 @@ export type ListViewProps<T extends AnyObject> = ListProviderProps<T> & {
|
|
|
23
23
|
modals?: ReactNode
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export type ListContentProps<T extends AnyObject> = Omit<
|
|
27
|
-
ListViewProps<T>,
|
|
28
|
-
'list' | 'basePath' | 'flexProps'
|
|
29
|
-
>
|
|
26
|
+
export type ListContentProps<T extends AnyObject> = Omit<ListViewProps<T>, 'list' | 'flexProps'>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Button, Flex, Image, useColorModeValue } from '@chakra-ui/react'
|
|
2
2
|
import { palette } from '@chem-po/core'
|
|
3
|
-
import {
|
|
3
|
+
import { View } from '@chem-po/react'
|
|
4
4
|
import React, { PropsWithChildren, useMemo } from 'react'
|
|
5
5
|
import { Link, useLocation } from 'react-router-dom'
|
|
6
|
+
import { useViews } from '../../contexts/view'
|
|
6
7
|
|
|
7
8
|
export const NAV_BAR_HEIGHT = 50
|
|
8
9
|
|
package/src/contexts/index.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { BaseUserData, getUserViews, getViewRoutes, View } from '@chem-po/core'
|
|
2
|
+
import { useAuth } from '@chem-po/react'
|
|
3
|
+
import React, { createContext, FC, PropsWithChildren, useContext, useMemo } from 'react'
|
|
4
|
+
import { RouteObject } from 'react-router'
|
|
5
|
+
|
|
6
|
+
export const ViewsContext = createContext<
|
|
7
|
+
Array<{ view: View<FC, BaseUserData>; routes: RouteObject[] }>
|
|
8
|
+
>([])
|
|
9
|
+
|
|
10
|
+
export const useViews = () => useContext(ViewsContext)
|
|
11
|
+
|
|
12
|
+
export const ViewsProvider = ({
|
|
13
|
+
children,
|
|
14
|
+
views,
|
|
15
|
+
}: PropsWithChildren & { views: Array<View<FC, BaseUserData>> }) => {
|
|
16
|
+
const user = useAuth(s => s.user)
|
|
17
|
+
const value = useMemo(
|
|
18
|
+
() =>
|
|
19
|
+
getUserViews(views, user).map(view => ({
|
|
20
|
+
view,
|
|
21
|
+
routes: getViewRoutes(view),
|
|
22
|
+
})),
|
|
23
|
+
[user, views],
|
|
24
|
+
)
|
|
25
|
+
return <ViewsContext.Provider value={value}>{children}</ViewsContext.Provider>
|
|
26
|
+
}
|