Skip to content

Commit

Permalink
refactor(structure): move PaneRouterContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 569c0f9 commit e765a47
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 23 deletions.
1 change: 1 addition & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export * from './structure/comments/selected-path/CommentsSelectedPathContext'
export * from './structure/comments/upsell/CommentsUpsellContext'
export * from './structure/components/pane/PaneContext'
export * from './structure/components/pane/PaneLayoutContext'
export * from './structure/components/paneRouter/PaneRouterContext'
export * from './structure/panes/document/DocumentPaneContext'
export * from './structure/StructureToolContext'
export * from './studio/activeWorkspaceMatcher/ActiveWorkspaceMatcherContext'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createContext} from 'react'

import {type PaneRouterContextValue} from './types'
import type {PaneRouterContextValue} from '../../../../structure/components/paneRouter/types'

function missingContext<T = unknown>(): T {
throw new Error('Pane is missing router context')
Expand Down
8 changes: 1 addition & 7 deletions packages/sanity/src/desk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ import {
type PaneMenuItemGroup as _PaneMenuItemGroup,
type PaneNode as _PaneNode,
type PaneNodeResolver as _PaneNodeResolver,
PaneRouterContext as _PaneRouterContext,
type PaneRouterContextValue as _PaneRouterContextValue,
type ParameterizedLinkProps as _ParameterizedLinkProps,
type PartialDocumentList as _PartialDocumentList,
Expand Down Expand Up @@ -915,12 +914,7 @@ export const MenuItemGroupBuilder = _MenuItemGroupBuilder
* @beta
*/
export const PaneLayout = _PaneLayout
/**
* @deprecated Import from `sanity/structure` instead!
* @hidden
* @beta
*/
export const PaneRouterContext = _PaneRouterContext

/**
* @deprecated Import from `sanity/structure` instead!
* @hidden
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type ComponentType, type ForwardedRef, forwardRef, useContext, useMemo} from 'react'
import {PaneRouterContext} from 'sanity/_singletons'
import {StateLink} from 'sanity/router'

import {PaneRouterContext} from './PaneRouterContext'
import {type BackLinkProps} from './types'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {type ForwardedRef, forwardRef, useContext} from 'react'
import {PaneRouterContext} from 'sanity/_singletons'
import {StateLink} from 'sanity/router'

import {PaneRouterContext} from './PaneRouterContext'
import {type ChildLinkProps} from './types'

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {toString as pathToString} from '@sanity/util/paths'
import {omit} from 'lodash'
import {type ReactNode, useCallback, useMemo} from 'react'
import {PaneRouterContext} from 'sanity/_singletons'
import {useRouter, useRouterState} from 'sanity/router'

import {type RouterPaneGroup, type RouterPanes, type RouterPaneSibling} from '../../types'
import {usePaneLayout} from '../pane/usePaneLayout'
import {BackLink} from './BackLink'
import {ChildLink} from './ChildLink'
import {PaneRouterContext} from './PaneRouterContext'
import {ParameterizedLink} from './ParameterizedLink'
import {ReferenceChildLink} from './ReferenceChildLink'
import {type PaneRouterContextValue} from './types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {type ForwardedRef, forwardRef, type ReactNode, useContext, useMemo} from 'react'
import {useUnique} from 'sanity'
import {PaneRouterContext} from 'sanity/_singletons'
import {StateLink} from 'sanity/router'

import {PaneRouterContext} from './PaneRouterContext'

interface ParameterizedLinkProps {
params?: Record<string, string>
payload?: unknown
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './BackLink'
export * from './PaneRouterContext'
export * from './PaneRouterProvider'
export * from './types'
export * from './usePaneRouter'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useContext} from 'react'
import {PaneRouterContext} from 'sanity/_singletons'

import {PaneRouterContext} from './PaneRouterContext'
import {type PaneRouterContextValue} from './types'

/**
Expand Down
9 changes: 1 addition & 8 deletions packages/sanity/src/structure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ export type {
ParameterizedLinkProps,
ReferenceChildLinkProps,
} from './components'
export {
ConfirmDeleteDialog,
Pane,
PaneContent,
PaneLayout,
PaneRouterContext,
usePaneRouter,
} from './components'
export {ConfirmDeleteDialog, Pane, PaneContent, PaneLayout, usePaneRouter} from './components'
export {structureLocaleNamespace, type StructureLocaleResourceKeys} from './i18n'
export * from './panes/document'
export {DocumentInspectorHeader} from './panes/document/documentInspector'
Expand Down

0 comments on commit e765a47

Please sign in to comment.