chore: merge
This commit is contained in:
@@ -6,20 +6,19 @@ export { useComponentMap } from '../providers/ComponentMapProvider/index.jsx'
|
||||
export type { IComponentMapContext } from '../providers/ComponentMapProvider/index.jsx'
|
||||
export { ConfigProvider, useConfig } from '../providers/Config/index.jsx'
|
||||
export { useDocumentEvents } from '../providers/DocumentEvents/index.jsx'
|
||||
export { useDocumentInfo } from '../providers/DocumentInfo/index.jsx'
|
||||
export {
|
||||
type DocumentInfo,
|
||||
type DocumentInfoContext,
|
||||
type DocumentInfoProps,
|
||||
DocumentInfoProvider,
|
||||
} from '../providers/DocumentInfo/index.jsx'
|
||||
export { EditDepthContext, EditDepthProvider } from '../providers/EditDepth/index.jsx'
|
||||
export { useEditDepth } from '../providers/EditDepth/index.jsx'
|
||||
export { FormQueryParams, FormQueryParamsProvider } from '../providers/FormQueryParams/index.jsx'
|
||||
export type { QueryParamTypes } from '../providers/FormQueryParams/index.jsx'
|
||||
export { useFormQueryParams } from '../providers/FormQueryParams/index.jsx'
|
||||
export { useListInfo } from '../providers/ListInfo/index.jsx'
|
||||
export { ListInfoProvider } from '../providers/ListInfo/index.jsx'
|
||||
} from '../providers/DocumentInfo/index.js'
|
||||
export { useDocumentInfo } from '../providers/DocumentInfo/index.jsx'
|
||||
export { EditDepthContext, EditDepthProvider } from '../providers/EditDepth/index.js'
|
||||
export { useEditDepth } from '../providers/EditDepth/index.js'
|
||||
export { FormQueryParams, FormQueryParamsProvider } from '../providers/FormQueryParams/index.js'
|
||||
export { useFormQueryParams } from '../providers/FormQueryParams/index.js'
|
||||
export { useListInfo } from '../providers/ListInfo/index.js'
|
||||
export { ListInfoProvider } from '../providers/ListInfo/index.js'
|
||||
export type { ColumnPreferences } from '../providers/ListInfo/types.js'
|
||||
export { useLocale } from '../providers/Locale/index.jsx'
|
||||
export { OperationProvider } from '../providers/OperationProvider/index.jsx'
|
||||
@@ -29,7 +28,6 @@ export {
|
||||
SelectAllStatus,
|
||||
SelectionProvider,
|
||||
useSelection,
|
||||
} from '../providers/SelectionProvider/index.jsx'
|
||||
export { useTheme } from '../providers/Theme/index.jsx'
|
||||
export type { Theme } from '../providers/Theme/types.js'
|
||||
export { useTranslation } from '../providers/Translation/index.jsx'
|
||||
} from '../providers/SelectionProvider/index.js'
|
||||
export { useTheme } from '../providers/Theme/index.js'
|
||||
export { useTranslation } from '../providers/Translation/index.js'
|
||||
|
||||
@@ -8,14 +8,24 @@ import qs from 'qs'
|
||||
import React, { createContext, useCallback, useContext, useEffect, useState } from 'react'
|
||||
import { toast } from 'react-toastify'
|
||||
|
||||
import type { AuthContext } from './types.js'
|
||||
|
||||
import useDebounce from '../../hooks/useDebounce.js'
|
||||
import { useTranslation } from '../../providers/Translation/index.js'
|
||||
import { requests } from '../../utilities/api.js'
|
||||
import { useConfig } from '../Config/index.js'
|
||||
import { useSearchParams } from '../SearchParams/index.js'
|
||||
// import { useLocale } from '../Locale'
|
||||
|
||||
export type AuthContext<T = ClientUser> = {
|
||||
fetchFullUser: () => Promise<void>
|
||||
logOut: () => void
|
||||
permissions?: Permissions
|
||||
refreshCookie: (forceRefresh?: boolean) => void
|
||||
refreshCookieAsync: () => Promise<ClientUser>
|
||||
refreshPermissions: () => Promise<void>
|
||||
setPermissions: (permissions: Permissions) => void
|
||||
setUser: (user: T) => void
|
||||
token?: string
|
||||
user?: T | null
|
||||
}
|
||||
|
||||
const Context = createContext({} as AuthContext)
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import type { ClientUser, Permissions } from 'payload/auth'
|
||||
|
||||
export type AuthContext<T = ClientUser> = {
|
||||
fetchFullUser: () => Promise<void>
|
||||
logOut: () => void
|
||||
permissions?: Permissions
|
||||
refreshCookie: (forceRefresh?: boolean) => void
|
||||
refreshCookieAsync: () => Promise<ClientUser>
|
||||
refreshPermissions: () => Promise<void>
|
||||
setPermissions: (permissions: Permissions) => void
|
||||
setUser: (user: T) => void
|
||||
token?: string
|
||||
user?: T | null
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
'use client'
|
||||
import React, { createContext, useContext, useState } from 'react'
|
||||
|
||||
import type { UpdatedDocument } from './types.js'
|
||||
export type UpdatedDocument = {
|
||||
entitySlug: string
|
||||
id?: number | string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
const Context = createContext({
|
||||
mostRecentUpdate: null,
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
export type UpdatedDocument = {
|
||||
entitySlug: string
|
||||
id?: number | string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export type DocumentEventsContext = {
|
||||
mostRecentUpdate: UpdatedDocument
|
||||
reportUpdate: (updatedDocument: Array<UpdatedDocument>) => void
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import type { Action, FormQueryParamsContext, State } from './types.js'
|
||||
|
||||
import { useLocale } from '../Locale/index.js'
|
||||
|
||||
export type QueryParamTypes = State
|
||||
export type { Action, FormQueryParamsContext, State }
|
||||
|
||||
export const FormQueryParams = createContext({} as FormQueryParamsContext)
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use client'
|
||||
import React, { createContext, useContext } from 'react'
|
||||
|
||||
import type { ListInfoContext, ListInfoProps } from './types.js'
|
||||
import type { ColumnPreferences, ListInfo, ListInfoContext, ListInfoProps } from './types.js'
|
||||
|
||||
export type { ColumnPreferences, ListInfo, ListInfoContext, ListInfoProps }
|
||||
|
||||
const Context = createContext({} as ListInfoContext)
|
||||
|
||||
|
||||
@@ -89,5 +89,3 @@ export const LocaleProvider: React.FC<{ children?: React.ReactNode }> = ({ child
|
||||
* A hook that returns the current locale object.
|
||||
*/
|
||||
export const useLocale = (): Locale => useContext(LocaleContext)
|
||||
|
||||
export default LocaleContext
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import type React from 'react'
|
||||
|
||||
import ReactDOM from 'react-dom'
|
||||
|
||||
const Portal = ({ children }: { children: React.ReactNode }): React.ReactPortal =>
|
||||
ReactDOM.createPortal(children, document.getElementById('portal'))
|
||||
|
||||
export default Portal
|
||||
@@ -3,7 +3,9 @@
|
||||
import { usePathname, useRouter } from 'next/navigation.js'
|
||||
import React, { createContext, useCallback, useContext, useEffect } from 'react'
|
||||
|
||||
import type { RouteCacheContext } from './types.js'
|
||||
export type RouteCacheContext = {
|
||||
clearRouteCache: () => void
|
||||
}
|
||||
|
||||
const Context = createContext<RouteCacheContext>({
|
||||
clearRouteCache: () => {},
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export type RouteCacheContext = {
|
||||
clearRouteCache: () => void
|
||||
}
|
||||
@@ -3,7 +3,12 @@ import { useSearchParams as useNextSearchParams } from 'next/navigation.js'
|
||||
import qs from 'qs'
|
||||
import React, { createContext, useContext } from 'react'
|
||||
|
||||
import type { SearchParamsContext, State } from './types.js'
|
||||
export type SearchParamsContext = {
|
||||
searchParams: qs.ParsedQs
|
||||
stringifyParams: ({ params, replace }: { params: State; replace?: boolean }) => string
|
||||
}
|
||||
|
||||
export type State = qs.ParsedQs
|
||||
|
||||
const initialContext: SearchParamsContext = {
|
||||
searchParams: {},
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export type SearchParamsContext = {
|
||||
searchParams: qs.ParsedQs
|
||||
stringifyParams: ({ params, replace }: { params: State; replace?: boolean }) => string
|
||||
}
|
||||
|
||||
export type State = qs.ParsedQs
|
||||
@@ -75,5 +75,3 @@ export const ThemeProvider: React.FC<{ children?: React.ReactNode }> = ({ childr
|
||||
}
|
||||
|
||||
export const useTheme = (): ThemeContext => useContext(Context)
|
||||
|
||||
export default Context
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
export type Theme = 'dark' | 'light'
|
||||
|
||||
export type ThemeContext = {
|
||||
autoMode: boolean
|
||||
setTheme: (theme: Theme) => void
|
||||
theme: Theme
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import type { Theme } from './types.js'
|
||||
|
||||
export function themeIsValid(string: null | string): string is Theme {
|
||||
return string ? ['dark', 'light'].includes(string) : false
|
||||
}
|
||||
|
||||
export const getImplicitPreference = (): Theme | null => {
|
||||
const mediaQuery = '(prefers-color-scheme: dark)'
|
||||
const mql = window.matchMedia(mediaQuery)
|
||||
const hasImplicitPreference = typeof mql.matches === 'boolean'
|
||||
|
||||
if (hasImplicitPreference) {
|
||||
return mql.matches ? 'dark' : 'light'
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user