Skip to content

Commit

Permalink
refactor(core): move SortableItemIdContext to singletons
Browse files Browse the repository at this point in the history
  • Loading branch information
binoy14 committed Apr 29, 2024
1 parent 372774e commit ffea136
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {createContext} from 'react'

/**
* @internal
*/
export const SortableItemIdContext = createContext<string | null>(null)
1 change: 1 addition & 0 deletions packages/sanity/src/_singletons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './form/FormBuilderContext'
export * from './form/FormValueContext'
export * from './form/GetFormValueContext'
export * from './form/inputs/arrays/ArrayOfObjectsInput/List/VirtualizerScrollInstanceContext'
export * from './form/inputs/arrays/common/SortableItemIdContext'
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useSortable} from '@dnd-kit/sortable'
import {DragHandleIcon} from '@sanity/icons'
import {createContext, useContext} from 'react'
import {useContext} from 'react'
import {SortableItemIdContext} from 'sanity/_singletons'
import {css, styled} from 'styled-components'

import {Button, type ButtonProps} from '../../../../../ui-components'
Expand All @@ -14,8 +15,6 @@ const DragHandleButton = styled(Button)<{$grid?: boolean; disabled?: boolean}>((
`
})

export const SortableItemIdContext = createContext<string | null>(null)

interface DragHandleProps {
$grid?: boolean
size?: ButtonProps['size']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import {
useCallback,
useMemo,
} from 'react'
import {SortableItemIdContext} from 'sanity/_singletons'
import {css, styled} from 'styled-components'

import {restrictToParentElementWithMargins} from './dndkit-modifier/restrictToParentElementWithMargins'
import {SortableItemIdContext} from './DragHandle'

export const MOVING_ITEM_CLASS_NAME = 'moving'

Expand Down

0 comments on commit ffea136

Please sign in to comment.