index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators/overlay/ConnectorsOverlay.styled.tsx | import styled from 'styled-components'
export const SvgWrapper = styled.svg`
pointer-events: none;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
`
| 2,700 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators/overlay/ConnectorsOverlay.tsx | import React, {useCallback, useMemo, useState} from 'react'
import {sortBy} from 'lodash'
import {Path} from '@sanity/types'
import {ScrollMonitor} from '../../components/scroll'
import {findMostSpecificTarget} from '../helpers/findMostSpecificTarget'
import {isChangeBar} from '../helpers/isChangeBar'
import {scrollInt... | 2,701 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators/overlay/DebugLayers.tsx | import React from 'react'
import {Rect} from './types'
export function DebugLayers({
field,
change,
}: {
field: {rect: Rect; bounds: Rect}
change: {rect: Rect; bounds: Rect}
}) {
return (
<g style={{pointerEvents: 'none'}}>
<rect
x={field.bounds.left}
y={field.bounds.top}
he... | 2,702 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators/overlay/connectorPath.ts | import {
ARROW_MARGIN_X,
ARROW_MARGIN_Y,
ARROW_SIZE,
ARROW_THRESHOLD,
CORNER_RADIUS,
} from '../constants'
import {ConnectorLine} from './types'
export function arrowPath(x: number, y: number, dir: number): string {
return [
`M ${x - ARROW_SIZE} ${y - ARROW_SIZE * dir} `,
`L ${x} ${y}`,
`L ${x ... | 2,703 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators/overlay/mapConnectorToLine.ts | import {ARROW_MARGIN_Y, ARROW_THRESHOLD, CONNECTOR_MARGIN} from '../constants'
import {ConnectorLinePoint, Rect} from './types'
function getConnectorLinePoint(rect: Rect, bounds: Rect): ConnectorLinePoint {
const centerY = rect.top + rect.height / 2
const isAbove = rect.top + rect.height < bounds.top + ARROW_MARGI... | 2,704 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators/overlay/types.ts | export interface ConnectorLinePoint {
bounds: {
top: number
left: number
height: number
width: number
}
left: number
top: number
startY: number
centerY: number
endY: number
isAbove: boolean
isBelow: boolean
outOfBounds: boolean
}
export interface ConnectorLine {
from: ConnectorLin... | 2,705 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators | petrpan-code/sanity-io/sanity/packages/sanity/src/core/changeIndicators/overlay/useResizeObserver.ts | import {useEffect} from 'react'
import {resizeObserver} from '../../util'
export function useResizeObserver(
element: HTMLDivElement,
onResize: (event: ResizeObserverEntry) => void,
): void {
useEffect(() => resizeObserver.observe(element, onResize), [element, onResize])
}
| 2,706 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/BetaBadge.tsx | import React, {PropsWithChildren} from 'react'
import {hues} from '@sanity/color'
import {Badge, BadgeProps} from '@sanity/ui'
import styled, {css} from 'styled-components'
const StyledBadge = styled(Badge)(({theme}) => {
const fgTint = theme.sanity.color.dark ? 50 : 700
const bgTint = theme.sanity.color.dark ? 70... | 2,707 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/DefaultDocument.tsx | import React from 'react'
import {NoJavascript} from './NoJavascript'
import {GlobalErrorHandler} from './globalErrorHandler'
import {Favicons} from './Favicons'
const globalStyles = `
html {
background-color: #f1f3f6;
}
html,
body,
#sanity {
height: 100%;
}
body {
margin: 0;
-webkit-font... | 2,708 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/Favicons.tsx | import React from 'react'
export interface FaviconProps {
basePath: string
}
export function Favicons({basePath}: FaviconProps) {
const base = `${basePath.replace(/\/+$/, '')}/static`
return (
<>
<link rel="icon" href={`${base}/favicon.ico`} sizes="any" />
<link rel="icon" href={`${base}/favicon... | 2,709 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/Hotkeys.tsx | import React, {type HTMLProps, type RefAttributes} from 'react'
import {type HotkeysProps as UIHotkeysProps, Hotkeys as UIHotkeys} from '@sanity/ui'
/**
* Properties for the `Hotkeys` component.
*
* @public
*/
export type HotkeysProps = UIHotkeysProps & {
/**
* Whether to make the keys platform-aware (eg `alt... | 2,710 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/InsufficientPermissionsMessage.tsx | import {AccessDeniedIcon} from '@sanity/icons'
import {CurrentUser} from '@sanity/types'
import {Text, Inline, Box} from '@sanity/ui'
import React from 'react'
/** @internal */
export interface InsufficientPermissionsMessageProps {
title?: string
operationLabel?: string
currentUser?: CurrentUser | null
}
/** @i... | 2,711 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/IntentButton.tsx | import {Button, ButtonProps} from '@sanity/ui'
import React, {HTMLProps} from 'react'
import {IntentLink, IntentLinkProps} from 'sanity/router'
/**
*
* @hidden
* @beta
*/
export function IntentButton(
props: IntentLinkProps & ButtonProps & Omit<HTMLProps<HTMLButtonElement>, 'as' | 'href' | 'ref'>,
) {
return p... | 2,712 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/NoJavascript.tsx | import React from 'react'
const NoJsStyles = `
.sanity-app-no-js__root {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: #fff;
}
.sanity-app-no-js__content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
font-family: helvet... | 2,713 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/StatusButton.tsx | import {
Box,
Button,
ButtonMode,
ButtonProps,
Flex,
Text,
Tooltip,
TooltipProps,
useTheme,
} from '@sanity/ui'
import React, {
createElement,
isValidElement,
useMemo,
HTMLProps,
forwardRef,
ForwardedRef,
ReactNode,
} from 'react'
import {isValidElementType} from 'react-is'
import styled... | 2,714 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/TooltipOfDisabled.tsx | import {Tooltip, TooltipProps} from '@sanity/ui'
import React, {ForwardedRef, forwardRef} from 'react'
/** @internal */
export const TooltipOfDisabled = forwardRef(function DisabledTooltip(
props: TooltipProps,
ref: ForwardedRef<HTMLDivElement>,
) {
const {children, content, disabled, ...restProps} = props
re... | 2,715 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/WithReferringDocuments.tsx | import {SanityDocument} from '@sanity/types'
import {ReactElement} from 'react'
import {DocumentStore} from '../store'
import {useReferringDocuments} from '../hooks/useReferringDocuments'
/**
* @internal
* @deprecated - Will be removed in 4.0.0, use the `useReferringDocuments(<documentId>)` hook instead
*/
export f... | 2,716 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/index.ts | // NOTE: exporting these here causes error (esbuild):
// > Cannot create styled-component for component: undefined.
// > Cannot use before defined.
// export * from './collapseMenu'
// export * from './scroll'
export * from './commandList'
export * from './DefaultDocument'
export * from './globalErrorHandler'
expo... | 2,717 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/CollapseMenu.tsx | import {EllipsisVerticalIcon} from '@sanity/icons'
import {Box, Button, Flex, MenuButtonProps, Text, Tooltip} from '@sanity/ui'
import React, {
Children,
cloneElement,
ForwardedRef,
forwardRef,
Fragment,
memo,
ReactElement,
ReactNode,
useCallback,
useMemo,
useState,
} from 'react'
import styled, {... | 2,718 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/CollapseMenuButton.tsx | import {Button, ButtonProps, TooltipProps} from '@sanity/ui'
import React, {forwardRef} from 'react'
/** @internal */
export interface CommonProps extends Omit<ButtonProps, 'text' | 'iconRight'> {
as?: React.ElementType | keyof JSX.IntrinsicElements
dividerBefore?: boolean
focused?: boolean
tooltipProps?: Tool... | 2,719 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/CollapseMenuDivider.tsx | import React from 'react'
import styled from 'styled-components'
const DividerDiv = styled.div`
border-right: 1px solid var(--card-border-color);
height: auto;
&[data-hidden] {
opacity: 0;
}
`
interface CollapseMenuDividerProps {
hidden?: boolean
}
export function CollapseMenuDivider(props: CollapseMe... | 2,720 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/CollapseOverflowMenu.tsx | import {Menu, MenuButton, MenuButtonProps, MenuDivider, MenuItem} from '@sanity/ui'
import React, {ForwardedRef, forwardRef} from 'react'
import {CollapseMenuProps} from './CollapseMenu'
const MENU_BUTTON_POPOVER_PROPS: MenuButtonProps['popover'] = {
portal: true,
constrainSize: true,
}
export const CollapseOverf... | 2,721 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/ObserveElement.tsx | import {Flex} from '@sanity/ui'
import React, {useEffect, useState} from 'react'
interface ObserveElementProps {
children: React.ReactElement
options?: IntersectionObserverInit
onIntersectionChange: IntersectionObserverCallback
}
export function ObserveElement(props: ObserveElementProps) {
const {onIntersecti... | 2,722 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/index.ts | export * from './CollapseMenu'
export * from './CollapseMenuButton'
| 2,723 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/__workshop__/CollapseMenuStory.tsx | import {EllipsisVerticalIcon, IceCreamIcon} from '@sanity/icons'
import {Button, Card, Flex} from '@sanity/ui'
import {useBoolean, useSelect} from '@sanity/ui-workshop'
import React from 'react'
import {CollapseMenu, CollapseMenuButton} from '../'
const GAP_OPTIONS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4}
export de... | 2,724 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/collapseMenu/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/collapseMenu',
title: 'CollapseMenu',
stories: [
{
name: 'collapse-menu',
title: 'Default',
component: lazy(() => import('./CollapseMenuStory')),
},
],
})
| 2,725 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/CommandList.tsx | import {Box, rem, Stack} from '@sanity/ui'
import {ScrollToOptions, useVirtualizer, Virtualizer} from '@tanstack/react-virtual'
import throttle from 'lodash/throttle'
import React, {
cloneElement,
forwardRef,
ReactElement,
useCallback,
useEffect,
useId,
useImperativeHandle,
useMemo,
useRef,
useState... | 2,726 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/index.ts | export * from './CommandList'
export * from './types'
| 2,727 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/types.ts | import {ResponsivePaddingProps} from '@sanity/ui'
import {ScrollToOptions} from '@tanstack/react-virtual'
import {ReactNode} from 'react'
/** @internal */
export type CommandListElementType = 'input' | 'list'
/** @internal */
export type CommandListGetItemDisabledCallback = (virtualIndex: number) => boolean
/** @int... | 2,728 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/__tests__/CommandList.test.tsx | // eslint-disable-next-line import/no-unassigned-import
import '@testing-library/jest-dom/extend-expect'
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React, {useCallback} from 'react'
import {studioTheme, ThemeProvider} from '@sanity/ui'
import {Comman... | 2,729 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/__workshop__/FilterableStory.tsx | import {Box, Card, Flex, Stack, Text, TextInput} from '@sanity/ui'
import {useBoolean} from '@sanity/ui-workshop'
import React, {KeyboardEvent, useCallback, useMemo, useRef, useState} from 'react'
import styled from 'styled-components'
import {CommandList} from '../CommandList'
import {CommandListHandle, CommandListRen... | 2,730 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/__workshop__/InfiniteScrollStory.tsx | import {Box, Card, Flex, Stack, Text, TextInput} from '@sanity/ui'
import {useBoolean} from '@sanity/ui-workshop'
import React, {KeyboardEvent, useCallback, useMemo, useRef, useState} from 'react'
import styled from 'styled-components'
import {CommandList} from '../CommandList'
import {CommandListHandle, CommandListRen... | 2,731 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/__workshop__/KitchenSinkStory.tsx | import {CheckmarkIcon, DotIcon} from '@sanity/icons'
import {Box, Button, Card, Flex, Stack, Text, TextInput} from '@sanity/ui'
import {useBoolean} from '@sanity/ui-workshop'
import React, {KeyboardEvent, useCallback, useMemo, useRef, useState} from 'react'
import styled from 'styled-components'
import {CommandList} fr... | 2,732 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/__workshop__/MinimalStory.tsx | import React, {useCallback, useRef} from 'react'
import styled from 'styled-components'
import {CommandList} from '../CommandList'
import {CommandListHandle, CommandListRenderItemCallback} from '../types'
const ITEMS = [...Array(5000).keys()].map((i) => `Item ${i}`)
const StyledLink = styled.a`
background: #1a1a1a;... | 2,733 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/__workshop__/PopoverStory.tsx | import {SelectIcon} from '@sanity/icons'
import {
Button,
Card,
Flex,
Inline,
Popover,
Stack,
useClickOutside,
useGlobalKeyDown,
} from '@sanity/ui'
import {useSelect} from '@sanity/ui-workshop'
import React, {useCallback, useState} from 'react'
import {CommandList} from '../CommandList'
import {Command... | 2,734 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/commandList/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/command-list',
title: 'CommandList',
stories: [
{
name: 'minimal',
title: 'Minimal',
component: lazy(() => import('./MinimalStory')),
},
{
name: 'filt... | 2,735 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/globalErrorHandler/GlobalErrorHandler.tsx | import React from 'react'
const errorHandlerScript = `
;(function () {
var _caughtErrors = []
var errorChannel = (function () {
var subscribers = []
function publish(msg) {
for (var i = 0; i < subscribers.length; i += 1) {
subscribers[i](msg)
}
}
function subscribe(subscriber... | 2,736 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/globalErrorHandler/_script.js | /* eslint-disable no-var */
/* eslint-disable prefer-arrow-callback */
/* eslint-disable prefer-template */
;(function () {
var _caughtErrors = []
var errorChannel = (function () {
var subscribers = []
function publish(msg) {
for (var i = 0; i < subscribers.length; i += 1) {
subscribers[i](... | 2,737 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/globalErrorHandler/index.ts | export * from './GlobalErrorHandler'
export * from './types'
| 2,738 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/globalErrorHandler/types.ts | /** @internal */
export interface GlobalErrorMessage {
error: Error | null
params: {
colno: number
lineno: number
error: Error
event: ErrorEvent | string
source?: string
}
}
/** @internal */
export type GlobalErrorSubscriber = (msg: GlobalErrorMessage) => void
/** @internal */
export type Gl... | 2,739 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/hookCollection/GetHookCollectionState.tsx | import type {ThrottleSettings} from 'lodash'
import React, {useCallback, useMemo, useRef, useState} from 'react'
import {isNonNullable, useThrottledCallback} from '../../util'
import {getHookId} from './actionId'
import {HookStateContainer} from './HookStateContainer'
import {cancelIdleCallback, requestIdleCallback} fr... | 2,740 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/hookCollection/HookStateContainer.ts | import React, {memo, useEffect, useRef} from 'react'
import shallowEquals from 'shallow-equals'
function useShallowCompareMemoize<T>(value: T): Array<T | undefined> {
const ref = useRef<T | undefined>(undefined)
if (!shallowEquals(value, ref.current)) {
ref.current = value
}
return [ref.current]
}
funct... | 2,741 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/hookCollection/actionId.ts | import {ActionHook} from './types'
const actionIds = new WeakMap<ActionHook<any, any>, string>()
let counter = 0
/** @internal */
export function getHookId<T, K>(actionHook: ActionHook<T, K>): string {
const cachedId = actionIds.get(actionHook)
if (cachedId) return cachedId
const id = `${actionHook.name || (... | 2,742 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/hookCollection/index.ts | export * from './GetHookCollectionState'
export * from './types'
| 2,743 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/hookCollection/requestIdleCallback.ts | const requestIdleCallbackShim: Window['requestIdleCallback'] = (callback) => {
const start = Date.now()
return setTimeout(() => {
callback({
didTimeout: false,
timeRemaining() {
return Math.max(0, Date.now() - start)
},
})
}, 1) as unknown as ReturnType<Window['requestIdleCallba... | 2,744 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/hookCollection/types.ts | /** @internal */
export type ActionHook<T, K> = (args: T) => K | null
| 2,745 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/image/Image.tsx | import createImageUrlBuilder from '@sanity/image-url'
import {ImageUrlFitMode} from '@sanity/types'
import React, {forwardRef, useMemo} from 'react'
import {useClient} from '../../hooks'
import {DEFAULT_STUDIO_CLIENT_OPTIONS} from '../../studioClient'
export interface ImageCrop {
_type: 'sanity.imageCrop'
top: num... | 2,746 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/image/index.ts | export * from './Image'
| 2,747 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/image | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/image/__workshop__/ImageStory.tsx | import React, {useMemo} from 'react'
import {Image, ImageSource} from '../Image'
export default function ImageStory() {
const assetId = 'image-7a450942c7845e53e1daddaffc2999f719352e16-3024x4032-jpg'
const source: ImageSource = useMemo(
() => ({
_type: 'image',
asset: {_ref: assetId, _type: 'refere... | 2,748 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/image | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/image/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/image',
title: 'Image',
stories: [
{
name: 'image',
title: 'Default',
component: lazy(() => import('./ImageStory')),
},
],
})
| 2,749 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/popoverDialog/PopoverContainer.tsx | import {
Container,
ContainerProps,
rem,
ResponsiveWidthStyleProps,
useArrayProp,
_responsive,
} from '@sanity/ui'
import React, {Ref} from 'react'
import styled from 'styled-components'
// This is a workaround to make sure that the Container gets the correct width when used inside a popover.
// The defaul... | 2,750 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/popoverDialog/PopoverDialog.tsx | import {CloseIcon} from '@sanity/icons'
import {
Box,
Button,
Flex,
Layer,
Popover,
PopoverProps,
ResponsiveWidthProps,
Stack,
Text,
Theme,
} from '@sanity/ui'
import React, {useCallback} from 'react'
import styled, {css} from 'styled-components'
import TrapFocus from 'react-focus-lock'
import {Popo... | 2,751 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/popoverDialog/index.ts | export * from './PopoverDialog'
| 2,752 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previewCard/PreviewCard.tsx | import {Card, CardProps} from '@sanity/ui'
import React, {createContext, forwardRef, useContext} from 'react'
import styled, {css} from 'styled-components'
/** @internal */
const StyledCard = styled(Card)(() => {
return css`
/* this is a hack to avoid layout jumps while previews are loading
there's probably ... | 2,753 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previewCard/index.ts | export * from './PreviewCard'
| 2,754 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previewCard | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previewCard/__workshop__/PreviewCardStory.tsx | import {EditIcon, PublishIcon} from '@sanity/icons'
import {Container, Flex} from '@sanity/ui'
import {useBoolean} from '@sanity/ui-workshop'
import React from 'react'
import {DocumentPreviewPresence} from '../../../presence'
import {TextWithTone} from '../../textWithTone'
import {PreviewCard} from '../PreviewCard'
ex... | 2,755 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previewCard | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previewCard/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/preview-card',
title: 'PreviewCard',
stories: [
{
name: 'preview-card',
title: 'Default',
component: lazy(() => import('./PreviewCardStory')),
},
],
})
| 2,756 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/constants.ts | import {PreviewLayoutKey} from './types'
export const PREVIEW_MEDIA_SIZE: Record<PreviewLayoutKey, {width: number; height: number}> = {
block: {width: 33, height: 33},
blockImage: {width: 600, height: 400},
default: {width: 35, height: 35},
detail: {width: 75, height: 75},
inline: {width: 15, height: 15},
... | 2,757 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/helpers.tsx | import React, {createElement} from 'react'
import {isValidElementType} from 'react-is'
import {PreviewLayoutKey, PreviewMediaDimensions} from './types'
export function renderPreviewMedia<Layout = PreviewLayoutKey>(
value: React.ReactNode | React.ElementType<{layout: Layout; dimensions: PreviewMediaDimensions}>,
la... | 2,758 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/index.ts | export * from './types'
// General previews
export * from './general/DefaultPreview'
export * from './general/DetailPreview'
export * from './general/MediaPreview'
// Portable text preview
export * from './portableText/BlockImagePreview'
export * from './portableText/BlockPreview'
export * from './portableText/Inline... | 2,759 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/types.ts | import type {ImageUrlFitMode, SchemaType} from '@sanity/types'
import type {ComponentType, ReactNode, ReactElement} from 'react'
/**
* Portable text preview layout key
*
* @public
*/
export type PortableTextPreviewLayoutKey = 'block' | 'blockImage' | 'inline'
/**
* General preview layout key
*
* @public
*/
ex... | 2,760 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/__workshop__/GeneralPreviewStory.tsx | import {DocumentIcon, EditIcon} from '@sanity/icons'
import {Card, Container, Flex, Text} from '@sanity/ui'
import {useBoolean, useNumber, useSelect, useString, useText} from '@sanity/ui-workshop'
import React, {createElement, useMemo} from 'react'
import {GeneralPreviewLayoutKey, PreviewProps} from '../types'
import {... | 2,761 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/__workshop__/InlinePreviewStory.tsx | import {DocumentIcon} from '@sanity/icons'
import {Card, Container, Flex, Heading, Stack, Text} from '@sanity/ui'
import {useBoolean, useString} from '@sanity/ui-workshop'
import React from 'react'
import styled from 'styled-components'
import {InlinePreview} from '../portableText/InlinePreview'
const PreviewWrapper =... | 2,762 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/__workshop__/PortableTextPreviewStory.tsx | import {DocumentIcon, EditIcon, EllipsisVerticalIcon} from '@sanity/icons'
import {Button, Card, Container, Flex, Text} from '@sanity/ui'
import {useBoolean, useSelect, useString} from '@sanity/ui-workshop'
import React, {ComponentType, createElement, useMemo} from 'react'
import {PortableTextPreviewLayoutKey, PreviewP... | 2,763 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/__workshop__/TemplatePreviewStory.tsx | import {DocumentIcon} from '@sanity/icons'
import {Card, Container, Flex, Text} from '@sanity/ui'
import {useBoolean, useSelect, useString, useText} from '@sanity/ui-workshop'
import React, {createElement} from 'react'
import {TemplatePreview, TemplatePreviewProps} from '../template/TemplatePreview'
type LayoutKey = '... | 2,764 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/previews',
title: 'Previews',
stories: [
{
name: 'general',
title: 'General preview',
component: lazy(() => import('./GeneralPreviewStory')),
},
{
nam... | 2,765 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/_common/Media.styled.ts | import {rem} from '@sanity/ui'
import styled, {css} from 'styled-components'
import {PREVIEW_ICON_SIZE} from '../constants'
import {PreviewLayoutKey, PreviewMediaDimensions} from '../types'
export const MediaWrapper = styled.span<{
$dimensions: PreviewMediaDimensions
$layout: PreviewLayoutKey
$radius: number
$... | 2,766 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/_common/Media.tsx | import {Text} from '@sanity/ui'
import React, {createElement, isValidElement} from 'react'
import {isValidElementType} from 'react-is'
import {PreviewMediaDimensions, PreviewLayoutKey, PreviewProps} from '../types'
import {MediaWrapper} from './Media.styled'
export interface MediaProps {
border?: boolean
dimension... | 2,767 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/general/DefaultPreview.tsx | import React from 'react'
import {Box, Flex, Stack, Text, Skeleton, TextSkeleton, rem} from '@sanity/ui'
import classNames from 'classnames'
import styled from 'styled-components'
import {getDevicePixelRatio} from 'use-device-pixel-ratio'
import {Media} from '../_common/Media'
import {PREVIEW_MEDIA_SIZE} from '../const... | 2,768 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/general/DetailPreview.styled.ts | import {Box, Flex, rem, Skeleton, Text, TextSkeleton} from '@sanity/ui'
import styled, {css} from 'styled-components'
import {PREVIEW_MEDIA_SIZE} from '../constants'
export const RootFlex = styled(Flex).attrs({align: 'center'})`
height: ${rem(PREVIEW_MEDIA_SIZE.detail.height)};
`
export const StatusBox = styled(Box... | 2,769 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/general/DetailPreview.tsx | import React from 'react'
import {Box, Flex, Stack, Text} from '@sanity/ui'
import {getDevicePixelRatio} from 'use-device-pixel-ratio'
import {Media} from '../_common/Media'
import {PREVIEW_MEDIA_SIZE} from '../constants'
import {PreviewMediaDimensions, PreviewProps} from '../types'
import {renderPreviewNode} from '../... | 2,770 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/general/MediaPreview.styled.ts | import {Box, Flex, rem, Skeleton, Stack} from '@sanity/ui'
import styled from 'styled-components'
export const RootBox = styled(Box)`
position: relative;
`
export const MediaFlex = styled(Flex).attrs({align: 'center', justify: 'center'})`
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
`
export... | 2,771 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/general/MediaPreview.tsx | import React, {useMemo} from 'react'
import {getDevicePixelRatio} from 'use-device-pixel-ratio'
import {Text, Tooltip} from '@sanity/ui'
import {CircularProgress} from '../../progress'
import {Media} from '../_common/Media'
import {PREVIEW_MEDIA_SIZE} from '../constants'
import {PreviewMediaDimensions, PreviewProps} fr... | 2,772 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/portableText/BlockImagePreview.styled.tsx | import {Box, Card, Flex, rem} from '@sanity/ui'
import styled from 'styled-components'
import {PREVIEW_MEDIA_SIZE} from '../constants'
export const HeaderFlex = styled(Flex).attrs({align: 'center'})`
box-shadow: 0 0 0 1px var(--card-border-color);
height: ${rem(PREVIEW_MEDIA_SIZE.block.height)};
white-space: now... | 2,773 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/portableText/BlockImagePreview.tsx | import {Box, Flex, Stack, Text} from '@sanity/ui'
import React from 'react'
import {getDevicePixelRatio} from 'use-device-pixel-ratio'
import {Media} from '../_common/Media'
import {PREVIEW_MEDIA_SIZE} from '../constants'
import {PreviewMediaDimensions, PreviewProps} from '../types'
import {renderPreviewNode} from '../... | 2,774 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/portableText/BlockPreview.tsx | import {Box, Flex, rem, Stack, Text} from '@sanity/ui'
import React from 'react'
import styled from 'styled-components'
import {getDevicePixelRatio} from 'use-device-pixel-ratio'
import {Media} from '../_common/Media'
import {PREVIEW_MEDIA_SIZE} from '../constants'
import {PreviewMediaDimensions, PreviewProps} from '..... | 2,775 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/portableText/InlinePreview.styled.tsx | import {rem, Text, Theme} from '@sanity/ui'
import styled, {css} from 'styled-components'
export const RootSpan = styled.span`
display: inline-flex;
align-items: center;
vertical-align: top;
height: calc(1em - 1px);
max-width: 100%;
`
export const MediaSpan = styled.span`
position: relative;
display: in... | 2,776 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/portableText/InlinePreview.tsx | import React from 'react'
import {getDevicePixelRatio} from 'use-device-pixel-ratio'
import {PREVIEW_MEDIA_SIZE} from '../constants'
import {renderPreviewMedia, renderPreviewNode} from '../helpers'
import {PreviewMediaDimensions, PreviewProps} from '../types'
import {RootSpan, MediaSpan, TextSpan} from './InlinePreview... | 2,777 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/previews/template/TemplatePreview.tsx | import React, {createElement, isValidElement} from 'react'
import {isValidElementType} from 'react-is'
import {Box, Flex, rem, Stack, Text, TextSkeleton} from '@sanity/ui'
import styled from 'styled-components'
import {getDevicePixelRatio} from 'use-device-pixel-ratio'
import {PreviewMediaDimensions} from '../types'
im... | 2,778 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/progress/CircularProgress.tsx | import {hues} from '@sanity/color'
import {Theme} from '@sanity/ui'
import React from 'react'
import styled, {css} from 'styled-components'
const SIZE = 43
const STROKE_WIDTH = 3
const Root = styled.svg`
width: ${SIZE}px;
height: ${SIZE}px;
transform: rotate(-90deg);
`
const BgCircle = styled.circle(({theme}: ... | 2,779 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/progress/LinearProgress.tsx | import {hues} from '@sanity/color'
import {Theme, Card} from '@sanity/ui'
import React from 'react'
import styled, {css} from 'styled-components'
const STROKE_WIDTH = 0.5
const Root = styled(Card)`
overflow: hidden;
overflow: clip;
`
const Bar = styled(Card)(({theme}: {theme: Theme}) => {
const {color} = theme... | 2,780 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/progress/index.ts | export * from './CircularProgress'
export * from './LinearProgress'
| 2,781 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/react-track-elements/createNoopTrackerScope.tsx | import React from 'react'
import {Reported} from './types'
// eslint-disable-next-line no-empty-function, @typescript-eslint/no-empty-function
function noop() {}
function NoopTracker({children}: {children: React.ReactNode}) {
return <>{children}</>
}
/** @internal */
export function createNoopTrackerScope<T>() {
... | 2,782 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/react-track-elements/createStore.ts | import {debounce} from 'lodash'
import createPubsub from 'nano-pubsub'
import {Reported} from './types'
export function createStore<Value>() {
const reportedValues = new Map<string, Value>()
const {publish, subscribe} = createPubsub<Reported<Value>[]>()
const debouncedPublish = debounce(publish, 10, {trailing: ... | 2,783 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/react-track-elements/createTrackerScope.tsx | import React from 'react'
import {Reported, TrackerContext} from './types'
import {createUseReporter, IsEqualFunction} from './createUseReporter'
import {createStore} from './createStore'
// Todo: consider memozing individual functions or move the context assertion/guard to a separate step.
let didWarn = false
const u... | 2,784 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/react-track-elements/createUseReporter.tsx | import React from 'react'
import {TrackerContext} from './types'
/** @internal */
export type ReporterHook<Payload> = (
id: string | null,
value: Payload | (() => Payload),
isEqual?: (a: Payload, b: Payload) => boolean,
) => void
function isFunc<T>(value: T | (() => T)): value is () => T {
return typeof value... | 2,785 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/react-track-elements/index.ts | export * from './createNoopTrackerScope'
export * from './createTrackerScope'
export * from './createUseReporter'
export * from './types'
| 2,786 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/react-track-elements/types.ts | import {Subscriber} from 'nano-pubsub'
/** @internal */
export type Reported<Value> = [string, Value]
/** @internal */
export interface TrackerContext<Value> {
add: (id: string, value: Value) => void
update: (id: string, value: Value) => void
remove: (id: string) => void
read: () => Reported<Value>[]
subscr... | 2,787 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus/index.ts | export * from './useRovingFocus'
export * from './types'
| 2,788 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus/types.ts | /**
* @hidden
* @beta */
export type RovingFocusNavigationType = 'arrows' | 'tab'
/**
* @hidden
* @beta */
export interface RovingFocusProps {
direction?: 'horizontal' | 'vertical'
initialFocus?: 'first' | 'last'
navigation?: RovingFocusNavigationType[]
loop?: boolean
pause?: boolean
rootElement: HTMLE... | 2,789 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus/useRovingFocus.ts | import {useCallback, useEffect, useState} from 'react'
import {RovingFocusProps} from './types'
const MUTATION_ATTRIBUTE_FILTER = ['aria-hidden', 'disabled', 'href']
const FOCUSABLE =
'a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'
function getFocusableElements(element: HTMLEle... | 2,790 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus/__tests__/useRovingFocus.test.tsx | // eslint-disable-next-line import/no-unassigned-import
import '@testing-library/jest-dom/extend-expect'
import {render, fireEvent} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React, {useState} from 'react'
import {Button, Card, studioTheme, ThemeProvider} from '@sanity/ui'
... | 2,791 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus/__workshop__/RovingFocusStory.tsx | import {Button, Card, Flex} from '@sanity/ui'
import {useBoolean, useSelect} from '@sanity/ui-workshop'
import React, {useState} from 'react'
import {useRovingFocus} from '../useRovingFocus'
const DIRECTION_OPTIONS: Record<string, 'horizontal' | 'vertical'> = {
horizontal: 'horizontal',
vertical: 'vertical',
}
co... | 2,792 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/rovingFocus/__workshop__/index.ts | import {defineScope} from '@sanity/ui-workshop'
import {lazy} from 'react'
export default defineScope({
name: 'core/components/rovingFocus',
title: 'Roving focus',
stories: [
{
name: 'roving-focus',
title: 'Default',
component: lazy(() => import('./RovingFocusStory')),
},
],
})
| 2,793 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/scroll/hooks.ts | import React from 'react'
import {ScrollContext} from './scrollContext'
import {Subscriber} from 'nano-pubsub'
/** @internal */
export function useOnScroll(callback: Subscriber<Event>) {
const parentContext = React.useContext(ScrollContext)
React.useEffect(() => {
return parentContext?.subscribe(callback)
},... | 2,794 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/scroll/index.ts | export * from './hooks'
export * from './scrollContainer'
export * from './scrollMonitor'
export * from './types'
| 2,795 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/scroll/scrollContainer.tsx | import {useForwardedRef} from '@sanity/ui'
import createPubSub from 'nano-pubsub'
import React, {useContext, useEffect, useMemo} from 'react'
import {ScrollContext} from './scrollContext'
/** @internal */
export interface ScrollContainerProps<T extends React.ElementType>
extends Omit<React.HTMLProps<T>, 'as' | 'onSc... | 2,796 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/scroll/scrollContext.ts | import React from 'react'
import {PubSub} from 'nano-pubsub'
export const ScrollContext = React.createContext<null | PubSub<Event>>(null)
| 2,797 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/scroll/scrollMonitor.tsx | import React from 'react'
import {useOnScroll} from './hooks'
import {ScrollEventHandler} from './types'
/** @internal */
export interface ScrollMonitorProps {
onScroll: ScrollEventHandler
children?: React.ReactNode
}
/** @internal */
export function ScrollMonitor({onScroll, children}: ScrollMonitorProps) {
use... | 2,798 |
0 | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components | petrpan-code/sanity-io/sanity/packages/sanity/src/core/components/scroll/types.ts | /** @internal */
export type ScrollEventHandler = (event: Event) => void
/** @internal */
export interface ScrollContextValue {
onScroll?: ScrollEventHandler
}
| 2,799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.