From 03294dfd18a951e1c233414b3f475d956ddf7ee1 Mon Sep 17 00:00:00 2001 From: Rico Kahler Date: Fri, 2 Aug 2024 21:41:34 -0500 Subject: [PATCH] refactor: switch to sanity/_createContext --- .../context/ActiveWorkspaceMatcherContext.ts | 2 +- .../context/AddonDatasetContext.ts | 9 +- .../_singletons/context/CalendarContext.ts | 9 +- .../context/ChangeIndicatorTrackerContexts.ts | 14 +- .../context/ColorSchemeSetValueContext.ts | 6 +- .../context/ColorSchemeValueContext.ts | 9 +- .../context/CommentInputContext.ts | 9 +- .../context/CommentsAuthoringPathContext.ts | 5 +- .../_singletons/context/CommentsContext.ts | 9 +- .../context/CommentsEnabledContext.ts | 15 +- .../context/CommentsIntentContext.ts | 2 +- .../context/CommentsOnboardingContext.ts | 9 +- .../context/CommentsSelectedPathContext.ts | 5 +- .../context/CommentsUpsellContext.ts | 9 +- .../_singletons/context/ConnectorContext.ts | 17 ++- .../_singletons/context/CopyPasteContext.ts | 9 +- .../src/_singletons/context/DiffContext.ts | 8 +- .../context/DocumentActionPropsContext.ts | 9 +- .../context/DocumentChangeContext.ts | 9 +- .../context/DocumentFieldActionsContext.ts | 5 +- .../_singletons/context/DocumentIdContext.ts | 7 +- .../context/DocumentPaneContext.ts | 2 +- .../context/DocumentSheetListContext.ts | 5 +- .../context/FieldActionsContext.ts | 21 +-- .../_singletons/context/FormBuilderContext.ts | 9 +- .../context/FormCallbacksContext.ts | 9 +- .../context/FormFieldPresenceContext.ts | 9 +- .../_singletons/context/FormValueContext.ts | 2 +- .../_singletons/context/FreeTrialContext.ts | 9 +- .../context/HoveredFieldContext.ts | 15 +- .../_singletons/context/IsLastPaneContext.ts | 7 +- .../src/_singletons/context/LocaleContext.ts | 6 +- .../_singletons/context/MentionUserContext.ts | 9 +- .../src/_singletons/context/NavbarContext.ts | 21 +-- .../src/_singletons/context/PaneContext.ts | 2 +- .../_singletons/context/PaneLayoutContext.ts | 2 +- .../_singletons/context/PaneRouterContext.tsx | 2 +- .../context/PortableTextMarkersContext.ts | 9 +- .../context/PortableTextMemberItemsContext.ts | 9 +- .../_singletons/context/PresenceContext.ts | 9 +- .../context/PresenceTrackerContexts.ts | 14 +- .../_singletons/context/PreviewCardContext.ts | 11 +- .../context/ReferenceInputOptionsContext.ts | 9 +- .../context/ReferenceItemRefContext.ts | 7 +- .../context/ResourceCacheContext.ts | 2 +- .../context/ReviewChangesContext.ts | 9 +- .../context/RouterHistoryContext.ts | 9 +- .../SchedulePublishingUpsellContext.ts | 31 ++-- .../ScheduledPublishingEnabledContext.ts | 9 +- .../src/_singletons/context/Schedules.ts | 9 +- .../src/_singletons/context/ScrollContext.ts | 7 +- .../src/_singletons/context/SearchContext.ts | 9 +- .../context/SortableItemIdContext.ts | 7 +- .../src/_singletons/context/SourceContext.ts | 2 +- .../src/_singletons/context/TasksContext.ts | 9 +- .../context/TasksEnabledContext.ts | 15 +- .../context/TasksNavigationContext.ts | 9 +- .../_singletons/context/TasksUpsellContext.ts | 9 +- .../context/TreeEditingEnabledContext.ts | 15 +- .../context/UserColorManagerContext.ts | 9 +- .../_singletons/context/ValidationContext.ts | 7 +- .../VirtualizerScrollInstanceContext.ts | 5 +- .../_singletons/context/WorkspaceContext.ts | 2 +- .../_singletons/context/WorkspacesContext.ts | 2 +- .../src/_singletons/context/ZIndexContext.ts | 42 +++++- .../context/zIndexContextDefaults.ts | 36 ----- packages/sanity/src/_singletons/index.ts | 137 +++++++++--------- 67 files changed, 458 insertions(+), 307 deletions(-) delete mode 100644 packages/sanity/src/_singletons/context/zIndexContextDefaults.ts diff --git a/packages/sanity/src/_singletons/context/ActiveWorkspaceMatcherContext.ts b/packages/sanity/src/_singletons/context/ActiveWorkspaceMatcherContext.ts index bcc1296bc37..fe9d3ab62fd 100644 --- a/packages/sanity/src/_singletons/context/ActiveWorkspaceMatcherContext.ts +++ b/packages/sanity/src/_singletons/context/ActiveWorkspaceMatcherContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {ActiveWorkspaceMatcherContextValue} from '../../../../core/studio/activeWorkspaceMatcher/ActiveWorkspaceMatcherContext' +import type {ActiveWorkspaceMatcherContextValue} from '../../core/studio/activeWorkspaceMatcher/ActiveWorkspaceMatcherContext' /** @internal */ export const ActiveWorkspaceMatcherContext = diff --git a/packages/sanity/src/_singletons/context/AddonDatasetContext.ts b/packages/sanity/src/_singletons/context/AddonDatasetContext.ts index 677a538878f..ab4c1215c95 100644 --- a/packages/sanity/src/_singletons/context/AddonDatasetContext.ts +++ b/packages/sanity/src/_singletons/context/AddonDatasetContext.ts @@ -1,9 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {AddonDatasetContextValue} from '../../../../core/studio/addonDataset/types' +import type {AddonDatasetContextValue} from '../../core/studio/addonDataset/types' /** * @beta * @hidden */ -export const AddonDatasetContext = createContext(null) +export const AddonDatasetContext = createContext( + 'sanity/_singletons/context/addon-dataset', + null, +) diff --git a/packages/sanity/src/_singletons/context/CalendarContext.ts b/packages/sanity/src/_singletons/context/CalendarContext.ts index 4db1695d1bd..9f376767c70 100644 --- a/packages/sanity/src/_singletons/context/CalendarContext.ts +++ b/packages/sanity/src/_singletons/context/CalendarContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CalendarContextValue} from '../../../../../../../../../../../../../core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/contexts/CalendarContext' +import type {CalendarContextValue} from '../../core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/contexts/CalendarContext' /** * @internal */ -export const CalendarContext = createContext(undefined) +export const CalendarContext = createContext( + 'sanity/_singletons/context/calendar', + undefined, +) diff --git a/packages/sanity/src/_singletons/context/ChangeIndicatorTrackerContexts.ts b/packages/sanity/src/_singletons/context/ChangeIndicatorTrackerContexts.ts index 230c45c0c74..419881f82fe 100644 --- a/packages/sanity/src/_singletons/context/ChangeIndicatorTrackerContexts.ts +++ b/packages/sanity/src/_singletons/context/ChangeIndicatorTrackerContexts.ts @@ -1,14 +1,20 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' import type { ChangeIndicatorTrackerContextStoreType, ChangeIndicatorTrackerGetSnapshotType, -} from '../../../core/changeIndicators/ChangeIndicatorTrackerContexts' +} from '../../core/changeIndicators/ChangeIndicatorTrackerContexts' /** @internal */ export const ChangeIndicatorTrackerContextStore = - createContext(null) + createContext( + 'sanity/_singletons/context/change-indicator-tracker-store', + null, + ) /** @internal */ export const ChangeIndicatorTrackerContextGetSnapshot = - createContext(null) + createContext( + 'sanity/_singletons/context/change-indicator-tracker-get-snapshot', + null, + ) diff --git a/packages/sanity/src/_singletons/context/ColorSchemeSetValueContext.ts b/packages/sanity/src/_singletons/context/ColorSchemeSetValueContext.ts index b59a6441027..a9f866d93b1 100644 --- a/packages/sanity/src/_singletons/context/ColorSchemeSetValueContext.ts +++ b/packages/sanity/src/_singletons/context/ColorSchemeSetValueContext.ts @@ -1,6 +1,6 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {StudioThemeColorSchemeKey} from '../../../core/theme/types' +import type {StudioThemeColorSchemeKey} from '../../core/theme/types' /** * The setter for ColorSchemeValueContext, in a separate context to avoid unnecessary re-renders @@ -9,4 +9,4 @@ import type {StudioThemeColorSchemeKey} from '../../../core/theme/types' */ export const ColorSchemeSetValueContext = createContext< ((nextScheme: StudioThemeColorSchemeKey) => void) | false | null ->(null) +>('sanity/_singletons/context/color-scheme-set-value', null) diff --git a/packages/sanity/src/_singletons/context/ColorSchemeValueContext.ts b/packages/sanity/src/_singletons/context/ColorSchemeValueContext.ts index fc3ffbdbd66..3fa18ef2174 100644 --- a/packages/sanity/src/_singletons/context/ColorSchemeValueContext.ts +++ b/packages/sanity/src/_singletons/context/ColorSchemeValueContext.ts @@ -1,9 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {StudioThemeColorSchemeKey} from '../../../core/theme/types' +import type {StudioThemeColorSchemeKey} from '../../core/theme/types' /** * Used to keep track of the internal value, which can be "system" in addition to "light" and "dark" * @internal */ -export const ColorSchemeValueContext = createContext(null) +export const ColorSchemeValueContext = createContext( + 'sanity/_singletons/context/color-scheme-value', + null, +) diff --git a/packages/sanity/src/_singletons/context/CommentInputContext.ts b/packages/sanity/src/_singletons/context/CommentInputContext.ts index c4e0bf43378..a261cd898a6 100644 --- a/packages/sanity/src/_singletons/context/CommentInputContext.ts +++ b/packages/sanity/src/_singletons/context/CommentInputContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CommentInputContextValue} from '../../../../../../core/comments/components/pte/comment-input/CommentInputProvider' +import type {CommentInputContextValue} from '../../core/comments/components/pte/comment-input/CommentInputProvider' /** * @internal */ -export const CommentInputContext = createContext(null) +export const CommentInputContext = createContext( + 'sanity/_singletons/context/comment-input', + null, +) diff --git a/packages/sanity/src/_singletons/context/CommentsAuthoringPathContext.ts b/packages/sanity/src/_singletons/context/CommentsAuthoringPathContext.ts index cffd0880fd4..7184f044eec 100644 --- a/packages/sanity/src/_singletons/context/CommentsAuthoringPathContext.ts +++ b/packages/sanity/src/_singletons/context/CommentsAuthoringPathContext.ts @@ -1,11 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CommentsAuthoringPathContextValue} from '../../../../core/comments/context/authoring-path/types' +import type {CommentsAuthoringPathContextValue} from '../../core/comments/context/authoring-path/types' /** * @beta * @hidden */ export const CommentsAuthoringPathContext = createContext( + 'sanity/_singletons/context/comments-authoring-path', null, ) diff --git a/packages/sanity/src/_singletons/context/CommentsContext.ts b/packages/sanity/src/_singletons/context/CommentsContext.ts index 15f7ac4af31..d830e94dd42 100644 --- a/packages/sanity/src/_singletons/context/CommentsContext.ts +++ b/packages/sanity/src/_singletons/context/CommentsContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CommentsContextValue} from '../../../core/comments/context/comments/types' +import type {CommentsContextValue} from '../../core/comments/context/comments/types' /** * @internal */ -export const CommentsContext = createContext(null) +export const CommentsContext = createContext( + 'sanity/_singletons/context/comments', + null, +) diff --git a/packages/sanity/src/_singletons/context/CommentsEnabledContext.ts b/packages/sanity/src/_singletons/context/CommentsEnabledContext.ts index 3cf79fbb056..661477f6d7e 100644 --- a/packages/sanity/src/_singletons/context/CommentsEnabledContext.ts +++ b/packages/sanity/src/_singletons/context/CommentsEnabledContext.ts @@ -1,6 +1,6 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CommentsEnabledContextValue} from '../../../../core/comments/context/enabled/types' +import type {CommentsEnabledContextValue} from '../../core/comments/context/enabled/types' // NOTE: We initialize this context with a default value (`enabled: false`) // rather than `null` to handle cases where the comments feature's availability @@ -11,7 +11,10 @@ import type {CommentsEnabledContextValue} from '../../../../core/comments/contex /** * @internal */ -export const CommentsEnabledContext = createContext({ - enabled: false, - mode: null, -}) +export const CommentsEnabledContext = createContext( + 'sanity/_singletons/context/comments-enabled', + { + enabled: false, + mode: null, + }, +) diff --git a/packages/sanity/src/_singletons/context/CommentsIntentContext.ts b/packages/sanity/src/_singletons/context/CommentsIntentContext.ts index dfc589f1098..f4d0daaf1a8 100644 --- a/packages/sanity/src/_singletons/context/CommentsIntentContext.ts +++ b/packages/sanity/src/_singletons/context/CommentsIntentContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {CommentsIntentContextValue} from '../../../../core/comments/context/intent/types' +import type {CommentsIntentContextValue} from '../../core/comments/context/intent/types' /** * @internal diff --git a/packages/sanity/src/_singletons/context/CommentsOnboardingContext.ts b/packages/sanity/src/_singletons/context/CommentsOnboardingContext.ts index a1465aa7b96..3cb6741e244 100644 --- a/packages/sanity/src/_singletons/context/CommentsOnboardingContext.ts +++ b/packages/sanity/src/_singletons/context/CommentsOnboardingContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CommentsOnboardingContextValue} from '../../../../core/comments/context/onboarding/types' +import type {CommentsOnboardingContextValue} from '../../core/comments/context/onboarding/types' /** * @internal */ -export const CommentsOnboardingContext = createContext(null) +export const CommentsOnboardingContext = createContext( + 'sanity/_singletons/context/comments-onboarding', + null, +) diff --git a/packages/sanity/src/_singletons/context/CommentsSelectedPathContext.ts b/packages/sanity/src/_singletons/context/CommentsSelectedPathContext.ts index 67e78170698..ab5e51fecbb 100644 --- a/packages/sanity/src/_singletons/context/CommentsSelectedPathContext.ts +++ b/packages/sanity/src/_singletons/context/CommentsSelectedPathContext.ts @@ -1,10 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CommentsSelectedPathContextValue} from '../../../../core/comments/context/selected-path/types' +import type {CommentsSelectedPathContextValue} from '../../core/comments/context/selected-path/types' /** * @internal */ export const CommentsSelectedPathContext = createContext( + 'sanity/_singletons/context/comments-selected-path', null, ) diff --git a/packages/sanity/src/_singletons/context/CommentsUpsellContext.ts b/packages/sanity/src/_singletons/context/CommentsUpsellContext.ts index 4139fb17c0d..1aab87728b9 100644 --- a/packages/sanity/src/_singletons/context/CommentsUpsellContext.ts +++ b/packages/sanity/src/_singletons/context/CommentsUpsellContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CommentsUpsellContextValue} from '../../../../core/comments/context/upsell/types' +import type {CommentsUpsellContextValue} from '../../core/comments/context/upsell/types' /** * @internal */ -export const CommentsUpsellContext = createContext(null) +export const CommentsUpsellContext = createContext( + 'sanity/_singletons/context/comments-upsell', + null, +) diff --git a/packages/sanity/src/_singletons/context/ConnectorContext.ts b/packages/sanity/src/_singletons/context/ConnectorContext.ts index 0017dc83b14..c62ef582dd5 100644 --- a/packages/sanity/src/_singletons/context/ConnectorContext.ts +++ b/packages/sanity/src/_singletons/context/ConnectorContext.ts @@ -1,10 +1,13 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {ConnectorContextValue} from '../../../core/changeIndicators/ConnectorContext' +import type {ConnectorContextValue} from '../../core/changeIndicators/ConnectorContext' /** @internal */ -export const ConnectorContext = createContext({ - isReviewChangesOpen: false, - onOpenReviewChanges: () => undefined, - onSetFocus: () => undefined, -} as ConnectorContextValue) +export const ConnectorContext = createContext( + 'sanity/_singletons/context/connector', + { + isReviewChangesOpen: false, + onOpenReviewChanges: () => undefined, + onSetFocus: () => undefined, + } as ConnectorContextValue, +) diff --git a/packages/sanity/src/_singletons/context/CopyPasteContext.ts b/packages/sanity/src/_singletons/context/CopyPasteContext.ts index a168ce4f1c9..948caca8ebe 100644 --- a/packages/sanity/src/_singletons/context/CopyPasteContext.ts +++ b/packages/sanity/src/_singletons/context/CopyPasteContext.ts @@ -1,9 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {CopyPasteContextType} from '../../../../core/studio/copyPaste' +import type {CopyPasteContextType} from '../../core/studio/copyPaste' /** * @beta * @hidden */ -export const CopyPasteContext = createContext(null) +export const CopyPasteContext = createContext( + 'sanity/_singletons/context/copy-paste', + null, +) diff --git a/packages/sanity/src/_singletons/context/DiffContext.ts b/packages/sanity/src/_singletons/context/DiffContext.ts index e8aa30223e6..f081ff82aec 100644 --- a/packages/sanity/src/_singletons/context/DiffContext.ts +++ b/packages/sanity/src/_singletons/context/DiffContext.ts @@ -1,5 +1,9 @@ import type {Path} from '@sanity/types' -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** @internal */ -export const DiffContext = createContext<{path: Path}>({path: []}) +export const DiffContext = createContext<{ + path: Path +}>('sanity/_singletons/context/diff', { + path: [], +}) diff --git a/packages/sanity/src/_singletons/context/DocumentActionPropsContext.ts b/packages/sanity/src/_singletons/context/DocumentActionPropsContext.ts index ad308272118..e7f08684015 100644 --- a/packages/sanity/src/_singletons/context/DocumentActionPropsContext.ts +++ b/packages/sanity/src/_singletons/context/DocumentActionPropsContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {DocumentActionProps} from '../../../core/config/document/actions' +import type {DocumentActionProps} from '../../core/config/document/actions' /** * @internal */ -export const DocumentActionPropsContext = createContext(undefined) +export const DocumentActionPropsContext = createContext( + 'sanity/_singletons/context/document-action-props', + undefined, +) diff --git a/packages/sanity/src/_singletons/context/DocumentChangeContext.ts b/packages/sanity/src/_singletons/context/DocumentChangeContext.ts index 9750592a6e0..886c5901e23 100644 --- a/packages/sanity/src/_singletons/context/DocumentChangeContext.ts +++ b/packages/sanity/src/_singletons/context/DocumentChangeContext.ts @@ -1,6 +1,9 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {DocumentChangeContextInstance} from '../../../../core/field/diff/contexts/DocumentChangeContext' +import type {DocumentChangeContextInstance} from '../../core/field/diff/contexts/DocumentChangeContext' /** @internal */ -export const DocumentChangeContext = createContext(null) +export const DocumentChangeContext = createContext( + 'sanity/_singletons/context/document-change', + null, +) diff --git a/packages/sanity/src/_singletons/context/DocumentFieldActionsContext.ts b/packages/sanity/src/_singletons/context/DocumentFieldActionsContext.ts index 61daf0ebd1b..48ec471efab 100644 --- a/packages/sanity/src/_singletons/context/DocumentFieldActionsContext.ts +++ b/packages/sanity/src/_singletons/context/DocumentFieldActionsContext.ts @@ -1,6 +1,6 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {DocumentFieldAction} from '../../../../core/config/document/fieldActions/types' +import type {DocumentFieldAction} from '../../core/config/document/fieldActions/types' /** * @internal @@ -13,5 +13,6 @@ export interface DocumentFieldActionsContextValue { * @internal */ export const DocumentFieldActionsContext = createContext( + 'sanity/_singletons/context/document-field-actions', null, ) diff --git a/packages/sanity/src/_singletons/context/DocumentIdContext.ts b/packages/sanity/src/_singletons/context/DocumentIdContext.ts index 02c6b84b46b..e409c0121d2 100644 --- a/packages/sanity/src/_singletons/context/DocumentIdContext.ts +++ b/packages/sanity/src/_singletons/context/DocumentIdContext.ts @@ -1,4 +1,4 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** * @internal @@ -10,4 +10,7 @@ export interface DocumentIdContextValue { /** * @internal */ -export const DocumentIdContext = createContext(null) +export const DocumentIdContext = createContext( + 'sanity/_singletons/context/document-id', + null, +) diff --git a/packages/sanity/src/_singletons/context/DocumentPaneContext.ts b/packages/sanity/src/_singletons/context/DocumentPaneContext.ts index 2dd05525b97..27f300baf0f 100644 --- a/packages/sanity/src/_singletons/context/DocumentPaneContext.ts +++ b/packages/sanity/src/_singletons/context/DocumentPaneContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {DocumentPaneContextValue} from '../../../../structure/panes/document/DocumentPaneContext' +import type {DocumentPaneContextValue} from '../../structure/panes/document/DocumentPaneContext' /** @internal */ export const DocumentPaneContext = createContext( diff --git a/packages/sanity/src/_singletons/context/DocumentSheetListContext.ts b/packages/sanity/src/_singletons/context/DocumentSheetListContext.ts index 8011b87d672..3d80de6d9bf 100644 --- a/packages/sanity/src/_singletons/context/DocumentSheetListContext.ts +++ b/packages/sanity/src/_singletons/context/DocumentSheetListContext.ts @@ -1,8 +1,9 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {DocumentSheetListContextValue} from '../../../../structure/panes/documentList/sheetList/DocumentSheetListProvider' +import type {DocumentSheetListContextValue} from '../../structure/panes/documentList/sheetList/DocumentSheetListProvider' /** @internal */ export const DocumentSheetListContext = createContext( + 'sanity/_singletons/context/document-sheet-list', undefined, ) diff --git a/packages/sanity/src/_singletons/context/FieldActionsContext.ts b/packages/sanity/src/_singletons/context/FieldActionsContext.ts index 70385154fb1..de25b0c515d 100644 --- a/packages/sanity/src/_singletons/context/FieldActionsContext.ts +++ b/packages/sanity/src/_singletons/context/FieldActionsContext.ts @@ -1,6 +1,6 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {DocumentFieldActionNode} from '../../../../../core/config/document/fieldActions/types' +import type {DocumentFieldActionNode} from '../../core/config/document/fieldActions/types' /** @internal */ export interface FieldActionsContextValue { @@ -12,10 +12,13 @@ export interface FieldActionsContextValue { } /** @internal */ -export const FieldActionsContext = createContext({ - actions: [], - focused: false, - hovered: false, - onMouseEnter: () => undefined, - onMouseLeave: () => undefined, -}) +export const FieldActionsContext = createContext( + 'sanity/_singletons/context/field-actions', + { + actions: [], + focused: false, + hovered: false, + onMouseEnter: () => undefined, + onMouseLeave: () => undefined, + }, +) diff --git a/packages/sanity/src/_singletons/context/FormBuilderContext.ts b/packages/sanity/src/_singletons/context/FormBuilderContext.ts index a0c438c8889..b71bd7a03e5 100644 --- a/packages/sanity/src/_singletons/context/FormBuilderContext.ts +++ b/packages/sanity/src/_singletons/context/FormBuilderContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {FormBuilderContextValue} from '../../../core/form/FormBuilderContext' +import type {FormBuilderContextValue} from '../../core/form/FormBuilderContext' /** * @internal */ -export const FormBuilderContext = createContext(null) +export const FormBuilderContext = createContext( + 'sanity/_singletons/context/form-builder', + null, +) diff --git a/packages/sanity/src/_singletons/context/FormCallbacksContext.ts b/packages/sanity/src/_singletons/context/FormCallbacksContext.ts index e6506a19850..fcd6e6c8778 100644 --- a/packages/sanity/src/_singletons/context/FormCallbacksContext.ts +++ b/packages/sanity/src/_singletons/context/FormCallbacksContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {FormCallbacksValue} from '../../../../core/form/studio/contexts/FormCallbacks' +import type {FormCallbacksValue} from '../../core/form/studio/contexts/FormCallbacks' /** * @internal */ -export const FormCallbacksContext = createContext(null) +export const FormCallbacksContext = createContext( + 'sanity/_singletons/context/form-callbacks', + null, +) diff --git a/packages/sanity/src/_singletons/context/FormFieldPresenceContext.ts b/packages/sanity/src/_singletons/context/FormFieldPresenceContext.ts index 34a22c59099..0618623a004 100644 --- a/packages/sanity/src/_singletons/context/FormFieldPresenceContext.ts +++ b/packages/sanity/src/_singletons/context/FormFieldPresenceContext.ts @@ -1,6 +1,9 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {FormNodePresence} from '../../../core/presence/types' +import type {FormNodePresence} from '../../core/presence/types' /** @internal */ -export const FormFieldPresenceContext = createContext([]) +export const FormFieldPresenceContext = createContext( + 'sanity/_singletons/context/form-field-presence', + [], +) diff --git a/packages/sanity/src/_singletons/context/FormValueContext.ts b/packages/sanity/src/_singletons/context/FormValueContext.ts index b2a96e55a78..8f790b673eb 100644 --- a/packages/sanity/src/_singletons/context/FormValueContext.ts +++ b/packages/sanity/src/_singletons/context/FormValueContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {FormValueContextValue} from '../../../core/form/contexts/FormValue' +import type {FormValueContextValue} from '../../core/form/contexts/FormValue' /** * @internal diff --git a/packages/sanity/src/_singletons/context/FreeTrialContext.ts b/packages/sanity/src/_singletons/context/FreeTrialContext.ts index 6f5ecc1db34..1e4ed848e20 100644 --- a/packages/sanity/src/_singletons/context/FreeTrialContext.ts +++ b/packages/sanity/src/_singletons/context/FreeTrialContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {FreeTrialContextProps} from '../../../../../../core/studio/components/navbar/free-trial/FreeTrialContext' +import type {FreeTrialContextProps} from '../../core/studio/components/navbar/free-trial/FreeTrialContext' /** * @internal */ -export const FreeTrialContext = createContext(undefined) +export const FreeTrialContext = createContext( + 'sanity/_singletons/context/free-trial', + undefined, +) diff --git a/packages/sanity/src/_singletons/context/HoveredFieldContext.ts b/packages/sanity/src/_singletons/context/HoveredFieldContext.ts index 437cf79ec30..6960d97ee69 100644 --- a/packages/sanity/src/_singletons/context/HoveredFieldContext.ts +++ b/packages/sanity/src/_singletons/context/HoveredFieldContext.ts @@ -1,5 +1,5 @@ import type {Path} from '@sanity/types' -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** @internal */ export interface HoveredFieldContextValue { @@ -9,8 +9,11 @@ export interface HoveredFieldContextValue { } /** @internal */ -export const HoveredFieldContext = createContext({ - hoveredStack: [], - onMouseEnter: () => undefined, - onMouseLeave: () => undefined, -}) +export const HoveredFieldContext = createContext( + 'sanity/_singletons/context/hovered-field', + { + hoveredStack: [], + onMouseEnter: () => undefined, + onMouseLeave: () => undefined, + }, +) diff --git a/packages/sanity/src/_singletons/context/IsLastPaneContext.ts b/packages/sanity/src/_singletons/context/IsLastPaneContext.ts index 16649fe5002..a4159200cf9 100644 --- a/packages/sanity/src/_singletons/context/IsLastPaneContext.ts +++ b/packages/sanity/src/_singletons/context/IsLastPaneContext.ts @@ -1,4 +1,4 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** * TODO: remove this context when alternate document-specific context are @@ -15,4 +15,7 @@ import {createContext} from 'react' /** * @internal */ -export const IsLastPaneContext = createContext(false) +export const IsLastPaneContext = createContext( + 'sanity/_singletons/context/is-last-pane', + false, +) diff --git a/packages/sanity/src/_singletons/context/LocaleContext.ts b/packages/sanity/src/_singletons/context/LocaleContext.ts index fb5af732833..fdfeb25801d 100644 --- a/packages/sanity/src/_singletons/context/LocaleContext.ts +++ b/packages/sanity/src/_singletons/context/LocaleContext.ts @@ -1,7 +1,7 @@ import type {i18n} from 'i18next' import {createContext} from 'sanity/_createContext' -import type {Locale} from '../../../core/i18n/types' +import type {Locale} from '../../core/i18n/types' /** * @internal @@ -10,7 +10,9 @@ import type {Locale} from '../../../core/i18n/types' export interface LocaleContextValue { locales: Locale[] currentLocale: Locale - __internal: {i18next: i18n} + __internal: { + i18next: i18n + } changeLocale: (newLocale: string) => Promise } diff --git a/packages/sanity/src/_singletons/context/MentionUserContext.ts b/packages/sanity/src/_singletons/context/MentionUserContext.ts index c06054d1afc..3652245a2f6 100644 --- a/packages/sanity/src/_singletons/context/MentionUserContext.ts +++ b/packages/sanity/src/_singletons/context/MentionUserContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {MentionUserContextValue} from '../../../../core/tasks/context/mentionUser/types' +import type {MentionUserContextValue} from '../../core/tasks/context/mentionUser/types' /** * @internal */ -export const MentionUserContext = createContext(null) +export const MentionUserContext = createContext( + 'sanity/_singletons/context/mention-user', + null, +) diff --git a/packages/sanity/src/_singletons/context/NavbarContext.ts b/packages/sanity/src/_singletons/context/NavbarContext.ts index 10287a92b9c..0db19ae2037 100644 --- a/packages/sanity/src/_singletons/context/NavbarContext.ts +++ b/packages/sanity/src/_singletons/context/NavbarContext.ts @@ -1,12 +1,15 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {NavbarContextValue} from '../../../core/studio/StudioLayout' +import type {NavbarContextValue} from '../../core/studio/StudioLayout' /** @internal */ -export const NavbarContext = createContext({ - onSearchFullscreenOpenChange: () => '', - onSearchOpenChange: () => '', - searchFullscreenOpen: false, - searchFullscreenPortalEl: null, - searchOpen: false, -}) +export const NavbarContext = createContext( + 'sanity/_singletons/context/navbar', + { + onSearchFullscreenOpenChange: () => '', + onSearchOpenChange: () => '', + searchFullscreenOpen: false, + searchFullscreenPortalEl: null, + searchOpen: false, + }, +) diff --git a/packages/sanity/src/_singletons/context/PaneContext.ts b/packages/sanity/src/_singletons/context/PaneContext.ts index 942d0f45343..304e2c0d7c1 100644 --- a/packages/sanity/src/_singletons/context/PaneContext.ts +++ b/packages/sanity/src/_singletons/context/PaneContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {PaneContextValue} from '../../../../structure/components/pane/types' +import type {PaneContextValue} from '../../structure/components/pane/types' /** * @internal diff --git a/packages/sanity/src/_singletons/context/PaneLayoutContext.ts b/packages/sanity/src/_singletons/context/PaneLayoutContext.ts index 83c275168e7..969a1c6c10f 100644 --- a/packages/sanity/src/_singletons/context/PaneLayoutContext.ts +++ b/packages/sanity/src/_singletons/context/PaneLayoutContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {PaneLayoutContextValue} from '../../../../structure/components/pane/types' +import type {PaneLayoutContextValue} from '../../structure/components/pane/types' /** * @internal diff --git a/packages/sanity/src/_singletons/context/PaneRouterContext.tsx b/packages/sanity/src/_singletons/context/PaneRouterContext.tsx index 026c7e21990..49934f4359e 100644 --- a/packages/sanity/src/_singletons/context/PaneRouterContext.tsx +++ b/packages/sanity/src/_singletons/context/PaneRouterContext.tsx @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {PaneRouterContextValue} from '../../../../structure/components/paneRouter/types' +import type {PaneRouterContextValue} from '../../structure/components/paneRouter/types' function missingContext(): T { throw new Error('Pane is missing router context') diff --git a/packages/sanity/src/_singletons/context/PortableTextMarkersContext.ts b/packages/sanity/src/_singletons/context/PortableTextMarkersContext.ts index 5b074ccdf4d..15ef4ed4044 100644 --- a/packages/sanity/src/_singletons/context/PortableTextMarkersContext.ts +++ b/packages/sanity/src/_singletons/context/PortableTextMarkersContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {PortableTextMarker} from '../../../../../core/form/types/_transitional' +import type {PortableTextMarker} from '../../core/form/types/_transitional' /** * @internal */ -export const PortableTextMarkersContext = createContext([]) +export const PortableTextMarkersContext = createContext( + 'sanity/_singletons/context/portable-text-markers', + [], +) diff --git a/packages/sanity/src/_singletons/context/PortableTextMemberItemsContext.ts b/packages/sanity/src/_singletons/context/PortableTextMemberItemsContext.ts index 368cd753885..44c6193743f 100644 --- a/packages/sanity/src/_singletons/context/PortableTextMemberItemsContext.ts +++ b/packages/sanity/src/_singletons/context/PortableTextMemberItemsContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {PortableTextMemberItem} from '../../../../../core/form/inputs/PortableText/PortableTextInput' +import type {PortableTextMemberItem} from '../../core/form/inputs/PortableText/PortableTextInput' /** * @internal */ -export const PortableTextMemberItemsContext = createContext([]) +export const PortableTextMemberItemsContext = createContext( + 'sanity/_singletons/context/portable-text-member-items', + [], +) diff --git a/packages/sanity/src/_singletons/context/PresenceContext.ts b/packages/sanity/src/_singletons/context/PresenceContext.ts index e58f8a48d21..6af19268c7b 100644 --- a/packages/sanity/src/_singletons/context/PresenceContext.ts +++ b/packages/sanity/src/_singletons/context/PresenceContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {FormNodePresence} from '../../../../core/presence/types' +import type {FormNodePresence} from '../../core/presence/types' /** * @internal */ -export const PresenceContext = createContext([]) +export const PresenceContext = createContext( + 'sanity/_singletons/context/presence', + [], +) diff --git a/packages/sanity/src/_singletons/context/PresenceTrackerContexts.ts b/packages/sanity/src/_singletons/context/PresenceTrackerContexts.ts index 8919e71f52e..af9d8bf4d90 100644 --- a/packages/sanity/src/_singletons/context/PresenceTrackerContexts.ts +++ b/packages/sanity/src/_singletons/context/PresenceTrackerContexts.ts @@ -1,12 +1,18 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' import type { PresenceTrackerContextStoreType, PresenceTrackerGetSnapshotType, -} from '../../../../core/presence/overlay/PresenceTrackerContexts' +} from '../../core/presence/overlay/PresenceTrackerContexts' /** @internal */ -export const PresenceTrackerContextStore = createContext(null) +export const PresenceTrackerContextStore = createContext( + 'sanity/_singletons/context/presence-tracker-store', + null, +) /** @internal */ -export const PresenceTrackerContextGetSnapshot = createContext(null) +export const PresenceTrackerContextGetSnapshot = createContext( + 'sanity/_singletons/context/presence-tracker-get-snapshot', + null, +) diff --git a/packages/sanity/src/_singletons/context/PreviewCardContext.ts b/packages/sanity/src/_singletons/context/PreviewCardContext.ts index 86e56398cb1..30663e9a45c 100644 --- a/packages/sanity/src/_singletons/context/PreviewCardContext.ts +++ b/packages/sanity/src/_singletons/context/PreviewCardContext.ts @@ -1,8 +1,13 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {PreviewCardContextValue} from '../../../../core/components/previewCard/PreviewCard' +import type {PreviewCardContextValue} from '../../core/components/previewCard/PreviewCard' /** * @internal */ -export const PreviewCardContext = createContext({selected: false}) +export const PreviewCardContext = createContext( + 'sanity/_singletons/context/preview-card', + { + selected: false, + }, +) diff --git a/packages/sanity/src/_singletons/context/ReferenceInputOptionsContext.ts b/packages/sanity/src/_singletons/context/ReferenceInputOptionsContext.ts index 3e6c6f01352..55756e9bf66 100644 --- a/packages/sanity/src/_singletons/context/ReferenceInputOptionsContext.ts +++ b/packages/sanity/src/_singletons/context/ReferenceInputOptionsContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {ReferenceInputOptions} from '../../../../core/form/studio/contexts/ReferenceInputOptions' +import type {ReferenceInputOptions} from '../../core/form/studio/contexts/ReferenceInputOptions' /** * @internal */ -export const ReferenceInputOptionsContext = createContext({}) +export const ReferenceInputOptionsContext = createContext( + 'sanity/_singletons/context/reference-input-options', + {}, +) diff --git a/packages/sanity/src/_singletons/context/ReferenceItemRefContext.ts b/packages/sanity/src/_singletons/context/ReferenceItemRefContext.ts index 4e6ab233eb5..3633a28825d 100644 --- a/packages/sanity/src/_singletons/context/ReferenceItemRefContext.ts +++ b/packages/sanity/src/_singletons/context/ReferenceItemRefContext.ts @@ -1,6 +1,6 @@ /* eslint-disable import/no-duplicates */ import type {MutableRefObject} from 'react' -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** * @internal @@ -16,4 +16,7 @@ export interface ReferenceItemRef { * so it can be used down the tree for clickOutside handling * @internal */ -export const ReferenceItemRefContext = createContext(null) +export const ReferenceItemRefContext = createContext( + 'sanity/_singletons/context/reference-item-ref', + null, +) diff --git a/packages/sanity/src/_singletons/context/ResourceCacheContext.ts b/packages/sanity/src/_singletons/context/ResourceCacheContext.ts index 88d4dbb6d29..587f92aec1e 100644 --- a/packages/sanity/src/_singletons/context/ResourceCacheContext.ts +++ b/packages/sanity/src/_singletons/context/ResourceCacheContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {ResourceCache} from '../../../../core/store/_legacy/ResourceCacheProvider' +import type {ResourceCache} from '../../core/store/_legacy/ResourceCacheProvider' /** * @internal diff --git a/packages/sanity/src/_singletons/context/ReviewChangesContext.ts b/packages/sanity/src/_singletons/context/ReviewChangesContext.ts index cc14ef2594f..06571b5ab18 100644 --- a/packages/sanity/src/_singletons/context/ReviewChangesContext.ts +++ b/packages/sanity/src/_singletons/context/ReviewChangesContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {ReviewChangesContextValue} from '../../../../../core/form/studio/contexts/reviewChanges/types' +import type {ReviewChangesContextValue} from '../../core/form/studio/contexts/reviewChanges/types' /** * @internal */ -export const ReviewChangesContext = createContext(null) +export const ReviewChangesContext = createContext( + 'sanity/_singletons/context/review-changes', + null, +) diff --git a/packages/sanity/src/_singletons/context/RouterHistoryContext.ts b/packages/sanity/src/_singletons/context/RouterHistoryContext.ts index 1fb526137b5..c51a65281da 100644 --- a/packages/sanity/src/_singletons/context/RouterHistoryContext.ts +++ b/packages/sanity/src/_singletons/context/RouterHistoryContext.ts @@ -1,9 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {RouterHistory} from '../../../../core/studio/router' +import type {RouterHistory} from '../../core/studio/router' /** * Internal use only. Userland should leverage the public `useRouter` APIs. * @internal */ -export const RouterHistoryContext = createContext(null) +export const RouterHistoryContext = createContext( + 'sanity/_singletons/context/router-history', + null, +) diff --git a/packages/sanity/src/_singletons/context/SchedulePublishingUpsellContext.ts b/packages/sanity/src/_singletons/context/SchedulePublishingUpsellContext.ts index c534cccb930..54d34b73f1b 100644 --- a/packages/sanity/src/_singletons/context/SchedulePublishingUpsellContext.ts +++ b/packages/sanity/src/_singletons/context/SchedulePublishingUpsellContext.ts @@ -1,20 +1,23 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {SchedulePublishUpsellContextValue} from '../../../../core/scheduledPublishing/tool/contexts/SchedulePublishingUpsellProvider' +import type {SchedulePublishUpsellContextValue} from '../../core/scheduledPublishing/tool/contexts/SchedulePublishingUpsellProvider' /** * @internal */ -export const SchedulePublishUpsellContext = createContext({ - upsellData: null, - handleOpenDialog: () => null, - upsellDialogOpen: false, - telemetryLogs: { - dialogSecondaryClicked: () => null, - dialogPrimaryClicked: () => null, - panelViewed: () => null, - panelDismissed: () => null, - panelPrimaryClicked: () => null, - panelSecondaryClicked: () => null, +export const SchedulePublishUpsellContext = createContext( + 'sanity/_singletons/context/schedule-publish-upsell', + { + upsellData: null, + handleOpenDialog: () => null, + upsellDialogOpen: false, + telemetryLogs: { + dialogSecondaryClicked: () => null, + dialogPrimaryClicked: () => null, + panelViewed: () => null, + panelDismissed: () => null, + panelPrimaryClicked: () => null, + panelSecondaryClicked: () => null, + }, }, -}) +) diff --git a/packages/sanity/src/_singletons/context/ScheduledPublishingEnabledContext.ts b/packages/sanity/src/_singletons/context/ScheduledPublishingEnabledContext.ts index dab69774b2e..c70765b8199 100644 --- a/packages/sanity/src/_singletons/context/ScheduledPublishingEnabledContext.ts +++ b/packages/sanity/src/_singletons/context/ScheduledPublishingEnabledContext.ts @@ -1,9 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {ScheduledPublishingEnabledContextValue} from '../../../../core/scheduledPublishing/tool/contexts/ScheduledPublishingEnabledProvider' +import type {ScheduledPublishingEnabledContextValue} from '../../core/scheduledPublishing/tool/contexts/ScheduledPublishingEnabledProvider' /** * @internal */ export const ScheduledPublishingEnabledContext = - createContext(null) + createContext( + 'sanity/_singletons/context/scheduled-publishing-enabled', + null, + ) diff --git a/packages/sanity/src/_singletons/context/Schedules.ts b/packages/sanity/src/_singletons/context/Schedules.ts index dc7125adce7..8ac0c0785e1 100644 --- a/packages/sanity/src/_singletons/context/Schedules.ts +++ b/packages/sanity/src/_singletons/context/Schedules.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {SchedulesContextValue} from '../../../../core/scheduledPublishing/tool/contexts/schedules' +import type {SchedulesContextValue} from '../../core/scheduledPublishing/tool/contexts/schedules' /** * @internal */ -export const SchedulesContext = createContext(undefined) +export const SchedulesContext = createContext( + 'sanity/_singletons/context/schedules', + undefined, +) diff --git a/packages/sanity/src/_singletons/context/ScrollContext.ts b/packages/sanity/src/_singletons/context/ScrollContext.ts index 3b9cfbe65c6..5a327d757ed 100644 --- a/packages/sanity/src/_singletons/context/ScrollContext.ts +++ b/packages/sanity/src/_singletons/context/ScrollContext.ts @@ -1,7 +1,10 @@ import type {PubSub} from 'nano-pubsub' -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** * @internal */ -export const ScrollContext = createContext>(null) +export const ScrollContext = createContext>( + 'sanity/_singletons/context/scroll', + null, +) diff --git a/packages/sanity/src/_singletons/context/SearchContext.ts b/packages/sanity/src/_singletons/context/SearchContext.ts index 0e369c4b867..e40da1e69da 100644 --- a/packages/sanity/src/_singletons/context/SearchContext.ts +++ b/packages/sanity/src/_singletons/context/SearchContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {SearchContextValue} from '../../../../../../core/studio/components/navbar/search/contexts/search/SearchContext' +import type {SearchContextValue} from '../../core/studio/components/navbar/search/contexts/search/SearchContext' /** * @internal */ -export const SearchContext = createContext(undefined) +export const SearchContext = createContext( + 'sanity/_singletons/context/search', + undefined, +) diff --git a/packages/sanity/src/_singletons/context/SortableItemIdContext.ts b/packages/sanity/src/_singletons/context/SortableItemIdContext.ts index b22c82f86c8..40abfcf4a6a 100644 --- a/packages/sanity/src/_singletons/context/SortableItemIdContext.ts +++ b/packages/sanity/src/_singletons/context/SortableItemIdContext.ts @@ -1,6 +1,9 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** * @internal */ -export const SortableItemIdContext = createContext(null) +export const SortableItemIdContext = createContext( + 'sanity/_singletons/context/sortable-item-id', + null, +) diff --git a/packages/sanity/src/_singletons/context/SourceContext.ts b/packages/sanity/src/_singletons/context/SourceContext.ts index e764bd94a59..cca1af391c1 100644 --- a/packages/sanity/src/_singletons/context/SourceContext.ts +++ b/packages/sanity/src/_singletons/context/SourceContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {Source} from '../../../core/config/types' +import type {Source} from '../../core/config/types' /** * @internal diff --git a/packages/sanity/src/_singletons/context/TasksContext.ts b/packages/sanity/src/_singletons/context/TasksContext.ts index 603e3e0f13e..28df99b2a7f 100644 --- a/packages/sanity/src/_singletons/context/TasksContext.ts +++ b/packages/sanity/src/_singletons/context/TasksContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {TasksContextValue} from '../../../../core/tasks/context/tasks/types' +import type {TasksContextValue} from '../../core/tasks/context/tasks/types' /** * @internal */ -export const TasksContext = createContext(null) +export const TasksContext = createContext( + 'sanity/_singletons/context/tasks', + null, +) diff --git a/packages/sanity/src/_singletons/context/TasksEnabledContext.ts b/packages/sanity/src/_singletons/context/TasksEnabledContext.ts index 1e4c82301cd..abdb4f4bc42 100644 --- a/packages/sanity/src/_singletons/context/TasksEnabledContext.ts +++ b/packages/sanity/src/_singletons/context/TasksEnabledContext.ts @@ -1,6 +1,6 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {TasksEnabledContextValue} from '../../../../core/tasks/context/enabled/types' +import type {TasksEnabledContextValue} from '../../core/tasks/context/enabled/types' // NOTE: We initialize this context with a default value (`enabled: false`) // rather than `null` to handle cases where the tasks feature's availability @@ -11,7 +11,10 @@ import type {TasksEnabledContextValue} from '../../../../core/tasks/context/enab /** * @internal */ -export const TasksEnabledContext = createContext({ - enabled: false, - mode: null, -}) +export const TasksEnabledContext = createContext( + 'sanity/_singletons/context/tasks-enabled', + { + enabled: false, + mode: null, + }, +) diff --git a/packages/sanity/src/_singletons/context/TasksNavigationContext.ts b/packages/sanity/src/_singletons/context/TasksNavigationContext.ts index bd55df29b2e..d6c1ab43bf4 100644 --- a/packages/sanity/src/_singletons/context/TasksNavigationContext.ts +++ b/packages/sanity/src/_singletons/context/TasksNavigationContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {TasksNavigationContextValue} from '../../../../core/tasks/context/navigation/types' +import type {TasksNavigationContextValue} from '../../core/tasks/context/navigation/types' /** * @internal */ -export const TasksNavigationContext = createContext(null) +export const TasksNavigationContext = createContext( + 'sanity/_singletons/context/tasks-navigation', + null, +) diff --git a/packages/sanity/src/_singletons/context/TasksUpsellContext.ts b/packages/sanity/src/_singletons/context/TasksUpsellContext.ts index d66a53d5d00..f5105c19717 100644 --- a/packages/sanity/src/_singletons/context/TasksUpsellContext.ts +++ b/packages/sanity/src/_singletons/context/TasksUpsellContext.ts @@ -1,9 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {TasksUpsellContextValue} from '../../../../core/tasks/context/upsell/types' +import type {TasksUpsellContextValue} from '../../core/tasks/context/upsell/types' /** * @beta * @hidden */ -export const TasksUpsellContext = createContext(null) +export const TasksUpsellContext = createContext( + 'sanity/_singletons/context/tasks-upsell', + null, +) diff --git a/packages/sanity/src/_singletons/context/TreeEditingEnabledContext.ts b/packages/sanity/src/_singletons/context/TreeEditingEnabledContext.ts index 39a632e1cee..efa9ff9c1ac 100644 --- a/packages/sanity/src/_singletons/context/TreeEditingEnabledContext.ts +++ b/packages/sanity/src/_singletons/context/TreeEditingEnabledContext.ts @@ -1,11 +1,14 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {TreeEditingEnabledContextValue} from '../../../../core/form/studio/tree-editing/context/enabled/useTreeEditingEnabled' +import type {TreeEditingEnabledContextValue} from '../../core/form/studio/tree-editing/context/enabled/useTreeEditingEnabled' /** * @internal */ -export const TreeEditingEnabledContext = createContext({ - enabled: false, - legacyEditing: false, -}) +export const TreeEditingEnabledContext = createContext( + 'sanity/_singletons/context/tree-editing-enabled', + { + enabled: false, + legacyEditing: false, + }, +) diff --git a/packages/sanity/src/_singletons/context/UserColorManagerContext.ts b/packages/sanity/src/_singletons/context/UserColorManagerContext.ts index 19dd5dd4d87..3f58ea1a1e5 100644 --- a/packages/sanity/src/_singletons/context/UserColorManagerContext.ts +++ b/packages/sanity/src/_singletons/context/UserColorManagerContext.ts @@ -1,8 +1,11 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {UserColorManager} from '../../../core/user-color/types' +import type {UserColorManager} from '../../core/user-color/types' /** * @internal */ -export const UserColorManagerContext = createContext(null) +export const UserColorManagerContext = createContext( + 'sanity/_singletons/context/user-color-manager', + null, +) diff --git a/packages/sanity/src/_singletons/context/ValidationContext.ts b/packages/sanity/src/_singletons/context/ValidationContext.ts index 71446ec818c..edfb731d8d5 100644 --- a/packages/sanity/src/_singletons/context/ValidationContext.ts +++ b/packages/sanity/src/_singletons/context/ValidationContext.ts @@ -1,7 +1,10 @@ import type {ValidationMarker} from '@sanity/types' -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' /** * @internal */ -export const ValidationContext = createContext([]) +export const ValidationContext = createContext( + 'sanity/_singletons/context/validation', + [], +) diff --git a/packages/sanity/src/_singletons/context/VirtualizerScrollInstanceContext.ts b/packages/sanity/src/_singletons/context/VirtualizerScrollInstanceContext.ts index 78242355042..dfef2db9f2d 100644 --- a/packages/sanity/src/_singletons/context/VirtualizerScrollInstanceContext.ts +++ b/packages/sanity/src/_singletons/context/VirtualizerScrollInstanceContext.ts @@ -1,11 +1,12 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {VirtualizerScrollInstance} from '../../../../../../../core/form/inputs/arrays/ArrayOfObjectsInput/List/useVirtualizerScrollInstance' +import type {VirtualizerScrollInstance} from '../../core/form/inputs/arrays/ArrayOfObjectsInput/List/useVirtualizerScrollInstance' /** * This is used to store the reference to the scroll element for virtualizer * @internal */ export const VirtualizerScrollInstanceContext = createContext( + 'sanity/_singletons/context/virtualizer-scroll-instance', null, ) diff --git a/packages/sanity/src/_singletons/context/WorkspaceContext.ts b/packages/sanity/src/_singletons/context/WorkspaceContext.ts index 0d0bfab3137..528afd5e0d4 100644 --- a/packages/sanity/src/_singletons/context/WorkspaceContext.ts +++ b/packages/sanity/src/_singletons/context/WorkspaceContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {Workspace} from '../../../core/config/types' +import type {Workspace} from '../../core/config/types' /** * @internal diff --git a/packages/sanity/src/_singletons/context/WorkspacesContext.ts b/packages/sanity/src/_singletons/context/WorkspacesContext.ts index 328d95b1cbd..144d004d3da 100644 --- a/packages/sanity/src/_singletons/context/WorkspacesContext.ts +++ b/packages/sanity/src/_singletons/context/WorkspacesContext.ts @@ -1,6 +1,6 @@ import {createContext} from 'sanity/_createContext' -import type {WorkspacesContextValue} from '../../../../core/studio/workspaces/WorkspacesContext' +import type {WorkspacesContextValue} from '../../core/studio/workspaces/WorkspacesContext' /** @internal */ export const WorkspacesContext = createContext( diff --git a/packages/sanity/src/_singletons/context/ZIndexContext.ts b/packages/sanity/src/_singletons/context/ZIndexContext.ts index d03b40e0f1b..ddbcd1f2cf0 100644 --- a/packages/sanity/src/_singletons/context/ZIndexContext.ts +++ b/packages/sanity/src/_singletons/context/ZIndexContext.ts @@ -1,11 +1,45 @@ -import {createContext} from 'react' +import {createContext} from 'sanity/_createContext' -import type {ZIndexContextValue} from '../../../../core/components/zOffsets/types' -import {zIndexContextDefaults} from './zIndexContextDefaults' +import type {ZIndexContextValue} from '../../core/components/zOffsets/types' + +/** + * @internal + */ +export const zIndexContextDefaults: ZIndexContextValue = { + navbar: 200, + navbarPopover: 500000, + navbarDialog: 500001, + // pane + pane: 100, + paneHeader: [110, 15000], + paneFooter: [120, 20000], + paneResizer: [130, 25000], + paneDialog: [140, 5000], + // + popover: 200, + modal: 200, + movingItem: 10000, + drawershade: 1000000, + drawer: 1000001, + fullscreen: 1200000, + toast: [100, 11000], + // NOT IN USE + portal: 200, + dropdown: 200, + navbarFixed: 1010, + fullscreenEdit: 1050, + popoverBackground: 1060, + tooltip: 200, + modalBackground: 2000, + spinner: 3000, +} /** * TODO: Rename to `ZOffsetsContext` * * @internal */ -export const ZIndexContext = createContext(zIndexContextDefaults) +export const ZIndexContext = createContext( + 'sanity/_singletons/context/z-index', + zIndexContextDefaults, +) diff --git a/packages/sanity/src/_singletons/context/zIndexContextDefaults.ts b/packages/sanity/src/_singletons/context/zIndexContextDefaults.ts deleted file mode 100644 index e2eb107329a..00000000000 --- a/packages/sanity/src/_singletons/context/zIndexContextDefaults.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type {ZIndexContextValue} from '../../../../core/components/zOffsets/types' - -/** - * @internal - */ -export const zIndexContextDefaults: ZIndexContextValue = { - navbar: 200, - navbarPopover: 500000, - navbarDialog: 500001, - - // pane - pane: 100, - paneHeader: [110, 15000], - paneFooter: [120, 20000], - paneResizer: [130, 25000], - paneDialog: [140, 5000], - - // - popover: 200, - modal: 200, - movingItem: 10000, - drawershade: 1000000, - drawer: 1000001, - fullscreen: 1200000, - toast: [100, 11000], - - // NOT IN USE - portal: 200, - dropdown: 200, - navbarFixed: 1010, - fullscreenEdit: 1050, - popoverBackground: 1060, - tooltip: 200, - modalBackground: 2000, - spinner: 3000, -} diff --git a/packages/sanity/src/_singletons/index.ts b/packages/sanity/src/_singletons/index.ts index 031b9182bb1..ca77d8f8c1d 100644 --- a/packages/sanity/src/_singletons/index.ts +++ b/packages/sanity/src/_singletons/index.ts @@ -1,69 +1,68 @@ -export * from './core/changeIndicators/ChangeIndicatorTrackerContexts' -export * from './core/changeIndicators/ConnectorContext' -export * from './core/components/previewCard/PreviewCardContext' -export * from './core/components/scroll/scrollContext' -export * from './core/components/zOffsets/ZIndexContext' -export * from './core/components/zOffsets/zIndexContextDefaults' -export * from './core/field/diff/DiffContext' -export * from './core/field/diff/DocumentChangeContext' -export * from './core/form/DocumentIdContext' -export * from './core/form/field/actions/FieldActionsContext' -export * from './core/form/field/HoveredFieldContext' -export * from './core/form/FormBuilderContext' -export * from './core/form/FormValueContext' -export * from './core/form/GetFormValueContext' -export * from './core/form/inputs/arrays/ArrayOfObjectsInput/List/VirtualizerScrollInstanceContext' -export * from './core/form/inputs/arrays/common/SortableItemIdContext' -export * from './core/form/inputs/PortableText/PortableTextMarkersContext' -export * from './core/form/inputs/PortableText/PortableTextMemberItemsContext' -export * from './core/form/inputs/ReferenceInput/ReferenceItemRefContext' -export * from './core/form/studio/DocumentFieldActionsContext' -export * from './core/form/studio/FormCallbacksContext' -export * from './core/form/studio/PresenceContext' -export * from './core/form/studio/ReferenceInputOptionsContext' -export * from './core/form/studio/reviewChanges/ReviewChangesContext' -export * from './core/form/studio/TreeEditingEnabledContext' -export * from './core/form/studio/ValidationContext' -export * from './core/i18n/LocaleContext' -export * from './core/presence/FormFieldPresenceContext' -export * from './core/presence/overlay/PresenceTrackerContexts' -export * from './core/schedulePublishing/DocumentActionPropsContext' -export * from './core/schedulePublishing/tool/ScheduledPublishingEnabledContext' -export * from './core/schedulePublishing/tool/SchedulePublishingUpsellContext' -export * from './core/schedulePublishing/tool/Schedules' -export * from './core/store/_legacy/ResourceCacheContext' -export * from './core/studio/activeWorkspaceMatcher/ActiveWorkspaceMatcherContext' -export * from './core/studio/addonDataset/AddonDatasetContext' -export * from './core/studio/ColorSchemeSetValueContext' -export * from './core/studio/ColorSchemeValueContext' -export * from './core/studio/components/navbar/free-trial/FreeTrialContext' -export * from './core/studio/components/navbar/search/components/filters/filter/inputs/date/datePicker/calendar/CalendarContext' -export * from './core/studio/components/navbar/search/SearchContext' -export * from './core/studio/copyPaste/CopyPasteContext' -export * from './core/studio/NavbarContext' -export * from './core/studio/router/RouterHistoryContext' -export * from './core/studio/SourceContext' -export * from './core/studio/WorkspaceContext' -export * from './core/studio/workspaces/WorkspacesContext' -export * from './core/tasks/enabled/TasksEnabledContext' -export * from './core/tasks/isLastPane/IsLastPaneContext' -export * from './core/tasks/mentionUser/MentionUserContext' -export * from './core/tasks/navigation/TasksNavigationContext' -export * from './core/tasks/tasks/TasksContext' -export * from './core/tasks/tasks/TasksUpsellContext' -export * from './core/user-color/UserColorManagerContext' -export * from './router/RouterContext' -export * from './structure/comments/authoring-path/CommentsAuthoringPathContext' -export * from './structure/comments/CommentsContext' -export * from './structure/comments/components/pte/comment-input/CommentInputContext' -export * from './structure/comments/enabled/CommentsEnabledContext' -export * from './structure/comments/intent/CommentsIntentContext' -export * from './structure/comments/onboarding/CommentsOnboardingContext' -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/panes/document/DocumentSheetListContext' -export * from './structure/StructureToolContext' +export * from './context/ActiveWorkspaceMatcherContext' +export * from './context/AddonDatasetContext' +export * from './context/CalendarContext' +export * from './context/ChangeIndicatorTrackerContexts' +export * from './context/ColorSchemeSetValueContext' +export * from './context/ColorSchemeValueContext' +export * from './context/CommentInputContext' +export * from './context/CommentsAuthoringPathContext' +export * from './context/CommentsContext' +export * from './context/CommentsEnabledContext' +export * from './context/CommentsIntentContext' +export * from './context/CommentsOnboardingContext' +export * from './context/CommentsSelectedPathContext' +export * from './context/CommentsUpsellContext' +export * from './context/ConnectorContext' +export * from './context/CopyPasteContext' +export * from './context/DiffContext' +export * from './context/DocumentActionPropsContext' +export * from './context/DocumentChangeContext' +export * from './context/DocumentFieldActionsContext' +export * from './context/DocumentIdContext' +export * from './context/DocumentPaneContext' +export * from './context/DocumentSheetListContext' +export * from './context/FieldActionsContext' +export * from './context/FormBuilderContext' +export * from './context/FormCallbacksContext' +export * from './context/FormFieldPresenceContext' +export * from './context/FormValueContext' +export * from './context/FreeTrialContext' +export * from './context/GetFormValueContext' +export * from './context/HoveredFieldContext' +export * from './context/IsLastPaneContext' +export * from './context/LocaleContext' +export * from './context/MentionUserContext' +export * from './context/NavbarContext' +export * from './context/PaneContext' +export * from './context/PaneLayoutContext' +export * from './context/PaneRouterContext' +export * from './context/PortableTextMarkersContext' +export * from './context/PortableTextMemberItemsContext' +export * from './context/PresenceContext' +export * from './context/PresenceTrackerContexts' +export * from './context/PreviewCardContext' +export * from './context/ReferenceInputOptionsContext' +export * from './context/ReferenceItemRefContext' +export * from './context/ResourceCacheContext' +export * from './context/ReviewChangesContext' +export * from './context/RouterContext' +export * from './context/RouterHistoryContext' +export * from './context/ScheduledPublishingEnabledContext' +export * from './context/SchedulePublishingUpsellContext' +export * from './context/Schedules' +export * from './context/ScrollContext' +export * from './context/SearchContext' +export * from './context/SortableItemIdContext' +export * from './context/SourceContext' +export * from './context/StructureToolContext' +export * from './context/TasksContext' +export * from './context/TasksEnabledContext' +export * from './context/TasksNavigationContext' +export * from './context/TasksUpsellContext' +export * from './context/TreeEditingEnabledContext' +export * from './context/UserColorManagerContext' +export * from './context/ValidationContext' +export * from './context/VirtualizerScrollInstanceContext' +export * from './context/WorkspaceContext' +export * from './context/WorkspacesContext' +export * from './context/ZIndexContext'